From e16866e072f94410321d70daedbcb855ea878cac Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 6 Nov 2011 15:56:40 -0600 Subject: Actually move the kde files that were renamed in the last commit --- kdecore/40.colors | 48 - kdecore/AUTHORS | 56 - kdecore/CMakeLists.txt | 209 - kdecore/DESIGN.COLOR | 141 - kdecore/DESIGN.iconloading | 187 - kdecore/DESIGN.kconfig | 224 - kdecore/KCONFIG_DESIGN | 51 - kdecore/MAINTAINERS | 116 - kdecore/Mainpage.dox | 42 - kdecore/Makefile.am | 195 - kdecore/README | 3 - kdecore/README.exec | 41 - kdecore/README.kiosk | 681 -- kdecore/README.kstartupinfo | 282 - kdecore/README.user_profiles | 136 - kdecore/Rainbow.colors | 118 - kdecore/Royal.colors | 258 - kdecore/Web.colors | 218 - kdecore/all_languages.desktop | 11919 ------------------- kdecore/configure.in.in | 234 - kdecore/eventsrc | 2741 ----- kdecore/fakes.c | 365 - kdecore/fixx11h.h | 236 - kdecore/generate_keys.sh | 63 - kdecore/kaboutdata.cpp | 512 - kdecore/kaboutdata.h | 629 - kdecore/kaccel.cpp | 663 -- kdecore/kaccel.h | 390 - kdecore/kaccelaction.cpp | 565 - kdecore/kaccelaction.h | 576 - kdecore/kaccelbase.cpp | 616 - kdecore/kaccelbase.h | 282 - kdecore/kaccelmanager.cpp | 872 -- kdecore/kaccelmanager.h | 88 - kdecore/kaccelmanager_private.h | 196 - kdecore/kaccelprivate.h | 53 - kdecore/kallocator.cpp | 260 - kdecore/kallocator.h | 140 - kdecore/kapp.h | 6 - kdecore/kappdcopiface.cpp | 70 - kdecore/kappdcopiface.h | 80 - kdecore/kapplication.cpp | 3616 ------ kdecore/kapplication.h | 1620 --- kdecore/kapplication_win.cpp | 117 - kdecore/kasyncio.cpp | 27 - kdecore/kasyncio.h | 95 - kdecore/kaudioplayer.cpp | 56 - kdecore/kaudioplayer.h | 93 - kdecore/kbufferedio.cpp | 309 - kdecore/kbufferedio.h | 300 - kdecore/kcalendarsystem.cpp | 146 - kdecore/kcalendarsystem.h | 357 - kdecore/kcalendarsystemfactory.cpp | 70 - kdecore/kcalendarsystemfactory.h | 65 - kdecore/kcalendarsystemgregorian.cpp | 329 - kdecore/kcalendarsystemgregorian.h | 92 - kdecore/kcalendarsystemhebrew.cpp | 746 -- kdecore/kcalendarsystemhebrew.h | 105 - kdecore/kcalendarsystemhijri.cpp | 596 - kdecore/kcalendarsystemhijri.h | 98 - kdecore/kcalendarsystemjalali.cpp | 560 - kdecore/kcalendarsystemjalali.h | 83 - kdecore/kcatalogue.cpp | 161 - kdecore/kcatalogue.h | 129 - kdecore/kcharsets.cpp | 664 -- kdecore/kcharsets.h | 142 - kdecore/kcheckaccelerators.cpp | 216 - kdecore/kcheckaccelerators.h | 96 - kdecore/kckey.cpp | 286 - kdecore/kckey.h | 17 - kdecore/kclipboard.cpp | 199 - kdecore/kclipboard.h | 123 - kdecore/kcmdlineargs.cpp | 1298 -- kdecore/kcmdlineargs.h | 690 -- kdecore/kcompletion.cpp | 892 -- kdecore/kcompletion.h | 1010 -- kdecore/kcompletion_private.h | 216 - kdecore/kcompletionbase.cpp | 154 - kdecore/kconfig.cpp | 367 - kdecore/kconfig.h | 296 - kdecore/kconfig_compiler/CMakeLists.txt | 29 - kdecore/kconfig_compiler/Makefile.am | 18 - kdecore/kconfig_compiler/README.dox | 255 - kdecore/kconfig_compiler/TODO | 0 kdecore/kconfig_compiler/checkkcfg.pl | 83 - kdecore/kconfig_compiler/example/Makefile.am | 27 - kdecore/kconfig_compiler/example/autoexample.cpp | 64 - kdecore/kconfig_compiler/example/example.cpp | 52 - kdecore/kconfig_compiler/example/example.kcfg | 63 - .../example/exampleprefs_base.kcfgc | 18 - kdecore/kconfig_compiler/example/general_base.ui | 46 - kdecore/kconfig_compiler/example/myoptions_base.ui | 35 - kdecore/kconfig_compiler/kcfg.xsd | 192 - kdecore/kconfig_compiler/kconfig_compiler.cpp | 1700 --- kdecore/kconfig_compiler/tests/Makefile.am | 134 - .../tests/kconfigcompiler_test.cpp | 96 - .../kconfig_compiler/tests/kconfigcompiler_test.h | 35 - kdecore/kconfig_compiler/tests/myprefs.h | 7 - kdecore/kconfig_compiler/tests/test1.cpp.ref | 72 - kdecore/kconfig_compiler/tests/test1.h.ref | 196 - kdecore/kconfig_compiler/tests/test1.kcfg | 55 - kdecore/kconfig_compiler/tests/test1.kcfgc | 18 - kdecore/kconfig_compiler/tests/test1main.cpp | 29 - kdecore/kconfig_compiler/tests/test2.cpp.ref | 98 - kdecore/kconfig_compiler/tests/test2.h.ref | 333 - kdecore/kconfig_compiler/tests/test2.kcfg | 78 - kdecore/kconfig_compiler/tests/test2.kcfgc | 11 - kdecore/kconfig_compiler/tests/test2main.cpp | 29 - kdecore/kconfig_compiler/tests/test3.cpp.ref | 29 - kdecore/kconfig_compiler/tests/test3.h.ref | 138 - kdecore/kconfig_compiler/tests/test3.kcfg | 26 - kdecore/kconfig_compiler/tests/test3.kcfgc | 12 - kdecore/kconfig_compiler/tests/test3main.cpp | 29 - kdecore/kconfig_compiler/tests/test4.cpp.ref | 82 - kdecore/kconfig_compiler/tests/test4.h.ref | 135 - kdecore/kconfig_compiler/tests/test4.kcfg | 42 - kdecore/kconfig_compiler/tests/test4.kcfgc | 11 - kdecore/kconfig_compiler/tests/test4main.cpp | 30 - kdecore/kconfig_compiler/tests/test5.cpp.ref | 82 - kdecore/kconfig_compiler/tests/test5.h.ref | 127 - kdecore/kconfig_compiler/tests/test5.kcfg | 42 - kdecore/kconfig_compiler/tests/test5.kcfgc | 11 - kdecore/kconfig_compiler/tests/test5main.cpp | 30 - kdecore/kconfig_compiler/tests/test6.cpp.ref | 31 - kdecore/kconfig_compiler/tests/test6.h.ref | 93 - kdecore/kconfig_compiler/tests/test6.kcfg | 25 - kdecore/kconfig_compiler/tests/test6.kcfgc | 11 - kdecore/kconfig_compiler/tests/test6main.cpp | 30 - kdecore/kconfig_compiler/tests/test7.cpp.ref | 31 - kdecore/kconfig_compiler/tests/test7.h.ref | 93 - kdecore/kconfig_compiler/tests/test7.kcfg | 25 - kdecore/kconfig_compiler/tests/test7.kcfgc | 11 - kdecore/kconfig_compiler/tests/test7main.cpp | 30 - kdecore/kconfig_compiler/tests/test8a.cpp.ref | 22 - kdecore/kconfig_compiler/tests/test8a.h.ref | 61 - kdecore/kconfig_compiler/tests/test8a.kcfg | 17 - kdecore/kconfig_compiler/tests/test8a.kcfgc | 3 - kdecore/kconfig_compiler/tests/test8b.cpp.ref | 46 - kdecore/kconfig_compiler/tests/test8b.h.ref | 96 - kdecore/kconfig_compiler/tests/test8b.kcfg | 21 - kdecore/kconfig_compiler/tests/test8b.kcfgc | 6 - kdecore/kconfig_compiler/tests/test8main.cpp | 34 - kdecore/kconfig_compiler/tests/test9.cpp.ref | 35 - kdecore/kconfig_compiler/tests/test9.h.ref | 82 - kdecore/kconfig_compiler/tests/test9.kcfg | 24 - kdecore/kconfig_compiler/tests/test9.kcfgc | 18 - kdecore/kconfig_compiler/tests/test9main.cpp | 43 - .../kconfig_compiler/tests/test_dpointer.cpp.ref | 344 - kdecore/kconfig_compiler/tests/test_dpointer.h.ref | 224 - kdecore/kconfig_compiler/tests/test_dpointer.kcfg | 78 - kdecore/kconfig_compiler/tests/test_dpointer.kcfgc | 11 - .../kconfig_compiler/tests/test_dpointer_main.cpp | 30 - kdecore/kconfigbackend.cpp | 1186 -- kdecore/kconfigbackend.h | 299 - kdecore/kconfigbase.cpp | 1935 --- kdecore/kconfigbase.h | 2180 ---- kdecore/kconfigdata.h | 146 - kdecore/kconfigdialogmanager.cpp | 398 - kdecore/kconfigdialogmanager.h | 236 - kdecore/kconfigskeleton.cpp | 1207 -- kdecore/kconfigskeleton.h | 1230 -- kdecore/kcrash.cpp | 524 - kdecore/kcrash.h | 127 - kdecore/kdcoppropertyproxy.cpp | 335 - kdecore/kdcoppropertyproxy.h | 106 - kdecore/kde-config.cpp.cmake | 272 - kdecore/kde-config.cpp.in | 270 - kdecore/kde_dmalloc.h | 28 - kdecore/kde_file.h | 125 - kdecore/kdebug.areas | 599 - kdecore/kdebug.cpp | 596 - kdecore/kdebug.h | 665 -- kdecore/kdebugclasses.h | 33 - kdecore/kdebugdcopiface.cpp | 40 - kdecore/kdebugdcopiface.h | 52 - kdecore/kdebugrc | 142 - kdecore/kdelibs_export.h | 86 - kdecore/kdemacros.h.cmake | 220 - kdecore/kdemacros.h.in | 220 - kdecore/kdesktopfile.cpp | 367 - kdecore/kdesktopfile.h | 253 - kdecore/kdetcompmgr.cpp | 115 - kdecore/kdeversion.cpp | 46 - kdecore/kdeversion.h | 79 - kdecore/kentities.c | 837 -- kdecore/kentities.gperf | 317 - kdecore/kextendedsocket.h | 4 - kdecore/kextsock.cpp | 2251 ---- kdecore/kextsock.h | 1130 -- kdecore/kgenericfactory.h | 397 - kdecore/kgenericfactory.tcc | 272 - kdecore/kglobal.cpp | 264 - kdecore/kglobal.h | 237 - kdecore/kglobalaccel.cpp | 139 - kdecore/kglobalaccel.h | 239 - kdecore/kglobalaccel_emb.h | 18 - kdecore/kglobalaccel_mac.h | 31 - kdecore/kglobalaccel_win.cpp | 345 - kdecore/kglobalaccel_win.h | 77 - kdecore/kglobalaccel_x11.cpp | 441 - kdecore/kglobalaccel_x11.h | 110 - kdecore/kglobalsettings.cpp | 774 -- kdecore/kglobalsettings.h | 584 - kdecore/kgrantpty.c | 179 - kdecore/kiconeffect.cpp | 920 -- kdecore/kiconeffect.h | 231 - kdecore/kiconloader.cpp | 1411 --- kdecore/kiconloader.h | 553 - kdecore/kiconloader_p.h | 60 - kdecore/kicontheme.cpp | 605 - kdecore/kicontheme.h | 369 - kdecore/kidna.cpp | 63 - kdecore/kidna.h | 51 - kdecore/kinstance.cpp | 283 - kdecore/kinstance.h | 159 - kdecore/kipc.cpp | 113 - kdecore/kipc.h | 79 - kdecore/kkeynative.h | 258 - kdecore/kkeynative_x11.cpp | 201 - kdecore/kkeyserver.h | 29 - kdecore/kkeyserver_x11.cpp | 1053 -- kdecore/kkeyserver_x11.h | 477 - kdecore/klargefile.h | 27 - kdecore/klibloader.cpp | 580 - kdecore/klibloader.h | 405 - kdecore/klocale.cpp | 2474 ---- kdecore/klocale.h | 1350 --- kdecore/klockfile.cpp | 376 - kdecore/klockfile.h | 123 - kdecore/kmacroexpander.cpp | 529 - kdecore/kmacroexpander.h | 380 - kdecore/kmanagerselection.cpp | 490 - kdecore/kmanagerselection.h | 233 - kdecore/kmdcodec.cpp | 1510 --- kdecore/kmdcodec.h | 745 -- kdecore/kmdcodec_compat.h | 4 - kdecore/kmimesourcefactory.cpp | 106 - kdecore/kmimesourcefactory.h | 85 - kdecore/kmountpoint.cpp | 385 - kdecore/kmountpoint.h | 116 - kdecore/kmultipledrag.cpp | 82 - kdecore/kmultipledrag.h | 105 - kdecore/knotifyclient.cpp | 363 - kdecore/knotifyclient.h | 325 - kdecore/kpalette.cpp | 237 - kdecore/kpalette.h | 228 - kdecore/kpixmapprovider.cpp | 27 - kdecore/kpixmapprovider.h | 55 - kdecore/kprocctrl.cpp | 277 - kdecore/kprocctrl.h | 150 - kdecore/kprocess.cpp | 1137 -- kdecore/kprocess.h | 939 -- kdecore/kprocio.cpp | 276 - kdecore/kprocio.h | 217 - kdecore/kprotocolinfo_kdecore.cpp | 562 - kdecore/kprotocolinfofactory.cpp | 113 - kdecore/kprotocolinfofactory.h | 91 - kdecore/kpty.cpp | 579 - kdecore/kpty.h | 159 - kdecore/kqiodevicegzip_p.cpp | 163 - kdecore/kqiodevicegzip_p.h | 68 - kdecore/krandomsequence.cpp | 239 - kdecore/krandomsequence.h | 145 - kdecore/kregexp.cpp | 210 - kdecore/kregexp.h | 129 - kdecore/kregpriv.h | 57 - kdecore/krfcdate.cpp | 505 - kdecore/krfcdate.h | 100 - kdecore/krootprop.cpp | 303 - kdecore/krootprop.h | 206 - kdecore/ksavefile.cpp | 230 - kdecore/ksavefile.h | 152 - kdecore/ksharedptr.h | 175 - kdecore/kshell.cpp | 377 - kdecore/kshell.h | 147 - kdecore/kshortcut.cpp | 671 -- kdecore/kshortcut.h | 851 -- kdecore/kshortcutlist.cpp | 220 - kdecore/kshortcutlist.h | 295 - kdecore/kshortcutmenu.cpp | 161 - kdecore/kshortcutmenu.h | 61 - kdecore/ksimpleconfig.cpp | 81 - kdecore/ksimpleconfig.h | 81 - kdecore/ksock.cpp | 435 - kdecore/ksock.h | 350 - kdecore/ksockaddr.cpp | 894 -- kdecore/ksockaddr.h | 683 -- kdecore/ksocks.cpp | 600 - kdecore/ksocks.h | 210 - kdecore/ksortablevaluelist.h | 171 - kdecore/kstandarddirs.cpp | 1705 --- kdecore/kstandarddirs.h | 729 -- kdecore/kstartupinfo.cpp | 1529 --- kdecore/kstartupinfo.h | 697 -- kdecore/kstaticdeleter.cpp | 10 - kdecore/kstaticdeleter.h | 139 - kdecore/kstdaccel.cpp | 396 - kdecore/kstdaccel.h | 492 - kdecore/kstddirs.h | 6 - kdecore/kstringhandler.cpp | 663 -- kdecore/kstringhandler.h | 441 - kdecore/ksycoca.cpp | 528 - kdecore/ksycoca.h | 187 - kdecore/ksycocadict.cpp | 454 - kdecore/ksycocadict.h | 123 - kdecore/ksycocaentry.h | 123 - kdecore/ksycocafactory.cpp | 202 - kdecore/ksycocafactory.h | 143 - kdecore/ksycocatype.h | 64 - kdecore/ktempdir.cpp | 218 - kdecore/ktempdir.h | 172 - kdecore/ktempfile.cpp | 289 - kdecore/ktempfile.h | 213 - kdecore/ktimezones.cpp | 790 -- kdecore/ktimezones.h | 351 - kdecore/ktypelist.h | 473 - kdecore/kuniqueapp.h | 6 - kdecore/kuniqueapplication.cpp | 495 - kdecore/kuniqueapplication.h | 221 - kdecore/kunload.h | 22 - kdecore/kurl.cpp | 2356 ---- kdecore/kurl.h | 1828 --- kdecore/kurldrag.cpp | 294 - kdecore/kurldrag.h | 165 - kdecore/kuser.cpp | 425 - kdecore/kuser.h | 384 - kdecore/kvmallocator.cpp | 274 - kdecore/kvmallocator.h | 119 - kdecore/kwin.cpp | 1267 -- kdecore/kwin.h | 721 -- kdecore/kwinmodule.cpp | 482 - kdecore/kwinmodule.h | 362 - kdecore/kxerrorhandler.cpp | 121 - kdecore/kxerrorhandler.h | 104 - kdecore/kxmessages.cpp | 214 - kdecore/kxmessages.h | 172 - kdecore/language.codes | 3 - kdecore/libintl.cpp | 420 - kdecore/libkdecore.nmcheck | 79 - kdecore/libkdecore_weak.nmcheck | 28 - kdecore/libqt-mt.nmcheck | 43 - kdecore/libqt-mt_weak.nmcheck | 34 - kdecore/malloc/CMakeLists.txt | 18 - kdecore/malloc/Makefile.am | 31 - kdecore/malloc/README | 56 - kdecore/malloc/configure.in.in | 134 - kdecore/malloc/glibc.h | 31 - kdecore/malloc/malloc.c | 5758 --------- kdecore/malloc/x86.h | 41 - kdecore/netsupp.cpp | 1237 -- kdecore/netsupp.h | 301 - kdecore/netsupp_win32.cpp | 65 - kdecore/netwm.cpp | 4645 -------- kdecore/netwm.h | 1471 --- kdecore/netwm_def.h | 671 -- kdecore/netwm_p.h | 155 - kdecore/network/CMakeLists.txt | 54 - kdecore/network/Makefile.am | 59 - kdecore/network/ipv6blacklist | 3 - kdecore/network/kbufferedsocket.cpp | 424 - kdecore/network/kbufferedsocket.h | 269 - kdecore/network/kclientsocketbase.cpp | 490 - kdecore/network/kclientsocketbase.h | 532 - kdecore/network/kdatagramsocket.cpp | 283 - kdecore/network/kdatagramsocket.h | 279 - kdecore/network/khttpproxysocketdevice.cpp | 281 - kdecore/network/khttpproxysocketdevice.h | 122 - kdecore/network/kiobuffer.h | 144 - kdecore/network/kmulticastsocket.h | 113 - kdecore/network/kmulticastsocketdevice.h | 151 - kdecore/network/knetworkinterface.h | 46 - kdecore/network/kresolver.cpp | 1164 -- kdecore/network/kresolver.h | 946 -- kdecore/network/kresolver_p.h | 353 - kdecore/network/kresolvermanager.cpp | 822 -- kdecore/network/kresolverstandardworkers.cpp | 1028 -- kdecore/network/kresolverstandardworkers_p.h | 111 - kdecore/network/kresolverworkerbase.cpp | 147 - kdecore/network/kresolverworkerbase.h | 317 - kdecore/network/kreverseresolver.cpp | 263 - kdecore/network/kreverseresolver.h | 196 - kdecore/network/kserversocket.cpp | 413 - kdecore/network/kserversocket.h | 436 - kdecore/network/ksocketaddress.cpp | 957 -- kdecore/network/ksocketaddress.h | 912 -- kdecore/network/ksocketbase.cpp | 327 - kdecore/network/ksocketbase.h | 771 -- kdecore/network/ksocketbuffer.cpp | 329 - kdecore/network/ksocketbuffer_p.h | 164 - kdecore/network/ksocketdevice.cpp | 891 -- kdecore/network/ksocketdevice.h | 433 - kdecore/network/ksockssocketdevice.cpp | 487 - kdecore/network/ksockssocketdevice.h | 129 - kdecore/network/ksrvresolverworker.cpp | 257 - kdecore/network/ksrvresolverworker_p.h | 86 - kdecore/network/kstreamsocket.cpp | 368 - kdecore/network/kstreamsocket.h | 250 - kdecore/network/syssocket.h | 93 - kdecore/standard_weak.nmcheck | 6 - kdecore/svgicons/CMakeLists.txt | 38 - kdecore/svgicons/Makefile.am | 6 - kdecore/svgicons/TODO | 5 - kdecore/svgicons/ksvgiconengine.cpp | 692 -- kdecore/svgicons/ksvgiconengine.h | 49 - kdecore/svgicons/ksvgiconpainter.cpp | 2837 ----- kdecore/svgicons/ksvgiconpainter.h | 101 - kdecore/tests/KIDLTest.cpp | 33 - kdecore/tests/KIDLTest.h | 16 - kdecore/tests/KIDLTestClient.cpp | 17 - kdecore/tests/Makefile.am | 86 - kdecore/tests/cplusplustest.cpp | 44 - kdecore/tests/dcopkonqtest.cpp | 36 - kdecore/tests/kapptest.cpp | 40 - kdecore/tests/kcalendartest.cpp | 152 - kdecore/tests/kcharsetstest.cpp | 12 - kdecore/tests/kcmdlineargstest.cpp | 91 - kdecore/tests/kconfigtest.cpp | 162 - kdecore/tests/kconfigtestgui.cpp | 200 - kdecore/tests/kconfigtestgui.h | 72 - kdecore/tests/kdebugtest.cpp | 98 - kdecore/tests/kglobaltest.cpp | 64 - kdecore/tests/kiconloadertest.cpp | 34 - kdecore/tests/kipctest.cpp | 33 - kdecore/tests/kipctest.h | 21 - kdecore/tests/klocaletest.cpp | 199 - kdecore/tests/klocaletest.h | 32 - kdecore/tests/kmacroexpandertest.cpp | 137 - kdecore/tests/kmdcodectest.cpp | 395 - kdecore/tests/kmemtest.cpp | 248 - kdecore/tests/knotifytest.cpp | 10 - kdecore/tests/kprocesstest.cpp | 116 - kdecore/tests/kprocesstest.h | 50 - kdecore/tests/kprociotest.cpp | 65 - kdecore/tests/kprociotest.h | 42 - kdecore/tests/krandomsequencetest.cpp | 91 - kdecore/tests/kresolvertest.cpp | 420 - kdecore/tests/krfcdatetest.cpp | 81 - kdecore/tests/kshelltest.cpp | 55 - kdecore/tests/ksimpleconfigtest.cpp | 48 - kdecore/tests/ksocktest.cpp | 109 - kdecore/tests/ksortablevaluelisttest.cpp | 32 - kdecore/tests/kstdacceltest.cpp | 39 - kdecore/tests/kstddirstest.cpp | 52 - kdecore/tests/kstringhandlertest.cpp | 97 - kdecore/tests/ktempfiletest.cpp | 48 - kdecore/tests/ktimezonestest.cpp | 62 - kdecore/tests/kuniqueapptest.cpp | 59 - kdecore/tests/kurltest.cpp | 1124 -- kdecore/tests/kxerrorhandlertest.cpp | 54 - kdecore/tests/startserviceby.cpp | 41 - kdecore/tests/testqtargs.cpp | 104 - kdecore/vsnprintf.c | 170 - kdefx/CMakeLists.txt | 48 - kdefx/Mainpage.dox | 32 - kdefx/Makefile.am | 45 - kdefx/configure.in.in | 63 - kdefx/kcpuinfo.cpp | 176 - kdefx/kcpuinfo.h | 70 - kdefx/kdrawutil.cpp | 264 - kdefx/kdrawutil.h | 180 - kdefx/kimageeffect.cpp | 4980 -------- kdefx/kimageeffect.h | 817 -- kdefx/kpixmap.cpp | 389 - kdefx/kpixmap.h | 213 - kdefx/kpixmapeffect.cpp | 325 - kdefx/kpixmapeffect.h | 218 - kdefx/kpixmapsplitter.cpp | 95 - kdefx/kpixmapsplitter.h | 123 - kdefx/kstyle.cpp | 2370 ---- kdefx/kstyle.h | 356 - kdefx/libkdefx.nmcheck | 12 - kdefx/libkdefx_weak.nmcheck | 3 - kdeprint/CMakeLists.txt | 124 - kdeprint/ChangeLog | 619 - kdeprint/Makefile.am | 114 - kdeprint/TODO | 75 - kdeprint/TODO.cups12 | 293 - kdeprint/configure.in.in | 99 - kdeprint/cups/CMakeLists.txt | 97 - kdeprint/cups/Makefile.am | 49 - kdeprint/cups/configure.in.in | 18 - kdeprint/cups/cups.print | 68 - kdeprint/cups/cupsaddsmb2.cpp | 476 - kdeprint/cups/cupsaddsmb2.h | 77 - kdeprint/cups/cupsdconf2/CMakeLists.txt | 54 - kdeprint/cups/cupsdconf2/Makefile.am | 35 - kdeprint/cups/cupsdconf2/addressdialog.cpp | 89 - kdeprint/cups/cupsdconf2/addressdialog.h | 42 - kdeprint/cups/cupsdconf2/browsedialog.cpp | 150 - kdeprint/cups/cupsdconf2/browsedialog.h | 49 - kdeprint/cups/cupsdconf2/cups-util.c | 557 - kdeprint/cups/cupsdconf2/cups-util.h | 26 - kdeprint/cups/cupsdconf2/cups_logo.png | Bin 1487 -> 0 bytes kdeprint/cups/cupsdconf2/cupsd.conf.template | 977 -- kdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp | 210 - kdeprint/cups/cupsdconf2/cupsdbrowsingpage.h | 55 - kdeprint/cups/cupsdconf2/cupsdcomment.cpp | 136 - kdeprint/cups/cupsdconf2/cupsdcomment.h | 55 - kdeprint/cups/cupsdconf2/cupsdcomment.pl | 61 - kdeprint/cups/cupsdconf2/cupsdconf.cpp | 884 -- kdeprint/cups/cupsdconf2/cupsdconf.h | 181 - kdeprint/cups/cupsdconf2/cupsddialog.cpp | 356 - kdeprint/cups/cupsdconf2/cupsddialog.h | 58 - kdeprint/cups/cupsdconf2/cupsddirpage.cpp | 109 - kdeprint/cups/cupsdconf2/cupsddirpage.h | 47 - kdeprint/cups/cupsdconf2/cupsdfilterpage.cpp | 94 - kdeprint/cups/cupsdconf2/cupsdfilterpage.h | 45 - kdeprint/cups/cupsdconf2/cupsdjobspage.cpp | 123 - kdeprint/cups/cupsdconf2/cupsdjobspage.h | 47 - kdeprint/cups/cupsdconf2/cupsdlogpage.cpp | 111 - kdeprint/cups/cupsdconf2/cupsdlogpage.h | 44 - kdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp | 159 - kdeprint/cups/cupsdconf2/cupsdnetworkpage.h | 55 - kdeprint/cups/cupsdconf2/cupsdpage.cpp | 32 - kdeprint/cups/cupsdconf2/cupsdpage.h | 54 - kdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp | 168 - kdeprint/cups/cupsdconf2/cupsdsecuritypage.h | 56 - kdeprint/cups/cupsdconf2/cupsdserverpage.cpp | 181 - kdeprint/cups/cupsdconf2/cupsdserverpage.h | 49 - kdeprint/cups/cupsdconf2/cupsdsplash.cpp | 73 - kdeprint/cups/cupsdconf2/cupsdsplash.h | 35 - kdeprint/cups/cupsdconf2/editlist.cpp | 124 - kdeprint/cups/cupsdconf2/editlist.h | 60 - kdeprint/cups/cupsdconf2/kde_logo.png | Bin 15177 -> 0 bytes kdeprint/cups/cupsdconf2/locationdialog.cpp | 222 - kdeprint/cups/cupsdconf2/locationdialog.h | 58 - kdeprint/cups/cupsdconf2/main.cpp | 48 - kdeprint/cups/cupsdconf2/portdialog.cpp | 118 - kdeprint/cups/cupsdconf2/portdialog.h | 46 - kdeprint/cups/cupsdconf2/qdirlineedit.cpp | 73 - kdeprint/cups/cupsdconf2/qdirlineedit.h | 49 - kdeprint/cups/cupsdconf2/qdirmultilineedit.cpp | 109 - kdeprint/cups/cupsdconf2/qdirmultilineedit.h | 53 - kdeprint/cups/cupsdconf2/sizewidget.cpp | 83 - kdeprint/cups/cupsdconf2/sizewidget.h | 43 - kdeprint/cups/cupsdoprint.c | 257 - kdeprint/cups/cupsinfos.cpp | 166 - kdeprint/cups/cupsinfos.h | 88 - kdeprint/cups/image.cpp | 295 - kdeprint/cups/imageposition.cpp | 153 - kdeprint/cups/imageposition.h | 58 - kdeprint/cups/imagepreview.cpp | 78 - kdeprint/cups/imagepreview.h | 49 - kdeprint/cups/ippreportdlg.cpp | 96 - kdeprint/cups/ippreportdlg.h | 42 - kdeprint/cups/ipprequest.cpp | 544 - kdeprint/cups/ipprequest.h | 196 - kdeprint/cups/kcupsprinterimpl.cpp | 159 - kdeprint/cups/kcupsprinterimpl.h | 36 - kdeprint/cups/kmconfigcups.cpp | 51 - kdeprint/cups/kmconfigcups.h | 39 - kdeprint/cups/kmconfigcupsdir.cpp | 67 - kdeprint/cups/kmconfigcupsdir.h | 41 - kdeprint/cups/kmcupsconfigwidget.cpp | 159 - kdeprint/cups/kmcupsconfigwidget.h | 43 - kdeprint/cups/kmcupsfactory.cpp | 30 - kdeprint/cups/kmcupsjobmanager.cpp | 452 - kdeprint/cups/kmcupsjobmanager.h | 53 - kdeprint/cups/kmcupsmanager.cpp | 1077 -- kdeprint/cups/kmcupsmanager.h | 106 - kdeprint/cups/kmcupsuimanager.cpp | 219 - kdeprint/cups/kmcupsuimanager.h | 40 - kdeprint/cups/kmpropbanners.cpp | 81 - kdeprint/cups/kmpropbanners.h | 43 - kdeprint/cups/kmpropquota.cpp | 96 - kdeprint/cups/kmpropquota.h | 44 - kdeprint/cups/kmpropusers.cpp | 90 - kdeprint/cups/kmpropusers.h | 42 - kdeprint/cups/kmwbanners.cpp | 145 - kdeprint/cups/kmwbanners.h | 43 - kdeprint/cups/kmwfax.cpp | 81 - kdeprint/cups/kmwfax.h | 39 - kdeprint/cups/kmwipp.cpp | 86 - kdeprint/cups/kmwipp.h | 34 - kdeprint/cups/kmwippprinter.cpp | 227 - kdeprint/cups/kmwippprinter.h | 56 - kdeprint/cups/kmwippselect.cpp | 108 - kdeprint/cups/kmwippselect.h | 40 - kdeprint/cups/kmwother.cpp | 125 - kdeprint/cups/kmwother.h | 46 - kdeprint/cups/kmwquota.cpp | 171 - kdeprint/cups/kmwquota.h | 46 - kdeprint/cups/kmwusers.cpp | 96 - kdeprint/cups/kmwusers.h | 43 - kdeprint/cups/kphpgl2page.cpp | 169 - kdeprint/cups/kphpgl2page.h | 42 - kdeprint/cups/kpimagepage.cpp | 503 - kdeprint/cups/kpimagepage.h | 56 - kdeprint/cups/kpschedulepage.cpp | 282 - kdeprint/cups/kpschedulepage.h | 52 - kdeprint/cups/kptagspage.cpp | 164 - kdeprint/cups/kptagspage.h | 44 - kdeprint/cups/kptextpage.cpp | 375 - kdeprint/cups/kptextpage.h | 57 - kdeprint/cups/make_driver_db_cups.c | 149 - kdeprint/cups/postscript.ppd.gz | Bin 2317 -> 0 bytes kdeprint/cups/preview-mini.png | Bin 1809 -> 0 bytes kdeprint/cups/preview.png | Bin 12738 -> 0 bytes kdeprint/driver.cpp | 714 -- kdeprint/driver.h | 383 - kdeprint/driveritem.cpp | 151 - kdeprint/driveritem.h | 47 - kdeprint/driverparse.c | 434 - kdeprint/driverparse.h | 30 - kdeprint/driverview.cpp | 157 - kdeprint/driverview.h | 62 - kdeprint/droptionview.cpp | 358 - kdeprint/droptionview.h | 136 - kdeprint/ext/CMakeLists.txt | 50 - kdeprint/ext/Makefile.am | 15 - kdeprint/ext/ext.print | 84 - kdeprint/ext/kextprinterimpl.cpp | 52 - kdeprint/ext/kextprinterimpl.h | 35 - kdeprint/ext/kmextfactory.cpp | 28 - kdeprint/ext/kmextmanager.cpp | 49 - kdeprint/ext/kmextmanager.h | 40 - kdeprint/ext/kmextuimanager.cpp | 44 - kdeprint/ext/kmextuimanager.h | 35 - kdeprint/filters/CMakeLists.txt | 23 - kdeprint/filters/Makefile.am | 14 - kdeprint/filters/enscript.desktop | 104 - kdeprint/filters/enscript.xml | 38 - kdeprint/filters/imagetops | 69 - kdeprint/filters/imagetops.desktop | 107 - kdeprint/filters/imagetops.xml | 25 - kdeprint/filters/pdf2ps.desktop | 40 - kdeprint/filters/pdf2ps.xml | 152 - kdeprint/filters/pdfwrite.desktop | 102 - kdeprint/filters/pdfwrite.xml | 14 - kdeprint/filters/poster.desktop | 163 - kdeprint/filters/poster.xml | 82 - kdeprint/filters/ps2pdf.desktop | 92 - kdeprint/filters/ps2pdf.xml | 152 - kdeprint/filters/psbook.desktop | 93 - kdeprint/filters/psbook.xml | 14 - kdeprint/filters/psbook1.desktop | 94 - kdeprint/filters/psbook1.xml | 14 - kdeprint/filters/psbook2.desktop | 95 - kdeprint/filters/psbook2.xml | 14 - kdeprint/filters/psnup.desktop | 89 - kdeprint/filters/psnup.xml | 32 - kdeprint/filters/psresize.desktop | 99 - kdeprint/filters/psresize.xml | 24 - kdeprint/filters/psselect.desktop | 97 - kdeprint/filters/psselect.xml | 24 - kdeprint/foomatic/Makefile.am | 20 - kdeprint/foomatic/foomatic.print | 17 - kdeprint/foomatic/kfoomaticprinterimpl.cpp | 53 - kdeprint/foomatic/kfoomaticprinterimpl.h | 37 - kdeprint/foomatic/kmfoomaticfactory.cpp | 27 - kdeprint/foomatic/kmfoomaticmanager.cpp | 197 - kdeprint/foomatic/kmfoomaticmanager.h | 42 - kdeprint/foomatic/make_driver_db_foomatic.c | 192 - kdeprint/foomatic2loader.cpp | 302 - kdeprint/foomatic2loader.h | 57 - kdeprint/fooparser.cpp | 1005 -- kdeprint/fooparser.cpp.h | 15 - kdeprint/fooparser.y | 70 - kdeprint/fooscanner.cpp | 1707 --- kdeprint/fooscanner.l | 83 - kdeprint/kdeprintcheck.cpp | 134 - kdeprint/kdeprintcheck.h | 41 - kdeprint/kdeprintd.cpp | 315 - kdeprint/kdeprintd.desktop | 162 - kdeprint/kdeprintd.h | 66 - kdeprint/kdeprintrc | 7 - kdeprint/kdeprintrc.upd | 6 - kdeprint/kfilelist.cpp | 326 - kdeprint/kfilelist.h | 62 - kdeprint/kmdbentry.cpp | 62 - kdeprint/kmdbentry.h | 52 - kdeprint/kmfactory.cpp | 453 - kdeprint/kmfactory.h | 129 - kdeprint/kmjob.cpp | 136 - kdeprint/kmjob.h | 130 - kdeprint/kmjobmanager.cpp | 257 - kdeprint/kmjobmanager.h | 109 - kdeprint/kmmanager.cpp | 556 - kdeprint/kmmanager.h | 183 - kdeprint/kmobject.h | 56 - kdeprint/kmprinter.cpp | 224 - kdeprint/kmprinter.h | 236 - kdeprint/kmspecialmanager.cpp | 228 - kdeprint/kmspecialmanager.h | 52 - kdeprint/kmthreadjob.cpp | 170 - kdeprint/kmthreadjob.h | 53 - kdeprint/kmuimanager.cpp | 201 - kdeprint/kmuimanager.h | 94 - kdeprint/kmvirtualmanager.cpp | 371 - kdeprint/kmvirtualmanager.h | 75 - kdeprint/kpcopiespage.cpp | 349 - kdeprint/kpcopiespage.h | 64 - kdeprint/kpdriverpage.cpp | 63 - kdeprint/kpdriverpage.h | 41 - kdeprint/kpfileselectpage.cpp | 65 - kdeprint/kpfileselectpage.h | 40 - kdeprint/kpfilterpage.cpp | 416 - kdeprint/kpfilterpage.h | 68 - kdeprint/kpgeneralpage.cpp | 736 -- kdeprint/kpgeneralpage.h | 57 - kdeprint/kpipeprocess.cpp | 60 - kdeprint/kpipeprocess.h | 41 - kdeprint/kpmarginpage.cpp | 163 - kdeprint/kpmarginpage.h | 47 - kdeprint/kpposterpage.cpp | 341 - kdeprint/kpposterpage.h | 60 - kdeprint/kpqtpage.cpp | 336 - kdeprint/kpqtpage.h | 57 - kdeprint/kpreloadobject.cpp | 32 - kdeprint/kpreloadobject.h | 38 - kdeprint/kprintaction.cpp | 130 - kdeprint/kprintaction.h | 57 - kdeprint/kprintdialog.cpp | 987 -- kdeprint/kprintdialog.h | 88 - kdeprint/kprintdialogpage.cpp | 49 - kdeprint/kprintdialogpage.h | 190 - kdeprint/kprinter.cpp | 1045 -- kdeprint/kprinter.h | 780 -- kdeprint/kprinterimpl.cpp | 606 - kdeprint/kprinterimpl.h | 70 - kdeprint/kprinterpropertydialog.cpp | 147 - kdeprint/kprinterpropertydialog.h | 69 - kdeprint/kprintpreview.cpp | 328 - kdeprint/kprintpreview.h | 65 - kdeprint/kprintpreviewui.rc | 27 - kdeprint/kprintprocess.cpp | 94 - kdeprint/kprintprocess.h | 90 - kdeprint/kxmlcommand.cpp | 830 -- kdeprint/kxmlcommand.h | 121 - kdeprint/lpd/Makefile.am | 18 - kdeprint/lpd/gschecker.cpp | 61 - kdeprint/lpd/gschecker.h | 40 - kdeprint/lpd/klpdprinterimpl.cpp | 51 - kdeprint/lpd/klpdprinterimpl.h | 37 - kdeprint/lpd/kmlpdfactory.cpp | 52 - kdeprint/lpd/kmlpdfactory.h | 35 - kdeprint/lpd/kmlpdmanager.cpp | 651 - kdeprint/lpd/kmlpdmanager.h | 76 - kdeprint/lpd/kmlpduimanager.cpp | 60 - kdeprint/lpd/kmlpduimanager.h | 35 - kdeprint/lpd/lpd.print | 87 - kdeprint/lpd/lpdtools.cpp | 417 - kdeprint/lpd/lpdtools.h | 76 - kdeprint/lpd/make_driver_db_lpd.c | 112 - kdeprint/lpdunix/CMakeLists.txt | 52 - kdeprint/lpdunix/Makefile.am | 15 - kdeprint/lpdunix/klpdunixprinterimpl.cpp | 83 - kdeprint/lpdunix/klpdunixprinterimpl.h | 41 - kdeprint/lpdunix/kmlpdunixfactory.cpp | 29 - kdeprint/lpdunix/kmlpdunixmanager.cpp | 410 - kdeprint/lpdunix/kmlpdunixmanager.h | 42 - kdeprint/lpdunix/kmlpdunixuimanager.cpp | 45 - kdeprint/lpdunix/kmlpdunixuimanager.h | 35 - kdeprint/lpdunix/lpdunix.print | 83 - kdeprint/lpr/CMakeLists.txt | 80 - kdeprint/lpr/Makefile.am | 40 - kdeprint/lpr/apsdriver1 | 84 - kdeprint/lpr/apsdriver2 | 83 - kdeprint/lpr/apshandler.cpp | 405 - kdeprint/lpr/apshandler.h | 57 - kdeprint/lpr/editentrydialog.cpp | 157 - kdeprint/lpr/editentrydialog.h | 62 - kdeprint/lpr/klprfactory.cpp | 29 - kdeprint/lpr/klprprinterimpl.cpp | 59 - kdeprint/lpr/klprprinterimpl.h | 38 - kdeprint/lpr/kmconfiglpr.cpp | 66 - kdeprint/lpr/kmconfiglpr.h | 39 - kdeprint/lpr/kmlprjobmanager.cpp | 90 - kdeprint/lpr/kmlprjobmanager.h | 44 - kdeprint/lpr/kmlprmanager.cpp | 492 - kdeprint/lpr/kmlprmanager.h | 82 - kdeprint/lpr/kmlpruimanager.cpp | 67 - kdeprint/lpr/kmlpruimanager.h | 37 - kdeprint/lpr/lpchelper.cpp | 320 - kdeprint/lpr/lpchelper.h | 59 - kdeprint/lpr/lpqhelper.cpp | 117 - kdeprint/lpr/lpqhelper.h | 44 - kdeprint/lpr/lpr.print | 86 - kdeprint/lpr/lprhandler.cpp | 270 - kdeprint/lpr/lprhandler.h | 88 - kdeprint/lpr/lprngtooldriver1 | 85 - kdeprint/lpr/lprngtoolhandler.cpp | 393 - kdeprint/lpr/lprngtoolhandler.h | 54 - kdeprint/lpr/lprsettings.cpp | 146 - kdeprint/lpr/lprsettings.h | 67 - kdeprint/lpr/make_driver_db_lpr.c | 192 - kdeprint/lpr/matichandler.cpp | 481 - kdeprint/lpr/matichandler.h | 57 - kdeprint/lpr/matichelper.cpp | 38 - kdeprint/lpr/matichelper.h | 29 - kdeprint/lpr/printcapentry.cpp | 82 - kdeprint/lpr/printcapentry.h | 81 - kdeprint/lpr/printcapreader.cpp | 176 - kdeprint/lpr/printcapreader.h | 43 - kdeprint/management/CMakeLists.txt | 111 - kdeprint/management/Makefile.am | 52 - kdeprint/management/cjanuswidget.cpp | 265 - kdeprint/management/cjanuswidget.h | 64 - kdeprint/management/jobitem.cpp | 74 - kdeprint/management/jobitem.h | 55 - kdeprint/management/kaddprinterwizard.cpp | 39 - kdeprint/management/kdeprint_management_module.cpp | 56 - kdeprint/management/kiconselectaction.cpp | 118 - kdeprint/management/kiconselectaction.h | 49 - kdeprint/management/kmconfigcommand.cpp | 53 - kdeprint/management/kmconfigcommand.h | 31 - kdeprint/management/kmconfigdialog.cpp | 89 - kdeprint/management/kmconfigdialog.h | 43 - kdeprint/management/kmconfigfilter.cpp | 159 - kdeprint/management/kmconfigfilter.h | 52 - kdeprint/management/kmconfigfonts.cpp | 182 - kdeprint/management/kmconfigfonts.h | 54 - kdeprint/management/kmconfiggeneral.cpp | 142 - kdeprint/management/kmconfiggeneral.h | 50 - kdeprint/management/kmconfigjobs.cpp | 63 - kdeprint/management/kmconfigjobs.h | 40 - kdeprint/management/kmconfigpage.cpp | 36 - kdeprint/management/kmconfigpage.h | 53 - kdeprint/management/kmconfigpreview.cpp | 74 - kdeprint/management/kmconfigpreview.h | 41 - kdeprint/management/kmdbcreator.cpp | 187 - kdeprint/management/kmdbcreator.h | 58 - kdeprint/management/kmdriverdb.cpp | 244 - kdeprint/management/kmdriverdb.h | 67 - kdeprint/management/kmdriverdbwidget.cpp | 273 - kdeprint/management/kmdriverdbwidget.h | 74 - kdeprint/management/kmdriverdialog.cpp | 55 - kdeprint/management/kmdriverdialog.h | 44 - kdeprint/management/kmiconview.cpp | 237 - kdeprint/management/kmiconview.h | 78 - kdeprint/management/kminfopage.cpp | 143 - kdeprint/management/kminfopage.h | 42 - kdeprint/management/kminstancepage.cpp | 276 - kdeprint/management/kminstancepage.h | 58 - kdeprint/management/kmjobviewer.cpp | 742 -- kdeprint/management/kmjobviewer.h | 127 - kdeprint/management/kmlistview.cpp | 268 - kdeprint/management/kmlistview.h | 59 - kdeprint/management/kmmainview.cpp | 920 -- kdeprint/management/kmmainview.h | 133 - kdeprint/management/kmpages.cpp | 74 - kdeprint/management/kmpages.h | 44 - kdeprint/management/kmprinterpage.h | 42 - kdeprint/management/kmprinterview.cpp | 113 - kdeprint/management/kmprinterview.h | 62 - kdeprint/management/kmpropbackend.cpp | 86 - kdeprint/management/kmpropbackend.h | 45 - kdeprint/management/kmpropcontainer.cpp | 77 - kdeprint/management/kmpropcontainer.h | 50 - kdeprint/management/kmpropdriver.cpp | 83 - kdeprint/management/kmpropdriver.h | 46 - kdeprint/management/kmpropertypage.cpp | 94 - kdeprint/management/kmpropertypage.h | 53 - kdeprint/management/kmpropgeneral.cpp | 83 - kdeprint/management/kmpropgeneral.h | 44 - kdeprint/management/kmpropmembers.cpp | 70 - kdeprint/management/kmpropmembers.h | 42 - kdeprint/management/kmpropwidget.cpp | 86 - kdeprint/management/kmpropwidget.h | 63 - kdeprint/management/kmspecialprinterdlg.cpp | 222 - kdeprint/management/kmspecialprinterdlg.h | 57 - kdeprint/management/kmtimer.cpp | 96 - kdeprint/management/kmtimer.h | 62 - kdeprint/management/kmwbackend.cpp | 177 - kdeprint/management/kmwbackend.h | 54 - kdeprint/management/kmwclass.cpp | 141 - kdeprint/management/kmwclass.h | 46 - kdeprint/management/kmwdriver.cpp | 116 - kdeprint/management/kmwdriver.h | 40 - kdeprint/management/kmwdriverselect.cpp | 116 - kdeprint/management/kmwdriverselect.h | 48 - kdeprint/management/kmwdrivertest.cpp | 172 - kdeprint/management/kmwdrivertest.h | 53 - kdeprint/management/kmwend.cpp | 119 - kdeprint/management/kmwend.h | 38 - kdeprint/management/kmwfile.cpp | 77 - kdeprint/management/kmwfile.h | 39 - kdeprint/management/kmwinfobase.cpp | 90 - kdeprint/management/kmwinfobase.h | 51 - kdeprint/management/kmwinfopage.cpp | 48 - kdeprint/management/kmwinfopage.h | 31 - kdeprint/management/kmwizard.cpp | 262 - kdeprint/management/kmwizard.h | 101 - kdeprint/management/kmwizardpage.cpp | 48 - kdeprint/management/kmwizardpage.h | 52 - kdeprint/management/kmwlocal.cpp | 206 - kdeprint/management/kmwlocal.h | 58 - kdeprint/management/kmwlpd.cpp | 102 - kdeprint/management/kmwlpd.h | 34 - kdeprint/management/kmwname.cpp | 96 - kdeprint/management/kmwname.h | 35 - kdeprint/management/kmwpassword.cpp | 133 - kdeprint/management/kmwpassword.h | 43 - kdeprint/management/kmwsmb.cpp | 119 - kdeprint/management/kmwsmb.h | 50 - kdeprint/management/kmwsocket.cpp | 151 - kdeprint/management/kmwsocket.h | 51 - kdeprint/management/kmwsocketutil.cpp | 219 - kdeprint/management/kmwsocketutil.h | 76 - kdeprint/management/kxmlcommanddlg.cpp | 1059 -- kdeprint/management/kxmlcommanddlg.h | 127 - kdeprint/management/kxmlcommandselector.cpp | 285 - kdeprint/management/kxmlcommandselector.h | 68 - kdeprint/management/networkscanner.cpp | 421 - kdeprint/management/networkscanner.h | 95 - kdeprint/management/pluginaction.cpp | 34 - kdeprint/management/pluginaction.h | 42 - kdeprint/management/side.png | Bin 50353 -> 0 bytes kdeprint/management/sidepixmap.cpp | 69 - kdeprint/management/sidepixmap.h | 42 - kdeprint/management/smbview.cpp | 292 - kdeprint/management/smbview.h | 67 - kdeprint/management/tiledown.png | Bin 323 -> 0 bytes kdeprint/management/tileup.png | Bin 241 -> 0 bytes kdeprint/marginpreview.cpp | 331 - kdeprint/marginpreview.h | 65 - kdeprint/marginvaluewidget.cpp | 126 - kdeprint/marginvaluewidget.h | 57 - kdeprint/marginwidget.cpp | 376 - kdeprint/marginwidget.h | 75 - kdeprint/messagewindow.cpp | 121 - kdeprint/messagewindow.h | 55 - kdeprint/pics/CMakeLists.txt | 41 - kdeprint/pics/Makefile.am | 22 - kdeprint/pics/cr16-action-filterstop.png | Bin 740 -> 0 bytes kdeprint/pics/cr16-action-kdeprint_restartsrv.png | Bin 941 -> 0 bytes kdeprint/pics/cr16-action-kdeprint_uploadsmb.png | Bin 985 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_computer.png | Bin 913 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_job.png | Bin 474 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_job_cancelled.png | Bin 652 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_job_completed.png | Bin 634 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_job_error.png | Bin 646 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_job_process.png | Bin 729 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_job_stopped.png | Bin 651 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_printer.png | Bin 668 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_printer_class.png | Bin 769 -> 0 bytes .../cr16-app-kdeprint_printer_class_process.png | Bin 871 -> 0 bytes .../cr16-app-kdeprint_printer_class_stopped.png | Bin 888 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_printer_defect.png | Bin 847 -> 0 bytes .../pics/cr16-app-kdeprint_printer_process.png | Bin 770 -> 0 bytes kdeprint/pics/cr16-app-kdeprint_printer_remote.png | Bin 692 -> 0 bytes .../cr16-app-kdeprint_printer_remote_process.png | Bin 804 -> 0 bytes .../cr16-app-kdeprint_printer_remote_stopped.png | Bin 838 -> 0 bytes .../pics/cr16-app-kdeprint_printer_stopped.png | Bin 827 -> 0 bytes kdeprint/pics/cr22-action-history.png | Bin 1515 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_addprinter.png | Bin 1218 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_addpseudo.png | Bin 1261 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_configmgr.png | Bin 974 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_configsrv.png | Bin 1356 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_defaulthard.png | Bin 1239 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_defaultsoft.png | Bin 1317 -> 0 bytes .../pics/cr22-action-kdeprint_enableprinter.png | Bin 769 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_printer.png | Bin 1001 -> 0 bytes .../pics/cr22-action-kdeprint_printer_infos.png | Bin 1244 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_printstate.png | Bin 1029 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_queuestate.png | Bin 1339 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_report.png | Bin 818 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_restartsrv.png | Bin 1455 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_stopprinter.png | Bin 1330 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_testprinter.png | Bin 1021 -> 0 bytes kdeprint/pics/cr22-action-kdeprint_uploadsmb.png | Bin 1566 -> 0 bytes kdeprint/pics/cr22-action-package_utilities.png | Bin 1430 -> 0 bytes kdeprint/pics/cr22-app-kdeprint_printer.png | Bin 1001 -> 0 bytes kdeprint/pics/cr32-action-kdeprint_inklevel.png | Bin 2209 -> 0 bytes kdeprint/pics/cr32-app-kdeprint_printer.png | Bin 1331 -> 0 bytes kdeprint/pics/cr32-app-kdeprint_printer_class.png | Bin 1803 -> 0 bytes .../cr32-app-kdeprint_printer_class_process.png | Bin 1955 -> 0 bytes .../cr32-app-kdeprint_printer_class_stopped.png | Bin 2232 -> 0 bytes kdeprint/pics/cr32-app-kdeprint_printer_defect.png | Bin 1960 -> 0 bytes .../pics/cr32-app-kdeprint_printer_process.png | Bin 1558 -> 0 bytes kdeprint/pics/cr32-app-kdeprint_printer_remote.png | Bin 1398 -> 0 bytes .../cr32-app-kdeprint_printer_remote_process.png | Bin 1595 -> 0 bytes .../cr32-app-kdeprint_printer_remote_stopped.png | Bin 1924 -> 0 bytes .../pics/cr32-app-kdeprint_printer_stopped.png | Bin 1915 -> 0 bytes kdeprint/pics/cr32-app-kdeprint_printer_users.png | Bin 1939 -> 0 bytes kdeprint/pics/cr48-app-kdeprint_printer.png | Bin 2140 -> 0 bytes kdeprint/pics/cr48-app-kdeprint_printer_class.png | Bin 2931 -> 0 bytes kdeprint/pics/cr64-app-kdeprint_printer.png | Bin 2940 -> 0 bytes kdeprint/pics/cr64-app-kdeprint_printer_class.png | Bin 3930 -> 0 bytes kdeprint/pics/kdeprint_collate.png | Bin 1846 -> 0 bytes kdeprint/pics/kdeprint_collate_reverse.png | Bin 1807 -> 0 bytes kdeprint/pics/kdeprint_color.png | Bin 2503 -> 0 bytes kdeprint/pics/kdeprint_dupl_none.png | Bin 680 -> 0 bytes kdeprint/pics/kdeprint_duplex_long.png | Bin 249 -> 0 bytes kdeprint/pics/kdeprint_duplex_none.png | Bin 231 -> 0 bytes kdeprint/pics/kdeprint_duplex_short.png | Bin 267 -> 0 bytes kdeprint/pics/kdeprint_grayscale.png | Bin 1121 -> 0 bytes kdeprint/pics/kdeprint_landscape.png | Bin 884 -> 0 bytes kdeprint/pics/kdeprint_nup1.png | Bin 320 -> 0 bytes kdeprint/pics/kdeprint_nup2.png | Bin 317 -> 0 bytes kdeprint/pics/kdeprint_nup4.png | Bin 322 -> 0 bytes kdeprint/pics/kdeprint_nupother.png | Bin 406 -> 0 bytes kdeprint/pics/kdeprint_opt_duplex.png | Bin 1111 -> 0 bytes kdeprint/pics/kdeprint_pagesize.png | Bin 289 -> 0 bytes kdeprint/pics/kdeprint_portrait.png | Bin 891 -> 0 bytes kdeprint/pics/kdeprint_prettyprint.png | Bin 335 -> 0 bytes kdeprint/pics/kdeprint_revlandscape.png | Bin 891 -> 0 bytes kdeprint/pics/kdeprint_revportrait.png | Bin 895 -> 0 bytes kdeprint/pics/kdeprint_uncollate.png | Bin 2003 -> 0 bytes kdeprint/pics/kdeprint_uncollate_reverse.png | Bin 2034 -> 0 bytes kdeprint/pics/processsign.png | Bin 423 -> 0 bytes kdeprint/pics/stopsign.png | Bin 890 -> 0 bytes kdeprint/plugincombobox.cpp | 104 - kdeprint/plugincombobox.h | 50 - kdeprint/posterpreview.cpp | 294 - kdeprint/posterpreview.h | 75 - kdeprint/ppdloader.cpp | 531 - kdeprint/ppdloader.h | 74 - kdeprint/ppdparser.cpp | 1456 --- kdeprint/ppdparser.cpp.h | 81 - kdeprint/ppdparser.y | 118 - kdeprint/ppdscanner.cpp | 1914 --- kdeprint/ppdscanner.l | 141 - kdeprint/printerfilter.cpp | 71 - kdeprint/printerfilter.h | 49 - kdeprint/rlpr/CMakeLists.txt | 54 - kdeprint/rlpr/Makefile.am | 17 - kdeprint/rlpr/kmconfigproxy.cpp | 47 - kdeprint/rlpr/kmconfigproxy.h | 40 - kdeprint/rlpr/kmproprlpr.cpp | 75 - kdeprint/rlpr/kmproprlpr.h | 43 - kdeprint/rlpr/kmproxywidget.cpp | 71 - kdeprint/rlpr/kmproxywidget.h | 43 - kdeprint/rlpr/kmrlprfactory.cpp | 28 - kdeprint/rlpr/kmrlprmanager.cpp | 158 - kdeprint/rlpr/kmrlprmanager.h | 48 - kdeprint/rlpr/kmrlpruimanager.cpp | 55 - kdeprint/rlpr/kmrlpruimanager.h | 36 - kdeprint/rlpr/kmwrlpr.cpp | 210 - kdeprint/rlpr/kmwrlpr.h | 50 - kdeprint/rlpr/krlprprinterimpl.cpp | 76 - kdeprint/rlpr/krlprprinterimpl.h | 36 - kdeprint/rlpr/rlpr.print | 84 - kdeprint/signal_proc.c | 136 - kdeprint/specials.desktop | 1196 -- kdeprint/testprint.ps | 522 - kdeprint/tests/Makefile.am | 15 - kdeprint/tests/back.xpm | 105 - kdeprint/tests/drawdemo.cpp | 253 - kdeprint/tests/drawdemo.h | 30 - kdeprint/tests/forward.xpm | 110 - kdeprint/tests/helpwindow.cpp | 351 - kdeprint/tests/helpwindow.h | 65 - kdeprint/tests/home.xpm | 119 - kdeprint/tests/main.cpp | 41 - kdeprint/tests/richpage.cpp | 85 - kdeprint/tests/richpage.h | 24 - kdeprint/tools/CMakeLists.txt | 12 - kdeprint/tools/Makefile.am | 1 - kdeprint/tools/escputil/CMakeLists.txt | 42 - kdeprint/tools/escputil/Makefile.am | 12 - kdeprint/tools/escputil/escputil.desktop | 29 - kdeprint/tools/escputil/escpwidget.cpp | 261 - kdeprint/tools/escputil/escpwidget.h | 57 - kdeprint/treecombobox.cpp | 156 - kdeprint/treecombobox.h | 76 - kdeprint/util.cpp | 139 - kdeprint/util.h | 76 - kdesu/CMakeLists.txt | 57 - kdesu/Mainpage.dox | 21 - kdesu/Makefile.am | 30 - kdesu/README | 13 - kdesu/client.cpp | 435 - kdesu/client.h | 207 - kdesu/configure.in.in | 93 - kdesu/defaults.h | 21 - kdesu/kcookie.cpp | 225 - kdesu/kcookie.h | 90 - kdesu/kdesu_pty.cpp | 302 - kdesu/kdesu_pty.h | 71 - kdesu/kdesu_stub.c | 432 - kdesu/libkdesu.nmcheck | 10 - kdesu/libkdesu_weak.nmcheck | 2 - kdesu/process.cpp | 626 - kdesu/process.h | 188 - kdesu/ssh.cpp | 279 - kdesu/ssh.h | 90 - kdesu/stub.cpp | 184 - kdesu/stub.h | 139 - kdesu/su.cpp | 342 - kdesu/su.h | 63 - kdeui/AUTHORS | 97 - kdeui/CMakeLists.txt | 168 - kdeui/MAINTAINERS | 97 - kdeui/Mainpage.dox | 43 - kdeui/Makefile.am | 171 - kdeui/README.kspell | 17 - kdeui/TODO.kspell | 34 - kdeui/TODO.xmlgui | 91 - kdeui/about/CMakeLists.txt | 21 - kdeui/about/Makefile.am | 9 - kdeui/about/bar-bottom-left.png | Bin 369 -> 0 bytes kdeui/about/bar-bottom-middle.png | Bin 160 -> 0 bytes kdeui/about/bar-bottom-right.png | Bin 346 -> 0 bytes kdeui/about/bar-middle-left.png | Bin 126 -> 0 bytes kdeui/about/bar-middle-right.png | Bin 141 -> 0 bytes kdeui/about/bar-top-left.png | Bin 358 -> 0 bytes kdeui/about/bar-top-middle.png | Bin 145 -> 0 bytes kdeui/about/bar-top-right.png | Bin 359 -> 0 bytes kdeui/about/bottom-left.png | Bin 665 -> 0 bytes kdeui/about/bottom-middle.png | Bin 174 -> 0 bytes kdeui/about/bottom-right.png | Bin 4922 -> 0 bytes kdeui/about/box-bottom-left.png | Bin 470 -> 0 bytes kdeui/about/box-bottom-middle.png | Bin 103 -> 0 bytes kdeui/about/box-bottom-right.png | Bin 462 -> 0 bytes kdeui/about/box-middle-left.png | Bin 95 -> 0 bytes kdeui/about/box-middle-right.png | Bin 95 -> 0 bytes kdeui/about/box-top-left.png | Bin 450 -> 0 bytes kdeui/about/box-top-middle.png | Bin 104 -> 0 bytes kdeui/about/box-top-right.png | Bin 496 -> 0 bytes kdeui/about/kde_infopage.css | 239 - kdeui/about/kde_infopage_rtl.css | 11 - kdeui/about/top-left.png | Bin 10867 -> 0 bytes kdeui/about/top-middle.png | Bin 233 -> 0 bytes kdeui/about/usage-example.html | 64 - kdeui/aboutkde.png | Bin 29600 -> 0 bytes kdeui/colors/Makefile.am | 10 - kdeui/colors/README | 2 - kdeui/colors/rgb.txt | 753 -- kdeui/dcolorarrow.xbm | 6 - kdeui/dcolorreset.xpm | 19 - kdeui/kaboutapplication.cpp | 188 - kdeui/kaboutapplication.h | 94 - kdeui/kaboutdialog.cpp | 1797 --- kdeui/kaboutdialog.h | 633 - kdeui/kaboutdialog_private.h | 143 - kdeui/kaboutkde.cpp | 87 - kdeui/kaboutkde.h | 62 - kdeui/kaccelgen.h | 280 - kdeui/kaction.cpp | 1288 -- kdeui/kaction.h | 676 -- kdeui/kactionclasses.cpp | 2421 ---- kdeui/kactionclasses.h | 1436 --- kdeui/kactioncollection.cpp | 802 -- kdeui/kactioncollection.h | 393 - kdeui/kactionselector.cpp | 538 - kdeui/kactionselector.h | 402 - kdeui/kactionshortcutlist.h | 79 - kdeui/kactivelabel.cpp | 142 - kdeui/kactivelabel.h | 87 - kdeui/kanimwidget.cpp | 212 - kdeui/kanimwidget.h | 144 - kdeui/karrowbutton.cpp | 113 - kdeui/karrowbutton.h | 94 - kdeui/kauthicon.cpp | 203 - kdeui/kauthicon.h | 173 - kdeui/kbugreport.cpp | 538 - kdeui/kbugreport.h | 121 - kdeui/kbuttonbox.cpp | 377 - kdeui/kbuttonbox.h | 170 - kdeui/kcharselect.cpp | 546 - kdeui/kcharselect.h | 266 - kdeui/kcmenumngr.cpp | 129 - kdeui/kcmenumngr.h | 116 - kdeui/kcmodule.cpp | 220 - kdeui/kcmodule.h | 361 - kdeui/kcolorbtn.h | 12 - kdeui/kcolorbutton.cpp | 207 - kdeui/kcolorbutton.h | 115 - kdeui/kcolorcombo.cpp | 264 - kdeui/kcolorcombo.h | 95 - kdeui/kcolordialog.cpp | 1616 --- kdeui/kcolordialog.h | 496 - kdeui/kcolordlg.h | 6 - kdeui/kcolordrag.cpp | 112 - kdeui/kcolordrag.h | 79 - kdeui/kcombobox.cpp | 797 -- kdeui/kcombobox.h | 825 -- kdeui/kcommand.cpp | 379 - kdeui/kcommand.h | 289 - kdeui/kcompletionbox.cpp | 562 - kdeui/kcompletionbox.h | 246 - kdeui/kconfigdialog.cpp | 259 - kdeui/kconfigdialog.h | 279 - kdeui/kcursor.cpp | 434 - kdeui/kcursor.h | 224 - kdeui/kcursor_private.h | 99 - kdeui/kdatepicker.cpp | 549 - kdeui/kdatepicker.h | 257 - kdeui/kdatepik.h | 6 - kdeui/kdatetbl.cpp | 1031 -- kdeui/kdatetbl.h | 447 - kdeui/kdatetimewidget.cpp | 74 - kdeui/kdatetimewidget.h | 92 - kdeui/kdatewidget.cpp | 177 - kdeui/kdatewidget.h | 90 - kdeui/kdcopactionproxy.cpp | 159 - kdeui/kdcopactionproxy.h | 112 - kdeui/kdepackages.h | 1301 -- kdeui/kdetrayproxy/CMakeLists.txt | 46 - kdeui/kdetrayproxy/Makefile.am | 13 - kdeui/kdetrayproxy/kdetrayproxy.cpp | 194 - kdeui/kdetrayproxy/kdetrayproxy.desktop | 134 - kdeui/kdetrayproxy/kdetrayproxy.h | 50 - kdeui/kdetrayproxy/module.cpp | 33 - kdeui/kdetrayproxy/module.h | 39 - kdeui/kdialog.cpp | 496 - kdeui/kdialog.h | 259 - kdeui/kdialogbase.cpp | 1844 --- kdeui/kdialogbase.h | 1632 --- kdeui/kdialogbase_priv.h | 71 - kdeui/kdockwidget.cpp | 3331 ------ kdeui/kdockwidget.h | 1553 --- kdeui/kdockwidget_p.h | 89 - kdeui/kdockwidget_private.cpp | 712 -- kdeui/kdockwidget_private.h | 335 - kdeui/kdockwindow.h | 41 - kdeui/kdualcolorbtn.h | 6 - kdeui/kdualcolorbutton.cpp | 283 - kdeui/kdualcolorbutton.h | 159 - kdeui/keditcl.h | 436 - kdeui/keditcl1.cpp | 718 -- kdeui/keditcl2.cpp | 1127 -- kdeui/keditlistbox.cpp | 418 - kdeui/keditlistbox.h | 279 - kdeui/kedittoolbar.cpp | 1455 --- kdeui/kedittoolbar.h | 439 - kdeui/kfontcombo.cpp | 382 - kdeui/kfontcombo.h | 179 - kdeui/kfontdialog.cpp | 799 -- kdeui/kfontdialog.h | 504 - kdeui/kfontrequester.cpp | 127 - kdeui/kfontrequester.h | 157 - kdeui/kguiitem.cpp | 229 - kdeui/kguiitem.h | 98 - kdeui/khelpmenu.cpp | 321 - kdeui/khelpmenu.h | 281 - kdeui/kiconview.cpp | 751 -- kdeui/kiconview.h | 281 - kdeui/kiconviewsearchline.cpp | 308 - kdeui/kiconviewsearchline.h | 184 - kdeui/kinputdialog.cpp | 472 - kdeui/kinputdialog.h | 292 - kdeui/kjanuswidget.cpp | 1255 -- kdeui/kjanuswidget.h | 615 - kdeui/kkeybutton.cpp | 178 - kdeui/kkeybutton.h | 91 - kdeui/kkeydialog.cpp | 1209 -- kdeui/kkeydialog.h | 407 - kdeui/klanguagebutton.cpp | 284 - kdeui/klanguagebutton.h | 182 - kdeui/kled.cpp | 644 - kdeui/kled.h | 329 - kdeui/klineedit.cpp | 1382 --- kdeui/klineedit.h | 656 - kdeui/klineeditdlg.cpp | 194 - kdeui/klineeditdlg.h | 127 - kdeui/klistbox.cpp | 266 - kdeui/klistbox.h | 128 - kdeui/klistview.cpp | 2365 ---- kdeui/klistview.h | 1086 -- kdeui/klistviewlineedit.h | 65 - kdeui/klistviewsearchline.cpp | 501 - kdeui/klistviewsearchline.h | 264 - kdeui/kmainwindow.cpp | 1249 -- kdeui/kmainwindow.h | 1076 -- kdeui/kmainwindowiface.cpp | 194 - kdeui/kmainwindowiface.h | 161 - kdeui/kmenubar.cpp | 571 - kdeui/kmenubar.h | 114 - kdeui/kmessagebox.cpp | 1071 -- kdeui/kmessagebox.h | 1166 -- kdeui/knuminput.cpp | 1180 -- kdeui/knuminput.h | 962 -- kdeui/knumvalidator.cpp | 371 - kdeui/knumvalidator.h | 212 - kdeui/kpanelapplet.cpp | 198 - kdeui/kpanelapplet.h | 395 - kdeui/kpanelappmenu.cpp | 182 - kdeui/kpanelappmenu.h | 99 - kdeui/kpanelextension.cpp | 163 - kdeui/kpanelextension.h | 345 - kdeui/kpanelmenu.cpp | 158 - kdeui/kpanelmenu.h | 182 - kdeui/kpartgui.dtd | 181 - kdeui/kpassdlg.cpp | 724 -- kdeui/kpassdlg.h | 414 - kdeui/kpassivepopup.cpp | 499 - kdeui/kpassivepopup.h | 368 - kdeui/kpixmapio-perf.png | Bin 3899 -> 0 bytes kdeui/kpixmapio.cpp | 908 -- kdeui/kpixmapio.h | 185 - kdeui/kpixmapregionselectordialog.cpp | 127 - kdeui/kpixmapregionselectordialog.h | 107 - kdeui/kpixmapregionselectorwidget.cpp | 450 - kdeui/kpixmapregionselectorwidget.h | 170 - kdeui/kpopupmenu.cpp | 694 -- kdeui/kpopupmenu.h | 282 - kdeui/kprogress.cpp | 414 - kdeui/kprogress.h | 401 - kdeui/kprogressbox.cpp | 316 - kdeui/kprogressbox.h | 291 - kdeui/kpushbutton.cpp | 220 - kdeui/kpushbutton.h | 161 - kdeui/krestrictedline.cpp | 81 - kdeui/krestrictedline.h | 95 - kdeui/krootpixmap.cpp | 347 - kdeui/krootpixmap.h | 240 - kdeui/kruler.cpp | 742 -- kdeui/kruler.h | 521 - kdeui/ksconfig.cpp | 1028 -- kdeui/ksconfig.h | 293 - kdeui/kscrollview.cpp | 189 - kdeui/kscrollview.h | 62 - kdeui/kselect.cpp | 534 - kdeui/kselect.h | 373 - kdeui/kseparator.cpp | 116 - kdeui/kseparator.h | 87 - kdeui/ksharedpixmap.cpp | 228 - kdeui/ksharedpixmap.h | 120 - kdeui/kshortcutdialog.cpp | 529 - kdeui/kshortcutdialog.h | 96 - kdeui/kshortcutdialog_advanced.ui | 254 - kdeui/kshortcutdialog_simple.ui | 120 - kdeui/kspell.cpp | 1577 --- kdeui/kspell.h | 568 - kdeui/kspelldlg.cpp | 285 - kdeui/kspelldlg.h | 114 - kdeui/kspellui.ui | 300 - kdeui/ksplashscreen.cpp | 42 - kdeui/ksplashscreen.h | 62 - kdeui/ksqueezedtextlabel.cpp | 87 - kdeui/ksqueezedtextlabel.h | 84 - kdeui/kstatusbar.cpp | 156 - kdeui/kstatusbar.h | 208 - kdeui/kstdaction.cpp | 323 - kdeui/kstdaction.h | 614 - kdeui/kstdaction_p.h | 139 - kdeui/kstdguiitem.cpp | 287 - kdeui/kstdguiitem.h | 183 - kdeui/kstringvalidator.cpp | 90 - kdeui/kstringvalidator.h | 141 - kdeui/kswitchlanguagedialog.cpp | 349 - kdeui/kswitchlanguagedialog.h | 87 - kdeui/ksyntaxhighlighter.cpp | 677 -- kdeui/ksyntaxhighlighter.h | 184 - kdeui/ksystemtray.cpp | 350 - kdeui/ksystemtray.h | 216 - kdeui/ktabbar.cpp | 427 - kdeui/ktabbar.h | 113 - kdeui/ktabctl.cpp | 336 - kdeui/ktabctl.h | 90 - kdeui/ktabwidget.cpp | 526 - kdeui/ktabwidget.h | 294 - kdeui/ktextbrowser.cpp | 145 - kdeui/ktextbrowser.h | 133 - kdeui/ktextedit.cpp | 419 - kdeui/ktextedit.h | 174 - kdeui/ktimewidget.cpp | 58 - kdeui/ktimewidget.h | 86 - kdeui/ktimezonewidget.cpp | 133 - kdeui/ktimezonewidget.h | 112 - kdeui/ktip-background.png | Bin 190 -> 0 bytes kdeui/ktip-bulb.png | Bin 14134 -> 0 bytes kdeui/ktip.cpp | 447 - kdeui/ktip.h | 192 - kdeui/ktoolbar.cpp | 2264 ---- kdeui/ktoolbar.h | 1130 -- kdeui/ktoolbarbutton.cpp | 781 -- kdeui/ktoolbarbutton.h | 331 - kdeui/ktoolbarhandler.cpp | 246 - kdeui/ktoolbarhandler.h | 69 - kdeui/ktoolbarlabelaction.cpp | 117 - kdeui/ktoolbarlabelaction.h | 137 - kdeui/ktoolbarradiogroup.cpp | 77 - kdeui/ktoolbarradiogroup.h | 88 - kdeui/kurllabel.cpp | 450 - kdeui/kurllabel.h | 411 - kdeui/kwhatsthismanager.cpp | 121 - kdeui/kwhatsthismanager_p.h | 58 - kdeui/kwindowinfo.cpp | 178 - kdeui/kwindowinfo.h | 145 - kdeui/kwindowlistmenu.cpp | 257 - kdeui/kwindowlistmenu.h | 74 - kdeui/kwizard.cpp | 57 - kdeui/kwizard.h | 62 - kdeui/kwordwrap.cpp | 269 - kdeui/kwordwrap.h | 149 - kdeui/kxmlgui.h | 6 - kdeui/kxmlgui.xsd | 445 - kdeui/kxmlguibuilder.cpp | 441 - kdeui/kxmlguibuilder.h | 96 - kdeui/kxmlguiclient.cpp | 951 -- kdeui/kxmlguiclient.h | 367 - kdeui/kxmlguifactory.cpp | 614 - kdeui/kxmlguifactory.h | 220 - kdeui/kxmlguifactory_p.cpp | 836 -- kdeui/kxmlguifactory_p.h | 254 - kdeui/libkdeui.nmcheck | 5 - kdeui/libkdeui_weak.nmcheck | 2 - kdeui/preparetips | 66 - kdeui/qxembed.cpp | 1450 --- kdeui/qxembed.h | 244 - kdeui/tests/CMakeLists.txt | 49 - kdeui/tests/Makefile.am | 105 - kdeui/tests/RayTracedGear.png | Bin 5844 -> 0 bytes kdeui/tests/background_1.png | Bin 7209 -> 0 bytes kdeui/tests/go.png | Bin 3286 -> 0 bytes kdeui/tests/itemcontainertest.cpp | 225 - kdeui/tests/itemcontainertest.h | 45 - kdeui/tests/kaboutdialogtest.cpp | 72 - kdeui/tests/kaccelgentest.cpp | 51 - kdeui/tests/kactiontest.cpp | 38 - kdeui/tests/kalphaicontest.h | 24 - kdeui/tests/kblendtest.cpp | 98 - kdeui/tests/kblendtest.h | 24 - kdeui/tests/kbuttonboxtest.cpp | 205 - kdeui/tests/kcharselecttest.cpp | 16 - kdeui/tests/kcolordlgtest.cpp | 41 - kdeui/tests/kcolortest.cpp | 169 - kdeui/tests/kcolortest.h | 21 - kdeui/tests/kcomboboxtest.cpp | 227 - kdeui/tests/kcomboboxtest.h | 44 - kdeui/tests/kcompletiontest.cpp | 198 - kdeui/tests/kcompletiontest.h | 67 - kdeui/tests/kdatepicktest.cpp | 16 - kdeui/tests/kdatetimewidgettest.cpp | 14 - kdeui/tests/kdatewidgettest.cpp | 16 - kdeui/tests/kdesattest.cpp | 65 - kdeui/tests/kdesattest.h | 31 - kdeui/tests/kdialogbasetest.cpp | 77 - kdeui/tests/kdocktest.cpp | 65 - kdeui/tests/kdocktest.h | 19 - kdeui/tests/kdockwidgetdemo.cpp | 796 -- kdeui/tests/kdockwidgetdemo.h | 164 - kdeui/tests/kdockwidgettest.cpp | 255 - kdeui/tests/kdockwidgettest.h | 72 - kdeui/tests/kdualcolortest.cpp | 63 - kdeui/tests/kdualcolortest.h | 20 - kdeui/tests/keditlistboxtest.cpp | 21 - kdeui/tests/kedittest.cpp | 14 - kdeui/tests/kfontdialogtest.cpp | 51 - kdeui/tests/kgradienttest.cpp | 108 - kdeui/tests/kgradienttest.h | 24 - kdeui/tests/khashtest.cpp | 137 - kdeui/tests/khashtest.h | 26 - kdeui/tests/kinputdialogtest.cpp | 67 - kdeui/tests/kjanuswidgettest.cpp | 25 - kdeui/tests/kledtest.cpp | 160 - kdeui/tests/kledtest.h | 56 - kdeui/tests/klineeditdlgtest.cpp | 19 - kdeui/tests/klineedittest.cpp | 137 - kdeui/tests/klineedittest.h | 41 - kdeui/tests/klistviewtest.cpp | 39 - kdeui/tests/kmainwindowrestoretest.cpp | 41 - kdeui/tests/kmainwindowrestoretest.h | 48 - kdeui/tests/kmainwindowtest.cpp | 38 - kdeui/tests/kmainwindowtest.h | 18 - kdeui/tests/kmessageboxtest.cpp | 242 - kdeui/tests/knuminputtest.cpp | 145 - kdeui/tests/knuminputtest.h | 23 - kdeui/tests/kpalettetest.cpp | 38 - kdeui/tests/kpanelmenutest.cpp | 72 - kdeui/tests/kpanelmenutest.h | 21 - kdeui/tests/kpixmapregionselectordialogtest.cpp | 33 - kdeui/tests/kpopuptest.cpp | 40 - kdeui/tests/kprogresstest.cpp | 58 - kdeui/tests/krulertest.cpp | 375 - kdeui/tests/krulertest.h | 91 - kdeui/tests/kseparatortest.cpp | 51 - kdeui/tests/kspelltest.cpp | 57 - kdeui/tests/ksqueezedtextlabeltest.cpp | 13 - kdeui/tests/kstatusbartest.cpp | 121 - kdeui/tests/kstatusbartest.h | 33 - kdeui/tests/ksystemtraytest.cpp | 14 - kdeui/tests/ktabctltest.cpp | 105 - kdeui/tests/ktabctltest.h | 30 - kdeui/tests/ktabwidgettest.cpp | 366 - kdeui/tests/ktabwidgettest.h | 69 - kdeui/tests/ktextedittest.cpp | 43 - kdeui/tests/ktimewidgettest.cpp | 14 - kdeui/tests/ktoolbarlabelactiontest.cpp | 97 - kdeui/tests/ktoolbarlabelactiontestui.rc | 9 - kdeui/tests/kunbalancedgrdtest.cpp | 176 - kdeui/tests/kunbalancedgrdtest.h | 49 - kdeui/tests/kwindowtest.cpp | 528 - kdeui/tests/kwindowtest.h | 71 - kdeui/tests/kwizardtest.cpp | 54 - kdeui/tests/kwordwraptest.cpp | 43 - kdeui/tests/kxmlguitest.cpp | 64 - kdeui/tests/kxmlguitest.h | 19 - kdeui/tests/kxmlguitest_part.rc | 8 - kdeui/tests/kxmlguitest_shell.rc | 7 - kdeui/tests/qxembedtest.cpp | 88 - kdeui/tests/testimage.png | Bin 35951 -> 0 bytes kdeui/ui_standards.rc | 211 - kinit/start_kdeinit.c | 191 - kinit/start_kdeinit_wrapper.c | 92 - kinit/start_tdeinit.c | 191 + kinit/start_tdeinit_wrapper.c | 92 + kio/misc/kdesasl/CMakeLists.txt | 42 - kio/misc/kdesasl/Makefile.am | 12 - kio/misc/kdesasl/kdesasl.cpp | 285 - kio/misc/kdesasl/kdesasl.h | 169 - kio/misc/tdesasl/CMakeLists.txt | 42 + kio/misc/tdesasl/Makefile.am | 12 + kio/misc/tdesasl/tdesasl.cpp | 285 + kio/misc/tdesasl/tdesasl.h | 169 + tdecore/40.colors | 48 + tdecore/AUTHORS | 56 + tdecore/CMakeLists.txt | 209 + tdecore/DESIGN.COLOR | 141 + tdecore/DESIGN.iconloading | 187 + tdecore/DESIGN.kconfig | 224 + tdecore/KCONFIG_DESIGN | 51 + tdecore/MAINTAINERS | 116 + tdecore/Mainpage.dox | 42 + tdecore/Makefile.am | 195 + tdecore/README | 3 + tdecore/README.exec | 41 + tdecore/README.kiosk | 681 ++ tdecore/README.kstartupinfo | 282 + tdecore/README.user_profiles | 136 + tdecore/Rainbow.colors | 118 + tdecore/Royal.colors | 258 + tdecore/Web.colors | 218 + tdecore/all_languages.desktop | 11919 +++++++++++++++++++ tdecore/configure.in.in | 234 + tdecore/eventsrc | 2741 +++++ tdecore/fakes.c | 365 + tdecore/fixx11h.h | 236 + tdecore/generate_keys.sh | 63 + tdecore/kaboutdata.cpp | 512 + tdecore/kaboutdata.h | 629 + tdecore/kaccel.cpp | 663 ++ tdecore/kaccel.h | 390 + tdecore/kaccelaction.cpp | 565 + tdecore/kaccelaction.h | 576 + tdecore/kaccelbase.cpp | 616 + tdecore/kaccelbase.h | 282 + tdecore/kaccelmanager.cpp | 872 ++ tdecore/kaccelmanager.h | 88 + tdecore/kaccelmanager_private.h | 196 + tdecore/kaccelprivate.h | 53 + tdecore/kallocator.cpp | 260 + tdecore/kallocator.h | 140 + tdecore/kapp.h | 6 + tdecore/kappdcopiface.cpp | 70 + tdecore/kappdcopiface.h | 80 + tdecore/kapplication.cpp | 3616 ++++++ tdecore/kapplication.h | 1620 +++ tdecore/kapplication_win.cpp | 117 + tdecore/kasyncio.cpp | 27 + tdecore/kasyncio.h | 95 + tdecore/kaudioplayer.cpp | 56 + tdecore/kaudioplayer.h | 93 + tdecore/kbufferedio.cpp | 309 + tdecore/kbufferedio.h | 300 + tdecore/kcalendarsystem.cpp | 146 + tdecore/kcalendarsystem.h | 357 + tdecore/kcalendarsystemfactory.cpp | 70 + tdecore/kcalendarsystemfactory.h | 65 + tdecore/kcalendarsystemgregorian.cpp | 329 + tdecore/kcalendarsystemgregorian.h | 92 + tdecore/kcalendarsystemhebrew.cpp | 746 ++ tdecore/kcalendarsystemhebrew.h | 105 + tdecore/kcalendarsystemhijri.cpp | 596 + tdecore/kcalendarsystemhijri.h | 98 + tdecore/kcalendarsystemjalali.cpp | 560 + tdecore/kcalendarsystemjalali.h | 83 + tdecore/kcatalogue.cpp | 161 + tdecore/kcatalogue.h | 129 + tdecore/kcharsets.cpp | 664 ++ tdecore/kcharsets.h | 142 + tdecore/kcheckaccelerators.cpp | 216 + tdecore/kcheckaccelerators.h | 96 + tdecore/kckey.cpp | 286 + tdecore/kckey.h | 17 + tdecore/kclipboard.cpp | 199 + tdecore/kclipboard.h | 123 + tdecore/kcmdlineargs.cpp | 1298 ++ tdecore/kcmdlineargs.h | 690 ++ tdecore/kcompletion.cpp | 892 ++ tdecore/kcompletion.h | 1010 ++ tdecore/kcompletion_private.h | 216 + tdecore/kcompletionbase.cpp | 154 + tdecore/kconfig.cpp | 367 + tdecore/kconfig.h | 296 + tdecore/kconfig_compiler/CMakeLists.txt | 29 + tdecore/kconfig_compiler/Makefile.am | 18 + tdecore/kconfig_compiler/README.dox | 255 + tdecore/kconfig_compiler/TODO | 0 tdecore/kconfig_compiler/checkkcfg.pl | 83 + tdecore/kconfig_compiler/example/Makefile.am | 27 + tdecore/kconfig_compiler/example/autoexample.cpp | 64 + tdecore/kconfig_compiler/example/example.cpp | 52 + tdecore/kconfig_compiler/example/example.kcfg | 63 + .../example/exampleprefs_base.kcfgc | 18 + tdecore/kconfig_compiler/example/general_base.ui | 46 + tdecore/kconfig_compiler/example/myoptions_base.ui | 35 + tdecore/kconfig_compiler/kcfg.xsd | 192 + tdecore/kconfig_compiler/kconfig_compiler.cpp | 1700 +++ tdecore/kconfig_compiler/tests/Makefile.am | 134 + .../tests/kconfigcompiler_test.cpp | 96 + .../kconfig_compiler/tests/kconfigcompiler_test.h | 35 + tdecore/kconfig_compiler/tests/myprefs.h | 7 + tdecore/kconfig_compiler/tests/test1.cpp.ref | 72 + tdecore/kconfig_compiler/tests/test1.h.ref | 196 + tdecore/kconfig_compiler/tests/test1.kcfg | 55 + tdecore/kconfig_compiler/tests/test1.kcfgc | 18 + tdecore/kconfig_compiler/tests/test1main.cpp | 29 + tdecore/kconfig_compiler/tests/test2.cpp.ref | 98 + tdecore/kconfig_compiler/tests/test2.h.ref | 333 + tdecore/kconfig_compiler/tests/test2.kcfg | 78 + tdecore/kconfig_compiler/tests/test2.kcfgc | 11 + tdecore/kconfig_compiler/tests/test2main.cpp | 29 + tdecore/kconfig_compiler/tests/test3.cpp.ref | 29 + tdecore/kconfig_compiler/tests/test3.h.ref | 138 + tdecore/kconfig_compiler/tests/test3.kcfg | 26 + tdecore/kconfig_compiler/tests/test3.kcfgc | 12 + tdecore/kconfig_compiler/tests/test3main.cpp | 29 + tdecore/kconfig_compiler/tests/test4.cpp.ref | 82 + tdecore/kconfig_compiler/tests/test4.h.ref | 135 + tdecore/kconfig_compiler/tests/test4.kcfg | 42 + tdecore/kconfig_compiler/tests/test4.kcfgc | 11 + tdecore/kconfig_compiler/tests/test4main.cpp | 30 + tdecore/kconfig_compiler/tests/test5.cpp.ref | 82 + tdecore/kconfig_compiler/tests/test5.h.ref | 127 + tdecore/kconfig_compiler/tests/test5.kcfg | 42 + tdecore/kconfig_compiler/tests/test5.kcfgc | 11 + tdecore/kconfig_compiler/tests/test5main.cpp | 30 + tdecore/kconfig_compiler/tests/test6.cpp.ref | 31 + tdecore/kconfig_compiler/tests/test6.h.ref | 93 + tdecore/kconfig_compiler/tests/test6.kcfg | 25 + tdecore/kconfig_compiler/tests/test6.kcfgc | 11 + tdecore/kconfig_compiler/tests/test6main.cpp | 30 + tdecore/kconfig_compiler/tests/test7.cpp.ref | 31 + tdecore/kconfig_compiler/tests/test7.h.ref | 93 + tdecore/kconfig_compiler/tests/test7.kcfg | 25 + tdecore/kconfig_compiler/tests/test7.kcfgc | 11 + tdecore/kconfig_compiler/tests/test7main.cpp | 30 + tdecore/kconfig_compiler/tests/test8a.cpp.ref | 22 + tdecore/kconfig_compiler/tests/test8a.h.ref | 61 + tdecore/kconfig_compiler/tests/test8a.kcfg | 17 + tdecore/kconfig_compiler/tests/test8a.kcfgc | 3 + tdecore/kconfig_compiler/tests/test8b.cpp.ref | 46 + tdecore/kconfig_compiler/tests/test8b.h.ref | 96 + tdecore/kconfig_compiler/tests/test8b.kcfg | 21 + tdecore/kconfig_compiler/tests/test8b.kcfgc | 6 + tdecore/kconfig_compiler/tests/test8main.cpp | 34 + tdecore/kconfig_compiler/tests/test9.cpp.ref | 35 + tdecore/kconfig_compiler/tests/test9.h.ref | 82 + tdecore/kconfig_compiler/tests/test9.kcfg | 24 + tdecore/kconfig_compiler/tests/test9.kcfgc | 18 + tdecore/kconfig_compiler/tests/test9main.cpp | 43 + .../kconfig_compiler/tests/test_dpointer.cpp.ref | 344 + tdecore/kconfig_compiler/tests/test_dpointer.h.ref | 224 + tdecore/kconfig_compiler/tests/test_dpointer.kcfg | 78 + tdecore/kconfig_compiler/tests/test_dpointer.kcfgc | 11 + .../kconfig_compiler/tests/test_dpointer_main.cpp | 30 + tdecore/kconfigbackend.cpp | 1186 ++ tdecore/kconfigbackend.h | 299 + tdecore/kconfigbase.cpp | 1935 +++ tdecore/kconfigbase.h | 2180 ++++ tdecore/kconfigdata.h | 146 + tdecore/kconfigdialogmanager.cpp | 398 + tdecore/kconfigdialogmanager.h | 236 + tdecore/kconfigskeleton.cpp | 1207 ++ tdecore/kconfigskeleton.h | 1230 ++ tdecore/kcrash.cpp | 524 + tdecore/kcrash.h | 127 + tdecore/kdcoppropertyproxy.cpp | 335 + tdecore/kdcoppropertyproxy.h | 106 + tdecore/kde-config.cpp.cmake | 272 + tdecore/kde-config.cpp.in | 270 + tdecore/kde_dmalloc.h | 28 + tdecore/kde_file.h | 125 + tdecore/kdebug.areas | 599 + tdecore/kdebug.cpp | 596 + tdecore/kdebug.h | 665 ++ tdecore/kdebugclasses.h | 33 + tdecore/kdebugdcopiface.cpp | 40 + tdecore/kdebugdcopiface.h | 52 + tdecore/kdebugrc | 142 + tdecore/kdelibs_export.h | 86 + tdecore/kdemacros.h.cmake | 220 + tdecore/kdemacros.h.in | 220 + tdecore/kdesktopfile.cpp | 367 + tdecore/kdesktopfile.h | 253 + tdecore/kdetcompmgr.cpp | 115 + tdecore/kdeversion.cpp | 46 + tdecore/kdeversion.h | 79 + tdecore/kentities.c | 837 ++ tdecore/kentities.gperf | 317 + tdecore/kextendedsocket.h | 4 + tdecore/kextsock.cpp | 2251 ++++ tdecore/kextsock.h | 1130 ++ tdecore/kgenericfactory.h | 397 + tdecore/kgenericfactory.tcc | 272 + tdecore/kglobal.cpp | 264 + tdecore/kglobal.h | 237 + tdecore/kglobalaccel.cpp | 139 + tdecore/kglobalaccel.h | 239 + tdecore/kglobalaccel_emb.h | 18 + tdecore/kglobalaccel_mac.h | 31 + tdecore/kglobalaccel_win.cpp | 345 + tdecore/kglobalaccel_win.h | 77 + tdecore/kglobalaccel_x11.cpp | 441 + tdecore/kglobalaccel_x11.h | 110 + tdecore/kglobalsettings.cpp | 774 ++ tdecore/kglobalsettings.h | 584 + tdecore/kgrantpty.c | 179 + tdecore/kiconeffect.cpp | 920 ++ tdecore/kiconeffect.h | 231 + tdecore/kiconloader.cpp | 1411 +++ tdecore/kiconloader.h | 553 + tdecore/kiconloader_p.h | 60 + tdecore/kicontheme.cpp | 605 + tdecore/kicontheme.h | 369 + tdecore/kidna.cpp | 63 + tdecore/kidna.h | 51 + tdecore/kinstance.cpp | 283 + tdecore/kinstance.h | 159 + tdecore/kipc.cpp | 113 + tdecore/kipc.h | 79 + tdecore/kkeynative.h | 258 + tdecore/kkeynative_x11.cpp | 201 + tdecore/kkeyserver.h | 29 + tdecore/kkeyserver_x11.cpp | 1053 ++ tdecore/kkeyserver_x11.h | 477 + tdecore/klargefile.h | 27 + tdecore/klibloader.cpp | 580 + tdecore/klibloader.h | 405 + tdecore/klocale.cpp | 2474 ++++ tdecore/klocale.h | 1350 +++ tdecore/klockfile.cpp | 376 + tdecore/klockfile.h | 123 + tdecore/kmacroexpander.cpp | 529 + tdecore/kmacroexpander.h | 380 + tdecore/kmanagerselection.cpp | 490 + tdecore/kmanagerselection.h | 233 + tdecore/kmdcodec.cpp | 1510 +++ tdecore/kmdcodec.h | 745 ++ tdecore/kmdcodec_compat.h | 4 + tdecore/kmimesourcefactory.cpp | 106 + tdecore/kmimesourcefactory.h | 85 + tdecore/kmountpoint.cpp | 385 + tdecore/kmountpoint.h | 116 + tdecore/kmultipledrag.cpp | 82 + tdecore/kmultipledrag.h | 105 + tdecore/knotifyclient.cpp | 363 + tdecore/knotifyclient.h | 325 + tdecore/kpalette.cpp | 237 + tdecore/kpalette.h | 228 + tdecore/kpixmapprovider.cpp | 27 + tdecore/kpixmapprovider.h | 55 + tdecore/kprocctrl.cpp | 277 + tdecore/kprocctrl.h | 150 + tdecore/kprocess.cpp | 1137 ++ tdecore/kprocess.h | 939 ++ tdecore/kprocio.cpp | 276 + tdecore/kprocio.h | 217 + tdecore/kprotocolinfo_tdecore.cpp | 562 + tdecore/kprotocolinfofactory.cpp | 113 + tdecore/kprotocolinfofactory.h | 91 + tdecore/kpty.cpp | 579 + tdecore/kpty.h | 159 + tdecore/kqiodevicegzip_p.cpp | 163 + tdecore/kqiodevicegzip_p.h | 68 + tdecore/krandomsequence.cpp | 239 + tdecore/krandomsequence.h | 145 + tdecore/kregexp.cpp | 210 + tdecore/kregexp.h | 129 + tdecore/kregpriv.h | 57 + tdecore/krfcdate.cpp | 505 + tdecore/krfcdate.h | 100 + tdecore/krootprop.cpp | 303 + tdecore/krootprop.h | 206 + tdecore/ksavefile.cpp | 230 + tdecore/ksavefile.h | 152 + tdecore/ksharedptr.h | 175 + tdecore/kshell.cpp | 377 + tdecore/kshell.h | 147 + tdecore/kshortcut.cpp | 671 ++ tdecore/kshortcut.h | 851 ++ tdecore/kshortcutlist.cpp | 220 + tdecore/kshortcutlist.h | 295 + tdecore/kshortcutmenu.cpp | 161 + tdecore/kshortcutmenu.h | 61 + tdecore/ksimpleconfig.cpp | 81 + tdecore/ksimpleconfig.h | 81 + tdecore/ksock.cpp | 435 + tdecore/ksock.h | 350 + tdecore/ksockaddr.cpp | 894 ++ tdecore/ksockaddr.h | 683 ++ tdecore/ksocks.cpp | 600 + tdecore/ksocks.h | 210 + tdecore/ksortablevaluelist.h | 171 + tdecore/kstandarddirs.cpp | 1705 +++ tdecore/kstandarddirs.h | 729 ++ tdecore/kstartupinfo.cpp | 1529 +++ tdecore/kstartupinfo.h | 697 ++ tdecore/kstaticdeleter.cpp | 10 + tdecore/kstaticdeleter.h | 139 + tdecore/kstdaccel.cpp | 396 + tdecore/kstdaccel.h | 492 + tdecore/kstddirs.h | 6 + tdecore/kstringhandler.cpp | 663 ++ tdecore/kstringhandler.h | 441 + 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/ktempdir.cpp | 218 + tdecore/ktempdir.h | 172 + tdecore/ktempfile.cpp | 289 + tdecore/ktempfile.h | 213 + tdecore/ktimezones.cpp | 790 ++ tdecore/ktimezones.h | 351 + tdecore/ktypelist.h | 473 + tdecore/kuniqueapp.h | 6 + tdecore/kuniqueapplication.cpp | 495 + tdecore/kuniqueapplication.h | 221 + tdecore/kunload.h | 22 + tdecore/kurl.cpp | 2356 ++++ tdecore/kurl.h | 1828 +++ tdecore/kurldrag.cpp | 294 + tdecore/kurldrag.h | 165 + tdecore/kuser.cpp | 425 + tdecore/kuser.h | 384 + tdecore/kvmallocator.cpp | 274 + tdecore/kvmallocator.h | 119 + tdecore/kwin.cpp | 1267 ++ tdecore/kwin.h | 721 ++ tdecore/kwinmodule.cpp | 482 + tdecore/kwinmodule.h | 362 + tdecore/kxerrorhandler.cpp | 121 + tdecore/kxerrorhandler.h | 104 + tdecore/kxmessages.cpp | 214 + tdecore/kxmessages.h | 172 + tdecore/language.codes | 3 + tdecore/libintl.cpp | 420 + tdecore/libqt-mt.nmcheck | 43 + tdecore/libqt-mt_weak.nmcheck | 34 + tdecore/libtdecore.nmcheck | 79 + tdecore/libtdecore_weak.nmcheck | 28 + tdecore/malloc/CMakeLists.txt | 18 + tdecore/malloc/Makefile.am | 31 + tdecore/malloc/README | 56 + tdecore/malloc/configure.in.in | 134 + tdecore/malloc/glibc.h | 31 + tdecore/malloc/malloc.c | 5758 +++++++++ tdecore/malloc/x86.h | 41 + tdecore/netsupp.cpp | 1237 ++ tdecore/netsupp.h | 301 + tdecore/netsupp_win32.cpp | 65 + tdecore/netwm.cpp | 4645 ++++++++ tdecore/netwm.h | 1471 +++ tdecore/netwm_def.h | 671 ++ tdecore/netwm_p.h | 155 + tdecore/network/CMakeLists.txt | 54 + tdecore/network/Makefile.am | 59 + tdecore/network/ipv6blacklist | 3 + tdecore/network/kbufferedsocket.cpp | 424 + tdecore/network/kbufferedsocket.h | 269 + tdecore/network/kclientsocketbase.cpp | 490 + tdecore/network/kclientsocketbase.h | 532 + tdecore/network/kdatagramsocket.cpp | 283 + tdecore/network/kdatagramsocket.h | 279 + tdecore/network/khttpproxysocketdevice.cpp | 281 + tdecore/network/khttpproxysocketdevice.h | 122 + tdecore/network/kiobuffer.h | 144 + tdecore/network/kmulticastsocket.h | 113 + tdecore/network/kmulticastsocketdevice.h | 151 + tdecore/network/knetworkinterface.h | 46 + tdecore/network/kresolver.cpp | 1164 ++ tdecore/network/kresolver.h | 946 ++ tdecore/network/kresolver_p.h | 353 + tdecore/network/kresolvermanager.cpp | 822 ++ tdecore/network/kresolverstandardworkers.cpp | 1028 ++ tdecore/network/kresolverstandardworkers_p.h | 111 + tdecore/network/kresolverworkerbase.cpp | 147 + tdecore/network/kresolverworkerbase.h | 317 + tdecore/network/kreverseresolver.cpp | 263 + tdecore/network/kreverseresolver.h | 196 + tdecore/network/kserversocket.cpp | 413 + tdecore/network/kserversocket.h | 436 + tdecore/network/ksocketaddress.cpp | 957 ++ tdecore/network/ksocketaddress.h | 912 ++ tdecore/network/ksocketbase.cpp | 327 + tdecore/network/ksocketbase.h | 771 ++ tdecore/network/ksocketbuffer.cpp | 329 + tdecore/network/ksocketbuffer_p.h | 164 + tdecore/network/ksocketdevice.cpp | 891 ++ tdecore/network/ksocketdevice.h | 433 + tdecore/network/ksockssocketdevice.cpp | 487 + tdecore/network/ksockssocketdevice.h | 129 + tdecore/network/ksrvresolverworker.cpp | 257 + tdecore/network/ksrvresolverworker_p.h | 86 + tdecore/network/kstreamsocket.cpp | 368 + tdecore/network/kstreamsocket.h | 250 + tdecore/network/syssocket.h | 93 + tdecore/standard_weak.nmcheck | 6 + tdecore/svgicons/CMakeLists.txt | 38 + tdecore/svgicons/Makefile.am | 6 + tdecore/svgicons/TODO | 5 + tdecore/svgicons/ksvgiconengine.cpp | 692 ++ tdecore/svgicons/ksvgiconengine.h | 49 + tdecore/svgicons/ksvgiconpainter.cpp | 2837 +++++ tdecore/svgicons/ksvgiconpainter.h | 101 + tdecore/tests/KIDLTest.cpp | 33 + tdecore/tests/KIDLTest.h | 16 + tdecore/tests/KIDLTestClient.cpp | 17 + tdecore/tests/Makefile.am | 86 + tdecore/tests/cplusplustest.cpp | 44 + tdecore/tests/dcopkonqtest.cpp | 36 + tdecore/tests/kapptest.cpp | 40 + tdecore/tests/kcalendartest.cpp | 152 + tdecore/tests/kcharsetstest.cpp | 12 + tdecore/tests/kcmdlineargstest.cpp | 91 + tdecore/tests/kconfigtest.cpp | 162 + tdecore/tests/kconfigtestgui.cpp | 200 + tdecore/tests/kconfigtestgui.h | 72 + tdecore/tests/kdebugtest.cpp | 98 + tdecore/tests/kglobaltest.cpp | 64 + tdecore/tests/kiconloadertest.cpp | 34 + tdecore/tests/kipctest.cpp | 33 + tdecore/tests/kipctest.h | 21 + tdecore/tests/klocaletest.cpp | 199 + tdecore/tests/klocaletest.h | 32 + tdecore/tests/kmacroexpandertest.cpp | 137 + tdecore/tests/kmdcodectest.cpp | 395 + tdecore/tests/kmemtest.cpp | 248 + tdecore/tests/knotifytest.cpp | 10 + tdecore/tests/kprocesstest.cpp | 116 + tdecore/tests/kprocesstest.h | 50 + tdecore/tests/kprociotest.cpp | 65 + tdecore/tests/kprociotest.h | 42 + tdecore/tests/krandomsequencetest.cpp | 91 + tdecore/tests/kresolvertest.cpp | 420 + tdecore/tests/krfcdatetest.cpp | 81 + tdecore/tests/kshelltest.cpp | 55 + tdecore/tests/ksimpleconfigtest.cpp | 48 + tdecore/tests/ksocktest.cpp | 109 + tdecore/tests/ksortablevaluelisttest.cpp | 32 + tdecore/tests/kstdacceltest.cpp | 39 + tdecore/tests/kstddirstest.cpp | 52 + tdecore/tests/kstringhandlertest.cpp | 97 + tdecore/tests/ktempfiletest.cpp | 48 + tdecore/tests/ktimezonestest.cpp | 62 + tdecore/tests/kuniqueapptest.cpp | 59 + tdecore/tests/kurltest.cpp | 1124 ++ tdecore/tests/kxerrorhandlertest.cpp | 54 + tdecore/tests/startserviceby.cpp | 41 + tdecore/tests/testqtargs.cpp | 104 + tdecore/vsnprintf.c | 170 + tdefx/CMakeLists.txt | 48 + tdefx/Mainpage.dox | 32 + tdefx/Makefile.am | 45 + tdefx/configure.in.in | 63 + tdefx/kcpuinfo.cpp | 176 + tdefx/kcpuinfo.h | 70 + tdefx/kdrawutil.cpp | 264 + tdefx/kdrawutil.h | 180 + tdefx/kimageeffect.cpp | 4980 ++++++++ tdefx/kimageeffect.h | 817 ++ tdefx/kpixmap.cpp | 389 + tdefx/kpixmap.h | 213 + tdefx/kpixmapeffect.cpp | 325 + tdefx/kpixmapeffect.h | 218 + tdefx/kpixmapsplitter.cpp | 95 + tdefx/kpixmapsplitter.h | 123 + tdefx/kstyle.cpp | 2370 ++++ tdefx/kstyle.h | 356 + tdefx/libtdefx.nmcheck | 12 + tdefx/libtdefx_weak.nmcheck | 3 + tdeprint/CMakeLists.txt | 124 + tdeprint/ChangeLog | 619 + tdeprint/Makefile.am | 114 + tdeprint/TODO | 75 + tdeprint/TODO.cups12 | 293 + tdeprint/configure.in.in | 99 + tdeprint/cups/CMakeLists.txt | 97 + tdeprint/cups/Makefile.am | 49 + tdeprint/cups/configure.in.in | 18 + tdeprint/cups/cups.print | 68 + tdeprint/cups/cupsaddsmb2.cpp | 476 + tdeprint/cups/cupsaddsmb2.h | 77 + tdeprint/cups/cupsdconf2/CMakeLists.txt | 54 + tdeprint/cups/cupsdconf2/Makefile.am | 35 + tdeprint/cups/cupsdconf2/addressdialog.cpp | 89 + tdeprint/cups/cupsdconf2/addressdialog.h | 42 + tdeprint/cups/cupsdconf2/browsedialog.cpp | 150 + tdeprint/cups/cupsdconf2/browsedialog.h | 49 + tdeprint/cups/cupsdconf2/cups-util.c | 557 + tdeprint/cups/cupsdconf2/cups-util.h | 26 + tdeprint/cups/cupsdconf2/cups_logo.png | Bin 0 -> 1487 bytes tdeprint/cups/cupsdconf2/cupsd.conf.template | 977 ++ tdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp | 210 + tdeprint/cups/cupsdconf2/cupsdbrowsingpage.h | 55 + tdeprint/cups/cupsdconf2/cupsdcomment.cpp | 136 + tdeprint/cups/cupsdconf2/cupsdcomment.h | 55 + tdeprint/cups/cupsdconf2/cupsdcomment.pl | 61 + tdeprint/cups/cupsdconf2/cupsdconf.cpp | 884 ++ tdeprint/cups/cupsdconf2/cupsdconf.h | 181 + tdeprint/cups/cupsdconf2/cupsddialog.cpp | 356 + tdeprint/cups/cupsdconf2/cupsddialog.h | 58 + tdeprint/cups/cupsdconf2/cupsddirpage.cpp | 109 + tdeprint/cups/cupsdconf2/cupsddirpage.h | 47 + tdeprint/cups/cupsdconf2/cupsdfilterpage.cpp | 94 + tdeprint/cups/cupsdconf2/cupsdfilterpage.h | 45 + tdeprint/cups/cupsdconf2/cupsdjobspage.cpp | 123 + tdeprint/cups/cupsdconf2/cupsdjobspage.h | 47 + tdeprint/cups/cupsdconf2/cupsdlogpage.cpp | 111 + tdeprint/cups/cupsdconf2/cupsdlogpage.h | 44 + tdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp | 159 + tdeprint/cups/cupsdconf2/cupsdnetworkpage.h | 55 + tdeprint/cups/cupsdconf2/cupsdpage.cpp | 32 + tdeprint/cups/cupsdconf2/cupsdpage.h | 54 + tdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp | 168 + tdeprint/cups/cupsdconf2/cupsdsecuritypage.h | 56 + tdeprint/cups/cupsdconf2/cupsdserverpage.cpp | 181 + tdeprint/cups/cupsdconf2/cupsdserverpage.h | 49 + tdeprint/cups/cupsdconf2/cupsdsplash.cpp | 73 + tdeprint/cups/cupsdconf2/cupsdsplash.h | 35 + tdeprint/cups/cupsdconf2/editlist.cpp | 124 + tdeprint/cups/cupsdconf2/editlist.h | 60 + tdeprint/cups/cupsdconf2/kde_logo.png | Bin 0 -> 15177 bytes tdeprint/cups/cupsdconf2/locationdialog.cpp | 222 + tdeprint/cups/cupsdconf2/locationdialog.h | 58 + tdeprint/cups/cupsdconf2/main.cpp | 48 + tdeprint/cups/cupsdconf2/portdialog.cpp | 118 + tdeprint/cups/cupsdconf2/portdialog.h | 46 + tdeprint/cups/cupsdconf2/qdirlineedit.cpp | 73 + tdeprint/cups/cupsdconf2/qdirlineedit.h | 49 + tdeprint/cups/cupsdconf2/qdirmultilineedit.cpp | 109 + tdeprint/cups/cupsdconf2/qdirmultilineedit.h | 53 + tdeprint/cups/cupsdconf2/sizewidget.cpp | 83 + tdeprint/cups/cupsdconf2/sizewidget.h | 43 + tdeprint/cups/cupsdoprint.c | 257 + tdeprint/cups/cupsinfos.cpp | 166 + tdeprint/cups/cupsinfos.h | 88 + tdeprint/cups/image.cpp | 295 + tdeprint/cups/imageposition.cpp | 153 + tdeprint/cups/imageposition.h | 58 + tdeprint/cups/imagepreview.cpp | 78 + tdeprint/cups/imagepreview.h | 49 + tdeprint/cups/ippreportdlg.cpp | 96 + tdeprint/cups/ippreportdlg.h | 42 + tdeprint/cups/ipprequest.cpp | 544 + tdeprint/cups/ipprequest.h | 196 + tdeprint/cups/kcupsprinterimpl.cpp | 159 + tdeprint/cups/kcupsprinterimpl.h | 36 + tdeprint/cups/kmconfigcups.cpp | 51 + tdeprint/cups/kmconfigcups.h | 39 + tdeprint/cups/kmconfigcupsdir.cpp | 67 + tdeprint/cups/kmconfigcupsdir.h | 41 + tdeprint/cups/kmcupsconfigwidget.cpp | 159 + tdeprint/cups/kmcupsconfigwidget.h | 43 + tdeprint/cups/kmcupsfactory.cpp | 30 + tdeprint/cups/kmcupsjobmanager.cpp | 452 + tdeprint/cups/kmcupsjobmanager.h | 53 + tdeprint/cups/kmcupsmanager.cpp | 1077 ++ tdeprint/cups/kmcupsmanager.h | 106 + tdeprint/cups/kmcupsuimanager.cpp | 219 + tdeprint/cups/kmcupsuimanager.h | 40 + tdeprint/cups/kmpropbanners.cpp | 81 + tdeprint/cups/kmpropbanners.h | 43 + tdeprint/cups/kmpropquota.cpp | 96 + tdeprint/cups/kmpropquota.h | 44 + tdeprint/cups/kmpropusers.cpp | 90 + tdeprint/cups/kmpropusers.h | 42 + tdeprint/cups/kmwbanners.cpp | 145 + tdeprint/cups/kmwbanners.h | 43 + tdeprint/cups/kmwfax.cpp | 81 + tdeprint/cups/kmwfax.h | 39 + tdeprint/cups/kmwipp.cpp | 86 + tdeprint/cups/kmwipp.h | 34 + tdeprint/cups/kmwippprinter.cpp | 227 + tdeprint/cups/kmwippprinter.h | 56 + tdeprint/cups/kmwippselect.cpp | 108 + tdeprint/cups/kmwippselect.h | 40 + tdeprint/cups/kmwother.cpp | 125 + tdeprint/cups/kmwother.h | 46 + tdeprint/cups/kmwquota.cpp | 171 + tdeprint/cups/kmwquota.h | 46 + tdeprint/cups/kmwusers.cpp | 96 + tdeprint/cups/kmwusers.h | 43 + tdeprint/cups/kphpgl2page.cpp | 169 + tdeprint/cups/kphpgl2page.h | 42 + tdeprint/cups/kpimagepage.cpp | 503 + tdeprint/cups/kpimagepage.h | 56 + tdeprint/cups/kpschedulepage.cpp | 282 + tdeprint/cups/kpschedulepage.h | 52 + tdeprint/cups/kptagspage.cpp | 164 + tdeprint/cups/kptagspage.h | 44 + tdeprint/cups/kptextpage.cpp | 375 + tdeprint/cups/kptextpage.h | 57 + tdeprint/cups/make_driver_db_cups.c | 149 + tdeprint/cups/postscript.ppd.gz | Bin 0 -> 2317 bytes tdeprint/cups/preview-mini.png | Bin 0 -> 1809 bytes tdeprint/cups/preview.png | Bin 0 -> 12738 bytes tdeprint/driver.cpp | 714 ++ tdeprint/driver.h | 383 + tdeprint/driveritem.cpp | 151 + tdeprint/driveritem.h | 47 + tdeprint/driverparse.c | 434 + tdeprint/driverparse.h | 30 + tdeprint/driverview.cpp | 157 + tdeprint/driverview.h | 62 + tdeprint/droptionview.cpp | 358 + tdeprint/droptionview.h | 136 + tdeprint/ext/CMakeLists.txt | 50 + tdeprint/ext/Makefile.am | 15 + tdeprint/ext/ext.print | 84 + tdeprint/ext/kextprinterimpl.cpp | 52 + tdeprint/ext/kextprinterimpl.h | 35 + tdeprint/ext/kmextfactory.cpp | 28 + tdeprint/ext/kmextmanager.cpp | 49 + tdeprint/ext/kmextmanager.h | 40 + tdeprint/ext/kmextuimanager.cpp | 44 + tdeprint/ext/kmextuimanager.h | 35 + tdeprint/filters/CMakeLists.txt | 23 + tdeprint/filters/Makefile.am | 14 + tdeprint/filters/enscript.desktop | 104 + tdeprint/filters/enscript.xml | 38 + tdeprint/filters/imagetops | 69 + tdeprint/filters/imagetops.desktop | 107 + tdeprint/filters/imagetops.xml | 25 + tdeprint/filters/pdf2ps.desktop | 40 + tdeprint/filters/pdf2ps.xml | 152 + tdeprint/filters/pdfwrite.desktop | 102 + tdeprint/filters/pdfwrite.xml | 14 + tdeprint/filters/poster.desktop | 163 + tdeprint/filters/poster.xml | 82 + tdeprint/filters/ps2pdf.desktop | 92 + tdeprint/filters/ps2pdf.xml | 152 + tdeprint/filters/psbook.desktop | 93 + tdeprint/filters/psbook.xml | 14 + tdeprint/filters/psbook1.desktop | 94 + tdeprint/filters/psbook1.xml | 14 + tdeprint/filters/psbook2.desktop | 95 + tdeprint/filters/psbook2.xml | 14 + tdeprint/filters/psnup.desktop | 89 + tdeprint/filters/psnup.xml | 32 + tdeprint/filters/psresize.desktop | 99 + tdeprint/filters/psresize.xml | 24 + tdeprint/filters/psselect.desktop | 97 + tdeprint/filters/psselect.xml | 24 + tdeprint/foomatic/Makefile.am | 20 + tdeprint/foomatic/foomatic.print | 17 + tdeprint/foomatic/kfoomaticprinterimpl.cpp | 53 + tdeprint/foomatic/kfoomaticprinterimpl.h | 37 + tdeprint/foomatic/kmfoomaticfactory.cpp | 27 + tdeprint/foomatic/kmfoomaticmanager.cpp | 197 + tdeprint/foomatic/kmfoomaticmanager.h | 42 + tdeprint/foomatic/make_driver_db_foomatic.c | 192 + tdeprint/foomatic2loader.cpp | 302 + tdeprint/foomatic2loader.h | 57 + tdeprint/fooparser.cpp | 1005 ++ tdeprint/fooparser.cpp.h | 15 + tdeprint/fooparser.y | 70 + tdeprint/fooscanner.cpp | 1707 +++ tdeprint/fooscanner.l | 83 + tdeprint/kfilelist.cpp | 326 + tdeprint/kfilelist.h | 62 + tdeprint/kmdbentry.cpp | 62 + tdeprint/kmdbentry.h | 52 + tdeprint/kmfactory.cpp | 453 + tdeprint/kmfactory.h | 129 + tdeprint/kmjob.cpp | 136 + tdeprint/kmjob.h | 130 + tdeprint/kmjobmanager.cpp | 257 + tdeprint/kmjobmanager.h | 109 + tdeprint/kmmanager.cpp | 556 + tdeprint/kmmanager.h | 183 + tdeprint/kmobject.h | 56 + tdeprint/kmprinter.cpp | 224 + tdeprint/kmprinter.h | 236 + tdeprint/kmspecialmanager.cpp | 228 + tdeprint/kmspecialmanager.h | 52 + tdeprint/kmthreadjob.cpp | 170 + tdeprint/kmthreadjob.h | 53 + tdeprint/kmuimanager.cpp | 201 + tdeprint/kmuimanager.h | 94 + tdeprint/kmvirtualmanager.cpp | 371 + tdeprint/kmvirtualmanager.h | 75 + tdeprint/kpcopiespage.cpp | 349 + tdeprint/kpcopiespage.h | 64 + tdeprint/kpdriverpage.cpp | 63 + tdeprint/kpdriverpage.h | 41 + tdeprint/kpfileselectpage.cpp | 65 + tdeprint/kpfileselectpage.h | 40 + tdeprint/kpfilterpage.cpp | 416 + tdeprint/kpfilterpage.h | 68 + tdeprint/kpgeneralpage.cpp | 736 ++ tdeprint/kpgeneralpage.h | 57 + tdeprint/kpipeprocess.cpp | 60 + tdeprint/kpipeprocess.h | 41 + tdeprint/kpmarginpage.cpp | 163 + tdeprint/kpmarginpage.h | 47 + tdeprint/kpposterpage.cpp | 341 + tdeprint/kpposterpage.h | 60 + tdeprint/kpqtpage.cpp | 336 + tdeprint/kpqtpage.h | 57 + tdeprint/kpreloadobject.cpp | 32 + tdeprint/kpreloadobject.h | 38 + tdeprint/kprintaction.cpp | 130 + tdeprint/kprintaction.h | 57 + tdeprint/kprintdialog.cpp | 987 ++ tdeprint/kprintdialog.h | 88 + tdeprint/kprintdialogpage.cpp | 49 + tdeprint/kprintdialogpage.h | 190 + tdeprint/kprinter.cpp | 1045 ++ tdeprint/kprinter.h | 780 ++ tdeprint/kprinterimpl.cpp | 606 + tdeprint/kprinterimpl.h | 70 + tdeprint/kprinterpropertydialog.cpp | 147 + tdeprint/kprinterpropertydialog.h | 69 + tdeprint/kprintpreview.cpp | 328 + tdeprint/kprintpreview.h | 65 + tdeprint/kprintpreviewui.rc | 27 + tdeprint/kprintprocess.cpp | 94 + tdeprint/kprintprocess.h | 90 + tdeprint/kxmlcommand.cpp | 830 ++ tdeprint/kxmlcommand.h | 121 + tdeprint/lpd/Makefile.am | 18 + tdeprint/lpd/gschecker.cpp | 61 + tdeprint/lpd/gschecker.h | 40 + tdeprint/lpd/klpdprinterimpl.cpp | 51 + tdeprint/lpd/klpdprinterimpl.h | 37 + tdeprint/lpd/kmlpdfactory.cpp | 52 + tdeprint/lpd/kmlpdfactory.h | 35 + tdeprint/lpd/kmlpdmanager.cpp | 651 + tdeprint/lpd/kmlpdmanager.h | 76 + tdeprint/lpd/kmlpduimanager.cpp | 60 + tdeprint/lpd/kmlpduimanager.h | 35 + tdeprint/lpd/lpd.print | 87 + tdeprint/lpd/lpdtools.cpp | 417 + tdeprint/lpd/lpdtools.h | 76 + tdeprint/lpd/make_driver_db_lpd.c | 112 + tdeprint/lpdunix/CMakeLists.txt | 52 + tdeprint/lpdunix/Makefile.am | 15 + tdeprint/lpdunix/klpdunixprinterimpl.cpp | 83 + tdeprint/lpdunix/klpdunixprinterimpl.h | 41 + tdeprint/lpdunix/kmlpdunixfactory.cpp | 29 + tdeprint/lpdunix/kmlpdunixmanager.cpp | 410 + tdeprint/lpdunix/kmlpdunixmanager.h | 42 + tdeprint/lpdunix/kmlpdunixuimanager.cpp | 45 + tdeprint/lpdunix/kmlpdunixuimanager.h | 35 + tdeprint/lpdunix/lpdunix.print | 83 + tdeprint/lpr/CMakeLists.txt | 80 + tdeprint/lpr/Makefile.am | 40 + tdeprint/lpr/apsdriver1 | 84 + tdeprint/lpr/apsdriver2 | 83 + tdeprint/lpr/apshandler.cpp | 405 + tdeprint/lpr/apshandler.h | 57 + tdeprint/lpr/editentrydialog.cpp | 157 + tdeprint/lpr/editentrydialog.h | 62 + tdeprint/lpr/klprfactory.cpp | 29 + tdeprint/lpr/klprprinterimpl.cpp | 59 + tdeprint/lpr/klprprinterimpl.h | 38 + tdeprint/lpr/kmconfiglpr.cpp | 66 + tdeprint/lpr/kmconfiglpr.h | 39 + tdeprint/lpr/kmlprjobmanager.cpp | 90 + tdeprint/lpr/kmlprjobmanager.h | 44 + tdeprint/lpr/kmlprmanager.cpp | 492 + tdeprint/lpr/kmlprmanager.h | 82 + tdeprint/lpr/kmlpruimanager.cpp | 67 + tdeprint/lpr/kmlpruimanager.h | 37 + tdeprint/lpr/lpchelper.cpp | 320 + tdeprint/lpr/lpchelper.h | 59 + tdeprint/lpr/lpqhelper.cpp | 117 + tdeprint/lpr/lpqhelper.h | 44 + tdeprint/lpr/lpr.print | 86 + tdeprint/lpr/lprhandler.cpp | 270 + tdeprint/lpr/lprhandler.h | 88 + tdeprint/lpr/lprngtooldriver1 | 85 + tdeprint/lpr/lprngtoolhandler.cpp | 393 + tdeprint/lpr/lprngtoolhandler.h | 54 + tdeprint/lpr/lprsettings.cpp | 146 + tdeprint/lpr/lprsettings.h | 67 + tdeprint/lpr/make_driver_db_lpr.c | 192 + tdeprint/lpr/matichandler.cpp | 481 + tdeprint/lpr/matichandler.h | 57 + tdeprint/lpr/matichelper.cpp | 38 + tdeprint/lpr/matichelper.h | 29 + tdeprint/lpr/printcapentry.cpp | 82 + tdeprint/lpr/printcapentry.h | 81 + tdeprint/lpr/printcapreader.cpp | 176 + tdeprint/lpr/printcapreader.h | 43 + tdeprint/management/CMakeLists.txt | 111 + tdeprint/management/Makefile.am | 52 + tdeprint/management/cjanuswidget.cpp | 265 + tdeprint/management/cjanuswidget.h | 64 + tdeprint/management/jobitem.cpp | 74 + tdeprint/management/jobitem.h | 55 + tdeprint/management/kaddprinterwizard.cpp | 39 + tdeprint/management/kiconselectaction.cpp | 118 + tdeprint/management/kiconselectaction.h | 49 + tdeprint/management/kmconfigcommand.cpp | 53 + tdeprint/management/kmconfigcommand.h | 31 + tdeprint/management/kmconfigdialog.cpp | 89 + tdeprint/management/kmconfigdialog.h | 43 + tdeprint/management/kmconfigfilter.cpp | 159 + tdeprint/management/kmconfigfilter.h | 52 + tdeprint/management/kmconfigfonts.cpp | 182 + tdeprint/management/kmconfigfonts.h | 54 + tdeprint/management/kmconfiggeneral.cpp | 142 + tdeprint/management/kmconfiggeneral.h | 50 + tdeprint/management/kmconfigjobs.cpp | 63 + tdeprint/management/kmconfigjobs.h | 40 + tdeprint/management/kmconfigpage.cpp | 36 + tdeprint/management/kmconfigpage.h | 53 + tdeprint/management/kmconfigpreview.cpp | 74 + tdeprint/management/kmconfigpreview.h | 41 + tdeprint/management/kmdbcreator.cpp | 187 + tdeprint/management/kmdbcreator.h | 58 + tdeprint/management/kmdriverdb.cpp | 244 + tdeprint/management/kmdriverdb.h | 67 + tdeprint/management/kmdriverdbwidget.cpp | 273 + tdeprint/management/kmdriverdbwidget.h | 74 + tdeprint/management/kmdriverdialog.cpp | 55 + tdeprint/management/kmdriverdialog.h | 44 + tdeprint/management/kmiconview.cpp | 237 + tdeprint/management/kmiconview.h | 78 + tdeprint/management/kminfopage.cpp | 143 + tdeprint/management/kminfopage.h | 42 + tdeprint/management/kminstancepage.cpp | 276 + tdeprint/management/kminstancepage.h | 58 + tdeprint/management/kmjobviewer.cpp | 742 ++ tdeprint/management/kmjobviewer.h | 127 + tdeprint/management/kmlistview.cpp | 268 + tdeprint/management/kmlistview.h | 59 + tdeprint/management/kmmainview.cpp | 920 ++ tdeprint/management/kmmainview.h | 133 + tdeprint/management/kmpages.cpp | 74 + tdeprint/management/kmpages.h | 44 + tdeprint/management/kmprinterpage.h | 42 + tdeprint/management/kmprinterview.cpp | 113 + tdeprint/management/kmprinterview.h | 62 + tdeprint/management/kmpropbackend.cpp | 86 + tdeprint/management/kmpropbackend.h | 45 + tdeprint/management/kmpropcontainer.cpp | 77 + tdeprint/management/kmpropcontainer.h | 50 + tdeprint/management/kmpropdriver.cpp | 83 + tdeprint/management/kmpropdriver.h | 46 + tdeprint/management/kmpropertypage.cpp | 94 + tdeprint/management/kmpropertypage.h | 53 + tdeprint/management/kmpropgeneral.cpp | 83 + tdeprint/management/kmpropgeneral.h | 44 + tdeprint/management/kmpropmembers.cpp | 70 + tdeprint/management/kmpropmembers.h | 42 + tdeprint/management/kmpropwidget.cpp | 86 + tdeprint/management/kmpropwidget.h | 63 + tdeprint/management/kmspecialprinterdlg.cpp | 222 + tdeprint/management/kmspecialprinterdlg.h | 57 + tdeprint/management/kmtimer.cpp | 96 + tdeprint/management/kmtimer.h | 62 + tdeprint/management/kmwbackend.cpp | 177 + tdeprint/management/kmwbackend.h | 54 + tdeprint/management/kmwclass.cpp | 141 + tdeprint/management/kmwclass.h | 46 + tdeprint/management/kmwdriver.cpp | 116 + tdeprint/management/kmwdriver.h | 40 + tdeprint/management/kmwdriverselect.cpp | 116 + tdeprint/management/kmwdriverselect.h | 48 + tdeprint/management/kmwdrivertest.cpp | 172 + tdeprint/management/kmwdrivertest.h | 53 + tdeprint/management/kmwend.cpp | 119 + tdeprint/management/kmwend.h | 38 + tdeprint/management/kmwfile.cpp | 77 + tdeprint/management/kmwfile.h | 39 + tdeprint/management/kmwinfobase.cpp | 90 + tdeprint/management/kmwinfobase.h | 51 + tdeprint/management/kmwinfopage.cpp | 48 + tdeprint/management/kmwinfopage.h | 31 + tdeprint/management/kmwizard.cpp | 262 + tdeprint/management/kmwizard.h | 101 + tdeprint/management/kmwizardpage.cpp | 48 + tdeprint/management/kmwizardpage.h | 52 + tdeprint/management/kmwlocal.cpp | 206 + tdeprint/management/kmwlocal.h | 58 + tdeprint/management/kmwlpd.cpp | 102 + tdeprint/management/kmwlpd.h | 34 + tdeprint/management/kmwname.cpp | 96 + tdeprint/management/kmwname.h | 35 + tdeprint/management/kmwpassword.cpp | 133 + tdeprint/management/kmwpassword.h | 43 + tdeprint/management/kmwsmb.cpp | 119 + tdeprint/management/kmwsmb.h | 50 + tdeprint/management/kmwsocket.cpp | 151 + tdeprint/management/kmwsocket.h | 51 + tdeprint/management/kmwsocketutil.cpp | 219 + tdeprint/management/kmwsocketutil.h | 76 + tdeprint/management/kxmlcommanddlg.cpp | 1059 ++ tdeprint/management/kxmlcommanddlg.h | 127 + tdeprint/management/kxmlcommandselector.cpp | 285 + tdeprint/management/kxmlcommandselector.h | 68 + tdeprint/management/networkscanner.cpp | 421 + tdeprint/management/networkscanner.h | 95 + tdeprint/management/pluginaction.cpp | 34 + tdeprint/management/pluginaction.h | 42 + tdeprint/management/side.png | Bin 0 -> 50353 bytes tdeprint/management/sidepixmap.cpp | 69 + tdeprint/management/sidepixmap.h | 42 + tdeprint/management/smbview.cpp | 292 + tdeprint/management/smbview.h | 67 + tdeprint/management/tdeprint_management_module.cpp | 56 + tdeprint/management/tiledown.png | Bin 0 -> 323 bytes tdeprint/management/tileup.png | Bin 0 -> 241 bytes tdeprint/marginpreview.cpp | 331 + tdeprint/marginpreview.h | 65 + tdeprint/marginvaluewidget.cpp | 126 + tdeprint/marginvaluewidget.h | 57 + tdeprint/marginwidget.cpp | 376 + tdeprint/marginwidget.h | 75 + tdeprint/messagewindow.cpp | 121 + tdeprint/messagewindow.h | 55 + tdeprint/pics/CMakeLists.txt | 41 + tdeprint/pics/Makefile.am | 22 + tdeprint/pics/cr16-action-filterstop.png | Bin 0 -> 740 bytes tdeprint/pics/cr16-action-tdeprint_restartsrv.png | Bin 0 -> 941 bytes tdeprint/pics/cr16-action-tdeprint_uploadsmb.png | Bin 0 -> 985 bytes tdeprint/pics/cr16-app-tdeprint_computer.png | Bin 0 -> 913 bytes tdeprint/pics/cr16-app-tdeprint_job.png | Bin 0 -> 474 bytes tdeprint/pics/cr16-app-tdeprint_job_cancelled.png | Bin 0 -> 652 bytes tdeprint/pics/cr16-app-tdeprint_job_completed.png | Bin 0 -> 634 bytes tdeprint/pics/cr16-app-tdeprint_job_error.png | Bin 0 -> 646 bytes tdeprint/pics/cr16-app-tdeprint_job_process.png | Bin 0 -> 729 bytes tdeprint/pics/cr16-app-tdeprint_job_stopped.png | Bin 0 -> 651 bytes tdeprint/pics/cr16-app-tdeprint_printer.png | Bin 0 -> 668 bytes tdeprint/pics/cr16-app-tdeprint_printer_class.png | Bin 0 -> 769 bytes .../cr16-app-tdeprint_printer_class_process.png | Bin 0 -> 871 bytes .../cr16-app-tdeprint_printer_class_stopped.png | Bin 0 -> 888 bytes tdeprint/pics/cr16-app-tdeprint_printer_defect.png | Bin 0 -> 847 bytes .../pics/cr16-app-tdeprint_printer_process.png | Bin 0 -> 770 bytes tdeprint/pics/cr16-app-tdeprint_printer_remote.png | Bin 0 -> 692 bytes .../cr16-app-tdeprint_printer_remote_process.png | Bin 0 -> 804 bytes .../cr16-app-tdeprint_printer_remote_stopped.png | Bin 0 -> 838 bytes .../pics/cr16-app-tdeprint_printer_stopped.png | Bin 0 -> 827 bytes tdeprint/pics/cr22-action-history.png | Bin 0 -> 1515 bytes tdeprint/pics/cr22-action-package_utilities.png | Bin 0 -> 1430 bytes tdeprint/pics/cr22-action-tdeprint_addprinter.png | Bin 0 -> 1218 bytes tdeprint/pics/cr22-action-tdeprint_addpseudo.png | Bin 0 -> 1261 bytes tdeprint/pics/cr22-action-tdeprint_configmgr.png | Bin 0 -> 974 bytes tdeprint/pics/cr22-action-tdeprint_configsrv.png | Bin 0 -> 1356 bytes tdeprint/pics/cr22-action-tdeprint_defaulthard.png | Bin 0 -> 1239 bytes tdeprint/pics/cr22-action-tdeprint_defaultsoft.png | Bin 0 -> 1317 bytes .../pics/cr22-action-tdeprint_enableprinter.png | Bin 0 -> 769 bytes tdeprint/pics/cr22-action-tdeprint_printer.png | Bin 0 -> 1001 bytes .../pics/cr22-action-tdeprint_printer_infos.png | Bin 0 -> 1244 bytes tdeprint/pics/cr22-action-tdeprint_printstate.png | Bin 0 -> 1029 bytes tdeprint/pics/cr22-action-tdeprint_queuestate.png | Bin 0 -> 1339 bytes tdeprint/pics/cr22-action-tdeprint_report.png | Bin 0 -> 818 bytes tdeprint/pics/cr22-action-tdeprint_restartsrv.png | Bin 0 -> 1455 bytes tdeprint/pics/cr22-action-tdeprint_stopprinter.png | Bin 0 -> 1330 bytes tdeprint/pics/cr22-action-tdeprint_testprinter.png | Bin 0 -> 1021 bytes tdeprint/pics/cr22-action-tdeprint_uploadsmb.png | Bin 0 -> 1566 bytes tdeprint/pics/cr22-app-tdeprint_printer.png | Bin 0 -> 1001 bytes tdeprint/pics/cr32-action-tdeprint_inklevel.png | Bin 0 -> 2209 bytes tdeprint/pics/cr32-app-tdeprint_printer.png | Bin 0 -> 1331 bytes tdeprint/pics/cr32-app-tdeprint_printer_class.png | Bin 0 -> 1803 bytes .../cr32-app-tdeprint_printer_class_process.png | Bin 0 -> 1955 bytes .../cr32-app-tdeprint_printer_class_stopped.png | Bin 0 -> 2232 bytes tdeprint/pics/cr32-app-tdeprint_printer_defect.png | Bin 0 -> 1960 bytes .../pics/cr32-app-tdeprint_printer_process.png | Bin 0 -> 1558 bytes tdeprint/pics/cr32-app-tdeprint_printer_remote.png | Bin 0 -> 1398 bytes .../cr32-app-tdeprint_printer_remote_process.png | Bin 0 -> 1595 bytes .../cr32-app-tdeprint_printer_remote_stopped.png | Bin 0 -> 1924 bytes .../pics/cr32-app-tdeprint_printer_stopped.png | Bin 0 -> 1915 bytes tdeprint/pics/cr32-app-tdeprint_printer_users.png | Bin 0 -> 1939 bytes tdeprint/pics/cr48-app-tdeprint_printer.png | Bin 0 -> 2140 bytes tdeprint/pics/cr48-app-tdeprint_printer_class.png | Bin 0 -> 2931 bytes tdeprint/pics/cr64-app-tdeprint_printer.png | Bin 0 -> 2940 bytes tdeprint/pics/cr64-app-tdeprint_printer_class.png | Bin 0 -> 3930 bytes tdeprint/pics/processsign.png | Bin 0 -> 423 bytes tdeprint/pics/stopsign.png | Bin 0 -> 890 bytes tdeprint/pics/tdeprint_collate.png | Bin 0 -> 1846 bytes tdeprint/pics/tdeprint_collate_reverse.png | Bin 0 -> 1807 bytes tdeprint/pics/tdeprint_color.png | Bin 0 -> 2503 bytes tdeprint/pics/tdeprint_dupl_none.png | Bin 0 -> 680 bytes tdeprint/pics/tdeprint_duplex_long.png | Bin 0 -> 249 bytes tdeprint/pics/tdeprint_duplex_none.png | Bin 0 -> 231 bytes tdeprint/pics/tdeprint_duplex_short.png | Bin 0 -> 267 bytes tdeprint/pics/tdeprint_grayscale.png | Bin 0 -> 1121 bytes tdeprint/pics/tdeprint_landscape.png | Bin 0 -> 884 bytes tdeprint/pics/tdeprint_nup1.png | Bin 0 -> 320 bytes tdeprint/pics/tdeprint_nup2.png | Bin 0 -> 317 bytes tdeprint/pics/tdeprint_nup4.png | Bin 0 -> 322 bytes tdeprint/pics/tdeprint_nupother.png | Bin 0 -> 406 bytes tdeprint/pics/tdeprint_opt_duplex.png | Bin 0 -> 1111 bytes tdeprint/pics/tdeprint_pagesize.png | Bin 0 -> 289 bytes tdeprint/pics/tdeprint_portrait.png | Bin 0 -> 891 bytes tdeprint/pics/tdeprint_prettyprint.png | Bin 0 -> 335 bytes tdeprint/pics/tdeprint_revlandscape.png | Bin 0 -> 891 bytes tdeprint/pics/tdeprint_revportrait.png | Bin 0 -> 895 bytes tdeprint/pics/tdeprint_uncollate.png | Bin 0 -> 2003 bytes tdeprint/pics/tdeprint_uncollate_reverse.png | Bin 0 -> 2034 bytes tdeprint/plugincombobox.cpp | 104 + tdeprint/plugincombobox.h | 50 + tdeprint/posterpreview.cpp | 294 + tdeprint/posterpreview.h | 75 + tdeprint/ppdloader.cpp | 531 + tdeprint/ppdloader.h | 74 + tdeprint/ppdparser.cpp | 1456 +++ tdeprint/ppdparser.cpp.h | 81 + tdeprint/ppdparser.y | 118 + tdeprint/ppdscanner.cpp | 1914 +++ tdeprint/ppdscanner.l | 141 + tdeprint/printerfilter.cpp | 71 + tdeprint/printerfilter.h | 49 + tdeprint/rlpr/CMakeLists.txt | 54 + tdeprint/rlpr/Makefile.am | 17 + tdeprint/rlpr/kmconfigproxy.cpp | 47 + tdeprint/rlpr/kmconfigproxy.h | 40 + tdeprint/rlpr/kmproprlpr.cpp | 75 + tdeprint/rlpr/kmproprlpr.h | 43 + tdeprint/rlpr/kmproxywidget.cpp | 71 + tdeprint/rlpr/kmproxywidget.h | 43 + tdeprint/rlpr/kmrlprfactory.cpp | 28 + tdeprint/rlpr/kmrlprmanager.cpp | 158 + tdeprint/rlpr/kmrlprmanager.h | 48 + tdeprint/rlpr/kmrlpruimanager.cpp | 55 + tdeprint/rlpr/kmrlpruimanager.h | 36 + tdeprint/rlpr/kmwrlpr.cpp | 210 + tdeprint/rlpr/kmwrlpr.h | 50 + tdeprint/rlpr/krlprprinterimpl.cpp | 76 + tdeprint/rlpr/krlprprinterimpl.h | 36 + tdeprint/rlpr/rlpr.print | 84 + tdeprint/signal_proc.c | 136 + tdeprint/specials.desktop | 1196 ++ tdeprint/tdeprintcheck.cpp | 134 + tdeprint/tdeprintcheck.h | 41 + tdeprint/tdeprintd.cpp | 315 + tdeprint/tdeprintd.desktop | 162 + tdeprint/tdeprintd.h | 66 + tdeprint/tdeprintrc | 7 + tdeprint/tdeprintrc.upd | 6 + tdeprint/testprint.ps | 522 + tdeprint/tests/Makefile.am | 15 + tdeprint/tests/back.xpm | 105 + tdeprint/tests/drawdemo.cpp | 253 + tdeprint/tests/drawdemo.h | 30 + tdeprint/tests/forward.xpm | 110 + tdeprint/tests/helpwindow.cpp | 351 + tdeprint/tests/helpwindow.h | 65 + tdeprint/tests/home.xpm | 119 + tdeprint/tests/main.cpp | 41 + tdeprint/tests/richpage.cpp | 85 + tdeprint/tests/richpage.h | 24 + tdeprint/tools/CMakeLists.txt | 12 + tdeprint/tools/Makefile.am | 1 + tdeprint/tools/escputil/CMakeLists.txt | 42 + tdeprint/tools/escputil/Makefile.am | 12 + tdeprint/tools/escputil/escputil.desktop | 29 + tdeprint/tools/escputil/escpwidget.cpp | 261 + tdeprint/tools/escputil/escpwidget.h | 57 + tdeprint/treecombobox.cpp | 156 + tdeprint/treecombobox.h | 76 + tdeprint/util.cpp | 139 + tdeprint/util.h | 76 + tdesu/CMakeLists.txt | 57 + tdesu/Mainpage.dox | 21 + tdesu/Makefile.am | 30 + tdesu/README | 13 + tdesu/client.cpp | 435 + tdesu/client.h | 207 + tdesu/configure.in.in | 93 + tdesu/defaults.h | 21 + tdesu/kcookie.cpp | 225 + tdesu/kcookie.h | 90 + tdesu/libtdesu.nmcheck | 10 + tdesu/libtdesu_weak.nmcheck | 2 + tdesu/process.cpp | 626 + tdesu/process.h | 188 + tdesu/ssh.cpp | 279 + tdesu/ssh.h | 90 + tdesu/stub.cpp | 184 + tdesu/stub.h | 139 + tdesu/su.cpp | 342 + tdesu/su.h | 63 + tdesu/tdesu_pty.cpp | 302 + tdesu/tdesu_pty.h | 71 + tdesu/tdesu_stub.c | 432 + tdeui/AUTHORS | 97 + tdeui/CMakeLists.txt | 168 + tdeui/MAINTAINERS | 97 + tdeui/Mainpage.dox | 43 + tdeui/Makefile.am | 171 + tdeui/README.kspell | 17 + tdeui/TODO.kspell | 34 + tdeui/TODO.xmlgui | 91 + tdeui/about/CMakeLists.txt | 21 + tdeui/about/Makefile.am | 9 + tdeui/about/bar-bottom-left.png | Bin 0 -> 369 bytes tdeui/about/bar-bottom-middle.png | Bin 0 -> 160 bytes tdeui/about/bar-bottom-right.png | Bin 0 -> 346 bytes tdeui/about/bar-middle-left.png | Bin 0 -> 126 bytes tdeui/about/bar-middle-right.png | Bin 0 -> 141 bytes tdeui/about/bar-top-left.png | Bin 0 -> 358 bytes tdeui/about/bar-top-middle.png | Bin 0 -> 145 bytes tdeui/about/bar-top-right.png | Bin 0 -> 359 bytes tdeui/about/bottom-left.png | Bin 0 -> 665 bytes tdeui/about/bottom-middle.png | Bin 0 -> 174 bytes tdeui/about/bottom-right.png | Bin 0 -> 4922 bytes tdeui/about/box-bottom-left.png | Bin 0 -> 470 bytes tdeui/about/box-bottom-middle.png | Bin 0 -> 103 bytes tdeui/about/box-bottom-right.png | Bin 0 -> 462 bytes tdeui/about/box-middle-left.png | Bin 0 -> 95 bytes tdeui/about/box-middle-right.png | Bin 0 -> 95 bytes tdeui/about/box-top-left.png | Bin 0 -> 450 bytes tdeui/about/box-top-middle.png | Bin 0 -> 104 bytes tdeui/about/box-top-right.png | Bin 0 -> 496 bytes tdeui/about/kde_infopage.css | 239 + tdeui/about/kde_infopage_rtl.css | 11 + tdeui/about/top-left.png | Bin 0 -> 10867 bytes tdeui/about/top-middle.png | Bin 0 -> 233 bytes tdeui/about/usage-example.html | 64 + tdeui/aboutkde.png | Bin 0 -> 29600 bytes tdeui/colors/Makefile.am | 10 + tdeui/colors/README | 2 + tdeui/colors/rgb.txt | 753 ++ tdeui/dcolorarrow.xbm | 6 + tdeui/dcolorreset.xpm | 19 + tdeui/kaboutapplication.cpp | 188 + tdeui/kaboutapplication.h | 94 + tdeui/kaboutdialog.cpp | 1797 +++ tdeui/kaboutdialog.h | 633 + tdeui/kaboutdialog_private.h | 143 + tdeui/kaboutkde.cpp | 87 + tdeui/kaboutkde.h | 62 + tdeui/kaccelgen.h | 280 + tdeui/kaction.cpp | 1288 ++ tdeui/kaction.h | 676 ++ tdeui/kactionclasses.cpp | 2421 ++++ tdeui/kactionclasses.h | 1436 +++ tdeui/kactioncollection.cpp | 802 ++ tdeui/kactioncollection.h | 393 + tdeui/kactionselector.cpp | 538 + tdeui/kactionselector.h | 402 + tdeui/kactionshortcutlist.h | 79 + tdeui/kactivelabel.cpp | 142 + tdeui/kactivelabel.h | 87 + tdeui/kanimwidget.cpp | 212 + tdeui/kanimwidget.h | 144 + tdeui/karrowbutton.cpp | 113 + tdeui/karrowbutton.h | 94 + tdeui/kauthicon.cpp | 203 + tdeui/kauthicon.h | 173 + tdeui/kbugreport.cpp | 538 + tdeui/kbugreport.h | 121 + tdeui/kbuttonbox.cpp | 377 + tdeui/kbuttonbox.h | 170 + tdeui/kcharselect.cpp | 546 + tdeui/kcharselect.h | 266 + tdeui/kcmenumngr.cpp | 129 + tdeui/kcmenumngr.h | 116 + tdeui/kcmodule.cpp | 220 + tdeui/kcmodule.h | 361 + tdeui/kcolorbtn.h | 12 + tdeui/kcolorbutton.cpp | 207 + tdeui/kcolorbutton.h | 115 + tdeui/kcolorcombo.cpp | 264 + tdeui/kcolorcombo.h | 95 + tdeui/kcolordialog.cpp | 1616 +++ tdeui/kcolordialog.h | 496 + tdeui/kcolordlg.h | 6 + tdeui/kcolordrag.cpp | 112 + tdeui/kcolordrag.h | 79 + tdeui/kcombobox.cpp | 797 ++ tdeui/kcombobox.h | 825 ++ tdeui/kcommand.cpp | 379 + tdeui/kcommand.h | 289 + tdeui/kcompletionbox.cpp | 562 + tdeui/kcompletionbox.h | 246 + tdeui/kconfigdialog.cpp | 259 + tdeui/kconfigdialog.h | 279 + tdeui/kcursor.cpp | 434 + tdeui/kcursor.h | 224 + tdeui/kcursor_private.h | 99 + tdeui/kdatepicker.cpp | 549 + tdeui/kdatepicker.h | 257 + tdeui/kdatepik.h | 6 + tdeui/kdatetbl.cpp | 1031 ++ tdeui/kdatetbl.h | 447 + tdeui/kdatetimewidget.cpp | 74 + tdeui/kdatetimewidget.h | 92 + tdeui/kdatewidget.cpp | 177 + tdeui/kdatewidget.h | 90 + tdeui/kdcopactionproxy.cpp | 159 + tdeui/kdcopactionproxy.h | 112 + tdeui/kdepackages.h | 1301 ++ tdeui/kdetrayproxy/CMakeLists.txt | 46 + tdeui/kdetrayproxy/Makefile.am | 13 + tdeui/kdetrayproxy/kdetrayproxy.cpp | 194 + tdeui/kdetrayproxy/kdetrayproxy.desktop | 134 + tdeui/kdetrayproxy/kdetrayproxy.h | 50 + tdeui/kdetrayproxy/module.cpp | 33 + tdeui/kdetrayproxy/module.h | 39 + tdeui/kdialog.cpp | 496 + tdeui/kdialog.h | 259 + tdeui/kdialogbase.cpp | 1844 +++ tdeui/kdialogbase.h | 1632 +++ tdeui/kdialogbase_priv.h | 71 + tdeui/kdockwidget.cpp | 3331 ++++++ tdeui/kdockwidget.h | 1553 +++ tdeui/kdockwidget_p.h | 89 + tdeui/kdockwidget_private.cpp | 712 ++ tdeui/kdockwidget_private.h | 335 + tdeui/kdockwindow.h | 41 + tdeui/kdualcolorbtn.h | 6 + tdeui/kdualcolorbutton.cpp | 283 + tdeui/kdualcolorbutton.h | 159 + tdeui/keditcl.h | 436 + tdeui/keditcl1.cpp | 718 ++ tdeui/keditcl2.cpp | 1127 ++ tdeui/keditlistbox.cpp | 418 + tdeui/keditlistbox.h | 279 + tdeui/kedittoolbar.cpp | 1455 +++ tdeui/kedittoolbar.h | 439 + tdeui/kfontcombo.cpp | 382 + tdeui/kfontcombo.h | 179 + tdeui/kfontdialog.cpp | 799 ++ tdeui/kfontdialog.h | 504 + tdeui/kfontrequester.cpp | 127 + tdeui/kfontrequester.h | 157 + tdeui/kguiitem.cpp | 229 + tdeui/kguiitem.h | 98 + tdeui/khelpmenu.cpp | 321 + tdeui/khelpmenu.h | 281 + tdeui/kiconview.cpp | 751 ++ tdeui/kiconview.h | 281 + tdeui/kiconviewsearchline.cpp | 308 + tdeui/kiconviewsearchline.h | 184 + tdeui/kinputdialog.cpp | 472 + tdeui/kinputdialog.h | 292 + tdeui/kjanuswidget.cpp | 1255 ++ tdeui/kjanuswidget.h | 615 + tdeui/kkeybutton.cpp | 178 + tdeui/kkeybutton.h | 91 + tdeui/kkeydialog.cpp | 1209 ++ tdeui/kkeydialog.h | 407 + tdeui/klanguagebutton.cpp | 284 + tdeui/klanguagebutton.h | 182 + tdeui/kled.cpp | 644 + tdeui/kled.h | 329 + tdeui/klineedit.cpp | 1382 +++ tdeui/klineedit.h | 656 + tdeui/klineeditdlg.cpp | 194 + tdeui/klineeditdlg.h | 127 + tdeui/klistbox.cpp | 266 + tdeui/klistbox.h | 128 + tdeui/klistview.cpp | 2365 ++++ tdeui/klistview.h | 1086 ++ tdeui/klistviewlineedit.h | 65 + tdeui/klistviewsearchline.cpp | 501 + tdeui/klistviewsearchline.h | 264 + tdeui/kmainwindow.cpp | 1249 ++ tdeui/kmainwindow.h | 1076 ++ tdeui/kmainwindowiface.cpp | 194 + tdeui/kmainwindowiface.h | 161 + tdeui/kmenubar.cpp | 571 + tdeui/kmenubar.h | 114 + tdeui/kmessagebox.cpp | 1071 ++ tdeui/kmessagebox.h | 1166 ++ tdeui/knuminput.cpp | 1180 ++ tdeui/knuminput.h | 962 ++ tdeui/knumvalidator.cpp | 371 + tdeui/knumvalidator.h | 212 + tdeui/kpanelapplet.cpp | 198 + tdeui/kpanelapplet.h | 395 + tdeui/kpanelappmenu.cpp | 182 + tdeui/kpanelappmenu.h | 99 + tdeui/kpanelextension.cpp | 163 + tdeui/kpanelextension.h | 345 + tdeui/kpanelmenu.cpp | 158 + tdeui/kpanelmenu.h | 182 + tdeui/kpartgui.dtd | 181 + tdeui/kpassdlg.cpp | 724 ++ tdeui/kpassdlg.h | 414 + tdeui/kpassivepopup.cpp | 499 + tdeui/kpassivepopup.h | 368 + tdeui/kpixmapio-perf.png | Bin 0 -> 3899 bytes tdeui/kpixmapio.cpp | 908 ++ tdeui/kpixmapio.h | 185 + tdeui/kpixmapregionselectordialog.cpp | 127 + tdeui/kpixmapregionselectordialog.h | 107 + tdeui/kpixmapregionselectorwidget.cpp | 450 + tdeui/kpixmapregionselectorwidget.h | 170 + tdeui/kpopupmenu.cpp | 694 ++ tdeui/kpopupmenu.h | 282 + tdeui/kprogress.cpp | 414 + tdeui/kprogress.h | 401 + tdeui/kprogressbox.cpp | 316 + tdeui/kprogressbox.h | 291 + tdeui/kpushbutton.cpp | 220 + tdeui/kpushbutton.h | 161 + tdeui/krestrictedline.cpp | 81 + tdeui/krestrictedline.h | 95 + tdeui/krootpixmap.cpp | 347 + tdeui/krootpixmap.h | 240 + tdeui/kruler.cpp | 742 ++ tdeui/kruler.h | 521 + tdeui/ksconfig.cpp | 1028 ++ tdeui/ksconfig.h | 293 + tdeui/kscrollview.cpp | 189 + tdeui/kscrollview.h | 62 + tdeui/kselect.cpp | 534 + tdeui/kselect.h | 373 + tdeui/kseparator.cpp | 116 + tdeui/kseparator.h | 87 + tdeui/ksharedpixmap.cpp | 228 + tdeui/ksharedpixmap.h | 120 + tdeui/kshortcutdialog.cpp | 529 + tdeui/kshortcutdialog.h | 96 + tdeui/kshortcutdialog_advanced.ui | 254 + tdeui/kshortcutdialog_simple.ui | 120 + tdeui/kspell.cpp | 1577 +++ tdeui/kspell.h | 568 + tdeui/kspelldlg.cpp | 285 + tdeui/kspelldlg.h | 114 + tdeui/kspellui.ui | 300 + tdeui/ksplashscreen.cpp | 42 + tdeui/ksplashscreen.h | 62 + tdeui/ksqueezedtextlabel.cpp | 87 + tdeui/ksqueezedtextlabel.h | 84 + tdeui/kstatusbar.cpp | 156 + tdeui/kstatusbar.h | 208 + tdeui/kstdaction.cpp | 323 + tdeui/kstdaction.h | 614 + tdeui/kstdaction_p.h | 139 + tdeui/kstdguiitem.cpp | 287 + tdeui/kstdguiitem.h | 183 + tdeui/kstringvalidator.cpp | 90 + tdeui/kstringvalidator.h | 141 + tdeui/kswitchlanguagedialog.cpp | 349 + tdeui/kswitchlanguagedialog.h | 87 + tdeui/ksyntaxhighlighter.cpp | 677 ++ tdeui/ksyntaxhighlighter.h | 184 + tdeui/ksystemtray.cpp | 350 + tdeui/ksystemtray.h | 216 + tdeui/ktabbar.cpp | 427 + tdeui/ktabbar.h | 113 + tdeui/ktabctl.cpp | 336 + tdeui/ktabctl.h | 90 + tdeui/ktabwidget.cpp | 526 + tdeui/ktabwidget.h | 294 + tdeui/ktextbrowser.cpp | 145 + tdeui/ktextbrowser.h | 133 + tdeui/ktextedit.cpp | 419 + tdeui/ktextedit.h | 174 + tdeui/ktimewidget.cpp | 58 + tdeui/ktimewidget.h | 86 + tdeui/ktimezonewidget.cpp | 133 + tdeui/ktimezonewidget.h | 112 + tdeui/ktip-background.png | Bin 0 -> 190 bytes tdeui/ktip-bulb.png | Bin 0 -> 14134 bytes tdeui/ktip.cpp | 447 + tdeui/ktip.h | 192 + tdeui/ktoolbar.cpp | 2264 ++++ tdeui/ktoolbar.h | 1130 ++ tdeui/ktoolbarbutton.cpp | 781 ++ tdeui/ktoolbarbutton.h | 331 + tdeui/ktoolbarhandler.cpp | 246 + tdeui/ktoolbarhandler.h | 69 + tdeui/ktoolbarlabelaction.cpp | 117 + tdeui/ktoolbarlabelaction.h | 137 + tdeui/ktoolbarradiogroup.cpp | 77 + tdeui/ktoolbarradiogroup.h | 88 + tdeui/kurllabel.cpp | 450 + tdeui/kurllabel.h | 411 + tdeui/kwhatsthismanager.cpp | 121 + tdeui/kwhatsthismanager_p.h | 58 + tdeui/kwindowinfo.cpp | 178 + tdeui/kwindowinfo.h | 145 + tdeui/kwindowlistmenu.cpp | 257 + tdeui/kwindowlistmenu.h | 74 + tdeui/kwizard.cpp | 57 + tdeui/kwizard.h | 62 + tdeui/kwordwrap.cpp | 269 + tdeui/kwordwrap.h | 149 + tdeui/kxmlgui.h | 6 + tdeui/kxmlgui.xsd | 445 + tdeui/kxmlguibuilder.cpp | 441 + tdeui/kxmlguibuilder.h | 96 + tdeui/kxmlguiclient.cpp | 951 ++ tdeui/kxmlguiclient.h | 367 + tdeui/kxmlguifactory.cpp | 614 + tdeui/kxmlguifactory.h | 220 + tdeui/kxmlguifactory_p.cpp | 836 ++ tdeui/kxmlguifactory_p.h | 254 + tdeui/libtdeui.nmcheck | 5 + tdeui/libtdeui_weak.nmcheck | 2 + tdeui/preparetips | 66 + tdeui/qxembed.cpp | 1450 +++ tdeui/qxembed.h | 244 + tdeui/tests/CMakeLists.txt | 49 + tdeui/tests/Makefile.am | 105 + tdeui/tests/RayTracedGear.png | Bin 0 -> 5844 bytes tdeui/tests/background_1.png | Bin 0 -> 7209 bytes tdeui/tests/go.png | Bin 0 -> 3286 bytes tdeui/tests/itemcontainertest.cpp | 225 + tdeui/tests/itemcontainertest.h | 45 + tdeui/tests/kaboutdialogtest.cpp | 72 + tdeui/tests/kaccelgentest.cpp | 51 + tdeui/tests/kactiontest.cpp | 38 + tdeui/tests/kalphaicontest.h | 24 + tdeui/tests/kblendtest.cpp | 98 + tdeui/tests/kblendtest.h | 24 + tdeui/tests/kbuttonboxtest.cpp | 205 + tdeui/tests/kcharselecttest.cpp | 16 + tdeui/tests/kcolordlgtest.cpp | 41 + tdeui/tests/kcolortest.cpp | 169 + tdeui/tests/kcolortest.h | 21 + tdeui/tests/kcomboboxtest.cpp | 227 + tdeui/tests/kcomboboxtest.h | 44 + tdeui/tests/kcompletiontest.cpp | 198 + tdeui/tests/kcompletiontest.h | 67 + tdeui/tests/kdatepicktest.cpp | 16 + tdeui/tests/kdatetimewidgettest.cpp | 14 + tdeui/tests/kdatewidgettest.cpp | 16 + tdeui/tests/kdesattest.cpp | 65 + tdeui/tests/kdesattest.h | 31 + tdeui/tests/kdialogbasetest.cpp | 77 + tdeui/tests/kdocktest.cpp | 65 + tdeui/tests/kdocktest.h | 19 + tdeui/tests/kdockwidgetdemo.cpp | 796 ++ tdeui/tests/kdockwidgetdemo.h | 164 + tdeui/tests/kdockwidgettest.cpp | 255 + tdeui/tests/kdockwidgettest.h | 72 + tdeui/tests/kdualcolortest.cpp | 63 + tdeui/tests/kdualcolortest.h | 20 + tdeui/tests/keditlistboxtest.cpp | 21 + tdeui/tests/kedittest.cpp | 14 + tdeui/tests/kfontdialogtest.cpp | 51 + tdeui/tests/kgradienttest.cpp | 108 + tdeui/tests/kgradienttest.h | 24 + tdeui/tests/khashtest.cpp | 137 + tdeui/tests/khashtest.h | 26 + tdeui/tests/kinputdialogtest.cpp | 67 + tdeui/tests/kjanuswidgettest.cpp | 25 + tdeui/tests/kledtest.cpp | 160 + tdeui/tests/kledtest.h | 56 + tdeui/tests/klineeditdlgtest.cpp | 19 + tdeui/tests/klineedittest.cpp | 137 + tdeui/tests/klineedittest.h | 41 + tdeui/tests/klistviewtest.cpp | 39 + tdeui/tests/kmainwindowrestoretest.cpp | 41 + tdeui/tests/kmainwindowrestoretest.h | 48 + tdeui/tests/kmainwindowtest.cpp | 38 + tdeui/tests/kmainwindowtest.h | 18 + tdeui/tests/kmessageboxtest.cpp | 242 + tdeui/tests/knuminputtest.cpp | 145 + tdeui/tests/knuminputtest.h | 23 + tdeui/tests/kpalettetest.cpp | 38 + tdeui/tests/kpanelmenutest.cpp | 72 + tdeui/tests/kpanelmenutest.h | 21 + tdeui/tests/kpixmapregionselectordialogtest.cpp | 33 + tdeui/tests/kpopuptest.cpp | 40 + tdeui/tests/kprogresstest.cpp | 58 + tdeui/tests/krulertest.cpp | 375 + tdeui/tests/krulertest.h | 91 + tdeui/tests/kseparatortest.cpp | 51 + tdeui/tests/kspelltest.cpp | 57 + tdeui/tests/ksqueezedtextlabeltest.cpp | 13 + tdeui/tests/kstatusbartest.cpp | 121 + tdeui/tests/kstatusbartest.h | 33 + tdeui/tests/ksystemtraytest.cpp | 14 + tdeui/tests/ktabctltest.cpp | 105 + tdeui/tests/ktabctltest.h | 30 + tdeui/tests/ktabwidgettest.cpp | 366 + tdeui/tests/ktabwidgettest.h | 69 + tdeui/tests/ktextedittest.cpp | 43 + tdeui/tests/ktimewidgettest.cpp | 14 + tdeui/tests/ktoolbarlabelactiontest.cpp | 97 + tdeui/tests/ktoolbarlabelactiontestui.rc | 9 + tdeui/tests/kunbalancedgrdtest.cpp | 176 + tdeui/tests/kunbalancedgrdtest.h | 49 + tdeui/tests/kwindowtest.cpp | 528 + tdeui/tests/kwindowtest.h | 71 + tdeui/tests/kwizardtest.cpp | 54 + tdeui/tests/kwordwraptest.cpp | 43 + tdeui/tests/kxmlguitest.cpp | 64 + tdeui/tests/kxmlguitest.h | 19 + tdeui/tests/kxmlguitest_part.rc | 8 + tdeui/tests/kxmlguitest_shell.rc | 7 + tdeui/tests/qxembedtest.cpp | 88 + tdeui/tests/testimage.png | Bin 0 -> 35951 bytes tdeui/ui_standards.rc | 211 + .../kdecore/kconfig_compiler/kconfig_compiler.pro | 18 - win/pro_files/kdecore/kdecore.pro | 143 - win/pro_files/kdefx/kdefx.pro | 22 - win/pro_files/kdefx/kdefx_rel.pro | 27 - win/pro_files/kdeprint/kdeprint.pro | 15 - win/pro_files/kdeui/kdeui.pro | 148 - .../tdecore/kconfig_compiler/kconfig_compiler.pro | 18 + win/pro_files/tdecore/tdecore.pro | 143 + win/pro_files/tdefx/tdefx.pro | 22 + win/pro_files/tdefx/tdefx_rel.pro | 27 + win/pro_files/tdeprint/tdeprint.pro | 15 + win/pro_files/tdeui/tdeui.pro | 148 + 2996 files changed, 368526 insertions(+), 368526 deletions(-) delete mode 100644 kdecore/40.colors delete mode 100644 kdecore/AUTHORS delete mode 100644 kdecore/CMakeLists.txt delete mode 100644 kdecore/DESIGN.COLOR delete mode 100644 kdecore/DESIGN.iconloading delete mode 100644 kdecore/DESIGN.kconfig delete mode 100644 kdecore/KCONFIG_DESIGN delete mode 100644 kdecore/MAINTAINERS delete mode 100644 kdecore/Mainpage.dox delete mode 100644 kdecore/Makefile.am delete mode 100644 kdecore/README delete mode 100644 kdecore/README.exec delete mode 100644 kdecore/README.kiosk delete mode 100644 kdecore/README.kstartupinfo delete mode 100644 kdecore/README.user_profiles delete mode 100644 kdecore/Rainbow.colors delete mode 100644 kdecore/Royal.colors delete mode 100644 kdecore/Web.colors delete mode 100644 kdecore/all_languages.desktop delete mode 100644 kdecore/configure.in.in delete mode 100644 kdecore/eventsrc delete mode 100644 kdecore/fakes.c delete mode 100644 kdecore/fixx11h.h delete mode 100755 kdecore/generate_keys.sh delete mode 100644 kdecore/kaboutdata.cpp delete mode 100644 kdecore/kaboutdata.h delete mode 100644 kdecore/kaccel.cpp delete mode 100644 kdecore/kaccel.h delete mode 100644 kdecore/kaccelaction.cpp delete mode 100644 kdecore/kaccelaction.h delete mode 100644 kdecore/kaccelbase.cpp delete mode 100644 kdecore/kaccelbase.h delete mode 100644 kdecore/kaccelmanager.cpp delete mode 100644 kdecore/kaccelmanager.h delete mode 100644 kdecore/kaccelmanager_private.h delete mode 100644 kdecore/kaccelprivate.h delete mode 100644 kdecore/kallocator.cpp delete mode 100644 kdecore/kallocator.h delete mode 100644 kdecore/kapp.h delete mode 100644 kdecore/kappdcopiface.cpp delete mode 100644 kdecore/kappdcopiface.h delete mode 100644 kdecore/kapplication.cpp delete mode 100644 kdecore/kapplication.h delete mode 100644 kdecore/kapplication_win.cpp delete mode 100644 kdecore/kasyncio.cpp delete mode 100644 kdecore/kasyncio.h delete mode 100644 kdecore/kaudioplayer.cpp delete mode 100644 kdecore/kaudioplayer.h delete mode 100644 kdecore/kbufferedio.cpp delete mode 100644 kdecore/kbufferedio.h delete mode 100644 kdecore/kcalendarsystem.cpp delete mode 100644 kdecore/kcalendarsystem.h delete mode 100644 kdecore/kcalendarsystemfactory.cpp delete mode 100644 kdecore/kcalendarsystemfactory.h delete mode 100644 kdecore/kcalendarsystemgregorian.cpp delete mode 100644 kdecore/kcalendarsystemgregorian.h delete mode 100644 kdecore/kcalendarsystemhebrew.cpp delete mode 100644 kdecore/kcalendarsystemhebrew.h delete mode 100644 kdecore/kcalendarsystemhijri.cpp delete mode 100644 kdecore/kcalendarsystemhijri.h delete mode 100644 kdecore/kcalendarsystemjalali.cpp delete mode 100644 kdecore/kcalendarsystemjalali.h delete mode 100644 kdecore/kcatalogue.cpp delete mode 100644 kdecore/kcatalogue.h delete mode 100644 kdecore/kcharsets.cpp delete mode 100644 kdecore/kcharsets.h delete mode 100644 kdecore/kcheckaccelerators.cpp delete mode 100644 kdecore/kcheckaccelerators.h delete mode 100644 kdecore/kckey.cpp delete mode 100644 kdecore/kckey.h delete mode 100644 kdecore/kclipboard.cpp delete mode 100644 kdecore/kclipboard.h delete mode 100644 kdecore/kcmdlineargs.cpp delete mode 100644 kdecore/kcmdlineargs.h delete mode 100644 kdecore/kcompletion.cpp delete mode 100644 kdecore/kcompletion.h delete mode 100644 kdecore/kcompletion_private.h delete mode 100644 kdecore/kcompletionbase.cpp delete mode 100644 kdecore/kconfig.cpp delete mode 100644 kdecore/kconfig.h delete mode 100644 kdecore/kconfig_compiler/CMakeLists.txt delete mode 100644 kdecore/kconfig_compiler/Makefile.am delete mode 100644 kdecore/kconfig_compiler/README.dox delete mode 100644 kdecore/kconfig_compiler/TODO delete mode 100755 kdecore/kconfig_compiler/checkkcfg.pl delete mode 100644 kdecore/kconfig_compiler/example/Makefile.am delete mode 100644 kdecore/kconfig_compiler/example/autoexample.cpp delete mode 100644 kdecore/kconfig_compiler/example/example.cpp delete mode 100644 kdecore/kconfig_compiler/example/example.kcfg delete mode 100644 kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc delete mode 100644 kdecore/kconfig_compiler/example/general_base.ui delete mode 100644 kdecore/kconfig_compiler/example/myoptions_base.ui delete mode 100644 kdecore/kconfig_compiler/kcfg.xsd delete mode 100644 kdecore/kconfig_compiler/kconfig_compiler.cpp delete mode 100644 kdecore/kconfig_compiler/tests/Makefile.am delete mode 100644 kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp delete mode 100644 kdecore/kconfig_compiler/tests/kconfigcompiler_test.h delete mode 100644 kdecore/kconfig_compiler/tests/myprefs.h delete mode 100644 kdecore/kconfig_compiler/tests/test1.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test1.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test1.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test1.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test1main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test2.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test2.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test2.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test2.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test2main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test3.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test3.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test3.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test3.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test3main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test4.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test4.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test4.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test4.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test4main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test5.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test5.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test5.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test5.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test5main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test6.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test6.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test6.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test6.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test6main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test7.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test7.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test7.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test7.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test7main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test8a.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test8a.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test8a.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test8a.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test8b.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test8b.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test8b.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test8b.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test8main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test9.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test9.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test9.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test9.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test9main.cpp delete mode 100644 kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref delete mode 100644 kdecore/kconfig_compiler/tests/test_dpointer.h.ref delete mode 100644 kdecore/kconfig_compiler/tests/test_dpointer.kcfg delete mode 100644 kdecore/kconfig_compiler/tests/test_dpointer.kcfgc delete mode 100644 kdecore/kconfig_compiler/tests/test_dpointer_main.cpp delete mode 100644 kdecore/kconfigbackend.cpp delete mode 100644 kdecore/kconfigbackend.h delete mode 100644 kdecore/kconfigbase.cpp delete mode 100644 kdecore/kconfigbase.h delete mode 100644 kdecore/kconfigdata.h delete mode 100644 kdecore/kconfigdialogmanager.cpp delete mode 100644 kdecore/kconfigdialogmanager.h delete mode 100644 kdecore/kconfigskeleton.cpp delete mode 100644 kdecore/kconfigskeleton.h delete mode 100644 kdecore/kcrash.cpp delete mode 100644 kdecore/kcrash.h delete mode 100644 kdecore/kdcoppropertyproxy.cpp delete mode 100644 kdecore/kdcoppropertyproxy.h delete mode 100644 kdecore/kde-config.cpp.cmake delete mode 100644 kdecore/kde-config.cpp.in delete mode 100644 kdecore/kde_dmalloc.h delete mode 100644 kdecore/kde_file.h delete mode 100644 kdecore/kdebug.areas delete mode 100644 kdecore/kdebug.cpp delete mode 100644 kdecore/kdebug.h delete mode 100644 kdecore/kdebugclasses.h delete mode 100644 kdecore/kdebugdcopiface.cpp delete mode 100644 kdecore/kdebugdcopiface.h delete mode 100644 kdecore/kdebugrc delete mode 100644 kdecore/kdelibs_export.h delete mode 100644 kdecore/kdemacros.h.cmake delete mode 100644 kdecore/kdemacros.h.in delete mode 100644 kdecore/kdesktopfile.cpp delete mode 100644 kdecore/kdesktopfile.h delete mode 100644 kdecore/kdetcompmgr.cpp delete mode 100644 kdecore/kdeversion.cpp delete mode 100644 kdecore/kdeversion.h delete mode 100644 kdecore/kentities.c delete mode 100644 kdecore/kentities.gperf delete mode 100644 kdecore/kextendedsocket.h delete mode 100644 kdecore/kextsock.cpp delete mode 100644 kdecore/kextsock.h delete mode 100644 kdecore/kgenericfactory.h delete mode 100644 kdecore/kgenericfactory.tcc delete mode 100644 kdecore/kglobal.cpp delete mode 100644 kdecore/kglobal.h delete mode 100644 kdecore/kglobalaccel.cpp delete mode 100644 kdecore/kglobalaccel.h delete mode 100644 kdecore/kglobalaccel_emb.h delete mode 100644 kdecore/kglobalaccel_mac.h delete mode 100644 kdecore/kglobalaccel_win.cpp delete mode 100644 kdecore/kglobalaccel_win.h delete mode 100644 kdecore/kglobalaccel_x11.cpp delete mode 100644 kdecore/kglobalaccel_x11.h delete mode 100644 kdecore/kglobalsettings.cpp delete mode 100644 kdecore/kglobalsettings.h delete mode 100644 kdecore/kgrantpty.c delete mode 100644 kdecore/kiconeffect.cpp delete mode 100644 kdecore/kiconeffect.h delete mode 100644 kdecore/kiconloader.cpp delete mode 100644 kdecore/kiconloader.h delete mode 100644 kdecore/kiconloader_p.h delete mode 100644 kdecore/kicontheme.cpp delete mode 100644 kdecore/kicontheme.h delete mode 100644 kdecore/kidna.cpp delete mode 100644 kdecore/kidna.h delete mode 100644 kdecore/kinstance.cpp delete mode 100644 kdecore/kinstance.h delete mode 100644 kdecore/kipc.cpp delete mode 100644 kdecore/kipc.h delete mode 100644 kdecore/kkeynative.h delete mode 100644 kdecore/kkeynative_x11.cpp delete mode 100644 kdecore/kkeyserver.h delete mode 100644 kdecore/kkeyserver_x11.cpp delete mode 100644 kdecore/kkeyserver_x11.h delete mode 100644 kdecore/klargefile.h delete mode 100644 kdecore/klibloader.cpp delete mode 100644 kdecore/klibloader.h delete mode 100644 kdecore/klocale.cpp delete mode 100644 kdecore/klocale.h delete mode 100644 kdecore/klockfile.cpp delete mode 100644 kdecore/klockfile.h delete mode 100644 kdecore/kmacroexpander.cpp delete mode 100644 kdecore/kmacroexpander.h delete mode 100644 kdecore/kmanagerselection.cpp delete mode 100644 kdecore/kmanagerselection.h delete mode 100644 kdecore/kmdcodec.cpp delete mode 100644 kdecore/kmdcodec.h delete mode 100644 kdecore/kmdcodec_compat.h delete mode 100644 kdecore/kmimesourcefactory.cpp delete mode 100644 kdecore/kmimesourcefactory.h delete mode 100644 kdecore/kmountpoint.cpp delete mode 100644 kdecore/kmountpoint.h delete mode 100644 kdecore/kmultipledrag.cpp delete mode 100644 kdecore/kmultipledrag.h delete mode 100644 kdecore/knotifyclient.cpp delete mode 100644 kdecore/knotifyclient.h delete mode 100644 kdecore/kpalette.cpp delete mode 100644 kdecore/kpalette.h delete mode 100644 kdecore/kpixmapprovider.cpp delete mode 100644 kdecore/kpixmapprovider.h delete mode 100644 kdecore/kprocctrl.cpp delete mode 100644 kdecore/kprocctrl.h delete mode 100644 kdecore/kprocess.cpp delete mode 100644 kdecore/kprocess.h delete mode 100644 kdecore/kprocio.cpp delete mode 100644 kdecore/kprocio.h delete mode 100644 kdecore/kprotocolinfo_kdecore.cpp delete mode 100644 kdecore/kprotocolinfofactory.cpp delete mode 100644 kdecore/kprotocolinfofactory.h delete mode 100644 kdecore/kpty.cpp delete mode 100644 kdecore/kpty.h delete mode 100644 kdecore/kqiodevicegzip_p.cpp delete mode 100644 kdecore/kqiodevicegzip_p.h delete mode 100644 kdecore/krandomsequence.cpp delete mode 100644 kdecore/krandomsequence.h delete mode 100644 kdecore/kregexp.cpp delete mode 100644 kdecore/kregexp.h delete mode 100644 kdecore/kregpriv.h delete mode 100644 kdecore/krfcdate.cpp delete mode 100644 kdecore/krfcdate.h delete mode 100644 kdecore/krootprop.cpp delete mode 100644 kdecore/krootprop.h delete mode 100644 kdecore/ksavefile.cpp delete mode 100644 kdecore/ksavefile.h delete mode 100644 kdecore/ksharedptr.h delete mode 100644 kdecore/kshell.cpp delete mode 100644 kdecore/kshell.h delete mode 100644 kdecore/kshortcut.cpp delete mode 100644 kdecore/kshortcut.h delete mode 100644 kdecore/kshortcutlist.cpp delete mode 100644 kdecore/kshortcutlist.h delete mode 100644 kdecore/kshortcutmenu.cpp delete mode 100644 kdecore/kshortcutmenu.h delete mode 100644 kdecore/ksimpleconfig.cpp delete mode 100644 kdecore/ksimpleconfig.h delete mode 100644 kdecore/ksock.cpp delete mode 100644 kdecore/ksock.h delete mode 100644 kdecore/ksockaddr.cpp delete mode 100644 kdecore/ksockaddr.h delete mode 100644 kdecore/ksocks.cpp delete mode 100644 kdecore/ksocks.h delete mode 100644 kdecore/ksortablevaluelist.h delete mode 100644 kdecore/kstandarddirs.cpp delete mode 100644 kdecore/kstandarddirs.h delete mode 100644 kdecore/kstartupinfo.cpp delete mode 100644 kdecore/kstartupinfo.h delete mode 100644 kdecore/kstaticdeleter.cpp delete mode 100644 kdecore/kstaticdeleter.h delete mode 100644 kdecore/kstdaccel.cpp delete mode 100644 kdecore/kstdaccel.h delete mode 100644 kdecore/kstddirs.h delete mode 100644 kdecore/kstringhandler.cpp delete mode 100644 kdecore/kstringhandler.h delete mode 100644 kdecore/ksycoca.cpp delete mode 100644 kdecore/ksycoca.h delete mode 100644 kdecore/ksycocadict.cpp delete mode 100644 kdecore/ksycocadict.h delete mode 100644 kdecore/ksycocaentry.h delete mode 100644 kdecore/ksycocafactory.cpp delete mode 100644 kdecore/ksycocafactory.h delete mode 100644 kdecore/ksycocatype.h delete mode 100644 kdecore/ktempdir.cpp delete mode 100644 kdecore/ktempdir.h delete mode 100644 kdecore/ktempfile.cpp delete mode 100644 kdecore/ktempfile.h delete mode 100644 kdecore/ktimezones.cpp delete mode 100644 kdecore/ktimezones.h delete mode 100644 kdecore/ktypelist.h delete mode 100644 kdecore/kuniqueapp.h delete mode 100644 kdecore/kuniqueapplication.cpp delete mode 100644 kdecore/kuniqueapplication.h delete mode 100644 kdecore/kunload.h delete mode 100644 kdecore/kurl.cpp delete mode 100644 kdecore/kurl.h delete mode 100644 kdecore/kurldrag.cpp delete mode 100644 kdecore/kurldrag.h delete mode 100644 kdecore/kuser.cpp delete mode 100644 kdecore/kuser.h delete mode 100644 kdecore/kvmallocator.cpp delete mode 100644 kdecore/kvmallocator.h delete mode 100644 kdecore/kwin.cpp delete mode 100644 kdecore/kwin.h delete mode 100644 kdecore/kwinmodule.cpp delete mode 100644 kdecore/kwinmodule.h delete mode 100644 kdecore/kxerrorhandler.cpp delete mode 100644 kdecore/kxerrorhandler.h delete mode 100644 kdecore/kxmessages.cpp delete mode 100644 kdecore/kxmessages.h delete mode 100644 kdecore/language.codes delete mode 100644 kdecore/libintl.cpp delete mode 100644 kdecore/libkdecore.nmcheck delete mode 100644 kdecore/libkdecore_weak.nmcheck delete mode 100644 kdecore/libqt-mt.nmcheck delete mode 100644 kdecore/libqt-mt_weak.nmcheck delete mode 100644 kdecore/malloc/CMakeLists.txt delete mode 100644 kdecore/malloc/Makefile.am delete mode 100644 kdecore/malloc/README delete mode 100644 kdecore/malloc/configure.in.in delete mode 100644 kdecore/malloc/glibc.h delete mode 100644 kdecore/malloc/malloc.c delete mode 100644 kdecore/malloc/x86.h delete mode 100644 kdecore/netsupp.cpp delete mode 100644 kdecore/netsupp.h delete mode 100644 kdecore/netsupp_win32.cpp delete mode 100644 kdecore/netwm.cpp delete mode 100644 kdecore/netwm.h delete mode 100644 kdecore/netwm_def.h delete mode 100644 kdecore/netwm_p.h delete mode 100644 kdecore/network/CMakeLists.txt delete mode 100644 kdecore/network/Makefile.am delete mode 100644 kdecore/network/ipv6blacklist delete mode 100644 kdecore/network/kbufferedsocket.cpp delete mode 100644 kdecore/network/kbufferedsocket.h delete mode 100644 kdecore/network/kclientsocketbase.cpp delete mode 100644 kdecore/network/kclientsocketbase.h delete mode 100644 kdecore/network/kdatagramsocket.cpp delete mode 100644 kdecore/network/kdatagramsocket.h delete mode 100644 kdecore/network/khttpproxysocketdevice.cpp delete mode 100644 kdecore/network/khttpproxysocketdevice.h delete mode 100644 kdecore/network/kiobuffer.h delete mode 100644 kdecore/network/kmulticastsocket.h delete mode 100644 kdecore/network/kmulticastsocketdevice.h delete mode 100644 kdecore/network/knetworkinterface.h delete mode 100644 kdecore/network/kresolver.cpp delete mode 100644 kdecore/network/kresolver.h delete mode 100644 kdecore/network/kresolver_p.h delete mode 100644 kdecore/network/kresolvermanager.cpp delete mode 100644 kdecore/network/kresolverstandardworkers.cpp delete mode 100644 kdecore/network/kresolverstandardworkers_p.h delete mode 100644 kdecore/network/kresolverworkerbase.cpp delete mode 100644 kdecore/network/kresolverworkerbase.h delete mode 100644 kdecore/network/kreverseresolver.cpp delete mode 100644 kdecore/network/kreverseresolver.h delete mode 100644 kdecore/network/kserversocket.cpp delete mode 100644 kdecore/network/kserversocket.h delete mode 100644 kdecore/network/ksocketaddress.cpp delete mode 100644 kdecore/network/ksocketaddress.h delete mode 100644 kdecore/network/ksocketbase.cpp delete mode 100644 kdecore/network/ksocketbase.h delete mode 100644 kdecore/network/ksocketbuffer.cpp delete mode 100644 kdecore/network/ksocketbuffer_p.h delete mode 100644 kdecore/network/ksocketdevice.cpp delete mode 100644 kdecore/network/ksocketdevice.h delete mode 100644 kdecore/network/ksockssocketdevice.cpp delete mode 100644 kdecore/network/ksockssocketdevice.h delete mode 100644 kdecore/network/ksrvresolverworker.cpp delete mode 100644 kdecore/network/ksrvresolverworker_p.h delete mode 100644 kdecore/network/kstreamsocket.cpp delete mode 100644 kdecore/network/kstreamsocket.h delete mode 100644 kdecore/network/syssocket.h delete mode 100644 kdecore/standard_weak.nmcheck delete mode 100644 kdecore/svgicons/CMakeLists.txt delete mode 100644 kdecore/svgicons/Makefile.am delete mode 100644 kdecore/svgicons/TODO delete mode 100644 kdecore/svgicons/ksvgiconengine.cpp delete mode 100644 kdecore/svgicons/ksvgiconengine.h delete mode 100644 kdecore/svgicons/ksvgiconpainter.cpp delete mode 100644 kdecore/svgicons/ksvgiconpainter.h delete mode 100644 kdecore/tests/KIDLTest.cpp delete mode 100644 kdecore/tests/KIDLTest.h delete mode 100644 kdecore/tests/KIDLTestClient.cpp delete mode 100644 kdecore/tests/Makefile.am delete mode 100644 kdecore/tests/cplusplustest.cpp delete mode 100644 kdecore/tests/dcopkonqtest.cpp delete mode 100644 kdecore/tests/kapptest.cpp delete mode 100644 kdecore/tests/kcalendartest.cpp delete mode 100644 kdecore/tests/kcharsetstest.cpp delete mode 100644 kdecore/tests/kcmdlineargstest.cpp delete mode 100644 kdecore/tests/kconfigtest.cpp delete mode 100644 kdecore/tests/kconfigtestgui.cpp delete mode 100644 kdecore/tests/kconfigtestgui.h delete mode 100644 kdecore/tests/kdebugtest.cpp delete mode 100644 kdecore/tests/kglobaltest.cpp delete mode 100644 kdecore/tests/kiconloadertest.cpp delete mode 100644 kdecore/tests/kipctest.cpp delete mode 100644 kdecore/tests/kipctest.h delete mode 100644 kdecore/tests/klocaletest.cpp delete mode 100644 kdecore/tests/klocaletest.h delete mode 100644 kdecore/tests/kmacroexpandertest.cpp delete mode 100644 kdecore/tests/kmdcodectest.cpp delete mode 100644 kdecore/tests/kmemtest.cpp delete mode 100644 kdecore/tests/knotifytest.cpp delete mode 100644 kdecore/tests/kprocesstest.cpp delete mode 100644 kdecore/tests/kprocesstest.h delete mode 100644 kdecore/tests/kprociotest.cpp delete mode 100644 kdecore/tests/kprociotest.h delete mode 100644 kdecore/tests/krandomsequencetest.cpp delete mode 100644 kdecore/tests/kresolvertest.cpp delete mode 100644 kdecore/tests/krfcdatetest.cpp delete mode 100644 kdecore/tests/kshelltest.cpp delete mode 100644 kdecore/tests/ksimpleconfigtest.cpp delete mode 100644 kdecore/tests/ksocktest.cpp delete mode 100644 kdecore/tests/ksortablevaluelisttest.cpp delete mode 100644 kdecore/tests/kstdacceltest.cpp delete mode 100644 kdecore/tests/kstddirstest.cpp delete mode 100644 kdecore/tests/kstringhandlertest.cpp delete mode 100644 kdecore/tests/ktempfiletest.cpp delete mode 100644 kdecore/tests/ktimezonestest.cpp delete mode 100644 kdecore/tests/kuniqueapptest.cpp delete mode 100644 kdecore/tests/kurltest.cpp delete mode 100644 kdecore/tests/kxerrorhandlertest.cpp delete mode 100644 kdecore/tests/startserviceby.cpp delete mode 100644 kdecore/tests/testqtargs.cpp delete mode 100644 kdecore/vsnprintf.c delete mode 100644 kdefx/CMakeLists.txt delete mode 100644 kdefx/Mainpage.dox delete mode 100644 kdefx/Makefile.am delete mode 100644 kdefx/configure.in.in delete mode 100644 kdefx/kcpuinfo.cpp delete mode 100644 kdefx/kcpuinfo.h delete mode 100644 kdefx/kdrawutil.cpp delete mode 100644 kdefx/kdrawutil.h delete mode 100644 kdefx/kimageeffect.cpp delete mode 100644 kdefx/kimageeffect.h delete mode 100644 kdefx/kpixmap.cpp delete mode 100644 kdefx/kpixmap.h delete mode 100644 kdefx/kpixmapeffect.cpp delete mode 100644 kdefx/kpixmapeffect.h delete mode 100644 kdefx/kpixmapsplitter.cpp delete mode 100644 kdefx/kpixmapsplitter.h delete mode 100644 kdefx/kstyle.cpp delete mode 100644 kdefx/kstyle.h delete mode 100644 kdefx/libkdefx.nmcheck delete mode 100644 kdefx/libkdefx_weak.nmcheck delete mode 100644 kdeprint/CMakeLists.txt delete mode 100644 kdeprint/ChangeLog delete mode 100644 kdeprint/Makefile.am delete mode 100644 kdeprint/TODO delete mode 100644 kdeprint/TODO.cups12 delete mode 100644 kdeprint/configure.in.in delete mode 100644 kdeprint/cups/CMakeLists.txt delete mode 100644 kdeprint/cups/Makefile.am delete mode 100644 kdeprint/cups/configure.in.in delete mode 100644 kdeprint/cups/cups.print delete mode 100644 kdeprint/cups/cupsaddsmb2.cpp delete mode 100644 kdeprint/cups/cupsaddsmb2.h delete mode 100644 kdeprint/cups/cupsdconf2/CMakeLists.txt delete mode 100644 kdeprint/cups/cupsdconf2/Makefile.am delete mode 100644 kdeprint/cups/cupsdconf2/addressdialog.cpp delete mode 100644 kdeprint/cups/cupsdconf2/addressdialog.h delete mode 100644 kdeprint/cups/cupsdconf2/browsedialog.cpp delete mode 100644 kdeprint/cups/cupsdconf2/browsedialog.h delete mode 100644 kdeprint/cups/cupsdconf2/cups-util.c delete mode 100644 kdeprint/cups/cupsdconf2/cups-util.h delete mode 100644 kdeprint/cups/cupsdconf2/cups_logo.png delete mode 100644 kdeprint/cups/cupsdconf2/cupsd.conf.template delete mode 100644 kdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdbrowsingpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdcomment.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdcomment.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdcomment.pl delete mode 100644 kdeprint/cups/cupsdconf2/cupsdconf.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdconf.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsddialog.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsddialog.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsddirpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsddirpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdfilterpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdfilterpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdjobspage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdjobspage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdlogpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdlogpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdnetworkpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdsecuritypage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdserverpage.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdserverpage.h delete mode 100644 kdeprint/cups/cupsdconf2/cupsdsplash.cpp delete mode 100644 kdeprint/cups/cupsdconf2/cupsdsplash.h delete mode 100644 kdeprint/cups/cupsdconf2/editlist.cpp delete mode 100644 kdeprint/cups/cupsdconf2/editlist.h delete mode 100644 kdeprint/cups/cupsdconf2/kde_logo.png delete mode 100644 kdeprint/cups/cupsdconf2/locationdialog.cpp delete mode 100644 kdeprint/cups/cupsdconf2/locationdialog.h delete mode 100644 kdeprint/cups/cupsdconf2/main.cpp delete mode 100644 kdeprint/cups/cupsdconf2/portdialog.cpp delete mode 100644 kdeprint/cups/cupsdconf2/portdialog.h delete mode 100644 kdeprint/cups/cupsdconf2/qdirlineedit.cpp delete mode 100644 kdeprint/cups/cupsdconf2/qdirlineedit.h delete mode 100644 kdeprint/cups/cupsdconf2/qdirmultilineedit.cpp delete mode 100644 kdeprint/cups/cupsdconf2/qdirmultilineedit.h delete mode 100644 kdeprint/cups/cupsdconf2/sizewidget.cpp delete mode 100644 kdeprint/cups/cupsdconf2/sizewidget.h delete mode 100644 kdeprint/cups/cupsdoprint.c delete mode 100644 kdeprint/cups/cupsinfos.cpp delete mode 100644 kdeprint/cups/cupsinfos.h delete mode 100644 kdeprint/cups/image.cpp delete mode 100644 kdeprint/cups/imageposition.cpp delete mode 100644 kdeprint/cups/imageposition.h delete mode 100644 kdeprint/cups/imagepreview.cpp delete mode 100644 kdeprint/cups/imagepreview.h delete mode 100644 kdeprint/cups/ippreportdlg.cpp delete mode 100644 kdeprint/cups/ippreportdlg.h delete mode 100644 kdeprint/cups/ipprequest.cpp delete mode 100644 kdeprint/cups/ipprequest.h delete mode 100644 kdeprint/cups/kcupsprinterimpl.cpp delete mode 100644 kdeprint/cups/kcupsprinterimpl.h delete mode 100644 kdeprint/cups/kmconfigcups.cpp delete mode 100644 kdeprint/cups/kmconfigcups.h delete mode 100644 kdeprint/cups/kmconfigcupsdir.cpp delete mode 100644 kdeprint/cups/kmconfigcupsdir.h delete mode 100644 kdeprint/cups/kmcupsconfigwidget.cpp delete mode 100644 kdeprint/cups/kmcupsconfigwidget.h delete mode 100644 kdeprint/cups/kmcupsfactory.cpp delete mode 100644 kdeprint/cups/kmcupsjobmanager.cpp delete mode 100644 kdeprint/cups/kmcupsjobmanager.h delete mode 100644 kdeprint/cups/kmcupsmanager.cpp delete mode 100644 kdeprint/cups/kmcupsmanager.h delete mode 100644 kdeprint/cups/kmcupsuimanager.cpp delete mode 100644 kdeprint/cups/kmcupsuimanager.h delete mode 100644 kdeprint/cups/kmpropbanners.cpp delete mode 100644 kdeprint/cups/kmpropbanners.h delete mode 100644 kdeprint/cups/kmpropquota.cpp delete mode 100644 kdeprint/cups/kmpropquota.h delete mode 100644 kdeprint/cups/kmpropusers.cpp delete mode 100644 kdeprint/cups/kmpropusers.h delete mode 100644 kdeprint/cups/kmwbanners.cpp delete mode 100644 kdeprint/cups/kmwbanners.h delete mode 100644 kdeprint/cups/kmwfax.cpp delete mode 100644 kdeprint/cups/kmwfax.h delete mode 100644 kdeprint/cups/kmwipp.cpp delete mode 100644 kdeprint/cups/kmwipp.h delete mode 100644 kdeprint/cups/kmwippprinter.cpp delete mode 100644 kdeprint/cups/kmwippprinter.h delete mode 100644 kdeprint/cups/kmwippselect.cpp delete mode 100644 kdeprint/cups/kmwippselect.h delete mode 100644 kdeprint/cups/kmwother.cpp delete mode 100644 kdeprint/cups/kmwother.h delete mode 100644 kdeprint/cups/kmwquota.cpp delete mode 100644 kdeprint/cups/kmwquota.h delete mode 100644 kdeprint/cups/kmwusers.cpp delete mode 100644 kdeprint/cups/kmwusers.h delete mode 100644 kdeprint/cups/kphpgl2page.cpp delete mode 100644 kdeprint/cups/kphpgl2page.h delete mode 100644 kdeprint/cups/kpimagepage.cpp delete mode 100644 kdeprint/cups/kpimagepage.h delete mode 100644 kdeprint/cups/kpschedulepage.cpp delete mode 100644 kdeprint/cups/kpschedulepage.h delete mode 100644 kdeprint/cups/kptagspage.cpp delete mode 100644 kdeprint/cups/kptagspage.h delete mode 100644 kdeprint/cups/kptextpage.cpp delete mode 100644 kdeprint/cups/kptextpage.h delete mode 100644 kdeprint/cups/make_driver_db_cups.c delete mode 100644 kdeprint/cups/postscript.ppd.gz delete mode 100644 kdeprint/cups/preview-mini.png delete mode 100644 kdeprint/cups/preview.png delete mode 100644 kdeprint/driver.cpp delete mode 100644 kdeprint/driver.h delete mode 100644 kdeprint/driveritem.cpp delete mode 100644 kdeprint/driveritem.h delete mode 100644 kdeprint/driverparse.c delete mode 100644 kdeprint/driverparse.h delete mode 100644 kdeprint/driverview.cpp delete mode 100644 kdeprint/driverview.h delete mode 100644 kdeprint/droptionview.cpp delete mode 100644 kdeprint/droptionview.h delete mode 100644 kdeprint/ext/CMakeLists.txt delete mode 100644 kdeprint/ext/Makefile.am delete mode 100644 kdeprint/ext/ext.print delete mode 100644 kdeprint/ext/kextprinterimpl.cpp delete mode 100644 kdeprint/ext/kextprinterimpl.h delete mode 100644 kdeprint/ext/kmextfactory.cpp delete mode 100644 kdeprint/ext/kmextmanager.cpp delete mode 100644 kdeprint/ext/kmextmanager.h delete mode 100644 kdeprint/ext/kmextuimanager.cpp delete mode 100644 kdeprint/ext/kmextuimanager.h delete mode 100644 kdeprint/filters/CMakeLists.txt delete mode 100644 kdeprint/filters/Makefile.am delete mode 100644 kdeprint/filters/enscript.desktop delete mode 100644 kdeprint/filters/enscript.xml delete mode 100755 kdeprint/filters/imagetops delete mode 100644 kdeprint/filters/imagetops.desktop delete mode 100644 kdeprint/filters/imagetops.xml delete mode 100644 kdeprint/filters/pdf2ps.desktop delete mode 100644 kdeprint/filters/pdf2ps.xml delete mode 100644 kdeprint/filters/pdfwrite.desktop delete mode 100644 kdeprint/filters/pdfwrite.xml delete mode 100644 kdeprint/filters/poster.desktop delete mode 100644 kdeprint/filters/poster.xml delete mode 100644 kdeprint/filters/ps2pdf.desktop delete mode 100644 kdeprint/filters/ps2pdf.xml delete mode 100644 kdeprint/filters/psbook.desktop delete mode 100644 kdeprint/filters/psbook.xml delete mode 100644 kdeprint/filters/psbook1.desktop delete mode 100644 kdeprint/filters/psbook1.xml delete mode 100644 kdeprint/filters/psbook2.desktop delete mode 100644 kdeprint/filters/psbook2.xml delete mode 100644 kdeprint/filters/psnup.desktop delete mode 100644 kdeprint/filters/psnup.xml delete mode 100644 kdeprint/filters/psresize.desktop delete mode 100644 kdeprint/filters/psresize.xml delete mode 100644 kdeprint/filters/psselect.desktop delete mode 100644 kdeprint/filters/psselect.xml delete mode 100644 kdeprint/foomatic/Makefile.am delete mode 100644 kdeprint/foomatic/foomatic.print delete mode 100644 kdeprint/foomatic/kfoomaticprinterimpl.cpp delete mode 100644 kdeprint/foomatic/kfoomaticprinterimpl.h delete mode 100644 kdeprint/foomatic/kmfoomaticfactory.cpp delete mode 100644 kdeprint/foomatic/kmfoomaticmanager.cpp delete mode 100644 kdeprint/foomatic/kmfoomaticmanager.h delete mode 100644 kdeprint/foomatic/make_driver_db_foomatic.c delete mode 100644 kdeprint/foomatic2loader.cpp delete mode 100644 kdeprint/foomatic2loader.h delete mode 100644 kdeprint/fooparser.cpp delete mode 100644 kdeprint/fooparser.cpp.h delete mode 100644 kdeprint/fooparser.y delete mode 100644 kdeprint/fooscanner.cpp delete mode 100644 kdeprint/fooscanner.l delete mode 100644 kdeprint/kdeprintcheck.cpp delete mode 100644 kdeprint/kdeprintcheck.h delete mode 100644 kdeprint/kdeprintd.cpp delete mode 100644 kdeprint/kdeprintd.desktop delete mode 100644 kdeprint/kdeprintd.h delete mode 100644 kdeprint/kdeprintrc delete mode 100644 kdeprint/kdeprintrc.upd delete mode 100644 kdeprint/kfilelist.cpp delete mode 100644 kdeprint/kfilelist.h delete mode 100644 kdeprint/kmdbentry.cpp delete mode 100644 kdeprint/kmdbentry.h delete mode 100644 kdeprint/kmfactory.cpp delete mode 100644 kdeprint/kmfactory.h delete mode 100644 kdeprint/kmjob.cpp delete mode 100644 kdeprint/kmjob.h delete mode 100644 kdeprint/kmjobmanager.cpp delete mode 100644 kdeprint/kmjobmanager.h delete mode 100644 kdeprint/kmmanager.cpp delete mode 100644 kdeprint/kmmanager.h delete mode 100644 kdeprint/kmobject.h delete mode 100644 kdeprint/kmprinter.cpp delete mode 100644 kdeprint/kmprinter.h delete mode 100644 kdeprint/kmspecialmanager.cpp delete mode 100644 kdeprint/kmspecialmanager.h delete mode 100644 kdeprint/kmthreadjob.cpp delete mode 100644 kdeprint/kmthreadjob.h delete mode 100644 kdeprint/kmuimanager.cpp delete mode 100644 kdeprint/kmuimanager.h delete mode 100644 kdeprint/kmvirtualmanager.cpp delete mode 100644 kdeprint/kmvirtualmanager.h delete mode 100644 kdeprint/kpcopiespage.cpp delete mode 100644 kdeprint/kpcopiespage.h delete mode 100644 kdeprint/kpdriverpage.cpp delete mode 100644 kdeprint/kpdriverpage.h delete mode 100644 kdeprint/kpfileselectpage.cpp delete mode 100644 kdeprint/kpfileselectpage.h delete mode 100644 kdeprint/kpfilterpage.cpp delete mode 100644 kdeprint/kpfilterpage.h delete mode 100644 kdeprint/kpgeneralpage.cpp delete mode 100644 kdeprint/kpgeneralpage.h delete mode 100644 kdeprint/kpipeprocess.cpp delete mode 100644 kdeprint/kpipeprocess.h delete mode 100644 kdeprint/kpmarginpage.cpp delete mode 100644 kdeprint/kpmarginpage.h delete mode 100644 kdeprint/kpposterpage.cpp delete mode 100644 kdeprint/kpposterpage.h delete mode 100644 kdeprint/kpqtpage.cpp delete mode 100644 kdeprint/kpqtpage.h delete mode 100644 kdeprint/kpreloadobject.cpp delete mode 100644 kdeprint/kpreloadobject.h delete mode 100644 kdeprint/kprintaction.cpp delete mode 100644 kdeprint/kprintaction.h delete mode 100644 kdeprint/kprintdialog.cpp delete mode 100644 kdeprint/kprintdialog.h delete mode 100644 kdeprint/kprintdialogpage.cpp delete mode 100644 kdeprint/kprintdialogpage.h delete mode 100644 kdeprint/kprinter.cpp delete mode 100644 kdeprint/kprinter.h delete mode 100644 kdeprint/kprinterimpl.cpp delete mode 100644 kdeprint/kprinterimpl.h delete mode 100644 kdeprint/kprinterpropertydialog.cpp delete mode 100644 kdeprint/kprinterpropertydialog.h delete mode 100644 kdeprint/kprintpreview.cpp delete mode 100644 kdeprint/kprintpreview.h delete mode 100644 kdeprint/kprintpreviewui.rc delete mode 100644 kdeprint/kprintprocess.cpp delete mode 100644 kdeprint/kprintprocess.h delete mode 100644 kdeprint/kxmlcommand.cpp delete mode 100644 kdeprint/kxmlcommand.h delete mode 100644 kdeprint/lpd/Makefile.am delete mode 100644 kdeprint/lpd/gschecker.cpp delete mode 100644 kdeprint/lpd/gschecker.h delete mode 100644 kdeprint/lpd/klpdprinterimpl.cpp delete mode 100644 kdeprint/lpd/klpdprinterimpl.h delete mode 100644 kdeprint/lpd/kmlpdfactory.cpp delete mode 100644 kdeprint/lpd/kmlpdfactory.h delete mode 100644 kdeprint/lpd/kmlpdmanager.cpp delete mode 100644 kdeprint/lpd/kmlpdmanager.h delete mode 100644 kdeprint/lpd/kmlpduimanager.cpp delete mode 100644 kdeprint/lpd/kmlpduimanager.h delete mode 100644 kdeprint/lpd/lpd.print delete mode 100644 kdeprint/lpd/lpdtools.cpp delete mode 100644 kdeprint/lpd/lpdtools.h delete mode 100644 kdeprint/lpd/make_driver_db_lpd.c delete mode 100644 kdeprint/lpdunix/CMakeLists.txt delete mode 100644 kdeprint/lpdunix/Makefile.am delete mode 100644 kdeprint/lpdunix/klpdunixprinterimpl.cpp delete mode 100644 kdeprint/lpdunix/klpdunixprinterimpl.h delete mode 100644 kdeprint/lpdunix/kmlpdunixfactory.cpp delete mode 100644 kdeprint/lpdunix/kmlpdunixmanager.cpp delete mode 100644 kdeprint/lpdunix/kmlpdunixmanager.h delete mode 100644 kdeprint/lpdunix/kmlpdunixuimanager.cpp delete mode 100644 kdeprint/lpdunix/kmlpdunixuimanager.h delete mode 100644 kdeprint/lpdunix/lpdunix.print delete mode 100644 kdeprint/lpr/CMakeLists.txt delete mode 100644 kdeprint/lpr/Makefile.am delete mode 100644 kdeprint/lpr/apsdriver1 delete mode 100644 kdeprint/lpr/apsdriver2 delete mode 100644 kdeprint/lpr/apshandler.cpp delete mode 100644 kdeprint/lpr/apshandler.h delete mode 100644 kdeprint/lpr/editentrydialog.cpp delete mode 100644 kdeprint/lpr/editentrydialog.h delete mode 100644 kdeprint/lpr/klprfactory.cpp delete mode 100644 kdeprint/lpr/klprprinterimpl.cpp delete mode 100644 kdeprint/lpr/klprprinterimpl.h delete mode 100644 kdeprint/lpr/kmconfiglpr.cpp delete mode 100644 kdeprint/lpr/kmconfiglpr.h delete mode 100644 kdeprint/lpr/kmlprjobmanager.cpp delete mode 100644 kdeprint/lpr/kmlprjobmanager.h delete mode 100644 kdeprint/lpr/kmlprmanager.cpp delete mode 100644 kdeprint/lpr/kmlprmanager.h delete mode 100644 kdeprint/lpr/kmlpruimanager.cpp delete mode 100644 kdeprint/lpr/kmlpruimanager.h delete mode 100644 kdeprint/lpr/lpchelper.cpp delete mode 100644 kdeprint/lpr/lpchelper.h delete mode 100644 kdeprint/lpr/lpqhelper.cpp delete mode 100644 kdeprint/lpr/lpqhelper.h delete mode 100644 kdeprint/lpr/lpr.print delete mode 100644 kdeprint/lpr/lprhandler.cpp delete mode 100644 kdeprint/lpr/lprhandler.h delete mode 100644 kdeprint/lpr/lprngtooldriver1 delete mode 100644 kdeprint/lpr/lprngtoolhandler.cpp delete mode 100644 kdeprint/lpr/lprngtoolhandler.h delete mode 100644 kdeprint/lpr/lprsettings.cpp delete mode 100644 kdeprint/lpr/lprsettings.h delete mode 100644 kdeprint/lpr/make_driver_db_lpr.c delete mode 100644 kdeprint/lpr/matichandler.cpp delete mode 100644 kdeprint/lpr/matichandler.h delete mode 100644 kdeprint/lpr/matichelper.cpp delete mode 100644 kdeprint/lpr/matichelper.h delete mode 100644 kdeprint/lpr/printcapentry.cpp delete mode 100644 kdeprint/lpr/printcapentry.h delete mode 100644 kdeprint/lpr/printcapreader.cpp delete mode 100644 kdeprint/lpr/printcapreader.h delete mode 100644 kdeprint/management/CMakeLists.txt delete mode 100644 kdeprint/management/Makefile.am delete mode 100644 kdeprint/management/cjanuswidget.cpp delete mode 100644 kdeprint/management/cjanuswidget.h delete mode 100644 kdeprint/management/jobitem.cpp delete mode 100644 kdeprint/management/jobitem.h delete mode 100644 kdeprint/management/kaddprinterwizard.cpp delete mode 100644 kdeprint/management/kdeprint_management_module.cpp delete mode 100644 kdeprint/management/kiconselectaction.cpp delete mode 100644 kdeprint/management/kiconselectaction.h delete mode 100644 kdeprint/management/kmconfigcommand.cpp delete mode 100644 kdeprint/management/kmconfigcommand.h delete mode 100644 kdeprint/management/kmconfigdialog.cpp delete mode 100644 kdeprint/management/kmconfigdialog.h delete mode 100644 kdeprint/management/kmconfigfilter.cpp delete mode 100644 kdeprint/management/kmconfigfilter.h delete mode 100644 kdeprint/management/kmconfigfonts.cpp delete mode 100644 kdeprint/management/kmconfigfonts.h delete mode 100644 kdeprint/management/kmconfiggeneral.cpp delete mode 100644 kdeprint/management/kmconfiggeneral.h delete mode 100644 kdeprint/management/kmconfigjobs.cpp delete mode 100644 kdeprint/management/kmconfigjobs.h delete mode 100644 kdeprint/management/kmconfigpage.cpp delete mode 100644 kdeprint/management/kmconfigpage.h delete mode 100644 kdeprint/management/kmconfigpreview.cpp delete mode 100644 kdeprint/management/kmconfigpreview.h delete mode 100644 kdeprint/management/kmdbcreator.cpp delete mode 100644 kdeprint/management/kmdbcreator.h delete mode 100644 kdeprint/management/kmdriverdb.cpp delete mode 100644 kdeprint/management/kmdriverdb.h delete mode 100644 kdeprint/management/kmdriverdbwidget.cpp delete mode 100644 kdeprint/management/kmdriverdbwidget.h delete mode 100644 kdeprint/management/kmdriverdialog.cpp delete mode 100644 kdeprint/management/kmdriverdialog.h delete mode 100644 kdeprint/management/kmiconview.cpp delete mode 100644 kdeprint/management/kmiconview.h delete mode 100644 kdeprint/management/kminfopage.cpp delete mode 100644 kdeprint/management/kminfopage.h delete mode 100644 kdeprint/management/kminstancepage.cpp delete mode 100644 kdeprint/management/kminstancepage.h delete mode 100644 kdeprint/management/kmjobviewer.cpp delete mode 100644 kdeprint/management/kmjobviewer.h delete mode 100644 kdeprint/management/kmlistview.cpp delete mode 100644 kdeprint/management/kmlistview.h delete mode 100644 kdeprint/management/kmmainview.cpp delete mode 100644 kdeprint/management/kmmainview.h delete mode 100644 kdeprint/management/kmpages.cpp delete mode 100644 kdeprint/management/kmpages.h delete mode 100644 kdeprint/management/kmprinterpage.h delete mode 100644 kdeprint/management/kmprinterview.cpp delete mode 100644 kdeprint/management/kmprinterview.h delete mode 100644 kdeprint/management/kmpropbackend.cpp delete mode 100644 kdeprint/management/kmpropbackend.h delete mode 100644 kdeprint/management/kmpropcontainer.cpp delete mode 100644 kdeprint/management/kmpropcontainer.h delete mode 100644 kdeprint/management/kmpropdriver.cpp delete mode 100644 kdeprint/management/kmpropdriver.h delete mode 100644 kdeprint/management/kmpropertypage.cpp delete mode 100644 kdeprint/management/kmpropertypage.h delete mode 100644 kdeprint/management/kmpropgeneral.cpp delete mode 100644 kdeprint/management/kmpropgeneral.h delete mode 100644 kdeprint/management/kmpropmembers.cpp delete mode 100644 kdeprint/management/kmpropmembers.h delete mode 100644 kdeprint/management/kmpropwidget.cpp delete mode 100644 kdeprint/management/kmpropwidget.h delete mode 100644 kdeprint/management/kmspecialprinterdlg.cpp delete mode 100644 kdeprint/management/kmspecialprinterdlg.h delete mode 100644 kdeprint/management/kmtimer.cpp delete mode 100644 kdeprint/management/kmtimer.h delete mode 100644 kdeprint/management/kmwbackend.cpp delete mode 100644 kdeprint/management/kmwbackend.h delete mode 100644 kdeprint/management/kmwclass.cpp delete mode 100644 kdeprint/management/kmwclass.h delete mode 100644 kdeprint/management/kmwdriver.cpp delete mode 100644 kdeprint/management/kmwdriver.h delete mode 100644 kdeprint/management/kmwdriverselect.cpp delete mode 100644 kdeprint/management/kmwdriverselect.h delete mode 100644 kdeprint/management/kmwdrivertest.cpp delete mode 100644 kdeprint/management/kmwdrivertest.h delete mode 100644 kdeprint/management/kmwend.cpp delete mode 100644 kdeprint/management/kmwend.h delete mode 100644 kdeprint/management/kmwfile.cpp delete mode 100644 kdeprint/management/kmwfile.h delete mode 100644 kdeprint/management/kmwinfobase.cpp delete mode 100644 kdeprint/management/kmwinfobase.h delete mode 100644 kdeprint/management/kmwinfopage.cpp delete mode 100644 kdeprint/management/kmwinfopage.h delete mode 100644 kdeprint/management/kmwizard.cpp delete mode 100644 kdeprint/management/kmwizard.h delete mode 100644 kdeprint/management/kmwizardpage.cpp delete mode 100644 kdeprint/management/kmwizardpage.h delete mode 100644 kdeprint/management/kmwlocal.cpp delete mode 100644 kdeprint/management/kmwlocal.h delete mode 100644 kdeprint/management/kmwlpd.cpp delete mode 100644 kdeprint/management/kmwlpd.h delete mode 100644 kdeprint/management/kmwname.cpp delete mode 100644 kdeprint/management/kmwname.h delete mode 100644 kdeprint/management/kmwpassword.cpp delete mode 100644 kdeprint/management/kmwpassword.h delete mode 100644 kdeprint/management/kmwsmb.cpp delete mode 100644 kdeprint/management/kmwsmb.h delete mode 100644 kdeprint/management/kmwsocket.cpp delete mode 100644 kdeprint/management/kmwsocket.h delete mode 100644 kdeprint/management/kmwsocketutil.cpp delete mode 100644 kdeprint/management/kmwsocketutil.h delete mode 100644 kdeprint/management/kxmlcommanddlg.cpp delete mode 100644 kdeprint/management/kxmlcommanddlg.h delete mode 100644 kdeprint/management/kxmlcommandselector.cpp delete mode 100644 kdeprint/management/kxmlcommandselector.h delete mode 100644 kdeprint/management/networkscanner.cpp delete mode 100644 kdeprint/management/networkscanner.h delete mode 100644 kdeprint/management/pluginaction.cpp delete mode 100644 kdeprint/management/pluginaction.h delete mode 100644 kdeprint/management/side.png delete mode 100644 kdeprint/management/sidepixmap.cpp delete mode 100644 kdeprint/management/sidepixmap.h delete mode 100644 kdeprint/management/smbview.cpp delete mode 100644 kdeprint/management/smbview.h delete mode 100644 kdeprint/management/tiledown.png delete mode 100644 kdeprint/management/tileup.png delete mode 100644 kdeprint/marginpreview.cpp delete mode 100644 kdeprint/marginpreview.h delete mode 100644 kdeprint/marginvaluewidget.cpp delete mode 100644 kdeprint/marginvaluewidget.h delete mode 100644 kdeprint/marginwidget.cpp delete mode 100644 kdeprint/marginwidget.h delete mode 100644 kdeprint/messagewindow.cpp delete mode 100644 kdeprint/messagewindow.h delete mode 100644 kdeprint/pics/CMakeLists.txt delete mode 100644 kdeprint/pics/Makefile.am delete mode 100644 kdeprint/pics/cr16-action-filterstop.png delete mode 100644 kdeprint/pics/cr16-action-kdeprint_restartsrv.png delete mode 100644 kdeprint/pics/cr16-action-kdeprint_uploadsmb.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_computer.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_job.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_job_cancelled.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_job_completed.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_job_error.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_job_process.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_job_stopped.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_class.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_class_process.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_class_stopped.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_defect.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_process.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_remote.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_remote_process.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_remote_stopped.png delete mode 100644 kdeprint/pics/cr16-app-kdeprint_printer_stopped.png delete mode 100644 kdeprint/pics/cr22-action-history.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_addprinter.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_addpseudo.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_configmgr.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_configsrv.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_defaulthard.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_defaultsoft.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_enableprinter.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_printer.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_printer_infos.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_printstate.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_queuestate.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_report.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_restartsrv.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_stopprinter.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_testprinter.png delete mode 100644 kdeprint/pics/cr22-action-kdeprint_uploadsmb.png delete mode 100644 kdeprint/pics/cr22-action-package_utilities.png delete mode 100644 kdeprint/pics/cr22-app-kdeprint_printer.png delete mode 100644 kdeprint/pics/cr32-action-kdeprint_inklevel.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_class.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_class_process.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_class_stopped.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_defect.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_process.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_remote.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_remote_process.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_remote_stopped.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_stopped.png delete mode 100644 kdeprint/pics/cr32-app-kdeprint_printer_users.png delete mode 100644 kdeprint/pics/cr48-app-kdeprint_printer.png delete mode 100644 kdeprint/pics/cr48-app-kdeprint_printer_class.png delete mode 100644 kdeprint/pics/cr64-app-kdeprint_printer.png delete mode 100644 kdeprint/pics/cr64-app-kdeprint_printer_class.png delete mode 100644 kdeprint/pics/kdeprint_collate.png delete mode 100644 kdeprint/pics/kdeprint_collate_reverse.png delete mode 100644 kdeprint/pics/kdeprint_color.png delete mode 100644 kdeprint/pics/kdeprint_dupl_none.png delete mode 100644 kdeprint/pics/kdeprint_duplex_long.png delete mode 100644 kdeprint/pics/kdeprint_duplex_none.png delete mode 100644 kdeprint/pics/kdeprint_duplex_short.png delete mode 100644 kdeprint/pics/kdeprint_grayscale.png delete mode 100644 kdeprint/pics/kdeprint_landscape.png delete mode 100644 kdeprint/pics/kdeprint_nup1.png delete mode 100644 kdeprint/pics/kdeprint_nup2.png delete mode 100644 kdeprint/pics/kdeprint_nup4.png delete mode 100644 kdeprint/pics/kdeprint_nupother.png delete mode 100644 kdeprint/pics/kdeprint_opt_duplex.png delete mode 100644 kdeprint/pics/kdeprint_pagesize.png delete mode 100644 kdeprint/pics/kdeprint_portrait.png delete mode 100644 kdeprint/pics/kdeprint_prettyprint.png delete mode 100644 kdeprint/pics/kdeprint_revlandscape.png delete mode 100644 kdeprint/pics/kdeprint_revportrait.png delete mode 100644 kdeprint/pics/kdeprint_uncollate.png delete mode 100644 kdeprint/pics/kdeprint_uncollate_reverse.png delete mode 100644 kdeprint/pics/processsign.png delete mode 100644 kdeprint/pics/stopsign.png delete mode 100644 kdeprint/plugincombobox.cpp delete mode 100644 kdeprint/plugincombobox.h delete mode 100644 kdeprint/posterpreview.cpp delete mode 100644 kdeprint/posterpreview.h delete mode 100644 kdeprint/ppdloader.cpp delete mode 100644 kdeprint/ppdloader.h delete mode 100644 kdeprint/ppdparser.cpp delete mode 100644 kdeprint/ppdparser.cpp.h delete mode 100644 kdeprint/ppdparser.y delete mode 100644 kdeprint/ppdscanner.cpp delete mode 100644 kdeprint/ppdscanner.l delete mode 100644 kdeprint/printerfilter.cpp delete mode 100644 kdeprint/printerfilter.h delete mode 100644 kdeprint/rlpr/CMakeLists.txt delete mode 100644 kdeprint/rlpr/Makefile.am delete mode 100644 kdeprint/rlpr/kmconfigproxy.cpp delete mode 100644 kdeprint/rlpr/kmconfigproxy.h delete mode 100644 kdeprint/rlpr/kmproprlpr.cpp delete mode 100644 kdeprint/rlpr/kmproprlpr.h delete mode 100644 kdeprint/rlpr/kmproxywidget.cpp delete mode 100644 kdeprint/rlpr/kmproxywidget.h delete mode 100644 kdeprint/rlpr/kmrlprfactory.cpp delete mode 100644 kdeprint/rlpr/kmrlprmanager.cpp delete mode 100644 kdeprint/rlpr/kmrlprmanager.h delete mode 100644 kdeprint/rlpr/kmrlpruimanager.cpp delete mode 100644 kdeprint/rlpr/kmrlpruimanager.h delete mode 100644 kdeprint/rlpr/kmwrlpr.cpp delete mode 100644 kdeprint/rlpr/kmwrlpr.h delete mode 100644 kdeprint/rlpr/krlprprinterimpl.cpp delete mode 100644 kdeprint/rlpr/krlprprinterimpl.h delete mode 100644 kdeprint/rlpr/rlpr.print delete mode 100644 kdeprint/signal_proc.c delete mode 100644 kdeprint/specials.desktop delete mode 100644 kdeprint/testprint.ps delete mode 100644 kdeprint/tests/Makefile.am delete mode 100644 kdeprint/tests/back.xpm delete mode 100644 kdeprint/tests/drawdemo.cpp delete mode 100644 kdeprint/tests/drawdemo.h delete mode 100644 kdeprint/tests/forward.xpm delete mode 100644 kdeprint/tests/helpwindow.cpp delete mode 100644 kdeprint/tests/helpwindow.h delete mode 100644 kdeprint/tests/home.xpm delete mode 100644 kdeprint/tests/main.cpp delete mode 100644 kdeprint/tests/richpage.cpp delete mode 100644 kdeprint/tests/richpage.h delete mode 100644 kdeprint/tools/CMakeLists.txt delete mode 100644 kdeprint/tools/Makefile.am delete mode 100644 kdeprint/tools/escputil/CMakeLists.txt delete mode 100644 kdeprint/tools/escputil/Makefile.am delete mode 100644 kdeprint/tools/escputil/escputil.desktop delete mode 100644 kdeprint/tools/escputil/escpwidget.cpp delete mode 100644 kdeprint/tools/escputil/escpwidget.h delete mode 100644 kdeprint/treecombobox.cpp delete mode 100644 kdeprint/treecombobox.h delete mode 100644 kdeprint/util.cpp delete mode 100644 kdeprint/util.h delete mode 100644 kdesu/CMakeLists.txt delete mode 100644 kdesu/Mainpage.dox delete mode 100644 kdesu/Makefile.am delete mode 100644 kdesu/README delete mode 100644 kdesu/client.cpp delete mode 100644 kdesu/client.h delete mode 100644 kdesu/configure.in.in delete mode 100644 kdesu/defaults.h delete mode 100644 kdesu/kcookie.cpp delete mode 100644 kdesu/kcookie.h delete mode 100644 kdesu/kdesu_pty.cpp delete mode 100644 kdesu/kdesu_pty.h delete mode 100644 kdesu/kdesu_stub.c delete mode 100644 kdesu/libkdesu.nmcheck delete mode 100644 kdesu/libkdesu_weak.nmcheck delete mode 100644 kdesu/process.cpp delete mode 100644 kdesu/process.h delete mode 100644 kdesu/ssh.cpp delete mode 100644 kdesu/ssh.h delete mode 100644 kdesu/stub.cpp delete mode 100644 kdesu/stub.h delete mode 100644 kdesu/su.cpp delete mode 100644 kdesu/su.h delete mode 100644 kdeui/AUTHORS delete mode 100644 kdeui/CMakeLists.txt delete mode 100644 kdeui/MAINTAINERS delete mode 100644 kdeui/Mainpage.dox delete mode 100644 kdeui/Makefile.am delete mode 100644 kdeui/README.kspell delete mode 100644 kdeui/TODO.kspell delete mode 100644 kdeui/TODO.xmlgui delete mode 100644 kdeui/about/CMakeLists.txt delete mode 100644 kdeui/about/Makefile.am delete mode 100644 kdeui/about/bar-bottom-left.png delete mode 100644 kdeui/about/bar-bottom-middle.png delete mode 100644 kdeui/about/bar-bottom-right.png delete mode 100644 kdeui/about/bar-middle-left.png delete mode 100644 kdeui/about/bar-middle-right.png delete mode 100644 kdeui/about/bar-top-left.png delete mode 100644 kdeui/about/bar-top-middle.png delete mode 100644 kdeui/about/bar-top-right.png delete mode 100644 kdeui/about/bottom-left.png delete mode 100644 kdeui/about/bottom-middle.png delete mode 100644 kdeui/about/bottom-right.png delete mode 100644 kdeui/about/box-bottom-left.png delete mode 100644 kdeui/about/box-bottom-middle.png delete mode 100644 kdeui/about/box-bottom-right.png delete mode 100644 kdeui/about/box-middle-left.png delete mode 100644 kdeui/about/box-middle-right.png delete mode 100644 kdeui/about/box-top-left.png delete mode 100644 kdeui/about/box-top-middle.png delete mode 100644 kdeui/about/box-top-right.png delete mode 100644 kdeui/about/kde_infopage.css delete mode 100644 kdeui/about/kde_infopage_rtl.css delete mode 100644 kdeui/about/top-left.png delete mode 100644 kdeui/about/top-middle.png delete mode 100644 kdeui/about/usage-example.html delete mode 100644 kdeui/aboutkde.png delete mode 100644 kdeui/colors/Makefile.am delete mode 100644 kdeui/colors/README delete mode 100644 kdeui/colors/rgb.txt delete mode 100644 kdeui/dcolorarrow.xbm delete mode 100644 kdeui/dcolorreset.xpm delete mode 100644 kdeui/kaboutapplication.cpp delete mode 100644 kdeui/kaboutapplication.h delete mode 100644 kdeui/kaboutdialog.cpp delete mode 100644 kdeui/kaboutdialog.h delete mode 100644 kdeui/kaboutdialog_private.h delete mode 100644 kdeui/kaboutkde.cpp delete mode 100644 kdeui/kaboutkde.h delete mode 100644 kdeui/kaccelgen.h delete mode 100644 kdeui/kaction.cpp delete mode 100644 kdeui/kaction.h delete mode 100644 kdeui/kactionclasses.cpp delete mode 100644 kdeui/kactionclasses.h delete mode 100644 kdeui/kactioncollection.cpp delete mode 100644 kdeui/kactioncollection.h delete mode 100644 kdeui/kactionselector.cpp delete mode 100644 kdeui/kactionselector.h delete mode 100644 kdeui/kactionshortcutlist.h delete mode 100644 kdeui/kactivelabel.cpp delete mode 100644 kdeui/kactivelabel.h delete mode 100644 kdeui/kanimwidget.cpp delete mode 100644 kdeui/kanimwidget.h delete mode 100644 kdeui/karrowbutton.cpp delete mode 100644 kdeui/karrowbutton.h delete mode 100644 kdeui/kauthicon.cpp delete mode 100644 kdeui/kauthicon.h delete mode 100644 kdeui/kbugreport.cpp delete mode 100644 kdeui/kbugreport.h delete mode 100644 kdeui/kbuttonbox.cpp delete mode 100644 kdeui/kbuttonbox.h delete mode 100644 kdeui/kcharselect.cpp delete mode 100644 kdeui/kcharselect.h delete mode 100644 kdeui/kcmenumngr.cpp delete mode 100644 kdeui/kcmenumngr.h delete mode 100644 kdeui/kcmodule.cpp delete mode 100644 kdeui/kcmodule.h delete mode 100644 kdeui/kcolorbtn.h delete mode 100644 kdeui/kcolorbutton.cpp delete mode 100644 kdeui/kcolorbutton.h delete mode 100644 kdeui/kcolorcombo.cpp delete mode 100644 kdeui/kcolorcombo.h delete mode 100644 kdeui/kcolordialog.cpp delete mode 100644 kdeui/kcolordialog.h delete mode 100644 kdeui/kcolordlg.h delete mode 100644 kdeui/kcolordrag.cpp delete mode 100644 kdeui/kcolordrag.h delete mode 100644 kdeui/kcombobox.cpp delete mode 100644 kdeui/kcombobox.h delete mode 100644 kdeui/kcommand.cpp delete mode 100644 kdeui/kcommand.h delete mode 100644 kdeui/kcompletionbox.cpp delete mode 100644 kdeui/kcompletionbox.h delete mode 100644 kdeui/kconfigdialog.cpp delete mode 100644 kdeui/kconfigdialog.h delete mode 100644 kdeui/kcursor.cpp delete mode 100644 kdeui/kcursor.h delete mode 100644 kdeui/kcursor_private.h delete mode 100644 kdeui/kdatepicker.cpp delete mode 100644 kdeui/kdatepicker.h delete mode 100644 kdeui/kdatepik.h delete mode 100644 kdeui/kdatetbl.cpp delete mode 100644 kdeui/kdatetbl.h delete mode 100644 kdeui/kdatetimewidget.cpp delete mode 100644 kdeui/kdatetimewidget.h delete mode 100644 kdeui/kdatewidget.cpp delete mode 100644 kdeui/kdatewidget.h delete mode 100644 kdeui/kdcopactionproxy.cpp delete mode 100644 kdeui/kdcopactionproxy.h delete mode 100644 kdeui/kdepackages.h delete mode 100644 kdeui/kdetrayproxy/CMakeLists.txt delete mode 100644 kdeui/kdetrayproxy/Makefile.am delete mode 100644 kdeui/kdetrayproxy/kdetrayproxy.cpp delete mode 100644 kdeui/kdetrayproxy/kdetrayproxy.desktop delete mode 100644 kdeui/kdetrayproxy/kdetrayproxy.h delete mode 100644 kdeui/kdetrayproxy/module.cpp delete mode 100644 kdeui/kdetrayproxy/module.h delete mode 100644 kdeui/kdialog.cpp delete mode 100644 kdeui/kdialog.h delete mode 100644 kdeui/kdialogbase.cpp delete mode 100644 kdeui/kdialogbase.h delete mode 100644 kdeui/kdialogbase_priv.h delete mode 100644 kdeui/kdockwidget.cpp delete mode 100644 kdeui/kdockwidget.h delete mode 100644 kdeui/kdockwidget_p.h delete mode 100644 kdeui/kdockwidget_private.cpp delete mode 100644 kdeui/kdockwidget_private.h delete mode 100644 kdeui/kdockwindow.h delete mode 100644 kdeui/kdualcolorbtn.h delete mode 100644 kdeui/kdualcolorbutton.cpp delete mode 100644 kdeui/kdualcolorbutton.h delete mode 100644 kdeui/keditcl.h delete mode 100644 kdeui/keditcl1.cpp delete mode 100644 kdeui/keditcl2.cpp delete mode 100644 kdeui/keditlistbox.cpp delete mode 100644 kdeui/keditlistbox.h delete mode 100644 kdeui/kedittoolbar.cpp delete mode 100644 kdeui/kedittoolbar.h delete mode 100644 kdeui/kfontcombo.cpp delete mode 100644 kdeui/kfontcombo.h delete mode 100644 kdeui/kfontdialog.cpp delete mode 100644 kdeui/kfontdialog.h delete mode 100644 kdeui/kfontrequester.cpp delete mode 100644 kdeui/kfontrequester.h delete mode 100644 kdeui/kguiitem.cpp delete mode 100644 kdeui/kguiitem.h delete mode 100644 kdeui/khelpmenu.cpp delete mode 100644 kdeui/khelpmenu.h delete mode 100644 kdeui/kiconview.cpp delete mode 100644 kdeui/kiconview.h delete mode 100644 kdeui/kiconviewsearchline.cpp delete mode 100644 kdeui/kiconviewsearchline.h delete mode 100644 kdeui/kinputdialog.cpp delete mode 100644 kdeui/kinputdialog.h delete mode 100644 kdeui/kjanuswidget.cpp delete mode 100644 kdeui/kjanuswidget.h delete mode 100644 kdeui/kkeybutton.cpp delete mode 100644 kdeui/kkeybutton.h delete mode 100644 kdeui/kkeydialog.cpp delete mode 100644 kdeui/kkeydialog.h delete mode 100644 kdeui/klanguagebutton.cpp delete mode 100644 kdeui/klanguagebutton.h delete mode 100644 kdeui/kled.cpp delete mode 100644 kdeui/kled.h delete mode 100644 kdeui/klineedit.cpp delete mode 100644 kdeui/klineedit.h delete mode 100644 kdeui/klineeditdlg.cpp delete mode 100644 kdeui/klineeditdlg.h delete mode 100644 kdeui/klistbox.cpp delete mode 100644 kdeui/klistbox.h delete mode 100644 kdeui/klistview.cpp delete mode 100644 kdeui/klistview.h delete mode 100644 kdeui/klistviewlineedit.h delete mode 100644 kdeui/klistviewsearchline.cpp delete mode 100644 kdeui/klistviewsearchline.h delete mode 100644 kdeui/kmainwindow.cpp delete mode 100644 kdeui/kmainwindow.h delete mode 100644 kdeui/kmainwindowiface.cpp delete mode 100644 kdeui/kmainwindowiface.h delete mode 100644 kdeui/kmenubar.cpp delete mode 100644 kdeui/kmenubar.h delete mode 100644 kdeui/kmessagebox.cpp delete mode 100644 kdeui/kmessagebox.h delete mode 100644 kdeui/knuminput.cpp delete mode 100644 kdeui/knuminput.h delete mode 100644 kdeui/knumvalidator.cpp delete mode 100644 kdeui/knumvalidator.h delete mode 100644 kdeui/kpanelapplet.cpp delete mode 100644 kdeui/kpanelapplet.h delete mode 100644 kdeui/kpanelappmenu.cpp delete mode 100644 kdeui/kpanelappmenu.h delete mode 100644 kdeui/kpanelextension.cpp delete mode 100644 kdeui/kpanelextension.h delete mode 100644 kdeui/kpanelmenu.cpp delete mode 100644 kdeui/kpanelmenu.h delete mode 100644 kdeui/kpartgui.dtd delete mode 100644 kdeui/kpassdlg.cpp delete mode 100644 kdeui/kpassdlg.h delete mode 100644 kdeui/kpassivepopup.cpp delete mode 100644 kdeui/kpassivepopup.h delete mode 100644 kdeui/kpixmapio-perf.png delete mode 100644 kdeui/kpixmapio.cpp delete mode 100644 kdeui/kpixmapio.h delete mode 100644 kdeui/kpixmapregionselectordialog.cpp delete mode 100644 kdeui/kpixmapregionselectordialog.h delete mode 100644 kdeui/kpixmapregionselectorwidget.cpp delete mode 100644 kdeui/kpixmapregionselectorwidget.h delete mode 100644 kdeui/kpopupmenu.cpp delete mode 100644 kdeui/kpopupmenu.h delete mode 100644 kdeui/kprogress.cpp delete mode 100644 kdeui/kprogress.h delete mode 100644 kdeui/kprogressbox.cpp delete mode 100644 kdeui/kprogressbox.h delete mode 100644 kdeui/kpushbutton.cpp delete mode 100644 kdeui/kpushbutton.h delete mode 100644 kdeui/krestrictedline.cpp delete mode 100644 kdeui/krestrictedline.h delete mode 100644 kdeui/krootpixmap.cpp delete mode 100644 kdeui/krootpixmap.h delete mode 100644 kdeui/kruler.cpp delete mode 100644 kdeui/kruler.h delete mode 100644 kdeui/ksconfig.cpp delete mode 100644 kdeui/ksconfig.h delete mode 100644 kdeui/kscrollview.cpp delete mode 100644 kdeui/kscrollview.h delete mode 100644 kdeui/kselect.cpp delete mode 100644 kdeui/kselect.h delete mode 100644 kdeui/kseparator.cpp delete mode 100644 kdeui/kseparator.h delete mode 100644 kdeui/ksharedpixmap.cpp delete mode 100644 kdeui/ksharedpixmap.h delete mode 100644 kdeui/kshortcutdialog.cpp delete mode 100644 kdeui/kshortcutdialog.h delete mode 100644 kdeui/kshortcutdialog_advanced.ui delete mode 100644 kdeui/kshortcutdialog_simple.ui delete mode 100644 kdeui/kspell.cpp delete mode 100644 kdeui/kspell.h delete mode 100644 kdeui/kspelldlg.cpp delete mode 100644 kdeui/kspelldlg.h delete mode 100644 kdeui/kspellui.ui delete mode 100644 kdeui/ksplashscreen.cpp delete mode 100644 kdeui/ksplashscreen.h delete mode 100644 kdeui/ksqueezedtextlabel.cpp delete mode 100644 kdeui/ksqueezedtextlabel.h delete mode 100644 kdeui/kstatusbar.cpp delete mode 100644 kdeui/kstatusbar.h delete mode 100644 kdeui/kstdaction.cpp delete mode 100644 kdeui/kstdaction.h delete mode 100644 kdeui/kstdaction_p.h delete mode 100644 kdeui/kstdguiitem.cpp delete mode 100644 kdeui/kstdguiitem.h delete mode 100644 kdeui/kstringvalidator.cpp delete mode 100644 kdeui/kstringvalidator.h delete mode 100644 kdeui/kswitchlanguagedialog.cpp delete mode 100644 kdeui/kswitchlanguagedialog.h delete mode 100644 kdeui/ksyntaxhighlighter.cpp delete mode 100644 kdeui/ksyntaxhighlighter.h delete mode 100644 kdeui/ksystemtray.cpp delete mode 100644 kdeui/ksystemtray.h delete mode 100644 kdeui/ktabbar.cpp delete mode 100644 kdeui/ktabbar.h delete mode 100644 kdeui/ktabctl.cpp delete mode 100644 kdeui/ktabctl.h delete mode 100644 kdeui/ktabwidget.cpp delete mode 100644 kdeui/ktabwidget.h delete mode 100644 kdeui/ktextbrowser.cpp delete mode 100644 kdeui/ktextbrowser.h delete mode 100644 kdeui/ktextedit.cpp delete mode 100644 kdeui/ktextedit.h delete mode 100644 kdeui/ktimewidget.cpp delete mode 100644 kdeui/ktimewidget.h delete mode 100644 kdeui/ktimezonewidget.cpp delete mode 100644 kdeui/ktimezonewidget.h delete mode 100644 kdeui/ktip-background.png delete mode 100644 kdeui/ktip-bulb.png delete mode 100644 kdeui/ktip.cpp delete mode 100644 kdeui/ktip.h delete mode 100644 kdeui/ktoolbar.cpp delete mode 100644 kdeui/ktoolbar.h delete mode 100644 kdeui/ktoolbarbutton.cpp delete mode 100644 kdeui/ktoolbarbutton.h delete mode 100644 kdeui/ktoolbarhandler.cpp delete mode 100644 kdeui/ktoolbarhandler.h delete mode 100644 kdeui/ktoolbarlabelaction.cpp delete mode 100644 kdeui/ktoolbarlabelaction.h delete mode 100644 kdeui/ktoolbarradiogroup.cpp delete mode 100644 kdeui/ktoolbarradiogroup.h delete mode 100644 kdeui/kurllabel.cpp delete mode 100644 kdeui/kurllabel.h delete mode 100644 kdeui/kwhatsthismanager.cpp delete mode 100644 kdeui/kwhatsthismanager_p.h delete mode 100644 kdeui/kwindowinfo.cpp delete mode 100644 kdeui/kwindowinfo.h delete mode 100644 kdeui/kwindowlistmenu.cpp delete mode 100644 kdeui/kwindowlistmenu.h delete mode 100644 kdeui/kwizard.cpp delete mode 100644 kdeui/kwizard.h delete mode 100644 kdeui/kwordwrap.cpp delete mode 100644 kdeui/kwordwrap.h delete mode 100644 kdeui/kxmlgui.h delete mode 100644 kdeui/kxmlgui.xsd delete mode 100644 kdeui/kxmlguibuilder.cpp delete mode 100644 kdeui/kxmlguibuilder.h delete mode 100644 kdeui/kxmlguiclient.cpp delete mode 100644 kdeui/kxmlguiclient.h delete mode 100644 kdeui/kxmlguifactory.cpp delete mode 100644 kdeui/kxmlguifactory.h delete mode 100644 kdeui/kxmlguifactory_p.cpp delete mode 100644 kdeui/kxmlguifactory_p.h delete mode 100644 kdeui/libkdeui.nmcheck delete mode 100644 kdeui/libkdeui_weak.nmcheck delete mode 100755 kdeui/preparetips delete mode 100644 kdeui/qxembed.cpp delete mode 100644 kdeui/qxembed.h delete mode 100644 kdeui/tests/CMakeLists.txt delete mode 100644 kdeui/tests/Makefile.am delete mode 100644 kdeui/tests/RayTracedGear.png delete mode 100644 kdeui/tests/background_1.png delete mode 100644 kdeui/tests/go.png delete mode 100644 kdeui/tests/itemcontainertest.cpp delete mode 100644 kdeui/tests/itemcontainertest.h delete mode 100644 kdeui/tests/kaboutdialogtest.cpp delete mode 100644 kdeui/tests/kaccelgentest.cpp delete mode 100644 kdeui/tests/kactiontest.cpp delete mode 100644 kdeui/tests/kalphaicontest.h delete mode 100644 kdeui/tests/kblendtest.cpp delete mode 100644 kdeui/tests/kblendtest.h delete mode 100644 kdeui/tests/kbuttonboxtest.cpp delete mode 100644 kdeui/tests/kcharselecttest.cpp delete mode 100644 kdeui/tests/kcolordlgtest.cpp delete mode 100644 kdeui/tests/kcolortest.cpp delete mode 100644 kdeui/tests/kcolortest.h delete mode 100644 kdeui/tests/kcomboboxtest.cpp delete mode 100644 kdeui/tests/kcomboboxtest.h delete mode 100644 kdeui/tests/kcompletiontest.cpp delete mode 100644 kdeui/tests/kcompletiontest.h delete mode 100644 kdeui/tests/kdatepicktest.cpp delete mode 100644 kdeui/tests/kdatetimewidgettest.cpp delete mode 100644 kdeui/tests/kdatewidgettest.cpp delete mode 100644 kdeui/tests/kdesattest.cpp delete mode 100644 kdeui/tests/kdesattest.h delete mode 100644 kdeui/tests/kdialogbasetest.cpp delete mode 100644 kdeui/tests/kdocktest.cpp delete mode 100644 kdeui/tests/kdocktest.h delete mode 100644 kdeui/tests/kdockwidgetdemo.cpp delete mode 100644 kdeui/tests/kdockwidgetdemo.h delete mode 100644 kdeui/tests/kdockwidgettest.cpp delete mode 100644 kdeui/tests/kdockwidgettest.h delete mode 100644 kdeui/tests/kdualcolortest.cpp delete mode 100644 kdeui/tests/kdualcolortest.h delete mode 100644 kdeui/tests/keditlistboxtest.cpp delete mode 100644 kdeui/tests/kedittest.cpp delete mode 100644 kdeui/tests/kfontdialogtest.cpp delete mode 100644 kdeui/tests/kgradienttest.cpp delete mode 100644 kdeui/tests/kgradienttest.h delete mode 100644 kdeui/tests/khashtest.cpp delete mode 100644 kdeui/tests/khashtest.h delete mode 100644 kdeui/tests/kinputdialogtest.cpp delete mode 100644 kdeui/tests/kjanuswidgettest.cpp delete mode 100644 kdeui/tests/kledtest.cpp delete mode 100644 kdeui/tests/kledtest.h delete mode 100644 kdeui/tests/klineeditdlgtest.cpp delete mode 100644 kdeui/tests/klineedittest.cpp delete mode 100644 kdeui/tests/klineedittest.h delete mode 100644 kdeui/tests/klistviewtest.cpp delete mode 100644 kdeui/tests/kmainwindowrestoretest.cpp delete mode 100644 kdeui/tests/kmainwindowrestoretest.h delete mode 100644 kdeui/tests/kmainwindowtest.cpp delete mode 100644 kdeui/tests/kmainwindowtest.h delete mode 100644 kdeui/tests/kmessageboxtest.cpp delete mode 100644 kdeui/tests/knuminputtest.cpp delete mode 100644 kdeui/tests/knuminputtest.h delete mode 100644 kdeui/tests/kpalettetest.cpp delete mode 100644 kdeui/tests/kpanelmenutest.cpp delete mode 100644 kdeui/tests/kpanelmenutest.h delete mode 100644 kdeui/tests/kpixmapregionselectordialogtest.cpp delete mode 100644 kdeui/tests/kpopuptest.cpp delete mode 100644 kdeui/tests/kprogresstest.cpp delete mode 100644 kdeui/tests/krulertest.cpp delete mode 100644 kdeui/tests/krulertest.h delete mode 100644 kdeui/tests/kseparatortest.cpp delete mode 100644 kdeui/tests/kspelltest.cpp delete mode 100644 kdeui/tests/ksqueezedtextlabeltest.cpp delete mode 100644 kdeui/tests/kstatusbartest.cpp delete mode 100644 kdeui/tests/kstatusbartest.h delete mode 100644 kdeui/tests/ksystemtraytest.cpp delete mode 100644 kdeui/tests/ktabctltest.cpp delete mode 100644 kdeui/tests/ktabctltest.h delete mode 100644 kdeui/tests/ktabwidgettest.cpp delete mode 100644 kdeui/tests/ktabwidgettest.h delete mode 100644 kdeui/tests/ktextedittest.cpp delete mode 100644 kdeui/tests/ktimewidgettest.cpp delete mode 100644 kdeui/tests/ktoolbarlabelactiontest.cpp delete mode 100644 kdeui/tests/ktoolbarlabelactiontestui.rc delete mode 100644 kdeui/tests/kunbalancedgrdtest.cpp delete mode 100644 kdeui/tests/kunbalancedgrdtest.h delete mode 100644 kdeui/tests/kwindowtest.cpp delete mode 100644 kdeui/tests/kwindowtest.h delete mode 100644 kdeui/tests/kwizardtest.cpp delete mode 100644 kdeui/tests/kwordwraptest.cpp delete mode 100644 kdeui/tests/kxmlguitest.cpp delete mode 100644 kdeui/tests/kxmlguitest.h delete mode 100644 kdeui/tests/kxmlguitest_part.rc delete mode 100644 kdeui/tests/kxmlguitest_shell.rc delete mode 100644 kdeui/tests/qxembedtest.cpp delete mode 100644 kdeui/tests/testimage.png delete mode 100644 kdeui/ui_standards.rc delete mode 100644 kinit/start_kdeinit.c delete mode 100644 kinit/start_kdeinit_wrapper.c create mode 100644 kinit/start_tdeinit.c create mode 100644 kinit/start_tdeinit_wrapper.c delete mode 100644 kio/misc/kdesasl/CMakeLists.txt delete mode 100644 kio/misc/kdesasl/Makefile.am delete mode 100644 kio/misc/kdesasl/kdesasl.cpp delete mode 100644 kio/misc/kdesasl/kdesasl.h create mode 100644 kio/misc/tdesasl/CMakeLists.txt create mode 100644 kio/misc/tdesasl/Makefile.am create mode 100644 kio/misc/tdesasl/tdesasl.cpp create mode 100644 kio/misc/tdesasl/tdesasl.h create mode 100644 tdecore/40.colors create mode 100644 tdecore/AUTHORS create mode 100644 tdecore/CMakeLists.txt create mode 100644 tdecore/DESIGN.COLOR create mode 100644 tdecore/DESIGN.iconloading create mode 100644 tdecore/DESIGN.kconfig create mode 100644 tdecore/KCONFIG_DESIGN create mode 100644 tdecore/MAINTAINERS create mode 100644 tdecore/Mainpage.dox create mode 100644 tdecore/Makefile.am create mode 100644 tdecore/README create mode 100644 tdecore/README.exec create mode 100644 tdecore/README.kiosk create mode 100644 tdecore/README.kstartupinfo create mode 100644 tdecore/README.user_profiles create mode 100644 tdecore/Rainbow.colors create mode 100644 tdecore/Royal.colors create mode 100644 tdecore/Web.colors create mode 100644 tdecore/all_languages.desktop create mode 100644 tdecore/configure.in.in create mode 100644 tdecore/eventsrc create mode 100644 tdecore/fakes.c create mode 100644 tdecore/fixx11h.h create mode 100755 tdecore/generate_keys.sh create mode 100644 tdecore/kaboutdata.cpp create mode 100644 tdecore/kaboutdata.h create mode 100644 tdecore/kaccel.cpp create mode 100644 tdecore/kaccel.h create mode 100644 tdecore/kaccelaction.cpp create mode 100644 tdecore/kaccelaction.h create mode 100644 tdecore/kaccelbase.cpp create mode 100644 tdecore/kaccelbase.h create mode 100644 tdecore/kaccelmanager.cpp create mode 100644 tdecore/kaccelmanager.h create mode 100644 tdecore/kaccelmanager_private.h create mode 100644 tdecore/kaccelprivate.h create mode 100644 tdecore/kallocator.cpp create mode 100644 tdecore/kallocator.h create mode 100644 tdecore/kapp.h create mode 100644 tdecore/kappdcopiface.cpp create mode 100644 tdecore/kappdcopiface.h create mode 100644 tdecore/kapplication.cpp create mode 100644 tdecore/kapplication.h create mode 100644 tdecore/kapplication_win.cpp create mode 100644 tdecore/kasyncio.cpp create mode 100644 tdecore/kasyncio.h create mode 100644 tdecore/kaudioplayer.cpp create mode 100644 tdecore/kaudioplayer.h create mode 100644 tdecore/kbufferedio.cpp create mode 100644 tdecore/kbufferedio.h create mode 100644 tdecore/kcalendarsystem.cpp create mode 100644 tdecore/kcalendarsystem.h create mode 100644 tdecore/kcalendarsystemfactory.cpp create mode 100644 tdecore/kcalendarsystemfactory.h create mode 100644 tdecore/kcalendarsystemgregorian.cpp create mode 100644 tdecore/kcalendarsystemgregorian.h create mode 100644 tdecore/kcalendarsystemhebrew.cpp create mode 100644 tdecore/kcalendarsystemhebrew.h create mode 100644 tdecore/kcalendarsystemhijri.cpp create mode 100644 tdecore/kcalendarsystemhijri.h create mode 100644 tdecore/kcalendarsystemjalali.cpp create mode 100644 tdecore/kcalendarsystemjalali.h create mode 100644 tdecore/kcatalogue.cpp create mode 100644 tdecore/kcatalogue.h create mode 100644 tdecore/kcharsets.cpp create mode 100644 tdecore/kcharsets.h create mode 100644 tdecore/kcheckaccelerators.cpp create mode 100644 tdecore/kcheckaccelerators.h create mode 100644 tdecore/kckey.cpp create mode 100644 tdecore/kckey.h create mode 100644 tdecore/kclipboard.cpp create mode 100644 tdecore/kclipboard.h create mode 100644 tdecore/kcmdlineargs.cpp create mode 100644 tdecore/kcmdlineargs.h create mode 100644 tdecore/kcompletion.cpp create mode 100644 tdecore/kcompletion.h create mode 100644 tdecore/kcompletion_private.h create mode 100644 tdecore/kcompletionbase.cpp create mode 100644 tdecore/kconfig.cpp create mode 100644 tdecore/kconfig.h create mode 100644 tdecore/kconfig_compiler/CMakeLists.txt create mode 100644 tdecore/kconfig_compiler/Makefile.am create mode 100644 tdecore/kconfig_compiler/README.dox create mode 100644 tdecore/kconfig_compiler/TODO create mode 100755 tdecore/kconfig_compiler/checkkcfg.pl create mode 100644 tdecore/kconfig_compiler/example/Makefile.am create mode 100644 tdecore/kconfig_compiler/example/autoexample.cpp create mode 100644 tdecore/kconfig_compiler/example/example.cpp create mode 100644 tdecore/kconfig_compiler/example/example.kcfg create mode 100644 tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc create mode 100644 tdecore/kconfig_compiler/example/general_base.ui create mode 100644 tdecore/kconfig_compiler/example/myoptions_base.ui create mode 100644 tdecore/kconfig_compiler/kcfg.xsd create mode 100644 tdecore/kconfig_compiler/kconfig_compiler.cpp create mode 100644 tdecore/kconfig_compiler/tests/Makefile.am create mode 100644 tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp create mode 100644 tdecore/kconfig_compiler/tests/kconfigcompiler_test.h create mode 100644 tdecore/kconfig_compiler/tests/myprefs.h create mode 100644 tdecore/kconfig_compiler/tests/test1.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test1.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test1.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test1.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test1main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test2.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test2.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test2.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test2.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test2main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test3.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test3.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test3.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test3.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test3main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test4.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test4.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test4.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test4.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test4main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test5.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test5.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test5.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test5.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test5main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test6.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test6.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test6.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test6.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test6main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test7.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test7.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test7.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test7.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test7main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test8a.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test8a.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test8a.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test8a.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test8b.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test8b.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test8b.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test8b.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test8main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test9.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test9.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test9.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test9.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test9main.cpp create mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref create mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.h.ref create mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.kcfg create mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.kcfgc create mode 100644 tdecore/kconfig_compiler/tests/test_dpointer_main.cpp create mode 100644 tdecore/kconfigbackend.cpp create mode 100644 tdecore/kconfigbackend.h create mode 100644 tdecore/kconfigbase.cpp create mode 100644 tdecore/kconfigbase.h create mode 100644 tdecore/kconfigdata.h create mode 100644 tdecore/kconfigdialogmanager.cpp create mode 100644 tdecore/kconfigdialogmanager.h create mode 100644 tdecore/kconfigskeleton.cpp create mode 100644 tdecore/kconfigskeleton.h create mode 100644 tdecore/kcrash.cpp create mode 100644 tdecore/kcrash.h create mode 100644 tdecore/kdcoppropertyproxy.cpp create mode 100644 tdecore/kdcoppropertyproxy.h create mode 100644 tdecore/kde-config.cpp.cmake create mode 100644 tdecore/kde-config.cpp.in create mode 100644 tdecore/kde_dmalloc.h create mode 100644 tdecore/kde_file.h create mode 100644 tdecore/kdebug.areas create mode 100644 tdecore/kdebug.cpp create mode 100644 tdecore/kdebug.h create mode 100644 tdecore/kdebugclasses.h create mode 100644 tdecore/kdebugdcopiface.cpp create mode 100644 tdecore/kdebugdcopiface.h create mode 100644 tdecore/kdebugrc create mode 100644 tdecore/kdelibs_export.h create mode 100644 tdecore/kdemacros.h.cmake create mode 100644 tdecore/kdemacros.h.in create mode 100644 tdecore/kdesktopfile.cpp create mode 100644 tdecore/kdesktopfile.h create mode 100644 tdecore/kdetcompmgr.cpp create mode 100644 tdecore/kdeversion.cpp create mode 100644 tdecore/kdeversion.h create mode 100644 tdecore/kentities.c create mode 100644 tdecore/kentities.gperf create mode 100644 tdecore/kextendedsocket.h create mode 100644 tdecore/kextsock.cpp create mode 100644 tdecore/kextsock.h create mode 100644 tdecore/kgenericfactory.h create mode 100644 tdecore/kgenericfactory.tcc create mode 100644 tdecore/kglobal.cpp create mode 100644 tdecore/kglobal.h create mode 100644 tdecore/kglobalaccel.cpp create mode 100644 tdecore/kglobalaccel.h create mode 100644 tdecore/kglobalaccel_emb.h create mode 100644 tdecore/kglobalaccel_mac.h create mode 100644 tdecore/kglobalaccel_win.cpp create mode 100644 tdecore/kglobalaccel_win.h create mode 100644 tdecore/kglobalaccel_x11.cpp create mode 100644 tdecore/kglobalaccel_x11.h create mode 100644 tdecore/kglobalsettings.cpp create mode 100644 tdecore/kglobalsettings.h create mode 100644 tdecore/kgrantpty.c create mode 100644 tdecore/kiconeffect.cpp create mode 100644 tdecore/kiconeffect.h create mode 100644 tdecore/kiconloader.cpp create mode 100644 tdecore/kiconloader.h create mode 100644 tdecore/kiconloader_p.h create mode 100644 tdecore/kicontheme.cpp create mode 100644 tdecore/kicontheme.h create mode 100644 tdecore/kidna.cpp create mode 100644 tdecore/kidna.h create mode 100644 tdecore/kinstance.cpp create mode 100644 tdecore/kinstance.h create mode 100644 tdecore/kipc.cpp create mode 100644 tdecore/kipc.h create mode 100644 tdecore/kkeynative.h create mode 100644 tdecore/kkeynative_x11.cpp create mode 100644 tdecore/kkeyserver.h create mode 100644 tdecore/kkeyserver_x11.cpp create mode 100644 tdecore/kkeyserver_x11.h create mode 100644 tdecore/klargefile.h create mode 100644 tdecore/klibloader.cpp create mode 100644 tdecore/klibloader.h create mode 100644 tdecore/klocale.cpp create mode 100644 tdecore/klocale.h create mode 100644 tdecore/klockfile.cpp create mode 100644 tdecore/klockfile.h create mode 100644 tdecore/kmacroexpander.cpp create mode 100644 tdecore/kmacroexpander.h create mode 100644 tdecore/kmanagerselection.cpp create mode 100644 tdecore/kmanagerselection.h create mode 100644 tdecore/kmdcodec.cpp create mode 100644 tdecore/kmdcodec.h create mode 100644 tdecore/kmdcodec_compat.h create mode 100644 tdecore/kmimesourcefactory.cpp create mode 100644 tdecore/kmimesourcefactory.h create mode 100644 tdecore/kmountpoint.cpp create mode 100644 tdecore/kmountpoint.h create mode 100644 tdecore/kmultipledrag.cpp create mode 100644 tdecore/kmultipledrag.h create mode 100644 tdecore/knotifyclient.cpp create mode 100644 tdecore/knotifyclient.h create mode 100644 tdecore/kpalette.cpp create mode 100644 tdecore/kpalette.h create mode 100644 tdecore/kpixmapprovider.cpp create mode 100644 tdecore/kpixmapprovider.h create mode 100644 tdecore/kprocctrl.cpp create mode 100644 tdecore/kprocctrl.h create mode 100644 tdecore/kprocess.cpp create mode 100644 tdecore/kprocess.h create mode 100644 tdecore/kprocio.cpp create mode 100644 tdecore/kprocio.h create mode 100644 tdecore/kprotocolinfo_tdecore.cpp create mode 100644 tdecore/kprotocolinfofactory.cpp create mode 100644 tdecore/kprotocolinfofactory.h create mode 100644 tdecore/kpty.cpp create mode 100644 tdecore/kpty.h create mode 100644 tdecore/kqiodevicegzip_p.cpp create mode 100644 tdecore/kqiodevicegzip_p.h create mode 100644 tdecore/krandomsequence.cpp create mode 100644 tdecore/krandomsequence.h create mode 100644 tdecore/kregexp.cpp create mode 100644 tdecore/kregexp.h create mode 100644 tdecore/kregpriv.h create mode 100644 tdecore/krfcdate.cpp create mode 100644 tdecore/krfcdate.h create mode 100644 tdecore/krootprop.cpp create mode 100644 tdecore/krootprop.h create mode 100644 tdecore/ksavefile.cpp create mode 100644 tdecore/ksavefile.h create mode 100644 tdecore/ksharedptr.h create mode 100644 tdecore/kshell.cpp create mode 100644 tdecore/kshell.h create mode 100644 tdecore/kshortcut.cpp create mode 100644 tdecore/kshortcut.h create mode 100644 tdecore/kshortcutlist.cpp create mode 100644 tdecore/kshortcutlist.h create mode 100644 tdecore/kshortcutmenu.cpp create mode 100644 tdecore/kshortcutmenu.h create mode 100644 tdecore/ksimpleconfig.cpp create mode 100644 tdecore/ksimpleconfig.h create mode 100644 tdecore/ksock.cpp create mode 100644 tdecore/ksock.h create mode 100644 tdecore/ksockaddr.cpp create mode 100644 tdecore/ksockaddr.h create mode 100644 tdecore/ksocks.cpp create mode 100644 tdecore/ksocks.h create mode 100644 tdecore/ksortablevaluelist.h create mode 100644 tdecore/kstandarddirs.cpp create mode 100644 tdecore/kstandarddirs.h create mode 100644 tdecore/kstartupinfo.cpp create mode 100644 tdecore/kstartupinfo.h create mode 100644 tdecore/kstaticdeleter.cpp create mode 100644 tdecore/kstaticdeleter.h create mode 100644 tdecore/kstdaccel.cpp create mode 100644 tdecore/kstdaccel.h create mode 100644 tdecore/kstddirs.h create mode 100644 tdecore/kstringhandler.cpp create mode 100644 tdecore/kstringhandler.h create mode 100644 tdecore/ksycoca.cpp create mode 100644 tdecore/ksycoca.h create mode 100644 tdecore/ksycocadict.cpp create mode 100644 tdecore/ksycocadict.h create mode 100644 tdecore/ksycocaentry.h create mode 100644 tdecore/ksycocafactory.cpp create mode 100644 tdecore/ksycocafactory.h create mode 100644 tdecore/ksycocatype.h create mode 100644 tdecore/ktempdir.cpp create mode 100644 tdecore/ktempdir.h create mode 100644 tdecore/ktempfile.cpp create mode 100644 tdecore/ktempfile.h create mode 100644 tdecore/ktimezones.cpp create mode 100644 tdecore/ktimezones.h create mode 100644 tdecore/ktypelist.h create mode 100644 tdecore/kuniqueapp.h create mode 100644 tdecore/kuniqueapplication.cpp create mode 100644 tdecore/kuniqueapplication.h create mode 100644 tdecore/kunload.h create mode 100644 tdecore/kurl.cpp create mode 100644 tdecore/kurl.h create mode 100644 tdecore/kurldrag.cpp create mode 100644 tdecore/kurldrag.h create mode 100644 tdecore/kuser.cpp create mode 100644 tdecore/kuser.h create mode 100644 tdecore/kvmallocator.cpp create mode 100644 tdecore/kvmallocator.h create mode 100644 tdecore/kwin.cpp create mode 100644 tdecore/kwin.h create mode 100644 tdecore/kwinmodule.cpp create mode 100644 tdecore/kwinmodule.h create mode 100644 tdecore/kxerrorhandler.cpp create mode 100644 tdecore/kxerrorhandler.h create mode 100644 tdecore/kxmessages.cpp create mode 100644 tdecore/kxmessages.h create mode 100644 tdecore/language.codes create mode 100644 tdecore/libintl.cpp create mode 100644 tdecore/libqt-mt.nmcheck create mode 100644 tdecore/libqt-mt_weak.nmcheck create mode 100644 tdecore/libtdecore.nmcheck create mode 100644 tdecore/libtdecore_weak.nmcheck create mode 100644 tdecore/malloc/CMakeLists.txt create mode 100644 tdecore/malloc/Makefile.am create mode 100644 tdecore/malloc/README create mode 100644 tdecore/malloc/configure.in.in create mode 100644 tdecore/malloc/glibc.h create mode 100644 tdecore/malloc/malloc.c create mode 100644 tdecore/malloc/x86.h create mode 100644 tdecore/netsupp.cpp create mode 100644 tdecore/netsupp.h create mode 100644 tdecore/netsupp_win32.cpp create mode 100644 tdecore/netwm.cpp create mode 100644 tdecore/netwm.h create mode 100644 tdecore/netwm_def.h create mode 100644 tdecore/netwm_p.h create mode 100644 tdecore/network/CMakeLists.txt create mode 100644 tdecore/network/Makefile.am create mode 100644 tdecore/network/ipv6blacklist create mode 100644 tdecore/network/kbufferedsocket.cpp create mode 100644 tdecore/network/kbufferedsocket.h create mode 100644 tdecore/network/kclientsocketbase.cpp create mode 100644 tdecore/network/kclientsocketbase.h create mode 100644 tdecore/network/kdatagramsocket.cpp create mode 100644 tdecore/network/kdatagramsocket.h create mode 100644 tdecore/network/khttpproxysocketdevice.cpp create mode 100644 tdecore/network/khttpproxysocketdevice.h create mode 100644 tdecore/network/kiobuffer.h create mode 100644 tdecore/network/kmulticastsocket.h create mode 100644 tdecore/network/kmulticastsocketdevice.h create mode 100644 tdecore/network/knetworkinterface.h create mode 100644 tdecore/network/kresolver.cpp create mode 100644 tdecore/network/kresolver.h create mode 100644 tdecore/network/kresolver_p.h create mode 100644 tdecore/network/kresolvermanager.cpp create mode 100644 tdecore/network/kresolverstandardworkers.cpp create mode 100644 tdecore/network/kresolverstandardworkers_p.h create mode 100644 tdecore/network/kresolverworkerbase.cpp create mode 100644 tdecore/network/kresolverworkerbase.h create mode 100644 tdecore/network/kreverseresolver.cpp create mode 100644 tdecore/network/kreverseresolver.h create mode 100644 tdecore/network/kserversocket.cpp create mode 100644 tdecore/network/kserversocket.h create mode 100644 tdecore/network/ksocketaddress.cpp create mode 100644 tdecore/network/ksocketaddress.h create mode 100644 tdecore/network/ksocketbase.cpp create mode 100644 tdecore/network/ksocketbase.h create mode 100644 tdecore/network/ksocketbuffer.cpp create mode 100644 tdecore/network/ksocketbuffer_p.h create mode 100644 tdecore/network/ksocketdevice.cpp create mode 100644 tdecore/network/ksocketdevice.h create mode 100644 tdecore/network/ksockssocketdevice.cpp create mode 100644 tdecore/network/ksockssocketdevice.h create mode 100644 tdecore/network/ksrvresolverworker.cpp create mode 100644 tdecore/network/ksrvresolverworker_p.h create mode 100644 tdecore/network/kstreamsocket.cpp create mode 100644 tdecore/network/kstreamsocket.h create mode 100644 tdecore/network/syssocket.h create mode 100644 tdecore/standard_weak.nmcheck create mode 100644 tdecore/svgicons/CMakeLists.txt create mode 100644 tdecore/svgicons/Makefile.am create mode 100644 tdecore/svgicons/TODO create mode 100644 tdecore/svgicons/ksvgiconengine.cpp create mode 100644 tdecore/svgicons/ksvgiconengine.h create mode 100644 tdecore/svgicons/ksvgiconpainter.cpp create mode 100644 tdecore/svgicons/ksvgiconpainter.h create mode 100644 tdecore/tests/KIDLTest.cpp create mode 100644 tdecore/tests/KIDLTest.h create mode 100644 tdecore/tests/KIDLTestClient.cpp create mode 100644 tdecore/tests/Makefile.am create mode 100644 tdecore/tests/cplusplustest.cpp create mode 100644 tdecore/tests/dcopkonqtest.cpp create mode 100644 tdecore/tests/kapptest.cpp create mode 100644 tdecore/tests/kcalendartest.cpp create mode 100644 tdecore/tests/kcharsetstest.cpp create mode 100644 tdecore/tests/kcmdlineargstest.cpp create mode 100644 tdecore/tests/kconfigtest.cpp create mode 100644 tdecore/tests/kconfigtestgui.cpp create mode 100644 tdecore/tests/kconfigtestgui.h create mode 100644 tdecore/tests/kdebugtest.cpp create mode 100644 tdecore/tests/kglobaltest.cpp create mode 100644 tdecore/tests/kiconloadertest.cpp create mode 100644 tdecore/tests/kipctest.cpp create mode 100644 tdecore/tests/kipctest.h create mode 100644 tdecore/tests/klocaletest.cpp create mode 100644 tdecore/tests/klocaletest.h create mode 100644 tdecore/tests/kmacroexpandertest.cpp create mode 100644 tdecore/tests/kmdcodectest.cpp create mode 100644 tdecore/tests/kmemtest.cpp create mode 100644 tdecore/tests/knotifytest.cpp create mode 100644 tdecore/tests/kprocesstest.cpp create mode 100644 tdecore/tests/kprocesstest.h create mode 100644 tdecore/tests/kprociotest.cpp create mode 100644 tdecore/tests/kprociotest.h create mode 100644 tdecore/tests/krandomsequencetest.cpp create mode 100644 tdecore/tests/kresolvertest.cpp create mode 100644 tdecore/tests/krfcdatetest.cpp create mode 100644 tdecore/tests/kshelltest.cpp create mode 100644 tdecore/tests/ksimpleconfigtest.cpp create mode 100644 tdecore/tests/ksocktest.cpp create mode 100644 tdecore/tests/ksortablevaluelisttest.cpp create mode 100644 tdecore/tests/kstdacceltest.cpp create mode 100644 tdecore/tests/kstddirstest.cpp create mode 100644 tdecore/tests/kstringhandlertest.cpp create mode 100644 tdecore/tests/ktempfiletest.cpp create mode 100644 tdecore/tests/ktimezonestest.cpp create mode 100644 tdecore/tests/kuniqueapptest.cpp create mode 100644 tdecore/tests/kurltest.cpp create mode 100644 tdecore/tests/kxerrorhandlertest.cpp create mode 100644 tdecore/tests/startserviceby.cpp create mode 100644 tdecore/tests/testqtargs.cpp create mode 100644 tdecore/vsnprintf.c create mode 100644 tdefx/CMakeLists.txt create mode 100644 tdefx/Mainpage.dox create mode 100644 tdefx/Makefile.am create mode 100644 tdefx/configure.in.in create mode 100644 tdefx/kcpuinfo.cpp create mode 100644 tdefx/kcpuinfo.h create mode 100644 tdefx/kdrawutil.cpp create mode 100644 tdefx/kdrawutil.h create mode 100644 tdefx/kimageeffect.cpp create mode 100644 tdefx/kimageeffect.h create mode 100644 tdefx/kpixmap.cpp create mode 100644 tdefx/kpixmap.h create mode 100644 tdefx/kpixmapeffect.cpp create mode 100644 tdefx/kpixmapeffect.h create mode 100644 tdefx/kpixmapsplitter.cpp create mode 100644 tdefx/kpixmapsplitter.h create mode 100644 tdefx/kstyle.cpp create mode 100644 tdefx/kstyle.h create mode 100644 tdefx/libtdefx.nmcheck create mode 100644 tdefx/libtdefx_weak.nmcheck create mode 100644 tdeprint/CMakeLists.txt create mode 100644 tdeprint/ChangeLog create mode 100644 tdeprint/Makefile.am create mode 100644 tdeprint/TODO create mode 100644 tdeprint/TODO.cups12 create mode 100644 tdeprint/configure.in.in create mode 100644 tdeprint/cups/CMakeLists.txt create mode 100644 tdeprint/cups/Makefile.am create mode 100644 tdeprint/cups/configure.in.in create mode 100644 tdeprint/cups/cups.print create mode 100644 tdeprint/cups/cupsaddsmb2.cpp create mode 100644 tdeprint/cups/cupsaddsmb2.h create mode 100644 tdeprint/cups/cupsdconf2/CMakeLists.txt create mode 100644 tdeprint/cups/cupsdconf2/Makefile.am create mode 100644 tdeprint/cups/cupsdconf2/addressdialog.cpp create mode 100644 tdeprint/cups/cupsdconf2/addressdialog.h create mode 100644 tdeprint/cups/cupsdconf2/browsedialog.cpp create mode 100644 tdeprint/cups/cupsdconf2/browsedialog.h create mode 100644 tdeprint/cups/cupsdconf2/cups-util.c create mode 100644 tdeprint/cups/cupsdconf2/cups-util.h create mode 100644 tdeprint/cups/cupsdconf2/cups_logo.png create mode 100644 tdeprint/cups/cupsdconf2/cupsd.conf.template create mode 100644 tdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdbrowsingpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdcomment.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdcomment.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdcomment.pl create mode 100644 tdeprint/cups/cupsdconf2/cupsdconf.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdconf.h create mode 100644 tdeprint/cups/cupsdconf2/cupsddialog.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsddialog.h create mode 100644 tdeprint/cups/cupsdconf2/cupsddirpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsddirpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdfilterpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdfilterpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdjobspage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdjobspage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdlogpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdlogpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdnetworkpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdsecuritypage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdserverpage.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdserverpage.h create mode 100644 tdeprint/cups/cupsdconf2/cupsdsplash.cpp create mode 100644 tdeprint/cups/cupsdconf2/cupsdsplash.h create mode 100644 tdeprint/cups/cupsdconf2/editlist.cpp create mode 100644 tdeprint/cups/cupsdconf2/editlist.h create mode 100644 tdeprint/cups/cupsdconf2/kde_logo.png create mode 100644 tdeprint/cups/cupsdconf2/locationdialog.cpp create mode 100644 tdeprint/cups/cupsdconf2/locationdialog.h create mode 100644 tdeprint/cups/cupsdconf2/main.cpp create mode 100644 tdeprint/cups/cupsdconf2/portdialog.cpp create mode 100644 tdeprint/cups/cupsdconf2/portdialog.h create mode 100644 tdeprint/cups/cupsdconf2/qdirlineedit.cpp create mode 100644 tdeprint/cups/cupsdconf2/qdirlineedit.h create mode 100644 tdeprint/cups/cupsdconf2/qdirmultilineedit.cpp create mode 100644 tdeprint/cups/cupsdconf2/qdirmultilineedit.h create mode 100644 tdeprint/cups/cupsdconf2/sizewidget.cpp create mode 100644 tdeprint/cups/cupsdconf2/sizewidget.h create mode 100644 tdeprint/cups/cupsdoprint.c create mode 100644 tdeprint/cups/cupsinfos.cpp create mode 100644 tdeprint/cups/cupsinfos.h create mode 100644 tdeprint/cups/image.cpp create mode 100644 tdeprint/cups/imageposition.cpp create mode 100644 tdeprint/cups/imageposition.h create mode 100644 tdeprint/cups/imagepreview.cpp create mode 100644 tdeprint/cups/imagepreview.h create mode 100644 tdeprint/cups/ippreportdlg.cpp create mode 100644 tdeprint/cups/ippreportdlg.h create mode 100644 tdeprint/cups/ipprequest.cpp create mode 100644 tdeprint/cups/ipprequest.h create mode 100644 tdeprint/cups/kcupsprinterimpl.cpp create mode 100644 tdeprint/cups/kcupsprinterimpl.h create mode 100644 tdeprint/cups/kmconfigcups.cpp create mode 100644 tdeprint/cups/kmconfigcups.h create mode 100644 tdeprint/cups/kmconfigcupsdir.cpp create mode 100644 tdeprint/cups/kmconfigcupsdir.h create mode 100644 tdeprint/cups/kmcupsconfigwidget.cpp create mode 100644 tdeprint/cups/kmcupsconfigwidget.h create mode 100644 tdeprint/cups/kmcupsfactory.cpp create mode 100644 tdeprint/cups/kmcupsjobmanager.cpp create mode 100644 tdeprint/cups/kmcupsjobmanager.h create mode 100644 tdeprint/cups/kmcupsmanager.cpp create mode 100644 tdeprint/cups/kmcupsmanager.h create mode 100644 tdeprint/cups/kmcupsuimanager.cpp create mode 100644 tdeprint/cups/kmcupsuimanager.h create mode 100644 tdeprint/cups/kmpropbanners.cpp create mode 100644 tdeprint/cups/kmpropbanners.h create mode 100644 tdeprint/cups/kmpropquota.cpp create mode 100644 tdeprint/cups/kmpropquota.h create mode 100644 tdeprint/cups/kmpropusers.cpp create mode 100644 tdeprint/cups/kmpropusers.h create mode 100644 tdeprint/cups/kmwbanners.cpp create mode 100644 tdeprint/cups/kmwbanners.h create mode 100644 tdeprint/cups/kmwfax.cpp create mode 100644 tdeprint/cups/kmwfax.h create mode 100644 tdeprint/cups/kmwipp.cpp create mode 100644 tdeprint/cups/kmwipp.h create mode 100644 tdeprint/cups/kmwippprinter.cpp create mode 100644 tdeprint/cups/kmwippprinter.h create mode 100644 tdeprint/cups/kmwippselect.cpp create mode 100644 tdeprint/cups/kmwippselect.h create mode 100644 tdeprint/cups/kmwother.cpp create mode 100644 tdeprint/cups/kmwother.h create mode 100644 tdeprint/cups/kmwquota.cpp create mode 100644 tdeprint/cups/kmwquota.h create mode 100644 tdeprint/cups/kmwusers.cpp create mode 100644 tdeprint/cups/kmwusers.h create mode 100644 tdeprint/cups/kphpgl2page.cpp create mode 100644 tdeprint/cups/kphpgl2page.h create mode 100644 tdeprint/cups/kpimagepage.cpp create mode 100644 tdeprint/cups/kpimagepage.h create mode 100644 tdeprint/cups/kpschedulepage.cpp create mode 100644 tdeprint/cups/kpschedulepage.h create mode 100644 tdeprint/cups/kptagspage.cpp create mode 100644 tdeprint/cups/kptagspage.h create mode 100644 tdeprint/cups/kptextpage.cpp create mode 100644 tdeprint/cups/kptextpage.h create mode 100644 tdeprint/cups/make_driver_db_cups.c create mode 100644 tdeprint/cups/postscript.ppd.gz create mode 100644 tdeprint/cups/preview-mini.png create mode 100644 tdeprint/cups/preview.png create mode 100644 tdeprint/driver.cpp create mode 100644 tdeprint/driver.h create mode 100644 tdeprint/driveritem.cpp create mode 100644 tdeprint/driveritem.h create mode 100644 tdeprint/driverparse.c create mode 100644 tdeprint/driverparse.h create mode 100644 tdeprint/driverview.cpp create mode 100644 tdeprint/driverview.h create mode 100644 tdeprint/droptionview.cpp create mode 100644 tdeprint/droptionview.h create mode 100644 tdeprint/ext/CMakeLists.txt create mode 100644 tdeprint/ext/Makefile.am create mode 100644 tdeprint/ext/ext.print create mode 100644 tdeprint/ext/kextprinterimpl.cpp create mode 100644 tdeprint/ext/kextprinterimpl.h create mode 100644 tdeprint/ext/kmextfactory.cpp create mode 100644 tdeprint/ext/kmextmanager.cpp create mode 100644 tdeprint/ext/kmextmanager.h create mode 100644 tdeprint/ext/kmextuimanager.cpp create mode 100644 tdeprint/ext/kmextuimanager.h create mode 100644 tdeprint/filters/CMakeLists.txt create mode 100644 tdeprint/filters/Makefile.am create mode 100644 tdeprint/filters/enscript.desktop create mode 100644 tdeprint/filters/enscript.xml create mode 100755 tdeprint/filters/imagetops create mode 100644 tdeprint/filters/imagetops.desktop create mode 100644 tdeprint/filters/imagetops.xml create mode 100644 tdeprint/filters/pdf2ps.desktop create mode 100644 tdeprint/filters/pdf2ps.xml create mode 100644 tdeprint/filters/pdfwrite.desktop create mode 100644 tdeprint/filters/pdfwrite.xml create mode 100644 tdeprint/filters/poster.desktop create mode 100644 tdeprint/filters/poster.xml create mode 100644 tdeprint/filters/ps2pdf.desktop create mode 100644 tdeprint/filters/ps2pdf.xml create mode 100644 tdeprint/filters/psbook.desktop create mode 100644 tdeprint/filters/psbook.xml create mode 100644 tdeprint/filters/psbook1.desktop create mode 100644 tdeprint/filters/psbook1.xml create mode 100644 tdeprint/filters/psbook2.desktop create mode 100644 tdeprint/filters/psbook2.xml create mode 100644 tdeprint/filters/psnup.desktop create mode 100644 tdeprint/filters/psnup.xml create mode 100644 tdeprint/filters/psresize.desktop create mode 100644 tdeprint/filters/psresize.xml create mode 100644 tdeprint/filters/psselect.desktop create mode 100644 tdeprint/filters/psselect.xml create mode 100644 tdeprint/foomatic/Makefile.am create mode 100644 tdeprint/foomatic/foomatic.print create mode 100644 tdeprint/foomatic/kfoomaticprinterimpl.cpp create mode 100644 tdeprint/foomatic/kfoomaticprinterimpl.h create mode 100644 tdeprint/foomatic/kmfoomaticfactory.cpp create mode 100644 tdeprint/foomatic/kmfoomaticmanager.cpp create mode 100644 tdeprint/foomatic/kmfoomaticmanager.h create mode 100644 tdeprint/foomatic/make_driver_db_foomatic.c create mode 100644 tdeprint/foomatic2loader.cpp create mode 100644 tdeprint/foomatic2loader.h create mode 100644 tdeprint/fooparser.cpp create mode 100644 tdeprint/fooparser.cpp.h create mode 100644 tdeprint/fooparser.y create mode 100644 tdeprint/fooscanner.cpp create mode 100644 tdeprint/fooscanner.l create mode 100644 tdeprint/kfilelist.cpp create mode 100644 tdeprint/kfilelist.h create mode 100644 tdeprint/kmdbentry.cpp create mode 100644 tdeprint/kmdbentry.h create mode 100644 tdeprint/kmfactory.cpp create mode 100644 tdeprint/kmfactory.h create mode 100644 tdeprint/kmjob.cpp create mode 100644 tdeprint/kmjob.h create mode 100644 tdeprint/kmjobmanager.cpp create mode 100644 tdeprint/kmjobmanager.h create mode 100644 tdeprint/kmmanager.cpp create mode 100644 tdeprint/kmmanager.h create mode 100644 tdeprint/kmobject.h create mode 100644 tdeprint/kmprinter.cpp create mode 100644 tdeprint/kmprinter.h create mode 100644 tdeprint/kmspecialmanager.cpp create mode 100644 tdeprint/kmspecialmanager.h create mode 100644 tdeprint/kmthreadjob.cpp create mode 100644 tdeprint/kmthreadjob.h create mode 100644 tdeprint/kmuimanager.cpp create mode 100644 tdeprint/kmuimanager.h create mode 100644 tdeprint/kmvirtualmanager.cpp create mode 100644 tdeprint/kmvirtualmanager.h create mode 100644 tdeprint/kpcopiespage.cpp create mode 100644 tdeprint/kpcopiespage.h create mode 100644 tdeprint/kpdriverpage.cpp create mode 100644 tdeprint/kpdriverpage.h create mode 100644 tdeprint/kpfileselectpage.cpp create mode 100644 tdeprint/kpfileselectpage.h create mode 100644 tdeprint/kpfilterpage.cpp create mode 100644 tdeprint/kpfilterpage.h create mode 100644 tdeprint/kpgeneralpage.cpp create mode 100644 tdeprint/kpgeneralpage.h create mode 100644 tdeprint/kpipeprocess.cpp create mode 100644 tdeprint/kpipeprocess.h create mode 100644 tdeprint/kpmarginpage.cpp create mode 100644 tdeprint/kpmarginpage.h create mode 100644 tdeprint/kpposterpage.cpp create mode 100644 tdeprint/kpposterpage.h create mode 100644 tdeprint/kpqtpage.cpp create mode 100644 tdeprint/kpqtpage.h create mode 100644 tdeprint/kpreloadobject.cpp create mode 100644 tdeprint/kpreloadobject.h create mode 100644 tdeprint/kprintaction.cpp create mode 100644 tdeprint/kprintaction.h create mode 100644 tdeprint/kprintdialog.cpp create mode 100644 tdeprint/kprintdialog.h create mode 100644 tdeprint/kprintdialogpage.cpp create mode 100644 tdeprint/kprintdialogpage.h create mode 100644 tdeprint/kprinter.cpp create mode 100644 tdeprint/kprinter.h create mode 100644 tdeprint/kprinterimpl.cpp create mode 100644 tdeprint/kprinterimpl.h create mode 100644 tdeprint/kprinterpropertydialog.cpp create mode 100644 tdeprint/kprinterpropertydialog.h create mode 100644 tdeprint/kprintpreview.cpp create mode 100644 tdeprint/kprintpreview.h create mode 100644 tdeprint/kprintpreviewui.rc create mode 100644 tdeprint/kprintprocess.cpp create mode 100644 tdeprint/kprintprocess.h create mode 100644 tdeprint/kxmlcommand.cpp create mode 100644 tdeprint/kxmlcommand.h create mode 100644 tdeprint/lpd/Makefile.am create mode 100644 tdeprint/lpd/gschecker.cpp create mode 100644 tdeprint/lpd/gschecker.h create mode 100644 tdeprint/lpd/klpdprinterimpl.cpp create mode 100644 tdeprint/lpd/klpdprinterimpl.h create mode 100644 tdeprint/lpd/kmlpdfactory.cpp create mode 100644 tdeprint/lpd/kmlpdfactory.h create mode 100644 tdeprint/lpd/kmlpdmanager.cpp create mode 100644 tdeprint/lpd/kmlpdmanager.h create mode 100644 tdeprint/lpd/kmlpduimanager.cpp create mode 100644 tdeprint/lpd/kmlpduimanager.h create mode 100644 tdeprint/lpd/lpd.print create mode 100644 tdeprint/lpd/lpdtools.cpp create mode 100644 tdeprint/lpd/lpdtools.h create mode 100644 tdeprint/lpd/make_driver_db_lpd.c create mode 100644 tdeprint/lpdunix/CMakeLists.txt create mode 100644 tdeprint/lpdunix/Makefile.am create mode 100644 tdeprint/lpdunix/klpdunixprinterimpl.cpp create mode 100644 tdeprint/lpdunix/klpdunixprinterimpl.h create mode 100644 tdeprint/lpdunix/kmlpdunixfactory.cpp create mode 100644 tdeprint/lpdunix/kmlpdunixmanager.cpp create mode 100644 tdeprint/lpdunix/kmlpdunixmanager.h create mode 100644 tdeprint/lpdunix/kmlpdunixuimanager.cpp create mode 100644 tdeprint/lpdunix/kmlpdunixuimanager.h create mode 100644 tdeprint/lpdunix/lpdunix.print create mode 100644 tdeprint/lpr/CMakeLists.txt create mode 100644 tdeprint/lpr/Makefile.am create mode 100644 tdeprint/lpr/apsdriver1 create mode 100644 tdeprint/lpr/apsdriver2 create mode 100644 tdeprint/lpr/apshandler.cpp create mode 100644 tdeprint/lpr/apshandler.h create mode 100644 tdeprint/lpr/editentrydialog.cpp create mode 100644 tdeprint/lpr/editentrydialog.h create mode 100644 tdeprint/lpr/klprfactory.cpp create mode 100644 tdeprint/lpr/klprprinterimpl.cpp create mode 100644 tdeprint/lpr/klprprinterimpl.h create mode 100644 tdeprint/lpr/kmconfiglpr.cpp create mode 100644 tdeprint/lpr/kmconfiglpr.h create mode 100644 tdeprint/lpr/kmlprjobmanager.cpp create mode 100644 tdeprint/lpr/kmlprjobmanager.h create mode 100644 tdeprint/lpr/kmlprmanager.cpp create mode 100644 tdeprint/lpr/kmlprmanager.h create mode 100644 tdeprint/lpr/kmlpruimanager.cpp create mode 100644 tdeprint/lpr/kmlpruimanager.h create mode 100644 tdeprint/lpr/lpchelper.cpp create mode 100644 tdeprint/lpr/lpchelper.h create mode 100644 tdeprint/lpr/lpqhelper.cpp create mode 100644 tdeprint/lpr/lpqhelper.h create mode 100644 tdeprint/lpr/lpr.print create mode 100644 tdeprint/lpr/lprhandler.cpp create mode 100644 tdeprint/lpr/lprhandler.h create mode 100644 tdeprint/lpr/lprngtooldriver1 create mode 100644 tdeprint/lpr/lprngtoolhandler.cpp create mode 100644 tdeprint/lpr/lprngtoolhandler.h create mode 100644 tdeprint/lpr/lprsettings.cpp create mode 100644 tdeprint/lpr/lprsettings.h create mode 100644 tdeprint/lpr/make_driver_db_lpr.c create mode 100644 tdeprint/lpr/matichandler.cpp create mode 100644 tdeprint/lpr/matichandler.h create mode 100644 tdeprint/lpr/matichelper.cpp create mode 100644 tdeprint/lpr/matichelper.h create mode 100644 tdeprint/lpr/printcapentry.cpp create mode 100644 tdeprint/lpr/printcapentry.h create mode 100644 tdeprint/lpr/printcapreader.cpp create mode 100644 tdeprint/lpr/printcapreader.h create mode 100644 tdeprint/management/CMakeLists.txt create mode 100644 tdeprint/management/Makefile.am create mode 100644 tdeprint/management/cjanuswidget.cpp create mode 100644 tdeprint/management/cjanuswidget.h create mode 100644 tdeprint/management/jobitem.cpp create mode 100644 tdeprint/management/jobitem.h create mode 100644 tdeprint/management/kaddprinterwizard.cpp create mode 100644 tdeprint/management/kiconselectaction.cpp create mode 100644 tdeprint/management/kiconselectaction.h create mode 100644 tdeprint/management/kmconfigcommand.cpp create mode 100644 tdeprint/management/kmconfigcommand.h create mode 100644 tdeprint/management/kmconfigdialog.cpp create mode 100644 tdeprint/management/kmconfigdialog.h create mode 100644 tdeprint/management/kmconfigfilter.cpp create mode 100644 tdeprint/management/kmconfigfilter.h create mode 100644 tdeprint/management/kmconfigfonts.cpp create mode 100644 tdeprint/management/kmconfigfonts.h create mode 100644 tdeprint/management/kmconfiggeneral.cpp create mode 100644 tdeprint/management/kmconfiggeneral.h create mode 100644 tdeprint/management/kmconfigjobs.cpp create mode 100644 tdeprint/management/kmconfigjobs.h create mode 100644 tdeprint/management/kmconfigpage.cpp create mode 100644 tdeprint/management/kmconfigpage.h create mode 100644 tdeprint/management/kmconfigpreview.cpp create mode 100644 tdeprint/management/kmconfigpreview.h create mode 100644 tdeprint/management/kmdbcreator.cpp create mode 100644 tdeprint/management/kmdbcreator.h create mode 100644 tdeprint/management/kmdriverdb.cpp create mode 100644 tdeprint/management/kmdriverdb.h create mode 100644 tdeprint/management/kmdriverdbwidget.cpp create mode 100644 tdeprint/management/kmdriverdbwidget.h create mode 100644 tdeprint/management/kmdriverdialog.cpp create mode 100644 tdeprint/management/kmdriverdialog.h create mode 100644 tdeprint/management/kmiconview.cpp create mode 100644 tdeprint/management/kmiconview.h create mode 100644 tdeprint/management/kminfopage.cpp create mode 100644 tdeprint/management/kminfopage.h create mode 100644 tdeprint/management/kminstancepage.cpp create mode 100644 tdeprint/management/kminstancepage.h create mode 100644 tdeprint/management/kmjobviewer.cpp create mode 100644 tdeprint/management/kmjobviewer.h create mode 100644 tdeprint/management/kmlistview.cpp create mode 100644 tdeprint/management/kmlistview.h create mode 100644 tdeprint/management/kmmainview.cpp create mode 100644 tdeprint/management/kmmainview.h create mode 100644 tdeprint/management/kmpages.cpp create mode 100644 tdeprint/management/kmpages.h create mode 100644 tdeprint/management/kmprinterpage.h create mode 100644 tdeprint/management/kmprinterview.cpp create mode 100644 tdeprint/management/kmprinterview.h create mode 100644 tdeprint/management/kmpropbackend.cpp create mode 100644 tdeprint/management/kmpropbackend.h create mode 100644 tdeprint/management/kmpropcontainer.cpp create mode 100644 tdeprint/management/kmpropcontainer.h create mode 100644 tdeprint/management/kmpropdriver.cpp create mode 100644 tdeprint/management/kmpropdriver.h create mode 100644 tdeprint/management/kmpropertypage.cpp create mode 100644 tdeprint/management/kmpropertypage.h create mode 100644 tdeprint/management/kmpropgeneral.cpp create mode 100644 tdeprint/management/kmpropgeneral.h create mode 100644 tdeprint/management/kmpropmembers.cpp create mode 100644 tdeprint/management/kmpropmembers.h create mode 100644 tdeprint/management/kmpropwidget.cpp create mode 100644 tdeprint/management/kmpropwidget.h create mode 100644 tdeprint/management/kmspecialprinterdlg.cpp create mode 100644 tdeprint/management/kmspecialprinterdlg.h create mode 100644 tdeprint/management/kmtimer.cpp create mode 100644 tdeprint/management/kmtimer.h create mode 100644 tdeprint/management/kmwbackend.cpp create mode 100644 tdeprint/management/kmwbackend.h create mode 100644 tdeprint/management/kmwclass.cpp create mode 100644 tdeprint/management/kmwclass.h create mode 100644 tdeprint/management/kmwdriver.cpp create mode 100644 tdeprint/management/kmwdriver.h create mode 100644 tdeprint/management/kmwdriverselect.cpp create mode 100644 tdeprint/management/kmwdriverselect.h create mode 100644 tdeprint/management/kmwdrivertest.cpp create mode 100644 tdeprint/management/kmwdrivertest.h create mode 100644 tdeprint/management/kmwend.cpp create mode 100644 tdeprint/management/kmwend.h create mode 100644 tdeprint/management/kmwfile.cpp create mode 100644 tdeprint/management/kmwfile.h create mode 100644 tdeprint/management/kmwinfobase.cpp create mode 100644 tdeprint/management/kmwinfobase.h create mode 100644 tdeprint/management/kmwinfopage.cpp create mode 100644 tdeprint/management/kmwinfopage.h create mode 100644 tdeprint/management/kmwizard.cpp create mode 100644 tdeprint/management/kmwizard.h create mode 100644 tdeprint/management/kmwizardpage.cpp create mode 100644 tdeprint/management/kmwizardpage.h create mode 100644 tdeprint/management/kmwlocal.cpp create mode 100644 tdeprint/management/kmwlocal.h create mode 100644 tdeprint/management/kmwlpd.cpp create mode 100644 tdeprint/management/kmwlpd.h create mode 100644 tdeprint/management/kmwname.cpp create mode 100644 tdeprint/management/kmwname.h create mode 100644 tdeprint/management/kmwpassword.cpp create mode 100644 tdeprint/management/kmwpassword.h create mode 100644 tdeprint/management/kmwsmb.cpp create mode 100644 tdeprint/management/kmwsmb.h create mode 100644 tdeprint/management/kmwsocket.cpp create mode 100644 tdeprint/management/kmwsocket.h create mode 100644 tdeprint/management/kmwsocketutil.cpp create mode 100644 tdeprint/management/kmwsocketutil.h create mode 100644 tdeprint/management/kxmlcommanddlg.cpp create mode 100644 tdeprint/management/kxmlcommanddlg.h create mode 100644 tdeprint/management/kxmlcommandselector.cpp create mode 100644 tdeprint/management/kxmlcommandselector.h create mode 100644 tdeprint/management/networkscanner.cpp create mode 100644 tdeprint/management/networkscanner.h create mode 100644 tdeprint/management/pluginaction.cpp create mode 100644 tdeprint/management/pluginaction.h create mode 100644 tdeprint/management/side.png create mode 100644 tdeprint/management/sidepixmap.cpp create mode 100644 tdeprint/management/sidepixmap.h create mode 100644 tdeprint/management/smbview.cpp create mode 100644 tdeprint/management/smbview.h create mode 100644 tdeprint/management/tdeprint_management_module.cpp create mode 100644 tdeprint/management/tiledown.png create mode 100644 tdeprint/management/tileup.png create mode 100644 tdeprint/marginpreview.cpp create mode 100644 tdeprint/marginpreview.h create mode 100644 tdeprint/marginvaluewidget.cpp create mode 100644 tdeprint/marginvaluewidget.h create mode 100644 tdeprint/marginwidget.cpp create mode 100644 tdeprint/marginwidget.h create mode 100644 tdeprint/messagewindow.cpp create mode 100644 tdeprint/messagewindow.h create mode 100644 tdeprint/pics/CMakeLists.txt create mode 100644 tdeprint/pics/Makefile.am create mode 100644 tdeprint/pics/cr16-action-filterstop.png create mode 100644 tdeprint/pics/cr16-action-tdeprint_restartsrv.png create mode 100644 tdeprint/pics/cr16-action-tdeprint_uploadsmb.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_computer.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_job.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_job_cancelled.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_job_completed.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_job_error.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_job_process.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_job_stopped.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_class.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_class_process.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_class_stopped.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_defect.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_process.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_remote.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_remote_process.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_remote_stopped.png create mode 100644 tdeprint/pics/cr16-app-tdeprint_printer_stopped.png create mode 100644 tdeprint/pics/cr22-action-history.png create mode 100644 tdeprint/pics/cr22-action-package_utilities.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_addprinter.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_addpseudo.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_configmgr.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_configsrv.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_defaulthard.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_defaultsoft.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_enableprinter.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_printer.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_printer_infos.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_printstate.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_queuestate.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_report.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_restartsrv.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_stopprinter.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_testprinter.png create mode 100644 tdeprint/pics/cr22-action-tdeprint_uploadsmb.png create mode 100644 tdeprint/pics/cr22-app-tdeprint_printer.png create mode 100644 tdeprint/pics/cr32-action-tdeprint_inklevel.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_class.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_class_process.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_class_stopped.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_defect.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_process.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_remote.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_remote_process.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_remote_stopped.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_stopped.png create mode 100644 tdeprint/pics/cr32-app-tdeprint_printer_users.png create mode 100644 tdeprint/pics/cr48-app-tdeprint_printer.png create mode 100644 tdeprint/pics/cr48-app-tdeprint_printer_class.png create mode 100644 tdeprint/pics/cr64-app-tdeprint_printer.png create mode 100644 tdeprint/pics/cr64-app-tdeprint_printer_class.png create mode 100644 tdeprint/pics/processsign.png create mode 100644 tdeprint/pics/stopsign.png create mode 100644 tdeprint/pics/tdeprint_collate.png create mode 100644 tdeprint/pics/tdeprint_collate_reverse.png create mode 100644 tdeprint/pics/tdeprint_color.png create mode 100644 tdeprint/pics/tdeprint_dupl_none.png create mode 100644 tdeprint/pics/tdeprint_duplex_long.png create mode 100644 tdeprint/pics/tdeprint_duplex_none.png create mode 100644 tdeprint/pics/tdeprint_duplex_short.png create mode 100644 tdeprint/pics/tdeprint_grayscale.png create mode 100644 tdeprint/pics/tdeprint_landscape.png create mode 100644 tdeprint/pics/tdeprint_nup1.png create mode 100644 tdeprint/pics/tdeprint_nup2.png create mode 100644 tdeprint/pics/tdeprint_nup4.png create mode 100644 tdeprint/pics/tdeprint_nupother.png create mode 100644 tdeprint/pics/tdeprint_opt_duplex.png create mode 100644 tdeprint/pics/tdeprint_pagesize.png create mode 100644 tdeprint/pics/tdeprint_portrait.png create mode 100644 tdeprint/pics/tdeprint_prettyprint.png create mode 100644 tdeprint/pics/tdeprint_revlandscape.png create mode 100644 tdeprint/pics/tdeprint_revportrait.png create mode 100644 tdeprint/pics/tdeprint_uncollate.png create mode 100644 tdeprint/pics/tdeprint_uncollate_reverse.png create mode 100644 tdeprint/plugincombobox.cpp create mode 100644 tdeprint/plugincombobox.h create mode 100644 tdeprint/posterpreview.cpp create mode 100644 tdeprint/posterpreview.h create mode 100644 tdeprint/ppdloader.cpp create mode 100644 tdeprint/ppdloader.h create mode 100644 tdeprint/ppdparser.cpp create mode 100644 tdeprint/ppdparser.cpp.h create mode 100644 tdeprint/ppdparser.y create mode 100644 tdeprint/ppdscanner.cpp create mode 100644 tdeprint/ppdscanner.l create mode 100644 tdeprint/printerfilter.cpp create mode 100644 tdeprint/printerfilter.h create mode 100644 tdeprint/rlpr/CMakeLists.txt create mode 100644 tdeprint/rlpr/Makefile.am create mode 100644 tdeprint/rlpr/kmconfigproxy.cpp create mode 100644 tdeprint/rlpr/kmconfigproxy.h create mode 100644 tdeprint/rlpr/kmproprlpr.cpp create mode 100644 tdeprint/rlpr/kmproprlpr.h create mode 100644 tdeprint/rlpr/kmproxywidget.cpp create mode 100644 tdeprint/rlpr/kmproxywidget.h create mode 100644 tdeprint/rlpr/kmrlprfactory.cpp create mode 100644 tdeprint/rlpr/kmrlprmanager.cpp create mode 100644 tdeprint/rlpr/kmrlprmanager.h create mode 100644 tdeprint/rlpr/kmrlpruimanager.cpp create mode 100644 tdeprint/rlpr/kmrlpruimanager.h create mode 100644 tdeprint/rlpr/kmwrlpr.cpp create mode 100644 tdeprint/rlpr/kmwrlpr.h create mode 100644 tdeprint/rlpr/krlprprinterimpl.cpp create mode 100644 tdeprint/rlpr/krlprprinterimpl.h create mode 100644 tdeprint/rlpr/rlpr.print create mode 100644 tdeprint/signal_proc.c create mode 100644 tdeprint/specials.desktop create mode 100644 tdeprint/tdeprintcheck.cpp create mode 100644 tdeprint/tdeprintcheck.h create mode 100644 tdeprint/tdeprintd.cpp create mode 100644 tdeprint/tdeprintd.desktop create mode 100644 tdeprint/tdeprintd.h create mode 100644 tdeprint/tdeprintrc create mode 100644 tdeprint/tdeprintrc.upd create mode 100644 tdeprint/testprint.ps create mode 100644 tdeprint/tests/Makefile.am create mode 100644 tdeprint/tests/back.xpm create mode 100644 tdeprint/tests/drawdemo.cpp create mode 100644 tdeprint/tests/drawdemo.h create mode 100644 tdeprint/tests/forward.xpm create mode 100644 tdeprint/tests/helpwindow.cpp create mode 100644 tdeprint/tests/helpwindow.h create mode 100644 tdeprint/tests/home.xpm create mode 100644 tdeprint/tests/main.cpp create mode 100644 tdeprint/tests/richpage.cpp create mode 100644 tdeprint/tests/richpage.h create mode 100644 tdeprint/tools/CMakeLists.txt create mode 100644 tdeprint/tools/Makefile.am create mode 100644 tdeprint/tools/escputil/CMakeLists.txt create mode 100644 tdeprint/tools/escputil/Makefile.am create mode 100644 tdeprint/tools/escputil/escputil.desktop create mode 100644 tdeprint/tools/escputil/escpwidget.cpp create mode 100644 tdeprint/tools/escputil/escpwidget.h create mode 100644 tdeprint/treecombobox.cpp create mode 100644 tdeprint/treecombobox.h create mode 100644 tdeprint/util.cpp create mode 100644 tdeprint/util.h create mode 100644 tdesu/CMakeLists.txt create mode 100644 tdesu/Mainpage.dox create mode 100644 tdesu/Makefile.am create mode 100644 tdesu/README create mode 100644 tdesu/client.cpp create mode 100644 tdesu/client.h create mode 100644 tdesu/configure.in.in create mode 100644 tdesu/defaults.h create mode 100644 tdesu/kcookie.cpp create mode 100644 tdesu/kcookie.h create mode 100644 tdesu/libtdesu.nmcheck create mode 100644 tdesu/libtdesu_weak.nmcheck create mode 100644 tdesu/process.cpp create mode 100644 tdesu/process.h create mode 100644 tdesu/ssh.cpp create mode 100644 tdesu/ssh.h create mode 100644 tdesu/stub.cpp create mode 100644 tdesu/stub.h create mode 100644 tdesu/su.cpp create mode 100644 tdesu/su.h create mode 100644 tdesu/tdesu_pty.cpp create mode 100644 tdesu/tdesu_pty.h create mode 100644 tdesu/tdesu_stub.c create mode 100644 tdeui/AUTHORS create mode 100644 tdeui/CMakeLists.txt create mode 100644 tdeui/MAINTAINERS create mode 100644 tdeui/Mainpage.dox create mode 100644 tdeui/Makefile.am create mode 100644 tdeui/README.kspell create mode 100644 tdeui/TODO.kspell create mode 100644 tdeui/TODO.xmlgui create mode 100644 tdeui/about/CMakeLists.txt create mode 100644 tdeui/about/Makefile.am create mode 100644 tdeui/about/bar-bottom-left.png create mode 100644 tdeui/about/bar-bottom-middle.png create mode 100644 tdeui/about/bar-bottom-right.png create mode 100644 tdeui/about/bar-middle-left.png create mode 100644 tdeui/about/bar-middle-right.png create mode 100644 tdeui/about/bar-top-left.png create mode 100644 tdeui/about/bar-top-middle.png create mode 100644 tdeui/about/bar-top-right.png create mode 100644 tdeui/about/bottom-left.png create mode 100644 tdeui/about/bottom-middle.png create mode 100644 tdeui/about/bottom-right.png create mode 100644 tdeui/about/box-bottom-left.png create mode 100644 tdeui/about/box-bottom-middle.png create mode 100644 tdeui/about/box-bottom-right.png create mode 100644 tdeui/about/box-middle-left.png create mode 100644 tdeui/about/box-middle-right.png create mode 100644 tdeui/about/box-top-left.png create mode 100644 tdeui/about/box-top-middle.png create mode 100644 tdeui/about/box-top-right.png create mode 100644 tdeui/about/kde_infopage.css create mode 100644 tdeui/about/kde_infopage_rtl.css create mode 100644 tdeui/about/top-left.png create mode 100644 tdeui/about/top-middle.png create mode 100644 tdeui/about/usage-example.html create mode 100644 tdeui/aboutkde.png create mode 100644 tdeui/colors/Makefile.am create mode 100644 tdeui/colors/README create mode 100644 tdeui/colors/rgb.txt create mode 100644 tdeui/dcolorarrow.xbm create mode 100644 tdeui/dcolorreset.xpm create mode 100644 tdeui/kaboutapplication.cpp create mode 100644 tdeui/kaboutapplication.h create mode 100644 tdeui/kaboutdialog.cpp create mode 100644 tdeui/kaboutdialog.h create mode 100644 tdeui/kaboutdialog_private.h create mode 100644 tdeui/kaboutkde.cpp create mode 100644 tdeui/kaboutkde.h create mode 100644 tdeui/kaccelgen.h create mode 100644 tdeui/kaction.cpp create mode 100644 tdeui/kaction.h create mode 100644 tdeui/kactionclasses.cpp create mode 100644 tdeui/kactionclasses.h create mode 100644 tdeui/kactioncollection.cpp create mode 100644 tdeui/kactioncollection.h create mode 100644 tdeui/kactionselector.cpp create mode 100644 tdeui/kactionselector.h create mode 100644 tdeui/kactionshortcutlist.h create mode 100644 tdeui/kactivelabel.cpp create mode 100644 tdeui/kactivelabel.h create mode 100644 tdeui/kanimwidget.cpp create mode 100644 tdeui/kanimwidget.h create mode 100644 tdeui/karrowbutton.cpp create mode 100644 tdeui/karrowbutton.h create mode 100644 tdeui/kauthicon.cpp create mode 100644 tdeui/kauthicon.h create mode 100644 tdeui/kbugreport.cpp create mode 100644 tdeui/kbugreport.h create mode 100644 tdeui/kbuttonbox.cpp create mode 100644 tdeui/kbuttonbox.h create mode 100644 tdeui/kcharselect.cpp create mode 100644 tdeui/kcharselect.h create mode 100644 tdeui/kcmenumngr.cpp create mode 100644 tdeui/kcmenumngr.h create mode 100644 tdeui/kcmodule.cpp create mode 100644 tdeui/kcmodule.h create mode 100644 tdeui/kcolorbtn.h create mode 100644 tdeui/kcolorbutton.cpp create mode 100644 tdeui/kcolorbutton.h create mode 100644 tdeui/kcolorcombo.cpp create mode 100644 tdeui/kcolorcombo.h create mode 100644 tdeui/kcolordialog.cpp create mode 100644 tdeui/kcolordialog.h create mode 100644 tdeui/kcolordlg.h create mode 100644 tdeui/kcolordrag.cpp create mode 100644 tdeui/kcolordrag.h create mode 100644 tdeui/kcombobox.cpp create mode 100644 tdeui/kcombobox.h create mode 100644 tdeui/kcommand.cpp create mode 100644 tdeui/kcommand.h create mode 100644 tdeui/kcompletionbox.cpp create mode 100644 tdeui/kcompletionbox.h create mode 100644 tdeui/kconfigdialog.cpp create mode 100644 tdeui/kconfigdialog.h create mode 100644 tdeui/kcursor.cpp create mode 100644 tdeui/kcursor.h create mode 100644 tdeui/kcursor_private.h create mode 100644 tdeui/kdatepicker.cpp create mode 100644 tdeui/kdatepicker.h create mode 100644 tdeui/kdatepik.h create mode 100644 tdeui/kdatetbl.cpp create mode 100644 tdeui/kdatetbl.h create mode 100644 tdeui/kdatetimewidget.cpp create mode 100644 tdeui/kdatetimewidget.h create mode 100644 tdeui/kdatewidget.cpp create mode 100644 tdeui/kdatewidget.h create mode 100644 tdeui/kdcopactionproxy.cpp create mode 100644 tdeui/kdcopactionproxy.h create mode 100644 tdeui/kdepackages.h create mode 100644 tdeui/kdetrayproxy/CMakeLists.txt create mode 100644 tdeui/kdetrayproxy/Makefile.am create mode 100644 tdeui/kdetrayproxy/kdetrayproxy.cpp create mode 100644 tdeui/kdetrayproxy/kdetrayproxy.desktop create mode 100644 tdeui/kdetrayproxy/kdetrayproxy.h create mode 100644 tdeui/kdetrayproxy/module.cpp create mode 100644 tdeui/kdetrayproxy/module.h create mode 100644 tdeui/kdialog.cpp create mode 100644 tdeui/kdialog.h create mode 100644 tdeui/kdialogbase.cpp create mode 100644 tdeui/kdialogbase.h create mode 100644 tdeui/kdialogbase_priv.h create mode 100644 tdeui/kdockwidget.cpp create mode 100644 tdeui/kdockwidget.h create mode 100644 tdeui/kdockwidget_p.h create mode 100644 tdeui/kdockwidget_private.cpp create mode 100644 tdeui/kdockwidget_private.h create mode 100644 tdeui/kdockwindow.h create mode 100644 tdeui/kdualcolorbtn.h create mode 100644 tdeui/kdualcolorbutton.cpp create mode 100644 tdeui/kdualcolorbutton.h create mode 100644 tdeui/keditcl.h create mode 100644 tdeui/keditcl1.cpp create mode 100644 tdeui/keditcl2.cpp create mode 100644 tdeui/keditlistbox.cpp create mode 100644 tdeui/keditlistbox.h create mode 100644 tdeui/kedittoolbar.cpp create mode 100644 tdeui/kedittoolbar.h create mode 100644 tdeui/kfontcombo.cpp create mode 100644 tdeui/kfontcombo.h create mode 100644 tdeui/kfontdialog.cpp create mode 100644 tdeui/kfontdialog.h create mode 100644 tdeui/kfontrequester.cpp create mode 100644 tdeui/kfontrequester.h create mode 100644 tdeui/kguiitem.cpp create mode 100644 tdeui/kguiitem.h create mode 100644 tdeui/khelpmenu.cpp create mode 100644 tdeui/khelpmenu.h create mode 100644 tdeui/kiconview.cpp create mode 100644 tdeui/kiconview.h create mode 100644 tdeui/kiconviewsearchline.cpp create mode 100644 tdeui/kiconviewsearchline.h create mode 100644 tdeui/kinputdialog.cpp create mode 100644 tdeui/kinputdialog.h create mode 100644 tdeui/kjanuswidget.cpp create mode 100644 tdeui/kjanuswidget.h create mode 100644 tdeui/kkeybutton.cpp create mode 100644 tdeui/kkeybutton.h create mode 100644 tdeui/kkeydialog.cpp create mode 100644 tdeui/kkeydialog.h create mode 100644 tdeui/klanguagebutton.cpp create mode 100644 tdeui/klanguagebutton.h create mode 100644 tdeui/kled.cpp create mode 100644 tdeui/kled.h create mode 100644 tdeui/klineedit.cpp create mode 100644 tdeui/klineedit.h create mode 100644 tdeui/klineeditdlg.cpp create mode 100644 tdeui/klineeditdlg.h create mode 100644 tdeui/klistbox.cpp create mode 100644 tdeui/klistbox.h create mode 100644 tdeui/klistview.cpp create mode 100644 tdeui/klistview.h create mode 100644 tdeui/klistviewlineedit.h create mode 100644 tdeui/klistviewsearchline.cpp create mode 100644 tdeui/klistviewsearchline.h create mode 100644 tdeui/kmainwindow.cpp create mode 100644 tdeui/kmainwindow.h create mode 100644 tdeui/kmainwindowiface.cpp create mode 100644 tdeui/kmainwindowiface.h create mode 100644 tdeui/kmenubar.cpp create mode 100644 tdeui/kmenubar.h create mode 100644 tdeui/kmessagebox.cpp create mode 100644 tdeui/kmessagebox.h create mode 100644 tdeui/knuminput.cpp create mode 100644 tdeui/knuminput.h create mode 100644 tdeui/knumvalidator.cpp create mode 100644 tdeui/knumvalidator.h create mode 100644 tdeui/kpanelapplet.cpp create mode 100644 tdeui/kpanelapplet.h create mode 100644 tdeui/kpanelappmenu.cpp create mode 100644 tdeui/kpanelappmenu.h create mode 100644 tdeui/kpanelextension.cpp create mode 100644 tdeui/kpanelextension.h create mode 100644 tdeui/kpanelmenu.cpp create mode 100644 tdeui/kpanelmenu.h create mode 100644 tdeui/kpartgui.dtd create mode 100644 tdeui/kpassdlg.cpp create mode 100644 tdeui/kpassdlg.h create mode 100644 tdeui/kpassivepopup.cpp create mode 100644 tdeui/kpassivepopup.h create mode 100644 tdeui/kpixmapio-perf.png create mode 100644 tdeui/kpixmapio.cpp create mode 100644 tdeui/kpixmapio.h create mode 100644 tdeui/kpixmapregionselectordialog.cpp create mode 100644 tdeui/kpixmapregionselectordialog.h create mode 100644 tdeui/kpixmapregionselectorwidget.cpp create mode 100644 tdeui/kpixmapregionselectorwidget.h create mode 100644 tdeui/kpopupmenu.cpp create mode 100644 tdeui/kpopupmenu.h create mode 100644 tdeui/kprogress.cpp create mode 100644 tdeui/kprogress.h create mode 100644 tdeui/kprogressbox.cpp create mode 100644 tdeui/kprogressbox.h create mode 100644 tdeui/kpushbutton.cpp create mode 100644 tdeui/kpushbutton.h create mode 100644 tdeui/krestrictedline.cpp create mode 100644 tdeui/krestrictedline.h create mode 100644 tdeui/krootpixmap.cpp create mode 100644 tdeui/krootpixmap.h create mode 100644 tdeui/kruler.cpp create mode 100644 tdeui/kruler.h create mode 100644 tdeui/ksconfig.cpp create mode 100644 tdeui/ksconfig.h create mode 100644 tdeui/kscrollview.cpp create mode 100644 tdeui/kscrollview.h create mode 100644 tdeui/kselect.cpp create mode 100644 tdeui/kselect.h create mode 100644 tdeui/kseparator.cpp create mode 100644 tdeui/kseparator.h create mode 100644 tdeui/ksharedpixmap.cpp create mode 100644 tdeui/ksharedpixmap.h create mode 100644 tdeui/kshortcutdialog.cpp create mode 100644 tdeui/kshortcutdialog.h create mode 100644 tdeui/kshortcutdialog_advanced.ui create mode 100644 tdeui/kshortcutdialog_simple.ui create mode 100644 tdeui/kspell.cpp create mode 100644 tdeui/kspell.h create mode 100644 tdeui/kspelldlg.cpp create mode 100644 tdeui/kspelldlg.h create mode 100644 tdeui/kspellui.ui create mode 100644 tdeui/ksplashscreen.cpp create mode 100644 tdeui/ksplashscreen.h create mode 100644 tdeui/ksqueezedtextlabel.cpp create mode 100644 tdeui/ksqueezedtextlabel.h create mode 100644 tdeui/kstatusbar.cpp create mode 100644 tdeui/kstatusbar.h create mode 100644 tdeui/kstdaction.cpp create mode 100644 tdeui/kstdaction.h create mode 100644 tdeui/kstdaction_p.h create mode 100644 tdeui/kstdguiitem.cpp create mode 100644 tdeui/kstdguiitem.h create mode 100644 tdeui/kstringvalidator.cpp create mode 100644 tdeui/kstringvalidator.h create mode 100644 tdeui/kswitchlanguagedialog.cpp create mode 100644 tdeui/kswitchlanguagedialog.h create mode 100644 tdeui/ksyntaxhighlighter.cpp create mode 100644 tdeui/ksyntaxhighlighter.h create mode 100644 tdeui/ksystemtray.cpp create mode 100644 tdeui/ksystemtray.h create mode 100644 tdeui/ktabbar.cpp create mode 100644 tdeui/ktabbar.h create mode 100644 tdeui/ktabctl.cpp create mode 100644 tdeui/ktabctl.h create mode 100644 tdeui/ktabwidget.cpp create mode 100644 tdeui/ktabwidget.h create mode 100644 tdeui/ktextbrowser.cpp create mode 100644 tdeui/ktextbrowser.h create mode 100644 tdeui/ktextedit.cpp create mode 100644 tdeui/ktextedit.h create mode 100644 tdeui/ktimewidget.cpp create mode 100644 tdeui/ktimewidget.h create mode 100644 tdeui/ktimezonewidget.cpp create mode 100644 tdeui/ktimezonewidget.h create mode 100644 tdeui/ktip-background.png create mode 100644 tdeui/ktip-bulb.png create mode 100644 tdeui/ktip.cpp create mode 100644 tdeui/ktip.h create mode 100644 tdeui/ktoolbar.cpp create mode 100644 tdeui/ktoolbar.h create mode 100644 tdeui/ktoolbarbutton.cpp create mode 100644 tdeui/ktoolbarbutton.h create mode 100644 tdeui/ktoolbarhandler.cpp create mode 100644 tdeui/ktoolbarhandler.h create mode 100644 tdeui/ktoolbarlabelaction.cpp create mode 100644 tdeui/ktoolbarlabelaction.h create mode 100644 tdeui/ktoolbarradiogroup.cpp create mode 100644 tdeui/ktoolbarradiogroup.h create mode 100644 tdeui/kurllabel.cpp create mode 100644 tdeui/kurllabel.h create mode 100644 tdeui/kwhatsthismanager.cpp create mode 100644 tdeui/kwhatsthismanager_p.h create mode 100644 tdeui/kwindowinfo.cpp create mode 100644 tdeui/kwindowinfo.h create mode 100644 tdeui/kwindowlistmenu.cpp create mode 100644 tdeui/kwindowlistmenu.h create mode 100644 tdeui/kwizard.cpp create mode 100644 tdeui/kwizard.h create mode 100644 tdeui/kwordwrap.cpp create mode 100644 tdeui/kwordwrap.h create mode 100644 tdeui/kxmlgui.h create mode 100644 tdeui/kxmlgui.xsd create mode 100644 tdeui/kxmlguibuilder.cpp create mode 100644 tdeui/kxmlguibuilder.h create mode 100644 tdeui/kxmlguiclient.cpp create mode 100644 tdeui/kxmlguiclient.h create mode 100644 tdeui/kxmlguifactory.cpp create mode 100644 tdeui/kxmlguifactory.h create mode 100644 tdeui/kxmlguifactory_p.cpp create mode 100644 tdeui/kxmlguifactory_p.h create mode 100644 tdeui/libtdeui.nmcheck create mode 100644 tdeui/libtdeui_weak.nmcheck create mode 100755 tdeui/preparetips create mode 100644 tdeui/qxembed.cpp create mode 100644 tdeui/qxembed.h create mode 100644 tdeui/tests/CMakeLists.txt create mode 100644 tdeui/tests/Makefile.am create mode 100644 tdeui/tests/RayTracedGear.png create mode 100644 tdeui/tests/background_1.png create mode 100644 tdeui/tests/go.png create mode 100644 tdeui/tests/itemcontainertest.cpp create mode 100644 tdeui/tests/itemcontainertest.h create mode 100644 tdeui/tests/kaboutdialogtest.cpp create mode 100644 tdeui/tests/kaccelgentest.cpp create mode 100644 tdeui/tests/kactiontest.cpp create mode 100644 tdeui/tests/kalphaicontest.h create mode 100644 tdeui/tests/kblendtest.cpp create mode 100644 tdeui/tests/kblendtest.h create mode 100644 tdeui/tests/kbuttonboxtest.cpp create mode 100644 tdeui/tests/kcharselecttest.cpp create mode 100644 tdeui/tests/kcolordlgtest.cpp create mode 100644 tdeui/tests/kcolortest.cpp create mode 100644 tdeui/tests/kcolortest.h create mode 100644 tdeui/tests/kcomboboxtest.cpp create mode 100644 tdeui/tests/kcomboboxtest.h create mode 100644 tdeui/tests/kcompletiontest.cpp create mode 100644 tdeui/tests/kcompletiontest.h create mode 100644 tdeui/tests/kdatepicktest.cpp create mode 100644 tdeui/tests/kdatetimewidgettest.cpp create mode 100644 tdeui/tests/kdatewidgettest.cpp create mode 100644 tdeui/tests/kdesattest.cpp create mode 100644 tdeui/tests/kdesattest.h create mode 100644 tdeui/tests/kdialogbasetest.cpp create mode 100644 tdeui/tests/kdocktest.cpp create mode 100644 tdeui/tests/kdocktest.h create mode 100644 tdeui/tests/kdockwidgetdemo.cpp create mode 100644 tdeui/tests/kdockwidgetdemo.h create mode 100644 tdeui/tests/kdockwidgettest.cpp create mode 100644 tdeui/tests/kdockwidgettest.h create mode 100644 tdeui/tests/kdualcolortest.cpp create mode 100644 tdeui/tests/kdualcolortest.h create mode 100644 tdeui/tests/keditlistboxtest.cpp create mode 100644 tdeui/tests/kedittest.cpp create mode 100644 tdeui/tests/kfontdialogtest.cpp create mode 100644 tdeui/tests/kgradienttest.cpp create mode 100644 tdeui/tests/kgradienttest.h create mode 100644 tdeui/tests/khashtest.cpp create mode 100644 tdeui/tests/khashtest.h create mode 100644 tdeui/tests/kinputdialogtest.cpp create mode 100644 tdeui/tests/kjanuswidgettest.cpp create mode 100644 tdeui/tests/kledtest.cpp create mode 100644 tdeui/tests/kledtest.h create mode 100644 tdeui/tests/klineeditdlgtest.cpp create mode 100644 tdeui/tests/klineedittest.cpp create mode 100644 tdeui/tests/klineedittest.h create mode 100644 tdeui/tests/klistviewtest.cpp create mode 100644 tdeui/tests/kmainwindowrestoretest.cpp create mode 100644 tdeui/tests/kmainwindowrestoretest.h create mode 100644 tdeui/tests/kmainwindowtest.cpp create mode 100644 tdeui/tests/kmainwindowtest.h create mode 100644 tdeui/tests/kmessageboxtest.cpp create mode 100644 tdeui/tests/knuminputtest.cpp create mode 100644 tdeui/tests/knuminputtest.h create mode 100644 tdeui/tests/kpalettetest.cpp create mode 100644 tdeui/tests/kpanelmenutest.cpp create mode 100644 tdeui/tests/kpanelmenutest.h create mode 100644 tdeui/tests/kpixmapregionselectordialogtest.cpp create mode 100644 tdeui/tests/kpopuptest.cpp create mode 100644 tdeui/tests/kprogresstest.cpp create mode 100644 tdeui/tests/krulertest.cpp create mode 100644 tdeui/tests/krulertest.h create mode 100644 tdeui/tests/kseparatortest.cpp create mode 100644 tdeui/tests/kspelltest.cpp create mode 100644 tdeui/tests/ksqueezedtextlabeltest.cpp create mode 100644 tdeui/tests/kstatusbartest.cpp create mode 100644 tdeui/tests/kstatusbartest.h create mode 100644 tdeui/tests/ksystemtraytest.cpp create mode 100644 tdeui/tests/ktabctltest.cpp create mode 100644 tdeui/tests/ktabctltest.h create mode 100644 tdeui/tests/ktabwidgettest.cpp create mode 100644 tdeui/tests/ktabwidgettest.h create mode 100644 tdeui/tests/ktextedittest.cpp create mode 100644 tdeui/tests/ktimewidgettest.cpp create mode 100644 tdeui/tests/ktoolbarlabelactiontest.cpp create mode 100644 tdeui/tests/ktoolbarlabelactiontestui.rc create mode 100644 tdeui/tests/kunbalancedgrdtest.cpp create mode 100644 tdeui/tests/kunbalancedgrdtest.h create mode 100644 tdeui/tests/kwindowtest.cpp create mode 100644 tdeui/tests/kwindowtest.h create mode 100644 tdeui/tests/kwizardtest.cpp create mode 100644 tdeui/tests/kwordwraptest.cpp create mode 100644 tdeui/tests/kxmlguitest.cpp create mode 100644 tdeui/tests/kxmlguitest.h create mode 100644 tdeui/tests/kxmlguitest_part.rc create mode 100644 tdeui/tests/kxmlguitest_shell.rc create mode 100644 tdeui/tests/qxembedtest.cpp create mode 100644 tdeui/tests/testimage.png create mode 100644 tdeui/ui_standards.rc delete mode 100644 win/pro_files/kdecore/kconfig_compiler/kconfig_compiler.pro delete mode 100644 win/pro_files/kdecore/kdecore.pro delete mode 100644 win/pro_files/kdefx/kdefx.pro delete mode 100644 win/pro_files/kdefx/kdefx_rel.pro delete mode 100644 win/pro_files/kdeprint/kdeprint.pro delete mode 100644 win/pro_files/kdeui/kdeui.pro create mode 100644 win/pro_files/tdecore/kconfig_compiler/kconfig_compiler.pro create mode 100644 win/pro_files/tdecore/tdecore.pro create mode 100644 win/pro_files/tdefx/tdefx.pro create mode 100644 win/pro_files/tdefx/tdefx_rel.pro create mode 100644 win/pro_files/tdeprint/tdeprint.pro create mode 100644 win/pro_files/tdeui/tdeui.pro diff --git a/kdecore/40.colors b/kdecore/40.colors deleted file mode 100644 index 4f08d39c5..000000000 --- a/kdecore/40.colors +++ /dev/null @@ -1,48 +0,0 @@ -KDE RGB Palette -0 0 0 Black -48 48 48 Almost black -88 88 88 Very dark gray -128 128 128 Dark gray -160 160 160 Mid gray -195 195 195 Light gray -220 220 220 Very light gray -255 255 255 White - -64 0 0 Very dark red -128 0 0 Dark red -192 0 0 Mid red -255 0 0 Red -255 192 192 Light red - -0 64 0 Very dark green -0 128 0 Dark green -0 192 0 Mid green -0 255 0 Green -192 255 192 Light green - -0 0 128 Dark blue -0 0 192 Mid blue -0 0 255 Blue -192 192 255 Light blue - -64 64 0 Very dark yellow -128 128 0 Dark yellow -192 192 0 Mid yellow -255 255 0 Yellow -255 255 192 Light yellow - -0 64 64 Very dark cyan -0 128 128 Dark cyan -0 192 192 Mid cyan -0 255 255 Cyan -192 255 255 Light cyan - -128 0 128 Dark magenta -192 0 192 Mid magenta -255 0 255 Magenta -255 192 255 Light magenta - -192 88 0 Dark orange -255 128 0 Orange -255 168 88 Light orange -255 220 168 Very light orange diff --git a/kdecore/AUTHORS b/kdecore/AUTHORS deleted file mode 100644 index a76f6be1e..000000000 --- a/kdecore/AUTHORS +++ /dev/null @@ -1,56 +0,0 @@ -Matthias Kalle Dalheimer : -classes KConfig, KTextStream, KColorSet, KApplication -automake, autoconf, maintenance - -Richard Moore : -KLedLamp class - -Martynas Kunigelis : -KProgress class - -Steffen Hansen : -KURL class - -Torben Weis -DnD stuff, KSocket and KServerSocket classes, KPixmap - -Alexander Sanda -Read and write numerical config entries, KPanner, KTabControl, -KPopupMenu, KMessageBox, KEdit widgets. - -Martin Jones -Bugfixes in KPixmap and KURL, KColorDialog, KSelector - -Keith Brown -KTreeList class - -Bernd Johannes Wuebben -KFontDialog classes - -Tim D. Gilman -KDatePicker, KDateTable class - -Nicolas Hadacek -Key configuration classes, bug fixes - -Michael Will -loading routine in KPixmap - -Christian Czezatke -KProcess class - -Matthias Ettrich -KWM, Changes to KApplication and KIconLoader - -Stephan Kulow -heavy modifications to KURL, autoconf and automake stuff - -Jacek Konieczny -KCharset* classes - -These files are part of GNU Libtool, originally by -Thomas Tanner -ltdl.c + ltdl.h - -Carsten Pfeiffer -KCompletion classes diff --git a/kdecore/CMakeLists.txt b/kdecore/CMakeLists.txt deleted file mode 100644 index 348e80451..000000000 --- a/kdecore/CMakeLists.txt +++ /dev/null @@ -1,209 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_subdirectory( malloc ) -add_subdirectory( network ) -add_subdirectory( kconfig_compiler ) - -if( WITH_LIBART ) - add_subdirectory( svgicons ) - set( KDESVGICONS kdesvgicons-static ) -endif( WITH_LIBART ) - - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/network - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/libltdl - ${CMAKE_SOURCE_DIR}/tdefx - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio/kio - ${LIBART_INCLUDE_DIRS} - ${LIBIDN_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} - ${LIBIDN_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - kconfig.h kconfigskeleton.h kconfigdata.h ksimpleconfig.h - kconfigdialogmanager.h kconfigbase.h kdesktopfile.h - kurl.h ksock.h kaboutdata.h kcmdlineargs.h kconfigbackend.h - kapp.h kapplication.h kuniqueapp.h kuniqueapplication.h - kcharsets.h kdeversion.h kpty.h kprocess.h kprocctrl.h - klocale.h kicontheme.h kiconloader.h kdebug.h kwinmodule.h - kwin.h krootprop.h kshortcut.h kkeynative.h kaccel.h - kglobalaccel.h kstdaccel.h kshortcutlist.h kcatalogue.h - kregexp.h kcompletion.h kstringhandler.h kstddirs.h - kstandarddirs.h kglobal.h kglobalsettings.h ksharedptr.h - kallocator.h kvmallocator.h kcrash.h krfcdate.h kinstance.h - kpalette.h kipc.h klibloader.h ktempfile.h ksavefile.h - krandomsequence.h knotifyclient.h kiconeffect.h kaudioplayer.h - 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 - ktypelist.h ksortablevaluelist.h kdebugclasses.h kclipboard.h - kcalendarsystem.h kcalendarsystemfactory.h kmacroexpander.h - kmanagerselection.h kmountpoint.h kuser.h klockfile.h - kidna.h ktempdir.h kshell.h fixx11h.h kxerrorhandler.h - kdelibs_export.h kde_file.h ktimezones.h - ${CMAKE_CURRENT_BINARY_DIR}/kdemacros.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - - -##### other data ################################ - -tde_install_empty_directory( ${LOCALE_INSTALL_DIR}/all_languages ) - -install( FILES 40.colors Web.colors Royal.colors Rainbow.colors - DESTINATION ${CONFIG_INSTALL_DIR}/colors ) - -install( FILES kdebug.areas kdebugrc language.codes - DESTINATION ${CONFIG_INSTALL_DIR} ) - -install( FILES kmdcodec_compat.h - DESTINATION ${INCLUDE_INSTALL_DIR}/kio RENAME kmdcodec.h ) - -install( FILES eventsrc - DESTINATION ${DATA_INSTALL_DIR}/knotify ) - - -##### libtdecore ################################ - -set( target tdecore ) - -set( ${target}_SRCS - libintl.cpp kapplication.cpp kdebug.cpp netwm.cpp - kconfigbase.cpp kconfig.cpp ksimpleconfig.cpp kconfigbackend.cpp - kmanagerselection.cpp kdesktopfile.cpp kstandarddirs.cpp - ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp klocale.cpp - krfcdate.cpp kiconeffect.cpp kicontheme.cpp kiconloader.cpp - kwin.cpp kwinmodule.cpp krootprop.cpp kcharsets.cpp - kckey.cpp kshortcut.cpp kkeynative_x11.cpp kkeyserver_x11.cpp - kaccelaction.cpp kshortcutmenu.cpp kaccelbase.cpp kaccel.cpp - kglobalaccel_x11.cpp kglobalaccel.cpp kstdaccel.cpp kshortcutlist.cpp - kcrash.cpp kurl.cpp kregexp.cpp kglobal.cpp kglobalsettings.cpp - kallocator.cpp kvmallocator.cpp kmimesourcefactory.cpp - kinstance.cpp kpalette.cpp kipc.cpp klibloader.cpp ktempfile.cpp - kuniqueapplication.cpp kaccelmanager.cpp ksavefile.cpp - krandomsequence.cpp kstringhandler.cpp kcompletion.cpp - kcmdlineargs.cpp kaboutdata.cpp kcompletionbase.cpp knotifyclient.cpp - 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 - kappdcopiface.cpp kappdcopiface.skel kclipboard.cpp - kcheckaccelerators.cpp kdeversion.cpp kdebugdcopiface.cpp - kdebugdcopiface.skel kcalendarsystem.cpp kcalendarsystemgregorian.cpp - kcalendarsystemhijri.cpp kcalendarsystemhebrew.cpp - kcalendarsystemfactory.cpp kmacroexpander.cpp kidna.cpp - ktempdir.cpp kshell.cpp kmountpoint.cpp kcalendarsystemjalali.cpp - kprotocolinfo_tdecore.cpp kprotocolinfofactory.cpp kxerrorhandler.cpp - kuser.cpp kconfigskeleton.cpp kconfigdialogmanager.cpp klockfile.cpp - kqiodevicegzip_p.cpp ktimezones.cpp -) - -tde_add_library( ${target} SHARED AUTOMOC - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - EMBED tdecorenetwork-static - LINK ltdlc-static ${KDESVGICONS} DCOP-shared tdefx-shared ${ZLIB_LIBRARIES} ${LIBIDN_LIBRARIES} ${XCOMPOSITE_LIBRARIES} ICE SM - DEPENDENCIES dcopidl dcopidl2cpp - DESTINATION ${LIB_INSTALL_DIR} -) - - -##### tdefakes_nonpic ########################### - -set( target tdefakes_nonpic ) - -set( ${target}_SRCS - fakes.c vsnprintf.c -) - -tde_add_library( ${target} STATIC - SOURCES ${${target}_SRCS} - DESTINATION ${LIB_INSTALL_DIR} -) - -##### tdefakes_pic ############################## - -set( target tdefakes_pic ) - -set( ${target}_SRCS - fakes.c vsnprintf.c -) - -tde_add_library( ${target} STATIC_PIC - SOURCES ${${target}_SRCS} - DESTINATION ${LIB_INSTALL_DIR} -) - - -##### libtdefakes ############################### - -set( target tdefakes ) - -set( ${target}_SRCS - fakes.c vsnprintf.c -) - -tde_add_library( ${target} SHARED - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - DESTINATION ${LIB_INSTALL_DIR} -) - - -##### kde-config ################################ - -# FIXME still need some research and improvements -configure_file( kde-config.cpp.cmake kde-config.cpp @ONLY ) - - -tde_add_executable( kde-config - SOURCES ${CMAKE_CURRENT_BINARY_DIR}/kde-config.cpp - LINK tdecore-shared - DESTINATION ${BIN_INSTALL_DIR} -) - -##### kgrantpty ################################# - -# FIXME there is something named KDE_USE_FPIE, I'm not sure what is this -#set_target_properties( kgrantpty PROPERTIES COMPILE_FLAGS ${KDE_USE_FPIE} ) -#set_target_properties( kgrantpty PROPERTIES LINK_FLAGS ${KDE_USE_FPIE} ) - -tde_add_executable(kgrantpty SETUID - SOURCES kgrantpty.c - DESTINATION ${BIN_INSTALL_DIR} -) - -##### kdetcompmgr ################################# - -tde_add_executable( kdetcompmgr - SOURCES kdetcompmgr.cpp - LINK tdecore-shared - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/kdecore/DESIGN.COLOR b/kdecore/DESIGN.COLOR deleted file mode 100644 index b997a6de0..000000000 --- a/kdecore/DESIGN.COLOR +++ /dev/null @@ -1,141 +0,0 @@ -Color Management in KDE - -Colors are in important part of KDE and are an important tool to make -a good looking desktop. Colors can also be a burden, especially for -people with visual impairments. - -The goal of color management is to take full advantage of colors while -reducing the disadvantages of color use to a minimum. - -Color Schemes -============= - -Color Management is based around the concept of color schemes. -A color scheme defines colors for different elements in the -UI. The most important factor for the readability of a UI is the -contrast between foreground and background colors. Colors in a color -scheme are therefor grouped in pairs which define the foreground and -background color for a UI element. When composing a color scheme care -should be taken to use sufficiently contrasting colors for fore- and -background in the same group. When using colors in applications, care -should be taken never to mix foreground colors from one group with -background colors from another group: they do not necasserily have any -contrast at all which can lead to a completely unreadable UI. - -Color schemes are supported by Qt (see TQColorGroup) and can be -configured on a KDE wide basis from the Control Panel. The settings -are stored in the global KDE configuration file under the "General" -setting. The KApplication class takes care that the configured -settings are passed on to Qt. Application developers can just use the -values provided by TQColorGroup. - -There are three major color categories: - -General -======= -The colors in this group are used when no particular other group is -relevant. - -TQColorGroup...: ColorRole::Background, background() -KDE config key: background -Control Center: i18n("Window Background") -Description...: General background color -Example use...: Background of dialogs - -TQColorGroup...: ColorRole::Foreground, foreground() -KDE config key: foreground -Control Center: i18n("Window Text") -Description...: General foreground color -Example use...: Text in dialogs - -Text Areas -========== -The colors in this group are used where the user can type text. it is -also used for lists from which the user can choose. - -TQColorGroup...: ColorRole::Base, base() -KDE config key: windowBackground -Control Center: i18n("Standard background") -Description...: Background color for text areas. -Example use...: Background in a word-processor. - -TQColorGroup...: ColorRole::Text, text() -KDE config key: windowForeground -Control Center: i18n("Standard text") -Description...: Text color for text areas. -Example use...: Text in a word-processor. - -TQColorGroup...: ColorRole::Highlight, highlight() -KDE config key: selectBackground -Control Center: i18n("Select background") -Description...: Background color for selected text. -Example use...: In a selection list. - -TQColorGroup...: ColorRole::HighlightedText, highlightedText() -KDE config key: selectForeground -Control Center: i18n("Select text") -Description...: Text color for selected text. -Example use...: In a selection list. - -"Base" and "Text" should have high contrast as well as "Highlight" and -"HighlightedText". In addition, "Highlight"/"HighlightedText" and -"Base"/"Text" are supposed to be sufficiently different to get a clear -indication of what is selected and what is not. - -Buttons -======= -The colors used in this category are used for buttons in the broad -sense, including e.g.scrollbars, menubars and -popup-menus. - -TQColorGroup...: ColorRole::Button, button() -KDE config key: buttonBackground -Control Center: i18n("Button background") -Description...: Background color for buttons. -Example use...: Background color of the OK button in a messagebox. - -TQColorGroup...: ColorRole::ButtonText, buttonText() -KDE config key: buttonForeground -Control Center: i18n("Button text") -Description...: Color for text on buttons. -Example use...: Color of the OK text on a button in a messagebox. - - -In addition to the above colors a number of derived colors are -defined.They are all darker of lighter version of "Background". - -TQColorGroup...: ColorRole::Shadow, shadow() -Description...: Used for shadow effects.(Very dark) - -TQColorGroup...: ColorRold::BrightText, brightText() -Description...: Used for text on pushed pushbuttons - -TQColorGroup...: ColorRole::Light, light() -Description...: Lighter than "Button" - -TQColorGroup...: ColorRole::Midlight, midlight() -Description...: Between "Button" and "Light" - -TQColorGroup...: ColorRole::Dark, dark() -Description...: Darker than "Button" - -TQColorGroup...: ColorRole::Mid, mid() -Description...: Between "Button" and "Dark" - -Well Behaved Aplications -======================== - -Applications should never hardcode colors but always default to the -colors from the users color scheme. This ensures consistency among -applications on the desktop. It also ensures that all applications -are equally readable. - -An application may offer the user an option to change the color of -certain aspects of the application. It should be noted that an -application specific color setting can cause unexpected results when -the user changes its color scheme. The application specific color may -look ugly in combination with other color schemes or the resulting UI -may even become unreadable. Therefor applications specific colors -should be used with care. - - diff --git a/kdecore/DESIGN.iconloading b/kdecore/DESIGN.iconloading deleted file mode 100644 index ceb2ffbce..000000000 --- a/kdecore/DESIGN.iconloading +++ /dev/null @@ -1,187 +0,0 @@ -Discussion of Icon Loading for KDE 3 -==================================================== - -This document describes the design ideas for improving icon loading -in KDE 3. - - -On Wednesday 08 August 2001 04:15 pm, Waldo Bastian wrote: -> On Wednesday 08 August 2001 03:52 pm, Dirk Mueller wrote: -> > On Mit, 08 Aug 2001, Waldo Bastian wrote: -> > > I'm not really sure how to do it... the idea is this: -> > > -> > > A list of shared icons is published somewhere. -> > > Applications load this list -> > > For all icons the application wants to use: -> > > It checks whether a shared version is available, -> > > if so it uses that one. -> > > If not, it loads the icon. -> > > When it has loaded most icons, it somehow (*) adds the icons that it loaded -> > > to the list of published icons. -> > > -> > > I think that the somehow (*) part can be done most reliable by a -> > > central service, e.g. a KDED module. That might also be able to keep -> > > track of usage so that it can throw icons out that aren't used any -> > > more. I think it will be difficult / slow if we need to do ref-counting -> > > for each and every shared icon using some mechanism that involves X. -> > -> > True. but things become a bit complicated if an application reregisters -> > with a different name. or do we handle that already ? -> > -> > what do you do if the DCOP-connection lifetime is crossing the -> > pixmap-lifetime somehow, i.e. the pixmap is still referenced after -> > closing the dcop connection on shutdown ? - -Ok, I have looked into this a bit more and it seems to be rather easy to -create one or more pixmaps in a server process containing icons, a client can -then create a pixmap of the right size itself and with a simple XCopyArea -call, it can copy the icon from the server pixmap to its own pixmap. - -That way the application's pixmap always remain valid. - -Some example code to get the idea: - -Server can publish an icon (test.png) like this: - QImage i("test.png"); - QPixmap p; - p.convertFromImage(i); - qWarning("Handle = %08x", p.handle()); - -Now, if Handle is e.g. 0x06c0000b, the following code (in another process) -can copy this pixmap: - - QPixmap p(35,35); - Drawable src = 0x06c0000b; - XGCValues values; - GC gc = XCreateGC(qt_xdisplay(), src, 0, &values); - XCopyArea(qt_xdisplay(), src, p.handle(), gc, 0, 0, 30, 30, 0, 0); - // 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 -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 -you will remove the actual image data from the pixmap, however, you must make -sure that none of the client apps will be using the outdated index informatin -any more before you can remove the actual image data. - -For practical purposes that might be solved by removing the entry from the -index, informing the applications via DCOP to flush their outdated index -information and then waiting for a sufficient long period, e.. 5 minutes, -before actually removing the image data. - -I can also imagine a scenario where the index information is only used very -temporarily, e.g. during the creation of a KMainWindow (mmap the file in the -constructor, unmap it from the next event loop) that way icons can be removed -from the index and after e.g. a timeout of 5 minutes one can be relatively -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 -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 -use on an average desktop? 50? 200? 500? 500*80bytes = 40Kb, not too bad) we -might want to write out only the updates, that would probably mean that we -need to have some sort of extensible on-disk hash-table. -Would that be worth the hassle? If we need to access hash-buckets throughout -this 40Kb the OS probably ends up writing all of this file to disk ayway. - -Better keep it simple to start with then... - -Cheers, -Waldo --- -KDE 2.2: We deliver. - - do you have any idea how many Kb of pixmaps are stored in the X-server on average? - e.g. with a standard desktop with 5 konsole's and konqueror or os - cause I was wondering... if we copy pixmaps on the X-server with XCopyArea like I proposed in my mail - then the next step could be to use shared pixmaps on the X-server... if the X-server could refcount pixmaps - i don't think it supports that at the moment - I'm not sure, but Konqueror seems to open around 500 icons (some of them repeated), and konsole... 40 ? (I made the experiments with my other computer and it's down at the moment) - and those icons are 22x22? 32x32? - 4 bytes per pixel? - I can have a look to see the sizes (my original experiments counted them in separate counters) - yes, 4 bytes per pixel - that's about 1.5Kb to 4Kb per pixmap - cause I think pixmap space on the X_server is a limited resource - it prolly can cache them in video-memory - Zogje: what worries me most is how to know when to delete a pixmap from X - but if we have the same pixmap 20 times in the X-server - then we are wasting such caching in a terrible way.. and that would cost us performance - antlarr: yes, that's why I say, we would need refcounting in the X-server itself - antlarr: should talk with Keith about that - Zogje: but if you unload the icon after all apps stop using it, then there's no benefit after you start konqueror again, because they'll have to be loaded again - antlarr: but it will be easier to make the point if we have some solid data behind it - antlarr: well.. there are two issues - you'll just stop loading repeated icons that way - 1) you want to have the benefit of caching, and for that you want to have the icon in the cache, you can throw it away after some time if you think it will not be needed any longer - 2) If you actually _share_ the pixmap, you must 100% guarante that the pixmap remains available as long as it is in use - so for the 1)-case there is no hard requirement, it just affects your cache-efficiency - the 2)-case is a hard requirement, in that if you don't meet it, you will have incorrect operation - Zogje: yes - we can meet 2) by coying the pixmap with e.g. XCopyArea - but a better way would be to have refcounting in the server - that's independent from 1) - Yes, that would be much better - antlarr: so if you can provide staticstic on the icons in use on a typical KDE desktop, including total size and number of icons shared, etc. - Zogje: ok, I'll try it tomorrow morning (I think I'll have some time, but little as I'm trying to study for exams) - Btw, do you plan to use a kind of "icon server" ? - antlarr: then we can take that to the XFree guys and say, if you gives us refcounting we can save XXX Kb of pixmap data on the x-server and we think that will give us better performance - Yes, you're right, that would be the best thing to do - in the mean time we might want to implement such an icon-server then, so that when they actually make ref-counting we can hook it in and get the results directly - So you think the apps should load the icon, apply the effects, convert it to a X pixmap and use it. But how do you plan to know if an icon is already in the XServer ? via atoms ? - s/an icon/an icon with the respective effects applied/ - pmax: that's precisely where I want to get to. - antlarr: I would like to publish an index of the icons and their handles through the filesystem - the app loads the icon, applies the effects, when it has finished starting up it - can make a DCOP call to the icon-server and tell it, here, I'm using these icons - then the icon-server can copy (or refcount++) them and update the file with the - published icons - Ok, so there'll be an icon server - yes - Zogje: you can never know when the app has finished starting up, as it can load some icons later than that - you could basically publish the icons via properties on the X server itself as well - but I think that will be slow - Zogje: yes, I think that too - But I'm not sure about the file with published icons - well, when it loads icons later on, it can tell the icon-server about them later on - or just ignore it - whatever works - what happens with remote connections of apps running on different hosts ? - they are on their own - over a slow link - icon server becomes n times slower, right? - pmax: when? - remote X connections - pmax: it doesn't matter if it's a slow or fast link, I'm talking about the problem with loaded icons that are available on one of the computers, but not on another and about the file with the published icons - pmax: if you use X properties you have X-server round-trips, so that will be an issue on slow-links - antlarr: true - pmax: you don't have that if you use the file-system - you can always send icons back and forth with dcop too though - antlarr: we have a DCOP communication space that is limited to a certain host and X-Display - I send x.509's pem encoded through dcop - antlarr: icon caching should happen within that space - antlarr: you can combine multiple spaces in various ways... but they don't communicate with each other - pmax: no, i don't plan too - pmax: it is faster to load the icon from disk than to use dcop, probably - Zogje: ok - Zogje: certainly, but if there is a case where the icon doesn't exist on a remote machine, it could easily be transferred like that - pmax: if the icons doesn't exist you haven't instaled KDE correctly - (I was referring to antlarr's comment) - pmax: why do that if you can just store it in the X server and tell the icon server what icon is yours? - what about an app that is only on one machine but not the other? then it's icons won't be there - pmax?? - antlarr: I'm not saying that's the best way.. I was just saying it's a possibility - pmax: how does that work now? - pmax: Zogje is right, there's no problem with remote apps, it will just not use the icon cache, nothing more - just found it - 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) - 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/kdecore/DESIGN.kconfig b/kdecore/DESIGN.kconfig deleted file mode 100644 index e683566cb..000000000 --- a/kdecore/DESIGN.kconfig +++ /dev/null @@ -1,224 +0,0 @@ -kconfigdata.h contains definitions of the data formats used by kconfig. - -Configuration entries are stored as "KEntry". They are indexed with "KEntryKey". -The primary store is a "KEntryMap" which is defined as a QMap from "KEntryKey" -to "KEntry" - -KEntry's are stored in order in the KEntryMap. The most significant sort -criteria is mGroup. This means that all entries who belong in the same group, -are grouped in the QMap as well. - -The start of a group is indicated with a KEntryKey with an empty mKey and a -dummy KEntry. This allows us to search for the start of the group and then to -iterate until we end up in another group. That way we will find all entries -of a certain group. - -Entries that are localised with the _current_ locale are stored with bLocal -set to true. Entries that are localised with another locale are either not -stored at all (default), or with the localization as part of the key (when -reading a file in order to merge it). -[WABA: Does it make sense to keep both localized and non-localised around? -Can't we just let the localised version override the non-localised version?] - -Currently the localization bit is the least significant sort criteria, that -means that the localised version always follows the non-localised version -immediately. - - -Entries that are being read from a location other than the location to -which is written back are marked as "default" and will be added both as -normal entry as well as an entry with the key marked as default. - -When entries are written to disk, it is checked whether the entry to write -is equal to the default, if so the entry will not be written. The default -entry always follows directly after the normal entry, due to the sorting. -(After that the localised version follows) - -When entries are written to disk, it is checked whether the entry to write -is equal to the default, if so the entry will not be written. - - -Open question: -Should unmodified entries that are written back be compared with the default -too? This seems to be mostly a transition issue. - - -Extra functions: - -bool entryIsImmutable(key); // Can entry be modified? -bool hasDefault(key); // Is there a system wide default set for the entry? -void revertToDefault(key); // Restore to default -void deleteEntry(key); // Remove entry - -Note that there is a subtle difference between revertToDefault() and deleteEntry(). -revertToDefault() will change the entry to the default value set by the system -administrator (Via e.g. $KDEDIR/share/config) or, if no such default was set, -non-existant. -deleteEntry() will make the entry non-existant. - -Entries are marked "immutable" if the key is followed by [$i]. This means -that a user can not override these entries. - -Entries can be marked as deleted if they are followed by [$d]. This -is needed if the system administrator has specified a default value but the -entry was deleted (made 'non-existant'). In that case we can't just leave -the entry out since that would mean we get the default from the system -administrator back the next time we read the file. - - -When an entry is read with readEntry(key, defaultValue), non-existing -entries will return "defaultValue" while hasKey(key) will return "false" -for such entries. - -Currently all entries are stored in memory. When KConfig is "sync()'ed" -it reads the file that it is about to overwrite (for the second time), it -then merges in the entries it has in memory and writes the result back to -the file. It does NOT update its map of entries in memory with the entries -(re)read from disk. It only updates the entries in memory when -"reparseConfiguration()" is called. - - -Open Question: The standard writeEntry() function returns the original value, -is this needed? Nobody seems to use it. - -Open Question: The bPersistent flag doesn't seem to be used... could it be removed? - -Open Question: Is the bNLS flag needed? Localised entries seem to be mostly -useful for default files, are they ever created by the user itself? - -Open Question: Would it be worthwhile to lock a user option that is equal to the -default so that it doesn't change when the default changes? - - -KDE3.0 Changes -============== - -*) writeEntry now returns void instead of QString. -*) deleteEntry functions added - - ------------------------------------------------------------------------------- - -KConfig XT -========== - -My buzzword picker offered KConfig XT ("eXtended Technology") and KConfig NG -("Next Generation"). Since the planned changes are ment to be evolutionary -rather than revolutionary, KConfig NG was dropped. - -Goals -===== - -* Have the default value for config entries defined in 1 place. Currently it is -not uncommon to have them defined in three places: - 1) In the application that reads the setting in order to use it - 2) In the settings dialog when reading the setting - 3) In the settings dialog when selecting "Use defaults". - -* Provide type-information about config entries to facilate "KConfEdit" like -tools. Ideally type-information also includes range-information; this is even -mandatory if enums become an explicit type. - -* Facilitate the documentation of config entries. - - -Instead of relying on the defaults that are hard-coded in the application, -rely on default configuration files being installed in $KDEDIR. The technical -changes required for this are very minimal, it is mostly a change in policy. - -Type information can be provide by preceding every entry with a formalized -comment. - -Work to be done: -* KConfig needs to be extended to provide access to the default values provided -by the default config files. KConfig already stores this information internally. -(DONE) -* A formal comment structure needs to be designed that can convey type-information. -Preferably in such a way that it is easily parsable by both machine and user. -* KConfig needs to be extended, or another class created, that is able to parse -the formalized comments. -* A tool needs to be developed that can assist developers with the generation -and verification of default configuration files including type-information. - -Drawbacks: -* We rely on default configuration files being properly installed. -* The user can break applications by making improper modifications to these -files. -* It is not possible to store defaults settings in a config file that are -of a dynamic nature. Examples are settings derived from other settings, -e.g. a color setting could be derived from the current color theme, or -e.g. the default high score user name which is determined by the user -currently logged in. - - -Some random ideas: -* The format of the entries would be something like this: - -[Mail Settings] -#!Type=string -#!Description=SMTP server to use for sending mail -#!Description[nl]=SMTP server voor het versturen van mail -Host=wantelbos.zogje.fr - -- the type could be subclassed more, e.g. strings can be "email", "hostname", - "url", etc. - -- having translations in these files is very arguable. external po's would be - better. - - - -Class overview - - KConfigBase - | - v - KConfigBackend <-----> KConfig <------> KConfigSkeleton /--< myapp.kcfg - | | | / - v v |*---------------< -KConfigINIBackend KSimpleConfig |kconfig_compiler \ - | \--< myconfig.kcfg-codegen - v - MyConfig <-----KConfigDialogManager----> MyConfigWidget *---< myconfigwidget.ui - uic - -KConfigBase: defines API for generic config class - -KConfig: functional generic config class that supports merging of cascaded - configuration files - -KSimpleConfig: functional generic config class without support for cascading - configuration files. - -KConfigBackend: defines API for config backend, t.i. the actual handling - of the storage method and storage format. - -KConfigINIBackend: the standard (and only one so far) class that implements - the config backend using the file-based .INI format - for configuration files - -KConfigSkeleton: base class for deriving classes that store application - specific options providing type-safety and single-point - defaults. - -MyConfig: An application specific class that offers configuration options - to the applications via variables or accessor functions and that - handles type-safety and defaults. MyConfig is just an example - name, the application developer choses the actual name. - -myapp.kcfg: File describing the configuration options used by a specific - application. myapp.kcfg is just an example name, the application - developer choses the actual name. - -myconfig.kcfg-codegen: Implementation specific code generation instructions - for the MyConfig class. myconfig.kcfg-codegen is - just an example name, the application developer - choses the actual name. - -KConfigDialogManager: Class that links widgets in a dialog up with their - corresponding confguration options in a configuration - object derived from KConfigSkeleton. - -MyConfigWidget: Dialog generated from a .ui description file. Widget names - in the dialog that start with "kcfg_" refer to configuration - options. diff --git a/kdecore/KCONFIG_DESIGN b/kdecore/KCONFIG_DESIGN deleted file mode 100644 index dfd9aa151..000000000 --- a/kdecore/KCONFIG_DESIGN +++ /dev/null @@ -1,51 +0,0 @@ - - The basic design on KConfig for KDE 2.0 and KDE 3.0: - ---------------------------------------- - -KConfig is a hierarchy of classes for loading and saving configuration -data in KDE. KConfigBase is an abstract data type (ADT) with pure -virtual functions which describes the API for accessing configuration -data. It cannot be instantiated directly; only subclasses which -actually implement the API may be created. The reason for this design -is that different ways of storing configuration data in _memory_ may -be desired. The default design uses a QMap (red-black tree) for -storing values in memory once they are read from disk. However, a -different design might use a shared database or something similar to -achieve shared memory config values. The possibilities are endless, -and with this design we insure that future designs will not break -compatibility. - -This means that most classes that currently take pointers to KConfig -objects should be changed to take pointers to KConfigBase objects. -The virtual functions and c++ polymorphism will make sure that the -correct function in the actual, instantiated object are called, but -this lets the user/programmer change the type of KConfig that has been -implemented at runtime without changing other code. - -Similarly, there is a abstract data type KConfigBackEnd. All -reading/writing of the physical, on-disk configuration should be done -through a subclass of KConfigBackEnd. The only class that is -currently implemented right now is KConfigINIBackEnd, which -reads/writes the standard windows INI-style configuration files that -KDE has used since KDE 1.x days. However, it is conceivable that one -might program an XML backend, or even a database/registry style -backend. Again, this abstract data type approach provides flexibility -for the future. Currently KConfig and KSimpleConfig hardcode that -they are using a KConfigINIBackEnd in the constructor. If more back -ends are implemented, this will have to be changed to use a factory -method of some sort to create the backend; all they maintain is a -pointer to a KConfigBackEnd, so the actual type of backend does not -matter. - -If you are interested in using KConfig, you need simply to look at the -public members of KConfigBase. They will provide you with everything -you need to do to look up data, change and write data, etc. If you -are interested in implementing a new KConfig format, look at KConfig -for ideas. Likewise if you want to implement a backend, look at -KConfigINIBackEnd for inspiration. The KDoc-style API documentation -should be complete. If there is anything confusing, please either fix -it in CVS yourself or mail me with your questions, and we will make -sure things get clarified. - - -- Preston Brown diff --git a/kdecore/MAINTAINERS b/kdecore/MAINTAINERS deleted file mode 100644 index 64b825f06..000000000 --- a/kdecore/MAINTAINERS +++ /dev/null @@ -1,116 +0,0 @@ -Here are the code maintainers for each part of this library. Any problems or -suggested patches for a class should be directed to the responsible person for -that class. - -When adding yourself as a maintainer, don't be afraid to reorder the files to a -more logical grouping. - -dmalloc.cpp -kaboutdata.cpp David Faure -kaccel.cpp Ellis Whitehead -kaccelaction.cpp Ellis Whitehead -kaccelbase.cpp Ellis Whitehead -kallocator.cpp Waldo Bastian -kappdcopiface.cpp -kapplication.cpp Waldo Bastian -kaudioplayer.cpp -kcatalogue.cpp Hans Petter Bieker -kcharsets.cpp Lars Knoll -kckey.cpp -kcmdlineargs.cpp Waldo Bastian -kcompletion.cpp Carsten Pfeiffer -kcompletionbase.cpp -kconfig.cpp Waldo Bastian -kconfigbackend.cpp Waldo Bastian -kconfigbase.cpp Waldo Bastian -kcrash.cpp Waldo Bastian -kdcoppropertyproxy.cpp -kdebug.cpp Stephan Kulow -kdesktopfile.cpp -kglobal.cpp Stephan Kulow -kglobalaccel.cpp Ellis Whitehead -kglobalaccel_x11.cpp Ellis Whitehead -kglobalsettings.cpp David Faure -kiconeffect.cpp -kiconloader.cpp -kicontheme.cpp -kinstance.cpp Stephan Kulow -kipc.cpp Lubos Lunak -kkey_x11.cpp Ellis Whitehead -kkeynative_x11.cpp Ellis Whitehead -kkeysequence.cpp Ellis Whitehead -kkeysequence_emb.cpp Ellis Whitehead -klibloader.cpp -klocale.cpp Hans Petter Bieker -kmdcodec.cpp -kmimesourcefactory.cpp -kmultipledrag.cpp David Faure -knotifyclient.cpp -kpalette.cpp Waldo Bastian -kpixmapprovider.cpp Carsten Pfeiffer -kprocctrl.cpp Waldo Bastian -kprocess.cpp Waldo Bastian -kprocio.cpp Waldo Bastian -krandomsequence.cpp Waldo Bastian -kregexp.cpp -krfcdate.cpp Waldo Bastian -krootprop.cpp Lubos Lunak -ksavefile.cpp Waldo Bastian -kshortcut.cpp Ellis Whitehead -ksimpleconfig.cpp Waldo Bastian -ksocks.cpp -kstandarddirs.cpp Waldo Bastian -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 -ktempfile.cpp Waldo Bastian -kuniqueapplication.cpp Waldo Bastian -kurl.cpp Waldo Bastian -kurldrag.cpp David Faure -kwin.cpp Lubos Lunak -kwinmodule.cpp Lubos Lunak -kxmessages.cpp Lubos Lunak -kxerrorhandler.cpp Lubos Lunak -libintl.cpp Hans Petter Bieker -akasyncio.cpp Thiago Macieira -kbufferedio.cpp Thiago Macieira -kextsock.cpp Thiago Macieira -kidna.cpp Thiago Macieira -ksock.cpp Thiago Macieira -ksockaddr.cpp Thiago Macieira -netsupp.cpp Thiago Macieira -network/ Thiago Macieira -netwm.cpp Lubos Lunak -kapplication_win.cpp Jaroslaw Staniek (copyright) -kcalendarsystem.cpp -kcalendarsystemfactory.cpp -kcalendarsystemgregorian.cpp -kcalendarsystemhebrew.cpp Hans Petter Bieker (copyright) -kcalendarsystemhijri.cpp -kcalendarsystemjalali.cpp Arash Bijanzadeh and FarsiKDE Project (copyright) -kcheckaccelerators.cpp Matthias Kalle Dalheimer (kalle@kde.org) (copyright) -kclipboard.cpp Carsten Pfeiffer (copyright) -kconfigdialogmanager.cpp -kconfigskeleton.cpp -kdebugdcopiface.cpp Andreas Beckermann (b_mann@gmx.de) (copyright) -kdeversion.cpp -kglobalaccel_win.cpp Ellis Whitehead (copyright) -kkeyserver_x11.cpp -klockfile.cpp Waldo Bastian (copyright) -kmacroexpander.cpp -kmanagerselection.cpp Lubos Lunak (copyright) -kmountpoint.cpp Waldo Bastian (copyright) -kprotocolinfo_tdecore.cpp Torben Weis (copyright) -kprotocolinfofactory.cpp Torben Weis (copyright) -kprotocolinfofactory.cpp Waldo Bastian (copyright) -kpty.cpp -kshell.cpp Oswald Buddenhagen (copyright) -kshortcutmenu.cpp Ellis Whitehead (copyright) -ktempdir.cpp Joseph Wenninger (copyright) -kuser.cpp Tim Jansen (copyright) -kvmallocator.cpp Waldo Bastian (bastian@kde.org) (copyright) -netsupp_win32.cpp diff --git a/kdecore/Mainpage.dox b/kdecore/Mainpage.dox deleted file mode 100644 index c0e13a339..000000000 --- a/kdecore/Mainpage.dox +++ /dev/null @@ -1,42 +0,0 @@ -/** \mainpage The Trinity Core Library - -All Trinity programs use this library to provide basic functionality such -as the configuration system, IPC, internationalization and locale -support, site-independent access to the filesystem and a large number -of other (but no less important) things. -

-All Trinity applications should link to the tdecore library. Also, using a -KApplication derived class instead of TQApplication is almost -mandatory if you expect your application to behave nicely within the -Trinity environment. - -If you are unsure where to start, have a look at the -tutorials on -the Trinity project site to get you going. - -If you know what you are looking for, you should be able to find it in -the class list or the -modules list. - -@authors -Various: see copyrights on individual files for more information - -@maintainers -See the MAINTAINERS file. - -@licenses -Library: @lgpl
-Some helper utilities: @gpl - -*/ - -/** - -\defgroup TrinityMacros Trinity Macros - -*/ - -// DOXYGEN_EXCLUDE = malloc kde_file.h -// DOXYGEN_SET_INPUT += @topdir@/kdemacros.h.cmake -// DOXYGEN_SET_PROJECT_NAME = TrinityCore -// vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/kdecore/Makefile.am b/kdecore/Makefile.am deleted file mode 100644 index 92ee7ebfc..000000000 --- a/kdecore/Makefile.am +++ /dev/null @@ -1,195 +0,0 @@ -# This file is part of the KDE libraries -# -# $Id$ -# -# Copyright (C) 1996-1997 Matthias Kalle Dalheimer (kalle@kde.org) -# (C) 1997 Stephan Kulow (coolo@kde.org) - -# 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. - -INCLUDES = -I$(top_srcdir)/tdefx -I$(top_srcdir)/tdecore/network $(all_includes) $(LIBART_CFLAGS) - -if include_SVGICONS -SVGICONS=svgicons -SVGICON_LIB=svgicons/libkdesvgicons.la -endif - -SUBDIRS = malloc network $(SVGICONS) . kconfig_compiler tests - -# For the future: examine if condensing the tons of *_LDFLAGS variables -# into $(all_libraries) isn't better -AM_LDFLAGS = $(LDFLAGS_AS_NEEDED) $(LDFLAGS_NEW_DTAGS) - -lib_LTLIBRARIES = libtdefakes.la libtdecore.la -lib_LIBRARIES = libtdefakes_nonpic.a libtdefakes_pic.a - -include_HEADERS = kconfig.h kconfigskeleton.h \ - kconfigdata.h ksimpleconfig.h kconfigdialogmanager.h \ - kconfigbase.h kdesktopfile.h kurl.h ksock.h kaboutdata.h \ - kcmdlineargs.h kconfigbackend.h kapp.h kapplication.h kuniqueapp.h \ - kuniqueapplication.h kcharsets.h kdeversion.h kpty.h kprocess.h \ - kprocctrl.h klocale.h kicontheme.h kiconloader.h kdebug.h \ - kwinmodule.h kwin.h krootprop.h kshortcut.h kkeynative.h kaccel.h \ - kglobalaccel.h kstdaccel.h kshortcutlist.h kcatalogue.h \ - kregexp.h kcompletion.h kstringhandler.h \ - kstddirs.h kstandarddirs.h kglobal.h kglobalsettings.h ksharedptr.h \ - kallocator.h kvmallocator.h kcrash.h krfcdate.h \ - kinstance.h kpalette.h kipc.h klibloader.h ktempfile.h ksavefile.h \ - krandomsequence.h knotifyclient.h kiconeffect.h \ - kaudioplayer.h 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 \ - ktypelist.h ksortablevaluelist.h kdebugclasses.h kclipboard.h \ - kcalendarsystem.h kcalendarsystemfactory.h kmacroexpander.h \ - kmanagerselection.h kmountpoint.h kuser.h klockfile.h \ - kidna.h ktempdir.h kshell.h fixx11h.h kxerrorhandler.h kdelibs_export.h \ - kdemacros.h kde_file.h ktimezones.h - -libtdefakes_la_SOURCES = fakes.c vsnprintf.c -libtdefakes_la_LDFLAGS = -version-info 6:0:2 -libtdefakes_la_LIBADD = $(LIBSOCKET) - -libtdefakes_nonpic_a_SOURCES = fakes_nonpic.c vsnprintf_nonpic.c - -fakes_nonpic.c:$(srcdir)/fakes.c - -rm -f fakes_nonpic.c - $(LN_S) $(srcdir)/fakes.c fakes_nonpic.c - -vsnprintf_nonpic.c: $(srcdir)/vsnprintf.c - -rm -f vsnprintf_nonpic.c - $(LN_S) $(srcdir)/vsnprintf.c vsnprintf_nonpic.c - -libtdefakes_pic.a: libtdefakes.la - -rm -f libtdefakes_pic.a fakes_pic.o vsnprintf_pic.o - cp -f .libs/fakes.o fakes_pic.o; cp -f .libs/vsnprintf.o vsnprintf_pic.o - ar cru libtdefakes_pic.a fakes_pic.o vsnprintf_pic.o - ranlib libtdefakes_pic.a - -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 \ - kcheckaccelerators.h kcalendarsystemgregorian.h \ - kcalendarsystemhijri.h kcalendarsystemhebrew.h kcalendarsystemjalali.h \ - kprotocolinfofactory.h kqiodevicegzip_p.h kiconloader_p.h - -libtdecore_la_SOURCES = libintl.cpp kapplication.cpp \ - kdebug.cpp netwm.cpp kconfigbase.cpp kconfig.cpp ksimpleconfig.cpp \ - kconfigbackend.cpp kmanagerselection.cpp kdesktopfile.cpp \ - kstandarddirs.cpp ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp \ - klocale.cpp krfcdate.cpp kiconeffect.cpp kicontheme.cpp \ - kiconloader.cpp kwin.cpp kwinmodule.cpp krootprop.cpp kcharsets.cpp \ - kckey.cpp kshortcut.cpp kkeynative_x11.cpp kkeyserver_x11.cpp \ - kaccelaction.cpp kshortcutmenu.cpp kaccelbase.cpp kaccel.cpp \ - kglobalaccel_x11.cpp kglobalaccel.cpp kstdaccel.cpp kshortcutlist.cpp \ - kcrash.cpp kurl.cpp kregexp.cpp kglobal.cpp kglobalsettings.cpp \ - kallocator.cpp kvmallocator.cpp kmimesourcefactory.cpp \ - kinstance.cpp kpalette.cpp kipc.cpp klibloader.cpp ktempfile.cpp \ - kuniqueapplication.cpp kaccelmanager.cpp \ - ksavefile.cpp krandomsequence.cpp kstringhandler.cpp kcompletion.cpp \ - kcmdlineargs.cpp kaboutdata.cpp kcompletionbase.cpp knotifyclient.cpp \ - 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 ksycocafactory.cpp ksycoca.skel \ - kxmessages.cpp kstartupinfo.cpp kcatalogue.cpp kasyncio.cpp \ - kmultipledrag.cpp kstaticdeleter.cpp kappdcopiface.cpp \ - kappdcopiface.skel kclipboard.cpp kcheckaccelerators.cpp \ - kdeversion.cpp kdebugdcopiface.cpp kdebugdcopiface.skel \ - kcalendarsystem.cpp kcalendarsystemgregorian.cpp \ - kcalendarsystemhijri.cpp kcalendarsystemhebrew.cpp \ - kcalendarsystemfactory.cpp kmacroexpander.cpp kidna.cpp \ - ktempdir.cpp kshell.cpp kmountpoint.cpp kcalendarsystemjalali.cpp \ - kprotocolinfo_tdecore.cpp kprotocolinfofactory.cpp kxerrorhandler.cpp \ - kuser.cpp kconfigskeleton.cpp kconfigdialogmanager.cpp klockfile.cpp \ - kqiodevicegzip_p.cpp ktimezones.cpp - -libtdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined -libtdecore_la_LIBADD = malloc/libklmalloc.la network/libtdecorenetwork.la $(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la \ - $(LIBART_LIBS) $(LIB_IDN) $(top_builddir)/tdefx/libtdefx.la $(LIB_QT) $(LIBSM) $(LIB_X11) $(LIBZ) $(LIBDL) -libtdecore_la_NMCHECK = $(srcdir)/libtdecore.nmcheck -libtdecore_la_NMCHECKWEAK = $(srcdir)/libtdecore_weak.nmcheck $(srcdir)/libqt-mt_weak.nmcheck \ - $(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/tdecore/standard_weak.nmcheck - -libtdecore_la_METASOURCES = AUTO - -SRCDOC_DEST=$(kde_htmldir)/en/kdelibs/tdecore - -kdebugdir = $(kde_confdir) -kdebug_DATA = kdebug.areas kdebugrc language.codes - -.PHONY: kckey_h parser -kckey_h : $(srcdir)/generate_keys.sh $(QNAMESPACE_H) - (cd $(srcdir) && ./generate_keys.sh $(QNAMESPACE_H)) - -# Also uninstall the old names of the KDE color palette files -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(kde_locale) - $(INSTALL_DATA) $(srcdir)/all_languages.desktop $(DESTDIR)$(kde_locale)/all_languages - $(mkinstalldirs) $(DESTDIR)$(includedir)/kio - $(mkinstalldirs) $(DESTDIR)$(kde_datadir)/knotify - $(INSTALL_DATA) $(srcdir)/eventsrc $(DESTDIR)$(kde_datadir)/knotify/eventsrc - $(INSTALL_DATA) $(srcdir)/kmdcodec_compat.h $(DESTDIR)$(includedir)/kio/kmdcodec.h - rm -f "$(DESTDIR)$(kde_confdir)/colors/40 Colors" - rm -f $(DESTDIR)$(kde_confdir)/colors/Web - rm -f $(DESTDIR)$(kde_confdir)/colors/Royal - -uninstall-local: - -rm -f $(DESTDIR)$(includedir)/kio/kmdcodec.h - -# If you add a color palette file here, please change kdelibs/tdeui/kcolordialog.cpp too to allow to translate the name -colors_DATA = 40.colors Web.colors Royal.colors Rainbow.colors -colorsdir = $(kde_confdir)/colors - -EXTRA_DIST = generate_keys.sh $(kdebug_DATA) \ - DESIGN.COLOR KCONFIG_DESIGN eventsrc \ - kentities.c kentities.gperf makeentities kmdcodec_compat.h \ - all_languages.desktop - -kcharsets.lo: kentities.c - -parser: kentities.gperf - cd $(srcdir) && gperf -a -L "ANSI-C" -E -C -c -o -t -k '*' -Nkde_findEntity -D -Hhash_Entity -Wwordlist_Entity -s 2 kentities.gperf > kentities.c - -bin_PROGRAMS = kde-config kgrantpty - -kde_config_SOURCES = kde-config.cpp -kde_config_LDADD = ./libtdecore.la -kde_config_LDFLAGS = $(KDE_RPATH) $(KDE_MT_LDFLAGS) - -kgrantpty_SOURCES = kgrantpty.c -kgrantpty_CFLAGS= $(KDE_USE_FPIE) -kgrantpty_LDFLAGS = $(KDE_USE_PIE) $(KDE_RPATH) $(all_libraries) - -# kgrantpty needs to be installed setuid root -install-exec-hook: - @(chown 0 $(DESTDIR)$(bindir)/kgrantpty && chmod 4755 $(DESTDIR)$(bindir)/kgrantpty) || echo "Please make kgrantpty setuid root" >&2 - @echo "" - @echo "kgrantpty is by default installed with a set SETUID root bit!" - @echo "This is needed for konsole, etc. to ensure that they can't be eavesdropped." - @echo "" - -DISTCLEANFILES = kde-config.cpp - -DOXYGEN_REFERENCES = dcop tdeui kparts kio -DOXYGEN_EXCLUDE = malloc kde_file.h -DOXYGEN_SET_WARN_IF_UNDOCUMENTED = YES - -include ../admin/Doxyfile.am diff --git a/kdecore/README b/kdecore/README deleted file mode 100644 index ec99f440f..000000000 --- a/kdecore/README +++ /dev/null @@ -1,3 +0,0 @@ -This is the KDE "core" library. The tdecore library provides basic non user -interface functionality. - diff --git a/kdecore/README.exec b/kdecore/README.exec deleted file mode 100644 index f2065b7ad..000000000 --- a/kdecore/README.exec +++ /dev/null @@ -1,41 +0,0 @@ -Starting other programs - -In KDE 2 and KDE 3 there are several ways to start other programs from within -your application. Here is a short summary of your options with reasons why -you should or should not use them. - -1. fork + exec - -You never want to use this unless you have a very good reason why it is -impossible to use KProcess. - -2. KProcess - -You want to use this if you need to start a new process which needs to be a -child of your process, e.g. because you want to catch stdout/stderr or need -to send it data via stdin. You should never use this to start other KDE -applications unless your application is called kgdb :-) If you need to -send/receive text like data to/from the process, you are probably better -off with KProcIO - -3. KProcIO - -Like KProcess. Unlike KProcess, this class actually makes it easy to -send data to and receive data from the process. - -4. startServiceByDesktopPath - -Preferred way to launch desktop (KDE/Gnome/X) applications or KDE services. -The application/service must have a .desktop file. It will make use of -KDEinit for increased startup performance and lower memory usage. These -benefits only apply to applications available as KDEinit loadable module (KLM) - -5. KRun - -Generic way to open documents/applications/shell commands. Uses -startServiceBy.... where applicable. Offers the additional -benefit of startup-notification. -KRun can start any application, from the binary or the desktop file, -it will determine the mimetype of a file before running the -preferred handler for it, and it can also start shell commands. -This makes KRun the recommended way to run another program in KDE 2. diff --git a/kdecore/README.kiosk b/kdecore/README.kiosk deleted file mode 100644 index cd59f8db3..000000000 --- a/kdecore/README.kiosk +++ /dev/null @@ -1,681 +0,0 @@ -In KDE3 a kiosk-framework has been introduced. - -One of the driving forces behind KDE is to put the user in control and -give him or her a large amount of possibilities to adjust KDE to his or her -liking. However, in some situations it is required to reduce the possibilities -of KDE, e.g. because the system is to be used for one or more specific -dedicated tasks only. - -The kiosk-framework provides an easy way to disable certain features within -KDE to create a more controlled environment. - -KDE's kiosk-framework builds on KDE's configuration framework and adds a -simple application API that applications can query to get authorisation -for certain operations. - -The KDE kiosk-framework should be used IN ADDITION to the standard UNIX -security measures. - -The configuration framework in KDE3 -=================================== - -Since the very beginning KDE makes use of file-hierarchy to store resources -for its applications. Resources range from icons, wallpapers, fonts to -sounds, menu-descriptions and configuration files. - -In KDE1 there were two locations were resources could be located: The -resources provided by the system were located under $KDEDIR and user- -specific resources were located under $HOME/.kde. - -In KDE2 resource management has been largely abstracted by the introduction -of the KStandardDirs class and has become much more flexible. The user / -administrator can now specify a variable number of locations where resources -can be found. A list of locations can either be specified via $KDEDIRS -(notice the extra 'S'), via /etc/kderc and even via the kdeglobals config -file. The location where user-specific resources can be found can be -set with $KDEHOME (The default is $HOME/.kde). Changes made by the user -are always written back to $KDEHOME. - -Both KDE1 and KDE2 feature so called "cascading configuration files": There -can be multiple configuration files with the same name in the various -locations for (config) resources, when that is the case, the information of -all these configuration files is combined on a key by key basis. If the same -key (within a certain group) is defined in more than one place, the value -of the key for the config file that was read last will override any previously -read values. Configuration files under $KDEHOME are always read last. This -ensures that after a configuration entry is written, the same value wil be -read back. - -In KDE3 two important changes have been made: - -* Default values are no longer written. -When a configuration file in a location other than $KDEHOME defines a value -for a key and the application subsequently writes out a new configuration file -to $KDEHOME, that configuration file will only contain an entry for the key -if its value differs from the value read from the other file. - -This counters the problem that changing default configuration files under -$KDEDIR would not take effect for users, since these users would most likely -have their own copy of these settings under $KDEHOME. KDE3 will make sure -not to copy these settings so changes made under $KDEDIR will affect all users -that haven't explicitly changed the affected settings to something else. - -* Configuration entries can be marked "immutable". -Starting with KDE3, configuration entries can be marked "immutable". When a -configuration entry is immutable it means that configuration files that are -read later will not be able to override its value. Immutable entries cannot -be changed via KConfig and if the entry is present under $KDEHOME it will -be ignored. - -Entries can be marked immutable on 4 different levels: - -- On an entry by entry basis by appending "[$i]" after the key. - -Example: -[MyGroup] -someKey[$i]=42 - -- On a group by group basis by appending "[$i]" after the group. All entries -specified in the group will be marked immutable and no new entries can be -added to the group. - -Example: -[MyGroup][$i] -someKey=42 - -- On a file by file basis by starting the file with [$i]. - -Example: -[$i] -[MyGroup] -someKey=42 -[MyOtherGroup] -someOtherKey=11 - -- On a directory basis. [Not yet implemented] - -- The filesystem can also be used to mark files immutable. If KDE does not -have write-access to the user's version of a configuration file, the file -will be automatically considered immutable. - -To make the configration file of kicker (the panel) immutable one could for -example use the commands below. - -Example: -chown root.root /home/user/.kde/share/config/kickerrc -chmod 644 /home/user/.kde/share/config/kickerrc - -If you do this, the user will be warned that the configuration file is not -writable. Since you will normally not want that, you can add the following -two lines to the application's configuration file (or to kdeglobals to -disable the warning for all applications): - -[KDE Action Restrictions] -warn_unwritable_config=false - -Note that the avove example is not fool-proof, the user can potentially still -rename either the root-owned kickerrc file or any of the directories in -the path to another name and create a new kickerrc _with_ write-access. - -KDE3 Action Restrictions -======================== - -Most functionality within KDE is coupled to so called actions. For example when a user -selects the File->Open option in the menubar of a KDE application, the "file_open" -action is activated. Likewise, toolbar icons are usually also coupled to actions. KDE -makes it possible to disable functionality by restricting specific actions. By restricting the -"file_open" action for example, the corresponding entry in the menubar and the corresponding icon on -the toolbar, if any, will disappear. - -To restrict access to function the kdeglobals file should contain the -group "[KDE Action Restrictions]", each action can then be restricted by -adding "=false". E.g. to disable the action "shell_access" one -would add: -[KDE Action Restrictions][$i] -shell_access=false - -Actions that refer to menu and toolbar actions are prefixed with 'action/'. -The following standard actions are defined: - -action/file_new -action/file_open -action/file_open_recent -action/file_save -action/file_save_as -action/file_revert -action/file_close -action/file_print -action/file_print_preview -action/file_mail -action/file_quit -action/edit_undo -action/edit_redo -action/edit_cut -action/edit_copy -action/edit_paste -action/edit_select_all -action/edit_deselect -action/edit_find -action/edit_find_next -action/edit_find_last -action/edit_replace -action/view_actual_size -action/view_fit_to_page -action/view_fit_to_width -action/view_fit_to_height -action/view_zoom_in -action/view_zoom_out -action/view_zoom -action/view_redisplay -action/go_up -action/go_back -action/go_forward -action/go_home -action/go_previous -action/go_next -action/go_goto -action/go_goto_page -action/go_goto_line -action/go_first -action/go_last -action/bookmarks // See note below -action/bookmark_add -action/bookmark_edit -action/tools_spelling -action/options_show_menubar -action/options_show_toolbar // See note below -action/options_show_statusbar -action/options_save_options -action/options_configure -action/options_configure_keybinding -action/options_configure_toolbars -action/options_configure_notifications -action/help // See note below -action/help_contents -action/help_whats_this -action/help_report_bug -action/help_about_app -action/help_about_kde -action/fullscreen - -Actions in the KDE File Dialog: -action/home // Go to home directory -action/up // Go to parent directory -action/back // Go to previous directory -action/forward // Go to next directory -action/reload // Reload directory -action/mkdir // Create new directory -action/toggleSpeedbar // Show/hide sidebar -action/sorting menu // Sorting options -action/short view // Select short view -action/detailed view // Select detailed view -action/show hidden // Show/hide hidden files -action/preview // Show/hide preview -action/separate dirs // Show/hide separate directories - - -Konqueror & KDesktop related: -action/editfiletype -action/properties -action/openwith -action/openintab -action/kdesktop_rmb // RMB menu, see note below -action/iconview_preview -action/sharefile // File sharing, see note below -action/sendURL // Send Link Address -action/sendPage // Send File -action/devnew // Create New -> Device -action/incIconSize // Increase icon size -action/decIconSize // Decrease icon size -action/go // Entire go menu -action/configdesktop // Configure desktop in RMB menu, see also Control Module Restrictions -action/executeshellcommand // In Konqueror Tools menu, see also shell_access -action/show_dot // Show Hidden Files, see note below - - -Kicker related: -action/kicker_rmb // RMB menu -action/menuedit - - -KWin related: -action/kwin_rmb // RMB window context menu - -Konsole related: -action/konsole_rmb // RMB context menu - -action/settings // Entire settings menu -action/show_menubar -action/show_toolbar -action/scrollbar -action/fullscreen -action/bell -action/font -action/keyboard -action/schema -action/size -action/history -action/save_default -action/save_sessions_profile -action/options_configure_notifications -action/options_configure_keybinding -action/options_configure - -action/send_signal -action/bookmarks -action/add_bookmark -action/edit_bookmarks -action/clear_terminal -action/reset_clear_terminal -action/find_history -action/find_next -action/find_previous -action/save_history -action/clear_history -action/clear_all_histories -action/detach_session -action/rename_session -action/zmodem_upload -action/monitor_activity -action/monitor_silence -action/send_input_to_all_sessions -action/close_session -action/new_session -action/activate_menu -action/list_sessions -action/move_session_left -action/move_session_right -action/previous_session -action/next_session -action/switch_to_session_1 -action/switch_to_session_2 -action/switch_to_session_3 -action/switch_to_session_4 -action/switch_to_session_5 -action/switch_to_session_6 -action/switch_to_session_7 -action/switch_to_session_8 -action/switch_to_session_9 -action/switch_to_session_10 -action/switch_to_session_11 -action/switch_to_session_12 -action/bigger_font -action/smaller_font -action/toggle_bidi - - - -Notes: -* action/options_show_toolbar will also disable the "Toolbars" submenu - if present. -* action/bookmarks also disables action/bookmark_add and action/bookmark_edit -* action/help is not yet fully implemented -* action/kdesktop_rmb disables the RMB menu but some actions may still be accesible - via keyboard shortcuts: cut/copy/rename/trash/delete -* action/iconview_preview disables the option to toggle previews on or off - in icon mode but the actual preview settings remains unaffected. - To disable previews you also need to add the following lines to - konqiconviewrc: - [Settings] - PreviewsEnabled[$i]=false -* action/show_dot disables the option to toggle showing hidden files, the actual - setting remains unaffected. - To disable showing hidden files, add the following lines to konqiconviewrc: - [Settings] - ShowDotFiles[$i]=false -* action/sharefile disables file sharing from the UI, but you may also want - to disable filesharing altogether. - - -Applications may use additional actions that they defined themselves. -You can get a list of the actions used by a certain applications by using the -following dcop command: - -dcop qt objects | grep KActionCollection/ | cut -d '/' -f 3 - -or with - -dcop actions - - -Actions that refer to applications that need to be run as a different user -are prefixed by user/ and identified by the username. For example: - -user/root=false - -will disable all application entries that require root access. - - -Printing related action restrictions: - -print/system - - disables the option to select the printing system (backend). It is - recommended to disable this option once the correct printing - system has been configured. - -print/properties - - disables the button to change printer properties or to add a new printer. - -print/options - - disables the button to select additional print options. - -print/copies - - disables the panel that allows users to make more than one copy. - -print/selection - - disables the options that allows selecting a (pseudo) printer or - change any of the printer properties. Make sure that a proper - default printer has been selected before disabling this option. - Disabling this option also disables print/system, print/options - and print/properties. - -print/dialog - - disables the complete print dialog. Selecting the print option will - immediately print the selected document using default settings. - Make sure that a system wide default printer has been selected. - No application specific settings are honored. - -Other defined actions: - -shell_access - - defines whether a shell suitable for entering random commands - may be started. This also determines whether the "Run Command" - option (Alt-F2) can be used to run shell-commands and arbitrary - executables. Likewise, executables placed in the user's - Autostart folder will no longer be executed. Applications can - still be autostarted by placing .desktop files in the $KDEHOME/Autostart - or $KDEDIR/share/autostart directory. - See also run_desktop_files. - -custom_config - - defines whether the --config command line option should be honored. - The --config command line option can be used to circumvent - locked-down configuration files. - -logout - - defines whether the user will be able to logout from KDE. - -lock_screen - - defines whether the user will be able to lock the screen. - -run_command - - defines whether the "Run Command" (Alt-F2) option is available. - -movable_toolbars - - define whether toolbars may be moved around by the user. - See also action/options_show_toolbar. - -editable_desktop_icons - - define whether icons on the desktop can be moved, renamed, - deleted or added. You might want to set the path for - the Desktop to some read-only directory as well. - (Instead of $HOME/Desktop) - -run_desktop_files - - defines whether users may execute desktop files that are not - part of the default desktop, KDE menu, registered services and - autostarting services. - * The default desktop includes the files under - $KDEDIR/share/kdesktop/Desktop but _NOT_ the files under - $HOME/Desktop. - * The KDE menu includes all files under $KDEDIR/share/applnk and - $XDGDIR/applications - * Registered services includes all files under $KDEDIR/share/services. - * Autostarting services include all files under $KDEDIR/share/autostart - but _NOT_ the files under $KDEHOME/Autostart - - You probably also want to activate the following resource - restictions: - "appdata_kdesktop" - To restrict the default desktop. - "apps" - To restrict the KDE menu. - "xdgdata-apps" - To restrict the KDE menu. - "services" - To restrict registered services. - "autostart" - To restrict autostarting services. - Otherwise users can still execute .desktop files by placing them - in e.g. $KDEHOME/share/kdesktop/Desktop - -lineedit_text_completion - - defines whether input lines should have the potential to remember - any previously entered data and make suggestions based on this - when typing. When a single account is shared by multiple people you - may wish to disable this out of privacy concerns. - -start_new_session - - defines whether the user may start a second X session. - See also the kdm configuration. - -switch_user - - defines whether user switching via kdm is allowed - -skip_drm - - defines if the user may omit DRM checking. - Currently only used by kpdf - -Screensaver related: -opengl_screensavers - - defines whether OpenGL screensavers are allowed to be used. - -manipulatescreen_screensavers - - defines whether screensavers that manipulate an image of the screen - (e.g. moving chunks of the screen around) are allowed to be used. - -When configuration files are marked immutable in whole or in part the user will no -longer be able to make permanent changes to the settings that have been marked -immutable. Ideally the application will recognize this and will no longer offer the -user the possibility to change these settings. Unfortunately not all applications -support this at the moment. It's therefor possible that the user will still be -presented with an option in the user interface to change a setting that is -immutable, changes made this way will not be saved though. In some cases the -user may be able to use the changed setting till the application terminates, in -other cases the changed setting will simply be ignored and the application will -continue to work with the immutable setting. - -The following applications currently detect when their configuration files have been -marked immutable and adjust their user interface accordingly: - -* kicker - By marking the kickerrc config file as immutable, the panel will be -"locked down" and it will not be possible to make any changes to it. - -* kdesktop - By marking the kdesktoprc config file as immutable, the desktop -will be "locked down" and it will no longer be possible to select -"Configure Desktop" from its menus. - -* kcalc - By marking the kcalcrc config file as immutable, the "Configure" button -will not be shown - -Application .desktop files can have an additional field "X-KDE-AuthorizeAction". -If this field is present the .desktop file is only considered if the action(s) -mentioned in this field has been authorized. If multiple actions are listed -they should be separated by commas (','). So if the .desktop file of an application -lists one or more actions this way and the user has no authorization for one -of these actions then the application will not appear in the KDE menu and will not -be used by KDE for opening files. - -IMPORTANT NOTE: -Changing restrictions may influence the data that is cached in the ksycoca -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 -to be rebuild the next time the user logs in. - -KDE3 URL Restrictions -===================== - -It is also possible to restrict URL related actions. The restriction framework -can disable URL actions based on the action, the URL in question and in some cases -the referring URL. URLs can be matched based on protocol, host and path. - -The syntax for adding URL action restrictions to kdeglobals is as follows: - -[KDE URL Restrictions] -rule_count= -rule_1=,,,,,,, -... -rule_N=,,,,,,, - -The following actions are supported: -redirect - e.g. a html-page obtained via HTTP could redirect itself to file:/path/some-file. This - is disabled by default but could be explicitly enabled for a specific HTTP host. - This also applies to links contained in html documents. - Example: rule_1=redirect,http,myhost.acme.com,,file,,,true - -list - This controls which directories can be browsed with KDE's file-dialogs. If a user - should only be able to browse files under home directory one could use: - rule_1=list,,,,file,,,false - rule_2=list,,,,file,,$HOME,true - The first rule disables browing any directories on the local filesystem. The second rule - then enables browsing the users home directory. - -open - This controls which files can be opened by the user in applications. It also - affects where users can save files. To only allow a user to open the files - in his own home directory one could use: - rule_1=open,,,,file,,,false - rule_2=open,,,,file,,$HOME,true - rule_3=open,,,,file,,$TMP,true - Note that with the above, users would still be able to open files from - the internet. Note that the user is also given access to $TMP in order to - ensure correct operation of KDE applications. $TMP is replaced with the - temporary directory that KDE uses for this user. - -Some remarks: -* empty entries match everything -* host names may start with a wildcard, e.g. "*.acme.com" -* a protocol also matches similar protocols that start with the same name, - e.g. "http" matches both http and https. You can use "http!" if you only want to - match http (and not https) -* specifying a path matches all URLs that start with the same path. For better results - you should not include a trailing slash. If you want to specify one specific path, you can - add an exclamation mark. E.g. "/srv" matches both "/srv" and "/srv/www" but "/srv!" only - matches "/srv" and not "/srv/www". - - -KDE3 Resource Restrictions -========================== -Most KDE applications make use of additional resource files that are typically -located in directories under $KDEDIR/share. By default KDE allows users to -override any of these resources by placing files in the same location -under $KDEHOME/share. For example, Konsole stores profiles under -$KDEDIR/share/apps/konsole and users can add additional profiles by -installing files in $KDEHOME/share/apps/konsole. - -KDE3 Resource Restrictions make it possible to restrict the lookup of files -to directories outside of $KDEHOME only. - -The following resources are defined: - -autostart - share/autostart -data - share/apps -html - share/doc/HTML -icon - share/icon -config - share/config -pixmap - share/pixmaps -apps - share/applnk -xdgdata-apps - share/applications -sound - share/sounds -locale - share/locale -services - share/services -servicetypes - share/servicetypes -mime - share/mimelnk -wallpaper - share/wallpapers -templates - share/templates -exe - bin -lib - lib - -For the purpose of resource restrictions there are two special resources: -all - covers all resources -data_ - covers the sub section for in the data resource. - -To restrict resources the kdeglobals file should contain the -group "[KDE Resource Restrictions]", each resource can then be restricted by -adding "=false". E.g. to restrict the "wallpaper" resource to -$KDEDIR/share/wallpapers one would add: -[KDE Resource Restrictions][$i] -wallpaper=false - -And to prevent a user from adding additional konsole profiles, one would add: -[KDE Resource Restrictions][$i] -data_konsole=false - - -Control Module Restrictions -=========================== - -It is possible to restrict access to particular control modules. -Although it is possible to remove control modules from the Control -Center by editing the menu structure, such modules will then still -be available to applications. A better way is to use the control -module restrictions offered by KIOSK: - -[KDE Control Module Restrictions][$i] -=false - -Some example menu-ids are: - -kde-display.desktop -kde-proxy.desktop -kde-screensaver.desktop - -See also kcmshell --list for a list of all the base names. - -Expansion of environment variables in KDE config files. -======================================================= - -In KDE3.1 arbitrary entries in configuration files can contain environment -variables. In order to use this the entry must be marked with [$e]. - -Example: -Name[$e]=$USER - -When the "Name" entry is read $USER will be replaced with the value of the -$USER environment variable. Note that the application will replace $USER -with the value of the environment variable after saving. To prevent this -combine the $e option with $i (immmutable) option. - -Example: -Name[$ei]=$USER - -The above will make that the "Name" entry will always return the value of -the $USER environment variable. The user will not be able to change this entry. - -The following syntax is also supported: -Name[$ei]=${USER} - - -Shell Commands in KDE config files. -=================================== - -In KDE3.1 arbitrary entries in configuration files can contain shell -commands. This way the value of a configuration entry can be determined -dynamically at runtime. In order to use this the entry must be marked -with [$e]. - -Example: -Host[$e]=$(hostname) - - -KDE3 Kiosk Application API -========================== - -Three new methods have been added to KApplication: - -- bool authorize(QString action); // Generic actions -- bool authorizeKAction(QString action); // For KActions exclusively -- bool authorizeURLAction(QString, referringURL, destinationURL) // URL Handling - -Automatic Logout -================ - -Since KDE 3.4 it is possible to automatically logout users that have been idle -for a certain period of time. - -WARNING: Be careful with this option, logging out a user may result in dataloss! - -In kdesktoprc you can use the following entry to enable automatic logout: - -[ScreenSaver] -AutoLogout=true -AutoLogoutTimeout=600 - -The AutoLogoutTimeout is the time in seconds that the user has to be idle before -his session is logged out. diff --git a/kdecore/README.kstartupinfo b/kdecore/README.kstartupinfo deleted file mode 100644 index cbb6a6dfb..000000000 --- a/kdecore/README.kstartupinfo +++ /dev/null @@ -1,282 +0,0 @@ -$Id$ - - -Application startup notification -Lubos Lunak --------------------------------- --------------------------------- - - - When a new application is started in KDE, together with it a startup -notification is sent, which is used to show a startup entry in taskbar, -the busy icon next to the cursor and put the window of the started app -on correct desktop. - This application startup notification ( ASN for short in the following -text ) usually works fine without problems, but some applications and -some special cases may need special handling. - Right now, this is only an internal KDE standard, but since a toolkit -support would improve the results a bit, I'll try to discuss this -on http://www.freedesktop.org . - - -Starting apps with ASN : -------------------------- - - When an application is started from the K-Menu or the minicli, and from other -places, ASN is sent automatically for it, assuming a matching .desktop file -is found for the starting application. Application without a .desktop file -don't get ASN ( this may change, but it's unlikely as it creates too many -ASNs which will stay too long until a timeout ). For improving the quality -of ASN and reducing the number of ASNs that don't detect when the application -has started, some .desktop file entries may be helpful ( see below ). - If you want to start an application in your code, prefer using KRun or -KApplication::startServiceByXXX() calls. Classes like KProcess don't create -ASN, so if you need to use it, you have to send it manually ( only in case -ASN is useful in this case, it shouldn't be sent e.g. for system processes ). - - -.desktop files : ------------------ - -These following .desktop file entries affect ASN : - -X-KDE-StartupNotify= - - if true, this app/service will get app startup notify - - if false, this app/service will _not_ get app startup notify - - if not set - - if it's service, it will _not_ get app startup notify - - if it's app, it will get app startup notify, but - X-KDE-WMClass will be assumed to be "0" ( non-compliant ) -X-KDE-WMClass= - - if set, and it's different from "0" ( without quotes ), this - is the WMClass value for startup notification - - if it's "0" ( without quotes ), such app is considered non-compliant, - and the startup notification will stop - - either if its windows is correctly detected using the default - WMClass value ( the name of the binary ) - - or if a window is mapped that is not recognized ( doesn't have - neither _KDE_STARTUP_ID nor _NET_WM_PID property /*CHECKME*/), - it's assumed this window belongs to the started app; - the start-on-desktop feature won't work then too - - if not set, it defaults to the binary name of the app ( ok for most apps, - including KDE ones ) - - to get the WMCLASS value for any app, run 'xprop' and click on the app's - window, WMCLASS value for this app should be any of the strings listed - in the WM_CLASS property ( it's usually the same as the name of the - app's binary file, in such case it doesn't need to be explicitly set ) -MapNotify= - - this key is obsolete - - true is equivalent to X-KDE-StartupNotify=true and no X-KDE-WMClass set - - false is equivalent to X-KDE-StartupNotify=true and X-KDE-WMClass=0 - - many .desktop files in KDE ( especially in kdebase/kappfinder ) - seem to have MapNotify=false even though it's not needed, this - needs to be checked and replaced by the needed X-KDE-* values, - often just X-KDE-StartupNotify=true should be enough - - The best way to check if the entries are set correctly is to start -the application and switch to other desktop. If the startup notification -disappears and the application appears on the desktop on which it was -started, it's correct ( with X-KDE-WMClass=0, the start-on-desktop -feature may not work ). - - Ideally, every .desktop file should have X-KDE-StartupNotify set to the correct -value, and for apps which need it also X-KDE-WMClass should be set. This -sometimes gives slightly better behavior than when these entries are not set. - - -The KStartupInfo classes : --------------------------- - - In some cases, or if you are interested in getting the ASN information, you -have to use the KStartupInfo classes in kdelibs/tdecore. - -Receiving the application startup notification information : ------------------------------------------------------------- - - Create an instance of class KStartupInfo and connect to its slots, they -will be emitted whenever a ASN info is received. - The clean_on_cantdetect argument to the constructor means whether all -ASN info for non-compliant apps should be removed when a window is mapped -which cannot be identified ( it's not possible to say if it belong to one -of the starting applications or not ). If the argument is true, it is -assumed that the window does belong to one of the starting applications, -and all ASN info for non-compliant apps must be removed, otherwise the ASN -info would timeout ( e.g. kdesktop sets it to true, otherwise the busy -icon would sometimes stay for too long, which is oftern annoying ). -On the other hand, KWin, which maps the first window of the starting apps -to the given virtual desktop, sets it to false, because there's no visual -representation and if a window for a starting non-compliant application is -detected later, it still will be successfully places on the correct virtual -desktop. - Note that the ASN info is often send in several messages, and the slots -will be therefore emitted several times, with the updated info ( e.g. the -binary name or PID is not know from the beginning ). - -Sending the application startup notification information : ----------------------------------------------------------- - - Before an application is started, ASN info for it must be sent ( unless -it's done by classes like KRun ). See e.g. KRun sources for details. - During the starting of the application, the info may need some updating -( e.g. right after starting the app, the PID with hostname may be sent, -or a PID change when KUniqueApplication forks into background ). - When it's detected that the started process exited, it an ASN info -about the finished process should be sent. Since the application may -have forked into background, the finish info should include the PID -and hostname, and the notification will be stopped only if there's -no other PID for it. On the other hand, if you simply really need -to stop ASN, send only the identification ( KStartupInfo::sendFinish() -with only KStartupInfoId argument ). - - - -Implementation details : ------------------------- - - The ASN info data is sent using X ClientMessages as text ( see below ), -this is mainly in hope also non-KDE people will start using it, and -they wouldn't be very happy with DCOP. - Before starting an application, and environment variable called -KDE_STARTUP_ENV is added to it's environment, and it's set to unique -identifier of its startup notification, or "0" for disabled ASN. -Ideally, the application should read it, and set a window property -called _KDE_STARTUP_ID ( type XA_STRING ) at least on its first mapped -toplevel window to this value. It should also unset it, so it doesn't get -propagated to other applications started from it. It should also -update the ASN info when necessary, e.g. when KUniqueApplication -forks into background, it sends the PID change. That's how compliant -applications should work, and this support for ASN should be provided -by toolkits. All KDE application should be compliant by now, since -kdelibs do all the necessary things. The KDE_STARTUP_ENV variable -is read and unset in KApplication constructor, and _KDE_STARTUP_ID -is set on every toplevel window in KApplication::setTopWidget(). - However, majority of applications aren't compliant now, and even -if I succeed making this thing a standard ( part of NETWM_SPEC -or whatever ), there still will be old applications that won't behave -this way. Not unsetting KDE_STARTUP_ENV is not a big problem, since -the ASN for its value will usually timeout, and when the app starts -a new application, this ASN identification value will get reused without -problems. The other problem is detecting, which newly mapped windows -belong to which starting application. If a newly mapped window doesn't -have _KDE_STARTUP_ID property, the code tries to read its _NET_WM_PID -property, and if it's set, it tries to match it ( together with -WM_CLIENT_MACHINE ) with PIDs of all ASN infos. And if the window -doesn't have even the _NET_WM_PID property, WM_CLASS property is used -then. It's usually set to two strings, and at least one of them is -usually the binary name of the application, so it's converted -to lowercase and compared. For applications, where such comparison -would fail, the X-KDE-WMClass .desktop file entry should be set -to the correct WMClass value ( e.g. for XEmacs, the binary name -is 'xemacs', but WM_CLASS is 'emacs', 'Emacs', so its X-KDE-WMClass -in its .desktop file should be set to 'emacs' - the case doesn't -matter ). - The ASN identification string must be a unique string for every ASN. -In KStartupInfo class, it's created as 'hostname;tm.sec;tm.usec;pid', -tm being the current time. If the identification string is set to "0", -it means no ASN should be done ( e.g. for things like kio_uiserver, -which shouldn't get ASN ). Empty identification string means the same -like "0", except for the call to KStartupInfoId::initId(), where it means -to create a new one. - - -Format of the text messages : ------------------------------ - -There are 3 types of messages : - - new: message - - this message announces that a new application is being started, - if there is not ASN info for this ASN identification, it should be - updated, otherwise it will be created - - the text of the message starts with 4 characters 'new:', followed - by the text entries ( see below ) - - change: message - - this message is like new: message, but it's only for updating existing - ASN info, if there's no ASN info for the given identification, it won't - be created. This is used e.g. in KUniqueApplication when it forks - into background and sends info about the PID change - it should update - any existing ASN info, but mustn't create a new one, otherwise there - could appear ASN even for applications which shouldn't have ASN - - the text of the message starts with 4 characters 'change:', followed - by the text entries ( see below ) - - remove: message - - this message is sent for stopping ASN with the given identification. - If the only item in the message is the identification string, the ASN - info should be removed. If there are also the PID and HOSTNAME entries - ( see below ), the matching ASN info should be only removed if this - given PID is the only PID for it ( in this case, the identification - string may be omitted ). - - the text of the message starts with 4 characters 'remove:', followed - by - - only ID entry - - only ID, PID and HOSTNAME entries - - only PID and HOSTNAME entries - - -Text entries in the messages : ------------------------------- - -Every entry is of the form =. Value may be either a number -or a string. If the string contains spaces, it must be quoted ("), all -backslashes and quotes (") must be escaped by backslashes. If this ever -becomes more than an internal KDE standard, non-standard entry names should -start with an underscore. - -Entries : - -- ID - string - - the identification string of the startup notification - - it must be present in all messages except for the remove: - message with only PID and HOSTNAME -- BIN - string - - the binary name of the starting application - - usually used as a fallback value if WMCLASS is not present - - e.g. 'kcontrol' -- NAME - string - - the name of the starting application - - usually used only for displaying it when indicating that - the application is starting - - e.g. 'Control Center' -- ICON - string - - the icon for this startup notification - - it should be handled like the Icon= entry in .desktop files - - e.g. 'kcontrol' -- DESKTOP - number - - the virtual desktop on which the application should appear - - if the application's first window has _NET_WM_DESKTOP already - set when the window is mapped, it shouldn't be changed -- WMCLASS - string - - the WMCLASS value used for matching newly mapped windows - of non-compliant applications - - useful only if it's different from the binary - name of the application -- PID - number - - the PID of a process that belongs to this startup notification - - there may be several PIDs for one notification - - value 0 is also valid, meaning that there's a process - with unknown PID for this notification ( is used e.g. - by kfmclient when it sends a DCOP message to already running - konqueror instance to create a new window and exits immediately, - without adding the zero PID to the notification, process - that started kfmclient could detect it exited and would send - a remove: message for the notification with kfmclient's PID, - which would cause the notification to stop if there wasn't also - PID=0 for it -- HOSTNAME - string - - the hostname of the machine on which the application is being - started - - this is used together with the PID entry - --------------------- - - Well, I guess that's all. The KDE2.2 release will show if the users like it -or not ( it's quite good IMHO, even though there are probably some minor -details to fix or improve ). The only big thing remaining is to make also -non-KDE people agree on using something like this. My first attempt -https://listman.redhat.com/pipermail/xdg-list/2001-May/000083.html -didn't get much attention, but now that there's a working implementation, -I hope it will get better, when I try again sometime in the future. - - - - Lubos Lunak - diff --git a/kdecore/README.user_profiles b/kdecore/README.user_profiles deleted file mode 100644 index 4fb43b757..000000000 --- a/kdecore/README.user_profiles +++ /dev/null @@ -1,136 +0,0 @@ -Users can be associated with Profile(s) -======================================= - -A user can be associated with one or more profiles. A profile indicates a -configuration set that applies to a group of users. Each profile has a name -to identify it. If a user is associated with more than one profile then the -order of the two profiles is important. Settings associated with one profile -could override the settings in the other profile, depending on the order. - - -Mapping profiles to users -========================= - -A mapping file determines which profile(s) should be used for which user. -The mapping file can be configured in /etc/kderc in the [Directories] group: - - [Directories] - userProfileMapFile=/etc/kde-user-profile - -Profiles can be mapped to individual users based on username, or profiles can -be mapped to groups of users based on the UNIX group(s) the users are part of. -(See man 1 groups) - - -Mapping profiles to individual users -==================================== - -The mapping file can contain a [Users] section for mapping profiles to -an individual user. The [Users] section contains the user's account name -followed by one or more profiles as follow: - - [Users] - bastian=developer - adrians=developer,packager - -The above example assigns to user "bastian" the profile "developer". To user -"adrians" it assigns the two profiles "developer" and "packager". The order -in which the profiles are listed makes a difference, settings in earlier -profiles overrule settings in profiles that are listed after it. In the above -case of user "adrians", wherever the "developer" and "packager" profiles contain -conflicting settings, the settings of the "developer" profile will take precedent. - -If a user has an entry under the [Users] section, this entry will determine all -profiles that are applicable to the user. The user will not be assigned any -additional profiles based on the groups the user is part of. - -Mapping profiles to user groups -=============================== - -If a user has no entry under the [Users] section in the mapping file, the profiles -that are applicable to the user will be based on the UNIX group(s) the user is -part of. - -The groups and the order in which the groups are considered is determined by -the following entry in the [General] section of the mapping file: - - [General] - groups=pkgs,devel - -Each of these groups should have an entry under the [Groups] section that defines -which profile(s) belongs to that group. This looks as follows: - - [Groups] - pkgs=packager - devel=developer - bofh=admin,packager,developer - -For each group that a user is part of, the corresponding profile(s) are used. The -order in which the groups are listed in the "groups" entry, determines the resulting -order of all the applicable profiles. If multiple profiles are applicable to a -particular user and a profile contains settings that conflict with settings in -another profile then the settings in the earlier listed profile take precedent. - -So if, based on the example above, a user is part of the "pkgs" group then the -"packager" profile will be used for that user. If the user is part of the "devel" -group then the "developer" profile will be used. Users that are part of the "bofh" -group will use the "admin", "packager" as well as the "developer" profile. In case -of conflict, settings in the "admin" profile will take precedent over settings -in the "packager" or "developer" profiles. - -If the user is part of both the "pkgs" and "devel" groups, then both the "packager" -and "developer" profiles will be used. In case of conflicting settings between the -two profiles, the "packager" profile will take precedent because the "pkgs" group -associated with the profile was listed before the "devel" group. - -The "groups" command can be used to see to which groups a user belongs: - - > groups coolo - coolo : users uucp dialout audio video cdrecording devel - -Note that in general only a few groups will have profiles associated with them. -In the example above only the "devel" group has a profile associated with it, -the other groups do not and will be ignored. - -If there is no profile defined for any of the groups that the user is in, the -user will be assigned the "default" profile. - - -The Profile determines the directory prefixes -============================================= - -The global KDE configuration file (e.g. kdeglobals or /etc/kderc) can -contain config-groups that are associated with a certain user profile. -Such a config-group is treated similar as the [Directories] config-group. - -The name of a such config-group is [Directories-] - - -Integration with KIOSK Admin Tool -================================= - -The KIOSK Admin Tool uses /etc/kderc as source for all its profile -information. For this it uses the following keys in the -[Directories-] config-group: - - # Short text describing this profile - ProfileDescription= - - # Files will be installed with the uid of this user - ProfileInstallUser= - -The KIOSK Admin Tool uses the first directory from the prefixes= entry -as default installation directory for this profile. - - -Default setting as example -========================== - -The following snipped could be added to /etc/kderc to define a "default" profile: - - [Directories-default] - ProfileDescription=Default profile - ProfileDescription[de]=Defaultprofiel - ProfileInstallUser=root - prefixes=/var/run/kde-profile/default - diff --git a/kdecore/Rainbow.colors b/kdecore/Rainbow.colors deleted file mode 100644 index afe836eb8..000000000 --- a/kdecore/Rainbow.colors +++ /dev/null @@ -1,118 +0,0 @@ -GIMP Palette -255 204 204 -255 230 204 -255 255 204 -230 255 204 -204 255 204 -204 255 230 -204 255 255 -204 230 255 -204 204 255 -230 204 255 -255 204 255 -255 204 230 -255 255 255 -255 153 153 -255 204 153 -255 255 153 -204 255 153 -153 255 153 -153 255 204 -153 255 255 -153 204 255 -153 153 255 -204 153 255 -255 153 255 -255 153 204 -224 224 224 -255 102 102 -255 179 102 -255 255 102 -179 255 102 -102 255 102 -102 255 179 -102 255 255 -102 179 255 -102 102 255 -179 102 255 -255 102 255 -255 102 179 -192 192 192 -255 51 51 -255 153 51 -255 255 51 -153 255 51 - 51 255 51 - 51 255 153 - 51 255 255 - 51 153 255 - 51 51 255 -153 51 255 -255 51 255 -255 51 153 -160 160 160 -255 0 0 -255 128 0 -255 255 0 -128 255 0 - 0 255 0 - 0 255 128 - 0 255 255 - 0 128 255 - 0 0 255 -128 0 255 -255 0 255 -255 0 128 -128 128 128 -204 0 0 -204 102 0 -204 204 0 -102 204 0 - 0 204 0 - 0 204 102 - 0 204 204 - 0 102 204 - 0 0 204 -102 0 204 -204 0 204 -204 0 102 - 96 96 96 -153 0 0 -153 77 0 -153 153 0 - 77 153 0 - 0 153 0 - 0 153 77 - 0 153 153 - 0 77 153 - 0 0 153 - 77 0 153 -153 0 153 -153 0 77 - 64 64 64 -102 0 0 -102 51 0 -102 102 0 - 51 102 0 - 0 102 0 - 0 102 51 - 0 102 102 - 0 51 102 - 0 0 102 - 51 0 102 -102 0 102 -102 0 51 - 32 32 32 - 51 0 0 - 51 26 0 - 51 51 0 - 26 51 0 - 0 51 0 - 0 51 26 - 0 51 51 - 0 26 51 - 0 0 51 - 26 0 51 - 51 0 51 - 51 0 26 - 0 0 0 diff --git a/kdecore/Royal.colors b/kdecore/Royal.colors deleted file mode 100644 index 5ea4fe638..000000000 --- a/kdecore/Royal.colors +++ /dev/null @@ -1,258 +0,0 @@ -GIMP Palette - 0 0 0 - 60 0 80 - 60 0 80 - 60 0 84 - 64 0 84 - 64 0 84 - 64 0 88 - 64 0 88 - 68 0 88 - 68 0 92 - 68 0 92 - 68 0 92 - 72 0 96 - 72 0 96 - 72 0 96 - 72 0 100 - 76 0 100 - 76 0 100 - 76 0 104 - 76 0 104 - 76 0 104 - 80 0 104 - 80 0 108 - 80 0 108 - 80 0 108 - 84 0 112 - 84 0 112 - 84 0 112 - 84 0 116 - 88 0 116 - 88 0 116 - 88 0 120 - 88 0 120 - 92 0 120 - 92 0 124 - 92 0 124 - 92 0 124 - 96 0 128 - 96 0 128 - 96 0 128 - 96 0 132 - 96 0 132 -100 0 132 -100 0 132 -100 0 136 -100 0 136 -104 0 136 -104 0 140 -104 0 140 -104 0 140 -108 0 144 -108 0 144 -108 0 144 -108 0 148 -112 0 148 -112 0 148 -112 0 152 -112 0 152 -116 0 152 -116 0 156 -116 0 156 -116 0 156 -120 0 160 -120 0 160 -124 4 160 -124 8 164 -128 12 164 -128 16 164 -132 20 168 -132 24 168 -136 28 168 -136 32 172 -140 36 172 -140 40 172 -144 44 176 -144 48 176 -148 52 180 -148 56 180 -152 60 180 -152 64 184 -156 68 184 -156 72 184 -160 76 188 -160 80 188 -164 84 188 -164 88 192 -168 92 192 -168 96 192 -172 100 196 -172 104 196 -176 108 200 -176 112 200 -180 116 200 -180 120 204 -184 124 204 -188 128 204 -188 132 208 -192 136 208 -192 140 208 -196 144 212 -196 148 212 -200 152 216 -200 156 216 -204 160 216 -204 164 220 -208 168 220 -208 172 220 -212 176 224 -212 180 224 -216 184 224 -216 188 228 -220 192 228 -220 196 228 -224 200 232 -224 204 232 -228 208 236 -228 212 236 -232 216 236 -232 220 240 -236 224 240 -236 228 240 -240 232 244 -240 236 244 -244 240 244 -244 244 248 -248 248 248 -252 252 252 -252 252 252 -252 252 248 -252 252 244 -252 252 240 -252 252 236 -252 252 232 -252 252 228 -252 252 224 -252 252 220 -252 252 216 -252 252 212 -252 252 208 -252 252 204 -252 252 200 -252 252 196 -252 252 192 -252 252 188 -252 252 184 -252 252 180 -252 252 176 -252 252 172 -252 252 168 -252 252 164 -252 252 160 -252 252 156 -252 252 152 -252 252 148 -252 252 144 -252 252 140 -252 252 136 -252 252 132 -252 252 128 -252 252 124 -252 252 120 -252 252 116 -252 252 112 -252 252 108 -252 252 104 -252 252 100 -252 252 96 -252 252 92 -252 252 88 -252 252 84 -252 252 80 -252 252 76 -252 252 72 -252 252 68 -252 252 64 -252 252 60 -252 252 56 -252 252 52 -252 252 48 -252 252 44 -252 252 40 -252 252 36 -252 252 32 -252 252 28 -252 252 24 -252 252 20 -252 252 16 -252 252 12 -252 252 8 -252 252 4 -252 252 0 -252 248 0 -248 244 0 -244 240 0 -240 236 4 -240 232 4 -236 228 4 -232 224 8 -228 220 8 -228 216 8 -224 212 12 -220 208 12 -216 204 12 -212 200 16 -212 196 16 -208 192 16 -204 188 20 -200 184 20 -200 180 20 -196 176 24 -192 172 24 -188 168 24 -184 164 28 -184 160 28 -180 156 28 -176 152 32 -172 148 32 -172 144 32 -168 140 36 -164 136 36 -160 132 36 -160 128 36 -156 124 40 -152 120 40 -148 116 40 -144 112 44 -144 108 44 -140 104 44 -136 100 48 -132 96 48 -132 92 48 -128 88 52 -124 84 52 -120 80 52 -116 76 56 -116 72 56 -112 68 56 -108 64 60 -104 60 60 -104 56 60 -100 52 64 - 96 48 64 - 92 44 64 - 88 40 68 - 88 36 68 - 84 32 68 - 80 28 72 - 76 24 72 - 76 20 72 - 72 16 76 - 68 12 76 - 64 8 76 - 60 0 80 - 60 0 80 - 60 0 80 - 60 0 80 -# The royal purple ... by D. Egnor diff --git a/kdecore/Web.colors b/kdecore/Web.colors deleted file mode 100644 index efdd23dd8..000000000 --- a/kdecore/Web.colors +++ /dev/null @@ -1,218 +0,0 @@ -GIMP Palette -# Netscape -- GIMP Palette file -255 255 255 -255 255 204 -255 255 153 -255 255 102 -255 255 51 -255 255 0 -255 204 255 -255 204 204 -255 204 153 -255 204 102 -255 204 51 -255 204 0 -255 153 255 -255 153 204 -255 153 153 -255 153 102 -255 153 51 -255 153 0 -255 102 255 -255 102 204 -255 102 153 -255 102 102 -255 102 51 -255 102 0 -255 51 255 -255 51 204 -255 51 153 -255 51 102 -255 51 51 -255 51 0 -255 0 255 -255 0 204 -255 0 153 -255 0 102 -255 0 51 -255 0 0 -204 255 255 -204 255 204 -204 255 153 -204 255 102 -204 255 51 -204 255 0 -204 204 255 -204 204 204 -204 204 153 -204 204 102 -204 204 51 -204 204 0 -204 153 255 -204 153 204 -204 153 153 -204 153 102 -204 153 51 -204 153 0 -204 102 255 -204 102 204 -204 102 153 -204 102 102 -204 102 51 -204 102 0 -204 51 255 -204 51 204 -204 51 153 -204 51 102 -204 51 51 -204 51 0 -204 0 255 -204 0 204 -204 0 153 -204 0 102 -204 0 51 -204 0 0 -153 255 255 -153 255 204 -153 255 153 -153 255 102 -153 255 51 -153 255 0 -153 204 255 -153 204 204 -153 204 153 -153 204 102 -153 204 51 -153 204 0 -153 153 255 -153 153 204 -153 153 153 -153 153 102 -153 153 51 -153 153 0 -153 102 255 -153 102 204 -153 102 153 -153 102 102 -153 102 51 -153 102 0 -153 51 255 -153 51 204 -153 51 153 -153 51 102 -153 51 51 -153 51 0 -153 0 255 -153 0 204 -153 0 153 -153 0 102 -153 0 51 -153 0 0 -102 255 255 -102 255 204 -102 255 153 -102 255 102 -102 255 51 -102 255 0 -102 204 255 -102 204 204 -102 204 153 -102 204 102 -102 204 51 -102 204 0 -102 153 255 -102 153 204 -102 153 153 -102 153 102 -102 153 51 -102 153 0 -102 102 255 -102 102 204 -102 102 153 -102 102 102 -102 102 51 -102 102 0 -102 51 255 -102 51 204 -102 51 153 -102 51 102 -102 51 51 -102 51 0 -102 0 255 -102 0 204 -102 0 153 -102 0 102 -102 0 51 -102 0 0 -51 255 255 -51 255 204 -51 255 153 -51 255 102 -51 255 51 -51 255 0 -51 204 255 -51 204 204 -51 204 153 -51 204 102 -51 204 51 -51 204 0 -51 153 255 -51 153 204 -51 153 153 -51 153 102 -51 153 51 -51 153 0 -51 102 255 -51 102 204 -51 102 153 -51 102 102 -51 102 51 -51 102 0 -51 51 255 -51 51 204 -51 51 153 -51 51 102 -51 51 51 -51 51 0 -51 0 255 -51 0 204 -51 0 153 -51 0 102 -51 0 51 -51 0 0 -0 255 255 -0 255 204 -0 255 153 -0 255 102 -0 255 51 -0 255 0 -0 204 255 -0 204 204 -0 204 153 -0 204 102 -0 204 51 -0 204 0 -0 153 255 -0 153 204 -0 153 153 -0 153 102 -0 153 51 -0 153 0 -0 102 255 -0 102 204 -0 102 153 -0 102 102 -0 102 51 -0 102 0 -0 51 255 -0 51 204 -0 51 153 -0 51 102 -0 51 51 -0 51 0 -0 0 255 -0 0 204 -0 0 153 -0 0 102 -0 0 51 -0 0 0 diff --git a/kdecore/all_languages.desktop b/kdecore/all_languages.desktop deleted file mode 100644 index 2f36efff6..000000000 --- a/kdecore/all_languages.desktop +++ /dev/null @@ -1,11919 +0,0 @@ -[aa] -Name=Afar -Name[az]=Afarca -Name[be]=ÐфарÑÐºÐ°Ñ -Name[bg]=Ðфар -Name[bn]=আফার -Name[csb]=Afarsczi -Name[cy]=Afareg -Name[eo]=Fora -Name[fa]=اÙار -Name[ga]=Afárais -Name[he]=×פ×ר -Name[hi]=अफà¥à¤° -Name[hr]=Afarski -Name[ja]=アファル語 -Name[ka]=áƒáƒ¤áƒáƒ áƒ£áƒšáƒ˜ -Name[kk]=Ðфарша -Name[km]=អាហ្វារ -Name[ko]=아파르어 -Name[lt]=Afarų -Name[lv]=AfÄru -Name[mk]=Ðфар -Name[mn]=Ðфар -Name[nds]=Afaarsch -Name[ne]=अफार -Name[nso]=Kgolekgole -Name[pa]=ਅਫਾਰ -Name[pl]=Afarski -Name[ro]=Afară -Name[ru]=ÐфарÑкий -Name[rw]=Ikinyafari -Name[se]=Afárgiella -Name[sk]=afarÄina -Name[sl]=afarsko -Name[sq]=Afarisht -Name[sr]=ÐфарÑки -Name[sr@Latn]=Afarski -Name[ss]=Si-Afar -Name[ta]=அஃபார௠-Name[te]=ఎఫారౠ-Name[tg]=Ðфарӣ -Name[th]=ภาษาอะฟาร์ -Name[tt]=Afarça -Name[uk]=Ðфар -Name[uz@cyrillic]=Ðфар -Name[vi]=Ä‚-pha -Name[zh_CN]=阿法尔语 -Name[zh_HK]=阿發爾 -Name[zh_TW]=阿發爾 -Name[zu]=Okude kakhulu -[ab] -Name=Abkhazian -Name[ar]=أبخازي -Name[az]=Abxazca -Name[be]=ÐбхазÑÐºÐ°Ñ -Name[bg]=Ðбхазки -Name[bn]=আবখাজিয়ান -Name[br]=Abkhazieg -Name[bs]=Abhaski -Name[ca]=Àzeri -Name[cs]=Abcházský -Name[csb]=Abchasczi -Name[cy]=Abkhazeg -Name[da]=Abkhaziansk -Name[de]=Abhasisch -Name[eo]=AbÄ¥aza -Name[et]=Abhaasia -Name[fa]=ابخازیان -Name[fi]=Abhaasi -Name[fr]=Abkhaze -Name[fy]=Abkhasysk -Name[ga]=Abcáisis -Name[gl]=Abxásio -Name[he]=×בחזית -Name[hi]=अबकाजियन -Name[hr]=AbhaÅ¡ki -Name[hsb]=Abchazisce -Name[hu]=Abház -Name[it]=Abkhaziano -Name[ja]=アブãƒã‚ºèªž -Name[ka]=áƒáƒ¤áƒ®áƒáƒ–ური -Name[kk]=Ðхбазша -Name[km]=អាប់ážáž¶áž áŸ’ស៊ាន -Name[ko]=아브하지아어 -Name[lb]=Abhasesch -Name[lt]=Abhazų -Name[lv]=AbhÄzu -Name[mk]=ÐбхаÑки -Name[mn]=Ðбкааз -Name[ms]=Abkhazia -Name[nb]=Abkhasisk -Name[nds]=Abchaassch -Name[ne]=अबà¥à¤–ाजियन -Name[nn]=Abkhasisk -Name[nso]=Se-Abkhazian -Name[pa]=ਅਬਖਾਜ਼ੀਨ -Name[pl]=Abchaski -Name[pt_BR]=Turco -Name[ro]=Abhaziană -Name[ru]=ÐбхазÑкий -Name[rw]=Abukaziyani -Name[se]=Abhásiagiella -Name[sk]=abcházÄina -Name[sl]=abkazijansko -Name[sq]=Abkhazanisht -Name[sr]=ÐбхазијÑки -Name[sr@Latn]=Abhazijski -Name[ss]=Si-Abkhazian -Name[sv]=Abkhasiska -Name[ta]=அபà¯à®•à®¾à®šà®¿à®¯à®©à¯ -Name[te]=à°…à°¬à±à°–జియనౠ-Name[tg]=Ðбхозӣ -Name[th]=ภาษาà¹à¸­à¸šà¸„าเซียน -Name[tt]=Abxazça -Name[uk]=Ðбхазька -Name[uz]=Abxazcha -Name[uz@cyrillic]=Ðбхазча -Name[vi]=Ap-kha-xi-an -Name[wa]=Abxhaze -Name[zh_CN]=阿布哈西亚语 -Name[zh_HK]=阿布哈西亞語 -Name[zh_TW]=阿布哈西亞語 -Name[zu]=I-Abkhazian -[ae] -Name=Avestan -Name[ar]=أيراني Ø£Ùستان -Name[az]=Avestanca -Name[be]=ÐвеÑтанÑÐºÐ°Ñ -Name[bg]=ÐвеÑтийÑки -Name[bn]=আভেসà§à¦¤à¦¾à¦¨ -Name[cs]=Avestánský -Name[csb]=AwestaÅ„sczi (iraÅ„sczi) -Name[cy]=Afestaneg -Name[da]=Avestansk -Name[de]=Avestisch -Name[eo]=Avesta -Name[et]=Vanapärsia -Name[fa]=اوستایی -Name[fi]=Avesta -Name[fy]=Avestaansk -Name[ga]=Aivéistis -Name[gl]=Avestani -Name[he]=×ווסטית -Name[hi]=अवेसà¥à¤¤à¤¨ -Name[hr]=Avestanski -Name[hsb]=Awestisce -Name[hu]=Avesztáni -Name[it]=Avestano -Name[ja]=アベスタ語 -Name[ka]=áƒáƒ•áƒ”სტური -Name[kk]=ÐвеÑтша -Name[km]=អាវែស្ážáž„់ -Name[ko]=아베스탄어 -Name[mk]=ÐвеÑтан -Name[mn]=ÐвеÑтан -Name[nb]=Avestisk -Name[nds]=Avesta -Name[ne]=अभेसà¥à¤Ÿà¤¨ -Name[nn]=Avestisk -Name[nso]=Se-Avestan -Name[pa]=ਅਵਸਟਅਨ -Name[pl]=AwestaÅ„ski (IraÅ„ski) -Name[ro]=Avestană -Name[ru]=ÐвеÑтийÑкий -Name[rw]=Ikinyavesitani -Name[se]=Avestánagiella -Name[sk]=avestÄina -Name[sl]=avestansko -Name[sq]=Avestanisht -Name[sr]=ÐвеÑтанÑки -Name[sr@Latn]=Avestanski -Name[ss]=Si-Avestan -Name[sv]=Avestiska -Name[ta]=அவெஸà¯à®¤à®©à¯ -Name[te]=అవెసà±à°¥à°¨à± -Name[tg]=ÐваÑтоӣ -Name[th]=ภาษาอะเวสà¹à¸—น -Name[tt]=Avestança -Name[uk]=ÐвеÑтан -Name[uz]=Avesta -Name[uz@cyrillic]=ÐвеÑта -Name[vi]=Ä‚-ve-x-tanh -Name[zh_CN]=阿维斯陀语 -Name[zh_HK]=阿維斯陀語 -Name[zh_TW]=阿維斯陀語 -Name[zu]=Isi-Avestan -[af] -Name=Afrikaans -Name[ar]=الأÙريكانس -Name[az]=Afrika Dili -Name[be]=ÐфрыканÑÐºÐ°Ñ -Name[bg]=ÐÑ„Ñ€Ð¸ÐºÐ°Ð°Ð½Ñ -Name[bn]=আফà§à¦°à¦¿à¦•à¦¾à¦¨à§â€Œà¦¸ -Name[cs]=Afrikánský -Name[csb]=Afrikanersczi -Name[cy]=Affricaneg -Name[el]=ΑφÏικανικά -Name[eo]=Afrikansa -Name[et]=Afrikaani -Name[eu]=Afrikaansa -Name[fa]=Ø¢Ùریکانس -Name[fy]=Afrikaansk -Name[ga]=Afracáinis -Name[gl]=Africáner -Name[he]=×פריקנס -Name[hi]=अफà¥à¤°à¥€à¤•à¤¨à¥à¤¸ -Name[id]=Afrika -Name[ja]=アフリカーンス語 -Name[ka]=áƒáƒ¤áƒ áƒ˜áƒ™áƒáƒáƒœáƒ¡áƒ˜ -Name[kk]=ÐÐ°Ñ„Ñ€Ð¸ÐºÐ°Ð°Ð½Ñ -Name[km]=អាហ្វ្រីកាអាន -Name[ko]=남아프리카 공용어 -Name[lt]=Afrikanso -Name[lv]=Ä€frikÄņu -Name[mi]=Reo Äwherika Tatimana -Name[mk]=ÐфриканÑки -Name[mn]=Ðфрик -Name[ms]=Afrika -Name[mt]=Afrikans -Name[nds]=Afrikaansch -Name[ne]=अफà¥à¤°à¤¿à¤•à¥€ -Name[nso]=Seburu -Name[pa]=ਅਫਰੀਕਨ -Name[pl]=Afrykanerski -Name[pt_BR]=Africâners -Name[ro]=Africană -Name[ru]=ÐÑ„Ñ€Ð¸ÐºÐ°Ð°Ð½Ñ -Name[rw]=Ikinyafurikansi -Name[se]=Afrikánsgiella -Name[sk]=afrikánÄina -Name[sl]=afrikansko -Name[sq]=Afrikanisht -Name[sr]=ÐфриканерÑки -Name[sr@Latn]=Afrikanerski -Name[ss]=Sibhunu -Name[sv]=Sydafrikansk holländska -Name[ta]=ஆஃபரிகானà¯à®¸à¯ -Name[te]=ఆఫà±à°°à°¿à°•à°¾à°¨à±à°¸à± -Name[tg]=Ðфрикоӣ -Name[th]=ภาษาà¹à¸­à¸Ÿà¸£à¸´à¸à¸² -Name[tr]=Afrika Dili -Name[tt]=Afrikança -Name[uk]=ПівденноафриканÑька -Name[uz]=Afrikancha -Name[uz@cyrillic]=Ðфриканча -Name[ven]=Tshivhuru -Name[vi]=Hoà Nam Phi -Name[xh]=Isibhulu -Name[zh_CN]=å—éžè·å…°è¯­ -Name[zh_HK]=å—éžè·è˜­èªž -Name[zh_TW]=å—éžè·è˜­èªž -Name[zu]=Isi-Bhunu -[am] -Name=Amharic -Name[ar]=أمهري -Name[az]=AmharikcÉ™ -Name[be]=ÐмхарÑÐºÐ°Ñ -Name[bg]=ÐмхарÑки -Name[bn]=আমহারিক -Name[br]=Amhareg -Name[bs]=Amharski -Name[ca]=Amhàric -Name[cs]=Amharský -Name[csb]=Etiopsczi -Name[cy]=Amhareg -Name[da]=Amharisk -Name[de]=Amharisch -Name[eo]=Amhara -Name[es]=Amárico -Name[et]=Amhaara -Name[fa]=امهری -Name[fi]=Amhara -Name[fr]=Amharique -Name[fy]=Amhaarsk -Name[ga]=Amáiris -Name[he]=×מהרית -Name[hi]=अमà¥à¤¹à¤¾à¤°à¤¿à¤• -Name[hr]=Amarski -Name[hsb]=Amharisce -Name[hu]=Amhár -Name[it]=Amarico -Name[ja]=アムãƒãƒ©èªž -Name[ka]=áƒáƒ›áƒ°áƒáƒ áƒ£áƒšáƒ˜ -Name[kk]=Ðхмарша -Name[km]=អាមហារី -Name[ko]=암하ë¼ì–´ -Name[lb]=Amharesch -Name[lt]=Amhari -Name[lv]=AmarieÅ¡u -Name[mk]=ÐмхарÑки -Name[mn]=Ðмхар -Name[nb]=Amharisk -Name[nds]=Amhaarsch -Name[ne]=अमà¥à¤¹à¤¾à¤°à¤¿à¤• -Name[nl]=Amharisch -Name[nn]=Amharisk -Name[nso]=Se-Amharic -Name[pa]=ਅਮਹਾਰਿਕ -Name[pl]=Etiopski -Name[pt]=Amárico -Name[pt_BR]=Amârico -Name[ro]=Amarică -Name[ru]=ÐмхарÑкий -Name[rw]=Ikinyamarike -Name[se]=Ambháriagiella -Name[sk]=amharÄina -Name[sl]=amharik -Name[sq]=Amharikisht -Name[sr]=ÐмарÑки -Name[sr@Latn]=Amarski -Name[ss]=Si-Amharic -Name[sv]=Amarinja -Name[ta]=à®…à®®à¯à®¹à®¾à®°à®¿à®•à¯ -Name[te]=à°…à°®à±à°¹à°°à°¿à°•à± -Name[tg]=Ðмхарикӣ -Name[th]=ภาษาอัมฮาริค -Name[tt]=Amharça -Name[uk]=ÐмхарÑька -Name[uz]=Amxarik -Name[uz@cyrillic]=Ðмхарик -Name[vi]=Am-ha-ri -Name[zh_CN]=阿姆哈拉语 -Name[zh_HK]=衣索比亞官方語 -Name[zh_TW]=衣索比亞官方語 -Name[zu]=isi-Amharic -[ar] -Name=Arabic -Name[af]=Arabies -Name[ar]=العربية -Name[az]=ÆrabcÉ™ -Name[be]=ÐрабÑÐºÐ°Ñ -Name[bg]=ÐрабÑки -Name[bn]=আরবী -Name[br]=Arabeg -Name[bs]=Arapski -Name[ca]=Àrab -Name[cs]=Arabský -Name[csb]=Arabsczi -Name[cy]=Arabeg -Name[da]=Arabisk -Name[de]=Arabisch -Name[el]=ΑÏαβικά -Name[eo]=Araba -Name[es]=Arábe -Name[et]=Araabia -Name[eu]=Arabiera -Name[fa]=عربی -Name[fi]=Arabia -Name[fr]=Arabe -Name[fy]=Arabysk -Name[ga]=Araibis -Name[gl]=Ãrabe -Name[he]=ערבית -Name[hi]=अरेबिक -Name[hr]=Arapski -Name[hsb]=Arabsce -Name[hu]=Arab -Name[id]=Arab -Name[is]=Arabíska -Name[it]=Arabo -Name[ja]=アラビア語 -Name[ka]=áƒáƒ áƒáƒ‘ული -Name[kk]=Ðрабша -Name[km]=អារ៉ាប់ -Name[ko]=ì•„ë¼ë¹„ì•„ì–´ -Name[lb]=Arabesch -Name[lt]=Arabų -Name[lv]=ArÄbu -Name[mi]=Reo Arapia -Name[mk]=ÐрапÑки -Name[mn]=Ðраб -Name[ms]=Arab -Name[mt]=Għarbi -Name[nb]=Arabisk -Name[nds]=Araabsch -Name[ne]=अरबी -Name[nl]=Arabisch -Name[nn]=Arabisk -Name[nso]=Searapo -Name[oc]=Arab -Name[pa]=ਅਰਬੀ -Name[pl]=Arabski -Name[pt]=Ãrabe -Name[pt_BR]=Ãrabe -Name[ro]=Arabă -Name[ru]=ÐрабÑкий -Name[rw]=Icyarabu -Name[se]=Arábiagiella -Name[sk]=arabÄina -Name[sl]=arabsko -Name[sq]=Arabisht -Name[sr]=ÐрапÑки -Name[sr@Latn]=Arapski -Name[ss]=Si-Arabhu -Name[sv]=Arabiska -Name[ta]=அராபிக௠-Name[te]=అరబికౠ-Name[tg]=Ðрабӣ -Name[th]=ภาษาอารบิภ-Name[tr]=Arapça -Name[tt]=Ğäräpçä -Name[uk]=ÐрабÑька -Name[uz]=Arabcha -Name[uz@cyrillic]=Ðрабча -Name[ven]=Tshiarabiki -Name[vi]=A-rập -Name[wa]=Arabe -Name[zh_CN]=阿拉伯语 -Name[zh_HK]=阿拉伯語 -Name[zh_TW]=阿拉伯語 -Name[zu]=Isi-Arabhu -[as] -Name=Assamese -Name[ar]=هندي أساميزي -Name[az]=AssamescÉ™ -Name[be]=ÐÑамÑÐºÐ°Ñ -Name[bg]=ÐÑами -Name[bn]=আসামী -Name[bs]=Asamski -Name[ca]=Assamès -Name[cs]=Asamský -Name[csb]=Assamijsczi -Name[cy]=Assameg -Name[de]=Assamesisch -Name[eo]=Asama -Name[et]=Assami -Name[fa]=آسامی -Name[fi]=Assami -Name[fr]=Assamais -Name[fy]=Assameesk -Name[ga]=Asaimis -Name[gl]=Asamixa -Name[he]=×סמית -Name[hi]=असमी -Name[hr]=Asamski -Name[hsb]=Asamezisce -Name[hu]=Asszámi -Name[ja]=アッサム語 -Name[ka]=áƒáƒ¡áƒáƒ›áƒ”სე -Name[kk]=ÐÑÑамша -Name[km]=អាសាមីស -Name[ko]=아삼어 -Name[lb]=Assamesesch -Name[lt]=Asamesų -Name[lv]=AsamieÅ¡u -Name[mk]=ÐÑамеÑки -Name[mn]=ÐÑÑаме -Name[nb]=Assamesisk -Name[nds]=Assameesch -Name[ne]=आसामी -Name[nl]=Assamees -Name[nn]=Assami -Name[nso]=Se-Assamese -Name[pa]=ਆਸਾਮੀ -Name[pl]=Assamijski -Name[ro]=Asameză -Name[ru]=ÐÑÑамÑкий -Name[rw]=Ikinyasamese -Name[se]=Assamesegiella -Name[sk]=ásámÄina -Name[sl]=asamese -Name[sq]=Assamesisht -Name[sr]=ÐÑамÑки -Name[sr@Latn]=Asamski -Name[ss]=Si-Assamese -Name[sv]=Assamesiska -Name[ta]=அஸà¯à®¸à®¾à®®à®¿à®¯ -Name[te]=à°…à°¸à±à°¸à°¾à°®à±€ -Name[tg]=ÐÑÑамӣ -Name[th]=ภาษาอัสสัม -Name[tt]=Assamesçä -Name[uk]=ÐÑамійÑька -Name[uz@cyrillic]=ÐÑÑамеÑе -Name[vi]=A-xam -Name[zh_CN]=阿è¨å§†è¯­ -Name[zh_HK]=阿薩姆語 -Name[zh_TW]=阿薩姆語 -Name[zu]=Isi-Assamese -[ay] -Name=Aymara -Name[ar]=هندي من سكان بوليÙيا والبيرو -Name[az]=Aymaraca -Name[be]=ÐймарÑÐºÐ°Ñ -Name[bg]=Ðймара -Name[bn]=আইমারা -Name[cy]=Aimareg -Name[de]=Aimara -Name[eo]=Ajmara -Name[et]=Aimaraa -Name[fa]=آیمارایی -Name[fi]=Aimara -Name[ga]=Adhmarais -Name[gl]=Aimará -Name[he]=×יימרה -Name[hi]=अयमारा -Name[hr]=Ajmarski -Name[hu]=Ajmara -Name[ja]=アイマラ語 -Name[ka]=áƒáƒ˜áƒ›áƒáƒ áƒ -Name[kk]=Ðймарша -Name[km]=អីម៉ារ៉ា -Name[ko]=ì•„ì´ë§ˆë¼ì–´ -Name[lb]=Aimara -Name[lv]=Ajmaru -Name[mk]=Ðјмара -Name[mn]=ÐÑмара -Name[ne]=आइमारा -Name[nso]=Se-Aymara -Name[pa]=ਅਯਮਾਰਾ -Name[ro]=Aymară -Name[ru]=ÐймарÑкий -Name[rw]=Ikinyayimara -Name[se]=Aimáragiella -Name[sk]=aymarÄina -Name[sl]=ajmarsko -Name[sq]=Ajmarisht -Name[sr]=ÐјмарÑки -Name[sr@Latn]=Ajmarski -Name[ss]=Si-Aymara -Name[ta]=அயà¯à®®à®¾à®°à®¾ -Name[te]=à°…à°¯à±à°®à°°à°¾ -Name[tg]=Ðймарагӣ -Name[th]=ภาษาอัยมารา -Name[tt]=Aymarça -Name[uk]=ÐймарÑька -Name[uz@cyrillic]=Ðймара -Name[vi]=Ay-ma-ra -Name[zh_CN]=艾马拉语 -Name[zh_HK]=愛瑪拉語 -Name[zh_TW]=愛瑪拉語 -Name[zu]=Isi-Aymara -[az] -Name=Azerbaijani -Name[ar]=الأذربيجانية -Name[az]=AzÉ™rbaycanca -Name[be]=ÐзербайджанÑÐºÐ°Ñ -Name[bg]=ÐзербайджанÑки -Name[bn]=আজেরবাইজানি -Name[br]=Azerbaidjanek -Name[bs]=Azerbejdžanski -Name[ca]=Àzeri -Name[cs]=Ãzerbajdžánský -Name[csb]=AzerbejdżaÅ„sczi -Name[cy]=Azerbaijaneg -Name[da]=Azerbaijansk -Name[de]=Aserbaidschanisch -Name[el]=ΑζεÏμπαϊτζανικά -Name[eo]=AzerbajÄana -Name[es]=Azerbayano -Name[et]=Aserbaidžaani -Name[eu]=Azerbaijanera -Name[fa]=آذربایجانی -Name[fi]=Azerbaidžani -Name[fr]=Azerbaïdjanais -Name[fy]=Azerbeidzjaansk -Name[ga]=Asarbaiseáinis -Name[gl]=Azeri -Name[he]=×זרביג'נית -Name[hi]=अजरबैजानी -Name[hr]=Azerbejdžanski -Name[hsb]=Azerbajdźansce -Name[hu]=Azerbajdzsán -Name[id]=Azerbaijan -Name[is]=Azerbaijanska -Name[it]=Azerbaigiano -Name[ja]=アゼルãƒã‚¤ã‚¸ãƒ£ãƒ³èªž -Name[ka]=áƒáƒ–ერბáƒáƒ˜áƒ¯áƒáƒœáƒ£áƒšáƒ˜ -Name[kk]=Ðзербайжанша -Name[km]=អាហ្ស៊ែរបែហ្សង់ -Name[ko]=아제르바ì´ìž”ì–´ -Name[lb]=Asserbaidschanesch -Name[lt]=AzerbaidžanieÄių -Name[lv]=AzerbaidžÄņu -Name[mk]=ÐзербејџанÑки -Name[mn]=Ðзербажайн -Name[ms]=Azerbaijan -Name[mt]=AżerbajÄ¡ani -Name[nb]=Aserbajdsjansk -Name[nds]=Aserbaidschaansch -Name[ne]=अजरबैजानी -Name[nl]=Azerbeidjaans -Name[nn]=Aserbajdsjansk -Name[nso]=Se-Azerbaijani -Name[pa]=ਅਜ਼ਰਬਾਈਜਾਨੀ -Name[pl]=AzerbejdżaÅ„ski -Name[pt]=Azerbaijano -Name[pt_BR]=Azerbaijão -Name[ro]=Azerbaijană -Name[ru]=ÐзербайджанÑкий -Name[rw]=Ikinyazeribayijani -Name[se]=Azerbaižánagiella -Name[sk]=azerbajdžanÄina -Name[sl]=azerbajdžansko -Name[sq]=Azerbejxhanisht -Name[sr]=ÐзербејџанÑки -Name[sr@Latn]=Azerbejdžanski -Name[ss]=Si-Azerbaijani -Name[sv]=Azerbajdzjanska -Name[ta]=அசரà¯à®ªà¯ˆà®šà®¾à®©à®¿ -Name[te]=అజెరౠబైజాని -Name[tg]=Озарбойҷонӣ -Name[th]=ภาษาอาเซอร์ไบจัน -Name[tr]=Azerbeycanca -Name[tt]=Äzerçä -Name[uk]=ÐзербайджанÑька -Name[uz]=Ozarbayjoncha -Name[uz@cyrillic]=Озарбайжонча -Name[vi]=A-xợ-bai-gianh -Name[wa]=Azeri -Name[zh_CN]=阿塞拜疆语 -Name[zh_HK]=亞塞拜彊語 -Name[zh_TW]=亞塞拜然語 -Name[zu]=Isi-Azerbaijani -[ba] -Name=Bashkir -Name[ar]=بشكير -Name[az]=BaÅŸkircÉ™ -Name[be]=БашкірÑÐºÐ°Ñ -Name[bg]=БашкирÑки -Name[bn]=বাশকীর -Name[bs]=BaÅ¡kir -Name[cs]=BaÅ¡kirský -Name[csb]=Baszkirsczi -Name[cy]=Bashkireg -Name[de]=Baschkirisch -Name[eo]=BaÅkira -Name[et]=BaÅ¡kiiri -Name[fa]=بشکیری -Name[fi]=BaÅ¡kiiri -Name[fr]=Bachkir -Name[ga]=Baiscíris -Name[gl]=Bashquir -Name[he]=בשקירית -Name[hi]=बाशकिर -Name[hr]=BaÅ¡kirski -Name[hu]=Baskír -Name[ja]=ãƒã‚·ãƒ¥ã‚­ãƒ¼ãƒ«èªž -Name[ka]=ბáƒáƒ¨áƒ™áƒ˜áƒ áƒ£áƒšáƒ˜ -Name[kk]=Башкұртша -Name[km]=បាសគៀរ -Name[ko]=바시킬어 -Name[lb]=Baschkiresch -Name[lt]=BaÅ¡kirų -Name[lv]=BaÅ¡kÄ«ru -Name[mk]=Башкир -Name[mn]=Башкир -Name[nds]=Baschkiirsch -Name[ne]=बासà¥à¤•à¤¿à¤° -Name[nn]=Basjkirsk -Name[nso]=Se-Bashkir -Name[pa]=ਬਸਕੀਰ -Name[pl]=Baszkirski -Name[ro]=BaÅŸchiră -Name[ru]=БашкирÑкий -Name[rw]=Ikinyabashikiri -Name[se]=BaÅ¡kiriagiella -Name[sk]=baÅ¡kirÄina -Name[sl]=baÅ¡kirsko -Name[sq]=Bashkirisht -Name[sr]=БашкирÑки -Name[sr@Latn]=BaÅ¡kirski -Name[ss]=Si-Bashkir -Name[ta]=பாகà¯à®·à¯€à®°à¯ -Name[te]=బాషà±à°•à°¿à°°à± -Name[tg]=Бошқирдӣ -Name[th]=ภาษาà¹à¸šà¸Šà¹€à¸„ียร์ -Name[tt]=BaÅŸqortça -Name[uk]=БашкирÑька -Name[uz]=Boshqircha -Name[uz@cyrillic]=Бошқирча -Name[vi]=Ba-x-kia -Name[zh_CN]=巴什基尔语 -Name[zh_HK]=Bashkir語 -Name[zh_TW]=Bashkir語 -Name[zu]=Isi-Bashkir -[be] -Name=Belarusian -Name[ar]=بلاروسي -Name[az]=Belarusca -Name[be]=БеларуÑÐºÐ°Ñ -Name[bg]=БелоруÑки -Name[bn]=বেলারà§à¦¶à¦¿à§Ÿ -Name[br]=Belarusieg -Name[bs]=Bjeloruski -Name[ca]=Bielorús -Name[cs]=BÄ›loruský -Name[csb]=BiaÅ‚orusczi -Name[cy]=Belarwsieg -Name[da]=Hviderussisk -Name[de]=Weißrussisch -Name[el]=ΛευκοÏωσικά -Name[eo]=Bjelorusa -Name[es]=Bieloruso -Name[et]=Valgevene -Name[eu]=Bielorrusiera -Name[fa]=بلاروسی -Name[fi]=Valkovenäjä -Name[fr]=Bélarus -Name[fy]=Wyt-Russysk -Name[ga]=Bealarúisis -Name[gl]=Bielorruso -Name[he]=בלרוסית -Name[hi]=बेलारूसियन -Name[hr]=Bjeloruski -Name[hsb]=Běłorusce -Name[hu]=Belorusz -Name[id]=Belarusia -Name[is]=Hvíta-Rússneska -Name[it]=Bielorusso -Name[ja]=ベラルーシ語 -Name[ka]=ბელáƒáƒ áƒ£áƒ¡áƒ£áƒšáƒ˜ -Name[kk]=БелоруÑша -Name[km]=áž”áŸáž¡áž¶ážšáž»ážŸáŸ’ស -Name[ko]=백러시아어 -Name[lb]=Wéisrussesch -Name[lt]=Baltarusių -Name[lv]=Baltkrievu -Name[mk]=БелоруÑки -Name[mn]=БеларуÑÑ -Name[ms]=Belarusia -Name[mt]=Bjelorussu -Name[nb]=Hviterussisk -Name[nds]=Wittruss'sch -Name[ne]=बेलारसियाली -Name[nl]=Wit-Rusland -Name[nn]=Kviterussisk -Name[nso]=Se-Belarusian -Name[pa]=ਬੇਲਾਰੂਸ -Name[pl]=BiaÅ‚oruski -Name[pt]=Bielorrusso -Name[pt_BR]=Bielo-Russo -Name[ro]=Belarusă -Name[ru]=БелоруÑÑкий -Name[rw]=Ikibelarusiya -Name[se]=VilgesruoÅ¡Å¡agiella -Name[sk]=bieloruÅ¡tina -Name[sl]=belorusko -Name[sq]=Bellorusisht -Name[sr]=БелоруÑки -Name[sr@Latn]=Beloruski -Name[ss]=Si-Belarusian -Name[sv]=Vitryska -Name[ta]=பெலாரூசியன௠-Name[te]=బెలరషియనౠ-Name[tg]=БелоруÑÓ£ -Name[th]=ภาษาเบลารุสเซีย -Name[tr]=Belarus Dili -Name[tt]=Belarusça -Name[uk]=БілоруÑька -Name[uz]=Beloruscha -Name[uz@cyrillic]=БелоруÑча -Name[vi]=Be-la-ru-xợ -Name[wa]=Bielorûsse -Name[zh_CN]=白俄罗斯语 -Name[zh_HK]=白俄羅斯語 -Name[zh_TW]=白俄羅斯語 -Name[zu]=Isi-Belarusian -[bg] -Name=Bulgarian -Name[af]=Bulgaars -Name[ar]=البلغارية -Name[az]=Bolqarca -Name[be]=БалгарÑÐºÐ°Ñ -Name[bg]=БългарÑки -Name[bn]=বà§à¦²à¦—েরিয় -Name[br]=Bulgareg -Name[bs]=Bugarski -Name[ca]=Búlgar -Name[cs]=Bulharský -Name[csb]=Bùlgarsczi -Name[cy]=Bwlgareg -Name[da]=Bulgarsk -Name[de]=Bulgarisch -Name[el]=ΒουλγαÏικά -Name[eo]=Bulgara -Name[es]=Búlgaro -Name[et]=Bulgaaria -Name[eu]=Bulgariera -Name[fa]=بلغاری -Name[fi]=Bulgaria -Name[fr]=Bulgare -Name[fy]=Bulgaarsk -Name[ga]=Bulgáiris -Name[gl]=Búlgaro -Name[he]=בולגרית -Name[hi]=बलà¥à¤—ारियन -Name[hr]=Bugarski -Name[hsb]=BoÅ‚harsce -Name[hu]=Bolgár -Name[id]=Bulgaria -Name[is]=Búlgarska -Name[it]=Bulgaro -Name[ja]=ブルガリア語 -Name[ka]=ბულგáƒáƒ áƒ£áƒšáƒ˜ -Name[kk]=Болғарша -Name[km]=ប៊ុលហ្ការី -Name[ko]=불가리아어 -Name[lb]=Bulgaresch -Name[lt]=Bulgarų -Name[lv]=BulgÄru -Name[mi]=Reo Purukeria -Name[mk]=БугарÑки -Name[mn]=Болгар -Name[ms]=Bulgaria -Name[mt]=Bulgaru -Name[nb]=Bulgarsk -Name[nds]=Bulgaarsch -Name[ne]=बà¥à¤²à¥à¤—ेरियाली -Name[nl]=Bulgaars -Name[nn]=Bulgarsk -Name[nso]=Se-Bulgarian -Name[oc]=Bulgar -Name[pa]=ਬà©à¨²à¨—ਾਰੀਆ -Name[pl]=BuÅ‚garski -Name[pt]=Búlgaro -Name[pt_BR]=Búlgaro -Name[ro]=Bulgară -Name[ru]=БолгарÑкий -Name[rw]=Ikinyabulugariya -Name[se]=Bulgáriagiella -Name[sk]=bulharÄina -Name[sl]=bolgarsko -Name[sq]=Bullgarisht -Name[sr]=БугарÑки -Name[sr@Latn]=Bugarski -Name[ss]=Si-Bulgarian -Name[sv]=Bulgariska -Name[ta]=பலà¯à®•à¯‡à®°à®¿à®¯à®©à¯ -Name[te]=బలà±à°—ెరియనౠ-Name[tg]=Булғорӣ -Name[th]=ภาษาบัลà¹à¸à¹€à¸£à¸µà¸¢ -Name[tr]=Bulgarca -Name[tt]=Bulgarça -Name[uk]=БолгарÑька -Name[uz]=Bolgarcha -Name[uz@cyrillic]=Болгарча -Name[vi]=Bảo-gia-lÆ¡i -Name[wa]=BulgÃ¥re -Name[zh_CN]=ä¿åŠ åˆ©äºšè¯­ -Name[zh_HK]=ä¿åŠ åˆ©äºžèªž -Name[zh_TW]=ä¿åŠ åˆ©äºžèªž -Name[zu]=Isi-Bulgarian -[bh] -Name=Bihari -Name[ar]=بهاري -Name[az]=BiharicÉ™ -Name[be]=БіхарÑÐºÐ°Ñ -Name[bg]=Бихари -Name[bn]=বিহারী -Name[ca]=Biharí -Name[cy]=Bihareg -Name[de]=Biharisch -Name[fa]=بیهاری -Name[fy]=Bihary -Name[ga]=Bihairis -Name[he]=ביהרי -Name[hi]=बिहारी -Name[hr]=Biharski -Name[ja]=ビãƒãƒ¼ãƒ«èªž -Name[ka]=ბიჰáƒáƒ áƒ˜ -Name[kk]=Бихарша -Name[km]=បិហារ -Name[ko]=비하르어 -Name[lb]=Biharesch -Name[mk]=Бихари -Name[mn]=Бихари -Name[ne]=बिहारी -Name[nso]=Se-Bihari -Name[pa]=ਬਿਹਾਰੀ -Name[ru]=БихарÑкий -Name[rw]=Ikibihari -Name[se]=Biháragiella -Name[sk]=bihárske jazyky -Name[sl]=bihari -Name[sq]=Biharisht -Name[sr]=БихарÑки -Name[sr@Latn]=Biharski -Name[ss]=Si-Bihari -Name[ta]=பீகாரி -Name[te]=బిహారి -Name[tg]=Бихарӣ -Name[th]=ภาษาบิฮาริ -Name[tt]=Biharça -Name[uk]=Біхарі -Name[uz]=Bixari -Name[uz@cyrillic]=Бихари -Name[vi]=Bi-ha-ri -Name[zh_CN]=比哈里语 -Name[zh_HK]=比哈爾語 -Name[zh_TW]=比哈爾語 -Name[zu]=Isi-Bihari -[bi] -Name=Bislama -Name[ar]=بيسلاما -Name[az]=Bislamaca -Name[be]=БіÑламÑÐºÐ°Ñ -Name[bg]=БиÑлама -Name[bn]=বিসলামা -Name[cy]=Bislameg -Name[fa]=بیسلاما -Name[fr]=Bichlamar -Name[ga]=Bioslamais -Name[he]=ביסלמה -Name[hi]=बिसà¥à¤²à¤¾à¤®à¤¾ -Name[hr]=Bislamski -Name[hu]=Biszlama -Name[ja]=ビスラマ語 -Name[ka]=ბისლáƒáƒ›áƒ -Name[kk]=БиÑамша -Name[km]=បីសឡាម៉ា -Name[ko]=비슬ë¼ë§ˆì–´ -Name[mk]=БиÑлама -Name[mn]=БиÑлам -Name[ne]=बिसà¥à¤²à¤¾à¤®à¤¾ -Name[nso]=Se-Bislama -Name[pa]=ਬਿਸਲਾਮਾ -Name[ru]=БиÑлама -Name[rw]=Ikibisilamu -Name[se]=Bislamagiella -Name[sk]=bislama -Name[sl]=bislama -Name[sq]=Bislamisht -Name[sr]=БиÑламÑки -Name[sr@Latn]=Bislamski -Name[ss]=Si-Bislama -Name[ta]=பிஸà¯à®²à®¾à®®à®¾ -Name[te]=బిసà±à°²à°®à°¾ -Name[tg]=БиÑлама -Name[th]=ภาษาบิสลามา -Name[tt]=Bislamaça -Name[uk]=БіÑлама -Name[uz@cyrillic]=БиÑлама -Name[vi]=Bit-la-ma -Name[zh_CN]=比斯拉马语 -Name[zh_HK]=Bislama語 -Name[zh_TW]=Bislama語 -Name[zu]=Isi-Bislama -[bn] -Name=Bengali -Name[ar]=بنغالي -Name[az]=Benqalca -Name[be]=БенгальÑÐºÐ°Ñ -Name[bg]=Бенгали -Name[bn]=বাংলা -Name[br]=Bangali -Name[bs]=Bengalski -Name[ca]=Bengalí -Name[cs]=Bengálský -Name[csb]=Bengalsczi -Name[cy]=Bengaleg -Name[eo]=Bengala -Name[es]=Bengalí -Name[eu]=Bengalera -Name[fa]=بنگلادشی -Name[fy]=Bengaalsk -Name[ga]=Beangáilis -Name[he]=בנגלית -Name[hi]=बंगाली -Name[hr]=Bengalski -Name[hsb]=Bengalsce -Name[hu]=Bengáli -Name[is]=Bengalst -Name[it]=Bengalese -Name[ja]=ベンガル語 -Name[ka]=ბენგáƒáƒšáƒ˜ -Name[kk]=Бенгали -Name[km]=áž”áŸáž“្កាលី -Name[ko]=벵갈어 -Name[lb]=Bengalesch -Name[lt]=Bengalų -Name[lv]=BengÄļu -Name[mk]=БенгалÑки -Name[mn]=Бенгали -Name[nds]=Bengaalsch -Name[ne]=बङà¥à¤—ाली -Name[nso]=Se-Bengali -Name[pa]=ਬੰਗਾਲੀ -Name[pl]=Bengalski -Name[ru]=Бенгали -Name[rw]=Ikibengali -Name[se]=Bengalagiella -Name[sk]=bengálÄina -Name[sl]=bengalsko -Name[sq]=Bengalisht -Name[sr]=БенгалÑки -Name[sr@Latn]=Bengalski -Name[ss]=Si-Bengali -Name[ta]=பெஙà¯à®•à®¾à®²à®¿ -Name[te]=బెంగాలి -Name[tg]=Бенголӣ -Name[th]=ภาษาเบงà¸à¸²à¸¥à¸µ -Name[tr]=Bengal -Name[tt]=Bengalça -Name[uk]=БенгальÑька -Name[uz]=Bengalcha -Name[uz@cyrillic]=Бенгалча -Name[vi]=Ben-ga-li -Name[zh_CN]=孟加拉语 -Name[zh_HK]=孟加拉語 -Name[zh_TW]=孟加拉語 -Name[zu]=Isi-Bengali -[bo] -Name=Tibetan -Name[ar]=تبتي -Name[az]=TibetcÉ™ -Name[be]=Ð¢Ñ‹Ð±ÐµÑ†ÐºÐ°Ñ -Name[bg]=ТибетÑки -Name[bn]=তিবà§à¦¬à¦¤à§€ -Name[br]=Yezh an Tibet -Name[bs]=Tibetanski -Name[ca]=Tibetà -Name[cs]=Tibetský -Name[csb]=TibetaÅ„sczi -Name[cy]=Tibeteg -Name[da]=Tibetansk -Name[de]=Tibetisch -Name[el]=Θιβετιανά -Name[eo]=Tibeta -Name[es]=Tibetano -Name[et]=Tiibeti -Name[eu]=Tibetera -Name[fa]=تیبوتیایی -Name[fi]=Tiibet -Name[fr]=Tibétain -Name[fy]=Tibetaansk -Name[ga]=Tibéidis -Name[gl]=Tibetano -Name[he]=טיבטית -Name[hi]=तिबà¥à¤¤à¥€ -Name[hr]=Tibetanski -Name[hsb]=Tibetisce -Name[hu]=Tibeti -Name[id]=Tibet -Name[is]=Tíbeska -Name[it]=Tibetano -Name[ja]=ãƒãƒ™ãƒƒãƒˆèªž -Name[ka]=ტიბეტური -Name[kk]=Тибетше -Name[km]=ទីប០-Name[ko]=티벳어 -Name[lb]=Tibetanesch -Name[lt]=TibetieÄių -Name[lv]=TibetieÅ¡u -Name[mk]=ТибетанÑки -Name[mn]=Төвд -Name[ms]=Tibet -Name[nb]=Tibetansk -Name[nds]=Tibeetsch -Name[ne]=तिबà¥à¤¬à¤¤à¥€ -Name[nl]=Tibetaans -Name[nn]=Tibetansk -Name[nso]=Se-Tibetan -Name[pa]=ਤਿੱਬਤੀ -Name[pl]=TybetaÅ„ski -Name[pt]=Tibetano -Name[pt_BR]=Tibetano -Name[ro]=Tibetană -Name[ru]=ТибетÑкий -Name[rw]=Ikinyatibeti -Name[se]=Tibehtagiella -Name[sk]=tibetÄina -Name[sl]=tibetansko -Name[sq]=Tibetisht -Name[sr]=ТибетанÑки -Name[sr@Latn]=Tibetanski -Name[ss]=Si-Tibetan -Name[sv]=Tibetanska -Name[ta]=திபெதà¯à®¤à®¿à®¯à®©à¯ -Name[te]=టిబెటియనౠ-Name[tg]=Тибетӣ -Name[th]=ภาษาฑิเบต -Name[tt]=Tibetçä -Name[uk]=ТибетÑька -Name[uz]=Tibetcha -Name[uz@cyrillic]=Тибетча -Name[vi]=Tây-tạng -Name[wa]=Tibetyin -Name[zh_CN]=è—语 -Name[zh_HK]=è—語 -Name[zh_TW]=è—語 -Name[zu]=Isi-Tibetan -[br] -Name=Breton -Name[ar]=البريتون -Name[az]=Bretonca -Name[be]=БрÑтонÑÐºÐ°Ñ -Name[bg]=БретонÑки -Name[bn]=বà§à¦°à§‡à¦Ÿà¦¨ -Name[br]=Brezhoneg -Name[bs]=Bretonski -Name[ca]=Bretó -Name[cs]=Bretonský -Name[csb]=BretoÅ„sczi -Name[cy]=Llydaweg -Name[da]=Bretonsk -Name[de]=Bretonisch -Name[el]=Î’Ïετονικά -Name[eo]=Bretona -Name[es]=Bretón -Name[et]=Bretooni -Name[eu]=Bretoiera -Name[fa]=برتونیایی -Name[fi]=Bretoni -Name[fy]=Bretonsk -Name[ga]=Briotáinis -Name[gl]=Bretón -Name[he]=ברטונית -Name[hi]=बà¥à¤°à¥‡à¤Ÿà¥‹à¤¨ -Name[hr]=Bretonski -Name[hsb]=Bretonisce -Name[is]=Bretánska -Name[it]=Bretone -Name[ja]=ブルトン語 -Name[ka]=ბრეტáƒáƒœáƒ£áƒšáƒ˜ -Name[kk]=Бретонша -Name[km]=ប្រឺážáž»áž„ -Name[ko]=브르타뉴어 -Name[lb]=Britesch -Name[lt]=Bretonų -Name[lv]=Bretoņu -Name[mi]=Reo Parani Uropi-Ãnia -Name[mk]=БретонÑки -Name[mn]=Бретон -Name[nb]=Bretonsk -Name[nds]=Bretoonsch -Name[ne]=बेलायती -Name[nl]=Bretoens -Name[nn]=Bretonsk -Name[nso]=Se-Breton -Name[oc]=Briton -Name[pa]=ਬਰੀਟੋਨ -Name[pl]=BretoÅ„ski -Name[pt]=Bretão -Name[pt_BR]=Bretão -Name[ro]=Bretonă -Name[ru]=БретонÑкий -Name[rw]=Ikinyabureto -Name[se]=Bretonagiella -Name[sk]=bretónÄina -Name[sl]=bretonsko -Name[sq]=Bretonisht -Name[sr]=БретонÑки -Name[sr@Latn]=Bretonski -Name[ss]=Si-Breton -Name[sv]=Bretonska -Name[ta]=பிரெடான௠-Name[te]=à°¬à±à°°à±†à°Ÿà°¨à± -Name[tg]=Бретонӣ -Name[th]=ภาษาเบรทตัน -Name[tr]=Britanya Dili -Name[tt]=Bretonça -Name[uk]=БретонÑька -Name[uz]=Bretoncha -Name[uz@cyrillic]=Бретонча -Name[vi]=Bợ-re-ton -Name[wa]=Burton -Name[zh_CN]=布里多尼语 -Name[zh_HK]=ä¸åˆ—塔尼語 -Name[zh_TW]=ä¸åˆ—塔尼語 -Name[zu]=Isi-Breton -[bs] -Name=Bosnian -Name[af]=Bosnies -Name[ar]=البوسنية -Name[az]=Bosnakca -Name[be]=БаÑнійÑÐºÐ°Ñ -Name[bg]=БоÑненÑки -Name[bn]=বসনীয় -Name[br]=Bosnieg -Name[bs]=Bosanski -Name[ca]=Bosnià -Name[cs]=Bosenský -Name[csb]=Bósniany -Name[cy]=Bosneg -Name[da]=Bosnisk -Name[de]=Bosnisch -Name[el]=Βοσνιακά -Name[eo]=Bosnia -Name[es]=Bosnio -Name[et]=Bosnia -Name[eu]=Bosniera -Name[fa]=بوسنیایی -Name[fi]=Bosnia -Name[fr]=Bosniaque -Name[fy]=Bosnysk -Name[ga]=Boisnis -Name[gl]=Bósnio -Name[he]=בוסנית -Name[hi]=बोसà¥à¤¨à¤¿à¤¯à¤¨ -Name[hr]=BoÅ¡njaÄki -Name[hsb]=Bosnisce -Name[hu]=Bosnyák -Name[id]=Bosnia -Name[is]=Bosníska -Name[it]=Bosniaco -Name[ja]=ボスニア語 -Name[ka]=ბáƒáƒ¡áƒœáƒ˜áƒ£áƒ áƒ˜ -Name[kk]=БоÑнаша -Name[km]=បូស្នី -Name[ko]=보스니아어 -Name[lb]=Bosnesch -Name[lt]=Bosnių -Name[lv]=BosnieÅ¡u -Name[mk]=БоÑанÑки -Name[mn]=БоÑни -Name[ms]=Bosnia -Name[mt]=Bożniaku -Name[nb]=Bosnisk -Name[nds]=Bosnisch -Name[ne]=बोसà¥à¤¨à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Bosnisch -Name[nn]=Bosnisk -Name[nso]=Se-Bosnian -Name[pa]=ਬੋਸਨੀਆ -Name[pl]=BoÅ›niacki -Name[pt]=Bósnio -Name[pt_BR]=Bósnio -Name[ro]=Bosniacă -Name[ru]=БоÑнийÑкий -Name[rw]=Ikinyabosiniya -Name[se]=Bosniagiella -Name[sk]=bosniaÄtina -Name[sl]=bosansko -Name[sq]=Boshnjakisht -Name[sr]=Бошњачки -Name[sr@Latn]=BoÅ¡njaÄki -Name[ss]=Si-Bosnian -Name[sv]=Bosniska -Name[ta]=பொஸà¯à®©à®¿à®¯à®©à¯ -Name[te]=బొసà±à°¨à°¿à°¯à°¨à± -Name[tg]=БоÑниÑвӣ -Name[th]=ภาษาบอสเนีย -Name[tr]=BoÅŸnakça -Name[tt]=Bosniçä -Name[uk]=БоÑнійÑька -Name[uz]=Bosniyacha -Name[uz@cyrillic]=БоÑниÑча -Name[ven]=Mubosinia -Name[vi]=Bo-x-ni-a -Name[wa]=Bosnyin -Name[zh_CN]=波斯尼亚语 -Name[zh_HK]=波斯尼亞語 -Name[zh_TW]=波士尼亞語 -Name[zu]=Isi-Bosnian -[ca] -Name=Catalan -Name[af]=Katelaans -Name[ar]=الكاتالونية -Name[az]=Katalanca -Name[be]=КаталонÑÐºÐ°Ñ -Name[bg]=КаталонÑки -Name[bn]=কà§à¦¯à¦¾à¦Ÿà¦¾à¦²à¦¾à¦¨ -Name[br]=Katalaneg -Name[bs]=Katalonski -Name[ca]=Català -Name[cs]=Katalánský -Name[csb]=KataloÅ„sczi -Name[cy]=Catalaneg -Name[da]=Catalansk -Name[de]=Katalanisch -Name[el]=Καταλανικά -Name[eo]=Kataluna -Name[es]=Catalán -Name[et]=Katalaani -Name[eu]=Katalaniera -Name[fa]=کاتالانی -Name[fi]=Katalaani -Name[fy]=Katalaansk -Name[ga]=Catalóinis -Name[gl]=Catalán -Name[he]=קטלונית -Name[hi]=केटालन -Name[hr]=Katalonski -Name[hsb]=Katalansce -Name[hu]=Katalán -Name[is]=Katalánska -Name[it]=Catalano -Name[ja]=カタロニア語 -Name[ka]=კáƒáƒ¢áƒáƒšáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Каталанша -Name[km]=កាážáž¶áž¡áž¶áž“ -Name[ko]=카탈로니아어 -Name[lb]=Katalanesch -Name[lt]=Katalonų -Name[lv]=Kataloņu -Name[mi]=Reo Peina Raki Räwhiti -Name[mk]=КаталонÑки -Name[mn]=Каталан -Name[mt]=Katalan -Name[nb]=Katalansk -Name[nds]=Katalaansch -Name[ne]=काटालान -Name[nl]=Catalaans -Name[nn]=Katalansk -Name[nso]=Se-Catalan -Name[pa]=ਕਾਟਾਲਾਨ -Name[pl]=KataloÅ„ski -Name[pt]=Catalão -Name[pt_BR]=Catalão -Name[ro]=Catalană -Name[ru]=КаталонÑкий -Name[rw]=Igikatalani -Name[se]=Katalánagiella -Name[sk]=katalánÄina -Name[sl]=katalonsko -Name[sq]=Katalanisht -Name[sr]=КаталонÑки -Name[sr@Latn]=Katalonski -Name[ss]=Si-Catalan -Name[sv]=Katalanska -Name[ta]=கடலான௠-Name[te]=కెటలనౠ-Name[tg]=Каталанӣ -Name[th]=ภาษาคาตาลาน -Name[tr]=Katalan Dili -Name[tt]=Katalança -Name[uk]=КаталонÑька -Name[uz]=Katalancha -Name[uz@cyrillic]=Каталанча -Name[vi]=Ca-ta-lan -Name[zh_CN]=加泰罗尼亚语 -Name[zh_HK]=嘉泰羅尼亞語 -Name[zh_TW]=嘉泰羅尼亞語 -Name[zu]=Isi-Catalan -[ce] -Name=Chechen -Name[ar]=شيشاني -Name[az]=ÇexencÉ™ -Name[be]=ЧачÑнÑÐºÐ°Ñ -Name[bg]=ЧеченÑки -Name[bn]=চেচেন -Name[br]=Tchetcheneg -Name[bs]=ÄŒeÄenski -Name[ca]=Txetxè -Name[cs]=ÄŒeÄenský -Name[csb]=CzeczeÅ„sczi -Name[cy]=Checheneg -Name[de]=Tschetschenisch -Name[eo]=Ĉeĉena -Name[es]=Checheno -Name[et]=TÅ¡etÅ¡eeni -Name[fa]=Ú†Ú†Ù†ÛŒ -Name[fi]=TÅ¡etÅ¡eeni -Name[fr]=Tchétchène -Name[fy]=Tsjechysk -Name[ga]=Seisnis -Name[gl]=Checheno -Name[he]=צ'צ'נית -Name[hi]=चेचेन -Name[hr]=ÄŒeÄenski -Name[hsb]=ÄŒeÄenisce -Name[hu]=Csecsen -Name[is]=Tékkneska -Name[it]=Ceceno -Name[ja]=ãƒã‚§ãƒã‚§ãƒ³èªž -Name[ka]=ჩეჩნური -Name[kk]=Шешенше -Name[km]=ឆáŸáž€ážˆáž·áž“ -Name[ko]=체첸어 -Name[lb]=Tschetschenesch -Name[lt]=ČėÄÄ—nų -Name[lv]=ÄŒeÄenu -Name[mk]=ЧеченÑки -Name[mn]=Чечен -Name[nb]=Tsjetsjensk -Name[nds]=Tschetscheensch -Name[ne]=चेचेन -Name[nn]=Tsjetsjensk -Name[nso]=Se-Chechen -Name[pa]=ਚੇਚਨ -Name[pl]=CzeczeÅ„ski -Name[pt]=Checheno -Name[pt_BR]=Chechênio -Name[ro]=Cecenă -Name[ru]=ЧеченÑкий -Name[rw]=Igiceceni -Name[se]=ÄŒeÄeniagiella -Name[sk]=ÄeÄenÄina -Name[sl]=ÄeÄensko -Name[sq]=Çeçenisht -Name[sr]=ЧеченÑки -Name[sr@Latn]=ÄŒeÄenski -Name[ss]=Si-Chechen -Name[sv]=Tjetjenska -Name[ta]=செசà¯à®šà¯†à®©à¯ -Name[te]=చెచనౠ-Name[tg]=Чеченӣ -Name[th]=ภาษาเชเชน -Name[tr]=Çeçen -Name[tt]=Çäçänçä -Name[uk]=ЧеченÑька -Name[uz]=Chechencha -Name[uz@cyrillic]=Чеченча -Name[vi]=Che-chen -Name[wa]=Tchetchene -Name[zh_CN]=车臣语 -Name[zh_HK]=Chechen語 -Name[zh_TW]=Chechen語 -Name[zu]=Isi-Chechen -[ch] -Name=Chamorro -Name[ar]=شامورو -Name[az]=Xamorroca -Name[be]=ЧаморÑÐºÐ°Ñ -Name[bg]=Чаморо -Name[bn]=চামোরো -Name[bs]=Kamoro -Name[cy]=Chamorreg -Name[eo]=Ĉamora -Name[fa]=کاماروئی -Name[ga]=Seamóróis -Name[he]=צ'מורו -Name[hi]=केमोरो -Name[hr]=ÄŒamorski -Name[is]=Chamorró -Name[ja]=ãƒãƒ£ãƒ¢ãƒ­èªž -Name[ka]=ჩáƒáƒ›áƒáƒ áƒ -Name[kk]=Чаморро -Name[km]=ចាមូរូ -Name[mk]=Чаморо -Name[mn]=Чаморро -Name[ne]=कà¥à¤¯à¤¾à¤®à¥‹à¤°à¥‹à¤¨à¥€ -Name[nso]=Se-Chamorro -Name[pa]=ਚਾਮੂਰੂ -Name[ro]=Camoro -Name[ru]=Чаморро -Name[rw]=Igishamoro -Name[se]=Chamorrogiella -Name[sk]=ÄamorÄina -Name[sl]=chamorro -Name[sq]=Kamoroisht -Name[sr]=ЧаморÑки -Name[sr@Latn]=ÄŒamorski -Name[ss]=Si-Chamorro -Name[ta]=சமாரோ -Name[te]=చమొరà±à°°à±Š -Name[tg]=Чаморроӣ -Name[th]=ภาษาชามอโร -Name[tt]=Çamorroça -Name[uk]=Чаморо -Name[uz@cyrillic]=Чаморро -Name[vi]=Cha-mo-rô -Name[zh_CN]=查莫罗语 -Name[zh_HK]=查摩洛語 -Name[zh_TW]=查摩洛語 -Name[zu]=Isi-Chamorro -[co] -Name=Corsican -Name[ar]=كورسيكي -Name[az]=Korsikaca -Name[be]=КарÑіканÑÐºÐ°Ñ -Name[bg]=КорÑиканÑки -Name[bn]=করà§à¦¸à¦¿à¦•à¦¾à¦¨ -Name[br]=Korseg -Name[bs]=Korzikanski -Name[ca]=Cors -Name[cs]=Korsický -Name[csb]=KòrsykaÅ„sczi -Name[cy]=Corsiceg -Name[da]=Korsikansk -Name[de]=Korsisch -Name[el]=ΚοÏσικανικά -Name[eo]=Korsika -Name[es]=Corso -Name[et]=Korsika -Name[eu]=Korsiera -Name[fa]=کورسیکانی -Name[fi]=Korsika -Name[fr]=Corse -Name[fy]=Korsikaansk -Name[ga]=Corsaicis -Name[gl]=Corso -Name[he]=קורסיקנית -Name[hi]=कॉरà¥à¤¸à¤¿à¤¯à¤¨ -Name[hr]=Korzikanski -Name[hsb]=Korsisce -Name[hu]=Korzikai -Name[is]=Korsíkanska -Name[it]=Corso -Name[ja]=コルシカ語 -Name[ka]=კáƒáƒ áƒ¡áƒ˜áƒ™áƒ£áƒšáƒ˜ -Name[kk]=КорÑиканша -Name[km]=កូស៊ីកា -Name[lb]=Korsesch -Name[lt]=KorsikieÄių -Name[lv]=KorsikieÅ¡u -Name[mk]=КорзиканÑки -Name[mn]=КорÑикан -Name[nb]=Korsikansk -Name[nds]=Korssch -Name[ne]=कोरà¥à¤¸à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Corsicaans -Name[nn]=Korsikansk -Name[nso]=Se-Corsican -Name[pa]=ਕà©à¨°à¨¸à©€à¨•à©‡à¨¨ -Name[pl]=KorsykaÅ„ski -Name[pt]=Corso -Name[ro]=Corsicană -Name[ru]=КорÑиканÑкий -Name[rw]=Igikoruse -Name[se]=Korsikagiella -Name[sk]=korziÄtina -Name[sl]=korzijÅ¡ko -Name[sq]=Korsikanisht -Name[sr]=КорзиканÑки -Name[sr@Latn]=Korzikanski -Name[ss]=Si-Corsican -Name[sv]=Korsikanska -Name[ta]=கோரà¯à®šà®¿à®•à®©à¯ -Name[te]=కొరà±à°¸à°¿à°•à°¨à± -Name[tg]=КорÑиканӣ -Name[th]=ภาษาคอร์ซิà¸à¸±à¸™ -Name[tt]=Korsikça -Name[uk]=КорÑиканÑька -Name[uz]=Korsikancha -Name[uz@cyrillic]=КорÑиканча -Name[vi]=Coa-xi-ca -Name[wa]=Corse -Name[zh_CN]=科西嘉语 -Name[zh_HK]=科西嘉語 -Name[zh_TW]=科西嘉語 -Name[zu]=Isi-Corsican -[cs] -Name=Czech -Name[af]=Tsjeggië -Name[ar]=التشيكية -Name[az]=ÇexcÉ™ -Name[be]=ЧÑшÑÐºÐ°Ñ -Name[bg]=Чешки -Name[bn]=চেক -Name[br]=Tchekeg -Name[bs]=ÄŒeÅ¡ki -Name[ca]=Txec -Name[cs]=ÄŒeský -Name[csb]=Czesczi -Name[cy]=Tsiec -Name[da]=Tjekkisk -Name[de]=Tschechisch -Name[el]=Τσέχικα -Name[eo]=ĈeÄ¥a -Name[es]=Checo -Name[et]=TÅ¡ehhi -Name[eu]=Txekiera -Name[fa]=Ú†Ú© -Name[fi]=TÅ¡ekki -Name[fr]=Tchèque -Name[fy]=Tsjechysk -Name[ga]=Seicis -Name[gl]=Checo -Name[he]=צ'כית -Name[hi]=चेक -Name[hr]=ÄŒeÅ¡ki -Name[hsb]=Čěsce -Name[hu]=Cseh -Name[id]=Ceko -Name[is]=Tékkneska -Name[it]=Ceco -Name[ja]=ãƒã‚§ã‚³èªž -Name[ka]=ჩეხური -Name[kk]=Чехше -Name[km]=ឆáŸáž€ -Name[ko]=체코어 -Name[lb]=Tschechesch -Name[lt]=ÄŒekų -Name[lv]=ÄŒehu -Name[mk]=Чешки -Name[mn]=Чех -Name[mt]=ÄŠek -Name[nb]=Tsjekkisk -Name[nds]=Tschechsch -Name[ne]=चेक -Name[nl]=Tsjechisch -Name[nn]=Tsjekkisk -Name[nso]=Se-Czech -Name[oc]=Chec -Name[pa]=ਚੈੱਕ -Name[pl]=Czeski -Name[pt]=Checo -Name[pt_BR]=Tcheco -Name[ro]=Cehă -Name[ru]=ЧешÑкий -Name[rw]=Ikinyaceke -Name[se]=ÄŒehkagiella -Name[sk]=korziÄtina -Name[sl]=ÄeÅ¡ko -Name[sq]=Çekisht -Name[sr]=Чешки -Name[sr@Latn]=ÄŒeÅ¡ki -Name[ss]=Si-Czech -Name[sv]=Tjeckiska -Name[ta]=செக௠-Name[te]=చెకౠ-Name[tg]=Чехӣ -Name[th]=เชค -Name[tr]=Çekçe -Name[tt]=Çexçä -Name[uk]=ЧеÑька -Name[uz]=Chexcha -Name[uz@cyrillic]=Чехча -Name[vi]=Séc -Name[wa]=Tcheke -Name[zh_CN]=æ·å…‹è¯­ -Name[zh_HK]=æ·å…‹èªž -Name[zh_TW]=æ·å…‹èªž -Name[zu]=Isi-Czech -[csb] -Name=Kashubian -Name[bg]=КашубÑки -Name[ca]=Caixubi -Name[da]=Kashubiansk -Name[de]=Kaschubisch -Name[es]=Casubio -Name[et]=KaÅ¡uubi -Name[fr]=Kachoube -Name[is]=Kashubíska -Name[it]=Casciubico -Name[ja]=カシューブ語 -Name[km]=ážáž¶áž áž·ážáž„់ -Name[nds]=Kaschuubsch -Name[pl]=Kaszubski -Name[sk]=kaÅ¡ubÄtina -Name[sr]=КашубианÑки -Name[sr@Latn]=КашубианÑки -Name[sv]=Kasjubiska -[cu] -Name=Church Slavic -Name[az]=KilisÉ™ Slavcası -Name[bg]=ЦърковноÑлавÑнÑки -Name[bn]=চারà§à¦š সà§à¦²à¦¾à¦­à¦¿à¦• -Name[br]=Slaveg an iliz -Name[bs]=Crkveno-slavenski -Name[ca]=Eslau eclesiàstic -Name[cs]=StaroslovÄ›nský -Name[csb]=Stôrôcerwiowò-sÅ‚owiaÅ„sczi -Name[cy]=Slaveg Eglwysol -Name[da]=Kirkeslavisk -Name[de]=Kirchenslawisch -Name[eo]=Eklezia Slava -Name[es]=Eslavo eclesiástico -Name[et]=Kirikuslaavi -Name[eu]=Church Eslaviera -Name[fa]=یوگوسلاویایی -Name[fi]=Kirkkoslaavi -Name[fr]=Slavon d'égise -Name[fy]=Tsjerk-slavysk -Name[ga]=Slaivis Eaglaise -Name[gl]=Eslávo Eclesiástico -Name[he]=סלבית כנסייתית -Name[hi]=चरà¥à¤š सà¥à¤²à¤¾à¤µà¤¿à¤• -Name[hr]=Crkveni pravoslavni -Name[hsb]=CyrkwinosÅ‚owjansce -Name[hu]=Szláv (egyházi) -Name[is]=Kirkju-slavneska -Name[it]=Slavo della Chiesa -Name[ja]=教会スラブ語 -Name[ka]=სáƒáƒ”კლესირსლáƒáƒ•áƒ£áƒ áƒ˜ -Name[kk]=Шірке ÑлавÑнша -Name[km]=ឆឺច ស្លាវិច -Name[ko]=êµíšŒ 슬ë¼ë¸Œì–´ -Name[lb]=Kiircheslawesch -Name[lt]=BažnytinÄ— slavų -Name[lv]=SlÄvu baznÄ«cas -Name[mk]=ЦрковноÑловенÑки -Name[mn]=Чүрч Ñлавик -Name[nb]=Kirkeslavisk -Name[nds]=Ooltslaawsch -Name[ne]=चरà¥à¤š सà¥à¤²à¤¾à¤­à¤¿à¤• -Name[nl]=Kerk Slavisch -Name[nn]=Kyrkjeslavisk -Name[nso]=Se-Church Slavic -Name[pa]=ਚੂਰਚ ਸਲਾਵਿਨ -Name[pl]=Starocerkiewno-sÅ‚owiaÅ„ski -Name[pt]=Igreja Eslava -Name[pt_BR]=Eslavo Clássico -Name[ro]=Slavă bisericească -Name[ru]=Церковно-ÑлавÑнÑкий -Name[rw]=Igisilavika -Name[se]=Slávagiella -Name[sk]=cirkevná slovanÄina -Name[sl]=cerkvena slovanÅ¡Äina -Name[sq]=Slavishte Kisthore -Name[sr]=Црквени правоÑлавни -Name[sr@Latn]=Crkveni pravoslavni -Name[ss]=Si-Church Slavic -Name[sv]=Kyrkoslaviska -Name[ta]=சரà¯à®šà¯ ஸà¯à®²à®¾à®µà®¿à®•à¯ -Name[te]=à°šà°°à±à°šà°¿ à°¸à±à°²à°¾à°µà°¿à°•à± -Name[tg]=СлавÑнии мазҳабӣ -Name[th]=ภาษาเชิร์ชสลาฟ -Name[tt]=Slavça, Çerkäw -Name[uk]=ЦерковноÑлов'ÑнÑька -Name[uz]=Cherkov-slovyancha -Name[uz@cyrillic]=Черков-ÑловÑнча -Name[ven]=Slavic Zwakereke -Name[vi]=Xla-vÆ¡ nhà thÆ¡ -Name[wa]=Eslave d' eglijhe -Name[zh_CN]=宗教斯拉夫语(å¤ä»£ä¿„语) -Name[zh_HK]=教堂斯拉夫語 -Name[zh_TW]=教堂斯拉夫語 -Name[zu]=Isi-Church Slavic -[cv] -Name=Chuvash -Name[ar]=شوÙاش -Name[az]=ÇuvaÅŸca -Name[be]=ЧувашÑÐºÐ°Ñ -Name[bg]=Чувашки -Name[bn]=চà§à¦­à¦¾à¦¶ -Name[br]=Tchuvasheg -Name[bs]=ÄŒuvaÅ¡ -Name[cs]=ÄŒuvaÅ¡ský -Name[csb]=Czuwasczi -Name[cy]=Chuvasheg -Name[de]=Tschuwaschisch -Name[eo]=ĈuvaÅa -Name[et]=TÅ¡uvaÅ¡i -Name[fa]=چواش -Name[fi]=TÅ¡uvassi -Name[fr]=Tchouvache -Name[ga]=Suvais -Name[he]=צ'ובשית -Name[hi]=चाउवेश -Name[hr]=ÄŒuvaÅ¡ki -Name[hsb]=ÄŒuwaÅ¡isce -Name[hu]=Csuvas -Name[ja]=ãƒãƒ¥ãƒ¯ã‚·ãƒ¥èªž -Name[ka]=ჩუვáƒáƒ¨áƒ£áƒ áƒ˜ -Name[kk]=Шуашша -Name[km]=ចូវ៉ាស -Name[ko]=추바시어 -Name[lb]=Chuvas -Name[lt]=ÄŒiuvašų -Name[lv]=ÄŒuvaÅ¡u -Name[mk]=Чуваш -Name[mn]=Чуваш -Name[nds]=Tschuwasch -Name[ne]=कà¥à¤¯à¥à¤­à¤¾à¤¸à¥€ -Name[nso]=Se-Chuvash -Name[pa]=ਚੂਵਸ਼ -Name[pl]=Czuwaski -Name[ro]=Ciuvaşă -Name[ru]=ЧувашÑкий -Name[rw]=Igicuvashi -Name[se]=Chuvashgiella -Name[sk]=ÄuvaÅ¡tina -Name[sl]=chuvash -Name[sq]=Çuvashisisht -Name[sr]=Чувашки -Name[sr@Latn]=ÄŒuvaÅ¡ki -Name[ss]=Si-Chuvash -Name[sv]=Tjuvasjiska -Name[ta]=சà¯à®µà®¾à®·à¯ -Name[te]=à°šà±à°µà°¾à°·à± -Name[tg]=Чувашӣ -Name[th]=ภาษาชูวาช -Name[tt]=Çuaşça -Name[uk]=ЧуваÑька -Name[uz]=Chuvashcha -Name[uz@cyrillic]=Чувашча -Name[vi]=Chu-va-xợ -Name[wa]=Tchouvache -Name[zh_CN]=楚瓦什语 -Name[zh_HK]=楚瓦士語 -Name[zh_TW]=楚瓦士語 -Name[zu]=Isi-Chuvash -[cy] -Name=Welsh -Name[af]=Wallies -Name[ar]=الويلزية -Name[az]=UelscÉ™ -Name[be]=УÑльÑÐºÐ°Ñ -Name[bg]=УелÑки -Name[bn]=ওয়েলà§â€Œà¦¶ -Name[br]=Kembraeg -Name[bs]=VelÅ¡ki -Name[ca]=Gal·lès -Name[cs]=WelÅ¡ský -Name[csb]=Walijsczi -Name[cy]=Cymraeg -Name[da]=Walisisk -Name[de]=Walisisch -Name[el]=Ουαλικά -Name[eo]=Valisa -Name[es]=Galés -Name[et]=Uelsi -Name[eu]=Galesa -Name[fa]=ولزی -Name[fi]=Wales -Name[fr]=Gallois -Name[fy]=Welsk -Name[ga]=Breatnais -Name[gl]=Galés -Name[he]=וולשית -Name[hi]=वेलà¥à¤¶ -Name[hr]=VelÅ¡ki -Name[hsb]=Kymrisce -Name[hu]=Velszi -Name[id]=Wales -Name[is]=Velska -Name[it]=Gallese -Name[ja]=ウェールズ語 -Name[ka]=უელსური -Name[kk]=УÑлÑше -Name[km]=វែល -Name[ko]=웨ì¼ìŠ¤ì–´ -Name[lb]=Walisesch -Name[lt]=VelsieÄių -Name[lv]=VelÅ¡u -Name[mk]=Велшки -Name[mn]=Вел -Name[ms]=Wales -Name[mt]=Welx -Name[nb]=Walisisk -Name[nds]=Waliessch -Name[ne]=वेलà¥à¤¸ -Name[nn]=Walisisk -Name[nso]=Se-Welsh -Name[pa]=ਵਾਲਿਸ਼ -Name[pl]=Walijski -Name[pt]=Galês -Name[pt_BR]=Gaulês -Name[ro]=Velşă -Name[ru]=УÑльÑкий -Name[rw]=Ikiwelishi -Name[se]=Walesagiella -Name[sk]=waleÅ¡tina -Name[sl]=valižansko -Name[sq]=Uelsh -Name[sr]=ВелшанÑки -Name[sr@Latn]=VelÅ¡anski -Name[ss]=Si-Welsh -Name[sv]=Walesiska -Name[ta]=வெலà¯à®·à¯ -Name[te]=వెలà±à°·à± -Name[tg]=УÑлÑÓ£ -Name[th]=ภาษาเวลช์ -Name[tt]=Welşçä -Name[uk]=УельÑька -Name[uz]=Uelscha -Name[uz@cyrillic]=УÑлÑча -Name[vi]=Ouen-x -Name[wa]=Walès -Name[zh_CN]=å¨å°”士 -Name[zh_HK]=å¨çˆ¾æ–¯èªž -Name[zh_TW]=å¨çˆ¾æ–¯èªž -Name[zu]=Isi-Welsh -[da] -Name=Danish -Name[af]=Deens -Name[ar]=الدنماركية -Name[az]=Danimarkaca -Name[be]=Ð”Ð°Ñ†ÐºÐ°Ñ -Name[bg]=ДатÑки -Name[bn]=ডà§à¦¯à¦¾à¦¨à¦¿à¦¶ -Name[br]=Daneg -Name[bs]=Danski -Name[ca]=Danès -Name[cs]=Dánský -Name[csb]=Dëńsczi -Name[cy]=Daneg -Name[da]=Dansk -Name[de]=Dänisch -Name[el]=Δανέζικα -Name[eo]=Dana -Name[es]=Danés -Name[et]=Taani -Name[eu]=Daniera -Name[fa]=دانمارکی -Name[fi]=Tanska -Name[fr]=Danois -Name[fy]=Deensk -Name[ga]=Danmhairgis -Name[gl]=Dinamarqués -Name[he]=דנית -Name[hi]=दानिश -Name[hr]=Danski -Name[hsb]=Dansce -Name[hu]=Dán -Name[id]=Denmark -Name[is]=Danska -Name[it]=Danese -Name[ja]=デンマーク語 -Name[ka]=დáƒáƒœáƒ˜áƒ£áƒ áƒ˜ -Name[kk]=Датша -Name[km]=ដាណឺម៉ាក -Name[ko]=ë´ë§ˆí¬ì–´ -Name[lb]=Dänesch -Name[lt]=Danų -Name[lv]=DÄņu -Name[mi]=Reo Tenemaka -Name[mk]=ДанÑки -Name[mn]=Дани -Name[mt]=Daniż -Name[nb]=Dansk -Name[nds]=Däänsch -Name[ne]=डेनिश -Name[nl]=Deens -Name[nn]=Dansk -Name[nso]=Se-Danish -Name[oc]=Danès -Name[pa]=ਡੈਨਿਸ਼ -Name[pl]=DuÅ„ski -Name[pt]=Dinamarquês -Name[pt_BR]=Dinamarquês -Name[ro]=Daneză -Name[ru]=ДатÑкий -Name[rw]=Ikidanwa -Name[se]=Dánskkagiella -Name[sk]=dánÄina -Name[sl]=dansko -Name[sq]=Danisht -Name[sr]=ДанÑки -Name[sr@Latn]=Danski -Name[ss]=Si-Danish -Name[sv]=Danska -Name[ta]=டேனிஷ௠-Name[te]=డెనిషౠ-Name[tg]=ДаниÑвӣ -Name[th]=ภาษาเดนมาร์ค -Name[tr]=Danimarka Dili -Name[tt]=Dança -Name[uk]=ДанÑька -Name[uz]=Daniyacha -Name[uz@cyrillic]=ДаниÑча -Name[vi]=Äan-mạch -Name[wa]=Daenwès -Name[zh_CN]=丹麦语 -Name[zh_HK]=丹麥語 -Name[zh_TW]=丹麥語 -Name[zu]=Isi-Danishi -[de] -Name=German -Name[af]=Duits -Name[ar]=الألمانية -Name[az]=Almanca -Name[be]=ÐÑÐ¼ÐµÑ†ÐºÐ°Ñ -Name[bg]=ÐемÑки -Name[bn]=জারà§à¦®à¦¾à¦¨ -Name[br]=Alamaneg -Name[bs]=NjemaÄki -Name[ca]=Alemany -Name[cs]=NÄ›mecký -Name[csb]=Miemiecczi -Name[cy]=Almaeneg -Name[da]=Tysk -Name[de]=Deutsch -Name[el]=ΓεÏμανικά -Name[eo]=Germana -Name[es]=Alemán -Name[et]=Saksa -Name[eu]=Alemaniera -Name[fa]=آلمانی -Name[fi]=Saksa -Name[fr]=Allemand -Name[fy]=Dútsk -Name[ga]=Gearmáinis -Name[gl]=Alemán -Name[he]=גרמנית -Name[hi]=जरà¥à¤®à¤¨ -Name[hr]=NjemaÄki -Name[hsb]=NÄ›msce -Name[hu]=Német -Name[id]=Jerman -Name[is]=Þýska -Name[it]=Tedesco -Name[ja]=ドイツ語 -Name[ka]=გერმáƒáƒœáƒ£áƒšáƒ˜ -Name[kk]=ÐеміÑше -Name[km]=អាល្លឺម៉ង់ -Name[ko]=ë…ì¼ì–´ -Name[lb]=Däitsch -Name[lt]=VokieÄių -Name[lv]=VÄcu -Name[mi]=Reo Tiamana -Name[mk]=ГерманÑки -Name[mn]=Герман -Name[ms]=Jerman -Name[mt]=Ä ermaniż -Name[nb]=Tysk -Name[nds]=Hoochdüütsch -Name[ne]=जरà¥à¤®à¤¨à¥€ -Name[nl]=Duits -Name[nn]=Tysk -Name[nso]=Se-German -Name[oc]=Alemani -Name[pa]=ਜਰਮਨ -Name[pl]=Niemiecki -Name[pt]=Alemão -Name[pt_BR]=Alemão -Name[ro]=Germană -Name[ru]=Ðемецкий -Name[rw]=Ikidage -Name[se]=Duiskkagiella -Name[sk]=nemÄina -Name[sl]=nemÅ¡ko -Name[sq]=Gjermanisht -Name[sr]=Ðемачки -Name[sr@Latn]=NemaÄki -Name[ss]=SiJalimani -Name[sv]=Tyska -Name[ta]=ஜெரà¯à®®à®©à¯ -Name[te]=జెరà±à°®à°¨à± -Name[tg]=Олмонӣ -Name[th]=ภาษาเยอรมัน -Name[tr]=Almanca -Name[tt]=Almança -Name[uk]=Ðімецька -Name[uz]=Nemischa -Name[uz@cyrillic]=ÐемиÑча -Name[ven]=Mudzhemeni -Name[vi]=Äức -Name[wa]=Almand -Name[xh]=Isijamani -Name[zh_CN]=德语 -Name[zh_HK]=德語 -Name[zh_TW]=德語 -Name[zu]=Isi-Jalimani -[dz] -Name=Dzongkha -Name[ar]=الجونغا -Name[az]=Dzunqxaca -Name[be]=Цонга -Name[bg]=Джонкгха -Name[bn]=জঙখা -Name[cy]=Dzongkhaeg -Name[fa]=زونگخا -Name[gl]=Dzongca -Name[he]=×’'ונקה -Name[hi]=à¤à¥‹à¤‚खा -Name[ja]=ゾンカ語 -Name[ka]=ჯáƒáƒœáƒ™áƒ (ბუტáƒáƒœáƒ˜) -Name[kk]=(Дзонгха) Бутанша -Name[km]=ដុងហ្កា -Name[ko]=부탄어 -Name[mk]=Ðонгха -Name[mn]=Жонгха -Name[ne]=जोङà¥à¤–ा -Name[nso]=Se-Dzongkha -Name[pa]=ਡਜ਼ੋਨਗਖਾ -Name[ru]=Дзонгка (Бутан) -Name[rw]=Ikinyazongika -Name[se]=Dzongkhagiella -Name[sk]=dzongkä -Name[sl]=dzonkha -Name[sq]=Xonganisht -Name[sr]=Ðонка -Name[sr@Latn]=Džonka -Name[ss]=Si-Dzongkha -Name[ta]=டà¯à®šà¯Šà®™à¯à®•à¯à®¹à®¾ -Name[te]=జొంగà±à°– -Name[tg]=Дзонгка (Бутан) -Name[th]=ภาษาซองคา -Name[tt]=Dzongxaça -Name[uk]=Дзонгка -Name[uz]=Dzongxa -Name[uz@cyrillic]=Дзонгха -Name[vi]=Ä-xong-kha -Name[wa]=Boutanès -Name[zh_CN]=ä¸ä¸¹å®—å¡è¯­ -Name[zh_HK]=Dzongkha語 -Name[zh_TW]=Dzongkha語 -Name[zu]=Isi-Dzongkha -[el] -Name=Greek -Name[af]=Grieks -Name[ar]=اليونانية -Name[az]=Yunanca -Name[be]=ГрÑÑ†ÐºÐ°Ñ -Name[bg]=Гръцки -Name[bn]=গà§à¦°à§€à¦• -Name[br]=Gresianeg -Name[bs]=GrÄki -Name[ca]=Grec -Name[cs]=Řecký -Name[csb]=Grecczi -Name[cy]=Groeg -Name[da]=Græsk -Name[de]=Griechisch -Name[el]=Ελληνικά -Name[eo]=Greka -Name[es]=Griego -Name[et]=Kreeka -Name[eu]=Grekoa -Name[fa]=یونانی -Name[fi]=Kreikka -Name[fr]=Grec -Name[fy]=Gryks -Name[ga]=Gréigis -Name[gl]=Grego -Name[he]=יוונית -Name[hi]=यूनानी -Name[hr]=GrÄki -Name[hsb]=Grjeksce -Name[hu]=Görög -Name[id]=Yunani -Name[is]=Gríska -Name[it]=Greco -Name[ja]=ギリシャ語 -Name[ka]=ბერძნული -Name[kk]=Грекше -Name[km]=ក្រិក -Name[ko]=그리스어 -Name[lb]=Griichesch -Name[lt]=Graikų -Name[lv]=GrieÄ·u -Name[mi]=Reo Kariki -Name[mk]=Грчки -Name[mn]=Грек -Name[mt]=Grieg -Name[nb]=Gresk -Name[nds]=Greeksch -Name[ne]=गà¥à¤°à¥€à¤• -Name[nl]=Grieks -Name[nn]=Gresk -Name[nso]=Se-Greek -Name[oc]=Grec -Name[pa]=ਗਰੀਕ -Name[pl]=Grecki -Name[pt]=Grego -Name[pt_BR]=Grego -Name[ro]=Greacă -Name[ru]=ГречеÑкий -Name[rw]=Ikigereki -Name[se]=Greikkagiella -Name[sk]=gréÄtina -Name[sl]=grÅ¡ko -Name[sq]=Greqisht -Name[sr]=Грчки -Name[sr@Latn]=GrÄki -Name[ss]=SiGriki -Name[sv]=Grekiska -Name[ta]=கிரேகà¯à®•à®®à¯ -Name[te]=à°—à±à°°à±€à°•à± -Name[tg]=Юнонӣ -Name[th]=ภาษาà¸à¸£à¸µà¸ -Name[tr]=Yunanca -Name[tt]=Yunança -Name[uk]=Грецька -Name[uz]=Yunoncha -Name[uz@cyrillic]=Юнонча -Name[ven]=Mugerika -Name[vi]=Hy-lạp -Name[wa]=Grek -Name[xh]=isigrike -Name[zh_CN]=希腊语 -Name[zh_HK]=希臘語 -Name[zh_TW]=希臘語 -Name[zu]=Isi-Grike -[en] -Name=English -Name[af]=Engels -Name[ar]=الإنجليزية -Name[az]=Ä°ngliscÉ™ -Name[be]=ÐнглійÑÐºÐ°Ñ -Name[bg]=ÐнглийÑки -Name[bn]=ইংরেজ -Name[br]=Saozneg -Name[bs]=Engleski -Name[ca]=Anglès -Name[cs]=Anglický -Name[csb]=Anielsczi -Name[cy]=Saesneg -Name[da]=Engelsk -Name[de]=Englisch -Name[el]=Αγγλικά -Name[eo]=Angla -Name[es]=Inglés -Name[et]=Inglise -Name[eu]=Ingelesa -Name[fa]=انگلیسی -Name[fi]=Englanti -Name[fr]=Anglais -Name[fy]=Ingelsk -Name[ga]=Béarla -Name[gl]=Inglés -Name[he]=×נגלית -Name[hi]=अंगà¥à¤°à¥‡à¤œà¤¼à¥€ -Name[hr]=Engleski -Name[hsb]=Jendźelsce -Name[hu]=Angol -Name[id]=Inggris -Name[is]=Enska -Name[it]=Inglese -Name[ja]=英語 -Name[ka]=ინგლისური -Name[kk]=Ðғылшынша -Name[km]=អង់គ្លáŸážŸ -Name[ko]=ì˜ì–´ -Name[lb]=Englesch -Name[lt]=Anglų -Name[lv]=Angļu -Name[mi]=Reo Päkehä -Name[mk]=ÐнглиÑки -Name[mn]=Ðнгли -Name[ms]=Inggeris -Name[mt]=Ingliż -Name[nb]=Engelsk -Name[nds]=Engelsch -Name[ne]=अङà¥à¤—à¥à¤°à¥‡à¤œà¥€ -Name[nl]=Engels -Name[nn]=Engelsk -Name[nso]=Sekgowa -Name[oc]=Anglès -Name[pa]=ਅੰਗਰੇਜ਼ੀ -Name[pl]=Angielski -Name[pt]=Inglês -Name[pt_BR]=Inglês -Name[ro]=Engleză -Name[ru]=ÐнглийÑкий -Name[rw]=Icyongereza -Name[se]=EÅ‹gelasgiella -Name[sk]=angliÄtina -Name[sl]=angleÅ¡ko -Name[sq]=Anglisht -Name[sr]=ЕнглеÑки -Name[sr@Latn]=Engleski -Name[ss]=SiNgisi -Name[sv]=Engelska -Name[ta]=ஆஙà¯à®•à®¿à®²à®®à¯ -Name[te]=ఆంగà±à°²à°‚ -Name[tg]=ÐнглиÑÓ£ -Name[th]=ภาษาอังà¸à¸¤à¸© -Name[tr]=Ä°ngilizce -Name[tt]=Ä°nglizçä -Name[uk]=ÐнглійÑька -Name[uz]=Inglizcha -Name[uz@cyrillic]=Инглизча -Name[ven]=Luisimane -Name[vi]=Anh -Name[wa]=Inglès -Name[xh]=Isingesi -Name[zh_CN]=英语 -Name[zh_HK]=英語 -Name[zh_TW]=英語 -Name[zu]=Isi-Ngisi -[en_GB] -Name=British English -Name[af]=Britse Engels -Name[be]=ÐнглійÑÐºÐ°Ñ Ð±Ñ€Ñ‹Ñ‚Ð°Ð½ÑÐºÐ°Ñ -Name[bg]=БританÑки английÑки -Name[bn]=বৃটিশ ইংরেজি -Name[br]=Saozneg eus Bro Saoz -Name[bs]=Britanski engleski -Name[ca]=Anglès britànic -Name[cs]=Britská angliÄtina -Name[csb]=Britijsczi anielsczi -Name[cy]=Saesneg Prydain -Name[da]=Britisk engelsk -Name[de]=Englisch (UK) -Name[el]=Αγγλικά (Îœ. Î’Ïετανίας) -Name[eo]=Brita Angla -Name[es]=Inglés británico -Name[et]=Briti inglise -Name[eu]=Ingelesa (britainiarra) -Name[fa]=انگلیسی بریتانیایی -Name[fi]=Brittienglanti -Name[fr]=Anglais britannique -Name[fy]=Britsk Ingelsk -Name[ga]=Béarla na Sasanach -Name[gl]=Inglés de GB -Name[he]=×נגלית בריטית -Name[hr]=Britanski Engleski -Name[hsb]=Jendźelsce (WB) -Name[hu]=Angol (brit) -Name[id]=Inggris Inggris -Name[is]=Bresk enska -Name[it]=Inglese britannico -Name[ja]=イギリス英語 -Name[ka]=ინგლისური (დიდი ბრიტáƒáƒœáƒ”თი) -Name[kk]=Британдық ағылшынша -Name[km]=អង់គ្លáŸážŸ (អង់គ្លáŸážŸ) -Name[lb]=Britescht Englesch -Name[lt]=Anglų (D.Britanijos) -Name[lv]=Britu angļu -Name[mk]=ÐнглиÑки (британÑки) -Name[nb]=Britisk engelsk -Name[nds]=Britsch Engelsch -Name[ne]=बेलायती अङà¥à¤—à¥à¤°à¥‡à¤œà¥€ -Name[nl]=Engels (Brits) -Name[nn]=Engelsk (Storbritannia) -Name[pa]=ਅੰਗਰੇਜ਼ੀ ਬਰਤਾਨੀਆ -Name[pl]=Angielski brytyjski -Name[pt]=Inglês da Grã-Bretanha -Name[pt_BR]=Inglês Britânico -Name[ro]=Engleză britanică -Name[ru]=ÐнглийÑкий (ВеликобританиÑ) -Name[rw]=Icyongereza, Nyongereza -Name[se]=EÅ‹gelasgiella (Stuorra Brittania) -Name[sk]=angliÄtina (Spojené kráľovstvo) -Name[sl]=britansko angleÅ¡ko -Name[sr]=БританÑки енглеÑки -Name[sr@Latn]=Britanski engleski -Name[sv]=Brittisk engelska -Name[ta]=பிரிடà¯à®Ÿà®¿à®·à¯ ஆஙà¯à®•à®¿à®²à®®à¯ -Name[te]=à°¬à±à°°à°¿à°Ÿà°¿à°·à± ఆంగà±à°²à°‚ -Name[tg]=ÐнглиÑÓ£(Британӣ) -Name[th]=ภาษาอังà¸à¸¤à¸© บริติช -Name[tr]=Ä°ngiliz Ä°ngilizcesi -Name[tt]=Ä°nglizçä (Britania) -Name[uk]=ÐнглійÑька (ВеликобританіÑ) -Name[uz]=Inglizcha (Angliya) -Name[uz@cyrillic]=Инглизча (ÐнглиÑ) -Name[vi]=Anh (quốc Anh) -Name[wa]=Inglès britanike -Name[zh_CN]=英国英语 -Name[zh_HK]=英å¼è‹±èªž -Name[zh_TW]=(英å¼ï¼‰è‹±èªž -[en_US] -Name=American English -Name[af]=Amerikaanse Engels -Name[be]=ÐнглійÑÐºÐ°Ñ Ð°Ð¼ÐµÑ€Ñ‹ÐºÐ°Ð½ÑÐºÐ°Ñ -Name[bg]=ÐмериканÑки английÑки -Name[bn]=মারà§à¦•à¦¿à¦¨ ইংরেজি -Name[br]=Saozneg eus SUA -Name[bs]=AmeriÄki engleski -Name[ca]=Anglès americà -Name[cs]=Americká angliÄtina -Name[csb]=AmerikaÅ„sczi anielsczi -Name[da]=Amerikansk engelsk -Name[de]=Englisch (US) -Name[el]=Αγγλικά (ΑμεÏικής) -Name[eo]=Usona Angla -Name[es]=Inglés americano -Name[et]=Ameerika inglise -Name[eu]=Ingelesa (amerikarra) -Name[fa]=انگلیسی امریکایی -Name[fi]=Amerikanenglanti -Name[fr]=Anglais américain -Name[fy]=Amerikaansk Ingelsk -Name[ga]=Béarla Mheiriceá -Name[gl]=Inglés Americano -Name[he]=×נגלית ×מרק×ית -Name[hr]=AmeriÄki Engleski -Name[hsb]=Jendźelsce (USA) -Name[hu]=Angol (amerikai) -Name[id]=Inggris Amerika -Name[is]=Bandarísk enska -Name[it]=Inglese americano -Name[ja]=アメリカ英語 -Name[ka]=ინგლისური (áƒáƒ¨áƒ¨) -Name[kk]=Ðмерикандық ағылшынша -Name[km]=អង់គ្លáŸážŸ អាមáŸážšáž·áž€ -Name[lb]=Amerikanescht Englesch -Name[lt]=Anglų (JAV) -Name[lv]=AmerikÄņu angļu -Name[mk]=ÐнглиÑки (американÑки) -Name[nb]=Amerikansk engelsk -Name[nds]=Amerikaansch Engelsch -Name[ne]=अमेरेकी अङà¥à¤—à¥à¤°à¥‡à¤œà¥€ -Name[nl]=Engels (Amerikaans) -Name[nn]=Engelsk (USA) -Name[pa]=ਅੰਗਰੇਜ਼ੀ ਅਮਰੀਕੀ -Name[pl]=Angielski amerykaÅ„ski -Name[pt]=Inglês Americano -Name[pt_BR]=Inglês Americano -Name[ro]=Engleză americană -Name[ru]=ÐнглийÑкий (СШÐ) -Name[rw]=Icyongereza cy'Amerika -Name[se]=EÅ‹gelasgiella (AmerihkáhlaÅ¡) -Name[sk]=angliÄtina (USA) -Name[sl]=ameriÅ¡ko angleÅ¡ko -Name[sr]=Ðмерички енглеÑки -Name[sr@Latn]=AmeriÄki engleski -Name[sv]=Amerikansk engelska -Name[ta]=அமெரிகà¯à®•à®©à¯ ஆஙà¯à®•à®¿à®²à®®à¯ -Name[te]=అమెరికనౠఆంగà±à°²à°‚ -Name[tg]=ÐнглиÑÓ£(Ðмрикоӣ) -Name[th]=ภาษาอังà¸à¸¤à¸© อเมริà¸à¸±à¸™ -Name[tr]=Amerikan Ä°ngilizcesi -Name[tt]=Ä°nglizçä (Amerika) -Name[uk]=ÐнглійÑька (СШÐ) -Name[uz]=Inglizcha (AQSH) -Name[uz@cyrillic]=Инглизча (ÐҚШ) -Name[vi]=Anh (Mỹ) -Name[zh_CN]=美国英语 -Name[zh_HK]=美å¼è‹±èªž -Name[zh_TW]=美語 -[eo] -Name=Esperanto -Name[ar]=الإسبرانتو -Name[az]=Esperantoca -Name[be]=ЭÑперанта -Name[bg]=ЕÑперанто -Name[bn]=à¦à¦¸à§à¦ªà¦¾à¦°à¦¾à¦¨à§à¦¤à§‹ -Name[br]=Esperanteg -Name[eu]=Esperantoa -Name[fa]=اسپرانتور -Name[fr]=Espéranto -Name[he]=×ספרנטו -Name[hi]=à¤à¤¸à¥à¤ªà¤°à¥‡à¤‚तो -Name[hu]=Eszperantó -Name[ja]=エスペラント語 -Name[ka]=ესპერáƒáƒœáƒ¢áƒ -Name[kk]=ЭÑперанто -Name[km]=អáŸážŸáŸ’áž–áŸážšáŸ‰áž¶áž“់ážáž¼ -Name[ko]=ì—스페란토 -Name[mk]=ЕÑперанто -Name[mn]=ÐÑпиранто -Name[ne]=इसà¥à¤ªà¥‡à¤°à¤¾à¤¨à¥à¤¤à¥‹ -Name[nso]=Se-Esperanto -Name[oc]=Esperantò -Name[pa]=ਇਸਪੀਰਨਟੋ -Name[ru]=ЭÑперанто -Name[rw]=Icyesiperanto -Name[sk]=esperanto -Name[sl]=esperanto -Name[sr]=ЕÑперанто -Name[ss]=Si-Esperanto -Name[ta]=எஸà¯à®ªà®°à®¾à®©à¯à®Ÿà¯‹ -Name[te]=à°Žà°¸à±à°ªà°°à°¾à°¨à±à°Ÿà±Š -Name[tg]=ЭÑперантоӣ -Name[th]=ภาษาเอสเปอร์รันโต -Name[tt]=Esperantoça -Name[uk]=ЕÑперанто -Name[uz@cyrillic]=ЭÑперанто -Name[vi]=Ét-pe-ran-tô -Name[zh_CN]=世界语 -Name[zh_HK]=世界語 -Name[zh_TW]=世界語 -Name[zu]=Isi-Esperanto -[es] -Name=Spanish -Name[af]=Spaans -Name[ar]=الأسبانية -Name[az]=Ä°spanca -Name[be]=ІÑпанÑÐºÐ°Ñ -Name[bg]=ИÑпанÑки -Name[bn]=সà§à¦ªà§à¦¯à¦¾à¦¨à¦¿à¦¶ -Name[br]=Spagnoleg -Name[bs]=Å panski -Name[ca]=Espanyol -Name[cs]=Å panÄ›lský -Name[csb]=SzpaÅ„sczi -Name[cy]=Sbaeneg -Name[da]=Spansk -Name[de]=Spanisch -Name[el]=Ισπανικά -Name[eo]=Hispana -Name[es]=Español -Name[et]=Hispaania -Name[eu]=Gaztelera -Name[fa]=اسپانیایی -Name[fi]=Espanja -Name[fr]=Espagnol -Name[fy]=Spaansk -Name[ga]=Spáinnis -Name[gl]=Castellano -Name[he]=ספרדית -Name[hi]=सà¥à¤ªà¥‡à¤¨à¥€ -Name[hr]=Å panjolski -Name[hsb]=Å panisce -Name[hu]=Spanyol -Name[id]=Spanyol -Name[is]=Spánska -Name[it]=Spagnolo -Name[ja]=スペイン語 -Name[ka]=ესპáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=ИÑпанша -Name[km]=អáŸážŸáŸ’ប៉ាញ -Name[ko]=스페ì¸ì–´ -Name[lb]=Spuenesch -Name[lt]=Ispanų -Name[lv]=SpÄņu -Name[mi]=Reo Peina -Name[mk]=ШпанÑки -Name[mn]=ИÑпани -Name[ms]=Sepanyol -Name[mt]=Spanjol -Name[nb]=Spansk -Name[nds]=Spaansch -Name[ne]=सà¥à¤ªà¥‡à¤¨à¤¿à¤¶ -Name[nl]=Spaans -Name[nn]=Spansk -Name[nso]=Se-Spanish -Name[oc]=Espanhòl -Name[pa]=ਸਪੇਨੀ -Name[pl]=HiszpaÅ„ski -Name[pt]=Espanhol -Name[pt_BR]=Espanhol -Name[ro]=Spaniolă -Name[ru]=ИÑпанÑкий -Name[rw]=Igisipanyole -Name[se]=Spánskkagiella -Name[sk]=Å¡panielÄina -Name[sl]=Å¡pansko -Name[sq]=Spanjollisht -Name[sr]=ШпанÑки -Name[sr@Latn]=Å panski -Name[ss]=SiSpanishi -Name[sv]=Spanska -Name[ta]=ஸà¯à®ªà®¾à®©à®¿à®¯ -Name[te]=à°¸à±à°ªà±†à°¨à°¿à°·à± -Name[tg]=ИÑпанӣ -Name[th]=ภาษาสเปน -Name[tr]=Ä°spanyolca -Name[tt]=Ä°spança -Name[uk]=ІÑпанÑька -Name[uz]=Ispancha -Name[uz@cyrillic]=ИÑпанча -Name[vi]=Tây-ban-nha -Name[wa]=Castiyan -Name[xh]=Isipanishi -Name[zh_CN]=西ç­ç‰™è¯­ -Name[zh_HK]=西ç­ç‰™èªž -Name[zh_TW]=西ç­ç‰™èªž -Name[zu]=Isi-Penishi -[et] -Name=Estonian -Name[af]=Estonianse -Name[ar]=الإستونية -Name[az]=Estonca -Name[be]=ЭÑтонÑÐºÐ°Ñ -Name[bg]=ЕÑтонÑки -Name[bn]=à¦à¦¸à§à¦Ÿà§‹à¦¨à§€à§Ÿ -Name[br]=Estoneg -Name[bs]=Estonski -Name[ca]=Estonià -Name[cs]=Estonský -Name[csb]=EstoÅ„sczi -Name[cy]=Estoneg -Name[da]=Estisk -Name[de]=Estnisch -Name[el]=Εσθονικά -Name[eo]=Estlanda -Name[es]=Estonio -Name[et]=Eesti -Name[eu]=Estoniera -Name[fa]=استونیایی -Name[fi]=Eesti -Name[fr]=Estonien -Name[fy]=Estsk -Name[ga]=Eastóinis -Name[gl]=Estoniano -Name[he]=×סטונית -Name[hi]=à¤à¤¸à¥à¤¤à¥‹à¤¨à¤¿à¤¯à¤¨ -Name[hr]=Estonski -Name[hsb]=Estnisce -Name[hu]=Észt -Name[id]=Estonia -Name[is]=Eistneska -Name[it]=Estone -Name[ja]=エストニア語 -Name[ka]=ესტáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=ЭÑтонша -Name[km]=អáŸážŸáŸ’ážáž¼áž“ី -Name[ko]=ì—스토니아어 -Name[lb]=Estnesch -Name[lt]=Estų -Name[lv]=Igauņu -Name[mi]=Reo Etonia -Name[mk]=ЕÑтонÑки -Name[mn]=ЭÑтони -Name[ms]=Estonia -Name[mt]=Estonjan -Name[nb]=Estisk -Name[nds]=Estnsch -Name[ne]=इसà¥à¤Ÿà¥‹à¤¨à¤¿à¤¯à¤¨ -Name[nl]=Ests -Name[nn]=Estisk -Name[nso]=Se-Estonian -Name[pa]=ਇਸਟੋਨੀਆ -Name[pl]=EstoÅ„ski -Name[pt]=Estónio -Name[pt_BR]=Estoniano -Name[ro]=Estoniană -Name[ru]=ЭÑтонÑкий -Name[rw]=Icyesitoniya -Name[se]=Esttegiella -Name[sk]=estónÄina -Name[sl]=estonsko -Name[sq]=Estonisht -Name[sr]=ЕÑтонÑки -Name[sr@Latn]=Estonski -Name[ss]=Si-Estonian -Name[sv]=Estniska -Name[ta]=எஸà¯à®Ÿà¯‹à®©à®¿à®¯à®©à¯ -Name[te]=à°Žà°¸à±à°Ÿà±Šà°¨à°¿à°¯à°¨à± -Name[tg]=ЭÑтонӣ -Name[th]=ภาษาเอสโทเนีย -Name[tr]=Estonca -Name[tt]=Estonça -Name[uk]=ЕÑтонÑька -Name[uz]=Estoncha -Name[uz@cyrillic]=ЭÑтонча -Name[vi]=E-x-tô-ni-a -Name[wa]=Estonyin -Name[zh_CN]=爱沙尼亚语 -Name[zh_HK]=愛沙尼亞語 -Name[zh_TW]=愛沙尼亞語 -Name[zu]=Isi-Estonian -[eu] -Name=Basque -Name[ar]=الباسك -Name[az]=Baskca -Name[be]=БаÑÑ†ÐºÐ°Ñ -Name[bg]=БаÑкийÑки -Name[bn]=বাসà§à¦• -Name[br]=Euskareg -Name[bs]=Baskijski -Name[ca]=Basc -Name[cs]=Baskický -Name[csb]=Baskijsczi -Name[cy]=Basgeg -Name[da]=Baskisk -Name[de]=Baskisch -Name[el]=Βασκικά -Name[eo]=Vaska -Name[es]=Vasco -Name[et]=Baski -Name[eu]=Euskara -Name[fa]=باسکی -Name[fi]=Baski -Name[fy]=Baskysk -Name[ga]=Bascais -Name[gl]=Basco -Name[he]=בסקית -Name[hi]=बाशà¥à¤• -Name[hr]=Baskijski -Name[hsb]=Baskisce -Name[hu]=Baszk -Name[is]=Baskamál -Name[it]=Basco -Name[ja]=ãƒã‚¹ã‚¯èªž -Name[ka]=ბáƒáƒ¡áƒ™áƒ£áƒ áƒ˜ -Name[kk]=БаÑкша -Name[km]=បាស្ក០-Name[ko]=바스í¬ì–´ -Name[lb]=Baskesch -Name[lt]=Baskų -Name[lv]=Basku -Name[mk]=БаÑкиÑки -Name[mn]=БаÑкү -Name[mt]=Bask -Name[nb]=Baskisk -Name[nds]=Basksch -Name[ne]=बासà¥à¤• -Name[nl]=Baskisch -Name[nn]=Baskisk -Name[nso]=Se-Basque -Name[oc]=Bascon -Name[pa]=ਬਸਕਿਉ -Name[pl]=Baskijski -Name[pt]=Basco -Name[pt_BR]=Basco -Name[ro]=Bască -Name[ru]=БаÑкÑкий -Name[rw]=Ikibasike -Name[se]=BaskalaÅ¡giella -Name[sk]=baskiÄtina -Name[sl]=baskovsko -Name[sq]=Baskisht -Name[sr]=БаÑкијÑки -Name[sr@Latn]=Baskijski -Name[ss]=Si-Basque -Name[sv]=Baskiska -Name[ta]=பாஸà¯à®•à¯ -Name[te]=బాసà±à°•à± -Name[tg]=БаÑкӣ -Name[th]=ภาษาบาสà¸à¹Œ -Name[tr]=Bask Dili -Name[tt]=Basqça -Name[uk]=БаÑкÑька -Name[uz]=Baskcha -Name[uz@cyrillic]=БаÑкча -Name[vi]=Ba-x-quợ -Name[wa]=Basse -Name[zh_CN]=巴斯克语 -Name[zh_HK]=巴斯克語 -Name[zh_TW]=巴斯克語 -Name[zu]=Isi-Basque -[fa] -Name=Farsi (Persian) -Name[af]=Farsi (Persies) -Name[ar]=Ùارسي -Name[be]=ПерÑідÑÐºÐ°Ñ -Name[bg]=ФарÑи -Name[bn]=ফারà§à¦¸à¦¿ (পারà§à¦¸à¦¿à§Ÿà¦¾à¦¨) -Name[br]=Farsieg (Persieg) -Name[bs]=Farsi (Perzijski) -Name[ca]=Farsi (Persa) -Name[cs]=Farsi (Perský) -Name[csb]=Farsi (persczi) -Name[cy]=Farsi (Perseg) -Name[da]=Farsi (Persisk) -Name[de]=Farsi (Persisch) -Name[el]=Farsi (ΠεÏσικά) -Name[eo]=Frisa (Persa) -Name[es]=Persa -Name[et]=Farsi (pärsia) -Name[eu]=Farsiera (Persiera) -Name[fa]=Ùارسی -Name[fi]=Farsi (Persia) -Name[fr]=Persan -Name[fy]=Farsysk (Persysk) -Name[ga]=Fairsis (Peirsis) -Name[gl]=Frisón (Pársi) -Name[he]=פרסית -Name[hi]=फ़ारसी (परà¥à¤¸à¤¿à¤¯à¤¨) -Name[hr]=Farsi (Perzijski) -Name[hsb]=Farsi (Persisce) -Name[hu]=Fárszi (perzsa) -Name[id]=Persia -Name[is]=Farsi (Persneska) -Name[it]=Farsi (Persiano) -Name[ja]=ペルシア語 -Name[ka]=სპáƒáƒ áƒ¡áƒ£áƒšáƒ˜ (ფáƒáƒ áƒ¡áƒ˜) -Name[kk]=ФарÑи -Name[km]=ហ្វាស៊ី (ពឺស៊ាន) -Name[ko]=팔시 (페르시아어) -Name[lb]=Farsi (Persesch) -Name[lt]=Farsi (persų) -Name[lv]=PersieÅ¡u (Farsi) -Name[mk]=ФарÑи (перÑиÑки) -Name[mn]=ФарÑи (ПерÑ) -Name[ms]=Parsi -Name[nb]=Farsi (Persisk) -Name[nds]=Farsi (Persisch) -Name[ne]=फारसी (परà¥à¤¸à¤¿à¤¯à¤¨) -Name[nl]=Farsi (Perzisch) -Name[nn]=Persisk -Name[pa]=ਫਾਰਸੀ (ਪਰਸ਼ੀਆਈ) -Name[pl]=Farsi (Perski) -Name[pt]=Farsi (Persa) -Name[pt_BR]=Farsi (Persa) -Name[ro]=Farsi (Persană) -Name[ru]=ФарÑи -Name[rw]=Igifarisi -Name[se]=Farsigiella (PersialaÅ¡) -Name[sk]=perzÅ¡tina -Name[sl]=Farsi (perzijsko) -Name[sr]=ФарÑи (ПерÑијÑки) -Name[sr@Latn]=Farsi (Persijski) -Name[sv]=Persiska -Name[ta]=பாரà¯à®šà®¿ (பெரà¯à®šà®¿à®¯à®©à¯) -Name[te]=ఫారà±à°¸à°¿ (పెరà±à°·à°¿à°¯à°¨à±) -Name[tg]=ФриÑианӣ -Name[th]=ภาษาฟาร์ซี (เปอร์เซียน) -Name[tr]=Ä°ranca -Name[tt]=Farsı -Name[uk]=ФризійÑька (ПерÑька) -Name[uz]=Forscha (Perscha) -Name[uz@cyrillic]=ФорÑча (ПерÑча) -Name[vi]=Pha-xi -Name[wa]=Farsi -Name[zh_CN]=波斯语 -Name[zh_HK]=波斯語 -Name[zh_TW]=波斯語 -[fi] -Name=Finnish -Name[af]=Feense -Name[ar]=الÙنلندية -Name[az]=FincÉ™ -Name[be]=ФінÑÐºÐ°Ñ -Name[bg]=ФинÑки -Name[bn]=ফিনিশ -Name[br]=Finneg -Name[bs]=Finski -Name[ca]=Finès -Name[cs]=Finský -Name[csb]=Finsczi -Name[cy]=Ffineg -Name[da]=Finsk -Name[de]=Finnisch -Name[el]=Φιλανδικά -Name[eo]=Fina -Name[es]=Finés -Name[et]=Soome -Name[eu]=Finlandiera -Name[fa]=Ùنلاندی -Name[fi]=Suomi -Name[fr]=Finnois -Name[fy]=Finsk -Name[ga]=Fionlainnis -Name[gl]=Finlandés -Name[he]=פינית -Name[hi]=फिनिश -Name[hr]=Finski -Name[hsb]=Finsce -Name[hu]=Finn -Name[id]=Finlandia -Name[is]=Finnska -Name[it]=Finlandese -Name[ja]=フィンランド語 -Name[ka]=ფინური -Name[kk]=Финнша -Name[km]=ហ្វាំងឡង់ -Name[ko]=핀란드어 -Name[lb]=Finnesch -Name[lt]=Suomių -Name[lv]=Somu -Name[mi]=Reo Whinarana -Name[mk]=ФинÑки -Name[mn]=ФиннлÑнд -Name[mt]=Finlandiż -Name[nb]=Finsk -Name[nds]=Finnsch -Name[ne]=फिनिश -Name[nl]=Fins -Name[nn]=Finsk -Name[nso]=Se-Finnish -Name[oc]=Finlandès -Name[pa]=ਫੈਨਿਸ਼ -Name[pl]=FiÅ„ski -Name[pt]=Finlandês -Name[pt_BR]=Finlandês -Name[ro]=Finlandeză -Name[ru]=ФинÑкий -Name[rw]=Ikinyafinilande -Name[se]=Suomagiella -Name[sk]=fínÄina -Name[sl]=finsko -Name[sq]=Finlandisht -Name[sr]=ФинÑки -Name[sr@Latn]=Finski -Name[ss]=Si-Finnish -Name[sv]=Finska -Name[ta]=ஃபினà¯à®©à®¿à®·à¯ -Name[te]=à°«à°¿à°¨à±à°¨à°¿à°·à± -Name[tg]=Финӣ -Name[th]=ภาษาฟินà¹à¸¥à¸™à¸”์ -Name[tr]=Fince -Name[tt]=Finçä -Name[uk]=ФінÑька -Name[uz]=Fincha -Name[uz@cyrillic]=Финча -Name[vi]=Phần-lan -Name[wa]=Finwès -Name[zh_CN]=芬兰语 -Name[zh_HK]=芬蘭語 -Name[zh_TW]=芬蘭語 -Name[zu]=Isi-Finishi -[fj] -Name=Fijian -Name[ar]=Ùيجي -Name[az]=Fijiyaca -Name[be]=ФіджыйÑÐºÐ°Ñ -Name[bg]=Фиджи -Name[bn]=ফিজিয়ান -Name[br]=Fidjeg -Name[bs]=Fidžijski -Name[ca]=Fijí -Name[cs]=Fidžijský -Name[csb]=z Fiji -Name[cy]=Fijieg -Name[da]=Fijiansk -Name[de]=Fidschi -Name[eo]=FiÄia -Name[es]=Fiyiano -Name[et]=Fidži -Name[eu]=Fijiera -Name[fa]=Ùیجیایی -Name[fi]=Fidži -Name[fr]=Fidjien -Name[fy]=Fijdzjysk -Name[ga]=Fidsis -Name[gl]=Fijiano -Name[he]=פיגי'ת -Name[hi]=फिज़ी -Name[hr]=Fidžijski -Name[hsb]=Fidźiasce -Name[hu]=Fidzsi -Name[it]=Figiano -Name[ja]=フィジー語 -Name[ka]=ფიჯი -Name[kk]=Фиджише -Name[km]=ហ្វ៊ីហ្ស៊ី -Name[ko]=피지어 -Name[lb]=Fidschi-Sprooch -Name[lt]=Fidži -Name[lv]=Fidži -Name[mk]=ФиџиÑки -Name[mn]=Фижи -Name[nb]=Fijisk -Name[nds]=Fidschi -Name[ne]=फिजियन -Name[nl]=Fijisch -Name[nn]=Fijisk -Name[nso]=Se-Fijian -Name[pa]=ਫਿਜੀਨ -Name[pl]=z Fiji -Name[pt]=Fidjiano -Name[ro]=Fijiană -Name[ru]=Фиджи -Name[rw]=Igifijiyani -Name[se]=Fižigiella -Name[sk]=fidžijÄina -Name[sl]=fidžijsko -Name[sq]=Figjinisht -Name[sr]=ФиџијÑки -Name[sr@Latn]=Fidžijski -Name[ss]=Si-Fijian -Name[sv]=Fijianska -Name[ta]=ஃபிஜியன௠-Name[te]=ఫిజియనౠ-Name[tg]=Фиҷианӣ -Name[th]=ภาษาฟิจิ -Name[tt]=Fijiçä -Name[uk]=ФіджійÑька -Name[uz]=Fijicha -Name[uz@cyrillic]=Фижича -Name[vi]=Phi-gi -Name[wa]=Fidjyin -Name[zh_CN]=æ–济语 -Name[zh_HK]=æ–濟語 -Name[zh_TW]=æ–濟語 -Name[zu]=Isi-Fijiyani -[fo] -Name=Faroese -Name[ar]=Ùروي -Name[az]=FaroezcÉ™ -Name[be]=ФароÑÐºÐ°Ñ -Name[bg]=ФарьорÑки -Name[bn]=ফারোইস -Name[br]=Faroeseg -Name[bs]=Farski -Name[ca]=Feroès -Name[cs]=Faerský -Name[csb]=z Ã’wczëch Ã’strowów -Name[cy]=Faroeg -Name[da]=Færøsk -Name[de]=Färöisch -Name[eo]=Feroa -Name[es]=Feroés -Name[et]=Fääri -Name[eu]=Faroera -Name[fa]=Ùاروسی -Name[fi]=Fääri -Name[fr]=Féroïen -Name[fy]=Faeroersk -Name[ga]=Faróis -Name[gl]=Feroés -Name[he]=פ×רו×ית -Name[hi]=फ़ारसी -Name[hr]=Farski -Name[hsb]=Farösce -Name[hu]=Faröei -Name[is]=Færeyska -Name[ja]=フェーロー語 -Name[ka]=ფáƒáƒ áƒ”რული -Name[kk]=ФароÑзше -Name[km]=ហ្វាអáŸážšáž¼ážŸážº -Name[lb]=Faröesch -Name[lt]=Farerų -Name[lv]=FÄ“ru -Name[mk]=ФарÑки -Name[mn]=Фаро -Name[nb]=Færøyisk -Name[nds]=Färöösch -Name[ne]=फारोसी -Name[nn]=Færøysk -Name[nso]=Se-Faroese -Name[pa]=ਫਾਰੋਇਸੀ -Name[pl]=z Wysp Owczych -Name[pt]=Faroês -Name[ro]=Faroeză -Name[ru]=ФарерÑкий -Name[rw]=Igifero -Name[se]=Fearagiella -Name[sk]=faerÄina -Name[sl]=fersko -Name[sq]=Farosisht -Name[sr]=ФарÑки -Name[sr@Latn]=Farski -Name[ss]=Si-Faroese -Name[sv]=Färöiska -Name[ta]=ஃபாரோவீஸ௠-Name[te]=ఫారొఈసౠ-Name[tg]=ФароеÑÓ£ -Name[th]=ภาษาฟาโรอีส -Name[tt]=Farosça -Name[uk]=ФарерÑька -Name[uz]=Farercha -Name[uz@cyrillic]=Фарерча -Name[vi]=Pha-rô -Name[wa]=Faeroyès -Name[zh_CN]=法罗群岛语 -Name[zh_HK]=法羅語 -Name[zh_TW]=法羅語 -Name[zu]=Isi-Faroese -[fr] -Name=French -Name[af]=Franse -Name[ar]=الÙرنسية -Name[az]=Fransızca -Name[be]=ФранцузÑÐºÐ°Ñ -Name[bg]=ФренÑки -Name[bn]=ফরাসী -Name[br]=Galleg -Name[bs]=Francuski -Name[ca]=Francès -Name[cs]=Francouzský -Name[csb]=Francësczi -Name[cy]=Frangeg -Name[da]=Fransk -Name[de]=Französisch -Name[el]=Γαλλικά -Name[eo]=Franca -Name[es]=Francés -Name[et]=Prantsuse -Name[eu]=Frantsesa -Name[fa]=Ùرانسوی -Name[fi]=Ranska -Name[fr]=Français -Name[fy]=Frânsk -Name[ga]=Fraincis -Name[gl]=Francés -Name[he]=צרפתית -Name[hi]=फà¥à¤°à¥‡à¤‚च -Name[hr]=Francuski -Name[hsb]=Francosce -Name[hu]=Francia -Name[id]=Prancis -Name[is]=Franska -Name[it]=Francese -Name[ja]=フランス語 -Name[ka]=ფრáƒáƒœáƒ’ული -Name[kk]=Французша -Name[km]=បារាំង -Name[ko]=불어 -Name[lb]=Franzéisch -Name[lt]=PrancÅ«zų -Name[lv]=FranÄu -Name[mi]=Reo Parani -Name[mk]=ФранцуÑки -Name[mn]=Франц -Name[ms]=Perancis -Name[mt]=FranÄ‹iż -Name[nb]=Fransk -Name[nds]=Franzöösch -Name[ne]=फà¥à¤°à¥‡à¤¨à¥à¤š -Name[nl]=Frans -Name[nn]=Fransk -Name[nso]=Sefora -Name[oc]=Franchimand -Name[pa]=ਫਰੈਂਚ -Name[pl]=Francuski -Name[pt]=Francês -Name[pt_BR]=Francês -Name[ro]=Franceză -Name[ru]=ФранцузÑкий -Name[rw]=Igifaransa -Name[se]=Fránskkagiella -Name[sk]=francúzÅ¡tina -Name[sl]=francosko -Name[sq]=Frengjisht -Name[sr]=ФранцуÑки -Name[sr@Latn]=Francuski -Name[ss]=SiFrentji -Name[sv]=Franska -Name[ta]=பிரெனà¯à®šà¯ -Name[te]=à°«à±à°°à±†à°‚à°šà± -Name[tg]=ФранÑавӣ -Name[th]=ภาษาà¸à¸£à¸±à¹ˆà¸‡à¹€à¸¨à¸ª -Name[tr]=Fransızca -Name[tt]=Fransça -Name[uk]=Французька -Name[uz]=Fransuzcha -Name[uz@cyrillic]=Французча -Name[ven]=Mufura -Name[vi]=Pháp -Name[wa]=Francès -Name[xh]=Isifrentshi -Name[zh_CN]=法语 -Name[zh_HK]=法語 -Name[zh_TW]=法語 -Name[zu]=Isi-Frentshi -[fy] -Name=Frisian -Name[ar]=الÙريزية -Name[az]=FriscÉ™ -Name[be]=ФрыÑійÑÐºÐ°Ñ -Name[bg]=ФризийÑки -Name[bn]=ফà§à¦°à¦¿à¦¸à¦¿à§Ÿà¦¾à¦¨ -Name[br]=Frisianeg -Name[bs]=Frizijski -Name[ca]=Frisó -Name[cs]=Fríský -Name[csb]=Frizëjsczi -Name[cy]=Frisieg -Name[da]=Frisisk -Name[de]=Friesisch -Name[eo]=Frisa -Name[es]=Frisio -Name[et]=Friisi -Name[eu]=Frisiera -Name[fa]=Ùریسی -Name[fi]=Friisi -Name[fr]=Frison -Name[fy]=Frysk -Name[ga]=Freaslainnis -Name[gl]=Frísio -Name[he]=פריזי×נית -Name[hi]=फà¥à¤°à¤¿à¤¸à¤¿à¤¯à¤¨ -Name[hr]=Frizijski -Name[hsb]=Frizisce -Name[hu]=Fríz -Name[is]=Frísneska -Name[it]=Frisone -Name[ja]=フリジア語 -Name[ka]=ფრიზიული -Name[kk]=Фризше -Name[km]=ហ្វ្រីស៊ាន -Name[ko]=프리시안어 -Name[lb]=Friesesch -Name[lt]=Fryzų -Name[lv]=FrÄ«zieÅ¡u -Name[mk]=ФризиÑки -Name[mn]=Ð¤Ñ€Ð¸Ñ -Name[ms]=Frisia -Name[nb]=Frisisk -Name[nds]=Freesch -Name[ne]=फà¥à¤°à¤¿à¤¸à¤¿à¤¯à¤¨ -Name[nl]=Frysk -Name[nn]=Frisisk -Name[nso]=Se-Frisian -Name[pa]=ਫਰੀਸੀਨਿਸ -Name[pl]=Fryzyjski -Name[pt]=Frísio -Name[ro]=Frisiană -Name[ru]=ФризийÑкий -Name[rw]=Igifuriziyani -Name[se]=Frisagiella -Name[sk]=frízÅ¡tina -Name[sl]=frizijsko -Name[sq]=Frisisht -Name[sr]=ФризијÑки -Name[sr@Latn]=Frizijski -Name[ss]=Si-Frisian -Name[sv]=Frisiska -Name[ta]=ஃபரீசியன௠-Name[te]=à°«à±à°°à°¿à°¸à°¿à°¯à°¨à± -Name[tg]=Фризианӣ -Name[th]=ภาษาฟรีเชียน -Name[uk]=ФризійÑька -Name[uz]=Frizcha -Name[uz@cyrillic]=Фризча -Name[vi]=Ph-ri-xi -Name[wa]=Frizon -Name[zh_CN]=弗里斯兰语 -Name[zh_HK]=弗利然語 -Name[zh_TW]=弗利然語 -Name[zu]=Isi-Frisiyani -[ga] -Name=Irish Gaelic -Name[af]=Ierse Gaelic -Name[be]=ІрландÑÐºÐ°Ñ Ð³Ð°Ð»ÑŒÑÐºÐ°Ñ -Name[bg]=ИрландÑки -Name[bn]=আইরিশ গেলিক -Name[br]=Iwerzhoneg eus Bro Iwerzhon -Name[bs]=Irski Gaelic -Name[ca]=Irlandès gaèlic -Name[cs]=Galský (irÅ¡tina) -Name[csb]=Irlandzczi Gaelic -Name[da]=Irsk gælisk -Name[de]=Irisches Gälisch -Name[eo]=Irlanda Gaela -Name[es]=Gaélico irlandés -Name[et]=Iiri gaeli -Name[eu]=Irlandar gaelikoa -Name[fa]=اسکاتلندی ایرلندی -Name[fi]=Irlannin gael -Name[fr]=Gaélique irlandais -Name[fy]=Iersk Gaelic -Name[ga]=Gaeilge -Name[gl]=Gaélico -Name[he]=×’×לית ×ירית -Name[hr]=Irski Galski -Name[hsb]=Gaelisce (Irska) -Name[hu]=Gall (ír) -Name[is]=Ãrsk gelíska -Name[it]=Gaelico irlandese -Name[ja]=アイルランド系ゲール語 -Name[ka]=ირლáƒáƒœáƒ“იური (გáƒáƒšáƒ£áƒ áƒ˜) -Name[kk]=Ирланд галлша -Name[km]=អៀរឡង់ ហ្កែលិគ -Name[lb]=Irescht Gällesch -Name[mk]=ИрÑки галÑки -Name[nb]=Irsk gaelisk -Name[nds]=Irsch Gäälsch -Name[ne]=आइरिश गà¥à¤¯à¤¾à¤²à¤¿à¤• -Name[nl]=Gaelic (Iers) -Name[nn]=Gælisk (Irland) -Name[pa]=ਆਈਰਿਸ਼ ਗਾਈਲਿਕ -Name[pl]=Irlandzki Gaelic -Name[pt]=Galês da Irlanda -Name[pt_BR]=Irlandês "Gaelic" -Name[ro]=Galeză irlandeză -Name[ru]=ГалльÑкий (ИрландиÑ) -Name[rw]=Ikinyirilande Gayerike -Name[se]=IrlánddalaÅ¡ gaelagiella -Name[sk]=írska gaelÄina -Name[sl]=irsko galsko -Name[sr]=ИрÑки галÑки -Name[sr@Latn]=Irski galski -Name[sv]=Irländsk galiciska -Name[ta]=à®à®°à®¿à®·à¯ காலிக௠-Name[te]=à°à°°à°¿à°·à± గెలికౠ-Name[tg]=Ирландӣ (Галикӣ) -Name[th]=ภาษาไอริชเà¸à¸¥à¸´à¸„ -Name[tr]=Ä°rlanda Galik -Name[tt]=Galça (Ä°rland) -Name[uk]=ГаельÑька (ІрландіÑ) -Name[vi]=Xen-tợ Ãi-nhÄ©-lan -Name[zh_CN]=爱尔兰盖尔语 -Name[zh_TW]=(愛爾蘭)蓋爾語 -[gd] -Name=Gaelic -Name[ar]=غالي -Name[az]=QaelikcÉ™ -Name[be]=ГальÑÐºÐ°Ñ -Name[bg]=ГаелÑки -Name[bn]=গেলিক -Name[br]=Iwerzhoneg -Name[ca]=Gaèlic -Name[cs]=Galský -Name[csb]=Celtycczi (gaelic) -Name[cy]=Gaeleg -Name[da]=Gælisk -Name[de]=Gälisch -Name[eo]=Gaela -Name[es]=Gaélico -Name[et]=Gaeli -Name[eu]=Gaelikoa -Name[fa]=اسکاتلندی -Name[fi]=Gael -Name[fr]=Gaélique -Name[ga]=Gàidhlig -Name[gl]=Gaélico -Name[he]=×’×לית -Name[hi]=गैलिक -Name[hr]=Galski -Name[hsb]=Gaelisce -Name[hu]=Gall -Name[is]=Gelíska -Name[it]=Gaelico -Name[ja]=ゲール語 -Name[ka]=გáƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Галлша -Name[km]=ហ្កែលិគ -Name[lb]=Gällesch -Name[lt]=Galų -Name[mk]=ГалÑки -Name[mn]=Гаели -Name[nb]=Gælisk -Name[nds]=Gäälsch -Name[ne]=गà¥à¤¯à¤¾à¤²à¤¿à¤• -Name[nn]=Gælisk -Name[nso]=Se-Gaelic -Name[pa]=ਗਾਈਲਿਕ -Name[pl]=celtycki (gaelic) -Name[pt]=Galês -Name[pt_BR]=Galês -Name[ro]=Galică -Name[ru]=ГалльÑкий -Name[rw]=Ikinyagayeli -Name[se]=Gaelagiella -Name[sk]=gaelÄina -Name[sl]=galsko -Name[sq]=Galikisht -Name[sr]=ГалÑки -Name[sr@Latn]=Galski -Name[ss]=Si-Gaelic -Name[sv]=Galiciska -Name[ta]=கேலிக௠-Name[te]=గెలికౠ-Name[tg]=Галӣ -Name[th]=ภาษาเà¸à¸¥à¸´à¸„ีย -Name[tr]=Galik -Name[tt]=Galça -Name[uk]=ГаельÑька -Name[uz]=Galikcha -Name[uz@cyrillic]=Галикча -Name[vi]=Xen-tợ -Name[wa]=Gayel -Name[zh_CN]=盖尔语 -Name[zh_HK]=蓋爾語 -Name[zh_TW]=蓋爾語 -Name[zu]=Isi-Gayelikhi -[gl] -Name=Galician -Name[be]=ГаліцыйÑÐºÐ°Ñ -Name[bg]=ГалиÑийÑки -Name[bn]=গেলিসিয়ান -Name[br]=Galiseg -Name[bs]=Galicijski -Name[ca]=Gallec -Name[cs]=HaliÄský -Name[csb]=Galicëjsczi -Name[cy]=Galiseg -Name[da]=Galicisk -Name[de]=Galicisch -Name[eo]=Gaela -Name[es]=Gallego -Name[et]=Galeegi -Name[eu]=Galiziera -Name[fa]=اسکاتلندی -Name[fi]=Gallicia -Name[fr]=Gaélicien -Name[fy]=Galiciaansk -Name[ga]=Gailísis -Name[gl]=Galego -Name[he]=×’×לית -Name[hr]=Galicijski -Name[hsb]=Galicisce -Name[hu]=Galíciai -Name[is]=Gelíska -Name[it]=Gallego -Name[ja]=ガリシア語 -Name[ka]=გáƒáƒšáƒ˜áƒªáƒ˜áƒ£áƒ áƒ˜ -Name[kk]=ГалициÑша -Name[km]=ហ្កាលីស៊ី -Name[lb]=Galizesch -Name[lt]=GalicieÄių -Name[lv]=GaliciÄņu -Name[mk]=ГалÑки -Name[mt]=GaliÄ‹ian -Name[nb]=Gaelisk -Name[nds]=Galizsch -Name[ne]=गà¥à¤¯à¤¾à¤²à¤¿à¤¸à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Galicisch -Name[nn]=Galisisk -Name[pa]=ਗਾਈਲੀਅਨ -Name[pl]=Galicyjski -Name[pt]=Galego -Name[pt_BR]=Galês -Name[ro]=Galică -Name[ru]=ГалицийÑкий -Name[rw]=Ikinyagalisiya -Name[se]=Galisiagiella -Name[sk]=galícijÄina -Name[sl]=galicijsko -Name[sr]=ГалицијÑки -Name[sr@Latn]=Galicijski -Name[sv]=Galiciska -Name[ta]=காலிசியன௠-Name[te]=గలిచియనౠ-Name[tg]=Галлӣ -Name[th]=ภาษาà¹à¸à¸¥à¸´à¹€à¸‹à¸µà¸¢ -Name[tr]=Galce -Name[tt]=Galisçä -Name[uk]=ГаліÑійÑька -Name[uz]=Galikcha -Name[uz@cyrillic]=Галикча -Name[ven]=Mugalata -Name[vi]=Ga-li-ci -Name[wa]=Galicyin -Name[xh]=isiGalacian -Name[zh_CN]=加利西亚语 -Name[zh_TW]=加利西亞語 -Name[zu]=Isi-Galashiyani -[gn] -Name=Guarani -Name[ar]=غوراني -Name[az]=Quaranca -Name[be]=ГуÑрані -Name[bg]=Гуарани -Name[bn]=গà§à§Ÿà¦¾à¦°à¦¾à¦¨à¦¿ -Name[ca]=Guaraní -Name[el]=ΓκουαÏάνι -Name[eo]=Gvarania -Name[es]=Guaraní -Name[et]=Guaranii -Name[eu]=Guaraniera -Name[fa]=گوارانی -Name[ga]=Guaráinis -Name[he]=גו×רני -Name[hi]=गौरानी -Name[hr]=Gvaranski -Name[ja]=グァラニ語 -Name[ka]=გვáƒáƒ áƒáƒœáƒ˜ -Name[kk]=Гуарани -Name[km]=ហ្កួរ៉ានី -Name[ko]=ê³¼ë¼ë‹ˆì–´ -Name[mk]=Гуарани -Name[mn]=Гуарани -Name[ne]=गà¥à¤µà¤¾à¤°à¤¾à¤¨à¥€ -Name[nso]=Se-Guarani -Name[pa]=ਗà©à¨°à¨¾à¨¨à©€ -Name[ro]=Guarană -Name[ru]=Гуарани -Name[rw]=Ikigwarani -Name[se]=Guaránagiella -Name[sk]=guaraní -Name[sl]=guarani -Name[sq]=Guaranisht -Name[sr]=ГваранÑки -Name[sr@Latn]=Gvaranski -Name[ss]=Si-Guarani -Name[sv]=Gujarati -Name[ta]=கà¯à®µà®°à®¾à®©à®¿ -Name[te]=à°—à±à°µà°¾à°°à°¾à°¨à°¿ -Name[tg]=Гуаранӣ -Name[th]=ภาษาà¸à¸§à¸²à¸£à¸²à¸™à¸µ -Name[tt]=Guarança -Name[uk]=Гуарані -Name[uz@cyrillic]=Гуарани -Name[vi]=Gua-ra-ni -Name[wa]=Gwarani -Name[zh_CN]=瓜拉尼语 -Name[zh_HK]=瓜拉尼語 -Name[zh_TW]=瓜拉尼語 -Name[zu]=Isi-Guarani -[gu] -Name=Gujarati -Name[ar]=جوجوراتي -Name[az]=QujaraticÉ™ -Name[be]=ГуÑраці -Name[bg]=Гуджарати -Name[bn]=গà§à¦œà¦°à¦¾à¦¤à§€ -Name[br]=Gujaratieg -Name[eo]= GuÄarata -Name[et]=Gudžarati -Name[eu]=Gujaratera -Name[fa]=گجراتی -Name[fi]=Gudžarati -Name[ga]=Gúisearáitis -Name[gl]=Guxarati -Name[he]=גוג'רטית -Name[hi]=गà¥à¤œà¤°à¤¾à¤¤à¥€ -Name[hr]=Gudžaratski -Name[hu]=Gudzsarati -Name[id]=Gujarat -Name[ja]=グジャラート語 -Name[ka]=გუჯáƒáƒ áƒáƒ—ი -Name[kk]=Гуджарати -Name[km]=ហ្កុយ៉ារាទី -Name[ko]=구ìžë¼íŠ¸ì–´ -Name[lt]=Gudžarati -Name[mk]=Гујарати -Name[mn]=ГуÑрати -Name[nds]=Gudscharati -Name[ne]=गà¥à¤œà¤°à¤¾à¤¤à¥€ -Name[nso]=Se-Gujarati -Name[pa]=ਗà©à¨œà¨°à¨¾à¨¤à©€ -Name[ru]=Гуджарати -Name[rw]=Ikigujarati -Name[se]=Gujaratigiella -Name[sk]=gudžarátÄina -Name[sl]=gujarati -Name[sq]=Guxharatish -Name[sr]=ГујаратÑки -Name[sr@Latn]=Gujaratski -Name[ss]=Si-Gujarati -Name[ta]=கà¯à®œà®°à®¾à®¤à¯à®¤à®¿ -Name[te]=à°—à±à°œà°°à°¾à°¤à±€ -Name[tg]=Гӯҷаратӣ -Name[th]=ภาษาà¸à¸¹à¸ˆà¸²à¸£à¸²à¸•à¸µ -Name[uk]=ГуÑраті -Name[uz@cyrillic]=Гужарати -Name[vi]=Gu-gia-ra-ti -Name[wa]=Goudjarati -Name[zh_CN]=å¤å‰æ‹‰ç‰¹è¯­ -Name[zh_HK]=å¤å‰æ‹‰ç‰¹èªž -Name[zh_TW]=å¤å‰æ‹‰ç‰¹èªž -Name[zu]=Isi-Gujarati -[gv] -Name=Manx -Name[ar]=مانكس -Name[az]=Manksca -Name[be]=ÐœÑÐ½ÐºÑ -Name[bg]=МанкÑки -Name[bn]=মানকà§à¦¸ -Name[br]=Manav -Name[cy]=Manneg -Name[da]=Mansk -Name[eo]=Manksa -Name[et]=Mänksi -Name[eu]=Manera -Name[fa]=مانکسی -Name[fr]=Mannois -Name[ga]=Manainnis -Name[he]=מנקס -Name[hi]=मांकà¥à¤¸ -Name[hsb]=Manxowsce -Name[it]=Man, lingua dell'isola di -Name[ja]=マン島語 -Name[ka]=მáƒáƒœáƒ¥áƒ¡áƒ˜ -Name[kk]=МанкÑша -Name[km]=ម៉ុង -Name[ko]=ë§ìŠ¤ì–´ -Name[mk]=ÐœÐ°Ð½ÐºÑ -Name[mn]=ÐœÐ°Ð½ÐºÑ -Name[ne]=मà¥à¤¯à¤¾à¤™à¥à¤•à¥à¤¸ -Name[nso]=Se-Manx -Name[pa]=ਮਾਲਸ -Name[ro]=Manxă -Name[ru]=ÐœÐ°Ð½ÐºÑ -Name[rw]=Ikimangisi -Name[se]=Mánksagiella -Name[sk]=manÄina -Name[sl]=manx -Name[sq]=Manksisht -Name[sr]=МанкÑки -Name[sr@Latn]=Mankski -Name[ss]=Si-Manx -Name[ta]=மானà¯à®•à¯à®¸à¯ -Name[te]=మేనà±à°•à±à°¸à± -Name[tg]=МанкÑÓ£ -Name[th]=ภาษาà¹à¸¡à¸‡à¸‹à¹Œà¹€à¸à¸¥à¸´à¸„ -Name[tt]=Manksça -Name[uk]=ÐœÐ°Ð½ÐºÑ -Name[uz]=Manks -Name[uz@cyrillic]=ÐœÐ°Ð½ÐºÑ -Name[vi]=Man-xợ -Name[wa]=Gayel del Iye di Man -Name[zh_CN]=马æ©å²›è¯­ -Name[zh_HK]=曼島語 -Name[zh_TW]=曼島語 -Name[zu]=Isi-Manx -[ha] -Name=Hausa -Name[ar]=الهاوسا -Name[be]=ХаўÑа -Name[bg]=ХауÑа -Name[bn]=হাউসা -Name[br]=Haousa -Name[eo]=HaÅ­sa -Name[fa]=هوسا -Name[fr]=Haoussa -Name[ga]=Hásais -Name[he]=×”×וסה -Name[hi]=हौसा -Name[ja]=ãƒã‚¦ã‚µèªž -Name[ka]=ჰáƒáƒ£áƒ¡áƒ -Name[kk]=ХауÑа -Name[km]=ហូសា -Name[ko]=하우사어 -Name[lb]=Haussa-Sprooch -Name[lv]=Hausu -Name[mk]=ХауÑа -Name[mn]=ХауÑа -Name[nds]=Haussa -Name[ne]=हउसा -Name[nso]=Se-Hausa -Name[pa]=ਹਾਉਸਾ -Name[ro]=Hausă -Name[ru]=ХауÑа -Name[rw]=Igihawusa -Name[se]=Hausagiella -Name[sk]=hauÅ¡tina -Name[sl]=hausa -Name[sq]=Hausisht -Name[sr]=ХауÑа -Name[ss]=Si-Hausa -Name[ta]=ஹவà¯à®šà®¾ -Name[te]=హౌసా -Name[tg]=ХауÑагӣ -Name[th]=ภาษาเฮาซา -Name[tt]=Hausça -Name[uk]=ГауÑа -Name[uz]=Xausa -Name[uz@cyrillic]=ХауÑа -Name[vi]=Hau-sa -Name[zh_CN]=豪撒语 -Name[zh_HK]=豪薩語 -Name[zh_TW]=豪薩語 -Name[zu]=Isi-Hausa -[he] -Name=Hebrew -Name[af]=Hibreüs -Name[ar]=العبرية -Name[az]=YÉ™hudicÉ™ -Name[be]=ГабрÑйÑÐºÐ°Ñ -Name[bg]=Иврит -Name[bn]=হীবà§à¦°à§ -Name[br]=Hebreeg -Name[bs]=Hebrejski -Name[ca]=Hebreu -Name[cs]=Hebrejský -Name[csb]=Hebrejsczi -Name[cy]=Iddeweg -Name[da]=Hebraisk -Name[de]=Hebräisch -Name[el]=ΕβÏαϊκά -Name[eo]=Hebrea -Name[es]=Hebreo -Name[et]=Heebrea -Name[eu]=Hebreera -Name[fa]=عبری -Name[fi]=Heprea -Name[fr]=Hébreu -Name[fy]=Hebrieuwsk -Name[ga]=Eabhrais -Name[gl]=Hebraico -Name[he]=עברית -Name[hi]=हिबà¥à¤°à¥‚ -Name[hr]=Hebrejski -Name[hsb]=Hebrejsce -Name[hu]=héber -Name[id]=Israel -Name[is]=Hebreska -Name[it]=Ebraico -Name[ja]=ヘブライ語 -Name[ka]=ივრითი -Name[kk]=Ивритше -Name[km]=áž áŸáž”្រូ -Name[ko]=히브리어 -Name[lb]=Hebräesch -Name[lt]=Hebrajų -Name[lv]=Ebreju -Name[mi]=Reo Hürai -Name[mk]=ЕврејÑки -Name[mn]=Хебрев -Name[mt]=Lhudi -Name[nb]=Hebraisk -Name[nds]=Hebrääsch -Name[ne]=हिबà¥à¤°à¥ -Name[nl]=Hebreeuws -Name[nn]=Hebraisk -Name[nso]=Se-Heberu -Name[oc]=Hebreu -Name[pa]=ਹੈਬਰਿਊ -Name[pl]=Hebrajski -Name[pt]=Hebreu -Name[pt_BR]=Hebreu -Name[ro]=Israeliană -Name[ru]=Иврит -Name[rw]=Igiheburayo -Name[se]=Hebreagiella -Name[sk]=hebrejÄina -Name[sl]=hebrejsko -Name[sq]=Hebraisht -Name[sr]=ХебрејÑки -Name[sr@Latn]=Hebrejski -Name[ss]=SiHebheru -Name[sv]=Hebreiska -Name[ta]=எபிரேயம௠-Name[te]=హీబà±à°°à±‚ -Name[tg]=Яҳудӣ -Name[th]=ภาษาฮิบรู -Name[tr]=Ä°branice -Name[tt]=Yähüdçä -Name[uk]=ЄврейÑька -Name[uz]=Yahudiycha -Name[uz@cyrillic]=Яҳудийча -Name[vi]=Do-thái -Name[wa]=Ebreu -Name[xh]=Isihebhere -Name[zh_CN]=希伯æ¥è¯­ -Name[zh_HK]=希伯來語 -Name[zh_TW]=希伯來語 -Name[zu]=Isi-Hebheru -[hi] -Name=Hindi -Name[ar]=هندي -Name[be]=Хіндзі -Name[bg]=Хинди -Name[bn]=হিনà§à¦¦à§€ -Name[cs]=Hindský -Name[cy]=Hindw^ -Name[eo]=Hinda -Name[fa]=هندی -Name[fy]=Hindy -Name[ga]=Hiondúis -Name[he]=הינדית -Name[hi]=हिनà¥à¤¦à¥€ -Name[hr]=Hinduski -Name[ja]=ヒンディー語 -Name[ka]=ჰინდი -Name[kk]=Хинди -Name[km]=ហិណ្ឌូ -Name[ko]=힌디어 -Name[lv]=Hindu -Name[mk]=Хинди -Name[mn]=Хинди -Name[ne]=हिनà¥à¤¦à¥€ -Name[nso]=Se-Hindi -Name[pa]=ਹਿੰਦੀ -Name[pt]=Hindu -Name[ro]=Hindusă -Name[ru]=Хинди -Name[rw]=Igihindi -Name[se]=Hindigiella -Name[sk]=hindÄina -Name[sl]=hindujsko -Name[sq]=Hinduisht -Name[sr]=Хинду -Name[sr@Latn]=Hindu -Name[ss]=Si-Hindi -Name[ta]=ஹிநà¯à®¤à®¿ -Name[te]=హింది -Name[tg]=Ҳиндӣ -Name[th]=ภาษาฮินดี -Name[tt]=Hindçä -Name[uk]=Гінді -Name[uz]=Hindcha -Name[uz@cyrillic]=Ҳиндча -Name[vi]=Hin-Ä‘i -Name[zh_CN]=北å°åº¦è¯­ -Name[zh_HK]=北å°åº¦èªž -Name[zh_TW]=北å°åº¦èªž -Name[zu]=Isi-Hindi -[ho] -Name=Hiri Motu -Name[ar]=الهيري-موتو -Name[be]=Хірымоту -Name[bg]=Хири Моту -Name[bn]=হিরি মোটৠ-Name[eo]=Hiri-Motuo -Name[fa]=هیری موتو -Name[fi]=Hiri-motu -Name[fr]=Hiri motu -Name[ga]=Hírí-Mótúis -Name[he]=הירי מוטו -Name[hi]=हिरी मोतू -Name[hu]=Hiri motu -Name[it]=Hiri motu -Name[ja]=ヒリモトゥ語 -Name[ka]=ჰირი მáƒáƒ¢áƒ£ -Name[kk]=Хири Моту -Name[km]=ហ៊ីរី ម៉ូទូ -Name[ko]=히리 모투어 -Name[lb]=Hiri-Motu -Name[mk]=Хири Моту -Name[mn]=Хири Моту -Name[ne]=हिरी मोतॠ-Name[nn]=Hiri motu -Name[nso]=Se-Hiri Motu -Name[pa]=ਹੀਰੀ ਮੋਟੂ -Name[ru]=Хири Моту -Name[rw]=Igihiri-motu -Name[se]=Hiri Motu-giella -Name[sk]=hiri motu -Name[sl]=hiri motu -Name[sr]=ХиримотÑки -Name[sr@Latn]=Hirimotski -Name[ss]=Si-Hiri Motu -Name[sv]=Hirimotu -Name[ta]=ஹிரி மொடà¯à®Ÿà¯ -Name[te]=హిరి మోటౠ-Name[tg]=Хири Моту -Name[th]=ภาษาฮิริโมตู -Name[uk]=Хірі Моту -Name[uz]=Xiri Motu -Name[uz@cyrillic]=Хири Моту -Name[vi]=Hi-ri-mô-tu -Name[zh_CN]=新里木托语 -Name[zh_HK]=Hiri Motu語 -Name[zh_TW]=Hiri Motu語 -Name[zu]=Isi-Hiri Motu -[hr] -Name=Croatian -Name[af]=Kroatiese -Name[ar]=الكرواتية -Name[az]=Xorvatca -Name[be]=Ð¥Ð°Ñ€Ð²Ð°Ñ†ÐºÐ°Ñ -Name[bg]=ХърватÑки -Name[bn]=কà§à¦°à§‹à§Ÿà§‡à¦¶à§€à§Ÿ -Name[br]=Kroateg -Name[bs]=Hrvatski -Name[ca]=Croat -Name[cs]=Chorvatský -Name[csb]=Chòrwacczi -Name[cy]=Croatieg -Name[da]=Kroatisk -Name[de]=Kroatisch -Name[el]=ΚÏοατικά -Name[eo]=Kroata -Name[es]=Croata -Name[et]=Horvaadi -Name[eu]=Kroaziera -Name[fa]=کروواسیایی -Name[fi]=Kroatia -Name[fr]=Croate -Name[fy]=Kroatysk -Name[ga]=Cróitis -Name[gl]=Croata -Name[he]=קרו×טית -Name[hi]=कà¥à¤°à¥‹à¤à¤¶à¤¿à¤¯à¤¨ -Name[hr]=Hrvatski -Name[hsb]=Chorwatsce -Name[hu]=Horvát -Name[id]=Kroasia -Name[is]=Króatíska -Name[it]=Croato -Name[ja]=クロアãƒã‚¢èªž -Name[ka]=ხáƒáƒ áƒ•áƒáƒ¢áƒ£áƒšáƒ˜ -Name[kk]=Хорватша -Name[km]=ក្រូអាស៊ី -Name[ko]=í¬ë¡œì•„í‹°ì•„ì–´ -Name[lb]=Kroatesch -Name[lt]=Kroatų -Name[lv]=HorvÄtu -Name[mi]=Reo Koroätia -Name[mk]=ХрватÑки -Name[mn]=Хорват -Name[ms]=Croatia -Name[mt]=Kroat -Name[nb]=Kroatisk -Name[nds]=Kroaatsch -Name[ne]=कà¥à¤°à¥‹à¤¯à¤¸à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Kroatisch -Name[nn]=Kroatisk -Name[nso]=Se-Croatian -Name[oc]=Cròatian -Name[pa]=ਕਰੋਟੀਅਨ -Name[pl]=Chorwacki -Name[pt]=Croata -Name[pt_BR]=Croata -Name[ro]=Croată -Name[ru]=ХорватÑкий -Name[rw]=Ikinyakorowasi -Name[se]=Kroatiagiella -Name[sk]=chorvátÄina -Name[sl]=hrvaÅ¡ko -Name[sq]=Kroatisht -Name[sr]=ХрватÑки -Name[sr@Latn]=Hrvatski -Name[ss]=Si-Croatian -Name[sv]=Kroatiska -Name[ta]=கà¯à®°à¯Šà®µà¯‡à®šà®¿à®¯à®©à¯ -Name[te]=à°•à±à°°à±Šà°¯à±†à°·à°¿à°¯à°¨à± -Name[tg]=Хорватӣ -Name[th]=ภาษาโครเอเชียน -Name[tr]=Hırvatça -Name[tt]=Kroatça -Name[uk]=ХорватÑька -Name[uz]=Xorvatcha -Name[uz@cyrillic]=Хорватча -Name[vi]=Cợ-rô-a-ti-a -Name[wa]=CrowÃ¥te -Name[zh_CN]=克罗地亚语 -Name[zh_HK]=克羅地亞語 -Name[zh_TW]=克羅埃西亞語 -Name[zu]=Isi-Croatian -[hsb] -Name=Upper Sorbian -Name[af]=Hoog Serbiese -Name[be]=ВерхнÑÐ»ÑƒÐ¶Ñ‹Ñ†ÐºÐ°Ñ -Name[bg]=ГорноÑорбийÑки -Name[bn]=উচà§à¦š সারà§à¦¬à§€à§Ÿ -Name[br]=Sorab uhel -Name[bs]=Gornji lužiÄkosrpski -Name[ca]=Alt sòrab -Name[cs]=Hornolužicko srbský -Name[csb]=Górnosorbsczi -Name[cy]=Sorbieg Uchaf -Name[da]=Øvre Sorbisk -Name[de]=Obersorbisch -Name[eo]=Supra Soraba -Name[es]=Serbio superior -Name[et]=Ãœlemsorbi -Name[eu]=Goi Serbiera -Name[fa]=صربستان شمالی -Name[fi]=Yläsorbi -Name[fr]=Haut Sorabe -Name[fy]=Heech Sorbysk -Name[ga]=Sorbais Uachtarach -Name[gl]=Alto Sórabo -Name[he]=סרבית עליונה -Name[hi]=अपर सरà¥à¤¬à¤¿à¤¯à¤¨ -Name[hr]=Gornjosrpski -Name[hsb]=Hornjoserbsce -Name[hu]=FelsÅ‘ szorb -Name[it]=Alto sorabo -Name[ja]=上ソルブ語 -Name[ka]=ზედáƒáƒ¡áƒáƒ áƒ‘ული -Name[kk]=Жоғары Ñорбше -Name[km]=សូបៀន លើ -Name[lb]=Uewersorbesch -Name[mk]=Јужно лужички -Name[nb]=Øvresorbisk -Name[nds]=Böversorbsch -Name[ne]=माथिलà¥à¤²à¥‹ सोरà¥à¤¬à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Opper Sorbian -Name[nn]=Øvresorbisk -Name[pa]=ਉੱਪਰੀ ਸਰਬੀਅਨ -Name[pl]=GórnoÅ‚użycki -Name[pt]=Sérvio de Cima -Name[pt_BR]=Sérvio -Name[ro]=Sîrbă de Sus -Name[ru]=Верхнелужицкий -Name[rw]=Ikinyasorubiya cyo hejuru -Name[se]=Bajil Sorbiagiella -Name[sk]=dolnolužická srbÄina -Name[sl]=zgornjesorbijsko -Name[sr]=Горње лужичко ÑрпÑки -Name[sr@Latn]=Gornje lužiÄko srpski -Name[sv]=Högsorbiska -Name[ta]=அபà¯à®ªà®°à¯ செரà¯à®ªà®¿à®¯à®©à¯ -Name[te]=à°…à°ªà±à°ªà°°à± సొరà±à°¬à°¿à°¯à°¨à± -Name[tg]=ЛужаÑагии болоӣ -Name[th]=ภาษาซอร์เบียนตอนบน -Name[tr]=Yukarı Sırpça -Name[tt]=Sorbça, Öske -Name[uk]=Верхньолужицька -Name[uz]=Yuqori Sorbcha -Name[uz@cyrillic]=Юқори Сорбча -Name[vi]=Xoa-bi muá»™n -Name[wa]=Hôt sorbyin -Name[zh_CN]=索布语 -Name[zh_TW]=塞爾維亞語 -[hu] -Name=Hungarian -Name[af]=Hongaars -Name[ar]=الهنغارية (المجرية) -Name[az]=Macarca -Name[be]=ВенгерÑÐºÐ°Ñ -Name[bg]=УнгарÑки -Name[bn]=হাঙà§à¦—ারীয় -Name[br]=Hungareg -Name[bs]=MaÄ‘arski -Name[ca]=Hongarès -Name[cs]=MaÄarský -Name[csb]=Madżarsczi -Name[cy]=Hwngareg -Name[da]=Ungarsk -Name[de]=Ungarisch -Name[el]=ΟυγγÏικά -Name[eo]=Hungara -Name[es]=Húngaro -Name[et]=Ungari -Name[eu]=Hungariera -Name[fa]=مجارستانی -Name[fi]=Unkari -Name[fr]=Hongrois -Name[fy]=Hongaarsk -Name[ga]=Ungáiris -Name[gl]=Húngaro -Name[he]=הונגרית -Name[hi]=हंगेरियन -Name[hr]=MaÄ‘arski -Name[hsb]=Madźarsce -Name[hu]=Magyar -Name[id]=Hungaria -Name[is]=Ungverska -Name[it]=Ungherese -Name[ja]=ãƒãƒ³ã‚¬ãƒªãƒ¼èªž -Name[ka]=უნგრული -Name[kk]=Мажарша -Name[km]=ហុងគ្រី -Name[ko]=í—가리어 -Name[lb]=Ungaresch -Name[lt]=Vengrų -Name[lv]=UngÄru -Name[mi]=Reo Hanekari -Name[mk]=УнгарÑки -Name[mn]=Унгар -Name[ms]=Hungaria -Name[mt]=Ungeriż -Name[nb]=Ungarsk -Name[nds]=Ungaarsch -Name[ne]=हङà¥à¤—ेरेली -Name[nl]=Hongaars -Name[nn]=Ungarsk -Name[nso]=Se-Hungarian -Name[oc]=Hongarian -Name[pa]=ਹੰਗਰੀਅਨ -Name[pl]=WÄ™gierski -Name[pt]=Húngaro -Name[pt_BR]=Húngaro -Name[ro]=Maghiară -Name[ru]=ВенгерÑкий -Name[rw]=Ikinyahangariya -Name[se]=Ungárgiella -Name[sk]=maÄarÄina -Name[sl]=madžarsko -Name[sq]=Hungarisht -Name[sr]=МађарÑки -Name[sr@Latn]=MaÄ‘arski -Name[ss]=Si-Hungarian -Name[sv]=Ungerska -Name[ta]=ஹஙà¯à®•à¯‡à®°à®¿à®¯à®©à¯ -Name[te]=హంగెరియనౠ-Name[tg]=Венгерӣ -Name[th]=ภาษาฮังà¸à¸²à¹€à¸£à¸µà¸¢à¸™ -Name[tr]=Macarca -Name[tt]=Macarça -Name[uk]=УгорÑька -Name[uz]=Vengrcha -Name[uz@cyrillic]=Венгрча -Name[vi]=Hung-gia-lợi -Name[wa]=Hongrwès -Name[zh_CN]=匈牙利语 -Name[zh_HK]=匈牙利語 -Name[zh_TW]=匈牙利語 -Name[zu]=Isi-Hangariyani -[hy] -Name=Armenian -Name[af]=Armeens -Name[ar]=أرمني -Name[az]=ErmÉ™nicÉ™ -Name[be]=ÐрмÑнÑÐºÐ°Ñ -Name[bg]=ÐрменÑки -Name[bn]=আরà§à¦®à§‡à¦¨à§€à§Ÿ -Name[br]=Armenieg -Name[bs]=Armenski -Name[ca]=Armeni -Name[cs]=Arménský -Name[csb]=ArmeÅ„sczi -Name[cy]=Armeineg -Name[da]=Armensk -Name[de]=Armenisch -Name[el]=ΑÏμενικά -Name[eo]=Armena -Name[es]=Armenio -Name[et]=Armeenia -Name[eu]=Armeniera -Name[fa]=ارمنی -Name[fi]=Armenia -Name[fr]=Arménien -Name[fy]=Armeensk -Name[ga]=Airméinis -Name[gl]=Arménio -Name[he]=×רמנית -Name[hi]=आरमेनियन -Name[hr]=Armenski -Name[hsb]=Armensce -Name[hu]=Örmény -Name[id]=Armenia -Name[is]=Armeskt -Name[it]=Armeno -Name[ja]=アルメニア語 -Name[ka]=სáƒáƒ›áƒ®áƒ£áƒ áƒ˜ -Name[kk]=Ðрменше -Name[km]=អារមáŸáž“ី -Name[ko]=아르메니아어 -Name[lb]=Armenesch -Name[lt]=ArmÄ—nų -Name[lv]=Armēņu -Name[mk]=ЕрменÑки -Name[mn]=Ðрмен -Name[ms]=Armenia -Name[nb]=Armensk -Name[nds]=Armeensch -Name[ne]=आरà¥à¤®à¥‡à¤¨à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Armeens -Name[nn]=Armensk -Name[nso]=Se-Armenian -Name[pa]=ਅਰਮੀਅਨ -Name[pl]=OrmiaÅ„ski -Name[pt]=Arménio -Name[pt_BR]=Armênio -Name[ro]=Armenă -Name[ru]=ÐрмÑнÑкий -Name[rw]=Icyarumeniya -Name[se]=Armeniagiella -Name[sk]=arménÄina -Name[sl]=armensko -Name[sq]=Armenisht -Name[sr]=ЈерменÑки -Name[sr@Latn]=Jermenski -Name[ss]=Si-Armenian -Name[sv]=Armenska -Name[ta]=ஆரà¯à®®à¯€à®©à®¿à®¯à®©à¯ -Name[te]=à°…à°°à±à°®à±†à°¨à°¿à°¯à°¨à± -Name[tg]=Ðрманӣ -Name[th]=ภาษาอาร์เมเนีย -Name[tr]=Ermenice -Name[tt]=Ärmänçä -Name[uk]=ВірменÑька -Name[uz]=Armancha -Name[uz@cyrillic]=Ðрманча -Name[vi]=Ãc-mê-ni -Name[wa]=Ã…rmenyin -Name[zh_CN]=亚美尼亚语 -Name[zh_HK]=亞美尼亞語 -Name[zh_TW]=亞美尼亞語 -Name[zu]=Isi-Armenian -[hz] -Name=Herero -Name[ar]=الهيريرو -Name[be]=Ð¥ÑÑ€Ñра -Name[bg]=Хереро -Name[bn]=হেরেরো -Name[cy]=Hausa -Name[eo]=Herera -Name[fa]=هررو -Name[ga]=Heiréiróis -Name[he]=הררו -Name[hi]=हेरेरो -Name[hu]=Hereró -Name[ja]=ヘレロ語 -Name[ka]=ჰერერრ-Name[kk]=Хереро -Name[km]=áž áŸážšáŸáž¢áž¼ -Name[ko]=헤레로어 -Name[mk]=Хереро -Name[mn]=Хереро -Name[ne]=हेरेरो -Name[nso]=Se-Herero -Name[pa]=ਹੀਰੀਰੋ -Name[ro]=Hereră -Name[ru]=Эреро -Name[rw]=Igiherero -Name[se]=Hererogiella -Name[sk]=hererÄina -Name[sl]=herero -Name[sq]=Herisht -Name[sr]=ХерерÑки -Name[sr@Latn]=Hererski -Name[ss]=Si-Herero -Name[ta]=ஹெரà¯à®°à¯‹ -Name[te]=హెరెరో -Name[tg]=ХерÑро -Name[th]=ภาษาเฮอเรโร -Name[tt]=Hereroça -Name[uk]=Гереро -Name[uz]=Xerero -Name[uz@cyrillic]=Хереро -Name[vi]=He-re-rô -Name[zh_CN]=赫雷罗语 -Name[zh_HK]=Herero語 -Name[zh_TW]=Herero語 -Name[zu]=Isi-Herero -[ia] -Name=Interlingua -Name[ar]=الإنترلينغوا -Name[az]=Ä°nterlinqua -Name[be]=ІнтÑрлінгуа -Name[bg]=Интерлингва -Name[bn]=ইনà§à¦Ÿà¦¾à¦°à¦²à¦¿à¦™à§à¦—à§à§Ÿà¦¾ -Name[eo]=Interlingvao -Name[fa]=میان زبانی -Name[ga]=Idirtheanga -Name[he]=×ינטרלינגו××” -Name[hi]=इंटरलिंगà¥à¤† -Name[ja]=インターリンガ -Name[ka]=ინტერლინგვრ-Name[kk]=Интерлингва -Name[km]=អ៊ីងážážºáž›áž¸áž„áž‚áŸážš -Name[ko]=국제어 (Interlingua) -Name[lv]=Interlingva -Name[mk]=Интерлингва -Name[mn]=Интерлингуа -Name[ne]=इनà¥à¤Ÿà¤°à¤²à¤¿à¤™à¥à¤—à¥à¤µà¤¾ -Name[nso]=Se-Interlingua -Name[pa]=ਇੰਟਰਲੀਗੂਆ -Name[pt_BR]=Interlíngua -Name[ru]=Интерлингва -Name[rw]=Ikinyenterilinga -Name[sk]=interlingua -Name[sl]=interlingua -Name[sr]=ИнтерлингванÑки -Name[sr@Latn]=Interlingvanski -Name[ss]=Si-Interlingua -Name[ta]=இனà¯à®Ÿà¯†à®°à¯à®²à®¿à®™à¯à®•à¯à®µà®¾ -Name[te]=ఇంటరౠలింగà±à°µà°¾ -Name[tg]=Забони миёнрав -Name[th]=ภาษานานาชาติ -Name[tt]=Ä°nterlingua -Name[uk]=Інтерлінгва -Name[uz@cyrillic]=Интерлингуа -Name[ven]=Luambo lwa hothe -Name[vi]=In-tợ-lin-gua -Name[wa]=Interlingua (noû latén) -Name[zh_CN]=拉ä¸å›½é™…语(国际辅助语) -Name[zh_HK]=科技共通語 -Name[zh_TW]=科技共通語 -Name[zu]=Ulimi olufanayo -[id] -Name=Indonesian -Name[af]=Indonesië -Name[ar]=الإندونيسية -Name[az]=Ä°ndoneziyaca -Name[be]=ІнданÑзійÑÐºÐ°Ñ -Name[bg]=ИндонезийÑки -Name[bn]=ইনà§à¦¦à§‹à¦¨à§‡à¦¶à§€à§Ÿ -Name[br]=Indoneseg -Name[bs]=Indonezijski -Name[ca]=Indonesi -Name[cs]=Indonéský -Name[csb]=Indonezëjsczi -Name[cy]=Indonesieg -Name[da]=Indonesisk -Name[de]=Indonesisch -Name[el]=Ινδονησιακά -Name[eo]=Indonezia -Name[es]=Indonesio -Name[et]=Indoneesia -Name[eu]=Indonesiera -Name[fa]=اندونزیایی -Name[fi]=Indonesia -Name[fr]=Indonésien -Name[fy]=Yndonesysk -Name[ga]=Indinéisis -Name[gl]=Bahasa Indonésia -Name[he]=×ינדונזית -Name[hi]=इंडोनेशियन -Name[hr]=Indonezijski -Name[hsb]=Indonezisce -Name[hu]=Indonéz -Name[id]=Indonesia -Name[is]=Indónesíska -Name[it]=Indonesiano -Name[ja]=インドãƒã‚·ã‚¢èªž -Name[ka]=ინდáƒáƒœáƒ”ზიური -Name[kk]=ИндонезиÑша -Name[km]=ឥណ្ឌូនáŸážŸáŸŠáž¸ -Name[ko]=ì¸ë„네시아어 -Name[lb]=Indonesesch -Name[lt]=IndonezieÄių -Name[lv]=IndonÄ“zieÅ¡u -Name[mk]=ИндонезиÑки -Name[mn]=Индонези -Name[ms]=Indonesia -Name[mt]=Indoneżjan -Name[nb]=Indonesisk -Name[nds]=Indoneesch -Name[ne]=इनà¥à¤¡à¥‹à¤¨à¥‡à¤¸à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Indonesisch -Name[nn]=Indonesisk -Name[nso]=Se-Indonesian -Name[pa]=ਇੰਡੋਨੇਸ਼ੀਆ -Name[pl]=Indonezyjski -Name[pt]=Indonésio -Name[pt_BR]=Indonésio -Name[ro]=Indoneziană -Name[ru]=ИндонезийÑкий -Name[rw]=Ikinyendonisiya -Name[se]=Indonesiagiella -Name[sk]=indonézÅ¡tina -Name[sl]=indonezijsko -Name[sq]=Indonezisht -Name[sr]=ИндонезијÑки -Name[sr@Latn]=Indonezijski -Name[ss]=Si-Indonesian -Name[sv]=Indonesiska -Name[ta]=இநà¯à®¤à¯‹à®©à¯€à®šà®¿à®¯à®©à¯ -Name[te]=ఇనà±à°¡à±Šà°¨à±†à°·à°¿à°¯à°¨à± -Name[tg]=Индонезӣ -Name[th]=ภาษาอินโดนีเซีย -Name[tr]=Ä°ndonezya dili -Name[tt]=Ä°ndonesçä -Name[uk]=ІндонезійÑька -Name[uz]=Indonezcha -Name[uz@cyrillic]=Индонезча -Name[vi]=Nam-dÆ°Æ¡ng -Name[wa]=Indonezyin -Name[zh_CN]=å°åº¦å°¼è¥¿äºšè¯­ -Name[zh_HK]=å°å°¼èªž -Name[zh_TW]=å°å°¼èªž -Name[zu]=Indoneshiya -[ie] -Name=Interlingue -Name[ar]=الإنترلينغوي -Name[be]=ІнтÑрлінг -Name[bg]=ОкÑидентал -Name[bn]=ইনà§à¦Ÿà¦¾à¦°à¦²à¦¿à¦‚ -Name[br]=Interlingeg -Name[eo]=Interlingveo -Name[es]=Interlinga -Name[fa]=میان زبانی -Name[fy]=Interlingua -Name[ga]=Idirtheanga iartharach -Name[gl]=Interlingua -Name[he]=×ינטרלינגווה -Name[hi]=इंटरलिंग -Name[ja]=インターリング -Name[ka]=ინტერლინგვე -Name[kk]=Интерлигве -Name[km]=អ៊ីងážážºáž›áž¸áž„áž‚áž¹ -Name[ko]=국제어 (Interlingue) -Name[lb]=Interlingua -Name[lv]=Interlingva -Name[mk]=Интерлингва -Name[mn]=Интерлингуе -Name[ne]=इनà¥à¤Ÿà¤°à¤²à¤¿à¤™à¥à¤—à¥à¤µà¤¾ -Name[nso]=Se-Interlingue -Name[pa]=ਇੰਟਰਈਨੂਗੂਈ -Name[rw]=Ikinyenterilinge -Name[sk]=interlingue -Name[sl]=interlingue -Name[sr]=ИнтерлингвијÑки -Name[sr@Latn]=Interlingvijski -Name[ss]=Si-Interlingue -Name[sv]=Interlingua -Name[ta]=இனà¯à®Ÿà¯†à®°à¯à®²à®¿à®™à¯à®•à¯ -Name[te]=ఇంటరౠలింగె -Name[tg]=Забони миёнрав -Name[th]=ภาษาอินเทอร์ลิงà¸à¹Œ -Name[tt]=Ä°nterlingue -Name[uk]=Інтерлінгва -Name[uz@cyrillic]=Интерлингуе -Name[ven]=Luambo lwa hothe -Name[vi]=In-tợ-lin-guợ -Name[zh_CN]=语际语 -Name[zh_HK]=Interlingue語 -Name[zh_TW]=Interlingue語 -Name[zu]=Izilimi ezifanayo -[ik] -Name=Inupiaq -Name[ar]=الإنوبياك -Name[az]=Ä°nupiaqca -Name[be]=Ð†Ð½ÑƒÐ¿Ñ–Ñ†ÐºÐ°Ñ -Name[bg]=Инупиак -Name[bn]=ইনà§à¦ªà¦¿à§Ÿà¦¾à¦• -Name[br]=Inupiak -Name[bs]=Inupiak -Name[eo]=Inuita -Name[fa]=اینوپیاک -Name[fi]=Inupiatun -Name[he]=×ינופי×ק -Name[hi]=इनà¥à¤ªà¤¿à¤†à¤• -Name[hsb]=Inupiak -Name[hu]=Inupiak -Name[it]=Inupiak -Name[ja]=イヌピアック語 -Name[ka]=ინუპიáƒáƒ™áƒ˜ -Name[kk]=Инупиакша -Name[km]=អ៊ីនូភាគ -Name[mk]=Инупиак -Name[mn]=Инупиак -Name[nds]=Inupiak -Name[ne]=इनà¥à¤ªà¤¿à¤• -Name[nn]=Inupiak -Name[nso]=Se-Inupiaq -Name[pa]=ਇਨਪੀਕਾਉ -Name[ro]=Inupiacă -Name[ru]=Инупиак -Name[rw]=Ikinupiyake -Name[se]=Inupiaqgiella -Name[sk]=inupiaq -Name[sl]=inupiaq -Name[sq]=Inupikisht -Name[sr]=ИнупиакÑки -Name[sr@Latn]=Inupiakski -Name[ss]=Si-Inupiaq -Name[ta]=இனà¯à®ªà®¿à®¯à®¾à®•à¯ -Name[te]=ఇనà±à°ªà°¿à°¯à°¾à°•à± -Name[tg]=Инупиакӣ -Name[th]=ภาษาอินุพิอัค -Name[tt]=Ä°nupiaqça -Name[uk]=Інупіак -Name[uz]=Inupiak -Name[uz@cyrillic]=Инупиак -Name[vi]=I-nu-piac -Name[wa]=Inyupiak -Name[zh_CN]=因纽佩特语 -Name[zh_HK]=Inupiaq語 -Name[zh_TW]=Inupiaq語 -Name[zu]=Isi-Inupiaq -[io] -Name=Ido -Name[ar]=الإيدو -Name[be]=Ідо -Name[bg]=Идо -Name[bn]=ইডো -Name[fa]=ایدو -Name[he]=×דו -Name[hi]=इडो -Name[ja]=イド語 -Name[ka]=იდრ-Name[kk]=Идо -Name[km]=អ៊ីឌូ -Name[ko]=ì´ë„ì–´ -Name[mk]=Идо -Name[mn]=Идо -Name[ne]=इडो -Name[nso]=Se-Ido -Name[pa]=ਆਈਡੋ -Name[ru]=Идо -Name[rw]=Ikido -Name[se]=Idogiella -Name[sk]=ido -Name[sl]=ido -Name[sq]=Idoisht -Name[sr]=ИдоÑки -Name[sr@Latn]=Idoski -Name[ss]=Si-Ido -Name[ta]=ஈடோ -Name[te]=ఇడొ -Name[tg]=Идо -Name[th]=ภาษาอิดอ -Name[tt]=Ä°doça -Name[uk]=Ідо -Name[uz@cyrillic]=Идо -Name[vi]=I-đô -Name[zh_CN]=伊多语 -Name[zh_HK]=伊多語 -Name[zh_TW]=伊多語 -Name[zu]=Isi-Ido -[is] -Name=Icelandic -Name[af]=Yslandies -Name[ar]=الآيسلندية -Name[az]=Ä°slandiyaca -Name[be]=ІÑландÑÐºÐ°Ñ -Name[bg]=ИÑландÑки -Name[bn]=আইসলà§à¦¯à¦¾à¦¨à§à¦¡à¦¿à¦• -Name[br]=Islandeg -Name[bs]=Islandski -Name[ca]=Islandès -Name[cs]=Islandský -Name[csb]=Islandzczi -Name[cy]=Islandeg -Name[da]=Islandsk -Name[de]=Isländisch -Name[el]=Ισλανδικά -Name[eo]=Islanda -Name[es]=Islandés -Name[et]=Islandi -Name[eu]=Islandiera -Name[fa]=ایسلندی -Name[fi]=Islanti -Name[fr]=Islandais -Name[fy]=Iislânsk -Name[ga]=Ãoslainnis -Name[gl]=Islandés -Name[he]=×יסלנדית -Name[hi]=आइसलैंडिक -Name[hr]=Islandski -Name[hsb]=Islandsce -Name[hu]=Izlandi -Name[id]=Islandia -Name[is]=Ãslenska -Name[it]=Islandese -Name[ja]=アイスランド語 -Name[ka]=ისლáƒáƒœáƒ“იური -Name[kk]=ИÑландша -Name[km]=អ៊ីស្លង់ -Name[ko]=ì•„ì´ìŠ¬ëž€ë“œì–´ -Name[lb]=Islännesch -Name[lt]=Islandų -Name[lv]=IslandieÅ¡u -Name[mi]=Reo Tiorangi -Name[mk]=ИÑландÑки -Name[mn]=ИÑланд -Name[mt]=Islandiż -Name[nb]=Islandsk -Name[nds]=Islannsch -Name[ne]=आइसलà¥à¤¯à¤¾à¤¨à¥à¤¡à¤¿à¤• -Name[nl]=IJslands -Name[nn]=Islandsk -Name[nso]=Se-Icelandic -Name[oc]=Islandès -Name[pa]=ਆਇਸਲੈਂਡ -Name[pl]=Islandzki -Name[pt]=Islandês -Name[pt_BR]=Islândico -Name[ro]=Islandeză -Name[ru]=ИÑландÑкий -Name[rw]=Ikinyisilande -Name[se]=Islánddagiella -Name[sk]=islandÄina -Name[sl]=islandsko -Name[sq]=Islandisht -Name[sr]=ИÑландÑки -Name[sr@Latn]=Islandski -Name[ss]=Si-Icelandic -Name[sv]=Isländska -Name[ta]=à®à®¸à¯à®²à®¾à®¨à¯à®¤à®¿à®•à¯ -Name[te]=à°à°¸à± లేండికౠ-Name[tg]=ИÑландӣ -Name[th]=ภาษาไอซ์à¹à¸¥à¸™à¸”์ -Name[tr]=Ä°zlanda Dili -Name[tt]=Ä°slandça -Name[uk]=ІÑландÑька -Name[uz]=Islandcha -Name[uz@cyrillic]=ИÑландча -Name[vi]=Băng-đảo -Name[wa]=Izlandès -Name[zh_CN]=冰岛语 -Name[zh_HK]=冰島語 -Name[zh_TW]=冰島語 -Name[zu]=isi-Icelandic -[it] -Name=Italian -Name[af]=Italiaans -Name[ar]=الإيطالية -Name[az]=Ä°talyanca -Name[be]=ІтальÑнÑÐºÐ°Ñ -Name[bg]=ИталианÑки -Name[bn]=ইতালীয় -Name[br]=Italianeg -Name[bs]=Talijanski -Name[ca]=Italià -Name[cs]=Italský -Name[csb]=Italsczi -Name[cy]=Eidaleg -Name[da]=Italiensk -Name[de]=Italienisch -Name[el]=Ιταλικά -Name[eo]=Itala -Name[es]=Italiano -Name[et]=Itaalia -Name[eu]=Italiera -Name[fa]=ایتالیایی -Name[fi]=Italia -Name[fr]=Italien -Name[fy]=Italiaansk -Name[ga]=Iodáilis -Name[gl]=Italiano -Name[he]=×יטלקית -Name[hi]=इतालवी -Name[hr]=Talijanski -Name[hsb]=Italsce -Name[hu]=Olasz -Name[id]=Italia -Name[is]=Ãtalska -Name[it]=Italiano -Name[ja]=イタリア語 -Name[ka]=იტáƒáƒšáƒ˜áƒ£áƒ áƒ˜ -Name[kk]=ИтальÑнша -Name[km]=អ៊ីážáž¶áž›áž¸ -Name[ko]=ì´íƒˆë¦¬ì•„ì–´ -Name[lb]=Italienesch -Name[lt]=Italų -Name[lv]=ItÄļu -Name[mi]=Reo Itari -Name[mk]=ИталијанÑки -Name[mn]=Итали -Name[ms]=Italia -Name[mt]=Taljan -Name[nb]=Italiensk -Name[nds]=Italieensch -Name[ne]=इटालियन -Name[nl]=Italiaans -Name[nn]=Italiensk -Name[nso]=Se-Italian -Name[pa]=ਇਤਾਲਵੀ -Name[pl]=WÅ‚oski -Name[pt]=Italiano -Name[pt_BR]=Italiano -Name[ro]=Italiană -Name[ru]=ИтальÑнÑкий -Name[rw]=Igitaliyani -Name[se]=Itáliagiella -Name[sk]=talianÄina -Name[sl]=italijansko -Name[sq]=Italisht -Name[sr]=ИталијанÑки -Name[sr@Latn]=Italijanski -Name[ss]=Sitaliyani -Name[sv]=Italienska -Name[ta]=இதà¯à®¤à®¾à®²à®¿à®¯à®©à¯ -Name[te]=ఇటాలియనౠ-Name[tg]=Итолиёӣ -Name[th]=ภาษาอิตาเลียน -Name[tr]=Ä°talyanca -Name[tt]=Ä°talça -Name[uk]=ІталійÑька -Name[uz]=Italyancha -Name[uz@cyrillic]=ИталÑнча -Name[vi]=à -Name[wa]=ItÃ¥lyin -Name[xh]=isitaliyane -Name[zh_CN]=æ„大利语 -Name[zh_HK]=æ„大利語 -Name[zh_TW]=義大利語 -Name[zu]=Isi-Ntaliyane -[iu] -Name=Inuktitut -Name[ar]=الإنكتيتوت -Name[be]=Інуктытут -Name[bg]=Инуктитут -Name[bn]=ইনাকà§à¦Ÿà¦¿à¦Ÿà§à¦Ÿ -Name[fa]=اینوکتیتوت -Name[ga]=Ionúitis -Name[he]=×ינוקטיטוט -Name[hi]=इनà¥à¤•à¥à¤¤à¤¿à¤¤à¥ -Name[ja]=イヌイット語 -Name[ka]=ინუქტიუტუტი -Name[kk]=Инуктиут -Name[km]=អ៊ីនូកទីទូហ-Name[mk]=Инуктитут -Name[mn]=Инуктитут -Name[ne]=इनकà¥à¤Ÿà¤¿à¤Ÿà¥à¤Ÿ -Name[nn]=Inuittisk -Name[nso]=Se-Inuktitut -Name[pa]=ਇਨੂਕਟੀਟੂਟ -Name[ru]=Инуктитут -Name[rw]=Ikinukititutu -Name[se]=Inuhkagiella -Name[sk]=inuktitut -Name[sl]=inuktitut -Name[sq]=Inukituisht -Name[sr]=ИнуктитутÑки -Name[sr@Latn]=Inuktitutski -Name[ss]=Si-Inuktitut -Name[ta]=இனà¯à®•à¯à®Ÿà®¿à®Ÿà¯à®Ÿà¯ -Name[te]=ఇనà±à°•à±à°¤à°¿à°Ÿà±à°Ÿà± -Name[tg]=Инуктитут -Name[th]=ภาษาอินุคทิทุท -Name[tt]=Ä°nuktitutça -Name[uk]=Інуктитут -Name[uz@cyrillic]=Инуктитут -Name[vi]=I-nuc-ti-túc -Name[zh_CN]=因纽特语 -Name[zh_HK]=Inuktitut語 -Name[zh_TW]=Inuktitut語 -Name[zu]=Isi-Inuktitut -[ja] -Name=Japanese -Name[af]=Japanees -Name[ar]=اليابانية -Name[az]=Yaponca -Name[be]=ЯпонÑÐºÐ°Ñ -Name[bg]=ЯпонÑки -Name[bn]=জাপানী -Name[br]=Japaneg -Name[bs]=Japanski -Name[ca]=Japonès -Name[cs]=Japonský -Name[csb]=Japòńsczi -Name[cy]=Japaneg -Name[da]=Japansk -Name[de]=Japanisch -Name[el]=Ιαπωνικά -Name[eo]=Japana -Name[es]=Japonés -Name[et]=Jaapani -Name[eu]=Japoniera -Name[fa]=ژاپنی -Name[fi]=Japani -Name[fr]=Japonais -Name[fy]=Japansk -Name[ga]=Seapáinis -Name[gl]=Xaponés -Name[he]=יפנית -Name[hi]=जापानी -Name[hr]=Japanski -Name[hsb]=Japansce -Name[hu]=Japán -Name[id]=Jepang -Name[is]=Japanska -Name[it]=Giapponese -Name[ja]=日本語 -Name[ka]=იáƒáƒžáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Жапонша -Name[km]=ជប៉ុន -Name[ko]=ì¼ë³¸ì–´ -Name[lb]=Japanesch -Name[lt]=Japonų -Name[lv]=JapÄņu -Name[mi]=Reo Hapana -Name[mk]=ЈапонÑки -Name[mn]=Япон -Name[ms]=Jepun -Name[mt]=Ä appuniż -Name[nb]=Japansk -Name[nds]=Japaansch -Name[ne]=जापानी -Name[nl]=Japans -Name[nn]=Japansk -Name[nso]=Se-Japanese -Name[oc]=Japònès -Name[pa]=ਜਾਪਾਨੀ -Name[pl]=JapoÅ„ski -Name[pt]=Japonês -Name[pt_BR]=Japonês -Name[ro]=Japoneză -Name[ru]=ЯпонÑкий -Name[rw]=Ikiyapani -Name[se]=Jáhpangiella -Name[sk]=japonÄina -Name[sl]=japonsko -Name[sq]=Japonisht -Name[sr]=ЈапанÑки -Name[sr@Latn]=Japanski -Name[ss]=Si-Japanese -Name[sv]=Japanska -Name[ta]=ஜபà¯à®ªà®¾à®©à®¿à®¯à®®à¯ -Name[te]=జపనీసౠ-Name[tg]=Японӣ -Name[th]=ภาษาà¸à¸µà¹ˆà¸›à¸¸à¹ˆà¸™ -Name[tr]=Japonca -Name[tt]=Japança -Name[uk]=ЯпонÑька -Name[uz]=Yaponcha -Name[uz@cyrillic]=Японча -Name[ven]=Mudzhapani -Name[vi]=Nhật -Name[wa]=Djaponès -Name[xh]=Isijapani -Name[zh_CN]=日语 -Name[zh_HK]=日語 -Name[zh_TW]=日語 -Name[zu]=Isi-Jaliphani -[jv] -Name=Javanese -Name[af]=Javanees -Name[ar]=جاويه -Name[az]=Yavonca -Name[be]=ЯванÑÐºÐ°Ñ -Name[bg]=ЯвайÑки -Name[bn]=জাভানিস -Name[br]=Javaneg -Name[bs]=Javanski -Name[ca]=Javanès -Name[cs]=Jávský -Name[csb]=JawaÅ„sczi -Name[cy]=Javaneg -Name[da]=Javansk -Name[de]=Javanisch -Name[eo]=Java -Name[es]=Javanés -Name[et]=Jaava -Name[eu]=Javera -Name[fa]=جاوانیز -Name[fi]=Jaava -Name[fr]=Javanais -Name[fy]=Javaansk -Name[ga]=Iávais -Name[gl]=Xavanés -Name[he]=×™×ווה -Name[hi]=जावानी (Javanese) -Name[hr]=Javanski -Name[hsb]=Jawanisce -Name[hu]=Jávai -Name[id]=Jawa -Name[it]=Giavanese -Name[ja]=ジャワ語 -Name[ka]=იáƒáƒ•áƒ -Name[kk]=Ява -Name[km]=យ៉ាវា -Name[ko]=ìžë°”ì–´ -Name[lb]=Javanesesch -Name[lt]=JavieÄių -Name[lv]=JavieÅ¡u -Name[mk]=ЈаванÑки -Name[mn]=Явон -Name[ms]=Jawa -Name[nb]=Javanesisk -Name[nds]=Javaneesch -Name[ne]=जाभानिज -Name[nl]=Javanees -Name[nn]=Javanesisk -Name[nso]=Se-Javanese -Name[pa]=ਜਾਵਾਨੀਅਨ -Name[pl]=JawaÅ„ski -Name[pt]=Javanês -Name[pt_BR]=Javanês -Name[ro]=Iavaneză -Name[ru]=ЯванÑкий -Name[rw]=Ikijavani -Name[se]=Jávagiella -Name[sk]=jávÄina -Name[sl]=javansko -Name[sq]=Javonisht -Name[sr]=ЈаванÑки -Name[sr@Latn]=Javanski -Name[ss]=Si-Javanese -Name[sv]=Javanska -Name[ta]=ஜாவானீஸ௠-Name[te]=జావానీసౠ-Name[tg]=Ðвонӣ -Name[th]=ภาษาชวา -Name[tt]=Javaça -Name[uk]=ЯванÑька -Name[uz]=Yaavanez -Name[uz@cyrillic]=Яаванез -Name[vi]=Gia-va -Name[wa]=Djavanès -Name[zh_CN]=爪哇语 -Name[zh_HK]=爪哇語 -Name[zh_TW]=爪哇語 -Name[zu]=Isi-Javanisi -[ka] -Name=Georgian -Name[af]=Georgiën -Name[ar]=جورجي -Name[az]=GürcücÉ™ -Name[be]=ГрузінÑÐºÐ°Ñ -Name[bg]=ГрузинÑки -Name[bn]=জরà§à¦œà¦¿à§Ÿà¦¾à¦¨ -Name[br]=Jeorjieg -Name[bs]=Gruzijski -Name[ca]=Georgià -Name[cs]=Gruzínský -Name[csb]=Grëzóńsczi -Name[cy]=Georgeg -Name[da]=Georgisk -Name[de]=Georgisch -Name[el]=ΓεωÏγιανά -Name[eo]=Kartvela -Name[es]=Georgiano -Name[et]=Gruusia -Name[eu]=Georgiera -Name[fa]=گرجی -Name[fi]=Georgia -Name[fr]=Géorgien -Name[fy]=Georgysk -Name[ga]=Seoirsis -Name[gl]=Xeorxiano -Name[he]=גרוזינית -Name[hi]=जà¥à¤¯à¥‰à¤°à¥à¤œà¤¿à¤¯à¤¨ -Name[hr]=Gruzijski -Name[hsb]=Gruzinsce -Name[hu]=Grúz -Name[is]=Georgíska -Name[it]=Georgiano -Name[ja]=グルジア語 -Name[ka]=ქáƒáƒ áƒ—ული -Name[kk]=Грузинше -Name[km]=ហ្សកហ្ស៉ី -Name[ko]=그루지안어 -Name[lb]=Georgesch -Name[lt]=Gruzinų -Name[lv]=Gruzīņu -Name[mk]=ГрузиÑки -Name[mn]=Георги -Name[ms]=Georgia -Name[nb]=Georgisk -Name[nds]=Georgsch -Name[ne]=जरà¥à¤œà¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Georgisch -Name[nn]=Georgisk -Name[nso]=Se-Georgian -Name[pa]=ਜਾਰਜੀਆ -Name[pl]=GruziÅ„ski -Name[pt]=Geórgio -Name[pt_BR]=Geórgio -Name[ro]=Georgiană -Name[ru]=ГрузинÑкий -Name[rw]=Ikinyageworugiya -Name[se]=Grusiagiella -Name[sk]=gruzínÄina -Name[sl]=gruzijsko -Name[sq]=Xhorxhanisht -Name[sr]=ГрузијÑки -Name[sr@Latn]=Gruzijski -Name[ss]=Si-Georgian -Name[sv]=Georgiska -Name[ta]=ஜாரà¯à®œà®¿à®¯à®©à¯ -Name[te]=జారà±à°œà°¿à°¯à°¨à± -Name[tg]=Гурҷӣ -Name[th]=ภาษาจอร์เจียน -Name[tr]=Gürcüce -Name[tt]=Görceçä -Name[uk]=ГрузинÑька -Name[uz]=Gruzincha -Name[uz@cyrillic]=Грузинча -Name[vi]=Gi-oa-gi-ạ -Name[wa]=Djeyordjyin -Name[zh_CN]=乔治亚语 -Name[zh_HK]=喬治亞語 -Name[zh_TW]=喬治亞語 -Name[zu]=Isi-Jojiyani -[ki] -Name=Kikuyu -Name[ar]=الكيكويو -Name[az]=Kikuyuca -Name[be]=Кікую -Name[bg]=Кикю -Name[bn]=কিকà§à§Ÿà§ -Name[et]=Kikuju -Name[fa]=کیکویا -Name[fi]=Kikuju -Name[ga]=Ciocúis -Name[he]=קיקויו -Name[hi]=किकूयू -Name[hu]=Kikuju -Name[ja]=キクユ語 -Name[ka]=კიკუიუ -Name[kk]=Кикую -Name[km]=គីគូយូ -Name[ko]=키쿠유어 -Name[lb]=Kikuyu-Sprooch -Name[mk]=Кикују -Name[mn]=Кикуюу -Name[ne]=किकà¥à¤¯à¥ -Name[nso]=Se-Kikuyu -Name[pa]=ਕਿਕੂਯੂ -Name[ru]=Кикую -Name[rw]=Ikikuyu -Name[se]=Kikujugiella -Name[sk]=kikuju -Name[sl]=kikuyu -Name[sq]=Kikuisht -Name[sr]=КикујÑки -Name[sr@Latn]=Kikujski -Name[ss]=Si-Kikuyu -Name[ta]=கியà¯à®•à¯ -Name[te]=à°•à°¿à°•à±à°¯à± -Name[tg]=КикуÑгӣ -Name[th]=ภาษาคิคุยุ -Name[tt]=Kikuyuça -Name[uk]=Кікуйю -Name[uz@cyrillic]=Кикуйу -Name[vi]=Ki-ku-yu -Name[zh_CN]=基库尤语 -Name[zh_HK]=å‰åº«çŒ¶èªž -Name[zh_TW]=å‰åº«çŒ¶èªž -Name[zu]=Isi-Kikuyu -[kk] -Name=Kazakh -Name[ar]=كزخي -Name[az]=Qazaxca -Name[be]=КазахÑÐºÐ°Ñ -Name[bg]=КазахÑки -Name[bn]=কাজাখ -Name[br]=Kazakstaneg -Name[bs]=KazaÅ¡ki -Name[cs]=KazaÅ¡ský -Name[csb]=Kazachsczi -Name[de]=Kasachisch -Name[el]=Καζαχικά -Name[eo]=KazaÄ¥a -Name[es]=Kazajo -Name[et]=Kasahhi -Name[eu]=Kazakhera -Name[fa]=قزاق -Name[fi]=Kazakki -Name[ga]=Casaicis -Name[gl]=Cazaxo -Name[he]=קזחית -Name[hi]=कज़ाख -Name[hr]=KazaÄki -Name[hsb]=Kazachisce -Name[hu]=Kazah -Name[it]=Kazako -Name[ja]=カザフ語 -Name[ka]=ყáƒáƒ–áƒáƒ®áƒ£áƒ áƒ˜ -Name[kk]=Қазақша -Name[km]=កាហ្សាក់ស្ážáž„់ -Name[ko]=ì¹´ìží¬ì–´ -Name[lb]=Kasachesch -Name[lt]=Kazachų -Name[lv]=Kazahu -Name[mk]=КазахÑтанÑки -Name[mn]=Казак -Name[nds]=Kasachsch -Name[ne]=कजाक -Name[nn]=Kasakhisk -Name[nso]=Se-Kazakh -Name[pa]=ਕਾਜ਼ਾਖ -Name[pl]=Kazachski -Name[pt]=Cazaquistanês -Name[ro]=Cazacă -Name[ru]=КазахÑкий -Name[rw]=Igikazaki -Name[se]=Kazakhagiella -Name[sk]=kazaÅ¡tina -Name[sl]=kazaÅ¡ko -Name[sq]=Kazakistanisht -Name[sr]=Казачки -Name[sr@Latn]=KazaÄki -Name[ss]=Si-Kazakh -Name[sv]=Kazakiska -Name[ta]=கசாக௠-Name[te]=కజాఖౠ-Name[tg]=Қазоқӣ -Name[th]=ภาษาคาซัคสถาน -Name[tt]=Qazaqça -Name[uk]=КазахÑька -Name[uz]=Qozoqcha -Name[uz@cyrillic]=Қозоқча -Name[vi]=Kha-xakh -Name[wa]=Kazaxh -Name[zh_CN]=哈è¨å…‹è¯­ -Name[zh_HK]=哈薩克語 -Name[zh_TW]=哈薩克語 -Name[zu]=Isi-Kazakhi -[kl] -Name=Kalaallisut -Name[ar]=الكالاليسوت -Name[az]=Kalaallisutca -Name[be]=КалааліÑут -Name[bg]=КалиÑути -Name[bn]=কালালিসà§à¦Ÿ -Name[fa]=کالالیسوت -Name[fi]=Grönlanti -Name[ga]=Graonlainnis -Name[gl]=Groenlandés -Name[he]=קל×ליסוט -Name[hi]=कलालिसà¥à¤¤ -Name[hu]=Kalaalliszut -Name[ja]=グリーンランド語 -Name[ka]=კáƒáƒšáƒáƒáƒšáƒ˜áƒ¡áƒ£áƒ¢áƒ˜ -Name[kk]=КалаалиÑутша -Name[km]=កាឡាលីសាážáŸ‹ -Name[ko]=그린란드어 -Name[mk]=КалалиÑут -Name[mn]=КалааллиÑут -Name[ne]=कलालà¥à¤²à¤¿à¤¸à¥à¤Ÿ -Name[nn]=Grønlandsk -Name[nso]=Se-Kalaallisut -Name[pa]=ਕਾਲਾਆਲਿਸੂਟ -Name[ro]=Calalisută -Name[ru]=КалаалиÑут -Name[rw]=Igikalalisuti -Name[se]=Kalállisutgiella -Name[sk]=grónÄina -Name[sl]=kalaallisut -Name[sq]=Katalisht -Name[sr]=КалалиÑутÑки -Name[sr@Latn]=Kalalisutski -Name[ss]=Si-Kalaallisut -Name[sv]=Grönländska -Name[ta]=கலாலிசà¯à®Ÿà¯ -Name[te]=కలాలà±à°²à°¿à°¸à±à°¤à± -Name[tg]=КалаалиÑутӣ -Name[th]=ภาษาคาลัทลิซุท -Name[tt]=Kalaallisutça -Name[uk]=КалааліÑут -Name[uz@cyrillic]=КалааллиÑут -Name[vi]=Ka-lă-li-sút -Name[zh_CN]=格陵兰语 -Name[zh_HK]=Kalaallisut語 -Name[zh_TW]=Kalaallisut語 -Name[zu]=Isi-Kalaallisut -[km] -Name=Khmer -Name[ar]=خميري -Name[az]=XmercÉ™ -Name[be]=ХмерÑÐºÐ°Ñ -Name[bg]=КхмерÑки -Name[bn]=খমের -Name[br]=Kmereg -Name[bs]=Kmerski -Name[cs]=Kmérský -Name[csb]=Khmersczi -Name[eo]=Kmera -Name[et]=Khmeeri -Name[fa]=خمری -Name[ga]=Ciméiris -Name[he]=חמר -Name[hi]=खà¥à¤®à¥‡à¤° -Name[hr]=Kmerski -Name[ja]=クメール語 -Name[ka]=ქჰმერული -Name[kk]=Кхмерше -Name[km]=ážáŸ’មែរ -Name[ko]=캄보디아어 -Name[lt]=Khmerų -Name[lv]=Khmeru -Name[mk]=КмерÑки -Name[mn]=Хмер -Name[ne]=खमेर -Name[nso]=Se-Khmer -Name[pa]=ਖਮੀਰ -Name[pl]=Khmerski -Name[ro]=Kmeră -Name[ru]=КхмерÑкий -Name[rw]=Ikinyakime -Name[se]=Khmeragiella -Name[sk]=khmérÄina -Name[sl]=kmersko -Name[sq]=Kmerisht -Name[sr]=КмерÑки -Name[sr@Latn]=Kmerski -Name[ss]=Si-Khmer -Name[sv]=Kambodjanska -Name[ta]=கெமர௠-Name[te]=à°–à±à°®à±†à°°à± -Name[tg]=Хмерӣ -Name[th]=ภาษาเขมร -Name[tt]=Xmerçä -Name[uk]=КхмерÑька -Name[uz]=Kxmercha -Name[uz@cyrillic]=Кхмерча -Name[vi]=KhÆ¡-me -Name[wa]=Xhmer -Name[zh_CN]=高棉语 -Name[zh_HK]=高棉語 -Name[zh_TW]=高棉語 -Name[zu]=Isi-Khmer -[kn] -Name=Kannada -Name[af]=Kanadees -Name[ar]=الكانادا -Name[az]=Kannadaca -Name[be]=КанадÑÐºÐ°Ñ -Name[bg]=Каннада -Name[bn]=কনà§à¦¨à¦¾à¦¡à¦¾ -Name[br]=Kanada -Name[fa]=کانادایی -Name[ga]=Cannadais -Name[he]=קנ×דה -Name[hi]=कनà¥à¤¨à¤¡à¤¼ -Name[ja]=カンナダ語 -Name[ka]=კáƒáƒœáƒœáƒáƒ“რ-Name[kk]=Каннада -Name[km]=កិណាដា -Name[mk]=Канада -Name[mn]=Канад -Name[ne]=कानाडा -Name[nso]=Se-Kannada -Name[pa]=ਕਾਨਡਾ -Name[pt_BR]=Canadá -Name[ro]=Kanada -Name[ru]=Каннада -Name[rw]=Iginyakanada -Name[se]=Kannadagiella -Name[sk]=kannadÄina -Name[sl]=kannada -Name[sq]=Kanadisht -Name[sr]=КанадÑки -Name[sr@Latn]=Kanadski -Name[ss]=Si-Kannada -Name[sv]=Kanaresiska -Name[ta]=கனà¯à®©à®Ÿà®®à¯ -Name[te]=à°•à°¨à±à°¨à°¡ -Name[tg]=Каннадӣ -Name[th]=ภาษาà¸à¸±à¸“ณาท -Name[tt]=Kannadça -Name[uk]=Каннада -Name[uz@cyrillic]=Каннада -Name[vi]=Ka-na-Ä‘a -Name[zh_CN]=åŽçº³å¾·è¯­ -Name[zh_HK]=åŽé‚£é”語 -Name[zh_TW]=åŽé‚£é”語 -Name[zu]=Isi-Khanada -[ko] -Name=Korean -Name[af]=Koriaanse -Name[ar]=الكورية -Name[az]=Koreyaca -Name[be]=КарÑйÑÐºÐ°Ñ -Name[bg]=КорейÑки -Name[bn]=কোরীয় -Name[br]=Koreeg -Name[bs]=Korejski -Name[ca]=Coreà -Name[cs]=Korejský -Name[csb]=KòrejaÅ„sczi -Name[cy]=Koreëg -Name[da]=Koreansk -Name[de]=Koreanisch -Name[el]=ΚοÏεάτικα -Name[eo]=Korea -Name[es]=Coreano -Name[et]=Korea -Name[eu]=Koreera -Name[fa]=کره‌ای -Name[fi]=Korea -Name[fr]=Coréen -Name[fy]=Koareaansk -Name[ga]=Cóiréis -Name[gl]=Coreano -Name[he]=קורי×נית -Name[hi]=कोरियाई -Name[hr]=Korejski -Name[hsb]=Koreansce -Name[hu]=Koreai -Name[id]=Korea -Name[is]=Kóreska -Name[it]=Coreano -Name[ja]=韓国語・æœé®®èªž -Name[ka]=კáƒáƒ áƒ”ული -Name[kk]=Корейше -Name[km]=កូរ៉០-Name[ko]=한국어 -Name[lb]=Koreanesch -Name[lt]=KorÄ—jieÄių -Name[lv]=KorejieÅ¡u -Name[mk]=КорејÑки -Name[mn]=Ð¡Ð¾Ð»Ð¾Ð½Ð³Ð¾Ñ -Name[ms]=Korea -Name[nb]=Koreansk -Name[nds]=Koreaansch -Name[ne]=कोरियाली -Name[nl]=Koreaans -Name[nn]=Koreansk -Name[nso]=Se-Korean -Name[oc]=Còrean -Name[pa]=ਕੋਰੀਆਈ -Name[pl]=KoreaÅ„ski -Name[pt]=Coreano -Name[pt_BR]=Coreano -Name[ro]=Coreană -Name[ru]=КорейÑкий -Name[rw]=Igikoreya -Name[se]=Koreagiella -Name[sk]=kórejÄina -Name[sl]=korejsko -Name[sq]=Koreanisht -Name[sr]=КорејÑки -Name[sr@Latn]=Korejski -Name[ss]=SiKoriya -Name[sv]=Koreanska -Name[ta]=கொரியன௠-Name[te]=కొరియనౠ-Name[tg]=КореÑгӣ -Name[th]=ภาษาเà¸à¸²à¸«à¸¥à¸µ -Name[tr]=Korece -Name[tt]=Koreyçä -Name[uk]=КорейÑька -Name[uz]=Koreyscha -Name[uz@cyrillic]=КорейÑча -Name[vi]=Triều-tiên -Name[wa]=Coreyin -Name[xh]=Isikorea -Name[zh_CN]=æœé²œè¯­ -Name[zh_HK]=韓國語 -Name[zh_TW]=韓國語 -Name[zu]=Isi-Korean -[ks] -Name=Kashmiri -Name[ar]=كشميري -Name[az]=KaÅŸmircÉ™ -Name[be]=КашмірÑÐºÐ°Ñ -Name[bg]=Кашмири -Name[bn]=কাশà§à¦®à§€à¦°à¦¿ -Name[bs]=KaÅ¡mirski -Name[cs]=KaÅ¡mírský -Name[csb]=Kaszmirsczi -Name[da]=Kashmirsk -Name[eo]=KaÅmira -Name[et]=KaÅ¡miiri -Name[eu]=Kaxmirera -Name[fa]=کشمیری -Name[fi]=KaÅ¡miri -Name[ga]=Caismíris -Name[gl]=Caxemir -Name[he]=קשמירית -Name[hi]=कशà¥à¤®à¥€à¤°à¥€ -Name[hr]=KaÅ¡mirski -Name[hsb]=KaÅ¡mirsce -Name[hu]=Kasmír -Name[id]=Kashmir -Name[it]=Cachemire, lingua del -Name[ja]=カシュミール語 -Name[ka]=ქáƒáƒ¨áƒ›áƒ˜áƒ áƒ£áƒšáƒ˜ -Name[kk]=Кашмирше -Name[km]=កាស្មៀរ -Name[ko]=카슈미르어 -Name[lt]=KaÅ¡miro -Name[lv]=KaÅ¡mirieÅ¡u -Name[mk]=КашмирÑки -Name[mn]=Кашмири -Name[nds]=Kaschmiirsch -Name[ne]=काशà¥à¤®à¤¿à¤°à¥€ -Name[nn]=Kasjmiri -Name[nso]=Se-Kashmiri -Name[pa]=ਕਸ਼ਮੀਰੀ -Name[pl]=Kaszmirski -Name[pt_BR]=Cashimira -Name[ro]=CaÅŸmiră -Name[ru]=КашмирÑкий -Name[rw]=Igikashimiri -Name[se]=KaÅ¡mirgiella -Name[sk]=kaÅ¡mírÄina -Name[sl]=kaÅ¡mirsko -Name[sq]=Kashmirisht -Name[sr]=КашмирÑки -Name[sr@Latn]=KaÅ¡mirski -Name[ss]=Si-Kashmiri -Name[ta]=காஷà¯à®®à¯€à®°à®¿ -Name[te]=à°•à°·à±à°®à±€à°°à±€ -Name[tg]=Кашмирӣ -Name[th]=ภาษาà¸à¸±à¸¨à¸¡à¸´à¸£à¸µ -Name[tt]=KaÅŸmirçä -Name[uk]=КашмірÑька -Name[uz]=Kashmircha -Name[uz@cyrillic]=Кашмирча -Name[vi]=Ka-x-mi-ri -Name[wa]=Cachmiri -Name[zh_CN]=克什米尔语 -Name[zh_HK]=喀什米爾語 -Name[zh_TW]=喀什米爾語 -Name[zu]=Isi-Kashimiri -[ku] -Name=Kurdish -Name[ar]=الكردية -Name[az]=KürdcÉ™ -Name[be]=КурдÑÐºÐ°Ñ -Name[bg]=КюрдÑки -Name[bn]=কà§à¦°à§à¦¦à¦¿à¦¶ -Name[br]=Kurdeg -Name[bs]=Kurdski -Name[ca]=Kurd -Name[cs]=Kurdský -Name[csb]=Kùrdijsczi -Name[cy]=Kwrdeg -Name[da]=Kurdisk -Name[de]=Kurdisch -Name[el]=ΚουÏδικά -Name[eo]=Kurda -Name[es]=Kurdo -Name[et]=Kurdi -Name[eu]=Turkiera -Name[fa]=کردی -Name[fi]=Kurdi -Name[fr]=Kurde -Name[fy]=Koerdysk -Name[ga]=Coirdis -Name[gl]=Kurdo -Name[he]=כורדית -Name[hi]=कà¥à¤°à¥à¤¦à¤¿à¤¶ -Name[hr]=Kurdski -Name[hsb]=Kurdisce -Name[hu]=Kurd -Name[id]=Kurdi -Name[is]=Kúrdíska -Name[it]=Curdo -Name[ja]=クルド語 -Name[ka]=ქურთული -Name[kk]=Курдше -Name[km]=ឃឺដ -Name[ko]=쿠르드어 -Name[ku]=Kurdî -Name[lb]=Kurdesch -Name[lt]=Kurdų -Name[lv]=Kurdu -Name[mk]=КурдÑки -Name[mn]=Күрд -Name[mt]=Kurd -Name[nb]=Kurdisk -Name[nds]=Kurdsch -Name[ne]=कà¥à¤°à¥à¤¦à¤¿à¤¶ -Name[nl]=Koerdisch -Name[nn]=Kurdisk -Name[nso]=Se-Kurdish -Name[pa]=ਕà©à¨°à¨¦ -Name[pl]=Kurdyjski -Name[pt]=Curdo -Name[pt_BR]=Turco -Name[ro]=Curdă -Name[ru]=КурдÑкий -Name[rw]=Igikurudishi -Name[se]=Kurdigiella -Name[sk]=kurdÄina -Name[sl]=kurdsko -Name[sq]=Kurdisht -Name[sr]=КурдÑки -Name[sr@Latn]=Kurdski -Name[ss]=Si-Kurdish -Name[sv]=Kurdiska -Name[ta]=கà¯à®°à¯à®¤à®¿à®·à¯ -Name[te]=à°•à±à°°à±à°¦à°¿à°·à± -Name[tg]=Курдиш -Name[th]=ภาษาเคอร์ดิช -Name[tr]=Kürtçe -Name[tt]=Kördçä -Name[uk]=КурдÑька -Name[uz]=Kurdcha -Name[uz@cyrillic]=Курдча -Name[vi]=Kuổ-đị -Name[wa]=Kurdi -Name[zh_CN]=库尔德语 -Name[zh_HK]=庫德語 -Name[zh_TW]=庫德語 -Name[zu]=isi-Kurdish -[kv] -Name=Komi -Name[ar]=الكومي -Name[az]=KomicÉ™ -Name[be]=Комі -Name[bg]=КомизирÑнÑки -Name[bn]=কোমি -Name[csb]=z Komi -Name[eo]=Komia -Name[eu]=Komoreera -Name[fa]=Ú©Ù…ÛŒ -Name[ga]=Coimí -Name[he]=קומי -Name[hi]=कोमी -Name[ja]=コミ語 -Name[ka]=კáƒáƒ›áƒ˜ -Name[kk]=Коми -Name[km]=កូមី -Name[ko]=코미어 -Name[lb]=Komi-Sprooch -Name[mk]=Коми -Name[mn]=Коми -Name[ne]=कोमी -Name[nso]=Se-Komi -Name[pa]=ਕੋਮੀ -Name[pl]=z Komi -Name[ru]=Коми -Name[rw]=Igikomi -Name[se]=Komigiella -Name[sk]=komijÄina -Name[sl]=komi -Name[sq]=Komisht -Name[sr]=КомÑки -Name[sr@Latn]=Komski -Name[ss]=Si-Komi -Name[ta]=கோமி -Name[te]=కోమి -Name[tg]=Коми -Name[th]=ภาษาคอมี -Name[tt]=Komiçä -Name[uk]=Комі -Name[uz@cyrillic]=Коми -Name[vi]=Khô-mi -Name[zh_CN]=科米语 -Name[zh_HK]=Komi語 -Name[zh_TW]=Komi語 -Name[zu]=Isi-Komi -[kw] -Name=Cornish -Name[ar]=كورنش -Name[az]=KorniÅŸcÉ™ -Name[be]=КорнÑÐºÐ°Ñ -Name[bg]=КорнуълÑки -Name[bn]=করà§à¦¨à¦¿à¦¶ -Name[br]=Korneveg -Name[bs]=Kornski -Name[cs]=KorniÅ¡ský -Name[csb]=Kòrnwalijsczi -Name[cy]=Cernyweg -Name[da]=Kornisk -Name[de]=Kornisch -Name[el]=ΚοÏνουαλικά -Name[eo]=Kornvala -Name[et]=Korni -Name[fa]=کرنیشی -Name[fi]=Korni -Name[fr]=Cornique -Name[fy]=Cornysk -Name[ga]=Coirnis -Name[gl]=Córnico -Name[he]=קורנית -Name[hi]=कॉरà¥à¤¨à¤¿à¤¶ -Name[hr]=Kornski -Name[hsb]=Kornisce -Name[hu]=Korn -Name[it]=Cornovaglia, lingua della -Name[ja]=コーンウォール語 -Name[ka]=კáƒáƒ áƒœáƒ£áƒ”ლური -Name[kk]=Корнуолше -Name[km]=កូនីស -Name[ko]=콘월어 -Name[lb]=Kornesch -Name[lt]=Kornų -Name[mk]=Корниш -Name[mn]=Корни -Name[nb]=Cornisk -Name[nds]=Kornisch -Name[ne]=करà¥à¤¨à¤¿à¤¸ -Name[nn]=Kornisk -Name[nso]=Se-Cornish -Name[pa]=ਕੋਰਨਿਸ਼ -Name[pl]=Kornwalijski -Name[pt]=Cornualho -Name[ro]=Corneză -Name[ru]=КорнуольÑкий -Name[rw]=Igikorunishe -Name[se]=Kornagiella -Name[sk]=kornÄina -Name[sl]=cornish -Name[sq]=Kornisht -Name[sr]=КорнÑки -Name[sr@Latn]=Kornski -Name[ss]=Si-Cornish -Name[sv]=Korniska -Name[ta]=கோரà¯à®©à®¿à®·à¯ -Name[te]=కొరà±à°¨à°¿à°·à± -Name[tg]=КорниÑгӣ -Name[th]=ภาษาคอร์นิช -Name[tt]=Kornişçä -Name[uk]=КорнійÑька -Name[uz]=Korn -Name[uz@cyrillic]=Корн -Name[vi]=Xen-tợ Coanh-ouặn -Name[wa]=Cornike -Name[zh_CN]=康瓦尔郡语 -Name[zh_HK]=康瓦耳語 -Name[zh_TW]=康瓦耳語 -Name[zu]=Isi-Khonishi -[ky] -Name=Kirghiz -Name[ar]=قرغيز -Name[az]=Qırğızca -Name[be]=КіргізÑÐºÐ°Ñ -Name[bg]=Киргизки -Name[bn]=কারà§à¦˜à¦¿à¦¸ -Name[br]=Kirgistaneg -Name[bs]=KirgiÅ¡ki -Name[cs]=Kyrgizský -Name[csb]=Kirgijsczi -Name[de]=Kirgisisch -Name[eo]=Kirgiza -Name[es]=Kirguiz -Name[et]=Kirgiisi -Name[eu]=Kirgiera -Name[fa]=قرقیزی -Name[fi]=Kirgiisi -Name[fr]=Kirghize -Name[fy]=Kirgizysk -Name[ga]=Cirgeastáinis -Name[gl]=Quirguize -Name[he]=קירגיזית -Name[hi]=किरà¥à¤—िज -Name[hr]=KirgiÅ¡ki -Name[hsb]=Kirgisce -Name[hu]=Kirgiz -Name[is]=Kirgíska -Name[it]=Chirghiso -Name[ja]=キルギス語 -Name[ka]=ყირგიზული -Name[kk]=Қырғызша -Name[km]=គៀរហ្គីស្ážáž„់ -Name[ko]=키르키즈어 -Name[lb]=Kirghisesch -Name[lt]=Kirgizų -Name[lv]=KirgÄ«zu -Name[mk]=КиргизтанÑки -Name[mn]=Киргиз -Name[nb]=Kirgisisk -Name[nds]=Kirgiisch -Name[ne]=कà¥à¤°à¤¿à¤—िज -Name[nl]=Kirghizisch -Name[nn]=Kirgisisk -Name[nso]=Se-Kirghiz -Name[pa]=ਕਿਰਘੀਜ਼ -Name[pl]=Kirgiski -Name[pt]=Quirguistanês -Name[ro]=Chirghiză -Name[ru]=КиргизÑкий -Name[rw]=Ikirigizi -Name[se]=Kirgisiagiella -Name[sk]=kirgizÅ¡tina -Name[sl]=kirgizijsko -Name[sq]=Kirgjizisht -Name[sr]=КиргиÑки -Name[sr@Latn]=Kirgiski -Name[ss]=Si-Kirghiz -Name[sv]=Kirghiziska -Name[ta]=கிரà¯à®•à®¿à®¸à¯ -Name[te]=à°•à°¿à°°à±à°˜à°¿à°œà± -Name[tg]=Кирғизӣ -Name[th]=ภาษาเคอร์à¸à¸´à¸‹ -Name[tr]=Kırgız -Name[tt]=Qırğızça -Name[uk]=Киргизька -Name[uz]=QirgÊ»izcha -Name[uz@cyrillic]=Қирғизча -Name[vi]=Kia-gi-x -Name[wa]=Kirguize -Name[zh_CN]=å‰å°”å‰æ–¯è¯­ -Name[zh_HK]=å‰çˆ¾å‰æ–¯èªž -Name[zh_TW]=å‰çˆ¾å‰æ–¯èªž -Name[zu]=Isi-Kirghizi -[la] -Name=Latin -Name[af]=Latyn -Name[ar]=لاتيني -Name[az]=Latınca -Name[be]=ЛацінÑÐºÐ°Ñ -Name[bg]=ЛатинÑки -Name[bn]=লাতিন -Name[bs]=Latinski -Name[ca]=Llatí -Name[cs]=Latina -Name[csb]=Åacëzna -Name[cy]=Lladin -Name[de]=Latein -Name[el]=Λατινικά -Name[eo]=Latino -Name[es]=Latín -Name[et]=Ladina -Name[eu]=Latina -Name[fa]=لاتین -Name[fi]=Latina -Name[fy]=Latyn -Name[ga]=Laidin -Name[he]=לטינית -Name[hi]=लेटिन -Name[hr]=Latinski -Name[hsb]=Åaćonsce -Name[is]=Latína -Name[it]=Latino -Name[ja]=ラテン語 -Name[ka]=ლáƒáƒ—ინური -Name[kk]=Латынша -Name[km]=ឡាážáž¶áŸ†áž„ -Name[ko]=ë¼í‹´ì–´ -Name[lb]=Latäin -Name[lt]=Lotynų -Name[mk]=ЛатинÑки -Name[mn]=Латин -Name[nds]=Latiensch -Name[ne]=लà¥à¤¯à¤¾à¤Ÿà¤¿à¤¨ -Name[nl]=Latijn -Name[nso]=Se-Latin -Name[pa]=ਲੈਟਿਨ -Name[pl]=ÅaciÅ„ski -Name[pt]=Latim -Name[pt_BR]=Latim -Name[ro]=Latină -Name[ru]=ЛатинÑкий -Name[rw]=Ikilatini -Name[se]=Láhtengiella -Name[sk]=latinÄina -Name[sl]=latinsko -Name[sq]=Latinisht -Name[sr]=ЛатинÑки -Name[sr@Latn]=Latinski -Name[ss]=Si-Latin -Name[ta]=இலதà¯à®¤à¯€à®©à¯ -Name[te]=లాటినౠ-Name[tg]=Лотинӣ -Name[th]=ภาษาละติน -Name[tt]=Latínça -Name[uk]=ЛатинÑька -Name[uz]=Lotincha -Name[uz@cyrillic]=Лотинча -Name[vi]=La-tinh -Name[wa]=Latén -Name[zh_CN]=拉ä¸è¯­ -Name[zh_HK]=拉ä¸èªž -Name[zh_TW]=拉ä¸èªž -Name[zu]=Isi-Lathini -[lb] -Name=Luxembourgish -Name[ar]=لوكسمبورغي -Name[az]=Lyuksemburqca -Name[be]=ЛюкÑембургÑÐºÐ°Ñ -Name[bg]=ЛюкÑембургÑки -Name[bn]=লাকà§à¦¸à§‡à¦®à¦¬à¦¾à¦°à§à¦—িশ -Name[br]=Luksembourgeg -Name[bs]=LuksemburÅ¡ki -Name[ca]=Luxemburguès -Name[cs]=Lucemburský -Name[csb]=Luksembùrsczi -Name[cy]=Luxembwrgeg -Name[de]=Luxemburgisch -Name[el]=ΛουξεμβουÏγικά -Name[eo]=Luksemburga -Name[es]=Luxemburgués -Name[et]=Luksemburgi -Name[eu]=Luxenburgera -Name[fa]=لوکزامبورگ -Name[fi]=Luxemburg -Name[fr]=Luxembourgeois -Name[fy]=Luksemboarchsk -Name[ga]=Lucsambuirgis -Name[gl]=Luxemburgués -Name[he]=לוקסמבורגית -Name[hi]=लकà¥à¤¸à¤®à¤¬à¤°à¥à¤—िश -Name[hr]=LuksemburÅ¡ki -Name[hsb]=Luksemburgsce -Name[hu]=Luxemburgi -Name[id]=Luxemburg -Name[is]=Lúxemborgiska -Name[it]=Lussemburghese -Name[ja]=ルクセンブルグ語 -Name[ka]=ლუქსემბურგული -Name[kk]=ЛюкÑимбургша -Name[km]=លុចហ្សំបួរ -Name[lb]=Lëtzebuergesch -Name[lt]=LiuksemburgieÄių -Name[lv]=LuksemburgieÅ¡u -Name[mk]=ЛукÑембургÑки -Name[mn]=ЛюькÑембүрг -Name[nb]=Luxemburgisk -Name[nds]=Luxemborgsch -Name[ne]=लगà¥à¤œà¥‡à¤®à¤¬à¤°à¥à¤—िस -Name[nl]=Letzenburgs -Name[nn]=Luxembourgsk -Name[nso]=Se-Luxembourgish -Name[pa]=ਲਕਸ਼ਬਰਗਸ਼ -Name[pl]=Luksemburski -Name[pt]=Luxemburguês -Name[pt_BR]=Luxemburgo -Name[ro]=Luxemburgheză -Name[ru]=ЛюкÑембургÑкий -Name[rw]=Ikinyalugizamburu -Name[se]=Luksenburggagiella -Name[sk]=luxemburÄina -Name[sl]=luksemburÅ¡ko -Name[sq]=Luksemburgisht -Name[sr]=ЛукÑембуршки -Name[sr@Latn]=LuksemburÅ¡ki -Name[ss]=Si-Luxembourgish -Name[sv]=Luxemburgiska -Name[ta]=லகà¯à®šà®®à¯à®ªà¯‹à®°à¯à®•à®¿à®·à¯ -Name[te]=లకà±à°¸à±†à°‚బరà±à°—à°¿à°·à± -Name[tg]=ЛюкÑембургӣ -Name[th]=ภาษาลัà¸à¹€à¸‹à¸¡à¹€à¸šà¸­à¸£à¹Œà¸ -Name[tt]=Lüksemburgça -Name[uk]=ЛюкÑембурзька -Name[uz]=Lyuksemburgcha -Name[uz@cyrillic]=ЛюкÑембургча -Name[vi]=Lúc-xăm-buac -Name[wa]=Lussimbordjwès -Name[zh_CN]=å¢æ£®å ¡è¯­ -Name[zh_HK]=盧森堡語 -Name[zh_TW]=盧森堡語 -Name[zu]=Isi-Luxembourgish -[li] -Name=Limburgan -Name[ar]=الليمبورغية -Name[az]=Limburqca -Name[be]=ЛімбургÑÐºÐ°Ñ -Name[bg]=ЛимбурганÑки -Name[bn]=লিমবারà§à¦—ান -Name[br]=Limburgeg -Name[bs]=LimburÅ¡ki -Name[ca]=Limburgà -Name[csb]=LimbùrgaÅ„sczi -Name[cy]=Limbwrgeg -Name[da]=Limburgansk -Name[de]=Limburgisch -Name[eo]=Limburga -Name[es]=Limburgano -Name[et]=Limburgi -Name[fa]=لیمبرگان -Name[fi]=Limburgi -Name[fr]=Limbourgeois -Name[fy]=Limburgsk -Name[ga]=Limbuirgis -Name[gl]=Limburgano -Name[he]=לימבורגית -Name[hi]=लिंबरगन -Name[hr]=LimburÅ¡ki -Name[hsb]=Limburgsce -Name[hu]=Limburgi -Name[is]=Limburgian -Name[it]=Limburghese -Name[ja]=リグリア語 -Name[ka]=ლიმბურგული -Name[kk]=Лимбургша -Name[km]=លីបួគ -Name[lb]=Limburgesch -Name[mk]=ЛимбурганÑки -Name[mn]=Лимбүрг -Name[nb]=Limburgisk -Name[nds]=Limborgsch -Name[ne]=लिमà¥à¤¬à¥à¤°à¤—न -Name[nl]=Limburgs -Name[nn]=Limburgsk -Name[nso]=Se-Limburgan -Name[pa]=ਲੀਮਬà©à¨°à¨—ਾਨ -Name[pl]=LimburgiaÅ„ski -Name[pt]=Limburguês -Name[ro]=Limburgană -Name[ru]=ЛимбуржÑкий -Name[rw]=Ikilimburigani -Name[se]=Limburggagiella -Name[sk]=limburÄina -Name[sl]=limburgan -Name[sq]=Limburganisht -Name[sr]=Лимбуршки -Name[sr@Latn]=LimburÅ¡ki -Name[ss]=Si-Limburgan -Name[sv]=Limburgiska -Name[ta]=லகà¯à®šà®®à¯à®ªà¯‡à®°à¯à®•à¯ -Name[te]=లింబరà±à°—నౠ-Name[tg]=Лимбурганӣ -Name[th]=ภาษาลิมเบอร์à¸à¸±à¸™ -Name[tt]=Limburgça -Name[uk]=ЛімбурганÑька -Name[uz@cyrillic]=Лимбурган -Name[vi]=Lim-bua-ga -Name[wa]=Limbordjwès -Name[zh_CN]=林堡语 -Name[zh_HK]=Limburgan語 -Name[zh_TW]=Limburgan語 -Name[zu]=Isi-Lumburgan -[ln] -Name=Lingala -Name[ar]=اللينغالا -Name[az]=Linqalaca -Name[be]=ЛінгальÑÐºÐ°Ñ -Name[bg]=Лингала -Name[bn]=লিঙà§à¦—ালা -Name[br]=Lingaleg -Name[fa]=لینگالا -Name[he]=לינגלה -Name[hi]=लिंगला -Name[hr]=Lingalski -Name[ja]=リンガラ語 -Name[ka]=ლინგáƒáƒšáƒ -Name[kk]=Лингата -Name[km]=លីនហ្កាឡា -Name[mk]=Лингала -Name[mn]=Лингала -Name[ne]=लिङà¥à¤—ाला -Name[nso]=Se-Lingala -Name[pa]=ਲੀਨਗਾਲਾ -Name[ro]=Lingală -Name[ru]=Лингала -Name[rw]=Ilingala -Name[se]=Lingalagiella -Name[sk]=lingalÄina -Name[sl]=lingala -Name[sq]=Lingalisht -Name[sr]=ЛингалÑки -Name[sr@Latn]=Lingalski -Name[ss]=Si-Lingala -Name[ta]=லிஙà¯à®•à®¾à®²à®¾ -Name[te]=లింగాలా -Name[tg]=Лингалӣ -Name[th]=ภาษาลิงà¸à¸²à¸¥à¸² -Name[tt]=Lingalaça -Name[uk]=Лінгала -Name[uz@cyrillic]=Лингала -Name[vi]=Lin-ga-la -Name[zh_CN]=林加拉语 -Name[zh_HK]=Lingala語 -Name[zh_TW]=Lingala語 -Name[zu]=Isi-Lingala -[lo] -Name=Lao -Name[ar]=لاويه -Name[az]=Laoca -Name[be]=ЛаоÑÐºÐ°Ñ -Name[bg]=ЛаоÑки -Name[bn]=লাও -Name[ca]=Laosià -Name[cs]=Laoský -Name[csb]=LaòtaÅ„sczi -Name[de]=Laotisch -Name[eo]=LaÅ­a -Name[es]=Laosiano -Name[eu]=Laosera -Name[fa]=لائویی -Name[ga]=Láóis -Name[he]=ל×ו -Name[hi]=लाओ -Name[hsb]=Laotisce -Name[ja]=ラオ語 -Name[ka]=ლáƒáƒ -Name[kk]=ЛаоÑша -Name[km]=ឡាវ -Name[ko]=ë¼ì˜¤ì–´ -Name[lt]=LaosieÄių -Name[lv]=LaosieÅ¡u -Name[mk]=Лао -Name[mn]=Лао -Name[nds]=Laootsch -Name[ne]=लाओ -Name[nso]=Se-Lao -Name[pa]=ਲਿਓ -Name[pl]=LaotaÅ„ski -Name[ru]=Лао -Name[rw]=Ikilawo -Name[se]=Laogiella -Name[sk]=laoÅ¡tina -Name[sl]=laoÅ¡ko -Name[sq]=Laisht -Name[sr]=Лао -Name[ss]=Si-Lao -Name[sv]=Laotiska -Name[ta]=லாவோ -Name[te]=లావో -Name[tg]=ЛаоÑÓ£ -Name[th]=ภาษาลาว -Name[tt]=Laoça -Name[uk]=ЛаоÑька -Name[uz]=Laoscha -Name[uz@cyrillic]=ЛаоÑча -Name[vi]=Lào -Name[wa]=Lawocyin -Name[zh_CN]=è€æŒè¯­ -Name[zh_HK]=寮國語 -Name[zh_TW]=寮國語 -Name[zu]=Isi-Lao -[lt] -Name=Lithuanian -Name[af]=Lithuaniese -Name[ar]=الليتوانية -Name[az]=Litovca -Name[be]=ЛітоўÑÐºÐ°Ñ -Name[bg]=ЛитовÑки -Name[bn]=লিথà§à§Ÿà§‡à¦¨à§€à§Ÿ -Name[br]=Lituaneg -Name[bs]=Litvanski -Name[ca]=Lituà -Name[cs]=Litevský -Name[csb]=Litewsczi -Name[cy]=Lithuaneg -Name[da]=Litauisk -Name[de]=Litauisch -Name[el]=Λιθουανικά -Name[eo]=Litova -Name[es]=Lituano -Name[et]=Leedu -Name[eu]=Lituaniera -Name[fa]=لیتوانی -Name[fi]=Liettua -Name[fr]=Lituanien -Name[fy]=Litouwsk -Name[ga]=Liotuáinis -Name[gl]=Lituano -Name[he]=ליט×ית -Name[hi]=लिथà¥à¤†à¤¨à¤¿à¤¯à¤¨ -Name[hr]=Litvanski -Name[hsb]=Litawsce -Name[hu]=Litván -Name[id]=Lithuania -Name[is]=Litháíska -Name[it]=Lituano -Name[ja]=リトアニア語 -Name[ka]=ლიტვური -Name[kk]=Литваша -Name[km]=លីទុយអានី -Name[ko]=리투아니아어 -Name[lb]=Litauesch -Name[lt]=Lietuvių -Name[lv]=LietuvieÅ¡u -Name[mk]=ЛитванÑки -Name[mn]=Литви -Name[ms]=Lithuania -Name[mt]=Litwanjan -Name[nb]=Litauisk -Name[nds]=Litausch -Name[ne]=लिथà¥à¤¨à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Litouws -Name[nn]=Litauisk -Name[nso]=Se-Lithuanian -Name[oc]=Litua -Name[pa]=ਲੀਥੂਨੀਆਨ -Name[pl]=Litewski -Name[pt]=Lituano -Name[pt_BR]=Lituano -Name[ro]=Lituaniană -Name[ru]=ЛитовÑкий -Name[rw]=Ikinyalitwani -Name[se]=Lietuvagiella -Name[sk]=litovÄina -Name[sl]=litvansko -Name[sq]=Lituanisht -Name[sr]=ЛитванÑки -Name[sr@Latn]=Litvanski -Name[ss]=Si-Lithuanian -Name[sv]=Litauiska -Name[ta]=லிதà¯à®µà¯‡à®©à®¿à®¯à®©à¯ -Name[te]=లితà±à°µà±†à°¨à°¿à°¯à°¨à± -Name[tg]=Литвонӣ -Name[th]=ภาษาลิธัวเนีย -Name[tr]=Litvanya Dili -Name[tt]=Litçä -Name[uk]=ЛитовÑька -Name[uz]=Litvacha -Name[uz@cyrillic]=Литвача -Name[vi]=Li-tu-a-ni -Name[wa]=Litwanyin -Name[zh_CN]=立陶宛语 -Name[zh_HK]=立陶宛語 -Name[zh_TW]=立陶宛語 -Name[zu]=Isi-Lithuanian -[lv] -Name=Latvian -Name[ar]=اللاتÙية -Name[az]=Latışca -Name[be]=ЛатвійÑÐºÐ°Ñ -Name[bg]=ЛатвийÑки -Name[bn]=লাটভিয়ান -Name[br]=Latvieg -Name[bs]=Latvijski -Name[ca]=Letó -Name[cs]=LotyÅ¡ský -Name[csb]=Åotewsczi -Name[cy]=Latfieg -Name[da]=Lettisk -Name[de]=Lettisch -Name[el]=Λεττονικά -Name[eo]=Latvia -Name[es]=Latvio -Name[et]=Läti -Name[eu]=Letoniera -Name[fa]=لاتوینی -Name[fi]=Latvia -Name[fr]=Letton -Name[fy]=Letsk -Name[ga]=Laitvis -Name[gl]=Letón -Name[he]=לטבית -Name[hi]=लाटवियन -Name[hr]=Latvijski -Name[hsb]=Letisce -Name[hu]=Lett -Name[id]=Latvia -Name[is]=Lettneska -Name[it]=Lettone -Name[ja]=ラトビア語 -Name[ka]=ლáƒáƒ¢áƒ•áƒ˜áƒ£áƒ áƒ˜ -Name[kk]=ЛатвиÑша -Name[km]=ឡាážážœáž¸áž™áŸ‰áž¶ -Name[ko]=ë¼íŠ¸ë¹„ì•„ì–´ -Name[lb]=Lettesch -Name[lt]=Latvių -Name[lv]=LatvieÅ¡u -Name[mk]=ЛатвиÑки -Name[mn]=Латви -Name[ms]=Latvia -Name[mt]=Latvjan -Name[nb]=Latvisk -Name[nds]=Lettsch -Name[ne]=लाटà¥à¤­à¤¿à¤¯à¤¨ -Name[nl]=Lets -Name[nn]=Latvisk -Name[nso]=Se-Latvian -Name[pa]=ਲਾਟਵੀਨ -Name[pl]=Åotewski -Name[pt]=Letão -Name[pt_BR]=Latvia -Name[ro]=Latviană -Name[ru]=ЛатышÑкий -Name[rw]=Ikilativiya -Name[se]=Látviagiella -Name[sk]=lotyÅ¡tina -Name[sl]=latvijsko -Name[sq]=Latvisht -Name[sr]=ЛатвијÑки -Name[sr@Latn]=Latvijski -Name[ss]=Si-Latvian -Name[sv]=Lettiska -Name[ta]=இலடà¯à®µà®¿à®¯à®©à¯ -Name[te]=లాటివà±à°¯à°¨à± -Name[tg]=ЛатвиÑгӣ -Name[th]=ภาษาลัทเวีย -Name[tr]=Litvanya Dili -Name[tt]=Latça -Name[uk]=ЛатвійÑька -Name[uz]=Latishcha -Name[uz@cyrillic]=Латишча -Name[vi]=Lát-vi-a -Name[wa]=Letonyin -Name[xh]=Isilatvian -Name[zh_CN]=拉脱维亚语 -Name[zh_HK]=拉脫維亞語 -Name[zh_TW]=拉脫維亞語 -Name[zu]=Isi-Latvian -[mg] -Name=Malagasy -Name[az]=MalaqasicÉ™ -Name[be]=МалагаÑійÑÐºÐ°Ñ -Name[bg]=Малагашки -Name[bn]=মালাগাসি -Name[br]=Malagacheg -Name[ca]=Malgaix -Name[csb]=Madagarsczi -Name[de]=Madagassisch -Name[el]=Μαλγασικά -Name[eo]=Malagasa -Name[es]=Malagasio -Name[et]=Malagassi -Name[eu]=Madagaskarera -Name[fa]=مالاگازی -Name[fi]=Malagasi -Name[fr]=Malgache -Name[fy]=Malagasysk -Name[ga]=Malagásais -Name[gl]=Kanu -Name[he]=מלגשית -Name[hi]=मलागासी -Name[hr]=Malagaski -Name[hu]=Malagazi -Name[id]=Malagasi -Name[it]=Malgascio -Name[ja]=マラガシ語 -Name[ka]=მáƒáƒšáƒáƒ’áƒáƒ¡áƒ£áƒ áƒ˜ -Name[kk]=Мальгашша -Name[km]=ម៉ាដាហ្កាសការ -Name[ko]=ë§ë¼ê°€ì‹œì–´ -Name[lb]=Madagassesch -Name[lt]=Malagasių -Name[lv]=Malagasu -Name[mk]=МалагаÑи -Name[mn]=МалагаÑу -Name[nds]=Madagass'sch -Name[ne]=मालागासे -Name[nn]=Gassisk -Name[nso]=Se-Malagasy -Name[pa]=ਮਾਲਾਗਾਸਆ -Name[pl]=Madagaskarski -Name[pt]=Malgaxe -Name[ro]=Malgaşă -Name[ru]=МальгашÑкий -Name[rw]=Ikimaragasi -Name[se]=Malagasigiella -Name[sk]=malgaÅ¡tina -Name[sl]=malagaÅ¡ko -Name[sq]=Malagasisht -Name[sr]=МалагаÑки -Name[sr@Latn]=Malagaski -Name[ss]=Si-Malagasy -Name[sv]=Malagassiska -Name[ta]=மலகாசி -Name[te]=మలగాసి -Name[tg]=МалагаÑÓ£ -Name[th]=ภาษามาลาà¸à¸²à¸‹à¸µ -Name[tt]=Malagasça -Name[uk]=МалайÑька -Name[uz]=Malagasi -Name[uz@cyrillic]=МалагаÑи -Name[vi]=Ma-la-ga-xị -Name[wa]=Malgache -Name[zh_CN]=马尔加什语 -Name[zh_HK]=馬拉加西語 -Name[zh_TW]=馬拉加西語 -Name[zu]=Isi-Malagasy -[mh] -Name=Marshallese -Name[ar]=المارشالية -Name[az]=MarÅŸallca -Name[be]=МаршальÑÐºÐ°Ñ -Name[bg]=Ебон -Name[bn]=মারà§à¦¶à¦¾à¦²à¦¿à¦¸ -Name[br]=Yezh an enez Marshall -Name[bs]=MarÅ¡alski -Name[ca]=Marshallès -Name[cs]=Marshallský -Name[csb]=z Ã’strowów Marshalla -Name[cy]=Marshalleg -Name[da]=Marshallesisk -Name[de]=Marshallisch -Name[eo]=MarÅala -Name[es]=Marshalés -Name[et]=MarÅ¡alli -Name[eu]=Marshallera -Name[fa]=مارشالی -Name[fi]=Marshall -Name[fr]=Marshall -Name[fy]=Marshalleesk -Name[ga]=Marascailis -Name[gl]=Marshalés -Name[he]=מרשלית -Name[hi]=मारà¥à¤¶à¤²à¥€à¤¸ -Name[hr]=MarÅ¡aleski -Name[hsb]=MarÅ¡alezisce -Name[hu]=Marsalli -Name[is]=Maltneska -Name[it]=Marshall, lingua delle isole -Name[ja]=マーシャル語 -Name[ka]=მáƒáƒ áƒ¨áƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Маршаллша -Name[km]=ម៉ាស្យលីស -Name[lb]=Marschallesesch -Name[lt]=MarÅ¡alieÄių -Name[lv]=MarÅ¡alieÅ¡u -Name[mk]=МаршалÑки -Name[mn]=Маршалл -Name[nb]=Marshallesisk -Name[nds]=Marschalleesch -Name[ne]=मारà¥à¤¶à¤¾à¤²à¤¿à¤¶ -Name[nl]=Marshallees -Name[nn]=Marshallesisk -Name[nso]=Se-Marshallese -Name[pa]=ਮਾਰਸ਼ਲੀਈਸੀ -Name[pl]=z Wysp Marshalla -Name[pt]=Marselhês -Name[ro]=MarÅŸaleză -Name[ru]=МаршалльÑкий -Name[rw]=Ikimarishali -Name[se]=Marshallagiella -Name[sk]=marÅ¡alÄina -Name[sl]=marÅ¡alsko -Name[sq]=Marshalisht -Name[sr]=МаршалеÑки -Name[sr@Latn]=MarÅ¡aleski -Name[ss]=Si-Marshallese -Name[sv]=Marshall -Name[ta]=மாரà¯à®·à®²à¯€à®¸à¯ -Name[te]=మారà±à°·à°²à±€à°¸à± -Name[tg]=Маршалезӣ -Name[th]=ภาษามาร์à¹à¸Šà¸¥à¸¥à¸µà¸ª -Name[tt]=MarÅŸallça -Name[uk]=МаршальÑька -Name[uz]=Marshallez -Name[uz@cyrillic]=Маршаллез -Name[vi]=Mă-xăn -Name[wa]=Marshalès -Name[zh_CN]=马ç»å°”语 -Name[zh_HK]=馬紹爾語 -Name[zh_TW]=馬紹爾語 -Name[zu]=Isi-Marshallese -[mi] -Name=Maori -Name[ar]=الموري -Name[az]=MaoricÉ™ -Name[be]=МаорÑÐºÐ°Ñ -Name[bg]=Маори -Name[bn]=মাওরি -Name[br]=Maorieg -Name[bs]=Maorski -Name[cs]=Maorský -Name[csb]=Maòrëjsczi -Name[el]=ΜαοÏί -Name[eo]=Maoria -Name[es]=Maorí -Name[et]=Maoori -Name[eu]=Maoria -Name[fa]=مائوری -Name[ga]=Maorais -Name[he]=מ×ורית -Name[hi]=माओरी -Name[hsb]=Maorisce -Name[ja]=マオリ語 -Name[ka]=მáƒáƒáƒ áƒ˜ -Name[kk]=Маори -Name[km]=ម៉ោរី -Name[ko]=마오리어 -Name[lb]=Maoresch -Name[lt]=Maorių -Name[lv]=Maoru -Name[mi]=Reo Mäori -Name[mk]=МаорÑки -Name[mn]=Маори -Name[ne]=माओरी -Name[nso]=Se-Maori -Name[oc]=Maòri -Name[pa]=ਮਾਓਰੀ -Name[pl]=Maoryjski -Name[ro]=Maură -Name[ru]=Маори -Name[rw]=Ikimawori -Name[se]=Maoragiella -Name[sk]=maorÄina -Name[sl]=maorsko -Name[sq]=Maorisht -Name[sr]=МаорÑки -Name[sr@Latn]=Maorski -Name[ss]=Si-Maori -Name[sv]=Maoriska -Name[ta]=மாவோரி -Name[te]=మావొరి -Name[tg]=Маори -Name[th]=ภาษาเมารี -Name[tr]=Maori Dili -Name[tt]=Maoriça -Name[uk]=Маорі -Name[uz@cyrillic]=Маори -Name[vi]=Mao-ri -Name[wa]=Mawori -Name[zh_CN]=毛利语 -Name[zh_HK]=毛利語 -Name[zh_TW]=毛利語 -Name[zu]=Isi-Maori -[mk] -Name=Macedonian -Name[ar]=المقدونية -Name[az]=Makedonca -Name[be]=МакедонÑÐºÐ°Ñ -Name[bg]=МакедонÑки -Name[bn]=মাসিডোনীয় -Name[br]=Makedoneg -Name[bs]=Makedonski -Name[ca]=Macedoni -Name[cs]=Makedonský -Name[csb]=MacedoÅ„sczi -Name[cy]=Macedoneg -Name[da]=Makedonisk -Name[de]=Mazedonisch -Name[el]=Σλαβομακεδονικά -Name[eo]=Macedonia -Name[es]=Macedonio -Name[et]=Makedoonia -Name[eu]=Mazedoniera -Name[fa]=مقدونی -Name[fi]=Makedonia -Name[fr]=Macédonien -Name[fy]=Masedoanysk -Name[ga]=Macadóinis -Name[gl]=Macedónio -Name[he]=מקדונית -Name[hi]=मकदूनियन -Name[hr]=Makedonski -Name[hsb]=Makedonsce -Name[hu]=Macedón -Name[id]=Masedonian -Name[is]=Makedóníska -Name[it]=Macedone -Name[ja]=マケドニア語 -Name[ka]=მáƒáƒ™áƒ”დáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Македонша -Name[km]=ម៉ាសáŸážŠáž¼áž“ី -Name[ko]=마케ë„니아어 -Name[lb]=Mazedonesch -Name[lt]=MakedonieÄių -Name[lv]=MaÄ·edonieÅ¡u -Name[mi]=Reo Makerönia -Name[mk]=МакедонÑки -Name[mn]=Макидон -Name[ms]=Macedonia -Name[mt]=MaÄ‹edonjan -Name[nb]=Makedonsk -Name[nds]=Makedoonsch -Name[ne]=मà¥à¤¯à¤¾à¤¸à¥‡à¤¡à¥‹à¤¨à¤¿à¤¯à¤¨ -Name[nl]=Macedonisch -Name[nn]=Makedonsk -Name[nso]=Se-Macedonian -Name[pa]=ਮੈਕਡੋਨੀਆ -Name[pl]=MacedoÅ„ski -Name[pt]=Macedónio -Name[pt_BR]=Macedoniano -Name[ro]=Macedoneană -Name[ru]=МакедонÑкий -Name[rw]=Ikinyamacedoniya -Name[se]=Makedoniagiella -Name[sk]=macedónÄina -Name[sl]=makedonsko -Name[sq]=SllavoMaqedonisht -Name[sr]=МакедонÑки -Name[sr@Latn]=Makedonski -Name[ss]=Si-Macedonian -Name[sv]=Makedonska -Name[ta]=மாசிடோனியன௠-Name[te]=మసిడొనియనౠ-Name[tg]=Мақдунӣ -Name[th]=ภาษามาเซโดเนีย -Name[tr]=Makedonca -Name[tt]=Makedonça -Name[uk]=МакедонÑька -Name[uz]=Makedoniyacha -Name[uz@cyrillic]=МакедониÑча -Name[vi]=Ma-xê-đô-ni -Name[wa]=Macedonyin -Name[zh_CN]=马其顿语 -Name[zh_HK]=馬其頓語 -Name[zh_TW]=馬其頓語 -Name[zu]=Isi-Makhedoniya -[ml] -Name=Malayalam -Name[ar]=المالايالام -Name[az]=Malayamca -Name[be]=МалаÑламÑÐºÐ°Ñ -Name[bg]=МалаÑлам -Name[bn]=মালয়লম -Name[csb]=DrawidaÅ„sczi (hindusczi) -Name[eo]=Malajalama -Name[es]=Malayo -Name[et]=Malajalami -Name[fa]=مالی -Name[fi]=Malajalam -Name[ga]=Mailéalaimis -Name[gl]=Malaialam -Name[he]=מלי×ל×× -Name[hi]=मलयालम -Name[hr]=Malajamski -Name[hu]=Malajalam -Name[it]=Kerala, lingua del -Name[ja]=マラヤーラム語 -Name[ka]=მáƒáƒšáƒáƒ˜áƒšáƒáƒ›áƒ˜ -Name[kk]=Малайамша -Name[km]=ម៉ាឡាយ៉ាឡាម -Name[lb]=Malajalam -Name[lt]=MalajieÄių -Name[mk]=Малајалам -Name[mn]=МалаÑлам -Name[ne]=मलायालम -Name[nso]=Se-Malayalam -Name[pa]=ਮਲਿਆਲਮ -Name[pl]=DrawidiaÅ„ski (Hinduski) -Name[ro]=Malailamă -Name[ru]=МалайÑлам -Name[rw]=Ikimalayalamu -Name[se]=Malajalamagiella -Name[sk]=malajálamÄina -Name[sl]=malayalam -Name[sq]=Malajamisht -Name[sr]=МалајамÑки -Name[sr@Latn]=Malajamski -Name[ss]=Si-Malayalam -Name[ta]=மலையாளம௠-Name[te]=మలయాళం -Name[tg]=МалаÑмӣ -Name[th]=ภาษามะละยาลัง -Name[uk]=МалайÑька -Name[uz@cyrillic]=Малайалам -Name[vi]=Ma-lay-am -Name[zh_CN]=德拉维æ—语 -Name[zh_HK]=馬來亞拉姆語 -Name[zh_TW]=馬來亞拉姆語 -Name[zu]=Isi-Malayalam -[mn] -Name=Mongolian -Name[af]=Mongolees -Name[ar]=منغولية -Name[az]=Monqolca -Name[be]=МангольÑÐºÐ°Ñ -Name[bg]=МонголÑки -Name[bn]=মোঙà§à¦—ল -Name[br]=Mongolieg -Name[bs]=Mongolski -Name[ca]=Mongol -Name[cs]=Mongolský -Name[csb]=Mòngolsczi -Name[cy]=Mongoleg -Name[da]=Mongolsk -Name[de]=Mongolisch -Name[el]=Μογγολικά -Name[eo]=Mongola -Name[es]=Mongol -Name[et]=Mongoolia -Name[eu]=Mongoliera -Name[fa]=مغول -Name[fi]=Mongoli -Name[fr]=Mongol -Name[fy]=Moangoalsk -Name[ga]=Mongóilis -Name[gl]=Mongol -Name[he]=מונגולית -Name[hi]=मंगोलियन -Name[hr]=Mongolski -Name[hsb]=Mongolsce -Name[hu]=Mongol -Name[id]=Mongolia -Name[is]=Bosníska -Name[it]=Mongolo -Name[ja]=モンゴル語 -Name[ka]=მáƒáƒœáƒ¦áƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Моңғолша -Name[km]=ម៉ុងហ្គោលី -Name[ko]=몽골어 -Name[ku]=Mongolî -Name[lb]=Mongolesch -Name[lt]=Mongolų -Name[lv]=Mongoļu -Name[mk]=МонголÑки -Name[mn]=Монгол -Name[ms]=Mongolia -Name[nb]=Mongolsk -Name[nds]=Mongoolsch -Name[ne]=मङà¥à¤—ोलियाली -Name[nl]=Mongolisch -Name[nn]=Mongolsk -Name[nso]=Se-Mongolian -Name[pa]=ਮੰਗੋਲੀਅਨ -Name[pl]=Mongolski -Name[pt]=Mongol -Name[pt_BR]=Mongolês -Name[ro]=Mongolă -Name[ru]=МонгольÑкий -Name[rw]=Ikinyamongoliya -Name[se]=Mongoliagiella -Name[sk]=mongolÄina -Name[sl]=mongolsko -Name[sq]=Mongolisht -Name[sr]=МонголÑки -Name[sr@Latn]=Mongolski -Name[ss]=Si-Mongolian -Name[sv]=Mongoliska -Name[ta]=மொஙà¯à®•à¯‹à®²à®¿à®¯à®©à¯ -Name[te]=మంగోలియనౠ-Name[tg]=Муғулӣ -Name[th]=ภาษามองโà¸à¸¥ -Name[tr]=Mongolca -Name[tt]=MoÄŸolça -Name[uk]=МонгольÑька -Name[uz]=MugÊ»ulcha -Name[uz@cyrillic]=Муғулча -Name[vi]=Mông-cổ -Name[wa]=Mongol -Name[zh_CN]=è’™å¤è¯­ -Name[zh_HK]=è’™å¤èªž -Name[zh_TW]=è’™å¤èªž -Name[zu]=Isi-Mongolian -[mo] -Name=Moldavian -Name[ar]=مولدوÙية -Name[az]=Moldavca -Name[be]=МалдаўÑÐºÐ°Ñ -Name[bg]=МолдовÑки -Name[bn]=মলডেভীয় -Name[br]=Moldaveg -Name[bs]=Moldavski -Name[ca]=Moldau -Name[cs]=Moldavský -Name[csb]=Mòłdawsczi -Name[cy]=Moldafeg -Name[da]=Moldovisk -Name[de]=Moldawisch -Name[el]=Μολδαβικά -Name[eo]=Moldava -Name[es]=Moldavo -Name[et]=Moldaavia -Name[eu]=Moldabiera -Name[fa]=مولداوی -Name[fi]=Moldavia -Name[fr]=Moldave -Name[fy]=Moldavysk -Name[ga]=Moldávais -Name[gl]=Moldavo -Name[he]=מולדבית -Name[hi]=मोलà¥à¤¦à¤¾à¤µà¤¿à¤¯à¤¨ -Name[hr]=Moldavski -Name[hsb]=Moldawisce -Name[hu]=Moldáv -Name[id]=Moldavia -Name[is]=Moldóvíska -Name[it]=Moldavo -Name[ja]=モルダビア語 -Name[ka]=მáƒáƒšáƒ“áƒáƒ•áƒ£áƒ áƒ˜ -Name[kk]=Молдовша -Name[km]=ម៉ុលដាវី -Name[ko]=몰다비어 -Name[lb]=Moldawesch -Name[lt]=Moldavų -Name[lv]=MoldÄvu -Name[mk]=МолдавÑки -Name[mn]=Молдав -Name[ms]=Moldavia -Name[nb]=Moldavisk -Name[nds]=Moldaawsch -Name[ne]=मोलà¥à¤¡à¤¾à¤­à¤¿à¤¯à¤¨ -Name[nl]=Moldavisch -Name[nn]=Moldovsk -Name[nso]=Se-Moldavian -Name[pa]=ਮੋਲਡਾਵੀਅਨ -Name[pl]=MoÅ‚dawski -Name[pt]=Moldavo -Name[pt_BR]=Moldaviano -Name[ro]=Moldovenească -Name[ru]=МолдавÑкий -Name[rw]=Ikinyamoludavi -Name[se]=Moldáviagiella -Name[sk]=moldavÄina -Name[sl]=moldavsko -Name[sq]=Moldavisht -Name[sr]=МолдавÑки -Name[sr@Latn]=Moldavski -Name[ss]=Si-Moldavian -Name[sv]=Moldaviska -Name[ta]=மோலà¯à®Ÿà¯‹à®µà®¿à®¯à®©à¯ -Name[te]=మొలà±à°¦à°¾à°µà°¿à°¯à°¨à± -Name[tg]=Молдаванӣ -Name[th]=ภาษามอลดาเวียน -Name[tr]=Moldavaca -Name[tt]=Moldavça -Name[uk]=МолдовÑька -Name[uz]=Moldavcha -Name[uz@cyrillic]=Молдавча -Name[vi]=Mon-Ä‘a-vi -Name[wa]=MoldÃ¥ve -Name[zh_CN]=摩尔多瓦 -Name[zh_HK]=摩爾é”維亞語 -Name[zh_TW]=摩爾é”維亞語 -Name[zu]=Isi-Moldavian -[mr] -Name=Marathi -Name[ar]=الماراثي -Name[az]=MaraticÉ™ -Name[be]=МараўÑÐºÐ°Ñ -Name[bg]=Маратхи -Name[bn]=মরাঠী -Name[br]=Marateg -Name[csb]=Marathi (hindusczi) -Name[eo]=Marata -Name[es]=Maratí -Name[eu]=Marathera -Name[fa]=ماراتی -Name[fr]=Marathe -Name[ga]=Maraitis -Name[gl]=Marata -Name[he]=מ×ר×תי -Name[hi]=मराठी -Name[hsb]=Marati -Name[hu]=Marati -Name[ja]=マラーティー語 -Name[ka]=მáƒáƒ áƒáƒ—ი -Name[kk]=Марати -Name[km]=ម៉ារាធី -Name[ko]=마ë¼í‹°ì–´ -Name[lv]=Maratu -Name[mk]=Марати -Name[mn]=Марати -Name[ne]=मराठी -Name[nso]=Se-Marathi -Name[pa]=ਮਰਾਠੀ -Name[pl]=Marathi (Hinduski) -Name[ru]=Марати -Name[rw]=Ikimarati -Name[se]=Marathagiella -Name[sk]=maráthÄina -Name[sl]=marathi -Name[sq]=Maratisht -Name[sr]=МаратÑки -Name[sr@Latn]=Maratski -Name[ss]=Si-Marathi -Name[ta]=மராதà¯à®¤à®¿ -Name[te]=మరాఠి -Name[tg]=Маравӣ -Name[th]=ภาษามราà¸à¸µ -Name[tt]=Maratça -Name[uk]=Мараті -Name[uz]=Marati -Name[uz@cyrillic]=Марати -Name[vi]=Ma-ra-ti -Name[wa]=Marati -Name[zh_CN]=马拉地语 -Name[zh_HK]=馬拉地語 -Name[zh_TW]=馬拉地語 -Name[zu]=Isi-Marathi -[ms] -Name=Malay -Name[ar]=مالاوية -Name[az]=Malayca -Name[be]=МалайÑÐºÐ°Ñ -Name[bg]=МалайÑки -Name[bn]=মালয় -Name[br]=Maya -Name[bs]=Malajski -Name[ca]=Malai -Name[cs]=Malajský -Name[csb]=Malajsczi -Name[de]=Malaiisch -Name[eo]=Malaja -Name[es]=Malayo -Name[et]=Malaisia -Name[eu]=Malaysiera -Name[fa]=مالی -Name[fi]=Malaiji -Name[fr]=Malais -Name[fy]=Maleisk -Name[ga]=Malaeis -Name[gl]=Malaio -Name[he]=מל×ית -Name[hi]=मलय -Name[hr]=Malajski -Name[hsb]=Malajsce -Name[hu]=Maláj -Name[id]=Melayu -Name[it]=Malese -Name[ja]=マレー語 -Name[ka]=მáƒáƒšáƒáƒ£áƒ áƒ˜ -Name[kk]=Малайша -Name[km]=ម៉ាឡáŸážŸáŸŠáž¸ -Name[ko]=ë§ë ˆì´ì–´ -Name[ku]=Malayî -Name[lb]=Malaiesch -Name[lt]=Malajų -Name[lv]=MalajieÅ¡u -Name[mk]=МалајÑки -Name[mn]=ÐœÐ°Ð»Ñ -Name[nb]=Malaiisk -Name[nds]=Malaiisch -Name[ne]=मले -Name[nn]=Malayisk -Name[nso]=Se-Malay -Name[pa]=ਮਾਲਿਆ -Name[pl]=Malajski -Name[pt]=Malaio -Name[pt_BR]=Malaiano -Name[ro]=Malaeză -Name[ru]=МалайÑкий -Name[rw]=Ikimalayi -Name[se]=Malaigiella -Name[sk]=malajálamÄina -Name[sl]=malajsko -Name[sq]=Malanisht -Name[sr]=МалајÑки -Name[sr@Latn]=Malajski -Name[ss]=Si-Malay -Name[sv]=Malajiska -Name[ta]=மலாய௠-Name[te]=మలయ -Name[tg]=Малайӣ -Name[th]=ภาษามาเลย์ -Name[tt]=Malayça -Name[uk]=МалайÑька -Name[uz]=Malaycha -Name[uz@cyrillic]=Малайча -Name[vi]=Mã-lai -Name[zh_CN]=马æ¥è¥¿äºšè¯­ -Name[zh_HK]=馬來語 -Name[zh_TW]=馬來語 -Name[zu]=Isi-Malay -[mt] -Name=Maltese -Name[af]=Maltees -Name[ar]=المالطية -Name[az]=Maltaca -Name[be]=МальтыйÑÐºÐ°Ñ -Name[bg]=МалтийÑки -Name[bn]=মলà§à¦Ÿà¦¿à¦¸ -Name[br]=Malteg -Name[bs]=MalteÅ¡ki -Name[ca]=Maltès -Name[cs]=Maltézský -Name[csb]=Maltajsczi -Name[cy]=Malteg -Name[da]=Maltesisk -Name[de]=Maltesisch -Name[el]=Μαλτέζικα -Name[eo]=Malta -Name[es]=Maltés -Name[et]=Malta -Name[eu]=Maltera -Name[fa]=مالتز -Name[fi]=Malta -Name[fr]=Maltais -Name[fy]=Malteesk -Name[ga]=Máltais -Name[gl]=Maltés -Name[he]=מלטזית -Name[hi]=मालà¥à¤Ÿà¥€à¤¸ -Name[hr]=MalteÅ¡ki -Name[hsb]=Maltisce -Name[hu]=Máltai -Name[id]=Malta -Name[is]=Maltneska -Name[ja]=マルタ語 -Name[ka]=მáƒáƒšáƒ¢áƒ£áƒ áƒ˜ -Name[kk]=Мальташа -Name[km]=ម៉ាល់ážáž¶ -Name[ko]=몰타어 -Name[ku]=Maltayî -Name[lb]=Maltesesch -Name[lt]=MaltieÄių -Name[lv]=MaltieÅ¡u -Name[mk]=Малтешки -Name[mn]=Малт -Name[mt]=Malti -Name[nb]=Maltesisk -Name[nds]=Malteesch -Name[ne]=मालà¥à¤¤à¥‡à¤¸à¥€ -Name[nl]=Maltees -Name[nn]=Maltesisk -Name[nso]=Se-Maltese -Name[pa]=ਮਾਲਟੀਸੀ -Name[pl]=MaltaÅ„ski -Name[pt]=Maltês -Name[pt_BR]=Maltês -Name[ro]=Malteză -Name[ru]=МальтийÑкий -Name[rw]=Ikinyamalite -Name[se]=Maltagiella -Name[sk]=maltÄina -Name[sl]=maltežansko -Name[sq]=Maltezisht -Name[sr]=Малтешки -Name[sr@Latn]=MalteÅ¡ki -Name[ss]=Si-Maltese -Name[sv]=Maltesiska -Name[ta]=மாலà¯à®Ÿà¯€à®šà®¿à®¯ -Name[te]=మాలà±à°Ÿà±€à°¸à± -Name[tg]=МалтеÑÓ£ -Name[th]=ภาษามอลตีส -Name[tr]=Malta Dili -Name[tt]=Maltesçä -Name[uk]=МальтійÑька -Name[uz]=Maltacha -Name[uz@cyrillic]=Малтача -Name[vi]=Man-tợ -Name[wa]=Maltès -Name[zh_CN]=马耳他语 -Name[zh_HK]=馬爾他語 -Name[zh_TW]=馬爾他語 -Name[zu]=Isi-Maltase -[my] -Name=Burmese -Name[af]=Burmees -Name[ar]=بورمي -Name[az]=Burmaca -Name[be]=БурмеÑÐºÐ°Ñ -Name[bg]=БирманÑки -Name[bn]=বরà§à¦®à§€ -Name[br]=Birmaneg -Name[bs]=Burmanski -Name[ca]=Burmès -Name[cs]=Burmský -Name[csb]=BirmaÅ„sczi -Name[cy]=Burmeg -Name[de]=Burmesisch -Name[el]=ΒιÏμανικά -Name[eo]=Birma -Name[es]=Burmés -Name[et]=Birma -Name[eu]=Birmaniera -Name[fa]=برمس -Name[fi]=Burma -Name[fr]=Birman -Name[fy]=Burmeesk -Name[ga]=Burmais -Name[gl]=Burmés -Name[he]=בורמזית -Name[hi]=बरà¥à¤®à¥€à¤¸ -Name[hr]=Burmanski -Name[hsb]=Burmezisce -Name[hu]=Burmai -Name[id]=Burma -Name[is]=Búrmenska -Name[it]=Birmano -Name[ja]=ビルマ語 -Name[ka]=ბირმული -Name[kk]=Бирманша -Name[km]=ភូមា -Name[ko]=버마어 -Name[lb]=Burmesesch -Name[lt]=BirmieÄių -Name[lv]=BirmieÅ¡u -Name[mk]=БурманÑки -Name[mn]=Бүрм -Name[ms]=Burma -Name[nb]=Burmesisk -Name[nds]=Burmeesch -Name[ne]=बरà¥à¤®à¥‡à¤²à¥€ -Name[nl]=Burmees -Name[nn]=Burmesisk -Name[nso]=Se-Burmese -Name[pa]=ਬà©à¨°à¨®à©€à¨¸à©€ -Name[pl]=BirmaÅ„ski -Name[pt]=Birmanês -Name[ro]=Burmeză -Name[ru]=БирманÑкий -Name[rw]=Ikibarumi -Name[se]=Burmagiella -Name[sk]=barmÄina -Name[sl]=burmansko -Name[sq]=Burmesisht -Name[sr]=БурманÑки -Name[sr@Latn]=Burmanski -Name[ss]=Si-Burmese -Name[sv]=Burmesiska -Name[ta]=பரà¯à®®à®¿à®¯ -Name[te]=బరà±à°®à±€à°¸à± -Name[tg]=Бурмезӣ -Name[th]=ภาษาพม่า -Name[tt]=Burmesçä -Name[uk]=БірманÑька -Name[uz]=Burmezcha -Name[uz@cyrillic]=Бурмезча -Name[vi]=Miến-Ä‘iện -Name[zh_CN]=缅甸语 -Name[zh_HK]=緬甸語 -Name[zh_TW]=緬甸語 -Name[zu]=Isi-Burmese -[na] -Name=Nauru -Name[ar]=الناورو -Name[az]=Nauruca -Name[be]=ÐаурÑкі -Name[bg]=Ðауру -Name[bn]=নাউরৠ-Name[br]=Naurueg -Name[de]=Nauruisch -Name[el]=ÎαουÏÎ¿Ï -Name[eo]=Naura -Name[eu]=Nauruera -Name[fa]=نائورو -Name[fr]=Nauruan -Name[fy]=Naurûaansk -Name[ga]=Nárúis -Name[he]=× ×ורו -Name[hi]=नौरू -Name[ja]=ナウル語 -Name[ka]=ნáƒáƒ£áƒ áƒ£ -Name[kk]=Ðауру -Name[km]=ណូរុ -Name[ko]=나우루 -Name[lb]=Nauruesch -Name[mk]=Ðауру -Name[mn]=Ðауру -Name[ne]=नाउरू -Name[nso]=Se-Nauru -Name[pa]=ਨਾਉਰੂ -Name[ro]=Naură -Name[ru]=Ðауру -Name[rw]=Ikinawuru -Name[se]=Naurugiella -Name[sk]=nauruÅ¡tina -Name[sl]=nauru -Name[sq]=Naurisht -Name[sr]=ÐаурÑки -Name[sr@Latn]=Naurski -Name[ss]=Si-Nauru -Name[ta]=நவà¯à®°à¯ -Name[te]=నౌరౠ-Name[tg]=Ðауру -Name[th]=ภาษานาอุรุ -Name[uk]=Ðауру -Name[uz@cyrillic]=Ðауру -Name[vi]=Nau-ru -Name[wa]=Nawouro -Name[zh_CN]=ç‘™é²è¯­ -Name[zh_HK]=諾魯語 -Name[zh_TW]=諾魯語 -Name[zu]=Isi-Nauru -[nb] -Name=Norwegian BokmÃ¥l -Name[ar]=بوكماال النرويجية -Name[az]=NorveçcÉ™ (BokmÃ¥l) -Name[be]=ÐарвежÑÐºÐ°Ñ (бокмаль) -Name[bg]=Ðорвежки (букмол) -Name[bn]=নরওয়েজীয় বোকমাল -Name[br]=Norvegeg BokmÃ¥l -Name[bs]=NorveÅ¡ki BokmÃ¥l -Name[ca]=Noruec BokmÃ¥l -Name[cs]=Norský (BokmÃ¥l) -Name[csb]=Norwesczi BokmÃ¥l -Name[cy]=Bokmal Norwyeg -Name[da]=Norsk bokmÃ¥l -Name[de]=Norwegisch (BokmÃ¥l) -Name[el]=ÎοÏβηγικά BokmÃ¥l -Name[eo]=Norvega (Bokmal) -Name[es]=Noruego BokmÃ¥l -Name[et]=Norra bokmÃ¥l -Name[eu]=Norvegiera (BokmÃ¥l) -Name[fa]=نروژی بوکمال -Name[fi]=Norja (bokmÃ¥l) -Name[fr]=Norvégien Bokmaal -Name[fy]=Noarsk, BokmÃ¥l -Name[ga]=Ioruais (BokmÃ¥l) -Name[gl]=Noruegués (Bokmaal) -Name[he]=נורבגית BokmÃ¥l -Name[hi]=नारà¥à¤µà¥‡à¤œà¤¿à¤¯à¤¨ बोकमॉल -Name[hr]=NorveÅ¡ki BokmÃ¥l -Name[hsb]=Norwegsce (BokmÃ¥l) -Name[hu]=Norvég (bokmal) -Name[is]=Norska (bókmál) -Name[it]=Norvegese BokmÃ¥l -Name[ja]=ノルウェー語 (ブークモール) -Name[ka]=ნáƒáƒ áƒ•áƒ”გიული (ბიáƒáƒ™áƒ›áƒáƒšáƒ˜) -Name[kk]=Ðорвег букмалша -Name[km]=áž“áŸážšážœáŸ‚ស បុកម៉ាល់ -Name[ko]=노르웨ì´ì–´ (Bokmaal) -Name[lb]=Norwegesch (BokmÃ¥l) -Name[lt]=Norvegų BokmÃ¥l -Name[lv]=NorvÄ“Ä£u (BokmÄlas) -Name[mk]=Ðорвешки BokmÃ¥l -Name[mn]=Ðорвеги, Бокмал -Name[nb]=Norsk, bokmÃ¥l -Name[nds]=Norweegsch (BokmÃ¥l) -Name[ne]=नरà¥à¤µà¥‡à¤²à¥€ बोकमल -Name[nl]=Noors BokmÃ¥l -Name[nn]=Norsk bokmÃ¥l -Name[nso]=Se-Norwegian BokmÃ¥l -Name[pa]=ਨੋਰਵਿਗੀਆਨ ਬੋਕਮਾਲ -Name[pl]=Norweski Bokmaal -Name[pt]=Norueguês BokmÃ¥l -Name[pt_BR]=Norueguês (Bokmaal) -Name[ro]=Norvegiană BokmÃ¥l -Name[ru]=ÐорвежÑкий (литературный) -Name[rw]=Ikibokumali nyanoruveje -Name[se]=Girjedárogiella -Name[sk]=nórsky bokmÃ¥l -Name[sl]=norveÅ¡ko (bokmaal) -Name[sr]=Ðорвешки (БокмалÑки) -Name[sr@Latn]=NorveÅ¡ki (Bokmalski) -Name[ss]=Si-Norwegian BokmÃ¥l -Name[sv]=Norskt bokmÃ¥l -Name[ta]=நாரà¯à®µà¯€à®œà®¿à®¯à®©à¯ பொகà¯à®®à®¾à®²à¯ -Name[te]=నారà±à°µà±€à°œà°¿à°¯à°¨à± బోకà±à°®à°¾à°²à± -Name[tg]=ÐорвегиÑгӣ Боқмал -Name[th]=ภาษานอร์เวย์ (บ็อคมัล) -Name[tr]=Norveççe BokmÃ¥l -Name[tt]=Norvegçä (ädäbi) -Name[uk]=Ðорвезька (BokmÃ¥l) -Name[uz]=Norvegcha (Bokmaal) -Name[uz@cyrillic]=Ðорвегча (Бокмаал) -Name[vi]=Na-uy (Bóc-mặn) -Name[wa]=Norvedjyin (BokmÃ¥l) -Name[zh_CN]=挪å¨è¯­ (åšå…‹é©¬å°”语) -Name[zh_TW]=æŒªå¨ BokmÃ¥l -Name[zu]=Isi-Norwegian Bokmaal -[nd] -Name=Ndebele, North -Name[af]=Ndebele, Noord -Name[ar]=النديبيلي الشمالية -Name[az]=Ndebele, Åžimal -Name[be]=ÐдÑбель (поўнач) -Name[bg]=Северен Ðдебеле -Name[bn]=নà§â€Œà¦¦à§‡à¦¬à§‡à¦²à§‡, উতà§à¦¤à¦° -Name[br]=Ndebele, Norzh -Name[bs]=Ndebele, Sjeverni -Name[ca]=Ndebele, Nord -Name[cs]=Ndebele, Severní -Name[csb]=Ndebele, Norda -Name[cy]=Ndebele, Gogledd -Name[da]=Ndebele, nord -Name[de]=Ndebele (nördliches) -Name[eo]=Norda Ndebele -Name[es]=Ndebele del norte -Name[et]=Põhja-ndebele -Name[eu]=Ndebelera (iparraldekoa) -Name[fa]=اندبل شمالی -Name[fi]=Ndebele, Pohjoinen -Name[fr]=Ndébélé du Nord -Name[fy]=Ndebele, Noard -Name[ga]=Ndebele Thuaidh -Name[gl]=Ndebele do norte -Name[he]=נדבלה צפונית -Name[hi]=नेदेबेले, उतà¥à¤¤à¤° -Name[hr]=Ndebele, Sjeverni -Name[hsb]=Ndebele, Sewjerne -Name[hu]=Ndebele (északi) -Name[id]=Ndebele, Utara -Name[is]=Ndebele, norður -Name[it]=Ndebele settentrionale -Name[ja]=北ンデベレ語 -Name[ka]=ჩრდილრნდებელე -Name[kk]=СолтүÑік Ðдебеле -Name[km]=នដិបិលិ​ážáž¶áž„​ជើង -Name[ko]=ë¶ë¶€ ì€ë°ë²¨ë ˆ -Name[lb]=Ndebele (nördlech) -Name[lt]=Ndebele, Å iaurÄ—s -Name[mk]=Ðдебеле, Ñеверен -Name[mn]=ÐдÑбÑлÑ, умард -Name[nb]=Ndebele, Nord -Name[nds]=Ndebele, Noord -Name[ne]=डेबेले, उतà¥à¤¤à¤° -Name[nl]=Ndebele, Noord -Name[nn]=Ndebele, nord -Name[nso]=Se-Ndebele, sa Lebowa -Name[pa]=ਨਡੀਬੀਲੀ, ਉੱਤਰੀ -Name[pl]=Ndebele, Północ -Name[pt]=Ndebele do Norte -Name[pt_BR]=Ndebele, Norte -Name[ro]=Ndebelă nordică -Name[ru]=Сев. Ðдебеле -Name[rw]=Ikindebele, amajyaruguru -Name[se]=Ndebelegiella, davvi -Name[sk]=severná ndebelÄina -Name[sl]=ndebele, severno -Name[sq]=Nbedelisht të Veriut -Name[sr]=Ðдебеле, Северни -Name[sr@Latn]=Ndebele, Severni -Name[ss]=SiNdebele, sasenyakatfo -Name[sv]=Nordndebele -Name[ta]=டெபெலே, வட -Name[te]=నెబేలె, ఉతà±à°¤à°° -Name[tg]=Ðдебелӣ, Шимол -Name[th]=ภาษาอึนเดเบเล ตอนเหนือ -Name[tt]=Ndebeleçä, Tönyaq -Name[uk]=Ðдебелє, Північна -Name[uz]=Ndebele, Shimol -Name[uz@cyrillic]=Ðдебеле, Шимол -Name[ven]=Ndebele, Devhula -Name[vi]=N-Ä‘e-be-lê (Bắc) -Name[wa]=Ndebele (bijhe) -Name[xh]=Isindebele, Emntla -Name[zh_CN]=Ndebele,北部 -Name[zh_HK]=Ndebele語,北部 -Name[zh_TW]=Ndebele語,北部 -Name[zu]=Isi-Ndebele, Sase-Ntshonalanga -[nds] -Name=Low Saxon -Name[af]=Lae Saxon -Name[be]=ÐіжнеÑакÑонÑÐºÐ°Ñ -Name[bg]=ДолноÑакÑонÑки -Name[bn]=নিমà§à¦¨ সà§à¦¯à¦¾à¦•à§à¦¸à¦¨ -Name[br]=Saozeg izel -Name[bs]=Niži saksonski -Name[ca]=Baix saxó -Name[cs]=Dolnosaský -Name[csb]=DolnosaksoÅ„sczi -Name[cy]=Sacsoneg Isel -Name[da]=Nedersaksisk -Name[de]=Niederdeutsch -Name[eo]=Malsupra Saksa -Name[es]=Sajón bajo -Name[et]=Alamsaksi -Name[eu]=Beheko Sajoniera -Name[fa]=ساکسونی سÙÙ„ÛŒ -Name[fi]=Alasaksa -Name[fr]=Bas saxon (ou francique, ou plattdeutsch) -Name[fy]=Neder Saksysk -Name[ga]=Sacsainis Ãochtarach -Name[gl]=Baixo Saxón -Name[hi]=लो सेकà¥à¤¸à¤¨ -Name[hr]=Donjosaksonski -Name[hsb]=Delnjosaksce -Name[hu]=Alsószász -Name[it]=Basso sassone -Name[ja]=低ザクセン語 -Name[ka]=ქვედრსáƒáƒ¥áƒ¡áƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Төмен ÑакÑонша -Name[km]=ឡូសាក់សុង -Name[ku]=Saksonî ya Jêrîn -Name[lb]=Niddersächsesch -Name[lt]=Žemutinių saksonų -Name[lv]=Lejas sakÅ¡u -Name[mk]=ДолноÑакÑонÑки -Name[nb]=Lavgermansk -Name[nds]=Plattdüütsch -Name[ne]=लो साकà¥à¤¸à¥‹à¤¨ -Name[nl]=Nedersaksisch -Name[nn]=LÃ¥ggermansk -Name[pa]=ਲੋਅ ਸਾਕੋਨ -Name[pl]=DolnosaksoÅ„ski -Name[pt]=Baixo-Saxão -Name[pt_BR]=Baixa Saxonia -Name[ro]=Saxona de Jos -Name[ru]=ÐижнеÑакÑонÑкий -Name[rw]=Igisagisoni cyo hasi -Name[se]=Vuolil Sáksonagiella -Name[sk]=dolná saÅ¡tina -Name[sl]=spodnjesaÅ¡ko -Name[sr]=Доњи ÑакÑонÑки -Name[sr@Latn]=Donji saksonski -Name[sv]=LÃ¥gsaxiska -Name[ta]=லோ சாகà¯à®¸à®¾à®©à¯ -Name[te]=లో సాకà±à°¸à°¨à± -Name[tg]=СакÑон -Name[th]=ภาษาเยอรมัน ระดับล่าง -Name[tr]=AÅŸağı Sakson -Name[tt]=Saksonça, Asqı -Name[uk]=ÐижньоÑакÑонÑька -Name[uz]=Past Saksoncha -Name[uz@cyrillic]=ПаÑÑ‚ СакÑонча -Name[vi]=Xác-xá»nh thấp -Name[wa]=Bas sacson -Name[zh_CN]=撒克逊语 -Name[zh_TW]=è–©å…‹éœèªž -[ne] -Name=Nepali -Name[ar]=نيبالي -Name[az]=Nepalca -Name[be]=ÐепальÑÐºÐ°Ñ -Name[bg]=Ðепали -Name[bn]=নেপালী -Name[br]=Nepaleg -Name[bs]=Nepalski -Name[ca]=Nepalí -Name[cs]=Nepálský -Name[csb]=Nepalsczi -Name[de]=Nepalesisch -Name[eo]=Nepala -Name[es]=Nepalí -Name[et]=Nepaali -Name[eu]=Nepalera -Name[fa]=نپالی -Name[fr]=Népalais -Name[fy]=Nepaleesk -Name[ga]=Neipealais -Name[he]=נפ×לית -Name[hi]=नेपाली -Name[hr]=Nepalski -Name[hsb]=Nepalezisce -Name[hu]=Nepáli -Name[id]=Nepal -Name[it]=Nepalese -Name[ja]=ãƒãƒ‘ール語 -Name[ka]=ნეპáƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Ðепалша -Name[km]=áž“áŸáž”៉ាល់ -Name[ko]=네팔어 -Name[ku]=Nepalî -Name[lb]=Nepalesesch -Name[lt]=NepalieÄių -Name[lv]=NepÄlieÅ¡u -Name[mk]=ÐепалÑки -Name[mn]=Ðепал -Name[nds]=Nepaleesch -Name[ne]=नेपाली -Name[nl]=Nepalees -Name[nn]=Nepalsk -Name[nso]=Se-Nepali -Name[pa]=ਨੇਪਾਲੀ -Name[pl]=Nepalski -Name[pt]=Nepalês -Name[ro]=Nepaleză -Name[ru]=ÐепальÑкий -Name[rw]=Ikinyanepale -Name[se]=Nepálagiella -Name[sk]=nepálÄina -Name[sl]=nepalsko -Name[sq]=Nepalisht -Name[sr]=ÐепалÑки -Name[sr@Latn]=Nepalski -Name[ss]=SiNepali -Name[ta]=நேபாளி -Name[te]=నేపాలి -Name[tg]=Ðепалӣ -Name[th]=ภาษาเนปาล -Name[tr]=Nepalce -Name[tt]=Nepalça -Name[uk]=ÐепальÑька -Name[uz]=Nepalcha -Name[uz@cyrillic]=Ðепалча -Name[vi]=Ne-pa-li -Name[wa]=Nepalès -Name[zh_CN]=尼泊尔语 -Name[zh_HK]=尼泊爾語 -Name[zh_TW]=尼泊爾語 -Name[zu]=Isi-Nepali -[ng] -Name=Ndonga -Name[ar]=الندونغا -Name[be]=Ðдонга -Name[bg]=Ðдонга -Name[bn]=নডোঙà§à¦—া -Name[de]=Oshivambo -Name[fa]=اندونگا -Name[ga]=Ndongais -Name[he]=נדונגה -Name[hi]=नदोनà¥à¤—ा -Name[ja]=ンドゥンガ語 -Name[ka]=ნდáƒáƒœáƒ’რ-Name[kk]=Ðдонга -Name[km]=នដុងហ្កា -Name[mk]=Ðдонга -Name[mn]=Ðдонга -Name[ne]=डोङà¥à¤—ा -Name[nso]=Se-Ndonga -Name[pa]=ਨਡੋਨਗਾ -Name[ro]=Ndongă -Name[ru]=Ðдонга -Name[rw]=Ikindonga -Name[se]=Ndongagiella -Name[sk]=ndonga -Name[sl]=ndonga -Name[sq]=Ndongisht -Name[sr]=Ðдонга -Name[ss]=SiNdonga -Name[ta]=டொஙà¯à®•à®¾ -Name[te]=డొంగా -Name[tg]=Ðдонга -Name[th]=ภาษาอึนดองà¸à¸² -Name[tt]=Ndongaça -Name[uk]=Ðдонга -Name[uz@cyrillic]=Ðдонга -Name[vi]=N-Ä‘on-ga -Name[zh_HK]=Ndonga語 -Name[zh_TW]=Ndonga語 -Name[zu]=Isi-Ndonga -[nl] -Name=Dutch -Name[af]=Hollands -Name[ar]=الهولندية -Name[az]=FlamenkcÉ™ -Name[be]=ГаландÑÐºÐ°Ñ -Name[bg]=ХоландÑки -Name[bn]=ওলনà§à¦¦à¦¾à¦œ -Name[br]=Nederlandeg -Name[bs]=Nizozemski -Name[ca]=Holandès -Name[cs]=Holandský -Name[csb]=Hòlandzczi -Name[cy]=Iseldireg -Name[da]=Hollandsk -Name[de]=Niederländisch -Name[el]=Ολλανδικά -Name[eo]=Nederlanda -Name[es]=Holandés -Name[et]=Hollandi -Name[eu]=Nederlandera -Name[fa]=هلندی -Name[fi]=Hollanti -Name[fr]=Hollandais -Name[fy]=Nederlânsk -Name[ga]=Ollainnis -Name[gl]=Holandés -Name[he]=הולנדית -Name[hi]=डच -Name[hr]=Nizozemski -Name[hsb]=Nižozemsce -Name[hu]=Holland -Name[id]=Belanda -Name[is]=Hollenska -Name[it]=Olandese -Name[ja]=オランダ語 -Name[ka]=ჰáƒáƒšáƒáƒœáƒ“იური -Name[kk]=Ðидреландша -Name[km]=ហុល្លង់ -Name[ko]=네ëœëž€ë“œì–´ -Name[ku]=Holendî -Name[lb]=Hollännesch -Name[lt]=Danų -Name[lv]=HolandieÅ¡u -Name[mi]=Reo Tenemaka -Name[mk]=ХоландÑки -Name[mn]=Дуч -Name[ms]=Belanda -Name[mt]=Olandiż -Name[nb]=Nederlandsk -Name[nds]=Nedderlannsch -Name[ne]=डच -Name[nl]=Nederlands -Name[nn]=Nederlandsk -Name[nso]=Se-Dutch -Name[oc]=Olandès -Name[pa]=ਡੱਚ -Name[pl]=Holenderski -Name[pt]=Holandês -Name[pt_BR]=Holandês -Name[ro]=Olandeză -Name[ru]=ГолландÑкий -Name[rw]=Ikinyaholande -Name[se]=Hollánddagiella -Name[sk]=holandÄina -Name[sl]=nizozemsko -Name[sq]=Hungarisht -Name[sr]=ХоландÑки -Name[sr@Latn]=Holandski -Name[ss]=SiDatji -Name[sv]=Holländska -Name[ta]=டசà¯à®šà¯ -Name[te]=à°¡à°šà± -Name[tg]=Олмонӣ -Name[th]=ภาษาดัทช์ -Name[tr]=Flamanca -Name[tt]=Dutça -Name[uk]=ÐідерландÑька -Name[uz]=Gollandcha -Name[uz@cyrillic]=Голландча -Name[vi]=Hoà-lan -Name[wa]=Neyerlandès -Name[xh]=Isidatshi -Name[zh_CN]=è·å…°è¯­ -Name[zh_HK]=è·è˜­èªž -Name[zh_TW]=è·è˜­èªž -Name[zu]=Isi-Danishi -[nn] -Name=Norwegian Nynorsk -Name[af]=Noörweese Nynorsk -Name[ar]=نينورسك النرويجية -Name[az]=NorveçcÉ™ (Nynorsk) -Name[be]=ÐарвежÑÐºÐ°Ñ (нюнорÑк) -Name[bg]=Ðорвежки (нюнорÑк) -Name[bn]=নরওয়েজীয় নাইনরà§à¦¸à§à¦• -Name[br]=Norvegeg Nynorsk -Name[bs]=NorveÅ¡ki Nynorsk -Name[ca]=Noruec Nynorsk -Name[cs]=Norský (Nynorsk) -Name[csb]=Norwesczi Nynorsk -Name[cy]=Nynorsk Norwyeg -Name[da]=Nynorsk -Name[de]=Norwegisch (Nynorsk) -Name[el]=ÎοÏβηγικά Nynorsk -Name[eo]=Norvega (Nynorsk) -Name[es]=Noruego Nynorsk -Name[et]=Norra nynorsk -Name[eu]=Norvegiera (Nynorsk) -Name[fa]=نرس جدید نروژی -Name[fi]=Norja (nynorsk) -Name[fr]=Norvégien Nynorsk -Name[fy]=Noarsk, Nynorsk -Name[ga]=Ioruais (Nynorsk) -Name[gl]=Noruegués (Nynorsk) -Name[he]=נורבגית Nynorsk -Name[hi]=नारà¥à¤µà¥‡à¤œà¤¿à¤¯à¤¨ नायनोरसà¥à¤• -Name[hr]=NorveÅ¡ki Nynorsk -Name[hsb]=Norwegsce (Nynorsk) -Name[hu]=Norvég (nynorsk) -Name[id]=Norwegia (Nynorsk) -Name[is]=Norska (nýnorska) -Name[it]=Norvegese Nynorsk -Name[ja]=ノルウェー語 (ニーノシュク) -Name[ka]=ნáƒáƒ áƒ•áƒ”გიული (ნინáƒáƒ áƒ¡áƒ™áƒ˜) -Name[kk]=Ðовег нунорÑкша -Name[km]=áž“áŸážšážœáŸ‚ស នីនូស -Name[ko]=노르웨ì´ì–´ (Nynorsk) -Name[ku]=Norwêcî Nynorsk -Name[lb]=Norwegesch (Nynorsk) -Name[lt]=Norvegų Nynorsk -Name[lv]=NorvÄ“Ä£u (Å…Å«norskas) -Name[mk]=Ðорвешки Nynorsk -Name[mn]=Ðорвеги ÐинорÑк -Name[nb]=Nynorsk -Name[nds]=Norweegsch Nynorsk -Name[ne]=नरà¥à¤µà¥‡à¤²à¥€ नाइनोरà¥à¤¸à¤• -Name[nl]=Noors, Nynorsk -Name[nn]=Norsk nynorsk -Name[nso]=Se-Norwegian Nynorsk -Name[pa]=ਨੋਰਵਿਗੀਆਨ ਨਯਾਨੋਰਸਕ -Name[pl]=Norweski Nynorsk -Name[pt]=Norueguês Nynorsk -Name[pt_BR]=Norueguês do Norte -Name[ro]=Norvegiană Nynorsk -Name[ru]=ÐорвежÑкий (нинорÑкий) -Name[rw]=Ikinyanoruveji nayinorusiki -Name[se]=OÄ‘Ä‘adárogiella -Name[sk]=nórsky nynorsk -Name[sl]=norveÅ¡ko (nyorsk) -Name[sq]=Norvegjisht (Nynorsk) -Name[sr]=Ðорвешки (Ðиноршки) -Name[sr@Latn]=NorveÅ¡ki (NinorÅ¡ki) -Name[ss]=Si-Norwegian Nynorsk -Name[sv]=Nynorska -Name[ta]=நாரà¯à®µà¯€à®œà®¿à®¯à®©à¯ (நையோரà¯à®¸à¯à®•à¯) -Name[te]=నారà±à°µà±€à°œà°¿à°¯à°¨à± à°¨à±à°¯à±‹à°°à±à°¸à±à°•à± -Name[tg]=ÐорвегиÑгӣ ÐунорÑк -Name[th]=ภาษานอร์เวย์ (นูนอร์สคฺ) -Name[tr]=Norveççe Nynorsk -Name[tt]=Norwejçä (Ninorsk) -Name[uk]=Ðорвезька (Nynorsk) -Name[uz]=Norvegiyacha (Nynorsk) -Name[uz@cyrillic]=ÐорвегиÑча (ÐйнорÑк) -Name[vi]=Na-uy (Ny-noạ-x-kh) -Name[wa]=Noû-Norvedjyin (Nynorsk) -Name[zh_CN]=挪å¨è¯­ (尼诺斯克语) -Name[zh_HK]=æŒªå¨ Nynorsk 語 -Name[zh_TW]=æŒªå¨ Nynorsk 語 -Name[zu]=Isi-Norwegian Nynorsk -[nr] -Name=Ndebele, South -Name[af]=Ndebele, Suid -Name[ar]=النديبيلي الجنوبية -Name[az]=Ndebele, CÉ™nub -Name[be]=ÐдÑбель (поўдзень) -Name[bg]=Южен Ðдебеле -Name[bn]=নà§â€Œà¦¦à§‡à¦¬à§‡à¦²à§‡, দকà§à¦·à¦¿à¦£ -Name[br]=Ndebele, Su -Name[bs]=Ndebele, Južni -Name[ca]=Ndebele, Sud -Name[cs]=Ndebele, Jižní -Name[csb]=Ndebele, Pôłnie -Name[cy]=Ndebele, De -Name[da]=Ndebele, syd -Name[de]=Ndebele (südliches) -Name[eo]=Suda Ndebele -Name[es]=Ndebele del sur -Name[et]=Lõuna-ndebele -Name[eu]=Ndebelera (hegoaldekoa) -Name[fa]=اندبل جنوبی -Name[fi]=Ndebele, Etelä -Name[fr]=Ndébélé du Sud -Name[fy]=Ndebele, Súd -Name[ga]=Ndebele Theas -Name[gl]=Ndebele do Sur -Name[he]=נדבלה דרומית -Name[hi]=नेदेबेले,दकà¥à¤·à¤¿à¤£ -Name[hr]=Ndebele, Južni -Name[hsb]=Ndebele, Južne -Name[hu]=Ndebele (déli) -Name[id]=Ndebele, Selatan -Name[is]=Ndebele, suður -Name[it]=Ndebele meridionale -Name[ja]=å—ンデベレ語 -Name[ka]=სáƒáƒ›áƒ®áƒ áƒ”თ ნდებელე -Name[kk]=ОңтүÑтік ндебеле -Name[km]=នដិបិលិ​ážáž¶áž„​ážáŸ’បូង -Name[ko]=남부 ì€ë°ë²¨ë ˆ -Name[lb]=Ndebele (südlecht) -Name[lt]=Ndebele, Pietų -Name[mk]=Ðдебеле, јужен -Name[mn]=ÐдÑбÑлÑ, өмнөд -Name[nb]=Ndebele, Sør -Name[nds]=Ndebele, Sööd -Name[ne]=डेबेले, दकà¥à¤·à¤¿à¤£ -Name[nl]=Ndebele, Zuid -Name[nn]=Ndebele, sør -Name[nso]=Se-Ndebele, sa Borwa -Name[pa]=ਨਡੀਬੀਲੀ, ਦੱਖਣੀ -Name[pl]=Ndebele, PoÅ‚udnie -Name[pt]=Ndebele do Sul -Name[pt_BR]=Ndebele, Sul -Name[ro]=Ndebelă sudică -Name[ru]=Юж. Ðдебеле -Name[rw]=Ikindebele, Amajyepfo -Name[se]=Ndebelegiella, lulli -Name[sk]=južná ndebelÄina -Name[sl]=ndebele, južno -Name[sq]=NBedelisht të Jugut -Name[sr]=Ðдебеле, Јужни -Name[sr@Latn]=Ndebele, Južni -Name[ss]=SiNdebele, saseningizimu -Name[sv]=Sydndebele -Name[ta]=டெபெலே, தென௠-Name[te]=నెబేలె, దకà±à°·à°¿à°£ -Name[tg]=Ðдебелӣ, Ҷануб -Name[th]=ภาษาอึนเดเบเล ตอนใต้ -Name[tt]=Ndebeleçä, Könyaq -Name[uk]=Ðдебелє, Південна -Name[uz]=Ndebele, Janub -Name[uz@cyrillic]=Ðдебеле, Жануб -Name[ven]=Ndebele, Tshipembe -Name[vi]=N-Ä‘e-be-lê (Nam) -Name[wa]=Ndebele (nonne) -Name[xh]=Isindebele, Emazantsi -Name[zh_CN]=Ndebele,å—部 -Name[zh_HK]=Ndebele語,å—部 -Name[zh_TW]=Ndebele語,å—部 -Name[zu]=Isi-Ndebele, Sase-Mzansi -[nso] -Name=Northern Sotho -Name[af]=Noord Sotho -Name[ar]=السوتو الشمالية -Name[az]=Åžimali Sotho -Name[be]=Паўночнае Сота -Name[bg]=Северен Сото -Name[bn]=উতà§à¦¤à¦° সোথো -Name[br]=Soto, Norzh -Name[bs]=Sjeverni Soto -Name[ca]=Sotho del nord -Name[cs]=Severní Sotho -Name[csb]=Nordowé Sotho -Name[cy]=Sotho'r Gogledd -Name[da]=Nord Sotho -Name[de]=Nord-Sotho -Name[eo]=Norda Sotoa -Name[es]=Sotho del norte -Name[et]=Põhja-sotho -Name[eu]=Sothoera (iparraldekoa) -Name[fa]=سوتوی شمالی -Name[fi]=Pohjoissotho -Name[fr]=Sotho du Nord -Name[fy]=Noard Sotho -Name[ga]=Seipidis -Name[gl]=Sotho do Norte -Name[hi]=नारà¥à¤¦à¤°à¥à¤¨ सोथो -Name[hr]=Sjeverni Sotho -Name[hsb]=Sewjerne Sotho -Name[hu]=Északi sotho -Name[is]=Norður Sotho -Name[it]=Sotho settentrionale -Name[ja]=北ソト語 -Name[ka]=ჩრდილრსáƒáƒ¢áƒ -Name[kk]=СолтүÑтік Ñото -Name[km]=សូធូ​ជើង -Name[ko]=ë¶ë¶€ 소토어 -Name[lb]=Nördlecht Sotho -Name[lt]=Å iaurÄ—s Sotho -Name[lv]=Ziemeļu Sotho -Name[mk]=Северен Сото -Name[mn]=Умард Сото -Name[ms]=Sotho Utara -Name[nb]=Nord-Sotho -Name[nds]=Noord-Sotho -Name[ne]=उतà¥à¤¤à¤°à¥€ सोथो -Name[nl]=Noord-Sotho -Name[nn]=Nord-Sotho -Name[pa]=ਉੱਤਰੀ ਸੋਥੋ -Name[pl]=Północne Sotho -Name[pt]=Sotho do Norte -Name[pt_BR]=Sotho do Norte -Name[ro]=Soto nordică -Name[ru]=Северное Сото -Name[rw]=Igisoto cy'Amajyaruguru -Name[se]=Davvi-sothogiella -Name[sk]=severná sothÄina -Name[sl]=severni sotho -Name[sq]=Sothisht Të Veriut -Name[sr]=Северни Ñото -Name[sr@Latn]=Severni soto -Name[sv]=Nordsotho -Name[ta]=நாரà¯à®¤à®©à¯ சோதà¯à®¤à¯‹ -Name[te]=ఉతà±à°¤à°° సొతొ -Name[tg]=Сотои Шимолӣ -Name[th]=ภาษาโซโธ ตอนเหนือ -Name[tt]=Tönyaq Sotho -Name[uk]=Північне Сото -Name[uz]=Shimoliy Sotocha -Name[uz@cyrillic]=Шимолий Соточа -Name[vi]=Xô-tô (Bắc) -Name[wa]=Soto (bijhe) -Name[zh_CN]=北部梭托语 -[nv] -Name=Navajo -Name[ar]=الناÙاجو -Name[az]=Navayoca -Name[be]=Ðаваё -Name[bg]=Ðавахо -Name[bn]=নাভায়ো -Name[el]=Îάβαχο -Name[eo]=Navaha -Name[et]=Navaho -Name[fa]=ناواجو -Name[fi]=Navaho -Name[fr]=Navaho -Name[ga]=Navachóis -Name[gl]=Navaxo -Name[he]=נב×חו -Name[hi]=नवाजो -Name[hr]=Navaho -Name[ja]=ナãƒãƒ›èªž -Name[ka]=ნáƒáƒ•áƒáƒ®áƒ -Name[kk]=Ðавахо -Name[km]=ណាវាហ្សូ -Name[ko]=나바조어 -Name[mk]=Ðавахо -Name[mn]=ÐаваÑа -Name[ne]=नेभाजो -Name[nso]=Se-Navajo -Name[pa]=ਨਾਵਾਜੋ -Name[ru]=Ðавахо -Name[rw]=Ikinavajo -Name[se]=Naváhogiella -Name[sk]=navajo -Name[sl]=navajo -Name[sq]=Navahisht -Name[sr]=Ðавахо -Name[sr@Latn]=Navaho -Name[ss]=Si-Navajo -Name[sv]=Navaho -Name[ta]=நவாஜோ -Name[te]=నవాజొ -Name[tg]=Ðаваҷо -Name[th]=ภาษานาวาโฮ -Name[tt]=Navaxoça -Name[uk]=Ðавахо -Name[uz@cyrillic]=Ðаважо -Name[vi]=Na-va-cá»™ -Name[wa]=Navaxho -Name[zh_CN]=纳瓦éœè¯­ -Name[zh_HK]=ç´ç“¦ä¼™èªž -Name[zh_TW]=ç´ç“¦ä¼™èªž -Name[zu]=Isi-Navajo -[ny] -Name=Chichewa -Name[ar]=التشيشيوا -Name[az]=Çiçeva -Name[be]=ЧычÑва -Name[bg]=Чеуа -Name[bn]=চিচেওয়া -Name[de]=Nyanja -Name[eo]=Ĉiĉeva -Name[fa]=چیچوا -Name[fi]=Njandža -Name[ga]=Siseivis -Name[he]=צ'יצ'ווה -Name[hi]=चिचेवा -Name[hu]=Csicseva -Name[ja]=ãƒã‚§ãƒ¯èªž -Name[ka]=ჩიჩევრ-Name[kk]=Чичева -Name[km]=ចីចិវ៉ា -Name[lb]=Nyanja -Name[lv]=ÄŒiÄevieÅ¡u -Name[mk]=Чичева -Name[mn]=Чичева -Name[ne]=चिचेवा -Name[nso]=Se-Chichewa -Name[pa]=ਚਿਚੀਵਾ -Name[ro]=Ciceuă -Name[ru]=Чичева -Name[rw]=Igicicewa -Name[se]=Chichevagiella -Name[sk]=ÄiÄewa -Name[sl]=chichewa -Name[sq]=Çiçevisht -Name[sr]=ЧичевÑки -Name[sr@Latn]=ÄŒiÄevski -Name[ss]=Si-Chichewa -Name[sv]=Chewa -Name[ta]=சிசà¯à®šà¯†à®µà®¾ -Name[te]=చిచెవా -Name[tg]=Чичевагӣ -Name[th]=ภาษาชิเชวา -Name[tt]=Çiçewaça -Name[uk]=ЧічеванÑька -Name[uz]=Chicheva -Name[uz@cyrillic]=Чичева -Name[vi]=Chi-che-ouă -Name[wa]=Tchitchewa -Name[zh_CN]=é½åˆ‡ç“¦è¯­ -Name[zh_HK]=Chichewa語 -Name[zh_TW]=Chichewa語 -Name[zu]=Isi-Chichewa -[oc] -Name=Occitan -Name[af]=Okkitaan -Name[ar]=الأوكسيتانية -Name[az]=Oksitan -Name[be]=ÐкітанÑÐºÐ°Ñ -Name[bg]=ОкÑитанÑки -Name[bn]=ওকà§à¦¸à¦¿à¦Ÿà¦¾à¦¨ -Name[br]=Oksitaneg -Name[ca]=Occità -Name[cs]=Okcitánský -Name[csb]=Ã’kcitaÅ„sczi -Name[cy]=Occitaneg -Name[de]=Okzitanisch -Name[eo]=Okcitana -Name[es]=Occitano -Name[et]=Oktsitaani -Name[eu]=Okzitaniera -Name[fa]=اÙکیتان -Name[fi]=Oksitaani -Name[fy]=Oksitaansk -Name[ga]=Ocatáinis -Name[gl]=Occitano -Name[he]=פרובנסלית -Name[hi]=ओसिटान -Name[hsb]=Okcitansce -Name[hu]=Okcitán -Name[it]=Occitano -Name[ja]=オック語 -Name[ka]=áƒáƒ¥áƒ˜áƒ¢áƒáƒœáƒ£áƒ áƒ˜ (ფრáƒáƒœáƒ’ული დიáƒáƒšáƒ”ქტი) -Name[kk]=ОÑÑитанша -Name[km]=អុកស៊ីážáž„់ -Name[ko]=오í¬ì–´ -Name[ku]=Oksîtanî -Name[lb]=Okzitanesch -Name[lv]=OkitÄņu -Name[mk]=Очитан -Name[mn]=ОкÑитан -Name[mt]=OÄ‹Ä‹itan -Name[nb]=Oksitansk -Name[nds]=Okzitaansch -Name[ne]=ओकà¥à¤¸à¤¿à¤Ÿà¤¾à¤¨ -Name[nn]=Oksitansk -Name[nso]=Se-Occitan -Name[oc]=Occitàn -Name[pa]=ਓਸੀਟਾਨ -Name[pl]=OkcytaÅ„ski -Name[pt]=Occitano -Name[ro]=Occitană -Name[ru]=ФранцузÑкий (диалект Occitan) -Name[rw]=Icyogisitani -Name[se]=Oksitánagiella -Name[sk]=okcitánÄina -Name[sl]=oÄitansko -Name[sq]=Oksitanisht -Name[sr]=ОцитанÑки -Name[sr@Latn]=Ocitanski -Name[ss]=Si-Occitan -Name[sv]=Occitanska -Name[ta]=ஒகà¯à®šà®¿à®Ÿà¯à®Ÿà®¾à®©à¯ -Name[te]=à°’à°¸à±à°¸à°¿à°Ÿà°¾à°¨à± -Name[tg]=Окитанӣ -Name[th]=ภาษาออคซิทัน -Name[tr]=Oksitan dili -Name[tt]=Okkitança -Name[uk]=ОкÑітанÑька -Name[uz]=Fransuzcha (Ossitan shevasi) -Name[uz@cyrillic]=Французча (ОÑÑитан шеваÑи) -Name[vi]=Óc-ci-tan -Name[zh_CN]=奥西å¦è¯­ -Name[zh_HK]=Occitan語 -Name[zh_TW]=Occitan語 -Name[zu]=Isi-Osithani -[om] -Name=Oromo -Name[ar]=الأورومو -Name[az]=Oromoca -Name[be]=Ðрома -Name[bg]=Ðфан Оромо -Name[bn]=ওরোমো -Name[eo]=Oroma -Name[fa]=اورومو -Name[ga]=Oraimis -Name[he]=×ורומו -Name[hi]=ओरोमो -Name[hr]=Oromski -Name[ja]=オロモ語 -Name[ka]=áƒáƒ áƒáƒ›áƒ -Name[kk]=Оромо -Name[km]=អុរុមុ -Name[ko]=오로모어 -Name[mk]=Оромо -Name[mn]=Оромо -Name[ne]=ओरोमो -Name[nso]=Se-Oromo -Name[pa]=ਓਰੋਮੋ -Name[ro]=Oromă -Name[ru]=Оромо -Name[rw]=Icyoromo -Name[se]=Oromogiella -Name[sk]=oromÄina -Name[sl]=oromo -Name[sq]=Oromisht -Name[sr]=ОромÑки -Name[sr@Latn]=Oromski -Name[ss]=Si-Oromo -Name[ta]=ஒரோமோ -Name[te]=ఒరొమొ -Name[tg]=Оромо -Name[th]=ภาษาโอโรโม -Name[tt]=Oromoça -Name[uk]=Оромо -Name[uz@cyrillic]=Оромо -Name[vi]=O-ro-mô -Name[zh_CN]=阿曼语 -Name[zh_HK]=Oromo語 -Name[zh_TW]=Oromo語 -Name[zu]=Isi-Oromo -[or] -Name=Oriya -Name[ar]=لغة أهل أوريسا )الهند( -Name[az]=Oriyaca -Name[be]=ÐžÑ€Ñ‹Ñ -Name[bg]=ÐžÑ€Ð¸Ñ -Name[bn]=ওড়িয়া -Name[eo]=Orijo -Name[et]=Orija -Name[fa]=اوریا -Name[fi]=Orija -Name[ga]=Oirísis -Name[gl]=Orisa -Name[he]=×וריה -Name[hi]=ओरिया -Name[hu]=Orija -Name[ja]=オリヤー語 -Name[ka]=áƒáƒ áƒ˜áƒ -Name[kk]=ÐžÑ€Ð¸Ñ -Name[km]=អូរីយ៉ា -Name[ko]=오리야어 -Name[lb]=Orija -Name[mk]=Орија -Name[mn]=ÐžÑ€Ð¸Ñ -Name[ne]=ओरिया -Name[nso]=Se-Oriya -Name[pa]=ਉੜੀਆ -Name[ro]=Oriană -Name[ru]=ÐžÑ€Ð¸Ñ -Name[rw]=Icyoriya -Name[se]=Orijagiella -Name[sk]=uríjÄina -Name[sl]=oriya -Name[sq]=Orijisht -Name[sr]=ОријÑки -Name[sr@Latn]=Orijski -Name[ss]=Si-Oriya -Name[ta]=ஒரியா -Name[te]=ఒరియా -Name[tg]=Ориёӣ -Name[th]=ภาษาโอริยา -Name[uk]=ÐžÑ€Ñ–Ñ -Name[uz@cyrillic]=ÐžÑ€Ð¸Ñ -Name[vi]=Ô-ri-yạ -Name[zh_CN]=欧里亚语 -Name[zh_HK]=Oriya語 -Name[zh_TW]=Oriya語 -Name[zu]=Isi-Oriya -[os] -Name=Ossetian -Name[ar]=الأوسيتية -Name[az]=Osetiyaca -Name[be]=ÐÑетынÑÐºÐ°Ñ -Name[bg]=ОÑетинÑки -Name[bn]=ওসেটিয়ান -Name[br]=Ossetieg -Name[bs]=Osetski -Name[ca]=Oseti -Name[cs]=Osetský -Name[csb]=Ã’setaÅ„sczi -Name[cy]=Oseteg -Name[de]=Ossetisch -Name[eo]=Oseta -Name[es]=Osetio -Name[et]=Osseedi -Name[eu]=Osetiera -Name[fa]=اوستی Ù‚Ùقاز -Name[fi]=Osseetti -Name[fr]=Ossète -Name[fy]=Ossetysk -Name[ga]=Óiséitis -Name[gl]=Oseto -Name[he]=×וסטית -Name[hi]=ओसेटियन -Name[hr]=Osetski -Name[hsb]=Osetisce -Name[hu]=Oszét -Name[it]=Ossetiano -Name[ja]=オセット語 -Name[ka]=áƒáƒ¡áƒ£áƒ áƒ˜ -Name[kk]=ОÑетинше -Name[km]=អូសសិážáŸ’យុង -Name[ko]=오세티안어 -Name[lb]=Ossetesch -Name[lt]=Osetinų -Name[lv]=Osetīņu -Name[mk]=ОÑетиÑки -Name[mn]=ОÑÑетан -Name[nb]=Ossetisk -Name[nds]=Osseetsch -Name[ne]=ओसेसियन -Name[nl]=Ossetisch -Name[nn]=Ossetisk -Name[nso]=Se-Ossetian -Name[pa]=ਓਸੀਟੀਅਨ -Name[pl]=OsetaÅ„ski -Name[pt]=Osseta -Name[ro]=Osetiană -Name[ru]=ОÑетинÑкий -Name[rw]=Icyosetiyani -Name[se]=Ossetiagiella -Name[sk]=osetÄina -Name[sl]=osetijsko -Name[sq]=Osetianisht -Name[sr]=ОÑетÑки -Name[sr@Latn]=Osetski -Name[ss]=Si-Ossetian -Name[sv]=Ossetsiska -Name[ta]=ஒசெடà¯à®Ÿà®¿à®¯à®©à¯ -Name[te]=à°’à°¸à±à°¸à±†à°·à°¿à°¯à°¨à± -Name[tg]=ОÑетинӣ -Name[th]=ภาษาโอซิเชียน -Name[tt]=Ossetinçä -Name[uk]=ОÑетинÑька -Name[uz]=Ossetincha -Name[uz@cyrillic]=ОÑÑетинча -Name[vi]=Óc-xe-ti-an -Name[wa]=Ossete -Name[zh_CN]=奥塞梯语 -Name[zh_HK]=Ossetian語 -Name[zh_TW]=Ossetian語 -Name[zu]=Isi-Ossethiyani -[pa] -Name=Panjabi -Name[ar]=بنجابي -Name[az]=PanjabicÉ™ -Name[be]=Панджабі -Name[bg]=Панджаби -Name[bn]=পাঞà§à¦œà¦¾à¦¬à§€ -Name[br]=Pendjabieg -Name[cs]=Pandžábský -Name[csb]=Pendżabsczi -Name[de]=Pandschabi -Name[eo]=PanÄaba -Name[es]=Punjabí -Name[et]=Pandžabi -Name[eu]=Punjabera -Name[fa]=پنجابی -Name[fi]=Pandžabi -Name[fr]=Pendjabi -Name[ga]=Painseáibis -Name[gl]=Panxabi -Name[he]=פנג'בית -Name[hi]=पंजाबी -Name[hr]=Pandžabski -Name[hsb]=Pandźabisce -Name[hu]=Pandzsabi -Name[it]=Punjabi -Name[ja]=ãƒãƒ³ã‚¸ãƒ£ãƒ¼ãƒ–語 -Name[ka]=პენჯáƒáƒ‘ი -Name[kk]=Панждаби -Name[km]=ពូនយ៉ាប៊ី -Name[ko]=펀잡어 -Name[ku]=Pêncabî -Name[lb]=Panjabi-Sprooch -Name[lt]=Pendžabo -Name[lv]=Pandžabu -Name[mk]=Пунџаби -Name[mn]=Панжаби -Name[nds]=Pandschaabsch -Name[ne]=पनà¥à¤œà¤¾à¤¬à¥€ -Name[nso]=Se-Panjabi -Name[pa]=ਪੰਜਾਬੀ -Name[pl]=Pendżabski -Name[ro]=Panjabă -Name[ru]=Панджаби -Name[rw]=Igipanjabi -Name[se]=Panjabigiella -Name[sk]=pandžábÄina -Name[sl]=pandžabsko -Name[sq]=Panjabisht -Name[sr]=ПенџабÑки -Name[sr@Latn]=Pendžabski -Name[ss]=Si-Panjabi -Name[ta]=பஞà¯à®šà®¾à®ªà®¿ -Name[te]=పంజాబి -Name[tg]=Панҷабӣ -Name[th]=ภาษาปัà¸à¸ˆà¸²à¸šà¸µ -Name[tt]=Panjabça -Name[uk]=ПанджабÑька -Name[uz]=Panjabcha -Name[uz@cyrillic]=Панжабча -Name[vi]=Pan-gia-bi -Name[wa]=Pundjabi -Name[zh_CN]=æ—é®æ™®è¯­ -Name[zh_HK]=Panjabi語 -Name[zh_TW]=Panjabi語 -Name[zu]=Isi-Phanjabi -[pi] -Name=Pali -Name[ar]=البالي -Name[az]=PalicÉ™ -Name[be]=Палі -Name[bg]=Пали -Name[bn]=পালি -Name[br]=Palieg -Name[eo]=Palio -Name[es]=Palí -Name[et]=Paali -Name[fa]=پالی -Name[ga]=Páilis -Name[he]=פ×לי -Name[hi]=पाली -Name[ja]=パーリ語 -Name[ka]=ფáƒáƒšáƒáƒ£áƒ áƒ˜ -Name[kk]=Пали -Name[km]=បាលី -Name[mk]=Пали -Name[mn]=Пали -Name[ne]=पाली -Name[nso]=Se-Pali -Name[pa]=ਪਾਲੀ -Name[ru]=Пали -Name[rw]=Igipali -Name[se]=Páligiella -Name[sk]=pálí -Name[sl]=pali -Name[sq]=Palisht -Name[sr]=ПалијÑки -Name[sr@Latn]=Palijski -Name[ss]=Si-Pali -Name[ta]=பாலி -Name[te]=పాళి -Name[tg]=Пали -Name[th]=ภาษาบาลี -Name[tt]=Paliçä -Name[uk]=Палі -Name[uz@cyrillic]=Пали -Name[vi]=Pa-li -Name[wa]=Pâli -Name[zh_CN]=巴利语 -Name[zh_HK]=巴利語 -Name[zh_TW]=巴利語 -Name[zu]=Isi-Phali -[pl] -Name=Polish -Name[af]=Poolse -Name[ar]=البولندية -Name[az]=Polyakca -Name[be]=ПольÑÐºÐ°Ñ -Name[bg]=ПолÑки -Name[bn]=পোলিশ -Name[br]=Poloneg -Name[bs]=Poljski -Name[ca]=Polonès -Name[cs]=Polský -Name[csb]=Pòlsczi -Name[cy]=Pwyleg -Name[da]=Polsk -Name[de]=Polnisch -Name[el]=Πολωνικά -Name[eo]=Pola -Name[es]=Polaco -Name[et]=Poola -Name[eu]=Poloniera -Name[fa]=لهستانی -Name[fi]=Puola -Name[fr]=Polonais -Name[fy]=Poalsk -Name[ga]=Polainnis -Name[gl]=Polaco -Name[he]=פולנית -Name[hi]=पोलिश -Name[hr]=Poljski -Name[hsb]=Pólsce -Name[hu]=Lengyel -Name[id]=Polandia -Name[is]=Pólska -Name[it]=Polacco -Name[ja]=ãƒãƒ¼ãƒ©ãƒ³ãƒ‰èªž -Name[ka]=პáƒáƒšáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=ПолÑкша -Name[km]=ប៉ូឡូញ -Name[ko]=í´ëž€ë“œì–´ -Name[ku]=Polî -Name[lb]=Polnesch -Name[lt]=Lenkų -Name[lv]=Poļu -Name[mi]=Reo Pörana -Name[mk]=ПолÑки -Name[mn]=Польш -Name[mt]=Pollakk -Name[nb]=Polsk -Name[nds]=Poolsch -Name[ne]=पोलीश -Name[nl]=Pools -Name[nn]=Polsk -Name[nso]=Se-Polish -Name[oc]=Pòlònès -Name[pa]=ਪੋਲੈਂਡੀ -Name[pl]=Polski -Name[pt]=Polaco -Name[pt_BR]=Polonês -Name[ro]=Poloneză -Name[ru]=ПольÑкий -Name[rw]=Ikinyapolonye -Name[se]=Polskkagiella -Name[sk]=poľština -Name[sl]=poljsko -Name[sq]=Polonisht -Name[sr]=ПољÑки -Name[sr@Latn]=Poljski -Name[ss]=Si-Polish -Name[sv]=Polska -Name[ta]=போலிஷ௠-Name[te]=పోలిషౠ-Name[tg]=ПолÑкӣ -Name[th]=ภาษาโปลิช -Name[tr]=Lehçe -Name[tt]=Polça -Name[uk]=ПольÑька -Name[uz]=Polyakcha -Name[uz@cyrillic]=ПолÑкча -Name[vi]=Ba-lan -Name[wa]=Polonès -Name[zh_CN]=波兰语 -Name[zh_HK]=波蘭語 -Name[zh_TW]=波蘭語 -Name[zu]=Isi-Pholishi -[ps] -Name=Pushto -Name[ar]=باشتو -Name[az]=PuÅŸtoca -Name[be]=Пушту -Name[bg]=Пущу -Name[bn]=পà§à¦¸à§à¦¤ -Name[ca]=Pashto -Name[de]=Paschtu -Name[eo]=PaÅtua -Name[es]=Pastún -Name[et]=PuÅ¡tu -Name[eu]=Paxtuera -Name[fa]=پشتو -Name[fi]=PaÅ¡tu -Name[ga]=Paistis -Name[he]=פשטו -Name[hi]=पशà¥à¤¤à¥‹ -Name[hsb]=PuÅ¡to -Name[hu]=Pusto -Name[it]=Pashto -Name[ja]=パシュトー語 -Name[ka]=პუშტუ -Name[kk]=Пушту -Name[km]=ប៉ាសážáž¼ -Name[ko]=푸시토어 -Name[lb]=Paschtu -Name[lt]=PuÅ¡tÅ«nų -Name[lv]=PuÅ¡tu -Name[mk]=Пушто -Name[mn]=Пушто -Name[nds]=Paschtuunsch -Name[ne]=पà¥à¤¸à¥à¤¤à¥‹ -Name[nso]=Se-Pushto -Name[pa]=ਪà©à¨¶à¨¤à©‹ -Name[ro]=PuÅŸtă -Name[ru]=ПуштунÑкий -Name[rw]=Igipushito -Name[se]=PuÅ¡tugiella -Name[sk]=paÅ¡tÄina -Name[sl]=pushto -Name[sq]=Pushtisht -Name[sr]=Пушто -Name[sr@Latn]=PuÅ¡to -Name[ss]=Si-Pushto -Name[sv]=Pashto -Name[ta]=பாஷà¯à®Ÿà¯à®©à¯ -Name[te]=à°ªà±à°·à±à°¤à±Š -Name[tg]=Пушто -Name[th]=ภาษาพาชโต -Name[tt]=PuÅŸtu Farsíçası -Name[uk]=ПуштунÑька -Name[uz]=Pushtuncha -Name[uz@cyrillic]=Пуштунча -Name[vi]=Pu-x-tô -Name[wa]=Pashto -Name[zh_CN]=普什图语 -Name[zh_HK]=普什圖語 -Name[zh_TW]=普什圖語 -Name[zu]=Dudula ku -[pt] -Name=Portuguese -Name[af]=Portugese -Name[ar]=البرتغالية -Name[az]=Portuqalca -Name[be]=ПартугальÑÐºÐ°Ñ -Name[bg]=ПортугалÑки -Name[bn]=পরà§à¦¤à§à¦—ীজ -Name[br]=Portugaleg -Name[bs]=Portugalski -Name[ca]=Portuguès -Name[cs]=Portugalský -Name[csb]=Pòrtugalsczi -Name[cy]=Portiwgaleg -Name[da]=Portugisisk -Name[de]=Portugiesisch -Name[el]=ΠοÏτογαλικά -Name[eo]=Portugala -Name[es]=Portugués -Name[et]=Portugali -Name[eu]=Portugesa -Name[fa]=پرتغالی -Name[fi]=Portugali -Name[fr]=Portugais -Name[fy]=Portugeesk -Name[ga]=Portaingéilis -Name[gl]=Portugués -Name[he]=פורטוגזית -Name[hi]=पोरà¥à¤¤à¥à¤—ीस -Name[hr]=Portugalski -Name[hsb]=Portugalsce -Name[hu]=Portugál -Name[id]=Portugis -Name[is]=Portúgalska -Name[it]=Portoghese -Name[ja]=ãƒãƒ«ãƒˆã‚¬ãƒ«èªž -Name[ka]=პáƒáƒ áƒ¢áƒ£áƒ’áƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Португалша -Name[km]=áž–áŸážšáž‘ុយហ្គាល់ -Name[ko]=í¬ë¥´íˆ¬ê°ˆì–´ -Name[ku]=Portûgalî -Name[lb]=Portugisesch -Name[lt]=Portugalų -Name[lv]=PortugÄļu -Name[mi]=Reo Pötikï -Name[mk]=ПортугалÑки -Name[mn]=Португал -Name[ms]=Portugis -Name[mt]=Portugiż -Name[nb]=Portugisisk -Name[nds]=Portugeesch -Name[ne]=पोरà¥à¤šà¥à¤—ाली -Name[nl]=Portugees -Name[nn]=Portugisisk -Name[nso]=Sepotokisi -Name[oc]=Pòrtuguès -Name[pa]=ਪà©à¨°à¨¤à¨—ਾਲੀ -Name[pl]=Portugalski -Name[pt]=Português -Name[pt_BR]=Português -Name[ro]=Portugheză -Name[ru]=ПортугальÑкий -Name[rw]=Igiporutigali -Name[se]=Portugálagiella -Name[sk]=portugalÄina -Name[sl]=portugalsko -Name[sq]=Portugalisht -Name[sr]=ПортугалÑки -Name[sr@Latn]=Portugalski -Name[ss]=SiPutukezi -Name[sv]=Portugisiska -Name[ta]=போரà¯à®¤à¯à®¤à¯à®•à¯à®•à¯€à®šà®¿à®¯ -Name[te]=పోరà±à°Ÿà±à°¯à±à°—ీసౠ-Name[tg]=Португалӣ -Name[th]=ภาษาโปรตุเà¸à¸ª -Name[tr]=Portekizce -Name[tt]=Portugalça -Name[uk]=ПортугальÑька -Name[uz]=Portugalcha -Name[uz@cyrillic]=Португалча -Name[vi]=Bồ-đào-nha -Name[wa]=Portuguès -Name[zh_CN]=è‘¡è„牙语 -Name[zh_HK]=è‘¡è„牙語 -Name[zh_TW]=è‘¡è„牙語 -Name[zu]=Isi-Phuthukesi -[pt_BR] -Name=Brazilian Portuguese -Name[ar]=البرتغالية البرازيلية -Name[az]=Braziliya Portuqalcası -Name[be]=ПартугальÑÐºÐ°Ñ Ð±Ñ€Ð°Ð·Ñ–Ð»ÑŒÑÐºÐ°Ñ -Name[bg]=БразилÑки португалÑки -Name[bn]=বà§à¦°à¦¾à¦œà¦¿à¦²à§€à§Ÿ পরà§à¦¤à§à¦—ীজ -Name[br]=Portugaleg Brazil -Name[bs]=Brazilski portugalski -Name[ca]=Brasiler Portuguès -Name[cs]=Portugalský (Brazílie) -Name[csb]=Brazylsczi pòrtugalsczi -Name[cy]=Portiwgaleg Brasil -Name[da]=Brasiliansk portugisisk -Name[de]=Brasilianisches Portugiesisch -Name[el]=ΠοÏτογαλικά Î’Ïαζιλίας -Name[eo]=Portugala (Brazilo) -Name[es]=Portugués brasileño -Name[et]=Brasiilia portugali -Name[eu]=Portugesa (Brasilgoa) -Name[fa]=پرتغالی برزیلی -Name[fi]=Brasilian Portugali -Name[fr]=Portugais Brésilien -Name[fy]=Braziliaansk Portugeesk -Name[ga]=Portaingéilis na Brasaíle -Name[gl]=Portugués Do Brasil -Name[he]=פורטוגזית ברזיל×ית -Name[hi]=बà¥à¤°à¤¾à¤œà¤¿à¤²à¤¿à¤¯à¤¨ पà¥à¤°à¥à¤¤à¤—ाली -Name[hr]=Brazilski portugalski -Name[hsb]=Portugalsce (Brazilska) -Name[hu]=Portugál (brazil) -Name[id]=Portugis Brazil -Name[is]=Brasílísk Portúgalska -Name[it]=Portoghese brasiliano -Name[ja]=ブラジル ãƒãƒ«ãƒˆã‚¬ãƒ«èªž -Name[ka]=ბრáƒáƒ–ილიური (პáƒáƒ áƒ¢áƒ£áƒ’áƒáƒšáƒ£áƒ áƒ˜) -Name[kk]=БразилиÑлық португалша -Name[km]=ប្រáŸážŸáŸŠáž¸áž› áž–áŸážšáž‘ុយហ្គាល់ -Name[ko]=브ë¼ì§ˆì‹ í¬ë¥´íˆ¬ê°ˆì–´ -Name[ku]=Portûgalî ya Brazîl -Name[lb]=Brazilianescht Portugisesch -Name[lt]=Brazilijos portugalų -Name[lv]=BrazÄ«lijas portugÄļu -Name[mk]=БразилÑки португалÑки -Name[mn]=Бразилын португал -Name[ms]=Portugis Brazil -Name[nb]=Brasil-portugisisk -Name[nds]=Brasiliaansch Portugeesch -Name[ne]=बà¥à¤°à¤¾à¤œà¤¿à¤²à¥€ पोरà¥à¤šà¥à¤—ाली -Name[nl]=Braziliaans Portugees -Name[nn]=Brasil-portugisisk -Name[pa]=ਬਰਾਜ਼ੀਲ ਪà©à¨°à¨¤à¨—ਾਲੀ -Name[pl]=Portugalski (brazylijski) -Name[pt]=Português do Brasil -Name[pt_BR]=Português do Brasil -Name[ro]=Portugheză braziliană -Name[ru]=ПортугальÑкий (БразилиÑ) -Name[rw]=Igiporutigali cya Burezile -Name[se]=BrasilialaÅ¡ portugálagiella -Name[sk]=portugalÄina (Brazília) -Name[sl]=brazilska portugalÅ¡Äina -Name[sq]=Portugalishte Braziliane -Name[sr]=БразилÑко португалÑки -Name[sr@Latn]=Brazilsko portugalski -Name[sv]=Brasiliansk portugisiska -Name[ta]=பிரேஸிலிய போரà¯à®¤à¯à®¤à¯à®•à¯à®•à¯€à®šà®¿à®¯ -Name[te]=à°¬à±à°°à°¾à°œà°¿à°²à°¿à°¯à°¨à± పోరà±à°Ÿà±à°¯à±à°—ీసౠ-Name[tg]=БразилиÑÓ£ Португалӣ -Name[th]=ภาษาโปรตุเà¸à¸ªà¸šà¸£à¸²à¸‹à¸´à¸¥ -Name[tr]=Brezilya Portekizcesi -Name[tt]=Portugalça, Brasil -Name[uk]=БразильÑька португальÑька -Name[uz]=Portugalcha (Braziliya) -Name[uz@cyrillic]=Португалча (БразилиÑ) -Name[vi]=Bồ-đào-nha (Bra-xin) -Name[wa]=Portuguès do Braezi -Name[zh_CN]=巴西葡è„牙语 -Name[zh_HK]=巴西葡è„牙語 -Name[zh_TW]=巴西葡è„牙語 -[qu] -Name=Quechua -Name[ar]=الكويتشيوا -Name[az]=KveçcÉ™ -Name[be]=КÑчуа -Name[bg]=Кечуа -Name[bn]=কেচà§à§Ÿà¦¾ -Name[br]=Kechuaeg -Name[eo]=Keĉua -Name[et]=KetÅ¡ua -Name[eu]=Kitxua -Name[fa]=کوچوا -Name[fi]=KetÅ¡ua -Name[ga]=Ceatsuais -Name[he]=קצ'ו××” -Name[hi]=कà¥à¤µà¥‡à¤šà¥à¤† -Name[hu]=Kecsua -Name[ja]=ケãƒãƒ¥ã‚¢èªž -Name[ka]=კეჩურ-Name[kk]=Кечуа -Name[km]=កáŸáž‘្ជូអា -Name[ko]=케추아어 -Name[lb]=Quechua-Sprooch -Name[mk]=Кечуа -Name[mn]=Куечуа -Name[nds]=Ketschua -Name[ne]=कà¥à¤µà¥‡à¤šà¤‰ -Name[nso]=Se-Quechua -Name[pa]=ਕਿਉਚà©à¨† -Name[ru]=Кечуа -Name[rw]=Igikwecuwa -Name[se]=KeÄÄuagiella -Name[sk]=keÄuánÄina -Name[sl]=quechua -Name[sq]=Keçisht -Name[sr]=Квечва -Name[sr@Latn]=KveÄva -Name[ss]=Si-Quechua -Name[ta]=கà¯à®µà¯†à®šà¯à®šà®¾ -Name[te]=à°•à±à°µà±†à°šà±à°µà°¾ -Name[tg]=Квечуа -Name[th]=ภาษาเคชัว -Name[tt]=Queçuaça -Name[uk]=Кечуа -Name[uz]=Kvechua -Name[uz@cyrillic]=Квечуа -Name[vi]=Quê-chua -Name[wa]=Kitchwa -Name[zh_CN]=盖丘亚语 -Name[zh_HK]=蓋楚瓦語 -Name[zh_TW]=蓋楚瓦語 -Name[zu]=Isi-Quechua -[rn] -Name=Rundi -Name[ar]=رواندي -Name[az]=RundicÉ™ -Name[be]=Рундзі -Name[bg]=Руанда -Name[bn]=রà§à¦£à§à¦¡à¦¿ -Name[cy]=Rwndi -Name[eo]=Ruanda -Name[fa]=روندی -Name[fy]=Rûandeesk -Name[he]=רונדי -Name[hi]=रूनà¥à¤¡à¥€ -Name[ja]=ルンディ語 -Name[ka]=რუნდი -Name[kk]=Рунди -Name[km]=រូន្ឌី -Name[ko]=룬디어 -Name[lb]=Rundi-Sprooch -Name[mk]=Рунди -Name[mn]=Рунди -Name[ne]=रूनà¥à¤¡à¥€ -Name[nso]=Se-Rundi -Name[pa]=ਰੂਡੀ -Name[ru]=Рунди -Name[rw]=Ikirundi -Name[se]=Rundigiella -Name[sk]=rundÄina -Name[sl]=rundi -Name[sq]=Rundisht -Name[sr]=Рунди -Name[ss]=Si-Rundi -Name[ta]=à®°à¯à®£à¯à®Ÿà®¿ -Name[te]=à°°à±à°‚à°¡à°¿ -Name[tg]=Рунди -Name[th]=ภาษารุนดิ -Name[tt]=Rundiçä -Name[uk]=Рунді -Name[uz@cyrillic]=Рунди -Name[vi]=Run-Ä‘i -Name[wa]=Kirundi -Name[zh_CN]=基隆迪语 -Name[zh_HK]=Rundi語 -Name[zh_TW]=Rundi語 -Name[zu]=Isi-Rundi -[ro] -Name=Romanian -Name[af]=Romeens -Name[ar]=الرومانية -Name[az]=Rumınca -Name[be]=РумынÑÐºÐ°Ñ -Name[bg]=РумънÑки -Name[bn]=রোমানীয় -Name[br]=Roumaneg -Name[bs]=Rumunski -Name[ca]=Romanès -Name[cs]=Rumunský -Name[csb]=Rumùńsczi -Name[cy]=Romaneg -Name[da]=Rumænsk -Name[de]=Rumänisch -Name[el]=Ρουμανικά -Name[eo]=Rumana -Name[es]=Rumano -Name[et]=Rumeenia -Name[eu]=Errumaniera -Name[fa]=رومانیایی -Name[fi]=Romania -Name[fr]=Roumain -Name[fy]=Roemeensk -Name[ga]=Rómáinis -Name[gl]=Romanés -Name[he]=רומנית -Name[hi]=रोमानियन -Name[hr]=Rumunjski -Name[hsb]=Rumunsce -Name[hu]=Román -Name[id]=Rumania -Name[is]=Rúmenska -Name[it]=Rumeno -Name[ja]=ルーマニア語 -Name[ka]=რუმინული -Name[kk]=Румынша -Name[km]=រូម៉ានី -Name[ko]=루마니아어 -Name[ku]=Romanî -Name[lb]=Rumänesch -Name[lt]=Rumunų -Name[lv]=RumÄņu -Name[mi]=Reo Romeinia -Name[mk]=РоманÑки -Name[mn]=Роман -Name[ms]=Romania -Name[mt]=Rumen -Name[nb]=Rumensk -Name[nds]=Rumäänsch -Name[ne]=रोमनियाली -Name[nl]=Roemeens -Name[nn]=Rumensk -Name[nso]=Se-Romanian -Name[pa]=ਰੋਮਾਨੀਆਈ -Name[pl]=RumuÅ„ski -Name[pt]=Romeno -Name[pt_BR]=Romeno -Name[ro]=Română -Name[ru]=РумынÑкий -Name[rw]=Ikinyarumaniya -Name[se]=Romániagiella -Name[sk]=rumunÄina -Name[sl]=romunsko -Name[sq]=Rumanisht -Name[sr]=РумунÑки -Name[sr@Latn]=Rumunski -Name[ss]=SiRoma -Name[sv]=Rumänska -Name[ta]=உரà¯à®®à¯‡à®©à®¿à®¯à®©à¯ -Name[te]=రొమేనియనౠ-Name[tg]=Романӣ -Name[th]=ภาษาโรมาเนีย -Name[tr]=Romence -Name[tt]=Romança -Name[uk]=РумунÑька -Name[uz]=Rumincha -Name[uz@cyrillic]=Руминча -Name[vi]=Rô-ma-ni-a -Name[wa]=Roumin -Name[zh_CN]=罗马尼亚语 -Name[zh_HK]=羅馬尼亞語 -Name[zh_TW]=羅馬尼亞語 -Name[zu]=Isi-Romania -[rom] -Name=Romany -Name[be]=РаманÑÐºÐ°Ñ -Name[bg]=РомÑки -Name[br]=Jipsianek -Name[bs]=Romanski -Name[ca]=Caló -Name[cs]=Romský -Name[csb]=Rumùńsczi -Name[de]=Romani -Name[el]=Ρουμανία -Name[eo]=Romaa -Name[es]=Rumaní -Name[et]=Mustlaskeel -Name[eu]=Errumaniera -Name[fa]=رومانی -Name[fi]=Romani -Name[fr]=Rromani -Name[ga]=Romainis -Name[gl]=Romanés -Name[he]=רומניה -Name[hr]=Romanski -Name[hu]=Lovári cigány -Name[is]=Rúmenía -Name[it]=Rom -Name[ja]=ロマニー語 -Name[ka]=რáƒáƒ›áƒáƒœáƒ£áƒšáƒ˜ -Name[kk]=Цыганша -Name[km]=រូម៉ានី -Name[lb]=Romani -Name[mk]=РомÑки -Name[ms]=Romania -Name[nb]=Romani -Name[nds]=Romaneesch -Name[ne]=रोमानी -Name[nl]=Roma -Name[nn]=Romani -Name[pa]=ਰੋਮੇ -Name[pl]=Romski -Name[pt]=Romani -Name[pt_BR]=Romani -Name[ro]=Å¢igănească -Name[ru]=ЦыганÑкий -Name[se]=Románigiella -Name[sk]=rómÄina -Name[sl]=romsko -Name[sr]=РомÑки -Name[sr@Latn]=Romski -Name[sv]=Romanés -Name[te]=రొమని -Name[tg]=Романӣ -Name[th]=ภาษาโรมานี -Name[tr]=Çingene Dili -Name[uk]=ЦиганÑька -Name[vi]=Rô-ma-ny -Name[zh_CN]=å‰æ™®èµ›è¯­ -Name[zh_TW]=å‰æ™®è³½èªž -[ru] -Name=Russian -Name[af]=Russies -Name[ar]=الروسية -Name[az]=Rusca -Name[be]=РаÑійÑÐºÐ°Ñ -Name[bg]=РуÑки -Name[bn]=রà§à¦¶ -Name[br]=Rusianeg -Name[bs]=Ruski -Name[ca]=Rus -Name[cs]=Ruský -Name[csb]=Rusczi -Name[cy]=Rwsieg -Name[da]=Russisk -Name[de]=Russisch -Name[el]=Ρωσικά -Name[eo]=Rusa -Name[es]=Ruso -Name[et]=Vene -Name[eu]=Errusiera -Name[fa]=روسی -Name[fi]=Venäjä -Name[fr]=Russe -Name[fy]=Russysk -Name[ga]=Rúisis -Name[gl]=Ruso -Name[he]=רוסית -Name[hi]=रशियन -Name[hr]=Ruski -Name[hsb]=Rusce -Name[hu]=Orosz -Name[id]=Rusia -Name[is]=Rússneska -Name[it]=Russo -Name[ja]=ロシア語 -Name[ka]=რუსული -Name[kk]=ОрыÑша -Name[km]=រុស្សី -Name[ko]=러시아어 -Name[ku]=Rûsî -Name[lb]=Russesch -Name[lt]=Rusų -Name[lv]=Krievu -Name[mi]=Reo Ruhia -Name[mk]=РуÑки -Name[mn]=ÐžÑ€Ð¾Ñ -Name[ms]=Russia -Name[mt]=Russu -Name[nb]=Russisk -Name[nds]=Russ'sch -Name[ne]=रसियाली -Name[nl]=Russisch -Name[nn]=Russisk -Name[nso]=Se-Russian -Name[oc]=Rus -Name[pa]=ਰੂਸੀ -Name[pl]=Rosyjski -Name[pt]=Russo -Name[pt_BR]=Russo -Name[ro]=Rusă -Name[ru]=РуÑÑкий -Name[rw]=Ikirusiya -Name[se]=RuoÅ¡Å¡agiella -Name[sk]=ruÅ¡tina -Name[sl]=rusko -Name[sq]=Rusisht -Name[sr]=РуÑки -Name[sr@Latn]=Ruski -Name[ss]=SiRashiya -Name[sv]=Ryska -Name[ta]=இரஷியன௠-Name[te]=రషియనౠ-Name[tg]=РӯÑÓ£ -Name[th]=ภาษารัสเซีย -Name[tr]=Rusça -Name[tt]=Urısça -Name[uk]=РоÑійÑька -Name[uz]=Ruscha -Name[uz@cyrillic]=РуÑча -Name[vi]=Nga -Name[wa]=Rûsse -Name[xh]=Isirashiya -Name[zh_CN]=俄语 -Name[zh_HK]=俄語 -Name[zh_TW]=俄語 -Name[zu]=Isi-Rashiya -[rw] -Name=Kinyarwanda -Name[ar]=الكينارواندا -Name[az]=Kinyarvandaca -Name[be]=КіньÑрванда -Name[bg]=КиниÑруанда -Name[bn]=কিনà§à¦¯à¦¾à¦°à¦“য়াণà§à¦¡à¦¾ -Name[et]=Ruanda -Name[eu]=Kinyaruanda -Name[fa]=کینیارواندایی -Name[fi]=Ruanda -Name[ga]=Cinearuáindis -Name[gl]=Quiñaruanda -Name[he]=קיניירו×נדה -Name[hi]=किनà¥à¤¯à¤¾à¤°à¤µà¤¾à¤¨à¥à¤¡à¤¾ -Name[hr]=Kinidžaruandski -Name[hu]=Kinjarvanda -Name[ja]=ルワンダ語 -Name[ka]=კინიáƒáƒ áƒ•áƒáƒœáƒ“რ-Name[kk]=КиньÑруанда -Name[km]=គីនយ៉ាវ៉ាន់ដា -Name[ko]=키ëƒë¥´ì™„다어 -Name[lb]=Ruanda-Sprooch -Name[mk]=Кинјарванда -Name[mn]=КинÑрванда -Name[ne]=किनà¥à¤¯à¤°à¤µà¤¾à¤¨à¥à¤¡à¤¾ -Name[nso]=Se-Kinyarwanda -Name[pa]=ਕਿਨਯਾਰਵਾਡਾਂ -Name[ro]=Chiniaruandeză -Name[ru]=КиньÑруанда -Name[rw]=Ikinyarwanda -Name[se]=Kinyarwandagiella -Name[sk]=rwandÄina -Name[sl]=kinyarwanda -Name[sq]=Kinjaruandaisht -Name[sr]=КинијарвандаÑки -Name[sr@Latn]=Kinijarvandaski -Name[ss]=Si-Kinyarwanda -Name[sv]=Rwanda -Name[ta]=கினà¯à®¯à®¾à®°à¯à®µà®¾à®£à¯à®Ÿà®¾ -Name[te]=à°•à°¿à°¨à±à°¨à±à°¯à°¾à°°à±à°µà°¾à°‚à°¡à°¾ -Name[tg]=Кинуарвандӣ -Name[th]=ภาษาคินยาร์วันดา -Name[tt]=Kinyarwandaça -Name[uk]=КіньÑрванда -Name[uz]=Kinyarvanda -Name[uz@cyrillic]=КинÑрванда -Name[vi]=Ki-nyă-ouanh-Ä‘a -Name[wa]=Kiniarwanda -Name[zh_CN]=å¢æ—ºè¾¾è¯­ -Name[zh_HK]=Kinyarwanda語 -Name[zh_TW]=Kinyarwanda語 -Name[zu]=Isi-Kinyarwanda -[sa] -Name=Sanskrit -Name[ar]=سنسيكريتي -Name[az]=SanskritcÉ™ -Name[be]=СанÑкрыт -Name[bg]=СанÑкрит -Name[bn]=সংসà§à¦•à§ƒà¦¤ -Name[cy]=Sansgrit -Name[el]=ΣανσκÏιτικά -Name[eo]=Sanskrito -Name[es]=Sanscrito -Name[et]=Sanskriti -Name[eu]=Sanskritoa -Name[fa]=سانسکریت -Name[fy]=Sanskryt -Name[ga]=Sanscrait -Name[gl]=Sánscrito -Name[he]=סנסקריט -Name[hi]=संसà¥à¤•à¥ƒà¤¤ -Name[hu]=Szanszkrit -Name[id]=Sansekerta -Name[is]=Sanskrít -Name[it]=Sanscrito -Name[ja]=サンスクリット語 -Name[ka]=სáƒáƒœáƒ¡áƒ™áƒ áƒ˜áƒ¢áƒ˜ -Name[kk]=СанÑкрит -Name[km]=សំស្ក្រឹហ-Name[ko]=범어 -Name[lt]=Sanskritas -Name[lv]=Sanskrits -Name[mk]=СанÑкрит -Name[mn]=СанÑкрит -Name[ne]=संसà¥à¤•à¥ƒà¤¤ -Name[nso]=Se-Sanskrit -Name[pa]=ਸੰਸਕà©à¨°à¨¿à¨¤ -Name[pl]=Sanskryt -Name[pt]=Sanscrito -Name[ro]=Sanscrită -Name[ru]=СанÑкрит -Name[rw]=Igisansikiriti -Name[se]=Sanskrihtagiella -Name[sk]=sanskrit -Name[sl]=sanskrt -Name[sq]=Sanskritisht -Name[sr]=СанÑкрит -Name[ss]=Si-Sanskrit -Name[ta]=சமஸà¯à®•à®¿à®°à¯à®¤à®®à¯ -Name[te]=సంసà±à°•à±à°°à±à°¤à°‚ -Name[tg]=СанÑкрит -Name[th]=ภาษาสันสà¸à¸¤à¸• -Name[tt]=Sanskritçä -Name[uk]=СанÑкрит -Name[uz@cyrillic]=СанÑкрит -Name[vi]=Xan-s-cợ-ríth -Name[zh_CN]=梵语 -Name[zh_HK]=梵語 -Name[zh_TW]=梵語 -Name[zu]=Isi-Sanskrit -[sc] -Name=Sardinian -Name[ar]=الساردينية -Name[be]=СардынÑÐºÐ°Ñ -Name[bg]=СардинÑки -Name[bn]=সারà§à¦¡à¦¿à¦¨à¦¿à§Ÿà¦¾à¦¨ -Name[br]=Sardinieg -Name[bs]=Sardinijski -Name[ca]=Sard -Name[cs]=Sardinský -Name[csb]=SardiÅ„sczi -Name[cy]=Sardinieg -Name[da]=Sardinsk -Name[de]=Sardisch -Name[el]=ΣαÏδηνιακά -Name[eo]=Sarda -Name[es]=Sardo -Name[et]=Sardiinia -Name[eu]=Sardiera -Name[fa]=ساردینی -Name[fi]=Sardi -Name[fr]=Sarde -Name[fy]=Sardinysk -Name[ga]=Sairdínis -Name[gl]=Sardo -Name[he]=סרדינית -Name[hi]=सारदिनी -Name[hr]=Sardinijski -Name[hsb]=Sardinsce -Name[hu]=Szardíniai -Name[is]=Sardíníska -Name[it]=Sardo -Name[ja]=サルデーニャ語 -Name[ka]=სáƒáƒ áƒ“ინიული -Name[kk]=Сардинше -Name[km]=សារឌីណង់ -Name[ko]=사르디니아어 -Name[lb]=Sardinesch -Name[lt]=Sardinijos -Name[lv]=SardÄ«nieÅ¡u -Name[mk]=СардиниÑки -Name[mn]=Сардин -Name[nb]=Sardisk -Name[nds]=Sardiensch -Name[ne]=सरà¥à¤¦à¤¿à¤¨à¤¿à¤¯à¤¨ -Name[nl]=Sardinisch -Name[nn]=Sardiniansk -Name[nso]=Se-Sardinian -Name[pa]=ਸਾਰਡੀਨੀਆਨ -Name[pl]=SardyÅ„ski -Name[pt]=Sardenho -Name[ro]=Sardiniană -Name[ru]=СардинийÑкий -Name[rw]=Ikinyasaridini -Name[se]=Sardiniagiella -Name[sk]=sardínÄina -Name[sl]=sardinsko -Name[sq]=Sardinisht -Name[sr]=СардинијÑки -Name[sr@Latn]=Sardinijski -Name[ss]=Si-Sardinian -Name[sv]=Sardiska -Name[ta]=சாரà¯à®Ÿà¯€à®©à®¿à®¯à®©à¯ -Name[te]=సారà±à°¡à°¿à°¨à°¿à°¯à°¨à± -Name[tg]=СардиниÑгӣ -Name[th]=ภาษาซาร์ดิเนียน -Name[tt]=Sardinça -Name[uk]=СардинÑька -Name[uz]=Sardincha -Name[uz@cyrillic]=Сардинча -Name[vi]=Xa-Ä‘i-ni-a -Name[wa]=Sardinyin -Name[zh_CN]=æ’’ä¸è¯­ -Name[zh_HK]=è–©ä¸å°¼äºžèªž -Name[zh_TW]=è–©ä¸å°¼äºžèªž -Name[zu]=Isi-Sardinian -[sd] -Name=Sindhi -Name[ar]=سندي -Name[be]=Сіндхі -Name[bg]=Синдхи -Name[bn]=সিনà§à¦§à¦¿ -Name[br]=Sindhieg -Name[eo]=Sinda -Name[fa]=سیندهی -Name[ga]=Sindis -Name[he]=סינדהי -Name[hi]=सिंधी -Name[hu]=Szindi -Name[is]=Shindi -Name[ja]=シンド語 -Name[ka]=სინდჰი -Name[kk]=Синдхи -Name[km]=ស៊ីន្ដី -Name[ko]=신디어 -Name[lb]=Sindhi-Sprooch -Name[mk]=Синди -Name[mn]=Синди -Name[ne]=सिनà¥à¤§à¥€ -Name[nso]=Se-Sindhi -Name[pa]=ਸਿੰਧੀ -Name[ro]=Sindi -Name[ru]=Синдхи -Name[rw]=Igisindi -Name[se]=Sindhigiella -Name[sk]=sindhÄina -Name[sl]=sindijsko -Name[sq]=Sindisht -Name[sr]=СиндиÑки -Name[sr@Latn]=Sindiski -Name[ss]=Si-Sindhi -Name[ta]=சிநà¯à®¤à®¿ -Name[te]=సింధి -Name[tg]=Синдхӣ -Name[th]=ภาษาสินธุ -Name[tt]=Sindihçä -Name[uk]=Синдхі -Name[uz]=Sindxi -Name[uz@cyrillic]=Синдхи -Name[vi]=Xin-Ä‘i -Name[wa]=Sindi -Name[zh_HK]=Sindhi語 -Name[zh_TW]=Sindhi語 -Name[zu]=Isi-Sindi -[se] -Name=Northern Sami -Name[af]=Noordelike Sami -Name[ar]=السامي الشمالية -Name[az]=Åžimali Sami -Name[be]=Самі (поўнач) -Name[bg]=Северен Сами -Name[bn]=উতà§à¦¤à¦° সামি -Name[br]=Sami, Norzh -Name[bs]=Sjeverni Sami -Name[ca]=Sami del nord -Name[cs]=Severní Sami -Name[csb]=Nordowi Sami -Name[cy]=Sami'r Gogledd -Name[da]=Nordsamisk -Name[de]=Nördliches Sami -Name[eo]=Norda Samea -Name[es]=Samí del norte -Name[et]=Põhja-saami -Name[eu]=Samia (iparrekoa) -Name[fa]=سامی شمالی -Name[fi]=Pohjoissaame -Name[fr]=Sami du Nord -Name[fy]=Noard-Koreaansk -Name[ga]=Sáimis Thuaidh -Name[gl]=Sami do Norte -Name[he]=ס×מית צפונית -Name[hi]=नारà¥à¤¦à¤°à¥à¤¨ सामी -Name[hr]=Sjeverni Sami -Name[hsb]=Sewjernosamisce -Name[hu]=Északi szami -Name[is]=Norður Sami -Name[it]=Sami settentrionale -Name[ja]=北サーミ語 -Name[ka]=ჩრდილრსáƒáƒáƒ›áƒ˜ -Name[kk]=СолтүÑтік Ñаами -Name[km]=សាមីជើង -Name[ko]=ë¶ë¶€ 사미어 -Name[lb]=Nördlecht Sami -Name[lt]=Å iaurÄ—s Sami -Name[mk]=Северен Сами -Name[mn]=Умард Сами -Name[ms]=Sami Utara -Name[nb]=Nordsamisk -Name[nds]=Noord-Saamsch -Name[ne]=उतà¥à¤¤à¤°à¥€ सामी -Name[nl]=Noord Sami -Name[nn]=Nordsamisk -Name[nso]=Se-Sami sa Lebowa -Name[pa]=ਉੱਤਰੀ ਸਾਮੀ -Name[pl]=Północny Sami -Name[pt]=Sami do Norte -Name[pt_BR]=Sami do Norte -Name[ro]=Sami nordică -Name[ru]=Северное Саами -Name[rw]=Igisami amajyaruguru -Name[se]=Davvisámegiella -Name[sk]=severná saamÄina -Name[sl]=severno sami -Name[sq]=Sami Verior -Name[sr]=СеверноÑамÑки -Name[sr@Latn]=Severnosamski -Name[ss]=SiSami sasenyakatfo -Name[sv]=Samiska -Name[ta]=நாரà¯à®¤à®©à¯ சாமி -Name[te]=ఉతà±à°¤à°° సమి -Name[tg]=Саамаи шимолӣ -Name[th]=ภาษาซามี ตอนเหนือ -Name[tt]=Tönyaq Sami -Name[uk]=Північна Саамі -Name[uz]=Shimoliy Sami -Name[uz@cyrillic]=Шимолий Сами -Name[ven]=Sami ya Devhula -Name[vi]=Xa-mi (Bắc) -Name[wa]=Bijhe sÃ¥mi -Name[xh]=Sami Yasemntla -Name[zh_CN]=北部沙米语 -Name[zh_HK]=北薩米語 -Name[zh_TW]=北薩米語 -Name[zu]=Isi-Sami Sase-Ntshonalanga -[sg] -Name=Sango -Name[ar]=السانغو -Name[az]=Sagno -Name[be]=Санга -Name[bg]=Сангро -Name[bn]=সাংগো -Name[eo]=Sangoa -Name[fa]=سانگو -Name[ga]=Sangóis -Name[he]=ס×נגו -Name[hi]=सैनà¥à¤—ो -Name[hu]=Szangó -Name[ja]=サンゴ語 -Name[ka]=სáƒáƒœáƒ’რ-Name[kk]=Санго -Name[km]=សង់ហ្គោ -Name[lb]=Sango-Sprooch -Name[mk]=Санго -Name[mn]=Санго -Name[ne]=साङà¥à¤—ो -Name[nso]=Se-Sango -Name[pa]=ਸਾਂਗੋ -Name[ro]=Sangă -Name[ru]=Санго -Name[rw]=Igisango -Name[se]=Sangogiella -Name[sk]=sango -Name[sl]=sango -Name[sq]=Sangisht -Name[sr]=Санго -Name[ss]=Si-Sango -Name[ta]=சாஙà¯à®•à¯‹ -Name[te]=సాంగొ -Name[tg]=Санго -Name[th]=ภาษาà¹à¸‹à¸‡à¹‚ภ-Name[tt]=Sangoça -Name[uk]=Санго -Name[uz@cyrillic]=Санго -Name[vi]=Xan-gô -Name[zh_CN]=桑戈语 -Name[zh_HK]=Sango語 -Name[zh_TW]=Sango語 -Name[zu]=Isi-Sango -[si] -Name=Sinhalese -Name[ar]=السينهالية -Name[az]=Sinhalca -Name[be]=СінгальÑÐºÐ°Ñ -Name[bg]=СингалÑки -Name[bn]=সিংহলী -Name[br]=Singaleg -Name[bs]=SinhaleÅ¡ki -Name[ca]=Sinhalès -Name[cs]=Sinhalský -Name[csb]=Synagelsczi -Name[cy]=Sinhaleg -Name[da]=Sinhalesisk -Name[de]=Singhalesisch -Name[eo]=Sinhala -Name[es]=Sinhalés -Name[et]=Singaleesi -Name[eu]=Sinhala -Name[fa]=سینهالس -Name[fi]=Sinhali -Name[fr]=Singhalais -Name[fy]=Singaleesk -Name[ga]=Siolóinis -Name[gl]=Sinhalés -Name[he]=סינהלזית -Name[hi]=सिंहली -Name[hr]=Sinhalski -Name[hsb]=Singalsce -Name[hu]=Szingaléz -Name[is]=Shinhalese -Name[it]=Cingalese -Name[ja]=シンãƒãƒ©èªž -Name[ka]=სენეგáƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Сингалша -Name[km]=ស៊ីងហាលីស -Name[ko]=ì‹ í• ë¼ì–´ -Name[lb]=Singhalesesch -Name[lt]=Sinhalų -Name[mk]=СинхалÑки -Name[mn]=Синхал -Name[nb]=Singalesisk -Name[nds]=Singaleesch -Name[ne]=सिङà¥à¤¹à¤¾à¤²à¥€ -Name[nl]=Sinhalees -Name[nn]=Singalesisk -Name[nso]=Se-Sinhalese -Name[pa]=ਸਿੰਹਾਲਸ਼ -Name[pl]=Syngaleski -Name[ro]=Sinaleză -Name[ru]=СингальÑкий -Name[rw]=Ikinyasinali -Name[se]=Singalesagiella -Name[sk]=sinhalÄina -Name[sl]=sinhalese -Name[sq]=Sinalezisht -Name[sr]=СинхалÑки -Name[sr@Latn]=Sinhalski -Name[ss]=Si-Sinhalese -Name[sv]=Singalesiska -Name[ta]=சிஙà¯à®•à®³à®®à¯ -Name[te]=సింహలీసౠ-Name[tg]=Сингалӣ -Name[th]=ภาษาสิงหล -Name[tt]=Sinhalçä -Name[uk]=СингальÑька -Name[uz]=Sinxalese -Name[uz@cyrillic]=СинхалеÑе -Name[vi]=Xin-ha-li -Name[wa]=Sinhalès -Name[zh_CN]=僧伽罗语 -Name[zh_HK]=錫蘭語 -Name[zh_TW]=錫蘭語 -Name[zu]=Isi-Sinhalese -[sk] -Name=Slovak -Name[af]=Slovakies -Name[ar]=السلوÙاكية -Name[az]=Slovakca -Name[be]=Ð¡Ð»Ð°Ð²Ð°Ñ†ÐºÐ°Ñ -Name[bg]=Словашки -Name[bn]=সà§à¦²à§‹à¦­à¦¾à¦• -Name[br]=Sloveg -Name[bs]=SlovaÄki -Name[ca]=Eslovè -Name[cs]=Slovenský -Name[csb]=SÅ‚owacczi -Name[cy]=Sloveg -Name[da]=Slovakisk -Name[de]=Slowakisch -Name[el]=Σλοβακικά -Name[eo]=Slovaka -Name[es]=Eslovaco -Name[et]=Slovaki -Name[eu]=Eslovakiera -Name[fa]=اسلواکی -Name[fi]=Slovakki -Name[fr]=Slovaque -Name[fy]=Slovaaks -Name[ga]=Slóvaicis -Name[gl]=Eslovaco -Name[he]=סלובנית -Name[hi]=सà¥à¤²à¥‹à¤µà¤¾à¤•à¤¨ -Name[hr]=SlovaÄki -Name[hsb]=SÅ‚owaksce -Name[hu]=Szlovák -Name[id]=Slovakia -Name[is]=Slóvenska -Name[it]=Slovacco -Name[ja]=スロãƒã‚­ã‚¢èªž -Name[ka]=სლáƒáƒ•áƒáƒ™áƒ£áƒ áƒ˜ -Name[kk]=Словакша -Name[km]=ស្លូវ៉ាគី -Name[ko]=슬로바키아어 -Name[ku]=Slovakî -Name[lb]=Slowakesch -Name[lt]=Slovakų -Name[lv]=SlovÄku -Name[mk]=Словачки -Name[mn]=Словак -Name[mt]=Slovakk -Name[nb]=Slovakisk -Name[nds]=Slowaaksch -Name[ne]=सà¥à¤²à¥‹à¤­à¤¾à¤• -Name[nl]=Slowaaks -Name[nn]=Slovakisk -Name[oc]=Eslòvac -Name[pa]=ਸਲੋਵਾਕ -Name[pl]=SÅ‚owacki -Name[pt]=Eslovaco -Name[pt_BR]=Eslovaco -Name[ro]=Slovacă -Name[ru]=Словацкий -Name[rw]=Igisilovake -Name[se]=Slovákagiella -Name[sk]=slovenÄina -Name[sl]=slovaÅ¡ko -Name[sq]=Sllovakisht -Name[sr]=Словачки -Name[sr@Latn]=SlovaÄki -Name[sv]=Slovakiska -Name[ta]=சà¯à®²à¯‹à®µà®¾à®•à¯ -Name[te]=à°¸à±à°²à±Šà°µà°¾à°•à± -Name[tg]=Словакӣ -Name[th]=ภาษาสโลวัค -Name[tr]=Slovakça -Name[tt]=Slovakça -Name[uk]=Словацька -Name[uz]=Slovakcha -Name[uz@cyrillic]=Словакча -Name[ven]=Musilovaka -Name[vi]=Xlô-vák -Name[wa]=Eslovake -Name[xh]=isiSlovak -Name[zh_CN]=斯洛ä¼å…‹è¯­ -Name[zh_HK]=斯洛ä¼å…‹èªž -Name[zh_TW]=斯洛ä¼å…‹èªž -Name[zu]=Isi-Silovaki -[sl] -Name=Slovenian -Name[af]=Sloveniese -Name[ar]=السلوÙينية -Name[az]=SlovencÉ™ -Name[be]=СлавенÑÐºÐ°Ñ -Name[bg]=СловенÑки -Name[bn]=সà§à¦²à§‹à¦­à§‡à¦¨à§€à§Ÿ -Name[br]=Slovenieg -Name[bs]=SlovenaÄki -Name[ca]=Eslovè -Name[cs]=Slovinský -Name[csb]=Slowensczi -Name[cy]=Sloveneg -Name[da]=Slovensk -Name[de]=Slowenisch -Name[el]=Σλοβενικά -Name[eo]=Slovena -Name[es]=Esloveno -Name[et]=Sloveeni -Name[eu]=Esloveniera -Name[fa]=اسلونیایی -Name[fi]=Sloveeni -Name[fr]=Slovène -Name[fy]=Sloveensk -Name[ga]=Slóivéinis -Name[gl]=Esloveno -Name[he]=סלובנית -Name[hi]=सà¥à¤²à¥‹à¤µà¥‡à¤¨à¤¿à¤¯à¤¨ -Name[hr]=Slovenski -Name[hsb]=SÅ‚owjensce -Name[hu]=Szlovén -Name[id]=Slovenia -Name[is]=Slóvenska -Name[it]=Sloveno -Name[ja]=スロベニア語 -Name[ka]=სლáƒáƒ•áƒ”ნური -Name[kk]=Словенше -Name[km]=ស្លូវ៉ានី -Name[ko]=슬로베니아어 -Name[ku]=Slovenî -Name[lb]=Slowenesch -Name[lt]=SlovÄ—nų -Name[lv]=Slovēņu -Name[mk]=Словенечки -Name[mn]=Словиан -Name[ms]=Slovenia -Name[mt]=Sloven -Name[nb]=Slovensk -Name[nds]=Sloweensch -Name[ne]=सà¥à¤²à¥‹à¤­à¥‡à¤¨à¤¿à¤¯à¤¨ -Name[nl]=Sloweens -Name[nn]=Slovensk -Name[nso]=Se-Slovenian -Name[oc]=Eslòvian -Name[pa]=ਸਲੋਵੀਨੀਆਨ -Name[pl]=SÅ‚oweÅ„ski -Name[pt]=Esloveno -Name[pt_BR]=Esloveno -Name[ro]=Slovenă -Name[ru]=СловенÑкий -Name[rw]=Ikinyasiloveniya -Name[se]=Slovenagiella -Name[sk]=slovinÄina -Name[sl]=slovensko -Name[sq]=Sllovenisht -Name[sr]=Словеначки -Name[sr@Latn]=SlovenaÄki -Name[ss]=Si-Slovenian -Name[sv]=Slovenska -Name[ta]=சà¯à®²à¯‹à®µà¯€à®©à®¿à®¯à®©à¯ -Name[te]=à°¸à±à°²à±Šà°µà±‡à°¨à°¿à°¯à°¨à± -Name[tg]=Словенӣ -Name[th]=ภาษาสโลเวเนีย -Name[tr]=Slovence -Name[tt]=Slovençä -Name[uk]=СловенÑька -Name[uz]=Sloveniancha -Name[uz@cyrillic]=Словенианча -Name[vi]=Xlô-ven -Name[wa]=Eslovenyin -Name[zh_CN]=斯洛文尼亚语 -Name[zh_HK]=斯洛維尼亞語 -Name[zh_TW]=斯洛維尼亞語 -Name[zu]=Isi-Slovenian -[sm] -Name=Samoan -Name[ar]=الساموية -Name[be]=Самоа -Name[bg]=СамоанÑки -Name[bn]=সামোয়ান -Name[bs]=Samoanski -Name[ca]=Samoanès -Name[cs]=Samojský -Name[csb]=SamoaÅ„sczi -Name[cy]=Samoeg -Name[da]=Samoansk -Name[de]=Samoanisch -Name[el]=Σαμοανικά -Name[eo]=Samoa -Name[es]=Samoano -Name[et]=Samoa -Name[eu]=Samoera -Name[fa]=ساموان -Name[fi]=Samoa -Name[fy]=Samoaansk -Name[ga]=Samóis -Name[gl]=Samoano -Name[he]=סמו×ית -Name[hi]=सामोन -Name[hr]=Samoanski -Name[hsb]=Samoasce -Name[hu]=Szamoai -Name[id]=Samoa -Name[it]=Samoano -Name[ja]=サモア語 -Name[ka]=სáƒáƒ›áƒáƒ -Name[kk]=Самоа -Name[km]=សាមូអា -Name[ko]=사모아어 -Name[lb]=Samoanesch -Name[lt]=Samoa -Name[lv]=SamoieÅ¡u -Name[mk]=СамоанÑки -Name[mn]=Самоан -Name[nb]=Samoansk -Name[nds]=Samoaansch -Name[ne]=सामोआन -Name[nl]=Samoaans -Name[nn]=Samoansk -Name[nso]=Se-Samoan -Name[pa]=ਸਾਮੋਆਨ -Name[pl]=SamoaÅ„ski -Name[pt]=Samoano -Name[pt_BR]=Samoa -Name[ro]=Samoană -Name[ru]=Самоа -Name[rw]=Igisamowani -Name[se]=Samoagiella -Name[sk]=samojÄina -Name[sl]=samojsko -Name[sq]=Samonisht -Name[sr]=СамоанÑки -Name[sr@Latn]=Samoanski -Name[ss]=Si-Samoan -Name[sv]=Samoanska -Name[ta]=சமோவன௠-Name[te]=సమొవనౠ-Name[tg]=Самоанӣ -Name[th]=ภาษาซาโมน -Name[tt]=Samoaça -Name[uk]=СамоанÑька -Name[uz]=Samoacha -Name[uz@cyrillic]=Самоача -Name[vi]=Xa-mô-a -Name[wa]=Samowan -Name[zh_CN]=è¨æ‘©äºšè¯­ -Name[zh_HK]=薩摩牙語 -Name[zh_TW]=薩摩牙語 -Name[zu]=Isi-Samoan -[sn] -Name=Shona -Name[ar]=الشونا -Name[be]=Шона -Name[bg]=Шона -Name[bn]=শোনা -Name[eo]=Åœona -Name[fa]=شوها -Name[fi]=Å¡ona -Name[ga]=Seoinis -Name[he]=שונה -Name[hi]=शोना -Name[hu]=Sona -Name[ja]=ショナ語 -Name[ka]=შáƒáƒœáƒ -Name[kk]=Схона -Name[km]=សូណា -Name[ko]=쇼나어 -Name[mk]=Шона -Name[mn]=Шона -Name[nds]=Schona -Name[ne]=शोना -Name[nso]=Se-Shona -Name[pa]=ਸ਼ੋਨਾ -Name[ro]=Åžonă -Name[ru]=Схона -Name[rw]=Igishona -Name[se]=Å onagiella -Name[sk]=Å¡ona -Name[sl]=shona -Name[sq]=Shonisht -Name[sr]=ШонÑки -Name[sr@Latn]=Å onski -Name[ss]=SiShona -Name[ta]=ஷோனா -Name[te]=షొనా -Name[tg]=Шонӣ -Name[th]=ภาษาโชนา -Name[tt]=Åžonaça -Name[uk]=Шона -Name[uz@cyrillic]=Шона -Name[vi]=Sô-na -Name[xh]=Isishona -Name[zh_CN]=修纳语 -Name[zh_HK]=Shona語 -Name[zh_TW]=Shona語 -Name[zu]=Isi-Shona -[so] -Name=Somali -Name[ar]=صومالي -Name[be]=СамалійÑÐºÐ°Ñ -Name[bg]=Сомали -Name[bn]=সোমালীয় -Name[br]=Somalieg -Name[bs]=Somalijski -Name[ca]=Somalí -Name[cs]=Somálský -Name[csb]=Somalijsczi -Name[da]=Somalisk -Name[el]=Σομαλικά -Name[eo]=Somala -Name[es]=Somalí -Name[et]=Somaali -Name[eu]=Somaliera -Name[fa]=سومالی -Name[fy]=Somalysk -Name[ga]=Somáilis -Name[he]=סומלית -Name[hi]=सोमाली -Name[hr]=Somalijski -Name[hsb]=Somalisce -Name[hu]=Szomáli -Name[id]=Somalia -Name[is]=Sómalska -Name[it]=Somalo -Name[ja]=ソマリ語 -Name[ka]=სáƒáƒ›áƒáƒšáƒ£áƒ áƒ˜ -Name[kk]=Сомали -Name[km]=សូម៉ាលី -Name[ko]=소ë§ë¦¬ì•„ì–´ -Name[lb]=Somalesch -Name[lt]=SomalieÄių -Name[lv]=SomÄlieÅ¡u -Name[mk]=СомалиÑки -Name[mn]=Сомали -Name[ne]=सोमाली -Name[nl]=Somalisch -Name[nso]=Se-Somali -Name[pa]=ਸੋਮਾਲੀ -Name[pl]=Somalijski -Name[ro]=Somaleză -Name[ru]=СомалийÑкий -Name[rw]=Igisomali -Name[se]=Somálagiella -Name[sk]=somálÄina -Name[sl]=somalsko -Name[sq]=Somalisht -Name[sr]=СомалијÑки -Name[sr@Latn]=Somalijski -Name[ss]=Si-Somali -Name[ta]=சோமாலி -Name[te]=సొమాలి -Name[tg]=Сомалӣ -Name[th]=ภาษาโซมาลี -Name[tt]=Somaliçä -Name[uk]=СомалійÑька -Name[uz]=Somalicha -Name[uz@cyrillic]=Сомалича -Name[vi]=Xô-ma-li -Name[wa]=Somalyin -Name[zh_CN]=索马里语 -Name[zh_HK]=索馬利語 -Name[zh_TW]=索馬利語 -Name[zu]=Isi-Somali -[sq] -Name=Albanian -Name[af]=Albanees -Name[ar]=ألباني -Name[az]=Albanca -Name[be]=ÐлбанÑÐºÐ°Ñ -Name[bg]=ÐлбанÑки -Name[bn]=আলবেনীয় -Name[br]=Albanieg -Name[bs]=Albanski -Name[ca]=Albanès -Name[cs]=Albánský -Name[csb]=AlbaÅ„sczi -Name[cy]=Albaneg -Name[da]=Albansk -Name[de]=Albanisch -Name[el]=Αλβανικά -Name[eo]=Albana -Name[es]=Albanés -Name[et]=Albaania -Name[eu]=Albaniera -Name[fa]=آلبانی -Name[fi]=Albania -Name[fr]=Albanais -Name[fy]=Albaansk -Name[ga]=Albáinis -Name[gl]=Albanés -Name[he]=×לבנית -Name[hi]=अलà¥à¤¬à¤¾à¤¨à¤¿à¤¯à¤¨ -Name[hr]=Albanski -Name[hsb]=Albansce -Name[hu]=Albán -Name[id]=Albania -Name[is]=Albanskur -Name[it]=Albanese -Name[ja]=アルãƒãƒ‹ã‚¢èªž -Name[ka]=áƒáƒšáƒ‘áƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Ðлбанша -Name[km]=អាល់បានី -Name[ko]=알바니아어 -Name[ku]=Albanî -Name[lb]=Albanesch -Name[lt]=Albanų -Name[lv]=AlbÄņu -Name[mk]=ÐлбанÑки -Name[mn]=Ðлбани -Name[ms]=Albania -Name[nb]=Albansk -Name[nds]=Albaansch -Name[ne]=अलà¥à¤¬à¤¾à¤¨à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Albanisch -Name[nn]=Albansk -Name[nso]=Se-Albanian -Name[pa]=ਅਲਬਾਨੀਅਨ -Name[pl]=AlbaÅ„ski -Name[pt]=Albanês -Name[pt_BR]=Albanês -Name[ro]=Albaneză -Name[ru]=ÐлбанÑкий -Name[rw]=Ikinyalubaniya -Name[se]=Albániagiella -Name[sk]=albánÄina -Name[sl]=albansko -Name[sq]=Shqip -Name[sr]=ÐлбанÑки -Name[sr@Latn]=Albanski -Name[ss]=Si-Albanian -Name[sv]=Albanska -Name[ta]=அலà¯à®ªà¯‡à®©à®¿à®¯à®©à¯ -Name[te]=à°…à°²à±à°¬à±‡à°¨à°¿à°¯à°¨à± -Name[tg]=Ðлбанӣ -Name[th]=ภาษาอัลเบเนีย -Name[tt]=Albança -Name[uk]=ÐлбанÑька -Name[uz]=Albancha -Name[uz@cyrillic]=Ðлбанча -Name[vi]=An-ba-ni -Name[wa]=Albanyin -Name[zh_CN]=阿尔巴尼亚语 -Name[zh_HK]=阿爾巴尼亞語 -Name[zh_TW]=阿爾巴尼亞語 -Name[zu]=Isi-Albanian -[sr] -Name=Serbian -Name[af]=Serbiese -Name[ar]=الصربية -Name[az]=SerbcÉ™ -Name[be]=СербÑÐºÐ°Ñ -Name[bg]=СръбÑки -Name[bn]=সারà§à¦¬à§€à§Ÿ -Name[br]=Serbeg -Name[bs]=Srpski -Name[ca]=Serbi -Name[cs]=Srbský -Name[csb]=Serbsczi -Name[cy]=Serbieg -Name[da]=Serbisk -Name[de]=Serbisch -Name[el]=ΣεÏβικά -Name[eo]=Serba -Name[es]=Serbio -Name[et]=Serbia -Name[eu]=Serbiera -Name[fa]=صربستانی -Name[fi]=Serbia -Name[fr]=Serbe -Name[fy]=Servysk -Name[ga]=Seirbis -Name[gl]=Sérvio -Name[he]=סרבית -Name[hi]=सरà¥à¤¬à¤¿à¤¯à¤¨ -Name[hr]=Srpski -Name[hsb]=Serbisce -Name[hu]=Szerb -Name[id]=Serbia -Name[is]=Serbneska -Name[it]=Serbo -Name[ja]=セルビア語 -Name[ka]=სერბული -Name[kk]=Сербше -Name[km]=សែប៊ី -Name[ko]=세르비아어 -Name[ku]=Sirbî -Name[lb]=Serbesch -Name[lt]=Serbų -Name[lv]=Serbu -Name[mk]=СрпÑки -Name[mn]=Серб -Name[ms]=Serbia -Name[mt]=Serb -Name[nb]=Serbisk -Name[nds]=Serbsch -Name[ne]=सरà¥à¤¬à¤¿à¤¯à¤¾à¤²à¥€ -Name[nl]=Servisch -Name[nn]=Serbisk -Name[nso]=Se-Serbian -Name[pa]=ਸਰਬੀਅਨ -Name[pl]=Serbski -Name[pt]=Sérvio -Name[pt_BR]=Sérvio -Name[ro]=Sîrbă -Name[ru]=СербÑкий -Name[rw]=Ikinyaseribiya -Name[se]=Serbiagiella -Name[sk]=srbÄina -Name[sl]=srbsko -Name[sq]=Serbisht -Name[sr]=СрпÑки -Name[sr@Latn]=Srpski -Name[ss]=Si-Serbian -Name[sv]=Serbiska -Name[ta]=செரà¯à®ªà®¿à®¯à®©à¯ -Name[te]=సెరà±à°¬à°¿à°¯à°¨à± -Name[tg]=Сербӣ -Name[th]=ภาษาเซอร์เบีย -Name[tr]=Sırpça -Name[tt]=Serbçä -Name[uk]=СербÑька -Name[uz]=Serbcha -Name[uz@cyrillic]=Сербча -Name[vi]=Xéc-bi -Name[wa]=Serbe -Name[zh_CN]=塞尔维亚语 -Name[zh_HK]=塞爾維亞語 -Name[zh_TW]=塞爾維亞語 -Name[zu]=Isi-Serbian -[sr@Latn] -Name=Serbian Latin -Name[be]=СербÑÐºÐ°Ñ (лацініца) -Name[bg]=СръбÑки латинÑки -Name[br]=Serbeg latin -Name[bs]=Srpski latinica -Name[ca]=Serbi llatí -Name[cs]=Srbský (latinka) -Name[csb]=Serbsczi (Å‚acëńsczi) -Name[cy]=Serbieg Lladin -Name[da]=Serbisk latin -Name[de]=Serbisch (lat. Alphabet) -Name[el]=ΣεÏβικά (Λατινικά) -Name[eo]=Serba Latina alfabeto -Name[es]=Latín Serbio -Name[et]=Serbia (ladina) -Name[eu]=Serbiera (Latina) -Name[fa]=صربستانی -Name[fi]=Serbian latina -Name[fr]=Serbe Latin -Name[fy]=Servysk Latijnsk -Name[ga]=Seirbis (aibítir Laidineach) -Name[gl]=Sérbio Latino -Name[he]=לטינית סרבית -Name[hr]=Srpski latinica -Name[hu]=Szerb (latin betűs) -Name[is]=Serbnesk latína -Name[it]=Serbo latino -Name[ja]=セルビア語 (ラテン文字) -Name[ka]=სერბული ლáƒáƒ—ინური -Name[kk]=Сербше (Латын) -Name[km]=សែប៊ី (ឡាážáž¶áŸ†áž„) -Name[ku]=Sirbiya Latînî -Name[lb]=Latäinescht Serbesch -Name[lt]=Serbų lotynų -Name[lv]=Serbu latīņu -Name[mk]=СрпÑки (латиница) -Name[ms]=Latin Serbia -Name[nb]=Serbisk (latinsk) -Name[nds]=Serbsch (latiensch Schrift) -Name[ne]=सरà¥à¤¬à¤¿à¤¯à¤¾à¤²à¥€ लà¥à¤¯à¤¾à¤Ÿà¤¿à¤¨ -Name[nl]=Servisch Latijn -Name[nn]=Serbisk, latinsk -Name[pa]=ਸਰਬੀਅਨ ਲੈਟਿਨ -Name[pl]=Serbski Å‚aciÅ„ski -Name[pt]=Sérvio Latino -Name[pt_BR]=Sérvio Latino -Name[ro]=Sîrbă latină -Name[ru]=СербÑкий латинницей -Name[se]=SerbialaÅ¡ latiidnagiella -Name[sk]=srbÄina (latinka) -Name[sl]=srbsko latinsko -Name[sr]=СрпÑки латинични -Name[sr@Latn]=Srpski latiniÄni -Name[sv]=Latinsk serbiska -Name[te]=సెరà±à°¬à°¿à°¯à°¨à± లాటినౠ-Name[tg]=Лотини СербиÑвӣ -Name[th]=ภาษาละตินเซอร์เบีย -Name[tr]=Sırpça Latin -Name[uk]=СербÑька (латинь) -Name[uz]=Serbcha (Lotin) -Name[uz@cyrillic]=Сербча (Лотин) -Name[vi]=Xéc-bi (La-tinh) -Name[wa]=Siebe (alfabet latén) -Name[zh_CN]=塞尔维亚语(拉ä¸) -Name[zh_TW]=賽爾維亞拉ä¸èªž -[ss] -Name=Swati -Name[ar]=السواتي -Name[az]=Svati -Name[be]=Сваці -Name[bg]=Суази -Name[bn]=সোয়াতি -Name[et]=Svaasi -Name[fa]=سواتی -Name[fi]=Swazi -Name[ga]=Sasuatais -Name[he]=סוו×טי -Name[hi]=सà¥à¤µà¤¾à¤¤à¥€ -Name[hu]=Szvati -Name[ja]=スワティ語 -Name[ka]=სვáƒáƒ¢áƒ˜ -Name[kk]=Свати -Name[km]=ស្វាទី -Name[ko]=스와티어 -Name[lb]=Swazi -Name[mk]=Свати -Name[mn]=Свати -Name[ne]=सà¥à¤µà¤¾à¤¤à¥€ -Name[nso]=Se-Swati -Name[pa]=ਸਵਾਟੀ -Name[ro]=Suată -Name[ru]=Свати -Name[rw]=Igiswati -Name[se]=Svatigiella -Name[sk]=swati -Name[sl]=swati -Name[sq]=Suatisht -Name[sr]=Свати -Name[sr@Latn]=Svati -Name[ss]=SiSwati -Name[sv]=Swazi -Name[ta]=சà¯à®µà®¾à®¤à®¿ -Name[te]=à°¸à±à°µà°¾à°¤à°¿ -Name[tg]=Сватӣ -Name[th]=ภาษาสวาตี -Name[tt]=Swatça -Name[uk]=Суаті -Name[uz]=Svati -Name[uz@cyrillic]=Свати -Name[vi]=Xouă-ti -Name[wa]=Suwati -Name[xh]=Isiswati -Name[zh_CN]=斯瓦特语 -Name[zh_HK]=Swati語 -Name[zh_TW]=Swati語 -Name[zu]=Isi-Swati -[st] -Name=Sotho, Southern -Name[af]=Sotho, Suid -Name[ar]=السوتو الشمالية -Name[az]=Sotho, CÉ™nubi -Name[be]=Сота (поўдзень) -Name[bg]=Южен Сото -Name[bn]=সোথো, দকà§à¦·à¦¿à¦£ -Name[br]=Soto, Su -Name[bs]=Soto, Južni -Name[ca]=Sotho del sud -Name[cs]=Sotho, Jižní -Name[csb]=Sotho, Pôłniowi -Name[cy]=Sotho, De -Name[da]=Sotho, syd -Name[de]=Südliches Sotho -Name[eo]=Suda Sota -Name[es]=Sotho del sur -Name[et]=Lõuna-sotho -Name[eu]=Sothoera (egoaldekoa) -Name[fa]=سوتوی جنوبی -Name[fi]=Sotho -Name[fr]=Sotho du Sud -Name[fy]=Sotho, Súd -Name[ga]=Sótó Theas -Name[gl]=Sotho do sur -Name[he]=סותו דרומית -Name[hi]=सोथो, दकà¥à¤·à¤¿à¤£à¥€ -Name[hr]=Sotho, Južni -Name[hsb]=Sotho (juh) -Name[hu]=Sotho (déli) -Name[is]=Sotho, suður -Name[it]=Sotho meridionale -Name[ja]=å—ソト語 -Name[ka]=სáƒáƒ›áƒ®áƒ áƒ”თ სáƒáƒ¢áƒ -Name[kk]=ОңтүÑтік Ñото -Name[km]=សូធូ​ážáž¶áž„​ážáŸ’បូង -Name[ko]=남부 소토어 -Name[lb]=Südlecht Sotho -Name[lt]=Sotho, Pietų -Name[mk]=Сото, јужен -Name[mn]=Сото, Өмнөд -Name[ms]=Sotho, Selatan -Name[nb]=Sotho, Sørlig -Name[nds]=Sotho, Sööd -Name[ne]=सोथो, दकà¥à¤·à¤¿à¤£à¥€ -Name[nl]=Sotho, Zuid -Name[nn]=Sotho, sør -Name[nso]=Sesotho, sa Borwa -Name[pa]=ਸੋਥੋ, ਦੱਖਣੀ -Name[pl]=Sotho, PoÅ‚udniowy -Name[pt]=Sotho do Sul -Name[pt_BR]=Sotho, Sul -Name[ro]=Soto sudică -Name[ru]=Юж. Сото -Name[rw]=Igisotho, Amajyepfo -Name[se]=Sothogiella, lulli -Name[sk]=južná sothÄina -Name[sl]=sotho, južni -Name[sq]=Sothe Jugore -Name[sr]=Сото, јужни -Name[sr@Latn]=Soto, južni -Name[ss]=SiSotho, saseningizimo -Name[sv]=Sydsotho -Name[ta]=சோதà¯à®¤à¯‹, தென௠-Name[te]=సోతొ, దకà±à°·à°¿à°£ -Name[th]=ภาษาโซโธ ตอนใต้ -Name[tt]=Sothoça, Könyaq -Name[uk]=Сото, Південна -Name[uz]=Sotxo, Janubiy -Name[uz@cyrillic]=Сотхо, Жанубий -Name[ven]=Sotho, Tshipembe -Name[vi]=Xô-tô (nam) -Name[wa]=Soto (nonne) -Name[xh]=Isisuthu, Sasemzantsi -Name[zh_CN]=索托,å—部 -Name[zh_HK]=梭托語,å—部 -Name[zh_TW]=梭托語,å—部 -Name[zu]=Isi-Suthu, Sase-Mzantsi -[su] -Name=Sundanese -Name[ar]=سوداني -Name[az]=Sundanca -Name[be]=СунданÑÐºÐ°Ñ -Name[bg]=СунданÑки -Name[bn]=সà§à¦¨à§à¦¦à¦¾à¦¨à¦¿à¦œ -Name[br]=Soudaneg -Name[bs]=SundaneÅ¡ki -Name[ca]=Sundanès -Name[cs]=Sundanský -Name[csb]=SudaÅ„sczi -Name[cy]=Sundaneg -Name[da]=Sundansk -Name[de]=Sundanesisch -Name[eo]=Sunda -Name[es]=Sudanés -Name[et]=Sunda -Name[eu]=Sundanera -Name[fa]=ساندانیز -Name[fi]=Sunda -Name[fr]=Soudanais -Name[fy]=Soendaneesk -Name[ga]=Sundais -Name[gl]=Sundanés -Name[he]=סודנית -Name[hi]=सूडानी -Name[hsb]=Sundanesce -Name[hu]=Szundanéz -Name[id]=Sunda -Name[it]=Sudanese -Name[ja]=スンダ語 -Name[ka]=სუდáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Суданша -Name[km]=ស៊ូដង់ -Name[ko]=수단어 -Name[lb]=Sudanesesch -Name[lt]=SudanieÄių -Name[lv]=SudÄnieÅ¡u -Name[mk]=СунданÑки -Name[mn]=Сундан -Name[nb]=Sundanesisk -Name[nds]=Sundaneesch -Name[ne]=सà¥à¤¡à¤¾à¤¨à¥€ -Name[nl]=Sundanees -Name[nn]=Sundanesisk -Name[nso]=Se-Sundan -Name[pa]=ਸੂਡਾਨੀਅਸ -Name[pl]=SudaÅ„ski -Name[pt]=Sudanês -Name[pt_BR]=Sudanês -Name[ro]=Sudaneză -Name[ru]=СуданÑкий -Name[rw]=Ikinyasundani -Name[se]=Sundanesagiella -Name[sk]=sundÄina -Name[sl]=sudansko -Name[sq]=Sundanezisht -Name[sr]=СунданÑки -Name[sr@Latn]=Sundanski -Name[ss]=Si-Sundanese -Name[sv]=Sundanesiska -Name[ta]=சூடானீஸ௠-Name[te]=సనà±à°¦à°¨à±€à°¸à± -Name[tg]=Санданизӣ -Name[th]=ภาษาซูดาน -Name[tt]=Sundanesçä -Name[uk]=СунданÑька -Name[uz]=Sundancha -Name[uz@cyrillic]=Сунданча -Name[vi]=Xun-Ä‘a-ni -Name[wa]=Soudanès -Name[zh_CN]=巽他语 -Name[zh_HK]=Sundanese語 -Name[zh_TW]=Sundanese語 -Name[zu]=Isi-Sundanese -[sv] -Name=Swedish -Name[af]=Sweeds -Name[ar]=السويدية -Name[az]=Ä°sveçcÉ™ -Name[be]=ШведÑÐºÐ°Ñ -Name[bg]=ШведÑки -Name[bn]=সà§à¦‡à¦¡à¦¿à¦¶ -Name[br]=Svedeg -Name[bs]=Å vedski -Name[ca]=Suec -Name[cs]=Å védský -Name[csb]=Szwedzczi -Name[cy]=Swedeg -Name[da]=Svensk -Name[de]=Schwedisch -Name[el]=Σουηδικά -Name[eo]=Sveda -Name[es]=Sueco -Name[et]=Rootsi -Name[eu]=Suediera -Name[fa]=سوئدی -Name[fi]=Ruotsi -Name[fr]=Suédois -Name[fy]=Sweedsk -Name[ga]=Sualainnis -Name[gl]=Sueco -Name[he]=שבדית -Name[hi]=सà¥à¤µà¥€à¤¡à¤¿à¤¶ -Name[hr]=Å vedski -Name[hsb]=Å wedsce -Name[hu]=Svéd -Name[id]=Swedia -Name[is]=Sænska -Name[it]=Svedese -Name[ja]=スウェーデン語 -Name[ka]=შვედური -Name[kk]=Шведше -Name[km]=ស៊ុយអែដ -Name[ko]=스웨ë´ì–´ -Name[ku]=Swêdî -Name[lb]=Schwedesch -Name[lt]=Å vedų -Name[lv]=Zviedru -Name[mi]=Reo Wïtana -Name[mk]=ШведÑки -Name[mn]=Швед -Name[mt]=Svediż -Name[nb]=Svensk -Name[nds]=Sweedsch -Name[ne]=सà¥à¤µà¤¿à¤¡à¥‡à¤¨à¥€ -Name[nl]=Zweeds -Name[nn]=Svensk -Name[nso]=Se-Swedish -Name[oc]=Suedès -Name[pa]=ਸਵੀਡਿਸ਼ -Name[pl]=Szwedzki -Name[pt]=Sueco -Name[pt_BR]=Sueco -Name[ro]=Suedeză -Name[ru]=ШведÑкий -Name[rw]=Ikinyasuwede -Name[se]=Ruoŧagiella -Name[sk]=Å¡védÄina -Name[sl]=Å¡vedsko -Name[sq]=Suedisht -Name[sr]=ШведÑки -Name[sr@Latn]=Å vedski -Name[ss]=SiSwidi -Name[sv]=Svenska -Name[ta]=சà¯à®µà¯€à®Ÿà®¿à®·à¯ -Name[te]=à°¸à±à°µà±€à°¡à°¿à°·à± -Name[tg]=Шведӣ -Name[th]=ภาษาสวีดิช -Name[tr]=Ä°sveççe -Name[tt]=Ä°swäcçä -Name[uk]=ШведÑька -Name[uz]=Shvedcha -Name[uz@cyrillic]=Шведча -Name[vi]=Thuỵ-Ä‘iển -Name[wa]=Suwedwès -Name[zh_CN]=瑞典语 -Name[zh_HK]=瑞典語 -Name[zh_TW]=瑞典語 -Name[zu]=Isi-Swidishi -[sw] -Name=Swahili -Name[ar]=سواحلي -Name[az]=SvahilcÉ™ -Name[be]=Суахілі -Name[bg]=Суахили -Name[bn]=সোয়াহিলি -Name[ca]=Suahili -Name[cs]=Svahilský -Name[de]=Suaheli -Name[el]=Σουαχίλι -Name[eo]=Svahila -Name[es]=Suahili -Name[et]=Suahiili -Name[eu]=Swahiliera -Name[fa]=سواهیلی -Name[ga]=Svahaílis -Name[he]=סוו×הילי -Name[hi]=सà¥à¤µà¤¾à¤¹à¤¿à¤²à¥€ -Name[hr]=Svahili -Name[hu]=Szvahili -Name[ja]=スワヒリ語 -Name[ka]=სუáƒáƒ°áƒ˜áƒšáƒ˜ -Name[kk]=Суахили -Name[km]=ស្វាហ៊ីលី -Name[ko]=스와ížë¦¬ì–´ -Name[lt]=Suahili -Name[lv]=Svahili -Name[mk]=Свахили -Name[mn]=Свахил -Name[ne]=सà¥à¤µà¤¾à¤¹à¤¿à¤²à¥€ -Name[nso]=Se-Swahili -Name[pa]=ਸਵਾਹਿਲੀ -Name[ro]=Suahileză -Name[ru]=Суахили -Name[rw]=Igiswayili -Name[se]=Svahilagiella -Name[sk]=svahilÄina -Name[sl]=svahili -Name[sq]=Suailisht -Name[sr]=Свахили -Name[sr@Latn]=Svahili -Name[ss]=SiSwahili -Name[ta]=ஸà¯à®µà®¾à®¹à®¿à®²à®¿ -Name[te]=à°¸à±à°µà°¾à°¹à°¿à°²à°¿ -Name[tg]=Свахили -Name[th]=ภาษาสวาฮิลี -Name[tt]=Swahiliçä -Name[uk]=Суахілі -Name[uz]=Svaxili -Name[uz@cyrillic]=Свахили -Name[vi]=Xouă-hi-li -Name[wa]=Suwahili -Name[zh_CN]=斯瓦希里语 -Name[zh_HK]=æ–¯è¯è¥¿é‡Œèªž -Name[zh_TW]=æ–¯è¯è¥¿é‡Œèªž -Name[zu]=Isi-Swahili -[ta] -Name=Tamil -Name[af]=Tamilies -Name[ar]=التاميلية -Name[az]=Tamil Dili -Name[be]=ТамільÑÐºÐ°Ñ -Name[bg]=ТамилÑки -Name[bn]=তামিল -Name[br]=Tamouleg -Name[bs]=Tamilski -Name[ca]=Tàmil -Name[cs]=Tamilský -Name[csb]=Tamilsczi -Name[da]=Tamilsk -Name[eo]=Tamila -Name[et]=Tamili -Name[eu]=Tamilera -Name[fa]=تامیل -Name[fi]=Tamili -Name[fr]=Tamoul -Name[ga]=Tamailis -Name[he]=טמילית -Name[hi]=तमिल -Name[hr]=Tamilski -Name[hsb]=Tamilsce -Name[is]=Tamílska -Name[ja]=タミル語 -Name[ka]=თáƒáƒ›áƒ˜áƒšáƒ£áƒ áƒ˜ -Name[kk]=Тамилша -Name[km]=ážáž¶áž˜áž¸áž› -Name[ko]=타밀어 -Name[lt]=Tamilų -Name[lv]=Tamilu -Name[mi]=Reo Ãnia tonga -Name[mk]=ТамилÑки -Name[mn]=Тамил -Name[nds]=Tamielsch -Name[ne]=तामिल -Name[nn]=Tamilsk -Name[nso]=Se-Tamil -Name[pa]=ਤਾਮਿਲ -Name[pl]=Tamiljski -Name[ro]=Tamilă -Name[ru]=ТамильÑкий -Name[rw]=Igitamili -Name[se]=Tamilgiella -Name[sk]=tamilÄina -Name[sl]=tamilsko -Name[sq]=Tamilisht -Name[sr]=ТамилÑки -Name[sr@Latn]=Tamilski -Name[ss]=Si-Tamil -Name[ta]=தமிழ௠-Name[te]=తమిళం -Name[tg]=Тамилӣ -Name[th]=ภาษาทมิฬ -Name[tr]=Tamil Dili -Name[tt]=Tamilça -Name[uk]=ТамільÑька -Name[uz]=Tamilcha -Name[uz@cyrillic]=Тамилча -Name[vi]=Ta-min -Name[wa]=Tamoul -Name[zh_CN]=泰米尔语 -Name[zh_HK]=å¦ç±³çˆ¾èªž -Name[zh_TW]=å¦ç±³çˆ¾èªž -Name[zu]=Isi-Tamili -[te] -Name=Telugu -Name[ar]=التيلوغو -Name[az]=Teluguca -Name[be]=ТÑлугу -Name[bg]=Телугу -Name[bn]=তেলেগৠ-Name[br]=Telegu -Name[eo]=Telugua -Name[fa]=تلوگو -Name[fr]=Télougou -Name[fy]=Telûgû -Name[ga]=Teileagúis -Name[he]=טלוגו -Name[hi]=तेलà¥à¤—ॠ-Name[ja]=テルグ語 -Name[ka]=ტელუგუ -Name[kk]=Телугу -Name[km]=ážáŸáž›áž¼áž áŸ’áž‚áž¼ -Name[ko]=테루그어 -Name[mk]=Телугу -Name[mn]=ТÑлүгү -Name[ne]=तेलà¥à¤—ॠ-Name[nso]=Se-Telugu -Name[pa]=ਤੇਲਗੂ -Name[ro]=Telugă -Name[ru]=Телугу -Name[rw]=Igitelugu -Name[se]=Telugugiella -Name[sk]=telugÄina -Name[sl]=telugu -Name[sq]=Talugisht -Name[sr]=ТелугÑки -Name[sr@Latn]=Telugski -Name[ss]=Si-Telugu -Name[ta]=தெலà¯à®™à¯à®•à¯ -Name[te]=తెలà±à°—à± -Name[tg]=ТелугуÑгӣ -Name[th]=ภาษาเตลูà¸à¸¹ -Name[tt]=Teluguça -Name[uk]=Телугу -Name[uz@cyrillic]=Телугу -Name[vi]=Te-lu-gu -Name[wa]=Telougou -Name[zh_CN]=æ³°å¢å›ºè¯­ -Name[zh_HK]=特拉å¤èªž -Name[zh_TW]=特拉å¤èªž -Name[zu]=Isi-Telugu -[tg] -Name=Tajik -Name[af]=Tajikees -Name[ar]=طاجيكي -Name[az]=TacikcÉ™ -Name[be]=Ð¢Ð°Ð´Ð¶Ñ‹Ñ†ÐºÐ°Ñ -Name[bg]=ТаджикÑки -Name[bn]=তাজিক -Name[br]=Tajiek -Name[bs]=TadžiÄki -Name[cs]=Tádžikský -Name[csb]=Tadżëcczi -Name[de]=Tadschikisch -Name[el]=Τατζικικά -Name[eo]=TaÄika -Name[es]=Tayiko -Name[et]=Tadžiki -Name[eu]=Tadjikera -Name[fa]=تاجیک -Name[fi]=Tadžikki -Name[fr]=Tadjik -Name[fy]=Tadzjyksk -Name[ga]=Táidsícis -Name[gl]=Taxico -Name[he]=טג'יקית -Name[hi]=ताजिक -Name[hr]=Tadžik -Name[hsb]=Tadźikisce -Name[hu]=Tadzsik -Name[it]=Tagicco -Name[ja]=タジク語 -Name[ka]=ტáƒáƒ¯áƒ˜áƒ™áƒ£áƒ áƒ˜ -Name[kk]=Тәжікше -Name[km]=ážáž¶ážŠáž áŸ’ស៊ីគីស្ážáž„់ -Name[ko]=타ì§ì–´ -Name[lb]=Tadschikesch -Name[lt]=Tadžikų -Name[lv]=Tadžiku -Name[mk]=ТаџикиÑтанÑки -Name[mn]=Тажик -Name[nb]=Tadsjikisk -Name[nds]=Tadschiiksch -Name[ne]=ताजिक -Name[nl]=Tajiks -Name[nn]=Tadsjikisk -Name[nso]=Se-Tajik -Name[pa]=ਤਾਜਿਕ -Name[pl]=Tadżycki -Name[ro]=Tajică -Name[ru]=ТаджикÑкий -Name[rw]=Igitajika -Name[se]=Tažihkagiella -Name[sk]=tadžiÄtina -Name[sl]=tadžiÅ¡ko -Name[sq]=Taxhikisht -Name[sr]=ТаџикиÑтанÑки -Name[sr@Latn]=Tadžikistanski -Name[ss]=Si-Tajik -Name[sv]=Tadzjikiska -Name[ta]=தஜிக௠-Name[te]=తాజికౠ-Name[tg]=Тоҷикӣ -Name[th]=ภาษาทาจิà¸à¸´à¸ªà¸–าน -Name[tt]=Tajıqça -Name[uk]=Таджицька -Name[uz]=Tojikcha -Name[uz@cyrillic]=Тожикча -Name[vi]=Ta-gíc -Name[wa]=Tadjik -Name[zh_CN]=å¡”å‰å…‹è¯­ -Name[zh_HK]=å¡”å‰å…‹èªž -Name[zh_TW]=å¡”å‰å…‹èªž -Name[zu]=Isi-Tajik -[th] -Name=Thai -Name[af]=Thaïs -Name[ar]=التايلاندية -Name[az]=Tayca -Name[be]=ТайÑÐºÐ°Ñ -Name[bg]=ТайÑки -Name[bn]=থাই -Name[br]=Tailh -Name[bs]=Tajlandski -Name[cs]=Thajský -Name[csb]=Tajsczi -Name[da]=Thailandsk -Name[el]=Ταϊλανδικά -Name[eo]=Taja -Name[es]=Tailandés -Name[et]=Tai -Name[eu]=Thailandiera -Name[fa]=تایلندی -Name[fr]=Thaïlandais -Name[fy]=Taaisk -Name[ga]=Téalainnis -Name[gl]=Tailandés -Name[he]=ת×ילנדית -Name[hi]=थाई -Name[hr]=Tajlandski -Name[hsb]=Taisce -Name[id]=Thailand -Name[is]=Tælenska -Name[it]=Thailandese -Name[ja]=タイ語 -Name[ka]=ტáƒáƒ˜ -Name[kk]=Тайша -Name[km]=ážáŸƒ -Name[ko]=타ì´ì–´ -Name[ku]=Tay -Name[lt]=TailandieÄių -Name[lv]=TaizemieÅ¡u -Name[mk]=ТајландÑки -Name[mn]=Тай -Name[mt]=Tai -Name[ne]=थाई -Name[nl]=Thais -Name[nn]=Thailandsk -Name[nso]=Se-Thai -Name[oc]=Tai -Name[pa]=ਥਾਈ -Name[pl]=Tajski -Name[pt]=Tailandês -Name[ro]=Tailandeză -Name[ru]=ТайÑкий -Name[rw]=Igitayi -Name[se]=Thaigiella -Name[sk]=thajÄina -Name[sl]=tajsko -Name[sq]=Tajlandisht -Name[sr]=ТајландÑки -Name[sr@Latn]=Tajlandski -Name[ss]=Si-Thai -Name[sv]=Thailändska -Name[ta]=தாய௠-Name[te]=థాయి -Name[tg]=Тайландӣ -Name[th]=ภาษาไทย -Name[tt]=Tayça -Name[uk]=ТайÑька -Name[uz]=Taycha -Name[uz@cyrillic]=Тайча -Name[vi]=Thái -Name[wa]=Taylandès -Name[zh_CN]=泰语 -Name[zh_HK]=泰國語 -Name[zh_TW]=泰國語 -Name[zu]=Isi-Thayi -[ti] -Name=Tigrinya -Name[ar]=التيغرينيا -Name[az]=Tigrinyaca -Name[be]=Ð¢Ñ‹Ð³Ñ€Ñ‹Ð½ÑŒÑ -Name[bg]=Ð¢Ð¸Ð³Ñ€Ð¸Ð½Ñ -Name[bn]=টিগà§à¦°à¦¿à¦¨à§à¦¯à¦¾ -Name[de]=Tigrinja -Name[eo]=Tigraja -Name[et]=Tigrinja -Name[fa]=تیگرینیا -Name[fi]=Tigrinja -Name[fr]=Tigrigna -Name[fy]=Tigrysk -Name[ga]=Tigrinis -Name[gl]=Tigrignan -Name[he]=טיגריניה -Name[hi]=टिगà¥à¤°à¤¿à¤¨à¥à¤¯à¤¾ -Name[hsb]=Tigrinja -Name[hu]=Tigrinja -Name[ja]=ティグリニア語 -Name[ka]=ტიგრინირ-Name[kk]=Ð¢Ð¸Ð³Ñ€Ð¸Ð½ÑŒÑ -Name[km]=ទីក្រីនយ៉ា -Name[ko]=티그리ëƒì–´ -Name[lb]=Tigrinja-Sprooch -Name[mk]=Тигринја -Name[mn]=Тигрин -Name[ne]=तिगà¥à¤°à¤¿à¤¨à¥à¤¯ -Name[nn]=Tigrinja -Name[nso]=Se-Tigrinya -Name[pa]=ਤਿਗਰੀਅਨ -Name[ro]=Tigrină -Name[ru]=Ð¢Ð¸Ð³Ñ€Ð¸Ð½ÑŒÑ -Name[rw]=Igitigirinya -Name[se]=Tigrinjágiella -Name[sk]=tigriňa -Name[sl]=tigrinya -Name[sq]=Tigrinjisht -Name[sr]=ТигринÑки -Name[sr@Latn]=Tigrinski -Name[ss]=Si-Tigrinya -Name[sv]=Tigrinja -Name[ta]=திகிரினà¯à®¯à®¾ -Name[te]=à°Ÿà°¿à°—à±à°°à°¿à°¨à±à°¯à°¾ -Name[tg]=ТигринÑгӣ -Name[th]=ภาษาทิà¸à¸£à¸´à¸™à¸¢à¸² -Name[tt]=Tigrinyaça -Name[uk]=ТигринійÑька -Name[uz@cyrillic]=Ð¢Ð¸Ð³Ñ€Ð¸Ð½Ñ -Name[vi]=Ti-gợ-ri-nia -Name[wa]=Tigrinia -Name[zh_CN]=æ格里尼亚语 -Name[zh_HK]=æ格利尼亞語 -Name[zh_TW]=æ格利尼亞語 -Name[zu]=Isi-Tigrinya -[tk] -Name=Turkmen -Name[ar]=تركماني -Name[az]=TürkmÉ™ncÉ™ -Name[be]=ТуркменÑÐºÐ°Ñ -Name[bg]=ТуркменÑки -Name[bn]=তà§à¦°à§à¦•à¦®à§‡à¦¨ -Name[bs]=Turkmenski -Name[ca]=Turcmeni -Name[cs]=Turkmenský -Name[csb]=TurkmeÅ„sczi -Name[cy]=Twrcmeneg -Name[de]=Turkmenisch -Name[el]=ΤουÏκμενικά -Name[eo]=Turkmena -Name[es]=Turkmenio -Name[et]=Turkmeeni -Name[eu]=Turkmeniera -Name[fa]=ترکمنی -Name[fi]=Turkmeeni -Name[fr]=Turkmène -Name[fy]=Turkmeensk -Name[ga]=Turcamáinis -Name[gl]=Turquemeno -Name[he]=טורקמנית -Name[hi]=तà¥à¤°à¥à¤•à¤®à¥‡à¤¨ -Name[hr]=Turkmenski -Name[hsb]=Turkmensce -Name[hu]=Türkmén -Name[it]=Turkmeno -Name[ja]=トルクメン語 -Name[ka]=თურქმენული -Name[kk]=Түркменше -Name[km]=ទួគមáŸáž“ីស្ážáž„់ -Name[lb]=Turkmenesch -Name[lt]=TurkmÄ—nų -Name[lv]=Turkmēņu -Name[mk]=ТуркмениÑтанÑки -Name[mn]=Туркмен -Name[nb]=Turkmensk -Name[nds]=Turkmeensch -Name[ne]=टरà¥à¤•à¤®à¥à¤¯à¤¾à¤¨ -Name[nl]=Turkmeens -Name[nn]=Turkmensk -Name[nso]=Se-Turkmen -Name[pa]=ਤà©à¨°à¨•à¨®à©€à¨¨ -Name[pl]=TurkmeÅ„ski -Name[pt]=Turquemenistanês -Name[pt_BR]=Turco -Name[ro]=Turcmenă -Name[ru]=ТуркменÑкий -Name[rw]=Igiturukimeni -Name[se]=Turkmenagiella -Name[sk]=turkménÄina -Name[sl]=turkmensko -Name[sq]=Turkmenisht -Name[sr]=ТуркмениÑтанÑки -Name[sr@Latn]=Turkmenistanski -Name[ss]=Si-Turkmen -Name[sv]=Turkmenska -Name[ta]=தà¯à®°à¯à®•à¯à®®à¯†à®©à¯ -Name[te]=à°¤à±à°°à±à°•à±à°®à±†à°¨à± -Name[tg]=Туркманӣ -Name[th]=ภาษาเติร์à¸à¹€à¸¡à¸™ -Name[tr]=Türkmence -Name[tt]=Törkmänçä -Name[uk]=ТуркменÑька -Name[uz]=Turkmancha -Name[uz@cyrillic]=Туркманча -Name[ven]=Munna wa Turkey -Name[vi]=Tuổc-men -Name[wa]=Turkmene -Name[zh_CN]=土库曼语 -Name[zh_HK]=土庫曼語 -Name[zh_TW]=土庫曼語 -Name[zu]=Amadoda Ase-Thekishi -[tn] -Name=Tswana -Name[ar]=التسوانا -Name[az]=Tsvanaca -Name[be]=Цвана -Name[bg]=ТÑуана -Name[bn]=তসওয়ানা -Name[eo]=Cvana -Name[et]=Tsvana -Name[eu]=Tswanera -Name[fa]=تی سوانا -Name[fi]=TÅ¡wana -Name[fy]=Tswanaansk -Name[ga]=Suáinis -Name[he]=צוו×× ×” -Name[hi]=तसà¥à¤µà¤¾à¤¨à¤¾ -Name[hu]=Tszvana -Name[ja]=ツワナ語 -Name[ka]=ტსვáƒáƒœáƒ -Name[kk]=ТÑвана -Name[km]=វ៉ាន់ណា -Name[lb]=Tswana-Sprooch -Name[mk]=Цвана -Name[mn]=Цвана -Name[ne]=तसà¥à¤µà¤¾à¤¨à¤¾ -Name[nn]=Setswana -Name[nso]=Setswana -Name[pa]=ਤਸਵਾਨਾ -Name[ro]=Å¢uană -Name[ru]=ТÑвана -Name[rw]=Igitswana -Name[se]=Tswanagiella -Name[sk]=ÄwanÄina -Name[sl]=tswana -Name[sq]=Cuanisht -Name[sr]=Цвана -Name[sr@Latn]=Cvana -Name[ss]=SiTswana -Name[ta]=ஸà¯à®µà®¾à®©à®¾ -Name[te]=à°¸à±à°µà°¾à°¨à°¾ -Name[tg]=Сванавӣ -Name[th]=ภาษาสวานา -Name[tt]=Tswanaça -Name[uk]=ТÑвана -Name[uz]=Tsvana -Name[uz@cyrillic]=ТÑвана -Name[vi]=T-xouă-nă -Name[xh]=Isitswana -Name[zh_CN]=茨瓦纳语 -Name[zh_HK]=ç­åœ–語 -Name[zh_TW]=ç­åœ–語 -Name[zu]=Isi-Tswana -[to] -Name=Tonga -Name[ar]=تونجي -Name[az]=Tongaca -Name[be]=Тонга -Name[bg]=Тонга -Name[bn]=টংগা -Name[br]=Inizi Tonga -Name[el]=Τόνγκα -Name[eu]=Tongera -Name[fa]=تونگا -Name[fy]=Tongaansk -Name[ga]=Tongais -Name[he]=טונגה -Name[hi]=टोनà¥à¤—ा -Name[ja]=トンガ語 -Name[ka]=ცáƒáƒœáƒ’რ-Name[kk]=Тонга -Name[km]=ážáž»áž„ហ្គោ -Name[ko]=통가어 -Name[lv]=TongieÅ¡u -Name[mk]=Тонга -Name[mn]=Тонга -Name[ne]=टोङà¥à¤—ा -Name[nn]=Tongansk -Name[nso]=Se-Tonga -Name[pa]=ਤੋਂਗਾ -Name[ro]=Tongă -Name[ru]=Тонга -Name[se]=Tongagiella -Name[sk]=tonga -Name[sl]=tongaÅ¡ko -Name[sq]=Tongisht -Name[sr]=Тонга -Name[ss]=Si-Tonga -Name[ta]=டோஙà¯à®•à®¾ -Name[te]=టొనà±à°—à°¾ -Name[tg]=Тонгаӣ -Name[th]=ภาษาทองà¸à¸² -Name[uk]=Тонга -Name[uz@cyrillic]=Тонга -Name[vi]=Tông-ga -Name[zh_CN]=汤加语 -Name[zh_HK]=æ±åŠ èªž -Name[zh_TW]=æ±åŠ èªž -Name[zu]=Isi-Tonga -[tr] -Name=Turkish -Name[af]=Turks -Name[ar]=التركية -Name[az]=TürkcÉ™ -Name[be]=ТурÑÑ†ÐºÐ°Ñ -Name[bg]=ТурÑки -Name[bn]=তà§à¦°à§à¦•à§€ -Name[br]=Turkeg -Name[bs]=Turski -Name[ca]=Turc -Name[cs]=Turecký -Name[csb]=Tërecczi -Name[cy]=Twrceg -Name[da]=Tyrkisk -Name[de]=Türkisch -Name[el]=ΤουÏκικά -Name[eo]=Turka -Name[es]=Turco -Name[et]=Türgi -Name[eu]=Turkiera -Name[fa]=ترکی -Name[fi]=Turkki -Name[fr]=Turc -Name[fy]=Turks -Name[ga]=Tuircis -Name[gl]=Turco -Name[he]=טורקית -Name[hi]=तà¥à¤°à¥à¤•à¥€ -Name[hr]=Turski -Name[hsb]=Turkowsce -Name[hu]=Török -Name[id]=Turki -Name[is]=Tyrkneska -Name[it]=Turco -Name[ja]=トルコ語 -Name[ka]=თურქული -Name[kk]=Түрікше -Name[km]=ទួរគី -Name[ko]=터키어 -Name[ku]=Tirkî -Name[lb]=Türkesch -Name[lt]=Turkų -Name[lv]=Turku -Name[mk]=ТурÑки -Name[mn]=Турк -Name[ms]=Turki -Name[mt]=Tork -Name[nb]=Tyrkisk -Name[nds]=Törksch -Name[ne]=टरà¥à¤•à¤¿à¤¶ -Name[nl]=Turks -Name[nn]=Tyrkisk -Name[nso]=Se-Turkish -Name[oc]=Turc -Name[pa]=ਤà©à¨°à¨•à¨¿à¨¶ -Name[pl]=Turecki -Name[pt]=Turco -Name[pt_BR]=Turco -Name[ro]=Turcă -Name[ru]=Турецкий -Name[rw]=Ikinyaturukiya -Name[se]=Turkiijagiella -Name[sk]=tureÄtina -Name[sl]=turÅ¡ko -Name[sq]=Turqisht -Name[sr]=ТурÑки -Name[sr@Latn]=Turski -Name[ss]=Si-Turkish -Name[sv]=Turkiska -Name[ta]=தà¯à®°à¯à®•à¯à®•à®¿à®¯ -Name[te]=à°Ÿà°°à±à°•à°¿à°·à± -Name[tg]=Туркӣ -Name[th]=ภาษาตุรà¸à¸µ -Name[tr]=Türkçe -Name[tt]=Törekçä -Name[uk]=Турецька -Name[uz]=Turkcha -Name[uz@cyrillic]=Туркча -Name[vi]=Thổ-nhÄ©-kỳ -Name[wa]=Turk -Name[zh_CN]=土耳其语 -Name[zh_HK]=土耳其語 -Name[zh_TW]=土耳其語 -Name[zu]=Isi-Thekishi -[ts] -Name=Tsonga -Name[ar]=التسونغا -Name[az]=Tsongaca -Name[be]=Цонга -Name[bg]=ТÑонга -Name[bn]=তসংগা -Name[eo]=Conga -Name[eu]=Tsongera -Name[fa]=تی سوانگا -Name[fy]=Tsongaansk -Name[ga]=Songais -Name[he]=צונגה -Name[hi]=तà¥à¤¸à¥‹à¤¨à¥à¤—ा -Name[ja]=ツォンガ語 -Name[ka]=ცáƒáƒœáƒ’რ-Name[kk]=ТÑонга -Name[km]=សុងហ្កា -Name[lb]=Tsonga-Sprooch -Name[mk]=Цонга -Name[mn]=Цонга -Name[ne]=सोङà¥à¤—ा -Name[nso]=Se-Tsonga -Name[pa]=ਤਸੋਂਗਾ -Name[ro]=Tsongă -Name[ru]=ТÑонга -Name[rw]=Igitsonga -Name[se]=Tsongagiella -Name[sk]=tsonga -Name[sl]=tsonga -Name[sq]=Congisht -Name[sr]=Цонга -Name[sr@Latn]=Conga -Name[ss]=SiTsonga -Name[ta]=டிசோஙà¯à®•à®¾ -Name[te]=సొంగా -Name[tg]=Сонгавӣ -Name[th]=ภาษาซองà¸à¸² -Name[tt]=Tsongaça -Name[uk]=Цонґа -Name[uz]=Songa -Name[uz@cyrillic]=Цонга -Name[vi]=T-xông-ga -Name[zh_CN]=特æ¾åŠ è¯­ -Name[zh_HK]=Tsonga語 -Name[zh_TW]=Tsonga語 -Name[zu]=Isi-Tsonga -[tt] -Name=Tatar -Name[ar]=تتري -Name[az]=Tatarca -Name[be]=ТатарÑÐºÐ°Ñ -Name[bg]=ТатарÑки -Name[bn]=তাতার -Name[br]=Tatareg -Name[bs]=Tatarski -Name[cs]=Tatarský -Name[csb]=Tatarsczi -Name[de]=Tatarisch -Name[eo]=Tatara -Name[et]=Tatari -Name[eu]=Tatariera -Name[fa]=تاتاری -Name[fi]=Tataari -Name[fy]=Tataarsk -Name[ga]=Tatairis -Name[he]=טטרית -Name[hi]=तातार -Name[hr]=Tatarski -Name[hsb]=Tatarisce -Name[hu]=Tatár -Name[it]=Tartaro -Name[ja]=タタール語 -Name[ka]=თáƒáƒ—რული -Name[kk]=Татарша -Name[km]=ážáž¶ážáž¶ážš -Name[ko]=타타르어 -Name[lb]=Tataresch -Name[lt]=Totorių -Name[lv]=TatÄru -Name[mk]=ТатарÑки -Name[mn]=Татаар -Name[nds]=Tartaarsch -Name[ne]=टाटर -Name[nn]=Tatarisk -Name[nso]=Se-Tatar -Name[pa]=ਤਾਟਾਰ -Name[pl]=Tatarski -Name[ro]=Tătară -Name[ru]=ТатарÑкий -Name[rw]=Igitatari -Name[se]=Tatáragiella -Name[sk]=tatárÄina -Name[sl]=tatarsko -Name[sq]=Tatarisht -Name[sr]=ТатарÑки -Name[sr@Latn]=Tatarski -Name[ss]=Si-Tatar -Name[sv]=Tatariska -Name[ta]=டாடார௠-Name[te]=తతరౠ-Name[tg]=Тоторӣ -Name[th]=ภาษาทาทาร์ -Name[tt]=Tatarça -Name[uk]=ТатарÑька -Name[uz]=Totarcha -Name[uz@cyrillic]=Тотарча -Name[vi]=Ta-tă -Name[wa]=TatÃ¥r -Name[zh_CN]=éž‘é¼è¯­ -Name[zh_HK]=韃é¼èªž -Name[zh_TW]=韃é¼èªž -Name[zu]=Isi-Tatar -[tw] -Name=Twi -Name[ar]=التوي -Name[az]=TvicÉ™ -Name[be]=Тві -Name[bg]=Туи -Name[bn]=টà§à§Ÿà¦¿ -Name[et]=Tvii -Name[fa]=توی -Name[he]=צ'ווי -Name[hi]=तà¥à¤µà¥€ -Name[hu]=Tvi -Name[ja]=ãƒãƒ¥ã‚¤èªž -Name[ka]=ტვი -Name[kk]=Тви -Name[km]=ទ្វី -Name[lb]=Akan-Sprooch -Name[mk]=Тви -Name[mn]=Тви -Name[ne]=तà¥à¤‡ -Name[nso]=Se-Twi -Name[pa]=ਤਵੀ -Name[ru]=Тви -Name[rw]=Igitwi -Name[se]=Twigiella -Name[sk]=twi -Name[sl]=twi -Name[sq]=Tuisht -Name[sr]=ТвиÑки -Name[sr@Latn]=Tviski -Name[ss]=Si-Twi -Name[ta]=தà¯à®µà¯€ -Name[te]=à°Ÿà±à°µà°¿ -Name[tg]=ТвиÑгӣ -Name[th]=ภาษาชวี -Name[tt]=Twiçä -Name[uk]=Тві -Name[uz]=Tvi -Name[uz@cyrillic]=Тви -Name[vi]=Tui -Name[zh_CN]=契维语 -Name[zh_HK]=契維語 -Name[zh_TW]=契維語 -Name[zu]=Isi-Twi -[ty] -Name=Tahitian -Name[ar]=التاهيتية -Name[az]=TaiticÉ™ -Name[be]=Ð¢Ð°Ñ–Ñ†ÐºÐ°Ñ -Name[bg]=ТаитÑки -Name[bn]=তাহিশিয়ান -Name[br]=Tahitieg -Name[bs]=Tahićanski -Name[ca]=Tahitià -Name[cs]=Tahitský -Name[csb]=TahitaÅ„sczi -Name[cy]=Tahitieg -Name[da]=Tahitisk -Name[de]=Tahitianisch -Name[eo]=Tahitia -Name[es]=Tahitiano -Name[et]=Tahiti -Name[eu]=Tahitiera -Name[fa]=تاهیتی -Name[fi]=Tahiti -Name[fr]=Tahitien -Name[fy]=Tahitiaansk -Name[ga]=Taihítis -Name[gl]=Taitiano -Name[he]=טהיטית -Name[hi]=ताहितियन -Name[hr]=Tahićanski -Name[hsb]=Tahitisce -Name[hu]=Tahiti -Name[id]=Tahiti -Name[it]=Tahitiano -Name[ja]=タヒãƒèªž -Name[ka]=ტáƒáƒ˜áƒ¢áƒ˜ -Name[kk]=Таитише -Name[km]=ážáž¶áž áž·ážáž„់ -Name[ko]=타히티어 -Name[lb]=Tahitesch -Name[lt]=Tahiti -Name[lv]=TaitieÅ¡u -Name[mk]=ТахитÑки -Name[mn]=Тахит -Name[ms]=Tahiti -Name[nb]=Tahitisk -Name[nds]=Tahiitsch -Name[ne]=ताहिसिन -Name[nl]=Tahitiaans -Name[nn]=Tahitisk -Name[nso]=Se-Tahitian -Name[pa]=ਤਾਹੀਟੀਅਨ -Name[pl]=TahitaÅ„ski -Name[pt]=Tahitiano -Name[pt_BR]=Tahitiano -Name[ro]=Tahitiană -Name[ru]=Таити -Name[rw]=Ikinyatahiti -Name[se]=Tahitigiella -Name[sk]=tahitÄina -Name[sl]=tahitijsko -Name[sq]=Tahisht -Name[sr]=ТахићанÑки -Name[sr@Latn]=Tahićanski -Name[ss]=Si-Tahitian -Name[sv]=Tahitiska -Name[ta]=தஹிடியன௠-Name[te]=టహితియనౠ-Name[tg]=ТаитиÑгӣ -Name[th]=ภาษาตาฮิเตียน -Name[tt]=Tahitçä -Name[uk]=ТаїтÑнÑька -Name[uz]=Taxitian -Name[uz@cyrillic]=Тахитиан -Name[vi]=Ta-hi-ti -Name[wa]=Tahityin -Name[zh_CN]=塔希æ语 -Name[zh_HK]=大溪地語 -Name[zh_TW]=大溪地語 -Name[zu]=Isi-Tahitian -[ug] -Name=Uighur -Name[ar]=الأويغورية -Name[az]=UyÄŸurca -Name[be]=Уігур -Name[bg]=Югхур -Name[bn]=উইঘà§à¦° -Name[bs]=Ujgurski -Name[csb]=Ujgùrsczi -Name[de]=Uigurisch -Name[eo]=Ujgura -Name[et]=Uiguuri -Name[fa]=یوگر -Name[fi]=Uiguuri -Name[ga]=Úígiúiris -Name[he]=×ויגור -Name[hi]=उइघà¥à¤° -Name[hr]=Ujgurski -Name[hsb]=Ujgursce -Name[hu]=Ujgur -Name[ja]=ウイグル語 -Name[ka]=უიგურული -Name[kk]=Ұйғырша -Name[km]=វីហ្គៀរ -Name[lb]=Uiguresch -Name[lv]=Uiguru -Name[mk]=Ујгур -Name[mn]=Уйгур -Name[nb]=Uigursk -Name[nds]=Uighuursch -Name[ne]=विगोर -Name[nn]=Uigurisk -Name[nso]=Se-Uighur -Name[pa]=ਉਘੂਰ -Name[pl]=Ujgurski -Name[ro]=Uigură -Name[ru]=УйгурÑкий -Name[rw]=Icyuyiguru -Name[se]=Uiguragiella -Name[sk]=ujgurÄina -Name[sl]=ujgursko -Name[sq]=Uigurisht -Name[sr]=УјгурÑки -Name[sr@Latn]=Ujgurski -Name[ss]=Si-Uighur -Name[sv]=Uiguriska -Name[ta]=உயிகூர௠-Name[te]=ఉఇఘరౠ-Name[tg]=Уйгурӣ -Name[th]=ภาษาอุยà¸à¸¹à¸£à¹Œ -Name[tr]=Uygurca -Name[tt]=UyÄŸurça -Name[uk]=Уйгур -Name[uz]=UygÊ»urcha -Name[uz@cyrillic]=Уйғурча -Name[vi]=Ui-gua -Name[wa]=Ouygour -Name[zh_CN]=ç»´å¾å°”语 -Name[zh_HK]=維å¾çˆ¾èªž -Name[zh_TW]=維å¾çˆ¾èªž -Name[zu]=Isi-Uighur -[uk] -Name=Ukrainian -Name[af]=Ukraïnies -Name[ar]=الأوكرانية -Name[az]=Ukrayna Dili -Name[be]=УкраінÑÐºÐ°Ñ -Name[bg]=УкраинÑки -Name[bn]=ইউকà§à¦°à§‡à¦¨à§€à§Ÿ -Name[br]=Ukrainiek -Name[bs]=Ukrajinski -Name[ca]=Ucraïnès -Name[cs]=Ukrajinský -Name[csb]=ÙkrajiÅ„sczi -Name[cy]=Ukraineg -Name[da]=Ukrainsk -Name[de]=Ukrainisch -Name[el]=ΟυκÏανικά -Name[eo]=Ukraina -Name[es]=Ucranio -Name[et]=Ukraina -Name[eu]=Ukrainiera -Name[fa]=اکراینی -Name[fi]=Ukraina -Name[fr]=Ukrainien -Name[fy]=Oekraïnsk -Name[ga]=Úcráinis -Name[gl]=Ucraíno -Name[he]=×וקר×ינית -Name[hi]=उकà¥à¤°à¥‡à¤¨à¤¿à¤¯à¤¨ -Name[hr]=Ukrajinski -Name[hsb]=Ukrainsce -Name[hu]=Ukrán -Name[id]=Ukraina -Name[is]=Úkraínska -Name[it]=Ucraino -Name[ja]=ウクライナ語 -Name[ka]=უკრáƒáƒ˜áƒœáƒ£áƒšáƒ˜ -Name[kk]=Украинша -Name[km]=អ៊ុយក្រែន -Name[ko]=ìš°í¬ë¼ì´ë‚˜ì–´ -Name[lb]=Ukrainesch -Name[lt]=UkrainieÄių -Name[lv]=Ukraiņu -Name[mk]=УкраинÑки -Name[mn]=Украйн -Name[ms]=Ukrainia -Name[mt]=Ukranjan -Name[nb]=Ukrainsk -Name[nds]=Ukrainsch -Name[ne]=यà¥à¤•à¥à¤°à¥‡à¤¨à¥€ -Name[nl]=Oekraïns -Name[nn]=Ukrainsk -Name[nso]=Se-Ukrainian -Name[oc]=Ucranian -Name[pa]=ਯੂਕਰੇਨ -Name[pl]=UkraiÅ„ski -Name[pt]=Ucraniano -Name[pt_BR]=Ucraniano -Name[ro]=Ucrainiană -Name[ru]=УкраинÑкий -Name[rw]=Ikinya-ikarayini -Name[se]=Ukrainagiella -Name[sk]=ukrajinÄina -Name[sl]=ukrajinsko -Name[sq]=Ukrainisht -Name[sr]=УкрајинÑки -Name[sr@Latn]=Ukrajinski -Name[ss]=Si-Ukrainian -Name[sv]=Ukrainska -Name[ta]=உகà¯à®°à¯‡à®©à®¿à®¯à®©à¯ -Name[te]=ఉకà±à°°à±‡à°¨à°¿à°¯à°¨à± -Name[tg]=Украинӣ -Name[th]=ภาษายูเครน -Name[tr]=Ukrayna Dili -Name[tt]=Ukrainça -Name[uk]=УкраїнÑька -Name[uz]=Ukraincha -Name[uz@cyrillic]=Украинча -Name[vi]=U-cợ-rainh -Name[wa]=Oucrinnyin -Name[xh]=Ukranian -Name[zh_CN]=乌克兰语 -Name[zh_HK]=çƒå…‹è˜­èªž -Name[zh_TW]=çƒå…‹è˜­èªž -Name[zu]=Isi-Ukraniyani -[ur] -Name=Urdu -Name[ar]=أوردي -Name[az]=Urduca -Name[be]=Урду -Name[bg]=Урду -Name[bn]=উরà§à¦¦à§ -Name[ca]=Urdú -Name[cy]=Wrdw -Name[eo]=Urduo -Name[fa]=اردو -Name[fy]=Urdû -Name[ga]=Urdais -Name[he]=×ורדו -Name[hi]=उरà¥à¤¦à¥‚ -Name[ja]=ウルドゥー語 -Name[ka]=ურდუ -Name[kk]=Урду -Name[km]=អ៊ូរ្ឌូ -Name[ko]=울ë‘ì–´ -Name[mk]=Урду -Name[mn]=Урду -Name[ne]=उरà¥à¤¦à¥ -Name[nso]=Se-Urdu -Name[pa]=ਉਰਦੂ -Name[ru]=Урду -Name[rw]=Icyuridu -Name[se]=Urdugiella -Name[sk]=urdÄina -Name[sl]=urdu -Name[sq]=Urdisht -Name[sr]=Урду -Name[ss]=Si-Urdu -Name[ta]=உரà¯à®¤à¯ -Name[te]=ఉరà±à°¦à± -Name[tg]=Урду -Name[th]=ภาษาอูร์ดู -Name[tt]=Urduça -Name[uk]=Урду -Name[uz@cyrillic]=Урду -Name[vi]=Uổ-Ä‘u -Name[wa]=Ourdou -Name[zh_CN]=乌尔都语 -Name[zh_HK]=çƒéƒ½èªž -Name[zh_TW]=çƒéƒ½èªž -Name[zu]=Isi-Urdu -[uz] -Name=Uzbek -Name[ar]=أوزباكي -Name[az]=ÖzbÉ™kcÉ™ -Name[be]=Ð£Ð·Ð±ÐµÑ†ÐºÐ°Ñ -Name[bg]=УзбекÑки -Name[bn]=উজবেক -Name[br]=Ouzbeg -Name[bs]=UzbeÄki -Name[cs]=Uzbecký -Name[csb]=Ùzbecczi -Name[cy]=Wzbec -Name[de]=Usbekisch -Name[el]=Ουζμπεκικά -Name[eo]=Uzbeka -Name[es]=Uzbeko -Name[et]=Usbeki -Name[eu]=Uzbekera -Name[fa]=ازبکی -Name[fi]=Uzbekki -Name[fy]=Oezbeeksk -Name[ga]=Úisbéicis -Name[gl]=Uzbeque -Name[he]=×וזבקית -Name[hi]=उजà¥à¤¬à¤¼à¥‡à¤• -Name[hr]=UzbeÄki -Name[hsb]=Uzbekisce -Name[hu]=Ãœzbég -Name[it]=Uzbeco -Name[ja]=ウズベク語 -Name[ka]=უზბეკური -Name[kk]=Өзбекше -Name[km]=អ៊ូហ្សបáŸáž‚ីស្ážáž„់ -Name[ko]=우즈베í¬ì–´ -Name[lb]=Usbekesch -Name[lt]=Uzbekų -Name[lv]=Uzbeku -Name[mk]=УзбекиÑтанÑки -Name[mn]=Узбек -Name[nb]=Usbekisk -Name[nds]=Usbeeksch -Name[ne]=उजà¥à¤¬à¥‡à¤• -Name[nl]=Uzbeeks -Name[nn]=Usbekisk -Name[nso]=Se-Uzbek -Name[pa]=ਊਜੇਬਕ -Name[pl]=Uzbecki -Name[pt]=Usbequistanês -Name[ro]=Uzbecă -Name[ru]=УзбекÑкий -Name[rw]=Icyuzubeka -Name[se]=Uzbehkagiella -Name[sk]=uzbeÄtina -Name[sl]=uzbeÅ¡ko -Name[sq]=Uzbekisht -Name[sr]=Узбечки -Name[sr@Latn]=UzbeÄki -Name[ss]=Si-Uzbek -Name[sv]=Uzbekiska -Name[ta]=உஸà¯à®ªà¯†à®•à¯ -Name[te]=ఉజà±à°¬à±†à°•à± -Name[tg]=Ӯзбекӣ -Name[th]=ภาษาอุซเบà¸à¸´à¸ªà¸–าน -Name[tr]=Özbek -Name[tt]=Ãœzbäkçä -Name[uk]=Узбецька -Name[uz]=OÊ»zbekcha -Name[uz@cyrillic]=Ўзбекча -Name[vi]=U-x-béc -Name[wa]=Ouzbeke -Name[zh_CN]=乌兹别克语 -Name[zh_HK]=çƒèŒ²åˆ¥å…‹èªž -Name[zh_TW]=çƒèŒ²åˆ¥å…‹èªž -Name[zu]=Isi-Uzbek -[uz@cyrillic] -Name=Uzbek (Cyrillic) -Name[bg]=УзбекÑки (кирилица) -Name[ca]=Uzbek (Ciríl·lic) -Name[da]=Uzbekisk (kyrillisk) -Name[de]=Usbekisch (Kyrillisch) -Name[el]=Ουζμπεκικά (ΚυÏιλικά) -Name[es]=Uzbeko (Cirílico) -Name[et]=Usbeki (kirillitsa) -Name[fr]=Uzbek (Cyrillique) -Name[is]=Uzbek (Kyrilísk) -Name[it]=Usbeco (Cirillico) -Name[ja]=ウズベク語 (キリル文字) -Name[km]=អ៊ូហ្សបáŸáž‚ីស្ážáž„់ (ស៊ីរីលីក) -Name[nds]=Usbeeksch (kyrillsch) -Name[pl]=Uzbecki (cyrlica) -Name[sk]=uzbeÄtina (cyrilika) -Name[sr]=Узбечки ћирилични -Name[sr@Latn]=Узбечки ћирилични -Name[sv]=Kyrillisk Uzbekiska -Name[zh_TW]=çƒèŒ²åˆ¥å…‹èªžï¼ˆæ–¯æ‹‰å¤«èªžç³»ï¼‰ -[ven] -Name=Venda -Name[ar]=Ùيندا -Name[be]=Венда -Name[bg]=Венда -Name[bn]=ভেণà§à¦¡à¦¾ -Name[de]=Tshivenda -Name[fa]=وندا -Name[ga]=Veindis -Name[hi]=वेंडा -Name[ja]=ベンダ語 -Name[ka]=ვენდრ-Name[kk]=Венда -Name[km]=វង់ដា -Name[ko]=벤다어 -Name[mk]=Венда -Name[mn]=Венда -Name[ne]=भेनà¥à¤¡à¤¾ -Name[pa]=ਵਾਂਡਾ -Name[ru]=Венда -Name[rw]=Ikivenda -Name[se]=Vendagiella -Name[sk]=venda -Name[sl]=venda -Name[sq]=Vendisht -Name[sr]=Венда -Name[ta]=வெணà¯à®Ÿà®¾ -Name[te]=వెండా -Name[tg]=Вендаӣ -Name[th]=ภาษาเวนดา -Name[tt]=Vendaça -Name[uk]=Венда -Name[uz@cyrillic]=Венда -Name[vi]=Ven-Ä‘a -Name[zh_CN]=闻达语 -[vi] -Name=Vietnamese -Name[af]=Viëtnamees -Name[ar]=الÙييتنامية -Name[az]=Vyetnamca -Name[be]=Ð’'етнамÑÐºÐ°Ñ -Name[bg]=ВиетнамÑки -Name[bn]=ভিয়েতনামী -Name[br]=Viet-Nameg -Name[bs]=Vijetnamski -Name[ca]=Vietnamita -Name[cs]=Vietnamský -Name[csb]=Wietnamsczi -Name[cy]=Vietnameg -Name[da]=Vietnamesisk -Name[de]=Vietnamesisch -Name[el]=Βιετναμέζικα -Name[eo]=Vjetnama -Name[es]=Vietnamita -Name[et]=Vietnami -Name[eu]=Vietnamera -Name[fa]=ویتنامی -Name[fi]=Vietnam -Name[fr]=Vietnamien -Name[fy]=Vietnameesk -Name[ga]=Vítneamais -Name[gl]=Vietnamita -Name[he]=וייטנ×מית -Name[hi]=वियतनामी -Name[hr]=Vijetnamski -Name[hsb]=Vietnamsce -Name[hu]=Vietnami -Name[id]=Vietnam -Name[is]=Víetnamska -Name[it]=Vietnamita -Name[ja]=ベトナム語 -Name[ka]=ვიეტნáƒáƒ›áƒ£áƒ áƒ˜ -Name[kk]=Вьетнамша -Name[km]=វៀážážŽáž¶áž˜ -Name[ko]=베트남어 -Name[ku]=Viyetnamî -Name[lb]=Vietnamesesch -Name[lt]=VietnamieÄių -Name[lv]=VjetnamieÅ¡u -Name[mk]=ВиетнамÑки -Name[mn]=Витьнам -Name[ms]=Vietnam -Name[mt]=Vjetnamiż -Name[nb]=Vietnamesisk -Name[nds]=Vietnameesch -Name[ne]=भियतनामी -Name[nl]=Vietnamees -Name[nn]=Vietnamesisk -Name[nso]=Se-Vietnamese -Name[pa]=ਵੀਅਤਨਾਮੀ -Name[pl]=Wietnamski -Name[pt]=Vietnamita -Name[pt_BR]=Vietnamita -Name[ro]=Vietnameză -Name[ru]=ВьетнамÑкий -Name[rw]=Ikinyaviyetinamu -Name[se]=Vietnamagiella -Name[sk]=vietnamÄina -Name[sl]=vietnamsko -Name[sq]=Vietnamisht -Name[sr]=ВијетнамÑки -Name[sr@Latn]=Vijetnamski -Name[ss]=Si-Vietnamese -Name[sv]=Vietnamesiska -Name[ta]=வியடà¯à®©à®¾à®®à®¿à®¯ -Name[te]=వియతà±à°¨à°¾à°®à±€à°¸à± -Name[tg]=Ветнамӣ -Name[th]=ภาษาเวียตนาม -Name[tr]=Vietnamca -Name[tt]=Vietnamça -Name[uk]=Ð’'єтнамÑька -Name[uz]=Vetnamcha -Name[uz@cyrillic]=Ветнамча -Name[vi]=Việt -Name[wa]=Vietnamyin -Name[zh_CN]=越å—语 -Name[zh_HK]=越å—語 -Name[zh_TW]=越å—語 -Name[zu]=Isi-Vietnamese -[vo] -Name=Volapük -Name[ar]=الÙولابوك -Name[az]=VolapükcÉ™ -Name[be]=Валапук -Name[bg]=Волапюк -Name[bn]=ভোলাপà§à¦• -Name[br]=Volapuk -Name[cy]=Volapuk -Name[da]=Volapyk -Name[eo]=Volapuko -Name[fa]=ولاپوک -Name[he]=וולפיק -Name[hi]=वोलापक -Name[ja]=ボラピューク語 -Name[ka]=ვáƒáƒšáƒáƒžáƒ˜áƒ£áƒ™áƒ˜ -Name[kk]=Волапюк -Name[km]=វូឡាភូក -Name[mk]=Волапук -Name[mn]=Волапүк -Name[ne]=भोलापà¥à¤• -Name[nl]=Volapúk -Name[nn]=Volapyk -Name[nso]=Se-Volapük -Name[pa]=ਵੂਲਾਉਕ -Name[ro]=Volapucă -Name[ru]=Волапюк -Name[rw]=Ikivolapuke -Name[se]=Volapükgiella -Name[sk]=volapük -Name[sl]=volapük -Name[sq]=Volapisht -Name[sr]=ВолапикÑки -Name[sr@Latn]=Volapikski -Name[ss]=Si-Volapük -Name[ta]=வொலà¯à®ªà®¾à®•à¯ -Name[te]=వొలపà±à°•à± -Name[tg]=Волапёкӣ -Name[th]=ภาษาวอลาพุค -Name[tt]=Volapükçä -Name[uk]=Волапюк -Name[uz]=Volapuk -Name[uz@cyrillic]=Волапук -Name[vi]=Vo-la-puc -Name[zh_CN]=沃拉普克语 -Name[zu]=Isi-Volapük -[wa] -Name=Walloon -Name[ar]=الوالون -Name[az]=Valonca -Name[be]=ВалонÑÐºÐ°Ñ -Name[bg]=ВалонÑки -Name[bn]=ওয়ালà§à¦¨ -Name[br]=Walloneg -Name[bs]=Valonski -Name[cs]=Wallonský -Name[csb]=WaloÅ„sczi -Name[da]=Vallonsk -Name[de]=Wallonisch -Name[eo]=Valona -Name[et]=Vallooni -Name[eu]=Waloiera -Name[fa]=والونی -Name[fi]=Valloni -Name[fr]=Wallon -Name[fy]=Waalsk -Name[ga]=Vallúnais -Name[gl]=Valón -Name[he]=וולונית -Name[hi]=वालून -Name[hr]=Valonski -Name[hsb]=Walloonisce -Name[hu]=Vallon -Name[id]=Wallon -Name[is]=Vallónska -Name[it]=Vallone -Name[ja]=ワロン語 -Name[ka]=ვáƒáƒšáƒáƒœáƒ£áƒ áƒ˜ -Name[kk]=Валонша -Name[km]=វ៉ាឡុង -Name[ko]=왈론어 -Name[ku]=Walûn -Name[lb]=Wallounesch -Name[lt]=Valonų -Name[lv]=Valoņu -Name[mk]=ВалонÑки -Name[mn]=Валлоон -Name[nb]=Vallonsk -Name[nds]=Walloonsch -Name[ne]=वालोन -Name[nl]=Waals -Name[nn]=Vallonsk -Name[nso]=Se-Walloon -Name[oc]=Valon -Name[pa]=ਵਾਲੂਨ -Name[pl]=WaloÅ„ski -Name[pt]=Valão -Name[ro]=Valonă -Name[ru]=ВаллонÑкий -Name[rw]=Ikiwaluni -Name[se]=Vallonagiella -Name[sk]=valónÄina -Name[sl]=walloonsko -Name[sq]=Uallunisht -Name[sr]=ВалонÑки -Name[sr@Latn]=Valonski -Name[ss]=Si-Walloon -Name[sv]=Vallonska -Name[ta]=வாலூன௠-Name[te]=వాలూనౠ-Name[tg]=Валунӣ -Name[th]=ภาษาวัลลูน -Name[tr]=Valonca -Name[tt]=Walonça -Name[uk]=ВаллонÑька -Name[uz]=Valloncha -Name[uz@cyrillic]=Валлонча -Name[vi]=Oua-lunh -Name[wa]=Walon -Name[zh_CN]=瓦龙语 -Name[zh_HK]=è¯éš†èªž -Name[zh_TW]=è¯éš†èªž -Name[zu]=Isi-Walloon -[wo] -Name=Wolof -Name[ar]=الوولو٠-Name[az]=Volofca -Name[be]=Волаф -Name[bg]=Уолоф -Name[bn]=ওয়োলফ -Name[cy]=Woloff -Name[eo]=Volofa -Name[et]=Volofi -Name[eu]=Wolofera -Name[fa]=ولو٠-Name[ga]=Volaifis -Name[he]=וולוף -Name[hi]=वालाफ़ -Name[hr]=Volofski -Name[hu]=Volof -Name[ja]=ウォロフ語 -Name[ka]=უáƒáƒšáƒáƒ¤áƒ˜ -Name[kk]=Волофша -Name[km]=វូឡុហ្វ -Name[lb]=Wolof-Sprooch -Name[mk]=Волоф -Name[mn]=Волоф -Name[ne]=वलोफ -Name[nso]=Se-Wolof -Name[pa]=ਵੂਲੂਫ -Name[ro]=Volofă -Name[ru]=Уолоф -Name[rw]=Ikiwolofu -Name[se]=Volofagiella -Name[sk]=wolof -Name[sl]=wolof -Name[sq]=Ollofisht -Name[sr]=ВолофÑки -Name[sr@Latn]=Volofski -Name[ss]=Si-Wolof -Name[ta]=வொலொஃப௠-Name[te]=వొలొఫౠ-Name[tg]=Волофӣ -Name[th]=ภาษาวอลอฟ -Name[tt]=Wolofça -Name[uk]=Волоф -Name[uz]=Volof -Name[uz@cyrillic]=Волоф -Name[vi]=Ouo-lo-ph -Name[zh_CN]=沃洛夫语 -Name[zh_HK]=Wolof語 -Name[zh_TW]=Wolof語 -Name[zu]=Isi-Wolof -[xh] -Name=Xhosa -Name[ar]=الهاوسا -Name[be]=КшоÑа -Name[bg]=КÑоÑа -Name[bn]=জোসা -Name[de]=isiXhosa -Name[eo]=Ĥosa -Name[eu]=Xhosera -Name[fa]=زسایی -Name[ga]=Cóisis -Name[he]=קוזה -Name[hi]=à¤à¥‹à¤¸à¤¾ -Name[hu]=Xhosza -Name[ja]=コサ語 -Name[ka]=ქშáƒáƒ¡áƒ -Name[kk]=КхоÑа -Name[km]=ឃសាLesotho -Name[ko]=엑스호사어 -Name[mk]=КÑоÑа -Name[mn]=ЧоÑа -Name[ne]=होजा -Name[nso]=Sethosa -Name[pa]=à¨à©‹à¨¸à¨¾ -Name[ru]=КшоÑа -Name[rw]=Ikigisosa -Name[se]=Xhosagiella -Name[sk]=xhosa -Name[sl]=xhosa -Name[sq]=Gjosisht -Name[sr]=ЗоÑа -Name[sr@Latn]=Zosa -Name[ss]=SiXhosa -Name[ta]=சோசா -Name[te]=à°•à±à°œà±Šà°¸à°¾ -Name[tg]=ХоÑа -Name[th]=ภาษาโคซา -Name[uk]=КÑоза -Name[uz@cyrillic]=ХҳоÑа -Name[ven]=Xhoza -Name[vi]=Xô-xa -Name[wa]=Xhossa -Name[xh]=isixhosa -Name[zh_CN]=科è¨è¯­ -Name[zh_HK]=科薩語 -Name[zh_TW]=科薩語 -Name[zu]=Isi-Xhosa -[yi] -Name=Yiddish -Name[ar]=اليديش -Name[az]=YiddiÅŸcÉ™ -Name[be]=Ідыш -Name[bg]=Идиш -Name[bn]=য়িডà§à¦¡à¦¿à¦¶ -Name[bs]=JidiÅ¡ -Name[cs]=JidiÅ¡ -Name[csb]=Jidisz -Name[cy]=Yideg -Name[de]=Jiddish -Name[eo]=Jida -Name[et]=JidiÅ¡ -Name[eu]=Jiddish -Name[fa]=عبری -Name[fi]=JiddiÅ¡ -Name[fy]=Jiddysk -Name[ga]=Giúdais -Name[gl]=Iídiche -Name[he]=יידיש -Name[hi]=यिदिश -Name[hr]=JidiÅ¡ -Name[hsb]=Jidisce -Name[hu]=Jiddis -Name[is]=Jiddíska -Name[ja]=イディッシュ語 -Name[ka]=იდიში -Name[kk]=Идиш -Name[km]=យីឌីហ្ស -Name[ko]=ì´ë””시어 -Name[lb]=Jiddesch -Name[lt]=JidiÅ¡ -Name[lv]=JidiÅ¡Å¡ -Name[mk]=ЕврејÑки -Name[mn]=Юүд -Name[nb]=Jiddisk -Name[nds]=Jiddsch -Name[ne]=इडिस -Name[nn]=Jiddisk -Name[nso]=Se-Yiddish -Name[pa]=ਯੀਡਿਸ਼ -Name[pl]=Jidysz -Name[ro]=IdiÅŸ -Name[ru]=Идиш -Name[rw]=Ikiyidishi -Name[se]=JiddiÅ¡giella -Name[sk]=jidiÅ¡ -Name[sl]=yiddish -Name[sq]=Jidisht -Name[sr]=ЈидијÑки -Name[sr@Latn]=Jidijski -Name[ss]=Si-Yiddish -Name[ta]=யிடà¯à®Ÿà®¿à®·à¯ -Name[te]=యిడà±à°¡à°¿à°·à± -Name[tg]=Йидишӣ -Name[th]=ภาษายิดดิช -Name[tt]=YidiÅŸ -Name[uk]=Ідиш -Name[uz@cyrillic]=Йиддиш -Name[vi]=Y-đít -Name[wa]=Yidish -Name[zh_CN]=ä¾åœ°è¯­ -Name[zh_HK]=æ„第緒語 -Name[zh_TW]=æ„第緒語 -Name[zu]=Isi-Yidishi -[yo] -Name=Yoruba -Name[ar]=اليوروبا -Name[az]=Yorubaca -Name[be]=Яруба -Name[bg]=Йоруба -Name[bn]=য়োরà§à¦¬à¦¾ -Name[eo]=Joruba -Name[et]=Joruba -Name[eu]=Jorubera -Name[fa]=یوروبا -Name[fi]=Joruba -Name[ga]=Iarúibis -Name[gl]=Yorùbá -Name[he]=יורובה -Name[hi]=योरà¥à¤¬à¤¾ -Name[hu]=Joruba -Name[ja]=ヨルãƒèªž -Name[ka]=იáƒáƒ áƒ£áƒ‘რ-Name[kk]=Йоруба -Name[km]=យរូបា -Name[ko]=요루바어 -Name[lb]=Yoruba-Sprooch -Name[lv]=Jarubu -Name[mk]=Јоруба -Name[mn]=Ðруба -Name[ne]=योरूबा -Name[nn]=Joruba -Name[nso]=Se-Yoruba -Name[pa]=ਯੂਰੋਬਾ -Name[ro]=Iorubă -Name[ru]=Йоруба -Name[rw]=Ikiyoruba -Name[se]=Jorubagiella -Name[sk]=jorubÄina -Name[sl]=yoruba -Name[sq]=Jorubisht -Name[sr]=ЈорубÑки -Name[sr@Latn]=Jorubski -Name[ss]=Si-Yoruba -Name[ta]=யொரூபா -Name[te]=యొరà±à°¬à°¾ -Name[tg]=Ðруба -Name[th]=ภาษาโยรูบา -Name[tt]=Yorubaça -Name[uk]=Йоруба -Name[uz@cyrillic]=Ðруба -Name[vi]=Yô-ru-ba -Name[wa]=Yorouba -Name[zh_CN]=约é²å·´è¯­ -Name[zh_HK]=優魯巴語 -Name[zh_TW]=優魯巴語 -Name[zu]=Isi-Yoruba -[za] -Name=Zhuang -Name[ar]=الزهوانغ -Name[az]=Zhuangca -Name[be]=Цванг -Name[bg]=Жуанг -Name[bn]=à¦à§à§Ÿà¦¾à¦‚ -Name[et]=Zhuangi -Name[fa]=هونگ -Name[ga]=Siuáingis -Name[gl]=Chuan -Name[he]=×’'ו×× ×’ -Name[hi]=à¤à¥à¤†à¤‚ग -Name[ja]=ãƒãƒ¥ãƒ¯ãƒ³èªž -Name[ka]=ჩჟუáƒáƒœáƒ˜ -Name[kk]=Зуангша -Name[km]=ចួង -Name[mk]=Жуанг -Name[mn]=Жунгаа -Name[ne]=à¤à¤¿à¤†à¤™ -Name[nso]=Se-Zhuang -Name[pa]=ਜ਼ੂੰਗ -Name[ru]=Чжуанг -Name[rw]=Ikizwange -Name[se]=Zhuangagiella -Name[sk]=ÄuangÄina -Name[sl]=zhuang -Name[sq]=Zhuanginsht -Name[sr]=Цуанг -Name[sr@Latn]=Cuang -Name[ss]=Si-Zhuang -Name[ta]=சà¯à®µà®¾à®™à¯ -Name[te]=à°œà±à°µà°¾à°‚à°—à± -Name[tg]=Жуанг -Name[th]=ภาษาจ้วง -Name[tt]=Cuañça -Name[uk]=Жуан -Name[uz]=Zxuang -Name[uz@cyrillic]=Зхуанг -Name[vi]=Xuang -Name[zh_CN]=壮语 -Name[zh_HK]=Zhuang語 -Name[zh_TW]=Zhuang語 -Name[zu]=Isi-Zhuang -[zh] -Name=Chinese -Name[af]=Sjinese -Name[ar]=الصينية -Name[az]=ÇincÉ™ -Name[be]=КітайÑÐºÐ°Ñ -Name[bg]=КитайÑки -Name[bn]=চৈনিক -Name[br]=Sinaeg -Name[bs]=Kineski -Name[ca]=Xinès -Name[cs]=Čínský -Name[csb]=ChiÅ„sczi -Name[cy]=Tseineeg -Name[da]=Kinesisk -Name[de]=Chinesisch -Name[el]=Κινέζικα -Name[eo]=Ĉina -Name[es]=Chino -Name[et]=Hiina -Name[eu]=Txinera -Name[fa]=چینی -Name[fi]=Kiina -Name[fr]=Chinois -Name[fy]=Sjineesk -Name[ga]=Sínis -Name[gl]=Chinés -Name[he]=סינית -Name[hi]=चाइनीस -Name[hr]=Kineski -Name[hsb]=Chinsce -Name[hu]=Kínai -Name[id]=Cina -Name[is]=Kínverska -Name[it]=Cinese -Name[ja]=中国語 -Name[ka]=ჩინური -Name[kk]=Қытайша -Name[km]=áž…áž·áž“ -Name[ko]=중국어 -Name[ku]=Çînî -Name[lb]=Chinesesch -Name[lt]=KinieÄių -Name[lv]=ĶīnieÅ¡u -Name[mi]=Reo Häina -Name[mk]=КинеÑки -Name[mn]=Ð¥Ñтад -Name[ms]=China -Name[mt]=ÄŠiniż -Name[nb]=Kinesisk -Name[nds]=Chineesch -Name[ne]=चिनियाठ-Name[nl]=Chinees -Name[nn]=Kinesisk -Name[nso]=Se-China -Name[oc]=Chinès -Name[pa]=ਚੀਨੀ -Name[pl]=ChiÅ„ski -Name[pt]=Chinês -Name[pt_BR]=Chinês -Name[ro]=Chineză -Name[ru]=КитайÑкий -Name[rw]=Igishinwa -Name[se]=Kiinnágiella -Name[sk]=ÄínÅ¡tina -Name[sl]=kitajsko -Name[sq]=Kinezisht -Name[sr]=КинеÑки -Name[sr@Latn]=Kineski -Name[ss]=SiShayina -Name[sv]=Kinesiska -Name[ta]=சீனம௠-Name[te]=చైనీసౠ-Name[tg]=Хитоӣ -Name[th]=ภาษาจีน -Name[tr]=Çince -Name[tt]=Çinçä -Name[uk]=КитайÑька -Name[uz]=Xitoycha -Name[uz@cyrillic]=Хитойча -Name[ven]=Mutshaina -Name[vi]=Trung quốc -Name[wa]=Chinwès -Name[xh]=Isitshayina -Name[zh_CN]=中文 -Name[zh_HK]=中文 -Name[zh_TW]=中文 -Name[zu]=Isi-Shayina -[zh_CN] -Name=Chinese Simplified -Name[af]=Sjinese vereenvoudig -Name[be]=КітайÑÐºÐ°Ñ ÑÐ¿Ñ€Ð¾ÑˆÑ‡Ð°Ð½Ð°Ñ -Name[bg]=КитайÑки опроÑтен -Name[bn]=সরলীকৃত চৈনিক -Name[br]=Sineg eeun -Name[bs]=Kineski pojednostavljeni -Name[ca]=Xinès simplificat -Name[cs]=Čínský (zjednoduÅ¡ená) -Name[csb]=ChiÅ„sczi Prosti -Name[cy]=Tseineeg Syml -Name[da]=Kinesisk simplificeret -Name[de]=Chinesisch (vereinfachtes) -Name[el]=Κινέζικα απλά -Name[eo]=Simpla Ĉina -Name[es]=Chino simplificado -Name[et]=Hiina (lihtsustatud) -Name[eu]=Txinatar soildua -Name[fa]=زبان چینی ساده‌شده -Name[fi]=Yksinkertaistettu kiina -Name[fr]=Chinois simplifié -Name[fy]=Sjineesk (ynfaldich) -Name[ga]=Sínis Simplithe -Name[gl]=Chinés simplificado -Name[he]=סינית מופשטת -Name[hr]=Kineski pojednostavljen -Name[hsb]=Chinsce (zjednorjene) -Name[hu]=Kínai (egyszerűsített) -Name[id]=Cina Sederhana -Name[is]=Einfölduð kínverska -Name[it]=Cinese semplificato -Name[ja]=中国語 簡体字 -Name[ka]=ჩინური გáƒáƒ›áƒáƒ áƒ¢áƒ˜áƒ•áƒ”ბული -Name[kk]=Жеңілдеткен қытайша -Name[km]=ចិនសាមញ្ញ -Name[ku]=Çîniya Hesankirî -Name[lb]=Einfacht Chinesesch -Name[lt]=Kinų supaprastinta -Name[lv]=ĶīnieÅ¡u vienkÄrÅ¡otÄ -Name[mk]=КинеÑки поедноÑтавен -Name[nb]=Forenklet kinesisk -Name[nds]=Vereenfacht Chineesch -Name[ne]=सरलीकृत चिनियाठ-Name[nl]=Chinees (Vereenvoudigd) -Name[nn]=Kinesisk (forenkla) -Name[pa]=ਚੀਨੀ ਸਧਾਰਨ -Name[pl]=ChiÅ„ski uproszczony -Name[pt]=Chinês Simplificado -Name[pt_BR]=Chinês Simplificado -Name[ro]=Chineză simplificată -Name[ru]=КитайÑкий (КÐР) -Name[rw]=Igishinwa Cyoroheje -Name[se]=Ãlkiduvvon kiinnágiella -Name[sk]=ÄínÅ¡tina (zjednoduÅ¡ená) -Name[sl]=poenostavljeno kitajsko -Name[sr]=ПоједноÑтављени кинеÑки -Name[sr@Latn]=Pojednostavljeni kineski -Name[sv]=Förenklad kinesiska -Name[ta]=சீனம௠சà¯à®²à®ªà®®à®¾à®•à¯à®•à®ªà¯à®ªà®Ÿà¯à®Ÿà®¤à¯ -Name[te]=సరళికరించిన చైనీసౠ-Name[tg]=Хитоӣ (Оддӣ) -Name[th]=ภาษาจีนประยุà¸à¸•à¹Œ -Name[tr]=BasitleÅŸtirilmiÅŸ Çince -Name[tt]=Çinçä (Ciñel) -Name[uk]=КитайÑька (Ñпрощена) -Name[uz]=Soddalashtirilgan Xitoycha -Name[uz@cyrillic]=Соддалаштирилган Хитойча -Name[vi]=Trung quốc (phổ thông) -Name[zh_CN]=简体中文 -Name[zh_HK]=簡體中文 -Name[zh_TW]=簡體中文 -[zh_HK] -Name=Chinese (Hong Kong) -Name[be]=КітайÑÐºÐ°Ñ (Гонг-Конг) -Name[bg]=КитайÑки (Хонг Конг) -Name[br]=Sinaeg (Hong Kong) -Name[bs]=Kineski (Hong Kong) -Name[ca]=Xinès (Hong Kong) -Name[cs]=Čínský (Hong Kong) -Name[csb]=ChiÅ„sczi (Hong Kong) -Name[da]=Kinesisk (Hong Kong) -Name[de]=Chinesisch (Hongkong) -Name[el]=Κινέζικα (Χονγκ Κονγκ) -Name[eo]=Ĉina (Hong Kong) -Name[es]=Chino (Hong Kong) -Name[et]=Hiina (Hong Kong) -Name[eu]=Txinera (Hong Kong) -Name[fa]=چینی)هنگ Ú©Ù†Ú¯( -Name[fi]=Kiina (Hong Kong) -Name[fr]=Chinois (Hong Kong) -Name[fy]=Sjineesk (Hong Kong) -Name[ga]=Sínis (Hong Cong) -Name[gl]=Chinés (Hong Kong) -Name[he]=סינית (הונג קונג) -Name[hr]=Kineski (Hong Kong) -Name[hu]=Kínai (hongkongi) -Name[id]=Cina (Hong Kong) -Name[is]=Kínverska (Hong Kong) -Name[it]=Cinese (Hong Kong) -Name[ja]=中国語 (香港) -Name[ka]=ჩინური (ჰáƒáƒœáƒ’ კáƒáƒœáƒ’ი) -Name[kk]=Қытайша (СÑнган) -Name[km]=áž…áž·áž“ (ហុងកុង) -Name[ku]=Çînî (Hong Kong) -Name[lb]=Chinesesch (Hong Kong) -Name[lt]=KinieÄių (Honkongo) -Name[lv]=ĶīnieÅ¡u (Honkongas) -Name[mk]=КинеÑки (Хонг Конг) -Name[ms]=China (Hong Kong) -Name[nb]=Kinesisk (Hong kong) -Name[nds]=Chineesch (Hong Kong) -Name[ne]=चिनियाठ(हङकङ) -Name[nl]=Chinees (Hong Kong) -Name[nn]=Kinesisk (Hong Kong) -Name[pa]=ਚੀਨੀ (ਹਾਂਗਕਾਂਗ) -Name[pl]=ChiÅ„ski (Hong Kong) -Name[pt]=Chinês (Hong Kong) -Name[pt_BR]=Chinês (Hong Kong) -Name[ro]=Chineză (Hong Kong) -Name[ru]=КитайÑкий (Гонконг) -Name[se]=Kiinnágiella (Hong Kong) -Name[sk]=ÄínÅ¡tina (Hongkong) -Name[sl]=kitajsko (Hong Kong) -Name[sr]=КинеÑки (Хонгконг) -Name[sr@Latn]=Kineski (Hongkong) -Name[sv]=Kinesiska (Hong Kong) -Name[te]=చైనీసౠ(హాంగౠకాంగà±) -Name[tg]=Хитоӣ (Гон-Конг) -Name[th]=ภาษาจีี (ฮ่องà¸à¸‡)น -Name[tr]=Çince (Hong Kong) -Name[uk]=КитайÑька (Гонконг) -Name[uz]=Xitoycha (Gongkong) -Name[uz@cyrillic]=Хитойча (Гонгконг) -Name[vi]=Trung quốc (Hồng Kông) -Name[zh_CN]=ç¹ä½“中文(香港) -Name[zh_TW]=正體中文(香港) -[zh_TW] -Name=Chinese Traditional -Name[af]=Sjinese tradisioneel -Name[be]=КітайÑÐºÐ°Ñ Ñ‚Ñ€Ð°Ð´Ñ‹Ñ†Ñ‹Ð¹Ð½Ð°Ñ -Name[bg]=КитайÑки традиционен -Name[bn]=পারমà§à¦ªà¦°à¦¿à¦• চৈনিক -Name[br]=Sinaeg da gustum -Name[bs]=Kineski tradicionalni -Name[ca]=Xinès tradicional -Name[cs]=Čínský (tradiÄní) -Name[csb]=ChiÅ„sczi Tradicëjny -Name[cy]=Tsieineeg Traddodiadol -Name[da]=Kinesisk traditionel -Name[de]=Chinesisch (traditionelles) -Name[el]=Κινέζικα παÏαδοσιακά -Name[eo]=Tradicia Ĉina -Name[es]=Chino tradicional -Name[et]=Hiina (traditsiooniline) -Name[eu]=Txinatar tradizionala -Name[fa]=چینی سنتی -Name[fi]=Perinteinen kiina -Name[fr]=Chinois traditionnel -Name[fy]=Sjineesk (tradisjoniel) -Name[ga]=Sínis Thraidisiúnta -Name[gl]=Chinés Tradicional -Name[he]=סינית מסורתית -Name[hr]=Kineski tradicionalan -Name[hsb]=Chinsce (tradicionalnje) -Name[hu]=Kínai (hagyományos) -Name[id]=Cina Tradisional -Name[is]=Hefðbundin kínverska -Name[it]=Cinese tradizionale -Name[ja]=中国語 ç¹ä½“å­— -Name[ka]=ჩინური ტრáƒáƒ“იციული -Name[kk]=ДәÑтүрлі қытайша -Name[km]=ចិន​បុរាណ -Name[ku]=Çîniya KevneÅŸop -Name[lb]=Traditionellt Chinesesch -Name[lt]=Kinų tradicinÄ— -Name[lv]=ĶīnieÅ¡u tradicionÄlÄ -Name[mk]=КинеÑки традиционален -Name[nb]=Tradisjonell kinesisk -Name[nds]=Traditschonell Chineesch -Name[ne]=चिनियाठपरमà¥à¤ªà¤°à¤¾à¤—त -Name[nl]=Chinees (Traditioneel) -Name[nn]=Kinesisk (tradisjonell) -Name[pa]=ਚੀਨੀ ਮੂਲ -Name[pl]=ChiÅ„ski tradycyjny -Name[pt]=Chinês Tradicional -Name[pt_BR]=Chinês Tradicional -Name[ro]=Chineză tradiÅ£ională -Name[ru]=КитайÑкий (Тайвань) -Name[rw]=Igishinwa Karande -Name[se]=ÃrbevirolaÅ¡ kiinnágiella -Name[sk]=ÄínÅ¡tina (tradiÄná) -Name[sl]=tradicionalno kitajsko -Name[sr]=Традиционални кинеÑки -Name[sr@Latn]=Tradicionalni kineski -Name[sv]=Traditionell kinesiska -Name[ta]=சீனம௠பழமையானத௠-Name[te]=సాంపà±à°°à°¦à°¾à°¯à°• చైనీసౠ-Name[tg]=Хитоӣ (Ðнъанавӣ) -Name[th]=ภาษาจีนดั้งเดิม -Name[tr]=Geleneksel Çince -Name[tt]=Çinçä (Ğädäti) -Name[uk]=КитайÑька (традиційна) -Name[uz]=Anʼanaviy Xitoycha -Name[uz@cyrillic]=Ðнъанавий Хитойча -Name[vi]=Trung quốc (truyá»n thống) -Name[zh_CN]=ç¹ä½“中文 -Name[zh_HK]=ç¹é«”中文 -Name[zh_TW]=正體中文 -[zu] -Name=Zulu -Name[af]=Zoeloe -Name[ar]=الزولو -Name[be]=ЗулуÑÐºÐ°Ñ -Name[bg]=Зулу -Name[bn]=জà§à¦²à§ -Name[br]=Zouloued -Name[csb]=Zulusczi -Name[eo]=Zulua -Name[es]=Zulú -Name[et]=Suulu -Name[eu]=Zuluera -Name[fa]=ناتالی -Name[fr]=Zoulou -Name[ga]=Súlúis -Name[he]=זולו -Name[hi]=ज़à¥à¤²à¥ -Name[is]=Zúlú -Name[ja]=ズールー語 -Name[ka]=ზულუსური -Name[kk]=Зулу -Name[km]=ហ្ស៊ូលូ -Name[ko]=줄루어 -Name[lv]=Zulusu -Name[mk]=Зулу -Name[mn]=Зулу -Name[mt]=Å»ulu -Name[ne]=जà¥à¤²à¥ -Name[nso]=Se-Zulu -Name[pa]=ਜ਼ੂਲੂ -Name[pl]=Zuluski -Name[ru]=ЗулуÑÑкий -Name[rw]=Ikizulu -Name[se]=Zulugiella -Name[sk]=zuluÅ¡tina -Name[sl]=zulu -Name[sr]=Зулу -Name[ss]=SiZulu -Name[ta]=ஜà¯à®²à¯ -Name[te]=జూలౠ-Name[tg]=Зулу -Name[th]=ภาษาซูลู -Name[tt]=Zuluça -Name[uk]=ЗулуÑька -Name[uz]=Zulucha -Name[uz@cyrillic]=Зулуча -Name[ven]=Muzulu -Name[vi]=Xu-lu -Name[wa]=Zoulou -Name[xh]=Isizulu -Name[zh_CN]=祖é²è¯­ -Name[zh_HK]=袓魯語 -Name[zh_TW]=袓魯語 -Name[zu]=Isi-Zulu diff --git a/kdecore/configure.in.in b/kdecore/configure.in.in deleted file mode 100644 index 7439a7c12..000000000 --- a/kdecore/configure.in.in +++ /dev/null @@ -1,234 +0,0 @@ -dnl Compile in the exec prefix to help kstddirs in finding dynamic libs -AC_DEFINE_UNQUOTED(__KDE_EXECPREFIX, "$exec_prefix", [execprefix or NONE if not set, for libloading]) - -dnl Compile in kde_bindir to safely find tdesu_stub. -if test "$exec_prefix" = "NONE"; then - bindir_str="\"$prefix/bin\"" -else - bindir_str="\"$exec_prefix/bin\"" -fi -AC_DEFINE_UNQUOTED(__KDE_BINDIR, $bindir_str, [KDE bindir]) - -dnl tests for openpty support -AC_MSG_CHECKING(whether we can use openpty) -AC_ARG_ENABLE(openpty, - [ --disable-openpty disable openpty (UNIX98 terminals) support [default=enabled]], - [ac_use_openpty=$enableval], [ac_use_openpty=yes]) -if test "$ac_use_openpty" = "yes"; then - kde_safe_LIBS=$LIBS - LIBS="$LIBS $LIBUTIL" - AC_TRY_RUN([ -#include - -int main(int argc, char* argv) { - int master_fd, slave_fd; - int result; - - result = openpty(&master_fd, &slave_fd, 0, 0, 0); - - return 0; -} -], [ac_use_openpty="yes"], [ac_use_openpty="no"]) - LIBS=$kde_safe_LIBS -fi -if test "$ac_use_openpty" = "yes"; then - AC_DEFINE(HAVE_OPENPTY, 1, [Defines whether we can use the openpty() function]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -dnl ------- -dnl Test for libidn (IDNA support) -dnl ------- - -AC_ARG_WITH(libidn, - [AC_HELP_STRING(--with-libidn, - [enable support for libidn @<:@default=check@:>@])], - [], with_libidn=check) -LIB_IDN= -if test "x$with_libidn" != xno; then - AC_CHECK_HEADERS([idna.h punycode.h stringprep.h]) - KDE_CHECK_LIB(idn, idna_to_ascii_4i, [ - AC_DEFINE_UNQUOTED(HAVE_LIBIDN, 1, [Defined if you have libidn in your system]) - LIB_IDN=-lidn - ]) - if test "x$with_libidn" != xcheck && test -z "$LIB_IDN"; then - AC_MSG_ERROR([--with-libidn was given, but test for libidn failed]) - fi -fi -AC_SUBST(LIB_IDN) - -dnl -------- -dnl KNetwork extra configuration -dnl -------- - -netincludes="#include -#include -#include " - -kde_safe_LIBS="$LIBS" -LIBS="$LIBS $all_libraries $X_EXTRA_LIBS" -AC_CHECK_FUNCS([inet_ntop inet_pton getpeername getsockname getsockopt gethostbyname2_r gethostbyname_r gethostbyname2 if_nametoindex getprotobyname_r getservbyname_r getservbyport_r]) -LIBS="$kde_safe_LIBS" - -dnl -dnl Some systems, like OpenBSD 3.6, have getservbyname_r but don't declare it -dnl -if test "x$ac_cv_func_getservbyname_r" = "xyes"; then - - AC_CHECK_DECLS([getservbyname_r],,,[$netincludes]) - -fi - -KDE_CHECK_HEADERS([netinet/in.h net/if.h],,,[$netincludes]) -KDE_CHECK_HEADERS([sys/filio.h]) -AC_CHECK_FUNCS([usleep poll madvise]) - -dnl Check for struct addrinfo -AC_CHECK_TYPES([struct addrinfo],,,[$netincludes]) - -kde_safe_LIBS="$LIBS" -LIBS="$LIBS $LIBSOCKET" -AC_CHECK_FUNCS([getaddrinfo], - [ - dnl Even though we now know that getaddrinfo is there, make sure getnameinfo is there too - kde_gai_ok=true - AC_CHECK_FUNCS([freeaddrinfo getnameinfo gai_strerror], : , - [ - kde_gai_ok=false - AC_DEFINE(HAVE_BROKEN_GETADDRINFO, 1, [Define if getaddrinfo is broken and should be replaced]) - AC_DEFINE(GETADDRINFO_RETURNS_UNIX, 1, [Define if getaddrinfo returns AF_UNIX sockets]) - break - ]) - - AC_MSG_CHECKING([if getaddrinfo works using numeric service with null host]) - dnl On AIX (4.3), getaddrinfo returns NULL if the hint - dnl is AF_INET/SOCK_STREAM/AI_PASSIVE. - dnl The error code reports "Host not found". - dnl It only seems to return non-NULL if the port is known (eg. in - dnl /etc/services). - AC_TRY_RUN(dnl - [ - #include - #include - #include - #include - int main() - { - struct addrinfo hint, *res; - int err; - memset(&hint, 0, sizeof(hint)); - hint.ai_family = AF_INET; - hint.ai_protocol = 0; - hint.ai_socktype = SOCK_STREAM; - hint.ai_flags = AI_PASSIVE; - err = getaddrinfo(0, "18300", &hint, &res); /* kxmlrpc tries this */ - if (err != 0 || res == 0 || res->ai_family != AF_INET) - return 1; - return 0; - } - ], - [ - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE(HAVE_BROKEN_GETADDRINFO, 1, [Define if getaddrinfo is broken and should be replaced]) - ], - [ - AC_MSG_RESULT(cross compiling. We hope so) - ]) - ] -) -LIBS="$kde_safe_LIBS" - -AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#include ]) -AC_CHECK_TYPES([struct sockaddr_in6], - [AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id],,,[#include ])],, - [#include -#include ]) - -AC_MSG_CHECKING([for GLIBC function backtrace]) -AC_TRY_LINK(dnl - [ - #include - ], - [ - void* trace[256]; - backtrace(trace, 256); - ], - [ - AC_DEFINE(HAVE_BACKTRACE, 1, [Define if execinfo.h exists and defines backtrace (GLIBC >= 2.1)]) - AC_MSG_RESULT(yes) - ], - AC_MSG_RESULT(no) -) - -AC_CHECK_HEADERS(sys/mount.h) - -dnl AC_OUTPUT(tdecore/kde-config.cpp) - -AM_CONFIG_HEADER(tdecore/kdemacros.h) - -SVGICONS= - -AC_ARG_WITH(libart, - [AC_HELP_STRING(--with-libart, - [enable support for libart @<:@default=check@:>@])], - [], with_libart=check) - -if test "x$with_libart" != xno; then - KDE_FIND_PATH(libart2-config, LIBART_CONFIG, [${prefix}/bin ${exec_prefix}/bin], [ - AC_MSG_WARN([Could not find libart anywhere, check http://www.levien.com/libart/]) - ]) - - if test -n "$LIBART_CONFIG"; then - vers=`$LIBART_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` - if test -n "$vers" && test "$vers" -ge 2003008 - then - LIBART_LIBS="`$LIBART_CONFIG --libs`" - LIBART_RPATH= - for args in $LIBART_LIBS; do - case $args in - -L/usr/lib) ;; - -L*) - LIBART_RPATH="$LIBART_RPATH $args" - ;; - esac - done - LIBART_RPATH=`echo $LIBART_RPATH | sed -e "s/-L/-R/g"` - LIBART_CFLAGS="`$LIBART_CONFIG --cflags`" - SVGICONS=svgicons - - AC_DEFINE_UNQUOTED(HAVE_LIBART, 1, [Defines if your system has the libart library]) - else - AC_MSG_WARN([You need at least libart 2.3.8]) - fi - fi - if test "x$with_libart" != xcheck && test -z "$LIBART_LIBS"; then - AC_MSG_ERROR([--with-libart was given, but test for libart failed]) - fi -fi - - -AC_SUBST(LIBART_LIBS) -AC_SUBST(LIBART_CFLAGS) -AC_SUBST(LIBART_RPATH) -AM_CONDITIONAL(include_SVGICONS, test -n "$SVGICONS") - -AC_CHECK_HEADERS([sys/stropts.h sys/select.h libutil.h util.h termios.h pty.h termio.h]) -AC_MSG_CHECKING([for revoke(tty) in unistd.h]) -AC_TRY_LINK(dnl - [ - #include - ], - [ - revoke("/dev/tty"); - ], - [ - AC_DEFINE(HAVE_REVOKE, 1, [Define if revoke(tty) is present in unistd.h]) - AC_MSG_RESULT(yes) - ], - AC_MSG_RESULT(no) -) diff --git a/kdecore/eventsrc b/kdecore/eventsrc deleted file mode 100644 index 0377e819a..000000000 --- a/kdecore/eventsrc +++ /dev/null @@ -1,2741 +0,0 @@ -[!Global!] -IconName=kmenu -Comment=KDE System Notifications -Comment[af]=KDE Stelsel Inkennistelling -Comment[ar]=تنبيهات كيدي -Comment[az]=KDE Sistem BildiriÅŸlÉ™ri -Comment[be]=СіÑÑ‚ÑÐ¼Ð½Ñ‹Ñ Ð½Ð°Ð³Ð°Ð´Ð²Ð°Ð½Ð½Ñ– KDE -Comment[bg]=СиÑтемни ÑÑŠÐ¾Ð±Ñ‰ÐµÐ½Ð¸Ñ -Comment[bn]=কে.ডি.ই সিসà§à¦Ÿà§‡à¦® বারà§à¦¤à¦¾à¦¬à¦²à§€ -Comment[br]=Kemennoù ar reizhiad KDE -Comment[bs]=KDE Sistemska obavjeÅ¡tenja -Comment[ca]=Notificacions del sistema KDE -Comment[cs]=Systémová hlášení prostÅ™edí KDE -Comment[csb]=Systemòwé òdkôzanié w KDE -Comment[cy]=Hysbysiadau Cysawd KDE -Comment[da]=KDE-systembekendtgørelser -Comment[de]=KDE-Systemnachrichten -Comment[el]=Ειδοποιήσεις συστήματος του KDE -Comment[eo]=KDE-Sistematentigoj -Comment[es]=Notificaciones del sistema de KDE -Comment[et]=KDE süsteemi märguanded -Comment[eu]=KDEren sistemako jakinarazpenak -Comment[fa]=اخطارهای سیستم KDE -Comment[fi]=KDE:n järjestelmähuomautukset -Comment[fr]=Notifications du système KDE -Comment[fy]=KDE Systeemberjochten -Comment[ga]=Fógairt Chórais KDE -Comment[gl]=Notificacións do Sistema de KDE -Comment[he]=הודעות מערכת של KDE -Comment[hi]=केडीई तंतà¥à¤° सूचना -Comment[hr]=KDE sistemske obavijesti -Comment[hsb]=KDE systemowe powÄ›sće -Comment[hu]=KDE rendszerüzenetek -Comment[id]=Sistem Pemberitahuan KDE -Comment[is]=Tilkynningar KDE kerfisins -Comment[it]=Avvisi di sistema di KDE -Comment[ja]=KDE システム通知 -Comment[ka]=KDE სისტემური შეტყáƒáƒ‘ინებები -Comment[kk]=KDE жүйе құлақтандырулар -Comment[km]=ការ​ជូន​ដំណឹង​អំពី​ប្រពáŸáž“្ធ​របស់ KDE -Comment[ko]=KDE 시스템 알림 -Comment[lb]=KDE-System-Norichten -Comment[lt]=KDE Sistemos PraneÅ¡imai -Comment[lv]=KDE SistÄ“mas Paziņojumi -Comment[mk]=KDE ÑиÑтемÑки извеÑтувања -Comment[mn]=KDE-СиÑтемийн Ñонордуулга -Comment[ms]= Sistem Pemberitahuan KDE -Comment[mt]=Notifiki tas-sistema KDE -Comment[nb]=KDE Systemvarsler -Comment[nds]=KDE-Systeemnarichten -Comment[ne]=KDE पà¥à¤°à¤£à¤¾à¤²à¥€ सूचना -Comment[nl]=KDE Systeemnotificaties -Comment[nn]=KDE SystempÃ¥minningar -Comment[nso]=Ditsebiso tsa System ya KDE -Comment[oc]=Notificacions dèu sistemo KDE -Comment[pa]=KDE ਸਿਸਟਮ ਟਿੱਪਣੀਆਂ -Comment[pl]=Powiadamianie systemowe w KDE -Comment[pt]=Mensagens do sistema -Comment[pt_BR]=Notificações de sistema do KDE -Comment[ro]=Sistem de notificare KDE -Comment[ru]=СиÑтемные ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ KDE -Comment[rw]=Amamenyekanisha ya Sisitemu KDE -Comment[se]=KDE vuogádatdieđáhusat -Comment[sk]=KDE Systémové správy -Comment[sl]=Sistemska obvestila KDE -Comment[sq]=Njoftim nga Sistemi KDE -Comment[sr]=KDE-ова ÑиÑтемÑка обавештења -Comment[sr@Latn]=KDE-ova sistemska obaveÅ¡tenja -Comment[ss]=Tatiso temshini we KDE -Comment[sv]=KDE:s systemunderrättelser -Comment[ta]=கேடிஇ கணினி அறிவிபà¯à®ªà¯à®•à®³à¯ -Comment[te]=కెడిఈ à°µà±à°¯à°µà°¸à±à°¥ à°ªà±à°°à°•à°Ÿà°¨à°²à± -Comment[tg]=Хабарҳои ÑиÑтемавии KDE -Comment[th]=à¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•à¸·à¸­à¸™à¸‚องระบบ KDE -Comment[tr]=KDE Sistem Bildirimleri -Comment[tt]=KDE'nıñ Sistem Beldermäläre -Comment[uk]=СиÑтемні Ð¿Ð¾Ð²Ñ–Ð´Ð¾Ð¼Ð»ÐµÐ½Ð½Ñ KDE -Comment[uz]=KDE tizimning xabarnomalari -Comment[uz@cyrillic]=KDE тизимнинг хабарномалари -Comment[ven]=U divhadza maitele a KDE -Comment[vi]=Thông báo hệ thống KDE -Comment[wa]=Notifiaedjes sistinme di KDE -Comment[xh]=Izaziso Zendlela ye KDE -Comment[zh_CN]=KDE 系统通知 -Comment[zh_HK]=KDE 系統通知 -Comment[zh_TW]=KDE 系統通知 -Comment[zu]=Izaziso Zesistimu ye-KDE - -[Trash: emptied] -Name=Trash: emptied -Name[af]=Gemors: leeggemaak -Name[be]=Сметніца: парожнÑÑ -Name[bg]=Кошчето е изтрито -Name[bn]=আবরà§à¦œà¦¨à¦¾: ফাà¦à¦•à¦¾ -Name[br]=Pod-lastez : goullonderet -Name[bs]=Smeće: ispražnjeno -Name[ca]=Paperera: buida -Name[cs]=KoÅ¡ vyprázdnÄ›n -Name[csb]=Kòsz: wëczëszczony -Name[da]=Affald: tømt -Name[de]=Mülleimer: geleert -Name[el]=Ο Κάδος ΑποÏÏιμμάτων άδειασε -Name[en_GB]=Wastebin: emptied -Name[eo]=Rubujo: Malplena -Name[es]=Papelera: vaciada -Name[et]=Prügikast: tühjendatud -Name[eu]=Zakarrontzia: hustuta -Name[fa]=زباله: خالی‌شده -Name[fi]=Roskakori: tyhjennetty -Name[fr]=Corbeille : vidée -Name[fy]=Jiskefet: leech makke -Name[ga]=Bruscar: folmhaithe -Name[gl]=Lixo: valeirado -Name[he]=×שפה: רוקן -Name[hr]=Otpad: ispražnjeno -Name[hsb]=Papjernik: wuprózdnjeny -Name[hu]=Szemétkosár: kiürítve -Name[id]=Tempat Sampah: emptied -Name[is]=Rusl: tæmt -Name[it]=Cestino: svuotato -Name[ja]=ã”ã¿ç®±: 空 -Name[ka]=ურნáƒ: ცáƒáƒ áƒ˜áƒ”ლირ-Name[kk]=Өшірігендер жойылды -Name[km]=ធុង​សំរាម ៖ បាន​សម្អាហ-Name[lb]=Dreckskëscht: eidel -Name[lt]=Å iukÅ¡liadėžė: iÅ¡tuÅ¡tinta -Name[lv]=Miskaste: iztukÅ¡ota -Name[mk]=Корпа: празна -Name[ms]=Tong Sampah; dikosongkan -Name[nb]=Papirkurven: tømt -Name[nds]=Affalltünn: leddigmaakt -Name[ne]=रदà¥à¤¦à¥€à¤Ÿà¥‹à¤•à¤°à¥€: रितà¥à¤¤à¤¿à¤¯à¥‹ -Name[nl]=Prullenbak: geleegd -Name[nn]=Papirkorg: tømt -Name[pa]=ਰੱਦੀ: ਖਾਲੀ ਕੀਤੀ ਗਈ -Name[pl]=Kosz: opróżniony -Name[pt]=Lixo: esvaziado -Name[pt_BR]=Lixeira: vazia -Name[ro]=Gunoi: golit -Name[ru]=Корзина очищена -Name[rw]=Agatebo: gafite ubusa -Name[se]=Ruskalihtti: gurrejuvvon -Name[sk]=KoÅ¡: vyprázdnený -Name[sl]=Smeti: izpraznjeno -Name[sr]=Смеће: иÑпражњено -Name[sr@Latn]=Smeće: ispražnjeno -Name[sv]=Papperskorg: tömd -Name[ta]=தொடà¯à®Ÿà®¿: காலியாகà¯à®•à®ªà¯à®ªà®Ÿà¯à®Ÿà®¤à¯ -Name[te]=చెతà±à°¤ : ఖాళి -Name[tg]=Ðхлотдон: тозашуда -Name[th]=ถังขยะ: เททิ้ง -Name[tr]=Çöp: boÅŸaltıldı -Name[tt]=Çüplek: buÅŸatıldı -Name[uk]=Смітник: Ñпорожнено -Name[uz]=Chiqindilar qutisi boÊ»shatildi -Name[uz@cyrillic]=Чиқиндилар қутиÑи бўшатилди -Name[vi]=Rác: đã đổ -Name[zh_CN]=回收站:已清空 -Name[zh_TW]=資æºå›žæ”¶æ¡¶å·²æ¸…空 -Comment=The trash has been emptied -Comment[af]=Die gemors is leeggemaak -Comment[be]=Сметніца парожнÑÑ -Comment[bg]=Съдържанието а кошчето е изтрито -Comment[bn]=আবরà§à¦œà¦¨à¦¾à¦° বাকà§à¦¸ ফাà¦à¦•à¦¾ করা হয়েছে -Comment[br]=Goullonderet e oa ar pod-lastez -Comment[bs]=Smeće je ispražnjeno -Comment[ca]=S'ha buidat la paperera -Comment[cs]=KoÅ¡ byl vyprázdnÄ›n -Comment[csb]=Kòsz òstôł wëczëszczony -Comment[da]=Affaldet er blevet tømt ud -Comment[de]=Der Mülleimer wurde geleert -Comment[el]=Ο Κάδος ΑποÏÏιμμάτων άδειασε -Comment[en_GB]=The wastebin has been emptied -Comment[eo]=la rubujo malpleniÄis -Comment[es]=La papelera se ha vaciado -Comment[et]=Prügikast on tühjendatud -Comment[eu]=Zakarrontzia hustu da -Comment[fa]=زباله خالی شده است -Comment[fi]=Roskakori on tyhjennetty -Comment[fr]=La corbeille a été vidée -Comment[fy]=It jiskefet is leech makke -Comment[ga]=Folmhaíodh an bruscar -Comment[gl]=O lixo foi valeirado -Comment[he]=פה ×”×שפה רוקן -Comment[hr]=Otpad je ispražnjen -Comment[hsb]=sym papjernik wuprózdniÅ‚ -Comment[hu]=A szemétkosár kiürült -Comment[id]=Tempat sampah sudah dikosongkan -Comment[is]=Ruslafatan hefur verið tæmd -Comment[it]=Il cestino è stato svuotato -Comment[ja]=ã”ã¿ç®±ã‚’空ã«ã—ã¾ã—㟠-Comment[ka]=ურნრდáƒáƒªáƒáƒ áƒ˜áƒ”ლდრ-Comment[kk]=Өшірілгендер қапшық тазарды -Comment[km]=ធុង​សំរាម​ážáŸ’រូវ​បាន​សម្អាហ-Comment[lb]=D'Dreckskëscht ass eidelgemat ginn -Comment[lt]=Å iukÅ¡liadėžė buvo iÅ¡tuÅ¡tinta -Comment[lv]=Miskaste ir iztukÅ¡ota -Comment[mk]=Корпата беше иÑпразнета -Comment[ms]=Tong sampah telah dikosongkan -Comment[nb]=Papirkurven er tømt -Comment[nds]=De Affalltünn wöör leddig maakt -Comment[ne]=रदà¥à¤¦à¥€à¤Ÿà¥‹à¤•à¤°à¥€ रितà¥à¤¤à¤¿à¤à¤•à¥‹ छ -Comment[nl]=De prullenbak is geleegd -Comment[nn]=Papirkorga er tømt -Comment[pa]=ਰੱਦੀ ਨੂੰ ਖਾਲੀ ਕੀਤਾ ਜਾ ਚà©à©±à¨•à¨¾ ਹੈ -Comment[pl]=Kosz zostaÅ‚ opróżniony -Comment[pt]=O lixo foi esvaziado -Comment[pt_BR]=A lixeira foi esvaziada -Comment[ro]=CoÅŸul de gunoi a fost golit -Comment[ru]=Корзина была очищена -Comment[rw]=Agatebo kavanywemo byose -Comment[se]=Ruskelihtti gurrejuvvui -Comment[sk]=Kôš bol vyprázdnený -Comment[sl]=Smeti so spraznjene -Comment[sr]=Смеће је иÑпражњено -Comment[sr@Latn]=Smeće je ispražnjeno -Comment[sv]=Papperskorgen har tömts -Comment[ta]=தொடà¯à®Ÿà®¿ காலியாகà¯à®•à®ªà¯à®ªà®Ÿà¯à®Ÿà®¤à¯ -Comment[te]=చెతà±à°¤ నౠపారబొయటమైనది -Comment[tg]=Ðхлотдон тоза карда шуд -Comment[th]=เทถังขยะทิ้งà¹à¸¥à¹‰à¸§ -Comment[tr]=Çöp boÅŸaltıldı -Comment[tt]=Çüplek buÅŸatılÄŸan buldı -Comment[uk]=Смітник було Ñпорожнено -Comment[uz]=Chiqindilar qutisi boÊ»shatildi -Comment[uz@cyrillic]=Чиқиндилар қутиÑи бўшатилди -Comment[vi]=Rác đã được đổ. -Comment[zh_CN]=回收站已被清空 -Comment[zh_TW]=資æºå›žæ”¶æ¡¶å·²æ¸…空。 -default_presentation=1 - -[Textcompletion: rotation] -Name=Textcompletion: rotation -Name[af]=Teksvoltooiïng: rotering -Name[ar]=اكمال نص: تدوير -Name[az]=Textcompletion: döndÉ™rmÉ™ -Name[be]=ЗаканчÑнне Ñ‚ÑкÑту: па колу -Name[bg]=Ðвтоматично завършване: завъртане -Name[bn]=Textcompletion: আবরà§à¦¤à¦¨ -Name[br]=KlokadurSrid : troerezh -Name[bs]=Textcompletion: rotacija -Name[ca]=Compleció de text: rotació -Name[cs]=Doplňování textu: rotace -Name[csb]=Dofùlowanié tekstu: rotacëjô -Name[cy]=CwblhauTestun: cylchdroi -Name[da]=Tekstkomplettering: rotation -Name[de]=Textvervollständigung: rotierend -Name[el]=ΣυμπλήÏωση κειμένου: πεÏιστÏοφή -Name[eo]=Kkompletigo: rotacio -Name[es]=Completado de texto: rotación -Name[et]=Teksti lõpetamine: pööramine -Name[eu]=Testu-osaketa: biraketa -Name[fa]=تکمیل متن: چرخش -Name[fi]=Tekstintäydennys: pyöritys -Name[fr]=Autocomplètement de texte : rotation -Name[fy]=Tekstkompletearing: rotaasje -Name[ga]=Comhlánú téacs: imchasadh -Name[gl]=Textcompletion: rotación -Name[he]=השלמת טקסט: רוטציה -Name[hi]=टेकà¥à¤¸à¥à¤Ÿ कमà¥à¤ªà¤²à¥€à¤¶à¤¨à¤ƒ रोटेशन -Name[hr]=Textcompletion: rotacija -Name[hsb]=WudospoÅ‚njenje teksta: rotacija -Name[hu]=Szövegkiegészítés: forgatás -Name[id]=Pemenuhanteks: rotasi -Name[is]=Textaklárun: snúningur -Name[it]=Completamento testo: rotazione -Name[ja]=テキスト補完: 繰り返㗠-Name[ka]=თვითშევსებáƒ: მáƒáƒ¢áƒ áƒ˜áƒáƒšáƒ”ბრ-Name[kk]=Ðвтотолтыру: бұрау -Name[km]=ការ​បំពáŸáž‰â€‹áž¢ážáŸ’ážáž”ទ ៖ ការ​បង្វិល -Name[ko]=글월 완성: 맴ëŒì´ -Name[lb]=Textergänzung: rotéierent -Name[lt]=Textcompletion: sukimas -Name[lv]=Tekstakomplekts: rotÄcija -Name[mk]=Довршување текÑÑ‚: ротација -Name[mn]=ТекÑÑ‚ гүйцÑÑлт: ÑргүүлÑлт -Name[ms]= Penyudah teks: putaran -Name[mt]=Kompletazzjoni tal-kliem: tidwir -Name[nb]=Tekstfullføring: rotering -Name[nds]=Textkompletteren: dreihen -Name[ne]=पाठ समापà¥à¤¤à¤¿: परिकà¥à¤°à¤®à¤£ -Name[nl]=Tekstaanvulling: rotatie -Name[nn]=Tekstfullføring: rotering -Name[nso]=Phetso ya sengwalwana: tharelo -Name[oc]=Textcompletion: rotacion -Name[pa]=Textcompletion: ਘà©à©°à¨®à¨¾à¨“ -Name[pl]=UzupeÅ‚nianie tekstu: rotacja -Name[pt]=Completação de texto: dei a volta -Name[pt_BR]=Completar Texto: rotação -Name[ro]=Completare text: rotire -Name[ru]=Ðвтозавершение: поворот -Name[rw]=Iyuzuzamwandiko: Ukuzenguruka -Name[se]=TeakstaollaÅ¡uhttin: joraheapmi -Name[sk]=Doplnenie textu:rotácia -Name[sl]=Dopolnjevanje: vrtenje -Name[sq]=Mbarimtekski: rrotullim -Name[sr]=Допуњавање текÑта: ротација -Name[sr@Latn]=Dopunjavanje teksta: rotacija -Name[ss]=Kucedzelwa kwembhalo:kujikeleta -Name[sv]=Textkomplettering: rotation -Name[ta]=உரைநிறைவà¯: சà¯à®´à®±à¯à®šà®¿ -Name[te]=వాచకపూరణ:à°­à±à°°à°®à°£à°‚ -Name[tg]=Худхотимадиҳӣ: гардиш -Name[th]=à¸à¸²à¸£à¹€à¸•à¸´à¸¡à¸‚้อความให้สมบูรณ์: à¸à¸²à¸£à¸«à¸¡à¸¸à¸™ -Name[tr]=Textcompletion: çevirme -Name[tt]=Süzazağı: äyländerü -Name[uk]=Ð”Ð¾Ð¿Ð¾Ð²Ð½ÐµÐ½Ð½Ñ Ñ‚ÐµÐºÑту: Ð¾Ð±ÐµÑ€Ñ‚Ð°Ð½Ð½Ñ -Name[uz]=Matnni tugatish: qaytarish -Name[uz@cyrillic]=Матнни тугатиш: қайтариш -Name[ven]=U fhela ha manwalwa: U mona -Name[vi]=Nhập xong từ: xoay -Name[xh]=Textcompletion: ujikeleziso -Name[zh_CN]=文字补é½ï¼šè½®è½¬ -Name[zh_HK]=文字補齊:旋轉 -Name[zh_TW]=文字補齊:旋轉 -Name[zu]=Ukuqedwa kombhalo:ukujikelezisa -Comment=The end of the list of matches has been reached -Comment[af]=Die einde van die lys van ooreenkomste is bereik -Comment[be]=ДаÑÑгнуты канец ÑпіÑа ÑупаданнÑÑž -Comment[bg]=ДоÑтигнат е ÐºÑ€Ð°Ñ Ð½Ð° ÑпиÑъка от ÑÑŠÐ²Ð¿Ð°Ð´ÐµÐ½Ð¸Ñ -Comment[bn]=মিলের তালিকার শেষে উপসà§à¦¥à¦¿à¦¤ -Comment[br]=Tizhet eo diwezh roll ar gendoareoù -Comment[bs]=DoÅ¡ao sam do kraja liste pogodaka -Comment[ca]=S'ha arribat al final de la llista de coincidències -Comment[cs]=Dosaženo konce seznamu odpovídajících položek -Comment[csb]=Je doszłé do kùńca lëstë dopasowaniów -Comment[da]=Slutningen pÃ¥ listen over det fundne er nÃ¥et -Comment[de]=Das Ende der Liste mit Ãœbereinstimmungen wurde erreicht -Comment[el]=Φτάσαμε στο τέλος της λίστας με τα ταιÏιάσματα -Comment[eo]=Fino de la listo de kongruaĵoj -Comment[es]=Se ha alcanzado el final de la lista de concordancias -Comment[et]=Jõuti kokkulangevuste nimekirja lõppu -Comment[eu]=Bat datozenen zerrendaren amaierara iritsi da -Comment[fa]=به پایان Ùهرست تطبیقها رسیده است -Comment[fi]=Osumalistan loppu saavutettu -Comment[fr]=La fin de la liste des correspondances a été atteinte -Comment[fy]=It ein fan de oerienkomstenlist is berikt -Comment[gl]=Chegou-se á fin da lista de coincidéncias. -Comment[he]=הגיעו לסוף רשימת ההת×מות -Comment[hi]= मिलान सूची का अंतिम आ पंहà¥à¤šà¤¾. -Comment[hr]=Stiglo se do zavrÅ¡etka popisa podudarnosti -Comment[hsb]=Sym na kóncu lisćiny namakankow -Comment[hu]=A találatok listájának végére értem -Comment[id]=Akhir daftar pencocokan telah dicapai -Comment[is]=Enda listans yfir atriði sem passa náð -Comment[it]=È stata raggiunta la fine della lista delle corrispondenze -Comment[ja]=マッãƒãƒªã‚¹ãƒˆã®çµ‚端ã«é”ã—ã¾ã—㟠-Comment[ka]=თáƒáƒœáƒ®áƒ•áƒ”დრáƒáƒ—რსიის ბáƒáƒšáƒ. -Comment[kk]=СайкеÑтіктер тізімі Ñоңына жетті -Comment[km]=បាន​ទៅ​ដល់​ចុង​បញ្ចប់​នៃ​បញ្ជី​ដំណូច -Comment[lb]=D'Enn vun der Lëscht mat den Iwwerteneestëmmungen ass erreecht ginn -Comment[lt]=Pasiektas atitikmenų sÄ…raÅ¡o galas -Comment[lv]=Sasniegtas atbilstÄ«bu saraksta beigas -Comment[mk]=ДоÑтигнат е крајот на лиÑтата на Ñовпаѓања -Comment[ms]=Sampai ke akhiran senarai padanan -Comment[nb]=Har kommet til slutten av lista over treff -Comment[nds]=Dat is dat Enn vun de List mit Övereenstimmen -Comment[ne]=मिलà¥à¤¦à¥‹ सूचीको अनà¥à¤¤à¥à¤¯à¤®à¤¾ पà¥à¤—िà¤à¤•à¥‹ छ -Comment[nl]=Het einde van de lijst met overeenkomsten is bereikt -Comment[nn]=Slutten av trefflista er nÃ¥dd -Comment[pa]=ਮੇਲ ਸੂਚੀ ਦਾ ਅੰਤ ਆ ਗਿਆ ਹੈ -Comment[pl]=OsiÄ…gniÄ™to koniec listy dopasowaÅ„ -Comment[pt]=O fim da lista de escolhas foi atingido -Comment[pt_BR]=O fim da lista de coincidências foi atingido -Comment[ro]=Am ajuns la sfîrÅŸitul listei de potriviri -Comment[ru]=ДоÑтигнут конец ÑпиÑка Ñовпадений. -Comment[rw]=Impera y'urutonde rw'ibihura yagezweho -Comment[se]=Ollii gávdnosiid listtu lohppii -Comment[sk]=Bol dosiahnutý koniec zoznamu nájdených položiek -Comment[sl]=To je konec seznama zadetkov -Comment[sr]=ДоÑтигнут је крај лиÑте подударања -Comment[sr@Latn]=Dostignut je kraj liste podudaranja -Comment[sv]=Slutet pÃ¥ listan med träffar har nÃ¥tts -Comment[ta]=பொரà¯à®¤à¯à®¤à®ªà¯ படà¯à®Ÿà®¿à®¯à®²à®¿à®©à¯ à®®à¯à®Ÿà®¿à®µà¯ˆ அடைநà¯à®¤à®¾à®¯à®¿à®±à¯à®±à¯. -Comment[te]=జతల జాబితా చివరకౠచేరà±à°•à±à°¨à±à°¨à°®à± -Comment[tg]=Охири рӯйхати мувофиқат раÑид -Comment[th]=ถึงส่วนท้ายของรายà¸à¸²à¸£à¸—ี่เข้าคู่ได้à¹à¸¥à¹‰à¸§ -Comment[tr]=EÅŸleÅŸme listesinin sonuna gelindi -Comment[tt]=Kileşülär tezmäseneñ azağına cittek -Comment[uk]=ДоÑÑгнуто кінець ÑпиÑку збігань -Comment[uz]=Mos keladigan elementlar roÊ»yxatining oxiri -Comment[uz@cyrillic]=ÐœÐ¾Ñ ÐºÐµÐ»Ð°Ð´Ð¸Ð³Ð°Ð½ Ñлементлар рўйхатининг охири -Comment[vi]=Má»›i tá»›i kết thúc của danh sách từ khá»›p. -Comment[zh_CN]=已到达匹é…é¡¹åˆ—è¡¨çš„æœ€åŽ -Comment[zh_TW]=符åˆæ¢ä»¶çš„列表已經到çµå°¾äº†ã€‚ -default_presentation=1 - -[Textcompletion: no match] -Name=Textcompletion: no match -Name[af]=Teksvoltooiïng: nee ooreenstem -Name[ar]=اكمال نص: لا يوجد تماثل -Name[az]=Textcompletion: oxÅŸarı Yoxdur -Name[be]=ЗаканчÑнне Ñ‚ÑкÑту: нÑма ÑупаданнÑÑž -Name[bg]=Ðвтоматично завършване: нÑма Ñъвпадение -Name[bn]=Textcompletion: কোনো মিল পাওয়া যায়নি -Name[br]=KlokadurSrid : kendoare ebet -Name[bs]=Textcompletion: bez poklapanja -Name[ca]=Compleció de text: cap coincidència -Name[cs]=Doplňování textu: žádná shoda -Name[csb]=Dofùlowanié tekstu: felënk dopasowaniô -Name[cy]=CwblhauTestun: cydweddiad -Name[da]=Tekstkomplettering: intet fundet -Name[de]=Textvervollständigung: keine Ãœbereinstimmung -Name[el]=ΣυμπλήÏωση κειμένου: κανένα ταίÏιασμα -Name[eo]=Kkompletigo: neniu trovaĵo -Name[es]=Completado de texto: no hay concordancias -Name[et]=Teksti lõpetamine: kokkulangevus puudub -Name[eu]=Testu-osaketa: ez dago bat datorrenik -Name[fa]=تکمیل متن: بدون تطبیق -Name[fi]=Tekstintäydennys: ei osumia -Name[fr]=Autocomplètement de texte : aucune correspondance -Name[fy]=Tekstkompletearing - gjin oerienkomst -Name[ga]=Comhlánú téacs: níl aon rud inchurtha -Name[gl]=Textcompletion: sen coincidéncia -Name[he]=השלמת טקסט: ×ין הת×מה -Name[hi]=टेकà¥à¤¸à¥à¤Ÿ कमà¥à¤ªà¤²à¥€à¤¶à¤¨à¤ƒ मिलान नहीं -Name[hr]=Textcompletion: bez poklapanja -Name[hsb]=WudospoÅ‚njenje teksta: njejsym niÄo namakaÅ‚ -Name[hu]=Szövegkiegészítés: nincs találat -Name[id]=Pemenuhanteks: tidak ada yang cocok -Name[is]=Textaklárun: ekkert passar -Name[it]=Completamento testo: nessuna corrispondenza -Name[ja]=テキスト補完: マッãƒãªã— -Name[ka]=თვითშევსებáƒ: თáƒáƒœáƒ®áƒ•áƒ”დრები áƒáƒ  áƒáƒ áƒ˜áƒ¡ -Name[kk]=Ðвтотолтыру: ÑәйкеÑтік жоқ -Name[km]=ការ​បំពáŸáž‰â€‹áž¢ážáŸ’ážáž”ទ ៖ គ្មាន​ដំណូច -Name[ko]=글월 완성: 맞는 ì§ì´ ì—†ìŒ -Name[lb]=Textergänzung: keng Iwwerteneestëmmung -Name[lt]=Textcompletion: netinka -Name[lv]=Tekstakomplekts: nav atbilstÄ«bu -Name[mk]=Довршување текÑÑ‚: нема Ñовпаѓања -Name[mn]=ТекÑÑ‚ гүйцÑÑлт: Харьцуулалтгүй -Name[ms]= Penyudah teks: tiada padanan -Name[mt]=Kompletazzjoni tal-kliem: ebda qbil -Name[nb]=Tekstfullføring: ingen treff -Name[nds]=Textkompletteren: nix passt -Name[ne]=पाठ समापà¥à¤¤à¤¿: बेमेल -Name[nl]=Tekstaanvulling - geen overeenkomsten -Name[nn]=Tekstfullføring: ingen treff -Name[nso]=Phetso ya sengwalwana: gagona tshwanelano -Name[oc]=Textcompletion: a pas res de coincidencia -Name[pa]=Textcompletion: ਕੋਈ ਮੇਲ ਨਹੀ -Name[pl]=UzupeÅ‚nianie tekstu: brak dopasowania -Name[pt]=Completação de texto: nenhuma encontrada -Name[pt_BR]=Completar Texto: nenhuma coincidência -Name[ro]=Completare text: nici o potrivire -Name[ru]=Ðвтозавершение: нет Ñовпадений -Name[rw]=Iyuzuzamwandiko: nta bihura -Name[se]=TeakstaollaÅ¡uhttin: ii gávdnon -Name[sk]=Doplnenie textu: žiadna zhoda -Name[sl]=Dopolnjevanje: ni ujemanja -Name[sq]=Mabrimteksti: nuk ka përputhje -Name[sr]=Допуњавање текÑта: нема поклапања -Name[sr@Latn]=Dopunjavanje teksta: nema poklapanja -Name[ss]=Kucedzelwa kwembhalo:akukho kuhambelana -Name[sv]=Textkomplettering: ingen träff -Name[ta]=உரைநிறைவà¯: பொரà¯à®¤à¯à®¤à®®à®¿à®²à¯à®²à¯ˆ -Name[te]=వాచకపూరణ:జత లేదౠ-Name[tg]=Худхотимадиҳӣ: номуноÑиб -Name[th]=à¸à¸²à¸£à¹€à¸•à¸´à¸¡à¸‚้อความให้สมบูรณ์: ไม่เข้าคู่ -Name[tr]=Textcompletion: eÅŸleÅŸme Yok -Name[tt]=Süzazağı: kileÅŸkäne yuq -Name[uk]=Ð”Ð¾Ð¿Ð¾Ð²Ð½ÐµÐ½Ð½Ñ Ñ‚ÐµÐºÑту: немає відповідних значень -Name[uz]=Matnni tugatish: mos keladigan yoÊ»q -Name[uz@cyrillic]=Матнни тугатиш: Ð¼Ð¾Ñ ÐºÐµÐ»Ð°Ð´Ð¸Ð³Ð°Ð½ йўқ -Name[ven]=U fhela ha manwalwa: A huna u fanyisa -Name[vi]=Nhập xong từ: không khá»›p -Name[xh]=Textcompletion: akukho ntelekiso -Name[zh_CN]=文字补é½ï¼šæ²¡æœ‰åŒ¹é… -Name[zh_HK]=æ–‡å­—è£œé½Šï¼šæ²’æœ‰åŒ¹é… -Name[zh_TW]=æ–‡å­—è£œé½Šï¼šæ²’æœ‰åŒ¹é… -Name[zu]=Ukuqedwa kokumbhalo: akukho okufanayo -Comment=No matching completion was found -Comment[af]=Geen ooreenstemming was gevind -Comment[be]=ÐÑма варыÑнтаў заканчÑÐ½Ð½Ñ -Comment[bg]=Ðе е намерено Ñъвпадение -Comment[bn]=কোনো যà§à¦¤à¦¸à¦‡ পরিপূরক পাওয়া যায় নি -Comment[br]=Kendoare ebet na voe kavet -Comment[bs]=Nijedno dovrÅ¡avanje nije pronaÄ‘eno -Comment[ca]=No s'ha trobat cap coincidència completable -Comment[cs]=Nenalezeno žádné vhodné doplnÄ›ní -Comment[csb]=Dopasowanié nie òstałó nalazłé -Comment[da]=Ingen passende komplettering blev fundet -Comment[de]=Keine passende Ergänzung gefunden -Comment[el]=Δε βÏέθηκε συμπλήÏωση που να ταιÏιάζει -Comment[eo]=Ne troviÄis konvena kompletigo. -Comment[es]=No se encontró ningún completado concordante -Comment[et]=Kokkulangevat lõppu ei leitud -Comment[eu]=Ez da bat datorren osaketarik aurkitu -Comment[fa]=تکمیل مطابق پیدا نشد -Comment[fi]=Ei osumia täydennettäväksi -Comment[fr]=Aucune possibilité d'auto-complètement trouvée -Comment[fy]=gjin oerienkomstige kompletearings binne fun -Comment[gl]=Non se atopou nengunha completado coincidente. -Comment[he]=×œ× × ×ž×¦××” ××£ השלמה תו×מת -Comment[hi]=कोई मैचिंग कमà¥à¤ªà¥à¤²à¥€à¤¶à¤¨ नहीं मिला -Comment[hr]=Nije pronaÄ‘ena nijedna podudarnost -Comment[hsb]=Žane wudospoÅ‚njenje so njehodźi -Comment[hu]=Nem található megfelelÅ‘ kiegészítés -Comment[id]=Tidak ada pelengkapan yang cocok -Comment[is]=Ekkert passar -Comment[it]=Nessun completamento corrispondente trovato -Comment[ja]=マッãƒã™ã‚‹è£œå®Œã¯è¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—㟠-Comment[ka]=თáƒáƒœáƒ®áƒ•áƒ”დერები ვერ მáƒáƒ˜áƒ«áƒ”ბნáƒ. -Comment[kk]=СәйкеÑтік жоқ -Comment[km]=រក​មិន​ឃើញ​ការ​បំពáŸáž‰â€‹ážŠáŸ‚ល​ដូច -Comment[lb]=Et gouf keng passend Ergänzung fonnt -Comment[lt]=Nerasta atitinkanti pabaiga -Comment[lv]=AtbilstoÅ¡a pabeigÅ¡ana netika atrasta -Comment[mk]=Ðе е најдено Ñовпаѓање -Comment[ms]=Tiada padanan lengkapan ditemui -Comment[nb]=Ingen passende fullføring funnet -Comment[nds]=Dor passt nix -Comment[ne]=बेमेल समापà¥à¤¤à¤¿ फेला पारेको थियो -Comment[nl]=Er werd geen overeenkomstige aanvulling gevonden -Comment[nn]=Ingen passande fullføring funne -Comment[pa]=ਸਮਾਪਤੀ ਤੱਕ ਕੋਈ ਮੇਲ ਨਹੀਂ ਲੱਭਾ -Comment[pl]=Nie znaleziono dopasowania -Comment[pt]=Não foi encontrada qualquer completação -Comment[pt_BR]=Nenhuma coincidência foi encontrada -Comment[ro]=Nu am găsit nimic potrivit -Comment[ru]=Ðе найдено Ñовпадений. -Comment[rw]=Nta yuzuza rihura ryabonetse -Comment[se]=HeivvolaÅ¡ ollaÅ¡uhttin ii gávdnon -Comment[sk]=Žiadna zhoda nebola nájdená -Comment[sl]=Ni najti ujemajoÄih se zadetkov -Comment[sr]=Подударна допуна није пронађена -Comment[sr@Latn]=Podudarna dopuna nije pronaÄ‘ena -Comment[sv]=Ingen matchande komplettering hittades -Comment[ta]=பொரà¯à®¤à¯à®¤à®®à®¾à®© நிறைவ௠à®à®¤à¯à®®à®¿à®²à¯à®²à¯ˆ. -Comment[te]=సరిపోయె జత దొరకలేదౠ-Comment[tg]=Ягон мувофиқат Ñ‘Ñ„Ñ‚ нашуд -Comment[th]=ไม่พบส่วนเติมข้อความที่เข้าคู่ -Comment[tr]=EÅŸleÅŸme bulunamadı -Comment[tt]=KileÅŸkän azaqlar tabılmadı -Comment[uk]=Відповідного Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð½Ñ Ð½Ðµ знайдено -Comment[uz]=Mos keladigan tugatish topilmadi -Comment[uz@cyrillic]=ÐœÐ¾Ñ ÐºÐµÐ»Ð°Ð´Ð¸Ð³Ð°Ð½ тугатиш топилмади -Comment[vi]=Không tìm thấy. -Comment[zh_CN]=没有找到匹é…的补全项 -Comment[zh_HK]=找ä¸åˆ°å®Œå…¨åŒ¹é…çš„é …ç›® -Comment[zh_TW]=找ä¸åˆ°å®Œå…¨åŒ¹é…的項目。 -default_presentation=1 - -[Textcompletion: partial match] -Name=Textcompletion: partial match -Name[af]=Teksvoltooiïng: gedeeltelike ooreenstem -Name[ar]=اكمال نص: تماثل جزئي -Name[az]=Textcompletion: qismi oxÅŸar -Name[be]=ЗаканчÑнне Ñ‚ÑкÑту: чаÑтковае Ñупаданне -Name[bg]=Ðвтоматично завършване: чаÑтично Ñъвпадение -Name[bn]=Textcompletion: আংশিক মিল -Name[br]=KlokadurSrid : kendoare darnek -Name[bs]=Textcompletion: djelomiÄno poklapanje -Name[ca]=Compleció de text: coincidència parcial -Name[cs]=Doplňování textu: ÄásteÄná shoda -Name[csb]=Dofùlowanié tekstu: dzélowé dopasowanié -Name[cy]=CwblhauTestun: cydweddiad rhannol -Name[da]=Tekstkomplettering: delvist fundet -Name[de]=Textvervollständigung: teilweise Ãœbereinstimmung -Name[el]=ΣυμπλήÏωση κειμένου: μεÏικό ταίÏιασμα -Name[eo]=Kkompletigo: parta trovaĵo -Name[es]=Completado de texto: concordancia parcial -Name[et]=Teksti lõpetamine: osaline kokkulangevus -Name[eu]=Testu-osaketa: bat datorren partziala -Name[fa]=تکمیل متن: تطبیق جزیی -Name[fi]=Tekstintäydennys: osittainen osuma -Name[fr]=Autocomplètement de texte : correspondance partielle -Name[fy]=Tekstkompletearing - foar in diel oerienkommend -Name[ga]=Comhlánú téacs: inchurtha i bpáirt -Name[gl]=Textcompletion: coincidéncia parcial -Name[he]=השלמת טקסט: הת×מה חלקית -Name[hi]=टेकà¥à¤¸à¥à¤Ÿ कमà¥à¤ªà¤²à¥€à¤¶à¤¨à¤ƒ अधूरा मिलान -Name[hr]=Textcompletion: djelomiÄno poklapanje -Name[hsb]=WudospoÅ‚njenje teksta: dźělne kryće -Name[hu]=Szövegkiegészítés: részleges találat -Name[id]=Pemenuhanteks: cocok sebagian -Name[is]=Textaklárun: passar næstum því -Name[it]=Completamento testo: corrispondenza parziale -Name[ja]=テキスト補完: 部分的ã«ãƒžãƒƒãƒ -Name[ka]=თვითშევსებáƒ: ნáƒáƒ¬áƒ˜áƒšáƒáƒ‘რივი თáƒáƒœáƒ®áƒ•áƒ”დრრ-Name[kk]=Ðвтотолтыру: жарты-жарым ÑәйкеÑтік -Name[km]=ការ​បំពáŸáž‰â€‹áž¢ážáŸ’ážáž”ទ ៖ ដូច​ážáŸ’លះៗ -Name[ko]=글월 완성: ë¶€ë¶„ì€ ì§ì´ ë§žìŒ -Name[lb]=Textergänzung: deelweis Iwwerteneestëmmung -Name[lt]=Textcompletion: tinka dalinai -Name[lv]=Tekstakomplekts: daļēja atbilstÄ«ba -Name[mk]=Довршување текÑÑ‚: делумни Ñовпаѓања -Name[mn]=ТекÑÑ‚ гүйцÑÑлт: Ð¥Ð°Ð³Ð°Ñ Ñ…Ð°Ñ€ÑŒÑ†ÑƒÑƒÐ»Ð°Ð»Ñ‚Ñ‚Ð°Ð¹ -Name[ms]= Penyudah teks: separa padanan -Name[mt]=Kompletazzjoni tal-kliem: qbil parzjali -Name[nb]=Tekstfullføring: delvis treff -Name[nds]=Textkompletteren: passt deelwies -Name[ne]=पाठ समापà¥à¤¤à¤¿: आंशिक मिलà¥à¤¯à¥‹ -Name[nl]=Tekstaanvulling - gedeeltelijke overeenkomsten -Name[nn]=Tekstfullføring: delvis treff -Name[nso]=Phetso ya sengwalwana: tshwanelanyo dikarolong tse rilego -Name[oc]=Textcompletion: coincidencia parciala -Name[pa]=Textcompletion: ਅਧੂਰਾ ਮਿਲਾਨ -Name[pl]=UzupeÅ‚nianie tekstu: częściowe dopasowanie -Name[pt]=Completação de texto: parcial -Name[pt_BR]=Completar Texto: coincidência parcial -Name[ro]=Completare text: potrivire parÅ£ială -Name[ru]=Ðвтозавершение: чаÑтичное Ñовпадение -Name[rw]=Iyuzuzamwandiko: uguhura kutuzuye -Name[se]=TaekstaollaÅ¡uhttin: oasil gávdnui -Name[sk]=Doplnenie textu: ÄiastoÄná zhoda -Name[sl]=Dopolnjevanje: delno ujemanje -Name[sq]=Mbarimteksti: përputhje e pjesërishme -Name[sr]=Допуњавање текÑта: делимично поклапање -Name[sr@Latn]=Dopunjavanje teksta: delimiÄno poklapanje -Name[ss]=Kucedzelwa kwembhalo:kuhambelana lokungakapheleli -Name[sv]=Textkomplettering: delvis träff -Name[ta]=உரைநிறைவà¯: கà¯à®±à¯ˆà®ªà¯ பொரà¯à®¤à¯à®¤à®®à¯ -Name[te]=వాచకపూరణ: పాకà±à°·à°¿à°• జత -Name[tg]=Худхотимадиҳӣ: мувофиқати қиÑмӣ -Name[th]=à¸à¸²à¸£à¹€à¸•à¸´à¸¡à¸‚้อความให้สมบูรณ์: เข้าคู่บางส่วน -Name[tr]=Textcompletion: kısmi eÅŸleÅŸme -Name[tt]=Süzazağı: öleşçä kileÅŸkän -Name[uk]=Ð”Ð¾Ð¿Ð¾Ð²Ð½ÐµÐ½Ð½Ñ Ñ‚ÐµÐºÑту: чаÑткове Ð·Ð±Ñ–Ð³Ð°Ð½Ð½Ñ -Name[uz]=Matnni tugatish: qisman mos kelish -Name[uz@cyrillic]=Матнни тугатиш: қиÑман Ð¼Ð¾Ñ ÐºÐµÐ»Ð¸Ñˆ -Name[ven]=U fhela ha manwalwa: U elana hu tukunyana -Name[vi]=Nhập xong từ: khá»›p bá»™ phạn -Name[xh]=Ugqibeko lokubhaliweyo: intelekiso engaphelelanga -Name[zh_CN]=文字补é½ï¼šéƒ¨åˆ†åŒ¹é… -Name[zh_HK]=æ–‡å­—è£œé½Šï¸°éƒ¨åˆ†åŒ¹é… -Name[zh_TW]=æ–‡å­—è£œé½Šï¸°éƒ¨åˆ†åŒ¹é… -Name[zu]=Ukuqedwa kokubhaliweyo: ukufaniswa kwesikhashana -Comment=There is more than one possible match -Comment[af]=Daar is meer as een moontlik ooreenkoms -Comment[be]=Знойдзена некалькі варыÑнтаў заканчÑÐ½Ð½Ñ -Comment[bg]=Ðамерени Ñа повече от едно Ñъвпадение -Comment[bn]=à¦à¦•à¦¾à¦§à¦¿à¦• সমà§à¦­à¦¾à¦¬à§à¦¯ পরিপূরক বরà§à¦¤à¦®à¦¾à¦¨ -Comment[br]=Tremen ur c'hendoare a zo -Comment[bs]=Postoji viÅ¡e od jednog mogućeg pogotka -Comment[ca]=Hi ha més d'una possible coincidència -Comment[cs]=Existuje více vhodných odpovídajících položek -Comment[csb]=Je wicy jak jedno dopasowanié -Comment[da]=Der er mere end en mulighed -Comment[de]=Mehr als eine mögliche Ergänzung vorhanden -Comment[el]=ΥπάÏχουν πεÏισσότεÏες από μία δυνατές συμπληÏώσεις -Comment[eo]=Ekzistas pli ol unu konvena trovaĵo. -Comment[es]=Hay más de una posible concordancia -Comment[et]=Võimalike variante on rohkem kui üks -Comment[eu]=Bat datorrenak bat baino gehiago dira -Comment[fa]=بیش از یک تطبیق ممکن وجود دارد -Comment[fi]=Useampia mahdollisia osumia -Comment[fr]=Au moins deux correspondances ont été trouvées -Comment[fy]=Der is wierskynlik mear as ien oerienkomst -Comment[gl]=Hai máis dunha coincidéncia posíbel -Comment[he]=יש יותר מהת×מה ×פשרית ×חת -Comment[hi]=वहाठपर à¤à¤• से अघिक संभव जोड़ मिले हैं -Comment[hr]=Postoji viÅ¡e od jedne moguće podudarnosti -Comment[hsb]=Wjace haÄ jedne móžne wudospoÅ‚njenje -Comment[hu]=Egynél több lehetséges kiegészítés van -Comment[id]=Lebih dari satu kemungkinan cocok -Comment[is]=Það eru fleiri en eitt atriði sem passar -Comment[it]=C'è più di una corrispondenza possibile -Comment[ja]=マッãƒã™ã‚‹ã‚‚ã®ãŒè¤‡æ•°ã‚ã‚Šã¾ã™ -Comment[ka]=მáƒáƒ˜áƒ«áƒ”ბნრერთზე მეტი თáƒáƒœáƒ®áƒ•áƒ”დრáƒ. -Comment[kk]=Бірден артық ÑәйкеÑтік бар -Comment[km]=អាច​មាន​ដំណូច​ច្រើន​ជាង​មួយ -Comment[lb]=Et gëtt méi wéi eng méiglech Iwwerteneestëmmung -Comment[lt]=Yra daugiau negu vienas galimas atitikmuo -Comment[lv]=Å eit ir vairÄk kÄ viena iespÄ“jamÄ atbilstÄ«ba -Comment[mk]=ПоÑтојат повеќе од едно Ñовпаѓање -Comment[ms]=Ada lebih dari satu kebarangkalian padanan. -Comment[nb]=Det er mer enn ett mulig treff -Comment[nds]=Dor passt mehr as een -Comment[ne]=तà¥à¤¯à¤¹à¤¾à¤ à¤à¤• भनà¥à¤¦à¤¾ बढी समà¥à¤­à¤µ जोडा छनॠ-Comment[nl]=Er is meer dan één mogelijke overeenkomst -Comment[nn]=Det er meir enn eitt mogleg treff -Comment[pa]=ਇੱਕ ਤੋਂ ਵਧੇਰੇ ਮੇਲ ਉਪਲੱਬਧ ਹਨ -Comment[pl]=Jest wiÄ™cej niż jedno dopasowanie -Comment[pt]=Há mais do que uma completação possível -Comment[pt_BR]=Há mais de uma opção possível -Comment[ro]=Există mai mult de o potrivire posibilă -Comment[ru]=Ðайдено более чем одно Ñовпадение. -Comment[rw]=Hari uguhura kurenga kumwe gushoboka -Comment[se]=Leat eanet go ovtta vejolaÅ¡ gávdnus -Comment[sk]=Existuje viac ako jedna zhoda -Comment[sl]=MogoÄ je veÄ kakor en zadetek -Comment[sr]=ПоÑтоји више од једног могућег подударања -Comment[sr@Latn]=Postoji viÅ¡e od jednog mogućeg podudaranja -Comment[sv]=Det finns mer än en möjlig träff -Comment[ta]=ஒனà¯à®±à¯à®•à¯à®•à¯ மேறà¯à®ªà®Ÿà¯à®Ÿ பொரà¯à®¤à¯à®¤à®™à¯à®•à®³à¯ உளà¯à®³à®©. -Comment[te]=à°’à°•à°Ÿà°¿ కంటె à°Žà°•à±à°•à±à°µ సరిపోయె జతలౠకలవౠ-Comment[tg]=Зиёд аз Ñк мувофиқат Ñ‘Ñ„Ñ‚ шуд -Comment[th]=มีส่วนที่เข้าคู่ได้อยู่มาà¸à¸à¸§à¹ˆà¸²à¸«à¸™à¸¶à¹ˆà¸‡ -Comment[tr]=Birden fazla muhtemel eÅŸleÅŸme var -Comment[tt]=KileÅŸkäne berdän dä kübkär -Comment[uk]=Більше одного відповідного Ð·Ð½Ð°Ñ‡ÐµÐ½Ð½Ñ -Comment[uz]=Bittadan koÊ»p moslik topildi -Comment[uz@cyrillic]=Биттадан кўп моÑлик топилди -Comment[vi]=Khá»›p nhiá»u từ. -Comment[zh_CN]=有多于一个的å¯èƒ½åŒ¹é…项 -Comment[zh_HK]=匹é…çš„å¯èƒ½æ€§å¤šæ–¼ä¸€å€‹ -Comment[zh_TW]=有多於一個的å¯èƒ½åŒ¹é…項。 -default_presentation=1 - -[cannotopenfile] -Name=Cannot Open File -Name[af]=Kan nie Open Lêer -Name[ar]=لا أستطيع Ùتح المل٠-Name[az]=Fayl Açıla bilmir -Name[be]=Ðемагчыма адкрыць файл -Name[bg]=Ðе може да Ñе отвори файла -Name[bn]=ফাইল খোলা যাচà§à¦›à§‡ না -Name[br]=N'hall ket digeriñ restr -Name[bs]=Ne mogu otvoriti datoteku -Name[ca]=No es pot obrir el fitxer -Name[cs]=Není možné otevřít soubor -Name[csb]=Nie je mòżno òtemknÄ…c lopkù -Name[cy]=Methu Agor y Ffeil -Name[da]=Kan ikke Ã¥bne fil -Name[de]=Datei lässt sich nicht öffnen -Name[el]=Δεν είναι δυνατό το άνοιγμα του αÏχείου -Name[eo]=Ne eblas malfermi dosieron -Name[es]=No se puede abrir archivo -Name[et]=Faili avamine ebaõnnestus -Name[eu]=Ezin da fitxategia ireki -Name[fa]=نمی‌توان پرونده را باز کرد -Name[fi]=Ei voitu avata tiedostoa -Name[fo]=Kann ikki opna fíla -Name[fr]=Impossible d'ouvrir un fichier -Name[fy]=Kin de triem net iepenje -Name[ga]=Ní Féidir an Comhad a Oscailt -Name[gl]=Non se pode abrir a ficheiro -Name[he]=×ין ×פשרות לפתוח קובץ -Name[hi]=फ़ाइल खोल नहीं सका -Name[hr]=Datoteku nije moguće otvoriti -Name[hsb]=Njemóžu dataju woÄinić -Name[hu]=Nem sikerült megnyitni a fájlt -Name[id]=Tidak Dapat Membuka Berkas -Name[is]=Get ekki opnað skrá -Name[it]=Impossibile aprire il file -Name[ja]=ファイルを開ã‘ã¾ã›ã‚“ -Name[ka]=ფáƒáƒ˜áƒšáƒ˜áƒ¡ გáƒáƒ®áƒ¡áƒœáƒ ვერ ხერხდებრ-Name[kk]=Файл ашылмайды -Name[km]=មិន​អាច​បើក​ឯកសារ -Name[ko]=파ì¼ì„ 열지 못함 -Name[lb]=Kann d'Datei net opmaachen -Name[lt]=Nepavyksta atverti bylos -Name[lv]=Nevar AtvÄ“rt Failu -Name[mi]=Kaua i te Puare Könae -Name[mk]=Ðе може да Ñе отвори датотеката -Name[mn]=Файл нÑÑгдÑхгүй байна -Name[ms]=Tidak boleh Buka Fail -Name[mt]=Ma jistax jinfetaħ fajl -Name[nb]=Kan ikke Ã¥pne fil -Name[nds]=Datei lett sik nich opmaken -Name[ne]=फाइल खोलà¥à¤¨ सकà¥à¤¦à¥ˆà¤¨ -Name[nl]=Kan het bestand niet openen -Name[nn]=Kan ikkje opna fil -Name[nso]=Ekase Bule Faele -Name[oc]=Pot pas obrir lo fiquier -Name[pa]=ਫਾਇਲ਼ ਖੋਲà©à¨¹à©€ ਨਹੀਂ ਜਾ ਸਕਦੀ -Name[pl]=Nie można otworzyć pliku -Name[pt]=Não Consigo Abrir o Ficheiro -Name[pt_BR]=Não Foi Possível Abrir o Arquivo -Name[ro]=Nu pot deschide fiÅŸierul -Name[ru]=Ðе удаётÑÑ Ð¾Ñ‚ÐºÑ€Ñ‹Ñ‚ÑŒ файл -Name[rw]=Ntibishobotse Gufungura Idosiye -Name[se]=Ii sáhte rahpat filla -Name[sk]=Nemôžem otvoriÅ¥ súbor -Name[sl]=Ni moÄ odpreti datoteke -Name[sq]=Nuk mund ta hap skedën -Name[sr]=Ðије могуће отворити фајл -Name[sr@Latn]=Nije moguće otvoriti fajl -Name[ss]=Akukhonakali kuvula lifayela -Name[sv]=Kan inte öppna fil -Name[ta]=கோபà¯à®ªà¯ˆà®¤à¯ திறகà¯à®• à®®à¯à®Ÿà®¿à®¯à®µà®¿à®²à¯à®²à¯ˆ -Name[te]=దసà±à°¤à±à°°à°¾à°¨à±à°¨à°¿ తెరà±à°µà°²à±‡à°¨à± -Name[tg]=Ðаметавон файлро кушод -Name[th]=ไม่สามารถเปิดà¹à¸Ÿà¹‰à¸¡à¹„ด้ -Name[tr]=Dosya Açılamıyor -Name[tt]=Biremne Aça Almím -Name[uk]=Ðеможливо відкрити файл -Name[uz]=Faylni ochib boÊ»lmadi -Name[uz@cyrillic]=Файлни очиб бўлмади -Name[ven]=I ngasi vule faela -Name[vi]=Không thể mở tập tin -Name[wa]=Dji n' sai drovi l' fitchî -Name[xh]=Ayinakuyivula Ifayile -Name[zh_CN]=无法打开文件 -Name[zh_HK]=無法打開檔案 -Name[zh_TW]=無法打開檔案 -Name[zu]=Ifayela Alivulekile -Comment=The selected file cannot be opened for reading or writing -Comment[af]=Die gekose lêer kan nie oop wees vir lees of om te skryf -Comment[ar]=المل٠المختار لا يمكن Ùتحه للقراءة أو الكتابة -Comment[az]=Seçili fayl oxunmaq ya da yazılmaq üçün açıla bilmir -Comment[be]=Ðемагчыма прачытаць/запіÑаць выбраны файл -Comment[bg]=ИзбраниÑÑ‚ файл не може да бъде отворен за четене или Ð·Ð°Ð¿Ð¸Ñ -Comment[bn]=নিরà§à¦¬à¦¾à¦šà¦¿à¦¤ ফাইলটি পড়া বা লেখার জনà§à¦¯ খোলা যাচà§à¦›à§‡ না -Comment[br]=N'heller ket digeriñ ar restr diuzet evit lenn pe skrivañ -Comment[bs]=Ne mogu otvoriti izabranu datoteku za Äitanje ili pisanje -Comment[ca]=El fitxer seleccionat no es pot obrir per a lectura o escriptura -Comment[cs]=Vybraný soubor není možné otevřít pro Ätení nebo zápis. -Comment[csb]=Wëbróny lopk nie mòże òstac òtemkÅ‚i do czëtaniô czë zapisaniô -Comment[cy]=Methu agor y ffeil penodol i'w ddarllen neu i'w ysgrifennu. -Comment[da]=Den valgte fil kan ikke Ã¥bnes til læsning eller skrivning -Comment[de]=Die gewählte Datei kann nicht zum Lesen oder Schreiben geöffnet werden. -Comment[el]=Το επιλεγμένο αÏχείο δεν μποÏεί να ανοιχθεί για εγγÏαφή ή ανάγνωση -Comment[eo]=La elektita dosiero ne estas malfermebla por legado aÅ­ skribado -Comment[es]=El archivo seleccionado no se puede abrir para leer o escribir. -Comment[et]=Valitud faili pole võimalik avada lugemiseks või kirjutamiseks. -Comment[eu]=Hautatutako fitxategia ezin da irakurtzeko edo idazteko ireki -Comment[fa]=پروندۀ برگزیده نمی‌تواند برای خواندن یا نوشتن باز شود -Comment[fi]=Valittua tiedostoa ei voida avata luettavaksi tai kirjoitettavaksi -Comment[fr]=Le fichier sélectionné ne peut être ouvert ni en lecture ni en écriture -Comment[fy]=It selektearre triem kin net iepene wurde om te lêzen of skriuwen -Comment[ga]=Ní féidir an comhad roghnaithe a oscailt chun é a léamh nó chun scríobh air -Comment[gl]=O ficheiro escollido non se pode abrir para ler ou escreber -Comment[he]=×ין ×פשרות לפתוח ×ת הקובץ הנבחר לקרי××” ×ו כתיבה -Comment[hi]=चà¥à¤¨à¤¾ हà¥à¤† फ़ाइल पढ़ने अथवा लिखने के लिठखोला नहीं जा सकता। -Comment[hr]=Odabranu datoteku nije moguće otvoriti za Äitanje ili zapisivanje -Comment[hsb]=Wubrana dataja njehodźi so woÄinić -Comment[hu]=A kiválasztott fájlt nem lehet megnyitni írásra vagy olvasásra -Comment[id]=Berkas yang dipilih tidak dapat dibuka untuk dibaca atau ditulis -Comment[is]=Ekki er hægt að opna völdu skrána til lestrar eða skriftar -Comment[it]=Il file selezionato non può essere aperto per la lettura o la scrittura -Comment[ja]=é¸æŠžã•ã‚ŒãŸãƒ•ã‚¡ã‚¤ãƒ«ã‚’読ã¿è¾¼ã¿ã¾ãŸã¯æ›¸ãè¾¼ã¿ã®ãŸã‚ã«é–‹ã‘ã¾ã›ã‚“ -Comment[ka]=მáƒáƒœáƒ˜áƒ¨áƒœáƒ£áƒšáƒ˜ ფáƒáƒ˜áƒšáƒ˜áƒ¡ გáƒáƒ®áƒ¡áƒœáƒ წáƒáƒ¡áƒáƒ™áƒ˜áƒ—ხáƒáƒ“ áƒáƒœ ჩáƒáƒ¡áƒáƒ¬áƒ”რáƒáƒ“ ვერ ხერხდებრ-Comment[kk]=Таңдалған файл жазуға не оқуға ашылмады -Comment[km]=មិន​អាច​បើក​អាន​ពី ឬ សរសáŸážšâ€‹áž‘ៅ​ឯកសារ​ដែល​បាន​ជ្រើស -Comment[ko]=고른 파ì¼ì„ ì½ê±°ë‚˜ 쓰기위해 ì—´ 수가 없습니다 -Comment[lb]=Déi ausgewielten Datei kann net opgemat gi fir ze liesen oder ze schreiwen -Comment[lt]=Nurodytos bylos negalima atverti skaitymui arba raÅ¡ymui -Comment[lv]=IzvÄ“lÄ“tais fails nevar tikt atvÄ“rts lasÄ«Å¡anai vai rakstÄ«Å¡anai -Comment[mk]=Избраните датотеки не можат да Ñе отворат за читање или пишување -Comment[mn]=СонгоÑон файл уншигдах ÑÑвÑл бичигдÑÑ…ÑÑÑ€ нÑÑгдÑхгүй байна. -Comment[ms]=Fail dipilih tidak boleh dibaca atau ditulis -Comment[mt]=Il-fajl magħżul ma setax jinfetaħ għall-qari jew kitba. -Comment[nb]=Den valgte fila kan ikke Ã¥pnes for lesing eller skriving -Comment[nds]=De utsöchte Datei lett sik nich lesen oder schrieven -Comment[ne]=पढà¥à¤¨ वा लेखà¥à¤¨à¤•à¤¾ लागि चयन गरिà¤à¤•à¤¾ फाइल खोलà¥à¤¨ सकेन -Comment[nl]=Het geselecteerde bestand kan niet worden geopend om te lezen of naar te schrijven. -Comment[nn]=Den valte fila kan ikkje opnast for lesing eller skriving -Comment[nso]=Faele yeo e kgethilwego ekase bulelwe go bala goba go ngwala -Comment[oc]=Lo fiquièr seleccionat pod pas esser obrit per legir on escriure -Comment[pa]=ਚà©à¨£à©€ ਫਾਇਲ ਨੂੰ ਪੜਨ ਜਾਂ ਲਿਖਣ ਲਈ ਖੋਲਿਆ ਨਹੀਂ ਜਾ ਸਕਦਾ ਹੈ -Comment[pl]=Wybrany plik nie może być otwarty do odczytu lub zapisu -Comment[pt]=O ficheiro seleccionado não pode ser aberto para leitura ou escrita. -Comment[pt_BR]=O arquivo selecionado não pode ser aberto para leitura ou gravação -Comment[ro]=FiÅŸierul selectat nu poate fi deschis pentru scriere sau citire -Comment[ru]=Ðе удаётÑÑ Ð¾Ñ‚ÐºÑ€Ñ‹Ñ‚ÑŒ выбранный файл Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи или Ñ‡Ñ‚ÐµÐ½Ð¸Ñ -Comment[rw]=Idosiye yatoranyijwe ntishoboye gufungurwa mu gusoma cyangwa kwandika -Comment[se]=Válljejuvvon fiilla ii sáhte rahpat lohkama dahje Äállima várás -Comment[sk]=Vybraný súbor nemôžem otvoriÅ¥ na Äítanie alebo zápis -Comment[sl]=Izbrane datoteke ni bilo moÄ odpreti za branje ali pisanje. -Comment[sq]=Skedari i zgjedhur nuk mund të hapet për lexim apo editim -Comment[sr]=Изабрани фајл је немогуће отворити ради читања или пиÑања -Comment[sr@Latn]=Izabrani fajl je nemoguće otvoriti radi Äitanja ili pisanja -Comment[ss]=lifayela lelikhetsiwe akukhonakali kutsi livulwe kutsi lifundvwe kumbe libhalwe -Comment[sv]=Den valda filen kan inte öppnas för läsning eller skrivning -Comment[ta]=தேரà¯à®µà¯ செயà¯à®¤ கோபà¯à®ªà¯ˆ வாசிகà¯à®•à®µà¯‹ எழà¯à®¤à®µà¯‹ திறகà¯à®• à®®à¯à®Ÿà®¿à®¯à®¾à®¤à¯ -Comment[te]=ఎఓపిక చేసిన దసà±à°¤à±à°°à°¾à°¨à±à°¨à°¿ à°šà°¦à±à°µà±à°Ÿà°•à± లేక à°µà±à°°à°¾à°¯à±à°Ÿà°•à± తెరà±à°µà°²à±‡à°¨à± -Comment[tg]=Ðаметавон файли интихобшударо барои Ñабт Ñ‘ хондан кушод -Comment[th]=ไม่สามารถเปิดà¹à¸Ÿà¹‰à¸¡à¸—ี่เลือà¸à¹„ว้ เพื่อทำà¸à¸²à¸£à¸­à¹ˆà¸²à¸™à¸«à¸£à¸·à¸­à¹€à¸‚ียนได้ -Comment[tr]=Seçili dosya okumnmak ya da yazılmak için açılamıyor -Comment[tt]=SaylanÄŸan biremne, uqu yä ki yazu eÅŸe öçen açıp bulmí -Comment[uk]=Вибраний файл не може бути відкритий Ð´Ð»Ñ Ñ‡Ð¸Ñ‚Ð°Ð½Ð½Ñ Ð°Ð±Ð¾ запиÑу -Comment[uz]=Tanlangan faylni na oÊ»qish na yozish uchun ochib boÊ»ladi. -Comment[uz@cyrillic]=Танланган файлни на ўқиш на ёзиш учун очиб бўлади. -Comment[ven]=Faela yo nangwaho ingasi vulwe u vhala kana u nwala -Comment[vi]=Tập tin được chá»n không có khả năng mở để Ä‘á»c hay ghi. -Comment[xh]=Ifayile ekhethiweyo ayinakuvulelwa ukufunda okanye ukubhala -Comment[zh_CN]=选中的文件ä¸èƒ½æ‰“å¼€æ¥è¯»æˆ–写 -Comment[zh_HK]=所é¸å–的檔案無法開啟進行讀å–或者是寫入 -Comment[zh_TW]=所é¸å–的檔案無法開啟進行讀å–或者是寫入 -Comment[zu]=Ifayela elikhethiwe alingeke livulwe ukuze lifundwe ukufundwa noma ukubhalwa -default_presentation=0 - -[fatalerror] -Name=Fatal Error -Name[af]=Fatale Fout -Name[ar]=خطأ قاتل -Name[az]=Ölümcül XÉ™ta -Name[bg]=Фатална грешка -Name[bn]=মারাতà§à¦®à¦• সমসà§à¦¯à¦¾ -Name[br]=Fazi sac'hus -Name[bs]=Fatalna greÅ¡ka -Name[ca]=Error fatal -Name[cs]=Závažná chyba -Name[csb]=Kriticznô fela -Name[cy]=Gwall Angheuol -Name[da]=Fatal fejl -Name[de]=Schwerer Fehler -Name[el]=ΜοιÏαίο σφάλμα -Name[eo]=Grava Eraro -Name[es]=Error fatal -Name[et]=Fataalne viga -Name[eu]=Errore larria -Name[fa]=خطای مهلک -Name[fi]=Peruuttamaton virhe -Name[fr]=Problème critique -Name[fy]=Fatale flater -Name[ga]=Earráid Mharfach -Name[gl]=Erro moi grave -Name[he]=שגי××” חמורה -Name[hi]=गंभीर तà¥à¤°à¥à¤Ÿà¤¿ -Name[hr]=Ozbiljna pogreÅ¡ka -Name[hsb]=Fatalny zmylk -Name[hu]=Végzetes hiba -Name[id]=Kesalahan Fatal -Name[is]=Banvæn villa -Name[it]=Errore fatale -Name[ja]=致命的ãªã‚¨ãƒ©ãƒ¼ -Name[ka]=ფáƒáƒ¢áƒáƒšáƒ£áƒ áƒ˜ შეცდáƒáƒ›áƒ -Name[kk]=Түзелмейтін қате -Name[km]=កំហុស​ធ្ងន់ធ្ងរ -Name[ko]=치명ì ì¸ 오류 -Name[lb]=Fatale Feeler -Name[lt]=Lemtinga klaida -Name[lv]=FatÄla Kļūda -Name[mk]=Фатална грешка -Name[mn]=Үхлүүт(Fatal) алдаа -Name[ms]=Ralat Maut -Name[mt]=Problema Fatali -Name[nb]=Fatal feil -Name[nds]=Groot Malöör -Name[ne]=घातक तà¥à¤°à¥à¤Ÿà¤¿ -Name[nl]=Fatale fout -Name[nn]=Fatal feil -Name[nso]=Bothatathata -Name[oc]=Error fatala -Name[pa]=ਘਾਤਕ ਗਲਤੀ -Name[pl]=BÅ‚Ä…d krytyczny -Name[pt]=Erro Fatal -Name[pt_BR]=Erro fatal -Name[ro]=Eroare fatală -Name[ru]=Ð¤Ð°Ñ‚Ð°Ð»ÑŒÐ½Ð°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ° -Name[rw]=Ikosa rikomeye -Name[se]=VáralaÅ¡ meattáhus -Name[sk]=Fatálna chyba -Name[sl]=Usodna napaka -Name[sq]=Gabim fatal -Name[sr]=Кобна грешка -Name[sr@Latn]=Kobna greÅ¡ka -Name[ss]=Liphutsa lelibi -Name[sv]=Allvarligt fel -Name[ta]=மீளமà¯à®Ÿà®¿à®¯à®¾à®¤à¯ தவற௠-Name[te]=హానికరమైన దోషం -Name[tg]=Хатои ногузир -Name[th]=เà¸à¸´à¸”ข้อผิดพลาดร้ายà¹à¸£à¸‡ -Name[tr]=Ölümcül Hata -Name[tt]=Ãœtmäslek Xata -Name[uk]=Фатальна помилка -Name[uz]=Juda jiddiy xato -Name[uz@cyrillic]=Жуда жиддий хато -Name[ven]=Vhukhakhi vhuhulwane -Name[vi]=Lá»—i nghiêm trá»ng -Name[wa]=Aroke moirt -Name[xh]=Imposiso Enengozi -Name[zh_CN]=致命错误 -Name[zh_HK]=åš´é‡éŒ¯èª¤ -Name[zh_TW]=åš´é‡éŒ¯èª¤ -Name[zu]=Iphutha Lengozi -Comment=There was a serious error causing the program to exit -Comment[af]=Daar was 'n ernstige fout wat veroorsaak het dat die program beïendig is. -Comment[be]=ÐдбылаÑÑ Ñур'Ñ‘Ð·Ð½Ð°Ñ Ð¿Ð°Ð¼Ñ‹Ð»ÐºÐ°, ÑÐºÐ°Ñ Ð¿Ñ€Ñ‹Ð²Ñла да выхаду з праграмы -Comment[bg]=ПоÑви Ñе Ñериозна грешка, коÑто предизвика Ñпиране на програмата -Comment[bn]=à¦à¦•à¦Ÿà¦¿ গà§à¦°à§à¦¤à¦° তà§à¦°à§à¦Ÿà¦¿à¦° দরà§à¦£ পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à¦Ÿà¦¿ থেমে গেছে -Comment[br]=Ur fazi grevus a voe pennabeg mont er-maez ar goulev. -Comment[bs]=Program je morao zavrÅ¡iti zbog ozbiljne greÅ¡ke -Comment[ca]=Hi ha hagut un error seriós que ha fet que el programa acabi -Comment[cs]=Nastala závažná chyba, která způsobila ukonÄení programu -Comment[csb]=Pòkôza sã pòwôżnô fela, jakô doprowadzëła do zamkniãcô programë -Comment[da]=Der var et alvorligt problem som fik programmet til at afslutte -Comment[de]=Es ist ein schwerer Fehler aufgetreten und das Programm wurde beendet. -Comment[el]=Συνέβη ένα σοβαÏÏŒ σφάλμα που έκανε το Ï€ÏόγÏαμμα να τεÏματίσει -Comment[eo]=Okazis grava eraro, kiu ĉesigis la programon. -Comment[es]=Hubo un error serio que ha causado el cierre del programa -Comment[et]=Ilmnes tõsine viga, mis sundis programmi tööd lõpetama -Comment[eu]=Errore larria gertatu da eta programa itxiarazi du. -Comment[fa]=یک خطای جدی باعث خروج برنامه شد -Comment[fi]=Tapahtui vakava virhe, jonka takia ohjelma lopetettiin -Comment[fr]=Un problème grave a provoqué l'arrêt du programme -Comment[fy]=Der wie in serieuse flater wertroch it programma sluten is -Comment[ga]=Tharla droch-earráid, agus tá an clár tar éis stopadh -Comment[gl]=Houbo un erro sério que provocou o remate da execución do programa -Comment[he]=×ירעה שגי××” חמורה שגרמה לתוכנית לצ×ת -Comment[hi]=à¤à¤• अति गंभीर तà¥à¤°à¥à¤Ÿà¤¿ हà¥à¤ˆ जिसके कारण पà¥à¤°à¥‹à¤—à¥à¤°à¤¾à¤® बाहर हो गया -Comment[hr]=Program je morao zavrÅ¡iti s radom zbog ozbiljne pogreÅ¡ke -Comment[hsb]=Je so chutny zmylk staÅ‚, kiž je program skónÄiÅ‚ -Comment[hu]=Súlyos hiba történt, ezért a program futása félbeszakadt. -Comment[id]=Ada kesalahan serius yang menyebabkan progam diakhiri -Comment[is]=Alvarleg villa stöðvaði keyrslu forritsins. -Comment[it]=Si è verificato un errore grave che ha causato la fine del programma -Comment[ja]=プログラムãŒçµ‚了ã™ã‚‹æ·±åˆ»ãªã‚¨ãƒ©ãƒ¼ãŒã‚ã‚Šã¾ã—㟠-Comment[ka]=სერიáƒáƒ–ული შეცდáƒáƒ›áƒ, რáƒáƒ›áƒ”ლმáƒáƒª პრáƒáƒ’რáƒáƒ›áƒ˜áƒ“áƒáƒœ გáƒáƒ¡áƒ•áƒšáƒ გáƒáƒ›áƒáƒ˜áƒ¬áƒ•áƒ˜áƒ. -Comment[kk]=Бір маңызды қате бағдарламадан шығуға мәжбүрледі -Comment[km]=មាន​កំហុស​ធ្ងន់ធ្ងរ​មួយ​ដែល​បាន​បណ្ážáž¶áž›â€‹áž²áŸ’យ​កម្មវិធី​បិទ -Comment[lb]=Et gouf e schwéiere Feeler, an de Programm gouf zougemat -Comment[lt]=Ä®vyko rimta klaida, privertusi programÄ… užbaigti darbÄ… -Comment[lv]=GadÄ«jusies nopietna kļuda, kas izraisa izieÅ¡anu no programmas -Comment[mk]=Се Ñлучи Ñериозна грешка поради која програмот заврши -Comment[ms]=Ada ralat serius menyebabkan program tutup. -Comment[nb]=Det var en alvorlig feil som førte til at programmet avsluttet -Comment[nds]=Dor is en Malöör passeert, dat Programm warrt afbraken -Comment[ne]=कारà¥à¤¯à¤•à¥à¤°à¤®à¤¬à¤¾à¤Ÿ निसà¥à¤•à¤¨à¤¾à¤²à¥‡ तà¥à¤¯à¤¹à¤¾à¤ गमà¥à¤­à¤¿à¤° तà¥à¤°à¥à¤Ÿà¤¿ भयो -Comment[nl]=Er was een ernstige fout die ervoor zorgde dat dit programma beëindigd werd -Comment[nn]=Ein alvorleg feil førte til at programmet avslutta -Comment[pa]= ਇੱਕ ਘਾਤਕ ਗਲਤੀ ਨੇ ਕਾਰਜ ਨੂੰ ਬੰਦ ਹੋਣ ਲਈ ਮਜਬੂਰ ਕਰ ਦਿੱਤਾ ਹੈ -Comment[pl]=WystÄ…piÅ‚ poważny bÅ‚Ä…d, który spowodowaÅ‚ zamkniÄ™cie programu -Comment[pt]=Ocorreu um erro grave que provocou o fim da execução do programa -Comment[pt_BR]=Houve um erro sério, que fez o programa finalizar -Comment[ro]=A apărut o eroare severă care a determinat terminarea programului -Comment[ru]=Серьёзный Ñбой, приведший к выходу из программы. -Comment[rw]=Habaye ikosa rikomeye ritera porogaramu guhagarara -Comment[se]=Vearrás meattáhusa geažil prográmma heittii -Comment[sk]=Vyskytla sa vážna chyba, ktorá spôsobila ukonÄenie programu -Comment[sl]=Program se je konÄal zaradi resne napake -Comment[sr]=ДеÑила Ñе озбиљна грешка, која је изазвала да Ñе програм затвори -Comment[sr@Latn]=Desila se ozbiljna greÅ¡ka, koja je izazvala da se program zatvori -Comment[sv]=Ett allvarligt fel uppstod vilket fick programmet att avslutas -Comment[ta]=நிரலை வெளியேறச௠செயà¯à®•à®¿à®± அளவில௠ஒர௠பெரிய தவறà¯à®£à¯à®Ÿà¯. -Comment[te]=à°®à±à°–à±à°¯à°®à±ˆà°¨ దోషం à°’à°•à°Ÿà°¿ కారà±à°¯à°•à±à°°à°®à°‚ నిషà±à°•à±à°°à°®à°£à°•à± కారణమైనది -Comment[tg]=ÐуқÑони ҷиддие, ки ба баромадан аз барнома раÑонид -Comment[th]=เà¸à¸´à¸”ข้อผิดพลาดร้ายà¹à¸£à¸‡ ทำให้ต้องออà¸à¸ˆà¸²à¸à¹‚ปรà¹à¸à¸£à¸¡ -Comment[tr]=Programın kapanmasına neden olan ciddi bir hata oluÅŸtu -Comment[tt]=Yazılımnan çığuına kitergän citdi xata kilep çıqqan -Comment[uk]=Серйозна помилка Ñтала причиною виходу програми -Comment[uz]=Dasturning ishini yakunlanishiga sababchi boÊ»lgan jiddiy xato roÊ»y berdi -Comment[uz@cyrillic]=ДаÑтурнинг ишини Ñкунланишига Ñабабчи бўлган жиддий хато рўй берди -Comment[vi]=Gặp lá»—i nghiêm trong mà gây ra chÆ°Æ¡ng trình thoát. -Comment[zh_CN]=有一个严é‡çš„错误导致程åºé€€å‡º -Comment[zh_HK]=發生了嚴é‡çš„錯誤,導致程å¼çµæŸ -Comment[zh_TW]=發生了一個嚴é‡çš„錯誤導致çµæŸè©²ç¨‹å¼ã€‚ -default_presentation=2 -level=4 - -[notification] -Name=Notification -Name[af]=Inkennisstelling -Name[ar]=تنبيه -Name[az]=XÉ™bÉ™rdarlıq -Name[be]=Ðагадванне -Name[bg]=Съобщение -Name[bn]=সংবাদ -Name[br]=Kemennadenn -Name[bs]=ObavjeÅ¡tenje -Name[ca]=Notificació -Name[cs]=Oznámení -Name[csb]=Ã’dkôzanié -Name[cy]=Hybys -Name[da]=Bekendtgørelse -Name[de]=Benachrichtigung -Name[el]=Ειδοποίηση -Name[eo]=Atentigo -Name[es]=Notificación -Name[et]=Märguanne -Name[eu]=Jakinarazpena -Name[fa]=اخطار -Name[fi]=Huomautus -Name[fo]=Ãminning -Name[fy]=Notifikaasje -Name[ga]=Fógairt -Name[gl]=Notificación -Name[he]=הודעה -Name[hi]=सूचना -Name[hr]=Obavijest -Name[hsb]=Zdźělenka -Name[hu]=Rendszerfigyelmeztetések -Name[id]=Pemberitahuan -Name[is]=Tilkynning -Name[it]=Avviso -Name[ja]=通知 -Name[ka]=შეტყáƒáƒ‘ინებრ-Name[kk]=Құлақтандыру -Name[km]=ការ​ជូន​ដំណឹង -Name[ko]=알림 -Name[lb]=Noricht -Name[lt]=PraneÅ¡imai -Name[lv]=ApziņoÅ¡ana -Name[mk]=ИзвеÑтување -Name[mn]=Сонордуулга -Name[ms]=Pemberitahuan -Name[mt]=Notifika -Name[nb]=Varsling -Name[nds]=Bescheed -Name[ne]=सूचना -Name[nl]=Notificatie -Name[nn]=PÃ¥minning -Name[nso]=Tsebiso -Name[oc]=Notificacion -Name[pa]=ਟਿੱਪਣੀ -Name[pl]=Powiadomienie -Name[pt]=Mensagem -Name[pt_BR]=Notificação -Name[ro]=Notificare -Name[ru]=Сообщение -Name[rw]=Imenyesha -Name[se]=Dieđáhus -Name[sk]=Upozornenie -Name[sl]=Obvestilo -Name[sq]=Lajmërim -Name[sr]=Обавештење -Name[sr@Latn]=ObaveÅ¡tenje -Name[ss]=Satiso -Name[sv]=Underrättelse -Name[ta]=அறிவிபà¯à®ªà¯ -Name[te]=à°ªà±à°°à°•à°Ÿà°¨ -Name[tg]=Иттилоот -Name[th]=à¸à¸²à¸£à¹à¸ˆà¹‰à¸‡à¹€à¸•à¸·à¸­à¸™ -Name[tr]=Uyarı -Name[tt]=Beldermä -Name[uk]=ÐŸÐ¾Ð²Ñ–Ð´Ð¾Ð¼Ð»ÐµÐ½Ð½Ñ -Name[uz]=Xabarnoma -Name[uz@cyrillic]=Хабарнома -Name[ven]=Ndivhadzo -Name[vi]=Thông báo -Name[wa]=Notifiaedje -Name[xh]=Isaziso -Name[zh_CN]=通知 -Name[zh_HK]=通知 -Name[zh_TW]=通知 -Name[zu]=Isaziso -Comment=Something special happened in the program -Comment[af]=Iets spesiaal het met die program gebeur -Comment[bg]=Ð’ програмата Ñе Ñлучи нещо неочаквано -Comment[bn]=পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à§‡ বিশেষ কিছৠà¦à¦•à¦Ÿà¦¾ ঘটেছে -Comment[br]=Un dra bennak dibar a c'hoarvezas gant ar goulev -Comment[bs]=NeÅ¡to posebno se desilo u programu -Comment[ca]=Ha passat quelcom d'especial al programa -Comment[cs]=NÄ›co zvláštního se stalo s programem -Comment[csb]=W programie staÅ‚o sã cos òsoblëwégò -Comment[da]=Der skete noget specielt i programmet -Comment[de]=Es ist eine besondere Programmsituation aufgetreten. -Comment[el]=Κάτι εξαιÏετικό συνέβη στο Ï€ÏόγÏαμμα -Comment[eo]=Io nekutima okazis en la programo -Comment[es]=Ocurrió algo especial en el programa -Comment[et]=Programmis juhtus midagi erilist -Comment[eu]=Gertaera berezia gertatu da programan -Comment[fa]=اتÙاق خاصی در برنامه رخ داد -Comment[fi]=Ohjelmassa tapahtui jotain erikoista -Comment[fr]=Quelque chose de spécial s'est passé dans le programme -Comment[fy]=Der barde wat spesjaals yn't programma -Comment[ga]=Tharla rud éigean ar leith sa chlár -Comment[gl]=Ocorreu algo especial no programa -Comment[he]=משהו מיוחד קרה ×¢× ×”×ª×•×›× ×™×ª -Comment[hi]=पà¥à¤°à¥‹à¤—à¥à¤°à¤¾à¤® मे कà¥à¤› महतà¥à¤µà¤ªà¥‚रà¥à¤£ घटित हà¥à¤† -Comment[hr]=NeÅ¡to se posebno dogodilo u programu -Comment[hsb]=Něšto njewoÄakowane je so staÅ‚o -Comment[hu]=Valami különleges történt a programban -Comment[id]=Sesuatu yang khusus terjadi dalam program -Comment[is]=Eitthvað sérstakt gerðist í forritinu -Comment[it]=È successo qualcosa di speciale nel programma -Comment[ja]=何ã‹ç‰¹åˆ¥ãªã“ã¨ãŒãƒ—ログラムã«èµ·ã“ã‚Šã¾ã—㟠-Comment[ka]=პრáƒáƒ’რáƒáƒ›áƒáƒ¨áƒ˜ რáƒáƒ¦áƒáƒª გáƒáƒœáƒ¡áƒáƒ™áƒ£áƒ—რებული მáƒáƒ®áƒ“რ-Comment[kk]=Бағдарламада ерекше бірдеме болды -Comment[km]=មាន​អ្វី​ពិសáŸážŸâ€‹áž˜áž½áž™â€‹áž”ាន​កើážâ€‹áž¡áž¾áž„​ក្នុង​កម្មវិធី -Comment[lb]=Et ass eng speziell Programmsituatioun opgetrueden -Comment[lt]=Kažkoks specialus įvykis programoje -Comment[lv]=ProgrammÄ noticis kas speciÄls -Comment[mk]=Ðешто Ñпецијално Ñе Ñлучило во програмот -Comment[ms]=Sesuatu yang pelik berlaku di dalam program -Comment[nb]=Noe spesielt skjedde med programmet -Comment[nds]=In dat Programm is wat besünners passeert -Comment[ne]=कारà¥à¤¯à¤•à¥à¤°à¤®à¤®à¤¾ केही विशेष आइपरà¥à¤¯à¥‹ -Comment[nl]=Er gebeurde iets bijzonders in het programma -Comment[nn]=Noko spesielt skjedde i programmet -Comment[pa]=ਇਸ ਕਾਰਜ ਵਿੱਚ ਕà©à¨ ਖਾਸ ਹੋ ਗਿਆ ਹੈ -Comment[pl]=CoÅ› specjalnego staÅ‚o sie w programie -Comment[pt]=Ocorreu algo de especial no programa -Comment[pt_BR]=Algo especial ocorreu no programa -Comment[ro]=S-a întîmplat ceva neaÅŸteptat în program -Comment[ru]=Ð’ программе возникла Ð½ÐµÐ¿Ñ€ÐµÐ´Ð²Ð¸Ð´ÐµÐ½Ð½Ð°Ñ ÑÐ¸Ñ‚ÑƒÐ°Ñ†Ð¸Ñ -Comment[rw]=Ikintu kidasanzwe cyabaye muri porogaramu -Comment[se]=Juoga erenoamáš dáhpáhuvai prográmmas -Comment[sk]=V programe sa udialo nieÄo neoÄakávané -Comment[sl]=V programu se je zgodilo nekaj izrednega -Comment[sr]=Ðешто поÑебно Ñе деÑило у програму -Comment[sr@Latn]=NeÅ¡to posebno se desilo u programu -Comment[sv]=NÃ¥gonting speciellt inträffade i programmet -Comment[ta]=நிரலில௠à®à®¤à¯‹ விசேடம௠நிகழà¯à®¨à¯à®¤à¯à®³à¯à®³à®¤à¯ -Comment[te]=కారà±à°¯à°•à±à°°à°®à°‚ లొ à°’à°• విశేషం చొటà±à°šà±†à°¸à±à°•à±à°‚ది -Comment[tg]=Дар барнома ҳолати ногаҳонӣ рӯй дод -Comment[th]=เà¸à¸´à¸”บางอย่างที่พิเศษขึ้นในโปรà¹à¸à¸£à¸¡ -Comment[tr]=Programda özel bir durum meydana geldi -Comment[tt]=Yazılımda kötelmägän närsä kilep çıqqan -Comment[uk]=ЩоÑÑŒ оÑобливе ÑталоÑÑŒ у програмі -Comment[uz]=Dasturda qandaydir odatdan tashqari hodisa roÊ»y berdi -Comment[uz@cyrillic]=ДаÑтурда қандайдир одатдан ташқари ҳодиÑа рўй берди -Comment[vi]=Có gì đặc biệt đã xảy ra trong chÆ°Æ¡ng trình. -Comment[zh_CN]=程åºä¸­å‘生了特殊情况 -Comment[zh_HK]=程å¼ç™¼ç”Ÿäº†ç‰¹æ®Šæƒ…æ³ -Comment[zh_TW]=程å¼ä¸­ç™¼ç”Ÿäº†ç‰¹æ®Šçš„æƒ…æ³ -default_presentation=1 -default_sound=KDE_Beep.ogg -level=1 - -[warning] -Name=Warning -Name[af]=Waarskuwing -Name[ar]=تحذير -Name[az]=DiqqÉ™t -Name[be]=ПапÑÑ€Ñджанне -Name[bg]=Предупреждение -Name[bn]=সতরà§à¦•à§€à¦•à¦°à¦£ -Name[br]=Kemenn -Name[bs]=Upozorenje -Name[ca]=Avís -Name[cs]=Varování -Name[csb]=Ã’strzega -Name[cy]=Rhybudd -Name[da]=Advarsel -Name[de]=Warnung -Name[el]=ΠÏοειδοποίηση -Name[eo]=Averto -Name[es]=Aviso -Name[et]=Hoiatus -Name[eu]=Abisua -Name[fa]=اخطار -Name[fi]=Varoitus -Name[fo]=Ãvaring -Name[fr]=Avertissement -Name[fy]=Warskôging -Name[ga]=Rabhadh -Name[gl]=Aviso -Name[he]=×זהרה -Name[hi]=चेतावनी -Name[hr]=Upozorenje -Name[hsb]=Warnowanje -Name[hu]=Figyelmeztetés -Name[id]=Perhatian -Name[is]=Aðvörun -Name[it]=Avvertimento -Name[ja]=警告 -Name[ka]=გáƒáƒ¤áƒ áƒ—ხილებრ-Name[kk]=ЕÑкерту -Name[km]=ព្រមាន -Name[ko]=경고 -Name[lb]=Warnung -Name[lt]=DÄ—mesio -Name[lv]=BrÄ«dinÄjums -Name[mk]=Предупредување -Name[mn]=Сануулга -Name[ms]=Amaran -Name[mt]=Twissija -Name[nb]=Advarsel -Name[nds]=Wohrschoen -Name[ne]=चेतावनी -Name[nl]=Waarschuwing -Name[nn]=Ã…tvaring -Name[nso]=Temoso -Name[oc]=Avis -Name[pa]=ਚੇਤਾਵਨੀ -Name[pl]=Ostrzeżenie -Name[pt]=Aviso -Name[pt_BR]=Aviso -Name[ro]=Avertizare -Name[ru]=Предупреждение -Name[rw]=Iburira -Name[se]=Váruhus -Name[sk]=Varovanie -Name[sl]=Opozorilo -Name[sq]=Vërejtje -Name[sr]=Упозорење -Name[sr@Latn]=Upozorenje -Name[ss]=Secwayiso -Name[sv]=Varning -Name[ta]=எசà¯à®šà®°à®¿à®•à¯à®•à¯ˆ -Name[te]=హెచà±à°šà°°à°¿à°• -Name[tg]=Огоҳӣ -Name[th]=คำเตือน -Name[tr]=Dikkat -Name[tt]=Kisätmä -Name[uk]=ÐŸÐ¾Ð¿ÐµÑ€ÐµÐ´Ð¶ÐµÐ½Ð½Ñ -Name[uz]=Diqqat -Name[uz@cyrillic]=Диққат -Name[ven]=Khaidzo -Name[vi]=Cảnh báo -Name[wa]=Adviertixhmint -Name[xh]=Isilumkiso -Name[zh_CN]=警告 -Name[zh_HK]=警告 -Name[zh_TW]=警告 -Name[zu]=Isexwayiso -Comment=There was an error in the program which may cause problems -Comment[af]=Daar was 'n fout in die program wat dalk probleme kan veroorsaak -Comment[be]=У праграме адбылаÑÑ Ð¿Ð°Ð¼Ñ‹Ð»ÐºÐ°, ÑÐºÐ°Ñ Ð¼Ð¾Ð¶Ð° Ñтварыць перашкоды нармальнай працы -Comment[bg]=ПоÑви Ñе грешка, коÑто може да предизвика проблеми -Comment[bn]=পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à§‡ à¦à¦•à¦Ÿà¦¿ তà§à¦°à§à¦Ÿà¦¿ ছিল যার ফলে সমসà§à¦¯à¦¾ হতে পারে -Comment[br]=Ur fazi a voe er goulev a c'hellfe bezañ pennabeg kudennoù. -Comment[bs]=Postoji greÅ¡ka u programu koja možda uzrokuje probleme. -Comment[ca]=Hi ha hagut un error en el programa que podria causar problemes -Comment[cs]=Nastala chyba v programu, která může způsobit problémy -Comment[csb]=Pòkôza sã fela, jakô mòże doprowadzëc do zmiÅ‚ków w dalszi robòce -Comment[da]=Der opstod en alvorlig fejl som kan forÃ¥rsage problemer -Comment[de]=Es ist ein Programmfehler aufgetreten, der Probleme verursachen könnte. -Comment[el]=ΥπήÏξε ένα σφάλμα στο Ï€ÏόγÏαμμα που ίσως να Ï€Ïοκαλέσει Ï€Ïοβλήματα -Comment[eo]=Okazis eraro en la programo, kiu povus kaÅ­zi problemojn. -Comment[es]=Hubo un error en el programa que puede causar problemas -Comment[et]=Programmis ilmnes viga, mis võib tekitada probleeme -Comment[eu]=Arazoak sor ditzakeen errorea gertatu da programan -Comment[fa]=خطایی در برنامه وجود دارد Ú©Ù‡ ممکن است باعث بروز مسائلی شود -Comment[fi]=Ohjelmassa tapahtui virhe, joka voi aiheuttaa ongelmia -Comment[fr]=Une erreur est survenu dans le programme, pouvant causer des dysfonctionnements. -Comment[fy]=Der wie in flater yn it programma wat swierrichheid feroorsaakje kin -Comment[ga]=Bhí earráid sa chlár agus b'fhéidir go mbeidh fadhbanna dá barr -Comment[gl]=Houbo un erro no programa que pode causar problemas. -Comment[he]=×ירעה שגי××” חמורה שעלולה ×œ×’×¨×•× ×œ×‘×¢×™×•×ª -Comment[hi]=पà¥à¤°à¥‹à¤—à¥à¤°à¤¾à¤® में तà¥à¤°à¥à¤Ÿà¤¿ है जिससे समसà¥à¤¯à¤¾ उतà¥à¤ªà¤¨à¥à¤¨ हो सकती है -Comment[hr]=UoÄena je pogreÅ¡ka u programu zbog koje bi moglo biti problema -Comment[hsb]=Je so nÄ›kajki zmylk staÅ‚, kiž móhÅ‚ problemy sÄinić -Comment[hu]=Olyan hiba történt a programban, mely további problémákat okozhat -Comment[id]=Ada kesalahan dalam program yang dapat menyebabkan masalah -Comment[is]=Það kom upp villa í forritinu sem gæti valdið vandræðum -Comment[it]=Nel programma si è verificato un errore che può causare problemi -Comment[ja]=å•é¡Œã‚’引ãèµ·ã“ã™å¯èƒ½æ€§ã®ã‚るエラーãŒãƒ—ログラムã«ã‚ã‚Šã¾ã—㟠-Comment[ka]=პრáƒáƒ’რáƒáƒ›áƒ˜áƒ¡ შეცდáƒáƒ›áƒ, რáƒáƒ›áƒ”ლმáƒáƒª შესáƒáƒ«áƒšáƒáƒ პრáƒáƒ‘ლემრშექმნáƒáƒ¡ -Comment[kk]=Бір қате бағдарламада мәÑелелер тудырды -Comment[km]=មាន​កំហុស​មួយ​ក្នុង​កម្មវិធី​ដែល​អាច​បណ្ážáž¶áž›â€‹áž²áŸ’យ​មាន​បញ្ហា -Comment[lb]=Et ass e Feeler am Programm opgetrueden, dee Problemer verursaache kéint -Comment[lt]=Ä®vyko programos klaida, galinti sukelti problemų -Comment[lv]=ProgrammÄ bija kļūda, kas var radÄ«t problÄ“mas -Comment[mk]=Се Ñлучи грешка во програмот што може да предизвика проблеми -Comment[ms]=Ada ralat di dalam program yang menyebabkan masalah. -Comment[nb]=Det var en feil i programmet som kan føre til problemer -Comment[nds]=Dat geev en Fehler in dat Programm, villicht treckt he Problemen na sik -Comment[ne]=समसà¥à¤¯à¤¾ आउनà¥à¤®à¤¾ कारà¥à¤¯à¤•à¥à¤°à¤®à¤®à¤¾ तà¥à¤°à¥à¤Ÿà¤¿ कारण थियो -Comment[nl]=Er zat een fout in het programma die voor problemen kon zorgen -Comment[nn]=Det oppstod ein feil i programmet og kan føra til problem -Comment[pa]=ਕਾਰਜ ਵਿੱਚ ਗਲਤੀ ਆਈ ਹੈ, ਜੋ ਕਿ ਸਮੱਸਿਆ ਪੈਦਾ ਕਰ ਰਹੀ ਹੈ -Comment[pl]=WystÄ…piÅ‚ bÅ‚Ä…d, który może spowodować zakłócenia w pracy -Comment[pt]=Ocorreu um erro grave no programa que pode causar problemas -Comment[pt_BR]=Houve um erro no programa que pode ter causado problemas -Comment[ro]=A apărut o eroare în program care ar putea cauza probleme -Comment[ru]=Ошибка в программе, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð¼Ð¾Ð¶ÐµÑ‚ вызвать проблемы -Comment[rw]=Habaye ikosa muri porogaramu rishobora gutera ibibazo -Comment[se]=Prográmmas lei meattáhus mii sáhttá dagahit váttisvuoÄ‘aid -Comment[sk]=V programe sa vyskytla chyba, ktorá môže spôsobiÅ¥ problémy -Comment[sl]=V programu je nastala napaka, ki lahko povzroÄi težave -Comment[sr]=ДеÑила Ñе грешка у програму која може изазвати проблеме -Comment[sr@Latn]=Desila se greÅ¡ka u programu koja može izazvati probleme -Comment[sv]=Det uppstod ett fel i programmet vilket kan orsaka problem -Comment[ta]=பிரசà¯à®©à¯ˆà®•à®³à¯ˆ à®à®±à¯à®ªà®Ÿà¯à®¤à¯à®¤à¯à®®à¯ அளவிறà¯à®•à¯ நிரலில௠ஒர௠தவற௠இரà¯à®¨à¯à®¤à®¤à¯. -Comment[te]=కారà±à°¯à°•à±à°°à°®à°‚ లొ దోషం కలదà±, ఇది సమసà±à°¯à°²à°¨à± à°•à°²à±à°—చేయవచà±à°šà±à°¨à± -Comment[tg]=Хатои барнома, ки метавон ба маÑъалаҳое оварад -Comment[th]=มีข้อผิดพลาดในโปรà¹à¸à¸£à¸¡ ซึ่งอาจจะส่งผลให้เà¸à¸´à¸”ปัà¸à¸«à¸²à¹„ด้ -Comment[tr]=Programda ciddi bir hata oluÅŸtu -Comment[tt]=QıyınlıqlarÄŸa kiterä ala torÄŸan xatalar kilep çıqqannar -Comment[uk]=СталаÑÑ Ñерйозна помилка, Ñка може викликати проблеми -Comment[uz]=Dasturda muammolarga olib kelishi mumkin boÊ»lgan xato roÊ»y berdi -Comment[uz@cyrillic]=ДаÑтурда муаммоларга олиб келиши мумкин бўлган хато рўй берди -Comment[vi]=Gặp lá»—i trong chÆ°Æ¡ng trình, mà có thể gây ra vấn Ä‘á». -Comment[zh_CN]=程åºä¸­å‘生了å¯èƒ½å¯¼è‡´é—®é¢˜çš„错误 -Comment[zh_TW]=程å¼ä¸­ç™¼ç”Ÿäº†ä¸€å€‹å¯èƒ½æœƒå°Žè‡´ç™¼ç”Ÿå•é¡Œçš„錯誤。 -default_presentation=2 -level=2 - -[catastrophe] -Name=Catastrophe -Name[af]=Katastrofe -Name[ar]=كارثة -Name[az]=FaciÉ™ -Name[be]=КатаÑтрофа -Name[bg]=КатаÑтрофа -Name[bn]=বিপরà§à¦¯à§Ÿ -Name[br]=Gwalldaol -Name[bs]=Katastrofa -Name[ca]=Catàstrofe -Name[cs]=Katastrofa -Name[csb]=Katastrofa -Name[cy]=Erchyll -Name[da]=Katastrofe -Name[de]=Schwerwiegender Fehler -Name[el]=ΚαταστÏοφή -Name[eo]=Katastrofo -Name[es]=Catástrofe -Name[et]=Katastroof -Name[eu]=Ondamendia -Name[fa]=Ùاجعه -Name[fi]=Katastrofi -Name[fy]=Katastrofe -Name[ga]=Tubaiste -Name[gl]=Catástrofe -Name[he]=קטסטרופה -Name[hi]=पà¥à¤°à¤²à¤¯ -Name[hr]=Katastrofa -Name[hsb]=Katastrofa -Name[hu]=Katasztrófa -Name[id]=Katastrofi -Name[is]=Stórslys -Name[it]=Catastrofe -Name[ja]=大惨事 -Name[ka]=სისტემის კრáƒáƒ®áƒ˜ -Name[kk]=Ð–Ð°Ò£Ñ‹Ð»Ñ‹Ñ -Name[km]=មហន្ážážšáž¶áž™ -Name[ko]=í°ì¼ë‚¬ìŠµë‹ˆë‹¤ -Name[lb]=Katastroph -Name[lt]=Katastrofa -Name[lv]=Katastrofa -Name[mk]=КатаÑтрофа -Name[mn]=СүйрÑл -Name[ms]=Malapetaka -Name[mt]=Katastrofu -Name[nb]=Katastrofe -Name[nds]=Katastroof -Name[ne]=विपतà¥à¤¤à¥€ -Name[nl]=Catastrofe -Name[nn]=Katastrofe -Name[oc]=Catastrofe -Name[pa]=ਕਾਟਾਸਟਰੋਫੀ -Name[pl]=Katastrofa -Name[pt]=Catástrofe -Name[pt_BR]=Catástrofe -Name[ro]=Catastrofă -Name[ru]=Сбой ÑиÑтемы -Name[rw]=Amakuba -Name[se]=Katastrofa -Name[sk]=Katastrofa -Name[sl]=Katastrofa -Name[sq]=Katastrofë -Name[sr]=КатаÑтрофа -Name[sr@Latn]=Katastrofa -Name[ss]=Inhlekelele -Name[sv]=Katastrof -Name[ta]=பிரளயம௠-Name[te]=విపతà±à°¤à± -Name[tg]=ÐуқÑони ÑиÑтема -Name[th]=เหตุหายนะ -Name[tr]=Facia -Name[tt]=Bälä-qaza -Name[uk]=КатаÑтрофа -Name[uz]=Fojia -Name[uz@cyrillic]=Фожиа -Name[ven]=Mutshinyalo -Name[vi]=Lá»—i rất nghiêm trá»ng -Name[xh]=Ingozi enkulu -Name[zh_CN]=严é‡é—®é¢˜ -Name[zh_HK]=åš´é‡å•é¡Œ -Name[zh_TW]=åš´é‡å•é¡Œ -Name[zu]=Inhlekelele -Comment=A very serious error occurred, at least causing the program to exit -Comment[af]='n baie ernstige fout het voorgekom. Dit het veroorsaak dat ten minste die program beëindig is -Comment[ar]=حدث خطأ كبير سيؤدي على الأقل الى ايقا٠البرنامج -Comment[az]=Çox ciddi bir xÉ™ta yarandÉ™ vÉ™ proqramı çıxmaÄŸa mÉ™cbur etdi -Comment[be]=ÐдбылаÑÑ Ð²ÐµÐ»ÑŒÐ¼Ñ– Ñур'Ñ‘Ð·Ð½Ð°Ñ Ð¿Ð°Ð¼Ñ‹Ð»ÐºÐ°, ÑÐºÐ°Ñ Ð¿Ñ€Ñ‹Ð²Ñла да выхаду з праграмы -Comment[bg]=ПоÑви Ñе Ñериозна грешка, коÑто предизвика Ñпиране на програмата -Comment[bn]=à¦à¦•à¦Ÿà¦¿ গমà§à¦­à§€à¦° তà§à¦°à§à¦Ÿà¦¿à¦° ফলে পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à¦Ÿà¦¿ থেমে গেছে -Comment[br]=Ur fazi grevus-tre a c'hoarvezas, a lakas d'an nebeutañ ar goulev da vont er-maez -Comment[bs]=DoÅ¡lo je do vrlo ozbiljne greÅ¡ke koja je uzrokovala najmanje prekid programa -Comment[ca]=Hi ha hagut un error molt seriós, com a mínim ha causat la finalització del programa -Comment[cs]=Nastala velmi závažná chyba, která pÅ™inejmenším způsobila ukonÄení programu. -Comment[csb]=Pòkôza sã pòwôżnô fela, jakô doprowadzëła co nômni do zakùńczeniô programë -Comment[cy]=Digwyddodd gwall difrifol iawn, oedd o leiaf yn achosi i'r rhaglen derfynu -Comment[da]=Der opstod et meget alvorligt problem som fik programmet til at afslutte. -Comment[de]=Ein schwerer Fehler ist aufgetreten, der zumindest zum Beenden des Programms geführt hat. -Comment[el]=Ένα Ï€Î¿Î»Ï ÏƒÎ¿Î²Î±ÏÏŒ σφάλμα συνέβη, που τουλάχιστον οδήγησε στο κλείσιμο του Ï€ÏογÏάμματος -Comment[eo]=Okazis tre grava eraro, kiu ĉesigis la programon -Comment[es]=Ocurrió un error muy serio, causando al menos el cierre del programa. -Comment[et]=Ilmnes väga tõsine viga, mis sundis programmi tööd lõpetama. -Comment[eu]=Errore oso larria gertatu da, programa itxiaraziz -Comment[fa]=یک خطای بسیار جدی رخ داد، حداقل باعث خروج برنامه شد -Comment[fi]=Tapahtui vakava virhe, jonka takia ohjelma ainakin lopetetaan. -Comment[fr]=Une erreur très grave s'est produite, provoquant au moins l'arrêt du programme -Comment[fy]=In serieuse flater had him foardyn wertroch it programma sluten is -Comment[ga]=Tharla droch-earráid, agus ara laghad tá an clár tar éis stopadh -Comment[gl]=Ocorreu un erro moi sério, causando polo menos o remate da execución do programa -Comment[he]=×ירעה שגי××” חמורה מ×וד, שלפחות גרמה לתוכנית לצ×ת -Comment[hi]=à¤à¤• अति गंभीर तà¥à¤°à¥à¤Ÿà¤¿ हà¥à¤ˆ, जिससे पà¥à¤°à¥‹à¤—à¥à¤°à¤¾à¤® बाहर हो गया -Comment[hr]=DoÅ¡lo je do jako ozbiljne pogreÅ¡ke, koja će u najmanju ruku prouzrokovati zatvaranje programa. -Comment[hsb]=Je so jara chutny zmylk staÅ‚, kiž je znajmjeÅ„Å¡a program skónÄiÅ‚ -Comment[hu]=Súlyos programhiba történt, a program futása félbeszakadt -Comment[id]=Ada kesalahan serius muncul, menyebabkan program harus diakhiri -Comment[is]=Mjög alvarleg villa kom upp, sem hefur stöðvað keyrslu forritsins -Comment[it]=Si è verificato un errore molto grave, che come minimo ha causato la fine del programma -Comment[ja]=éžå¸¸ã«é‡å¤§ãªã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã€ãã®ãŸã‚ã«å°‘ãªãã¨ã‚‚プログラムãŒçµ‚了ã—ã¾ã—㟠-Comment[ka]=სერიáƒáƒ–ული შეცდáƒáƒ›áƒ, რáƒáƒ›áƒ”ლმáƒáƒª პრáƒáƒ’რáƒáƒ›áƒ˜áƒ“áƒáƒœ გáƒáƒ¡áƒ•áƒšáƒ გáƒáƒ›áƒáƒ˜áƒ¬áƒ•áƒ˜áƒ -Comment[kk]=Өте маңызды бір қате кемінде бағдарламадан шығуға мәжбүрледі -Comment[km]=កំហុស​ដáŸâ€‹áž’្ងន់ធ្ងរ​បំផុážâ€‹áž˜áž½áž™â€‹áž”ាន​កើážáž¡áž¾áž„ ដែល​យ៉ាង​ហោច​ណាស់ ​វា​បណ្ážáž¶áž›â€‹áž²áŸ’យកម្មវិធី​បិទ -Comment[ko]=í”„ë¡œê·¸ëž¨ì´ ëë‚  ë•Œ 아주 심ê°í•œ 오류가 ìƒê²¼ìŠµë‹ˆë‹¤ -Comment[lb]=E ganz schlëmme Feeler ass opgetrueden, deen op Mannst zum Ophale vum Programm gefouert huet -Comment[lt]=Ä®vyko labai rimta klaida, privertusi programÄ… bent jau baigti darbÄ…. -Comment[lv]=GadÄ«jusies ļoti nopietna kļūda, kas kÄ minumums izraisa izieÅ¡anu no programmas -Comment[mk]=Се Ñлучи Ñериозна грешка, што во најмала рака предизвика програмот да Ñе иÑклучи -Comment[mn]=Дор хаÑж программыг таÑлан гарах ноцтой алдаа гарлаа. -Comment[ms]=Ada ralat sangat serius di dalam program yang menyebabkan program keluar -Comment[nb]=Det oppsto en alvorlig feil som til slutt førte til at programmet avsluttet -Comment[nds]=Dor is en Malöör passeert, dat tominnst to't Enn vun't Programm föhrt hett -Comment[ne]=कमà¥à¤¤à¤¿à¤®à¤¾ कारà¥à¤¯à¤•à¥à¤°à¤® अनà¥à¤¤à¥à¤¯ गरà¥à¤¦à¤¾, à¤à¤‰à¤Ÿà¤¾ धेरै गमà¥à¤­à¤¿à¤° तà¥à¤°à¥à¤Ÿà¤¿ देखा परà¥à¤¯à¥‹ -Comment[nl]=Er deed zich een zeer ernstige fout voor, waardoor tenminste de toepassing werd afgesloten -Comment[nn]=Ein svært alvorleg feil oppstod, som førte til at programmet avslutta -Comment[pa]=ਇੱਕ ਘਾਤਕ ਗਲਤੀ ਆਈ ਹੈ, ਘੱਟੋ-ਘੱਟ ਇਹ ਕਾਰਜ ਨੂੰ ਬੰਦ ਹੋਣ ਲਈ ਮਜ਼ਬੂਰ ਕਰ ਰਹੀ ਹੈ -Comment[pl]=WystÄ…piÅ‚ bardzo poważny bÅ‚Ä…d, który spowodowaÅ‚ przynajmniej zakoÅ„czenie programu -Comment[pt]=Ocorreu um erro muito grave, que no mínimo provocou o fim da execução do programa -Comment[pt_BR]=Ocorreu um erro grave, que causou no mínimo a saída do programa. -Comment[ro]=A apărut o eroare foarte severă în program care a provocat cel puÅ£in terminarea lui -Comment[ru]=Возник Ñерьёзный Ñбой, приведший как минимум к выходу из программы -Comment[rw]=Ikosa rikomeye cyane ryagaragaye, rituma porogaramu ihagarara -Comment[se]=Hui vearrás meattáhus dáhpáhuvai, dagahii goit prográmma heaitit -Comment[sk]=Vyskytla sa veľmi vážna chyba, ktorá minimálne ukonÄí program -Comment[sl]=Nastala je tako resna napaka, da se bo konÄal program. -Comment[sq]=Një gabim serioz ka ndodhur, së paku do të shkaktoj mbylljen e programit -Comment[sr]=ДеÑила Ñе веома озбиљна грешка, која ће у најмању руку проузроковати затварање програма -Comment[sr@Latn]=Desila se veoma ozbiljna greÅ¡ka, koja će u najmanju ruku prouzrokovati zatvaranje programa -Comment[sv]=Ett väldigt allvarligt fel uppstod som Ã¥tminstone fick programmet att avslutas -Comment[ta]=நிரலை வெளியேறச௠செயà¯à®¯à¯à®®à¯ அளவில௠ஒர௠பெரிய தவற௠à®à®±à¯à®ªà®Ÿà¯à®Ÿà®¤à¯ -Comment[te]=చాలా à°®à±à°–à±à°¯à°®à±ˆà°¨ దోషం à°’à°•à°Ÿà°¿ కారà±à°¯à°•à±à°°à°®à°‚లో వచà±à°šà°¿à°‚ది,ఇది కనీసం కారà±à°¯à°•à±à°°à°®à°‚ నిషà±à°•à±à°°à°®à°£à°•à± కారణమౌతà±à°‚ది -Comment[tg]=ÐуқÑони ҷиддӣ рӯй дод, ки чун минимум ба аз барнома баромадан раÑонид -Comment[th]=เà¸à¸´à¸”ข้อผิดพลาดที่ร้ายà¹à¸£à¸‡à¸¡à¸²à¸ ซึ่งอย่างน้อยจะทำให้โปรà¹à¸à¸£à¸¡à¸ˆà¸šà¸à¸²à¸£à¸—ำงาน -Comment[tr]=Programın kapanmasına neden olan ciddi bir hata oluÅŸtu ve programdan çıkıldı. -Comment[tt]=İñ kimendä,yazılımnan çığuına kitergän bik citdi xata kilep çıqqan -Comment[uk]=СталаÑÑ Ð´ÑƒÐ¶Ðµ Ñерйозна помилка, Ñка, щонайменше, Ñтала причиною виходу програми -Comment[uz]=Dasturning ishini yakunlanishiga sababchi boÊ»lgan jiddiy xato roÊ»y berdi -Comment[uz@cyrillic]=ДаÑтурнинг ишини Ñкунланишига Ñабабчи бўлган жиддий хато рўй берди -Comment[vi]=Gặp lá»—i rất nghiêm trá»ng mà ít nhất đã gây ra chÆ°Æ¡ng trình thoát. -Comment[zh_CN]=出现了一个éžå¸¸ä¸¥é‡çš„错误,至少使程åºé€€å‡º -Comment[zh_HK]=發生了一個很嚴é‡çš„錯誤,令程å¼å¿…é ˆçµæŸ -Comment[zh_TW]=因為發生了一個很嚴é‡çš„錯誤,所以該程å¼å¿…é ˆè¦çµæŸ -default_presentation=2 -level=8 -[startkde] -Name=Login -Name[af]=Aanteken -Name[ar]=دخول -Name[az]=GiriÅŸ -Name[be]=Уваход -Name[bg]=Вход в ÑиÑтемата -Name[bn]=লগ-ইন -Name[br]=Anv ereañ -Name[bs]=Prijava -Name[ca]=Accés -Name[cs]=PÅ™ihlášení -Name[csb]=Logòwanié -Name[cy]=Mewngofnodi -Name[da]=Log pÃ¥ -Name[de]=Anmelden -Name[el]=ΣÏνδεση -Name[eo]=Ensaluto -Name[es]=Entrada -Name[et]=Sisselogimine -Name[eu]=Hasi saioa -Name[fa]=ورود -Name[fi]=Kirjaudu sisään -Name[fo]=Innrita -Name[fr]=Début de session -Name[fy]=Oanmelde -Name[ga]=Logáil Isteach -Name[he]=כניסה למערכת -Name[hi]=लॉगइन -Name[hr]=Prijava -Name[hsb]=PÅ™izjewjenje -Name[hu]=Bejelentkezés -Name[is]=Innstimplun -Name[it]=Accesso -Name[ja]=ログイン -Name[ka]=შესვლრ-Name[kk]=Кіру -Name[km]=ចូល -Name[ko]=ë¡œê·¸ì¸ -Name[ku]=Têketin -Name[lb]=Umellen -Name[lt]=Registracija -Name[lv]=Pieteikties -Name[mk]=Ðајавување -Name[mn]=БүртгүүлÑÑ… -Name[ms]=Log masuk -Name[nb]=Logg inn -Name[nds]=Anmellen -Name[ne]=लगइन -Name[nl]=Aanmelden -Name[nn]=Logg inn -Name[nso]=Tsena -Name[oc]=Conneccion -Name[pa]=ਲਾਗਇਨ -Name[pl]=Zalogowanie -Name[pt]=Inicio de sessão -Name[ro]=Logare -Name[ru]=Вход -Name[rw]=Ifashayinjira -Name[se]=SisaÄáliheapmi -Name[sk]=Prihlásenie -Name[sl]=Prijava -Name[sq]=Hyni -Name[sr]=Пријава -Name[sr@Latn]=Prijava -Name[ss]=Kungena -Name[sv]=Logga in -Name[ta]=நà¯à®´à¯ˆà®µà¯ -Name[te]=లాగినౠ-Name[tg]=Вурудот -Name[th]=ล็อà¸à¸­à¸´à¸™ -Name[tr]=GiriÅŸ -Name[tt]=KereÅŸ -Name[uk]=РеєÑÑ‚Ñ€Ð°Ñ†Ñ–Ñ -Name[uz]=Kirish -Name[uz@cyrillic]=Кириш -Name[ven]=U dzhena kha khomupwutha -Name[vi]=Äăng nhập -Name[wa]=Elodjaedje -Name[xh]=Igama elithile -Name[zh_CN]=登录 -Name[zh_HK]=登入 -Name[zh_TW]=登入 -Name[zu]=Ukungena ngaphakathi -Comment=KDE is starting up -Comment[af]=Begin KDE Laai -Comment[ar]=جاري بدء تشغيل KDE -Comment[be]=Стартаванне KDE -Comment[bg]=Стартиране на ÑиÑтемата -Comment[bn]=কে.ডি.ই. চালৠহচà§à¦›à§‡ -Comment[br]=Emañ o loc'hañ KDE -Comment[bs]=KDE se pokreće -Comment[ca]=S'està engegant el KDE -Comment[cs]=SpouÅ¡tí se prostÅ™edí KDE -Comment[csb]=Zrëszënié KDE -Comment[da]=KDE er ved at starte -Comment[de]=KDE startet -Comment[el]=Το KDE ξεκινά -Comment[eo]=KDE estas lanĉata -Comment[es]=KDE está arrancando -Comment[et]=KDE käivitub -Comment[eu]=KDE abiarazten ari da -Comment[fa]=KDE در حال راه‌اندازی است -Comment[fi]=KDE:tä käynnistetään -Comment[fr]=KDE est en cours de démarrage -Comment[fy]=KDE set útein -Comment[ga]=Tá KDE ag tosú. -Comment[gl]=KDE está a Iniciar-se -Comment[he]=×יתחול KDE בעיצומו -Comment[hi]=केडीई पà¥à¤°à¤¾à¤°à¤‚भ हो रहा है -Comment[hr]=Podizanje KDE -Comment[hsb]=KDE so startuje -Comment[hu]=A KDE elindul -Comment[id]=KDE mulai dijalankan -Comment[is]=KDE er að ræsa -Comment[it]=Avvio di KDE -Comment[ja]=KDE 起動中 -Comment[ka]=KDE-ს დáƒáƒ¬áƒ§áƒ”ბრ-Comment[kk]=KDE жұмыÑын баÑтауда -Comment[km]=KDE កំពុង​ចាប់ផ្ážáž¾áž˜ -Comment[ku]=KDE dest pê dike -Comment[lb]=KDE gëtt gestart -Comment[lt]=KDE pradeda darbÄ… -Comment[lv]=Tiek startÄ“ts KDE -Comment[mk]=KDE Ñе вклучува -Comment[ms]=KDE sedang bermula -Comment[nb]=KDE starter -Comment[nds]=KDE warrt start -Comment[ne]=KDE सà¥à¤°à¥à¤†à¤¤ हà¥à¤¦à¥ˆà¤› -Comment[nl]=KDE is aan het opstarten -Comment[nn]=KDE startar -Comment[pa]=KDE ਸ਼à©à¨°à©‚ ਹੋ ਰਿਹਾ ਹੈ -Comment[pl]=Uruchomienie KDE -Comment[pt]=O KDE está a arrancar -Comment[pt_BR]=KDE está iniciando -Comment[ro]=KDE porneÅŸte -Comment[ru]=ЗапуÑк KDE -Comment[rw]=KDE iri gutangira -Comment[se]=KDE vuolgigoahtá johtui -Comment[sk]=KDE sa spúšťa -Comment[sl]=KDE se zaganja -Comment[sr]=KDE Ñе покреће -Comment[sr@Latn]=KDE se pokreće -Comment[sv]=KDE startas -Comment[ta]=கேடிஇ ஆரமà¯à®ªà®¿à®•à¯à®•à®¿à®±à®¤à¯ -Comment[te]=కెడిఈ మొదవà±à°¤à±à°‚ది -Comment[tg]=Оғози KDE -Comment[th]=KDE à¸à¸³à¸¥à¸±à¸‡à¹€à¸£à¸´à¹ˆà¸¡à¸à¸²à¸£à¸—ำงาน -Comment[tr]=KDE masaüstü baÅŸlıyor -Comment[tt]=KDE yöklänä -Comment[uk]=Триває запуÑк KDE -Comment[uz]=KDE ishga tushmoqda -Comment[uz@cyrillic]=KDE ишга тушмоқда -Comment[vi]=KDE Ä‘ang khởi chạy. -Comment[zh_CN]=KDE 正在å¯åŠ¨ -Comment[zh_HK]=KDE 正在啟動 -Comment[zh_TW]=KDE 正在啟動 -default_presentation=1 -default_sound=KDE_Startup_1.ogg - -[exitkde] -Name=Logout -Name[af]=Teken af -Name[ar]=الخروج -Name[az]=Çıxış -Name[be]=ЗаканчÑнне ÑеанÑу -Name[bg]=Изход от ÑиÑтемата -Name[bn]=লগ-আউট -Name[br]=Kuitaat -Name[bs]=Odjava -Name[ca]=Sortida -Name[cs]=Odhlášení -Name[csb]=Wëlogòwanié -Name[cy]=Allgofnodi -Name[da]=Log af -Name[de]=Abmelden -Name[el]=ΑποσÏνδεση -Name[eo]=Elsaluto -Name[es]=Salida -Name[et]=Väljalogimine -Name[eu]=Amaitu saioa -Name[fa]=خروج -Name[fi]=Kirjaudu ulos -Name[fo]=Útrita -Name[fr]=Fin de session -Name[fy]=Ofmelde -Name[ga]=Logáil Amach -Name[he]=יצי××” מהמערכת -Name[hi]=लॉगआउट -Name[hr]=Odjava -Name[hsb]=Wotzjewjenje -Name[hu]=Kijelentkezés -Name[is]=Stimpla út -Name[it]=Uscita -Name[ja]=ログアウト -Name[ka]=გáƒáƒ›áƒáƒ¡áƒ•áƒšáƒ -Name[kk]=Шығу -Name[km]=áž…áŸáž‰ -Name[ko]=로그아웃 -Name[ku]=Derketin -Name[lb]=Ofmellen -Name[lt]=IÅ¡siregistravimas -Name[lv]=Atteikties -Name[mk]=Одјавување -Name[mn]=Хаалгах -Name[ms]=Log keluar -Name[mt]=Temm is-sessjoni -Name[nb]=Logg ut -Name[nds]=Afmellen -Name[ne]=लगआउट -Name[nl]=Afmelden -Name[nn]=Logg ut -Name[nso]=Etswa -Name[oc]=Desconneccion -Name[pa]=ਲਾਗਆਉਟ -Name[pl]=Wylogowanie -Name[pt]=Fim de sessão -Name[pt_BR]=Sair -Name[ro]=IeÅŸire -Name[ru]=Выход из KDE -Name[rw]=Gusohoka -Name[se]=OlggosÄáliheapmi -Name[sk]=Odhlásenie -Name[sl]=Odjava -Name[sq]=Dilni -Name[sr]=Одјављивање -Name[sr@Latn]=Odjavljivanje -Name[ss]=Phuma -Name[sv]=Logga ut -Name[ta]=à®®à¯à®Ÿà®¿à®¤à¯à®¤à®²à¯ -Name[te]=లాగౌటౠ-Name[tg]=Баромад аз KDE -Name[th]=ล็อà¸à¹€à¸­à¸²à¸•à¹Œ -Name[tr]=Çıkış -Name[tt]=Çığış -Name[uk]=Кінець ÑеанÑу -Name[uz]=Chiqish -Name[uz@cyrillic]=Чиқиш -Name[ven]=U litsha u shumisa khomupwutha -Name[vi]=Äăng xuất -Name[wa]=Dislodjaedje -Name[xh]=Phuma ngaphandle -Name[zh_CN]=注消 -Name[zh_HK]=登出 -Name[zh_TW]=登出 -Name[zu]=Phumela ngaphandle -Comment=KDE is exiting -Comment[af]=KDE is besig om toe te maak -Comment[ar]=جاري إيقا٠KDE -Comment[be]=Выхад з KDE -Comment[bg]=Спиране на ÑиÑтемата -Comment[bn]=কে.ডি.ই. বনà§à¦§ করা হচà§à¦›à§‡ -Comment[br]=Emañ o kuitaat KDE -Comment[bs]=KDE se zatvara -Comment[ca]=S'està aturant el KDE -Comment[cs]=UkonÄuje se prostÅ™edí KDE -Comment[csb]=Zakùńczenié KDE -Comment[da]=KDE er ved at afslutte -Comment[de]=KDE wird beendet -Comment[el]=Το KDE τεÏματίζει -Comment[eo]=KDE estas finata -Comment[es]=KDE está terminando -Comment[et]=KDE lõpetab töö -Comment[eu]=KDE bukatzen ari da -Comment[fa]=KDE در حال خروج است -Comment[fi]=KDE:tä sammutetaan -Comment[fr]=KDE est en cours d'arrêt -Comment[fy]=KDE giet nei de útgong -Comment[ga]=Tá KDE ag stopadh. -Comment[gl]=KDE está Saindo -Comment[he]=היצי××” מ־KDE בעיצומה -Comment[hi]=केडीई बंद हो रहा है -Comment[hr]=Izlazak KDE -Comment[hsb]=KDE so zakónÄi -Comment[hu]=A KDE kilép -Comment[id]=KDE sedang diakhiri -Comment[is]=KDE er að hætta -Comment[it]=Uscita da KDE -Comment[ja]=KDE 終了中 -Comment[ka]=KDE-დáƒáƒœ გáƒáƒ›áƒáƒ¡áƒ•áƒšáƒ -Comment[kk]=KDE жүйеÑінен шығу -Comment[km]=KDE កំពុង​បិទ -Comment[lb]=KDE gëtt zougemat -Comment[lt]=KDE baigia darbÄ… -Comment[lv]=KDE beidz darbu -Comment[mk]=KDE излегува -Comment[ms]=KDE sedang keluar -Comment[nb]=KDE avslutter -Comment[nds]=KDE warrt utmaakt -Comment[ne]=KDE अनà¥à¤¤à¥à¤¯ हà¥à¤à¤¦à¥ˆà¤› -Comment[nl]=KDE is aan het afsluiten -Comment[nn]=KDE avsluttar -Comment[pa]=KDE ਸਮਾਪਤ ਹੋ ਰਿਹਾ ਹੈ -Comment[pl]=ZakoÅ„czenie KDE -Comment[pt]=O KDE está a terminar -Comment[pt_BR]=KDE está finalizando -Comment[ro]=KDE se termină -Comment[ru]=Выход из KDE -Comment[rw]=KDE iri gufunga -Comment[se]=KDE heaitigoÄ‘ii -Comment[sk]=KDE sa ukonÄuje -Comment[sl]=KDE se konÄuje -Comment[sr]=KDE Ñе завршава -Comment[sr@Latn]=KDE se zavrÅ¡ava -Comment[sv]=KDE avslutas -Comment[ta]=கேடிஇ வெளிசà¯à®šà¯†à®²à¯à®•à®¿à®±à®¤à¯ -Comment[te]=కెడిఈ నిషà±à°•à±à°°à°®à°¿à°¸à±à°¤à±à°‚ది -Comment[tg]=Баромад аз KDE -Comment[th]=à¸à¸³à¸¥à¸±à¸‡à¸­à¸­à¸à¸ˆà¸²à¸ KDE -Comment[tr]=KDE Masaüstünden çıkılıyor -Comment[tt]=KDE tuqtatıla -Comment[uk]=Триває Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð½Ñ Ñ€Ð¾Ð±Ð¾Ñ‚Ð¸ KDE -Comment[uz]=KDE ishini yakunlamoqda -Comment[uz@cyrillic]=KDE ишини Ñкунламоқда -Comment[vi]=KDE Ä‘ang thoát. -Comment[zh_CN]=KDE 正在退出 -Comment[zh_HK]=KDE 正在çµæŸ -Comment[zh_TW]=KDE 正在çµæŸ -default_presentation=1 -default_sound=KDE_Logout_3.ogg - -[cancellogout] -Name=Logout canceled -Name[bg]=Излизането от ÑиÑтемата отменено -Name[ca]=S'ha anul·lat la desconnexió -Name[cs]=Odhlášení zruÅ¡eno -Name[csb]=Wëlogòwanié òprzestóné -Name[da]=Log af annulleret -Name[de]=Abmelden abgebrochen -Name[el]=Η αποσÏνδεση ακυÏώθηκε -Name[eo]=Elsaluto estis rezignita -Name[es]=Salida cancelada -Name[et]=Väljalogimine katkestatud -Name[fi]=Uloskirjautuminen peruttu -Name[fr]=Annulation de la déconnexion -Name[fy]=Ofmelding ôfbrutsen -Name[hr]=Odjavljivanje prekinuto -Name[hu]=Kijelentkezés megszakítva -Name[is]=Hætt við útstimplun -Name[it]=Uscita annullata -Name[ja]=ログアウトãŒã‚­ãƒ£ãƒ³ã‚»ãƒ«ã•ã‚Œã¾ã—㟠-Name[ka]=გáƒáƒ›áƒáƒ¡áƒ•áƒšáƒ გáƒáƒ£áƒ¥áƒ›áƒ“რ-Name[kk]=Шығу доғарылды -Name[km]=ការ​ចáŸáž‰â€‹áž”ាន​បោះបង់ -Name[lt]=IÅ¡siregistravimas nutrauktas -Name[mk]=Откажано одјавување -Name[nb]=Avbrutt utlogging -Name[nds]=Afmellen afbraken -Name[nl]=Afmelden geannuleerd -Name[nn]=Utlogging avbroten -Name[pa]=ਲਾਗਆਉਟ ਰੱਦ ਕੀਤਾ ਗਿਆ -Name[pl]=Wylogowanie anulowane -Name[pt]=Encerramento cancelado -Name[pt_BR]=Logout cancelado -Name[ru]=Выход из KDE прерван -Name[sk]=Odhlásenie zruÅ¡ené -Name[sl]=Odjava preklicana -Name[sr]=Одјављивање отказано -Name[sr@Latn]=Odjavljivanje otkazano -Name[sv]=Utloggning avbruten -Name[te]=లాగౌటౠరదà±à°¦à±à°šà±‡à°¯à°¬à°¡à°¿à°¨à°¦à°¿ -Name[tg]=Баромадан аз KDE қатъ шуд -Name[th]=ยà¸à¹€à¸¥à¸´à¸à¸à¸²à¸£à¸¥à¹‡à¸­à¸à¹€à¸­à¸²à¸•à¹Œ -Name[tr]=Oturumu kapatma iÅŸlemi iptal edildi -Name[uk]=Вихід ÑкаÑовано -Name[uz]=Chiqish bekor qilindi -Name[uz@cyrillic]=Чиқиш бекор қилинди -Name[zh_CN]=注消已å–消 -Name[zh_TW]=å–消登出 -Comment=KDE logout was canceled -Comment[bg]=Излизането от KDE беше отменено -Comment[ca]=S'ha anul·lat la desconnexió del KDE -Comment[cs]=Odhlášení z KDE bylo zruÅ¡eno -Comment[csb]=Logòwanié KDE òprzestóné -Comment[da]=log af fra KDE blev annulleret -Comment[de]=Das Abmelden von KDE wurde abgebrochen -Comment[el]=Η αποσÏνδεση από το KDE ακυÏώθηκε -Comment[eo]=KDE-elsaluto estas rezignita -Comment[es]=La salida de KDE fue cancelada -Comment[et]=KDE väljalogimine katkestati -Comment[fi]=KDE:n uloskirjautuminen on peruttu -Comment[fr]=La déconnexion de KDE a été annulée -Comment[fy]=KDE ôfmelding wie ôfbrutsen -Comment[hr]=KDE odjavljivanje je prekinuto -Comment[hu]=A KDE-s kijelentkezés megszakadt -Comment[is]=Hætt var við KDE útstimplun -Comment[it]=L'uscita da KDE è stata annullata -Comment[ja]=KDE ã‹ã‚‰ã®ãƒ­ã‚°ã‚¢ã‚¦ãƒˆãŒã‚­ãƒ£ãƒ³ã‚»ãƒ«ã•ã‚Œã¾ã—㟠-Comment[ka]=KDED გáƒáƒ›áƒáƒ¡áƒ•áƒšáƒ გáƒáƒ£áƒ¥áƒ›áƒ“რ-Comment[kk]=KDE-ден шығу доғарылды -Comment[km]=ការ​ចáŸáž‰â€‹ážšáž”ស់ KDE ážáŸ’រូវ​បាន​បោះបង់ -Comment[lt]=IÅ¡siregistravimas iÅ¡ KDE buvo nutrauktas -Comment[mk]=Одјавувањето од KDE е откажано -Comment[nb]=KDE utlogging ble avbrutt -Comment[nds]=Afmellen vun KDE wöör afbraken -Comment[nl]=Uitloggen KDE was geannuleerd -Comment[nn]=KDE-utlogginga vart avbroten -Comment[pa]=KDE ਲਾਗ-ਆਉਟ ਰੱਦ ਕੀਤਾ ਗਿਆ ਹੈ -Comment[pl]=Wylogowanie z KDE zostaÅ‚o anulowane -Comment[pt]=O encerramento da sessão do KDE foi cancelado -Comment[pt_BR]=Logout do KDE foi cancelado -Comment[ru]=Выход из KDE прерван -Comment[sk]=Odhlásenie z KDE bolo zruÅ¡ené -Comment[sl]=Odjava iz KDE je bila preklicana -Comment[sr]=Одјављивање из KDE-а је отказано -Comment[sr@Latn]=Odjavljivanje iz KDE-a je otkazano -Comment[sv]=Utloggning frÃ¥n KDE avbröts -Comment[te]=కెడిఈ లాగౌటౠరదà±à°¦à±à°šà±‡à°¯à°¬à°¡à°¿à°¨à°¦à°¿ -Comment[tg]=Баромадан аз KDE қатъ карда шуд -Comment[th]=à¸à¸²à¸£à¸¥à¹‡à¸­à¸à¹€à¸­à¸²à¸—์ออà¸à¸ˆà¸²à¸ KDE ถูà¸à¸¢à¸à¹€à¸¥à¸´à¸ -Comment[tr]=KDE oturumunu kapatma iÅŸlemi iptal edildi -Comment[uk]=Вихід з KDE ÑкаÑовано -Comment[uz]=KDE'dan chiqish bekor qilindi -Comment[uz@cyrillic]=KDE'дан чиқиш бекор қилинди -Comment[zh_CN]=KDE 注销已å–消 -Comment[zh_TW]=KDE 登出動作已被å–消 -default_presentation=16 -default_sound= - -[printerror] -Name=Print error -Name[af]=Druk fout -Name[ar]=خطأ ÙÙŠ الطباعة -Name[az]=Çap Edici xÉ™tası -Name[be]=Памылка друку -Name[bg]=Грешка при печат -Name[bn]=মà§à¦¦à§à¦°à¦£ তà§à¦°à§à¦Ÿà¦¿ -Name[br]=Fazi en ur moulañ -Name[bs]=GreÅ¡ka pri Å¡tampanju -Name[ca]=Error d'impressió -Name[cs]=Chyba tisku -Name[csb]=Fela drëkù -Name[cy]=Gwall argraffu -Name[da]=Udskriftsfejl -Name[de]=Fehler beim Drucken -Name[el]=Σφάλμα εκτÏπωσης -Name[eo]=Preseraro -Name[es]=Error de impresión -Name[et]=Viga trükkimisel -Name[eu]=Inprimatze-errorea -Name[fa]=خطای چاپ -Name[fi]=Tulostusvirhe -Name[fr]=Problème d'impression -Name[fy]=Printflater -Name[ga]=Earráid phriontála -Name[gl]=Error de impresión -Name[he]=שגי×ת הדפסה -Name[hi]=छपाई तà¥à¤°à¥à¤Ÿà¤¿ -Name[hr]=PogreÅ¡ka ispisa -Name[hsb]=Ćišćenski zmylk -Name[hu]=Nyomtatási hiba -Name[id]=Kesalahan pencetakan -Name[is]=Prentunarvilla -Name[it]=Errore di stampa -Name[ja]=å°åˆ·ã‚¨ãƒ©ãƒ¼ -Name[ka]=ბეჭდვის შეცდáƒáƒ›áƒ -Name[kk]=БаÑып шығару қатеÑÑ– -Name[km]=កំហុស​បោះពុម្ព -Name[ko]=ì¸ì‡„ 오류 -Name[lb]=Dréckfeeler -Name[lt]=Spausdinimo klaida -Name[lv]=Drukas kļūda -Name[mk]=Грешка при печатење -Name[mn]=Ð¥ÑвлÑÑ…Ñд алдаа -Name[ms]= Ralat cetak -Name[mt]=Problema fl-ipprintjar -Name[nb]=Skriverfeil -Name[nds]=Fehler bi't Drucken -Name[ne]=मà¥à¤¦à¥à¤°à¤£ तà¥à¤°à¥à¤Ÿà¤¿ -Name[nl]=Print fout -Name[nn]=Utskriftsfeil -Name[nso]=Bothata bja kgatiso -Name[pa]=ਪà©à¨°à¨¿à©°à¨Ÿà¨° ਗਲਤੀ -Name[pl]=BÅ‚Ä…d wydruku -Name[pt]=Erro de impressão -Name[pt_BR]=Erro de Impressão -Name[ro]=Eroare tipărire -Name[ru]=Ошибка печати -Name[rw]=Ikosa ryo gucapa -Name[se]=Čálihanmeattáhus -Name[sk]=Chyba tlaÄe -Name[sl]=Napaka pri tiskanju -Name[sq]=Gabim shtypi -Name[sr]=Грешка у штампању -Name[sr@Latn]=GreÅ¡ka u Å¡tampanju -Name[ss]=Liphutsa lekushicelela -Name[sv]=Skrivarfel -Name[ta]=அசà¯à®šà¯à®¤à¯ தவற௠-Name[te]=à°ªà±à°°à°šà±à°°à°£ దొషం -Name[tg]=Хатои чоп -Name[th]=à¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¸œà¸´à¸”พลาด -Name[tr]=Yazdırma hatası -Name[tt]=Bastıru xatası -Name[uk]=Помилка друку -Name[uz]=Bosib chiqarish xatosi -Name[uz@cyrillic]=БоÑиб чиқариш хатоÑи -Name[ven]=Vhukhakhi hau phirintha -Name[vi]=Lá»—i in -Name[wa]=Aroke d' imprimaedje -Name[xh]=Imposiso yoshicilelo -Name[zh_CN]=打å°é”™è¯¯ -Name[zh_HK]=列å°éŒ¯èª¤ -Name[zh_TW]=列å°éŒ¯èª¤ -Name[zu]=Iphutha lokushicelela -Comment=A print error has occurred -Comment[af]='n Druk fout het voorgekom -Comment[ar]=حدث خطأ ÙÙŠ الطباعة -Comment[az]=Çap xÉ™tası baÅŸ verdi -Comment[be]=ÐдбылаÑÑ Ð¿Ð°Ð¼Ñ‹Ð»ÐºÐ° друку -Comment[bg]=Грешка при печат -Comment[bn]=ছাপানোয় সমসà§à¦¯à¦¾ দেখা দিয়েছে -Comment[br]=Degouezhet ez eus ar fazi gant ar voullerez -Comment[bs]=DoÅ¡lo je do greÅ¡ke pri Å¡tampanju -Comment[ca]=Hi ha hagut un error d'impressió -Comment[cs]=DoÅ¡lo k chybÄ› tisku -Comment[csb]=Wëskrzëniwô sã fela drëkù -Comment[cy]=Mae gwall argraffu wedi digwydd -Comment[da]=Der opstod en udskriftsfejl -Comment[de]=Beim Drucken ist ein Fehler aufgetreten -Comment[el]=ΠÏοέκυψε ένα σφάλμα εκτÏπωσης -Comment[eo]=Okazis preseraro -Comment[es]=Se ha producido un error de impresión. -Comment[et]=Viga trükkimisel -Comment[eu]=Inprimatze-errorea gertatu da -Comment[fa]=خطای چاپی رخ داده است -Comment[fi]=Tapahtui tulostusvirhe -Comment[fr]=Un problème d'impression est survenu -Comment[fy]=In printflater had him foardyn -Comment[ga]=Tharla earráid phriontála -Comment[gl]=Ocorreu un erro de impresión -Comment[he]=×ירעה שגי×ת הדפסה -Comment[hi]=छापने में à¤à¤• तà¥à¤°à¥à¤Ÿà¤¿ हà¥à¤ˆ -Comment[hr]=Tijekom ispisivanje doÅ¡lo je do pogreÅ¡ke -Comment[hsb]=Zmylk je so staÅ‚ pÅ™i ćišćenju -Comment[hu]=Hiba történt nyomtatás közben -Comment[id]=Telah terjadi kesalahan pencetakan -Comment[is]=Prentunarvilla átti sér stað -Comment[it]=Si è verificato un errore di stampa -Comment[ja]=å°åˆ·ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—㟠-Comment[ka]=ბეჭდვის შეცდáƒáƒ›áƒ -Comment[kk]=БаÑып шығару кезде қате пайда болды -Comment[km]=កំហុស​បោះពុម្ព​មួយ​បាន​កើážáž¡áž¾áž„ -Comment[ko]=ì¸ì‡„ 오류가 ìƒê²¼ìŠµë‹ˆë‹¤ -Comment[lb]=En Dréckfeeler ass opgetrueden -Comment[lt]=Ä®vyko spausdinimo klaida -Comment[lv]=Notikusi drukas kļūda -Comment[mk]=Се Ñлучи грешка при печатење -Comment[mn]=Ð¥ÑвлÑÑ…Ñд алдаа гарлаа -Comment[ms]=Ralat cetak berlaku -Comment[nb]=En skriverfeil har oppstÃ¥tt -Comment[nds]=Bi't Drucken hett dat en Fehler geven -Comment[ne]=मà¥à¤¦à¥à¤°à¤£ तà¥à¤°à¥à¤Ÿà¤¿ देखापरà¥à¤¯à¥‹ -Comment[nl]=Er deed zich een afdrukfout voor -Comment[nn]=Feil ved utskrift -Comment[pa]=ਇੱਕ ਪà©à¨°à¨¿à©°à¨Ÿà¨° ਗਲਤੀ ਹੈ -Comment[pl]=WystÄ…piÅ‚ bÅ‚Ä…d drukowania -Comment[pt]=Ocorreu um erro de impressão -Comment[pt_BR]=Ocorreu um erro de impressão -Comment[ro]=A apărut o eroare la tipărire -Comment[ru]=Ошибка при печати -Comment[rw]=Ikosa ryo gucapa ryagaragaye -Comment[se]=Čálihanmeattáhus dáhpáhuvai -Comment[sk]=Nastala chyba tlaÄe -Comment[sl]=Nastala je napaka pri tiskanju -Comment[sq]=Ka ndodhur një gabim shtypi -Comment[sr]=Догодила Ñе грешка током штампања -Comment[sr@Latn]=Dogodila se greÅ¡ka tokom Å¡tampanja -Comment[sv]=Utskriftsfel har inträffat -Comment[ta]=அசà¯à®šà¯à®¤à¯ தவறொனà¯à®±à¯ நேரà¯à®¨à¯à®¤à®¿à®°à¯à®•à¯à®•à®¿à®±à®¤à¯ -Comment[te]=à°’à°• à°ªà±à°°à°šà±à°°à°£ దొషం వచà±à°šà°¿à°‚ది -Comment[tg]=Хатои чопкунӣ пайдо шуд -Comment[th]=เà¸à¸´à¸”ข้อผิดพลาดในà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œ -Comment[tr]=Bir yazdırma hatası oluÅŸtu -Comment[tt]=Bastıru xatası bulıp çıqtı -Comment[uk]=Виникла помилка друку -Comment[uz]=Bosib chiqarish xatosi roÊ»y berdi -Comment[uz@cyrillic]=БоÑиб чиқариш хатоÑи рўй берди -Comment[vi]=Gặp lá»—i in -Comment[wa]=Ã…k n' a nén stî tot-z imprimant -Comment[zh_CN]=å‘生了打å°é”™è¯¯ -Comment[zh_HK]=列å°æ™‚發生錯誤 -Comment[zh_TW]=列å°æ™‚發生錯誤 -default_presentation=2 -level=8 - -[messageInformation] -Name=Information message -Name[af]=Inligting boodskap -Name[ar]=رسالة المعلومات -Name[az]=MÉ™'lumat ismarışı -Name[be]=Інфармацыйнае паведамленне -Name[bg]=Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ -Name[bn]=তথà§à¦¯à¦¬à¦¾à¦°à§à¦¤à¦¾ -Name[br]=Kemennad a titouroù -Name[bs]=Informativna poruka -Name[ca]=Missatge informatiu -Name[cs]=InformaÄní zpráva -Name[csb]=Wëdowiédny kòmùnikat -Name[cy]=Neges gwybodaeth -Name[da]=Informationsbesked -Name[de]=Information -Name[el]=Μήνυμα πληÏοφοÏίας -Name[eo]=Informa mesaÄo -Name[es]=Mensaje de información -Name[et]=Informatiivne teade -Name[eu]=Informazioaren mezua -Name[fa]=پیام اطلاعاتی -Name[fi]=Tiedoitusviesti -Name[fr]=Message d'information -Name[fy]=Ynformaasje berjocht -Name[ga]=Teachtaireacht Eolais -Name[gl]=Mensaxe de información -Name[he]=הודעת מידע -Name[hi]=सूचनातà¥à¤®à¤• संदेश -Name[hr]=Poruka s podacima -Name[hsb]=Informaciska zdźělenka -Name[hu]=Tájékoztató üzenet -Name[id]=Pesan informasi -Name[is]=Til fróðleiks -Name[it]=Messaggio informativo -Name[ja]=情報メッセージ -Name[ka]=სáƒáƒ˜áƒœáƒ¤áƒáƒ áƒ›áƒáƒªáƒ˜áƒ შეტყáƒáƒ‘ინებრ-Name[kk]=Ðқпараттық хабар -Name[km]=សារ​ដំណឹង -Name[ko]=ì •ë³´ 메세지 -Name[lb]=Informatioun -Name[lt]=Informacinis praneÅ¡imas -Name[lv]=InformatÄ«vs paziņojums -Name[mk]=Информативна порака -Name[mn]=ÐœÑдÑÑллийн мÑдÑÑ -Name[ms]=Mesej maklumat -Name[nb]=Informasjonsmelding -Name[nds]=Informatschoon -Name[ne]=सूचना सनà¥à¤¦à¥‡à¤¶ -Name[nl]=Informatiebericht -Name[nn]=Informasjonsmelding -Name[pa]=ਜਾਣਕਾਰੀ ਸà©à¨¨à©‡à¨¹à©‡ -Name[pl]=Komunikat informacyjny -Name[pt]=Mensagem de informação -Name[pt_BR]=Mensagem de informações -Name[ro]=Mesaj informaÅ£ional -Name[ru]=Информационное Ñообщение -Name[rw]=Ubutumwa bwo kumenyesha -Name[se]=Diehtu -Name[sk]=Informácia -Name[sl]=Informativno sporoÄilo -Name[sq]=Porosi informimi -Name[sr]=Информациона порука -Name[sr@Latn]=Informaciona poruka -Name[sv]=Informationsmeddelande -Name[ta]=தகவல௠செயà¯à®¤à®¿ -Name[te]=సమాచార సందేశం -Name[tg]=Хабари иттилоотӣ -Name[th]=ข้อความà¹à¸ˆà¹‰à¸‡à¸‚้อมูล -Name[tr]=Bilgi mesajı -Name[tt]=Belderü xäbäre -Name[uk]=Інформаційне Ð¿Ð¾Ð²Ñ–Ð´Ð¾Ð¼Ð»ÐµÐ½Ð½Ñ -Name[uz]=Maʼlumot xabari -Name[uz@cyrillic]=Маълумот хабари -Name[vi]=Thông Ä‘iệp thông tin -Name[wa]=Messaedje d' informÃ¥cion -Name[zh_CN]=ä¿¡æ¯æ€§æ¶ˆæ¯ -Name[zh_HK]=ä¸€èˆ¬è¨Šæ¯ -Name[zh_TW]=è³‡è¨Šè¨Šæ¯ -Comment=An information message is being shown -Comment[af]='n Informasie boodskap word vertoon -Comment[ar]=تظهر الآن رسالة معلوماتية -Comment[az]=MÉ™'lumat ismarışı göstÉ™rilir -Comment[be]=Паказана інфармацыйнае паведамленне -Comment[bg]=Показване на уведомително Ñъобщение (ИнформациÑ) -Comment[bn]=à¦à¦•à¦Ÿà¦¿ তথà§à¦¯à¦¬à¦¾à¦°à§à¦¤à¦¾ পà§à¦°à¦¦à¦°à§à¦¶à¦¿à¦¤ হচà§à¦›à§‡ -Comment[bs]=Prikazana je informativna poruka -Comment[ca]=Mostrarà un missatge informatiu -Comment[cs]=InformaÄní zpráva je zobrazena -Comment[csb]=Wëskrzëniwô sã wëdowiédny kòmùnikat -Comment[cy]=Dangosir neges gwybodaeth -Comment[da]=En informationsbesked er ved at blive vist -Comment[de]=Anzeige einer Info-Nachricht -Comment[el]=Ένα μήνυμα πληÏοφοÏίας εμφανίζεται -Comment[eo]=Informa mesaÄo estas montrata -Comment[es]=Se está mostrando un mensaje de información -Comment[et]=Näidatakse informatiivset teadet -Comment[eu]=Informazioren mezua erakusten ari da -Comment[fa]=پیام اطلاعاتی نمایش داده می‌شود -Comment[fi]=Näytetään tiedotusviesti -Comment[fr]=Un message d'information est affiché actuellement -Comment[fy]=In ynformaasje berjocht lit him sjen -Comment[ga]=Tá teachtaireacht eolais á taispeáint -Comment[gl]=Está-se a mostrar unha mensaxe de información -Comment[he]=מוצגת הדעת מידע -Comment[hi]=à¤à¤• जानकारी परक सूचना दिखाई जा रही है -Comment[hr]=Prikazana je poruka s podacima -Comment[hsb]=Informaciska zdźělenka so pokazuje -Comment[hu]=Tájékoztató üzenet látszik -Comment[id]=Pesan informasi sedang ditampilkan -Comment[is]=Skilaboð notandanum til fróðleiks -Comment[it]=Viene mostrato un messaggio informativo -Comment[ja]=情報メッセージを表示ã—ã¾ã™ -Comment[ka]=სáƒáƒ˜áƒœáƒ¤áƒáƒ áƒ›áƒáƒªáƒ˜áƒ შეტყáƒáƒ‘ინების ჩვენებრ-Comment[kk]=Ðқпараттық хабар көрÑетілуде -Comment[km]=កំពុង​បង្ហាញ​សារ​ដំណឹង​មួយ -Comment[ko]=ì •ë³´ 메세지가 보입니다 -Comment[lb]=Eng Informatiounsnoricht gëtt ugewisen -Comment[lt]=Rodomas informacinis praneÅ¡imas -Comment[lv]=Tiek rÄdÄ«ts informatÄ«vs paziņojums -Comment[mk]=Прикажана е информативна порака -Comment[mn]=Харуулж байхад мÑдÑÑллийн мÑдÑÑ -Comment[ms]=Mesej yang dipaparkan -Comment[nb]=En informasjonsmelding blir vist -Comment[nds]=En Informatschoon warrt wiest -Comment[ne]=सूचना सनà¥à¤¦à¥‡à¤¶ देखिरहेको छ -Comment[nl]=Er wordt een informatiebericht getoond -Comment[nn]=Ei informasjonsmelding vert vist -Comment[pa]=ਇੱਕ ਜਾਣਕਾਰੀ ਸà©à¨¨à©‡à¨¹à¨¾ ਹੇਠਾਂ ਵੇਖਿਆ ਗਿਆ ਹੈ -Comment[pl]=Pokazywany jest komunikat informacyjny -Comment[pt]=Está a ser mostrada uma mensagem informativa -Comment[pt_BR]=Uma mensagem de informação está sendo mostrada -Comment[ro]=A fost afiÅŸat un mesaj informaÅ£ional -Comment[ru]=Вывод информационного ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ -Comment[rw]=Ubutumwa bwo kumenyesha bwerekanwe -Comment[se]=Diehtu Äájehuvvo -Comment[sk]=Je zobrazená informácia -Comment[sl]=Prikazano je informativno sporoÄilo -Comment[sq]=Një porosi informimi është paraqitur -Comment[sr]=Приказана је информативна порука -Comment[sr@Latn]=Prikazana je informativna poruka -Comment[sv]=Informationsmeddelande visas -Comment[ta]=ஒர௠தகவல௠செயà¯à®¤à®¿ காணà¯à®ªà®¿à®•à¯à®•à®ªà¯à®ªà®Ÿà¯à®•à®¿à®±à®¤à¯ -Comment[te]=à°’à°• సమాచార సందేశం చూపించబడà±à°¤à±à°‚ది -Comment[tg]=Хабари иттилоотӣ нишон дода иÑтодааÑÑ‚ -Comment[th]=à¸à¸³à¸¥à¸±à¸‡à¹à¸ªà¸”งข้อความà¹à¸ˆà¹‰à¸‡à¸‚้อมูล -Comment[tr]=Bir bilgi mesajı gösterildi -Comment[tt]=Belderü xäbäre kürsätelä -Comment[uk]=ПоказуєтьÑÑ Ñ–Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ‚Ð¸Ð²Ð½Ðµ Ð¿Ð¾Ð²Ñ–Ð´Ð¾Ð¼Ð»ÐµÐ½Ð½Ñ -Comment[uz]=Maʼlumot xabari koÊ»rsatildi -Comment[uz@cyrillic]=Маълумот хабари кўрÑатилди -Comment[vi]=Má»™t thông Ä‘iệp thông in Ä‘ang được hiển thị. -Comment[wa]=On messaedje d' informÃ¥cion est hÃ¥yné -Comment[zh_CN]=正在显示信æ¯æ€§æ¶ˆæ¯ -Comment[zh_HK]=é¡¯ç¤ºä¸€èˆ¬è¨Šæ¯ -Comment[zh_TW]=資訊訊æ¯å·²é¡¯ç¤º -default_sound=KDE_Chimes_2.ogg -default_presentation=65 -nopresentation=18 - -[messageWarning] -Name=Warning message -Name[af]=Waarskuwing boodskap -Name[ar]=رسالة تحذيرية -Name[az]=XÉ™bÉ™rdarlıq ismarışı -Name[be]=ПапÑÑ€Ñджанне -Name[bg]=Предупреждение -Name[bn]=সতরà§à¦•à¦¬à¦¾à¦°à§à¦¤à¦¾ -Name[bs]=Poruka upozorenja -Name[ca]=Missatge d'avís -Name[cs]=Varovná zpráva -Name[csb]=Ã’strzegawczi kòmùnikat -Name[cy]=Neges rhybudd -Name[da]=Advarselsbesked -Name[de]=Warnung -Name[el]=Μήνυμα Ï€Ïοειδοποίησης -Name[eo]=Averta mesaÄo -Name[es]=Mensaje de aviso -Name[et]=Hoiatav teade -Name[eu]=Abisuaren mezua -Name[fa]=پیام اخطار -Name[fi]=Varoitusviesti -Name[fr]=Message d'avertissement -Name[fy]=Warskôgings berjocht -Name[ga]=Teachtaireacht Rabhaidh -Name[gl]=Mensaxe de aviso -Name[he]=הודעת הזהרה -Name[hi]=चेतावनी संदेश -Name[hr]=Poruka upozorenja -Name[hsb]=Warnowanska zdźělenka -Name[hu]=FigyelmeztetÅ‘ üzenet -Name[id]=Pesan peringatan -Name[is]=Aðvörun -Name[it]=Messaggio di avvertimento -Name[ja]=警告メッセージ -Name[ka]=გáƒáƒ¤áƒ áƒ—ხილებრ-Name[kk]=ЕÑкерту хабары -Name[km]=សារ​ព្រមាន -Name[ko]=경고 메세지 -Name[lb]=Warnung -Name[lt]=PerspÄ—jantis praneÅ¡imas -Name[lv]=BrÄ«dinÄjums -Name[mk]=Предупредувачка порака -Name[mn]=Сануулга мÑдÑÑ -Name[ms]=Mesej amaran -Name[nb]=Varselmelding -Name[nds]=Wohrschoen -Name[ne]=चेतावनी सनà¥à¤¦à¥‡à¤¶ -Name[nl]=Waarschuwingsbericht -Name[nn]=Varselmelding -Name[pa]=ਚੇਤਾਵਨੀ ਸà©à¨¨à©‡à¨¹à¨¾ -Name[pl]=Komunikat ostrzegawczy -Name[pt]=Mensagem de aviso -Name[pt_BR]=Mensagem de Aviso -Name[ro]=Mesaj de avertizare -Name[ru]=Предупреждение -Name[rw]=Ubutumwa bw'iburira -Name[se]=Váruhus -Name[sk]=Varovanie -Name[sl]=Opozorilno sporoÄilo -Name[sq]=Porosi vërejtjeje -Name[sr]=Упозоравајућа порука -Name[sr@Latn]=Upozoravajuća poruka -Name[sv]=Varningsmeddelande -Name[ta]=எசà¯à®šà®°à®¿à®•à¯à®•à¯ˆà®šà¯ செயà¯à®¤à®¿ -Name[te]=హెచà±à°šà°°à°¿à°• సందేశం -Name[tg]=Огоҳӣ -Name[th]=ข้อความà¹à¸ˆà¹‰à¸‡à¹€à¸•à¸·à¸­à¸™ -Name[tr]=Uyarı mesajı -Name[tt]=Kisätü xäbäre -Name[uk]=ÐŸÐ¾Ð¿ÐµÑ€ÐµÐ´Ð¶ÐµÐ½Ð½Ñ -Name[uz]=Ogohnoma xabari -Name[uz@cyrillic]=Огоҳнома хабари -Name[vi]=Thông Ä‘iệp cảnh báo -Name[wa]=Messaedje d' adviertixhmint -Name[zh_CN]=è­¦å‘Šæ¶ˆæ¯ -Name[zh_HK]=è­¦å‘Šè¨Šæ¯ -Name[zh_TW]=è­¦å‘Šè¨Šæ¯ -Comment=A warning message is being shown -Comment[af]='n Waarskuwing boodskap word vertoon -Comment[ar]=تظهر الآن رسالة تحذيرية -Comment[az]=XÉ™bÉ™rdarlıq ismarışı göstÉ™rilir -Comment[be]=Паказана папÑÑ€Ñджанне -Comment[bg]=Показване на предупредително Ñъобщение (Предупреждение) -Comment[bn]=à¦à¦•à¦Ÿà¦¿ সতরà§à¦•à¦¬à¦¾à¦°à§à¦¤à¦¾ পà§à¦°à¦¦à¦°à§à¦¶à¦¿à¦¤ হচà§à¦›à§‡ -Comment[bs]=Prikazana je poruka upozorenja -Comment[ca]=Mostrarà un missatge d'avís -Comment[cs]=Varovná zpráva je zobrazena -Comment[csb]=Wëskrzëniwô sã òstrzegawczi kòmùnikat -Comment[cy]=Dangosir neges rhybudd -Comment[da]=En advarselsbesked er ved at blive vist -Comment[de]=Anzeige einer Warnungs-Nachricht -Comment[el]=Ένα μήνυμα Ï€Ïοειδοποίησης εμφανίζεται -Comment[eo]=Averta mesaÄo estas montrata -Comment[es]=Se está mostrando un mensaje de aviso -Comment[et]=Näidatakse hoiatavat teadet -Comment[eu]=Abisuaren mezua erakusten ari da -Comment[fa]=پیام اخطار نمایش داده می‌شود -Comment[fi]=Näytetään varoitusviesti -Comment[fr]=Un message d'avertissement est affiché actuellement -Comment[fy]=In warskôgings berjocht lit him sjen -Comment[ga]=Tá teachtaireacht rabhaidh á taispeáint -Comment[gl]=Está-se a mostrar unha mensaxe de aviso -Comment[he]=מוצגת הדעת הזהרה -Comment[hi]=à¤à¤• चेतावनी सूचना दिखाई जा रही है -Comment[hr]=Prikazana je upozoravajuća poruka -Comment[hsb]=Warnowanska zdźělenka so pokazuje -Comment[hu]=FigyelmeztetÅ‘ üzenet látszik -Comment[id]=Pesan peringatan sedang ditampilkan -Comment[is]=Aðvörun til notanda -Comment[it]=Viene mostrato un messaggio di avvertimento -Comment[ja]=警告メッセージを表示ã—ã¾ã™ -Comment[ka]=გáƒáƒ¤áƒ áƒ—ხილების ჩვენებრ-Comment[kk]=ЕÑкерту хабары көрÑтілуде -Comment[km]=កំពុង​បង្ហាញ​សារ​ព្រមាន​មួយ -Comment[ko]=경고 메세지가 보입니다 -Comment[lb]=Eng Warnungsnoricht gëtt ugewisen -Comment[lt]=Rodomas perspÄ—jantis praneÅ¡imas -Comment[lv]=Tiek rÄdÄ«ts brÄ«dinÄjums -Comment[mk]=Прикажана е предупредувачка порака -Comment[mn]=Харуулж байхад Ñануулга -Comment[ms]=Mesej amaran yang dipaparkan -Comment[nb]=En varselmelding blir vist -Comment[nds]=En Wohrschoen warrt wiest -Comment[ne]=चेतावनी सनà¥à¤¦à¥‡à¤¶ देखिरहेको छ -Comment[nl]=Er wordt een waarschuwingsbericht getoond -Comment[nn]=Ei varselmelding vert vist -Comment[pa]=ਇੱਕ ਚੇਤਾਵਨੀ ਸà©à¨¨à©‡à¨¹à¨¾ ਹੇਠਾਂ ਵੇਖਿਆ ਗਿਆ ਹੈ -Comment[pl]=Pokazywany jest komunikat ostrzegawczy -Comment[pt]=Está a ser mostrada uma mensagem de aviso -Comment[pt_BR]=Uma mensagem de aviso está sendo mostrada -Comment[ro]=A fost afiÅŸat un mesaj de avertizare -Comment[ru]=Вывод Ð¿Ñ€ÐµÐ´ÑƒÐ¿Ñ€ÐµÐ¶Ð´ÐµÐ½Ð¸Ñ -Comment[rw]=Ubutumwa bw'iburira bwerekanwe -Comment[se]=Váruhus Äájehuvvo -Comment[sk]=Je zobrazené varovanie -Comment[sl]=Prikazano je opozorilno sporoÄilo -Comment[sq]=Një porosi vërejtjeje është paraqitur -Comment[sr]=Приказана је упозоравајућа порука -Comment[sr@Latn]=Prikazana je upozoravajuća poruka -Comment[sv]=Varningsmeddelande visas -Comment[ta]=ஒர௠எசà¯à®šà®°à®¿à®•à¯à®•à¯ˆ செயà¯à®¤à®¿ காணà¯à®ªà®¿à®•à¯à®•à®ªà¯à®ªà®Ÿà¯à®•à®¿à®±à®¤à¯ -Comment[te]=à°’à°• హెచà±à°šà°°à°¿à°• సందేశం చూపించబడà±à°¤à±à°‚ది -Comment[tg]=Хурӯҷи огоҳӣ -Comment[th]=à¸à¸³à¸¥à¸±à¸‡à¹à¸ªà¸”งข้อความà¹à¸ˆà¹‰à¸‡à¹€à¸•à¸·à¸­à¸™ -Comment[tr]=Bir uyarı mesajı gösterildi -Comment[tt]=Kisätü xäbäre kürsätelä -Comment[uk]=ПоказуєтьÑÑ Ð¿Ð¾Ð²Ñ–Ð´Ð¾Ð¼Ð»ÐµÐ½Ð½Ñ Ð· попередженнÑм -Comment[uz]=Ogohnoma xabari koÊ»rsatildi -Comment[uz@cyrillic]=Огоҳнома хабари кўрÑатилди -Comment[vi]=Má»™t thông Ä‘iệp cảnh báo Ä‘ang được hiển thị. -Comment[wa]=On messaedje d' adviertixhmint est hÃ¥yné -Comment[zh_CN]=æ­£åœ¨æ˜¾ç¤ºè­¦å‘Šæ¶ˆæ¯ -Comment[zh_HK]=é¡¯ç¤ºè­¦å‘Šè¨Šæ¯ -Comment[zh_TW]=警告訊æ¯å·²é¡¯ç¤º -default_sound=KDE_Error_1.ogg -default_presentation=65 -nopresentation=18 -level=2 - -[messageCritical] -Name=Critical message -Name[af]=Kritiese boodskap -Name[ar]=رسالة هامَة -Name[az]=Kritik ismarış -Name[be]=Важнае паведамленне -Name[bg]=Грешка -Name[bn]=গà§à¦°à§à¦¤à§à¦¬à¦ªà§‚রà§à¦£ বারà§à¦¤à¦¾ -Name[bs]=KritiÄna poruka -Name[ca]=Missatge crític -Name[cs]=Kritická zpráva -Name[csb]=Kòmunikat kriticzny felë -Name[cy]=Neges critigol -Name[da]=Kritisk besked -Name[de]=Kritisches Ereignis -Name[el]=ΚÏίσιμο μήνυμα -Name[eo]=Averta mesaÄo -Name[es]=Mensaje crítico -Name[et]=Kriitiline teade -Name[eu]=Mezu kritikoa -Name[fa]=پیام بحرانی -Name[fi]=Kriittinen viesti -Name[fr]=Message critique -Name[fy]=krityk berjocht -Name[ga]=Teachtaireaacht chriticiúil -Name[gl]=Mensaxe crítica -Name[he]=הודעה קריטית -Name[hi]=महतà¥à¤µà¤ªà¥‚रà¥à¤£ संदेश -Name[hr]=KritiÄna poruka -Name[hsb]=Kritiska zdźělenka -Name[hu]=Kritikus hibaüzenet -Name[id]=Pesan kritis -Name[is]=Alvarleg aðvörun -Name[it]=Messaggio critico -Name[ja]=クリティカルメッセージ -Name[ka]=კრიტიკული შეცდáƒáƒ›áƒ -Name[kk]=ДағдарыÑÑ‚Ñ‹ хабар -Name[km]=សារ​សំážáž¶áž“់ -Name[ko]=중요 메세지 -Name[lb]=Kritesch Noricht -Name[lt]=Kritinis praneÅ¡imas -Name[lv]=Kritisks paziņojums -Name[mk]=Критична порака -Name[mn]=ШүүмжлÑлт мÑдÑÑ -Name[ms]=Mesej Kritikal -Name[nb]=Kritisk melding -Name[nds]=Malöör -Name[ne]=आलोचनातà¥à¤®à¤• सनà¥à¤¦à¥‡à¤¶ -Name[nl]=Kritiek bericht -Name[nn]=Kritisk melding -Name[pa]=ਘਾਤਕ ਸà©à¨¨à©‡à¨¹à¨¾ -Name[pl]=Komunikat bÅ‚Ä™du krytycznego -Name[pt]=Mensagem crítica -Name[pt_BR]=Mensagem Crítica -Name[ro]=Mesaj situaÅ£ie critică -Name[ru]=КритичеÑÐºÐ°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ° -Name[rw]=Ubutumwa bunenga -Name[sk]=Kritická správa -Name[sl]=KritiÄno sporoÄilo -Name[sq]=Porosi Kritik -Name[sr]=Критична порука -Name[sr@Latn]=KritiÄna poruka -Name[sv]=Kritiskt meddelande -Name[ta]=இகà¯à®•à®Ÿà¯à®Ÿà®¾à®© செயà¯à®¤à®¿ -Name[te]=కీలక సందేశం -Name[tg]=Хатои хатарнок -Name[th]=ข้อความวิà¸à¸¤à¸•à¸´ -Name[tr]=Kritik hata mesajı -Name[tt]=Kisken xäl xäbäre -Name[uk]=Критична помилка -Name[uz]=Muammo xabari -Name[uz@cyrillic]=Муаммо хабари -Name[vi]=Thông Ä‘iệp tá»›i hạn -Name[wa]=Messaedje critike -Name[zh_CN]=å…³é”®æ¶ˆæ¯ -Name[zh_HK]=åš´é‡è­¦å‘Šè¨Šæ¯ -Name[zh_TW]=åš´é‡è­¦å‘Šè¨Šæ¯ -Comment=A critical message is being shown -Comment[af]='n Kritiese boodskap word vertoon -Comment[ar]=تظهر الآن رسالة مهمَة -Comment[az]=Kritik ismarış göstÉ™rilir -Comment[be]=Паказана важнае паведамленне -Comment[bg]=Показване на Ñъобщение за грешка (Грешка) -Comment[bn]=à¦à¦•à¦Ÿà¦¿ গà§à¦°à§à¦¤à¦° বারà§à¦¤à¦¾ পà§à¦°à¦¦à¦°à§à¦¶à¦¿à¦¤ হচà§à¦›à§‡ -Comment[bs]=Prikazana je kritiÄna poruka -Comment[ca]=Mostrarà un missatge crític -Comment[cs]=Kritická zpráva je zobrazena -Comment[csb]=Wëskrzëniwô sã kòmunikat kriticzny felë -Comment[cy]=Dangosir neges critigol -Comment[da]=En kritisk besked er ved at blive vist -Comment[de]=Anzeige einer Nachricht zu einem kritischen Ereignis -Comment[el]=Ένα κÏίσιμο μήνυμα εμφανίζεται -Comment[eo]=Gravega mesaÄo estas montrata -Comment[es]=Se está mostrando un mensaje crítico -Comment[et]=Näidatakse kriitilist teadet -Comment[eu]=Mezu kritikoa erakusten ari da -Comment[fa]=پیام بحرانی نمایش داده می‌شود -Comment[fi]=Näytetään kriittinen viesti -Comment[fr]=Un message critique est affiché actuellement -Comment[fy]=In krityk berjocht let him sjen -Comment[ga]=Tá teachtaireacht chriticiúil á taispeáint -Comment[gl]=Está-se a mostrar unha mensaxe crítica -Comment[he]=מוצגת הודעה קריטית -Comment[hi]=à¤à¤• महतà¥à¤µà¤ªà¥‚रà¥à¤£ सूचना दिखाई जा रही है -Comment[hr]=Prikazana je kritiÄna poruka -Comment[hsb]=Kritiska zdźělenka so pokazuje -Comment[hu]=Kritikus hibaüzenet látszik -Comment[id]=Pesan kritis sedang ditampilkan -Comment[is]=Alvarleg skilaboð -Comment[it]=Viene mostrato un messaggio critico -Comment[ja]=クリティカルメッセージを表示ã—ã¾ã™ -Comment[ka]=კრიტიკული შეცდáƒáƒ›áƒ˜áƒ¡ ჩვენებრ-Comment[kk]=ДағдарыÑÑ‚Ñ‹ хабар көрÑетілуде -Comment[km]=កំពុង​បង្ហាញ​សារ​សំážáž¶áž“់​មួយ -Comment[ko]=중요 메세지가 보입니다 -Comment[lb]=Eng kritesch Noricht gëtt ugewisen -Comment[lt]=Rodomas kritinis praneÅ¡imas -Comment[lv]=Tiek rÄdÄ«ts kritisks paziņojums -Comment[mk]=Прикажана е критична порака -Comment[mn]=Харуулж байхад шүүмжилÑлт Ñануулга -Comment[ms]=Mesej kritikal yang dipaparkan -Comment[nb]=En kritisk melding blir vist -Comment[nds]=En kritische Naricht warrt wiest -Comment[ne]=आलोचनातà¥à¤®à¤• सनà¥à¤¦à¥‡à¤¶ देखिरहेको छ -Comment[nl]=Er wordt een kritiek bericht getoond -Comment[nn]=Ei kritisk melding vert vist -Comment[pa]=ਇੱਕ ਘਾਤਕ ਸà©à¨¨à©‡à¨¹à¨¾ ਹੇਠਾਂ ਵੇਖਿਆ ਗਿਆ ਹੈ -Comment[pl]=Pokazywany jest komunikat o bÅ‚Ä™dzie krytycznym -Comment[pt]=Está a ser mostrada uma mensagem crítica -Comment[pt_BR]=Uma mensagem crítica está sendo mostrada -Comment[ro]=A fost afiÅŸat un mesaj de situaÅ£ie critică -Comment[ru]=Вывод критичеÑкого ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ -Comment[rw]=Ubutumwa bunenga bwerekanwe -Comment[sk]=Je zobrazená kritická správa -Comment[sl]=Prikazano je kritiÄno sporoÄilo -Comment[sq]=Një porosi kritike është paraqitur -Comment[sr]=Приказана је критична порука -Comment[sr@Latn]=Prikazana je kritiÄna poruka -Comment[sv]=Kritiskt meddelande visas -Comment[ta]=ஒர௠மாறà¯à®¨à®¿à®²à¯ˆà®¯à®¾à®© செயà¯à®¤à®¿ காணà¯à®ªà®¿à®•à¯à®•à®ªà¯à®ªà®Ÿà¯à®•à®¿à®±à®¤à¯ -Comment[te]=à°’à°• కీలక సందేశం చూపించబడà±à°¤à±à°‚ది -Comment[tg]=Хурӯҷи иттилоъи хатарнок -Comment[th]=à¸à¸³à¸¥à¸±à¸‡à¹à¸ªà¸”งข้อความวิà¸à¸¤à¸•à¸´ -Comment[tr]=Bir kritik mesaj gösterildi -Comment[tt]=Kisken xäl xäbäre kürsätelä -Comment[uk]=ПоказуєтьÑÑ Ð¿Ð¾Ð²Ñ–Ð´Ð¾Ð¼Ð»ÐµÐ½Ð½Ñ Ð¿Ñ€Ð¾ критичну помилку -Comment[uz]=Muammo xabari koÊ»rsatildi -Comment[uz@cyrillic]=Муаммо хабари кўрÑатилди -Comment[vi]=Má»™t thông Ä‘iệp vá» trÆ°á»ng hợp tá»›i hạn Ä‘ang được hiển thị. -Comment[wa]=On messaedje critike est hÃ¥yné -Comment[zh_CN]=æ­£åœ¨æ˜¾ç¤ºå…³é”®æ¶ˆæ¯ -Comment[zh_HK]=顯示嚴é‡è­¦å‘Šè¨Šæ¯ -Comment[zh_TW]=åš´é‡çš„警告訊æ¯å·²é¡¯ç¤º -default_sound=KDE_Error_1.ogg -default_presentation=65 -nopresentation=18 -level=4 - -[messageboxQuestion] -Name=Question -Name[af]=Vraag -Name[ar]=سؤال -Name[az]=Sual -Name[be]=Запыт -Name[bg]=Ð’ÑŠÐ¿Ñ€Ð¾Ñ -Name[bn]=পà§à¦°à¦¶à§à¦¨ -Name[br]=Goulenn -Name[bs]=Pitanje -Name[ca]=Pregunta -Name[cs]=Dotaz -Name[csb]=Pëtanié -Name[cy]=Cwestiwn -Name[da]=SpørgsmÃ¥l -Name[de]=Frage -Name[el]=ΕÏώτηση -Name[eo]=Demando -Name[es]=Pregunta -Name[et]=Küsimus -Name[eu]=Galdera -Name[fa]=سؤال -Name[fi]=Kysymys -Name[fy]=Fraach -Name[ga]=Ceist -Name[gl]=Pergunta -Name[he]=ש×לה -Name[hi]=पà¥à¤°à¤¶à¥à¤¨ -Name[hr]=Pitanje -Name[hsb]=PraÅ¡enje -Name[hu]=Kérdés -Name[id]=Pertanyaan -Name[is]=Spurning -Name[it]=Domanda -Name[ja]=è³ªå• -Name[ka]=შეკითხვრ-Name[kk]=Сұрақ -Name[km]=សំណួរ -Name[ko]=ë¬¼ìŒ -Name[ku]=Pirs -Name[lb]=Fro -Name[lt]=Klausimas -Name[lv]=JautÄjums -Name[mk]=Прашање -Name[mn]=ÐÑуулт -Name[ms]=Soalan -Name[nb]=SpørsmÃ¥l -Name[nds]=Fraag -Name[ne]=पà¥à¤°à¤¶à¥à¤¨ -Name[nl]=Vraag -Name[nn]=SpørsmÃ¥l -Name[pa]=ਸਵਾਲ -Name[pl]=Komunikat z pytaniem -Name[pt]=Pergunta -Name[pt_BR]=Questão -Name[ro]=ÃŽntrebare -Name[ru]=Ð’Ð¾Ð¿Ñ€Ð¾Ñ -Name[rw]=Ikibazo -Name[se]=Gažaldat -Name[sk]=Otázka -Name[sl]=VpraÅ¡anje -Name[sq]=Pyetje -Name[sr]=Питање -Name[sr@Latn]=Pitanje -Name[sv]=FrÃ¥ga -Name[ta]=கேளà¯à®µà®¿ -Name[te]=à°ªà±à°°à°¶à±à°¨ -Name[tg]=Савол -Name[th]=คำถาม -Name[tr]=Soru -Name[tt]=Soraw -Name[uk]=Ð—Ð°Ð¿Ð¸Ñ‚Ð°Ð½Ð½Ñ -Name[uz]=Savol -Name[uz@cyrillic]=Савол -Name[vi]=Câu há»i -Name[wa]=Kesse -Name[zh_CN]=问题 -Name[zh_HK]=æå• -Name[zh_TW]=å•é¡Œ -Comment=A question is being asked -Comment[af]='n Vraag word gevra -Comment[ar]=هناك سؤال يتم سؤاله -Comment[az]=Sual ismarışı göstÉ™rilir -Comment[be]=Зададзена пытанне -Comment[bg]=Показване на въпроÑително Ñъобщение (ВъпроÑ) -Comment[bn]=à¦à¦•à¦Ÿà¦¿ পà§à¦°à¦¶à§à¦¨ করা হচà§à¦›à§‡ -Comment[br]=Emañ o c'houlleniñ ur goulenn -Comment[bs]=Postavljeno je pitanje -Comment[ca]=Farà una pregunta -Comment[cs]=Je položena otázka -Comment[csb]=Zadóné je pëtanié -Comment[cy]=Gofynnir cwestiwn -Comment[da]=Et spørgsmÃ¥l er ved at blive stillet -Comment[de]=Anzeige einer Frage -Comment[el]=Γίνεται μια εÏώτηση -Comment[eo]=Demando estas demandata -Comment[es]=Se está haciendo una pregunta -Comment[et]=Esitatakse küsimus -Comment[eu]=Galdera egiten ari da -Comment[fa]=سؤالی پرسیده می‌شود -Comment[fi]=Kysytään kysymys -Comment[fr]=Une question est posée actuellement -Comment[fy]=In fraach is stelt -Comment[ga]=Tá ceist á cur. -Comment[gl]=Está-se a facer unha pergunta -Comment[he]=נש×לת ש×לה -Comment[hi]=à¤à¤• पà¥à¤°à¤¶à¥à¤¨ पूछा गया है -Comment[hr]=Postavljeno je pitanje -Comment[hsb]=PraÅ¡a so za nÄ›Äim -Comment[hu]=Kérdés a felhasználóhoz -Comment[id]=Pertanyaan sedang diajukan -Comment[is]=Spurt er -Comment[it]=Viene posta una domanda -Comment[ja]=質å•ãŒå‡ºã•ã‚Œã¦ã„ã¾ã™ -Comment[ka]=შეკითხვის დáƒáƒ¡áƒ›áƒ -Comment[kk]=Сұрақ койылуда -Comment[km]=កំពុង​សួរ​សំណួរ​មួយ -Comment[ko]=물어보겠습니다 -Comment[lb]=Eng Fro gëtt ugewisen -Comment[lt]=Užduodamas klausimas -Comment[lv]=Tiek uzdots jautÄjums -Comment[mk]=ПоÑтавено е прашање -Comment[mn]=ÐÑуулт тавигдаж байна -Comment[ms]=Soalan yang ditanya -Comment[nb]=Et spørsmÃ¥l blir stillt -Comment[nds]=En Fraag warrt stellt -Comment[ne]=पà¥à¤°à¤¶à¥à¤¨ सोधिराखेको छ -Comment[nl]=Er wordt een vraag gesteld -Comment[nn]=Eit spørsmÃ¥l vert spurd -Comment[pa]=ਇੱਕ ਸਵਾਲ ਪà©à¨›à¨¿à¨† ਜਾ ਰਿਹਾ ਹੈ -Comment[pl]=Zadawane jest pytanie -Comment[pt]=Está´a ser feita uma pergunta -Comment[pt_BR]=Uma pergunta está sendo feita -Comment[ro]=A fost pusă o întrebare -Comment[ru]=Вывод вопроÑа -Comment[rw]=Ikibazo cyabajijwe -Comment[se]=Gažaldat jearahuvvo -Comment[sk]=Je zobrazená otázka -Comment[sl]=Postavljeno je vpraÅ¡anje -Comment[sq]=Një pyetje është duke u pyetur -Comment[sr]=ПоÑтављено је питање -Comment[sr@Latn]=Postavljeno je pitanje -Comment[sv]=FrÃ¥ga ställs -Comment[ta]=ஒர௠கேளà¯à®µà®¿ கேடà¯à®•à®ªà¯à®ªà®Ÿà¯à®•à®¿à®±à®¤à¯ -Comment[te]=à°ªà±à°°à°¶à±à°¨ అడగబడà±à°¤à±à°¨à±à°¨à°¦à°¿ -Comment[tg]=Ҷавоби Ñавол -Comment[th]=à¸à¸³à¸¥à¸±à¸‡à¸–ามคำถาม -Comment[tr]=Bir soru soruldu -Comment[tt]=Ber soraw birelde -Comment[uk]=ПоказуєтьÑÑ Ð·Ð°Ð¿Ð¸Ñ‚Ð°Ð½Ð½Ñ -Comment[uz]=Savol berildi -Comment[uz@cyrillic]=Савол берилди -Comment[vi]=Má»™t câu Ä‘ang được há»i. -Comment[wa]=Ene kesse est dmandêye -Comment[zh_CN]=正在æé—® -Comment[zh_HK]=顯示æå•è¨Šæ¯ -Comment[zh_TW]=å•é¡Œè©¢å•ä¸­ -default_sound=KDE_Vox_Ahem.ogg -default_presentation=65 -nopresentation=18 - - diff --git a/kdecore/fakes.c b/kdecore/fakes.c deleted file mode 100644 index 14f162eca..000000000 --- a/kdecore/fakes.c +++ /dev/null @@ -1,365 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2000 The KDE Project - - unsetenv() taken from the GNU C Library. - Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc. - - 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 "kdelibs_export.h" - -#include - -#ifdef _WIN32 -#include -#define KDE_open kdewin32_open -#define KDE_mkdir kdewin32_mkdir -#else -#define KDE_open open -#define KDE_mkdir mkdir -#endif - -#ifndef HAVE_SETENV - -#ifdef HAVE_ALLOCA_H -#include -#endif - -#include -#include -#include - -KDECORE_EXPORT int setenv(const char *name, const char *value, int overwrite) { - int i; - char * a; - - if (!overwrite && getenv(name)) return 0; - - i = strlen(name) + strlen(value) + 2; - a = (char*)malloc(i); - if (!a) return 1; - - strcpy(a, name); - strcat(a, "="); - strcat(a, value); - - return putenv(a); -} -#endif /* !HAVE_SETENV */ - -#ifndef HAVE_UNSETENV - -#ifdef HAVE_ALLOCA_H -#include -#endif - -#include -#include -#include -#include - -#ifndef environ -extern char ** environ; -#endif - -KDECORE_EXPORT void unsetenv (name) - const char *name; -{ - size_t len; - char **ep; - - if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) - { - errno = EINVAL; - return; - } - - len = strlen (name); - - ep = environ; - while (*ep != NULL) - if (!strncmp (*ep, name, len) && (*ep)[len] == '=') - { - /* Found it. Remove this pointer by moving later ones back. */ - char **dp = ep; - - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ - } - else - ++ep; - -} - -#endif /* !HAVE_UNSETENV */ - -#ifndef HAVE_USLEEP - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if defined(HAVE_SYS_TIME_H) -# include -# else -# include -# endif -#endif - -#ifdef HAVE_SYS_SELECT_H -#include -#endif - -#ifdef __cplusplus /* this is supposed to be a C source file but still.. */ -extern "C" { -#endif - -void usleep(unsigned int usec) { - struct timeval _usleep_tv; - _usleep_tv.tv_sec = usec/1000000; - _usleep_tv.tv_usec = usec%1000000; - select(0,0,0,0,&_usleep_tv); -} - -#ifdef __cplusplus -} -#endif - -#endif /* !HAVE_USLEEP */ - -#ifndef HAVE_RANDOM -long int random() -{ - return lrand48(); -} - -void srandom(unsigned int seed) -{ - srand48(seed); -} -#endif - -#ifndef HAVE_SETEUID -int seteuid(uid_t euid) -{ - return setreuid(-1, euid); /* Well, if you have neither you are in trouble :) */ -} -#endif - -#ifndef HAVE_MKSTEMPS -#include -#ifdef HAVE_SYS_STAT_H -#include -#endif -#include -#include -#include -#include - -/* this is based on code taken from the GNU libc, distributed under the LGPL license */ - -/* Generate a unique temporary file name from TEMPLATE. - - TEMPLATE has the form: - - /ccXXXXXX - - SUFFIX_LEN tells us how long is (it can be zero length). - - The last six characters of TEMPLATE before must be "XXXXXX"; - they are replaced with a string that makes the filename unique. - - Returns a file descriptor open on the file for reading and writing. */ - -KDECORE_EXPORT int mkstemps (char* _template, int suffix_len) -{ - static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - char *XXXXXX; - int len; - int count; - int value; - - len = strlen (_template); - - if ((int) len < 6 + suffix_len || strncmp (&_template[len - 6 - suffix_len], "XXXXXX", 6)) - return -1; - - XXXXXX = &_template[len - 6 - suffix_len]; - - value = rand(); - for (count = 0; count < 256; ++count) - { - int v = value; - int fd; - - /* Fill in the random bits. */ - XXXXXX[0] = letters[v % 62]; - v /= 62; - XXXXXX[1] = letters[v % 62]; - v /= 62; - XXXXXX[2] = letters[v % 62]; - v /= 62; - XXXXXX[3] = letters[v % 62]; - v /= 62; - XXXXXX[4] = letters[v % 62]; - v /= 62; - XXXXXX[5] = letters[v % 62]; - - fd = KDE_open (_template, O_RDWR|O_CREAT|O_EXCL, 0600); - if (fd >= 0) - /* The file does not exist. */ - return fd; - - /* This is a random value. It is only necessary that the next - TMP_MAX values generated by adding 7777 to VALUE are different - with (module 2^32). */ - value += 7777; - } - /* We return the null string if we can't find a unique file name. */ - _template[0] = '\0'; - return -1; -} - -#endif /* !HAVE_MKSTEMPS */ - -#ifndef HAVE_MKSTEMP -KDECORE_EXPORT int mkstemp (char* _template) -{ - return mkstemps( _template, 0 ); -} -#endif - -#ifndef HAVE_MKDTEMP - -#ifndef HAVE_MKSTEMPS -#include -#ifdef HAVE_SYS_STAT_H -#include -#endif -#endif - -/* Generate a unique temporary directory name from TEMPLATE. - - TEMPLATE has the form: - - /ccXXXXXX - - - The last six characters of TEMPLATE must be "XXXXXX"; - they are replaced with a string that makes the filename unique. - - Returns a file descriptor open on the file for reading and writing. */ - -KDECORE_EXPORT char* mkdtemp (char* _template) -{ - static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - char *XXXXXX; - int len; - int count; - int value; - - len = strlen (_template); - - if ((int) len < 6 || strncmp (&_template[len - 6], "XXXXXX", 6)) - return 0; - - XXXXXX = &_template[len - 6]; - - value = rand(); - for (count = 0; count < 256; ++count) - { - int v = value; - - /* Fill in the random bits. */ - XXXXXX[0] = letters[v % 62]; - v /= 62; - XXXXXX[1] = letters[v % 62]; - v /= 62; - XXXXXX[2] = letters[v % 62]; - v /= 62; - XXXXXX[3] = letters[v % 62]; - v /= 62; - XXXXXX[4] = letters[v % 62]; - v /= 62; - XXXXXX[5] = letters[v % 62]; - - /* This is a random value. It is only necessary that the next - TMP_MAX values generated by adding 7777 to VALUE are different - with (module 2^32). */ - value += 7777; - - if (!KDE_mkdir(_template,0700)) - return _template; - } - return 0; -} -#endif /* !HAVE_MKDTEMP */ - -#ifndef HAVE_REVOKE -#include -#ifndef ENOTSUP -#define ENOTSUP 134 /* Not supported */ -#endif -KDECORE_EXPORT int revoke(const char *tty) -{ - errno = ENOTSUP; - return -1; -} -#endif - -#ifndef HAVE_STRLCPY -#include -KDECORE_EXPORT unsigned long strlcpy(char* d, const char* s, unsigned long bufsize) -{ - unsigned long len, ret = strlen(s); - - if (ret >= bufsize) { - if (bufsize) { - len = bufsize - 1; - memcpy(d, s, len); - d[len] = '\0'; - } - } else - memcpy(d, s, ret + 1); - - return ret; -} -#endif - -#ifndef HAVE_STRLCAT -#include -KDECORE_EXPORT unsigned long strlcat(char* d, const char* s, unsigned long bufsize) -{ - char *cp; - unsigned long ret, len1, len2 = strlen(s); - - cp = memchr (d, '\0', bufsize); - if (!cp) - return bufsize + len2; - len1 = cp - d; - ret = len1 + len2; - if (ret >= bufsize) { - len2 = bufsize - len1 - 1; - memcpy(cp, s, len2); - cp[len2] = '\0'; - } else - memcpy(cp, s, len2 + 1); - - return ret; -} -#endif diff --git a/kdecore/fixx11h.h b/kdecore/fixx11h.h deleted file mode 100644 index e572335a1..000000000 --- a/kdecore/fixx11h.h +++ /dev/null @@ -1,236 +0,0 @@ -//#ifdef don't do this, this file is supposed to be included -//#define multiple times - -/* Usage: - - If you get compile errors caused by X11 includes (the line - where first error appears contains word like None, Unsorted, - Below, etc.), put #include in the .cpp file - (not .h file!) between the place where X11 headers are - included and the place where the file with compile - error is included (or the place where the compile error - in the .cpp file occurs). - - This file remaps X11 #defines to const variables or - inline functions. The side effect may be that these - symbols may now refer to different variables - (e.g. if X11 #defined NoButton, after this file - is included NoButton would no longer be X11's - NoButton, but Qt::NoButton instead). At this time, - there's no conflict known that could cause problems. - - The original X11 symbols are still accessible - (e.g. for None) as X::None, XNone, and also still - None, unless name lookup finds different None - first (in the current class, etc.) - - Use 'Unsorted', 'Bool' and 'index' as templates. - -*/ - -namespace X -{ - -// template ---> -// Affects: Should be without side effects. -#ifdef Unsorted -#ifndef FIXX11H_Unsorted -#define FIXX11H_Unsorted -const int XUnsorted = Unsorted; -#undef Unsorted -const int Unsorted = XUnsorted; -#endif -#undef Unsorted -#endif -// template <--- - -// Affects: Should be without side effects. -#ifdef None -#ifndef FIXX11H_None -#define FIXX11H_None -const XID XNone = None; -#undef None -const XID None = XNone; -#endif -#undef None -#endif - -// template ---> -// Affects: Should be without side effects. -#ifndef _XTYPEDEF_BOOL -#ifdef Bool -#ifndef FIXX11H_Bool -#define FIXX11H_Bool -typedef Bool XBool; -#undef Bool -#define _XTYPEDEF_BOOL -typedef XBool Bool; -#endif -#undef Bool -#endif -#endif // _XTYPEDEF_BOOL -// template <--- - -// Affects: Should be without side effects. -#ifdef KeyPress -#ifndef FIXX11H_KeyPress -#define FIXX11H_KeyPress -const int XKeyPress = KeyPress; -#undef KeyPress -const int KeyPress = XKeyPress; -#endif -#undef KeyPress -#endif - -// Affects: Should be without side effects. -#ifdef KeyRelease -#ifndef FIXX11H_KeyRelease -#define FIXX11H_KeyRelease -const int XKeyRelease = KeyRelease; -#undef KeyRelease -const int KeyRelease = XKeyRelease; -#endif -#undef KeyRelease -#endif - -// Affects: Should be without side effects. -#ifdef Above -#ifndef FIXX11H_Above -#define FIXX11H_Above -const int XAbove = Above; -#undef Above -const int Above = XAbove; -#endif -#undef Above -#endif - -// Affects: Should be without side effects. -#ifdef Below -#ifndef FIXX11H_Below -#define FIXX11H_Below -const int XBelow = Below; -#undef Below -const int Below = XBelow; -#endif -#undef Below -#endif - -// Affects: Should be without side effects. -#ifdef FocusIn -#ifndef FIXX11H_FocusIn -#define FIXX11H_FocusIn -const int XFocusIn = FocusIn; -#undef FocusIn -const int FocusIn = XFocusIn; -#endif -#undef FocusIn -#endif - -// Affects: Should be without side effects. -#ifdef FocusOut -#ifndef FIXX11H_FocusOut -#define FIXX11H_FocusOut -const int XFocusOut = FocusOut; -#undef FocusOut -const int FocusOut = XFocusOut; -#endif -#undef FocusOut -#endif - -// Affects: Should be without side effects. -#ifdef Always -#ifndef FIXX11H_Always -#define FIXX11H_Always -const int XAlways = Always; -#undef Always -const int Always = XAlways; -#endif -#undef Always -#endif - -// Affects: Should be without side effects. -#ifdef Success -#ifndef FIXX11H_Success -#define FIXX11H_Success -const int XSuccess = Success; -#undef Success -const int Success = XSuccess; -#endif -#undef Success -#endif - -// Affects: Should be without side effects. -#ifdef GrayScale -#ifndef FIXX11H_GrayScale -#define FIXX11H_GrayScale -const int XGrayScale = GrayScale; -#undef GrayScale -const int GrayScale = XGrayScale; -#endif -#undef GrayScale -#endif - -// Affects: Should be without side effects. -#ifdef Status -#ifndef FIXX11H_Status -#define FIXX11H_Status -typedef Status XStatus; -#undef Status -typedef XStatus Status; -#endif -#undef Status -#endif - -// Affects: Should be without side effects. -#ifdef CursorShape -#ifndef FIXX11H_CursorShape -#define FIXX11H_CursorShape -const int XCursorShape = CursorShape; -#undef CursorShape -const int CursorShape = CursorShape; -#endif -#undef CursorShape -#endif - -// template ---> -// Affects: Should be without side effects. -#ifdef index -#ifndef FIXX11H_index -#define FIXX11H_index -inline -char* Xindex( const char* s, int c ) - { - return index( s, c ); - } -#undef index -inline -char* index( const char* s, int c ) - { - return Xindex( s, c ); - } -#endif -#undef index -#endif -// template <--- - -#ifdef rindex -// Affects: Should be without side effects. -#ifndef FIXX11H_rindex -#define FIXX11H_rindex -inline -char* Xrindex( const char* s, int c ) - { - return rindex( s, c ); - } -#undef rindex -inline -char* rindex( const char* s, int c ) - { - return Xrindex( s, c ); - } -#endif -#undef rindex -#endif -} - -using namespace X; diff --git a/kdecore/generate_keys.sh b/kdecore/generate_keys.sh deleted file mode 100755 index d0fea1cdd..000000000 --- a/kdecore/generate_keys.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -## This script extracts the key names from the QT header -## -## Copyright (c) 1999 Nicolas HADACEK (hadacek@kde.org) -## Distributed under the GNU General Public License - -# remove files -rm -f kckey.h kckey.cpp kckey_a - -# extract key names and code from QT header -sed -n '/enum Key/!d - :1 - N - /}/!b1 - p' $1 \ -| sed -n '/=/p' \ -| sed -n 's/\s*Key_/{ "/ - s/,.*$/ },/ - s/ =/",/ - s/Key_/Qt::Key_/ - $s/.*/& }/ - p' \ -> kckey_a -list=`grep '{ "' kckey_a | sed -e 's#.*{ "\([^"]*\)".*#\1#'` -for i in $list; do - if grep -q "i18n(\"QAccel\", \"$i\");" ../common_texts.cpp; then - sed -e "s#^\(.*\"$i\",.*\$\)#\1 // translated#" kckey_a > kckey_a.new && mv kckey_a.new kckey_a - fi -done - -# write header file -begin_line="// This file has been automatically generated by \"generate_keys.sh\"" -echo -e $begin_line \ - "\n// Distributed under the GNU Library General Public License" \ - "\n#ifndef KCKEY_H" \ - "\n#define KCKEY_H" \ - "\n\ntypedef struct {" \ - "\n\tconst char *name;" \ - "\n\tint code;" \ - "\n} KKeys;" \ - "\n\n#define MAX_KEY_LENGTH 15 // should be calculated (gawk ?)" \ - "\n#define MAX_KEY_MODIFIER_LENGTH 21 // \"SHIFT + CRTL + ALT + \" : " \ - "\n#define MAX_FCTN_LENGTH 50 // arbitrary limit" \ - "\n#define NB_KEYS " `cat kckey_a | wc -l` \ - "\nextern const KKeys kde_KKEYS[NB_KEYS];" \ - "\n\n#endif" \ -> kckey.h - -# write source file -echo -e $begin_line \ - "\n// Distributed under the GNU Library General Public License" \ - "\n\n#include " \ - "\n#include \"kckey.h\"" \ - "\n\nconst KKeys kde_KKEYS[NB_KEYS] = {" \ -> kckey.cpp - -cat kckey_a >> kckey.cpp - -echo -e "};" >> kckey.cpp - -# cleaning -rm -f kckey_a diff --git a/kdecore/kaboutdata.cpp b/kdecore/kaboutdata.cpp deleted file mode 100644 index e6aa1a68a..000000000 --- a/kdecore/kaboutdata.cpp +++ /dev/null @@ -1,512 +0,0 @@ -/* - * This file is part of the KDE Libraries - * Copyright (C) 2000 Espen Sand (espen@kde.org) - * - * 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. - * - */ - - -#include -#include -#include -#include - -TQString -KAboutPerson::name() const -{ - return TQString::fromUtf8(mName); -} - -TQString -KAboutPerson::task() const -{ - if (mTask && *mTask) - return i18n(mTask); - else - return TQString::null; -} - -TQString -KAboutPerson::emailAddress() const -{ - return TQString::fromUtf8(mEmailAddress); -} - - -TQString -KAboutPerson::webAddress() const -{ - return TQString::fromUtf8(mWebAddress); -} - - -KAboutTranslator::KAboutTranslator(const TQString & name, - const TQString & emailAddress) -{ - mName=name; - mEmail=emailAddress; -} - -TQString KAboutTranslator::name() const -{ - return mName; -} - -TQString KAboutTranslator::emailAddress() const -{ - return mEmail; -} - -class KAboutDataPrivate -{ -public: - KAboutDataPrivate() - : translatorName("_: NAME OF TRANSLATORS\nYour names") - , translatorEmail("_: EMAIL OF TRANSLATORS\nYour emails") - , productName(0) - , programLogo(0) - , customAuthorTextEnabled(false) - , mTranslatedProgramName( 0 ) - {} - ~KAboutDataPrivate() - { - delete programLogo; - delete[] mTranslatedProgramName; - } - const char *translatorName; - const char *translatorEmail; - const char *productName; - TQImage* programLogo; - TQString customAuthorPlainText, customAuthorRichText; - bool customAuthorTextEnabled; - const char *mTranslatedProgramName; -}; - - - -KAboutData::KAboutData( const char *appName, - const char *programName, - const char *version, - const char *shortDescription, - int licenseType, - const char *copyrightStatement, - const char *text, - const char *homePageAddress, - const char *bugsEmailAddress - ) : - mProgramName( programName ), - mVersion( version ), - mShortDescription( shortDescription ), - mLicenseKey( licenseType ), - mCopyrightStatement( copyrightStatement ), - mOtherText( text ), - mHomepageAddress( homePageAddress ), - mBugEmailAddress( bugsEmailAddress ), - mLicenseText (0) -{ - d = new KAboutDataPrivate; - - if( appName ) { - const char *p = strrchr(appName, '/'); - if( p ) - mAppName = p+1; - else - mAppName = appName; - } else - mAppName = 0; -} - -KAboutData::~KAboutData() -{ - if (mLicenseKey == License_File) - delete [] mLicenseText; - delete d; -} - -void -KAboutData::addAuthor( const char *name, const char *task, - const char *emailAddress, const char *webAddress ) -{ - mAuthorList.append(KAboutPerson(name,task,emailAddress,webAddress)); -} - -void -KAboutData::addCredit( const char *name, const char *task, - const char *emailAddress, const char *webAddress ) -{ - mCreditList.append(KAboutPerson(name,task,emailAddress,webAddress)); -} - -void -KAboutData::setTranslator( const char *name, const char *emailAddress) -{ - d->translatorName=name; - d->translatorEmail=emailAddress; -} - -void -KAboutData::setLicenseText( const char *licenseText ) -{ - mLicenseText = licenseText; - mLicenseKey = License_Custom; -} - -void -KAboutData::setLicenseTextFile( const TQString &file ) -{ - mLicenseText = qstrdup(TQFile::encodeName(file)); - mLicenseKey = License_File; -} - -void -KAboutData::setAppName( const char *appName ) -{ - mAppName = appName; -} - -void -KAboutData::setProgramName( const char* programName ) -{ - mProgramName = programName; - translateInternalProgramName(); -} - -void -KAboutData::setVersion( const char* version ) -{ - mVersion = version; -} - -void -KAboutData::setShortDescription( const char *shortDescription ) -{ - mShortDescription = shortDescription; -} - -void -KAboutData::setLicense( LicenseKey licenseKey) -{ - mLicenseKey = licenseKey; -} - -void -KAboutData::setCopyrightStatement( const char *copyrightStatement ) -{ - mCopyrightStatement = copyrightStatement; -} - -void -KAboutData::setOtherText( const char *otherText ) -{ - mOtherText = otherText; -} - -void -KAboutData::setHomepage( const char *homepage ) -{ - mHomepageAddress = homepage; -} - -void -KAboutData::setBugAddress( const char *bugAddress ) -{ - mBugEmailAddress = bugAddress; -} - -void -KAboutData::setProductName( const char *productName ) -{ - d->productName = productName; -} - -const char * -KAboutData::appName() const -{ - return mAppName; -} - -const char * -KAboutData::productName() const -{ - if (d->productName) - return d->productName; - else - return appName(); -} - -TQString -KAboutData::programName() const -{ - if (mProgramName && *mProgramName) - return i18n(mProgramName); - else - return TQString::null; -} - -const char* -KAboutData::internalProgramName() const -{ - if (d->mTranslatedProgramName) - return d->mTranslatedProgramName; - else - return mProgramName; -} - -// KCrash should call as few things as possible and should avoid e.g. malloc() -// because it may deadlock. Since i18n() needs it, when KLocale is available -// the i18n() call will be done here in advance. -void -KAboutData::translateInternalProgramName() const -{ - delete[] d->mTranslatedProgramName; - d->mTranslatedProgramName = 0; - if( KGlobal::locale() ) - d->mTranslatedProgramName = qstrdup( programName().utf8()); -} - -TQImage -KAboutData::programLogo() const -{ - return d->programLogo ? (*d->programLogo) : TQImage(); -} - -void -KAboutData::setProgramLogo(const TQImage& image) -{ - if (!d->programLogo) - d->programLogo = new TQImage( image ); - else - *d->programLogo = image; -} - -TQString -KAboutData::version() const -{ - return TQString::tqfromLatin1(mVersion); -} - -TQString -KAboutData::shortDescription() const -{ - if (mShortDescription && *mShortDescription) - return i18n(mShortDescription); - else - return TQString::null; -} - -TQString -KAboutData::homepage() const -{ - return TQString::tqfromLatin1(mHomepageAddress); -} - -TQString -KAboutData::bugAddress() const -{ - return TQString::tqfromLatin1(mBugEmailAddress); -} - -const TQValueList -KAboutData::authors() const -{ - return mAuthorList; -} - -const TQValueList -KAboutData::credits() const -{ - return mCreditList; -} - -const TQValueList -KAboutData::translators() const -{ - TQValueList personList; - - if(d->translatorName == 0) - return personList; - - TQStringList nameList; - TQStringList emailList; - - TQString names = i18n(d->translatorName); - if(names != TQString::fromUtf8(d->translatorName)) - { - nameList = TQStringList::split(',',names); - } - - - if(d->translatorEmail) - { - TQString emails = i18n(d->translatorEmail); - - if(emails != TQString::fromUtf8(d->translatorEmail)) - { - emailList = TQStringList::split(',',emails,true); - } - } - - - TQStringList::Iterator nit; - TQStringList::Iterator eit=emailList.begin(); - - for(nit = nameList.begin(); nit != nameList.end(); ++nit) - { - TQString email; - if(eit != emailList.end()) - { - email=*eit; - ++eit; - } - - TQString name=*nit; - - personList.append(KAboutTranslator(name.stripWhiteSpace(), email.stripWhiteSpace())); - } - - return personList; -} - -TQString -KAboutData::aboutTranslationTeam() -{ - return i18n("replace this with information about your translation team", - "

KDE is translated into many languages thanks to the work " - "of the translation teams all over the world.

" - "

For more information on KDE internationalization " - "visit http://l10n.kde.org

" - ); -} - -TQString -KAboutData::otherText() const -{ - if (mOtherText && *mOtherText) - return i18n(mOtherText); - else - return TQString::null; -} - - -TQString -KAboutData::license() const -{ - TQString result; - if (!copyrightStatement().isEmpty()) - result = copyrightStatement() + "\n\n"; - - TQString l; - TQString f; - switch ( mLicenseKey ) - { - case License_File: - f = TQFile::decodeName(mLicenseText); - break; - case License_GPL_V2: - l = "GPL v2"; - f = locate("data", "LICENSES/GPL_V2"); - break; - case License_LGPL_V2: - l = "LGPL v2"; - f = locate("data", "LICENSES/LGPL_V2"); - break; - case License_BSD: - l = "BSD License"; - f = locate("data", "LICENSES/BSD"); - break; - case License_Artistic: - l = "Artistic License"; - f = locate("data", "LICENSES/ARTISTIC"); - break; - case License_QPL_V1_0: - l = "QPL v1.0"; - f = locate("data", "LICENSES/QPL_V1.0"); - break; - case License_Custom: - if (mLicenseText && *mLicenseText) - return( i18n(mLicenseText) ); - // fall through - default: - result += i18n("No licensing terms for this program have been specified.\n" - "Please check the documentation or the source for any\n" - "licensing terms.\n"); - return result; - } - - if (!l.isEmpty()) - result += i18n("This program is distributed under the terms of the %1.").arg( l ); - - if (!f.isEmpty()) - { - TQFile file(f); - if (file.open(IO_ReadOnly)) - { - result += '\n'; - result += '\n'; - TQTextStream str(&file); - result += str.read(); - } - } - - return result; -} - -TQString -KAboutData::copyrightStatement() const -{ - if (mCopyrightStatement && *mCopyrightStatement) - return i18n(mCopyrightStatement); - else - return TQString::null; -} - -TQString -KAboutData::customAuthorPlainText() const -{ - return d->customAuthorPlainText; -} - -TQString -KAboutData::customAuthorRichText() const -{ - return d->customAuthorRichText; -} - -bool -KAboutData::customAuthorTextEnabled() const -{ - return d->customAuthorTextEnabled; -} - -void -KAboutData::setCustomAuthorText(const TQString &plainText, const TQString &richText) -{ - d->customAuthorPlainText = plainText; - d->customAuthorRichText = richText; - - d->customAuthorTextEnabled = true; -} - -void -KAboutData::unsetCustomAuthorText() -{ - d->customAuthorPlainText = TQString::null; - d->customAuthorRichText = TQString::null; - - d->customAuthorTextEnabled = false; -} - diff --git a/kdecore/kaboutdata.h b/kdecore/kaboutdata.h deleted file mode 100644 index 3165c89d9..000000000 --- a/kdecore/kaboutdata.h +++ /dev/null @@ -1,629 +0,0 @@ -/* - * This file is part of the KDE Libraries - * Copyright (C) 2000 Espen Sand (espen@kde.org) - * - * 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. - * - */ - -#include -#include -#include -#include - -#ifndef _KABOUTDATA_H_ -#define _KABOUTDATA_H_ - -class KAboutPersonPrivate; -class KAboutDataPrivate; - -/** - * This structure is used to store information about a person or developer. - * It can store the person's name, a task, an email address and a - * link to a home page. This class is intended for use in the - * KAboutData class, but it can be used elsewhere as well. - * Normally you should at least define the person's name. - * - * Example Usage within a main(): - * - * \code - * KAboutData about("khello", I18N_NOOP("KHello"), "0.1", - * I18N_NOOP("A KDE version of Hello, world!"), - * KAboutData::License_LGPL, - * I18N_NOOP("Copyright (c) 2003 Developer")); - * - * about.addAuthor("Joe Developer", I18N_NOOP("developer"), "joe@host.com", 0); - * about.addCredit("Joe User", I18N_NOOP("A lot of bug reports"), - * "joe.user@host.org", 0); - * KCmdLineArgs::init(argc, argv, &about); - * \endcode - */ -class KDECORE_EXPORT KAboutPerson -{ -public: - /** - * Convenience constructor - * - * @param name The name of the person. - * - * @param task The task of this person. This string should be - * marked for translation, e.g. - * I18N_NOOP("Task description....") - * - * @param emailAddress The email address of the person. - * - * @param webAddress Home page of the person. - */ - KAboutPerson( const char *name, const char *task, - const char *emailAddress, const char *webAddress ) - { - mName = name; - mTask = task; - mEmailAddress = emailAddress; - mWebAddress = webAddress; - } - /** - * @internal - * Don't use. Required by QValueList - */ - KAboutPerson() {} - - /** - * The person's name - * @return the person's name (can be TQString::null, if it has been - * constructed with a null name) - */ - TQString name() const; - - /** - * The person's task - * @return the person's task (can be TQString::null, if it has been - * constructed with a null task) - */ - TQString task() const; - - /** - * The person's email address - * @return the person's email address (can be TQString::null, if it has been - * constructed with a null email) - */ - TQString emailAddress() const; - - /** - * The home page or a relevant link - * @return the persons home page (can be TQString::null, if it has been - * constructed with a null home page) - */ - TQString webAddress() const; - -private: - const char *mName; - const char *mTask; - const char *mEmailAddress; - const char *mWebAddress; - - KAboutPersonPrivate *d; -}; - -class KAboutTranslatorPrivate; -/** - * This structure is used to store information about a translator. - * It can store the translator's name and an email address. - * This class is intended for use in the KAboutData class, - * but it can be used elsewhere as well. - * Normally you should at least define the translator's name. - * - * It's not possible to use KAboutPerson for this, because - * KAboutPerson stores internally only const char* pointers, but the - * translator information is generated dynamically from the translation - * of a dummy string. -*/ -class KDECORE_EXPORT KAboutTranslator -{ -public: - /** - * Convenience constructor - * - * @param name The name of the person. - * - * @param emailAddress The email address of the person. - */ - KAboutTranslator(const TQString & name=TQString::null, - const TQString & emailAddress=TQString::null); - - /** - * The translator's name - * @return the translators's name (can be TQString::null, if it has been - * constructed with a null name) - */ - TQString name() const; - - /** - * The translator's email - * @return the translator's email address (can be TQString::null, if it has been - * constructed with a null email) - */ - TQString emailAddress() const; - -private: - TQString mName; - TQString mEmail; - KAboutTranslatorPrivate* d; -}; - - -/** - * This class is used to store information about a program. It can store - * such values as version number, program name, home page, email address - * for bug reporting, multiple authors and contributors - * (using KAboutPerson), license and copyright information. - * - * Currently, the values set here are shown by the "About" box - * (see KAboutDialog), used by the bug report dialog (see KBugReport), - * and by the help shown on command line (see KCmdLineArgs). - * - * @short Holds information needed by the "About" box and other - * classes. - * @author Espen Sand (espen@kde.org), David Faure (faure@kde.org) - */ -class KDECORE_EXPORT KAboutData -{ - public: - /** - * Descibes the license of the software. - */ - enum LicenseKey - { - License_Custom = -2, - License_File = -1, - License_Unknown = 0, - License_GPL = 1, - License_GPL_V2 = 1, - License_LGPL = 2, - License_LGPL_V2 = 2, - License_BSD = 3, - License_Artistic = 4, - License_QPL = 5, - License_QPL_V1_0 = 5 - }; - - public: - /** - * Constructor. - * - * @param appName The program name used internally. Example: "kedit" - * - * @param programName A displayable program name string. This string - * should be marked for translation. Example: I18N_NOOP("KEdit") - * - * @param version The program version string. - * - * @param shortDescription A short description of what the program does. - * This string should be marked for translation. - * Example: I18N_NOOP("A simple text editor.") - * - * @param licenseType The license identifier. Use setLicenseText if - * you use a license not predefined here. - * - * @param copyrightStatement A copyright statement, that can look like this: - * "(c) 1999-2000, Name". The string specified here is not modified - * in any manner. The author information from addAuthor is not - * used. - * - * @param text Some free form text, that can contain any kind of - * information. The text can contain newlines. This string - * should be marked for translation. - * - * @param homePageAddress The program homepage string. - * Start the address with "http://". "http://some.domain" is - * is correct, "some.domain" is not. - * - * @param bugsEmailAddress The bug report email address string. - * This defaults to the kde.org bug system. - * - */ - KAboutData( const char *appName, - const char *programName, - const char *version, - const char *shortDescription = 0, - int licenseType = License_Unknown, - const char *copyrightStatement = 0, - const char *text = 0, - const char *homePageAddress = 0, - const char *bugsEmailAddress = "submit@bugs.kde.org" - ); - - ~KAboutData(); - - /** - * Defines an author. You can call this function as many times you - * need. Each entry is appended to a list. The person in the first entry - * is assumed to be the leader of the project. - * - * @param name The developer's name in UTF-8 encoding. - * - * @param task What the person is responsible for. This text can contain - * newlines. It should be marked for translation like this: - * I18N_NOOP("Task description..."). Can be 0. - * - * @param emailAddress An Email address where the person can be reached. - * Can be 0. - * - * @param webAddress The person's homepage or a relevant link. - * Start the address with "http://". "http://some.domain" is - * correct, "some.domain" is not. Can be 0. - * - */ - void addAuthor( const char *name, - const char *task=0, - const char *emailAddress=0, - const char *webAddress=0 ); - - /** - * Defines a person that deserves credit. You can call this function - * as many times you need. Each entry is appended to a list. - * - * @param name The person's name in UTF-8 encoding. - * - * @param task What the person has done to deserve the honor. The - * text can contain newlines. It should be marked for - * translation like this: I18N_NOOP("Task description...") - * Can be 0. - * - * @param emailAddress An Email address when the person can be reached. - * Can be 0. - * - * @param webAddress The person's homepage or a relevant link. - * Start the address with "http://". "http://some.domain" is - * is correct, "some.domain" is not. Can be 0. - * - */ - void addCredit( const char *name, - const char *task=0, - const char *emailAddress=0, - const char *webAddress=0 ); - - /** - * Sets the name of the translator of the gui. Since this depends - * on the language, just use a dummy text marked for translation. - * - * For example: - * \code - * setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\\nYour names") - * ,I18N_NOOP("_: EMAIL OF TRANSLATORS\\nYour emails")); - * \endcode - * - * The translator can then translate this dummy text with his name - * or with a list of names separated with ",". - * If there is no translation or the application is used with the - * default language, this function call is ignored. - * - * Note: If you are using the default KDE automake environment, - * there is no need to use this function, because the two - * default strings above are added to the applications po file - * automatically. - * - * @param name the name of the translator - * @param emailAddress the email address of the translator - * @see KAboutTranslator - */ - void setTranslator(const char* name, const char* emailAddress); - - /** - * Defines a license text. - * - * The text will be translated if it got marked for - * translations with the I18N_NOOP() macro. - * - * Example: - * \code - * setLicenseText( I18N_NOOP("This is my license")); - * \endcode - * - * NOTE: No copy of the text is made. - * - * @param license The license text in utf8 encoding. - */ - void setLicenseText( const char *license ); - - /** - * Defines a license text. - * - * @param file File containing the license text. - */ - void setLicenseTextFile( const TQString &file ); - - /** - * Defines the program name used internally. - * - * @param appName The application name. Example: "kate". - */ - void setAppName( const char *appName ); - - /** - * Defines the displayable program name string. - * - * @param programName The program name. This string should be - * marked for translation. - * Example: I18N_NOOP("Advanced Text Editor"). - * @since 3.2 - */ - void setProgramName( const char* programName ); - - /** - * Defines the program logo. - * Use this if you need to have application logo - * in AboutData other than application icon. - * - * @param image logo image. - * @see programLogo() - * @since 3.4 - */ - void setProgramLogo(const TQImage& image); - - /** - * Defines the program version string. - * - * @param version The program version. - */ - void setVersion( const char* version ); - - /** - * Defines a short description of what the program does. - * - * @param shortDescription The program description This string should be marked - * for translation. Example: I18N_NOOP("An advanced text editor - * with syntax highlithing support."). - */ - void setShortDescription( const char *shortDescription ); - - /** - * Defines the license identifier. - * - * @param licenseKey The license identifier. - */ - void setLicense( LicenseKey licenseKey); - - /** - * Defines the copyright statement to show when displaying the license. - * - * @param copyrightStatement A copyright statement, that can look like - * this: "(c) 1999-2000, Name". The string specified here is not - * modified in any manner. The author information from addAuthor - * is not used. - */ - void setCopyrightStatement( const char *copyrightStatement ); - - /** - * Defines the additional text to show in the about dialog. - * - * @param otherText Some free form text, that can contain any kind of - * information. The text can contain newlines. This string - * should be marked for translation. - */ - void setOtherText( const char *otherText ); - - /** - * Defines the program homepage. - * - * @param homepage The program homepage string. - * Start the address with "http://". "http://kate.kde.org" is - * is correct, "kde.kde.org" is not. - */ - void setHomepage( const char *homepage ); - - /** - * Defines the address where bug reports should be sent. - * - * @param bugAddress The bug report email address string. - * This defaults to the kde.org bug system. - */ - void setBugAddress( const char *bugAddress ); - - /** - * Defines the product name wich will be used in the KBugReport dialog. - * By default it's the appName, but you can overwrite it here to provide - * support for special components e.g. 'product/component' like - * 'kontact/summary'. - * - * @param name The name of product - */ - void setProductName( const char *name ); - - /** - * Returns the application's internal name. - * @return the internal program name. - */ - const char *appName() const; - - /** - * Returns the application's product name, which will be used in KBugReport - * dialog. By default it returns appName(), otherwise the one which is set - * with setProductName() - * - * @return the product name. - */ - const char *productName() const; - - /** - * Returns the translated program name. - * @return the program name (translated). - */ - TQString programName() const; - - /** - * @internal - */ - const char* internalProgramName() const; - /** - * @internal - */ - void translateInternalProgramName() const; - - /** - * Returns the program logo image. - * @return the program logo data or null image if there is - * no custom application logo defined. - * @since 3.4 - */ - TQImage programLogo() const; - - /** - * Returns the program's version. - * @return the version string. - */ - TQString version() const; - - /** - * @internal - */ - const char* internalVersion() const { return mVersion; } - - /** - * Returns a short, translated description. - * @return the short description (translated). Can be - * TQString::null if not set. - */ - TQString shortDescription() const; - - /** - * Returns the application homepage. - * @return the application homepage URL. Can be TQString::null if - * not set. - */ - TQString homepage() const; - - /** - * Returns the email address for bugs. - * @return the email address where to report bugs. - */ - TQString bugAddress() const; - - /** - * @internal - */ - const char* internalBugAddress() const { return mBugEmailAddress; } - - /** - * Returns a list of authors. - * @return author information (list of persons). - */ - const TQValueList authors() const; - - /** - * Returns a list of persons who contributed. - * @return credit information (list of persons). - */ - const TQValueList credits() const; - - /** - * Returns a list of translators. - * @return translators information (list of persons) - */ - const TQValueList translators() const; - - /** - * Returns a message about the translation team. - * @return a message about the translation team - */ - static TQString aboutTranslationTeam(); - - /** - * Returns a translated, free form text. - * @return the free form text (translated). Can be TQString::null if not set. - */ - TQString otherText() const; - - /** - * Returns the license. If the licenseType argument of the constructor has been - * used, any text defined by setLicenseText is ignored, - * and the standard text for the chosen license will be returned. - * - * @return The license text. - */ - TQString license() const; - - /** - * Returns the copyright statement. - * @return the copyright statement. Can be TQString::null if not set. - */ - TQString copyrightStatement() const; - - /** - * Returns the plain text displayed around the list of authors instead - * of the default message telling users to send bug reports to bugAddress(). - * - * @return the plain text displayed around the list of authors instead - * of the default message. Can be TQString::null. - */ - TQString customAuthorPlainText() const; - - /** - * Returns the rich text displayed around the list of authors instead - * of the default message telling users to send bug reports to bugAddress(). - * - * @return the rich text displayed around the list of authors instead - * of the default message. Can be TQString::null. - */ - TQString customAuthorRichText() const; - - /** - * Returns whether custom text should be displayed around the list of - * authors. - * - * @return whether custom text should be displayed around the list of - * authors. - */ - bool customAuthorTextEnabled() const; - - /** - * Sets the custom text displayed around the list of authors instead - * of the default message telling users to send bug reports to bugAddress(). - * - * @param plainText The plain text. - * @param richText The rich text. - * - * Both parameters can be TQString::null to not display any message at - * all. Call unsetCustomAuthorText() to revert to the default mesage. - */ - void setCustomAuthorText(const TQString &plainText, const TQString &richText); - - /** - * Clears any custom text displayed around the list of authors and falls - * back to the default message telling users to send bug reports to - * bugAddress(). - */ - void unsetCustomAuthorText(); - - private: - const char *mAppName; - const char *mProgramName; - const char *mVersion; - const char *mShortDescription; - int mLicenseKey; - const char *mCopyrightStatement; - const char *mOtherText; - const char *mHomepageAddress; - const char *mBugEmailAddress; - TQValueList mAuthorList; - TQValueList mCreditList; - const char *mLicenseText; - - KAboutDataPrivate *d; -}; - -#endif - diff --git a/kdecore/kaccel.cpp b/kdecore/kaccel.cpp deleted file mode 100644 index b1fe773c6..000000000 --- a/kdecore/kaccel.cpp +++ /dev/null @@ -1,663 +0,0 @@ -/* - Copyright (c) 2001,2002 Ellis Whitehead - - 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. -*/ - -#include "kaccel.h" - -#include -#include -#include -#include -#include -#include - -#include "kaccelbase.h" -#include -#include -#include -#include - -#include "kaccelprivate.h" - -#ifdef Q_WS_X11 -# include -# ifdef KeyPress // needed for --enable-final - // defined by X11 headers - const int XKeyPress = KeyPress; -# undef KeyPress -# endif -#endif - -// TODO: Put in kaccelbase.cpp -//--------------------------------------------------------------------- -// KAccelEventHandler -//--------------------------------------------------------------------- -// -// In KAccelEventHandler::x11Event we do our own X11 keyboard event handling -// This allows us to map the Win key to Qt::MetaButton, Qt does not know about -// the Win key. -// -// KAccelEventHandler::x11Event will generate an AccelOverride event. The -// AccelOverride event is abused a bit to ensure that KAccelPrivate::eventFilter -// (as an event filter on the toplevel widget) will get the key event first -// (in the form of AccelOverride) before any of the intermediate widgets are -// able to process it. -// -// Qt normally sends an AccelOverride, Accel and then a KeyPress event. -// A widget can accept the AccelOverride event in which case the Accel event will be -// skipped and the KeyPress is followed immediately. -// If the Accel event is accepted, no KeyPress event will follow. -// -// KAccelEventHandler::x11Event converts a X11 keyboard event into an AccelOverride -// event, there are now two possibilities: -// -// 1) If KAccel intercepts the AccelOverride we are done and can consider the X11 -// keyboard event as handled. -// 2) If another widget accepts the AccelOverride, it will expect to get a normal -// Qt generated KeyPress event afterwards. So we let Qt handle the X11 keyboard event -// again. However, this will first generate an AccelOverride event, and we already -// had send that one. To compnesate for this, the global event filter in KApplication -// is instructed to eat the next AccelOveride event. Qt will then send a normal KeyPress -// event and from then on everything is normal again. -// -// kde_g_bKillAccelOverride is used to tell KApplication::notify to eat the next -// AccelOverride event. - -bool kde_g_bKillAccelOverride = false; - -class KAccelEventHandler : public TQWidget -{ - public: - static KAccelEventHandler* self() - { - if( !g_pSelf ) - g_pSelf = new KAccelEventHandler; - return g_pSelf; - } - - static void accelActivated( bool b ) { g_bAccelActivated = b; } - - private: - KAccelEventHandler(); - -# ifdef Q_WS_X11 - bool x11Event( XEvent* pEvent ); -# endif - - static KAccelEventHandler* g_pSelf; - static bool g_bAccelActivated; -}; - -KAccelEventHandler* KAccelEventHandler::g_pSelf = 0; -bool KAccelEventHandler::g_bAccelActivated = false; - -KAccelEventHandler::KAccelEventHandler() - : TQWidget( 0, "KAccelEventHandler" ) -{ -# ifdef Q_WS_X11 - if ( kapp ) - kapp->installX11EventFilter( TQT_TQWIDGET(this) ); -# endif -} - -#ifdef Q_WS_X11 -bool qt_try_modal( TQWidget *, XEvent * ); - -bool KAccelEventHandler::x11Event( XEvent* pEvent ) -{ - if( TQWidget::keyboardGrabber() || !kapp->tqfocusWidget() ) - return false; - - if ( !qt_try_modal(kapp->tqfocusWidget(), pEvent) ) - return false; - - if( pEvent->type == XKeyPress ) { - unsigned int tmp = pEvent->xkey.state; - pEvent->xkey.state &= ~0x2000; - KKeyNative keyNative( pEvent ); - pEvent->xkey.state = tmp; - KKey key( keyNative ); - key.simplify(); - int keyCodeQt = key.keyCodeQt(); - int state = 0; - if( key.modFlags() & KKey::SHIFT ) state |= TQt::ShiftButton; - if( key.modFlags() & KKey::CTRL ) state |= TQt::ControlButton; - if( key.modFlags() & KKey::ALT ) state |= TQt::AltButton; - if( key.modFlags() & KKey::WIN ) state |= TQt::MetaButton; - - TQKeyEvent ke( TQEvent::AccelOverride, keyCodeQt, 0, state ); - ke.ignore(); - - g_bAccelActivated = false; - kapp->sendEvent( kapp->tqfocusWidget(), &ke ); - - // If the Override event was accepted from a non-KAccel widget, - // then kill the next AccelOverride in KApplication::notify. - if( ke.isAccepted() && !g_bAccelActivated ) - kde_g_bKillAccelOverride = true; - - // Stop event processing if a KDE accelerator was activated. - return g_bAccelActivated; - } - - return false; -} -#endif // Q_WS_X11 - -//--------------------------------------------------------------------- -// KAccelPrivate -//--------------------------------------------------------------------- - -KAccelPrivate::KAccelPrivate( KAccel* pParent, TQWidget* pWatch ) -: KAccelBase( KAccelBase::QT_KEYS ) -{ - //kdDebug(125) << "KAccelPrivate::KAccelPrivate( pParent = " << pParent << " ): this = " << this << endl; - m_pAccel = pParent; - m_pWatch = pWatch; - m_bAutoUpdate = true; - connect( (TQAccel*)m_pAccel, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotKeyPressed(int)) ); - -#ifdef Q_WS_X11 //only makes sense if KAccelEventHandler is working - if( m_pWatch ) - m_pWatch->installEventFilter( this ); -#endif - KAccelEventHandler::self(); -} - -void KAccelPrivate::setEnabled( bool bEnabled ) -{ - m_bEnabled = bEnabled; - ((TQAccel*)m_pAccel)->setEnabled( bEnabled ); -} - -bool KAccelPrivate::setEnabled( const TQString& sAction, bool bEnable ) -{ - kdDebug(125) << "KAccelPrivate::setEnabled( \"" << sAction << "\", " << bEnable << " ): this = " << this << endl; - KAccelAction* pAction = actionPtr( sAction ); - if( !pAction ) - return false; - if( pAction->isEnabled() == bEnable ) - return true; - - pAction->setEnabled( bEnable ); - - TQMap::const_iterator it = m_mapIDToAction.begin(); - for( ; it != m_mapIDToAction.end(); ++it ) { - if( *it == pAction ) - ((TQAccel*)m_pAccel)->setItemEnabled( it.key(), bEnable ); - } - return true; -} - -bool KAccelPrivate::removeAction( const TQString& sAction ) -{ - // FIXME: getID() doesn't contains any useful - // information! Use mapIDToAction. --ellis, 2/May/2002 - // Or maybe KAccelBase::remove() takes care of TQAccel indirectly... - KAccelAction* pAction = actions().actionPtr( sAction ); - if( pAction ) { - int nID = pAction->getID(); - //bool b = actions().removeAction( sAction ); - bool b = KAccelBase::remove( sAction ); - ((TQAccel*)m_pAccel)->removeItem( nID ); - return b; - } else - return false; -} - -bool KAccelPrivate::emitSignal( KAccelBase::Signal signal ) -{ - if( signal == KAccelBase::KEYCODE_CHANGED ) { - m_pAccel->emitKeycodeChanged(); - return true; - } - return false; -} - -bool KAccelPrivate::connectKey( KAccelAction& action, const KKeyServer::Key& key ) -{ - uint keyQt = key.keyCodeQt(); - int nID = ((TQAccel*)m_pAccel)->insertItem( keyQt ); - m_mapIDToAction[nID] = &action; - m_mapIDToKey[nID] = keyQt; - - if( action.objSlotPtr() && action.methodSlotPtr() ) { -#ifdef Q_WS_WIN /** @todo TEMP: new implementation (commit #424926) didn't work */ - ((TQAccel*)m_pAccel)->connectItem( nID, action.objSlotPtr(), action.methodSlotPtr() ); -#else - ((TQAccel*)m_pAccel)->connectItem( nID, this, TQT_SLOT(slotKeyPressed(int))); -#endif - if( !action.isEnabled() ) - ((TQAccel*)m_pAccel)->setItemEnabled( nID, false ); - } - - kdDebug(125) << "KAccelPrivate::connectKey( \"" << action.name() << "\", " << key.key().toStringInternal() << " = 0x" << TQString::number(keyQt,16) << " ): id = " << nID << " m_pObjSlot = " << action.objSlotPtr() << endl; - //kdDebug(125) << "m_pAccel = " << m_pAccel << endl; - return nID != 0; -} - -bool KAccelPrivate::connectKey( const KKeyServer::Key& key ) -{ - uint keyQt = key.keyCodeQt(); - int nID = ((TQAccel*)m_pAccel)->insertItem( keyQt ); - - m_mapIDToKey[nID] = keyQt; - - kdDebug(125) << "KAccelPrivate::connectKey( " << key.key().toStringInternal() << " = 0x" << TQString::number(keyQt,16) << " ): id = " << nID << endl; - return nID != 0; -} - -bool KAccelPrivate::disconnectKey( KAccelAction& action, const KKeyServer::Key& key ) -{ - int keyQt = key.keyCodeQt(); - TQMap::iterator it = m_mapIDToKey.begin(); - for( ; it != m_mapIDToKey.end(); ++it ) { - //kdDebug(125) << "m_mapIDToKey[" << it.key() << "] = " << TQString::number(*it,16) << " == " << TQString::number(keyQt,16) << endl; - if( *it == keyQt ) { - int nID = it.key(); - kdDebug(125) << "KAccelPrivate::disconnectKey( \"" << action.name() << "\", 0x" << TQString::number(keyQt,16) << " ) : id = " << nID << " m_pObjSlot = " << action.objSlotPtr() << endl; - ((TQAccel*)m_pAccel)->removeItem( nID ); - m_mapIDToAction.remove( nID ); - m_mapIDToKey.remove( it ); - return true; - } - } - //kdWarning(125) << kdBacktrace() << endl; - kdWarning(125) << "Didn't find key in m_mapIDToKey." << endl; - return false; -} - -bool KAccelPrivate::disconnectKey( const KKeyServer::Key& key ) -{ - int keyQt = key.keyCodeQt(); - kdDebug(125) << "KAccelPrivate::disconnectKey( 0x" << TQString::number(keyQt,16) << " )" << endl; - TQMap::iterator it = m_mapIDToKey.begin(); - for( ; it != m_mapIDToKey.end(); ++it ) { - if( *it == keyQt ) { - ((TQAccel*)m_pAccel)->removeItem( it.key() ); - m_mapIDToKey.remove( it ); - return true; - } - } - //kdWarning(125) << kdBacktrace() << endl; - kdWarning(125) << "Didn't find key in m_mapIDTokey." << endl; - return false; -} - -void KAccelPrivate::slotKeyPressed( int id ) -{ - kdDebug(125) << "KAccelPrivate::slotKeyPressed( " << id << " )" << endl; - - if( m_mapIDToKey.contains( id ) ) { - KKey key = m_mapIDToKey[id]; - KKeySequence seq( key ); - TQPopupMenu* pMenu = createPopupMenu( m_pWatch, seq ); - - // If there was only one action mapped to this key, - // and that action is not a multi-key shortcut, - // then activated it without popping up the menu. - // This is needed for when there are multiple actions - // with the same shortcut where all but one is disabled. - // pMenu->count() also counts the menu title, so one shortcut will give count = 2. - if( pMenu->count() == 2 && pMenu->accel(1).isEmpty() ) { - int iAction = pMenu->idAt(1); - slotMenuActivated( iAction ); - } else { - connect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMenuActivated(int)) ); - pMenu->exec( m_pWatch->mapToGlobal( TQPoint( 0, 0 ) ) ); - disconnect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMenuActivated(int)) ); - } - delete pMenu; - } -} - -void KAccelPrivate::slotShowMenu() -{ -} - -void KAccelPrivate::slotMenuActivated( int iAction ) -{ - kdDebug(125) << "KAccelPrivate::slotMenuActivated( " << iAction << " )" << endl; - KAccelAction* pAction = actions().actionPtr( iAction ); -#ifdef Q_WS_WIN /** @todo TEMP: new implementation (commit #424926) didn't work */ - if( pAction ) { - connect( this, TQT_SIGNAL(menuItemActivated()), pAction->objSlotPtr(), pAction->methodSlotPtr() ); - emit menuItemActivated(); - disconnect( this, TQT_SIGNAL(menuItemActivated()), pAction->objSlotPtr(), pAction->methodSlotPtr() ); - } -#else - emitActivatedSignal( pAction ); -#endif -} - -bool KAccelPrivate::eventFilter( TQObject* /*pWatched*/, TQEvent* pEvent ) -{ - if( pEvent->type() == TQEvent::AccelOverride && m_bEnabled ) { - TQKeyEvent* pKeyEvent = (TQKeyEvent*) pEvent; - KKey key( pKeyEvent ); - kdDebug(125) << "KAccelPrivate::eventFilter( AccelOverride ): this = " << this << ", key = " << key.toStringInternal() << endl; - int keyCodeQt = key.keyCodeQt(); - TQMap::iterator it = m_mapIDToKey.begin(); - for( ; it != m_mapIDToKey.end(); ++it ) { - if( (*it) == keyCodeQt ) { - int nID = it.key(); - kdDebug(125) << "shortcut found!" << endl; - if( m_mapIDToAction.contains( nID ) ) { - // TODO: reduce duplication between here and slotMenuActivated - KAccelAction* pAction = m_mapIDToAction[nID]; - if( !pAction->isEnabled() ) - continue; -#ifdef Q_WS_WIN /** @todo TEMP: new implementation (commit #424926) didn't work */ - TQGuardedPtr me = this; - connect( this, TQT_SIGNAL(menuItemActivated()), pAction->objSlotPtr(), pAction->methodSlotPtr() ); - emit menuItemActivated(); - if (me) { - disconnect( me, TQT_SIGNAL(menuItemActivated()), pAction->objSlotPtr(), pAction->methodSlotPtr() ); - } -#else - emitActivatedSignal( pAction ); -#endif - } else - slotKeyPressed( nID ); - - pKeyEvent->accept(); - KAccelEventHandler::accelActivated( true ); - return true; - } - } - } - return false; -} - -#ifndef Q_WS_WIN /** @todo TEMP: new implementation (commit #424926) didn't work */ -void KAccelPrivate::emitActivatedSignal( KAccelAction* pAction ) -{ - if( pAction ) { - TQGuardedPtr me = this; - TQRegExp reg( "([ ]*KAccelAction.*)" ); - if( reg.search( pAction->methodSlotPtr()) >= 0 ) { - connect( this, TQT_SIGNAL(menuItemActivated(KAccelAction*)), - pAction->objSlotPtr(), pAction->methodSlotPtr() ); - emit menuItemActivated( pAction ); - if (me) - disconnect( me, TQT_SIGNAL(menuItemActivated(KAccelAction*)), - pAction->objSlotPtr(), pAction->methodSlotPtr() ); - } else { - connect( this, TQT_SIGNAL(menuItemActivated()), - pAction->objSlotPtr(), pAction->methodSlotPtr() ); - emit menuItemActivated(); - if (me) - disconnect( me, TQT_SIGNAL(menuItemActivated()), - pAction->objSlotPtr(), pAction->methodSlotPtr() ); - - } - } -} -#endif - -//--------------------------------------------------------------------- -// KAccel -//--------------------------------------------------------------------- - -KAccel::KAccel( TQWidget* pParent, const char* psName ) -: TQAccel( pParent, (psName) ? psName : "KAccel-TQAccel" ) -{ - kdDebug(125) << "KAccel( pParent = " << pParent << ", psName = " << psName << " ): this = " << this << endl; - d = new KAccelPrivate( this, pParent ); -} - -KAccel::KAccel( TQWidget* watch, TQObject* pParent, const char* psName ) -: TQAccel( watch, pParent, (psName) ? psName : "KAccel-TQAccel" ) -{ - kdDebug(125) << "KAccel( watch = " << watch << ", pParent = " << pParent << ", psName = " << psName << " ): this = " << this << endl; - if( !watch ) - kdDebug(125) << kdBacktrace() << endl; - d = new KAccelPrivate( this, watch ); -} - -KAccel::~KAccel() -{ - kdDebug(125) << "~KAccel(): this = " << this << endl; - delete d; -} - -KAccelActions& KAccel::actions() { return d->actions(); } -const KAccelActions& KAccel::actions() const { return d->actions(); } -bool KAccel::isEnabled() { return d->isEnabled(); } -void KAccel::setEnabled( bool bEnabled ) { d->setEnabled( bEnabled ); } -bool KAccel::setAutoUpdate( bool bAuto ) { return d->setAutoUpdate( bAuto ); } - -KAccelAction* KAccel::insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - return d->insert( sAction, sLabel, sWhatsThis, - cutDef, cutDef, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); -} - -KAccelAction* KAccel::insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - return d->insert( sAction, sLabel, sWhatsThis, - cutDef3, cutDef4, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); -} - -KAccelAction* KAccel::insert( const char* psAction, const KShortcut& cutDef, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - return d->insert( psAction, i18n(psAction), TQString::null, - cutDef, cutDef, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); -} - -KAccelAction* KAccel::insert( KStdAccel::StdAccel id, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - TQString sAction = KStdAccel::name( id ); - if( sAction.isEmpty() ) - return 0; - - KAccelAction* pAction = d->insert( sAction, KStdAccel::label( id ), KStdAccel::whatsThis( id ), - KStdAccel::shortcutDefault3( id ), KStdAccel::shortcutDefault4( id ), - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); - if( pAction ) - pAction->setShortcut( KStdAccel::shortcut( id ) ); - - return pAction; -} - -bool KAccel::remove( const TQString& sAction ) - { return d->removeAction( sAction ); } -bool KAccel::updateConnections() - { return d->updateConnections(); } - -const KShortcut& KAccel::shortcut( const TQString& sAction ) const -{ - const KAccelAction* pAction = actions().actionPtr( sAction ); - return (pAction) ? pAction->shortcut() : KShortcut::null(); -} - -bool KAccel::setSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot ) - { return d->setActionSlot( sAction, pObjSlot, psMethodSlot ); } - -bool KAccel::setEnabled( const TQString& sAction, bool bEnable ) - { return d->setEnabled( sAction, bEnable ); } - -bool KAccel::setShortcut( const TQString& sAction, const KShortcut& cut ) -{ - kdDebug(125) << "KAccel::setShortcut( \"" << sAction << "\", " << cut.toStringInternal() << " )" << endl; - KAccelAction* pAction = actions().actionPtr( sAction ); - if( pAction ) { - if( pAction->shortcut() != cut ) - return d->setShortcut( sAction, cut ); - return true; - } - return false; -} - -const TQString& KAccel::configGroup() const - { return d->configGroup(); } -// for tdegames/ksirtet -void KAccel::setConfigGroup( const TQString& s ) - { d->setConfigGroup( s ); } - -bool KAccel::readSettings( KConfigBase* pConfig ) -{ - d->readSettings( pConfig ); - return true; -} - -bool KAccel::writeSettings( KConfigBase* pConfig ) const - { d->writeSettings( pConfig ); return true; } - -void KAccel::emitKeycodeChanged() -{ - kdDebug(125) << "KAccel::emitKeycodeChanged()" << endl; - emit keycodeChanged(); -} - -#ifndef KDE_NO_COMPAT -//------------------------------------------------------------ -// Obsolete methods -- for backward compatibility -//------------------------------------------------------------ - -bool KAccel::insertItem( const TQString& sLabel, const TQString& sAction, - const char* cutsDef, - int /*nIDMenu*/, TQPopupMenu *, bool bConfigurable ) -{ - KShortcut cut( cutsDef ); - bool b = d->insert( sAction, sLabel, TQString::null, - cut, cut, - 0, 0, - bConfigurable ) != 0; - return b; -} - -bool KAccel::insertItem( const TQString& sLabel, const TQString& sAction, - int key, - int /*nIDMenu*/, TQPopupMenu*, bool bConfigurable ) -{ - KShortcut cut; - cut.init( TQKeySequence(key) ); - KAccelAction* pAction = d->insert( sAction, sLabel, TQString::null, - cut, cut, - 0, 0, - bConfigurable ); - return pAction != 0; -} - -// Used in kdeutils/kjots -bool KAccel::insertStdItem( KStdAccel::StdAccel id, const TQString& sLabel ) -{ - KAccelAction* pAction = d->insert( KStdAccel::name( id ), sLabel, TQString::null, - KStdAccel::shortcutDefault3( id ), KStdAccel::shortcutDefault4( id ), - 0, 0 ); - if( pAction ) - pAction->setShortcut( KStdAccel::shortcut( id ) ); - - return true; -} - -bool KAccel::connectItem( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot, bool bActivate ) -{ - kdDebug(125) << "KAccel::connectItem( " << sAction << ", " << pObjSlot << ", " << psMethodSlot << " )" << endl; - if( bActivate == false ) - d->setActionEnabled( sAction, false ); - bool b = setSlot( sAction, pObjSlot, psMethodSlot ); - if( bActivate == true ) - d->setActionEnabled( sAction, true ); - return b; -} - -bool KAccel::removeItem( const TQString& sAction ) - { return d->removeAction( sAction ); } - -bool KAccel::setItemEnabled( const TQString& sAction, bool bEnable ) - { return setEnabled( sAction, bEnable ); } - -void KAccel::changeMenuAccel( TQPopupMenu *menu, int id, const TQString& action ) -{ - KAccelAction* pAction = actions().actionPtr( action ); - TQString s = menu->text( id ); - if( !pAction || s.isEmpty() ) - return; - - int i = s.find( '\t' ); - - TQString k = pAction->shortcut().seq(0).toString(); - if( k.isEmpty() ) - return; - - if ( i >= 0 ) - s.replace( i+1, s.length()-i, k ); - else { - s += '\t'; - s += k; - } - - TQPixmap *pp = menu->pixmap(id); - if( pp && !pp->isNull() ) - menu->changeItem( *pp, s, id ); - else - menu->changeItem( s, id ); -} - -void KAccel::changeMenuAccel( TQPopupMenu *menu, int id, KStdAccel::StdAccel accel ) -{ - changeMenuAccel( menu, id, KStdAccel::name( accel ) ); -} - -int KAccel::stringToKey( const TQString& sKey ) -{ - return KKey( sKey ).keyCodeQt(); -} - -int KAccel::currentKey( const TQString& sAction ) const -{ - KAccelAction* pAction = d->actionPtr( sAction ); - if( pAction ) - return pAction->shortcut().keyCodeQt(); - return 0; -} - -TQString KAccel::findKey( int key ) const -{ - KAccelAction* pAction = d->actionPtr( KKey(key) ); - if( pAction ) - return pAction->name(); - else - return TQString::null; -} -#endif // !KDE_NO_COMPAT - -void KAccel::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kaccel.moc" -#include "kaccelprivate.moc" diff --git a/kdecore/kaccel.h b/kdecore/kaccel.h deleted file mode 100644 index 7bdf9e0e7..000000000 --- a/kdecore/kaccel.h +++ /dev/null @@ -1,390 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead - - 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 _KACCEL_H -#define _KACCEL_H - -#include -#include -#include -#include "kdelibs_export.h" - -class TQPopupMenu; // for obsolete insertItem() methods below -class TQWidget; -class KAccelAction; -class KAccelActions; -class KConfigBase; - -class KAccelPrivate; -/** - * Handle shortcuts. - * - * Allow a user to configure shortcuts - * through application configuration files or through the - * KKeyChooser GUI. - * - * A KAccel contains a list of accelerator actions. - * - * For example, CTRL+Key_P could be a shortcut for printing a document. The key - * codes are listed in tqnamespace.h. "Print" could be the action name for printing. - * The action name identifies the shortcut in configuration files and the - * KKeyChooser GUI. - * - * A KAccel object handles key events sent to its parent widget and to all - * children of this parent widget. The most recently created KAccel object - * has precedence over any KAccel objects created before it. - * When a shortcut pressed, KAccel calls the slot to which it has been - * connected. If you want to set global accelerators, independent of the window - * which has the focus, use KGlobalAccel. - * - * Reconfiguration of a given shortcut can be prevented by specifying - * that an accelerator item is not configurable when it is inserted. A special - * group of non-configurable key bindings are known as the - * standard accelerators. - * - * The standard accelerators appear repeatedly in applications for - * standard document actions such as printing and saving. A convenience method is - * available to insert and connect these accelerators which are configurable on - * a desktop-wide basis. - * - * It is possible for a user to choose to have no key associated with - * an action. - * - * The translated first argument for insertItem() is used only - * in the configuration dialog. - *\code - * KAccel* pAccel = new KAccel( this ); - * - * // Insert an action "Scroll Up" which is associated with the "Up" key: - * pAccel->insert( "Scroll Up", i18n("Scroll up"), - * i18n("Scroll up the current document by one line."), - * Qt::Key_Up, this, TQT_SLOT(slotScrollUp()) ); - * // Insert an standard acclerator action. - * pAccel->insert( KStdAccel::Print, this, TQT_SLOT(slotPrint()) ); - * - * // Update the shortcuts by read any user-defined settings from the - * // application's config file. - * pAccel->readSettings(); - * \endcode - * - * @short Configurable shortcut support for widgets. - * @see KGlobalAccel - * @see KAccelShortcutList - * @see KKeyChooser - * @see KKeyDialog - */ - -class KDECORE_EXPORT KAccel : public TQAccel -{ - Q_OBJECT - public: - /** - * Creates a new KAccel that watches @p pParent, which is also - * the QObject's parent. - * - * @param pParent the parent and widget to watch for key strokes - * @param psName the name of the QObject - */ - KAccel( TQWidget* pParent, const char* psName = 0 ); - - /** - * Creates a new KAccel that watches @p watch. - * - * @param watch the widget to watch for key strokes - * @param parent the parent of the QObject - * @param psName the name of the QObject - */ - KAccel( TQWidget* watch, TQObject* parent, const char* psName = 0 ); - virtual ~KAccel(); - - /** - * @internal - * Returns the KAccel's @p KAccelActions, a list of @p KAccelAction. - * @return the KAccelActions of the KAccel - */ - KAccelActions& actions(); - - /** - * @internal - * Returns the KAccel's @p KAccelActions, a list of @p KAccelAction. - * @return the KAccelActions of the KAccel - */ - const KAccelActions& actions() const; - - /** - * Checks whether the KAccel is active. - * @return true if the TQAccel is enabled - */ - bool isEnabled(); - - /** - * Enables or disables the KAccel. - * @param bEnabled true to enable, false to disable - */ - void setEnabled( bool bEnabled ); - - /** - * Enable auto-update of connections. This means that the signals - * are automatically disconnected when you disable an action, and - * re-enabled when you enable it. By default auto update is turned - * on. If you disable auto-update, you need to call - * updateConnections() after changing actions. - * - * @param bAuto true to enable, false to disable - * @return the value of the flag before this call - */ - bool setAutoUpdate( bool bAuto ); - - /** - * Create an accelerator action. - * - * Usage: - *\code - * insert( "Do Something", i18n("Do Something"), - * i18n("This action allows you to do something really great with this program to " - * "the currently open document."), - * ALT+Key_D, this, TQT_SLOT(slotDoSomething()) ); - *\endcode - * - * @param sAction The internal name of the action. - * @param sLabel An i18n'ized short description of the action displayed when - * using KKeyChooser to reconfigure the shortcuts. - * @param sWhatsThis An extended description of the action. - * @param cutDef The default shortcut. - * @param pObjSlot Pointer to the slot object. - * @param psMethodSlot Pointer to the slot method. - * @param bConfigurable Allow the user to change this shortcut if set to 'true'. - * @param bEnabled The action will be activated by the shortcut if set to 'true'. - */ - KAccelAction* insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable = true, bool bEnabled = true ); - /** - * Same as first insert(), but with separate shortcuts defined for - * 3- and 4- modifier defaults. - */ - KAccelAction* insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable = true, bool bEnabled = true ); - /** - * This is an overloaded function provided for convenience. - * The advantage of this is when you want to use the same text for the name - * of the action as for the user-visible label. - * - * Usage: - * \code - * insert( i18n("Do Something"), ALT+Key_D, this, TQT_SLOT(slotDoSomething()) ); - * \endcode - * - * @param psAction The name AND label of the action. - * @param cutDef The default shortcut for this action. - * @param pObjSlot Pointer to the slot object. - * @param psMethodSlot Pointer to the slot method. - * @param bConfigurable Allow the user to change this shortcut if set to 'true'. - * @param bEnabled The action will be activated by the shortcut if set to 'true'. - */ - KAccelAction* insert( const char* psAction, const KShortcut& cutDef, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable = true, bool bEnabled = true ); - /** - * Similar to the first insert() method, but with the action - * name, short description, help text, and default shortcuts all - * set according to one of the standard accelerators. - * @see KStdAccel. - */ - KAccelAction* insert( KStdAccel::StdAccel id, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable = true, bool bEnabled = true ); - - /** - * Removes the accelerator action identified by the name. - * Remember to also call updateConnections(). - * @param sAction the name of the action to remove - * @return true if successful, false otherwise - */ - bool remove( const TQString& sAction ); - - /** - * Updates the connections of the accelerations after changing them. - * This is only necessary if you have disabled auto updates which are - * on by default. - * @return true if successful, false otherwise - * @see setAutoUpdate() - * @see getAutoUpdate() - */ - bool updateConnections(); - - /** - * Return the shortcut associated with the action named by @p sAction. - * @param sAction the name of the action - * @return the action's shortcut, or a null shortcut if not found - */ - const KShortcut& shortcut( const TQString& sAction ) const; - - /** - * Set the shortcut to be associated with the action named by @p sAction. - * @param sAction the name of the action - * @param shortcut the shortcut to set - * @return true if successful, false otherwise - */ - bool setShortcut( const TQString& sAction, const KShortcut &shortcut ); - - /** - * Set the slot to be called when the shortcut of the action named - * by @p sAction is pressed. - * @param sAction the name of the action - * @param pObjSlot the owner of the slot - * @param psMethodSlot the name of the slot - * @return true if successful, false otherwise - */ - bool setSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot ); - /** - * Enable or disable the action named by @p sAction. - * @param sAction the action to en-/disable - * @param bEnabled true to enable, false to disable - * @return true if successful, false otherwise - */ - bool setEnabled( const TQString& sAction, bool bEnabled ); - - /** - * Returns the configuration group of the settings. - * @return the configuration group - * @see KConfig - */ - const TQString& configGroup() const; - - /** - * Returns the configuration group of the settings. - * @param name the new configuration group - * @see KConfig - */ - void setConfigGroup( const TQString &name ); - - /** - * Read all shortcuts from @p pConfig, or (if @p pConfig - * is zero) from the application's configuration file - * KGlobal::config(). - * - * The group in which the configuration is stored can be - * set with setConfigGroup(). - * @param pConfig the configuration file, or 0 for the application - * configuration file - * @return true if successful, false otherwise - */ - bool readSettings( KConfigBase* pConfig = 0 ); - /** - * Write the current shortcuts to @p pConfig, - * or (if @p pConfig is zero) to the application's - * configuration file. - * @param pConfig the configuration file, or 0 for the application - * configuration file - * @return true if successful, false otherwise - */ - bool writeSettings( KConfigBase* pConfig = 0 ) const; - - /** - * Emits the keycodeChanged() signal. - */ - void emitKeycodeChanged(); - - signals: - /** - * Emitted when one of the key codes has changed. - */ - void keycodeChanged(); - -#ifndef KDE_NO_COMPAT - public: - // Source compatibility to KDE 2.x - /** - * @deprecated use insert - */ - bool insertItem( const TQString& sLabel, const TQString& sAction, - const char* psKey, - int nIDMenu = 0, TQPopupMenu* pMenu = 0, bool bConfigurable = true ) KDE_DEPRECATED; - /** - * @deprecated use insert - */ - bool insertItem( const TQString& sLabel, const TQString& sAction, - int key, - int nIDMenu = 0, TQPopupMenu* pMenu = 0, bool bConfigurable = true ) KDE_DEPRECATED; - /** - * @deprecated use insert - */ - bool insertStdItem( KStdAccel::StdAccel id, const TQString& descr = TQString::null ) KDE_DEPRECATED; - /** - * @deprecated use insert - */ - bool connectItem( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot, bool bActivate = true ) KDE_DEPRECATED; - /** - * @deprecated use insert( accel, pObjSlot, psMethodSlot ); - * - */ - KDE_DEPRECATED bool connectItem( KStdAccel::StdAccel accel, const TQObject* pObjSlot, const char* psMethodSlot ) - { return insert( accel, pObjSlot, psMethodSlot ); } - /** - * @deprecated use remove - */ - bool removeItem( const TQString& sAction ) KDE_DEPRECATED; - /** - * @deprecated - */ - bool setItemEnabled( const TQString& sAction, bool bEnable ) KDE_DEPRECATED; - /** - * @deprecated see KDE3PORTING.html - */ - void changeMenuAccel( TQPopupMenu *menu, int id, const TQString& action ) KDE_DEPRECATED; - /** - * @deprecated see KDE3PORTING.html - */ - void changeMenuAccel( TQPopupMenu *menu, int id, KStdAccel::StdAccel accel ) KDE_DEPRECATED; - /** - * @deprecated - */ - static int stringToKey( const TQString& ) KDE_DEPRECATED; - - /** - * @deprecated Use shortcut(). - * - * Retrieve the key code of the accelerator item with the action name - * @p action, or zero if either the action name cannot be - * found or the current key is set to no key. - */ - int currentKey( const TQString& action ) const KDE_DEPRECATED; - - /** - * @deprecated Use actions().actionPtr(). - * - * Return the name of the accelerator item with the keycode @p key, - * or TQString::null if the item cannot be found. - */ - TQString findKey( int key ) const KDE_DEPRECATED; -#endif // !KDE_NO_COMPAT - - protected: - /** \internal */ - virtual void virtual_hook( int id, void* data ); - private: - class KAccelPrivate* d; - friend class KAccelPrivate; -}; - -#endif // _KACCEL_H diff --git a/kdecore/kaccelaction.cpp b/kdecore/kaccelaction.cpp deleted file mode 100644 index 856bbefdc..000000000 --- a/kdecore/kaccelaction.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/* - Copyright (C) 1998 Mark Donohoe - Copyright (C) 1997-2000 Nicolas Hadacek - Copyright (C) 1998 Matthias Ettrich - Copyright (c) 2001,2002 Ellis Whitehead - - 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. -*/ - -#include "kaccelaction.h" -#include "kaccelbase.h" // for KAccelBase::slotRemoveAction() & emitSignal() - -#include - -#include -#include "kckey.h" -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------- -// KAccelAction -//--------------------------------------------------------------------- - -class KAccelActionPrivate -{ - public: - uint m_nConnections; -}; - -KAccelAction::KAccelAction() -{ - //kdDebug(125) << "KAccelAction(): this = " << this << endl; - d = new KAccelActionPrivate; - m_pObjSlot = 0; - m_psMethodSlot = 0; - m_bConfigurable = true; - m_bEnabled = true; - m_nIDAccel = 0; - d->m_nConnections = 0; -} - -KAccelAction::KAccelAction( const KAccelAction& action ) -{ - //kdDebug(125) << "KAccelAction( copy from \"" << action.m_sName << "\" ): this = " << this << endl; - d = new KAccelActionPrivate; - *this = action; -} - -KAccelAction::KAccelAction( const TQString& sName, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - //kdDebug(125) << "KAccelAction( \"" << sName << "\" ): this = " << this << endl; - d = new KAccelActionPrivate; - init( sName, sLabel, sWhatsThis, - cutDef3, cutDef4, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); -} - -KAccelAction::~KAccelAction() -{ - //kdDebug(125) << "\t\t\tKAccelAction::~KAccelAction( \"" << m_sName << "\" ): this = " << this << endl; - delete d; -} - -void KAccelAction::clear() -{ - m_cut.clear(); - m_pObjSlot = 0; - m_psMethodSlot = 0; - m_bConfigurable = true; - m_bEnabled = true; - m_nIDAccel = 0; - d->m_nConnections = 0; -} - -bool KAccelAction::init( const TQString& sName, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - m_sName = sName; - m_sLabel = sLabel; - m_sWhatsThis = sWhatsThis; - m_cutDefault3 = rgCutDefaults3; - m_cutDefault4 = rgCutDefaults4; - m_pObjSlot = pObjSlot; - m_psMethodSlot = psMethodSlot; - m_bConfigurable = bConfigurable; - m_bEnabled = bEnabled; - m_nIDAccel = 0; - m_cut = shortcutDefault(); - d->m_nConnections = 0; - if( !m_bEnabled ) - kdDebug(125) << "KAccelAction::init( \"" << sName << "\" ): created with enabled = false" << endl; - return true; -} - -KAccelAction& KAccelAction::operator =( const KAccelAction& action ) -{ - m_sName = action.m_sName; - m_sLabel = action.m_sLabel; - m_sWhatsThis = action.m_sWhatsThis; - m_cutDefault3 = action.m_cutDefault3; - m_cutDefault4 = action.m_cutDefault4; - m_pObjSlot = action.m_pObjSlot; - m_psMethodSlot = action.m_psMethodSlot; - m_bConfigurable = action.m_bConfigurable; - m_bEnabled = action.m_bEnabled; - m_nIDAccel = action.m_nIDAccel; - m_cut = action.m_cut; - d->m_nConnections = action.d->m_nConnections; - - return *this; -} - -void KAccelAction::setName( const TQString& s ) - { m_sName = s; } -void KAccelAction::setLabel( const TQString& s ) - { m_sLabel = s; } -void KAccelAction::setWhatsThis( const TQString& s ) - { m_sWhatsThis = s; } - -bool KAccelAction::setShortcut( const KShortcut& cut ) -{ - m_cut = cut; - return true; -} - -void KAccelAction::setSlot( const TQObject* pObjSlot, const char* psMethodSlot ) -{ - m_pObjSlot = pObjSlot; - m_psMethodSlot = psMethodSlot; -} - -void KAccelAction::setConfigurable( bool b ) - { m_bConfigurable = b; } -void KAccelAction::setEnabled( bool b ) - { m_bEnabled = b; } - -TQString KAccelAction::toString() const - { return m_cut.toString(); } - -TQString KAccelAction::toStringInternal() const - { return m_cut.toStringInternal( &shortcutDefault() ); } - -bool KAccelAction::setKeySequence( uint i, const KKeySequence& seq ) -{ - if( i < m_cut.count() ) { - m_cut.setSeq( i, seq ); - return true; - } else if( i == m_cut.count() ) - return m_cut.append( seq ); - return false; -} - -void KAccelAction::clearShortcut() -{ - m_cut.clear(); -} - -bool KAccelAction::contains( const KKeySequence& seq ) -{ - return m_cut.contains( seq ); - for( uint i = 0; i < m_cut.count(); i++ ) { - if( m_cut.seq(i) == seq ) - return true; - } - return false; -} - -const KShortcut& KAccelAction::shortcutDefault() const - { return (useFourModifierKeys()) ? m_cutDefault4 : m_cutDefault3; } -bool KAccelAction::isConnected() const - { return d->m_nConnections; } -void KAccelAction::incConnections() - { d->m_nConnections++; } -void KAccelAction::decConnections() - { if( d->m_nConnections > 0 ) d->m_nConnections--; } - -// Indicate whether to default to the 3- or 4- modifier keyboard schemes -int KAccelAction::g_bUseFourModifierKeys = -1; - -bool KAccelAction::useFourModifierKeys() -{ - if( KAccelAction::g_bUseFourModifierKeys == -1 ) { - // Read in whether to use 4 modifier keys - KConfigGroupSaver cgs( KGlobal::config(), "Keyboard" ); - bool b = KGlobal::config()->readBoolEntry( "Use Four Modifier Keys", false ); - KAccelAction::g_bUseFourModifierKeys = b && KKeyNative::keyboardHasWinKey(); - } - return KAccelAction::g_bUseFourModifierKeys == 1; -} - -void KAccelAction::useFourModifierKeys( bool b ) -{ - if( KAccelAction::g_bUseFourModifierKeys != (int)b ) { - KAccelAction::g_bUseFourModifierKeys = b && KKeyNative::keyboardHasWinKey(); - // If we're 'turning off' the meta key or, if we're turning it on, - // the keyboard must actually have a meta key. - if( b && !KKeyNative::keyboardHasWinKey() ) - kdDebug(125) << "Tried to use four modifier keys on a keyboard layout without a Meta key.\n"; - } - KConfigGroupSaver cgs( KGlobal::config(), "Keyboard" ); - KGlobal::config()->writeEntry( "Use Four Modifier Keys", KAccelAction::g_bUseFourModifierKeys, true, true); - - kdDebug(125) << "bUseFourModifierKeys = " << KAccelAction::g_bUseFourModifierKeys << endl; -} - -//--------------------------------------------------------------------- -// KAccelActions -//--------------------------------------------------------------------- - -class KAccelActionsPrivate -{ - public: -}; - -KAccelActions::KAccelActions() -{ - kdDebug(125) << "KAccelActions(): this = " << this << endl; - initPrivate( 0 ); -} - -KAccelActions::KAccelActions( const KAccelActions& actions ) -{ - kdDebug(125) << "KAccelActions( actions = " << &actions << " ): this = " << this << endl; - initPrivate( 0 ); - init( actions ); -} - -KAccelActions::KAccelActions( KAccelBase* pKAccelBase ) -{ - kdDebug(125) << "KAccelActions( KAccelBase = " << pKAccelBase << " ): this = " << this << endl; - initPrivate( pKAccelBase ); -} - -KAccelActions::~KAccelActions() -{ - //kdDebug(125) << "KAccelActions::~KAccelActions(): this = " << this << endl; - clear(); - //delete d; -} - -void KAccelActions::initPrivate( KAccelBase* pKAccelBase ) -{ - m_pKAccelBase = pKAccelBase; - m_nSizeAllocated = m_nSize = 0; - m_prgActions = 0; - //d = new KAccelActionsPrivate; -} - -void KAccelActions::clear() -{ - kdDebug(125) << "\tKAccelActions::clear()" << endl; - for( uint i = 0; i < m_nSize; i++ ) - delete m_prgActions[i]; - delete[] m_prgActions; - - m_nSizeAllocated = m_nSize = 0; - m_prgActions = 0; -} - -bool KAccelActions::init( const KAccelActions& actions ) -{ - clear(); - resize( actions.count() ); - for( uint i = 0; i < m_nSize; i++ ) { - KAccelAction* pAction = actions.m_prgActions[i]; - if( pAction ) - m_prgActions[i] = new KAccelAction( *pAction ); - else - m_prgActions[i] = 0; - } - - return true; -} - -bool KAccelActions::init( KConfigBase& config, const TQString& sGroup ) -{ - kdDebug(125) << "KAccelActions::init( " << sGroup << " )" << endl; - TQMap mapEntry = config.entryMap( sGroup ); - resize( mapEntry.count() ); - - TQMap::Iterator it( mapEntry.begin() ); - for( uint i = 0; it != mapEntry.end(); ++it, i++ ) { - TQString sShortcuts = *it; - KShortcut cuts; - - kdDebug(125) << it.key() << " = " << sShortcuts << endl; - if( !sShortcuts.isEmpty() && sShortcuts != "none" ) - cuts.init( sShortcuts ); - - m_prgActions[i] = new KAccelAction( it.key(), it.key(), it.key(), - cuts, cuts, - 0, 0, // pObjSlot, psMethodSlot, - true, false ); // bConfigurable, bEnabled - } - - return true; -} - -void KAccelActions::resize( uint nSize ) -{ - if( nSize > m_nSizeAllocated ) { - uint nSizeAllocated = ((nSize/10) + 1) * 10; - KAccelAction** prgActions = new KAccelAction* [nSizeAllocated]; - - // Copy pointers over to new array - for( uint i = 0; i < m_nSizeAllocated; i++ ) - prgActions[i] = m_prgActions[i]; - - // Null out new pointers - for( uint i = m_nSizeAllocated; i < nSizeAllocated; i++ ) - prgActions[i] = 0; - - delete[] m_prgActions; - m_prgActions = prgActions; - m_nSizeAllocated = nSizeAllocated; - } - - m_nSize = nSize; -} - -void KAccelActions::insertPtr( KAccelAction* pAction ) -{ - resize( m_nSize + 1 ); - m_prgActions[m_nSize-1] = pAction; -} - -void KAccelActions::updateShortcuts( KAccelActions& actions2 ) -{ - kdDebug(125) << "KAccelActions::updateShortcuts()" << endl; - bool bChanged = false; - - for( uint i = 0; i < m_nSize; i++ ) { - KAccelAction* pAction = m_prgActions[i]; - if( pAction && pAction->m_bConfigurable ) { - KAccelAction* pAction2 = actions2.actionPtr( pAction->m_sName ); - if( pAction2 ) { - TQString sOld = pAction->m_cut.toStringInternal(); - pAction->m_cut = pAction2->m_cut; - kdDebug(125) << "\t" << pAction->m_sName - << " found: " << sOld - << " => " << pAction2->m_cut.toStringInternal() - << " = " << pAction->m_cut.toStringInternal() << endl; - bChanged = true; - } - } - } - - if( bChanged ) - emitKeycodeChanged(); -} - -int KAccelActions::actionIndex( const TQString& sAction ) const -{ - for( uint i = 0; i < m_nSize; i++ ) { - if( m_prgActions[i] == 0 ) - kdWarning(125) << "KAccelActions::actionPtr( " << sAction << " ): encountered null pointer at m_prgActions[" << i << "]" << endl; - else if( m_prgActions[i]->m_sName == sAction ) - return (int) i; - } - return -1; -} - -KAccelAction* KAccelActions::actionPtr( uint i ) -{ - return m_prgActions[i]; -} - -const KAccelAction* KAccelActions::actionPtr( uint i ) const -{ - return m_prgActions[i]; -} - -KAccelAction* KAccelActions::actionPtr( const TQString& sAction ) -{ - int i = actionIndex( sAction ); - return (i >= 0) ? m_prgActions[i] : 0; -} - -const KAccelAction* KAccelActions::actionPtr( const TQString& sAction ) const -{ - int i = actionIndex( sAction ); - return (i >= 0) ? m_prgActions[i] : 0; -} - -KAccelAction* KAccelActions::actionPtr( KKeySequence cut ) -{ - for( uint i = 0; i < m_nSize; i++ ) { - if( m_prgActions[i] == 0 ) - kdWarning(125) << "KAccelActions::actionPtr( " << cut.toStringInternal() << " ): encountered null pointer at m_prgActions[" << i << "]" << endl; - else if( m_prgActions[i]->contains( cut ) ) - return m_prgActions[i]; - } - return 0; -} - -KAccelAction& KAccelActions::operator []( uint i ) -{ - return *actionPtr( i ); -} - -const KAccelAction& KAccelActions::operator []( uint i ) const -{ - return *actionPtr( i ); -} - -KAccelAction* KAccelActions::insert( const TQString& sName, const TQString& sLabel ) -{ - if( actionPtr( sName ) ) { - kdWarning(125) << "KAccelActions::insertLabel( " << sName << ", " << sLabel << " ): action with same name already present." << endl; - return 0; - } - - KAccelAction* pAction = new KAccelAction; - pAction->m_sName = sName; - pAction->m_sLabel = sLabel; - pAction->m_bConfigurable = false; - pAction->m_bEnabled = false; - - insertPtr( pAction ); - return pAction; -} - -KAccelAction* KAccelActions::insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - //kdDebug(125) << "KAccelActions::insert()2 begin" << endl; - if( actionPtr( sAction ) ) { - kdWarning(125) << "KAccelActions::insert( " << sAction << " ): action with same name already present." << endl; - return 0; - } - - KAccelAction* pAction = new KAccelAction( - sAction, sLabel, sWhatsThis, - rgCutDefaults3, rgCutDefaults4, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); - insertPtr( pAction ); - - //kdDebug(125) << "KAccelActions::insert()2 end" << endl; - return pAction; -} - -bool KAccelActions::remove( const TQString& sAction ) -{ - kdDebug(125) << "KAccelActions::remove( \"" << sAction << "\" ): this = " << this << " m_pKAccelBase = " << m_pKAccelBase << endl; - - int iAction = actionIndex( sAction ); - if( iAction < 0 ) - return false; - - if( m_pKAccelBase ) - m_pKAccelBase->slotRemoveAction( m_prgActions[iAction] ); - delete m_prgActions[iAction]; - - for( uint i = iAction; i < m_nSize - 1; i++ ) - m_prgActions[i] = m_prgActions[i+1]; - m_nSize--; - - return true; -} - -bool KAccelActions::readActions( const TQString& sConfigGroup, KConfigBase* pConfig ) -{ - KAccelShortcutList accelList(*this, false); - return accelList.readSettings( sConfigGroup, pConfig ); -} - -/* - 1) KAccelAction = "Something" - 1) KKeySequence = "Meta+X,Asterisk" - 1) KAccelSequence = "Meta+X" - 1) KKeySequence = Meta+X - 2) KAccelSequence = "Asterisk" - 1) KKeySequence = Shift+8 (English layout) - 2) KKeySequence = Keypad_Asterisk - 2) KKeySequence = "Alt+F2" - 1) KAccelSequence = "Alt+F2" - 1) KKeySequence = Alt+F2 - -> "Something=Meta+X,Asterisk;Alt+F2" -*/ -bool KAccelActions::writeActions( const TQString &sGroup, KConfigBase* pConfig, - bool bWriteAll, bool bGlobal ) const -{ - kdDebug(125) << "KAccelActions::writeActions( " << sGroup << ", " << pConfig << ", " << bWriteAll << ", " << bGlobal << " )" << endl; - if( !pConfig ) - pConfig = KGlobal::config(); - KConfigGroupSaver cs( pConfig, sGroup ); - - for( uint i = 0; i < m_nSize; i++ ) { - if( m_prgActions[i] == 0 ) { - kdWarning(125) << "KAccelActions::writeActions(): encountered null pointer at m_prgActions[" << i << "]" << endl; - continue; - } - const KAccelAction& action = *m_prgActions[i]; - - TQString s; - bool bConfigHasAction = !pConfig->readEntry( action.m_sName ).isEmpty(); - bool bSameAsDefault = true; - bool bWriteAction = false; - - if( action.m_bConfigurable ) { - s = action.toStringInternal(); - bSameAsDefault = (action.m_cut == action.shortcutDefault()); - - //if( bWriteAll && s.isEmpty() ) - if( s.isEmpty() ) - s = "none"; - - // If we're using a global config or this setting - // differs from the default, then we want to write. - if( bWriteAll || !bSameAsDefault ) - bWriteAction = true; - - if( bWriteAction ) { - kdDebug(125) << "\twriting " << action.m_sName << " = " << s << endl; - // Is passing bGlobal irrelevant, since if it's true, - // then we're using the global config anyway? --ellis - pConfig->writeEntry( action.m_sName, s, true, bGlobal ); - } - // Otherwise, this key is the same as default - // but exists in config file. Remove it. - else if( bConfigHasAction ) { - kdDebug(125) << "\tremoving " << action.m_sName << " because == default" << endl; - pConfig->deleteEntry( action.m_sName, bGlobal ); - } - - } - } - - pConfig->sync(); - return true; -} - -void KAccelActions::emitKeycodeChanged() -{ - if( m_pKAccelBase ) - m_pKAccelBase->emitSignal( KAccelBase::KEYCODE_CHANGED ); -} - -uint KAccelActions::count() const - { return m_nSize; } diff --git a/kdecore/kaccelaction.h b/kdecore/kaccelaction.h deleted file mode 100644 index d55e4517c..000000000 --- a/kdecore/kaccelaction.h +++ /dev/null @@ -1,576 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead - - 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 _KACCELACTION_H -#define _KACCELACTION_H - -#include -#include -#include -#include - -#include - -class KAccelBase; - -class TQObject; -class KConfig; -class KConfigBase; - -/** - * @internal - * A KAccelAction prepresents an action that can be executed using - * an accelerator key. Each KAccelAction has a name, a label, a - * "What's this" string and a KShortcut. The user can configure and - * enable/disable them using KKeyDialog. - * - * \code - * 1) KAccelAction = "Run Command" - * Default3 = "Alt+F2" - * Default4 = "Meta+Enter;Alt+F2" - * 1) KShortcut = "Meta+Enter" - * 1) KKeySequence = "Meta+Enter" - * 1) KKey = "Meta+Enter" - * 1) Meta+Enter - * 2) Meta+Keypad_Enter - * 2) KShortcut = "Alt+F2" - * 1) KKeySequence = "Alt+F2" - * 1) Alt+F2 - * 2) KAccelAction = "Something" - * Default3 = "" - * Default4 = "" - * 1) KShortcut = "Meta+X,Asterisk" - * 1) KKeySequence = "Meta+X,Asterisk" - * 1) KKey = "Meta+X" - * 1) Meta+X - * 2) KKey = "Asterisk" - * 1) Shift+8 (English layout) - * 2) Keypad_Asterisk - * \endcode - * @short An accelerator action - * @see KAccel - * @see KGlobalAccel - * @see KKeyChooser - * @see KKeyDialog - */ -class KDECORE_EXPORT KAccelAction -{ - public: - /** - * Creates an empty KAccelAction. - * @see clear() - */ - KAccelAction(); - - /** - * Copy constructor. - */ - KAccelAction( const KAccelAction& ); - - /** - * Creates a new KAccelAction. - * @param sName the name of the accelerator - * @param sLabel the label of the accelerator (i18n!) - * @param sWhatsThis the What's This text (18n!) - * @param cutDef3 the default shortcut for 3 modifier systems - * @param cutDef4 the default shortcut for 4 modifier systems - * @param pObjSlot the receiver of a signal when the key has been - * pressed - * @param psMethodSlot the slot to connect for key presses. Receives - * an int, as set by setID(), as only argument - * @param bConfigurable if true the user can configure the shortcut - * @param bEnabled true if the accelerator should be enabled - */ - KAccelAction( const TQString& sName, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ); - ~KAccelAction(); - - /** - * Clears the accelerator. - */ - void clear(); - - /** - * Re-initialized the KAccelAction. - * @param sName the name of the accelerator - * @param sLabel the label of the accelerator (i18n!) - * @param sWhatsThis the What's This text (18n!) - * @param cutDef3 the default shortcut for 3 modifier systems - * @param cutDef4 the default shortcut for 4 modifier systems - * @param pObjSlot the receiver of a signal when the key has been - * pressed - * @param psMethodSlot the slot to connect for key presses. Receives - * an int, as set by setID(), as only argument - * @param bConfigurable if true the user can configure the shortcut - * @param bEnabled true if the accelerator should be enabled - * @return true if successful, false otherwise - */ - bool init( const TQString& sName, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ); - - /** - * Copies this KAccelAction. - */ - KAccelAction& operator=( const KAccelAction& ); - - /** - * Returns the name of the accelerator action. - * @return the name of the accelerator action, can be null if not - * set - */ - const TQString& name() const { return m_sName; } - - /** - * Returns the label of the accelerator action. - * @return the label of the accelerator action, can be null if - * not set - */ - const TQString& label() const { return m_sLabel; } - - /** - * Returns the What's This text of the accelerator action. - * @return the What's This text of the accelerator action, can be - * null if not set - */ - const TQString& whatsThis() const { return m_sWhatsThis; } - - /** - * The shortcut that is actually used (may be used configured). - * @return the shortcut of the KAccelAction, can be null if not set - * @see shortcutDefault() - */ - const KShortcut& shortcut() const { return m_cut; } - - /** - * The default shortcut for this system. - * @return the default shortcut on this system, can be null if not set - * @see shortcut() - * @see shortcutDefault3() - * @see shortcutDefault4() - */ - const KShortcut& shortcutDefault() const; - - /** - * The default shortcut for 3 modifier systems. - * @return the default shortcut for 3 modifier systems, can be null - * if not set - * @see shortcutDefault() - * @see shortcutDefault4() - * @see useFourModifierKeys() - */ - const KShortcut& shortcutDefault3() const { return m_cutDefault3; } - - /** - * The default shortcut for 4 modifier systems. - * @return the default shortcut for 4 modifier systems, can be null - * if not set - * @see shortcutDefault() - * @see shortcutDefault3() - * @see useFourModifierKeys() - */ - const KShortcut& shortcutDefault4() const { return m_cutDefault4; } - - /** - * Returns the receiver of signals. - * @return the receiver of signals (can be 0 if not set) - */ - const TQObject* objSlotPtr() const { return m_pObjSlot; } - - /** - * Returns the slot for the signal. - * @return the slot for the signal - */ - const char* methodSlotPtr() const { return m_psMethodSlot; } - - /** - * Checks whether the user can configure the action. - * @return true if configurable, false otherwise - */ - bool isConfigurable() const { return m_bConfigurable; } - - /** - * Checks whether the action is enabled. - * @return true if enabled, false otherwise - */ - bool isEnabled() const { return m_bEnabled; } - - /** - * Sets the name of the accelerator action. - * @param name the new name - */ - void setName( const TQString& name ); - - /** - * Sets the user-readable label of the accelerator action. - * @param label the new label (i18n!) - */ - void setLabel( const TQString& label ); - - /** - * Sets the What's This text for the accelerator action. - * @param whatsThis the new What's This text (i18n!) - */ - void setWhatsThis( const TQString& whatsThis ); - - /** - * Sets the new shortcut of the accelerator action. - * @param rgCuts the shortcut to set - * @return true if successful, false otherwise - */ - bool setShortcut( const KShortcut& rgCuts ); - - /** - * Sets the slot of the accelerator action. - * @param pObjSlot the receiver object of the signal - * @param psMethodSlot the slot for the signal - */ - void setSlot( const TQObject* pObjSlot, const char* psMethodSlot ); - - /** - * Enables or disabled configuring the action. - * @param configurable true to enable configurability, false to disable - */ - void setConfigurable( bool configurable ); - - /** - * Enables or disabled the action. - * @param enable true to enable the action, false to disable - */ - void setEnabled( bool enable ); - - /** - * Retrieves the id set using setID. - * @return the id of the accelerator action - */ - int getID() const { return m_nIDAccel; } - - /** - * Allows you to set an id that will be used as the action - * signal's argument. - * - * @param n the new id - * @see getID() - */ - void setID( int n ) { m_nIDAccel = n; } - - /** - * Checkes whether the action is connected (emits signals). - * @return true if connected, false otherwise - */ - bool isConnected() const; - - /** - * Sets a key sequence of the action's shortcut. - * @param i the position of the sequence - * @param keySeq the new new sequence - * @return true if successful, false otherwise - * @see KShortcut::setSeq() - */ - bool setKeySequence( uint i, const KKeySequence &keySeq ); - - /** - * Clears the action's shortcut. It will not contain any sequences after - * calling this method. - * @see KShortcut::clear() - */ - void clearShortcut(); - - /** - * Checks whether the action's shortcut contains the given key sequence. - * @param keySeq the key sequence to check - * @return true if the shortcut contains the given sequence - * @see KShortcut::contains() - */ - bool contains( const KKeySequence &keySeq ); - - /** - * Returns the string representation of the action's shortcut. - * @return the string representation of the action's shortcut. - * @see KShortcut::toString() - */ - TQString toString() const; - - /** - * @internal - */ - TQString toStringInternal() const; - - /** - * Returns true if four modifier keys will be used. - * @return true if four modifier keys will be used. - */ - static bool useFourModifierKeys(); - - /** - * Selects 3 or 4 modifier default shortcuts. - * @param use true to use 4 modifier shortcuts, false to use - * 3 modifier shortcuts - */ - static void useFourModifierKeys( bool use ); - - protected: - TQString m_sName /**< Name of accel. @sa setName() */, - m_sLabel /**< Label of accel. User-visible. */, - m_sWhatsThis /**< WhatsThis help for accel. User-visible. */; - KShortcut m_cut /**< Shortcut actually assigned. */; - KShortcut m_cutDefault3 /**< Default shortcut in 3-modifier layout */, - m_cutDefault4 /**< Default shortcur in 4-modifier layout */; - const TQObject* m_pObjSlot /**< Object we will send signals to. */; - const char* m_psMethodSlot /**< Slot we send signals to, in m_pObjSlot */; - bool m_bConfigurable /**< Can this accel be configured by the user? */, - m_bEnabled /**< Is this accel enabled? */; - int m_nIDAccel /**< Id of this accel, from the list of IDs */; - uint m_nConnections /**< Number of connections to this accel. */ ; - - /** @internal Increment the number of connections to this accel. */ - void incConnections(); - /** @internal Decrement the number of connections to this accel (bouded by zero). */ - void decConnections(); - - private: - static int g_bUseFourModifierKeys; - class KAccelActionPrivate* d; - - friend class KAccelActions; - friend class KAccelBase; -}; - -//--------------------------------------------------------------------- -// KAccelActions -//--------------------------------------------------------------------- - -/** - * @internal - * This class represents a collection of KAccelAction objects. - * - * @short A collection of accelerator actions - * @see KAccelAction - */ -class KDECORE_EXPORT KAccelActions -{ - public: - /** - * Creates a new, empty KAccelActions object. - */ - KAccelActions(); - - /** - * Copy constructor (deep copy). - */ - KAccelActions( const KAccelActions& ); - virtual ~KAccelActions(); - - /** - * Removes all items from this collection. - */ - void clear(); - - /** - * Initializes this object with the given actions. - * It will make a deep copy of all actions. - * @param actions the actions to copy - * @return true if successful, false otherwise - */ - bool init( const KAccelActions &actions ); - - /** - * Loads the actions from the given configuration file. - * - * @param config the configuration file to load from - * @param sGroup the group in the configuration file - * @return true if successful, false otherwise - */ - bool init( KConfigBase& config, const TQString& sGroup ); - - /** - * Updates the shortcuts of all actions in this object - * with the shortcuts from the given object. - * @param shortcuts the collection that contains the new - * shortcuts - */ - void updateShortcuts( KAccelActions &shortcuts ); - - /** - * Retrieves the index of the action with the given name. - * @param sAction the action to search - * @return the index of the action, or -1 if not found - */ - int actionIndex( const TQString& sAction ) const; - - /** - * Returns the action with the given @p index. - * @param index the index of an action. You must not - * use an index that is too high. - * @return the KAccelAction with the given index - * @see count() - */ - KAccelAction* actionPtr( uint index ); - - /** - * Returns the action with the given @p index. - * @param index the index of an action. You must not - * use an index that is too high. - * @return the KAccelAction with the given index - * @see count() - */ - const KAccelAction* actionPtr( uint index ) const; - - /** - * Returns the action with the given name. - * @param sAction the name of the action to search - * @return the KAccelAction with the given name, or 0 - * if not found - */ - KAccelAction* actionPtr( const TQString& sAction ); - - /** - * Returns the action with the given name. - * @param sAction the name of the action to search - * @return the KAccelAction with the given name, or 0 - * if not found - */ - const KAccelAction* actionPtr( const TQString& sAction ) const; - - /** - * Returns the action with the given key sequence. - * @param cut the sequence to search for - * @return the KAccelAction with the given sequence, or 0 - * if not found - */ - KAccelAction* actionPtr( KKeySequence cut ); - - /** - * Returns the action with the given @p index. - * @param index the index of an action. You must not - * use an index that is too high. - * @return the KAccelAction with the given index - * @see actionPtr() - * @see count() - */ - KAccelAction& operator []( uint index ); - - /** - * Returns the action with the given @p index. - * @param index the index of an action. You must not - * use an index that is too high. - * @return the KAccelAction with the given index - * @see actionPtr() - * @see count() - */ - const KAccelAction& operator []( uint index ) const; - - /** - * Inserts an action into the collection. - * @param sAction the name of the accelerator - * @param sLabel the label of the accelerator (i18n!) - * @param sWhatsThis the What's This text (18n!) - * @param rgCutDefaults3 the default shortcut for 3 modifier systems - * @param rgCutDefaults4 the default shortcut for 4 modifier systems - * @param pObjSlot the receiver of a signal when the key has been - * pressed - * @param psMethodSlot the slot to connect for key presses. Receives - * an int, as set by setID(), as only argument - * @param bConfigurable if true the user can configure the shortcut - * @param bEnabled if true the accelerator should be enabled - * @return the new action - */ - KAccelAction* insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4, - const TQObject* pObjSlot = 0, const char* psMethodSlot = 0, - bool bConfigurable = true, bool bEnabled = true ); - - /** - * Inserts an action into the collection. - * @param sName the name of the accelerator - * @param sLabel the label of the accelerator (i18n!) - * @return the new action - */ - KAccelAction* insert( const TQString& sName, const TQString& sLabel ); - - /** - * Removes the given action. - * @param sAction the name of the action. - * @return true if successful, false otherwise - */ - bool remove( const TQString& sAction ); - - /** - * Loads the actions from the given configuration file. - * - * @param sConfigGroup the group in the configuration file - * @param pConfig the configuration file to load from - * @return true if successful, false otherwise - */ - bool readActions( const TQString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0 ); - - /** - * Writes the actions to the given configuration file. - * - * @param sConfigGroup the group in the configuration file - * @param pConfig the configuration file to save to - * @param bWriteAll true to write all actions - * @param bGlobal true to write to the global configuration file - * @return true if successful, false otherwise - */ - bool writeActions( const TQString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0, - bool bWriteAll = false, bool bGlobal = false ) const; - - /** - * Emit a keycodeChanged signal. - */ - void emitKeycodeChanged(); - - /** - * Returns the number of actions in the collection. - * @return the number of actions - */ - uint count() const; - - protected: - /** Base object that proxies signals from us. */ - KAccelBase* m_pKAccelBase; - /** Array of actions we're hanging on to. */ - KAccelAction** m_prgActions; - uint m_nSizeAllocated /**< Allocated size of the array. */, - m_nSize /**< Amount in use. */ ; - - /** - * Resize the list to the given number @p new_size of entries. - * @todo Can you make it smaller? - * @todo Implementation seems to break m_nSize. - */ - void resize( uint new_size ); - /** Add a action to this collection. @todo Document ownership. */ - void insertPtr( KAccelAction* ); - - private: - class KAccelActionsPrivate* d; - - KAccelActions( KAccelBase* ); - void initPrivate( KAccelBase* ); - KAccelActions& operator =( KAccelActions& ); - - friend class KAccelBase; -}; - -#endif // _KACCELACTION_H diff --git a/kdecore/kaccelbase.cpp b/kdecore/kaccelbase.cpp deleted file mode 100644 index 4ba4c9c3b..000000000 --- a/kdecore/kaccelbase.cpp +++ /dev/null @@ -1,616 +0,0 @@ -/* - Copyright (C) 1997-2000 Nicolas Hadacek - Copyright (C) 1998 Mark Donohoe - Copyright (C) 1998 Matthias Ettrich - Copyright (c) 2001,2002 Ellis Whitehead - - 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. -*/ - -#include "kaccelbase.h" - -#include -#include -#include - -#include -#include "kckey.h" -#include -#include -#include -#include "kkeyserver.h" -#include -#include "kshortcutmenu.h" - -//--------------------------------------------------------------------- -// class KAccelBase::ActionInfo -//--------------------------------------------------------------------- - -//--------------------------------------------------------------------- -// class KAccelBase -//--------------------------------------------------------------------- - -KAccelBase::KAccelBase( int fInitCode ) -: m_rgActions( this ) -{ - kdDebug(125) << "KAccelBase(): this = " << this << endl; - m_bNativeKeys = fInitCode & NATIVE_KEYS; - m_bEnabled = true; - m_sConfigGroup = "Shortcuts"; - m_bConfigIsGlobal = false; - m_bAutoUpdate = false; - mtemp_pActionRemoving = 0; -} - -KAccelBase::~KAccelBase() -{ - kdDebug(125) << "~KAccelBase(): this = " << this << endl; -} - -uint KAccelBase::actionCount() const { return m_rgActions.count(); } -KAccelActions& KAccelBase::actions() { return m_rgActions; } -bool KAccelBase::isEnabled() const { return m_bEnabled; } -// see KGlobalAccel::blockShortcuts() stuff - it's to temporarily block -// all global shortcuts, so that the key grabs are released, but from the app's -// point of view the KGlobalAccel is still enabled, so KGlobalAccel needs -// to disable key grabbing even if enabled -bool KAccelBase::isEnabledInternal() const { return isEnabled(); } - -KAccelAction* KAccelBase::actionPtr( const TQString& sAction ) - { return m_rgActions.actionPtr( sAction ); } - -const KAccelAction* KAccelBase::actionPtr( const TQString& sAction ) const - { return m_rgActions.actionPtr( sAction ); } - -KAccelAction* KAccelBase::actionPtr( const KKeyServer::Key& key ) -{ - if( !m_mapKeyToAction.contains( key ) ) - return 0; - // Note: If more than one action is connected to a single key, nil will be returned. - return m_mapKeyToAction[key].pAction; -} - -KAccelAction* KAccelBase::actionPtr( const KKey& key ) -{ - KKeyServer::Key k2; - k2.init( key, !m_bNativeKeys ); - return actionPtr( k2 ); -} - -void KAccelBase::setConfigGroup( const TQString& sConfigGroup ) - { m_sConfigGroup = sConfigGroup; } - -void KAccelBase::setConfigGlobal( bool global ) - { m_bConfigIsGlobal = global; } - -bool KAccelBase::setActionEnabled( const TQString& sAction, bool bEnable ) -{ - KAccelAction* pAction = actionPtr( sAction ); - if( pAction ) { - if( pAction->m_bEnabled != bEnable ) { - kdDebug(125) << "KAccelBase::setActionEnabled( " << sAction << ", " << bEnable << " )" << endl; - pAction->m_bEnabled = bEnable; - if( m_bAutoUpdate ) { - // FIXME: the action may already have it's connections inserted! - if( bEnable ) - insertConnection( pAction ); - else if( pAction->isConnected() ) - removeConnection( pAction ); - } - } - return true; - } - return false; -} - -bool KAccelBase::setAutoUpdate( bool bAuto ) -{ - kdDebug(125) << "KAccelBase::setAutoUpdate( " << bAuto << " ): m_bAutoUpdate on entrance = " << m_bAutoUpdate << endl; - bool b = m_bAutoUpdate; - if( !m_bAutoUpdate && bAuto ) - updateConnections(); - m_bAutoUpdate = bAuto; - return b; -} - -KAccelAction* KAccelBase::insert( const TQString& sAction, const TQString& sDesc, const TQString& sHelp, - const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - //kdDebug(125) << "KAccelBase::insert() begin" << endl; - KAccelAction* pAction = m_rgActions.insert( - sAction, sDesc, sHelp, - rgCutDefaults3, rgCutDefaults4, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); - - if( pAction && m_bAutoUpdate ) - insertConnection( pAction ); - - //kdDebug(125) << "KAccelBase::insert() end" << endl; - return pAction; -} - -KAccelAction* KAccelBase::insert( const TQString& sName, const TQString& sDesc ) - { return m_rgActions.insert( sName, sDesc ); } - -bool KAccelBase::remove( const TQString& sAction ) -{ - return m_rgActions.remove( sAction ); -} - -void KAccelBase::slotRemoveAction( KAccelAction* pAction ) -{ - removeConnection( pAction ); -} - -bool KAccelBase::setActionSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot ) -{ - kdDebug(125) << "KAccelBase::setActionSlot( " << sAction << ", " << pObjSlot << ", " << psMethodSlot << " )\n"; - KAccelAction* pAction = m_rgActions.actionPtr( sAction ); - if( pAction ) { - // If there was a previous connection, remove it. - if( m_bAutoUpdate && pAction->isConnected() ) { - kdDebug(125) << "\tm_pObjSlot = " << pAction->m_pObjSlot << " m_psMethodSlot = " << pAction->m_psMethodSlot << endl; - removeConnection( pAction ); - } - - pAction->m_pObjSlot = pObjSlot; - pAction->m_psMethodSlot = psMethodSlot; - - // If we're setting a connection, - if( m_bAutoUpdate && pObjSlot && psMethodSlot ) - insertConnection( pAction ); - - return true; - } else - return false; -} - -/* -KAccelBase - Run Command=Meta+Enter;Alt+F2 - KAccelAction = "Run Command" - 1) KAccelKeySeries = "Meta+Enter" - 1a) Meta+Enter - 1b) Meta+Keypad_Enter - 2) KAccelKeySeries = "Alt+F2" - 1a) Alt+F2 - - Konqueror=Meta+I,I - KAccelAction = "Konqueror" - 1) KAccelKeySeries = "Meta+I,I" - 1a) Meta+I - 2a) I - - Something=Meta+Asterisk,X - KAccelAction = "Something" - 1) KAccelKeySeries = "Meta+Asterisk,X" - 1a) Meta+Shift+8 - 1b) Meta+Keypad_8 - 2a) X - -read in a config entry - split by ';' - find key sequences to disconnect - find new key sequences to connect -check for conflicts with implicit keys - disconnect conflicting implicit keys -connect new key sequences -*/ -/* -{ - For { - for( KAccelAction::iterator itAction = m_rgActions.begin(); itAction != m_rgActions.end(); ++itAction ) { - KAccelAction& action = *itAction; - for( KAccelSeries::iterator itSeries = action.m_rgSeries.begin(); itSeries != action.m_rgSeries.end(); ++itSeries ) { - KAccelSeries& series = *itSeries; - if( - } - } - } - Sort by: iVariation, iSequence, iSeries, iAction - - 1) KAccelAction = "Run Command" - 1) KAccelKeySeries = "Meta+Enter" - 1a) Meta+Enter - 1b) Meta+Keypad_Enter - 2) KAccelKeySeries = "Alt+F2" - 1a) Alt+F2 - - 2) KAccelAction = "Enter Calculation" - 1) KAccelKeySeries = "Meta+Keypad_Enter" - 1a) Meta+Keypad_Enter - - List = - Meta+Enter -> 1, 1, 1a - Meta+Keypad_Enter -> 2, 1, 1a - Alt+F2 -> 1, 2, 1a - [Meta+Keypad_Enter] -> [1, 1, 1b] - -} -*/ - -#ifdef Q_WS_X11 -struct KAccelBase::X -{ - uint iAction, iSeq, iVari; - KKeyServer::Key key; - - X() {} - X( uint _iAction, uint _iSeq, uint _iVari, const KKeyServer::Key& _key ) - { iAction = _iAction; iSeq = _iSeq; iVari = _iVari; key = _key; } - - int compare( const X& x ) - { - int n = key.compare( x.key ); - if( n != 0 ) return n; - if( iVari != x.iVari ) return iVari - x.iVari; - if( iSeq != x.iSeq ) return iSeq - x.iSeq; - return 0; - } - - bool operator <( const X& x ) { return compare( x ) < 0; } - bool operator >( const X& x ) { return compare( x ) > 0; } - bool operator <=( const X& x ) { return compare( x ) <= 0; } -}; -#endif //Q_WS_X11 - -/* -#1 Ctrl+A -#2 Ctrl+A -#3 Ctrl+B - ------ - Ctrl+A => Null - Ctrl+B => #3 - -#1 Ctrl+A -#1 Ctrl+B;Ctrl+A - ------ - Ctrl+A => #1 - Ctrl+B => #2 - -#1 Ctrl+A -#1 Ctrl+B,C -#1 Ctrl+B,D - ------ - Ctrl+A => #1 - Ctrl+B => Null - -#1 Ctrl+A -#2 Ctrl+Plus(Ctrl+KP_Add) - ------ - Ctrl+A => #1 - Ctrl+Plus => #2 - Ctrl+KP_Add => #2 - -#1 Ctrl+Plus(Ctrl+KP_Add) -#2 Ctrl+KP_Add - ------ - Ctrl+Plus => #1 - Ctrl+KP_Add => #2 - -#1 Ctrl+Plus(Ctrl+KP_Add) -#2 Ctrl+A;Ctrl+KP_Add - ------ - Ctrl+A => #2 - Ctrl+Plus => #1 - Ctrl+KP_Add => #2 -*/ - -bool KAccelBase::updateConnections() -{ -#ifdef Q_WS_X11 - kdDebug(125) << "KAccelBase::updateConnections() this = " << this << endl; - // Retrieve the list of keys to be connected, sorted by priority. - // (key, variation, seq) - TQValueVector rgKeys; - createKeyList( rgKeys ); - m_rgActionsNonUnique.clear(); - - KKeyToActionMap mapKeyToAction; - for( uint i = 0; i < rgKeys.size(); i++ ) { - X& x = rgKeys[i]; - KKeyServer::Key& key = x.key; - ActionInfo info; - bool bNonUnique = false; - - info.pAction = m_rgActions.actionPtr( x.iAction ); - info.iSeq = x.iSeq; - info.iVariation = x.iVari; - - // If this is a multi-key shortcut, - if( info.pAction->shortcut().seq(info.iSeq).count() > 1 ) - bNonUnique = true; - // If this key is requested by more than one action, - else if( i < rgKeys.size() - 1 && key == rgKeys[i+1].key ) { - // If multiple actions requesting this key - // have the same priority as the first one, - if( info.iVariation == rgKeys[i+1].iVari && info.iSeq == rgKeys[i+1].iSeq ) - bNonUnique = true; - - kdDebug(125) << "key conflict = " << key.key().toStringInternal() - << " action1 = " << info.pAction->name() - << " action2 = " << m_rgActions.actionPtr( rgKeys[i+1].iAction )->name() - << " non-unique = " << bNonUnique << endl; - - // Skip over the other records with this same key. - while( i < rgKeys.size() - 1 && key == rgKeys[i+1].key ) - i++; - } - - if( bNonUnique ) { - // Remove connection to single action if there is one - if( m_mapKeyToAction.contains( key ) ) { - KAccelAction* pAction = m_mapKeyToAction[key].pAction; - if( pAction ) { - m_mapKeyToAction.remove( key ); - disconnectKey( *pAction, key ); - pAction->decConnections(); - m_rgActionsNonUnique.append( pAction ); - } - } - // Indicate that no single action is associated with this key. - m_rgActionsNonUnique.append( info.pAction ); - info.pAction = 0; - } - - //kdDebug(125) << "mapKeyToAction[" << key.toStringInternal() << "] = " << info.pAction << endl; - mapKeyToAction[key] = info; - } - - // Disconnect keys which no longer have bindings: - for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) { - const KKeyServer::Key& key = it.key(); - KAccelAction* pAction = (*it).pAction; - // If this key is longer used or it points to a different action now, - if( !mapKeyToAction.contains( key ) || mapKeyToAction[key].pAction != pAction ) { - if( pAction ) { - disconnectKey( *pAction, key ); - pAction->decConnections(); - } else - disconnectKey( key ); - } - } - - // Connect any unconnected keys: - // In other words, connect any keys which are present in the - // new action map, but which are _not_ present in the old one. - for( KKeyToActionMap::iterator it = mapKeyToAction.begin(); it != mapKeyToAction.end(); ++it ) { - const KKeyServer::Key& key = it.key(); - KAccelAction* pAction = (*it).pAction; - if( !m_mapKeyToAction.contains( key ) || m_mapKeyToAction[key].pAction != pAction ) { - // TODO: Decide what to do if connect fails. - // Probably should remove this item from map. - if( pAction ) { - if( connectKey( *pAction, key ) ) - pAction->incConnections(); - } else - connectKey( key ); - } - } - - // Store new map. - m_mapKeyToAction = mapKeyToAction; - -#ifndef NDEBUG - for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) { - kdDebug(125) << "Key: " << it.key().key().toStringInternal() << " => '" - << (((*it).pAction) ? (*it).pAction->name() : TQString::null) << "'" << endl; - } -#endif -#endif //Q_WS_X11 - return true; -} - -#ifdef Q_WS_X11 -// Construct a list of keys to be connected, sorted highest priority first. -void KAccelBase::createKeyList( TQValueVector& rgKeys ) -{ - //kdDebug(125) << "KAccelBase::createKeyList()" << endl; - if( !isEnabledInternal()) - return; - - // create the list - // For each action - for( uint iAction = 0; iAction < m_rgActions.count(); iAction++ ) { - KAccelAction* pAction = m_rgActions.actionPtr( iAction ); - if( pAction && pAction->m_pObjSlot && pAction->m_psMethodSlot && pAction != mtemp_pActionRemoving ) { - // For each key sequence associated with action - for( uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++ ) { - const KKeySequence& seq = pAction->shortcut().seq(iSeq); - if( seq.count() > 0 ) { - KKeyServer::Variations vars; - vars.init( seq.key(0), !m_bNativeKeys ); - for( uint iVari = 0; iVari < vars.count(); iVari++ ) { - if( vars.key(iVari).code() && vars.key(iVari).sym() ) - rgKeys.push_back( X( iAction, iSeq, iVari, vars.key( iVari ) ) ); - //kdDebug(125) << "\t" << pAction->name() << ": " << vars.key(iVari).toStringInternal() << endl; - } - } - //else - // kdDebug(125) << "\t*" << pAction->name() << ":" << endl; - } - } - } - - // sort by priority: iVariation[of first key], iSequence, iAction - qHeapSort( rgKeys.begin(), rgKeys.end() ); -} -#endif //Q_WS_X11 - -bool KAccelBase::insertConnection( KAccelAction* pAction ) -{ - if( !pAction->m_pObjSlot || !pAction->m_psMethodSlot ) - return true; - - kdDebug(125) << "KAccelBase::insertConnection( " << pAction << "=\"" << pAction->m_sName << "\"; shortcut = " << pAction->shortcut().toStringInternal() << " ) this = " << this << endl; - - // For each sequence associated with the given action: - for( uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++ ) { - // Get the first key of the sequence. - KKeyServer::Variations vars; - vars.init( pAction->shortcut().seq(iSeq).key(0), !m_bNativeKeys ); - for( uint iVari = 0; iVari < vars.count(); iVari++ ) { - const KKeyServer::Key& key = vars.key( iVari ); - - //if( !key.isNull() ) { - if( key.sym() ) { - if( !m_mapKeyToAction.contains( key ) ) { - // If this is a single-key shortcut, - if( pAction->shortcut().seq(iSeq).count() == 1 ) { - m_mapKeyToAction[key] = ActionInfo( pAction, iSeq, iVari ); - if( connectKey( *pAction, key ) ) - pAction->incConnections(); - } - // Else this is a multi-key shortcut, - else { - m_mapKeyToAction[key] = ActionInfo( 0, 0, 0 ); - // Insert into non-unique list if it's not already there. - if( m_rgActionsNonUnique.findIndex( pAction ) == -1 ) - m_rgActionsNonUnique.append( pAction ); - if( connectKey( key ) ) - pAction->incConnections(); - } - } else { - // There is a key conflict. A full update - // check is necessary. - // TODO: make this more efficient where possible. - if( m_mapKeyToAction[key].pAction != pAction - && m_mapKeyToAction[key].pAction != 0 ) { - kdDebug(125) << "Key conflict with action = " << m_mapKeyToAction[key].pAction->name() - << " key = " << key.key().toStringInternal() << " : call updateConnections()" << endl; - return updateConnections(); - } - } - } - } - } - - //kdDebug(125) << "\tActions = " << m_rgActions.size() << endl; - //for( KAccelActions::const_iterator it = m_rgActions.begin(); it != m_rgActions.end(); ++it ) { - // kdDebug(125) << "\t" << &(*it) << " '" << (*it).m_sName << "'" << endl; - //} - - //kdDebug(125) << "\tKeys = " << m_mapKeyToAction.size() << endl; - //for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) { - // //kdDebug(125) << "\tKey: " << it.key().toString() << " => '" << (*it)->m_sName << "'" << endl; - // kdDebug(125) << "\tKey: " << it.key().toString() << " => '" << *it << "'" << endl; - // kdDebug(125) << "\t\t'" << (*it)->m_sName << "'" << endl; - //} - - return true; -} - -bool KAccelBase::removeConnection( KAccelAction* pAction ) -{ - kdDebug(125) << "KAccelBase::removeConnection( " << pAction << " = \"" << pAction->m_sName << "\"; shortcut = " << pAction->m_cut.toStringInternal() << " ): this = " << this << endl; - - //for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) - // kdDebug(125) << "\tKey: " << it.key().toString() << " => '" << (*it)->m_sName << "'" << " " << *it << endl; - - if( m_rgActionsNonUnique.findIndex( pAction ) >= 0 ) { - mtemp_pActionRemoving = pAction; - bool b = updateConnections(); - mtemp_pActionRemoving = 0; - return b; - } - - KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); - while( it != m_mapKeyToAction.end() ) { - KKeyServer::Key key = it.key(); - ActionInfo* pInfo = &(*it); - - // If the given action is connected to this key, - if( pAction == pInfo->pAction ) { - disconnectKey( *pAction, key ); - pAction->decConnections(); - - KKeyToActionMap::iterator itRemove = it++; - m_mapKeyToAction.remove( itRemove ); - } else - ++it; - } - return true; -} - -bool KAccelBase::setShortcut( const TQString& sAction, const KShortcut& cut ) -{ - KAccelAction* pAction = actionPtr( sAction ); - if( pAction ) { - if( m_bAutoUpdate ) - removeConnection( pAction ); - - pAction->setShortcut( cut ); - - if( m_bAutoUpdate && !pAction->shortcut().isNull() ) - insertConnection( pAction ); - return true; - } else - return false; -} - -void KAccelBase::readSettings( KConfigBase* pConfig ) -{ - m_rgActions.readActions( m_sConfigGroup, pConfig ); - if( m_bAutoUpdate ) - updateConnections(); -} - -void KAccelBase::writeSettings( KConfigBase* pConfig ) const -{ - m_rgActions.writeActions( m_sConfigGroup, pConfig, m_bConfigIsGlobal, m_bConfigIsGlobal ); -} - -TQPopupMenu* KAccelBase::createPopupMenu( TQWidget* pParent, const KKeySequence& seq ) -{ - KShortcutMenu* pMenu = new KShortcutMenu( pParent, &actions(), seq ); - - bool bActionInserted = false; - bool bInsertSeparator = false; - for( uint i = 0; i < actionCount(); i++ ) { - const KAccelAction* pAction = actions().actionPtr( i ); - - if( !pAction->isEnabled() ) - continue; - - // If an action has already been inserted into the menu - // and we have a label instead of an action here, - // then indicate that we should insert a separator before the next menu entry. - if( bActionInserted && !pAction->isConfigurable() && pAction->name().contains( ':' ) ) - bInsertSeparator = true; - - for( uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++ ) { - const KKeySequence& seqAction = pAction->shortcut().seq(iSeq); - if( seqAction.startsWith( seq ) ) { - if( bInsertSeparator ) { - pMenu->insertSeparator(); - bInsertSeparator = false; - } - - pMenu->insertAction( i, seqAction ); - - //kdDebug(125) << "sLabel = " << sLabel << ", seq = " << (TQString)seqMenu.qt() << ", i = " << i << endl; - //kdDebug(125) << "pMenu->accel(" << i << ") = " << (TQString)pMenu->accel(i) << endl; - bActionInserted = true; - break; - } - } - } - pMenu->updateShortcuts(); - return pMenu; -} diff --git a/kdecore/kaccelbase.h b/kdecore/kaccelbase.h deleted file mode 100644 index 07e3f4833..000000000 --- a/kdecore/kaccelbase.h +++ /dev/null @@ -1,282 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001 Ellis Whitehead - - 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 _KACCELBASE_H -#define _KACCELBASE_H - -#include -#include -#include -#include -#include - -#include "kaccelaction.h" -#include "kkeyserver.h" - -class TQPopupMenu; -class TQWidget; - -//---------------------------------------------------- - -/** - * @internal - * Handle keyboard accelerators. - * - * Allow an user to configure - * key bindings through application configuration files or through the - * KKeyChooser GUI. - * - * A KAccel contains a list of accelerator items. Each accelerator item - * consists of an action name and a keyboard code combined with modifiers - * (Shift, Ctrl and Alt.) - * - * For example, "Ctrl+P" could be a shortcut for printing a document. The key - * codes are listed in ckey.h. "Print" could be the action name for printing. - * The action name identifies the key binding in configuration files and the - * KKeyChooser GUI. - * - * When pressed, an accelerator key calls the slot to which it has been - * connected. Accelerator items can be connected so that a key will activate - * two different slots. - * - * A KAccel object handles key events sent to its parent widget and to all - * children of this parent widget. - * - * Key binding reconfiguration during run time can be prevented by specifying - * that an accelerator item is not configurable when it is inserted. A special - * group of non-configurable key bindings are known as the - * standard accelerators. - * - * The standard accelerators appear repeatedly in applications for - * standard document actions such as printing and saving. Convenience methods are - * available to insert and connect these accelerators which are configurable on - * a desktop-wide basis. - * - * It is possible for a user to choose to have no key associated with - * an action. - * - * The translated first argument for insertItem() is used only - * in the configuration dialog. - *\code - * KAccel *a = new KAccel( myWindow ); - * // Insert an action "Scroll Up" which is associated with the "Up" key: - * a->insertItem( i18n("Scroll Up"), "Scroll Up", "Up" ); - * // Insert an action "Scroll Down" which is not associated with any key: - * a->insertItem( i18n("Scroll Down"), "Scroll Down", 0); - * a->connectItem( "Scroll up", myWindow, TQT_SLOT( scrollUp() ) ); - * // a->insertStdItem( KStdAccel::Print ); //not necessary, since it - * // is done automatially with the - * // connect below! - * a->connectItem(KStdAccel::Print, myWindow, TQT_SLOT( printDoc() ) ); - * - * a->readSettings(); - *\endcode - * - * If a shortcut has a menu entry as well, you could insert them like - * this. The example is again the KStdAccel::Print from above. - * - * \code - * int id; - * id = popup->insertItem("&Print",this, TQT_SLOT(printDoc())); - * a->changeMenuAccel(popup, id, KStdAccel::Print ); - * \endcode - * - * If you want a somewhat "exotic" name for your standard print action, like - * id = popup->insertItem(i18n("Print &Document"),this, TQT_SLOT(printDoc())); - * it might be a good idea to insert the standard action before as - * a->insertStdItem( KStdAccel::Print, i18n("Print Document") ) - * as well, so that the user can easily find the corresponding function. - * - * This technique works for other actions as well. Your "scroll up" function - * in a menu could be done with - * - * \code - * id = popup->insertItem(i18n"Scroll &up",this, TQT_SLOT(scrollUp())); - * a->changeMenuAccel(popup, id, "Scroll Up" ); - * \endcode - * - * Please keep the order right: First insert all functions in the - * acceleratior, then call a -> readSettings() and @em then build your - * menu structure. - * - * @short Configurable key binding support. - */ - -class KDECORE_EXPORT KAccelBase -{ - public: - /** Initialization mode of the KAccelBase, used in constructor. */ - enum Init { QT_KEYS = 0x00, NATIVE_KEYS = 0x01 }; - - /** Enum for kinds of signals which may be emitted. */ - enum Signal { KEYCODE_CHANGED }; - - /** Constructor. @p fInitCode should be a bitwise OR of - * values from the Init enum. - */ - KAccelBase( int fInitCode ); - virtual ~KAccelBase(); - - /** Returns number of actions in this handler. */ - uint actionCount() const; - /** Returns a list of all the actions in this handler. */ - KAccelActions& actions(); - /** Returns whether this accelerator handler is enabled or not. */ - bool isEnabled() const; - - /** Returns a pointer to the KAccelAction named @p sAction. */ - KAccelAction* actionPtr( const TQString& sAction ); - /** Const version of the above. */ - const KAccelAction* actionPtr( const TQString& sAction ) const; - /** Returns a pointer to the KAccelAction associated with - * the key @p key. This function takes into account the - * key mapping defined in the constructor. - * - * May return 0 if no (or more than one) - * action is associated with the key. - */ - KAccelAction* actionPtr( const KKey& key ); - /** Basically the same as above, except a KKeyServer::Key - * already has a key mapping defined (either NATIVE_KEYS or not). - */ - KAccelAction* actionPtr( const KKeyServer::Key& key ); - - /** Returns the name of the configuration group these - * accelerators are stored in. The default is "Shortcuts". - */ - const TQString& configGroup() const { return m_sConfigGroup; } - /** Set the group (in the configuration file) for storing - * accelerators. - */ - void setConfigGroup( const TQString& group ); - void setConfigGlobal( bool global ); - /** Enables or disables the accelerator. - * @param bEnabled determines whether the accelerator should be enabled or - * disabled. - */ - virtual void setEnabled( bool bEnabled ) = 0; - /** Returns whether autoupdate is enabled for these accelerators. */ - bool getAutoUpdate() { return m_bAutoUpdate; } - /** Enables (or disables) autoupdate for these accelerators. - * @return the value of autoupdate before the call. - */ - bool setAutoUpdate( bool bAuto ); - -// Procedures for manipulating Actions. - //void clearActions(); - - KAccelAction* insert( const TQString& sName, const TQString& sDesc ); - KAccelAction* insert( - const TQString& sAction, const TQString& sDesc, const TQString& sHelp, - const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable = true, bool bEnabled = true ); - bool remove( const TQString& sAction ); - bool setActionSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot ); - - bool updateConnections(); - - bool setShortcut( const TQString& sAction, const KShortcut& cut ); - -// Modify individual Action sub-items - bool setActionEnabled( const TQString& sAction, bool bEnable ); - - /** - * Read all key associations from @p config, or (if @p config - * is zero) from the application's configuration file - * KGlobal::config(). - * - * The group in which the configuration is stored can be - * set with setConfigGroup(). - */ - void readSettings( KConfigBase* pConfig = 0 ); - - /** - * Write the current configurable associations to @p config, - * or (if @p config is zero) to the application's - * configuration file. - */ - void writeSettings( KConfigBase* pConfig = 0 ) const; - - TQPopupMenu* createPopupMenu( TQWidget* pParent, const KKeySequence& ); - - // Protected methods - protected: - void slotRemoveAction( KAccelAction* ); - - struct X; - - /** Constructs a list of keys to be connected, sorted highest priority first. - * @param rgKeys constructed list of keys - */ - void createKeyList( TQValueVector& rgKeys ); - bool insertConnection( KAccelAction* ); - bool removeConnection( KAccelAction* ); - - /** Emits a signal. - * @param signal signal to be emitted - */ - virtual bool emitSignal( Signal signal ) = 0; - /** Defines a key which activates the accelerator and executes the action - * @param action action to be executed when key is pressed - * @param key key which causes the action to be executed - */ - virtual bool connectKey( KAccelAction& action, const KKeyServer::Key& key ) = 0; - /** Defines a key which activates the accelerator - * @param key key which causes the action to be executed - */ - virtual bool connectKey( const KKeyServer::Key& key) = 0; - /** Removes the key from accelerator so it no longer executes the action - */ - virtual bool disconnectKey( KAccelAction&, const KKeyServer::Key& ) = 0; - /** Removes the key from accelerator - */ - virtual bool disconnectKey( const KKeyServer::Key& ) = 0; - - protected: - virtual bool isEnabledInternal() const; - struct ActionInfo - { - KAccelAction* pAction; - uint iSeq, iVariation; - //ActionInfo* pInfoNext; // nil if only one action uses this key. - - ActionInfo() { pAction = 0; iSeq = 0xffff; iVariation = 0xffff; } - ActionInfo( KAccelAction* _pAction, uint _iSeq, uint _iVariation ) - { pAction = _pAction; iSeq = _iSeq; iVariation = _iVariation; } - }; - typedef TQMap KKeyToActionMap; - - KAccelActions m_rgActions; - KKeyToActionMap m_mapKeyToAction; - TQValueList m_rgActionsNonUnique; - bool m_bNativeKeys; // Use native key codes instead of Qt codes - bool m_bEnabled; - bool m_bConfigIsGlobal; - TQString m_sConfigGroup; - bool m_bAutoUpdate; - KAccelAction* mtemp_pActionRemoving; - - private: - KAccelBase& operator =( const KAccelBase& ); - - friend class KAccelActions; -}; - -#endif // _KACCELBASE_H diff --git a/kdecore/kaccelmanager.cpp b/kdecore/kaccelmanager.cpp deleted file mode 100644 index 6e8f08e0a..000000000 --- a/kdecore/kaccelmanager.cpp +++ /dev/null @@ -1,872 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002 Matthias H�lzer-Kl�pfel - - 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. -*/ - -#include "kaccelmanager.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -#include "kaccelmanager_private.h" -#include "../tdeui/kstdaction_p.h" -#include "../kutils/kmultitabbar.h" - - -/********************************************************************* - - class Item - helper class containing widget information - - This class stores information about the widgets the need accelerators, - as well as about their relationship. - - *********************************************************************/ - - - -/********************************************************************* - - class KAcceleratorManagerPrivate - internal helper class - - This class does all the work to find accelerators for a hierarchy of - widgets. - - *********************************************************************/ - - -class KAcceleratorManagerPrivate -{ -public: - - static void manage(TQWidget *widget); - static bool programmers_mode; - static bool standardName(const TQString &str); - - static bool checkChange(const KAccelString &as) { - TQString t2 = as.accelerated(); - TQString t1 = as.originalText(); - if (t1 != t2) - { - if (as.accel() == -1) { - removed_string += "" + TQStyleSheet::escape(t1) + ""; - } else if (as.originalAccel() == -1) { - added_string += "" + TQStyleSheet::escape(t2) + ""; - } else { - changed_string += "" + TQStyleSheet::escape(t1) + ""; - changed_string += "" + TQStyleSheet::escape(t2) + ""; - } - return true; - } - return false; - } - static TQString changed_string; - static TQString added_string; - static TQString removed_string; - static TQMap ignored_widgets; - -private: - class Item; -public: - typedef TQPtrList ItemList; - -private: - static void traverseChildren(TQWidget *widget, Item *item); - - static void manageWidget(TQWidget *widget, Item *item); - static void manageMenuBar(TQMenuBar *mbar, Item *item); - static void manageTabBar(TQTabBar *bar, Item *item); - - static void calculateAccelerators(Item *item, TQString &used); - - class Item - { - public: - - Item() : m_widget(0), m_children(0), m_index(-1) {} - ~Item(); - - void addChild(Item *item); - - TQWidget *m_widget; - KAccelString m_content; - ItemList *m_children; - int m_index; - - }; -}; - - -bool KAcceleratorManagerPrivate::programmers_mode = false; -TQString KAcceleratorManagerPrivate::changed_string; -TQString KAcceleratorManagerPrivate::added_string; -TQString KAcceleratorManagerPrivate::removed_string; -static TQStringList *kaccmp_sns = 0; -static KStaticDeleter kaccmp_sns_d; -TQMap KAcceleratorManagerPrivate::ignored_widgets; - -bool KAcceleratorManagerPrivate::standardName(const TQString &str) -{ - if (!kaccmp_sns) - kaccmp_sns_d.setObject(kaccmp_sns, new TQStringList(KStdAction::internal_stdNames())); - return kaccmp_sns->contains(str); -} - -KAcceleratorManagerPrivate::Item::~Item() -{ - delete m_children; -} - - -void KAcceleratorManagerPrivate::Item::addChild(Item *item) -{ - if (!m_children) { - m_children = new ItemList; - m_children->setAutoDelete(true); - } - - m_children->append(item); -} - -void KAcceleratorManagerPrivate::manage(TQWidget *widget) -{ - if (!widget) - { - kdDebug(131) << "null pointer given to manage" << endl; - return; - } - - if (dynamic_cast(widget)) - { - // create a popup accel manager that can deal with dynamic menus - KPopupAccelManager::manage(static_cast(widget)); - return; - } - - Item *root = new Item; - - manageWidget(widget, root); - - TQString used; - calculateAccelerators(root, used); - delete root; -} - - -void KAcceleratorManagerPrivate::calculateAccelerators(Item *item, TQString &used) -{ - if (!item->m_children) - return; - - // collect the contents - KAccelStringList contents; - for (Item *it = item->m_children->first(); it != 0; - it = item->m_children->next()) - { - contents << it->m_content; - } - - // find the right accelerators - KAccelManagerAlgorithm::findAccelerators(contents, used); - - // write them back into the widgets - int cnt = -1; - for (Item *it = item->m_children->first(); it != 0; - it = item->m_children->next()) - { - cnt++; - - TQTabBar *tabBar = dynamic_cast(it->m_widget); - if (tabBar) - { - if (checkChange(contents[cnt])) - tabBar->tabAt(it->m_index)->setText(contents[cnt].accelerated()); - continue; - } - TQMenuBar *menuBar = dynamic_cast(it->m_widget); - if (menuBar) - { - if (it->m_index >= 0) - { - TQMenuItem *mitem = menuBar->findItem(menuBar->idAt(it->m_index)); - if (mitem) - { - checkChange(contents[cnt]); - mitem->setText(contents[cnt].accelerated()); - } - continue; - } - } - // we possibly reserved an accel, but we won't set it as it looks silly - if ( dynamic_cast( it->m_widget ) ) - continue; - // links look weird with ampersands - if ( dynamic_cast( it->m_widget ) && it->m_widget->inherits("KURLLabel") ) - continue; - - int tprop = it->m_widget->tqmetaObject()->findProperty("text", true); - if (tprop != -1) { - if (checkChange(contents[cnt])) - it->m_widget->setProperty("text", contents[cnt].accelerated()); - } else { - tprop = it->m_widget->tqmetaObject()->findProperty("title", true); - if (tprop != -1 && checkChange(contents[cnt])) - it->m_widget->setProperty("title", contents[cnt].accelerated()); - } - } - - // calculate the accelerators for the children - for (Item *it = item->m_children->first(); it != 0; - it = item->m_children->next()) - { - if (it->m_widget && it->m_widget->isVisibleTo( item->m_widget ) ) - calculateAccelerators(it, used); - } -} - - -void KAcceleratorManagerPrivate::traverseChildren(TQWidget *widget, Item *item) -{ - TQObjectList *childList = widget->queryList(TQWIDGET_OBJECT_NAME_STRING, 0, false, false); - for ( TQObject *it = childList->first(); it; it = childList->next() ) - { - TQWidget *w = TQT_TQWIDGET(it); - - if ( !w->isVisibleTo( widget ) || ( w->isTopLevel() && dynamic_cast(w) == NULL ) ) - continue; - - if ( KAcceleratorManagerPrivate::ignored_widgets.find( w ) != KAcceleratorManagerPrivate::ignored_widgets.end() ) - continue; - - manageWidget(w, item); - } - delete childList; -} - -void KAcceleratorManagerPrivate::manageWidget(TQWidget *w, Item *item) -{ - // first treat the special cases - - TQTabBar *tabBar = dynamic_cast(w); - if (tabBar) - { - manageTabBar(tabBar, item); - return; - } - - TQWidgetStack *wds = dynamic_cast( w ); - if ( wds ) - { - QWidgetStackAccelManager::manage( wds ); - // return; - } - - TQPopupMenu *popupMenu = dynamic_cast(w); - if (popupMenu) - { - // create a popup accel manager that can deal with dynamic menus - KPopupAccelManager::manage(popupMenu); - return; - } - - TQWidgetStack *wdst = dynamic_cast( w ); - if ( wdst ) - { - QWidgetStackAccelManager::manage( wdst ); - // return; - } - - TQMenuBar *menuBar = dynamic_cast(w); - if (menuBar) - { - manageMenuBar(menuBar, item); - return; - } - - if (dynamic_cast(w) || dynamic_cast(w) || - dynamic_cast(w) || dynamic_cast(w) || - dynamic_cast(w) || static_cast(w->qt_cast("KMultiTabBar"))) - return; - - // now treat 'ordinary' widgets - TQLabel *label = dynamic_cast(w); - if ( label ) { - if ( !label->buddy() ) - label = 0; - else { - if ( label->textFormat() == Qt::RichText || - ( label->textFormat() == Qt::AutoText && - TQStyleSheet::mightBeRichText( label->text() ) ) ) - label = 0; - } - } - - if (w->isFocusEnabled() || label || dynamic_cast(w) || dynamic_cast( w )) - { - TQString content; - TQVariant variant; - int tprop = w->tqmetaObject()->findProperty("text", true); - if (tprop != -1) { - const TQMetaProperty* p = w->tqmetaObject()->property( tprop, true ); - if ( p && p->isValid() ) - w->qt_property( tprop, 1, &variant ); - else - tprop = -1; - } - - if (tprop == -1) { - tprop = w->tqmetaObject()->findProperty("title", true); - if (tprop != -1) { - const TQMetaProperty* p = w->tqmetaObject()->property( tprop, true ); - if ( p && p->isValid() ) - w->qt_property( tprop, 1, &variant ); - } - } - - if (variant.isValid()) - content = variant.toString(); - - if (!content.isEmpty()) - { - Item *i = new Item; - i->m_widget = w; - - // put some more weight on the usual action elements - int weight = KAccelManagerAlgorithm::DEFAULT_WEIGHT; - if (dynamic_cast(w) || dynamic_cast(w) || dynamic_cast(w) || dynamic_cast(w)) - weight = KAccelManagerAlgorithm::ACTION_ELEMENT_WEIGHT; - - // don't put weight on group boxes, as usually the contents are more important - if (dynamic_cast(w)) - weight = KAccelManagerAlgorithm::GROUP_BOX_WEIGHT; - - // put a lot of extra weight on the KDialogBaseButton's - if (w->inherits("KDialogBaseButton")) - weight += KAccelManagerAlgorithm::DIALOG_BUTTON_EXTRA_WEIGHT; - - i->m_content = KAccelString(content, weight); - item->addChild(i); - } - } - traverseChildren(w, item); -} - -void KAcceleratorManagerPrivate::manageTabBar(TQTabBar *bar, Item *item) -{ - for (int i=0; icount(); i++) - { - TQString content = bar->tabAt(i)->text(); - if (content.isEmpty()) - continue; - - Item *it = new Item; - item->addChild(it); - it->m_widget = bar; - it->m_index = i; - it->m_content = KAccelString(content); - } -} - -void KAcceleratorManagerPrivate::manageMenuBar(TQMenuBar *mbar, Item *item) -{ - TQMenuItem *mitem; - TQString s; - - for (uint i=0; icount(); ++i) - { - mitem = mbar->findItem(mbar->idAt(i)); - if (!mitem) - continue; - - // nothing to do for separators - if (mitem->isSeparator()) - continue; - - s = mitem->text(); - if (!s.isEmpty()) - { - Item *it = new Item; - item->addChild(it); - it->m_content = - KAccelString(s, - // menu titles are important, so raise the weight - KAccelManagerAlgorithm::MENU_TITLE_WEIGHT); - - it->m_widget = mbar; - it->m_index = i; - } - - // have a look at the popup as well, if present - if (mitem->popup()) - KPopupAccelManager::manage(mitem->popup()); - } -} - - -/********************************************************************* - - class KAcceleratorManager - main entry point - - This class is just here to provide a clean public API... - - *********************************************************************/ - -void KAcceleratorManager::manage(TQWidget *widget) -{ - KAcceleratorManager::manage(widget, false); -} - -void KAcceleratorManager::manage(TQWidget *widget, bool programmers_mode) -{ - kdDebug(131) << "KAcceleratorManager::manage\n"; - KAcceleratorManagerPrivate::changed_string = TQString::null; - KAcceleratorManagerPrivate::added_string = TQString::null; - KAcceleratorManagerPrivate::removed_string = TQString::null; - KAcceleratorManagerPrivate::programmers_mode = programmers_mode; - KAcceleratorManagerPrivate::manage(widget); -} - -void KAcceleratorManager::last_manage(TQString &added, TQString &changed, TQString &removed) -{ - added = KAcceleratorManagerPrivate::added_string; - changed = KAcceleratorManagerPrivate::changed_string; - removed = KAcceleratorManagerPrivate::removed_string; -} - - -/********************************************************************* - - class KAccelString - a string with weighted characters - - *********************************************************************/ - -KAccelString::KAccelString(const TQString &input, int initialWeight) - : m_pureText(input), m_weight() -{ - m_orig_accel = m_pureText.find("(!)&"); - if (m_orig_accel != -1) - m_pureText.remove(m_orig_accel, 4); - - m_orig_accel = m_pureText.find("(&&)"); - if (m_orig_accel != -1) - m_pureText.replace(m_orig_accel, 4, "&"); - - m_origText = m_pureText; - - if (m_pureText.contains('\t')) - m_pureText = m_pureText.left(m_pureText.find('\t')); - - m_orig_accel = m_accel = stripAccelerator(m_pureText); - - if (initialWeight == -1) - initialWeight = KAccelManagerAlgorithm::DEFAULT_WEIGHT; - - calculateWeights(initialWeight); - - // dump(); -} - - -TQString KAccelString::accelerated() const -{ - TQString result = m_origText; - if (result.isEmpty()) - return result; - - if (KAcceleratorManagerPrivate::programmers_mode) - { - if (m_accel != m_orig_accel) { - int oa = m_orig_accel; - - if (m_accel >= 0) { - result.insert(m_accel, "(!)&"); - if (m_accel < m_orig_accel) - oa += 4; - } - if (m_orig_accel >= 0) - result.replace(oa, 1, "(&&)"); - } - } else { - if (m_accel >= 0 && m_orig_accel != m_accel) { - result.remove(m_orig_accel, 1); - result.insert(m_accel, "&"); - } - } - return result; -} - - -TQChar KAccelString::accelerator() const -{ - if ((m_accel < 0) || (m_accel > (int)m_pureText.length())) - return TQChar(); - - return m_pureText[m_accel].lower(); -} - - -void KAccelString::calculateWeights(int initialWeight) -{ - m_weight.resize(m_pureText.length()); - - uint pos = 0; - bool start_character = true; - - while (pos= 0) - { - p = text.find('&', p)+1; - - if (p <= 0 || p >= (int)text.length()) - return -1; - - if (text[p] != '&') - { - TQChar c = text[p]; - if (c.isPrint()) - { - text.remove(p-1,1); - return p-1; - } - } - - p++; - } - - return -1; -} - - -int KAccelString::maxWeight(int &index, const TQString &used) -{ - int max = 0; - index = -1; - - for (uint pos=0; pos max) - { - max = m_weight[pos]; - index = pos; - } - - return max; -} - - -void KAccelString::dump() -{ - TQString s; - for (uint i=0; imax) - { - max = m; - index = i; - accel = a; - } - } - - // stop if no more accelerators can be found - if (index < 0) - return; - - // insert the accelerator - if (accel >= 0) - { - result[index].setAccel(accel); - used.append(result[index].accelerator()); - } - - // make sure we don't visit this one again - accel_strings[index] = KAccelString(); - } -} - - -/********************************************************************* - - class KPopupAccelManager - managing TQPopupMenu widgets dynamically - - *********************************************************************/ - -KPopupAccelManager::KPopupAccelManager(TQPopupMenu *popup) - : TQObject(popup), m_popup(popup), m_count(-1) -{ - aboutToShow(); // do one check and then connect to show - connect(popup, TQT_SIGNAL(aboutToShow()), TQT_SLOT(aboutToShow())); -} - - -void KPopupAccelManager::aboutToShow() -{ - // Note: we try to be smart and avoid recalculating the accelerators - // whenever possible. Unfortunately, there is no way to know if an - // item has been added or removed, so we can not do much more than - // to compare the items each time the menu is shown :-( - - if (m_count != (int)m_popup->count()) - { - findMenuEntries(m_entries); - calculateAccelerators(); - m_count = m_popup->count(); - } - else - { - KAccelStringList entries; - findMenuEntries(entries); - if (entries != m_entries) - { - m_entries = entries; - calculateAccelerators(); - } - } -} - - -void KPopupAccelManager::calculateAccelerators() -{ - // find the new accelerators - TQString used; - KAccelManagerAlgorithm::findAccelerators(m_entries, used); - - // change the menu entries - setMenuEntries(m_entries); -} - - -void KPopupAccelManager::findMenuEntries(KAccelStringList &list) -{ - TQMenuItem *mitem; - TQString s; - - list.clear(); - - // read out the menu entries - for (uint i=0; icount(); i++) - { - mitem = m_popup->findItem(m_popup->idAt(i)); - if (mitem->isSeparator()) - continue; - - s = mitem->text(); - - // in full menus, look at entries with global accelerators last - int weight = 50; - if (s.contains('\t')) - weight = 0; - - list.append(KAccelString(s, weight)); - - // have a look at the popup as well, if present - if (mitem->popup()) - KPopupAccelManager::manage(mitem->popup()); - } -} - - -void KPopupAccelManager::setMenuEntries(const KAccelStringList &list) -{ - TQMenuItem *mitem; - - uint cnt = 0; - for (uint i=0; icount(); i++) - { - mitem = m_popup->findItem(m_popup->idAt(i)); - if (mitem->isSeparator()) - continue; - - if (KAcceleratorManagerPrivate::checkChange(list[cnt])) - mitem->setText(list[cnt].accelerated()); - cnt++; - } -} - - -void KPopupAccelManager::manage(TQPopupMenu *popup) -{ - // don't add more than one manager to a popup - if (popup->child(0, "KPopupAccelManager", false) == 0 ) - new KPopupAccelManager(popup); -} - -void QWidgetStackAccelManager::manage( TQWidgetStack *stack ) -{ - if ( stack->child( 0, "QWidgetStackAccelManager", false ) == 0 ) - new QWidgetStackAccelManager( stack ); -} - -QWidgetStackAccelManager::QWidgetStackAccelManager(TQWidgetStack *stack) - : TQObject(stack), m_stack(stack) -{ - aboutToShow(stack->visibleWidget()); // do one check and then connect to show - connect(stack, TQT_SIGNAL(aboutToShow(TQWidget *)), TQT_SLOT(aboutToShow(TQWidget *))); -} - -bool QWidgetStackAccelManager::eventFilter ( TQObject * watched, TQEvent * e ) -{ - if ( e->type() == TQEvent::Show && tqApp->activeWindow() ) { - KAcceleratorManager::manage( TQT_TQWIDGET(tqApp->activeWindow()) ); - watched->removeEventFilter( this ); - } - return false; -} - -void QWidgetStackAccelManager::aboutToShow(TQWidget *child) -{ - if (!child) - { - kdDebug(131) << "null pointer given to aboutToShow" << endl; - return; - } - - child->installEventFilter( this ); -} - -void KAcceleratorManager::setNoAccel( TQWidget *widget ) -{ - KAcceleratorManagerPrivate::ignored_widgets[widget] = 1; -} - -#include "kaccelmanager_private.moc" diff --git a/kdecore/kaccelmanager.h b/kdecore/kaccelmanager.h deleted file mode 100644 index 21655fd9c..000000000 --- a/kdecore/kaccelmanager.h +++ /dev/null @@ -1,88 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002 Matthias Hoelzer-Kluepfel - - 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 __K_ACCELMANAGER_H__ -#define __K_ACCELMANAGER_H__ - - -class TQWidget; -class TQString; - -#include - -/** - * KDE Accelerator manager. - * - * This class can be used to find a valid and working set of - * accelerators for any widget. - * - * @author Matthias Hoelzer-Kluepfel - * @since 3.1 -*/ - -class KDECORE_EXPORT KAcceleratorManager -{ -public: - - /** - * Manages the accelerators of a widget. - * - * Call this function on the top widget of the hierarchy you - * want to manage. It will fix the accelerators of the child widgets so - * there are never duplicate accelerators. It also tries to put - * accelerators on as many widgets as possible. - * - * The algorithm used tries to take the existing accelerators into - * account, as well as the class of each widget. Hopefully, the result - * is close to what you would assign manually. - * - * QPopupMenu's are managed dynamically, so when you add or remove entries, - * the accelerators are reassigned. If you add or remove widgets to your - * toplevel widget, you will have to call manage again to fix the - * accelerators. - * - * @param widget The toplevel widget you want to manage. - */ - - static void manage(TQWidget *widget); - - /** - * Does the same as the above function, but puts hints in the GUI so the - * programmer can enhance his program. - * - * TODO KDE4: merge with the above - * @param widget The toplevel widget you want to manage. - * @param programmers_mode if true, KAcceleratorManager adds (&) for removed - * accels and & before added accels - */ - static void manage(TQWidget *widget, bool programmers_mode); - - /** \internal returns the result of the last manage operation. */ - static void last_manage(TQString &added, TQString &changed, TQString &removed); - - /** - * Use this method for a widget (and its children) you want no accels to be set on. - * @since 3.4 - */ - static void setNoAccel( TQWidget *widget ); -}; - - -#endif diff --git a/kdecore/kaccelmanager_private.h b/kdecore/kaccelmanager_private.h deleted file mode 100644 index e931b7e3e..000000000 --- a/kdecore/kaccelmanager_private.h +++ /dev/null @@ -1,196 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2002 Matthias Hoelzer-Kluepfel - - 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 __KACCELMANAGER_PRIVATE_H__ -#define __KACCELMANAGER_PRIVATE_H__ - - -#include -#include -#include -#include - -class TQWidgetStack; - -/** - * A string class handling accelerators. - * - * This class contains a string and knowledge about accelerators. - * It keeps a list weights, telling how valuable each character - * would be as an accelerator. - * - * @author Matthias Hoelzer-Kluepfel -*/ - -class KAccelString -{ -public: - - KAccelString() : m_pureText(), m_accel(-1) {} - KAccelString(const TQString &input, int initalWeight=-1); - - void calculateWeights(int initialWeight); - - const TQString &pure() const { return m_pureText; } - TQString accelerated() const; - - int accel() const { return m_accel; } - void setAccel(int accel) { m_accel = accel; } - - int originalAccel() const { return m_orig_accel; } - TQString originalText() const { return m_origText; } - - TQChar accelerator() const; - - int maxWeight(int &index, const TQString &used); - - bool operator == (const KAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; } - - -private: - - int stripAccelerator(TQString &input); - - void dump(); - - TQString m_pureText, m_origText; - int m_accel, m_orig_accel; - TQMemArray m_weight; - -}; - - -typedef TQValueList KAccelStringList; - - -/** - * This class encapsulates the algorithm finding the 'best' - * distribution of accelerators in a hierarchy of widgets. - * - * @author Matthias Hoelzer-Kluepfel -*/ - -class KAccelManagerAlgorithm -{ -public: - - /// Constants used in the algorithm - enum { - /// Default control weight - DEFAULT_WEIGHT = 50, - /// Additional weight for first character in string - FIRST_CHARACTER_EXTRA_WEIGHT = 50, - /// Additional weight for the beginning of a word - WORD_BEGINNING_EXTRA_WEIGHT = 50, - /// Additional weight for the dialog buttons (large, we basically never want these reassigned) - DIALOG_BUTTON_EXTRA_WEIGHT = 300, - /// Additional weight for a 'wanted' accelerator - WANTED_ACCEL_EXTRA_WEIGHT = 150, - /// Default weight for an 'action' widget (ie, pushbuttons) - ACTION_ELEMENT_WEIGHT = 50, - /// Default weight for group boxes (low priority) - GROUP_BOX_WEIGHT = -2000, - /// Default weight for menu titles - MENU_TITLE_WEIGHT = 250, - /// Additional weight for KDE standard accelerators - STANDARD_ACCEL = 300 - }; - - /// Method to call to find the best distribution of accelerators. - static void findAccelerators(KAccelStringList &result, TQString &used); - -}; - - -class TQPopupMenu; - - -/** - * This class manages a popup menu. It will notice if entries have been - * added or changed, and will recalculate the accelerators accordingly. - * - * This is necessary for dynamic menus like for example in kicker. - * - * @author Matthias Hoelzer-Kluepfel -*/ - -class KPopupAccelManager : public TQObject -{ - Q_OBJECT - -public: - - static void manage(TQPopupMenu *popup); - - -protected: - - KPopupAccelManager(TQPopupMenu *popup); - - -private slots: - - void aboutToShow(); - - -private: - - void calculateAccelerators(); - - void findMenuEntries(KAccelStringList &list); - void setMenuEntries(const KAccelStringList &list); - - TQPopupMenu *m_popup; - KAccelStringList m_entries; - int m_count; - -}; - - -class QWidgetStackAccelManager : public TQObject -{ - Q_OBJECT - -public: - - static void manage(TQWidgetStack *popup); - - -protected: - - QWidgetStackAccelManager(TQWidgetStack *popup); - - -private slots: - - void aboutToShow(TQWidget *); - bool eventFilter ( TQObject * watched, TQEvent * e ); - -private: - - void calculateAccelerators(); - - TQWidgetStack *m_stack; - KAccelStringList m_entries; - -}; - - -#endif diff --git a/kdecore/kaccelprivate.h b/kdecore/kaccelprivate.h deleted file mode 100644 index 0a6cdc19b..000000000 --- a/kdecore/kaccelprivate.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __KACCELPRIVATE_H -#define __KACCELPRIVATE_H - -#include "kkeyserver_x11.h" -#include - -class KAccelAction; - -/** - * @internal - */ -class KDECORE_EXPORT KAccelPrivate : public TQObject, public KAccelBase -{ - Q_OBJECT - public: - KAccel* m_pAccel; - TQWidget* m_pWatch; - TQMap m_mapIDToKey; - TQMap m_mapIDToAction; - TQTimer m_timerShowMenu; - - KAccelPrivate( KAccel* pParent, TQWidget* pWatch ); - - virtual void setEnabled( bool bEnabled ); - - bool setEnabled( const TQString& sAction, bool bEnable ); - - virtual bool removeAction( const TQString& sAction ); - - virtual bool emitSignal( KAccelBase::Signal signal ); - virtual bool connectKey( KAccelAction& action, const KKeyServer::Key& key ); - virtual bool connectKey( const KKeyServer::Key& key ); - virtual bool disconnectKey( KAccelAction& action, const KKeyServer::Key& key ); - virtual bool disconnectKey( const KKeyServer::Key& key ); - - signals: - void menuItemActivated(); - void menuItemActivated(KAccelAction*); - - private: -#ifndef Q_WS_WIN /** @todo TEMP: new implementation (commit #424926) didn't work */ - void emitActivatedSignal(KAccelAction*); -#endif - - private slots: - void slotKeyPressed( int id ); - void slotShowMenu(); - void slotMenuActivated( int iAction ); - - bool eventFilter( TQObject* pWatched, TQEvent* pEvent ); // virtual method from QObject -}; - -#endif // !__KACCELPRIVATE_H diff --git a/kdecore/kallocator.cpp b/kdecore/kallocator.cpp deleted file mode 100644 index 16c1b3625..000000000 --- a/kdecore/kallocator.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (C) 1999 Waldo Bastian (bastian@kde.org) - Copyright (C) 2002 Michael Matz (matz@kde.org) - - 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. -*/ - -/* Fast zone memory allocator with deallocation support, for use as obstack - or as general purpose allocator. It does no compaction. If the usage - pattern is non-optimal it might waste some memory while running. E.g. - allocating many small things at once, and then deallocating only every - second one, there is a high chance, that actually no memory is freed. */ -// $Id$ - -#include "kallocator.h" -#include - -class KZoneAllocator::MemBlock -{ - public: - MemBlock(size_t s) : size(s), ref(0), older(0), newer(0) - { begin = new char[s]; } - ~MemBlock() { delete [] begin; } - bool is_in(void *ptr) const {return !(begin > (char *)ptr - || (begin + size) <= (char *)ptr); } - size_t size; - unsigned int ref; - char *begin; - MemBlock *older; - MemBlock *newer; -}; - -KZoneAllocator::KZoneAllocator(unsigned long _blockSize) -: currentBlock(0), blockSize(1), blockOffset(0), log2(0), num_blocks(0), - hashList(0), hashSize(0), hashDirty(true) -{ - while (blockSize < _blockSize) - blockSize <<= 1, log2++; - /* Make sure, that a block is allocated at the first time allocate() - is called (even with a 0 size). */ - blockOffset = blockSize + 1; -} - -KZoneAllocator::~KZoneAllocator() -{ - unsigned int count = 0; - if (hashList) { - /* No need to maintain the different lists in hashList[] anymore. - I.e. no need to use delBlock(). */ - for (unsigned int i = 0; i < hashSize; i++) - delete hashList[i]; - delete [] hashList; - hashList = 0; - } - MemBlock *next; - for (; currentBlock; currentBlock = next) { - next = currentBlock->older; - delete currentBlock; - count++; - } -#ifndef NDEBUG // as this is called quite late in the app, we don't care - // to use kdDebug - if (count > 1) - qDebug("zone still contained %d blocks", count); -#endif -} - -void KZoneAllocator::insertHash(MemBlock *b) -{ - unsigned long adr = ((unsigned long)b->begin) & (~(blockSize - 1)); - unsigned long end = ((unsigned long)b->begin) + blockSize; - while (adr < end) { - unsigned long key = adr >> log2; - key = key & (hashSize - 1); - if (!hashList[key]) - hashList[key] = new TQValueList; - hashList[key]->append(b); - adr += blockSize; - } -} - -/** Add a new memory block to the pool of blocks, - and reorganize the hash lists if needed. - @param b block to add - @internal -*/ -void KZoneAllocator::addBlock(MemBlock *b) -{ - b->newer = 0; - b->older = currentBlock; - if (currentBlock) - b->older->newer = b; - currentBlock = b; - num_blocks++; - /* If we either have no hashList at all, or since it's last construction - there are now many more blocks we reconstruct the list. But don't - make it larger than a certain maximum. */ - if (hashList && ((num_blocks / 4) > hashSize && hashSize < 64*1024)) - hashDirty = true; - /* Only insert this block into the hashlists, if we aren't going to - reconstruct them anyway. */ - if (hashList && !hashDirty) - insertHash (b); -} - -/** Reinitialize hash list. @internal */ -void KZoneAllocator::initHash() -{ - if (hashList) { - for (unsigned int i = 0; i < hashSize; i++) - delete hashList[i]; - delete [] hashList; - hashList = 0; - } - hashSize = 1; - while (hashSize < num_blocks) - hashSize <<= 1; - if (hashSize < 1024) - hashSize = 1024; - if (hashSize > 64*1024) - hashSize = 64*1024; - hashList = new TQValueList *[hashSize]; - memset (hashList, 0, sizeof(TQValueList *) * hashSize); - hashDirty = false; - for (MemBlock *b = currentBlock; b; b = b->older) - insertHash(b); -} - -/** Delete a memory block. This @em really returns the memory to the heap. - @param b block to delete - @internal -*/ -void KZoneAllocator::delBlock(MemBlock *b) -{ - /* Update also the hashlists if we aren't going to reconstruct them - soon. */ - if (hashList && !hashDirty) { - unsigned long adr = ((unsigned long)b->begin) & (~(blockSize - 1)); - unsigned long end = ((unsigned long)b->begin) + blockSize; - while (adr < end) { - unsigned long key = adr >> log2; - key = key & (hashSize - 1); - if (hashList[key]) { - TQValueList *list = hashList[key]; - TQValueList::Iterator it = list->begin(); - TQValueList::Iterator endit = list->end(); - for (; it != endit; ++it) - if (*it == b) { - list->remove(it); - break; - } - } - adr += blockSize; - } - } - if (b->older) - b->older->newer = b->newer; - if (b->newer) - b->newer->older = b->older; - if (b == currentBlock) { - currentBlock = 0; - blockOffset = blockSize; - } - delete b; - num_blocks--; -} - -void * -KZoneAllocator::allocate(size_t _size) -{ - // Use the size of (void *) as tqalignment - const size_t tqalignment = sizeof(void *) - 1; - _size = (_size + tqalignment) & ~tqalignment; - - if ((unsigned long) _size + blockOffset > blockSize) - { - if (_size > blockSize) { - qDebug("KZoneAllocator: allocating more than %lu bytes", blockSize); - return 0; - } - addBlock(new MemBlock(blockSize)); - blockOffset = 0; - //qDebug ("Allocating block #%d (%x)\n", num_blocks, currentBlock->begin); - } - void *result = (void *)(currentBlock->begin+blockOffset); - currentBlock->ref++; - blockOffset += _size; - return result; -} - -void -KZoneAllocator::deallocate(void *ptr) -{ - if (hashDirty) - initHash(); - - unsigned long key = (((unsigned long)ptr) >> log2) & (hashSize - 1); - TQValueList *list = hashList[key]; - if (!list) { - /* Can happen with certain usage pattern of intermixed free_since() - and deallocate(). */ - //qDebug("Uhoh"); - return; - } - TQValueList::ConstIterator it = list->begin(); - TQValueList::ConstIterator endit = list->end(); - for (; it != endit; ++it) { - MemBlock *cur = *it; - if (cur->is_in(ptr)) { - if (!--cur->ref) { - if (cur != currentBlock) - delBlock (cur); - else - blockOffset = 0; - } - return; - } - } - /* Can happen with certain usage pattern of intermixed free_since() - and deallocate(). */ - //qDebug("Uhoh2"); -} - -void -KZoneAllocator::free_since(void *ptr) -{ - /* If we have a hashList and it's not yet dirty, see, if we will dirty - it by removing too many blocks. This will make the below delBlock()s - faster. */ - if (hashList && !hashDirty) - { - const MemBlock *b; - unsigned int removed = 0; - for (b = currentBlock; b; b = b->older, removed++) - if (b->is_in (ptr)) - break; - if (hashSize >= 4 * (num_blocks - removed)) - hashDirty = true; - } - while (currentBlock && !currentBlock->is_in(ptr)) { - currentBlock = currentBlock->older; - delBlock (currentBlock->newer); - } - blockOffset = ((char*)ptr) - currentBlock->begin; -} diff --git a/kdecore/kallocator.h b/kdecore/kallocator.h deleted file mode 100644 index 2fed42c85..000000000 --- a/kdecore/kallocator.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (C) 1999 Waldo Bastian (bastian@kde.org) - Copyright (C) 2002 Michael Matz (matz@kde.org) - - 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. -*/ -//---------------------------------------------------------------------------- -// -// KDE Memory Allocator - -#ifndef KALLOCATOR_H -#define KALLOCATOR_H - -#include -#include "kdelibs_export.h" - -class KZoneAllocatorPrivate; - - -/** - * Memory allocator for large groups of small objects. - * This should be used for large groups of objects that are created and - * destroyed together. When used carefully for this purpose it is faster - * and more memory efficient than malloc. Additionally to a usual obstack - * like allocator you can also free the objects individually. Because it - * does no compaction it still is faster then malloc()/free(). Depending - * on the exact usage pattern that might come at the expense of some - * memory though. - * @author Waldo Bastian , Michael Matz - */ -class KDECORE_EXPORT KZoneAllocator -{ -public: - /** - * Creates a KZoneAllocator object. - * @param _blockSize Size in bytes of the blocks requested from malloc. - */ - KZoneAllocator(unsigned long _blockSize = 8*1024); - - /** - * Destructs the ZoneAllocator and free all memory allocated by it. - */ - ~KZoneAllocator(); - - /** - * Allocates a memory block. - * @param _size Size in bytes of the memory block. Memory is aligned to - * the size of a pointer. - */ - void* allocate(size_t _size); - - /** - * Gives back a block returned by allocate() to the zone - * allocator, and possibly deallocates the block holding it (when it's - * empty). The first deallocate() after many allocate() calls - * (or the first at all) builds an internal data structure for speeding - * up deallocation. The consistency of that structure is maintained - * from then on (by allocate() and deallocate()) unless many - * more objects are allocated without any intervening deallocation, in - * which case it's thrown away and rebuilt at the next deallocate(). - * - * The effect of this is, that such initial deallocate() calls take - * more time then the normal calls, and that after this list is built, i.e. - * generally if deallocate() is used at all, also allocate() is a - * little bit slower. This means, that if you want to squeeze out the last - * bit performance you would want to use KZoneAllocator as an obstack, i.e. - * just use the functions allocate() and free_since(). All the - * remaining memory is returned to the system if the zone allocator - * is destroyed. - * @param ptr Pointer as returned by allocate(). - */ - void deallocate(void *ptr); - - /** - * Deallocate many objects at once. - * free_since() deallocates all objects allocated after @p ptr, - * @em including @p ptr itself. - * - * The intended use is something along the lines of: - * \code - * KZoneAllocator alloc(8192); - * void *remember_me = alloc.allocate(0); - * for (int i = 0; i < 1000; i++) - * do_something_with (alloc.allocate(12)); - * alloc.free_since (remember_me); - * \endcode - * Note, that we don't need to remember all the pointers to the 12-byte - * objects for freeing them. The free_since() does deallocate them - * all at once. - * @param ptr Pointer as returned by allocate(). It acts like - * a kind of mark of a certain position in the stack of all objects, - * off which you can throw away everything above that mark. - */ - void free_since(void *ptr); - -protected: - /** A single chunk of memory from the heap. @internal */ - class MemBlock; - /**< A list of chunks. @internal */ - typedef TQValueList MemList; - void addBlock(MemBlock *b); - void delBlock(MemBlock *b); - void insertHash(MemBlock *b); - void initHash(); - /** One block is 'current' to satisfy requests. @internal */ - MemBlock *currentBlock; - /** Store block size from constructor. @internal */ - unsigned long blockSize; - /** Store offset into current block; size-offset is free. @internal */ - unsigned long blockOffset; - /** base-2 log of the block size. @internal */ - unsigned int log2; - /** Count total number of allocated blocks. @internal */ - unsigned int num_blocks; - /** Collection of lists of blocks, for lookups. @internal */ - MemList **hashList; - /** Count of hashes. @internal */ - unsigned int hashSize; - /** Flag the hashes as in need of reorganization. @internal */ - bool hashDirty; -private: - KZoneAllocatorPrivate *d; -}; - -#endif diff --git a/kdecore/kapp.h b/kdecore/kapp.h deleted file mode 100644 index c51c463a0..000000000 --- a/kdecore/kapp.h +++ /dev/null @@ -1,6 +0,0 @@ -// kapp.h is the old name. Use #include from now on -#ifdef KDE_NO_COMPAT -#error include instead of -#else -#include -#endif diff --git a/kdecore/kappdcopiface.cpp b/kdecore/kappdcopiface.cpp deleted file mode 100644 index fc0198d87..000000000 --- a/kdecore/kappdcopiface.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 Ian Reinhart Geiser - - This program is free software; you can redistribute it and/or - modify it under the terms of the Lesser GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - 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 - General Public License for more details. - - You should have received a copy of the Lesser GNU 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 "kappdcopiface.h" -#include -#include -#include -#include - - -KAppDCOPInterface::KAppDCOPInterface(KApplication * theKApp) - : DCOPObject( "MainApplication-Interface") -{ - m_KApplication = theKApp; -} - -KAppDCOPInterface::~KAppDCOPInterface() -{ -} - -void KAppDCOPInterface::disableSessionManagement() -{ - -} - -TQCString KAppDCOPInterface::startupId() -{ - return ""; -} - -TQCString KAppDCOPInterface::caption() -{ - return ""; -} - -void KAppDCOPInterface::quit() -{ - m_KApplication->quit(); -} - -void KAppDCOPInterface::updateUserTimestamp( ulong time ) -{ - m_KApplication->updateUserTimestamp( time ); -} - -void KAppDCOPInterface::reparseConfiguration() -{ - KGlobal::config()->reparseConfiguration(); -} - -void KAppDCOPInterface::sendFakeKey( unsigned int keyCode) { - m_KApplication->broadcastKeyCode(keyCode); -} - diff --git a/kdecore/kappdcopiface.h b/kdecore/kappdcopiface.h deleted file mode 100644 index 448f08d66..000000000 --- a/kdecore/kappdcopiface.h +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 Ian Reinhart Geiser - - 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, or (at your option) any later version. - - 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 - 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 KAPPDCOP_INTERFACE_H -#define KAPPDCOP_INTERFACE_H - -#include -#include -#include -#include -#include "kdelibs_export.h" - -class KApplication; - -/** -This is the main interface to the KApplication. This will provide a consistant -dcop interface to all KDE applications that use it. -@short DCOP interface to KApplication. -@author Ian Reinhart Geiser -*/ -class KDECORE_EXPORT KAppDCOPInterface : virtual public DCOPObject -{ -K_DCOP - -public: - /** - Construct a new interface object. - @param theKapp - The parent KApplication object - that will provide us with the functional interface. - */ - KAppDCOPInterface( KApplication * theKapp ); - /** - Destructor - Cleans up the dcop connection. - **/ - ~KAppDCOPInterface(); -k_dcop: - /** - Disable current applications session management - **/ - void disableSessionManagement(); - - TQCString startupId(); - TQCString caption(); - - void quit(); - - void reparseConfiguration(); - - void updateUserTimestamp( ulong time ); - /** - Send a fake keypress to all KApplication instances - For internal use in connecting insecure function keys to - KDE applications while the X keyboard is locked. - **/ - void sendFakeKey( unsigned int keyCode); - -private: - KApplication *m_KApplication; -}; - -#endif - - diff --git a/kdecore/kapplication.cpp b/kdecore/kapplication.cpp deleted file mode 100644 index 9fdcfbcb9..000000000 --- a/kdecore/kapplication.cpp +++ /dev/null @@ -1,3616 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (C) 1998, 1999, 2000 KDE Team - - 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. - */ - -#include "config.h" - -#ifdef HAVE_XCOMPOSITE -#define COMPOSITE -#endif - -// #ifdef QTRANSLATOR_H -// #error qtranslator.h was already included -// #endif // QTRANSLATOR_H -// -// #ifdef TQTRANSLATOR_H -// #error tqtranslator.h was already included -// #endif // TQTRANSLATOR_H - -#undef QT_NO_TRANSLATION -#undef TQT_NO_TRANSLATION -#include -#include "kapplication.h" -#define QT_NO_TRANSLATION -#define TQT_NO_TRANSLATION -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_SQL -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "kcheckaccelerators.h" -#include -#include -#include -#include -#include -#include -#include - -#if defined Q_WS_X11 -#include -#endif - -#include -#include - -#include -#ifdef HAVE_SYS_STAT_H -#include -#endif -#include -#include -#include - -#ifndef Q_WS_WIN -#include "kwin.h" -#endif - -#include -#include // getenv(), srand(), rand() -#include -#include -#include -#include -#include -#include -#include -#if defined Q_WS_X11 -//#ifndef Q_WS_QWS //FIXME(E): NetWM should talk to QWS... -#include -#endif - -#include "kprocctrl.h" - -#ifdef HAVE_PATHS_H -#include -#endif - -#ifdef Q_WS_X11 -#include -#ifdef COMPOSITE -#include -#include -#include -#endif -#include -#include -#include -#include -#endif - -#include - -#ifndef Q_WS_WIN -#include -#else -typedef void* IceIOErrorHandler; -#include -//KDE4: remove -#define Button1Mask (1<<8) -#define Button2Mask (1<<9) -#define Button3Mask (1<<10) -#endif - -#ifdef Q_WS_X11 -#define DISPLAY "DISPLAY" -#elif defined(Q_WS_QWS) -#define DISPLAY "QWS_DISPLAY" -#endif - -#if defined Q_WS_X11 -#include -#endif - -#ifdef Q_WS_MACX -#include -#include -#endif - -#include "kappdcopiface.h" - -// exported for kdm kfrontend -KDE_EXPORT bool kde_have_kipc = true; // magic hook to disable kipc in kdm -bool kde_kiosk_exception = false; // flag to disable kiosk restrictions -bool kde_kiosk_admin = false; - -KApplication* KApplication::KApp = 0L; -bool KApplication::loadedByKdeinit = false; -DCOPClient *KApplication::s_DCOPClient = 0L; -bool KApplication::s_dcopClientNeedsPostInit = false; - -#ifdef Q_WS_X11 -static Atom atom_DesktopWindow; -static Atom atom_NetSupported; -static Atom kde_xdnd_drop; -#endif - -#ifdef Q_WS_X11 -static int composite_event, composite_error, composite_opcode; -static bool x11_composite_error_generated; -static int x11_error(Display *dpy, XErrorEvent *ev) { - if (ev->request_code == composite_opcode && ev->minor_code == X_CompositeRedirectSubwindows) - { - x11_composite_error_generated = true; - return 0; - } -} -#endif - -// duplicated from patched Qt, so that there won't be unresolved symbols if Qt gets -// replaced by unpatched one -KDECORE_EXPORT bool qt_qclipboard_bailout_hack = false; - -template class TQPtrList; - -#ifdef Q_WS_X11 -extern "C" { -static int kde_xio_errhandler( Display * dpy ) -{ - return kapp->xioErrhandler( dpy ); -} - -static int kde_x_errhandler( Display *dpy, XErrorEvent *err ) -{ - return kapp->xErrhandler( dpy, err ); -} - -} - -extern "C" { -static void kde_ice_ioerrorhandler( IceConn conn ) -{ - if(kapp) - kapp->iceIOErrorHandler( conn ); - // else ignore the error for now -} -} -#endif - -#ifdef Q_WS_WIN -void KApplication_init_windows(bool GUIenabled); - -class QAssistantClient; -#endif - -/* - Private data to make keeping binary compatibility easier - */ -class KApplicationPrivate -{ -public: - KApplicationPrivate() - : actionRestrictions( false ), - refCount( 1 ), - oldIceIOErrorHandler( 0 ), - checkAccelerators( 0 ), - overrideStyle( TQString::null ), - startup_id( "0" ), - app_started_timer( NULL ), - m_KAppDCOPInterface( 0L ), - session_save( false ) -#ifdef Q_WS_X11 - ,oldXErrorHandler( NULL ) - ,oldXIOErrorHandler( NULL ) -#elif defined Q_WS_WIN - ,qassistantclient( 0 ) -#endif - { - } - - ~KApplicationPrivate() - { -#ifdef Q_WS_WIN - delete qassistantclient; -#endif - } - - - bool actionRestrictions : 1; - bool guiEnabled : 1; - /** - * This counter indicates when to exit the application. - * It starts at 1, is decremented in KMainWindow when the last window is closed, but - * is incremented by operations that should outlive the last window closed - * (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client). - */ - int refCount; - IceIOErrorHandler oldIceIOErrorHandler; - KCheckAccelerators* checkAccelerators; - TQString overrideStyle; - TQString geometry_arg; - TQCString startup_id; - TQTimer* app_started_timer; - KAppDCOPInterface *m_KAppDCOPInterface; - bool session_save; -#ifdef Q_WS_X11 - int (*oldXErrorHandler)(Display*,XErrorEvent*); - int (*oldXIOErrorHandler)(Display*); -#elif defined Q_WS_WIN - QAssistantClient* qassistantclient; -#endif - - class URLActionRule - { - public: -#define checkExactMatch(s, b) \ - if (s.isEmpty()) b = true; \ - else if (s[s.length()-1] == '!') \ - { b = false; s.truncate(s.length()-1); } \ - else b = true; -#define checkStartWildCard(s, b) \ - if (s.isEmpty()) b = true; \ - else if (s[0] == '*') \ - { b = true; s = s.mid(1); } \ - else b = false; -#define checkEqual(s, b) \ - b = (s == "="); - - URLActionRule(const TQString &act, - const TQString &bProt, const TQString &bHost, const TQString &bPath, - const TQString &dProt, const TQString &dHost, const TQString &dPath, - bool perm) - : action(act), - baseProt(bProt), baseHost(bHost), basePath(bPath), - destProt(dProt), destHost(dHost), destPath(dPath), - permission(perm) - { - checkExactMatch(baseProt, baseProtWildCard); - checkStartWildCard(baseHost, baseHostWildCard); - checkExactMatch(basePath, basePathWildCard); - checkExactMatch(destProt, destProtWildCard); - checkStartWildCard(destHost, destHostWildCard); - checkExactMatch(destPath, destPathWildCard); - checkEqual(destProt, destProtEqual); - checkEqual(destHost, destHostEqual); - } - - bool baseMatch(const KURL &url, const TQString &protClass) - { - if (baseProtWildCard) - { - if ( !baseProt.isEmpty() && !url.protocol().startsWith(baseProt) && - (protClass.isEmpty() || (protClass != baseProt)) ) - return false; - } - else - { - if ( (url.protocol() != baseProt) && - (protClass.isEmpty() || (protClass != baseProt)) ) - return false; - } - if (baseHostWildCard) - { - if (!baseHost.isEmpty() && !url.host().endsWith(baseHost)) - return false; - } - else - { - if (url.host() != baseHost) - return false; - } - if (basePathWildCard) - { - if (!basePath.isEmpty() && !url.path().startsWith(basePath)) - return false; - } - else - { - if (url.path() != basePath) - return false; - } - return true; - } - - bool destMatch(const KURL &url, const TQString &protClass, const KURL &base, const TQString &baseClass) - { - if (destProtEqual) - { - if ( (url.protocol() != base.protocol()) && - (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass) ) - return false; - } - else if (destProtWildCard) - { - if ( !destProt.isEmpty() && !url.protocol().startsWith(destProt) && - (protClass.isEmpty() || (protClass != destProt)) ) - return false; - } - else - { - if ( (url.protocol() != destProt) && - (protClass.isEmpty() || (protClass != destProt)) ) - return false; - } - if (destHostWildCard) - { - if (!destHost.isEmpty() && !url.host().endsWith(destHost)) - return false; - } - else if (destHostEqual) - { - if (url.host() != base.host()) - return false; - } - else - { - if (url.host() != destHost) - return false; - } - if (destPathWildCard) - { - if (!destPath.isEmpty() && !url.path().startsWith(destPath)) - return false; - } - else - { - if (url.path() != destPath) - return false; - } - return true; - } - - TQString action; - TQString baseProt; - TQString baseHost; - TQString basePath; - TQString destProt; - TQString destHost; - TQString destPath; - bool baseProtWildCard : 1; - bool baseHostWildCard : 1; - bool basePathWildCard : 1; - bool destProtWildCard : 1; - bool destHostWildCard : 1; - bool destPathWildCard : 1; - bool destProtEqual : 1; - bool destHostEqual : 1; - bool permission; - }; - TQPtrList urlActionRestrictions; - - TQString sessionKey; - TQString pSessionConfigFile; -}; - - -static TQPtrList*x11Filter = 0; -static bool autoDcopRegistration = true; - -void KApplication::installX11EventFilter( TQWidget* filter ) -{ - if ( !filter ) - return; - if (!x11Filter) - x11Filter = new TQPtrList; - connect ( filter, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( x11FilterDestroyed() ) ); - x11Filter->append( filter ); -} - -void KApplication::x11FilterDestroyed() -{ - removeX11EventFilter( static_cast< const TQWidget* >( sender())); -} - -void KApplication::removeX11EventFilter( const TQWidget* filter ) -{ - if ( !x11Filter || !filter ) - return; - x11Filter->removeRef( filter ); - if ( x11Filter->isEmpty() ) { - delete x11Filter; - x11Filter = 0; - } -} - -// FIXME: remove this when we've get a better method of -// customizing accelerator handling -- hopefully in Qt. -// For now, this is set whenever an accelerator is overridden -// in KAccelEventHandler so that the AccelOverride isn't sent twice. -- ellis, 19/10/02 -extern bool kde_g_bKillAccelOverride; - -bool KApplication::notify(TQObject *receiver, TQEvent *event) -{ - TQEvent::Type t = event->type(); - if (kde_g_bKillAccelOverride) - { - kde_g_bKillAccelOverride = false; - // Indicate that the accelerator has been overridden. - if (t == TQEvent::AccelOverride) - { - TQT_TQKEYEVENT(event)->accept(); - return true; - } - else - kdWarning(125) << "kde_g_bKillAccelOverride set, but received an event other than AccelOverride." << endl; - } - - if ((t == TQEvent::AccelOverride) || (t == TQEvent::KeyPress)) - { - static const KShortcut& _selectAll = KStdAccel::selectAll(); - TQLineEdit *edit = ::tqqt_cast(receiver); - if (edit) - { - // We have a keypress for a lineedit... - TQKeyEvent *kevent = TQT_TQKEYEVENT(event); - KKey key(kevent); - if (_selectAll.contains(key)) - { - if (t == TQEvent::KeyPress) - { - edit->selectAll(); - return true; - } - else - { - kevent->accept(); - } - } - // Ctrl-U deletes from start of line. - if (key == KKey(Qt::CTRL + Qt::Key_U)) - { - if (t == TQEvent::KeyPress) - { - if (!edit->isReadOnly()) - { - TQString t(edit->text()); - t = t.mid(edit->cursorPosition()); - edit->validateAndSet(t, 0, 0, 0); - } - return true; - } - else - { - kevent->accept(); - } - - } - } - TQTextEdit *medit = ::tqqt_cast(receiver); - if (medit) - { - // We have a keypress for a multilineedit... - TQKeyEvent *kevent = TQT_TQKEYEVENT(event); - if (_selectAll.contains(KKey(kevent))) - { - if (t == TQEvent::KeyPress) - { - medit->selectAll(); - return true; - } - else - { - kevent->accept(); - } - } - } - } - if( t == TQEvent::Show && receiver->isWidgetType()) - { - TQWidget* w = TQT_TQWIDGET( receiver ); -#if defined Q_WS_X11 - if( w->isTopLevel() && !startupId().isEmpty() && !TQT_TQSHOWEVENT(event)->spontaneous()) // TODO better done using window group leader? - KStartupInfo::setWindowStartupId( w->winId(), startupId()); -#endif - if( w->isTopLevel() && !w->testWFlags( WX11BypassWM ) && !w->isPopup() && !event->spontaneous()) - { - if( d->app_started_timer == NULL ) - { - d->app_started_timer = new TQTimer( this, "app_started_timer" ); - connect( d->app_started_timer, TQT_SIGNAL( timeout()), TQT_SLOT( checkAppStartedSlot())); - } - if( !d->app_started_timer->isActive()) - d->app_started_timer->start( 0, true ); - } - if( w->isTopLevel() && ( w->icon() == NULL || w->icon()->isNull())) - { - // icon() cannot be null pixmap, it'll be the "unknown" icon - so check if there is this application icon - static TQPixmap* ic = NULL; - if( ic == NULL ) - ic = new TQPixmap( KGlobal::iconLoader()->loadIcon( iconName(), - KIcon::NoGroup, 0, KIcon::DefaultState, NULL, true )); - if( !ic->isNull()) - { - w->setIcon( *ic ); -#if defined Q_WS_X11 - KWin::setIcons( w->winId(), *ic, miniIcon()); -#endif - } - } - } - return TQApplication::notify(receiver, event); -} - -void KApplication::checkAppStartedSlot() -{ -#if defined Q_WS_X11 - KStartupInfo::handleAutoAppStartedSending(); -#endif -} - -// the help class for session management communication -static TQPtrList* sessionClients() -{ - static TQPtrList* session_clients = 0L; - if ( !session_clients ) - session_clients = new TQPtrList; - return session_clients; -} - -/* - Auxiliary function to calculate a a session config name used for the - instance specific config object. - Syntax: "session/_" - */ -TQString KApplication::sessionConfigName() const -{ - TQString sessKey = sessionKey(); - if ( sessKey.isEmpty() && !d->sessionKey.isEmpty() ) - sessKey = d->sessionKey; - return TQString("session/%1_%2_%3").arg(name()).arg(sessionId()).arg(sessKey); -} - -#ifdef Q_WS_X11 -static SmcConn mySmcConnection = 0; -static SmcConn tmpSmcConnection = 0; -#else -// FIXME(E): Implement for Qt Embedded -// Possibly "steal" XFree86's libSM? -#endif -static TQTime* smModificationTime = 0; - -KApplication::KApplication( int& argc, char** argv, const TQCString& rAppName, - bool allowStyles, bool GUIenabled ) : - TQApplication( argc, argv, GUIenabled ), KInstance(rAppName), -#ifdef Q_WS_X11 - display(0L), - argb_visual(false), -#endif - d (new KApplicationPrivate()) -{ - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - if (!GUIenabled) - allowStyles = false; - useStyles = allowStyles; - Q_ASSERT (!rAppName.isEmpty()); - setName(rAppName); - - installSigpipeHandler(); - KCmdLineArgs::initIgnore(argc, argv, rAppName.data()); - parseCommandLine( ); - init(GUIenabled); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} - -KApplication::KApplication( bool allowStyles, bool GUIenabled ) : - TQApplication( *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(), TRUE ), // Qt4 requires that there always be a GUI - KInstance( KCmdLineArgs::about), -#ifdef Q_WS_X11 - display(0L), - argb_visual(false), -#endif - d (new KApplicationPrivate) -{ - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - if (!GUIenabled) - allowStyles = false; - useStyles = allowStyles; - setName( instanceName() ); - - installSigpipeHandler(); - parseCommandLine( ); - init(GUIenabled); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} - -#ifdef Q_WS_X11 -KApplication::KApplication( Display *dpy, bool allowStyles ) : - TQApplication( dpy, *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(), - getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ), - KInstance( KCmdLineArgs::about), display(0L), d (new KApplicationPrivate) -{ - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - useStyles = allowStyles; - setName( instanceName() ); - installSigpipeHandler(); - parseCommandLine( ); - init( true ); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} - -KApplication::KApplication( Display *dpy, bool disable_argb, Qt::HANDLE visual, Qt::HANDLE colormap, bool allowStyles ) : - TQApplication( dpy, *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(), - disable_argb?visual:getX11RGBAVisual(dpy), disable_argb?colormap:getX11RGBAColormap(dpy) ), - KInstance( KCmdLineArgs::about), display(0L), d (new KApplicationPrivate) -{ - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - useStyles = allowStyles; - if (disable_argb) argb_visual = false; - setName( instanceName() ); - installSigpipeHandler(); - parseCommandLine( ); - init( true ); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} - -KApplication::KApplication( Display *dpy, Qt::HANDLE visual, Qt::HANDLE colormap, - bool allowStyles ) : - TQApplication( dpy, *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(), - visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ), - KInstance( KCmdLineArgs::about), display(0L), d (new KApplicationPrivate) -{ - if ((visual) && (colormap)) - getX11RGBAInformation(dpy); - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - useStyles = allowStyles; - setName( instanceName() ); - installSigpipeHandler(); - parseCommandLine( ); - init( true ); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} - -KApplication::KApplication( Display *dpy, Qt::HANDLE visual, Qt::HANDLE colormap, - bool allowStyles, KInstance * _instance ) : - TQApplication( dpy, *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(), - visual?visual:getX11RGBAVisual(dpy), colormap?colormap:getX11RGBAColormap(dpy) ), - KInstance( _instance ), display(0L), d (new KApplicationPrivate) -{ - if ((visual) && (colormap)) - getX11RGBAInformation(dpy); - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - useStyles = allowStyles; - setName( instanceName() ); - installSigpipeHandler(); - parseCommandLine( ); - init( true ); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} -#endif - -KApplication::KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance ) : - TQApplication( *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(), - GUIenabled ), - KInstance( _instance ), -#ifdef Q_WS_X11 - display(0L), -#endif - argb_visual(false), - d (new KApplicationPrivate) -{ - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - if (!GUIenabled) - allowStyles = false; - useStyles = allowStyles; - setName( instanceName() ); - - installSigpipeHandler(); - parseCommandLine( ); - init(GUIenabled); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} - -#ifdef Q_WS_X11 -KApplication::KApplication(Display *display, int& argc, char** argv, const TQCString& rAppName, - bool allowStyles, bool GUIenabled ) : - TQApplication( display ), KInstance(rAppName), - display(0L), - argb_visual(false), - d (new KApplicationPrivate()) -{ - aIconPixmap.pm.icon = 0L; - aIconPixmap.pm.miniIcon = 0L; - read_app_startup_id(); - if (!GUIenabled) - allowStyles = false; - useStyles = allowStyles; - - Q_ASSERT (!rAppName.isEmpty()); - setName(rAppName); - - installSigpipeHandler(); - KCmdLineArgs::initIgnore(argc, argv, rAppName.data()); - parseCommandLine( ); - init(GUIenabled); - d->m_KAppDCOPInterface = new KAppDCOPInterface(this); -} -#endif - -int KApplication::xioErrhandler( Display* dpy ) -{ - if(kapp) - { - emit shutDown(); -#ifdef Q_WS_X11 - d->oldXIOErrorHandler( dpy ); -#else - Q_UNUSED(dpy); -#endif - } - exit( 1 ); - return 0; -} - -int KApplication::xErrhandler( Display* dpy, void* err_ ) -{ // no idea how to make forward decl. for XErrorEvent -#ifdef Q_WS_X11 - XErrorEvent* err = static_cast< XErrorEvent* >( err_ ); - if(kapp) - { - // add KDE specific stuff here - d->oldXErrorHandler( dpy, err ); - } -#endif - return 0; -} - -void KApplication::iceIOErrorHandler( _IceConn *conn ) -{ - emit shutDown(); - -#ifdef Q_WS_X11 - if ( d->oldIceIOErrorHandler != NULL ) - (*d->oldIceIOErrorHandler)( conn ); -#endif - exit( 1 ); -} - -class KDETranslator : public TQTranslator -{ -public: - KDETranslator(TQObject *parent) : TQTranslator(parent, "kdetranslator") {} - virtual TQTranslatorMessage findMessage(const char* context, - const char *sourceText, - const char* message) const - { - TQTranslatorMessage res; - res.setTranslation(KGlobal::locale()->translateQt(context, sourceText, message)); - return res; - } -}; - -void KApplication::init(bool GUIenabled) -{ - d->guiEnabled = GUIenabled; - if ((getuid() != geteuid()) || - (getgid() != getegid()) ) - { - // man permissions are not exploitable and better than - // world writable directories - struct group *man = getgrnam("man"); - if ( !man || man->gr_gid != getegid() ){ - fprintf(stderr, "The KDE libraries are not designed to run with suid privileges.\n"); - ::exit(127); - } - } - - KProcessController::ref(); - - (void) KClipboardSynchronizer::self(); - - TQApplication::setDesktopSettingsAware( false ); - - KApp = this; - - -#ifdef Q_WS_X11 //FIXME(E) - // create all required atoms in _one_ roundtrip to the X server - if ( GUIenabled ) { - const int max = 20; - Atom* atoms[max]; - char* names[max]; - Atom atoms_return[max]; - int n = 0; - - atoms[n] = &kipcCommAtom; - names[n++] = (char *) "KIPC_COMM_ATOM"; - - atoms[n] = &atom_DesktopWindow; - names[n++] = (char *) "KDE_DESKTOP_WINDOW"; - - atoms[n] = &atom_NetSupported; - names[n++] = (char *) "_NET_SUPPORTED"; - - atoms[n] = &kde_xdnd_drop; - names[n++] = (char *) "XdndDrop"; - - XInternAtoms( qt_xdisplay(), names, n, false, atoms_return ); - - for (int i = 0; i < n; i++ ) - *atoms[i] = atoms_return[i]; - } -#endif - - dcopAutoRegistration(); - dcopClientPostInit(); - - smw = 0; - - // Initial KIPC event mask. -#if defined Q_WS_X11 - kipcEventMask = (1 << KIPC::StyleChanged) | (1 << KIPC::PaletteChanged) | - (1 << KIPC::FontChanged) | (1 << KIPC::BackgroundChanged) | - (1 << KIPC::ToolbarStyleChanged) | (1 << KIPC::SettingsChanged) | - (1 << KIPC::ClipboardConfigChanged) | (1 << KIPC::BlockShortcuts); -#endif - - // Trigger creation of locale. - (void) KGlobal::locale(); - - KConfig* config = KGlobal::config(); - d->actionRestrictions = config->hasGroup("KDE Action Restrictions" ) && !kde_kiosk_exception; - // For brain-dead configurations where the user's local config file is not writable. - // * We use kdialog to warn the user, so we better not generate warnings from - // kdialog itself. - // * Don't warn if we run with a read-only $HOME - TQCString readOnly = getenv("KDE_HOME_READONLY"); - if (readOnly.isEmpty() && (tqstrcmp(name(), "kdialog") != 0)) - { - KConfigGroupSaver saver(config, "KDE Action Restrictions"); - if (config->readBoolEntry("warn_unwritable_config",true)) - config->checkConfigFilesWritable(true); - } - - if (GUIenabled) - { -#ifdef Q_WS_X11 - // this is important since we fork() to launch the help (Matthias) - fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, FD_CLOEXEC); - // set up the fancy (=robust and error ignoring ) KDE xio error handlers (Matthias) - d->oldXErrorHandler = XSetErrorHandler( kde_x_errhandler ); - d->oldXIOErrorHandler = XSetIOErrorHandler( kde_xio_errhandler ); -#endif - - connect( this, TQT_SIGNAL( aboutToQuit() ), this, TQT_SIGNAL( shutDown() ) ); - -#ifdef Q_WS_X11 //FIXME(E) - display = desktop()->x11Display(); -#endif - - { - TQStringList plugins = KGlobal::dirs()->resourceDirs( "qtplugins" ); - TQStringList::Iterator it = plugins.begin(); - while (it != plugins.end()) { - addLibraryPath( *it ); - ++it; - } - - } - kdisplaySetStyle(); - kdisplaySetFont(); -// kdisplaySetPalette(); done by kdisplaySetStyle - propagateSettings(SETTINGS_QT); - - // Set default mime-source factory - // XXX: This is a hack. Make our factory the default factory, but add the - // previous default factory to the list of factories. Why? When the default - // factory can't resolve something, it iterates in the list of factories. - // But it TQWhatsThis only uses the default factory. So if there was already - // a default factory (which happens when using an image library using uic), - // we prefer KDE's factory and so we put that old default factory in the - // list and use KDE as the default. This may speed up things as well. - TQMimeSourceFactory* oldDefaultFactory = TQMimeSourceFactory::takeDefaultFactory(); - TQMimeSourceFactory::setDefaultFactory( mimeSourceFactory() ); - if ( oldDefaultFactory ) { - TQMimeSourceFactory::addFactory( oldDefaultFactory ); - } - - d->checkAccelerators = new KCheckAccelerators( TQT_TQOBJECT(this) ); - } - -#ifdef Q_WS_MACX - if (GUIenabled) { - TQPixmap pixmap = KGlobal::iconLoader()->loadIcon( KCmdLineArgs::appName(), - KIcon::NoGroup, KIcon::SizeLarge, KIcon::DefaultState, 0L, false ); - if (!pixmap.isNull()) { - TQImage i = pixmap.convertToImage().convertDepth(32).smoothScale(40, 40); - for(int y = 0; y < i.height(); y++) { - uchar *l = i.scanLine(y); - for(int x = 0; x < i.width(); x+=4) - *(l+x) = 255; - } - CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); - CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, - i.bits(), i.numBytes(), NULL); - CGImageRef ir = CGImageCreate(i.width(), i.height(), 8, 32, i.bytesPerLine(), - cs, kCGImageAlphaNoneSkipFirst, dp, - 0, 0, kCGRenderingIntentDefault); - //cleanup - SetApplicationDockTileImage(ir); - CGImageRelease(ir); - CGColorSpaceRelease(cs); - CGDataProviderRelease(dp); - } - } -#endif - - - // save and restore the RTL setting, as installTranslator calls qt_detectRTLLanguage, - // which makes it impossible to use the -reverse cmdline switch with KDE apps - bool rtl = reverseLayout(); - installTranslator(new KDETranslator(TQT_TQOBJECT(this))); - setReverseLayout( rtl ); - if (i18n( "_: Dear Translator! Translate this string to the string 'LTR' in " - "left-to-right languages (as english) or to 'RTL' in right-to-left " - "languages (such as Hebrew and Arabic) to get proper widget layout." ) == "RTL") - setReverseLayout( !rtl ); - - // install appdata resource type - KGlobal::dirs()->addResourceType("appdata", KStandardDirs::kde_default("data") - + TQString::tqfromLatin1(name()) + '/'); - pSessionConfig = 0L; - bSessionManagement = true; - -#ifdef Q_WS_X11 - // register a communication window for desktop changes (Matthias) - if (GUIenabled && kde_have_kipc ) - { - smw = new TQWidget(0,0); - long data = 1; - XChangeProperty(qt_xdisplay(), smw->winId(), - atom_DesktopWindow, atom_DesktopWindow, - 32, PropModeReplace, (unsigned char *)&data, 1); - } - d->oldIceIOErrorHandler = IceSetIOErrorHandler( kde_ice_ioerrorhandler ); -#elif defined(Q_WS_WIN) - KApplication_init_windows(GUIenabled); -#else - // FIXME(E): Implement for Qt Embedded -#endif -} - -static int my_system (const char *command) { - int pid, status; - - pid = fork(); - if (pid == -1) - return -1; - if (pid == 0) { - const char* shell = "/bin/sh"; - execl(shell, shell, "-c", command, (void *)0); - ::_exit(127); - } - do { - if (waitpid(pid, &status, 0) == -1) { - if (errno != EINTR) - return -1; - } else - return status; - } while(1); -} - - -DCOPClient *KApplication::dcopClient() -{ - if (s_DCOPClient) - return s_DCOPClient; - - s_DCOPClient = new DCOPClient(); - KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde"); - if (args && args->isSet("dcopserver")) - { - s_DCOPClient->setServerAddress( args->getOption("dcopserver")); - } - if( kapp ) { - connect(s_DCOPClient, TQT_SIGNAL(attachFailed(const TQString &)), - kapp, TQT_SLOT(dcopFailure(const TQString &))); - connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(bool) ), - kapp, TQT_SLOT(dcopBlockUserInput(bool)) ); - } - else - s_dcopClientNeedsPostInit = true; - - DCOPClient::setMainClient( s_DCOPClient ); - return s_DCOPClient; -} - -void KApplication::dcopClientPostInit() -{ - if( s_dcopClientNeedsPostInit ) - { - s_dcopClientNeedsPostInit = false; - connect(s_DCOPClient, TQT_SIGNAL(blockUserInput(bool) ), - TQT_SLOT(dcopBlockUserInput(bool)) ); - s_DCOPClient->bindToApp(); // Make sure we get events from the DCOPClient. - } -} - -void KApplication::dcopAutoRegistration() -{ - if (autoDcopRegistration) - { - ( void ) dcopClient(); - if( dcopClient()->appId().isEmpty()) - dcopClient()->registerAs(name()); - } -} - -void KApplication::disableAutoDcopRegistration() -{ - autoDcopRegistration = false; -} - -KConfig* KApplication::sessionConfig() -{ - if (pSessionConfig) - return pSessionConfig; - - // create an instance specific config object - pSessionConfig = new KConfig( sessionConfigName(), false, false); - return pSessionConfig; -} - -void KApplication::ref() -{ - d->refCount++; - //kdDebug() << "KApplication::ref() : refCount = " << d->refCount << endl; -} - -void KApplication::deref() -{ - d->refCount--; - //kdDebug() << "KApplication::deref() : refCount = " << d->refCount << endl; - if ( d->refCount <= 0 ) - quit(); -} - -KSessionManaged::KSessionManaged() -{ - sessionClients()->remove( this ); - sessionClients()->append( this ); -} - -KSessionManaged::~KSessionManaged() -{ - sessionClients()->remove( this ); -} - -bool KSessionManaged::saveState(TQSessionManager&) -{ - return true; -} - -bool KSessionManaged::commitData(TQSessionManager&) -{ - return true; -} - - -void KApplication::disableSessionManagement() { - bSessionManagement = false; -} - -void KApplication::enableSessionManagement() { - bSessionManagement = true; -#ifdef Q_WS_X11 - // Session management support in Qt/KDE is awfully broken. - // If konqueror disables session management right after its startup, - // and enables it later (preloading stuff), it won't be properly - // saved on session shutdown. - // I'm not actually sure why it doesn't work, but saveState() - // doesn't seem to be called on session shutdown, possibly - // because disabling session management after konqueror startup - // disabled it somehow. Forcing saveState() here for this application - // seems to fix it. - if( mySmcConnection ) { - SmcRequestSaveYourself( mySmcConnection, SmSaveLocal, False, - SmInteractStyleAny, - False, False ); - - // flush the request - IceFlush(SmcGetIceConnection(mySmcConnection)); - } -#endif -} - - -bool KApplication::requestShutDown( - ShutdownConfirm confirm, ShutdownType sdtype, ShutdownMode sdmode ) -{ -#ifdef Q_WS_X11 - TQApplication::syncX(); - /* use ksmserver's dcop interface if necessary */ - if ( confirm == ShutdownConfirmYes || - sdtype != ShutdownTypeDefault || - sdmode != ShutdownModeDefault ) - { - TQByteArray data; - TQDataStream arg(data, IO_WriteOnly); - arg << (int)confirm << (int)sdtype << (int)sdmode; - return dcopClient()->send( "ksmserver", "ksmserver", - "logout(int,int,int)", data ); - } - - if ( mySmcConnection ) { - // we already have a connection to the session manager, use it. - SmcRequestSaveYourself( mySmcConnection, SmSaveBoth, True, - SmInteractStyleAny, - confirm == ShutdownConfirmNo, True ); - - // flush the request - IceFlush(SmcGetIceConnection(mySmcConnection)); - return true; - } - - // open a temporary connection, if possible - - propagateSessionManager(); - TQCString smEnv = ::getenv("SESSION_MANAGER"); - if (smEnv.isEmpty()) - return false; - - if (! tmpSmcConnection) { - char cerror[256]; - char* myId = 0; - char* prevId = 0; - SmcCallbacks cb; - tmpSmcConnection = SmcOpenConnection( 0, 0, 1, 0, - 0, &cb, - prevId, - &myId, - 255, - cerror ); - ::free( myId ); // it was allocated by C - if (!tmpSmcConnection ) - return false; - } - - SmcRequestSaveYourself( tmpSmcConnection, SmSaveBoth, True, - SmInteractStyleAny, False, True ); - - // flush the request - IceFlush(SmcGetIceConnection(tmpSmcConnection)); - return true; -#else - // FIXME(E): Implement for Qt Embedded - return false; -#endif -} - -void KApplication::propagateSessionManager() -{ -#ifdef Q_WS_X11 - TQCString fName = TQFile::encodeName(locateLocal("socket", "KSMserver")); - TQCString display = ::getenv(DISPLAY); - // strip the screen number from the display - display.replace(TQRegExp("\\.[0-9]+$"), ""); - int i; - while( (i = display.find(':')) >= 0) - display[i] = '_'; - - fName += "_"+display; - TQCString smEnv = ::getenv("SESSION_MANAGER"); - bool check = smEnv.isEmpty(); - if ( !check && smModificationTime ) { - TQFileInfo info( fName ); - TQTime current = TQT_TQTIME_OBJECT(info.lastModified().time()); - check = current > *smModificationTime; - } - if ( check ) { - delete smModificationTime; - TQFile f( fName ); - if ( !f.open( IO_ReadOnly ) ) - return; - TQFileInfo info ( f ); - smModificationTime = new TQTime( TQT_TQTIME_OBJECT(info.lastModified().time()) ); - TQTextStream t(&f); - t.setEncoding( TQTextStream::Latin1 ); - TQString s = t.readLine(); - f.close(); - ::setenv( "SESSION_MANAGER", s.latin1(), true ); - } -#endif -} - -void KApplication::commitData( TQSessionManager& sm ) -{ - d->session_save = true; - bool canceled = false; - for (KSessionManaged* it = sessionClients()->first(); - it && !canceled; - it = sessionClients()->next() ) { - canceled = !it->commitData( sm ); - } - if ( canceled ) - sm.cancel(); - - if ( sm.allowsInteraction() ) { - TQWidgetList done; - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - bool canceled = false; - TQWidget* w = list->first(); - while ( !canceled && w ) { - if ( !w->testWState( WState_ForceHide ) && !w->inherits("KMainWindow") ) { - TQCloseEvent e; - sendEvent( w, &e ); - canceled = !e.isAccepted(); - if ( !canceled ) - done.append( w ); - delete list; // one never knows... - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - while ( w && done.containsRef( w ) ) - w = list->next(); - } - delete list; - } - - - if ( !bSessionManagement ) - sm.setRestartHint( TQSessionManager::RestartNever ); - else - sm.setRestartHint( TQSessionManager::RestartIfRunning ); - d->session_save = false; -} - -static void checkRestartVersion( TQSessionManager& sm ) -{ - Display* dpy = qt_xdisplay(); - Atom type; - int format; - unsigned long nitems, after; - unsigned char* data; - if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy, "TDE_FULL_SESSION", False ), - 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) { - if( data != NULL ) - XFree( data ); - if( type == XA_STRING && format == 8 ) { // session set, check if KDE_SESSION_VERSION is not set (meaning KDE3) - if( XGetWindowProperty( dpy, RootWindow( dpy, 0 ), XInternAtom( dpy, "KDE_SESSION_VERSION", False ), - 0, 1, False, AnyPropertyType, &type, &format, &nitems, &after, &data ) == Success ) { - if( data != NULL ) - XFree( data ); // KDE4 or newer - if( type == None ) - return; // we run in our native session, no need to wrap - } else { - return; // we run in our native session, no need to wrap - } - } - } - TQString wrapper = KStandardDirs::findExe( "trinity" ); - TQStringList restartCommand = sm.restartCommand(); - restartCommand.prepend( wrapper ); - sm.setRestartCommand( restartCommand ); -} - -void KApplication::saveState( TQSessionManager& sm ) -{ - d->session_save = true; -#ifdef Q_WS_X11 - static bool firstTime = true; - mySmcConnection = (SmcConn) sm.handle(); - - if ( !bSessionManagement ) { - sm.setRestartHint( TQSessionManager::RestartNever ); - d->session_save = false; - return; - } - else - sm.setRestartHint( TQSessionManager::RestartIfRunning ); - - if ( firstTime ) { - firstTime = false; - d->session_save = false; - return; // no need to save the state. - } - - // remove former session config if still existing, we want a new - // and fresh one. Note that we do not delete the config file here, - // this is done by the session manager when it executes the - // discard commands. In fact it would be harmful to remove the - // file here, as the session might be stored under a different - // name, meaning the user still might need it eventually. - if ( pSessionConfig ) { - delete pSessionConfig; - pSessionConfig = 0; - } - - // tell the session manager about our new lifecycle - TQStringList restartCommand = sm.restartCommand(); - - TQCString multiHead = getenv("KDE_MULTIHEAD"); - if (multiHead.lower() == "true") { - // if multihead is enabled, we save our -display argument so that - // we are restored onto the correct head... one problem with this - // is that the display is hard coded, which means we cannot restore - // to a different display (ie. if we are in a university lab and try, - // try to restore a multihead session, our apps could be started on - // someone else's display instead of our own) - TQCString displayname = getenv(DISPLAY); - if (! displayname.isNull()) { - // only store the command if we actually have a DISPLAY - // environment variable - restartCommand.append("-display"); - restartCommand.append(displayname); - } - sm.setRestartCommand( restartCommand ); - } - - checkRestartVersion( sm ); - - // finally: do session management - emit saveYourself(); // for compatibility - bool canceled = false; - for (KSessionManaged* it = sessionClients()->first(); - it && !canceled; - it = sessionClients()->next() ) { - canceled = !it->saveState( sm ); - } - - // if we created a new session config object, register a proper discard command - if ( pSessionConfig ) { - pSessionConfig->sync(); - TQStringList discard; - discard << "rm" << locateLocal("config", sessionConfigName()); - sm.setDiscardCommand( discard ); - } else { - sm.setDiscardCommand( TQStringList("") ); - } - - if ( canceled ) - sm.cancel(); -#else - // FIXME(E): Implement for Qt Embedded -#endif - d->session_save = false; -} - -bool KApplication::sessionSaving() const -{ - return d->session_save; -} - -void KApplication::startKdeinit() -{ -#ifndef Q_WS_WIN //TODO - KInstance inst( "starttdeinitlock" ); - KLockFile lock( locateLocal( "tmp", "starttdeinitlock", &inst )); - if( lock.lock( KLockFile::LockNoBlock ) != KLockFile::LockOK ) { - lock.lock(); - DCOPClient cl; - if( cl.attach()) - return; // whoever held the lock has already started dcopserver - } - // Try to launch tdeinit. - TQString srv = KStandardDirs::findExe(TQString::tqfromLatin1("tdeinit")); - if (srv.isEmpty()) - srv = KStandardDirs::findExe(TQString::tqfromLatin1("tdeinit"), KGlobal::dirs()->kfsstnd_defaultbindir()); - if (srv.isEmpty()) - return; - if (kapp && (Tty != kapp->type())) - setOverrideCursor( tqwaitCursor ); - my_system(TQFile::encodeName(srv)+" --suicide"+" --new-startup"); - if (kapp && (Tty != kapp->type())) - restoreOverrideCursor(); -#endif -} - -void KApplication::dcopFailure(const TQString &msg) -{ - static int failureCount = 0; - failureCount++; - if (failureCount == 1) - { - startKdeinit(); - return; - } - if (failureCount == 2) - { -#ifdef Q_WS_WIN - KGlobal::config()->setGroup("General"); - if (KGlobal::config()->readBoolEntry("ignoreDCOPFailures", false)) - return; -#endif - TQString msgStr(i18n("There was an error setting up inter-process " - "communications for KDE. The message returned " - "by the system was:\n\n")); - msgStr += msg; - msgStr += i18n("\n\nPlease check that the \"dcopserver\" program is running!"); - - if (Tty != kapp->type()) - { - TQMessageBox::critical - ( - kapp->mainWidget(), - i18n("DCOP communications error (%1)").arg(kapp->caption()), - msgStr, - i18n("&OK") - ); - } - else - { - fprintf(stderr, "%s\n", msgStr.local8Bit().data()); - } - - return; - } -} - -static const KCmdLineOptions qt_options[] = -{ - //FIXME: Check if other options are specific to Qt/X11 -#ifdef Q_WS_X11 - { "display ", I18N_NOOP("Use the X-server display 'displayname'"), 0}, -#else - { "display ", I18N_NOOP("Use the QWS display 'displayname'"), 0}, -#endif - { "session ", I18N_NOOP("Restore the application for the given 'sessionId'"), 0}, - { "cmap", I18N_NOOP("Causes the application to install a private color\nmap on an 8-bit display"), 0}, - { "ncols ", I18N_NOOP("Limits the number of colors allocated in the color\ncube on an 8-bit display, if the application is\nusing the TQApplication::ManyColor color\nspecification"), 0}, - { "nograb", I18N_NOOP("tells Qt to never grab the mouse or the keyboard"), 0}, - { "dograb", I18N_NOOP("running under a debugger can cause an implicit\n-nograb, use -dograb to override"), 0}, - { "sync", I18N_NOOP("switches to synchronous mode for debugging"), 0}, - { "fn", 0, 0}, - { "font ", I18N_NOOP("defines the application font"), 0}, - { "bg", 0, 0}, - { "background ", I18N_NOOP("sets the default background color and an\napplication palette (light and dark shades are\ncalculated)"), 0}, - { "fg", 0, 0}, - { "foreground ", I18N_NOOP("sets the default foreground color"), 0}, - { "btn", 0, 0}, - { "button ", I18N_NOOP("sets the default button color"), 0}, - { "name ", I18N_NOOP("sets the application name"), 0}, - { "title ", I18N_NOOP("sets the application title (caption)"), 0}, -#ifdef Q_WS_X11 - { "visual TrueColor", I18N_NOOP("forces the application to use a TrueColor visual on\nan 8-bit display"), 0}, - { "inputstyle <inputstyle>", I18N_NOOP("sets XIM (X Input Method) input style. Possible\nvalues are onthespot, overthespot, offthespot and\nroot"), 0 }, - { "im <XIM server>", I18N_NOOP("set XIM server"),0}, - { "noxim", I18N_NOOP("disable XIM"), 0 }, -#endif -#ifdef Q_WS_QWS - { "qws", I18N_NOOP("forces the application to run as QWS Server"), 0}, -#endif - { "reverse", I18N_NOOP("mirrors the whole layout of widgets"), 0}, - KCmdLineLastOption -}; - -static const KCmdLineOptions kde_options[] = -{ - { "caption <caption>", I18N_NOOP("Use 'caption' as name in the titlebar"), 0}, - { "icon <icon>", I18N_NOOP("Use 'icon' as the application icon"), 0}, - { "miniicon <icon>", I18N_NOOP("Use 'icon' as the icon in the titlebar"), 0}, - { "config <filename>", I18N_NOOP("Use alternative configuration file"), 0}, - { "dcopserver <server>", I18N_NOOP("Use the DCOP Server specified by 'server'"), 0}, - { "nocrashhandler", I18N_NOOP("Disable crash handler, to get core dumps"), 0}, - { "waitforwm", I18N_NOOP("Waits for a WM_NET compatible windowmanager"), 0}, - { "style <style>", I18N_NOOP("sets the application GUI style"), 0}, - { "geometry <geometry>", I18N_NOOP("sets the client geometry of the main widget - see man X for the argument format"), 0}, - { "smkey <sessionKey>", 0, 0}, // this option is obsolete and exists only to allow smooth upgrades from sessions - // saved under Qt 3.0.x -- Qt 3.1.x includes the session key now automatically in - // the session id (Simon) - KCmdLineLastOption -}; - -void -KApplication::addCmdLineOptions() -{ - KCmdLineArgs::addCmdLineOptions(qt_options, "Qt", "qt"); - KCmdLineArgs::addCmdLineOptions(kde_options, "KDE", "kde"); -} - -void KApplication::parseCommandLine( ) -{ - KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde"); - - if ( !args ) return; - - if (args->isSet("config")) - { - TQString config = TQString::fromLocal8Bit(args->getOption("config")); - setConfigName(config); - } - - if (args->isSet("style")) - { - - TQStringList plugins = KGlobal::dirs()->resourceDirs( "qtplugins" ); - TQStringList::Iterator itp = plugins.begin(); - while (itp != plugins.end()) { - addLibraryPath( *itp ); - ++itp; - } - - TQStringList styles = TQStyleFactory::keys(); - TQString reqStyle(args->getOption("style").lower()); - - TQStringList list = libraryPaths(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - ++it; - } - - for (TQStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it) { - if ((*it).lower() == reqStyle) - { - d->overrideStyle = *it; - break; - } - } - - if (d->overrideStyle.isEmpty()) - fprintf(stderr, "%s", TQString(i18n("The style %1 was not found\n").arg(reqStyle)).local8Bit().data()); - } - - if (args->isSet("caption")) - { - aCaption = TQString::fromLocal8Bit(args->getOption("caption")); - } - - if (args->isSet("miniicon")) - { - const char *tmp = args->getOption("miniicon"); - if (!aIconPixmap.pm.miniIcon) { - aIconPixmap.pm.miniIcon = new TQPixmap; - } - *aIconPixmap.pm.miniIcon = SmallIcon(tmp); - aMiniIconName = tmp; - } - - if (args->isSet("icon")) - { - const char *tmp = args->getOption("icon"); - if (!aIconPixmap.pm.icon) { - aIconPixmap.pm.icon = new TQPixmap; - } - *aIconPixmap.pm.icon = DesktopIcon( tmp ); - aIconName = tmp; - if (!aIconPixmap.pm.miniIcon) { - aIconPixmap.pm.miniIcon = new TQPixmap; - } - if (aIconPixmap.pm.miniIcon->isNull()) - { - *aIconPixmap.pm.miniIcon = SmallIcon( tmp ); - aMiniIconName = tmp; - } - } - - bool nocrashhandler = (getenv("KDE_DEBUG") != NULL); - if (!nocrashhandler && args->isSet("crashhandler")) - { - // set default crash handler / set emergency save function to nothing - KCrash::setCrashHandler(KCrash::defaultCrashHandler); - KCrash::setEmergencySaveFunction(NULL); - - KCrash::setApplicationName(TQString(args->appName())); - } - -#ifdef Q_WS_X11 - if ( args->isSet( "waitforwm" ) ) { - Atom type; - (void) desktop(); // trigger desktop creation, we need PropertyNotify events for the root window - int format; - unsigned long length, after; - unsigned char *data; - while ( XGetWindowProperty( qt_xdisplay(), qt_xrootwin(), atom_NetSupported, - 0, 1, false, AnyPropertyType, &type, &format, - &length, &after, &data ) != Success || !length ) { - if ( data ) - XFree( data ); - XEvent event; - XWindowEvent( qt_xdisplay(), qt_xrootwin(), PropertyChangeMask, &event ); - } - if ( data ) - XFree( data ); - } -#else - // FIXME(E): Implement for Qt Embedded -#endif - - if (args->isSet("geometry")) - { - d->geometry_arg = args->getOption("geometry"); - } - - if (args->isSet("smkey")) - { - d->sessionKey = args->getOption("smkey"); - } - -} - -TQString KApplication::geometryArgument() const -{ - return d->geometry_arg; -} - -TQPixmap KApplication::icon() const -{ - if( !aIconPixmap.pm.icon) { - aIconPixmap.pm.icon = new TQPixmap; - } - if( aIconPixmap.pm.icon->isNull()) { - *aIconPixmap.pm.icon = DesktopIcon( instanceName() ); - } - return *aIconPixmap.pm.icon; -} - -TQString KApplication::iconName() const -{ - return aIconName.isNull() ? (TQString)instanceName() : aIconName; -} - -TQPixmap KApplication::miniIcon() const -{ - if (!aIconPixmap.pm.miniIcon) { - aIconPixmap.pm.miniIcon = new TQPixmap; - } - if (aIconPixmap.pm.miniIcon->isNull()) { - *aIconPixmap.pm.miniIcon = SmallIcon( instanceName() ); - } - return *aIconPixmap.pm.miniIcon; -} - -TQString KApplication::miniIconName() const -{ - return aMiniIconName.isNull() ? (TQString)instanceName() : aMiniIconName; -} - -extern void kDebugCleanup(); - -KApplication::~KApplication() -{ - delete aIconPixmap.pm.miniIcon; - aIconPixmap.pm.miniIcon = 0L; - delete aIconPixmap.pm.icon; - aIconPixmap.pm.icon = 0L; - delete d->m_KAppDCOPInterface; - - // First call the static deleters and then call KLibLoader::cleanup() - // The static deleters may delete libraries for which they need KLibLoader. - // KLibLoader will take care of the remaining ones. - KGlobal::deleteStaticDeleters(); - KLibLoader::cleanUp(); - - delete smw; - - // close down IPC - delete s_DCOPClient; - s_DCOPClient = 0L; - - KProcessController::deref(); - -#ifdef Q_WS_X11 - if ( d->oldXErrorHandler != NULL ) - XSetErrorHandler( d->oldXErrorHandler ); - if ( d->oldXIOErrorHandler != NULL ) - XSetIOErrorHandler( d->oldXIOErrorHandler ); - if ( d->oldIceIOErrorHandler != NULL ) - IceSetIOErrorHandler( d->oldIceIOErrorHandler ); -#endif - - delete d; - KApp = 0; - -#ifdef Q_WS_X11 - mySmcConnection = 0; - delete smModificationTime; - smModificationTime = 0; - - // close the temporary smc connection - if (tmpSmcConnection) { - SmcCloseConnection( tmpSmcConnection, 0, 0 ); - tmpSmcConnection = 0; - } -#else - // FIXME(E): Implement for Qt Embedded -#endif -} - - -#ifdef Q_WS_X11 -class KAppX11HackWidget: public QWidget -{ -public: - bool publicx11Event( XEvent * e) { return x11Event( e ); } -}; -#endif - -#if defined(Q_WS_X11) && defined(COMPOSITE) -bool KApplication::isCompositionManagerAvailable() { - bool have_manager = false; - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - - char *filename; - const char *configfile = "/.kompmgr.available"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); - - // Now that we did all that by way of introduction...read the file! - FILE *pFile; - char buffer[255]; - pFile = fopen(filename, "r"); - int kompmgrpid = 0; - if (pFile) { - have_manager = true; - fclose(pFile); - } - - free(filename); - filename = NULL; - - return have_manager; -} - -bool KApplication::detectCompositionManagerAvailable(bool force_available, bool available) { - bool compositing_manager_available; - if (force_available) { - compositing_manager_available = available; - } - else { - // See if compositing has been enabled - KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt"); - char *displayname = 0; - if ( qtargs->isSet("display")) - displayname = qtargs->getOption( "display" ).data(); - - Display *dpy = XOpenDisplay( displayname ); - - x11_composite_error_generated = false; - compositing_manager_available = false; - XSetErrorHandler(x11_error); - if (!XQueryExtension (dpy, COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) { - XSetErrorHandler(NULL); - compositing_manager_available = false; - } - else { - Window root_window = XDefaultRootWindow(dpy); - XCompositeRedirectSubwindows(dpy, root_window, CompositeRedirectManual); - XSync(dpy, false); - if (x11_composite_error_generated == true) { - compositing_manager_available = true; - } - else { - XCompositeUnredirectSubwindows(dpy, root_window, CompositeRedirectManual); - compositing_manager_available = false; - } - XSetErrorHandler(NULL); - XCloseDisplay(dpy); - } - } - - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - - char *filename; - const char *configfile = "/.kompmgr.available"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); - - /* now that we did all that by way of introduction...create or remove the file! */ - if (compositing_manager_available) { - FILE *pFile; - char buffer[255]; - sprintf(buffer, "available"); - pFile = fopen(filename, "w"); - if (pFile) { - fwrite(buffer,1,strlen(buffer), pFile); - fclose(pFile); - } - } - else { - unlink(filename); - } - - free(filename); - filename = NULL; - - return compositing_manager_available; -} - -Display* KApplication::openX11RGBADisplay() { - KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt"); - char *display = 0; - if ( qtargs->isSet("display")) - display = qtargs->getOption( "display" ).data(); - - Display *dpy = XOpenDisplay( display ); - if ( !dpy ) { - kdError() << "cannot connect to X server " << display << endl; - exit( 1 ); - } - - return dpy; -} - -Qt::HANDLE KApplication::getX11RGBAVisual(Display *dpy) { - getX11RGBAInformation(dpy); - if (KApplication::isCompositionManagerAvailable() == true) { - return argb_x11_visual; - } - else { - return NULL; - } -} - -Qt::HANDLE KApplication::getX11RGBAColormap(Display *dpy) { - getX11RGBAInformation(dpy); - if (KApplication::isCompositionManagerAvailable() == true) { - return argb_x11_colormap; - } - else { - return NULL; - } -} - -bool KApplication::isX11CompositionAvailable() { - return (argb_visual & isCompositionManagerAvailable()); -} - -void KApplication::getX11RGBAInformation(Display *dpy) { - if ( !dpy ) { - argb_visual = false; - return; - } - - int screen = DefaultScreen( dpy ); - Colormap colormap = 0; - Visual *visual = 0; - int event_base, error_base; - - if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) { - int nvi; - XVisualInfo templ; - templ.screen = screen; - templ.depth = 32; - templ.c_class = TrueColor; - XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask - | VisualClassMask, &templ, &nvi ); - - for ( int i = 0; i < nvi; i++ ) { - XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual ); - if ( format->type == PictTypeDirect && format->direct.alphaMask ) { - visual = xvi[i].visual; - colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone ); - kdDebug() << "found visual with alpha support" << endl; - argb_visual = true; - break; - } - } - } - - if( argb_visual ) { - argb_x11_visual = Qt::HANDLE( visual ); - argb_x11_colormap = Qt::HANDLE( colormap ); - argb_visual = true; - return; - } - argb_visual = false; - return; -} -#else -void KApplication::getX11RGBAInformation(Display *dpy) { -} - -bool KApplication::isCompositionManagerAvailable() { - return false; -} - -bool KApplication::detectCompositionManagerAvailable(bool force_available) { - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - - char *filename; - const char *configfile = "/.kompmgr.available"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); - - /* now that we did all that by way of introduction...remove the file! */ - unlink(filename); - - free(filename); - filename = NULL; - - return false; -} - -Display* KApplication::openX11RGBADisplay() { - return 0; -} - -Qt::HANDLE KApplication::getX11RGBAVisual(char *display) { - return 0; -} - -Qt::HANDLE KApplication::getX11RGBAColormap(char *display) { - return 0; -} - -bool KApplication::isX11CompositionAvailable() { - return false; -} - -KApplication KApplication::KARGBApplication( bool allowStyles ) { - return KApplication::KApplication(allowStyles, true); -} -#endif - -static bool kapp_block_user_input = false; - -void KApplication::dcopBlockUserInput( bool b ) -{ - kapp_block_user_input = b; -} - -#ifdef Q_WS_X11 -bool KApplication::x11EventFilter( XEvent *_event ) -{ - switch ( _event->type ) { - case ClientMessage: - { -#if KDE_IS_VERSION( 3, 90, 90 ) -#warning This should be already in Qt, check. -#endif - // Workaround for focus stealing prevention not working when dragging e.g. text from KWrite - // to KDesktop -> the dialog asking for filename doesn't get activated. This is because - // Qt-3.2.x doesn't have concept of qt_x_user_time at all, and Qt-3.3.0b1 passes the timestamp - // in the XdndDrop message in incorrect field (and doesn't update qt_x_user_time either). - // Patch already sent, future Qt version should have this fixed. - if( _event->xclient.message_type == kde_xdnd_drop ) - { // if the message is XdndDrop - if( _event->xclient.data.l[ 1 ] == 1 << 24 // and it's broken the way it's in Qt-3.2.x - && _event->xclient.data.l[ 2 ] == 0 - && _event->xclient.data.l[ 4 ] == 0 - && _event->xclient.data.l[ 3 ] != 0 ) - { - if( GET_QT_X_USER_TIME() == 0 - || NET::timestampCompare( _event->xclient.data.l[ 3 ], GET_QT_X_USER_TIME() ) > 0 ) - { // and the timestamp looks reasonable - SET_QT_X_USER_TIME(_event->xclient.data.l[ 3 ]); // update our qt_x_user_time from it - } - } - else // normal DND, only needed until Qt updates qt_x_user_time from XdndDrop - { - if( GET_QT_X_USER_TIME() == 0 - || NET::timestampCompare( _event->xclient.data.l[ 2 ], GET_QT_X_USER_TIME() ) > 0 ) - { // the timestamp looks reasonable - SET_QT_X_USER_TIME(_event->xclient.data.l[ 2 ]); // update our qt_x_user_time from it - } - } - } - } - default: break; - } - - if ( kapp_block_user_input ) { - switch ( _event->type ) { - case ButtonPress: - case ButtonRelease: - case XKeyPress: - case XKeyRelease: - case MotionNotify: - case EnterNotify: - case LeaveNotify: - return true; - default: - break; - } - } - - if (x11Filter) { - for (TQWidget *w=x11Filter->first(); w; w=x11Filter->next()) { - if (((KAppX11HackWidget*) w)->publicx11Event(_event)) - return true; - } - } - - if ((_event->type == ClientMessage) && - (_event->xclient.message_type == kipcCommAtom)) - { - XClientMessageEvent *cme = (XClientMessageEvent *) _event; - - int id = cme->data.l[0]; - int arg = cme->data.l[1]; - if ((id < 32) && (kipcEventMask & (1 << id))) - { - switch (id) - { - case KIPC::StyleChanged: - KGlobal::config()->reparseConfiguration(); - kdisplaySetStyle(); - break; - - case KIPC::ToolbarStyleChanged: - KGlobal::config()->reparseConfiguration(); - if (useStyles) - emit toolbarAppearanceChanged(arg); - break; - - case KIPC::PaletteChanged: - KGlobal::config()->reparseConfiguration(); - kdisplaySetPalette(); - break; - - case KIPC::FontChanged: - KGlobal::config()->reparseConfiguration(); - KGlobalSettings::rereadFontSettings(); - kdisplaySetFont(); - break; - - case KIPC::BackgroundChanged: - emit backgroundChanged(arg); - break; - - case KIPC::SettingsChanged: - KGlobal::config()->reparseConfiguration(); - if (arg == SETTINGS_PATHS) - KGlobalSettings::rereadPathSettings(); - else if (arg == SETTINGS_MOUSE) - KGlobalSettings::rereadMouseSettings(); - propagateSettings((SettingsCategory)arg); - break; - - case KIPC::IconChanged: - TQPixmapCache::clear(); - KGlobal::config()->reparseConfiguration(); - KGlobal::instance()->newIconLoader(); - emit updateIconLoaders(); - emit iconChanged(arg); - break; - - case KIPC::ClipboardConfigChanged: - KClipboardSynchronizer::newConfiguration(arg); - break; - - case KIPC::BlockShortcuts: - KGlobalAccel::blockShortcuts(arg); - emit kipcMessage(id, arg); // some apps may do additional things - break; - } - } - else if (id >= 32) - { - emit kipcMessage(id, arg); - } - return true; - } - return false; -} -#endif // Q_WS_X11 - -void KApplication::updateUserTimestamp( unsigned long time ) -{ -#if defined Q_WS_X11 - if( time == 0 ) - { // get current X timestamp - Window w = XCreateSimpleWindow( qt_xdisplay(), qt_xrootwin(), 0, 0, 1, 1, 0, 0, 0 ); - XSelectInput( qt_xdisplay(), w, PropertyChangeMask ); - unsigned char data[ 1 ]; - XChangeProperty( qt_xdisplay(), w, XA_ATOM, XA_ATOM, 8, PropModeAppend, data, 1 ); - XEvent ev; - XWindowEvent( qt_xdisplay(), w, PropertyChangeMask, &ev ); - time = ev.xproperty.time; - XDestroyWindow( qt_xdisplay(), w ); - } - if( GET_QT_X_USER_TIME() == 0 - || NET::timestampCompare( time, GET_QT_X_USER_TIME() ) > 0 ) // check time > qt_x_user_time - SET_QT_X_USER_TIME(time); -#endif -} - -unsigned long KApplication::userTimestamp() const -{ -#if defined Q_WS_X11 - return GET_QT_X_USER_TIME(); -#else - return 0; -#endif -} - -void KApplication::updateRemoteUserTimestamp( const TQCString& dcopId, unsigned long time ) -{ -#if defined Q_WS_X11 - if( time == 0 ) - time = GET_QT_X_USER_TIME(); - DCOPRef( dcopId, "MainApplication-Interface" ).call( "updateUserTimestamp", time ); -#endif -} - -void KApplication::invokeEditSlot( const char *slot ) -{ - TQObject *object = TQT_TQOBJECT(tqfocusWidget()); - if( !object ) - return; - - TQMetaObject *meta = object->tqmetaObject(); - - int idx = meta->findSlot( slot + 1, true ); - if( idx < 0 ) - return; - - object->qt_invoke( idx, 0 ); -} - -void KApplication::addKipcEventMask(int id) -{ - if (id >= 32) - { - kdDebug(101) << "Cannot use KIPC event mask for message IDs >= 32\n"; - return; - } - kipcEventMask |= (1 << id); -} - -void KApplication::removeKipcEventMask(int id) -{ - if (id >= 32) - { - kdDebug(101) << "Cannot use KIPC event mask for message IDs >= 32\n"; - return; - } - kipcEventMask &= ~(1 << id); -} - -void KApplication::enableStyles() -{ - if (!useStyles) - { - useStyles = true; - applyGUIStyle(); - } -} - -void KApplication::disableStyles() -{ - useStyles = false; -} - -void KApplication::applyGUIStyle() -{ - if ( !useStyles ) return; - - KConfigGroup pConfig (KGlobal::config(), "General"); - TQString defaultStyle = KStyle::defaultStyle(); - TQString styleStr = pConfig.readEntry("widgetStyle", defaultStyle); - - if (d->overrideStyle.isEmpty()) { - // ### add check whether we already use the correct style to return then - // (workaround for Qt misbehavior to avoid double style initialization) - - TQStyle* sp = TQStyleFactory::create( styleStr ); - - // If there is no default style available, try falling back any available style - if ( !sp && styleStr != defaultStyle) - sp = TQStyleFactory::create( defaultStyle ); - if ( !sp ) - sp = TQStyleFactory::create( *(TQStyleFactory::keys().begin()) ); - setStyle(sp); - } - else - setStyle(d->overrideStyle); - // Reread palette from config file. - kdisplaySetPalette(); -} - -TQString KApplication::caption() const -{ - // Caption set from command line ? - if( !aCaption.isNull() ) - return aCaption; - else - // We have some about data ? - if ( KGlobal::instance()->aboutData() ) - return KGlobal::instance()->aboutData()->programName(); - else - // Last resort : application name - return name(); -} - - -// -// 1999-09-20: Espen Sand -// An attempt to simplify consistent captions. -// -TQString KApplication::makeStdCaption( const TQString &userCaption, - bool withAppName, bool modified ) const -{ - TQString s = userCaption.isEmpty() ? caption() : userCaption; - - // If the document is modified, add '[modified]'. - if (modified) - s += TQString::fromUtf8(" [") + i18n("modified") + TQString::fromUtf8("]"); - - if ( !userCaption.isEmpty() ) { - // Add the application name if: - // User asked for it, it's not a duplication and the app name (caption()) is not empty - if ( withAppName && !caption().isNull() && !userCaption.endsWith(caption()) ) - s += TQString::fromUtf8(" - ") + caption(); - } - - return s; -} - -TQPalette KApplication::createApplicationPalette() -{ - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver( config, "General" ); - return createApplicationPalette( config, KGlobalSettings::contrast() ); -} - -TQPalette KApplication::createApplicationPalette( KConfig *config, int contrast_ ) -{ - TQColor trinity4Background( 239, 239, 239 ); - TQColor trinity4Blue( 103,141,178 ); - - TQColor trinity4Button; - if ( TQPixmap::defaultDepth() > 8 ) - trinity4Button.setRgb( 221, 223, 228 ); - else - trinity4Button.setRgb( 220, 220, 220 ); - - TQColor trinity4Link( 0, 0, 238 ); - TQColor trinity4VisitedLink( 82, 24, 139 ); - - TQColor background = config->readColorEntry( "background", &trinity4Background ); - TQColor foreground = config->readColorEntry( "foreground", tqblackptr ); - TQColor button = config->readColorEntry( "buttonBackground", &trinity4Button ); - TQColor buttonText = config->readColorEntry( "buttonForeground", tqblackptr ); - TQColor highlight = config->readColorEntry( "selectBackground", &trinity4Blue ); - TQColor highlightedText = config->readColorEntry( "selectForeground", tqwhiteptr ); - TQColor base = config->readColorEntry( "windowBackground", tqwhiteptr ); - TQColor baseText = config->readColorEntry( "windowForeground", tqblackptr ); - TQColor link = config->readColorEntry( "linkColor", &trinity4Link ); - TQColor visitedLink = config->readColorEntry( "visitedLinkColor", &trinity4VisitedLink ); - - int highlightVal, lowlightVal; - highlightVal = 100 + (2*contrast_+4)*16/10; - lowlightVal = 100 + (2*contrast_+4)*10; - - TQColor disfg = foreground; - - int h, s, v; - disfg.hsv( &h, &s, &v ); - if (v > 128) - // dark bg, light fg - need a darker disabled fg - disfg = disfg.dark(lowlightVal); - else if (disfg != Qt::black) - // light bg, dark fg - need a lighter disabled fg - but only if !black - disfg = disfg.light(highlightVal); - else - // black fg - use darkgray disabled fg - disfg = Qt::darkGray; - - - TQColorGroup disabledgrp(disfg, background, - background.light(highlightVal), - background.dark(lowlightVal), - background.dark(120), - background.dark(120), base); - - TQColorGroup colgrp(foreground, background, background.light(highlightVal), - background.dark(lowlightVal), - background.dark(120), - baseText, base); - - int inlowlightVal = lowlightVal-25; - if(inlowlightVal < 120) - inlowlightVal = 120; - - colgrp.setColor(TQColorGroup::Highlight, highlight); - colgrp.setColor(TQColorGroup::HighlightedText, highlightedText); - colgrp.setColor(TQColorGroup::Button, button); - colgrp.setColor(TQColorGroup::ButtonText, buttonText); - colgrp.setColor(TQColorGroup::Midlight, background.light(110)); - colgrp.setColor(TQColorGroup::Link, link); - colgrp.setColor(TQColorGroup::LinkVisited, visitedLink); - - disabledgrp.setColor(TQColorGroup::Button, button); - - TQColor disbtntext = buttonText; - disbtntext.hsv( &h, &s, &v ); - if (v > 128) - // dark button, light buttonText - need a darker disabled buttonText - disbtntext = disbtntext.dark(lowlightVal); - else if (disbtntext != Qt::black) - // light buttonText, dark button - need a lighter disabled buttonText - but only if !black - disbtntext = disbtntext.light(highlightVal); - else - // black button - use darkgray disabled buttonText - disbtntext = Qt::darkGray; - - disabledgrp.setColor(TQColorGroup::ButtonText, disbtntext); - disabledgrp.setColor(TQColorGroup::Midlight, background.light(110)); - disabledgrp.setColor(TQColorGroup::Highlight, highlight.dark(120)); - disabledgrp.setColor(TQColorGroup::Link, link); - disabledgrp.setColor(TQColorGroup::LinkVisited, visitedLink); - - return TQPalette(colgrp, disabledgrp, colgrp); -} - - -void KApplication::kdisplaySetPalette() -{ -#ifdef Q_WS_MACX - //Can I have this on other platforms, please!? --Sam - { - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver( config, "General" ); - bool do_not_set_palette = FALSE; - if(config->readBoolEntry("nopaletteChange", &do_not_set_palette)) - return; - } -#endif - TQApplication::tqsetPalette( createApplicationPalette(), true); - emit kdisplayPaletteChanged(); - emit appearanceChanged(); -} - - -void KApplication::kdisplaySetFont() -{ - TQApplication::tqsetFont(KGlobalSettings::generalFont(), true); - TQApplication::tqsetFont(KGlobalSettings::menuFont(), true, TQMENUBAR_OBJECT_NAME_STRING); - TQApplication::tqsetFont(KGlobalSettings::menuFont(), true, TQPOPUPMENU_OBJECT_NAME_STRING); - TQApplication::tqsetFont(KGlobalSettings::menuFont(), true, "KPopupTitle"); - - // "patch" standard TQStyleSheet to follow our fonts - TQStyleSheet* sheet = TQStyleSheet::defaultSheet(); - sheet->item ("pre")->setFontFamily (KGlobalSettings::fixedFont().family()); - sheet->item ("code")->setFontFamily (KGlobalSettings::fixedFont().family()); - sheet->item ("tt")->setFontFamily (KGlobalSettings::fixedFont().family()); - - emit kdisplayFontChanged(); - emit appearanceChanged(); -} - - -void KApplication::kdisplaySetStyle() -{ - if (useStyles) - { - applyGUIStyle(); - emit kdisplayStyleChanged(); - emit appearanceChanged(); - } -} - - -void KApplication::propagateSettings(SettingsCategory arg) -{ - KConfigBase* config = KGlobal::config(); - KConfigGroupSaver saver( config, "KDE" ); - -#ifdef QT_HAVE_MAX_IMAGE_SIZE - TQSize maxImageSize(4096, 4096); - maxImageSize = config->readSizeEntry("MaxImageSize", &maxImageSize); - TQImage::setMaxImageSize(maxImageSize); -#endif - - int num = config->readNumEntry("CursorBlinkRate", TQApplication::cursorFlashTime()); - if ((num != 0) && (num < 200)) - num = 200; - if (num > 2000) - num = 2000; - TQApplication::setCursorFlashTime(num); - num = config->readNumEntry("DoubleClickInterval", TQApplication::doubleClickInterval()); - TQApplication::setDoubleClickInterval(num); - num = config->readNumEntry("StartDragTime", TQApplication::startDragTime()); - TQApplication::setStartDragTime(num); - num = config->readNumEntry("StartDragDist", TQApplication::startDragDistance()); - TQApplication::setStartDragDistance(num); - num = config->readNumEntry("WheelScrollLines", TQApplication::wheelScrollLines()); - TQApplication::setWheelScrollLines(num); - - bool b = config->readBoolEntry("EffectAnimateMenu", false); - TQApplication::setEffectEnabled( Qt::UI_AnimateMenu, b); - b = config->readBoolEntry("EffectFadeMenu", false); - TQApplication::setEffectEnabled( Qt::UI_FadeMenu, b); - b = config->readBoolEntry("EffectAnimateCombo", false); - TQApplication::setEffectEnabled( Qt::UI_AnimateCombo, b); - b = config->readBoolEntry("EffectAnimateTooltip", false); - TQApplication::setEffectEnabled( Qt::UI_AnimateTooltip, b); - b = config->readBoolEntry("EffectFadeTooltip", false); - TQApplication::setEffectEnabled( Qt::UI_FadeTooltip, b); - b = !config->readBoolEntry("EffectNoTooltip", false); - TQToolTip::setGloballyEnabled( b ); - - emit settingsChanged(arg); -} - -void KApplication::installKDEPropertyMap() -{ -#ifndef QT_NO_SQL - static bool installed = false; - if (installed) return; - installed = true; - /** - * If you are adding a widget that was missing please - * make sure to also add it to KConfigDialogManager's retrieveSettings() - * function. - * Thanks. - */ - // TQSqlPropertyMap takes ownership of the new default map. - TQSqlPropertyMap *kdeMap = new TQSqlPropertyMap; - kdeMap->insert( "KColorButton", "color" ); - kdeMap->insert( "KComboBox", "currentItem" ); - kdeMap->insert( "KDatePicker", "date" ); - kdeMap->insert( "KDateWidget", "date" ); - kdeMap->insert( "KDateTimeWidget", "dateTime" ); - kdeMap->insert( "KEditListBox", "items" ); - kdeMap->insert( "KFontCombo", "family" ); - kdeMap->insert( "KFontRequester", "font" ); - kdeMap->insert( "KFontChooser", "font" ); - kdeMap->insert( "KHistoryCombo", "currentItem" ); - kdeMap->insert( "KListBox", "currentItem" ); - kdeMap->insert( "KLineEdit", "text" ); - kdeMap->insert( "KRestrictedLine", "text" ); - kdeMap->insert( "KSqueezedTextLabel", "text" ); - kdeMap->insert( "KTextBrowser", "source" ); - kdeMap->insert( "KTextEdit", "text" ); - kdeMap->insert( "KURLRequester", "url" ); - kdeMap->insert( "KPasswordEdit", "password" ); - kdeMap->insert( "KIntNumInput", "value" ); - kdeMap->insert( "KIntSpinBox", "value" ); - kdeMap->insert( "KDoubleNumInput", "value" ); - // Temp til fixed in QT then enable ifdef with the correct version num - kdeMap->insert( TQGROUPBOX_OBJECT_NAME_STRING, "checked" ); - kdeMap->insert( TQTABWIDGET_OBJECT_NAME_STRING, "currentPage" ); - TQSqlPropertyMap::installDefaultMap( kdeMap ); -#endif -} - -void KApplication::invokeHelp( const TQString& anchor, - const TQString& _appname) const -{ - return invokeHelp( anchor, _appname, "" ); -} - -#ifndef Q_WS_WIN -// for win32 we're using simple help tools like Qt Assistant, -// see kapplication_win.cpp -void KApplication::invokeHelp( const TQString& anchor, - const TQString& _appname, - const TQCString& startup_id ) const -{ - TQString url; - TQString appname; - if (_appname.isEmpty()) - appname = name(); - else - appname = _appname; - - if (!anchor.isEmpty()) - url = TQString("help:/%1?anchor=%2").arg(appname).arg(anchor); - else - url = TQString("help:/%1/index.html").arg(appname); - - TQString error; - if ( !dcopClient()->isApplicationRegistered("khelpcenter") ) - { - if (startServiceByDesktopName("khelpcenter", url, &error, 0, 0, startup_id, false)) - { - if (Tty != kapp->type()) - TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Help Center"), - i18n("Could not launch the KDE Help Center:\n\n%1").arg(error), i18n("&OK")); - else - kdWarning() << "Could not launch help:\n" << error << endl; - return; - } - } - else - DCOPRef( "khelpcenter", "KHelpCenterIface" ).send( "openUrl", url, startup_id ); -} -#endif - -void KApplication::invokeHTMLHelp( const TQString& _filename, const TQString& topic ) const -{ - kdWarning() << "invoking HTML help is deprecated! use docbook and invokeHelp!\n"; - - TQString filename; - - if( _filename.isEmpty() ) - filename = TQString(name()) + "/index.html"; - else - filename = _filename; - - TQString url; - if (!topic.isEmpty()) - url = TQString("help:/%1#%2").arg(filename).arg(topic); - else - url = TQString("help:/%1").arg(filename); - - TQString error; - if ( !dcopClient()->isApplicationRegistered("khelpcenter") ) - { - if (startServiceByDesktopName("khelpcenter", url, &error, 0, 0, "", false)) - { - if (Tty != kapp->type()) - TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Help Center"), - i18n("Could not launch the KDE Help Center:\n\n%1").arg(error), i18n("&OK")); - else - kdWarning() << "Could not launch help:\n" << error << endl; - return; - } - } - else - DCOPRef( "khelpcenter", "KHelpCenterIface" ).send( "openUrl", url ); -} - - -void KApplication::invokeMailer(const TQString &address, const TQString &subject) -{ - return invokeMailer(address,subject,""); -} - -void KApplication::invokeMailer(const TQString &address, const TQString &subject, const TQCString& startup_id) -{ - invokeMailer(address, TQString::null, TQString::null, subject, TQString::null, TQString::null, - TQStringList(), startup_id ); -} - -void KApplication::invokeMailer(const KURL &mailtoURL) -{ - return invokeMailer( mailtoURL, "" ); -} - -void KApplication::invokeMailer(const KURL &mailtoURL, const TQCString& startup_id ) -{ - return invokeMailer( mailtoURL, startup_id, false); -} - -void KApplication::invokeMailer(const KURL &mailtoURL, const TQCString& startup_id, bool allowAttachments ) -{ - TQString address = KURL::decode_string(mailtoURL.path()), subject, cc, bcc, body; - TQStringList queries = TQStringList::split('&', mailtoURL.query().mid(1)); - TQStringList attachURLs; - for (TQStringList::Iterator it = queries.begin(); it != queries.end(); ++it) - { - TQString q = (*it).lower(); - if (q.startsWith("subject=")) - subject = KURL::decode_string((*it).mid(8)); - else - if (q.startsWith("cc=")) - cc = cc.isEmpty()? KURL::decode_string((*it).mid(3)): cc + ',' + KURL::decode_string((*it).mid(3)); - else - if (q.startsWith("bcc=")) - bcc = bcc.isEmpty()? KURL::decode_string((*it).mid(4)): bcc + ',' + KURL::decode_string((*it).mid(4)); - else - if (q.startsWith("body=")) - body = KURL::decode_string((*it).mid(5)); - else - if (allowAttachments && q.startsWith("attach=")) - attachURLs.push_back(KURL::decode_string((*it).mid(7))); - else - if (allowAttachments && q.startsWith("attachment=")) - attachURLs.push_back(KURL::decode_string((*it).mid(11))); - else - if (q.startsWith("to=")) - address = address.isEmpty()? KURL::decode_string((*it).mid(3)): address + ',' + KURL::decode_string((*it).mid(3)); - } - - invokeMailer( address, cc, bcc, subject, body, TQString::null, attachURLs, startup_id ); -} - -void KApplication::invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc, - const TQString &subject, const TQString &body, - const TQString & messageFile, const TQStringList &attachURLs) -{ - return invokeMailer(to,cc,bcc,subject,body,messageFile,attachURLs,""); -} - -#ifndef Q_WS_WIN -// on win32, for invoking browser we're using win32 API -// see kapplication_win.cpp - -static TQStringList splitEmailAddressList( const TQString & aStr ) -{ - // This is a copy of KPIM::splitEmailAddrList(). - // Features: - // - always ignores quoted characters - // - ignores everything (including parentheses and commas) - // inside quoted strings - // - supports nested comments - // - ignores everything (including double quotes and commas) - // inside comments - - TQStringList list; - - if (aStr.isEmpty()) - return list; - - TQString addr; - uint addrstart = 0; - int commentlevel = 0; - bool insidequote = false; - - for (uint index=0; index<aStr.length(); index++) { - // the following conversion to latin1 is o.k. because - // we can safely ignore all non-latin1 characters - switch (aStr[index].latin1()) { - case '"' : // start or end of quoted string - if (commentlevel == 0) - insidequote = !insidequote; - break; - case '(' : // start of comment - if (!insidequote) - commentlevel++; - break; - case ')' : // end of comment - if (!insidequote) { - if (commentlevel > 0) - commentlevel--; - else { - //kdDebug() << "Error in address splitting: Unmatched ')'" - // << endl; - return list; - } - } - break; - case '\\' : // quoted character - index++; // ignore the quoted character - break; - case ',' : - if (!insidequote && (commentlevel == 0)) { - addr = aStr.mid(addrstart, index-addrstart); - if (!addr.isEmpty()) - list += addr.simplifyWhiteSpace(); - addrstart = index+1; - } - break; - } - } - // append the last address to the list - if (!insidequote && (commentlevel == 0)) { - addr = aStr.mid(addrstart, aStr.length()-addrstart); - if (!addr.isEmpty()) - list += addr.simplifyWhiteSpace(); - } - //else - // kdDebug() << "Error in address splitting: " - // << "Unexpected end of address list" - // << endl; - - return list; -} - -void KApplication::invokeMailer(const TQString &_to, const TQString &_cc, const TQString &_bcc, - const TQString &subject, const TQString &body, - const TQString & /*messageFile TODO*/, const TQStringList &attachURLs, - const TQCString& startup_id ) -{ - KConfig config("emaildefaults"); - - config.setGroup("Defaults"); - TQString group = config.readEntry("Profile","Default"); - - config.setGroup( TQString("PROFILE_%1").arg(group) ); - TQString command = config.readPathEntry("EmailClient"); - - TQString to, cc, bcc; - if (command.isEmpty() || command == TQString::tqfromLatin1("kmail") - || command.endsWith("/kmail")) - { - command = TQString::tqfromLatin1("kmail --composer -s %s -c %c -b %b --body %B --attach %A -- %t"); - if ( !_to.isEmpty() ) - { - // put the whole address lists into RFC2047 encoded blobs; technically - // this isn't correct, but KMail understands it nonetheless - to = TQString( "=?utf8?b?%1?=" ) - .arg( QString(KCodecs::base64Encode( _to.utf8(), false )) ); - } - if ( !_cc.isEmpty() ) - cc = TQString( "=?utf8?b?%1?=" ) - .arg( QString(KCodecs::base64Encode( _cc.utf8(), false )) ); - if ( !_bcc.isEmpty() ) - bcc = TQString( "=?utf8?b?%1?=" ) - .arg( QString(KCodecs::base64Encode( _bcc.utf8(), false )) ); - } else { - to = _to; - cc = _cc; - bcc = _bcc; - if( !command.contains( '%' )) - command += " %u"; - } - - if (config.readBoolEntry("TerminalClient", false)) - { - KConfigGroup confGroup( KGlobal::config(), "General" ); - TQString preferredTerminal = confGroup.readPathEntry("TerminalApplication", "konsole"); - command = preferredTerminal + " -e " + command; - } - - TQStringList cmdTokens = KShell::splitArgs(command); - TQString cmd = cmdTokens[0]; - cmdTokens.remove(cmdTokens.begin()); - - KURL url; - TQStringList qry; - if (!to.isEmpty()) - { - TQStringList tos = splitEmailAddressList( to ); - url.setPath( tos.first() ); - tos.remove( tos.begin() ); - for (TQStringList::ConstIterator it = tos.begin(); it != tos.end(); ++it) - qry.append( "to=" + KURL::encode_string( *it ) ); - } - const TQStringList ccs = splitEmailAddressList( cc ); - for (TQStringList::ConstIterator it = ccs.begin(); it != ccs.end(); ++it) - qry.append( "cc=" + KURL::encode_string( *it ) ); - const TQStringList bccs = splitEmailAddressList( bcc ); - for (TQStringList::ConstIterator it = bccs.begin(); it != bccs.end(); ++it) - qry.append( "bcc=" + KURL::encode_string( *it ) ); - for (TQStringList::ConstIterator it = attachURLs.begin(); it != attachURLs.end(); ++it) - qry.append( "attach=" + KURL::encode_string( *it ) ); - if (!subject.isEmpty()) - qry.append( "subject=" + KURL::encode_string( subject ) ); - if (!body.isEmpty()) - qry.append( "body=" + KURL::encode_string( body ) ); - url.setQuery( qry.join( "&" ) ); - if ( ! (to.isEmpty() && qry.isEmpty()) ) - url.setProtocol("mailto"); - - TQMap<TQChar, TQString> keyMap; - keyMap.insert('t', to); - keyMap.insert('s', subject); - keyMap.insert('c', cc); - keyMap.insert('b', bcc); - keyMap.insert('B', body); - keyMap.insert('u', url.url()); - - TQString attachlist = attachURLs.join(","); - attachlist.prepend('\''); - attachlist.append('\''); - keyMap.insert('A', attachlist); - - for (TQStringList::Iterator it = cmdTokens.begin(); it != cmdTokens.end(); ) - { - if (*it == "%A") - { - if (it == cmdTokens.begin()) // better safe than sorry ... - continue; - TQStringList::ConstIterator urlit = attachURLs.begin(); - TQStringList::ConstIterator urlend = attachURLs.end(); - if ( urlit != urlend ) - { - TQStringList::Iterator previt = it; - --previt; - *it = *urlit; - ++it; - while ( ++urlit != urlend ) - { - cmdTokens.insert( it, *previt ); - cmdTokens.insert( it, *urlit ); - } - } else { - --it; - it = cmdTokens.remove( cmdTokens.remove( it ) ); - } - } else { - *it = KMacroExpander::expandMacros(*it, keyMap); - ++it; - } - } - - TQString error; - // TODO this should check if cmd has a .desktop file, and use data from it, together - // with sending more ASN data - if (tdeinitExec(cmd, cmdTokens, &error, NULL, startup_id )) - if (Tty != kapp->type()) - TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Mail Client"), - i18n("Could not launch the mail client:\n\n%1").arg(error), i18n("&OK")); - else - kdWarning() << "Could not launch mail client:\n" << error << endl; -} -#endif - -void KApplication::invokeBrowser( const TQString &url ) -{ - return invokeBrowser( url, "" ); -} - -#ifndef Q_WS_WIN -// on win32, for invoking browser we're using win32 API -// see kapplication_win.cpp -void KApplication::invokeBrowser( const TQString &url, const TQCString& startup_id ) -{ - TQString error; - - if (startServiceByDesktopName("kfmclient", url, &error, 0, 0, startup_id, false)) - { - if (Tty != kapp->type()) - TQMessageBox::critical(kapp->mainWidget(), i18n("Could not Launch Browser"), - i18n("Could not launch the browser:\n\n%1").arg(error), i18n("&OK")); - else - kdWarning() << "Could not launch browser:\n" << error << endl; - return; - } -} -#endif - -void KApplication::cut() -{ - invokeEditSlot( TQT_SLOT( cut() ) ); -} - -void KApplication::copy() -{ - invokeEditSlot( TQT_SLOT( copy() ) ); -} - -void KApplication::paste() -{ - invokeEditSlot( TQT_SLOT( paste() ) ); -} - -void KApplication::clear() -{ - invokeEditSlot( TQT_SLOT( clear() ) ); -} - -void KApplication::selectAll() -{ - invokeEditSlot( TQT_SLOT( selectAll() ) ); -} - -void KApplication::broadcastKeyCode(unsigned int keyCode) -{ - emit coreFakeKeyPress(keyCode); -} - -TQCString -KApplication::launcher() -{ - return "klauncher"; -} - -static int -startServiceInternal( const TQCString &function, - const TQString& _name, const TQStringList &URLs, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - struct serviceResult - { - int result; - TQCString dcopName; - TQString error; - pid_t pid; - }; - - // Register app as able to send DCOP messages - DCOPClient *dcopClient; - if (kapp) - dcopClient = kapp->dcopClient(); - else - dcopClient = new DCOPClient; - - if (!dcopClient->isAttached()) - { - if (!dcopClient->attach()) - { - if (error) - *error = i18n("Could not register with DCOP.\n"); - if (!kapp) - delete dcopClient; - - return -1; - } - } - TQByteArray params; - TQDataStream stream(params, IO_WriteOnly); - stream << _name << URLs; - TQCString replyType; - TQByteArray replyData; - TQCString _launcher = KApplication::launcher(); - TQValueList<TQCString> envs; -#ifdef Q_WS_X11 - if (qt_xdisplay()) { - TQCString dpystring(XDisplayString(qt_xdisplay())); - envs.append( TQCString("DISPLAY=") + dpystring ); - } else if( getenv( "DISPLAY" )) { - TQCString dpystring( getenv( "DISPLAY" )); - envs.append( TQCString("DISPLAY=") + dpystring ); - } -#endif - stream << envs; -#if defined Q_WS_X11 - // make sure there is id, so that user timestamp exists - stream << ( startup_id.isEmpty() ? KStartupInfo::createNewStartupId() : startup_id ); -#endif - if( function.left( 12 ) != "tdeinit_exec" ) - stream << noWait; - - if (!dcopClient->call(_launcher, _launcher, - function, params, replyType, replyData)) - { - if (error) - *error = i18n("KLauncher could not be reached via DCOP.\n"); - if (!kapp) - delete dcopClient; - return -1; - } - if (!kapp) - delete dcopClient; - - if (noWait) - return 0; - - TQDataStream stream2(replyData, IO_ReadOnly); - serviceResult result; - stream2 >> result.result >> result.dcopName >> result.error >> result.pid; - if (dcopService) - *dcopService = result.dcopName; - if (error) - *error = result.error; - if (pid) - *pid = result.pid; - return result.result; -} - -int -KApplication::startServiceByName( const TQString& _name, const TQString &URL, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - TQStringList URLs; - if (!URL.isEmpty()) - URLs.append(URL); - return startServiceInternal( - "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)", - _name, URLs, error, dcopService, pid, startup_id, noWait); -} - -int -KApplication::startServiceByName( const TQString& _name, const TQStringList &URLs, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - return startServiceInternal( - "start_service_by_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)", - _name, URLs, error, dcopService, pid, startup_id, noWait); -} - -int -KApplication::startServiceByDesktopPath( const TQString& _name, const TQString &URL, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - TQStringList URLs; - if (!URL.isEmpty()) - URLs.append(URL); - return startServiceInternal( - "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)", - _name, URLs, error, dcopService, pid, startup_id, noWait); -} - -int -KApplication::startServiceByDesktopPath( const TQString& _name, const TQStringList &URLs, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - return startServiceInternal( - "start_service_by_desktop_path(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)", - _name, URLs, error, dcopService, pid, startup_id, noWait); -} - -int -KApplication::startServiceByDesktopName( const TQString& _name, const TQString &URL, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - TQStringList URLs; - if (!URL.isEmpty()) - URLs.append(URL); - return startServiceInternal( - "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)", - _name, URLs, error, dcopService, pid, startup_id, noWait); -} - -int -KApplication::startServiceByDesktopName( const TQString& _name, const TQStringList &URLs, - TQString *error, TQCString *dcopService, int *pid, const TQCString& startup_id, bool noWait ) -{ - return startServiceInternal( - "start_service_by_desktop_name(TQString,TQStringList,TQValueList<TQCString>,TQCString,bool)", - _name, URLs, error, dcopService, pid, startup_id, noWait); -} - -int -KApplication::tdeinitExec( const TQString& name, const TQStringList &args, - TQString *error, int *pid ) -{ - return tdeinitExec( name, args, error, pid, "" ); -} - -int -KApplication::tdeinitExec( const TQString& name, const TQStringList &args, - TQString *error, int *pid, const TQCString& startup_id ) -{ - return startServiceInternal("tdeinit_exec(TQString,TQStringList,TQValueList<TQCString>,TQCString)", - name, args, error, 0, pid, startup_id, false); -} - -int -KApplication::tdeinitExecWait( const TQString& name, const TQStringList &args, - TQString *error, int *pid ) -{ - return tdeinitExecWait( name, args, error, pid, "" ); -} - -int -KApplication::tdeinitExecWait( const TQString& name, const TQStringList &args, - TQString *error, int *pid, const TQCString& startup_id ) -{ - return startServiceInternal("tdeinit_exec_wait(TQString,TQStringList,TQValueList<TQCString>,TQCString)", - name, args, error, 0, pid, startup_id, false); -} - -TQString KApplication::tempSaveName( const TQString& pFilename ) const -{ - TQString aFilename; - - if( TQDir::isRelativePath(pFilename) ) - { - kdWarning(101) << "Relative filename passed to KApplication::tempSaveName" << endl; - aFilename = TQFileInfo( TQDir( "." ), pFilename ).absFilePath(); - } - else - aFilename = pFilename; - - TQDir aAutosaveDir( TQDir::homeDirPath() + "/autosave/" ); - if( !aAutosaveDir.exists() ) - { - if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) ) - { - // Last chance: use temp dir - aAutosaveDir.setPath( KGlobal::dirs()->saveLocation("tmp") ); - } - } - - aFilename.replace( "/", "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() ); - - return aFilename; -} - - -TQString KApplication::checkRecoverFile( const TQString& pFilename, - bool& bRecover ) const -{ - TQString aFilename; - - if( TQDir::isRelativePath(pFilename) ) - { - kdWarning(101) << "Relative filename passed to KApplication::tempSaveName" << endl; - aFilename = TQFileInfo( TQDir( "." ), pFilename ).absFilePath(); - } - else - aFilename = pFilename; - - TQDir aAutosaveDir( TQDir::homeDirPath() + "/autosave/" ); - if( !aAutosaveDir.exists() ) - { - if( !aAutosaveDir.mkdir( aAutosaveDir.absPath() ) ) - { - // Last chance: use temp dir - aAutosaveDir.setPath( KGlobal::dirs()->saveLocation("tmp") ); - } - } - - aFilename.replace( "/", "\\!" ).prepend( "#" ).append( "#" ).prepend( "/" ).prepend( aAutosaveDir.absPath() ); - - if( TQFile( aFilename ).exists() ) - { - bRecover = true; - return aFilename; - } - else - { - bRecover = false; - return pFilename; - } -} - - -bool checkAccess(const TQString& pathname, int mode) -{ - int accessOK = access( TQFile::encodeName(pathname), mode ); - if ( accessOK == 0 ) - return true; // OK, I can really access the file - - // else - // if we want to write the file would be created. Check, if the - // user may write to the directory to create the file. - if ( (mode & W_OK) == 0 ) - return false; // Check for write access is not part of mode => bail out - - - if (!access( TQFile::encodeName(pathname), F_OK)) // if it already exists - return false; - - //strip the filename (everything until '/' from the end - TQString dirName(pathname); - int pos = dirName.findRev('/'); - if ( pos == -1 ) - return false; // No path in argument. This is evil, we won't allow this - else if ( pos == 0 ) // don't turn e.g. /root into an empty string - pos = 1; - - dirName.truncate(pos); // strip everything starting from the last '/' - - accessOK = access( TQFile::encodeName(dirName), W_OK ); - // -?- Can I write to the accessed diretory - if ( accessOK == 0 ) - return true; // Yes - else - return false; // No -} - -void KApplication::setTopWidget( TQWidget *topWidget ) -{ - if( !topWidget ) - return; - - // set the specified caption - if ( !topWidget->inherits("KMainWindow") ) { // KMainWindow does this already for us - topWidget->setCaption( caption() ); - } - - // set the specified icons - topWidget->setIcon( icon() ); //standard X11 -#if defined Q_WS_X11 -//#ifdef Q_WS_X11 // FIXME(E): Implement for Qt/Embedded - KWin::setIcons(topWidget->winId(), icon(), miniIcon() ); // NET_WM hints for KWin - - // set the app startup notification window property - KStartupInfo::setWindowStartupId( topWidget->winId(), startupId()); -#endif -} - -TQCString KApplication::startupId() const -{ - return d->startup_id; -} - -void KApplication::setStartupId( const TQCString& startup_id ) -{ - if( startup_id == d->startup_id ) - return; -#if defined Q_WS_X11 - KStartupInfo::handleAutoAppStartedSending(); // finish old startup notification if needed -#endif - if( startup_id.isEmpty()) - d->startup_id = "0"; - else - { - d->startup_id = startup_id; -#if defined Q_WS_X11 - KStartupInfoId id; - id.initId( startup_id ); - long timestamp = id.timestamp(); - if( timestamp != 0 ) - updateUserTimestamp( timestamp ); -#endif - } -} - -// read the startup notification env variable, save it and unset it in order -// not to propagate it to processes started from this app -void KApplication::read_app_startup_id() -{ -#if defined Q_WS_X11 - KStartupInfoId id = KStartupInfo::currentStartupIdEnv(); - KStartupInfo::resetStartupEnv(); - d->startup_id = id.id(); -#endif -} - -int KApplication::random() -{ - static bool init = false; - if (!init) - { - unsigned int seed; - init = true; - int fd = open("/dev/urandom", O_RDONLY); - if (fd < 0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed)) - { - // No /dev/urandom... try something else. - srand(getpid()); - seed = rand()+time(0); - } - if (fd >= 0) close(fd); - srand(seed); - } - return rand(); -} - -TQString KApplication::randomString(int length) -{ - if (length <=0 ) return TQString::null; - - TQString str; str.setLength( length ); - int i = 0; - while (length--) - { - int r=random() % 62; - r+=48; - if (r>57) r+=7; - if (r>90) r+=6; - str[i++] = char(r); - // so what if I work backwards? - } - return str; -} - -bool KApplication::authorize(const TQString &genericAction) -{ - if (!d->actionRestrictions) - return true; - - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver( config, "KDE Action Restrictions" ); - return config->readBoolEntry(genericAction, true); -} - -bool KApplication::authorizeKAction(const char *action) -{ - if (!d->actionRestrictions || !action) - return true; - - static const TQString &action_prefix = KGlobal::staticQString( "action/" ); - - return authorize(action_prefix + action); -} - -bool KApplication::authorizeControlModule(const TQString &menuId) -{ - if (menuId.isEmpty() || kde_kiosk_exception) - return true; - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver( config, "KDE Control Module Restrictions" ); - return config->readBoolEntry(menuId, true); -} - -TQStringList KApplication::authorizeControlModules(const TQStringList &menuIds) -{ - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver( config, "KDE Control Module Restrictions" ); - TQStringList result; - for(TQStringList::ConstIterator it = menuIds.begin(); - it != menuIds.end(); ++it) - { - if (config->readBoolEntry(*it, true)) - result.append(*it); - } - return result; -} - -void KApplication::initUrlActionRestrictions() -{ - d->urlActionRestrictions.setAutoDelete(true); - d->urlActionRestrictions.clear(); - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("open", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, true)); - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, true)); -// TEST: -// d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule -// ("list", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, false)); -// d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule -// ("list", TQString::null, TQString::null, TQString::null, "file", TQString::null, TQDir::homeDirPath(), true)); - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("link", TQString::null, TQString::null, TQString::null, ":internet", TQString::null, TQString::null, true)); - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("redirect", TQString::null, TQString::null, TQString::null, ":internet", TQString::null, TQString::null, true)); - - // We allow redirections to file: but not from internet protocols, redirecting to file: - // is very popular among io-slaves and we don't want to break them - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("redirect", TQString::null, TQString::null, TQString::null, "file", TQString::null, TQString::null, true)); - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("redirect", ":internet", TQString::null, TQString::null, "file", TQString::null, TQString::null, false)); - - // local protocols may redirect everywhere - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("redirect", ":local", TQString::null, TQString::null, TQString::null, TQString::null, TQString::null, true)); - - // Anyone may redirect to about: - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("redirect", TQString::null, TQString::null, TQString::null, "about", TQString::null, TQString::null, true)); - - // Anyone may redirect to itself, cq. within it's own group - d->urlActionRestrictions.append( new KApplicationPrivate::URLActionRule - ("redirect", TQString::null, TQString::null, TQString::null, "=", TQString::null, TQString::null, true)); - - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver( config, "KDE URL Restrictions" ); - int count = config->readNumEntry("rule_count"); - TQString keyFormat = TQString("rule_%1"); - for(int i = 1; i <= count; i++) - { - TQString key = keyFormat.arg(i); - TQStringList rule = config->readListEntry(key); - if (rule.count() != 8) - continue; - TQString action = rule[0]; - TQString refProt = rule[1]; - TQString refHost = rule[2]; - TQString refPath = rule[3]; - TQString urlProt = rule[4]; - TQString urlHost = rule[5]; - TQString urlPath = rule[6]; - TQString strEnabled = rule[7].lower(); - - bool bEnabled = (strEnabled == "true"); - - if (refPath.startsWith("$HOME")) - refPath.replace(0, 5, TQDir::homeDirPath()); - else if (refPath.startsWith("~")) - refPath.replace(0, 1, TQDir::homeDirPath()); - if (urlPath.startsWith("$HOME")) - urlPath.replace(0, 5, TQDir::homeDirPath()); - else if (urlPath.startsWith("~")) - urlPath.replace(0, 1, TQDir::homeDirPath()); - - if (refPath.startsWith("$TMP")) - refPath.replace(0, 4, KGlobal::dirs()->saveLocation("tmp")); - if (urlPath.startsWith("$TMP")) - urlPath.replace(0, 4, KGlobal::dirs()->saveLocation("tmp")); - - d->urlActionRestrictions.append(new KApplicationPrivate::URLActionRule - ( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled)); - } -} - -void KApplication::allowURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL) -{ - if (authorizeURLAction(action, _baseURL, _destURL)) - return; - - d->urlActionRestrictions.append(new KApplicationPrivate::URLActionRule - ( action, _baseURL.protocol(), _baseURL.host(), _baseURL.path(-1), - _destURL.protocol(), _destURL.host(), _destURL.path(-1), true)); -} - -bool KApplication::authorizeURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL) -{ - if (_destURL.isEmpty()) - return true; - - bool result = false; - if (d->urlActionRestrictions.isEmpty()) - initUrlActionRestrictions(); - - KURL baseURL(_baseURL); - baseURL.setPath(TQDir::cleanDirPath(baseURL.path())); - TQString baseClass = KProtocolInfo::protocolClass(baseURL.protocol()); - KURL destURL(_destURL); - destURL.setPath(TQDir::cleanDirPath(destURL.path())); - TQString destClass = KProtocolInfo::protocolClass(destURL.protocol()); - - for(KApplicationPrivate::URLActionRule *rule = d->urlActionRestrictions.first(); - rule; rule = d->urlActionRestrictions.next()) - { - if ((result != rule->permission) && // No need to check if it doesn't make a difference - (action == rule->action) && - rule->baseMatch(baseURL, baseClass) && - rule->destMatch(destURL, destClass, baseURL, baseClass)) - { - result = rule->permission; - } - } - return result; -} - - -uint KApplication::keyboardModifiers() -{ -#ifdef Q_WS_X11 - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint keybstate; - XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, - &root_x, &root_y, &win_x, &win_y, &keybstate ); - return keybstate & 0x00ff; -#elif defined W_WS_MACX - return GetCurrentEventKeyModifiers() & 0x00ff; -#else - //TODO for win32 - return 0; -#endif -} - -uint KApplication::mouseState() -{ - uint mousestate; -#ifdef Q_WS_X11 - Window root; - Window child; - int root_x, root_y, win_x, win_y; - XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, - &root_x, &root_y, &win_x, &win_y, &mousestate ); -#elif defined(Q_WS_WIN) - const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON); - if (GetAsyncKeyState(VK_LBUTTON)) - mousestate |= (mousebtn_swapped ? Button3Mask : Button1Mask); - if (GetAsyncKeyState(VK_MBUTTON)) - mousestate |= Button2Mask; - if (GetAsyncKeyState(VK_RBUTTON)) - mousestate |= (mousebtn_swapped ? Button1Mask : Button3Mask); -#elif defined(Q_WS_MACX) - mousestate = GetCurrentEventButtonState(); -#else - //TODO: other platforms -#endif - return mousestate & 0xff00; -} - -TQ_ButtonState KApplication::keyboardMouseState() -{ - int ret = 0; -#ifdef Q_WS_X11 - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint state; - XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, - &root_x, &root_y, &win_x, &win_y, &state ); - // transform the same way like Qt's qt_x11_translateButtonState() - if( state & Button1Mask ) - ret |= TQ_LeftButton; - if( state & Button2Mask ) - ret |= TQ_MidButton; - if( state & Button3Mask ) - ret |= TQ_RightButton; - if( state & ShiftMask ) - ret |= TQ_ShiftButton; - if( state & ControlMask ) - ret |= TQ_ControlButton; - if( state & KKeyNative::modX( KKey::ALT )) - ret |= TQ_AltButton; - if( state & KKeyNative::modX( KKey::WIN )) - ret |= TQ_MetaButton; -#elif defined(Q_WS_WIN) - const bool mousebtn_swapped = GetSystemMetrics(SM_SWAPBUTTON); - if (GetAsyncKeyState(VK_LBUTTON)) - ret |= (mousebtn_swapped ? RightButton : LeftButton); - if (GetAsyncKeyState(VK_MBUTTON)) - ret |= TQ_MidButton; - if (GetAsyncKeyState(VK_RBUTTON)) - ret |= (mousebtn_swapped ? TQ_LeftButton : TQ_RightButton); - if (GetAsyncKeyState(VK_SHIFT)) - ret |= TQ_ShiftButton; - if (GetAsyncKeyState(VK_CONTROL)) - ret |= TQ_ControlButton; - if (GetAsyncKeyState(VK_MENU)) - ret |= TQ_AltButton; - if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) - ret |= TQ_MetaButton; -#else - //TODO: other platforms -#endif - return static_cast< ButtonState >( ret ); -} - -void KApplication::installSigpipeHandler() -{ -#ifdef Q_OS_UNIX - struct sigaction act; - act.sa_handler = SIG_IGN; - sigemptyset( &act.sa_mask ); - act.sa_flags = 0; - sigaction( SIGPIPE, &act, 0 ); -#endif -} - -void KApplication::sigpipeHandler(int) -{ - int saved_errno = errno; - // Using kdDebug from a signal handler is not a good idea. -#ifndef NDEBUG - char msg[1000]; - sprintf(msg, "*** SIGPIPE *** (ignored, pid = %ld)\n", (long) getpid()); - write(2, msg, strlen(msg)); -#endif - - // Do nothing. - errno = saved_errno; -} - -bool KApplication::guiEnabled() -{ - return kapp && kapp->d->guiEnabled; -} - -void KApplication::virtual_hook( int id, void* data ) -{ KInstance::virtual_hook( id, data ); } - -void KSessionManaged::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kapplication.moc" diff --git a/kdecore/kapplication.h b/kdecore/kapplication.h deleted file mode 100644 index f1be3bfb8..000000000 --- a/kdecore/kapplication.h +++ /dev/null @@ -1,1620 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (c) 1998, 1999 KDE Team - - 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 _KAPP_H -#define _KAPP_H - -// Version macros. Never put this further down. -#include "kdeversion.h" -#include "kdelibs_export.h" - -class KConfig; -class KCharsets; -class DCOPClient; -class DCOPObject; - -#include <tqtglobaldefines.h> - -typedef unsigned long Atom; -#if !defined(Q_WS_X11) -typedef void Display; -#endif - -#include <tqapplication.h> -#include <tqpixmap.h> -#include <kinstance.h> - -struct _IceConn; -class TQPopupMenu; -class TQStrList; -class KSessionManaged; -class KStyle; -class KURL; - -#define kapp KApplication::kApplication() - -class KApplicationPrivate; - -/** -* Controls and provides information to all KDE applications. -* -* Only one object of this class can be instantiated in a single app. -* This instance is always accessible via the 'kapp' global variable. -* See cut() for an example. -* -* This class provides the following services to all KDE applications. -* -* @li It controls the event queue (see TQApplication ). -* @li It provides the application with KDE resources such as -* accelerators, common menu entries, a KConfig object. session -* management events, help invocation etc. -* @li Installs a signal handler for the SIGCHLD signal in order to -* avoid zombie children. If you want to catch this signal yourself or -* don't want it to be caught at all, you have set a new signal handler -* (or SIG_IGN) after KApplication's constructor has run. -* @li Installs an empty signal handler for the SIGPIPE signal using -* installSigpipeHandler(). If you want to catch this signal -* yourself, you have set a new signal handler after KApplication's -* constructor has run. -* @li It can start new services -* -* -* The way a service gets started depends on the 'X-DCOP-ServiceType' -* entry in the desktop file of the service: -* -* There are three possibilities: -* @li X-DCOP-ServiceType=None (default) -* Always start a new service, -* don't wait till the service registers with dcop. -* @li X-DCOP-ServiceType=Multi -* Always start a new service, -* wait until the service has registered with dcop. -* @li X-DCOP-ServiceType=Unique -* Only start the service if it isn't already running, -* wait until the service has registered with dcop. -* -* @short Controls and provides information to all KDE applications. -* @author Matthias Kalle Dalheimer <kalle@kde.org> -*/ -class KDECORE_EXPORT KApplication : public TQApplication, public KInstance -{ - - Q_OBJECT -public: - /** Position of the caption (presumably in the application window's - * title bar). This enum appears to be unused. - * - * @todo Find out if this is used anywhere. - */ - enum CaptionLayout { - CaptionAppLast=1 /**< Display the application name last (before document name). */, - CaptionAppFirst /**< Display the application name first. */ , - CaptionNoApp /**< Do not display application name at all. */ - }; - - /** - * This constructor takes aboutData and command line - * arguments from KCmdLineArgs. - * - * If ARGB (transparent) widgets are to be used in your application, - * please use - * KApplication app(KApplication::openX11RGBADisplay()); - * or - * KApplication app(KApplication::openX11RGBADisplay(), useStyles); - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * it normally runs in the background but under special circumstances - * displays widgets. Call enableStyles() before displaying any widgets. - * - * @param GUIenabled Set to false to disable all GUI stuff. This implies - * no styles either. - */ - KApplication( bool allowStyles=true, bool GUIenabled=true); - -#ifdef Q_WS_X11 - /** - * Constructor. Parses command-line arguments. Use this constructor when you - * you want ARGB support to be automatically detected and enabled. - * - * @param display Will be passed to Qt as the X display. The display must be - * valid and already opened. - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * that normally runs in the background but under special circumstances - * displays widgets call enableStyles() before displaying any widgets. - * - * @since KDE 3.5 - * - * @see RGBADisplay() - */ - KApplication(Display *display, bool allowStyles); - - /** - * Constructor. Parses command-line arguments. Use this constructor when you - * you want ARGB support to be automatically detected and enabled. - * - * @param display Will be passed to Qt as the X display. The display must be - * valid and already opened. - * - * @param disable_argb Set to true to disable ARGB visuals in this application. - * - * @param display Will be passed to Qt as the X display. The display must be - * valid and already opened. - * - * @param visual A pointer to the X11 visual that should be used by the - * appliction. Note that only TrueColor visuals are supported on depths - * greater than 8 bpp. If this parameter is NULL, the default visual will - * be used instead. - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * that normally runs in the background but under special circumstances - * displays widgets call enableStyles() before displaying any widgets. - * - * @since KDE 3.5 - * - * @see RGBADisplay() - */ - KApplication(Display *display, bool disable_argb, Qt::HANDLE visual, Qt::HANDLE colormap, bool allowStyles); - - /** - * Constructor. Parses command-line arguments. Use this constructor when you - * you need to use a non-default visual or colormap. - * - * @param display Will be passed to Qt as the X display. The display must be - * valid and already opened. - * - * @param visual A pointer to the X11 visual that should be used by the - * appliction. Note that only TrueColor visuals are supported on depths - * greater than 8 bpp. If this parameter is NULL, the default visual will - * be used instead. - * - * @param colormap The colormap that should be used by the application. If - * this parameter is 0, the default colormap will be used instead. - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * that normally runs in the background but under special circumstances - * displays widgets call enableStyles() before displaying any widgets. - * - * @since KDE 3.3 - */ - KApplication(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0, - bool allowStyles=true); - - /** - * Constructor. Parses command-line arguments. Use this constructor to use KApplication - * in a Motif or Xt program. - * - * @param display Will be passed to Qt as the X display. The display must be valid and already - * opened. - * - * @param argc command line argument count - * - * @param argv command line argument value(s) - * - * @param rAppName application name. Will be used for finding the - * associated message files and icon files, and as the default - * registration name for DCOP. This is a mandatory parameter. - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * that normally runs in the background but under special circumstances - * displays widgets call enableStyles() before displaying any widgets. - * - * @param GUIenabled Set to false to disable all GUI stuff. This implies - * no styles either. - */ - KApplication(Display *display, int& argc, char** argv, const TQCString& rAppName, - bool allowStyles=true, bool GUIenabled=true); -#endif - - /** - * @deprecated do not use it at all, it will make your application crash, use KCmdLineArgs - * - * Constructor. Parses command-line arguments. - * - * @param argc command line argument count - * - * @param argv command line argument value(s) - * - * @param rAppName application name. Will be used for finding the - * associated message files and icon files, and as the default - * registration name for DCOP. This is a mandatory parameter. - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * that normally runs in the background but under special circumstances - * displays widgets call enableStyles() before displaying any widgets. - * - * @param GUIenabled Set to false to disable all GUI stuff. This implies - * no styles either. - */ - // REMOVE FOR KDE 4.0 - using it only gives crashing applications because - // KCmdLineArgs::init isn't called - KApplication(int& argc, char** argv, - const TQCString& rAppName, bool allowStyles=true, bool GUIenabled=true) KDE_DEPRECATED; - - /** - * Add Qt and KDE command line options to KCmdLineArgs. - */ - static void addCmdLineOptions(); - - virtual ~KApplication(); - - /** - * Returns the current application object. - * - * This is similar to the global TQApplication pointer tqApp. It - * allows access to the single global KApplication object, since - * more than one cannot be created in the same application. It - * saves you the trouble of having to pass the pointer explicitly - * to every function that may require it. - * @return the current application object - */ - static KApplication* kApplication() { return KApp; } - - /** - * Returns the application session config object. - * - * @return A pointer to the application's instance specific - * KConfig object. - * @see KConfig - */ - KConfig* sessionConfig(); - - /** - * Is the application restored from the session manager? - * - * @return If true, this application was restored by the session manager. - * Note that this may mean the config object returned by - * sessionConfig() contains data saved by a session closedown. - * @see sessionConfig() - */ - bool isRestored() const { return TQApplication::isSessionRestored(); } - - /** - * Disables session management for this application. - * - * Useful in case your application is started by the - * initial "startkde" script. - */ - void disableSessionManagement(); - - /** - * Enables again session management for this application, formerly - * disabled by calling disableSessionManagement(). You usually - * shouldn't call this function, as the session management is enabled - * by default. - */ - void enableSessionManagement(); - - /** - * The possible values for the @p confirm parameter of requestShutDown(). - */ - enum ShutdownConfirm { - /** - * Obey the user's confirmation setting. - */ - ShutdownConfirmDefault = -1, - /** - * Don't confirm, shutdown without asking. - */ - ShutdownConfirmNo = 0, - /** - * Always confirm, ask even if the user turned it off. - */ - ShutdownConfirmYes = 1 - }; - - /** - * The possible values for the @p sdtype parameter of requestShutDown(). - */ - enum ShutdownType { - /** - * Select previous action or the default if it's the first time. - */ - ShutdownTypeDefault = -1, - /** - * Only log out. - */ - ShutdownTypeNone = 0, - /** - * Log out and reboot the machine. - */ - ShutdownTypeReboot = 1, - /** - * Log out and halt the machine. - */ - ShutdownTypeHalt = 2 - }; - - /** - * The possible values for the @p sdmode parameter of requestShutDown(). - */ - enum ShutdownMode { - /** - * Select previous mode or the default if it's the first time. - */ - ShutdownModeDefault = -1, - /** - * Schedule a shutdown (halt or reboot) for the time all active sessions - * have exited. - */ - ShutdownModeSchedule = 0, - /** - * Shut down, if no sessions are active. Otherwise do nothing. - */ - ShutdownModeTryNow = 1, - /** - * Force shutdown. Kill any possibly active sessions. - */ - ShutdownModeForceNow = 2, - /** - * Pop up a dialog asking the user what to do if sessions are still active. - */ - ShutdownModeInteractive = 3 - }; - - /** - * Asks the session manager to shut the session down. - * - * Using @p confirm == ShutdownConfirmYes or @p sdtype != ShutdownTypeDefault or - * @p sdmode != ShutdownModeDefault causes the use of ksmserver's DCOP - * interface. The remaining two combinations use the standard XSMP and - * will work with any session manager compliant with it. - * - * @param confirm Whether to ask the user if he really wants to log out. - * ShutdownConfirm - * @param sdtype The action to take after logging out. ShutdownType - * @param sdmode If/When the action should be taken. ShutdownMode - * @return true on success, false if the session manager could not be - * contacted. - */ - bool requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault, - ShutdownType sdtype = ShutdownTypeDefault, - ShutdownMode sdmode = ShutdownModeDefault ); - - /** - * Propagates the network address of the session manager in the - * SESSION_MANAGER environment variable so that child processes can - * pick it up. - * - * If SESSION_MANAGER isn't defined yet, the address is searched in - * $HOME/.KSMserver. - * - * This function is called by clients that are started outside the - * session ( i.e. before ksmserver is started), but want to launch - * other processes that should participate in the session. Examples - * are kdesktop or kicker. - */ - void propagateSessionManager(); - - /** - * Reimplemented for internal purposes, mainly the highlevel - * handling of session management with KSessionManaged. - * @internal - */ - void commitData( TQSessionManager& sm ); - - /** - * Reimplemented for internal purposes, mainly the highlevel - * handling of session management with KSessionManaged. - * @internal - */ - void saveState( TQSessionManager& sm ); - - /** - * Returns true if the application is currently saving its session - * data (most probably before KDE logout). This is intended for use - * mainly in KMainWindow::queryClose() and KMainWindow::queryExit(). - * - * @see KMainWindow::queryClose - * @see KMainWindow::queryExit - * @since 3.1.1 - */ - bool sessionSaving() const; - - /** - * Returns a pointer to a DCOPClient for the application. - * If a client does not exist yet, it is created when this - * function is called. - * @return the DCOPClient for the application - */ - static DCOPClient *dcopClient(); - - /** - * Disable automatic dcop registration - * Must be called before creating a KApplication instance to have an effect. - */ - static void disableAutoDcopRegistration(); - - /** - * Returns a TQPixmap with the application icon. - * @return the application icon - */ - TQPixmap icon() const; - - /** - * Returns the name of the application icon. - * @return the icon's name - */ - TQString iconName() const; - - /** - * Returns the mini-icon for the application as a TQPixmap. - * @return the application's mini icon - */ - TQPixmap miniIcon() const; - - /** - * Returns the name of the mini-icon for the application. - * @return the mini icon's name - */ - TQString miniIconName() const; - - /** - * Sets the top widget of the application. - * This means basically applying the right window caption and - * icon. An application may have several top widgets. You don't - * need to call this function manually when using KMainWindow. - * - * @param topWidget A top widget of the application. - * - * @see icon(), caption() - **/ - void setTopWidget( TQWidget *topWidget ); - - /** - * Invokes the KHelpCenter HTML help viewer from docbook sources. - * - * @param anchor This has to be a defined anchor in your - * docbook sources. If empty the main index - * is loaded - * @param appname This allows you to show the help of another - * application. If empty the current name() is - * used - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - */ - void invokeHelp( const TQString& anchor, - const TQString& appname, - const TQCString& startup_id ) const; - - // KDE4 merge with above with startup_id = "" - void invokeHelp( const TQString& anchor = TQString::null, - const TQString& appname = TQString::null ) const; - - /** - * @deprecated - * Invoke the khelpcenter HTML help viewer from HTML sources. - * Please use invokeHelp() instead. - * - * @param aFilename The filename that is to be loaded. Its - * location is computed automatically - * according to the KFSSTND. If @p aFilename - * is empty, the logical appname with .html - * appended to it is used. - * @param aTopic This allows context-sensitive help. Its - * value will be appended to the filename, - * prefixed with a "#" (hash) character. - */ - void invokeHTMLHelp( const TQString& aFilename, const TQString& aTopic = TQString::null ) const KDE_DEPRECATED; - - /** - * Convenience method; invokes the standard email application. - * - * @param address The destination address - * @param subject Subject string. Can be TQString::null. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - */ - void invokeMailer( const TQString &address, const TQString &subject, const TQCString& startup_id ); - // KDE4 merge with above with startup_id = "" - void invokeMailer( const TQString &address, const TQString &subject ); - - /** - * Invokes the standard email application. - * - * @param mailtoURL A mailto URL. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param allowAttachments whether attachments specified in mailtoURL should be honoured. - The default is false; do not honour requests for attachments. - */ - void invokeMailer( const KURL &mailtoURL, const TQCString& startup_id, bool allowAttachments ); - // KDE4 merge with above with allowAttachments = false - void invokeMailer( const KURL &mailtoURL, const TQCString& startup_id ); - // KDE4 merge with above with startup_id = "" - void invokeMailer( const KURL &mailtoURL ); - - /** - * Convenience method; invokes the standard email application. - * - * All parameters are optional. - * - * @param to The destination address. - * @param cc The Cc field - * @param bcc The Bcc field - * @param subject Subject string - * @param body A string containing the body of the mail (exclusive with messageFile) - * @param messageFile A file (URL) containing the body of the mail (exclusive with body) - currently unsupported - * @param attachURLs List of URLs to be attached to the mail. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - */ - void invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc, - const TQString &subject, const TQString &body, - const TQString &messageFile, const TQStringList &attachURLs, - const TQCString& startup_id ); - // KDE4 merge with above with startup_id = "" - void invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc, - const TQString &subject, const TQString &body, - const TQString &messageFile = TQString::null, const TQStringList &attachURLs = TQStringList()); - -public slots: - /** - * Invokes the standard browser. - * Note that you should only do this when you know for sure that the browser can - * handle the URL (i.e. its mimetype). In doubt, if the URL can point to an image - * or anything else than directory or HTML, prefer to use new KRun( url ). - * - * @param url The destination address - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - */ - void invokeBrowser( const TQString &url, const TQCString& startup_id ); - // KDE4 merge with above with startup_id = "" - /** - * Invoke the standard browser. Uses a @p startup_id of "" (empty) - * and is otherwise the same as the above function. - */ - void invokeBrowser( const TQString &url ); - - /** - * If the widget with focus provides a cut() slot, call that slot. Thus for a - * simple application cut can be implemented as: - * \code - * KStdAction::cut( kapp, TQT_SLOT( cut() ), actionCollection() ); - * \endcode - */ - void cut(); - - /** - * If the widget with focus provides a copy() slot, call that slot. Thus for a - * simple application copy can be implemented as: - * \code - * KStdAction::copy( kapp, TQT_SLOT( copy() ), actionCollection() ); - * \endcode - */ - void copy(); - - /** - * If the widget with focus provides a paste() slot, call that slot. Thus for a - * simple application copy can be implemented as: - * \code - * KStdAction::paste( kapp, TQT_SLOT( paste() ), actionCollection() ); - * \endcode - */ - void paste(); - - /** - * If the widget with focus provides a clear() slot, call that slot. Thus for a - * simple application clear() can be implemented as: - * \code - * new KAction( i18n( "Clear" ), "editclear", 0, kapp, TQT_SLOT( clear() ), actionCollection(), "clear" ); - * \endcode - * - * Note that for some widgets, this may not provide the intended bahavior. For - * example if you make use of the code above and a KListView has the focus, clear() - * will clear all of the items in the list. If this is not the intened behavior - * and you want to make use of this slot, you can subclass KListView and reimplement - * this slot. For example the following code would implement a KListView without this - * behavior: - * - * \code - * class MyListView : public KListView { - * Q_OBJECT - * public: - * MyListView( TQWidget * parent = 0, const char * name = 0, WFlags f = 0 ) : KListView( parent, name, f ) {} - * virtual ~MyListView() {} - * public slots: - * virtual void clear() {} - * }; - * \endcode - */ - void clear(); - - /** - * If the widget with focus provides a selectAll() slot, call that slot. Thus for a - * simple application select all can be implemented as: - * \code - * KStdAction::selectAll( kapp, TQT_SLOT( selectAll() ), actionCollection() ); - * \endcode - */ - void selectAll(); - - /** - * Broadcast a received keycode to all listening KDE applications - * The primary use for this feature is to connect hotkeys such as - * XF86Display to their respective KGlobalAccel functions while - * the screen is locked by kdesktop_lock. - */ - void broadcastKeyCode(unsigned int keyCode); - -public: - /** - * Returns the DCOP name of the service launcher. This will be something like - * klaucher_$host_$uid. - * @return the name of the service launcher - */ - static TQCString launcher(); - - /** - * Starts a service based on the (translated) name of the service. - * E.g. "Web Browser" - * - * @param _name the name of the service - * @param URL if not empty this URL is passed to the service - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param dcopService On success, @p dcopService contains the DCOP name - * under which this service is available. If empty, the service does - * not provide DCOP services. If the pointer is 0 the argument - * will be ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param noWait if set, the function does not wait till the service is running. - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int startServiceByName( const TQString& _name, const TQString &URL, - TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id = "", bool noWait = false ); - - /** - * Starts a service based on the (translated) name of the service. - * E.g. "Web Browser" - * - * @param _name the name of the service - * @param URLs if not empty these URLs will be passed to the service - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param dcopService On success, @p dcopService contains the DCOP name - * under which this service is available. If empty, the service does - * not provide DCOP services. If the pointer is 0 the argument - * will be ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param noWait if set, the function does not wait till the service is running. - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int startServiceByName( const TQString& _name, const TQStringList &URLs=TQStringList(), - TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id = "", bool noWait = false ); - - /** - * Starts a service based on the desktop path of the service. - * E.g. "Applications/konqueror.desktop" or "/home/user/bla/myfile.desktop" - * - * @param _name the path of the desktop file - * @param URL if not empty this URL is passed to the service - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param dcopService On success, @p dcopService contains the DCOP name - * under which this service is available. If empty, the service does - * not provide DCOP services. If the pointer is 0 the argument - * will be ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param noWait if set, the function does not wait till the service is running. - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int startServiceByDesktopPath( const TQString& _name, const TQString &URL, - TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false ); - - /** - * Starts a service based on the desktop path of the service. - * E.g. "Applications/konqueror.desktop" or "/home/user/bla/myfile.desktop" - * - * @param _name the path of the desktop file - * @param URLs if not empty these URLs will be passed to the service - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param dcopService On success, @p dcopService contains the DCOP name - * under which this service is available. If empty, the service does - * not provide DCOP services. If the pointer is 0 the argument - * will be ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param noWait if set, the function does not wait till the service is running. - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int startServiceByDesktopPath( const TQString& _name, const TQStringList &URLs=TQStringList(), - TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false ); - - /** - * Starts a service based on the desktop name of the service. - * E.g. "konqueror" - * - * @param _name the desktop name of the service - * @param URL if not empty this URL is passed to the service - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param dcopService On success, @p dcopService contains the DCOP name - * under which this service is available. If empty, the service does - * not provide DCOP services. If the pointer is 0 the argument - * will be ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param noWait if set, the function does not wait till the service is running. - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int startServiceByDesktopName( const TQString& _name, const TQString &URL, - TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false ); - - /** - * Starts a service based on the desktop name of the service. - * E.g. "konqueror" - * - * @param _name the desktop name of the service - * @param URLs if not empty these URLs will be passed to the service - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param dcopService On success, @p dcopService contains the DCOP name - * under which this service is available. If empty, the service does - * not provide DCOP services. If the pointer is 0 the argument - * will be ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @param noWait if set, the function does not wait till the service is running. - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int startServiceByDesktopName( const TQString& _name, const TQStringList &URLs=TQStringList(), - TQString *error=0, TQCString *dcopService=0, int *pid = 0, const TQCString &startup_id = "", bool noWait = false ); - - /** - * Starts a program via tdeinit. - * - * program name and arguments are converted to according to the - * local encoding and passed as is to tdeinit. - * - * @param name Name of the program to start - * @param args Arguments to pass to the program - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int tdeinitExec( const TQString& name, const TQStringList &args, - TQString *error, int *pid, const TQCString& startup_id ); - // KDE4 merge with above with startup_id = "" - static int tdeinitExec( const TQString& name, const TQStringList &args=TQStringList(), - TQString *error=0, int *pid = 0 ); - - /** - * Starts a program via tdeinit and wait for it to finish. - * - * Like tdeinitExec(), but it waits till the program is finished. - * As such it behaves similar to the system(...) function. - * - * @param name Name of the program to start - * @param args Arguments to pass to the program - * @param error On failure, @p error contains a description of the error - * that occurred. If the pointer is 0, the argument will be - * ignored - * @param pid On success, the process id of the new service will be written - * here. If the pointer is 0, the argument will be ignored. - * @param startup_id for app startup notification, "0" for none, - * "" ( empty string ) is the default - * @return an error code indicating success (== 0) or failure (> 0). - */ - static int tdeinitExecWait( const TQString& name, const TQStringList &args, - TQString *error, int *pid, const TQCString& startup_id ); - // KDE4 merge with above with startup_id = "" - static int tdeinitExecWait( const TQString& name, const TQStringList &args=TQStringList(), - TQString *error=0, int *pid = 0 ); - - /** - * Returns a text for the window caption. - * - * This may be set by - * "-caption", otherwise it will be equivalent to the name of the - * executable. - * @return the text for the window caption - */ - TQString caption() const; - - /** - * @deprecated - */ - KDE_DEPRECATED KStyle* kstyle() const { return 0; } - - /** - * Builds a caption that contains the application name along with the - * userCaption using a standard layout. - * - * To make a compliant caption - * for your window, simply do: @p setCaption(kapp->makeStdCaption(yourCaption)); - * - * @param userCaption The caption string you want to display in the - * window caption area. Do not include the application name! - * @param withAppName Indicates that the method shall include or ignore - * the application name when making the caption string. You are not - * compliant if you set this to @p false. - * @param modified If true, a 'modified' sign will be included in the - * returned string. This is useful when indicating that a file is - * modified, i.e., it contains data that has not been saved. - * @return the created caption - */ - TQString makeStdCaption( const TQString &userCaption, - bool withAppName=true, bool modified=false ) const; - - /** - * Get a file name in order to make a temporary copy of your document. - * - * @param pFilename The full path to the current file of your - * document. - * @return A new filename for auto-saving. - */ - TQString tempSaveName( const TQString& pFilename ) const; - - /** - * Check whether an auto-save file exists for the document you want to - * open. - * - * @param pFilename The full path to the document you want to open. - * @param bRecover This gets set to true if there was a recover - * file. - * @return The full path of the file to open. - */ - TQString checkRecoverFile( const TQString& pFilename, bool& bRecover ) const; - -#if defined(Q_WS_X11) - /** - * @internal - * Get the X11 display - * @return the X11 Display - */ - Display *getDisplay() { return display; } -#endif - - /** - * @internal - * Gets X11 composition information - */ - void getX11RGBAInformation(Display *dpy); - - /** - * Gets the availability of a composition manager such as kompmgr - * Note that at least one application must have called detectCompositionManagerAvailable - * while the current X display was active in order for this method to return valid results. - * @see detectCompositionManagerAvailable() - * @return whether the composition manager is enabled - */ - static bool isCompositionManagerAvailable(); - - /** - * Detects the availability of a composition manager such as kompmgr - * Note that calling this method will probably cause the screen to flicker. - * @see isCompositionManagerAvailable() - * @param force_available If set, force TDE to assume a composition manager is available - * @param available Whether or not the composition manager is available (only used if force_available is TRUE) - * @return whether the composition manager is enabled - */ - bool detectCompositionManagerAvailable(bool force_available=false, bool available=true); - - /** - * @internal - * Opens the display - * This can be used to initialize a KApplication with RGBA support like this: - * KApplication app(KApplication::openX11RGBADisplay()); - * or - * KApplication app(KApplication::openX11RGBADisplay(), useStyles); - */ - static Display* openX11RGBADisplay(); - - /** - * Returns the X11 display visual - * - * @return A pointer to the X11 display visual - */ - Qt::HANDLE getX11RGBAVisual(Display *dpy); - - /** - * Returns the X11 display colormap - * - * @return An X11 display colormap object - */ - Qt::HANDLE getX11RGBAColormap(Display *dpy); - - /** - * Returns whether or not X11 composition is available - * - * You must first call getX11RGBAInformation() - * - * Note that getX11RGBAInformation() has already - * been called if you used the default KApplication - * constructor. - * - * Additionally, at least one application must have called - * detectCompositionManagerAvailable while the current X - * display was active in order for this method to return - * valid results. - * - * @return true if composition is available - */ - bool isX11CompositionAvailable(); - - /** - * Enables style plugins. - * - * This is useful only to applications that normally - * do not display a GUI and create the KApplication with - * allowStyles set to false. - */ - void enableStyles(); - - /** - * Disables style plugins. - * - * Current style plugins do not get unloaded. - * - * This is only useful when used in combination with enableStyles(). - */ - void disableStyles(); - - /** - * Installs widget filter as global X11 event filter. - * - * The widget - * filter receives XEvents in its standard TQWidget::x11Event() function. - * - * Warning: Only do this when absolutely necessary. An installed X11 filter - * can slow things down. - **/ - void installX11EventFilter( TQWidget* filter ); - - /** - * Removes global X11 event filter previously installed by - * installX11EventFilter(). - */ - void removeX11EventFilter( const TQWidget* filter ); - - /** - * Generates a uniform random number. - * @return A truly unpredictable number in the range [0, RAND_MAX) - */ - static int random(); - - /** - * Generates a random string. It operates in the range [A-Za-z0-9] - * @param length Generate a string of this length. - * @return the random string - */ - static TQString randomString(int length); - - /** - * Adds a message type to the KIPC event mask. You can only add "system - * messages" to the event mask. These are the messages with id < 32. - * Messages with id >= 32 are user messages. - * @param id The message id. See KIPC::Message. - * @see KIPC - * @see removeKipcEventMask() - * @see kipcMessage() - */ - void addKipcEventMask(int id); - - /** - * Removes a message type from the KIPC event mask. This message will - * not be handled anymore. - * @param id The message id. - * @see KIPC - * @see addKipcEventMask() - * @see kipcMessage() - */ - void removeKipcEventMask(int id); - - /** - * Returns the app startup notification identifier for this running - * application. - * @return the startup notification identifier - */ - TQCString startupId() const; - - /** - * @internal - * Sets a new value for the application startup notification window property for newly - * created toplevel windows. - * @param startup_id the startup notification identifier - * @see KStartupInfo::setNewStartupId - */ - void setStartupId( const TQCString& startup_id ); - - /** - * Updates the last user action timestamp to the given time, or to the current time, - * if 0 is given. Do not use unless you're really sure what you're doing. - * Consult focus stealing prevention section in kdebase/kwin/README. - * @since 3.2 - */ - void updateUserTimestamp( unsigned long time = 0 ); - - /** - * Returns the last user action timestamp or 0 if no user activity has taken place yet. - * @since 3.2.3 - * @see updateuserTimestamp - */ - unsigned long userTimestamp() const; - - /** - * Updates the last user action timestamp in the application registered to DCOP with dcopId - * to the given time, or to this application's user time, if 0 is given. - * Use before causing user interaction in the remote application, e.g. invoking a dialog - * in the application using a DCOP call. - * Consult focus stealing prevention section in kdebase/kwin/README. - * @since 3.3 - */ - void updateRemoteUserTimestamp( const TQCString& dcopId, unsigned long time = 0 ); - - /** - * Returns the argument to --geometry if any, so the geometry can be set - * wherever necessary - * @return the geometry argument, or TQString::null if there is none - */ - TQString geometryArgument() const; - - /** - * Install a Qt SQL property map with entries for all KDE widgets - * Call this in any application using KDE widgets in TQSqlForm or TQDataView. - */ - void installKDEPropertyMap(); - - /** - * Returns whether a certain action is authorized - * @param genericAction The name of a generic action - * @return true if the action is authorized - */ - bool authorize(const TQString &genericAction); - - /** - * Returns whether a certain KAction is authorized. - * - * @param action The name of a KAction action. The name is prepended - * with "action/" before being passed to authorize() - * @return true if the KAction is authorized - */ - bool authorizeKAction(const char *action); - - /** - * Returns whether a certain URL related action is authorized. - * - * @param action The name of the action. Known actions are - * list (may be listed (e.g. in file selection dialog)), - * link (may be linked to), - * open (may open) and - * redirect (may be redirected to) - * @param baseURL The url where the action originates from - * @param destURL The object of the action - * @return true when the action is authorized, false otherwise. - * @since 3.1 - */ - bool authorizeURLAction(const TQString &action, const KURL &baseURL, const KURL &destURL); - - /** - * Allow a certain URL action. This can be useful if your application - * needs to ensure access to an application specific directory that may - * otherwise be subject to KIOSK restrictions. - * @param action The name of the action. - * @param _baseURL The url where the action originates from - * @param _destURL The object of the action - * @since 3.2 - */ - void allowURLAction(const TQString &action, const KURL &_baseURL, const KURL &_destURL); - - /** - * Returns whether access to a certain control module is authorized. - * - * @param menuId identifying the control module, e.g. kde-mouse.desktop - * @return true if access to the module is authorized, false otherwise. - * @since 3.2 - */ - bool authorizeControlModule(const TQString &menuId); - - /** - * Returns whether access to a certain control modules is authorized. - * - * @param menuIds list of menu-ids of control module, - * an example of a menu-id is kde-mouse.desktop. - * @return Those control modules for which access has been authorized. - * @since 3.2 - */ - TQStringList authorizeControlModules(const TQStringList &menuIds); - - /** - * Returns the state of the currently pressed keyboard modifiers (e.g. shift, control, etc.) - * and mouse buttons, similarly to TQKeyEvent::state() and TQMouseEvent::state(). - * You usually should simply use the information provided by TQKeyEvent and TQMouseEvent, - * but it can be useful to query for the status of the modifiers at another moment - * (e.g. some KDE apps do that upon a drop event). - * @return the keyboard modifiers and mouse buttons state - * @since 3.4 - */ - static ButtonState keyboardMouseState(); - - // Same values as ShiftMask etc. in X.h - enum { ShiftModifier = 1<<0, - LockModifier = 1<<1, - ControlModifier = 1<<2, - Modifier1 = 1<<3, - Modifier2 = 1<<4, - Modifier3 = 1<<5, - Modifier4 = 1<<6, - Modifier5 = 1<<7 }; - /** - * @deprecated Use keyboardMouseState() - * @since 3.1 - */ - static uint keyboardModifiers() KDE_DEPRECATED; - - /** @deprecated Same values as Button1Mask etc. in X.h */ - enum { Button1Pressed = 1<<8, - Button2Pressed = 1<<9, - Button3Pressed = 1<<10, - Button4Pressed = 1<<11, - Button5Pressed = 1<<12 }; - /** - * @deprecated Use keyboardMouseState() - * @since 3.1 - */ - static uint mouseState() KDE_DEPRECATED; - - -public slots: - /** - * Tells KApplication about one more operation that should be finished - * before the application exits. The standard behavior is to exit on the - * "last window closed" event, but some events should outlive the last window closed - * (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client). - */ - void ref(); - - /** - * Tells KApplication that one operation such as those described in ref() just finished. - * The application exits if the counter is back to 0. - */ - void deref(); - -protected: - /** - * @internal Used by KUniqueApplication - */ - KApplication( bool allowStyles, bool GUIenabled, KInstance* _instance ); - -#ifdef Q_WS_X11 - /** - * @internal Used by KUniqueApplication - */ - KApplication( Display *display, Qt::HANDLE visual, Qt::HANDLE colormap, - bool allowStyles, KInstance* _instance ); - - /** - * Used to catch X11 events - */ - bool x11EventFilter( XEvent * ); - - Display *display; -#endif - Atom kipcCommAtom; - int kipcEventMask; - - /// Current application object. - static KApplication *KApp; - int pArgc; - - /** - * This method is used internally to determine which edit slots are implemented - * by the widget that has the focus, and to invoke those slots if available. - * - * @param slot is the slot as returned using the TQT_SLOT() macro, for example TQT_SLOT( cut() ) - * - * This method can be used in KApplication subclasses to implement application wide - * edit actions not supported by the KApplication class. For example (in your subclass): - * - * \code - * void MyApplication::deselect() - * { - * invokeEditSlot( TQT_SLOT( deselect() ) ); - * } - * \endcode - * - * Now in your application calls to MyApplication::deselect() will call this slot on the - * focused widget if it provides this slot. You can combine this with KAction with: - * - * \code - * KStdAction::deselect( static_cast<MyApplication *>( kapp ), TQT_SLOT( cut() ), actionCollection() ); - * \endcode - * - * @see cut() - * @see copy() - * @see paste() - * @see clear() - * @see selectAll() - * - * @since 3.2 - */ - void invokeEditSlot( const char *slot ); - -private slots: - void dcopFailure(const TQString &); - void dcopBlockUserInput( bool ); - void x11FilterDestroyed(); - void checkAppStartedSlot(); - -private: - TQString sessionConfigName() const; - KConfig* pSessionConfig; //instance specific application config object - static DCOPClient *s_DCOPClient; // app specific application communication client - static bool s_dcopClientNeedsPostInit; - TQString aCaption; // the name for the window title - bool bSessionManagement; - struct oldPixmapType { TQPixmap a, b; }; - mutable union { - struct { - TQPixmap *icon, *miniIcon; - } pm; - char unused[sizeof(oldPixmapType)]; - } aIconPixmap; // KDE4: remove me - TQString aIconName; - TQString aMiniIconName; - bool useStyles; - TQWidget *smw; - - void init( bool GUIenabled ); - - void parseCommandLine( ); // Handle KDE arguments (Using KCmdLineArgs) - - void read_app_startup_id(); - - void dcopAutoRegistration(); - void dcopClientPostInit(); - void initUrlActionRestrictions(); - - bool argb_visual; -#if defined(Q_WS_X11) - Qt::HANDLE argb_x11_visual; - Qt::HANDLE argb_x11_colormap; -#endif - -public: - /** - * @internal - */ - bool notify(TQObject *receiver, TQEvent *event); - - /** - @internal - */ - int xErrhandler( Display*, void* ); - - /** - @internal - */ - int xioErrhandler( Display* ); - - /** - * @internal - */ - void iceIOErrorHandler( _IceConn *conn ); - - /** - * @internal - */ - static bool loadedByKdeinit; - - /** - * @internal - */ - static void startKdeinit(); - - /** - * Valid values for the settingsChanged signal - */ - enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS, - SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS }; - - /** - * Used to obtain the TQPalette that will be used to set the application palette. - * - * This is only useful for configuration modules such as krdb and should not be - * used in normal circumstances. - * @return the QPalette - * @since 3.1 - */ - static TQPalette createApplicationPalette(); - - /** - * @internal - * Raw access for use by KDM. - */ - static TQPalette createApplicationPalette( KConfig *config, int contrast ); - - /** - * Installs a handler for the SIGPIPE signal. It is thrown when you write to - * a pipe or socket that has been closed. - * The handler is installed automatically in the constructor, but you may - * need it if your application or component does not have a KApplication - * instance. - */ - static void installSigpipeHandler(); - - /** - * @internal - * Whether widgets can be used. - * - * @since 3.2 - */ - static bool guiEnabled(); - -signals: - /** - * Emitted when KApplication has changed its palette due to a KControl request. - * - * Normally, widgets will update their palette automatically, but you - * should connect to this to program special behavior. - */ - void kdisplayPaletteChanged(); - - /** - * Emitted when KApplication has changed its GUI style in response to a KControl request. - * - * Normally, widgets will update their styles automatically (as they would - * respond to an explicit setGUIStyle() call), but you should connect to - * this to program special behavior. - */ - void kdisplayStyleChanged(); - - /** - * Emitted when KApplication has changed its font in response to a KControl request. - * - * Normally widgets will update their fonts automatically, but you should - * connect to this to monitor global font changes, especially if you are - * using explicit fonts. - * - * Note: If you derive from a QWidget-based class, a faster method is to - * reimplement TQWidget::fontChange(). This is the preferred way - * to get informed about font updates. - */ - void kdisplayFontChanged(); - - /** - * Emitted when KApplication has changed either its GUI style, its font or its palette - * in response to a kdisplay request. Normally, widgets will update their styles - * automatically, but you should connect to this to program special - * behavior. */ - void appearanceChanged(); - - /** - * Emitted when the settings for toolbars have been changed. KToolBar will know what to do. - */ - void toolbarAppearanceChanged(int); - - /** - * Emitted when the desktop background has been changed by @p kcmdisplay. - * - * @param desk The desktop whose background has changed. - */ - void backgroundChanged(int desk); - - /** - * Emitted when the global settings have been changed - see KGlobalSettings - * KApplication takes care of calling reparseConfiguration on KGlobal::config() - * so that applications/classes using this only have to re-read the configuration - * @param category the category among the enum above - */ - void settingsChanged(int category); - - /** - * Emitted when the global icon settings have been changed. - * @param group the new group - */ - void iconChanged(int group); - - /** - * Emitted when a KIPC user message has been received. - * @param id the message id - * @param data the data - * @see KIPC - * @see KIPC::Message - * @see addKipcEventMask - * @see removeKipcEventMask - */ - void kipcMessage(int id, int data); - - /** - Session management asks you to save the state of your application. - - This signal is provided for compatibility only. For new - applications, simply use KMainWindow. By reimplementing - KMainWindow::queryClose(), KMainWindow::saveProperties() and - KMainWindow::readProperties() you can simply handle session - management for applications with multiple toplevel windows. - - For purposes without KMainWindow, create an instance of - KSessionManaged and reimplement the functions - KSessionManaged::commitData() and/or - KSessionManaged::saveState() - - If you still want to use this signal, here is what you should do: - - Connect to this signal in order to save your data. Do NOT - manipulate the UI in that slot, it is blocked by the session - manager. - - Use the sessionConfig() KConfig object to store all your - instance specific data. - - Do not do any closing at this point! The user may still select - Cancel wanting to continue working with your - application. Cleanups could be done after shutDown() (see - the following). - - */ - void saveYourself(); - - /** Your application is killed. Either by your program itself, - @p xkill or (the usual case) by KDE's logout. - - The signal is particularly useful if your application has to do some - last-second cleanups. Note that no user interaction is possible at - this state. - */ - void shutDown(); - - /** - * @internal - * Used to notify KIconLoader objects that they need to reload. - */ - void updateIconLoaders(); - - /** - * @internal - * Used to send KGlobalAccel objects a new keypress from physical hotkeys. - */ - void coreFakeKeyPress(unsigned int keyCode); - -private: - void propagateSettings(SettingsCategory category); - void kdisplaySetPalette(); - void kdisplaySetStyle(); - void kdisplaySetFont(); - void applyGUIStyle(); - static void sigpipeHandler(int); - - int captionLayout; - - KApplication(const KApplication&); - KApplication& operator=(const KApplication&); -protected: - virtual void virtual_hook( int id, void* data ); -private: - KApplicationPrivate* d; -}; - - -/** - * \relates KGlobal - * Check, if a file may be accessed in a given mode. - * This is a wrapper around the access() system call. - * checkAccess() calls access() with the given parameters. - * If this is OK, checkAccess() returns true. If not, and W_OK - * is part of mode, it is checked if there is write access to - * the directory. If yes, checkAccess() returns true. - * In all other cases checkAccess() returns false. - * - * Other than access() this function EXPLICITLY ignores non-existant - * files if checking for write access. - * - * @param pathname The full path of the file you want to test - * @param mode The access mode, as in the access() system call. - * @return Whether the access is allowed, true = Access allowed - */ -KDECORE_EXPORT bool checkAccess(const TQString& pathname, int mode); - -class KSessionManagedPrivate; - -/** - Provides highlevel access to session management on a per-object - base. - - KSessionManaged makes it possible to provide implementations for - TQApplication::commitData() and TQApplication::saveState(), without - subclassing KApplication. KMainWindow internally makes use of this. - - You don't need to do anything with this class when using - KMainWindow. Instead, use KMainWindow::saveProperties(), - KMainWindow::readProperties(), KMainWindow::queryClose(), - KMainWindow::queryExit() and friends. - - @short Highlevel access to session management. - @author Matthias Ettrich <ettrich@kde.org> - */ -class KDECORE_EXPORT KSessionManaged -{ -public: - KSessionManaged(); - virtual ~KSessionManaged(); - - /** - See TQApplication::saveState() for documentation. - - This function is just a convenience version to avoid subclassing KApplication. - - Return true to indicate a successful state save or false to - indicate a problem and to halt the shutdown process (will - implicitly call sm.cancel() ). - */ - virtual bool saveState( TQSessionManager& sm ); - /** - See TQApplication::commitData() for documentation. - - This function is just a convenience version to avoid subclassing KApplication. - - Return true to indicate a successful commit of data or false to - indicate a problem and to halt the shutdown process (will - implicitly call sm.cancel() ). - */ - virtual bool commitData( TQSessionManager& sm ); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KSessionManagedPrivate *d; -}; - - -#endif - diff --git a/kdecore/kapplication_win.cpp b/kdecore/kapplication_win.cpp deleted file mode 100644 index abf0694b4..000000000 --- a/kdecore/kapplication_win.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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 <kapplication.h> -#include <kstandarddirs.h> -#include <klocale.h> -#include <kurl.h> - -#include "kcheckaccelerators.h" -#include "kappdcopiface.h" - -#include <qassistantclient.h> -#include <tqdir.h> - -#include "windows.h" -#include "shellapi.h" - -/** - * MS Windows-related actions for KApplication startup. - * - * - Use Qt translation which will be usable for TQFileDialog - * and other Qt-only GUIs. The "qt_<language>.qm" file should be stored - * in the same place as .po files for a given language. - * - * @internal -*/ -void KApplication_init_windows(bool /*GUIenabled*/) -{ - TQString qt_transl_file = ::locate( "locale", KGlobal::locale()->language() - + "/LC_MESSAGES/qt_" + KGlobal::locale()->language() + ".qm" ); - QTranslator *qt_transl = new QTranslator(); - if (qt_transl->load( qt_transl_file, "")) - kapp->installTranslator( qt_transl ); - else - delete qt_transl; -} - -//unsafe; create kapplication_p.h instead! -typedef void* IceIOErrorHandler; - -class KApplicationPrivate -{ -public: - KApplicationPrivate(); - ~KApplicationPrivate(); - - bool actionRestrictions : 1; - bool guiEnabled : 1; - int refCount; - IceIOErrorHandler oldIceIOErrorHandler; - KCheckAccelerators* checkAccelerators; - TQString overrideStyle; - TQString geometry_arg; - TQCString startup_id; - TQTimer* app_started_timer; - KAppDCOPInterface *m_KAppDCOPInterface; - bool session_save; - QAssistantClient* qassistantclient; -}; - -void KApplication::invokeHelp( const TQString& anchor, - const TQString& _appname, const TQCString& startup_id ) const -{ - if (!d->qassistantclient) { - d->qassistantclient = new QAssistantClient( - KStandardDirs::findExe( "assistant" ), 0); - TQStringList args; - args << "-profile"; - args << TQDir::convertSeparators( locate("html", TQString(name())+"/"+TQString(name())+".adp") ); - d->qassistantclient->setArguments(args); - } - d->qassistantclient->openAssistant(); -} - -// on win32, for invoking browser we're using win32 API -// see kapplication_win.cpp -void KApplication::invokeBrowser( const TQString &url, const TQCString& startup_id ) -{ - TQCString s = url.latin1(); - const unsigned short *l = (const unsigned short *)s.data(); - ShellExecuteA(0, "open", s.data(), 0, 0, SW_NORMAL); -} - -void KApplication::invokeMailer(const TQString &to, const TQString &cc, const TQString &bcc, - const TQString &subject, const TQString &body, - const TQString & /*messageFile TODO*/, const TQStringList &attachURLs, - const TQCString& startup_id ) -{ - KURL url("mailto:"+to); - url.setQuery("?subject="+subject); - url.addQueryItem("cc", cc); - url.addQueryItem("bcc", bcc); - url.addQueryItem("body", body); - for (TQStringList::ConstIterator it = attachURLs.constBegin(); it != attachURLs.constEnd(); ++it) - url.addQueryItem("attach", KURL::encode_string(*it)); - - TQCString s = url.url().latin1(); - const unsigned short *l = (const unsigned short *)s.data(); - ShellExecuteA(0, "open", s.data(), 0, 0, SW_NORMAL); -} - diff --git a/kdecore/kasyncio.cpp b/kdecore/kasyncio.cpp deleted file mode 100644 index 45f588d9c..000000000 --- a/kdecore/kasyncio.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - */ - - -#include "kasyncio.h" - -void KAsyncIO::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kasyncio.moc" diff --git a/kdecore/kasyncio.h b/kdecore/kasyncio.h deleted file mode 100644 index ad2fe1e30..000000000 --- a/kdecore/kasyncio.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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 KASYNCIO_H -#define KASYNCIO_H - - -#include <tqobject.h> -#include <tqiodevice.h> -#include "kdelibs_export.h" - -#ifdef Q_MOC_RUN -#define USE_QT4 -#endif // Q_MOC_RUN - -class KAsyncIOPrivate; -/** - * Asynchronous I/O Support - * - * This abstract class provides basic functionality for asynchronous I/O - * support on top of TQIODevice. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - * @short Asynchronous I/O support - */ -class KDECORE_EXPORT KAsyncIO: -#ifdef USE_QT4 -#else // USE_QT4 -public TQObject, -#endif // USE_QT4 -public TQIODevice -{ - Q_OBJECT - TQ_OBJECT -protected: - KAsyncIO() // cannot be accessed externally - { } - -private: - KAsyncIO(KAsyncIO&); - - KAsyncIO& operator=(KAsyncIO&); - -public: - /** - * Toggles the emission of the readyRead() signal whenever the device - * is ready for reading. This is useful if you want to know the first time - * the device is ready for reading and you don't want to read it now. - * @param enable true to enable, false to disable the readyRead() signal - */ - virtual void enableRead(bool enable) = 0; - - /** - * Toggles the emission of the readyWrite() signal whenever the device - * is ready for writing. This is useful if you want to know the first time - * the device is ready for writing and you don't want to write to it now. - * @param enable true to enable, false to disable the readyWrite() signal - */ - virtual void enableWrite(bool enable) = 0; - -signals: - - /** - * This signal gets sent when the device is ready for reading. - */ - void readyRead(); - - /** - * This signal gets sent when the device is ready for writing. - */ - void readyWrite(); -protected: - /** \internal */ - virtual void virtual_hook( int id, void* data ); -private: - KAsyncIOPrivate* d; -}; - -#endif // KASYNCIO_H diff --git a/kdecore/kaudioplayer.cpp b/kdecore/kaudioplayer.cpp deleted file mode 100644 index 0dae392c9..000000000 --- a/kdecore/kaudioplayer.cpp +++ /dev/null @@ -1,56 +0,0 @@ - /* - - Copyright (C) 2000 Stefan Westerfeld - stefan@space.twc.de - - 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. - - */ - -#include "kaudioplayer.h" -#include "knotifyclient.h" - -class KAudioPlayerPrivate { -public: - TQString filename; - - KAudioPlayerPrivate(const TQString &filename) : filename(filename) { } -}; - -KAudioPlayer::KAudioPlayer( const TQString& filename, - TQObject* parent, const char* name ) : TQObject(parent,name) -{ - d = new KAudioPlayerPrivate(filename); -} - -KAudioPlayer::~KAudioPlayer() -{ - delete d; -} - -void KAudioPlayer::play(const TQString &filename) -{ - KAudioPlayer ap(filename); - ap.play(); -} - -void KAudioPlayer::play() -{ - KNotifyClient::userEvent("KAudioPlayer event", - KNotifyClient::Sound,KNotifyClient::Notification,d->filename); -} - -#include "kaudioplayer.moc" diff --git a/kdecore/kaudioplayer.h b/kdecore/kaudioplayer.h deleted file mode 100644 index 81ca2cdf7..000000000 --- a/kdecore/kaudioplayer.h +++ /dev/null @@ -1,93 +0,0 @@ - /* - - Copyright (C) 2000 Stefan Westerfeld - stefan@space.twc.de - - 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 __KAUDIOPLAYER_H__ -#define __KAUDIOPLAYER_H__ - -#include <tqobject.h> -#include "kdelibs_export.h" - -class KAudioPlayerPrivate; -/** - * This class provides one-shot-and-forget audio playing. You will never - * know if what you wanted to play really got played. - * - * It doesn't require linking any special libraries, as it operates over - * DCOP. In the current implementation, it only indirectly communicates - * with the aRts soundserver, using knotify as DCOP -> MCOP bridge. - * - * Due to that fact, if you need "fast" response times, more control or - * feedback, use the MCOP interfaces rather than this. - * - * An example of using this class is: - * - * \code - * KAudioPlayer::play("/var/share/foo.wav"); - * \endcode - * - * If you want to use signals & slots, you can do something like: - * - * \code - * KAudioPlayer player("/var/share/foo.wav"); - * connect(&button, TQT_SIGNAL(clicked()), &player, TQT_SLOT(play())); - * \endcode - * - */ -//REVISED: hausmann -class KDECORE_EXPORT KAudioPlayer : public TQObject { -Q_OBJECT -public: - /** - * Constructor. - * - * @param filename Absolute path to the filename of the sound file to play - * @param parent A parent TQObject for this KAudioPlayer - * @param name An internal name for this KAudioPlayer - */ - KAudioPlayer( const TQString& filename, - TQObject* parent = 0, const char* name = 0 ); - - /** - * Destructor. - */ - ~KAudioPlayer(); - - /** - * Static play function. - * - * @param filename Absolute path to the filename of the sound file to play. - * if not absolute, goes off KDEDIR/share/sounds/ (preferred) - */ - static void play(const TQString &filename); - -public slots: - /** - * Play function as slot. - * - * Plays the soundfile given to the constructor. - */ - void play(); -private: - KAudioPlayerPrivate *d; -}; - -#endif // __KAUDIOPLAYER_H__ diff --git a/kdecore/kbufferedio.cpp b/kdecore/kbufferedio.cpp deleted file mode 100644 index 951c41244..000000000 --- a/kdecore/kbufferedio.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - */ - -#include "config.h" - -#include <string.h> - -#include <tqptrlist.h> -#include <tqcstring.h> -#include "kbufferedio.h" - -/** - * @section impldetails Implementation Details - * - * The KBufferedIO class has two purposes: first, it defines an API on how - * that classes providing buffered I/O should provide. Next, it implements on - * top of that API a generic buffering, that should suffice for most cases. - * - * The buffering implemented consists of two separate buffer areas, one for - * the input (or read) buffer, and one for the output (or write) buffer. Each - * of those buffers is implemented through a QList of QByteArrays instead of - * simply QByteArrays. The idea is that, instead of having one large, contiguous - * buffer area, we have several small ones. Even though this could be seen as - * a waste of memory, it makes our life easier, because we can just append a new - * TQByteArray to the list and not have to worry with copying the rest of the - * buffer, should we need to expand. - * - * This way, we have the capability of unlimited buffering, which can grow to - * the extent of available memory. - * - * For each buffer, we provide three kinds of functions, available as protected - * members: consume, feed and size. The size functions calculate the current - * size of the buffer, by adding each individual TQByteArray size. The feed - * functions are used by the I/O functions that receive data from somewhere, - * i.e., from the system, in the case of the input buffer, and from the user, - * in the case of the output buffer. These two functions are used to give - * the buffers more data. And the consume functions are used by the functions - * that send out data (to the system, for the write buffer, and to the user, - * for the read buffer). - * - * Note that for your own implementation, you can have your readBlock function - * merely call consumeReadBuffer, similarly to peekBlock. As for - * the writeBlock function, you'd call feedWriteBuffer. - * - * Now, the function receiving data from the system will need to simply call - * feedReadBuffer, much in the same way of unreadBlock. The tricky part is - * for the output function. We do not provide a member function that copies - * data from the output buffer into another buffer for sending. We believe that - * would be a waste of resources and CPU time, since you'd have to allocate - * that buffer, copy data into it and then call the OS, which will likely just - * copy data out of it. - * - * Instead, we found it better to leave it to you to access outBuf member - * variable directly and use the buffers there. Should you want to copy that - * into a larger buffer before sending, that's up to you. - * - * Both buffers work in the same way: they're an "array" of buffers, each - * concatenated to the other. All data in all buffers is valid data, except - * for the first TQByteArray, whose valid data starts at inBufIndex/outBufIndex - * bytes from the start. That is, the data starts in the first TQByteArray buffer - * that many bytes from the start and goes on contiguously until the last - * TQByteArray. This has been decided like that because we didn't want to - * create a new TQByteArray of the remaining bytes in the first buffer, after - * a consume operation, because that could take some time. It is faster - * this way, although not really easy. - * - * If you want to take a look at an implementation of a buffered I/O class, - * refer to KExtendedSocket's source code. - */ - -// constructor -KBufferedIO::KBufferedIO() : - inBufIndex(0), outBufIndex(0) -{ - inBuf.setAutoDelete(true); - outBuf.setAutoDelete(true); -} - -// destructor -KBufferedIO::~KBufferedIO() -{ -} - -// sets the buffer sizes -// this implementation doesn't support setting the buffer sizes -// if any parameter is different than -1 or -2, fail -bool KBufferedIO::setBufferSize(int rsize, int wsize /* = -2 */) -{ - if (wsize != -2 && wsize != -1) - return false; - if (rsize != -2 && rsize != -1) - return false; - - return true; -} - -#ifdef USE_QT3 -int KBufferedIO::bytesAvailable() const -#endif // USE_QT3 -#ifdef USE_QT4 -qint64 KBufferedIO::bytesAvailable() const -#endif // USE_QT4 -{ - return readBufferSize(); -} - -#ifdef USE_QT3 -int KBufferedIO::bytesToWrite() const -#endif // USE_QT3 -#ifdef USE_QT4 -qint64 KBufferedIO::bytesToWrite() const -#endif // USE_QT4 -{ - return writeBufferSize(); -} - -// This function will scan the read buffer for a '\n' -bool KBufferedIO::canReadLine() const -{ - if (bytesAvailable() == 0) - return false; // no new line in here - - TQByteArray* buf; - - // scan each TQByteArray for the occurrence of '\n' - TQPtrList<TQByteArray> &buflist = ((KBufferedIO*)this)->inBuf; - buf = buflist.first(); - char *p = buf->data() + inBufIndex; - int n = buf->size() - inBufIndex; - while (buf != NULL) - { - while (n--) - if (*p++ == '\n') - return true; - buf = buflist.next(); - if (buf != NULL) - { - p = buf->data(); - n = buf->size(); - } - } - - return false; // no new line found -} - -// unreads the current data -// that is, writes into the read buffer, at the beginning -int KBufferedIO::unreadBlock(const char *data, uint len) -{ - return feedReadBuffer(len, data, true); -} - -// -// protected member functions -// - -unsigned KBufferedIO::consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard) -{ - { - register unsigned u = readBufferSize(); - if (nbytes > u) - nbytes = u; // we can't consume more than there is - } - - TQByteArray *buf; - unsigned copied = 0; - unsigned index = inBufIndex; - - buf = inBuf.first(); - while (nbytes && buf) - { - // should we copy it all? - unsigned to_copy = buf->size() - index; - if (to_copy > nbytes) - to_copy = nbytes; - - if (destbuffer) - memcpy(destbuffer + copied, buf->data() + index, to_copy); - nbytes -= to_copy; - copied += to_copy; - - if (buf->size() - index > to_copy) - { - index += to_copy; - break; // we aren't copying everything, that means that's - // all the user wants - } - else - { - index = 0; - if (discard) - { - inBuf.remove(); - buf = inBuf.first(); - } - else - buf = inBuf.next(); - } - } - - if (discard) - inBufIndex = index; - - return copied; -} - -void KBufferedIO::consumeWriteBuffer(unsigned nbytes) -{ - TQByteArray *buf = outBuf.first(); - if (buf == NULL) - return; // nothing to consume - - if (nbytes < buf->size() - outBufIndex) - // we want to consume less than there is in the first buffer - outBufIndex += nbytes; - else - { - nbytes -= buf->size() - outBufIndex; - outBufIndex = 0; - outBuf.remove(); - - while ((buf = outBuf.current()) != NULL) - if (buf->size() <= nbytes) - { - nbytes -= buf->size(); - outBuf.remove(); - } - else - { - outBufIndex = nbytes; - break; - } - } -} - -unsigned KBufferedIO::feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning) -{ - if (nbytes == 0) - return 0; - - TQByteArray *a = new TQByteArray(nbytes); - a->duplicate(buffer, nbytes); - - if (atBeginning) - inBuf.prepend(a); - else - inBuf.append(a); - - return nbytes; -} - -unsigned KBufferedIO::feedWriteBuffer(unsigned nbytes, const char *buffer) -{ - if (nbytes == 0) - return 0; - - TQByteArray *a = new TQByteArray(nbytes); - a->duplicate(buffer, nbytes); - outBuf.append(a); - return nbytes; -} - -unsigned KBufferedIO::readBufferSize() const -{ - unsigned count = 0; - TQByteArray *buf = ((KBufferedIO*)this)->inBuf.first(); - while (buf != NULL) - { - count += buf->size(); - buf = ((KBufferedIO*)this)->inBuf.next(); - } - - return count - inBufIndex; -} - -unsigned KBufferedIO::writeBufferSize() const -{ - unsigned count = 0; - TQByteArray *buf = ((KBufferedIO*)this)->outBuf.first(); - while (buf != NULL) - { - count += buf->size(); - buf = (const_cast<KBufferedIO*>(this))->outBuf.next(); - } - - return count - outBufIndex; -} - -void KBufferedIO::virtual_hook( int id, void* data ) -{ KAsyncIO::virtual_hook( id, data ); } - -#include "kbufferedio.moc" diff --git a/kdecore/kbufferedio.h b/kdecore/kbufferedio.h deleted file mode 100644 index abdb68f80..000000000 --- a/kdecore/kbufferedio.h +++ /dev/null @@ -1,300 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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 KBUFFEREDIO_H -#define KBUFFEREDIO_H - -#include <tqcstring.h> -#include <tqptrlist.h> -#include "kasyncio.h" - -class KBufferedIOPrivate; -/** - * This abstract class implements basic functionality for buffered - * input/output. - * - * Through the available methods, you can find out how many bytes are - * available for reading, how many are still unsent and you can peek at - * the buffered data. - * - * This class was intentionally written to resemble TQSocket, because - * KExtendedSocket is a subclass of this one. This is so that applications - * written using QSocket's buffering characteristics will be more easily - * ported to the more powerful KExtendedSocket class. - * - * KBufferedIO already provides a powerful internal buffering algorithm. However, - * this does not include the I/O itself, which must be implemented in - * derived classes. Thus, to implement a class that does some I/O, you must - * override, in addition to the pure virtual TQIODevice methods, these two: - * @li closeNow() - * @li waitForMore() - * - * If your derived class reimplements the buffering algorithm, you must then - * decide which buffering functions to override. For instance, you may want to - * change the protected functions like feedReadBuffer() and consumeReadBuffer(). - * - * @author Thiago Macieira <thiagom@mail.com> - * @short Buffered I/O - */ -class KDECORE_EXPORT KBufferedIO: public KAsyncIO -{ - Q_OBJECT - TQ_OBJECT - -protected: - // no default public constructor - KBufferedIO(); - -public: - /** - * The modes for closed() signal - */ - enum closeModes - { - availRead = 0x01, - dirtyWrite = 0x02, - involuntary = 0x10, - delayed = 0x20, - closedNow = 0x40 - }; - - /** - * Destroys this class. The flushing of the buffers is implementation dependant. - * The default implementation discards the contents - */ - virtual ~KBufferedIO(); - - /** - * Closes the stream now, discarding the contents of the - * write buffer. That is, we won't try to flush that - * buffer before closing. If you want that buffer to be - * flushed, you can call TQIODevice::flush(), which is blocking, and - * then closeNow, or you can call TQIODevice::close() for a delayed - * close. - */ - virtual void closeNow() = 0; - - /** - * Sets the internal buffer size to value. - * - * Not all implementations support this. - * - * The parameters may be 0 to make the class unbuffered or -1 - * to let the class choose the size (which may be unlimited) or - * -2 to leave the buffer size untouched. - * - * Note that setting the write buffer size to any value smaller than - * the current size of the buffer will force it to flush first, - * which can make this call blocking. - * - * The default implementation does not support setting the buffer - * sizes. You can only call this function with values -1 for "don't care" - * or -2 for "unchanged" - * @param rsize the size of the read buffer - * @param wsize the size of the write buffer - * @return true if setting both was ok. If false is returned, the - * buffers were left unchanged. - */ - virtual bool setBufferSize(int rsize, int wsize = -2); - - /** - * Returns the number of bytes available for reading in the read buffer - * @return the number of bytes available for reading - */ -#ifdef USE_QT3 - virtual int bytesAvailable() const; -#endif // USE_QT3 -#ifdef USE_QT4 - virtual qint64 bytesAvailable() const; -#endif // USE_QT4 - - /** - * Waits for more data to be available and returns the amount of available data then. - * - * @param msec number of milliseconds to wait, -1 to wait forever - * @return -1 if we cannot wait (e.g., that doesn't make sense in this stream) - */ - virtual int waitForMore(int msec) = 0; - - /** - * Returns the number of bytes yet to write, still in the write buffer - * @return the number of unwritten bytes in the write buffer - */ -#ifdef USE_QT3 - virtual int bytesToWrite() const; -#endif // USE_QT3 -#ifdef USE_QT4 - virtual qint64 bytesToWrite() const; -#endif // USE_QT4 - - /** - * Checks whether there is enough data in the buffer to read a line - * - * The default implementation reads directly from inBuf, so if your - * implementation changes the meaning of that member, then you must override - * this function. - * @return true when there is enough data in the buffer to read a line - */ - virtual bool canReadLine() const; - - // readBlock, peekBlock and writeBlock are not defined in this class (thus, left - // pure virtual) because this does not mean only reading and writing - // to the buffers. It may be necessary to do I/O to complete the - // transaction (e.g., user wants to read more than is in the buffer). - // Reading and writing to the buffer are available for access through - // protected member functions - - /** - * Reads into the user buffer at most maxlen bytes, but does not - * consume that data from the read buffer. This is useful to check - * whether we already have the needed data to process something. - * - * This function may want to try and read more data from the system - * provided it won't block. - * - * @param data the user buffer pointer, at least maxlen bytes long - * @param maxlen the maximum length to be peeked - * @return the number of bytes actually copied. - */ - virtual int peekBlock(char *data, uint maxlen) = 0; - - /** - * Unreads some data. That is, write the data to the beginning of the - * read buffer, so that next calls to readBlock or peekBlock will see - * this data instead. - * - * Note not all devices implement this since this could mean a semantic - * problem. For instance, sockets are sequential devices, so they won't - * accept unreading. - * @param data the data to be unread - * @param len the size of the data - * @return the number of bytes actually unread - */ - virtual int unreadBlock(const char *data, uint len); - -signals: - /** - * This signal gets sent whenever bytes are written from the buffer. - * @param nbytes the number of bytes sent. - */ - void bytesWritten(int nbytes); - - // There is no read signal here. We use the readyRead signal inherited - // from KAsyncIO for that purpose - - /** - * This signal gets sent when the stream is closed. The @p state parameter - * will give the current state, in OR-ed bits: - * @li availRead: read buffer contains data to be read - * @li dirtyWrite: write buffer wasn't empty when the stream closed - * @li involuntary: the stream wasn't closed due to user request - * (i.e., call to close). Probably remote end closed it - * @li delayed: the stream was closed voluntarily by the user, but it - * happened only after the write buffer was emptied - * @li closedNow: the stream was closed voluntarily by the user, by - * explicitly calling closeNow, which means the - * write buffer's contents may have been discarded - * @param state the state (see function description) - */ - void closed(int state); - -protected: - /** - * For an explanation on how this buffer work, please refer to the comments - * at the top of kbufferedio.cpp, @ref impldetails . - */ - TQPtrList<TQByteArray> inBuf; - - /** - * For an explanation on how this buffer work, please refer to the comments - * at the top of kbufferedio.cpp, @ref impldetails . - */ - TQPtrList<TQByteArray> outBuf; - - unsigned inBufIndex /** Offset into first input buffer. */, - outBufIndex /** Offset into first output buffer. */ ; - - /** - * Consumes data from the input buffer. - * That is, this will copy the data stored in the input (read) buffer - * into the given @p destbuffer, as much as @p nbytes. - * @param nbytes the maximum amount of bytes to copy into the buffer - * @param destbuffer the destination buffer into which to copy the data - * @param discard whether to discard the copied data after the operation - * @return the real amount of data copied. If it is less than - * nbytes, then all the buffer was copied. - */ - virtual unsigned consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard = true); - - /** - * Consumes data from the output buffer. - * Since this is called whenever we managed to send data out the wire, we - * can only discard this amount from the buffer. There is no copying and no - * "peeking" for the output buffer. - * - * Note this function should be called AFTER the data was sent. After it - * is called, the data is no longer available in the buffer. And don't pass - * wrong nbytes values. - * @param nbytes the amount of bytes to discard - */ - virtual void consumeWriteBuffer(unsigned nbytes); - - /** - * Feeds data into the input buffer. - * This happens when we detected available data in the device and read it. - - * The data will be appended to the buffer or inserted at the beginning, - * depending on whether @p atBeginning is set or not. - * @param nbytes the number of bytes in the buffer - * @param buffer the data that was read - * @param atBeginning whether to append or insert at the beginning - * @return the number of bytes that have been appended - */ - virtual unsigned feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning = false); - - /** - * Feeds data into the output buffer. - * This happens when the user told us to write some data. - * The data will be appended to the buffer. - * @param nbytes the number of bytes in the buffer - * @param buffer the data that is to be written - * @return the number of bytes that have been appended - */ - virtual unsigned feedWriteBuffer(unsigned nbytes, const char *buffer); - - /** - * Returns the number of bytes in the read buffer - * @return the size of the read buffer in bytes - */ - virtual unsigned readBufferSize() const; - - /** - * Returns the number of bytes in the write buffer - * @return the size of the write buffer in bytes - */ - virtual unsigned writeBufferSize() const; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KBufferedIOPrivate *d; -}; - -#endif // KBUFFEREDIO_H diff --git a/kdecore/kcalendarsystem.cpp b/kdecore/kcalendarsystem.cpp deleted file mode 100644 index 782b272e7..000000000 --- a/kdecore/kcalendarsystem.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> - - 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. -*/ - -// Gregorian calendar system implementation factory for creation of kde calendar -// systems. -// Also default gregorian and factory classes - -#include <kglobal.h> - -#include "kcalendarsystem.h" -#include "klocale.h" - -class KCalendarSystemPrivate -{ -public: - const KLocale * locale; -}; - -KCalendarSystem::KCalendarSystem(const KLocale * locale) - : d(new KCalendarSystemPrivate) -{ - d->locale = locale; -} - -KCalendarSystem::~KCalendarSystem() -{ - delete d; -} - -const KLocale * KCalendarSystem::locale() const -{ - if ( d->locale ) - return d->locale; - - return KGlobal::locale(); -} - -TQString KCalendarSystem::dayString(const TQDate & pDate, bool bShort) const -{ - TQString sResult; - - sResult.setNum(day(pDate)); - if (!bShort && sResult.length() == 1 ) - sResult.prepend('0'); - - return sResult; -} - -TQString KCalendarSystem::monthString(const TQDate & pDate, bool bShort) const -{ - TQString sResult; - - sResult.setNum(month(pDate)); - if (!bShort && sResult.length() == 1 ) - sResult.prepend('0'); - - return sResult; -} - -TQString KCalendarSystem::yearString(const TQDate & pDate, bool bShort) const -{ - TQString sResult; - - sResult.setNum(year(pDate)); - if (bShort && sResult.length() == 4 ) - sResult = sResult.right(2); - - return sResult; -} - -static int stringToInteger(const TQString & sNum, int & iLength) -{ - unsigned int iPos = 0; - - int result = 0; - for (; sNum.length() > iPos && sNum.tqat(iPos).isDigit(); iPos++) - { - result *= 10; - result += sNum.tqat(iPos).digitValue(); - } - - iLength = iPos; - return result; -} - - -int KCalendarSystem::dayStringToInteger(const TQString & sNum, int & iLength) const -{ - return stringToInteger(sNum, iLength); -} - -int KCalendarSystem::monthStringToInteger(const TQString & sNum, int & iLength) const -{ - return stringToInteger(sNum, iLength); -} - -int KCalendarSystem::yearStringToInteger(const TQString & sNum, int & iLength) const -{ - return stringToInteger(sNum, iLength); -} - -TQString KCalendarSystem::weekDayName (int weekDay, bool shortName) const -{ - if ( shortName ) - switch ( weekDay ) - { - case 1: return locale()->translate("Monday", "Mon"); - case 2: return locale()->translate("Tuesday", "Tue"); - case 3: return locale()->translate("Wednesday", "Wed"); - case 4: return locale()->translate("Thursday", "Thu"); - case 5: return locale()->translate("Friday", "Fri"); - case 6: return locale()->translate("Saturday", "Sat"); - case 7: return locale()->translate("Sunday", "Sun"); - } - else - switch ( weekDay ) - { - case 1: return locale()->translate("Monday"); - case 2: return locale()->translate("Tuesday"); - case 3: return locale()->translate("Wednesday"); - case 4: return locale()->translate("Thursday"); - case 5: return locale()->translate("Friday"); - case 6: return locale()->translate("Saturday"); - case 7: return locale()->translate("Sunday"); - } - - return TQString::null; -} - diff --git a/kdecore/kcalendarsystem.h b/kdecore/kcalendarsystem.h deleted file mode 100644 index 826539a65..000000000 --- a/kdecore/kcalendarsystem.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org> - - 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 KCALENDARSYSTEM_H -#define KCALENDARSYSTEM_H - -#include <tqdatetime.h> -#include <tqstring.h> -#include "kdelibs_export.h" - -class KLocale; - -class KCalendarSystemPrivate; - -/** - * CalendarSystem abstract class, default derived kde gregorian class and - * factory class. Provides support for different calendar types for kde - * calendar widget and related stuff. - * - * Derived classes must be created through KCalendarFactory class - * - * @author Carlos Moro <cfmoro@correo.uniovi.es> - * @since 3.2 - */ -class KDECORE_EXPORT KCalendarSystem -{ -public: - /** - * Constructor of abstract calendar class. This will be called by the derived classes. - * - * @param locale It will use this locale for translations, 0 means global. - */ - KCalendarSystem(const KLocale * locale = 0); - - /** - * Descructor. - */ - virtual ~KCalendarSystem(); - - /** - * Gets specific calendar type year for a given gregorian date - * - * @param date gregorian date - * @return year - */ - virtual int year (const TQDate & date) const = 0; - - /** - * Converts a date into a year literal - * - * @param pDate The date to convert - * @param bShort If the short version of should be used - * @return The year literal of the date - */ - virtual TQString yearString(const TQDate & pDate, bool bShort) const; - - /** - * Converts a year literal of a part of a string into a integer starting at the beginning of the string - * - * @param sNum The string to parse - * @param iLength The number of QChars used, and 0 if no valid symbols was found in the string - * @return An integer corresponding to the year - */ - virtual int yearStringToInteger(const TQString & sNum, int & iLength) const; - - /** - * Gets specific calendar type month for a given gregorian date - * - * @param date gregorian date - * @return month number - */ - virtual int month (const TQDate & date) const = 0; - - /** - * Converts a date into a month literal - * - * @param pDate The date to convert - * @param bShort If the short version of should be used - * @return The month literal of the date - */ - virtual TQString monthString(const TQDate & pDate, bool bShort) const; - - /** - * Converts a month literal of a part of a string into a integer starting at the beginning of the string - * - * @param sNum The string to parse - * @param iLength The number of QChars used, and 0 if no valid symbols was found in the string - * @return An integer corresponding to the month - */ - virtual int monthStringToInteger(const TQString & sNum, int & iLength) const; - - /** - * Gets specific calendar type day number of month for a given date - * - * @param date gregorian date equivalent to the specific one - * @return day of the month - */ - virtual int day (const TQDate & date) const = 0; - - /** - * Converts a date into a day literal - * - * @param pDate The date to convert - * @param bShort If the short version of should be used - * @return The day literal of the date - */ - virtual TQString dayString(const TQDate & pDate, bool bShort) const; - - /** - * Converts a day literal of a part of a string into a integer starting at the beginning of the string - * - * @param sNum The string to parse - * @param iLength The number of QChars used, and 0 if no valid symbols was found in the string - * @return An integer corresponding to the day - */ - virtual int dayStringToInteger(const TQString & sNum, int & iLength) const; - - /** - * Gets specific calendar type number of day of week number for a given - * date - * - * @param date gregorian date - * @return day of week - */ - virtual int dayOfWeek (const TQDate & date) const = 0; - - /** - * Gets specific calendar type day number of year for a given date - * - * @param date gregorian date equivalent to the specific one - * @return day number - */ - virtual int dayOfYear (const TQDate & date) const = 0; - - /** - * Changes the date's year, month and day. The range of the year, month - * and day depends on which calendar is being used. - * - * @param date Date to change - * @param y Year - * @param m Month number - * @param d Day of month - * @return true if the date is valid; otherwise returns false. - */ - virtual bool setYMD(TQDate & date, int y, int m, int d) const = 0; - - /** - * Returns a TQDate object containing a date nyears later. - * - * @param date The old date - * @param nyears The number of years to add - * @return The new date - */ - virtual TQDate addYears(const TQDate & date, int nyears) const = 0; - - /** - * Returns a TQDate object containing a date nmonths later. - * - * @param date The old date - * @param nmonths The number of months to add - * @return The new date - */ - virtual TQDate addMonths(const TQDate & date, int nmonths) const = 0; - - /** - * Returns a TQDate object containing a date ndays later. - * - * @param date The old date - * @param ndays The number of days to add - * @return The new date - */ - virtual TQDate addDays(const TQDate & date, int ndays) const = 0; - - /** - * Gets specific calendar type number of month for a given year - * - * @param date The date whose year to use - * @return The number of months in that year - */ - virtual int monthsInYear (const TQDate & date) const = 0; - - /** - * Gets the number of days in date whose years specified. - * - * @param date Gregorian date equivalent to the specific one - * @return The number of days in year - */ - virtual int daysInYear (const TQDate & date) const = 0; - - /** - * Gets specific calendar type number of days in month for a given date - * - * @param date gregorian date - * @return number of days for month in date - */ - virtual int daysInMonth (const TQDate & date) const = 0; - - /** - * Gets the number of weeks in a specified year - * - * @param year the year - * @return number of weeks in year - */ - virtual int weeksInYear(int year) const = 0; - - /** - * Gets specific calendar type week number for a given date - * - * @param date gregorian date - * @param yearNum The year the date belongs to - * @return week number - */ - virtual int weekNumber(const TQDate& date, int * yearNum = 0) const = 0; - - /** - * Gets specific calendar type month name for a given month number - * If an invalid month is specified, TQString::null is returned. - * - * @param month The month number - * @param year The year the month belongs to - * @param shortName Specifies if the short month name should be used - * @return The name of the month - */ - virtual TQString monthName (int month, int year, bool shortName = false) const = 0; - - /** - * Gets specific calendar type month name for a given gregorian date - * - * @param date Gregorian date - * @param shortName Specifies if the short month name should be used - * @return The name of the month - */ - virtual TQString monthName (const TQDate & date, bool shortName = false ) const = 0; - - /** - * Returns a string containing the possessive form of the month name. - * ("of January", "of February", etc.) - * It's needed in long format dates in some languages. - * If an invalid month is specified, TQString::null is returned. - * - * @param month The month number - * @param year The year the month belongs to - * @param shortName Specifies if the short month name should be used - * - * @return The possessive form of the name of the month - */ - virtual TQString monthNamePossessive(int month, int year, bool shortName = false) const = 0; - - /** - * Returns a string containing the possessive form of the month name. - * ("of January", "of February", etc.) - * It's needed in long format dates in some languages. - * - * @param date Gregorian date - * @param shortName Specifies if the short month name should be used - * - * @return The possessive form of the name of the month - */ - virtual TQString monthNamePossessive(const TQDate & date, bool shortName = false) const = 0; - - /** - * Gets specific calendar type week day name - * If an invalid week day is specified, TQString::null is returned. - * - * @param weekDay number of day in week (1 -> Monday) - * @param shortName short or complete day name - * @return day name - */ - virtual TQString weekDayName (int weekDay, bool shortName = false) const = 0; - - /** - * Gets specific calendar type week day name - * - * @param date the date - * @param shortName short or complete day name - * @return day name - */ - virtual TQString weekDayName (const TQDate & date, bool shortName = false) const = 0; - - /** - * Gets the first year value supported by specific calendar type - * algorithms. - * - * @return first year supported - */ - virtual int minValidYear () const = 0; - - /** - * Gets the maximum year value supported by specific calendar type - * algorithms (TQDate, 8000) - * - * @return maximum year supported - */ - virtual int maxValidYear () const = 0; - - /** - * Gets the day of the week traditionaly associated with pray - * - * @return day number - */ - virtual int weekDayOfPray () const = 0; - - /** - * Gets the string representing the calendar - */ - virtual TQString calendarName() const = 0; - - /** - * Gets if the calendar is lunar based - * - * @return if the calendar is lunar based - */ - virtual bool isLunar() const = 0; - - /** - * Gets if the calendar is lunisolar based - * - * @return if the calendar is lunisolar based - */ - virtual bool isLunisolar() const = 0; - - /** - * Gets if the calendar is solar based - * - * @return if the calendar is solar based - */ - virtual bool isSolar() const = 0; - -protected: - /** - * Gets the locale the calendar uses for translations. Set in - * the constructor. - */ - const KLocale * locale() const; - -private: - KCalendarSystemPrivate * d; -}; - -#endif diff --git a/kdecore/kcalendarsystemfactory.cpp b/kdecore/kcalendarsystemfactory.cpp deleted file mode 100644 index 723873497..000000000 --- a/kdecore/kcalendarsystemfactory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org> - - 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. -*/ - -// Gregorian calendar system implementation factory for creation of kde -// calendar systems. -// Also default gregorian and factory classes - -#include <kdebug.h> - -#include "kcalendarsystemfactory.h" - -#include "kcalendarsystemgregorian.h" -#include "kcalendarsystemhijri.h" -#include "kcalendarsystemhebrew.h" -#include "kcalendarsystemjalali.h" - -KCalendarSystemFactory::KCalendarSystemFactory() -{ - kdDebug(5400) << "Created factory calendar" << endl; -} - -KCalendarSystemFactory::~KCalendarSystemFactory() -{ -} - -KCalendarSystem *KCalendarSystemFactory::create( const TQString &calType, - const KLocale * locale ) -{ - if ( calType == "hebrew" ) - return new KCalendarSystemHebrew(locale); - if ( calType == "hijri" ) - return new KCalendarSystemHijri(locale); - if ( calType == "gregorian" ) - return new KCalendarSystemGregorian(locale); - if ( calType == "jalali" ) - return new KCalendarSystemJalali(locale); - - kdDebug(5400) << "Calendar " << calType << " not found, defaulting to gregorian" << endl; - - // ### HPB: Should it really be a default here? - return new KCalendarSystemGregorian(locale); -} - -TQStringList KCalendarSystemFactory::calendarSystems() -{ - TQStringList lst; - lst.append("hebrew"); - lst.append("hijri"); - lst.append("gregorian"); - lst.append("jalali"); - - return lst; -} diff --git a/kdecore/kcalendarsystemfactory.h b/kdecore/kcalendarsystemfactory.h deleted file mode 100644 index 0ceae43b9..000000000 --- a/kdecore/kcalendarsystemfactory.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> - - 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 KCALENDARSYSTEMFACTORY_H -#define KCALENDARSYSTEMFACTORY_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include "kdelibs_export.h" - -class KCalendarSystem; -class KLocale; - -/** - * Factory class for calendar types - * @author Carlos Moro <cfmoro@correo.uniovi.es> - * @since 3.2 - */ -class KDECORE_EXPORT KCalendarSystemFactory -{ -public: - KCalendarSystemFactory (); - ~KCalendarSystemFactory (); - - /** - * Gets specific calendar type number of days in previous month for a - * given date - * - * @param calType string identification of the specific calendar type - * to be constructed - * @param locale Locale used for translations. Use the global locale when - * 0 is specified. - * @return a KCalendarSystem object - */ - static KCalendarSystem *create (const TQString & calType = TQString::tqfromLatin1("gregorian"), - const KLocale * locale = 0); - - /** - * Gets list of names of supported calendar systems - * - * @return A TQStringList object - */ - static TQStringList calendarSystems(); - -private: -}; - -#endif diff --git a/kdecore/kcalendarsystemgregorian.cpp b/kdecore/kcalendarsystemgregorian.cpp deleted file mode 100644 index 19f9b3dc8..000000000 --- a/kdecore/kcalendarsystemgregorian.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org> - - 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. -*/ - -// Derived gregorian kde calendar class -// Just a schema. - -#include <tqdatetime.h> -#include <tqstring.h> - -#include <klocale.h> -#include <kdebug.h> - -#include "kcalendarsystemgregorian.h" - -KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) - : KCalendarSystem(locale) -{ -} - -KCalendarSystemGregorian::~KCalendarSystemGregorian() -{ -} - -int KCalendarSystemGregorian::year(const TQDate& date) const -{ - return date.year(); -} - -int KCalendarSystemGregorian::monthsInYear( const TQDate & date ) const -{ - Q_UNUSED( date ) - - return 12; -} - -int KCalendarSystemGregorian::weeksInYear(int year) const -{ - TQDate temp; - temp.setYMD(year, 12, 31); - - // If the last day of the year is in the first week, we have to check the - // week before - if ( temp.weekNumber() == 1 ) - temp = TQT_TQDATE_OBJECT(temp.addDays(-7)); - - return temp.weekNumber(); -} - -int KCalendarSystemGregorian::weekNumber(const TQDate& date, - int * yearNum) const -{ - return date.weekNumber(yearNum); -} - -TQString KCalendarSystemGregorian::monthName(const TQDate& date, - bool shortName) const -{ - return monthName(month(date), year(date), shortName); -} - -TQString KCalendarSystemGregorian::monthNamePossessive(const TQDate& date, bool shortName) const -{ - return monthNamePossessive(month(date), year(date), shortName); -} - -TQString KCalendarSystemGregorian::monthName(int month, int year, bool shortName) const -{ - Q_UNUSED(year); - - if ( shortName ) - switch ( month ) - { - case 1: - return locale()->translate("January", "Jan"); - case 2: - return locale()->translate("February", "Feb"); - case 3: - return locale()->translate("March", "Mar"); - case 4: - return locale()->translate("April", "Apr"); - case 5: - return locale()->translate("May short", "May"); - case 6: - return locale()->translate("June", "Jun"); - case 7: - return locale()->translate("July", "Jul"); - case 8: - return locale()->translate("August", "Aug"); - case 9: - return locale()->translate("September", "Sep"); - case 10: - return locale()->translate("October", "Oct"); - case 11: - return locale()->translate("November", "Nov"); - case 12: - return locale()->translate("December", "Dec"); - } - else - switch ( month ) - { - case 1: - return locale()->translate("January"); - case 2: - return locale()->translate("February"); - case 3: - return locale()->translate("March"); - case 4: - return locale()->translate("April"); - case 5: - return locale()->translate("May long", "May"); - case 6: - return locale()->translate("June"); - case 7: - return locale()->translate("July"); - case 8: - return locale()->translate("August"); - case 9: - return locale()->translate("September"); - case 10: - return locale()->translate("October"); - case 11: - return locale()->translate("November"); - case 12: - return locale()->translate("December"); - } - - return TQString::null; -} - -TQString KCalendarSystemGregorian::monthNamePossessive(int month, int year, - bool shortName) const -{ - Q_UNUSED(year); - - if ( shortName ) - switch ( month ) - { - case 1: - return locale()->translate("of January", "of Jan"); - case 2: - return locale()->translate("of February", "of Feb"); - case 3: - return locale()->translate("of March", "of Mar"); - case 4: - return locale()->translate("of April", "of Apr"); - case 5: - return locale()->translate("of May short", "of May"); - case 6: - return locale()->translate("of June", "of Jun"); - case 7: - return locale()->translate("of July", "of Jul"); - case 8: - return locale()->translate("of August", "of Aug"); - case 9: - return locale()->translate("of September", "of Sep"); - case 10: - return locale()->translate("of October", "of Oct"); - case 11: - return locale()->translate("of November", "of Nov"); - case 12: - return locale()->translate("of December", "of Dec"); - } - else - switch ( month ) - { - case 1: - return locale()->translate("of January"); - case 2: - return locale()->translate("of February"); - case 3: - return locale()->translate("of March"); - case 4: - return locale()->translate("of April"); - case 5: - return locale()->translate("of May long", "of May"); - case 6: - return locale()->translate("of June"); - case 7: - return locale()->translate("of July"); - case 8: - return locale()->translate("of August"); - case 9: - return locale()->translate("of September"); - case 10: - return locale()->translate("of October"); - case 11: - return locale()->translate("of November"); - case 12: - return locale()->translate("of December"); - } - - return TQString::null; -} - -bool KCalendarSystemGregorian::setYMD(TQDate & date, int y, int m, int d) const -{ - // We don't want Qt to add 1900 to them - if ( y >= 0 && y <= 99 ) - return false; - - // TQDate supports gregorian internally - return date.setYMD(y, m, d); -} - -TQDate KCalendarSystemGregorian::addYears(const TQDate & date, int nyears) const -{ - return TQT_TQDATE_OBJECT(date.addYears(nyears)); -} - -TQDate KCalendarSystemGregorian::addMonths(const TQDate & date, int nmonths) const -{ - return TQT_TQDATE_OBJECT(date.addMonths(nmonths)); -} - -TQDate KCalendarSystemGregorian::addDays(const TQDate & date, int ndays) const -{ - return TQT_TQDATE_OBJECT(date.addDays(ndays)); -} - -TQString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const -{ - // ### Should this really be different to each calendar system? Or are we - // only going to support weeks with 7 days? - - return KCalendarSystem::weekDayName(col, shortName); -} - -TQString KCalendarSystemGregorian::weekDayName(const TQDate& date, bool shortName) const -{ - return weekDayName(dayOfWeek(date), shortName); -} - - -int KCalendarSystemGregorian::dayOfWeek(const TQDate& date) const -{ - return date.dayOfWeek(); -} - -int KCalendarSystemGregorian::dayOfYear(const TQDate & date) const -{ - return date.dayOfYear(); -} - -int KCalendarSystemGregorian::daysInMonth(const TQDate& date) const -{ - return date.daysInMonth(); -} - -int KCalendarSystemGregorian::minValidYear() const -{ - return 1753; // TQDate limit -} - -int KCalendarSystemGregorian::maxValidYear() const -{ - return 8000; // TQDate limit -} - -int KCalendarSystemGregorian::day(const TQDate& date) const -{ - return date.day(); -} - -int KCalendarSystemGregorian::month(const TQDate& date) const -{ - return date.month(); -} - -int KCalendarSystemGregorian::daysInYear(const TQDate& date) const -{ - return date.daysInYear(); -} - -int KCalendarSystemGregorian::weekDayOfPray() const -{ - return 7; // sunday -} - -TQString KCalendarSystemGregorian::calendarName() const -{ - return TQString::tqfromLatin1("gregorian"); -} - -bool KCalendarSystemGregorian::isLunar() const -{ - return false; -} - -bool KCalendarSystemGregorian::isLunisolar() const -{ - return false; -} - -bool KCalendarSystemGregorian::isSolar() const -{ - return true; -} - -int KCalendarSystemGregorian::yearStringToInteger(const TQString & sNum, int & iLength) const -{ - int iYear; - iYear = KCalendarSystem::yearStringToInteger(sNum, iLength); - - // Qt treats a year in the range 0-100 as 1900-1999. - // It is nicer for the user if we treat 0-68 as 2000-2068 - if (iYear < 69) - iYear += 2000; - else if (iYear < 100) - iYear += 1900; - - return iYear; -} diff --git a/kdecore/kcalendarsystemgregorian.h b/kdecore/kcalendarsystemgregorian.h deleted file mode 100644 index b116c40f4..000000000 --- a/kdecore/kcalendarsystemgregorian.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> - - 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 KCALENDARSYSTEMGREGORIAN_H -#define KCALENDARSYSTEMGREGORIAN_H - -#include <tqdatetime.h> -#include <tqstring.h> - -#include "kcalendarsystem.h" - -class KCalendarSystemGregorianPrivate; - -/** - * @internal - * This is the Gregorian calendar implementation. - * - * The Gregorian calender is the most used calendar today. The first year in - * the calendar is set to the birth of Christ. - * - * @see KLocale,KCalendarSystem,KCalendarSystemFactory - * - * @author Carlos Moro <cfmoro@correo.uniovi.es> - * @since 3.2 - */ -class KDECORE_EXPORT KCalendarSystemGregorian: public KCalendarSystem -{ -public: - /** Constructor. Just like KCalendarSystem::KCalendarSystem(). */ - KCalendarSystemGregorian (const KLocale * locale = 0); - virtual ~KCalendarSystemGregorian (); - - virtual int year (const TQDate & date) const; - virtual int month (const TQDate & date) const; - virtual int day (const TQDate & date) const; - virtual int dayOfWeek (const TQDate & date) const; - virtual int dayOfYear (const TQDate & date) const; - - virtual bool setYMD(TQDate & date, int y, int m, int d) const; - - virtual TQDate addYears(const TQDate & date, int nyears) const; - virtual TQDate addMonths(const TQDate & date, int nmonths) const; - virtual TQDate addDays(const TQDate & date, int ndays) const; - - virtual int monthsInYear (const TQDate & date) const; - - virtual int daysInYear (const TQDate & date) const; - virtual int daysInMonth (const TQDate & date) const; - virtual int weeksInYear(int year) const; - virtual int weekNumber(const TQDate& date, int * yearNum = 0) const; - - virtual int yearStringToInteger(const TQString & sNum, int & iLength) const; - - virtual TQString monthName (int month, int year, bool shortName = false) const; - virtual TQString monthName (const TQDate & date, bool shortName = false ) const; - virtual TQString monthNamePossessive(int month, int year, bool shortName = false) const; - virtual TQString monthNamePossessive(const TQDate & date, bool shortName = false ) const; - virtual TQString weekDayName (int weekDay, bool shortName = false) const; - virtual TQString weekDayName (const TQDate & date, bool shortName = false) const; - - virtual int minValidYear () const; - virtual int maxValidYear () const; - virtual int weekDayOfPray () const; - - virtual TQString calendarName() const; - - virtual bool isLunar() const; - virtual bool isLunisolar() const; - virtual bool isSolar() const; - -private: - KCalendarSystemGregorianPrivate * d; -}; - -#endif diff --git a/kdecore/kcalendarsystemhebrew.cpp b/kdecore/kcalendarsystemhebrew.cpp deleted file mode 100644 index 710e027d1..000000000 --- a/kdecore/kcalendarsystemhebrew.cpp +++ /dev/null @@ -1,746 +0,0 @@ -/* - Copyright (c) 2003 Hans Petter Bieker <bieker@kde.org> - Calendar conversion routines based on Hdate v6, by Amos - Shapir 1978 (rev. 1985, 1992) - - 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. -*/ - -// Derived hebrew kde calendar class - -#include <klocale.h> -#include <kdebug.h> - -#include "kcalendarsystemhebrew.h" - -static int hebrewDaysElapsed(int y); -static TQString num2heb(int num, bool includeMillenium); - -class h_date -{ -public: - int hd_day; - int hd_mon; - int hd_year; - int hd_dw; - int hd_flg; -}; - -/* - * compute general date structure from hebrew date - */ -static class h_date * hebrewToGregorian(int y, int m, int d) -{ - static class h_date h; - int s; - - y -= 3744; - s = hebrewDaysElapsed(y); - d += s; - s = hebrewDaysElapsed(y + 1) - s; /* length of year */ - - if (s > 365 && m > 6 ) - { - --m; - d += 30; - } - d += (59 * (m - 1) + 1) / 2; /* regular months */ - /* special cases */ - if (s % 10 > 4 && m > 2) /* long Heshvan */ - d++; - if (s % 10 < 4 && m > 3) /* short Kislev */ - d--; - // ### HPB: Broken in leap years - //if (s > 365 && m > 6) /* leap year */ - // d += 30; - d -= 6002; - - y = (d + 36525) * 4 / 146097 - 1; - d -= y / 4 * 146097 + (y % 4) * 36524; - y *= 100; - - /* compute year */ - s = (d + 366)*4/1461-1; - d -= s/4*1461 + (s % 4)*365; - y += s; - /* compute month */ - m = (d + 245)*12/367-7; - d -= m*367/12-30; - if (++m >= 12) { - m -= 12; - y++; - } - h.hd_day = d; - h.hd_mon = m; - h.hd_year = y; - return(&h); -} - -/* - * compute date structure from no. of days since 1 Tishrei 3744 - */ -static class h_date * gregorianToHebrew(int y, int m, int d) -{ - static class h_date h; - int s; - - if ((m -= 2) <= 0) { - m += 12; - y--; - } - /* no. of days, Julian calendar */ - d += 365*y + y/4 + 367*m/12 + 5968; - /* Gregorian calendar */ - d -= y/100-y/400-2; - h.hd_dw = (d + 1) % 7; - - /* compute the year */ - y += 16; - s = hebrewDaysElapsed(y); - m = hebrewDaysElapsed(y + 1); - while(d >= m) { /* computed year was underestimated */ - s = m; - y++; - m = hebrewDaysElapsed(y + 1); - } - d -= s; - s = m-s; /* size of current year */ - y += 3744; - - h.hd_flg = s % 10-4; - - /* compute day and month */ - if (d >= s-236) { /* last 8 months are regular */ - d -= s-236; - m = d*2/59; - d -= (m*59 + 1)/2; - m += 4; - if (s > 365 && m <= 5) /* Adar of Meuberet */ - m += 8; - } else { - /* first 4 months have 117-119 days */ - s = 114 + s % 10; - m = d * 4 / s; - d -= (m * s + 3) / 4; - } - - h.hd_day = d; - h.hd_mon = m; - h.hd_year = y; - return(&h); -} - -static TQString num2heb(int num, bool includeMillenium) -{ - const TQChar decade[] = {0x05D8, 0x05D9, 0x05DB, 0x05DC, 0x05DE, - 0x05E0, 0x05E1, 0x05E2, 0x05E4, 0x05E6}; - TQString result; - - if (num < 1 || num > 9999) - return TQString::number(num); - - if (num >= 1000) { - if (includeMillenium || num % 1000 == 0) - result += TQChar(0x05D0 - 1 + num / 1000); - num %= 1000; - } - if (num >= 100) { - while (num >= 500) { - result += TQChar(0x05EA); - num -= 400; - } - result += TQChar(0x05E7 - 1 + num / 100); - num %= 100; - } - if (num >= 10) { - if (num == 15 || num == 16) - num -= 9; - result += decade[num / 10]; - num %= 10; - } - if (num > 0) - result += TQChar(0x05D0 - 1 + num); - - if (result.length() == 1) - result += "'"; - else - result.insert(result.length() - 1, '\"'); - - return result; -} - -/* constants, in 1/18th of minute */ -static const int HOUR = 1080; -static const int DAY = 24*HOUR; -static const int WEEK = 7*DAY; -#define M(h,p) ((h)*HOUR+p) -#define MONTH (DAY+M(12,793)) - -/** - * @internal - * no. of days in y years - */ -static int hebrewDaysElapsed(int y) -{ - int m, nm, dw, s, l; - - l = y * 7 + 1; // no. of leap months - m = y*12+l/19; // total no. of months - l %= 19; - nm = m*MONTH+M(1+6,779); // molad new year 3744 (16BC) + 6 hours - s = m*28+nm/DAY-2; - - nm %= WEEK; - dw = nm/DAY; - nm %= DAY; - - // special cases of Molad Zaken - if (l < 12 && dw == 3 && nm >= M(9 + 6,204) || - l < 7 && dw == 2 && nm>=M(15+6,589)) - s++,dw++; - /* ADU */ - if (dw == 1 || dw == 4 || dw == 6) - s++; - return s; -} - -/** - * @internal - * true if long Cheshvan - */ -static int long_cheshvan(int year) -{ - TQDate first, last; - class h_date *gd; - - gd = hebrewToGregorian(year, 1, 1); - first.setYMD(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1); - - gd = hebrewToGregorian(year + 1, 1, 1); - last.setYMD(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1); - - return (first.daysTo(last) % 10 == 5); -} - -/** - * @internal - * true if short Kislev - */ -static int short_kislev(int year) -{ - TQDate first, last; - class h_date * gd; - - gd = hebrewToGregorian(year, 1, 1); - first.setYMD(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1); - - gd = hebrewToGregorian(year + 1, 1, 1); - last.setYMD(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1); - - return (first.daysTo(last) % 10 == 3); -} - -static bool is_leap_year(int year) -{ - return ((((7 * year) + 1) % 19) < 7); -} - -// Ok -KCalendarSystemHebrew::KCalendarSystemHebrew(const KLocale * locale) - : KCalendarSystem(locale) -{ -} - -// Ok -KCalendarSystemHebrew::~KCalendarSystemHebrew() -{ -} - -// Ok -static class h_date * toHebrew(const TQDate & date) -{ - class h_date *sd; - sd = gregorianToHebrew(date.year(), date.month(), date.day()); - ++sd->hd_mon; - ++sd->hd_day; - return sd; -} - -// Ok -int KCalendarSystemHebrew::year(const TQDate& date) const -{ - class h_date *sd = toHebrew(date); - return sd->hd_year; -} - -// Ok -int KCalendarSystemHebrew::monthsInYear( const TQDate & date ) const -{ - if ( is_leap_year( year(date) ) ) - return 13; - else - return 12; -} - -// Ok -int KCalendarSystemHebrew::weeksInYear(int year) const -{ - TQDate temp; - setYMD(temp, year, 1, 1); // don't pass an uninitialized TQDate to - // monthsInYear in the next call - setYMD(temp, year, monthsInYear(temp), hndays(monthsInYear(temp), year) ); - - int nWeekNumber = weekNumber(temp); - if(nWeekNumber == 1) // last week belongs to next year - { - temp = TQT_TQDATE_OBJECT(temp.addDays(-7)); - nWeekNumber = weekNumber(temp); - } - - return nWeekNumber; -} - -int KCalendarSystemHebrew::weekNumber(const TQDate& date, int * yearNum) const -{ - TQDate firstDayWeek1, lastDayOfYear; - int y = year(date); - int week; - int weekDay1, dayOfWeek1InYear; - - // let's guess 1st day of 1st week - setYMD(firstDayWeek1, y, 1, 1); - weekDay1 = dayOfWeek(firstDayWeek1); - - // iso 8601: week 1 is the first containing thursday and week starts on - // monday - if (weekDay1 > 4 /*Thursday*/) - firstDayWeek1 = addDays(firstDayWeek1 , 7 - weekDay1 + 1); // next monday - - dayOfWeek1InYear = dayOfYear(firstDayWeek1); - - if ( dayOfYear(date) < dayOfWeek1InYear ) // our date in prev year's week - { - if ( yearNum ) - *yearNum = y - 1; - return weeksInYear(y - 1); - } - - // let's check if its last week belongs to next year - setYMD(lastDayOfYear, y + 1, 1, 1); - lastDayOfYear = addDays(lastDayOfYear, -1); - if ( (dayOfYear(date) >= daysInYear(date) - dayOfWeek(lastDayOfYear) + 1) - // our date is in last week - && dayOfWeek(lastDayOfYear) < 4) // 1st week in next year has thursday - { - if ( yearNum ) - *yearNum = y + 1; - week = 1; - } - else - { - if( weekDay1 < 5 ) // To calculate properly the number of weeks - // from day a to x let's make a day 1 of week - firstDayWeek1 = addDays( firstDayWeek1, -( weekDay1 - 1)); - - week = firstDayWeek1.daysTo(date) / 7 + 1; - } - - return week; -} - -// Ok -TQString KCalendarSystemHebrew::monthName(const TQDate& date, - bool shortName) const -{ - return monthName(month(date), year(date), shortName); -} - -// Ok -TQString KCalendarSystemHebrew::monthNamePossessive(const TQDate& date, - bool shortName) const -{ - return monthNamePossessive(month(date), year(date), shortName); -} - -// ### Fixme -TQString KCalendarSystemHebrew::monthName(int month, int year, bool /*shortName*/) const -{ - if ( month < 1 ) - return TQString::null; - if ( is_leap_year(year) ) - { - if ( month > 13 ) - return TQString::null; - } - else if ( month > 12 ) - return TQString::null; - - // We must map conversion algorithm month index to real index - if( month == 6 && is_leap_year(year) ) - month = 13; /*Adar I*/ - else if ( month == 7 && is_leap_year(year) ) - month = 14; /*Adar II*/ - else if ( month > 7 && is_leap_year(year) ) - month--; //Because of Adar II - - switch(month) - { - case 1: - return locale()->translate("Tishrey"); - case 2: - return locale()->translate("Heshvan"); - case 3: - return locale()->translate("Kislev"); - case 4: - return locale()->translate("Tevet"); - case 5: - return locale()->translate("Shvat"); - case 6: - return locale()->translate("Adar"); - case 7: - return locale()->translate("Nisan"); - case 8: - return locale()->translate("Iyar"); - case 9: - return locale()->translate("Sivan"); - case 10: - return locale()->translate("Tamuz"); - case 11: - return locale()->translate("Av"); - case 12: - return locale()->translate("Elul"); - case 13: - return locale()->translate("Adar I"); - case 14: - return locale()->translate("Adar II"); - default: - break; - } - - return TQString::null; -} - -// ### Fixme -TQString KCalendarSystemHebrew::monthNamePossessive(int month, int year, - bool shortName) const -{ - return "of " + monthName(month, year, shortName); -} - -bool KCalendarSystemHebrew::setYMD(TQDate & date, int y, int m, int d) const -{ - if( y < minValidYear() || y > maxValidYear() ) - return false; - if( m < 1 || m > (is_leap_year(y) ? 13 : 12) ) - return false; - if( d < 1 || d > hndays(m,y) ) - return false; - - class h_date * gd = hebrewToGregorian( y, m, d ); - - return date.setYMD(gd->hd_year, gd->hd_mon + 1, gd->hd_day + 1); -} - -TQString KCalendarSystemHebrew::weekDayName(int day, bool shortName) const -{ - return KCalendarSystem::weekDayName(day, shortName); -} - -// Ok -TQString KCalendarSystemHebrew::weekDayName(const TQDate& date, - bool shortName) const -{ - return weekDayName(dayOfWeek(date), shortName); -} - -// Ok -int KCalendarSystemHebrew::dayOfWeek(const TQDate& date) const -{ - class h_date *sd = toHebrew(date); - if ( sd->hd_dw == 0 ) - return 7; - else - return (sd->hd_dw); -} - -// Ok -int KCalendarSystemHebrew::dayOfYear(const TQDate & date) const -{ - TQDate first; - setYMD(first, year(date), 1, 1); - - return first.daysTo(date) + 1; -} - -int KCalendarSystemHebrew::daysInMonth(const TQDate& date) const -{ - return hndays(month(date), year(date)); -} - -int KCalendarSystemHebrew::hndays(int mon, int year) const -{ - if ( mon == 6 && is_leap_year(year) ) - mon = 13; /*Adar I*/ - else if ( mon == 7 && is_leap_year(year) ) - mon = 14; /*Adar II*/ - else if ( mon > 7 && is_leap_year(year) ) - mon--; //Because of Adar II - - if( mon == 8 /*IYYAR*/ || mon == 10 /*TAMUZ*/ || - mon == 12 /*ELUL*/ || mon == 4 /*TEVET*/ || - mon == 14 /*ADAR 2*/|| - ( mon == 6 /*ADAR*/ && !is_leap_year(year)) || - (mon == 2 /*CHESHVAN*/ && !long_cheshvan(year)) || - (mon == 3 /*KISLEV*/ && short_kislev(year))) - return 29; - else - return 30; -} - -// Ok -// Min valid year that may be converted to QDate -int KCalendarSystemHebrew::minValidYear() const -{ - TQDate date(1753, 1, 1); - - return year(date); -} - -// Ok -// Max valid year that may be converted to QDate -int KCalendarSystemHebrew::maxValidYear() const -{ - TQDate date(8000, 1, 1); - - return year(date); -} - -// Ok -int KCalendarSystemHebrew::day(const TQDate& date) const -{ - class h_date *sd = toHebrew(date); - - return sd->hd_day; -} - -// Ok -int KCalendarSystemHebrew::month(const TQDate& date) const -{ - class h_date *sd = toHebrew(date); - - int month = sd->hd_mon; - if ( is_leap_year( sd->hd_year ) ) - { - if( month == 13 /*AdarI*/ ) - month = 6; - else if( month == 14 /*AdarII*/ ) - month = 7; - else if ( month > 6 && month < 13 ) - ++month; - } - - return month; -} - -// Ok -int KCalendarSystemHebrew::daysInYear(const TQDate & date) const -{ - TQDate first, last; - setYMD(first, year(date), 1, 1); // 1 Tishrey - setYMD(last, year(date) + 1, 1, 1); // 1 Tishrey the year later - - return first.daysTo(last); -} - -// Ok -int KCalendarSystemHebrew::weekDayOfPray() const -{ - return 6; // saturday -} - -// Ok -TQDate KCalendarSystemHebrew::addDays( const TQDate & date, int ndays ) const -{ - return TQT_TQDATE_OBJECT(date.addDays( ndays )); -} - -// Ok -TQDate KCalendarSystemHebrew::addMonths( const TQDate & date, int nmonths ) const -{ - TQDate result = date; - - while ( nmonths > 0 ) - { - result = addDays(result, daysInMonth(result)); - --nmonths; - } - - while ( nmonths < 0 ) - { - // get the number of days in the previous month to be consistent with - // addMonths where nmonths > 0 - int nDaysInMonth = daysInMonth(addDays(result, -day(result))); - result = addDays(result, -nDaysInMonth); - ++nmonths; - } - - return result; -} - -// Ok -TQDate KCalendarSystemHebrew::addYears( const TQDate & date, int nyears ) const -{ - TQDate result = date; - int y = year(date) + nyears; - - setYMD( result, y, month(date), day(date) ); - - return result; -} - -// Ok -TQString KCalendarSystemHebrew::calendarName() const -{ - return TQString::tqfromLatin1("hebrew"); -} - -// Ok -bool KCalendarSystemHebrew::isLunar() const -{ - return false; -} - -// Ok -bool KCalendarSystemHebrew::isLunisolar() const -{ - return true; -} - -// Ok -bool KCalendarSystemHebrew::isSolar() const -{ - return false; -} - -TQString KCalendarSystemHebrew::dayString(const TQDate & pDate, bool bShort) const -{ - TQString sResult; - - // Only use hebrew numbers if the hebrew setting is selected - if (locale()->language() == TQString::tqfromLatin1("he")) - sResult = num2heb(day(pDate), false); - else - sResult = KCalendarSystem::dayString(pDate, bShort); - - return sResult; -} - -TQString KCalendarSystemHebrew::yearString(const TQDate & pDate, bool bShort) const -{ - TQString sResult; - - // Only use hebrew numbers if the hebrew setting is selected - if (locale()->language() == TQString::tqfromLatin1("he")) - sResult = num2heb(year(pDate), !bShort); - else - sResult = KCalendarSystem::yearString(pDate, bShort); - - return sResult; -} - -static int heb2num(const TQString& str, int & iLength) { - TQChar c; - TQString s = str; - int result = 0; - iLength = 0; - int decadeValues[14] = {10, 20, 20, 30, 40, 40, 50, - 50, 60, 70, 80, 80, 90, 90}; - - uint pos; - for (pos = 0 ; pos < s.length() ; pos++) - { - c = s[pos]; - if (s.length() > pos && (s[pos + 1] == TQChar('\'') || - s[pos + 1] == TQChar('\"'))) - { - iLength++; - s.remove(pos + 1, 1); - } - - if (c >= TQChar(0x05D0) && c <= TQChar(0x05D7)) - { - if (s.length() > pos && s[pos + 1] >= TQChar(0x05D0) && - s[pos + 1] <= TQChar(0x05EA)) - result += (c.tqunicode() - 0x05D0 + 1) * 1000; - else - result += c.tqunicode() - 0x05D0 + 1; - } - else if (c == TQChar(0x05D8)) - { - if (s.length() > pos && s[pos + 1] >= TQChar(0x05D0) && - s[pos + 1] <= TQChar(0x05EA) && s[pos + 1] != TQChar(0x05D5) && - s[pos + 1] != TQChar(0x05D6)) - result += 9000; - else - result += 9; - } - else if (c >= TQChar(0x05D9) && c <= TQChar(0x05E6)) - { - if (s.length() > pos && s[pos + 1] >= TQChar(0x05D9)) - return -1; - else - result += decadeValues[c.tqunicode() - 0x05D9]; - } - else if (c >= TQChar(0x05E7) && c <= TQChar(0x05EA)) - { - result += (c.tqunicode() - 0x05E7 + 1) * 100; - } - else - { - break; - } - } - - iLength += pos; - - return result; -} - -int KCalendarSystemHebrew::dayStringToInteger(const TQString & sNum, int & iLength) const -{ - int iResult; - if (locale()->language() == "he") - iResult= heb2num(sNum, iLength); - else - iResult = KCalendarSystem::yearStringToInteger(sNum, iLength); - - return iResult; -} - -int KCalendarSystemHebrew::yearStringToInteger(const TQString & sNum, int & iLength) const -{ - int iResult; - if (locale()->language() == "he") - iResult = heb2num(sNum, iLength); - else - iResult = KCalendarSystem::yearStringToInteger(sNum, iLength); - - if (iResult < 1000) - iResult += 5000; // assume we're in the 6th millenium (y6k bug) - - return iResult; -} - diff --git a/kdecore/kcalendarsystemhebrew.h b/kdecore/kcalendarsystemhebrew.h deleted file mode 100644 index ec0d82ba2..000000000 --- a/kdecore/kcalendarsystemhebrew.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (c) 2002-2003 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org> - Calendar conversion routines based on Hdate v6, by Amos - Shapir 1978 (rev. 1985, 1992) - - 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 KCALENDARSYSTEMHEBREW_H -#define KCALENDARSYSTEMHEBREW_H - -#include <tqdatetime.h> -#include <tqstring.h> - -#include "kcalendarsystem.h" - -class KCalendarSystemHebrewPrivate; - -/** - * @internal - * This is the Hebrew calendar implementation. - * - * The Hebrew calendar is the traditional Islamic calendar used in the Midle - * East. - * - * @see KLocale,KCalendarSystem,KCalendarSystemFactory - * - * @author Hans Petter Bieker <bieker@kde.org> - * @since 3.2 - */ -class KDECORE_EXPORT KCalendarSystemHebrew : public KCalendarSystem -{ -public: - /** Constructor. Just like KCalendarSystem::KCalendarSystem(). */ - KCalendarSystemHebrew(const KLocale * locale = 0); - virtual ~KCalendarSystemHebrew(); - - virtual int year (const TQDate & date) const; - virtual int month (const TQDate & date) const; - virtual int day (const TQDate & date) const; - virtual int dayOfWeek (const TQDate & date) const; - virtual int dayOfYear (const TQDate & date) const; - - virtual bool setYMD(TQDate & date, int y, int m, int d) const; - - virtual TQDate addYears(const TQDate & date, int nyears) const; - virtual TQDate addMonths(const TQDate & date, int nmonths) const; - virtual TQDate addDays(const TQDate & date, int ndays) const; - - virtual int monthsInYear (const TQDate & date) const; - virtual int daysInYear (const TQDate & date) const; - virtual int daysInMonth (const TQDate & date) const; - virtual int weeksInYear(int year) const; - virtual int weekNumber(const TQDate& date, int * yearNum = 0) const; - - virtual TQString monthName (int month, int year, bool shortName = false) const; - virtual TQString monthName (const TQDate & date, bool shortName = false ) const; - virtual TQString monthNamePossessive(int month, int year, bool shortName = false) const; - virtual TQString monthNamePossessive(const TQDate & date, bool shortName = false ) const; - virtual TQString weekDayName (int weekDay, bool shortName = false) const; - virtual TQString weekDayName (const TQDate & date, bool shortName = false) const; - - virtual TQString dayString(const TQDate & pDate, bool bShort) const; - virtual TQString yearString(const TQDate & pDate, bool bShort) const; - virtual int dayStringToInteger(const TQString & sNum, int & iLength) const; - virtual int yearStringToInteger(const TQString & sNum, int & iLength) const; - - virtual int minValidYear () const; - virtual int maxValidYear () const; - virtual int weekDayOfPray () const; - - virtual TQString calendarName() const; - - virtual bool isLunar() const; - virtual bool isLunisolar() const; - virtual bool isSolar() const; - -private: - /** - * Gets the number of days in a month for a given date - * - * @param year given year - * @param mon month number - * @return number of days in month - */ - int hndays(int year, int mon) const; - - KCalendarSystemHebrewPrivate * d; -}; - -#endif diff --git a/kdecore/kcalendarsystemhijri.cpp b/kdecore/kcalendarsystemhijri.cpp deleted file mode 100644 index 90faec48e..000000000 --- a/kdecore/kcalendarsystemhijri.cpp +++ /dev/null @@ -1,596 +0,0 @@ -/* - Copyright (c) 2002-2003 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org> - - 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. -*/ - -// Derived hijri kde calendar class - -#include <tqdatetime.h> -#include <tqstring.h> - -#include <klocale.h> -#include <kdebug.h> - -#include "kcalendarsystemhijri.h" - -/* - The following C++ code is translated from the Lisp code - in ``Calendrical Calculations'' by Nachum Dershowitz and - Edward M. Reingold, Software---Practice & Experience, - vol. 20, no. 9 (September, 1990), pp. 899--928. - - This code is in the public domain, but any use of it - should publically acknowledge its source. - - Classes GregorianDate, IslamicDate - */ - -static int lastDayOfGregorianMonth(int month, int year) { -// Compute the last date of the month for the Gregorian calendar. - - switch (month) { - case 2: - if ((((year % 4) == 0) && ((year % 100) != 0)) - || ((year % 400) == 0)) - return 29; - else - return 28; - case 4: - case 6: - case 9: - case 11: return 30; - default: return 31; - } -} - -class GregorianDate { -private: - int year; // 1... - int month; // 1 == January, ..., 12 == December - int day; // 1..lastDayOfGregorianMonth(month, year) - -public: - GregorianDate(int m, int d, int y) { month = m; day = d; year = y; } - - GregorianDate(int d) { // Computes the Gregorian date from the absolute date. - - // Search forward year by year from approximate year - year = d/366; - while (d >= GregorianDate(1,1,year+1)) - year++; - // Search forward month by month from January - month = 1; - while (d > GregorianDate(month, lastDayOfGregorianMonth(month,year), year)) - month++; - day = d - GregorianDate(month,1,year) + 1; - } - - operator int() { // Computes the absolute date from the Gregorian date. - int N = day; // days this month - for (int m = month - 1; m > 0; m--) // days in prior months this year - N = N + lastDayOfGregorianMonth(m, year); - return - (N // days this year - + 365 * (year - 1) // days in previous years ignoring leap days - + (year - 1)/4 // Julian leap days before this year... - - (year - 1)/100 // ...minus prior century years... - + (year - 1)/400); // ...plus prior years divisible by 400 - } - - int getMonth() { return month; } - int getDay() { return day; } - int getYear() { return year; } - -}; - -static int IslamicLeapYear(int year) { -// True if year is an Islamic leap year - - if ((((11 * year) + 14) % 30) < 11) - return 1; - else - return 0; -} - -static const int IslamicEpoch = 227014; // Absolute date of start of - // Islamic calendar - -static int lastDayOfIslamicMonth(int month, int year) { -// Last day in month during year on the Islamic calendar. - - if (((month % 2) == 1) || ((month == 12) && IslamicLeapYear(year))) - return 30; - else - return 29; -} - -class IslamicDate { -private: - int year; // 1... - int month; // 1..13 (12 in a common year) - int day; // 1..lastDayOfIslamicMonth(month,year) - -public: - IslamicDate(int m, int d, int y) { month = m; day = d; year = y; } - - IslamicDate(int d) { // Computes the Islamic date from the absolute date. - if (d <= IslamicEpoch) { // Date is pre-Islamic - month = 0; - day = 0; - year = 0; - } - else { - // Search forward year by year from approximate year - year = (d - IslamicEpoch) / 355; - while (d >= IslamicDate(1,1,year+1)) - year++; - // Search forward month by month from Muharram - month = 1; - while (d > IslamicDate(month, lastDayOfIslamicMonth(month,year), year)) - month++; - day = d - IslamicDate(month,1,year) + 1; - } - } - - operator int() { // Computes the absolute date from the Islamic date. - return (day // days so far this month - + 29 * (month - 1) // days so far... - + month/2 // ...this year - + 354 * (year - 1) // non-leap days in prior years - + (3 + (11 * year)) / 30 // leap days in prior years - + IslamicEpoch); // days before start of calendar - } - - int getMonth() { return month; } - int getDay() { return day; } - int getYear() { return year; } - -}; - -static void gregorianToHijri(const TQDate & date, int * pYear, int * pMonth, - int * pDay) -{ - GregorianDate gregorian(date.month(),date.day(),date.year()); - int absolute = gregorian; - - IslamicDate islamic(absolute); - - if (pYear) - *pYear = islamic.getYear(); - if (pMonth) - *pMonth = islamic.getMonth(); - if (pDay) - *pDay = islamic.getDay(); -} - -KCalendarSystemHijri::KCalendarSystemHijri(const KLocale * locale) - : KCalendarSystem(locale) -{ -} - -KCalendarSystemHijri::~KCalendarSystemHijri() -{ -} - -int KCalendarSystemHijri::year(const TQDate& date) const -{ - int y; - gregorianToHijri(date, &y, 0, 0); - return y; -} - -int KCalendarSystemHijri::month(const TQDate& date) const -{ - int m; - gregorianToHijri(date, 0, &m, 0); - return m; -} - -int KCalendarSystemHijri::day(const TQDate& date) const -{ - int d; - gregorianToHijri(date, 0, 0, &d); - return d; -} - -int KCalendarSystemHijri::monthsInYear( const TQDate & date ) const -{ - Q_UNUSED( date ) - - return 12; -} - -int KCalendarSystemHijri::weeksInYear(int year) const -{ - TQDate temp; - setYMD(temp, year, 12, lastDayOfIslamicMonth(12, year)); - - // If the last day of the year is in the first week, we have to check the - // week before - if ( weekNumber(temp) == 1 ) - temp = addDays(temp, -7); - - return weekNumber(temp); -} - -int KCalendarSystemHijri::weekNumber(const TQDate& date, int * yearNum) const -{ - TQDate firstDayWeek1, lastDayOfYear; - int y = year(date); - int week; - int weekDay1, dayOfWeek1InYear; - - // let's guess 1st day of 1st week - setYMD(firstDayWeek1, y, 1, 1); - weekDay1 = dayOfWeek(firstDayWeek1); - - // iso 8601: week 1 is the first containing thursday and week starts on - // monday - if (weekDay1 > 4 ) - firstDayWeek1 = addDays(firstDayWeek1 , 7 - weekDay1 + 1); // next monday - - dayOfWeek1InYear = dayOfYear(firstDayWeek1); - - if ( dayOfYear(date) < dayOfWeek1InYear ) // our date in prev year's week - { - if ( yearNum ) - *yearNum = y - 1; - return weeksInYear(y - 1); - } - - // let' check if its last week belongs to next year - setYMD(lastDayOfYear, y, 12, lastDayOfIslamicMonth(12, y)); - if ( (dayOfYear(date) >= daysInYear(date) - dayOfWeek(lastDayOfYear) + 1) - // our date is in last week - && dayOfWeek(lastDayOfYear) < 4) // 1st week in next year has thursday - { - if ( yearNum ) - *yearNum = y + 1; - week = 1; - } - else - { - if ( weekDay1 < 5 ) - firstDayWeek1 = addDays(firstDayWeek1, - (weekDay1 - 1)); - - week = firstDayWeek1.daysTo(date) / 7 + 1; - } - - return week; -} - -TQString KCalendarSystemHijri::monthName(const TQDate& date, - bool shortName) const -{ - return monthName(month(date), year(date), shortName); -} - -TQString KCalendarSystemHijri::monthNamePossessive(const TQDate& date, - bool shortName) const -{ - return monthNamePossessive(month(date), year(date), shortName); -} - -TQString KCalendarSystemHijri::monthName(int month, int year, bool shortName) - const { - - Q_UNUSED(year); - - if (shortName) - switch ( month ) - { - case 1: - return locale()->translate("Muharram"); - case 2: - return locale()->translate("Safar"); - case 3: - return locale()->translate("R. Awal"); - case 4: - return locale()->translate("R. Thaani"); - case 5: - return locale()->translate("J. Awal"); - case 6: - return locale()->translate("J. Thaani"); - case 7: - return locale()->translate("Rajab"); - case 8: - return locale()->translate("Sha`ban"); - case 9: - return locale()->translate("Ramadan"); - case 10: - return locale()->translate("Shawwal"); - case 11: - return locale()->translate("Qi`dah"); - case 12: - return locale()->translate("Hijjah"); - } - else - switch ( month ) - { - case 1: - return locale()->translate("Muharram"); - case 2: - return locale()->translate("Safar"); - case 3: - return locale()->translate("Rabi` al-Awal"); - case 4: - return locale()->translate("Rabi` al-Thaani"); - case 5: - return locale()->translate("Jumaada al-Awal"); - case 6: - return locale()->translate("Jumaada al-Thaani"); - case 7: - return locale()->translate("Rajab"); - case 8: - return locale()->translate("Sha`ban"); - case 9: - return locale()->translate("Ramadan"); - case 10: - return locale()->translate("Shawwal"); - case 11: - return locale()->translate("Thu al-Qi`dah"); - case 12: - return locale()->translate("Thu al-Hijjah"); - } - - return TQString::null; -} - -TQString KCalendarSystemHijri::monthNamePossessive(int month, int year, - bool shortName) const -{ - Q_UNUSED(year); - - if (shortName) - switch ( month ) - { - case 1: - return locale()->translate("of Muharram"); - case 2: - return locale()->translate("of Safar"); - case 3: - return locale()->translate("of R. Awal"); - case 4: - return locale()->translate("of R. Thaani"); - case 5: - return locale()->translate("of J. Awal"); - case 6: - return locale()->translate("of J. Thaani"); - case 7: - return locale()->translate("of Rajab"); - case 8: - return locale()->translate("of Sha`ban"); - case 9: - return locale()->translate("of Ramadan"); - case 10: - return locale()->translate("of Shawwal"); - case 11: - return locale()->translate("of Qi`dah"); - case 12: - return locale()->translate("of Hijjah"); - } - else - switch ( month ) - { - case 1: - return locale()->translate("of Muharram"); - case 2: - return locale()->translate("of Safar"); - case 3: - return locale()->translate("of Rabi` al-Awal"); - case 4: - return locale()->translate("of Rabi` al-Thaani"); - case 5: - return locale()->translate("of Jumaada al-Awal"); - case 6: - return locale()->translate("of Jumaada al-Thaani"); - case 7: - return locale()->translate("of Rajab"); - case 8: - return locale()->translate("of Sha`ban"); - case 9: - return locale()->translate("of Ramadan"); - case 10: - return locale()->translate("of Shawwal"); - case 11: - return locale()->translate("of Thu al-Qi`dah"); - case 12: - return locale()->translate("of Thu al-Hijjah"); - } - - return TQString::null; -} - -bool KCalendarSystemHijri::setYMD(TQDate & date, int y, int m, int d) const -{ - // range checks - if ( y < minValidYear() || y > maxValidYear() ) - return false; - - if ( m < 1 || m > 12 ) - return false; - - if ( d < 1 || d > lastDayOfIslamicMonth(m, y) ) - return false; - - IslamicDate islamic (m, d, y); - int absolute = islamic; - GregorianDate gregorian(absolute); - - return date.setYMD(gregorian.getYear(), gregorian.getMonth(), - gregorian.getDay()); -} - -TQString KCalendarSystemHijri::weekDayName(int day, bool shortName) const -{ - if ( shortName ) - switch (day) - { - case 1: - return locale()->translate("Ith"); - case 2: - return locale()->translate("Thl"); - case 3: - return locale()->translate("Arb"); - case 4: - return locale()->translate("Kha"); - case 5: - return locale()->translate("Jum"); - case 6: - return locale()->translate("Sab"); - case 7: - return locale()->translate("Ahd"); - } - else - switch ( day ) - { - case 1: - return locale()->translate("Yaum al-Ithnain"); - case 2: - return locale()->translate("Yau al-Thulatha"); - case 3: - return locale()->translate("Yaum al-Arbi'a"); - case 4: - return locale()->translate("Yaum al-Khamees"); - case 5: - return locale()->translate("Yaum al-Jumma"); - case 6: - return locale()->translate("Yaum al-Sabt"); - case 7: - return locale()->translate("Yaum al-Ahad"); - } - - return TQString::null; -} - -TQString KCalendarSystemHijri::weekDayName(const TQDate& date, - bool shortName) const -{ - return weekDayName(dayOfWeek(date), shortName); -} - -int KCalendarSystemHijri::dayOfWeek(const TQDate& date) const -{ - return date.dayOfWeek(); // same as gregorian -} - -int KCalendarSystemHijri::dayOfYear(const TQDate & date) const -{ - TQDate first; - setYMD(first, year(date), 1, 1); - - return first.daysTo(date) + 1; - - return 100; -} - -int KCalendarSystemHijri::daysInMonth(const TQDate& date) const -{ - int y, m; - gregorianToHijri(date, &y, &m, 0); - - return lastDayOfIslamicMonth(m, y); -} - -// Min valid year that may be converted to QDate -int KCalendarSystemHijri::minValidYear() const -{ - TQDate date(1753, 1, 1); - - return year(date); -} - -// Max valid year that may be converted to QDate -int KCalendarSystemHijri::maxValidYear() const -{ - TQDate date(8000, 1, 1); - - return year(date); -} - -int KCalendarSystemHijri::daysInYear(const TQDate & date) const -{ - TQDate first, last; - setYMD(first, year(date), 1, 1); - setYMD(last, year(date) + 1, 1, 1); - - return first.daysTo(last); -} - -int KCalendarSystemHijri::weekDayOfPray() const -{ - return 5; // friday -} - -TQDate KCalendarSystemHijri::addDays( const TQDate & date, int ndays ) const -{ - return TQT_TQDATE_OBJECT(date.addDays( ndays )); -} - -TQDate KCalendarSystemHijri::addMonths( const TQDate & date, int nmonths ) const -{ - TQDate result = date; - int m = month(date); - int y = year(date); - - if ( nmonths < 0 ) - { - m += 12; - y -= 1; - } - - --m; // this only works if we start counting at zero - m += nmonths; - y += m / 12; - m %= 12; - ++m; - - setYMD( result, y, m, day(date) ); - - return result; -} - -TQDate KCalendarSystemHijri::addYears( const TQDate & date, int nyears ) const -{ - TQDate result = date; - int y = year(date) + nyears; - - setYMD( result, y, month(date), day(date) ); - - return result; -} - -TQString KCalendarSystemHijri::calendarName() const -{ - return TQString::tqfromLatin1("hijri"); -} - -bool KCalendarSystemHijri::isLunar() const -{ - return true; -} - -bool KCalendarSystemHijri::isLunisolar() const -{ - return false; -} - -bool KCalendarSystemHijri::isSolar() const -{ - return false; -} diff --git a/kdecore/kcalendarsystemhijri.h b/kdecore/kcalendarsystemhijri.h deleted file mode 100644 index 214b7a50a..000000000 --- a/kdecore/kcalendarsystemhijri.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> - Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org> - - 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 KCALENDARSYSTEMHIJRI_H -#define KCALENDARSYSTEMHIJRI_H - -#include <tqdatetime.h> -#include <tqstring.h> - -#include "kcalendarsystem.h" - -class KCalendarSystemHijriPrivate; - -/** - * @internal - * This is the Hijri calendar implementation. - * - * The Hijri calendar is the traditional Islamic calendar used in the Midle - * East. - * - * @see KLocale,KCalendarSystem,KCalendarSystemFactory - * - * @author Carlos Moro <cfmoro@correo.uniovi.es> - * @since 3.2 - */ -class KDECORE_EXPORT KCalendarSystemHijri : public KCalendarSystem -{ -public: - /** Constructor. Just like KCalendarSystem::KCalendarSystem(). */ - KCalendarSystemHijri(const KLocale * locale = 0); - virtual ~KCalendarSystemHijri(); - - virtual int year (const TQDate & date) const; - virtual int month (const TQDate & date) const; - virtual int day (const TQDate & date) const; - virtual int dayOfWeek (const TQDate & date) const; - virtual int dayOfYear (const TQDate & date) const; - - virtual bool setYMD(TQDate & date, int y, int m, int d) const; - - virtual TQDate addYears(const TQDate & date, int nyears) const; - virtual TQDate addMonths(const TQDate & date, int nmonths) const; - virtual TQDate addDays(const TQDate & date, int ndays) const; - - virtual int monthsInYear (const TQDate & date) const; - virtual int daysInYear (const TQDate & date) const; - virtual int daysInMonth (const TQDate & date) const; - virtual int weeksInYear(int year) const; - virtual int weekNumber(const TQDate& date, int * yearNum = 0) const; - - virtual TQString monthName (int month, int year, bool shortName = false) const; - virtual TQString monthName (const TQDate & date, bool shortName = false ) const; - virtual TQString monthNamePossessive(int month, int year, bool shortName = false) const; - virtual TQString monthNamePossessive(const TQDate & date, bool shortName = false ) const; - virtual TQString weekDayName (int weekDay, bool shortName = false) const; - virtual TQString weekDayName (const TQDate & date, bool shortName = false) const; - - virtual int minValidYear () const; - virtual int maxValidYear () const; - virtual int weekDayOfPray () const; - - virtual TQString calendarName() const; - - virtual bool isLunar() const; - virtual bool isLunisolar() const; - virtual bool isSolar() const; - - private: - /** - * Gets the number of days in a month for a given date - * - * @param month month number - * @param year given rear - * @return number of days in month - */ - int hndays(int month, int year) const; - - KCalendarSystemHijriPrivate * d; -}; - -#endif diff --git a/kdecore/kcalendarsystemjalali.cpp b/kdecore/kcalendarsystemjalali.cpp deleted file mode 100644 index 6197ca75f..000000000 --- a/kdecore/kcalendarsystemjalali.cpp +++ /dev/null @@ -1,560 +0,0 @@ -/* - Copyright (C) 2002-2003 Arash Bijanzadeh and FarsiKDE Project <www.farsikde.org> - Contact: Arash Bijanzadeh <a.bijanzadeh@linuxiran.org> - - This program is part of FarsiKDE - - FarsiKDE 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. - - FarsiKDE 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 <tqdatetime.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <math.h> - -#include <kglobal.h> -#include <klocale.h> -#include <kdebug.h> -#include <stdio.h> - -#include "kcalendarsystemjalali.h" - -static const int gMonthDay[2][13]={ - {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, -}; - -static const int jMonthDay[2][13] = { - {0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29}, - {0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30}, -}; - -typedef struct { - int day; - int mon; - int year; - } SDATE; -// converting funcs from - -static int Ceil(float number) -{ - int ret; - if(number>0) - number += 0.5; - ret =(int) number; - return ret; -} - -static long jalali_jdn(int year, int month, int day) -{ - const long PERSIAN_EPOCH = 1948321; /* The JDN of 1 Farvardin 1*/ - int epbase; - long epyear; - long mdays; - long jdn; - epbase = year - 474; - epyear = 474 + (epbase % 2820); - if (month <= 7) - mdays = (month - 1) * 31; - else - mdays = (month - 1) * 30 + 6; - jdn = day + mdays ; - jdn += (((epyear * 682) - 110) / 2816) ; - jdn += (epyear - 1) * 365; - jdn += (epbase / 2820) * 1029983 ; - jdn += (PERSIAN_EPOCH - 1); - return jdn; -} - - -static SDATE jdn_jalali(long jdn) -{ - static SDATE ret; - int day, month, year; - int iYear, iMonth, iDay; - int depoch; - int cycle; - int cyear; - int ycycle; - int aux1, aux2; - int yday; - day = 1; - month = 1; - year = 475; - depoch = jdn - jalali_jdn(year,month, day); - cycle = (int) (depoch / 1029983); - cyear = depoch % 1029983; - if( cyear == 1029982) - ycycle = 2820; - else{ - aux1 = cyear / 366; - aux2 = cyear % 366; - ycycle = (((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1; - } - iYear = ycycle + (2820 * cycle) + 474; - if (iYear <= 0) - iYear = iYear - 1; - year = iYear; - yday = (jdn - jalali_jdn(year, month, day)) + 1; - if(yday <= 186 ) - iMonth = Ceil((yday-1) / 31); - else - iMonth = Ceil((yday - 7) / 30); - iMonth++; - month = iMonth; - iDay = (jdn - jalali_jdn(year, month, day)) + 1; - ret.day = iDay; - ret.mon = iMonth; - ret.year = iYear; - return ret; -} - - - -static long civil_jdn(int year, int month, int day) -{ - long jdn = ((1461 * (year + 4800 + ((month - 14) / 12))) / 4) - + ((367 * (month - 2 - 12 * (((month - 14) / 12)))) / 12) - - ((3 * (((year + 4900 + ((month - 14) / 12)) / 100))) / 4) - + day - 32075; - return jdn; -} - -static SDATE jdn_civil(long jdn) -{ - long l, n, i, j; - static SDATE ret; - int iday, imonth, iyear; - l = jdn + 68569; - n = ((4 * l) / 146097); - l = l - ((146097 * n + 3) / 4); - i = ((4000 * (l + 1)) / 1461001); - l = l - ((1461 * i) / 4) + 31; - j = ((80 * l) / 2447); - iday = l - ((2447 * j) / 80); - l = (j / 11); - imonth = j + 2 - 12 * l; - iyear = 100 * (n - 49) + i + l; - ret.day = iday; - ret.mon = imonth; - ret.year = iyear; - return (ret); -} - -static SDATE *jalaliToGregorian(int y,int m,int d) -{ -static SDATE sd; -long jday = jalali_jdn(y,m,d); -sd= jdn_civil(jday); -return (&sd); -} -static SDATE *gregorianToJalali(int y,int m, int d) -{ - static SDATE sd; - long jdn = civil_jdn(y,m,d);//TQDate::gregorianToJulian(y, m, d); - sd = jdn_jalali(jdn); - return(&sd); -} -static void gregorianToJalali(const TQDate & date, int * pYear, int * pMonth, - int * pDay) -{ - SDATE *sd; - sd = gregorianToJalali(date.year(), date.month(), date.day()); - if (pYear) - *pYear = sd->year; - if (pMonth) - *pMonth = sd->mon; - if (pDay) - *pDay = sd->day; - -} - -// End of converting functions - -static int isJalaliLeap(int year) -{ - int tmp; - tmp = year % 33; - if (tmp == 1 || tmp == 5||tmp==9||tmp==13||tmp==17||tmp==22||tmp==26||tmp==30) - return 1; -else - return 0; -} -static int hndays(int m,int y) -{ - return jMonthDay[isJalaliLeap(y)][m]; -} - - -KCalendarSystemJalali::KCalendarSystemJalali(const KLocale * locale) - : KCalendarSystem(locale) -{ -} - -KCalendarSystemJalali::~KCalendarSystemJalali() -{ -} - -int KCalendarSystemJalali::year(const TQDate& date) const - -{ - kdDebug(5400) << "Jalali year..." << endl; -int y; - gregorianToJalali(date, &y, 0, 0); - return y; -} - -int KCalendarSystemJalali::month (const TQDate& date) const - -{ - kdDebug(5400) << "Jalali month..." << endl; -int m; - gregorianToJalali(date, 0 , &m, 0); - return m; -} - -int KCalendarSystemJalali::day(const TQDate& date) const - -{ - kdDebug(5400) << "Jalali day..." << endl; -int d; - gregorianToJalali(date, 0, 0, &d); - return d; -} - -int KCalendarSystemJalali::dayOfWeek(const TQDate& date) const -{ -//same same I think?! - return date.dayOfWeek(); - -} - -//NOT TESTED YET -int KCalendarSystemJalali::dayOfYear(const TQDate & date) const -{ - TQDate first; - setYMD(first, year(date), 1, 1); - - return first.daysTo(date) + 1; -} - -//MAY BE BUGGY -bool KCalendarSystemJalali::setYMD(TQDate & date, int y, int m, int d) const -{ - // range checks - if ( y < minValidYear() || y > maxValidYear() ) - return false; - - if ( m < 1 || m > 12 ) - return false; - - if ( d < 1 || d > hndays(m, y) ) - return false; - - SDATE *gd =jalaliToGregorian( y, m, d); - - return date.setYMD(gd->year, gd->mon, gd->day); -} - -TQDate KCalendarSystemJalali::addYears( const TQDate & date, int nyears ) const -{ - TQDate result = date; - int y = year(date) + nyears; - setYMD( result, y, month(date), day(date) ); - - return result; -} - -TQDate KCalendarSystemJalali::addMonths( const TQDate & date, int nmonths ) const -{ - TQDate result = date; - int m = month(date); - int y = year(date); - - if ( nmonths < 0 ) - { - m += 12; - y -= 1; - } - - --m; // this only works if we start counting at zero - m += nmonths; - y += m / 12; - m %= 12; - ++m; - - setYMD( result, y, m, day(date) ); - - return result; -} - -TQDate KCalendarSystemJalali::addDays( const TQDate & date, int ndays ) const -{ - return TQT_TQDATE_OBJECT(date.addDays( ndays )); -} - -int KCalendarSystemJalali::monthsInYear( const TQDate & date ) const -{ - Q_UNUSED( date ) - - return 12; -} - -int KCalendarSystemJalali::daysInYear(const TQDate & date) const -{ -Q_UNUSED(date); -int result; -//SDATE *sd = gregorianToJalali(year(date),month(date),day(date)); -//if (isJalaliLeap(sd->year)) - result=366; -//else -// result=365; -return result; -} - -int KCalendarSystemJalali::daysInMonth(const TQDate & date) const -{ -SDATE *sd = gregorianToJalali(date.year(),date.month(),date.day()); -return hndays(sd->mon,sd->year); -} - -int KCalendarSystemJalali::weeksInYear(int year) const - -{ - Q_UNUSED(year); -// couldn't understand it! -return 52; -} - -int KCalendarSystemJalali::weekNumber(const TQDate& date, int * yearNum) const -{ - TQDate firstDayWeek1, lastDayOfYear; - int y = year(date); - int week; - int weekDay1, dayOfWeek1InYear; - - // let's guess 1st day of 1st week - setYMD(firstDayWeek1, y, 1, 1); - weekDay1 = dayOfWeek(firstDayWeek1); - - // iso 8601: week 1 is the first containing thursday and week starts on - // monday - if (weekDay1 > 4 /*Thursday*/) - firstDayWeek1 = addDays(firstDayWeek1 , 7 - weekDay1 + 1); // next monday - - dayOfWeek1InYear = dayOfYear(firstDayWeek1); - - if ( dayOfYear(date) < dayOfWeek1InYear ) // our date in prev year's week - { - if ( yearNum ) - *yearNum = y - 1; - return weeksInYear(y - 1); - } - // let' check if its last week belongs to next year - setYMD(lastDayOfYear, y, 12, hndays(12, y)); - if ( (dayOfYear(date) >= daysInYear(date) - dayOfWeek(lastDayOfYear) + 1) - // our date is in last week - && dayOfWeek(lastDayOfYear) < 4) // 1st week in next year has thursday - { - if ( yearNum ) - *yearNum = y + 1; - week = 1; - } - else - week = firstDayWeek1.daysTo(date) / 7 + 1; - - return week; -} - -TQString KCalendarSystemJalali::monthName(int month, int year, bool shortName) - const -{ - Q_UNUSED(year); - - if (shortName) - switch ( month ) - { - case 1: - return locale()->translate("Far"); - case 2: - return locale()->translate("Ord"); - case 3: - return locale()->translate("Kho"); - case 4: - return locale()->translate("Tir"); - case 5: - return locale()->translate("Mor"); - case 6: - return locale()->translate("Sha"); - case 7: - return locale()->translate("Meh"); - case 8: - return locale()->translate("Aba"); - case 9: - return locale()->translate("Aza"); - case 10: - return locale()->translate("Dei"); - case 11: - return locale()->translate("Bah"); - case 12: - return locale()->translate("Esf"); - } - else - switch ( month ) - { - case 1: - return locale()->translate("Farvardin"); - case 2: - return locale()->translate("Ordibehesht"); - case 3: - return locale()->translate("Khordad"); - case 4: - return locale()->translate("Tir"); - case 5: - return locale()->translate("Mordad"); - case 6: - return locale()->translate("Shahrivar"); - case 7: - return locale()->translate("Mehr"); - case 8: - return locale()->translate("Aban"); - case 9: - return locale()->translate("Azar"); - case 10: - return locale()->translate("Dei"); - case 11: - return locale()->translate("Bahman"); - case 12: - return locale()->translate("Esfand"); - } - - return TQString::null; -} - -TQString KCalendarSystemJalali::monthName(const TQDate& date, bool shortName) - const -{ - int mon; - gregorianToJalali(date,0,&mon,0); - //SDATE *sd = gregorianToJalali(date.year(),date.month(),date.day()); - return (monthName(mon, 0, shortName)); -} - -TQString KCalendarSystemJalali::monthNamePossessive(const TQDate& date, - bool shortName ) const -{ - return monthName(date,shortName); -} - -TQString KCalendarSystemJalali::monthNamePossessive(int month, int year, - bool shortName ) const -{ - return monthName(month,year,shortName); -} - - -TQString KCalendarSystemJalali::weekDayName(int day, bool shortName) const -{ - if ( shortName ) - switch (day) - { - case 1: - return locale()->translate("2sh"); - case 2: - return locale()->translate("3sh"); - case 3: - return locale()->translate("4sh"); - case 4: - return locale()->translate("5sh"); - case 5: - return locale()->translate("Jom"); - case 6: - return locale()->translate("shn"); - case 7: - return locale()->translate("1sh"); - } - else - switch ( day ) - { - case 1: - return locale()->translate("Do shanbe"); - case 2: - return locale()->translate("Se shanbe"); - case 3: - return locale()->translate("Chahar shanbe"); - case 4: - return locale()->translate("Panj shanbe"); - case 5: - return locale()->translate("Jumee"); - case 6: - return locale()->translate("Shanbe"); - case 7: - return locale()->translate("Yek-shanbe"); - } - - return TQString::null; -} - -TQString KCalendarSystemJalali::weekDayName(const TQDate &date,bool shortName) - const -{ - return weekDayName(dayOfWeek(date), shortName); -} - -// Min valid year that may be converted to QDate -int KCalendarSystemJalali::minValidYear() const -{ - TQDate date(1753, 1, 1); - - return year(date); -} - -// Max valid year that may be converted to QDate -int KCalendarSystemJalali::maxValidYear() const -{ -/* - TQDate date(8000, 1, 1); - - SDATE *sd = toJalali(date); - - return sd->year; - */ - return 10000; -} -int KCalendarSystemJalali::weekDayOfPray() const -{ - return 5; // friday -} -TQString KCalendarSystemJalali::calendarName() const -{ - return TQString::tqfromLatin1("jalali"); -} - -bool KCalendarSystemJalali::isLunar() const -{ - return false; -} - -bool KCalendarSystemJalali::isLunisolar() const -{ - return false; -} - -bool KCalendarSystemJalali::isSolar() const -{ - return true; -} diff --git a/kdecore/kcalendarsystemjalali.h b/kdecore/kcalendarsystemjalali.h deleted file mode 100644 index e7ec99fe3..000000000 --- a/kdecore/kcalendarsystemjalali.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef KCALENDARSYSTEMJALALI_H -#define KCALENDARSYSTEMJALALI_H - - -/* - Copyright (C) 2002-2003 Arash Bijanzadeh and FarsiKDE Project <www.farsikde.org> - Contact: Arash Bijanzadeh <a.bijanzadeh@linuxiran.org> - - This program is part of FarsiKDE - - FarsiKDE 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. - - FarsiKDE 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 <tqdatetime.h> -#include <tqstring.h> - -#include "kcalendarsystem.h" - -class KCalendarSystemJalaliPrivate; -/** - Jalali calendar type implementation -*/ -class KDECORE_EXPORT KCalendarSystemJalali : public KCalendarSystem -{ -public: - /** Constructor. Just like KCalendarSystem::KCalendarSystem(). */ - KCalendarSystemJalali(const KLocale * locale = 0); - virtual ~KCalendarSystemJalali(); - - - - virtual int year (const TQDate & date) const; - virtual int month (const TQDate & date) const; - virtual int day (const TQDate & date) const; - virtual int dayOfWeek (const TQDate & date) const; - virtual int dayOfYear (const TQDate & date) const; - - virtual bool setYMD(TQDate & date, int y, int m, int d) const; - - virtual TQDate addYears(const TQDate & date, int nyears) const; - virtual TQDate addMonths(const TQDate & date, int nmonths) const; - virtual TQDate addDays(const TQDate & date, int ndays) const; - - virtual int monthsInYear (const TQDate & date) const; - - virtual int daysInYear (const TQDate & date) const; - virtual int daysInMonth (const TQDate & date) const; - virtual int weeksInYear(int year) const; - virtual int weekNumber(const TQDate& date, int * yearNum = 0) const; - - virtual TQString monthName (const TQDate & date, bool shortName = false ) const; - virtual TQString monthNamePossessive(const TQDate & date, bool shortName = false ) const; - virtual TQString weekDayName (int weekDay, bool shortName = false) const; - virtual TQString weekDayName (const TQDate & date, bool shortName = false) const; - virtual TQString monthNamePossessive(int month, int year, bool shortName = false) const; - virtual TQString monthName(int month, int year, bool shortName = false) const; - - virtual int minValidYear () const; - virtual int maxValidYear () const; - virtual int weekDayOfPray () const; - - virtual TQString calendarName() const; - - virtual bool isLunar() const; - virtual bool isLunisolar() const; - virtual bool isSolar() const; - -}; - -#endif diff --git a/kdecore/kcatalogue.cpp b/kdecore/kcatalogue.cpp deleted file mode 100644 index 764cd4618..000000000 --- a/kdecore/kcatalogue.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2001 Hans Petter Bieker <bieker@kde.org> - - 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. -*/ - -#include <config.h> - -#include <tqfile.h> - -#include <kdebug.h> - -#include "kcatalogue.h" -#include "kstandarddirs.h" - -char *k_nl_find_msg(struct kde_loaded_l10nfile *domain_file, - const char *msgid); -void k_nl_unload_domain (struct loaded_domain *domain); - -#ifndef KDE_USE_FINAL // with --enable-final, we're getting this from libintl.cpp -struct kde_loaded_l10nfile -{ - const char *filename; - int decided; - - const void *data; - - kde_loaded_l10nfile() : filename(0), decided(0), data(0) {} -}; -#endif - -class KCataloguePrivate -{ -public: - TQString name; - TQString language; - int pluralType; - - kde_loaded_l10nfile domain; -}; - -KCatalogue::KCatalogue(const TQString & name, const TQString & language ) - : d( new KCataloguePrivate ) -{ - d->name = name; - d->language = language; - // at the moment we do not know more. To find out the plural type we first have to look into - // kdelibs.mo for the language. And for this we already need a catalog object. So this data - // has to be set after we have the first catalog objects. - d->pluralType = -1; - - TQString path = TQString::tqfromLatin1("%1/LC_MESSAGES/%2.mo") - .arg( d->language ) - .arg( d->name ); - - TQString fileName = locate( "locale", path ); - if (fileName.isEmpty()) - fileName = locate( "locale-bundle", path ); - - setFileName( fileName ); - -} - -KCatalogue::KCatalogue(const KCatalogue & rhs) - : d( new KCataloguePrivate ) -{ - *this = rhs; -} - -KCatalogue & KCatalogue::operator=(const KCatalogue & rhs) -{ - d->name = rhs.d->name; - d->language = rhs.d->language; - d->pluralType = rhs.d->pluralType; - setFileName( rhs.fileName() ); - - return *this; -} - -KCatalogue::~KCatalogue() -{ - doUnload(); - - delete d; -} - -TQString KCatalogue::name() const -{ - return d->name; -} - -TQString KCatalogue::language() const -{ - return d->language; -} - -void KCatalogue::setPluralType( int pluralType) -{ - d->pluralType = pluralType; -} - -int KCatalogue::pluralType() const -{ - return d->pluralType; -} - - -void KCatalogue::setFileName( const TQString & fileName ) -{ - // nothing to do if the file name is already the same - if ( this->fileName() == fileName ) return; - - doUnload(); - - TQCString newFileName = TQFile::encodeName( fileName ); - - if ( !fileName.isEmpty() ) - { - // set file name - char *filename = new char[ newFileName.length() + 1 ]; - ::qstrcpy( filename, newFileName ); - d->domain.filename = filename; - } -} - -TQString KCatalogue::fileName() const -{ - return TQFile::decodeName( d->domain.filename ); -} - -const char * KCatalogue::translate(const char * msgid) const -{ - return ::k_nl_find_msg( &d->domain, msgid ); -} - -void KCatalogue::doUnload() -{ - // use gettext's unloader - if ( d->domain.data ) - ::k_nl_unload_domain( (struct loaded_domain *)d->domain.data ); - d->domain.data = 0; - - // free name - delete [] const_cast<char *>(d->domain.filename); - d->domain.filename = 0; - - d->domain.decided = 0; -} diff --git a/kdecore/kcatalogue.h b/kdecore/kcatalogue.h deleted file mode 100644 index 0658b9000..000000000 --- a/kdecore/kcatalogue.h +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2001 Hans Petter Bieker <bieker@kde.org> - - 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 KCATALOGUE_H -#define KCATALOGUE_H - -#include <tqstring.h> -#include "kdelibs_export.h" - -struct kde_loaded_l10nfile; - -class KCataloguePrivate; - -/** - * This class abstracts a gettext message catalog. It will take care of - * opening the file and reading the catalog. - * - * @see KLocale - */ -//REVISED: hausmann -class KDECORE_EXPORT KCatalogue -{ -public: - /** - * Constructor. - * - * @param name The name of the catalog - * @param language The language of this catalog - */ - explicit KCatalogue(const TQString & name = TQString::null, const TQString & language = TQString::null); - - /** - * Copy constructor. - */ - KCatalogue(const KCatalogue & rhs); - - /** - * Assignment operator. - */ - KCatalogue & operator = ( const KCatalogue & rhs); - - /** - * Destructor. - */ - virtual ~KCatalogue(); - - /** - * Returns the name of the catalog. - * - * @return The name of the catalog - */ - TQString name() const; - - /** - * Returns the language of the catalog. - * - * @return The language of the catalog - */ - TQString language() const; - - /** - * Returns the plural type for the catalog. This type is based on the language of the catalog - and is cached for performance. - * - * @return The plural type for the catalog - */ - int pluralType() const; - - /** - * Sets the plural type for the catalog. The caller has probably looked it up in a kdelibs.mo-catalog - * for the appropriate language - * - * @return The plural type for the catalog - */ - void setPluralType( int pluralType ); - - - /** - * Retrieves a translation of the specified message id. - * - * Do not pass 0 or "" strings as message ids. - * - * @param msgid The message id - * - * @return The translated message, in utf8 encoding, or 0 if not found - */ - const char * translate( const char * msgid ) const; - -private: - /** - * @internal Changes the current file name. - * - * @param fileName The new file name - */ - - void setFileName( const TQString & fileName ); - /** - * @internal Retrieves the current file name. - * - * @return The current file name, if any. - */ - TQString fileName() const; - - /** - * @internal Unloads the current file. - */ - void doUnload(); - -private: - KCataloguePrivate * d; -}; - -#endif diff --git a/kdecore/kcharsets.cpp b/kdecore/kcharsets.cpp deleted file mode 100644 index b78345276..000000000 --- a/kdecore/kcharsets.cpp +++ /dev/null @@ -1,664 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Lars Knoll (knoll@kde.org) - - 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. -*/ -#include "kcharsets.h" - -#include "kqiodevicegzip_p.h" -#include "kentities.c" - -#include <kapplication.h> -#include <kglobal.h> -#include <klocale.h> -#include <kconfig.h> - -#include <tqfontinfo.h> -#include <tqstrlist.h> -#include <tqfontdatabase.h> -#include <kdebug.h> - -#include <tqtextcodec.h> -#include <tqmap.h> -#include <tqcstring.h> -#include <tqdir.h> -#include <tqregexp.h> - -#include <assert.h> - -static const char * const language_names[] = { - I18N_NOOP( "Other" ), - I18N_NOOP( "Arabic" ), - I18N_NOOP( "Baltic" ), - I18N_NOOP( "Central European" ), - I18N_NOOP( "Chinese Simplified" ), - I18N_NOOP( "Chinese Traditional" ), - I18N_NOOP( "Cyrillic" ), - I18N_NOOP( "Greek" ), - I18N_NOOP( "Hebrew" ), - I18N_NOOP( "Japanese" ), - I18N_NOOP( "Korean" ), - I18N_NOOP( "Thai" ), - I18N_NOOP( "Turkish" ), - I18N_NOOP( "Western European" ), - I18N_NOOP( "Tamil" ), - I18N_NOOP( "Unicode" ), - I18N_NOOP( "Northern Saami" ), - I18N_NOOP( "Vietnamese" ), - I18N_NOOP( "South-Eastern Europe" ) -}; - -// This list gives the charsets that can be used to display a file given in a certain encoding. -// The list should be in order of preference -static const char* const charsets_for_encoding[] = { - "koi8-r", - "koi8-u", - "iso 8859-1", - "iso 8859-2", - "iso 8859-3", - "iso 8859-4", - "iso 8859-5", - "iso 8859-6", - "iso 8859-7", - "iso 8859-8", - "iso 8859-8-i", - "iso 8859-9", - "iso 8859-11", - "iso 8859-13", - "iso 8859-14", - "iso 8859-15", - "iso 8859-16", - "utf8", - "utf16", - "iso-10646-ucs-2", - "cp 1250", - "cp 1251", - "cp 1252", - "cp 1253", - "cp 1254", - "cp 1255", - "cp 1256", - "cp 1257", - "cp 1258", - "ibm850", - "ibm852", - "ibm866", - "tis620", - "eucjp", - "sjis", - "jis7", - "big5", - "big5-hkscs", - "gbk", - "gb18030", - "gb2312", - "euckr", - "tscii", -// "pt 154", - "winsami2", - "cp 874", - 0 }; // extra 0 for end - -// 0 other -// 1 Arabic -// 2 Baltic -// 3 Central European -// 4 Chinese Simplified -// 5 Chinese Traditional -// 6 Cyrillic -// 7 Greek -// 8 Hebrew -// 9 Japanese -// 10 Korean -// 11 Thai -// 12 Turkish -// 13 Western European -// 14 Tamil -// 15 Unicode -// 16 Northern Sami -// 17 Vietnamese -// 18 South-Eastern Europe -// ### FIXME KDE4: the name of the encodings should mostly be uppercase -static struct LanguageForEncoding - { - const char* index; - int data; - } const language_for_encoding[] = { - { "iso 8859-1", 13 }, - { "iso 8859-15", 13 }, - { "iso 8859-14", 13 }, - { "cp 1252", 13 }, - { "ibm850", 13 }, - { "iso 8859-2", 3 }, - { "iso 8859-3", 3 }, - { "iso 8859-4", 2 }, - { "iso 8859-13", 2 }, - { "iso 8859-16", 18 }, - { "cp 1250", 3 }, - { "cp 1254", 12 }, - { "cp 1257", 2 }, - { "ibm852", 3 }, - { "koi8-r", 6 }, - { "iso 8859-5", 6 }, - { "cp 1251", 6 }, - { "koi8-u", 6 }, -// { "pt 154", 6 }, - { "ibm866", 6 }, - { "big5", 5 }, - { "big5-hkscs", 5 }, - { "gb18030", 4 }, - { "gbk", 4 }, - { "gb2312", 4 }, - { "euckr", 10 }, - { "sjis", 9 }, - { "jis7", 9 }, - { "eucjp", 9 }, - { "iso 8859-7", 7 }, - { "cp 1253", 7 }, - { "iso 8859-6", 1 }, - { "cp 1256", 1 }, - { "iso 8859-8", 8 }, - { "iso 8859-8-i", 8 }, - { "cp 1255", 8 }, - { "iso 8859-9", 12 }, - { "tis620", 11 }, - { "iso 8859-11", 11 }, - { "cp 874", 11 }, - { "cp 1258", 17 }, - { "tscii", 14 }, - { "utf8", 15 }, - { "utf16", 15 }, - { "utf7", 15 }, // ### FIXME: UTF-7 is not in Qt - { "ucs2", 15 }, - { "iso-10646-ucs-2", 15 }, - { "winsami2", 16}, - { 0, 0 } }; - -// defines some different names for codecs that are built into Qt. -static struct Builtin - { - const char* index; - const char* data; - } const builtin[] = { - { "iso-ir-111", "koi8-r" }, - { "koi8-ru", "koi8-u" }, // ### Qt 3.3 maps it to koi8-r - { "koi unified", "koi8-r" }, // ### FIXME: Qt 3.3 seems to map this to EUC-KR, so this mapping is too late :-( - // Using ISO-8859-1 for ASCII is an approximation at write - { "us-ascii", "iso 8859-1" }, - { "usascii", "iso 8859-1" }, - { "ascii", "iso 8859-1" }, - { "x-utf-8", "utf-8" }, - { "x-utf-7", "utf-7" }, // ### FIXME: UTF-7 is not in Qt - { "tqunicode-1-1-utf-7", "utf-7" }, // ### FIXME: UTF-7 is not in Qt - { "utf-16", "iso-10646-ucs-2" }, - { "utf16", "iso-10646-ucs-2" }, - { "ucs2", "iso-10646-ucs-2" }, - { "iso10646-1", "iso-10646-ucs-2" }, - { "gb18030.2000-1", "gb18030" }, - { "gb18030.2000-0", "gb18030" }, - { "gbk-0", "gbk" }, - { "gb2312.1980-0", "gbk" }, - { "gb_2312-80", "gbk" },/* this one is not official, but MS is using it :/ */ - { "x-euc-kr", "euckr" }, - { "jisx0201.1976-0", "eucjp" }, - { "jisx0208.1983-0", "eucjp" }, - { "jisx0208.1990-0", "eucjp" }, - { "jisx0208.1997-0", "eucjp" }, - { "jisx0212.1990-0", "eucjp" }, - { "jisx0213.2000-1", "eucjp" }, - { "jisx0213.2000-2", "eucjp" }, - { "windows850", "ibm850" }, - { "windows866", "ibm866" }, - { "windows1251", "cp 1251" }, - { "windows1252", "cp 1252" }, - { "windows1253", "cp 1253" }, - { "windows1254", "cp 1254" }, - { "windows1255", "cp 1255" }, - { "windows1256", "cp 1256" }, - { "windows1257", "cp 1257" }, - { "windows1258", "cp 1258" }, - { "windows-850", "ibm850" }, - { "windows-866", "ibm866" }, - { "x-windows-850", "ibm850" }, - { "x-windows-866", "ibm866" }, - { "x-windows-1250", "cp 1250" }, - { "x-windows-1251", "cp 1251" }, - { "x-windows-1252", "cp 1252" }, - { "x-windows-1253", "cp 1253" }, - { "x-windows-1254", "cp 1254" }, - { "x-windows-1255", "cp 1255" }, - { "x-windows-1256", "cp 1256" }, - { "x-windows-1257", "cp 1257" }, - { "x-windows-1258", "cp 1258" }, - { "cp819", "iso 8859-1" }, - { "cp850", "ibm850" }, - { "cp866", "ibm866" }, - { "cp-819", "iso 8859-1" }, - { "cp-850", "ibm850" }, - { "cp-866", "ibm866" }, - { "cp-1250", "cp 1250" }, - { "cp-1251", "cp 1251" }, - { "cp-1252", "cp 1252" }, - { "cp-1253", "cp 1253" }, - { "cp-1254", "cp 1254" }, - { "cp-1255", "cp 1255" }, - { "cp-1256", "cp 1256" }, - { "cp-1257", "cp 1257" }, - { "cp-1258", "cp 1258" }, - { "cp-10000", "apple roman" }, - { "x-cp-850", "ibm850" }, - { "x-cp-866", "ibm866" }, - { "x-cp-1250", "cp 1250" }, - { "x-cp-1251", "cp 1251" }, - { "x-cp-1252", "cp 1252" }, - { "x-cp-1253", "cp 1253" }, - { "x-cp-1254", "cp 1254" }, - { "x-cp-1255", "cp 1255" }, - { "x-cp-1256", "cp 1256" }, - { "x-cp-1257", "cp 1257" }, - { "x-cp-1258", "cp 1258" }, - { "x-cp-10000", "apple roman" }, - { "ibm819", "iso 8859-1" }, - { "thai-tis620", "iso 8859-11" }, - { "windows-874", "cp 874" }, - { "windows874", "cp 874" }, - { "x-windows-874", "cp 874" }, - { "x-cp-874", "cp 874" }, - { "ibm 874", "cp 874" }, - { "ibm874", "cp 874" }, // Qt4 name - { "x-ibm874", "cp 874" }, - { "ksc5601.1987-0", "euckr" }, - { "x-winsami2", "winsami2" }, - { "x-mac-roman", "apple roman" }, - { "macintosh", "apple roman" }, - { "mac", "apple roman" }, - { "csiso2022jp", "jis7" }, // See bug #77243 - { "big5-eten", "big5-hkscs" }, - { "cp950", "big5-hkscs" }, - { 0, 0 }}; - -// some different names for the encodings defined in the charmaps files. -// even though the charmap file names are all uppercase, the names are all lowercase here. -static struct Aliases - { - const char* index; - const char* data; - } const aliases[] = { - { "cp852", "ibm852" }, - { "cp-852", "ibm852" }, - { "x-cp-852", "ibm852" }, - { "windows852", "ibm852" }, - { "windows-852", "ibm852" }, - { "x-windows-852", "ibm852" }, - { 0, 0 }}; - -// some last resort hints in case the charmap file couldn't be found. This gives at least a partial conversion -// and helps making things readable. -// the name used as input here is already converted to the more canonical name as defined in the aliases array. -static struct ConversionHints - { - const char* index; - const char* data; - } const conversion_hints[] = { - { "cp1250", "iso-8859-2" }, - { "koi8-r", "iso-8859-5" }, - { "koi8-u", "koi8-r" }, - // KDE had always "CP 1251" as best fallback to PT 154. Now that Qt does not offer this encoding anymore, it is our fallback. - { "pt 154", "cp 1251" }, - { "paratype-154", "cp 1251" }, - { "pt-154", "cp 1251" }, - { 0, 0 }}; - - -// search an array of items index/data, index is const char*, data is T, find first matching index -// and return data, or return 0 -template< typename T, typename Data > -static Data kcharsets_array_search( const T* start, const char* entry ) -{ - for( const T* pos = start; - pos->index != 0; - ++pos ) - if( qstrcmp( pos->index, entry ) == 0 ) - return pos->data; - return 0; -} - - -class KCharsetsPrivate -{ -public: - KCharsetsPrivate(KCharsets* _kc) - : codecForNameDict(43, false) // case insensitive - { - db = 0; - kc = _kc; - } - ~KCharsetsPrivate() - { - delete db; - } - TQFontDatabase *db; - TQAsciiDict<TQTextCodec> codecForNameDict; - KCharsets* kc; -}; - -// -------------------------------------------------------------------------- - -KCharsets::KCharsets() -{ - d = new KCharsetsPrivate(this); -} - -KCharsets::~KCharsets() -{ - delete d; -} - -TQChar KCharsets::fromEntity(const TQString &str) -{ - TQChar res = TQChar::null; - - int pos = 0; - if(str[pos] == (QChar)'&') pos++; - - // Check for '�' or '�' sequence - if (str[pos] == (QChar)'#' && str.length()-pos > 1) { - bool ok; - pos++; - if (str[pos] == (QChar)'x' || str[pos] == (QChar)'X') { - pos++; - // '�', hexadeciaml character reference - TQString tmp(str.tqunicode()+pos, str.length()-pos); - res = tmp.toInt(&ok, 16); - } else { - // '�', decimal character reference - TQString tmp(str.tqunicode()+pos, str.length()-pos); - res = tmp.toInt(&ok, 10); - } - return res; - } - - const entity *e = kde_findEntity(str.ascii(), str.length()); - - if(!e) - { - //kdDebug( 0 ) << "unknown entity " << str <<", len = " << str.length() << endl; - return TQChar::null; - } - //kdDebug() << "got entity " << str << " = " << e->code << endl; - - return TQChar(e->code); -} - -TQChar KCharsets::fromEntity(const TQString &str, int &len) -{ - // entities are never longer than 8 chars... we start from - // that length and work backwards... - len = 8; - while(len > 0) - { - TQString tmp = str.left(len); - TQChar res = fromEntity(tmp); - if( res != (QChar)TQChar::null ) return res; - len--; - } - return TQChar::null; -} - - -TQString KCharsets::toEntity(const TQChar &ch) -{ - TQString ent; - ent.sprintf("�x%x;", ch.tqunicode()); - return ent; -} - -TQString KCharsets::resolveEntities( const TQString &input ) -{ - TQString text = input; - const TQChar *p = text.tqunicode(); - const TQChar *end = p + text.length(); - const TQChar *ampersand = 0; - bool scanForSemicolon = false; - - for ( ; p < end; ++p ) { - const TQChar ch = *p; - - if ( ch == (QChar)'&' ) { - ampersand = p; - scanForSemicolon = true; - continue; - } - - if ( ch != (QChar)';' || scanForSemicolon == false ) - continue; - - assert( ampersand ); - - scanForSemicolon = false; - - const TQChar *entityBegin = ampersand + 1; - - const uint entityLength = p - entityBegin; - if ( entityLength == 0 ) - continue; - - const TQChar entityValue = KCharsets::fromEntity( TQConstString( entityBegin, entityLength ).string() ); - if ( entityValue.isNull() ) - continue; - - const uint ampersandPos = ampersand - text.tqunicode(); - - text[ (int)ampersandPos ] = entityValue; - text.remove( ampersandPos + 1, entityLength + 1 ); - p = text.tqunicode() + ampersandPos; - end = text.tqunicode() + text.length(); - ampersand = 0; - } - - return text; -} - -TQStringList KCharsets::availableEncodingNames() -{ - TQStringList available; - for ( const char* const* pos = charsets_for_encoding; *pos; ++pos ) { - //kdDebug(0) << *charsets << " available" << endl; - available.append( TQString::tqfromLatin1( *pos )); - } - return available; -} - -TQString KCharsets::languageForEncoding( const TQString &encoding ) -{ - int lang = kcharsets_array_search< LanguageForEncoding, int > - ( language_for_encoding, encoding.latin1()); - return i18n( language_names[lang] ); -} - -TQString KCharsets::encodingForName( const TQString &descriptiveName ) -{ - const int left = descriptiveName.findRev( '(' ); - - if (left<0) // No parenthesis, so assume it is a normal encoding name - return descriptiveName.stripWhiteSpace(); - - TQString name(descriptiveName.mid(left+1)); - - const int right = name.findRev( ')' ); - - if (right<0) - return name; - - return name.left(right).stripWhiteSpace(); -} - -TQStringList KCharsets::descriptiveEncodingNames() -{ - // As we are sorting, we can directly read the array language_for_encoding - TQStringList encodings; - for ( const LanguageForEncoding* pos = language_for_encoding; pos->index; ++pos ) { - const TQString name = TQString::tqfromLatin1( pos->index ); - const TQString description = i18n( language_names[ pos->data ] ); - encodings.append( i18n("Descriptive Encoding Name", "%1 ( %2 )"). arg ( description ). arg( name ) ); - } - encodings.sort(); - return encodings; -} - -TQTextCodec *KCharsets::codecForName(const TQString &n) const -{ - bool b; - return codecForName( n, b ); -} - -TQTextCodec *KCharsets::codecForName(const TQString &n, bool &ok) const -{ - ok = true; - - TQTextCodec* codec = 0; - // dict lookup is case insensitive anyway - if((codec = d->codecForNameDict[n.isEmpty() ? "->locale<-" : n.latin1()])) - return codec; // cache hit, return - - if (n.isEmpty()) { - codec = KGlobal::locale()->codecForEncoding(); - d->codecForNameDict.replace("->locale<-", codec); - return codec; - } - - TQCString name = n.lower().latin1(); - TQCString key = name; - if (name.right(8) == "_charset") - name.truncate(name.length()-8); - - if (name.isEmpty()) { - ok = false; - return TQTextCodec::codecForName("iso8859-1"); - } - - codec = TQTextCodec::codecForName(name); - - if(codec) { - d->codecForNameDict.replace(key, codec); - return codec; - } - - // these codecs are built into Qt, but the name given for the codec is different, - // so TQTextCodec did not recognize it. - TQCString cname = kcharsets_array_search< Builtin, const char* >( builtin, name.data()); - - if(!cname.isEmpty()) - codec = TQTextCodec::codecForName(cname); - - if(codec) - { - d->codecForNameDict.replace(key, codec); - return codec; - } - - TQString dir; - { - KConfigGroupSaver cfgsav( KGlobal::config(), "i18n" ); - dir = KGlobal::config()->readPathEntry("i18ndir", TQString::tqfromLatin1("/usr/share/i18n/charmaps")); - } - - // these are codecs not included in Qt. They can be build up if the corresponding charmap - // is available in the charmap directory. - cname = kcharsets_array_search< Aliases, const char* >( aliases, name.data()); - - if(cname.isEmpty()) - cname = name; - cname = cname.upper(); - - const TQString basicName = TQString::tqfromLatin1(cname); - kdDebug() << k_funcinfo << endl << " Trying to find " << cname << " in " << dir << endl; - - TQString charMapFileName; - bool gzipped = false; - TQDir qdir(dir); - if (!qdir.exists()) { - // The directory for the charmaps does not even exist... (That is common!) - } - else if (qdir.exists(basicName, false)) { - charMapFileName = basicName; - } - else if (qdir.exists(basicName+".gz", false)) { - charMapFileName = basicName + ".gz"; - gzipped = true; - } - else { - // Check if we are asking a code page - // If yes, then check "CP99999" and "IBM99999" - // First we need to find the number of the codepage - TQRegExp regexp("^(X-)?(CP|IBM)(-| )?(0-9)+"); - if ( regexp.search(basicName) != -1) { - const TQString num = regexp.cap(4); - if (num.isEmpty()) { - // No number, not a code page (or something went wrong) - } - else if (qdir.exists("IBM"+num)) { - charMapFileName = "IBM"+num; - } - else if (qdir.exists("IBM"+num+".gz")) { - charMapFileName = "IBM"+num+".gz"; - gzipped = true; - } - else if (qdir.exists("CP"+num)) { - charMapFileName = "CP"+num; - } - else if (qdir.exists("CP"+num+".gz")) { - charMapFileName = "CP"+num+".gz"; - gzipped = true; - } - } - } - - if (gzipped && !charMapFileName.isEmpty()) { - KQIODeviceGZip gzip(dir + "/" + charMapFileName); - if (gzip.open(IO_ReadOnly)) { - kdDebug() << "Loading gzipped charset..." << endl; - codec = TQTextCodec::loadCharmap(&gzip); - gzip.close(); - } - else - kdWarning() << "Could not open gzipped charset!" << endl; - } - else if (!charMapFileName.isEmpty()) { - codec = TQTextCodec::loadCharmapFile(dir + "/" + charMapFileName); - } - - if(codec) { - d->codecForNameDict.replace(key, codec); - return codec; - } - - // this also failed, the last resort is now to take some compatibility charmap - - cname = kcharsets_array_search< ConversionHints, const char* >( conversion_hints, (const char*)name.data() ); - - if(!cname.isEmpty()) - codec = TQTextCodec::codecForName(cname); - - if(codec) { - d->codecForNameDict.replace(key, codec); - return codec; - } - - // could not assign a codec, let's return Latin1 - ok = false; - return TQTextCodec::codecForName("iso8859-1"); -} diff --git a/kdecore/kcharsets.h b/kdecore/kcharsets.h deleted file mode 100644 index 32c91148a..000000000 --- a/kdecore/kcharsets.h +++ /dev/null @@ -1,142 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Lars Knoll (knoll@kde.org) - - 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 KCHARSETS_H -#define KCHARSETS_H - -#include <tqstring.h> -#include <tqfont.h> -#include <tqstringlist.h> -#include <tqptrlist.h> -#include "kdelibs_export.h" - -class KGlobal; -class KCharsetsPrivate; - -class TQTextCodec; - -/** - * Charset font and encoder/decoder handling. - * - * This is needed, because Qt's font matching algorithm gives the font - * family a higher priority than the charset. For many applications - * this is not acceptable, since it can totally obscure the output, - * in languages which use non iso-8859-1 charsets. - * - * @author Lars Knoll <knoll@kde.org> - */ -class KDECORE_EXPORT KCharsets -{ - friend class KGlobal; - -protected: - /** Protected constructor. If you need the kcharsets object, use - KGlobal::charsets() instead. - */ - KCharsets(); - -public: - - /** - * Destructor. - */ - virtual ~KCharsets(); - - /** - * Provided for compatibility. - * @param name the name of the codec - * @return the TQTextCodec. If the desired codec could not be found, - * it returns a default (Latin-1) codec - */ - TQTextCodec *codecForName(const TQString &name) const; - - /** - * Tries to find a TQTextCodec to convert the given encoding from and to - * Unicode. If no codec could be found the latin1 codec will be returned an - * @p ok will be set to false. - * @return the TQTextCodec. If the desired codec could not be found, - * it returns a default (Latin-1) codec - */ - TQTextCodec *codecForName(const TQString &n, bool &ok) const; - - /** - * Converts an entity to a character. The string must contain only the - * entity without the trailing ';'. - * @param str the entity - * @return TQChar::null if the entity could not be decoded. - */ - static TQChar fromEntity(const TQString &str); - /** - * Overloaded member function. Tries to find an entity in the - * TQString str. - * @param str the string containing entified - * @param len is a return value, that gives the length of the decoded - * entity. - * @return a decoded entity if one could be found, TQChar::null - * otherwise - */ - static TQChar fromEntity(const TQString &str, int &len); - - /** - * Converts a TQChar to an entity. The returned string does already - * contain the leading '&' and the trailing ';'. - * @param ch the char to convert - * @return the entity - */ - static TQString toEntity(const TQChar &ch); - - /** - * Scans the given string for entities (like &amp;) and resolves them - * using fromEntity. - * @param text the string containing the entities - * @return the clean string - * @since 3.1 - */ - static TQString resolveEntities( const TQString &text ); - - /** - * Lists all available encodings as names. - * @return the list of all encodings - */ - TQStringList availableEncodingNames(); - - /** - * Lists the available encoding names together with a more descriptive language. - * @return the list of descriptive encoding names - */ - TQStringList descriptiveEncodingNames(); - - /** - * Returns the language the encoding is used for. - * @param encoding the encoding for the language - * @return the language of the encoding - */ - TQString languageForEncoding( const TQString &encoding ); - - /** - * Returns the encoding for a string obtained with descriptiveEncodingNames(). - * @param descriptiveName the descriptive name for the encoding - * @return the name of the encoding - */ - TQString encodingForName( const TQString &descriptiveName ); - -private: - KCharsetsPrivate *d; -}; - -#endif diff --git a/kdecore/kcheckaccelerators.cpp b/kdecore/kcheckaccelerators.cpp deleted file mode 100644 index 06337485c..000000000 --- a/kdecore/kcheckaccelerators.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (C) 1998, 1999, 2000 KDE Team - - 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. - */ - -// $Id$ - -#define INCLUDE_MENUITEM_DEF -#include <tqmenudata.h> - -#include "config.h" - -#include "kcheckaccelerators.h" -#include "kaccelmanager.h" -#include <tqpopupmenu.h> -#include <tqapplication.h> -#include <tqdialog.h> -#include <tqlayout.h> -#include <tqtextview.h> -#include <tqobjectlist.h> -#include <tqmenubar.h> -#include <tqtabbar.h> -#include <tqpushbutton.h> -#include <tqmetaobject.h> -#include <tqcheckbox.h> - -#include <kconfig.h> -#include <kdebug.h> -#include <kglobal.h> -#include <kshortcut.h> -#include <klocale.h> - -/* - - HOWTO: - - This class allows translators (and application developers) to check for accelerator - conflicts in menu and widgets. Put the following in your kdeglobals (or the config - file for the application you're testing): - - [Development] - CheckAccelerators=F12 - AutoCheckAccelerators=false - AlwaysShowCheckAccelerators=false - - The checking can be either manual or automatic. To perform manual check, press - the keyboard shortcut set to 'CheckAccelerators' (here F12). If automatic checking - is enabled by setting 'AutoCheckAccelerators' to true, check will be performed every - time the GUI changes. It's possible that in certain cases the check will be - done also when no visible changes in the GUI happen or the check won't be done - even if the GUI changed (in the latter case, use manual check ). Automatic - checks can be anytime disabled by the checkbox in the dialog presenting - the results of the check. If you set 'AlwaysShowCheckAccelerators' to true, - the dialog will be shown even if the automatic check didn't find any conflicts, - and all submenus will be shown, even those without conflicts. - - The dialog first lists the name of the window, then all results for all menus - (if the window has a menubar) and then result for all controls in the active - window (if there are any checkboxes etc.). For every submenu and all controls - there are shown all conflicts grouped by accelerator, and a list of all used - accelerators. -*/ - -KCheckAccelerators::KCheckAccelerators( TQObject* parent ) - : TQObject( parent, "kapp_accel_filter" ), key(0), block( false ), drklash(0) -{ - parent->installEventFilter( this ); - KConfigGroupSaver saver( KGlobal::config(), "Development" ); - TQString sKey = KGlobal::config()->readEntry( "CheckAccelerators" ).stripWhiteSpace(); - if( !sKey.isEmpty() ) { - KShortcut cuts( sKey ); - if( cuts.count() > 0 ) - key = int(cuts.seq(0).qt()); - } - alwaysShow = KGlobal::config()->readBoolEntry( "AlwaysShowCheckAccelerators", false ); - autoCheck = KGlobal::config()->readBoolEntry( "AutoCheckAccelerators", true ); - connect( &autoCheckTimer, TQT_SIGNAL( timeout()), TQT_SLOT( autoCheckSlot())); -} - -bool KCheckAccelerators::eventFilter( TQObject * , TQEvent * e) -{ - if ( block ) - return false; - - switch ( e->type() ) { // just simplify debuggin - case TQEvent::Accel: - if ( key && (TQT_TQKEYEVENT(e)->key() == key) ) { - block = true; - checkAccelerators( false ); - block = false; - TQT_TQKEYEVENT(e)->accept(); - return true; - } - break; - case TQEvent::ChildInserted: - case TQEvent::ChildRemoved: - case TQEvent::Resize: - case TQEvent::LayoutHint: - case TQEvent::WindowActivate: - case TQEvent::WindowDeactivate: - if( autoCheck ) - autoCheckTimer.start( 20, true ); // 20 ms - break; - case TQEvent::Timer: - case TQEvent::MouseMove: - case TQEvent::Paint: - return false; - default: - // kdDebug(125) << "KCheckAccelerators::eventFilter " << e->type() << " " << autoCheck << endl; - break; - } - return false; -} - -void KCheckAccelerators::autoCheckSlot() -{ - if( block ) - { - autoCheckTimer.start( 20, true ); - return; - } - block = true; - checkAccelerators( !alwaysShow ); - block = false; -} - -void KCheckAccelerators::createDialog(TQWidget *actWin, bool automatic) -{ - if ( drklash ) - return; - - drklash = new TQDialog( actWin, "kapp_accel_check_dlg", false, (WFlags)TQt::WDestructiveClose); - drklash->setCaption( i18n( "Dr. Klash' Accelerator Diagnosis" )); - drklash->resize( 500, 460 ); - TQVBoxLayout* layout = new TQVBoxLayout( drklash, 11, 6 ); - layout->setAutoAdd( true ); - drklash_view = new TQTextView( drklash ); - TQCheckBox* disableAutoCheck = NULL; - if( automatic ) { - disableAutoCheck = new TQCheckBox( i18n( "&Disable automatic checking" ), drklash ); - connect(disableAutoCheck, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotDisableCheck(bool))); - } - TQPushButton* btnClose = new TQPushButton( i18n( "&Close" ), drklash ); - btnClose->setDefault( true ); - connect( btnClose, TQT_SIGNAL( clicked() ), drklash, TQT_SLOT( close() ) ); - if (disableAutoCheck) - disableAutoCheck->setFocus(); - else - drklash_view->setFocus(); -} - -void KCheckAccelerators::slotDisableCheck(bool on) -{ - autoCheck = !on; - if (!on) - autoCheckSlot(); -} - -void KCheckAccelerators::checkAccelerators( bool automatic ) -{ - TQWidget* actWin = TQT_TQWIDGET(tqApp->activeWindow()); - if ( !actWin ) - return; - - KAcceleratorManager::manage(actWin); - TQString a, c, r; - KAcceleratorManager::last_manage(a, c, r); - - if (automatic) // for now we only show dialogs on F12 checks - return; - - if (c.isEmpty() && r.isEmpty() && (automatic || a.isEmpty())) - return; - - TQString s; - - if ( ! c.isEmpty() ) { - s += i18n("<h2>Accelerators changed</h2>"); - s += "<table border><tr><th><b>Old Text</b></th><th><b>New Text</b></th></tr>" - + c + "</table>"; - } - - if ( ! r.isEmpty() ) { - s += i18n("<h2>Accelerators removed</h2>"); - s += "<table border><tr><th><b>Old Text</b></th></tr>" + r + "</table>"; - } - - if ( ! a.isEmpty() ) { - s += i18n("<h2>Accelerators added (just for your info)</h2>"); - s += "<table border><tr><th><b>New Text</b></th></tr>" + a + "</table>"; - } - - createDialog(actWin, automatic); - drklash_view->setText(s); - drklash->show(); - drklash->raise(); - - // dlg will be destroyed before returning -} - -#include "kcheckaccelerators.moc" diff --git a/kdecore/kcheckaccelerators.h b/kdecore/kcheckaccelerators.h deleted file mode 100644 index 6a9439be6..000000000 --- a/kdecore/kcheckaccelerators.h +++ /dev/null @@ -1,96 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (C) 1998, 1999, 2000 KDE Team - - 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 KCHECKACCELERATORS_H_ -#define KCHECKACCELERATORS_H_ - -#include <tqguardedptr.h> -#include <tqobject.h> -#include <tqkeysequence.h> -#include <tqmap.h> -#include <tqstring.h> -#include <tqtimer.h> - -class TQMenuData; -class TQTextView; - -#include "kdelibs_export.h" - -/** - @internal - This class allows translators (and application developers) to check for accelerator - conflicts in menu and widgets. Put the following in your kdeglobals (or the config - file for the application you're testing): - - \code - [Development] - CheckAccelerators=F12 - AutoCheckAccelerators=false - AlwaysShowCheckAccelerators=false - \endcode - - The checking can be either manual or automatic. To perform manual check, press - the keyboard shortcut set to 'CheckAccelerators' (here F12). If automatic checking - is enabled by setting 'AutoCheckAccelerators' to true, check will be performed every - time the GUI changes. It's possible that in certain cases the check will be - done also when no visible changes in the GUI happen or the check won't be done - even if the GUI changed (in the latter case, use manual check ). Automatic - checks can be anytime disabled by the checkbox in the dialog presenting - the results of the check. If you set 'AlwaysShowCheckAccelerators' to true, - the dialog will be shown even if the automatic check didn't find any conflicts, - and all submenus will be shown, even those without conflicts. - - The dialog first lists the name of the window, then all results for all menus - (if the window has a menubar) and then result for all controls in the active - window (if there are any checkboxes etc.). For every submenu and all controls - there are shown all conflicts grouped by accelerator, and a list of all used - accelerators. -*/ -class KDECORE_EXPORT KCheckAccelerators : public TQObject -{ - Q_OBJECT -public: - /** - * Creates a KCheckAccelerators instance for the given object. - * @param parent the parent to check - */ - KCheckAccelerators( TQObject* parent ); - /** - * Re-implemented to filter the parent's events. - */ - bool eventFilter( TQObject * , TQEvent * e); - -private: - void checkAccelerators( bool automatic ); - int key; - bool alwaysShow; - bool autoCheck; - bool block; - TQTimer autoCheckTimer; - void createDialog(TQWidget *parent, bool automatic); - TQGuardedPtr<TQDialog> drklash; - TQTextView *drklash_view; - -private slots: - void autoCheckSlot(); - void slotDisableCheck(bool); -}; - -#endif diff --git a/kdecore/kckey.cpp b/kdecore/kckey.cpp deleted file mode 100644 index 0feea1d49..000000000 --- a/kdecore/kckey.cpp +++ /dev/null @@ -1,286 +0,0 @@ -// This file has been automatically generated by "generate_keys.sh" -// Distributed under the GNU Library General Public License - -#include <tqnamespace.h> -#include "kckey.h" - -const KKeys kde_KKEYS[NB_KEYS] = { - { "Escape", 0x1000 }, // translated - { "Tab", 0x1001 }, // translated - { "Backtab", 0x1002 }, // translated - { "Backspace", 0x1003 }, // translated - { "Return", 0x1004 }, // translated - { "Enter", 0x1005 }, // translated - { "Insert", 0x1006 }, // translated - { "Delete", 0x1007 }, // translated - { "Pause", 0x1008 }, // translated - { "Print", 0x1009 }, // translated - { "SysReq", 0x100a }, // translated - { "Clear", 0x100b }, - { "Home", 0x1010 }, // translated - { "End", 0x1011 }, // translated - { "Left", 0x1012 }, // translated - { "Up", 0x1013 }, // translated - { "Right", 0x1014 }, // translated - { "Down", 0x1015 }, // translated - { "Prior", 0x1016 }, // translated - { "Next", 0x1017 }, // translated - { "Shift", 0x1020 }, // translated - { "Control", 0x1021 }, // translated - { "Meta", 0x1022 }, // translated - { "Alt", 0x1023 }, // translated - { "CapsLock", 0x1024 }, // translated - { "NumLock", 0x1025 }, // translated - { "ScrollLock", 0x1026 }, // translated - { "F1", 0x1030 }, - { "F2", 0x1031 }, - { "F3", 0x1032 }, - { "F4", 0x1033 }, - { "F5", 0x1034 }, - { "F6", 0x1035 }, - { "F7", 0x1036 }, - { "F8", 0x1037 }, - { "F9", 0x1038 }, - { "F10", 0x1039 }, - { "F11", 0x103a }, - { "F12", 0x103b }, - { "F13", 0x103c }, - { "F14", 0x103d }, - { "F15", 0x103e }, - { "F16", 0x103f }, - { "F17", 0x1040 }, - { "F18", 0x1041 }, - { "F19", 0x1042 }, - { "F20", 0x1043 }, - { "F21", 0x1044 }, - { "F22", 0x1045 }, - { "F23", 0x1046 }, - { "F24", 0x1047 }, - { "F25", 0x1048 }, - { "F26", 0x1049 }, - { "F27", 0x104a }, - { "F28", 0x104b }, - { "F29", 0x104c }, - { "F30", 0x104d }, - { "F31", 0x104e }, - { "F32", 0x104f }, - { "F33", 0x1050 }, - { "F34", 0x1051 }, - { "F35", 0x1052 }, - { "Super_L", 0x1053 }, - { "Super_R", 0x1054 }, - { "Menu", 0x1055 }, // translated - { "Hyper_L", 0x1056 }, - { "Hyper_R", 0x1057 }, - { "Help", 0x1058 }, // translated - { "Direction_L", 0x1059 }, - { "Direction_R", 0x1060 }, - { "Space", 0x20 }, // translated - { "Any", Qt::Key_Space }, - { "Exclam", 0x21 }, // translated - { "QuoteDbl", 0x22 }, - { "NumberSign", 0x23 }, // translated - { "Dollar", 0x24 }, // translated - { "Percent", 0x25 }, // translated - { "Ampersand", 0x26 }, // translated - { "Apostrophe", 0x27 }, // translated - { "ParenLeft", 0x28 }, // translated - { "ParenRight", 0x29 }, // translated - { "Asterisk", 0x2a }, // translated - { "Plus", 0x2b }, // translated - { "Comma", 0x2c }, // translated - { "Minus", 0x2d }, // translated - { "Period", 0x2e }, // translated - { "Slash", 0x2f }, // translated - { "0", 0x30 }, - { "1", 0x31 }, - { "2", 0x32 }, - { "3", 0x33 }, - { "4", 0x34 }, - { "5", 0x35 }, - { "6", 0x36 }, - { "7", 0x37 }, - { "8", 0x38 }, - { "9", 0x39 }, - { "Colon", 0x3a }, // translated - { "Semicolon", 0x3b }, // translated - { "Less", 0x3c }, // translated - { "Equal", 0x3d }, // translated - { "Greater", 0x3e }, // translated - { "Question", 0x3f }, // translated - { "At", 0x40 }, - { "A", 0x41 }, - { "B", 0x42 }, - { "C", 0x43 }, - { "D", 0x44 }, - { "E", 0x45 }, - { "F", 0x46 }, - { "G", 0x47 }, - { "H", 0x48 }, - { "I", 0x49 }, - { "J", 0x4a }, - { "K", 0x4b }, - { "L", 0x4c }, - { "M", 0x4d }, - { "N", 0x4e }, - { "O", 0x4f }, - { "P", 0x50 }, - { "Q", 0x51 }, - { "R", 0x52 }, - { "S", 0x53 }, - { "T", 0x54 }, - { "U", 0x55 }, - { "V", 0x56 }, - { "W", 0x57 }, - { "X", 0x58 }, - { "Y", 0x59 }, - { "Z", 0x5a }, - { "BracketLeft", 0x5b }, // translated - { "Backslash", 0x5c }, // translated - { "BracketRight", 0x5d }, // translated - { "AsciiCircum", 0x5e }, // translated - { "Underscore", 0x5f }, // translated - { "QuoteLeft", 0x60 }, // translated - { "BraceLeft", 0x7b }, // translated - { "Bar", 0x7c }, - { "BraceRight", 0x7d }, // translated - { "AsciiTilde", 0x7e }, // translated - { "nobreakspace", 0x0a0 }, - { "exclamdown", 0x0a1 }, - { "cent", 0x0a2 }, - { "sterling", 0x0a3 }, - { "currency", 0x0a4 }, - { "yen", 0x0a5 }, - { "brokenbar", 0x0a6 }, - { "section", 0x0a7 }, - { "diaeresis", 0x0a8 }, - { "copyright", 0x0a9 }, - { "ordfeminine", 0x0aa }, - { "guillemotleft", 0x0ab }, - { "notsign", 0x0ac }, - { "hyphen", 0x0ad }, - { "registered", 0x0ae }, - { "macron", 0x0af }, - { "degree", 0x0b0 }, - { "plusminus", 0x0b1 }, - { "twosuperior", 0x0b2 }, - { "threesuperior", 0x0b3 }, - { "acute", 0x0b4 }, - { "mu", 0x0b5 }, - { "paragraph", 0x0b6 }, - { "periodcentered", 0x0b7 }, - { "cedilla", 0x0b8 }, - { "onesuperior", 0x0b9 }, - { "masculine", 0x0ba }, - { "guillemotright", 0x0bb }, - { "onequarter", 0x0bc }, - { "onehalf", 0x0bd }, - { "threequarters", 0x0be }, - { "questiondown", 0x0bf }, - { "Agrave", 0x0c0 }, - { "Aacute", 0x0c1 }, - { "Acircumflex", 0x0c2 }, - { "Atilde", 0x0c3 }, - { "Adiaeresis", 0x0c4 }, - { "Aring", 0x0c5 }, - { "AE", 0x0c6 }, - { "Ccedilla", 0x0c7 }, - { "Egrave", 0x0c8 }, - { "Eacute", 0x0c9 }, - { "Ecircumflex", 0x0ca }, - { "Ediaeresis", 0x0cb }, - { "Igrave", 0x0cc }, - { "Iacute", 0x0cd }, - { "Icircumflex", 0x0ce }, - { "Idiaeresis", 0x0cf }, - { "ETH", 0x0d0 }, - { "Ntilde", 0x0d1 }, - { "Ograve", 0x0d2 }, - { "Oacute", 0x0d3 }, - { "Ocircumflex", 0x0d4 }, - { "Otilde", 0x0d5 }, - { "Odiaeresis", 0x0d6 }, - { "multiply", 0x0d7 }, - { "Ooblique", 0x0d8 }, - { "Ugrave", 0x0d9 }, - { "Uacute", 0x0da }, - { "Ucircumflex", 0x0db }, - { "Udiaeresis", 0x0dc }, - { "Yacute", 0x0dd }, - { "THORN", 0x0de }, - { "ssharp", 0x0df }, - { "agrave", 0x0e0 }, - { "aacute", 0x0e1 }, - { "acircumflex", 0x0e2 }, - { "atilde", 0x0e3 }, - { "adiaeresis", 0x0e4 }, - { "aring", 0x0e5 }, - { "ae", 0x0e6 }, - { "ccedilla", 0x0e7 }, - { "egrave", 0x0e8 }, - { "eacute", 0x0e9 }, - { "ecircumflex", 0x0ea }, - { "ediaeresis", 0x0eb }, - { "igrave", 0x0ec }, - { "iacute", 0x0ed }, - { "icircumflex", 0x0ee }, - { "idiaeresis", 0x0ef }, - { "eth", 0x0f0 }, - { "ntilde", 0x0f1 }, - { "ograve", 0x0f2 }, - { "oacute", 0x0f3 }, - { "ocircumflex", 0x0f4 }, - { "otilde", 0x0f5 }, - { "odiaeresis", 0x0f6 }, - { "division", 0x0f7 }, - { "oslash", 0x0f8 }, - { "ugrave", 0x0f9 }, - { "uacute", 0x0fa }, - { "ucircumflex", 0x0fb }, - { "udiaeresis", 0x0fc }, - { "yacute", 0x0fd }, - { "thorn", 0x0fe }, - { "ydiaeresis", 0x0ff }, - { "Back ", 0x1061 }, - { "Forward ", 0x1062 }, - { "Stop ", 0x1063 }, - { "Refresh ", 0x1064 }, - { "VolumeDown", 0x1070 }, - { "VolumeMute ", 0x1071 }, - { "VolumeUp", 0x1072 }, - { "BassBoost", 0x1073 }, - { "BassUp", 0x1074 }, - { "BassDown", 0x1075 }, - { "TrebleUp", 0x1076 }, - { "TrebleDown", 0x1077 }, - { "MediaPlay ", 0x1080 }, - { "MediaStop ", 0x1081 }, - { "MediaPrev ", 0x1082 }, - { "MediaNext ", 0x1083 }, - { "MediaRecord", 0x1084 }, - { "HomePage ", 0x1090 }, - { "Favorites ", 0x1091 }, - { "Search ", 0x1092 }, - { "Standby", 0x1093 }, - { "OpenUrl", 0x1094 }, - { "LaunchMail ", 0x10a0 }, - { "LaunchMedia", 0x10a1 }, - { "Launch0 ", 0x10a2 }, - { "Launch1 ", 0x10a3 }, - { "Launch2 ", 0x10a4 }, - { "Launch3 ", 0x10a5 }, - { "Launch4 ", 0x10a6 }, - { "Launch5 ", 0x10a7 }, - { "Launch6 ", 0x10a8 }, - { "Launch7 ", 0x10a9 }, - { "Launch8 ", 0x10aa }, - { "Launch9 ", 0x10ab }, - { "LaunchA ", 0x10ac }, - { "LaunchB ", 0x10ad }, - { "LaunchC ", 0x10ae }, - { "LaunchD ", 0x10af }, - { "LaunchE ", 0x10b0 }, - { "LaunchF ", 0x10b1 }, - { "MediaLast", 0x1fff }, - { "unknown", 0xffff } -}; diff --git a/kdecore/kckey.h b/kdecore/kckey.h deleted file mode 100644 index 887d42e0a..000000000 --- a/kdecore/kckey.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file has been automatically generated by "generate_keys.sh" -// Distributed under the GNU Library General Public License -#ifndef KCKEY_H -#define KCKEY_H - -typedef struct { - const char *name; - int code; -} KKeys; - -#define MAX_KEY_LENGTH 15 // should be calculated (gawk ?) -#define MAX_KEY_MODIFIER_LENGTH 21 // "SHIFT + CRTL + ALT + " : -#define MAX_FCTN_LENGTH 50 // arbitrary limit -#define NB_KEYS 278 -extern const KKeys kde_KKEYS[NB_KEYS]; - -#endif diff --git a/kdecore/kclipboard.cpp b/kdecore/kclipboard.cpp deleted file mode 100644 index 86250ea4f..000000000 --- a/kdecore/kclipboard.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 <kapplication.h> -#include <kconfig.h> -#include <kglobal.h> - -#include "kclipboard.h" - -/* - * This class provides an automatic synchronization of the X11 Clipboard and Selection - * buffers. There are two configuration options in the kdeglobals configuration file, - * in the [General] section: - * - SynchronizeClipboardAndSelection - whenever the Selection changes, Clipboard is - * set to the same value. This can be also enabled in Klipper. - * - ClipboardSetSelection - whenever the Clipboard changes, Selection is set - * to the same value. This setting is only for die-hard fans of the old broken - * KDE1/2 behavior, which can potentionally lead to unexpected problems, - * and this setting therefore can be enabled only in the configuration file. - * - * Whenever reporting any bug only remotely related to clipboard, first make - * sure you can reproduce it when both these two options are turned off, - * especially the second one. - */ - -class KClipboardSynchronizer::MimeSource : public TQMimeSource -{ -public: - MimeSource( const TQMimeSource * src ) - : TQMimeSource(), - m_formats( true ) // deep copies! - { - m_formats.setAutoDelete( true ); - m_data.setAutoDelete( true ); - - if ( src ) - { - TQByteArray *byteArray; - const char *format; - int i = 0; - while ( (format = src->format( i++ )) ) - { - byteArray = new TQByteArray(); - *byteArray = src->tqencodedData( format ).copy(); - m_data.append( byteArray ); - m_formats.append( format ); - } - } - } - - ~MimeSource() {} - - virtual const char *format( int i ) const { - if ( i < (int) m_formats.count() ) - return m_formats.tqat( i ); - else - return 0L; - } - virtual bool provides( const char *mimeType ) const { - return ( m_formats.find( mimeType ) > -1 ); - } - virtual TQByteArray tqencodedData( const char *format ) const - { - int index = m_formats.find( format ); - if ( index > -1 ) - return *(m_data.tqat( index )); - - return TQByteArray(); - } - -private: - mutable TQStrList m_formats; - mutable TQPtrList<TQByteArray> m_data; -}; - - -KClipboardSynchronizer * KClipboardSynchronizer::s_self = 0L; -bool KClipboardSynchronizer::s_sync = false; -bool KClipboardSynchronizer::s_reverse_sync = false; -bool KClipboardSynchronizer::s_blocked = false; - -KClipboardSynchronizer * KClipboardSynchronizer::self() -{ - if ( !s_self ) - s_self = new KClipboardSynchronizer( TQT_TQOBJECT(kapp), "KDE Clipboard" ); - - return s_self; -} - -KClipboardSynchronizer::KClipboardSynchronizer( TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ - s_self = this; - - KConfigGroup config( KGlobal::config(), "General" ); - s_sync = config.readBoolEntry( "SynchronizeClipboardAndSelection", s_sync); - s_reverse_sync = config.readBoolEntry( "ClipboardSetSelection", - s_reverse_sync ); - - setupSignals(); -} - -KClipboardSynchronizer::~KClipboardSynchronizer() -{ - if ( s_self == this ) - s_self = 0L; -} - -void KClipboardSynchronizer::setupSignals() -{ - TQClipboard *clip = TQApplication::tqclipboard(); - disconnect( clip, NULL, this, NULL ); - if( s_sync ) - connect( clip, TQT_SIGNAL( selectionChanged() ), - TQT_SLOT( slotSelectionChanged() )); - if( s_reverse_sync ) - connect( clip, TQT_SIGNAL( dataChanged() ), - TQT_SLOT( slotClipboardChanged() )); -} - -void KClipboardSynchronizer::slotSelectionChanged() -{ - TQClipboard *clip = TQApplication::tqclipboard(); - -// qDebug("*** sel changed: %i", s_blocked); - if ( s_blocked || !clip->ownsSelection() ) - return; - - setClipboard( new MimeSource( clip->data( TQClipboard::Selection) ), - TQClipboard::Clipboard ); -} - -void KClipboardSynchronizer::slotClipboardChanged() -{ - TQClipboard *clip = TQApplication::tqclipboard(); - -// qDebug("*** clip changed : %i (implicit: %i, ownz: clip: %i, selection: %i)", s_blocked, s_implicitSelection, clip->ownsClipboard(), clip->ownsSelection()); - if ( s_blocked || !clip->ownsClipboard() ) - return; - - setClipboard( new MimeSource( clip->data( TQClipboard::Clipboard ) ), - TQClipboard::Selection ); -} - -void KClipboardSynchronizer::setClipboard( TQMimeSource *data, TQClipboard::Mode mode ) -{ -// qDebug("---> setting clipboard: %p", data); - - TQClipboard *clip = TQApplication::tqclipboard(); - - s_blocked = true; - - if ( mode == TQClipboard::Clipboard ) - { - clip->setData( data, TQClipboard::Clipboard ); - } - else if ( mode == TQClipboard::Selection ) - { - clip->setData( data, TQClipboard::Selection ); - } - - s_blocked = false; -} - -void KClipboardSynchronizer::setSynchronizing( bool sync ) -{ - s_sync = sync; - self()->setupSignals(); -} - -void KClipboardSynchronizer::setReverseSynchronizing( bool enable ) -{ - s_reverse_sync = enable; - self()->setupSignals(); -} - -// private, called by KApplication -void KClipboardSynchronizer::newConfiguration( int config ) -{ - s_sync = (config & Synchronize); - self()->setupSignals(); -} - -#include "kclipboard.moc" diff --git a/kdecore/kclipboard.h b/kdecore/kclipboard.h deleted file mode 100644 index 9432d70aa..000000000 --- a/kdecore/kclipboard.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 KCLIPBOARD_H -#define KCLIPBOARD_H - -#include <tqclipboard.h> -#include <tqmime.h> -#include <tqobject.h> -#include <tqstrlist.h> -#include "kdelibs_export.h" - -/** - * This class is only for internal use. - * - * @short Allowing to automatically synchronize the X11 Clipboard and Selection buffers. - * @author Carsten Pfeiffer <pfeiffer@kde.org> - * @since 3.1 - * @internal - */ -class KDECORE_EXPORT KClipboardSynchronizer : public TQObject -{ - Q_OBJECT - -public: - /** Systray widget for manipulating the clipboard. */ - friend class KlipperWidget; - friend class KApplication; - - /** - * Returns the KClipboardSynchronizer singleton object. - * @return the KClipboardSynchronizer singleton object. - */ - static KClipboardSynchronizer *self(); - - /** - * Configures KClipboardSynchronizer to synchronize the Selection to Clipboard whenever - * it changes. - * - * Default is false. - * @see isSynchronizing - */ - static void setSynchronizing( bool sync ); - - /** - * Checks whether Clipboard and Selection will be synchronized upon changes. - * @returns whether Clipboard and Selection will be synchronized upon - * changes. - * @see setSynchronizing - */ - static bool isSynchronizing() - { - return s_sync; - } - - /** - * Configures KClipboardSynchronizer to copy the Clipboard buffer to the Selection - * buffer whenever the Clipboard changes. - * - * - * @param enable true to enable implicit selection, false otherwise. - * Default is true. - * @see selectionSetting - */ - static void setReverseSynchronizing( bool enable ); - - /** - * Checks whether the Clipboard buffer will be copied to the Selection - * buffer upon changes. - * @returns whether the Clipboard buffer will be copied to the Selection - * buffer upon changes. - * @see setSelectionSetting - */ - static bool isReverseSynchronizing() - { - return s_reverse_sync; - } - - -protected: - ~KClipboardSynchronizer(); - -private slots: - void slotSelectionChanged(); - void slotClipboardChanged(); - -private: - KClipboardSynchronizer( TQObject *parent = 0, const char *name = 0L ); - void setupSignals(); - - static void setClipboard( TQMimeSource* data, TQClipboard::Mode mode ); - - static KClipboardSynchronizer *s_self; - static bool s_sync; - static bool s_reverse_sync; - static bool s_blocked; - - class MimeSource; - -private: - // needed by klipper - enum Configuration { Synchronize = 1 }; - // called by KApplication upon kipc message, invoked by klipper - static void newConfiguration( int config ); - -}; - -#endif // KCLIPBOARD_H diff --git a/kdecore/kcmdlineargs.cpp b/kdecore/kcmdlineargs.cpp deleted file mode 100644 index 10793b739..000000000 --- a/kdecore/kcmdlineargs.cpp +++ /dev/null @@ -1,1298 +0,0 @@ -/* - Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - - 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 <sys/param.h> - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif - -#include <tqdir.h> -#include <tqfile.h> -#include <tqasciidict.h> -#include <tqstrlist.h> - -#include "kcmdlineargs.h" -#include <kaboutdata.h> -#include <klocale.h> -#include <kapplication.h> -#include <kglobal.h> -#include <kstringhandler.h> -#include <kstaticdeleter.h> - -#ifdef Q_WS_X11 -#define DISPLAY "DISPLAY" -#elif defined(Q_WS_QWS) -#define DISPLAY "QWS_DISPLAY" -#endif - -#ifdef Q_WS_WIN -#include <win32_utils.h> -#endif - -template class TQAsciiDict<TQCString>; -template class TQPtrList<KCmdLineArgs>; - -class KCmdLineParsedOptions : public TQAsciiDict<TQCString> -{ -public: - KCmdLineParsedOptions() - : TQAsciiDict<TQCString>( 7 ) { } - - // WABA: Huh? - // The compiler doesn't find KCmdLineParsedOptions::write(s) by itself ??? - // WABA: No, because there is another write function that hides the - // write function in the base class even though this function has a - // different signature. (obscure C++ feature) - TQDataStream& save( TQDataStream &s) const - { return TQGDict::write(s); } - - TQDataStream& load( TQDataStream &s) - { return TQGDict::read(s); } - -protected: - virtual TQDataStream& write( TQDataStream &s, TQPtrCollection::Item data) const - { - TQCString *str = (TQCString *) data; - s << (*str); - return s; - } - - virtual TQDataStream& read( TQDataStream &s, TQPtrCollection::Item &item) - { - TQCString *str = new TQCString; - s >> (*str); - item = (void *)str; - return s; - } - -}; - -class KCmdLineParsedArgs : public TQStrList -{ -public: - KCmdLineParsedArgs() - : TQStrList( true ) { } - TQDataStream& save( TQDataStream &s) const - { return TQGList::write(s); } - - TQDataStream& load( TQDataStream &s) - { return TQGList::read(s); } -}; - - -class KCmdLineArgsList: public TQPtrList<KCmdLineArgs> -{ -public: - KCmdLineArgsList() { } -}; - -KCmdLineArgsList *KCmdLineArgs::argsList = 0; -int KCmdLineArgs::argc = 0; -char **KCmdLineArgs::argv = 0; -char *KCmdLineArgs::mCwd = 0; -static KStaticDeleter <char> mCwdd; -const KAboutData *KCmdLineArgs::about = 0; -bool KCmdLineArgs::parsed = false; -bool KCmdLineArgs::ignoreUnknown = false; - -// -// Static functions -// - -void -KCmdLineArgs::init(int _argc, char **_argv, const char *_appname, const char* programName, - const char *_description, const char *_version, bool noKApp) -{ - init(_argc, _argv, - new KAboutData(_appname, programName, _version, _description), - noKApp); -} - -void -KCmdLineArgs::init(int _argc, char **_argv, const char *_appname, - const char *_description, const char *_version, bool noKApp) -{ - init(_argc, _argv, - new KAboutData(_appname, _appname, _version, _description), - noKApp); -} - -void -KCmdLineArgs::initIgnore(int _argc, char **_argv, const char *_appname ) -{ - init(_argc, _argv, - new KAboutData(_appname, _appname, "unknown", "KDE Application", false)); - ignoreUnknown = true; -} - -void -KCmdLineArgs::init(const KAboutData* ab) -{ - char **_argv = (char **) malloc(sizeof(char *)); - _argv[0] = (char *) ab->appName(); - init(1,_argv,ab, true); -} - - -void -KCmdLineArgs::init(int _argc, char **_argv, const KAboutData *_about, bool noKApp) -{ - argc = _argc; - argv = _argv; - - if (!argv) - { - fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n"); - fprintf(stderr, "Passing null-pointer to 'argv' is not allowed.\n\n"); - - assert( 0 ); - exit(255); - } - - // Strip path from argv[0] - if (argc) { - char *p = strrchr( argv[0], '/'); - if (p) - argv[0] = p+1; - } - - about = _about; - parsed = false; - mCwd = mCwdd.setObject(mCwd, new char [PATH_MAX+1], true); - (void) getcwd(mCwd, PATH_MAX); -#ifdef Q_WS_WIN - win32_slashify(mCwd, PATH_MAX); -#endif - if (!noKApp) - KApplication::addCmdLineOptions(); -} - -TQString KCmdLineArgs::cwd() -{ - return TQFile::decodeName(TQCString(mCwd)); -} - -const char * KCmdLineArgs::appName() -{ - if (!argc) return 0; - return argv[0]; -} - -void -KCmdLineArgs::addCmdLineOptions( const KCmdLineOptions *options, const char *name, - const char *id, const char *afterId) -{ - if (!argsList) - argsList = new KCmdLineArgsList(); - - int pos = argsList->count(); - - if (pos && id && argsList->last() && !argsList->last()->name) - pos--; - - KCmdLineArgs *args; - int i = 0; - for(args = argsList->first(); args; args = argsList->next(), i++) - { - if (!id && !args->id) - return; // Options already present. - - if (id && args->id && (::qstrcmp(id, args->id) == 0)) - return; // Options already present. - - if (afterId && args->id && (::qstrcmp(afterId, args->id) == 0)) - pos = i+1; - } - - assert( parsed == false ); // You must add _ALL_ cmd line options - // before accessing the arguments! - args = new KCmdLineArgs(options, name, id); - argsList->insert(pos, args); -} - -void -KCmdLineArgs::saveAppArgs( TQDataStream &ds) -{ - if (!parsed) - parseAllArgs(); - - // Remove Qt and KDE options. - removeArgs("qt"); - removeArgs("kde"); - - TQCString qCwd = mCwd; - ds << qCwd; - - uint count = argsList ? argsList->count() : 0; - ds << count; - - if (!count) return; - - KCmdLineArgs *args; - for(args = argsList->first(); args; args = argsList->next()) - { - ds << TQCString(args->id); - args->save(ds); - } -} - -void -KCmdLineArgs::loadAppArgs( TQDataStream &ds) -{ - parsed = true; // don't reparse argc/argv! - - // Remove Qt and KDE options. - removeArgs("qt"); - removeArgs("kde"); - - KCmdLineArgs *args; - if ( argsList ) { - for(args = argsList->first(); args; args = argsList->next()) - { - args->clear(); - } - } - - if (ds.atEnd()) - return; - - TQCString qCwd; - ds >> qCwd; - delete [] mCwd; - - mCwd = mCwdd.setObject(mCwd, new char[qCwd.length()+1], true); - strncpy(mCwd, qCwd.data(), qCwd.length()+1); - - uint count; - ds >> count; - - while(count--) - { - TQCString id; - ds >> id; - assert( argsList ); - for(args = argsList->first(); args; args = argsList->next()) - { - if (args->id == id) - { - args->load(ds); - break; - } - } - } - parsed = true; -} - -KCmdLineArgs *KCmdLineArgs::parsedArgs(const char *id) -{ - KCmdLineArgs *args = argsList ? argsList->first() : 0; - while(args) - { - if ((id && ::qstrcmp(args->id, id) == 0) || (!id && !args->id)) - { - if (!parsed) - parseAllArgs(); - return args; - } - args = argsList->next(); - } - - return args; -} - -void KCmdLineArgs::removeArgs(const char *id) -{ - KCmdLineArgs *args = argsList ? argsList->first() : 0; - while(args) - { - if (args->id && id && ::qstrcmp(args->id, id) == 0) - { - if (!parsed) - parseAllArgs(); - break; - } - args = argsList->next(); - } - - if (args) - delete args; -} - -/* - * @return: - * 0 - option not found. - * 1 - option found // -fork - * 2 - inverse option found ('no') // -nofork - * 3 - option + arg found // -fork now - * - * +4 - no more options follow // !fork - */ -static int -findOption(const KCmdLineOptions *options, TQCString &opt, - const char *&opt_name, const char *&def, bool &enabled) -{ - int result; - bool inverse; - int len = opt.length(); - while(options && options->name) - { - result = 0; - inverse = false; - opt_name = options->name; - if ((opt_name[0] == ':') || (opt_name[0] == 0)) - { - options++; - continue; - } - - if (opt_name[0] == '!') - { - opt_name++; - result = 4; - } - if ((opt_name[0] == 'n') && (opt_name[1] == 'o')) - { - opt_name += 2; - inverse = true; - } - if (strncmp(opt.data(), opt_name, len) == 0) - { - opt_name += len; - if (!opt_name[0]) - { - if (inverse) - return result+2; - - if (!options->description) - { - options++; - if (!options->name) - return result+0; - TQCString nextOption = options->name; - int p = nextOption.find(' '); - if (p > 0) - nextOption = nextOption.left(p); - if (nextOption[0] == '!') - nextOption = nextOption.mid(1); - if (strncmp(nextOption.data(), "no", 2) == 0) - { - nextOption = nextOption.mid(2); - enabled = !enabled; - } - result = findOption(options, nextOption, opt_name, def, enabled); - assert(result); - opt = nextOption; - return result; - } - - return 1; - } - if (opt_name[0] == ' ') - { - opt_name++; - def = options->def; - return result+3; - } - } - - options++; - } - return 0; -} - - -void -KCmdLineArgs::findOption(const char *_opt, TQCString opt, int &i, bool _enabled, bool &moreOptions) -{ - KCmdLineArgs *args = argsList->first(); - const char *opt_name; - const char *def; - TQCString argument; - int j = opt.find('='); - if (j != -1) - { - argument = opt.mid(j+1); - opt = opt.left(j); - } - - bool enabled = true; - int result = 0; - while (args) - { - enabled = _enabled; - result = ::findOption(args->options, opt, opt_name, def, enabled); - if (result) break; - args = argsList->next(); - } - if (!args && (_opt[0] == '-') && _opt[1] && (_opt[1] != '-')) - { - // Option not found check if it is a valid option - // in the style of -Pprinter1 or ps -aux - int p = 1; - while (true) - { - TQCString singleCharOption = " "; - singleCharOption[0] = _opt[p]; - args = argsList->first(); - while (args) - { - enabled = _enabled; - result = ::findOption(args->options, singleCharOption, opt_name, def, enabled); - if (result) break; - args = argsList->next(); - } - if (!args) - break; // Unknown argument - - p++; - if (result == 1) // Single option - { - args->setOption(singleCharOption, enabled); - if (_opt[p]) - continue; // Next option - else - return; // Finished - } - else if (result == 3) // This option takes an argument - { - if (argument.isEmpty()) - { - argument = _opt+p; - } - args->setOption(singleCharOption, (const char*)argument); - return; - } - break; // Unknown argument - } - args = 0; - result = 0; - } - - if (!args || !result) - { - if (ignoreUnknown) - return; - enable_i18n(); - usage( i18n("Unknown option '%1'.").arg(TQString::fromLocal8Bit(_opt))); - } - - if ((result & 4) != 0) - { - result &= ~4; - moreOptions = false; - } - - if (result == 3) // This option takes an argument - { - if (!enabled) - { - if (ignoreUnknown) - return; - enable_i18n(); - usage( i18n("Unknown option '%1'.").arg(TQString::fromLocal8Bit(_opt))); - } - if (argument.isEmpty()) - { - i++; - if (i >= argc) - { - enable_i18n(); - usage( i18n("'%1' missing.").arg( opt_name)); - } - argument = argv[i]; - } - args->setOption(opt, (const char*)argument); - } - else - { - args->setOption(opt, enabled); - } -} - -void -KCmdLineArgs::printQ(const TQString &msg) -{ - TQCString localMsg = msg.local8Bit(); - fprintf(stdout, "%s", localMsg.data()); -} - -void -KCmdLineArgs::parseAllArgs() -{ - bool allowArgs = false; - bool inOptions = true; - bool everythingAfterArgIsArgs = false; - KCmdLineArgs *appOptions = argsList->last(); - if (!appOptions->id) - { - const KCmdLineOptions *option = appOptions->options; - while(option && option->name) - { - if (option->name[0] == '+') - allowArgs = true; - if ( option->name[0] == '!' && option->name[1] == '+' ) - { - allowArgs = true; - everythingAfterArgIsArgs = true; - } - option++; - } - } - for(int i = 1; i < argc; i++) - { - if (!argv[i]) - continue; - - if ((argv[i][0] == '-') && argv[i][1] && inOptions) - { - bool enabled = true; - const char *option = &argv[i][1]; - const char *orig = argv[i]; - if (option[0] == '-') - { - option++; - argv[i]++; - if (!option[0]) - { - inOptions = false; - continue; - } - } - if (::qstrcmp(option, "help") == 0) - { - usage(0); - } - else if (strncmp(option, "help-",5) == 0) - { - usage(option+5); - } - else if ( (::qstrcmp(option, "version") == 0) || - (::qstrcmp(option, "v") == 0)) - { - printQ( TQString("Qt: %1\n").arg(qVersion())); - printQ( TQString("KDE: %1\n").arg(KDE_VERSION_STRING)); - printQ( TQString("%1: %2\n"). - arg(about->programName()).arg(about->version())); - exit(0); - } else if ( (::qstrcmp(option, "license") == 0) ) - { - enable_i18n(); - printQ( about->license() ); - printQ( "\n" ); - exit(0); - } else if ( ::qstrcmp( option, "author") == 0 ) { - enable_i18n(); - if ( about ) { - const TQValueList<KAboutPerson> authors = about->authors(); - if ( !authors.isEmpty() ) { - TQString authorlist; - for (TQValueList<KAboutPerson>::ConstIterator it = authors.begin(); it != authors.end(); ++it ) { - TQString email; - if ( !(*it).emailAddress().isEmpty() ) - email = " <" + (*it).emailAddress() + ">"; - authorlist += TQString(" ") + (*it).name() + email + "\n"; - } - printQ( i18n("the 2nd argument is a list of name+address, one on each line","%1 was written by\n%2").arg ( TQString(about->programName()) ).arg( authorlist ) ); - } - } else { - printQ( i18n("This application was written by somebody who wants to remain anonymous.") ); - } - if (about) - { - if (!about->customAuthorTextEnabled ()) - { - if (about->bugAddress().isEmpty() || about->bugAddress() == "submit@bugs.kde.org" ) - printQ( i18n( "Please use http://bugs.kde.org to report bugs.\n" ) ); - else { - if( about->authors().count() == 1 && about->authors().first().emailAddress() == about->bugAddress() ) - printQ( i18n( "Please report bugs to %1.\n" ).arg( about->authors().first().emailAddress() ) ); - else - printQ( i18n( "Please report bugs to %1.\n" ).arg(about->bugAddress()) ); - } - } - else - { - printQ(about->customAuthorPlainText()); - } - } - exit(0); - } else { - if ((option[0] == 'n') && (option[1] == 'o')) - { - option += 2; - enabled = false; - } - findOption(orig, option, i, enabled, inOptions); - } - } - else - { - // Check whether appOptions allows these arguments - if (!allowArgs) - { - if (ignoreUnknown) - continue; - enable_i18n(); - usage( i18n("Unexpected argument '%1'.").arg(TQString::fromLocal8Bit(argv[i]))); - } - else - { - appOptions->addArgument(argv[i]); - if (everythingAfterArgIsArgs) - inOptions = false; - } - } - } - parsed = true; -} - -/** - * For KApplication only: - * - * Return argc - */ -int * -KCmdLineArgs::qt_argc() -{ - if (!argsList) - KApplication::addCmdLineOptions(); // Lazy bastards! - - static int qt_argc = -1; - if( qt_argc != -1 ) - return &qt_argc; - - KCmdLineArgs *args = parsedArgs("qt"); - assert(args); // No qt options have been added! - if (!argv) - { - fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n"); - fprintf(stderr, "Application has not called KCmdLineArgs::init(...).\n\n"); - - assert( 0 ); - exit(255); - } - - assert(argc >= (args->count()+1)); - qt_argc = args->count() +1; - return &qt_argc; -} - -/** - * For KApplication only: - * - * Return argv - */ -char *** -KCmdLineArgs::qt_argv() -{ - if (!argsList) - KApplication::addCmdLineOptions(); // Lazy bastards! - - static char** qt_argv; - if( qt_argv != NULL ) - return &qt_argv; - - KCmdLineArgs *args = parsedArgs("qt"); - assert(args); // No qt options have been added! - if (!argv) - { - fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n"); - fprintf(stderr, "Application has not called KCmdLineArgs::init(...).\n\n"); - - assert( 0 ); - exit(255); - } - - qt_argv = new char*[ args->count() + 2 ]; - qt_argv[ 0 ] = qstrdup( appName()); - int i = 0; - for(; i < args->count(); i++) - { - qt_argv[i+1] = qstrdup((char *) args->arg(i)); - } - qt_argv[i+1] = 0; - - return &qt_argv; -} - -void -KCmdLineArgs::enable_i18n() -{ - // called twice or too late - if (KGlobal::_locale) - return; - - if (!KGlobal::_instance) { - KInstance *instance = new KInstance(about); - (void) instance->config(); - // Don't delete instance! - } -} - -void -KCmdLineArgs::usage(const TQString &error) -{ - assert(KGlobal::_locale); - TQCString localError = error.local8Bit(); - if (localError[error.length()-1] == '\n') - localError = localError.left(error.length()-1); - fprintf(stderr, "%s: %s\n", argv[0], localError.data()); - - TQString tmp = i18n("Use --help to get a list of available command line options."); - localError = tmp.local8Bit(); - fprintf(stderr, "%s: %s\n", argv[0], localError.data()); - exit(254); -} - -void -KCmdLineArgs::usage(const char *id) -{ - enable_i18n(); - assert(argsList != 0); // It's an error to call usage(...) without - // having done addCmdLineOptions first! - - TQString optionFormatString = " %1 %2\n"; - TQString optionFormatStringDef = " %1 %2 [%3]\n"; - TQString optionHeaderString = i18n("\n%1:\n"); - TQString tmp; - TQString usage; - - KCmdLineArgs *args = argsList->last(); - - if (!(args->id) && (args->options) && - (args->options->name) && (args->options->name[0] != '+')) - { - usage = i18n("[options] ")+usage; - } - - while(args) - { - if (args->name) - { - usage = i18n("[%1-options]").arg(args->name)+" "+usage; - } - args = argsList->prev(); - } - - KCmdLineArgs *appOptions = argsList->last(); - if (!appOptions->id) - { - const KCmdLineOptions *option = appOptions->options; - while(option && option->name) - { - if (option->name[0] == '+') - usage = usage + (option->name+1) + " "; - else if ( option->name[0] == '!' && option->name[1] == '+' ) - usage = usage + (option->name+2) + " "; - - option++; - } - } - - printQ(i18n("Usage: %1 %2\n").arg(argv[0]).arg(usage)); - printQ("\n"+about->shortDescription()+"\n"); - - printQ(optionHeaderString.arg(i18n("Generic options"))); - printQ(optionFormatString.arg("--help", -25).arg(i18n("Show help about options"))); - - args = argsList->first(); - while(args) - { - if (args->name && args->id) - { - TQString option = TQString("--help-%1").arg(args->id); - TQString desc = i18n("Show %1 specific options").arg(args->name); - - printQ(optionFormatString.arg(option, -25).arg(desc)); - } - args = argsList->next(); - } - - printQ(optionFormatString.arg("--help-all",-25).arg(i18n("Show all options"))); - printQ(optionFormatString.arg("--author",-25).arg(i18n("Show author information"))); - printQ(optionFormatString.arg("-v, --version",-25).arg(i18n("Show version information"))); - printQ(optionFormatString.arg("--license",-25).arg(i18n("Show license information"))); - printQ(optionFormatString.arg("--", -25).arg(i18n("End of options"))); - - args = argsList->first(); // Sets current to 1st. - - bool showAll = id && (::qstrcmp(id, "all") == 0); - - if (!showAll) - { - while(args) - { - if (!id && !args->id) break; - if (id && (::qstrcmp(args->id, id) == 0)) break; - args = argsList->next(); - } - } - - while(args) - { - bool hasArgs = false; - bool hasOptions = false; - TQString optionsHeader; - if (args->name) - optionsHeader = optionHeaderString.arg(i18n("%1 options").arg(TQString::tqfromLatin1(args->name))); - else - optionsHeader = i18n("\nOptions:\n"); - - while (args) - { - const KCmdLineOptions *option = args->options; - TQCString opt = ""; -// - while(option && option->name) - { - TQString description; - TQString descriptionRest; - TQStringList dl; - - // Option header - if (option->name[0] == ':') - { - if (option->description) - { - optionsHeader = "\n"+i18n(option->description); - if (!optionsHeader.endsWith("\n")) - optionsHeader.append("\n"); - hasOptions = false; - } - option++; - continue; - } - - // Free-form comment - if (option->name[0] == 0) - { - if (option->description) - { - TQString tmp = "\n"+i18n(option->description); - if (!tmp.endsWith("\n")) - tmp.append("\n"); - printQ(tmp); - } - option++; - continue; - } - - // Options - if (option->description) - { - description = i18n(option->description); - dl = TQStringList::split("\n", description, true); - description = dl.first(); - dl.remove( dl.begin() ); - } - TQCString name = option->name; - if (name[0] == '!') - name = name.mid(1); - - if (name[0] == '+') - { - if (!hasArgs) - { - printQ(i18n("\nArguments:\n")); - hasArgs = true; - } - - name = name.mid(1); - if ((name[0] == '[') && (name[name.length()-1] == ']')) - name = name.mid(1, name.length()-2); - printQ(optionFormatString.arg(QString(name), -25) - .arg(description)); - } - else - { - if (!hasOptions) - { - printQ(optionsHeader); - hasOptions = true; - } - - if ((name.length() == 1) || (name[1] == ' ')) - name = "-"+name; - else - name = "--"+name; - if (!option->description) - { - opt = name + ", "; - } - else - { - opt = opt + name; - if (!option->def) - { - printQ(optionFormatString.arg(QString(opt), -25) - .arg(description)); - } - else - { - printQ(optionFormatStringDef.arg(QString(opt), -25) - .arg(description).arg(option->def)); - } - opt = ""; - } - } - for(TQStringList::Iterator it = dl.begin(); - it != dl.end(); - ++it) - { - printQ(optionFormatString.arg("", -25).arg(*it)); - } - - option++; - } - args = argsList->next(); - if (!args || args->name || !args->id) break; - } - if (!showAll) break; - } - - exit(254); -} - -// -// Member functions -// - -/** - * Constructor. - * - * The given arguments are assumed to be constants. - */ -KCmdLineArgs::KCmdLineArgs( const KCmdLineOptions *_options, - const char *_name, const char *_id) - : options(_options), name(_name), id(_id) -{ - parsedOptionList = 0; - parsedArgList = 0; - isQt = (::qstrcmp(id, "qt") == 0); -} - -/** - * Destructor. - */ -KCmdLineArgs::~KCmdLineArgs() -{ - delete parsedOptionList; - delete parsedArgList; - if (argsList) - argsList->removeRef(this); -} - -void -KCmdLineArgs::clear() -{ - delete parsedArgList; - parsedArgList = 0; - delete parsedOptionList; - parsedOptionList = 0; -} - -void -KCmdLineArgs::reset() -{ - if ( argsList ) { - argsList->setAutoDelete( true ); - argsList->clear(); - delete argsList; - argsList = 0; - } - parsed = false; -} - -void -KCmdLineArgs::save( TQDataStream &ds) const -{ - uint count = 0; - if (parsedOptionList) - parsedOptionList->save( ds ); - else - ds << count; - - if (parsedArgList) - parsedArgList->save( ds ); - else - ds << count; -} - -void -KCmdLineArgs::load( TQDataStream &ds) -{ - if (!parsedOptionList) parsedOptionList = new KCmdLineParsedOptions; - if (!parsedArgList) parsedArgList = new KCmdLineParsedArgs; - - parsedOptionList->load( ds ); - parsedArgList->load( ds ); - - if (parsedOptionList->count() == 0) - { - delete parsedOptionList; - parsedOptionList = 0; - } - if (parsedArgList->count() == 0) - { - delete parsedArgList; - parsedArgList = 0; - } -} - -void -KCmdLineArgs::setOption(const TQCString &opt, bool enabled) -{ - if (isQt) - { - // Qt does it own parsing. - TQCString arg = "-"; - if( !enabled ) - arg += "no"; - arg += opt; - addArgument(arg); - } - if (!parsedOptionList) { - parsedOptionList = new KCmdLineParsedOptions; - parsedOptionList->setAutoDelete(true); - } - - if (enabled) - parsedOptionList->replace( opt, new TQCString("t") ); - else - parsedOptionList->replace( opt, new TQCString("f") ); -} - -void -KCmdLineArgs::setOption(const TQCString &opt, const char *value) -{ - if (isQt) - { - // Qt does it's own parsing. - TQCString arg = "-"; - arg += opt; - addArgument(arg); - addArgument(value); - -#ifdef Q_WS_X11 - // Hack coming up! - if (arg == "-display") - { - setenv(DISPLAY, value, true); - } -#endif - } - if (!parsedOptionList) { - parsedOptionList = new KCmdLineParsedOptions; - parsedOptionList->setAutoDelete(true); - } - - parsedOptionList->insert( opt, new TQCString(value) ); -} - -TQCString -KCmdLineArgs::getOption(const char *_opt) const -{ - TQCString *value = 0; - if (parsedOptionList) - { - value = parsedOptionList->find(_opt); - } - - if (value) - return (*value); - - // Look up the default. - const char *opt_name; - const char *def; - bool dummy = true; - TQCString opt = _opt; - int result = ::findOption( options, opt, opt_name, def, dummy) & ~4; - - if (result != 3) - { - fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n"); - fprintf(stderr, "Application requests for getOption(\"%s\") but the \"%s\" option\n", - _opt, _opt); - fprintf(stderr, "has never been specified via addCmdLineOptions( ... )\n\n"); - - assert( 0 ); - exit(255); - } - return TQCString(def); -} - -QCStringList -KCmdLineArgs::getOptionList(const char *_opt) const -{ - QCStringList result; - if (!parsedOptionList) - return result; - - while(true) - { - TQCString *value = parsedOptionList->take(_opt); - if (!value) - break; - result.prepend(*value); - delete value; - } - - // Reinsert items in dictionary - // WABA: This is rather silly, but I don't want to add restrictions - // to the API like "you can only call this function once". - // I can't access all items without taking them out of the list. - // So taking them out and then putting them back is the only way. - for(QCStringList::ConstIterator it=result.begin(); - it != result.end(); - ++it) - { - parsedOptionList->insert(_opt, new TQCString(*it)); - } - return result; -} - -bool -KCmdLineArgs::isSet(const char *_opt) const -{ - // Look up the default. - const char *opt_name; - const char *def; - bool dummy = true; - TQCString opt = _opt; - int result = ::findOption( options, opt, opt_name, def, dummy) & ~4; - - if (result == 0) - { - fprintf(stderr, "\n\nFAILURE (KCmdLineArgs):\n"); - fprintf(stderr, "Application requests for isSet(\"%s\") but the \"%s\" option\n", - _opt, _opt); - fprintf(stderr, "has never been specified via addCmdLineOptions( ... )\n\n"); - - assert( 0 ); - exit(255); - } - - TQCString *value = 0; - if (parsedOptionList) - { - value = parsedOptionList->find(opt); - } - - if (value) - { - if (result == 3) - return true; - else - return ((*value)[0] == 't'); - } - - if (result == 3) - return false; // String option has 'false' as default. - - // We return 'true' as default if the option was listed as '-nofork' - // We return 'false' as default if the option was listed as '-fork' - return (result == 2); -} - -int -KCmdLineArgs::count() const -{ - if (!parsedArgList) - return 0; - return parsedArgList->count(); -} - -const char * -KCmdLineArgs::arg(int n) const -{ - if (!parsedArgList || (n >= (int) parsedArgList->count())) - { - fprintf(stderr, "\n\nFAILURE (KCmdLineArgs): Argument out of bounds\n"); - fprintf(stderr, "Application requests for arg(%d) without checking count() first.\n", - n); - - assert( 0 ); - exit(255); - } - - return parsedArgList->tqat(n); -} - -KURL -KCmdLineArgs::url(int n) const -{ - return makeURL( arg(n) ); -} - -KURL KCmdLineArgs::makeURL(const char *_urlArg) -{ - const TQString urlArg = TQFile::decodeName(_urlArg); - TQFileInfo fileInfo(urlArg); - if (!fileInfo.isRelative()) { // i.e. starts with '/', on unix - KURL result; - result.setPath(urlArg); - return result; // Absolute path. - } - - if ( KURL::isRelativeURL(urlArg) || fileInfo.exists() ) { - KURL result; - result.setPath( cwd()+'/'+urlArg ); - result.cleanPath(); - return result; // Relative path - } - - return KURL(urlArg); // Argument is a URL -} - -void -KCmdLineArgs::addArgument(const char *argument) -{ - if (!parsedArgList) - parsedArgList = new KCmdLineParsedArgs; - - parsedArgList->append(argument); -} - -static const KCmdLineOptions kde_tempfile_option[] = -{ - { "tempfile", I18N_NOOP("The files/URLs opened by the application will be deleted after use"), 0}, - KCmdLineLastOption -}; - -void -KCmdLineArgs::addTempFileOption() -{ - KCmdLineArgs::addCmdLineOptions( kde_tempfile_option, "KDE-tempfile", "kde-tempfile" ); -} - -bool KCmdLineArgs::isTempFileSet() -{ - KCmdLineArgs* args = KCmdLineArgs::parsedArgs( "kde-tempfile" ); - if ( args ) - return args->isSet( "tempfile" ); - return false; -} diff --git a/kdecore/kcmdlineargs.h b/kdecore/kcmdlineargs.h deleted file mode 100644 index b4386c629..000000000 --- a/kdecore/kcmdlineargs.h +++ /dev/null @@ -1,690 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - - 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 _KCMDLINEARGS_H_ -#define _KCMDLINEARGS_H_ - -#include "kdelibs_export.h" -#include <kurl.h> - -#include <tqptrlist.h> -#include <tqstring.h> -#include <tqvaluelist.h> - -typedef TQValueList<TQCString> QCStringList; - -/** - * @short Structure that holds command line options. - * - * This class is intended to be used with the KCmdLineArgs class, which - * provides convenient and powerful command line argument parsing and - * handling functionality. - * - * @see KCmdLineArgs for additional usage information - */ -struct KDECORE_EXPORT KCmdLineOptions -{ - /** - * The name of the argument as it should be called on the command line and - * appear in <i>myapp --help</i>. - * - * Note that if this option starts with "no" that you will need to test for - * the name without the "no" and the result will be the inverse of what is - * specified. i.e. if "nofoo" is the name of the option and - * <i>myapp --nofoo</i> is called: - * - * \code - * KCmdLineArgs::parsedArgs()->isSet("foo"); // false - * \endcode - */ - const char *name; - /** - * The text description of the option as should appear in - * <i>myapp --help</i>. This value should be wrapped with I18N_NOOP(). - */ - const char *description; - /** - * The default value for the option, if it is not specified on the - * command line. - */ - const char *def; // Default -}; - -#define KCmdLineLastOption { 0, 0, 0 } - -class KCmdLineArgsList; -class KApplication; -class KUniqueApplication; -class KCmdLineParsedOptions; -class KCmdLineParsedArgs; -class KAboutData; -class KCmdLineArgsPrivate; - -/** - * @short A class for command-line argument handling. - * - * KCmdLineArgs provides simple access to the command-line arguments - * for an application. It takes into account Qt-specific options, - * KDE-specific options and application specific options. - * - * This class is used in %main() via the static method - * init(). - * - * A typical %KDE application using %KCmdLineArgs should look like this: - * - * \code - * int main(int argc, char *argv[]) - * { - * // Initialize command line args - * KCmdLineArgs::init(argc, argv, appName, programName, description, version); - * - * // Tell which options are supported - * KCmdLineArgs::addCmdLineOptions( options ); - * - * // Add options from other components - * KUniqueApplication::addCmdLineOptions(); - * - * .... - * - * // Create application object without passing 'argc' and 'argv' again. - * KUniqueApplication app; - * - * .... - * - * // Handle our own options/arguments - * // A KApplication will usually do this in main but this is not - * // necessary. - * // A KUniqueApplication might want to handle it in newInstance(). - * - * KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - * - * // A binary option (on / off) - * if (args->isSet("some-option")) - * .... - * - * // An option which takes an additional argument - * TQCString anotherOptionArg = args->getOption("another-option"); - * - * // Arguments (e.g. files to open) - * for(int i = 0; i < args->count(); i++) // Counting start at 0! - * { - * // don't forget to convert to Unicode! - * openFile( TQFile::decodeName( args->arg(i))); - * // Or more convenient: - * // openURL( args->url(i)); - * - * } - * - * args->clear(); // Free up some memory. - * .... - * } - * \endcode - * - * The options that an application supports are configured using the - * KCmdLineOptions class. An example is shown below: - * - * \code - * static const KCmdLineOptions options[] = - * { - * { "a", I18N_NOOP("A short binary option"), 0 }, - * { "b \<file>", I18N_NOOP("A short option which takes an argument"), 0 }, - * { "c \<speed>", I18N_NOOP("As above but with a default value"), "9600" }, - * { "option1", I18N_NOOP("A long binary option, off by default"), 0 }, - * { "nooption2", I18N_NOOP("A long binary option, on by default"), 0 }, - * { ":", I18N_NOOP("Extra options:"), 0 }, - * { "option3 \<file>", I18N_NOOP("A long option which takes an argument"), 0 }, - * { "option4 \<speed>", I18N_NOOP("A long option which takes an argument, defaulting to 9600"), "9600" }, - * { "d", 0, 0 }, - * { "option5", I18N_NOOP("A long option which has a short option as alias"), 0 }, - * { "e", 0, 0 }, - * { "nooption6", I18N_NOOP("Another long option with an alias"), 0 }, - * { "f", 0, 0 }, - * { "option7 \<speed>", I18N_NOOP("'--option7 speed' is the same as '-f speed'"), 0 }, - * { "!option8 \<cmd>", I18N_NOOP("All options following this one will be treated as arguments"), 0 }, - * { "+file", I18N_NOOP("A required argument 'file'"), 0 }, - * { "+[arg1]", I18N_NOOP("An optional argument 'arg1'"), 0 }, - * { "!+command", I18N_NOOP("A required argument 'command', that can contain multiple words, even starting with '-'"), 0 }, - * { "", I18N_NOOP("Additional help text not associated with any particular option") 0 }, - * KCmdLineLastOption // End of options. - * }; - * \endcode - * - * The I18N_NOOP macro is used to indicate that these strings should be - * marked for translation. The actual translation is done by KCmdLineArgs. - * You can't use i18n() here because we are setting up a static data - * structure and can't do translations at compile time. - * - * Note that a program should define the options before any arguments. - * - * When a long option has a short option as an alias, a program should - * only test for the long option. - * - * With the above options a command line could look like: - * \code - * myapp -a -c 4800 --display localhost:0.0 --nooption5 -d /tmp/file - * \endcode - * - * Long binary options can be in the form 'option' and 'nooption'. - * A command line may contain the same binary option multiple times, - * the last option determines the outcome: - * \code - * myapp --nooption4 --option4 --nooption4 - * \endcode - * is the same as: - * \code - * myapp --nooption4 - * \endcode - * - * If an option value is provided multiple times, normally only the last - * value is used: - * \code - * myapp -c 1200 -c 2400 -c 4800 - * \endcode - * is usually the same as: - * \code - * myapp -c 4800 - * \endcode - * - * However, an application can choose to use all values specified as well. - * As an example of this, consider that you may wish to specify a - * number of directories to use: - * \code - * myapp -I /usr/include -I /opt/kde/include -I /usr/X11/include - * \endcode - * When an application does this it should mention this in the description - * of the option. To access these options, use getOptionList() - * - * Tips for end-users: - * - * @li Single char options like "-a -b -c" may be combined into "-abc" - * @li The option "--foo bar" may also be written "--foo=bar" - * @li The option "-P lp1" may also be written "-P=lp1" or "-Plp1" - * @li The option "--foo bar" may also be written "-foo bar" - * - * @author Waldo Bastian - * @version 0.0.4 - */ -class KDECORE_EXPORT KCmdLineArgs -{ - friend class KApplication; - friend class KUniqueApplication; - friend class TQPtrList<KCmdLineArgs>; -public: - // Static functions: - - /** - * Initialize class. - * - * This function should be called as the very first thing in - * your application. - * @param _argc As passed to @p main(...). - * @param _argv As passed to @p main(...). - * @param _appname The untranslated name of your application. This should - * match with @p argv[0]. - * @param programName A program name string to be used for display - * purposes. This string should be marked for - * translation. Example: I18N_NOOP("KEdit") - * @param _description A short description of what your application is about. - * @param _version A version. - * @param noKApp Set this true to not add commandline options for - * TQApplication / KApplication - * - * @since 3.2 - */ - static void init(int _argc, char **_argv, const char *_appname, - const char* programName, const char *_description, - const char *_version, bool noKApp = false); - /** - * @deprecated - * You should convert any calls to this method to use the one - * above, by adding in the program name to be used for display - * purposes. Do not forget to mark it for translation using I18N_NOOP. - */ - static void init(int _argc, char **_argv, - const char *_appname, const char *_description, - const char *_version, bool noKApp = false) KDE_DEPRECATED; - - /** - * Initialize class. - * - * This function should be called as the very first thing in - * your application. It uses KAboutData to replace some of the - * arguments that would otherwise be required. - * - * @param _argc As passed to @p main(...). - * @param _argv As passed to @p main(...). - * @param about A KAboutData object describing your program. - * @param noKApp Set this true to not add commandline options for - * TQApplication / KApplication - */ - static void init(int _argc, char **_argv, - const KAboutData *about, bool noKApp = false); - - /** - * Initialize Class - * - * This function should be called as the very first thing in your - * application. This method will rarely be used, since it doesn't - * provide any argument parsing. It does provide access to the - * KAboutData information. - * This method is exactly the same as calling - * init(0,0, const KAboutData *about, true). - * - * @param about the about data. - * \see KAboutData - */ - static void init(const KAboutData *about); - - /** - * Add options to your application. - * - * You must make sure that all possible options have been added before - * any class uses the command line arguments. - * - * The list of options should look like this: - * - * \code - * static KCmdLineOptions options[] = - * { - * { "option1 \<argument>", I18N_NOOP("Description 1"), "my_extra_arg" }, - * { "o", 0, 0 }, - * { "option2", I18N_NOOP("Description 2"), 0 }, - * { "nooption3", I18N_NOOP("Description 3"), 0 }, - * KCmdLineLastOption - * } - * \endcode - * - * @li "option1" is an option that requires an additional argument, - * but if one is not provided, it uses "my_extra_arg". - * @li "option2" is an option that can be turned on. The default is off. - * @li "option3" is an option that can be turned off. The default is on. - * @li "o" does not have a description. It is an alias for the option - * that follows. In this case "option2". - * @li "+file" specifies an argument. The '+' is removed. If your program - * doesn't specify that it can use arguments your program will abort - * when an argument is passed to it. Note that the reverse is not - * true. If required, you must check yourself the number of arguments - * specified by the user: - * \code - * KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - * if (args->count() == 0) KCmdLineArgs::usage(i18n("No file specified!")); - * \endcode - * - * In BNF: - * \code - * cmd = myapp [options] file - * options = (option)* - * option = --option1 \<argument> | - * (-o | --option2 | --nooption2) | - * ( --option3 | --nooption3 ) - * \endcode - * - * Instead of "--option3" one may also use "-option3" - * - * Usage examples: - * - * @li "myapp --option1 test" - * @li "myapp" (same as "myapp --option1 my_extra_arg") - * @li "myapp --option2" - * @li "myapp --nooption2" (same as "myapp", since it is off by default) - * @li "myapp -o" (same as "myapp --option2") - * @li "myapp --nooption3" - * @li "myapp --option3 (same as "myapp", since it is on by default) - * @li "myapp --option2 --nooption2" (same as "myapp", because it - * option2 is off by default, and the last usage applies) - * @li "myapp /tmp/file" - * - * @param options A list of options that your code supplies. - * @param name the name of the option, can be 0. - * @param id A name with which these options can be identified, can be 0. - * @param afterId The options are inserted after this set of options, can be 0. - */ - static void addCmdLineOptions( const KCmdLineOptions *options, - const char *name=0, const char *id = 0, - const char *afterId=0); - - /** - * Access parsed arguments. - * - * This function returns all command line arguments that your code - * handles. If unknown command-line arguments are encountered the program - * is aborted and usage information is shown. - * - * @param id The name of the options you are interested in, can be 0. - */ - static KCmdLineArgs *parsedArgs(const char *id=0); - - /** - * Get the CWD (Current Working Directory) associated with the - * current command line arguments. - * - * Typically this is needed in KUniqueApplication::newInstance() - * since the CWD of the process may be different from the CWD - * where the user started a second instance. - * @return the current working directory - **/ - static TQString cwd(); - - /** - * Get the appname according to argv[0]. - * @return the name of the application - **/ - static const char *appName(); - - /** - * Print the usage help to stdout and exit. - * - * @param id if 0, print all options. If id is set, only print the - * option specified by id. The id is the value set by - * addCmdLineOptions(). - **/ - static void usage(const char *id = 0); - - /** - * Print an error to stderr and the usage help to stdout and exit. - * @param error the error to print - **/ - static void usage(const TQString &error); - - /** - * Enable i18n to be able to print a translated error message. - * - * N.B.: This function leaks memory, therefore you are expected to exit - * afterwards (e.g., by calling usage()). - **/ - static void enable_i18n(); - - // Member functions: - - - /** - * Read out a string option. - * - * The option must have a corresponding KCmdLineOptions entry - * of the form: - * \code - * { "option \<argument>", I18N_NOOP("Description"), "default" } - * \endcode - * You cannot test for the presence of an alias - you must always - * test for the full option. - * - * @param option The name of the option without '-'. - * - * @return The value of the option. If the option was not - * present on the command line the default is returned. - * If the option was present more than the value of the - * last occurrence is used. - */ - TQCString getOption(const char *option) const; - - /** - * Read out all occurrences of a string option. - * - * The option must have a corresponding KCmdLineOptions entry - * of the form: - * \code - * { "option \<argument>", I18N_NOOP("Description"), "default" } - * \endcode - * You cannot test for the presence of an alias - you must always - * test for the full option. - * - * @param option The name of the option, without '-' or '-no'. - * - * @return A list of all option values. If no option was present - * on the command line, an empty list is returned. - */ - QCStringList getOptionList(const char *option) const; - - /** - * Read out a boolean option or check for the presence of string option. - * - * @param option The name of the option without '-' or '-no'. - * - * @return The value of the option. It will be true if the option - * was specifically turned on in the command line, or if the option - * is turned on by default (in the KCmdLineOptions list) and was - * not specifically turned off in the command line. Equivalently, - * it will be false if the option was specifically turned off in - * the command line, or if the option is turned off by default (in - * the KCmdLineOptions list) and was not specifically turned on in - * the command line. - */ - bool isSet(const char *option) const; - - /** - * Read the number of arguments that aren't options (but, - * for example, filenames). - * - * @return The number of arguments that aren't options - */ - int count() const; - - /** - * Read out an argument. - * - * @param n The argument to read. 0 is the first argument. - * count()-1 is the last argument. - * - * @return A @p const @p char @p * pointer to the n'th argument. - */ - const char *arg(int n) const; - - /** - * Read out an argument representing a URL. - * - * The argument can be - * @li an absolute filename - * @li a relative filename - * @li a URL - * - * @param n The argument to read. 0 is the first argument. - * count()-1 is the last argument. - * - * @return a URL representing the n'th argument. - */ - KURL url(int n) const; - - /** - * Used by url(). - * Made public for apps that don't use KCmdLineArgs - * @param urlArg the argument - * @return the url. - */ - static KURL makeURL( const char * urlArg ); - - /** - * Made public for apps that don't use KCmdLineArgs - * To be done before makeURL, to set the current working - * directory in case makeURL needs it. - * @param cwd the new working directory - */ - static void setCwd( char * cwd ) { mCwd = cwd; } - - /** - * Clear all options and arguments. - */ - void clear(); - - /** - * Reset all option definitions, i.e. cancel all addCmdLineOptions calls. - * Note that KApplication's options are removed too, you might want to - * call KApplication::addCmdLineOptions if you want them back. - * - * You usually don't want to call this method. - */ - static void reset(); - - /** - * Load arguments from a stream. - */ - static void loadAppArgs( TQDataStream &); - - /** - * Add standard option --tempfile - * @since 3.4 - */ - static void addTempFileOption(); - - // this avoids having to know the "id" used by addTempFileOption - // but this approach doesn't scale well, we can't have 50 standard options here... - /** - * @return true if --tempfile was set - * @since 3.4 - */ - static bool isTempFileSet(); - -protected: - /** - * @internal - * Constructor. - */ - KCmdLineArgs( const KCmdLineOptions *_options, const char *_name, - const char *_id); - - /** - * @internal use only. - * - * Use clear() if you want to free up some memory. - * - * Destructor. - */ - ~KCmdLineArgs(); - -private: - /** - * @internal - * - * Checks what to do with a single option - */ - static void findOption(const char *_opt, TQCString opt, int &i, bool enabled, bool &moreOptions); - - /** - * @internal - * - * Parse all arguments, verify correct syntax and put all arguments - * where they belong. - */ - static void parseAllArgs(); - - /** - * @internal for KApplication only: - * - * Return argc - */ - static int *qt_argc(); - - /** - * @internal for KApplication only: - * - * Return argv - */ - - static char ***qt_argv(); - - /** - * @internal - * - * Remove named options. - * - * @param id The name of the options to be removed. - */ - static void removeArgs(const char *id); - - /** - * @internal for KUniqueApplication only: - * - * Save all but the Qt and KDE arguments to a stream. - */ - static void saveAppArgs( TQDataStream &); - - /** - * @internal - * - * Set a boolean option - */ - void setOption(const TQCString &option, bool enabled); - - /** - * @internal - * - * Set a string option - */ - void setOption(const TQCString &option, const char *value); - - /** - * @internal - * - * Add an argument - */ - void addArgument(const char *argument); - - /** - * @internal - * - * Save to a stream. - */ - void save( TQDataStream &) const; - - /** - * @internal - * - * Restore from a stream. - */ - void load( TQDataStream &); - - /** - * @internal for KApplication only - * - * Initialize class. - * - * This function should be called as the very first thing in - * your application. - * @param argc As passed to @p main(...). - * @param argv As passed to @p main(...). - * @param appname The untranslated name of your application. This should - * match with @p argv[0]. - * - * This function makes KCmdLineArgs ignore all unknown options as well as - * all arguments. - */ - static void initIgnore(int _argc, char **_argv, const char *_appname); - - static void printQ(const TQString &msg); - - const KCmdLineOptions *options; - const char *name; - const char *id; - KCmdLineParsedOptions *parsedOptionList; - KCmdLineParsedArgs *parsedArgList; - bool isQt; - - static KCmdLineArgsList *argsList; // All options. - static const KAboutData *about; - - static int argc; // The original argc - static char **argv; // The original argv - static bool parsed; // Whether we have parsed the arguments since calling init - static bool ignoreUnknown; // Ignore unknown options and arguments - static char *mCwd; // Current working directory. Important for KUnqiueApp! - static bool parseArgs; - - KCmdLineArgsPrivate *d; -}; - -#endif - diff --git a/kdecore/kcompletion.cpp b/kdecore/kcompletion.cpp deleted file mode 100644 index 813b56027..000000000 --- a/kdecore/kcompletion.cpp +++ /dev/null @@ -1,892 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> - - 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. -*/ - - -#include <kapplication.h> -#include <kdebug.h> -#include <klocale.h> -#include <knotifyclient.h> -#include <kglobal.h> - -#include <tqptrvector.h> - -#include "kcompletion.h" -#include "kcompletion_private.h" - - -class KCompletionPrivate -{ -public: - // not a member to avoid #including kcompletion_private.h from kcompletion.h - // list used for nextMatch() and previousMatch() - KCompletionMatchesWrapper matches; -}; - -KCompletion::KCompletion() -{ - d = new KCompletionPrivate; - - myCompletionMode = KGlobalSettings::completionMode(); - myTreeRoot = new KCompTreeNode; - myBeep = true; - myIgnoreCase = false; - myHasMultipleMatches = false; - myRotationIndex = 0; - setOrder( Insertion ); -} - -KCompletion::~KCompletion() -{ - delete d; - delete myTreeRoot; -} - -void KCompletion::setOrder( CompOrder order ) -{ - myOrder = order; - d->matches.setSorting( order == Weighted ); -} - -void KCompletion::setIgnoreCase( bool ignoreCase ) -{ - myIgnoreCase = ignoreCase; -} - -void KCompletion::setItems( const TQStringList& items ) -{ - clear(); - insertItems( items ); -} - - -void KCompletion::insertItems( const TQStringList& items ) -{ - bool weighted = (myOrder == Weighted); - TQStringList::ConstIterator it; - if ( weighted ) { // determine weight - for ( it = items.begin(); it != items.end(); ++it ) - addWeightedItem( *it ); - } - else { - for ( it = items.begin(); it != items.end(); ++it ) - addItem( *it, 0 ); - } -} - -TQStringList KCompletion::items() const -{ - KCompletionMatchesWrapper list; // unsorted - bool addWeight = (myOrder == Weighted); - extractStringsFromNode( myTreeRoot, TQString::null, &list, addWeight ); - - return list.list(); -} - -bool KCompletion::isEmpty() const -{ - return (myTreeRoot->childrenCount() == 0); -} - -void KCompletion::addItem( const TQString& item ) -{ - d->matches.clear(); - myRotationIndex = 0; - myLastString = TQString::null; - - addItem( item, 0 ); -} - -void KCompletion::addItem( const TQString& item, uint weight ) -{ - if ( item.isEmpty() ) - return; - - KCompTreeNode *node = myTreeRoot; - uint len = item.length(); - - bool sorted = (myOrder == Sorted); - bool weighted = ((myOrder == Weighted) && weight > 1); - - // knowing the weight of an item, we simply add this weight to all of its - // nodes. - - for ( uint i = 0; i < len; i++ ) { - node = node->insert( item.tqat(i), sorted ); - if ( weighted ) - node->confirm( weight -1 ); // node->insert() sets weighting to 1 - } - - // add 0x0-item as delimiter with evtl. weight - node = node->insert( 0x0, true ); - if ( weighted ) - node->confirm( weight -1 ); -// qDebug("*** added: %s (%i)", item.latin1(), node->weight()); -} - -void KCompletion::addWeightedItem( const TQString& item ) -{ - if ( myOrder != Weighted ) { - addItem( item, 0 ); - return; - } - - uint len = item.length(); - uint weight = 0; - - // find out the weighting of this item (appended to the string as ":num") - int index = item.findRev(':'); - if ( index > 0 ) { - bool ok; - weight = item.mid( index + 1 ).toUInt( &ok ); - if ( !ok ) - weight = 0; - - len = index; // only insert until the ':' - } - - addItem( item.left( len ), weight ); - return; -} - - -void KCompletion::removeItem( const TQString& item ) -{ - d->matches.clear(); - myRotationIndex = 0; - myLastString = TQString::null; - - myTreeRoot->remove( item ); -} - - -void KCompletion::clear() -{ - d->matches.clear(); - myRotationIndex = 0; - myLastString = TQString::null; - - delete myTreeRoot; - myTreeRoot = new KCompTreeNode; -} - - -TQString KCompletion::makeCompletion( const TQString& string ) -{ - if ( myCompletionMode == KGlobalSettings::CompletionNone ) - return TQString::null; - - //kdDebug(0) << "KCompletion: completing: " << string << endl; - - d->matches.clear(); - myRotationIndex = 0; - myHasMultipleMatches = false; - myLastMatch = myCurrentMatch; - - // in Shell-completion-mode, emit all matches when we get the same - // complete-string twice - if ( myCompletionMode == KGlobalSettings::CompletionShell && - string == myLastString ) { - // Don't use d->matches since calling postProcessMatches() - // on d->matches here would interfere with call to - // postProcessMatch() during rotation - - findAllCompletions( string, &d->matches, myHasMultipleMatches ); - TQStringList l = d->matches.list(); - postProcessMatches( &l ); - emit matches( l ); - - if ( l.isEmpty() ) - doBeep( NoMatch ); - - return TQString::null; - } - - TQString completion; - // in case-insensitive popup mode, we search all completions at once - if ( myCompletionMode == KGlobalSettings::CompletionPopup || - myCompletionMode == KGlobalSettings::CompletionPopupAuto ) { - findAllCompletions( string, &d->matches, myHasMultipleMatches ); - if ( !d->matches.isEmpty() ) - completion = d->matches.first(); - } - else - completion = findCompletion( string ); - - if ( myHasMultipleMatches ) - emit multipleMatches(); - - myLastString = string; - myCurrentMatch = completion; - - postProcessMatch( &completion ); - - if ( !string.isEmpty() ) { // only emit match when string is not empty - //kdDebug(0) << "KCompletion: Match: " << completion << endl; - emit match( completion ); - } - - if ( completion.isNull() ) - doBeep( NoMatch ); - - return completion; -} - - -TQStringList KCompletion::substringCompletion( const TQString& string ) const -{ - // get all items in the tree, possibly in sorted order - bool sorted = (myOrder == Weighted); - KCompletionMatchesWrapper allItems( sorted ); - extractStringsFromNode( myTreeRoot, TQString::null, &allItems, false ); - - TQStringList list = allItems.list(); - - // subStringMatches is invoked manually, via a shortcut, so we should - // beep here, if necessary. - if ( list.isEmpty() ) { - doBeep( NoMatch ); - return list; - } - - if ( string.isEmpty() ) { // shortcut - postProcessMatches( &list ); - return list; - } - - TQStringList matches; - TQStringList::ConstIterator it = list.begin(); - - for( ; it != list.end(); ++it ) { - TQString item = *it; - if ( item.find( string, 0, false ) != -1 ) { // always case insensitive - matches.append( item ); - } - } - - postProcessMatches( &matches ); - - if ( matches.isEmpty() ) - doBeep( NoMatch ); - - return matches; -} - - -void KCompletion::setCompletionMode( KGlobalSettings::Completion mode ) -{ - myCompletionMode = mode; -} - -TQStringList KCompletion::allMatches() -{ - // Don't use d->matches since calling postProcessMatches() - // on d->matches here would interfere with call to - // postProcessMatch() during rotation - KCompletionMatchesWrapper matches( myOrder == Weighted ); - bool dummy; - findAllCompletions( myLastString, &matches, dummy ); - TQStringList l = matches.list(); - postProcessMatches( &l ); - return l; -} - -KCompletionMatches KCompletion::allWeightedMatches() -{ - // Don't use d->matches since calling postProcessMatches() - // on d->matches here would interfere with call to - // postProcessMatch() during rotation - KCompletionMatchesWrapper matches( myOrder == Weighted ); - bool dummy; - findAllCompletions( myLastString, &matches, dummy ); - KCompletionMatches ret( matches ); - postProcessMatches( &ret ); - return ret; -} - -TQStringList KCompletion::allMatches( const TQString &string ) -{ - KCompletionMatchesWrapper matches( myOrder == Weighted ); - bool dummy; - findAllCompletions( string, &matches, dummy ); - TQStringList l = matches.list(); - postProcessMatches( &l ); - return l; -} - -KCompletionMatches KCompletion::allWeightedMatches( const TQString &string ) -{ - KCompletionMatchesWrapper matches( myOrder == Weighted ); - bool dummy; - findAllCompletions( string, &matches, dummy ); - KCompletionMatches ret( matches ); - postProcessMatches( &ret ); - return ret; -} - -///////////////////////////////////////////////////// -///////////////// tree operations /////////////////// - - -TQString KCompletion::nextMatch() -{ - TQString completion; - myLastMatch = myCurrentMatch; - - if ( d->matches.isEmpty() ) { - findAllCompletions( myLastString, &d->matches, myHasMultipleMatches ); - completion = d->matches.first(); - myCurrentMatch = completion; - myRotationIndex = 0; - postProcessMatch( &completion ); - emit match( completion ); - return completion; - } - - TQStringList matches = d->matches.list(); - myLastMatch = matches[ myRotationIndex++ ]; - - if ( myRotationIndex == matches.count() -1 ) - doBeep( Rotation ); // indicate last matching item -> rotating - - else if ( myRotationIndex == matches.count() ) - myRotationIndex = 0; - - completion = matches[ myRotationIndex ]; - myCurrentMatch = completion; - postProcessMatch( &completion ); - emit match( completion ); - return completion; -} - - - -TQString KCompletion::previousMatch() -{ - TQString completion; - myLastMatch = myCurrentMatch; - - if ( d->matches.isEmpty() ) { - findAllCompletions( myLastString, &d->matches, myHasMultipleMatches ); - completion = d->matches.last(); - myCurrentMatch = completion; - myRotationIndex = 0; - postProcessMatch( &completion ); - emit match( completion ); - return completion; - } - - TQStringList matches = d->matches.list(); - myLastMatch = matches[ myRotationIndex ]; - if ( myRotationIndex == 1 ) - doBeep( Rotation ); // indicate first item -> rotating - - else if ( myRotationIndex == 0 ) - myRotationIndex = matches.count(); - - myRotationIndex--; - - completion = matches[ myRotationIndex ]; - myCurrentMatch = completion; - postProcessMatch( &completion ); - emit match( completion ); - return completion; -} - - - -// tries to complete "string" from the tree-root -TQString KCompletion::findCompletion( const TQString& string ) -{ - TQChar ch; - TQString completion; - const KCompTreeNode *node = myTreeRoot; - - // start at the tree-root and try to find the search-string - for( uint i = 0; i < string.length(); i++ ) { - ch = string.tqat( i ); - node = node->find( ch ); - - if ( node ) - completion += ch; - else - return TQString::null; // no completion - } - - // Now we have the last node of the to be completed string. - // Follow it as long as it has exactly one child (= longest possible - // completion) - - while ( node->childrenCount() == 1 ) { - node = node->firstChild(); - if ( !node->isNull() ) - completion += *node; - } - // if multiple matches and auto-completion mode - // -> find the first complete match - if ( node && node->childrenCount() > 1 ) { - myHasMultipleMatches = true; - - if ( myCompletionMode == KGlobalSettings::CompletionAuto ) { - myRotationIndex = 1; - if (myOrder != Weighted) { - while ( (node = node->firstChild()) ) { - if ( !node->isNull() ) - completion += *node; - else - break; - } - } - else { - // don't just find the "first" match, but the one with the - // highest priority - - const KCompTreeNode* temp_node = 0L; - while(1) { - int count = node->childrenCount(); - temp_node = node->firstChild(); - uint weight = temp_node->weight(); - const KCompTreeNode* hit = temp_node; - for( int i = 1; i < count; i++ ) { - temp_node = node->tqchildAt(i); - if( temp_node->weight() > weight ) { - hit = temp_node; - weight = hit->weight(); - } - } - // 0x0 has the highest priority -> we have the best match - if ( hit->isNull() ) - break; - - node = hit; - completion += *node; - } - } - } - - else - doBeep( PartialMatch ); // partial match -> beep - } - - return completion; -} - - -void KCompletion::findAllCompletions(const TQString& string, - KCompletionMatchesWrapper *matches, - bool& hasMultipleMatches) const -{ - //kdDebug(0) << "*** finding all completions for " << string << endl; - - if ( string.isEmpty() ) - return; - - if ( myIgnoreCase ) { // case insensitive completion - extractStringsFromNodeCI( myTreeRoot, TQString::null, string, matches ); - hasMultipleMatches = (matches->count() > 1); - return; - } - - TQChar ch; - TQString completion; - const KCompTreeNode *node = myTreeRoot; - - // start at the tree-root and try to find the search-string - for( uint i = 0; i < string.length(); i++ ) { - ch = string.tqat( i ); - node = node->find( ch ); - - if ( node ) - completion += ch; - else - return; // no completion -> return empty list - } - - // Now we have the last node of the to be completed string. - // Follow it as long as it has exactly one child (= longest possible - // completion) - - while ( node->childrenCount() == 1 ) { - node = node->firstChild(); - if ( !node->isNull() ) - completion += *node; - // kdDebug() << completion << node->latin1(); - } - - - // there is just one single match) - if ( node->childrenCount() == 0 ) - matches->append( node->weight(), completion ); - - else { - // node has more than one child - // -> recursively find all remaining completions - hasMultipleMatches = true; - extractStringsFromNode( node, completion, matches ); - } -} - - -void KCompletion::extractStringsFromNode( const KCompTreeNode *node, - const TQString& beginning, - KCompletionMatchesWrapper *matches, - bool addWeight ) const -{ - if ( !node || !matches ) - return; - - // kDebug() << "Beginning: " << beginning << endl; - const KCompTreeChildren *list = node->children(); - TQString string; - TQString w; - - // loop thru all children - for ( KCompTreeNode *cur = list->begin(); cur ; cur = cur->next) { - string = beginning; - node = cur; - if ( !node->isNull() ) - string += *node; - - while ( node && node->childrenCount() == 1 ) { - node = node->firstChild(); - if ( node->isNull() ) - break; - string += *node; - } - - if ( node && node->isNull() ) { // we found a leaf - if ( addWeight ) { - // add ":num" to the string to store the weighting - string += ':'; - w.setNum( node->weight() ); - string.append( w ); - } - matches->append( node->weight(), string ); - } - - // recursively find all other strings. - if ( node && node->childrenCount() > 1 ) - extractStringsFromNode( node, string, matches, addWeight ); - } -} - -void KCompletion::extractStringsFromNodeCI( const KCompTreeNode *node, - const TQString& beginning, - const TQString& restString, - KCompletionMatchesWrapper *matches ) const -{ - if ( restString.isEmpty() ) { - extractStringsFromNode( node, beginning, matches, false /*noweight*/ ); - return; - } - - TQChar ch1 = restString.tqat(0); - TQString newRest = restString.mid(1); - KCompTreeNode *child1, *child2; - - child1 = node->find( ch1 ); // the correct match - if ( child1 ) - extractStringsFromNodeCI( child1, beginning + *child1, newRest, - matches ); - - // append the case insensitive matches, if available - if ( ch1.isLetter() ) { - // find out if we have to lower or upper it. Is there a better way? - TQChar ch2 = ch1.lower(); - if ( ch1 == ch2 ) - ch2 = ch1.upper(); - if ( ch1 != ch2 ) { - child2 = node->find( ch2 ); - if ( child2 ) - extractStringsFromNodeCI( child2, beginning + *child2, newRest, - matches ); - } - } -} - -void KCompletion::doBeep( BeepMode mode ) const -{ - if ( !myBeep ) - return; - - TQString text, event; - - switch ( mode ) { - case Rotation: - event = TQString::tqfromLatin1("Textcompletion: rotation"); - text = i18n("You reached the end of the list\nof matching items.\n"); - break; - case PartialMatch: - if ( myCompletionMode == KGlobalSettings::CompletionShell || - myCompletionMode == KGlobalSettings::CompletionMan ) { - event = TQString::tqfromLatin1("Textcompletion: partial match"); - text = i18n("The completion is ambiguous, more than one\nmatch is available.\n"); - } - break; - case NoMatch: - if ( myCompletionMode == KGlobalSettings::CompletionShell ) { - event = TQString::tqfromLatin1("Textcompletion: no match"); - text = i18n("There is no matching item available.\n"); - } - break; - } - - if ( !text.isEmpty() ) - KNotifyClient::event( event, text ); -} - - -///////////////////////////////// -///////// - - -// Implements the tree. Every node is a TQChar and has a list of children, which -// are Nodes as well. -// TQChar( 0x0 ) is used as the delimiter of a string; the last child of each -// inserted string is 0x0. - -KCompTreeNode::~KCompTreeNode() -{ - // delete all children - KCompTreeNode *cur = myChildren.begin(); - while (cur) { - KCompTreeNode * next = cur->next; - delete myChildren.remove(cur); - cur = next; - } -} - - -// Adds a child-node "ch" to this node. If such a node is already existant, -// it will not be created. Returns the new/existing node. -KCompTreeNode * KCompTreeNode::insert( const TQChar& ch, bool sorted ) -{ - KCompTreeNode *child = find( ch ); - if ( !child ) { - child = new KCompTreeNode( ch ); - - // FIXME, first (slow) sorted insertion implementation - if ( sorted ) { - KCompTreeNode * prev = 0; - KCompTreeNode * cur = myChildren.begin(); - while ( cur ) { - if ( ch > *cur ) { - prev = cur; - cur = cur->next; - } else - break; - } - if (prev) - myChildren.insert( prev, child ); - else - myChildren.prepend(child); - } - - else - myChildren.append( child ); - } - - // implicit weighting: the more often an item is inserted, the higher - // priority it gets. - child->confirm(); - - return child; -} - - -// Iteratively removes a string from the tree. The nicer recursive -// version apparently was a little memory hungry (see #56757) -void KCompTreeNode::remove( const TQString& str ) -{ - TQString string = str; - string += TQChar(0x0); - - TQPtrVector<KCompTreeNode> deletables( string.length() + 1 ); - - KCompTreeNode *child = 0L; - KCompTreeNode *parent = this; - deletables.insert( 0, parent ); - - uint i = 0; - for ( ; i < string.length(); i++ ) - { - child = parent->find( string.tqat( i ) ); - if ( child ) - deletables.insert( i + 1, child ); - else - break; - - parent = child; - } - - for ( ; i >= 1; i-- ) - { - parent = deletables.tqat( i - 1 ); - child = deletables.tqat( i ); - if ( child->myChildren.count() == 0 ) - delete parent->myChildren.remove( child ); - } -} - -TQStringList KCompletionMatchesWrapper::list() const -{ - if ( sortedList && dirty ) { - sortedList->sort(); - dirty = false; - - stringList.clear(); - - // high weight == sorted last -> reverse the sorting here - TQValueListConstIterator<KSortableItem<TQString> > it; - for ( it = sortedList->begin(); it != sortedList->end(); ++it ) - stringList.prepend( (*it).value() ); - } - - return stringList; -} - -KCompletionMatches::KCompletionMatches( bool sort_P ) - : _sorting( sort_P ) -{ -} - -KCompletionMatches::KCompletionMatches( const KCompletionMatchesWrapper& matches ) - : _sorting( matches.sorting()) -{ - if( matches.sortedList != 0L ) - KCompletionMatchesList::operator=( *matches.sortedList ); - else { - TQStringList l = matches.list(); - for( TQStringList::ConstIterator it = l.begin(); - it != l.end(); - ++it ) - prepend( KSortableItem<TQString, int>( 1, *it ) ); - } -} - -KCompletionMatches::~KCompletionMatches() -{ -} - -TQStringList KCompletionMatches::list( bool sort_P ) const -{ - if( _sorting && sort_P ) - const_cast< KCompletionMatches* >( this )->sort(); - TQStringList stringList; - // high weight == sorted last -> reverse the sorting here - for ( ConstIterator it = begin(); it != end(); ++it ) - stringList.prepend( (*it).value() ); - return stringList; -} - -void KCompletionMatches::removeDuplicates() -{ - Iterator it1, it2; - for ( it1 = begin(); it1 != end(); ++it1 ) { - for ( (it2 = it1), ++it2; it2 != end();) { - if( (*it1).value() == (*it2).value()) { - // use the max height - (*it1).first = kMax( (*it1).index(), (*it2).index()); - it2 = remove( it2 ); - continue; - } - ++it2; - } - } -} - -void KCompTreeNodeList::append(KCompTreeNode *item) -{ - m_count++; - if (!last) { - last = item; - last->next = 0; - first = item; - return; - } - last->next = item; - item->next = 0; - last = item; -} - -void KCompTreeNodeList::prepend(KCompTreeNode *item) -{ - m_count++; - if (!last) { - last = item; - last->next = 0; - first = item; - return; - } - item->next = first; - first = item; -} - -void KCompTreeNodeList::insert(KCompTreeNode *after, KCompTreeNode *item) -{ - if (!after) { - append(item); - return; - } - - m_count++; - - item->next = after->next; - after->next = item; - - if (after == last) - last = item; -} - -KCompTreeNode *KCompTreeNodeList::remove(KCompTreeNode *item) -{ - if (!first || !item) - return 0; - KCompTreeNode *cur = 0; - - if (item == first) - first = first->next; - else { - cur = first; - while (cur && cur->next != item) cur = cur->next; - if (!cur) - return 0; - cur->next = item->next; - } - if (item == last) - last = cur; - m_count--; - return item; -} - -KCompTreeNode *KCompTreeNodeList::tqat(uint index) const -{ - KCompTreeNode *cur = first; - while (index-- && cur) cur = cur->next; - return cur; -} - -KZoneAllocator KCompTreeNode::alloc(8192); - -void KCompletion::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KCompletionBase::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kcompletion.moc" diff --git a/kdecore/kcompletion.h b/kdecore/kcompletion.h deleted file mode 100644 index f6c8f0f82..000000000 --- a/kdecore/kcompletion.h +++ /dev/null @@ -1,1010 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999,2000 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 KCOMPLETION_H -#define KCOMPLETION_H - -#include <tqmap.h> -#include <tqptrlist.h> -#include <tqobject.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqguardedptr.h> - -#include "kdelibs_export.h" -#include <kglobalsettings.h> -#include <ksortablevaluelist.h> -#include <kshortcut.h> - -class KCompTreeNode; -class KCompletionPrivate; -class KCompletionBasePrivate; -class KCompletionMatchesWrapper; -class KCompletionMatches; -class TQPopupMenu; - -/** - * @short A generic class for completing QStrings - * - * This class offers easy use of "auto-completion", "manual-completion" or - * "shell completion" on TQString objects. A common use is completing filenames - * or URLs (see KURLCompletion()). - * But it is not limited to URL-completion -- everything should be completable! - * The user should be able to complete email-addresses, telephone-numbers, - * commands, SQL queries, ... - * Every time your program knows what the user can type into an edit-field, you - * should offer completion. With KCompletion, this is very easy, and if you are - * using a line edit widget ( KLineEdit), it is even more easy. - * Basically, you tell a KCompletion object what strings should be completable - * and whenever completion should be invoked, you call makeCompletion(). - * KLineEdit and (an editable) KComboBox even do this automatically for you. - * - * KCompletion offers the completed string via the signal match() and - * all matching strings (when the result is ambiguous) via the method - * allMatches(). - * - * Notice: auto-completion, shell completion and manual completion work - * slightly differently: - * - * @li auto-completion always returns a complete item as match. - * When more than one matching items are available, it will deliver just - * the first (depending on sorting order) item. Iterating over all matches - * is possible via nextMatch() and previousMatch(). - * - * @li popup-completion works in the same way, the only difference being that - * the completed items are not put into the edit-widget, but into a - * separate popup-box. - * - * @li manual completion works the same way as auto-completion, the - * subtle difference is, that it isn't invoked automatically while the user - * is typing, but only when the user presses a special key. The difference - * of manual and auto-completion is therefore only visible in UI classes, - * KCompletion needs to know whether to deliver partial matches - * (shell completion) or whole matches (auto/manual completion), therefore - * KGlobalSettings::CompletionMan and - * KGlobalSettings::CompletionAuto have the exact same effect in - * KCompletion. - * - * @li shell completion works like how shells complete filenames: - * when multiple matches are available, the longest possible string of all - * matches is returned (i.e. only a partial item). - * Iterating over all matching items (complete, not partial) is possible - * via nextMatch() and previousMatch(). - * - * You don't have to worry much about that though, KCompletion handles - * that for you, according to the setting setCompletionMode(). - * The default setting is globally configured by the user and read - * from KGlobalSettings::completionMode(). - * - * A short example: - * \code - * KCompletion completion; - * completion.setOrder( KCompletion::Sorted ); - * completion.addItem( "pfeiffer@kde.org" ); - * completion.addItem( "coolo@kde.org" ); - * completion.addItem( "carpdjih@sp.zrz.tu-berlin.de" ); - * completion.addItem( "carp@cs.tu-berlin.de" ); - * - * cout << completion.makeCompletion( "ca" ).latin1() << endl; - * \endcode - * - * In shell-completion-mode, this will be "carp"; in auto-completion- - * mode it will be "carp\@cs.tu-berlin.de", as that is alphabetically - * smaller. - * If setOrder was set to Insertion, "carpdjih\@sp.zrz.tu-berlin.de" - * would be completed in auto-completion-mode, as that was inserted before - * "carp\@cs.tu-berlin.de". - * - * You can dynamically update the completable items by removing and adding them - * whenever you want. - * For advanced usage, you could even use multiple KCompletion objects. E.g. - * imagine an editor like kwrite with multiple open files. You could store - * items of each file in a different KCompletion object, so that you know (and - * tell the user) where a completion comes from. - * - * Note: KCompletion does not work with strings that contain 0x0 characters - * (tqunicode nul), as this is used internally as a delimiter. - * - * You may inherit from KCompletion and override makeCompletion() in - * special cases (like reading directories/urls and then supplying the - * contents to KCompletion, as KURLCompletion does), but generally, this is - * not necessary. - * - * - * @author Carsten Pfeiffer <pfeiffer@kde.org> - */ -class KDECORE_EXPORT KCompletion : public TQObject -{ - Q_ENUMS( CompOrder ) - Q_PROPERTY( CompOrder order READ order WRITE setOrder ) - Q_PROPERTY( bool ignoreCase READ ignoreCase WRITE setIgnoreCase ) - Q_PROPERTY( TQStringList items READ items WRITE setItems ) - Q_OBJECT - -public: - /** - * Constants that represent the order in which KCompletion performs - * completion-lookups. - */ - enum CompOrder { Sorted, ///< Use alphabetically sorted order - Insertion, ///< Use order of insertion - Weighted ///< Use weighted order - }; - - /** - * Constructor, nothing special here :) - */ - KCompletion(); - - // FIXME: copy constructor, assignment operator... - - /** - * Destructor, nothing special here, either. - */ - virtual ~KCompletion(); - - /** - * Attempts to find an item in the list of available completions, - * that begins with @p string. Will either return the first matching item - * (if there is more than one match) or TQString::null, if no match was - * found. - * - * In the latter case, a sound will be issued, depending on - * isSoundsEnabled(). - * If a match was found, it will also be emitted via the signal - * match(). - * - * If this is called twice or more often with the same string while no - * items were added or removed in the meantime, all available completions - * will be emitted via the signal #matches(). - * This happens only in shell-completion-mode. - * - * @param string the string to complete - * @return the matching item, or TQString::null if there is no matching - * item. - * @see slotMakeCompletion - * @see substringCompletion - */ - virtual TQString makeCompletion( const TQString& string ); - - /** - * Returns a list of all completion items that contain the given @p string. - * @param string the string to complete - * @return a list of items which all contain @p text as a substring, - * i.e. not necessarily at the beginning. - * - * @see makeCompletion - */ - TQStringList substringCompletion( const TQString& string ) const; - - /** - * Returns the next item from the matching-items-list. - * When reaching the beginning, the list is rotated so it will return the - * last match and a sound is issued (depending on isSoundsEnabled()). - * @return the next item from the matching-items-list. - * When there is no match, TQString::null is returned and - * a sound is be issued. - * @see slotPreviousMatch - */ - TQString previousMatch(); - - /** - * Returns the next item from the matching-items-list. - * When reaching the last item, the list is rotated, so it will return - * the first match and a sound is issued (depending on - * isSoundsEnabled()). - * @return the next item from the matching-items-list. When there is no - * match, TQString::null is returned and a sound is issued - * @see slotNextMatch - */ - TQString nextMatch(); - - /** - * Returns the last match. Might be useful if you need to check whether - * a completion is different from the last one. - * @return the last match. TQString::null is returned when there is no - * last match. - */ - virtual const TQString& lastMatch() const { return myLastMatch; } - - /** - * Returns a list of all items inserted into KCompletion. This is useful - * if you need to save the state of a KCompletion object and restore it - * later. - * - * Important note: when order() == Weighted, then every item in the - * stringlist has its weight appended, delimited by a colon. E.g. an item - * "www.kde.org" might look like "www.kde.org:4", where 4 is the weight. - * - * This is necessary so that you can save the items along with its - * weighting on disk and load them back with setItems(), restoring its - * weight as well. If you really don't want the appended weightings, call - * setOrder( KCompletion::Insertion ) - * before calling items(). - * - * @return a list of all items - * @see setItems - */ - TQStringList items() const; - - /** - * Returns true when the completion object contains no entries. - */ - bool isEmpty() const; - - /** - * Sets the completion mode to Auto/Manual, Shell or None. - * If you don't set the mode explicitly, the global default value - * KGlobalSettings::completionMode() is used. - * KGlobalSettings::CompletionNone disables completion. - * @param mode the completion mode - * @see completionMode - * @see KGlobalSettings::completionMode - */ - virtual void setCompletionMode( KGlobalSettings::Completion mode ); - - /** - * Return the current completion mode. - * May be different from KGlobalSettings::completionMode(), if you - * explicitly called setCompletionMode(). - * @return the current completion mode - * @see setCompletionMode - */ - KGlobalSettings::Completion completionMode() const { - return myCompletionMode; - } - - /** - * KCompletion offers three different ways in which it offers its items: - * @li in the order of insertion - * @li sorted alphabetically - * @li weighted - * - * Choosing weighted makes KCompletion perform an implicit weighting based - * on how often an item is inserted. Imagine a web browser with a location - * bar, where the user enters URLs. The more often a URL is entered, the - * higher priority it gets. - * - * Note: Setting the order to sorted only affects new inserted items, - * already existing items will stay in the current order. So you probably - * want to call setOrder( Sorted ) before inserting items, when you want - * everything sorted. - * - * Default is insertion order. - * @param order the new order - * @see order - */ - virtual void setOrder( CompOrder order ); - - /** - * Returns the completion order. - * @return the current completion order. - * @see setOrder - */ - CompOrder order() const { return myOrder; } - - /** - * Setting this to true makes KCompletion behave case insensitively. - * E.g. makeCompletion( "CA" ); might return "carp\@cs.tu-berlin.de". - * Default is false (case sensitive). - * @param ignoreCase true to ignore the case - * @see ignoreCase - */ - virtual void setIgnoreCase( bool ignoreCase ); - - /** - * Return whether KCompletion acts case insensitively or not. - * Default is false (case sensitive). - * @return true if the case will be ignored - * @see setIgnoreCase - */ - bool ignoreCase() const { return myIgnoreCase; } - - /** - * Returns a list of all items matching the last completed string. - * Might take some time, when you have LOTS of items. - * @return a list of all matches for the last completed string. - * @see substringCompletion - */ - TQStringList allMatches(); - - /** - * Returns a list of all items matching @p string. - * @param string the string to match - * @return the list of all matches - */ - TQStringList allMatches( const TQString& string ); - - /** - * Returns a list of all items matching the last completed string. - * Might take some time, when you have LOTS of items. - * The matches are returned as KCompletionMatches, which also - * keeps the weight of the matches, allowing - * you to modify some matches or merge them with matches - * from another call to allWeightedMatches(), and sort the matches - * after that in order to have the matches ordered correctly. - * - * @return a list of all completion matches - * @see substringCompletion - */ - KCompletionMatches allWeightedMatches(); - - /** - * Returns a list of all items matching @p string. - * @param string the string to match - * @return a list of all matches - */ - KCompletionMatches allWeightedMatches( const TQString& string ); - - /** - * Enables/disables playing a sound when - * @li makeCompletion() can't find a match - * @li there is a partial completion (= multiple matches in - * Shell-completion mode) - * @li nextMatch() or previousMatch() hit the last possible - * match -> rotation - * - * For playing the sounds, KNotifyClient() is used. - * - * @param enable true to enable sounds - * @see isSoundsEnabled - */ - virtual void setEnableSounds( bool enable ) { myBeep = enable; } - - /** - * Tells you whether KCompletion will play sounds on certain occasions. - * Default is enabled. - * @return true if sounds are enabled - * @see enableSounds - * @see disableSounds - */ - bool isSoundsEnabled() const { return myBeep; } - - /** - * Returns true when more than one match is found. - * @return true if there are more than one match - * @see multipleMatches - */ - bool hasMultipleMatches() const { return myHasMultipleMatches; } - -#ifndef KDE_NO_COMPAT - /** - * @deprecated - * @see setEnableSounds - */ - void enableSounds() { myBeep = true; } - - /** - * @deprecated - * @see setEnableSounds - */ - void disableSounds() { myBeep = false; } -#endif - -public slots: - /** - * Attempts to complete "string" and emits the completion via match(). - * Same as makeCompletion() (just as a slot). - * @param string the string to complete - * @see makeCompletion - */ - void slotMakeCompletion( const TQString& string ) { - (void) makeCompletion( string ); - } - - /** - * Searches the previous matching item and emits it via match(). - * Same as previousMatch() (just as a slot). - * @see previousMatch - */ - void slotPreviousMatch() { - (void) previousMatch(); - } - - /** - * Searches the next matching item and emits it via match(). - * Same as nextMatch() (just as a slot). - * @see nextMatch - */ - void slotNextMatch() { - (void) nextMatch(); - } - - // FIXME ###: KDE4: unify the nomenclature. We have insertItems, addItem, - // setItems... - /** - * Inserts @p items into the list of possible completions. - * Does the same as setItems(), but does not call clear() before. - * @param items the items to insert - */ - void insertItems( const TQStringList& items ); - - /** - * Sets the list of items available for completion. Removes all previous - * items. - * - * Notice: when order() == Weighted, then the weighting is looked up for - * every item in the stringlist. Every item should have ":number" appended, - * where number is an unsigned integer, specifying the weighting. - * - * If you don't like this, call - * setOrder( KCompletion::Insertion ) - * before calling setItems(). - * - * @param list the list of items that are available for completion - * @see items - */ - virtual void setItems( const TQStringList& list); - - /** - * Adds an item to the list of available completions. - * Resets the current item-state ( previousMatch() and nextMatch() - * won't work anymore). - * @param item the item to add - */ - void addItem( const TQString& item); - - /** - * Adds an item to the list of available completions. - * Resets the current item-state ( previousMatch() and nextMatch() - * won't work anymore). - * - * Sets the weighting of the item to @p weight or adds it to the current - * weighting if the item is already available. The weight has to be greater - * than 1 to take effect (default weight is 1). - * @param item the item to add - * @param weight the weight of the item, default is 1 - */ - void addItem( const TQString& item, uint weight ); - - /** - * Removes an item from the list of available completions. - * Resets the current item-state ( previousMatch() and nextMatch() - * won't work anymore). - * @param item the item to remove - */ - void removeItem( const TQString& item); - - /** - * Removes all inserted items. - */ - virtual void clear(); - - -signals: - /** - * The matching item. Will be emitted by makeCompletion(), - * previousMatch() or nextMatch(). May be TQString::null if there - * is no matching item. - * @param item the match, or TQString::null if there is none - */ - void match( const TQString& item); - - /** - * All matching items. Will be emitted by makeCompletion() in shell- - * completion-mode, when the same string is passed to makeCompletion twice - * or more often. - * @param matchlist the list of matches - */ - void matches( const TQStringList& matchlist); - - /** - * This signal is emitted, when calling makeCompletion() and more than - * one matching item is found. - * @see hasMultipleMatches - */ - void multipleMatches(); - -protected: - /** - * This method is called after a completion is found and before the - * matching string is emitted. You can override this method to modify the - * string that will be emitted. - * This is necessary e.g. in KURLCompletion(), where files with spaces - * in their names are shown escaped ("filename\ with\ spaces"), but stored - * unescaped inside KCompletion. - * Never delete that pointer! - * - * Default implementation does nothing. - * @param match the match to process - * @see postProcessMatches - */ - virtual void postProcessMatch( TQString *match ) const { Q_UNUSED(match) } - - /** - * This method is called before a list of all available completions is - * emitted via #matches. You can override this method to modify the - * found items before match() or #matches are emitted. - * Never delete that pointer! - * - * Default implementation does nothing. - * @param matches the matches to process - * @see postProcessMatch - */ - virtual void postProcessMatches( TQStringList * matches ) const { Q_UNUSED(matches)} - - /** - * This method is called before a list of all available completions is - * emitted via #matches. You can override this method to modify the - * found items before #match() or #matches() are emitted. - * Never delete that pointer! - * - * Default implementation does nothing. - * @param matches the matches to process - * @see postProcessMatch - */ - virtual void postProcessMatches( KCompletionMatches * matches ) const {Q_UNUSED(matches)} - -private: - void addWeightedItem( const TQString& ); - TQString findCompletion( const TQString& string ); - void findAllCompletions( const TQString&, - KCompletionMatchesWrapper *matches, - bool& hasMultipleMatches ) const; - - void extractStringsFromNode( const KCompTreeNode *, - const TQString& beginning, - KCompletionMatchesWrapper *matches, - bool addWeight = false ) const; - void extractStringsFromNodeCI( const KCompTreeNode *, - const TQString& beginning, - const TQString& restString, - KCompletionMatchesWrapper *matches) const; - - enum BeepMode { NoMatch, PartialMatch, Rotation }; - void doBeep( BeepMode ) const; - - KGlobalSettings::Completion myCompletionMode; - - CompOrder myOrder; - TQString myLastString; - TQString myLastMatch; - TQString myCurrentMatch; - KCompTreeNode * myTreeRoot; - TQStringList myRotations; - bool myBeep; - bool myIgnoreCase; - bool myHasMultipleMatches; - uint myRotationIndex; - - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KCompletionPrivate *d; -}; - -// some more helper stuff -typedef KSortableValueList<TQString> KCompletionMatchesList; -class KCompletionMatchesPrivate; - -/** - * This structure is returned by KCompletion::allWeightedMatches . - * It also keeps the weight of the matches, allowing - * you to modify some matches or merge them with matches - * from another call to allWeightedMatches(), and sort the matches - * after that in order to have the matches ordered correctly - * - * Example (a simplified example of what Konqueror's completion does): - * \code - * KCompletionMatches matches = completion->allWeightedMatches( location ); - * if( !location.startsWith( "www." )) - matches += completion->allWeightedmatches( "www." + location" ); - * matches.removeDuplicates(); - * TQStringList list = matches.list(); - * \endcode - * - * @short List for keeping matches returned from KCompletion - */ -class KDECORE_EXPORT KCompletionMatches : public KCompletionMatchesList -{ -public: - KCompletionMatches( bool sort ); - /** - * @internal - */ - KCompletionMatches( const KCompletionMatchesWrapper& matches ); - ~KCompletionMatches(); - /** - * Removes duplicate matches. Needed only when you merged several matches - * results and there's a possibility of duplicates. - */ - void removeDuplicates(); - /** - * Returns the matches as a TQStringList. - * @param sort if false, the matches won't be sorted before the conversion, - * use only if you're sure the sorting is not needed - * @return the list of matches - */ - TQStringList list( bool sort = true ) const; - /** - * If sorting() returns false, the matches aren't sorted by their weight, - * even if true is passed to list(). - * @return true if the matches won't be sorted - */ - bool sorting() const { - return _sorting; - } -private: - bool _sorting; - KCompletionMatchesPrivate* d; -}; - -/** - * An abstract base class for adding a completion feature - * into widgets. - * - * This is a convenience class that provides the basic functions - * needed to add text completion support into widgets. All that - * is required is an implementation for the pure virtual function - * setCompletedText. Refer to KLineEdit or KComboBox - * to see how easily such support can be added using this as a base - * class. - * - * @short An abstract class for adding text completion support to widgets. - * @author Dawit Alemayehu <adawit@kde.org> - */ -class KDECORE_EXPORT KCompletionBase -{ -public: - /** - * Constants that represent the items whose short-cut - * key-binding is programmable. The default key-bindings - * for these items are defined in KStdAccel. - */ - enum KeyBindingType { - /** - * Text completion (by default Ctrl-E). - */ - TextCompletion, - /** - * Switch to previous completion (by default Ctrl-Up). - */ - PrevCompletionMatch, - /** - * Switch to next completion (by default Ctrl-Down). - */ - NextCompletionMatch, - /** - * Substring completion (by default Ctrl-T). - */ - SubstringCompletion - }; - - - // Map for the key binding types mentioned above. - typedef TQMap<KeyBindingType, KShortcut> KeyBindingMap; - - /** - * Default constructor. - */ - KCompletionBase(); - - /** - * Destructor. - */ - virtual ~KCompletionBase(); - - /** - * Returns a pointer to the current completion object. - * - * If the completion object does not exist, it is automatically created and - * by default handles all the completion signals internally unless @p hsig - * is set to false. It is also automatically destroyed when the destructor - * is called. You can change this default behavior using the - * @ref setAutoDeleteCompletionObject and @ref setHandleSignals member - * functions. - * - * See also @ref compObj. - * - * @param hsig if true, handles completion signals internally. - * @return a pointer the completion object. - */ - KCompletion* completionObject( bool hsig = true ); - - /** - * Sets up the completion object to be used. - * - * This method assigns the completion object and sets it up to automatically - * handle the completion and rotation signals internally. You should use - * this function if you want to share one completion object among your - * widgets or need to use a customized completion object. - * - * The object assigned through this method is not deleted when this object's - * destructor is invoked unless you explicitly call @ref setAutoDeleteCompletionObject - * after calling this method. Be sure to set the bool argument to false, if - * you want to handle the completion signals yourself. - * - * @param compObj a KCompletion() or a derived child object. - * @param hsig if true, handles completion signals internally. - */ - virtual void setCompletionObject( KCompletion* compObj, bool hsig = true ); - - /** - * Enables this object to handle completion and rotation - * events internally. - * - * This function simply assigns a boolean value that - * indicates whether it should handle rotation and - * completion events or not. Note that this does not - * stop the object from emitting signals when these - * events occur. - * - * @param handle if true, handle completion & rotation internally. - */ - virtual void setHandleSignals( bool handle ); - - /** - * Returns true if the completion object is deleted - * upon this widget's destruction. - * - * See setCompletionObject() and enableCompletion() - * for details. - * - * @return true if the completion object will be deleted - * automatically - */ - bool isCompletionObjectAutoDeleted() const { - return m_delegate ? m_delegate->isCompletionObjectAutoDeleted() : m_bAutoDelCompObj; - } - - /** - * Sets the completion object when this widget's destructor - * is called. - * - * If the argument is set to true, the completion object - * is deleted when this widget's destructor is called. - * - * @param autoDelete if true, delete completion object on destruction. - */ - void setAutoDeleteCompletionObject( bool autoDelete ) { - if ( m_delegate ) - m_delegate->setAutoDeleteCompletionObject( autoDelete ); - else - m_bAutoDelCompObj = autoDelete; - } - - /** - * Sets the widget's ability to emit text completion and - * rotation signals. - * - * Invoking this function with @p enable set to @p false will - * cause the completion & rotation signals not to be emitted. - * However, unlike setting the completion object to @p NULL - * using setCompletionObject, disabling the emition of - * the signals through this method does not affect the current - * completion object. - * - * There is no need to invoke this function by default. When a - * completion object is created through completionObject or - * setCompletionObject, these signals are set to emit - * automatically. Also note that disabling this signals will not - * necessarily interfere with the objects ability to handle these - * events internally. See setHandleSignals. - * - * @param enable if false, disables the emition of completion & rotation signals. - */ - void setEnableSignals( bool enable ) { - if ( m_delegate ) - m_delegate->setEnableSignals( enable ); - else - m_bEmitSignals = enable; - } - - /** - * Returns true if the object handles the signals. - * - * @return true if this signals are handled internally. - */ - bool handleSignals() const { return m_delegate ? m_delegate->handleSignals() : m_bHandleSignals; } - - /** - * Returns true if the object emits the signals. - * - * @return true if signals are emitted - */ - bool emitSignals() const { return m_delegate ? m_delegate->emitSignals() : m_bEmitSignals; } - - /** - * Sets the type of completion to be used. - * - * The completion modes supported are those defined in - * KGlobalSettings(). See below. - * - * @param mode Completion type: - * @li CompletionNone: Disables completion feature. - * @li CompletionAuto: Attempts to find a match & - * fills-in the remaining text. - * @li CompletionMan: Acts the same as the above - * except the action has to be - * manually triggered through - * pre-defined completion key. - * @li CompletionShell: Mimics the completion feature - * found in typical *nix shell - * environments. - * @li CompletionPopup: Shows all available completions at once, - * in a listbox popping up. - */ - virtual void setCompletionMode( KGlobalSettings::Completion mode ); - - /** - * Returns the current completion mode. - * - * The return values are of type KGlobalSettings::Completion. - * See setCompletionMode() for details. - * - * @return the completion mode. - */ - KGlobalSettings::Completion completionMode() const { - return m_delegate ? m_delegate->completionMode() : m_iCompletionMode; - } - - /** - * Sets the key-binding to be used for manual text - * completion, text rotation in a history list as - * well as a completion list. - * - * - * When the keys set by this function are pressed, a - * signal defined by the inheriting widget will be activated. - * If the default value or 0 is specified by the second - * parameter, then the key-binding as defined in the global - * setting should be used. This method returns false value - * for @p key is negative or the supplied key-binding conflicts - * with the ones set for one of the other features. - * - * NOTE: To use a modifier key (Shift, Ctrl, Alt) as part of - * the key-binding simply simply @p sum up the values of the - * modifier and the actual key. For example, to use CTRL+E as - * a key binding for one of the items, you would simply supply - * @p "Qt::CtrlButton + Qt::Key_E" as the second argument to this - * function. - * - * @param item the feature whose key-binding needs to be set: - * @li TextCompletion the manual completion key-binding. - * @li PrevCompletionMatch the previous match key for multiple completion. - * @li NextCompletionMatch the next match key for for multiple completion. - * @li SubstringCompletion the key for substring completion - * @param key key-binding used to rotate down in a list. - * @return true if key-binding can successfully be set. - * @see getKeyBinding - */ - bool setKeyBinding( KeyBindingType item , const KShortcut& key ); - - /** - * Returns the key-binding used for the specified item. - * - * This methods returns the key-binding used to activate - * the feature feature given by @p item. If the binding - * contains modifier key(s), the SUM of the modifier key - * and the actual key code are returned. - * - * @param item the item to check - * @return the key-binding used for the feature given by @p item. - * @see setKeyBinding - */ - const KShortcut& getKeyBinding( KeyBindingType item ) const { - return m_delegate ? m_delegate->getKeyBinding( item ) : m_keyMap[ item ]; - } - - /** - * Sets this object to use global values for key-bindings. - * - * This method changes the values of the key bindings for - * rotation and completion features to the default values - * provided in KGlobalSettings. - * - * NOTE: By default inheriting widgets should uses the - * global key-bindings so that there will be no need to - * call this method. - */ - void useGlobalKeyBindings(); - - /** - * A pure virtual function that must be implemented by - * all inheriting classes. - * - * This function is intended to allow external completion - * implementations to set completed text appropriately. It - * is mostly relevant when the completion mode is set to - * CompletionAuto and CompletionManual modes. See - * KCompletionBase::setCompletedText. - * Does nothing in CompletionPopup mode, as all available - * matches will be shown in the popup. - * - * @param text the completed text to be set in the widget. - */ - virtual void setCompletedText( const TQString& text ) = 0; - - /** - * A pure virtual function that must be implemented by - * all inheriting classes. - * @param items the list of completed items - */ - virtual void setCompletedItems( const TQStringList& items ) = 0; - - /** - * Returns a pointer to the completion object. - * - * This method is only different from completionObject() - * in that it does not create a new KCompletion object even if - * the internal pointer is @p NULL. Use this method to get the - * pointer to a completion object when inheriting so that you - * won't inadvertently create it!! - * - * @return the completion object or NULL if one does not exist. - */ - KCompletion* compObj() const { return m_delegate ? m_delegate->compObj() : (KCompletion*) m_pCompObj; } - -protected: - /** - * Returns a key-binding map. - * - * This method is the same as getKeyBinding() except it - * returns the whole keymap containing the key-bindings. - * - * @return the key-binding used for the feature given by @p item. - */ - KeyBindingMap getKeyBindings() const { return m_delegate ? m_delegate->getKeyBindings() : m_keyMap; } - - /** - * Sets or removes the delegation object. If a delegation object is - * set, all function calls will be forwarded to the delegation object. - * @param delegate the delegation object, or 0 to remove it - */ - void setDelegate( KCompletionBase *delegate ); - - /** - * Returns the delegation object. - * @return the delegation object, or 0 if there is none - * @see setDelegate() - */ - KCompletionBase *delegate() const { return m_delegate; } - -private: - // This method simply sets the autodelete boolean for - // the completion object, the emit signals and handle - // signals internally flags to the provided values. - void setup( bool, bool, bool ); - - // Flag that determined whether the completion object - // should be deleted when this object is destroyed. - bool m_bAutoDelCompObj; - // Determines whether this widget handles completion signals - // internally or not - bool m_bHandleSignals; - // Determines whether this widget fires rotation signals - bool m_bEmitSignals; - // Stores the completion mode locally. - KGlobalSettings::Completion m_iCompletionMode; - // Pointer to Completion object. - TQGuardedPtr<KCompletion> m_pCompObj; - // Keybindings - KeyBindingMap m_keyMap; - // we may act as a proxy to another KCompletionBase object - KCompletionBase *m_delegate; - - // BCI -protected: - virtual void virtual_hook( int id, void* data ); -private: - KCompletionBasePrivate *d; -}; - -#endif // KCOMPLETION_H diff --git a/kdecore/kcompletion_private.h b/kdecore/kcompletion_private.h deleted file mode 100644 index 1ce613faa..000000000 --- a/kdecore/kcompletion_private.h +++ /dev/null @@ -1,216 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 KCOMPLETION_PRIVATE_H -#define KCOMPLETION_PRIVATE_H - -#include <tqstring.h> -#include <ksortablevaluelist.h> - -class KCompTreeNode; - -#include <kallocator.h> - -/** - * @internal - */ -class KDECORE_EXPORT KCompTreeNodeList -{ -public: - KCompTreeNodeList() : first(0), last(0), m_count(0) {} - KCompTreeNode *begin() const { return first; } - KCompTreeNode *end() const { return last; } - - KCompTreeNode *tqat(uint index) const; - void append(KCompTreeNode *item); - void prepend(KCompTreeNode *item); - void insert(KCompTreeNode *after, KCompTreeNode *item); - KCompTreeNode *remove(KCompTreeNode *item); - uint count() const { return m_count; } - -private: - KCompTreeNode *first, *last; - uint m_count; -}; - -typedef KCompTreeNodeList KCompTreeChildren; - -/** - * A helper class for KCompletion. Implements a tree of TQChar. - * - * The tree looks like this (containing the items "kde", "kde-ui", - * "kde-core" and "pfeiffer". Every item is delimited with TQChar( 0x0 ) - * - * some_root_node - * / \ - * k p - * | | - * d f - * | | - * e e - * /| | - * 0x0 - i - * / \ | - * u c f - * | | | - * i o f - * | | | - * 0x0 r e - * | | - * e r - * | | - * 0x0 0x0 - * - * @author Carsten Pfeiffer <pfeiffer@kde.org> - * @internal - */ -class KDECORE_EXPORT KCompTreeNode : public TQChar -{ -public: - KCompTreeNode() : TQChar(), myWeight(0) {} - KCompTreeNode( const TQChar& ch, uint weight = 0 ) - : TQChar( ch ), - myWeight( weight ) {} - ~KCompTreeNode(); - - void * operator new( size_t s ) { - return alloc.allocate( s ); - } - void operator delete( void * s ) { - alloc.deallocate( s ); - } - - // Returns a child of this node matching ch, if available. - // Otherwise, returns 0L - inline KCompTreeNode * find( const TQChar& ch ) const { - KCompTreeNode * cur = myChildren.begin(); - while (cur && (*cur != ch)) cur = cur->next; - return cur; - } - KCompTreeNode * insert( const TQChar&, bool sorted ); - void remove( const TQString& ); - - inline int childrenCount() const { return myChildren.count(); } - - // weighting - inline void confirm() { myWeight++; } - inline void confirm(uint w) { myWeight += w; } - inline void decline() { myWeight--; } - inline uint weight() const { return myWeight; } - - inline const KCompTreeChildren * children() const { - return &myChildren; - } - inline const KCompTreeNode * tqchildAt(int index) const { - return myChildren.tqat(index); - } - inline const KCompTreeNode * firstChild() const { - return myChildren.begin(); - } - inline const KCompTreeNode * lastChild() const { - return myChildren.end(); - } - - /* We want to handle a list of KCompTreeNodes on our own, to not - need to use TQValueList<>. And to make it even more fast we don't - use an accessor, but just a public member. */ - KCompTreeNode *next; -private: - uint myWeight; - KCompTreeNodeList myChildren; - static KZoneAllocator alloc; -}; - - - -// some more helper stuff -typedef KSortableValueList<TQString> KCompletionMatchesList; - -/** - * @internal - */ -class KDECORE_EXPORT KCompletionMatchesWrapper -{ -public: - KCompletionMatchesWrapper( bool sort = false ) - : sortedList( sort ? new KCompletionMatchesList : 0L ), - dirty( false ) - {} - ~KCompletionMatchesWrapper() { - delete sortedList; - } - - void setSorting( bool sort ) { - if ( sort && !sortedList ) - sortedList = new KCompletionMatchesList; - else if ( !sort ) { - delete sortedList; - sortedList = 0L; - } - stringList.clear(); - dirty = false; - } - - bool sorting() const { - return sortedList != 0L; - } - - void append( int i, const TQString& string ) { - if ( sortedList ) - sortedList->insert( i, string ); - else - stringList.append( string ); - dirty = true; - } - - void clear() { - if ( sortedList ) - sortedList->clear(); - stringList.clear(); - dirty = false; - } - - uint count() const { - if ( sortedList ) - return sortedList->count(); - return stringList.count(); - } - - bool isEmpty() const { - return count() == 0; - } - - TQString first() const { - return list().first(); - } - - TQString last() const { - return list().last(); - } - - TQStringList list() const; - - mutable TQStringList stringList; - KCompletionMatchesList *sortedList; - mutable bool dirty; -}; - - -#endif // KCOMPLETION_PRIVATE_H diff --git a/kdecore/kcompletionbase.cpp b/kdecore/kcompletionbase.cpp deleted file mode 100644 index 9e7f6d746..000000000 --- a/kdecore/kcompletionbase.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (c) 2000 Dawit Alemayehu <adawit@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) 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. -*/ - -#include <tqobject.h> - -#include <kcompletion.h> - -KCompletionBase::KCompletionBase() -{ - m_delegate = 0L; - // Assign the default completion type to use. - m_iCompletionMode = KGlobalSettings::completionMode(); - - // Initialize all key-bindings to 0 by default so that - // the event filter will use the global settings. - useGlobalKeyBindings(); - - // By default we initialize everything to false. - // All the variables would be setup properly when - // the appropriate member functions are called. - setup( false, false, false ); -} - -KCompletionBase::~KCompletionBase() -{ - if( m_bAutoDelCompObj && m_pCompObj ) - { - delete m_pCompObj; - } -} - -void KCompletionBase::setDelegate( KCompletionBase *delegate ) -{ - m_delegate = delegate; - - if ( m_delegate ) { - m_delegate->m_bAutoDelCompObj = m_bAutoDelCompObj; - m_delegate->m_bHandleSignals = m_bHandleSignals; - m_delegate->m_bEmitSignals = m_bEmitSignals; - m_delegate->m_iCompletionMode = m_iCompletionMode; - m_delegate->m_keyMap = m_keyMap; - } -} - -KCompletion* KCompletionBase::completionObject( bool hsig ) -{ - if ( m_delegate ) - return m_delegate->completionObject( hsig ); - - if ( !m_pCompObj ) - { - setCompletionObject( new KCompletion(), hsig ); - m_bAutoDelCompObj = true; - } - return m_pCompObj; -} - -void KCompletionBase::setCompletionObject( KCompletion* compObj, bool hsig ) -{ - if ( m_delegate ) { - m_delegate->setCompletionObject( compObj, hsig ); - return; - } - - if ( m_bAutoDelCompObj && compObj != m_pCompObj ) - delete m_pCompObj; - - m_pCompObj = compObj; - - // We emit rotation and completion signals - // if completion object is not NULL. - setup( false, hsig, !m_pCompObj.isNull() ); -} - -// BC: Inline this function and possibly rename it to setHandleEvents??? (DA) -void KCompletionBase::setHandleSignals( bool handle ) -{ - if ( m_delegate ) - m_delegate->setHandleSignals( handle ); - else - m_bHandleSignals = handle; -} - -void KCompletionBase::setCompletionMode( KGlobalSettings::Completion mode ) -{ - if ( m_delegate ) { - m_delegate->setCompletionMode( mode ); - return; - } - - m_iCompletionMode = mode; - // Always sync up KCompletion mode with ours as long as we - // are performing completions. - if( m_pCompObj && m_iCompletionMode != KGlobalSettings::CompletionNone ) - m_pCompObj->setCompletionMode( m_iCompletionMode ); -} - -bool KCompletionBase::setKeyBinding( KeyBindingType item, const KShortcut& cut ) -{ - if ( m_delegate ) - return m_delegate->setKeyBinding( item, cut ); - - - if( !cut.isNull() ) - { - for( KeyBindingMap::Iterator it = m_keyMap.begin(); it != m_keyMap.end(); ++it ) - if( it.data() == cut ) return false; - } - m_keyMap.replace( item, cut ); - return true; -} - -void KCompletionBase::useGlobalKeyBindings() -{ - if ( m_delegate ) { - m_delegate->useGlobalKeyBindings(); - return; - } - - m_keyMap.clear(); - m_keyMap.insert( TextCompletion, 0 ); - m_keyMap.insert( PrevCompletionMatch, 0 ); - m_keyMap.insert( NextCompletionMatch, 0 ); - m_keyMap.insert( SubstringCompletion, 0 ); -} - -void KCompletionBase::setup( bool autodel, bool hsig, bool esig ) -{ - if ( m_delegate ) { - m_delegate->setup( autodel, hsig, esig ); - return; - } - - m_bAutoDelCompObj = autodel; - m_bHandleSignals = hsig; - m_bEmitSignals = esig; -} diff --git a/kdecore/kconfig.cpp b/kdecore/kconfig.cpp deleted file mode 100644 index 709e39de3..000000000 --- a/kdecore/kconfig.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (C) 1997-1999 Matthias Kalle Dalheimer (kalle@kde.org) - - 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. -*/ - -// $Id$ - -#include <config.h> - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include <stdlib.h> -#include <unistd.h> - -#include <tqfileinfo.h> - -#include <kapplication.h> -#include "kconfigbackend.h" - -#include "kconfig.h" -#include "kglobal.h" -#include "kstandarddirs.h" -#include "kstaticdeleter.h" -#include <tqtimer.h> - -KConfig::KConfig( const TQString& fileName, - bool bReadOnly, bool bUseKderc, const char *resType ) - : KConfigBase(), bGroupImmutable(false), bFileImmutable(false), - bForceGlobal(false) -{ - // set the object's read-only status. - setReadOnly(bReadOnly); - - // for right now we will hardcode that we are using the INI - // back end driver. In the future this should be converted over to - // a object factory of some sorts. - KConfigINIBackEnd *aBackEnd = new KConfigINIBackEnd(this, - fileName, - resType, - bUseKderc); - - // set the object's back end pointer to this new backend - backEnd = aBackEnd; - - // read initial information off disk - reparseConfiguration(); - - // we let KStandardDirs add custom user config files. It will do - // this only once. So only the first call ever to this constructor - // will anything else than return here We have to reparse here as - // configuration files may appear after customized directories have - // been added. and the info they contain needs to be inserted into the - // config object. - // Since this makes only sense for config directories, addCustomized - // returns true only if new config directories appeared. - if (KGlobal::dirs()->addCustomized(this)) - reparseConfiguration(); -} - -KConfig::KConfig(KConfigBackEnd *aBackEnd, bool bReadOnly) - : bGroupImmutable(false), bFileImmutable(false), - bForceGlobal(false) -{ - setReadOnly(bReadOnly); - backEnd = aBackEnd; - reparseConfiguration(); -} - -KConfig::~KConfig() -{ - sync(); - - delete backEnd; -} - -void KConfig::rollback(bool bDeep) -{ - KConfigBase::rollback(bDeep); - - if (!bDeep) - return; // object's bDeep flag is set in KConfigBase method - - // clear any dirty flags that entries might have set - for (KEntryMapIterator aIt = aEntryMap.begin(); - aIt != aEntryMap.end(); ++aIt) - (*aIt).bDirty = false; -} - -TQStringList KConfig::groupList() const -{ - TQStringList retList; - - KEntryMapConstIterator aIt = aEntryMap.begin(); - KEntryMapConstIterator aEnd = aEntryMap.end(); - for (; aIt != aEnd; ++aIt) - { - while(aIt.key().mKey.isEmpty()) - { - TQCString group = aIt.key().mGroup; - ++aIt; - while (true) - { - if (aIt == aEnd) - return retList; // done - - if (aIt.key().mKey.isEmpty()) - break; // Group is empty, next group - - if (!aIt.key().bDefault && !(*aIt).bDeleted) - { - if (group != "$Version") // Special case! - retList.append(TQString::fromUtf8(group)); - break; // Group is non-empty, added, next group - } - ++aIt; - } - } - } - - return retList; -} - -TQMap<TQString, TQString> KConfig::entryMap(const TQString &pGroup) const -{ - TQCString pGroup_utf = pGroup.utf8(); - KEntryKey groupKey( pGroup_utf, 0 ); - TQMap<TQString, TQString> tmpMap; - - KEntryMapConstIterator aIt = aEntryMap.find(groupKey); - if (aIt == aEntryMap.end()) - return tmpMap; - ++aIt; // advance past special group entry marker - for (; aIt.key().mGroup == pGroup_utf && aIt != aEntryMap.end(); ++aIt) - { - // Leave the default values out && leave deleted entries out - if (!aIt.key().bDefault && !(*aIt).bDeleted) - tmpMap.insert(TQString::fromUtf8(aIt.key().mKey), TQString::fromUtf8((*aIt).mValue.data(), (*aIt).mValue.length())); - } - - return tmpMap; -} - -void KConfig::reparseConfiguration() -{ - // Don't lose pending changes - if (!isReadOnly() && backEnd && bDirty) - backEnd->sync(); - - aEntryMap.clear(); - - // add the "default group" marker to the map - KEntryKey groupKey("<default>", 0); - aEntryMap.insert(groupKey, KEntry()); - - bFileImmutable = false; - parseConfigFiles(); - bFileImmutable = bReadOnly; -} - -KEntryMap KConfig::internalEntryMap(const TQString &pGroup) const -{ - TQCString pGroup_utf = pGroup.utf8(); - KEntry aEntry; - KEntryMapConstIterator aIt; - KEntryKey aKey(pGroup_utf, 0); - KEntryMap tmpEntryMap; - - aIt = aEntryMap.find(aKey); - if (aIt == aEntryMap.end()) { - // the special group key is not in the map, - // so it must be an invalid group. Return - // an empty map. - return tmpEntryMap; - } - // we now have a pointer to the nodes we want to copy. - for (; aIt.key().mGroup == pGroup_utf && aIt != aEntryMap.end(); ++aIt) - { - tmpEntryMap.insert(aIt.key(), *aIt); - } - - return tmpEntryMap; -} - -void KConfig::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup) -{ - if (bFileImmutable && !_key.bDefault) - return; - - // check to see if the special group key is present, - // and if not, put it in. - if (_checkGroup) - { - KEntryKey groupKey( _key.mGroup, 0); - KEntry &entry = aEntryMap[groupKey]; - bGroupImmutable = entry.bImmutable; - } - if (bGroupImmutable && !_key.bDefault) - return; - - // now either add or replace the data - KEntry &entry = aEntryMap[_key]; - bool immutable = entry.bImmutable; - if (immutable && !_key.bDefault) - return; - - entry = _data; - entry.bImmutable |= immutable; - entry.bGlobal |= bForceGlobal; // force to kdeglobals - - if (_key.bDefault) - { - // We have added the data as default value, - // add it as normal value as well. - KEntryKey key(_key); - key.bDefault = false; - aEntryMap[key] = _data; - } -} - -KEntry KConfig::lookupData(const KEntryKey &_key) const -{ - KEntryMapConstIterator aIt = aEntryMap.find(_key); - if (aIt != aEntryMap.end()) - { - const KEntry &entry = *aIt; - if (entry.bDeleted) - return KEntry(); - else - return entry; - } - else { - return KEntry(); - } -} - -bool KConfig::internalHasGroup(const TQCString &group) const -{ - KEntryKey groupKey( group, 0); - - KEntryMapConstIterator aIt = aEntryMap.find(groupKey); - KEntryMapConstIterator aEnd = aEntryMap.end(); - - if (aIt == aEnd) - return false; - ++aIt; - for(; (aIt != aEnd); ++aIt) - { - if (aIt.key().mKey.isEmpty()) - break; - - if (!aIt.key().bDefault && !(*aIt).bDeleted) - return true; - } - return false; -} - -void KConfig::setFileWriteMode(int mode) -{ - backEnd->setFileWriteMode(mode); -} - -KLockFile::Ptr KConfig::lockFile(bool bGlobal) -{ - KConfigINIBackEnd *aBackEnd = dynamic_cast<KConfigINIBackEnd*>(backEnd); - if (!aBackEnd) return 0; - return aBackEnd->lockFile(bGlobal); -} - -void KConfig::checkUpdate(const TQString &id, const TQString &updateFile) -{ - TQString oldGroup = group(); - setGroup("$Version"); - TQString cfg_id = updateFile+":"+id; - TQStringList ids = readListEntry("update_info"); - if (!ids.contains(cfg_id)) - { - TQStringList args; - args << "--check" << updateFile; - KApplication::tdeinitExecWait("kconf_update", args); - reparseConfiguration(); - } - setGroup(oldGroup); -} - -KConfig* KConfig::copyTo(const TQString &file, KConfig *config) const -{ - if (!config) - config = new KConfig(TQString::null, false, false); - config->backEnd->changeFileName(file, "config", false); - config->setReadOnly(false); - config->bFileImmutable = false; - config->backEnd->mConfigState = ReadWrite; - - TQStringList groups = groupList(); - for(TQStringList::ConstIterator it = groups.begin(); - it != groups.end(); ++it) - { - TQMap<TQString, TQString> map = entryMap(*it); - config->setGroup(*it); - for (TQMap<TQString,TQString>::Iterator it2 = map.begin(); - it2 != map.end(); ++it2) - { - config->writeEntry(it2.key(), it2.data()); - } - - } - return config; -} - -void KConfig::virtual_hook( int id, void* data ) -{ KConfigBase::virtual_hook( id, data ); } - -static KStaticDeleter< TQValueList<KSharedConfig*> > sd; -TQValueList<KSharedConfig*> *KSharedConfig::s_list = 0; - -KSharedConfig::Ptr KSharedConfig::openConfig(const TQString& fileName, bool readOnly, bool useKDEGlobals ) -{ - if (s_list) - { - for(TQValueList<KSharedConfig*>::ConstIterator it = s_list->begin(); - it != s_list->end(); ++it) - { - if ((*it)->backEnd->fileName() == fileName && - (*it)->bReadOnly == readOnly && - (*it)->backEnd->useKDEGlobals == useKDEGlobals ) - return (*it); - } - } - return new KSharedConfig(fileName, readOnly, useKDEGlobals); -} - -KSharedConfig::KSharedConfig( const TQString& fileName, bool readonly, bool usekdeglobals) - : KConfig(fileName, readonly, usekdeglobals) -{ - if (!s_list) - { - sd.setObject(s_list, new TQValueList<KSharedConfig*>); - } - - s_list->append(this); -} - -KSharedConfig::~KSharedConfig() -{ - if ( s_list ) - s_list->remove(this); -} - -#include "kconfig.moc" diff --git a/kdecore/kconfig.h b/kdecore/kconfig.h deleted file mode 100644 index 19ff09314..000000000 --- a/kdecore/kconfig.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> - - 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 _KCONFIG_H -#define _KCONFIG_H - -class TQTimer; - -#include <tqvaluelist.h> - -#include "kconfigbase.h" -#include "klockfile.h" - -class KConfigPrivate; - -/** -* Access KDE Configuration entries. -* -* This class implements KDE's default configuration system. -* -* @author Kalle Dalheimer <kalle@kde.org>, Preston Brown <pbrown@kde.org> -* @see KGlobal::config(), KConfigBase, KSimpleConfig -* @short KDE Configuration Management class -*/ -class KDECORE_EXPORT KConfig : public KConfigBase -{ - Q_OBJECT - -public: - - /** - * Constructs a KConfig object. - * - * @param fileName A file to parse in addition to the - * system-wide file(s). If it is not provided, only global - * KDE configuration data will be read (depending on the value of - * @p bUseKDEGlobals). - * @param bReadOnly Set the config object's read-only status. Note that the - * object will automatically become read-only if either the user does not have - * write permission to @p fileName or if no file was specified. - * @param bUseKDEGlobals Toggle reading the global KDE configuration file. - * @param resType the place to look in (config, data, etc) See KStandardDirs. - */ - KConfig( const TQString& fileName = TQString::null, - bool bReadOnly = false, bool bUseKDEGlobals = true, const char *resType="config"); - - KConfig(KConfigBackEnd *backEnd, bool bReadOnly = false); - - /** - * Destructs the KConfig object. - * - * Writes back any dirty configuration entries, and destroys - * dynamically created objects. - */ - virtual ~KConfig(); - - /** - * Clears all entries out of the @p dirtyEntryMap, so the - * values will not be written to disk on a later call to - * sync(). - * - * @param bDeep If true, the dirty map is actually emptied. - * otherwise, the config object's global dirty flag is set to - * false, but the dirty entries remain in the dirty entry - * map. - * - * @see KConfigBase::rollback - */ - virtual void rollback(bool bDeep = true); - - - /** - * Returns a list of groups that are known. - * @return a list of of groups - */ - virtual TQStringList groupList() const; - - /** - * Returns a map (tree) of entries for all entries in a particular - * group. - * - * Only the actual entry string is returned, none of the - * other internal data should be included. - * - * @param pGroup A group to get keys from. - * @return A map of entries in the group specified, indexed by key. - * The returned map may be empty if the group is not found. - */ - virtual TQMap<TQString, TQString> entryMap(const TQString &pGroup) const; - - /** - * Clears all internal data structures and then reread - * configuration information from disk. - */ - virtual void reparseConfiguration(); - - /** - * Set the file mode for newly created files. - * - * @param mode the mode for new files as described in chmod(2) - * @see man:chmod(2) for a description of @p mode - */ - void setFileWriteMode(int mode); - - /** - * Forces all following write-operations being performed on kdeglobals, - * independent of the bGlobal flag in writeEntry(). - * @param force true to force writing in kdeglobals - * @see forceGlobal - */ - void setForceGlobal( bool force ) { bForceGlobal = force; } - - /** - * Returns true if all entries are being written into kdeglobals. - * @return true if all entries are being written into kdeglobals - * @see setForceGlobal - */ - bool forceGlobal() const { return bForceGlobal; } - - /** - * Checks whether the config file contains the update @p id - * as contained in @p updateFile. If not, it runs kconf_update - * to update the config file. - * - * If you install config update files with critical fixes - * you may wish to use this method to verify that a critical - * update has indeed been performed to catch the case where - * a user restores an old config file from backup that has - * not been updated yet. - * @param id the update to check - * @param updateFile the file containing the update - * @since 3.1 - */ - void checkUpdate(const TQString &id, const TQString &updateFile); - - /** - * Copies all entries from this config object to a new config - * object that will save itself to @p file. - * - * Actual saving to @p file happens when the returned object is - * destructed or when sync() is called upon it. - * - * @param file the new config object will save itself to. - * @param config optional config object to reuse - * @since 3.2 - */ - KConfig* copyTo(const TQString &file, KConfig *config=0) const; - - /** - * Returns a lock file object for the configuration file or 0 if - * the backend does not support locking. - * @param bGlobal if true, return the lock file for the global config file - * - * NOTE: KConfig::sync() requires a lock on both the normal and global - * config file. When calling KConfig::sync() while having a lock on the - * global config file, the normal config file MUST be locked AS WELL and the - * normal config file MUST be locked BEFORE the global config file! - * Otherwise there is a risk of deadlock. - * @since 3.3 - */ - KLockFile::Ptr lockFile( bool bGlobal=false ); - -protected: - - /** - * Returns true if the specified group is known. - * - * @param group The group to search for. - * @returns true if the group exists. - */ - virtual bool internalHasGroup(const TQCString &group) const; - - /** - * @internal - * Returns a map (tree) of the entries in the specified group. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @param pGroup the group to provide a KEntryMap for. - * @return The map of the entries in the group. - */ - virtual KEntryMap internalEntryMap(const TQString &pGroup) const; - - /** - * @internal - * Returns a copy of the internal map used to hold all entries. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @return The map of the entries in the group. - */ - virtual KEntryMap internalEntryMap() const { return aEntryMap; } - - /** - * Inserts a (key, value) pair into the internal storage mechanism of - * the configuration object. - * - * @param _key The key to insert. It contains information both on - * the group of the key and the key itself. If the key already - * exists, the old value will be replaced. - * @param _data the KEntry that is to be stored. - * @param _checkGroup When false, assume that the group already exists. - */ - virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true); - - /** - * Looks up an entry in the config object's internal structure. - * - * @param _key The key to look up It contains information both on - * the group of the key and the entry's key itself. - * @return the KEntry value (data) found for the key. KEntry.aValue - * will be the null string if nothing was located. - */ - virtual KEntry lookupData(const KEntryKey &_key) const; - - /** - * Contains all key,value entries, as well as some "special" - * keys which indicate the start of a group of entries. - * - * These special keys will have the .key portion of their KEntryKey - * set to TQString::null. - */ - KEntryMap aEntryMap; - -private: - /** - * @internal - * copy-construction and assignment are not allowed - */ - KConfig( const KConfig& ); - /** - * @internal - * copy-construction and assignment are not allowed - */ - KConfig& operator= ( const KConfig& rConfig ); - -private: - bool bGroupImmutable : 1; // Current group is immutable. - bool bFileImmutable : 1; // Current file is immutable. - bool bForceGlobal : 1; // Apply everything to kdeglobals. -protected: - virtual void virtual_hook( int id, void* data ); -private: - KConfigPrivate *d; -}; - -/** - * KConfig variant using shared memory - * - * KSharedConfig provides a reference counted, shared memory variant - * of KConfig. - */ -class KDECORE_EXPORT KSharedConfig : public KConfig, public KShared -{ - friend class TQValueList<KSharedConfig*>; -public: - typedef KSharedPtr<KSharedConfig> Ptr; - -public: - /** - * Returns a ref-counted pointer to a shared read-write config object. - * @param fileName the name of the file to use for the configuration - * @param readOnly set the config object's read-only status - * @param bUseKDEGlobals Toggle reading the global KDE configuration file. - */ - static KSharedConfig::Ptr openConfig(const TQString& fileName, bool readOnly = false, - bool bUseKDEGlobals = true); - -private: - KSharedConfig( const TQString& fileName, bool readOnly, bool useKDEGlobals ); - ~KSharedConfig(); - - static TQValueList<KSharedConfig*> *s_list; -}; - -#endif diff --git a/kdecore/kconfig_compiler/CMakeLists.txt b/kdecore/kconfig_compiler/CMakeLists.txt deleted file mode 100644 index 4acc09f51..000000000 --- a/kdecore/kconfig_compiler/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### kconfig_compiler ########################## - -tde_add_executable( kconfig_compiler - SOURCES kconfig_compiler.cpp - LINK tdecore-shared - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/kdecore/kconfig_compiler/Makefile.am b/kdecore/kconfig_compiler/Makefile.am deleted file mode 100644 index d7b1400a4..000000000 --- a/kdecore/kconfig_compiler/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -SUBDIRS = example tests - -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_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -kconfig_compiler_LDADD = $(LIB_KDECORE) -kconfig_compiler_SOURCES = kconfig_compiler.cpp - -TESTFILES = test1.kcfg test2.kcfg test3.kcfg test4.kcfg test_dpointer.kcfg - -check-local: - for i in $(TESTFILES); \ - do xmllint --noout --schema $(srcdir)/kcfg.xsd $(srcdir)/tests/$$i; \ - perl $(top_srcdir)/tdecore/kconfig_compiler/checkkcfg.pl \ - $(top_srcdir)/tdecore/kconfig_compiler/tests/$$i; done - diff --git a/kdecore/kconfig_compiler/README.dox b/kdecore/kconfig_compiler/README.dox deleted file mode 100644 index 36d9f988b..000000000 --- a/kdecore/kconfig_compiler/README.dox +++ /dev/null @@ -1,255 +0,0 @@ -/** -\page kconfig_compiler The KDE Configuration Compiler - -kconfig_compiler generates C++ source code from an XML file containing -information about configuration options (.kcfg) and a file that provides -the code generation options (.kcfgc) The generated class is based on -KConfigSkeleton and provides an API for the application to access its -configuration data. - -<h2>XML description of the configuration options</h2> - -The structure of the .kcfg file is described by its DTD kcfg.dtd. - -The \<kcfgfile\> tag contains the name of the configuration file described. -Omitting the name will make the generated class use the default configuration -file ("<appname>rc"). - -The \<include\> tags are optional and may contain C++ header files that -are needed to compile the code needed to compute default values. - -The remaining entries in the XML file are grouped by the tag \<group\> -which describes the corresponding group in the configuration file. - -The individual entries must have at least a name or a key. The name is used to -create accessor and modifier functions. It's also used as the key in the config -file. If \<key\> is given, but not \<name\>, the name is constructed by removing -all spaces from \<key\>. - -An entry must also have a type. The list of allowable types is -specified in the DTD and loosely follows the list of types supported -by the QVariant with exception of the clearly binary types -(e.g. Pixmap, Image...) which are not supported. Besides those basic -type the following special types are supported: - -- Path This is a string that is specially treated as a file-path. - In particular paths in the home directory are prefixed with $HOME in - when being stored in the configuration file. - -- Enum This indicates an enumeration. The possible enum values should - be provided via the \<choices\> tag. Enum values are accessed as integers - by the application but stored as string in the configuration file. This - makes it possible to add more values at a later date without breaking - compatibility. - -- IntList This indicates a list of integers. This information is provided - to the application as QValueList<int>. Useful for storing QSplitter - geometries. - -An entry can optionally have a default value which is used as default when -the value isn't specified in any config file. Default values are interpreted -as literal constant values. If a default value needs to be computed -or if it needs to be obtained from a function call, the \<default\> tag -should contain the code="true" attribute. The contents of the \<default\> -tag is then considered to be a C++ expression. Note that in this case you -might have to add an \<include\> tag as described above so that the code -which computes the default value can be compiled. - -Additional code for computing default values can be provided via -the \<code\> tag. The contents of the \<code\> tag is inserted as-is. A -typical use for this is to compute a common default value which can -then be referenced by multiple entries that follow. - -<h2>Code generation options</h2> - -The options for generating the C++ sources are read from the file with the -extension .kcfgc. To generate a class add the corresponding kcfgc file to the -SOURCES line in the Makefile.am. - -The following options are read from the kcfgc file: - -<table> -<tr> - <td><b><i>Name</i></b></td> - <td><b><i>Type</i></b></td> - <td><b><i>Default</i></b></td> - <td><b><i>Description</i></b></td> -</tr> -<tr> - <td><b>File</b></td> - <td>string</td> - <td>programname.kcfg</td> - <td>Name of kcfg file containing the options the class is generated for</td> -</tr> -<tr> - <td><b>NameSpace</b></td> - <td>string</td> - <td>-</td> - <td>Optional namespace for generated class</td> -</tr> -<tr> - <td><b>ClassName</b></td> - <td>string</td> - <td>-</td> - <td>Name of generated class (required)</td> -</tr> -<tr> - <td><b>Inherits</b></td> - <td>string</td> - <td>KConfigSkeleton</td> - <td>Class the generated class inherits from. This class must inherit - KConfigSkeleton.</td> -</tr> -<tr> - <td><b>Visibility</b></td> - <td>string</td> - <td>-</td> - <td>Inserts visibility directive (for example KDE_EXPORT) between "class" keyword and class - name in header file</td> -</tr> -<tr> - <td><b>Singleton</b></td> - <td>bool</td> - <td>false</td> - <td>Generated class is a singleton.</td> -</tr> -<tr> - <td><b>CustomAdditions</b></td> - <td>bool</td> - <td>-</td> - <td></td> -</tr> -<tr> - <td><b>MemberVariables</b></td> - <td>string: public|protected|private</td> - <td>private</td> - <td>C++ access modifier used for memeber variables holding the configuration - valuse</td> -</tr> -<tr> - <td><b>IncludeFiles</b></td> - <td>comma separated list of strings</td> - <td>-</td> - <td>Names of files to be included in the header of the generated class</td> -</tr> -<tr> - <td><b>Mutators</b></td> - <td>true, false or a comma seperated list of options</td> - <td>-</td> - <td>If true, mutator functions for all configuration options are generated. - If false, no mutator functions are generated. If a list is provided, - mutator functions are generated for the options that are listed.</td> -</tr> -<tr> - <td><b>ItemAccessors</b></td> - <td>bool</td> - <td>false</td> - <td>Generate accessor functions for the KConfigSkeletonItem objects - corresponding to the configuration options. If <b>SetUserTexts</b> is set, - <b>ItemAccessors</b> also has to be set.</td> -</tr> -<tr> - <td><b>SetUserTexts</b></td> - <td>bool</td> - <td>false</td> - <td>Set the label and whatthis texts of the items from the kcfg file.If - <b>SetUserTexts</b> is set, <b>ItemAccessors</b> also has to be set.</td> -</tr> -<tr> - <td><b>GlobalEnums</b></td> - <td>bool</td> - <td>false</td> - <td>If set to true all choices of Enum items will be created in the global - scope of the generated class. If set to false, each Enum item will get an own - namespace for its choices.</td> -</tr> -</table> - - -<h2>Advanced options</h2> - -There are several possibilities to parameterize entries. - -- Parameterized entries - -An entry can be parameterized using a fixed range parameter specified with -the \<parameter\> tag. Such parameter can either be an Enum or an int. An Enum -parameter should specify the possible enumeration values with the \<choices\> -tag. An int parameter should specify its maximum value. Its minimum value -is always 0. - -A parameterized entry is expanded to a number of entries, one for each -value in the parameter range. The name and key should contain a reference -to the parameter in the form of $(parameter-name). When expanding the entries -the $(parameter-name) part is replaced with the value of the parameter. -In the case of an Enum parameter it is replaced with the name of the -enumuration value. In the case of an int parameter it is replaced with -the numeric value of the parameter. - -Parameterized entries all share the same default value unless different -default values have been specified for specific parameter values. -This can be done with the param= attribute of the \<default\>. When a -param attribute is specified the default value only applies to that -particular parameter value. - -Example 1: -\verbatim - <entry name="Color$(ColorIndex)" type="Color" key="color_$(ColorIndex)"> - <parameter name="ColorIndex" type="Int" max="3"/> - <default param="0">#ff0000</default> - <default param="1">#00ff00</default> - <default param="2">#0000ff</default> - <default param="3">#ffff00</default> - </entry> -\endverbatim - -The above describes 4 color configuration entries with the following defaults: - -\verbatim -color_0=#ff0000 -color_1=#00ff00 -color_2=#0000ff -color_3=#ffff00 -\endverbatim - -The configuration options will be accessible to the application via -a QColor color(int ColorIndex) and a -void setColor(int ColorIndex, const QColor &v) function. - -Example 2: -\verbatim - <entry name="Sound$(SoundEvent)" type="String" key="sound_$(SoundEvent)"> - <parameter name="SoundEvent" type="Enum"> - <values> - <value>Explosion</value> - <value>Crash</value> - <value>Missile</value> - </values> - </parameter> - <default param="Explosion">boom.wav</default> - <default param="Crash">crash.wav</default> - <default param="Missile">missile.wav</default> - </entry> -\endverbatim - -The above describes 3 string configuration entries with the following defaults: - -sound_Explosion=boom.wav -sound_Crash=crash.wav -sound_Missile=missile.wav - -The configuration options will be accessible to the application via -a QString sound(int SoundEvent) and a -void setSound(int SoundEvent, const QString &v) function. - -- Parameterized groups - -...STILL TODO... - - - - - -If you have questions or comments please contact Cornelius Schumacher -<schumacher@kde.org> or Waldo Bastian <bastian@kde.org> -*/ diff --git a/kdecore/kconfig_compiler/TODO b/kdecore/kconfig_compiler/TODO deleted file mode 100644 index e69de29bb..000000000 diff --git a/kdecore/kconfig_compiler/checkkcfg.pl b/kdecore/kconfig_compiler/checkkcfg.pl deleted file mode 100755 index 2eddbeee6..000000000 --- a/kdecore/kconfig_compiler/checkkcfg.pl +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/perl - -if ( @ARGV != 1 ) { - print STDERR "Missing arg: filename\n"; - exit 1; -} - -$file = $ARGV[0]; - -$file =~ /^(.*)\.[^\.]*$/; -$filebase = $1; - -$file_h = "$filebase.h"; -$file_cpp = "$filebase.cpp"; - -$kcfgc = $file . "c"; - -$cmd = "./kconfig_compiler $file $kcfgc"; - -#print "CMD $cmd\n"; - -if ( system( $cmd ) != 0 ) { - print STDERR "Unable to run kconfig_compiler\n"; - exit 1; -} - -checkfile( $file_h ); -checkfile( $file_cpp ); - -exit 0; - -sub checkfile() -{ - my $file = shift; - - $file =~ /\/([^\/]*)$/; - my $filename = $1; - - print "Checking '$filename':\n"; - - my @ref; - if ( !open( REF, "$file.ref" ) ) { - print STDERR "Unable to open $file.ref\n"; - exit 1; - } - while( <REF> ) { - push @ref, $_; - } - close REF; - - if ( !open( READ, $filename ) ) { - print STDERR "Unable to open $filename\n"; - exit 1; - } - - $error = 0; - $i = 0; - $line = 1; - while( <READ> ) { - $out = $_; - $ref = @ref[$i++]; - - if ( $out ne $ref ) { - $error++; - print " Line $line: Expected : $ref"; - print " Line $line: Compiler output : $out"; - } - - $line++; - } - - close READ; - - if ( $error > 0 ) { - print "\n FAILED: $error errors found.\n"; - if ( $error > 5 ) { - system( "diff -u $file.ref $filename" ); - } - exit 1; - } else { - print " OK\n"; - } -} diff --git a/kdecore/kconfig_compiler/example/Makefile.am b/kdecore/kconfig_compiler/example/Makefile.am deleted file mode 100644 index 9c0454ad8..000000000 --- a/kdecore/kconfig_compiler/example/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -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_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -example_LDADD = $(LIB_KDECORE) -example_SOURCES = example.cpp exampleprefs_base.cpp - -autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -autoexample_LDADD = $(LIB_KDECORE) $(LIB_KDEUI) -autoexample_SOURCES = exampleprefs_base.cpp general_base.ui myoptions_base.ui \ - autoexample.cpp - -example.o exampleprefs_base.o: exampleprefs_base.h -# avoid running the below command in parallel -exampleprefs_base.cpp: exampleprefs_base.h -exampleprefs_base.cpp exampleprefs_base.h: $(srcdir)/example.kcfg ../kconfig_compiler $(srcdir)/exampleprefs_base.kcfgc - ../kconfig_compiler $(srcdir)/example.kcfg $(srcdir)/exampleprefs_base.kcfgc - -METASOURCES = AUTO - -CLEANFILES = exampleprefs_base.h exampleprefs_base.cpp - -## The example's messages should not go into kdelibs.pot -messages: rc.cpp - true diff --git a/kdecore/kconfig_compiler/example/autoexample.cpp b/kdecore/kconfig_compiler/example/autoexample.cpp deleted file mode 100644 index 2c4e4d442..000000000 --- a/kdecore/kconfig_compiler/example/autoexample.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - - 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. -*/ - -#include "general_base.h" -#include "myoptions_base.h" - -#include "exampleprefs_base.h" - -#include <kaboutdata.h> -#include <kapplication.h> -#include <kdebug.h> -#include <klocale.h> -#include <kcmdlineargs.h> -#include <kglobal.h> -#include <kconfig.h> -#include <kstandarddirs.h> -#include <kconfigdialog.h> - -#include <tqlabel.h> - -int main( int argc, char **argv ) -{ - KAboutData aboutData( "example", I18N_NOOP("autoconfig example"), "0.1" ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - - KCmdLineArgs::init( argc, argv, &aboutData ); - - KApplication app; - - ExamplePrefsBase configSkeleton( "dummy1", "dummy2" ); - configSkeleton.readConfig(); - - KConfigDialog *dialog = new KConfigDialog( 0, "settings", &configSkeleton ); - - GeneralBase *general = new GeneralBase( 0 ); - dialog->addPage( general, i18n("General"), "General", "" ); - - MyOptionsBase *myOptions = new MyOptionsBase( 0 ); - dialog->addPage( myOptions, i18n("MyOptions"), "MyOptions", "" ); - - app.setMainWidget( dialog ); - - dialog->show(); - - return app.exec(); -} diff --git a/kdecore/kconfig_compiler/example/example.cpp b/kdecore/kconfig_compiler/example/example.cpp deleted file mode 100644 index 146d2460f..000000000 --- a/kdecore/kconfig_compiler/example/example.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - - 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. -*/ - -#include "exampleprefs_base.h" - -#include <kaboutdata.h> -#include <kapplication.h> -#include <kdebug.h> -#include <klocale.h> -#include <kcmdlineargs.h> -#include <kglobal.h> -#include <kconfig.h> -#include <kstandarddirs.h> - -int main( int argc, char **argv ) -{ - KAboutData aboutData( "example", I18N_NOOP("cfgc example"), "0.1" ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - - KCmdLineArgs::init( argc, argv, &aboutData ); - - KApplication app; - - ExamplePrefsBase *prefs = new ExamplePrefsBase("Trans1", "Folder2"); - - prefs->readConfig(); - - prefs->setAnotherOption(17); - - kdWarning() << "Another Option = " << prefs->anotherOption() << endl; - kdWarning() << "Another Option2 = " << prefs->anotherOption2() << endl; - kdWarning() << "MyPaths = " << prefs->myPaths() << endl; - kdWarning() << "MyPaths2 = " << prefs->myPaths2() << endl; -} diff --git a/kdecore/kconfig_compiler/example/example.kcfg b/kdecore/kconfig_compiler/example/example.kcfg deleted file mode 100644 index 076bfb644..000000000 --- a/kdecore/kconfig_compiler/example/example.kcfg +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <include>qdir.h</include> - <kcfgfile name="examplerc"> - <parameter name="transport" /> - <parameter name="folder" /> - </kcfgfile> - <group name="General-$(folder)"> - <entry name="OneOption" type="Bool"> - <label>One option</label> - <default>true</default> - </entry> - <entry name="AnotherOption" type="Int" key="Another Option"> - <label>Another option</label> - <default>5</default> - </entry> - <entry name="ListOption" type="Enum"> - <label>This is some funky option</label> - <whatsthis>And this is a longer description of this option. Just wondering, how will the translations of those be handled?</whatsthis> - <choices> - <choice name="One"/> - <choice name="Two"/> - <choice name="Three"/> - </choices> - <default>One</default> - </entry> - </group> - <group name="MyOptions"> - <entry name="MyString" type="String"> - <label>This is a string</label> - <default>Default String</default> - </entry> - <entry name="MyPath" type="Path"> - <label>This is a path</label> - <default code="true">QDir::homeDirPath()+QString::fromLatin1(".hidden_file")</default> - </entry> - <entry name="MyPaths" type="PathList"> - <label>This is a list of paths</label> - <default>/home,~</default> - </entry> - <entry name="MyPaths2" type="PathList"> - <label>This is a list of paths (test2)</label> - <default code="true">QStringList(QDir::homeDirPath())</default> - </entry> - <entry name="AnotherOption2" type="Int" key="Another Option"> - <label>Another option</label> - <default>10</default> - </entry> - <entry name="MyStringList" type="StringList"> - <default>up,down</default> - </entry> - <entry name="MyStringListHidden" hidden="true" type="StringList"> - <default>up,down</default> - </entry> - <entry name="MyNumber" type="Int64" key="List-$(transport)-$(folder)"> - <label>List Number</label> - <default>1</default> - </entry> - </group> -</kcfg> diff --git a/kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc b/kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc deleted file mode 100644 index 829ec2e29..000000000 --- a/kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc +++ /dev/null @@ -1,18 +0,0 @@ -# Code generation options for kconfig_compiler -ClassName=ExamplePrefsBase -# -# Singleton=false -# -# Inherits=KConfigSkeleton -# -# IncludeFiles=libtdepim/kpimprefs.h -# -# MemberVariables=public -# -### The following line includes the file exampleprefs_base_addon.h -### It can be used to add extra functions and variables to the -### class. -# CustomAdditions=true -# -### Provide setFooBar(int) style functions -Mutators=true diff --git a/kdecore/kconfig_compiler/example/general_base.ui b/kdecore/kconfig_compiler/example/general_base.ui deleted file mode 100644 index 9b41370c7..000000000 --- a/kdecore/kconfig_compiler/example/general_base.ui +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> -<class>GeneralBase</class> -<widget class="QWidget"> - <property name="name"> - <cstring>GeneralBase</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>486</height> - </rect> - </property> - <property name="caption"> - <string>AutoExampleDialog</string> - </property> - <grid> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="QCheckBox" row="0" column="1"> - <property name="name"> - <cstring>kcfg_OneOption</cstring> - </property> - <property name="text"> - <string>OneOption</string> - </property> - </widget> - <widget class="QSpinBox" row="1" column="1"> - <property name="name"> - <cstring>kcfg_AnotherOption2</cstring> - </property> - </widget> - <widget class="QLabel" row="1" column="0"> - <property name="name"> - <cstring>textLabel1</cstring> - </property> - <property name="text"> - <string>AnotherOption:</string> - </property> - </widget> - </grid> -</widget> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/kdecore/kconfig_compiler/example/myoptions_base.ui b/kdecore/kconfig_compiler/example/myoptions_base.ui deleted file mode 100644 index 3c0c2e6cb..000000000 --- a/kdecore/kconfig_compiler/example/myoptions_base.ui +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> -<class>MyOptionsBase</class> -<widget class="QWidget"> - <property name="name"> - <cstring>MyOptionsBase</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>486</height> - </rect> - </property> - <grid> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="QLabel" row="0" column="0"> - <property name="name"> - <cstring>textLabel1</cstring> - </property> - <property name="text"> - <string>MyString:</string> - </property> - </widget> - <widget class="QLineEdit" row="0" column="1"> - <property name="name"> - <cstring>kcfg_MyString</cstring> - </property> - </widget> - </grid> -</widget> -<layoutdefaults spacing="6" margin="11"/> -</UI> diff --git a/kdecore/kconfig_compiler/kcfg.xsd b/kdecore/kconfig_compiler/kcfg.xsd deleted file mode 100644 index 97f716d62..000000000 --- a/kdecore/kconfig_compiler/kcfg.xsd +++ /dev/null @@ -1,192 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- kcfg XSD v1.0 --> -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:kcfg="http://www.kde.org/standards/kcfg/1.0" - targetNamespace="http://www.kde.org/standards/kcfg/1.0" - version="1.0" - elementFormDefault="qualified" > - - <xsd:annotation> - <xsd:documentation> - - Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - Copyright (c) 2003 Zack Rusin <zack@kde.org> - Copyright (c) 2004 Frans Englich <frans.englich@telia.com> - - Permission to use, copy, modify and distribute this DTD - and its accompanying documentation for any purpose and without fee - is hereby granted in perpetuity, provided that the above copyright - notice and this paragraph appear in all copies. The copyright - holders make no representation about the suitability of the DTD for - any purpose. It is provided "as is" without expressed or implied - warranty. - - </xsd:documentation> - </xsd:annotation> - <xsd:annotation> - <xsd:documentation> - - A Schema for KDE's KConfigXT XML format. It is similar to the DTD - found at: - - http://www.kde.org/standards/kcfg/1.0/kcfg.dtd - - Documents valid against the Schema version are backwards compatible - to the DTD. Validating against the Schema instead of the DTD is - recommended, since the former provides better validation. - - A document instance of this Schema should have a declaration - looking like this: - - <![CDATA[ - - <?xml version="1.0" encoding="UTF-8" ?> - <kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <!-- the content --> - </kcfg> - - ]]> - - </xsd:documentation> - </xsd:annotation> - - <xsd:element name="kcfg"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="include" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/> - <xsd:element name="kcfgfile" > - <xsd:complexType> - <xsd:sequence> - <xsd:element name="parameter" type="kcfg:parameter" minOccurs="0" maxOccurs="unbounded" /> - <!-- FIXME: Are really unbounded occurances of parameter allowed? --> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="optional"/> - <xsd:attribute name="arg" type="xsd:boolean" use="optional"/> - </xsd:complexType> - </xsd:element> - <xsd:element name="group" maxOccurs="unbounded" > - <xsd:complexType> - <xsd:sequence> - <xsd:element name="entry" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:choice maxOccurs="unbounded"> - <xsd:element name="parameter" minOccurs="0" type="kcfg:parameter"/> - <xsd:element name="label" minOccurs="0" type="xsd:string"/> - <xsd:element name="whatsthis" minOccurs="0" type="xsd:string"/> - <xsd:element name="choices" minOccurs="0"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="choice" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:all> - <xsd:element minOccurs="0" name="label" type="xsd:string"/> - <xsd:element minOccurs="0" name="whatsthis" type="xsd:string"/> - </xsd:all> - <xsd:attribute name="name" use="required" type="xsd:string"/> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:element name="code" minOccurs="0" type="kcfg:code"/> - - <xsd:element name="default" maxOccurs="unbounded" minOccurs="0" > - <xsd:complexType> - <xsd:simpleContent> - <xsd:extension base="xsd:string"> - <xsd:attribute use="optional" name="code" type="xsd:boolean"/> - <xsd:attribute use="optional" name="param" type="xsd:string"/> - </xsd:extension> - </xsd:simpleContent> - </xsd:complexType> - </xsd:element> - - <xsd:element name="min" minOccurs="0" > - <xsd:complexType> - <xsd:simpleContent> - <xsd:extension base="xsd:string"> - <xsd:attribute name="code" type="xsd:boolean"/> - </xsd:extension> - </xsd:simpleContent> - </xsd:complexType> - </xsd:element> - - <xsd:element name="max" minOccurs="0"> - <xsd:complexType> - <xsd:simpleContent> - <xsd:extension base="xsd:string"> - <xsd:attribute name="code" type="xsd:boolean"/> - </xsd:extension> - </xsd:simpleContent> - </xsd:complexType> - </xsd:element> - - </xsd:choice> - <xsd:attribute name="name" use="optional" type="xsd:string"/> - <xsd:attribute name="key" use="optional" type="xsd:string"/> - <xsd:attribute name="hidden" use="optional" type="xsd:boolean"/> - <xsd:attribute name="type" type="kcfg:datatype"/> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - <xsd:attribute name="name" use="required" type="xsd:string"/> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:simpleType name="datatype"> - <xsd:restriction base="xsd:string"> - <xsd:enumeration value="String"/> - <xsd:enumeration value="StringList"/> - <xsd:enumeration value="Font"/> - <xsd:enumeration value="Rect"/> - <xsd:enumeration value="Size"/> - <xsd:enumeration value="Color"/> - <xsd:enumeration value="Point"/> - <xsd:enumeration value="Int"/> - <xsd:enumeration value="UInt"/> - <xsd:enumeration value="Bool"/> - <xsd:enumeration value="Double"/> - <xsd:enumeration value="DateTime"/> - <xsd:enumeration value="Int64"/> - <xsd:enumeration value="UInt64"/> - <xsd:enumeration value="IntList"/> - <xsd:enumeration value="Enum"/> - <xsd:enumeration value="Path"/> - <xsd:enumeration value="PathList"/> - <xsd:enumeration value="Password"/> - </xsd:restriction> - </xsd:simpleType> - - <xsd:complexType name="parameter"> - <xsd:sequence> - <xsd:element minOccurs="0" name="values"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" maxOccurs="unbounded" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - </xsd:sequence> - <xsd:attribute name="name" use="required" type="xsd:string"/> - <xsd:attribute name="type" use="optional" type="kcfg:datatype" /> - <xsd:attribute name="max" use="optional" type="xsd:positiveInteger"/> - </xsd:complexType> - - <xsd:complexType name="code"> - <xsd:simpleContent> - <xsd:extension base="xsd:string"/> - </xsd:simpleContent> - </xsd:complexType> - -</xsd:schema> - diff --git a/kdecore/kconfig_compiler/kconfig_compiler.cpp b/kdecore/kconfig_compiler/kconfig_compiler.cpp deleted file mode 100644 index 10c91834c..000000000 --- a/kdecore/kconfig_compiler/kconfig_compiler.cpp +++ /dev/null @@ -1,1700 +0,0 @@ -// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- -/* - This file is part of KDE. - - Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - Copyright (c) 2003 Zack Rusin <zack@kde.org> - - 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. -*/ - -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqdom.h> -#include <tqregexp.h> - -#include <kaboutdata.h> -#include <kapplication.h> -#include <kdebug.h> -#include <klocale.h> -#include <kcmdlineargs.h> -#include <kglobal.h> -#include <kconfig.h> -#include <ksimpleconfig.h> -#include <kstandarddirs.h> - -#include <iostream> - -static const KCmdLineOptions options[] = -{ - { "d", 0, 0 }, - { "directory <dir>", I18N_NOOP("Directory to generate files in"), "." }, - { "+file.kcfg", I18N_NOOP("Input kcfg XML file"), 0 }, - { "+file.kcfgc", I18N_NOOP("Code generation options file"), 0 }, - KCmdLineLastOption -}; - - -bool globalEnums; -bool itemAccessors; -bool dpointer; -TQStringList allNames; -TQRegExp *validNameRegexp; -TQString This; -TQString Const; - -class CfgEntry -{ - public: - struct Choice - { - TQString name; - TQString label; - TQString whatsThis; - }; - - CfgEntry( const TQString &group, const TQString &type, const TQString &key, - const TQString &name, const TQString &label, - const TQString &whatsThis, const TQString &code, - const TQString &defaultValue, const TQValueList<Choice> &choices, - bool hidden ) - : mGroup( group ), mType( type ), mKey( key ), mName( name ), - mLabel( label ), mWhatsThis( whatsThis ), mCode( code ), - mDefaultValue( defaultValue ), - mChoices( choices ), mHidden( hidden ) - { - } - - void setGroup( const TQString &group ) { mGroup = group; } - TQString group() const { return mGroup; } - - void setType( const TQString &type ) { mType = type; } - TQString type() const { return mType; } - - void setKey( const TQString &key ) { mKey = key; } - TQString key() const { return mKey; } - - void setName( const TQString &name ) { mName = name; } - TQString name() const { return mName; } - - void setLabel( const TQString &label ) { mLabel = label; } - TQString label() const { return mLabel; } - - void setWhatsThis( const TQString &whatsThis ) { mWhatsThis = whatsThis; } - TQString whatsThis() const { return mWhatsThis; } - - void setDefaultValue( const TQString &d ) { mDefaultValue = d; } - TQString defaultValue() const { return mDefaultValue; } - - void setCode( const TQString &d ) { mCode = d; } - TQString code() const { return mCode; } - - void setMinValue( const TQString &d ) { mMin = d; } - TQString minValue() const { return mMin; } - - void setMaxValue( const TQString &d ) { mMax = d; } - TQString maxValue() const { return mMax; } - - void setParam( const TQString &d ) { mParam = d; } - TQString param() const { return mParam; } - - void setParamName( const TQString &d ) { mParamName = d; } - TQString paramName() const { return mParamName; } - - void setParamType( const TQString &d ) { mParamType = d; } - TQString paramType() const { return mParamType; } - - void setChoices( const TQValueList<Choice> &d ) { mChoices = d; } - TQValueList<Choice> choices() const { return mChoices; } - - void setParamValues( const TQStringList &d ) { mParamValues = d; } - TQStringList paramValues() const { return mParamValues; } - - void setParamDefaultValues( const TQStringList &d ) { mParamDefaultValues = d; } - TQString paramDefaultValue(int i) const { return mParamDefaultValues[i]; } - - void setParamMax( int d ) { mParamMax = d; } - int paramMax() const { return mParamMax; } - - bool hidden() const { return mHidden; } - - void dump() const - { - kdDebug() << "<entry>" << endl; - kdDebug() << " group: " << mGroup << endl; - kdDebug() << " type: " << mType << endl; - kdDebug() << " key: " << mKey << endl; - kdDebug() << " name: " << mName << endl; - kdDebug() << " label: " << mLabel << endl; -// whatsthis - kdDebug() << " code: " << mCode << endl; -// kdDebug() << " values: " << mValues.join(":") << endl; - - if (!param().isEmpty()) - { - kdDebug() << " param name: "<< mParamName << endl; - kdDebug() << " param type: "<< mParamType << endl; - kdDebug() << " paramvalues: " << mParamValues.join(":") << endl; - } - kdDebug() << " default: " << mDefaultValue << endl; - kdDebug() << " hidden: " << mHidden << endl; - kdDebug() << " min: " << mMin << endl; - kdDebug() << " max: " << mMax << endl; - kdDebug() << "</entry>" << endl; - } - - private: - TQString mGroup; - TQString mType; - TQString mKey; - TQString mName; - TQString mLabel; - TQString mWhatsThis; - TQString mCode; - TQString mDefaultValue; - TQString mParam; - TQString mParamName; - TQString mParamType; - TQValueList<Choice> mChoices; - TQStringList mParamValues; - TQStringList mParamDefaultValues; - int mParamMax; - bool mHidden; - TQString mMin; - TQString mMax; -}; - -class Param { -public: - TQString name; - TQString type; -}; - -// returns the name of an member variable -// use itemPath to know the full path -// like using d-> in case of dpointer -static TQString varName(const TQString &n) -{ - TQString result; - if ( !dpointer ) { - result = "m"+n; - result[1] = result[1].upper(); - } - else { - result = n; - result[0] = result[0].lower(); - } - return result; -} - -static TQString varPath(const TQString &n) -{ - TQString result; - if ( dpointer ) { - result = "d->"+varName(n); - } - else { - result = varName(n); - } - return result; -} - -static TQString enumName(const TQString &n) -{ - TQString result = "Enum"+n; - result[4] = result[4].upper(); - return result; -} - -static TQString setFunction(const TQString &n, const TQString &className = TQString()) -{ - TQString result = "set"+n; - result[3] = result[3].upper(); - - if ( !className.isEmpty() ) - result = className + "::" + result; - return result; -} - - -static TQString getFunction(const TQString &n, const TQString &className = TQString()) -{ - TQString result = n; - result[0] = result[0].lower(); - - if ( !className.isEmpty() ) - result = className + "::" + result; - return result; -} - - -static void addQuotes( TQString &s ) -{ - if ( s.left( 1 ) != "\"" ) s.prepend( "\"" ); - if ( s.right( 1 ) != "\"" ) s.append( "\"" ); -} - -static TQString quoteString( const TQString &s ) -{ - TQString r = s; - r.replace( "\\", "\\\\" ); - r.replace( "\"", "\\\"" ); - r.replace( "\r", "" ); - r.replace( "\n", "\\n\"\n\"" ); - return "\"" + r + "\""; -} - -static TQString literalString( const TQString &s ) -{ - bool isAscii = true; - for(int i = s.length(); i--;) - if (s[i].tqunicode() > 127) isAscii = false; - - if (isAscii) - return "TQString::tqfromLatin1( " + quoteString(s) + " )"; - else - return "TQString::fromUtf8( " + quoteString(s) + " )"; -} - -static TQString dumpNode(const TQDomNode &node) -{ - TQString msg; - TQTextStream s(&msg, IO_WriteOnly ); - node.save(s, 0); - - msg = msg.simplifyWhiteSpace(); - if (msg.length() > 40) - return msg.left(37)+"..."; - return msg; -} - -static TQString filenameOnly(TQString path) -{ - int i = path.findRev('/'); - if (i >= 0) - return path.mid(i+1); - return path; -} - -static void preProcessDefault( TQString &defaultValue, const TQString &name, - const TQString &type, - const TQValueList<CfgEntry::Choice> &choices, - TQString &code ) -{ - if ( type == "String" && !defaultValue.isEmpty() ) { - defaultValue = literalString(defaultValue); - - } else if ( type == "Path" && !defaultValue.isEmpty() ) { - defaultValue = literalString( defaultValue ); - - } else if ( (type == "StringList" || type == "PathList") && !defaultValue.isEmpty() ) { - TQTextStream cpp( &code, IO_WriteOnly | IO_Append ); - if (!code.isEmpty()) - cpp << endl; - - cpp << " TQStringList default" << name << ";" << endl; - TQStringList defaults = TQStringList::split( ",", defaultValue ); - TQStringList::ConstIterator it; - for( it = defaults.begin(); it != defaults.end(); ++it ) { - cpp << " default" << name << ".append( TQString::fromUtf8( \"" << *it << "\" ) );" - << endl; - } - defaultValue = "default" + name; - - } else if ( type == "Color" && !defaultValue.isEmpty() ) { - TQRegExp colorRe("\\d+,\\s*\\d+,\\s*\\d+"); - if (colorRe.exactMatch(defaultValue)) - { - defaultValue = "TQColor( " + defaultValue + " )"; - } - else - { - defaultValue = "TQColor( \"" + defaultValue + "\" )"; - } - - } else if ( type == "Enum" ) { - if ( !globalEnums ) { - TQValueList<CfgEntry::Choice>::ConstIterator it; - for( it = choices.begin(); it != choices.end(); ++it ) { - if ( (*it).name == defaultValue ) { - defaultValue.prepend( enumName(name) + "::"); - break; - } - } - } - - } else if ( type == "IntList" ) { - TQTextStream cpp( &code, IO_WriteOnly | IO_Append ); - if (!code.isEmpty()) - cpp << endl; - - cpp << " TQValueList<int> default" << name << ";" << endl; - TQStringList defaults = TQStringList::split( ",", defaultValue ); - TQStringList::ConstIterator it; - for( it = defaults.begin(); it != defaults.end(); ++it ) { - cpp << " default" << name << ".append( " << *it << " );" - << endl; - } - defaultValue = "default" + name; - } -} - - -CfgEntry *parseEntry( const TQString &group, const TQDomElement &element ) -{ - bool defaultCode = false; - TQString type = element.attribute( "type" ); - TQString name = element.attribute( "name" ); - TQString key = element.attribute( "key" ); - TQString hidden = element.attribute( "hidden" ); - TQString label; - TQString whatsThis; - TQString defaultValue; - TQString code; - TQString param; - TQString paramName; - TQString paramType; - TQValueList<CfgEntry::Choice> choices; - TQStringList paramValues; - TQStringList paramDefaultValues; - TQString minValue; - TQString maxValue; - int paramMax = 0; - - TQDomNode n; - for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - TQDomElement e = n.toElement(); - TQString tag = e.tagName(); - if ( tag == "label" ) label = e.text(); - else if ( tag == "whatsthis" ) whatsThis = e.text(); - else if ( tag == "min" ) minValue = e.text(); - else if ( tag == "max" ) maxValue = e.text(); - else if ( tag == "code" ) code = e.text(); - else if ( tag == "parameter" ) - { - param = e.attribute( "name" ); - paramType = e.attribute( "type" ); - if ( param.isEmpty() ) { - kdError() << "Parameter must have a name: " << dumpNode(e) << endl; - return 0; - } - if ( paramType.isEmpty() ) { - kdError() << "Parameter must have a type: " << dumpNode(e) << endl; - return 0; - } - if ((paramType == "Int") || (paramType == "UInt")) - { - bool ok; - paramMax = e.attribute("max").toInt(&ok); - if (!ok) - { - kdError() << "Integer parameter must have a maximum (e.g. max=\"0\"): " << dumpNode(e) << endl; - return 0; - } - } - else if (paramType == "Enum") - { - TQDomNode n2; - for ( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if (e2.tagName() == "values") - { - TQDomNode n3; - for ( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { - TQDomElement e3 = n3.toElement(); - if (e3.tagName() == "value") - { - paramValues.append( e3.text() ); - } - } - break; - } - } - if (paramValues.isEmpty()) - { - kdError() << "No values specified for parameter '" << param << "'." << endl; - return 0; - } - paramMax = paramValues.count()-1; - } - else - { - kdError() << "Parameter '" << param << "' has type " << paramType << " but must be of type int, uint or Enum." << endl; - return 0; - } - } - else if ( tag == "default" ) - { - if (e.attribute("param").isEmpty()) - { - defaultValue = e.text(); - if (e.attribute( "code" ) == "true") - defaultCode = true; - } - } - else if ( tag == "choices" ) { - TQDomNode n2; - for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if ( e2.tagName() == "choice" ) { - TQDomNode n3; - CfgEntry::Choice choice; - choice.name = e2.attribute( "name" ); - if ( choice.name.isEmpty() ) { - kdError() << "Tag <choice> requires attribute 'name'." << endl; - } - for( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { - TQDomElement e3 = n3.toElement(); - if ( e3.tagName() == "label" ) choice.label = e3.text(); - if ( e3.tagName() == "whatsthis" ) choice.whatsThis = e3.text(); - } - choices.append( choice ); - } - } - } - } - - bool nameIsEmpty = name.isEmpty(); - if ( nameIsEmpty && key.isEmpty() ) { - kdError() << "Entry must have a name or a key: " << dumpNode(element) << endl; - return 0; - } - - if ( key.isEmpty() ) { - key = name; - } - - if ( nameIsEmpty ) { - name = key; - name.replace( " ", TQString() ); - } else if ( name.contains( ' ' ) ) { - kdWarning()<<"Entry '"<<name<<"' contains spaces! <name> elements can't contain speces!"<<endl; - name.remove( ' ' ); - } - - if (name.contains("$(")) - { - if (param.isEmpty()) - { - kdError() << "Name may not be parameterized: " << name << endl; - return 0; - } - } - else - { - if (!param.isEmpty()) - { - kdError() << "Name must contain '$(" << param << ")': " << name << endl; - return 0; - } - } - - if ( label.isEmpty() ) { - label = key; - } - - if ( type.isEmpty() ) type = "String"; // XXX : implicit type might be bad - - if (!param.isEmpty()) - { - // Adjust name - paramName = name; - name.replace("$("+param+")", TQString()); - // Lookup defaults for indexed entries - for(int i = 0; i <= paramMax; i++) - { - paramDefaultValues.append(TQString()); - } - - TQDomNode n; - for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - TQDomElement e = n.toElement(); - TQString tag = e.tagName(); - if ( tag == "default" ) - { - TQString index = e.attribute("param"); - if (index.isEmpty()) - continue; - - bool ok; - int i = index.toInt(&ok); - if (!ok) - { - i = paramValues.findIndex(index); - if (i == -1) - { - kdError() << "Index '" << index << "' for default value is unknown." << endl; - return 0; - } - } - - if ((i < 0) || (i > paramMax)) - { - kdError() << "Index '" << i << "' for default value is out of range [0, "<< paramMax<<"]." << endl; - return 0; - } - - TQString tmpDefaultValue = e.text(); - - if (e.attribute( "code" ) != "true") - preProcessDefault(tmpDefaultValue, name, type, choices, code); - - paramDefaultValues[i] = tmpDefaultValue; - } - } - } - - if (!validNameRegexp->exactMatch(name)) - { - if (nameIsEmpty) - kdError() << "The key '" << key << "' can not be used as name for the entry because " - "it is not a valid name. You need to specify a valid name for this entry." << endl; - else - kdError() << "The name '" << name << "' is not a valid name for an entry." << endl; - return 0; - } - - if (allNames.contains(name)) - { - if (nameIsEmpty) - kdError() << "The key '" << key << "' can not be used as name for the entry because " - "it does not result in a unique name. You need to specify a unique name for this entry." << endl; - else - kdError() << "The name '" << name << "' is not unique." << endl; - return 0; - } - allNames.append(name); - - if (!defaultCode) - { - preProcessDefault(defaultValue, name, type, choices, code); - } - - CfgEntry *result = new CfgEntry( group, type, key, name, label, whatsThis, - code, defaultValue, choices, - hidden == "true" ); - if (!param.isEmpty()) - { - result->setParam(param); - result->setParamName(paramName); - result->setParamType(paramType); - result->setParamValues(paramValues); - result->setParamDefaultValues(paramDefaultValues); - result->setParamMax(paramMax); - } - result->setMinValue(minValue); - result->setMaxValue(maxValue); - - return result; -} - -/** - Return parameter declaration for given type. -*/ -TQString param( const TQString &type ) -{ - if ( type == "String" ) return "const TQString &"; - else if ( type == "StringList" ) return "const TQStringList &"; - else if ( type == "Font" ) return "const TQFont &"; - else if ( type == "Rect" ) return "const TQRect &"; - else if ( type == "Size" ) return "const TQSize &"; - else if ( type == "Color" ) return "const TQColor &"; - else if ( type == "Point" ) return "const TQPoint &"; - else if ( type == "Int" ) return "int"; - else if ( type == "UInt" ) return "uint"; - else if ( type == "Bool" ) return "bool"; - else if ( type == "Double" ) return "double"; - else if ( type == "DateTime" ) return "const TQDateTime &"; - else if ( type == "Int64" ) return "TQ_INT64"; - else if ( type == "UInt64" ) return "TQ_UINT64"; - else if ( type == "IntList" ) return "const TQValueList<int> &"; - else if ( type == "Enum" ) return "int"; - else if ( type == "Path" ) return "const TQString &"; - else if ( type == "PathList" ) return "const TQStringList &"; - else if ( type == "Password" ) return "const TQString &"; - else { - kdError() <<"kconfig_compiler does not support type \""<< type <<"\""<<endl; - return TQSTRING_OBJECT_NAME_STRING; //For now, but an assert would be better - } -} - -/** - Actual C++ storage type for given type. -*/ -TQString cppType( const TQString &type ) -{ - if ( type == "String" ) return TQSTRING_OBJECT_NAME_STRING; - else if ( type == "StringList" ) return TQSTRINGLIST_OBJECT_NAME_STRING; - else if ( type == "Font" ) return "TQFont"; - else if ( type == "Rect" ) return "TQRect"; - else if ( type == "Size" ) return "TQSize"; - else if ( type == "Color" ) return "TQColor"; - else if ( type == "Point" ) return TQPOINT_OBJECT_NAME_STRING; - else if ( type == "Int" ) return "int"; - else if ( type == "UInt" ) return "uint"; - else if ( type == "Bool" ) return "bool"; - else if ( type == "Double" ) return "double"; - else if ( type == "DateTime" ) return "TQDateTime"; - else if ( type == "Int64" ) return "TQ_INT64"; - else if ( type == "UInt64" ) return "TQ_UINT64"; - else if ( type == "IntList" ) return "TQValueList<int>"; - else if ( type == "Enum" ) return "int"; - else if ( type == "Path" ) return TQSTRING_OBJECT_NAME_STRING; - else if ( type == "PathList" ) return TQSTRINGLIST_OBJECT_NAME_STRING; - else if ( type == "Password" ) return TQSTRING_OBJECT_NAME_STRING; - else { - kdError()<<"kconfig_compiler does not support type \""<< type <<"\""<<endl; - return TQSTRING_OBJECT_NAME_STRING; //For now, but an assert would be better - } -} - -TQString defaultValue( const TQString &type ) -{ - if ( type == "String" ) return "\"\""; // Use empty string, not null string! - else if ( type == "StringList" ) return "TQStringList()"; - else if ( type == "Font" ) return "KGlobalSettings::generalFont()"; - else if ( type == "Rect" ) return "TQRect()"; - else if ( type == "Size" ) return "TQSize()"; - else if ( type == "Color" ) return "TQColor(128, 128, 128)"; - else if ( type == "Point" ) return "TQPoint()"; - else if ( type == "Int" ) return "0"; - else if ( type == "UInt" ) return "0"; - else if ( type == "Bool" ) return "false"; - else if ( type == "Double" ) return "0.0"; - else if ( type == "DateTime" ) return "TQDateTime()"; - else if ( type == "Int64" ) return "0"; - else if ( type == "UInt64" ) return "0"; - else if ( type == "IntList" ) return "TQValueList<int>()"; - else if ( type == "Enum" ) return "0"; - else if ( type == "Path" ) return "\"\""; // Use empty string, not null string! - else if ( type == "PathList" ) return "TQStringList()"; - else if ( type == "Password" ) return "\"\""; // Use empty string, not null string! - else { - kdWarning()<<"Error, kconfig_compiler doesn't support the \""<< type <<"\" type!"<<endl; - return TQSTRING_OBJECT_NAME_STRING; //For now, but an assert would be better - } -} - -TQString itemType( const TQString &type ) -{ - TQString t; - - t = type; - t.replace( 0, 1, t.left( 1 ).upper() ); - - return t; -} - -static TQString itemDeclaration(const CfgEntry *e) -{ - if (itemAccessors) - return TQString(); - - TQString fCap = e->name(); - fCap[0] = fCap[0].upper(); - return " KConfigSkeleton::Item"+itemType( e->type() ) + - " *item" + fCap + - ( (!e->param().isEmpty())?(TQString("[%1]").arg(e->paramMax()+1)) : TQString()) + - ";\n"; -} - -// returns the name of an item variable -// use itemPath to know the full path -// like using d-> in case of dpointer -static TQString itemVar(const CfgEntry *e) -{ - TQString result; - if (itemAccessors) - { - if ( !dpointer ) - { - result = "m" + e->name() + "Item"; - result[1] = result[1].upper(); - } - else - { - result = e->name() + "Item"; - result[0] = result[0].lower(); - } - } - else - { - result = "item" + e->name(); - result[4] = result[4].upper(); - } - return result; -} - -static TQString itemPath(const CfgEntry *e) -{ - TQString result; - if ( dpointer ) { - result = "d->"+itemVar(e); - } - else { - result = itemVar(e); - } - return result; -} - -TQString newItem( const TQString &type, const TQString &name, const TQString &key, - const TQString &defaultValue, const TQString ¶m = TQString()) -{ - TQString t = "new KConfigSkeleton::Item" + itemType( type ) + - "( currentGroup(), " + key + ", " + varPath( name ) + param; - if ( type == "Enum" ) t += ", values" + name; - if ( !defaultValue.isEmpty() ) { - t += ", "; - if ( type == "String" ) t += defaultValue; - else t+= defaultValue; - } - t += " );"; - - return t; -} - -TQString paramString(const TQString &s, const CfgEntry *e, int i) -{ - TQString result = s; - TQString needle = "$("+e->param()+")"; - if (result.contains(needle)) - { - TQString tmp; - if (e->paramType() == "Enum") - { - tmp = e->paramValues()[i]; - } - else - { - tmp = TQString::number(i); - } - - result.replace(needle, tmp); - } - return result; -} - -TQString paramString(const TQString &group, const TQValueList<Param> ¶meters) -{ - TQString paramString = group; - TQString arguments; - int i = 1; - for (TQValueList<Param>::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - if (paramString.contains("$("+(*it).name+")")) - { - TQString tmp; - tmp.sprintf("%%%d", i++); - paramString.replace("$("+(*it).name+")", tmp); - arguments += ".arg( mParam"+(*it).name+" )"; - } - } - if (arguments.isEmpty()) - return "TQString::tqfromLatin1( \""+group+"\" )"; - - return "TQString::tqfromLatin1( \""+paramString+"\" )"+arguments; -} - -/* int i is the value of the parameter */ -TQString userTextsFunctions( CfgEntry *e, TQString itemVarStr=TQString(), TQString i=TQString() ) -{ - TQString txt; - if (itemVarStr.isNull()) itemVarStr=itemPath(e); - if ( !e->label().isEmpty() ) { - txt += " " + itemVarStr + "->setLabel( i18n("; - if ( !e->param().isEmpty() ) - txt += quoteString(e->label().replace("$("+e->param()+")", i)); - else - txt+= quoteString(e->label()); - txt+= ") );\n"; - } - if ( !e->whatsThis().isEmpty() ) { - txt += " " + itemVarStr + "->setWhatsThis( i18n("; - if ( !e->param().isEmpty() ) - txt += quoteString(e->whatsThis().replace("$("+e->param()+")", i)); - else - txt+= quoteString(e->whatsThis()); - txt+=") );\n"; - } - return txt; -} - -// returns the member accesor implementation -// which should go in the h file if inline -// or the cpp file if not inline -TQString memberAccessorBody( CfgEntry *e ) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - TQString n = e->name(); - TQString t = e->type(); - - out << "return " << This << varPath(n); - if (!e->param().isEmpty()) out << "[i]"; - out << ";" << endl; - - return result; -} - -// returns the member mutator implementation -// which should go in the h file if inline -// or the cpp file if not inline -TQString memberMutatorBody( CfgEntry *e ) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - TQString n = e->name(); - TQString t = e->type(); - - if (!e->minValue().isEmpty()) - { - out << "if (v < " << e->minValue() << ")" << endl; - out << "{" << endl; - out << " kdDebug() << \"" << setFunction(n); - out << ": value \" << v << \" is less than the minimum value of "; - out << e->minValue()<< "\" << endl;" << endl; - out << " v = " << e->minValue() << ";" << endl; - out << "}" << endl; - } - - if (!e->maxValue().isEmpty()) - { - out << endl << "if (v > " << e->maxValue() << ")" << endl; - out << "{" << endl; - out << " kdDebug() << \"" << setFunction(n); - out << ": value \" << v << \" is greater than the maximum value of "; - out << e->maxValue()<< "\" << endl;" << endl; - out << " v = " << e->maxValue() << ";" << endl; - out << "}" << endl << endl; - } - - out << "if (!" << This << "isImmutable( TQString::tqfromLatin1( \""; - if (!e->param().isEmpty()) - { - out << e->paramName().replace("$("+e->param()+")", "%1") << "\" ).arg( "; - if ( e->paramType() == "Enum" ) { - out << "TQString::tqfromLatin1( "; - - if (globalEnums) - out << enumName(e->param()) << "ToString[i]"; - else - out << enumName(e->param()) << "::enumToString[i]"; - - out << " )"; - } - else - { - out << "i"; - } - out << " )"; - } - else - { - out << n << "\" )"; - } - out << " ))" << endl; - out << " " << This << varPath(n); - if (!e->param().isEmpty()) - out << "[i]"; - out << " = v;" << endl; - - return result; -} - -// returns the item accesor implementation -// which should go in the h file if inline -// or the cpp file if not inline -TQString itemAccessorBody( CfgEntry *e ) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - - out << "return " << itemPath(e); - if (!e->param().isEmpty()) out << "[i]"; - out << ";" << endl; - - return result; -} - -//indents text adding X spaces per line -TQString indent(TQString text, int spaces) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - TQTextStream in(&text, IO_ReadOnly); - TQString currLine; - while ( !in.atEnd() ) - { - currLine = in.readLine(); - if (!currLine.isEmpty()) - for (int i=0; i < spaces; i++) - out << " "; - out << currLine << endl; - } - return result; -} - - -int main( int argc, char **argv ) -{ - KAboutData aboutData( "kconfig_compiler", I18N_NOOP("KDE .kcfg compiler"), "0.3", - I18N_NOOP("KConfig Compiler") , KAboutData::License_LGPL ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - aboutData.addAuthor( "Waldo Bastian", 0, "bastian@kde.org" ); - aboutData.addAuthor( "Zack Rusin", 0, "zack@kde.org" ); - aboutData.addCredit( "Reinhold Kainhofer", "Fix for parametrized entries", - "reinhold@kainhofer.com", "http://reinhold.kainhofer.com" ); - aboutData.addCredit( "Duncan Mac-Vicar P.", "dpointer support", - "duncan@kde.org", "http://www.mac-vicar.com/~duncan" ); - - KCmdLineArgs::init( argc, argv, &aboutData ); - KCmdLineArgs::addCmdLineOptions( options ); - - KInstance app( &aboutData ); - - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - if ( args->count() < 2 ) { - kdError() << "Too few arguments." << endl; - return 1; - } - if ( args->count() > 2 ) { - kdError() << "Too many arguments." << endl; - return 1; - } - - validNameRegexp = new TQRegExp("[a-zA-Z_][a-zA-Z0-9_]*"); - - TQString baseDir = TQFile::decodeName(args->getOption("directory")); - if (!baseDir.endsWith("/")) - baseDir.append("/"); - - TQString inputFilename = args->url( 0 ).path(); - TQString codegenFilename = args->url( 1 ).path(); - - if (!codegenFilename.endsWith(".kcfgc")) - { - kdError() << "Codegen options file must have extension .kcfgc" << endl; - return 1; - } - TQString baseName = args->url( 1 ).fileName(); - baseName = baseName.left(baseName.length() - 6); - - KSimpleConfig codegenConfig( codegenFilename, true ); - - TQString nameSpace = codegenConfig.readEntry("NameSpace"); - TQString className = codegenConfig.readEntry("ClassName"); - TQString inherits = codegenConfig.readEntry("Inherits"); - TQString visibility = codegenConfig.readEntry("Visibility"); - if (!visibility.isEmpty()) visibility+=" "; - bool singleton = codegenConfig.readBoolEntry("Singleton", false); - bool staticAccessors = singleton; - //bool useDPointer = codegenConfig.readBoolEntry("DPointer", false); - bool customAddons = codegenConfig.readBoolEntry("CustomAdditions"); - TQString memberVariables = codegenConfig.readEntry("MemberVariables"); - TQStringList headerIncludes = codegenConfig.readListEntry("IncludeFiles"); - TQStringList mutators = codegenConfig.readListEntry("Mutators"); - bool allMutators = false; - if ((mutators.count() == 1) && (mutators[0].lower() == "true")) - allMutators = true; - itemAccessors = codegenConfig.readBoolEntry( "ItemAccessors", false ); - bool setUserTexts = codegenConfig.readBoolEntry( "SetUserTexts", false ); - - globalEnums = codegenConfig.readBoolEntry( "GlobalEnums", false ); - - dpointer = (memberVariables == "dpointer"); - - TQFile input( inputFilename ); - - TQDomDocument doc; - TQString errorMsg; - int errorRow; - int errorCol; - if ( !doc.setContent( &input, &errorMsg, &errorRow, &errorCol ) ) { - kdError() << "Unable to load document." << endl; - kdError() << "Parse error in " << args->url( 0 ).fileName() << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg << endl; - return 1; - } - - TQDomElement cfgElement = doc.documentElement(); - - if ( cfgElement.isNull() ) { - kdError() << "No document in kcfg file" << endl; - return 1; - } - - TQString cfgFileName; - bool cfgFileNameArg = false; - TQValueList<Param> parameters; - TQStringList includes; - - TQPtrList<CfgEntry> entries; - entries.setAutoDelete( true ); - - TQDomNode n; - for ( n = cfgElement.firstChild(); !n.isNull(); n = n.nextSibling() ) { - TQDomElement e = n.toElement(); - - TQString tag = e.tagName(); - - if ( tag == "include" ) { - TQString includeFile = e.text(); - if (!includeFile.isEmpty()) - includes.append(includeFile); - - } else if ( tag == "kcfgfile" ) { - cfgFileName = e.attribute( "name" ); - cfgFileNameArg = e.attribute( "arg" ).lower() == "true"; - TQDomNode n2; - for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if ( e2.tagName() == "parameter" ) { - Param p; - p.name = e2.attribute( "name" ); - p.type = e2.attribute( "type" ); - if (p.type.isEmpty()) - p.type = "String"; - parameters.append( p ); - } - } - - } else if ( tag == "group" ) { - TQString group = e.attribute( "name" ); - if ( group.isEmpty() ) { - kdError() << "Group without name" << endl; - return 1; - } - TQDomNode n2; - for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if ( e2.tagName() != "entry" ) continue; - CfgEntry *entry = parseEntry( group, e2 ); - if ( entry ) entries.append( entry ); - else { - kdError() << "Can't parse entry." << endl; - return 1; - } - } - } - } - - if ( inherits.isEmpty() ) inherits = "KConfigSkeleton"; - - if ( className.isEmpty() ) { - kdError() << "Class name missing" << endl; - return 1; - } - - if ( singleton && !parameters.isEmpty() ) { - kdError() << "Singleton class can not have parameters" << endl; - return 1; - } - - if ( !cfgFileName.isEmpty() && cfgFileNameArg) - { - kdError() << "Having both a fixed filename and a filename as argument is not possible." << endl; - return 1; - } - - if ( entries.isEmpty() ) { - kdWarning() << "No entries." << endl; - } - -#if 0 - CfgEntry *cfg; - for( cfg = entries.first(); cfg; cfg = entries.next() ) { - cfg->dump(); - } -#endif - - TQString headerFileName = baseName + ".h"; - TQString implementationFileName = baseName + ".cpp"; - TQString cppPreamble; // code to be inserted at the beginnin of the cpp file, e.g. initialization of static values - - TQFile header( baseDir + headerFileName ); - if ( !header.open( IO_WriteOnly ) ) { - kdError() << "Can't open '" << headerFileName << "' for writing." << endl; - return 1; - } - - TQTextStream h( &header ); - - h << "// This file is generated by kconfig_compiler from " << args->url(0).fileName() << "." << endl; - h << "// All changes you do to this file will be lost." << endl; - - h << "#ifndef " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" ) - << className.upper() << "_H" << endl; - h << "#define " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" ) - << className.upper() << "_H" << endl << endl; - - // Includes - TQStringList::ConstIterator it; - for( it = headerIncludes.begin(); it != headerIncludes.end(); ++it ) { - h << "#include <" << *it << ">" << endl; - } - - if ( headerIncludes.count() > 0 ) h << endl; - - if ( !singleton && cfgFileNameArg && parameters.isEmpty() ) - h << "#include <kglobal.h>" << endl; - - h << "#include <kconfigskeleton.h>" << endl; - h << "#include <kdebug.h>" << endl << endl; - - // Includes - for( it = includes.begin(); it != includes.end(); ++it ) { - h << "#include <" << *it << ">" << endl; - } - - - if ( !nameSpace.isEmpty() ) - h << "namespace " << nameSpace << " {" << endl << endl; - - // Private class declaration - if ( dpointer ) - h << "class " << className << "Private;" << endl << endl; - - // Class declaration header - h << "class " << visibility << className << " : public " << inherits << endl; - h << "{" << endl; - h << " public:" << endl; - - // enums - CfgEntry *e; - for( e = entries.first(); e; e = entries.next() ) { - TQValueList<CfgEntry::Choice> choices = e->choices(); - if ( !choices.isEmpty() ) { - TQStringList values; - TQValueList<CfgEntry::Choice>::ConstIterator itChoice; - for( itChoice = choices.begin(); itChoice != choices.end(); ++itChoice ) { - values.append( (*itChoice).name ); - } - if ( globalEnums ) { - h << " enum { " << values.join( ", " ) << " };" << endl; - } else { - h << " class " << enumName(e->name()) << endl; - h << " {" << endl; - h << " public:" << endl; - h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl; - h << " };" << endl; - } - } - TQStringList values = e->paramValues(); - if ( !values.isEmpty() ) { - if ( globalEnums ) { - h << " enum { " << values.join( ", " ) << " };" << endl; - h << " static const char* const " << enumName(e->param()) << "ToString[];" << endl; - cppPreamble += "const char* const " + className + "::" + enumName(e->param()) + "ToString[] = " + - "{ \"" + values.join( "\", \"" ) + "\" };\n"; - } else { - h << " class " << enumName(e->param()) << endl; - h << " {" << endl; - h << " public:" << endl; - h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl; - h << " static const char* const enumToString[];" << endl; - h << " };" << endl; - cppPreamble += "const char* const " + className + "::" + enumName(e->param()) + "::enumToString[] = " + - "{ \"" + values.join( "\", \"" ) + "\" };\n"; - } - } - } - - h << endl; - - // Constructor or singleton accessor - if ( !singleton ) { - h << " " << className << "("; - if (cfgFileNameArg) - h << " KSharedConfig::Ptr config" << (parameters.isEmpty() ? " = KGlobal::sharedConfig()" : ", "); - for (TQValueList<Param>::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - if (it != parameters.begin()) - h << ","; - h << " " << param((*it).type) << " " << (*it).name; - } - h << " );" << endl; - } else { - h << " static " << className << " *self();" << endl; - if (cfgFileNameArg) - h << " static void instance(const char * cfgfilename);" << endl; - } - - // Destructor - h << " ~" << className << "();" << endl << endl; - - // global variables - if (staticAccessors) - This = "self()->"; - else - Const = " const"; - - for( e = entries.first(); e; e = entries.next() ) { - TQString n = e->name(); - TQString t = e->type(); - - // Manipulator - if (allMutators || mutators.contains(n)) - { - h << " /**" << endl; - h << " Set " << e->label() << endl; - h << " */" << endl; - if (staticAccessors) - h << " static" << endl; - h << " void " << setFunction(n) << "( "; - if (!e->param().isEmpty()) - h << cppType(e->paramType()) << " i, "; - h << param( t ) << " v )"; - // function body inline only if not using dpointer - // for BC mode - if ( !dpointer ) - { - h << endl << " {" << endl; - h << indent(memberMutatorBody(e), 6 ); - h << " }" << endl; - } - else - { - h << ";" << endl; - } - } - h << endl; - // Accessor - h << " /**" << endl; - h << " Get " << e->label() << endl; - h << " */" << endl; - if (staticAccessors) - h << " static" << endl; - h << " " << cppType(t) << " " << getFunction(n) << "("; - if (!e->param().isEmpty()) - h << " " << cppType(e->paramType()) <<" i "; - h << ")" << Const; - // function body inline only if not using dpointer - // for BC mode - if ( !dpointer ) - { - h << endl << " {" << endl; - h << indent(memberAccessorBody(e), 6 ); - h << " }" << endl; - } - else - { - h << ";" << endl; - } - - // Item accessor - if ( itemAccessors ) { - h << endl; - h << " /**" << endl; - h << " Get Item object corresponding to " << n << "()" - << endl; - h << " */" << endl; - h << " Item" << itemType( e->type() ) << " *" - << getFunction( n ) << "Item("; - if (!e->param().isEmpty()) { - h << " " << cppType(e->paramType()) << " i "; - } - h << ")"; - if (! dpointer ) - { - h << endl << " {" << endl; - h << indent( itemAccessorBody(e), 6); - h << " }" << endl; - } - else - { - h << ";" << endl; - } - } - - h << endl; - } - - // Static writeConfig method for singleton - if ( singleton ) { - h << " static" << endl; - h << " void writeConfig()" << endl; - h << " {" << endl; - h << " static_cast<KConfigSkeleton*>(self())->writeConfig();" << endl; - h << " }" << endl; - } - - h << " protected:" << endl; - - // Private constructor for singleton - if ( singleton ) { - h << " " << className << "("; - if ( cfgFileNameArg ) - h << "const char *arg"; - h << ");" << endl; - h << " static " << className << " *mSelf;" << endl << endl; - } - - // Member variables - if ( !memberVariables.isEmpty() && memberVariables != "private" && memberVariables != "dpointer") { - h << " " << memberVariables << ":" << endl; - } - - // Class Parameters - for (TQValueList<Param>::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - h << " " << cppType((*it).type) << " mParam" << (*it).name << ";" << endl; - } - - if ( memberVariables != "dpointer" ) - { - TQString group; - for( e = entries.first(); e; e = entries.next() ) { - if ( e->group() != group ) { - group = e->group(); - h << endl; - h << " // " << group << endl; - } - h << " " << cppType(e->type()) << " " << varName(e->name()); - if (!e->param().isEmpty()) - { - h << TQString("[%1]").arg(e->paramMax()+1); - } - h << ";" << endl; - } - - h << endl << " private:" << endl; - if ( itemAccessors ) { - for( e = entries.first(); e; e = entries.next() ) { - h << " Item" << itemType( e->type() ) << " *" << itemVar( e ); - if (!e->param().isEmpty() ) h << TQString("[%1]").arg( e->paramMax()+1 ); - h << ";" << endl; - } - } - - } - else - { - // use a private class for both member variables and items - h << " private:" << endl; - h << " " + className + "Private *d;" << endl; - } - - if (customAddons) - { - h << " // Include custom additions" << endl; - h << " #include \"" << filenameOnly(baseName) << "_addons.h\"" <<endl; - } - - h << "};" << endl << endl; - - if ( !nameSpace.isEmpty() ) h << "}" << endl << endl; - - h << "#endif" << endl << endl; - - - header.close(); - - TQFile implementation( baseDir + implementationFileName ); - if ( !implementation.open( IO_WriteOnly ) ) { - kdError() << "Can't open '" << implementationFileName << "' for writing." - << endl; - return 1; - } - - TQTextStream cpp( &implementation ); - - - cpp << "// This file is generated by kconfig_compiler from " << args->url(0).fileName() << "." << endl; - cpp << "// All changes you do to this file will be lost." << endl << endl; - - cpp << "#include \"" << headerFileName << "\"" << endl << endl; - - if ( setUserTexts ) cpp << "#include <klocale.h>" << endl << endl; - - // Header required by singleton implementation - if ( singleton ) - cpp << "#include <kstaticdeleter.h>" << endl << endl; - if ( singleton && cfgFileNameArg ) - cpp << "#include <kdebug.h>" << endl << endl; - - if ( !nameSpace.isEmpty() ) - cpp << "using namespace " << nameSpace << ";" << endl << endl; - - TQString group; - - // private class implementation - if ( dpointer ) - { - cpp << "class " << className << "Private" << endl; - cpp << "{" << endl; - cpp << " public:" << endl; - for( e = entries.first(); e; e = entries.next() ) { - if ( e->group() != group ) { - group = e->group(); - cpp << endl; - cpp << " // " << group << endl; - } - cpp << " " << cppType(e->type()) << " " << varName(e->name()); - if (!e->param().isEmpty()) - { - cpp << TQString("[%1]").arg(e->paramMax()+1); - } - cpp << ";" << endl; - } - cpp << endl << " // items" << endl; - for( e = entries.first(); e; e = entries.next() ) { - cpp << " KConfigSkeleton::Item" << itemType( e->type() ) << " *" << itemVar( e ); - if (!e->param().isEmpty() ) cpp << TQString("[%1]").arg( e->paramMax()+1 ); - cpp << ";" << endl; - } - - cpp << "};" << endl << endl; - } - - // Singleton implementation - if ( singleton ) { - cpp << className << " *" << className << "::mSelf = 0;" << endl; - cpp << "static KStaticDeleter<" << className << "> static" << className << "Deleter;" << endl << endl; - - cpp << className << " *" << className << "::self()" << endl; - cpp << "{" << endl; - if ( cfgFileNameArg ) { - cpp << " if (!mSelf)" << endl; - cpp << " kdFatal() << \"you need to call " << className << "::instance before using\" << endl;" << endl; - } else { - cpp << " if ( !mSelf ) {" << endl; - cpp << " static" << className << "Deleter.setObject( mSelf, new " << className << "() );" << endl; - cpp << " mSelf->readConfig();" << endl; - cpp << " }" << endl << endl; - } - cpp << " return mSelf;" << endl; - cpp << "}" << endl << endl; - - if ( cfgFileNameArg ) { - cpp << "void " << className << "::instance(const char *cfgfilename)" << endl; - cpp << "{" << endl; - cpp << " if (mSelf) {" << endl; - cpp << " kdError() << \"" << className << "::instance called after the first use - ignoring\" << endl;" << endl; - cpp << " return;" << endl; - cpp << " }" << endl; - cpp << " static" << className << "Deleter.setObject( mSelf, new " << className << "(cfgfilename) );" << endl; - cpp << " mSelf->readConfig();" << endl; - cpp << "}" << endl << endl; - } - } - - if ( !cppPreamble.isEmpty() ) - cpp << cppPreamble << endl; - - // Constructor - cpp << className << "::" << className << "( "; - if ( cfgFileNameArg ) { - if ( !singleton ) - cpp << " KSharedConfig::Ptr config"; - else - cpp << " const char *config"; - cpp << (parameters.isEmpty() ? " " : ", "); - } - - for (TQValueList<Param>::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - if (it != parameters.begin()) - cpp << ","; - cpp << " " << param((*it).type) << " " << (*it).name; - } - cpp << " )" << endl; - - cpp << " : " << inherits << "("; - if ( !cfgFileName.isEmpty() ) cpp << " TQString::tqfromLatin1( \"" << cfgFileName << "\" "; - if ( cfgFileNameArg ) cpp << " config "; - if ( !cfgFileName.isEmpty() ) cpp << ") "; - cpp << ")" << endl; - - // Store parameters - for (TQValueList<Param>::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - cpp << " , mParam" << (*it).name << "(" << (*it).name << ")" << endl; - } - - cpp << "{" << endl; - - if (dpointer) - cpp << " d = new " + className + "Private;" << endl; - // Needed in case the singleton class is used as baseclass for - // another singleton. - if ( singleton ) - cpp << " mSelf = this;" << endl; - - group = TQString(); - for( e = entries.first(); e; e = entries.next() ) { - if ( e->group() != group ) { - if ( !group.isEmpty() ) cpp << endl; - group = e->group(); - cpp << " setCurrentGroup( " << paramString(group, parameters) << " );" << endl << endl; - } - - TQString key = paramString(e->key(), parameters); - if ( !e->code().isEmpty()) - { - cpp << e->code() << endl; - } - if ( e->type() == "Enum" ) { - cpp << " TQValueList<KConfigSkeleton::ItemEnum::Choice> values" - << e->name() << ";" << endl; - TQValueList<CfgEntry::Choice> choices = e->choices(); - TQValueList<CfgEntry::Choice>::ConstIterator it; - for( it = choices.begin(); it != choices.end(); ++it ) { - cpp << " {" << endl; - cpp << " KConfigSkeleton::ItemEnum::Choice choice;" << endl; - cpp << " choice.name = TQString::tqfromLatin1( \"" << (*it).name << "\" );" << endl; - if ( setUserTexts ) { - if ( !(*it).label.isEmpty() ) - cpp << " choice.label = i18n(" << quoteString((*it).label) << ");" << endl; - if ( !(*it).whatsThis.isEmpty() ) - cpp << " choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ");" << endl; - } - cpp << " values" << e->name() << ".append( choice );" << endl; - cpp << " }" << endl; - } - } - - if (!dpointer) - cpp << itemDeclaration(e); - - if (e->param().isEmpty()) - { - // Normal case - cpp << " " << itemPath(e) << " = " - << newItem( e->type(), e->name(), key, e->defaultValue() ) << endl; - - if ( !e->minValue().isEmpty() ) - cpp << " " << itemPath(e) << "->setMinValue(" << e->minValue() << ");" << endl; - if ( !e->maxValue().isEmpty() ) - cpp << " " << itemPath(e) << "->setMaxValue(" << e->maxValue() << ");" << endl; - - if ( setUserTexts ) - cpp << userTextsFunctions( e ); - - cpp << " addItem( " << itemPath(e); - TQString quotedName = e->name(); - addQuotes( quotedName ); - if ( quotedName != key ) cpp << ", TQString::tqfromLatin1( \"" << e->name() << "\" )"; - cpp << " );" << endl; - } - else - { - // Indexed - for(int i = 0; i <= e->paramMax(); i++) - { - TQString defaultStr; - TQString itemVarStr(itemPath(e)+TQString("[%1]").arg(i)); - - if ( !e->paramDefaultValue(i).isEmpty() ) - defaultStr = e->paramDefaultValue(i); - else if ( !e->defaultValue().isEmpty() ) - defaultStr = paramString(e->defaultValue(), e, i); - else - defaultStr = defaultValue( e->type() ); - - cpp << " " << itemVarStr << " = " - << newItem( e->type(), e->name(), paramString(key, e, i), defaultStr, TQString("[%1]").arg(i) ) - << endl; - - if ( setUserTexts ) - cpp << userTextsFunctions( e, itemVarStr, e->paramName() ); - - // Make mutators for enum parameters work by adding them with $(..) replaced by the - // param name. The check for isImmutable in the set* functions doesn't have the param - // name available, just the corresponding enum value (int), so we need to store the - // param names in a separate static list!. - cpp << " addItem( " << itemVarStr << ", TQString::tqfromLatin1( \""; - if ( e->paramType()=="Enum" ) - cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(e->paramValues()[i] ); - else - cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(i); - cpp << "\" ) );" << endl; - } - } - } - - cpp << "}" << endl << endl; - - if (dpointer) - { - // setters and getters go in Cpp if in dpointer mode - for( e = entries.first(); e; e = entries.next() ) - { - TQString n = e->name(); - TQString t = e->type(); - - // Manipulator - if (allMutators || mutators.contains(n)) - { - cpp << "void " << setFunction(n, className) << "( "; - if (!e->param().isEmpty()) - cpp << cppType(e->paramType()) << " i, "; - cpp << param( t ) << " v )" << endl; - // function body inline only if not using dpointer - // for BC mode - cpp << "{" << endl; - cpp << indent(memberMutatorBody(e), 6); - cpp << "}" << endl << endl; - } - - // Accessor - cpp << cppType(t) << " " << getFunction(n, className) << "("; - if (!e->param().isEmpty()) - cpp << " " << cppType(e->paramType()) <<" i "; - cpp << ")" << Const << endl; - // function body inline only if not using dpointer - // for BC mode - cpp << "{" << endl; - cpp << indent(memberAccessorBody(e), 2); - cpp << "}" << endl << endl; - - // Item accessor - if ( itemAccessors ) - { - cpp << endl; - cpp << "KConfigSkeleton::Item" << itemType( e->type() ) << " *" - << getFunction( n, className ) << "Item("; - if (!e->param().isEmpty()) { - cpp << " " << cppType(e->paramType()) << " i "; - } - cpp << ")" << endl; - cpp << "{" << endl; - cpp << indent(itemAccessorBody(e), 2); - cpp << "}" << endl; - } - - cpp << endl; - } - } - - // Destructor - cpp << className << "::~" << className << "()" << endl; - cpp << "{" << endl; - if ( singleton ) { - if ( dpointer ) - cpp << " delete d;" << endl; - cpp << " if ( mSelf == this )" << endl; - cpp << " static" << className << "Deleter.setObject( mSelf, 0, false );" << endl; - } - cpp << "}" << endl << endl; - - implementation.close(); -} diff --git a/kdecore/kconfig_compiler/tests/Makefile.am b/kdecore/kconfig_compiler/tests/Makefile.am deleted file mode 100644 index 0b47449fa..000000000 --- a/kdecore/kconfig_compiler/tests/Makefile.am +++ /dev/null @@ -1,134 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir)/kunittest $(all_includes) -DQT_NO_CAST_ASCII -DSRCDIR=\"$(srcdir)\" - -check_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test_dpointer - -CLEANFILES = test1.cpp test1.h \ - test2.cpp test2.h \ - test3.cpp test3.h \ - test4.cpp test4.h \ - test5.cpp test5.h \ - test6.cpp test6.h \ - test7.cpp test7.h \ - test8a.cpp test8a.h test8b.cpp test8b.h \ - test9.cpp test9.h \ - test_dpointer.cpp test_dpointer.h \ - md5sums - -test1_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test1_LDADD = $(LIB_KDECORE) -test1_SOURCES = test1main.cpp test1.cpp - -test2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test2_LDADD = $(LIB_KDECORE) -test2_SOURCES = test2main.cpp test2.cpp - -test3_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test3_LDADD = $(LIB_KDECORE) -test3_SOURCES = test3main.cpp test3.cpp - -test4_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test4_LDADD = $(LIB_KDECORE) -test4_SOURCES = test4main.cpp test4.cpp - -test5_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test5_LDADD = $(LIB_KDECORE) -test5_SOURCES = test5main.cpp test5.cpp - -test6_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test6_LDADD = $(LIB_KDECORE) -test6_SOURCES = test6main.cpp test6.cpp - -test7_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test7_LDADD = $(LIB_KDECORE) -test7_SOURCES = test7main.cpp test7.cpp - -test8_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test8_LDADD = $(LIB_KDECORE) -test8_SOURCES = test8main.cpp test8a.cpp test8b.cpp - -test9_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test9_LDADD = $(LIB_KDECORE) -test9_SOURCES = test9main.cpp test9.cpp - -test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor -test_dpointer_LDADD = $(LIB_KDECORE) -test_dpointer_SOURCES = test_dpointer_main.cpp test_dpointer.cpp - -check_LTLIBRARIES = kunittest_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) \ - $(all_libraries) - - -test1main.o test1.o: test1.h -# avoid running the below command in parallel -test1.cpp: test1.h -test1.cpp test1.h: $(srcdir)/test1.kcfg ../kconfig_compiler $(srcdir)/test1.kcfgc - ../kconfig_compiler $(srcdir)/test1.kcfg $(srcdir)/test1.kcfgc - -test2main.o test2.o: test2.h -# avoid running the below command in parallel -test2.cpp: test2.h -test2.cpp test2.h: $(srcdir)/test2.kcfg ../kconfig_compiler $(srcdir)/test2.kcfgc - ../kconfig_compiler $(srcdir)/test2.kcfg $(srcdir)/test2.kcfgc - -test3main.o test3.o: test3.h -# avoid running the below command in parallel -test3.cpp: test3.h -test3.cpp test3.h: $(srcdir)/test3.kcfg ../kconfig_compiler $(srcdir)/test3.kcfgc - ../kconfig_compiler $(srcdir)/test3.kcfg $(srcdir)/test3.kcfgc - -test4main.o test4.o: test4.h -# avoid running the below command in parallel -test4.cpp: test4.h -test4.cpp test4.h: $(srcdir)/test4.kcfg ../kconfig_compiler $(srcdir)/test4.kcfgc - ../kconfig_compiler $(srcdir)/test4.kcfg $(srcdir)/test4.kcfgc - -test5main.o test5.o: test5.h -# avoid running the below command in parallel -test5.cpp: test5.h -test5.cpp test5.h: $(srcdir)/test5.kcfg ../kconfig_compiler $(srcdir)/test5.kcfgc - ../kconfig_compiler $(srcdir)/test5.kcfg $(srcdir)/test5.kcfgc - -test6main.o test6.o: test6.h -# avoid running the below command in parallel -test6.cpp: test6.h -test6.cpp test6.h: $(srcdir)/test6.kcfg ../kconfig_compiler $(srcdir)/test6.kcfgc - ../kconfig_compiler $(srcdir)/test6.kcfg $(srcdir)/test6.kcfgc - -test7main.o test7.o: test7.h -# avoid running the below command in parallel -test7.cpp: test7.h -test7.cpp test7.h: $(srcdir)/test7.kcfg ../kconfig_compiler $(srcdir)/test7.kcfgc - ../kconfig_compiler $(srcdir)/test7.kcfg $(srcdir)/test7.kcfgc - -test8main.o test8a.o test8b.o: test8a.h test8b.h -# avoid running the below command in parallel -test8a.cpp: test8a.h -test8a.cpp test8a.h: $(srcdir)/test8a.kcfg ../kconfig_compiler $(srcdir)/test8a.kcfgc - ../kconfig_compiler $(srcdir)/test8a.kcfg $(srcdir)/test8a.kcfgc -test8b.cpp: test8b.h -test8b.cpp test8b.h: $(srcdir)/test8b.kcfg ../kconfig_compiler $(srcdir)/test8b.kcfgc - ../kconfig_compiler $(srcdir)/test8b.kcfg $(srcdir)/test8b.kcfgc - -test9main.o test9.o: test9.h -# avoid running the below command in parallel -test9.cpp: test9.h -test9.cpp test9.h: $(srcdir)/test9.kcfg ../kconfig_compiler $(srcdir)/test9.kcfgc - ../kconfig_compiler $(srcdir)/test9.kcfg $(srcdir)/test9.kcfgc - -test_dpointer_main.o test_dpointer.o: test_dpointer.h -# avoid running the below command in parallel -test_dpointer.cpp: test_dpointer.h -test_dpointer.cpp test_dpointer.h: $(srcdir)/test_dpointer.kcfg ../kconfig_compiler $(srcdir)/test_dpointer.kcfgc - ../kconfig_compiler $(srcdir)/test_dpointer.kcfg $(srcdir)/test_dpointer.kcfgc - -md5sums: - $(MD5SUM) $(srcdir)/test*.ref | sed -e "s,$(srcdir)/,,; s,\.ref$$,," > md5sums - -md5check: test1.cpp test2.cpp test3.cpp test4.cpp test5.cpp test6.cpp test7.cpp test8a.cpp test8b.cpp test9.cpp md5sums - $(MD5SUM) -c md5sums - diff --git a/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp deleted file mode 100644 index 3dd197b34..000000000 --- a/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - Tests for KConfig Compiler - - Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org> - - ************************************************************************* - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - ************************************************************************* -*/ - -#include <tqfile.h> -#include <tqstring.h> -#include <kdebug.h> -#include <kunittest/module.h> -#include "kconfigcompiler_test.h" - -using namespace KUnitTest; - -KUNITTEST_MODULE( kunittest_kconfigcompiler_test, "KConfigXT") -KUNITTEST_MODULE_REGISTER_TESTER( KConfigCompiler_Test ) - -typedef const char * CompilerTestSet[]; - -static CompilerTestSet testCases = -{ - "test1.cpp", "test1.h", - "test2.cpp", "test2.h", - "test3.cpp", "test3.h", - "test4.cpp", "test4.h", - "test5.cpp", "test5.h", - "test6.cpp", "test6.h", - "test7.cpp", "test7.h", - "test8a.cpp", "test8a.h", - "test8b.cpp", "test8b.h", - "test9.h", "test9.cpp", - "test_dpointer.cpp", "test_dpointer.h", - NULL -}; - -static CompilerTestSet willFailCases = -{ - // where is that TQDir comming from? - //"test9.cpp", NULL - NULL -}; - - -void KConfigCompiler_Test::allTests() -{ - testExpectedOutput(); -} - -void KConfigCompiler_Test::testExpectedOutput() -{ - uint i = 0; - // Known to pass test cases - while (testCases[ i ]) - { - performCompare(TQString::tqfromLatin1(testCases[ i ])); - ++i; - } - - // broken test cases - i= 0; - while (willFailCases[ i ]) - { - performCompare(TQString::tqfromLatin1(willFailCases[ i ]), true); - ++i; - } -} - -void KConfigCompiler_Test::performCompare(const TQString &fileName, bool fail) -{ - TQFile file(fileName); - TQFile fileRef(TQString::tqfromLatin1(SRCDIR) + TQString::tqfromLatin1("/") + fileName + TQString::tqfromLatin1(".ref")); - - if ( file.open(IO_ReadOnly) && fileRef.open(IO_ReadOnly) ) - { - TQString content = file.readAll(); - TQString contentRef = fileRef.readAll(); - - if (!fail) - CHECK( content, contentRef); - else - XFAIL( content, contentRef); - } - else - { - SKIP("Can't open file for comparision"); - } -} diff --git a/kdecore/kconfig_compiler/tests/kconfigcompiler_test.h b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.h deleted file mode 100644 index 36b33cd47..000000000 --- a/kdecore/kconfig_compiler/tests/kconfigcompiler_test.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Tests for KConfig Compiler - - Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org> - - ************************************************************************* - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - ************************************************************************* -*/ - -#ifndef KCONFIGCOMPILER_TEST_H -#define KCONFIGCOMPILER_TEST_H - -#include <kunittest/tester.h> - -class TQString; - -// change to SlotTester when it works -class KConfigCompiler_Test : public KUnitTest::Tester -{ -public: - void allTests(); -public slots: - void testExpectedOutput(); -private: - void performCompare(const TQString &fileName, bool fail=false); -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/myprefs.h b/kdecore/kconfig_compiler/tests/myprefs.h deleted file mode 100644 index ebef89c08..000000000 --- a/kdecore/kconfig_compiler/tests/myprefs.h +++ /dev/null @@ -1,7 +0,0 @@ -#include <kconfigskeleton.h> - -class MyPrefs : public KConfigSkeleton -{ - public: - MyPrefs( const TQString &a ) : KConfigSkeleton( a ) {} -}; diff --git a/kdecore/kconfig_compiler/tests/test1.cpp.ref b/kdecore/kconfig_compiler/tests/test1.cpp.ref deleted file mode 100644 index f8c4c1189..000000000 --- a/kdecore/kconfig_compiler/tests/test1.cpp.ref +++ /dev/null @@ -1,72 +0,0 @@ -// This file is generated by kconfig_compiler from test1.kcfg. -// All changes you do to this file will be lost. - -#include "test1.h" - -Test1::Test1( const TQString & transport, const TQString & folder ) - : KConfigSkeleton( TQString::tqfromLatin1( "examplerc" ) ) - , mParamtransport(transport) - , mParamfolder(folder) -{ - setCurrentGroup( TQString::tqfromLatin1( "General-%1" ).arg( mParamfolder ) ); - - KConfigSkeleton::ItemBool *itemOneOption; - itemOneOption = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "OneOption" ), mOneOption, true ); - addItem( itemOneOption, TQString::tqfromLatin1( "OneOption" ) ); - KConfigSkeleton::ItemInt *itemAnotherOption; - itemAnotherOption = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Another Option" ), mAnotherOption, 5 ); - addItem( itemAnotherOption, TQString::tqfromLatin1( "AnotherOption" ) ); - TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesListOption; - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "One" ); - valuesListOption.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "Two" ); - valuesListOption.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "Three" ); - valuesListOption.append( choice ); - } - KConfigSkeleton::ItemEnum *itemListOption; - itemListOption = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "ListOption" ), mListOption, valuesListOption, EnumListOption::One ); - addItem( itemListOption, TQString::tqfromLatin1( "ListOption" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "MyOptions" ) ); - - KConfigSkeleton::ItemString *itemMyString; - itemMyString = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "MyString" ), mMyString, TQString::tqfromLatin1( "Default String" ) ); - addItem( itemMyString, TQString::tqfromLatin1( "MyString" ) ); - KConfigSkeleton::ItemPath *itemMyPath; - itemMyPath = new KConfigSkeleton::ItemPath( currentGroup(), TQString::tqfromLatin1( "MyPath" ), mMyPath, TQDir::homeDirPath()+TQString::tqfromLatin1(".hidden_file") ); - addItem( itemMyPath, TQString::tqfromLatin1( "MyPath" ) ); - KConfigSkeleton::ItemInt *itemAnotherOption2; - itemAnotherOption2 = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Another Option" ), mAnotherOption2, 10 ); - addItem( itemAnotherOption2, TQString::tqfromLatin1( "AnotherOption2" ) ); - TQStringList defaultMyStringList; - defaultMyStringList.append( TQString::fromUtf8( "up" ) ); - defaultMyStringList.append( TQString::fromUtf8( "down" ) ); - - KConfigSkeleton::ItemStringList *itemMyStringList; - itemMyStringList = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList ); - addItem( itemMyStringList, TQString::tqfromLatin1( "MyStringList" ) ); - TQStringList defaultMyStringListHidden; - defaultMyStringListHidden.append( TQString::fromUtf8( "up" ) ); - defaultMyStringListHidden.append( TQString::fromUtf8( "down" ) ); - - KConfigSkeleton::ItemStringList *itemMyStringListHidden; - itemMyStringListHidden = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden ); - addItem( itemMyStringListHidden, TQString::tqfromLatin1( "MyStringListHidden" ) ); - KConfigSkeleton::ItemInt *itemMyNumber; - itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 ); - addItem( itemMyNumber, TQString::tqfromLatin1( "MyNumber" ) ); -} - -Test1::~Test1() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test1.h.ref b/kdecore/kconfig_compiler/tests/test1.h.ref deleted file mode 100644 index b5a66b5cd..000000000 --- a/kdecore/kconfig_compiler/tests/test1.h.ref +++ /dev/null @@ -1,196 +0,0 @@ -// This file is generated by kconfig_compiler from test1.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST1_H -#define TEST1_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -#include <tqdir.h> -class Test1 : public KConfigSkeleton -{ - public: - class EnumListOption - { - public: - enum type { One, Two, Three, COUNT }; - }; - - Test1( const TQString & transport, const TQString & folder ); - ~Test1(); - - /** - Set One option - */ - void setOneOption( bool v ) - { - if (!isImmutable( TQString::tqfromLatin1( "OneOption" ) )) - mOneOption = v; - } - - /** - Get One option - */ - bool oneOption() const - { - return mOneOption; - } - - /** - Set Another option - */ - void setAnotherOption( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "AnotherOption" ) )) - mAnotherOption = v; - } - - /** - Get Another option - */ - int anotherOption() const - { - return mAnotherOption; - } - - /** - Set This is some funky option - */ - void setListOption( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "ListOption" ) )) - mListOption = v; - } - - /** - Get This is some funky option - */ - int listOption() const - { - return mListOption; - } - - /** - Set This is a string - */ - void setMyString( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyString" ) )) - mMyString = v; - } - - /** - Get This is a string - */ - TQString myString() const - { - return mMyString; - } - - /** - Set This is a path - */ - void setMyPath( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyPath" ) )) - mMyPath = v; - } - - /** - Get This is a path - */ - TQString myPath() const - { - return mMyPath; - } - - /** - Set Another option - */ - void setAnotherOption2( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "AnotherOption2" ) )) - mAnotherOption2 = v; - } - - /** - Get Another option - */ - int anotherOption2() const - { - return mAnotherOption2; - } - - /** - Set MyStringList - */ - void setMyStringList( const TQStringList & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyStringList" ) )) - mMyStringList = v; - } - - /** - Get MyStringList - */ - TQStringList myStringList() const - { - return mMyStringList; - } - - /** - Set MyStringListHidden - */ - void setMyStringListHidden( const TQStringList & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyStringListHidden" ) )) - mMyStringListHidden = v; - } - - /** - Get MyStringListHidden - */ - TQStringList myStringListHidden() const - { - return mMyStringListHidden; - } - - /** - Set List Number - */ - void setMyNumber( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyNumber" ) )) - mMyNumber = v; - } - - /** - Get List Number - */ - int myNumber() const - { - return mMyNumber; - } - - protected: - TQString mParamtransport; - TQString mParamfolder; - - // General-$(folder) - bool mOneOption; - int mAnotherOption; - int mListOption; - - // MyOptions - TQString mMyString; - TQString mMyPath; - int mAnotherOption2; - TQStringList mMyStringList; - TQStringList mMyStringListHidden; - int mMyNumber; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test1.kcfg b/kdecore/kconfig_compiler/tests/test1.kcfg deleted file mode 100644 index ce42aebfb..000000000 --- a/kdecore/kconfig_compiler/tests/test1.kcfg +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <include>qdir.h</include> - <kcfgfile name="examplerc"> - <parameter name="transport" /> - <parameter name="folder" /> - </kcfgfile> - <group name="General-$(folder)"> - <entry name="OneOption" type="Bool"> - <label>One option</label> - <default>true</default> - </entry> - <entry name="AnotherOption" type="Int" key="Another Option"> - <label>Another option</label> - <default>5</default> - </entry> - <entry name="ListOption" type="Enum"> - <label>This is some funky option</label> - <whatsthis>And this is a longer description of this option. Just wondering, how will the translations of those be handled?</whatsthis> - <choices> - <choice name="One"/> - <choice name="Two"/> - <choice name="Three"/> - </choices> - <default>One</default> - </entry> - </group> - <group name="MyOptions"> - <entry name="MyString" type="String"> - <label>This is a string</label> - <default>Default String</default> - </entry> - <entry name="MyPath" type="Path"> - <label>This is a path</label> - <default code="true">QDir::homeDirPath()+QString::fromLatin1(".hidden_file")</default> - </entry> - <entry name="AnotherOption2" type="Int" key="Another Option"> - <label>Another option</label> - <default>10</default> - </entry> - <entry name="MyStringList" type="StringList"> - <default>up,down</default> - </entry> - <entry name="MyStringListHidden" hidden="true" type="StringList"> - <default>up,down</default> - </entry> - <entry name="MyNumber" type="Int" key="List-$(transport)-$(folder)"> - <label>List Number</label> - <default>1</default> - </entry> - </group> -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test1.kcfgc b/kdecore/kconfig_compiler/tests/test1.kcfgc deleted file mode 100644 index 3b74d7c51..000000000 --- a/kdecore/kconfig_compiler/tests/test1.kcfgc +++ /dev/null @@ -1,18 +0,0 @@ -# Code generation options for kconfig_compiler -ClassName=Test1 -# -# Singleton=false -# -# Inherits=KConfigSkeleton -# -# IncludeFiles=libtdepim/kpimprefs.h -# -# MemberVariables=public -# -### The following line includes the file exampleprefs_base_addon.h -### It can be used to add extra functions and variables to the -### class. -# CustomAdditions=true -# -### Provide setFooBar(int) style functions -Mutators=true diff --git a/kdecore/kconfig_compiler/tests/test1main.cpp b/kdecore/kconfig_compiler/tests/test1main.cpp deleted file mode 100644 index 976a7bbd6..000000000 --- a/kdecore/kconfig_compiler/tests/test1main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - -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 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. -*/ -#include "test1.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test1 *t = new Test1( TQString::null, TQString::null ); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test2.cpp.ref b/kdecore/kconfig_compiler/tests/test2.cpp.ref deleted file mode 100644 index af8db588d..000000000 --- a/kdecore/kconfig_compiler/tests/test2.cpp.ref +++ /dev/null @@ -1,98 +0,0 @@ -// This file is generated by kconfig_compiler from test2.kcfg. -// All changes you do to this file will be lost. - -#include "test2.h" - -#include <klocale.h> - -Test2::Test2( ) - : MyPrefs( TQString::tqfromLatin1( "korganizerrc" ) ) -{ - setCurrentGroup( TQString::tqfromLatin1( "General" ) ); - - mAutoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Auto Save" ), mAutoSave, false ); - mAutoSaveItem->setLabel( i18n("Enable automatic saving of calendar") ); - mAutoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") ); - addItem( mAutoSaveItem, TQString::tqfromLatin1( "AutoSave" ) ); - mAutoSaveIntervalItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Auto Save Interval" ), mAutoSaveInterval, 10 ); - mAutoSaveIntervalItem->setLabel( i18n("Auto Save Interval") ); - addItem( mAutoSaveIntervalItem, TQString::tqfromLatin1( "AutoSaveInterval" ) ); - mConfirmItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Confirm Deletes" ), mConfirm, true ); - mConfirmItem->setLabel( i18n("Confirm deletes") ); - addItem( mConfirmItem, TQString::tqfromLatin1( "Confirm" ) ); - mArchiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "Archive File" ), mArchiveFile ); - mArchiveFileItem->setLabel( i18n("Archive File") ); - addItem( mArchiveFileItem, TQString::tqfromLatin1( "ArchiveFile" ) ); - TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesDestination; - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "standardDestination" ); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "askDestination" ); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "argl1" ); - choice.label = i18n("Argl1 Label"); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "argl2" ); - choice.whatsThis = i18n("Argl2 Whatsthis"); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "argl3" ); - choice.label = i18n("Argl3 Label"); - choice.whatsThis = i18n("Argl3 Whatsthis"); - valuesDestination.append( choice ); - } - mDestinationItem = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "Destination" ), mDestination, valuesDestination, standardDestination ); - mDestinationItem->setLabel( i18n("New Events/Todos Should") ); - addItem( mDestinationItem, TQString::tqfromLatin1( "Destination" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Views" ) ); - - mHourSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Hour Size" ), mHourSize, 10 ); - mHourSizeItem->setLabel( i18n("Hour Size") ); - addItem( mHourSizeItem, TQString::tqfromLatin1( "HourSize" ) ); - mSelectionStartsEditorItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "SelectionStartsEditor" ), mSelectionStartsEditor, false ); - mSelectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") ); - addItem( mSelectionStartsEditorItem, TQString::tqfromLatin1( "SelectionStartsEditor" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "KOrganizer Plugins" ) ); - - TQStringList defaultSelectedPlugins; - defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) ); - defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) ); - - mSelectedPluginsItem = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "SelectedPlugins" ), mSelectedPlugins, defaultSelectedPlugins ); - mSelectedPluginsItem->setLabel( i18n("SelectedPlugins") ); - addItem( mSelectedPluginsItem, TQString::tqfromLatin1( "SelectedPlugins" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Colors" ) ); - - mHighlightColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Highlight Color" ), mHighlightColor, TQColor( 100, 100, 255 ) ); - mHighlightColorItem->setLabel( i18n("Highlight color") ); - addItem( mHighlightColorItem, TQString::tqfromLatin1( "HighlightColor" ) ); - mAgendaBgColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Agenda Background Color" ), mAgendaBgColor, TQColor( 255, 255, 255 ) ); - mAgendaBgColorItem->setLabel( i18n("Agenda view background color") ); - addItem( mAgendaBgColorItem, TQString::tqfromLatin1( "AgendaBgColor" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Fonts" ) ); - - mTimeBarFontItem = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "TimeBar Font" ), mTimeBarFont ); - mTimeBarFontItem->setLabel( i18n("Time bar") ); - addItem( mTimeBarFontItem, TQString::tqfromLatin1( "TimeBarFont" ) ); -} - -Test2::~Test2() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test2.h.ref b/kdecore/kconfig_compiler/tests/test2.h.ref deleted file mode 100644 index 075f48bde..000000000 --- a/kdecore/kconfig_compiler/tests/test2.h.ref +++ /dev/null @@ -1,333 +0,0 @@ -// This file is generated by kconfig_compiler from test2.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST2_H -#define TEST2_H - -#include <myprefs.h> - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test2 : public MyPrefs -{ - public: - enum { standardDestination, askDestination, argl1, argl2, argl3 }; - - Test2( ); - ~Test2(); - - /** - Set Enable automatic saving of calendar - */ - void setAutoSave( bool v ) - { - if (!isImmutable( TQString::tqfromLatin1( "AutoSave" ) )) - mAutoSave = v; - } - - /** - Get Enable automatic saving of calendar - */ - bool autoSave() const - { - return mAutoSave; - } - - /** - Get Item object corresponding to AutoSave() - */ - ItemBool *autoSaveItem() - { - return mAutoSaveItem; - } - - /** - Set Auto Save Interval - */ - void setAutoSaveInterval( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "AutoSaveInterval" ) )) - mAutoSaveInterval = v; - } - - /** - Get Auto Save Interval - */ - int autoSaveInterval() const - { - return mAutoSaveInterval; - } - - /** - Get Item object corresponding to AutoSaveInterval() - */ - ItemInt *autoSaveIntervalItem() - { - return mAutoSaveIntervalItem; - } - - /** - Set Confirm deletes - */ - void setConfirm( bool v ) - { - if (!isImmutable( TQString::tqfromLatin1( "Confirm" ) )) - mConfirm = v; - } - - /** - Get Confirm deletes - */ - bool confirm() const - { - return mConfirm; - } - - /** - Get Item object corresponding to Confirm() - */ - ItemBool *confirmItem() - { - return mConfirmItem; - } - - /** - Set Archive File - */ - void setArchiveFile( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "ArchiveFile" ) )) - mArchiveFile = v; - } - - /** - Get Archive File - */ - TQString archiveFile() const - { - return mArchiveFile; - } - - /** - Get Item object corresponding to ArchiveFile() - */ - ItemString *archiveFileItem() - { - return mArchiveFileItem; - } - - /** - Set New Events/Todos Should - */ - void setDestination( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "Destination" ) )) - mDestination = v; - } - - /** - Get New Events/Todos Should - */ - int destination() const - { - return mDestination; - } - - /** - Get Item object corresponding to Destination() - */ - ItemEnum *destinationItem() - { - return mDestinationItem; - } - - /** - Set Hour Size - */ - void setHourSize( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "HourSize" ) )) - mHourSize = v; - } - - /** - Get Hour Size - */ - int hourSize() const - { - return mHourSize; - } - - /** - Get Item object corresponding to HourSize() - */ - ItemInt *hourSizeItem() - { - return mHourSizeItem; - } - - /** - Set Time range selection in agenda view starts event editor - */ - void setSelectionStartsEditor( bool v ) - { - if (!isImmutable( TQString::tqfromLatin1( "SelectionStartsEditor" ) )) - mSelectionStartsEditor = v; - } - - /** - Get Time range selection in agenda view starts event editor - */ - bool selectionStartsEditor() const - { - return mSelectionStartsEditor; - } - - /** - Get Item object corresponding to SelectionStartsEditor() - */ - ItemBool *selectionStartsEditorItem() - { - return mSelectionStartsEditorItem; - } - - /** - Set SelectedPlugins - */ - void setSelectedPlugins( const TQStringList & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "SelectedPlugins" ) )) - mSelectedPlugins = v; - } - - /** - Get SelectedPlugins - */ - TQStringList selectedPlugins() const - { - return mSelectedPlugins; - } - - /** - Get Item object corresponding to SelectedPlugins() - */ - ItemStringList *selectedPluginsItem() - { - return mSelectedPluginsItem; - } - - /** - Set Highlight color - */ - void setHighlightColor( const TQColor & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "HighlightColor" ) )) - mHighlightColor = v; - } - - /** - Get Highlight color - */ - TQColor highlightColor() const - { - return mHighlightColor; - } - - /** - Get Item object corresponding to HighlightColor() - */ - ItemColor *highlightColorItem() - { - return mHighlightColorItem; - } - - /** - Set Agenda view background color - */ - void setAgendaBgColor( const TQColor & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "AgendaBgColor" ) )) - mAgendaBgColor = v; - } - - /** - Get Agenda view background color - */ - TQColor agendaBgColor() const - { - return mAgendaBgColor; - } - - /** - Get Item object corresponding to AgendaBgColor() - */ - ItemColor *agendaBgColorItem() - { - return mAgendaBgColorItem; - } - - /** - Set Time bar - */ - void setTimeBarFont( const TQFont & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "TimeBarFont" ) )) - mTimeBarFont = v; - } - - /** - Get Time bar - */ - TQFont timeBarFont() const - { - return mTimeBarFont; - } - - /** - Get Item object corresponding to TimeBarFont() - */ - ItemFont *timeBarFontItem() - { - return mTimeBarFontItem; - } - - protected: - public: - - // General - bool mAutoSave; - int mAutoSaveInterval; - bool mConfirm; - TQString mArchiveFile; - int mDestination; - - // Views - int mHourSize; - bool mSelectionStartsEditor; - - // KOrganizer Plugins - TQStringList mSelectedPlugins; - - // Colors - TQColor mHighlightColor; - TQColor mAgendaBgColor; - - // Fonts - TQFont mTimeBarFont; - - private: - ItemBool *mAutoSaveItem; - ItemInt *mAutoSaveIntervalItem; - ItemBool *mConfirmItem; - ItemString *mArchiveFileItem; - ItemEnum *mDestinationItem; - ItemInt *mHourSizeItem; - ItemBool *mSelectionStartsEditorItem; - ItemStringList *mSelectedPluginsItem; - ItemColor *mHighlightColorItem; - ItemColor *mAgendaBgColorItem; - ItemFont *mTimeBarFontItem; -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test2.kcfg b/kdecore/kconfig_compiler/tests/test2.kcfg deleted file mode 100644 index 3b19e270e..000000000 --- a/kdecore/kconfig_compiler/tests/test2.kcfg +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="korganizerrc"/> - - <group name="General"> - <entry type="Bool" key="Auto Save"> - <label>Enable automatic saving of calendar</label> - <whatsthis>WhatsThis text for AutoSave option</whatsthis> - <default>false</default> - </entry> - <entry type="Int" key="Auto Save Interval"> - <default>10</default> - </entry> - <entry type="Bool" key="Confirm Deletes" name="Confirm"> - <label>Confirm deletes</label> - <default>true</default> - </entry> - <entry type="String" key="Archive File"> - </entry> - <entry type="Enum" key="Destination" name="Destination"> - <label>New Events/Todos Should</label> - <choices> - <choice name="standardDestination"> - </choice> - <choice name="askDestination"> - </choice> - <choice name="argl1"> - <label>Argl1 Label</label> - </choice> - <choice name="argl2"> - <whatsthis>Argl2 Whatsthis</whatsthis> - </choice> - <choice name="argl3"> - <label>Argl3 Label</label> - <whatsthis>Argl3 Whatsthis</whatsthis> - </choice> - </choices> - <default>standardDestination</default> - </entry> - </group> - - <group name="Views"> - <entry type="Int" key="Hour Size"> - <default>10</default> - </entry> - <entry type="Bool" name="SelectionStartsEditor"> - <label>Time range selection in agenda view starts event editor</label> - <default>false</default> - </entry> - </group> - - <group name="KOrganizer Plugins"> - <entry type="StringList" name="SelectedPlugins"> - <default>holidays,webexport</default> - </entry> - </group> - - <group name="Colors"> - <entry type="Color" key="Highlight Color"> - <label>Highlight color</label> - <default>100, 100, 255</default> - </entry> - <entry type="Color" key="Agenda Background Color" name="AgendaBgColor"> - <label>Agenda view background color</label> - <default>255, 255, 255</default> - </entry> - </group> - - <group name="Fonts"> - <entry type="Font" key="TimeBar Font"> - <label>Time bar</label> - </entry> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test2.kcfgc b/kdecore/kconfig_compiler/tests/test2.kcfgc deleted file mode 100644 index 56620d2f4..000000000 --- a/kdecore/kconfig_compiler/tests/test2.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test2.kcfg -ClassName=Test2 -Singleton=false -Mutators=true -Inherits=MyPrefs -IncludeFiles=myprefs.h -MemberVariables=public -GlobalEnums=true -ItemAccessors=true -SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test2main.cpp b/kdecore/kconfig_compiler/tests/test2main.cpp deleted file mode 100644 index 904c57270..000000000 --- a/kdecore/kconfig_compiler/tests/test2main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - -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 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. -*/ -#include "test2.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test2 *t = new Test2(); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test3.cpp.ref b/kdecore/kconfig_compiler/tests/test3.cpp.ref deleted file mode 100644 index a47fd5213..000000000 --- a/kdecore/kconfig_compiler/tests/test3.cpp.ref +++ /dev/null @@ -1,29 +0,0 @@ -// This file is generated by kconfig_compiler from test3.kcfg. -// All changes you do to this file will be lost. - -#include "test3.h" - -using namespace TestNameSpace; - -Test3::Test3( ) - : KConfigSkeleton( TQString::tqfromLatin1( "test3rc" ) ) -{ - setCurrentGroup( TQString::tqfromLatin1( "General" ) ); - - mAutoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Auto Save" ), mAutoSave, false ); - addItem( mAutoSaveItem, TQString::tqfromLatin1( "AutoSave" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Blah" ) ); - - mBlubbItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Blubb" ), mBlubb, 10 ); - addItem( mBlubbItem, TQString::tqfromLatin1( "Blubb" ) ); - mBlahBlahItem = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "BlahBlah" ), mBlahBlah, TQString::tqfromLatin1( "a string" ) ); - addItem( mBlahBlahItem, TQString::tqfromLatin1( "BlahBlah" ) ); - mMyPasswordItem = new KConfigSkeleton::ItemPassword( currentGroup(), TQString::tqfromLatin1( "MyPassword" ), mMyPassword ); - addItem( mMyPasswordItem, TQString::tqfromLatin1( "MyPassword" ) ); -} - -Test3::~Test3() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test3.h.ref b/kdecore/kconfig_compiler/tests/test3.h.ref deleted file mode 100644 index 8e86d36b0..000000000 --- a/kdecore/kconfig_compiler/tests/test3.h.ref +++ /dev/null @@ -1,138 +0,0 @@ -// This file is generated by kconfig_compiler from test3.kcfg. -// All changes you do to this file will be lost. -#ifndef TESTNAMESPACE_TEST3_H -#define TESTNAMESPACE_TEST3_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -namespace TestNameSpace { - -class Test3 : public KConfigSkeleton -{ - public: - - Test3( ); - ~Test3(); - - /** - Set Enable automatic saving of calendar - */ - void setAutoSave( bool v ) - { - if (!isImmutable( TQString::tqfromLatin1( "AutoSave" ) )) - mAutoSave = v; - } - - /** - Get Enable automatic saving of calendar - */ - bool autoSave() const - { - return mAutoSave; - } - - /** - Get Item object corresponding to AutoSave() - */ - ItemBool *autoSaveItem() - { - return mAutoSaveItem; - } - - /** - Set Blubb - */ - void setBlubb( int v ) - { - if (!isImmutable( TQString::tqfromLatin1( "Blubb" ) )) - mBlubb = v; - } - - /** - Get Blubb - */ - int blubb() const - { - return mBlubb; - } - - /** - Get Item object corresponding to Blubb() - */ - ItemInt *blubbItem() - { - return mBlubbItem; - } - - /** - Set BlahBlah - */ - void setBlahBlah( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "BlahBlah" ) )) - mBlahBlah = v; - } - - /** - Get BlahBlah - */ - TQString blahBlah() const - { - return mBlahBlah; - } - - /** - Get Item object corresponding to BlahBlah() - */ - ItemString *blahBlahItem() - { - return mBlahBlahItem; - } - - /** - Set MyPassword - */ - void setMyPassword( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyPassword" ) )) - mMyPassword = v; - } - - /** - Get MyPassword - */ - TQString myPassword() const - { - return mMyPassword; - } - - /** - Get Item object corresponding to MyPassword() - */ - ItemPassword *myPasswordItem() - { - return mMyPasswordItem; - } - - protected: - - // General - bool mAutoSave; - - // Blah - int mBlubb; - TQString mBlahBlah; - TQString mMyPassword; - - private: - ItemBool *mAutoSaveItem; - ItemInt *mBlubbItem; - ItemString *mBlahBlahItem; - ItemPassword *mMyPasswordItem; -}; - -} - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test3.kcfg b/kdecore/kconfig_compiler/tests/test3.kcfg deleted file mode 100644 index 77916da40..000000000 --- a/kdecore/kconfig_compiler/tests/test3.kcfg +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="test3rc"/> - - <group name="General"> - <entry type="Bool" key="Auto Save"> - <label>Enable automatic saving of calendar</label> - <whatsthis>WhatsThis text for AutoSave option</whatsthis> - <default>false</default> - </entry> - </group> - - <group name="Blah"> - <entry type="Int" name="Blubb"> - <default>10</default> - </entry> - <entry type="String" name="BlahBlah"> - <default>a string</default> - </entry> - <entry type="Password" name="MyPassword"/> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test3.kcfgc b/kdecore/kconfig_compiler/tests/test3.kcfgc deleted file mode 100644 index ca2c22057..000000000 --- a/kdecore/kconfig_compiler/tests/test3.kcfgc +++ /dev/null @@ -1,12 +0,0 @@ -# Code generation options for kconfig_compiler -File=test3.kcfg -NameSpace=TestNameSpace -ClassName=Test3 -#Singleton=false -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=true -#SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test3main.cpp b/kdecore/kconfig_compiler/tests/test3main.cpp deleted file mode 100644 index 9789d697d..000000000 --- a/kdecore/kconfig_compiler/tests/test3main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - -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 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. -*/ -#include "test3.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - TestNameSpace::Test3 *t = new TestNameSpace::Test3(); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test4.cpp.ref b/kdecore/kconfig_compiler/tests/test4.cpp.ref deleted file mode 100644 index 0eee21488..000000000 --- a/kdecore/kconfig_compiler/tests/test4.cpp.ref +++ /dev/null @@ -1,82 +0,0 @@ -// This file is generated by kconfig_compiler from test4.kcfg. -// All changes you do to this file will be lost. - -#include "test4.h" - -#include <kstaticdeleter.h> - -Test4 *Test4::mSelf = 0; -static KStaticDeleter<Test4> staticTest4Deleter; - -Test4 *Test4::self() -{ - if ( !mSelf ) { - staticTest4Deleter.setObject( mSelf, new Test4() ); - mSelf->readConfig(); - } - - return mSelf; -} - -const char* const Test4::EnumButton::enumToString[] = { "right", "mid", "left" }; - -Test4::Test4( ) - : KConfigSkeleton( TQString::tqfromLatin1( "test4rc" ) ) -{ - mSelf = this; - setCurrentGroup( TQString::tqfromLatin1( "Foo" ) ); - -TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; - KConfigSkeleton::ItemColor *itemColor[4]; - itemColor[0] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #0" ), mColor[0], defaultColor[0] ); - addItem( itemColor[0], TQString::tqfromLatin1( "Color0" ) ); - itemColor[1] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #1" ), mColor[1], defaultColor[1] ); - addItem( itemColor[1], TQString::tqfromLatin1( "Color1" ) ); - itemColor[2] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #2" ), mColor[2], defaultColor[2] ); - addItem( itemColor[2], TQString::tqfromLatin1( "Color2" ) ); - itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #3" ), mColor[3], defaultColor[3] ); - addItem( itemColor[3], TQString::tqfromLatin1( "Color3" ) ); - TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction; - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "Encrypt" ); - valuesMouseAction.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "Decrypt" ); - valuesMouseAction.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "CrashNBurn" ); - valuesMouseAction.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "PumpNDump" ); - valuesMouseAction.append( choice ); - } - KConfigSkeleton::ItemEnum *itemMouseAction[3]; - itemMouseAction[0] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, EnumMouseAction::Decrypt ); - addItem( itemMouseAction[0], TQString::tqfromLatin1( "MouseActionright" ) ); - itemMouseAction[1] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, EnumMouseAction::Encrypt ); - addItem( itemMouseAction[1], TQString::tqfromLatin1( "MouseActionmid" ) ); - itemMouseAction[2] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, EnumMouseAction::PumpNDump ); - addItem( itemMouseAction[2], TQString::tqfromLatin1( "MouseActionleft" ) ); - KConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) ); - KConfigSkeleton::ItemInt *itemAge; - itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::tqfromLatin1( "Age" ) ); -} - -Test4::~Test4() -{ - if ( mSelf == this ) - staticTest4Deleter.setObject( mSelf, 0, false ); -} - diff --git a/kdecore/kconfig_compiler/tests/test4.h.ref b/kdecore/kconfig_compiler/tests/test4.h.ref deleted file mode 100644 index dc8691b1f..000000000 --- a/kdecore/kconfig_compiler/tests/test4.h.ref +++ /dev/null @@ -1,135 +0,0 @@ -// This file is generated by kconfig_compiler from test4.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST4_H -#define TEST4_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test4 : public KConfigSkeleton -{ - public: - class EnumMouseAction - { - public: - enum type { Encrypt, Decrypt, CrashNBurn, PumpNDump, COUNT }; - }; - class EnumButton - { - public: - enum type { right, mid, left, COUNT }; - static const char* const enumToString[]; - }; - - static Test4 *self(); - ~Test4(); - - /** - Set Block colors. - */ - static - void setColor( int i, const TQColor & v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "Color%1" ).arg( i ) )) - self()->mColor[i] = v; - } - - /** - Get Block colors. - */ - static - TQColor color( int i ) - { - return self()->mColor[i]; - } - - /** - Set Mouse actions. - */ - static - void setMouseAction( int i, int v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "MouseAction%1" ).arg( TQString::tqfromLatin1( EnumButton::enumToString[i] ) ) )) - self()->mMouseAction[i] = v; - } - - /** - Get Mouse actions. - */ - static - int mouseAction( int i ) - { - return self()->mMouseAction[i]; - } - - /** - Set foo bar - */ - static - void setFooBar( const TQString & v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "FooBar" ) )) - self()->mFooBar = v; - } - - /** - Get foo bar - */ - static - TQString fooBar() - { - return self()->mFooBar; - } - - /** - Set Age - */ - static - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!self()->isImmutable( TQString::tqfromLatin1( "Age" ) )) - self()->mAge = v; - } - - /** - Get Age - */ - static - int age() - { - return self()->mAge; - } - - static - void writeConfig() - { - static_cast<KConfigSkeleton*>(self())->writeConfig(); - } - protected: - Test4(); - static Test4 *mSelf; - - - // Foo - TQColor mColor[4]; - int mMouseAction[3]; - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test4.kcfg b/kdecore/kconfig_compiler/tests/test4.kcfg deleted file mode 100644 index d8ef2bfae..000000000 --- a/kdecore/kconfig_compiler/tests/test4.kcfg +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="test4rc"/> - - <group name="Foo"> - <entry name="Color$(Number)" type="Color" key="color #$(Number)"> - <parameter name="Number" type="Int" max="3"/> - <label>Block colors.</label> - <code>QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };</code> - <default code="true">defaultColor[$(Number)]</default> - </entry> - <entry name="MouseAction$(Button)" type="Enum" key="$(Button)_mouse_action"> - <parameter name="Button" type="Enum"> - <values> - <value>right</value> - <value>mid</value> - <value>left</value> - </values> - </parameter> - <label>Mouse actions.</label> - <choices> - <choice name="Encrypt"/> - <choice name="Decrypt"/> - <choice name="CrashNBurn"/> - <choice name="PumpNDump"/> - </choices> - <default param="right">Decrypt</default> - <default param="mid">Encrypt</default> - <default param="left">PumpNDump</default> - </entry> - <entry name="FooBar" key="foo bar" type="String"/> - <entry name="Age" type="Int"> - <default>35</default> - <min>8</min> - <max>88</max> - </entry> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test4.kcfgc b/kdecore/kconfig_compiler/tests/test4.kcfgc deleted file mode 100644 index 754706dff..000000000 --- a/kdecore/kconfig_compiler/tests/test4.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test4.kcfg -ClassName=Test4 -Singleton=true -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=false -ItemAccessors=false -#SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test4main.cpp b/kdecore/kconfig_compiler/tests/test4main.cpp deleted file mode 100644 index 8b38b3dbd..000000000 --- a/kdecore/kconfig_compiler/tests/test4main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2003,2004 Waldo Bastian <bastian@kde.org> - -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 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. -*/ - -#include "test4.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test4 *t = Test4::self(); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test5.cpp.ref b/kdecore/kconfig_compiler/tests/test5.cpp.ref deleted file mode 100644 index 0fc90b387..000000000 --- a/kdecore/kconfig_compiler/tests/test5.cpp.ref +++ /dev/null @@ -1,82 +0,0 @@ -// This file is generated by kconfig_compiler from test5.kcfg. -// All changes you do to this file will be lost. - -#include "test5.h" - -#include <kstaticdeleter.h> - -Test5 *Test5::mSelf = 0; -static KStaticDeleter<Test5> staticTest5Deleter; - -Test5 *Test5::self() -{ - if ( !mSelf ) { - staticTest5Deleter.setObject( mSelf, new Test5() ); - mSelf->readConfig(); - } - - return mSelf; -} - -const char* const Test5::EnumButtonToString[] = { "right", "mid", "left" }; - -Test5::Test5( ) - : KConfigSkeleton( TQString::tqfromLatin1( "test4rc" ) ) -{ - mSelf = this; - setCurrentGroup( TQString::tqfromLatin1( "Foo" ) ); - -TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; - KConfigSkeleton::ItemColor *itemColor[4]; - itemColor[0] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #0" ), mColor[0], defaultColor[0] ); - addItem( itemColor[0], TQString::tqfromLatin1( "Color0" ) ); - itemColor[1] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #1" ), mColor[1], defaultColor[1] ); - addItem( itemColor[1], TQString::tqfromLatin1( "Color1" ) ); - itemColor[2] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #2" ), mColor[2], defaultColor[2] ); - addItem( itemColor[2], TQString::tqfromLatin1( "Color2" ) ); - itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #3" ), mColor[3], defaultColor[3] ); - addItem( itemColor[3], TQString::tqfromLatin1( "Color3" ) ); - TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction; - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "Encrypt" ); - valuesMouseAction.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "Decrypt" ); - valuesMouseAction.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "CrashNBurn" ); - valuesMouseAction.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "PumpNDump" ); - valuesMouseAction.append( choice ); - } - KConfigSkeleton::ItemEnum *itemMouseAction[3]; - itemMouseAction[0] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, Decrypt ); - addItem( itemMouseAction[0], TQString::tqfromLatin1( "MouseActionright" ) ); - itemMouseAction[1] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, Encrypt ); - addItem( itemMouseAction[1], TQString::tqfromLatin1( "MouseActionmid" ) ); - itemMouseAction[2] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, PumpNDump ); - addItem( itemMouseAction[2], TQString::tqfromLatin1( "MouseActionleft" ) ); - KConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) ); - KConfigSkeleton::ItemInt *itemAge; - itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::tqfromLatin1( "Age" ) ); -} - -Test5::~Test5() -{ - if ( mSelf == this ) - staticTest5Deleter.setObject( mSelf, 0, false ); -} - diff --git a/kdecore/kconfig_compiler/tests/test5.h.ref b/kdecore/kconfig_compiler/tests/test5.h.ref deleted file mode 100644 index 9fadbd0ec..000000000 --- a/kdecore/kconfig_compiler/tests/test5.h.ref +++ /dev/null @@ -1,127 +0,0 @@ -// This file is generated by kconfig_compiler from test5.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST5_H -#define TEST5_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test5 : public KConfigSkeleton -{ - public: - enum { Encrypt, Decrypt, CrashNBurn, PumpNDump }; - enum { right, mid, left }; - static const char* const EnumButtonToString[]; - - static Test5 *self(); - ~Test5(); - - /** - Set Block colors. - */ - static - void setColor( int i, const TQColor & v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "Color%1" ).arg( i ) )) - self()->mColor[i] = v; - } - - /** - Get Block colors. - */ - static - TQColor color( int i ) - { - return self()->mColor[i]; - } - - /** - Set Mouse actions. - */ - static - void setMouseAction( int i, int v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "MouseAction%1" ).arg( TQString::tqfromLatin1( EnumButtonToString[i] ) ) )) - self()->mMouseAction[i] = v; - } - - /** - Get Mouse actions. - */ - static - int mouseAction( int i ) - { - return self()->mMouseAction[i]; - } - - /** - Set foo bar - */ - static - void setFooBar( const TQString & v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "FooBar" ) )) - self()->mFooBar = v; - } - - /** - Get foo bar - */ - static - TQString fooBar() - { - return self()->mFooBar; - } - - /** - Set Age - */ - static - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!self()->isImmutable( TQString::tqfromLatin1( "Age" ) )) - self()->mAge = v; - } - - /** - Get Age - */ - static - int age() - { - return self()->mAge; - } - - static - void writeConfig() - { - static_cast<KConfigSkeleton*>(self())->writeConfig(); - } - protected: - Test5(); - static Test5 *mSelf; - - - // Foo - TQColor mColor[4]; - int mMouseAction[3]; - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test5.kcfg b/kdecore/kconfig_compiler/tests/test5.kcfg deleted file mode 100644 index d8ef2bfae..000000000 --- a/kdecore/kconfig_compiler/tests/test5.kcfg +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="test4rc"/> - - <group name="Foo"> - <entry name="Color$(Number)" type="Color" key="color #$(Number)"> - <parameter name="Number" type="Int" max="3"/> - <label>Block colors.</label> - <code>QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };</code> - <default code="true">defaultColor[$(Number)]</default> - </entry> - <entry name="MouseAction$(Button)" type="Enum" key="$(Button)_mouse_action"> - <parameter name="Button" type="Enum"> - <values> - <value>right</value> - <value>mid</value> - <value>left</value> - </values> - </parameter> - <label>Mouse actions.</label> - <choices> - <choice name="Encrypt"/> - <choice name="Decrypt"/> - <choice name="CrashNBurn"/> - <choice name="PumpNDump"/> - </choices> - <default param="right">Decrypt</default> - <default param="mid">Encrypt</default> - <default param="left">PumpNDump</default> - </entry> - <entry name="FooBar" key="foo bar" type="String"/> - <entry name="Age" type="Int"> - <default>35</default> - <min>8</min> - <max>88</max> - </entry> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test5.kcfgc b/kdecore/kconfig_compiler/tests/test5.kcfgc deleted file mode 100644 index 663005e5e..000000000 --- a/kdecore/kconfig_compiler/tests/test5.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test5.kcfg -ClassName=Test5 -Singleton=true -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=false -#SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test5main.cpp b/kdecore/kconfig_compiler/tests/test5main.cpp deleted file mode 100644 index 57ad5189d..000000000 --- a/kdecore/kconfig_compiler/tests/test5main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2004 Waldo Bastian <bastian@kde.org> - -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 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. -*/ - -#include "test5.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test5 *t = Test5::self(); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test6.cpp.ref b/kdecore/kconfig_compiler/tests/test6.cpp.ref deleted file mode 100644 index 2b8a71d50..000000000 --- a/kdecore/kconfig_compiler/tests/test6.cpp.ref +++ /dev/null @@ -1,31 +0,0 @@ -// This file is generated by kconfig_compiler from test6.kcfg. -// All changes you do to this file will be lost. - -#include "test6.h" - -Test6::Test6( const TQString & Number ) - : KConfigSkeleton( TQString::tqfromLatin1( "test4rc" ) ) - , mParamNumber(Number) -{ - setCurrentGroup( TQString::tqfromLatin1( "Foo" ) ); - - KConfigSkeleton::ItemColor *itemColor; - itemColor = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) ); - addItem( itemColor, TQString::tqfromLatin1( "Color" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Bar%1" ).arg( mParamNumber ) ); - - KConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) ); - KConfigSkeleton::ItemInt *itemAge; - itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::tqfromLatin1( "Age" ) ); -} - -Test6::~Test6() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test6.h.ref b/kdecore/kconfig_compiler/tests/test6.h.ref deleted file mode 100644 index 18615da38..000000000 --- a/kdecore/kconfig_compiler/tests/test6.h.ref +++ /dev/null @@ -1,93 +0,0 @@ -// This file is generated by kconfig_compiler from test6.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST6_H -#define TEST6_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test6 : public KConfigSkeleton -{ - public: - - Test6( const TQString & Number ); - ~Test6(); - - /** - Set Block colors. - */ - void setColor( const TQColor & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "Color" ) )) - mColor = v; - } - - /** - Get Block colors. - */ - TQColor color() const - { - return mColor; - } - - /** - Set foo bar - */ - void setFooBar( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "FooBar" ) )) - mFooBar = v; - } - - /** - Get foo bar - */ - TQString fooBar() const - { - return mFooBar; - } - - /** - Set Age - */ - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!isImmutable( TQString::tqfromLatin1( "Age" ) )) - mAge = v; - } - - /** - Get Age - */ - int age() const - { - return mAge; - } - - protected: - TQString mParamNumber; - - // Foo - TQColor mColor; - - // Bar$(Number) - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test6.kcfg b/kdecore/kconfig_compiler/tests/test6.kcfg deleted file mode 100644 index e59fa88f3..000000000 --- a/kdecore/kconfig_compiler/tests/test6.kcfg +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="test4rc"> - <parameter name="Number" type="String"/> - </kcfgfile> - - <group name="Foo"> - <entry name="Color" type="Color" key="color #$(Number)"> - <label>Block colors.</label> - <default>red</default> - </entry> - </group> - <group name="Bar$(Number)"> - <entry name="FooBar" key="foo bar" type="String"/> - <entry name="Age" type="Int"> - <default>35</default> - <min>8</min> - <max>88</max> - </entry> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test6.kcfgc b/kdecore/kconfig_compiler/tests/test6.kcfgc deleted file mode 100644 index b69dc152d..000000000 --- a/kdecore/kconfig_compiler/tests/test6.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test6.kcfg -ClassName=Test6 -Singleton=false -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=false -#SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test6main.cpp b/kdecore/kconfig_compiler/tests/test6main.cpp deleted file mode 100644 index 27dff57ff..000000000 --- a/kdecore/kconfig_compiler/tests/test6main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2004 Waldo Bastian <bastian@kde.org> - -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 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. -*/ - -#include "test6.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test6 *t = new Test6(TQString::null); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test7.cpp.ref b/kdecore/kconfig_compiler/tests/test7.cpp.ref deleted file mode 100644 index dab0ae27d..000000000 --- a/kdecore/kconfig_compiler/tests/test7.cpp.ref +++ /dev/null @@ -1,31 +0,0 @@ -// This file is generated by kconfig_compiler from test7.kcfg. -// All changes you do to this file will be lost. - -#include "test7.h" - -Test7::Test7( int Number ) - : KConfigSkeleton( TQString::tqfromLatin1( "test7rc" ) ) - , mParamNumber(Number) -{ - setCurrentGroup( TQString::tqfromLatin1( "Foo" ) ); - - KConfigSkeleton::ItemColor *itemColor; - itemColor = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) ); - addItem( itemColor, TQString::tqfromLatin1( "Color" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Bar%1" ).arg( mParamNumber ) ); - - KConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) ); - KConfigSkeleton::ItemInt *itemAge; - itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::tqfromLatin1( "Age" ) ); -} - -Test7::~Test7() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test7.h.ref b/kdecore/kconfig_compiler/tests/test7.h.ref deleted file mode 100644 index f67bc30cb..000000000 --- a/kdecore/kconfig_compiler/tests/test7.h.ref +++ /dev/null @@ -1,93 +0,0 @@ -// This file is generated by kconfig_compiler from test7.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST7_H -#define TEST7_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test7 : public KConfigSkeleton -{ - public: - - Test7( int Number ); - ~Test7(); - - /** - Set Block colors. - */ - void setColor( const TQColor & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "Color" ) )) - mColor = v; - } - - /** - Get Block colors. - */ - TQColor color() const - { - return mColor; - } - - /** - Set foo bar - */ - void setFooBar( const TQString & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "FooBar" ) )) - mFooBar = v; - } - - /** - Get foo bar - */ - TQString fooBar() const - { - return mFooBar; - } - - /** - Set Age - */ - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!isImmutable( TQString::tqfromLatin1( "Age" ) )) - mAge = v; - } - - /** - Get Age - */ - int age() const - { - return mAge; - } - - protected: - int mParamNumber; - - // Foo - TQColor mColor; - - // Bar$(Number) - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test7.kcfg b/kdecore/kconfig_compiler/tests/test7.kcfg deleted file mode 100644 index 0a7fd3272..000000000 --- a/kdecore/kconfig_compiler/tests/test7.kcfg +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="test7rc"> - <parameter name="Number" type="Int"/> - </kcfgfile> - - <group name="Foo"> - <entry name="Color" type="Color" key="color #$(Number)"> - <label>Block colors.</label> - <default>red</default> - </entry> - </group> - <group name="Bar$(Number)"> - <entry name="FooBar" key="foo bar" type="String"/> - <entry name="Age" type="Int"> - <default>35</default> - <min>8</min> - <max>88</max> - </entry> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test7.kcfgc b/kdecore/kconfig_compiler/tests/test7.kcfgc deleted file mode 100644 index 9a6c40954..000000000 --- a/kdecore/kconfig_compiler/tests/test7.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test7.kcfg -ClassName=Test7 -Singleton=false -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=false -#SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test7main.cpp b/kdecore/kconfig_compiler/tests/test7main.cpp deleted file mode 100644 index 9c1ad1931..000000000 --- a/kdecore/kconfig_compiler/tests/test7main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2004 Waldo Bastian <bastian@kde.org> - -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 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. -*/ - -#include "test7.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test7 *t = new Test7(42); - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test8a.cpp.ref b/kdecore/kconfig_compiler/tests/test8a.cpp.ref deleted file mode 100644 index 8d8925c57..000000000 --- a/kdecore/kconfig_compiler/tests/test8a.cpp.ref +++ /dev/null @@ -1,22 +0,0 @@ -// This file is generated by kconfig_compiler from test8a.kcfg. -// All changes you do to this file will be lost. - -#include "test8a.h" - -Test8a::Test8a( KSharedConfig::Ptr config ) - : KConfigSkeleton( config ) -{ - setCurrentGroup( TQString::tqfromLatin1( "Group" ) ); - - KConfigSkeleton::ItemFont *itemFont; - itemFont = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "Font" ), mFont, KGlobalSettings::generalFont() ); - addItem( itemFont, TQString::tqfromLatin1( "Font" ) ); - KConfigSkeleton::ItemFont *itemTitleFont; - itemTitleFont = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "TitleFont" ), mTitleFont, KGlobalSettings::windowTitleFont() ); - addItem( itemTitleFont, TQString::tqfromLatin1( "TitleFont" ) ); -} - -Test8a::~Test8a() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test8a.h.ref b/kdecore/kconfig_compiler/tests/test8a.h.ref deleted file mode 100644 index a1ac4de64..000000000 --- a/kdecore/kconfig_compiler/tests/test8a.h.ref +++ /dev/null @@ -1,61 +0,0 @@ -// This file is generated by kconfig_compiler from test8a.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST8A_H -#define TEST8A_H - -#include <kglobal.h> -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test8a : public KConfigSkeleton -{ - public: - - Test8a( KSharedConfig::Ptr config = KGlobal::sharedConfig() ); - ~Test8a(); - - /** - Set Font - */ - void setFont( const TQFont & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "Font" ) )) - mFont = v; - } - - /** - Get Font - */ - TQFont font() const - { - return mFont; - } - - /** - Set TitleFont - */ - void setTitleFont( const TQFont & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "TitleFont" ) )) - mTitleFont = v; - } - - /** - Get TitleFont - */ - TQFont titleFont() const - { - return mTitleFont; - } - - protected: - - // Group - TQFont mFont; - TQFont mTitleFont; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test8a.kcfg b/kdecore/kconfig_compiler/tests/test8a.kcfg deleted file mode 100644 index 5ee87199f..000000000 --- a/kdecore/kconfig_compiler/tests/test8a.kcfg +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile arg="true"/> - - <group name="Group"> - <entry name="Font" type="Font"> - <default code="true">KGlobalSettings::generalFont()</default> - </entry> - - <entry name="TitleFont" type="Font"> - <default code="true">KGlobalSettings::windowTitleFont()</default> - </entry> - </group> -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test8a.kcfgc b/kdecore/kconfig_compiler/tests/test8a.kcfgc deleted file mode 100644 index 5f63c31c2..000000000 --- a/kdecore/kconfig_compiler/tests/test8a.kcfgc +++ /dev/null @@ -1,3 +0,0 @@ -File=test8a.kcfg -ClassName=Test8a -Mutators=true diff --git a/kdecore/kconfig_compiler/tests/test8b.cpp.ref b/kdecore/kconfig_compiler/tests/test8b.cpp.ref deleted file mode 100644 index 566902399..000000000 --- a/kdecore/kconfig_compiler/tests/test8b.cpp.ref +++ /dev/null @@ -1,46 +0,0 @@ -// This file is generated by kconfig_compiler from test8b.kcfg. -// All changes you do to this file will be lost. - -#include "test8b.h" - -#include <kstaticdeleter.h> - -Test8b *Test8b::mSelf = 0; -static KStaticDeleter<Test8b> staticTest8bDeleter; - -Test8b *Test8b::self() -{ - if ( !mSelf ) { - staticTest8bDeleter.setObject( mSelf, new Test8b() ); - mSelf->readConfig(); - } - - return mSelf; -} - -Test8b::Test8b( ) - : Test8a() -{ - mSelf = this; - setCurrentGroup( TQString::tqfromLatin1( "Group8b1" ) ); - - KConfigSkeleton::ItemUInt *itemSomething; - itemSomething = new KConfigSkeleton::ItemUInt( currentGroup(), TQString::tqfromLatin1( "Something" ), mSomething, 60 ); - addItem( itemSomething, TQString::tqfromLatin1( "Something" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Group8b2" ) ); - - KConfigSkeleton::ItemBool *itemFooBoo; - itemFooBoo = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "FooBoo" ), mFooBoo, false ); - addItem( itemFooBoo, TQString::tqfromLatin1( "FooBoo" ) ); - KConfigSkeleton::ItemUInt *itemPort; - itemPort = new KConfigSkeleton::ItemUInt( currentGroup(), TQString::tqfromLatin1( "Port" ), mPort, 1000 ); - addItem( itemPort, TQString::tqfromLatin1( "Port" ) ); -} - -Test8b::~Test8b() -{ - if ( mSelf == this ) - staticTest8bDeleter.setObject( mSelf, 0, false ); -} - diff --git a/kdecore/kconfig_compiler/tests/test8b.h.ref b/kdecore/kconfig_compiler/tests/test8b.h.ref deleted file mode 100644 index dfc9089e3..000000000 --- a/kdecore/kconfig_compiler/tests/test8b.h.ref +++ /dev/null @@ -1,96 +0,0 @@ -// This file is generated by kconfig_compiler from test8b.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST8B_H -#define TEST8B_H - -#include <test8a.h> - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class Test8b : public Test8a -{ - public: - - static Test8b *self(); - ~Test8b(); - - /** - Set Something - */ - static - void setSomething( uint v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "Something" ) )) - self()->mSomething = v; - } - - /** - Get Something - */ - static - uint something() - { - return self()->mSomething; - } - - /** - Set FooBoo - */ - static - void setFooBoo( bool v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "FooBoo" ) )) - self()->mFooBoo = v; - } - - /** - Get FooBoo - */ - static - bool fooBoo() - { - return self()->mFooBoo; - } - - /** - Set Port - */ - static - void setPort( uint v ) - { - if (!self()->isImmutable( TQString::tqfromLatin1( "Port" ) )) - self()->mPort = v; - } - - /** - Get Port - */ - static - uint port() - { - return self()->mPort; - } - - static - void writeConfig() - { - static_cast<KConfigSkeleton*>(self())->writeConfig(); - } - protected: - Test8b(); - static Test8b *mSelf; - - - // Group8b1 - uint mSomething; - - // Group8b2 - bool mFooBoo; - uint mPort; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test8b.kcfg b/kdecore/kconfig_compiler/tests/test8b.kcfg deleted file mode 100644 index 3e203a155..000000000 --- a/kdecore/kconfig_compiler/tests/test8b.kcfg +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <group name="Group8b1"> - <entry name="Something" type="UInt"> - <default>60</default> - </entry> - </group> - - <group name="Group8b2"> - <entry name="FooBoo" type="Bool"> - <default>false</default> - </entry> - - <entry name="Port" type="UInt"> - <default>1000</default> - </entry> - </group> -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test8b.kcfgc b/kdecore/kconfig_compiler/tests/test8b.kcfgc deleted file mode 100644 index 7be055203..000000000 --- a/kdecore/kconfig_compiler/tests/test8b.kcfgc +++ /dev/null @@ -1,6 +0,0 @@ -File=test8b.kcfg -ClassName=Test8b -Mutators=true -Singleton=true -IncludeFiles=test8a.h -Inherits=Test8a diff --git a/kdecore/kconfig_compiler/tests/test8main.cpp b/kdecore/kconfig_compiler/tests/test8main.cpp deleted file mode 100644 index b3c242f68..000000000 --- a/kdecore/kconfig_compiler/tests/test8main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2005 Michael Brade <brade@kde.org> - -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 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. -*/ - -#include "test8a.h" -#include "test8b.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - Test8a *config1 = new Test8a( KSharedConfig::openConfig( TQString::null ) ); - Test8a *config2 = new Test8a(); - Test8b::self(); - delete config1; - delete config2; -} diff --git a/kdecore/kconfig_compiler/tests/test9.cpp.ref b/kdecore/kconfig_compiler/tests/test9.cpp.ref deleted file mode 100644 index 606f21ed1..000000000 --- a/kdecore/kconfig_compiler/tests/test9.cpp.ref +++ /dev/null @@ -1,35 +0,0 @@ -// This file is generated by kconfig_compiler from test9.kcfg. -// All changes you do to this file will be lost. - -#include "test9.h" - -Test9::Test9( const TQString & transport, const TQString & folder ) - : KConfigSkeleton( TQString::tqfromLatin1( "examplerc" ) ) - , mParamtransport(transport) - , mParamfolder(folder) -{ - setCurrentGroup( TQString::tqfromLatin1( "MyOptionsXX" ) ); - - TQStringList defaultMyStringList; - defaultMyStringList.append( TQString::fromUtf8( "up" ) ); - defaultMyStringList.append( TQString::fromUtf8( "down" ) ); - - KConfigSkeleton::ItemStringList *itemMyStringList; - itemMyStringList = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList ); - addItem( itemMyStringList, TQString::tqfromLatin1( "MyStringList" ) ); - TQStringList defaultMyPathList; - defaultMyPathList.append( TQString::fromUtf8( "/home" ) ); - defaultMyPathList.append( TQString::fromUtf8( "~" ) ); - - KConfigSkeleton::ItemPathList *itemMyPathList; - itemMyPathList = new KConfigSkeleton::ItemPathList( currentGroup(), TQString::tqfromLatin1( "MyPathList" ), mMyPathList, defaultMyPathList ); - addItem( itemMyPathList, TQString::tqfromLatin1( "MyPathList" ) ); - KConfigSkeleton::ItemPathList *itemMyPathsList2; - itemMyPathsList2 = new KConfigSkeleton::ItemPathList( currentGroup(), TQString::tqfromLatin1( "MyPathsList2" ), mMyPathsList2, TQStringList(TQString::tqfromLatin1("/usr/bin")) += TQDir::homeDirPath() ); - addItem( itemMyPathsList2, TQString::tqfromLatin1( "MyPathsList2" ) ); -} - -Test9::~Test9() -{ -} - diff --git a/kdecore/kconfig_compiler/tests/test9.h.ref b/kdecore/kconfig_compiler/tests/test9.h.ref deleted file mode 100644 index 0476c8a19..000000000 --- a/kdecore/kconfig_compiler/tests/test9.h.ref +++ /dev/null @@ -1,82 +0,0 @@ -// This file is generated by kconfig_compiler from test9.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST9_H -#define TEST9_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -#include <tqdir.h> -class Test9 : public KConfigSkeleton -{ - public: - - Test9( const TQString & transport, const TQString & folder ); - ~Test9(); - - /** - Set MyStringList - */ - void setMyStringList( const TQStringList & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyStringList" ) )) - mMyStringList = v; - } - - /** - Get MyStringList - */ - TQStringList myStringList() const - { - return mMyStringList; - } - - /** - Set This is a list of paths - */ - void setMyPathList( const TQStringList & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyPathList" ) )) - mMyPathList = v; - } - - /** - Get This is a list of paths - */ - TQStringList myPathList() const - { - return mMyPathList; - } - - /** - Set This is an additional test for PathList - */ - void setMyPathsList2( const TQStringList & v ) - { - if (!isImmutable( TQString::tqfromLatin1( "MyPathsList2" ) )) - mMyPathsList2 = v; - } - - /** - Get This is an additional test for PathList - */ - TQStringList myPathsList2() const - { - return mMyPathsList2; - } - - protected: - public: - TQString mParamtransport; - TQString mParamfolder; - - // MyOptionsXX - TQStringList mMyStringList; - TQStringList mMyPathList; - TQStringList mMyPathsList2; - - private: -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test9.kcfg b/kdecore/kconfig_compiler/tests/test9.kcfg deleted file mode 100644 index b7495e2b6..000000000 --- a/kdecore/kconfig_compiler/tests/test9.kcfg +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <include>qdir.h</include> - <kcfgfile name="examplerc"> - <parameter name="transport" /> - <parameter name="folder" /> - </kcfgfile> - <group name="MyOptionsXX"> - <entry name="MyStringList" type="StringList"> - <default>up,down</default> - </entry> - <entry name="MyPathList" type="PathList"> - <label>This is a list of paths</label> - <default>/home,~</default> - </entry> - <entry name="MyPathsList2" type="PathList"> - <label>This is an additional test for PathList</label> - <default code="true">QStringList(QString::fromLatin1("/usr/bin")) += QDir::homeDirPath()</default> - </entry> - </group> -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test9.kcfgc b/kdecore/kconfig_compiler/tests/test9.kcfgc deleted file mode 100644 index 8f124fc25..000000000 --- a/kdecore/kconfig_compiler/tests/test9.kcfgc +++ /dev/null @@ -1,18 +0,0 @@ -# Code generation options for kconfig_compiler -ClassName=Test9 -# -# Singleton=false -# -# Inherits=KConfigSkeleton -# -# IncludeFiles=libtdepim/kpimprefs.h -# -MemberVariables=public -# -### The following line includes the file exampleprefs_base_addon.h -### It can be used to add extra functions and variables to the -### class. -# CustomAdditions=true -# -### Provide setFooBar(int) style functions -Mutators=true diff --git a/kdecore/kconfig_compiler/tests/test9main.cpp b/kdecore/kconfig_compiler/tests/test9main.cpp deleted file mode 100644 index 796ec0001..000000000 --- a/kdecore/kconfig_compiler/tests/test9main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 2005 Helge Deller <deller@kde.org> - -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 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. -*/ -#include "test9.h" -#include "kinstance.h" -#include <kdebug.h> -#include <tqdir.h> - -int main( int, char*[] ) -{ - KInstance i("test"); - Test9 *t = new Test9( TQString::null, TQString::null ); - - TQStringList myPathsList2 = t->myPathsList2(); - kdWarning() << myPathsList2 << endl; - - // add another path - TQStringList newlist = TQDir::homeDirPath() + TQString::tqfromLatin1("/.kde"); - myPathsList2 = myPathsList2 + newlist; - kdWarning() << myPathsList2 << endl; - - t->setMyPathsList2(myPathsList2); - kdWarning() << t->myPathsList2() << endl; - - delete t; -} diff --git a/kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref b/kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref deleted file mode 100644 index 00e933564..000000000 --- a/kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref +++ /dev/null @@ -1,344 +0,0 @@ -// This file is generated by kconfig_compiler from test_dpointer.kcfg. -// All changes you do to this file will be lost. - -#include "test_dpointer.h" - -#include <klocale.h> - -#include <kstaticdeleter.h> - -class TestDPointerPrivate -{ - public: - - // General - bool autoSave; - int autoSaveInterval; - bool confirm; - TQString archiveFile; - int destination; - - // Views - int hourSize; - bool selectionStartsEditor; - - // KOrganizer Plugins - TQStringList selectedPlugins; - - // Colors - TQColor highlightColor; - TQColor agendaBgColor; - - // Fonts - TQFont timeBarFont; - - // items - KConfigSkeleton::ItemBool *autoSaveItem; - KConfigSkeleton::ItemInt *autoSaveIntervalItem; - KConfigSkeleton::ItemBool *confirmItem; - KConfigSkeleton::ItemString *archiveFileItem; - KConfigSkeleton::ItemEnum *destinationItem; - KConfigSkeleton::ItemInt *hourSizeItem; - KConfigSkeleton::ItemBool *selectionStartsEditorItem; - KConfigSkeleton::ItemStringList *selectedPluginsItem; - KConfigSkeleton::ItemColor *highlightColorItem; - KConfigSkeleton::ItemColor *agendaBgColorItem; - KConfigSkeleton::ItemFont *timeBarFontItem; -}; - -TestDPointer *TestDPointer::mSelf = 0; -static KStaticDeleter<TestDPointer> staticTestDPointerDeleter; - -TestDPointer *TestDPointer::self() -{ - if ( !mSelf ) { - staticTestDPointerDeleter.setObject( mSelf, new TestDPointer() ); - mSelf->readConfig(); - } - - return mSelf; -} - -TestDPointer::TestDPointer( ) - : KConfigSkeleton( TQString::tqfromLatin1( "korganizerrc" ) ) -{ - d = new TestDPointerPrivate; - mSelf = this; - setCurrentGroup( TQString::tqfromLatin1( "General" ) ); - - d->autoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Auto Save" ), d->autoSave, false ); - d->autoSaveItem->setLabel( i18n("Enable automatic saving of calendar") ); - d->autoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") ); - addItem( d->autoSaveItem, TQString::tqfromLatin1( "AutoSave" ) ); - d->autoSaveIntervalItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Auto Save Interval" ), d->autoSaveInterval, 10 ); - d->autoSaveIntervalItem->setLabel( i18n("Auto Save Interval") ); - addItem( d->autoSaveIntervalItem, TQString::tqfromLatin1( "AutoSaveInterval" ) ); - d->confirmItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Confirm Deletes" ), d->confirm, true ); - d->confirmItem->setLabel( i18n("Confirm deletes") ); - addItem( d->confirmItem, TQString::tqfromLatin1( "Confirm" ) ); - d->archiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "Archive File" ), d->archiveFile ); - d->archiveFileItem->setLabel( i18n("Archive File") ); - addItem( d->archiveFileItem, TQString::tqfromLatin1( "ArchiveFile" ) ); - TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesDestination; - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "standardDestination" ); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "askDestination" ); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "argl1" ); - choice.label = i18n("Argl1 Label"); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "argl2" ); - choice.whatsThis = i18n("Argl2 Whatsthis"); - valuesDestination.append( choice ); - } - { - KConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::tqfromLatin1( "argl3" ); - choice.label = i18n("Argl3 Label"); - choice.whatsThis = i18n("Argl3 Whatsthis"); - valuesDestination.append( choice ); - } - d->destinationItem = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "Destination" ), d->destination, valuesDestination, EnumDestination::standardDestination ); - d->destinationItem->setLabel( i18n("New Events/Todos Should") ); - addItem( d->destinationItem, TQString::tqfromLatin1( "Destination" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Views" ) ); - - d->hourSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Hour Size" ), d->hourSize, 10 ); - d->hourSizeItem->setLabel( i18n("Hour Size") ); - addItem( d->hourSizeItem, TQString::tqfromLatin1( "HourSize" ) ); - d->selectionStartsEditorItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "SelectionStartsEditor" ), d->selectionStartsEditor, false ); - d->selectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") ); - addItem( d->selectionStartsEditorItem, TQString::tqfromLatin1( "SelectionStartsEditor" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "KOrganizer Plugins" ) ); - - TQStringList defaultSelectedPlugins; - defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) ); - defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) ); - - d->selectedPluginsItem = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "SelectedPlugins" ), d->selectedPlugins, defaultSelectedPlugins ); - d->selectedPluginsItem->setLabel( i18n("SelectedPlugins") ); - addItem( d->selectedPluginsItem, TQString::tqfromLatin1( "SelectedPlugins" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Colors" ) ); - - d->highlightColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Highlight Color" ), d->highlightColor, TQColor( 100, 100, 255 ) ); - d->highlightColorItem->setLabel( i18n("Highlight color") ); - addItem( d->highlightColorItem, TQString::tqfromLatin1( "HighlightColor" ) ); - d->agendaBgColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Agenda Background Color" ), d->agendaBgColor, TQColor( 255, 255, 255 ) ); - d->agendaBgColorItem->setLabel( i18n("Agenda view background color") ); - addItem( d->agendaBgColorItem, TQString::tqfromLatin1( "AgendaBgColor" ) ); - - setCurrentGroup( TQString::tqfromLatin1( "Fonts" ) ); - - d->timeBarFontItem = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "TimeBar Font" ), d->timeBarFont ); - d->timeBarFontItem->setLabel( i18n("Time bar") ); - addItem( d->timeBarFontItem, TQString::tqfromLatin1( "TimeBarFont" ) ); -} - -void TestDPointer::setAutoSave( bool v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "AutoSave" ) )) - self()->d->autoSave = v; -} - -bool TestDPointer::autoSave() -{ - return self()->d->autoSave; -} - - -KConfigSkeleton::ItemBool *TestDPointer::autoSaveItem() -{ - return d->autoSaveItem; -} - -void TestDPointer::setAutoSaveInterval( int v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "AutoSaveInterval" ) )) - self()->d->autoSaveInterval = v; -} - -int TestDPointer::autoSaveInterval() -{ - return self()->d->autoSaveInterval; -} - - -KConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem() -{ - return d->autoSaveIntervalItem; -} - -void TestDPointer::setConfirm( bool v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "Confirm" ) )) - self()->d->confirm = v; -} - -bool TestDPointer::confirm() -{ - return self()->d->confirm; -} - - -KConfigSkeleton::ItemBool *TestDPointer::confirmItem() -{ - return d->confirmItem; -} - -void TestDPointer::setArchiveFile( const TQString & v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "ArchiveFile" ) )) - self()->d->archiveFile = v; -} - -TQString TestDPointer::archiveFile() -{ - return self()->d->archiveFile; -} - - -KConfigSkeleton::ItemString *TestDPointer::archiveFileItem() -{ - return d->archiveFileItem; -} - -void TestDPointer::setDestination( int v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "Destination" ) )) - self()->d->destination = v; -} - -int TestDPointer::destination() -{ - return self()->d->destination; -} - - -KConfigSkeleton::ItemEnum *TestDPointer::destinationItem() -{ - return d->destinationItem; -} - -void TestDPointer::setHourSize( int v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "HourSize" ) )) - self()->d->hourSize = v; -} - -int TestDPointer::hourSize() -{ - return self()->d->hourSize; -} - - -KConfigSkeleton::ItemInt *TestDPointer::hourSizeItem() -{ - return d->hourSizeItem; -} - -void TestDPointer::setSelectionStartsEditor( bool v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "SelectionStartsEditor" ) )) - self()->d->selectionStartsEditor = v; -} - -bool TestDPointer::selectionStartsEditor() -{ - return self()->d->selectionStartsEditor; -} - - -KConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem() -{ - return d->selectionStartsEditorItem; -} - -void TestDPointer::setSelectedPlugins( const TQStringList & v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "SelectedPlugins" ) )) - self()->d->selectedPlugins = v; -} - -TQStringList TestDPointer::selectedPlugins() -{ - return self()->d->selectedPlugins; -} - - -KConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem() -{ - return d->selectedPluginsItem; -} - -void TestDPointer::setHighlightColor( const TQColor & v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "HighlightColor" ) )) - self()->d->highlightColor = v; -} - -TQColor TestDPointer::highlightColor() -{ - return self()->d->highlightColor; -} - - -KConfigSkeleton::ItemColor *TestDPointer::highlightColorItem() -{ - return d->highlightColorItem; -} - -void TestDPointer::setAgendaBgColor( const TQColor & v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "AgendaBgColor" ) )) - self()->d->agendaBgColor = v; -} - -TQColor TestDPointer::agendaBgColor() -{ - return self()->d->agendaBgColor; -} - - -KConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem() -{ - return d->agendaBgColorItem; -} - -void TestDPointer::setTimeBarFont( const TQFont & v ) -{ - if (!self()->isImmutable( TQString::tqfromLatin1( "TimeBarFont" ) )) - self()->d->timeBarFont = v; -} - -TQFont TestDPointer::timeBarFont() -{ - return self()->d->timeBarFont; -} - - -KConfigSkeleton::ItemFont *TestDPointer::timeBarFontItem() -{ - return d->timeBarFontItem; -} - -TestDPointer::~TestDPointer() -{ - delete d; - if ( mSelf == this ) - staticTestDPointerDeleter.setObject( mSelf, 0, false ); -} - diff --git a/kdecore/kconfig_compiler/tests/test_dpointer.h.ref b/kdecore/kconfig_compiler/tests/test_dpointer.h.ref deleted file mode 100644 index 81f281e83..000000000 --- a/kdecore/kconfig_compiler/tests/test_dpointer.h.ref +++ /dev/null @@ -1,224 +0,0 @@ -// This file is generated by kconfig_compiler from test_dpointer.kcfg. -// All changes you do to this file will be lost. -#ifndef TESTDPOINTER_H -#define TESTDPOINTER_H - -#include <kconfigskeleton.h> -#include <kdebug.h> - -class TestDPointerPrivate; - -class TestDPointer : public KConfigSkeleton -{ - public: - class EnumDestination - { - public: - enum type { standardDestination, askDestination, argl1, argl2, argl3, COUNT }; - }; - - static TestDPointer *self(); - ~TestDPointer(); - - /** - Set Enable automatic saving of calendar - */ - static - void setAutoSave( bool v ); - - /** - Get Enable automatic saving of calendar - */ - static - bool autoSave(); - - /** - Get Item object corresponding to AutoSave() - */ - ItemBool *autoSaveItem(); - - /** - Set Auto Save Interval - */ - static - void setAutoSaveInterval( int v ); - - /** - Get Auto Save Interval - */ - static - int autoSaveInterval(); - - /** - Get Item object corresponding to AutoSaveInterval() - */ - ItemInt *autoSaveIntervalItem(); - - /** - Set Confirm deletes - */ - static - void setConfirm( bool v ); - - /** - Get Confirm deletes - */ - static - bool confirm(); - - /** - Get Item object corresponding to Confirm() - */ - ItemBool *confirmItem(); - - /** - Set Archive File - */ - static - void setArchiveFile( const TQString & v ); - - /** - Get Archive File - */ - static - TQString archiveFile(); - - /** - Get Item object corresponding to ArchiveFile() - */ - ItemString *archiveFileItem(); - - /** - Set New Events/Todos Should - */ - static - void setDestination( int v ); - - /** - Get New Events/Todos Should - */ - static - int destination(); - - /** - Get Item object corresponding to Destination() - */ - ItemEnum *destinationItem(); - - /** - Set Hour Size - */ - static - void setHourSize( int v ); - - /** - Get Hour Size - */ - static - int hourSize(); - - /** - Get Item object corresponding to HourSize() - */ - ItemInt *hourSizeItem(); - - /** - Set Time range selection in agenda view starts event editor - */ - static - void setSelectionStartsEditor( bool v ); - - /** - Get Time range selection in agenda view starts event editor - */ - static - bool selectionStartsEditor(); - - /** - Get Item object corresponding to SelectionStartsEditor() - */ - ItemBool *selectionStartsEditorItem(); - - /** - Set SelectedPlugins - */ - static - void setSelectedPlugins( const TQStringList & v ); - - /** - Get SelectedPlugins - */ - static - TQStringList selectedPlugins(); - - /** - Get Item object corresponding to SelectedPlugins() - */ - ItemStringList *selectedPluginsItem(); - - /** - Set Highlight color - */ - static - void setHighlightColor( const TQColor & v ); - - /** - Get Highlight color - */ - static - TQColor highlightColor(); - - /** - Get Item object corresponding to HighlightColor() - */ - ItemColor *highlightColorItem(); - - /** - Set Agenda view background color - */ - static - void setAgendaBgColor( const TQColor & v ); - - /** - Get Agenda view background color - */ - static - TQColor agendaBgColor(); - - /** - Get Item object corresponding to AgendaBgColor() - */ - ItemColor *agendaBgColorItem(); - - /** - Set Time bar - */ - static - void setTimeBarFont( const TQFont & v ); - - /** - Get Time bar - */ - static - TQFont timeBarFont(); - - /** - Get Item object corresponding to TimeBarFont() - */ - ItemFont *timeBarFontItem(); - - static - void writeConfig() - { - static_cast<KConfigSkeleton*>(self())->writeConfig(); - } - protected: - TestDPointer(); - static TestDPointer *mSelf; - - private: - TestDPointerPrivate *d; -}; - -#endif - diff --git a/kdecore/kconfig_compiler/tests/test_dpointer.kcfg b/kdecore/kconfig_compiler/tests/test_dpointer.kcfg deleted file mode 100644 index 3b19e270e..000000000 --- a/kdecore/kconfig_compiler/tests/test_dpointer.kcfg +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - <kcfgfile name="korganizerrc"/> - - <group name="General"> - <entry type="Bool" key="Auto Save"> - <label>Enable automatic saving of calendar</label> - <whatsthis>WhatsThis text for AutoSave option</whatsthis> - <default>false</default> - </entry> - <entry type="Int" key="Auto Save Interval"> - <default>10</default> - </entry> - <entry type="Bool" key="Confirm Deletes" name="Confirm"> - <label>Confirm deletes</label> - <default>true</default> - </entry> - <entry type="String" key="Archive File"> - </entry> - <entry type="Enum" key="Destination" name="Destination"> - <label>New Events/Todos Should</label> - <choices> - <choice name="standardDestination"> - </choice> - <choice name="askDestination"> - </choice> - <choice name="argl1"> - <label>Argl1 Label</label> - </choice> - <choice name="argl2"> - <whatsthis>Argl2 Whatsthis</whatsthis> - </choice> - <choice name="argl3"> - <label>Argl3 Label</label> - <whatsthis>Argl3 Whatsthis</whatsthis> - </choice> - </choices> - <default>standardDestination</default> - </entry> - </group> - - <group name="Views"> - <entry type="Int" key="Hour Size"> - <default>10</default> - </entry> - <entry type="Bool" name="SelectionStartsEditor"> - <label>Time range selection in agenda view starts event editor</label> - <default>false</default> - </entry> - </group> - - <group name="KOrganizer Plugins"> - <entry type="StringList" name="SelectedPlugins"> - <default>holidays,webexport</default> - </entry> - </group> - - <group name="Colors"> - <entry type="Color" key="Highlight Color"> - <label>Highlight color</label> - <default>100, 100, 255</default> - </entry> - <entry type="Color" key="Agenda Background Color" name="AgendaBgColor"> - <label>Agenda view background color</label> - <default>255, 255, 255</default> - </entry> - </group> - - <group name="Fonts"> - <entry type="Font" key="TimeBar Font"> - <label>Time bar</label> - </entry> - </group> - -</kcfg> diff --git a/kdecore/kconfig_compiler/tests/test_dpointer.kcfgc b/kdecore/kconfig_compiler/tests/test_dpointer.kcfgc deleted file mode 100644 index 48baa376e..000000000 --- a/kdecore/kconfig_compiler/tests/test_dpointer.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test_dpointer.kcfg -ClassName=TestDPointer -Singleton=true -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -MemberVariables=dpointer -#GlobalEnums=true -ItemAccessors=true -SetUserTexts=true diff --git a/kdecore/kconfig_compiler/tests/test_dpointer_main.cpp b/kdecore/kconfig_compiler/tests/test_dpointer_main.cpp deleted file mode 100644 index a6c23c8fe..000000000 --- a/kdecore/kconfig_compiler/tests/test_dpointer_main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2005 Duncan Mac-Vicar P. <duncan@kde.org> - -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 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. -*/ - -#include "test_dpointer.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - KInstance i("test"); - TestDPointer *t = TestDPointer::self(); - delete t; -} diff --git a/kdecore/kconfigbackend.cpp b/kdecore/kconfigbackend.cpp deleted file mode 100644 index 633458d41..000000000 --- a/kdecore/kconfigbackend.cpp +++ /dev/null @@ -1,1186 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (c) 1997-1999 Matthias Kalle Dalheimer <kalle@kde.org> - - 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. -*/ - -#include <config.h> - -#include <unistd.h> -#include <ctype.h> -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif -#include <sys/types.h> -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#include <fcntl.h> -#include <signal.h> -#include <setjmp.h> - -#include <tqdir.h> -#include <tqfileinfo.h> -#include <tqtextcodec.h> -#include <tqtextstream.h> - -#include "kconfigbackend.h" -#include "kconfigbase.h" -#include <kapplication.h> -#include <kglobal.h> -#include <kprocess.h> -#include <klocale.h> -#include <kstandarddirs.h> -#include <ksavefile.h> -#include <kurl.h> -#include <kde_file.h> - -extern bool checkAccess(const TQString& pathname, int mode); -/* translate escaped escape sequences to their actual values. */ -static TQCString printableToString(const char *str, int l) -{ - // Strip leading white-space. - while((l>0) && - ((*str == ' ') || (*str == '\t') || (*str == '\r'))) - { - str++; l--; - } - - // Strip trailing white-space. - while((l>0) && - ((str[l-1] == ' ') || (str[l-1] == '\t') || (str[l-1] == '\r'))) - { - l--; - } - - TQCString result(l + 1); - char *r = result.data(); - - for(int i = 0; i < l;i++, str++) - { - if (*str == '\\') - { - i++, str++; - if (i >= l) // End of line. (Line ends with single slash) - { - *r++ = '\\'; - break; - } - switch(*str) - { - case 's': - *r++ = ' '; - break; - case 't': - *r++ = '\t'; - break; - case 'n': - *r++ = '\n'; - break; - case 'r': - *r++ = '\r'; - break; - case '\\': - *r++ = '\\'; - break; - default: - *r++ = '\\'; - *r++ = *str; - } - } - else - { - *r++ = *str; - } - } - result.truncate(r-result.data()); - return result; -} - -static TQCString stringToPrintable(const TQCString& str){ - TQCString result(str.length()*2); // Maximum 2x as long as source string - register char *r = const_cast<TQCString&>(result).data(); - register char *s = const_cast<TQCString&>(str).data(); - - if (!s) return TQCString(""); - - // Escape leading space - if (*s == ' ') - { - *r++ = '\\'; *r++ = 's'; - s++; - } - - if (*s) - { - while(*s) - { - if (*s == '\n') - { - *r++ = '\\'; *r++ = 'n'; - } - else if (*s == '\t') - { - *r++ = '\\'; *r++ = 't'; - } - else if (*s == '\r') - { - *r++ = '\\'; *r++ = 'r'; - } - else if (*s == '\\') - { - *r++ = '\\'; *r++ = '\\'; - } - else - { - *r++ = *s; - } - s++; - } - // Escape trailing space - if (*(r-1) == ' ') - { - *(r-1) = '\\'; *r++ = 's'; - } - } - - result.truncate(r - result.data()); - return result; -} - -static TQCString decodeGroup(const char*s, int l) -{ - TQCString result(l); - register char *r = result.data(); - - l--; // Correct for trailing \0 - while(l) - { - if ((*s == '[') && (l > 1)) - { - if ((*(s+1) == '[')) - { - l--; - s++; - } - } - if ((*s == ']') && (l > 1)) - { - if ((*(s+1) == ']')) - { - l--; - s++; - } - } - *r++ = *s++; - l--; - } - result.truncate(r - result.data()); - return result; -} - -static TQCString encodeGroup(const TQCString &str) -{ - int l = str.length(); - TQCString result(l*2+1); - register char *r = const_cast<TQCString&>(result).data(); - register char *s = const_cast<TQCString&>(str).data(); - while(l) - { - if ((*s == '[') || (*s == ']')) - *r++ = *s; - *r++ = *s++; - l--; - } - result.truncate(r - result.data()); - return result; -} - -static TQCString encodeKey(const char* key) -{ - TQCString newKey(key); - - newKey.replace('[', "%5b"); - newKey.replace(']', "%5d"); - - return newKey; -} - -static TQCString decodeKey(const char* key) -{ - TQCString newKey(key); - - newKey.replace("%5b", "["); - newKey.replace("%5d", "]"); - - return newKey; -} - -class KConfigBackEnd::KConfigBackEndPrivate -{ -public: - TQDateTime localLastModified; - uint localLastSize; - KLockFile::Ptr localLockFile; - KLockFile::Ptr globalLockFile; -}; - -void KConfigBackEnd::changeFileName(const TQString &_fileName, - const char * _resType, - bool _useKDEGlobals) -{ - mfileName = _fileName; - resType = _resType; - useKDEGlobals = _useKDEGlobals; - if (mfileName.isEmpty()) - mLocalFileName = TQString::null; - else if (!TQDir::isRelativePath(mfileName)) - mLocalFileName = mfileName; - else - mLocalFileName = KGlobal::dirs()->saveLocation(resType) + mfileName; - - if (useKDEGlobals) - mGlobalFileName = KGlobal::dirs()->saveLocation("config") + - TQString::tqfromLatin1("kdeglobals"); - else - mGlobalFileName = TQString::null; - - d->localLastModified = TQDateTime(); - d->localLastSize = 0; - d->localLockFile = 0; - d->globalLockFile = 0; -} - -KLockFile::Ptr KConfigBackEnd::lockFile(bool bGlobal) -{ - if (bGlobal) - { - if (d->globalLockFile) - return d->globalLockFile; - - if (!mGlobalFileName.isEmpty()) - { - d->globalLockFile = new KLockFile(mGlobalFileName+".lock"); - return d->globalLockFile; - } - } - else - { - if (d->localLockFile) - return d->localLockFile; - - if (!mLocalFileName.isEmpty()) - { - d->localLockFile = new KLockFile(mLocalFileName+".lock"); - return d->localLockFile; - } - } - return 0; -} - -KConfigBackEnd::KConfigBackEnd(KConfigBase *_config, - const TQString &_fileName, - const char * _resType, - bool _useKDEGlobals) - : pConfig(_config), bFileImmutable(false), mConfigState(KConfigBase::NoAccess), mFileMode(-1) -{ - d = new KConfigBackEndPrivate; - changeFileName(_fileName, _resType, _useKDEGlobals); -} - -KConfigBackEnd::~KConfigBackEnd() -{ - delete d; -} - -void KConfigBackEnd::setFileWriteMode(int mode) -{ - mFileMode = mode; -} - -bool KConfigINIBackEnd::parseConfigFiles() -{ - // Check if we can write to the local file. - mConfigState = KConfigBase::ReadOnly; - if (!mLocalFileName.isEmpty() && !pConfig->isReadOnly()) - { - if (checkAccess(mLocalFileName, W_OK)) - { - mConfigState = KConfigBase::ReadWrite; - } - else - { - // Create the containing dir, maybe it wasn't there - KURL path; - path.setPath(mLocalFileName); - TQString dir=path.directory(); - KStandardDirs::makeDir(dir); - - if (checkAccess(mLocalFileName, W_OK)) - { - mConfigState = KConfigBase::ReadWrite; - } - } - TQFileInfo info(mLocalFileName); - d->localLastModified = info.lastModified(); - d->localLastSize = info.size(); - } - - // Parse all desired files from the least to the most specific. - bFileImmutable = false; - - // Parse the general config files - if (useKDEGlobals) { - TQStringList kdercs = KGlobal::dirs()-> - findAllResources("config", TQString::tqfromLatin1("kdeglobals")); - -#ifdef Q_WS_WIN - TQString etc_kderc = TQFile::decodeName( TQCString(getenv("WINDIR")) + "\\kderc" ); -#else - TQString etc_kderc = TQString::tqfromLatin1("/etc/kderc"); -#endif - - if (checkAccess(etc_kderc, R_OK)) - kdercs += etc_kderc; - - kdercs += KGlobal::dirs()-> - findAllResources("config", TQString::tqfromLatin1("system.kdeglobals")); - - TQStringList::ConstIterator it; - - for (it = kdercs.fromLast(); it != kdercs.end(); --it) { - - TQFile aConfigFile( *it ); - if (!aConfigFile.open( IO_ReadOnly )) - continue; - parseSingleConfigFile( aConfigFile, 0L, true, (*it != mGlobalFileName) ); - aConfigFile.close(); - if (bFileImmutable) - break; - } - } - - bool bReadFile = !mfileName.isEmpty(); - while(bReadFile) { - bReadFile = false; - TQString bootLanguage; - if (useKDEGlobals && localeString.isEmpty() && !KGlobal::_locale) { - // Boot strap language - bootLanguage = KLocale::_initLanguage(pConfig); - setLocaleString(bootLanguage.utf8()); - } - - bFileImmutable = false; - TQStringList list; - if ( !TQDir::isRelativePath(mfileName) ) - list << mfileName; - else - list = KGlobal::dirs()->findAllResources(resType, mfileName); - - TQStringList::ConstIterator it; - - for (it = list.fromLast(); it != list.end(); --it) { - - TQFile aConfigFile( *it ); - // we can already be sure that this file exists - bool bIsLocal = (*it == mLocalFileName); - if (aConfigFile.open( IO_ReadOnly )) { - parseSingleConfigFile( aConfigFile, 0L, false, !bIsLocal ); - aConfigFile.close(); - if (bFileImmutable) - break; - } - } - if (KGlobal::dirs()->isRestrictedResource(resType, mfileName)) - bFileImmutable = true; - TQString currentLanguage; - if (!bootLanguage.isEmpty()) - { - currentLanguage = KLocale::_initLanguage(pConfig); - // If the file changed the language, we need to read the file again - // with the new language setting. - if (bootLanguage != currentLanguage) - { - bReadFile = true; - setLocaleString(currentLanguage.utf8()); - } - } - } - if (bFileImmutable) - mConfigState = KConfigBase::ReadOnly; - - return true; -} - -#ifdef HAVE_MMAP -#ifdef SIGBUS -static sigjmp_buf mmap_jmpbuf; -struct sigaction mmap_old_sigact; - -extern "C" { - static void mmap_sigbus_handler(int) - { - siglongjmp (mmap_jmpbuf, 1); - } -} -#endif -#endif - -extern bool kde_kiosk_exception; - -void KConfigINIBackEnd::parseSingleConfigFile(TQFile &rFile, - KEntryMap *pWriteBackMap, - bool bGlobal, bool bDefault) -{ - const char *s; // May get clobbered by sigsetjump, but we don't use them afterwards. - const char *eof; // May get clobbered by sigsetjump, but we don't use them afterwards. - TQByteArray data; - - if (!rFile.isOpen()) // come back, if you have real work for us ;-> - return; - - //using kdDebug() here leads to an infinite loop - //remove this for the release, aleXXX - //qWarning("Parsing %s, global = %s default = %s", - // rFile.name().latin1(), bGlobal ? "true" : "false", bDefault ? "true" : "false"); - - TQCString aCurrentGroup("<default>"); - - unsigned int ll = localeString.length(); - -#ifdef HAVE_MMAP - static volatile const char *map; - map = ( const char* ) mmap(0, rFile.size(), PROT_READ, MAP_PRIVATE, - rFile.handle(), 0); - - if ( map != MAP_FAILED ) - { - s = (const char*) map; - eof = s + rFile.size(); - -#ifdef SIGBUS - struct sigaction act; - act.sa_handler = mmap_sigbus_handler; - sigemptyset( &act.sa_mask ); -#ifdef SA_ONESHOT - act.sa_flags = SA_ONESHOT; -#else - act.sa_flags = SA_RESETHAND; -#endif - sigaction( SIGBUS, &act, &mmap_old_sigact ); - - if (sigsetjmp (mmap_jmpbuf, 1)) - { -qWarning("SIGBUS while reading %s", rFile.name().latin1()); - munmap(( char* )map, rFile.size()); - sigaction (SIGBUS, &mmap_old_sigact, 0); - return; - } -#endif - } - else -#endif - { - rFile.tqat(0); - data = rFile.readAll(); - s = data.data(); - eof = s + data.size(); - } - - bool fileOptionImmutable = false; - bool groupOptionImmutable = false; - bool groupSkip = false; - bool foundGettextDomain = false; - TQCString gettextDomain; - - int line = 0; - for(; s < eof; s++) - { - line++; - - while((s < eof) && isspace(*s) && (*s != '\n')) - s++; //skip leading whitespace, shouldn't happen too often - - //skip empty lines, lines starting with # - if ((s < eof) && ((*s == '\n') || (*s == '#'))) - { - sktoeol: //skip till end-of-line - while ((s < eof) && (*s != '\n')) - s++; - continue; // Empty or comment or no keyword - } - const char *startLine = s; - - if (*s == '[') //group - { - // In a group [[ and ]] have a special meaning - while ((s < eof) && (*s != '\n')) - { - if (*s == ']') - { - if ((s+1 < eof) && (*(s+1) == ']')) - s++; // Skip "]]" - else - break; - } - - s++; // Search till end of group - } - const char *e = s; - while ((s < eof) && (*s != '\n')) s++; // Search till end of line / end of file - if ((e >= eof) || (*e != ']')) - { - fprintf(stderr, "Invalid group header at %s:%d\n", rFile.name().latin1(), line); - continue; - } - // group found; get the group name by taking everything in - // between the brackets - if ((e-startLine == 3) && - (startLine[1] == '$') && - (startLine[2] == 'i')) - { - if (!kde_kiosk_exception) - fileOptionImmutable = true; - continue; - } - - aCurrentGroup = decodeGroup(startLine + 1, e - startLine); - //cout<<"found group ["<<aCurrentGroup<<"]"<<endl; - - // Backwards compatibility - if (aCurrentGroup == "KDE Desktop Entry") - aCurrentGroup = "Desktop Entry"; - - groupOptionImmutable = fileOptionImmutable; - - e++; - if ((e+2 < eof) && (*e++ == '[') && (*e++ == '$')) // Option follows - { - if ((*e == 'i') && !kde_kiosk_exception) - { - groupOptionImmutable = true; - } - } - - KEntryKey groupKey(aCurrentGroup, 0); - KEntry entry = pConfig->lookupData(groupKey); - groupSkip = entry.bImmutable; - - if (groupSkip && !bDefault) - continue; - - entry.bImmutable |= groupOptionImmutable; - pConfig->putData(groupKey, entry, false); - - if (pWriteBackMap) - { - // add the special group key indicator - (*pWriteBackMap)[groupKey] = entry; - } - - continue; - } - if (groupSkip && !bDefault) - goto sktoeol; // Skip entry - - - bool optionImmutable = groupOptionImmutable; - bool optionDeleted = false; - bool optionExpand = false; - const char *endOfKey = 0, *locale = 0, *elocale = 0; - for (; (s < eof) && (*s != '\n'); s++) - { - if (*s == '=') //find the equal sign - { - if (!endOfKey) - endOfKey = s; - goto haveeq; - } - if (*s == '[') //find the locale or options. - { - const char *option; - const char *eoption; - endOfKey = s; - option = ++s; - for (;; s++) - { - if ((s >= eof) || (*s == '\n') || (*s == '=')) { - fprintf(stderr, "Invalid entry (missing ']') at %s:%d\n", rFile.name().latin1(), line); - goto sktoeol; - } - if (*s == ']') - break; - } - eoption = s; - if (*option != '$') - { - // Locale - if (locale) { - fprintf(stderr, "Invalid entry (second locale!?) at %s:%d\n", rFile.name().latin1(), line); - goto sktoeol; - } - locale = option; - elocale = eoption; - } - else - { - // Option - while (option < eoption) - { - option++; - if ((*option == 'i') && !kde_kiosk_exception) - optionImmutable = true; - else if (*option == 'e') - optionExpand = true; - else if (*option == 'd') - { - optionDeleted = true; - goto haveeq; - } - else if (*option == ']') - break; - } - } - } - } - fprintf(stderr, "Invalid entry (missing '=') at %s:%d\n", rFile.name().latin1(), line); - continue; - - haveeq: - for (endOfKey--; ; endOfKey--) - { - if (endOfKey < startLine) - { - fprintf(stderr, "Invalid entry (empty key) at %s:%d\n", rFile.name().latin1(), line); - goto sktoeol; - } - if (!isspace(*endOfKey)) - break; - } - - const char *st = ++s; - while ((s < eof) && (*s != '\n')) s++; // Search till end of line / end of file - - if (locale) { - unsigned int cl = static_cast<unsigned int>(elocale - locale); - if ((ll != cl) || memcmp(locale, localeString.data(), ll)) - { - // backward compatibility. C == en_US - if ( cl != 1 || ll != 5 || *locale != 'C' || memcmp(localeString.data(), "en_US", 5)) { - //cout<<"mismatched locale '"<<TQCString(locale, elocale-locale +1)<<"'"<<endl; - // We can ignore this one - if (!pWriteBackMap) - continue; // We just ignore it - // We just store it as is to be able to write it back later. - endOfKey = elocale; - locale = 0; - } - } - } - - // insert the key/value line - TQCString key(startLine, endOfKey - startLine + 2); - TQCString val = printableToString(st, s - st); - //qDebug("found key '%s' with value '%s'", key.data(), val.data()); - - if (TQString(key.data()) == "X-Ubuntu-Gettext-Domain") { - gettextDomain = val.data(); - foundGettextDomain = true; - } - - KEntryKey aEntryKey(aCurrentGroup, decodeKey(key)); - aEntryKey.bLocal = (locale != 0); - aEntryKey.bDefault = bDefault; - - KEntry aEntry; - aEntry.mValue = val; - aEntry.bGlobal = bGlobal; - aEntry.bImmutable = optionImmutable; - aEntry.bDeleted = optionDeleted; - aEntry.bExpand = optionExpand; - aEntry.bNLS = (locale != 0); - - if (pWriteBackMap) { - // don't insert into the config object but into the temporary - // scratchpad map - pWriteBackMap->insert(aEntryKey, aEntry); - } else { - // directly insert value into config object - // no need to specify localization; if the key we just - // retrieved was localized already, no need to localize it again. - pConfig->putData(aEntryKey, aEntry, false); - } - } - // Look up translations using KLocale - // https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde - // This calls KLocale up to 10 times for each config file (and each KConfig has up to 4 files) - // so I'll see how much of a performance hit it is - // it also only acts on the last group in a file - // Ideas: only translate most important fields, only translate "Desktop Entry" files, - // do translation per KConfig not per single file - if (!pWriteBackMap) { - TQFile file("file.txt"); - if (foundGettextDomain) { - - KLocale locale(gettextDomain); - - TQString language = locale.language(); - translateKey(locale, aCurrentGroup, TQCString("Name")); - translateKey(locale, aCurrentGroup, TQCString("Comment")); - translateKey(locale, aCurrentGroup, TQCString("Language")); - translateKey(locale, aCurrentGroup, TQCString("Keywords")); - translateKey(locale, aCurrentGroup, TQCString("About")); - translateKey(locale, aCurrentGroup, TQCString("Description")); - translateKey(locale, aCurrentGroup, TQCString("GenericName")); - translateKey(locale, aCurrentGroup, TQCString("Query")); - translateKey(locale, aCurrentGroup, TQCString("ExtraNames")); - translateKey(locale, aCurrentGroup, TQCString("X-KDE-Submenu")); - } - } - - - if (fileOptionImmutable) - bFileImmutable = true; - -#ifdef HAVE_MMAP - if (map) - { - munmap(( char* )map, rFile.size()); -#ifdef SIGBUS - sigaction (SIGBUS, &mmap_old_sigact, 0); -#endif - } -#endif -} - -void KConfigINIBackEnd::translateKey(KLocale& locale, TQCString currentGroup, TQCString key) { - KEntryKey entryKey = KEntryKey(currentGroup, key); - KEntry entry = pConfig->lookupData(entryKey); - if (TQString(entry.mValue) != "") { - TQString orig = key + "=" + entry.mValue; - TQString translate = locale.translate(key + "=" + entry.mValue); - if (TQString::compare(orig, translate) != 0) { - translate = translate.mid(key.length() + 1); - entry.mValue = translate.utf8(); - entryKey.bLocal = true; - entry.bNLS = true; - pConfig->putData(entryKey, entry, false); - } - } -} - -void KConfigINIBackEnd::sync(bool bMerge) -{ - // write-sync is only necessary if there are dirty entries - if (!pConfig->isDirty()) - return; - - bool bEntriesLeft = true; - - // find out the file to write to (most specific writable file) - // try local app-specific file first - - if (!mfileName.isEmpty()) { - // Create the containing dir if needed - if ((resType!="config") && !TQDir::isRelativePath(mLocalFileName)) - { - KURL path; - path.setPath(mLocalFileName); - TQString dir=path.directory(); - KStandardDirs::makeDir(dir); - } - - // Can we allow the write? We can, if the program - // doesn't run SUID. But if it runs SUID, we must - // check if the user would be allowed to write if - // it wasn't SUID. - if (checkAccess(mLocalFileName, W_OK)) { - // File is writable - KLockFile::Ptr lf; - - bool mergeLocalFile = bMerge; - // Check if the file has been updated since. - if (mergeLocalFile) - { - lf = lockFile(false); // Lock file for local file - if (lf && lf->isLocked()) - lf = 0; // Already locked, we don't need to lock/unlock again - - if (lf) - { - lf->lock( KLockFile::LockForce ); - // But what if the locking failed? Ignore it for now... - } - - TQFileInfo info(mLocalFileName); - if ((d->localLastSize == info.size()) && - (d->localLastModified == info.lastModified())) - { - // Not changed, don't merge. - mergeLocalFile = false; - } - else - { - // Changed... - d->localLastModified = TQDateTime(); - d->localLastSize = 0; - } - } - - bEntriesLeft = writeConfigFile( mLocalFileName, false, mergeLocalFile ); - - // Only if we didn't have to merge anything can we use our in-memory state - // the next time around. Otherwise the config-file may contain entries - // that are different from our in-memory state which means we will have to - // do a merge from then on. - // We do not automatically update the in-memory state with the on-disk - // state when writing the config to disk. We only do so when - // KCOnfig::reparseConfiguration() is called. - // For KDE 4.0 we may wish to reconsider that. - if (!mergeLocalFile) - { - TQFileInfo info(mLocalFileName); - d->localLastModified = info.lastModified(); - d->localLastSize = info.size(); - } - if (lf) lf->unlock(); - } - } - - // only write out entries to the kdeglobals file if there are any - // entries marked global (indicated by bEntriesLeft) and - // the useKDEGlobals flag is set. - if (bEntriesLeft && useKDEGlobals) { - - // can we allow the write? (see above) - if (checkAccess ( mGlobalFileName, W_OK )) { - KLockFile::Ptr lf = lockFile(true); // Lock file for global file - if (lf && lf->isLocked()) - lf = 0; // Already locked, we don't need to lock/unlock again - - if (lf) - { - lf->lock( KLockFile::LockForce ); - // But what if the locking failed? Ignore it for now... - } - writeConfigFile( mGlobalFileName, true, bMerge ); // Always merge - if (lf) lf->unlock(); - } - } - -} - -static void writeEntries(FILE *pStream, const KEntryMap& entryMap, bool defaultGroup, bool &firstEntry, const TQCString &localeString) -{ - // now write out all other groups. - TQCString currentGroup; - for (KEntryMapConstIterator aIt = entryMap.begin(); - aIt != entryMap.end(); ++aIt) - { - const KEntryKey &key = aIt.key(); - - // Either proces the default group or all others - if ((key.mGroup != "<default>") == defaultGroup) - continue; // Skip - - // Skip default values and group headers. - if ((key.bDefault) || key.mKey.isEmpty()) - continue; // Skip - - const KEntry ¤tEntry = *aIt; - - KEntryMapConstIterator aTestIt = aIt; - ++aTestIt; - bool hasDefault = (aTestIt != entryMap.end()); - if (hasDefault) - { - const KEntryKey &defaultKey = aTestIt.key(); - if ((!defaultKey.bDefault) || - (defaultKey.mKey != key.mKey) || - (defaultKey.mGroup != key.mGroup) || - (defaultKey.bLocal != key.bLocal)) - hasDefault = false; - } - - - if (hasDefault) - { - // Entry had a default value - if ((currentEntry.mValue == (*aTestIt).mValue) && - (currentEntry.bDeleted == (*aTestIt).bDeleted)) - continue; // Same as default, don't write. - } - else - { - // Entry had no default value. - if (currentEntry.bDeleted) - continue; // Don't write deleted entries if there is no default. - } - - if (!defaultGroup && (currentGroup != key.mGroup)) { - if (!firstEntry) - fprintf(pStream, "\n"); - currentGroup = key.mGroup; - fprintf(pStream, "[%s]\n", encodeGroup(currentGroup).data()); - } - - firstEntry = false; - // it is data for a group - fputs(encodeKey(key.mKey.data()), pStream); // Key - - if ( currentEntry.bNLS ) - { - fputc('[', pStream); - fputs(localeString.data(), pStream); - fputc(']', pStream); - } - - if (currentEntry.bDeleted) - { - fputs("[$d]\n", pStream); // Deleted - } - else - { - if (currentEntry.bImmutable || currentEntry.bExpand) - { - fputc('[', pStream); - fputc('$', pStream); - if (currentEntry.bImmutable) - fputc('i', pStream); - if (currentEntry.bExpand) - fputc('e', pStream); - - fputc(']', pStream); - } - fputc('=', pStream); - fputs(stringToPrintable(currentEntry.mValue).data(), pStream); - fputc('\n', pStream); - } - } // for loop -} - -bool KConfigINIBackEnd::getEntryMap(KEntryMap &aTempMap, bool bGlobal, - TQFile *mergeFile) -{ - bool bEntriesLeft = false; - bFileImmutable = false; - - // Read entries from disk - if (mergeFile && mergeFile->open(IO_ReadOnly)) - { - // fill the temporary structure with entries from the file - parseSingleConfigFile(*mergeFile, &aTempMap, bGlobal, false ); - - if (bFileImmutable) // File has become immutable on disk - return bEntriesLeft; - } - - KEntryMap aMap = pConfig->internalEntryMap(); - - // augment this structure with the dirty entries from the config object - for (KEntryMapIterator aIt = aMap.begin(); - aIt != aMap.end(); ++aIt) - { - const KEntry ¤tEntry = *aIt; - if(aIt.key().bDefault) - { - aTempMap.replace(aIt.key(), currentEntry); - continue; - } - - if (mergeFile && !currentEntry.bDirty) - continue; - - // only write back entries that have the same - // "globality" as the file - if (currentEntry.bGlobal != bGlobal) - { - // wrong "globality" - might have to be saved later - bEntriesLeft = true; - continue; - } - - // put this entry from the config object into the - // temporary map, possibly replacing an existing entry - KEntryMapIterator aIt2 = aTempMap.find(aIt.key()); - if (aIt2 != aTempMap.end() && (*aIt2).bImmutable) - continue; // Bail out if the on-disk entry is immutable - - aTempMap.insert(aIt.key(), currentEntry, true); - } // loop - - return bEntriesLeft; -} - -/* antlarr: KDE 4.0: make the first parameter "const TQString &" */ -bool KConfigINIBackEnd::writeConfigFile(TQString filename, bool bGlobal, - bool bMerge) -{ - // is the config object read-only? - if (pConfig->isReadOnly()) - return true; // pretend we wrote it - - KEntryMap aTempMap; - TQFile *mergeFile = (bMerge ? new TQFile(filename) : 0); - bool bEntriesLeft = getEntryMap(aTempMap, bGlobal, mergeFile); - delete mergeFile; - if (bFileImmutable) - return true; // pretend we wrote it - - // OK now the temporary map should be full of ALL entries. - // write it out to disk. - - // Check if file exists: - int fileMode = -1; - bool createNew = true; - - KDE_struct_stat buf; - if (KDE_stat(TQFile::encodeName(filename), &buf) == 0) - { - if (buf.st_uid == getuid()) - { - // Preserve file mode if file exists and is owned by user. - fileMode = buf.st_mode & 0777; - } - else - { - // File is not owned by user: - // Don't create new file but write to existing file instead. - createNew = false; - } - } - - KSaveFile *pConfigFile = 0; - FILE *pStream = 0; - - if (createNew) - { - pConfigFile = new KSaveFile( filename, 0600 ); - - if (pConfigFile->status() != 0) - { - delete pConfigFile; - return bEntriesLeft; - } - - if (!bGlobal && (fileMode == -1)) - fileMode = mFileMode; - - if (fileMode != -1) - { - fchmod(pConfigFile->handle(), fileMode); - } - - pStream = pConfigFile->fstream(); - } - else - { - // Open existing file. - // We use open() to ensure that we call without O_CREAT. - int fd = KDE_open( TQFile::encodeName(filename), O_WRONLY | O_TRUNC ); - if (fd < 0) - { - return bEntriesLeft; - } - pStream = KDE_fdopen( fd, "w"); - if (!pStream) - { - close(fd); - return bEntriesLeft; - } - } - - writeEntries(pStream, aTempMap); - - if (pConfigFile) - { - bool bEmptyFile = (ftell(pStream) == 0); - if ( bEmptyFile && ((fileMode == -1) || (fileMode == 0600)) ) - { - // File is empty and doesn't have special permissions: delete it. - ::unlink(TQFile::encodeName(filename)); - pConfigFile->abort(); - } - else - { - // Normal case: Close the file - pConfigFile->close(); - } - delete pConfigFile; - } - else - { - fclose(pStream); - } - - return bEntriesLeft; -} - -void KConfigINIBackEnd::writeEntries(FILE *pStream, const KEntryMap &aTempMap) -{ - bool firstEntry = true; - - // Write default group - ::writeEntries(pStream, aTempMap, true, firstEntry, localeString); - - // Write all other groups - ::writeEntries(pStream, aTempMap, false, firstEntry, localeString); -} - -void KConfigBackEnd::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KConfigINIBackEnd::virtual_hook( int id, void* data ) -{ KConfigBackEnd::virtual_hook( id, data ); } - -bool KConfigBackEnd::checkConfigFilesWritable(bool warnUser) -{ - // WARNING: Do NOT use the event loop as it may not exist at this time. - bool allWritable = true; - TQString errorMsg; - if ( !mLocalFileName.isEmpty() && !bFileImmutable && !checkAccess(mLocalFileName,W_OK) ) - { - errorMsg = i18n("Will not save configuration.\n"); - allWritable = false; - errorMsg += i18n("Configuration file \"%1\" not writable.\n").arg(mLocalFileName); - } - // We do not have an immutability flag for kdeglobals. However, making kdeglobals mutable while making - // the local config file immutable is senseless. - if ( !mGlobalFileName.isEmpty() && useKDEGlobals && !bFileImmutable && !checkAccess(mGlobalFileName,W_OK) ) - { - if ( errorMsg.isEmpty() ) - errorMsg = i18n("Will not save configuration.\n"); - errorMsg += i18n("Configuration file \"%1\" not writable.\n").arg(mGlobalFileName); - allWritable = false; - } - - if (warnUser && !allWritable) - { - // Note: We don't ask the user if we should not ask this question again because we can't save the answer. - errorMsg += i18n("Please contact your system administrator."); - TQString cmdToExec = KStandardDirs::findExe(TQString("kdialog")); - KApplication *app = kapp; - if (!cmdToExec.isEmpty() && app) - { - KProcess lprocess; - lprocess << cmdToExec << "--title" << app->instanceName() << "--msgbox" << TQCString(errorMsg.local8Bit()); - lprocess.start( KProcess::Block ); - } - } - return allWritable; -} diff --git a/kdecore/kconfigbackend.h b/kdecore/kconfigbackend.h deleted file mode 100644 index 3b2418330..000000000 --- a/kdecore/kconfigbackend.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Portions copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> - - 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 _KCONFIGBACKEND_H -#define _KCONFIGBACKEND_H - -#include "kconfigdata.h" -#include <kconfigbase.h> -#include <klockfile.h> -#include <klocale.h> -#include "kdelibs_export.h" - -class TQFile; -class KConfigBackEndPrivate; - -/** - * Abstract base class for KDE configuration file loading/saving. - * - * This class forms the base for all classes that implement some - * manner of loading/saving to configuration files. It is an - * abstract base class, meaning that you cannot directly instantiate - * objects of this class. As of right now, the only back end available - * is one to read/write to INI-style files, but in the future, other - * formats may be available, such as XML or a database. - * - * @author Preston Brown <pbrown@kde.org>, - * Matthias Kalle Dalheimer <kalle@kde.org> - * @short KDE Configuration file loading/saving abstract base class - */ -class KDECORE_EXPORT KConfigBackEnd -{ - friend class KConfig; - friend class KSharedConfig; -public: - /** - * Constructs a configuration back end. - * - * @param _config Specifies the configuration object which values - * will be passed to as they are read, or from where values - * to be written to will be obtained from. - * @param _fileName The name of the file in which config - * data is stored. All registered configuration directories - * will be looked in in order of decreasing relevance. - * @param _resType the resource type of the fileName specified, _if_ - * it is not an absolute path (otherwise this parameter is ignored). - * @param _useKDEGlobals If true, the user's system-wide kdeglobals file - * will be imported into the config object. If false, only - * the filename specified will be dealt with. - */ - KConfigBackEnd(KConfigBase *_config, const TQString &_fileName, - const char * _resType, bool _useKDEGlobals); - - /** - * Destructs the configuration backend. - */ - virtual ~KConfigBackEnd(); - - /** - * Parses all configuration files for a configuration object. This - * method must be reimplemented by the derived classes. - * - * @returns Whether or not parsing was successful. - */ - virtual bool parseConfigFiles() = 0; - - /** - * Writes configuration data to file(s). This method must be - * reimplemented by the derived classes. - * - * @param bMerge Specifies whether the old config file already - * on disk should be merged in with the data in memory. If true, - * data is read off the disk and merged. If false, the on-disk - * file is removed and only in-memory data is written out. - */ - virtual void sync(bool bMerge = true) = 0; - - /** - * Changes the filenames associated with this back end. You should - * probably reparse your config info after doing this. - * - * @param _fileName the new filename to use - * @param _resType the resource type of the fileName specified, _if_ - * it is not an absolute path (otherwise this parameter is ignored). - * @param _useKDEGlobals specifies whether or not to also parse the - * global KDE configuration files. - */ - void changeFileName(const TQString &_fileName, const char * _resType, - bool _useKDEGlobals); - - /** - * Returns the state of the app-config object. - * - * @see KConfig::getConfigState - */ - virtual KConfigBase::ConfigState getConfigState() const - { return mConfigState; } - - /** - * Returns the filename as passed to the constructor. - * @return the filename as passed to the constructor. - */ - TQString fileName() const { return mfileName; } - - /** - * Returns the resource type as passed to the constructor. - * @return the resource type as passed to the constructor. - */ - const char * resource() const { return resType; } - - /** - * Set the locale string that defines the current language. - * @param _localeString the identifier of the language - * @see KLocale - */ - void setLocaleString(const TQCString &_localeString) { localeString = _localeString; } - - /** - * Set the file mode for newly created files. - * @param mode the filemode (as in chmod) - */ - void setFileWriteMode(int mode); - - /** - * Check whether the config files are writable. - * @param warnUser Warn the user if the configuration files are not writable. - * @return Indicates that all of the configuration files used are writable. - * @since 3.2 - */ - bool checkConfigFilesWritable(bool warnUser); - - /** - * Returns a lock file object for the configuration file - * @param bGlobal If true, returns a lock file object for kdeglobals - * @since 3.3 - */ - KLockFile::Ptr lockFile( bool bGlobal = false ); - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated Use fileName() instead - */ - KDE_DEPRECATED TQString filename() const { return mfileName; } - -protected: - KConfigBase *pConfig; - - TQString mfileName; - TQCString resType; - bool useKDEGlobals : 1; - bool bFileImmutable : 1; - TQCString localeString; - TQString mLocalFileName; - TQString mGlobalFileName; - KConfigBase::ConfigState mConfigState; - int mFileMode; - -protected: - virtual void virtual_hook( int id, void* data ); -protected: - class KConfigBackEndPrivate; - KConfigBackEndPrivate *d; -}; - - -/** - * Class for KDE INI-style configuration file loading/saving. - * - * @author Preston Brown <pbrown@kde.org>, - * Matthias Kalle Dalheimer <kalle@kde.org> - */ -class KDECORE_EXPORT KConfigINIBackEnd : public KConfigBackEnd -{ - -public: - /** - * Constructs an ini-style configuration back end. - * - * @param _config Specifies the configuration object which values - * will be passed to as they are read, or from where values - * to be written to will be obtained from. - * @param _fileName The name of the file in which config - * data is stored. All registered configuration directories - * will be looked in in order of decreasing relevance. - * @param _resType the resource type of the fileName specified, _if_ - * it is not an absolute path (otherwise this parameter is ignored). - * @param _useKDEGlobals If true, the user's system-wide kdeglobals file - * will be imported into the config object. If false, only - * the filename specified will be dealt with. - */ - KConfigINIBackEnd(KConfigBase *_config, const TQString &_fileName, - const char * _resType, bool _useKDEGlobals = true) - : KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {} - - /** - * Destructs the configuration backend. - */ - virtual ~KConfigINIBackEnd() {} - - /** - * Parses all INI-style configuration files for a config object. - * - * @returns Whether or not parsing was successful. - */ - bool parseConfigFiles(); - - /** - * Writes configuration data to file(s). - * @param bMerge Specifies whether the old config file already - * on disk should be merged in with the data in memory. If true, - * data is read off the disk and merged. If false, the on-disk - * file is removed and only in-memory data is written out. - */ - virtual void sync(bool bMerge = true); - -protected: - /** - * Parses one configuration file. - * - * @param rFile The configuration file to parse - * @param pWriteBackMap If specified, points to a KEntryMap where - * the data read from the file should be stored, instead of - * inserting them directly into the configuration object. - * Use this area as a "scratchpad" when you need to know what is - * on disk but don't want to effect the configuration object. - * @param bGlobal Specifies whether entries should be marked as - * belonging to the global KDE configuration file rather - * than the application-specific KDE configuration file(s). - * @param bDefault Specifies whether entries should be marked as - * being default values. - */ - void parseSingleConfigFile(TQFile& rFile, KEntryMap *pWriteBackMap = 0L, - bool bGlobal = false, bool bDefault = false); - - // Kubuntu patch, 2006-08-03 - // looks up a key in with KLocale - // see https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde - void translateKey(KLocale& locale, TQCString currentGroup, TQCString key); - - /** - * Writes configuration file back. - * - * @param filename The name of the file to write. - * @param bGlobal Specifies whether to write only entries which - * are marked as belonging to the global KDE config file. - * If this is false, it skips those entries. - * @param bMerge Specifies whether the old config file already - * on disk should be merged in with the data in memory. If true, - * data is read off the disk and merged. If false, the on-disk - * file is removed and only in-memory data is written out. - * @return Whether some entries are left to be written to other - * files. - */ - bool writeConfigFile(TQString filename, bool bGlobal = false, bool bMerge = true); - - /** Get the entry map. - * - * @param map the entries will be stored in this object. - * @param bGlobal Specifies whether to get only entries which - * are marked as belonging to the global KDE config file. - * If this is false, it skips those entries. - * @param mergeFile if not null, the dirty entries for this file will - * be merged. - * - * @return Whether there will be some entries left for writing to other - * files. - */ - bool getEntryMap(KEntryMap &map, bool bGlobal, TQFile *mergeFile); - - /** Write the entries in @e aTempMap to the file stream.*/ - void writeEntries(FILE *pStream, const KEntryMap &aTempMap); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KConfigINIBackEndPrivate; - KConfigINIBackEndPrivate *not_d; -}; - -#endif diff --git a/kdecore/kconfigbase.cpp b/kdecore/kconfigbase.cpp deleted file mode 100644 index 20d3f023c..000000000 --- a/kdecore/kconfigbase.cpp +++ /dev/null @@ -1,1935 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> - - 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. -*/ - -#include <stdlib.h> -#include <string.h> - -#include <tqfile.h> -#include <tqdir.h> -#include <tqtextstream.h> - -#include <kapplication.h> -#include <kglobal.h> -#include <klocale.h> -#include <kcharsets.h> - -#include "kconfigbase.h" -#include "kconfigbackend.h" -#include "kdebug.h" -#include "kstandarddirs.h" -#include "kstringhandler.h" - -class KConfigBase::KConfigBasePrivate -{ -public: - KConfigBasePrivate() : readDefaults(false) { }; - -public: - bool readDefaults; -}; - -KConfigBase::KConfigBase() - : backEnd(0L), bDirty(false), bLocaleInitialized(false), - bReadOnly(false), bExpand(false), d(0) -{ - setGroup(TQString::null); -} - -KConfigBase::~KConfigBase() -{ - delete d; -} - -void KConfigBase::setLocale() -{ - bLocaleInitialized = true; - - if (KGlobal::locale()) - aLocaleString = KGlobal::locale()->language().utf8(); - else - aLocaleString = KLocale::defaultLanguage().utf8(); - if (backEnd) - backEnd->setLocaleString(aLocaleString); -} - -TQString KConfigBase::locale() const -{ - return TQString::fromUtf8(aLocaleString); -} - -void KConfigBase::setGroup( const TQString& group ) -{ - if ( group.isEmpty() ) - mGroup = "<default>"; - else - mGroup = group.utf8(); -} - -void KConfigBase::setGroup( const char *pGroup ) -{ - setGroup(TQCString(pGroup)); -} - -void KConfigBase::setGroup( const TQCString &group ) -{ - if ( group.isEmpty() ) - mGroup = "<default>"; - else - mGroup = group; -} - -TQString KConfigBase::group() const { - return TQString::fromUtf8(mGroup); -} - -void KConfigBase::setDesktopGroup() -{ - mGroup = "Desktop Entry"; -} - -bool KConfigBase::hasKey(const TQString &key) const -{ - return hasKey(key.utf8().data()); -} - -bool KConfigBase::hasKey(const char *pKey) const -{ - KEntryKey aEntryKey(mGroup, 0); - aEntryKey.c_key = pKey; - aEntryKey.bDefault = readDefaults(); - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - aEntryKey.bLocal = false; - } - - // try the non-localized version - KEntry entry = lookupData(aEntryKey); - return !entry.mValue.isNull(); -} - -bool KConfigBase::hasTranslatedKey(const char* pKey) const -{ - KEntryKey aEntryKey(mGroup, 0); - aEntryKey.c_key = pKey; - aEntryKey.bDefault = readDefaults(); - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - aEntryKey.bLocal = false; - } - - return false; -} - -bool KConfigBase::hasGroup(const TQString &group) const -{ - return internalHasGroup( group.utf8()); -} - -bool KConfigBase::hasGroup(const char *_pGroup) const -{ - return internalHasGroup( TQCString(_pGroup)); -} - -bool KConfigBase::hasGroup(const TQCString &_pGroup) const -{ - return internalHasGroup( _pGroup); -} - -bool KConfigBase::isImmutable() const -{ - return (getConfigState() != ReadWrite); -} - -bool KConfigBase::groupIsImmutable(const TQString &group) const -{ - if (getConfigState() != ReadWrite) - return true; - - KEntryKey groupKey(group.utf8(), 0); - KEntry entry = lookupData(groupKey); - return entry.bImmutable; -} - -bool KConfigBase::entryIsImmutable(const TQString &key) const -{ - if (getConfigState() != ReadWrite) - return true; - - KEntryKey entryKey(mGroup, 0); - KEntry aEntryData = lookupData(entryKey); // Group - if (aEntryData.bImmutable) - return true; - - TQCString utf8_key = key.utf8(); - entryKey.c_key = utf8_key.data(); - aEntryData = lookupData(entryKey); // Normal entry - if (aEntryData.bImmutable) - return true; - - entryKey.bLocal = true; - aEntryData = lookupData(entryKey); // Localized entry - return aEntryData.bImmutable; -} - - -TQString KConfigBase::readEntryUntranslated( const TQString& pKey, - const TQString& aDefault ) const -{ - return KConfigBase::readEntryUntranslated(pKey.utf8().data(), aDefault); -} - - -TQString KConfigBase::readEntryUntranslated( const char *pKey, - const TQString& aDefault ) const -{ - TQCString result = readEntryUtf8(pKey); - if (result.isNull()) - return aDefault; - return TQString::fromUtf8(result); -} - - -TQString KConfigBase::readEntry( const TQString& pKey, - const TQString& aDefault ) const -{ - return KConfigBase::readEntry(pKey.utf8().data(), aDefault); -} - -TQString KConfigBase::readEntry( const char *pKey, - const TQString& aDefault ) const -{ - // we need to access _locale instead of the method locale() - // because calling locale() will create a locale object if it - // doesn't exist, which requires KConfig, which will create a infinite - // loop, and nobody likes those. - if (!bLocaleInitialized && KGlobal::_locale) { - // get around const'ness. - KConfigBase *that = const_cast<KConfigBase *>(this); - that->setLocale(); - } - - TQString aValue; - - bool expand = false; - // construct a localized version of the key - // try the localized key first - KEntry aEntryData; - KEntryKey entryKey(mGroup, 0); - entryKey.c_key = pKey; - entryKey.bDefault = readDefaults(); - entryKey.bLocal = true; - aEntryData = lookupData(entryKey); - if (!aEntryData.mValue.isNull()) { - // for GNOME .desktop - aValue = KStringHandler::from8Bit( aEntryData.mValue.data() ); - expand = aEntryData.bExpand; - } else { - entryKey.bLocal = false; - aEntryData = lookupData(entryKey); - if (!aEntryData.mValue.isNull()) { - aValue = TQString::fromUtf8(aEntryData.mValue.data()); - if (aValue.isNull()) - { - static const TQString &emptyString = KGlobal::staticQString(""); - aValue = emptyString; - } - expand = aEntryData.bExpand; - } else { - aValue = aDefault; - } - } - - // only do dollar expansion if so desired - if( expand || bExpand ) - { - // check for environment variables and make necessary translations - int nDollarPos = aValue.find( '$' ); - - while( nDollarPos != -1 && nDollarPos+1 < static_cast<int>(aValue.length())) { - // there is at least one $ - if( (aValue)[nDollarPos+1] == '(' ) { - uint nEndPos = nDollarPos+1; - // the next character is no $ - while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=')') ) - nEndPos++; - nEndPos++; - TQString cmd = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); - - TQString result; - FILE *fs = popen(TQFile::encodeName(cmd).data(), "r"); - if (fs) - { - { - TQTextStream ts(fs, IO_ReadOnly); - result = ts.read().stripWhiteSpace(); - } - pclose(fs); - } - aValue.replace( nDollarPos, nEndPos-nDollarPos, result ); - } else if( (aValue)[nDollarPos+1] != '$' ) { - uint nEndPos = nDollarPos+1; - // the next character is no $ - TQString aVarName; - if (aValue[nEndPos]=='{') - { - while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!='}') ) - nEndPos++; - nEndPos++; - aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); - } - else - { - while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber() - || aValue[nEndPos].isLetter() || aValue[nEndPos]=='_' ) ) - nEndPos++; - aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 ); - } - const char* pEnv = 0; - if (!aVarName.isEmpty()) - pEnv = getenv( aVarName.ascii() ); - if( pEnv ) { - // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!! - // A environment variables may contain values in 8bit - // locale cpecified encoding or in UTF8 encoding. - aValue.replace( nDollarPos, nEndPos-nDollarPos, KStringHandler::from8Bit( pEnv ) ); - } else - aValue.remove( nDollarPos, nEndPos-nDollarPos ); - } else { - // remove one of the dollar signs - aValue.remove( nDollarPos, 1 ); - nDollarPos++; - } - nDollarPos = aValue.find( '$', nDollarPos ); - } - } - - return aValue; -} - -TQCString KConfigBase::readEntryUtf8( const char *pKey) const -{ - // We don't try the localized key - KEntryKey entryKey(mGroup, 0); - entryKey.bDefault = readDefaults(); - entryKey.c_key = pKey; - KEntry aEntryData = lookupData(entryKey); - if (aEntryData.bExpand) - { - // We need to do fancy, take the slow route. - return readEntry(pKey, TQString::null).utf8(); - } - return aEntryData.mValue; -} - -TQVariant KConfigBase::readPropertyEntry( const TQString& pKey, - TQVariant::Type type ) const -{ - return readPropertyEntry(pKey.utf8().data(), type); -} - -TQVariant KConfigBase::readPropertyEntry( const char *pKey, - TQVariant::Type type ) const -{ - TQVariant va; - if ( !hasKey( pKey ) ) return va; - (void)va.cast(type); - return readPropertyEntry(pKey, va); -} - -TQVariant KConfigBase::readPropertyEntry( const TQString& pKey, - const TQVariant &aDefault ) const -{ - return readPropertyEntry(pKey.utf8().data(), aDefault); -} - -TQVariant KConfigBase::readPropertyEntry( const char *pKey, - const TQVariant &aDefault ) const -{ - if ( !hasKey( pKey ) ) return aDefault; - - TQVariant tmp = aDefault; - - switch( aDefault.type() ) - { - case TQVariant::Invalid: - return TQVariant(); - case TQVariant::String: - return TQVariant( readEntry( pKey, aDefault.toString() ) ); - case TQVariant::StringList: - return TQVariant( readListEntry( pKey ) ); - case TQVariant::List: { - TQStringList strList = readListEntry( pKey ); - TQStringList::ConstIterator it = strList.begin(); - TQStringList::ConstIterator end = strList.end(); - TQValueList<TQVariant> list; - - for (; it != end; ++it ) { - tmp = *it; - list.append( tmp ); - } - return TQVariant( list ); - } - case TQVariant::Font: - return TQVariant( readFontEntry( pKey, &tmp.asFont() ) ); - case TQVariant::Point: - return TQVariant( readPointEntry( pKey, &tmp.asPoint() ) ); - case TQVariant::Rect: - return TQVariant( readRectEntry( pKey, &tmp.asRect() ) ); - case TQVariant::Size: - return TQVariant( readSizeEntry( pKey, &tmp.asSize() ) ); - case TQVariant::Color: - return TQVariant( readColorEntry( pKey, &tmp.asColor() ) ); - case TQVariant::Int: - return TQVariant( readNumEntry( pKey, aDefault.toInt() ) ); - case TQVariant::UInt: - return TQVariant( readUnsignedNumEntry( pKey, aDefault.toUInt() ) ); - case TQVariant::LongLong: - return TQVariant( readNum64Entry( pKey, aDefault.toLongLong() ) ); - case TQVariant::ULongLong: - return TQVariant( readUnsignedNum64Entry( pKey, aDefault.toULongLong() ) ); - case TQVariant::Bool: - return TQVariant( readBoolEntry( pKey, aDefault.toBool() ), 0 ); - case TQVariant::Double: - return TQVariant( readDoubleNumEntry( pKey, aDefault.toDouble() ) ); - case TQVariant::DateTime: - return TQVariant( readDateTimeEntry( pKey, &tmp.asDateTime() ) ); - case TQVariant::Date: - return TQVariant(TQT_TQDATE_OBJECT(readDateTimeEntry( pKey, &tmp.asDateTime() ).date())); - - case TQVariant::Pixmap: - case TQVariant::Image: - case TQVariant::Brush: - case TQVariant::Palette: - case TQVariant::ColorGroup: - case TQVariant::Map: - case TQVariant::IconSet: - case TQVariant::CString: - case TQVariant::PointArray: - case TQVariant::Region: - case TQVariant::Bitmap: - case TQVariant::Cursor: - case TQVariant::SizePolicy: - case TQVariant::Time: -#ifdef USE_QT3 - case TQVariant::ByteArray: -#endif // USE_QT3 - case TQVariant::BitArray: - case TQVariant::KeySequence: - case TQVariant::Pen: -#ifdef USE_QT4 - case TQVariant::Char: - case TQVariant::Url: - case TQVariant::Locale: - case TQVariant::RectF: - case TQVariant::SizeF: - case TQVariant::Line: - case TQVariant::LineF: - case TQVariant::PointF: - case TQVariant::RegExp: - case TQVariant::Hash: - case TQVariant::TextLength: - case QVariant::TextFormat: - case TQVariant::Matrix: - case TQVariant::Transform: - case TQVariant::Matrix4x4: - case TQVariant::Vector2D: - case TQVariant::Vector3D: - case TQVariant::Vector4D: - case TQVariant::Quaternion: - case TQVariant::UserType: -#endif // USE_QT4 - break; - } - - Q_ASSERT( 0 ); - return TQVariant(); -} - -int KConfigBase::readListEntry( const TQString& pKey, - TQStrList &list, char sep ) const -{ - return readListEntry(pKey.utf8().data(), list, sep); -} - -int KConfigBase::readListEntry( const char *pKey, - TQStrList &list, char sep ) const -{ - if( !hasKey( pKey ) ) - return 0; - - TQCString str_list = readEntryUtf8( pKey ); - if (str_list.isEmpty()) - return 0; - - list.clear(); - TQCString value = ""; - int len = str_list.length(); - - for (int i = 0; i < len; i++) { - if (str_list[i] != sep && str_list[i] != '\\') { - value += str_list[i]; - continue; - } - if (str_list[i] == '\\') { - i++; - if ( i < len ) - value += str_list[i]; - continue; - } - // if we fell through to here, we are at a separator. Append - // contents of value to the list - // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!! - // A TQStrList may contain values in 8bit locale cpecified - // encoding - list.append( value ); - value.truncate(0); - } - - if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) ) - list.append( value ); - return list.count(); -} - -TQStringList KConfigBase::readListEntry( const TQString& pKey, char sep ) const -{ - return readListEntry(pKey.utf8().data(), sep); -} - -TQStringList KConfigBase::readListEntry( const char *pKey, char sep ) const -{ - static const TQString& emptyString = KGlobal::staticQString(""); - - TQStringList list; - if( !hasKey( pKey ) ) - return list; - TQString str_list = readEntry( pKey ); - if( str_list.isEmpty() ) - return list; - TQString value(emptyString); - int len = str_list.length(); - // obviously too big, but faster than letting each += resize the string. - value.reserve( len ); - for( int i = 0; i < len; i++ ) - { - if( str_list[i] != sep && str_list[i] != '\\' ) - { - value += str_list[i]; - continue; - } - if( str_list[i] == '\\' ) - { - i++; - if ( i < len ) - value += str_list[i]; - continue; - } - TQString finalvalue( value ); - finalvalue.squeeze(); - list.append( finalvalue ); - value.truncate( 0 ); - } - if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) ) - { - value.squeeze(); - list.append( value ); - } - return list; -} - -TQStringList KConfigBase::readListEntry( const char* pKey, const TQStringList& aDefault, - char sep ) const -{ - if ( !hasKey( pKey ) ) - return aDefault; - else - return readListEntry( pKey, sep ); -} - -TQValueList<int> KConfigBase::readIntListEntry( const TQString& pKey ) const -{ - return readIntListEntry(pKey.utf8().data()); -} - -TQValueList<int> KConfigBase::readIntListEntry( const char *pKey ) const -{ - TQStringList strlist = readListEntry(pKey); - TQValueList<int> list; - TQStringList::ConstIterator end(strlist.end()); - for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it) - // I do not check if the toInt failed because I consider the number of items - // more important than their value - list << (*it).toInt(); - - return list; -} - -TQString KConfigBase::readPathEntry( const TQString& pKey, const TQString& pDefault ) const -{ - return readPathEntry(pKey.utf8().data(), pDefault); -} - -TQString KConfigBase::readPathEntry( const char *pKey, const TQString& pDefault ) const -{ - const bool bExpandSave = bExpand; - bExpand = true; - TQString aValue = readEntry( pKey, pDefault ); - bExpand = bExpandSave; - return aValue; -} - -TQStringList KConfigBase::readPathListEntry( const TQString& pKey, char sep ) const -{ - return readPathListEntry(pKey.utf8().data(), sep); -} - -TQStringList KConfigBase::readPathListEntry( const char *pKey, char sep ) const -{ - const bool bExpandSave = bExpand; - bExpand = true; - TQStringList aValue = readListEntry( pKey, sep ); - bExpand = bExpandSave; - return aValue; -} - -int KConfigBase::readNumEntry( const TQString& pKey, int nDefault) const -{ - return readNumEntry(pKey.utf8().data(), nDefault); -} - -int KConfigBase::readNumEntry( const char *pKey, int nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else if( aValue == "true" || aValue == "on" || aValue == "yes" ) - return 1; - else - { - bool ok; - int rc = aValue.toInt( &ok ); - return( ok ? rc : nDefault ); - } -} - - -unsigned int KConfigBase::readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault) const -{ - return readUnsignedNumEntry(pKey.utf8().data(), nDefault); -} - -unsigned int KConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - unsigned int rc = aValue.toUInt( &ok ); - return( ok ? rc : nDefault ); - } -} - - -long KConfigBase::readLongNumEntry( const TQString& pKey, long nDefault) const -{ - return readLongNumEntry(pKey.utf8().data(), nDefault); -} - -long KConfigBase::readLongNumEntry( const char *pKey, long nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - long rc = aValue.toLong( &ok ); - return( ok ? rc : nDefault ); - } -} - - -unsigned long KConfigBase::readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault) const -{ - return readUnsignedLongNumEntry(pKey.utf8().data(), nDefault); -} - -unsigned long KConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - unsigned long rc = aValue.toULong( &ok ); - return( ok ? rc : nDefault ); - } -} - -TQ_INT64 KConfigBase::readNum64Entry( const TQString& pKey, TQ_INT64 nDefault) const -{ - return readNum64Entry(pKey.utf8().data(), nDefault); -} - -TQ_INT64 KConfigBase::readNum64Entry( const char *pKey, TQ_INT64 nDefault) const -{ - // Note that TQCString::toLongLong() is missing, we muse use a TQString instead. - TQString aValue = readEntry( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - TQ_INT64 rc = aValue.toLongLong( &ok ); - return( ok ? rc : nDefault ); - } -} - - -TQ_UINT64 KConfigBase::readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault) const -{ - return readUnsignedNum64Entry(pKey.utf8().data(), nDefault); -} - -TQ_UINT64 KConfigBase::readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault) const -{ - // Note that TQCString::toULongLong() is missing, we muse use a TQString instead. - TQString aValue = readEntry( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - TQ_UINT64 rc = aValue.toULongLong( &ok ); - return( ok ? rc : nDefault ); - } -} - -double KConfigBase::readDoubleNumEntry( const TQString& pKey, double nDefault) const -{ - return readDoubleNumEntry(pKey.utf8().data(), nDefault); -} - -double KConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - double rc = aValue.toDouble( &ok ); - return( ok ? rc : nDefault ); - } -} - - -bool KConfigBase::readBoolEntry( const TQString& pKey, bool bDefault ) const -{ - return readBoolEntry(pKey.utf8().data(), bDefault); -} - -bool KConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const -{ - TQCString aValue = readEntryUtf8( pKey ); - - if( aValue.isNull() ) - return bDefault; - else - { - if( aValue == "true" || aValue == "on" || aValue == "yes" || aValue == "1" ) - return true; - else - { - bool bOK; - int val = aValue.toInt( &bOK ); - if( bOK && val != 0 ) - return true; - else - return false; - } - } -} - -TQFont KConfigBase::readFontEntry( const TQString& pKey, const TQFont* pDefault ) const -{ - return readFontEntry(pKey.utf8().data(), pDefault); -} - -TQFont KConfigBase::readFontEntry( const char *pKey, const TQFont* pDefault ) const -{ - TQFont aRetFont; - - TQString aValue = readEntry( pKey ); - if( !aValue.isNull() ) { - if ( aValue.contains( ',' ) > 5 ) { - // KDE3 and upwards entry - if ( !aRetFont.fromString( aValue ) && pDefault ) - aRetFont = *pDefault; - } - else { - // backward compatibility with older font formats - // ### remove KDE 3.1 ? - // find first part (font family) - int nIndex = aValue.find( ',' ); - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - aRetFont.setFamily( aValue.left( nIndex ) ); - - // find second part (point size) - int nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - aRetFont.setPointSize( aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ).toInt() ); - - // find third part (style hint) - nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); - - // find fourth part (char set) - nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - TQString chStr=aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ); - // find fifth part (weight) - nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - aRetFont.setWeight( aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ).toUInt() ); - - // find sixth part (font bits) - uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); - - aRetFont.setItalic( nFontBits & 0x01 ); - aRetFont.setUnderline( nFontBits & 0x02 ); - aRetFont.setStrikeOut( nFontBits & 0x04 ); - aRetFont.setFixedPitch( nFontBits & 0x08 ); - aRetFont.setRawMode( nFontBits & 0x20 ); - } - } - else - { - if( pDefault ) - aRetFont = *pDefault; - } - - return aRetFont; -} - - -TQRect KConfigBase::readRectEntry( const TQString& pKey, const TQRect* pDefault ) const -{ - return readRectEntry(pKey.utf8().data(), pDefault); -} - -TQRect KConfigBase::readRectEntry( const char *pKey, const TQRect* pDefault ) const -{ - TQCString aValue = readEntryUtf8(pKey); - - if (!aValue.isEmpty()) - { - int left, top, width, height; - - if (sscanf(aValue.data(), "%d,%d,%d,%d", &left, &top, &width, &height) == 4) - { - return TQRect(left, top, width, height); - } - } - if (pDefault) - return *pDefault; - return TQRect(); -} - - -TQPoint KConfigBase::readPointEntry( const TQString& pKey, - const TQPoint* pDefault ) const -{ - return readPointEntry(pKey.utf8().data(), pDefault); -} - -TQPoint KConfigBase::readPointEntry( const char *pKey, - const TQPoint* pDefault ) const -{ - TQCString aValue = readEntryUtf8(pKey); - - if (!aValue.isEmpty()) - { - int x,y; - - if (sscanf(aValue.data(), "%d,%d", &x, &y) == 2) - { - return TQPoint(x,y); - } - } - if (pDefault) - return *pDefault; - return TQPoint(); -} - -TQSize KConfigBase::readSizeEntry( const TQString& pKey, - const TQSize* pDefault ) const -{ - return readSizeEntry(pKey.utf8().data(), pDefault); -} - -TQSize KConfigBase::readSizeEntry( const char *pKey, - const TQSize* pDefault ) const -{ - TQCString aValue = readEntryUtf8(pKey); - - if (!aValue.isEmpty()) - { - int width,height; - - if (sscanf(aValue.data(), "%d,%d", &width, &height) == 2) - { - return TQSize(width, height); - } - } - if (pDefault) - return *pDefault; - return TQSize(); -} - - -TQColor KConfigBase::readColorEntry( const TQString& pKey, - const TQColor* pDefault ) const -{ - return readColorEntry(pKey.utf8().data(), pDefault); -} - -TQColor KConfigBase::readColorEntry( const char *pKey, - const TQColor* pDefault ) const -{ - TQColor aRetColor; - int nRed = 0, nGreen = 0, nBlue = 0; - - TQString aValue = readEntry( pKey ); - if( !aValue.isEmpty() ) - { - if ( aValue.tqat(0) == (QChar)'#' ) - { - aRetColor.setNamedColor(aValue); - } - else - { - - bool bOK; - - // find first part (red) - int nIndex = aValue.find( ',' ); - - if( nIndex == -1 ){ - // return a sensible default -- Bernd - if( pDefault ) - aRetColor = *pDefault; - return aRetColor; - } - - nRed = aValue.left( nIndex ).toInt( &bOK ); - - // find second part (green) - int nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - // return a sensible default -- Bernd - if( pDefault ) - aRetColor = *pDefault; - return aRetColor; - } - nGreen = aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ).toInt( &bOK ); - - // find third part (blue) - nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); - - aRetColor.setRgb( nRed, nGreen, nBlue ); - } - } - else { - - if( pDefault ) - aRetColor = *pDefault; - } - - return aRetColor; -} - - -TQDateTime KConfigBase::readDateTimeEntry( const TQString& pKey, - const TQDateTime* pDefault ) const -{ - return readDateTimeEntry(pKey.utf8().data(), pDefault); -} - -// ### tqcurrentDateTime() as fallback ? (Harri) -TQDateTime KConfigBase::readDateTimeEntry( const char *pKey, - const TQDateTime* pDefault ) const -{ - if( !hasKey( pKey ) ) - { - if( pDefault ) - return *pDefault; - else - return TQDateTime::tqcurrentDateTime(); - } - - TQStrList list; - int count = readListEntry( pKey, list, ',' ); - if( count == 6 ) { - TQDate date( atoi( list.tqat( 0 ) ), atoi( list.tqat( 1 ) ), - atoi( list.tqat( 2 ) ) ); - TQTime time( atoi( list.tqat( 3 ) ), atoi( list.tqat( 4 ) ), - atoi( list.tqat( 5 ) ) ); - - return TQDateTime( date, time ); - } - - return TQDateTime::tqcurrentDateTime(); -} - -void KConfigBase::writeEntry( const TQString& pKey, const TQString& value, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQString& value, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey, value, bPersistent, bGlobal, bNLS, false); -} - -void KConfigBase::writeEntry( const char *pKey, const TQString& value, - bool bPersistent, - bool bGlobal, - bool bNLS, - bool bExpand ) -{ - // the KConfig object is dirty now - // set this before any IO takes place so that if any derivative - // classes do caching, they won't try and flush the cache out - // from under us before we read. A race condition is still - // possible but minimized. - if( bPersistent ) - setDirty(true); - - if (!bLocaleInitialized && KGlobal::locale()) - setLocale(); - - KEntryKey entryKey(mGroup, pKey); - entryKey.bLocal = bNLS; - - KEntry aEntryData; - aEntryData.mValue = value.utf8(); // set new value - aEntryData.bGlobal = bGlobal; - aEntryData.bNLS = bNLS; - aEntryData.bExpand = bExpand; - - if (bPersistent) - aEntryData.bDirty = true; - - // rewrite the new value - putData(entryKey, aEntryData, true); -} - -void KConfigBase::writePathEntry( const TQString& pKey, const TQString & path, - bool bPersistent, bool bGlobal, - bool bNLS) -{ - writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS); -} - - -static bool cleanHomeDirPath( TQString &path, const TQString &homeDir ) -{ -#ifdef Q_WS_WIN //safer - if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir))) - return false; -#else - if (!path.startsWith(homeDir)) - return false; -#endif - - unsigned int len = homeDir.length(); - // replace by "$HOME" if possible - if (len && (path.length() == len || path[len] == '/')) { - path.replace(0, len, TQString::tqfromLatin1("$HOME")); - return true; - } else - return false; -} - -static TQString translatePath( TQString path ) -{ - if (path.isEmpty()) - return path; - - // only "our" $HOME should be interpreted - path.replace('$', "$$"); - - bool startsWithFile = path.tqstartsWith("file:", false); - - // return original path, if it refers to another type of URL (e.g. http:/), or - // if the path is already relative to another directory - if (!startsWithFile && path[0] != '/' || - startsWithFile && path[5] != '/') - return path; - - if (startsWithFile) - path.remove(0,5); // strip leading "file:/" off the string - - // keep only one single '/' at the beginning - needed for cleanHomeDirPath() - while (path[0] == '/' && path[1] == '/') - path.remove(0,1); - - // we can not use KGlobal::dirs()->relativeLocation("home", path) here, - // since it would not recognize paths without a trailing '/'. - // All of the 3 following functions to return the user's home directory - // can return different paths. We have to test all them. - TQString homeDir0 = TQFile::decodeName(getenv("HOME")); - TQString homeDir1 = TQDir::homeDirPath(); - TQString homeDir2 = TQDir(homeDir1).canonicalPath(); - if (cleanHomeDirPath(path, homeDir0) || - cleanHomeDirPath(path, homeDir1) || - cleanHomeDirPath(path, homeDir2) ) { - // kdDebug() << "Path was replaced\n"; - } - - if (startsWithFile) - path.prepend( "file://" ); - - return path; -} - -void KConfigBase::writePathEntry( const char *pKey, const TQString & path, - bool bPersistent, bool bGlobal, - bool bNLS) -{ - writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, true); -} - -void KConfigBase::writePathEntry ( const TQString& pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writePathEntry ( const char *pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - if( list.isEmpty() ) - { - writeEntry( pKey, TQString::tqfromLatin1(""), bPersistent ); - return; - } - TQStringList new_list; - TQStringList::ConstIterator it = list.begin(); - for( ; it != list.end(); ++it ) - { - TQString value = *it; - new_list.append( translatePath(value) ); - } - writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS, true ); -} - -void KConfigBase::deleteEntry( const TQString& pKey, - bool bNLS, - bool bGlobal) -{ - deleteEntry(pKey.utf8().data(), bNLS, bGlobal); -} - -void KConfigBase::deleteEntry( const char *pKey, - bool bNLS, - bool bGlobal) -{ - // the KConfig object is dirty now - // set this before any IO takes place so that if any derivative - // classes do caching, they won't try and flush the cache out - // from under us before we read. A race condition is still - // possible but minimized. - setDirty(true); - - if (!bLocaleInitialized && KGlobal::locale()) - setLocale(); - - KEntryKey entryKey(mGroup, pKey); - KEntry aEntryData; - - aEntryData.bGlobal = bGlobal; - aEntryData.bNLS = bNLS; - aEntryData.bDirty = true; - aEntryData.bDeleted = true; - - // rewrite the new value - putData(entryKey, aEntryData, true); -} - -bool KConfigBase::deleteGroup( const TQString& group, bool bDeep, bool bGlobal ) -{ - KEntryMap aEntryMap = internalEntryMap(group); - - if (!bDeep) { - // Check if it empty - return aEntryMap.isEmpty(); - } - - bool dirty = false; - bool checkGroup = true; - // we want to remove all entries in the group - KEntryMapIterator aIt; - for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt) - { - if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted) - { - (*aIt).bDeleted = true; - (*aIt).bDirty = true; - (*aIt).bGlobal = bGlobal; - (*aIt).mValue = 0; - putData(aIt.key(), *aIt, checkGroup); - checkGroup = false; - dirty = true; - } - } - if (dirty) - setDirty(true); - return true; -} - -void KConfigBase::writeEntry ( const TQString& pKey, const TQVariant &prop, - bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry ( const char *pKey, const TQVariant &prop, - bool bPersistent, - bool bGlobal, bool bNLS ) -{ - switch( prop.type() ) - { - case TQVariant::Invalid: - writeEntry( pKey, "", bPersistent, bGlobal, bNLS ); - return; - case TQVariant::String: - writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::StringList: - writeEntry( pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS ); - return; - case TQVariant::List: { - TQValueList<TQVariant> list = prop.toList(); - TQValueList<TQVariant>::ConstIterator it = list.begin(); - TQValueList<TQVariant>::ConstIterator end = list.end(); - TQStringList strList; - - for (; it != end; ++it ) - strList.append( (*it).toString() ); - - writeEntry( pKey, strList, ',', bPersistent, bGlobal, bNLS ); - - return; - } - case TQVariant::Font: - writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Point: - writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Rect: - writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Size: - writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Color: - writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Int: - writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::UInt: - writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::LongLong: - writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::ULongLong: - writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Bool: - writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Double: - writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS ); - return; - case TQVariant::DateTime: - writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS); - return; - case TQVariant::Date: - writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS); - return; - - case TQVariant::Pixmap: - case TQVariant::Image: - case TQVariant::Brush: - case TQVariant::Palette: - case TQVariant::ColorGroup: - case TQVariant::Map: - case TQVariant::IconSet: - case TQVariant::CString: - case TQVariant::PointArray: - case TQVariant::Region: - case TQVariant::Bitmap: - case TQVariant::Cursor: - case TQVariant::SizePolicy: - case TQVariant::Time: -#ifdef USE_QT3 - case TQVariant::ByteArray: -#endif // USE_QT3 - case TQVariant::BitArray: - case TQVariant::KeySequence: - case TQVariant::Pen: -#ifdef USE_QT4 - case TQVariant::Char: - case TQVariant::Url: - case TQVariant::Locale: - case TQVariant::RectF: - case TQVariant::SizeF: - case TQVariant::Line: - case TQVariant::LineF: - case TQVariant::PointF: - case TQVariant::RegExp: - case TQVariant::Hash: - case TQVariant::TextLength: - case QVariant::TextFormat: - case TQVariant::Matrix: - case TQVariant::Transform: - case TQVariant::Matrix4x4: - case TQVariant::Vector2D: - case TQVariant::Vector3D: - case TQVariant::Vector4D: - case TQVariant::Quaternion: - case TQVariant::UserType: -#endif // USE_QT4 - break; - } - - Q_ASSERT( 0 ); -} - -void KConfigBase::writeEntry ( const TQString& pKey, const TQStrList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry ( const char *pKey, const TQStrList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - if( list.isEmpty() ) - { - writeEntry( pKey, TQString::tqfromLatin1(""), bPersistent ); - return; - } - TQString str_list; - TQStrListIterator it( list ); - for( ; it.current(); ++it ) - { - uint i; - TQString value; - // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!! - // A TQStrList may contain values in 8bit locale cpecified - // encoding or in UTF8 encoding. - value = KStringHandler::from8Bit(it.current()); - uint strLengh(value.length()); - for( i = 0; i < strLengh; i++ ) - { - if( value[i] == sep || value[i] == '\\' ) - str_list += '\\'; - str_list += value[i]; - } - str_list += sep; - } - if( str_list.tqat(str_list.length() - 1) == (QChar)sep ) - str_list.truncate( str_list.length() -1 ); - writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry ( const TQString& pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry ( const char *pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS, false); -} - -void KConfigBase::writeEntry ( const char *pKey, const TQStringList &list, - char sep, bool bPersistent, - bool bGlobal, bool bNLS, bool bExpand ) -{ - if( list.isEmpty() ) - { - writeEntry( pKey, TQString::tqfromLatin1(""), bPersistent ); - return; - } - TQString str_list; - str_list.reserve( 4096 ); - TQStringList::ConstIterator it = list.begin(); - for( ; it != list.end(); ++it ) - { - TQString value = *it; - uint i; - uint strLength(value.length()); - for( i = 0; i < strLength; i++ ) - { - if( value[i] == sep || value[i] == '\\' ) - str_list += '\\'; - str_list += value[i]; - } - str_list += sep; - } - if( str_list.tqat(str_list.length() - 1) == (QChar)sep ) - str_list.truncate( str_list.length() -1 ); - writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand ); -} - -void KConfigBase::writeEntry ( const TQString& pKey, const TQValueList<int> &list, - bool bPersistent, bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry ( const char *pKey, const TQValueList<int> &list, - bool bPersistent, bool bGlobal, bool bNLS ) -{ - TQStringList strlist; - TQValueList<int>::ConstIterator end = list.end(); - for (TQValueList<int>::ConstIterator it = list.begin(); it != end; it++) - strlist << TQString::number(*it); - writeEntry(pKey, strlist, ',', bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const TQString& pKey, int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, unsigned int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, unsigned int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, unsigned long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, unsigned long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const TQString& pKey, TQ_INT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, TQ_INT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, TQ_UINT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, TQ_UINT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const TQString& pKey, double nValue, - bool bPersistent, bool bGlobal, - char format, int precision, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue, format, precision), - bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const char *pKey, double nValue, - bool bPersistent, bool bGlobal, - char format, int precision, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue, format, precision), - bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, bool bValue, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, bool bValue, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - TQString aValue; - - if( bValue ) - aValue = "true"; - else - aValue = "false"; - - writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, const TQFont& rFont, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQFont& rFont, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, const TQRect& rRect, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQRect& rRect, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - list.insert( 0, tempstr.setNum( rRect.left() ) ); - list.insert( 1, tempstr.setNum( rRect.top() ) ); - list.insert( 2, tempstr.setNum( rRect.width() ) ); - list.insert( 3, tempstr.setNum( rRect.height() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, const TQPoint& rPoint, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQPoint& rPoint, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - list.insert( 0, tempstr.setNum( rPoint.x() ) ); - list.insert( 1, tempstr.setNum( rPoint.y() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - - -void KConfigBase::writeEntry( const TQString& pKey, const TQSize& rSize, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQSize& rSize, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - list.insert( 0, tempstr.setNum( rSize.width() ) ); - list.insert( 1, tempstr.setNum( rSize.height() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const TQString& pKey, const TQColor& rColor, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQColor& rColor, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - TQString aValue; - if (rColor.isValid()) - aValue.sprintf( "%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() ); - else - aValue = "invalid"; - - writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::writeEntry( const TQString& pKey, const TQDateTime& rDateTime, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS); -} - -void KConfigBase::writeEntry( const char *pKey, const TQDateTime& rDateTime, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - - TQTime time = TQT_TQTIME_OBJECT(rDateTime.time()); - TQDate date = TQT_TQDATE_OBJECT(rDateTime.date()); - - list.insert( 0, tempstr.setNum( date.year() ) ); - list.insert( 1, tempstr.setNum( date.month() ) ); - list.insert( 2, tempstr.setNum( date.day() ) ); - - list.insert( 3, tempstr.setNum( time.hour() ) ); - list.insert( 4, tempstr.setNum( time.minute() ) ); - list.insert( 5, tempstr.setNum( time.second() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - -void KConfigBase::parseConfigFiles() -{ - if (!bLocaleInitialized && KGlobal::_locale) { - setLocale(); - } - if (backEnd) - { - backEnd->parseConfigFiles(); - bReadOnly = (backEnd->getConfigState() == ReadOnly); - } -} - -void KConfigBase::sync() -{ - if (isReadOnly()) - return; - - if (backEnd) - backEnd->sync(); - if (bDirty) - rollback(); -} - -KConfigBase::ConfigState KConfigBase::getConfigState() const { - if (backEnd) - return backEnd->getConfigState(); - return ReadOnly; -} - -void KConfigBase::rollback( bool /*bDeep = true*/ ) -{ - bDirty = false; -} - - -void KConfigBase::setReadDefaults(bool b) -{ - if (!d) - { - if (!b) return; - d = new KConfigBasePrivate(); - } - - d->readDefaults = b; -} - -bool KConfigBase::readDefaults() const -{ - return (d && d->readDefaults); -} - -void KConfigBase::revertToDefault(const TQString &key) -{ - setDirty(true); - - KEntryKey aEntryKey(mGroup, key.utf8()); - aEntryKey.bDefault = true; - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (entry.mValue.isNull()) - entry.bDeleted = true; - - entry.bDirty = true; - putData(aEntryKey, entry, true); // Revert - aEntryKey.bLocal = false; - } - - // try the non-localized version - KEntry entry = lookupData(aEntryKey); - if (entry.mValue.isNull()) - entry.bDeleted = true; - entry.bDirty = true; - putData(aEntryKey, entry, true); // Revert -} - -bool KConfigBase::hasDefault(const TQString &key) const -{ - KEntryKey aEntryKey(mGroup, key.utf8()); - aEntryKey.bDefault = true; - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - - aEntryKey.bLocal = false; - } - - // try the non-localized version - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - - return false; -} - - - -KConfigGroup::KConfigGroup(KConfigBase *master, const TQString &group) -{ - mMaster = master; - backEnd = mMaster->backEnd; // Needed for getConfigState() - bLocaleInitialized = true; - bReadOnly = mMaster->bReadOnly; - bExpand = false; - bDirty = false; // Not used - mGroup = group.utf8(); - aLocaleString = mMaster->aLocaleString; - setReadDefaults(mMaster->readDefaults()); -} - -KConfigGroup::KConfigGroup(KConfigBase *master, const TQCString &group) -{ - mMaster = master; - backEnd = mMaster->backEnd; // Needed for getConfigState() - bLocaleInitialized = true; - bReadOnly = mMaster->bReadOnly; - bExpand = false; - bDirty = false; // Not used - mGroup = group; - aLocaleString = mMaster->aLocaleString; - setReadDefaults(mMaster->readDefaults()); -} - -KConfigGroup::KConfigGroup(KConfigBase *master, const char * group) -{ - mMaster = master; - backEnd = mMaster->backEnd; // Needed for getConfigState() - bLocaleInitialized = true; - bReadOnly = mMaster->bReadOnly; - bExpand = false; - bDirty = false; // Not used - mGroup = group; - aLocaleString = mMaster->aLocaleString; - setReadDefaults(mMaster->readDefaults()); -} - -void KConfigGroup::deleteGroup(bool bGlobal) -{ - mMaster->deleteGroup(KConfigBase::group(), true, bGlobal); -} - -bool KConfigGroup::groupIsImmutable() const -{ - return mMaster->groupIsImmutable(KConfigBase::group()); -} - -void KConfigGroup::setDirty(bool _bDirty) -{ - mMaster->setDirty(_bDirty); -} - -void KConfigGroup::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup) -{ - mMaster->putData(_key, _data, _checkGroup); -} - -KEntry KConfigGroup::lookupData(const KEntryKey &_key) const -{ - return mMaster->lookupData(_key); -} - -void KConfigGroup::sync() -{ - mMaster->sync(); -} - -void KConfigBase::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KConfigGroup::virtual_hook( int id, void* data ) -{ KConfigBase::virtual_hook( id, data ); } - -bool KConfigBase::checkConfigFilesWritable(bool warnUser) -{ - if (backEnd) - return backEnd->checkConfigFilesWritable(warnUser); - else - return false; -} - -#include "kconfigbase.moc" diff --git a/kdecore/kconfigbase.h b/kdecore/kconfigbase.h deleted file mode 100644 index 4f3dd545b..000000000 --- a/kdecore/kconfigbase.h +++ /dev/null @@ -1,2180 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> - Copyright (c) 2001 Waldo Bastian <bastian@kde.org> - - 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 _KCONFIGBASE_H -#define _KCONFIGBASE_H - -#include <tqobject.h> -#include <tqcolor.h> -#include <tqfont.h> -#include <tqdatetime.h> -#include <tqstrlist.h> -#include <tqstringlist.h> -#include <tqvariant.h> -#include <tqmap.h> - -#include "kconfigdata.h" -#include "kdelibs_export.h" - -class KConfigBackEnd; -class KConfigBasePrivate; -class KConfigGroup; - -/** - * @short KDE Configuration Management abstract base class - * - * This class forms the base for all %KDE configuration. It is an - * abstract base class, meaning that you cannot directly instantiate - * objects of this class. Either use KConfig (for usual %KDE - * configuration) or KSimpleConfig (for special needs as in ksamba), or - * even KSharedConfig (stores values in shared memory). - * - * All configuration entries are key, value pairs. Each entry also - * belongs to a specific group of related entries. All configuration - * entries that do not explicitly specify which group they are in are - * in a special group called the default group. - * - * If there is a $ character in an entry, KConfigBase tries to expand - * environment variable and uses its value instead of its name. You - * can avoid this feature by having two consecutive $ characters in - * your config file which get expanded to one. - * - * \note the '=' char is not allowed in keys and the ']' char is not allowed in - * a group name. - * - * @author Kalle Dalheimer <kalle@kde.org>, Preston Brown <pbrown@kde.org> - * @see KGlobal#config() - * @see KConfig - * @see KSimpleConfig - * @see KSharedConfig - */ -class KDECORE_EXPORT KConfigBase : public TQObject -{ - Q_OBJECT - TQ_OBJECT - - friend class KConfigBackEnd; - friend class KConfigINIBackEnd; - friend class KConfigGroup; - -public: - /** - * Construct a KConfigBase object. - */ - KConfigBase(); - - /** - * Destructs the KConfigBase object. - */ - virtual ~KConfigBase(); - - /** - * Specifies the group in which keys will be read and written. - * - * Subsequent - * calls to readEntry() and writeEntry() will be applied only in the - * activated group. - * - * Switch back to the default group by passing a null string. - * @param group The name of the new group. - */ - void setGroup( const TQString& group ); - - /** - * Sets the group to the "Desktop Entry" group used for - * desktop configuration files for applications, mime types, etc. - */ - void setDesktopGroup(); - - /** - * Returns the name of the group in which we are - * searching for keys and from which we are retrieving entries. - * - * @return The current group. - */ - TQString group() const; - - /** - * Returns true if the specified group is known about. - * - * @param group The group to search for. - * @return true if the group exists. - */ - bool hasGroup(const TQString &group) const; - - /** - * Returns a list of groups that are known about. - * - * @return The list of groups. - **/ - virtual TQStringList groupList() const = 0; - - /** - * Returns a the current locale. - * - * @return A string representing the current locale. - */ - TQString locale() const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * If you want to read a path, please use readPathEntry(). - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readEntry(const TQString& pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readEntry(const char *pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the given type. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * @deprecated - * - * @param pKey The key to search for. - * @return An invalid TQVariant if the key was not found or if the - * read value cannot be converted to the given TQVariant::Type. - */ - TQVariant readPropertyEntry( const TQString& pKey, TQVariant::Type ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the given type. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * - * @deprecated - * - * @param pKey The key to search for. - * @return An invalid TQVariant if the key was not found or if the - * read value cannot be converted to the given TQVariant::Type. - */ - TQVariant readPropertyEntry( const char *pKey, TQVariant::Type ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the type of the given default value. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found or - * if the read value cannot be converted to the TQVariant::Type. - * @return The value for the key or the default value if the key was not - * found. - */ - TQVariant readPropertyEntry( const TQString& pKey, - const TQVariant &aDefault) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the type of the given default value. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found or - * if the read value cannot be converted to the TQVariant::Type. - * @return The value for the key or the default value if the key was not - * found. - */ - TQVariant readPropertyEntry( const char *pKey, - const TQVariant &aDefault) const; - - /** - * Reads a list of strings. - * - * @deprecated - * - * @param pKey The key to search for - * @param list In this object, the read list will be returned. - * @param sep The list separator (default ",") - * @return The number of entries in the list. - */ - int readListEntry( const TQString& pKey, TQStrList &list, char sep = ',' ) const; - - /** - * Reads a list of strings. - * - * @deprecated - * - * @param pKey The key to search for - * @param list In this object, the read list will be returned. - * @param sep The list separator (default ",") - * @return The number of entries in the list. - */ - int readListEntry( const char *pKey, TQStrList &list, char sep = ',' ) const; - - /** - * Reads a list of strings. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - */ - TQStringList readListEntry( const TQString& pKey, char sep = ',' ) const; - - /** - * Reads a list of strings. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - */ - TQStringList readListEntry( const char *pKey, char sep = ',' ) const; - - /** - * Reads a list of strings, but returns a default if the key - * did not exist. - * @param pKey The key to search for. - * @param aDefault The default value to use if the key does not exist. - * @param sep The list separator (default is ","). - * @return The list. Contains @p aDefault if the Key does not exist. - * @since 3.3 - */ - TQStringList readListEntry( const char* pKey, const TQStringList& aDefault, - char sep = ',' ) const; - - /** - * Reads a list of Integers. - * - * @param pKey The key to search for. - * @return The list. Empty if the entry does not exist. - */ - TQValueList<int> readIntListEntry( const TQString& pKey ) const; - - /** - * Reads a list of Integers. - * - * @param pKey The key to search for. - * @return The list. Empty if the entry does not exist. - */ - TQValueList<int> readIntListEntry( const char *pKey ) const; - - /** - * Reads a path. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a path. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readPathEntry( const TQString& pKey, const TQString & aDefault = TQString::null ) const; - - /** - * Reads a path. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a path. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readPathEntry( const char *pKey, const TQString & aDefault = TQString::null ) const; - - /** - * Reads a list of string paths. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a list of paths. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - * @since 3.1.3 - */ - TQStringList readPathListEntry( const TQString& pKey, char sep = ',' ) const; - - /** - * Reads a list of string paths. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a list of paths. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - * @since 3.1.3 - */ - TQStringList readPathListEntry( const char *pKey, char sep = ',' ) const; - - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - int readNumEntry( const TQString& pKey, int nDefault = 0 ) const; - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - int readNumEntry( const char *pKey, int nDefault = 0 ) const; - - /** - * Reads an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned int readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault = 0 ) const; - - /** - * Reads an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned int readUnsignedNumEntry( const char *pKey, unsigned int nDefault = 0 ) const; - - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - long readLongNumEntry( const TQString& pKey, long nDefault = 0 ) const; - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - long readLongNumEntry( const char *pKey, long nDefault = 0 ) const; - - /** - * Read an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned long readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault = 0 ) const; - - /** - * Read an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned long readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault = 0 ) const; - - /** - * Reads a 64-bit numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_INT64 readNum64Entry( const TQString& pKey, TQ_INT64 nDefault = 0 ) const; - - /** - * Reads a 64-bit numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_INT64 readNum64Entry( const char *pKey, TQ_INT64 nDefault = 0 ) const; - - /** - * Read an 64-bit unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_UINT64 readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault = 0 ) const; - - /** - * Read an 64-bit unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_UINT64 readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault = 0 ) const; - - /** - * Reads a floating point value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - double readDoubleNumEntry( const TQString& pKey, double nDefault = 0.0 ) const; - - /** - * Reads a floating point value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - double readDoubleNumEntry( const char *pKey, double nDefault = 0.0 ) const; - - /** - * Reads a TQFont value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a font object. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQFont by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQFont readFontEntry( const TQString& pKey, const TQFont* pDefault = 0L ) const; - - /** - * Reads a TQFont value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a font object. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQFont by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQFont readFontEntry( const char *pKey, const TQFont* pDefault = 0L ) const; - - /** - * Reads a boolean entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a boolean value. Currently "on", "yes", "1" and - * "true" are accepted as true, everything else if false. - * - * @param pKey The key to search for - * @param bDefault A default value returned if the key was not found. - * @return The value for this key. - */ - bool readBoolEntry( const TQString& pKey, bool bDefault = false ) const; - - /** - * Reads a boolean entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a boolean value. Currently "on", "yes", "1" and - * "true" are accepted as true, everything else if false. - * - * @param pKey The key to search for - * @param bDefault A default value returned if the key was not found. - * @return The value for this key. - */ - bool readBoolEntry( const char *pKey, bool bDefault = false ) const; - - /** - * Reads a TQRect entry. - * - * Read the value of an entry specified by pKey in the current group - * and interpret it as a TQRect object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQRect by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQRect readRectEntry( const TQString& pKey, const TQRect* pDefault = 0L ) const; - - /** - * Reads a TQRect entry. - * - * Read the value of an entry specified by pKey in the current group - * and interpret it as a TQRect object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQRect by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQRect readRectEntry( const char *pKey, const TQRect* pDefault = 0L ) const; - - /** - * Reads a TQPoint entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQPoint object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQPoint by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQPoint readPointEntry( const TQString& pKey, const TQPoint* pDefault = 0L ) const; - - /** - * Reads a TQPoint entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQPoint object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQPoint by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQPoint readPointEntry( const char *pKey, const TQPoint* pDefault = 0L ) const; - - /** - * Reads a TQSize entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQSize object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQSize by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQSize readSizeEntry( const TQString& pKey, const TQSize* pDefault = 0L ) const; - - /** - * Reads a TQSize entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQSize object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQSize by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQSize readSizeEntry( const char *pKey, const TQSize* pDefault = 0L ) const; - - - /** - * Reads a TQColor entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a color. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQColor by default) returned if the - * key was not found or if the value cannot be interpreted. - * @return The value for this key. - */ - TQColor readColorEntry( const TQString& pKey, const TQColor* pDefault = 0L ) const; - - /** - * Reads a TQColor entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a color. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQColor by default) returned if the - * key was not found or if the value cannot be interpreted. - * @return The value for this key. - */ - TQColor readColorEntry( const char *pKey, const TQColor* pDefault = 0L ) const; - - /** - * Reads a TQDateTime entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a date and time. - * - * @param pKey The key to search for. - * @param pDefault A default value ( tqcurrentDateTime() by default) - * returned if the key was not found or if the read value cannot be - * interpreted. - * @return The value for this key. - */ - TQDateTime readDateTimeEntry( const TQString& pKey, const TQDateTime* pDefault = 0L ) const; - - /** - * Reads a TQDateTime entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a date and time. - * - * @param pKey The key to search for. - * @param pDefault A default value ( tqcurrentDateTime() by default) - * returned if the key was not found or if the read value cannot be - * interpreted. - * @return The value for this key. - */ - TQDateTime readDateTimeEntry( const char *pKey, const TQDateTime* pDefault = 0L ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The untranslated entry is returned, you normally do not need this. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. - */ - TQString readEntryUntranslated( const TQString& pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The untranslated entry is returned, you normally do not need this. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. - */ - TQString readEntryUntranslated( const char *pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Writes a key/value pair. - * - * This is stored in the most specific config file when destroying the - * config object or when calling sync(). - * - * If you want to write a path, please use writePathEntry(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQString& pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a key/value pair. - * - * This is stored in the most specific config file when destroying the - * config object or when calling sync(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQString& pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * writeEntry() Overridden to accept a property. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The property to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQVariant& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * writeEntry() Overridden to accept a property. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The property to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQVariant& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQStrList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQStrList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - - /** - * writeEntry() overridden to accept a list of Integers. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQValueList<int>& rValue, - bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writeEntry() overridden to accept a list of Integers. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQValueList<int>& rValue, - bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - /** - * Write a (key/value) pair. - * - * This is stored to the most specific config file when destroying the - * config object or when calling sync(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const char *pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ) - { writeEntry(pKey, TQString::tqfromLatin1(pValue), bPersistent, bGlobal, bNLS); } - /** - * Write a (key/value) pair. - * - * This is stored to the most specific config file when destroying the - * config object or when calling sync(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const char *pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ) - { writeEntry(pKey, TQString::tqfromLatin1(pValue), bPersistent, bGlobal, bNLS); } - - /** - * Write a (key/value) pair. - * Same as above, but writes a numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Write a (key/value) pair. - * Same as above, but writes a numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, unsigned int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, unsigned int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but write a long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but write a long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, unsigned long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, unsigned long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but write a 64-bit numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, TQ_INT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but write a long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, TQ_INT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned 64-bit numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, TQ_UINT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned 64-bit numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, TQ_UINT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a floating-point value. - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param format @p format determines the format to which the value - * is converted. Default is 'g'. - * @param precision @p precision sets the precision with which the - * value is converted. Default is 6 as in TQString. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, double nValue, - bool bPersistent = true, bool bGlobal = false, - char format = 'g', int precision = 6, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a floating-point value. - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param format @p format determines the format to which the value - * is converted. Default is 'g'. - * @param precision @p precision sets the precision with which the - * value is converted. Default is 6 as in TQString. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, double nValue, - bool bPersistent = true, bool bGlobal = false, - char format = 'g', int precision = 6, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a boolean value. - * - * @param pKey The key to write. - * @param bValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, bool bValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a boolean value. - * - * @param pKey The key to write. - * @param bValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, bool bValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a font value. - * - * @param pKey The key to write. - * @param rFont The font value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQFont& rFont, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a font value. - * - * @param pKey The key to write. - * @param rFont The font value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQFont& rFont, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but write a color entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rColor The color value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQColor& rColor, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but write a color entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rColor The color value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQColor& rColor, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a date and time entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * @em not returned here! - * - * @param pKey The key to write. - * @param rDateTime The date and time value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQDateTime& rDateTime, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a date and time entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * @em not returned here! - * - * @param pKey The key to write. - * @param rDateTime The date and time value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQDateTime& rDateTime, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - - /** - * Writes a (key/value) pair. - * Same as above, but writes a rectangle. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The rectangle value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQRect& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a rectangle. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The rectangle value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQRect& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a point. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The point value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQPoint& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a point. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The point value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQPoint& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a size. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The size value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQSize& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a size. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The size value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQSize& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a file path. - * - * It is checked whether the path is located under $HOME. If so the - * path is written out with the user's home-directory replaced with - * $HOME. The path should be read back with readPathEntry() - * - * @param pKey The key to write. - * @param path The path to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writePathEntry( const TQString& pKey, const TQString & path, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a file path. - * - * It is checked whether the path is located under $HOME. If so the - * path is written out with the user's home-directory replaced with - * $HOME. The path should be read back with readPathEntry() - * - * @param pKey The key to write. - * @param path The path to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writePathEntry( const char *pKey, const TQString & path, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * writePathEntry() overridden to accept a list of paths (strings). - * - * It is checked whether the paths are located under $HOME. If so each of - * the paths are written out with the user's home-directory replaced with - * $HOME. The paths should be read back with readPathListEntry() - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writePathEntry() - * @see readPathListEntry() - * @since 3.1.3 - */ - void writePathEntry( const TQString& pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writePathEntry() overridden to accept a list of paths (strings). - * - * It is checked whether the paths are located under $HOME. If so each of - * the paths are written out with the user's home-directory replaced with - * $HOME. The paths should be read back with readPathListEntry() - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writePathEntry() - * @see readPathListEntry() - * @since 3.1.3 - */ - void writePathEntry( const char *pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - - /** - * Deletes the entry specified by @p pKey in the current group. - * - * @param pKey The key to delete. - * @param bGlobal If @p bGlobal is true, the pair is not removed from the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the key with the locale tag is removed. - */ - void deleteEntry( const TQString& pKey, - bool bNLS = false, bool bGlobal = false); - /** - * Deletes the entry specified by @p pKey in the current group. - * - * @param pKey The key to delete. - * @param bGlobal If @p bGlobal is true, the pair is not removed from the - * application specific config file, but from the global KDE config file. - * @param bNLS If @p bNLS is true, the key with the locale tag is removed. - */ - void deleteEntry( const char *pKey, - bool bNLS = false, bool bGlobal = false); - - /** - * Deletes a configuration entry group - * - * If the group is not empty and bDeep is false, nothing gets - * deleted and false is returned. - * If this group is the current group and it is deleted, the - * current group is undefined and should be set with setGroup() - * before the next operation on the configuration object. - * - * @param group The name of the group - * @param bDeep Specify whether non-empty groups should be completely - * deleted (including their entries). - * @param bGlobal If @p bGlobal is true, the group is not removed from the - * application specific config file, but from the global KDE config file. - * @return If the group is not empty and bDeep is false, - * deleteGroup returns false. - */ - bool deleteGroup( const TQString& group, bool bDeep = true, bool bGlobal = false ); - - - /** - * Turns on or off "dollar expansion" (see KConfigBase introduction) - * when reading config entries. - * Dollar sign expansion is initially OFF. - * - * @param _bExpand Tf true, dollar expansion is turned on. - */ - void setDollarExpansion( bool _bExpand = true ) { bExpand = _bExpand; } - - /** - * Returns whether dollar expansion is on or off. It is initially OFF. - * - * @return true if dollar expansion is on. - */ - bool isDollarExpansion() const { return bExpand; } - - /** - * Mark the config object as "clean," i.e. don't write dirty entries - * at destruction time. If @p bDeep is false, only the global dirty - * flag of the KConfig object gets cleared. If you then call - * writeEntry() again, the global dirty flag is set again and all - * dirty entries will be written at a subsequent sync() call. - * - * Classes that derive from KConfigBase should override this - * method and implement storage-specific behavior, as well as - * calling the KConfigBase::rollback() explicitly in the initializer. - * - * @param bDeep If true, the dirty flags of all entries are cleared, - * as well as the global dirty flag. - */ - virtual void rollback( bool bDeep = true ); - - /** - * Flushes all changes that currently reside only in memory - * back to disk / permanent storage. Dirty configuration entries are - * written to the most specific file available. - * - * Asks the back end to flush out all pending writes, and then calls - * rollback(). No changes are made if the object has @p readOnly - * status. - * - * You should call this from your destructor in derivative classes. - * - * @see rollback(), #isReadOnly() - */ - virtual void sync(); - - /** - * Checks whether the config file has any dirty (modified) entries. - * @return true if the config file has any dirty (modified) entries. - */ - bool isDirty() const { return bDirty; } - - /** - * Sets the config object's read-only status. - * - * @param _ro If true, the config object will not write out any - * changes to disk even if it is destroyed or sync() is called. - * - */ - virtual void setReadOnly(bool _ro) { bReadOnly = _ro; } - - /** - * Returns the read-only status of the config object. - * - * @return The read-only status. - */ - bool isReadOnly() const { return bReadOnly; } - - /** - * Checks whether the key has an entry in the currently active group. - * Use this to determine whether a key is not specified for the current - * group (hasKey() returns false). Keys with null data are considered - * nonexistent. - * - * @param key The key to search for. - * @return If true, the key is available. - */ - bool hasKey( const TQString& key ) const; - - /** - * Returns a map (tree) of entries for all entries in a particular - * group. Only the actual entry string is returned, none of the - * other internal data should be included. - * - * @param group A group to get keys from. - * @return A map of entries in the group specified, indexed by key. - * The returned map may be empty if the group is not found. - * @see QMap - */ - virtual TQMap<TQString, TQString> entryMap(const TQString &group) const = 0; - - /** - * Reparses all configuration files. This is useful for programs - * that use stand alone graphical configuration tools. The base - * method implemented here only clears the group list and then - * appends the default group. - * - * Derivative classes should clear any internal data structures and - * then simply call parseConfigFiles() when implementing this - * method. - * - * @see parseConfigFiles() - */ - virtual void reparseConfiguration() = 0; - - /** - * Checks whether this configuration file can be modified. - * @return whether changes may be made to this configuration file. - */ - bool isImmutable() const; - - /** - * Checks whether it is possible to change the given group. - * @param group the group to check - * @return whether changes may be made to @p group in this configuration - * file. - */ - bool groupIsImmutable(const TQString &group) const; - - /** - * Checks whether it is possible to change the given entry. - * @param key the key to check - * @return whether the entry @p key may be changed in the current group - * in this configuration file. - */ - bool entryIsImmutable(const TQString &key) const; - - /** - * Possible return values for getConfigState(). - * - * @see getConfigState() - */ - enum ConfigState { NoAccess, ReadOnly, ReadWrite }; - - /** - * Returns the state of the app-config object. - * - * Possible return values - * are NoAccess (the application-specific config file could not be - * opened neither read-write nor read-only), ReadOnly (the - * application-specific config file is opened read-only, but not - * read-write) and ReadWrite (the application-specific config - * file is opened read-write). - * - * @see ConfigState() - * @return the state of the app-config object - */ - ConfigState getConfigState() const; - - /** - * Check whether the config files are writable. - * @param warnUser Warn the user if the configuration files are not writable. - * @return Indicates that all of the configuration files used are writable. - * @since 3.2 - */ - bool checkConfigFilesWritable(bool warnUser); - - /** - * When set, all readEntry and readXXXEntry calls return the system - * wide (default) values instead of the user's preference. - * This is off by default. - * @since 3.2 - */ - void setReadDefaults(bool b); - - /** - * @returns true if all readEntry and readXXXEntry calls return the system - * wide (default) values instead of the user's preference. - * @since 3.2 - */ - bool readDefaults() const; - - /** - * Reverts the entry with key @p key in the current group in the - * application specific config file to either the system wide (default) - * value or the value specified in the global KDE config file. - * - * To revert entries in the global KDE config file, the global KDE config - * file should be opened explicitly in a separate config object. - * - * @param key The key of the entry to revert. - * @since 3.2 - */ - void revertToDefault(const TQString &key); - - /** - * Returns whether a default is specified for an entry in either the - * system wide configuration file or the global KDE config file. - * - * If an application computes a default value at runtime for - * a certain entry, e.g. like: - * \code - * TQColor computedDefault = kapp->palette().color(TQPalette::Active, TQColorGroup::Text) - * TQColor color = config->readEntry(key, computedDefault); - * \encode - * - * Then it may wish to make the following check before - * writing back changes: - * \code - * if ( (value == computedDefault) && !config->hasDefault(key) ) - * config->revertToDefault(key) - * else - * config->writeEntry(key, value) - * \endcode - * - * This ensures that as long as the entry is not modified to differ from - * the computed default, the application will keep using the computed default - * and will follow changes the computed default makes over time. - * @param key The key of the entry to check. - * @since 3.2 - */ - bool hasDefault(const TQString &key) const; - -protected: - /** - * Reads the locale and put in the configuration data struct. - * Note that this should be done in the constructor, but this is not - * possible due to some mutual dependencies in KApplication::init() - */ - void setLocale(); - - /** - * Sets the global dirty flag of the config object - * - * @param _bDirty How to mark the object's dirty status - */ - virtual void setDirty(bool _bDirty = true) { bDirty = _bDirty; } - - /** - * Parses all configuration files for a configuration object. - * - * The actual parsing is done by the associated KConfigBackEnd. - */ - virtual void parseConfigFiles(); - - /** - * Returns a map (tree) of the entries in the specified group. - * This may or may not return all entries that belong to the - * config object. The only guarantee that you are given is that - * any entries that are dirty (i.e. modified and not yet written back - * to the disk) will be contained in the map. Some derivative - * classes may choose to return everything. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @param pGroup The group to provide a KEntryMap for. - * @return The map of the entries in the group. - * @internal - */ - virtual KEntryMap internalEntryMap( const TQString& pGroup ) const = 0; - - /** - * Returns a map (tree) of the entries in the tree. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @return A map of the entries in the tree. - * - * @internal - * - */ - virtual KEntryMap internalEntryMap() const = 0; - - /** - * Inserts a (key/value) pair into the internal storage mechanism of - * the configuration object. Classes that derive from KConfigBase - * will need to implement this method in a storage-specific manner. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @param _key The key to insert. It contains information both on - * the group of the key and the key itself. If the key already - * exists, the old value will be replaced. - * @param _data the KEntry that is to be stored. - * @param _checkGroup When false, assume that the group already exists. - * @internal - */ - virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true) = 0; - - /** - * Looks up an entry in the config object's internal structure. - * Classes that derive from KConfigBase will need to implement this - * method in a storage-specific manner. - * - * Do not use this function, the implementation and return type are - * subject to change. - * - * @param _key The key to look up It contains information both on - * the group of the key and the entry's key itself. - * @return The KEntry value (data) found for the key. @p KEntry.aValue - * will be the null string if nothing was located. - * @internal - */ - virtual KEntry lookupData(const KEntryKey &_key) const = 0; - - virtual bool internalHasGroup(const TQCString &group) const = 0; - - /** - * A back end for loading/saving to disk in a particular format. - */ - KConfigBackEnd *backEnd; -public: - /** - * Overloaded public methods: - */ - void setGroup( const TQCString &pGroup ); - void setGroup( const char *pGroup ); - bool hasGroup(const TQCString &_pGroup) const; - bool hasGroup(const char *_pGroup) const; - bool hasKey( const char *pKey ) const; - -protected: - TQCString readEntryUtf8( const char *pKey) const; - bool hasTranslatedKey( const char *pKey ) const; - - /** - * The currently selected group. */ - TQCString mGroup; - - /** - * The locale to retrieve keys under if possible, i.e en_US or fr. */ - TQCString aLocaleString; - - /** - * Indicates whether there are any dirty entries in the config object - * that need to be written back to disk. */ - bool bDirty; - - bool bLocaleInitialized; - bool bReadOnly; // currently only used by KSimpleConfig - mutable bool bExpand; // whether dollar expansion is used - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KConfigBasePrivate; - KConfigBasePrivate *d; - - void writeEntry( const char *pKey, const TQString &rValue, - bool bPersistent, bool bGlobal, bool bNLS, bool bExpand ); - void writeEntry( const char *pKey, const TQStringList &rValue, - char sep, bool bPersistent, bool bGlobal, bool bNLS, bool bExpand ); - -}; - -class KConfigGroupSaverPrivate; - -/** - * Helper class to facilitate working with KConfig / KSimpleConfig - * groups. - * - * Careful programmers always set the group of a - * KConfig KSimpleConfig object to the group they want to read from - * and set it back to the old one of afterwards. This is usually - * written as: - * \code - * - * TQString oldgroup config->group(); - * config->setGroup( "TheGroupThatIWant" ); - * ... - * config->writeEntry( "Blah", "Blubb" ); - * - * config->setGroup( oldgroup ); - * \endcode - * - * In order to facilitate this task, you can use - * KConfigGroupSaver. Simply construct such an object ON THE STACK - * when you want to switch to a new group. Then, when the object goes - * out of scope, the group will automatically be restored. If you - * want to use several different groups within a function or method, - * you can still use KConfigGroupSaver: Simply enclose all work with - * one group (including the creation of the KConfigGroupSaver object) - * in one block. - * - * @deprecated This class is deprecated and will be removed in KDE 4. - * KConfigGroup provides similar functionality in a more object oriented - * way. - * - * @author Matthias Kalle Dalheimer <kalle@kde.org> - * @see KConfigBase, KConfig, KSimpleConfig, KConfigGroup - * @short Helper class for easier use of KConfig/KSimpleConfig groups - */ - -class KDECORE_EXPORT KConfigGroupSaver // KDE4 remove -{ -public: - /** - * Constructor. You pass a pointer to the KConfigBase-derived - * object you want to work with and a string indicating the _new_ - * group. - * - * @param config The KConfigBase-derived object this - * KConfigGroupSaver works on. - * @param group The new group that the config object should switch to. - */ - KConfigGroupSaver( KConfigBase* config, TQString group ) - /* KDE 4 : make the second parameter const TQString & */ - : _config(config), _oldgroup(config->group()) - { _config->setGroup( group ); } - - KConfigGroupSaver( KConfigBase* config, const char *group ) - : _config(config), _oldgroup(config->group()) - { _config->setGroup( group ); } - - KConfigGroupSaver( KConfigBase* config, const TQCString &group ) - : _config(config), _oldgroup(config->group()) - { _config->setGroup( group ); } - - ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); } - - KConfigBase* config() { return _config; }; - -private: - KConfigBase* _config; - TQString _oldgroup; - - KConfigGroupSaver(const KConfigGroupSaver&); - KConfigGroupSaver& operator=(const KConfigGroupSaver&); - - KConfigGroupSaverPrivate *d; -}; - -class KConfigGroupPrivate; - -/** - * A KConfigBase derived class for one specific group in a KConfig object. - */ -class KDECORE_EXPORT KConfigGroup: public KConfigBase -{ -public: - /** - * Construct a config group corresponding to @p group in @p master. - * @p group is the group name encoded in UTF-8. - */ - KConfigGroup(KConfigBase *master, const TQCString &group); - /** - * This is an overloaded constructor provided for convenience. - * It behaves essentially like the above function. - * - * Construct a config group corresponding to @p group in @p master - */ - KConfigGroup(KConfigBase *master, const TQString &group); - /** - * This is an overloaded constructor provided for convenience. - * It behaves essentially like the above function. - * - * Construct a config group corresponding to @p group in @p master - * @p group is the group name encoded in UTF-8. - */ - KConfigGroup(KConfigBase *master, const char * group); - - /** - * Delete all entries in the entire group - * @param bGlobal If @p bGlobal is true, the entries are not removed - * from the application specific config file, but from the global - * KDE config file. - */ - void deleteGroup(bool bGlobal = false); - - /** - * Checks whether it is possible to change this group. - * @return whether changes may be made to this group in this configuration - * file. - * @since 3.4 - */ - bool groupIsImmutable() const; - - // The following functions are reimplemented: - virtual void setDirty(bool _bDirty); - virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true); - virtual KEntry lookupData(const KEntryKey &_key) const; - virtual void sync(); - -private: - // Hide the following members: - void setGroup() { } - void setDesktopGroup() { } - void group() { } - void hasGroup() { } - void setReadOnly(bool) { } - void isDirty() { } - - // The following members are not used. - virtual TQStringList groupList() const { return TQStringList(); } - virtual void rollback(bool) { } - virtual void reparseConfiguration() { } - virtual TQMap<TQString, TQString> entryMap(const TQString &) const - { return TQMap<TQString,TQString>(); } - virtual KEntryMap internalEntryMap( const TQString&) const - { return KEntryMap(); } - virtual KEntryMap internalEntryMap() const - { return KEntryMap(); } - virtual bool internalHasGroup(const TQCString &) const - { return false; } - - void getConfigState() { } - - KConfigBase *mMaster; -protected: - virtual void virtual_hook( int id, void* data ); -private: - KConfigGroupPrivate* d; -}; - -#endif diff --git a/kdecore/kconfigdata.h b/kdecore/kconfigdata.h deleted file mode 100644 index e514b2781..000000000 --- a/kdecore/kconfigdata.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999-2000 Preston Brown <pbrown@kde.org> - Copyright (C) 1996-2000 Matthias Kalle Dalheimer <kalle@kde.org> - - 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 _KCONFIGDATA_H -#define _KCONFIGDATA_H - -#include <tqmap.h> // generic red-black tree class -#include "kdelibs_export.h" - -/** - * map/dict/list config node entry. - * @internal - */ -struct KDECORE_EXPORT KEntry -{ - KEntry() - : mValue(0), bDirty(false), bNLS(false), - bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false) {} - TQCString mValue; - /** - * Must the entry be written back to disk? - */ - bool bDirty :1; - /** - * Entry should be written with locale tag - */ - bool bNLS :1; - /** - * Entry should be written to the global config file - */ - bool bGlobal:1; - /** - * Entry can not be modified. - */ - bool bImmutable:1; - /** - * Entry has been deleted. - */ - bool bDeleted:1; - /** - * Whether to apply dollar expansion or not. - */ - bool bExpand:1; -}; - -/** - * key structure holding both the actual key and the the group - * to which it belongs. - * @internal - */ -struct KDECORE_EXPORT KEntryKey -{ - KEntryKey(const TQCString& _group = 0, - const TQCString& _key = 0) - : mGroup(_group), mKey(_key), bLocal(false), bDefault(false), - c_key(_key.data()) {} - /** - * The "group" to which this EntryKey belongs - */ - TQCString mGroup; - /** - * The _actual_ key of the entry in question - */ - TQCString mKey; - /** - * Entry is localised or not - */ - bool bLocal :1; - /** - * Entry indicates if this is a default value. - */ - bool bDefault:1; - - const char *c_key; -}; - -/** - * compares two KEntryKeys (needed for TQMap). - * @internal - */ -inline bool operator <(const KEntryKey &k1, const KEntryKey &k2) -{ - //saves one strcmp on each call - int result=qstrcmp(k1.mGroup.data(),k2.mGroup.data()); - if (result!=0) - return (result<0); - - if (!k1.c_key && k2.c_key) - return true; - - result = 0; - if (k1.c_key && k2.c_key) - result = strcmp(k1.c_key, k2.c_key); - if (result != 0) - return result < 0; - if (!k1.bLocal && k2.bLocal) - return true; - if (k1.bLocal && !k2.bLocal) - return false; - return (!k1.bDefault && k2.bDefault); -} - -/** - * \relates KEntry - * type specifying a map of entries (key,value pairs). - * The keys are actually a key in a particular config file group together - * with the group name. - * @internal - */ -typedef TQMap<KEntryKey, KEntry> KEntryMap; - -/** - * \relates KEntry - * type for iterating over keys in a KEntryMap in sorted order. - * @internal - */ -typedef TQMap<KEntryKey, KEntry>::Iterator KEntryMapIterator; - -/** - * \relates KEntry - * type for iterating over keys in a KEntryMap in sorted order. - * It is const, thus you cannot change the entries in the iterator, - * only examine them. - * @internal - */ -typedef TQMap<KEntryKey, KEntry>::ConstIterator KEntryMapConstIterator; - -#endif diff --git a/kdecore/kconfigdialogmanager.cpp b/kdecore/kconfigdialogmanager.cpp deleted file mode 100644 index 97e741f65..000000000 --- a/kdecore/kconfigdialogmanager.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Benjamin C Meyer (ben+kdelibs at meyerhome dot net) - * Copyright (C) 2003 Waldo Bastian <bastian@kde.org> - * - * 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. - */ - -#include "kconfigdialogmanager.h" - -#include <tqbuttongroup.h> -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqmetaobject.h> -#include <tqobjectlist.h> -#include <tqsqlpropertymap.h> -#include <tqtimer.h> -#include <tqwhatsthis.h> - -#include <kapplication.h> -#include <kconfigskeleton.h> -#include <kdebug.h> -#include <kglobal.h> - -#include <assert.h> - -class KConfigDialogManager::Private { - -public: - Private() : insideGroupBox(false) { } - -public: - TQDict<TQWidget> knownWidget; - TQDict<TQWidget> buddyWidget; - bool insideGroupBox; -}; - -KConfigDialogManager::KConfigDialogManager(TQWidget *parent, KConfigSkeleton *conf, const char *name) - : TQObject(parent, name), m_conf(conf), m_dialog(parent) -{ - d = new Private(); - - kapp->installKDEPropertyMap(); - propertyMap = TQSqlPropertyMap::defaultMap(); - - init(true); -} - -KConfigDialogManager::~KConfigDialogManager() -{ - delete d; -} - -void KConfigDialogManager::init(bool trackChanges) -{ - if(trackChanges) - { - // QT - changedMap.insert(TQBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - changedMap.insert(TQCHECKBOX_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - changedMap.insert(TQPUSHBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - changedMap.insert(TQRADIOBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - // We can only store one thing, so you can't have - // a ButtonGroup that is checkable. - changedMap.insert(TQBUTTONGROUP_OBJECT_NAME_STRING, TQT_SIGNAL(clicked(int))); - changedMap.insert(TQGROUPBOX_OBJECT_NAME_STRING, TQT_SIGNAL(toggled(bool))); - changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(activated (int))); - //qsqlproperty map doesn't store the text, but the value! - //changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert(TQDATEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQDate &))); - changedMap.insert(TQDATETIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQDateTime &))); - changedMap.insert(TQDIAL_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged (int))); - changedMap.insert(TQLINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert(TQSLIDER_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(int))); - changedMap.insert(TQSPINBOX_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(int))); - changedMap.insert(TQTIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQTime &))); - changedMap.insert(TQTEXTEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged())); - changedMap.insert(TQTEXTBROWSER_OBJECT_NAME_STRING, TQT_SIGNAL(sourceChanged(const TQString &))); - changedMap.insert(TQMULTILINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged())); - changedMap.insert(TQLISTBOX_OBJECT_NAME_STRING, TQT_SIGNAL(selectionChanged())); - changedMap.insert(TQTABWIDGET_OBJECT_NAME_STRING, TQT_SIGNAL(currentChanged(TQWidget *))); - - // KDE - changedMap.insert( "KComboBox", TQT_SIGNAL(activated (int))); - changedMap.insert( "KFontCombo", TQT_SIGNAL(activated (int))); - changedMap.insert( "KFontRequester", TQT_SIGNAL(fontSelected(const TQFont &))); - changedMap.insert( "KFontChooser", TQT_SIGNAL(fontSelected(const TQFont &))); - changedMap.insert( "KHistoryCombo", TQT_SIGNAL(activated (int))); - - changedMap.insert( "KColorButton", TQT_SIGNAL(changed(const TQColor &))); - changedMap.insert( "KDatePicker", TQT_SIGNAL(dateSelected (TQDate))); - changedMap.insert( "KDateWidget", TQT_SIGNAL(changed (TQDate))); - changedMap.insert( "KDateTimeWidget", TQT_SIGNAL(valueChanged (const TQDateTime &))); - changedMap.insert( "KEditListBox", TQT_SIGNAL(changed())); - changedMap.insert( "KListBox", TQT_SIGNAL(selectionChanged())); - changedMap.insert( "KLineEdit", TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert( "KPasswordEdit", TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert( "KRestrictedLine", TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert( "KTextBrowser", TQT_SIGNAL(sourceChanged(const TQString &))); - changedMap.insert( "KTextEdit", TQT_SIGNAL(textChanged())); - changedMap.insert( "KURLRequester", TQT_SIGNAL(textChanged (const TQString& ))); - changedMap.insert( "KIntNumInput", TQT_SIGNAL(valueChanged (int))); - changedMap.insert( "KIntSpinBox", TQT_SIGNAL(valueChanged (int))); - changedMap.insert( "KDoubleNumInput", TQT_SIGNAL(valueChanged (double))); - } - - // Go through all of the children of the widgets and find all known widgets - (void) parseChildren(m_dialog, trackChanges); -} - -void KConfigDialogManager::addWidget(TQWidget *widget) -{ - (void) parseChildren(widget, true); -} - -void KConfigDialogManager::setupWidget(TQWidget *widget, KConfigSkeletonItem *item) -{ - TQVariant minValue = item->minValue(); - if (minValue.isValid()) - { - if (widget->tqmetaObject()->findProperty("minValue", true) != -1) - widget->setProperty("minValue", minValue); - } - TQVariant maxValue = item->maxValue(); - if (maxValue.isValid()) - { - if (widget->tqmetaObject()->findProperty("maxValue", true) != -1) - widget->setProperty("maxValue", maxValue); - } - if (TQWhatsThis::textFor( widget ).isEmpty()) - { - TQString whatsThis = item->whatsThis(); - if ( !whatsThis.isEmpty() ) - { - TQWhatsThis::add( widget, whatsThis ); - } - } -} - -bool KConfigDialogManager::parseChildren(const TQWidget *widget, bool trackChanges) -{ - bool valueChanged = false; - const TQObjectList listOfChildren = widget->childrenListObject(); - if(listOfChildren.isEmpty()) - return valueChanged; - - TQObject *object; - for( TQObjectListIterator it( listOfChildren ); - (object = it.current()); ++it ) - { - if(!object->isWidgetType()) - continue; // Skip non-widgets - - TQWidget *childWidget = (TQWidget *)object; - - const char *widgetName = childWidget->name(0); - bool bParseChildren = true; - bool bSaveInsideGroupBox = d->insideGroupBox; - - if (widgetName && (strncmp(widgetName, "kcfg_", 5) == 0)) - { - // This is one of our widgets! - TQString configId = widgetName+5; - KConfigSkeletonItem *item = m_conf->findItem(configId); - if (item) - { - d->knownWidget.insert(configId, childWidget); - - setupWidget(childWidget, item); - - TQMap<TQString, TQCString>::const_iterator changedIt = changedMap.find(childWidget->className()); - - if (changedIt == changedMap.end()) - { - // If the class name of the widget wasn't in the monitored widgets map, then look for - // it again using the super class name. This fixes a problem with using QtRuby/Korundum - // widgets with KConfigXT where 'Qt::Widget' wasn't being seen a the real deal, even - // though it was a 'QWidget'. - changedIt = changedMap.find(childWidget->tqmetaObject()->tqsuperClassName()); - } - - if (changedIt == changedMap.end()) - { - kdWarning(178) << "Don't know how to monitor widget '" << childWidget->className() << "' for changes!" << endl; - } - else - { - connect(childWidget, *changedIt, - this, TQT_SIGNAL(widgetModified())); - - TQGroupBox *gb = dynamic_cast<TQGroupBox *>(childWidget); - if (!gb) - bParseChildren = false; - else - d->insideGroupBox = true; - - TQComboBox *cb = dynamic_cast<TQComboBox *>(childWidget); - if (cb && cb->editable()) - connect(cb, TQT_SIGNAL(textChanged(const TQString &)), - this, TQT_SIGNAL(widgetModified())); - } - } - else - { - kdWarning(178) << "A widget named '" << widgetName << "' was found but there is no setting named '" << configId << "'" << endl; - } - } - else if (childWidget->inherits(TQLABEL_OBJECT_NAME_STRING)) - { - TQLabel *label = static_cast<TQLabel *>(childWidget); - TQWidget *buddy = label->buddy(); - if (!buddy) - continue; - const char *buddyName = buddy->name(0); - if (buddyName && (strncmp(buddyName, "kcfg_", 5) == 0)) - { - // This is one of our widgets! - TQString configId = buddyName+5; - d->buddyWidget.insert(configId, childWidget); - } - } -#ifndef NDEBUG - else if (widgetName) - { - TQMap<TQString, TQCString>::const_iterator changedIt = changedMap.find(childWidget->className()); - if (changedIt != changedMap.end()) - { - if ((!d->insideGroupBox || !childWidget->inherits(TQRADIOBUTTON_OBJECT_NAME_STRING)) && - !childWidget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) - kdDebug(178) << "Widget '" << widgetName << "' (" << childWidget->className() << ") remains unmanaged." << endl; - } - } -#endif - - if(bParseChildren) - { - // this widget is not known as something we can store. - // Maybe we can store one of its children. - valueChanged |= parseChildren(childWidget, trackChanges); - } - d->insideGroupBox = bSaveInsideGroupBox; - } - return valueChanged; -} - -void KConfigDialogManager::updateWidgets() -{ - bool changed = false; - bool bSignalsBlocked = signalsBlocked(); - blockSignals(true); - - TQWidget *widget; - for( TQDictIterator<TQWidget> it( d->knownWidget ); - (widget = it.current()); ++it ) - { - KConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); - if (!item) - { - kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; - continue; - } - - TQVariant p = item->property(); - if (p != property(widget)) - { - setProperty(widget, p); -// kdDebug(178) << "The setting '" << it.currentKey() << "' [" << widget->className() << "] has changed" << endl; - changed = true; - } - if (item->isImmutable()) - { - widget->setEnabled(false); - TQWidget *buddy = d->buddyWidget.find(it.currentKey()); - if (buddy) - buddy->setEnabled(false); - } - } - blockSignals(bSignalsBlocked); - - if (changed) - TQTimer::singleShot(0, this, TQT_SIGNAL(widgetModified())); -} - -void KConfigDialogManager::updateWidgetsDefault() -{ - bool bUseDefaults = m_conf->useDefaults(true); - updateWidgets(); - m_conf->useDefaults(bUseDefaults); -} - -void KConfigDialogManager::updateSettings() -{ - bool changed = false; - - TQWidget *widget; - for( TQDictIterator<TQWidget> it( d->knownWidget ); - (widget = it.current()); ++it ) - { - KConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); - if (!item) - { - kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; - continue; - } - - TQVariant p = property(widget); - if (p != item->property()) - { - item->setProperty(p); - changed = true; - } - } - if (changed) - { - m_conf->writeConfig(); - emit settingsChanged(); - } -} - -void KConfigDialogManager::setProperty(TQWidget *w, const TQVariant &v) -{ - TQButtonGroup *bg = dynamic_cast<TQButtonGroup *>(w); - if (bg) - { - bg->setButton(v.toInt()); - return; - } - - TQComboBox *cb = dynamic_cast<TQComboBox *>(w); - if (cb && cb->editable()) - { - cb->setCurrentText(v.toString()); - return; - } - - propertyMap->setProperty(w, v); -} - -TQVariant KConfigDialogManager::property(TQWidget *w) -{ - TQButtonGroup *bg = dynamic_cast<TQButtonGroup *>(w); - if (bg) - return TQVariant(bg->selectedId()); - - TQComboBox *cb = dynamic_cast<TQComboBox *>(w); - if (cb && cb->editable()) - return TQVariant(cb->currentText()); - - return propertyMap->property(w); -} - -bool KConfigDialogManager::hasChanged() -{ - - TQWidget *widget; - for( TQDictIterator<TQWidget> it( d->knownWidget ); - (widget = it.current()); ++it ) - { - KConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); - if (!item) - { - kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; - continue; - } - - TQVariant p = property(widget); - if (p != item->property()) - { -// kdDebug(178) << "Widget for '" << it.currentKey() << "' has changed." << endl; - return true; - } - } - return false; -} - -bool KConfigDialogManager::isDefault() -{ - bool bUseDefaults = m_conf->useDefaults(true); - bool result = !hasChanged(); - m_conf->useDefaults(bUseDefaults); - return result; -} - -#include "kconfigdialogmanager.moc" - diff --git a/kdecore/kconfigdialogmanager.h b/kdecore/kconfigdialogmanager.h deleted file mode 100644 index d0b385b60..000000000 --- a/kdecore/kconfigdialogmanager.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Benjamin C Meyer (ben+kdelibs at meyerhome dot net) - * Copyright (C) 2003 Waldo Bastian <bastian@kde.org> - * - * 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 KCONFIGDIALOGMANAGER_H -#define KCONFIGDIALOGMANAGER_H - -#include <tqobject.h> -#include <tqptrlist.h> -#include "kdelibs_export.h" - -class KConfigSkeleton; -class KConfigSkeletonItem; -class TQWidget; -class TQSqlPropertyMap; - -/** - * @short Provides a means of automatically retrieving, - * saving and resetting KConfigSkeleton based settings in a dialog. - * - * The KConfigDialogManager class provides a means of automatically - * retrieving, saving and resetting basic settings. - * It also can emit signals when settings have been changed - * (settings were saved) or modified (the user changes a checkbox - * from on to off). - * - * The names of the widgets to be managed have to correspond to the names of the - * configuration entries in the KConfigSkeleton object plus an additional - * "kcfg_" prefix. For example a widget named "kcfg_MyOption" would be - * associated to the configuration entry "MyOption". - * - * KConfigDialogManager uses the TQSqlPropertyMap class to determine if it can do - * anything to a widget. Note that KConfigDialogManager doesn't require a - * database, it simply uses the functionality that is built into the - * TQSqlPropertyMap class. New widgets can be added to the map using - * TQSqlPropertyMap::installDefaultMap(). Note that you can't just add any - * class. The class must have a matching Q_PROPERTY(...) macro defined. - * - * For example (note that KColorButton is already added and it doesn't need to - * manually added): - * - * kcolorbutton.h defines the following property: - * \code - * Q_PROPERTY( TQColor color READ color WRITE setColor ) - * \endcode - * - * To add KColorButton the following code would be inserted in the main. - * - * \code - * kapp->installKDEPropertyMap(); - * TQSqlPropertyMap *map = TQSqlPropertyMap::defaultMap(); - * map->insert("KColorButton", "color"); - * \endcode - * - * If you add a new widget to the TQSqlPropertyMap and wish to be notified when - * it is modified you should add its signal using addWidgetChangedSignal(). - - * @since 3.2 - * @author Benjamin C Meyer <ben+kdelibs at meyerhome dot net> - * @author Waldo Bastian <bastian@kde.org> - */ -class KDECORE_EXPORT KConfigDialogManager : public TQObject { - -Q_OBJECT - -signals: - /** - * One or more of the settings have been saved (such as when the user - * clicks on the Apply button). This is only emitted by updateSettings() - * whenever one or more setting were changed and consequently saved. - */ - void settingsChanged(); - - /** - * TODO: Verify - * One or more of the settings have been changed. - * @param widget - The widget group (pass in via addWidget()) that - * contains the one or more modified setting. - * @see settingsChanged() - */ - void settingsChanged( TQWidget *widget ); - - /** - * If retrieveSettings() was told to track changes then if - * any known setting was changed this signal will be emitted. Note - * that a settings can be modified several times and might go back to the - * original saved state. hasChanged() will tell you if anything has - * actually changed from the saved values. - */ - void widgetModified(); - - -public: - - /** - * Constructor. - * @param parent Dialog widget to manage - * @param conf Object that contains settings - * @param name - Object name. - */ - KConfigDialogManager(TQWidget *parent, KConfigSkeleton *conf, const char *name=0); - - /** - * Destructor. - */ - ~KConfigDialogManager(); - - /** - * Add additional widgets to manage - * @param widget Additional widget to manage, inlcuding all its children - */ - void addWidget(TQWidget *widget); - - /** - * Returns whether the current state of the known widgets are - * different from the state in the config object. - */ - bool hasChanged(); - - /** - * Returns whether the current state of the known widgets are - * the same as the default state in the config object. - */ - bool isDefault(); - -public slots: - /** - * Traverse the specified widgets, saving the settings of all known - * widgets in the settings object. - * - * Example use: User clicks Ok or Apply button in a configure dialog. - */ - void updateSettings(); - - /** - * Traverse the specified widgets, sets the state of all known - * widgets according to the state in the settings object. - * - * Example use: Initialisation of dialog. - * Example use: User clicks Reset button in a configure dialog. - */ - void updateWidgets(); - - /** - * Traverse the specified widgets, sets the state of all known - * widgets according to the default state in the settings object. - * - * Example use: User clicks Defaults button in a configure dialog. - */ - void updateWidgetsDefault(); - -protected: - - /** - * @param trackChanges - If any changes by the widgets should be tracked - * set true. This causes the emitting the modified() signal when - * something changes. - * TODO: @return bool - True if any setting was changed from the default. - */ - void init(bool trackChanges); - - /** - * Recursive function that finds all known children. - * Goes through the children of widget and if any are known and not being - * ignored, stores them in currentGroup. Also checks if the widget - * should be disabled because it is set immutable. - * @param widget - Parent of the children to look at. - * @param trackChanges - If true then tracks any changes to the children of - * widget that are known. - * @return bool - If a widget was set to something other then its default. - */ - bool parseChildren(const TQWidget *widget, bool trackChanges); - - /** - * Set a property - */ - void setProperty(TQWidget *w, const TQVariant &v); - - /** - * Retrieve a property - */ - TQVariant property(TQWidget *w); - - /** - * Setup secondary widget properties - */ - void setupWidget(TQWidget *widget, KConfigSkeletonItem *item); - -protected: - /** - * KConfigSkeleton object used to store settings - */ - KConfigSkeleton *m_conf; - - /** - * Dialog being managed - */ - TQWidget *m_dialog; - - /** - * Pointer to the property map for easy access. - */ - TQSqlPropertyMap *propertyMap; - - /** - * Map of the classes and the signals that they emit when changed. - */ - TQMap<TQString, TQCString> changedMap; - -private: - class Private; - /** - * KConfigDialogManager Private class. - */ - Private *d; - -}; - -#endif // KCONFIGDIALOGMANAGER_H - diff --git a/kdecore/kconfigskeleton.cpp b/kdecore/kconfigskeleton.cpp deleted file mode 100644 index b464f64d2..000000000 --- a/kdecore/kconfigskeleton.cpp +++ /dev/null @@ -1,1207 +0,0 @@ -/* - This file is part of KOrganizer. - Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - - 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. -*/ - -#include <tqcolor.h> -#include <tqvariant.h> - -#include <kconfig.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kglobalsettings.h> -#include <kdebug.h> - -#include "kstringhandler.h" - -#include "kconfigskeleton.h" - -void KConfigSkeletonItem::readImmutability( KConfig *config ) -{ - mIsImmutable = config->entryIsImmutable( mKey ); -} - - -KConfigSkeleton::ItemString::ItemString( const TQString &group, const TQString &key, - TQString &reference, - const TQString &defaultValue, - Type type ) - : KConfigSkeletonGenericItem<TQString>( group, key, reference, defaultValue ), - mType( type ) -{ -} - -void KConfigSkeleton::ItemString::writeConfig( KConfig *config ) -{ - if ( mReference != mLoadedValue ) // WABA: Is this test needed? - { - config->setGroup( mGroup ); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else if ( mType == Path ) - config->writePathEntry( mKey, mReference ); - else if ( mType == Password ) - config->writeEntry( mKey, KStringHandler::obscure( mReference ) ); - else - config->writeEntry( mKey, mReference ); - } -} - - -void KConfigSkeleton::ItemString::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - - if ( mType == Path ) - { - mReference = config->readPathEntry( mKey, mDefault ); - } - else if ( mType == Password ) - { - TQString value = config->readEntry( mKey, - KStringHandler::obscure( mDefault ) ); - mReference = KStringHandler::obscure( value ); - } - else - { - mReference = config->readEntry( mKey, mDefault ); - } - - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemString::setProperty(const TQVariant & p) -{ - mReference = p.toString(); -} - -TQVariant KConfigSkeleton::ItemString::property() const -{ - return TQVariant(mReference); -} - -KConfigSkeleton::ItemPassword::ItemPassword( const TQString &group, const TQString &key, - TQString &reference, - const TQString &defaultValue) - : ItemString( group, key, reference, defaultValue, Password ) -{ -} - -KConfigSkeleton::ItemPath::ItemPath( const TQString &group, const TQString &key, - TQString &reference, - const TQString &defaultValue) - : ItemString( group, key, reference, defaultValue, Path ) -{ -} - -KConfigSkeleton::ItemProperty::ItemProperty( const TQString &group, - const TQString &key, - TQVariant &reference, - TQVariant defaultValue ) - : KConfigSkeletonGenericItem<TQVariant>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemProperty::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readPropertyEntry( mKey, mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemProperty::setProperty(const TQVariant & p) -{ - mReference = p; -} - -TQVariant KConfigSkeleton::ItemProperty::property() const -{ - return mReference; -} - -KConfigSkeleton::ItemBool::ItemBool( const TQString &group, const TQString &key, - bool &reference, bool defaultValue ) - : KConfigSkeletonGenericItem<bool>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemBool::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readBoolEntry( mKey, mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemBool::setProperty(const TQVariant & p) -{ - mReference = p.toBool(); -} - -TQVariant KConfigSkeleton::ItemBool::property() const -{ - return TQVariant( mReference, 42 /* dummy */ ); -} - - -KConfigSkeleton::ItemInt::ItemInt( const TQString &group, const TQString &key, - int &reference, int defaultValue ) - : KConfigSkeletonGenericItem<int>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemInt::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemInt::setProperty(const TQVariant & p) -{ - mReference = p.toInt(); -} - -TQVariant KConfigSkeleton::ItemInt::property() const -{ - return TQVariant(mReference); -} - -TQVariant KConfigSkeleton::ItemInt::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemInt::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemInt::setMinValue(int v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemInt::setMaxValue(int v) -{ - mHasMax = true; - mMax = v; -} - - -KConfigSkeleton::ItemInt64::ItemInt64( const TQString &group, const TQString &key, - TQ_INT64 &reference, TQ_INT64 defaultValue ) - : KConfigSkeletonGenericItem<TQ_INT64>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemInt64::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readNum64Entry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemInt64::setProperty(const TQVariant & p) -{ - mReference = p.toLongLong(); -} - -TQVariant KConfigSkeleton::ItemInt64::property() const -{ - return TQVariant(mReference); -} - -TQVariant KConfigSkeleton::ItemInt64::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemInt64::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemInt64::setMinValue(TQ_INT64 v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemInt64::setMaxValue(TQ_INT64 v) -{ - mHasMax = true; - mMax = v; -} - -KConfigSkeleton::ItemEnum::ItemEnum( const TQString &group, const TQString &key, - int &reference, - const TQValueList<Choice> &choices, - int defaultValue ) - : ItemInt( group, key, reference, defaultValue ), mChoices( choices ) -{ -} - -void KConfigSkeleton::ItemEnum::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - if (!config->hasKey(mKey)) - { - mReference = mDefault; - } - else - { - int i = 0; - mReference = -1; - TQString tmp = config->readEntry( mKey ).lower(); - for(TQValueList<Choice>::ConstIterator it = mChoices.begin(); - it != mChoices.end(); ++it, ++i) - { - if ((*it).name.lower() == tmp) - { - mReference = i; - break; - } - } - if (mReference == -1) - mReference = config->readNumEntry( mKey, mDefault ); - } - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemEnum::writeConfig( KConfig *config ) -{ - if ( mReference != mLoadedValue ) // WABA: Is this test needed? - { - config->setGroup( mGroup ); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else if ((mReference >= 0) && (mReference < (int) mChoices.count())) - config->writeEntry( mKey, mChoices[mReference].name ); - else - config->writeEntry( mKey, mReference ); - } -} - -TQValueList<KConfigSkeleton::ItemEnum::Choice> KConfigSkeleton::ItemEnum::choices() const -{ - return mChoices; -} - - -KConfigSkeleton::ItemUInt::ItemUInt( const TQString &group, const TQString &key, - unsigned int &reference, - unsigned int defaultValue ) - : KConfigSkeletonGenericItem<unsigned int>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemUInt::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readUnsignedNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemUInt::setProperty(const TQVariant & p) -{ - mReference = p.toUInt(); -} - -TQVariant KConfigSkeleton::ItemUInt::property() const -{ - return TQVariant(mReference); -} - -TQVariant KConfigSkeleton::ItemUInt::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemUInt::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemUInt::setMinValue(unsigned int v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemUInt::setMaxValue(unsigned int v) -{ - mHasMax = true; - mMax = v; -} - - -KConfigSkeleton::ItemUInt64::ItemUInt64( const TQString &group, const TQString &key, - TQ_UINT64 &reference, TQ_UINT64 defaultValue ) - : KConfigSkeletonGenericItem<TQ_UINT64>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemUInt64::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readUnsignedNum64Entry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemUInt64::setProperty(const TQVariant & p) -{ - mReference = p.toULongLong(); -} - -TQVariant KConfigSkeleton::ItemUInt64::property() const -{ - return TQVariant(mReference); -} - -TQVariant KConfigSkeleton::ItemUInt64::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemUInt64::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemUInt64::setMinValue(TQ_UINT64 v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemUInt64::setMaxValue(TQ_UINT64 v) -{ - mHasMax = true; - mMax = v; -} - -KConfigSkeleton::ItemLong::ItemLong( const TQString &group, const TQString &key, - long &reference, long defaultValue ) - : KConfigSkeletonGenericItem<long>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemLong::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readLongNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemLong::setProperty(const TQVariant & p) -{ - mReference = p.toLongLong(); -} - -TQVariant KConfigSkeleton::ItemLong::property() const -{ - return TQVariant((TQ_LLONG) mReference); -} - -TQVariant KConfigSkeleton::ItemLong::minValue() const -{ - if (mHasMin) - return TQVariant((TQ_LLONG) mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemLong::maxValue() const -{ - if (mHasMax) - return TQVariant((TQ_LLONG) mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemLong::setMinValue(long v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemLong::setMaxValue(long v) -{ - mHasMax = true; - mMax = v; -} - - -KConfigSkeleton::ItemULong::ItemULong( const TQString &group, const TQString &key, - unsigned long &reference, - unsigned long defaultValue ) - : KConfigSkeletonGenericItem<unsigned long>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemULong::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readUnsignedLongNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemULong::setProperty(const TQVariant & p) -{ - mReference = p.toULongLong(); -} - -TQVariant KConfigSkeleton::ItemULong::property() const -{ - return TQVariant((TQ_ULLONG) mReference); -} - -TQVariant KConfigSkeleton::ItemULong::minValue() const -{ - if (mHasMin) - return TQVariant((TQ_ULLONG) mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemULong::maxValue() const -{ - if (mHasMax) - return TQVariant((TQ_ULLONG) mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemULong::setMinValue(unsigned long v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemULong::setMaxValue(unsigned long v) -{ - mHasMax = true; - mMax = v; -} - - -KConfigSkeleton::ItemDouble::ItemDouble( const TQString &group, const TQString &key, - double &reference, double defaultValue ) - : KConfigSkeletonGenericItem<double>( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void KConfigSkeleton::ItemDouble::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readDoubleNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemDouble::setProperty(const TQVariant & p) -{ - mReference = p.toDouble(); -} - -TQVariant KConfigSkeleton::ItemDouble::property() const -{ - return TQVariant(mReference); -} - -TQVariant KConfigSkeleton::ItemDouble::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant KConfigSkeleton::ItemDouble::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void KConfigSkeleton::ItemDouble::setMinValue(double v) -{ - mHasMin = true; - mMin = v; -} - -void KConfigSkeleton::ItemDouble::setMaxValue(double v) -{ - mHasMax = true; - mMax = v; -} - - -KConfigSkeleton::ItemColor::ItemColor( const TQString &group, const TQString &key, - TQColor &reference, - const TQColor &defaultValue ) - : KConfigSkeletonGenericItem<TQColor>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemColor::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readColorEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemColor::setProperty(const TQVariant & p) -{ - mReference = p.toColor(); -} - -TQVariant KConfigSkeleton::ItemColor::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemFont::ItemFont( const TQString &group, const TQString &key, - TQFont &reference, - const TQFont &defaultValue ) - : KConfigSkeletonGenericItem<TQFont>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemFont::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readFontEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemFont::setProperty(const TQVariant & p) -{ - mReference = p.toFont(); -} - -TQVariant KConfigSkeleton::ItemFont::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemRect::ItemRect( const TQString &group, const TQString &key, - TQRect &reference, - const TQRect &defaultValue ) - : KConfigSkeletonGenericItem<TQRect>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemRect::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readRectEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemRect::setProperty(const TQVariant & p) -{ - mReference = p.toRect(); -} - -TQVariant KConfigSkeleton::ItemRect::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemPoint::ItemPoint( const TQString &group, const TQString &key, - TQPoint &reference, - const TQPoint &defaultValue ) - : KConfigSkeletonGenericItem<TQPoint>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemPoint::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readPointEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemPoint::setProperty(const TQVariant & p) -{ - mReference = p.toPoint(); -} - -TQVariant KConfigSkeleton::ItemPoint::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemSize::ItemSize( const TQString &group, const TQString &key, - TQSize &reference, - const TQSize &defaultValue ) - : KConfigSkeletonGenericItem<TQSize>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemSize::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readSizeEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemSize::setProperty(const TQVariant & p) -{ - mReference = p.toSize(); -} - -TQVariant KConfigSkeleton::ItemSize::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemDateTime::ItemDateTime( const TQString &group, const TQString &key, - TQDateTime &reference, - const TQDateTime &defaultValue ) - : KConfigSkeletonGenericItem<TQDateTime>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemDateTime::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readDateTimeEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemDateTime::setProperty(const TQVariant & p) -{ - mReference = p.toDateTime(); -} - -TQVariant KConfigSkeleton::ItemDateTime::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemStringList::ItemStringList( const TQString &group, const TQString &key, - TQStringList &reference, - const TQStringList &defaultValue ) - : KConfigSkeletonGenericItem<TQStringList>( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemStringList::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - if ( !config->hasKey( mKey ) ) - mReference = mDefault; - else - mReference = config->readListEntry( mKey ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemStringList::setProperty(const TQVariant & p) -{ - mReference = p.toStringList(); -} - -TQVariant KConfigSkeleton::ItemStringList::property() const -{ - return TQVariant(mReference); -} - - -KConfigSkeleton::ItemPathList::ItemPathList( const TQString &group, const TQString &key, - TQStringList &reference, - const TQStringList &defaultValue ) - : ItemStringList( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemPathList::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - if ( !config->hasKey( mKey ) ) - mReference = mDefault; - else - mReference = config->readPathListEntry( mKey ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemPathList::writeConfig( KConfig *config ) -{ - if ( mReference != mLoadedValue ) // WABA: Is this test needed? - { - config->setGroup( mGroup ); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else { - TQStringList sl = mReference; - config->writePathEntry( mKey, sl ); - } - } -} - - -KConfigSkeleton::ItemIntList::ItemIntList( const TQString &group, const TQString &key, - TQValueList<int> &reference, - const TQValueList<int> &defaultValue ) - : KConfigSkeletonGenericItem<TQValueList<int> >( group, key, reference, defaultValue ) -{ -} - -void KConfigSkeleton::ItemIntList::readConfig( KConfig *config ) -{ - config->setGroup( mGroup ); - if ( !config->hasKey( mKey ) ) - mReference = mDefault; - else - mReference = config->readIntListEntry( mKey ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void KConfigSkeleton::ItemIntList::setProperty(const TQVariant &) -{ - // TODO: Not yet supported -} - -TQVariant KConfigSkeleton::ItemIntList::property() const -{ - // TODO: Not yet supported - return TQVariant(); -} - - -KConfigSkeleton::KConfigSkeleton( const TQString &configname ) - : mCurrentGroup( "No Group" ), mUseDefaults(false) -{ - kdDebug(177) << "Creating KConfigSkeleton (" << (void *)this << ")" << endl; - - if ( !configname.isEmpty() ) - { - mConfig = KSharedConfig::openConfig( configname ); - } - else - { - mConfig = KGlobal::sharedConfig(); - } -} - -KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr config) - : mCurrentGroup( "No Group" ), mUseDefaults(false) -{ - kdDebug(177) << "Creating KConfigSkeleton (" << (void *)this << ")" << endl; - mConfig = config; -} - - -KConfigSkeleton::~KConfigSkeleton() -{ - KConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - delete *it; - } -} - -void KConfigSkeleton::setCurrentGroup( const TQString &group ) -{ - mCurrentGroup = group; -} - -KConfig *KConfigSkeleton::config() const -{ - return mConfig; -} - -bool KConfigSkeleton::useDefaults(bool b) -{ - if (b == mUseDefaults) - return mUseDefaults; - - mUseDefaults = b; - KConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - (*it)->swapDefault(); - } - - usrUseDefaults(b); - return !mUseDefaults; -} - -void KConfigSkeleton::setDefaults() -{ - KConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) { - (*it)->setDefault(); - } - - usrSetDefaults(); -} - -void KConfigSkeleton::readConfig() -{ - kdDebug(177) << "KConfigSkeleton::readConfig()" << endl; - - TQString origGroup = mConfig->group(); - - mConfig->reparseConfiguration(); - KConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - (*it)->readConfig( mConfig ); - } - - usrReadConfig(); - - mConfig->setGroup(origGroup); -} - -void KConfigSkeleton::writeConfig() -{ - kdDebug(177) << "KConfigSkeleton::writeConfig()" << endl; - - TQString origGroup = mConfig->group(); - - KConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - (*it)->writeConfig( mConfig ); - } - - usrWriteConfig(); - - mConfig->sync(); - - readConfig(); - - mConfig->setGroup(origGroup); -} - -void KConfigSkeleton::addItem( KConfigSkeletonItem *item, const TQString &name ) -{ - item->setName( name.isEmpty() ? item->key() : name ); - mItems.append( item ); - mItemDict.insert( item->name(), item ); - item->readDefault( mConfig ); - item->readConfig( mConfig ); -} - -KConfigSkeleton::ItemString *KConfigSkeleton::addItemString( const TQString &name, TQString &reference, - const TQString &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemString *item; - item = new KConfigSkeleton::ItemString( mCurrentGroup, key.isEmpty() ? name : key, - reference, defaultValue, - KConfigSkeleton::ItemString::Normal ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemPassword *KConfigSkeleton::addItemPassword( const TQString &name, TQString &reference, - const TQString &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemPassword *item; - item = new KConfigSkeleton::ItemPassword( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemPath *KConfigSkeleton::addItemPath( const TQString &name, TQString &reference, - const TQString &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemPath *item; - item = new KConfigSkeleton::ItemPath( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemProperty *KConfigSkeleton::addItemProperty( const TQString &name, TQVariant &reference, - const TQVariant &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemProperty *item; - item = new KConfigSkeleton::ItemProperty( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemBool *KConfigSkeleton::addItemBool( const TQString &name, bool &reference, - bool defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemBool *item; - item = new KConfigSkeleton::ItemBool( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemInt *KConfigSkeleton::addItemInt( const TQString &name, int &reference, - int defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemInt *item; - item = new KConfigSkeleton::ItemInt( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemUInt *KConfigSkeleton::addItemUInt( const TQString &name, unsigned int &reference, - unsigned int defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemUInt *item; - item = new KConfigSkeleton::ItemUInt( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemInt64 *KConfigSkeleton::addItemInt64( const TQString &name, TQ_INT64 &reference, - TQ_INT64 defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemInt64 *item; - item = new KConfigSkeleton::ItemInt64( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemUInt64 *KConfigSkeleton::addItemUInt64( const TQString &name, TQ_UINT64 &reference, - TQ_UINT64 defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemUInt64 *item; - item = new KConfigSkeleton::ItemUInt64( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemLong *KConfigSkeleton::addItemLong( const TQString &name, long &reference, - long defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemLong *item; - item = new KConfigSkeleton::ItemLong( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemULong *KConfigSkeleton::addItemULong( const TQString &name, unsigned long &reference, - unsigned long defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemULong *item; - item = new KConfigSkeleton::ItemULong( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemDouble *KConfigSkeleton::addItemDouble( const TQString &name, double &reference, - double defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemDouble *item; - item = new KConfigSkeleton::ItemDouble( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor( const TQString &name, TQColor &reference, - const TQColor &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemColor *item; - item = new KConfigSkeleton::ItemColor( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont( const TQString &name, TQFont &reference, - const TQFont &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemFont *item; - item = new KConfigSkeleton::ItemFont( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemRect *KConfigSkeleton::addItemRect( const TQString &name, TQRect &reference, - const TQRect &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemRect *item; - item = new KConfigSkeleton::ItemRect( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemPoint *KConfigSkeleton::addItemPoint( const TQString &name, TQPoint &reference, - const TQPoint &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemPoint *item; - item = new KConfigSkeleton::ItemPoint( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemSize *KConfigSkeleton::addItemSize( const TQString &name, TQSize &reference, - const TQSize &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemSize *item; - item = new KConfigSkeleton::ItemSize( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemDateTime *KConfigSkeleton::addItemDateTime( const TQString &name, TQDateTime &reference, - const TQDateTime &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemDateTime *item; - item = new KConfigSkeleton::ItemDateTime( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemStringList *KConfigSkeleton::addItemStringList( const TQString &name, TQStringList &reference, - const TQStringList &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemStringList *item; - item = new KConfigSkeleton::ItemStringList( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -KConfigSkeleton::ItemIntList *KConfigSkeleton::addItemIntList( const TQString &name, TQValueList<int> &reference, - const TQValueList<int> &defaultValue, const TQString &key ) -{ - KConfigSkeleton::ItemIntList *item; - item = new KConfigSkeleton::ItemIntList( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -bool KConfigSkeleton::isImmutable(const TQString &name) -{ - KConfigSkeletonItem *item = findItem(name); - return !item || item->isImmutable(); -} - -KConfigSkeletonItem *KConfigSkeleton::findItem(const TQString &name) -{ - return mItemDict.find(name); -} diff --git a/kdecore/kconfigskeleton.h b/kdecore/kconfigskeleton.h deleted file mode 100644 index c3e9f4a57..000000000 --- a/kdecore/kconfigskeleton.h +++ /dev/null @@ -1,1230 +0,0 @@ -/* - * This file is part of KDE. - * - * Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> - * Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - * - * 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 _KCONFIGSKELETON_H -#define _KCONFIGSKELETON_H - -#include <tqcolor.h> -#include <tqdatetime.h> -#include <tqfont.h> -#include <tqpoint.h> -#include <tqptrlist.h> -#include <tqdict.h> -#include <tqrect.h> -#include <tqsize.h> -#include <tqstringlist.h> -#include <tqvariant.h> -#include <kconfig.h> -#include <kglobalsettings.h> - - /** - * @short Class for storing a preferences setting - * @author Cornelius Schumacher - * @see KConfigSkeleton - * - * This class represents one preferences setting as used by @ref KConfigSkeleton. - * Subclasses of KConfigSkeletonItem implement storage functions for a certain type of - * setting. Normally you don't have to use this class directly. Use the special - * addItem() functions of KConfigSkeleton instead. If you subclass this class you will - * have to register instances with the function KConfigSkeleton::addItem(). - */ - class KDECORE_EXPORT KConfigSkeletonItem - { - public: - typedef TQValueList < KConfigSkeletonItem * >List; - typedef TQDict < KConfigSkeletonItem > Dict; - typedef TQDictIterator < KConfigSkeletonItem > DictIterator; - - /** - * Constructor. - * - * @param group Config file group. - * @param key Config file key. - */ - KConfigSkeletonItem(const TQString & group, const TQString & key) - :mGroup(group),mKey(key), mIsImmutable(true) - { - } - - /** - * Destructor. - */ - virtual ~KConfigSkeletonItem() - { - } - - /** - * Set config file group. - */ - void setGroup( const TQString &group ) - { - mGroup = group; - } - - /** - * Return config file group. - */ - TQString group() const - { - return mGroup; - } - - /** - * Set config file key. - */ - void setKey( const TQString &key ) - { - mKey = key; - } - - /** - * Return config file key. - */ - TQString key() const - { - return mKey; - } - - /** - * Set internal name of entry. - */ - void setName(const TQString &name) - { - mName = name; - } - - /** - * Return internal name of entry. - */ - TQString name() const - { - return mName; - } - - /** - Set label providing a translated one-line description of the item. - */ - void setLabel( const TQString &l ) - { - mLabel = l; - } - - /** - Return label of item. See setLabel(). - */ - TQString label() const - { - return mLabel; - } - - /** - Set WhatsThis description og item. - */ - void setWhatsThis( const TQString &w ) - { - mWhatsThis = w; - } - - /** - Return WhatsThis description of item. See setWhatsThis(). - */ - TQString whatsThis() const - { - return mWhatsThis; - } - - /** - * This function is called by @ref KConfigSkeleton to read the value for this setting - * from a config file. - * value. - */ - virtual void readConfig(KConfig *) = 0; - - /** - * This function is called by @ref KConfigSkeleton to write the value of this setting - * to a config file. - */ - virtual void writeConfig(KConfig *) = 0; - - /** - * Read global default value. - */ - virtual void readDefault(KConfig *) = 0; - - /** - * Set item to @p p - */ - virtual void setProperty(const TQVariant &p) = 0; - - /** - * Return item as property - */ - virtual TQVariant property() const = 0; - - /** - * Return minimum value of item or invalid if not specified - */ - virtual TQVariant minValue() const { return TQVariant(); } - - /** - * Return maximum value of item or invalid if not specified - */ - virtual TQVariant maxValue() const { return TQVariant(); } - - /** - Sets the current value to the default value. - */ - virtual void setDefault() = 0; - - /** - * Exchanges the current value with the default value - * Used by KConfigSkeleton::useDefaults(bool); - */ - virtual void swapDefault() = 0; - - /** - * Return if the entry can be modified. - */ - bool isImmutable() const - { - return mIsImmutable; - } - - protected: - /** - * sets mIsImmutable to true if mKey in config is immutable - * @param config KConfig to check if mKey is immutable in - */ - void readImmutability(KConfig *config); - - TQString mGroup; - TQString mKey; - TQString mName; - - private: - bool mIsImmutable; - - TQString mLabel; - TQString mWhatsThis; - }; - - -template < typename T > class KConfigSkeletonGenericItem:public KConfigSkeletonItem - { - public: - KConfigSkeletonGenericItem(const TQString & group, const TQString & key, T & reference, - T defaultValue) - : KConfigSkeletonItem(group, key), mReference(reference), - mDefault(defaultValue), mLoadedValue(defaultValue) - { - } - - /** - * Set value of this KConfigSkeletonItem. - */ - void setValue(const T & v) - { - mReference = v; - } - - /** - * Return value of this KConfigSkeletonItem. - */ - T & value() - { - return mReference; - } - - /** - * Return const value of this KConfigSkeletonItem. - */ - const T & value() const - { - return mReference; - } - - /** - Set default value for this item. - */ - virtual void setDefaultValue( const T &v ) - { - mDefault = v; - } - - virtual void setDefault() - { - mReference = mDefault; - } - - virtual void writeConfig(KConfig * config) - { - if ( mReference != mLoadedValue ) // Is this needed? - { - config->setGroup(mGroup); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else - config->writeEntry(mKey, mReference); - } - } - - void readDefault(KConfig * config) - { - config->setReadDefaults(true); - readConfig(config); - config->setReadDefaults(false); - mDefault = mReference; - } - - void swapDefault() - { - T tmp = mReference; - mReference = mDefault; - mDefault = tmp; - } - - protected: - T & mReference; - T mDefault; - T mLoadedValue; - }; - - /** - * @short Class for handling preferences settings for an application. - * @author Cornelius Schumacher - * @see KConfigSkeletonItem - * - * This class provides an interface to preferences settings. Preferences items - * can be registered by the addItem() function corresponding to the data type of - * the seetting. KConfigSkeleton then handles reading and writing of config files and - * setting of default values. - * - * Normally you will subclass KConfigSkeleton, add data members for the preferences - * settings and register the members in the constructor of the subclass. - * - * Example: - * \code - * class MyPrefs : public KConfigSkeleton - * { - * public: - * MyPrefs() - * { - * setCurrentGroup("MyGroup"); - * addItemBool("MySetting1",mMyBool,false); - * addItemColor("MySetting2",mMyColor,TQColor(1,2,3)); - * - * setCurrentGroup("MyOtherGroup"); - * addItemFont("MySetting3",mMyFont,TQFont("helvetica",12)); - * } - * - * bool mMyBool; - * TQColor mMyColor; - * TQFont mMyFont; - * } - * \endcode - * - * It might be convenient in many cases to make this subclass of KConfigSkeleton a - * singleton for global access from all over the application without passing - * references to the KConfigSkeleton object around. - * - * You can write the data to the configuration file by calling @ref writeConfig() - * and read the data from the configuration file by calling @ref readConfig(). - * - * If you have items, which are not covered by the existing addItem() functions - * you can add customized code for reading, writing and default setting by - * implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and - * @ref usrWriteConfig(). - * - * Internally preferences settings are stored in instances of subclasses of - * @ref KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses - * for your own types and call the generic @ref addItem() to register them. - * - * In many cases you don't have to write the specific KConfigSkeleton - * subclasses yourself, but you can use \ref kconfig_compiler to automatically - * generate the C++ code from an XML description of the configuration options. - */ -class KDECORE_EXPORT KConfigSkeleton -{ -public: - - /** - * Class for handling a string preferences item. - */ - class KDECORE_EXPORT ItemString:public KConfigSkeletonGenericItem < TQString > - { - public: - enum Type { Normal, Password, Path }; - - ItemString(const TQString & group, const TQString & key, - TQString & reference, - const TQString & defaultValue = TQString::tqfromLatin1(""), // NOT TQString::null !! - Type type = Normal); - - void writeConfig(KConfig * config); - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - - private: - Type mType; - }; - - /** - * Class for handling a password preferences item. - */ - class KDECORE_EXPORT ItemPassword:public ItemString - { - public: - ItemPassword(const TQString & group, const TQString & key, - TQString & reference, - const TQString & defaultValue = TQString::tqfromLatin1("")); // NOT TQString::null !! - }; - - /** - * Class for handling a path preferences item. - */ - class KDECORE_EXPORT ItemPath:public ItemString - { - public: - ItemPath(const TQString & group, const TQString & key, - TQString & reference, - const TQString & defaultValue = TQString::null); - }; - - - /** - * Class for handling a TQVariant preferences item. - */ - class KDECORE_EXPORT ItemProperty:public KConfigSkeletonGenericItem < TQVariant > - { - public: - ItemProperty(const TQString & group, const TQString & key, - TQVariant & reference, TQVariant defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a bool preferences item. - */ - class KDECORE_EXPORT ItemBool:public KConfigSkeletonGenericItem < bool > - { - public: - ItemBool(const TQString & group, const TQString & key, bool & reference, - bool defaultValue = true); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling an integer preferences item. - */ - class KDECORE_EXPORT ItemInt:public KConfigSkeletonGenericItem < int > - { - public: - ItemInt(const TQString & group, const TQString & key, int &reference, - int defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(int); - void setMaxValue(int); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - int mMin; - int mMax; - }; - - /** - * Class for handling an 64-bit integer preferences item. - */ - class KDECORE_EXPORT ItemInt64:public KConfigSkeletonGenericItem < TQ_INT64 > - { - public: - ItemInt64(const TQString & group, const TQString & key, TQ_INT64 &reference, - TQ_INT64 defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(TQ_INT64); - void setMaxValue(TQ_INT64); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - TQ_INT64 mMin; - TQ_INT64 mMax; - }; - - /** - * Class for handling enums. - */ - class KDECORE_EXPORT ItemEnum:public ItemInt - { - public: - struct Choice - { - TQString name; - TQString label; - TQString whatsThis; - }; - - ItemEnum(const TQString & group, const TQString & key, int &reference, - const TQValueList<Choice> &choices, int defaultValue = 0); - - TQValueList<Choice> choices() const; - - void readConfig(KConfig * config); - void writeConfig(KConfig * config); - - private: - TQValueList<Choice> mChoices; - }; - - - /** - * Class for handling an unsingend integer preferences item. - */ - class KDECORE_EXPORT ItemUInt:public KConfigSkeletonGenericItem < unsigned int > - { - public: - ItemUInt(const TQString & group, const TQString & key, - unsigned int &reference, unsigned int defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(unsigned int); - void setMaxValue(unsigned int); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - unsigned int mMin; - unsigned int mMax; - }; - - - /** - * Class for hanlding a long integer preferences item. - */ - class KDECORE_EXPORT ItemLong:public KConfigSkeletonGenericItem < long > - { - public: - ItemLong(const TQString & group, const TQString & key, long &reference, - long defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(long); - void setMaxValue(long); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - long mMin; - long mMax; - }; - - - /** - * Class for handling an unsigned long integer preferences item. - */ - class KDECORE_EXPORT ItemULong:public KConfigSkeletonGenericItem < unsigned long > - { - public: - ItemULong(const TQString & group, const TQString & key, - unsigned long &reference, unsigned long defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(unsigned long); - void setMaxValue(unsigned long); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - unsigned long mMin; - unsigned long mMax; - }; - - /** - * Class for handling unsigned 64-bit integer preferences item. - */ - class KDECORE_EXPORT ItemUInt64:public KConfigSkeletonGenericItem < TQ_UINT64 > - { - public: - ItemUInt64(const TQString & group, const TQString & key, TQ_UINT64 &reference, - TQ_UINT64 defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(TQ_UINT64); - void setMaxValue(TQ_UINT64); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - TQ_UINT64 mMin; - TQ_UINT64 mMax; - }; - - /** - * Class for handling a floating point preference item. - */ - class KDECORE_EXPORT ItemDouble:public KConfigSkeletonGenericItem < double > - { - public: - ItemDouble(const TQString & group, const TQString & key, - double &reference, double defaultValue = 0); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(double); - void setMaxValue(double); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - double mMin; - double mMax; - }; - - - /** - * Class for handling a color preferences item. - */ - class KDECORE_EXPORT ItemColor:public KConfigSkeletonGenericItem < TQColor > - { - public: - ItemColor(const TQString & group, const TQString & key, - TQColor & reference, - const TQColor & defaultValue = TQColor(128, 128, 128)); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a font preferences item. - */ - class KDECORE_EXPORT ItemFont:public KConfigSkeletonGenericItem < TQFont > - { - public: - ItemFont(const TQString & group, const TQString & key, TQFont & reference, - const TQFont & defaultValue = KGlobalSettings::generalFont()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQRect preferences item. - */ - class KDECORE_EXPORT ItemRect:public KConfigSkeletonGenericItem < TQRect > - { - public: - ItemRect(const TQString & group, const TQString & key, TQRect & reference, - const TQRect & defaultValue = TQRect()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQPoint preferences item. - */ - class KDECORE_EXPORT ItemPoint:public KConfigSkeletonGenericItem < TQPoint > - { - public: - ItemPoint(const TQString & group, const TQString & key, TQPoint & reference, - const TQPoint & defaultValue = TQPoint()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQSize preferences item. - */ - class KDECORE_EXPORT ItemSize:public KConfigSkeletonGenericItem < TQSize > - { - public: - ItemSize(const TQString & group, const TQString & key, TQSize & reference, - const TQSize & defaultValue = TQSize()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQDateTime preferences item. - */ - class KDECORE_EXPORT ItemDateTime:public KConfigSkeletonGenericItem < TQDateTime > - { - public: - ItemDateTime(const TQString & group, const TQString & key, - TQDateTime & reference, - const TQDateTime & defaultValue = TQDateTime()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a string list preferences item. - */ - class KDECORE_EXPORT ItemStringList:public KConfigSkeletonGenericItem < TQStringList > - { - public: - ItemStringList(const TQString & group, const TQString & key, - TQStringList & reference, - const TQStringList & defaultValue = TQStringList()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a path list preferences item. - */ - class KDECORE_EXPORT ItemPathList:public ItemStringList - { - public: - ItemPathList(const TQString & group, const TQString & key, - TQStringList & reference, - const TQStringList & defaultValue = TQStringList()); - - void readConfig(KConfig * config); - void writeConfig(KConfig * config); - }; - - - /** - * Class for handling an integer list preferences item. - */ - class KDECORE_EXPORT ItemIntList:public KConfigSkeletonGenericItem < TQValueList < int > > - { - public: - ItemIntList(const TQString & group, const TQString & key, - TQValueList < int >&reference, - const TQValueList < int >&defaultValue = TQValueList < int >()); - - void readConfig(KConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - -public: - /** - * Constructor. - * - * @param configname name of config file. If no name is given, the default - * config file as returned by kapp()->config() is used. - */ - KConfigSkeleton(const TQString & configname = TQString::null); - - /** - * Constructor. - * - * @param config configuration object to use. - */ - KConfigSkeleton(KSharedConfig::Ptr config); - - /** - * Destructor - */ - virtual ~ KConfigSkeleton(); - - /** - Set all registered items to their default values. - */ - void setDefaults(); - - /** - * Read preferences from config file. All registered items are set to the - * values read from disk. - */ - void readConfig(); - - /** - * Write preferences to config file. The values of all registered items are - * written to disk. - */ - void writeConfig(); - - /** - * Set the config file group for subsequent addItem() calls. It is valid - * until setCurrentGroup() is called with a new argument. Call this before - * you add any items. The default value is "No Group". - */ - void setCurrentGroup(const TQString & group); - - /** - * Returns the current group used for addItem() calls. - */ - TQString currentGroup() // ### KDE 4.0: make const - { - return mCurrentGroup; - } - - /** - * Register a custom @ref KConfigSkeletonItem with a given name. If the name - * parameter is null, take the name from KConfigSkeletonItem::key(). - * Note that all names must be unique but that multiple entries can have - * the same key if they reside in different groups. - */ - void addItem(KConfigSkeletonItem *, const TQString & name = TQString::null ); - - /** - * Register an item of type TQString. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemString *addItemString(const TQString & name, TQString & reference, - const TQString & defaultValue = TQString::tqfromLatin1(""), // NOT TQString::null !! - const TQString & key = TQString::null); - - /** - * Register a password item of type TQString. The string value is written - * encrypted to the config file. Note that the current encryption scheme - * is very weak. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemPassword *addItemPassword(const TQString & name, TQString & reference, - const TQString & defaultValue = TQString::tqfromLatin1(""), - const TQString & key = TQString::null); - - /** - * Register a path item of type TQString. The string value is interpreted - * as a path. This means, dollar expension is activated for this value, so - * that e.g. $HOME gets expanded. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemPath *addItemPath(const TQString & name, TQString & reference, - const TQString & defaultValue = TQString::tqfromLatin1(""), - const TQString & key = TQString::null); - - /** - * Register a property item of type TQVariant. Note that only the following - * TQVariant types are allowed: String, StringList, Font, Point, Rect, Size, - * Color, Int, UInt, Bool, Double, DateTime and Date. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemProperty *addItemProperty(const TQString & name, TQVariant & reference, - const TQVariant & defaultValue = TQVariant(), - const TQString & key = TQString::null); - /** - * Register an item of type bool. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemBool *addItemBool(const TQString & name, bool & reference, - bool defaultValue = false, - const TQString & key = TQString::null); - - /** - * Register an item of type int. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemInt *addItemInt(const TQString & name, int &reference, int defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type unsigned int. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemUInt *addItemUInt(const TQString & name, unsigned int &reference, - unsigned int defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type long. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemLong *addItemLong(const TQString & name, long &reference, - long defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type unsigned long. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemULong *addItemULong(const TQString & name, unsigned long &reference, - unsigned long defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type TQ_INT64. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemInt64 *addItemInt64(const TQString & name, TQ_INT64 &reference, - TQ_INT64 defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type TQ_UINT64 - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemUInt64 *addItemUInt64(const TQString & name, TQ_UINT64 &reference, - TQ_UINT64 defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type double. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemDouble *addItemDouble(const TQString & name, double &reference, - double defaultValue = 0.0, - const TQString & key = TQString::null); - - /** - * Register an item of type TQColor. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemColor *addItemColor(const TQString & name, TQColor & reference, - const TQColor & defaultValue = TQColor(128, 128, 128), - const TQString & key = TQString::null); - - /** - * Register an item of type TQFont. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemFont *addItemFont(const TQString & name, TQFont & reference, - const TQFont & defaultValue = - KGlobalSettings::generalFont(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQRect. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemRect *addItemRect(const TQString & name, TQRect & reference, - const TQRect & defaultValue = TQRect(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQPoint. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemPoint *addItemPoint(const TQString & name, TQPoint & reference, - const TQPoint & defaultValue = TQPoint(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQSize. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemSize *addItemSize(const TQString & name, TQSize & reference, - const TQSize & defaultValue = TQSize(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQDateTime. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemDateTime *addItemDateTime(const TQString & name, TQDateTime & reference, - const TQDateTime & defaultValue = TQDateTime(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQStringList. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemStringList *addItemStringList(const TQString & name, TQStringList & reference, - const TQStringList & defaultValue = TQStringList(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQValueList<int>. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemIntList *addItemIntList(const TQString & name, TQValueList < int >&reference, - const TQValueList < int >&defaultValue = - TQValueList < int >(), - const TQString & key = TQString::null); - - /** - * Return the @ref KConfig object used for reading and writing the settings. - */ - KConfig *config() const; - - /** - * Return list of items managed by this KConfigSkeleton object. - */ - KConfigSkeletonItem::List items() const - { - return mItems; - } - - /** - * Return whether a certain item is immutable - */ - bool isImmutable(const TQString & name); - - /** - * Lookup item by name - */ - KConfigSkeletonItem * findItem(const TQString & name); - - /** - * Indicate whether this object should reflect the actual - * values or the default values. - * @param b If true this object reflects the default values. - * @return The state prior to this call - */ - bool useDefaults(bool b); - -protected: - /** - * Implemented by subclasses that use special defaults. - * It should replace the default values with the actual - * values and vice versa. - */ - virtual void usrUseDefaults(bool) - { - } - - virtual void usrSetDefaults() - { - } - - /** - * Implemented by subclasses that read special config values. - */ - virtual void usrReadConfig() - { - } - - /** - * Implemented by subclasses that write special config values. - */ - virtual void usrWriteConfig() - { - } - -private: - TQString mCurrentGroup; - - KSharedConfig::Ptr mConfig; // pointer to KConfig object - - KConfigSkeletonItem::List mItems; - KConfigSkeletonItem::Dict mItemDict; - - bool mUseDefaults; - - class Private; - Private *d; - -}; - -#endif diff --git a/kdecore/kcrash.cpp b/kdecore/kcrash.cpp deleted file mode 100644 index dbbd41338..000000000 --- a/kdecore/kcrash.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/* - * This file is part of the KDE Libraries - * Copyright (C) 2000 Timo Hummel <timo.hummel@sap.com> - * Tom Braun <braunt@fh-konstanz.de> - * - * 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. - */ - -/* - * This file is used to catch signals which would normally - * crash the application (like segmentation fault, floating - * point exception and such). - */ - -#include "config.h" - -#include <string.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <time.h> -#include "kcrash.h" - -#include <sys/types.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/wait.h> -#include <sys/un.h> -#include <sys/socket.h> -#include <errno.h> - -#include <tqwindowdefs.h> -#include <kglobal.h> -#include <kinstance.h> -#include <kaboutdata.h> -#include <kdebug.h> -#include <kapplication.h> -#include <dcopclient.h> - -#include <../kinit/klauncher_cmds.h> - -#if defined Q_WS_X11 -#include <X11/Xlib.h> -#endif - -KCrash::HandlerType KCrash::_emergencySaveFunction = 0; -KCrash::HandlerType KCrash::_crashHandler = 0; -const char *KCrash::appName = 0; -const char *KCrash::appPath = 0; -bool KCrash::safer = false; - -// This function sets the function which should be called when the -// application crashes and the -// application is asked to try to save its data. -void -KCrash::setEmergencySaveFunction (HandlerType saveFunction) -{ - _emergencySaveFunction = saveFunction; - - /* - * We need at least the default crash handler for - * emergencySaveFunction to be called - */ - if (_emergencySaveFunction && !_crashHandler) - _crashHandler = defaultCrashHandler; -} - - -// This function sets the function which should be responsible for -// the application crash handling. -void -KCrash::setCrashHandler (HandlerType handler) -{ -#ifdef Q_OS_UNIX - if (!handler) - handler = SIG_DFL; - - sigset_t mask; - sigemptyset(&mask); - -#ifdef SIGSEGV - signal (SIGSEGV, handler); - sigaddset(&mask, SIGSEGV); -#endif -#ifdef SIGFPE - signal (SIGFPE, handler); - sigaddset(&mask, SIGFPE); -#endif -#ifdef SIGILL - signal (SIGILL, handler); - sigaddset(&mask, SIGILL); -#endif -#ifdef SIGABRT - signal (SIGABRT, handler); - sigaddset(&mask, SIGABRT); -#endif - - sigprocmask(SIG_UNBLOCK, &mask, 0); -#endif //Q_OS_UNIX - - _crashHandler = handler; -} - -void -KCrash::defaultCrashHandler (int sig) -{ -#ifdef Q_OS_UNIX - // WABA: Do NOT use kdDebug() in this function because it is much too risky! - // Handle possible recursions - static int crashRecursionCounter = 0; - crashRecursionCounter++; // Nothing before this, please ! - - signal(SIGALRM, SIG_DFL); - alarm(3); // Kill me... (in case we deadlock in malloc) - - if (crashRecursionCounter < 2) { - if (_emergencySaveFunction) { - _emergencySaveFunction (sig); - } - crashRecursionCounter++; // - } - - // Close all remaining file descriptors except for stdin/stdout/stderr - struct rlimit rlp; - getrlimit(RLIMIT_NOFILE, &rlp); - for (int i = 3; i < (int)rlp.rlim_cur; i++) - close(i); - - - // this code is leaking, but this should not hurt cause we will do a - // exec() afterwards. exec() is supposed to clean up. - if (crashRecursionCounter < 3) - { - if (appName) - { -#ifndef NDEBUG - fprintf(stderr, "KCrash: crashing... crashRecursionCounter = %d\n", crashRecursionCounter); - fprintf(stderr, "KCrash: Application Name = %s path = %s pid = %d\n", appName ? appName : "<unknown>" , appPath ? appPath : "<unknown>", getpid()); -#else - fprintf(stderr, "KCrash: Application '%s' crashing...\n", appName ? appName : "<unknown>"); -#endif - - const char * argv[24]; // don't forget to update this - int i = 0; - - // argument 0 has to be drkonqi - argv[i++] = "drkonqi"; - -#if defined Q_WS_X11 - // start up on the correct display - argv[i++] = "-display"; - if ( qt_xdisplay() ) - argv[i++] = XDisplayString(qt_xdisplay()); - else - argv[i++] = getenv("DISPLAY"); -#elif defined(Q_WS_QWS) - // start up on the correct display - argv[i++] = "-display"; - argv[i++] = getenv("QWS_DISPLAY"); -#endif - - // we have already tested this - argv[i++] = "--appname"; - argv[i++] = appName; - if (KApplication::loadedByKdeinit) - argv[i++] = "--tdeinit"; - - // only add apppath if it's not NULL - if (appPath) { - argv[i++] = "--apppath"; - argv[i++] = appPath; - } - - // signal number -- will never be NULL - char sigtxt[ 10 ]; - sprintf( sigtxt, "%d", sig ); - argv[i++] = "--signal"; - argv[i++] = sigtxt; - - char pidtxt[ 10 ]; - sprintf( pidtxt, "%d", getpid()); - argv[i++] = "--pid"; - argv[i++] = pidtxt; - - const KInstance *instance = KGlobal::_instance; - const KAboutData *about = instance ? instance->aboutData() : 0; - if (about) { - if (about->internalVersion()) { - argv[i++] = "--appversion"; - argv[i++] = about->internalVersion(); - } - - if (about->internalProgramName()) { - argv[i++] = "--programname"; - argv[i++] = about->internalProgramName(); - } - - if (about->internalBugAddress()) { - argv[i++] = "--bugaddress"; - argv[i++] = about->internalBugAddress(); - } - } - - if ( kapp && !kapp->startupId().isNull()) { - argv[i++] = "--startupid"; - argv[i++] = kapp->startupId().data(); - } - - if ( safer ) - argv[i++] = "--safer"; - - // NULL terminated list - argv[i] = NULL; - - startDrKonqi( argv, i ); - _exit(253); - - } - else { - fprintf(stderr, "Unknown appname\n"); - } - } - - if (crashRecursionCounter < 4) - { - fprintf(stderr, "Unable to start Dr. Konqi\n"); - } -#endif //Q_OS_UNIX - - _exit(255); -} - -#ifdef Q_OS_UNIX - -// Since we can't fork() in the crashhandler, we cannot execute any external code -// (there can be functions registered to be performed before fork(), for example -// handling of malloc locking, which doesn't work when malloc crashes because of heap corruption). - -static int write_socket(int sock, char *buffer, int len); -static int read_socket(int sock, char *buffer, int len); -static int openSocket(); - -void KCrash::startDrKonqi( const char* argv[], int argc ) -{ - int socket = openSocket(); - if( socket < -1 ) - { - startDirectly( argv, argc ); - return; - } - klauncher_header header; - header.cmd = LAUNCHER_EXEC_NEW; - const int BUFSIZE = 8192; // make sure this is big enough - char buffer[ BUFSIZE + 10 ]; - int pos = 0; - long argcl = argc; - memcpy( buffer + pos, &argcl, sizeof( argcl )); - pos += sizeof( argcl ); - for( int i = 0; - i < argc; - ++i ) - { - int len = strlen( argv[ i ] ) + 1; // include terminating \0 - if( pos + len > BUFSIZE ) - { - fprintf( stderr, "BUFSIZE in KCrash not big enough!\n" ); - startDirectly( argv, argc ); - return; - } - memcpy( buffer + pos, argv[ i ], len ); - pos += len; - } - long env = 0; - memcpy( buffer + pos, &env, sizeof( env )); - pos += sizeof( env ); - long avoid_loops = 0; - memcpy( buffer + pos, &avoid_loops, sizeof( avoid_loops )); - pos += sizeof( avoid_loops ); - header.arg_length = pos; - write_socket(socket, (char *) &header, sizeof(header)); - write_socket(socket, buffer, pos); - if( read_socket( socket, (char *) &header, sizeof(header)) < 0 - || header.cmd != LAUNCHER_OK ) - { - startDirectly( argv, argc ); - return; - } - long pid; - read_socket(socket, buffer, header.arg_length); - pid = *((long *) buffer); - - alarm(0); // Seems we made it.... - - for(;;) - { - if( kill( pid, 0 ) < 0 ) - _exit(253); - sleep(1); - // the debugger should stop this process anyway - } -} - -// If we can't reach tdeinit we can still at least try to fork() -void KCrash::startDirectly( const char* argv[], int ) -{ - fprintf( stderr, "KCrash cannot reach tdeinit, launching directly.\n" ); - pid_t pid = fork(); - if (pid <= 0) - { - if(!geteuid() && setgid(getgid()) < 0) - _exit(253); - if(!geteuid() && setuid(getuid()) < 0) - _exit(253); - execvp("drkonqi", const_cast< char** >( argv )); - _exit(errno); - } - else - { - alarm(0); // Seems we made it.... - // wait for child to exit - waitpid(pid, NULL, 0); - _exit(253); - } -} - -// From now on this code is copy&pasted from kinit/wrapper.c : - -extern char **environ; - -static char *getDisplay() -{ - const char *display; - char *result; - char *screen; - char *colon; - char *i; -/* - don't test for a value from tqglobal.h but instead distinguish - Qt/X11 from Qt/Embedded by the fact that Qt/E apps have -DQWS - on the commandline (which in tqglobal.h however triggers Q_WS_QWS, - but we don't want to include that here) (Simon) -#ifdef Q_WS_X11 - */ -#if !defined(QWS) - display = getenv("DISPLAY"); -#else - display = getenv("QWS_DISPLAY"); -#endif - if (!display || !*display) - { - display = ":0"; - } - result = (char*)malloc(strlen(display)+1); - if (result == NULL) - return NULL; - - strcpy(result, display); - screen = strrchr(result, '.'); - colon = strrchr(result, ':'); - if (screen && (screen > colon)) - *screen = '\0'; - while((i = strchr(result, ':'))) - *i = '_'; - return result; -} - -/* - * Write 'len' bytes from 'buffer' into 'sock'. - * returns 0 on success, -1 on failure. - */ -static int write_socket(int sock, char *buffer, int len) -{ - ssize_t result; - int bytes_left = len; - while ( bytes_left > 0) - { - result = write(sock, buffer, bytes_left); - if (result > 0) - { - buffer += result; - bytes_left -= result; - } - else if (result == 0) - return -1; - else if ((result == -1) && (errno != EINTR) && (errno != EAGAIN)) - return -1; - } - return 0; -} - -/* - * Read 'len' bytes from 'sock' into 'buffer'. - * returns 0 on success, -1 on failure. - */ -static int read_socket(int sock, char *buffer, int len) -{ - ssize_t result; - int bytes_left = len; - while ( bytes_left > 0) - { - result = read(sock, buffer, bytes_left); - if (result > 0) - { - buffer += result; - bytes_left -= result; - } - else if (result == 0) - return -1; - else if ((result == -1) && (errno != EINTR) && (errno != EAGAIN)) - return -1; - } - return 0; -} - -static int openSocket() -{ - kde_socklen_t socklen; - int s; - struct sockaddr_un server; -#define MAX_SOCK_FILE 255 - char sock_file[MAX_SOCK_FILE + 1]; - const char *home_dir = getenv("HOME"); - const char *kde_home = getenv("KDEHOME"); - char *display; - - sock_file[0] = sock_file[MAX_SOCK_FILE] = 0; - - if (!kde_home || !kde_home[0]) - { - kde_home = "~/.trinity/"; - } - - if (kde_home[0] == '~') - { - if (!home_dir || !home_dir[0]) - { - fprintf(stderr, "Warning: $HOME not set!\n"); - return -1; - } - if (strlen(home_dir) > (MAX_SOCK_FILE-100)) - { - fprintf(stderr, "Warning: Home directory path too long!\n"); - return -1; - } - kde_home++; - strncpy(sock_file, home_dir, MAX_SOCK_FILE); - } - strncat(sock_file, kde_home, MAX_SOCK_FILE - strlen(sock_file)); - - /** Strip trailing '/' **/ - if ( sock_file[strlen(sock_file)-1] == '/') - sock_file[strlen(sock_file)-1] = 0; - - strncat(sock_file, "/socket-", MAX_SOCK_FILE - strlen(sock_file)); - if( getenv("XAUTHLOCALHOSTNAME")) - strncat(sock_file, getenv("XAUTHLOCALHOSTNAME"), MAX_SOCK_FILE - strlen(sock_file) - 1); - else if (gethostname(sock_file+strlen(sock_file), MAX_SOCK_FILE - strlen(sock_file) - 1) != 0) - { - perror("Warning: Could not determine hostname: "); - return -1; - } - sock_file[sizeof(sock_file)-1] = '\0'; - - /* append $DISPLAY */ - display = getDisplay(); - if (display == NULL) - { - fprintf(stderr, "Error: Could not determine display.\n"); - return -1; - } - - if (strlen(sock_file)+strlen(display)+strlen("/tdeinit_")+2 > MAX_SOCK_FILE) - { - fprintf(stderr, "Warning: Socket name will be too long.\n"); - free(display); - return -1; - } - strcat(sock_file, "/tdeinit_"); - strcat(sock_file, display); - free(display); - - if (strlen(sock_file) >= sizeof(server.sun_path)) - { - fprintf(stderr, "Warning: Path of socketfile exceeds UNIX_PATH_MAX.\n"); - return -1; - } - - /* - * create the socket stream - */ - s = socket(PF_UNIX, SOCK_STREAM, 0); - if (s < 0) - { - perror("Warning: socket() failed: "); - return -1; - } - - server.sun_family = AF_UNIX; - strcpy(server.sun_path, sock_file); - socklen = sizeof(server); - if(connect(s, (struct sockaddr *)&server, socklen) == -1) - { - perror("Warning: connect() failed: "); - close(s); - return -1; - } - return s; -} - -#endif // Q_OS_UNIX diff --git a/kdecore/kcrash.h b/kdecore/kcrash.h deleted file mode 100644 index 31a802f3d..000000000 --- a/kdecore/kcrash.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file is part of the KDE Libraries - * Copyright (C) 2000 Timo Hummel <timo.hummel@sap.com> - * Tom Braun <braunt@fh-konstanz.de> - * 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 __KCRASH_H -#define __KCRASH_H - -#include <tqstring.h> -#include "kdelibs_export.h" - -/** - * This class handles segmentation-faults. - * By default it displays a message-box saying the application crashed. - * This default can be overridden by setting a custom crash handler with - * setCrashHandler(). - * If a function is specified with setEmergencySaveFunction() it will - * be called by the default crash handler, giving the application a chance - * to save its data. - */ -class KDECORE_EXPORT KCrash -{ - private: // ;o) - static const char *appName; - static const char *appPath; - static bool safer; - - public: - /** - * The default crash handler. - * @param signal the signal number - */ - static void defaultCrashHandler (int signal); - - /** - * This function type is a pointer to a crash handler function. - * The function's argument is the number of the signal. - */ - typedef void (*HandlerType)(int); - - /** - * Install a function to be called in case a SIGSEGV is caught. - * @param handler HandlerType handler can be one of - * @li null in which case signal-catching is disabled - * (by calling signal(SIGSEGV, SIG_DFL)) - * @li if handler is omitted the default crash handler is installed. - * @li an user defined function in the form: - * static (if in a class) void myCrashHandler(int); - * @param handler the crash handler - */ - - static void setCrashHandler (HandlerType handler = defaultCrashHandler); - - /** - * Returns the installed crash handler. - * @return the crash handler - */ - static HandlerType crashHandler() { return _crashHandler; } - - /** - * Installs a function which should try to save the applications data. - * It is the crash handler´s responsibility to call this function. - * Therefore, if no crash handler is set, the default crash handler - * is installed to ensure the save function is called. - * @param saveFunction the handler to install - */ - static void setEmergencySaveFunction (HandlerType saveFunction = (HandlerType)0); - /** - * Return the currently set emergency save function. - * @return the emergency save function - */ - static HandlerType emergencySaveFunction() { return _emergencySaveFunction; } - - /** - * Set whether to start drkonqi without arbitrary disk access - */ - static void setSafer( bool on ) { safer = on; } - - /** - * Sets the application @p path which should be passed to - * Dr. Konqi, our nice crash display application. - * @param path the application path. - */ - static void setApplicationPath (TQString path) { appPath = qstrdup(path.local8Bit().data()); } - /* KDE 4: Make it const TQString & */ - - /** - * Sets the application name @p name which should be passed to - * Dr. Konqi, our nice crash display application. - * @param name the name of the application, as shown in Dr. Konqi - */ - static void setApplicationName (TQString name) { appName = qstrdup(name.local8Bit().data()); } - /* KDE 4: Make it const TQString & */ - - protected: - /** - * Pointer to the crash handler. - */ - static HandlerType _crashHandler; - /** - * Pointer to the emergency save function. - */ - static HandlerType _emergencySaveFunction; - - private: - static void startDrKonqi( const char* argv[], int argc ); - static void startDirectly( const char* argv[], int argc ); -}; - -#endif - diff --git a/kdecore/kdcoppropertyproxy.cpp b/kdecore/kdcoppropertyproxy.cpp deleted file mode 100644 index 3742c509c..000000000 --- a/kdecore/kdcoppropertyproxy.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1999 Simon Hausmann <hausmann@kde.org> - - 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. -*/ - -#include "kdcoppropertyproxy.h" - -#include <tqstrlist.h> -#include <tqmetaobject.h> -#include <tqvariant.h> -#include <tqcursor.h> -#include <tqbitmap.h> -#include <tqregion.h> -#include <tqpointarray.h> -#include <tqiconset.h> -#include <tqfont.h> -#include <tqimage.h> -#include <tqbrush.h> -#include <tqpalette.h> - -#include <ctype.h> -#include <assert.h> - -class KDCOPPropertyProxyPrivate -{ -public: - KDCOPPropertyProxyPrivate() - { - } - ~KDCOPPropertyProxyPrivate() - { - } - - TQObject *m_object; -}; - -KDCOPPropertyProxy::KDCOPPropertyProxy( TQObject *object ) -{ - d = new KDCOPPropertyProxyPrivate; - d->m_object = object; -} - -KDCOPPropertyProxy::~KDCOPPropertyProxy() -{ - delete d; -} - -bool KDCOPPropertyProxy::isPropertyRequest( const TQCString &fun ) -{ - return isPropertyRequest( fun, d->m_object ); -} - -bool KDCOPPropertyProxy::processPropertyRequest( const TQCString &fun, const TQByteArray &data, - TQCString &replyType, TQByteArray &replyData ) -{ - return processPropertyRequest( fun, data, replyType, replyData, d->m_object ); -} - -TQValueList<TQCString> KDCOPPropertyProxy::functions() -{ - return functions( d->m_object ); -} - -bool KDCOPPropertyProxy::isPropertyRequest( const TQCString &fun, TQObject *object ) -{ - if ( fun == "property(TQCString)" || - fun == "setProperty(TQCString,TQVariant)" || - fun == "propertyNames(bool)" ) - return true; - - bool set; - TQCString propName, arg; - return decodePropertyRequestInternal( fun, object, set, propName, arg ); -} - -TQValueList<TQCString> KDCOPPropertyProxy::functions( TQObject *object ) -{ - TQValueList<TQCString> res; - res << "TQVariant property(TQCString property)"; - res << "bool setProperty(TQCString name,TQVariant property)"; - res << "TQValueList<TQCString> propertyNames(bool super)"; - - TQMetaObject *metaObj = object->tqmetaObject(); - TQStrList properties = metaObj->propertyNames( true ); - TQStrListIterator it( properties ); - for (; it.current(); ++it ) - { - const TQMetaProperty *metaProp = metaObj->property( metaObj->findProperty( it.current(), true ), true ); - - assert( metaProp ); - - TQCString name = it.current(); - name.prepend( " " ); - name.prepend( metaProp->type() ); - name.append( "()" ); - res << name; - - if ( metaProp->writable() ) - { - TQCString setName = it.current(); - setName[ 0 ] = toupper( setName[ 0 ] ); - setName = "void set" + setName + "(" + metaProp->type() + " " + it.current() + ")"; - res << setName; - } - } - - return res; -} - -bool KDCOPPropertyProxy::processPropertyRequest( const TQCString &fun, const TQByteArray &data, - TQCString &replyType, TQByteArray &replyData, - TQObject *object ) -{ - if ( fun == "property(TQCString)" ) - { - TQCString propName; - TQDataStream stream( data, IO_ReadOnly ); - stream >> propName; - - replyType = "TQVariant"; - TQDataStream reply( replyData, IO_WriteOnly ); - reply << object->property( propName ); - return true; - } - - if ( fun == "setProperty(TQCString,TQVariant)" ) - { - TQCString propName; - TQVariant propValue; - TQDataStream stream( data, IO_ReadOnly ); - stream >> propName >> propValue; - - replyType = "bool"; - TQDataStream reply( replyData, IO_WriteOnly ); - reply << (TQ_INT8)object->setProperty( propName, propValue ); - return true; - } - - if ( fun == "propertyNames(bool)" ) - { - TQ_INT8 b; - TQDataStream stream( data, IO_ReadOnly ); - stream >> b; - - TQValueList<TQCString> res; - TQStrList props = object->tqmetaObject()->propertyNames( static_cast<bool>( b ) ); - TQStrListIterator it( props ); - for (; it.current(); ++it ) - res.append( it.current() ); - - replyType = "TQValueList<TQCString>"; - TQDataStream reply( replyData, IO_WriteOnly ); - reply << res; - return true; - } - - bool set; - TQCString propName, arg; - - bool res = decodePropertyRequestInternal( fun, object, set, propName, arg ); - if ( !res ) - return false; - - if ( set ) - { - TQVariant prop; - TQDataStream stream( data, IO_ReadOnly ); - - TQVariant::Type type = TQVariant::nameToType( arg ); - if ( type == TQVariant::Invalid ) - return false; - -#define DEMARSHAL( type, val ) \ - case TQVariant::type: \ - { \ - val v; \ - stream >> v; \ - prop = TQVariant( v ); \ - } \ - break; - - typedef TQValueList<TQVariant> ListType; - typedef TQMap<TQString,TQVariant> MapType; - - switch ( type ) - { - DEMARSHAL( Cursor, TQCursor ) - DEMARSHAL( Bitmap, TQBitmap ) - DEMARSHAL( PointArray, TQPointArray ) - DEMARSHAL( Region, TQRegion ) - DEMARSHAL( List, ListType ) - DEMARSHAL( Map, MapType ) - DEMARSHAL( String, TQString ) - DEMARSHAL( CString, TQCString ) - DEMARSHAL( StringList, TQStringList ) - DEMARSHAL( Font, TQFont ) - DEMARSHAL( Pixmap, TQPixmap ) - DEMARSHAL( Image, TQImage ) - DEMARSHAL( Brush, TQBrush ) - DEMARSHAL( Point, TQPoint ) - DEMARSHAL( Rect, TQRect ) - DEMARSHAL( Size, TQSize ) - DEMARSHAL( Color, TQColor ) - DEMARSHAL( Palette, TQPalette ) - DEMARSHAL( ColorGroup, TQColorGroup ) - case TQVariant::IconSet: - { - TQPixmap val; - stream >> val; - prop = TQVariant( TQIconSet( val ) ); - } - break; - DEMARSHAL( Int, int ) - DEMARSHAL( UInt, uint ) - case TQVariant::Bool: - { - TQ_INT8 v; - stream >> v; - prop = TQVariant( static_cast<bool>( v ), 1 ); - } - break; - DEMARSHAL( Double, double ) - default: - return false; - } - - replyType = "void"; - return object->setProperty( propName, prop ); - } - else - { - TQVariant prop = object->property( propName ); - - if ( prop.type() == TQVariant::Invalid ) - return false; - - replyType = prop.typeName(); - TQDataStream reply( replyData, IO_WriteOnly ); - -#define MARSHAL( type ) \ - case TQVariant::type: \ - reply << prop.to##type(); \ - break; - - switch ( prop.type() ) - { - MARSHAL( Cursor ) - MARSHAL( Bitmap ) - MARSHAL( PointArray ) - MARSHAL( Region ) - MARSHAL( List ) - MARSHAL( Map ) - MARSHAL( String ) - MARSHAL( CString ) - MARSHAL( StringList ) - MARSHAL( Font ) - MARSHAL( Pixmap ) - MARSHAL( Image ) - MARSHAL( Brush ) - MARSHAL( Point ) - MARSHAL( Rect ) - MARSHAL( Size ) - MARSHAL( Color ) - MARSHAL( Palette ) - MARSHAL( ColorGroup ) - case TQVariant::IconSet: - reply << prop.toIconSet().pixmap(); - break; - MARSHAL( Int ) - MARSHAL( UInt ) - case TQVariant::Bool: - reply << (TQ_INT8)prop.toBool(); - break; - MARSHAL( Double ) - default: - return false; - } - -#undef MARSHAL -#undef DEMARSHAL - - return true; - } - - return false; -} - -bool KDCOPPropertyProxy::decodePropertyRequestInternal( const TQCString &fun, TQObject *object, bool &set, - TQCString &propName, TQCString &arg ) -{ - if ( fun.length() < 3 ) - return false; - - set = false; - - propName = fun; - - if ( propName.left( 3 ) == "set" ) - { - propName.detach(); - set = true; - propName = propName.mid( 3 ); - int p1 = propName.find( '(' ); - - uint len = propName.length(); - - if ( propName[ len - 1 ] != ')' ) - return false; - - arg = propName.mid( p1+1, len - p1 - 2 ); - propName.truncate( p1 ); - propName[ 0 ] = tolower( propName[ 0 ] ); - } - else - propName.truncate( propName.length() - 2 ); - - if ( !object->tqmetaObject()->propertyNames( true ).contains( propName ) ) - return false; - - return true; -} diff --git a/kdecore/kdcoppropertyproxy.h b/kdecore/kdcoppropertyproxy.h deleted file mode 100644 index 9bc7736e3..000000000 --- a/kdecore/kdcoppropertyproxy.h +++ /dev/null @@ -1,106 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1999 Simon Hausmann <hausmann@kde.org> - - 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 __kdcoppropertyproxy_h__ -#define __kdcoppropertyproxy_h__ - -#include <tqobject.h> -#include <tqcstring.h> -#include <tqvaluelist.h> -#include "kdelibs_export.h" - -class KDCOPPropertyProxyPrivate; -/** - * The KDCOPPropertyProxy class provides an easy way to publish Qt properties of a - * TQObject through DCOP. - * - * The class provides DCOP equivalents for the Qt property methods setProperty() , - * property() and propertyNames() and also provides automatic set/get methods for - * the properties of a TQObject. That means for example if your object provides a - * TQString property called foo , then KDCOPPropertyProxy translates DCOP calls - * "setFoo( TQString )" and "TQString foo()" automatically into the corresponding - * setProperty/property calls. - */ -class KDECORE_EXPORT KDCOPPropertyProxy -{ -public: - /** - * Convenience constructor. Use it if you want to use this class as object, in contrary - * to using the static methods of this class and providing a TQObject argument for each - * call. - */ - KDCOPPropertyProxy( TQObject *object ); - /** - * Destructor. - */ - ~KDCOPPropertyProxy(); - - /** - * Convenience method, when using this class as object. See documentation of the constructor and - * static isPropertyRequest method. - */ - bool isPropertyRequest( const TQCString &fun ); - - /** - * Convenience method, when using this class as object. See documentation of the constructor and - * static processPropertyRequest method. - */ - bool processPropertyRequest( const TQCString &fun, const TQByteArray &data, TQCString &replyType, - TQByteArray &replyData ); - - /** - * Convenience method, when using this class as object. See documentation of the constructor and - * static functions method. - */ - TQValueList<TQCString> functions(); - - /** - * Returns a semicolon-separated list of functions understood by the PropertyProxy for the given - * TQObject argument. - * - * Returns "property(TQCString);setProperty(TQCString,TQVariant);propertyNames();" plus set/get - * methods for the properties of the given object argument. - * - * @see DCOPObject::functions() - */ - static TQValueList<TQCString> functions( TQObject *object ); - - /** - * Returns true if the method request in the fun argument matches the signature of the three standard - * property methods or set/get methods for the properties of the object argument. - * - * Use this method in your own DCOPObject dispatcher to check if the DCOP request is a property - * request which can be handled by this class. - */ - static bool isPropertyRequest( const TQCString &fun, TQObject *object ); - - /** - * Processes the given DCOP method request by translating the request into a setProperty/property call - * on the given TQObject argument. - */ - static bool processPropertyRequest( const TQCString &fun, const TQByteArray &data, TQCString &replyType, - TQByteArray &replyData, TQObject *object ); - -private: - static bool decodePropertyRequestInternal( const TQCString &fun, TQObject *object, bool &set, - TQCString &propName, TQCString &arg ); - - KDCOPPropertyProxyPrivate *d; -}; - -#endif diff --git a/kdecore/kde-config.cpp.cmake b/kdecore/kde-config.cpp.cmake deleted file mode 100644 index 867e43789..000000000 --- a/kdecore/kde-config.cpp.cmake +++ /dev/null @@ -1,272 +0,0 @@ -// -*- c++ -*- - -#include <kcmdlineargs.h> -#include <klocale.h> -#include <kinstance.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kglobalsettings.h> -#include <stdio.h> -#include <kaboutdata.h> -#include <config.h> -#include <kapplication.h> - -static const char *description = I18N_NOOP("A little program to output installation paths"); - -static KCmdLineOptions options[] = -{ - { "expandvars", I18N_NOOP("expand ${prefix} and ${exec_prefix} in output"), 0 }, - { "prefix", I18N_NOOP("Compiled in prefix for KDE libraries"), 0 }, - { "exec-prefix", I18N_NOOP("Compiled in exec_prefix for KDE libraries"), 0 }, - { "libsuffix", I18N_NOOP("Compiled in library path suffix"), 0 }, - { "localprefix", I18N_NOOP("Prefix in $HOME used to write files"), 0}, - { "version", I18N_NOOP("Compiled in version string for KDE libraries"), 0 }, - { "types", I18N_NOOP("Available KDE resource types"), 0 }, - { "path type", I18N_NOOP("Search path for resource type"), 0 }, - { "userpath type", I18N_NOOP("User path: desktop|autostart|trash|document"), 0 }, - { "install type", I18N_NOOP("Prefix to install resource files to"), 0}, - { 0,0,0 } -}; - -bool _expandvars = false; - -TQString expandvars(const char *_input) -{ - TQString result = TQString::fromLatin1(_input); - if (!_expandvars) - return result; - - bool changed = false; - int index = result.find("${prefix}"); - if (index >= 0) { - result = result.replace(index, 9, "@CMAKE_INSTALL_PREFIX@"); - changed = true; - } - index = result.find("$(prefix)"); - if (index >= 0) { - result = result.replace(index, 9, "@CMAKE_INSTALL_PREFIX@"); - changed = true; - } - index = result.find("${datadir}"); - if (index >= 0) { - result = result.replace(index, 10, "@SHARE_INSTALL_PREFIX@"); - changed = true; - } - index = result.find("$(datadir)"); - if (index >= 0) { - result = result.replace(index, 10, "@SHARE_INSTALL_PREFIX@"); - changed = true; - } - index = result.find("${exec_prefix}"); - if (index >= 0) { - result = result.replace(index, 14, "@EXEC_INSTALL_PREFIX@"); - changed = true; - } - index = result.find("$(exec_prefix)"); - if (index >= 0) { - result = result.replace(index, 14, "@EXEC_INSTALL_PREFIX@"); - changed = true; - } - index = result.find("${libdir}"); - if (index >= 0) { - result = result.replace(index, 9, "@LIB_INSTALL_DIR@"); - changed = true; - } - index = result.find("$(libdir)"); - if (index >= 0) { - result = result.replace(index, 9, "@LIB_INSTALL_DIR@"); - changed = true; - } - index = result.find("${includedir}"); - if (index >= 0) { - result = result.replace(index, 20, "@INCLUDE_INSTALL_DIR@"); - changed = true; - } - index = result.find("$(includedir)"); - if (index >= 0) { - result = result.replace(index, 20, "@INCLUDE_INSTALL_DIR@"); - changed = true; - } - index = result.find("${sysconfdir}"); - if (index >= 0) { - result = result.replace(index, 13, "@SYSCONF_INSTALL_DIR@"); - changed = true; - } - index = result.find("$(sysconfdir)"); - if (index >= 0) { - result = result.replace(index, 13, "@SYSCONF_INSTALL_DIR@"); - changed = true; - } - if (changed) - return expandvars(result.latin1()); - else - return result; -} - -void printResult(const TQString &s) -{ - if (s.isEmpty()) - printf("\n"); - else - printf("%s\n", s.local8Bit().data()); -} - -int main(int argc, char **argv) -{ - KLocale::setMainCatalogue("kdelibs"); - KAboutData about("kde-config", "kde-config", "1.0", description, KAboutData::License_GPL, "(C) 2000 Stephan Kulow"); - KCmdLineArgs::init( argc, argv, &about); - - KCmdLineArgs::addCmdLineOptions( options ); // Add my own options. - - KInstance a("kde-config"); - (void)KGlobal::dirs(); // trigger the creation - (void)KGlobal::config(); - - // Get application specific arguments - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - _expandvars = args->isSet("expandvars"); - - if (args->isSet("prefix")) - { - printResult(expandvars("@CMAKE_INSTALL_PREFIX@")); - return 0; - } - - if (args->isSet("exec-prefix")) - { - printResult(expandvars("@EXEC_INSTALL_PREFIX@")); - return 0; - } - - if (args->isSet("libsuffix")) - { - TQString tmp(KDELIBSUFF); - tmp.remove('"'); - printResult(expandvars(tmp.local8Bit())); - return 0; - } - - if (args->isSet("localprefix")) - { - printResult(KGlobal::dirs()->localkdedir()); - return 0; - } - - if (args->isSet("version")) - { - printf("%s\n", KDE_VERSION_STRING); - return 0; - } - - if (args->isSet("types")) - { - TQStringList types = KGlobal::dirs()->allTypes(); - types.sort(); - const char *helptexts[] = { - "apps", I18N_NOOP("Applications menu (.desktop files)"), - "cgi", I18N_NOOP("CGIs to run from kdehelp"), - "config", I18N_NOOP("Configuration files"), - "data", I18N_NOOP("Where applications store data"), - "exe", I18N_NOOP("Executables in $prefix/bin"), - "html", I18N_NOOP("HTML documentation"), - "icon", I18N_NOOP("Icons"), - "kcfg", I18N_NOOP("Configuration description files"), - "lib", I18N_NOOP("Libraries"), - "include", I18N_NOOP("Includes/Headers"), - "locale", I18N_NOOP("Translation files for KLocale"), - "mime", I18N_NOOP("Mime types"), - "module", I18N_NOOP("Loadable modules"), - "qtplugins", I18N_NOOP("Qt plugins"), - "services", I18N_NOOP("Services"), - "servicetypes", I18N_NOOP("Service types"), - "sound", I18N_NOOP("Application sounds"), - "templates", I18N_NOOP("Templates"), - "wallpaper", I18N_NOOP("Wallpapers"), - "xdgdata-apps", I18N_NOOP("XDG Application menu (.desktop files)"), - "xdgdata-dirs", I18N_NOOP("XDG Menu descriptions (.directory files)"), - "xdgconf-menu", I18N_NOOP("XDG Menu layout (.menu files)"), - "cmake", I18N_NOOP("CMake import modules (.cmake files)"), - "tmp", I18N_NOOP("Temporary files (specific for both current host and current user)"), - "socket", I18N_NOOP("UNIX Sockets (specific for both current host and current user)"), - 0, 0 - }; - for (TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it) - { - int index = 0; - while (helptexts[index] && *it != helptexts[index]) { - index += 2; - } - if (helptexts[index]) { - printf("%s - %s\n", helptexts[index], i18n(helptexts[index+1]).local8Bit().data()); - } else { - printf("%s", i18n("%1 - unknown type\n").tqarg(*it).local8Bit().data()); - } - } - return 0; - } - - TQString type = args->getOption("path"); - if (!type.isEmpty()) - { - printResult(KGlobal::dirs()->resourceDirs(type.latin1()).join(":")); - return 0; - } - - type = args->getOption("userpath"); - if (!type.isEmpty()) - { - if ( type == "desktop" ) - printResult(KGlobalSettings::desktopPath()); - else if ( type == "autostart" ) - printResult(KGlobalSettings::autostartPath()); - else if ( type == "trash" ) - printResult(KGlobalSettings::trashPath()); - else if ( type == "document" ) - printResult(KGlobalSettings::documentPath()); - else - fprintf(stderr, "%s", i18n("%1 - unknown type of userpath\n").tqarg(type).local8Bit().data() ); - return 0; - } - - type = args->getOption("install"); - if (!type.isEmpty()) - { - const char *installprefixes[] = { - "apps", "@APPS_INSTALL_DIR@", - "config", "@CONFIG_INSTALL_DIR@", - "kcfg", "@KCFG_INSTALL_DIR@", - "data", "@DATA_INSTALL_DIR@", - "exe", "@BIN_INSTALL_DIR@", - "html", "@HTML_INSTALL_DIR@", - "icon", "@ICON_INSTALL_DIR@", - "lib", "@LIB_INSTALL_DIR@", - "module", "@PLUGIN_INSTALL_DIR@", - "qtplugins", "@PLUGIN_INSTALL_DIR@/plugins", - "locale", "@LOCALE_INSTALL_DIR@", - "mime", "@MIME_INSTALL_DIR@", - "services", "@SERVICES_INSTALL_DIR@", - "servicetypes", "@SERVICETYPES_INSTALL_DIR@", - "sound", "@SOUND_INSTALL_DIR@", - "templates", "@TEMPLATES_INSTALL_DIR@", - "wallpaper", "@WALLPAPER_INSTALL_DIR@", - "xdgconf-menu", "@XDG_MENU_INSTALL_DIR@", - "xdgdata-apps", "@XDG_APPS_INSTALL_DIR@", - "xdgdata-dirs", "@XDG_DIRECTORY_INSTALL_DIR@", - "include", "@INCLUDE_INSTALL_DIR@", - "cmake", "@CMAKE_INSTALL_DIR@", - 0, 0 - }; - int index = 0; - while (installprefixes[index] && type != installprefixes[index]) { - index += 2; - } - if (installprefixes[index]) { - printResult(expandvars(installprefixes[index+1])); - } else { - printResult("NONE"); // no i18n here as for scripts - } - } - return 0; -} diff --git a/kdecore/kde-config.cpp.in b/kdecore/kde-config.cpp.in deleted file mode 100644 index ec9f24133..000000000 --- a/kdecore/kde-config.cpp.in +++ /dev/null @@ -1,270 +0,0 @@ -// -*- c++ -*- - -#include <kcmdlineargs.h> -#include <klocale.h> -#include <kinstance.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kglobalsettings.h> -#include <stdio.h> -#include <kaboutdata.h> -#include <config.h> -#include <kapplication.h> - -static const char *description = I18N_NOOP("A little program to output installation paths"); - -static KCmdLineOptions options[] = -{ - { "expandvars", I18N_NOOP("expand ${prefix} and ${exec_prefix} in output"), 0 }, - { "prefix", I18N_NOOP("Compiled in prefix for KDE libraries"), 0 }, - { "exec-prefix", I18N_NOOP("Compiled in exec_prefix for KDE libraries"), 0 }, - { "libsuffix", I18N_NOOP("Compiled in library path suffix"), 0 }, - { "localprefix", I18N_NOOP("Prefix in $HOME used to write files"), 0}, - { "version", I18N_NOOP("Compiled in version string for KDE libraries"), 0 }, - { "types", I18N_NOOP("Available KDE resource types"), 0 }, - { "path type", I18N_NOOP("Search path for resource type"), 0 }, - { "userpath type", I18N_NOOP("User path: desktop|autostart|trash|document"), 0 }, - { "install type", I18N_NOOP("Prefix to install resource files to"), 0}, - { 0,0,0 } -}; - -bool _expandvars = false; - -TQString expandvars(const char *_input) -{ - TQString result = TQString::tqfromLatin1(_input); - if (!_expandvars) - return result; - - bool changed = false; - int index = result.find("${prefix}"); - if (index >= 0) { - result = result.replace(index, 9, "@prefix@"); - changed = true; - } - index = result.find("$(prefix)"); - if (index >= 0) { - result = result.replace(index, 9, "@prefix@"); - changed = true; - } - index = result.find("${datadir}"); - if (index >= 0) { - result = result.replace(index, 10, "@datadir@"); - changed = true; - } - index = result.find("$(datadir)"); - if (index >= 0) { - result = result.replace(index, 10, "@datadir@"); - changed = true; - } - index = result.find("${exec_prefix}"); - if (index >= 0) { - result = result.replace(index, 14, "@exec_prefix@"); - changed = true; - } - index = result.find("$(exec_prefix)"); - if (index >= 0) { - result = result.replace(index, 14, "@exec_prefix@"); - changed = true; - } - index = result.find("${libdir}"); - if (index >= 0) { - result = result.replace(index, 9, "@libdir@"); - changed = true; - } - index = result.find("$(libdir)"); - if (index >= 0) { - result = result.replace(index, 9, "@libdir@"); - changed = true; - } - index = result.find("${includedir}"); - if (index >= 0) { - result = result.replace(index, 20, "@includedir@"); - changed = true; - } - index = result.find("$(includedir)"); - if (index >= 0) { - result = result.replace(index, 20, "@includedir@"); - changed = true; - } - index = result.find("${sysconfdir}"); - if (index >= 0) { - result = result.replace(index, 13, "@sysconfdir@"); - changed = true; - } - index = result.find("$(sysconfdir)"); - if (index >= 0) { - result = result.replace(index, 13, "@sysconfdir@"); - changed = true; - } - if (changed) - return expandvars(result.latin1()); - else - return result; -} - -void printResult(const TQString &s) -{ - if (s.isEmpty()) - printf("\n"); - else - printf("%s\n", s.local8Bit().data()); -} - -int main(int argc, char **argv) -{ - KLocale::setMainCatalogue("kdelibs"); - KAboutData about("kde-config", "kde-config", "1.0", description, KAboutData::License_GPL, "(C) 2000 Stephan Kulow"); - KCmdLineArgs::init( argc, argv, &about); - - KCmdLineArgs::addCmdLineOptions( options ); // Add my own options. - - KInstance a("kde-config"); - (void)KGlobal::dirs(); // trigger the creation - (void)KGlobal::config(); - - // Get application specific arguments - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - _expandvars = args->isSet("expandvars"); - - if (args->isSet("prefix")) - { - printResult(expandvars("@prefix@")); - return 0; - } - - if (args->isSet("exec-prefix")) - { - printResult(expandvars("@exec_prefix@")); - return 0; - } - - if (args->isSet("libsuffix")) - { - TQString tmp(KDELIBSUFF); - tmp.remove('"'); - printResult(expandvars(tmp.local8Bit())); - return 0; - } - - if (args->isSet("localprefix")) - { - printResult(KGlobal::dirs()->localkdedir()); - return 0; - } - - if (args->isSet("version")) - { - printf("%s\n", KDE_VERSION_STRING); - return 0; - } - - if (args->isSet("types")) - { - TQStringList types = KGlobal::dirs()->allTypes(); - types.sort(); - const char *helptexts[] = { - "apps", I18N_NOOP("Applications menu (.desktop files)"), - "cgi", I18N_NOOP("CGIs to run from kdehelp"), - "config", I18N_NOOP("Configuration files"), - "data", I18N_NOOP("Where applications store data"), - "exe", I18N_NOOP("Executables in $prefix/bin"), - "html", I18N_NOOP("HTML documentation"), - "icon", I18N_NOOP("Icons"), - "kcfg", I18N_NOOP("Configuration description files"), - "lib", I18N_NOOP("Libraries"), - "include", I18N_NOOP("Includes/Headers"), - "locale", I18N_NOOP("Translation files for KLocale"), - "mime", I18N_NOOP("Mime types"), - "module", I18N_NOOP("Loadable modules"), - "qtplugins", I18N_NOOP("Qt plugins"), - "services", I18N_NOOP("Services"), - "servicetypes", I18N_NOOP("Service types"), - "sound", I18N_NOOP("Application sounds"), - "templates", I18N_NOOP("Templates"), - "wallpaper", I18N_NOOP("Wallpapers"), - "xdgdata-apps", I18N_NOOP("XDG Application menu (.desktop files)"), - "xdgdata-dirs", I18N_NOOP("XDG Menu descriptions (.directory files)"), - "xdgconf-menu", I18N_NOOP("XDG Menu layout (.menu files)"), - "tmp", I18N_NOOP("Temporary files (specific for both current host and current user)"), - "socket", I18N_NOOP("UNIX Sockets (specific for both current host and current user)"), - 0, 0 - }; - for (TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it) - { - int index = 0; - while (helptexts[index] && *it != helptexts[index]) { - index += 2; - } - if (helptexts[index]) { - printf("%s - %s\n", helptexts[index], i18n(helptexts[index+1]).local8Bit().data()); - } else { - printf("%s", TQString(i18n("%1 - unknown type\n").arg(*it)).local8Bit().data()); - } - } - return 0; - } - - TQString type = args->getOption("path"); - if (!type.isEmpty()) - { - printResult(KGlobal::dirs()->resourceDirs(type.latin1()).join(":")); - return 0; - } - - type = args->getOption("userpath"); - if (!type.isEmpty()) - { - if ( type == "desktop" ) - printResult(KGlobalSettings::desktopPath()); - else if ( type == "autostart" ) - printResult(KGlobalSettings::autostartPath()); - else if ( type == "trash" ) - printResult(KGlobalSettings::trashPath()); - else if ( type == "document" ) - printResult(KGlobalSettings::documentPath()); - else - fprintf(stderr, "%s", TQString(i18n("%1 - unknown type of userpath\n").arg(type)).local8Bit().data() ); - return 0; - } - - type = args->getOption("install"); - if (!type.isEmpty()) - { - const char *installprefixes[] = { - "apps", "@kde_appsdir@", - "config", "@kde_confdir@", - "kcfg", "@kde_kcfgdir@", - "data", "@kde_datadir@", - "exe", "@kde_bindir@", - "html", "@kde_htmldir@", - "icon", "@kde_icondir@", - "lib", "@libdir@", - "module", "@kde_moduledir@", - "qtplugins", "@kde_moduledir@/plugins", - "locale", "@kde_locale@", - "mime", "@kde_mimedir@", - "services", "@kde_servicesdir@", - "servicetypes", "@kde_servicetypesdir@", - "sound", "@kde_sounddir@", - "templates", "@kde_templatesdir@", - "wallpaper", "@kde_wallpaperdir@", - "xdgconf-menu", "@xdg_menudir@", - "xdgdata-apps", "@xdg_appsdir@", - "xdgdata-dirs", "@xdg_directorydir@", - "include", "@includedir@", - 0, 0 - }; - int index = 0; - while (installprefixes[index] && type != installprefixes[index]) { - index += 2; - } - if (installprefixes[index]) { - printResult(expandvars(installprefixes[index+1])); - } else { - printResult("NONE"); // no i18n here as for scripts - } - } - return 0; -} diff --git a/kdecore/kde_dmalloc.h b/kdecore/kde_dmalloc.h deleted file mode 100644 index 4609349ae..000000000 --- a/kdecore/kde_dmalloc.h +++ /dev/null @@ -1,28 +0,0 @@ -/* This file is part of the KDE libraries - - 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. -*/ - -/* - * These operators are used in conjunction with the dmalloc memory - * debugging library. - */ -#if !defined(KDE_DMALLOC_H) && defined(WITH_DMALLOC) -#define KDE_DMALLOC_H - -#warning dmalloc support has been removed from KDE. use valgrind :) - -#endif - diff --git a/kdecore/kde_file.h b/kdecore/kde_file.h deleted file mode 100644 index b402aab29..000000000 --- a/kdecore/kde_file.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (C) 2001 Waldo Bastian <bastian@kde.org> - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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 _KDE_FILE_H_ -#define _KDE_FILE_H_ - -/** - * \file kde_file.h - * \brief This file provides portable defines for file support. - * - * Use the KDE_xxx defines instead of the normal C - * functions and structures. - * \since 3.3 - */ - -#include <unistd.h> -#ifdef _WIN32 -#include <kde_file_win.h> -#endif - -#if (defined _LFS64_LARGEFILE) && (defined _LARGEFILE64_SOURCE) -/* - * This section provides portable defines for large file support. - * To use this you must compile your code with _LARGEFILE64_SOURCE - * defined and use the KDE_xxx defines instead of the normal - * C functions and structures. - * - * Please note that not every platform supports 64 bit file structures, - * in that case the normal 32 bit functions will be used. - * - * @see http://www.suse.de/~aj/linux_lfs.html - * @see http://ftp.sas.com/standards/large.file/xopen/x_open.05Mar96.html - * - * KDE makes use of the "Transitional Extensions" since we can not ensure - * that all modules and libraries used by KDE will be compiled with - * 64-bit support. - * (A.3.2.3 Mixed API and Compile Environments within a Single Process) - */ -#define KDE_stat ::stat64 -#define KDE_lstat ::lstat64 -#define KDE_fstat ::fstat64 -#define KDE_open ::open64 -#define KDE_lseek ::lseek64 -#define KDE_fseek ::fseek64 -#define KDE_ftell ::ftell64 -#define KDE_fgetpos ::fgetpos64 -#define KDE_fsetpos ::fsetpos64 -#define KDE_readdir ::readdir64 -#define KDE_sendfile ::sendfile64 -#define KDE_struct_stat struct stat64 -#define KDE_struct_dirent struct dirent64 -#define KDE_rename ::rename -#define KDE_mkdir ::mkdir -/* TODO: define for win32 */ - -#else /* !_LFS64_LARGEFILE */ - -/* - * This section defines portable defines for standard file support. - */ -#ifdef _WIN32 -#define KDE_stat kdewin32_stat -#define KDE_lstat kdewin32_lstat -#define KDE_open kdewin32_open -#define KDE_rename kdewin32_rename -#define KDE_mkdir kdewin32_mkdir -#else /* unix */ -#define KDE_stat ::stat -#define KDE_lstat ::lstat -#define KDE_open ::open -#define KDE_rename ::rename -#define KDE_mkdir ::mkdir -#endif - -#define KDE_fstat ::fstat -#define KDE_lseek ::lseek -#define KDE_fseek ::fseek -#define KDE_ftell ::ftell -#define KDE_fgetpos ::fgetpos -#define KDE_fsetpos ::fsetpos -#define KDE_readdir ::readdir -#define KDE_sendfile ::sendfile -#define KDE_struct_stat struct stat -#define KDE_struct_dirent struct dirent -#endif - - -#ifdef _LFS64_STDIO -#define KDE_fopen ::fopen64 -#define KDE_freopen ::freopen64 -/* TODO: define for win32 */ -#else -#ifdef _WIN32 -#define KDE_fopen kdewin32_fopen -#define KDE_freopen kdewin32_freopen -#else /* unix */ -#define KDE_fopen ::fopen -#endif -#endif - -/* functions without 64-bit version but wrapped for compatibility reasons */ -#ifdef _WIN32 -#define KDE_fdopen kdewin32_fdopen -#else /* unix */ -#define KDE_fdopen ::fdopen -#endif - -#endif /* _KDE_FILE_H_ */ diff --git a/kdecore/kdebug.areas b/kdecore/kdebug.areas deleted file mode 100644 index efa46034c..000000000 --- a/kdecore/kdebug.areas +++ /dev/null @@ -1,599 +0,0 @@ -#Debug areas for kdebug() -# If you plan to add some areas, look at http://lists.kde.org/?l=kde-devel&m=106607933724723&w=2 first. -# Applications of the kdenonbeta module (or similar) should not define any own area but use area 0. -# When you add KDebug areas, email kde-devel@kde.org with the appropriate descriptions. -# -#Format : number<tab>description - -125 tdecore (KAccel) -126 tdecore (KURL) -127 kio (KProtocolInfo) -128 tdecore (KRegExp) -129 tdecore (KAction) -130 kio (KPasswdServer) -131 tdecore (KAcceleratorManager) -150 tdecore (KLibLoader) -160 tdecore (KNotifyClient) -170 tdecore (KNetwork socket) -171 tdecore (KSocks) -172 tdecore (KStartupInfo) -173 tdecore (KLocale) -174 tdecore (KProcIO) -175 tdecore (KProcess) -176 tdecore (KWin) -177 tdecore (KConfigSkeleton) -178 tdecore (KConfigDialogManager) -179 tdecore (KNetwork resolver) -180 tdecore (kdelibs) -200 tdeui (KMainWindow) -220 tdeui (KToolBar) -230 tdeui (KCommand) -240 tdeui (kdelibs) -250 kfile (kdelibs) -264 tdecore (KIconLoader) -265 tdecore (KIconEffect) -270 tdeui (KRootPixmap) -280 tdeui (KSharedPixmap) -281 tdeui (KCModule) -282 tdeui (KDockWidget) -290 tdeui (KPixmapIO) -291 tdeui (KAboutDialog) -292 tdeui (KComboBox) -293 tdeui (KLineEdit) -294 tdeui (KEdit) -295 tdeui (KMenuBar) -296 tdeui (KPopupMenu) -298 tdeui (KDatePicker) -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 (KCModuleProxy) -712 kutils (KCModuleInfo) -713 kutils (KCModuleContainer) -750 kspell (kdelibs) -760 kmdi -780 kcmshell (kdelibs) -790 kimproxy (kdelibs) -800 kabapi (kdelibs) -900 tdesu (kdelibs) -912 ksmartcard (kdelibs) - - -1000 kparts -1001 kparts (mainwindow) -1002 kparts (factory) - -# kdebase -1201 konqtree -1202 konqueror -1203 libkonq -1204 kdesktop -1205 tdesud -1206 tdesu -1207 kdesktop (Minicli) -1208 kcontrol -1210 kicker -1211 konsole -1212 kwin -1213 kappfinder -1214 kdesktop (icons) -1215 ksysguard -1216 kwin (client errors) -1217 khotkeys -1218 ksmserver -1219 media kioslave -1220 remote kioslave - -1400 khelpcenter (kdebase) -1401 kcmhelpcenter -1402 khc_indexbuilder - -1420 kikbd -1421 ki18b_keys (kcmodule) - -1430 nspluginviewer (Qt/Xt) -1431 nspluginviewer (plugin) -1432 nspluginviewer (part) -1433 nspluginscan - -# kdeutils -1501 khexedit (kdeutils) -1511 kdessh (kdeutils) -1512 kdepasswd (kdeutils) -1601 ark (kdeutils) -1901 kfind -1902 kfind (KfindWindow::updateResults) -1903 kfind (KfindTabDialog::createQuery) -2000 kfind -2001 kregexpeditor -2002 kfloppy -2003 ksim -2100 kgpg -2200 kdf -2300 kwallet - -# 2500-2999 Reserved for private use - -# kdeadmin -3000 ksysv -3100 ksysv (model) - -# kdegraphics -4300 kdvi (kdegraphics) -4400 kpaint (kdegraphics) -4500 kghostview (kdegraphics) -4600 kview -4610 kviewviewer -4620 kviewcanvas -4630 kview_plugin -4640 kiconedit - -# kdenetwork -5001 kget -5002 kppp -5003 knode -5004 kdict -5005 knewsticker -5006 kmail -5007 kpf -5008 ksirc -5009 filesharing -5050 libkmime -5051 libkmime (Codecs) -5052 libkmime (Plugin Loader) -5100 libkdenetwork -5150 libkleopatra - - -# tdepim -5200 kitchensync -5201 kitchensync (Konnector) -5202 kitchensync (OpieKonnector) -5203 kitchensync (PhoneKonnector) -5204 kitchensync (AgendaKonnector) -5205 kitchensync (CasioKonnector) -5210 kitchensync (KitchenSyncApp) -5220 kitchensync (ManipulatorParts) -5221 kitchensync (overviewpart) -5222 kitchensync (organizerpart) -5223 kitchensync (fileviewpart) -5224 kitchensync Desktop -5225 kitchensync (QtopiaKonnector) -5226 kitchensync Categories -5227 kitchensync Todo -5228 kitchensync AddressBook -5229 kitchensync Datebook -5230 kitchensync SyncEntry -5231 kitchensync SyncUI -5250 kitchensync (Syncing Algorithm) -5300 libtdepim -5310 kprefs -5400 calendarsystem -5500 knotes -5510 kpilot -5511 kpilotdaemon -5512 kpilotconduit -5600 kontact (core) -5601 kontact (interfaces) -5602 kontact (plugins) -5650 kresources -5700 kabc -5710 kabc/vcard -5720 kaddressbook -5800 libkcal -5850 korganizer -5855 korganizer (verbose) -5890 korgac -5891 korgac (check) -5900 kalarmd -5901 kalarmd (check) -5950 kalarm -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) -6100 kjas -6200 khtml (caret) -6201 khtml (caret table) -6210 khtml (editor) - -# libkio -7000 kio -7001 kio (KDirWatch) -7002 kio (Slave) -7003 kio (KDirLister) -7004 kio (KDirListerCache) -7005 kio (Filter) -7006 kio (Scheduler) -7007 kio (KIOJob) -7009 kio (KMimeType) -7010 kio (KRun) -7011 kio (KSycoca) -7012 kio (KService*) -7013 kio (KPing) -7014 kio (KTrader) -7015 kio (KAutoMount) -7016 kio (KLauncher) -7017 kio (KIOConnection) -7018 kio (KMimeMagic) -7019 kio (kioslave) -7020 kded -7021 kbuildsycoca -7022 kurifilter -7023 kurifilter (plugins) -7024 kio (UIServer) -7025 kpac -7026 kio (KShred) -7027 kio (TCPSlaveBase) -7028 kio (Observer) -7029 kssl -7030 kio (KEMailSettings) -7031 KImageIO -7032 kio (KURLCompletion) -7033 KFileMetaInfo -7034 KFileMetainfo (plugins) -7040 KZip -7041 KTar -7042 KAr -7043 kio (bookmarks) - -# 71xx are for kioslaves -7101 kio_file -7102 kio_ftp -7103 kio_http -7104 kcookiejar -7105 kio_pop3 -7106 kio_smb -7107 kio_man -7108 kio_info -7109 kio_tar -7110 kio_gzip -7111 kio_sql -7112 kio_smtp -7113 kio_http_debug -7114 kio_nntp -7115 kio_thumbnail -7116 kio_imap -7117 kio_audiocd -7118 kio_bzip2 -7119 kio_help -7120 kio_sftp -7121 kio_nfs -7122 kio_sieve -7123 kio_kamera -7124 kio_cgi -7125 kio_ldap -7126 kio_devices -7127 kio_fish -7128 kio_svn - -# kdesdk -8100 kompare -8101 kompare (libs) -8102 kompare (shell) -8103 kompare (part) -8104 kompare (list view) -8105 kompare (nav view) -8106 kompare (connect widget) -8107 kbabel -8108 kbabel (search) -8109 catalogmanager -8050 cervisia -8051 cervisia (cvsservice) - -# kdevelop -9000 kdevelop (core) -9001 kdevelop (grep view) -9002 kdevelop (doc tree view) -9003 kdevelop (class view) -9004 kdevelop (output views) -9005 kdevelop (class store) -9006 kdevelop (cvs interface) -9007 kdevelop (cpp support) -9008 kdevelop (gcc options) -9009 kdevelop (astyle) -9010 kdevelop (appwizard) -9011 kdevelop (python scripting) -9012 kdevelop (debugger) -9013 kdevelop (java support) -9014 kdevelop (python support) -9015 kdevelop (script project) -9016 kdevelop (perl support) -9017 kdevelop (file view) -9018 kdevelop (php support) -9019 kdevelop (fortran support) -9020 kdevelop (auto project) -9021 kdevelop (pgi options) -9022 kdevelop (ctags) -9023 kdevelop (regexptest) -9024 kdevelop (trollproject) -9025 kdevelop (customproject) -9026 kdevelop (doxygen) -9027 kdevelop (cvs) -9028 kdevelop (abbrev) -9029 kdevelop (filter) -9030 kdevelop (texttools) -9031 kdevelop (history) -9032 qeditor -9033 kdevelop (diff frontend) -9034 kdevelop (filecreate part) -9035 kdevelop (konsole part) -9036 kdevelop (subversion part) - -# toys and games -10000 amor -10500 KBackgammon -11000 libtdegames -11001 libtdegames (KGame) -11002 libtdegames (Highscores) -11111 kpat -12000 KPoker -12001 KPoker (Server) -12002 kvoctrain (application) -12003 kvoctrain (core library) -12004 kweather -12005 kallers -12006 kweatherservice -12007 kolf -12008 kbounce -12009 kblackbox -12010 kwin4 -12011 kenolaba -12012 kasteroids - - -# Kate/Kant/KWrite -13000 Kate -13001 Kate (App) -13002 Kate (View Manager) -13010 Kate (XML/Syntax) -13020 Kate (Document) -13025 Kate (Commands) -13030 Kate (View) -13033 Kate (Renderer) -13035 Kate (Code Completion) -13040 Kate (Plugins) -13050 Kate (Scripting) -13051 Kate (KJS Scripts) - -# Kopete -14000 kopete -14010 libkopete -14100 kopete (gadu) -14101 kopete (gadu - raw protocol) -14110 kopete (icq) -14111 kopete (icq - raw protocol) -14120 kopete (irc) -14121 kopete (irc - raw protocol) -14130 kopete (jabber) -14131 kopete (jabber - raw protocol) -14140 kopete (msn) -14141 kopete (msn - raw protocol) -14150 kopete (oscar) -14151 kopete (oscar - raw protocol) -14152 kopete (oscar/aim) -14153 kopete (oscar/icq) -14160 kopete (sms) -14161 kopete (sms - raw protocol) -14170 kopete (winpopup) -14171 kopete (winpopup - raw protocol) -14180 kopete (yahoo) -14181 kopete (yahoo - raw protocol) -14190 kopete (groupwise) -14191 kopete (libgroupwise) -14192 kopete (libgroupwise - raw) -14200 kopete (meanwhile) -14300 kopete (autoaway) -14301 kopete (connectionstatus) -14302 kopete (contactnotes) -14303 kopete (cryptography) -14304 kopete (importer) -14305 kopete (motionautoaway) -14306 kopete (msginfo) -14307 kopete (nowlistening) -14308 kopete (translator) -14309 kopete (webpresence) -14310 kopete (history) -14311 kopete (skype) -14312 kopete (smpppdcs) - -# KDB -20000 KDB (core) -20001 KDB (ui) -20010 KDB (DBEngine) -20011 KDB (Connection) -20012 KDB (plugin) - -#kfilereplace -23000 KFileReplace (kfilereplacepart) - -#klinkstatus -23100 KLinkStatus - -# Quanta -24000 Quanta -24001 Quanta (parser) -24002 Quanta (debugger) - -# kafka -25000 Kafka (kafkapp) -25001 Kafka (kafkaeditpart) -25002 Kafka (kafkapluginloader) -25003 Kafka (kafkaplugins) -25004 Kafka (kafkaobjectmgr) -25005 Kafka (kafkadom) - -# KSVG -26000 KSVG -26001 KSVG - Parser -26002 KSVG - Rendering -26003 KSVG - KPart -26004 KSVG - Ecma -26005 KSVG - Canvas - -26500 KDOM XInclude -26550 KDOM XPointer -26560 KDOM XPath -26600 KDOM Catalog -26650 KDOM kxmllint - -# XSLT on top of KDOM -27000 KXSLT - -# libkscan / kooka -28000 Kooka -29000 libkscan - -# 30001-40000 are for KOffice -30001 koffice (lib koml) -30002 koffice (lib store) -30003 koffice (lib kofficecore) -30004 koffice (lib kofficeui) -30005 koffice (lib kopainter) -30006 koffice (lib kospell) -30007 koffice (lib koproperty) -30500 koffice (filter manager) -30501 csvfilter -30502 asciifilter -30503 htmlfilter -30504 wmffilter -30505 msodfilter -30506 abiwordfilter -30507 docbookfilter -30508 export-filter-lib -30509 mswritefilter -30510 ole-lib -30511 ole-excel -30512 ole-powerpoint -30513 winword-filter -30514 svgfilter -30515 rtffilter -30516 pdffilter -30517 applix-filter -30518 openoffice-filter -30519 import-export-openoffice-filter-lib -30520 kword-1.3-filter -30521 gnumeric-filter -30522 latex-filter -30523 quattro-pro-filter -# 30524 -30525 palmdoc-filter -31000 koffice -32001 kword -32002 kword (formatting) -32003 kword (UI) -32004 kword (tables) -32500 kotext -33001 kpresenter -34000 kpresenter -34001 klyx -35000 klyx -35001 kchart -36000 kchart -36001 kspread -36002 kspread (cell) -37000 kspread -37001 graphite -38000 karbon -39001 kformula -40000 kformula -41000 krita (tiles) -41001 krita (core) -41002 krita (registry) -41003 krita (tools) -41004 krita (color management system) -41005 krita (filters) -41006 krita (plugins) -41007 krita (user interface) -41008 krita (file handling) -41009 krita (math) -41010 krita (render) -41011 krita (scripting) -42000 kplato -43000 kivio -44000 KexiDB -44001 KexiDB (driver impl) -44010 Kexi (general) -44020 Kexi (core) -44021 Kexi (plugins) - -# kdeextragear -50001 kfortune - -# KIPI - KDE Imaging Plugin Interface -51000 KIPI (general) -51001 KIPI (loading) - -# kdemultimedia -60001 kreatecd -60002 kaudiocreator -60005 krec -60010 libkcddb -65432 juk -66666 noatun -67000 kscd -67100 kmix -67200 kmid - -# kdebindings -70001 dcoppython -80001 kjsembed - -# kdeaddons -90000 vimpart -90010 noatun-plugins (dub) -90020 noatun-plugins (lyrics) -90100 konq-plugins (fsview) -90110 konq-plugins (webarchiver) -90120 konq-plugins (validators) -90130 konq-plugins (uachanger) -90140 konq-plugins (sidebar - newsticker) -90150 konq-plugins (minitools) -90160 konq-plugins (kuick) -90170 konq-plugins (kimgalleryplugin) -90180 konq-plugins (domtreeviewer) -90190 konq-plugins (dirfilter) -90200 kicker-applets (mediacontrol) -90210 konq-plugins (rellinks) - - -# kdenonbeta -100000 reaktivate (KPart) -100001 reaktivate (proxy) -100100 geheimnis -100101 geheimnis (backends) - -100200 kfs - -# rosegarden - -200000 rosegarden -200001 rosegarden (notation) -200002 rosegarden (matrix) -200003 rosegarden (sequencer) -200004 rosegarden (sequence manager) - - diff --git a/kdecore/kdebug.cpp b/kdecore/kdebug.cpp deleted file mode 100644 index ed1a3d60d..000000000 --- a/kdecore/kdebug.cpp +++ /dev/null @@ -1,596 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - 2002 Holger Freyther (freyther@kde.org) - - 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. -*/ - -#include "kdebug.h" - -#ifdef NDEBUG -#undef kdDebug -#undef kdBacktrace -#endif - -#include "kdebugdcopiface.h" - -#include "kapplication.h" -#include "kglobal.h" -#include "kinstance.h" -#include "kstandarddirs.h" - -#include <tqmessagebox.h> -#include <klocale.h> -#include <tqfile.h> -#include <tqintdict.h> -#include <tqstring.h> -#include <tqdatetime.h> -#include <tqpoint.h> -#include <tqrect.h> -#include <tqregion.h> -#include <tqstringlist.h> -#include <tqpen.h> -#include <tqbrush.h> -#include <tqsize.h> - -#include <kurl.h> - -#include <stdlib.h> // abort -#include <unistd.h> // getpid -#include <stdarg.h> // vararg stuff -#include <ctype.h> // isprint -#include <syslog.h> -#include <errno.h> -#include <string.h> -#include <kconfig.h> -#include "kstaticdeleter.h" -#include <config.h> - -#ifdef HAVE_BACKTRACE -#include <execinfo.h> -#endif - -class KDebugEntry; - -class KDebugEntry -{ -public: - KDebugEntry (int n, const TQCString& d) {number=n; descr=d;} - unsigned int number; - TQCString descr; -}; - -static TQIntDict<KDebugEntry> *KDebugCache; - -static KStaticDeleter< TQIntDict<KDebugEntry> > kdd; - -static TQCString getDescrFromNum(unsigned int _num) -{ - if (!KDebugCache) { - kdd.setObject(KDebugCache, new TQIntDict<KDebugEntry>( 601 )); - // Do not call this deleter from ~KApplication - KGlobal::unregisterStaticDeleter(&kdd); - KDebugCache->setAutoDelete(true); - } - - KDebugEntry *ent = KDebugCache->find( _num ); - if ( ent ) - return ent->descr; - - if ( !KDebugCache->isEmpty() ) // areas already loaded - return TQCString(); - - TQString filename(locate("config","kdebug.areas")); - if (filename.isEmpty()) - return TQCString(); - - TQFile file(filename); - if (!file.open(IO_ReadOnly)) { - qWarning("Couldn't open %s", filename.local8Bit().data()); - file.close(); - return TQCString(); - } - - uint lineNumber=0; - TQCString line(1024); - int len; - - while (( len = file.readLine(line.data(),line.size()-1) ) > 0) { - int i=0; - ++lineNumber; - - while (line[i] && line[i] <= ' ') - i++; - - unsigned char ch=line[i]; - - if ( !ch || ch =='#' || ch =='\n') - continue; // We have an eof, a comment or an empty line - - if (ch < '0' && ch > '9') { - qWarning("Syntax error: no number (line %u)",lineNumber); - continue; - } - - const int numStart=i; - do { - ch=line[++i]; - } while ( ch >= '0' && ch <= '9'); - - const TQ_ULONG number =line.mid(numStart,i).toULong(); - - while (line[i] && line[i] <= ' ') - i++; - - KDebugCache->insert(number, new KDebugEntry(number, line.mid(i, len-i-1))); - } - file.close(); - - ent = KDebugCache->find( _num ); - if ( ent ) - return ent->descr; - - return TQCString(); -} - -enum DebugLevels { - KDEBUG_INFO= 0, - KDEBUG_WARN= 1, - KDEBUG_ERROR= 2, - KDEBUG_FATAL= 3 -}; - - -struct kDebugPrivate { - kDebugPrivate() : - oldarea(0), config(0) { } - - ~kDebugPrivate() { delete config; } - - TQCString aAreaName; - unsigned int oldarea; - KConfig *config; -}; - -static kDebugPrivate *kDebug_data = 0; -static KStaticDeleter<kDebugPrivate> pcd; -static KStaticDeleter<KDebugDCOPIface> dcopsd; -static KDebugDCOPIface* kDebugDCOPIface = 0; - -static void kDebugBackend( unsigned short nLevel, unsigned int nArea, const char *data) -{ - if ( !kDebug_data ) - { - pcd.setObject(kDebug_data, new kDebugPrivate()); - // Do not call this deleter from ~KApplication - KGlobal::unregisterStaticDeleter(&pcd); - - // create the dcop interface if it has not been created yet - if (!kDebugDCOPIface) - { - kDebugDCOPIface = dcopsd.setObject(kDebugDCOPIface, new KDebugDCOPIface); - } - } - - if (!kDebug_data->config && KGlobal::_instance ) - { - kDebug_data->config = new KConfig("kdebugrc", false, false); - kDebug_data->config->setGroup("0"); - - //AB: this is necessary here, otherwise all output with area 0 won't be - //prefixed with anything, unless something with area != 0 is called before - if ( KGlobal::_instance ) - kDebug_data->aAreaName = KGlobal::instance()->instanceName(); - } - - if (kDebug_data->config && kDebug_data->oldarea != nArea) { - kDebug_data->config->setGroup( TQString::number(static_cast<int>(nArea)) ); - kDebug_data->oldarea = nArea; - if ( nArea > 0 && KGlobal::_instance ) - kDebug_data->aAreaName = getDescrFromNum(nArea); - if ((nArea == 0) || kDebug_data->aAreaName.isEmpty()) - if ( KGlobal::_instance ) - kDebug_data->aAreaName = KGlobal::instance()->instanceName(); - } - - int nPriority = 0; - TQString aCaption; - - /* Determine output */ - - TQString key; - switch( nLevel ) - { - case KDEBUG_INFO: - key = "InfoOutput"; - aCaption = "Info"; - nPriority = LOG_INFO; - break; - case KDEBUG_WARN: - key = "WarnOutput"; - aCaption = "Warning"; - nPriority = LOG_WARNING; - break; - case KDEBUG_FATAL: - key = "FatalOutput"; - aCaption = "Fatal Error"; - nPriority = LOG_CRIT; - break; - case KDEBUG_ERROR: - default: - /* Programmer error, use "Error" as default */ - key = "ErrorOutput"; - aCaption = "Error"; - nPriority = LOG_ERR; - break; - } - - // if no output mode is specified default to no debug output - short nOutput = kDebug_data->config ? kDebug_data->config->readNumEntry(key, 4) : 4; - - // If the application doesn't have a TQApplication object it can't use - // a messagebox. - if (!kapp && (nOutput == 1)) - nOutput = 2; - else if ( nOutput == 4 && nLevel != KDEBUG_FATAL ) - return; - - const int BUFSIZE = 4096; - char buf[BUFSIZE]; - if ( !kDebug_data->aAreaName.isEmpty() ) { - strlcpy( buf, kDebug_data->aAreaName.data(), BUFSIZE ); - strlcat( buf, ": ", BUFSIZE ); - strlcat( buf, data, BUFSIZE ); - } - else - strlcpy( buf, data, BUFSIZE ); - - - // Output - switch( nOutput ) - { - case 0: // File - { - const char* aKey; - switch( nLevel ) - { - case KDEBUG_INFO: - aKey = "InfoFilename"; - break; - case KDEBUG_WARN: - aKey = "WarnFilename"; - break; - case KDEBUG_FATAL: - aKey = "FatalFilename"; - break; - case KDEBUG_ERROR: - default: - aKey = "ErrorFilename"; - break; - } - TQFile aOutputFile( kDebug_data->config->readPathEntry(aKey, "kdebug.dbg") ); - aOutputFile.open( (TQIODevice_OpenModeFlag)((int)IO_WriteOnly | (int)IO_Append | (int)IO_Raw) ); - aOutputFile.writeBlock( buf, strlen( buf ) ); - aOutputFile.close(); - break; - } - case 1: // Message Box - { - // Since we are in tdecore here, we cannot use KMsgBox and use - // TQMessageBox instead - if ( !kDebug_data->aAreaName.isEmpty() ) - aCaption += TQString("(%1)").arg( QString(kDebug_data->aAreaName) ); - TQMessageBox::warning( 0L, aCaption, data, i18n("&OK") ); - break; - } - case 2: // Shell - { - write( 2, buf, strlen( buf ) ); //fputs( buf, stderr ); - break; - } - case 3: // syslog - { - syslog( nPriority, "%s", buf); - break; - } - } - - // check if we should abort - if( ( nLevel == KDEBUG_FATAL ) - && ( !kDebug_data->config || kDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) - abort(); -} - -kdbgstream &perror( kdbgstream &s) { return s << TQString(TQString::fromLocal8Bit(strerror(errno))); } -kdbgstream kdDebug(int area) { return kdbgstream(area, KDEBUG_INFO); } -kdbgstream kdDebug(bool cond, int area) { if (cond) return kdbgstream(area, KDEBUG_INFO); else return kdbgstream(0, 0, false); } - -kdbgstream kdError(int area) { return kdbgstream("ERROR: ", area, KDEBUG_ERROR); } -kdbgstream kdError(bool cond, int area) { if (cond) return kdbgstream("ERROR: ", area, KDEBUG_ERROR); else return kdbgstream(0,0,false); } -kdbgstream kdWarning(int area) { return kdbgstream("WARNING: ", area, KDEBUG_WARN); } -kdbgstream kdWarning(bool cond, int area) { if (cond) return kdbgstream("WARNING: ", area, KDEBUG_WARN); else return kdbgstream(0,0,false); } -kdbgstream kdFatal(int area) { return kdbgstream("FATAL: ", area, KDEBUG_FATAL); } -kdbgstream kdFatal(bool cond, int area) { if (cond) return kdbgstream("FATAL: ", area, KDEBUG_FATAL); else return kdbgstream(0,0,false); } - -kdbgstream::kdbgstream(kdbgstream &str) - : output(str.output), area(str.area), level(str.level), print(str.print) -{ - str.output.truncate(0); -} - -void kdbgstream::flush() { - if (output.isEmpty() || !print) - return; - kDebugBackend( level, area, output.local8Bit().data() ); - output = TQString::null; -} - -kdbgstream &kdbgstream::form(const char *format, ...) -{ - char buf[4096]; - va_list arguments; - va_start( arguments, format ); - vsnprintf( buf, sizeof(buf), format, arguments ); - va_end(arguments); - *this << buf; - return *this; -} - -kdbgstream::~kdbgstream() { - if (!output.isEmpty()) { - fprintf(stderr, "ASSERT: debug output not ended with \\n\n"); - fprintf(stderr, "%s", kdBacktrace().latin1()); - *this << "\n"; - } -} - -kdbgstream& kdbgstream::operator << (char ch) -{ - if (!print) return *this; - if (!isprint(ch)) - output += "\\x" + TQString::number( static_cast<uint>( ch ), 16 ).rightJustify(2, '0'); - else { - output += ch; - if (ch == '\n') flush(); - } - return *this; -} - -kdbgstream& kdbgstream::operator << (TQChar ch) -{ - if (!print) return *this; - if (!ch.isPrint()) - output += "\\x" + TQString::number( ch.tqunicode(), 16 ).rightJustify(2, '0'); - else { - output += ch; - if (ch == (QChar)'\n') flush(); - } - return *this; -} - -kdbgstream& kdbgstream::operator << (TQWidget* widget) -{ - return *this << const_cast< const TQWidget* >( widget ); -} - -kdbgstream& kdbgstream::operator << (const TQWidget* widget) -{ - TQString string, temp; - // ----- - if(widget==0) - { - string=(TQString)"[Null pointer]"; - } else { - temp.setNum((ulong)widget, 16); - string=(TQString)"["+widget->className()+" pointer " - + "(0x" + temp + ")"; - if(widget->name(0)==0) - { - string += " to unnamed widget, "; - } else { - string += (TQString)" to widget " + widget->name() + ", "; - } - string += "geometry=" - + TQString().setNum(widget->width()) - + "x"+TQString().setNum(widget->height()) - + "+"+TQString().setNum(widget->x()) - + "+"+TQString().setNum(widget->y()) - + "]"; - } - if (!print) - { - return *this; - } - output += string; - if (output.tqat(output.length() -1 ) == (QChar)'\n') - { - flush(); - } - return *this; -} -/* - * either use 'output' directly and do the flush if needed - * or use the TQString operator which calls the char* operator - * - */ -kdbgstream& kdbgstream::operator<<( const TQDateTime& time) { - *this << time.toString(); - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQDate& date) { - *this << TQString(date.toString()); - - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQTime& time ) { - *this << TQString(time.toString()); - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQPoint& p ) { - *this << "(" << p.x() << ", " << p.y() << ")"; - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQSize& s ) { - *this << "[" << s.width() << "x" << s.height() << "]"; - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQRect& r ) { - *this << "[" << r.x() << "," << r.y() << " - " << r.width() << "x" << r.height() << "]"; - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQRegion& reg ) { - *this<< "[ "; - - TQMemArray<TQRect>rs=reg.tqrects(); - for (uint i=0;i<rs.size();++i) - *this << TQString(TQString("[%1,%2 - %3x%4] ").arg(rs[i].x()).arg(rs[i].y()).arg(rs[i].width()).arg(rs[i].height() )) ; - - *this <<"]"; - return *this; -} -kdbgstream& kdbgstream::operator<<( const KURL& u ) { - *this << u.prettyURL(); - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQStringList& l ) { - *this << "("; - *this << l.join(","); - *this << ")"; - - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQColor& c ) { - if ( c.isValid() ) - *this << TQString(c.name()); - else - *this << "(invalid/default)"; - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQPen& p ) { - static const char* const s_penStyles[] = { - "NoPen", "SolidLine", "DashLine", "DotLine", "DashDotLine", - "DashDotDotLine" }; - static const char* const s_capStyles[] = { - "FlatCap", "SquareCap", "RoundCap" }; - *this << "[ style:"; - *this << s_penStyles[ p.style() ]; - *this << " width:"; - *this << p.width(); - *this << " color:"; - if ( p.color().isValid() ) - *this << TQString(p.color().name()); - else - *this <<"(invalid/default)"; - if ( p.width() > 0 ) // cap style doesn't matter, otherwise - { - *this << " capstyle:"; - *this << s_capStyles[ p.capStyle() >> 4 ]; - // join style omitted - } - *this <<" ]"; - return *this; -} -kdbgstream& kdbgstream::operator<<( const TQBrush& b) { - static const char* const s_brushStyles[] = { - "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern", - "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern", - "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern", - "DiagCrossPattern" }; - - *this <<"[ style: "; - *this <<s_brushStyles[ b.style() ]; - *this <<" color: "; - // can't use operator<<(str, b.color()) because that terminates a kdbgstream (flushes) - if ( b.color().isValid() ) - *this << TQString(b.color().name()) ; - else - *this <<"(invalid/default)"; - if ( b.pixmap() ) - *this <<" has a pixmap"; - *this <<" ]"; - return *this; -} - -kdbgstream& kdbgstream::operator<<( const TQVariant& v) { - *this << "[variant: "; - *this << v.typeName(); - // For now we just attempt a conversion to string. - // Feel free to switch(v.type()) and improve the output. - *this << " toString="; - *this << v.toString(); - *this << "]"; - return *this; -} - -kdbgstream& kdbgstream::operator<<( const TQByteArray& data) { - if (!print) return *this; - output += '['; - unsigned int i = 0; - unsigned int sz = QMIN( data.size(), 64 ); - for ( ; i < sz ; ++i ) { - output += TQString::number( (unsigned char) data[i], 16 ).rightJustify(2, '0'); - if ( i < sz ) - output += ' '; - } - if ( sz < data.size() ) - output += "..."; - output += ']'; - return *this; -} - -TQString kdBacktrace(int levels) -{ - TQString s; -#ifdef HAVE_BACKTRACE - void* trace[256]; - int n = backtrace(trace, 256); - if (!n) - return s; - char** strings = backtrace_symbols (trace, n); - - if ( levels != -1 ) - n = QMIN( n, levels ); - s = "[\n"; - - for (int i = 0; i < n; ++i) - s += TQString::number(i) + - TQString::tqfromLatin1(": ") + - TQString::tqfromLatin1(strings[i]) + TQString::tqfromLatin1("\n"); - s += "]\n"; - if (strings) - free (strings); -#endif - return s; -} - -TQString kdBacktrace() -{ - return kdBacktrace(-1 /*all*/); -} - -void kdClearDebugConfig() -{ - if (kDebug_data) { - delete kDebug_data->config; - kDebug_data->config = 0; - } -} - - -// Needed for --enable-final -#ifdef NDEBUG -#define kdDebug kndDebug -#endif diff --git a/kdecore/kdebug.h b/kdecore/kdebug.h deleted file mode 100644 index 0a7d2546f..000000000 --- a/kdecore/kdebug.h +++ /dev/null @@ -1,665 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - 2000-2002 Stephan Kulow (coolo@kde.org) - 2002 Holger Freyther (freyther@kde.org) - - 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 _KDEBUG_H_ -#define _KDEBUG_H_ - -#include <tqstring.h> -#include "kdelibs_export.h" - -class TQWidget; -class TQDateTime; -class TQDate; -class TQTime; -class TQPoint; -class TQSize; -class TQRect; -class TQRegion; -class KURL; -class TQStringList; -class TQColor; -class TQPen; -class TQBrush; -class TQVariant; -template <class T> -class TQValueList; - -class kdbgstream; -class kndbgstream; - -/** - * \addtogroup kdebug Debug message generators - * @{ - * KDE debug message streams let you and the user control just how many debug - * messages you see. - */ - -typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function -typedef kndbgstream & (*KNDBGFUNC)(kndbgstream &); // manipulator function - -#ifdef __GNUC__ -#define k_funcinfo "[" << __PRETTY_FUNCTION__ << "] " -#else -#define k_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] " -#endif - -#define k_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] " - -class kdbgstreamprivate; -/** - * kdbgstream is a text stream that allows you to print debug messages. - * Using the overloaded "<<" operator you can send messages. Usually - * you do not create the kdbgstream yourself, but use kdDebug() - * kdWarning(), kdError() or kdFatal to obtain one. - * - * Example: - * \code - * int i = 5; - * kdDebug() << "The value of i is " << i << endl; - * \endcode - * @see kndbgstream - */ -class KDECORE_EXPORT kdbgstream { - public: - /** - * @internal - */ - kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) : - area(_area), level(_level), print(_print) { } - kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true) : - output(TQString::tqfromLatin1(initialString)), area(_area), level(_level), print(_print) { } - /// Copy constructor - kdbgstream(kdbgstream &str); - kdbgstream(const kdbgstream &str) : - output(str.output), area(str.area), level(str.level), print(str.print) {} - ~kdbgstream(); - /** - * Prints the given value. - * @param i the boolean to print (as "true" or "false") - * @return this stream - */ - kdbgstream &operator<<(bool i) { - if (!print) return *this; - output += TQString::tqfromLatin1(i ? "true" : "false"); - return *this; - } - /** - * Prints the given value. - * @param i the short to print - * @return this stream - */ - kdbgstream &operator<<(short i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param i the unsigned short to print - * @return this stream - */ - kdbgstream &operator<<(unsigned short i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param ch the char to print - * @return this stream - */ - kdbgstream &operator<<(char ch); - /** - * Prints the given value. - * @param ch the unsigned char to print - * @return this stream - */ - kdbgstream &operator<<(unsigned char ch) { - return operator<<( static_cast<char>( ch ) ); - } - /** - * Prints the given value. - * @param i the int to print - * @return this stream - */ - kdbgstream &operator<<(int i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param i the unsigned int to print - * @return this stream - */ - kdbgstream &operator<<(unsigned int i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param i the long to print - * @return this stream - */ - kdbgstream &operator<<(long i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param i the unsigned long to print - * @return this stream - */ - kdbgstream &operator<<(unsigned long i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param i the long long to print - * @return this stream - */ - kdbgstream &operator<<(TQ_LLONG i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - /** - * Prints the given value. - * @param i the unsigned long long to print - * @return this stream - */ - kdbgstream &operator<<(TQ_ULLONG i) { - if (!print) return *this; - TQString tmp; tmp.setNum(i); output += tmp; - return *this; - } - - /** - * Flushes the output. - */ - void flush(); //AB: maybe this should be virtual! would save some trouble for some 3rd party projects - - /** - * Prints the given value. - * @param ch the char to print - * @return this stream - * @since 3.3 - */ - kdbgstream &operator<<(TQChar ch); - /** - * Prints the given value. - * @param string the string to print - * @return this stream - */ - kdbgstream &operator<<(const TQString& string) { - if (!print) return *this; - output += string; - if (output.tqat(output.length() -1 ) == (QChar)'\n') - flush(); - return *this; - } - /** - * Prints the given value. - * @param string the string to print - * @return this stream - */ - kdbgstream &operator<<(const char *string) { - if (!print) return *this; - output += TQString::fromUtf8(string); - if (output.tqat(output.length() - 1) == (QChar)'\n') - flush(); - return *this; - } - /** - * Prints the given value. - * @param string the string to print - * @return this stream - */ - kdbgstream &operator<<(const TQCString& string) { - *this << string.data(); - return *this; - } - /** - * Prints the given value. - * @param p a pointer to print (in number form) - * @return this stream - */ - kdbgstream& operator<<(const void * p) { - form("%p", p); - return *this; - } - /** - * Invokes the given function. - * @param f the function to invoke - * @return the return value of @p f - */ - kdbgstream& operator<<(KDBGFUNC f) { - if (!print) return *this; - return (*f)(*this); - } - /** - * Prints the given value. - * @param d the double to print - * @return this stream - */ - kdbgstream& operator<<(double d) { - TQString tmp; tmp.setNum(d); output += tmp; - return *this; - } - /** - * Prints the string @p format which can contain - * printf-style formatted values. - * @param format the printf-style format - * @return this stream - */ - kdbgstream &form(const char *format, ...) -#ifdef __GNUC__ - __attribute__ ( ( format ( printf, 2, 3 ) ) ) -#endif - ; - - /** Operator to print out basic information about a TQWidget. - * Output of class names only works if the class is tqmoc'ified. - * @param widget the widget to print - * @return this stream - */ - kdbgstream& operator << (const TQWidget* widget); - kdbgstream& operator << (TQWidget* widget); // KDE4 merge - - /** - * Prints the given value. - * @param dateTime the datetime to print - * @return this stream - */ - kdbgstream& operator << ( const TQDateTime& dateTime ); - - /** - * Prints the given value. - * @param date the date to print - * @return this stream - */ - kdbgstream& operator << ( const TQDate& date ); - - /** - * Prints the given value. - * @param time the time to print - * @return this stream - */ - kdbgstream& operator << ( const TQTime& time ); - - /** - * Prints the given value. - * @param point the point to print - * @return this stream - */ - kdbgstream& operator << ( const TQPoint& point ); - - /** - * Prints the given value. - * @param size the TQSize to print - * @return this stream - */ - kdbgstream& operator << ( const TQSize& size ); - - /** - * Prints the given value. - * @param rect the TQRect to print - * @return this stream - */ - kdbgstream& operator << ( const TQRect& rect); - - /** - * Prints the given value. - * @param region the TQRegion to print - * @return this stream - */ - kdbgstream& operator << ( const TQRegion& region); - - /** - * Prints the given value. - * @param url the url to print - * @return this stream - */ - kdbgstream& operator << ( const KURL& url ); - - /** - * Prints the given value. - * @param list the stringlist to print - * @return this stream - */ - // ### KDE4: Remove in favor of template operator for TQValueList<T> below - kdbgstream& operator << ( const TQStringList& list); - - /** - * Prints the given value. - * @param color the color to print - * @return this stream - */ - kdbgstream& operator << ( const TQColor& color); - - /** - * Prints the given value. - * @param pen the pen to print - * @return this stream - * @since 3.2 - */ - kdbgstream& operator << ( const TQPen& pen ); - - /** - * Prints the given value. - * @param brush the brush to print - * @return this stream - */ - kdbgstream& operator << ( const TQBrush& brush ); - - /** - * Prints the given value. - * @param variant the variant to print - * @return this stream - * @since 3.3 - */ - kdbgstream& operator << ( const TQVariant& variant ); - - /** - * Prints the given value. - * @param data the byte array to print - * @return this stream - * @since 3.3 - */ - kdbgstream& operator << ( const TQByteArray& data ); - - /** - * Prints the given value - * @param list the list to print - * @return this stream - * @since 3.3 - */ - template <class T> - kdbgstream& operator << ( const TQValueList<T> &list ); - - private: - TQString output; - unsigned int area, level; - bool print; - kdbgstreamprivate* d; -}; - -template <class T> -kdbgstream &kdbgstream::operator<<( const TQValueList<T> &list ) -{ - *this << "("; - typename TQValueList<T>::ConstIterator it = list.begin(); - if ( !list.isEmpty() ) { - *this << *it++; - } - for ( ; it != list.end(); ++it ) { - *this << "," << *it; - } - *this << ")"; - return *this; -} - -/** - * \relates KGlobal - * Prints an "\n". - * @param s the debug stream to write to - * @return the debug stream (@p s) - */ -inline kdbgstream &endl( kdbgstream &s) { s << "\n"; return s; } - -/** - * \relates KGlobal - * Flushes the stream. - * @param s the debug stream to write to - * @return the debug stream (@p s) - */ -inline kdbgstream &flush( kdbgstream &s) { s.flush(); return s; } - -KDECORE_EXPORT kdbgstream &perror( kdbgstream &s); - -/** - * \relates KGlobal - * kndbgstream is a dummy variant of kdbgstream. All functions do - * nothing. - * @see kndDebug() - */ -class KDECORE_EXPORT kndbgstream { - public: - /// Default constructor. - kndbgstream() {} - ~kndbgstream() {} - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(short int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(unsigned short int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(char ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(unsigned char ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(unsigned int ) { return *this; } - /** - * Does nothing. - */ - void flush() {} - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(TQChar) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(const TQString& ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(const TQCString& ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream &operator<<(const char *) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(const void *) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(void *) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(double) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(long) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(unsigned long) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(TQ_LLONG) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(TQ_ULLONG) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator<<(KNDBGFUNC) { return *this; } - /** - * Does nothing. - * @return this stream - */ - kndbgstream& operator << (const TQWidget*) { return *this; } - kndbgstream& operator << (TQWidget*) { return *this; } // KDE4 merge - /** - * Does nothing. - * @return this stream - */ - kndbgstream &form(const char *, ...) { return *this; } - - kndbgstream& operator<<( const TQDateTime& ) { return *this; } - kndbgstream& operator<<( const TQDate& ) { return *this; } - kndbgstream& operator<<( const TQTime& ) { return *this; } - kndbgstream& operator<<( const TQPoint & ) { return *this; } - kndbgstream& operator<<( const TQSize & ) { return *this; } - kndbgstream& operator<<( const TQRect & ) { return *this; } - kndbgstream& operator<<( const TQRegion & ) { return *this; } - kndbgstream& operator<<( const KURL & ) { return *this; } - kndbgstream& operator<<( const TQStringList & ) { return *this; } - kndbgstream& operator<<( const TQColor & ) { return *this; } - kndbgstream& operator<<( const TQPen & ) { return *this; } - kndbgstream& operator<<( const TQBrush & ) { return *this; } - kndbgstream& operator<<( const TQVariant & ) { return *this; } - kndbgstream& operator<<( const TQByteArray & ) { return *this; } - - template <class T> - kndbgstream& operator<<( const TQValueList<T> & ) { return *this; } -}; - -/** - * Does nothing. - * @param s a stream - * @return the given @p s - */ -inline kndbgstream &endl( kndbgstream & s) { return s; } -/** - * Does nothing. - * @param s a stream - * @return the given @p s - */ -inline kndbgstream &flush( kndbgstream & s) { return s; } -inline kndbgstream &perror( kndbgstream & s) { return s; } - -/** - * \relates KGlobal - * Returns a debug stream. You can use it to print debug - * information. - * @param area an id to identify the output, 0 for default - * @see kndDebug() - */ -KDECORE_EXPORT kdbgstream kdDebug(int area = 0); -KDECORE_EXPORT kdbgstream kdDebug(bool cond, int area = 0); -/** - * \relates KGlobal - * Returns a backtrace. - * @return a backtrace - */ -KDECORE_EXPORT TQString kdBacktrace(); -/** - * \relates KGlobal - * Returns a backtrace. - * @param levels the number of levels of the backtrace - * @return a backtrace - * @since 3.1 - */ -KDECORE_EXPORT TQString kdBacktrace(int levels); -/** - * Returns a dummy debug stream. The stream does not print anything. - * @param area an id to identify the output, 0 for default - * @see kdDebug() - */ -inline kndbgstream kndDebug(int area = 0) { Q_UNUSED(area); return kndbgstream(); } -inline kndbgstream kndDebug(bool , int = 0) { return kndbgstream(); } -inline TQString kndBacktrace() { return TQString::null; } -inline TQString kndBacktrace(int) { return TQString::null; } - -/** - * \relates KGlobal - * Returns a warning stream. You can use it to print warning - * information. - * @param area an id to identify the output, 0 for default - */ -KDECORE_EXPORT kdbgstream kdWarning(int area = 0); -KDECORE_EXPORT kdbgstream kdWarning(bool cond, int area = 0); -/** - * \relates KGlobal - * Returns an error stream. You can use it to print error - * information. - * @param area an id to identify the output, 0 for default - */ -KDECORE_EXPORT kdbgstream kdError(int area = 0); -KDECORE_EXPORT kdbgstream kdError(bool cond, int area = 0); -/** - * \relates KGlobal - * Returns a fatal error stream. You can use it to print fatal error - * information. - * @param area an id to identify the output, 0 for default - */ -KDECORE_EXPORT kdbgstream kdFatal(int area = 0); -KDECORE_EXPORT kdbgstream kdFatal(bool cond, int area = 0); - -/** - * \relates KGlobal - * Deletes the kdebugrc cache and therefore forces KDebug to reread the - * config file - */ -KDECORE_EXPORT void kdClearDebugConfig(); - -/** @} */ - -#ifdef NDEBUG -#define kdDebug kndDebug -#define kdBacktrace kndBacktrace -#endif - -#endif - diff --git a/kdecore/kdebugclasses.h b/kdecore/kdebugclasses.h deleted file mode 100644 index 00c0b07ce..000000000 --- a/kdecore/kdebugclasses.h +++ /dev/null @@ -1,33 +0,0 @@ - -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - 2000-2002 Stephan Kulow (coolo@kde.org) - - - 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 _KDEBUG_CLASSES_H_ -#define _KDEBUG_CLASSES_H_ - -#if defined(__GNUC__) -#warning include kdebug.h instead, except if KDE 3.1 compatibility is needed -#endif - -#include <kdebug.h> - -#endif - diff --git a/kdecore/kdebugdcopiface.cpp b/kdecore/kdebugdcopiface.cpp deleted file mode 100644 index 427384479..000000000 --- a/kdecore/kdebugdcopiface.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Andreas Beckermann (b_mann@gmx.de) - - 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. -*/ - -#include "kdebugdcopiface.h" -#include "kdebug.h" - -KDebugDCOPIface::KDebugDCOPIface() : DCOPObject("KDebug") -{ -} - -KDebugDCOPIface::~KDebugDCOPIface() -{ -} - -void KDebugDCOPIface::notifyKDebugConfigChanged() -{ - kdClearDebugConfig(); -} - -void KDebugDCOPIface::printBacktrace() -{ - kdDebug() << kdBacktrace() << endl; -} - diff --git a/kdecore/kdebugdcopiface.h b/kdecore/kdebugdcopiface.h deleted file mode 100644 index 44e4bcf71..000000000 --- a/kdecore/kdebugdcopiface.h +++ /dev/null @@ -1,52 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Andreas Beckermann (b_mann@gmx.de) - - 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 _KDEBUGDCOPIFACE_H_ -#define _KDEBUGDCOPIFACE_H_ - -#include <dcopobject.h> -#include <dcopref.h> -#include "kdelibs_export.h" - -/** - * @short DCOP interface to KDebug. - **/ -class KDECORE_EXPORT KDebugDCOPIface : virtual public DCOPObject -{ - K_DCOP -public: - KDebugDCOPIface(); - ~KDebugDCOPIface(); - -k_dcop: - /** - * The kdebugrc has been changed and should be reparsed now. - * This will simply call kdClearDebugConfig - **/ - void notifyKDebugConfigChanged(); - - /** - * Print out a kdBacktrace. Useful when trying to understand why - * a dialog is popping up, without having to launch gdb - */ - void printBacktrace(); -}; - -#endif - diff --git a/kdecore/kdebugrc b/kdecore/kdebugrc deleted file mode 100644 index 58b09ae7a..000000000 --- a/kdecore/kdebugrc +++ /dev/null @@ -1,142 +0,0 @@ -# This files includes the default behavior for some specific debug areas -# This allows to leave the kdDebug* calls in the code, but still have them -# disabled for most users. -# -# This file will be installed as $KDEDIR/share/config/kdebugrc -# -# There are four levels of output: Info, Warn, Error and Fatal -# corresponding to kdDebug(), kdWarn(), kdError(), kdFatal() -# -# For every of them you can define a target by *Output=n -# using the following numbers: -# -# 0 = file -# 1 = message box -# 2 = shell (stderr) -# 3 = syslog -# 4 = off -# -# For file output you can give a filename by *Filename=<file> -# otherwise kdebug.dbg in the current directory is used. -# -# ekzample: -# -# For the debug area 100 you want output of debug messages -# to a file /var/log/dbg.log and error messages as message boxes. -# Additionally the program should abort on fatal errors. -# -# [100] -# InfoOutput=0 -# InfoFilename=/var/log/dbg.log -# ErrorOutput=1 -# AbortFatal=1 -# - -# KAccel debug info off -[125] -InfoOutput=4 - -# KCheckAccel debug info off -[131] -InfoOutput=4 - -# KAction debug info off -[129] -InfoOutput=4 - -# KStartupInfo debug info off -[172] -InfoOutput=4 - -# KLocale debug info off -[173] -InfoOutput=4 - -# KMainWindow debug info off -[200] -InfoOutput=4 - -# KFile debug info off -[250] -InfoOutput=4 - -# KIconloader debug info off -[264] -InfoOutput=4 - -# KSpell debug info off -[750] -InfoOutput=4 - -# KPart's mainwindow info off -[1001] -InfoOutput=4 - -# KPart's factory info off -[1002] -InfoOutput=4 - -# KDesktop icons -[1214] -InfoOutput=4 - -# KHotKeys -[1217] -InfoOutput=4 - -# KMail -[5006] -InfoOutput=4 - -# KitchenSync (Syncing Algorithm) -[5250] -InfoOutput=4 - -# calendarsystem debug info off -[5400] -InfoOutput=4 - -# kabc/vcard -[5710] -InfoOutput=4 - -# korganizer (verbose) -[5855] -InfoOutput=4 - -# korgac (check) -[5891] -InfoOutput=4 - -# kalarmd check -[5901] -InfoOutput=4 - -# kio_http_debug debug info off -[7113] -InfoOutput=4 - -# kbzip2filter's debug info off -[7118] -InfoOutput=4 - -# kio_nntp debug info off -[7114] -InfoOutput=4 - -# KRun debug info off -[7010] -InfoOutput=4 - -# KMimeMagic debug info off -[7018] -InfoOutput=4 - -# KGame debug info off -[11001] -InfoOutput=4 - -# KOStore debug info off -[30002] -InfoOutput=4 - diff --git a/kdecore/kdelibs_export.h b/kdecore/kdelibs_export.h deleted file mode 100644 index 220657d0b..000000000 --- a/kdecore/kdelibs_export.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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 _KDELIBS_EXPORT_H -#define _KDELIBS_EXPORT_H - -/* needed for KDE_EXPORT macros */ -#include <kdemacros.h> - -/* needed, because e.g. Q_OS_UNIX is so frequently used */ -#include <tqglobal.h> - -#ifdef Q_WS_WIN -#include <kdelibs_export_win.h> - -#else /* Q_OS_UNIX */ - -/* export statements for unix */ -#define KDECORE_EXPORT KDE_EXPORT -#define KDEUI_EXPORT KDE_EXPORT -#define KDEFX_EXPORT KDE_EXPORT -#define KDEPRINT_EXPORT KDE_EXPORT -#define KDNSSD_EXPORT KDE_EXPORT -#define KIO_EXPORT KDE_EXPORT -#define DCOP_EXPORT KDE_EXPORT -#define KPARTS_EXPORT KDE_EXPORT -#define KTEXTEDITOR_EXPORT KDE_EXPORT -#define KABC_EXPORT KDE_EXPORT -#define KDESU_EXPORT KDE_EXPORT -#define KVCARD_EXPORT KDE_EXPORT -#define KRESOURCES_EXPORT KDE_EXPORT -#define KSTYLE_EXPORT KDE_EXPORT -#define KHTML_EXPORT KDE_EXPORT -#define KMDI_EXPORT KDE_EXPORT -#define KUTILS_EXPORT KDE_EXPORT -#define KATEPARTINTERFACES_EXPORT KDE_EXPORT -#define KATEPART_EXPORT KDE_EXPORT -#define KMID_EXPORT KDE_EXPORT -#define KRANDR_EXPORT KDE_EXPORT -#define KIMPROXY_EXPORT KDE_EXPORT -#define KDE_ARTS_EXPORT KDE_EXPORT -#define KUNITTEST_EXPORT KDE_EXPORT - -#define KPATH_SEPARATOR ':' - -#ifndef O_BINARY -#define O_BINARY 0 /* for open() */ -#endif - -#endif - -#endif /*_KDELIBS_EXPORT_H*/ - -/* workaround for tdecore: stupid tqmoc's grammar doesn't accept two macros - between 'class' keyword and <classname>: */ -#ifdef KDE_DEPRECATED -# ifndef KDECORE_EXPORT_DEPRECATED -# define KDECORE_EXPORT_DEPRECATED KDE_DEPRECATED KDECORE_EXPORT -# endif -# ifndef KIO_EXPORT_DEPRECATED -# define KIO_EXPORT_DEPRECATED KDE_DEPRECATED KIO_EXPORT -# endif -# ifndef KDEUI_EXPORT_DEPRECATED -# define KDEUI_EXPORT_DEPRECATED KDE_DEPRECATED KDEUI_EXPORT -# endif -# ifndef KABC_EXPORT_DEPRECATED -# define KABC_EXPORT_DEPRECATED KDE_DEPRECATED KABC_EXPORT -# endif -#endif -/* (let's add KDE****_EXPORT_DEPRECATED for other libraries if it's needed) */ diff --git a/kdecore/kdemacros.h.cmake b/kdecore/kdemacros.h.cmake deleted file mode 100644 index 766ca622a..000000000 --- a/kdecore/kdemacros.h.cmake +++ /dev/null @@ -1,220 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2002-2003 KDE Team - - 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 _KDE_MACROS_H_ -#define _KDE_MACROS_H_ - -/* Set by configure */ -#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 - -/** - * The KDE_NO_EXPORT macro marks the symbol of the given variable - * to be hidden. A hidden symbol is stripped during the linking step, - * so it can't be used from outside the resulting library, which is similar - * to static. However, static limits the visibility to the current - * compilation unit. hidden symbols can still be used in multiple compilation - * units. - * - * \code - * int KDE_NO_EXPORT foo; - * int KDE_EXPORT bar; - * \end - */ - -#ifdef __KDE_HAVE_GCC_VISIBILITY -#define KDE_NO_EXPORT __attribute__ ((visibility("hidden"))) -#define KDE_EXPORT __attribute__ ((visibility("default"))) -#elif defined(Q_WS_WIN) -#define KDE_NO_EXPORT -#define KDE_EXPORT __declspec(dllexport) -#else -#define KDE_NO_EXPORT -#define KDE_EXPORT -#endif - -/** - * KDE_Q_EXPORT_PLUGIN is a workaround for Qt not being able to - * cope with symbol visibility. - */ -#define KDE_Q_EXPORT_PLUGIN(PLUGIN) \ - TQ_EXTERN_C KDE_EXPORT const char* tqt_ucm_query_verification_data(); \ - TQ_EXTERN_C KDE_EXPORT TQUnknownInterface* ucm_instantiate(); \ - TQ_EXPORT_PLUGIN(PLUGIN) - -/** - * The KDE_PACKED can be used to hint the compiler that a particular - * structure or class should not contain unnecessary paddings. - */ - -#ifdef __GNUC__ -#define KDE_PACKED __attribute__((__packed__)) -#else -#define KDE_PACKED -#endif - -/** - * The KDE_DEPRECATED macro can be used to trigger compile-time warnings - * with newer compilers when deprecated functions are used. - * - * For non-inline functions, the macro gets inserted at the very end of the - * function declaration, right before the semicolon: - * - * \code - * DeprecatedConstructor() KDE_DEPRECATED; - * void deprecatedFunctionA() KDE_DEPRECATED; - * int deprecatedFunctionB() const KDE_DEPRECATED; - * \endcode - * - * Functions which are implemented inline are handled differently: for them, - * the KDE_DEPRECATED macro is inserted at the front, right before the return - * type, but after "static" or "virtual": - * - * \code - * KDE_DEPRECATED void deprecatedInlineFunctionA() { .. } - * virtual KDE_DEPRECATED int deprecatedInlineFunctionB() { .. } - * static KDE_DEPRECATED bool deprecatedInlineFunctionC() { .. } - * \end - * - * You can also mark whole structs or classes as deprecated, by inserting the - * KDE_DEPRECATED macro after the struct/class keyword, but before the - * name of the struct/class: - * - * \code - * class KDE_DEPRECATED DeprecatedClass { }; - * struct KDE_DEPRECATED DeprecatedStruct { }; - * \endcode - * - * \note - * It does not make much sense to use the KDE_DEPRECATED keyword for a Qt signal; - * this is because usually get called by the class which they belong to, - * and one'd assume that a class author doesn't use deprecated methods of his - * own class. The only exception to this are signals which are connected to - * other signals; they get invoked from moc-generated code. In any case, - * printing a warning message in either case is not useful. - * For slots, it can make sense (since slots can be invoked directly) but be - * aware that if the slots get triggered by a signal, the will get called from - * moc code as well and thus the warnings are useless. - * - * \par - * Also note that it is not possible to use KDE_DEPRECATED for classes which - * use the k_dcop keyword (to indicate a DCOP interface declaration); this is - * because the dcopidl program would choke on the unexpected declaration - * syntax. - */ - -#ifndef KDE_DEPRECATED -#if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2) - /* gcc >= 3.2 */ -# define KDE_DEPRECATED __attribute__ ((deprecated)) -#elif defined(_MSC_VER) && (_MSC_VER >= 1300) - /* msvc >= 7 */ -# define KDE_DEPRECATED __declspec(deprecated) -#else -# define KDE_DEPRECATED -#endif -#endif - -/** - * The KDE_ISLIKELY macro tags a boolean expression as likely to evaluate to - * 'true'. When used in an if ( ) statement, it gives a hint to the compiler - * that the following codeblock is likely to get executed. Providing this - * information helps the compiler to optimize the code for better performance. - * Using the macro has an insignificant code size or runtime memory footprint impact. - * The code semantics is not affected. - * - * \note - * Providing wrong information ( like marking a condition that almost never - * passes as 'likely' ) will cause a significant runtime slowdown. Therefore only - * use it for cases where you can be sure about the odds of the expression to pass - * in all cases ( independent from e.g. user configuration ). - * - * \par - * The KDE_ISUNLIKELY macro tags an expression as unlikely evaluating to 'true'. - * - * \note - * Do NOT use ( !KDE_ISLIKELY(foo) ) as an replacement for KDE_ISUNLIKELY ! - * - * \code - * if ( KDE_ISUNLIKELY( testsomething() ) ) - * abort(); // assume its unlikely that the application aborts - * \endcode - */ -#if __GNUC__ - 0 >= 3 -# define KDE_ISLIKELY( x ) __builtin_expect(!!(x),1) -# define KDE_ISUNLIKELY( x ) __builtin_expect(!!(x),0) -#else -# define KDE_ISLIKELY( x ) ( x ) -# define KDE_ISUNLIKELY( x ) ( x ) -#endif - -/** - * This macro, and it's friends going up to 10 reserve a fixed number of virtual - * functions in a class. Because adding virtual functions to a class changes the - * size of the vtable, adding virtual functions to a class breaks binary - * compatibility. However, by using this macro, and decrementing it as new - * virtual methods are added, binary compatibility can still be preserved. - * - * \note The added functions must be added to the header at the same location - * as the macro; changing the order of virtual functions in a header is also - * binary incompatible as it breaks the layout of the vtable. - */ - -#define RESERVE_VIRTUAL_1 \ - virtual void reservedVirtual1() {} -#define RESERVE_VIRTUAL_2 \ - virtual void reservedVirtual2() {} \ - RESERVE_VIRTUAL_1 -#define RESERVE_VIRTUAL_3 \ - virtual void reservedVirtual3() {} \ - RESERVE_VIRTUAL_2 -#define RESERVE_VIRTUAL_4 \ - virtual void reservedVirtual4() {} \ - RESERVE_VIRTUAL_3 -#define RESERVE_VIRTUAL_5 \ - virtual void reservedVirtual5() {} \ - RESERVE_VIRTUAL_4 -#define RESERVE_VIRTUAL_6 \ - virtual void reservedVirtual6() {} \ - RESERVE_VIRTUAL_5 -#define RESERVE_VIRTUAL_7 \ - virtual void reservedVirtual7() {} \ - RESERVE_VIRTUAL_6 -#define RESERVE_VIRTUAL_8 \ - virtual void reservedVirtual8() {} \ - RESERVE_VIRTUAL_7 -#define RESERVE_VIRTUAL_9 \ - virtual void reservedVirtual9() {} \ - RESERVE_VIRTUAL_8 -#define RESERVE_VIRTUAL_10 \ - virtual void reservedVirtual10() {} \ - RESERVE_VIRTUAL_9 - -/** - * The KDE_WEAK_SYMBOL macro can be used to tell the compiler that - * a particular function should be a weak symbol (that e.g. may be overriden - * in another library, -Bdirect will not bind this symbol directly) - */ - -#ifdef __GNUC__ -#define KDE_WEAK_SYMBOL __attribute__((__weak__)) -#else -#define KDE_WEAK_SYMBOL -#endif - -#endif /* _KDE_MACROS_H_ */ diff --git a/kdecore/kdemacros.h.in b/kdecore/kdemacros.h.in deleted file mode 100644 index 04ee7f183..000000000 --- a/kdecore/kdemacros.h.in +++ /dev/null @@ -1,220 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2002-2003 KDE Team - - 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 _KDE_MACROS_H_ -#define _KDE_MACROS_H_ - -/* Set by configure */ -#undef __KDE_HAVE_GCC_VISIBILITY - -/** - * The KDE_NO_EXPORT macro marks the symbol of the given variable - * to be hidden. A hidden symbol is stripped during the linking step, - * so it can't be used from outside the resulting library, which is similar - * to static. However, static limits the visibility to the current - * compilation unit. hidden symbols can still be used in multiple compilation - * units. - * - * \code - * int KDE_NO_EXPORT foo; - * int KDE_EXPORT bar; - * \end - */ - -#ifdef __KDE_HAVE_GCC_VISIBILITY -#define KDE_NO_EXPORT __attribute__ ((visibility("hidden"))) -#define KDE_EXPORT __attribute__ ((visibility("default"))) -#elif defined(Q_WS_WIN) -#define KDE_NO_EXPORT -#define KDE_EXPORT __declspec(dllexport) -#else -#define KDE_NO_EXPORT -#define KDE_EXPORT -#endif - -/** - * KDE_Q_EXPORT_PLUGIN is a workaround for Qt not being able to - * cope with symbol visibility. - */ -#define KDE_Q_EXPORT_PLUGIN(PLUGIN) \ - TQ_EXTERN_C KDE_EXPORT const char* tqt_ucm_query_verification_data(); \ - TQ_EXTERN_C KDE_EXPORT TQUnknownInterface* ucm_instantiate(); \ - TQ_EXPORT_PLUGIN(PLUGIN) - -/** - * The KDE_PACKED can be used to hint the compiler that a particular - * structure or class should not contain unnecessary paddings. - */ - -#ifdef __GNUC__ -#define KDE_PACKED __attribute__((__packed__)) -#else -#define KDE_PACKED -#endif - -/** - * The KDE_DEPRECATED macro can be used to trigger compile-time warnings - * with newer compilers when deprecated functions are used. - * - * For non-inline functions, the macro gets inserted at the very end of the - * function declaration, right before the semicolon: - * - * \code - * DeprecatedConstructor() KDE_DEPRECATED; - * void deprecatedFunctionA() KDE_DEPRECATED; - * int deprecatedFunctionB() const KDE_DEPRECATED; - * \endcode - * - * Functions which are implemented inline are handled differently: for them, - * the KDE_DEPRECATED macro is inserted at the front, right before the return - * type, but after "static" or "virtual": - * - * \code - * KDE_DEPRECATED void deprecatedInlineFunctionA() { .. } - * virtual KDE_DEPRECATED int deprecatedInlineFunctionB() { .. } - * static KDE_DEPRECATED bool deprecatedInlineFunctionC() { .. } - * \end - * - * You can also mark whole structs or classes as deprecated, by inserting the - * KDE_DEPRECATED macro after the struct/class keyword, but before the - * name of the struct/class: - * - * \code - * class KDE_DEPRECATED DeprecatedClass { }; - * struct KDE_DEPRECATED DeprecatedStruct { }; - * \endcode - * - * \note - * It does not make much sense to use the KDE_DEPRECATED keyword for a Qt signal; - * this is because usually get called by the class which they belong to, - * and one'd assume that a class author doesn't use deprecated methods of his - * own class. The only exception to this are signals which are connected to - * other signals; they get invoked from tqmoc-generated code. In any case, - * printing a warning message in either case is not useful. - * For slots, it can make sense (since slots can be invoked directly) but be - * aware that if the slots get triggered by a signal, the will get called from - * tqmoc code as well and thus the warnings are useless. - * - * \par - * Also note that it is not possible to use KDE_DEPRECATED for classes which - * use the k_dcop keyword (to indicate a DCOP interface declaration); this is - * because the dcopidl program would choke on the unexpected declaration - * syntax. - */ - -#ifndef KDE_DEPRECATED -#if __GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2) - /* gcc >= 3.2 */ -# define KDE_DEPRECATED __attribute__ ((deprecated)) -#elif defined(_MSC_VER) && (_MSC_VER >= 1300) - /* msvc >= 7 */ -# define KDE_DEPRECATED __declspec(deprecated) -#else -# define KDE_DEPRECATED -#endif -#endif - -/** - * The KDE_ISLIKELY macro tags a boolean expression as likely to evaluate to - * 'true'. When used in an if ( ) statement, it gives a hint to the compiler - * that the following codeblock is likely to get executed. Providing this - * information helps the compiler to optimize the code for better performance. - * Using the macro has an insignificant code size or runtime memory footprint impact. - * The code semantics is not affected. - * - * \note - * Providing wrong information ( like marking a condition that almost never - * passes as 'likely' ) will cause a significant runtime slowdown. Therefore only - * use it for cases where you can be sure about the odds of the expression to pass - * in all cases ( independent from e.g. user configuration ). - * - * \par - * The KDE_ISUNLIKELY macro tags an expression as unlikely evaluating to 'true'. - * - * \note - * Do NOT use ( !KDE_ISLIKELY(foo) ) as an replacement for KDE_ISUNLIKELY ! - * - * \code - * if ( KDE_ISUNLIKELY( testsomething() ) ) - * abort(); // assume its unlikely that the application aborts - * \endcode - */ -#if __GNUC__ - 0 >= 3 -# define KDE_ISLIKELY( x ) __builtin_expect(!!(x),1) -# define KDE_ISUNLIKELY( x ) __builtin_expect(!!(x),0) -#else -# define KDE_ISLIKELY( x ) ( x ) -# define KDE_ISUNLIKELY( x ) ( x ) -#endif - -/** - * This macro, and it's friends going up to 10 reserve a fixed number of virtual - * functions in a class. Because adding virtual functions to a class changes the - * size of the vtable, adding virtual functions to a class breaks binary - * compatibility. However, by using this macro, and decrementing it as new - * virtual methods are added, binary compatibility can still be preserved. - * - * \note The added functions must be added to the header at the same location - * as the macro; changing the order of virtual functions in a header is also - * binary incompatible as it breaks the layout of the vtable. - */ - -#define RESERVE_VIRTUAL_1 \ - virtual void reservedVirtual1() {} -#define RESERVE_VIRTUAL_2 \ - virtual void reservedVirtual2() {} \ - RESERVE_VIRTUAL_1 -#define RESERVE_VIRTUAL_3 \ - virtual void reservedVirtual3() {} \ - RESERVE_VIRTUAL_2 -#define RESERVE_VIRTUAL_4 \ - virtual void reservedVirtual4() {} \ - RESERVE_VIRTUAL_3 -#define RESERVE_VIRTUAL_5 \ - virtual void reservedVirtual5() {} \ - RESERVE_VIRTUAL_4 -#define RESERVE_VIRTUAL_6 \ - virtual void reservedVirtual6() {} \ - RESERVE_VIRTUAL_5 -#define RESERVE_VIRTUAL_7 \ - virtual void reservedVirtual7() {} \ - RESERVE_VIRTUAL_6 -#define RESERVE_VIRTUAL_8 \ - virtual void reservedVirtual8() {} \ - RESERVE_VIRTUAL_7 -#define RESERVE_VIRTUAL_9 \ - virtual void reservedVirtual9() {} \ - RESERVE_VIRTUAL_8 -#define RESERVE_VIRTUAL_10 \ - virtual void reservedVirtual10() {} \ - RESERVE_VIRTUAL_9 - -/** - * The KDE_WEAK_SYMBOL macro can be used to tell the compiler that - * a particular function should be a weak symbol (that e.g. may be overriden - * in another library, -Bdirect will not bind this symbol directly) - */ - -#ifdef __GNUC__ -#define KDE_WEAK_SYMBOL __attribute__((__weak__)) -#else -#define KDE_WEAK_SYMBOL -#endif - -#endif /* _KDE_MACROS_H_ */ diff --git a/kdecore/kdesktopfile.cpp b/kdecore/kdesktopfile.cpp deleted file mode 100644 index 431a65578..000000000 --- a/kdecore/kdesktopfile.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Pietro Iglio <iglio@kde.org> - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - - 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. -*/ - -// $Id$ - -#include <stdlib.h> -#include <unistd.h> - -#include <tqfile.h> -#include <tqdir.h> -#include <tqtextstream.h> - -#include <kdebug.h> -#include "kurl.h" -#include "kconfigbackend.h" -#include "kapplication.h" -#include "kstandarddirs.h" -#include "kmountpoint.h" -#include "kcatalogue.h" -#include "klocale.h" - -#include "kdesktopfile.h" -#include "kdesktopfile.moc" - -KDesktopFile::KDesktopFile(const TQString &fileName, bool bReadOnly, - const char * resType) - : KConfig(TQString::tqfromLatin1(""), bReadOnly, false) -{ - // KConfigBackEnd will try to locate the filename that is provided - // based on the resource type specified, _only_ if the filename - // is not an absolute path. - backEnd->changeFileName(fileName, resType, false); - setReadOnly(bReadOnly); - reparseConfiguration(); - setDesktopGroup(); -} - -KDesktopFile::~KDesktopFile() -{ - // no need to do anything -} - -TQString KDesktopFile::locateLocal(const TQString &path) -{ - TQString local; - if (path.endsWith(".directory")) - { - local = path; - if (!TQDir::isRelativePath(local)) - { - // Relative wrt apps? - local = KGlobal::dirs()->relativeLocation("apps", path); - } - - if (TQDir::isRelativePath(local)) - { - local = ::locateLocal("apps", local); // Relative to apps - } - else - { - // XDG Desktop menu items come with absolute paths, we need to - // extract their relative path and then build a local path. - local = KGlobal::dirs()->relativeLocation("xdgdata-dirs", local); - if (!TQDir::isRelativePath(local)) - { - // Hm, that didn't work... - // What now? Use filename only and hope for the best. - local = path.mid(path.findRev('/')+1); - } - local = ::locateLocal("xdgdata-dirs", local); - } - } - else - { - if (TQDir::isRelativePath(path)) - { - local = ::locateLocal("apps", path); // Relative to apps - } - else - { - // XDG Desktop menu items come with absolute paths, we need to - // extract their relative path and then build a local path. - local = KGlobal::dirs()->relativeLocation("xdgdata-apps", path); - if (!TQDir::isRelativePath(local)) - { - // What now? Use filename only and hope for the best. - local = path.mid(path.findRev('/')+1); - } - local = ::locateLocal("xdgdata-apps", local); - } - } - return local; -} - -bool KDesktopFile::isDesktopFile(const TQString& path) -{ - int len = path.length(); - - if(len > 8 && path.right(8) == TQString::tqfromLatin1(".desktop")) - return true; - else if(len > 7 && path.right(7) == TQString::tqfromLatin1(".kdelnk")) - return true; - else - return false; -} - -bool KDesktopFile::isAuthorizedDesktopFile(const TQString& path) -{ - if (!kapp || kapp->authorize("run_desktop_files")) - return true; - - if (path.isEmpty()) - return false; // Empty paths are not ok. - - if (TQDir::isRelativePath(path)) - return true; // Relative paths are ok. - - KStandardDirs *dirs = KGlobal::dirs(); - if (TQDir::isRelativePath( dirs->relativeLocation("apps", path) )) - return true; - if (TQDir::isRelativePath( dirs->relativeLocation("xdgdata-apps", path) )) - return true; - if (TQDir::isRelativePath( dirs->relativeLocation("services", path) )) - return true; - if (dirs->relativeLocation("data", path).startsWith("kdesktop/Desktop")) - return true; - - kdWarning() << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl; - return false; -} - -TQString KDesktopFile::translatedEntry(const char* key) const -{ - if (hasTranslatedKey(key)) - return readEntry(key); - - if (hasKey(key)) { - TQString value = readEntryUntranslated(key); - TQString fName = fileName(); - fName = fName.mid(fName.findRev('/')+1); - TQString po_lookup_key = TQString::tqfromLatin1(key) + "(" + fName + "): " + value; - TQString po_value = KGlobal::locale()->translate(po_lookup_key.utf8().data()); - - if (po_value == po_lookup_key) - return value; - - return po_value; - } - - return TQString::null; -} - -TQString KDesktopFile::readType() const -{ - return readEntry("Type"); -} - -TQString KDesktopFile::readIcon() const -{ - return readEntry("Icon"); -} - -TQString KDesktopFile::readName() const -{ - return translatedEntry("Name"); -} - -TQString KDesktopFile::readComment() const -{ - return translatedEntry("Comment"); -} - -TQString KDesktopFile::readGenericName() const -{ - return translatedEntry("GenericName"); -} - -TQString KDesktopFile::readPath() const -{ - return readPathEntry("Path"); -} - -TQString KDesktopFile::readDevice() const -{ - return readEntry("Dev"); -} - -TQString KDesktopFile::readURL() const -{ - if (hasDeviceType()) { - TQString device = readDevice(); - KMountPoint::List mountPoints = KMountPoint::possibleMountPoints(); - - for(KMountPoint::List::ConstIterator it = mountPoints.begin(); - it != mountPoints.end(); ++it) - { - KMountPoint *mp = *it; - if (mp->mountedFrom() == device) - { - KURL u; - u.setPath( mp->mountPoint() ); - return u.url(); - } - } - return TQString::null; - } else { - TQString url = readPathEntry("URL"); - if ( !url.isEmpty() && !TQDir::isRelativePath(url) ) - { - // Handle absolute paths as such (i.e. we need to escape them) - KURL u; - u.setPath( url ); - return u.url(); - } - return url; - } -} - -TQStringList KDesktopFile::readActions() const -{ - return readListEntry("Actions", ';'); -} - -void KDesktopFile::setActionGroup(const TQString &group) -{ - setGroup(TQString::tqfromLatin1("Desktop Action ") + group); -} - -bool KDesktopFile::hasActionGroup(const TQString &group) const -{ - return hasGroup(TQString::tqfromLatin1("Desktop Action ") + group); -} - -bool KDesktopFile::hasLinkType() const -{ - return readEntry("Type") == TQString::tqfromLatin1("Link"); -} - -bool KDesktopFile::hasApplicationType() const -{ - return readEntry("Type") == TQString::tqfromLatin1("Application"); -} - -bool KDesktopFile::hasMimeTypeType() const -{ - return readEntry("Type") == TQString::tqfromLatin1("MimeType"); -} - -bool KDesktopFile::hasDeviceType() const -{ - return readEntry("Type") == TQString::tqfromLatin1("FSDev") || - readEntry("Type") == TQString::tqfromLatin1("FSDevice"); -} - -bool KDesktopFile::tryExec() const -{ - // Test for TryExec and "X-KDE-AuthorizeAction" - TQString te = readPathEntry("TryExec"); - - if (!te.isEmpty()) { - if (!TQDir::isRelativePath(te)) { - if (::access(TQFile::encodeName(te), X_OK)) - return false; - } else { - // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!! - // Environment PATH may contain filenames in 8bit locale cpecified - // encoding (Like a filenames). - TQStringList dirs = TQStringList::split(':', TQFile::decodeName(::getenv("PATH"))); - TQStringList::Iterator it(dirs.begin()); - bool match = false; - for (; it != dirs.end(); ++it) { - TQString fName = *it + "/" + te; - if (::access(TQFile::encodeName(fName), X_OK) == 0) - { - match = true; - break; - } - } - // didn't match at all - if (!match) - return false; - } - } - TQStringList list = readListEntry("X-KDE-AuthorizeAction"); - if (kapp && !list.isEmpty()) - { - for(TQStringList::ConstIterator it = list.begin(); - it != list.end(); - ++it) - { - if (!kapp->authorize((*it).stripWhiteSpace())) - return false; - } - } - - // See also KService::username() - bool su = readBoolEntry("X-KDE-SubstituteUID"); - if (su) - { - TQString user = readEntry("X-KDE-Username"); - if (user.isEmpty()) - user = ::getenv("ADMIN_ACCOUNT"); - if (user.isEmpty()) - user = "root"; - if (!kapp->authorize("user/"+user)) - return false; - } - - return true; -} - -/** - * @return the filename as passed to the constructor. - */ -TQString -KDesktopFile::fileName() const { return backEnd->fileName(); } - -/** - * @return the resource type as passed to the constructor. - */ -TQString -KDesktopFile::resource() const { return backEnd->resource(); } - -TQStringList -KDesktopFile::sortOrder() const -{ - return readListEntry("SortOrder"); -} - -void KDesktopFile::virtual_hook( int id, void* data ) -{ KConfig::virtual_hook( id, data ); } - -TQString KDesktopFile::readDocPath() const -{ - // Depreciated, remove in KDE4 or 5? - // See: http://www.freedesktop.org/Standards/desktop-entry-spec - if(hasKey( "DocPath" )) - return readPathEntry( "DocPath" ); - - return readPathEntry( "X-DocPath" ); -} - -KDesktopFile* KDesktopFile::copyTo(const TQString &file) const -{ - KDesktopFile *config = new KDesktopFile(TQString::null, false); - KConfig::copyTo(file, config); - config->setDesktopGroup(); - return config; -} diff --git a/kdecore/kdesktopfile.h b/kdecore/kdesktopfile.h deleted file mode 100644 index bb705b696..000000000 --- a/kdecore/kdesktopfile.h +++ /dev/null @@ -1,253 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Pietro Iglio <iglio@kde.org> - - 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 _KDESKTOPFILE_H -#define _KDESKTOPFILE_H - -#include "kconfig.h" -#include "kdelibs_export.h" - -class KDesktopFilePrivate; - -/** - * KDE Desktop File Management. - * - * @author Pietro Iglio <iglio@kde.org> - * @see KConfigBase KConfig - * @short KDE Desktop File Management class - */ -class KDECORE_EXPORT KDesktopFile : public KConfig -{ - Q_OBJECT - -public: - /** - * Constructs a KDesktopFile object and make it either read-write - * or read-only. - * - * @param fileName The name or path of the desktop file. If it - * is not absolute, it will be located - * using the resource type @p resType. - * @param readOnly Whether the object should be read-only. - * @param resType Allows you to change what sort of resource - * to search for if @p fileName is not absolute. For - * instance, you might want to specify "config". - */ - KDesktopFile( const TQString &fileName, bool readOnly = false, - const char * resType = "apps"); - - /** - * Destructs the KDesktopFile object. - * - * Writes back any dirty configuration entries. - */ - virtual ~KDesktopFile(); - - /** - * Checks whether this is really a desktop file. - * - * The check is performed looking at the file extension (the file is not - * opened). - * Currently, valid extensions are ".kdelnk" and ".desktop". - * @param path the path of the file to check - * @return true if the file appears to be a desktop file. - */ - static bool isDesktopFile(const TQString& path); - - /** - * Checks whether the user is authorized to run this desktop file. - * By default users are authorized to run all desktop files but - * the KIOSK framework can be used to activate certain restrictions. - * See README.kiosk for more information. - * @param path the file to check - * @return true if the user is authorized to run the file - * @since 3.1 - */ - static bool isAuthorizedDesktopFile(const TQString& path); - - /** - * Returns the location where changes for the .desktop file @p path - * should be written to. - * @since 3.2 - */ - static TQString locateLocal(const TQString &path); - - /** - * Returns the value of the "Type=" entry. - * @return the type or TQString::null if not specified - */ - TQString readType() const; - - /** - * Returns the value of the "Icon=" entry. - * @return the icon or TQString::null if not specified - */ - TQString readIcon() const; - - /** - * Returns the value of the "Name=" entry. - * @return the name or TQString::null if not specified - */ - TQString readName() const; - - /** - * Returns the value of the "Comment=" entry. - * @return the comment or TQString::null if not specified - */ - TQString readComment() const; - - /** - * Returns the value of the "GenericName=" entry. - * @return the generic name or TQString::null if not specified - */ - TQString readGenericName() const; - - /** - * Returns the value of the "Path=" entry. - * @return the path or TQString::null if not specified - */ - TQString readPath() const; - - /** - * Returns the value of the "Dev=" entry. - * @return the device or TQString::null if not specified - */ - TQString readDevice() const; - - /** - * Returns the value of the "URL=" entry. - * @return the URL or TQString::null if not specified - */ - TQString readURL() const; - - /** - * Returns a list of the "Actions=" entries. - * @return the list of actions - */ - TQStringList readActions() const; - - /** - * Sets the desktop action group. - * @param group the new action group - */ - void setActionGroup(const TQString &group); - - /** - * Returns true if the action group exists, false otherwise - * @param group the action group to test - * @return true if the action group exists - */ - bool hasActionGroup(const TQString &group) const; - - /** - * Checks whether there is a "Type=Link" entry. - * - * The link points to the "URL=" entry. - * @return true if there is a "Type=Link" entry - */ - bool hasLinkType() const; - - /** - * Checks whether there is an entry "Type=Application". - * @return true if there is a "Type=Application" entry - */ - bool hasApplicationType() const; - - /** - * Checks whether there is an entry "Type=MimeType". - * @return true if there is a "Type=MimeType" entry - */ - bool hasMimeTypeType() const; // funny name :) - - /** - * Checks whether there is an entry "Type=FSDev". - * @return true if there is a "Type=FSDev" entry - */ - bool hasDeviceType() const; - - /** - * Checks whether the TryExec field contains a binary - * which is found on the local system. - * @return true if TryExec contains an existing binary - */ - bool tryExec() const; - - /** - * Returns the file name. - * @return The filename as passed to the constructor. - */ - TQString fileName() const; - - /** - * Returns the resource. - * @return The resource type as passed to the constructor. - */ - TQString resource() const; - - /** - * Returns the value of the "X-DocPath=" Or "DocPath=" entry. - * X-DocPath should be used and DocPath is depreciated and will - * one day be not supported. - * @return The value of the "X-DocPath=" Or "DocPath=" entry. - * @since 3.1 - */ - TQString readDocPath() const; - - /** - * Returns the entry of the "SortOrder=" entry. - * @return the value of the "SortOrder=" entry. - */ - TQStringList sortOrder() const; - - /** - * Copies all entries from this config object to a new - * KDesktopFile object that will save itself to @p file. - * - * Actual saving to @p file happens when the returned object is - * destructed or when sync() is called upon it. - * - * @param file the new KDesktopFile object it will save itself to. - * @since 3.2 - */ - KDesktopFile* copyTo(const TQString &file) const; - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated Use fileName() instead. - */ - KDE_DEPRECATED TQString filename() const { return fileName(); }; - -private: - - TQString translatedEntry(const char*) const; - - // copy-construction and assignment are not allowed - KDesktopFile( const KDesktopFile& ); - KDesktopFile& operator= ( const KDesktopFile& ); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KDesktopFilePrivate *d; -}; - - -#endif - diff --git a/kdecore/kdetcompmgr.cpp b/kdecore/kdetcompmgr.cpp deleted file mode 100644 index 9b78e3478..000000000 --- a/kdecore/kdetcompmgr.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 Timothy Pearson <kb9vqf@pearsoncomputing.net> * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * 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 General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> - -#include <kapplication.h> -#include <kaboutdata.h> -#include <kcmdlineargs.h> -#include <klocale.h> -#include <kdebug.h> -#include <kconfig.h> - -#include <pwd.h> -#include <signal.h> - -static const char description[] = - I18N_NOOP("TDE composition manager detection utility"); - -static const char version[] = "0.1"; - -static KCmdLineOptions options[] = -{ - KCmdLineLastOption -}; - -int main(int argc, char **argv) -{ - KAboutData about("kdetcompmgr", I18N_NOOP("kdetcompmgr"), version, description, - KAboutData::License_GPL, "(C) 2011 Timothy Pearson", 0, 0, "kb9vqf@pearsoncomputing.net"); - about.addAuthor( "Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net" ); - KCmdLineArgs::init(argc, argv, &about); - KCmdLineArgs::addCmdLineOptions( options ); - - KApplication app; - - KConfig config("kwinrc", true); - config.setGroup( "Notification Messages" ); - if (!config.readBoolEntry("UseTranslucency",false)) { - // Attempt to load the kompmgr pid file - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - char *filename; - const char *configfile = "/.kompmgr.pid"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); - - printf("reading '%s' as kompmgr pidfile\n\n", filename); - - // Now that we did all that by way of introduction...read the file! - FILE *pFile; - char buffer[255]; - pFile = fopen(filename, "r"); - int kompmgrpid = 0; - if (pFile) { - // obtain file size - fseek (pFile , 0 , SEEK_END); - unsigned long lSize = ftell (pFile); - if (lSize > 254) - lSize = 254; - rewind (pFile); - size_t result = fread (buffer, 1, lSize, pFile); - fclose(pFile); - kompmgrpid = atoi(buffer); - } - - free(filename); - filename = NULL; - - if (kompmgrpid) { - kill(kompmgrpid, SIGTERM); - } - } - -// app.detectCompositionManagerAvailable(); - -// if (!app.isCompositionManagerAvailable()) { - KConfig config2("kwinrc", true); - config2.setGroup( "Notification Messages" ); - if (config2.readBoolEntry("UseTranslucency",false)) { - app.detectCompositionManagerAvailable(true, true); - return 2; - } - else { - app.detectCompositionManagerAvailable(true, false); - return 0; - } -// } -} - diff --git a/kdecore/kdeversion.cpp b/kdecore/kdeversion.cpp deleted file mode 100644 index 807618244..000000000 --- a/kdecore/kdeversion.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2002 KDE Team - - 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. -*/ - -#include "kdeversion.h" - -unsigned int KDE::version() -{ - return KDE_VERSION; -} - -unsigned int KDE::versionMajor() -{ - return KDE_VERSION_MAJOR; -} - -unsigned int KDE::versionMinor() -{ - return KDE_VERSION_MINOR; -} - -unsigned int KDE::versionRelease() -{ - return KDE_VERSION_RELEASE; -} - -const char *KDE::versionString() -{ - return KDE_VERSION_STRING; -} - diff --git a/kdecore/kdeversion.h b/kdecore/kdeversion.h deleted file mode 100644 index 5f8c3dc8c..000000000 --- a/kdecore/kdeversion.h +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 2002-2005 KDE Team - - 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 _KDE_VERSION_H_ -#define _KDE_VERSION_H_ - -#include "kdelibs_export.h" - -#define KDE_VERSION_STRING "3.5.13" -#define KDE_VERSION_MAJOR 3 -#define KDE_VERSION_MINOR 5 -#define KDE_VERSION_RELEASE 13 -#define KDE_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c)) - -#define KDE_VERSION \ - KDE_MAKE_VERSION(KDE_VERSION_MAJOR,KDE_VERSION_MINOR,KDE_VERSION_RELEASE) - -#define KDE_IS_VERSION(a,b,c) ( KDE_VERSION >= KDE_MAKE_VERSION(a,b,c) ) - -/** - * Namespace for general KDE functions. - */ -namespace KDE -{ - /** - * Returns the encoded number of KDE's version, see the KDE_VERSION macro. - * In contrary to that macro this function returns the number of the actully - * installed KDE version, not the number of the KDE version that was - * installed when the program was compiled. - * @return the version number, encoded in a single uint - * @since 3.2 - */ - KDECORE_EXPORT unsigned int version(); - /** - * Returns the major number of KDE's version, e.g. - * 3 for KDE 3.1.2. - * @return the major version number - * @since 3.1 - */ - KDECORE_EXPORT unsigned int versionMajor(); - /** - * Returns the minor number of KDE's version, e.g. - * 1 for KDE 3.1.2. - * @return the minor version number - * @since 3.1 - */ - KDECORE_EXPORT unsigned int versionMinor(); - /** - * Returns the release of KDE's version, e.g. - * 2 for KDE 3.1.2. - * @return the release number - * @since 3.1 - */ - KDECORE_EXPORT unsigned int versionRelease(); - /** - * Returns the KDE version as string, e.g. "3.1.2". - * @return the KDE version. You can keep the string forever - * @since 3.1 - */ - KDECORE_EXPORT const char *versionString(); -} - -#endif // _KDE_VERSION_H_ diff --git a/kdecore/kentities.c b/kdecore/kentities.c deleted file mode 100644 index 8181e5a6c..000000000 --- a/kdecore/kentities.c +++ /dev/null @@ -1,837 +0,0 @@ -/* ANSI-C code produced by gperf version 3.0.1 */ -/* Command-line: gperf -a -L ANSI-C -E -C -c -o -t -k '*' -Nkde_findEntity -D -Hhash_Entity -Wwordlist_Entity -s 2 kentities.gperf */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." -#endif - -#line 1 "kentities.gperf" - -/* This file is part of the KDE libraries - - Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) - - 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. - - ---------------------------------------------------------------------------- - - 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" - from kentities.gperf - - $Id$ -*/ -#line 31 "kentities.gperf" -struct entity { - const char *name; - int code; -}; -/* maximum key range = 924, duplicates = 0 */ - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static unsigned int -hash_Entity (register const char *str, register unsigned int len) -{ - static const unsigned short asso_values[] = - { - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 0, - 145, 120, 0, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 125, 315, 35, 60, 325, - 5, 5, 0, 130, 932, 10, 0, 20, 110, 120, - 100, 0, 45, 40, 10, 135, 0, 932, 0, 15, - 50, 932, 932, 932, 932, 932, 932, 0, 15, 70, - 0, 20, 200, 250, 295, 10, 285, 5, 140, 90, - 15, 5, 65, 195, 5, 100, 25, 25, 130, 0, - 75, 190, 30, 35, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 932, 932, 932 - }; - register int hval = len; - - switch (hval) - { - default: - hval += asso_values[(unsigned char)str[7]]; - /*FALLTHROUGH*/ - case 7: - hval += asso_values[(unsigned char)str[6]]; - /*FALLTHROUGH*/ - case 6: - hval += asso_values[(unsigned char)str[5]]; - /*FALLTHROUGH*/ - case 5: - hval += asso_values[(unsigned char)str[4]]; - /*FALLTHROUGH*/ - case 4: - hval += asso_values[(unsigned char)str[3]]; - /*FALLTHROUGH*/ - case 3: - hval += asso_values[(unsigned char)str[2]]; - /*FALLTHROUGH*/ - case 2: - hval += asso_values[(unsigned char)str[1]+1]; - /*FALLTHROUGH*/ - case 1: - hval += asso_values[(unsigned char)str[0]]; - break; - } - return hval; -} - -#ifdef __GNUC__ -__inline -#endif -const struct entity * -kde_findEntity (register const char *str, register unsigned int len) -{ - enum - { - TOTAL_KEYWORDS = 280, - MIN_WORD_LENGTH = 2, - MAX_WORD_LENGTH = 8, - MIN_HASH_VALUE = 8, - MAX_HASH_VALUE = 931 - }; - - static const struct entity wordlist_Entity[] = - { -#line 116 "kentities.gperf" - {"and", 0x22a5}, -#line 264 "kentities.gperf" - {"rho", 0x03c1}, -#line 142 "kentities.gperf" - {"darr", 0x2193}, -#line 143 "kentities.gperf" - {"dcaron", 0x10f}, -#line 257 "kentities.gperf" - {"rarr", 0x2192}, -#line 258 "kentities.gperf" - {"rcaron", 0x0159}, -#line 95 "kentities.gperf" - {"Tcaron", 0x0164}, -#line 185 "kentities.gperf" - {"int", 0x222b}, -#line 214 "kentities.gperf" - {"ncaron", 0x0148}, -#line 161 "kentities.gperf" - {"eta", 0x03b7}, -#line 150 "kentities.gperf" - {"ecaron", 0x011b}, -#line 94 "kentities.gperf" - {"Tau", 0x03a4}, -#line 299 "kentities.gperf" - {"uarr", 0x2191}, -#line 288 "kentities.gperf" - {"tcaron", 0x0165}, -#line 48 "kentities.gperf" - {"Chi", 0x03a7}, -#line 312 "kentities.gperf" - {"zcaron", 0x017e}, -#line 90 "kentities.gperf" - {"Rho", 0x03a1}, -#line 188 "kentities.gperf" - {"isin", 0x2208}, -#line 293 "kentities.gperf" - {"thorn", 0x00fe}, -#line 46 "kentities.gperf" - {"Ccaron", 0x010c}, -#line 287 "kentities.gperf" - {"tau", 0x03c4}, -#line 96 "kentities.gperf" - {"Theta", 0x0398}, -#line 91 "kentities.gperf" - {"Scaron", 0x0160}, -#line 110 "kentities.gperf" - {"acute", 0x00b4}, -#line 89 "kentities.gperf" - {"Rcaron", 0x0158}, -#line 106 "kentities.gperf" - {"Zcaron", 0x017d}, -#line 115 "kentities.gperf" - {"amp", 38}, -#line 220 "kentities.gperf" - {"nsub", 0x2284}, -#line 290 "kentities.gperf" - {"theta", 0x03b8}, -#line 289 "kentities.gperf" - {"there4", 0x2234}, -#line 243 "kentities.gperf" - {"phi", 0x03c6}, -#line 238 "kentities.gperf" - {"para", 0x00b6}, -#line 109 "kentities.gperf" - {"acirc", 0x00e2}, -#line 50 "kentities.gperf" - {"Dcaron", 0x010e}, -#line 132 "kentities.gperf" - {"chi", 0x03c7}, -#line 224 "kentities.gperf" - {"ocirc", 0x00f4}, -#line 180 "kentities.gperf" - {"icirc", 0x00ee}, -#line 128 "kentities.gperf" - {"ccaron", 0x010d}, -#line 251 "kentities.gperf" - {"psi", 0x03c8}, -#line 186 "kentities.gperf" - {"iota", 0x03b9}, -#line 254 "kentities.gperf" - {"radic", 0x221a}, -#line 231 "kentities.gperf" - {"or", 0x22a6}, -#line 218 "kentities.gperf" - {"not", 0x00ac}, -#line 152 "kentities.gperf" - {"ecirc", 0x00ea}, -#line 239 "kentities.gperf" - {"part", 0x2202}, -#line 300 "kentities.gperf" - {"ucirc", 0x00fb}, -#line 84 "kentities.gperf" - {"Phi", 0x03a6}, -#line 69 "kentities.gperf" - {"Lambda", 0x039b}, -#line 269 "kentities.gperf" - {"scaron", 0x0161}, -#line 229 "kentities.gperf" - {"omicron", 0x03bf}, -#line 88 "kentities.gperf" - {"QUOT", 34}, -#line 219 "kentities.gperf" - {"notin", 0x2209}, -#line 70 "kentities.gperf" - {"LT", 60}, -#line 87 "kentities.gperf" - {"Psi", 0x03a8}, -#line 72 "kentities.gperf" - {"Ncaron", 0x0147}, -#line 62 "kentities.gperf" - {"GT", 62}, -#line 227 "kentities.gperf" - {"oline", 0x203e}, -#line 222 "kentities.gperf" - {"nu", 0x03bd}, -#line 296 "kentities.gperf" - {"trade", 0x2122}, -#line 71 "kentities.gperf" - {"Mu", 0x039c}, -#line 127 "kentities.gperf" - {"cap", 0x2229}, -#line 270 "kentities.gperf" - {"sdot", 0x22c5}, -#line 190 "kentities.gperf" - {"kappa", 0x03ba}, -#line 68 "kentities.gperf" - {"Kappa", 0x039a}, -#line 108 "kentities.gperf" - {"aacute", 0x00e1}, -#line 164 "kentities.gperf" - {"euro", 0x20ac}, -#line 223 "kentities.gperf" - {"oacute", 0x00f3}, -#line 205 "kentities.gperf" - {"lt", 60}, -#line 195 "kentities.gperf" - {"larr", 0x2190}, -#line 179 "kentities.gperf" - {"iacute", 0x00ed}, -#line 249 "kentities.gperf" - {"prod", 0x220f}, -#line 247 "kentities.gperf" - {"pound", 0x00a3}, -#line 104 "kentities.gperf" - {"Yacute", 0x00dd}, -#line 259 "kentities.gperf" - {"rceil", 0x2309}, -#line 149 "kentities.gperf" - {"eacute", 0x00e9}, -#line 302 "kentities.gperf" - {"uml", 0x00a8}, -#line 206 "kentities.gperf" - {"macr", 0x00af}, -#line 137 "kentities.gperf" - {"crarr", 0x21b5}, -#line 298 "kentities.gperf" - {"uacute", 0x00fa}, -#line 265 "kentities.gperf" - {"rlm", 0x200f}, -#line 212 "kentities.gperf" - {"nabla", 0x2207}, -#line 187 "kentities.gperf" - {"iquest", 0x00bf}, -#line 158 "kentities.gperf" - {"ensp", 0x2002}, -#line 160 "kentities.gperf" - {"equiv", 0x2261}, -#line 233 "kentities.gperf" - {"ordm", 0x00ba}, -#line 121 "kentities.gperf" - {"atilde", 0x00e3}, -#line 156 "kentities.gperf" - {"emsp", 0x2003}, -#line 61 "kentities.gperf" - {"Gamma", 0x0393}, -#line 235 "kentities.gperf" - {"otilde", 0x00f5}, -#line 148 "kentities.gperf" - {"dol", 0x0024}, -#line 77 "kentities.gperf" - {"Ocirc", 0x00d4}, -#line 47 "kentities.gperf" - {"Ccedil", 0x00c7}, -#line 38 "kentities.gperf" - {"Acirc", 0x00c2}, -#line 221 "kentities.gperf" - {"ntilde", 0x00f1}, -#line 216 "kentities.gperf" - {"ne", 0x2260}, -#line 64 "kentities.gperf" - {"Icirc", 0x00ce}, -#line 211 "kentities.gperf" - {"mu", 0x03bc}, -#line 66 "kentities.gperf" - {"Iota", 0x0399}, -#line 98 "kentities.gperf" - {"Ucirc", 0x00db}, -#line 292 "kentities.gperf" - {"thinsp", 0x2009}, -#line 201 "kentities.gperf" - {"loz", 0x25ca}, -#line 250 "kentities.gperf" - {"prop", 0x221d}, -#line 74 "kentities.gperf" - {"Nu", 0x039d}, -#line 124 "kentities.gperf" - {"beta", 0x03b2}, -#line 184 "kentities.gperf" - {"infin", 0x221e}, -#line 129 "kentities.gperf" - {"ccedil", 0x00e7}, -#line 80 "kentities.gperf" - {"Omicron", 0x039f}, -#line 277 "kentities.gperf" - {"sub", 0x2282}, -#line 256 "kentities.gperf" - {"raquo", 0x00bb}, -#line 139 "kentities.gperf" - {"curren", 0x00a4}, -#line 213 "kentities.gperf" - {"nbsp", 0x00a0}, -#line 260 "kentities.gperf" - {"rdquo", 0x201d}, -#line 236 "kentities.gperf" - {"otimes", 0x2297}, -#line 117 "kentities.gperf" - {"ang", 0x2220}, -#line 313 "kentities.gperf" - {"zeta", 0x03b6}, -#line 267 "kentities.gperf" - {"rsquo", 0x2019}, -#line 266 "kentities.gperf" - {"rsaquo", 0x203a}, -#line 123 "kentities.gperf" - {"bdquo", 0x201e}, -#line 192 "kentities.gperf" - {"lambda", 0x03bb}, -#line 138 "kentities.gperf" - {"cup", 0x222a}, -#line 278 "kentities.gperf" - {"sube", 0x2286}, -#line 125 "kentities.gperf" - {"brvbar", 0x00a6}, -#line 174 "kentities.gperf" - {"gt", 62}, -#line 107 "kentities.gperf" - {"Zeta", 0x0396}, -#line 76 "kentities.gperf" - {"Oacute", 0x00d3}, -#line 37 "kentities.gperf" - {"Aacute", 0x00c1}, -#line 103 "kentities.gperf" - {"Xi", 0x039e}, -#line 255 "kentities.gperf" - {"rang", 0x232a}, -#line 248 "kentities.gperf" - {"prime", 0x2032}, -#line 63 "kentities.gperf" - {"Iacute", 0x00cd}, -#line 228 "kentities.gperf" - {"omega", 0x03c9}, -#line 97 "kentities.gperf" - {"Uacute", 0x00da}, -#line 284 "kentities.gperf" - {"sup", 0x2283}, -#line 280 "kentities.gperf" - {"sup1", 0x00b9}, -#line 183 "kentities.gperf" - {"image", 0x2111}, -#line 217 "kentities.gperf" - {"ni", 0x220b}, -#line 272 "kentities.gperf" - {"shy", 0x00ad}, -#line 118 "kentities.gperf" - {"apos", 0x0027}, -#line 134 "kentities.gperf" - {"clubs", 0x2663}, -#line 307 "kentities.gperf" - {"weierp", 0x2118}, -#line 232 "kentities.gperf" - {"ordf", 0x00aa}, -#line 73 "kentities.gperf" - {"Ntilde", 0x00d1}, -#line 131 "kentities.gperf" - {"cent", 0x00a2}, -#line 196 "kentities.gperf" - {"lceil", 0x2308}, -#line 285 "kentities.gperf" - {"supe", 0x2287}, -#line 155 "kentities.gperf" - {"empty", 0x2205}, -#line 82 "kentities.gperf" - {"Otilde", 0x00d5}, -#line 279 "kentities.gperf" - {"sum", 0x2211}, -#line 176 "kentities.gperf" - {"harr", 0x2194}, -#line 86 "kentities.gperf" - {"Prime", 0x2033}, -#line 43 "kentities.gperf" - {"Atilde", 0x00c3}, -#line 140 "kentities.gperf" - {"dArr", 0x21d3}, -#line 202 "kentities.gperf" - {"lrm", 0x200e}, -#line 253 "kentities.gperf" - {"rArr", 0x21d2}, -#line 151 "kentities.gperf" - {"eague", 0x00e9}, -#line 200 "kentities.gperf" - {"lowast", 0x2217}, -#line 41 "kentities.gperf" - {"AMP", 38}, -#line 242 "kentities.gperf" - {"perp", 0x22a5}, -#line 198 "kentities.gperf" - {"le", 0x2264}, -#line 162 "kentities.gperf" - {"eth", 0x00f0}, -#line 261 "kentities.gperf" - {"real", 0x211c}, -#line 165 "kentities.gperf" - {"exist", 0x2203}, -#line 309 "kentities.gperf" - {"yacute", 0x00fd}, -#line 244 "kentities.gperf" - {"pi", 0x03c0}, -#line 59 "kentities.gperf" - {"Eta", 0x0397}, -#line 297 "kentities.gperf" - {"uArr", 0x21d1}, -#line 54 "kentities.gperf" - {"Ecaron", 0x011a}, -#line 252 "kentities.gperf" - {"quot", 34}, -#line 308 "kentities.gperf" - {"xi", 0x03be}, -#line 122 "kentities.gperf" - {"auml", 0x00e4}, -#line 237 "kentities.gperf" - {"ouml", 0x00f6}, -#line 145 "kentities.gperf" - {"delta", 0x03b4}, -#line 189 "kentities.gperf" - {"iuml", 0x00ef}, -#line 120 "kentities.gperf" - {"asymp", 0x2248}, -#line 169 "kentities.gperf" - {"frac14", 0x00bc}, -#line 105 "kentities.gperf" - {"Yuml", 0x0178}, -#line 119 "kentities.gperf" - {"aring", 0x00e5}, -#line 163 "kentities.gperf" - {"euml", 0x00eb}, -#line 194 "kentities.gperf" - {"laquo", 0x00ab}, -#line 240 "kentities.gperf" - {"percnt", 0x0025}, -#line 85 "kentities.gperf" - {"Pi", 0x03a0}, -#line 306 "kentities.gperf" - {"uuml", 0x00fc}, -#line 197 "kentities.gperf" - {"ldquo", 0x201c}, -#line 246 "kentities.gperf" - {"plusmn", 0x00b1}, -#line 314 "kentities.gperf" - {"zwj", 0x200d}, -#line 136 "kentities.gperf" - {"copy", 0x00a9}, -#line 204 "kentities.gperf" - {"lsquo", 0x2018}, -#line 203 "kentities.gperf" - {"lsaquo", 0x2039}, -#line 271 "kentities.gperf" - {"sect", 0x00a7}, -#line 268 "kentities.gperf" - {"sbquo", 0x201a}, -#line 135 "kentities.gperf" - {"cong", 0x2245}, -#line 305 "kentities.gperf" - {"uring", 0x016f}, -#line 310 "kentities.gperf" - {"yen", 0x00a5}, -#line 315 "kentities.gperf" - {"zwnj", 0x200c}, -#line 79 "kentities.gperf" - {"Omega", 0x03a9}, -#line 209 "kentities.gperf" - {"middot", 0x00b7}, -#line 166 "kentities.gperf" - {"fnof", 0x0192}, -#line 55 "kentities.gperf" - {"Ecirc", 0x00ca}, -#line 263 "kentities.gperf" - {"rfloor", 0x230b}, -#line 283 "kentities.gperf" - {"sup3", 0x00b3}, -#line 93 "kentities.gperf" - {"THORN", 0x00de}, -#line 276 "kentities.gperf" - {"spades", 0x2660}, -#line 193 "kentities.gperf" - {"lang", 0x2329}, -#line 130 "kentities.gperf" - {"cedil", 0x00b8}, -#line 157 "kentities.gperf" - {"endash", 0x2013}, -#line 126 "kentities.gperf" - {"bull", 0x2022}, -#line 51 "kentities.gperf" - {"Delta", 0x0394}, -#line 133 "kentities.gperf" - {"circ", 0x02c6}, -#line 215 "kentities.gperf" - {"ndash", 0x2013}, -#line 154 "kentities.gperf" - {"emdash", 0x2014}, -#line 281 "kentities.gperf" - {"supl", 0x00b9}, -#line 282 "kentities.gperf" - {"sup2", 0x00b2}, -#line 172 "kentities.gperf" - {"gamma", 0x03b3}, -#line 147 "kentities.gperf" - {"divide", 0x00f7}, -#line 173 "kentities.gperf" - {"ge", 0x2265}, -#line 144 "kentities.gperf" - {"deg", 0x00b0}, -#line 114 "kentities.gperf" - {"alpha", 0x03b1}, -#line 112 "kentities.gperf" - {"agrave", 0x00e0}, -#line 262 "kentities.gperf" - {"reg", 0x00ae}, -#line 208 "kentities.gperf" - {"micro", 0x00b5}, -#line 226 "kentities.gperf" - {"ograve", 0x00f2}, -#line 52 "kentities.gperf" - {"ETH", 0x00d0}, -#line 182 "kentities.gperf" - {"igrave", 0x00ec}, -#line 291 "kentities.gperf" - {"thetasym", 0x03d1}, -#line 191 "kentities.gperf" - {"lArr", 0x21d0}, -#line 230 "kentities.gperf" - {"oplus", 0x2295}, -#line 294 "kentities.gperf" - {"tilde", 0x02dc}, -#line 153 "kentities.gperf" - {"egrave", 0x00e8}, -#line 275 "kentities.gperf" - {"sim", 0x223c}, -#line 146 "kentities.gperf" - {"diams", 0x2666}, -#line 301 "kentities.gperf" - {"ugrave", 0x00f9}, -#line 245 "kentities.gperf" - {"piv", 0x03d6}, -#line 83 "kentities.gperf" - {"Ouml", 0x00d6}, -#line 53 "kentities.gperf" - {"Eacute", 0x00c9}, -#line 44 "kentities.gperf" - {"Auml", 0x00c4}, -#line 159 "kentities.gperf" - {"epsilon", 0x03b5}, -#line 67 "kentities.gperf" - {"Iuml", 0x00cf}, -#line 170 "kentities.gperf" - {"frac34", 0x00be}, -#line 304 "kentities.gperf" - {"upsilon", 0x03c5}, -#line 102 "kentities.gperf" - {"Uuml", 0x00dc}, -#line 181 "kentities.gperf" - {"iexcl", 0x00a1}, -#line 42 "kentities.gperf" - {"Aring", 0x00c5}, -#line 207 "kentities.gperf" - {"mdash", 0x2014}, -#line 101 "kentities.gperf" - {"Uring", 0x016e}, -#line 241 "kentities.gperf" - {"permil", 0x2030}, -#line 210 "kentities.gperf" - {"minus", 0x2212}, -#line 168 "kentities.gperf" - {"frac12", 0x00bd}, -#line 295 "kentities.gperf" - {"times", 0x00d7}, -#line 75 "kentities.gperf" - {"OElig", 0x0152}, -#line 36 "kentities.gperf" - {"AElig", 0x00c6}, -#line 286 "kentities.gperf" - {"szlig", 0x00df}, -#line 45 "kentities.gperf" - {"Beta", 0x0392}, -#line 171 "kentities.gperf" - {"frasl", 0x2044}, -#line 141 "kentities.gperf" - {"dagger", 0x2020}, -#line 199 "kentities.gperf" - {"lfloor", 0x230a}, -#line 311 "kentities.gperf" - {"yuml", 0x00ff}, -#line 167 "kentities.gperf" - {"forall", 0x2200}, -#line 234 "kentities.gperf" - {"oslash", 0x00f8}, -#line 78 "kentities.gperf" - {"Ograve", 0x00d2}, -#line 40 "kentities.gperf" - {"Alpha", 0x0391}, -#line 39 "kentities.gperf" - {"Agrave", 0x00c0}, -#line 65 "kentities.gperf" - {"Igrave", 0x00cc}, -#line 99 "kentities.gperf" - {"Ugrave", 0x00d9}, -#line 111 "kentities.gperf" - {"aelig", 0x00e6}, -#line 49 "kentities.gperf" - {"Dagger", 0x2021}, -#line 100 "kentities.gperf" - {"Upsilon", 0x03a5}, -#line 225 "kentities.gperf" - {"oelig", 0x0153}, -#line 175 "kentities.gperf" - {"hArr", 0x21d4}, -#line 303 "kentities.gperf" - {"upsih", 0x03d2}, -#line 177 "kentities.gperf" - {"hearts", 0x2665}, -#line 57 "kentities.gperf" - {"Eague", 0x00c9}, -#line 92 "kentities.gperf" - {"Sigma", 0x03a3}, -#line 81 "kentities.gperf" - {"Oslash", 0x00d8}, -#line 60 "kentities.gperf" - {"Euml", 0x00cb}, -#line 113 "kentities.gperf" - {"alefsym", 0x2135}, -#line 273 "kentities.gperf" - {"sigma", 0x03c3}, -#line 56 "kentities.gperf" - {"Egrave", 0x00c8}, -#line 58 "kentities.gperf" - {"Epsilon", 0x0395}, -#line 178 "kentities.gperf" - {"hellip", 0x2026}, -#line 274 "kentities.gperf" - {"sigmaf", 0x03c2} - }; - - static const short lookup[] = - { - -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 1, -1, -1, -1, -1, -1, 2, - -1, 3, -1, -1, 4, -1, 5, -1, -1, -1, - -1, 6, -1, 7, -1, -1, 8, -1, 9, -1, - -1, 10, -1, 11, 12, -1, 13, -1, 14, -1, - -1, 15, -1, 16, 17, 18, 19, -1, 20, -1, - 21, 22, -1, -1, -1, 23, 24, -1, -1, -1, - -1, 25, -1, 26, 27, 28, 29, -1, 30, 31, - 32, 33, -1, 34, -1, 35, -1, -1, -1, -1, - 36, 37, -1, 38, 39, 40, -1, 41, 42, -1, - 43, -1, -1, -1, 44, 45, -1, -1, -1, -1, - -1, -1, -1, 46, -1, -1, 47, -1, -1, -1, - -1, 48, 49, -1, 50, 51, -1, 52, 53, -1, - -1, 54, 55, -1, -1, 56, -1, 57, -1, -1, - 58, -1, 59, 60, 61, 62, -1, -1, -1, -1, - 63, 64, -1, -1, 65, -1, 66, 67, -1, 68, - -1, 69, -1, -1, 70, 71, 72, -1, -1, -1, - 73, 74, -1, 75, 76, 77, 78, -1, 79, -1, - 80, 81, -1, -1, 82, 83, -1, -1, -1, 84, - -1, 85, -1, -1, 86, 87, 88, -1, 89, -1, - 90, 91, -1, -1, -1, 92, 93, 94, -1, -1, - 95, -1, 96, -1, 97, 98, -1, -1, -1, -1, - -1, 99, -1, -1, -1, -1, -1, -1, 100, 101, - -1, -1, 102, -1, 103, 104, 105, 106, 107, -1, - 108, 109, -1, -1, 110, 111, 112, -1, 113, 114, - 115, 116, -1, -1, -1, 117, 118, -1, 119, 120, - -1, 121, -1, -1, -1, -1, -1, 122, -1, 123, - -1, 124, -1, -1, -1, -1, 125, 126, -1, 127, - 128, 129, -1, -1, -1, 130, 131, -1, 132, 133, - 134, -1, 135, 136, 137, 138, 139, -1, -1, 140, - -1, 141, -1, -1, 142, 143, -1, -1, -1, 144, - 145, 146, -1, 147, 148, 149, 150, -1, -1, 151, - -1, -1, -1, 152, 153, 154, 155, -1, 156, 157, - -1, -1, 158, 159, -1, -1, -1, -1, -1, 160, - 161, 162, 163, 164, 165, -1, 166, -1, -1, 167, - -1, -1, 168, -1, 169, -1, -1, -1, -1, 170, - 171, -1, -1, -1, 172, 173, 174, -1, -1, 175, - 176, -1, -1, -1, 177, 178, 179, 180, -1, 181, - 182, 183, -1, 184, 185, 186, 187, -1, -1, 188, - 189, -1, -1, -1, 190, 191, -1, -1, 192, 193, - 194, 195, -1, -1, 196, 197, 198, -1, -1, 199, - 200, 201, -1, -1, 202, 203, 204, -1, -1, 205, - 206, -1, -1, -1, 207, 208, 209, -1, -1, 210, - -1, -1, -1, -1, 211, -1, -1, -1, -1, -1, - 212, 213, 214, 215, -1, 216, 217, -1, 218, -1, - 219, 220, -1, 221, -1, -1, 222, -1, 223, 224, - 225, -1, -1, -1, -1, 226, 227, -1, 228, -1, - 229, 230, -1, 231, 232, -1, 233, -1, -1, 234, - -1, -1, 235, -1, 236, -1, 237, 238, -1, 239, - 240, -1, -1, -1, -1, 241, -1, -1, -1, -1, - 242, -1, -1, -1, -1, 243, 244, -1, -1, -1, - 245, 246, -1, -1, -1, 247, -1, -1, -1, -1, - 248, -1, -1, -1, -1, 249, -1, -1, -1, -1, - 250, -1, -1, -1, 251, 252, 253, -1, -1, -1, - -1, 254, -1, -1, 255, -1, 256, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 257, -1, -1, -1, -1, 258, -1, -1, -1, - 259, 260, -1, -1, -1, -1, 261, -1, -1, -1, - -1, 262, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 263, 264, 265, -1, -1, - 266, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 267, -1, -1, -1, -1, -1, - 268, 269, -1, -1, -1, -1, -1, -1, -1, -1, - 270, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 271, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 272, -1, -1, 273, - -1, -1, -1, -1, -1, -1, -1, 274, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 275, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 276, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 277, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 278, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 279 - }; - - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - register int key = hash_Entity (str, len); - - if (key <= MAX_HASH_VALUE && key >= 0) - { - register int index = lookup[key]; - - if (index >= 0) - { - register const char *s = wordlist_Entity[index].name; - - if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') - return &wordlist_Entity[index]; - } - } - } - return 0; -} -#line 316 "kentities.gperf" - - diff --git a/kdecore/kentities.gperf b/kdecore/kentities.gperf deleted file mode 100644 index 08f712707..000000000 --- a/kdecore/kentities.gperf +++ /dev/null @@ -1,317 +0,0 @@ -%{ -/* This file is part of the KDE libraries - - Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) - - 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. - - ---------------------------------------------------------------------------- - - 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" - from kentities.gperf - - $Id$ -*/ -%} -struct entity { - const char *name; - int code; -}; -%% -AElig, 0x00c6 -Aacute, 0x00c1 -Acirc, 0x00c2 -Agrave, 0x00c0 -Alpha, 0x0391 -AMP, 38 -Aring, 0x00c5 -Atilde, 0x00c3 -Auml, 0x00c4 -Beta, 0x0392 -Ccaron, 0x010c -Ccedil, 0x00c7 -Chi, 0x03a7 -Dagger, 0x2021 -Dcaron, 0x010e -Delta, 0x0394 -ETH, 0x00d0 -Eacute, 0x00c9 -Ecaron, 0x011a -Ecirc, 0x00ca -Egrave, 0x00c8 -Eague, 0x00c9 -Epsilon, 0x0395 -Eta, 0x0397 -Euml, 0x00cb -Gamma, 0x0393 -GT, 62 -Iacute, 0x00cd -Icirc, 0x00ce -Igrave, 0x00cc -Iota, 0x0399 -Iuml, 0x00cf -Kappa, 0x039a -Lambda, 0x039b -LT, 60 -Mu, 0x039c -Ncaron, 0x0147 -Ntilde, 0x00d1 -Nu, 0x039d -OElig, 0x0152 -Oacute, 0x00d3 -Ocirc, 0x00d4 -Ograve, 0x00d2 -Omega, 0x03a9 -Omicron, 0x039f -Oslash, 0x00d8 -Otilde, 0x00d5 -Ouml, 0x00d6 -Phi, 0x03a6 -Pi, 0x03a0 -Prime, 0x2033 -Psi, 0x03a8 -QUOT, 34 -Rcaron, 0x0158 -Rho, 0x03a1 -Scaron, 0x0160 -Sigma, 0x03a3 -THORN, 0x00de -Tau, 0x03a4 -Tcaron, 0x0164 -Theta, 0x0398 -Uacute, 0x00da -Ucirc, 0x00db -Ugrave, 0x00d9 -Upsilon, 0x03a5 -Uring, 0x016e -Uuml, 0x00dc -Xi, 0x039e -Yacute, 0x00dd -Yuml, 0x0178 -Zcaron, 0x017d -Zeta, 0x0396 -aacute, 0x00e1 -acirc, 0x00e2 -acute, 0x00b4 -aelig, 0x00e6 -agrave, 0x00e0 -alefsym, 0x2135 -alpha, 0x03b1 -amp, 38 -and, 0x22a5 -ang, 0x2220 -apos, 0x0027 -aring, 0x00e5 -asymp, 0x2248 -atilde, 0x00e3 -auml, 0x00e4 -bdquo, 0x201e -beta, 0x03b2 -brvbar, 0x00a6 -bull, 0x2022 -cap, 0x2229 -ccaron, 0x010d -ccedil, 0x00e7 -cedil, 0x00b8 -cent, 0x00a2 -chi, 0x03c7 -circ, 0x02c6 -clubs, 0x2663 -cong, 0x2245 -copy, 0x00a9 -crarr, 0x21b5 -cup, 0x222a -curren, 0x00a4 -dArr, 0x21d3 -dagger, 0x2020 -darr, 0x2193 -dcaron, 0x10f -deg, 0x00b0 -delta, 0x03b4 -diams, 0x2666 -divide, 0x00f7 -dol, 0x0024 -eacute, 0x00e9 -ecaron, 0x011b -eague, 0x00e9 -ecirc, 0x00ea -egrave, 0x00e8 -emdash, 0x2014 -empty, 0x2205 -emsp, 0x2003 -endash, 0x2013 -ensp, 0x2002 -epsilon, 0x03b5 -equiv, 0x2261 -eta, 0x03b7 -eth, 0x00f0 -euml, 0x00eb -euro, 0x20ac -exist, 0x2203 -fnof, 0x0192 -forall, 0x2200 -frac12, 0x00bd -frac14, 0x00bc -frac34, 0x00be -frasl, 0x2044 -gamma, 0x03b3 -ge, 0x2265 -gt, 62 -hArr, 0x21d4 -harr, 0x2194 -hearts, 0x2665 -hellip, 0x2026 -iacute, 0x00ed -icirc, 0x00ee -iexcl, 0x00a1 -igrave, 0x00ec -image, 0x2111 -infin, 0x221e -int, 0x222b -iota, 0x03b9 -iquest, 0x00bf -isin, 0x2208 -iuml, 0x00ef -kappa, 0x03ba -lArr, 0x21d0 -lambda, 0x03bb -lang, 0x2329 -laquo, 0x00ab -larr, 0x2190 -lceil, 0x2308 -ldquo, 0x201c -le, 0x2264 -lfloor, 0x230a -lowast, 0x2217 -loz, 0x25ca -lrm, 0x200e -lsaquo, 0x2039 -lsquo, 0x2018 -lt, 60 -macr, 0x00af -mdash, 0x2014 -micro, 0x00b5 -middot, 0x00b7 -minus, 0x2212 -mu, 0x03bc -nabla, 0x2207 -nbsp, 0x00a0 -ncaron, 0x0148 -ndash, 0x2013 -ne, 0x2260 -ni, 0x220b -not, 0x00ac -notin, 0x2209 -nsub, 0x2284 -ntilde, 0x00f1 -nu, 0x03bd -oacute, 0x00f3 -ocirc, 0x00f4 -oelig, 0x0153 -ograve, 0x00f2 -oline, 0x203e -omega, 0x03c9 -omicron, 0x03bf -oplus, 0x2295 -or, 0x22a6 -ordf, 0x00aa -ordm, 0x00ba -oslash, 0x00f8 -otilde, 0x00f5 -otimes, 0x2297 -ouml, 0x00f6 -para, 0x00b6 -part, 0x2202 -percnt, 0x0025 -permil, 0x2030 -perp, 0x22a5 -phi, 0x03c6 -pi, 0x03c0 -piv, 0x03d6 -plusmn, 0x00b1 -pound, 0x00a3 -prime, 0x2032 -prod, 0x220f -prop, 0x221d -psi, 0x03c8 -quot, 34 -rArr, 0x21d2 -radic, 0x221a -rang, 0x232a -raquo, 0x00bb -rarr, 0x2192 -rcaron, 0x0159 -rceil, 0x2309 -rdquo, 0x201d -real, 0x211c -reg, 0x00ae -rfloor, 0x230b -rho, 0x03c1 -rlm, 0x200f -rsaquo, 0x203a -rsquo, 0x2019 -sbquo, 0x201a -scaron, 0x0161 -sdot, 0x22c5 -sect, 0x00a7 -shy, 0x00ad -sigma, 0x03c3 -sigmaf, 0x03c2 -sim, 0x223c -spades, 0x2660 -sub, 0x2282 -sube, 0x2286 -sum, 0x2211 -sup1, 0x00b9 -supl, 0x00b9 -sup2, 0x00b2 -sup3, 0x00b3 -sup, 0x2283 -supe, 0x2287 -szlig, 0x00df -tau, 0x03c4 -tcaron, 0x0165 -there4, 0x2234 -theta, 0x03b8 -thetasym, 0x03d1 -thinsp, 0x2009 -thorn, 0x00fe -tilde, 0x02dc -times, 0x00d7 -trade, 0x2122 -uArr, 0x21d1 -uacute, 0x00fa -uarr, 0x2191 -ucirc, 0x00fb -ugrave, 0x00f9 -uml, 0x00a8 -upsih, 0x03d2 -upsilon, 0x03c5 -uring, 0x016f -uuml, 0x00fc -weierp, 0x2118 -xi, 0x03be -yacute, 0x00fd -yen, 0x00a5 -yuml, 0x00ff -zcaron, 0x017e -zeta, 0x03b6 -zwj, 0x200d -zwnj, 0x200c -%% - diff --git a/kdecore/kextendedsocket.h b/kdecore/kextendedsocket.h deleted file mode 100644 index b90b999d1..000000000 --- a/kdecore/kextendedsocket.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef KEXTENDEDSOCKET_H -#define KEXTENDEDSOCKET_H -#include "kextsock.h" -#endif diff --git a/kdecore/kextsock.cpp b/kdecore/kextsock.cpp deleted file mode 100644 index 5aad239bd..000000000 --- a/kdecore/kextsock.cpp +++ /dev/null @@ -1,2251 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000-2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - **/ - -#include <config.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/times.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/un.h> - -#include <stdio.h> -#include <errno.h> -#include <fcntl.h> - -#include <netdb.h> - -#include <stdlib.h> -#include <unistd.h> - -#include <tqglobal.h> -#include <tqstring.h> -#include <tqiodevice.h> -#include <tqsocketnotifier.h> -#include <tqguardedptr.h> - -#include "kresolver.h" - -#include "kdebug.h" -#include "kextsock.h" -#include "ksockaddr.h" -#include "ksocks.h" - -#ifdef __CYGWIN__ -#include "netsupp.h" -#endif - -using namespace KNetwork; - -// -// Internal class definitions -// - -class KExtendedSocketPrivate -{ -public: - int flags; // socket flags - int status; // status - int syserror; // the system error value - - timeval timeout; // connection/acception timeout - - KResolver resRemote; // the resolved addresses - KResolver resLocal; // binding resolution - unsigned current; // used by the asynchronous connection - - ::KSocketAddress *local; // local socket address - ::KSocketAddress *peer; // peer socket address - - TQSocketNotifier *qsnIn, *qsnOut; - int inMaxSize, outMaxSize; - bool emitRead : 1, emitWrite : 1; - mutable bool addressReusable : 1, ipv6only : 1; - - KExtendedSocketPrivate() : - flags(0), status(0), syserror(0), - current(0), local(0), peer(0), - qsnIn(0), qsnOut(0), inMaxSize(-1), outMaxSize(-1), emitRead(false), emitWrite(false), - addressReusable(false), ipv6only(false) - { - timeout.tv_sec = timeout.tv_usec = 0; - } -}; - -// translate KExtendedSocket flags into KResolver ones -static bool process_flags(int flags, int& socktype, int& familyMask, int& outflags) -{ - switch (flags & (KExtendedSocket::streamSocket | KExtendedSocket::datagramSocket | KExtendedSocket::rawSocket)) - { - case 0: - /* No flags given, use default */ - - case KExtendedSocket::streamSocket: - /* streaming socket requested */ - socktype = SOCK_STREAM; - break; - - case KExtendedSocket::datagramSocket: - /* datagram packet socket requested */ - socktype = SOCK_DGRAM; - break; - - case KExtendedSocket::rawSocket: - /* raw socket requested. I wouldn't do this if I were you... */ - socktype = SOCK_RAW; - break; - - default: - /* the flags were used in an invalid manner */ - return false; - } - - if (flags & KExtendedSocket::knownSocket) - { - familyMask = 0; - if ((flags & KExtendedSocket::unixSocket) == KExtendedSocket::unixSocket) - familyMask |= KResolver::UnixFamily; - - switch ((flags & (KExtendedSocket::ipv6Socket|KExtendedSocket::ipv4Socket))) - { - case KExtendedSocket::ipv4Socket: - familyMask |= KResolver::IPv4Family; - break; - case KExtendedSocket::ipv6Socket: - familyMask |= KResolver::IPv6Family; - break; - case KExtendedSocket::inetSocket: - familyMask |= KResolver::InternetFamily; - break; - } - - // those are all the families we know about - } - else - familyMask = KResolver::KnownFamily; - - /* check other flags */ - outflags = (flags & KExtendedSocket::passiveSocket ? KResolver::Passive : 0) | - (flags & KExtendedSocket::canonName ? KResolver::CanonName : 0) | - (flags & KExtendedSocket::noResolve ? KResolver::NoResolve : 0); - - if (getenv("KDE_NO_IPV6")) - familyMask &= ~KResolver::IPv6Family; - - return true; -} - -// "skips" at most len bytes from file descriptor fd -// that is, we will try and read that much data and discard -// it. We will stop when we have read those or when the read -// function returns error -static int skipData(int fd, unsigned len) -{ - char buf[1024]; - unsigned skipped = 0; - while (len) - { - int count = sizeof(buf); - if ((unsigned)count > len) - count = len; - count = KSocks::self()->read(fd, buf, count); - if (count == -1) - return -1; - else - { - len -= count; - skipped += count; - } - } - return skipped; -} - -/* - * class KExtendedSocket - */ - -// default constructor -KExtendedSocket::KExtendedSocket() : - sockfd(-1), d(new KExtendedSocketPrivate) -{ -} - -// constructor with hostname -KExtendedSocket::KExtendedSocket(const TQString& host, int port, int flags) : - sockfd(-1), d(new KExtendedSocketPrivate) -{ - setAddress(host, port); - setSocketFlags(flags); -} - -// same -KExtendedSocket::KExtendedSocket(const TQString& host, const TQString& service, int flags) : - sockfd(-1), d(new KExtendedSocketPrivate) -{ - setAddress(host, service); - setSocketFlags(flags); -} - -// destroy the class -KExtendedSocket::~KExtendedSocket() -{ - closeNow(); - - if (d->local != NULL) - delete d->local; - if (d->peer != NULL) - delete d->peer; - - if (d->qsnIn != NULL) - delete d->qsnIn; - if (d->qsnOut != NULL) - delete d->qsnOut; - - delete d; -} - -#ifdef USE_QT3 -void KExtendedSocket::reset() -#endif // USE_QT3 -#ifdef USE_QT4 -bool KExtendedSocket::reset() -#endif // USE_QT4 -{ - closeNow(); - release(); - d->current = 0; - d->status = nothing; - d->syserror = 0; -} - -int KExtendedSocket::socketStatus() const -{ - return d->status; -} - -void KExtendedSocket::setSocketStatus(int newstatus) -{ - d->status = newstatus; -} - -void KExtendedSocket::setError(int errorcode, int syserror) -{ - setqStatus(errorcode); - d->syserror = syserror; -} - -int KExtendedSocket::systemError() const -{ - return d->syserror; -} - -/* - * Sets socket flags - * This is only allowed if we are in nothing state - */ -int KExtendedSocket::setSocketFlags(int flags) -{ - if (d->status > nothing) - return -1; // error! - - return d->flags = flags; -} - -int KExtendedSocket::socketFlags() const -{ - return d->flags; -} - -/* - * Sets socket target hostname - * This is only allowed if we are in nothing state - */ -bool KExtendedSocket::setHost(const TQString& host) -{ - if (d->status > nothing) - return false; // error! - - d->resRemote.setNodeName(host); - return true; -} - -/* - * returns the hostname - */ -TQString KExtendedSocket::host() const -{ - return d->resRemote.nodeName(); -} - -/* - * Sets the socket target port/service - * Same thing: only state 'nothing' - */ -bool KExtendedSocket::setPort(int port) -{ - return setPort(TQString::number(port)); -} - -bool KExtendedSocket::setPort(const TQString& service) -{ - if (d->status > nothing) - return false; // error - - d->resRemote.setServiceName(service); - return true; -} - -/* - * returns the service port number - */ -TQString KExtendedSocket::port() const -{ - return d->resRemote.serviceName(); -} - -/* - * sets the address - */ -bool KExtendedSocket::setAddress(const TQString& host, int port) -{ - return setHost(host) && setPort(port); -} - -/* - * the same - */ -bool KExtendedSocket::setAddress(const TQString& host, const TQString& serv) -{ - return setHost(host) && setPort(serv); -} - -/* - * Sets the bind hostname - * This is only valid in the 'nothing' state and if this is not a - * passiveSocket socket - */ -bool KExtendedSocket::setBindHost(const TQString& host) -{ - if (d->status > nothing || d->flags & passiveSocket) - return false; // error - - d->resLocal.setServiceName(host); - return true; -} - -/* - * Unsets the bind hostname - * same thing - */ -bool KExtendedSocket::unsetBindHost() -{ - return setBindHost(TQString::null); -} - -/* - * returns the binding host - */ -TQString KExtendedSocket::bindHost() const -{ - return d->resLocal.serviceName(); -} - -/* - * Sets the bind port - * Same condition as setBindHost - */ -bool KExtendedSocket::setBindPort(int port) -{ - return setBindPort(TQString::number(port)); -} - -bool KExtendedSocket::setBindPort(const TQString& service) -{ - if (d->status > nothing || d->flags & passiveSocket) - return false; // error - - d->resLocal.setServiceName(service); - return true; -} - -/* - * unsets the bind port - */ -bool KExtendedSocket::unsetBindPort() -{ - return setBindPort(TQString::null); -} - -/* - * returns the binding port - */ -TQString KExtendedSocket::bindPort() const -{ - return d->resLocal.serviceName(); -} - -/* - * sets the binding address - */ -bool KExtendedSocket::setBindAddress(const TQString& host, int port) -{ - return setBindHost(host) && setBindPort(port); -} - -/* - * same - */ -bool KExtendedSocket::setBindAddress(const TQString& host, const TQString& service) -{ - return setBindHost(host) && setBindPort(service); -} - -/* - * unsets binding address - */ -bool KExtendedSocket::unsetBindAddress() -{ - return unsetBindHost() && unsetBindPort(); -} - -/* - * sets the timeout for the connection - */ -bool KExtendedSocket::setTimeout(int secs, int usecs) -{ - if (d->status >= connected) // closed? - return false; - - d->timeout.tv_sec = secs; - d->timeout.tv_usec = usecs; - return true; -} - -/* - * returns the timeout - */ -timeval KExtendedSocket::timeout() const -{ - return d->timeout; -} - -/* - * Sets the blocking mode on this socket - */ -bool KExtendedSocket::setBlockingMode(bool enable) -{ - cleanError(); - if (d->status < created) - return false; - - if (sockfd == -1) - return false; // error! - - int fdflags = fcntl(sockfd, F_GETFL, 0); - if (fdflags == -1) - return false; // error! - - if (!enable) - fdflags |= O_NONBLOCK; - else - fdflags &= ~O_NONBLOCK; - - if (fcntl(sockfd, F_SETFL, fdflags) == -1) - { - setError(IO_UnspecifiedError, errno); - return false; - } - return true; -} - -/* - * Returns the blocking mode on the socket - */ -bool KExtendedSocket::blockingMode() -{ - cleanError(); - if (d->status < created) - return false; // sockets not created are in blocking mode - - if (sockfd == -1) - return false; // error - - int fdflags = fcntl(sockfd, F_GETFL, 0); - if (fdflags == -1) - { - setError(IO_UnspecifiedError, errno); - return false; - } - return (fdflags & O_NONBLOCK) == 0; // non-blocking == false -} - -/* - * Sets the reusability flag for this socket in the OS - */ -bool KExtendedSocket::setAddressReusable(bool enable) -{ - cleanError(); - d->addressReusable = enable; - if (d->status < created) - return true; - - if (sockfd == -1) - return true; - - if (!setAddressReusable(sockfd, enable)) - { - setError(IO_UnspecifiedError, errno); - return false; - } - return true; -} - -bool KExtendedSocket::setAddressReusable(int fd, bool enable) -{ - if (fd == -1) - return false; - - int on = enable; // just to be on the safe side - - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on)) == -1) - return false; - return true; -} - -/* - * Retrieves the reusability flag for this socket - */ -bool KExtendedSocket::addressReusable() -{ - cleanError(); - if (d->status < created) - return d->addressReusable; - - if (sockfd == -1) - return d->addressReusable; - - int on; - socklen_t onsiz = sizeof(on); - if (getsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, &onsiz) == -1) - { - setError(IO_UnspecifiedError, errno); - return false; - } - - return on != 0; -} - -/* - * Set the IPV6_V6ONLY flag - */ -bool KExtendedSocket::setIPv6Only(bool enable) -{ -#ifdef IPV6_V6ONLY - cleanError(); - - d->ipv6only = enable; - if (sockfd == -1) - return true; // can't set on a non-existing socket - - int on = enable; - - if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, - (char *)&on, sizeof(on)) == -1) - { - setError(IO_UnspecifiedError, errno); - return false; - } - else - return true; - -#else - // we don't have the IPV6_V6ONLY constant in this system - d->ipv6only = enable; - - setError(IO_UnspecifiedError, ENOSYS); - return false; // can't set if we don't know about this flag -#endif -} - -/* - * retrieve the IPV6_V6ONLY flag - */ -bool KExtendedSocket::isIPv6Only() -{ -#ifdef IPV6_V6ONLY - cleanError(); - - if (d->status < created || sockfd == -1) - return d->ipv6only; - - int on; - socklen_t onsiz = sizeof(on); - if (getsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, - (char *)&on, &onsiz) == -1) - { - setError(IO_UnspecifiedError, errno); - return false; - } - - return d->ipv6only = on; - -#else - // we don't have the constant - setError(IO_UnspecifiedError, ENOSYS); - return false; -#endif -} - -/* - * Sets the buffer sizes in this socket - * Also, we create or delete the socket notifiers - */ -bool KExtendedSocket::setBufferSize(int rsize, int wsize) -{ - cleanError(); - if (d->status < created) - return false; - - if (sockfd == -1) - return false; - - if (d->flags & passiveSocket) - return false; // no I/O on passive sockets - - if (rsize < -2) - return false; - - if (wsize < -2) - return false; - - // LOCK BUFFER MUTEX - - // The input socket notifier is always enabled - // That happens because we want to be notified of when the socket gets - // closed - if (d->qsnIn == NULL) - { - d->qsnIn = new TQSocketNotifier(sockfd, TQSocketNotifier::Read); - TQObject::connect(d->qsnIn, TQT_SIGNAL(activated(int)), this, TQT_SLOT(socketActivityRead())); - d->qsnIn->setEnabled(true); - } - - if (rsize == 0 && d->flags & inputBufferedSocket) - { - // user wants to disable input buffering - d->flags &= ~inputBufferedSocket; - - consumeReadBuffer(readBufferSize(), NULL, true); - d->inMaxSize = 0; - } - else if (rsize != -2) - { - // enabling input buffering - if (rsize) - d->flags |= inputBufferedSocket; - d->inMaxSize = rsize; - - if (rsize > 0 && (unsigned)rsize < readBufferSize()) - // input buffer has more data than the new size; discard - consumeReadBuffer(readBufferSize() - rsize, NULL, true); - - } - - if (wsize == 0 && d->flags & outputBufferedSocket) - { - // disabling output buffering - d->flags &= ~outputBufferedSocket; - if (d->qsnOut && !d->emitWrite) - d->qsnOut->setEnabled(false); - consumeWriteBuffer(writeBufferSize()); - d->outMaxSize = 0; - } - else if (wsize != -2) - { - // enabling input buffering - if (wsize) - d->flags |= outputBufferedSocket; - d->outMaxSize = wsize; - - if (wsize > 0 && (unsigned)wsize < writeBufferSize()) - // output buffer is bigger than it is to become; shrink - consumeWriteBuffer(writeBufferSize() - wsize); - - if (d->qsnOut == NULL) - { - d->qsnOut = new TQSocketNotifier(sockfd, TQSocketNotifier::Write); - TQObject::connect(d->qsnOut, TQT_SIGNAL(activated(int)), this, TQT_SLOT(socketActivityWrite())); - // if the class is being created now, there's nothing to write yet - // so socketActivityWrite() will get called once and disable - // the notifier - } - } - - // UNLOCK BUFFER MUTEX - - setFlags((mode() & ~IO_Raw) | ((d->flags & bufferedSocket) ? 0 : IO_Raw)); - - // check we didn't turn something off we shouldn't - if (d->emitWrite && d->qsnOut == NULL) - { - d->qsnOut = new TQSocketNotifier(sockfd, TQSocketNotifier::Write); - TQObject::connect(d->qsnOut, TQT_SIGNAL(activated(int)), this, TQT_SLOT(socketActivityWrite())); - } - - return true; -} - -/* - * Finds the local address for this socket - * if we have done this already, we return it. Otherwise, we'll have - * to find the socket name - */ -const ::KSocketAddress *KExtendedSocket::localAddress() -{ - if (d->local != NULL) - return d->local; - if (d->status < bound) - return NULL; - - return d->local = localAddress(sockfd); -} - -/* - * Same thing, but for peer address. Which means this does not work on - * passiveSocket and that we require to be connected already. Also note that - * the behavior on connectionless sockets is not defined here. - */ -const ::KSocketAddress* KExtendedSocket::peerAddress() -{ - if (d->peer != NULL) - return d->peer; - if (d->flags & passiveSocket || d->status < connected) - return NULL; - - return d->peer = peerAddress(sockfd); -} - -/* - * Perform the lookup on the addresses given - */ -int KExtendedSocket::lookup() -{ - if (startAsyncLookup() != 0) - return -1; - - if (!d->resRemote.wait() || !d->resLocal.wait()) - { - d->status = nothing; - return -1; - } - - d->status = lookupDone; - if (d->resRemote.error() != KResolver::NoError) - return d->resRemote.error(); - if (d->resLocal.error() != KResolver::NoError) - return d->resLocal.error(); - return 0; -} - -/* - * Performs an asynchronous lookup on the given address(es) - */ -int KExtendedSocket::startAsyncLookup() -{ - cleanError(); - if (d->status > lookupInProgress) - return -1; - if (d->status == lookupInProgress) - // already in progress - return 0; - - /* check socket type flags */ - int socktype, familyMask, flags; - if (!process_flags(d->flags, socktype, familyMask, flags)) - return -2; - - // perform the global lookup before - if (!d->resRemote.isRunning()) - { - d->resRemote.setFlags(flags); - d->resRemote.setFamily(familyMask); - d->resRemote.setSocketType(socktype); - TQObject::connect(&d->resRemote, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(dnsResultsReady())); - - if (!d->resRemote.start()) - { - setError(IO_LookupError, d->resRemote.error()); - return d->resRemote.error(); - } - } - - if ((d->flags & passiveSocket) == 0 && !d->resLocal.isRunning()) - { - /* keep flags, but make this passive */ - flags |= KResolver::Passive; - d->resLocal.setFlags(flags); - d->resLocal.setFamily(familyMask); - d->resLocal.setSocketType(socktype); - TQObject::connect(&d->resLocal, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(dnsResultsReady())); - - if (!d->resLocal.start()) - { - setError(IO_LookupError, d->resLocal.error()); - return d->resLocal.error(); - } - } - - // if we are here, there were no errors - if (d->resRemote.isRunning() || d->resLocal.isRunning()) - d->status = lookupInProgress; // only if there actually is a running lookup - else - { - d->status = lookupDone; - emit lookupFinished(d->resRemote.results().count() + - d->resLocal.results().count()); - } - return 0; -} - -void KExtendedSocket::cancelAsyncLookup() -{ - cleanError(); - if (d->status != lookupInProgress) - return; // what's to cancel? - - d->status = nothing; - d->resLocal.cancel(false); - d->resRemote.cancel(false); -} - -int KExtendedSocket::listen(int N) -{ - cleanError(); - if ((d->flags & passiveSocket) == 0 || d->status >= listening) - return -2; - if (d->status < lookupDone) - if (lookup() != 0) - return -2; // error! - if (d->resRemote.error()) - return -2; - - // doing the loop: - KResolverResults::const_iterator it; - KResolverResults res = d->resRemote.results(); - for (it = res.begin(); it != res.end(); ++it) - { - //kdDebug(170) << "Trying to listen on " << (*it).address().toString() << endl; - sockfd = ::socket((*it).family(), (*it).socketType(), (*it).protocol()); - if (sockfd == -1) - { - // socket failed creating - //kdDebug(170) << "Failed to create: " << perror << endl; - continue; - } - - fcntl(sockfd, F_SETFD, FD_CLOEXEC); - - if (d->addressReusable) - setAddressReusable(sockfd, true); - setIPv6Only(d->ipv6only); - cleanError(); - if (KSocks::self()->bind(sockfd, (*it).address().address(), (*it).length()) == -1) - { - //kdDebug(170) << "Failed to bind: " << perror << endl; - ::close(sockfd); - sockfd = -1; - continue; - } - - // ok, socket has bound - // kdDebug(170) << "Socket bound: " << sockfd << endl; - - d->status = bound; - break; - } - - if (sockfd == -1) - { - setError(IO_ListenError, errno); - //kdDebug(170) << "Listen error - sockfd is -1 " << endl; - return -1; - } - - d->status = bound; - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - - int retval = KSocks::self()->listen(sockfd, N); - if (retval == -1) - setError(IO_ListenError, errno); - else - { - d->status = listening; - d->qsnIn = new TQSocketNotifier(sockfd, TQSocketNotifier::Read); - TQObject::connect(d->qsnIn, TQT_SIGNAL(activated(int)), this, TQT_SLOT(socketActivityRead())); - } - return retval == -1 ? -1 : 0; -} - -int KExtendedSocket::accept(KExtendedSocket *&sock) -{ - cleanError(); - sock = NULL; - if ((d->flags & passiveSocket) == 0 || d->status >= accepting) - return -2; - if (d->status < listening) - if (listen() < 0) - return -2; // error! - - // let's see - // if we have a timeout in place, we have to place this socket in non-blocking - // mode - bool block = blockingMode(); - struct sockaddr sa; - ksocklen_t len = sizeof(sa); - sock = NULL; - - if (d->timeout.tv_sec > 0 || d->timeout.tv_usec > 0) - { - fd_set set; - - setBlockingMode(false); // turn on non-blocking - FD_ZERO(&set); - FD_SET(sockfd, &set); - - //kdDebug(170).form("Accepting on %d with %d.%06d second timeout\n", - // sockfd, d->timeout.tv_sec, d->timeout.tv_usec); - // check if there is anything to accept now - int retval = KSocks::self()->select(sockfd + 1, &set, NULL, NULL, &d->timeout); - if (retval == -1) - { - setError(IO_UnspecifiedError, errno); - return -1; // system error - } - else if (retval == 0 || !FD_ISSET(sockfd, &set)) - { - setError(IO_TimeOutError, 0); - return -3; // timeout - } - } - - // it's common stuff here - int newfd = KSocks::self()->accept(sockfd, &sa, &len); - - if (newfd == -1) - { - setError(IO_AcceptError, errno); - kdWarning(170) << "Error accepting on socket " << sockfd << ":" - << perror << endl; - return -1; - } - - fcntl(newfd, F_SETFD, FD_CLOEXEC); - - //kdDebug(170).form("Socket %d accepted socket %d\n", sockfd, newfd); - - setBlockingMode(block); // restore blocking mode - - sock = new KExtendedSocket; - sock->d->status = connected; - sock->sockfd = newfd; - sock->setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - sock->setBufferSize(0, 0); // always unbuffered here. User can change that later - - return 0; -} - -/* - * tries to connect - * - * FIXME! - * This function is critical path. It has to be cleaned up and made faster - */ -int KExtendedSocket::connect() -{ - cleanError(); - if (d->flags & passiveSocket || d->status >= connected) - return -2; - if (d->status < lookupDone) - if (lookup() != 0) - return -2; - - timeval end, now; - timeval timeout_copy = d->timeout; - // Ok, things are a little tricky here - // Let me explain - // getaddrinfo() will return several different families of sockets - // When we have to bind before we connect, we have to make sure we're binding - // and connecting to the same family, or things won't work - - KResolverResults remote = d->resRemote.results(), - local = d->resLocal.results(); - KResolverResults::const_iterator it, it2; - //kdDebug(170) << "Starting connect to " << host() << '|' << port() - // << ": have " << local.count() << " local entries and " - // << remote.count() << " remote" << endl; - - int ret = -1; - for (it = remote.begin(), it2 = local.begin(); it != remote.end(); ++it) - { - bool doingtimeout = d->timeout.tv_sec > 0 || d->timeout.tv_usec > 0; - if (doingtimeout) - { - gettimeofday(&end, NULL); - end.tv_usec += d->timeout.tv_usec; - end.tv_sec += d->timeout.tv_sec; - if (end.tv_usec > 1000*1000) - { - end.tv_usec -= 1000*1000; - end.tv_sec++; - } - //kdDebug(170).form("Connection with timeout of %d.%06d seconds (ends in %d.%06d)\n", - // d->timeout.tv_sec, d->timeout.tv_usec, end.tv_sec, end.tv_usec); - } - - //kdDebug(170) << "Trying to connect to " << (*it).address().toString() << endl; - if (it2 != local.end()) - { -// //kdDebug(170) << "Searching bind socket for family " << p->ai_family << endl; - if ((*it).family() != (*it2).family()) - // differing families, scan local for a matching family - for (it2 = local.begin(); it2 != local.end(); ++it2) - if ((*it).family() == (*it2).family()) - break; - - if ((*it).family() != (*it2).family()) - { - // no matching families for this - //kdDebug(170) << "No matching family for bind socket\n"; - it2 = local.begin(); - continue; - } - - //kdDebug(170) << "Binding on " << (*it2).address().toString() << " before connect" << endl; - errno = 0; - sockfd = ::socket((*it).family(), (*it).socketType(), (*it).protocol()); - setError(IO_ConnectError, errno); - if (sockfd == -1) - continue; // cannot create this socket - fcntl(sockfd, F_SETFD, FD_CLOEXEC); - if (d->addressReusable) - setAddressReusable(sockfd, true); - setIPv6Only(d->ipv6only); - cleanError(); - if (KSocks::self()->bind(sockfd, (*it2).address(), (*it2).length())) - { - //kdDebug(170) << "Bind failed: " << perror << endl; - ::close(sockfd); - sockfd = -1; - continue; - } - } - else - { - // no need to bind, just create - sockfd = ::socket((*it).family(), (*it).socketType(), (*it).protocol()); - if (sockfd == -1) - { - setError(IO_ConnectError, errno); - continue; - } - fcntl(sockfd, F_SETFD, FD_CLOEXEC); - if (d->addressReusable) - setAddressReusable(sockfd, true); - setIPv6Only(d->ipv6only); - cleanError(); - } - -// kdDebug(170) << "Socket " << sockfd << " created" << endl; - d->status = created; - - // check if we have to do timeout - if (doingtimeout && KSocks::self()->hasWorkingAsyncConnect()) - { - fd_set rd, wr; - - setBlockingMode(false); - - // now try and connect - if (KSocks::self()->connect(sockfd, (*it).address(), (*it).length()) == -1) - { - // this could be EWOULDBLOCK - if (errno != EWOULDBLOCK && errno != EINPROGRESS) - { - //kdDebug(170) << "Socket " << sockfd << " did not connect: " << perror << endl; - setError(IO_ConnectError, errno); - ::close(sockfd); - sockfd = -1; - continue; // nope, another error - } - - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_SET(sockfd, &rd); - FD_SET(sockfd, &wr); - - int retval = KSocks::self()->select(sockfd + 1, &rd, &wr, NULL, &d->timeout); - if (retval == -1) - { - setError(IO_FatalError, errno); - continue; // system error - } - else if (retval == 0) - { - ::close(sockfd); - sockfd = -1; -// kdDebug(170) << "Time out while trying to connect to " << -// (*it).address().toString() << endl; - setError(IO_TimeOutError, 0); - ret = -3; // time out - - d->timeout.tv_usec += timeout_copy.tv_usec; - d->timeout.tv_sec += timeout_copy.tv_sec; - if (d->timeout.tv_usec < 0) - { - d->timeout.tv_usec += 1000*1000; - d->timeout.tv_sec--; - } - - continue; - } - - // adjust remaining time - gettimeofday(&now, NULL); - d->timeout.tv_sec = end.tv_sec - now.tv_sec; - d->timeout.tv_usec = end.tv_usec - now.tv_usec; - if (d->timeout.tv_usec < 0) - { - d->timeout.tv_usec += 1000*1000; - d->timeout.tv_sec--; - } -// kdDebug(170).form("Socket %d activity; %d.%06d seconds remaining\n", -// sockfd, d->timeout.tv_sec, d->timeout.tv_usec); - - // this means that an event occurred in the socket - int errcode; - socklen_t len = sizeof(errcode); - retval = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (char*)&errcode, - &len); - if (retval == -1 || errcode != 0) - { - // socket did not connect - //kdDebug(170) << "Socket " << sockfd << " did not connect: " - // << strerror(errcode) << endl; - ::close(sockfd); - sockfd = -1; - - // this is HIGHLY UNLIKELY - if (d->timeout.tv_sec == 0 && d->timeout.tv_usec == 0) - { - d->status = lookupDone; - setError(IO_TimeOutError, 0); - return -3; // time out - } - - setError(IO_ConnectError, errcode); - continue; - } - } - - // getting here means it connected - // setBufferSize() takes care of creating the socket notifiers - setBlockingMode(true); - d->status = connected; - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - setBufferSize(d->flags & inputBufferedSocket ? -1 : 0, - d->flags & outputBufferedSocket ? -1 : 0); - emit connectionSuccess(); -// kdDebug(170) << "Socket " << sockfd << " connected\n"; - return 0; - } - else - { - // without timeouts - if (KSocks::self()->connect(sockfd, (*it).address(), (*it).length()) == -1) - { - //kdDebug(170) << "Socket " << sockfd << " to " << (*it).address().toString() - // << " did not connect: " << perror << endl; - setError(IO_ConnectError, errno); - ::close(sockfd); - sockfd = -1; - continue; - } - - d->status = connected; - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - setBufferSize(d->flags & inputBufferedSocket ? -1 : 0, - d->flags & outputBufferedSocket ? -1 : 0); - emit connectionSuccess(); -// kdDebug(170) << "Socket " << sockfd << " connected\n"; - return 0; // it connected - } - } - - // getting here means no socket connected or stuff like that - emit connectionFailed(d->syserror); - //kdDebug(170) << "Failed to connect\n"; - return ret; -} - -int KExtendedSocket::startAsyncConnect() -{ - cleanError(); - // check status - if (d->status >= connected || d->flags & passiveSocket) - return -2; - - if (d->status == connecting) - // already on async connect - return 0; - - // check if we have to do lookup - // if we do, then we'll use asynchronous lookup and use - // signal lookupFinished to do connection - if (d->status < lookupDone) - { - TQObject::connect(this, TQT_SIGNAL(lookupFinished(int)), this, TQT_SLOT(startAsyncConnectSlot())); - if (d->status < lookupInProgress) - return startAsyncLookup(); - else - return 0; // we still have to wait - } - - // here we have d->status >= lookupDone and <= connecting - // we can do our connection - d->status = connecting; - TQGuardedPtr<TQObject> p = TQT_TQOBJECT(this); - connectionEvent(); - if (!p) - return -1; // We have been deleted. - if (d->status < connecting) - return -1; - return 0; -} - -void KExtendedSocket::cancelAsyncConnect() -{ - if (d->status != connecting) - return; - - if (sockfd != -1) - { - // we have a waiting connection - if (d->qsnIn) - delete d->qsnIn; - if (d->qsnOut) - delete d->qsnOut; - d->qsnIn = d->qsnOut = NULL; - - ::close(sockfd); - sockfd = -1; - } - d->status = lookupDone; -} - -bool KExtendedSocket::open(TQ_OpenMode mode) -{ - if (mode != IO_Raw | IO_ReadWrite) - return false; // invalid open mode - - if (d->flags & passiveSocket) - return listen() == 0; - else if (d->status < connecting) - return connect() == 0; - else - return false; -} - -void KExtendedSocket::close() -{ - if (sockfd == -1 || d->status >= closing) - return; // nothing to close - - // LOCK BUFFER MUTEX - if (d->flags & outputBufferedSocket && writeBufferSize() > 0) - { - // write buffer not empty, go into closing state - d->status = closing; - if (d->qsnIn) - delete d->qsnIn; - d->qsnIn = NULL; - // we keep the outgoing socket notifier because we want - // to send data, but not receive - } - else - { - // nope, write buffer is empty - // we can close now - if (d->qsnIn) - delete d->qsnIn; - if (d->qsnOut) - delete d->qsnOut; - d->qsnIn = d->qsnOut = NULL; - - ::close(sockfd); - d->status = done; - emit closed(readBufferSize() != 0 ? availRead : 0); - } - // UNLOCK BUFFER MUTEX -} - - -void KExtendedSocket::closeNow() -{ - if (d->status >= done) - return; // nothing to close - - // close the socket - delete d->qsnIn; - delete d->qsnOut; - d->qsnIn = d->qsnOut = NULL; - - if (d->status > connecting && sockfd != -1) - { - ::close(sockfd); - sockfd = -1; - } - else if (d->status == connecting) - cancelAsyncConnect(); - else if (d->status == lookupInProgress) - cancelAsyncLookup(); - - d->status = done; - - emit closed(closedNow | - (readBufferSize() != 0 ? availRead : 0) | - (writeBufferSize() != 0 ? dirtyWrite : 0)); -} - -void KExtendedSocket::release() -{ - // release our hold on the socket - sockfd = -1; - d->status = done; - - d->resRemote.cancel(false); - d->resLocal.cancel(false); - - if (d->local != NULL) - delete d->local; - if (d->peer != NULL) - delete d->peer; - - d->peer = d->local = NULL; - - if (d->qsnIn != NULL) - delete d->qsnIn; - if (d->qsnOut != NULL) - delete d->qsnOut; - - d->qsnIn = d->qsnOut = NULL; - - // now that the socket notificators are done with, we can flush out the buffers - consumeReadBuffer(readBufferSize(), NULL, true); - consumeWriteBuffer(writeBufferSize()); - - // don't delete d - // leave that for the destructor -} - -void KExtendedSocket::flush() -{ - cleanError(); - if (d->status < connected || d->status >= done || d->flags & passiveSocket) - return; - - if (sockfd == -1) - return; - - if ((d->flags & outputBufferedSocket) == 0) - return; // nothing to do - - // LOCK MUTEX - - unsigned written = 0; - unsigned offset = outBufIndex; // this happens only for the first - while (writeBufferSize() - written > 0) - { - // we have to write each output buffer in outBuf - // but since we can have several very small buffers, we can make things - // better by concatenating a few of them into a big buffer - // question is: how big should that buffer be? 16 kB should be enough - - TQByteArray buf(16384); - TQByteArray *a = outBuf.first(); - unsigned count = 0; - - while (a && count + (a->size() - offset) <= buf.size()) - { - memcpy(buf.data() + count, a->data() + offset, a->size() - offset); - count += a->size() - offset; - offset = 0; - a = outBuf.next(); - } - - // see if we can still fit more - if (a && count < buf.size()) - { - // getting here means this buffer (a) is larger than - // (buf.size() - count) (even for count == 0). - memcpy(buf.data() + count, a->data() + offset, buf.size() - count); - offset += buf.size() - count; - count = buf.size(); - } - - // now try to write those bytes - int wrote = KSocks::self()->write(sockfd, buf, count); - - if (wrote == -1) - { - // could be EAGAIN (EWOULDBLOCK) - setError(IO_WriteError, errno); - break; - } - written += wrote; - - if ((unsigned)wrote != count) - break; - } - if (written) - { - consumeWriteBuffer(written); - emit bytesWritten(written); - } - - // UNLOCK MUTEX -} - - -TQT_TQIO_LONG KExtendedSocket::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen) -{ - cleanError(); - if (d->status < connected || d->flags & passiveSocket) - return -2; - - int retval; - - if ((d->flags & inputBufferedSocket) == 0) - { - // we aren't buffering this socket, so just pass along - // the call to the real read method - - if (sockfd == -1) - return -2; - if (data) - retval = KSocks::self()->read(sockfd, data, maxlen); - else - retval = skipData(sockfd, maxlen); - if (retval == -1) - setError(IO_ReadError, errno); - } - else - { - // this socket is being buffered. So read from the buffer - - // LOCK BUFFER MUTEX - - retval = consumeReadBuffer(maxlen, data); - if (retval == 0) - { - // consumeReadBuffer returns 0 only if the buffer is - // empty - if (sockfd == -1) - return 0; // buffer is clear now, indicate EOF - setError(IO_ReadError, EWOULDBLOCK); - retval = -1; - } - - // UNLOCK BUFFER MUTEX - - } - return retval; -} - -TQT_TQIO_LONG KExtendedSocket::tqwriteBlock(const char *data, TQT_TQIO_ULONG len) -{ - cleanError(); - if (d->status < connected || d->status >= closing || d->flags & passiveSocket) - return -2; - if (sockfd == -1) - return -2; - - if (len == 0) - return 0; // what's to write? - - int retval; - - if ((d->flags & outputBufferedSocket) == 0) - { - // socket not buffered. Just call write - retval = KSocks::self()->write(sockfd, data, len); - if (retval == -1) - setError(IO_WriteError, errno); - else - emit bytesWritten(retval); - } - else - { - // socket is buffered. Feed the write buffer - - // LOCK BUFFER MUTEX - - register unsigned wsize = writeBufferSize(); - if (d->outMaxSize == (int)wsize) // (int) to get rid of annoying warning - { - // buffer is full! - setError(IO_WriteError, EWOULDBLOCK); - retval = -1; - } - else - { - if (d->outMaxSize != -1 && wsize + len > (unsigned)d->outMaxSize) - // we cannot write all data. Write just as much as to fill the buffer - len = d->outMaxSize - wsize; - - // len > 0 here - retval = feedWriteBuffer(len, data); - if (wsize == 0 || d->emitWrite) - // buffer was empty, which means that the notifier is probably disabled - d->qsnOut->setEnabled(true); - } - - // UNLOCK BUFFER MUTEX - } - - return retval; -} - -int KExtendedSocket::peekBlock(char *data, uint maxlen) -{ - if (d->status < connected || d->flags & passiveSocket) - return -2; - if (sockfd == -1) - return -2; - - // need to LOCK MUTEX around this call... - - if (d->flags & inputBufferedSocket) - return consumeReadBuffer(maxlen, data, false); - - return 0; -} - -int KExtendedSocket::unreadBlock(const char *, uint) -{ - // Always return -1, indicating this is not supported - setError(IO_ReadError, ENOSYS); - return -1; -} - -#ifdef USE_QT3 -int KExtendedSocket::bytesAvailable() const -#endif // USE_QT3 -#ifdef USE_QT4 -qint64 KExtendedSocket::bytesAvailable() const -#endif // USE_QT4 -{ - if (d->status < connected || d->flags & passiveSocket) - return -2; - - // as of now, we don't do any extra processing - // we only work in input-buffered sockets - if (d->flags & inputBufferedSocket) - return KBufferedIO::bytesAvailable(); - - return 0; // TODO: FIONREAD ioctl -} - -int KExtendedSocket::waitForMore(int msecs) -{ - cleanError(); - if (d->flags & passiveSocket || d->status < connected || d->status >= closing) - return -2; - if (sockfd == -1) - return -2; - - fd_set rd; - FD_ZERO(&rd); - FD_SET(sockfd, &rd); - timeval tv; - tv.tv_sec = msecs / 1000; - tv.tv_usec = (msecs % 1000) * 1000; - - int retval = KSocks::self()->select(sockfd + 1, &rd, NULL, NULL, &tv); - if (retval == -1) - { - setError(IO_FatalError, errno); - return -1; - } - else if (retval != 0) - socketActivityRead(); // do read processing - - return bytesAvailable(); -} - -int KExtendedSocket::getch() -{ - unsigned char c; - int retval; - retval = tqreadBlock((char*)&c, sizeof(c)); - - if (retval < 0) - return retval; - return c; -} - -int KExtendedSocket::putch(int ch) -{ - unsigned char c = (char)ch; - return tqwriteBlock((char*)&c, sizeof(c)); -} - -// sets the emission of the readyRead signal -void KExtendedSocket::enableRead(bool enable) -{ - // check if we can disable the socket notifier - // saves us a few cycles - // this is so because in buffering mode, we rely on these signals - // being emitted to do our I/O. We couldn't disable them here - if (!enable && (d->flags & inputBufferedSocket) == 0 && d->qsnIn) - d->qsnIn->setEnabled(false); - else if (enable && d->qsnIn) - // we can enable it always - d->qsnIn->setEnabled(true); - d->emitRead = enable; -} - -// sets the emission of the readyWrite signal -void KExtendedSocket::enableWrite(bool enable) -{ - // same thing as above - if (!enable && (d->flags & outputBufferedSocket) == 0 && d->qsnOut) - d->qsnOut->setEnabled(false); - else if (enable && d->qsnOut) - // we can enable it always - d->qsnOut->setEnabled(true); - d->emitWrite = enable; -} - -// protected slot -// this is connected to d->qsnIn::activated(int) -void KExtendedSocket::socketActivityRead() -{ - if (d->flags & passiveSocket) - { - emit readyAccept(); - return; - } - if (d->status == connecting) - { - connectionEvent(); - return; - } - if (d->status != connected) - return; - - // do we need to do I/O here? - if (d->flags & inputBufferedSocket) - { - // aye. Do read from the socket and feed our buffer - TQByteArray a; - char buf[1024]; - int len, totalread = 0; - - // LOCK MUTEX - - unsigned cursize = readBufferSize(); - - if (d->inMaxSize == -1 || cursize < (unsigned)d->inMaxSize) - { - do - { - // check that we can read that many bytes - if (d->inMaxSize != -1 && d->inMaxSize - (cursize + totalread) < sizeof(buf)) - // no, that would overrun the buffer - // note that this will also make us exit the loop - len = d->inMaxSize - (cursize + totalread); - else - len = sizeof(buf); - - len = KSocks::self()->read(sockfd, buf, len); - if (len > 0) - { - // normal read operation - a.resize(a.size() + len); - memcpy(a.data() + totalread, buf, len); - totalread += len; // totalread == a.size() now - } - else if (len == 0) - { - // EOF condition here - ::close(sockfd); - sockfd = -1; // we're closed - d->qsnIn->deleteLater(); - delete d->qsnOut; - d->qsnIn = d->qsnOut = NULL; - d->status = done; - emit closed(involuntary | - (readBufferSize() ? availRead : 0) | - (writeBufferSize() ? dirtyWrite : 0)); - return; - } - else - { - // error! - setError(IO_ReadError, errno); - return; - } - // will loop only for normal read operations - } - while (len == sizeof(buf)); - - feedReadBuffer(a.size(), a.data()); - } - - // UNLOCK MUTEX - } - else - { - // No input buffering, but the notifier fired - // That means that either there is data to be read or that the - // socket closed. - - // try to read one byte. If we can't, then the socket got closed - - char c; - int len = KSocks::self()->recv(sockfd, &c, sizeof(c), MSG_PEEK); - if (len == 0) - { - // yes, it's an EOF condition - d->qsnIn->setEnabled(false); - ::close(sockfd); - sockfd = -1; - d->status = done; - emit closed(involuntary); - return; - } - } - - if (d->emitRead) - emit readyRead(); -} - -void KExtendedSocket::socketActivityWrite() -{ - if (d->flags & passiveSocket) - return; - if (d->status == connecting) - { - connectionEvent(); - return; - } - if (d->status != connected && d->status != closing) - return; - - flush(); - - bool empty = writeBufferSize() == 0; - - if (d->emitWrite && empty) - emit readyWrite(); - else if (!d->emitWrite) - { - // check if we can disable the notifier - d->qsnOut->setEnabled(!empty); // leave it enabled only if we have more data to send - } - if (d->status == closing && empty) - { - // done sending the missing data! - d->status = done; - - delete d->qsnOut; - ::close(sockfd); - - d->qsnOut = NULL; - sockfd = -1; - emit closed(delayed | (readBufferSize() ? availRead : 0)); - } -} - -// this function is called whenever we have a "connection event" -// that is, whenever our asynchronously connecting socket throws -// an event -void KExtendedSocket::connectionEvent() -{ - if (d->status != connecting) - return; // move along. There's nothing to see here - - KResolverResults remote = d->resRemote.results(); - if (remote.count() == 0) - { - // We have a problem! Abort? - kdError(170) << "KExtendedSocket::connectionEvent() called but no data available!\n"; - return; - } - - int errcode = 0; - - if (sockfd != -1) - { - // our socket has activity - // find out what it was - int retval; - socklen_t len = sizeof(errcode); - retval = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (char*)&errcode, &len); - - if (retval == -1 || errcode != 0) - { - // socket activity and there was error? - // that means the socket probably did not connect - if (d->qsnIn) - delete d->qsnIn; - if (d->qsnOut) - delete d->qsnOut; - ::close(sockfd); - - sockfd = -1; - d->qsnIn = d->qsnOut = NULL; - d->current++; - setError(IO_ConnectError, errcode); - } - else - { - // hmm, socket activity and there was no error? - // that means it connected - // YAY! - cleanError(); - d->status = connected; - setBlockingMode(true); - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - setBufferSize(d->flags & inputBufferedSocket ? -1 : 0, - d->flags & outputBufferedSocket ? -1 : 0); - emit connectionSuccess(); - return; - } - } - - // ok, we have to try something here - // and sockfd == -1 - KResolverResults local = d->resLocal.results(); - unsigned localidx = 0; - for ( ; d->current < remote.count(); d->current++) - { - // same code as in connect() - if (local.count() != 0) - { - // scan bindres for a local resuls family - for (localidx = 0; localidx < local.count(); localidx++) - if (remote[d->current].family() == local[localidx].family()) - break; - - if (remote[d->current].family() != local[localidx].family()) - { - // no matching families for this - continue; - } - - errno = 0; - sockfd = ::socket(remote[d->current].family(), remote[d->current].socketType(), - remote[d->current].protocol()); - setError(IO_ConnectError, errno); - errcode = errno; - if (sockfd == -1) - continue; // cannot create this socket - fcntl(sockfd, F_SETFD, FD_CLOEXEC); - if (d->addressReusable) - setAddressReusable(sockfd, true); - setIPv6Only(d->ipv6only); - cleanError(); - if (KSocks::self()->bind(sockfd, local[localidx].address(), - local[localidx].length()) == -1) - { - ::close(sockfd); - sockfd = -1; - continue; - } - } - else - { - // no need to bind, just create - sockfd = ::socket(remote[d->current].family(), remote[d->current].socketType(), - remote[d->current].protocol()); - if (sockfd == -1) - { - setError(IO_ConnectError, errno); - errcode = errno; - continue; - } - fcntl(sockfd, F_SETFD, FD_CLOEXEC); - if (d->addressReusable) - setAddressReusable(sockfd, true); - setIPv6Only(d->ipv6only); - cleanError(); - } - - if (KSocks::self()->hasWorkingAsyncConnect()) - setBlockingMode(false); - if (KSocks::self()->connect(sockfd, remote[d->current].address(), - remote[d->current].length()) == -1) - { - if (errno != EWOULDBLOCK && errno != EINPROGRESS) - { - setError(IO_ConnectError, errno); - ::close(sockfd); - sockfd = -1; - errcode = errno; - continue; - } - - // error here is either EWOULDBLOCK or EINPROGRESS - // so, it is a good condition - d->qsnIn = new TQSocketNotifier(sockfd, TQSocketNotifier::Read); - TQObject::connect(d->qsnIn, TQT_SIGNAL(activated(int)), this, TQT_SLOT(socketActivityRead())); - d->qsnOut = new TQSocketNotifier(sockfd, TQSocketNotifier::Write); - TQObject::connect(d->qsnOut, TQT_SIGNAL(activated(int)), this, TQT_SLOT(socketActivityWrite())); - - // ok, let the Qt event loop do the selecting for us - return; - } - - // eh, what? - // the non-blocking socket returned valid connection? - // already? - // I suppose that could happen... - cleanError(); - d->status = connected; - setBlockingMode(true); - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - setBufferSize(d->flags & inputBufferedSocket ? -1 : 0, - d->flags & outputBufferedSocket ? -1 : 0); - emit connectionSuccess(); - return; - } - - // if we got here, it means that there are no more options to connect - d->status = lookupDone; // go back - emit connectionFailed(errcode); -} - -void KExtendedSocket::dnsResultsReady() -{ - // check that this function was called in a valid state - if (d->status != lookupInProgress) - return; - - // valid state. Are results fully ready? - if (d->resRemote.isRunning() || d->resLocal.isRunning()) - // no, still waiting for answer in one of the lookups - return; - - // ok, we have all results - // count how many results we have - int n = d->resRemote.results().count() + d->resLocal.results().count(); - - if (n) - { - d->status = lookupDone; - cleanError(); - } - else - { - d->status = nothing; - setError(IO_LookupError, KResolver::NoName); - } - - emit lookupFinished(n); - - return; -} - -void KExtendedSocket::startAsyncConnectSlot() -{ - TQObject::disconnect(this, TQT_SIGNAL(lookupFinished(int)), this, TQT_SLOT(startAsyncConnectSlot())); - - if (d->status == lookupDone) - startAsyncConnect(); -} - -int KExtendedSocket::resolve(sockaddr *sock, ksocklen_t len, TQString &host, - TQString &port, int flags) -{ - kdDebug(170) << "Deprecated function called:" << k_funcinfo << endl; - - int err; - char h[NI_MAXHOST], s[NI_MAXSERV]; - - h[0] = s[0] = '\0'; - - err = getnameinfo(sock, len, h, sizeof(h) - 1, s, sizeof(s) - 1, flags); - host = TQString::fromUtf8(h); - port = TQString::fromUtf8(s); - - return err; -} - -int KExtendedSocket::resolve(::KSocketAddress *sock, TQString &host, TQString &port, - int flags) -{ - return resolve(sock->data, sock->datasize, host, port, flags); -} - -TQPtrList<KAddressInfo> KExtendedSocket::lookup(const TQString& host, const TQString& port, - int userflags, int *error) -{ - kdDebug(170) << "Deprecated function called:" << k_funcinfo << endl; - - int socktype, familyMask, flags; - unsigned i; - TQPtrList<KAddressInfo> l; - - /* check socket type flags */ - if (!process_flags(userflags, socktype, familyMask, flags)) - return l; - -// kdDebug(170) << "Performing lookup on " << host << "|" << port << endl; - KResolverResults res = KResolver::resolve(host, port, flags, familyMask); - if (res.error()) - { - if (error) - *error = res.error(); - return l; - } - - for (i = 0; i < res.count(); i++) - { - KAddressInfo *ai = new KAddressInfo(); - - // I should have known that using addrinfo was going to come - // and bite me back some day... - ai->ai = (addrinfo *) malloc(sizeof(addrinfo)); - memset(ai->ai, 0, sizeof(addrinfo)); - - ai->ai->ai_family = res[i].family(); - ai->ai->ai_socktype = res[i].socketType(); - ai->ai->ai_protocol = res[i].protocol(); - TQString canon = res[i].canonicalName(); - if (!canon.isEmpty()) - { - ai->ai->ai_canonname = (char *) malloc(canon.length()+1); - strcpy(ai->ai->ai_canonname, canon.ascii()); // ASCII here is intentional - } - if ((ai->ai->ai_addrlen = res[i].length())) - { - ai->ai->ai_addr = (struct sockaddr *) malloc(res[i].length()); - memcpy(ai->ai->ai_addr, res[i].address().address(), res[i].length()); - } - else - { - ai->ai->ai_addr = 0; - } - - ai->addr = ::KSocketAddress::newAddress(ai->ai->ai_addr, ai->ai->ai_addrlen); - - l.append(ai); - } - - if ( error ) - *error = 0; // all is fine! - - return l; -} - -::KSocketAddress *KExtendedSocket::localAddress(int fd) -{ - ::KSocketAddress *local; - struct sockaddr static_sa, *sa = &static_sa; - ksocklen_t len = sizeof(static_sa); - - /* find out the socket length, in advance - * we use a sockaddr allocated on the heap just not to pass down - * a NULL pointer to the first call. Some systems are reported to - * set len to 0 if we pass NULL as the sockaddr */ - if (KSocks::self()->getsockname(fd, sa, &len) == -1) - return NULL; // error! - - /* was it enough? */ - if (len > sizeof(static_sa) -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - || sa->sa_len > sizeof(static_sa) -#endif - ) - { - /* nope, malloc a new socket with the proper size */ - -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - if (sa->sa_len != len) - len = sa->sa_len; -#endif - - sa = (sockaddr*)malloc(len); - if (sa == NULL) - return NULL; // out of memory - - if (KSocks::self()->getsockname(fd, sa, &len) == -1) - { - free(sa); - return NULL; - } - - local = ::KSocketAddress::newAddress(sa, len); - free(sa); - } - else - local = ::KSocketAddress::newAddress(sa, len); - - return local; -} - -/* This is exactly the same code as localAddress, except - * we call getpeername here */ -::KSocketAddress *KExtendedSocket::peerAddress(int fd) -{ - ::KSocketAddress *peer; - struct sockaddr static_sa, *sa = &static_sa; - ksocklen_t len = sizeof(static_sa); - - /* find out the socket length, in advance - * we use a sockaddr allocated on the heap just not to pass down - * a NULL pointer to the first call. Some systems are reported to - * set len to 0 if we pass NULL as the sockaddr */ - if (KSocks::self()->getpeername(fd, sa, &len) == -1) - return NULL; // error! - - /* was it enough? */ - if (len > sizeof(static_sa) -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - || sa->sa_len > sizeof(static_sa) -#endif - ) - { - /* nope, malloc a new socket with the proper size */ - -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - if (sa->sa_len != len) - len = sa->sa_len; -#endif - - sa = (sockaddr*)malloc(len); - if (sa == NULL) - return NULL; // out of memory - - if (KSocks::self()->getpeername(fd, sa, &len) == -1) - { - free(sa); - return NULL; - } - - peer = ::KSocketAddress::newAddress(sa, len); - free(sa); - } - else - peer = ::KSocketAddress::newAddress(sa, len); - - return peer; -} - -TQString KExtendedSocket::strError(int code, int syserr) -{ - const char * msg; - if (code == IO_LookupError) - msg = gai_strerror(syserr); - else - msg = strerror(syserr); - - return TQString::fromLocal8Bit(msg); -} - - -TQSocketNotifier *KExtendedSocket::readNotifier() { return d->qsnIn; } -TQSocketNotifier *KExtendedSocket::writeNotifier() { return d->qsnOut; } - -/* - * class KAddressInfo - */ - -#if 0 -KAddressInfo::KAddressInfo(addrinfo *p) -{ - ai = (addrinfo *) malloc(sizeof(addrinfo)); - memcpy(ai, p, sizeof(addrinfo)); - ai->ai_next = NULL; - if (p->ai_canonname) - { - ai->ai_canonname = (char *) malloc(strlen(p->ai_canonname)+1); - strcpy(ai->ai_canonname, p->ai_canonname); - } - if (p->ai_addr && p->ai_addrlen) - { - ai->ai_addr = (struct sockaddr *) malloc(p->ai_addrlen); - memcpy(ai->ai_addr, p->ai_addr, p->ai_addrlen); - } - else - { - ai->ai_addr = 0; - ai->ai_addrlen = 0; - } - - addr = ::KSocketAddress::newAddress(ai->ai_addr, ai->ai_addrlen); -} -#endif -KAddressInfo::~KAddressInfo() -{ - if (ai && ai->ai_canonname) - free(ai->ai_canonname); - - if (ai && ai->ai_addr) - free(ai->ai_addr); - - if (ai) - free(ai); - delete addr; -} - -int KAddressInfo::flags() const -{ - return ai->ai_flags; -} - -int KAddressInfo::family() const -{ - return ai->ai_family; -} - -int KAddressInfo::socktype() const -{ - return ai->ai_socktype; -} - -int KAddressInfo::protocol() const -{ - return ai->ai_protocol; -} - -const char* KAddressInfo::canonname() const -{ - return ai->ai_canonname; -} - -void KExtendedSocket::virtual_hook( int id, void* data ) -{ KBufferedIO::virtual_hook( id, data ); } - -#include "kextsock.moc" diff --git a/kdecore/kextsock.h b/kdecore/kextsock.h deleted file mode 100644 index 24957dd47..000000000 --- a/kdecore/kextsock.h +++ /dev/null @@ -1,1130 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000-2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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 KEXTSOCK_H -#define KEXTSOCK_H - -#include "kdelibs_export.h" - -#ifdef Q_MOC_RUN -#define Q_OS_UNIX -#endif // Q_MOC_RUN - -#ifdef Q_OS_UNIX - -#include <sys/time.h> - -#include <tqstring.h> -#include <tqptrlist.h> -#include <tqiodevice.h> - -#include "kbufferedio.h" -#include "ksockaddr.h" - -/* External reference to netdb.h */ -struct addrinfo; -struct kde_addrinfo; -class KAddressInfo; /* our abstraction of it */ -class TQSocketNotifier; - -/* - * This is extending QIODevice's error codes - * - * According to tqiodevice.h, the last error is IO_UnspecifiedError - * These errors will never occur in functions declared in QIODevice - * (except open, but you shouldn't call open) - */ -#define IO_ListenError (IO_UnspecifiedError+1) -#define IO_AcceptError (IO_UnspecifiedError+2) -#define IO_LookupError (IO_UnspecifiedError+3) - -class KExtendedSocketPrivate; -/** - * The extended socket class. - * - * This class should be used instead of KSocket whenever the user needs - * fine-grained control over the socket being created. Unlike KSocket, which - * does everything at once, without much intervention, KExtendedSocket allows - * intervention at every step of the process and the setting of parameters. - * - * This class allows for the creation of both server and client sockets. The - * only difference is that the passiveSocket flag must be passed either to - * the constructor or to setSocketFlags(). If passiveSocket is used, the class will - * enable functions listen() and accept() and related signals, and will - * also disable tqreadBlock() and tqwriteBlock(). - * - * To create a Unix socket, one would pass flag unixSocket to the constructor - * or setSocketFlags(). The hostname and service/port can be set to whatever is - * necessary. If no hostname is given, but a service/port is, the socket created - * will be implementation dependant (usually in /tmp). In any other case, the - * fields will be concatenated. - * - * To create an Internet socket, inetSocket flag can be used. If, on the other - * hand a specific IP protocol is desired, ipv4Socket and/or ipv6Socket can be - * used. - * - * Note that the socket type selection flags are cumulative. One could select - * Unix and Internet sockets by using unixSocket | inetSocket. Or, for instance, - * to make sure only IPv4 and IPv6 sockets are selected, even if future implementations - * support newer IP protocols, ipv4Socket | ipv6Socket is your guy. - * - * @deprecated - * This class is now deprecated. Please use the classes in KNetwork for - * new programs. In particular, this class is replaced by KNetwork::KStreamSocket - * and @ref KNetwork::KServerSocket. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - * @short an extended socket - */ -class KDECORE_EXPORT KExtendedSocket: public KBufferedIO // public TQObject, public QIODevice -{ - Q_OBJECT - TQ_OBJECT - -public: - /** - * flags that can be passed down to the member functions - */ - enum Flags - { - /* socket address families */ - /* - * NOTE: if you change this, you have to change function valid_socket() as well - * These values are hard coded! - */ - anySocket = 0x00, - knownSocket = 0x01, - unixSocket = knownSocket | 0x02, - inetSocket = knownSocket | 0x04, - ipv4Socket = inetSocket | 0x100, - ipv6Socket = inetSocket | 0x200, - - passiveSocket = 0x1000, /* passive socket (i.e., one that accepts connections) */ - canonName = 0x2000, /* request that the canon name be found */ - noResolve = 0x4000, /* do not attempt to resolve, treat as numeric host */ - - streamSocket = 0x8000, /* request a streaming socket (e.g., TCP) */ - datagramSocket = 0x10000, /* request a datagram socket (e.g., UDP) */ - rawSocket = 0x20000, /* request a raw socket. This probably requires privileges */ - - inputBufferedSocket = 0x200000, /* buffer input in this socket */ - outputBufferedSocket = 0x400000, /* buffer output in this socket */ - bufferedSocket = 0x600000 /* make this a fully buffered socket */ - }; - - /** - * status of the class - * The status are sequential. If a change to one status is requested, - * all the prior status will be passed and their actions, performed - */ - enum SockStatus - { - // the numbers are scattered so that we leave room for future expansion - error = -1, // invalid status! - - nothing = 0, // no status, the class has just been created - - lookupInProgress = 50, // lookup is in progress. Signals will be sent - lookupDone = 70, // lookup has been done. Flags cannot be changed - // from this point on - - created = 100, // ::socket() has been called, a socket exists - bound = 140, // socket has been bound - - connecting = 200, // socket is connecting (not passiveSocket) - connected = 220, // socket has connected (not passiveSocket) - - listening = 200, // socket is listening (passiveSocket) - accepting = 220, // socket is accepting (passiveSocket) - - closing = 350, // socket is closing (delayed close) - - done = 400 // socket has been closed - }; - -public: - /** - * Creates an empty KExtendedSocket. - */ - KExtendedSocket(); - - /** - * Creates a socket with the given hostname and port. - * - * If this is a connecting (active) socket, the hostname and port specify - * the remote address to which we will connect. - * - * If this is a listening (passive) socket, the hostname and port specify - * the address to listen on. In order to listen on every interface - * available on this node, set @p host to TQString::null. To let the operating - * system select a port, set it to 0. - * - * @sa setAddress - * @param host the hostname - * @param port the port number - * @param flags flags - */ - KExtendedSocket(const TQString& host, int port, int flags = 0); - - /** - * Creates a socket with the given hostname and service. - * - * If this is a connecting (active) socket, the hostname and service specify - * the remote address to which we will connect. - * - * If this is a listening (passive) socket, the hostname and service specify - * the address to listen on. In order to listen on every interface - * available on this node, set @p host to TQString::null. To let the operating - * system select a port, set the service to "0". - * - * @sa setAddress - * @param host the hostname - * @param service the service - * @param flags flags - */ - KExtendedSocket(const TQString& host, const TQString& service, int flags = 0); - - /** - * Destroys the socket, disconnecting if still connected and - * freeing any related resources still being kept. - */ - virtual ~KExtendedSocket(); - - /** - * Resets the socket, disconnecting if still connected and - * freeing any related resources still being kept. - * @since 3.1 - */ -#ifdef USE_QT3 - void reset(); -#endif // USE_QT3 -#ifdef USE_QT4 - bool reset(); -#endif // USE_QT4 - - /* - * --- status, flags and internal variables --- * - */ - - /** - * Returns the class status. - * @return the class status - * @see ::SockStatus - */ - int socketStatus() const; - - /** - * Returns the related system error code - * Except for IO_LookupError errors, these are codes found in - * errno - * @return the system error code - */ - int systemError() const; - - /** - * Sets the given flags. - * @param flags the flags to be set - * @return the new flags status, or -1 if flags can no longer be set - */ - int setSocketFlags(int flags); - - /** - * Returns the current flags - * @return the current flags - * @see ::Flags - */ - int socketFlags() const; - - /** - * Sets the hostname to the given value. - * - * If this is a listening (passive) socket, the hostname is the host to which the socket - * will bind in order to listen. If you want to listen in every interface, set it - * to "*" or TQString::null. - * - * If this is a connecting (active) socket, the hostname is the host to which we will try - * to connect. - * - * @param host the hostname - * @return true on success, false on error - */ - bool setHost(const TQString& host); - - /** - * Returns the hostname. - * @return the hostname or TQString::null if no host has been set - */ - TQString host() const; - - /** - * Sets the port/service. - * @param port the port - */ - bool setPort(int port); - - /** - * Sets the port/service. - * - * In the case of Unix-domain sockets, the port is the filename for the socket. - * If the name is not an absolute path, "/tmp/" will be prepended. - * - * @param port the port - * @return true if successful, false on error (e.g. connection already established) - */ - bool setPort(const TQString& port); - - /** - * Returns the port/service. If it is a port, the string contains a number. - * @return the port or TQString::null if it has not been set. - */ - TQString port() const; - - /** - * Sets the address where we will connect to. - * - * See @ref setHost and @ref setPort for information on the parameters. - * - * @param host the hostname - * @param port port number - * @return true if successful, false on error (e.g. connection already established) - */ - bool setAddress(const TQString& host, int port); - - /** - * Sets the address where we will connect to. - * - * See @ref setHost and @ref setPort for information on the parameters. - * - * @param host the hostname - * @param serv the service - * @return true if successful, false on error (e.g. connection already established) - */ - bool setAddress(const TQString& host, const TQString& serv); - - /** - * Sets the hostname to which we will bind locally before connecting. - * @param host the hostname - * @return false if this is a passiveSocket, otherwise true. - */ - bool setBindHost(const TQString& host); - - /** - * Unsets the bind hostname. That is, don't request a binding host. - * @return true if successful, false on error (e.g. connection already established) - */ - bool unsetBindHost(); - - /** - * Returns the hostname to which the socket will be/is bound. - * @return the host or TQString::null if it has not been set. - */ - TQString bindHost() const; - - /** - * Sets the port/service to which we will bind before connecting - * @param port the port number - * @return true if successful, false on error (e.g. connection already established) - */ - bool setBindPort(int port); - - /** - * Sets the port/service to which we will bind before connecting. - * @param service the port number or service name - * @return true if successful, false on error (e.g. connection already established) - */ - bool setBindPort(const TQString& service); - - /** - * Unsets the bind port/service. - * @return true if successful, false on error (e.g. connection already established) - */ - bool unsetBindPort(); - - /** - * Returns the service to which the socket will be/is bound. - * @return the host or TQString::null if it has not been set. - */ - TQString bindPort() const; - - /** - * Sets both host and port to which we will bind the socket. Will return - * false if this is a passiveSocket. - * @param host the hostname - * @param port the port number - * @return true if successful, false on error (e.g. connection already established) - */ - bool setBindAddress(const TQString& host, int port); - - /** - * Sets both host and service to which we will bind the socket. Will return - * false if this is a passiveSocket. - * @param host the hostname - * @param service the service - * @return true if successful, false on error (e.g. connection already established) - */ - bool setBindAddress(const TQString& host, const TQString& service); - - /** - * Unsets the bind address for the socket. That means that we won't - * attempt to bind to an address before connecting. - * @return true if successful, false on error (e.g. connection already established) - */ - bool unsetBindAddress(); - - /** - * Sets the timeout value for the connection (if this is not passiveSocket) or - * acception (if it is). In the event the given function - * (connect or accept) returns due to time out, it's possible to call it again. - * - * Setting the timeout to 0 disables the timeout feature. - * - * @param secs the timeout length, in seconds - * @param usecs the timeout complement, in microseconds - * @return false if setting timeout makes no sense in the context. - */ - bool setTimeout(int secs, int usecs = 0); - - /** - * Returns the timeout value for the connection. - * @return the timeout value. 0 if there is no timeout. - */ - timeval timeout() const; - - /** - * Sets/unsets blocking mode for the socket. When non-blocking mode is enabled, - * I/O operations might return error and set errno to EWOULDBLOCK. Also, - * it's not recommended to use this when using the class signals. - * - * @param enable if true, set blocking mode. False, non-blocking mode. - * @return false on error. - */ - bool setBlockingMode(bool enable); - - /** - * Returns the current blocking mode for this socket. - * @return true if in blocking mode - */ - bool blockingMode(); - - /** - * Sets/unsets address reusing flag for this socket. - * - * This function returns true if the value was set correctly. That is NOT - * the result of the set. - * @param enable if true, set address reusable - * @return true on success, false on failure. If the socket was not yet created, - * the value is only remembered. In this case the return value is always true. - */ - bool setAddressReusable(bool enable); - - /** - * Returns whether this socket's address can be reused - * @return true if the address can be reused - */ - bool addressReusable(); - - /** - * Sets/unsets the v6-only flag for IPv6 sockets. - * - * When an IPv6 socket is in use, communication with IPv4 sockets is - * guaranteed by translating those IPv4 addresses into IPv6 ones - * (specifically, the v4-mapped addresses). This flag allows that - * behavior to be turned on and off. - * - * Note that this does not have any effect on sockets that are not - * IPv6 and the function will always return false in those cases. - * Also note that this flag defaults to off in order to accommodate - * existing applications. - * - * @param enable if true, no IPv4 translation will be performed; - * this socket will be restricted to IPv6 communication - * @returns true on success, false on failure. - * @see localAddress to find out if this is an IPv6 socket - */ - bool setIPv6Only(bool enable); - - /** - * Returns the status of the v6-only flag for IPv6 sockets. - * @returns true if the flag is set to on; false if it is not. If this - * socket is not an IPv6 one, the return value is false. - * @see setIPv6Only - */ - bool isIPv6Only(); - - /** - * Sets the buffer sizes for this socket. - * - * This implementation allows any size for both parameters. The value given - * will be interpreted as the maximum size allowed for the buffers, after - * which the I/O functions will stop buffering. The value of -1 will be - * interpreted as "unlimited" size. The value of -2 means "no change". - * - * Note: changing the buffer size to 0 for any buffer will cause the given - * buffer's to be discarded. Likewise, setting the size to a value less than - * the current size will cause the buffer to be shrunk to the wanted value, - * as if the data had been read. - * @param rsize read buffer size - * @param wsize write buffer size - * @return true on success, false if this is not possible in this state (e.g. connection - * not established yet) - */ - virtual bool setBufferSize(int rsize, int wsize = -2); - - /** - * Returns the local socket address - * @return the local socket address, can be 0 if the connection has not been established - * yet - */ - const ::KSocketAddress *localAddress(); - - /** - * Returns the peer socket address. Use KExtendedSocket::resolve() to - * resolve this to a human-readable hostname/service or port. - * @return the peer address, can be 0 if the connection has not been established yet - * or the socket is passive - */ - const ::KSocketAddress *peerAddress(); - - /** - * Returns the file descriptor - * @return the file descriptor. -1 if there is no fd yet. - */ - inline int fd() const - { return sockfd; } - - /* - * -- socket creation -- * - */ - - /** - * Performs lookup on the addresses we were given before. - * - * This will perform lookups on the bind addresses if they were given. - * @return 0 or an error. Do not rely on the values returned by lookup - * as of now. They are not specified. - */ - virtual int lookup(); - - /** - * Starts an asynchronous lookup for the addresses given. - * - * When the lookup is done, the lookupReady signal will be emitted. - * - * Note that, depending on the parameters for the lookup, this function might - * know the results without the need for blocking or queuing an - * asynchronous lookup. That means that the lookupReady signal might be - * emitted by this function, so your code should be prepared for that. - * - * One such case is when noResolve flag is set. - * If this function is able to determine the results without queuing - * and the lookup failed, this function will return -1. - * - * @return 0 on success or -1 on error. Note that - * returning 0 means that either we are in the process of doing - * lookup or that it has finished already. - */ - virtual int startAsyncLookup(); - - /** - * Cancels any on-going asynchronous lookups - */ - virtual void cancelAsyncLookup(); - - /** - * Place the socket in listen mode. The parameters are the same as for - * the system listen() call. - * @param N the queue length for pending connections - * @return 0 on success, -1 on system error (errno - * available) and -2 if this is not a passiveSocket. - */ - virtual int listen(int N = 5); // 5 is arbitrary - - /** - * Accepts an incoming connection from the socket. If this socket is in - * blocking mode, this function will block until a connection is received. - * Otherwise, it might return with error. The sock parameter will be - * initialised with the newly created socket. - * - * Upon successful acception (i.e., this function returns 0), the newly - * created socket will be already connected. The socket will be unbuffered - * and readyRead() and readyWrite() signals will be disabled. - * - * @param sock a pointer to an KExtendedSocket variable - * @return 0 on success, -1 on system error (errno set) and -2 if this is - * not a passiveSocket and -3 if this took too long (time out) - */ - virtual int accept(KExtendedSocket *&sock); - - /** - * Attempts to connect to the remote host. - * After successful connection (return value 0), the socket will be ready - * for I/O operations. Note, however, that not all signals may be enabled - * for emission by this socket: - * @li readyRead and readyWrite signals will be enabled only if - * enableRead or enableWrite were called. You can still enable - * them by calling those functions, of course. - * @li #closed() will only be sent if we are indeed reading from the input - * stream. That is, if this socket is buffering the input. See setBufferSize - * - * Note that, in general, functions inherited/overridden from KBufferedIO will only - * work on buffered sockets, like bytesAvailable and bytesToWrite. - * @return The return values are: - * @li 0: success - * @li -1: system error, errno was set accordingly - * @li -2: this socket cannot connect(); this is a passiveSocket. It can also - * mean that the function was unable to make a connection with the given - * bind address or that an asynchronous connection attempt is already - * in progress. - * @li -3: connection timed out - * - */ - virtual int connect(); - - /** - * Starts an asynchronous connect. This works exactly the same as #connect, - * except that the connection result won't be returned. - * - * Note that those signals might be emitted before this function returns, so your - * code should be prepared for that condition. - * - * You must call cancelAsyncConnect() before you delete the socket if you - * call this. Otherwise you will have crashes. - * - * @return 0 on successful queuing of the connect or -1 on error. - * If this function returns 0, then the connectionSuccess() or the - * connectionFailed() signals will be emitted. - */ - virtual int startAsyncConnect(); - - /** - * Cancels any on-going asynchronous connection attempt. - */ - virtual void cancelAsyncConnect(); - - /** - * Implementation of TQIODevice::open() pure virtual function. - * This depends on the target host address already being there. - * If this is a passiveSocket, this is identical to call listen(); else, if - * this is not a passiveSocket and no connection attempt is in progress, this - * is like connect(). If one is in progress, this function will fail. - * @param mode the open mode. Must be IO_Raw | IO_ReadWrite - * @return true if successful, false when an error occurred or the most was - * not correct - */ - virtual bool open(TQ_OpenMode mode = (TQ_OpenMode)(IO_Raw | IO_ReadWrite)); - - /** - * Closes the socket. If we have data still in the write buffer yet to be - * sent, the socket won't be closed right now. It'll be closed after we managed - * to send everything out. - * If you want to close the socket now, you may want to call flush() first, - * and then closeNow(). - */ - virtual void close(); - - /** - * Closes the socket now, discarding the contents of the write buffer, if any. - * The read buffer's contents are kept until they are emptied by read operations - * or the class is destroyed. - */ - virtual void closeNow(); - - /** - * Releases the socket and anything we have holding on it. The class cannot - * be used anymore. In other words, this is just like closeNow(), but it does - * not actually close the socket. - * - * This is useful if you just want to connect and don't need the rest of the - * class. - * - * Note that the buffers' contents will be discarded. - * - * Use of this method is discouraged, because the socket created might be such that - * normal library routines can't handle (read, write, close, etc.) - */ - virtual void release(); - - /* - * -- I/O -- - */ - - /** - * Flushes the socket buffer. You need not call this method during normal - * operation as we will try and send everything as soon as possible. - * However, if you want to make sure that data in the buffer is being sent - * at this moment, you can call this function. It will try to send as much - * data as possible, but it will stop as soon as the kernel cannot receive - * any more data, and would possibly block. - * - * By repeatedly calling this function, the behavior will be like that of - * a blocking socket. Indeed, if this function is called with the kernel not - * ready to receive data, it will block, unless this is a non-blocking socket. - * - * This function does not touch the read buffer. You can empty it by calling - * tqreadBlock() with a null destination buffer. - */ - virtual void flush(); - - /** - * Returns length of this socket. This call is not supported on sockets. - * @return the length of this socket, or 0 if unsupported - */ -#ifdef USE_QT3 - virtual inline TQ_ULONG size() const -#endif // USE_QT3 -#ifdef USE_QT4 - virtual inline qint64 size() const -#endif // USE_QT4 - { return 0; } - - /** - * Returns relative position from start. This call is not supported on sockets. - * @return the relative position from the start, or 0 if unsupported - */ - virtual inline TQ_ULONG at() const - { return 0; } - - /** - * Returns true if we are at position. This is not supported on sockets. - * @param i the position to check - * @return true if we art at the given position, or always true if unsupported. - */ - virtual inline bool at(int i) - { Q_UNUSED(i);return true; } - - /** - * Returns true if we are at the end. This is not supported on sockets, but - * we always are at the end in a socket... - * @return true if we are at the end. Always false if unsupported. - */ - virtual inline bool atEnd() const - { return false; } - - /** - * Reads a block of data from the socket. - * - * If the socket is not buffered, this function will simply call the underlying - * read method. This function will block if the socket is not on non-blocking mode - * (see setBlockingMode) and there is not enough data to be read in the - * Operating System yet. If we are in non-blocking operation, the call will - * fail in this case. - * - * However, if we are buffering, this function will instead read from the - * buffer while there is available data. This function will never block - * in buffering mode, which means that if you try to read while the buffers - * are empty, this function will always return -1 and set the system error to - * EWOULDBLOCK (aka EAGAIN), so as to mimic non-blocking operation. - * - * @param data where we will write the read data to - * @param maxlen maximum length of data to be read - * @return the number of bytes effectively read, or a negative number in case - * or an error. If the @p data param is not null, then this is also the number - * of bytes copied into that buffer. If the return value is different than - * @p maxlen, then this function encountered a situation in which no more - * bytes were available. Subsequent calls might cause this function to one - * of these behaviours: - * @li return an error, with EWOULDBLOCK system error, if we buffering - * or we are in non-blocking mode - * @li otherwise, it'll block - * This function returns 0, if the function detected end-of-file condition - * (socket was closed) - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen); - - /** - * Writes a block of data to the socket. - * - * If the socket is not buffered, this function will simply call the underlying - * write method. This means that the function might block if that method blocks - * as well. That situation is possible if we are not in non-blocking mode and - * the operating system buffers are full for this socket. If we are in - * non-blocking mode and the operating system buffers are full, this function - * will return -1 and the system error will be set to EWOULDBLOCK. - * - * If we are buffering, this function will simply transfer the data into the - * write buffer. This function will then always succeed, as long as there is - * enough room in the buffer. If the buffer size was limited and that limit - * is reached, this function will copy no more bytes than that limit. Trying - * to write with a full buffer will return -1 and set system error to - * EWOULDBLOCK. - * - * @param data the data to write - * @param len the length of data to write - * @return the number of bytes written from @p data buffer. - * The return value might be less than @p len if the output buffers cannot - * accommodate that many bytes and -1 in the case of an errro. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len); - - /** - * Peeks at a block of data from the socket. - * - * This is exactly like read, except that the data won't be flushed from the - * read buffer. - * - * If this socket is not buffered, this function will always return with - * 0 bytes copied. - * - * @param data where to store the data - * @param maxlen how many bytes to copy, at most - * @return the number of bytes copied. 0 does not mean end-of-file - * condition. - */ - virtual int peekBlock(char *data, uint maxlen); - - /** - * Reimplementation of unreadBlock() method. This is so because unreading in - * sockets doesn't make sense, so this function will always return -1 (error) - * and set the system error to ENOSYS. - * @return always -1 (error) - */ - virtual int unreadBlock(const char *data, uint len); - - /** - * Returns the number of available bytes yet to be read via readBlock - * and family of functions. - * - * Note: as of now, this only works on input-buffered sockets. This will - * change in the future - * @return The number of available bytes, or -1 on error or -2 if this call is invalid - * in the current state. - */ -#ifdef USE_QT3 - virtual int bytesAvailable() const; -#endif // USE_QT3 -#ifdef USE_QT4 - virtual qint64 bytesAvailable() const; -#endif // USE_QT4 - - /** - * Waits @p msec milliseconds for more data to be available (use 0 to - * wait forever). The return value is the amount of data available for - * read in the read buffer. - * - * @param msec milliseconds to wait - * @return -1 in case of system error and -2 in case of invalid socket - * state - */ - virtual int waitForMore(int msec); - - /** - * Gets a single character (unsigned char) from the stream. - * @return the value of the character. Negative if there was an error. - */ - virtual int getch(); - - /** - * Writes a single character (unsigned char) to the stream. All other bits - * will be ignored. - * @param ch character to write, converted to char - */ - virtual int putch(int ch); - - /** - * Unreads one character from the stream. This is not possible on sockets. - * @return always returns -1 on sockets. - */ - virtual int ungetch(int) - { return -1; } - - /** - * Toggles the emission of the readyRead signal. - * - * Note that this signal is emitted every time more data is available to be - * read, so you might get flooded with it being emitted every time, when in - * non-buffered mode. However, in buffered mode, this signal will be - * emitted only when there is data coming in from the wire. - * By default, this flag is set to false, i.e., signal not being emitted. - * @param enable if true, the signal will be emitted - */ - virtual void enableRead(bool enable); - - /** - * Toggles the emission of the readyWrite signal. - * - * Note that this signal is emitted only when the OS is ready to receive more - * data, which means that the write buffer is empty. And when that is reached, - * this signal will possibly be emitted on every loop, so you might - * want to disable it. By default, this flag is set to false. - * @param enable if true, the signal will be emitted - */ - virtual void enableWrite(bool enable); - -signals: - /** - * This signal is emitted whenever an asynchronous lookup process is done. - * The parameter @p count tells - * @param count the number of results - */ - void lookupFinished(int count); - - /** - * This signal is emitted whenever we connected asynchronously to a host. - */ - void connectionSuccess(); - - /** - * This signal is emitted whenever our asynchronous connection attempt - * failed to all hosts listed. - * @param error the errno code of the last connection attempt - */ - void connectionFailed(int error); - - /** - * This signal is emitted whenever this socket is ready to accept another - * socket. - * @see accept() - */ - void readyAccept(); - -protected: - int sockfd; // file descriptor of the socket - -protected slots: - - void socketActivityRead(); - void socketActivityWrite(); - void dnsResultsReady(); - void startAsyncConnectSlot(); - void connectionEvent(); - -protected: - - TQSocketNotifier *readNotifier(); - TQSocketNotifier *writeNotifier(); - -private: - - // protection against accidental use - KExtendedSocket(KExtendedSocket&); - KExtendedSocket& operator=(KExtendedSocket&); - - /** - * This is actually a wrapper around getaddrinfo(). - * @internal - */ - static int doLookup(const TQString& host, const TQString& serv, addrinfo& hint, - kde_addrinfo** result); - -protected: - /** - * Sets the error code - */ - void setError(int errorkind, int error); - - inline void cleanError() - { setError(IO_Ok, 0); } - - /** - * Sets the socket status. For derived classes only. - */ - void setSocketStatus(int status); - -public: - /** - * Performs resolution on the given socket address. - * - * That is, tries to resolve the raw form of the socket address into a textual - * representation. - * - * @param sock the socket address - * @param len the length of the socket address - * @param host where the hostname will be written - * @param port where the service-port will be written - * @param flags the same flags as getnameinfo() - * @returns 0 on success, nonzero otherwise. - */ - static int resolve(sockaddr* sock, ksocklen_t len, TQString& host, TQString& port, int flags = 0) KDE_DEPRECATED; - - /** - * Performs resolution on the given socket address. - * - * That is, tries to resolve the raw form of the socket address into a textual - * representation. - * - * @param sock the socket address - * @param host where the hostname will be written - * @param port where the service-port will be written - * @param flags the same flags as getnameinfo() - * @returns 0 on success, nonzero otherwise. - */ - static int resolve(::KSocketAddress* sock, TQString& host, TQString& port, int flags = 0) KDE_DEPRECATED; - - /** @deprecated - * This function is now deprecated. Please use @ref KNetwork::KResolver::resolve. - * - * Performs lookup on the given hostname/port combination and returns a list - * of matching addresses. - * The error code can be transformed into string by KExtendedSocket::strError() - * with code of IO_LookupError. - * - * IMPORTANT: the result values of the TQPtrList must be deleted after use. So, - * if you don't copy the KAddressInfo objects, the best way to assure that - * is to call setAutoDelete(true) on the list right after this function - * returns. If you do copy the results out, you must assure that the objects - * get deleted when they are not needed any more. - * - * @param host the hostname to look up - * @param port the port/service to look up - * @param flags flags to be used when looking up, Flags - * @param error pointer to a variable holding the error code - * @return a list of KAddressInfos - */ - static TQPtrList<KAddressInfo> lookup(const TQString& host, const TQString& port, int flags = 0, int *error = 0) KDE_DEPRECATED; - - /** - * Returns the local socket address - * Remember to delete the returned object when it is no longer needed. - * @param fd the file descriptor - * @return the local socket address or 0 if an error occurred. Delete after use. - */ - static ::KSocketAddress *localAddress(int fd) KDE_DEPRECATED; - - /** - * Returns the peer socket address. Use KExtendedSocket::resolve() to - * resolve this to a human-readable hostname/service or port. - * Remember to delete the returned object when it is no longer needed. - * @param fd the file descriptor - * @return the peer socket address or 0 if an error occurred. Delete after use. - */ - static ::KSocketAddress *peerAddress(int fd) KDE_DEPRECATED; - - /** - * Returns the representing text of this error code - * @param code the error code, as seen in status() - * @param syserr the system error, as from systemError() - * @return the text for the given error code - */ - static TQString strError(int code, int syserr); - - /** - * Sets/unsets address reusing flag for this socket. - * - * This function returns true if the value was set correctly. That is NOT - * the result of the set. - * @param fd the file descriptor - * @param enable if true, set address reusable - * @return true on success, false on failure. - */ - static bool setAddressReusable(int fd, bool enable) KDE_DEPRECATED; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KExtendedSocketPrivate *d; - - friend class KSocket; - friend class KServerSocket; -}; - -/** @deprecated - * This class is now deprecated. Please see @ref KNetwork::KResolver for the new API. - * - * Contains information about an internet address. It wraps addrinfo, - * see getaddrinfo(3) for more information. - */ -class KDECORE_EXPORT KAddressInfo -{ -private: - addrinfo *ai; - ::KSocketAddress *addr; - - inline KAddressInfo() : ai(0), addr(0) - { } - - // KAddressInfo(addrinfo *ai); - KAddressInfo(KAddressInfo&) { } - KAddressInfo& operator=(KAddressInfo&) { return *this; } - -public: - ~KAddressInfo(); - - /** - * Returns the KAddressInfo's KSocketAddress. - * Only valid as long as the KAddressInfo exists. - */ - inline KDE_DEPRECATED operator const ::KSocketAddress*() const - { return addr; } - - /** - * Returns the KAddressInfo's addrinfo. - */ - inline KDE_DEPRECATED operator const addrinfo&() const - { return *ai; } - - /** - * Returns a pointer to KAddressInfo's addrinfo. - * Only valid as long as the KAddressInfo exists. - */ - inline KDE_DEPRECATED operator const addrinfo*() const - { return ai; } - - /** - * Returns the KAddressInfo's KSocketAddress. - * Only valid as long as the KAddressInfo exists. - * @return the KAddressInfo's KSocketAddress. - */ - inline KDE_DEPRECATED const ::KSocketAddress* address() const - { return addr; } - - /** - * Returns the flags of the address info (see getaddrinfo(3)). - * @return the flags of the addres info. - */ - int flags() const KDE_DEPRECATED; - - /** - * Returns the family of the address info (see getaddrinfo(3)). - * @return the family of the addres info. - */ - int family() const KDE_DEPRECATED; - - /** - * Returns the socket type of the address info (see getaddrinfo(3)). - * @return the socket type of the addres info. - */ - int socktype() const KDE_DEPRECATED; - - /** - * Returns the protocol of the address info (see getaddrinfo(3)). - * @return the protocol of the addres info. - */ - int protocol() const KDE_DEPRECATED; - - - /** - * Returns the official name of the host (see getaddrinfo(3)). - * Only valid as long as the KAddressInfo exists. - * @return the official name of the host - */ - const char* canonname() const KDE_DEPRECATED; - - /** - * Returns the length of the KSocketAddress. - * @return the KSocketAddress's length - */ - inline int length() const - { if (addr) return addr->size(); return 0; } - - friend class KExtendedSocket; -}; - -#endif //Q_OS_UNIX - -#endif // KEXTSOCK_H diff --git a/kdecore/kgenericfactory.h b/kdecore/kgenericfactory.h deleted file mode 100644 index 3faaae7bf..000000000 --- a/kdecore/kgenericfactory.h +++ /dev/null @@ -1,397 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> - * - * 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 __kgenericfactory_h__ -#define __kgenericfactory_h__ - -#include <klibloader.h> -#include <ktypelist.h> -#include <kinstance.h> -#include <kgenericfactory.tcc> -#include <kglobal.h> -#include <klocale.h> -#include <kdebug.h> - -/* @internal */ -template <class T> -class KGenericFactoryBase -{ -public: - KGenericFactoryBase( const char *instanceName ) - : m_instanceName( instanceName ) - { - m_aboutData=0L; - s_self = this; - m_catalogueInitialized = false; - } - KGenericFactoryBase( const KAboutData *data ) - : m_aboutData(data) - { - s_self = this; - m_catalogueInitialized = false; - } - - virtual ~KGenericFactoryBase() - { - if ( s_instance ) - KGlobal::locale()->removeCatalogue( TQString::fromAscii( s_instance->instanceName() ) ); - delete s_instance; - s_instance = 0; - s_self = 0; - } - - static KInstance *instance(); - -protected: - virtual KInstance *createInstance() - { - if ( m_aboutData ) - return new KInstance( m_aboutData ); - if ( m_instanceName.isEmpty() ) { - kdWarning() << "KGenericFactory: instance requested but no instance name or about data passed to the constructor!" << endl; - return 0; - } - return new KInstance( m_instanceName ); - } - - virtual void setupTranslations( void ) - { - if ( instance() ) - KGlobal::locale()->insertCatalogue( TQString::fromAscii( instance()->instanceName() ) ); - } - - void initializeMessageCatalogue() - { - if ( !m_catalogueInitialized ) - { - m_catalogueInitialized = true; - setupTranslations(); - } - } - -private: - TQCString m_instanceName; - const KAboutData *m_aboutData; - bool m_catalogueInitialized; - - static KInstance *s_instance; - static KGenericFactoryBase<T> *s_self; -}; - -/* @internal */ -template <class T> -KInstance *KGenericFactoryBase<T>::s_instance = 0; - -/* @internal */ -template <class T> -KGenericFactoryBase<T> *KGenericFactoryBase<T>::s_self = 0; - -/* @internal */ -template <class T> -KInstance *KGenericFactoryBase<T>::instance() -{ - if ( !s_instance && s_self ) - s_instance = s_self->createInstance(); - return s_instance; -} - -/** - * This template provides a generic implementation of a KLibFactory , - * for use with shared library components. It implements the pure virtual - * createObject method of KLibFactory and instantiates objects of the - * specified class (template argument) when the class name argument of - * createObject matches a class name in the given hierarchy. - * - * In case you are developing a KParts component, skip this file and - * go directly to KParts::GenericFactory . - * - * Note that the class specified as template argument needs to provide - * a certain constructor: - * <ul> - * <li>If the class is derived from TQObject then it needs to have - * a constructor like: - * <code>MyClass( TQObject *parent, const char *name, - * const TQStringList &args );</code> - * <li>If the class is derived from TQWidget then it needs to have - * a constructor like: - * <code>MyWidget( TQWidget *parent, const char *name, - * const TQStringList &args);</code> - * <li>If the class is derived from KParts::Part then it needs to have - * a constructor like: - * <code>MyPart( TQWidget *parentWidget, const char *widgetName, - * TQObject *parent, const char *name, - * const TQStringList &args );</code> - * </ul> - * The args TQStringList passed to the constructor is the args string list - * that the caller passed to KLibFactory's create method. - * - * In addition upon instantiation this template provides a central - * KInstance object for your component, accessible through the - * static instance() method. The instanceName argument of the - * KGenericFactory constructor is passed to the KInstance object. - * - * The creation of the KInstance object can be customized by inheriting - * from this template class and re-implementing the virtual createInstance - * method. For example it could look like this: - * \code - * KInstance *MyFactory::createInstance() - * { - * return new KInstance( myAboutData ); - * } - * \endcode - * - * Example of usage of the whole template: - * \code - * class MyPlugin : public KParts::Plugin - * { - * Q_ OBJECT - * public: - * MyPlugin( TQObject *parent, const char *name, - * const TQStringList &args ); - * ... - * }; - * - * K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory<MyPlugin> ) - * \endcode - */ -template <class Product, class ParentType = TQObject> -class KGenericFactory : public KLibFactory, public KGenericFactoryBase<Product> -{ -public: - KGenericFactory( const char *instanceName = 0 ) - : KGenericFactoryBase<Product>( instanceName ) - {} - - /** - * @since 3.3 - */ - KGenericFactory( const KAboutData *data ) - : KGenericFactoryBase<Product>( data ) - {} - - -protected: - virtual TQObject *createObject( TQObject *parent, const char *name, - const char *className, const TQStringList &args ) - { - KGenericFactoryBase<Product>::initializeMessageCatalogue(); - return TQT_TQOBJECT((KDEPrivate::ConcreteFactory<Product, ParentType> - ::create( 0, 0, parent, name, className, args ))); - } -}; - -/** - * This template provides a generic implementation of a KLibFactory , - * for use with shared library components. It implements the pure virtual - * createObject method of KLibFactory and instantiates objects of the - * specified classes in the given typelist template argument when the class - * name argument of createObject matches a class names in the given hierarchy - * of classes. - * - * Note that each class in the specified in the typelist template argument - * needs to provide a certain constructor: - * <ul> - * <li>If the class is derived from TQObject then it needs to have - * a constructor like: - * <code>MyClass( TQObject *parent, const char *name, - * const TQStringList &args );</code> - * <li>If the class is derived from TQWidget then it needs to have - * a constructor like: - * <code>MyWidget( TQWidget *parent, const char *name, - * const TQStringList &args);</code> - * <li>If the class is derived from KParts::Part then it needs to have - * a constructor like: - * <code>MyPart( TQWidget *parentWidget, const char *widgetName, - * TQObject *parent, const char *name, - * const TQStringList &args );</code> - * </ul> - * The args TQStringList passed to the constructor is the args string list - * that the caller passed to KLibFactory's create method. - * - * In addition upon instantiation this template provides a central - * KInstance object for your component, accessible through the - * static instance() method. The instanceName argument of the - * KGenericFactory constructor is passed to the KInstance object. - * - * The creation of the KInstance object can be customized by inheriting - * from this template class and re-implementing the virtual createInstance - * method. For example it could look like this: - * \code - * KInstance *MyFactory::createInstance() - * { - * return new KInstance( myAboutData ); - * } - * \endcode - * - * Example of usage of the whole template: - * \code - * class MyPlugin : public KParts::Plugin - * { - * Q_ OBJECT - * public: - * MyPlugin( TQObject *parent, const char *name, - * const TQStringList &args ); - * ... - * }; - * - * class MyDialogComponent : public KDialogBase - * { - * Q_ OBJECT - * public: - * MyDialogComponent( TQWidget *parentWidget, const char *name, - * const TQStringList &args ); - * ... - * }; - * - * typedef K_TYPELIST_2( MyPlugin, MyDialogComponent ) Products; - * K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory<Products> ) - * \endcode - */ -template <class Product, class ProductListTail> -class KGenericFactory< KTypeList<Product, ProductListTail>, TQObject > - : public KLibFactory, - public KGenericFactoryBase< KTypeList<Product, ProductListTail> > -{ -public: - KGenericFactory( const char *instanceName = 0 ) - : KGenericFactoryBase< KTypeList<Product, ProductListTail> >( instanceName ) - {} - - /** - * @since 3.3 - */ - KGenericFactory( const KAboutData *data ) - : KGenericFactoryBase< KTypeList<Product, ProductListTail> >( data ) - {} - - -protected: - virtual TQObject *createObject( TQObject *parent, const char *name, - const char *className, const TQStringList &args ) - { - this->initializeMessageCatalogue(); - return KDEPrivate::MultiFactory< KTypeList< Product, ProductListTail > > - ::create( 0, 0, parent, name, className, args ); - } -}; - -/** - * This template provides a generic implementation of a KLibFactory , - * for use with shared library components. It implements the pure virtual - * createObject method of KLibFactory and instantiates objects of the - * specified classes in the given typelist template argument when the class - * name argument of createObject matches a class names in the given hierarchy - * of classes. - * - * Note that each class in the specified in the typelist template argument - * needs to provide a certain constructor: - * <ul> - * <li>If the class is derived from TQObject then it needs to have - * a constructor like: - * <code>MyClass( TQObject *parent, const char *name, - * const TQStringList &args );</code> - * <li>If the class is derived from TQWidget then it needs to have - * a constructor like: - * <code>MyWidget( TQWidget *parent, const char *name, - * const TQStringList &args);</code> - * <li>If the class is derived from KParts::Part then it needs to have - * a constructor like: - * <code>MyPart( TQWidget *parentWidget, const char *widgetName, - * TQObject *parent, const char *name, - * const TQStringList &args );</code> - * </ul> - * The args TQStringList passed to the constructor is the args string list - * that the caller passed to KLibFactory's create method. - * - * In addition upon instantiation this template provides a central - * KInstance object for your component, accessible through the - * static instance() method. The instanceName argument of the - * KGenericFactory constructor is passed to the KInstance object. - * - * The creation of the KInstance object can be customized by inheriting - * from this template class and re-implementing the virtual createInstance - * method. For example it could look like this: - * \code - * KInstance *MyFactory::createInstance() - * { - * return new KInstance( myAboutData ); - * } - * \endcode - * - * Example of usage of the whole template: - * \code - * class MyPlugin : public KParts::Plugin - * { - * Q_ OBJECT - * public: - * MyPlugin( TQObject *parent, const char *name, - * const TQStringList &args ); - * ... - * }; - * - * class MyDialogComponent : public KDialogBase - * { - * Q_ OBJECT - * public: - * MyDialogComponent( TQWidget *parentWidget, const char *name, - * const TQStringList &args ); - * ... - * }; - * - * typedef K_TYPELIST_2( MyPlugin, MyDialogComponent ) Products; - * K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory<Products> ) - * \endcode - */ -template <class Product, class ProductListTail, - class ParentType, class ParentTypeListTail> -class KGenericFactory< KTypeList<Product, ProductListTail>, - KTypeList<ParentType, ParentTypeListTail> > - : public KLibFactory, - public KGenericFactoryBase< KTypeList<Product, ProductListTail> > -{ -public: - KGenericFactory( const char *instanceName = 0 ) - : KGenericFactoryBase< KTypeList<Product, ProductListTail> >( instanceName ) - {} - /** - * @since 3.3 - */ - KGenericFactory( const KAboutData *data ) - : KGenericFactoryBase< KTypeList<Product, ProductListTail> >( data ) - {} - - -protected: - virtual TQObject *createObject( TQObject *parent, const char *name, - const char *className, const TQStringList &args ) - { - this->initializeMessageCatalogue(); - return KDEPrivate::MultiFactory< KTypeList< Product, ProductListTail >, - KTypeList< ParentType, ParentTypeListTail > > - ::create( 0, 0, parent, name, - className, args ); - } -}; - - -/* - * vim: et sw=4 - */ - -#endif - diff --git a/kdecore/kgenericfactory.tcc b/kdecore/kgenericfactory.tcc deleted file mode 100644 index c3afb1b5a..000000000 --- a/kdecore/kgenericfactory.tcc +++ /dev/null @@ -1,272 +0,0 @@ -/* - * The Type2Type template and the Inheritance Detector are from - * <http://www.cuj.com/experts/1810/alexandr.htm> - * (c) Andrei Alexandrescu <andrei@metalanguage.com> and - * free for any use. - * - * The rest is: - * Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> - * - * 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. - */ -// -*- mode: c++ -*- -// -// W A R N I N G -// ------------- -// -// This file is not part of the KDE API. It exists for the convenience -// of KGenericFactory. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef KGENERICFACTORY_TCC -#define KGENERICFACTORY_TCC - -#include <tqmetaobject.h> -#include <ktypelist.h> - -namespace KParts -{ - class Part; -} - -namespace KDEPrivate -{ - template <class Base> - struct InheritanceDetector - { - typedef char ConversionExists; - struct ConversionDoesNotExist { char bleh[ 2 ]; }; - static ConversionExists test( Base * ); - static ConversionDoesNotExist test( ... ); - }; - - /* Simon: KCC doesn't eat the generic InheritanceDetector<Base>. - Instead we have to use concrete specializations :-( - - template <class Base, class Derived> - struct InheritanceTest - { - typedef Derived * DerivedPtr; - enum { Result = sizeof( InheritanceDetector<Base>::test( DerivedPtr() ) ) == - sizeof( InheritanceDetector<Base>::ConversionExists ) }; - }; - */ - - template <class Derived> - struct TQWidgetInheritanceTest - { - typedef Derived * DerivedPtr; - enum { Result = sizeof( InheritanceDetector<TQWidget>::test( DerivedPtr() ) ) == - sizeof( InheritanceDetector<TQWidget>::ConversionExists ) }; - }; - - template <class Derived> - struct PartInheritanceTest - { - typedef Derived * DerivedPtr; - enum { Result = sizeof( InheritanceDetector<KParts::Part>::test( DerivedPtr() ) ) == - sizeof( InheritanceDetector<KParts::Part>::ConversionExists ) }; - }; - - - template <bool condition, typename Then, typename Else> - struct If - { - typedef Else Result; - }; - - template <typename Then, typename Else> - struct If<true, Then, Else> - { - typedef Then Result; - }; - - // a small helper template, to ease the overloading done in ConcreteFactory - // to choose the right constructor for the given class. - template <class T> - struct Type2Type - { - typedef T OriginalType; - }; - - // this template is called from the MultiFactory one. It instantiates - // the given class if the className matches. Instantiating is done by - // calling the right constructor (a parentwidget/widgetname/parent/name - // one for Parts, a parentwidget/widgetname one for widgets and last - // but not least the standard default constructor of parent/name . - // the choice of the right constructor is done using an ordered inheritance - // test. - template <class Product, class ParentType = TQObject> - class ConcreteFactory - { - public: - typedef typename If< PartInheritanceTest< Product >::Result, - KParts::Part, - typename If< TQWidgetInheritanceTest< Product >::Result, - TQWidget, TQObject >::Result >::Result BaseType; - - static inline Product *create( TQWidget *parentWidget, const char *widgetName, - TQObject *parent, const char *name, - const char *className, const TQStringList &args ) - { - TQMetaObject *tqmetaObject = Product::tqstaticMetaObject(); - while ( tqmetaObject ) - { - if ( !qstrcmp( className, tqmetaObject->className() ) ) - return create( parentWidget, widgetName, - parent, name, args, Type2Type<BaseType>() ); - tqmetaObject = tqmetaObject->tqsuperClass(); - } - return 0; - } - private: - typedef typename If< TQWidgetInheritanceTest<ParentType>::Result, - ParentType, TQWidget >::Result WidgetParentType; - - static inline Product *create( TQWidget *parentWidget, const char *widgetName, - TQObject *parent, const char *name, - const TQStringList &args, Type2Type<KParts::Part> ) - { - return new Product( parentWidget, widgetName, parent, name, args ); - } - - static inline Product *create( TQWidget* /*parentWidget*/, const char* /*widgetName*/, - TQObject *parent, const char *name, - const TQStringList &args, Type2Type<TQWidget> ) - { - - WidgetParentType *p = dynamic_cast<WidgetParentType *>( static_cast<TQT_BASE_OBJECT_NAME*>(parent) ); - if ( parent && !p ) - return 0; - return new Product( p, name, args ); - } - - static inline Product *create( TQWidget* /*parentWidget*/, const char* /*widgetName*/, - TQObject *parent, const char *name, - const TQStringList &args, Type2Type<TQObject> ) - { - ParentType *p = dynamic_cast<ParentType *>( static_cast<TQT_BASE_OBJECT_NAME*>(parent) ); - if ( parent && !p ) - return 0; - return new Product( p, name, args ); - } - }; - - // this template is used to iterate through the typelist and call the - // concrete factory for each type. the specializations of this template - // are the ones actually being responsible for iterating, in fact. - template <class Product, class ParentType = TQObject> - class MultiFactory - { - public: - inline static TQObject *create( TQWidget *parentWidget, const char *widgetName, - TQObject *parent, const char *name, - const char *className, - const TQStringList &args ) - { - return static_cast<TQObject*>(static_cast<QObject*>(ConcreteFactory<Product, ParentType>::create( parentWidget, widgetName, - parent, name, className, - args ))); - } - - }; - - // this specialized template we 'reach' at the end of a typelist - // (the last item in a typelist is the NullType) - template <> - class MultiFactory<KDE::NullType> - { - public: - inline static TQObject *create( TQWidget *, const char *, TQObject *, - const char *, const char *, - const TQStringList & ) - { return 0; } - }; - - // this specialized template we 'reach' at the end of a typelist - // (the last item in a typelist is the NullType) - template <> - class MultiFactory<KDE::NullType, KDE::NullType> - { - public: - inline static TQObject *create( TQWidget *, const char *, TQObject *, - const char *, const char *, - const TQStringList & ) - { return 0; } - }; - - template <class Product, class ProductListTail> - class MultiFactory< KTypeList<Product, ProductListTail>, TQObject > - { - public: - inline static TQObject *create( TQWidget *parentWidget, const char *widgetName, - TQObject *parent, const char *name, - const char *className, - const TQStringList &args ) - { - // try with the head of the typelist first. the head is always - // a concrete type. - TQObject *object = MultiFactory<Product>::create( parentWidget, widgetName, - parent, name, className, - args ); - - if ( !object ) - object = MultiFactory<ProductListTail>::create( parentWidget, widgetName, - parent, name, className, - args ); - - return object; - } - }; - - template <class Product, class ProductListTail, - class ParentType, class ParentTypeListTail> - class MultiFactory< KTypeList<Product, ProductListTail>, - KTypeList<ParentType, ParentTypeListTail> > - { - public: - inline static TQObject *create( TQWidget *parentWidget, const char *widgetName, - TQObject *parent, const char *name, - const char *className, - const TQStringList &args ) - { - // try with the head of the typelist first. the head is always - // a concrete type. - TQObject *object = MultiFactory<Product, ParentType> - ::create( parentWidget, widgetName, - parent, name, className, args ); - - // if that failed continue by advancing the typelist, calling this - // template specialization recursively (with T2 being a typelist) . - // at the end we reach the nulltype specialization. - if ( !object ) - object = MultiFactory<ProductListTail, ParentTypeListTail> - ::create( parentWidget, widgetName, - parent, name, className, args ); - - return object; - } - }; -} - -#endif - -/* - * vim: et sw=4 - */ diff --git a/kdecore/kglobal.cpp b/kdecore/kglobal.cpp deleted file mode 100644 index d64974be4..000000000 --- a/kdecore/kglobal.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Sirtaj Singh Kanq <taj@kde.org> - - 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. -*/ -/* -* kglobal.cpp -- Implementation of class KGlobal. -* Author: Sirtaj Singh Kang -* Version: $Id$ -* Generated: Sat May 1 02:08:43 EST 1999 -*/ - -#include <tqglobal.h> -#include <tqdict.h> -#include <tqptrlist.h> -#include "kglobal.h" - -#include <kapplication.h> -#include <kaboutdata.h> -#include <kdebug.h> -#include <kconfig.h> -#include <klocale.h> -#include <kcharsets.h> -#include <kiconloader.h> -#include <kstandarddirs.h> -#include <kinstance.h> -#include "kstaticdeleter.h" - -#include <tqfont.h> - -#ifndef NDEBUG -#define MYASSERT(x) if (!x) \ - qFatal("Fatal error: you need to have a KInstance object before\n" \ - "you do anything that requires it! Examples of this are config\n" \ - "objects, standard directories or translations."); -#else -#define MYASSERT(x) /* nope */ -#endif - -static void kglobal_init(); - -KStandardDirs *KGlobal::dirs() -{ - MYASSERT(_instance); - - return _instance->dirs(); -} - -KConfig *KGlobal::config() -{ - MYASSERT(_instance); - - return _instance->config(); -} - -KSharedConfig *KGlobal::sharedConfig() -{ - MYASSERT(_instance); - - return _instance->sharedConfig(); -} - -KIconLoader *KGlobal::iconLoader() -{ - MYASSERT(_instance); - - return _instance->iconLoader(); -} - -KInstance *KGlobal::instance() -{ - MYASSERT(_instance); - return _instance; -} - -KLocale *KGlobal::locale() -{ - if( _locale == 0 ) { - if (!_instance) - return 0; - kglobal_init(); - - // will set _locale if it works - otherwise 0 is returned - KLocale::initInstance(); - if( _instance->aboutData()) - _instance->aboutData()->translateInternalProgramName(); - } - - return _locale; -} - -KCharsets *KGlobal::charsets() -{ - if( _charsets == 0 ) { - _charsets =new KCharsets(); - kglobal_init(); - } - - return _charsets; -} - -void KGlobal::setActiveInstance(KInstance *i) -{ - _activeInstance = i; - if (i && _locale) - _locale->setActiveCatalogue(TQString::fromUtf8(i->instanceName())); -} - -/** - * Create a static QString - * - * To be used inside functions(!) like: - * static const TQString &myString = KGlobal::staticQString("myText"); - */ -const TQString & -KGlobal::staticQString(const char *str) -{ - return staticQString(TQString::tqfromLatin1(str)); -} - -class KStringDict : public TQDict<TQString> -{ -public: - KStringDict() : TQDict<TQString>(139) { } -}; - -/** - * Create a static QString - * - * To be used inside functions(!) like: - * static const TQString &myString = KGlobal::staticQString(i18n("My Text")); - */ -const TQString & -KGlobal::staticQString(const TQString &str) -{ - if (!_stringDict) { - _stringDict = new KStringDict; - _stringDict->setAutoDelete( true ); - kglobal_init(); - } - TQString *result = _stringDict->find(str); - if (!result) - { - result = new TQString(str); - _stringDict->insert(str, result); - } - return *result; -} - -class KStaticDeleterList: public TQPtrList<KStaticDeleterBase> -{ -public: - KStaticDeleterList() { } -}; - -void -KGlobal::registerStaticDeleter(KStaticDeleterBase *obj) -{ - if (!_staticDeleters) - kglobal_init(); - if (_staticDeleters->find(obj) == -1) - _staticDeleters->append(obj); -} - -void -KGlobal::unregisterStaticDeleter(KStaticDeleterBase *obj) -{ - if (_staticDeleters) - _staticDeleters->removeRef(obj); -} - -void -KGlobal::deleteStaticDeleters() -{ - if (!KGlobal::_staticDeleters) - return; - - for(;_staticDeleters->count();) - { - _staticDeleters->take(0)->destructObject(); - } - - delete KGlobal::_staticDeleters; - KGlobal::_staticDeleters = 0; -} - -// The Variables - -KStringDict *KGlobal::_stringDict = 0; -KInstance *KGlobal::_instance = 0; -KInstance *KGlobal::_activeInstance = 0; -KLocale *KGlobal::_locale = 0; -KCharsets *KGlobal::_charsets = 0; -KStaticDeleterList *KGlobal::_staticDeleters = 0; - -#ifdef WIN32 -#include <windows.h> -static void kglobal_freeAll(); -BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID impLoad ) -{ - if (reason == DLL_PROCESS_DETACH) - kglobal_freeAll(); - return TRUE; -} -#else -__attribute__((destructor)) -#endif -static void kglobal_freeAll() -{ - delete KGlobal::_locale; - KGlobal::_locale = 0; - delete KGlobal::_charsets; - KGlobal::_charsets = 0; - delete KGlobal::_stringDict; - KGlobal::_stringDict = 0; - KGlobal::deleteStaticDeleters(); - // so that we don't hold a reference and see memory leaks :/ - KGlobal::setActiveInstance(0); -} - -static void kglobal_init() -{ - if (KGlobal::_staticDeleters) - return; - - KGlobal::_staticDeleters = new KStaticDeleterList; -} - -int kasciistricmp( const char *str1, const char *str2 ) -{ - const unsigned char *s1 = (const unsigned char *)str1; - const unsigned char *s2 = (const unsigned char *)str2; - int res; - unsigned char c1, c2; - - if ( !s1 || !s2 ) - return s1 ? 1 : (s2 ? -1 : 0); - if ( !*s1 || !*s2 ) - return *s1 ? 1 : (*s2 ? -1 : 0); - for (;*s1; ++s1, ++s2) { - c1 = *s1; c2 = *s2; - if (c1 >= 'A' && c1 <= 'Z') - c1 += 'a' - 'A'; - if (c2 >= 'A' && c2 <= 'Z') - c2 += 'a' - 'A'; - - if ((res = c1 - c2)) - break; - } - return *s1 ? res : (*s2 ? -1 : 0); -} - diff --git a/kdecore/kglobal.h b/kdecore/kglobal.h deleted file mode 100644 index 08e12767e..000000000 --- a/kdecore/kglobal.h +++ /dev/null @@ -1,237 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Sirtaj Singh Kanq <taj@kde.org> - - 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 _KGLOBAL_H -#define _KGLOBAL_H - -#include "kdelibs_export.h" -#include <kinstance.h> // KDE4: class KInstance is enough here - -class KCharsets; -class KConfig; -class KSharedConfig; -class KIconLoader; -class KLocale; -class KStandardDirs; -class KStaticDeleterBase; -class KStaticDeleterList; -class KStringDict; -class TQString; - -/** - * Access to the KDE global objects. - * KGlobal provides you with pointers of many central - * objects that exist only once in the process. It is also - * responsible for managing instances of KStaticDeleterBase. - * - * @see KStaticDeleterBase - * @author Sirtaj Singh Kang (taj@kde.org) - */ -class KDECORE_EXPORT KGlobal -{ -public: - - /** - * Returns the global instance. There is always at least - * one instance of a component in one application (in most - * cases the application itself). - * @return the global instance - */ - static KInstance *instance(); - - /** - * Returns the application standard dirs object. - * @return the global standard dir object - */ - static KStandardDirs *dirs(); - - /** - * Returns the general config object. - * @return the global configuration object. - */ - static KConfig *config(); - - /** - * Returns the general config object. - * @return the global configuration object. - */ - static KSharedConfig *sharedConfig(); - - /** - * Returns an iconloader object. - * @return the global iconloader object - */ - static KIconLoader *iconLoader(); - - /** - * Returns the global locale object. - * @return the global locale object - */ - static KLocale *locale(); - - /** - * The global charset manager. - * @return the global charset manager - */ - static KCharsets *charsets(); - - /** - * Creates a static TQString. - * - * To be used inside functions(!) like: - * \code - * static const TQString &myString = KGlobal::staticQString("myText"); - * \endcode - * - * !!! Do _NOT_ use: !!! - * \code - * static TQString myString = KGlobal::staticQString("myText"); - * \endcode - * This creates a static object (instead of a static reference) - * and as you know static objects are EVIL. - * @param str the string to create - * @return the static string - */ - static const TQString &staticQString(const char *str); - - /** - * Creates a static TQString. - * - * To be used inside functions(!) like: - * \code - * static const TQString &myString = KGlobal::staticQString(i18n("My Text")); - * \endcode - * - * !!! Do _NOT_ use: !!! - * \code - * static TQString myString = KGlobal::staticQString(i18n("myText")); - * \endcode - * This creates a static object (instead of a static reference) - * and as you know static objects are EVIL. - * @param str the string to create - * @return the static string - */ - static const TQString &staticQString(const TQString &str); - - /** - * Registers a static deleter. - * @param d the static deleter to register - * @see KStaticDeleterBase - * @see KStaticDeleter - */ - static void registerStaticDeleter(KStaticDeleterBase *d); - - /** - * Unregisters a static deleter. - * @param d the static deleter to unregister - * @see KStaticDeleterBase - * @see KStaticDeleter - */ - static void unregisterStaticDeleter(KStaticDeleterBase *d); - - /** - * Calls KStaticDeleterBase::destructObject() on all - * registered static deleters and unregisters them all. - * @see KStaticDeleterBase - * @see KStaticDeleter - */ - static void deleteStaticDeleters(); - - //private: - static KStringDict *_stringDict; - static KInstance *_instance; - static KLocale *_locale; - static KCharsets *_charsets; - static KStaticDeleterList *_staticDeleters; - - /** - * The instance currently active (useful in a multi-instance - * application, such as a KParts application). - * Don't use this - it's mainly for KAboutDialog and KBugReport. - * @internal - */ - static void setActiveInstance(KInstance *d); - static KInstance *activeInstance() { return _activeInstance; } - - static KInstance *_activeInstance; -}; - -/** - * \relates KGlobal - * A typesafe function to find the minimum of the two arguments. - */ -#define KMIN(a,b) kMin(a,b) -/** - * \relates KGlobal - * A typesafe function to find the maximum of the two arguments. - */ -#define KMAX(a,b) kMax(a,b) -/** - * \relates KGlobal - * A typesafe function to determine the absolute value of the argument. - */ -#define KABS(a) kAbs(a) -/** - * \relates KGlobal - * A typesafe function that returns x if it's between low and high values. - * low if x is smaller than then low and high if x is bigger than high. - */ -#define KCLAMP(x,low,high) kClamp(x,low,high) - -// XXX KDE4: Make kMin, kMax and kClamp return "T" instead of "const T &"! -template<class T> -inline const T& kMin (const T& a, const T& b) { return a < b ? a : b; } - -template<class T> -inline const T& kMax (const T& a, const T& b) { return b < a ? a : b; } - -template<class T> -inline T kAbs (const T& a) { return a < 0 ? -a : a; } - -template<class T> -inline const T& kClamp( const T& x, const T& low, const T& high ) -{ - if ( x < low ) return low; - else if ( high < x ) return high; - else return x; -} - -/** - * Locale-independent qstricmp. Use this for comparing ascii keywords - * in a case-insensitive way. - * qstricmp fails with e.g. the Turkish locale where 'I'.lower() != 'i' - * @since 3.4 - */ -int KDECORE_EXPORT kasciistricmp( const char *str1, const char *str2 ); - - -/** - * \mainpage The KDE Core Functionality Library - * - * All KDE programs use this library to provide basic functionality such - * as the configuration system, IPC, internationalization and locale - * support, site-independent access to the filesystem and a large number - * of other (but no less important) things. - * - * All KDE applications should link to the tdecore library. Also, using a - * KApplication derived class instead of TQApplication is almost - * mandatory if you expect your application to behave nicely within the - * KDE environment. - */ - -#endif // _KGLOBAL_H - diff --git a/kdecore/kglobalaccel.cpp b/kdecore/kglobalaccel.cpp deleted file mode 100644 index 689b08616..000000000 --- a/kdecore/kglobalaccel.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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. -*/ - -#include "kglobalaccel.h" -#ifdef Q_WS_X11 -#include "kglobalaccel_x11.h" -#elif defined(Q_WS_WIN) -#include "kglobalaccel_win.h" -#elif defined(Q_WS_MACX) -#include "kglobalaccel_mac.h" -#else -#include "kglobalaccel_emb.h" -#endif - -#include <tqstring.h> -#include "kaccelbase.h" -#include <kdebug.h> -#include <kshortcut.h> -#include <klocale.h> - -//---------------------------------------------------- - -KGlobalAccel::KGlobalAccel( TQObject* pParent, const char* psName ) -: TQObject( pParent, psName ) -{ - kdDebug(125) << "KGlobalAccel(): this = " << this << endl; - d = new KGlobalAccelPrivate(); -} - -KGlobalAccel::~KGlobalAccel() -{ - kdDebug(125) << "~KGlobalAccel(): this = " << this << endl; - delete d; -} - -/* -void KGlobalAccel::clear() - { d->clearActions(); } -*/ -KAccelActions& KGlobalAccel::actions() - { return d->KAccelBase::actions(); } - -const KAccelActions& KGlobalAccel::actions() const - { return d->KAccelBase::actions(); } - -bool KGlobalAccel::isEnabled() - { return ((KAccelBase*)d)->isEnabled(); } - -void KGlobalAccel::setEnabled( bool bEnabled ) - { d->setEnabled( bEnabled ); } - -void KGlobalAccel::suspend( bool s ) - { d->suspend( s ); } - -void KGlobalAccel::blockShortcuts( bool block ) - { KGlobalAccelPrivate::blockShortcuts( block ); } - -void KGlobalAccel::disableBlocking( bool disable ) - { d->disableBlocking( disable ); } - -KAccelAction* KGlobalAccel::insert( const TQString& sAction, const TQString& sDesc, const TQString& sHelp, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable, bool bEnabled ) -{ - return d->insert( sAction, sDesc, sHelp, - cutDef3, cutDef4, - pObjSlot, psMethodSlot, - bConfigurable, bEnabled ); -} - -KAccelAction* KGlobalAccel::insert( const TQString& sName, const TQString& sDesc ) - { return d->insert( sName, sDesc ); } -bool KGlobalAccel::updateConnections() - { return d->updateConnections(); } - -bool KGlobalAccel::remove( const TQString& sAction ) - { return d->remove( sAction ); } - -const KShortcut& KGlobalAccel::shortcut( const TQString& sAction ) const -{ - const KAccelAction* pAction = d->KAccelBase::actions().actionPtr( sAction ); - return (pAction) ? pAction->shortcut() : KShortcut::null(); -} - -bool KGlobalAccel::setShortcut( const TQString& sAction, const KShortcut& cut ) - { return d->setShortcut( sAction, cut ); } -bool KGlobalAccel::setSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot ) - { return d->setActionSlot( sAction, pObjSlot, psMethodSlot ); } -TQString KGlobalAccel::label( const TQString& sAction ) const -{ - const KAccelAction* pAction = d->KAccelBase::actions().actionPtr( sAction ); - return (pAction) ? pAction->label() : TQString(); -} -bool KGlobalAccel::setActionEnabled( const TQString& sAction, bool bEnable ) -{ - return d->setActionEnabled( sAction, bEnable ); -} - -const TQString& KGlobalAccel::configGroup() const - { return d->configGroup(); } -// for kdemultimedia/kmix -void KGlobalAccel::setConfigGroup( const TQString& s ) - { d->setConfigGroup( s ); } - -bool KGlobalAccel::readSettings( KConfigBase* pConfig ) - { d->readSettings( pConfig ); return true; } -bool KGlobalAccel::writeSettings( KConfigBase* pConfig ) const - { d->writeSettings( pConfig ); return true; } -bool KGlobalAccel::writeSettings( KConfigBase* pConfig, bool bGlobal ) const -{ - d->setConfigGlobal( bGlobal ); - d->writeSettings( pConfig ); - return true; -} - -bool KGlobalAccel::useFourModifierKeys() - { return KAccelAction::useFourModifierKeys(); } - -void KGlobalAccel::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kglobalaccel.moc" diff --git a/kdecore/kglobalaccel.h b/kdecore/kglobalaccel.h deleted file mode 100644 index 4eee753dc..000000000 --- a/kdecore/kglobalaccel.h +++ /dev/null @@ -1,239 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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 _KGLOBALACCEL_H_ -#define _KGLOBALACCEL_H_ - -#include <tqobject.h> -#include <kshortcut.h> - -class TQPopupMenu; -class TQWidget; -class KAccelAction; -class KAccelActions; -class KConfigBase; - -class KGlobalAccelPrivate; - -/** -* KGlobalAccel allows you to have global accelerators that are independent of -* the focused window. Unlike KAccel it does not matter which window is -* currently active. -* -* @see KAccel -* @see KAccelShortcutList -* @see KKeyChooser -* @see KKeyDialog -* @short Configurable global shortcut support -*/ -class KDECORE_EXPORT KGlobalAccel : public TQObject -{ - Q_OBJECT - public: - /** - * Creates a new KGlobalAccel object with the given pParent and - * psName. - * @param pParent the parent of the QObject - * @param psName the name of the QObject - */ - KGlobalAccel( TQObject* pParent, const char* psName = 0 ); - virtual ~KGlobalAccel(); - - /** - * Checks whether the accelerators are enabled. - * @return true if the KGlobalAccel is enabled - */ - bool isEnabled(); - - /** - * Enables or disables the KGlobalAccel - * @param bEnabled true if the KGlobalAccel should be enabled, false if it - * should be disabled. - */ - void setEnabled( bool bEnabled ); - - /** - * Create an accelerator action. - * - * Usage: - *\code - * insert( "Do Something", i18n("Do Something"), - * i18n("This action allows you to do something really great with this program to " - * "the currently open document."), - * ALT+CTRL+Key_Q, KKey::QtWIN+CTRL+Key_Q, this, TQT_SLOT(slotDoSomething()) ); - *\endcode - * - * @param sAction The internal name of the action. - * @param sLabel An i18n'ized short description of the action displayed when - * using KKeyChooser to reconfigure the shortcuts. - * @param sWhatsThis An extended description of the action. - * @param cutDef3 The default 3 modifier scheme shortcut. - * @param cutDef4 The default 4 modifier scheme shortcut. - * @param pObjSlot Pointer to the slot object. - * @param psMethodSlot Pointer to the slot method. - * @param bConfigurable Allow the user to change this shortcut if set to 'true'. - * @param bEnabled The action will be activated by the shortcut if set to 'true'. - */ - KAccelAction* insert( const TQString& sAction, const TQString& sLabel, const TQString& sWhatsThis, - const KShortcut& cutDef3, const KShortcut& cutDef4, - const TQObject* pObjSlot, const char* psMethodSlot, - bool bConfigurable = true, bool bEnabled = true ); - - /** - * Removes the accelerator action identified by the name. - * Remember to also call updateConnections(). - * @param sAction the name of the action to remove - * @since 3.1 - */ - bool remove( const TQString& sAction ); - - /** - * Use this to insert a label into the action list. This will be - * displayed when the user configures shortcuts. - * @param sName of the of the action to insert - * @param sLabel a user-readable (i18n!) name for the action - * @return the KAccelAction of the action - */ - KAccelAction* insert( const TQString& sName, const TQString& sLabel ); - - /** - * Updates the connections of the accelerations after changing them. - * @return true if successful, false otherwise - */ - bool updateConnections(); - - /** - * Return the shortcut associated with the action named by @p sAction. - * @param sAction the name of the action - * @return the shortcut. If the action does not exist a null shortcut will be returned. - */ - const KShortcut& shortcut( const TQString& sAction ) const; - /** - * Set the shortcut to be associated with the action named by @p sAction. - * @param sAction the name of the action - * @param shortcut the shortcut for the action - * @return true if successful, false otherwise - */ - bool setShortcut( const TQString& sAction, const KShortcut &shortcut ); - /** - * Set the slot to be called when the shortcut of the action named - * by @p sAction is pressed. - * @param sAction the name of the action - * @param pObjSlot the receiver of the signal - * @param psMethodSlot the slot to receive the signal - * @return true if successful, false otherwise - */ - bool setSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot ); - - /** - * Enables or disables action @p sAction. - * @since 3.4 - */ - bool setActionEnabled( const TQString& sAction, bool bEnable ); - /** - * Return the label (i18n'ized short description) associated with the action named by @p sAction. - * @param sAction the name of the action - * @return the label - * @since 3.3 - */ - TQString label( const TQString& sAction ) const; - - /** - * Returns the configuration group that is used to save the accelerators. - * @return the configuration group - * @see KConfig - */ - const TQString& configGroup() const; - - /** - * Sets the configuration group that is used to save the accelerators. - * @param cg the configuration group - * @see KConfig - */ - void setConfigGroup( const TQString &cg ); - - /** - * Read all shortcuts from @p pConfig, or (if @p pConfig - * is zero) from the application's configuration file - * KGlobal::config(). - * @param pConfig the configuration file to read from, or 0 for the application - * configuration file - * @return true if successful, false otherwise - */ - bool readSettings( KConfigBase* pConfig = 0 ); - - /** - * Write the current shortcuts to @p pConfig, - * or (if @p pConfig is zero) to the application's - * configuration file. - * @param pConfig the configuration file to read from, or 0 for the application - * configuration file - * @return true if successful, false otherwise - * @since 3.1 - */ - bool writeSettings( KConfigBase* pConfig = 0 ) const; - // BCI: merge these two writeSettings methods in KDE 4.0 - /** - * Write the current shortcuts to @p pConfig, - * or (if @p pConfig is zero) to the application's - * configuration file. Alternatively, if bGlobal is true, then write - * to kdeglobals. - * @param pConfig the configuration file to read from, or 0 for the application - * configuration file - * @param bGlobal if true write the configuration to the kde global settings - * @return true if successful, false otherwise - */ - bool writeSettings( KConfigBase* pConfig, bool bGlobal ) const; - - /** - * @internal -- this a wrapper function to - * KAccelActions::useFourModifierKeys(). - */ - static bool useFourModifierKeys(); - - /** - * @internal - */ - static void blockShortcuts( bool block ); - /** - * @internal - */ - void disableBlocking( bool disable ); - - /** - * @internal - */ - // like setEnabled(), but doesn't ungrab (see in KGlobalAccelPrivate) - void suspend( bool s ); - -private: - - KAccelActions& actions(); - const KAccelActions& actions() const; - - friend class KGlobalAccelPrivate; - friend class KAccelShortcutList; -protected: - /** \internal */ - virtual void virtual_hook( int id, void* data ); -private: - class KGlobalAccelPrivate* d; -}; - -#endif // _KGLOBALACCEL_H_ diff --git a/kdecore/kglobalaccel_emb.h b/kdecore/kglobalaccel_emb.h deleted file mode 100644 index 859a53362..000000000 --- a/kdecore/kglobalaccel_emb.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _KGLOBALACCEL_EMB_H -#define _KGLOBALACCEL_EMB_H - -#include "kaccelbase.h" -#include "kshortcut.h" - -class KGlobalAccelPrivate -{ -public: - KGlobalAccelPrivate(); - - virtual void setEnabled( bool bEnabled ); - - virtual bool connectKey( KAccelAction&, KKeySequence ); - virtual bool disconnectKey( KAccelAction&, KKeySequence ); -}; - -#endif // _KGLOBALACCEL_EMB_H diff --git a/kdecore/kglobalaccel_mac.h b/kdecore/kglobalaccel_mac.h deleted file mode 100644 index 1bed4f3cc..000000000 --- a/kdecore/kglobalaccel_mac.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _KGLOBALACCEL_MAC_H -#define _KGLOBALACCEL_MAC_H - -#include <tqwidget.h> - -#include "kshortcut.h" -#include "kaccelbase.h" - -class KGlobalAccelPrivate: public KAccelBase -{ -public: - KGlobalAccelPrivate() - : KAccelBase(KAccelBase::NATIVE_KEYS) - {} - - // reimplemented pure virtuals - void setEnabled( bool bEnabled ) - { Q_UNUSED(bEnabled); } - bool emitSignal( Signal signal ) - { Q_UNUSED(signal); return false; } - bool connectKey( KAccelAction& action, const KKeyServer::Key& key) - { Q_UNUSED(action); Q_UNUSED(key); return false; } - bool connectKey( const KKeyServer::Key& key) - { Q_UNUSED(key); return false; } - bool disconnectKey( KAccelAction&, const KKeyServer::Key& key) - { Q_UNUSED(key); return false; } - bool disconnectKey( const KKeyServer::Key& ) - { return false; } -}; - -#endif // _KGLOBALACCEL_EMB_H diff --git a/kdecore/kglobalaccel_win.cpp b/kdecore/kglobalaccel_win.cpp deleted file mode 100644 index 674f09671..000000000 --- a/kdecore/kglobalaccel_win.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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. -*/ - -#include "config.h" - -#include <tqwindowdefs.h> -#ifdef Q_WS_WIN - -#include "kglobalaccel_win.h" -#include "kglobalaccel.h" -#include "kkeyserver_x11.h" - -#include <tqpopupmenu.h> -#include <tqregexp.h> -#include <tqwidget.h> -#include <tqmetaobject.h> -#include <private/qucomextra_p.h> -#include <kapplication.h> -#include <kdebug.h> -#include <kkeynative.h> - -//---------------------------------------------------- - -static TQValueList< KGlobalAccelPrivate* >* all_accels = 0; - -KGlobalAccelPrivate::KGlobalAccelPrivate() -: KAccelBase( KAccelBase::NATIVE_KEYS ) -, m_blocked( false ) -, m_blockingDisabled( false ) -{ - if( all_accels == NULL ) - all_accels = new TQValueList< KGlobalAccelPrivate* >; - all_accels->append( this ); - m_sConfigGroup = "Global Shortcuts"; -// kapp->installX11EventFilter( this ); -} - -KGlobalAccelPrivate::~KGlobalAccelPrivate() -{ - // TODO: Need to release all grabbed keys if the main window is not shutting down. - //for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) { - // const CodeMod& codemod = it.key(); - //} - all_accels->remove( this ); - if( all_accels->count() == 0 ) { - delete all_accels; - all_accels = NULL; - } -} - -void KGlobalAccelPrivate::setEnabled( bool bEnable ) -{ - m_bEnabled = bEnable; - //updateConnections(); -} - -void KGlobalAccelPrivate::blockShortcuts( bool block ) -{ - if( all_accels == NULL ) - return; - for( TQValueList< KGlobalAccelPrivate* >::ConstIterator it = all_accels->begin(); - it != all_accels->end(); - ++it ) { - if( (*it)->m_blockingDisabled ) - continue; - (*it)->m_blocked = block; - (*it)->updateConnections(); - } -} - -void KGlobalAccelPrivate::disableBlocking( bool block ) -{ - m_blockingDisabled = block; -} - -bool KGlobalAccelPrivate::isEnabledInternal() const -{ - return KAccelBase::isEnabled() && !m_blocked; -} - -bool KGlobalAccelPrivate::emitSignal( Signal ) -{ - return false; -} - -bool KGlobalAccelPrivate::connectKey( KAccelAction& action, const KKeyServer::Key& key ) - { return grabKey( key, true, &action ); } -bool KGlobalAccelPrivate::connectKey( const KKeyServer::Key& key ) - { return grabKey( key, true, 0 ); } -bool KGlobalAccelPrivate::disconnectKey( KAccelAction& action, const KKeyServer::Key& key ) - { return grabKey( key, false, &action ); } -bool KGlobalAccelPrivate::disconnectKey( const KKeyServer::Key& key ) - { return grabKey( key, false, 0 ); } - -bool KGlobalAccelPrivate::grabKey( const KKeyServer::Key& key, bool bGrab, KAccelAction* pAction ) -{ - /* - if( !key.code() ) { - kdWarning(125) << "KGlobalAccelPrivate::grabKey( " << key.key().toStringInternal() << ", " << bGrab << ", \"" << (pAction ? pAction->name().latin1() : "(null)") << "\" ): Tried to grab key with null code." << endl; - return false; - } - - // Make sure that grab masks have been initialized. - if( g_keyModMaskXOnOrOff == 0 ) - calculateGrabMasks(); - - uchar keyCodeX = key.code(); - uint keyModX = key.mod() & g_keyModMaskXAccel; // Get rid of any non-relevant bits in mod - // HACK: make Alt+Print work - if( key.sym() == XK_Sys_Req ) { - keyModX |= KKeyServer::modXAlt(); - keyCodeX = 111; - } - - kdDebug(125) << TQString( "grabKey( key: '%1', bGrab: %2 ): keyCodeX: %3 keyModX: %4\n" ) - .arg( key.key().toStringInternal() ).arg( bGrab ) - .arg( keyCodeX, 0, 16 ).arg( keyModX, 0, 16 ); - if( !keyCodeX ) - return false; - - // We'll have to grab 8 key modifier combinations in order to cover all - // combinations of CapsLock, NumLock, ScrollLock. - // Does anyone with more X-savvy know how to set a mask on qt_xrootwin so that - // the irrelevant bits are always ignored and we can just make one XGrabKey - // call per accelerator? -- ellis -#ifndef NDEBUG - TQString sDebug = TQString("\tcode: 0x%1 state: 0x%2 | ").arg(keyCodeX,0,16).arg(keyModX,0,16); -#endif - uint keyModMaskX = ~g_keyModMaskXOnOrOff; - for( uint irrelevantBitsMask = 0; irrelevantBitsMask <= 0xff; irrelevantBitsMask++ ) { - if( (irrelevantBitsMask & keyModMaskX) == 0 ) { -#ifndef NDEBUG - sDebug += TQString("0x%3, ").arg(irrelevantBitsMask, 0, 16); -#endif - if( bGrab ) - XGrabKey( qt_xdisplay(), keyCodeX, keyModX | irrelevantBitsMask, - qt_xrootwin(), True, GrabModeAsync, GrabModeSync ); - else - XUngrabKey( qt_xdisplay(), keyCodeX, keyModX | irrelevantBitsMask, qt_xrootwin() ); - } - } -#ifndef NDEBUG - kdDebug(125) << sDebug << endl; -#endif - - bool failed = false; - if( bGrab ) { -#ifdef Q_WS_X11 - failed = handler.error( true ); // sync now -#endif - // If grab failed, then ungrab any grabs that could possibly succeed - if( failed ) { - kdDebug(125) << "grab failed!\n"; - for( uint m = 0; m <= 0xff; m++ ) { - if( m & keyModMaskX == 0 ) - XUngrabKey( qt_xdisplay(), keyCodeX, keyModX | m, qt_xrootwin() ); - } - } - } - if( !failed ) - { - CodeMod codemod; - codemod.code = keyCodeX; - codemod.mod = keyModX; - if( key.mod() & KKeyServer::MODE_SWITCH ) - codemod.mod |= KKeyServer::MODE_SWITCH; - - if( bGrab ) - m_rgCodeModToAction.insert( codemod, pAction ); - else - m_rgCodeModToAction.remove( codemod ); - } - return !failed;*/ - return false; -} - -/*bool KGlobalAccelPrivate::x11Event( XEvent* pEvent ) -{ - //kdDebug(125) << "x11EventFilter( type = " << pEvent->type << " )" << endl; - switch( pEvent->type ) { - case MappingNotify: - XRefreshKeyboardMapping( &pEvent->xmapping ); - x11MappingNotify(); - return false; - case XKeyPress: - if( x11KeyPress( pEvent ) ) - return true; - default: - return TQWidget::x11Event( pEvent ); - } -} - -void KGlobalAccelPrivate::x11MappingNotify() -{ - kdDebug(125) << "KGlobalAccelPrivate::x11MappingNotify()" << endl; - if( m_bEnabled ) { - // Maybe the X modifier map has been changed. - KKeyServer::initializeMods(); - calculateGrabMasks(); - // Do new XGrabKey()s. - updateConnections(); - } -} - -bool KGlobalAccelPrivate::x11KeyPress( const XEvent *pEvent ) -{ - // do not change this line unless you really really know what you are doing (Matthias) - if ( !TQWidget::keyboardGrabber() && !TQApplication::activePopupWidget() ) { - XUngrabKeyboard( qt_xdisplay(), pEvent->xkey.time ); - XFlush( qt_xdisplay()); // avoid X(?) bug - } - - if( !m_bEnabled ) - return false; - - CodeMod codemod; - codemod.code = pEvent->xkey.keycode; - codemod.mod = pEvent->xkey.state & (g_keyModMaskXAccel | KKeyServer::MODE_SWITCH); - - // If numlock is active and a keypad key is pressed, XOR the SHIFT state. - // e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left. - if( pEvent->xkey.state & KKeyServer::modXNumLock() ) { - // TODO: what's the xor operator in c++? - uint sym = XKeycodeToKeysym( qt_xdisplay(), codemod.code, 0 ); - // If this is a keypad key, - if( sym >= XK_KP_Space && sym <= XK_KP_9 ) { - switch( sym ) { - // Leave the following keys unaltered - // FIXME: The proper solution is to see which keysyms don't change when shifted. - case XK_KP_Multiply: - case XK_KP_Add: - case XK_KP_Subtract: - case XK_KP_Divide: - break; - default: - if( codemod.mod & KKeyServer::modXShift() ) - codemod.mod &= ~KKeyServer::modXShift(); - else - codemod.mod |= KKeyServer::modXShift(); - } - } - } - - KKeyNative keyNative( pEvent ); - KKey key = keyNative; - - kdDebug(125) << "x11KeyPress: seek " << key.toStringInternal() - << TQString( " keyCodeX: %1 state: %2 keyModX: %3" ) - .arg( codemod.code, 0, 16 ).arg( pEvent->xkey.state, 0, 16 ).arg( codemod.mod, 0, 16 ) << endl; - - // Search for which accelerator activated this event: - if( !m_rgCodeModToAction.contains( codemod ) ) { -#ifndef NDEBUG - for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) { - KAccelAction* pAction = *it; - kdDebug(125) << "\tcode: " << TQString::number(it.key().code, 16) << " mod: " << TQString::number(it.key().mod, 16) - << (pAction ? TQString(" name: \"%1\" shortcut: %2").arg(pAction->name()).arg(pAction->shortcut().toStringInternal()) : TQString::null) - << endl; - } -#endif - return false; - } - KAccelAction* pAction = m_rgCodeModToAction[codemod]; - - if( !pAction ) { - static bool recursion_block = false; - if( !recursion_block ) { - recursion_block = true; - TQPopupMenu* pMenu = createPopupMenu( 0, KKeySequence(key) ); - connect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int)) ); - pMenu->exec( TQPoint( 0, 0 ) ); - disconnect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int))); - delete pMenu; - recursion_block = false; - } - } else if( !pAction->objSlotPtr() || !pAction->isEnabled() ) - return false; - else - activate( pAction, KKeySequence(key) ); - - return true; -}*/ - -void KGlobalAccelPrivate::activate( KAccelAction* pAction, const KKeySequence& seq ) -{ - kdDebug(125) << "KGlobalAccelPrivate::activate( \"" << pAction->name() << "\" ) " << endl; - - TQRegExp rexPassIndex( "([ ]*int[ ]*)" ); - TQRegExp rexPassInfo( " TQString" ); - TQRegExp rexIndex( " ([0-9]+)$" ); - - // If the slot to be called accepts an integer index - // and an index is present at the end of the action's name, - // then send the slot the given index #. - if( rexPassIndex.search( pAction->methodSlotPtr() ) >= 0 && rexIndex.search( pAction->name() ) >= 0 ) { - int n = rexIndex.cap(1).toInt(); - kdDebug(125) << "Calling " << pAction->methodSlotPtr() << " int = " << n << endl; - int slot_id = pAction->objSlotPtr()->tqmetaObject()->findSlot( normalizeSignalSlot( pAction->methodSlotPtr() ).data() + 1, true ); - if( slot_id >= 0 ) { - QUObject o[2]; - static_QUType_int.set(o+1,n); - const_cast< TQObject* >( pAction->objSlotPtr())->qt_invoke( slot_id, o ); - } - } else if( rexPassInfo.search( pAction->methodSlotPtr() ) ) { - int slot_id = pAction->objSlotPtr()->tqmetaObject()->findSlot( normalizeSignalSlot( pAction->methodSlotPtr() ).data() + 1, true ); - if( slot_id >= 0 ) { - QUObject o[4]; - static_QUType_QString.set(o+1,pAction->name()); - static_QUType_QString.set(o+2,pAction->label()); - static_QUType_ptr.set(o+3,&seq); - const_cast< TQObject* >( pAction->objSlotPtr())->qt_invoke( slot_id, o ); - } - } else { - int slot_id = pAction->objSlotPtr()->tqmetaObject()->findSlot( normalizeSignalSlot( pAction->methodSlotPtr() ).data() + 1, true ); - if( slot_id >= 0 ) - const_cast< TQObject* >( pAction->objSlotPtr())->qt_invoke( slot_id, 0 ); - } -} - -void KGlobalAccelPrivate::slotActivated( int iAction ) -{ - KAccelAction* pAction = actions().actionPtr( iAction ); - if( pAction ) - activate( pAction, KKeySequence() ); -} - -#include "kglobalaccel_win.moc" - -#endif // !Q_WS_WIN diff --git a/kdecore/kglobalaccel_win.h b/kdecore/kglobalaccel_win.h deleted file mode 100644 index 414254881..000000000 --- a/kdecore/kglobalaccel_win.h +++ /dev/null @@ -1,77 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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 _KGLOBALACCEL_WIN_H -#define _KGLOBALACCEL_WIN_H - -#include <tqmap.h> -#include <tqwidget.h> - -#include "kaccelbase.h" -#include "kkeyserver.h" -#include "kshortcut.h" - -/** - * @internal - */ -class KGlobalAccelPrivate : public TQWidget, public KAccelBase -{ - friend class KGlobalAccel; - Q_OBJECT - public: - KGlobalAccelPrivate(); - virtual ~KGlobalAccelPrivate(); - - virtual void setEnabled( bool bEnabled ); - - virtual bool emitSignal( Signal signal ); - virtual bool connectKey( KAccelAction& action, const KKeyServer::Key& key ); - virtual bool connectKey( const KKeyServer::Key& key ); - virtual bool disconnectKey( KAccelAction& action, const KKeyServer::Key& key ); - virtual bool disconnectKey( const KKeyServer::Key& key ); - - protected: - - /** - * @param bGrab Set to true to grab key, false to ungrab key. - */ - bool grabKey( const KKeyServer::Key&, bool bGrab, KAccelAction* ); - - /** - * Filters X11 events ev for key bindings in the accelerator dictionary. - * If a match is found the activated activated is emitted and the function - * returns true. Return false if the event is not processed. - * - * This is public for compatibility only. You do not need to call it. - */ -// virtual bool x11Event( XEvent* ); -// void x11MappingNotify(); -// bool x11KeyPress( const XEvent *pEvent ); - void activate( KAccelAction* pAction, const KKeySequence& seq ); - virtual bool isEnabledInternal() const; - static void blockShortcuts( bool block ); - void disableBlocking( bool disable ); - - protected slots: - void slotActivated( int iAction ); - bool m_blocked; - bool m_blockingDisabled; -}; - -#endif // _KGLOBALACCEL_WIN_H diff --git a/kdecore/kglobalaccel_x11.cpp b/kdecore/kglobalaccel_x11.cpp deleted file mode 100644 index c2f7a3829..000000000 --- a/kdecore/kglobalaccel_x11.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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. -*/ - -#include "config.h" - -#include <tqwindowdefs.h> -#ifdef Q_WS_X11 - -#include "kglobalaccel_x11.h" -#include "kglobalaccel.h" -#include "kkeyserver_x11.h" - -#include <tqpopupmenu.h> -#include <tqregexp.h> -#include <tqwidget.h> -#include <tqmetaobject.h> -#include <tqucomextra_p.h> -#include <kapplication.h> -#include <kdebug.h> -#include <kkeynative.h> - -#ifdef Q_WS_X11 -#include <kxerrorhandler.h> -#endif - -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/keysym.h> -#include <fixx11h.h> - -extern "C" { - static int XGrabErrorHandler( Display *, XErrorEvent *e ) { - if ( e->error_code != BadAccess ) { - kdWarning() << "grabKey: got X error " << e->type << " instead of BadAccess\n"; - } - return 1; - } -} - -// g_keyModMaskXAccel -// mask of modifiers which can be used in shortcuts -// (meta, alt, ctrl, shift) -// g_keyModMaskXOnOrOff -// mask of modifiers where we don't care whether they are on or off -// (caps lock, num lock, scroll lock) -static uint g_keyModMaskXAccel = 0; -static uint g_keyModMaskXOnOrOff = 0; - -static void calculateGrabMasks() -{ - g_keyModMaskXAccel = KKeyServer::accelModMaskX(); - g_keyModMaskXOnOrOff = - KKeyServer::modXLock() | - KKeyServer::modXNumLock() | - KKeyServer::modXScrollLock() | - KKeyServer::modXModeSwitch(); - //kdDebug() << "g_keyModMaskXAccel = " << g_keyModMaskXAccel - // << "g_keyModMaskXOnOrOff = " << g_keyModMaskXOnOrOff << endl; -} - -//---------------------------------------------------- - -static TQValueList< KGlobalAccelPrivate* >* all_accels = 0; - -KGlobalAccelPrivate::KGlobalAccelPrivate() -: KAccelBase( KAccelBase::NATIVE_KEYS ) -, m_blocked( false ) -, m_blockingDisabled( false ) -, m_suspended( false ) -{ - if( all_accels == NULL ) - all_accels = new TQValueList< KGlobalAccelPrivate* >; - all_accels->append( this ); - m_sConfigGroup = "Global Shortcuts"; - kapp->installX11EventFilter( this ); - connect(kapp, TQT_SIGNAL(coreFakeKeyPress(unsigned int)), this, TQT_SLOT(fakeKeyPressed(unsigned int))); -} - -KGlobalAccelPrivate::~KGlobalAccelPrivate() -{ - // TODO: Need to release all grabbed keys if the main window is not shutting down. - //for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) { - // const CodeMod& codemod = it.key(); - //} - all_accels->remove( this ); - if( all_accels->count() == 0 ) { - delete all_accels; - all_accels = NULL; - } -} - -void KGlobalAccelPrivate::setEnabled( bool bEnable ) -{ - m_bEnabled = bEnable; - updateConnections(); -} - -void KGlobalAccelPrivate::blockShortcuts( bool block ) -{ - if( all_accels == NULL ) - return; - for( TQValueList< KGlobalAccelPrivate* >::ConstIterator it = all_accels->begin(); - it != all_accels->end(); - ++it ) { - if( (*it)->m_blockingDisabled ) - continue; - (*it)->m_blocked = block; - (*it)->updateConnections(); - } -} - -void KGlobalAccelPrivate::disableBlocking( bool block ) -{ - m_blockingDisabled = block; -} - -bool KGlobalAccelPrivate::isEnabledInternal() const -{ - return KAccelBase::isEnabled() && !m_blocked; -} - -// see #117169 - the bug is hard to reproduce, probably somewhere in X, testcase would be probably -// difficult to make, and so on - just don't release the grabs and only ignore the events instead -void KGlobalAccelPrivate::suspend( bool s ) -{ - m_suspended = s; -} - -bool KGlobalAccelPrivate::emitSignal( Signal ) -{ - return false; -} - -bool KGlobalAccelPrivate::connectKey( KAccelAction& action, const KKeyServer::Key& key ) - { return grabKey( key, true, &action ); } -bool KGlobalAccelPrivate::connectKey( const KKeyServer::Key& key ) - { return grabKey( key, true, 0 ); } -bool KGlobalAccelPrivate::disconnectKey( KAccelAction& action, const KKeyServer::Key& key ) - { return grabKey( key, false, &action ); } -bool KGlobalAccelPrivate::disconnectKey( const KKeyServer::Key& key ) - { return grabKey( key, false, 0 ); } - -bool KGlobalAccelPrivate::grabKey( const KKeyServer::Key& key, bool bGrab, KAccelAction* pAction ) -{ - if( !key.code() ) { - kdWarning(125) << "KGlobalAccelPrivate::grabKey( " << key.key().toStringInternal() << ", " << bGrab << ", \"" << (pAction ? pAction->name().latin1() : "(null)") << "\" ): Tried to grab key with null code." << endl; - return false; - } - - // Make sure that grab masks have been initialized. - if( g_keyModMaskXOnOrOff == 0 ) - calculateGrabMasks(); - - uchar keyCodeX = key.code(); - uint keyModX = key.mod() & g_keyModMaskXAccel; // Get rid of any non-relevant bits in mod - // HACK: make Alt+Print work - // only do this for the Xorg default keyboard keycodes, - // other mappings (e.g. evdev) don't need or want it - if( key.sym() == XK_Sys_Req && XKeycodeToKeysym( qt_xdisplay(), 111, 0 ) == XK_Print ) { - keyModX |= KKeyServer::modXAlt(); - keyCodeX = 111; - } - -#ifndef __osf__ -// this crashes under Tru64 so ..... - kdDebug(125) << TQString(TQString( "grabKey( key: '%1', bGrab: %2 ): keyCodeX: %3 keyModX: %4\n" ) - .arg( key.key().toStringInternal() ).arg( bGrab ) - .arg( keyCodeX, 0, 16 ).arg( keyModX, 0, 16 )); -#endif - if( !keyCodeX ) - return false; - -#ifdef Q_WS_X11 - KXErrorHandler handler( XGrabErrorHandler ); -#endif - // We'll have to grab 8 key modifier combinations in order to cover all - // combinations of CapsLock, NumLock, ScrollLock. - // Does anyone with more X-savvy know how to set a mask on qt_xrootwin so that - // the irrelevant bits are always ignored and we can just make one XGrabKey - // call per accelerator? -- ellis -#ifndef NDEBUG - TQString sDebug = TQString("\tcode: 0x%1 state: 0x%2 | ").arg(keyCodeX,0,16).arg(keyModX,0,16); -#endif - uint keyModMaskX = ~g_keyModMaskXOnOrOff; - for( uint irrelevantBitsMask = 0; irrelevantBitsMask <= 0xff; irrelevantBitsMask++ ) { - if( (irrelevantBitsMask & keyModMaskX) == 0 ) { -#ifndef NDEBUG - sDebug += TQString("0x%3, ").arg(irrelevantBitsMask, 0, 16); -#endif - if( bGrab ) - XGrabKey( qt_xdisplay(), keyCodeX, keyModX | irrelevantBitsMask, - qt_xrootwin(), True, GrabModeAsync, GrabModeSync ); - else - XUngrabKey( qt_xdisplay(), keyCodeX, keyModX | irrelevantBitsMask, qt_xrootwin() ); - } - } -#ifndef NDEBUG - kdDebug(125) << sDebug << endl; -#endif - - bool failed = false; - if( bGrab ) { -#ifdef Q_WS_X11 - failed = handler.error( true ); // sync now -#endif - // If grab failed, then ungrab any grabs that could possibly succeed - if( failed ) { - kdDebug(125) << "grab failed!\n"; - for( uint m = 0; m <= 0xff; m++ ) { - if(( m & keyModMaskX ) == 0 ) - XUngrabKey( qt_xdisplay(), keyCodeX, keyModX | m, qt_xrootwin() ); - } - } - } - if( !failed ) - { - CodeMod codemod; - codemod.code = keyCodeX; - codemod.mod = keyModX; - if( key.mod() & KKeyServer::MODE_SWITCH ) - codemod.mod |= KKeyServer::MODE_SWITCH; - - if( bGrab ) - m_rgCodeModToAction.insert( codemod, pAction ); - else - m_rgCodeModToAction.remove( codemod ); - } - return !failed; -} - -bool KGlobalAccelPrivate::x11Event( XEvent* pEvent ) -{ - //kdDebug(125) << "x11EventFilter( type = " << pEvent->type << " )" << endl; - switch( pEvent->type ) { - case MappingNotify: - XRefreshKeyboardMapping( &pEvent->xmapping ); - x11MappingNotify(); - return false; - case XKeyPress: - if( x11KeyPress( pEvent ) ) - return true; - default: - return TQWidget::x11Event( pEvent ); - } -} - -void KGlobalAccelPrivate::x11MappingNotify() -{ - kdDebug(125) << "KGlobalAccelPrivate::x11MappingNotify()" << endl; - // Maybe the X modifier map has been changed. - KKeyServer::initializeMods(); - calculateGrabMasks(); - // Do new XGrabKey()s. - updateConnections(); -} - -void KGlobalAccelPrivate::fakeKeyPressed(unsigned int keyCode) { - CodeMod codemod; - codemod.code = keyCode; - codemod.mod = 0; - - KKey key = (keyCode, 0); - - kdDebug(125) << "fakeKeyPressed: seek " << key.toStringInternal() - << TQString(TQString( " keyCodeX: %1 keyCode: %2 keyModX: %3" ) - .arg( codemod.code, 0, 16 ).arg( keyCode, 0, 16 ).arg( codemod.mod, 0, 16 )) << endl; - - // Search for which accelerator activated this event: - if( !m_rgCodeModToAction.contains( codemod ) ) { -#ifndef NDEBUG - for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) { - KAccelAction* pAction = *it; - kdDebug(125) << "\tcode: " << TQString::number(it.key().code, 16) << " mod: " << TQString::number(it.key().mod, 16) - << (pAction ? TQString(" name: \"%1\" shortcut: %2").tqarg(pAction->name()).tqarg(pAction->shortcut().toStringInternal()) : TQString()) - << endl; - } -#endif - return; - } - - KAccelAction* pAction = m_rgCodeModToAction[codemod]; - - if( !pAction ) { - static bool recursion_block = false; - if( !recursion_block ) { - recursion_block = true; - TQPopupMenu* pMenu = createPopupMenu( 0, KKeySequence(key) ); - connect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int)) ); - pMenu->exec( TQPoint( 0, 0 ) ); - disconnect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int))); - delete pMenu; - recursion_block = false; - } - } else if( !pAction->objSlotPtr() || !pAction->isEnabled() ) - return; - else - activate( pAction, KKeySequence(key) ); -} - -bool KGlobalAccelPrivate::x11KeyPress( const XEvent *pEvent ) -{ - // do not change this line unless you really really know what you are doing (Matthias) - if ( !TQWidget::keyboardGrabber() && !TQApplication::activePopupWidget() ) { - XUngrabKeyboard( qt_xdisplay(), pEvent->xkey.time ); - XFlush( qt_xdisplay()); // avoid X(?) bug - } - - if( !isEnabledInternal() || m_suspended ) - return false; - - CodeMod codemod; - codemod.code = pEvent->xkey.keycode; - codemod.mod = pEvent->xkey.state & (g_keyModMaskXAccel | KKeyServer::MODE_SWITCH); - - // If numlock is active and a keypad key is pressed, XOR the SHIFT state. - // e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left. - if( pEvent->xkey.state & KKeyServer::modXNumLock() ) { - // TODO: what's the xor operator in c++? - uint sym = XKeycodeToKeysym( qt_xdisplay(), codemod.code, 0 ); - // If this is a keypad key, - if( sym >= XK_KP_Space && sym <= XK_KP_9 ) { - switch( sym ) { - // Leave the following keys unaltered - // FIXME: The proper solution is to see which keysyms don't change when shifted. - case XK_KP_Multiply: - case XK_KP_Add: - case XK_KP_Subtract: - case XK_KP_Divide: - break; - default: - if( codemod.mod & KKeyServer::modXShift() ) - codemod.mod &= ~KKeyServer::modXShift(); - else - codemod.mod |= KKeyServer::modXShift(); - } - } - } - - KKeyNative keyNative( pEvent ); - KKey key = keyNative; - - kdDebug(125) << "x11KeyPress: seek " << key.toStringInternal() - << TQString(TQString( " keyCodeX: %1 state: %2 keyModX: %3" ) - .arg( codemod.code, 0, 16 ).arg( pEvent->xkey.state, 0, 16 ).arg( codemod.mod, 0, 16 )) << endl; - - // Search for which accelerator activated this event: - if( !m_rgCodeModToAction.contains( codemod ) ) { -#ifndef NDEBUG - for( CodeModMap::ConstIterator it = m_rgCodeModToAction.begin(); it != m_rgCodeModToAction.end(); ++it ) { - KAccelAction* pAction = *it; - kdDebug(125) << "\tcode: " << TQString::number(it.key().code, 16) << " mod: " << TQString::number(it.key().mod, 16) - << (pAction ? TQString(" name: \"%1\" shortcut: %2").tqarg(pAction->name()).tqarg(pAction->shortcut().toStringInternal()) : TQString()) - << endl; - } -#endif - return false; - } - - KAccelAction* pAction = m_rgCodeModToAction[codemod]; - - if( !pAction ) { - static bool recursion_block = false; - if( !recursion_block ) { - recursion_block = true; - TQPopupMenu* pMenu = createPopupMenu( 0, KKeySequence(key) ); - connect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int)) ); - pMenu->exec( TQPoint( 0, 0 ) ); - disconnect( pMenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int))); - delete pMenu; - recursion_block = false; - } - } else if( !pAction->objSlotPtr() || !pAction->isEnabled() ) - return false; - else - activate( pAction, KKeySequence(key) ); - - return true; -} - -void KGlobalAccelPrivate::activate( KAccelAction* pAction, const KKeySequence& seq ) -{ - kdDebug(125) << "KGlobalAccelPrivate::activate( \"" << pAction->name() << "\" ) " << endl; - - TQRegExp rexPassIndex( "([ ]*int[ ]*)" ); - TQRegExp rexPassInfo( " TQString" ); - TQRegExp rexIndex( " ([0-9]+)$" ); - - // If the slot to be called accepts an integer index - // and an index is present at the end of the action's name, - // then send the slot the given index #. - if( rexPassIndex.search( pAction->methodSlotPtr() ) >= 0 && rexIndex.search( pAction->name() ) >= 0 ) { - int n = rexIndex.cap(1).toInt(); - kdDebug(125) << "Calling " << pAction->methodSlotPtr() << " int = " << n << endl; - int slot_id = pAction->objSlotPtr()->tqmetaObject()->findSlot( normalizeSignalSlot( pAction->methodSlotPtr() ).data() + 1, true ); - if( slot_id >= 0 ) { - TQUObject o[2]; - static_TQUType_int.set(o+1,n); - const_cast< TQObject* >( pAction->objSlotPtr())->qt_invoke( slot_id, o ); - } - } else if( rexPassInfo.search( pAction->methodSlotPtr() ) ) { - int slot_id = pAction->objSlotPtr()->tqmetaObject()->findSlot( normalizeSignalSlot( pAction->methodSlotPtr() ).data() + 1, true ); - if( slot_id >= 0 ) { - TQUObject o[4]; - static_TQUType_TQString.set(o+1,pAction->name()); - static_TQUType_TQString.set(o+2,pAction->label()); - static_TQUType_ptr.set(o+3,&seq); - const_cast< TQObject* >( pAction->objSlotPtr())->qt_invoke( slot_id, o ); - } - } else { - int slot_id = pAction->objSlotPtr()->tqmetaObject()->findSlot( normalizeSignalSlot( pAction->methodSlotPtr() ).data() + 1, true ); - if( slot_id >= 0 ) - const_cast< TQObject* >( pAction->objSlotPtr())->qt_invoke( slot_id, 0 ); - } -} - -void KGlobalAccelPrivate::slotActivated( int iAction ) -{ - KAccelAction* pAction = KAccelBase::actions().actionPtr( iAction ); - if( pAction ) - activate( pAction, KKeySequence() ); -} - -#include "kglobalaccel_x11.moc" - -#endif // !Q_WS_X11 diff --git a/kdecore/kglobalaccel_x11.h b/kdecore/kglobalaccel_x11.h deleted file mode 100644 index 3022e0d90..000000000 --- a/kdecore/kglobalaccel_x11.h +++ /dev/null @@ -1,110 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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 _KGLOBALACCEL_X11_H -#define _KGLOBALACCEL_X11_H - -#include <tqmap.h> -#include <tqwidget.h> - -#include "kaccelbase.h" -#include "kkeyserver_x11.h" -#include "kshortcut.h" - -/** - * @internal - */ -class KGlobalAccelPrivate : public TQWidget, public KAccelBase -{ - friend class KGlobalAccel; - Q_OBJECT - public: - KGlobalAccelPrivate(); - virtual ~KGlobalAccelPrivate(); - - virtual void setEnabled( bool bEnabled ); - - virtual bool emitSignal( Signal signal ); - virtual bool connectKey( KAccelAction& action, const KKeyServer::Key& key ); - virtual bool connectKey( const KKeyServer::Key& key ); - virtual bool disconnectKey( KAccelAction& action, const KKeyServer::Key& key ); - virtual bool disconnectKey( const KKeyServer::Key& key ); - - protected: - /** - * @internal - * Represents a key code and modifier combination. - */ - class CodeMod - { - public: - /** - * The key code of the CodeMod. - */ - uchar code; - /** - * The modifier flags of the CodeMod. - */ - uint mod; - - /** - * Compares two CodeMods. - */ - bool operator < ( const CodeMod& b ) const - { - if( code < b.code ) return true; - if( code == b.code && mod < b.mod ) return true; - return false; - } - }; - typedef TQMap<CodeMod, KAccelAction*> CodeModMap; - - CodeModMap m_rgCodeModToAction; - - /** - * @param bGrab Set to true to grab key, false to ungrab key. - */ - bool grabKey( const KKeyServer::Key&, bool bGrab, KAccelAction* ); - - /** - * Filters X11 events ev for key bindings in the accelerator dictionary. - * If a match is found the activated activated is emitted and the function - * returns true. Return false if the event is not processed. - * - * This is public for compatibility only. You do not need to call it. - */ - virtual bool x11Event( XEvent* ); - void x11MappingNotify(); - bool x11KeyPress( const XEvent *pEvent ); - void activate( KAccelAction* pAction, const KKeySequence& seq ); - virtual bool isEnabledInternal() const; - static void blockShortcuts( bool block ); - void disableBlocking( bool disable ); - void suspend( bool s ); - - protected slots: - void slotActivated( int iAction ); - void fakeKeyPressed(unsigned int keyCode); - private: - bool m_blocked; - bool m_blockingDisabled; - bool m_suspended; -}; - -#endif // _KGLOBALACCEL_X11_H diff --git a/kdecore/kglobalsettings.cpp b/kdecore/kglobalsettings.cpp deleted file mode 100644 index 6d2a487d4..000000000 --- a/kdecore/kglobalsettings.cpp +++ /dev/null @@ -1,774 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 David Faure <faure@kde.org> - - 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 "kglobalsettings.h" - -#include <tqdir.h> -#include <tqpixmap.h> -#include <tqfontdatabase.h> -#include <tqcursor.h> - -#include <kconfig.h> -#include <ksimpleconfig.h> -#include <kapplication.h> - -#include <kipc.h> - -#ifdef Q_WS_WIN -#include <windows.h> -#include "qt_windows.h" -#include <win32_utils.h> -static QRgb qt_colorref2qrgb(COLORREF col) -{ - return tqRgb(GetRValue(col),GetGValue(col),GetBValue(col)); -} -#endif - -#include <kdebug.h> -#include <kglobal.h> -#include <kshortcut.h> -#include <kstandarddirs.h> -#include <kcharsets.h> -#include <kaccel.h> -#include <klocale.h> -#include <tqfontinfo.h> -#include <stdlib.h> -#include <kprotocolinfo.h> - -#include <tqtextcodec.h> -#include <tqtextstream.h> -#include <tqfile.h> - -#ifdef Q_WS_X11 -#include <X11/Xlib.h> -#endif - -TQString* KGlobalSettings::s_desktopPath = 0; -TQString* KGlobalSettings::s_autostartPath = 0; -TQString* KGlobalSettings::s_trashPath = 0; -TQString* KGlobalSettings::s_documentPath = 0; -TQFont *KGlobalSettings::_generalFont = 0; -TQFont *KGlobalSettings::_fixedFont = 0; -TQFont *KGlobalSettings::_toolBarFont = 0; -TQFont *KGlobalSettings::_menuFont = 0; -TQFont *KGlobalSettings::_windowTitleFont = 0; -TQFont *KGlobalSettings::_taskbarFont = 0; -TQFont *KGlobalSettings::_largeFont = 0; -TQColor *KGlobalSettings::_trinity4Blue = 0; -TQColor *KGlobalSettings::_inactiveBackground = 0; -TQColor *KGlobalSettings::_inactiveForeground = 0; -TQColor *KGlobalSettings::_activeBackground = 0; -TQColor *KGlobalSettings::_buttonBackground = 0; -TQColor *KGlobalSettings::_selectBackground = 0; -TQColor *KGlobalSettings::_linkColor = 0; -TQColor *KGlobalSettings::_visitedLinkColor = 0; -TQColor *KGlobalSettings::alternateColor = 0; - -KGlobalSettings::KMouseSettings *KGlobalSettings::s_mouseSettings = 0; - -// helper function for reading xdg user dirs: it is required in order to take -// care of locale stuff -void readXdgUserDirs(TQString *desktop, TQString *documents) -{ - TQFile f( TQDir::homeDirPath() + "/.config/user-dirs.dirs" ); - - if (!f.open(IO_ReadOnly)) - return; - - // set the codec for the current locale - TQTextStream s(&f); - s.setCodec( TQTextCodec::codecForLocale() ); - - TQString line = s.readLine(); - while (!line.isNull()) - { - if (line.startsWith("XDG_DESKTOP_DIR=")) - *desktop = line.remove("XDG_DESKTOP_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath()); - else if (line.startsWith("XDG_DOCUMENTS_DIR=")) - *documents = line.remove("XDG_DOCUMENTS_DIR=").remove("\"").replace("$HOME", TQDir::homeDirPath()); - - line = s.readLine(); - } -} - -int KGlobalSettings::dndEventDelay() -{ - KConfigGroup g( KGlobal::config(), "General" ); - return g.readNumEntry("StartDragDist", TQApplication::startDragDistance()); -} - -bool KGlobalSettings::singleClick() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); -} - -bool KGlobalSettings::iconUseRoundedRect() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("IconUseRoundedRect", KDE_DEFAULT_ICONTEXTROUNDED); -} - -KGlobalSettings::TearOffHandle KGlobalSettings::insertTearOffHandle() -{ - int tearoff; - bool effectsenabled; - KConfigGroup g( KGlobal::config(), "KDE" ); - effectsenabled = g.readBoolEntry( "EffectsEnabled", false); - tearoff = g.readNumEntry("InsertTearOffHandle", KDE_DEFAULT_INSERTTEAROFFHANDLES); - return effectsenabled ? (TearOffHandle) tearoff : Disable; -} - -bool KGlobalSettings::changeCursorOverIcon() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("ChangeCursor", KDE_DEFAULT_CHANGECURSOR); -} - -bool KGlobalSettings::visualActivate() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("VisualActivate", KDE_DEFAULT_VISUAL_ACTIVATE); -} - -unsigned int KGlobalSettings::visualActivateSpeed() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return - g.readNumEntry( - "VisualActivateSpeed", - KDE_DEFAULT_VISUAL_ACTIVATE_SPEED - ); -} - - - -int KGlobalSettings::autoSelectDelay() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readNumEntry("AutoSelectDelay", KDE_DEFAULT_AUTOSELECTDELAY); -} - -KGlobalSettings::Completion KGlobalSettings::completionMode() -{ - int completion; - KConfigGroup g( KGlobal::config(), "General" ); - completion = g.readNumEntry("completionMode", -1); - if ((completion < (int) CompletionNone) || - (completion > (int) CompletionPopupAuto)) - { - completion = (int) CompletionPopup; // Default - } - return (Completion) completion; -} - -bool KGlobalSettings::showContextMenusOnPress () -{ - KConfigGroup g(KGlobal::config(), "ContextMenus"); - return g.readBoolEntry("ShowOnPress", true); -} - -int KGlobalSettings::contextMenuKey () -{ - KConfigGroup g(KGlobal::config(), "Shortcuts"); - KShortcut cut (g.readEntry ("PopupMenuContext", "Menu")); - return cut.keyCodeQt(); -} - -TQColor KGlobalSettings::toolBarHighlightColor() -{ - initColors(); - KConfigGroup g( KGlobal::config(), "Toolbar style" ); - return g.readColorEntry("HighlightColor", _trinity4Blue); -} - -TQColor KGlobalSettings::inactiveTitleColor() -{ -#ifdef Q_WS_WIN - return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION)); -#else - if (!_inactiveBackground) - _inactiveBackground = new TQColor(157, 170, 186); - KConfigGroup g( KGlobal::config(), "WM" ); - return g.readColorEntry( "inactiveBackground", _inactiveBackground ); -#endif -} - -TQColor KGlobalSettings::inactiveTextColor() -{ -#ifdef Q_WS_WIN - return qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT)); -#else - if (!_inactiveForeground) - _inactiveForeground = new TQColor(221,221,221); - KConfigGroup g( KGlobal::config(), "WM" ); - return g.readColorEntry( "inactiveForeground", _inactiveForeground ); -#endif -} - -TQColor KGlobalSettings::activeTitleColor() -{ -#ifdef Q_WS_WIN - return qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION)); -#else - initColors(); - if (!_activeBackground) - _activeBackground = new TQColor(65,142,220); - KConfigGroup g( KGlobal::config(), "WM" ); - return g.readColorEntry( "activeBackground", _activeBackground); -#endif -} - -TQColor KGlobalSettings::activeTextColor() -{ -#ifdef Q_WS_WIN - return qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT)); -#else - KConfigGroup g( KGlobal::config(), "WM" ); - return g.readColorEntry( "activeForeground", tqwhiteptr ); -#endif -} - -int KGlobalSettings::contrast() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readNumEntry( "contrast", 7 ); -} - -TQColor KGlobalSettings::buttonBackground() -{ - if (!_buttonBackground) - _buttonBackground = new TQColor(221,223,228); - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "buttonBackground", _buttonBackground ); -} - -TQColor KGlobalSettings::buttonTextColor() -{ - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "buttonForeground", tqblackptr ); -} - -// IMPORTANT: -// This function should be kept in sync with -// KApplication::kdisplaySetPalette() -TQColor KGlobalSettings::baseColor() -{ - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "windowBackground", tqwhiteptr ); -} - -// IMPORTANT: -// This function should be kept in sync with -// KApplication::kdisplaySetPalette() -TQColor KGlobalSettings::textColor() -{ - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "windowForeground", tqblackptr ); -} - -// IMPORTANT: -// This function should be kept in sync with -// KApplication::kdisplaySetPalette() -TQColor KGlobalSettings::highlightedTextColor() -{ - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "selectForeground", tqwhiteptr ); -} - -// IMPORTANT: -// This function should be kept in sync with -// KApplication::kdisplaySetPalette() -TQColor KGlobalSettings::highlightColor() -{ - initColors(); - if (!_selectBackground) - _selectBackground = new TQColor(103,141,178); - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "selectBackground", _selectBackground ); -} - -TQColor KGlobalSettings::alternateBackgroundColor() -{ - initColors(); - KConfigGroup g( KGlobal::config(), "General" ); - *alternateColor = calculateAlternateBackgroundColor( baseColor() ); - return g.readColorEntry( "alternateBackground", alternateColor ); -} - -TQColor KGlobalSettings::calculateAlternateBackgroundColor(const TQColor& base) -{ - if (base == Qt::white) - return TQColor(238,246,255); - else - { - int h, s, v; - base.hsv( &h, &s, &v ); - if (v > 128) - return base.dark(106); - else if (base != Qt::black) - return base.light(110); - - return TQColor(32,32,32); - } -} - -bool KGlobalSettings::shadeSortColumn() -{ - KConfigGroup g( KGlobal::config(), "General" ); - return g.readBoolEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN ); -} - -TQColor KGlobalSettings::linkColor() -{ - initColors(); - if (!_linkColor) - _linkColor = new TQColor(0,0,238); - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "linkColor", _linkColor ); -} - -TQColor KGlobalSettings::visitedLinkColor() -{ - if (!_visitedLinkColor) - _visitedLinkColor = new TQColor(82,24,139); - KConfigGroup g( KGlobal::config(), "General" ); - return g.readColorEntry( "visitedLinkColor", _visitedLinkColor ); -} - -TQFont KGlobalSettings::generalFont() -{ - if (_generalFont) - return *_generalFont; - - // Sync default with kdebase/kcontrol/fonts/fonts.cpp - _generalFont = new TQFont("Sans Serif", 10); - _generalFont->setPointSize(10); - _generalFont->setStyleHint(TQFont::SansSerif); - - KConfigGroup g( KGlobal::config(), "General" ); - *_generalFont = g.readFontEntry("font", _generalFont); - - return *_generalFont; -} - -TQFont KGlobalSettings::fixedFont() -{ - if (_fixedFont) - return *_fixedFont; - - // Sync default with kdebase/kcontrol/fonts/fonts.cpp - _fixedFont = new TQFont("Monospace", 10); - _fixedFont->setPointSize(10); - _fixedFont->setStyleHint(TQFont::TypeWriter); - - KConfigGroup g( KGlobal::config(), "General" ); - *_fixedFont = g.readFontEntry("fixed", _fixedFont); - - return *_fixedFont; -} - -TQFont KGlobalSettings::toolBarFont() -{ - if(_toolBarFont) - return *_toolBarFont; - - // Sync default with kdebase/kcontrol/fonts/fonts.cpp - _toolBarFont = new TQFont("Sans Serif", 10); - _toolBarFont->setPointSize(10); - _toolBarFont->setStyleHint(TQFont::SansSerif); - - KConfigGroup g( KGlobal::config(), "General" ); - *_toolBarFont = g.readFontEntry("toolBarFont", _toolBarFont); - - return *_toolBarFont; -} - -TQFont KGlobalSettings::menuFont() -{ - if(_menuFont) - return *_menuFont; - - // Sync default with kdebase/kcontrol/fonts/fonts.cpp - _menuFont = new TQFont("Sans Serif", 10); - _menuFont->setPointSize(10); - _menuFont->setStyleHint(TQFont::SansSerif); - - KConfigGroup g( KGlobal::config(), "General" ); - *_menuFont = g.readFontEntry("menuFont", _menuFont); - - return *_menuFont; -} - -TQFont KGlobalSettings::windowTitleFont() -{ - if(_windowTitleFont) - return *_windowTitleFont; - - // Sync default with kdebase/kcontrol/fonts/fonts.cpp - _windowTitleFont = new TQFont("Sans Serif", 9, TQFont::Bold); - _windowTitleFont->setPointSize(10); - _windowTitleFont->setStyleHint(TQFont::SansSerif); - - KConfigGroup g( KGlobal::config(), "WM" ); - *_windowTitleFont = g.readFontEntry("activeFont", _windowTitleFont); // inconsistency - - return *_windowTitleFont; -} - -TQFont KGlobalSettings::taskbarFont() -{ - if(_taskbarFont) - return *_taskbarFont; - - // Sync default with kdebase/kcontrol/fonts/fonts.cpp - _taskbarFont = new TQFont("Sans Serif", 10); - _taskbarFont->setPointSize(10); - _taskbarFont->setStyleHint(TQFont::SansSerif); - - KConfigGroup g( KGlobal::config(), "General" ); - *_taskbarFont = g.readFontEntry("taskbarFont", _taskbarFont); - - return *_taskbarFont; -} - - -TQFont KGlobalSettings::largeFont(const TQString &text) -{ - TQFontDatabase db; - TQStringList fam = db.tqfamilies(); - - // Move a bunch of preferred fonts to the front. - if (fam.remove("Arial")) - fam.prepend("Arial"); - if (fam.remove("Verdana")) - fam.prepend("Verdana"); - if (fam.remove("Tahoma")) - fam.prepend("Tahoma"); - if (fam.remove("Lucida Sans")) - fam.prepend("Lucida Sans"); - if (fam.remove("Lucidux Sans")) - fam.prepend("Lucidux Sans"); - if (fam.remove("Nimbus Sans")) - fam.prepend("Nimbus Sans"); - if (fam.remove("Gothic I")) - fam.prepend("Gothic I"); - - if (_largeFont) - fam.prepend(_largeFont->family()); - - for(TQStringList::ConstIterator it = fam.begin(); - it != fam.end(); ++it) - { - if (db.isSmoothlyScalable(*it) && !db.isFixedPitch(*it)) - { - TQFont font(*it); - font.setPixelSize(75); - TQFontMetrics metrics(font); - int h = metrics.height(); - if ((h < 60) || ( h > 90)) - continue; - - bool ok = true; - for(unsigned int i = 0; i < text.length(); i++) - { - if (!metrics.inFont(text[i])) - { - ok = false; - break; - } - } - if (!ok) - continue; - - font.setPointSize(48); - _largeFont = new TQFont(font); - return *_largeFont; - } - } - _largeFont = new TQFont(KGlobalSettings::generalFont()); - _largeFont->setPointSize(48); - return *_largeFont; -} - -void KGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. -{ - if ( s_desktopPath != 0 ) - return; - - s_desktopPath = new TQString(); - s_autostartPath = new TQString(); - s_trashPath = new TQString(); - s_documentPath = new TQString(); - - KConfigGroup g( KGlobal::config(), "Paths" ); - - // Read desktop and documents path using XDG_USER_DIRS - readXdgUserDirs(s_desktopPath, s_documentPath); - - if (s_desktopPath->isEmpty() == true) { - *s_desktopPath = TQDir::homeDirPath() + "/Desktop/"; - } - *s_desktopPath = TQDir::cleanDirPath( *s_desktopPath ); - if ( !s_desktopPath->endsWith("/") ) - s_desktopPath->append('/'); - - if (s_documentPath->isEmpty() == true) { -#ifdef Q_WS_WIN - *s_documentPath = getWin32ShellFoldersPath("Personal"); -#else - *s_documentPath = TQDir::homeDirPath() + "/Documents/"; -#endif - } - *s_documentPath = TQDir::cleanDirPath( *s_documentPath ); - if ( !s_documentPath->endsWith("/")) - s_documentPath->append('/'); - - // Trash Path - TODO remove in KDE4 (kio_trash can't use it for interoperability reasons) - *s_trashPath = *s_desktopPath + i18n("Trash") + "/"; - *s_trashPath = g.readPathEntry( "Trash" , *s_trashPath); - *s_trashPath = TQDir::cleanDirPath( *s_trashPath ); - if ( !s_trashPath->endsWith("/") ) - s_trashPath->append('/'); - // We need to save it in any case, in case the language changes later on, - if ( !g.hasKey( "Trash" ) ) - { - g.writePathEntry( "Trash", *s_trashPath, true, true ); - g.sync(); - } - - // Autostart Path - *s_autostartPath = KGlobal::dirs()->localkdedir() + "Autostart/"; - *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath); - *s_autostartPath = TQDir::cleanDirPath( *s_autostartPath ); - if ( !s_autostartPath->endsWith("/") ) - s_autostartPath->append('/'); - - // Make sure this app gets the notifications about those paths - if (kapp) - kapp->addKipcEventMask(KIPC::SettingsChanged); -} - -void KGlobalSettings::initColors() -{ - if (!_trinity4Blue) { - if (TQPixmap::defaultDepth() > 8) - _trinity4Blue = new TQColor(103,141,178); - else - _trinity4Blue = new TQColor(0, 0, 192); - } - if (!alternateColor) - alternateColor = new TQColor(237, 244, 249); -} - -void KGlobalSettings::rereadFontSettings() -{ - delete _generalFont; - _generalFont = 0L; - delete _fixedFont; - _fixedFont = 0L; - delete _menuFont; - _menuFont = 0L; - delete _toolBarFont; - _toolBarFont = 0L; - delete _windowTitleFont; - _windowTitleFont = 0L; - delete _taskbarFont; - _taskbarFont = 0L; -} - -void KGlobalSettings::rereadPathSettings() -{ - kdDebug() << "KGlobalSettings::rereadPathSettings" << endl; - delete s_autostartPath; - s_autostartPath = 0L; - delete s_trashPath; - s_trashPath = 0L; - delete s_desktopPath; - s_desktopPath = 0L; - delete s_documentPath; - s_documentPath = 0L; -} - -KGlobalSettings::KMouseSettings & KGlobalSettings::mouseSettings() -{ - if ( ! s_mouseSettings ) - { - s_mouseSettings = new KMouseSettings; - KMouseSettings & s = *s_mouseSettings; // for convenience - -#ifndef Q_WS_WIN - KConfigGroup g( KGlobal::config(), "Mouse" ); - TQString setting = g.readEntry("MouseButtonMapping"); - if (setting == "RightHanded") - s.handed = KMouseSettings::RightHanded; - else if (setting == "LeftHanded") - s.handed = KMouseSettings::LeftHanded; - else - { -#ifdef Q_WS_X11 - // get settings from X server - // This is a simplified version of the code in input/mouse.cpp - // Keep in sync ! - s.handed = KMouseSettings::RightHanded; - unsigned char map[20]; - int num_buttons = XGetPointerMapping(kapp->getDisplay(), map, 20); - if( num_buttons == 2 ) - { - if ( (int)map[0] == 1 && (int)map[1] == 2 ) - s.handed = KMouseSettings::RightHanded; - else if ( (int)map[0] == 2 && (int)map[1] == 1 ) - s.handed = KMouseSettings::LeftHanded; - } - else if( num_buttons >= 3 ) - { - if ( (int)map[0] == 1 && (int)map[2] == 3 ) - s.handed = KMouseSettings::RightHanded; - else if ( (int)map[0] == 3 && (int)map[2] == 1 ) - s.handed = KMouseSettings::LeftHanded; - } -#else - // FIXME(E): Implement in Qt Embedded -#endif - } -#endif //Q_WS_WIN - } -#ifdef Q_WS_WIN - //not cached - s_mouseSettings->handed = (GetSystemMetrics(SM_SWAPBUTTON) ? KMouseSettings::LeftHanded : KMouseSettings::RightHanded); -#endif - return *s_mouseSettings; -} - -void KGlobalSettings::rereadMouseSettings() -{ -#ifndef Q_WS_WIN - delete s_mouseSettings; - s_mouseSettings = 0L; -#endif -} - -bool KGlobalSettings::isMultiHead() -{ -#ifdef Q_WS_WIN - return GetSystemMetrics(SM_CMONITORS) > 1; -#else - TQCString multiHead = getenv("KDE_MULTIHEAD"); - if (!multiHead.isEmpty()) { - return (multiHead.lower() == "true"); - } - return false; -#endif -} - -bool KGlobalSettings::wheelMouseZooms() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry( "WheelMouseZooms", KDE_DEFAULT_WHEEL_ZOOM ); -} - -TQRect KGlobalSettings::splashScreenDesktopGeometry() -{ - TQDesktopWidget *dw = TQApplication::desktop(); - - if (dw->isVirtualDesktop()) { - KConfigGroup group(KGlobal::config(), "Windows"); - int scr = group.readNumEntry("Unmanaged", -3); - if (group.readBoolEntry("XineramaEnabled", true) && scr != -2) { - if (scr == -3) - scr = dw->screenNumber(TQCursor::pos()); - return dw->screenGeometry(scr); - } else { - return dw->geometry(); - } - } else { - return dw->geometry(); - } -} - -TQRect KGlobalSettings::desktopGeometry(const TQPoint& point) -{ - TQDesktopWidget *dw = TQApplication::desktop(); - - if (dw->isVirtualDesktop()) { - KConfigGroup group(KGlobal::config(), "Windows"); - if (group.readBoolEntry("XineramaEnabled", true) && - group.readBoolEntry("XineramaPlacementEnabled", true)) { - return dw->screenGeometry(dw->screenNumber(point)); - } else { - return dw->geometry(); - } - } else { - return dw->geometry(); - } -} - -TQRect KGlobalSettings::desktopGeometry(TQWidget* w) -{ - TQDesktopWidget *dw = TQApplication::desktop(); - - if (dw->isVirtualDesktop()) { - KConfigGroup group(KGlobal::config(), "Windows"); - if (group.readBoolEntry("XineramaEnabled", true) && - group.readBoolEntry("XineramaPlacementEnabled", true)) { - if (w) - return dw->screenGeometry(dw->screenNumber(w)); - else return dw->screenGeometry(-1); - } else { - return dw->geometry(); - } - } else { - return dw->geometry(); - } -} - -bool KGlobalSettings::showIconsOnPushButtons() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("ShowIconsOnPushButtons", - KDE_DEFAULT_ICON_ON_PUSHBUTTON); -} - -bool KGlobalSettings::showFilePreview(const KURL &url) -{ - KConfigGroup g(KGlobal::config(), "PreviewSettings"); - TQString protocol = url.protocol(); - bool defaultSetting = KProtocolInfo::showFilePreview( protocol ); - return g.readBoolEntry(protocol, defaultSetting ); -} - -bool KGlobalSettings::showKonqIconActivationEffect() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("ShowKonqIconActivationEffect", - KDE_DEFAULT_KONQ_ACTIVATION_EFFECT); -} - -bool KGlobalSettings::opaqueResize() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readBoolEntry("OpaqueResize", - KDE_DEFAULT_OPAQUE_RESIZE); -} - -int KGlobalSettings::buttonLayout() -{ - KConfigGroup g( KGlobal::config(), "KDE" ); - return g.readNumEntry("ButtonLayout", - KDE_DEFAULT_BUTTON_LAYOUT); -} diff --git a/kdecore/kglobalsettings.h b/kdecore/kglobalsettings.h deleted file mode 100644 index 07a6f2ccb..000000000 --- a/kdecore/kglobalsettings.h +++ /dev/null @@ -1,584 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 David Faure <faure@kde.org> - - 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 _KGLOBALSETTINGS_H -#define _KGLOBALSETTINGS_H - -#include <tqstring.h> -#include <tqcolor.h> -#include <tqfont.h> -#include "kdelibs_export.h" - -#define KDE_DEFAULT_SINGLECLICK false -#define KDE_DEFAULT_ICONTEXTROUNDED true -#define KDE_DEFAULT_INSERTTEAROFFHANDLES 0 -#define KDE_DEFAULT_AUTOSELECTDELAY -1 -#define KDE_DEFAULT_CHANGECURSOR true -#define KDE_DEFAULT_LARGE_CURSOR false -#define KDE_DEFAULT_VISUAL_ACTIVATE true -#define KDE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 -#define KDE_DEFAULT_WHEEL_ZOOM false -#define KDE_DEFAULT_ICON_ON_PUSHBUTTON true -#define KDE_DEFAULT_OPAQUE_RESIZE true -#define KDE_DEFAULT_BUTTON_LAYOUT 0 -#define KDE_DEFAULT_SHADE_SORT_COLUMN true -#define KDE_DEFAULT_KONQ_ACTIVATION_EFFECT true - -class KURL; - -/** - * Access the KDE global configuration. - * - * @author David Faure <faure@kde.org> - */ -class KDECORE_EXPORT KGlobalSettings -{ - public: - - /** - * Returns a threshold in pixels for drag & drop operations. - * As long as the mouse movement has not exceeded this number - * of pixels in either X or Y direction no drag operation may - * be started. This prevents spurious drags when the user intended - * to click on something but moved the mouse a bit while doing so. - * - * For this to work you must save the position of the mouse (oldPos) - * in the TQWidget::mousePressEvent(). - * When the position of the mouse (newPos) - * in a TQWidget::mouseMoveEvent() exceeds this threshold - * you may start a drag - * which should originate from oldPos. - * - * Example code: - * \code - * void KColorCells::mousePressEvent( TQMouseEvent *e ) - * { - * mOldPos = e->pos(); - * } - * - * void KColorCells::mouseMoveEvent( TQMouseEvent *e ) - * { - * if( !(e->state() && LeftButton)) return; - * - * int delay = KGlobalSettings::dndEventDelay(); - * TQPoint newPos = e->pos(); - * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || - * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) - * { - * // Drag color object - * int cell = posToCell(mOldPos); // Find color at mOldPos - * if ((cell != -1) && colors[cell].isValid()) - * { - * KColorDrag *d = KColorDrag::makeDrag( colors[cell], this); - * d->dragCopy(); - * } - * } - * } - * \endcode - * @return the threshold for drag & drop in pixels - */ - - static int dndEventDelay(); - - /** - * Returns whether KDE runs in single (default) or double click - * mode. - * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html - * @return true if single click mode, or false if double click mode. - **/ - static bool singleClick(); - - /** - * Returns whether icon text is drawn in a rounded style - * @return true if rounded, or false if rectangular. - **/ - static bool iconUseRoundedRect(); - - /** - * This enum describes the return type for insertTearOffHandle() whether to insert - * a handle or not. Applications who independently want to use handles in their popup menus - * should test for Application level before calling the appropriate function in KPopupMenu. - * @since 3.1 - **/ - enum TearOffHandle { - Disable = 0, ///< disable tear-off handles - ApplicationLevel, ///< enable on application level - Enable ///< enable tear-off handles - }; - - /** - * Returns whether tear-off handles are inserted in KPopupMenus. - * @return whether tear-off handles are inserted in KPopupMenus. - * @since 3.1 - **/ - static TearOffHandle insertTearOffHandle(); - - /** - * Checks whether the cursor changes over icons. - * @return the KDE setting for "change cursor over icon" - */ - static bool changeCursorOverIcon(); - - /** - * Checks whether to show feedback when in item (specifically an - * icon) is activated. - * @return whether to show some feedback when an item is activated. - */ - static bool visualActivate(); - - /** - * Returns the speed of the visual activation feedback. - * @return the speed of the visual activation feedback, between - * 0 for minimum and 100 for maximum speed - */ - static unsigned int visualActivateSpeed(); - - /** - * Returns the KDE setting for the auto-select option. - * - * @return the auto-select delay or -1 if auto-select is disabled. - */ - static int autoSelectDelay(); - - /** - * Returns the KDE setting for the shortcut key to open - * context menus. - * - * @return the key that pops up context menus. - */ - static int contextMenuKey (); - - /** - * Returns the KDE setting for context menus. - * - * @return whether context menus should be shown on button press - * or button release (click). - */ - static bool showContextMenusOnPress (); - - /** - * This enum describes the completion mode used for by the KCompletion class. - * See <a href="http://developer.kde.org/documentation/standards/kde/style/keys/completion.html"> - * the styleguide</a>. - **/ - enum Completion { - /** - * No completion is used. - */ - CompletionNone=1, - /** - * Text is automatically filled in whenever possible. - */ - CompletionAuto, - /** - * Same as automatic except shortest match is used for completion. - */ - CompletionMan, - /** - * Complete text much in the same way as a typical *nix shell would. - */ - CompletionShell, - /** - * Lists all possible matches in a popup list-box to choose from. - */ - CompletionPopup, - /** - * Lists all possible matches in a popup list-box to choose from, and automatically - * fill the result whenever possible. - */ - CompletionPopupAuto - }; - - /** - * Returns the preferred completion mode setting. - * - * @return Completion. Default is @p CompletionPopup. - */ - static Completion completionMode(); - - /** - * Describes the mouse settings. - */ - struct KMouseSettings - { - enum { RightHanded = 0, LeftHanded = 1 }; - int handed; // left or right - }; - - /** - * This returns the current mouse settings. - * On Windows, settings are retrieved from the system. - * @return the current mouse settings - */ - static KMouseSettings & mouseSettings(); - - /** - * The path to the desktop directory of the current user. - * @return the user's desktop directory - */ - static TQString desktopPath() { initStatic(); return *s_desktopPath; } - - /** - * The path to the autostart directory of the current user. - * @return the path of the autostart directory - */ - static TQString autostartPath() { initStatic(); return *s_autostartPath; } - - /** - * DEPRECATED (starting from kde-3.4). - * This isn't where the trash contents is, anymore. - * Use KIO::trash() to trash files, "trash:/" to list the trash contents. - */ - static TQString trashPath() { initStatic(); return *s_trashPath; } - // KDE4: if you want to remove the above, move it to kdesktop/init.cc, which needs - // to know the old location of the trash - - /** - * The path where documents are stored of the current user. - * @return the path of the document directory - */ - static TQString documentPath() { initStatic(); return *s_documentPath; } - - - /** - * The default color to use when highlighting toolbar buttons. - * @return the toolbar highlight color - */ - static TQColor toolBarHighlightColor(); - - /** - * The default color to use for inactive titles. - * @return the inactive title color - */ - static TQColor inactiveTitleColor(); - - /** - * The default color to use for inactive texts. - * @return the inactive text color - */ - static TQColor inactiveTextColor(); - - /** - * The default color to use for active titles. - * @return the active title color - */ - static TQColor activeTitleColor(); - - /** - * The default color to use for active texts. - * @return the active text color - */ - static TQColor activeTextColor(); - - /** - * Returns the contrast for borders. - * @return the contrast (between 0 for minimum and 10 for maximum - * contrast) - */ - static int contrast(); - - /** - * Returns the button background color - * @return the button background color - * @since 3.4 - */ - static TQColor buttonBackground(); - - /** - * Returns the button text color - * @return the button text color - * @since 3.4 - */ - static TQColor buttonTextColor(); - - /** - * Returns the default base (background) color. - * @return the default base (background) color - * @see TQColorGroup::base() - */ - static TQColor baseColor(); - - /** - * Returns the default text color. - * @return the default text color - * @see TQColorGroup::text() - */ - static TQColor textColor(); - - /** - * Returns the default link color. - * @return the default link color - */ - static TQColor linkColor(); - - /** - * Returns the default color for visited links. - * @return the default color for visited links - */ - static TQColor visitedLinkColor(); - - /** - * Returns the default color for highlighted text. - * @return the default color for highlighted text - * @see TQColorGroup::hightlightedText() - */ - static TQColor highlightedTextColor(); - - /** - * Returns the default color for text highlights. - * @return the default color for text highlights - * @see TQColorGroup::hightlight() - */ - static TQColor highlightColor(); - - /** - * Returns the alternate background color used by KListView with - * KListViewItem. Any other list that uses alternating background - * colors should use this too, to obey to the user's preferences. Returns - * an invalid color if the user doesn't want alternating backgrounds. - * @return the alternate background color - * @see calculateAlternateBackgroundColor - */ - static TQColor alternateBackgroundColor(); - - /** - * Calculates a color based on @p base to be used as alternating - * color for e.g. listviews. - * @param base the base for the calculation - * @return the calculated color - * @see alternateBackgroundColor - */ - static TQColor calculateAlternateBackgroundColor(const TQColor& base); - - /** - * Returns if the sorted column in a KListView shall be drawn with a - * shaded background color. - * @return true if the sorted column shall be shaded - * @since 3.4 - */ - static bool shadeSortColumn(); - - /** - * Returns the default general font. - * @return the default general font. - */ - static TQFont generalFont(); - - /** - * Returns the default fixed font. - * @return the default fixed font. - */ - static TQFont fixedFont(); - - /** - * Returns the default toolbar font. - * @return the default toolbar font. - */ - static TQFont toolBarFont(); - - /** - * Returns the default menu font. - * @return the default menu font. - */ - static TQFont menuFont(); - - /** - * Returns the default window title font. - * @return the default window title font. - */ - static TQFont windowTitleFont(); - - /** - * Returns the default taskbar font. - * @return the default taskbar font. - */ - static TQFont taskbarFont(); - - /** - * Returns a font of approx. 48 pt. capable of showing @p text. - * @param text the text to test - * @return the font that is capable to show the text with 48 pt - * @since 3.1 - */ - static TQFont largeFont(const TQString &text = TQString::null); - - /** - * Returns if the user specified multihead. In case the display - * has multiple screens, the return value of this function specifies - * if the user wants KDE to run on all of them or just on the primary - * On Windows, settings are retrieved from the system. - * @return true if the user chose multi head - */ - static bool isMultiHead(); - - /** - * Typically, TQScrollView derived classes can be scrolled fast by - * holding down the Ctrl-button during wheel-scrolling. - * But TQTextEdit and derived classes perform zooming instead of fast - * scrolling. - * - * This value determines whether the user wants to zoom or scroll fast - * with Ctrl-wheelscroll. - * @return true if the user wishes to zoom with the mouse wheel, - * false for scrolling - * @since 3.1 - */ - static bool wheelMouseZooms(); - - /** - * This function returns the desktop geometry for an application's splash - * screen. It takes into account the user's display settings (number of - * screens, Xinerama, etc), and the user's preferences (if KDE should be - * Xinerama aware). - * - * @return the geometry to use for the desktop. Note that it might not - * start at (0,0). - * @since 3.2 - */ - static TQRect splashScreenDesktopGeometry(); - - /** - * This function returns the desktop geometry for an application that needs - * to set the geometry of a widget on the screen manually. It takes into - * account the user's display settings (number of screens, Xinerama, etc), - * and the user's preferences (if KDE should be Xinerama aware). - * - * Note that this can break in multi-head (not Xinerama) mode because this - * point could be on multiple screens. Use with care. - * - * @param point a reference point for the widget, for instance one that the - * widget should be adjacent or on top of. - * - * @return the geometry to use for the desktop. Note that it might not - * start at (0,0). - * @since 3.2 - */ - static TQRect desktopGeometry(const TQPoint& point); - - /** - * This function returns the desktop geometry for an application that needs - * to set the geometry of a widget on the screen manually. It takes into - * account the user's display settings (number of screens, Xinerama, etc), - * and the user's preferences (if KDE should be Xinerama aware). - * - * @param w the widget in question. This is used to determine which screen - * to use in Xinerama or multi-head mode. - * - * @return the geometry to use for the desktop. Note that it might not - * start at (0,0). - * @since 3.2 - */ - static TQRect desktopGeometry(TQWidget* w); - - /** - * This function determines if the user wishes to see icons on the - * push buttons. - * - * @return Returns true if user wants to show icons. - * - * @since 3.2 - */ - static bool showIconsOnPushButtons(); - - /** - * This function determines if the user wishes to see previews - * for the selected url - * - * @return Returns true if user wants to show previews. - * - * @since 3.2 - */ - static bool showFilePreview(const KURL &); - - /** - * This function determines if the user wishes to see icon - * activation effects in Konqueror or KDesktop - * - * @return Returns true if user wants to show activation effects. - * - * @since 3.5.12 - */ - static bool showKonqIconActivationEffect(); - - /** - * Whether the user wishes to use opaque resizing. Primarily - * intended for TQSplitter::setOpaqueResize() - * - * @return Returns true if user wants to use opaque resizing. - * - * @since 3.2 - */ - static bool opaqueResize(); - - /** - * The layout scheme to use for dialog buttons - * - * @return Returns the number of the scheme to use. - * @see KDialogBase::setButtonStyle() - * @since 3.3 - */ - static int buttonLayout(); - -private: - /** - * reads in all paths from kdeglobals - */ - static void initStatic(); - /** - * initialize colors - */ - static void initColors(); - /** - * drop cached values for fonts (called by KApplication) - */ - static void rereadFontSettings(); - /** - * drop cached values for paths (called by KApplication) - */ - static void rereadPathSettings(); - /** - * drop cached values for mouse settings (called by KApplication) - */ - static void rereadMouseSettings(); - - - static TQString* s_desktopPath; - static TQString* s_autostartPath; - static TQString* s_trashPath; - static TQString* s_documentPath; - static TQFont *_generalFont; - static TQFont *_fixedFont; - static TQFont *_toolBarFont; - static TQFont *_menuFont; - static TQFont *_windowTitleFont; - static TQFont *_taskbarFont; - static TQFont *_largeFont; - static TQColor * _trinity4Blue; - static TQColor * _inactiveBackground; - static TQColor * _inactiveForeground; - static TQColor * _activeBackground; - static TQColor * _buttonBackground; - static TQColor * _selectBackground; - static TQColor * _linkColor; - static TQColor * _visitedLinkColor; - static TQColor * alternateColor; - static KMouseSettings *s_mouseSettings; - - friend class KApplication; -}; - -#endif diff --git a/kdecore/kgrantpty.c b/kdecore/kgrantpty.c deleted file mode 100644 index 7d16f5b68..000000000 --- a/kdecore/kgrantpty.c +++ /dev/null @@ -1,179 +0,0 @@ -/* kgrantpty - helper program for KPty. */ - -/* This program is based on the glibc2.1 pt_chmod. - * It was pulled out from there since both Linux - * distributors and other OSes are not able to make - * use of the glibc for different reasons. - * - * THIS IS A ROOT SUID PROGRAM - * - * Things work as following: - * - * In konsole we open a master pty. This can be - * done by at most one process. Prior to opening the - * master pty, the slave pty cannot be opened. Then, in - * grantpty, we fork to this program. The trick is, that - * the parameter is passed as a file handle, which cannot - * be faked, so that we get a secure setuid root chmod/chown - * with this program. - * - * We have to chown/chmod the slave pty to prevent eavesdroping. - * - * Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. - * Copyright (c) 1999 by Lars Doelle <lars.doelle@on-line.de>. - * GPL applies. - */ - -#include <config.h> - -#include <sys/types.h> -#include <errno.h> -#include <grp.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> -#include <unistd.h> - -#include <sys/param.h> -#if defined(__FreeBSD__) || defined(__DragonFly__) -# define BSD_PTY_HACK -# include <paths.h> -# include <dirent.h> -#endif - -#define TTY_GROUP "tty" - -int main (int argc, char *argv[]) -{ - struct stat st; - struct group* p; - gid_t gid; - uid_t uid; - mode_t mod; - char* tty; - int fd; - - /* check preconditions **************************************************/ - if (argc != 3 || (strcmp(argv[1],"--grant") && strcmp(argv[1],"--revoke"))) - { - printf("usage: %s (--grant|--revoke) <file descriptor>\n" - "%s is a helper for the KDE core libraries.\n" - "It is not intended to be called from the command line.\n" - "It needs to be installed setuid root to function.\n", - argv[0], argv[0]); - return 1; /* FAIL */ - } - - if (geteuid () != 0) - { - fprintf(stderr, "%s not installed setuid root\n", argv[0]); - return 1; /* FAIL */ - } - - fd = atoi(argv[2]); - - /* get slave pty name from master pty file handle *********/ -#ifdef HAVE_PTSNAME - tty = ptsname(fd); - if (!tty) -#endif - { - /* Check that fd is a valid master pseudo terminal. */ - char *pty = ttyname(fd); - -#ifdef BSD_PTY_HACK - if (pty == NULL) - { - /* - Hack to make kgrantpty work on some versions of FreeBSD (and possibly - other systems): ttyname(3) does not work with a file descriptor opened - on a /dev/pty?? device. - - Instead, this code looks through all the devices in /dev for a device - which has the same inode as our PTY_FILENO descriptor... if found, we - have the name for our pty. - */ - - struct dirent *dirp; - DIR *dp; - struct stat dsb; - - if (fstat(fd, &dsb) != -1) { - if ((dp = opendir(_PATH_DEV)) != NULL) { - while ((dirp = readdir(dp))) { - if (dirp->d_fileno != dsb.st_ino) - continue; - pty = malloc(sizeof(_PATH_DEV) + strlen(dirp->d_name)); - if (pty) { - strcpy(pty, _PATH_DEV); - strcat(pty, dirp->d_name); - } - break; - } - - (void) closedir(dp); - } - } - } -#endif - - if (pty == NULL) - { - fprintf(stderr,"%s: cannot determine pty name.\n",argv[0]); - return 1; /* FAIL */ - } - - /* matches /dev/pty?? */ - if (memcmp(pty,"/dev/pty",8)) - { - fprintf(stderr,"%s: determined a strange pty name `%s'.\n",argv[0],pty); - return 1; /* FAIL */ - } - - tty = malloc(strlen(pty) + 1); - strcpy(tty,"/dev/tty"); - strcat(tty,pty+8); - } - - /* Check that the returned slave pseudo terminal is a character device. */ - if (stat(tty, &st) < 0 || !S_ISCHR(st.st_mode)) - { - fprintf(stderr,"%s: found `%s' not to be a character device.\n",argv[0],tty); - return 1; /* FAIL */ - } - - /* setup parameters for the operation ***********************************/ - - if (!strcmp(argv[1],"--grant")) - { - uid = getuid(); - p = getgrnam(TTY_GROUP); - if (!p) - p = getgrnam("wheel"); - gid = p ? p->gr_gid : getgid (); - mod = S_IRUSR | S_IWUSR | S_IWGRP; - } - else - { - uid = 0; - gid = st.st_gid == getgid () ? 0 : -1; - mod = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - } - - /* Perform the actual chown/chmod ************************************/ - - if (chown(tty, uid, gid) < 0) - { - fprintf(stderr,"%s: cannot chown %s: %s\n",argv[0],tty,strerror(errno)); - return 1; /* FAIL */ - } - - if (chmod(tty, mod) < 0) - { - fprintf(stderr,"%s: cannot chmod %s: %s\n",argv[0],tty,strerror(errno)); - return 1; /* FAIL */ - } - - return 0; /* OK */ -} diff --git a/kdecore/kiconeffect.cpp b/kdecore/kiconeffect.cpp deleted file mode 100644 index 9c76c7e4d..000000000 --- a/kdecore/kiconeffect.cpp +++ /dev/null @@ -1,920 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * $Id$ - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * with minor additions and based on ideas from - * Torsten Rahn <torsten@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#include <config.h> -#include <unistd.h> -#include <math.h> - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqbitmap.h> -#include <tqpixmap.h> -#include <tqimage.h> -#include <tqcolor.h> -#include <tqwidget.h> -#include <tqpainter.h> -#include <tqpen.h> -#include <tqapplication.h> -#include <tqpoint.h> -#include <tqrect.h> - -#include <kdebug.h> -#include <kglobal.h> -#include <kconfig.h> -#include <kglobalsettings.h> -#include <kicontheme.h> -#include "kiconeffect.h" - -#if defined(Q_WS_WIN) || defined(Q_WS_MACX) -static bool qt_use_xrender=true; -static bool qt_has_xft=true; -#else -extern bool qt_use_xrender; -extern bool qt_has_xft; -#endif -class KIconEffectPrivate -{ -public: - TQString mKey[6][3]; - TQColor mColor2[6][3]; -}; - -KIconEffect::KIconEffect() -{ - d = new KIconEffectPrivate; - init(); -} - -KIconEffect::~KIconEffect() -{ - delete d; - d = 0L; -} - -void KIconEffect::init() -{ - KConfig *config = KGlobal::config(); - - int i, j, effect=-1; - TQStringList groups; - groups += "Desktop"; - groups += "Toolbar"; - groups += "MainToolbar"; - groups += "Small"; - groups += "Panel"; - - TQStringList states; - states += "Default"; - states += "Active"; - states += "Disabled"; - - TQStringList::ConstIterator it, it2; - TQString _togray("togray"); - TQString _colorize("colorize"); - TQString _desaturate("desaturate"); - TQString _togamma("togamma"); - TQString _none("none"); - TQString _tomonochrome("tomonochrome"); - - KConfigGroupSaver cs(config, "default"); - - for (it=groups.begin(), i=0; it!=groups.end(); it++, i++) - { - // Default effects - mEffect[i][0] = NoEffect; - mEffect[i][1] = ((i==0)||(i==4)) ? ToGamma : NoEffect; - mEffect[i][2] = ToGray; - - mTrans[i][0] = false; - mTrans[i][1] = false; - mTrans[i][2] = true; - mValue[i][0] = 1.0; - mValue[i][1] = ((i==0)||(i==4)) ? 0.7 : 1.0; - mValue[i][2] = 1.0; - mColor[i][0] = TQColor(144,128,248); - mColor[i][1] = TQColor(169,156,255); - mColor[i][2] = TQColor(34,202,0); - d->mColor2[i][0] = TQColor(0,0,0); - d->mColor2[i][1] = TQColor(0,0,0); - d->mColor2[i][2] = TQColor(0,0,0); - - config->setGroup(*it + "Icons"); - for (it2=states.begin(), j=0; it2!=states.end(); it2++, j++) - { - TQString tmp = config->readEntry(*it2 + "Effect"); - if (tmp == _togray) - effect = ToGray; - else if (tmp == _colorize) - effect = Colorize; - else if (tmp == _desaturate) - effect = DeSaturate; - else if (tmp == _togamma) - effect = ToGamma; - else if (tmp == _tomonochrome) - effect = ToMonochrome; - else if (tmp == _none) - effect = NoEffect; - else - continue; - if(effect != -1) - mEffect[i][j] = effect; - mValue[i][j] = config->readDoubleNumEntry(*it2 + "Value"); - mColor[i][j] = config->readColorEntry(*it2 + "Color"); - d->mColor2[i][j] = config->readColorEntry(*it2 + "Color2"); - mTrans[i][j] = config->readBoolEntry(*it2 + "SemiTransparent"); - - } - } -} - -bool KIconEffect::hasEffect(int group, int state) const -{ - return mEffect[group][state] != NoEffect; -} - -TQString KIconEffect::fingerprint(int group, int state) const -{ - if ( group >= KIcon::LastGroup ) return ""; - TQString cached = d->mKey[group][state]; - if (cached.isEmpty()) - { - TQString tmp; - cached = tmp.setNum(mEffect[group][state]); - cached += ':'; - cached += tmp.setNum(mValue[group][state]); - cached += ':'; - cached += mTrans[group][state] ? TQString::tqfromLatin1("trans") - : TQString::tqfromLatin1("notrans"); - if (mEffect[group][state] == Colorize || mEffect[group][state] == ToMonochrome) - { - cached += ':'; - cached += mColor[group][state].name(); - } - if (mEffect[group][state] == ToMonochrome) - { - cached += ':'; - cached += d->mColor2[group][state].name(); - } - - d->mKey[group][state] = cached; - } - - return cached; -} - -TQImage KIconEffect::apply(TQImage image, int group, int state) const -{ - if (state >= KIcon::LastState) - { - kdDebug(265) << "Illegal icon state: " << state << "\n"; - return image; - } - if (group >= KIcon::LastGroup) - { - kdDebug(265) << "Illegal icon group: " << group << "\n"; - return image; - } - return apply(image, mEffect[group][state], mValue[group][state], - mColor[group][state], d->mColor2[group][state], mTrans[group][state]); -} - -TQImage KIconEffect::apply(TQImage image, int effect, float value, const TQColor col, bool trans) const -{ - return apply (image, effect, value, col, KGlobalSettings::baseColor(), trans); -} - -TQImage KIconEffect::apply(TQImage image, int effect, float value, const TQColor col, const TQColor col2, bool trans) const -{ - if (effect >= LastEffect ) - { - kdDebug(265) << "Illegal icon effect: " << effect << "\n"; - return image; - } - if (value > 1.0) - value = 1.0; - else if (value < 0.0) - value = 0.0; - switch (effect) - { - case ToGray: - toGray(image, value); - break; - case DeSaturate: - deSaturate(image, value); - break; - case Colorize: - colorize(image, col, value); - break; - case ToGamma: - toGamma(image, value); - break; - case ToMonochrome: - toMonochrome(image, col, col2, value); - break; - } - if (trans == true) - { - semiTransparent(image); - } - return image; -} - -TQPixmap KIconEffect::apply(TQPixmap pixmap, int group, int state) const -{ - if (state >= KIcon::LastState) - { - kdDebug(265) << "Illegal icon state: " << state << "\n"; - return pixmap; - } - if (group >= KIcon::LastGroup) - { - kdDebug(265) << "Illegal icon group: " << group << "\n"; - return pixmap; - } - return apply(pixmap, mEffect[group][state], mValue[group][state], - mColor[group][state], d->mColor2[group][state], mTrans[group][state]); -} - -TQPixmap KIconEffect::apply(TQPixmap pixmap, int effect, float value, - const TQColor col, bool trans) const -{ - return apply (pixmap, effect, value, col, KGlobalSettings::baseColor(), trans); -} - -TQPixmap KIconEffect::apply(TQPixmap pixmap, int effect, float value, - const TQColor col, const TQColor col2, bool trans) const -{ - TQPixmap result; - - if (effect >= LastEffect ) - { - kdDebug(265) << "Illegal icon effect: " << effect << "\n"; - return result; - } - - if ((trans == true) && (effect == NoEffect)) - { - result = pixmap; - semiTransparent(result); - } - else if ( effect != NoEffect ) - { - TQImage tmpImg = pixmap.convertToImage(); - tmpImg = apply(tmpImg, effect, value, col, col2, trans); - result.convertFromImage(tmpImg); - } - else - result = pixmap; - - return result; -} - -// Taken from KImageEffect. We don't want to link tdecore to tdeui! As long -// as this code is not too big, it doesn't seem much of a problem to me. - -void KIconEffect::toGray(TQImage &img, float value) -{ - int pixels = (img.depth() > 8) ? img.width()*img.height() - : img.numColors(); - unsigned int *data = img.depth() > 8 ? (unsigned int *) img.bits() - : (unsigned int *) img.tqcolorTable(); - int rval, gval, bval, val, alpha, i; - for (i=0; i<pixels; i++) - { - val = tqGray(data[i]); - alpha = tqAlpha(data[i]); - if (value < 1.0) - { - rval = static_cast<int>(value*val+(1.0-value)*tqRed(data[i])); - gval = static_cast<int>(value*val+(1.0-value)*tqGreen(data[i])); - bval = static_cast<int>(value*val+(1.0-value)*tqBlue(data[i])); - data[i] = tqRgba(rval, gval, bval, alpha); - } else - data[i] = tqRgba(val, val, val, alpha); - } -} - -void KIconEffect::colorize(TQImage &img, const TQColor &col, float value) -{ - int pixels = (img.depth() > 8) ? img.width()*img.height() - : img.numColors(); - unsigned int *data = img.depth() > 8 ? (unsigned int *) img.bits() - : (unsigned int *) img.tqcolorTable(); - int rval, gval, bval, val, alpha, i; - float rcol = col.red(), gcol = col.green(), bcol = col.blue(); - for (i=0; i<pixels; i++) - { - val = tqGray(data[i]); - if (val < 128) - { - rval = static_cast<int>(rcol/128*val); - gval = static_cast<int>(gcol/128*val); - bval = static_cast<int>(bcol/128*val); - } - else if (val > 128) - { - rval = static_cast<int>((val-128)*(2-rcol/128)+rcol-1); - gval = static_cast<int>((val-128)*(2-gcol/128)+gcol-1); - bval = static_cast<int>((val-128)*(2-bcol/128)+bcol-1); - } - else // val == 128 - { - rval = static_cast<int>(rcol); - gval = static_cast<int>(gcol); - bval = static_cast<int>(bcol); - } - if (value < 1.0) - { - rval = static_cast<int>(value*rval+(1.0 - value)*tqRed(data[i])); - gval = static_cast<int>(value*gval+(1.0 - value)*tqGreen(data[i])); - bval = static_cast<int>(value*bval+(1.0 - value)*tqBlue(data[i])); - } - - alpha = tqAlpha(data[i]); - data[i] = tqRgba(rval, gval, bval, alpha); - } -} - -void KIconEffect::toMonochrome(TQImage &img, const TQColor &black, const TQColor &white, float value) { - int pixels = (img.depth() > 8) ? img.width()*img.height() : img.numColors(); - unsigned int *data = img.depth() > 8 ? (unsigned int *) img.bits() - : (unsigned int *) img.tqcolorTable(); - int rval, gval, bval, alpha, i; - int rw = white.red(), gw = white.green(), bw = white.blue(); - int rb = black.red(), gb = black.green(), bb = black.blue(); - - double values = 0, sum = 0; - bool grayscale = true; - // Step 1: determine the average brightness - for (i=0; i<pixels; i++) { - sum += tqGray(data[i])*tqAlpha(data[i]) + 255*(255-tqAlpha(data[i])); - values += 255; - if ((tqRed(data[i]) != tqGreen(data[i]) ) || (tqGreen(data[i]) != tqBlue(data[i]) )) - grayscale = false; - } - double medium = sum/values; - - // Step 2: Modify the image - if (grayscale) { - for (i=0; i<pixels; i++) { - int v = tqRed(data[i]); - rval = static_cast<int>( ((255-v)*rb + v*rw)*value/255 + (1.0-value)*tqRed(data[i])); - gval = static_cast<int>( ((255-v)*gb + v*gw)*value/255 + (1.0-value)*tqGreen(data[i])); - bval = static_cast<int>( ((255-v)*bb + v*bw)*value/255 + (1.0-value)*tqBlue(data[i])); - - alpha = tqAlpha(data[i]); - data[i] = tqRgba(rval, gval, bval, alpha); - } - } - else { - for (i=0; i<pixels; i++) { - if (tqGray(data[i]) <= medium) { - rval = static_cast<int>(value*rb+(1.0-value)*tqRed(data[i])); - gval = static_cast<int>(value*gb+(1.0-value)*tqGreen(data[i])); - bval = static_cast<int>(value*bb+(1.0-value)*tqBlue(data[i])); - } - else { - rval = static_cast<int>(value*rw+(1.0-value)*tqRed(data[i])); - gval = static_cast<int>(value*gw+(1.0-value)*tqGreen(data[i])); - bval = static_cast<int>(value*bw+(1.0-value)*tqBlue(data[i])); - } - - alpha = tqAlpha(data[i]); - data[i] = tqRgba(rval, gval, bval, alpha); - } - } -} - -void KIconEffect::deSaturate(TQImage &img, float value) -{ - int pixels = (img.depth() > 8) ? img.width()*img.height() - : img.numColors(); - unsigned int *data = (img.depth() > 8) ? (unsigned int *) img.bits() - : (unsigned int *) img.tqcolorTable(); - TQColor color; - int h, s, v, i; - for (i=0; i<pixels; i++) - { - color.setRgb(data[i]); - color.hsv(&h, &s, &v); - color.setHsv(h, (int) (s * (1.0 - value) + 0.5), v); - data[i] = tqRgba(color.red(), color.green(), color.blue(), - tqAlpha(data[i])); - } -} - -void KIconEffect::toGamma(TQImage &img, float value) -{ - int pixels = (img.depth() > 8) ? img.width()*img.height() - : img.numColors(); - unsigned int *data = (img.depth() > 8) ? (unsigned int *) img.bits() - : (unsigned int *) img.tqcolorTable(); - TQColor color; - int i, rval, gval, bval; - float gamma; - gamma = 1/(2*value+0.5); - - for (i=0; i<pixels; i++) - { - color.setRgb(data[i]); - color.rgb(&rval, &gval, &bval); - rval = static_cast<int>(pow(static_cast<float>(rval)/255 , gamma)*255); - gval = static_cast<int>(pow(static_cast<float>(gval)/255 , gamma)*255); - bval = static_cast<int>(pow(static_cast<float>(bval)/255 , gamma)*255); - data[i] = tqRgba(rval, gval, bval, tqAlpha(data[i])); - } -} - -void KIconEffect::semiTransparent(TQImage &img) -{ - img.setAlphaBuffer(true); - - int x, y; - if (img.depth() == 32) - { - int width = img.width(); - int height = img.height(); - - if (qt_use_xrender && qt_has_xft ) - for (y=0; y<height; y++) - { -#ifdef WORDS_BIGENDIAN - uchar *line = (uchar*) img.scanLine(y); -#else - uchar *line = (uchar*) img.scanLine(y) + 3; -#endif - for (x=0; x<width; x++) - { - *line >>= 1; - line += 4; - } - } - else - for (y=0; y<height; y++) - { - QRgb *line = (QRgb *) img.scanLine(y); - for (x=(y%2); x<width; x+=2) - line[x] &= 0x00ffffff; - } - - } else - { - // Insert transparent pixel into the clut. - int transColor = -1; - - // search for a color that is already transparent - for (x=0; x<img.numColors(); x++) - { - // try to find already transparent pixel - if (tqAlpha(img.color(x)) < 127) - { - transColor = x; - break; - } - } - - - // FIXME: image must have transparency - if(transColor < 0 || transColor >= img.numColors()) - return; - - img.setColor(transColor, 0); - if(img.depth() == 8) - { - for (y=0; y<img.height(); y++) - { - unsigned char *line = img.scanLine(y); - for (x=(y%2); x<img.width(); x+=2) - line[x] = transColor; - } - } - else - { - // SLOOW, but simple, as we would have to - // deal with endianess etc on our own here - for (y=0; y<img.height(); y++) - for (x=(y%2); x<img.width(); x+=2) - img.setPixel(x, y, transColor); - } - } -} - -void KIconEffect::semiTransparent(TQPixmap &pix) -{ - if ( qt_use_xrender && qt_has_xft ) - { - TQImage img=pix.convertToImage(); - semiTransparent(img); - pix.convertFromImage(img); - return; - } - - TQImage img; - if (pix.mask() != 0L) - img = pix.mask()->convertToImage(); - else - { - img.create(pix.size(), 1, 2, TQImage::BigEndian); - img.fill(1); - } - - for (int y=0; y<img.height(); y++) - { - QRgb *line = (QRgb *) img.scanLine(y); - QRgb pattern = (y % 2) ? 0x55555555 : 0xaaaaaaaa; - for (int x=0; x<(img.width()+31)/32; x++) - line[x] &= pattern; - } - TQBitmap mask; - mask.convertFromImage(img); - pix.setMask(mask); -} - -TQImage KIconEffect::doublePixels(TQImage src) const -{ - TQImage dst; - if (src.depth() == 1) - { - kdDebug(265) << "image depth 1 not supported\n"; - return dst; - } - - int w = src.width(); - int h = src.height(); - dst.create(w*2, h*2, src.depth()); - dst.setAlphaBuffer(src.hasAlphaBuffer()); - - int x, y; - if (src.depth() == 32) - { - QRgb *l1, *l2; - for (y=0; y<h; y++) - { - l1 = (QRgb *) src.scanLine(y); - l2 = (QRgb *) dst.scanLine(y*2); - for (x=0; x<w; x++) - { - l2[x*2] = l2[x*2+1] = l1[x]; - } - memcpy(dst.scanLine(y*2+1), l2, dst.bytesPerLine()); - } - } else - { - for (x=0; x<src.numColors(); x++) - dst.setColor(x, src.color(x)); - - unsigned char *l1, *l2; - for (y=0; y<h; y++) - { - l1 = src.scanLine(y); - l2 = dst.scanLine(y*2); - for (x=0; x<w; x++) - { - l2[x*2] = l1[x]; - l2[x*2+1] = l1[x]; - } - memcpy(dst.scanLine(y*2+1), l2, dst.bytesPerLine()); - } - } - return dst; -} - -void KIconEffect::overlay(TQImage &src, TQImage &overlay) -{ - if (src.depth() != overlay.depth()) - { - kdDebug(265) << "Image depth src != overlay!\n"; - return; - } - if (src.size() != overlay.size()) - { - kdDebug(265) << "Image size src != overlay\n"; - return; - } - if (!overlay.hasAlphaBuffer()) - { - kdDebug(265) << "Overlay doesn't have alpha buffer!\n"; - return; - } - - int i, j; - - // We don't do 1 bpp - - if (src.depth() == 1) - { - kdDebug(265) << "1bpp not supported!\n"; - return; - } - - // Overlay at 8 bpp doesn't use alpha blending - - if (src.depth() == 8) - { - if (src.numColors() + overlay.numColors() > 255) - { - kdDebug(265) << "Too many colors in src + overlay!\n"; - return; - } - - // Find transparent pixel in overlay - int trans; - for (trans=0; trans<overlay.numColors(); trans++) - { - if (tqAlpha(overlay.color(trans)) == 0) - { - kdDebug(265) << "transparent pixel found at " << trans << "\n"; - break; - } - } - if (trans == overlay.numColors()) - { - kdDebug(265) << "transparent pixel not found!\n"; - return; - } - - // Merge color tables - int nc = src.numColors(); - src.setNumColors(nc + overlay.numColors()); - for (i=0; i<overlay.numColors(); i++) - { - src.setColor(nc+i, overlay.color(i)); - } - - // Overwrite nontransparent pixels. - unsigned char *oline, *sline; - for (i=0; i<src.height(); i++) - { - oline = overlay.scanLine(i); - sline = src.scanLine(i); - for (j=0; j<src.width(); j++) - { - if (oline[j] != trans) - sline[j] = oline[j]+nc; - } - } - } - - // Overlay at 32 bpp does use alpha blending - - if (src.depth() == 32) - { - QRgb *oline, *sline; - int r1, g1, b1, a1; - int r2, g2, b2, a2; - - for (i=0; i<src.height(); i++) - { - oline = (QRgb *) overlay.scanLine(i); - sline = (QRgb *) src.scanLine(i); - - for (j=0; j<src.width(); j++) - { - r1 = tqRed(oline[j]); - g1 = tqGreen(oline[j]); - b1 = tqBlue(oline[j]); - a1 = tqAlpha(oline[j]); - - r2 = tqRed(sline[j]); - g2 = tqGreen(sline[j]); - b2 = tqBlue(sline[j]); - a2 = tqAlpha(sline[j]); - - r2 = (a1 * r1 + (0xff - a1) * r2) >> 8; - g2 = (a1 * g1 + (0xff - a1) * g2) >> 8; - b2 = (a1 * b1 + (0xff - a1) * b2) >> 8; - a2 = QMAX(a1, a2); - - sline[j] = tqRgba(r2, g2, b2, a2); - } - } - } - - return; -} - - void -KIconEffect::visualActivate(TQWidget * widget, TQRect rect) -{ - if (!KGlobalSettings::visualActivate()) - return; - - uint actSpeed = KGlobalSettings::visualActivateSpeed(); - - uint actCount = QMIN(rect.width(), rect.height()) / 2; - - // Clip actCount to range 1..10. - - if (actCount < 1) - actCount = 1; - - else if (actCount > 10) - actCount = 10; - - // Clip actSpeed to range 1..100. - - if (actSpeed < 1) - actSpeed = 1; - - else if (actSpeed > 100) - actSpeed = 100; - - // actSpeed needs to be converted to actDelay. - // actDelay is inversely proportional to actSpeed and needs to be - // divided up into actCount portions. - // We also convert the us value to ms. - - unsigned int actDelay = (1000 * (100 - actSpeed)) / actCount; - - //kdDebug() << "actCount=" << actCount << " actDelay=" << actDelay << endl; - - TQPoint c = rect.center(); - - TQPainter p(widget); - - // Use NotROP to avoid having to tqrepaint the pixmap each time. - p.setPen(TQPen(Qt::black, 2, Qt::DotLine)); - p.setRasterOp(TQt::NotROP); - - // The spacing between the rects we draw. - // Use the minimum of width and height to avoid painting outside the - // pixmap area. - //unsigned int delta(QMIN(rect.width() / actCount, rect.height() / actCount)); - - // Support for rectangles by David - unsigned int deltaX = rect.width() / actCount; - unsigned int deltaY = rect.height() / actCount; - - for (unsigned int i = 1; i < actCount; i++) { - - int w = i * deltaX; - int h = i * deltaY; - - rect.setRect(c.x() - w / 2, c.y() - h / 2, w, h); - - p.drawRect(rect); - p.flush(); - - usleep(actDelay); - - p.drawRect(rect); - } -} - -void -KIconEffect::visualActivate(TQWidget * widget, TQRect rect, TQPixmap *pixmap) -{ - if (!KGlobalSettings::visualActivate()) - return; - - // Image too big to display smoothly - if ((rect.width() > 160) || (rect.height() > 160)) { - visualActivate(widget, rect); // call old effect - return; - } - - uint actSpeed = KGlobalSettings::visualActivateSpeed(); - uint actCount = TQMIN(rect.width(), rect.height()) / 4; - - - // Clip actCount to range 1..10. - if (actCount < 1) - actCount = 1; - - else if (actCount > 10) - actCount = 10; - - // Clip actSpeed to range 1..100. - if (actSpeed < 1) - actSpeed = 1; - - else if (actSpeed > 100) - actSpeed = 100; - - // actSpeed needs to be converted to actDelay. - // actDelay is inversely proportional to actSpeed and needs to be - // divided up into actCount portions. - // We also convert the us value to ms. - - unsigned int actDelay = (1000 * (100 - actSpeed)) / actCount; - - unsigned int deltaX = rect.width() / actCount * 1.5; - unsigned int deltaY = rect.height() / actCount * 1.5; - - TQPoint c = rect.center(); - TQRect maxRect(c.x() - (actCount * 2) * deltaX /2, - c.y() - (actCount * 2) * deltaY /2, - actCount * 2 * deltaX, - actCount * 2 * deltaY); - - // convert rect to global coordinates if needed - if ((widget->rect().width() <= maxRect.width()) - || (widget->rect().height() <= maxRect.height())) - { - TQPoint topLeft(rect.x(), rect.y()); - rect.moveLeft(widget->mapToGlobal(topLeft).x()); - rect.moveTop(widget->mapToGlobal(topLeft).y()); - c = rect.center(); - maxRect.setRect(c.x() - (actCount * 2) * deltaX /2, - c.y() - (actCount * 2) * deltaY /2, - actCount * 2 * deltaX, - actCount * 2 * deltaY); - } - - TQPainter *p; - TQImage img = pixmap->convertToImage(); - TQPixmap pix; - TQPixmap composite(maxRect.width(), maxRect.height(), -1, TQPixmap::BestOptim); - TQPainter cPainter(&composite); - TQPoint cComposite = composite.rect().center(); - - // enable alpha blending - img.setAlphaBuffer(true); - - // Ugly hack... Get "Screenshot" to blt into and even do that on the - // root window if the display area of <widget> is too small - if ((widget->rect().width() <= maxRect.width()) - || (widget->rect().height() <= maxRect.height())) - { -// p = new TQPainter(TQApplication::desktop()->screen( -1 ), TRUE); // WARNING: This was done in Qt3. It only worked in this placement due to a glitch in Qt3; it has therefore been moved below grabWidget, where it should have been in the first place. - pix = TQPixmap::grabWindow((TQApplication::desktop()->screen( -1 ))->winId(), - maxRect.x(), - maxRect.y(), - maxRect.width(), - maxRect.height()); - p = new TQPainter(TQApplication::desktop()->screen( -1 ), TRUE); - } else - { - // not as ugly as drawing directly to the screen -// p = new TQPainter(widget); // WARNING: This was done in Qt3. See above. - pix = TQPixmap::grabWidget(widget, - maxRect.x(), - maxRect.y(), - maxRect.width(), - maxRect.height()); - p = new TQPainter(widget); - } - uchar deltaAlpha = 255 / (actCount * 1.2); - - // Activate effect like MacOS X - for (unsigned int i = actCount; i < actCount * 2; i++) { - - int w = i * deltaX; - int h = i * deltaY; - - rect.setRect(cComposite.x() - w / 2, cComposite.y() - h / 2, w, h); - - // draw offscreen - cPainter.drawPixmap(0, 0, pix, 0, 0, pix.width(), pix.height()); - cPainter.drawImage(rect, img); - cPainter.flush(); - - // put onscreen - p->drawPixmap(maxRect, composite); - p->flush(); - - // Fade out Icon a bit more - int x, y; - if ((img.depth() == 32) && qt_use_xrender && qt_has_xft) - { - int width = img.width(); - int height = img.height(); - - for (y=0; y<height; y++) - { -#ifdef WORDS_BIGENDIAN - uchar *line = (uchar*) img.scanLine(y); -#else - uchar *line = (uchar*) img.scanLine(y) + 3; -#endif - for (x=0; x<width; x++) - { - *line = (*line < deltaAlpha) ? 0 : *line - deltaAlpha; - line += 4; - } - } - } - usleep(actDelay*3); - } - - // remove traces of the effect - if ((widget->rect().width() <= maxRect.width()) - || (widget->rect().height() <= maxRect.height())) - p->drawPixmap(maxRect, pix); - else { - p->drawPixmap(maxRect, pix); - widget->update(rect); - } - - delete p; -} diff --git a/kdecore/kiconeffect.h b/kdecore/kiconeffect.h deleted file mode 100644 index a8e7b685e..000000000 --- a/kdecore/kiconeffect.h +++ /dev/null @@ -1,231 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * with minor additions and based on ideas from - * Torsten Rahn <torsten@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __KIconEffect_h_Included__ -#define __KIconEffect_h_Included__ - -#include <tqimage.h> -#include <tqpixmap.h> -#include <tqcolor.h> -#include <tqrect.h> -#include "kdelibs_export.h" - -class TQWidget; - -class KIconEffectPrivate; - -/** - * Applies effects to icons. - * - * This class applies effects to icons depending on their state and - * group. For example, it can be used to make all disabled icons - * in a toolbar gray. - * @see KIcon - */ -class KDECORE_EXPORT KIconEffect -{ -public: - /** - * Create a new KIconEffect. - */ - KIconEffect(); - ~KIconEffect(); - - /** - * This is the enumeration of all possible icon effects. - * Note that 'LastEffect' is no valid icon effect but only - * used internally to check for invalid icon effects. - * - * @li NoEffect: Don't apply any icon effect - * @li ToGray: Tints the icon gray - * @li Colorize: Tints the icon with an other color - * @li ToGamma: Change the gamma value of the icon - * @li DeSaturate: Reduce the saturation of the icon - * @li ToMonochrome: Produces a monochrome icon - */ - enum Effects { NoEffect, ToGray, Colorize, ToGamma, DeSaturate, - ToMonochrome, ///< @since 3.4 - LastEffect }; - - /** - * Rereads configuration. - */ - void init(); - - /** - * Tests whether an effect has been configured for the given icon group. - * @param group the group to check, see KIcon::Group - * @param state the state to check, see KIcon::States - * @returns true if an effect is configured for the given @p group - * in @p state, otherwise false. - * @see KIcon::Group - * KIcon::States - */ - bool hasEffect(int group, int state) const; - - /** - * Returns a fingerprint for the effect by encoding - * the given @p group and @p state into a TQString. This - * is useful for caching. - * @param group the group, see KIcon::Group - * @param state the state, see KIcon::States - * @return the fingerprint of the given @p group+@p state - */ - TQString fingerprint(int group, int state) const; - - /** - * Applies an effect to an image. The effect to apply depends on the - * @p group and @p state parameters, and is configured by the user. - * @param src The image. - * @param group The group for the icon, see KIcon::Group - * @param state The icon's state, see KIcon::States - * @return An image with the effect applied. - */ - TQImage apply(TQImage src, int group, int state) const; - - /** - * Applies an effect to an image. - * @param src The image. - * @param effect The effect to apply, one of KIconEffect::Effects. - * @param value Strength of the effect. 0 <= @p value <= 1. - * @param rgb Color parameter for effects that need one. - * @param trans Add Transparency if trans = true. - * @return An image with the effect applied. - */ - // KDE4: make them references - TQImage apply(TQImage src, int effect, float value, const TQColor rgb, bool trans) const; - /** - * @since 3.4 - */ - TQImage apply(TQImage src, int effect, float value, const TQColor rgb, const TQColor rgb2, bool trans) const; - - /** - * Applies an effect to a pixmap. - * @param src The pixmap. - * @param group The group for the icon, see KIcon::Group - * @param state The icon's state, see KIcon::States - * @return A pixmap with the effect applied. - */ - TQPixmap apply(TQPixmap src, int group, int state) const; - - /** - * Applies an effect to a pixmap. - * @param src The pixmap. - * @param effect The effect to apply, one of KIconEffect::Effects. - * @param value Strength of the effect. 0 <= @p value <= 1. - * @param rgb Color parameter for effects that need one. - * @param trans Add Transparency if trans = true. - * @return A pixmap with the effect applied. - */ - TQPixmap apply(TQPixmap src, int effect, float value, const TQColor rgb, bool trans) const; - /** - * @since 3.4 - */ - TQPixmap apply(TQPixmap src, int effect, float value, const TQColor rgb, const TQColor rgb2, bool trans) const; - - /** - * Returns an image twice as large, consisting of 2x2 pixels. - * @param src the image. - * @return the scaled image. - */ - TQImage doublePixels(TQImage src) const; - - /** - * Provides visual feedback to show activation of an icon on a widget. - * - * Not strictly an 'icon effect', but in practice that's what it looks - * like. - * - * This method does nothing if the global 'Visual feedback on activation' - * option is not activated (See kcontrol/Peripherals/Mouse). - * - * @param widget The widget on which the effect should be painted - * @param rect This rectangle defines the effect's borders - */ - static void visualActivate(TQWidget *widget, TQRect rect); - static void visualActivate(TQWidget *widget, TQRect rect, TQPixmap *pixmap); - - /** - * Tints an image gray. - * - * @param image The image - * @param value Strength of the effect. 0 <= @p value <= 1 - */ - static void toGray(TQImage &image, float value); - - /** - * Colorizes an image with a specific color. - * - * @param image The image - * @param col The color with which the @p image is tinted - * @param value Strength of the effect. 0 <= @p value <= 1 - */ - static void colorize(TQImage &image, const TQColor &col, float value); - - /** - * Produces a monochrome icon with a given foreground and background color - * - * @param image The image - * @param white The color with which the white parts of @p image are painted - * @param black The color with which the black parts of @p image are painted - * @param value Strength of the effect. 0 <= @p value <= 1 - * @since 3.4 - */ - static void toMonochrome(TQImage &image, const TQColor &black, const TQColor &white, float value); - - /** - * Desaturates an image. - * - * @param image The image - * @param value Strength of the effect. 0 <= @p value <= 1 - */ - static void deSaturate(TQImage &image, float value); - - /** - * Changes the gamma value of an image. - * - * @param image The image - * @param value Strength of the effect. 0 <= @p value <= 1 - */ - static void toGamma(TQImage &image, float value); - - /** - * Renders an image semi-transparent. - * - * @param image The image - */ - static void semiTransparent(TQImage &image); - - /** - * Renders a pixmap semi-transparent. - * - * @param pixmap The pixmap - */ - static void semiTransparent(TQPixmap &pixmap); - - /** - * Overlays an image with an other image. - * - * @param src The image - * @param overlay The image to overlay @p src with - */ - static void overlay(TQImage &src, TQImage &overlay); - -private: - int mEffect[6][3]; - float mValue[6][3]; - TQColor mColor[6][3]; - bool mTrans[6][3]; - KIconEffectPrivate *d; -}; - -#endif diff --git a/kdecore/kiconloader.cpp b/kdecore/kiconloader.cpp deleted file mode 100644 index 317a56add..000000000 --- a/kdecore/kiconloader.cpp +++ /dev/null @@ -1,1411 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * Antonio Larrosa <larrosa@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * kiconloader.cpp: An icon loader for KDE with theming functionality. - */ - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqptrlist.h> -#include <tqintdict.h> -#include <tqpixmap.h> -#include <tqpixmapcache.h> -#include <tqimage.h> -#include <tqfileinfo.h> -#include <tqdir.h> -#include <tqiconset.h> -#include <tqmovie.h> -#include <tqbitmap.h> - -#include <kapplication.h> -#include <kipc.h> -#include <kdebug.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kconfig.h> -#include <ksimpleconfig.h> -#include <kinstance.h> - -#include <kicontheme.h> -#include <kiconloader.h> -#include <kiconeffect.h> - -#include <sys/types.h> -#include <stdlib.h> //for abs -#include <unistd.h> //for readlink -#include <dirent.h> -#include <config.h> -#include <assert.h> - -#ifdef HAVE_LIBART -#include "svgicons/ksvgiconengine.h" -#include "svgicons/ksvgiconpainter.h" -#endif - -#include <kimageeffect.h> - -#include "kiconloader_p.h" - -/*** KIconThemeNode: A node in the icon theme dependancy tree. ***/ - -KIconThemeNode::KIconThemeNode(KIconTheme *_theme) -{ - theme = _theme; -} - -KIconThemeNode::~KIconThemeNode() -{ - delete theme; -} - -void KIconThemeNode::printTree(TQString& dbgString) const -{ - /* This method doesn't have much sense anymore, so maybe it should - be removed in the (near?) future */ - dbgString += "("; - dbgString += theme->name(); - dbgString += ")"; -} - -void KIconThemeNode::queryIcons(TQStringList *result, - int size, KIcon::Context context) const -{ - // add the icons of this theme to it - *result += theme->queryIcons(size, context); -} - -void KIconThemeNode::queryIconsByContext(TQStringList *result, - int size, KIcon::Context context) const -{ - // add the icons of this theme to it - *result += theme->queryIconsByContext(size, context); -} - -KIcon KIconThemeNode::findIcon(const TQString& name, int size, - KIcon::MatchType match) const -{ - return theme->iconPath(name, size, match); -} - - -/*** KIconGroup: Icon type description. ***/ - -struct KIconGroup -{ - int size; - bool dblPixels; - bool alphaBlending; -}; - -#define KICONLOADER_CHECKS -#ifdef KICONLOADER_CHECKS -// Keep a list of recently created and destroyed KIconLoader instances in order -// to detect bugs like #68528. -struct KIconLoaderDebug - { - KIconLoaderDebug( KIconLoader* l, const TQString& a ) - : loader( l ), appname( a ), valid( true ) - {} - KIconLoaderDebug() {}; // this TQValueList feature annoys me - KIconLoader* loader; - TQString appname; - bool valid; - TQString delete_bt; - }; - -static TQValueList< KIconLoaderDebug > *kiconloaders; -#endif - -/*** KIconLoader: the icon loader ***/ - -KIconLoader::KIconLoader(const TQString& _appname, KStandardDirs *_dirs) -{ -#ifdef KICONLOADER_CHECKS - if( kiconloaders == NULL ) - kiconloaders = new TQValueList< KIconLoaderDebug>(); - // check for the (very unlikely case) that new KIconLoader gets allocated - // at exactly same address like some previous one - for( TQValueList< KIconLoaderDebug >::Iterator it = kiconloaders->begin(); - it != kiconloaders->end(); - ) - { - if( (*it).loader == this ) - it = kiconloaders->remove( it ); - else - ++it; - } - kiconloaders->append( KIconLoaderDebug( this, _appname )); -#endif - d = new KIconLoaderPrivate; - d->q = this; - d->mpGroups = 0L; - d->imgDict.setAutoDelete(true); - d->links.setAutoDelete(true); - - if (kapp) { - kapp->addKipcEventMask(KIPC::IconChanged); - TQObject::connect(kapp, TQT_SIGNAL(updateIconLoaders()), d, TQT_SLOT(reconfigure())); - } - - init( _appname, _dirs ); -} - -void KIconLoader::reconfigure( const TQString& _appname, KStandardDirs *_dirs ) -{ - d->links.clear(); - d->imgDict.clear(); - d->mThemesInTree.clear(); - d->lastImage.reset(); - d->lastImageKey = TQString::null; - delete [] d->mpGroups; - - init( _appname, _dirs ); -} - -void KIconLoader::init( const TQString& _appname, KStandardDirs *_dirs ) -{ - // If this is unequal to 0, the iconloader is initialized - // successfully. - d->mpThemeRoot = 0L; - - d->appname = _appname; - d->extraDesktopIconsLoaded = false; - d->delayedLoading = false; - - if (_dirs) - d->mpDirs = _dirs; - else - d->mpDirs = KGlobal::dirs(); - - TQString appname = _appname; - if (appname.isEmpty()) - appname = KGlobal::instance()->instanceName(); - - // Add the default theme and its base themes to the theme tree - KIconTheme *def = new KIconTheme(KIconTheme::current(), appname); - if (!def->isValid()) - { - delete def; - // warn, as this is actually a small penalty hit - kdDebug(264) << "Couldn't find current icon theme, falling back to default." << endl; - def = new KIconTheme(KIconTheme::defaultThemeName(), appname); - if (!def->isValid()) - { - kdError(264) << "Error: standard icon theme" - << " \"" << KIconTheme::defaultThemeName() << "\" " - << " not found!" << endl; - d->mpGroups=0L; - return; - } - } - d->mpThemeRoot = new KIconThemeNode(def); - d->links.append(d->mpThemeRoot); - d->mThemesInTree += KIconTheme::current(); - addBaseThemes(d->mpThemeRoot, appname); - - // These have to match the order in kicontheme.h - static const char * const groups[] = { "Desktop", "Toolbar", "MainToolbar", "Small", "Panel", 0L }; - KConfig *config = KGlobal::config(); - KConfigGroupSaver cs(config, "dummy"); - - // loading config and default sizes - d->mpGroups = new KIconGroup[(int) KIcon::LastGroup]; - for (KIcon::Group i=KIcon::FirstGroup; i<KIcon::LastGroup; i++) - { - if (groups[i] == 0L) - break; - config->setGroup(TQString::tqfromLatin1(groups[i]) + "Icons"); - d->mpGroups[i].size = config->readNumEntry("Size", 0); - d->mpGroups[i].dblPixels = config->readBoolEntry("DoublePixels", false); - if (TQPixmap::defaultDepth()>8) - d->mpGroups[i].alphaBlending = config->readBoolEntry("AlphaBlending", true); - else - d->mpGroups[i].alphaBlending = false; - - if (!d->mpGroups[i].size) - d->mpGroups[i].size = d->mpThemeRoot->theme->defaultSize(i); - } - - // Insert application specific themes at the top. - d->mpDirs->addResourceType("appicon", KStandardDirs::kde_default("data") + - appname + "/pics/"); - // ################## KDE4: consider removing the toolbar directory - d->mpDirs->addResourceType("appicon", KStandardDirs::kde_default("data") + - appname + "/toolbar/"); - - // Add legacy icon dirs. - TQStringList dirs; - dirs += d->mpDirs->resourceDirs("icon"); - dirs += d->mpDirs->resourceDirs("pixmap"); - dirs += d->mpDirs->resourceDirs("xdgdata-icon"); - dirs += "/usr/share/pixmaps"; - // These are not in the icon spec, but e.g. GNOME puts some icons there anyway. - dirs += d->mpDirs->resourceDirs("xdgdata-pixmap"); - for (TQStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it) - d->mpDirs->addResourceDir("appicon", *it); - -#ifndef NDEBUG - TQString dbgString = "Theme tree: "; - d->mpThemeRoot->printTree(dbgString); - kdDebug(264) << dbgString << endl; -#endif -} - -KIconLoader::~KIconLoader() -{ -#ifdef KICONLOADER_CHECKS - for( TQValueList< KIconLoaderDebug >::Iterator it = kiconloaders->begin(); - it != kiconloaders->end(); - ++it ) - { - if( (*it).loader == this ) - { - (*it).valid = false; - (*it).delete_bt = kdBacktrace(); - break; - } - } -#endif - /* antlarr: There's no need to delete d->mpThemeRoot as it's already - deleted when the elements of d->links are deleted */ - d->mpThemeRoot=0; - delete[] d->mpGroups; - delete d; -} - -void KIconLoader::enableDelayedIconSetLoading( bool enable ) -{ - d->delayedLoading = enable; -} - -bool KIconLoader::isDelayedIconSetLoadingEnabled() const -{ - return d->delayedLoading; -} - -void KIconLoader::addAppDir(const TQString& appname) -{ - d->mpDirs->addResourceType("appicon", KStandardDirs::kde_default("data") + - appname + "/pics/"); - // ################## KDE4: consider removing the toolbar directory - d->mpDirs->addResourceType("appicon", KStandardDirs::kde_default("data") + - appname + "/toolbar/"); - addAppThemes(appname); -} - -void KIconLoader::addAppThemes(const TQString& appname) -{ - if ( KIconTheme::current() != KIconTheme::defaultThemeName() ) - { - KIconTheme *def = new KIconTheme(KIconTheme::current(), appname); - if (def->isValid()) - { - KIconThemeNode* node = new KIconThemeNode(def); - d->links.append(node); - addBaseThemes(node, appname); - } - else - delete def; - } - - KIconTheme *def = new KIconTheme(KIconTheme::defaultThemeName(), appname); - KIconThemeNode* node = new KIconThemeNode(def); - d->links.append(node); - addBaseThemes(node, appname); -} - -void KIconLoader::addBaseThemes(KIconThemeNode *node, const TQString &appname) -{ - TQStringList lst = node->theme->inherits(); - TQStringList::ConstIterator it; - - for (it=lst.begin(); it!=lst.end(); ++it) - { - if( d->mThemesInTree.contains(*it) && (*it) != "hicolor") - continue; - KIconTheme *theme = new KIconTheme(*it,appname); - if (!theme->isValid()) { - delete theme; - continue; - } - KIconThemeNode *n = new KIconThemeNode(theme); - d->mThemesInTree.append(*it); - d->links.append(n); - addBaseThemes(n, appname); - } -} - -void KIconLoader::addExtraDesktopThemes() -{ - if ( d->extraDesktopIconsLoaded ) return; - - TQStringList list; - TQStringList icnlibs = KGlobal::dirs()->resourceDirs("icon"); - TQStringList::ConstIterator it; - char buf[1000]; - int r; - for (it=icnlibs.begin(); it!=icnlibs.end(); ++it) - { - TQDir dir(*it); - if (!dir.exists()) - continue; - TQStringList lst = dir.entryList("default.*", TQDir::Dirs); - TQStringList::ConstIterator it2; - for (it2=lst.begin(); it2!=lst.end(); ++it2) - { - if (!KStandardDirs::exists(*it + *it2 + "/index.desktop") - && !KStandardDirs::exists(*it + *it2 + "/index.theme")) - continue; - r=readlink( TQFile::encodeName(*it + *it2) , buf, sizeof(buf)-1); - if ( r>0 ) - { - buf[r]=0; - TQDir dir2( buf ); - TQString themeName=dir2.dirName(); - - if (!list.contains(themeName)) - list.append(themeName); - } - } - } - - for (it=list.begin(); it!=list.end(); ++it) - { - if ( d->mThemesInTree.contains(*it) ) - continue; - if ( *it == TQString("default.kde") ) continue; - - KIconTheme *def = new KIconTheme( *it, "" ); - KIconThemeNode* node = new KIconThemeNode(def); - d->mThemesInTree.append(*it); - d->links.append(node); - addBaseThemes(node, "" ); - } - - d->extraDesktopIconsLoaded=true; - -} - -bool KIconLoader::extraDesktopThemesAdded() const -{ - return d->extraDesktopIconsLoaded; -} - -TQString KIconLoader::removeIconExtension(const TQString &name) const -{ - int extensionLength=0; - - TQString ext = name.right(4); - - static const TQString &png_ext = KGlobal::staticQString(".png"); - static const TQString &xpm_ext = KGlobal::staticQString(".xpm"); - if (ext == png_ext || ext == xpm_ext) - extensionLength=4; -#ifdef HAVE_LIBART - else - { - static const TQString &svgz_ext = KGlobal::staticQString(".svgz"); - static const TQString &svg_ext = KGlobal::staticQString(".svg"); - - if (name.right(5) == svgz_ext) - extensionLength=5; - else if (ext == svg_ext) - extensionLength=4; - } -#endif - - if ( extensionLength > 0 ) - { - return name.left(name.length() - extensionLength); - } - return name; -} - -TQString KIconLoader::removeIconExtensionInternal(const TQString &name) const -{ - TQString name_noext = removeIconExtension(name); - -#ifndef NDEBUG - if (name != name_noext) - { - kdDebug(264) << "Application " << KGlobal::instance()->instanceName() - << " loads icon " << name << " with extension." << endl; - } -#endif - - return name_noext; -} - -KIcon KIconLoader::findMatchingIcon(const TQString& name, int size) const -{ - KIcon icon; - - const TQString *ext[4]; - int count=0; - static const TQString &png_ext = KGlobal::staticQString(".png"); - ext[count++]=&png_ext; -#ifdef HAVE_LIBART - static const TQString &svgz_ext = KGlobal::staticQString(".svgz"); - ext[count++]=&svgz_ext; - static const TQString &svg_ext = KGlobal::staticQString(".svg"); - ext[count++]=&svg_ext; -#endif - static const TQString &xpm_ext = KGlobal::staticQString(".xpm"); - ext[count++]=&xpm_ext; - - /* JRT: To follow the XDG spec, the order in which we look for an - icon 1s: - - png, svgz, svg, xpm exact match - png, svgz, svg, xpm best match - next theme in inheritance tree : png, svgz, svg, xpm exact match - png, svgz, svg, xpm best match - next theme in inheritance tree : png, svgz, svg, xpm exact match - png, svgz, svg, xpm best match - and so on - - */ - for ( KIconThemeNode *themeNode = d->links.first() ; themeNode ; - themeNode = d->links.next() ) - { - for (int i = 0 ; i < count ; i++) - { - icon = themeNode->theme->iconPath(name + *ext[i], size, KIcon::MatchExact); - if (icon.isValid()) goto icon_found ; - } - - for (int i = 0 ; i < count ; i++) - { - icon = themeNode->theme->iconPath(name + *ext[i], size, KIcon::MatchBest); - if (icon.isValid()) goto icon_found; - } - } - icon_found: - return icon; -} - -inline TQString KIconLoader::unknownIconPath( int size ) const -{ - static const TQString &str_unknown = KGlobal::staticQString("unknown"); - - KIcon icon = findMatchingIcon(str_unknown, size); - if (!icon.isValid()) - { - kdDebug(264) << "Warning: could not find \"Unknown\" icon for size = " - << size << endl; - return TQString::null; - } - return icon.path; -} - -// Finds the absolute path to an icon. - -TQString KIconLoader::iconPath(const TQString& _name, int group_or_size, - bool canReturnNull) const -{ - if (d->mpThemeRoot == 0L) - return TQString::null; - - if (!TQDir::isRelativePath(_name)) - return _name; - - TQString name = removeIconExtensionInternal( _name ); - - TQString path; - if (group_or_size == KIcon::User) - { - static const TQString &png_ext = KGlobal::staticQString(".png"); - static const TQString &xpm_ext = KGlobal::staticQString(".xpm"); - path = d->mpDirs->findResource("appicon", name + png_ext); - -#ifdef HAVE_LIBART - static const TQString &svgz_ext = KGlobal::staticQString(".svgz"); - static const TQString &svg_ext = KGlobal::staticQString(".svg"); - if (path.isEmpty()) - path = d->mpDirs->findResource("appicon", name + svgz_ext); - if (path.isEmpty()) - path = d->mpDirs->findResource("appicon", name + svg_ext); -#endif - if (path.isEmpty()) - path = d->mpDirs->findResource("appicon", name + xpm_ext); - return path; - } - - if (group_or_size >= KIcon::LastGroup) - { - kdDebug(264) << "Illegal icon group: " << group_or_size << endl; - return path; - } - - int size; - if (group_or_size >= 0) - size = d->mpGroups[group_or_size].size; - else - size = -group_or_size; - - if (_name.isEmpty()) { - if (canReturnNull) - return TQString::null; - else - return unknownIconPath(size); - } - - KIcon icon = findMatchingIcon(name, size); - - if (!icon.isValid()) - { - // Try "User" group too. - path = iconPath(name, KIcon::User, true); - if (!path.isEmpty() || canReturnNull) - return path; - - if (canReturnNull) - return TQString::null; - else - return unknownIconPath(size); - } - return icon.path; -} - -TQPixmap KIconLoader::loadIcon(const TQString& _name, KIcon::Group group, int size, - int state, TQString *path_store, bool canReturnNull) const -{ - TQString name = _name; - TQPixmap pix; - TQString key; - bool absolutePath=false, favIconOverlay=false; - - if (d->mpThemeRoot == 0L) - return pix; - - // Special case for absolute path icons. - if (name.startsWith("favicons/")) - { - favIconOverlay = true; - name = locateLocal("cache", name+".png"); - } - if (!TQDir::isRelativePath(name)) absolutePath=true; - - static const TQString &str_unknown = KGlobal::staticQString("unknown"); - - // Special case for "User" icons. - if (group == KIcon::User) - { - key = "$kicou_"; - key += TQString::number(size); key += '_'; - key += name; - bool inCache = TQPixmapCache::find(key, pix); - if (inCache && (path_store == 0L)) - return pix; - - TQString path = (absolutePath) ? name : - iconPath(name, KIcon::User, canReturnNull); - if (path.isEmpty()) - { - if (canReturnNull) - return pix; - // We don't know the desired size: use small - path = iconPath(str_unknown, KIcon::Small, true); - if (path.isEmpty()) - { - kdDebug(264) << "Warning: Cannot find \"unknown\" icon." << endl; - return pix; - } - } - - if (path_store != 0L) - *path_store = path; - if (inCache) - return pix; - TQImage img(path); - if (size != 0) - img=img.smoothScale(size,size); - - pix.convertFromImage(img); - TQPixmapCache::insert(key, pix); - return pix; - } - - // Regular case: Check parameters - - if ((group < -1) || (group >= KIcon::LastGroup)) - { - kdDebug(264) << "Illegal icon group: " << group << endl; - group = KIcon::Desktop; - } - - int overlay = (state & KIcon::OverlayMask); - state &= ~KIcon::OverlayMask; - if ((state < 0) || (state >= KIcon::LastState)) - { - kdDebug(264) << "Illegal icon state: " << state << endl; - state = KIcon::DefaultState; - } - - if (size == 0 && group < 0) - { - kdDebug(264) << "Neither size nor group specified!" << endl; - group = KIcon::Desktop; - } - - if (!absolutePath) - { - if (!canReturnNull && name.isEmpty()) - name = str_unknown; - else - name = removeIconExtensionInternal(name); - } - - // If size == 0, use default size for the specified group. - if (size == 0) - { - size = d->mpGroups[group].size; - } - favIconOverlay = favIconOverlay && size > 22; - - // Generate a unique cache key for the icon. - - key = "$kico_"; - key += name; key += '_'; - key += TQString::number(size); key += '_'; - - TQString overlayStr = TQString::number( overlay ); - - TQString noEffectKey = key + '_' + overlayStr; - - if (group >= 0) - { - key += d->mpEffect.fingerprint(group, state); - if (d->mpGroups[group].dblPixels) - key += TQString::tqfromLatin1(":dblsize"); - } else - key += TQString::tqfromLatin1("noeffect"); - key += '_'; - key += overlayStr; - - // Is the icon in the cache? - bool inCache = TQPixmapCache::find(key, pix); - if (inCache && (path_store == 0L)) - return pix; - - TQImage *img = 0; - int iconType; - int iconThreshold; - - if ( ( path_store != 0L ) || - noEffectKey != d->lastImageKey ) - { - // No? load it. - KIcon icon; - if (absolutePath && !favIconOverlay) - { - icon.context=KIcon::Any; - icon.type=KIcon::Scalable; - icon.path=name; - } - else - { - if (!name.isEmpty()) - icon = findMatchingIcon(favIconOverlay ? TQString("www") : name, size); - - if (!icon.isValid()) - { - // Try "User" icon too. Some apps expect this. - if (!name.isEmpty()) - pix = loadIcon(name, KIcon::User, size, state, path_store, true); - if (!pix.isNull() || canReturnNull) { - TQPixmapCache::insert(key, pix); - return pix; - } - - icon = findMatchingIcon(str_unknown, size); - if (!icon.isValid()) - { - kdDebug(264) - << "Warning: could not find \"Unknown\" icon for size = " - << size << endl; - return pix; - } - } - } - - if (path_store != 0L) - *path_store = icon.path; - if (inCache) - return pix; - - // Use the extension as the format. Works for XPM and PNG, but not for SVG - TQString ext = icon.path.right(3).upper(); - if(ext != "SVG" && ext != "VGZ") - { - img = new TQImage(icon.path, ext.latin1()); - if (img->isNull()) { - delete img; - return pix; - } - } -#ifdef HAVE_LIBART - else - { - // Special stuff for SVG icons - KSVGIconEngine *svgEngine = new KSVGIconEngine(); - - if(svgEngine->load(size, size, icon.path)) - img = svgEngine->painter()->image(); - else - img = new TQImage(); - - delete svgEngine; - } -#endif - - iconType = icon.type; - iconThreshold = icon.threshold; - - d->lastImage = img->copy(); - d->lastImageKey = noEffectKey; - d->lastIconType = iconType; - d->lastIconThreshold = iconThreshold; - } - else - { - img = new TQImage( d->lastImage.copy() ); - iconType = d->lastIconType; - iconThreshold = d->lastIconThreshold; - } - - // Blend in all overlays - if (overlay) - { - TQImage *ovl; - KIconTheme *theme = d->mpThemeRoot->theme; - if ((overlay & KIcon::LockOverlay) && - ((ovl = loadOverlay(theme->lockOverlay(), size)) != 0L)) - KIconEffect::overlay(*img, *ovl); - if ((overlay & KIcon::LinkOverlay) && - ((ovl = loadOverlay(theme->linkOverlay(), size)) != 0L)) - KIconEffect::overlay(*img, *ovl); - if ((overlay & KIcon::ZipOverlay) && - ((ovl = loadOverlay(theme->zipOverlay(), size)) != 0L)) - KIconEffect::overlay(*img, *ovl); - if ((overlay & KIcon::ShareOverlay) && - ((ovl = loadOverlay(theme->shareOverlay(), size)) != 0L)) - KIconEffect::overlay(*img, *ovl); - if (overlay & KIcon::HiddenOverlay) - { - if (img->depth() != 32) - *img = img->convertDepth(32); - for (int y = 0; y < img->height(); y++) - { - QRgb *line = reinterpret_cast<QRgb *>(img->scanLine(y)); - for (int x = 0; x < img->width(); x++) - line[x] = (line[x] & 0x00ffffff) | (QMIN(0x80, tqAlpha(line[x])) << 24); - } - } - } - - // Scale the icon and apply effects if necessary - if (iconType == KIcon::Scalable && size != img->width()) - { - *img = img->smoothScale(size, size); - } - if (iconType == KIcon::Threshold && size != img->width()) - { - if ( abs(size-img->width())>iconThreshold ) - *img = img->smoothScale(size, size); - } - if (group >= 0 && d->mpGroups[group].dblPixels) - { - *img = d->mpEffect.doublePixels(*img); - } - if (group >= 0) - { - *img = d->mpEffect.apply(*img, group, state); - } - - if (favIconOverlay) - { - TQImage favIcon(name, "PNG"); - int x = img->width() - favIcon.width() - 1, - y = img->height() - favIcon.height() - 1; - if( favIcon.depth() != 32 ) - favIcon = favIcon.convertDepth( 32 ); - if( img->depth() != 32 ) - *img = img->convertDepth( 32 ); - for( int line = 0; - line < favIcon.height(); - ++line ) - { - QRgb* fpos = reinterpret_cast< QRgb* >( favIcon.scanLine( line )); - QRgb* ipos = reinterpret_cast< QRgb* >( img->scanLine( line + y )) + x; - for( int i = 0; - i < favIcon.width(); - ++i, ++fpos, ++ipos ) - *ipos = tqRgba( ( tqRed( *ipos ) * ( 255 - tqAlpha( *fpos )) + tqRed( *fpos ) * tqAlpha( *fpos )) / 255, - ( tqGreen( *ipos ) * ( 255 - tqAlpha( *fpos )) + tqGreen( *fpos ) * tqAlpha( *fpos )) / 255, - ( tqBlue( *ipos ) * ( 255 - tqAlpha( *fpos )) + tqBlue( *fpos ) * tqAlpha( *fpos )) / 255, - ( tqAlpha( *ipos ) * ( 255 - tqAlpha( *fpos )) + tqAlpha( *fpos ) * tqAlpha( *fpos )) / 255 ); - } - } - - if (TQPaintDevice::x11AppDepth() == 32) pix.convertFromImage(KImageEffect::convertToPremultipliedAlpha( *img )); - else pix.convertFromImage(*img); - - delete img; - - TQPixmapCache::insert(key, pix); - return pix; -} - -TQImage *KIconLoader::loadOverlay(const TQString &name, int size) const -{ - TQString key = name + '_' + TQString::number(size); - TQImage *image = d->imgDict.find(key); - if (image != 0L) - return image; - - KIcon icon = findMatchingIcon(name, size); - if (!icon.isValid()) - { - kdDebug(264) << "Overlay " << name << "not found." << endl; - return 0L; - } - image = new TQImage(icon.path); - // In some cases (since size in findMatchingIcon() is more a hint than a - // constraint) image->size can be != size. If so perform rescaling. - if ( size != image->width() ) - *image = image->smoothScale( size, size ); - d->imgDict.insert(key, image); - return image; -} - - - -TQMovie KIconLoader::loadMovie(const TQString& name, KIcon::Group group, int size) const -{ - TQString file = moviePath( name, group, size ); - if (file.isEmpty()) - return TQMovie(); - int dirLen = file.findRev('/'); - TQString icon = iconPath(name, size ? -size : group, true); - if (!icon.isEmpty() && file.left(dirLen) != icon.left(dirLen)) - return TQMovie(); - return TQMovie(file); -} - -TQString KIconLoader::moviePath(const TQString& name, KIcon::Group group, int size) const -{ - if (!d->mpGroups) return TQString::null; - - if ( (group < -1 || group >= KIcon::LastGroup) && group != KIcon::User ) - { - kdDebug(264) << "Illegal icon group: " << group << endl; - group = KIcon::Desktop; - } - if (size == 0 && group < 0) - { - kdDebug(264) << "Neither size nor group specified!" << endl; - group = KIcon::Desktop; - } - - TQString file = name + ".mng"; - if (group == KIcon::User) - { - file = d->mpDirs->findResource("appicon", file); - } - else - { - if (size == 0) - size = d->mpGroups[group].size; - - KIcon icon; - - for ( KIconThemeNode *themeNode = d->links.first() ; themeNode ; - themeNode = d->links.next() ) - { - icon = themeNode->theme->iconPath(file, size, KIcon::MatchExact); - if (icon.isValid()) goto icon_found ; - - icon = themeNode->theme->iconPath(file, size, KIcon::MatchBest); - if (icon.isValid()) goto icon_found ; - } - - icon_found: - file = icon.isValid() ? icon.path : TQString::null; - } - return file; -} - - -TQStringList KIconLoader::loadAnimated(const TQString& name, KIcon::Group group, int size) const -{ - TQStringList lst; - - if (!d->mpGroups) return lst; - - if ((group < -1) || (group >= KIcon::LastGroup)) - { - kdDebug(264) << "Illegal icon group: " << group << endl; - group = KIcon::Desktop; - } - if ((size == 0) && (group < 0)) - { - kdDebug(264) << "Neither size nor group specified!" << endl; - group = KIcon::Desktop; - } - - TQString file = name + "/0001"; - if (group == KIcon::User) - { - file = d->mpDirs->findResource("appicon", file + ".png"); - } else - { - if (size == 0) - size = d->mpGroups[group].size; - KIcon icon = findMatchingIcon(file, size); - file = icon.isValid() ? icon.path : TQString::null; - - } - if (file.isEmpty()) - return lst; - - TQString path = file.left(file.length()-8); - DIR* dp = opendir( TQFile::encodeName(path) ); - if(!dp) - return lst; - - struct dirent* ep; - while( ( ep = readdir( dp ) ) != 0L ) - { - TQString fn(TQFile::decodeName(ep->d_name)); - if(!(fn.left(4)).toUInt()) - continue; - - lst += path + fn; - } - closedir ( dp ); - lst.sort(); - return lst; -} - -KIconTheme *KIconLoader::theme() const -{ - if (d->mpThemeRoot) return d->mpThemeRoot->theme; - return 0L; -} - -int KIconLoader::currentSize(KIcon::Group group) const -{ - if (!d->mpGroups) return -1; - - if (group < 0 || group >= KIcon::LastGroup) - { - kdDebug(264) << "Illegal icon group: " << group << endl; - return -1; - } - return d->mpGroups[group].size; -} - -TQStringList KIconLoader::queryIconsByDir( const TQString& iconsDir ) const -{ - TQDir dir(iconsDir); - TQStringList lst = dir.entryList("*.png;*.xpm", TQDir::Files); - TQStringList result; - TQStringList::ConstIterator it; - for (it=lst.begin(); it!=lst.end(); ++it) - result += iconsDir + "/" + *it; - return result; -} - -TQStringList KIconLoader::queryIconsByContext(int group_or_size, - KIcon::Context context) const -{ - TQStringList result; - if (group_or_size >= KIcon::LastGroup) - { - kdDebug(264) << "Illegal icon group: " << group_or_size << endl; - return result; - } - int size; - if (group_or_size >= 0) - size = d->mpGroups[group_or_size].size; - else - size = -group_or_size; - - for ( KIconThemeNode *themeNode = d->links.first() ; themeNode ; - themeNode = d->links.next() ) - themeNode->queryIconsByContext(&result, size, context); - - // Eliminate duplicate entries (same icon in different directories) - TQString name; - TQStringList res2, entries; - TQStringList::ConstIterator it; - for (it=result.begin(); it!=result.end(); ++it) - { - int n = (*it).findRev('/'); - if (n == -1) - name = *it; - else - name = (*it).mid(n+1); - name = removeIconExtension(name); - if (!entries.contains(name)) - { - entries += name; - res2 += *it; - } - } - return res2; - -} - -TQStringList KIconLoader::queryIcons(int group_or_size, KIcon::Context context) const -{ - TQStringList result; - if (group_or_size >= KIcon::LastGroup) - { - kdDebug(264) << "Illegal icon group: " << group_or_size << endl; - return result; - } - int size; - if (group_or_size >= 0) - size = d->mpGroups[group_or_size].size; - else - size = -group_or_size; - - for ( KIconThemeNode *themeNode = d->links.first() ; themeNode ; - themeNode = d->links.next() ) - themeNode->queryIcons(&result, size, context); - - // Eliminate duplicate entries (same icon in different directories) - TQString name; - TQStringList res2, entries; - TQStringList::ConstIterator it; - for (it=result.begin(); it!=result.end(); ++it) - { - int n = (*it).findRev('/'); - if (n == -1) - name = *it; - else - name = (*it).mid(n+1); - name = removeIconExtension(name); - if (!entries.contains(name)) - { - entries += name; - res2 += *it; - } - } - return res2; -} - -// used by KIconDialog to find out which contexts to offer in a combobox -bool KIconLoader::hasContext(KIcon::Context context) const -{ - for ( KIconThemeNode *themeNode = d->links.first() ; themeNode ; - themeNode = d->links.next() ) - if( themeNode->theme->hasContext( context )) - return true; - return false; -} - -KIconEffect * KIconLoader::iconEffect() const -{ - return &d->mpEffect; -} - -bool KIconLoader::alphaBlending(KIcon::Group group) const -{ - if (!d->mpGroups) return false; - - if (group < 0 || group >= KIcon::LastGroup) - { - kdDebug(264) << "Illegal icon group: " << group << endl; - return false; - } - return d->mpGroups[group].alphaBlending; -} - -TQIconSet KIconLoader::loadIconSet(const TQString& name, KIcon::Group group, int size, bool canReturnNull) -{ - return loadIconSet( name, group, size, canReturnNull, true ); -} - -TQIconSet KIconLoader::loadIconSet(const TQString& name, KIcon::Group group, int size) -{ - return loadIconSet( name, group, size, false ); -} - -/*** class for delayed icon loading for TQIconSet ***/ - -class KIconFactory - : public TQIconFactory - { - public: - KIconFactory( const TQString& iconName_P, KIcon::Group group_P, - int size_P, KIconLoader* loader_P ); - KIconFactory( const TQString& iconName_P, KIcon::Group group_P, - int size_P, KIconLoader* loader_P, bool canReturnNull ); - virtual TQPixmap* createPixmap( const TQIconSet&, TQIconSet::Size, TQIconSet::Mode, TQIconSet::State ); - private: - TQString iconName; - KIcon::Group group; - int size; - KIconLoader* loader; - bool canReturnNull; - }; - - -TQIconSet KIconLoader::loadIconSet( const TQString& name, KIcon::Group g, int s, - bool canReturnNull, bool immediateExistenceCheck) -{ - if ( !d->delayedLoading ) - return loadIconSetNonDelayed( name, g, s, canReturnNull ); - - if (g < -1 || g > 6) { - kdDebug() << "KIconLoader::loadIconSet " << name << " " << (int)g << " " << s << endl; - qDebug("%s", kdBacktrace().latin1()); - abort(); - } - - if(canReturnNull && immediateExistenceCheck) - { // we need to find out if the icon actually exists - TQPixmap pm = loadIcon( name, g, s, KIcon::DefaultState, NULL, true ); - if( pm.isNull()) - return TQIconSet(); - - TQIconSet ret( pm ); - ret.installIconFactory( new KIconFactory( name, g, s, this )); - return ret; - } - - TQIconSet ret; - ret.installIconFactory( new KIconFactory( name, g, s, this, canReturnNull )); - return ret; -} - -TQIconSet KIconLoader::loadIconSetNonDelayed( const TQString& name, - KIcon::Group g, - int s, bool canReturnNull ) -{ - TQIconSet iconset; - TQPixmap tmp = loadIcon(name, g, s, KIcon::ActiveState, NULL, canReturnNull); - iconset.setPixmap( tmp, TQIconSet::Small, TQIconSet::Active ); - // we don't use QIconSet's resizing anyway - iconset.setPixmap( tmp, TQIconSet::Large, TQIconSet::Active ); - tmp = loadIcon(name, g, s, KIcon::DisabledState, NULL, canReturnNull); - iconset.setPixmap( tmp, TQIconSet::Small, TQIconSet::Disabled ); - iconset.setPixmap( tmp, TQIconSet::Large, TQIconSet::Disabled ); - tmp = loadIcon(name, g, s, KIcon::DefaultState, NULL, canReturnNull); - iconset.setPixmap( tmp, TQIconSet::Small, TQIconSet::Normal ); - iconset.setPixmap( tmp, TQIconSet::Large, TQIconSet::Normal ); - return iconset; -} - -KIconFactory::KIconFactory( const TQString& iconName_P, KIcon::Group group_P, - int size_P, KIconLoader* loader_P ) - : iconName( iconName_P ), group( group_P ), size( size_P ), loader( loader_P ) -{ - canReturnNull = false; - setAutoDelete( true ); -} - -KIconFactory::KIconFactory( const TQString& iconName_P, KIcon::Group group_P, - int size_P, KIconLoader* loader_P, bool canReturnNull_P ) - : iconName( iconName_P ), group( group_P ), size( size_P ), - loader( loader_P ), canReturnNull( canReturnNull_P) -{ - setAutoDelete( true ); -} - -TQPixmap* KIconFactory::createPixmap( const TQIconSet&, TQIconSet::Size, TQIconSet::Mode mode_P, TQIconSet::State ) - { -#ifdef KICONLOADER_CHECKS - bool found = false; - for( TQValueList< KIconLoaderDebug >::Iterator it = kiconloaders->begin(); - it != kiconloaders->end(); - ++it ) - { - if( (*it).loader == loader ) - { - found = true; - if( !(*it).valid ) - { -#ifdef NDEBUG - loader = KGlobal::iconLoader(); - iconName = "no_way_man_you_will_get_broken_icon"; -#else - kdWarning() << "Using already destroyed KIconLoader for loading an icon!" << endl; - kdWarning() << "Appname:" << (*it).appname << ", icon:" << iconName << endl; - kdWarning() << "Deleted at:" << endl; - kdWarning() << (*it).delete_bt << endl; - kdWarning() << "Current:" << endl; - kdWarning() << kdBacktrace() << endl; - abort(); - return NULL; -#endif - } - break; - } - } - if( !found ) - { -#ifdef NDEBUG - loader = KGlobal::iconLoader(); - iconName = "no_way_man_you_will_get_broken_icon"; -#else - kdWarning() << "Using unknown KIconLoader for loading an icon!" << endl; - kdWarning() << "Icon:" << iconName << endl; - kdWarning() << kdBacktrace() << endl; - abort(); - return NULL; -#endif - } -#endif - // TQIconSet::Mode to KIcon::State conversion - static const KIcon::States tbl[] = { KIcon::DefaultState, KIcon::DisabledState, KIcon::ActiveState }; - int state = KIcon::DefaultState; - if( mode_P <= TQIconSet::Active ) - state = tbl[ mode_P ]; - if( group >= 0 && state == KIcon::ActiveState ) - { // active and normal icon are usually the same - if( loader->iconEffect()->fingerprint(group, KIcon::ActiveState ) - == loader->iconEffect()->fingerprint(group, KIcon::DefaultState )) - return 0; // so let TQIconSet simply duplicate it - } - // ignore passed size - // ignore passed state (i.e. on/off) - TQPixmap pm = loader->loadIcon( iconName, group, size, state, 0, canReturnNull ); - return new TQPixmap( pm ); - } - -// Easy access functions - -TQPixmap DesktopIcon(const TQString& name, int force_size, int state, - KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIcon(name, KIcon::Desktop, force_size, state); -} - -TQPixmap DesktopIcon(const TQString& name, KInstance *instance) -{ - return DesktopIcon(name, 0, KIcon::DefaultState, instance); -} - -TQIconSet DesktopIconSet(const TQString& name, int force_size, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIconSet( name, KIcon::Desktop, force_size ); -} - -TQPixmap BarIcon(const TQString& name, int force_size, int state, - KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIcon(name, KIcon::Toolbar, force_size, state); -} - -TQPixmap BarIcon(const TQString& name, KInstance *instance) -{ - return BarIcon(name, 0, KIcon::DefaultState, instance); -} - -TQIconSet BarIconSet(const TQString& name, int force_size, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIconSet( name, KIcon::Toolbar, force_size ); -} - -TQPixmap SmallIcon(const TQString& name, int force_size, int state, - KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIcon(name, KIcon::Small, force_size, state); -} - -TQPixmap SmallIcon(const TQString& name, KInstance *instance) -{ - return SmallIcon(name, 0, KIcon::DefaultState, instance); -} - -TQIconSet SmallIconSet(const TQString& name, int force_size, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIconSet( name, KIcon::Small, force_size ); -} - -TQPixmap MainBarIcon(const TQString& name, int force_size, int state, - KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIcon(name, KIcon::MainToolbar, force_size, state); -} - -TQPixmap MainBarIcon(const TQString& name, KInstance *instance) -{ - return MainBarIcon(name, 0, KIcon::DefaultState, instance); -} - -TQIconSet MainBarIconSet(const TQString& name, int force_size, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIconSet( name, KIcon::MainToolbar, force_size ); -} - -TQPixmap UserIcon(const TQString& name, int state, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIcon(name, KIcon::User, 0, state); -} - -TQPixmap UserIcon(const TQString& name, KInstance *instance) -{ - return UserIcon(name, KIcon::DefaultState, instance); -} - -TQIconSet UserIconSet(const TQString& name, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->loadIconSet( name, KIcon::User ); -} - -int IconSize(KIcon::Group group, KInstance *instance) -{ - KIconLoader *loader = instance->iconLoader(); - return loader->currentSize(group); -} - -TQPixmap KIconLoader::unknown() -{ - TQPixmap pix; - if ( TQPixmapCache::find("unknown", pix) ) - return pix; - - TQString path = KGlobal::iconLoader()->iconPath("unknown", KIcon::Small, true); - if (path.isEmpty()) - { - kdDebug(264) << "Warning: Cannot find \"unknown\" icon." << endl; - pix.resize(32,32); - } else - { - pix.load(path); - TQPixmapCache::insert("unknown", pix); - } - - return pix; -} - -void KIconLoaderPrivate::reconfigure() -{ - q->reconfigure(appname, mpDirs); -} - -#include "kiconloader_p.moc" diff --git a/kdecore/kiconloader.h b/kdecore/kiconloader.h deleted file mode 100644 index b7f1478f6..000000000 --- a/kdecore/kiconloader.h +++ /dev/null @@ -1,553 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * Antonio Larrosa <larrosa@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __KIconLoader_h_Included__ -#define __KIconLoader_h_Included__ - -#include <tqstring.h> -#include <tqpixmap.h> -#include <tqiconset.h> - -// Grmbl, X headers..... -#ifdef Status -#define KIconLoaderXStatus Status -#undef Status -#endif -#include <tqmovie.h> -#ifdef KIconLoaderXStatus -#define Status int -#undef KIconLoaderXStatus -#endif - -#include <kglobal.h> -#include <kinstance.h> -#include <kicontheme.h> - -struct KIconGroup; -class KIconThemeNode; -class KConfig; -struct KIconLoaderPrivate; -class KStandardDirs; -class KIconEffect; - - -/** - * Iconloader for KDE. - * - * KIconLoader will load the current icon theme and all its base themes. - * Icons will be searched in any of these themes. Additionally, it caches - * icons and applies effects according the the user's preferences. - * - * In KDE, it is encouraged to load icons by "Group". An icon group is a - * location on the screen where icons are being used. Standard groups are: - * Desktop, Toolbar, MainToolbar, Small and Panel. Each group has some - * centrally configured properties bound to it, including the icon size - * and effects. This makes it possible to offer a consistent icon look in - * all KDE applications. - * - * The standard groups are defined below. - * - * @li KIcon::Desktop: Icons in the iconview of konqueror, kdesktop and similar apps. - * @li KIcon::Toolbar: Icons in toolbars. - * @li KIcon::MainToolbar: Icons in the main toolbars. - * @li KIcon::Small: Various small (typical 16x16) places: titlebars, listviews - * and menu entries. - * @li KIcon::Panel: Icons in kicker's panel - * - * The icons are stored on disk in an icon theme or in a standalone - * directory. The icon theme directories contain multiple sizes and/or - * depths for the same icon. The iconloader will load the correct one based - * on the icon group and the current theme. Icon themes are stored globally - * in share/icons, or, application specific in share/apps/$appdir/icons. - * - * The standalone directories contain just one version of an icon. The - * directories that are searched are: $appdir/pics and $appdir/toolbar. - * Icons in these directories can be loaded by using the special group - * "User". - * - */ -class KDECORE_EXPORT KIconLoader -{ -public: - - /** - * Constructs an iconloader. - * @param appname Add the data directories of this application to the - * icon search path for the "User" group. The default argument adds the - * directories of the current application. - * @param dirs the KStandardDirs object to use. If null the global one is used - * - * Usually, you use the default iconloader, which can be accessed via - * KGlobal::iconLoader(), so you hardly ever have to create an - * iconloader object yourself. That one is the current KInstance's - * (typically KApplication's) iconloader. - * @see KGlobal::iconLoader() - * @see KInstance::iconLoader() - */ - KIconLoader(const TQString& appname=TQString::null, KStandardDirs *dirs = 0); - - /** - * Cleanup - */ - ~KIconLoader(); - - /** - * Adds @p appname to the list of application specific directories. - * @param appname The application name. - */ - void addAppDir(const TQString& appname); - - /** - * Loads an icon. It will try very hard to find an icon which is - * suitable. If no exact match is found, a close match is searched. - * If neither an exact nor a close match is found, a null pixmap or - * the "unknown" pixmap is returned, depending on the value of the - * @p canReturnNull parameter. - * - * @param name The name of the icon, without extension. - * @param group The icon group. This will specify the size of and effects to - * be applied to the icon. - * @param size If nonzero, this overrides the size specified by @p group. - * See KIcon::StdSizes. - * @param state The icon state: @p DefaultState, @p ActiveState or - * @p DisabledState. Depending on the user's preferences, the iconloader - * may apply a visual effect to hint about its state. - * @param path_store If not null, the path of the icon is stored here. - * @param canReturnNull Can return a null pixmap? If false, the - * "unknown" pixmap is returned when no appropriate icon has been found. - * @return the TQPixmap. Can be null when not found, depending on - * @p canReturnNull. - */ - TQPixmap loadIcon(const TQString& name, KIcon::Group group, int size=0, - int state=KIcon::DefaultState, TQString *path_store=0L, - bool canReturnNull=false) const; - - /** - * Creates an icon set, that will do on-demand loading of the icon. - * Loading itself is done by calling loadIcon . - * - * @param name The name of the icon, without extension. - * @param group The icon group. This will specify the size of and effects to - * be applied to the icon. - * @param size If nonzero, this overrides the size specified by @p group. - * See KIcon::StdSizes. - * @param canReturnNull Can return a null iconset? If false, iconset - * containing the "unknown" pixmap is returned when no appropriate icon has - * been found. - * @param immediateExistenceCheck If true on-demand icon loading will be - * disabled for canReturnNull and a null iconset may be returned immediately - * @return the icon set. Can be null when not found, depending on - * @p canReturnNull. - * @since 3.5 - */ - TQIconSet loadIconSet(const TQString& name, KIcon::Group group, int size, - bool canReturnNull, bool immediateExistenceCheck); - - // KDE4 merge as (const TQString&,KIcon::Group,int=0,bool=false,bool=true); - /** - * Creates an icon set, that will do on-demand loading of the icon. - * Loading itself is done by calling loadIcon . - * - * @param name The name of the icon, without extension. - * @param group The icon group. This will specify the size of and effects to - * be applied to the icon. - * @param size If nonzero, this overrides the size specified by @p group. - * See KIcon::StdSizes. - * @param canReturnNull Can return a null iconset? If false, iconset - * containing the "unknown" pixmap is returned when no appropriate icon has - * been found. - * @return the icon set. Can be null when not found, depending on - * @p canReturnNull. - * @since 3.1 - */ - TQIconSet loadIconSet(const TQString& name, KIcon::Group group, int size, - bool canReturnNull); - - // KDE4 merge as (const TQString&,KIcon::Group,int=0,bool=false,bool=true); - /** - * Creates an icon set, that will do on-demand loading of the icon. - * Loading itself is done by calling loadIcon . - * - * @param name The name of the icon, without extension. - * @param group The icon group. This will specify the size of and effects to - * be applied to the icon. - * @param size If nonzero, this overrides the size specified by @p group. - * See KIcon::StdSizes. - * @return the icon set. Can be null when not found - */ - TQIconSet loadIconSet(const TQString& name, KIcon::Group group, int size=0); - - /** - * Returns the path of an icon. - * @param name The name of the icon, without extension. If an absolute - * path is supplied for this parameter, iconPath will return it - * directly. - * @param group_or_size If positive, search icons whose size is - * specified by the icon group @p group_or_size. If negative, search - * icons whose size is - @p group_or_size. - * See KIcon::Group and KIcon::StdSizes - * @param canReturnNull Can return a null string? If not, a path to the - * "unknown" icon will be returned. - * @return the path of an icon, can be null or the "unknown" icon when - * not found, depending on @p canReturnNull. - */ - TQString iconPath(const TQString& name, int group_or_size, - bool canReturnNull=false) const; - - /** - * Loads an animated icon. - * @param name The name of the icon. - * @param group The icon group. See loadIcon(). - * @param size Override the default size for @p group. - * See KIcon::StdSizes. - * @return A TQMovie object. Can be null if not found. - */ - TQMovie loadMovie(const TQString& name, KIcon::Group group, int size=0) const; - - /** - * Returns the path to an animated icon. - * @param name The name of the icon. - * @param group The icon group. See loadIcon(). - * @param size Override the default size for @p group. - * See KIcon::StdSizes. - * @return the full path to the movie, ready to be passed to QMovie's constructor. - * Empty string if not found. - */ - TQString moviePath(const TQString& name, KIcon::Group group, int size=0) const; - - /** - * Loads an animated icon as a series of still frames. If you want to load - * a .mng animation as TQMovie instead, please use loadMovie() instead. - * @param name The name of the icon. - * @param group The icon group. See loadIcon(). - * @param size Override the default size for @p group. - * See KIcon::StdSizes. - * @return A TQStringList containing the absolute path of all the frames - * making up the animation. - */ - TQStringList loadAnimated(const TQString& name, KIcon::Group group, int size=0) const; - - /** - * Queries all available icons for a specific group, having a specific - * context. - * @param group_or_size If positive, search icons whose size is - * specified by the icon group @p group_or_size. If negative, search - * icons whose size is - @p group_or_size. - * See KIcon::Group and KIcon::StdSizes - * @param context The icon context. - * @return a list of all icons - */ - TQStringList queryIcons(int group_or_size, KIcon::Context context=KIcon::Any) const; - - /** - * Queries all available icons for a specific context. - * @param group_or_size The icon preferred group or size. If available - * at this group or size, those icons will be returned, in other case, - * icons of undefined size will be returned. Positive numbers are groups, - * negative numbers are negated sizes. See KIcon::Group and - * KIcon::StdSizes - * @param context The icon context. - * @return A TQStringList containing the icon names - * available for that context - */ - TQStringList queryIconsByContext(int group_or_size, - KIcon::Context context=KIcon::Any) const; - - /** - * @internal - */ - bool hasContext( KIcon::Context context ) const; - - /** - * Returns a list of all icons (*.png or *.xpm extension) in the - * given directory. - * @param iconsDir the directory to search in - * @return A TQStringList containing the icon paths - * @since 3.1 - */ - TQStringList queryIconsByDir( const TQString& iconsDir ) const; - - /** - * Returns the current size of the group. - * @param group the group to check. - * @return the current size for an icon group. - */ - int currentSize(KIcon::Group group) const; - - /** - * Returns a pointer to the current theme. Can be used to query - * available and default sizes for groups. - * @return a pointer to the current theme. 0 if no theme set. - */ - KIconTheme *theme() const; - - /** - * Returns a pointer to the KIconEffect object used by the icon loader. - * @return the KIconEffect. - */ - KIconEffect *iconEffect() const; - - /** - * Called by KInstance::newIconLoader to reconfigure the icon loader. - * @param _appname the new application name - * @param _dirs the new standard directories. If 0, the directories - * from KGlobal will be taken. - */ - void reconfigure( const TQString& _appname, KStandardDirs *_dirs ); - - /** - * Returns the unknown icon. An icon that is used when no other icon - * can be found. - * @return the unknown pixmap - */ - static TQPixmap unknown(); - - /** - * Checks whether the user wants to blend the icons with the background - * using the alpha channel information for a given group. - * @param group the group to check - * @return true if alpha blending is desired - * @obsolete - */ - bool alphaBlending( KIcon::Group group ) const; - - /** - * Adds all the default themes from other desktops at the end of - * the list of icon themes. - * @since 3.1 - */ - void addExtraDesktopThemes(); - - /** - * Returns if the default icon themes of other desktops have been added - * to the list of icon themes where icons are searched. - * @since 3.1 - */ - bool extraDesktopThemesAdded() const; - - /** - * Enables on-demand icon loading for QIconSets using TQIconFactory. - * Icons loaded via loadIconSet() will be loaded as soon as they - * need to be displayed, not earlier. - * - * Note that enabling or disabling this only affects loadIconSet() - * calls after this setting is changed. - * - * The default is disabled, as the iconloader object must not be - * destroyed before all those iconsets are destroyed. - * - * (Some broken applications use temporary KIconLoader objects). - * Every KInstance 's iconloader has this feature enabled. - * - * @param enable true to enable delayed icon loading, false to disable - * @see isDelayedIconSetLoadingEnabled() - * @see QIconFactory - * @since 3.1 - */ - void enableDelayedIconSetLoading( bool enable ); - - /** - * Checks whether delayed loading for TQIconSet is enabled. - * @return whether icons for QIconSets will be loaded on demand. - * @see enableDelayedIconSetLoading() - * @see QIconFactory - * @since 3.1 - */ - bool isDelayedIconSetLoadingEnabled() const; - - - private: - /** - * @internal - */ - void init( const TQString& _appname, KStandardDirs *_dirs ); - - /** - * @internal - * tries to find an icon with the name. It tries some extension and - * match strategies - */ - KIcon findMatchingIcon(const TQString& name, int size) const; - - /** - * @internal - * Loads and caches an overlay. - */ - TQImage *loadOverlay(const TQString& name, int size) const; - - /** - * @internal - * Adds themes installed in the application's directory. - **/ - void addAppThemes(const TQString& appname); - - /** - * Adds all themes that are part of this node and the themes - * below (the fallbacks of the theme) in the tree. - * @internal - */ - void addBaseThemes(KIconThemeNode *node, const TQString &appname); - - /** - * @internal - * return the path for the unknown icon in that size - * @since 3.1 - */ - TQString unknownIconPath( int size ) const; - - /** - * Checks if name ends in one of the supported icon formats (i.e. .png) - * and returns the name without the extension if it does. - * - * Otherwise name is returned unchanged. - * - * Currently supported: - * - png - * - xpm - * - svg (if libart is being used) - * - svgz (if libart is being used) - * - * TODO: KDE 4 make public & static - * @since 3.1 - */ - TQString removeIconExtension(const TQString &name) const; - - /** - * Same as removeIconExtension except it prints a debug message - * if an extension is removed to help catch programming errors. - * - * @see findMatchingIcon() - * @see iconPath() - * - * TODO: KDE 4 make static - */ - TQString removeIconExtensionInternal(const TQString &name) const; - - /** - * Loads all the different sizes for an iconset. - */ - TQIconSet loadIconSetNonDelayed( const TQString& name, KIcon::Group group, - int size, bool canReturnNull ); - - // @internal the data object - KIconLoaderPrivate *d; -}; - -/** - * \relates KIconLoader - * Load a desktop icon. - */ -KDECORE_EXPORT TQPixmap DesktopIcon(const TQString& name, int size=0, - int state=KIcon::DefaultState, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a desktop icon. - */ -KDECORE_EXPORT TQPixmap DesktopIcon(const TQString& name, KInstance *instance); - -/** - * \relates KIconLoader - * Load a desktop icon, and apply the necessary effects to get an IconSet. - */ -KDECORE_EXPORT TQIconSet DesktopIconSet(const TQString& name, int size=0, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a toolbar icon. - */ -KDECORE_EXPORT TQPixmap BarIcon(const TQString& name, int size=0, int state=KIcon::DefaultState, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a toolbar icon. - */ -KDECORE_EXPORT TQPixmap BarIcon(const TQString& name, KInstance *instance); - -/** - * \relates KIconLoader - * Load a toolbar icon, and apply the necessary effects to get an IconSet. - */ -KDECORE_EXPORT TQIconSet BarIconSet(const TQString& name, int size=0, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a small icon. - */ -KDECORE_EXPORT TQPixmap SmallIcon(const TQString& name, int size=0, - int state=KIcon::DefaultState, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a small icon. - */ -KDECORE_EXPORT TQPixmap SmallIcon(const TQString& name, KInstance *instance); - -/** - * \relates KIconLoader - * Load a small icon, and apply the necessary effects to get an IconSet. - */ -KDECORE_EXPORT TQIconSet SmallIconSet(const TQString& name, int size=0, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a main toolbar icon. - */ -KDECORE_EXPORT TQPixmap MainBarIcon(const TQString& name, int size=0, - int state=KIcon::DefaultState, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a main toolbar icon. - */ -KDECORE_EXPORT TQPixmap MainBarIcon(const TQString& name, KInstance *instance); - -/** - * \relates KIconLoader - * Load a main toolbar icon, and apply the effects to get an IconSet. - */ -KDECORE_EXPORT TQIconSet MainBarIconSet(const TQString& name, int size=0, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a user icon. User icons are searched in $appdir/pics. - */ -KDECORE_EXPORT TQPixmap UserIcon(const TQString& name, int state=KIcon::DefaultState, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Load a user icon. User icons are searched in $appdir/pics. - */ -KDECORE_EXPORT TQPixmap UserIcon(const TQString& name, KInstance *instance); - -/** - * \relates KIconLoader - * Load a user icon, and apply the effects to get an IconSet. - */ -KDECORE_EXPORT TQIconSet UserIconSet(const TQString& name, - KInstance *instance=KGlobal::instance()); - -/** - * \relates KIconLoader - * Returns the current icon size for a specific group. - */ -KDECORE_EXPORT int IconSize(KIcon::Group group, KInstance *instance=KGlobal::instance()); - -#endif // __KIconLoader_h_Included__ diff --git a/kdecore/kiconloader_p.h b/kdecore/kiconloader_p.h deleted file mode 100644 index 4a7695390..000000000 --- a/kdecore/kiconloader_p.h +++ /dev/null @@ -1,60 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * Antonio Larrosa <larrosa@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __KIconLoader_p_h_Included__ -#define __KIconLoader_p_h_Included__ - -#include <tqobject.h> -#include <tqstringlist.h> -#include <kicontheme.h> -#include <kiconloader.h> -#include <kiconeffect.h> -#include <tqdict.h> - -class KIconThemeNode -{ -public: - KIconThemeNode(KIconTheme *_theme); - ~KIconThemeNode(); - - void queryIcons(TQStringList *lst, int size, KIcon::Context context) const; - void queryIconsByContext(TQStringList *lst, int size, KIcon::Context context) const; - KIcon findIcon(const TQString& name, int size, KIcon::MatchType match) const; - void printTree(TQString& dbgString) const; - - KIconTheme *theme; -}; - -class KIconLoaderPrivate : public TQObject -{ - Q_OBJECT -public: - TQStringList mThemesInTree; - KIconGroup *mpGroups; - KIconThemeNode *mpThemeRoot; - KStandardDirs *mpDirs; - KIconLoader *q; - KIconEffect mpEffect; - TQDict<TQImage> imgDict; - TQImage lastImage; // last loaded image without effect applied - TQString lastImageKey; // key for icon without effect - TQString appname; - int lastIconType; // see KIcon::type - int lastIconThreshold; // see KIcon::threshold - TQPtrList<KIconThemeNode> links; - bool extraDesktopIconsLoaded; - bool delayedLoading; - -public slots: - void reconfigure(); -}; - -#endif // __KIconLoader_p_h_Included__ diff --git a/kdecore/kicontheme.cpp b/kdecore/kicontheme.cpp deleted file mode 100644 index 0f7d3b605..000000000 --- a/kdecore/kicontheme.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * Antonio Larrosa <larrosa@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * kicontheme.cpp: Lowlevel icon theme handling. - */ - -#include <sys/stat.h> -#include <unistd.h> -#include <stdlib.h> -#include <config.h> - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqvaluelist.h> -#include <tqmap.h> -#include <tqpixmap.h> -#include <tqpixmapcache.h> -#include <tqimage.h> -#include <tqfileinfo.h> -#include <tqdir.h> - -#include <kdebug.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kconfig.h> -#include <ksimpleconfig.h> -#include <kinstance.h> - -#include "kicontheme.h" - -class KIconThemePrivate -{ -public: - TQString example, screenshot; - TQString linkOverlay, lockOverlay, zipOverlay, shareOverlay; - bool hidden; - KSharedConfig::Ptr sharedConfig; -}; - -/** - * A subdirectory in an icon theme. - */ -class KIconThemeDir -{ -public: - KIconThemeDir(const TQString& dir, const KConfigBase *config); - - bool isValid() const { return mbValid; } - TQString iconPath(const TQString& name) const; - TQStringList iconList() const; - TQString dir() const { return mDir; } - - KIcon::Context context() const { return mContext; } - KIcon::Type type() const { return mType; } - int size() const { return mSize; } - int minSize() const { return mMinSize; } - int maxSize() const { return mMaxSize; } - int threshold() const { return mThreshold; } - -private: - bool mbValid; - KIcon::Type mType; - KIcon::Context mContext; - int mSize, mMinSize, mMaxSize; - int mThreshold; - - TQString mDir; -}; - - -/*** KIconTheme ***/ - -KIconTheme::KIconTheme(const TQString& name, const TQString& appName) -{ - d = new KIconThemePrivate; - - TQStringList icnlibs; - TQStringList::ConstIterator it, itDir; - TQStringList themeDirs; - TQString cDir; - - // Applications can have local additions to the global "locolor" and - // "hicolor" icon themes. For these, the _global_ theme description - // files are used.. - - if (!appName.isEmpty() && - ( name == "crystalsvg" || name== "hicolor" || name == "locolor" ) ) - { - icnlibs = KGlobal::dirs()->resourceDirs("data"); - for (it=icnlibs.begin(); it!=icnlibs.end(); ++it) - { - cDir = *it + appName + "/icons/" + name; - if (TQFile::exists( cDir )) - themeDirs += cDir + "/"; - } - } - // Find the theme description file. These are always global. - - icnlibs = KGlobal::dirs()->resourceDirs("icon"); - icnlibs += KGlobal::dirs()->resourceDirs("xdgdata-icon"); - icnlibs += "/usr/share/pixmaps"; - // These are not in the icon spec, but e.g. GNOME puts some icons there anyway. - icnlibs += KGlobal::dirs()->resourceDirs("xdgdata-pixmap"); - for (it=icnlibs.begin(); it!=icnlibs.end(); ++it) - { - cDir = *it + name + "/"; - if (KStandardDirs::exists(cDir)) - { - themeDirs += cDir; - if (mDir.isEmpty() - && (KStandardDirs::exists( cDir + "index.desktop") || KStandardDirs::exists( cDir + "index.theme"))) - mDir = cDir; - } - } - - if (mDir.isEmpty()) - { - kdDebug(264) << "Icon theme " << name << " not found.\n"; - return; - } - - TQString fileName, mainSection; - if(TQFile::exists(mDir + "index.desktop")) { - fileName = mDir + "index.desktop"; - mainSection="KDE Icon Theme"; - } else { - fileName = mDir + "index.theme"; - mainSection="Icon Theme"; - } - // Use KSharedConfig to avoid parsing the file many times, from each kinstance. - // Need to keep a ref to it to make this useful - d->sharedConfig = KSharedConfig::openConfig( fileName, true /*readonly*/, false /*useKDEGlobals*/ ); - KConfig& cfg = *d->sharedConfig; - //was: KSimpleConfig cfg(fileName); - - cfg.setGroup(mainSection); - mName = cfg.readEntry("Name"); - mDesc = cfg.readEntry("Comment"); - mDepth = cfg.readNumEntry("DisplayDepth", 32); - mInherits = cfg.readListEntry("Inherits"); - if ( name != "crystalsvg" ) - for ( TQStringList::Iterator it = mInherits.begin(); it != mInherits.end(); ++it ) - if ( *it == "default" || *it == "hicolor" ) *it="crystalsvg"; - - d->hidden = cfg.readBoolEntry("Hidden", false); - d->example = cfg.readPathEntry("Example"); - d->screenshot = cfg.readPathEntry("ScreenShot"); - d->linkOverlay = cfg.readEntry("LinkOverlay", "link"); - d->lockOverlay = cfg.readEntry("LockOverlay", "lock"); - d->zipOverlay = cfg.readEntry("ZipOverlay", "zip"); - d->shareOverlay = cfg.readEntry("ShareOverlay","share"); - - TQStringList dirs = cfg.readPathListEntry("Directories"); - mDirs.setAutoDelete(true); - for (it=dirs.begin(); it!=dirs.end(); ++it) - { - cfg.setGroup(*it); - for (itDir=themeDirs.begin(); itDir!=themeDirs.end(); ++itDir) - { - if (KStandardDirs::exists(*itDir + *it + "/")) - { - KIconThemeDir *dir = new KIconThemeDir(*itDir + *it, &cfg); - if (!dir->isValid()) - { - kdDebug(264) << "Icon directory " << *itDir << " group " << *it << " not valid.\n"; - delete dir; - } - else - mDirs.append(dir); - } - } - } - - // Expand available sizes for scalable icons to their full range - int i; - TQMap<int,TQValueList<int> > scIcons; - for (KIconThemeDir *dir=mDirs.first(); dir!=0L; dir=mDirs.next()) - { - if ((dir->type() == KIcon::Scalable) && !scIcons.contains(dir->size())) - { - TQValueList<int> lst; - for (i=dir->minSize(); i<=dir->maxSize(); i++) - lst += i; - scIcons[dir->size()] = lst; - } - } - - TQStringList groups; - groups += "Desktop"; - groups += "Toolbar"; - groups += "MainToolbar"; - groups += "Small"; - groups += "Panel"; - const int defDefSizes[] = { 32, 22, 22, 16, 32 }; - cfg.setGroup(mainSection); - for (it=groups.begin(), i=0; it!=groups.end(); ++it, i++) - { - mDefSize[i] = cfg.readNumEntry(*it + "Default", defDefSizes[i]); - TQValueList<int> exp, lst = cfg.readIntListEntry(*it + "Sizes"); - TQValueList<int>::ConstIterator it2; - for (it2=lst.begin(); it2!=lst.end(); ++it2) - { - if (scIcons.contains(*it2)) - exp += scIcons[*it2]; - else - exp += *it2; - } - mSizes[i] = exp; - } - -} - -KIconTheme::~KIconTheme() -{ - delete d; -} - -bool KIconTheme::isValid() const -{ - return !mDirs.isEmpty(); -} - -bool KIconTheme::isHidden() const -{ - return d->hidden; -} - -TQString KIconTheme::example() const { return d->example; } -TQString KIconTheme::screenshot() const { return d->screenshot; } -TQString KIconTheme::linkOverlay() const { return d->linkOverlay; } -TQString KIconTheme::lockOverlay() const { return d->lockOverlay; } -TQString KIconTheme::zipOverlay() const { return d->zipOverlay; } -TQString KIconTheme::shareOverlay() const { return d->shareOverlay; } - -int KIconTheme::defaultSize(KIcon::Group group) const -{ - if ((group < 0) || (group >= KIcon::LastGroup)) - { - kdDebug(264) << "Illegal icon group: " << group << "\n"; - return -1; - } - return mDefSize[group]; -} - -TQValueList<int> KIconTheme::querySizes(KIcon::Group group) const -{ - TQValueList<int> empty; - if ((group < 0) || (group >= KIcon::LastGroup)) - { - kdDebug(264) << "Illegal icon group: " << group << "\n"; - return empty; - } - return mSizes[group]; -} - -TQStringList KIconTheme::queryIcons(int size, KIcon::Context context) const -{ - int delta = 1000, dw; - - TQPtrListIterator<KIconThemeDir> dirs(mDirs); - KIconThemeDir *dir; - - // Try to find exact match - TQStringList result; - for ( ; dirs.current(); ++dirs) - { - dir = dirs.current(); - if ((context != KIcon::Any) && (context != dir->context())) - continue; - if ((dir->type() == KIcon::Fixed) && (dir->size() == size)) - { - result += dir->iconList(); - continue; - } - if ((dir->type() == KIcon::Scalable) && - (size >= dir->minSize()) && (size <= dir->maxSize())) - { - result += dir->iconList(); - continue; - } - if ((dir->type() == KIcon::Threshold) && - (abs(size-dir->size())<dir->threshold())) - result+=dir->iconList(); - } - - return result; - - dirs.toFirst(); - - // Find close match - KIconThemeDir *best = 0L; - for ( ; dirs.current(); ++dirs) - { - dir = dirs.current(); - if ((context != KIcon::Any) && (context != dir->context())) - continue; - dw = dir->size() - size; - if ((dw > 6) || (abs(dw) >= abs(delta))) - continue; - delta = dw; - best = dir; - } - if (best == 0L) - return TQStringList(); - - return best->iconList(); -} - -TQStringList KIconTheme::queryIconsByContext(int size, KIcon::Context context) const -{ - TQPtrListIterator<KIconThemeDir> dirs(mDirs); - int dw; - KIconThemeDir *dir; - - // We want all the icons for a given context, but we prefer icons - // of size size . Note that this may (will) include duplicate icons - //TQStringList iconlist[34]; // 33 == 48-16+1 - TQStringList iconlist[128]; // 33 == 48-16+1 - // Usually, only the 0, 6 (22-16), 10 (32-22), 16 (48-32 or 32-16), - // 26 (48-22) and 32 (48-16) will be used, but who knows if someone - // will make icon themes with different icon sizes. - - for ( ; dirs.current(); ++dirs) - { - dir = dirs.current(); - if ((context != KIcon::Any) && (context != dir->context())) - continue; - dw = abs(dir->size() - size); - iconlist[(dw<127)?dw:127]+=dir->iconList(); - } - - TQStringList iconlistResult; - for (int i=0; i<128; i++) iconlistResult+=iconlist[i]; - - return iconlistResult; -} - -bool KIconTheme::hasContext(KIcon::Context context) const -{ - TQPtrListIterator<KIconThemeDir> dirs(mDirs); - KIconThemeDir *dir; - - for ( ; dirs.current(); ++dirs) - { - dir = dirs.current(); - if ((context == KIcon::Any) || (context == dir->context())) - return true; - } - return false; -} - -KIcon KIconTheme::iconPath(const TQString& name, int size, KIcon::MatchType match) const -{ - KIcon icon; - TQString path; - int delta = -1000, dw; - KIconThemeDir *dir; - - dw = 1000; // shut up, gcc - TQPtrListIterator<KIconThemeDir> dirs(mDirs); - for ( ; dirs.current(); ++dirs) - { - dir = dirs.current(); - - if (match == KIcon::MatchExact) - { - if ((dir->type() == KIcon::Fixed) && (dir->size() != size)) - continue; - if ((dir->type() == KIcon::Scalable) && - ((size < dir->minSize()) || (size > dir->maxSize()))) - continue; - if ((dir->type() == KIcon::Threshold) && - (abs(dir->size()-size) > dir->threshold())) - continue; - } else - { - // dw < 0 means need to scale up to get an icon of the requested size - if (dir->type() == KIcon::Fixed) - { - dw = dir->size() - size; - } else if (dir->type() == KIcon::Scalable) - { - if (size < dir->minSize()) - dw = dir->minSize() - size; - else if (size > dir->maxSize()) - dw = dir->maxSize() - size; - else - dw = 0; - } else if (dir->type() == KIcon::Threshold) - { - if (size < dir->size() - dir->threshold()) - dw = dir->size() - dir->threshold() - size; - else if (size > dir->size() + dir->threshold()) - dw = dir->size() + dir->threshold() - size; - else - dw = 0; - } - /* Skip this if we've found a closer one, unless - it's a downscale, and we only had upscales befores. - This is to avoid scaling up unless we have to, - since that looks very ugly */ - if (/*(abs(dw) >= abs(delta)) ||*/ - (delta > 0 && dw < 0)) - continue; - } - - path = dir->iconPath(name); - if (path.isEmpty()) - continue; - icon.path = path; - icon.size = dir->size(); - icon.type = dir->type(); - icon.threshold = dir->threshold(); - icon.context = dir->context(); - - // if we got in MatchExact that far, we find no better - if (match == KIcon::MatchExact) - return icon; - else - { - delta = dw; - if (delta==0) return icon; // We won't find a better match anyway - } - } - return icon; -} - -// static -TQString *KIconTheme::_theme = 0L; - -// static -TQStringList *KIconTheme::_theme_list = 0L; - -// static -TQString KIconTheme::current() -{ - // Static pointer because of unloading problems wrt DSO's. - if (_theme != 0L) - return *_theme; - - _theme = new TQString(); - KConfig *config = KGlobal::config(); - KConfigGroupSaver saver(config, "Icons"); - *_theme = config->readEntry("Theme",defaultThemeName()); - if ( *_theme == TQString::tqfromLatin1("hicolor") ) *_theme = defaultThemeName(); -/* if (_theme->isEmpty()) - { - if (TQPixmap::defaultDepth() > 8) - *_theme = defaultThemeName(); - else - *_theme = TQString::tqfromLatin1("locolor"); - }*/ - return *_theme; -} - -// static -TQStringList KIconTheme::list() -{ - // Static pointer because of unloading problems wrt DSO's. - if (_theme_list != 0L) - return *_theme_list; - - _theme_list = new TQStringList(); - TQStringList icnlibs = KGlobal::dirs()->resourceDirs("icon"); - icnlibs += (KGlobal::dirs()->resourceDirs("xdgdata-icon")); - icnlibs += "/usr/share/pixmaps"; - // These are not in the icon spec, but e.g. GNOME puts some icons there anyway. - icnlibs += KGlobal::dirs()->resourceDirs("xdgdata-pixmap"); - TQStringList::ConstIterator it; - for (it=icnlibs.begin(); it!=icnlibs.end(); ++it) - { - TQDir dir(*it); - if (!dir.exists()) - continue; - TQStringList lst = dir.entryList(TQDir::Dirs); - TQStringList::ConstIterator it2; - for (it2=lst.begin(); it2!=lst.end(); ++it2) - { - if ((*it2 == ".") || (*it2 == "..") || (*it2).startsWith("default.") ) - continue; - if (!KStandardDirs::exists(*it + *it2 + "/index.desktop") && !KStandardDirs::exists(*it + *it2 + "/index.theme")) - continue; - KIconTheme oink(*it2); - if (!oink.isValid()) continue; - - if (!_theme_list->contains(*it2)) - _theme_list->append(*it2); - } - } - return *_theme_list; -} - -// static -void KIconTheme::reconfigure() -{ - delete _theme; - _theme=0L; - delete _theme_list; - _theme_list=0L; -} - -// static -TQString KIconTheme::defaultThemeName() -{ - return TQString::tqfromLatin1("crystalsvg"); -} - -/*** KIconThemeDir ***/ - -KIconThemeDir::KIconThemeDir(const TQString& dir, const KConfigBase *config) -{ - mbValid = false; - mDir = dir; - mSize = config->readNumEntry("Size"); - mMinSize = 1; // just set the variables to something - mMaxSize = 50; // meaningful in case someone calls minSize or maxSize - mType = KIcon::Fixed; - - if (mSize == 0) - return; - - TQString tmp = config->readEntry("Context"); - if (tmp == "Devices") - mContext = KIcon::Device; - else if (tmp == "MimeTypes") - mContext = KIcon::MimeType; - else if (tmp == "FileSystems") - mContext = KIcon::FileSystem; - else if (tmp == "Applications") - mContext = KIcon::Application; - else if (tmp == "Actions") - mContext = KIcon::Action; - else if (tmp == "Animations") - mContext = KIcon::Animation; - else if (tmp == "Categories") - mContext = KIcon::Category; - else if (tmp == "Emblems") - mContext = KIcon::Emblem; - else if (tmp == "Emotes") - mContext = KIcon::Emote; - else if (tmp == "International") - mContext = KIcon::International; - else if (tmp == "Places") - mContext = KIcon::Place; - else if (tmp == "Status") - mContext = KIcon::StatusIcon; - else { - kdDebug(264) << "Invalid Context= line for icon theme: " << mDir << "\n"; - return; - } - tmp = config->readEntry("Type"); - if (tmp == "Fixed") - mType = KIcon::Fixed; - else if (tmp == "Scalable") - mType = KIcon::Scalable; - else if (tmp == "Threshold") - mType = KIcon::Threshold; - else { - kdDebug(264) << "Invalid Type= line for icon theme: " << mDir << "\n"; - return; - } - if (mType == KIcon::Scalable) - { - mMinSize = config->readNumEntry("MinSize", mSize); - mMaxSize = config->readNumEntry("MaxSize", mSize); - } else if (mType == KIcon::Threshold) - mThreshold = config->readNumEntry("Threshold", 2); - mbValid = true; -} - -TQString KIconThemeDir::iconPath(const TQString& name) const -{ - if (!mbValid) - return TQString::null; - TQString file = mDir + "/" + name; - - if (access(TQFile::encodeName(file), R_OK) == 0) - return file; - - return TQString::null; -} - -TQStringList KIconThemeDir::iconList() const -{ - TQDir dir(mDir); -#ifdef HAVE_LIBART - TQStringList lst = dir.entryList("*.png;*.svg;*.svgz;*.xpm", TQDir::Files); -#else - TQStringList lst = dir.entryList("*.png;*.xpm", TQDir::Files); -#endif - TQStringList result; - TQStringList::ConstIterator it; - for (it=lst.begin(); it!=lst.end(); ++it) - result += mDir + "/" + *it; - return result; -} diff --git a/kdecore/kicontheme.h b/kdecore/kicontheme.h deleted file mode 100644 index d8e29d339..000000000 --- a/kdecore/kicontheme.h +++ /dev/null @@ -1,369 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * This file is part of the KDE project, module tdecore. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * Antonio Larrosa <larrosa@kde.org> - * - * This is free software; it comes under the GNU Library General - * Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - */ - -#ifndef __KIconTheme_h_Included__ -#define __KIconTheme_h_Included__ - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqptrlist.h> -#include <tqvaluelist.h> -#include "kdelibs_export.h" - -class KConfig; -class KIconThemeDir; - -class KIconThemePrivate; - -class KIconPrivate; - -/** - * One icon as found by KIconTheme. Also serves as a namespace containing - * icon related constants. - * @see KIconEffect - * @see KIconTheme - * @see KIconLoader - */ -class KDECORE_EXPORT KIcon -{ -public: - KIcon() { size = 0; } - - /** - * Return true if this icon is valid, false otherwise. - */ - bool isValid() const { return size != 0; } - - /** - * Defines the context of the icon. - */ - enum Context { - Any, ///< Some icon with unknown purpose. - Action, ///< An action icon (e.g. 'save', 'print'). - Application, ///< An icon that represents an application. - Device, ///< An icon that represents a device. - FileSystem, ///< An icon that represents a file system. - MimeType, ///< An icon that represents a mime type (or file type). - Animation, ///< An icon that is animated. - Category, ///< An icon that represents a category. - Emblem, ///< An icon that adds information to an existing icon. - Emote, ///< An icon that expresses an emotion. - International, ///< An icon that represents a country's flag. - Place, ///< An icon that represents a location (e.g. 'home', 'trash'). - StatusIcon ///< An icon that represents an event. - }; - - /** - * The type of the icon. - */ - enum Type { - Fixed, ///< Fixed-size icon. - Scalable, ///< Scalable-size icon. - Threshold ///< A threshold icon. - }; - - /** - * The type of a match. - */ - enum MatchType { - MatchExact, ///< Only try to find an exact match. - MatchBest ///< Take the best match if there is no exact match. - - }; - - // if you add a group here, make sure to change the config reading in - // KIconLoader too - /** - * The group of the icon. - */ - enum Group { - /// No group - NoGroup=-1, - /// Desktop icons - Desktop=0, - /// First group - FirstGroup=0, - /// Toolbar icons - Toolbar, - /// Main toolbar icons - MainToolbar, - /// Small icons - Small, - /// Panel (Kicker) icons - Panel, - /// Last group - LastGroup, - /// User icons - User - }; - - /** - * These are the standard sizes for icons. - */ - enum StdSizes { - /// small icons for menu entries - SizeSmall=16, - /// slightly larger small icons for toolbars, panels, etc - SizeSmallMedium=22, - /// medium sized icons for the desktop - SizeMedium=32, - /// large sized icons for the panel - SizeLarge=48, - /// huge sized icons for iconviews - SizeHuge=64, - /// enormous sized icons for iconviews - SizeEnormous=128 - }; - - /** - * Defines the possible states of an icon. - */ - enum States { DefaultState, ///< The default state. - ActiveState, ///< Icon is active. - DisabledState, ///< Icon is disabled. - LastState ///< Last state (last constant) - }; - - /** - * This defines an overlay, a semi-transparent image that is - * projected onto the icon. They are used to show that the file - * represented by the icon is, for example, locked, zipped or hidden. - */ - enum Overlays { - LockOverlay=0x100, ///< a file is locked - ZipOverlay=0x200, ///< a file is zipped - LinkOverlay=0x400, ///< a file is a link - HiddenOverlay=0x800, ///< a file is hidden - ShareOverlay=0x1000, ///< a file is shared - OverlayMask = ~0xff - }; - - /** - * The size in pixels of the icon. - */ - int size; - - /** - * The context of the icon. - */ - Context context; - - /** - * The type of the icon: Fixed, Scalable or Threshold. - **/ - Type type; - - /** - * The threshold in case type == Threshold - */ - int threshold; - - /** - * The full path of the icon. - */ - TQString path; - -private: - KIconPrivate *d; -}; - -inline KIcon::Group& operator++(KIcon::Group& group) { group = static_cast<KIcon::Group>(group+1); return group; } -inline KIcon::Group operator++(KIcon::Group& group,int) { KIcon::Group ret = group; ++group; return ret; } - -/** - * Class to use/access icon themes in KDE. This class is used by the - * iconloader but can be used by others too. - * @see KIconLoader - */ -class KDECORE_EXPORT KIconTheme -{ -public: - /** - * Load an icon theme by name. - * @param name the name of the theme (e.g. "hicolor" or "keramik") - * @param appName the name of the application. Can be null. This argument - * allows applications to have themed application icons. - */ - KIconTheme(const TQString& name, const TQString& appName=TQString::null); - ~KIconTheme(); - - /** - * The stylized name of the icon theme. - * @return the (human-readable) name of the theme - */ - TQString name() const { return mName; } - - /** - * A description for the icon theme. - * @return a human-readable description of the theme, TQString::null - * if there is none - */ - TQString description() const { return mDesc; } - - /** - * Return the name of the "example" icon. This can be used to - * present the theme to the user. - * @return the name of the example icon, TQString::null if there is none - */ - TQString example() const; - - /** - * Return the name of the screenshot. - * @return the name of the screenshot, TQString::null if there is none - */ - TQString screenshot() const; - - /** - * Returns the name of this theme's link overlay. - * @return the name of the link overlay - */ - TQString linkOverlay() const; - - /** - * Returns the name of this theme's zip overlay. - * @return the name of the zip overlay - */ - TQString zipOverlay() const; - - /** - * Returns the name of this theme's lock overlay. - * @return the name of the lock overlay - */ - TQString lockOverlay() const; - - /** - * Returns the name of this theme's share overlay. - * @return the name of the share overlay - * @since 3.1 - */ - TQString shareOverlay () const; - - /** - * Returns the toplevel theme directory. - * @return the directory of the theme - */ - TQString dir() const { return mDir; } - - /** - * The themes this icon theme falls back on. - * @return a list of icon themes that are used as fall-backs - */ - TQStringList inherits() const { return mInherits; } - - /** - * The icon theme exists? - * @return true if the icon theme is valid - */ - bool isValid() const; - - /** - * The icon theme should be hidden to the user? - * @return true if the icon theme is hidden - * @since 3.1 - */ - bool isHidden() const; - - /** - * The minimum display depth required for this theme. This can either - * be 8 or 32. - * @return the minimum bpp (8 or 32) - */ - int depth() const { return mDepth; } - - /** - * The default size of this theme for a certain icon group. - * @param group The icon group. See KIcon::Group. - * @return The default size in pixels for the given icon group. - */ - int defaultSize(KIcon::Group group) const; - - /** - * Query available sizes for a group. - * @param group The icon group. See KIcon::Group. - * @return a list of available sized for the given group - */ - TQValueList<int> querySizes(KIcon::Group group) const; - - /** - * Query available icons for a size and context. - * @param size the size of the icons - * @param context the context of the icons - * @return the list of icon names - */ - TQStringList queryIcons(int size, KIcon::Context context = KIcon::Any) const; - - /** - * Query available icons for a context and preferred size. - * @param size the size of the icons - * @param context the context of the icons - * @return the list of icon names - */ - TQStringList queryIconsByContext(int size, KIcon::Context context = KIcon::Any) const; - - - /** - * Lookup an icon in the theme. - * @param name The name of the icon, without extension. - * @param size The desired size of the icon. - * @param match The matching mode. KIcon::MatchExact returns an icon - * only if matches exactly. KIcon::MatchBest returns the best matching - * icon. - * @return A KIcon class that describes the icon. If an icon is found, - * @see KIcon::isValid will return true, and false otherwise. - */ - KIcon iconPath(const TQString& name, int size, KIcon::MatchType match) const; - - /** - * Returns true if the theme has any icons for the given context. - * @since 3.5.5 - */ - bool hasContext( KIcon::Context context ) const; - - /** - * List all icon themes installed on the system, global and local. - * @return the list of all icon themes - */ - static TQStringList list(); - - /** - * Returns the current icon theme. - * @return the name of the current theme - */ - static TQString current(); - - /** - * Reconfigure the theme. - */ - static void reconfigure(); - - /** - * Returns the default icon theme. - * @return the name of the default theme name - * @since 3.1 - */ - static TQString defaultThemeName(); - -private: - int mDefSize[8]; - TQValueList<int> mSizes[8]; - - int mDepth; - TQString mDir, mName, mDesc; - TQStringList mInherits; - TQPtrList<KIconThemeDir> mDirs; - KIconThemePrivate *d; - - static TQString *_theme; - static TQStringList *_theme_list; -}; - -#endif diff --git a/kdecore/kidna.cpp b/kdecore/kidna.cpp deleted file mode 100644 index 1ce2c1348..000000000 --- a/kdecore/kidna.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - - 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. -*/ - -#include "kidna.h" - -#ifndef Q_WS_WIN //TODO kresolver not ported -#include "kresolver.h" -#endif -#include <kdebug.h> - -#ifndef Q_WS_WIN //TODO knetwork not ported -using namespace KNetwork; -#endif - -TQCString KIDNA::toAsciiCString(const TQString &idna) -{ -#ifndef Q_WS_WIN //TODO kresolver not ported - return KResolver::domainToAscii(idna); -#else - return TQCString(); -#endif -} - -TQString KIDNA::toAscii(const TQString &idna) -{ - if (idna.length() && (idna[0] == (QChar)'.')) - { - TQString host = TQString::tqfromLatin1(toAsciiCString(idna.mid(1))); - if (host.isEmpty()) - return TQString::null; // Error - return idna[0] + host; - } - return TQString::tqfromLatin1(toAsciiCString(idna)); -} - -TQString KIDNA::toUnicode(const TQString &idna) -{ -#ifndef Q_WS_WIN //TODO kresolver not ported - if (idna.length() && (idna[0] == (QChar)'.')) - return idna[0] + KResolver::domainToUnicode(idna.mid(1)); - return KResolver::domainToUnicode(idna); -#else - return TQString::null; -#endif -} diff --git a/kdecore/kidna.h b/kdecore/kidna.h deleted file mode 100644 index 9feac63b5..000000000 --- a/kdecore/kidna.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - - 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 _KIDNA_H -#define _KIDNA_H - -#include <tqstring.h> -#include "kdelibs_export.h" - -namespace KIDNA { - /** - * Converts an International Domain Name @p idna to - * its ASCII representation - * - * If conversion is not possible, an empty string is returned. - */ - KDECORE_EXPORT TQCString toAsciiCString(const TQString &idna); - - /** - * Converts an International Domain Name @p idna to - * its ASCII representation - * - * If conversion is not possible, an empty string is returned. - */ - KDECORE_EXPORT TQString toAscii(const TQString &idna); - - /** - * Converts an International Domain Name @p idna to - * its UNICODE representation - */ - KDECORE_EXPORT TQString toUnicode(const TQString &idna); -} - -#endif /* _KIDNA_H */ diff --git a/kdecore/kinstance.cpp b/kdecore/kinstance.cpp deleted file mode 100644 index 2a579de0a..000000000 --- a/kdecore/kinstance.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - - 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 "kinstance.h" - -#include <stdlib.h> -#include <unistd.h> - -#include "kconfig.h" -#include "klocale.h" -#include "kcharsets.h" -#include "kiconloader.h" -#include "kaboutdata.h" -#include "kstandarddirs.h" -#include "kdebug.h" -#include "kglobal.h" -#include "kmimesourcefactory.h" - -#include <tqfont.h> - -#include "config.h" -#ifndef NDEBUG - #include <assert.h> - #include <tqptrdict.h> - static TQPtrList<KInstance> *allInstances = 0; - static TQPtrDict<TQCString> *allOldInstances = 0; - #define DEBUG_ADD do { if (!allInstances) { allInstances = new TQPtrList<KInstance>(); allOldInstances = new TQPtrDict<TQCString>(); } allInstances->append(this); allOldInstances->insert( this, new TQCString( _name)); } while (false); - #define DEBUG_REMOVE do { allInstances->removeRef(this); } while (false); - #define DEBUG_CHECK_ALIVE do { if (!allInstances->contains((KInstance*)this)) { TQCString *old = allOldInstances->find((KInstance*)this); qWarning("ACCESSING DELETED KINSTANCE! (%s)", old ? old->data() : "<unknown>"); assert(false); } } while (false); -#else - #define DEBUG_ADD - #define DEBUG_REMOVE - #define DEBUG_CHECK_ALIVE -#endif - -class KInstancePrivate -{ -public: - KInstancePrivate () - { - mimeSourceFactory = 0L; - } - - ~KInstancePrivate () - { - delete mimeSourceFactory; - } - - KMimeSourceFactory* mimeSourceFactory; - TQString configName; - bool ownAboutdata; - KSharedConfig::Ptr sharedConfig; -}; - -KInstance::KInstance( const TQCString& name) - : _dirs (0L), - _config (0L), - _iconLoader (0L), - _name( name ), _aboutData( new KAboutData( name, "", 0 ) ) -{ - DEBUG_ADD - Q_ASSERT(!name.isEmpty()); - if (!KGlobal::_instance) - { - KGlobal::_instance = this; - KGlobal::setActiveInstance(this); - } - - d = new KInstancePrivate (); - d->ownAboutdata = true; -} - -KInstance::KInstance( const KAboutData * aboutData ) - : _dirs (0L), - _config (0L), - _iconLoader (0L), - _name( aboutData->appName() ), _aboutData( aboutData ) -{ - DEBUG_ADD - Q_ASSERT(!_name.isEmpty()); - - if (!KGlobal::_instance) - { - KGlobal::_instance = this; - KGlobal::setActiveInstance(this); - } - - d = new KInstancePrivate (); - d->ownAboutdata = false; -} - -KInstance::KInstance( KInstance* src ) - : _dirs ( src->_dirs ), - _config ( src->_config ), - _iconLoader ( src->_iconLoader ), - _name( src->_name ), _aboutData( src->_aboutData ) -{ - DEBUG_ADD - Q_ASSERT(!_name.isEmpty()); - - if (!KGlobal::_instance || KGlobal::_instance == src ) - { - KGlobal::_instance = this; - KGlobal::setActiveInstance(this); - } - - d = new KInstancePrivate (); - d->ownAboutdata = src->d->ownAboutdata; - d->sharedConfig = src->d->sharedConfig; - - src->_dirs = 0L; - src->_config = 0L; - src->_iconLoader = 0L; - src->_aboutData = 0L; - delete src; -} - -KInstance::~KInstance() -{ - DEBUG_CHECK_ALIVE - - if (d->ownAboutdata) - delete _aboutData; - _aboutData = 0; - - delete d; - d = 0; - - delete _iconLoader; - _iconLoader = 0; - - // delete _config; // Do not delete, stored in d->sharedConfig - _config = 0; - delete _dirs; - _dirs = 0; - - if (KGlobal::_instance == this) - KGlobal::_instance = 0; - if (KGlobal::activeInstance() == this) - KGlobal::setActiveInstance(0); - DEBUG_REMOVE -} - - -KStandardDirs *KInstance::dirs() const -{ - DEBUG_CHECK_ALIVE - if( _dirs == 0 ) { - _dirs = new KStandardDirs( ); - if (_config) { - if (_dirs->addCustomized(_config)) - _config->reparseConfiguration(); - } else - config(); // trigger adding of possible customized dirs - } - - return _dirs; -} - -extern bool kde_kiosk_exception; -extern bool kde_kiosk_admin; - -KConfig *KInstance::config() const -{ - DEBUG_CHECK_ALIVE - if( _config == 0 ) { - if ( !d->configName.isEmpty() ) - { - d->sharedConfig = KSharedConfig::openConfig( d->configName ); - - // Check whether custom config files are allowed. - d->sharedConfig->setGroup( "KDE Action Restrictions" ); - TQString kioskException = d->sharedConfig->readEntry("kiosk_exception"); - if (d->sharedConfig->readBoolEntry( "custom_config", true)) - { - d->sharedConfig->setGroup(TQString::null); - } - else - { - d->sharedConfig = 0; - } - - } - - if ( d->sharedConfig == 0 ) - { - if ( !_name.isEmpty() ) - d->sharedConfig = KSharedConfig::openConfig( _name + "rc"); - else - d->sharedConfig = KSharedConfig::openConfig( TQString::null ); - } - - // Check if we are excempt from kiosk restrictions - if (kde_kiosk_admin && !kde_kiosk_exception && !TQCString(getenv("KDE_KIOSK_NO_RESTRICTIONS")).isEmpty()) - { - kde_kiosk_exception = true; - d->sharedConfig = 0; - return config(); // Reread... - } - - _config = d->sharedConfig; - if (_dirs) - if (_dirs->addCustomized(_config)) - _config->reparseConfiguration(); - } - - return _config; -} - -KSharedConfig *KInstance::sharedConfig() const -{ - DEBUG_CHECK_ALIVE - if (_config == 0) - (void) config(); // Initialize config - - return d->sharedConfig; -} - -void KInstance::setConfigName(const TQString &configName) -{ - DEBUG_CHECK_ALIVE - d->configName = configName; -} - -KIconLoader *KInstance::iconLoader() const -{ - DEBUG_CHECK_ALIVE - if( _iconLoader == 0 ) { - _iconLoader = new KIconLoader( _name, dirs() ); - _iconLoader->enableDelayedIconSetLoading( true ); - } - - return _iconLoader; -} - -void KInstance::newIconLoader() const -{ - DEBUG_CHECK_ALIVE - KIconTheme::reconfigure(); - _iconLoader->reconfigure( _name, dirs() ); -} - -const KAboutData * KInstance::aboutData() const -{ - DEBUG_CHECK_ALIVE - return _aboutData; -} - -TQCString KInstance::instanceName() const -{ - DEBUG_CHECK_ALIVE - return _name; -} - -KMimeSourceFactory* KInstance::mimeSourceFactory () const -{ - DEBUG_CHECK_ALIVE - if (!d->mimeSourceFactory) - { - d->mimeSourceFactory = new KMimeSourceFactory(_iconLoader); - d->mimeSourceFactory->setInstance(const_cast<KInstance *>(this)); - } - - return d->mimeSourceFactory; -} - -void KInstance::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - diff --git a/kdecore/kinstance.h b/kdecore/kinstance.h deleted file mode 100644 index bb11183db..000000000 --- a/kdecore/kinstance.h +++ /dev/null @@ -1,159 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - - 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 _KINSTANCE_H -#define _KINSTANCE_H - -class KStandardDirs; -class KAboutData; -class KConfig; -class KIconLoader; -class KCharsets; -class TQFont; -class KInstancePrivate; -class KMimeSourceFactory; -class KSharedConfig; - -#include <tqstring.h> -#include "kdelibs_export.h" - - -/** - * Access to KDE global objects for use in shared libraries. In - * practical terms, this class is used in KDE components. This allows - * components to store things that normally would be accessed by - * KGlobal. - * - * @author Torben Weis - */ -class KDECORE_EXPORT KInstance -{ - friend class KStandardDirs; - - public: - /** - * Constructor. - * @param instanceName the name of the instance - */ - KInstance( const TQCString& instanceName) ; - - /** - * Constructor. - * When building a KInstance that is not your KApplication, - * make sure that the KAboutData and the KInstance have the same life time. - * You have to destroy both, since the instance doesn't own the about data. - * Don't build a KAboutData on the stack in this case ! - * Building a KAboutData on the stack is only ok for usage with - * KCmdLineArgs and KApplication (not destroyed until the app exits). - * @param aboutData data about this instance (see KAboutData) - */ - KInstance( const KAboutData * aboutData ); - - /* - * @internal - * Only for K(Unique)Application - * Initialize from src and delete it. - */ - - KInstance( KInstance* src ); - - /** - * Destructor. - */ - virtual ~KInstance(); - - /** - * Returns the application standard dirs object. - * @return The KStandardDirs of the application. - */ - KStandardDirs *dirs() const; - - /** - * Returns the general config object ("appnamerc"). - * @return the KConfig object for the instance. - */ - KConfig *config() const; - - /** - * Returns the general config object ("appnamerc"). - * @return the KConfig object for the instance. - */ - KSharedConfig *sharedConfig() const; - - /** - * Returns an iconloader object. - * @return the iconloader object. - */ - KIconLoader *iconLoader() const; - - /** - * Re-allocate the global iconloader. - */ - void newIconLoader() const; - - /** - * Returns the about data of this instance - * Warning, can be 0L - * @return the about data of the instance, or 0 if it has - * not been set yet - */ - const KAboutData *aboutData() const; - - /** - * Returns the name of the instance - * @return the instance name, can be null if the KInstance has been - * created with a null name - */ - TQCString instanceName() const; - - /** - * Returns the KMimeSourceFactory of the instance. - * Mainly added for API completeness and future extensibility. - * @return the KMimeSourceFactory set as default for this application. - */ - KMimeSourceFactory* mimeSourceFactory () const; - -protected: - /** - * Copy Constructor is not allowed - */ - KInstance( const KInstance& ); - - /** - * Set name of default config file. - * @param name the name of the default config file - * @since 3.1 - */ - void setConfigName(const TQString &name); - -private: - mutable KStandardDirs *_dirs; - - mutable KConfig *_config; - mutable KIconLoader *_iconLoader; - - TQCString _name; - const KAboutData *_aboutData; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KInstancePrivate *d; -}; - -#endif - diff --git a/kdecore/kipc.cpp b/kdecore/kipc.cpp deleted file mode 100644 index 8c568ba1b..000000000 --- a/kdecore/kipc.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (C) 1999 Mattias Ettrich (ettrich@kde.org) - Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - - 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. -*/ - - -/* - * kipc.cpp: Send a message to one/all KDE apps. - * - * $Id$ - */ -#include "config.h" - -#include <tqevent.h> -#include <tqwindowdefs.h> - -#if defined Q_WS_X11 -#include <X11/X.h> -#include <X11/Xlib.h> -#include <kxerrorhandler.h> -#endif - -#include <kipc.h> - - -#if defined Q_WS_X11 -static long getSimpleProperty(Window w, Atom a) -{ - Atom real_type; - int format; - unsigned long n, extra, res = 0; - int status; - unsigned char *p = 0; - - status = XGetWindowProperty(qt_xdisplay(), w, a, 0L, 1L, False, a, - &real_type, &format, &n, &extra, &p); - if ((status == Success) && (n == 1) && (format == 32)) - res = *(unsigned long*)p; - if (p) XFree(p); - return res; -} -#endif - -void KIPC::sendMessage(Message msg, WId w, int data) -{ -#if defined Q_WS_X11 - static Atom a = 0; - if (a == 0) - a = XInternAtom(qt_xdisplay(), "KIPC_COMM_ATOM", False); - XEvent ev; - ev.xclient.type = ClientMessage; - ev.xclient.display = qt_xdisplay(); - ev.xclient.window = (Window) w; - ev.xclient.message_type = a; - ev.xclient.format = 32; - ev.xclient.data.l[0] = msg; - ev.xclient.data.l[1] = data; - XSendEvent(qt_xdisplay(), (Window) w, False, 0L, &ev); - - // KDE 1 support - static Atom kde1 = 0; - if ( msg == PaletteChanged || msg == FontChanged ) { - if ( kde1 == 0 ) - kde1 = XInternAtom(qt_xdisplay(), "KDEChangeGeneral", False ); - ev.xclient.message_type = kde1; - XSendEvent(qt_xdisplay(), (Window) w, False, 0L, &ev); - } - -#endif -} - - -void KIPC::sendMessageAll(Message msg, int data) -{ -#if defined Q_WS_X11 - unsigned int i, nrootwins; - Window dw1, dw2, *rootwins = 0; - Display *dpy = qt_xdisplay(); - int screen_count = ScreenCount(dpy); - - KXErrorHandler handler; - for (int s = 0; s < screen_count; s++) { - Window root = RootWindow(dpy, s); - - XQueryTree(dpy, root, &dw1, &dw2, &rootwins, &nrootwins); - Atom a = XInternAtom(qt_xdisplay(), "KDE_DESKTOP_WINDOW", False); - for (i = 0; i < nrootwins; i++) - { - if (getSimpleProperty(rootwins[i], a) != 0L) - sendMessage(msg, rootwins[i], data); - } - XFree((char *) rootwins); - } - XSync(dpy,False); -#endif -} - diff --git a/kdecore/kipc.h b/kdecore/kipc.h deleted file mode 100644 index 384620cde..000000000 --- a/kdecore/kipc.h +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (C) 1999 Mattias Ettrich (ettrich@kde.org) - Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - - 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 __KIPC_h_Included__ -#define __KIPC_h_Included__ - -#include <tqwindowdefs.h> -#include "kdelibs_export.h" - -/** - * This class implements a very simple IPC mechanism for KDE. You can send - * a message of a predefined type to either a specific application, or to all - * KDE application on the current display. The message can carry one integer of - * data. - * - * KIPC is mainly used in KDE for sending "Change Messages", i.e. a message to - * all KDE apps that a certain setting (the font, for example) has changed. - * For anything more complex it is recommended to use DCOP -- the Desktop - * Communications Protocol. - * - * Messages with id code < 32 are called "System Messages". These are - * directly handled by KApplication. Examples are: PaletteChanged and - * StyleChanged. Messages with id code >= 32 are user messages. KApplication - * emits the signal kipcMessage(id,arg) for each user message it receives. - * - * KIPC is implemented using X11 ClientMessage events. - * - * @see KApplication::kipcMessage() - * @author Geert Jansen <jansen@kde.org> - */ -class KDECORE_EXPORT KIPC -{ -public: - /** - * A identifier for messages. Messages below UserMessage are system - * messages, messages above can be defined by the user. - */ - enum Message { PaletteChanged=0, FontChanged, StyleChanged, - BackgroundChanged, SettingsChanged, IconChanged, ToolbarStyleChanged, - ClipboardConfigChanged, /// @since 3.1 - BlockShortcuts, /// @since 3.5 - UserMessage=32 }; - - /** - * Send a message to a specific application. - * - * @param msg The message to send. - * @param w The window id of a toplevel window of the target application. - * @param data An optional integer of data. - */ - static void sendMessage(Message msg, WId w, int data=0); - - /** - * Send a message to all KDE application on the current display. - * - * @param msg The message to send. - * @param data An optional integer of data. - */ - static void sendMessageAll(Message msg, int data=0); -}; -#endif diff --git a/kdecore/kkeynative.h b/kdecore/kkeynative.h deleted file mode 100644 index 47b4ad677..000000000 --- a/kdecore/kkeynative.h +++ /dev/null @@ -1,258 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Ellis Whitehead <ellis@kde.org> - - Win32 port: - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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 __KKEYNATIVE_H -#define __KKEYNATIVE_H - -#include <kshortcut.h> - -#ifdef Q_WS_X11 -typedef union _XEvent XEvent; -#endif - -class KKeyNativePrivate; -/** - * Representation of a key in the format native of the windowing system (eg. X11). - * @see KKey - */ -class KDECORE_EXPORT KKeyNative -{ - public: - /** - * Creates a new null KKey. - * @see clear() - * @see isNull() - * @see null() - */ - KKeyNative(); - -#ifdef Q_WS_X11 - /** - * Extracts a new native key from the given xevent. - * @param xevent the XEvent that contains the key - */ - KKeyNative( const XEvent* xevent ); -#endif - - /** - * Creates a new native key for the given KKey code. - * @param key the KKey that contains the generic key - */ - KKeyNative( const KKey& key ); - - /** - * Copy constructor. - */ - KKeyNative( const KKeyNative& ); - - /** - * @internal - */ - KKeyNative( uint code, uint mod, uint sym ); - ~KKeyNative(); - - /** - * Clears the key. The key is null after calling this function. - * @see isNull() - */ - void clear(); - -#ifdef Q_WS_X11 - /** - * Initializes the native key by extracting the information - * from the given xevent. - * @param xevent the XEvent that contains the key - * @return true if successful, false otherwise - */ - bool init( const XEvent* xevent ); -#endif - - /** - * Creates a new native key for the given KKey code. - * @param key the KKey that contains the generic key - * @return true if successful, false otherwise - */ - bool init( const KKey& key ); - - /** - * Copies the given key into this key. - * @param key the key to copy - * @return true if successful, false otherwise - */ - bool init( const KKeyNative& key ); - - /** - * Copies the given key into this key. - * @param key the key to copy - * @return this key - */ - KKeyNative& operator =( const KKeyNative& key ) - { init( key ); return *this; } - - /** - * Returns the qt key code. - * @return the qt key code or 0 if there is no key set. - * @see Qt::Key - */ - - int keyCodeQt() const; - - /** - * Returns the KKey representation of this key. - * @return the KKey representation - */ - KKey key() const; - - /** - * Converts this key to its KKey representation. - * @return the KKey representation - * @see key() - */ - operator KKey() const { return key(); } - - /** - * The native keycode of the key. - * @return the native keycode - */ - uint code() const; - - /** - * The native modifier flags of the key. - * @return the native modifier flags - */ - uint mod() const; - - /** - * The native symbol (KeySym) of the key. - * @return the native symbol (KeySym) - */ - uint sym() const; - - /** - * Returns true if the key is null (after clear() or empty - * constructor). - * @return true if the key is null - * @see clear() - * @see null() - */ - bool isNull() const; - - /** - * Compares this key with the given KKeyNative object. Returns a - * negative number if the given KKeyNative is larger, 0 if they - * are equal and a positive number this KKeyNative is larger. The - * returned value is the difference between the symbol, modifier - * or code, whatever is non-zero first. - * - * @param key the key to compare with this key - * @return a negative number if the given KKeyNative is larger, 0 if - * they are equal and a positive number this KKeyNative is larger - */ - int compare( const KKeyNative& key ) const; - - /** - * Compares the symbol, modifiers and code of both keys. - * @see compare() - */ - bool operator == ( const KKeyNative& key ) const - { return compare( key ) == 0; } - - /** - * Compares the symbol, modifiers and code of both keys. - * @see compare() - */ - bool operator != ( const KKeyNative& key ) const - { return compare( key ) != 0; } - - /** - * Compares the symbol, modifiers and code of both keys. - * @see compare() - */ - bool operator < ( const KKeyNative& key ) const - { return compare( key ) < 0; } - - /** - * Returns a null key. - * @return the null key - * @see isNull() - * @see clear() - */ - static KKeyNative& null(); - - // General query functions. // - /** - * Checks whether the keyboard has a Win key. - * @return true if the keyboard has a Win key - */ - static bool keyboardHasWinKey(); - -#ifdef Q_WS_X11 - /** - * Returns the equivalent X modifier mask of the given modifier flag. - * @param modFlag the mod flags to test - * @return the equivalent native flags of the window system - */ - static uint modX( KKey::ModFlag modFlag ); - - /** - * Returns bitwise OR'ed mask containing Shift, Ctrl, Alt, and - * Win (if available). - * @return the mask of Shift, Ctrl, Alt and Win. - */ - static uint accelModMaskX(); - - /** - * Returns the X11 NumLock modifier mask/flag. - * @return the X11 NumLock modifier mask/flag. - * @see accelModMaskX() - */ - static uint modXNumLock(); - - /** - * Returns the X11 Lock modifier mask/flag. - * @return the X11 Lock modifier mask/flag. - * @see accelModMaskX() - */ - static uint modXLock(); - - /** - * Returns the X11 ScrollLock modifier mask/flag. - * @return the X11 ScrollLock modifier mask/flag. - * @see accelModMaskX() - */ - static uint modXScrollLock(); - - /** - * Returns the X11 Mode_switch modifier mask/flag. - * @return the X11 Mode_switch modifier mask/flag. - * @see accelModMaskX() - * @since 3.5 - */ - static uint modXModeSwitch(); -#endif - - private: - uint m_code, m_mod, m_sym; - KKeyNativePrivate* d; -}; - -#endif // !__KKEYNATIVE_H diff --git a/kdecore/kkeynative_x11.cpp b/kdecore/kkeynative_x11.cpp deleted file mode 100644 index 8fed59deb..000000000 --- a/kdecore/kkeynative_x11.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - Copyright (C) 2001 Ellis Whitehead <ellis@kde.org> - - Win32 port: - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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. -*/ - -#include <tqnamespace.h> -#include <tqwindowdefs.h> - -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MACX) // Only compile this module if we're compiling for X11, mac or win32 - -#include "kkeynative.h" -#include "kkeyserver_x11.h" - -#include <tqmap.h> -#include <tqstringlist.h> -#include "kckey.h" -#include <kdebug.h> -#include <klocale.h> - -#ifdef Q_WS_X11 -#define XK_MISCELLANY -#define XK_XKB_KEYS -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/keysymdef.h> -#include <ctype.h> -#endif - -//--------------------------------------------------------------------- - -static KKeyNative* gx_pkey = 0; - -//--------------------------------------------------------------------- -// KKeyNative -//--------------------------------------------------------------------- - -KKeyNative::KKeyNative() { clear(); } -KKeyNative::KKeyNative( const KKey& key ) { init( key ); } -KKeyNative::KKeyNative( const KKeyNative& key ) { init( key ); } -#ifdef Q_WS_X11 -KKeyNative::KKeyNative( const XEvent* pEvent ) { init( pEvent ); } -#endif - -KKeyNative::KKeyNative( uint code, uint mod, uint sym ) -{ - m_code = code; - m_mod = mod; - m_sym = sym; -} - -KKeyNative::~KKeyNative() - { } - -void KKeyNative::clear() -{ - m_code = 0; - m_mod = 0; - m_sym = 0; -} - -#ifdef Q_WS_X11 -bool KKeyNative::init( const XEvent* pEvent ) -{ - KeySym keySym; - m_code = pEvent->xkey.keycode; - m_mod = pEvent->xkey.state; - XLookupString( (XKeyEvent*) pEvent, 0, 0, &keySym, 0 ); - m_sym = (uint) keySym; - return true; -} -#endif - -bool KKeyNative::init( const KKey& key ) -{ -#ifdef Q_WS_WIN - m_sym = key.sym(); - m_code = m_sym; //key.keyCodeQt(); - m_mod = key.m_mod; -#elif !defined(Q_WS_WIN) && !defined(Q_WS_MACX) - // Get any extra mods required by the sym. - // E.g., XK_Plus requires SHIFT on the en layout. - m_sym = key.sym(); - uint modExtra = KKeyServer::Sym(m_sym).getModsRequired(); - // Get the X modifier equivalent. - if( !m_sym || !KKeyServer::modToModX( key.modFlags() | modExtra, m_mod ) ) { - m_sym = m_mod = 0; - m_code = 0; - return false; - } - - // XKeysymToKeycode returns the wrong keycode for XK_Print and XK_Break. - // Specifically, it returns the code for SysReq instead of Print - // Only do this for the default Xorg layout, other keycode mappings - // (e.g. evdev) don't need or want it. - if( m_sym == XK_Print && !(m_mod & Mod1Mask) && - XKeycodeToKeysym( qt_xdisplay(), 111, 0 ) == XK_Print ) - m_code = 111; // code for Print - else if( m_sym == XK_Break || (m_sym == XK_Pause && (m_mod & ControlMask)) && - XKeycodeToKeysym( qt_xdisplay(), 114, 0 ) == XK_Pause ) - m_code = 114; - else - m_code = XKeysymToKeycode( qt_xdisplay(), m_sym ); - - if( !m_code && m_sym ) - kdDebug(125) << "Couldn't get code for sym" << endl; - // Now get the true sym formed by the modifiers - // E.g., Shift+Equal => Plus on the en layout. - if( key.modFlags() && ( ( m_sym < XK_Home || m_sym > XK_Begin ) && - m_sym != XK_Insert && m_sym != XK_Delete )) - KKeyServer::codeXToSym( m_code, m_mod, m_sym ); -#endif - return true; -} - -bool KKeyNative::init( const KKeyNative& key ) -{ - m_code = key.m_code; - m_mod = key.m_mod; - m_sym = key.m_sym; - return true; -} - -uint KKeyNative::code() const { return m_code; } -uint KKeyNative::mod() const { return m_mod; } -uint KKeyNative::sym() const { return m_sym; } - -bool KKeyNative::isNull() const -{ - return m_sym == 0; -} - -int KKeyNative::compare( const KKeyNative& key ) const -{ - if( m_sym != key.m_sym ) return m_sym - key.m_sym; - if( m_mod != key.m_mod ) return m_mod - key.m_mod; - if( m_code != key.m_code ) return m_code - key.m_code; - return 0; -} - -KKeyNative& KKeyNative::null() -{ - if( !gx_pkey ) - gx_pkey = new KKeyNative; - if( !gx_pkey->isNull() ) - gx_pkey->clear(); - return *gx_pkey; -} - -KKey KKeyNative::key() const -{ -#ifdef Q_WS_WIN - return KKey( m_sym, m_mod ); -#else - uint modSpec; - if( KKeyServer::modXToMod( m_mod, modSpec ) ) - return KKey( m_sym, modSpec ); - else - return KKey(); -#endif -} - -int KKeyNative::keyCodeQt() const -{ - int keyQt = KKeyServer::Sym(m_sym).qt(), modQt; - - if( keyQt != TQt::Key_unknown && KKeyServer::modXToModQt( m_mod, modQt ) ) - return keyQt | modQt; - - return 0; -} - -bool KKeyNative::keyboardHasWinKey() { return KKeyServer::keyboardHasWinKey(); } - -#ifdef Q_WS_X11 -uint KKeyNative::modX( KKey::ModFlag modFlag ) { return KKeyServer::modX( modFlag ); } -uint KKeyNative::accelModMaskX() { return KKeyServer::accelModMaskX(); } -uint KKeyNative::modXNumLock() { return KKeyServer::modXNumLock(); } -uint KKeyNative::modXLock() { return KKeyServer::modXLock(); } -uint KKeyNative::modXScrollLock() { return KKeyServer::modXScrollLock(); } -uint KKeyNative::modXModeSwitch() { return KKeyServer::modXModeSwitch(); } -#endif - -#endif // Q_WS_X11 diff --git a/kdecore/kkeyserver.h b/kdecore/kkeyserver.h deleted file mode 100644 index ef673ea9a..000000000 --- a/kdecore/kkeyserver.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2001 Ellis Whitehead <ellis@kde.org> - - Win32 port: - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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 _KKEYSERVER_H -#define _KKEYSERVER_H - -//FOR COMPATIBILITY -#include "kkeyserver_x11.h" - -#endif // !_KKEYSERVER_H diff --git a/kdecore/kkeyserver_x11.cpp b/kdecore/kkeyserver_x11.cpp deleted file mode 100644 index de7157210..000000000 --- a/kdecore/kkeyserver_x11.cpp +++ /dev/null @@ -1,1053 +0,0 @@ -/* - Copyright (C) 2001 Ellis Whitehead <ellis@kde.org> - - Win32 port: - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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. -*/ - -#include <config.h> - -#include <tqnamespace.h> -#include <tqwindowdefs.h> - -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MACX) // Only compile this module if we're compiling for X11, mac or win32 - -#include "kkeyserver_x11.h" -#include "kkeynative.h" -#include "kshortcut.h" - -#include <kconfig.h> -#include <kdebug.h> -#include <kglobal.h> -#include <klocale.h> - -#ifdef Q_WS_X11 -# define XK_MISCELLANY -# define XK_XKB_KEYS -# include <X11/X.h> -# include <X11/Xlib.h> -# include <X11/Xutil.h> -# include <X11/keysymdef.h> -# define X11_ONLY(arg) arg, //allows to omit an argument -#else -# include <kckey.h> -# define X11_ONLY(arg) -# define XK_ISO_Left_Tab Qt::Key_Backtab -# define XK_BackSpace Qt::Key_Backspace -# define XK_Sys_Req Qt::Key_SysReq -# define XK_Caps_Lock Qt::Key_CapsLock -# define XK_Num_Lock Qt::Key_NumLock -# define XK_Scroll_Lock Qt::Key_ScrollLock -# define XK_Prior Qt::Key_Prior -# define XK_Next Qt::Key_Next -#endif - -namespace KKeyServer -{ - -//--------------------------------------------------------------------- -// Data Structures -//--------------------------------------------------------------------- - -struct Mod -{ - int m_mod; -}; - -//--------------------------------------------------------------------- -// Array Structures -//--------------------------------------------------------------------- - -struct ModInfo -{ - KKey::ModFlag mod; - int modQt; -#ifdef Q_WS_X11 - uint modX; -#endif - const char* psName; - TQString sLabel; -}; - -struct SymVariation -{ - uint sym, symVariation; - bool bActive; -}; - -struct SymName -{ - uint sym; - const char* psName; -}; - -struct TransKey { - int keySymQt; - uint keySymX; -}; - -//--------------------------------------------------------------------- -// Arrays -//--------------------------------------------------------------------- - -static ModInfo g_rgModInfo[KKey::MOD_FLAG_COUNT] = -{ - { KKey::SHIFT, Qt::SHIFT, X11_ONLY(ShiftMask) I18N_NOOP("Shift"), TQString() }, - { KKey::CTRL, Qt::CTRL, X11_ONLY(ControlMask) I18N_NOOP("Ctrl"), TQString() }, - { KKey::ALT, Qt::ALT, X11_ONLY(Mod1Mask) I18N_NOOP("Alt"), TQString() }, - { KKey::WIN, KKey::QtWIN, X11_ONLY(Mod4Mask) I18N_NOOP("Win"), TQString() } -}; - -// Special Names List -static const SymName g_rgSymNames[] = { - { XK_ISO_Left_Tab, "Backtab" }, - { XK_BackSpace, I18N_NOOP("Backspace") }, - { XK_Sys_Req, I18N_NOOP("SysReq") }, - { XK_Caps_Lock, I18N_NOOP("CapsLock") }, - { XK_Num_Lock, I18N_NOOP("NumLock") }, - { XK_Scroll_Lock, I18N_NOOP("ScrollLock") }, - { XK_Prior, I18N_NOOP("PageUp") }, - { XK_Next, I18N_NOOP("PageDown") }, -#ifdef sun - { XK_F11, I18N_NOOP("Stop") }, - { XK_F12, I18N_NOOP("Again") }, - { XK_F13, I18N_NOOP("Props") }, - { XK_F14, I18N_NOOP("Undo") }, - { XK_F15, I18N_NOOP("Front") }, - { XK_F16, I18N_NOOP("Copy") }, - { XK_F17, I18N_NOOP("Open") }, - { XK_F18, I18N_NOOP("Paste") }, - { XK_F19, I18N_NOOP("Find") }, - { XK_F20, I18N_NOOP("Cut") }, - { XK_F22, I18N_NOOP("Print") }, -#endif - { 0, 0 } -}; - -#ifdef Q_WS_X11 -static SymVariation g_rgSymVariation[] = -{ - { '/', XK_KP_Divide, false }, - { '*', XK_KP_Multiply, false }, - { '-', XK_KP_Subtract, false }, - { '+', XK_KP_Add, false }, - { XK_Return, XK_KP_Enter, false }, - { 0, 0, false } -}; - -// TODO: Add Mac key names list: Key_Backspace => "Delete", Key_Delete => "Del" - -// These are the X equivalents to the Qt keycodes 0x1000 - 0x1026 -static const TransKey g_rgQtToSymX[] = -{ - { Qt::Key_Escape, XK_Escape }, - { Qt::Key_Tab, XK_Tab }, - { Qt::Key_Backtab, XK_ISO_Left_Tab }, - { Qt::Key_Backspace, XK_BackSpace }, - { Qt::Key_Return, XK_Return }, - { Qt::Key_Enter, XK_KP_Enter }, - { Qt::Key_Insert, XK_Insert }, - { Qt::Key_Delete, XK_Delete }, - { Qt::Key_Pause, XK_Pause }, -#ifdef sun - { Qt::Key_Print, XK_F22 }, -#else - { Qt::Key_Print, XK_Print }, -#endif - { Qt::Key_SysReq, XK_Sys_Req }, - { Qt::Key_Home, XK_Home }, - { Qt::Key_End, XK_End }, - { Qt::Key_Left, XK_Left }, - { Qt::Key_Up, XK_Up }, - { Qt::Key_Right, XK_Right }, - { Qt::Key_Down, XK_Down }, - { TQt::Key_Prior, XK_Prior }, - { TQt::Key_Next, XK_Next }, - //{ Qt::Key_Shift, 0 }, - //{ Qt::Key_Control, 0 }, - //{ Qt::Key_Meta, 0 }, - //{ Qt::Key_Alt, 0 }, - { Qt::Key_CapsLock, XK_Caps_Lock }, - { Qt::Key_NumLock, XK_Num_Lock }, - { Qt::Key_ScrollLock, XK_Scroll_Lock }, - { Qt::Key_F1, XK_F1 }, - { Qt::Key_F2, XK_F2 }, - { Qt::Key_F3, XK_F3 }, - { Qt::Key_F4, XK_F4 }, - { Qt::Key_F5, XK_F5 }, - { Qt::Key_F6, XK_F6 }, - { Qt::Key_F7, XK_F7 }, - { Qt::Key_F8, XK_F8 }, - { Qt::Key_F9, XK_F9 }, - { Qt::Key_F10, XK_F10 }, - { Qt::Key_F11, XK_F11 }, - { Qt::Key_F12, XK_F12 }, - { Qt::Key_F13, XK_F13 }, - { Qt::Key_F14, XK_F14 }, - { Qt::Key_F15, XK_F15 }, - { Qt::Key_F16, XK_F16 }, - { Qt::Key_F17, XK_F17 }, - { Qt::Key_F18, XK_F18 }, - { Qt::Key_F19, XK_F19 }, - { Qt::Key_F20, XK_F20 }, - { Qt::Key_F21, XK_F21 }, - { Qt::Key_F22, XK_F22 }, - { Qt::Key_F23, XK_F23 }, - { Qt::Key_F24, XK_F24 }, - { Qt::Key_F25, XK_F25 }, - { Qt::Key_F26, XK_F26 }, - { Qt::Key_F27, XK_F27 }, - { Qt::Key_F28, XK_F28 }, - { Qt::Key_F29, XK_F29 }, - { Qt::Key_F30, XK_F30 }, - { Qt::Key_F31, XK_F31 }, - { Qt::Key_F32, XK_F32 }, - { Qt::Key_F33, XK_F33 }, - { Qt::Key_F34, XK_F34 }, - { Qt::Key_F35, XK_F35 }, - { Qt::Key_Super_L, XK_Super_L }, - { Qt::Key_Super_R, XK_Super_R }, - { Qt::Key_Menu, XK_Menu }, - { Qt::Key_Hyper_L, XK_Hyper_L }, - { Qt::Key_Hyper_R, XK_Hyper_R }, - { Qt::Key_Help, XK_Help }, - //{ Qt::Key_Direction_L, XK_Direction_L }, These keys don't exist in X11 - //{ Qt::Key_Direction_R, XK_Direction_R }, - - { '/', XK_KP_Divide }, - { '*', XK_KP_Multiply }, - { '-', XK_KP_Subtract }, - { '+', XK_KP_Add }, - { Qt::Key_Return, XK_KP_Enter } -#if QT_VERSION >= 0x030100 - -// the next lines are taken from XFree > 4.0 (X11/XF86keysyms.h), defining some special -// multimedia keys. They are included here as not every system has them. -#define XF86XK_Standby 0x1008FF10 -#define XF86XK_AudioLowerVolume 0x1008FF11 -#define XF86XK_AudioMute 0x1008FF12 -#define XF86XK_AudioRaiseVolume 0x1008FF13 -#define XF86XK_AudioPlay 0x1008FF14 -#define XF86XK_AudioStop 0x1008FF15 -#define XF86XK_AudioPrev 0x1008FF16 -#define XF86XK_AudioNext 0x1008FF17 -#define XF86XK_HomePage 0x1008FF18 -#define XF86XK_Calculator 0x1008FF1D -#define XF86XK_Mail 0x1008FF19 -#define XF86XK_Start 0x1008FF1A -#define XF86XK_Search 0x1008FF1B -#define XF86XK_AudioRecord 0x1008FF1C -#define XF86XK_Back 0x1008FF26 -#define XF86XK_Forward 0x1008FF27 -#define XF86XK_Stop 0x1008FF28 -#define XF86XK_Refresh 0x1008FF29 -#define XF86XK_Favorites 0x1008FF30 -#define XF86XK_AudioPause 0x1008FF31 -#define XF86XK_AudioMedia 0x1008FF32 -#define XF86XK_MyComputer 0x1008FF33 -#define XF86XK_OpenURL 0x1008FF38 -#define XF86XK_Launch0 0x1008FF40 -#define XF86XK_Launch1 0x1008FF41 -#define XF86XK_Launch2 0x1008FF42 -#define XF86XK_Launch3 0x1008FF43 -#define XF86XK_Launch4 0x1008FF44 -#define XF86XK_Launch5 0x1008FF45 -#define XF86XK_Launch6 0x1008FF46 -#define XF86XK_Launch7 0x1008FF47 -#define XF86XK_Launch8 0x1008FF48 -#define XF86XK_Launch9 0x1008FF49 -#define XF86XK_LaunchA 0x1008FF4A -#define XF86XK_LaunchB 0x1008FF4B -#define XF86XK_LaunchC 0x1008FF4C -#define XF86XK_LaunchD 0x1008FF4D -#define XF86XK_LaunchE 0x1008FF4E -#define XF86XK_LaunchF 0x1008FF4F -// end of XF86keysyms.h - , - { Qt::Key_Standby, XF86XK_Standby }, - { Qt::Key_VolumeDown, XF86XK_AudioLowerVolume }, - { Qt::Key_VolumeMute, XF86XK_AudioMute }, - { Qt::Key_VolumeUp, XF86XK_AudioRaiseVolume }, - { Qt::Key_MediaPlay, XF86XK_AudioPlay }, - { Qt::Key_MediaStop, XF86XK_AudioStop }, - { TQt::Key_MediaPrev, XF86XK_AudioPrev }, - { Qt::Key_MediaNext, XF86XK_AudioNext }, - { Qt::Key_HomePage, XF86XK_HomePage }, - { Qt::Key_LaunchMail, XF86XK_Mail }, - { Qt::Key_Search, XF86XK_Search }, - { Qt::Key_MediaRecord, XF86XK_AudioRecord }, - { Qt::Key_LaunchMedia, XF86XK_AudioMedia }, - { Qt::Key_Launch1, XF86XK_Calculator }, - { Qt::Key_Back, XF86XK_Back }, - { Qt::Key_Forward, XF86XK_Forward }, - { Qt::Key_Stop, XF86XK_Stop }, - { Qt::Key_Refresh, XF86XK_Refresh }, - { Qt::Key_Favorites, XF86XK_Favorites }, - { Qt::Key_Launch0, XF86XK_MyComputer }, - { Qt::Key_OpenUrl, XF86XK_OpenURL }, - { Qt::Key_Launch2, XF86XK_Launch0 }, - { Qt::Key_Launch3, XF86XK_Launch1 }, - { Qt::Key_Launch4, XF86XK_Launch2 }, - { Qt::Key_Launch5, XF86XK_Launch3 }, - { Qt::Key_Launch6, XF86XK_Launch4 }, - { Qt::Key_Launch7, XF86XK_Launch5 }, - { Qt::Key_Launch8, XF86XK_Launch6 }, - { Qt::Key_Launch9, XF86XK_Launch7 }, - { Qt::Key_LaunchA, XF86XK_Launch8 }, - { Qt::Key_LaunchB, XF86XK_Launch9 }, - { Qt::Key_LaunchC, XF86XK_LaunchA }, - { Qt::Key_LaunchD, XF86XK_LaunchB }, - { Qt::Key_LaunchE, XF86XK_LaunchC }, - { Qt::Key_LaunchF, XF86XK_LaunchD }, -#endif -}; -#endif //Q_WS_X11 - -//--------------------------------------------------------------------- -// Initialization -//--------------------------------------------------------------------- -static bool g_bInitializedMods, g_bInitializedVariations, g_bInitializedKKeyLabels; -static bool g_bMacLabels; -#ifdef Q_WS_X11 -static uint g_modXNumLock, g_modXScrollLock, g_modXModeSwitch; - -bool initializeMods() -{ - XModifierKeymap* xmk = XGetModifierMapping( qt_xdisplay() ); - - g_rgModInfo[3].modX = g_modXNumLock = g_modXScrollLock = g_modXModeSwitch = 0; - - int min_keycode, max_keycode; - int keysyms_per_keycode = 0; - XDisplayKeycodes( qt_xdisplay(), &min_keycode, &max_keycode ); - XFree( XGetKeyboardMapping( qt_xdisplay(), min_keycode, 1, &keysyms_per_keycode )); - // Qt assumes that Alt is always Mod1Mask, so start at Mod2Mask. - for( int i = Mod2MapIndex; i < 8; i++ ) { - uint mask = (1 << i); - uint keySymX = NoSymbol; - // This used to be only XKeycodeToKeysym( ... , 0 ), but that fails with XFree4.3.99 - // and X.org R6.7 , where for some reason only ( ... , 1 ) works. I have absolutely no - // idea what the problem is, but searching all posibilities until something valid is - // found fixes the problem. - for( int j = 0; j < xmk->max_keypermod && keySymX == NoSymbol; ++j ) - for( int k = 0; k < keysyms_per_keycode && keySymX == NoSymbol; ++k ) - keySymX = XKeycodeToKeysym( qt_xdisplay(), xmk->modifiermap[xmk->max_keypermod * i + j], k ); - switch( keySymX ) { - case XK_Num_Lock: g_modXNumLock = mask; break; // Normally Mod2Mask - case XK_Super_L: - case XK_Super_R: g_rgModInfo[3].modX = mask; break; // Win key, Normally Mod4Mask - case XK_Meta_L: - case XK_Meta_R: if( !g_rgModInfo[3].modX ) g_rgModInfo[3].modX = mask; break; // Win alternate - case XK_Scroll_Lock: g_modXScrollLock = mask; break; // Normally Mod5Mask - case XK_Mode_switch: g_modXModeSwitch = mask; break; - } - } - - XFreeModifiermap( xmk ); - - //KConfigGroupSaver cgs( KGlobal::config(), "Keyboard" ); - // read in mod that win should be attached to - - g_bInitializedMods = true; - - kdDebug(125) << "KKeyServer::initializeMods(): Win Mod = 0x" << TQString::number(g_rgModInfo[3].modX, 16) << endl; - return true; -} - -static void initializeVariations() -{ - for( int i = 0; g_rgSymVariation[i].sym != 0; i++ ) - g_rgSymVariation[i].bActive = (XKeysymToKeycode( qt_xdisplay(), g_rgSymVariation[i].symVariation ) != 0); - g_bInitializedVariations = true; -} -#endif //Q_WS_X11 - -static void intializeKKeyLabels() -{ - KConfigGroupSaver cgs( KGlobal::config(), "Keyboard" ); - g_rgModInfo[0].sLabel = KGlobal::config()->readEntry( "Label Shift", i18n(g_rgModInfo[0].psName) ); - g_rgModInfo[1].sLabel = KGlobal::config()->readEntry( "Label Ctrl", i18n(g_rgModInfo[1].psName) ); - g_rgModInfo[2].sLabel = KGlobal::config()->readEntry( "Label Alt", i18n(g_rgModInfo[2].psName) ); - g_rgModInfo[3].sLabel = KGlobal::config()->readEntry( "Label Win", i18n(g_rgModInfo[3].psName) ); - g_bMacLabels = (g_rgModInfo[2].sLabel == "Command"); - g_bInitializedKKeyLabels = true; -} - -//--------------------------------------------------------------------- -// class Mod -//--------------------------------------------------------------------- - -/*void Mod::init( const TQString& s ) -{ - -}*/ - -//--------------------------------------------------------------------- -// class Sym -//--------------------------------------------------------------------- - -bool Sym::initQt( int keyQt ) -{ - int symQt = keyQt & 0xffff; - - if( (keyQt & Qt::UNICODE_ACCEL) || symQt < 0x1000 ) { - m_sym = TQChar(symQt).lower().tqunicode(); - return true; - } - -#ifdef Q_WS_WIN - m_sym = symQt; - return true; -#elif defined(Q_WS_X11) - for( uint i = 0; i < sizeof(g_rgQtToSymX)/sizeof(TransKey); i++ ) { - if( g_rgQtToSymX[i].keySymQt == symQt ) { - m_sym = g_rgQtToSymX[i].keySymX; - return true; - } - } - - m_sym = 0; - if( symQt != Qt::Key_Shift && symQt != Qt::Key_Control && symQt != Qt::Key_Alt && - symQt != Qt::Key_Meta && symQt != Qt::Key_Direction_L && symQt != Qt::Key_Direction_R ) - kdDebug(125) << "Sym::initQt( " << TQString::number(keyQt,16) << " ): failed to convert key." << endl; - return false; -#elif defined(Q_WS_MACX) - m_sym = symQt; - return true; -#endif -} - -bool Sym::init( const TQString& s ) -{ - // If it's a single character, get tqunicode value. - if( s.length() == 1 ) { - m_sym = s[0].lower().tqunicode(); - return true; - } - - // Look up in special names list - for( int i = 0; g_rgSymNames[i].sym != 0; i++ ) { - if( qstricmp( s.latin1(), g_rgSymNames[i].psName ) == 0 ) { - m_sym = g_rgSymNames[i].sym; - return true; - } - } - -#ifdef Q_WS_WIN - // search for name in KKeys array - for ( KKeys const *pKey = kde_KKEYS; pKey->code != 0xffff; pKey++) { - if( qstricmp( s.latin1(), pKey->name ) == 0 ) { - m_sym = pKey->code; - return true; - } - } - m_sym = 0; -#elif defined(Q_WS_X11) - // search X list: 's' as is, all lower, first letter in caps - m_sym = XStringToKeysym( s.latin1() ); - if( !m_sym ) { - m_sym = XStringToKeysym( s.lower().latin1() ); - if( !m_sym ) { - TQString s2 = s; - s2[0] = s2[0].upper(); - m_sym = XStringToKeysym( s2.latin1() ); - } - } -#endif - return m_sym != 0; -} - -int Sym::qt() const -{ - if( m_sym < 0x1000 ) { - if( m_sym >= 'a' && m_sym <= 'z' ) - return TQChar(m_sym).upper(); - return m_sym; - } -#ifdef Q_WS_WIN - if( m_sym < 0x3000 ) - return m_sym; -#elif defined(Q_WS_X11) - if( m_sym < 0x3000 ) - return m_sym | Qt::UNICODE_ACCEL; - - for( uint i = 0; i < sizeof(g_rgQtToSymX)/sizeof(TransKey); i++ ) - if( g_rgQtToSymX[i].keySymX == m_sym ) - return g_rgQtToSymX[i].keySymQt; -#endif - return TQt::Key_unknown; -} - -TQString Sym::toString( bool bUserSpace ) const -{ - if( m_sym == 0 ) - return TQString::null; - - // If it's a tqunicode character, -#ifdef Q_WS_WIN - else if( m_sym < 0x1000 ) { -#else - else if( m_sym < 0x3000 ) { -#endif - TQChar c = TQChar(m_sym).upper(); - // Print all non-space characters directly when output is user-visible. - // Otherwise only print alphanumeric latin1 characters directly (A,B,C,1,2,3). - if( (c.latin1() && c.isLetterOrNumber()) - || (bUserSpace && !c.isSpace()) ) - return c; - } - - // Look up in special names list - for( int i = 0; g_rgSymNames[i].sym != 0; i++ ) { - if( m_sym == g_rgSymNames[i].sym ) - return bUserSpace ? i18n(g_rgSymNames[i].psName) : TQString(g_rgSymNames[i].psName); - } - - TQString s; -#ifdef Q_WS_WIN - s = TQKeySequence( m_sym ); -#elif defined(Q_WS_X11) - // Get X-name - s = XKeysymToString( m_sym ); -#endif - capitalizeKeyname( s ); - return bUserSpace ? i18n(TQACCEL_OBJECT_NAME_STRING, s.latin1()) : s; -} - -TQString Sym::toStringInternal() const { return toString( false ); } -TQString Sym::toString() const { return toString( true ); } - -uint Sym::getModsRequired() const -{ - uint mod = 0; -#ifdef Q_WS_X11 - // FIXME: This might not be true on all keyboard layouts! - if( m_sym == XK_Sys_Req ) return KKey::ALT; - if( m_sym == XK_Break ) return KKey::CTRL; - - if( m_sym < 0x3000 ) { - TQChar c(m_sym); - if( c.isLetter() && c.lower() != c.upper() && m_sym == c.upper().tqunicode() ) - return KKey::SHIFT; - } - - uchar code = XKeysymToKeycode( qt_xdisplay(), m_sym ); - if( code ) { - // need to check index 0 before the others, so that a null-mod - // can take precedence over the others, in case the modified - // key produces the same symbol. - if( m_sym == XKeycodeToKeysym( qt_xdisplay(), code, 0 ) ) - ; - else if( m_sym == XKeycodeToKeysym( qt_xdisplay(), code, 1 ) ) - mod = KKey::SHIFT; - else if( m_sym == XKeycodeToKeysym( qt_xdisplay(), code, 2 ) ) - mod = KKeyServer::MODE_SWITCH; - else if( m_sym == XKeycodeToKeysym( qt_xdisplay(), code, 3 ) ) - mod = KKey::SHIFT | KKeyServer::MODE_SWITCH; - } -#endif - return mod; -} - -uint Sym::getSymVariation() const -{ -#ifdef Q_WS_X11 - if( !g_bInitializedVariations ) - initializeVariations(); - for( int i = 0; g_rgSymVariation[i].sym != 0; i++ ) - if( g_rgSymVariation[i].sym == m_sym && g_rgSymVariation[i].bActive ) - return g_rgSymVariation[i].symVariation; -#endif - return 0; -} - -void Sym::capitalizeKeyname( TQString& s ) -{ - s[0] = s[0].upper(); - int len = s.length(); - if( s.endsWith( "left" ) ) s[len-4] = 'L'; - else if( s.endsWith( "right" ) ) s[len-5] = 'R'; - else if( s == "Sysreq" ) s[len-3] = 'R'; -} - -//--------------------------------------------------------------------- -// Public functions -//--------------------------------------------------------------------- - -#ifdef Q_WS_X11 -uint modX( KKey::ModFlag mod ) -{ - if( mod == KKey::WIN && !g_bInitializedMods ) - initializeMods(); - - for( uint i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) { - if( g_rgModInfo[i].mod == mod ) - return g_rgModInfo[i].modX; - } - return 0; -} - -bool keyboardHasWinKey() { if( !g_bInitializedMods ) { initializeMods(); } return g_rgModInfo[3].modX != 0; } -uint modXShift() { return ShiftMask; } -uint modXLock() { return LockMask; } -uint modXCtrl() { return ControlMask; } -uint modXAlt() { return Mod1Mask; } -uint modXNumLock() { if( !g_bInitializedMods ) { initializeMods(); } return g_modXNumLock; } -uint modXWin() { if( !g_bInitializedMods ) { initializeMods(); } return g_rgModInfo[3].modX; } -uint modXScrollLock() { if( !g_bInitializedMods ) { initializeMods(); } return g_modXScrollLock; } -uint modXModeSwitch() { if( !g_bInitializedMods ) { initializeMods(); } return g_modXModeSwitch; } - -uint accelModMaskX() -{ - if( !g_bInitializedMods ) - initializeMods(); - return ShiftMask | ControlMask | Mod1Mask | g_rgModInfo[3].modX; -} -#endif //Q_WS_X11 - -bool keyQtToSym( int keyQt, uint& keySym ) -{ - Sym sym; - if( sym.initQt( keyQt ) ) { - keySym = sym.m_sym; - return true; - } else - return false; -} - -bool keyQtToMod( int keyQt, uint& mod ) -{ - mod = 0; - - if( keyQt & Qt::SHIFT ) mod |= KKey::SHIFT; - if( keyQt & Qt::CTRL ) mod |= KKey::CTRL; - if( keyQt & Qt::ALT ) mod |= KKey::ALT; - if( keyQt & Qt::META ) mod |= KKey::WIN; - - return true; -} - -bool symToKeyQt( uint keySym, int& keyQt ) -{ - Sym sym( keySym ); - keyQt = sym.qt(); - return (keyQt != TQt::Key_unknown); -} - -bool modToModQt( uint mod, int& modQt ) -{ - modQt = 0; - for( int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) { - if( mod & g_rgModInfo[i].mod ) { - if( !g_rgModInfo[i].modQt ) { - modQt = 0; - return false; - } - modQt |= g_rgModInfo[i].modQt; - } - } - return true; -} - -#ifdef Q_WS_WIN -//wrapped -bool modXToModQt( uint modX, int& modQt ) -{ - return modToModQt( modX, modQt ); -} - -KDECORE_EXPORT int qtButtonStateToMod( TQt::ButtonState s ) -{ - int modQt = 0; - if (s & Qt::ShiftButton) modQt |= KKey::SHIFT; - if (s & Qt::ControlButton) modQt |= KKey::CTRL; - if (s & Qt::AltButton) modQt |= KKey::ALT; - return modQt; -} - -bool keyboardHasWinKey() { -//! TODO - return true; -} - -#elif defined(Q_WS_MACX) - -bool modXToModQt(uint modX, int& modQt) -{ - return modToModQt( modX, modQt ); -} - -bool keyboardHasWinKey() { -//! TODO - A win key on the Mac...? - return false; -} - -bool modXToMod( uint , uint& ) -{ - return false; -} -#elif defined(Q_WS_X11) - -bool modToModX( uint mod, uint& modX ) -{ - if( !g_bInitializedMods ) - initializeMods(); - - modX = 0; - for( int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) { - if( mod & g_rgModInfo[i].mod ) { - if( !g_rgModInfo[i].modX ) { - kdDebug(125) << "Invalid modifier flag." << endl; - modX = 0; - return false; - } - modX |= g_rgModInfo[i].modX; - } - } - // TODO: document 0x2000 flag - if( mod & 0x2000 ) - modX |= 0x2000; - return true; -} - -bool modXToModQt( uint modX, int& modQt ) -{ - if( !g_bInitializedMods ) - initializeMods(); - - modQt = 0; - for( int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) { - if( modX & g_rgModInfo[i].modX ) { - if( !g_rgModInfo[i].modQt ) { - modQt = 0; - return false; - } - modQt |= g_rgModInfo[i].modQt; - } - } - return true; -} - -bool modXToMod( uint modX, uint& mod ) -{ - if( !g_bInitializedMods ) - initializeMods(); - - mod = 0; - for( int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) { - if( modX & g_rgModInfo[i].modX ) - mod |= g_rgModInfo[i].mod; - } - return true; -} - -bool codeXToSym( uchar codeX, uint modX, uint& sym ) -{ - KeySym keySym; - XKeyPressedEvent event; - - event.type = KeyPress; - event.display = qt_xdisplay(); - event.state = modX; - event.keycode = codeX; - - char buffer[64]; - XLookupString( &event, buffer, 63, &keySym, NULL ); - sym = (uint) keySym; - return true; -} -#endif //!Q_WS_WIN - -static TQString modToString( uint mod, bool bUserSpace ) -{ - if( bUserSpace && !g_bInitializedKKeyLabels ) - intializeKKeyLabels(); - - TQString s; - for( int i = KKey::MOD_FLAG_COUNT-1; i >= 0; i-- ) { - if( mod & g_rgModInfo[i].mod ) { - if( !s.isEmpty() ) - s += '+'; - s += (bUserSpace) - ? g_rgModInfo[i].sLabel - : TQString(g_rgModInfo[i].psName); - } - } - return s; -} - -TQString modToStringInternal( uint mod ) { return modToString( mod, false ); } -TQString modToStringUser( uint mod ) { return modToString( mod, true ); } - -uint stringUserToMod( const TQString& mod ) -{ - if( !g_bInitializedKKeyLabels ) - intializeKKeyLabels(); - - TQString s; - for( int i = KKey::MOD_FLAG_COUNT-1; i >= 0; i-- ) { - if( mod.lower() == g_rgModInfo[i].sLabel.lower()) - return g_rgModInfo[i].mod; - } - return 0; -} - -/*void keySymModToKeyX( uint sym, uint mod, unsigned char *pKeyCodeX, uint *pKeySymX, uint *pKeyModX ) -{ -... - uint keySymQt; - uint keySymX = 0; - unsigned char keyCodeX = 0; - uint keyModX = 0; - - const char *psKeySym = 0; - - if( !g_bInitialized ) - Initialize(); - - // Get code of just the primary key - keySymQt = keyCombQt & 0xffff; - - // If tqunicode value beneath 0x1000 (special Qt codes begin thereafter), - if( keySymQt < 0x1000 ) { - // For reasons unbeknownst to me, Qt converts 'a-z' to 'A-Z'. - // So convert it back to lowercase if SHIFT isn't held down. - if( keySymQt >= Qt::Key_A && keySymQt <= Qt::Key_Z && !(keyCombQt & Qt::SHIFT) ) - keySymQt = tolower( keySymQt ); - keySymX = keySymQt; - } - // Else, special key (e.g. Delete, F1, etc.) - else { - for( int i = 0; i < NB_KEYS; i++ ) { - if( keySymQt == (uint) KKEYS[i].code ) { - psKeySym = KKEYS[i].name; - //kdDebug(125) << " symbol found: \"" << psKeySym << "\"" << endl; - break; - } - } - - // Get X key symbol. Only works if Qt name is same as X name. - if( psKeySym ) { - TQString sKeySym = psKeySym; - - // Check for lower-case equalent first because most - // X11 names are all lower-case. - keySymX = XStringToKeysym( sKeySym.lower().ascii() ); - if( keySymX == 0 ) - keySymX = XStringToKeysym( psKeySym ); - } - - if( keySymX == 0 ) - keySymX = getSymXEquiv( keySymQt ); - } - - if( keySymX != 0 ) { - // Get X keyboard code - keyCodeX = XKeysymToKeycode( qt_xdisplay(), keySymX ); - // Add ModeSwitch modifier bit, if necessary - keySymXMods( keySymX, 0, &keyModX ); - - // Get X modifier flags - for( int i = 0; i < MOD_KEYS; i++ ) { - if( keyCombQt & g_aModKeys[i].keyModMaskQt ) { - if( g_aModKeys[i].keyModMaskX ) - keyModX |= g_aModKeys[i].keyModMaskX; - // Qt key calls for a modifier which the current - // X modifier map doesn't support. - else { - keySymX = 0; - keyCodeX = 0; - keyModX = 0; - break; - } - } - } - } - - // Take care of complications: - // The following keys will not have been correctly interpreted, - // because their shifted values are not activated with the - // Shift key, but rather something else. They are also - // defined twice under different keycodes. - // keycode 111 & 92: Print Sys_Req -> Sys_Req = Alt+Print - // keycode 110 & 114: Pause Break -> Break = Ctrl+Pause - if( (keyCodeX == 92 || keyCodeX == 111) && - XKeycodeToKeysym( qt_xdisplay(), 92, 0 ) == XK_Print && - XKeycodeToKeysym( qt_xdisplay(), 111, 0 ) == XK_Print ) - { - // If Alt is pressed, then we need keycode 92, keysym XK_Sys_Req - if( keyModX & keyModXAlt() ) { - keyCodeX = 92; - keySymX = XK_Sys_Req; - } - // Otherwise, keycode 111, keysym XK_Print - else { - keyCodeX = 111; - keySymX = XK_Print; - } - } - else if( (keyCodeX == 110 || keyCodeX == 114) && - XKeycodeToKeysym( qt_xdisplay(), 110, 0 ) == XK_Pause && - XKeycodeToKeysym( qt_xdisplay(), 114, 0 ) == XK_Pause ) - { - if( keyModX & keyModXCtrl() ) { - keyCodeX = 114; - keySymX = XK_Break; - } else { - keyCodeX = 110; - keySymX = XK_Pause; - } - } - - if( pKeySymX ) *pKeySymX = keySymX; - if( pKeyCodeX ) *pKeyCodeX = keyCodeX; - if( pKeyModX ) *pKeyModX = keyModX; -}*/ - -//--------------------------------------------------------------------- -// Key -//--------------------------------------------------------------------- - -bool Key::init( const KKey& key, bool bQt ) -{ - if( bQt ) { - m_code = CODE_FOR_QT; - m_sym = key.keyCodeQt(); - } else { - KKeyNative keyNative( key ); - *this = keyNative; - } - return true; -} - -KKey Key::key() const -{ - if( m_code == CODE_FOR_QT ) - return KKey( keyCodeQt() ); - else { -#if defined(Q_WS_WIN) || defined(Q_WS_MACX) - return KKey(); -#else - uint mod; - modXToMod( m_mod, mod ); - return KKey( m_sym, mod ); -#endif - } -} - -Key& Key::operator =( const KKeyNative& key ) -{ - m_code = key.code(); m_mod = key.mod(); m_sym = key.sym(); - return *this; -} - -int Key::compare( const Key& b ) const -{ - if( m_code == CODE_FOR_QT ) - return m_sym - b.m_sym; - if( m_sym != b.m_sym ) return m_sym - b.m_sym; - if( m_mod != b.m_mod ) return m_mod - b.m_mod; - return m_code - b.m_code; -} - -//--------------------------------------------------------------------- -// Variations -//--------------------------------------------------------------------- - -// TODO: allow for sym to have variations, such as Plus => { Plus, KP_Add } -void Variations::init( const KKey& key, bool bQt ) -{ - if( key.isNull() ) { - m_nVariations = 0; - return; - } - - m_nVariations = 1; - m_rgkey[0] = KKeyNative(key); - uint symVar = Sym(key.sym()).getSymVariation(); - if( symVar ) { - uint modReq = Sym(m_rgkey[0].sym()).getModsRequired(); - uint modReqVar = Sym(symVar).getModsRequired(); - // If 'key' doesn't require any mods that are inherent in - // the primary key but not required for the alternate, - if( (key.modFlags() & modReq) == (key.modFlags() & modReqVar) ) { - m_rgkey[1] = KKeyNative(KKey(symVar, key.modFlags())); - m_nVariations = 2; - } - } - - if( bQt ) { - uint nVariations = 0; - for( uint i = 0; i < m_nVariations; i++ ) { - int keyQt = KKeyNative( m_rgkey[i].code(), m_rgkey[i].mod(), m_rgkey[i].sym() ).keyCodeQt(); - if( keyQt ) - m_rgkey[nVariations++].setKeycodeQt( keyQt ); - } - m_nVariations = nVariations; - - // Two different native codes may produce a single - // Qt code. Search for duplicates. - for( uint i = 1; i < m_nVariations; i++ ) { - for( uint j = 0; j < i; j++ ) { - // If key is already present in list, then remove it. - if( m_rgkey[i].keyCodeQt() == m_rgkey[j].keyCodeQt() ) { - for( uint k = i; k < m_nVariations - 1; k++ ) - m_rgkey[k].setKeycodeQt( m_rgkey[k+1].keyCodeQt() ); - m_nVariations--; - i--; - break; - } - } - } - } -} - -} // end of namespace KKeyServer block - -// FIXME: This needs to be moved to kshortcut.cpp, and create a -// KKeyServer::method which it will call. -// Alt+SysReq => Alt+Print -// Ctrl+Shift+Plus => Ctrl+Plus (en) -// Ctrl+Shift+Equal => Ctrl+Plus -// Ctrl+Pause => Ctrl+Break -void KKey::simplify() -{ -#ifdef Q_WS_X11 - if( m_sym == XK_Sys_Req ) { - m_sym = XK_Print; - m_mod |= ALT; - } else if( m_sym == XK_ISO_Left_Tab ) { - m_sym = XK_Tab; - m_mod |= SHIFT; - } else { - // Shift+Equal => Shift+Plus (en) - m_sym = KKeyNative(*this).sym(); - } - - // If this is a letter, don't remove any modifiers. - if( m_sym < 0x3000 && TQChar(m_sym).isLetter() ) - m_sym = TQChar(m_sym).lower().tqunicode(); - - // Remove modifers from modifier list which are implicit in the symbol. - // Ex. Shift+Plus => Plus (en) - m_mod &= ~KKeyServer::Sym(m_sym).getModsRequired(); -#endif -} - -#endif //Q_WS_X11 || Q_WS_WIN - diff --git a/kdecore/kkeyserver_x11.h b/kdecore/kkeyserver_x11.h deleted file mode 100644 index 7935c0ce4..000000000 --- a/kdecore/kkeyserver_x11.h +++ /dev/null @@ -1,477 +0,0 @@ -/* - Copyright (C) 2001 Ellis Whitehead <ellis@kde.org> - - Win32 port: - Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl> - - 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 _KKEYSERVER_X11_H -#define _KKEYSERVER_X11_H - -#include "kshortcut.h" -#include "kkeynative.h" - -/** - * A collection of functions for the conversion of key presses and - * their modifiers from the window system specific format - * to the generic format and vice-versa. - */ -namespace KKeyServer -{ - /** - * Supplement enum KKey::ModFlag - * @since 3.1 - */ - enum ExtraModFlag { MODE_SWITCH = 0x2000 }; - - /** - * Represents a key symbol. - * @see KKey - * @see KKeyServer - */ - struct KDECORE_EXPORT Sym - { - public: - /// the actual value of the symbol - uint m_sym; - - /// Creates a null symbol. - Sym() - { m_sym = 0; } - /** - * Creates asymbol with the given value. - * @param sym the value - */ - Sym( uint sym ) - { m_sym = sym; } - /** - * Creates a symbol from the given string description. - * @param s the description of the symbol - * @see toString() - */ - Sym( const TQString& s ) - { init( s ); } - - /** - * Initializes the symbol with the given Qt key code. - * @param keyQt the qt key code - * @return true if successful, false otherwise - * @see Qt::Key - */ - bool initQt( int keyQt ); - - /** - * Initializes the key with the given string description. - * @param s the string description - * @return true if successful, false otherwise - * @see toString() - */ - bool init( const TQString &s ); - - /** - * Returns the qt key code of the symbol. - * @return the qt key code - */ - int qt() const; - - /** - * @internal - */ - TQString toStringInternal() const; - - /** - * Returns the string representation of the symbol. - * @return the string representation of the symbol - */ - TQString toString() const; - - /** - * Returns the mods that are required for this symbol as - * ORed KKey::ModFlag's. For example, Break requires a - * Ctrl to be valid. - * @return the required KKey::ModFlag's - * @see KKey::ModFlag - */ - uint getModsRequired() const; - - /** - * TODO: please find out what this method does and document it - */ - uint getSymVariation() const; - - /** - * Casts the symbol to its integer representation. - */ - operator uint() const { return m_sym; } - - /** - * Overloaded operator to convert ints to Sym. - */ - Sym& operator =( uint sym ) { m_sym = sym; return *this; } - - private: - TQString toString( bool bUserSpace ) const; - - static void capitalizeKeyname( TQString& ); - }; - - /** - * Represents a key press. - * @see KKey - */ - struct KDECORE_EXPORT Key - { - /// Code for native Keys in Qt - enum { CODE_FOR_QT = 256 }; - - /// The code of the key - uint m_code; - - /// The modifiers of the key - uint m_mod; - - /// The symbol of the key - uint m_sym; - - /** - * Initializes the key with a KKey. - * @param key the key to get the data from - * @param bQt true to take the Qt keycode, false - * for the native key code - * @see Qt::Key - * @see KKeyNative - */ - bool init( const KKey& key, bool bQt ); - - /** - * Checks whether the key code is a native code. - * @return true if native code of the window system, - * false if it is a Qt keycode - * @see Qt::Key - * @see KKeyNative - */ - bool isNative() const { return m_code != CODE_FOR_QT; } - - /** - * Returns the code of the key. - * @return the code of the key - */ - uint code() const { return m_code; } - - /** - * Returns the modifiers of the key. - * @return the modifiers of the key - */ - uint mod() const { return m_mod; } - - /** - * Returns the symbol of the key. - * @return the symbol of the key - */ - uint sym() const { return m_sym; } - - /** - * Returns the qt key code. - * @return the qt key code - */ - int keyCodeQt() const { return (int) m_sym; } - - /** - * Sets the qt key code. - * @param keyQt the qt key code - */ - void setKeycodeQt( int keyQt ) - { m_code = CODE_FOR_QT; m_sym = keyQt; } - - /** - * Initializes this key with a KKeyNative. - * @return this key - */ - Key& operator =( const KKeyNative& key ); - - /** - * Compares this key with the given Key object. Returns a - * negative number if the given Key is larger, 0 if they - * are equal and a positive number this Key is larger. The - * returned value is the difference between the symbol, modifier - * or code, whatever is non-zero first. - * - * @param key the key to compare with this key - * @return a negative number if the given Key is larger, 0 if - * they are equal and a positive number this Key is larger - */ - int compare( const Key& key ) const; - - /** - * Compares the symbol, modifiers and code of both keys. - * @see compare() - */ - bool operator ==( const Key& b ) const - { return compare( b ) == 0; } - - /** - * Compares the symbol, modifiers and code of both keys. - * @see compare() - */ - bool operator <( const Key& b ) const - { return compare( b ) < 0; } - - /** - * Converts this Key to a KKey. - * @return the KKey - */ - KKey key() const; - }; - - /** - * TODO: please document this class - */ - struct KDECORE_EXPORT Variations - { - enum { MAX_VARIATIONS = 4 }; - - Key m_rgkey[MAX_VARIATIONS]; - uint m_nVariations; - - Variations() { m_nVariations = 0; } - - void init( const KKey&, bool bQt ); - - uint count() const { return m_nVariations; } - const Key& key( uint i ) const { return m_rgkey[i]; } - }; - - /// TODO: please document - KDECORE_EXPORT bool initializeMods(); - - /** - * Returns the equivalent X modifier mask of the given modifier flag. - * @param modFlag the generic flags to check - * @return the window system specific flags - */ - KDECORE_EXPORT uint modX( KKey::ModFlag modFlag ); - - /** - * Returns true if the current keyboard layout supports the Win key. - * Specifically, whether the Super or Meta keys are assigned to an X modifier. - * @return true if the keyboard has a Win key - * @see modXWin() - */ - KDECORE_EXPORT bool keyboardHasWinKey(); - - /** - * Returns the X11 Shift modifier mask/flag. - * @return the X11 Shift modifier mask/flag. - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXShift(); - - /** - * Returns the X11 Lock modifier mask/flag. - * @return the X11 Lock modifier mask/flag. - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXLock(); - - /** - * Returns the X11 Ctrl modifier mask/flag. - * @return the X11 Ctrl modifier mask/flag. - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXCtrl(); - - /** - * Returns the X11 Alt (Mod1) modifier mask/flag. - * @return the X11 Alt (Mod1) modifier mask/flag. - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXAlt(); - - /** - * Returns the X11 NumLock modifier mask/flag. - * @return the X11 NumLock modifier mask/flag. - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXNumLock(); - - /** - * Returns the X11 Win (Mod3) modifier mask/flag. - * @return the X11 Win (Mod3) modifier mask/flag. - * @see keyboardHasWinKey() - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXWin(); - - /** - * Returns the X11 ScrollLock modifier mask/flag. - * @return the X11 ScrollLock modifier mask/flag. - * @see accelModMaskX() - */ - KDECORE_EXPORT uint modXScrollLock(); - - /** - * Returns the X11 Mode_switch modifier mask/flag. - * @return the X11 Mode_switch modifier mask/flag. - * @see accelModMaskX() - * @since 3.5 - */ - KDECORE_EXPORT uint modXModeSwitch(); - - /** - * Returns bitwise OR'ed mask containing Shift, Ctrl, Alt, and - * Win (if available). - * @see modXShift() - * @see modXLock() - * @see modXCtrl() - * @see modXAlt() - * @see modXNumLock() - * @see modXWin() - * @see modXScrollLock() - */ - KDECORE_EXPORT uint accelModMaskX(); - - /** - * Extracts the symbol from the given Qt key and - * converts it to a symbol. - * @param keyQt the qt key code - * @param sym if successful, the symbol will be written here - * @return true if successful, false otherwise - * @see Qt::Key - * @see Sym - */ - KDECORE_EXPORT bool keyQtToSym( int keyQt, uint& sym ); - - /** - * Extracts the modifiers from the given Qt key and - * converts them in a mask of ORed KKey::ModFlag modifiers. - * @param keyQt the qt key code - * @param mod if successful, the modifiers will be written here - * @return true if successful, false otherwise - * @see Qt::Key - */ - KDECORE_EXPORT bool keyQtToMod( int keyQt, uint& mod ); - - /** - * Converts the given symbol to a Qt key code. - * @param sym the symbol - * @param keyQt if successful, the qt key code will be written here - * @return true if successful, false otherwise - * @see Qt::Key - * @see Sym - */ - KDECORE_EXPORT bool symToKeyQt( uint sym, int& keyQt ); - - /** - * Converts the mask of ORed KKey::ModFlag modifiers to - * a mask of ORed Qt key code modifiers. - * @param mod the mask of KKey::ModFlag modifiers - * @param modQt the mask of Qt key code modifiers will be written here, - * if successful - * @return true if successful, false otherwise - * @see Qt::Key - * @see KKey - */ - KDECORE_EXPORT bool modToModQt( uint mod, int& modQt ); - - /** - * Converts the mask of ORed KKey::ModFlag modifiers to - * a mask of ORed X11 modifiers. - * @param mod the mask of KKey::ModFlag modifiers - * @param modX the mask of X11 modifiers will be written here, - * if successful - * @return true if successful, false otherwise - * @see KKey - */ - KDECORE_EXPORT bool modToModX( uint mod, uint& modX ); - - /** - * Converts the mask of ORed X11 modifiers to - * a mask of ORed Qt key code modifiers. - * @param modX the mask of X11 modifiers - * @param modQt the mask of Qt key code modifiers will be written here - * if successful - * @return true if successful, false otherwise - * @see Qt::Key - */ - //wrapped for win32 - KDECORE_EXPORT bool modXToModQt( uint modX, int& modQt ); - - /** - * Converts the Qt-compatible button state to x11 modifier. - */ - KDECORE_EXPORT int qtButtonStateToMod( TQ_ButtonState s ); - - /** - * Converts the mask of ORed X11 modifiers to - * a mask of ORed KKey::ModFlag modifiers. - * @param modX the mask of X11 modifiers - * @param mod the mask of KKey::ModFlag modifiers will be written here, - * if successful - * @return true if successful, false otherwise - * @see KKey - */ - KDECORE_EXPORT bool modXToMod( uint modX, uint& mod ); - - /** - * Converts a X11 key code and a mask of ORed X11 modifiers - * into a X11 symbol. - * converts it to a symbol. - * @param codeX the X11 key code - * @param modX the mask of ORed X11 modifiers - * @param symX if successful, the X11 symbol will be written here - * @return true if successful, false otherwise - * @see Qt::Key - * @see Sym - */ - KDECORE_EXPORT bool codeXToSym( uchar codeX, uint modX, uint& symX ); - - /** - * @internal - */ - KDECORE_EXPORT TQString modToStringInternal( uint mod ); - - /** - * Converts the mask of ORed KKey::ModFlag modifiers to a - * user-readable string. - * @param mod the mask of ORed KKey::ModFlag modifiers - * @return the user-readable string - */ - KDECORE_EXPORT TQString modToStringUser( uint mod ); - - /** - * Converts the modifier given as user-readable string - * to KKey::ModFlag modifier, or 0. - * @internal - * @since 3.5 - */ - KDECORE_EXPORT uint stringUserToMod( const TQString& mod ); - - /** - * @internal - * Unimplemented? - */ - KDECORE_EXPORT bool stringToSymMod( const TQString&, uint& sym, uint& mod ); - - /** - * @internal - * Unimplemented? - */ - KDECORE_EXPORT void keyQtToKeyX( uint keyCombQt, unsigned char *pKeyCodeX, uint *pKeySymX, uint *pKeyModX ); -} - -#endif // !_KKEYSERVER_X11_H diff --git a/kdecore/klargefile.h b/kdecore/klargefile.h deleted file mode 100644 index 2eb6bfa22..000000000 --- a/kdecore/klargefile.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2001 Waldo Bastian <bastian@kde.org> - - 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 _KDE_LARGEFILE_H_ -#define _KDE_LARGEFILE_H_ - -/* TODO: remove this file in KDE4 */ - -#include <kde_file.h> - -#endif diff --git a/kdecore/klibloader.cpp b/kdecore/klibloader.cpp deleted file mode 100644 index 290e23154..000000000 --- a/kdecore/klibloader.cpp +++ /dev/null @@ -1,580 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - Copyright (C) 2000 Michael Matz <matz@kde.org> - - 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 <config.h> -#include <tqclipboard.h> -#include <tqfile.h> -#include <tqdir.h> -#include <tqtimer.h> -#include <tqobjectdict.h> - -#include "kapplication.h" -#include "klibloader.h" -#include "kstandarddirs.h" -#include "kdebug.h" -#include "klocale.h" - -#include "ltdl.h" - -template class TQAsciiDict<KLibrary>; - -#include <stdlib.h> //getenv - - -#if HAVE_DLFCN_H -# include <dlfcn.h> -#endif - -#ifdef RTLD_GLOBAL -# define LT_GLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_GLOBAL DL_GLOBAL -# endif -#endif /* !RTLD_GLOBAL */ -#ifndef LT_GLOBAL -# define LT_GLOBAL 0 -#endif /* !LT_GLOBAL */ - - -class KLibLoaderPrivate -{ -public: - TQPtrList<KLibWrapPrivate> loaded_stack; - TQPtrList<KLibWrapPrivate> pending_close; - enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; - - TQString errorMessage; -}; - -KLibLoader* KLibLoader::s_self = 0; - -// ------------------------------------------------------------------------- - -KLibFactory::KLibFactory( TQObject* parent, const char* name ) - : TQObject( parent, name ) -{ -} - -KLibFactory::~KLibFactory() -{ -// kdDebug(150) << "Deleting KLibFactory " << this << endl; -} - -TQObject* KLibFactory::create( TQObject* parent, const char* name, const char* classname, const TQStringList &args ) -{ - TQObject* obj = createObject( parent, name, classname, args ); - if ( obj ) - emit objectCreated( obj ); - return obj; -} - - -TQObject* KLibFactory::createObject( TQObject*, const char*, const char*, const TQStringList &) -{ - return 0; -} - - -// ----------------------------------------------- - -KLibrary::KLibrary( const TQString& libname, const TQString& filename, void * handle ) -{ - /* Make sure, we have a KLibLoader */ - (void) KLibLoader::self(); - m_libname = libname; - m_filename = filename; - m_handle = handle; - m_factory = 0; - m_timer = 0; -} - -KLibrary::~KLibrary() -{ -// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; - if ( m_timer && m_timer->isActive() ) - m_timer->stop(); - - // If any object is remaining, delete - if ( m_objs.count() > 0 ) - { - TQPtrListIterator<TQObject> it( m_objs ); - for ( ; it.current() ; ++it ) - { - kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; - disconnect( it.current(), TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( slotObjectDestroyed() ) ); - } - m_objs.setAutoDelete(true); - m_objs.clear(); - } - - if ( m_factory ) { -// kdDebug(150) << " ... deleting the factory " << m_factory << endl; - delete m_factory; - m_factory = 0L; - } -} - -TQString KLibrary::name() const -{ - return m_libname; -} - -TQString KLibrary::fileName() const -{ - return m_filename; -} - -KLibFactory* KLibrary::factory() -{ - if ( m_factory ) - return m_factory; - - TQCString symname; - symname.sprintf("init_%s", name().latin1() ); - - void* sym = symbol( symname ); - if ( !sym ) - { - KLibLoader::self()->d->errorMessage = i18n( "The library %1 does not offer an %2 function." ).arg( name(), "init_" + name() ); - kdWarning(150) << KLibLoader::self()->d->errorMessage << endl; - return 0; - } - - typedef KLibFactory* (*t_func)(); - t_func func = (t_func)sym; - m_factory = func(); - - if( !m_factory ) - { - KLibLoader::self()->d->errorMessage = i18n( "The library %1 does not offer a KDE compatible factory." ).arg( name() ); - kdWarning(150) << KLibLoader::self()->d->errorMessage << endl; - return 0; - } - - connect( m_factory, TQT_SIGNAL( objectCreated( TQObject * ) ), - this, TQT_SLOT( slotObjectCreated( TQObject * ) ) ); - - return m_factory; -} - -void* KLibrary::symbol( const char* symname ) const -{ - void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); - if ( !sym ) - { - KLibLoader::self()->d->errorMessage = "KLibrary: " + TQString::fromLocal8Bit( lt_dlerror() ); - kdWarning(150) << KLibLoader::self()->d->errorMessage << endl; - return 0; - } - - return sym; -} - -bool KLibrary::hasSymbol( const char* symname ) const -{ - void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); - return (sym != 0L ); -} - -void KLibrary::unload() const -{ - if (KLibLoader::s_self) - KLibLoader::s_self->unloadLibrary(TQFile::encodeName(name())); -} - -void KLibrary::slotObjectCreated( TQObject *obj ) -{ - if ( !obj ) - return; - - if ( m_timer && m_timer->isActive() ) - m_timer->stop(); - - if ( m_objs.containsRef( obj ) ) - return; // we know this object already - - connect( obj, TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( slotObjectDestroyed() ) ); - - m_objs.append( obj ); -} - -void KLibrary::slotObjectDestroyed() -{ - m_objs.removeRef( TQT_TQOBJECT_CONST(sender()) ); - - if ( m_objs.count() == 0 ) - { -// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" -// << endl; - - if ( !m_timer ) - { - m_timer = new TQTimer( this, "klibrary_shutdown_timer" ); - connect( m_timer, TQT_SIGNAL( timeout() ), - this, TQT_SLOT( slotTimeout() ) ); - } - - // as long as it's not stable make the timeout short, for debugging - // pleasure (matz) - //m_timer->start( 1000*60, true ); - m_timer->start( 1000*10, true ); - } -} - -void KLibrary::slotTimeout() -{ - if ( m_objs.count() != 0 ) - return; - - /* Don't go through KLibLoader::unloadLibrary(), because that uses the - ref counter, but this timeout means to unconditionally close this library - The destroyed() signal will take care to remove us from all lists. - */ - delete this; -} - -// ------------------------------------------------- - -/* This helper class is needed, because KLibraries can go away without - being unloaded. So we need some info about KLibraries even after its - death. */ -class KLibWrapPrivate -{ -public: - KLibWrapPrivate(KLibrary *l, lt_dlhandle h); - - KLibrary *lib; - enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; - int ref_count; - lt_dlhandle handle; - TQString name; - TQString filename; -}; - -KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) - : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) -{ - unload_mode = UNKNOWN; - if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { -// kdDebug(150) << "Will not unload " << name << endl; - unload_mode = DONT_UNLOAD; - } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { - unload_mode = UNLOAD; - } -} - -KLibLoader* KLibLoader::self() -{ - if ( !s_self ) - s_self = new KLibLoader; - return s_self; -} - -void KLibLoader::cleanUp() -{ - if ( !s_self ) - return; - - delete s_self; - s_self = 0L; -} - -KLibLoader::KLibLoader( TQObject* parent, const char* name ) - : TQObject( parent, name ) -{ - s_self = this; - d = new KLibLoaderPrivate; - lt_dlinit(); - d->unload_mode = KLibLoaderPrivate::UNKNOWN; - if (getenv("KDE_NOUNLOAD") != 0) - d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; - else if (getenv("KDE_DOUNLOAD") != 0) - d->unload_mode = KLibLoaderPrivate::UNLOAD; - d->loaded_stack.setAutoDelete( true ); -} - -KLibLoader::~KLibLoader() -{ -// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; - - TQAsciiDictIterator<KLibWrapPrivate> it( m_libs ); - for (; it.current(); ++it ) - { - kdDebug(150) << "The KLibLoader contains the library " << it.current()->name - << " (" << it.current()->lib << ")" << endl; - d->pending_close.append(it.current()); - } - - close_pending(0); - - delete d; - d = 0L; -} - -static inline TQCString makeLibName( const char* name ) -{ - TQCString libname(name); - // only append ".la" if there is no extension - // this allows to load non-libtool libraries as well - // (mhk, 20000228) - int pos = libname.findRev('/'); - if (pos < 0) - pos = 0; - if (libname.find('.', pos) < 0) - libname += ".la"; - return libname; -} - -//static -TQString KLibLoader::findLibrary( const char * name, const KInstance * instance ) -{ - TQCString libname = makeLibName( name ); - - // only look up the file if it is not an absolute filename - // (mhk, 20000228) - TQString libfile; - if (!TQDir::isRelativePath(libname)) - libfile = TQFile::decodeName( libname ); - else - { - libfile = instance->dirs()->findResource( "module", libname ); - if ( libfile.isEmpty() ) - { - libfile = instance->dirs()->findResource( "lib", libname ); -#ifndef NDEBUG - if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for tdeinit modules - kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; -#endif - } - } - return libfile; -} - - -KLibrary* KLibLoader::globalLibrary( const char *name ) -{ -KLibrary *tmp; -int olt_dlopen_flag = lt_dlopen_flag; - - lt_dlopen_flag |= LT_GLOBAL; - kdDebug(150) << "Loading the next library global with flag " - << lt_dlopen_flag - << "." << endl; - tmp = library(name); - lt_dlopen_flag = olt_dlopen_flag; - -return tmp; -} - - -KLibrary* KLibLoader::library( const char *name ) -{ - if (!name) - return 0; - - KLibWrapPrivate* wrap = m_libs[name]; - if (wrap) { - /* Nothing to do to load the library. */ - wrap->ref_count++; - return wrap->lib; - } - - /* Test if this library was loaded at some time, but got - unloaded meanwhile, whithout being dlclose()'ed. */ - TQPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); - for (; it.current(); ++it) { - if (it.current()->name == name) - wrap = it.current(); - } - - if (wrap) { - d->pending_close.removeRef(wrap); - if (!wrap->lib) { - /* This lib only was in loaded_stack, but not in m_libs. */ - wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); - } - wrap->ref_count++; - } else { - TQString libfile = findLibrary( name ); - if ( libfile.isEmpty() ) - { - const TQCString libname = makeLibName( name ); -#ifndef NDEBUG - kdDebug(150) << "library=" << name << ": No file named " << libname << " found in paths." << endl; -#endif - d->errorMessage = i18n("Library files for \"%1\" not found in paths.").arg(TQString(libname)); - return 0; - } - - lt_dlhandle handle = lt_dlopen( TQFile::encodeName(libfile) ); - if ( !handle ) - { - const char* errmsg = lt_dlerror(); - if(errmsg) - d->errorMessage = TQString::fromLocal8Bit(errmsg); - else - d->errorMessage = TQString::null; - return 0; - } - else - d->errorMessage = TQString::null; - - KLibrary *lib = new KLibrary( name, libfile, handle ); - wrap = new KLibWrapPrivate(lib, handle); - d->loaded_stack.prepend(wrap); - } - m_libs.insert( name, wrap ); - - connect( wrap->lib, TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( slotLibraryDestroyed() ) ); - - return wrap->lib; -} - -TQString KLibLoader::lastErrorMessage() const -{ - return d->errorMessage; -} - -void KLibLoader::unloadLibrary( const char *libname ) -{ - KLibWrapPrivate *wrap = m_libs[ libname ]; - if (!wrap) - return; - if (--wrap->ref_count) - return; - -// kdDebug(150) << "closing library " << libname << endl; - - m_libs.remove( libname ); - - disconnect( wrap->lib, TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( slotLibraryDestroyed() ) ); - close_pending( wrap ); -} - -KLibFactory* KLibLoader::factory( const char* name ) -{ - KLibrary* lib = library( name ); - if ( !lib ) - return 0; - - return lib->factory(); -} - -void KLibLoader::slotLibraryDestroyed() -{ - const KLibrary *lib = static_cast<const KLibrary *>( sender() ); - - TQAsciiDictIterator<KLibWrapPrivate> it( m_libs ); - for (; it.current(); ++it ) - if ( it.current()->lib == lib ) - { - KLibWrapPrivate *wrap = it.current(); - wrap->lib = 0; /* the KLibrary object is already away */ - m_libs.remove( it.currentKey() ); - close_pending( wrap ); - return; - } -} - -void KLibLoader::close_pending(KLibWrapPrivate *wrap) -{ - if (wrap && !d->pending_close.containsRef( wrap )) - d->pending_close.append( wrap ); - - /* First delete all KLibrary objects in pending_close, but _don't_ unload - the DSO behind it. */ - TQPtrListIterator<KLibWrapPrivate> it(d->pending_close); - for (; it.current(); ++it) { - wrap = it.current(); - if (wrap->lib) { - disconnect( wrap->lib, TQT_SIGNAL( destroyed() ), - this, TQT_SLOT( slotLibraryDestroyed() ) ); - KLibrary* to_delete = wrap->lib; - wrap->lib = 0L; // unset first, because KLibrary dtor can cause - delete to_delete; // recursive call to close_pending() - } - } - - if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) { - d->pending_close.clear(); - return; - } - - bool deleted_one = false; - while ((wrap = d->loaded_stack.first())) { - /* Let's first see, if we want to try to unload this lib. - If the env. var KDE_DOUNLOAD is set, we try to unload every lib. - If not, we look at the lib itself, and unload it only, if it exports - the symbol __kde_do_unload. */ - if (d->unload_mode != KLibLoaderPrivate::UNLOAD - && wrap->unload_mode != KLibWrapPrivate::UNLOAD) - break; - - /* Now ensure, that the libs are only unloaded in the reverse direction - they were loaded. */ - if (!d->pending_close.containsRef( wrap )) { - if (!deleted_one) - /* Only diagnose, if we really haven't deleted anything. */ -// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; - break; - } - -// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; - - if ( !deleted_one ) { - /* Only do the hack once in this loop. - WABA: *HACK* - We need to make sure to clear the clipboard before unloading a DSO - because the DSO could have defined an object derived from QMimeSource - and placed that on the clipboard. */ - /*kapp->tqclipboard()->clear();*/ - - /* Well.. let's do something more subtle... convert the clipboard context - to text. That should be safe as it only uses objects defined by Qt. */ - if( kapp->tqclipboard()->ownsSelection()) { - kapp->tqclipboard()->setText( - kapp->tqclipboard()->text( TQClipboard::Selection ), TQClipboard::Selection ); - } - if( kapp->tqclipboard()->ownsClipboard()) { - kapp->tqclipboard()->setText( - kapp->tqclipboard()->text( TQClipboard::Clipboard ), TQClipboard::Clipboard ); - } - } - - deleted_one = true; - lt_dlclose(wrap->handle); - d->pending_close.removeRef(wrap); - /* loaded_stack is AutoDelete, so wrap is freed */ - d->loaded_stack.remove(); - } -} - -void KLibLoader::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KLibFactory::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "klibloader.moc" diff --git a/kdecore/klibloader.h b/kdecore/klibloader.h deleted file mode 100644 index 0d372237d..000000000 --- a/kdecore/klibloader.h +++ /dev/null @@ -1,405 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - - 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 KLIBLOADER_H -#define KLIBLOADER_H - -#include <tqobject.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqasciidict.h> -#include <tqptrlist.h> -#include <kglobal.h> - -#include <stdlib.h> // For backwards compatibility - -class KInstance; -class TQTimer; -class KLibrary; -class KLibFactory; -class KLibFactoryPrivate; -class KLibLoaderPrivate; -class KLibraryPrivate; - -# define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \ - extern "C" { KDE_EXPORT void *init_##libname() { return new factory; } } - -/** - * @short Represents a dynamically loaded library. - * - * KLibrary allows you to look up symbols of the shared library. - * Use KLibLoader to create a new instance of KLibrary. - * - * @see KLibLoader - * @author Torben Weis <weis@kde.org> - */ -class KDECORE_EXPORT KLibrary : public TQObject -{ - friend class KLibLoader; - friend class TQAsciiDict<KLibrary>; - - Q_OBJECT -public: - /** - * Don't create KLibrary objects on your own. Instead use KLibLoader. - */ - KLibrary( const TQString& libname, const TQString& filename, void * handle ); - - /** - * Returns the name of the library. - * @return The name of the library like "libkspread". - */ - TQString name() const; - - /** - * Returns the file name of the library. - * @return The filename of the library, for example "/opt/kde2&/lib/libkspread.la" - */ - TQString fileName() const; - - /** - * Returns the factory of the library. - * @return The factory of the library if there is any, otherwise 0 - */ - KLibFactory* factory(); - - /** - * Looks up a symbol from the library. This is a very low level - * function that you usually don't want to use. Usually you should - * check using hasSymbol() whether the symbol actually exists, - * otherwise a warning will be printed. - * @param name the name of the symbol to look up - * @return the address of the symbol, or 0 if it does not exist - * @see hasSymbol - */ - void* symbol( const char* name ) const; - - /** - * Looks up a symbol from the library. This is a very low level - * function that you usually don't want to use. - * Unlike symbol(), this method doesn't warn if the symbol doesn't exist, - * so if the symbol might or might not exist, better use hasSymbol() before symbol(). - * @param name the name of the symbol to check - * @return true if the symbol exists - * @since 3.1 - */ - bool hasSymbol( const char* name ) const; - - /** - * Unloads the library. - * This typically results in the deletion of this object. You should - * not reference its pointer after calling this function. - */ - void unload() const; - -private slots: - void slotObjectCreated( TQObject *obj ); - void slotObjectDestroyed(); - void slotTimeout(); - -private: - /** - * @internal - * Don't destruct KLibrary objects yourself. Instead use unload() instead. - */ - ~KLibrary(); - - TQString m_libname; - TQString m_filename; - KLibFactory* m_factory; - void * m_handle; - TQPtrList<TQObject> m_objs; - TQTimer *m_timer; - KLibraryPrivate *d; -}; - -class KLibWrapPrivate; - -/** - * The KLibLoader allows you to load libraries dynamically at runtime. - * Dependent libraries are loaded automatically. - * - * KLibLoader follows the singleton pattern. You can not create multiple - * instances. Use self() to get a pointer to the loader. - * - * @see KLibrary - * @author Torben Weis <weis@kde.org> - */ -class KDECORE_EXPORT KLibLoader : public TQObject -{ - friend class KLibrary; - - Q_OBJECT -public: - /** - * You should NEVER destruct an instance of KLibLoader - * until you know what you are doing. This will release - * the loaded libraries. - */ - ~KLibLoader(); - - /** - * Loads and initializes a library. Loading a library multiple times is - * handled gracefully. - * - * This is a convenience function that returns the factory immediately - * @param libname This is the library name without extension. Usually that is something like - * "libkspread". The function will then search for a file named - * "libkspread.la" in the KDE library paths. - * The *.la files are created by libtool and contain - * important information especially about the libraries dependencies - * on other shared libs. Loading a "libfoo.so" could not solve the - * dependencies problem. - * - * You can, however, give a library name ending in ".so" - * (or whatever is used on your platform), and the library - * will be loaded without resolving dependencies. Use with caution. - * @return the KLibFactory, or 0 if the library does not exist or it does - * not have a factory - * @see library - */ - KLibFactory* factory( const char* libname ); - - /** - * Loads and initializes a library. Loading a library multiple times is - * handled gracefully. - * - * @param libname This is the library name without extension. Usually that is something like - * "libkspread". The function will then search for a file named - * "libkspread.la" in the KDE library paths. - * The *.la files are created by libtool and contain - * important information especially about the libraries dependencies - * on other shared libs. Loading a "libfoo.so" could not solve the - * dependencies problem. - * - * You can, however, give a library name ending in ".so" - * (or whatever is used on your platform), and the library - * will be loaded without resolving dependencies. Use with caution. - * @return KLibrary is invalid (0) when the library couldn't be dlopened. in such - * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage() - * - * @see factory - */ - virtual KLibrary* library( const char* libname ); - - /** - * Loads and initializes a library. Loading a library multiple times is - * handled gracefully. The library is loaded such that the symbols are - * globally accessible so libraries with dependencies can be loaded - * sequentially. - * - * @param name This is the library name without extension. Usually that is something like - * "libkspread". The function will then search for a file named - * "libkspread.la" in the KDE library paths. - * The *.la files are created by libtool and contain - * important information especially about the libraries dependencies - * on other shared libs. Loading a "libfoo.so" could not solve the - * dependencies problem. - * - * You can, however, give a library name ending in ".so" - * (or whatever is used on your platform), and the library - * will be loaded without resolving dependencies. Use with caution. - * @return KLibrariy is invalid (0) when the library couldn't be dlopened. in such - * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage() - * - * @see factory - */ - KLibrary* globalLibrary( const char *name ); - - /** - * Returns an error message that can be useful to debug the problem. - * Returns TQString::null if the last call to library() was successful. - * You can call this function more than once. The error message is only - * reset by a new call to library(). - * @return the last error message, or TQString::null if there was no error - */ - TQString lastErrorMessage() const; - - /** - * Unloads the library with the given name. - * @param libname This is the library name without extension. Usually that is something like - * "libkspread". The function will then search for a file named - * "libkspread.la" in the KDE library paths. - * The *.la files are created by libtool and contain - * important information especially about the libraries dependencies - * on other shared libs. Loading a "libfoo.so" could not solve the - * dependencies problem. - * - * You can, however, give a library name ending in ".so" - * (or whatever is used on your platform), and the library - * will be loaded without resolving dependencies. Use with caution. - */ - virtual void unloadLibrary( const char *libname ); - - /** - * Returns a pointer to the factory. Use this function to get an instance - * of KLibLoader. - * @return a pointer to the loader. If no loader exists until now - * then one is created. - */ - static KLibLoader* self(); - - /** - * @internal - * Internal Method, called by the KApplication destructor. - * Do not call it. - * This is what makes it possible to rely on ~KLibFactory - * being called in all cases, whether the library is unloaded - * while the application is running or when exiting. - */ - static void cleanUp(); - - /** - * Helper method which looks for a library in the standard paths - * ("module" and "lib" resources). - * Made public for code that doesn't use KLibLoader itself, but still - * wants to open modules. - * @param name of the library. If it is not a path, the function searches in - * the "module" and "lib" resources. If there is no extension, - * ".la" will be appended. - * @param instance a KInstance used to get the standard paths - */ - static TQString findLibrary( const char * name, const KInstance * instance = KGlobal::instance() ); - -protected: - KLibLoader( TQObject* parent = 0, const char* name = 0 ); - -private slots: - void slotLibraryDestroyed(); -private: - void close_pending( KLibWrapPrivate * ); - TQAsciiDict<KLibWrapPrivate> m_libs; - - static KLibLoader* s_self; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KLibLoaderPrivate *d; -}; - -/** - * If you develop a library that is to be loaded dynamically at runtime, then - * you should return a pointer to your factory. The K_EXPORT_COMPONENT_FACTORY - * macro is provided for this purpose: - * \code - * K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory ) - * \endcode - * - * The first macro argument is the name of your library, the second specifies the name - * of your factory. - * - * NOTE: you probably want to use KGenericFactory<PluginClassName> - * instead of writing your own factory. - * - * In the constructor of your factory you should create an instance of KInstance - * like this: - * \code - * s_global = new KInstance( "kspread" ); - * \endcode - * This KInstance is comparable to KGlobal used by normal applications. - * It allows you to find resource files (images, XML, sound etc.) belonging - * to the library. - * - * If you want to load a library, use KLibLoader. You can query KLibLoader - * directly for a pointer to the libraries factory by using the KLibLoader::factory() - * function. - * - * The KLibFactory is used to create the components, the library has to offer. - * The factory of KSpread for example will create instances of KSpreadDoc, - * while the Konqueror factory will create KonqView widgets. - * All objects created by the factory must be derived from TQObject, since QObject - * offers type safe casting. - * - * KLibFactory is an abstract class. Reimplement the - * createObject() method to give it functionality. - * - * @author Torben Weis <weis@kde.org> - */ -class KDECORE_EXPORT KLibFactory : public TQObject -{ - Q_OBJECT -public: - /** - * Create a new factory. - * @param parent the parent of the TQObject, 0 for no parent - * @param name the name of the TQObject, 0 for no name - */ - KLibFactory( TQObject* parent = 0, const char* name = 0 ); - virtual ~KLibFactory(); - - /** - * Creates a new object. The returned object has to be derived from - * the requested classname. - * - * It is valid behavior to create different kinds of objects - * depending on the requested @p classname. For example a koffice - * library may usually return a pointer to KoDocument. But - * if asked for a TQWIDGET_OBJECT_NAME_STRING, it could create a wrapper widget, - * that encapsulates the Koffice specific features. - * - * create() automatically emits a signal objectCreated to tell - * the library about its newly created object. This is very - * important for reference counting, and allows unloading the - * library automatically once all its objects have been destroyed. - * - * @param parent the parent of the TQObject, 0 for no parent - * @param name the name of the TQObject, 0 for no name - * @param classname the name of the class - * @param args a list of arguments - */ - - TQObject* create( TQObject* parent = 0, const char* name = 0, const char* classname = TQOBJECT_OBJECT_NAME_STRING, const TQStringList &args = TQStringList() ); - -signals: - /** - * Emitted in #create - * @param obj the new object - */ - void objectCreated( TQObject *obj ); - - -protected: - - /** - * Creates a new object. The returned object has to be derived from - * the requested classname. - * - * It is valid behavior to create different kinds of objects - * depending on the requested @p className. For example a koffice - * library may usually return a pointer to KoDocument. But - * if asked for a TQWIDGET_OBJECT_NAME_STRING, it could create a wrapper widget, - * that encapsulates the Koffice specific features. - * - * This function is called by #create() - * @param parent the parent of the TQObject, 0 for no parent - * @param name the name of the TQObject, 0 for no name - * @param className the name of the class - * @param args a list of arguments - */ - virtual TQObject* createObject( TQObject* parent = 0, const char* name = 0, - const char* className = TQOBJECT_OBJECT_NAME_STRING, - const TQStringList &args = TQStringList() ) = 0; - - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KLibFactoryPrivate *d; -}; - -#endif diff --git a/kdecore/klocale.cpp b/kdecore/klocale.cpp deleted file mode 100644 index 1fae4fbab..000000000 --- a/kdecore/klocale.cpp +++ /dev/null @@ -1,2474 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* This file is part of the KDE libraries - Copyright (c) 1997,2001 Stephan Kulow <coolo@kde.org> - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (c) 1999-2002 Hans Petter Bieker <bieker@kde.org> - Copyright (c) 2002 Lukas Tinkl <lukas@kde.org> - - 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. -*/ - -#include <config.h> - -#include <stdlib.h> // getenv - -#include <tqtextcodec.h> -#include <tqfile.h> -#include <tqprinter.h> -#include <tqdatetime.h> -#include <tqfileinfo.h> -#include <tqregexp.h> - -#include "kcatalogue.h" -#include "kglobal.h" -#include "kstandarddirs.h" -#include "ksimpleconfig.h" -#include "kinstance.h" -#include "kconfig.h" -#include "kdebug.h" -#include "kcalendarsystem.h" -#include "kcalendarsystemfactory.h" -#include "klocale.h" - -#ifdef Q_WS_WIN -#include <windows.h> -#endif - -static const char * const SYSTEM_MESSAGES = "kdelibs"; - -static const char *maincatalogue = 0; - -class KLocalePrivate -{ -public: - int weekStartDay; - bool nounDeclension; - bool dateMonthNamePossessive; - TQStringList languageList; - TQStringList catalogNames; // list of all catalogs (regardless of language) - TQValueList<KCatalogue> catalogues; // list of all loaded catalogs, contains one instance per catalog name and language - TQString encoding; - TQTextCodec * codecForEncoding; - KConfig * config; - bool formatInited; - int /*TQPrinter::PageSize*/ pageSize; - KLocale::MeasureSystem measureSystem; - TQStringList langTwoAlpha; - KConfig *languages; - - TQString calendarType; - KCalendarSystem * calendar; - bool utf8FileEncoding; - TQString appName; -#ifdef Q_WS_WIN - char win32SystemEncoding[3+7]; //"cp " + lang ID -#endif - bool useMainCatalogue; -}; - -static KLocale *this_klocale = 0; - -KLocale::KLocale( const TQString & catalog, KConfig * config ) -{ - d = new KLocalePrivate; - d->config = config; - d->languages = 0; - d->calendar = 0; - d->formatInited = false; - - initEncoding(0); - initFileNameEncoding(0); - - KConfig *cfg = d->config; - this_klocale = this; - if (!cfg) cfg = KGlobal::instance()->config(); - this_klocale = 0; - Q_ASSERT( cfg ); - - d->appName = catalog; - initLanguageList( cfg, config == 0); - initMainCatalogues(catalog); -} - -TQString KLocale::_initLanguage(KConfigBase *config) -{ - if (this_klocale) - { - // ### HPB Why this cast?? - this_klocale->initLanguageList((KConfig *) config, true); - // todo: adapt current catalog list: remove unused languages, insert main catalogs, if not already found - return this_klocale->language(); - } - return TQString::null; -} - -void KLocale::initMainCatalogues(const TQString & catalog) -{ - // Use the first non-null string. - TQString mainCatalogue = catalog; - - // don't use main catalogue if we're looking up .desktop translations - if (mainCatalogue.contains("desktop") == 0 || mainCatalogue.contains("kdesktop") == 1) { - if (maincatalogue) { - mainCatalogue = TQString::tqfromLatin1(maincatalogue); - } - } - - if (mainCatalogue.isEmpty()) { - kdDebug(173) << "KLocale instance created called without valid " - << "catalog! Give an argument or call setMainCatalogue " - << "before init" << endl; - } - else { - // do not use insertCatalogue here, that would already trigger updateCatalogs - d->catalogNames.append( mainCatalogue ); // application catalog - if (mainCatalogue.contains("desktop") == 0 || mainCatalogue.contains("kdesktop") == 1) { //don't bother if we're looking up desktop translations - d->catalogNames.append( SYSTEM_MESSAGES ); // always include kdelibs.mo - d->catalogNames.append( "kio" ); // always include kio.mo - d->catalogNames.append( "xdg-user-dirs" ); - } - updateCatalogues(); // evaluate this for all languages - } -} - -void KLocale::initLanguageList(KConfig * config, bool useEnv) -{ - KConfigGroupSaver saver(config, "Locale"); - - m_country = config->readEntry( "Country" ); - if ( m_country.isEmpty() ) - m_country = defaultCountry(); - - // Reset the list and add the new languages - TQStringList languageList; - if ( useEnv ) - languageList += TQStringList::split - (':', TQFile::decodeName( ::getenv("KDE_LANG") )); - - languageList += config->readListEntry("Language", ':'); - - // same order as setlocale use - if ( useEnv ) - { - // HPB: Only run splitLocale on the environment variables.. - TQStringList langs; - - langs << TQFile::decodeName( ::getenv("LC_ALL") ); - langs << TQFile::decodeName( ::getenv("LC_MESSAGES") ); - langs << TQFile::decodeName( ::getenv("LANG") ); - - for ( TQStringList::Iterator it = langs.begin(); - it != langs.end(); - ++it ) - { - TQString ln, ct, chrset; - splitLocale(*it, ln, ct, chrset); - - if (!ct.isEmpty()) { - langs.insert(it, ln + '_' + ct); - if (!chrset.isEmpty()) - langs.insert(it, ln + '_' + ct + '.' + chrset); - } - - langs.insert(it, ln); - } - - languageList += langs; - } - - // now we have a language list -- let's use the first OK language - setLanguage( languageList ); -} - -void KLocale::initPluralTypes() -{ - for ( TQValueList<KCatalogue>::Iterator it = d->catalogues.begin(); - it != d->catalogues.end(); - ++it ) - { - TQString language = (*it).language(); - int pt = pluralType( language ); - (*it).setPluralType( pt ); - } -} - - -int KLocale::pluralType( const TQString & language ) -{ - for ( TQValueList<KCatalogue>::ConstIterator it = d->catalogues.begin(); - it != d->catalogues.end(); - ++it ) - { - if ( ((*it).name() == SYSTEM_MESSAGES ) && ((*it).language() == language )) { - return pluralType( *it ); - } - } - // kdelibs.mo does not seem to exist for this language - return -1; -} - -int KLocale::pluralType( const KCatalogue& catalog ) -{ - const char* pluralFormString = - I18N_NOOP("_: Dear translator, please do not translate this string " - "in any form, but pick the _right_ value out of " - "NoPlural/TwoForms/French... If not sure what to do mail " - "thd@kde.org and coolo@kde.org, they will tell you. " - "Better leave that out if unsure, the programs will " - "crash!!\nDefinition of PluralForm - to be set by the " - "translator of kdelibs.po"); - TQString pf (catalog.translate( pluralFormString)); - if ( pf.isEmpty() ) { - return -1; - } - else if ( pf == "NoPlural" ) - return 0; - else if ( pf == "TwoForms" ) - return 1; - else if ( pf == "French" ) - return 2; - else if ( pf == "OneTwoRest" ) - return 3; - else if ( pf == "Russian" ) - return 4; - else if ( pf == "Polish" ) - return 5; - else if ( pf == "Slovenian" ) - return 6; - else if ( pf == "Lithuanian" ) - return 7; - else if ( pf == "Czech" ) - return 8; - else if ( pf == "Slovak" ) - return 9; - else if ( pf == "Maltese" ) - return 10; - else if ( pf == "Arabic" ) - return 11; - else if ( pf == "Balcan" ) - return 12; - else if ( pf == "Macedonian" ) - return 13; - else if ( pf == "Gaeilge" ) - return 14; - else { - kdWarning(173) << "Definition of PluralForm is none of " - << "NoPlural/" - << "TwoForms/" - << "French/" - << "OneTwoRest/" - << "Russian/" - << "Polish/" - << "Slovenian/" - << "Lithuanian/" - << "Czech/" - << "Slovak/" - << "Arabic/" - << "Balcan/" - << "Macedonian/" - << "Gaeilge/" - << "Maltese: " << pf << endl; - exit(1); - } -} - -void KLocale::doFormatInit() const -{ - if ( d->formatInited ) return; - - KLocale * that = const_cast<KLocale *>(this); - that->initFormat(); - - d->formatInited = true; -} - -void KLocale::initFormat() -{ - KConfig *config = d->config; - if (!config) config = KGlobal::instance()->config(); - Q_ASSERT( config ); - - kdDebug(173) << "KLocale::initFormat" << endl; - - // make sure the config files are read using the correct locale - // ### Why not add a KConfigBase::setLocale( const KLocale * )? - // ### Then we could remove this hack - KLocale *lsave = KGlobal::_locale; - KGlobal::_locale = this; - - KConfigGroupSaver saver(config, "Locale"); - - KSimpleConfig entry(locate("locale", - TQString::tqfromLatin1("l10n/%1/entry.desktop") - .arg(m_country)), true); - entry.setGroup("KCM Locale"); - - // Numeric -#define readConfigEntry(key, default, save) \ - save = entry.readEntry(key, TQString::tqfromLatin1(default)); \ - save = config->readEntry(key, save); - -#define readConfigNumEntry(key, default, save, type) \ - save = (type)entry.readNumEntry(key, default); \ - save = (type)config->readNumEntry(key, save); - -#define readConfigBoolEntry(key, default, save) \ - save = entry.readBoolEntry(key, default); \ - save = config->readBoolEntry(key, save); - - readConfigEntry("DecimalSymbol", ".", m_decimalSymbol); - readConfigEntry("ThousandsSeparator", ",", m_thousandsSeparator); - m_thousandsSeparator.replace( TQString::tqfromLatin1("$0"), TQString() ); - //kdDebug(173) << "m_thousandsSeparator=" << m_thousandsSeparator << endl; - - readConfigEntry("PositiveSign", "", m_positiveSign); - readConfigEntry("NegativeSign", "-", m_negativeSign); - - // Monetary - readConfigEntry("CurrencySymbol", "$", m_currencySymbol); - readConfigEntry("MonetaryDecimalSymbol", ".", m_monetaryDecimalSymbol); - readConfigEntry("MonetaryThousandsSeparator", ",", - m_monetaryThousandsSeparator); - m_monetaryThousandsSeparator.replace(TQString::tqfromLatin1("$0"), TQString()); - - readConfigNumEntry("FracDigits", 2, m_fracDigits, int); - readConfigBoolEntry("PositivePrefixCurrencySymbol", true, - m_positivePrefixCurrencySymbol); - readConfigBoolEntry("NegativePrefixCurrencySymbol", true, - m_negativePrefixCurrencySymbol); - readConfigNumEntry("PositiveMonetarySignPosition", (int)BeforeQuantityMoney, - m_positiveMonetarySignPosition, SignPosition); - readConfigNumEntry("NegativeMonetarySignPosition", (int)ParensAround, - m_negativeMonetarySignPosition, SignPosition); - - - // Date and time - readConfigEntry("TimeFormat", "%H:%M:%S", m_timeFormat); - readConfigEntry("DateFormat", "%A %d %B %Y", m_dateFormat); - readConfigEntry("DateFormatShort", "%Y-%m-%d", m_dateFormatShort); - readConfigNumEntry("WeekStartDay", 1, d->weekStartDay, int); - - // other - readConfigNumEntry("PageSize", (int)TQPrinter::A4, d->pageSize, int); - readConfigNumEntry("MeasureSystem", (int)Metric, d->measureSystem, - MeasureSystem); - readConfigEntry("CalendarSystem", "gregorian", d->calendarType); - delete d->calendar; - d->calendar = 0; // ### HPB Is this the correct place? - - //Grammatical - //Precedence here is l10n / i18n / config file - KSimpleConfig language(locate("locale", - TQString::tqfromLatin1("%1/entry.desktop") - .arg(m_language)), true); - language.setGroup("KCM Locale"); -#define read3ConfigBoolEntry(key, default, save) \ - save = entry.readBoolEntry(key, default); \ - save = language.readBoolEntry(key, save); \ - save = config->readBoolEntry(key, save); - - read3ConfigBoolEntry("NounDeclension", false, d->nounDeclension); - read3ConfigBoolEntry("DateMonthNamePossessive", false, - d->dateMonthNamePossessive); - - // end of hack - KGlobal::_locale = lsave; -} - -bool KLocale::setCountry(const TQString & country) -{ - // Check if the file exists too?? - if ( country.isEmpty() ) - return false; - - m_country = country; - - d->formatInited = false; - - return true; -} - -TQString KLocale::catalogueFileName(const TQString & language, - const KCatalogue & catalog) -{ - TQString path = TQString::tqfromLatin1("%1/LC_MESSAGES/%2.mo") - .arg( language ) - .arg( catalog.name() ); - - TQString fileName = locate( "locale", path ); - if (fileName.isEmpty()) - fileName = locate( "locale-bundle", path ); - - return fileName; -} - -bool KLocale::setLanguage(const TQString & language) -{ - if ( d->languageList.contains( language ) ) { - d->languageList.remove( language ); - } - d->languageList.prepend( language ); // let us consider this language to be the most important one - - m_language = language; // remember main language for shortcut evaluation - - // important when called from the outside and harmless when called before populating the - // catalog name list - updateCatalogues(); - - d->formatInited = false; - - return true; // Maybe the mo-files for this language are empty, but in principle we can speak all languages -} - -bool KLocale::setLanguage(const TQStringList & languages) -{ - TQStringList languageList( languages ); - // This list might contain - // 1) some empty strings that we have to eliminate - // 2) duplicate entries like in de:fr:de, where we have to keep the first occurrance of a language in order - // to preserve the order of precenence of the user => iterate backwards - // 3) languages into which the application is not translated. For those languages we should not even load kdelibs.mo or kio.po. - // these langugage have to be dropped. Otherwise we get strange side effects, e.g. with Hebrew: - // the right/left switch for languages that write from - // right to left (like Hebrew or Arabic) is set in kdelibs.mo. If you only have kdelibs.mo - // but nothing from appname.mo, you get a mostly English app with layout from right to left. - // That was considered to be a bug by the Hebrew translators. - for( TQStringList::Iterator it = languageList.fromLast(); - it != languageList.begin(); --it ) - { - // kdDebug() << "checking " << (*it) << endl; - bool bIsTranslated = isApplicationTranslatedInto( *it ); - if ( languageList.contains(*it) > 1 || (*it).isEmpty() || (!bIsTranslated) ) { - // kdDebug() << "removing " << (*it) << endl; - it = languageList.remove( it ); - } - } - // now this has left the first element of the list unchecked. - // The question why this is the case is left as an exercise for the reader... - // Besides the list might have been empty all the way, so check that too. - if ( languageList.begin() != languageList.end() ) { - TQStringList::Iterator it = languageList.begin(); // now pointing to the first element - // kdDebug() << "checking " << (*it) << endl; - if( (*it).isEmpty() || !(isApplicationTranslatedInto( *it )) ) { - // kdDebug() << "removing " << (*it) << endl; - languageList.remove( it ); // that's what the iterator was for... - } - } - - if ( languageList.isEmpty() ) { - // user picked no language, so we assume he/she speaks English. - languageList.append( defaultLanguage() ); - } - m_language = languageList.first(); // keep this for shortcut evaluations - - d->languageList = languageList; // keep this new list of languages to use - d->langTwoAlpha.clear(); // Flush cache - - // important when called from the outside and harmless when called before populating the - // catalog name list - updateCatalogues(); - - return true; // we found something. Maybe it's only English, but we found something -} - -bool KLocale::isApplicationTranslatedInto( const TQString & language) -{ - if ( language.isEmpty() ) { - return false; - } - - if ( language == defaultLanguage() ) { - // en_us is always "installed" - return true; - } - - TQString appName = d->appName; - if (maincatalogue) { - appName = TQString::tqfromLatin1(maincatalogue); - } - // sorry, catalogueFileName requires catalog object,k which we do not have here - // path finding was supposed to be moved completely to KCatalogue. The interface cannot - // be changed that far during deep freeze. So in order to fix the bug now, we have - // duplicated code for file path evaluation. Cleanup will follow later. We could have e.g. - // a static method in KCataloge that can translate between these file names. - // a stat - TQString sFileName = TQString::tqfromLatin1("%1/LC_MESSAGES/%2.mo") - .arg( language ) - .arg( appName ); - // kdDebug() << "isApplicationTranslatedInto: filename " << sFileName << endl; - - TQString sAbsFileName = locate( "locale", sFileName ); - if (sAbsFileName.isEmpty()) - sAbsFileName = locate( "locale-bundle", sFileName ); - - // kdDebug() << "isApplicationTranslatedInto: absname " << sAbsFileName << endl; - return ! sAbsFileName.isEmpty(); -} - -void KLocale::splitLocale(const TQString & aStr, - TQString & language, - TQString & country, - TQString & chrset) -{ - TQString str = aStr; - - // just in case, there is another language appended - int f = str.find(':'); - if (f >= 0) - str.truncate(f); - - country = TQString::null; - chrset = TQString::null; - language = TQString::null; - - f = str.find('.'); - if (f >= 0) - { - chrset = str.mid(f + 1); - str.truncate(f); - } - - f = str.find('_'); - if (f >= 0) - { - country = str.mid(f + 1); - str.truncate(f); - } - - language = str; -} - -TQString KLocale::language() const -{ - return m_language; -} - -TQString KLocale::country() const -{ - return m_country; -} - -TQString KLocale::monthName(int i, bool shortName) const -{ - if ( shortName ) - switch ( i ) - { - case 1: return translate("January", "Jan"); - case 2: return translate("February", "Feb"); - case 3: return translate("March", "Mar"); - case 4: return translate("April", "Apr"); - case 5: return translate("May short", "May"); - case 6: return translate("June", "Jun"); - case 7: return translate("July", "Jul"); - case 8: return translate("August", "Aug"); - case 9: return translate("September", "Sep"); - case 10: return translate("October", "Oct"); - case 11: return translate("November", "Nov"); - case 12: return translate("December", "Dec"); - } - else - switch (i) - { - case 1: return translate("January"); - case 2: return translate("February"); - case 3: return translate("March"); - case 4: return translate("April"); - case 5: return translate("May long", "May"); - case 6: return translate("June"); - case 7: return translate("July"); - case 8: return translate("August"); - case 9: return translate("September"); - case 10: return translate("October"); - case 11: return translate("November"); - case 12: return translate("December"); - } - - return TQString::null; -} - -TQString KLocale::monthNamePossessive(int i, bool shortName) const -{ - if ( shortName ) - switch ( i ) - { - case 1: return translate("of January", "of Jan"); - case 2: return translate("of February", "of Feb"); - case 3: return translate("of March", "of Mar"); - case 4: return translate("of April", "of Apr"); - case 5: return translate("of May short", "of May"); - case 6: return translate("of June", "of Jun"); - case 7: return translate("of July", "of Jul"); - case 8: return translate("of August", "of Aug"); - case 9: return translate("of September", "of Sep"); - case 10: return translate("of October", "of Oct"); - case 11: return translate("of November", "of Nov"); - case 12: return translate("of December", "of Dec"); - } - else - switch (i) - { - case 1: return translate("of January"); - case 2: return translate("of February"); - case 3: return translate("of March"); - case 4: return translate("of April"); - case 5: return translate("of May long", "of May"); - case 6: return translate("of June"); - case 7: return translate("of July"); - case 8: return translate("of August"); - case 9: return translate("of September"); - case 10: return translate("of October"); - case 11: return translate("of November"); - case 12: return translate("of December"); - } - - return TQString::null; -} - -TQString KLocale::weekDayName (int i, bool shortName) const -{ - return calendar()->weekDayName(i, shortName); -} - -void KLocale::insertCatalogue( const TQString & catalog ) -{ - if ( !d->catalogNames.contains( catalog) ) { - d->catalogNames.append( catalog ); - } - updateCatalogues( ); // evaluate the changed list and generate the neccessary KCatalog objects -} - -void KLocale::updateCatalogues( ) -{ - // some changes have occured. Maybe we have learned or forgotten some languages. - // Maybe the language precedence has changed. - // Maybe we have learned or forgotten some catalog names. - // Now examine the list of KCatalogue objects and change it according to the new circumstances. - - // this could be optimized: try to reuse old KCatalog objects, but remember that the order of - // catalogs might have changed: e.g. in this fashion - // 1) move all catalogs into a temporary list - // 2) iterate over all languages and catalog names - // 3.1) pick the catalog from the saved list, if it already exists - // 3.2) else create a new catalog. - // but we will do this later. - - for ( TQValueList<KCatalogue>::Iterator it = d->catalogues.begin(); - it != d->catalogues.end(); ) - { - it = d->catalogues.remove(it); - } - - // now iterate over all languages and all wanted catalog names and append or create them in the right order - // the sequence must be e.g. nds/appname nds/kdelibs nds/kio de/appname de/kdelibs de/kio etc. - // and not nds/appname de/appname nds/kdelibs de/kdelibs etc. Otherwise we would be in trouble with a language - // sequende nds,en_US, de. In this case en_US must hide everything below in the language list. - for ( TQStringList::ConstIterator itLangs = d->languageList.begin(); - itLangs != d->languageList.end(); ++itLangs) - { - for ( TQStringList::ConstIterator itNames = d->catalogNames.begin(); - itNames != d->catalogNames.end(); ++itNames) - { - KCatalogue cat( *itNames, *itLangs ); // create Catalog for this name and this language - d->catalogues.append( cat ); - } - } - initPluralTypes(); // evaluate the plural type for all languages and remember this in each KCatalogue -} - - - - -void KLocale::removeCatalogue(const TQString &catalog) -{ - if ( d->catalogNames.contains( catalog )) { - d->catalogNames.remove( catalog ); - if (KGlobal::_instance) - updateCatalogues(); // walk through the KCatalogue instances and weed out everything we no longer need - } -} - -void KLocale::setActiveCatalogue(const TQString &catalog) -{ - if ( d->catalogNames.contains( catalog ) ) { - d->catalogNames.remove( catalog ); - d->catalogNames.prepend( catalog ); - updateCatalogues(); // walk through the KCatalogue instances and adapt to the new order - } -} - -KLocale::~KLocale() -{ - delete d->calendar; - delete d->languages; - delete d; - d = 0L; -} - -TQString KLocale::translate_priv(const char *msgid, - const char *fallback, - const char **translated, - int* pluralType ) const -{ - if ( pluralType) { - *pluralType = -1; // unless we find something more precise - } - if (!msgid || !msgid[0]) - { - kdWarning() << "KLocale: trying to look up \"\" in catalog. " - << "Fix the program" << endl; - return TQString::null; - } - - if ( useDefaultLanguage() ) { // shortcut evaluation if en_US is main language: do not consult the catalogs - return TQString::fromUtf8( fallback ); - } - - for ( TQValueList<KCatalogue>::ConstIterator it = d->catalogues.begin(); - it != d->catalogues.end(); - ++it ) - { - // shortcut evaluation: once we have arrived at en_US (default language) we cannot consult - // the catalog as it will not have an assiciated mo-file. For this default language we can - // immediately pick the fallback string. - if ( (*it).language() == defaultLanguage() ) { - return TQString::fromUtf8( fallback ); - } - - const char * text = (*it).translate( msgid ); - - if ( text ) - { - // we found it - if (translated) { - *translated = text; - } - if ( pluralType) { - *pluralType = (*it).pluralType(); // remember the plural type information from the catalog that was used - } - return TQString::fromUtf8( text ); - } - } - - // Always use UTF-8 if the string was not found - return TQString::fromUtf8( fallback ); -} - -TQString KLocale::translate(const char* msgid) const -{ - return translate_priv(msgid, msgid); -} - -TQString KLocale::translate( const char *index, const char *fallback) const -{ - if (!index || !index[0] || !fallback || !fallback[0]) - { - kdDebug(173) << "KLocale: trying to look up \"\" in catalog. " - << "Fix the program" << endl; - return TQString::null; - } - - if ( useDefaultLanguage() ) - return TQString::fromUtf8( fallback ); - - char *newstring = new char[strlen(index) + strlen(fallback) + 5]; - sprintf(newstring, "_: %s\n%s", index, fallback); - // as copying TQString is very fast, it looks slower as it is ;/ - TQString r = translate_priv(newstring, fallback); - delete [] newstring; - - return r; -} - -static TQString put_n_in(const TQString &orig, unsigned long n) -{ - TQString ret = orig; - int index = ret.find("%n"); - if (index == -1) - return ret; - ret.replace(index, 2, TQString::number(n)); - return ret; -} - -#define EXPECT_LENGTH(x) \ - if (forms.count() != x) { \ - kdError() << "translation of \"" << singular << "\" doesn't contain " << x << " different plural forms as expected\n"; \ - return TQString( "BROKEN TRANSLATION %1" ).arg( singular ); } - -TQString KLocale::translate( const char *singular, const char *plural, - unsigned long n ) const -{ - if (!singular || !singular[0] || !plural || !plural[0]) - { - kdWarning() << "KLocale: trying to look up \"\" in catalog. " - << "Fix the program" << endl; - return TQString::null; - } - - char *newstring = new char[strlen(singular) + strlen(plural) + 6]; - sprintf(newstring, "_n: %s\n%s", singular, plural); - // as copying TQString is very fast, it looks slower as it is ;/ - int pluralType = -1; - TQString r = translate_priv(newstring, 0, 0, &pluralType); - delete [] newstring; - - if ( r.isEmpty() || useDefaultLanguage() || pluralType == -1) { - if ( n == 1 ) { - return put_n_in( TQString::fromUtf8( singular ), n ); - } else { - TQString tmp = TQString::fromUtf8( plural ); -#ifndef NDEBUG - if (tmp.find("%n") == -1) { - kdDebug() << "the message for i18n should contain a '%n'! " << plural << endl; - } -#endif - return put_n_in( tmp, n ); - } - } - - TQStringList forms = TQStringList::split( "\n", r, false ); - switch ( pluralType ) { - case 0: // NoPlural - EXPECT_LENGTH( 1 ); - return put_n_in( forms[0], n); - case 1: // TwoForms - EXPECT_LENGTH( 2 ); - if ( n == 1 ) - return put_n_in( forms[0], n); - else - return put_n_in( forms[1], n); - case 2: // French - EXPECT_LENGTH( 2 ); - if ( n == 1 || n == 0 ) - return put_n_in( forms[0], n); - else - return put_n_in( forms[1], n); - case 3: // OneTwoRest - EXPECT_LENGTH( 3 ); - if ( n == 1 ) - return put_n_in( forms[0], n); - else if ( n == 2 ) - return put_n_in( forms[1], n); - else - return put_n_in( forms[2], n); - case 4: // Russian, corrected by mok - EXPECT_LENGTH( 3 ); - if ( n%10 == 1 && n%100 != 11) - return put_n_in( forms[0], n); // odin fail - else if (( n%10 >= 2 && n%10 <=4 ) && (n%100<10 || n%100>20)) - return put_n_in( forms[1], n); // dva faila - else - return put_n_in( forms[2], n); // desyat' failov - case 5: // Polish - EXPECT_LENGTH( 3 ); - if ( n == 1 ) - return put_n_in( forms[0], n); - else if ( n%10 >= 2 && n%10 <=4 && (n%100<10 || n%100>=20) ) - return put_n_in( forms[1], n); - else - return put_n_in( forms[2], n); - case 6: // Slovenian - EXPECT_LENGTH( 4 ); - if ( n%100 == 1 ) - return put_n_in( forms[1], n); // ena datoteka - else if ( n%100 == 2 ) - return put_n_in( forms[2], n); // dve datoteki - else if ( n%100 == 3 || n%100 == 4 ) - return put_n_in( forms[3], n); // tri datoteke - else - return put_n_in( forms[0], n); // sto datotek - case 7: // Lithuanian - EXPECT_LENGTH( 3 ); - if ( n%10 == 0 || (n%100>=11 && n%100<=19) ) - return put_n_in( forms[2], n); - else if ( n%10 == 1 ) - return put_n_in( forms[0], n); - else - return put_n_in( forms[1], n); - case 8: // Czech - use modern form which is equivalent to Slovak - case 9: // Slovak - EXPECT_LENGTH( 3 ); - if ( n == 1 ) - return put_n_in( forms[0], n); - else if (( n >= 2 ) && ( n <= 4 )) - return put_n_in( forms[1], n); - else - return put_n_in( forms[2], n); - case 10: // Maltese - EXPECT_LENGTH( 4 ); - if ( n == 1 ) - return put_n_in( forms[0], n ); - else if ( ( n == 0 ) || ( n%100 > 0 && n%100 <= 10 ) ) - return put_n_in( forms[1], n ); - else if ( n%100 > 10 && n%100 < 20 ) - return put_n_in( forms[2], n ); - else - return put_n_in( forms[3], n ); - case 11: // Arabic - EXPECT_LENGTH( 4 ); - if (n == 1) - return put_n_in(forms[0], n); - else if (n == 2) - return put_n_in(forms[1], n); - else if ( n < 11) - return put_n_in(forms[2], n); - else - return put_n_in(forms[3], n); - case 12: // Balcan - EXPECT_LENGTH( 3 ); - if (n != 11 && n % 10 == 1) - return put_n_in(forms[0], n); - else if (n / 10 != 1 && n % 10 >= 2 && n % 10 <= 4) - return put_n_in(forms[1], n); - else - return put_n_in(forms[2], n); - case 13: // Macedonian - EXPECT_LENGTH(3); - if (n % 10 == 1) - return put_n_in(forms[0], n); - else if (n % 10 == 2) - return put_n_in(forms[1], n); - else - return put_n_in(forms[2], n); - case 14: // Gaeilge - EXPECT_LENGTH(5); - if (n == 1) // "ceann amhain" - return put_n_in(forms[0], n); - else if (n == 2) // "dha cheann" - return put_n_in(forms[1], n); - else if (n < 7) // "%n cinn" - return put_n_in(forms[2], n); - else if (n < 11) // "%n gcinn" - return put_n_in(forms[3], n); - else // "%n ceann" - return put_n_in(forms[4], n); - } - kdFatal() << "The function should have been returned in another way\n"; - - return TQString::null; -} - -TQString KLocale::translateQt( const char *context, const char *source, - const char *message) const -{ - if (!source || !source[0]) { - kdWarning() << "KLocale: trying to look up \"\" in catalog. " - << "Fix the program" << endl; - return TQString::null; - } - - if ( useDefaultLanguage() ) { - return TQString::null; - } - - char *newstring = 0; - const char *translation = 0; - TQString r; - - if ( message && message[0]) { - char *newstring = new char[strlen(source) + strlen(message) + 5]; - sprintf(newstring, "_: %s\n%s", source, message); - const char *translation = 0; - // as copying TQString is very fast, it looks slower as it is ;/ - r = translate_priv(newstring, source, &translation); - delete [] newstring; - if (translation) - return r; - } - - if ( context && context[0] && message && message[0]) { - newstring = new char[strlen(context) + strlen(message) + 5]; - sprintf(newstring, "_: %s\n%s", context, message); - // as copying TQString is very fast, it looks slower as it is ;/ - r = translate_priv(newstring, source, &translation); - delete [] newstring; - if (translation) - return r; - } - - r = translate_priv(source, source, &translation); - if (translation) - return r; - return TQString::null; -} - -bool KLocale::nounDeclension() const -{ - doFormatInit(); - return d->nounDeclension; -} - -bool KLocale::dateMonthNamePossessive() const -{ - doFormatInit(); - return d->dateMonthNamePossessive; -} - -int KLocale::weekStartDay() const -{ - doFormatInit(); - return d->weekStartDay; -} - -bool KLocale::weekStartsMonday() const //deprecated -{ - doFormatInit(); - return (d->weekStartDay==1); -} - -TQString KLocale::decimalSymbol() const -{ - doFormatInit(); - return m_decimalSymbol; -} - -TQString KLocale::thousandsSeparator() const -{ - doFormatInit(); - return m_thousandsSeparator; -} - -TQString KLocale::currencySymbol() const -{ - doFormatInit(); - return m_currencySymbol; -} - -TQString KLocale::monetaryDecimalSymbol() const -{ - doFormatInit(); - return m_monetaryDecimalSymbol; -} - -TQString KLocale::monetaryThousandsSeparator() const -{ - doFormatInit(); - return m_monetaryThousandsSeparator; -} - -TQString KLocale::positiveSign() const -{ - doFormatInit(); - return m_positiveSign; -} - -TQString KLocale::negativeSign() const -{ - doFormatInit(); - return m_negativeSign; -} - -int KLocale::fracDigits() const -{ - doFormatInit(); - return m_fracDigits; -} - -bool KLocale::positivePrefixCurrencySymbol() const -{ - doFormatInit(); - return m_positivePrefixCurrencySymbol; -} - -bool KLocale::negativePrefixCurrencySymbol() const -{ - doFormatInit(); - return m_negativePrefixCurrencySymbol; -} - -KLocale::SignPosition KLocale::positiveMonetarySignPosition() const -{ - doFormatInit(); - return m_positiveMonetarySignPosition; -} - -KLocale::SignPosition KLocale::negativeMonetarySignPosition() const -{ - doFormatInit(); - return m_negativeMonetarySignPosition; -} - -static inline void put_it_in( TQChar *buffer, uint& index, const TQString &s ) -{ - for ( uint l = 0; l < s.length(); l++ ) - buffer[index++] = s.tqat( l ); -} - -static inline void put_it_in( TQChar *buffer, uint& index, int number ) -{ - buffer[index++] = number / 10 + '0'; - buffer[index++] = number % 10 + '0'; -} - -// insert (thousands)-"separator"s into the non-fractional part of str -static void _insertSeparator(TQString &str, const TQString &separator, - const TQString &decimalSymbol) -{ - // leave fractional part untouched - TQString mainPart = str.section(decimalSymbol, 0, 0); - TQString fracPart = str.section(decimalSymbol, 1, 1, - TQString::SectionIncludeLeadingSep); - - for (int pos = mainPart.length() - 3; pos > 0; pos -= 3) - mainPart.insert(pos, separator); - - str = mainPart + fracPart; -} - -TQString KLocale::formatMoney(double num, - const TQString & symbol, - int precision) const -{ - // some defaults - TQString currency = symbol.isNull() - ? currencySymbol() - : symbol; - if (precision < 0) precision = fracDigits(); - - // the number itself - bool neg = num < 0; - TQString res = TQString::number(neg?-num:num, 'f', precision); - - // Replace dot with locale decimal separator - res.replace(TQChar('.'), monetaryDecimalSymbol()); - - // Insert the thousand separators - _insertSeparator(res, monetaryThousandsSeparator(), monetaryDecimalSymbol()); - - // set some variables we need later - int signpos = neg - ? negativeMonetarySignPosition() - : positiveMonetarySignPosition(); - TQString sign = neg - ? negativeSign() - : positiveSign(); - - switch (signpos) - { - case ParensAround: - res.prepend('('); - res.append (')'); - break; - case BeforeQuantityMoney: - res.prepend(sign); - break; - case AfterQuantityMoney: - res.append(sign); - break; - case BeforeMoney: - currency.prepend(sign); - break; - case AfterMoney: - currency.append(sign); - break; - } - - if (neg?negativePrefixCurrencySymbol(): - positivePrefixCurrencySymbol()) - { - res.prepend(' '); - res.prepend(currency); - } else { - res.append (' '); - res.append (currency); - } - - return res; -} - -TQString KLocale::formatMoney(const TQString &numStr) const -{ - return formatMoney(numStr.toDouble()); -} - -TQString KLocale::formatNumber(double num, int precision) const -{ - if (precision == -1) precision = 2; - // no need to round since TQString::number does this for us - return formatNumber(TQString::number(num, 'f', precision), false, 0); -} - -TQString KLocale::formatLong(long num) const -{ - return formatNumber((double)num, 0); -} - -TQString KLocale::formatNumber(const TQString &numStr) const -{ - return formatNumber(numStr, true, 2); -} - -// increase the digit at 'position' by one -static void _inc_by_one(TQString &str, int position) -{ - for (int i = position; i >= 0; i--) - { - char last_char = str[i].latin1(); - switch(last_char) - { - case '0': - str[i] = (QChar)'1'; - break; - case '1': - str[i] = (QChar)'2'; - break; - case '2': - str[i] = (QChar)'3'; - break; - case '3': - str[i] = (QChar)'4'; - break; - case '4': - str[i] = (QChar)'5'; - break; - case '5': - str[i] = (QChar)'6'; - break; - case '6': - str[i] = (QChar)'7'; - break; - case '7': - str[i] = (QChar)'8'; - break; - case '8': - str[i] = (QChar)'9'; - break; - case '9': - str[i] = (QChar)'0'; - if (i == 0) str.prepend('1'); - continue; - case '.': - continue; - } - break; - } -} - -// Cut off if more digits in fractional part than 'precision' -static void _round(TQString &str, int precision) -{ - int decimalSymbolPos = str.find('.'); - - if (decimalSymbolPos == -1) - if (precision == 0) return; - else if (precision > 0) // add dot if missing (and needed) - { - str.append('.'); - decimalSymbolPos = str.length() - 1; - } - - // fill up with more than enough zeroes (in case fractional part too short) - str.append(TQString().fill('0', precision)); - - // Now decide whether to round up or down - char last_char = str[decimalSymbolPos + precision + 1].latin1(); - switch (last_char) - { - case '0': - case '1': - case '2': - case '3': - case '4': - // nothing to do, rounding down - break; - case '5': - case '6': - case '7': - case '8': - case '9': - _inc_by_one(str, decimalSymbolPos + precision); - break; - default: - break; - } - - decimalSymbolPos = str.find('.'); - str.truncate(decimalSymbolPos + precision + 1); - - // if precision == 0 delete also '.' - if (precision == 0) str = str.section('.', 0, 0); -} - -TQString KLocale::formatNumber(const TQString &numStr, bool round, - int precision) const -{ - TQString tmpString = numStr; - if ((round && precision < 0) || - ! TQRegExp("^[+-]?\\d+(\\.\\d+)*(e[+-]?\\d+)?$").exactMatch(tmpString)) - return numStr; - - - // Skip the sign (for now) - bool neg = (tmpString[0] == (QChar)'-'); - if (neg || tmpString[0] == (QChar)'+') tmpString.remove(0, 1); - - // Split off exponential part (including 'e'-symbol) - TQString mantString = tmpString.section('e', 0, 0, - TQString::SectionCaseInsensitiveSeps); - TQString expString = tmpString.section('e', 1, 1, - TQString::SectionCaseInsensitiveSeps | - TQString::SectionIncludeLeadingSep); - - if (round) _round(mantString, precision); - - // Replace dot with locale decimal separator - mantString.replace(TQChar('.'), decimalSymbol()); - - // Insert the thousand separators - _insertSeparator(mantString, thousandsSeparator(), decimalSymbol()); - - // How can we know where we should put the sign? - mantString.prepend(neg?negativeSign():positiveSign()); - - return mantString + expString; -} - -TQString KLocale::formatDate(const TQDate &pDate, bool shortFormat) const -{ - const TQString rst = shortFormat?dateFormatShort():dateFormat(); - - TQString buffer; - - if ( ! pDate.isValid() ) return buffer; - - bool escape = false; - - int year = calendar()->year(pDate); - int month = calendar()->month(pDate); - - for ( uint format_index = 0; format_index < rst.length(); ++format_index ) - { - if ( !escape ) - { - if ( (TQChar(rst.tqat( format_index )).tqunicode()) == '%' ) - escape = true; - else - buffer.append(rst.tqat(format_index)); - } - else - { - switch ( TQChar(rst.tqat( format_index )).tqunicode() ) - { - case '%': - buffer.append('%'); - break; - case 'Y': - buffer.append(calendar()->yearString(pDate, false)); - break; - case 'y': - buffer.append(calendar()->yearString(pDate, true)); - break; - case 'n': - buffer.append(calendar()->monthString(pDate, true)); - break; - case 'e': - buffer.append(calendar()->dayString(pDate, true)); - break; - case 'm': - buffer.append(calendar()->monthString(pDate, false)); - break; - case 'b': - if (d->nounDeclension && d->dateMonthNamePossessive) - buffer.append(calendar()->monthNamePossessive(month, year, true)); - else - buffer.append(calendar()->monthName(month, year, true)); - break; - case 'B': - if (d->nounDeclension && d->dateMonthNamePossessive) - buffer.append(calendar()->monthNamePossessive(month, year, false)); - else - buffer.append(calendar()->monthName(month, year, false)); - break; - case 'd': - buffer.append(calendar()->dayString(pDate, false)); - break; - case 'a': - buffer.append(calendar()->weekDayName(pDate, true)); - break; - case 'A': - buffer.append(calendar()->weekDayName(pDate, false)); - break; - default: - buffer.append(rst.tqat(format_index)); - break; - } - escape = false; - } - } - return buffer; -} - -void KLocale::setMainCatalogue(const char *catalog) -{ - maincatalogue = catalog; -} - -double KLocale::readNumber(const TQString &_str, bool * ok) const -{ - TQString str = _str.stripWhiteSpace(); - bool neg = str.find(negativeSign()) == 0; - if (neg) - str.remove( 0, negativeSign().length() ); - - /* will hold the scientific notation portion of the number. - Example, with 2.34E+23, exponentialPart == "E+23" - */ - TQString exponentialPart; - int EPos; - - EPos = str.find('E', 0, false); - - if (EPos != -1) - { - exponentialPart = str.mid(EPos); - str = str.left(EPos); - } - - int pos = str.find(decimalSymbol()); - TQString major; - TQString minor; - if ( pos == -1 ) - major = str; - else - { - major = str.left(pos); - minor = str.mid(pos + decimalSymbol().length()); - } - - // Remove thousand separators - int thlen = thousandsSeparator().length(); - int lastpos = 0; - while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) - { - // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N - int fromEnd = major.length() - pos; - if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error - || pos - lastpos > 3 // More than 3 digits between two separators -> error - || pos == 0 // Can't start with a separator - || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators - { - if (ok) *ok = false; - return 0.0; - } - - lastpos = pos; - major.remove( pos, thlen ); - } - if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator - { - if (ok) *ok = false; - return 0.0; - } - - TQString tot; - if (neg) tot = (QChar)'-'; - - tot += major + '.' + minor + exponentialPart; - - return tot.toDouble(ok); -} - -double KLocale::readMoney(const TQString &_str, bool * ok) const -{ - TQString str = _str.stripWhiteSpace(); - bool neg = false; - bool currencyFound = false; - TQString symbol = currencySymbol(); - // First try removing currency symbol from either end - int pos = str.find(symbol); - if ( pos == 0 || pos == (int) str.length()-symbol.length() ) - { - str.remove(pos,symbol.length()); - str = str.stripWhiteSpace(); - currencyFound = true; - } - if (str.isEmpty()) - { - if (ok) *ok = false; - return 0; - } - // Then try removing negative sign from either end - // (with a special case for parenthesis) - if (negativeMonetarySignPosition() == ParensAround) - { - if (str[0] == (QChar)'(' && str[str.length()-1] == (QChar)')') - { - neg = true; - str.remove(str.length()-1,1); - str.remove(0,1); - } - } - else - { - int i1 = str.find(negativeSign()); - if ( i1 == 0 || i1 == (int) str.length()-1 ) - { - neg = true; - str.remove(i1,negativeSign().length()); - } - } - if (neg) str = str.stripWhiteSpace(); - - // Finally try again for the currency symbol, if we didn't find - // it already (because of the negative sign being in the way). - if ( !currencyFound ) - { - pos = str.find(symbol); - if ( pos == 0 || pos == (int) str.length()-symbol.length() ) - { - str.remove(pos,symbol.length()); - str = str.stripWhiteSpace(); - } - } - - // And parse the rest as a number - pos = str.find(monetaryDecimalSymbol()); - TQString major; - TQString minior; - if (pos == -1) - major = str; - else - { - major = str.left(pos); - minior = str.mid(pos + monetaryDecimalSymbol().length()); - } - - // Remove thousand separators - int thlen = monetaryThousandsSeparator().length(); - int lastpos = 0; - while ( ( pos = major.find( monetaryThousandsSeparator() ) ) > 0 ) - { - // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N - int fromEnd = major.length() - pos; - if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error - || pos - lastpos > 3 // More than 3 digits between two separators -> error - || pos == 0 // Can't start with a separator - || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators - { - if (ok) *ok = false; - return 0.0; - } - lastpos = pos; - major.remove( pos, thlen ); - } - if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator - { - if (ok) *ok = false; - return 0.0; - } - - TQString tot; - if (neg) tot = (QChar)'-'; - tot += major + '.' + minior; - return tot.toDouble(ok); -} - -/** - * helper function to read integers - * @param str - * @param pos the position to start at. It will be updated when we parse it. - * @return the integer read in the string, or -1 if no string - */ -static int readInt(const TQString &str, uint &pos) -{ - if (!str.tqat(pos).isDigit()) return -1; - int result = 0; - for (; str.length() > pos && str.tqat(pos).isDigit(); pos++) - { - result *= 10; - result += str.tqat(pos).digitValue(); - } - - return result; -} - -TQDate KLocale::readDate(const TQString &intstr, bool* ok) const -{ - TQDate date; - date = readDate(intstr, ShortFormat, ok); - if (date.isValid()) return date; - return readDate(intstr, NormalFormat, ok); -} - -TQDate KLocale::readDate(const TQString &intstr, ReadDateFlags flags, bool* ok) const -{ - TQString fmt = ((flags & ShortFormat) ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); - return readDate( intstr, fmt, ok ); -} - -TQDate KLocale::readDate(const TQString &intstr, const TQString &fmt, bool* ok) const -{ - //kdDebug() << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; - TQString str = intstr.simplifyWhiteSpace().lower(); - int day = -1, month = -1; - // allow the year to be omitted if not in the format - int year = calendar()->year(TQDate::currentDate()); - uint strpos = 0; - uint fmtpos = 0; - - int iLength; // Temporary variable used when reading input - - bool error = false; - - while (fmt.length() > fmtpos && str.length() > strpos && !error) - { - - TQChar c = fmt.tqat(fmtpos++); - - if (c != (QChar)'%') { - if (c.isSpace() && str.tqat(strpos).isSpace()) - strpos++; - else if (c != str.tqat(strpos++)) - error = true; - } - else - { - int j; - // remove space at the beginning - if (str.length() > strpos && str.tqat(strpos).isSpace()) - strpos++; - - c = fmt.tqat(fmtpos++); - switch (c) - { - case 'a': - case 'A': - - error = true; - j = 1; - while (error && (j < 8)) { - TQString s = calendar()->weekDayName(j, c == (QChar)'a').lower(); - int len = s.length(); - if (str.mid(strpos, len) == s) - { - strpos += len; - error = false; - } - j++; - } - break; - case 'b': - case 'B': - - error = true; - if (d->nounDeclension && d->dateMonthNamePossessive) { - j = 1; - while (error && (j < 13)) { - TQString s = calendar()->monthNamePossessive(j, year, c == (QChar)'b').lower(); - int len = s.length(); - if (str.mid(strpos, len) == s) { - month = j; - strpos += len; - error = false; - } - j++; - } - } - j = 1; - while (error && (j < 13)) { - TQString s = calendar()->monthName(j, year, c == (QChar)'b').lower(); - int len = s.length(); - if (str.mid(strpos, len) == s) { - month = j; - strpos += len; - error = false; - } - j++; - } - break; - case 'd': - case 'e': - day = calendar()->dayStringToInteger(str.mid(strpos), iLength); - strpos += iLength; - - error = iLength <= 0; - break; - - case 'n': - case 'm': - month = calendar()->monthStringToInteger(str.mid(strpos), iLength); - strpos += iLength; - - error = iLength <= 0; - break; - - case 'Y': - case 'y': - year = calendar()->yearStringToInteger(str.mid(strpos), iLength); - strpos += iLength; - - error = iLength <= 0; - break; - } - } - } - - /* for a match, we should reach the end of both strings, not just one of - them */ - if ( fmt.length() > fmtpos || str.length() > strpos ) - { - error = true; - } - - //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; - if ( year != -1 && month != -1 && day != -1 && !error) - { - if (ok) *ok = true; - - TQDate result; - calendar()->setYMD(result, year, month, day); - - return result; - } - else - { - if (ok) *ok = false; - return TQDate(); // invalid date - } -} - -TQTime KLocale::readTime(const TQString &intstr, bool *ok) const -{ - TQTime _time; - _time = readTime(intstr, WithSeconds, ok); - if (_time.isValid()) return _time; - return readTime(intstr, WithoutSeconds, ok); -} - -TQTime KLocale::readTime(const TQString &intstr, ReadTimeFlags flags, bool *ok) const -{ - TQString str = intstr.simplifyWhiteSpace().lower(); - TQString Format = timeFormat().simplifyWhiteSpace(); - if (flags & WithoutSeconds) - Format.remove(TQRegExp(".%S")); - - int hour = -1, minute = -1; - int second = ( (flags & WithoutSeconds) == 0 ) ? -1 : 0; // don't require seconds - bool g_12h = false; - bool pm = false; - uint strpos = 0; - uint Formatpos = 0; - - while (Format.length() > Formatpos || str.length() > strpos) - { - if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; - - TQChar c = Format.tqat(Formatpos++); - - if (c != (QChar)'%') - { - if (c.isSpace()) - strpos++; - else if (c != str.tqat(strpos++)) - goto error; - continue; - } - - // remove space at the beginning - if (str.length() > strpos && str.tqat(strpos).isSpace()) - strpos++; - - c = Format.tqat(Formatpos++); - switch (c) - { - case 'p': - { - TQString s; - s = translate("pm").lower(); - int len = s.length(); - if (str.mid(strpos, len) == s) - { - pm = true; - strpos += len; - } - else - { - s = translate("am").lower(); - len = s.length(); - if (str.mid(strpos, len) == s) { - pm = false; - strpos += len; - } - else - goto error; - } - } - break; - - case 'k': - case 'H': - g_12h = false; - hour = readInt(str, strpos); - if (hour < 0 || hour > 23) - goto error; - - break; - - case 'l': - case 'I': - g_12h = true; - hour = readInt(str, strpos); - if (hour < 1 || hour > 12) - goto error; - - break; - - case 'M': - minute = readInt(str, strpos); - if (minute < 0 || minute > 59) - goto error; - - break; - - case 'S': - second = readInt(str, strpos); - if (second < 0 || second > 59) - goto error; - - break; - } - } - if (g_12h) { - hour %= 12; - if (pm) hour += 12; - } - - if (ok) *ok = true; - return TQTime(hour, minute, second); - - error: - if (ok) *ok = false; - // ######## KDE4: remove this - return TQTime(-1, -1, -1); // return invalid date if it didn't work -} - -//BIC: merge with below -TQString KLocale::formatTime(const TQTime &pTime, bool includeSecs) const -{ - return formatTime( pTime, includeSecs, false ); -} - -TQString KLocale::formatTime(const TQTime &pTime, bool includeSecs, bool isDuration) const -{ - const TQString rst = timeFormat(); - - // only "pm/am" here can grow, the rest shrinks, but - // I'm rather safe than sorry - TQChar *buffer = new TQChar[rst.length() * 3 / 2 + 30]; - - uint index = 0; - bool escape = false; - int number = 0; - - for ( uint format_index = 0; format_index < rst.length(); format_index++ ) - { - if ( !escape ) - { - if ( (TQChar(rst.tqat( format_index )).tqunicode()) == '%' ) - escape = true; - else - buffer[index++] = rst.tqat( format_index ); - } - else - { - switch ( TQChar(rst.tqat( format_index )).tqunicode() ) - { - case '%': - buffer[index++] = (QChar)'%'; - break; - case 'H': - put_it_in( buffer, index, pTime.hour() ); - break; - case 'I': - if ( isDuration ) - put_it_in( buffer, index, pTime.hour() ); - else - put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); - break; - case 'M': - put_it_in( buffer, index, pTime.minute() ); - break; - case 'S': - if (includeSecs) - put_it_in( buffer, index, pTime.second() ); - else if ( index > 0 ) - { - // we remove the separator sign before the seconds and - // assume that works everywhere - --index; - break; - } - break; - case 'k': - number = pTime.hour(); - case 'l': - // to share the code - if ( (TQChar(rst.tqat( format_index )).tqunicode()) == 'l' ) - number = isDuration ? pTime.hour() : (pTime.hour() + 11) % 12 + 1; - if ( number / 10 ) - buffer[index++] = number / 10 + '0'; - buffer[index++] = number % 10 + '0'; - break; - case 'p': - if ( !isDuration ) - { - TQString s; - if ( pTime.hour() >= 12 ) - put_it_in( buffer, index, translate("pm") ); - else - put_it_in( buffer, index, translate("am") ); - } - break; - default: - buffer[index++] = rst.tqat( format_index ); - break; - } - escape = false; - } - } - TQString ret( buffer, index ); - delete [] buffer; - if ( isDuration ) // eliminate trailing-space due to " %p" - return ret.stripWhiteSpace(); - else - return ret; -} - -bool KLocale::use12Clock() const -{ - if ((timeFormat().contains(TQString::tqfromLatin1("%I")) > 0) || - (timeFormat().contains(TQString::tqfromLatin1("%l")) > 0)) - return true; - else - return false; -} - -TQString KLocale::languages() const -{ - return d->languageList.join( TQString::tqfromLatin1(":") ); -} - -TQStringList KLocale::languageList() const -{ - return d->languageList; -} - -TQString KLocale::formatDateTime(const TQDateTime &pDateTime, - bool shortFormat, - bool includeSeconds) const -{ - return translate("concatenation of dates and time", "%1 %2") - .arg( formatDate( TQT_TQDATE_OBJECT(pDateTime.date()), shortFormat ) ) - .arg( formatTime( TQT_TQTIME_OBJECT(pDateTime.time()), includeSeconds ) ); -} - -TQString i18n(const char* text) -{ - register KLocale *instance = KGlobal::locale(); - if (instance) - return instance->translate(text); - return TQString::fromUtf8(text); -} - -TQString i18n(const char* index, const char *text) -{ - register KLocale *instance = KGlobal::locale(); - if (instance) - return instance->translate(index, text); - return TQString::fromUtf8(text); -} - -TQString i18n(const char* singular, const char* plural, unsigned long n) -{ - register KLocale *instance = KGlobal::locale(); - if (instance) - return instance->translate(singular, plural, n); - if (n == 1) - return put_n_in(TQString::fromUtf8(singular), n); - else - return put_n_in(TQString::fromUtf8(plural), n); -} - -void KLocale::initInstance() -{ - if (KGlobal::_locale) - return; - - KInstance *app = KGlobal::instance(); - if (app) { - KGlobal::_locale = new KLocale(TQString::tqfromLatin1(app->instanceName())); - - // only do this for the global instance - TQTextCodec::setCodecForLocale(KGlobal::_locale->codecForEncoding()); - } - else - kdDebug(173) << "no app name available using KLocale - nothing to do\n"; -} - -TQString KLocale::langLookup(const TQString &fname, const char *rtype) -{ - TQStringList search; - - // assemble the local search paths - const TQStringList localDoc = KGlobal::dirs()->resourceDirs(rtype); - - // look up the different languages - for (int id=localDoc.count()-1; id >= 0; --id) - { - TQStringList langs = KGlobal::locale()->languageList(); - langs.append( "en" ); - langs.remove( defaultLanguage() ); - TQStringList::ConstIterator lang; - for (lang = langs.begin(); lang != langs.end(); ++lang) - search.append(TQString("%1%2/%3").arg(localDoc[id]).arg(*lang).arg(fname)); - } - - // try to locate the file - TQStringList::Iterator it; - for (it = search.begin(); it != search.end(); ++it) - { - kdDebug(173) << "Looking for help in: " << *it << endl; - - TQFileInfo info(*it); - if (info.exists() && info.isFile() && info.isReadable()) - return *it; - } - - return TQString::null; -} - -bool KLocale::useDefaultLanguage() const -{ - return language() == defaultLanguage(); -} - -void KLocale::initEncoding(KConfig *) -{ - const int mibDefault = 4; // ISO 8859-1 - - // This all made more sense when we still had the EncodingEnum config key. - setEncoding( TQTextCodec::codecForLocale()->mibEnum() ); - - if ( !d->codecForEncoding ) - { - kdWarning(173) << " Defaulting to ISO 8859-1 encoding." << endl; - setEncoding(mibDefault); - } - - Q_ASSERT( d->codecForEncoding ); -} - -void KLocale::initFileNameEncoding(KConfig *) -{ - // If the following environment variable is set, assume all filenames - // are in UTF-8 regardless of the current C locale. - d->utf8FileEncoding = getenv("KDE_UTF8_FILENAMES") != 0; - if (d->utf8FileEncoding) - { - TQFile::setEncodingFunction(KLocale::encodeFileNameUTF8); - TQFile::setDecodingFunction(KLocale::decodeFileNameUTF8); - } - // Otherwise, stay with QFile's default filename encoding functions - // which, on Unix platforms, use the locale's codec. -} - -#ifdef USE_QT3 -TQCString KLocale::encodeFileNameUTF8( const TQString & fileName ) -#endif // USE_QT3 -#ifdef USE_QT4 -QByteArray KLocale::encodeFileNameUTF8( const QString & fileName ) -#endif // USE_QT4 -{ - return TQString(fileName).utf8(); -} - -#ifdef USE_QT3 -TQString KLocale::decodeFileNameUTF8( const TQCString & localFileName ) -#endif // USE_QT3 -#ifdef USE_QT4 -QString KLocale::decodeFileNameUTF8( const QByteArray & localFileName ) -#endif // USE_QT4 -{ - return TQString::fromUtf8(localFileName); -} - -void KLocale::setDateFormat(const TQString & format) -{ - doFormatInit(); - m_dateFormat = format.stripWhiteSpace(); -} - -void KLocale::setDateFormatShort(const TQString & format) -{ - doFormatInit(); - m_dateFormatShort = format.stripWhiteSpace(); -} - -void KLocale::setDateMonthNamePossessive(bool possessive) -{ - doFormatInit(); - d->dateMonthNamePossessive = possessive; -} - -void KLocale::setTimeFormat(const TQString & format) -{ - doFormatInit(); - m_timeFormat = format.stripWhiteSpace(); -} - -void KLocale::setWeekStartsMonday(bool start) //deprecated -{ - doFormatInit(); - if (start) - d->weekStartDay = 1; - else - d->weekStartDay = 7; -} - -void KLocale::setWeekStartDay(int day) -{ - doFormatInit(); - if (day>7 || day<1) - d->weekStartDay = 1; //Monday is default - else - d->weekStartDay = day; -} - -TQString KLocale::dateFormat() const -{ - doFormatInit(); - return m_dateFormat; -} - -TQString KLocale::dateFormatShort() const -{ - doFormatInit(); - return m_dateFormatShort; -} - -TQString KLocale::timeFormat() const -{ - doFormatInit(); - return m_timeFormat; -} - -void KLocale::setDecimalSymbol(const TQString & symbol) -{ - doFormatInit(); - m_decimalSymbol = symbol.stripWhiteSpace(); -} - -void KLocale::setThousandsSeparator(const TQString & separator) -{ - doFormatInit(); - // allow spaces here - m_thousandsSeparator = separator; -} - -void KLocale::setPositiveSign(const TQString & sign) -{ - doFormatInit(); - m_positiveSign = sign.stripWhiteSpace(); -} - -void KLocale::setNegativeSign(const TQString & sign) -{ - doFormatInit(); - m_negativeSign = sign.stripWhiteSpace(); -} - -void KLocale::setPositiveMonetarySignPosition(SignPosition signpos) -{ - doFormatInit(); - m_positiveMonetarySignPosition = signpos; -} - -void KLocale::setNegativeMonetarySignPosition(SignPosition signpos) -{ - doFormatInit(); - m_negativeMonetarySignPosition = signpos; -} - -void KLocale::setPositivePrefixCurrencySymbol(bool prefix) -{ - doFormatInit(); - m_positivePrefixCurrencySymbol = prefix; -} - -void KLocale::setNegativePrefixCurrencySymbol(bool prefix) -{ - doFormatInit(); - m_negativePrefixCurrencySymbol = prefix; -} - -void KLocale::setFracDigits(int digits) -{ - doFormatInit(); - m_fracDigits = digits; -} - -void KLocale::setMonetaryThousandsSeparator(const TQString & separator) -{ - doFormatInit(); - // allow spaces here - m_monetaryThousandsSeparator = separator; -} - -void KLocale::setMonetaryDecimalSymbol(const TQString & symbol) -{ - doFormatInit(); - m_monetaryDecimalSymbol = symbol.stripWhiteSpace(); -} - -void KLocale::setCurrencySymbol(const TQString & symbol) -{ - doFormatInit(); - m_currencySymbol = symbol.stripWhiteSpace(); -} - -int KLocale::pageSize() const -{ - doFormatInit(); - return d->pageSize; -} - -void KLocale::setPageSize(int pageSize) -{ - // #### check if it's in range?? - doFormatInit(); - d->pageSize = pageSize; -} - -KLocale::MeasureSystem KLocale::measureSystem() const -{ - doFormatInit(); - return d->measureSystem; -} - -void KLocale::setMeasureSystem(MeasureSystem value) -{ - doFormatInit(); - d->measureSystem = value; -} - -TQString KLocale::defaultLanguage() -{ - return TQString::tqfromLatin1("en_US"); -} - -TQString KLocale::defaultCountry() -{ - return TQString::tqfromLatin1("C"); -} - -const char * KLocale::encoding() const -{ -#ifdef Q_WS_WIN - if (0==qstrcmp("System", codecForEncoding()->name())) - { - //win32 returns "System" codec name here but KDE apps expect a real name: - strcpy(d->win32SystemEncoding, "cp "); - if (GetLocaleInfoA( MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), SORT_DEFAULT), - LOCALE_IDEFAULTANSICODEPAGE, d->win32SystemEncoding+3, sizeof(d->win32SystemEncoding)-3-1 )) - { - return d->win32SystemEncoding; - } - } -#endif - return codecForEncoding()->name(); -} - -int KLocale::encodingMib() const -{ - return codecForEncoding()->mibEnum(); -} - -int KLocale::fileEncodingMib() const -{ - if (d->utf8FileEncoding) - return 106; - return codecForEncoding()->mibEnum(); -} - -TQTextCodec * KLocale::codecForEncoding() const -{ - return d->codecForEncoding; -} - -bool KLocale::setEncoding(int mibEnum) -{ - TQTextCodec * codec = TQTextCodec::codecForMib(mibEnum); - if (codec) - d->codecForEncoding = codec; - - return codec != 0; -} - -TQStringList KLocale::languagesTwoAlpha() const -{ - if (d->langTwoAlpha.count()) - return d->langTwoAlpha; - - const TQStringList &origList = languageList(); - - TQStringList result; - - KConfig config(TQString::tqfromLatin1("language.codes"), true, false); - config.setGroup("TwoLetterCodes"); - - for ( TQStringList::ConstIterator it = origList.begin(); - it != origList.end(); - ++it ) - { - TQString lang = *it; - TQStringList langLst; - if (config.hasKey( lang )) - langLst = config.readListEntry( lang ); - else - { - int i = lang.find('_'); - if (i >= 0) - lang.truncate(i); - langLst << lang; - } - - for ( TQStringList::ConstIterator langIt = langLst.begin(); - langIt != langLst.end(); - ++langIt ) - { - if ( !(*langIt).isEmpty() && !result.contains( *langIt ) ) - result += *langIt; - } - } - d->langTwoAlpha = result; - return result; -} - -TQStringList KLocale::allLanguagesTwoAlpha() const -{ - if (!d->languages) - d->languages = new KConfig("all_languages", true, false, "locale"); - - return d->languages->groupList(); -} - -TQString KLocale::twoAlphaToLanguageName(const TQString &code) const -{ - if (!d->languages) - d->languages = new KConfig("all_languages", true, false, "locale"); - - TQString groupName = code; - const int i = groupName.find('_'); - groupName.replace(0, i, groupName.left(i).lower()); - - d->languages->setGroup(groupName); - return d->languages->readEntry("Name"); -} - -TQStringList KLocale::allCountriesTwoAlpha() const -{ - TQStringList countries; - TQStringList paths = KGlobal::dirs()->findAllResources("locale", "l10n/*/entry.desktop"); - for(TQStringList::ConstIterator it = paths.begin(); - it != paths.end(); ++it) - { - TQString code = (*it).mid((*it).length()-16, 2); - if (code != "/C") - countries.append(code); - } - return countries; -} - -TQString KLocale::twoAlphaToCountryName(const TQString &code) const -{ - KConfig cfg("l10n/"+code.lower()+"/entry.desktop", true, false, "locale"); - cfg.setGroup("KCM Locale"); - return cfg.readEntry("Name"); -} - -void KLocale::setCalendar(const TQString & calType) -{ - doFormatInit(); - - d->calendarType = calType; - - delete d->calendar; - d->calendar = 0; -} - -TQString KLocale::calendarType() const -{ - doFormatInit(); - - return d->calendarType; -} - -const KCalendarSystem * KLocale::calendar() const -{ - doFormatInit(); - - // Check if it's the correct calendar?!? - if ( !d->calendar ) - d->calendar = KCalendarSystemFactory::create( d->calendarType, this ); - - return d->calendar; -} - -KLocale::KLocale(const KLocale & rhs) -{ - d = new KLocalePrivate; - - *this = rhs; -} - -KLocale & KLocale::operator=(const KLocale & rhs) -{ - // Numbers and money - m_decimalSymbol = rhs.m_decimalSymbol; - m_thousandsSeparator = rhs.m_thousandsSeparator; - m_currencySymbol = rhs.m_currencySymbol; - m_monetaryDecimalSymbol = rhs.m_monetaryDecimalSymbol; - m_monetaryThousandsSeparator = rhs.m_monetaryThousandsSeparator; - m_positiveSign = rhs.m_positiveSign; - m_negativeSign = rhs.m_negativeSign; - m_fracDigits = rhs.m_fracDigits; - m_positivePrefixCurrencySymbol = rhs.m_positivePrefixCurrencySymbol; - m_negativePrefixCurrencySymbol = rhs.m_negativePrefixCurrencySymbol; - m_positiveMonetarySignPosition = rhs.m_positiveMonetarySignPosition; - m_negativeMonetarySignPosition = rhs.m_negativeMonetarySignPosition; - - // Date and time - m_timeFormat = rhs.m_timeFormat; - m_dateFormat = rhs.m_dateFormat; - m_dateFormatShort = rhs.m_dateFormatShort; - - m_language = rhs.m_language; - m_country = rhs.m_country; - - // the assignment operator works here - *d = *rhs.d; - d->languages = 0; // Don't copy languages - d->calendar = 0; // Don't copy the calendar - - return *this; -} - -bool KLocale::setCharset(const TQString & ) { return true; } -TQString KLocale::charset() const { return TQString::tqfromLatin1("UTF-8"); } - -// KDE4: remove -#if 0 -void nothing() { i18n("&Next"); } -#endif diff --git a/kdecore/klocale.h b/kdecore/klocale.h deleted file mode 100644 index 9bca02077..000000000 --- a/kdecore/klocale.h +++ /dev/null @@ -1,1350 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* This file is part of the KDE libraries - Copyright (C) 1997 Stephan Kulow <coolo@kde.org> - Copyright (C) 1999-2003 Hans Petter Bieker <bieker@kde.org> - Copyright (c) 2002 Lukas Tinkl <lukas@kde.org> - - 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 _KLOCALE_H -#define _KLOCALE_H - -#include <tqstring.h> -#include <kdelibs_export.h> - -class TQStringList; -class TQTextCodec; -class TQDate; -class TQTime; -class TQDateTime; - -class KGlobal; -class KConfig; -class KConfigBase; -class KLocalePrivate; -class KCatalogue; -class KCalendarSystem; - -/** - * \file klocale.h - */ - -#ifndef I18N_NOOP -/** - * \relates KLocale - * I18N_NOOP marks a string to be translated without translating it. - * Do not use this unless you know you need it. - * http://developer.kde.org/documentation/other/developer-faq.html#q2.11.2 - */ -#define I18N_NOOP(x) x -#endif - -#ifndef I18N_NOOP2 -/** - * \relates KLocale - * If the string is too ambiguous to be translated well to a non-english - * language, use this instead of I18N_NOOP to separate lookup string and english. - * \warning You need to call i18n( comment, stringVar ) later on, not just i18n( stringVar ). - * \since 3.3 - */ -#define I18N_NOOP2(comment,x) x -#endif - -/** - * \relates KLocale - * i18n is the function that does everything you need to translate - * a string. You just wrap around every user visible string a i18n - * call to get a TQString with the string in the user's preferred - * language. - * - * The argument must be an UTF-8 encoded string (If you only use - * characters that are in US-ASCII, you're on the safe side. But - * for e.g. German umlauts or French accents should be recoded to - * UTF-8) - **/ -KDECORE_EXPORT TQString i18n(const char *text); - -/** - * \relates KLocale - * If the string is too ambiguous to be translated well to a non-english - * language, use this form of i18n to separate lookup string and english - * text. - * @see translate - **/ -KDECORE_EXPORT TQString i18n(const char *comment, const char *text); - -/** - * \relates KLocale - * If you want to handle plural forms, use this form of i18n. - * @param singular the singular form of the word, for example "file". - * @param plural the plural form of the word. Must contain a "%n" that will - * be replaced by the number @p n, for example "%n files" - * @param n the number - * @return the correct singular or plural for the selected language, - * depending on n - * @see translate - **/ -KDECORE_EXPORT TQString i18n(const char *singular, const char *plural, unsigned long n); - -/** - * \relates KLocale - * Qt3's uic generates i18n( "msg", "comment" ) calls which conflict - * with our i18n method. We use uic -tr tr2i18n to redirect - * to the right i18n() function -**/ -inline TQString tr2i18n(const char* message, const char* =0) { - return i18n(message); -} - -/** - * - * KLocale provides support for country specific stuff like - * the national language. - * - * KLocale supports translating, as well as specifying the format - * for numbers, currency, time, and date. - * - * @author Stephan Kulow <coolo@kde.org>, Preston Brown <pbrown@kde.org>, - * Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz> - * @short class for supporting locale settings and national language - */ -class KDECORE_EXPORT KLocale -{ - friend class KGlobal; // for initInstance() -public: - /** - * Constructs a KLocale with the given catalog name. - * The constructor looks for an entry Locale/Language in the - * configuration file. - * If no config file is specified, it will also look for languages - * using the environment variables (KDE_LANG, LC_MESSAGES, LC_ALL, LANG), - * as well as the global configuration file. If KLocale is not able to use - * any of the specified languages, the default language (en_US) will be - * used. - * - * If you specify a configuration file, it has to be valid until - * the KLocale object is destroyed. - * - * @param catalog The name of the main language file - * @param config The configuration file to use. - */ - KLocale( const TQString& catalog, KConfig *config = 0 ); - - /** - * Copy constructor. - */ - KLocale( const KLocale & rhs ); - - /** - * Assignment operator. - */ - KLocale& operator= ( const KLocale & rhs ); - - /** - * Destructor. - */ - ~KLocale(); - - /** - * Translates the string into the corresponding string in - * the national language, if available. If not, returns - * the string itself. - * There is a KDE wide message file that contains the most - * often used phrases, so we can avoid duplicating the - * translation of these phrases. If a phrase is not found - * in the catalog given to the constructor, it will search - * in the system catalog. This makes it possible to override - * some phrases for your needs. - * - * The argument must be an UTF-8 encoded string (If you only use - * characters that are in US-ASCII you're on the safe side. But - * for e.g. german umlauts or french accents should be recoded to - * UTF-8) - * - * @param index The lookup text and default text, if not found. - */ - TQString translate( const char *index ) const; - - /** - * Translates the string into the corresponding string in the - * national language, if available. - * - * The real contents of the string is in the argument fallback, - * but the meaning of it is coded into the argument index. - * In some cases you'll need this function, when english is - * too ambiguous to express it. - * - * Most of the times the translators will tell you if it can't - * be translated as it, but think of cases as "New", where the - * translations differs depending on what is New. - * Or simple cases as "Open", that can be used to express something - * is open or it can be used to express that you want something to - * open... There are tons of such examples. - * - * If translate("Open") is not enough to translate it well, use - * translate("To Open", "Open") or translate("Is Open", "Open"). - * The english user will see "Open" in both cases, but the translated - * version may vary. Of course you can also use i18n() - * - * @param comment the comment. The lookup text is made out of comment + @p fallback - * @param fallback the default text, if not found - * @return translation - */ - TQString translate( const char *comment, const char *fallback) const; - - /** - * Used to get the correct, translated singular or plural of a - * word. - * @param singular the singular form of the word, for example "file". - * @param plural the plural form of the word. Must contain a "%n" that will - * be replaced by the number @p n, for example "%n files" - * @param n the number - * @return the correct singular or plural for the selected language, - * depending on n - */ - TQString translate( const char *singular, const char *plural, - unsigned long n) const; - - /** - * Changes the current encoding. - * - * @param mibEnum The mib of the preferred codec - * - * @return True on success. - */ - bool setEncoding(int mibEnum); - - /** - * Changes the current language. The current language will be left - * unchanged if failed. It will force a reload of the country specific - * configuration as well. - * - * @param language The language code. - * - * @return True on success. - */ - bool setLanguage(const TQString & language); - - /** - * Changes the list of prefed languages for the locale. The first valid - * language in the list will be used, or the default (en_US) language - * will be used if non of the specified languages were available. - * - * @param languages The list of language codes. - * - * @return True if one of the specified languages were used. - */ - bool setLanguage(const TQStringList & languages); - - /** - * Changes the current country. The current country will be left - * unchanged if failed. It will force a reload of the country specific - * configuration. - * - * @param country The ISO 3166 country code. - * - * @return True on success. - */ - bool setCountry(const TQString & country); - - /** - * Various positions for where to place the positive or negative - * sign when they are related to a monetary value. - */ - enum SignPosition { ParensAround = 0, BeforeQuantityMoney = 1, - AfterQuantityMoney = 2, - BeforeMoney = 3, AfterMoney = 4 }; - - /** - * Returns what a decimal point should look like ("." or "," etc.) - * according to the current locale or user settings. - * - * @return The decimal symbol used by locale. - */ - TQString decimalSymbol() const; - - /** - * Returns what the thousands separator should look - * like ("," or "." etc.) - * according to the current locale or user settings. - * - * @return The thousands separator used by locale. - */ - TQString thousandsSeparator() const; - - /** - * Returns what the symbol denoting currency in the current locale - * as as defined by user settings should look like. - * - * @return The default currency symbol used by locale. - */ - TQString currencySymbol() const; - - /** - * Returns what a decimal point should look like ("." or "," etc.) - * for monetary values, according to the current locale or user - * settings. - * - * @return The monetary decimal symbol used by locale. - */ - TQString monetaryDecimalSymbol() const; - - /** - * Returns what a thousands separator for monetary values should - * look like ("," or " " etc.) according to the current locale or - * user settings. - * - * @return The monetary thousands separator used by locale. - */ - TQString monetaryThousandsSeparator() const; - - /** - * Returns what a positive sign should look like ("+", " ", etc.) - * according to the current locale or user settings. - * - * @return The positive sign used by locale. - */ - TQString positiveSign() const; - - /** - * Returns what a negative sign should look like ("-", etc.) - * according to the current locale or user settings. - * - * @return The negative sign used by locale. - */ - TQString negativeSign() const; - - /** - * The number of fractional digits to include in numeric/monetary - * values (usually 2). - * - * @return Default number of fractional digits used by locale. - */ - int fracDigits() const; - - /** - * If and only if the currency symbol precedes a positive value, - * this will be true. - * - * @return Where to print the currency symbol for positive numbers. - */ - bool positivePrefixCurrencySymbol() const; - - /** - * If and only if the currency symbol precedes a negative value, - * this will be true. - * - * @return True if the currency symbol precedes negative numbers. - */ - bool negativePrefixCurrencySymbol() const; - - /** - * Returns the position of a positive sign in relation to a - * monetary value. - * - * @return Where/how to print the positive sign. - * @see SignPosition - */ - SignPosition positiveMonetarySignPosition() const; - - /** - * Denotes where to place a negative sign in relation to a - * monetary value. - * - * @return Where/how to print the negative sign. - * @see SignPosition - */ - SignPosition negativeMonetarySignPosition() const; - - /** - * Given a double, converts that to a numeric string containing - * the localized monetary equivalent. - * - * e.g. given 123456, return "$ 123,456.00". - * - * @param num The number we want to format - * @param currency The currency symbol you want. - * @param digits Number of fractional digits, or -1 for the default - * value - * - * @return The number of money as a localized string - * @see fracDigits() - */ - TQString formatMoney(double num, - const TQString & currency = TQString::null, - int digits = -1) const; - - /** - * Given a double, converts that to a numeric string containing - * the localized numeric equivalent. - * - * e.g. given 123456.78F, return "123,456.78" (for some European country). - * If precision isn't specified, 2 is used. - * - * This function is a wrapper that is provided for convenience. - * - * @param num The number to convert - * @param precision Number of fractional digits used. - * - * @return The number as a localized string - * @see formatNumber(const TQString, bool, int) - */ - TQString formatNumber(double num, int precision = -1) const; - - /** - * @deprecated - * - * KDE 4.0: merge with formatNumber(const TQString int) - * - * calls formatNumber(numStr, 2) - */ - TQString formatNumber(const TQString &numStr) const KDE_DEPRECATED; - - /** - * Given a string representing a number, converts that to a numeric - * string containing the localized numeric equivalent. - * - * e.g. given 123456.78F, return "123,456.78" (for some European country). - * - * @param numStr The number to convert - * @param round Round fractional digits. - * @param precision Number of fractional digits used. - * - * @return The number as a localized string - * @since 3.5 - */ - TQString formatNumber(const TQString &numStr, bool round, int precision) const; - - /** - * Given an integer, converts that to a numeric string containing - * the localized numeric equivalent. - * - * e.g. given 123456L, return "123,456" (for some European country). - * - * @param num The number to convert - * - * @return The number as a localized string - * @since 3.2 - */ - TQString formatLong(long num) const; - - /** - * Use this to determine whether nouns are declined in - * locale's language. This property should remain - * read-only (no setter function) - * - * @return If nouns are declined - * @since 3.1 - */ - bool nounDeclension() const; - - /** - * Returns a string formatted to the current locale's conventions - * regarding dates. - * - * @param pDate The date to be formated. - * @param shortFormat True for non text dates. - * - * @return The date as a string - */ - TQString formatDate(const TQDate &pDate, bool shortFormat = false) const; - - /** - * Use this to determine whether in dates a possessive form of month - * name is preferred ("of January" rather than "January") - * - * @return If possessive form should be used - * @since 3.1 - */ - bool dateMonthNamePossessive() const; - - /** - * Returns a string formatted to the current locale's conventions - * regarding times. - * - * @param pTime The time to be formated. - * @param includeSecs if true, seconds are included in the output, - * otherwise only hours and minutes are formatted. - * @param isDuration if true, the given time is a duration, not a clock time. - * This means "am/pm" shouldn't be displayed. - * - * @return The time as a string - */ - TQString formatTime(const TQTime &pTime, bool includeSecs, bool isDuration /*=false*/) const; - - /** - * Returns a string formatted to the current locale's conventions - * regarding times. - * - * @param pTime The time to be formated. - * @param includeSecs if true, seconds are included in the output, - * otherwise only hours and minutes are formatted. - * - * @return The time as a string - */ - TQString formatTime(const TQTime &pTime, bool includeSecs = false) const; // BIC: merge with above - - /** - * Use this to determine if the user wants a 12 hour clock. - * - * @return If the user wants 12h clock - */ - bool use12Clock() const; - - /** - * @deprecated - * - * Please use the weekStartDay method instead. - * - * Use this to determine if the user wants the week to start on Monday. - * - * @return true if the week starts on Monday - */ - bool weekStartsMonday() const KDE_DEPRECATED; //### remove for KDE 4.0 - - /** - * Use this to determine which day is the first day of the week. - * - * @return an integer (Monday=1..Sunday=7) - * @since 3.1 - */ - int weekStartDay() const; - - /** - * @deprecated - * - * Returns a string containing the name of the month name used in the Gregorian calendar. - * - * @param i the month number of the year starting at 1/January. - * @param shortName we will return the short version of the string. - * - * @return The name of the month - * - * Typically the correct replacement for this deprecated class is - * calendar()->monthString(), which requires a TQDate (rather than an - * integer month) or both a month and a year. - * This will work across different calendars. - * Note that you also need to add - * \code - * #include <kcalendarsystem.h> - * \endcode - * to the applicable file. - */ - TQString monthName(int i, bool shortName = false) const KDE_DEPRECATED; - - /** - * @deprecated - * - * Returns a string containing the possessive form of the month name used in the Gregorian calendar. - * ("of January", "of February", etc.) - * It's needed in long format dates in some languages. - * - * @param i the month number of the year starting at 1/January. - * @param shortName we will return the short version of the string. - * - * @return The possessive form of the name of the month - * @since 3.1 - * - * Typically the correct replacement for this deprecated class is - * calendar()->monthNamePossessive(), which requires a TQDate (rather than - * an integer month) or both a month and a year. - * This will work across different calendars. - * Note that you also need to add - * \code - * #include <kcalendarsystem.h> - * \endcode - * to the applicable file. - */ - TQString monthNamePossessive(int i, bool shortName = false) const KDE_DEPRECATED; - - /** - * @deprecated use calendar()->weekDayName - * - * Returns a string containing the name of the week day used in the Gregorian calendar. - * - * @param i the day number of the week starting at 1/Monday. - * @param shortName we will return the short version of the string. - * - * @return The name of the day - */ - TQString weekDayName(int i, bool shortName = false) const KDE_DEPRECATED; - - /** - * Returns a pointer to the calendar system object. - * - * @return the current calendar system instance - * @since 3.2 - */ - const KCalendarSystem * calendar() const; - - /** - * Returns the name of the calendar system that is currently being - * used by the system. - * - * @return the name of the calendar system - * @since 3.2 - */ - TQString calendarType() const; - - /** - * Changes the current calendar system to the calendar specified. - * Currently "gregorian" and "hijri" are supported. If the calendar - * system specified is not found, gregorian will be used. - * - * @param calendarType the name of the calendar type - * @since 3.2 - */ - void setCalendar(const TQString & calendarType); - - /** - * Returns a string formated to the current locale's conventions - * regarding both date and time. - * - * @param pDateTime The date and time to be formated. - * @param shortFormat using the short date format. - * @param includeSecs using the short date format. - * - * @return The date and time as a string - */ - TQString formatDateTime(const TQDateTime &pDateTime, - bool shortFormat = true, - bool includeSecs = false) const; - - /** - * Converts a localized monetary string to a double. - * - * @param numStr the string we want to convert. - * @param ok the boolean that is set to false if it's not a number. - * If @p ok is 0, it will be ignored - * - * @return The string converted to a double - */ - double readMoney(const TQString &numStr, bool * ok = 0) const; - - /** - * Converts a localized numeric string to a double. - * - * @param numStr the string we want to convert. - * @param ok the boolean that is set to false if it's not a number. - * If @p ok is 0, it will be ignored - * - * @return The string converted to a double - */ - double readNumber(const TQString &numStr, bool * ok = 0) const; - - /** - * Converts a localized date string to a TQDate. - * The bool pointed by ok will be invalid if the date entered was not valid. - * - * @param str the string we want to convert. - * @param ok the boolean that is set to false if it's not a valid date. - * If @p ok is 0, it will be ignored - * - * @return The string converted to a QDate - */ - TQDate readDate(const TQString &str, bool* ok = 0) const; - - /** - * Converts a localized date string to a TQDate, using the specified format. - * You will usually not want to use this method. - */ - TQDate readDate( const TQString &intstr, const TQString &fmt, bool* ok = 0) const; - - enum ReadDateFlags { - NormalFormat = 1, - ShortFormat = 2 - }; - - /** - * Converts a localized date string to a TQDate. - * This method is stricter than readDate(str,&ok): it will either accept - * a date in full format or a date in short format, depending on @p flags. - * - * @param str the string we want to convert. - * @param flags whether the date string is to be in full format or in short format. - * @param ok the boolean that is set to false if it's not a valid date. - * If @p ok is 0, it will be ignored - * - * @return The string converted to a QDate - * @since 3.2 - */ - TQDate readDate(const TQString &str, ReadDateFlags flags, bool *ok = 0) const; - - /** - * Converts a localized time string to a TQTime. - * This method will try to parse it with seconds, then without seconds. - * The bool pointed to by @p ok will be set to false if the time entered was - * not valid. - * - * @param str the string we want to convert. - * @param ok the boolean that is set to false if it's not a valid time. - * If @p ok is 0, it will be ignored - * - * @return The string converted to a QTime - */ - TQTime readTime(const TQString &str, bool* ok = 0) const; - - enum ReadTimeFlags { - WithSeconds = 0, // default (no flag set) - WithoutSeconds = 1 - }; // (maybe use this enum as a bitfield, if adding independent features?) - /** - * Converts a localized time string to a TQTime. - * This method is stricter than readTime(str,&ok): it will either accept - * a time with seconds or a time without seconds. - * Use this method when the format is known by the application. - * - * @param str the string we want to convert. - * @param flags whether the time string is expected to contain seconds or not. - * @param ok the boolean that is set to false if it's not a valid time. - * If @p ok is 0, it will be ignored - * - * @return The string converted to a QTime - * @since 3.2 - */ - TQTime readTime(const TQString &str, ReadTimeFlags flags, bool *ok = 0) const; - - /** - * Returns the language used by this object. The domain AND the - * library translation must be available in this language. - * defaultLanguage() is returned by default, if no other available. - * - * @return The currently used language. - */ - TQString language() const; - - /** - * Returns the country code of the country where the user lives. - * defaultCountry() is returned by default, if no other available. - * - * @return The country code for the user. - */ - TQString country() const; - - /** - * Returns the preferred languages as ISO 639-1 codes. This means - * that information about country is removed. If the internal language - * code might be represented by more than one 639-1 code, they will all be - * listed (but only once). - * - * If the selected languages are "nn, nb, pt_BR", you will get: - * "nn, nb, pt". - * - * @return List of language codes - * - * @see languageList - */ - TQStringList languagesTwoAlpha() const; - - /** - * Returns the languages selected by user. The codes returned here is the - * internal language codes. - * - * @return List of language codes - * - * @see languagesTwoAlpha - */ - TQStringList languageList() const; - - /** - * Returns the user's preferred encoding. - * - * @return The name of the preferred encoding - * - * @see codecForEncoding - * @see encodingMib - */ - const char * encoding() const; - - /** - * Returns the user's preferred encoding. - * - * @return The Mib of the preferred encoding - * - * @see encoding - * @see codecForEncoding - */ - int encodingMib() const; - /** - * Returns the user's preferred encoding. Should never be NULL. - * - * @return The codec for the preferred encoding - * - * @see encoding - * @see encodingMib - */ - TQTextCodec * codecForEncoding() const; - - /** - * Returns the file encoding. - * - * @return The Mib of the file encoding - * - * @see TQFile::encodeName - * @see TQFile::decodeName - */ - int fileEncodingMib() const; - - /** - * Changes the current date format. - * - * The format of the date is a string which contains variables that will - * be replaced: - * @li %Y with the century (e.g. "19" for "1984") - * @li %y with the lower 2 digits of the year (e.g. "84" for "1984") - * @li %n with the month (January="1", December="12") - * @li %m with the month with two digits (January="01", December="12") - * @li %e with the day of the month (e.g. "1" on the first of march) - * @li %d with the day of the month with two digits(e.g. "01" on the first of march) - * @li %b with the short form of the month (e.g. "Jan" for January) - * @li %B with the long form of the month (e.g. "January") - * @li %a with the short form of the weekday (e.g. "Wed" for Wednesday) - * @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday) - * - * Everything else in the format string will be taken as is. - * For example, March 20th 1989 with the format "%y:%m:%d" results - * in "89:03:20". - * - * @param format The new date format - */ - void setDateFormat(const TQString & format); - /** - * Changes the current short date format. - * - * The format of the date is a string which contains variables that will - * be replaced: - * @li %Y with the century (e.g. "19" for "1984") - * @li %y with the lower 2 digits of the year (e.g. "84" for "1984") - * @li %n with the month (January="1", December="12") - * @li %m with the month with two digits (January="01", December="12") - * @li %e with the day of the month (e.g. "1" on the first of march) - * @li %d with the day of the month with two digits(e.g. "01" on the first of march) - * @li %b with the short form of the month (e.g. "Jan" for January) - * @li %B with the long form of the month (e.g. "January") - * @li %a with the short form of the weekday (e.g. "Wed" for Wednesday) - * @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday) - * - * Everything else in the format string will be taken as is. - * For example, March 20th 1989 with the format "%y:%m:%d" results - * in "89:03:20". - * - * @param format The new short date format - */ - void setDateFormatShort(const TQString & format); - /** - * Changes the form of month name used in dates. - * - * @param possessive True if possessive forms should be used - * @since 3.1 - */ - void setDateMonthNamePossessive(bool possessive); - /** - * Changes the current time format. - * - * The format of the time is string a which contains variables that will - * be replaced: - * @li %H with the hour in 24h format and 2 digits (e.g. 5pm is "17", 5am is "05") - * @li %k with the hour in 24h format and one digits (e.g. 5pm is "17", 5am is "5") - * @li %I with the hour in 12h format and 2 digits (e.g. 5pm is "05", 5am is "05") - * @li %l with the hour in 12h format and one digits (e.g. 5pm is "5", 5am is "5") - * @li %M with the minute with 2 digits (e.g. the minute of 07:02:09 is "02") - * @li %S with the seconds with 2 digits (e.g. the minute of 07:02:09 is "09") - * @li %p with pm or am (e.g. 17.00 is "pm", 05.00 is "am") - * - * Everything else in the format string will be taken as is. - * For example, 5.23pm with the format "%H:%M" results - * in "17:23". - * - * @param format The new time format - */ - void setTimeFormat(const TQString & format); - - /** - * @deprecated - * - * Please use setWeekStartDay instead. - * - * Changes how KLocale defines the first day in week. - * - * @param start True if Monday is the first day in the week - */ - void setWeekStartsMonday(bool start) KDE_DEPRECATED; //### remove for KDE 4.0 - - /** - * Changes how KLocale defines the first day in week. - * - * @param day first day of the week (Monday=1..Sunday=7) as integer - * @since 3.1 - */ - void setWeekStartDay(int day); - /** - * Returns the currently selected date format. - * - * @return Current date format. - * @see setDateFormat() - */ - TQString dateFormat() const; - /** - * Returns the currently selected short date format. - * - * @return Current short date format. - * @see setDateFormatShort() - */ - TQString dateFormatShort() const; - /** - * Returns the currently selected time format. - * - * @return Current time format. - * @see setTimeFormat() - */ - TQString timeFormat() const; - - /** - * Changes the symbol used to identify the decimal pointer. - * - * @param symbol The new decimal symbol. - */ - void setDecimalSymbol(const TQString & symbol); - /** - * Changes the separator used to group digits when formating numbers. - * - * @param separator The new thousands separator. - */ - void setThousandsSeparator(const TQString & separator); - /** - * Changes the sign used to identify a positive number. Normally this is - * left blank. - * - * @param sign Sign used for positive numbers. - */ - void setPositiveSign(const TQString & sign); - /** - * Changes the sign used to identify a negative number. - * - * @param sign Sign used for negative numbers. - */ - void setNegativeSign(const TQString & sign); - /** - * Changes the sign position used for positive monetary values. - * - * @param signpos The new sign position - */ - void setPositiveMonetarySignPosition(SignPosition signpos); - /** - * Changes the sign position used for negative monetary values. - * - * @param signpos The new sign position - */ - void setNegativeMonetarySignPosition(SignPosition signpos); - /** - * Changes the position where the currency symbol should be printed for - * positive monetary values. - * - * @param prefix True if the currency symbol should be prefixed instead of - * postfixed - */ - void setPositivePrefixCurrencySymbol(bool prefix); - /** - * Changes the position where the currency symbol should be printed for - * negative monetary values. - * - * @param prefix True if the currency symbol should be prefixed instead of - * postfixed - */ - void setNegativePrefixCurrencySymbol(bool prefix); - /** - * Changes the number of digits used when formating numbers. - * - * @param digits The default number of digits to use. - */ - void setFracDigits(int digits); - /** - * Changes the separator used to group digits when formating monetary values. - * - * @param separator The new thousands separator. - */ - void setMonetaryThousandsSeparator(const TQString & separator); - /** - * Changes the symbol used to identify the decimal pointer for monetary - * values. - * - * @param symbol The new decimal symbol. - */ - void setMonetaryDecimalSymbol(const TQString & symbol); - /** - * Changes the current currency symbol. - * - * @param symbol The new currency symbol - */ - void setCurrencySymbol(const TQString & symbol); - - /** - * Returns the preferred page size for printing. - * - * @return The preferred page size, cast it to TQPrinter::PageSize - */ - int pageSize() const; - - /** - * Changes the preferred page size when printing. - * - * @param paperFormat the new preferred page size in the format TQPrinter::PageSize - */ - void setPageSize(int paperFormat); - - /** - * The Metric system will give you information in mm, while the - * Imperial system will give you information in inches. - */ - enum MeasureSystem { Metric, Imperial }; - - /** - * Returns which measuring system we use. - * - * @return The preferred measuring system - */ - MeasureSystem measureSystem() const; - - /** - * Changes the preferred measuring system. - * - * @return value The preferred measuring system - */ - void setMeasureSystem(MeasureSystem value); - - /** - * Adds another catalog to search for translation lookup. - * This function is useful for extern libraries and/or code, - * that provide there own messages. - * - * If the catalog does not exist for the chosen language, - * it will be ignored and en_US will be used. - * - * @param catalog The catalog to add. - */ - void insertCatalogue(const TQString& catalog); - - /** - * Removes a catalog for translation lookup. - * @param catalog The catalog to remove. - * @see insertCatalogue() - */ - void removeCatalogue(const TQString &catalog); - - /** - * Sets the active catalog for translation lookup. - * @param catalog The catalog to activate. - */ - void setActiveCatalogue(const TQString &catalog); - - /** - * Translates a message as a QTranslator is supposed to. - * The parameters are similar to i18n(), but the result - * value has other semantics (it can be TQString::null) - * @since 3.1 - **/ - TQString translateQt(const char *context, - const char *sourceText, - const char *message) const; - - /** - * Returns list of all known ISO 639-1 codes. - * @return a list of all language codes - * @since 3.1 - */ - TQStringList allLanguagesTwoAlpha() const; - - /** - * Convert a ISO 639-1 code to a human readable form. - * @param code the language ISO 639-1 code - * @return the human readable form - * @since 3.1 - */ - TQString twoAlphaToLanguageName(const TQString &code) const; - - /** - * Returns list of all known country codes. - * @return a list of all country codes - * @since 3.1 - */ - TQStringList allCountriesTwoAlpha() const; - - /** - * Convert a country code to a human readable form. - * @param code the country code - * @return the human readable form of the country name - * @since 3.1 - */ - TQString twoAlphaToCountryName(const TQString &code) const; - - /** - * Returns the parts of the parameter str understood as language setting - * the format is language_COUNTRY.charset - * - * @param str The string to split. - * @param language This will be set to the language part of the string. - * @param country This will be set to the country part of the string. - * @param charset This will be set to the charset part of the string. - */ - static void splitLocale(const TQString & str, - TQString & language, - TQString & country, - TQString & charset); - - /** - * Use this as main catalog for *all* KLocales, if not the appname - * will be used. This function is best to be the very first instruction - * in your program's main function as it only has an effect before the - * first KLocale object is created. - * - * @param catalog Catalogue to override all other main catalogues. - */ - static void setMainCatalogue(const char *catalog); - - /** - * Finds localized resource in resourceDir( rtype ) + \<lang> + fname. - * - * @param fname relative path to find - * @param rtype resource type to use - */ - static TQString langLookup(const TQString &fname, const char *rtype = "html"); - - /** - * Returns the name of the internal language. - * - * @return Name of the default language - */ - static TQString defaultLanguage(); - - /** - * Returns the name of the default country. - * - * @return Name of the default country - */ - static TQString defaultCountry(); - - - /** - * @internal Called from KConfigBackend to initialize language. - */ - static TQString _initLanguage(KConfigBase *config); - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated - * use formatMoney(double) - */ - TQString formatMoney(const TQString &numStr) const KDE_DEPRECATED; - - /** - * @deprecated - * Use languageList() - * - * @return String containing language codes separated by colons - */ - TQString languages() const KDE_DEPRECATED; - - /** - * @deprecated - * @return True - */ - bool setCharset(const TQString & charset) KDE_DEPRECATED; - - /** - * @deprecated - * @see encoding - */ - TQString charset() const KDE_DEPRECATED; - -protected: - /** - * @internal Creates a KLocale object for KGlobal and inits the locale - * pointer. - */ - static void initInstance(); - -private: - /** - * @internal Inits the localization part of the instance with the config - * object. - * - * @param config The configuration object used for init. - */ - void initFormat(KConfig *config); - - /** - * @internal Initializes the catalogs appname, kdelibs and kio for all chosen languages. - * - * @param config The configuration object used for init - * @param useEnv True if we should use environment variables - */ - void initMainCatalogues(const TQString & catalog); - - /** - * @internal Initializes the list of valid languages from the user's point of view. This is the list of - * languages that the user picks in kcontrol. The config object should be valid and contain the global - * entries. - * - * @param config The configuration object used for init - * @param useEnv True if we should use environment variables - */ - void initLanguageList(KConfig * config, bool useEnv); - - /** - * @internal Figures out which encoding the user prefers. - * - * @param config The configuration object used for init - */ - void initEncoding(KConfig * config); - - /** - * @internal Figures out which encoding the user prefers for filenames - * and sets up the appropriate TQFile encoding and decoding functions. - */ - void initFileNameEncoding(KConfig *config); - - /** - * @internal A TQFile filename encoding function (TQFile::encodeFn). - */ -#ifdef USE_QT3 - static TQCString encodeFileNameUTF8( const TQString & fileName ); -#endif // USE_QT3 -#ifdef USE_QT4 - static QByteArray encodeFileNameUTF8( const QString & fileName ); -#endif // USE_QT4 - - /** - * @internal TQFile filename decoding function (TQFile::decodeFn). - */ -#ifdef USE_QT3 - static TQString decodeFileNameUTF8( const TQCString & localFileName ); -#endif // USE_QT3 -#ifdef USE_QT4 - static QString decodeFileNameUTF8( const QByteArray & localFileName ); -#endif // USE_QT4 - - /** - * @internal Changes the file name of the catalog to the correct - * one. - */ - void initCatalogue( KCatalogue & catalog ); - - /** - * @internal Ensures that the format configuration is read. - */ - void doFormatInit() const; - - /** - * @internal Reads the format configuration from disk. - */ - void initFormat(); - - /** - * @internal function used by the two translate versions - */ - TQString translate_priv(const char *index, - const char *text, - const char ** original = 0, - int* pluralType = 0) const; - - /** - * @internal function used to determine if we are using the en_US translation - */ - bool useDefaultLanguage() const; - - /** - * @internal Checks if the specified language is installed - */ - bool isLanguageInstalled(const TQString & language) const; - - /** - * @internal evaluate the list of catalogs and check that all instances for all languages are loaded - * and that they are sorted according to the catalog names - */ - void updateCatalogues( ); - - /** - * @internal Find the plural type for all loaded catalogs - */ - void initPluralTypes( ); - /** - * @internal Find the plural type for a language. Look this up in the corresponding kdelibs.po. - * - * @param language The language to examine - */ - int pluralType( const TQString & language ); - - /** - * @internal Find the plural type information for a given catalog. This catalog will be a kdelibs.mo. Method - * just exists to make code more readable. - * - * @param language The language to examine - */ - int pluralType( const KCatalogue& catalog ); - /** - * @internal Find catalog for given language and given catalog name. - * - * @param language language of the catalog - * @param name name of the catalog - */ - // const KCatalogue * catalog( const TQString & language, const TQString & name ); - - - /** - * @internal Retrieves the file name of the catalog, or TQString::null - * if not found. - */ - static TQString catalogueFileName(const TQString & language, - const KCatalogue & catalog); -public: - /** - * @internal Checks whether or not theFind catalog for given language and given catalog name. - * - * @param language language to check - */ - bool isApplicationTranslatedInto( const TQString & language); - -private: - // Numbers and money - TQString m_decimalSymbol; - TQString m_thousandsSeparator; - TQString m_currencySymbol; - TQString m_monetaryDecimalSymbol; - TQString m_monetaryThousandsSeparator; - TQString m_positiveSign; - TQString m_negativeSign; - int m_fracDigits; - SignPosition m_positiveMonetarySignPosition; - SignPosition m_negativeMonetarySignPosition; - - // Date and time - TQString m_timeFormat; - TQString m_dateFormat; - TQString m_dateFormatShort; - - TQString m_language; - TQString m_country; - - bool m_weekStartsMonday; //### remove for KDE 4.0 - bool m_positivePrefixCurrencySymbol; - bool m_negativePrefixCurrencySymbol; - - KLocalePrivate *d; -}; - -#endif diff --git a/kdecore/klockfile.cpp b/kdecore/klockfile.cpp deleted file mode 100644 index 3bd6edb30..000000000 --- a/kdecore/klockfile.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2004 Waldo Bastian <bastian@kde.org> - - 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 <klockfile.h> - -#include <config.h> - -#include <sys/types.h> -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#include <signal.h> -#include <errno.h> -#include <stdlib.h> -#include <unistd.h> - -#include <tqfile.h> -#include <tqtextstream.h> - -#include <kde_file.h> -#include <kapplication.h> -#include <kcmdlineargs.h> -#include <kglobal.h> -#include <ktempfile.h> - -// TODO: http://www.spinnaker.de/linux/nfs-locking.html -// TODO: Make regression test - -class KLockFile::KLockFilePrivate { -public: - TQString file; - int staleTime; - bool isLocked; - bool recoverLock; - bool linkCountSupport; - TQTime staleTimer; - KDE_struct_stat statBuf; - int pid; - TQString hostname; - TQString instance; - TQString lockRecoverFile; -}; - - -// 30 seconds -KLockFile::KLockFile(const TQString &file) -{ - d = new KLockFilePrivate(); - d->file = file; - d->staleTime = 30; - d->isLocked = false; - d->recoverLock = false; - d->linkCountSupport = true; -} - -KLockFile::~KLockFile() -{ - unlock(); - delete d; -} - -int -KLockFile::staleTime() const -{ - return d->staleTime; -} - - -void -KLockFile::setStaleTime(int _staleTime) -{ - d->staleTime = _staleTime; -} - -static bool statResultIsEqual(KDE_struct_stat &st_buf1, KDE_struct_stat &st_buf2) -{ -#define FIELD_EQ(what) (st_buf1.what == st_buf2.what) - return FIELD_EQ(st_dev) && FIELD_EQ(st_ino) && - FIELD_EQ(st_uid) && FIELD_EQ(st_gid) && FIELD_EQ(st_nlink); -#undef FIELD_EQ -} - -static bool testLinkCountSupport(const TQCString &fileName) -{ - KDE_struct_stat st_buf; - // Check if hardlinks raise the link count at all? - ::link( fileName, fileName+".test" ); - int result = KDE_lstat( fileName, &st_buf ); - ::unlink( fileName+".test" ); - return ((result == 0) && (st_buf.st_nlink == 2)); -} - -static KLockFile::LockResult lockFile(const TQString &lockFile, KDE_struct_stat &st_buf, bool &linkCountSupport) -{ - TQCString lockFileName = TQFile::encodeName( lockFile ); - int result = KDE_lstat( lockFileName, &st_buf ); - if (result == 0) - return KLockFile::LockFail; - - KTempFile uniqueFile(lockFile, TQString::null, 0644); - uniqueFile.setAutoDelete(true); - if (uniqueFile.status() != 0) - return KLockFile::LockError; - - char hostname[256]; - hostname[0] = 0; - gethostname(hostname, 255); - hostname[255] = 0; - TQCString instanceName = KCmdLineArgs::appName(); - - (*(uniqueFile.textStream())) << TQString::number(getpid()) << endl - << instanceName << endl - << hostname << endl; - uniqueFile.close(); - - TQCString uniqueName = TQFile::encodeName( uniqueFile.name() ); - -#ifdef Q_OS_UNIX - // Create lock file - result = ::link( uniqueName, lockFileName ); - if (result != 0) - return KLockFile::LockError; - - if (!linkCountSupport) - return KLockFile::LockOK; -#else - //TODO for win32 - return KLockFile::LockOK; -#endif - - KDE_struct_stat st_buf2; - result = KDE_lstat( uniqueName, &st_buf2 ); - if (result != 0) - return KLockFile::LockError; - - result = KDE_lstat( lockFileName, &st_buf ); - if (result != 0) - return KLockFile::LockError; - - if (!statResultIsEqual(st_buf, st_buf2) || S_ISLNK(st_buf.st_mode) || S_ISLNK(st_buf2.st_mode)) - { - // SMBFS supports hardlinks by copying the file, as a result the above test will always fail - if ((st_buf.st_nlink == 1) && (st_buf2.st_nlink == 1) && (st_buf.st_ino != st_buf2.st_ino)) - { - linkCountSupport = testLinkCountSupport(uniqueName); - if (!linkCountSupport) - return KLockFile::LockOK; // Link count support is missing... assume everything is OK. - } - return KLockFile::LockFail; - } - - return KLockFile::LockOK; -} - -static KLockFile::LockResult deleteStaleLock(const TQString &lockFile, KDE_struct_stat &st_buf, bool &linkCountSupport) -{ - // This is dangerous, we could be deleting a new lock instead of - // the old stale one, let's be very careful - - // Create temp file - KTempFile ktmpFile(lockFile); - if (ktmpFile.status() != 0) - return KLockFile::LockError; - - TQCString lckFile = TQFile::encodeName(lockFile); - TQCString tmpFile = TQFile::encodeName(ktmpFile.name()); - ktmpFile.close(); - ktmpFile.unlink(); - -#ifdef Q_OS_UNIX - // link to lock file - if (::link(lckFile, tmpFile) != 0) - return KLockFile::LockFail; // Try again later -#else - //TODO for win32 - return KLockFile::LockOK; -#endif - - // check if link count increased with exactly one - // and if the lock file still matches - KDE_struct_stat st_buf1; - KDE_struct_stat st_buf2; - memcpy(&st_buf1, &st_buf, sizeof(KDE_struct_stat)); - st_buf1.st_nlink++; - if ((KDE_lstat(tmpFile, &st_buf2) == 0) && statResultIsEqual(st_buf1, st_buf2)) - { - if ((KDE_lstat(lckFile, &st_buf2) == 0) && statResultIsEqual(st_buf1, st_buf2)) - { - // - - if yes, delete lock file, delete temp file, retry lock - qWarning("WARNING: deleting stale lockfile %s", lckFile.data()); - ::unlink(lckFile); - ::unlink(tmpFile); - return KLockFile::LockOK; - } - } - - // SMBFS supports hardlinks by copying the file, as a result the above test will always fail - if (linkCountSupport) - { - linkCountSupport = testLinkCountSupport(tmpFile); - } - - if (!linkCountSupport && - (KDE_lstat(lckFile, &st_buf2) == 0) && - statResultIsEqual(st_buf, st_buf2)) - { - // Without support for link counts we will have a little race condition - qWarning("WARNING: deleting stale lockfile %s", lckFile.data()); - ::unlink(lckFile); - ::unlink(tmpFile); - return KLockFile::LockOK; - } - - // Failed to delete stale lock file - qWarning("WARNING: Problem deleting stale lockfile %s", lckFile.data()); - ::unlink(tmpFile); - return KLockFile::LockFail; -} - - -KLockFile::LockResult KLockFile::lock(int options) -{ - if (d->isLocked) - return KLockFile::LockOK; - - KLockFile::LockResult result; - int hardErrors = 5; - int n = 5; - while(true) - { - KDE_struct_stat st_buf; - result = lockFile(d->file, st_buf, d->linkCountSupport); - if (result == KLockFile::LockOK) - { - d->staleTimer = TQTime(); - break; - } - else if (result == KLockFile::LockError) - { - d->staleTimer = TQTime(); - if (--hardErrors == 0) - { - break; - } - } - else // KLockFile::Fail - { - if (!d->staleTimer.isNull() && !statResultIsEqual(d->statBuf, st_buf)) - d->staleTimer = TQTime(); - - if (!d->staleTimer.isNull()) - { - bool isStale = false; - if ((d->pid > 0) && !d->hostname.isEmpty()) - { - // Check if hostname is us - char hostname[256]; - hostname[0] = 0; - gethostname(hostname, 255); - hostname[255] = 0; - - if (d->hostname == hostname) - { - // Check if pid still exists - int res = ::kill(d->pid, 0); - if ((res == -1) && (errno == ESRCH)) - isStale = true; - } - } - if (d->staleTimer.elapsed() > (d->staleTime*1000)) - isStale = true; - - if (isStale) - { - if ((options & LockForce) == 0) - return KLockFile::LockStale; - - result = deleteStaleLock(d->file, d->statBuf, d->linkCountSupport); - - if (result == KLockFile::LockOK) - { - // Lock deletion successful - d->staleTimer = TQTime(); - continue; // Now try to get the new lock - } - else if (result != KLockFile::LockFail) - { - return result; - } - } - } - else - { - memcpy(&(d->statBuf), &st_buf, sizeof(KDE_struct_stat)); - d->staleTimer.start(); - - d->pid = -1; - d->hostname = TQString::null; - d->instance = TQString::null; - - TQFile file(d->file); - if (file.open(IO_ReadOnly)) - { - TQTextStream ts(&file); - if (!ts.atEnd()) - d->pid = ts.readLine().toInt(); - if (!ts.atEnd()) - d->instance = ts.readLine(); - if (!ts.atEnd()) - d->hostname = ts.readLine(); - } - } - } - - if ((options & LockNoBlock) != 0) - break; - - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = n*((KApplication::random() % 200)+100); - if (n < 2000) - n = n * 2; - -#ifdef Q_OS_UNIX - select(0, 0, 0, 0, &tv); -#else - //TODO for win32 -#endif - } - if (result == LockOK) - d->isLocked = true; - return result; -} - -bool KLockFile::isLocked() const -{ - return d->isLocked; -} - -void KLockFile::unlock() -{ - if (d->isLocked) - { - ::unlink(TQFile::encodeName(d->file)); - d->isLocked = false; - } -} - -bool KLockFile::getLockInfo(int &pid, TQString &hostname, TQString &appname) -{ - if (d->pid == -1) - return false; - pid = d->pid; - hostname = d->hostname; - appname = d->instance; - return true; -} diff --git a/kdecore/klockfile.h b/kdecore/klockfile.h deleted file mode 100644 index fac66831a..000000000 --- a/kdecore/klockfile.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2004 Waldo Bastian <bastian@kde.org> - - 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 _KLOCKFILE_H_ -#define _KLOCKFILE_H_ - -#include <tqstring.h> -#include <tqdatetime.h> - -#include <ksharedptr.h> -/** - * The KLockFile class provides NFS safe lockfiles. - * - * @author Waldo Bastian <bastian@kde.org> - * @since 3.3 - */ -class KDECORE_EXPORT KLockFile : public KShared -{ -public: - typedef KSharedPtr<KLockFile> Ptr; - - KLockFile(const TQString &file); - - /** - * Destroys the object, releasing the lock if held - **/ - ~KLockFile(); - - /** - * Possible return values of the lock function. - */ - enum LockResult { - /** - * Lock was acquired successfully - */ - LockOK = 0, - - /** - * The lock could not be acquired because it is held by another process - */ - LockFail, - - /** - * The lock could not be acquired due to an error - */ - LockError, - - /** - * A stale lock has been detected - */ - LockStale - }; - - enum LockOptions { - /** - * Return immediately, do not wait for the lock to become available - */ - LockNoBlock = 1, - - /** - * Automatically remove a lock when a lock is detected that is stale - * for more than staleTime() seconds. - */ - LockForce = 2 - }; - - /** - * Attempt to acquire the lock - * - * @param options A set of @ref LockOptions OR'ed together. - */ - LockResult lock(int options=0); - - /** - * Returns whether the lock is held or not - */ - bool isLocked() const; - - /** - * Release the lock - */ - void unlock(); - - /** - * Return the time in seconds after which a lock is considered stale - * The default is 30. - */ - int staleTime() const; - - /** - * Set the time in seconds after which a lock is considered stale - */ - void setStaleTime(int _staleTime); - - /** - * Returns the pid, hostname and appname of the process holding - * the lock after the lock functon has returned with LockStale. - * @returns false if the pid and hostname could not be determined - */ - bool getLockInfo(int &pid, TQString &hostname, TQString &appname); - -private: - class KLockFilePrivate; - KLockFilePrivate *d; -}; - -#endif diff --git a/kdecore/kmacroexpander.cpp b/kdecore/kmacroexpander.cpp deleted file mode 100644 index c7717029c..000000000 --- a/kdecore/kmacroexpander.cpp +++ /dev/null @@ -1,529 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (c) 2002-2003 Oswald Buddenhagen <ossi@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - - 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. -*/ - -#include <kmacroexpander.h> - -#include <tqvaluestack.h> -#include <tqregexp.h> - -KMacroExpanderBase::KMacroExpanderBase( TQChar c ) -{ - escapechar = c; -} - -KMacroExpanderBase::~KMacroExpanderBase() -{ -} - -void -KMacroExpanderBase::setEscapeChar( TQChar c ) -{ - escapechar = c; -} - -TQChar -KMacroExpanderBase::escapeChar() const -{ - return escapechar; -} - -void KMacroExpanderBase::expandMacros( TQString &str ) -{ - uint pos; - int len; - TQChar ec( escapechar ); - TQStringList rst; - TQString rsts; - - for (pos = 0; pos < str.length(); ) { - if (ec != (QChar)0) { - if (str.tqunicode()[pos] != ec) - goto nohit; - if (!(len = expandEscapedMacro( str, pos, rst ))) - goto nohit; - } else { - if (!(len = expandPlainMacro( str, pos, rst ))) - goto nohit; - } - if (len < 0) { - pos -= len; - continue; - } - rsts = rst.join( " " ); - rst.clear(); - str.replace( pos, len, rsts ); - pos += rsts.length(); - continue; - nohit: - pos++; - } -} - - -namespace KMacroExpander { - - /** @intern Quoting state of the expander code. Not available publicly. */ - enum Quoting { noquote, singlequote, doublequote, dollarquote, - paren, subst, group, math }; - typedef struct { - Quoting current; - bool dquote; - } State; - typedef struct { - TQString str; - uint pos; - } Save; - -} - -using namespace KMacroExpander; - -bool KMacroExpanderBase::expandMacrosShellQuote( TQString &str, uint &pos ) -{ - int len; - uint pos2; - TQChar ec( escapechar ); - State state = { noquote, false }; - TQValueStack<State> sstack; - TQValueStack<Save> ostack; - TQStringList rst; - TQString rsts; - - while (pos < str.length()) { - TQChar cc( str.tqunicode()[pos] ); - if (ec != (QChar)0) { - if (cc != ec) - goto nohit; - if (!(len = expandEscapedMacro( str, pos, rst ))) - goto nohit; - } else { - if (!(len = expandPlainMacro( str, pos, rst ))) - goto nohit; - } - if (len < 0) { - pos -= len; - continue; - } - if (state.dquote) { - rsts = rst.join( " " ); - rsts.replace( TQRegExp("([$`\"\\\\])"), "\\\\1" ); - } else if (state.current == dollarquote) { - rsts = rst.join( " " ); - rsts.replace( TQRegExp("(['\\\\])"), "\\\\1" ); - } else if (state.current == singlequote) { - rsts = rst.join( " " ); - rsts.replace( '\'', "'\\''"); - } else { - if (rst.isEmpty()) { - str.remove( pos, len ); - continue; - } else { - rsts = "'"; -#if 0 // this could pay off if join() would be cleverer and the strings were long - for (TQStringList::Iterator it = rst.begin(); it != rst.end(); ++it) - (*it).replace( '\'', "'\\''" ); - rsts += rst.join( "' '" ); -#else - for (TQStringList::ConstIterator it = rst.begin(); it != rst.end(); ++it) { - if (it != rst.begin()) - rsts += "' '"; - TQString trsts( *it ); - trsts.replace( '\'', "'\\''" ); - rsts += trsts; - } -#endif - rsts += "'"; - } - } - rst.clear(); - str.replace( pos, len, rsts ); - pos += rsts.length(); - continue; - nohit: - if (state.current == singlequote) { - if (cc == (QChar)'\'') - state = sstack.pop(); - } else if (cc == (QChar)'\\') { - // always swallow the char -> prevent anomalies due to expansion - pos += 2; - continue; - } else if (state.current == dollarquote) { - if (cc == (QChar)'\'') - state = sstack.pop(); - } else if (cc == (QChar)'$') { - cc = str[++pos]; - if (cc == (QChar)'(') { - sstack.push( state ); - if (str[pos + 1] == (QChar)'(') { - Save sav = { str, pos + 2 }; - ostack.push( sav ); - state.current = math; - pos += 2; - continue; - } else { - state.current = paren; - state.dquote = false; - } - } else if (cc == (QChar)'{') { - sstack.push( state ); - state.current = subst; - } else if (!state.dquote) { - if (cc == (QChar)'\'') { - sstack.push( state ); - state.current = dollarquote; - } else if (cc == (QChar)'"') { - sstack.push( state ); - state.current = doublequote; - state.dquote = true; - } - } - // always swallow the char -> prevent anomalies due to expansion - } else if (cc == (QChar)'`') { - str.replace( pos, 1, "$( " ); // add space -> avoid creating $(( - pos2 = pos += 3; - for (;;) { - if (pos2 >= str.length()) { - pos = pos2; - return false; - } - cc = str.tqunicode()[pos2]; - if (cc == (QChar)'`') - break; - if (cc == (QChar)'\\') { - cc = str[++pos2]; - if (cc == (QChar)'$' || cc == (QChar)'`' || cc == (QChar)'\\' || - (cc == (QChar)'"' && state.dquote)) - { - str.remove( pos2 - 1, 1 ); - continue; - } - } - pos2++; - } - str[pos2] = ')'; - sstack.push( state ); - state.current = paren; - state.dquote = false; - continue; - } else if (state.current == doublequote) { - if (cc == (QChar)'"') - state = sstack.pop(); - } else if (cc == (QChar)'\'') { - if (!state.dquote) { - sstack.push( state ); - state.current = singlequote; - } - } else if (cc == (QChar)'"') { - if (!state.dquote) { - sstack.push( state ); - state.current = doublequote; - state.dquote = true; - } - } else if (state.current == subst) { - if (cc == (QChar)'}') - state = sstack.pop(); - } else if (cc == (QChar)')') { - if (state.current == math) { - if (str[pos + 1] == (QChar)')') { - state = sstack.pop(); - pos += 2; - } else { - // false hit: the $(( was a $( ( in fact - // ash does not care, but bash does - pos = ostack.top().pos; - str = ostack.top().str; - ostack.pop(); - state.current = paren; - state.dquote = false; - sstack.push( state ); - } - continue; - } else if (state.current == paren) - state = sstack.pop(); - else - break; - } else if (cc == (QChar)'}') { - if (state.current == KMacroExpander::group) - state = sstack.pop(); - else - break; - } else if (cc == (QChar)'(') { - sstack.push( state ); - state.current = paren; - } else if (cc == (QChar)'{') { - sstack.push( state ); - state.current = KMacroExpander::group; - } - pos++; - } - return sstack.empty(); -} - -bool KMacroExpanderBase::expandMacrosShellQuote( TQString &str ) -{ - uint pos = 0; - return expandMacrosShellQuote( str, pos ) && pos == str.length(); -} - -int KMacroExpanderBase::expandPlainMacro( const TQString &, uint, TQStringList & ) -{ qFatal( "KMacroExpanderBase::expandPlainMacro called!" ); return 0; } - -int KMacroExpanderBase::expandEscapedMacro( const TQString &, uint, TQStringList & ) -{ qFatal( "KMacroExpanderBase::expandEscapedMacro called!" ); return 0; } - - -////////////////////////////////////////////////// - -template<class KT,class VT> -class KMacroMapExpander : public KMacroExpanderBase { - -public: - KMacroMapExpander( const TQMap<KT,VT> &map, TQChar c = '%' ) : - KMacroExpanderBase( c ), macromap( map ) {} - -protected: - virtual int expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ); - virtual int expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ); - -private: - TQMap<KT,VT> macromap; -}; - -static TQStringList &operator+=( TQStringList &s, const TQString &n) { s << n; return s; } - -//////// - -static bool -isIdentifier( uint c ) -{ - return c == '_' || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); -} - -//////// - -template<class VT> -class KMacroMapExpander<TQChar,VT> : public KMacroExpanderBase { - -public: - KMacroMapExpander( const TQMap<TQChar,VT> &map, TQChar c = '%' ) : - KMacroExpanderBase( c ), macromap( map ) {} - -protected: - virtual int expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ); - virtual int expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ); - -private: - TQMap<TQChar,VT> macromap; -}; - -template<class VT> -int -KMacroMapExpander<TQChar,VT>::expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - TQMapConstIterator<TQChar,VT> it = macromap.find(str[pos]); - if (it != macromap.end()) { - ret += it.data(); - return 1; - } - return 0; -} - -template<class VT> -int -KMacroMapExpander<TQChar,VT>::expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (str[pos + 1] == escapeChar()) { - ret += TQString( escapeChar() ); - return 2; - } - TQMapConstIterator<TQChar,VT> it = macromap.find(str[pos+1]); - if (it != macromap.end()) { - ret += it.data(); - return 2; - } - - return 0; -} - -template<class VT> -class KMacroMapExpander<TQString,VT> : public KMacroExpanderBase { - -public: - KMacroMapExpander( const TQMap<TQString,VT> &map, TQChar c = '%' ) : - KMacroExpanderBase( c ), macromap( map ) {} - -protected: - virtual int expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ); - virtual int expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ); - -private: - TQMap<TQString,VT> macromap; -}; - -template<class VT> -int -KMacroMapExpander<TQString,VT>::expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (isIdentifier( str[pos - 1].tqunicode() )) - return 0; - uint sl; - for (sl = 0; isIdentifier( str[pos + sl].tqunicode() ); sl++); - if (!sl) - return 0; - TQMapConstIterator<TQString,VT> it = - macromap.find( TQConstString( str.tqunicode() + pos, sl ).string() ); - if (it != macromap.end()) { - ret += it.data(); - return sl; - } - return 0; -} - -template<class VT> -int -KMacroMapExpander<TQString,VT>::expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (str[pos + 1] == escapeChar()) { - ret += TQString( escapeChar() ); - return 2; - } - uint sl, rsl, rpos; - if (str[pos + 1] == (QChar)'{') { - rpos = pos + 2; - for (sl = 0; str[rpos + sl] != (QChar)'}'; sl++) - if (rpos + sl >= str.length()) - return 0; - rsl = sl + 3; - } else { - rpos = pos + 1; - for (sl = 0; isIdentifier( str[rpos + sl].tqunicode() ); sl++); - rsl = sl + 1; - } - if (!sl) - return 0; - TQMapConstIterator<TQString,VT> it = - macromap.find( TQConstString( str.tqunicode() + rpos, sl ).string() ); - if (it != macromap.end()) { - ret += it.data(); - return rsl; - } - return 0; -} - -//////////// - -int -KCharMacroExpander::expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (expandMacro( str[pos], ret )) - return 1; - return 0; -} - -int -KCharMacroExpander::expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (str[pos + 1] == escapeChar()) { - ret += TQString( escapeChar() ); - return 2; - } - if (expandMacro( str[pos+1], ret )) - return 2; - return 0; -} - -int -KWordMacroExpander::expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (isIdentifier( str[pos - 1].tqunicode() )) - return 0; - uint sl; - for (sl = 0; isIdentifier( str[pos + sl].tqunicode() ); sl++); - if (!sl) - return 0; - if (expandMacro( TQConstString( str.tqunicode() + pos, sl ).string(), ret )) - return sl; - return 0; -} - -int -KWordMacroExpander::expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ) -{ - if (str[pos + 1] == escapeChar()) { - ret += TQString( escapeChar() ); - return 2; - } - uint sl, rsl, rpos; - if (str[pos + 1] == (QChar)'{') { - rpos = pos + 2; - for (sl = 0; str[rpos + sl] != (QChar)'}'; sl++) - if (rpos + sl >= str.length()) - return 0; - rsl = sl + 3; - } else { - rpos = pos + 1; - for (sl = 0; isIdentifier( str[rpos + sl].tqunicode() ); sl++); - rsl = sl + 1; - } - if (!sl) - return 0; - if (expandMacro( TQConstString( str.tqunicode() + rpos, sl ).string(), ret )) - return rsl; - return 0; -} - -//////////// - -template<class KT,class VT> -inline QString -TexpandMacros( const TQString &ostr, const TQMap<KT,VT> &map, TQChar c ) -{ - TQString str( ostr ); - KMacroMapExpander<KT,VT> kmx( map, c ); - kmx.expandMacros( str ); - return str; -} - -template<class KT,class VT> -inline QString -TexpandMacrosShellQuote( const TQString &ostr, const TQMap<KT,VT> &map, TQChar c ) -{ - TQString str( ostr ); - KMacroMapExpander<KT,VT> kmx( map, c ); - if (!kmx.expandMacrosShellQuote( str )) - return TQString(); - return str; -} - -// public API -namespace KMacroExpander { - - TQString expandMacros( const TQString &ostr, const TQMap<TQChar,TQString> &map, TQChar c ) { return TexpandMacros( ostr, map, c ); } - TQString expandMacrosShellQuote( const TQString &ostr, const TQMap<TQChar,TQString> &map, TQChar c ) { return TexpandMacrosShellQuote( ostr, map, c ); } - TQString expandMacros( const TQString &ostr, const TQMap<TQString,TQString> &map, TQChar c ) { return TexpandMacros( ostr, map, c ); } - TQString expandMacrosShellQuote( const TQString &ostr, const TQMap<TQString,TQString> &map, TQChar c ) { return TexpandMacrosShellQuote( ostr, map, c ); } - TQString expandMacros( const TQString &ostr, const TQMap<TQChar,TQStringList> &map, TQChar c ) { return TexpandMacros( ostr, map, c ); } - TQString expandMacrosShellQuote( const TQString &ostr, const TQMap<TQChar,TQStringList> &map, TQChar c ) { return TexpandMacrosShellQuote( ostr, map, c ); } - TQString expandMacros( const TQString &ostr, const TQMap<TQString,TQStringList> &map, TQChar c ) { return TexpandMacros( ostr, map, c ); } - TQString expandMacrosShellQuote( const TQString &ostr, const TQMap<TQString,TQStringList> &map, TQChar c ) { return TexpandMacrosShellQuote( ostr, map, c ); } - -} // namespace diff --git a/kdecore/kmacroexpander.h b/kdecore/kmacroexpander.h deleted file mode 100644 index 226264990..000000000 --- a/kdecore/kmacroexpander.h +++ /dev/null @@ -1,380 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (c) 2002-2003 Oswald Buddenhagen <ossi@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - - 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 _KMACROEXPANDER_H -#define _KMACROEXPANDER_H - -#include <tqstringlist.h> -#include <tqstring.h> -#include <tqmap.h> -#include "kdelibs_export.h" - -/** - * Abstract base class for the worker classes behind the KMacroExpander namespace - * and the KCharMacroExpander and KWordMacroExpander classes. - * - * @since 3.1.3 - * @author Oswald Buddenhagen <ossi@kde.org> - */ -class KDECORE_EXPORT KMacroExpanderBase { - -public: - /** - * Constructor. - * @param c escape char indicating start of macros, or TQChar::null for none - */ - KMacroExpanderBase( TQChar c = '%' ); - - /** - * Destructor. - */ - virtual ~KMacroExpanderBase(); - - /** - * Perform safe macro expansion (substitution) on a string. - * - * @param str the string in which macros are expanded in-place - */ - void expandMacros( TQString &str ); - - /* - * Perform safe macro expansion (substitution) on a string for use - * in shell commands. - * - * Explicitly supported shell constructs: - * \ '' "" $'' $"" {} () $(()) ${} $() `` - * - * Implicitly supported shell constructs: - * (()) - * - * Unsupported shell constructs that will cause problems: - * @li Shortened "case $v in pat)" syntax. Use "case $v in (pat)" instead. - * - * The rest of the shell (incl. bash) syntax is simply ignored, - * as it is not expected to cause problems. - * - * Note that bash contains a bug which makes macro expansion within - * double quoted substitutions ("${VAR:-%macro}") inherently insecure. - * - * @param str the string in which macros are expanded in-place - * @param pos the position inside the string at which parsing/substitution - * should start, and upon exit where processing stopped - * @return false if the string could not be parsed and therefore no safe - * substitution was possible. Note that macros will have been processed - * up to the point where the error occurred. An unmatched closing paren - * or brace outside any shell construct is @em not an error (unlike in - * the function below), but still prematurely terminates processing. - */ - bool expandMacrosShellQuote( TQString &str, uint &pos ); - - /** - * Same as above, but always starts at position 0, and unmatched closing - * parens and braces are treated as errors. - */ - bool expandMacrosShellQuote( TQString &str ); - - /** - * Set the macro escape character. - * @param c escape char indicating start of macros, or TQChar::null if none - */ - void setEscapeChar( TQChar c ); - - /** - * Obtain the macro escape character. - * @return escape char indicating start of macros, or TQChar::null if none - */ - TQChar escapeChar() const; - -protected: - /** - * This function is called for every single char within the string if - * the escape char is TQChar::null. It should determine whether the - * string starting at @p pos within @p str is a valid macro and return - * the substitution value for it if so. - * @param str the input string - * @param pos the offset within @p str - * @param ret return value: the string to substitute for the macro - * @return if greater than zero, the number of chars at @p pos in @p str - * to substitute with @p ret (i.e., a valid macro was found). if less - * than zero, subtract this value from @p pos (to skip a macro, i.e., - * substitute it with itself). zero requests no special action. - */ - virtual int expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ); - - /** - * This function is called every time the escape char is found if it is - * not TQChar::null. It should determine whether the - * string starting at @p pos witin @p str is a valid macro and return - * the substitution value for it if so. - * @param str the input string - * @param pos the offset within @p str. Note that this is the position of - * the occurrence of the escape char - * @param ret return value: the string to substitute for the macro - * @return if greater than zero, the number of chars at @p pos in @p str - * to substitute with @p ret (i.e., a valid macro was found). if less - * than zero, subtract this value from @p pos (to skip a macro, i.e., - * substitute it with itself). zero requests no special action. - */ - virtual int expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ); - -private: - TQChar escapechar; -}; - -/** - * Abstract base class for simple word macro substitutors. Use this instead of - * the functions in the KMacroExpander namespace if speculatively pre-filling - * the substitution map would be too expensive. - * - * A typical application: - * - * \code - * class MyClass { - * ... - * private: - * TQString m_str; - * ... - * friend class MyExpander; - * }; - * - * class MyExpander : public KWordMacroExpander { - * public: - * MyExpander( MyClass *_that ) : KWordMacroExpander(), that( _that ) {} - * protected: - * virtual bool expandMacro( const TQString &str, TQStringList &ret ); - * private: - * MyClass *that; - * }; - * - * bool MyExpander::expandMacro( const TQString &str, TQStringList &ret ) - * { - * if (str == "macro") { - * ret += complexOperation( that->m_str ); - * return true; - * } - * return false; - * } - * - * ... MyClass::...(...) - * { - * TQString str; - * ... - * MyExpander mx( this ); - * mx.expandMacrosShellQuote( str ); - * ... - * } - * \endcode - * - * Alternatively MyClass could inherit from KWordMacroExpander directly. - * - * @since 3.3 - * @author Oswald Buddenhagen <ossi@kde.org> - */ -class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase { - -public: - /** - * Constructor. - * @param c escape char indicating start of macros, or TQChar::null for none - */ - KWordMacroExpander( TQChar c = '%' ) : KMacroExpanderBase( c ) {} - -protected: - virtual int expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ); - virtual int expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ); - - /** - * Return substitution list @p ret for string macro @p str. - * @param str the macro to expand - * @param ret return variable reference. It is guaranteed to be empty - * when expandMacro is entered. - * @return @c true iff @p chr was a recognized macro name - */ - virtual bool expandMacro( const TQString &str, TQStringList &ret ) = 0; -}; - -/** - * Abstract base class for single char macro substitutors. Use this instead of - * the functions in the KMacroExpander namespace if speculatively pre-filling - * the substitution map would be too expensive. - * - * See KWordMacroExpander for a sample application. - * - * @since 3.3 - * @author Oswald Buddenhagen <ossi@kde.org> - */ -class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase { - -public: - /** - * Constructor. - * @param c escape char indicating start of macros, or TQChar::null for none - */ - KCharMacroExpander( TQChar c = '%' ) : KMacroExpanderBase( c ) {} - -protected: - virtual int expandPlainMacro( const TQString &str, uint pos, TQStringList &ret ); - virtual int expandEscapedMacro( const TQString &str, uint pos, TQStringList &ret ); - - /** - * Return substitution list @p ret for single-character macro @p chr. - * @param chr the macro to expand - * @param ret return variable reference. It is guaranteed to be empty - * when expandMacro is entered. - * @return @c true iff @p chr was a recognized macro name - */ - virtual bool expandMacro( TQChar chr, TQStringList &ret ) = 0; -}; - -/** - * A group of functions providing macro expansion (substitution) in strings, - * optionally with quoting appropriate for shell execution. - * @since 3.1.3 - */ -namespace KMacroExpander { - /** - * Perform safe macro expansion (substitution) on a string. - * The escape char must be quoted with itself to obtain its literal - * representation in the resulting string. - * - * @param str The string to expand - * @param map map with substitutions - * @param c escape char indicating start of macro, or TQChar::null if none - * @return the string with all valid macros expanded - * - * \code - * // Code example - * TQMap<TQChar,TQString> map; - * map.insert('u', "/tmp/myfile.txt"); - * map.insert('n', "My File"); - * TQString s = "%% Title: %u:%n"; - * s = KMacroExpander::expandMacros(s, map); - * // s is now "% Title: /tmp/myfile.txt:My File"; - * \endcode - */ - KDECORE_EXPORT TQString expandMacros( const TQString &str, const TQMap<TQChar,TQString> &map, TQChar c = '%' ); - - /** - * Perform safe macro expansion (substitution) on a string for use - * in shell commands. - * The escape char must be quoted with itself to obtain its literal - * representation in the resulting string. - * - * @param str The string to expand - * @param map map with substitutions - * @param c escape char indicating start of macro, or TQChar::null if none - * @return the string with all valid macros expanded, or a null string - * if a shell syntax error was detected in the command - * - * \code - * // Code example - * TQMap<TQChar,TQString> map; - * map.insert('u', "/tmp/myfile.txt"); - * map.insert('n', "My File"); - * TQString s = "kedit --caption %n %u"; - * s = KMacroExpander::expandMacrosShellQuote(s, map); - * // s is now "kedit --caption 'My File' '/tmp/myfile.txt'"; - * system(TQFile::encodeName(s)); - * \endcode - */ - KDECORE_EXPORT TQString expandMacrosShellQuote( const TQString &str, const TQMap<TQChar,TQString> &map, TQChar c = '%' ); - - /** - * Perform safe macro expansion (substitution) on a string. - * The escape char must be quoted with itself to obtain its literal - * representation in the resulting string. - * Macro names can consist of chars in the range [A-Za-z0-9_]; - * use braces to delimit macros from following words starting - * with these chars, or to use other chars for macro names. - * - * @param str The string to expand - * @param map map with substitutions - * @param c escape char indicating start of macro, or TQChar::null if none - * @return the string with all valid macros expanded - * - * \code - * // Code example - * TQMap<TQString,TQString> map; - * map.insert("url", "/tmp/myfile.txt"); - * map.insert("name", "My File"); - * TQString s = "Title: %{url}-%name"; - * s = KMacroExpander::expandMacros(s, map); - * // s is now "Title: /tmp/myfile.txt-My File"; - * \endcode - */ - KDECORE_EXPORT TQString expandMacros( const TQString &str, const TQMap<TQString,TQString> &map, TQChar c = '%' ); - - /** - * Perform safe macro expansion (substitution) on a string for use - * in shell commands. - * The escape char must be quoted with itself to obtain its literal - * representation in the resulting string. - * Macro names can consist of chars in the range [A-Za-z0-9_]; - * use braces to delimit macros from following words starting - * with these chars, or to use other chars for macro names. - * - * @param str The string to expand - * @param map map with substitutions - * @param c escape char indicating start of macro, or TQChar::null if none - * @return the string with all valid macros expanded, or a null string - * if a shell syntax error was detected in the command - * - * \code - * // Code example - * TQMap<TQString,TQString> map; - * map.insert("url", "/tmp/myfile.txt"); - * map.insert("name", "My File"); - * TQString s = "kedit --caption %name %{url}"; - * s = KMacroExpander::expandMacrosShellQuote(s, map); - * // s is now "kedit --caption 'My File' '/tmp/myfile.txt'"; - * system(TQFile::encodeName(s)); - * \endcode - */ - KDECORE_EXPORT TQString expandMacrosShellQuote( const TQString &str, const TQMap<TQString,TQString> &map, TQChar c = '%' ); - - /** - * Same as above, except that the macros expand to string lists that - * are simply join(" ")ed together. - */ - KDECORE_EXPORT TQString expandMacros( const TQString &str, const TQMap<TQChar,TQStringList> &map, TQChar c = '%' ); - /** - * Same as above, except that the macros expand to string lists that - * are simply join(" ")ed together. - */ - KDECORE_EXPORT TQString expandMacros( const TQString &str, const TQMap<TQString,TQStringList> &map, TQChar c = '%' ); - - /** - * Same as above, except that the macros expand to string lists. - * If the macro appears inside a quoted string, the list is simply - * join(" ")ed together; otherwise every element expands to a separate - * quoted string. - */ - KDECORE_EXPORT TQString expandMacrosShellQuote( const TQString &str, const TQMap<TQChar,TQStringList> &map, TQChar c = '%' ); - /** - * Same as above, except that the macros expand to string lists. - * If the macro appears inside a quoted string, the list is simply - * join(" ")ed together; otherwise every element expands to a separate - * quoted string. - */ - KDECORE_EXPORT TQString expandMacrosShellQuote( const TQString &str, const TQMap<TQString,TQStringList> &map, TQChar c = '%' ); -} - -#endif /* _KMACROEXPANDER_H */ diff --git a/kdecore/kmanagerselection.cpp b/kdecore/kmanagerselection.cpp deleted file mode 100644 index feabf630d..000000000 --- a/kdecore/kmanagerselection.cpp +++ /dev/null @@ -1,490 +0,0 @@ -/**************************************************************************** - - $Id$ - - Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> - -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. - -****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include <tqobject.h> -#ifdef Q_WS_X11 // FIXME(E) - -#include "kmanagerselection.h" - -#include <kdebug.h> -#include <tqwidget.h> -#include <kapplication.h> -#include <kxerrorhandler.h> -#include <X11/Xatom.h> - -class KSelectionOwnerPrivate - : public QWidget - { - public: - KSelectionOwnerPrivate( KSelectionOwner* owner ); - protected: - virtual bool x11Event( XEvent* ev ); - private: - KSelectionOwner* owner; - }; - -KSelectionOwnerPrivate::KSelectionOwnerPrivate( KSelectionOwner* owner_P ) - : owner( owner_P ) - { - kapp->installX11EventFilter( TQT_TQWIDGET(this) ); - } - -bool KSelectionOwnerPrivate::x11Event( XEvent* ev_P ) - { - return owner->filterEvent( ev_P ); - } - -KSelectionOwner::KSelectionOwner( Atom selection_P, int screen_P, TQObject* parent_P ) - : TQObject( parent_P ), - selection( selection_P ), - screen( screen_P >= 0 ? screen_P : DefaultScreen( qt_xdisplay())), - window( None ), - timestamp( CurrentTime ), - extra1( 0 ), extra2( 0 ), - d( new KSelectionOwnerPrivate( this )) - { - } - -KSelectionOwner::KSelectionOwner( const char* selection_P, int screen_P, TQObject* parent_P ) - : TQObject( parent_P ), - selection( XInternAtom( qt_xdisplay(), selection_P, False )), - screen( screen_P >= 0 ? screen_P : DefaultScreen( qt_xdisplay())), - window( None ), - timestamp( CurrentTime ), - extra1( 0 ), extra2( 0 ), - d( new KSelectionOwnerPrivate( this )) - { - } - -KSelectionOwner::~KSelectionOwner() - { - release(); - delete d; - } - -bool KSelectionOwner::claim( bool force_P, bool force_kill_P ) - { - if( manager_atom == None ) - getAtoms(); - if( timestamp != CurrentTime ) - release(); - Display* const dpy = qt_xdisplay(); - Window prev_owner = XGetSelectionOwner( dpy, selection ); - if( prev_owner != None ) - { - if( !force_P ) - { -// kdDebug() << "Selection already owned, failing" << endl; - return false; - } - XSelectInput( dpy, prev_owner, StructureNotifyMask ); - } - XSetWindowAttributes attrs; - attrs.override_redirect = True; - window = XCreateWindow( dpy, RootWindow( dpy, screen ), 0, 0, 1, 1, - 0, CopyFromParent, InputOnly, CopyFromParent, CWOverrideRedirect, &attrs ); -// kdDebug() << "Using owner window " << window << endl; - Atom tmp = XA_ATOM; - XSelectInput( dpy, window, PropertyChangeMask ); - XChangeProperty( dpy, window, XA_ATOM, XA_ATOM, 32, PropModeReplace, - reinterpret_cast< unsigned char* >( &tmp ), 1 ); - XEvent ev; - XSync( dpy, False ); - XCheckTypedWindowEvent( dpy, window, PropertyNotify, &ev ); // get a timestamp - timestamp = ev.xproperty.time; - XSelectInput( dpy, window, StructureNotifyMask ); // for DestroyNotify - XSetSelectionOwner( dpy, selection, window, timestamp ); - Window new_owner = XGetSelectionOwner( dpy, selection ); - if( new_owner != window ) - { -// kdDebug() << "Failed to claim selection : " << new_owner << endl; - XDestroyWindow( dpy, window ); - timestamp = CurrentTime; - return false; - } - if( prev_owner != None ) - { -// kdDebug() << "Waiting for previous owner to disown" << endl; - for( int cnt = 0; - ; - ++cnt ) - { - if( XCheckTypedWindowEvent( dpy, prev_owner, DestroyNotify, &ev ) == True ) - break; - struct timeval tm = { 0, 50000 }; // 50 ms - select( 0, NULL, NULL, NULL, &tm ); - if( cnt == 19 ) - { - if( force_kill_P ) - { -// kdDebug() << "Killing previous owner" << endl; - XKillClient( dpy, prev_owner ); - } - break; - } - } - } - ev.type = ClientMessage; - ev.xclient.window = RootWindow( dpy, screen ); - ev.xclient.display = dpy; - ev.xclient.message_type = manager_atom; - ev.xclient.format = 32; - ev.xclient.data.l[ 0 ] = timestamp; - ev.xclient.data.l[ 1 ] = selection; - ev.xclient.data.l[ 2 ] = window; - ev.xclient.data.l[ 3 ] = extra1; - ev.xclient.data.l[ 4 ] = extra2; - XSendEvent( dpy, RootWindow( dpy, screen ), False, StructureNotifyMask, &ev ); -// kdDebug() << "Claimed selection" << endl; - return true; - } - -// destroy resource first -void KSelectionOwner::release() - { - if( timestamp == CurrentTime ) - return; - XDestroyWindow( qt_xdisplay(), window ); // also makes the selection not owned -// kdDebug() << "Releasing selection" << endl; - timestamp = CurrentTime; - } - -Window KSelectionOwner::ownerWindow() const - { - if( timestamp == CurrentTime ) - return None; - return window; - } - -void KSelectionOwner::setData( long extra1_P, long extra2_P ) - { - extra1 = extra1_P; - extra2 = extra2_P; - } - -bool KSelectionOwner::filterEvent( XEvent* ev_P ) - { - if( timestamp != CurrentTime && ev_P->xany.window == window ) - { - if( handleMessage( ev_P )) - return true; - } - switch( ev_P->type ) - { - case SelectionClear: - { - if( timestamp == CurrentTime || ev_P->xselectionclear.selection != selection ) - return false; - timestamp = CurrentTime; -// kdDebug() << "Lost selection" << endl; - emit lostOwnership(); - XSelectInput( qt_xdisplay(), window, 0 ); - XDestroyWindow( qt_xdisplay(), window ); - return false; - } - case DestroyNotify: - { - if( timestamp == CurrentTime || ev_P->xdestroywindow.window != window ) - return false; - timestamp = CurrentTime; -// kdDebug() << "Lost selection (destroyed)" << endl; - emit lostOwnership(); - return false; - } - case SelectionNotify: - { - if( timestamp == CurrentTime || ev_P->xselection.selection != selection ) - return false; - // ignore? - return false; - } - case SelectionRequest: - filter_selection_request( ev_P->xselectionrequest ); - return false; - } - return false; - } - -bool KSelectionOwner::handleMessage( XEvent* ) - { - return false; - } - -void KSelectionOwner::filter_selection_request( XSelectionRequestEvent& ev_P ) - { - if( timestamp == CurrentTime || ev_P.selection != selection ) - return; - if( ev_P.time != CurrentTime - && ev_P.time - timestamp > 1U << 31 ) - return; // too old or too new request -// kdDebug() << "Got selection request" << endl; - bool handled = false; - if( ev_P.target == xa_multiple ) - { - if( ev_P.property != None ) - { - const int MAX_ATOMS = 100; // no need to handle more? - int format; - Atom type; - unsigned long items; - unsigned long after; - unsigned char* data; - if( XGetWindowProperty( qt_xdisplay(), ev_P.requestor, ev_P.property, 0, - MAX_ATOMS, False, AnyPropertyType, &type, &format, &items, &after, - &data ) == Success && format == 32 && items % 2 == 0 ) - { - bool handled_array[ MAX_ATOMS ]; - Atom* atoms = reinterpret_cast< Atom* >( data ); - for( unsigned int i = 0; - i < items / 2; - ++i ) - handled_array[ i ] = handle_selection( - atoms[ i * 2 ], atoms[ i * 2 + 1 ], ev_P.requestor ); - bool all_handled = true; - for( unsigned int i = 0; - i < items / 2; - ++i ) - if( !handled_array[ i ] ) - { - all_handled = false; - atoms[ i * 2 + 1 ] = None; - } - if( !all_handled ) - XChangeProperty( qt_xdisplay(), ev_P.requestor, ev_P.property, XA_ATOM, - 32, PropModeReplace, reinterpret_cast< unsigned char* >( atoms ), items ); - handled = true; - XFree( data ); - } - } - } - else - { - if( ev_P.property == None ) // obsolete client - ev_P.property = ev_P.target; - handled = handle_selection( ev_P.target, ev_P.property, ev_P.requestor ); - } - XEvent ev; - ev.xselection.type = SelectionNotify; - ev.xselection.display = qt_xdisplay(); - ev.xselection.requestor = ev_P.requestor; - ev.xselection.target = ev_P.target; - ev.xselection.property = handled ? ev_P.property : None; - XSendEvent( qt_xdisplay(), ev_P.requestor, False, 0, &ev ); - } - -bool KSelectionOwner::handle_selection( Atom target_P, Atom property_P, Window requestor_P ) - { - if( target_P == xa_timestamp ) - { -// kdDebug() << "Handling timestamp request" << endl; - XChangeProperty( qt_xdisplay(), requestor_P, property_P, XA_INTEGER, 32, - PropModeReplace, reinterpret_cast< unsigned char* >( ×tamp ), 1 ); - } - else if( target_P == xa_targets ) - replyTargets( property_P, requestor_P ); - else if( genericReply( target_P, property_P, requestor_P )) - ; // handled - else - return false; // unknown - return true; - } - -void KSelectionOwner::replyTargets( Atom property_P, Window requestor_P ) - { - Atom atoms[ 3 ] = { xa_multiple, xa_timestamp, xa_targets }; -// kdDebug() << "Handling targets request" << endl; - XChangeProperty( qt_xdisplay(), requestor_P, property_P, XA_ATOM, 32, PropModeReplace, - reinterpret_cast< unsigned char* >( atoms ), 3 ); - } - -bool KSelectionOwner::genericReply( Atom, Atom, Window ) - { - return false; - } - -void KSelectionOwner::getAtoms() - { - if( manager_atom == None ) - { - Atom atoms[ 4 ]; - const char* const names[] = - { "MANAGER", "MULTIPLE", "TARGETS", "TIMESTAMP" }; - XInternAtoms( qt_xdisplay(), const_cast< char** >( names ), 4, False, atoms ); - manager_atom = atoms[ 0 ]; - xa_multiple = atoms[ 1]; - xa_targets = atoms[ 2 ]; - xa_timestamp = atoms[ 3 ]; - } - } - -Atom KSelectionOwner::manager_atom = None; -Atom KSelectionOwner::xa_multiple = None; -Atom KSelectionOwner::xa_targets = None; -Atom KSelectionOwner::xa_timestamp = None; - -//******************************************* -// KSelectionWatcher -//******************************************* - - -class KSelectionWatcherPrivate - : public QWidget - { - public: - KSelectionWatcherPrivate( KSelectionWatcher* watcher ); - protected: - virtual bool x11Event( XEvent* ev ); - private: - KSelectionWatcher* watcher; - }; - -KSelectionWatcherPrivate::KSelectionWatcherPrivate( KSelectionWatcher* watcher_P ) - : watcher( watcher_P ) - { - kapp->installX11EventFilter( TQT_TQWIDGET(this) ); - } - -bool KSelectionWatcherPrivate::x11Event( XEvent* ev_P ) - { - watcher->filterEvent( ev_P ); - return false; - } - - -KSelectionWatcher::KSelectionWatcher( Atom selection_P, int screen_P, TQObject* parent_P ) - : TQObject( parent_P ), - selection( selection_P ), - screen( screen_P >= 0 ? screen_P : DefaultScreen( qt_xdisplay())), - selection_owner( None ), - d( new KSelectionWatcherPrivate( this )) - { - init(); - } - -KSelectionWatcher::KSelectionWatcher( const char* selection_P, int screen_P, TQObject* parent_P ) - : TQObject( parent_P ), - selection( XInternAtom( qt_xdisplay(), selection_P, False )), - screen( screen_P >= 0 ? screen_P : DefaultScreen( qt_xdisplay())), - selection_owner( None ), - d( new KSelectionWatcherPrivate( this )) - { - init(); - } - -KSelectionWatcher::~KSelectionWatcher() - { - delete d; - } - -void KSelectionWatcher::init() - { - if( manager_atom == None ) - { - Display* const dpy = qt_xdisplay(); - manager_atom = XInternAtom( dpy, "MANAGER", False ); - XWindowAttributes attrs; - XGetWindowAttributes( dpy, RootWindow( dpy, screen ), &attrs ); - long event_mask = attrs.your_event_mask; - // StructureNotifyMask on the root window is needed - XSelectInput( dpy, RootWindow( dpy, screen ), event_mask | StructureNotifyMask ); - } - } - -Window KSelectionWatcher::owner() - { - Display* const dpy = qt_xdisplay(); - KXErrorHandler handler; - Window current_owner = XGetSelectionOwner( dpy, selection ); - if( current_owner == None ) - return None; - if( current_owner == selection_owner ) - return selection_owner; - XSelectInput( dpy, current_owner, StructureNotifyMask ); - if( !handler.error( true ) && current_owner == XGetSelectionOwner( dpy, selection )) - { -// kdDebug() << "isOwner: " << current_owner << endl; - selection_owner = current_owner; - emit newOwner( selection_owner ); - } - else - selection_owner = None; - return selection_owner; - } - -// void return value in order to allow more watchers in one process -void KSelectionWatcher::filterEvent( XEvent* ev_P ) - { - if( ev_P->type == ClientMessage ) - { -// kdDebug() << "got ClientMessage" << endl; - if( ev_P->xclient.message_type != manager_atom - || ev_P->xclient.data.l[ 1 ] != static_cast< long >( selection )) - return; -// kdDebug() << "handling message" << endl; - if( static_cast< long >( owner()) == ev_P->xclient.data.l[ 2 ] ) - { - // owner() emits newOwner() if needed, no need to do it twice - } - return; - } - if( ev_P->type == DestroyNotify ) - { - if( selection_owner == None || ev_P->xdestroywindow.window != selection_owner ) - return; - selection_owner = None; // in case the exactly same ID gets reused as the owner - if( owner() == None ) - emit lostOwner(); // it must be safe to delete 'this' in a slot - return; - } - return; - } - -Atom KSelectionWatcher::manager_atom = None; - -void KSelectionOwner::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KSelectionWatcher::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -#include "kmanagerselection.moc" -#endif diff --git a/kdecore/kmanagerselection.h b/kdecore/kmanagerselection.h deleted file mode 100644 index 384f5d23f..000000000 --- a/kdecore/kmanagerselection.h +++ /dev/null @@ -1,233 +0,0 @@ -/**************************************************************************** - - Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> - -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 __KMANAGERSELECTION_H -#define __KMANAGERSELECTION_H - -#include <tqobject.h> -#include <kdelibs_export.h> - -#ifdef Q_MOC_RUN -#define Q_WS_X11 -#endif // Q_MOC_RUN - -#ifdef Q_WS_X11 // FIXME(E) - -#include <X11/Xlib.h> - -class KSelectionOwnerPrivate; - -/** - This class implements claiming and owning manager selections, as described - in the ICCCM, section 2.8. The selection atom is passed to the constructor, - claim() attemps to claim ownership of the selection, release() gives up - the selection ownership. Signal lostOwnership() is emitted when the selection - is claimed by another owner. - @since 3.2 - @short ICCCM manager selection owner -*/ -class KDECORE_EXPORT KSelectionOwner - : public TQObject - { - Q_OBJECT - public: - /** - * This constructor initializes the object, but doesn't perform any - * operation on the selection. - * - * @param selection atom representing the manager selection - * @param screen X screen, or -1 for default - * @param parent parent object, or NULL if there is none - */ - KSelectionOwner( Atom selection, int screen = -1, TQObject* parent = NULL ); - /** - * @overload - * This constructor accepts the selection name and creates the appropriate atom - * for it automatically. - * - * @param selection name of the manager selection - * @param screen X screen, or -1 for default - * @param parent parent object, or NULL if there is none - */ - KSelectionOwner( const char* selection, int screen = -1, TQObject* parent = NULL ); - /** - * Destructor. Calls release(). - */ - virtual ~KSelectionOwner(); - /** - * This function attemps to claim ownership of the manager selection, using - * the current X timestamp. If @p force is false, and the selection is already - * owned, the selection is not claimed, and false is returned. If claiming - * is forced and the selection is owned by another client, it is waited for up to 1 second - * for the previous owner to disown the selection, if @p force_kill is true, - * and the previous owner fails to disown the selection in time, - * it will be forcibly killed. True is returned after successfully claiming - * ownership of the selection. - */ - bool claim( bool force, bool force_kill = true ); - /** - * If the selection is owned, the ownership is given up. - */ - void release(); - /** - * If the selection is owned, returns the window used internally - * for owning the selection. - */ - Window ownerWindow() const; // None if not owning the selection - /** - * @internal - */ - bool filterEvent( XEvent* ev_P ); // internal - signals: - /** - * This signal is emitted if the selection was owned and the ownership - * has been lost due to another client claiming it, this signal is emitted. - * IMPORTANT: It's not safe to delete the instance in a slot connected - * to this signal. - */ - void lostOwnership(); - protected: - /** - * Called for every X event received on the window used for owning - * the selection. If true is returned, the event is filtered out. - */ - virtual bool handleMessage( XEvent* ev ); - /** - * Called when a SelectionRequest event is received. A reply should - * be sent using the selection handling mechanism described in the ICCCM - * section 2. - * - * @param target requested target type - * @param property property to use for the reply data - * @param requestor requestor window - */ - virtual bool genericReply( Atom target, Atom property, Window requestor ); - /** - * Called to announce the supported targets, as described in the ICCCM - * section 2.6. The default implementation announces the required targets - * MULTIPLE, TIMESTAMP and TARGETS. - */ - virtual void replyTargets( Atom property, Window requestor ); - /** - * Called to create atoms needed for claiming the selection and - * communication using the selection handling mechanism. The default - * implementation must be called if reimplemented. This method - * may be called repeatedly. - */ - virtual void getAtoms(); - /** - * Sets extra data to be sent in the message sent to root window - * after successfully claiming a selection. These extra data - * are in data.l[3] and data.l[4] fields of the XClientMessage. - */ - void setData( long extra1, long extra2 ); - private: - void filter_selection_request( XSelectionRequestEvent& ev_P ); - bool handle_selection( Atom target_P, Atom property_P, Window requestor_P ); - const Atom selection; - const int screen; - Window window; - Time timestamp; - long extra1, extra2; - static Atom manager_atom; - static Atom xa_multiple; - static Atom xa_targets; - static Atom xa_timestamp; - protected: - virtual void virtual_hook( int id, void* data ); - private: - KSelectionOwnerPrivate* d; - }; - -class KSelectionWatcherPrivate; - -/** - This class implements watching manager selections, as described in the ICCCM - section 2.8. It emits signal newOwner() when a new owner claim the selection, - and emits lostOwner() when the selection ownership is given up. To find - out current owner of the selection, owner() can be used. - @since 3.2 - @short ICCCM manager selection watching -*/ -class KDECORE_EXPORT KSelectionWatcher - : public TQObject - { - Q_OBJECT - public: - /** - * This constructor initializes the object, but doesn't perform any - * operation on the selection. - * - * @param selection atom representing the manager selection - * @param screen X screen, or -1 for default - * @param parent parent object, or NULL if there is none - */ - KSelectionWatcher( Atom selection, int screen = -1, TQObject* parent = NULL ); - /** - * @overload - * This constructor accepts the selection name and creates the appropriate atom - * for it automatically. - * - * @param selection name of the manager selection - * @param screen X screen, or -1 for default - * @param parent parent object, or NULL if there is none - */ - KSelectionWatcher( const char* selection, int screen = -1, TQObject* parent = NULL ); - virtual ~KSelectionWatcher(); - /** - * Return the current owner of the manager selection, if any. - */ - Window owner(); - /** - * @internal - */ - void filterEvent( XEvent* ev_P ); // internal - signals: - /** - * This signal is emitted when the selection is successfully claimed by a new - * owner. - * @param owner the new owner of the selection - */ - void newOwner( Window owner ); - /** - * This signal is emitted when the selection is given up, i.e. there's no - * owner. Note that the selection may be immediatelly claimed again, - * so the newOwner() signal may be emitted right after this one. - * It's safe to delete the instance in a slot connected to this signal. - */ - void lostOwner(); - private: - void init(); - const Atom selection; - const int screen; - Window selection_owner; - static Atom manager_atom; - protected: - virtual void virtual_hook( int id, void* data ); - private: - KSelectionWatcherPrivate* d; - }; - -#endif -#endif diff --git a/kdecore/kmdcodec.cpp b/kdecore/kmdcodec.cpp deleted file mode 100644 index 77badf49f..000000000 --- a/kdecore/kmdcodec.cpp +++ /dev/null @@ -1,1510 +0,0 @@ -/* - Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> - Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License (LGPL) - version 2 as published by the Free Software Foundation. - - 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 General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. - RSA Data Security, Inc. Created 1991. All rights reserved. - - The KMD5 class is based on a C++ implementation of - "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by - Mordechai T. Abzug, Copyright (c) 1995. This implementation - passes the test-suite as defined in RFC 1321. - - The encoding and decoding utilities in KCodecs with the exception of - quoted-printable are based on the java implementation in HTTPClient - package by Ronald Tschal�r Copyright (C) 1996-1999. - - The quoted-printable codec as described in RFC 2045, section 6.7. is by - Rik Hemsley (C) 2001. - - KMD4 class based on the LGPL code of Copyright (C) 2001 Nikos Mavroyanopoulos - The algorithm is due to Ron Rivest. This code is based on code - written by Colin Plumb in 1993. -*/ - -#include <config.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <kdebug.h> -#include "kmdcodec.h" - -#define KMD5_S11 7 -#define KMD5_S12 12 -#define KMD5_S13 17 -#define KMD5_S14 22 -#define KMD5_S21 5 -#define KMD5_S22 9 -#define KMD5_S23 14 -#define KMD5_S24 20 -#define KMD5_S31 4 -#define KMD5_S32 11 -#define KMD5_S33 16 -#define KMD5_S34 23 -#define KMD5_S41 6 -#define KMD5_S42 10 -#define KMD5_S43 15 -#define KMD5_S44 21 - -const char KCodecs::Base64EncMap[64] = -{ - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, - 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, - 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, - 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F -}; - -const char KCodecs::Base64DecMap[128] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, - 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, - 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -const char KCodecs::UUEncMap[64] = -{ - 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F -}; - -const char KCodecs::UUDecMap[128] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -const char KCodecs::hexChars[16] = -{ - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' -}; - -const unsigned int KCodecs::maxQPLineLength = 70; - - -/******************************** KCodecs ********************************/ -// strchr(3) for broken systems. -static int rikFindChar(register const char * _s, const char c) -{ - register const char * s = _s; - - while (true) - { - if ((0 == *s) || (c == *s)) break; ++s; - if ((0 == *s) || (c == *s)) break; ++s; - if ((0 == *s) || (c == *s)) break; ++s; - if ((0 == *s) || (c == *s)) break; ++s; - } - - return s - _s; -} - -TQCString KCodecs::quotedPrintableEncode(const TQByteArray& in, bool useCRLF) -{ - TQByteArray out; - quotedPrintableEncode (in, out, useCRLF); - return TQCString (out.data(), out.size()+1); -} - -TQCString KCodecs::quotedPrintableEncode(const TQCString& str, bool useCRLF) -{ - if (str.isEmpty()) - return ""; - - TQByteArray in (str.length()); - memcpy (in.data(), str.data(), str.length()); - return quotedPrintableEncode(in, useCRLF); -} - -void KCodecs::quotedPrintableEncode(const TQByteArray& in, TQByteArray& out, bool useCRLF) -{ - out.resize (0); - if (in.isEmpty()) - return; - - char *cursor; - const char *data; - unsigned int lineLength; - unsigned int pos; - - const unsigned int length = in.size(); - const unsigned int end = length - 1; - - - // Reasonable guess for output size when we're encoding - // mostly-ASCII data. It doesn't really matter, because - // the underlying allocation routines are quite efficient, - // but it's nice to have 0 allocations in many cases. - out.resize ((length*12)/10); - cursor = out.data(); - data = in.data(); - lineLength = 0; - pos = 0; - - for (unsigned int i = 0; i < length; i++) - { - unsigned char c (data[i]); - - // check if we have to enlarge the output buffer, use - // a safety margin of 16 byte - pos = cursor-out.data(); - if (out.size()-pos < 16) { - out.resize(out.size()+4096); - cursor = out.data()+pos; - } - - // Plain ASCII chars just go straight out. - - if ((c >= 33) && (c <= 126) && ('=' != c)) - { - *cursor++ = c; - ++lineLength; - } - - // Spaces need some thought. We have to encode them at eol (or eof). - - else if (' ' == c) - { - if - ( - (i >= length) - || - ((i < end) && ((useCRLF && ('\r' == data[i + 1]) && ('\n' == data[i + 2])) - || - (!useCRLF && ('\n' == data[i + 1])))) - ) - { - *cursor++ = '='; - *cursor++ = '2'; - *cursor++ = '0'; - - lineLength += 3; - } - else - { - *cursor++ = ' '; - ++lineLength; - } - } - // If we find a line break, just let it through. - else if ((useCRLF && ('\r' == c) && (i < end) && ('\n' == data[i + 1])) || - (!useCRLF && ('\n' == c))) - { - lineLength = 0; - - if (useCRLF) { - *cursor++ = '\r'; - *cursor++ = '\n'; - ++i; - } else { - *cursor++ = '\n'; - } - } - - // Anything else is converted to =XX. - - else - { - *cursor++ = '='; - *cursor++ = hexChars[c / 16]; - *cursor++ = hexChars[c % 16]; - - lineLength += 3; - } - - // If we're approaching the maximum line length, do a soft line break. - - if ((lineLength > maxQPLineLength) && (i < end)) - { - if (useCRLF) { - *cursor++ = '='; - *cursor++ = '\r'; - *cursor++ = '\n'; - } else { - *cursor++ = '='; - *cursor++ = '\n'; - } - - lineLength = 0; - } - } - - out.truncate(cursor - out.data()); -} - -TQCString KCodecs::quotedPrintableDecode(const TQByteArray & in) -{ - TQByteArray out; - quotedPrintableDecode (in, out); - return TQCString (out.data(), out.size()+1); -} - -TQCString KCodecs::quotedPrintableDecode(const TQCString & str) -{ - if (str.isEmpty()) - return ""; - - TQByteArray in (str.length()); - memcpy (in.data(), str.data(), str.length()); - return quotedPrintableDecode (in); -} - -void KCodecs::quotedPrintableDecode(const TQByteArray& in, TQByteArray& out) -{ - // clear out the output buffer - out.resize (0); - if (in.isEmpty()) - return; - - char *cursor; - const char *data; - const unsigned int length = in.size(); - - data = in.data(); - out.resize (length); - cursor = out.data(); - - for (unsigned int i = 0; i < length; i++) - { - char c(in[i]); - - if ('=' == c) - { - if (i < length - 2) - { - char c1 = in[i + 1]; - char c2 = in[i + 2]; - - if (('\n' == c1) || ('\r' == c1 && '\n' == c2)) - { - // Soft line break. No output. - if ('\r' == c1) - i += 2; // CRLF line breaks - else - i += 1; - } - else - { - // =XX encoded byte. - - int hexChar0 = rikFindChar(hexChars, c1); - int hexChar1 = rikFindChar(hexChars, c2); - - if (hexChar0 < 16 && hexChar1 < 16) - { - *cursor++ = char((hexChar0 * 16) | hexChar1); - i += 2; - } - } - } - } - else - { - *cursor++ = c; - } - } - - out.truncate(cursor - out.data()); -} - -TQCString KCodecs::base64Encode( const TQCString& str, bool insertLFs ) -{ - if ( str.isEmpty() ) - return ""; - - TQByteArray in (str.length()); - memcpy( in.data(), str.data(), str.length() ); - return base64Encode( in, insertLFs ); -} - -TQCString KCodecs::base64Encode( const TQByteArray& in, bool insertLFs ) -{ - TQByteArray out; - base64Encode( in, out, insertLFs ); - return TQCString( out.data(), out.size()+1 ); -} - -void KCodecs::base64Encode( const TQByteArray& in, TQByteArray& out, - bool insertLFs ) -{ - // clear out the output buffer - out.resize (0); - if ( in.isEmpty() ) - return; - - unsigned int sidx = 0; - unsigned int didx = 0; - const char* data = in.data(); - const unsigned int len = in.size(); - - unsigned int out_len = ((len+2)/3)*4; - - // Deal with the 76 characters or less per - // line limit specified in RFC 2045 on a - // pre request basis. - insertLFs = (insertLFs && out_len > 76); - if ( insertLFs ) - out_len += ((out_len-1)/76); - - int count = 0; - out.resize( out_len ); - - // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion - if ( len > 1 ) - { - while (sidx < len-2) - { - if ( insertLFs ) - { - if ( count && (count%76) == 0 ) - out[didx++] = '\n'; - count += 4; - } - out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; - out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | - (data[sidx] << 4) & 077]; - out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 | - (data[sidx+1] << 2) & 077]; - out[didx++] = Base64EncMap[data[sidx+2] & 077]; - sidx += 3; - } - } - - if (sidx < len) - { - if ( insertLFs && (count > 0) && (count%76) == 0 ) - out[didx++] = '\n'; - - out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; - if (sidx < len-1) - { - out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | - (data[sidx] << 4) & 077]; - out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077]; - } - else - { - out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; - } - } - - // Add padding - while (didx < out.size()) - { - out[didx] = '='; - didx++; - } -} - -TQCString KCodecs::base64Decode( const TQCString& str ) -{ - if ( str.isEmpty() ) - return ""; - - TQByteArray in( str.length() ); - memcpy( in.data(), str.data(), str.length() ); - return base64Decode( in ); -} - -TQCString KCodecs::base64Decode( const TQByteArray& in ) -{ - TQByteArray out; - base64Decode( in, out ); - return TQCString( out.data(), out.size()+1 ); -} - -void KCodecs::base64Decode( const TQByteArray& in, TQByteArray& out ) -{ - out.resize(0); - if ( in.isEmpty() ) - return; - - unsigned int count = 0; - unsigned int len = in.size(), tail = len; - const char* data = in.data(); - - // Deal with possible *nix "BEGIN" marker!! - while ( count < len && (data[count] == '\n' || data[count] == '\r' || - data[count] == '\t' || data[count] == ' ') ) - count++; - - if ( count == len ) - return; - - if ( strncasecmp(data+count, "begin", 5) == 0 ) - { - count += 5; - while ( count < len && data[count] != '\n' && data[count] != '\r' ) - count++; - - while ( count < len && (data[count] == '\n' || data[count] == '\r') ) - count ++; - - data += count; - tail = (len -= count); - } - - // Find the tail end of the actual encoded data even if - // there is/are trailing CR and/or LF. - while ( tail > 0 - && ( data[tail-1] == '=' || data[tail-1] == '\n' || data[tail-1] == '\r' ) ) - if ( data[--tail] != '=' ) len = tail; - - unsigned int outIdx = 0; - out.resize( (count=len) ); - for (unsigned int idx = 0; idx < count; idx++) - { - // Adhere to RFC 2045 and ignore characters - // that are not part of the encoding table. - unsigned char ch = data[idx]; - if ((ch > 47 && ch < 58) || (ch > 64 && ch < 91) || - (ch > 96 && ch < 123) || ch == '+' || ch == '/' || ch == '=') - { - out[outIdx++] = Base64DecMap[ch]; - } - else - { - len--; - tail--; - } - } - - // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; - - // 4-byte to 3-byte conversion - len = (tail>(len/4)) ? tail-(len/4) : 0; - unsigned int sidx = 0, didx = 0; - if ( len > 1 ) - { - while (didx < len-2) - { - out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); - out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); - out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); - sidx += 4; - didx += 3; - } - } - - if (didx < len) - out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); - - if (++didx < len ) - out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); - - // Resize the output buffer - if ( len == 0 || len < out.size() ) - out.resize(len); -} - -TQCString KCodecs::uuencode( const TQCString& str ) -{ - if ( str.isEmpty() ) - return ""; - - TQByteArray in; - in.resize( str.length() ); - memcpy( in.data(), str.data(), str.length() ); - return uuencode( in ); -} - -TQCString KCodecs::uuencode( const TQByteArray& in ) -{ - TQByteArray out; - uuencode( in, out ); - return TQCString( out.data(), out.size()+1 ); -} - -void KCodecs::uuencode( const TQByteArray& in, TQByteArray& out ) -{ - out.resize( 0 ); - if( in.isEmpty() ) - return; - - unsigned int sidx = 0; - unsigned int didx = 0; - unsigned int line_len = 45; - - const char nl[] = "\n"; - const char* data = in.data(); - const unsigned int nl_len = strlen(nl); - const unsigned int len = in.size(); - - out.resize( (len+2)/3*4 + ((len+line_len-1)/line_len)*(nl_len+1) ); - // split into lines, adding line-length and line terminator - while (sidx+line_len < len) - { - // line length - out[didx++] = UUEncMap[line_len]; - - // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion - for (unsigned int end = sidx+line_len; sidx < end; sidx += 3) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 | - (data[sidx] << 4) & 077]; - out[didx++] = UUEncMap[(data[sidx+2] >> 6) & 003 | - (data[sidx+1] << 2) & 077]; - out[didx++] = UUEncMap[data[sidx+2] & 077]; - } - - // line terminator - //for (unsigned int idx=0; idx < nl_len; idx++) - //out[didx++] = nl[idx]; - memcpy(out.data()+didx, nl, nl_len); - didx += nl_len; - } - - // line length - out[didx++] = UUEncMap[len-sidx]; - // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion - while (sidx+2 < len) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 | - (data[sidx] << 4) & 077]; - out[didx++] = UUEncMap[(data[sidx+2] >> 6) & 003 | - (data[sidx+1] << 2) & 077]; - out[didx++] = UUEncMap[data[sidx+2] & 077]; - sidx += 3; - } - - if (sidx < len-1) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 | - (data[sidx] << 4) & 077]; - out[didx++] = UUEncMap[(data[sidx+1] << 2) & 077]; - out[didx++] = UUEncMap[0]; - } - else if (sidx < len) - { - out[didx++] = UUEncMap[(data[sidx] >> 2) & 077]; - out[didx++] = UUEncMap[(data[sidx] << 4) & 077]; - out[didx++] = UUEncMap[0]; - out[didx++] = UUEncMap[0]; - } - - // line terminator - memcpy(out.data()+didx, nl, nl_len); - didx += nl_len; - - // sanity check - if ( didx != out.size() ) - out.resize( 0 ); -} - -TQCString KCodecs::uudecode( const TQCString& str ) -{ - if ( str.isEmpty() ) - return ""; - - TQByteArray in; - in.resize( str.length() ); - memcpy( in.data(), str.data(), str.length() ); - return uudecode( in ); -} - -TQCString KCodecs::uudecode( const TQByteArray& in ) -{ - TQByteArray out; - uudecode( in, out ); - return TQCString( out.data(), out.size()+1 ); -} - -void KCodecs::uudecode( const TQByteArray& in, TQByteArray& out ) -{ - out.resize( 0 ); - if( in.isEmpty() ) - return; - - unsigned int sidx = 0; - unsigned int didx = 0; - unsigned int len = in.size(); - unsigned int line_len, end; - const char* data = in.data(); - - // Deal with *nix "BEGIN"/"END" separators!! - unsigned int count = 0; - while ( count < len && (data[count] == '\n' || data[count] == '\r' || - data[count] == '\t' || data[count] == ' ') ) - count ++; - - bool hasLF = false; - if ( strncasecmp( data+count, "begin", 5) == 0 ) - { - count += 5; - while ( count < len && data[count] != '\n' && data[count] != '\r' ) - count ++; - - while ( count < len && (data[count] == '\n' || data[count] == '\r') ) - count ++; - - data += count; - len -= count; - hasLF = true; - } - - out.resize( len/4*3 ); - while ( sidx < len ) - { - // get line length (in number of encoded octets) - line_len = UUDecMap[ (unsigned char) data[sidx++]]; - // ascii printable to 0-63 and 4-byte to 3-byte conversion - end = didx+line_len; - char A, B, C, D; - if (end > 2) { - while (didx < end-2) - { - A = UUDecMap[(unsigned char) data[sidx]]; - B = UUDecMap[(unsigned char) data[sidx+1]]; - C = UUDecMap[(unsigned char) data[sidx+2]]; - D = UUDecMap[(unsigned char) data[sidx+3]]; - out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) ); - out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) ); - out[didx++] = ( ((C << 6) & 255) | (D & 077) ); - sidx += 4; - } - } - - if (didx < end) - { - A = UUDecMap[(unsigned char) data[sidx]]; - B = UUDecMap[(unsigned char) data[sidx+1]]; - out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) ); - } - - if (didx < end) - { - B = UUDecMap[(unsigned char) data[sidx+1]]; - C = UUDecMap[(unsigned char) data[sidx+2]]; - out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) ); - } - - // skip padding - while (sidx < len && data[sidx] != '\n' && data[sidx] != '\r') - sidx++; - - // skip end of line - while (sidx < len && (data[sidx] == '\n' || data[sidx] == '\r')) - sidx++; - - // skip the "END" separator when present. - if ( hasLF && strncasecmp( data+sidx, "end", 3) == 0 ) - break; - } - - if ( didx < out.size() ) - out.resize( didx ); -} - -/******************************** KMD5 ********************************/ -KMD5::KMD5() -{ - init(); -} - -KMD5::KMD5(const char *in, int len) -{ - init(); - update(in, len); -} - -KMD5::KMD5(const TQByteArray& in) -{ - init(); - update( in ); -} - -KMD5::KMD5(const TQCString& in) -{ - init(); - update( in ); -} - -void KMD5::update(const TQByteArray& in) -{ - update(in.data(), int(in.size())); -} - -void KMD5::update(const TQCString& in) -{ - update(in.data(), int(in.length())); -} - -void KMD5::update(const unsigned char* in, int len) -{ - if (len < 0) - len = tqstrlen(reinterpret_cast<const char*>(in)); - - if (!len) - return; - - if (m_finalized) { - kdWarning() << "KMD5::update called after state was finalized!" << endl; - return; - } - - TQ_UINT32 in_index; - TQ_UINT32 buffer_index; - TQ_UINT32 buffer_space; - TQ_UINT32 in_length = static_cast<TQ_UINT32>( len ); - - buffer_index = static_cast<TQ_UINT32>((m_count[0] >> 3) & 0x3F); - - if ( (m_count[0] += (in_length << 3))<(in_length << 3) ) - m_count[1]++; - - m_count[1] += (in_length >> 29); - buffer_space = 64 - buffer_index; - - if (in_length >= buffer_space) - { - memcpy (m_buffer + buffer_index, in, buffer_space); - transform (m_buffer); - - for (in_index = buffer_space; in_index + 63 < in_length; - in_index += 64) - transform (reinterpret_cast<const unsigned char*>(in+in_index)); - - buffer_index = 0; - } - else - in_index=0; - - memcpy(m_buffer+buffer_index, in+in_index, in_length-in_index); -} - -bool KMD5::update(TQIODevice& file) -{ - char buffer[1024]; - int len; - - while ((len=file.readBlock(reinterpret_cast<char*>(buffer), sizeof(buffer))) > 0) - update(buffer, len); - - return file.atEnd(); -} - -void KMD5::finalize () -{ - if (m_finalized) return; - - TQ_UINT8 bits[8]; - TQ_UINT32 index, padLen; - static const unsigned char PADDING[64]= - { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - encode (bits, m_count, 8); - //memcpy( bits, m_count, 8 ); - - // Pad out to 56 mod 64. - index = static_cast<TQ_UINT32>((m_count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - update (reinterpret_cast<const char*>(PADDING), padLen); - - // Append length (before padding) - update (reinterpret_cast<const char*>(bits), 8); - - // Store state in digest - encode (m_digest, m_state, 16); - //memcpy( m_digest, m_state, 16 ); - - // Fill sensitive information with zero's - memset ( (void *)m_buffer, 0, sizeof(*m_buffer)); - - m_finalized = true; -} - - -bool KMD5::verify( const KMD5::Digest& digest) -{ - finalize(); - return (0 == memcmp(rawDigest(), digest, sizeof(KMD5::Digest))); -} - -bool KMD5::verify( const TQCString& hexdigest) -{ - finalize(); - return (0 == strcmp(hexDigest().data(), hexdigest)); -} - -const KMD5::Digest& KMD5::rawDigest() -{ - finalize(); - return m_digest; -} - -void KMD5::rawDigest( KMD5::Digest& bin ) -{ - finalize(); - memcpy( bin, m_digest, 16 ); -} - - -TQCString KMD5::hexDigest() -{ - TQCString s(33); - - finalize(); - sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], - m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], - m_digest[12], m_digest[13], m_digest[14], m_digest[15]); - - return s; -} - -void KMD5::hexDigest(TQCString& s) -{ - finalize(); - s.resize(33); - sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], - m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], - m_digest[12], m_digest[13], m_digest[14], m_digest[15]); -} - -TQCString KMD5::base64Digest() -{ - TQByteArray ba(16); - - finalize(); - memcpy(ba.data(), m_digest, 16); - return KCodecs::base64Encode(ba); -} - - -void KMD5::init() -{ - d = 0; - reset(); -} - -void KMD5::reset() -{ - m_finalized = false; - - m_count[0] = 0; - m_count[1] = 0; - - m_state[0] = 0x67452301; - m_state[1] = 0xefcdab89; - m_state[2] = 0x98badcfe; - m_state[3] = 0x10325476; - - memset ( m_buffer, 0, sizeof(*m_buffer)); - memset ( m_digest, 0, sizeof(*m_digest)); -} - -void KMD5::transform( const unsigned char block[64] ) -{ - - TQ_UINT32 a = m_state[0], b = m_state[1], c = m_state[2], d = m_state[3], x[16]; - - decode (x, block, 64); - //memcpy( x, block, 64 ); - - Q_ASSERT(!m_finalized); // not just a user error, since the method is private - - /* Round 1 */ - FF (a, b, c, d, x[ 0], KMD5_S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], KMD5_S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], KMD5_S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], KMD5_S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], KMD5_S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], KMD5_S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], KMD5_S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], KMD5_S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], KMD5_S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], KMD5_S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], KMD5_S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], KMD5_S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], KMD5_S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], KMD5_S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], KMD5_S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], KMD5_S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], KMD5_S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], KMD5_S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], KMD5_S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], KMD5_S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], KMD5_S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], KMD5_S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], KMD5_S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], KMD5_S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], KMD5_S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], KMD5_S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], KMD5_S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], KMD5_S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], KMD5_S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], KMD5_S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], KMD5_S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], KMD5_S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], KMD5_S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], KMD5_S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], KMD5_S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], KMD5_S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], KMD5_S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], KMD5_S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], KMD5_S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], KMD5_S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], KMD5_S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], KMD5_S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], KMD5_S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], KMD5_S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], KMD5_S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], KMD5_S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], KMD5_S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], KMD5_S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], KMD5_S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], KMD5_S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], KMD5_S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], KMD5_S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], KMD5_S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], KMD5_S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], KMD5_S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], KMD5_S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], KMD5_S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], KMD5_S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], KMD5_S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], KMD5_S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], KMD5_S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], KMD5_S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], KMD5_S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], KMD5_S44, 0xeb86d391); /* 64 */ - - m_state[0] += a; - m_state[1] += b; - m_state[2] += c; - m_state[3] += d; - - memset ( static_cast<void *>(x), 0, sizeof(x) ); -} - -inline TQ_UINT32 KMD5::rotate_left (TQ_UINT32 x, TQ_UINT32 n) -{ - return (x << n) | (x >> (32-n)) ; -} - -inline TQ_UINT32 KMD5::F (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return (x & y) | (~x & z); -} - -inline TQ_UINT32 KMD5::G (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return (x & z) | (y & ~z); -} - -inline TQ_UINT32 KMD5::H (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return x ^ y ^ z; -} - -inline TQ_UINT32 KMD5::I (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return y ^ (x | ~z); -} - -void KMD5::FF ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s, TQ_UINT32 ac ) -{ - a += F(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -void KMD5::GG ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s, TQ_UINT32 ac) -{ - a += G(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -void KMD5::HH ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s, TQ_UINT32 ac ) -{ - a += H(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -void KMD5::II ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s, TQ_UINT32 ac ) -{ - a += I(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - - -void KMD5::encode ( unsigned char* output, TQ_UINT32 *in, TQ_UINT32 len ) -{ -#if !defined(WORDS_BIGENDIAN) - memcpy(output, in, len); - -#else - TQ_UINT32 i, j; - for (i = 0, j = 0; j < len; i++, j += 4) - { - output[j] = static_cast<TQ_UINT8>((in[i] & 0xff)); - output[j+1] = static_cast<TQ_UINT8>(((in[i] >> 8) & 0xff)); - output[j+2] = static_cast<TQ_UINT8>(((in[i] >> 16) & 0xff)); - output[j+3] = static_cast<TQ_UINT8>(((in[i] >> 24) & 0xff)); - } -#endif -} - -// Decodes in (TQ_UINT8) into output (TQ_UINT32). Assumes len is a -// multiple of 4. -void KMD5::decode (TQ_UINT32 *output, const unsigned char* in, TQ_UINT32 len) -{ -#if !defined(WORDS_BIGENDIAN) - memcpy(output, in, len); - -#else - TQ_UINT32 i, j; - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = static_cast<TQ_UINT32>(in[j]) | - (static_cast<TQ_UINT32>(in[j+1]) << 8) | - (static_cast<TQ_UINT32>(in[j+2]) << 16) | - (static_cast<TQ_UINT32>(in[j+3]) << 24); -#endif -} - - - -/**************************************************************/ - - - -/***********************************************************/ - -KMD4::KMD4() -{ - init(); -} - -KMD4::KMD4(const char *in, int len) -{ - init(); - update(in, len); -} - -KMD4::KMD4(const TQByteArray& in) -{ - init(); - update( in ); -} - -KMD4::KMD4(const TQCString& in) -{ - init(); - update( in ); -} - -void KMD4::update(const TQByteArray& in) -{ - update(in.data(), int(in.size())); -} - -void KMD4::update(const TQCString& in) -{ - update(in.data(), int(in.length())); -} - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void KMD4::update(const unsigned char *in, int len) -{ - if (len < 0) - len = tqstrlen(reinterpret_cast<const char*>(in)); - - if (!len) - return; - - if (m_finalized) { - kdWarning() << "KMD4::update called after state was finalized!" << endl; - return; - } - - TQ_UINT32 t; - - /* Update bitcount */ - - t = m_count[0]; - if ((m_count[0] = t + ((TQ_UINT32) len << 3)) < t) - m_count[1]++; /* Carry from low to high */ - m_count[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) - { - TQ_UINT8 *p = &m_buffer[ t ]; - - t = 64 - t; - if ((TQ_UINT32)len < t) - { - memcpy (p, in, len); - return; - } - memcpy (p, in, t); - byteReverse (m_buffer, 16); - transform (m_state, (TQ_UINT32*) m_buffer); - in += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) - { - memcpy (m_buffer, in, 64); - byteReverse (m_buffer, 16); - transform (m_state, (TQ_UINT32 *) m_buffer); - in += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memcpy (m_buffer, in, len); -} - -bool KMD4::update(TQIODevice& file) -{ - char buffer[1024]; - int len; - - while ((len=file.readBlock(reinterpret_cast<char*>(buffer), sizeof(buffer))) > 0) - update(buffer, len); - - return file.atEnd(); -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void KMD4::finalize() -{ - unsigned int count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (m_count[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = m_buffer + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) - { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset (p, 0, count); - byteReverse (m_buffer, 16); - transform (m_state, (TQ_UINT32*) m_buffer); - - /* Now fill the next block with 56 bytes */ - memset (m_buffer, 0, 56); - } - else - { - /* Pad block to 56 bytes */ - memset (p, 0, count - 8); - } - byteReverse (m_buffer, 14); - - /* Append length in bits and transform */ - ((TQ_UINT32 *) m_buffer)[14] = m_count[0]; - ((TQ_UINT32 *) m_buffer)[15] = m_count[1]; - - transform (m_state, (TQ_UINT32 *) m_buffer); - byteReverse ((unsigned char *) m_state, 4); - - memcpy (m_digest, m_state, 16); - memset ( (void *)m_buffer, 0, sizeof(*m_buffer)); - - m_finalized = true; -} - -bool KMD4::verify( const KMD4::Digest& digest) -{ - finalize(); - return (0 == memcmp(rawDigest(), digest, sizeof(KMD4::Digest))); -} - -bool KMD4::verify( const TQCString& hexdigest) -{ - finalize(); - return (0 == strcmp(hexDigest().data(), hexdigest)); -} - -const KMD4::Digest& KMD4::rawDigest() -{ - finalize(); - return m_digest; -} - -void KMD4::rawDigest( KMD4::Digest& bin ) -{ - finalize(); - memcpy( bin, m_digest, 16 ); -} - -TQCString KMD4::hexDigest() -{ - TQCString s(33); - - finalize(); - sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], - m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], - m_digest[12], m_digest[13], m_digest[14], m_digest[15]); -// kdDebug() << "KMD4::hexDigest() " << s << endl; - return s; -} - -void KMD4::hexDigest(TQCString& s) -{ - finalize(); - s.resize(33); - sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], - m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], - m_digest[12], m_digest[13], m_digest[14], m_digest[15]); -} - -TQCString KMD4::base64Digest() -{ - TQByteArray ba(16); - - finalize(); - memcpy(ba.data(), m_digest, 16); - return KCodecs::base64Encode(ba); -} - - -void KMD4::init() -{ - d = 0; - reset(); -} - -/* - * Start MD4 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void KMD4::reset() -{ - m_finalized = false; - - m_state[0] = 0x67452301; - m_state[1] = 0xefcdab89; - m_state[2] = 0x98badcfe; - m_state[3] = 0x10325476; - - m_count[0] = 0; - m_count[1] = 0; - - memset ( m_buffer, 0, sizeof(*m_buffer)); - memset ( m_digest, 0, sizeof(*m_digest)); -} - -//#define rotl32(x,n) (((x) << ((TQ_UINT32)(n))) | ((x) >> (32 - (TQ_UINT32)(n)))) - -inline TQ_UINT32 KMD4::rotate_left (TQ_UINT32 x, TQ_UINT32 n) -{ - return (x << n) | (x >> (32-n)) ; -} - -inline TQ_UINT32 KMD4::F (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return (x & y) | (~x & z); -} - -inline TQ_UINT32 KMD4::G (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return ((x) & (y)) | ((x) & (z)) | ((y) & (z)); -} - -inline TQ_UINT32 KMD4::H (TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z) -{ - return x ^ y ^ z; -} - -inline void KMD4::FF ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s ) -{ - a += F(b, c, d) + x; - a = rotate_left (a, s); -} - -inline void KMD4::GG ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s) -{ - a += G(b, c, d) + x + (TQ_UINT32)0x5a827999; - a = rotate_left (a, s); -} - -inline void KMD4::HH ( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, - TQ_UINT32 x, TQ_UINT32 s ) -{ - a += H(b, c, d) + x + (TQ_UINT32)0x6ed9eba1; - a = rotate_left (a, s); -} - -void KMD4::byteReverse( unsigned char *buf, TQ_UINT32 len ) -{ -#ifdef WORDS_BIGENDIAN - TQ_UINT32 *b = (TQ_UINT32*) buf; - while ( len > 0 ) { - *b = ((((*b) & 0xff000000) >> 24) | (((*b) & 0x00ff0000) >> 8) | - (((*b) & 0x0000ff00) << 8) | (((*b) & 0x000000ff) << 24)); - len--; - b++; - } -#else - Q_UNUSED(buf) - Q_UNUSED(len) -#endif -} - -/* - * The core of the MD4 algorithm - */ -void KMD4::transform( TQ_UINT32 buf[4], TQ_UINT32 const in[16] ) -{ - TQ_UINT32 a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - FF (a, b, c, d, in[0], 3); /* 1 */ - FF (d, a, b, c, in[1], 7); /* 2 */ - FF (c, d, a, b, in[2], 11); /* 3 */ - FF (b, c, d, a, in[3], 19); /* 4 */ - FF (a, b, c, d, in[4], 3); /* 5 */ - FF (d, a, b, c, in[5], 7); /* 6 */ - FF (c, d, a, b, in[6], 11); /* 7 */ - FF (b, c, d, a, in[7], 19); /* 8 */ - FF (a, b, c, d, in[8], 3); /* 9 */ - FF (d, a, b, c, in[9], 7); /* 10 */ - FF (c, d, a, b, in[10], 11); /* 11 */ - FF (b, c, d, a, in[11], 19); /* 12 */ - FF (a, b, c, d, in[12], 3); /* 13 */ - FF (d, a, b, c, in[13], 7); /* 14 */ - FF (c, d, a, b, in[14], 11); /* 15 */ - FF (b, c, d, a, in[15], 19); /* 16 */ - - GG (a, b, c, d, in[0], 3); /* 17 */ - GG (d, a, b, c, in[4], 5); /* 18 */ - GG (c, d, a, b, in[8], 9); /* 19 */ - GG (b, c, d, a, in[12], 13); /* 20 */ - GG (a, b, c, d, in[1], 3); /* 21 */ - GG (d, a, b, c, in[5], 5); /* 22 */ - GG (c, d, a, b, in[9], 9); /* 23 */ - GG (b, c, d, a, in[13], 13); /* 24 */ - GG (a, b, c, d, in[2], 3); /* 25 */ - GG (d, a, b, c, in[6], 5); /* 26 */ - GG (c, d, a, b, in[10], 9); /* 27 */ - GG (b, c, d, a, in[14], 13); /* 28 */ - GG (a, b, c, d, in[3], 3); /* 29 */ - GG (d, a, b, c, in[7], 5); /* 30 */ - GG (c, d, a, b, in[11], 9); /* 31 */ - GG (b, c, d, a, in[15], 13); /* 32 */ - - HH (a, b, c, d, in[0], 3); /* 33 */ - HH (d, a, b, c, in[8], 9); /* 34 */ - HH (c, d, a, b, in[4], 11); /* 35 */ - HH (b, c, d, a, in[12], 15); /* 36 */ - HH (a, b, c, d, in[2], 3); /* 37 */ - HH (d, a, b, c, in[10], 9); /* 38 */ - HH (c, d, a, b, in[6], 11); /* 39 */ - HH (b, c, d, a, in[14], 15); /* 40 */ - HH (a, b, c, d, in[1], 3); /* 41 */ - HH (d, a, b, c, in[9], 9); /* 42 */ - HH (c, d, a, b, in[5], 11); /* 43 */ - HH (b, c, d, a, in[13], 15); /* 44 */ - HH (a, b, c, d, in[3], 3); /* 45 */ - HH (d, a, b, c, in[11], 9); /* 46 */ - HH (c, d, a, b, in[7], 11); /* 47 */ - HH (b, c, d, a, in[15], 15); /* 48 */ - - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} diff --git a/kdecore/kmdcodec.h b/kdecore/kmdcodec.h deleted file mode 100644 index d4bd8dfb0..000000000 --- a/kdecore/kmdcodec.h +++ /dev/null @@ -1,745 +0,0 @@ -/* - Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> - Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License (LGPL) - version 2 as published by the Free Software Foundation. - - 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 General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. - RSA Data Security, Inc. Created 1991. All rights reserved. - - The KMD5 class is based on a C++ implementation of - "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by - Mordechai T. Abzug, Copyright (c) 1995. This implementation - passes the test-suite as defined in RFC 1321. - - The encoding and decoding utilities in KCodecs with the exception of - quoted-printable are based on the java implementation in HTTPClient - package by Ronald Tschalär Copyright (C) 1996-1999. - - The quoted-printable codec as described in RFC 2045, section 6.7. is by - Rik Hemsley (C) 2001. -*/ - -#ifndef _KMDBASE_H -#define _KMDBASE_H - -#define KBase64 KCodecs - -#include <tqglobal.h> -#include <tqstring.h> -#include <tqiodevice.h> -#include "kdelibs_export.h" - -/** - * A wrapper class for the most commonly used encoding and - * decoding algorithms. Currently there is support for encoding - * and decoding input using base64, uu and the quoted-printable - * specifications. - * - * \b Usage: - * - * \code - * TQCString input = "Aladdin:open sesame"; - * TQCString result = KCodecs::base64Encode(input); - * cout << "Result: " << result.data() << endl; - * \endcode - * - * <pre> - * Output should be - * Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ== - * </pre> - * - * The above example makes use of the convenience functions - * (ones that accept/return null-terminated strings) to encode/decode - * a string. If what you need is to encode or decode binary data, then - * it is highly recommended that you use the functions that take an input - * and output TQByteArray as arguments. These functions are specifically - * tailored for encoding and decoding binary data. - * - * @short A collection of commonly used encoding and decoding algorithms. - * @author Dawit Alemayehu <adawit@kde.org> - * @author Rik Hemsley <rik@kde.org> - */ -class KDECORE_EXPORT KCodecs -{ -public: - - /** - * Encodes the given data using the quoted-printable algorithm. - * - * @param in data to be encoded. - * @param useCRLF if true the input data is expected to have - * CRLF line breaks and the output will have CRLF line - * breaks, too. - * @return quoted-printable encoded string. - */ - static TQCString quotedPrintableEncode(const TQByteArray & in, - bool useCRLF = true); - - /** - * @overload - * - * Same as above except it accepts a null terminated - * string instead an array. - * - * @param str string to be encoded. - * @param useCRLF if true the input data is expected to have - * CRLF line breaks and the output will have CRLF line - * breaks, too. - * @return quoted-printable encoded string. - */ - static TQCString quotedPrintableEncode(const TQCString & str, - bool useCRLF = true); - - /** - * Encodes the given data using the quoted-printable algorithm. - * - * Use this function if you want the result of the encoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for encoding binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be encoded. - * @param out encoded data. - * @param useCRLF if true the input data is expected to have - * CRLF line breaks and the output will have CRLF line - * breaks, too. - */ - static void quotedPrintableEncode(const TQByteArray & in, TQByteArray& out, - bool useCRLF); - - /** - * Decodes a quoted-printable encoded data. - * - * Accepts data with CRLF or standard unix line breaks. - * - * @param in data to be decoded. - * @return decoded string. - */ - static TQCString quotedPrintableDecode(const TQByteArray & in); - - /** - * @overload - * - * Same as above except it accepts a null terminated - * string instead an array. - * - * @param str string to be decoded. - * @return decoded string. - */ - static TQCString quotedPrintableDecode(const TQCString & str); - - /** - * Decodes a quoted-printable encoded data. - * - * Accepts data with CRLF or standard unix line breaks. - * Use this function if you want the result of the decoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for decoding an encoded - * binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be decoded. - * @param out decoded data. - */ - static void quotedPrintableDecode(const TQByteArray & in, TQByteArray& out); - - - /** - * Encodes the given data using the uuencode algorithm. - * - * The output is split into lines starting with the number of - * encoded octets in the line and ending with a newline. No - * line is longer than 45 octets (60 characters), excluding the - * line terminator. - * - * @param in data to be uuencoded - * @return uuencoded string. - */ - static TQCString uuencode( const TQByteArray& in ); - - /** - * @overload - * - * Same as the above functions except it accepts - * a null terminated string instead an array. - * - * @param str string to be uuencoded. - * @return encoded string. - */ - static TQCString uuencode( const TQCString& str ); - - /** - * Encodes the given data using the uuencode algorithm. - * - * Use this function if you want the result of the encoding - * to be placed in another array and cut down the number of - * copy operation that have to be performed in the process. - * This is the preffered method for encoding binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be uuencoded. - * @param out uudecoded data. - */ - static void uuencode( const TQByteArray& in, TQByteArray& out ); - - /** - * Decodes the given data using the uudecode algorithm. - * - * Any 'begin' and 'end' lines like those generated by - * the utilities in unix and unix-like OS will be - * automatically ignored. - * - * @param in data to be decoded. - * @return decoded string. - */ - static TQCString uudecode( const TQByteArray& in ); - - /** - * @overload - * - * Same as the above functions except it accepts - * a null terminated string instead an array. - * - * @param str string to be decoded. - * @return uudecoded string. - */ - static TQCString uudecode( const TQCString& str ); - - /** - * Decodes the given data using the uudecode algorithm. - * - * Use this function if you want the result of the decoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is the preferred method for decoding binary data. - * - * Any 'begin' and 'end' lines like those generated by - * the utilities in unix and unix-like OS will be - * automatically ignored. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be decoded. - * @param out uudecoded data. - */ - static void uudecode( const TQByteArray& in, TQByteArray& out ); - - - /** - * Encodes the given data using the base64 algorithm. - * - * The boolean argument determines if the encoded data is - * going to be restricted to 76 characters or less per line - * as specified by RFC 2045. If @p insertLFs is true, then - * there will be 76 characters or less per line. - * - * @param in data to be encoded. - * @param insertLFs limit the number of characters per line. - * - * @return base64 encoded string. - */ - static TQCString base64Encode( const TQByteArray& in, bool insertLFs = false); - - /** - * @overload - * - * Same as the above functions except it accepts - * a null terminated string instead an array. - * - * @param str string to be encoded. - * @param insertLFs limit the number of characters per line. - * @return decoded string. - */ - static TQCString base64Encode( const TQCString& str, bool insertLFs = false ); - - /** - * Encodes the given data using the base64 algorithm. - * - * Use this function if you want the result of the encoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for encoding binary data. - * - * The boolean argument determines if the encoded data is going - * to be restricted to 76 characters or less per line as specified - * by RFC 2045. If @p insertLFs is true, then there will be 76 - * characters or less per line. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be encoded. - * @param out encoded data. - * @param insertLFs limit the number of characters per line. - */ - static void base64Encode( const TQByteArray& in, TQByteArray& out, - bool insertLFs = false ); - - /** - * Decodes the given data that was encoded using the - * base64 algorithm. - * - * @param in data to be decoded. - * @return decoded string. - */ - static TQCString base64Decode( const TQByteArray& in ); - - /** - * @overload - * - * Same as the above functions except it accepts - * a null terminated string instead an array. - * - * @param str string to be decoded. - * @return decoded string. - */ - static TQCString base64Decode( const TQCString& str ); - - /** - * Decodes the given data that was encoded with the base64 - * algorithm. - * - * Use this function if you want the result of the decoding - * to be placed in another array which cuts down the number - * of copy operation that have to be performed in the process. - * This is also the preferred method for decoding an encoded - * binary data. - * - * NOTE: the output array is first reset and then resized - * appropriately before use, hence, all data stored in the - * output array will be lost. - * - * @param in data to be decoded. - * @param out decoded data. - */ - static void base64Decode( const TQByteArray& in, TQByteArray& out ); - - -private: - KCodecs(); - -private: - static const char UUEncMap[64]; - static const char UUDecMap[128]; - static const char Base64EncMap[64]; - static const char Base64DecMap[128]; - static const char hexChars[16]; - static const unsigned int maxQPLineLength; -}; - -class KMD5Private; -/** - * @short An adapted C++ implementation of RSA Data Securities MD5 algorithm. - * - * The default constructor is designed to provide much the same - * functionality as the most commonly used C-implementation, while - * the other three constructors are meant to further simplify the - * process of obtaining a digest by calculating the result in a - * single step. - * - * KMD5 is state-based, that means you can add new contents with - * update() as long as you didn't request the digest value yet. - * After the digest value was requested, the object is "finalized" - * and you have to call reset() to be able to do another calculation - * with it. The reason for this behavior is that upon requesting - * the message digest KMD5 has to pad the received contents up to a - * 64 byte boundary to calculate its value. After this operation it - * is not possible to resume consuming data. - * - * \b Usage: - * - * A common usage of this class: - * - * \code - * const char* test1; - * KMD5::Digest rawResult; - * - * test1 = "This is a simple test."; - * KMD5 context (test1); - * cout << "Hex Digest output: " << context.hexDigest().data() << endl; - * \endcode - * - * To cut down on the unnecessary overhead of creating multiple KMD5 - * objects, you can simply invoke reset() to reuse the same object - * in making another calculation: - * - * \code - * context.reset (); - * context.update ("TWO"); - * context.update ("THREE"); - * cout << "Hex Digest output: " << context.hexDigest().data() << endl; - * \endcode - * - * @author Dirk Mueller <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org> - */ - -class KDECORE_EXPORT KMD5 -{ -public: - - typedef unsigned char Digest[16]; - - KMD5(); - - /** - * Constructor that updates the digest for the given string. - * - * @param in C string or binary data - * @param len if negative, calculates the length by using - * strlen on the first parameter, otherwise - * it trusts the given length (does not stop on NUL byte). - */ - KMD5(const char* in, int len = -1); - - /** - * @overload - * - * Same as above except it accepts a TQByteArray as its argument. - */ - KMD5(const TQByteArray& a ); - - /** - * @overload - * - * Same as above except it accepts a TQCString as its argument. - */ - KMD5(const TQCString& a ); - - /** - * Updates the message to be digested. Be sure to add all data - * before you read the digest. After reading the digest, you - * can <b>not</b> add more data! - * - * @param in message to be added to digest - * @param len the length of the given message. - */ - void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); } - - /** - * @overload - */ - void update(const unsigned char* in, int len = -1); - - /** - * @overload - * - * @param in message to be added to the digest (TQByteArray). - */ - void update(const TQByteArray& in ); - - /** - * @overload - * - * @param in message to be added to the digest (TQCString). - */ - void update(const TQCString& in ); - - /** - * @overload - * - * reads the data from an I/O device, i.e. from a file (TQFile). - * - * NOTE that the file must be open for reading. - * - * @param file a pointer to FILE as returned by calls like f{d,re}open - * - * @returns false if an error occurred during reading. - */ - bool update(TQIODevice& file); - - /** - * Calling this function will reset the calculated message digest. - * Use this method to perform another message digest calculation - * without recreating the KMD5 object. - */ - void reset(); - - /** - * @return the raw representation of the digest - */ - const Digest& rawDigest (); - - /** - * Fills the given array with the binary representation of the - * message digest. - * - * Use this method if you do not want to worry about making - * copy of the digest once you obtain it. - * - * @param bin an array of 16 characters ( char[16] ) - */ - void rawDigest( KMD5::Digest& bin ); - - /** - * Returns the value of the calculated message digest in - * a hexadecimal representation. - */ - TQCString hexDigest (); - - /** - * @overload - */ - void hexDigest(TQCString&); - - /** - * Returns the value of the calculated message digest in - * a base64-encoded representation. - */ - TQCString base64Digest (); - - /** - * returns true if the calculated digest for the given - * message matches the given one. - */ - bool verify( const KMD5::Digest& digest); - - /** - * @overload - */ - bool verify(const TQCString&); - -protected: - /** - * Performs the real update work. Note - * that length is implied to be 64. - */ - void transform( const unsigned char buffer[64] ); - - /** - * finalizes the digest - */ - void finalize(); - -private: - KMD5(const KMD5& u); - KMD5& operator=(const KMD5& md); - - void init(); - void encode( unsigned char* output, TQ_UINT32 *in, TQ_UINT32 len ); - void decode( TQ_UINT32 *output, const unsigned char* in, TQ_UINT32 len ); - - TQ_UINT32 rotate_left( TQ_UINT32 x, TQ_UINT32 n ); - TQ_UINT32 F( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - TQ_UINT32 G( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - TQ_UINT32 H( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - TQ_UINT32 I( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - void FF( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s, TQ_UINT32 ac ); - void GG( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s, TQ_UINT32 ac ); - void HH( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s, TQ_UINT32 ac ); - void II( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s, TQ_UINT32 ac ); - -private: - TQ_UINT32 m_state[4]; - TQ_UINT32 m_count[2]; - TQ_UINT8 m_buffer[64]; - Digest m_digest; - bool m_finalized; - - KMD5Private* d; -}; - -/** - * @short An adapted C++ implementation of the MD4 Message-Digest algorithm. - * @since 3.4 - * - * The class usage is the same as KMD5. - */ -class KDECORE_EXPORT KMD4 -{ -public: - - typedef unsigned char Digest[16]; - - KMD4(); - - /** - * Constructor that updates the digest for the given string. - * - * @param in C string or binary data - * @param len if negative, calculates the length by using - * strlen on the first parameter, otherwise - * it trusts the given length (does not stop on NUL byte). - */ - KMD4(const char* in, int len = -1); - - /** - * @overload - * - * Same as above except it accepts a TQByteArray as its argument. - */ - KMD4(const TQByteArray& a ); - - /** - * @overload - * - * Same as above except it accepts a TQCString as its argument. - */ - KMD4(const TQCString& a ); - - /** - * Updates the message to be digested. Be sure to add all data - * before you read the digest. After reading the digest, you - * can <b>not</b> add more data! - * - * @param in message to be added to digest - * @param len the length of the given message. - */ - void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); } - - /** - * @overload - */ - void update(const unsigned char* in, int len = -1); - - /** - * @overload - * - * @param in message to be added to the digest (TQByteArray). - */ - void update(const TQByteArray& in ); - - /** - * @overload - * - * @param in message to be added to the digest (TQCString). - */ - void update(const TQCString& in ); - - /** - * @overload - * - * reads the data from an I/O device, i.e. from a file (TQFile). - * - * NOTE that the file must be open for reading. - * - * @param file a pointer to FILE as returned by calls like f{d,re}open - * - * @returns false if an error occurred during reading. - */ - bool update(TQIODevice& file); - - /** - * Calling this function will reset the calculated message digest. - * Use this method to perform another message digest calculation - * without recreating the KMD4 object. - */ - void reset(); - - /** - * @return the raw representation of the digest - */ - const Digest& rawDigest (); - - /** - * Fills the given array with the binary representation of the - * message digest. - * - * Use this method if you do not want to worry about making - * copy of the digest once you obtain it. - * - * @param bin an array of 16 characters ( char[16] ) - */ - void rawDigest( KMD4::Digest& bin ); - - /** - * Returns the value of the calculated message digest in - * a hexadecimal representation. - */ - TQCString hexDigest (); - - /** - * @overload - */ - void hexDigest(TQCString&); - - /** - * Returns the value of the calculated message digest in - * a base64-encoded representation. - */ - TQCString base64Digest (); - - /** - * returns true if the calculated digest for the given - * message matches the given one. - */ - bool verify( const KMD4::Digest& digest); - - /** - * @overload - */ - bool verify(const TQCString&); - -protected: - /** - * Performs the real update work. Note - * that length is implied to be 64. - */ - void transform( TQ_UINT32 buf[4], TQ_UINT32 const in[16] ); - - /** - * finalizes the digest - */ - void finalize(); - -private: - KMD4(const KMD4& u); - KMD4& operator=(const KMD4& md); - - void init(); - - void byteReverse( unsigned char *buf, TQ_UINT32 len ); - - TQ_UINT32 rotate_left( TQ_UINT32 x, TQ_UINT32 n ); - TQ_UINT32 F( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - TQ_UINT32 G( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - TQ_UINT32 H( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 z ); - void FF( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s ); - void GG( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s ); - void HH( TQ_UINT32& a, TQ_UINT32 b, TQ_UINT32 c, TQ_UINT32 d, TQ_UINT32 x, - TQ_UINT32 s ); - -private: - TQ_UINT32 m_state[4]; - TQ_UINT32 m_count[2]; - TQ_UINT8 m_buffer[64]; - Digest m_digest; - bool m_finalized; - - class KMD4Private; - KMD4Private* d; -}; - - -#endif diff --git a/kdecore/kmdcodec_compat.h b/kdecore/kmdcodec_compat.h deleted file mode 100644 index f2ed3b580..000000000 --- a/kdecore/kmdcodec_compat.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef __GNUC__ -#warning #include <kio/kmdcodec.h> is deprecated, use #include <kmdcodec.h> instead. -#endif -#include "../kmdcodec.h" diff --git a/kdecore/kmimesourcefactory.cpp b/kdecore/kmimesourcefactory.cpp deleted file mode 100644 index 37745d398..000000000 --- a/kdecore/kmimesourcefactory.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - 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. -*/ - -#include <kdebug.h> -#include <kglobal.h> -#include <kinstance.h> -#include <kiconloader.h> - -#include "kmimesourcefactory.h" - -class KMimeSourceFactoryPrivate -{ -public: - inline KMimeSourceFactoryPrivate (KIconLoader* loader) : m_iconLoader(loader), m_instance(0L) {} - inline KIconLoader *iconLoader() - { - // If we don't have either of these, things are looking grim. - Q_ASSERT(m_instance || m_iconLoader); - - if (m_iconLoader) - return m_iconLoader; - - return m_instance->iconLoader(); - } - - KIconLoader *m_iconLoader; - KInstance *m_instance; -}; - -KMimeSourceFactory::KMimeSourceFactory (KIconLoader* loader) - : TQMimeSourceFactory (), - d (new KMimeSourceFactoryPrivate (loader)) -{ -} - -KMimeSourceFactory::~KMimeSourceFactory() -{ - delete d; -} - -TQString KMimeSourceFactory::makeAbsolute (const TQString& absOrRelName, const TQString& context) const -{ - TQString myName; - TQString myContext; - - const int pos = absOrRelName.find ('|'); - if (pos > -1) - { - myContext = absOrRelName.left (pos); - myName = absOrRelName.right (absOrRelName.length() - myContext.length() - 1); - } - - TQString result; - - if (myContext == "desktop") - { - result = d->iconLoader()->iconPath (myName, KIcon::Desktop); - } - else if (myContext == "toolbar") - { - result = d->iconLoader()->iconPath (myName, KIcon::Toolbar); - } - else if (myContext == "maintoolbar") - { - result = d->iconLoader()->iconPath (myName, KIcon::MainToolbar); - } - else if (myContext == "small") - { - result = d->iconLoader()->iconPath (myName, KIcon::Small); - } - else if (myContext == "user") - { - result = d->iconLoader()->iconPath (myName, KIcon::User); - } - - if (result.isEmpty()) - result = TQMimeSourceFactory::makeAbsolute (absOrRelName, context); - - return result; -} - -void KMimeSourceFactory::setInstance(KInstance *instance) -{ - d->m_instance = instance; -} - -void KMimeSourceFactory::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - diff --git a/kdecore/kmimesourcefactory.h b/kdecore/kmimesourcefactory.h deleted file mode 100644 index 536ead0b8..000000000 --- a/kdecore/kmimesourcefactory.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> - - 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 KMIMESOURCEFACTORY_H -#define KMIMESOURCEFACTORY_H - -#include <tqmime.h> -#include <kglobal.h> - -class KMimeSourceFactoryPrivate; -class KInstance; - -/** - * An extension to TQMimeSourceFactory that uses KIconLoader to - * find images. - * - * Normally you don't have to instantiate this class at all, KApplication does that for - * you automagically and sets TQMimeSourceFactory::setDefaultFactory(). - * - * @author Peter Putzer <putzer@kde.org> - */ -class KDECORE_EXPORT KMimeSourceFactory : public TQMimeSourceFactory -{ -public: - - /** - * Constructor. - * - * @param loader is the iconloader used to find images. - */ - KMimeSourceFactory (KIconLoader* loader = KGlobal::iconLoader()); - - /** - * Destructor. - */ - virtual ~KMimeSourceFactory(); - - /** - * This function is maps an absolute or relative name for a resource to - * the absolute one. - * - * To load an icon, prepend the @p category name before the @p icon name, in the style - * of \<category>|\<icon>. - * - * Example: - * \code "<img src=\"user|ksysv_start\"/>", "<img src="\desktop|trash\">", ... - * \endcode - * - * @param abs_or_rel_name is the absolute or relative pathname. - * @param context is the path of the context object for the queried resource. Almost always empty. - */ - virtual TQString makeAbsolute (const TQString& abs_or_rel_name, const TQString& context) const; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - /** - * @internal - * Associate with a KInstance so we can pull its iconLoader() when need arises. - */ - friend class KInstance; - void setInstance(KInstance *); - - KMimeSourceFactoryPrivate* d; -}; - -#endif // KMIMESOURCEFACTORY_H diff --git a/kdecore/kmountpoint.cpp b/kdecore/kmountpoint.cpp deleted file mode 100644 index 764f085a0..000000000 --- a/kdecore/kmountpoint.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - * - * This file is part of the KDE libraries - * Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - * - * $Id$ - * - * 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 <stdlib.h> - -#include <tqfile.h> - -#include "kstandarddirs.h" - -#include "kmountpoint.h" - -#ifdef HAVE_VOLMGT -#include <volmgt.h> -#endif -#ifdef HAVE_SYS_MNTTAB_H -#include <sys/mnttab.h> -#endif -#ifdef HAVE_MNTENT_H -#include <mntent.h> -#elif defined(HAVE_SYS_MNTENT_H) -#include <sys/mntent.h> -#endif - -// This is the *BSD branch -#ifdef HAVE_SYS_MOUNT_H -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif -#include <sys/mount.h> -#endif - -#ifdef HAVE_FSTAB_H -#include <fstab.h> -#endif -#if defined(_AIX) -#include <sys/mntctl.h> -#include <sys/vmount.h> -#include <sys/vfs.h> -/* AIX does not prototype mntctl anywhere that I can find */ -#ifndef mntctl -extern "C" { -int mntctl(int command, int size, void* buffer); -} -#endif -extern "C" struct vfs_ent *getvfsbytype(int vfsType); -extern "C" void endvfsent( ); -#endif - - -#ifndef HAVE_GETMNTINFO -# ifdef _PATH_MOUNTED -// On some Linux, MNTTAB points to /etc/fstab ! -# undef MNTTAB -# define MNTTAB _PATH_MOUNTED -# else -# ifndef MNTTAB -# ifdef MTAB_FILE -# define MNTTAB MTAB_FILE -# else -# define MNTTAB "/etc/mnttab" -# endif -# endif -# endif -#endif - - - -#ifdef _OS_SOLARIS_ -#define FSTAB "/etc/vfstab" -#else -#define FSTAB "/etc/fstab" -#endif - - - -KMountPoint::KMountPoint() -{ -} - -KMountPoint::~KMountPoint() -{ -} - -#ifdef HAVE_SETMNTENT -#define SETMNTENT setmntent -#define ENDMNTENT endmntent -#define STRUCT_MNTENT struct mntent * -#define STRUCT_SETMNTENT FILE * -#define GETMNTENT(file, var) ((var = getmntent(file)) != 0) -#define MOUNTPOINT(var) var->mnt_dir -#define MOUNTTYPE(var) var->mnt_type -#define MOUNTOPTIONS(var) var->mnt_opts -#define FSNAME(var) var->mnt_fsname -#else -#define SETMNTENT fopen -#define ENDMNTENT fclose -#define STRUCT_MNTENT struct mnttab -#define STRUCT_SETMNTENT FILE * -#define GETMNTENT(file, var) (getmntent(file, &var) == 0) -#define MOUNTPOINT(var) var.mnt_mountp -#define MOUNTTYPE(var) var.mnt_fstype -#define MOUNTOPTIONS(var) var.mnt_mntopts -#define FSNAME(var) var.mnt_special -#endif - -KMountPoint::List KMountPoint::possibleMountPoints(int infoNeeded) -{ - KMountPoint::List result; - -#ifdef HAVE_SETMNTENT - STRUCT_SETMNTENT fstab; - if ((fstab = SETMNTENT(FSTAB, "r")) == 0) - return result; - - STRUCT_MNTENT fe; - while (GETMNTENT(fstab, fe)) - { - KMountPoint *mp = new KMountPoint(); - mp->m_mountedFrom = TQFile::decodeName(FSNAME(fe)); - - mp->m_mountPoint = TQFile::decodeName(MOUNTPOINT(fe)); - mp->m_mountType = TQFile::decodeName(MOUNTTYPE(fe)); - - //Devices using supermount have their device names in the mount options - //instead of the device field. That's why we need to read the mount options - if (infoNeeded & NeedMountOptions || (mp->m_mountType == "supermount")) - { - TQString options = TQFile::decodeName(MOUNTOPTIONS(fe)); - mp->m_mountOptions = TQStringList::split(',', options); - } - - if(mp->m_mountType == "supermount") - mp->m_mountedFrom = devNameFromOptions(mp->m_mountOptions); - - if (infoNeeded & NeedRealDeviceName) - { - if (mp->m_mountedFrom.startsWith("/")) - mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom); - } - // TODO: Strip trailing '/' ? - result.append(mp); - } - ENDMNTENT(fstab); -#else - TQFile f(FSTAB); - if ( !f.open(IO_ReadOnly) ) - return result; - - TQTextStream t (&f); - TQString s; - - while (! t.eof()) - { - s=t.readLine().simplifyWhiteSpace(); - if ( s.isEmpty() || (s[0] == '#')) - continue; - - // not empty or commented out by '#' - TQStringList item = TQStringList::split(' ', s); - -#ifdef _OS_SOLARIS_ - if (item.count() < 5) - continue; -#else - if (item.count() < 4) - continue; -#endif - - KMountPoint *mp = new KMountPoint(); - - int i = 0; - mp->m_mountedFrom = item[i++]; -#ifdef _OS_SOLARIS_ - //device to fsck - i++; -#endif - mp->m_mountPoint = item[i++]; - mp->m_mountType = item[i++]; - TQString options = item[i++]; - - if (infoNeeded & NeedMountOptions) - { - mp->m_mountOptions = TQStringList::split(',', options); - } - - if (infoNeeded & NeedRealDeviceName) - { - if (mp->m_mountedFrom.startsWith("/")) - mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom); - } - // TODO: Strip trailing '/' ? - result.append(mp); - } //while - - f.close(); -#endif - return result; -} - -KMountPoint::List KMountPoint::currentMountPoints(int infoNeeded) -{ - KMountPoint::List result; - -#ifdef HAVE_GETMNTINFO - -#ifdef GETMNTINFO_USES_STATVFS - struct statvfs *mounted; -#else - struct statfs *mounted; -#endif - - int num_fs = getmntinfo(&mounted, MNT_NOWAIT); - - for (int i=0;i<num_fs;i++) - { - KMountPoint *mp = new KMountPoint(); - mp->m_mountedFrom = TQFile::decodeName(mounted[i].f_mntfromname); - mp->m_mountPoint = TQFile::decodeName(mounted[i].f_mntonname); - -#ifdef __osf__ - mp->m_mountType = TQFile::decodeName(mnt_names[mounted[i].f_type]); -#else - mp->m_mountType = TQFile::decodeName(mounted[i].f_fstypename); -#endif - - if (infoNeeded & NeedMountOptions) - { - struct fstab *ft = getfsfile(mounted[i].f_mntonname); - TQString options = TQFile::decodeName(ft->fs_mntops); - mp->m_mountOptions = TQStringList::split(',', options); - } - - if (infoNeeded & NeedRealDeviceName) - { - if (mp->m_mountedFrom.startsWith("/")) - mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom); - } - // TODO: Strip trailing '/' ? - result.append(mp); - } - -#elif defined(_AIX) - - struct vmount *mntctl_buffer; - struct vmount *vm; - char *mountedfrom; - char *mountedto; - int fsname_len, num; - int buf_sz = 4096; - - mntctl_buffer = (struct vmount*)malloc(buf_sz); - num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer); - if (num == 0) - { - buf_sz = *(int*)mntctl_buffer; - free(mntctl_buffer); - mntctl_buffer = (struct vmount*)malloc(buf_sz); - num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer); - } - - if (num > 0) - { - /* iterate through items in the vmount structure: */ - vm = (struct vmount *)mntctl_buffer; - for ( ; num > 0; num-- ) - { - /* get the name of the mounted file systems: */ - fsname_len = vmt2datasize(vm, VMT_STUB); - mountedto = (char*)malloc(fsname_len + 1); - mountedto[fsname_len] = '\0'; - strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len); - - fsname_len = vmt2datasize(vm, VMT_OBJECT); - mountedfrom = (char*)malloc(fsname_len + 1); - mountedfrom[fsname_len] = '\0'; - strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len); - - /* Look up the string for the file system type, - * as listed in /etc/vfs. - * ex.: nfs,jfs,afs,cdrfs,sfs,cachefs,nfs3,autofs - */ - struct vfs_ent* ent = getvfsbytype(vm->vmt_gfstype); - - KMountPoint *mp = new KMountPoint(); - mp->m_mountedFrom = TQFile::decodeName(mountedfrom); - mp->m_mountPoint = TQFile::decodeName(mountedto); - mp->m_mountType = TQFile::decodeName(ent->vfsent_name); - - free(mountedfrom); - free(mountedto); - - if (infoNeeded & NeedMountOptions) - { - // TODO - } - - if (infoNeeded & NeedRealDeviceName) - { - if (mp->m_mountedFrom.startsWith("/")) - mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom); - } - - result.append(mp); - - /* goto the next vmount structure: */ - vm = (struct vmount *)((char *)vm + vm->vmt_length); - } - - endvfsent( ); - } - - free( mntctl_buffer ); -#elif defined(Q_WS_WIN) - //TODO? -#else - STRUCT_SETMNTENT mnttab; - if ((mnttab = SETMNTENT(MNTTAB, "r")) == 0) - return result; - - STRUCT_MNTENT fe; - while (GETMNTENT(mnttab, fe)) - { - KMountPoint *mp = new KMountPoint(); - mp->m_mountedFrom = TQFile::decodeName(FSNAME(fe)); - - mp->m_mountPoint = TQFile::decodeName(MOUNTPOINT(fe)); - mp->m_mountType = TQFile::decodeName(MOUNTTYPE(fe)); - - //Devices using supermount have their device names in the mount options - //instead of the device field. That's why we need to read the mount options - if (infoNeeded & NeedMountOptions || (mp->m_mountType == "supermount")) - { - TQString options = TQFile::decodeName(MOUNTOPTIONS(fe)); - mp->m_mountOptions = TQStringList::split(',', options); - } - - if (mp->m_mountType == "supermount") - mp->m_mountedFrom = devNameFromOptions(mp->m_mountOptions); - - if (infoNeeded & NeedRealDeviceName) - { - if (mp->m_mountedFrom.startsWith("/")) - mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom); - } - // TODO: Strip trailing '/' ? - result.append(mp); - } - ENDMNTENT(mnttab); -#endif - return result; -} - -TQString KMountPoint::devNameFromOptions(const TQStringList &options) -{ - // Search options to find the device name - for ( TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it) - { - if( (*it).startsWith("dev=")) - return TQString(*it).remove("dev="); - } - return TQString("none"); -} diff --git a/kdecore/kmountpoint.h b/kdecore/kmountpoint.h deleted file mode 100644 index fd4fe9c5d..000000000 --- a/kdecore/kmountpoint.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - - 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 _KMOUNTPOINT_H_ -#define _KMOUNTPOINT_H_ - -#include <tqptrlist.h> -#include <tqstringlist.h> - -#include <ksharedptr.h> - -/** - * The KMountPoint class provides information about mounted and unmounted disks. - * It provides a system independent interface to fstab. - * - * @author Waldo Bastian <bastian@kde.org> - * @since 3.2 - */ -class KDECORE_EXPORT KMountPoint : public KShared -{ - typedef signed long long int filesize_t; -public: - typedef KSharedPtr<KMountPoint> Ptr; - typedef TQValueList<Ptr> List; -public: - enum { NeedMountOptions = 1, NeedRealDeviceName = 2 }; - - /** - * This function gives a list of all possible mountpoints. (fstab) - * @param infoNeeded Flags that specify which additional information - * should be fetched. - */ - static KMountPoint::List possibleMountPoints(int infoNeeded=0); - - /** - * This function gives a list of all currently used mountpoints. (mtab) - * @param infoNeeded Flags that specify which additional information - * should be fetched. - */ - static KMountPoint::List currentMountPoints(int infoNeeded=0); - - /** - * Where this filesystem gets mounted from. - * This can refer to a device, a remote server or something else. - */ - TQString mountedFrom() const { return m_mountedFrom; } - - /** - * Canonical name of the device where the filesystem got mounted from. - * (Or empty, if not a device) - * Only available when the NeedRealDeviceName flag was set. - */ - TQString realDeviceName() const { return m_device; } - - /** - * Path where the filesystem is mounted or can be mounted. - */ - TQString mountPoint() const { return m_mountPoint; } - - /** - * Type of filesystem - */ - TQString mountType() const { return m_mountType; } - - /** - * Options used to mount the filesystem. - * Only available when the NeedMountOptions flag was set. - */ - TQStringList mountOptions() const { return m_mountOptions; } - - /** - * When using supermount, the device name is in the options field - * as dev=/my/device - * @since 3.4 - */ - static TQString devNameFromOptions(const TQStringList &options); - - /** - * Destructor - */ - ~KMountPoint(); - -private: - /** - * Constructor - */ - KMountPoint(); - - TQString m_mountedFrom; - TQString m_device; - TQString m_mountPoint; - TQString m_mountType; - TQStringList m_mountOptions; - - class KMountPointPrivate; - KMountPointPrivate *d; -}; - -#endif // _KMOUNTPOINT_H_ - diff --git a/kdecore/kmultipledrag.cpp b/kdecore/kmultipledrag.cpp deleted file mode 100644 index 94abe689e..000000000 --- a/kdecore/kmultipledrag.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 David Faure <faure@kde.org> - - 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::tqencodedData( const char *mime ) const -{ - //kdDebug() << "KMultipleDrag::tqencodedData " << mime << endl; - // Iterate over the drag objects, and find the format in the right one - TQPtrListIterator<TQDragObject> 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()->tqencodedData( 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<int>::ConstIterator nit = m_numberFormats.begin(); - TQValueList<int>::ConstIterator nend = m_numberFormats.end(); - TQPtrListIterator<TQDragObject> 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/kdecore/kmultipledrag.h b/kdecore/kmultipledrag.h deleted file mode 100644 index 2490ec694..000000000 --- a/kdecore/kmultipledrag.h +++ /dev/null @@ -1,105 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001 David Faure <faure@kde.org> - - 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 <tqdragobject.h> -#include <tqvaluelist.h> -#include "kdelibs_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 <faure@kde.org> - */ -class KDECORE_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 tqencodedData( 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<TQDragObject> m_dragObjects; - TQValueList<int> m_numberFormats; -protected: - virtual void virtual_hook( int id, void* data ); -private: - KMultipleDragPrivate* d; -}; - -#endif // QT_NO_DRAGANDDROP - -#endif // KMULTIPLEDRAG_H diff --git a/kdecore/knotifyclient.cpp b/kdecore/knotifyclient.cpp deleted file mode 100644 index 185639f11..000000000 --- a/kdecore/knotifyclient.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 Charles Samuels <charles@altair.dhs.org> - 2000 Malte Starostik <starosti@zedat.fu-berlin.de> - 2000,2003 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 "knotifyclient.h" - -#include <tqdatastream.h> -#include <tqptrstack.h> - -#include <kapplication.h> -#include <kstandarddirs.h> -#include <kapplication.h> -#include <kconfig.h> -#include <dcopclient.h> -#include <kdebug.h> -#include <kstaticdeleter.h> - -static const char daemonName[] = "knotify"; - -static bool canAvoidStartupEvent( const TQString& event, const TQString& appname, int present ) -{ - static bool checkAvoid = true; - if( !checkAvoid ) - return false; - if(( appname != "kwin" && appname != "ksmserver" ) || present > 0 ) { - checkAvoid = false; - return false; - } - // startkde event is in global events file - static KConfig* configfile = appname != "ksmserver" - ? new KConfig( appname + ".eventsrc", true, false ) - : new KConfig( "knotify.eventsrc", true, false ); - static KConfig* eventsfile = appname != "ksmserver" - ? new KConfig( appname + "/eventsrc", true, false, "data" ) - : new KConfig( "knotify/eventsrc", true, false, "data" ); - configfile->setGroup( event ); - eventsfile->setGroup( event ); - int ev1 = configfile->readNumEntry( "presentation", -2 ); - int ev2 = eventsfile->readNumEntry( "default_presentation", -2 ); - if(( ev1 == -2 && ev2 == -2 ) // unknown - || ev1 > 0 // configured to have presentation - || ( ev1 == -2 && ev2 > 0 )) { // not configured, has default presentation - checkAvoid = false; - return false; - } - return true; -} - -static int sendNotifyEvent(const TQString &message, const TQString &text, - int present, int level, const TQString &sound, - const TQString &file, int winId ) -{ - if (!kapp) return 0; - - DCOPClient *client=kapp->dcopClient(); - if (!client->isAttached()) - { - client->attach(); - if (!client->isAttached()) - return 0; - } - - TQString appname = KNotifyClient::instance()->instanceName(); - - if( canAvoidStartupEvent( message, appname, present )) - return -1; // done "successfully" - there will be no event presentation - - int uniqueId = kMax( 1, kapp->random() ); // must not be 0 -- means failure! - - // knotify daemon needs toplevel window - TQWidget* widget = TQT_TQWIDGET(TQWidget::find( (WId)winId )); - if( widget ) - winId = (int)widget->tqtopLevelWidget()->winId(); - - TQByteArray data; - TQDataStream ds(data, IO_WriteOnly); - ds << message << appname << text << sound << file << present << level - << winId << uniqueId; - - if ( !KNotifyClient::startDaemon() ) - return 0; - - if ( client->send(daemonName, "Notify", "notify(TQString,TQString,TQString,TQString,TQString,int,int,int,int)", data) ) - { - return uniqueId; - } - - return 0; -} - -int KNotifyClient::event( StandardEvent type, const TQString& text ) -{ - return event( 0, type, text ); -} - -int KNotifyClient::event(const TQString &message, const TQString &text) -{ - return event(0, message, text); -} - -int KNotifyClient::userEvent(const TQString &text, int present, int level, - const TQString &sound, const TQString &file) -{ - return userEvent( 0, text, present, level, sound, file ); -} - - -int KNotifyClient::event( int winId, StandardEvent type, const TQString& text ) -{ - TQString message; - switch ( type ) { - case cannotOpenFile: - message = TQString::tqfromLatin1("cannotopenfile"); - break; - case warning: - message = TQString::tqfromLatin1("warning"); - break; - case fatalError: - message = TQString::tqfromLatin1("fatalerror"); - break; - case catastrophe: - message = TQString::tqfromLatin1("catastrophe"); - break; - case notification: // fall through - default: - message = TQString::tqfromLatin1("notification"); - break; - } - - return sendNotifyEvent( message, text, Default, Default, - TQString::null, TQString::null, winId ); -} - -int KNotifyClient::event(int winId, const TQString &message, - const TQString &text) -{ - return sendNotifyEvent(message, text, Default, Default, TQString::null, TQString::null, winId); -} - -int KNotifyClient::userEvent(int winId, const TQString &text, int present, - int level, - const TQString &sound, const TQString &file) -{ - return sendNotifyEvent(TQString::null, text, present, level, sound, file, winId); -} - -int KNotifyClient::getPresentation(const TQString &eventname) -{ - int present; - if (eventname.isEmpty()) return Default; - - KConfig eventsfile( KNotifyClient::instance()->instanceName()+".eventsrc", true, false); - eventsfile.setGroup(eventname); - - present=eventsfile.readNumEntry("presentation", -1); - - return present; -} - -TQString KNotifyClient::getFile(const TQString &eventname, int present) -{ - if (eventname.isEmpty()) return TQString::null; - - KConfig eventsfile( KNotifyClient::instance()->instanceName()+".eventsrc", true, false); - eventsfile.setGroup(eventname); - - switch (present) - { - case (Sound): - return eventsfile.readPathEntry("soundfile"); - case (Logfile): - return eventsfile.readPathEntry("logfile"); - } - - return TQString::null; -} - -int KNotifyClient::getDefaultPresentation(const TQString &eventname) -{ - int present; - if (eventname.isEmpty()) return Default; - - KConfig eventsfile( KNotifyClient::instance()->instanceName()+"/eventsrc", true, false, "data"); - eventsfile.setGroup(eventname); - - present=eventsfile.readNumEntry("default_presentation", -1); - - return present; -} - -TQString KNotifyClient::getDefaultFile(const TQString &eventname, int present) -{ - if (eventname.isEmpty()) return TQString::null; - - KConfig eventsfile( KNotifyClient::instance()->instanceName()+"/eventsrc", true, false, "data"); - eventsfile.setGroup(eventname); - - switch (present) - { - case (Sound): - return eventsfile.readPathEntry("default_sound"); - case (Logfile): - return eventsfile.readPathEntry("default_logfile"); - } - - return TQString::null; -} - -bool KNotifyClient::startDaemon() -{ - static bool firstTry = true; - if (!kapp->dcopClient()->isApplicationRegistered(daemonName)) { - if( firstTry ) { - firstTry = false; - return KApplication::startServiceByDesktopName(daemonName) == 0; - } - return false; - } - return true; -} - - -void KNotifyClient::beep(const TQString& reason) -{ - if ( !kapp || KNotifyClient::Instance::currentInstance()->useSystemBell() ) { - TQApplication::beep(); - return; - } - - DCOPClient *client=kapp->dcopClient(); - if (!client->isAttached()) - { - client->attach(); - if (!client->isAttached() || !client->isApplicationRegistered(daemonName)) - { - TQApplication::beep(); - return; - } - } - // The kaccess daemon handles visual and other audible beeps - if ( client->isApplicationRegistered( "kaccess" ) ) - { - TQApplication::beep(); - return; - } - - KNotifyClient::event(KNotifyClient::notification, reason); -} - - -KInstance * KNotifyClient::instance() { - return KNotifyClient::Instance::current(); -} - - -class KNotifyClient::InstanceStack -{ -public: - InstanceStack() { m_defaultInstance = 0; } - virtual ~InstanceStack() { delete m_defaultInstance; } - void push(Instance *instance) { m_instances.push(instance); } - - void pop(Instance *instance) - { - if (m_instances.top() == instance) - m_instances.pop(); - else if (!m_instances.isEmpty()) - { - kdWarning(160) << "Tried to remove an Instance that is not the current," << endl; - kdWarning(160) << "Resetting to the main KApplication." << endl; - m_instances.clear(); - } - else - kdWarning(160) << "Tried to remove an Instance, but the stack was empty." << endl; - } - - Instance *currentInstance() - { - if (m_instances.isEmpty()) - { - m_defaultInstance = new Instance(kapp); - } - return m_instances.top(); - } - -private: - TQPtrStack<Instance> m_instances; - Instance *m_defaultInstance; -}; - -KNotifyClient::InstanceStack * KNotifyClient::Instance::s_instances = 0L; -static KStaticDeleter<KNotifyClient::InstanceStack > instancesDeleter; - -struct KNotifyClient::InstancePrivate -{ - KInstance *instance; - bool useSystemBell; -}; - -KNotifyClient::Instance::Instance(KInstance *instance) -{ - d = new InstancePrivate; - d->instance = instance; - instances()->push(this); - - KConfig *config = instance->config(); - KConfigGroupSaver cs( config, "General" ); - d->useSystemBell = config->readBoolEntry( "UseSystemBell", false ); -} - -KNotifyClient::Instance::~Instance() -{ - if (s_instances) - s_instances->pop(this); - delete d; -} - -KNotifyClient::InstanceStack *KNotifyClient::Instance::instances() -{ - if (!s_instances) - instancesDeleter.setObject(s_instances, new InstanceStack); - return s_instances; -} - -bool KNotifyClient::Instance::useSystemBell() const -{ - return d->useSystemBell; -} - - -// static methods - -// We always return a valid KNotifyClient::Instance here. If no special one -// is available, we have a default-instance with kapp as KInstance. -// We make sure to always have that default-instance in the stack, because -// the stack might have gotten cleared in the destructor. -// We can't use QStack::setAutoDelete( true ), because no instance besides -// our default instance is owned by us. -KNotifyClient::Instance * KNotifyClient::Instance::currentInstance() -{ - return instances()->currentInstance(); -} - -KInstance *KNotifyClient::Instance::current() -{ - return currentInstance()->d->instance; -} diff --git a/kdecore/knotifyclient.h b/kdecore/knotifyclient.h deleted file mode 100644 index 2de3e297d..000000000 --- a/kdecore/knotifyclient.h +++ /dev/null @@ -1,325 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 Charles Samuels <charles@kde.org> - - 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 _KNOTIFY_CLIENT -#define _KNOTIFY_CLIENT -#include <tqstring.h> -#include "kdelibs_export.h" - -class KInstance; -#undef None // X11 headers... - -/** - * This namespace provides a method for issuing events to a KNotifyServer - * call KNotifyClient::event("eventname"); to issue it. - * On installation, there should be a file called - * $KDEDIR/share/apps/appname/eventsrc which contains the events. - * - * The file looks like this: - * \code - * [!Global!] - * IconName=Filename (e.g. kdesktop, without any extension) - * Comment=FriendlyNameOfApp - * - * [eventname] - * Name=FriendlyNameOfEvent - * Comment=Description Of Event - * default_sound=filetoplay.wav - * default_logfile=logfile.txt - * default_commandline=command - * default_presentation=1 - * ... - * \endcode - * default_presentation contains these ORed events: - * None=0, Sound=1, Messagebox=2, Logfile=4, Stderr=8, PassivePopup=16, - * Execute=32, Taskbar=64 - * - * KNotify will search for sound files given with a relative path first in - * the application's sound directory (share/apps/Application Name/sounds), then in - * the KDE global sound directory (share/sounds). - * - * You can also use the "nopresentation" key, with any the presentations - * ORed. Those that are in that field will not appear in the kcontrol - * module. This was intended for software like KWin to not allow a window-opening - * that opens a window (e.g., allowing to disable KMessageBoxes from appearing) - * If the user edits the eventsrc file manually, it will appear. This only - * affects the KcmNotify. - * - * You can also use the following events, which are system controlled - * and do not need to be placed in your eventsrc: - * - *<ul> - * <li>cannotopenfile - * <li>notification - * <li>warning - * <li>fatalerror - * <li>catastrophe - *</ul> - * - * The events can be configured in an application using KNotifyDialog, which is part of KIO. - * - * @author Charles Samuels <charles@kde.org> - */ - - -namespace KNotifyClient -{ - struct InstancePrivate; - class InstanceStack; - - /** - * Makes it possible to use KNotifyClient with a KInstance - * that is not the application. - * - * Use like this: - * \code - * KNotifyClient::Instance(myInstance); - * KNotifyClient::event("MyEvent"); - * \endcode - * - * @short Enables KNotifyClient to use a different KInstance - */ - class KDECORE_EXPORT Instance - { - public: - /** - * Constructs a KNotifyClient::Instance to make KNotifyClient use - * the specified KInstance for the event configuration. - * @param instance the instance for the event configuration - */ - Instance(KInstance *instance); - /** - * Destructs the KNotifyClient::Instance and resets KNotifyClient - * to the previously used KInstance. - */ - ~Instance(); - /** - * Checks whether the system bell should be used. - * @returns true if this instance should use the System bell instead - * of KNotify. - */ - bool useSystemBell() const; - /** - * Returns the currently active KInstance. - * @return the active KInstance - */ - static KInstance *current(); - - /** - * Returns the current KNotifyClient::Instance (not the KInstance). - * @return the active Instance - */ - static Instance *currentInstance(); - - private: - static InstanceStack *instances(); - InstancePrivate *d; - static InstanceStack *s_instances; - }; - - - /** - * Describes the notification method. - */ - enum { - Default = -1, - None = 0, - Sound = 1, - Messagebox = 2, - Logfile = 4, - Stderr = 8, - PassivePopup = 16, ///< @since 3.1 - Execute = 32, ///< @since 3.1 - Taskbar = 64 ///< @since 3.2 - }; - - /** - * Describes the level of the error. - */ - enum { - Notification=1, - Warning=2, - Error=4, - Catastrophe=8 - }; - - /** - * default events you can use - */ - enum StandardEvent { - cannotOpenFile, - notification, - warning, - fatalError, - catastrophe - }; - - /** - * This starts the KNotify Daemon, if it's not already started. - * This will be useful for games that use sound effects. Run this - * at the start of the program, and there won't be a pause when it is - * first triggered. - * @return true if daemon is running (always true at the moment) - **/ - KDECORE_EXPORT bool startDaemon(); - -//#ifndef KDE_NO_COMPAT - /** - * @deprecated - * @param message The name of the event - * @param text The text to put in a dialog box. This won't be shown if - * the user connected the event to sound, only. Can be TQString::null. - * @return a value > 0, unique for this event if successful, 0 otherwise - */ - KDECORE_EXPORT int event(const TQString &message, const TQString &text=TQString::null) KDE_DEPRECATED; - - /** - * @deprecated - * Allows to easily emit standard events. - * @param event The event you want to raise. - * @param text The text explaining the event you raise. Can be TQString::null. - * @return a value > 0, unique for this event if successful, 0 otherwise - */ - KDECORE_EXPORT int event( StandardEvent event, const TQString& text=TQString::null ) KDE_DEPRECATED; - - /** - * @deprecated - * Will fire an event that's not registered. - * @param text The error message text, if applicable - * @param present The presentation method(s) of the event - * @param level The error message level, defaulting to "Default" - * @param sound The sound file to play if selected with @p present - * @param file The log file to append the message to if selected with @p present - * @return a value > 0, unique for this event if successful, 0 otherwise - */ - KDECORE_EXPORT int userEvent(const TQString &text=TQString::null, int present=Default, int level=Default, - const TQString &sound=TQString::null, const TQString &file=TQString::null) KDE_DEPRECATED; - -//#endif - - /** - * This should be the most used method in here. - * Pass the origin-widget's winId() here so that a PassivePopup can be - * placed appropriately. - * - * Call it by KNotifyClient::event(widget->winId(), "EventName"); - * It will use KApplication::kApplication->dcopClient() to communicate to - * the server - * @param winId The winId() of the widget where the event originates - * @param message The name of the event - * @param text The text to put in a dialog box. This won't be shown if - * the user connected the event to sound, only. Can be TQString::null. - * @return a value > 0, unique for this event if successful, 0 otherwise - * @since 3.1.1 - */ - // KDE4: use WId instead of int - KDECORE_EXPORT int event( int winId, const TQString& message, - const TQString& text = TQString::null ); - - /** - * You should - * pass the origin-widget's winId() here so that a PassivePopup can be - * placed appropriately. - * @param winId The winId() of the widget where the event originates - * @param event The event you want to raise - * @param text The text to put in a dialog box. This won't be shown if - * the user connected the event to sound, only. Can be TQString::null. - * @return a value > 0, unique for this event if successful, 0 otherwise - * @since 3.1.1 - */ - // KDE4: use WId instead of int - KDECORE_EXPORT int event( int winId, StandardEvent event, - const TQString& text = TQString::null ); - - /** - * Will fire an event that's not registered. - * You should - * pass the origin-widget's winId() here so that a PassivePopup can be - * placed appropriately. - * @param winId The winId() of the originating widget - * @param text The error message text, if applicable - * @param present The presentation method(s) of the event - * @param level The error message level, defaulting to "Default" - * @param sound The sound file to play if selected with @p present - * @param file The log file to append the message to if selected with @p present - * @return a value > 0, unique for this event if successful, 0 otherwise - * @since 3.1.1 - */ - // KDE4: use WId instead of int - KDECORE_EXPORT int userEvent(int winId, const TQString &text=TQString::null, int present=Default, int level=Default, - const TQString &sound=TQString::null, const TQString &file=TQString::null); - - /** - * This is a simple substitution for TQApplication::beep(). - * It simply calls - * \code - * KNotifyClient::event( KNotifyClient::notification, reason ); - * \endcode - * @param reason the reason, can be TQString::null. - */ - KDECORE_EXPORT void beep(const TQString& reason=TQString::null); - - /** - * Gets the presentation associated with a certain event name - * Remeber that they may be ORed: - * \code - * if (present & KNotifyClient::Sound) { [Yes, sound is a default] } - * \endcode - * @param eventname the event name to check - * @return the presentation methods - */ - KDECORE_EXPORT int getPresentation(const TQString &eventname); - - /** - * Gets the default file associated with a certain event name - * The control panel module will list all the event names - * This has the potential for being slow. - * @param eventname the name of the event - * @param present the presentation method - * @return the associated file. Can be TQString::null if not found. - */ - KDECORE_EXPORT TQString getFile(const TQString &eventname, int present); - - /** - * Gets the default presentation for the event of this program. - * Remember that the Presentation may be ORed. Try this: - * \code - * if (present & KNotifyClient::Sound) { [Yes, sound is a default] } - * \endcode - * @return the presentation methods - */ - KDECORE_EXPORT int getDefaultPresentation(const TQString &eventname); - - /** - * Gets the default File for the event of this program. - * It gets it in relation to present. - * Some events don't apply to this function ("Message Box") - * Some do (Sound) - * @param eventname the name of the event - * @param present the presentation method - * @return the default file. Can be TQString::null if not found. - */ - KDECORE_EXPORT TQString getDefaultFile(const TQString &eventname, int present); - - /** - * Shortcut to KNotifyClient::Instance::current() :) - * @returns the current KInstance. - */ - KDECORE_EXPORT KInstance * instance(); -} - -#endif diff --git a/kdecore/kpalette.cpp b/kdecore/kpalette.cpp deleted file mode 100644 index 9cc7b5635..000000000 --- a/kdecore/kpalette.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Waldo Bastian (bastian@kde.org) - - 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. - - 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. -*/ -//----------------------------------------------------------------------------- -// KDE color palette - -#include "kpalette.h" - -#include <tqfile.h> -#include <tqtextstream.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <ksavefile.h> -#include <kstringhandler.h> - -template class TQPtrList<KPalette::kolor>; - -TQStringList -KPalette::getPaletteList() -{ - TQStringList paletteList; - KGlobal::dirs()->findAllResources("config", "colors/*", false, true, paletteList); - - int strip = strlen("colors/"); - for(TQStringList::Iterator it = paletteList.begin(); - it != paletteList.end(); - it++) - { - (*it) = (*it).mid(strip); - } - - return paletteList; -} - -KPalette::KPalette(const TQString &name) - : mName(name) -{ - mKolorList.setAutoDelete(true); - if (mName.isEmpty()) return; - - TQString filename = locate("config", "colors/"+mName); - if (filename.isEmpty()) return; - - TQFile paletteFile(filename); - if (!paletteFile.exists()) return; - if (!paletteFile.open(IO_ReadOnly)) return; - - uint maxLength = 1024; - TQString line; - - // Read first line - // Expected "GIMP Palette" - if (paletteFile.readLine(line, maxLength) == -1) return; - if (line.find(" Palette") == -1) return; - - while( paletteFile.readLine(line, maxLength) != -1) - { - if (line[0] == '#') - { - // This is a comment line - line = line.mid(1); // Strip '#' - line = line.stripWhiteSpace(); // Strip remaining white space.. - if (!line.isEmpty()) - { - mDesc += line+"\n"; // Add comment to description - } - } - else - { - // This is a color line, hopefully - line = line.stripWhiteSpace(); - if (line.isEmpty()) continue; - int red, green, blue; - int pos = 0; - if (sscanf(line.ascii(), "%d %d %d%n", &red, &green, &blue, &pos) >= 3) - { - if (red > 255) red = 255; - if (red < 0) red = 0; - if (green > 255) green = 255; - if (green < 0) green = 0; - if (blue > 255) blue = 255; - if (blue < 0) blue = 0; - kolor *node = new kolor(); - node->color.setRgb(red, green, blue); - node->name = line.mid(pos).stripWhiteSpace(); - if (node->name.isNull()) node->name = ""; - mKolorList.append( node ); - } - } - } -} - -KPalette::KPalette(const KPalette &p) - : mName(p.mName), mDesc(p.mDesc), mEditable(p.mEditable) -{ - mKolorList.setAutoDelete(true); - // Make a deep copy of the color list - // We can't iterate a const list :( - // DF: yes you can - use the proper iterator, not first/next - TQPtrList<kolor> *nonConstList = (TQPtrList<kolor> *) &p.mKolorList; - for(kolor *node = nonConstList->first(); node; node = nonConstList->next()) - { - mKolorList.append(new kolor(*node)); - } -} - -KPalette::~KPalette() -{ - // Need auto-save? -} - -bool -KPalette::save() -{ - TQString filename = locateLocal("config", "colors/"+mName); - KSaveFile sf(filename); - if (sf.status() != 0) return false; - - TQTextStream *str = sf.textStream(); - - TQString description = mDesc.stripWhiteSpace(); - description = "#"+TQStringList::split("\n", description, true).join("\n#"); - - (*str) << "KDE RGB Palette\n"; - (*str) << description << "\n"; - // We can't iterate a const list :( - // DF: yes you can - use the proper iterator, not first/next - TQPtrList<kolor> *nonConstList = (TQPtrList<kolor> *) (&mKolorList); - for(kolor *node = nonConstList->first(); node; node = nonConstList->next()) - { - int r,g,b; - node->color.rgb(&r, &g, &b); - (*str) << r << " " << g << " " << b << " " << node->name << "\n"; - } - return sf.close(); -} - - -KPalette& -KPalette::operator=( const KPalette &p) -{ - if (&p == this) return *this; - mKolorList.clear(); - // Make a deep copy of the color list - // We can't iterate a const list :( - // DF: yes you can - use the proper iterator, not first/next - TQPtrList<kolor> *nonConstList = (TQPtrList<kolor> *) &p.mKolorList; - for(kolor *node = nonConstList->first(); node; node = nonConstList->next()) - { - mKolorList.append(new kolor(*node)); - } - mName = p.mName; - mDesc = p.mDesc; - mEditable = p.mEditable; - return *this; -} - -TQColor -KPalette::color(int index) -{ - if ((index < 0) || (index >= nrColors())) - return TQColor(); - - kolor *node = mKolorList.tqat(index); - if (!node) - return TQColor(); - - return node->color; -} - -int -KPalette::findColor(const TQColor &color) const -{ - int index; - TQPtrListIterator<kolor> it( mKolorList ); - for (index = 0; it.current(); ++it, ++index) - { - if (it.current()->color == color) - return index; - } - return -1; -} - -TQString -KPalette::colorName(int index) -{ - if ((index < 0) || (index >= nrColors())) - return TQString::null; - - kolor *node = mKolorList.tqat(index); - if (!node) - return TQString::null; - - return node->name; -} - -int -KPalette::addColor(const TQColor &newColor, const TQString &newColorName) -{ - kolor *node = new kolor(); - node->color = newColor; - node->name = newColorName; - mKolorList.append( node ); - return nrColors()-1; -} - -int -KPalette::changeColor(int index, - const TQColor &newColor, - const TQString &newColorName) -{ - if ((index < 0) || (index >= nrColors())) - return -1; - - kolor *node = mKolorList.tqat(index); - if (!node) - return -1; - - node->color = newColor; - node->name = newColorName; - return index; -} diff --git a/kdecore/kpalette.h b/kdecore/kpalette.h deleted file mode 100644 index 4f9c74029..000000000 --- a/kdecore/kpalette.h +++ /dev/null @@ -1,228 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Waldo Bastian (bastian@kde.org) - - 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; version - 2 of the License. - - 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. -*/ -//----------------------------------------------------------------------------- -// KDE color palette. - -#ifndef KDELIBS_KPALETTE_H -#define KDELIBS_KPALETTE_H - -#include <tqcolor.h> -#include <tqptrlist.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include "kdelibs_export.h" - -class KPalettePrivate; - -/** - * Class for handling Palettes. - * - * This class makes it easy to handle palettes. - * A palette is a set of colors. This class can read - * and write palettes from and to a file. - * - * This class uses the "GIMP" palette file format. - * - * This class is totally unrelated to TQPalette. - * - * @author Waldo Bastian (bastian@kde.org) - **/ -class KDECORE_EXPORT KPalette -{ -public: - /** - * Query which KDE palettes are installed. - * - * @return A list with a palette names. - */ - static TQStringList getPaletteList(); - - /** - * KPalette constructor. Creates a KPalette from a file - * the filename is derived from the name. - * @param name The name of palette as returned by getPaletteList() - **/ - KPalette(const TQString &name=TQString::null); - - /** - * KPalette copy constructor. - **/ - KPalette(const KPalette &); - - /** - * KPalette destructor. - **/ - virtual ~KPalette(); - - /** - * KPalette assignment operator - **/ - KPalette& operator=( const KPalette &); - - /** - * Save the palette - * - * @return 'true' if successful - **/ - bool save(); - - /** - * Get the description of the palette. - * @return the description of the palette. - **/ - TQString description() const - { return mDesc; } - - /** - * Set the description of the palette. - * @param desc the new description - **/ - void setDescription(const TQString &desc) - { mDesc = desc; } - - /** - * Get the name of the palette. - * @return the name of the palette - **/ - TQString name() const - { return mName; } - - /** - * Set the name of the palette. - * @param name the name of the palette - **/ - void setName(const TQString &name) - { mName = name; } - - /** - * Used to specify whether a palette may be edited. - * @see editable() - * @see setEditable() - */ - enum Editable { Yes, ///< Palette may be edited - No, ///< Palette may not be edited - Ask ///< Ask user before editing - }; - - /** - * Returns whether the palette may be edited. - * @return the state of the palette - **/ - Editable editable() const - { return mEditable; } - - /** - * Change whether the palette may be edited. - * @param editable the state of the palette - **/ - void setEditable(Editable editable) - { mEditable = editable; } - - /** - * Return the number of colors in the palette. - * @return the number of colors - **/ - int nrColors() const - { return (int) mKolorList.count(); } - - /** - * Find color by index. - * @param index the index of the desired color - * @return The @p index -th color of the palette, null if not found. - **/ - TQColor color(int index); - - /** - * Find index by @p color. - * @param color the color to find - * @return The index of the color in the palette or -1 if the - * color is not found. - **/ - int findColor(const TQColor &color) const; - - /** - * Find color name by @p index. - * @param index the index of the color - * @return The name of the @p index -th color. - * Note that not all palettes have named the colors. Null is - * returned if the color does not exist or has no name. - **/ - TQString colorName(int index); - - /** - * Find color name by @p color. - * @return The name of color according to this palette. - * Note that not all palettes have named the colors. - * Note also that each palette can give the same color - * a different name. - **/ - TQString colorName(const TQColor &color) - { return colorName( findColor(color)); } - - /** - * Add a color. - * @param newColor The color to add. - * @param newColorName The name of the color, null to remove - * the name. - * @return The index of the added color. - **/ - int addColor(const TQColor &newColor, - const TQString &newColorName = TQString::null); - - /** - * Change a color. - * @param index Index of the color to change - * @param newColor The new color. - * @param newColorName The new color name, null to remove - * the name. - * @return The index of the new color or -1 if the color couldn't - * be changed. - **/ - int changeColor(int index, - const TQColor &newColor, - const TQString &newColorName = TQString::null); - - /** - * Change a color. - * @param oldColor The original color - * @param newColor The new color. - * @param newColorName The new color name, null to remove - * the name. - * @return The index of the new color or -1 if the color couldn't - * be changed. - **/ - int changeColor(const TQColor &oldColor, - const TQColor &newColor, - const TQString &newColorName = TQString::null) - { return changeColor( findColor(oldColor), newColor, newColorName); } - -private: - typedef struct { TQColor color; TQString name; } kolor; - TQPtrList<kolor> mKolorList; - - TQString mName; - TQString mDesc; - Editable mEditable; - - KPalettePrivate *d; -}; - - -#endif // KDELIBS_KPALETTE_H - diff --git a/kdecore/kpixmapprovider.cpp b/kdecore/kpixmapprovider.cpp deleted file mode 100644 index 1745e68f6..000000000 --- a/kdecore/kpixmapprovider.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) 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. -*/ - -#include "kpixmapprovider.h" - -KPixmapProvider::~KPixmapProvider() {} - -void KPixmapProvider::virtual_hook( int , void* ) -{ /*BASE::virtual_hook( id, data );*/ } - diff --git a/kdecore/kpixmapprovider.h b/kdecore/kpixmapprovider.h deleted file mode 100644 index 8b3c653af..000000000 --- a/kdecore/kpixmapprovider.h +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) 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 KPIXMAPPROVIDER_H -#define KPIXMAPPROVIDER_H - -#include <tqpixmap.h> -#include "kdelibs_export.h" - -/** - * A tiny abstract class with just one method: - * pixmapFor() - * - * It will be called whenever an icon is searched for @p text. - * - * Used e.g. by KHistoryCombo - * - * @author Carsten Pfeiffer <pfeiffer@kde.org> - * @short an abstract interface for looking up icons - */ -class KDECORE_EXPORT KPixmapProvider -{ -public: - virtual ~KPixmapProvider(); - /** - * You may subclass this and return a pixmap of size @p size for @p text. - * @param text the text that is associated with the pixmap - * @param size the size of the icon in pixels, 0 for defaylt size. - * See KIcon::StdSize. - * @return the pixmap for the arguments, or null if there is none - */ - virtual TQPixmap pixmapFor( const TQString& text, int size = 0 ) = 0; -protected: - virtual void virtual_hook( int id, void* data ); -}; - - -#endif // KPIXMAPPROVIDER_H diff --git a/kdecore/kprocctrl.cpp b/kdecore/kprocctrl.cpp deleted file mode 100644 index 6774eee5f..000000000 --- a/kdecore/kprocctrl.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) - - 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. -*/ - -#include "kprocess.h" -#include "kprocctrl.h" - -#include <config.h> - -#include <sys/time.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> - -#include <tqsocketnotifier.h> - -KProcessController *KProcessController::theKProcessController; -int KProcessController::refCount; - -void KProcessController::ref() -{ - if( !refCount ) { - theKProcessController = new KProcessController; - setupHandlers(); - } - refCount++; -} - -void KProcessController::deref() -{ - refCount--; - if( !refCount ) { - resetHandlers(); - delete theKProcessController; - theKProcessController = 0; - } -} - -KProcessController::KProcessController() - : needcheck( false ) -{ - if( pipe( fd ) ) - { - perror( "pipe" ); - abort(); - } - - fcntl( fd[0], F_SETFL, O_NONBLOCK ); // in case slotDoHousekeeping is called without polling first - fcntl( fd[1], F_SETFL, O_NONBLOCK ); // in case it fills up - fcntl( fd[0], F_SETFD, FD_CLOEXEC ); - fcntl( fd[1], F_SETFD, FD_CLOEXEC ); - - notifier = new TQSocketNotifier( fd[0], TQSocketNotifier::Read ); - notifier->setEnabled( true ); - TQObject::connect( notifier, TQT_SIGNAL(activated(int)), - TQT_SLOT(slotDoHousekeeping())); -} - -KProcessController::~KProcessController() -{ - delete notifier; - - close( fd[0] ); - close( fd[1] ); -} - - -extern "C" { -static void theReaper( int num ) -{ - KProcessController::theSigCHLDHandler( num ); -} -} - -#ifdef Q_OS_UNIX -struct sigaction KProcessController::oldChildHandlerData; -#endif -bool KProcessController::handlerSet = false; - -void KProcessController::setupHandlers() -{ - if( handlerSet ) - return; - handlerSet = true; - -#ifdef Q_OS_UNIX - struct sigaction act; - sigemptyset( &act.sa_mask ); - - act.sa_handler = SIG_IGN; - act.sa_flags = 0; - sigaction( SIGPIPE, &act, 0L ); - - act.sa_handler = theReaper; - act.sa_flags = SA_NOCLDSTOP; - // CC: take care of SunOS which automatically restarts interrupted system - // calls (and thus does not have SA_RESTART) -#ifdef SA_RESTART - act.sa_flags |= SA_RESTART; -#endif - sigaction( SIGCHLD, &act, &oldChildHandlerData ); - - sigaddset( &act.sa_mask, SIGCHLD ); - // Make sure we don't block this signal. gdb tends to do that :-( - sigprocmask( SIG_UNBLOCK, &act.sa_mask, 0 ); -#else - //TODO: win32 -#endif -} - -void KProcessController::resetHandlers() -{ - if( !handlerSet ) - return; - handlerSet = false; - -#ifdef Q_OS_UNIX - sigaction( SIGCHLD, &oldChildHandlerData, 0 ); -#else - //TODO: win32 -#endif - // there should be no problem with SIGPIPE staying SIG_IGN -} - -// the pipe is needed to sync the child reaping with our event processing, -// as otherwise there are race conditions, locking requirements, and things -// generally get harder -void KProcessController::theSigCHLDHandler( int arg ) -{ - int saved_errno = errno; - - char dummy = 0; - ::write( theKProcessController->fd[1], &dummy, 1 ); - -#ifdef Q_OS_UNIX - if( oldChildHandlerData.sa_handler != SIG_IGN && - oldChildHandlerData.sa_handler != SIG_DFL ) - oldChildHandlerData.sa_handler( arg ); // call the old handler -#else - //TODO: win32 -#endif - - errno = saved_errno; -} - -int KProcessController::notifierFd() const -{ - return fd[0]; -} - -void KProcessController::unscheduleCheck() -{ - char dummy[16]; // somewhat bigger - just in case several have queued up - if( ::read( fd[0], dummy, sizeof(dummy) ) > 0 ) - needcheck = true; -} - -void -KProcessController::rescheduleCheck() -{ - if( needcheck ) - { - needcheck = false; - char dummy = 0; - ::write( fd[1], &dummy, 1 ); - } -} - -void KProcessController::slotDoHousekeeping() -{ - char dummy[16]; // somewhat bigger - just in case several have queued up - ::read( fd[0], dummy, sizeof(dummy) ); - - int status; - again: - TQValueListIterator<KProcess*> it( kProcessList.begin() ); - TQValueListIterator<KProcess*> eit( kProcessList.end() ); - while( it != eit ) - { - KProcess *prc = *it; - if( prc->runs && waitpid( prc->pid_, &status, WNOHANG ) > 0 ) - { - prc->processHasExited( status ); - // the callback can nuke the whole process list and even 'this' - if (!theKProcessController) - return; - goto again; - } - ++it; - } - TQValueListIterator<int> uit( unixProcessList.begin() ); - TQValueListIterator<int> ueit( unixProcessList.end() ); - while( uit != ueit ) - { - if( waitpid( *uit, 0, WNOHANG ) > 0 ) - { - uit = unixProcessList.remove( uit ); - deref(); // counterpart to addProcess, can tqinvalidate 'this' - } else - ++uit; - } -} - -bool KProcessController::waitForProcessExit( int timeout ) -{ -#ifdef Q_OS_UNIX - for(;;) - { - struct timeval tv, *tvp; - if (timeout < 0) - tvp = 0; - else - { - tv.tv_sec = timeout; - tv.tv_usec = 0; - tvp = &tv; - } - - fd_set fds; - FD_ZERO( &fds ); - FD_SET( fd[0], &fds ); - - switch( select( fd[0]+1, &fds, 0, 0, tvp ) ) - { - case -1: - if( errno == EINTR ) - continue; - // fall through; should never happen - case 0: - return false; - default: - slotDoHousekeeping(); - return true; - } - } -#else - //TODO: win32 - return false; -#endif -} - -void KProcessController::addKProcess( KProcess* p ) -{ - kProcessList.append( p ); -} - -void KProcessController::removeKProcess( KProcess* p ) -{ - kProcessList.remove( p ); -} - -void KProcessController::addProcess( int pid ) -{ - unixProcessList.append( pid ); - ref(); // make sure we stay around when the KProcess goes away -} - -#include "kprocctrl.moc" diff --git a/kdecore/kprocctrl.h b/kdecore/kprocctrl.h deleted file mode 100644 index 0e534f4ad..000000000 --- a/kdecore/kprocctrl.h +++ /dev/null @@ -1,150 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) - - 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 __KPROCCTRL_H__ -#define __KPROCCTRL_H__ - -#include <tqvaluelist.h> - -#include "kprocess.h" - -class TQSocketNotifier; - -/** - * @short Used internally by KProcess - * @internal - * @author Christian Czezatke <e9025461@student.tuwien.ac.at> - * - * A class for internal use by KProcess only. -- Exactly one instance - * of this class is created by KApplication. - * - * This class takes care of the actual (UN*X) signal handling. - */ -class KDECORE_EXPORT KProcessController : public TQObject -{ - Q_OBJECT - -public: - /** - * Create an instance if none exists yet. - * Called by KApplication::KApplication() - */ - static void ref(); - - /** - * Destroy the instance if one exists and it is not referenced any more. - * Called by KApplication::~KApplication() - */ - static void deref(); - - /** - * Only a single instance of this class is allowed at a time, - * and this static variable is used to track the one instance. - */ - static KProcessController *theKProcessController; // kde4: rename: instance - - /** - * Automatically called upon SIGCHLD. Never call it directly. - * If your application (or some library it uses) redirects SIGCHLD, - * the new signal handler (and only it) should call the old handler - * returned by sigaction(). - * @internal - */ - static void theSigCHLDHandler(int signal); // KDE4: private - - /** - * Wait for any process to exit and handle their exit without - * starting an event loop. - * This function may cause KProcess to emit any of its signals. - * - * @param timeout the timeout in seconds. -1 means no timeout. - * @return true if a process exited, false - * if no process exited within @p timeout seconds. - * @since 3.1 - */ - bool waitForProcessExit(int timeout); - - /** - * Call this function to defer processing of the data that became available - * on notifierFd(). - * @since 3.2 - */ - void unscheduleCheck(); - - /** - * This function @em must be called at some point after calling - * unscheduleCheck(). - * @since 3.2 - */ - void rescheduleCheck(); - - /* - * Obtain the file descriptor KProcessController uses to get notified - * about process exits. select() or poll() on it if you create a custom - * event loop that needs to act upon SIGCHLD. - * @return the file descriptor of the reading end of the notification pipe - * @since 3.2 - */ - int notifierFd() const; - - /** - * @internal - */ - void addKProcess( KProcess* ); - /** - * @internal - */ - void removeKProcess( KProcess* ); - /** - * @internal - */ - void addProcess( int pid ); - -private slots: - void slotDoHousekeeping(); - -private: - friend class I_just_love_gcc; - - int fd[2]; - bool needcheck; - TQSocketNotifier *notifier; - TQValueList<KProcess*> kProcessList; - TQValueList<int> unixProcessList; - - static void setupHandlers(); - static void resetHandlers(); - static struct sigaction oldChildHandlerData; - static bool handlerSet; - - static int refCount; - - // Disallow instantiation - KProcessController(); - ~KProcessController(); - - // Disallow assignment and copy-construction - KProcessController( const KProcessController& ); - KProcessController& operator= ( const KProcessController& ); -}; - - - -#endif - diff --git a/kdecore/kprocess.cpp b/kdecore/kprocess.cpp deleted file mode 100644 index f13813d15..000000000 --- a/kdecore/kprocess.cpp +++ /dev/null @@ -1,1137 +0,0 @@ -/* - - $Id$ - - This file is part of the KDE libraries - Copyright (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) - - 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. -*/ - - -#include "kprocess.h" -#include "kprocctrl.h" -#include "kpty.h" - -#include <config.h> - -#ifdef __sgi -#define __svr4__ -#endif - -#ifdef __osf__ -#define _OSF_SOURCE -#include <float.h> -#endif - -#ifdef _AIX -#define _ALL_SOURCE -#endif - -#ifdef Q_OS_UNIX -#include <sys/socket.h> -#include <sys/ioctl.h> -#endif - -#include <sys/types.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/stat.h> -#include <sys/wait.h> - -#ifdef HAVE_SYS_STROPTS_H -#include <sys/stropts.h> // Defines I_PUSH -#define _NEW_TTY_CTRL -#endif -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif - -#include <errno.h> -#include <assert.h> -#include <fcntl.h> -#include <time.h> -#include <stdlib.h> -#include <signal.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <pwd.h> -#include <grp.h> - -#include <tqfile.h> -#include <tqsocketnotifier.h> -#include <tqapplication.h> - -#include <kdebug.h> -#include <kstandarddirs.h> -#include <kuser.h> - - -////////////////// -// private data // -////////////////// - -class KProcessPrivate { -public: - KProcessPrivate() : - usePty(KProcess::NoCommunication), - addUtmp(false), useShell(false), -#ifdef Q_OS_UNIX - pty(0), -#endif - priority(0) - { - } - - KProcess::Communication usePty; - bool addUtmp : 1; - bool useShell : 1; - -#ifdef Q_OS_UNIX - KPty *pty; -#endif - - int priority; - - TQMap<TQString,TQString> env; - TQString wd; - TQCString shell; - TQCString executable; -}; - -///////////////////////////// -// public member functions // -///////////////////////////// - -KProcess::KProcess( TQObject* parent, const char *name ) - : TQObject( parent, name ), - run_mode(NotifyOnExit), - runs(false), - pid_(0), - status(0), - keepPrivs(false), - innot(0), - outnot(0), - errnot(0), - communication(NoCommunication), - input_data(0), - input_sent(0), - input_total(0) -{ - KProcessController::ref(); - KProcessController::theKProcessController->addKProcess(this); - - d = new KProcessPrivate; - - out[0] = out[1] = -1; - in[0] = in[1] = -1; - err[0] = err[1] = -1; -} - -KProcess::KProcess() - : TQObject(), - run_mode(NotifyOnExit), - runs(false), - pid_(0), - status(0), - keepPrivs(false), - innot(0), - outnot(0), - errnot(0), - communication(NoCommunication), - input_data(0), - input_sent(0), - input_total(0) -{ - KProcessController::ref(); - KProcessController::theKProcessController->addKProcess(this); - - d = new KProcessPrivate; - - out[0] = out[1] = -1; - in[0] = in[1] = -1; - err[0] = err[1] = -1; -} - -void -KProcess::setEnvironment(const TQString &name, const TQString &value) -{ - d->env.insert(name, value); -} - -void -KProcess::setWorkingDirectory(const TQString &dir) -{ - d->wd = dir; -} - -void -KProcess::setupEnvironment() -{ - TQMap<TQString,TQString>::Iterator it; - for(it = d->env.begin(); it != d->env.end(); ++it) - { - setenv(TQFile::encodeName(it.key()).data(), - TQFile::encodeName(it.data()).data(), 1); - } - if (!d->wd.isEmpty()) - { - chdir(TQFile::encodeName(d->wd).data()); - } -} - -void -KProcess::setRunPrivileged(bool keepPrivileges) -{ - keepPrivs = keepPrivileges; -} - -bool -KProcess::runPrivileged() const -{ - return keepPrivs; -} - -bool -KProcess::setPriority(int prio) -{ -#ifdef Q_OS_UNIX - if (runs) { - if (setpriority(PRIO_PROCESS, pid_, prio)) - return false; - } else { - if (prio > 19 || prio < (geteuid() ? getpriority(PRIO_PROCESS, 0) : -20)) - return false; - } -#endif - d->priority = prio; - return true; -} - -KProcess::~KProcess() -{ - if (run_mode != DontCare) - kill(SIGKILL); - detach(); - -#ifdef Q_OS_UNIX - delete d->pty; -#endif - delete d; - - KProcessController::theKProcessController->removeKProcess(this); - KProcessController::deref(); -} - -void KProcess::detach() -{ - if (runs) { - KProcessController::theKProcessController->addProcess(pid_); - runs = false; - pid_ = 0; // close without draining - commClose(); // Clean up open fd's and socket notifiers. - } -} - -void KProcess::setBinaryExecutable(const char *filename) -{ - d->executable = filename; -} - -bool KProcess::setExecutable(const TQString& proc) -{ - if (runs) return false; - - if (proc.isEmpty()) return false; - - if (!arguments.isEmpty()) - arguments.remove(arguments.begin()); - arguments.prepend(TQFile::encodeName(proc)); - - return true; -} - -KProcess &KProcess::operator<<(const TQStringList& args) -{ - TQStringList::ConstIterator it = args.begin(); - for ( ; it != args.end() ; ++it ) - arguments.append(TQFile::encodeName(*it)); - return *this; -} - -KProcess &KProcess::operator<<(const TQCString& arg) -{ - return operator<< (arg.data()); -} - -KProcess &KProcess::operator<<(const char* arg) -{ - arguments.append(arg); - return *this; -} - -KProcess &KProcess::operator<<(const TQString& arg) -{ - arguments.append(TQFile::encodeName(arg)); - return *this; -} - -void KProcess::clearArguments() -{ - arguments.clear(); -} - -bool KProcess::start(RunMode runmode, Communication comm) -{ - if (runs) { - kdDebug(175) << "Attempted to start an already running process" << endl; - return false; - } - - uint n = arguments.count(); - if (n == 0) { - kdDebug(175) << "Attempted to start a process without arguments" << endl; - return false; - } -#ifdef Q_OS_UNIX - char **arglist; - TQCString shellCmd; - if (d->useShell) - { - if (d->shell.isEmpty()) { - kdDebug(175) << "Invalid shell specified" << endl; - return false; - } - - for (uint i = 0; i < n; i++) { - shellCmd += arguments[i]; - shellCmd += " "; // CC: to separate the arguments - } - - arglist = static_cast<char **>(malloc( 4 * sizeof(char *))); - arglist[0] = d->shell.data(); - arglist[1] = (char *) "-c"; - arglist[2] = shellCmd.data(); - arglist[3] = 0; - } - else - { - arglist = static_cast<char **>(malloc( (n + 1) * sizeof(char *))); - for (uint i = 0; i < n; i++) - arglist[i] = arguments[i].data(); - arglist[n] = 0; - } - - run_mode = runmode; - - if (!setupCommunication(comm)) - { - kdDebug(175) << "Could not setup Communication!" << endl; - free(arglist); - return false; - } - - // We do this in the parent because if we do it in the child process - // gdb gets confused when the application runs from gdb. -#ifdef HAVE_INITGROUPS - struct passwd *pw = geteuid() ? 0 : getpwuid(getuid()); -#endif - - int fd[2]; - if (pipe(fd)) - fd[0] = fd[1] = -1; // Pipe failed.. continue - - // we don't use vfork() because - // - it has unclear semantics and is not standardized - // - we do way too much magic in the child - pid_ = fork(); - if (pid_ == 0) { - // The child process - - close(fd[0]); - // Closing of fd[1] indicates that the execvp() succeeded! - fcntl(fd[1], F_SETFD, FD_CLOEXEC); - - if (!commSetupDoneC()) - kdDebug(175) << "Could not finish comm setup in child!" << endl; - - // reset all signal handlers - struct sigaction act; - sigemptyset(&act.sa_mask); - act.sa_handler = SIG_DFL; - act.sa_flags = 0; - for (int sig = 1; sig < NSIG; sig++) - sigaction(sig, &act, 0L); - - if (d->priority) - setpriority(PRIO_PROCESS, 0, d->priority); - - if (!runPrivileged()) - { - setgid(getgid()); -#ifdef HAVE_INITGROUPS - if (pw) - initgroups(pw->pw_name, pw->pw_gid); -#endif - if (geteuid() != getuid()) - setuid(getuid()); - if (geteuid() != getuid()) - _exit(1); - } - - setupEnvironment(); - - if (runmode == DontCare || runmode == OwnGroup) - setsid(); - - const char *executable = arglist[0]; - if (!d->executable.isEmpty()) - executable = d->executable.data(); - execvp(executable, arglist); - - char resultByte = 1; - write(fd[1], &resultByte, 1); - _exit(-1); - } else if (pid_ == -1) { - // forking failed - - // commAbort(); - pid_ = 0; - free(arglist); - return false; - } - // the parent continues here - free(arglist); - - if (!commSetupDoneP()) - kdDebug(175) << "Could not finish comm setup in parent!" << endl; - - // Check whether client could be started. - close(fd[1]); - for(;;) - { - char resultByte; - int n = ::read(fd[0], &resultByte, 1); - if (n == 1) - { - // exec() failed - close(fd[0]); - waitpid(pid_, 0, 0); - pid_ = 0; - commClose(); - return false; - } - if (n == -1) - { - if (errno == EINTR) - continue; // Ignore - } - break; // success - } - close(fd[0]); - - runs = true; - switch (runmode) - { - case Block: - for (;;) - { - commClose(); // drain only, unless obsolete reimplementation - if (!runs) - { - // commClose detected data on the process exit notifification pipe - KProcessController::theKProcessController->unscheduleCheck(); - if (waitpid(pid_, &status, WNOHANG) != 0) // error finishes, too - { - commClose(); // this time for real (runs is false) - KProcessController::theKProcessController->rescheduleCheck(); - break; - } - runs = true; // for next commClose() iteration - } - else - { - // commClose is an obsolete reimplementation and waited until - // all output channels were closed (or it was interrupted). - // there is a chance that it never gets here ... - waitpid(pid_, &status, 0); - runs = false; - break; - } - } - // why do we do this? i think this signal should be emitted _only_ - // after the process has successfully run _asynchronously_ --ossi - emit processExited(this); - break; - default: // NotifyOnExit & OwnGroup - input_data = 0; // Discard any data for stdin that might still be there - break; - } - return true; -#else - //TODO - return false; -#endif -} - - - -bool KProcess::kill(int signo) -{ -#ifdef Q_OS_UNIX - if (runs && pid_ > 0 && !::kill(run_mode == OwnGroup ? -pid_ : pid_, signo)) - return true; -#endif - return false; -} - - - -bool KProcess::isRunning() const -{ - return runs; -} - - - -pid_t KProcess::pid() const -{ - return pid_; -} - -#ifndef timersub -# define timersub(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ - } while (0) -#endif - -bool KProcess::wait(int timeout) -{ - if (!runs) - return true; - -#ifndef __linux__ - struct timeval etv; -#endif - struct timeval tv, *tvp; - if (timeout < 0) - tvp = 0; - else - { -#ifndef __linux__ - gettimeofday(&etv, 0); - etv.tv_sec += timeout; -#else - tv.tv_sec = timeout; - tv.tv_usec = 0; -#endif - tvp = &tv; - } - -#ifdef Q_OS_UNIX - int fd = KProcessController::theKProcessController->notifierFd(); - for(;;) - { - fd_set fds; - FD_ZERO( &fds ); - FD_SET( fd, &fds ); - -#ifndef __linux__ - if (tvp) - { - gettimeofday(&tv, 0); - timersub(&etv, &tv, &tv); - if (tv.tv_sec < 0) - tv.tv_sec = tv.tv_usec = 0; - } -#endif - - switch( select( fd+1, &fds, 0, 0, tvp ) ) - { - case -1: - if( errno == EINTR ) - break; - // fall through; should happen if tvp->tv_sec < 0 - case 0: - KProcessController::theKProcessController->rescheduleCheck(); - return false; - default: - KProcessController::theKProcessController->unscheduleCheck(); - if (waitpid(pid_, &status, WNOHANG) != 0) // error finishes, too - { - processHasExited(status); - KProcessController::theKProcessController->rescheduleCheck(); - return true; - } - } - } -#endif //Q_OS_UNIX - return false; -} - - - -bool KProcess::normalExit() const -{ - return (pid_ != 0) && !runs && WIFEXITED(status); -} - - -bool KProcess::signalled() const -{ - return (pid_ != 0) && !runs && WIFSIGNALED(status); -} - - -bool KProcess::coreDumped() const -{ -#ifdef WCOREDUMP - return signalled() && WCOREDUMP(status); -#else - return false; -#endif -} - - -int KProcess::exitStatus() const -{ - return WEXITSTATUS(status); -} - - -int KProcess::exitSignal() const -{ - return WTERMSIG(status); -} - - -bool KProcess::writeStdin(const char *buffer, int buflen) -{ - // if there is still data pending, writing new data - // to stdout is not allowed (since it could also confuse - // kprocess ...) - if (input_data != 0) - return false; - - if (communication & Stdin) { - input_data = buffer; - input_sent = 0; - input_total = buflen; - innot->setEnabled(true); - if (input_total) - slotSendData(0); - return true; - } else - return false; -} - -void KProcess::suspend() -{ - if (outnot) - outnot->setEnabled(false); -} - -void KProcess::resume() -{ - if (outnot) - outnot->setEnabled(true); -} - -bool KProcess::closeStdin() -{ - if (communication & Stdin) { - communication = (Communication) (communication & ~Stdin); - delete innot; - innot = 0; - if (!(d->usePty & Stdin)) - close(in[1]); - in[1] = -1; - return true; - } else - return false; -} - -bool KProcess::closeStdout() -{ - if (communication & Stdout) { - communication = (Communication) (communication & ~Stdout); - delete outnot; - outnot = 0; - if (!(d->usePty & Stdout)) - close(out[0]); - out[0] = -1; - return true; - } else - return false; -} - -bool KProcess::closeStderr() -{ - if (communication & Stderr) { - communication = (Communication) (communication & ~Stderr); - delete errnot; - errnot = 0; - if (!(d->usePty & Stderr)) - close(err[0]); - err[0] = -1; - return true; - } else - return false; -} - -bool KProcess::closePty() -{ -#ifdef Q_OS_UNIX - if (d->pty && d->pty->masterFd() >= 0) { - if (d->addUtmp) - d->pty->logout(); - d->pty->close(); - return true; - } else - return false; -#else - return false; -#endif -} - -void KProcess::closeAll() -{ - closeStdin(); - closeStdout(); - closeStderr(); - closePty(); -} - -///////////////////////////// -// protected slots // -///////////////////////////// - - - -void KProcess::slotChildOutput(int fdno) -{ - if (!childOutput(fdno)) - closeStdout(); -} - - -void KProcess::slotChildError(int fdno) -{ - if (!childError(fdno)) - closeStderr(); -} - - -void KProcess::slotSendData(int) -{ - if (input_sent == input_total) { - innot->setEnabled(false); - input_data = 0; - emit wroteStdin(this); - } else { - int result = ::write(in[1], input_data+input_sent, input_total-input_sent); - if (result >= 0) - { - input_sent += result; - } - else if ((errno != EAGAIN) && (errno != EINTR)) - { - kdDebug(175) << "Error writing to stdin of child process" << endl; - closeStdin(); - } - } -} - -void KProcess::setUseShell(bool useShell, const char *shell) -{ - d->useShell = useShell; - if (shell && *shell) - d->shell = shell; - else -// #ifdef NON_FREE // ... as they ship non-POSIX /bin/sh -#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__GNU__) && !defined(__DragonFly__) - // Solaris POSIX ... - if (!access( "/usr/xpg4/bin/sh", X_OK )) - d->shell = "/usr/xpg4/bin/sh"; - else - // ... which links here anyway - if (!access( "/bin/ksh", X_OK )) - d->shell = "/bin/ksh"; - else - // dunno, maybe superfluous? - if (!access( "/usr/ucb/sh", X_OK )) - d->shell = "/usr/ucb/sh"; - else -#endif - d->shell = "/bin/sh"; -} - -#ifdef Q_OS_UNIX -void KProcess::setUsePty(Communication usePty, bool addUtmp) -{ - d->usePty = usePty; - d->addUtmp = addUtmp; - if (usePty) { - if (!d->pty) - d->pty = new KPty; - } else { - delete d->pty; - d->pty = 0; - } -} - -KPty *KProcess::pty() const -{ - return d->pty; -} -#endif //Q_OS_UNIX - -TQString KProcess::quote(const TQString &arg) -{ - TQChar q('\''); - return TQString(arg).replace(q, "'\\''").prepend(q).append(q); -} - - -////////////////////////////// -// private member functions // -////////////////////////////// - - -void KProcess::processHasExited(int state) -{ - // only successfully run NotifyOnExit processes ever get here - - status = state; - runs = false; // do this before commClose, so it knows we're dead - - commClose(); // cleanup communication sockets - - if (run_mode != DontCare) - emit processExited(this); -} - - - -int KProcess::childOutput(int fdno) -{ - if (communication & NoRead) { - int len = -1; - emit receivedStdout(fdno, len); - errno = 0; // Make sure errno doesn't read "EAGAIN" - return len; - } - else - { - char buffer[1025]; - int len; - - len = ::read(fdno, buffer, 1024); - - if (len > 0) { - buffer[len] = 0; // Just in case. - emit receivedStdout(this, buffer, len); - } - return len; - } -} - -int KProcess::childError(int fdno) -{ - char buffer[1025]; - int len; - - len = ::read(fdno, buffer, 1024); - - if (len > 0) { - buffer[len] = 0; // Just in case. - emit receivedStderr(this, buffer, len); - } - return len; -} - - -int KProcess::setupCommunication(Communication comm) -{ -#ifdef Q_OS_UNIX - // PTY stuff // - if (d->usePty) - { - // cannot communicate on both stderr and stdout if they are both on the pty - if (!(~(comm & d->usePty) & (Stdout | Stderr))) { - kdWarning(175) << "Invalid usePty/communication combination (" << d->usePty << "/" << comm << ")" << endl; - return 0; - } - if (!d->pty->open()) - return 0; - - int rcomm = comm & d->usePty; - int mfd = d->pty->masterFd(); - if (rcomm & Stdin) - in[1] = mfd; - if (rcomm & Stdout) - out[0] = mfd; - if (rcomm & Stderr) - err[0] = mfd; - } - - communication = comm; - - comm = (Communication) (comm & ~d->usePty); - if (comm & Stdin) { - if (socketpair(AF_UNIX, SOCK_STREAM, 0, in)) - goto fail0; - fcntl(in[0], F_SETFD, FD_CLOEXEC); - fcntl(in[1], F_SETFD, FD_CLOEXEC); - } - if (comm & Stdout) { - if (socketpair(AF_UNIX, SOCK_STREAM, 0, out)) - goto fail1; - fcntl(out[0], F_SETFD, FD_CLOEXEC); - fcntl(out[1], F_SETFD, FD_CLOEXEC); - } - if (comm & Stderr) { - if (socketpair(AF_UNIX, SOCK_STREAM, 0, err)) - goto fail2; - fcntl(err[0], F_SETFD, FD_CLOEXEC); - fcntl(err[1], F_SETFD, FD_CLOEXEC); - } - return 1; // Ok - fail2: - if (comm & Stdout) - { - close(out[0]); - close(out[1]); - out[0] = out[1] = -1; - } - fail1: - if (comm & Stdin) - { - close(in[0]); - close(in[1]); - in[0] = in[1] = -1; - } - fail0: - communication = NoCommunication; -#endif //Q_OS_UNIX - return 0; // Error -} - - - -int KProcess::commSetupDoneP() -{ - int rcomm = communication & ~d->usePty; - if (rcomm & Stdin) - close(in[0]); - if (rcomm & Stdout) - close(out[1]); - if (rcomm & Stderr) - close(err[1]); - in[0] = out[1] = err[1] = -1; - - // Don't create socket notifiers if no interactive comm is to be expected - if (run_mode != NotifyOnExit && run_mode != OwnGroup) - return 1; - - if (communication & Stdin) { - fcntl(in[1], F_SETFL, O_NONBLOCK | fcntl(in[1], F_GETFL)); - innot = new TQSocketNotifier(in[1], TQSocketNotifier::Write, this); - Q_CHECK_PTR(innot); - innot->setEnabled(false); // will be enabled when data has to be sent - TQObject::connect(innot, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(slotSendData(int))); - } - - if (communication & Stdout) { - outnot = new TQSocketNotifier(out[0], TQSocketNotifier::Read, this); - Q_CHECK_PTR(outnot); - TQObject::connect(outnot, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(slotChildOutput(int))); - if (communication & NoRead) - suspend(); - } - - if (communication & Stderr) { - errnot = new TQSocketNotifier(err[0], TQSocketNotifier::Read, this ); - Q_CHECK_PTR(errnot); - TQObject::connect(errnot, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(slotChildError(int))); - } - - return 1; -} - - - -int KProcess::commSetupDoneC() -{ - int ok = 1; -#ifdef Q_OS_UNIX - - if (d->usePty & Stdin) { - if (dup2(d->pty->slaveFd(), STDIN_FILENO) < 0) ok = 0; - } else if (communication & Stdin) { - if (dup2(in[0], STDIN_FILENO) < 0) ok = 0; - } else { - int null_fd = open( "/dev/null", O_RDONLY ); - if (dup2( null_fd, STDIN_FILENO ) < 0) ok = 0; - close( null_fd ); - } - struct linger so; - memset(&so, 0, sizeof(so)); - if (d->usePty & Stdout) { - if (dup2(d->pty->slaveFd(), STDOUT_FILENO) < 0) ok = 0; - } else if (communication & Stdout) { - if (dup2(out[1], STDOUT_FILENO) < 0 || - setsockopt(out[1], SOL_SOCKET, SO_LINGER, (char *)&so, sizeof(so))) - ok = 0; - if (communication & MergedStderr) { - if (dup2(out[1], STDERR_FILENO) < 0) - ok = 0; - } - } - if (d->usePty & Stderr) { - if (dup2(d->pty->slaveFd(), STDERR_FILENO) < 0) ok = 0; - } else if (communication & Stderr) { - if (dup2(err[1], STDERR_FILENO) < 0 || - setsockopt(err[1], SOL_SOCKET, SO_LINGER, (char *)&so, sizeof(so))) - ok = 0; - } - - // don't even think about closing all open fds here or anywhere else - - // PTY stuff // - if (d->usePty) { - d->pty->setCTty(); - if (d->addUtmp) - d->pty->login(KUser(KUser::UseRealUserID).loginName().local8Bit().data(), getenv("DISPLAY")); - } -#endif //Q_OS_UNIX - - return ok; -} - - - -void KProcess::commClose() -{ - closeStdin(); - -#ifdef Q_OS_UNIX - if (pid_) { // detached, failed, and killed processes have no output. basta. :) - // If both channels are being read we need to make sure that one socket - // buffer doesn't fill up whilst we are waiting for data on the other - // (causing a deadlock). Hence we need to use select. - - int notfd = KProcessController::theKProcessController->notifierFd(); - - while ((communication & (Stdout | Stderr)) || runs) { - fd_set rfds; - FD_ZERO(&rfds); - struct timeval timeout, *p_timeout; - - int max_fd = 0; - if (communication & Stdout) { - FD_SET(out[0], &rfds); - max_fd = out[0]; - } - if (communication & Stderr) { - FD_SET(err[0], &rfds); - if (err[0] > max_fd) - max_fd = err[0]; - } - if (runs) { - FD_SET(notfd, &rfds); - if (notfd > max_fd) - max_fd = notfd; - // If the process is still running we block until we - // receive data or the process exits. - p_timeout = 0; // no timeout - } else { - // If the process has already exited, we only check - // the available data, we don't wait for more. - timeout.tv_sec = timeout.tv_usec = 0; // timeout immediately - p_timeout = &timeout; - } - - int fds_ready = select(max_fd+1, &rfds, 0, 0, p_timeout); - if (fds_ready < 0) { - if (errno == EINTR) - continue; - break; - } else if (!fds_ready) - break; - - if ((communication & Stdout) && FD_ISSET(out[0], &rfds)) - slotChildOutput(out[0]); - - if ((communication & Stderr) && FD_ISSET(err[0], &rfds)) - slotChildError(err[0]); - - if (runs && FD_ISSET(notfd, &rfds)) { - runs = false; // hack: signal potential exit - return; // don't close anything, we will be called again - } - } - } -#endif //Q_OS_UNIX - - closeStdout(); - closeStderr(); - - closePty(); -} - - -void KProcess::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - - -/////////////////////////// -// CC: Class KShellProcess -/////////////////////////// - -KShellProcess::KShellProcess(const char *shellname): - KProcess() -{ - setUseShell( true, shellname ? shellname : getenv("SHELL") ); -} - -KShellProcess::~KShellProcess() { -} - -TQString KShellProcess::quote(const TQString &arg) -{ - return KProcess::quote(arg); -} - -bool KShellProcess::start(RunMode runmode, Communication comm) -{ - return KProcess::start(runmode, comm); -} - -void KShellProcess::virtual_hook( int id, void* data ) -{ KProcess::virtual_hook( id, data ); } - -#include "kprocess.moc" diff --git a/kdecore/kprocess.h b/kdecore/kprocess.h deleted file mode 100644 index a07df060e..000000000 --- a/kdecore/kprocess.h +++ /dev/null @@ -1,939 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) - - 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 __kprocess_h__ -#define __kprocess_h__ - -#include <sys/types.h> // for pid_t -#include <sys/wait.h> -#include <signal.h> -#include <unistd.h> -#include <tqvaluelist.h> -#include <tqcstring.h> -#include <tqobject.h> -#include "kdelibs_export.h" - -class TQSocketNotifier; -class KProcessPrivate; - -#ifdef Q_OS_UNIX -#include <kpty.h> -#else -class KPty; -#endif - -/** - * Child process invocation, monitoring and control. - * This class works only in the application's main thread. - * - * <b>General usage and features:</b>\n - * - * This class allows a KDE application to start child processes without having - * to worry about UN*X signal handling issues and zombie process reaping. - * - * @see KProcIO - * - * Basically, this class distinguishes three different ways of running - * child processes: - * - * @li DontCare -- The child process is invoked and both the child - * process and the parent process continue concurrently. - * - * The process is started in an own session (see setsid(2)). - * - * @li NotifyOnExit -- The child process is invoked and both the - * child and the parent process run concurrently. - * - * When the child process exits, the KProcess instance - * corresponding to it emits the Qt signal processExited(). - * Since this signal is @em not emitted from within a UN*X - * signal handler, arbitrary function calls can be made. - * - * Be aware: When the KProcess object gets destructed, the child - * process will be killed if it is still running! - * This means in particular, that it usually makes no sense to use - * a KProcess on the stack with NotifyOnExit. - * - * @li OwnGroup -- like NotifyOnExit, but the child process is started - * in an own process group (and an own session, FWIW). The behavior of - * kill() changes to killing the whole process group - this makes - * this mode useful for implementing primitive job management. It can be - * used to work around broken wrapper scripts that don't propagate signals - * to the "real" program. However, use this with care, as you disturb the - * shell's job management if your program is started from the command line. - * - * @li Block -- The child process starts and the parent process - * is suspended until the child process exits. (@em Really not recommended - * for programs with a GUI.) - * In this mode the parent can read the child's output, but can't send it any - * input. - * - * KProcess also provides several functions for determining the exit status - * and the pid of the child process it represents. - * - * Furthermore it is possible to supply command-line arguments to the process - * in a clean fashion (no null-terminated stringlists and such...) - * - * A small usage example: - * \code - * KProcess *proc = new KProcess; - * - * *proc << "my_executable"; - * *proc << "These" << "are" << "the" << "command" << "line" << "args"; - * TQApplication::connect(proc, TQT_SIGNAL(processExited(KProcess *)), - * pointer_to_my_object, TQT_SLOT(my_objects_slot(KProcess *))); - * proc->start(); - * \endcode - * - * This will start "my_executable" with the commandline arguments "These"... - * - * When the child process exits, the slot will be invoked. - * - * <b>Communication with the child process:</b>\n - * - * KProcess supports communication with the child process through - * stdin/stdout/stderr. - * - * The following functions are provided for getting data from the child - * process or sending data to the child's stdin (For more information, - * have a look at the documentation of each function): - * - * @li writeStdin() - * -- Transmit data to the child process' stdin. When all data was sent, the - * signal wroteStdin() is emitted. - * - * @li When data arrives at stdout or stderr, the signal receivedStdout() - * resp. receivedStderr() is emitted. - * - * @li You can shut down individual communication channels with - * closeStdin(), closeStdout(), and closeStderr(), resp. - * - * @author Christian Czezatke e9025461@student.tuwien.ac.at - * - **/ -class KDECORE_EXPORT KProcess : public TQObject -{ - Q_OBJECT - -public: - - /** - * Modes in which the communication channel can be opened. - * - * If communication for more than one channel is required, - * the values have to be or'ed together, for example to get - * communication with stdout as well as with stdin, you would - * specify @p Stdin | @p Stdout - * - * If @p NoRead is specified in conjunction with @p Stdout, - * no data is actually read from @p Stdout but only - * the signal receivedStdout(int fd, int &len) is emitted. - * - * @p CTtyOnly tells setUsePty() to create a PTY for the process - * and make it the process' controlling TTY, but does not redirect - * any I/O channel to the PTY. - * - * If @p MergedStderr is specified in conjunction with @p Stdout, - * Stderr will be redirected onto the same file handle as Stdout, - * i.e., all error output will be signalled with receivedStdout(). - * Don't specify @p Stderr if you specify @p MergedStderr. - */ - enum Communication { - NoCommunication = 0, - Stdin = 1, Stdout = 2, Stderr = 4, - AllOutput = 6, All = 7, - NoRead = 8, - CTtyOnly = NoRead, - MergedStderr = 16 - }; - - /** - * Run-modes for a child process. - */ - enum RunMode { - /** - * The application does not receive notifications from the subprocess when - * it is finished or aborted. - */ - DontCare, - /** - * The application is notified when the subprocess dies. - */ - NotifyOnExit, - /** - * The application is suspended until the started process is finished. - */ - Block, - /** - * Same as NotifyOnExit, but the process is run in an own session, - * just like with DontCare. - */ - OwnGroup - }; - - /** - * Constructor - * @since 3.2 - */ - KProcess( TQObject* parent, const char *name = 0 ); - - /** - * Constructor - */ // KDE4 merge with the above - KProcess(); - - /** - *Destructor: - * - * If the process is running when the destructor for this class - * is called, the child process is killed with a SIGKILL, but - * only if the run mode is not of type @p DontCare. - * Processes started as @p DontCare keep running anyway. - */ - virtual ~KProcess(); - - /** - @deprecated - Use operator<<() instead. - - Sets the executable to be started with this KProcess object. - Returns false if the process is currently running (in that - case the executable remains unchanged). - - @see operator<<() - - */ - bool setExecutable(const TQString& proc) KDE_DEPRECATED; - - - /** - * Sets the executable and the command line argument list for this process. - * - * For example, doing an "ls -l /usr/local/bin" can be achieved by: - * \code - * KProcess p; - * ... - * p << "ls" << "-l" << "/usr/local/bin" - * \endcode - * - * @param arg the argument to add - * @return a reference to this KProcess - **/ - KProcess &operator<<(const TQString& arg); - /** - * Similar to previous method, takes a char *, supposed to be in locale 8 bit already. - */ - KProcess &operator<<(const char * arg); - /** - * Similar to previous method, takes a TQCString, supposed to be in locale 8 bit already. - * @param arg the argument to add - * @return a reference to this KProcess - */ - KProcess &operator<<(const TQCString & arg); - - /** - * Sets the executable and the command line argument list for this process, - * in a single method call, or add a list of arguments. - * @param args the arguments to add - * @return a reference to this KProcess - **/ - KProcess &operator<<(const TQStringList& args); - - /** - * Clear a command line argument list that has been set by using - * operator<<. - */ - void clearArguments(); - - /** - * Starts the process. - * For a detailed description of the - * various run modes and communication semantics, have a look at the - * general description of the KProcess class. Note that if you use - * setUsePty( Stdout | Stderr, \<bool\> ), you cannot use Stdout | Stderr - * here - instead, use Stdout only to receive the mixed output. - * - * The following problems could cause this function to - * return false: - * - * @li The process is already running. - * @li The command line argument list is empty. - * @li The the @p comm parameter is incompatible with the selected pty usage. - * @li The starting of the process failed (could not fork). - * @li The executable was not found. - * - * @param runmode The Run-mode for the process. - * @param comm Specifies which communication links should be - * established to the child process (stdin/stdout/stderr). By default, - * no communication takes place and the respective communication - * signals will never get emitted. - * - * @return true on success, false on error - * (see above for error conditions) - **/ - virtual bool start(RunMode runmode = NotifyOnExit, - Communication comm = NoCommunication); - - /** - * Stop the process (by sending it a signal). - * - * @param signo The signal to send. The default is SIGTERM. - * @return true if the signal was delivered successfully. - */ - virtual bool kill(int signo = SIGTERM); - - /** - * Checks whether the process is running. - * @return true if the process is (still) considered to be running - */ - bool isRunning() const; - - /** Returns the process id of the process. - * - * If it is called after - * the process has exited, it returns the process id of the last - * child process that was created by this instance of KProcess. - * - * Calling it before any child process has been started by this - * KProcess instance causes pid() to return 0. - * @return the pid of the process or 0 if no process has been started yet. - **/ - pid_t pid() const; - - /** - * @deprecated - * Use pid() instead. - */ - KDE_DEPRECATED pid_t getPid() const { return pid(); } - - /** - * Suspend processing of data from stdout of the child process. - */ - void suspend(); - - /** - * Resume processing of data from stdout of the child process. - */ - void resume(); - - /** - * Suspend execution of the current thread until the child process dies - * or the timeout hits. This function is not recommended for programs - * with a GUI. - * @param timeout timeout in seconds. -1 means wait indefinitely. - * @return true if the process exited, false if the timeout hit. - * @since 3.2 - */ - bool wait(int timeout = -1); - - /** - * Checks whether the process exited cleanly. - * - * @return true if the process has already finished and has exited - * "voluntarily", ie: it has not been killed by a signal. - */ - bool normalExit() const; - - /** - * Checks whether the process was killed by a signal. - * - * @return true if the process has already finished and has not exited - * "voluntarily", ie: it has been killed by a signal. - * - * @since 3.2 - */ - bool signalled() const; - - /** - * Checks whether a killed process dumped core. - * - * @return true if signalled() returns true and the process - * dumped core. Note that on systems that don't define the - * WCOREDUMP macro, the return value is always false. - * - * @since 3.2 - */ - bool coreDumped() const; - - /** - * Returns the exit status of the process. - * - * @return the exit status of the process. Note that this value - * is not valid if normalExit() returns false. - */ - int exitStatus() const; - - /** - * Returns the signal the process was killed by. - * - * @return the signal number that caused the process to exit. - * Note that this value is not valid if signalled() returns false. - * - * @since 3.2 - */ - int exitSignal() const; - - /** - * Transmit data to the child process' stdin. - * - * This function may return false in the following cases: - * - * @li The process is not currently running. - * This implies that you cannot use this function in Block mode. - * - * @li Communication to stdin has not been requested in the start() call. - * - * @li Transmission of data to the child process by a previous call to - * writeStdin() is still in progress. - * - * Please note that the data is sent to the client asynchronously, - * so when this function returns, the data might not have been - * processed by the child process. - * That means that you must not free @p buffer or call writeStdin() - * again until either a wroteStdin() signal indicates that the - * data has been sent or a processExited() signal shows that - * the child process is no longer alive. - * - * If all the data has been sent to the client, the signal - * wroteStdin() will be emitted. - * - * This function does not work when the process is start()ed in Block mode. - * - * @param buffer the buffer to write - * @param buflen the length of the buffer - * @return false if an error has occurred - **/ - bool writeStdin(const char *buffer, int buflen); - - /** - * Shuts down the Stdin communication link. If no pty is used, this - * causes "EOF" to be indicated on the child's stdin file descriptor. - * - * @return false if no Stdin communication link exists (any more). - */ - bool closeStdin(); - - /** - * Shuts down the Stdout communication link. If no pty is used, any further - * attempts by the child to write to its stdout file descriptor will cause - * it to receive a SIGPIPE. - * - * @return false if no Stdout communication link exists (any more). - */ - bool closeStdout(); - - /** - * Shuts down the Stderr communication link. If no pty is used, any further - * attempts by the child to write to its stderr file descriptor will cause - * it to receive a SIGPIPE. - * - * @return false if no Stderr communication link exists (any more). - */ - bool closeStderr(); - - /** - * Deletes the optional utmp entry and closes the pty. - * - * Make sure to shut down any communication links that are using the pty - * before calling this function. - * - * @return false if the pty is not open (any more). - */ - bool closePty(); - - /** - * @brief Close stdin, stdout, stderr and the pty - * - * This is the same that calling all close* functions in a row: - * @see closeStdin, @see closeStdout, @see closeStderr and @see closePty - */ - void closeAll(); - - /** - * Lets you see what your arguments are for debugging. - * @return the list of arguments - */ - const TQValueList<TQCString> &args() /* const */ { return arguments; } - - /** - * Controls whether the started process should drop any - * setuid/setgid privileges or whether it should keep them. - * Note that this function is mostly a dummy, as the KDE libraries - * currently refuse to run with setuid/setgid privileges. - * - * The default is false: drop privileges - * @param keepPrivileges true to keep the privileges - */ - void setRunPrivileged(bool keepPrivileges); - - /** - * Returns whether the started process will drop any - * setuid/setgid privileges or whether it will keep them. - * @return true if the process runs privileged - */ - bool runPrivileged() const; - - /** - * Adds the variable @p name to the process' environment. - * This function must be called before starting the process. - * @param name the name of the environment variable - * @param value the new value for the environment variable - */ - void setEnvironment(const TQString &name, const TQString &value); - - /** - * Changes the current working directory (CWD) of the process - * to be started. - * This function must be called before starting the process. - * @param dir the new directory - */ - void setWorkingDirectory(const TQString &dir); - - /** - * Specify whether to start the command via a shell or directly. - * The default is to start the command directly. - * If @p useShell is true @p shell will be used as shell, or - * if shell is empty, /bin/sh will be used. - * - * When using a shell, the caller should make sure that all filenames etc. - * are properly quoted when passed as argument. - * @see quote() - * @param useShell true if the command should be started via a shell - * @param shell the path to the shell that will execute the process, or - * 0 to use /bin/sh. Use getenv("SHELL") to use the user's - * default shell, but note that doing so is usually a bad idea - * for shell compatibility reasons. - * @since 3.1 - */ - void setUseShell(bool useShell, const char *shell = 0); - - /** - * This function can be used to quote an argument string such that - * the shell processes it properly. This is e. g. necessary for - * user-provided file names which may contain spaces or quotes. - * It also prevents expansion of wild cards and environment variables. - * @param arg the argument to quote - * @return the quoted argument - * @since 3.1 - */ - static TQString quote(const TQString &arg); - - /** - * Detaches KProcess from child process. All communication is closed. - * No exit notification is emitted any more for the child process. - * Deleting the KProcess will no longer kill the child process. - * Note that the current process remains the parent process of the - * child process. - */ - void detach(); - -#ifdef Q_OS_UNIX - /** - * Specify whether to create a pty (pseudo-terminal) for running the - * command. - * This function should be called before starting the process. - * - * @param comm for which stdio handles to use a pty. Note that it is not - * allowed to specify Stdout and Stderr at the same time both here and to - * start (there is only one pty, so they cannot be distinguished). - * @param addUtmp true if a utmp entry should be created for the pty - * @since 3.2 - */ - void setUsePty(Communication comm, bool addUtmp); - - /** - * Obtains the pty object used by this process. The return value is - * valid only after setUsePty() was used with a non-zero argument. - * The pty is open only while the process is running. - * @return a pointer to the pty object - * @since 3.2 - */ - KPty *pty() const; -#endif - - /** - * More or less intuitive constants for use with setPriority(). - */ - enum { PrioLowest = 20, PrioLow = 10, PrioLower = 5, PrioNormal = 0, - PrioHigher = -5, PrioHigh = -10, PrioHighest = -19 }; - - /** - * Sets the scheduling priority of the process. - * @param prio the new priority in the range -20 (high) to 19 (low). - * @return false on error; see setpriority(2) for possible reasons. - * @since 3.2 - */ - bool setPriority(int prio); - -signals: - /** - * Emitted after the process has terminated when - * the process was run in the @p NotifyOnExit (==default option to - * start() ) or the Block mode. - * @param proc a pointer to the process that has exited - **/ - void processExited(KProcess *proc); - - - /** - * Emitted, when output from the child process has - * been received on stdout. - * - * To actually get this signal, the Stdout communication link - * has to be turned on in start(). - * - * @param proc a pointer to the process that has received the output - * @param buffer The data received. - * @param buflen The number of bytes that are available. - * - * You should copy the information contained in @p buffer to your private - * data structures before returning from the slot. - * Example: - * \code - * TQString myBuf = TQString::tqfromLatin1(buffer, buflen); - * \endcode - **/ - void receivedStdout(KProcess *proc, char *buffer, int buflen); - - /** - * Emitted when output from the child process has - * been received on stdout. - * - * To actually get this signal, the Stdout communication link - * has to be turned on in start() and the - * NoRead flag must have been passed. - * - * You will need to explicitly call resume() after your call to start() - * to begin processing data from the child process' stdout. This is - * to ensure that this signal is not emitted when no one is connected - * to it, otherwise this signal will not be emitted. - * - * The data still has to be read from file descriptor @p fd. - * @param fd the file descriptor that provides the data - * @param len the number of bytes that have been read from @p fd must - * be written here - **/ - void receivedStdout(int fd, int &len); // KDE4: change, broken API - - - /** - * Emitted, when output from the child process has - * been received on stderr. - * - * To actually get this signal, the Stderr communication link - * has to be turned on in start(). - * - * You should copy the information contained in @p buffer to your private - * data structures before returning from the slot. - * - * @param proc a pointer to the process that has received the data - * @param buffer The data received. - * @param buflen The number of bytes that are available. - **/ - void receivedStderr(KProcess *proc, char *buffer, int buflen); - - /** - * Emitted after all the data that has been - * specified by a prior call to writeStdin() has actually been - * written to the child process. - * @param proc a pointer to the process - **/ - void wroteStdin(KProcess *proc); - - -protected slots: - - /** - * This slot gets activated when data from the child's stdout arrives. - * It usually calls childOutput(). - * @param fdno the file descriptor for the output - */ - void slotChildOutput(int fdno); - - /** - * This slot gets activated when data from the child's stderr arrives. - * It usually calls childError(). - * @param fdno the file descriptor for the output - */ - void slotChildError(int fdno); - - /** - * Called when another bulk of data can be sent to the child's - * stdin. If there is no more data to be sent to stdin currently - * available, this function must disable the TQSocketNotifier innot. - * @param dummy ignore this argument - */ - void slotSendData(int dummy); // KDE 4: remove dummy - -protected: - - /** - * Sets up the environment according to the data passed via - * setEnvironment() - */ - void setupEnvironment(); - - /** - * The list of the process' command line arguments. The first entry - * in this list is the executable itself. - */ - TQValueList<TQCString> arguments; - /** - * How to run the process (Block, NotifyOnExit, DontCare). You should - * not modify this data member directly from derived classes. - */ - RunMode run_mode; - /** - * true if the process is currently running. You should not - * modify this data member directly from derived classes. Please use - * isRunning() for reading the value of this data member since it - * will probably be made private in later versions of KProcess. - */ - bool runs; - - /** - * The PID of the currently running process. - * You should not modify this data member in derived classes. - * Please use pid() instead of directly accessing this - * member since it will probably be made private in - * later versions of KProcess. - */ - pid_t pid_; - - /** - * The process' exit status as returned by waitpid(). You should not - * modify the value of this data member from derived classes. You should - * rather use exitStatus() than accessing this data member directly - * since it will probably be made private in further versions of - * KProcess. - */ - int status; - - - /** - * If false, the child process' effective uid & gid will be reset to the - * real values. - * @see setRunPrivileged() - */ - bool keepPrivs; - - /** - * This function is called from start() right before a fork() takes - * place. According to the @p comm parameter this function has to initialize - * the in, out and err data members of KProcess. - * - * This function should return 1 if setting the needed communication channels - * was successful. - * - * The default implementation is to create UNIX STREAM sockets for the - * communication, but you could reimplement this function to establish a - * TCP/IP communication for network communication, for example. - */ - virtual int setupCommunication(Communication comm); - - /** - * Called right after a (successful) fork() on the parent side. This function - * will usually do some communications cleanup, like closing in[0], - * out[1] and out[1]. - * - * Furthermore, it must also create the TQSocketNotifiers innot, - * outnot and errnot and connect their Qt signals to the respective - * KProcess slots. - * - * For a more detailed explanation, it is best to have a look at the default - * implementation in kprocess.cpp. - */ - virtual int commSetupDoneP(); - - /** - * Called right after a (successful) fork(), but before an exec() on the child - * process' side. It usually duplicates the in[0], out[1] and - * err[1] file handles to the respective standard I/O handles. - */ - virtual int commSetupDoneC(); - - - /** - * Immediately called after a successfully started process in NotifyOnExit - * mode has exited. This function normally calls commClose() - * and emits the processExited() signal. - * @param state the exit code of the process as returned by waitpid() - */ - virtual void processHasExited(int state); - - /** - * Cleans up the communication links to the child after it has exited. - * This function should act upon the values of pid() and runs. - * See the kprocess.cpp source for details. - * @li If pid() returns zero, the communication links should be closed - * only. - * @li if pid() returns non-zero and runs is false, all data - * immediately available from the communication links should be processed - * before closing them. - * @li if pid() returns non-zero and runs is true, the communication - * links should be monitored for data until the file handle returned by - * KProcessController::theKProcessController->notifierFd() becomes ready - * for reading - when it triggers, runs should be reset to false, and - * the function should be immediately left without closing anything. - * - * The previous semantics of this function are forward-compatible, but should - * be avoided, as they are prone to race conditions and can cause KProcess - * (and thus the whole program) to lock up under certain circumstances. At the - * end the function closes the communication links in any case. Additionally - * @li if runs is true, the communication links are monitored for data - * until all of them have returned EOF. Note that if any system function is - * interrupted (errno == EINTR) the polling loop should be aborted. - * @li if runs is false, all data immediately available from the - * communication links is processed. - */ - virtual void commClose(); - - /* KDE 4 - commClose will be changed to perform cleanup only in all cases * - * If @p notfd is -1, all data immediately available from the - * communication links should be processed. - * If @p notfd is not -1, the communication links should be monitored - * for data until the file handle @p notfd becomes ready for reading. - */ -// virtual void commDrain(int notfd); - - /** - * Specify the actual executable that should be started (first argument to execve) - * Normally the the first argument is the executable but you can - * override that with this function. - */ - void setBinaryExecutable(const char *filename); - - /** - * The socket descriptors for stdout. - */ - int out[2]; - /** - * The socket descriptors for stdin. - */ - int in[2]; - /** - * The socket descriptors for stderr. - */ - int err[2]; - - /** - * The socket notifier for in[1]. - */ - TQSocketNotifier *innot; - /** - * The socket notifier for out[0]. - */ - TQSocketNotifier *outnot; - /** - * The socket notifier for err[0]. - */ - TQSocketNotifier *errnot; - - /** - * Lists the communication links that are activated for the child - * process. Should not be modified from derived classes. - */ - Communication communication; - - /** - * Called by slotChildOutput() this function copies data arriving from - * the child process' stdout to the respective buffer and emits the signal - * receivedStdout(). - */ - int childOutput(int fdno); - - /** - * Called by slotChildError() this function copies data arriving from - * the child process' stderr to the respective buffer and emits the signal - * receivedStderr(). - */ - int childError(int fdno); - - /** - * The buffer holding the data that has to be sent to the child - */ - const char *input_data; - /** - * The number of bytes already transmitted - */ - int input_sent; - /** - * The total length of input_data - */ - int input_total; - - /** - * KProcessController is a friend of KProcess because it has to have - * access to various data members. - */ - friend class KProcessController; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KProcessPrivate *d; -}; - -class KShellProcessPrivate; - -/** -* @obsolete -* -* Use KProcess and KProcess::setUseShell(true) instead. -* -* @short A class derived from KProcess to start child -* processes through a shell. -* @author Christian Czezatke <e9025461@student.tuwien.ac.at> -*/ -class KDECORE_EXPORT KShellProcess: public KProcess -{ - Q_OBJECT - -public: - - /** - * Constructor - * - * If no shellname is specified, the user's default shell is used. - */ - KShellProcess(const char *shellname=0); - - /** - * Destructor. - */ - ~KShellProcess(); - - virtual bool start(RunMode runmode = NotifyOnExit, - Communication comm = NoCommunication); - - static TQString quote(const TQString &arg); - -private: - TQCString shell; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KShellProcessPrivate *d; -}; - - - -#endif - diff --git a/kdecore/kprocio.cpp b/kdecore/kprocio.cpp deleted file mode 100644 index 9159edab5..000000000 --- a/kdecore/kprocio.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 David Sweet <dsweet@kde.org> - - 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. -*/ - -// $Id$ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> - -#include "kprocio.h" - -#include <kdebug.h> -#include <tqtextcodec.h> - -class KProcIOPrivate { -public: - KProcIOPrivate() : comm(KProcess::All) {} - KProcess::Communication comm; -}; - -KProcIO::KProcIO ( TQTextCodec *_codec) - : codec(_codec), d(new KProcIOPrivate) -{ - rbi=0; - readsignalon=writeready=true; - outbuffer.setAutoDelete(true); - - if (!codec) - { - codec = TQTextCodec::codecForName("ISO 8859-1"); - if (!codec) - { - kdError(174) << "Can't create ISO 8859-1 codec!" << endl; - } - } -} - -KProcIO::~KProcIO() -{ - delete d; -} - -void -KProcIO::resetAll () -{ - if (isRunning()) - kill(); - - clearArguments(); - rbi=0; - readsignalon=writeready=true; - - disconnect (this, TQT_SIGNAL (receivedStdout (KProcess *, char *, int)), - this, TQT_SLOT (received (KProcess *, char *, int))); - - disconnect (this, TQT_SIGNAL (receivedStderr (KProcess *, char *, int)), - this, TQT_SLOT (received (KProcess *, char *, int))); - - disconnect (this, TQT_SIGNAL (wroteStdin(KProcess *)), - this, TQT_SLOT (sent (KProcess *))); - - outbuffer.clear(); - -} - -void KProcIO::setComm (Communication comm) -{ - d->comm = comm; -} - -bool KProcIO::start (RunMode runmode, bool includeStderr) -{ - connect (this, TQT_SIGNAL (receivedStdout (KProcess *, char *, int)), - this, TQT_SLOT (received (KProcess *, char *, int))); - - if (includeStderr) - { - connect (this, TQT_SIGNAL (receivedStderr (KProcess *, char *, int)), - this, TQT_SLOT (received (KProcess *, char *, int))); - } - - connect (this, TQT_SIGNAL (wroteStdin(KProcess *)), - this, TQT_SLOT (sent (KProcess *))); - - return KProcess::start (runmode, d->comm); -} - -bool KProcIO::writeStdin (const TQString &line, bool appendnewline) -{ - return writeStdin(TQCString(codec->fromUnicode(line)), appendnewline); -} - -bool KProcIO::writeStdin (const TQCString &line, bool appendnewline) -{ - TQCString *qs = new TQCString(line); - - if (appendnewline) - { - *qs += '\n'; - } - - int l = qs->length(); - if (!l) - { - delete qs; - return true; - } - - TQByteArray *b = (TQByteArray *) qs; - b->truncate(l); // Strip trailing null - - outbuffer.append(b); - - if (writeready) - { - writeready=false; - return KProcess::writeStdin( b->data(), b->size() ); - } - return true; -} - -bool KProcIO::writeStdin(const TQByteArray &data) -{ - if (!data.size()) - return true; - TQByteArray *b = new TQByteArray(data); - outbuffer.append(b); - - if (writeready) - { - writeready=false; - return KProcess::writeStdin( b->data(), b->size() ); - } - return true; -} - -void KProcIO::closeWhenDone() -{ - if (writeready) - { - closeStdin(); - return; - } - outbuffer.append(0); - - return; -} - -void KProcIO::sent(KProcess *) -{ - outbuffer.removeFirst(); - - if (outbuffer.count()==0) - { - writeready=true; - } - else - { - TQByteArray *b = outbuffer.first(); - if (!b) - { - closeStdin(); - } - else - { - KProcess::writeStdin(b->data(), b->size()); - } - } - -} - -void KProcIO::received (KProcess *, char *buffer, int buflen) -{ - recvbuffer += TQCString(buffer, buflen+1); - - controlledEmission(); -} - -void KProcIO::ackRead () -{ - readsignalon=true; - if (needreadsignal || recvbuffer.length()!=0) - controlledEmission(); -} - -void KProcIO::controlledEmission () -{ - if (readsignalon) - { - needreadsignal=false; - readsignalon=false; //will stay off until read is acknowledged - emit readReady (this); - } - else - { - needreadsignal=true; - } -} - -void KProcIO::enableReadSignals (bool enable) -{ - readsignalon=enable; - - if (enable && needreadsignal) - emit readReady (this); -} - -int KProcIO::readln (TQString &line, bool autoAck, bool *partial) -{ - int len; - - if (autoAck) - readsignalon=true; - - //need to reduce the size of recvbuffer at some point... - - len=recvbuffer.find ('\n',rbi)-rbi; - - //kdDebug(174) << "KPIO::readln" << endl; - - //in case there's no '\n' at the end of the buffer - if ((len<0) && - ((unsigned int)rbi<recvbuffer.length())) - { - recvbuffer=recvbuffer.mid (rbi); - rbi=0; - if (partial) - { - len = recvbuffer.length(); - line = recvbuffer; - recvbuffer = ""; - *partial = true; - return len; - } - return -1; - } - - if (len>=0) - { - line = codec->toUnicode(recvbuffer.mid(rbi,len), len); - rbi += len+1; - if (partial) - *partial = false; - return len; - } - - recvbuffer=""; - rbi=0; - - //-1 on return signals "no more data" not error - return -1; - -} - -void KProcIO::virtual_hook( int id, void* data ) -{ KProcess::virtual_hook( id, data ); } - -#include "kprocio.moc" - diff --git a/kdecore/kprocio.h b/kdecore/kprocio.h deleted file mode 100644 index 89c69008e..000000000 --- a/kdecore/kprocio.h +++ /dev/null @@ -1,217 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 David Sweet <dsweet@kde.org> - - 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 KPROCIO_H_ -#define KPROCIO_H_ - -#include <tqstring.h> -#include <kprocess.h> -#include <tqstrlist.h> -#include "kdelibs_export.h" - -class KProcIOPrivate; -class TQTextCodec; - -/** - * KProcIO - * - * This class provides a slightly simpler interface to the communication - * functions provided by KProcess. The simplifications are: - * @li The buffer for a write is copied to an internal KProcIO - * buffer and maintained/freed appropriately. There is no need - * to be concerned with wroteStdin() signals _at_all_. - * @li readln() reads a line of data and buffers any leftovers. - * @li Conversion from/to tqunicode. - * - * Basically, KProcIO gives you buffered I/O similar to fgets()/fputs(). - * - * Aside from these, and the fact that start() takes different - * parameters, use this class just like KProcess. - * - * @author David Sweet - * @short A slightly simpler interface to KProcess - **/ - - -class KDECORE_EXPORT KProcIO : public KProcess -{ - Q_OBJECT - -public: - /** - * Constructor - */ - KProcIO ( TQTextCodec *codec = 0 ); - - /** - * Destructor - */ - ~KProcIO(); - - /** - * Sets the communication mode to be passed to KProcess::start() - * by start(). The default communication mode is KProcess::All. - * You probably want to use this function in conjunction with - * KProcess::setUsePty(). - * @param comm the communication mode - */ - void setComm (Communication comm); - - /** - * Starts the process. It will fail in the following cases: - * @li The process is already running. - * @li The command line argument list is empty. - * @li The starting of the process failed (could not fork). - * @li The executable was not found. - * - * @param runmode For a detailed description of the - * various run modes, have a look at the - * general description of the KProcess class. - * @param includeStderr If true, data from both stdout and stderr is - * listened to. If false, only stdout is listened to. - * @return true on success, false on error. - **/ - bool start (RunMode runmode = NotifyOnExit, bool includeStderr = false); - - /** - * Writes text to stdin of the process. - * @param line Text to write. - * @param appendnewline if true, a newline '\\n' is appended. - * @return true if successful, false otherwise - **/ - bool writeStdin(const TQString &line, bool appendnewline=true); - - /** - * Writes text to stdin of the process. - * @param line Text to write. - * @param appendnewline if true, a newline '\\n' is appended. - * @return true if successful, false otherwise - **/ - bool writeStdin(const TQCString &line, bool appendnewline); - - /** - * Writes data to stdin of the process. - * @param data Data to write. - * @return true if successful, false otherwise - **/ - bool writeStdin(const TQByteArray &data); - - //I like fputs better -- it's the same as writeStdin - //inline - /** - * This function just calls writeStdin(). - * - * @param line Text to write. - * @param AppendNewLine if true, a newline '\\n' is appended. - * @return true if successful, false otherwise - * @deprecated - **/ - KDE_DEPRECATED bool fputs (const TQString &line, bool AppendNewLine=true) - { return writeStdin(line, AppendNewLine); } - - /** - * Closes stdin after all data has been send. - */ - void closeWhenDone(); - - /** - * Reads a line of text (up to and including '\\n'). - * - * Use readln() in response to a readReady() signal. - * You may use it multiple times if more than one line of data is - * available. - * Be sure to use ackRead() when you have finished processing the - * readReady() signal. This informs KProcIO that you are ready for - * another readReady() signal. - * - * readln() never blocks. - * - * autoAck==true makes these functions call ackRead() for you. - * - * @param line is used to store the line that was read. - * @param autoAck when true, ackRead() is called for you. - * @param partial when provided the line is returned - * even if it does not contain a '\\n'. *partial will be set to - * false if the line contains a '\\n' and false otherwise. - * @return the number of characters read, or -1 if no data is available. - **/ - int readln (TQString &line, bool autoAck=true, bool *partial=0); - - /** - * This function calls readln(). - * @param line is used to store the line that was read. - * @param autoAck when true, ackRead() is called for you. - * @return the number of characters read, or -1 if no data is available. - * @deprecated use readln. Note that it has an inverted autoAck default, - * though. - **/ - KDE_DEPRECATED int fgets (TQString &line, bool autoAck=false) - { return readln (line, autoAck); } - - /** - * Reset the class. Doesn't kill the process. - **/ - void resetAll (); - - /** - * Call this after you have finished processing a readReady() - * signal. This call need not be made in the slot that was signalled - * by readReady(). You won't receive any more readReady() signals - * until you acknowledge with ackRead(). This prevents your slot - * from being reentered while you are still processing the current - * data. If this doesn't matter, then call ackRead() right away in - * your readReady()-processing slot. - **/ - void ackRead (); - - /** - * Turns readReady() signals on and off. - * You can turn this off at will and not worry about losing any data. - * (as long as you turn it back on at some point...) - * @param enable true to turn the signals on, false to turn them off - */ - void enableReadSignals (bool enable); - -signals: - /** - * Emitted when the process is ready for reading. - * @param pio the process that emitted the signal - * @see enableReadSignals() - */ - void readReady(KProcIO *pio); - -protected: - TQPtrList<TQByteArray> outbuffer; - TQCString recvbuffer; - TQTextCodec *codec; - int rbi; - bool needreadsignal, readsignalon, writeready; - - void controlledEmission (); - -protected slots: - void received (KProcess *proc, char *buffer, int buflen); - void sent (KProcess *); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KProcIOPrivate *d; -}; - -#endif // KPROCIO_H_ - diff --git a/kdecore/kprotocolinfo_kdecore.cpp b/kdecore/kprotocolinfo_kdecore.cpp deleted file mode 100644 index 66ce97760..000000000 --- a/kdecore/kprotocolinfo_kdecore.cpp +++ /dev/null @@ -1,562 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - - 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. -*/ - -#ifdef MAKE_KDECORE_LIB //needed for proper linkage (win32) -#undef KIO_EXPORT -#define KIO_EXPORT KDE_EXPORT -#endif - -#define KPROTOCOLINFO_KDECORE -#include "kprotocolinfo.h" -#include "kprotocolinfofactory.h" - -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kapplication.h> -#include <kdebug.h> -#include <ksimpleconfig.h> -#include <kconfig.h> -#include <kstringhandler.h> - -class KProtocolInfo::KProtocolInfoPrivate -{ -public: - TQString docPath; - TQString protClass; - KProtocolInfo::ExtraFieldList extraFields; - bool showPreviews; - bool canRenameFromFile; - bool canRenameToFile; - bool canDeleteRecursive; - bool fileNameUsedForCopying; // true if using UDS_NAME, false if using KURL::fileName() [default] - KURL::URIMode uriMode; - TQStringList capabilities; - TQString proxyProtocol; -}; - -// -// Internal functions: -// -KProtocolInfo::KProtocolInfo(const TQString &path) - : KSycocaEntry(path) -{ - d = new KProtocolInfoPrivate; - TQString fullPath = locate("services", path); - - KSimpleConfig config( fullPath, true ); - config.setGroup( "Protocol" ); - - m_name = config.readEntry( "protocol" ); - m_exec = config.readPathEntry( "exec" ); - m_isSourceProtocol = config.readBoolEntry( "source", true ); - m_isHelperProtocol = config.readBoolEntry( "helper", false ); - m_supportsReading = config.readBoolEntry( "reading", false ); - m_supportsWriting = config.readBoolEntry( "writing", false ); - m_supportsMakeDir = config.readBoolEntry( "makedir", false ); - m_supportsDeleting = config.readBoolEntry( "deleting", false ); - m_supportsLinking = config.readBoolEntry( "linking", false ); - m_supportsMoving = config.readBoolEntry( "moving", false ); - m_canCopyFromFile = config.readBoolEntry( "copyFromFile", false ); - m_canCopyToFile = config.readBoolEntry( "copyToFile", false ); - d->canRenameFromFile = config.readBoolEntry( "renameFromFile", false ); - d->canRenameToFile = config.readBoolEntry( "renameToFile", false ); - d->canDeleteRecursive = config.readBoolEntry( "deleteRecursive", false ); - d->fileNameUsedForCopying = config.readEntry( "fileNameUsedForCopying", "FromURL" ) == "Name"; - - m_listing = config.readListEntry( "listing" ); - // Many .protocol files say "Listing=false" when they really mean "Listing=" (i.e. unsupported) - if ( m_listing.count() == 1 && m_listing.first() == "false" ) - m_listing.clear(); - m_supportsListing = ( m_listing.count() > 0 ); - m_defaultMimetype = config.readEntry( "defaultMimetype" ); - m_determineMimetypeFromExtension = config.readBoolEntry( "determineMimetypeFromExtension", true ); - m_icon = config.readEntry( "Icon", "unknown" ); - m_config = config.readEntry( "config", m_name ); - m_maxSlaves = config.readNumEntry( "maxInstances", 1); - - TQString tmp = config.readEntry( "input" ); - if ( tmp == "filesystem" ) - m_inputType = KProtocolInfo::T_FILESYSTEM; - else if ( tmp == "stream" ) - m_inputType = KProtocolInfo::T_STREAM; - else - m_inputType = KProtocolInfo::T_NONE; - - tmp = config.readEntry( "output" ); - if ( tmp == "filesystem" ) - m_outputType = KProtocolInfo::T_FILESYSTEM; - else if ( tmp == "stream" ) - m_outputType = KProtocolInfo::T_STREAM; - else - m_outputType = KProtocolInfo::T_NONE; - - d->docPath = config.readPathEntry( "DocPath" ); - d->protClass = config.readEntry( "Class" ).lower(); - if (d->protClass[0] != ':') - d->protClass.prepend(':'); - - TQStringList extraNames = config.readListEntry( "ExtraNames" ); - TQStringList extraTypes = config.readListEntry( "ExtraTypes" ); - TQStringList::Iterator it = extraNames.begin(); - TQStringList::Iterator typeit = extraTypes.begin(); - for( ; it != extraNames.end() && typeit != extraTypes.end(); ++it, ++typeit ) { - d->extraFields.append( ExtraField( *it, *typeit ) ); - } - - d->showPreviews = config.readBoolEntry( "ShowPreviews", d->protClass == ":local" ); - - tmp = config.readEntry( "URIMode", TQString::null ).lower(); - if (tmp == "rawuri") - d->uriMode = KURL::RawURI; - else if (tmp == "mailto") - d->uriMode = KURL::Mailto; - else if (tmp == "url") - d->uriMode = KURL::URL; - else - d->uriMode = KURL::Auto; - - d->capabilities = config.readListEntry( "Capabilities" ); - d->proxyProtocol = config.readEntry( "ProxiedBy" ); -} - -KProtocolInfo::KProtocolInfo( TQDataStream& _str, int offset) : - KSycocaEntry( _str, offset) -{ - d = new KProtocolInfoPrivate; - load( _str ); -} - -KProtocolInfo::~KProtocolInfo() -{ - delete d; -} - -void -KProtocolInfo::load( TQDataStream& _str) -{ - // You may add new fields at the end. Make sure to update the version - // number in ksycoca.h - TQ_INT32 i_inputType, i_outputType; - TQ_INT8 i_isSourceProtocol, i_isHelperProtocol, - i_supportsListing, i_supportsReading, - i_supportsWriting, i_supportsMakeDir, - i_supportsDeleting, i_supportsLinking, - i_supportsMoving, i_determineMimetypeFromExtension, - i_canCopyFromFile, i_canCopyToFile, i_showPreviews, - i_uriMode, i_canRenameFromFile, i_canRenameToFile, - i_canDeleteRecursive, i_fileNameUsedForCopying; - - _str >> m_name >> m_exec >> m_listing >> m_defaultMimetype - >> i_determineMimetypeFromExtension - >> m_icon - >> i_inputType >> i_outputType - >> i_isSourceProtocol >> i_isHelperProtocol - >> i_supportsListing >> i_supportsReading - >> i_supportsWriting >> i_supportsMakeDir - >> i_supportsDeleting >> i_supportsLinking - >> i_supportsMoving - >> i_canCopyFromFile >> i_canCopyToFile - >> m_config >> m_maxSlaves >> d->docPath >> d->protClass - >> d->extraFields >> i_showPreviews >> i_uriMode - >> d->capabilities >> d->proxyProtocol - >> i_canRenameFromFile >> i_canRenameToFile - >> i_canDeleteRecursive >> i_fileNameUsedForCopying; - - m_inputType = (Type) i_inputType; - m_outputType = (Type) i_outputType; - m_isSourceProtocol = (i_isSourceProtocol != 0); - m_isHelperProtocol = (i_isHelperProtocol != 0); - m_supportsListing = (i_supportsListing != 0); - m_supportsReading = (i_supportsReading != 0); - m_supportsWriting = (i_supportsWriting != 0); - m_supportsMakeDir = (i_supportsMakeDir != 0); - m_supportsDeleting = (i_supportsDeleting != 0); - m_supportsLinking = (i_supportsLinking != 0); - m_supportsMoving = (i_supportsMoving != 0); - m_canCopyFromFile = (i_canCopyFromFile != 0); - m_canCopyToFile = (i_canCopyToFile != 0); - d->canRenameFromFile = (i_canRenameFromFile != 0); - d->canRenameToFile = (i_canRenameToFile != 0); - d->canDeleteRecursive = (i_canDeleteRecursive != 0); - d->fileNameUsedForCopying = (i_fileNameUsedForCopying != 0); - m_determineMimetypeFromExtension = (i_determineMimetypeFromExtension != 0); - d->showPreviews = (i_showPreviews != 0); - d->uriMode = (KURL::URIMode) i_uriMode; -} - -void -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 - TQ_INT32 i_inputType, i_outputType; - TQ_INT8 i_isSourceProtocol, i_isHelperProtocol, - i_supportsListing, i_supportsReading, - i_supportsWriting, i_supportsMakeDir, - i_supportsDeleting, i_supportsLinking, - i_supportsMoving, i_determineMimetypeFromExtension, - i_canCopyFromFile, i_canCopyToFile, i_showPreviews, - i_uriMode, i_canRenameFromFile, i_canRenameToFile, - i_canDeleteRecursive, i_fileNameUsedForCopying; - - i_inputType = (TQ_INT32) m_inputType; - i_outputType = (TQ_INT32) m_outputType; - i_isSourceProtocol = m_isSourceProtocol ? 1 : 0; - i_isHelperProtocol = m_isHelperProtocol ? 1 : 0; - i_supportsListing = m_supportsListing ? 1 : 0; - i_supportsReading = m_supportsReading ? 1 : 0; - i_supportsWriting = m_supportsWriting ? 1 : 0; - i_supportsMakeDir = m_supportsMakeDir ? 1 : 0; - i_supportsDeleting = m_supportsDeleting ? 1 : 0; - i_supportsLinking = m_supportsLinking ? 1 : 0; - i_supportsMoving = m_supportsMoving ? 1 : 0; - i_canCopyFromFile = m_canCopyFromFile ? 1 : 0; - i_canCopyToFile = m_canCopyToFile ? 1 : 0; - i_canRenameFromFile = d->canRenameFromFile ? 1 : 0; - i_canRenameToFile = d->canRenameToFile ? 1 : 0; - i_canDeleteRecursive = d->canDeleteRecursive ? 1 : 0; - i_fileNameUsedForCopying = d->fileNameUsedForCopying ? 1 : 0; - i_determineMimetypeFromExtension = m_determineMimetypeFromExtension ? 1 : 0; - i_showPreviews = d->showPreviews ? 1 : 0; - i_uriMode = d->uriMode; - - _str << m_name << m_exec << m_listing << m_defaultMimetype - << i_determineMimetypeFromExtension - << m_icon - << i_inputType << i_outputType - << i_isSourceProtocol << i_isHelperProtocol - << i_supportsListing << i_supportsReading - << i_supportsWriting << i_supportsMakeDir - << i_supportsDeleting << i_supportsLinking - << i_supportsMoving - << i_canCopyFromFile << i_canCopyToFile - << m_config << m_maxSlaves << d->docPath << d->protClass - << d->extraFields << i_showPreviews << i_uriMode - << d->capabilities << d->proxyProtocol - << i_canRenameFromFile << i_canRenameToFile - << i_canDeleteRecursive << i_fileNameUsedForCopying; -} - - -// -// Static functions: -// - -TQStringList KProtocolInfo::protocols() -{ - return KProtocolInfoFactory::self()->protocols(); -} - -bool KProtocolInfo::isSourceProtocol( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_isSourceProtocol; -} - -bool KProtocolInfo::isFilterProtocol( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return !prot->m_isSourceProtocol; -} - -bool KProtocolInfo::isHelperProtocol( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_isHelperProtocol; -} - -bool KProtocolInfo::isKnownProtocol( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - return ( prot != 0); -} - -bool KProtocolInfo::supportsListing( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsListing; -} - -TQStringList KProtocolInfo::listing( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQStringList(); - - return prot->m_listing; -} - -bool KProtocolInfo::supportsReading( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsReading; -} - -bool KProtocolInfo::supportsWriting( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsWriting; -} - -bool KProtocolInfo::supportsMakeDir( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsMakeDir; -} - -bool KProtocolInfo::supportsDeleting( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsDeleting; -} - -bool KProtocolInfo::supportsLinking( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsLinking; -} - -bool KProtocolInfo::supportsMoving( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_supportsMoving; -} - -bool KProtocolInfo::canCopyFromFile( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_canCopyFromFile; -} - - -bool KProtocolInfo::canCopyToFile( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->m_canCopyToFile; -} - -TQString KProtocolInfo::icon( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::tqfromLatin1("unknown"); - - return prot->m_icon; -} - -TQString KProtocolInfo::config( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::null; - - return TQString("kio_%1rc").arg(prot->m_config); -} - -int KProtocolInfo::maxSlaves( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return 1; - - return prot->m_maxSlaves; -} - -TQString KProtocolInfo::defaultMimetype( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::null; - - return prot->m_defaultMimetype; -} - -bool KProtocolInfo::determineMimetypeFromExtension( const TQString &_protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol( _protocol ); - if ( !prot ) - return true; - - return prot->m_determineMimetypeFromExtension; -} - -TQString KProtocolInfo::exec( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::null; - - return prot->m_exec; -} - -KProtocolInfo::Type KProtocolInfo::inputType( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return T_NONE; - - return prot->m_inputType; -} - -KProtocolInfo::Type KProtocolInfo::outputType( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return T_NONE; - - return prot->m_outputType; -} - -KProtocolInfo::ExtraFieldList KProtocolInfo::extraFields( const KURL &url ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(url.protocol()); - if ( !prot ) - return ExtraFieldList(); - - return prot->d->extraFields; -} - -TQString KProtocolInfo::docPath( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::null; - - return prot->d->docPath; -} - -TQString KProtocolInfo::protocolClass( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::null; - - return prot->d->protClass; -} - -bool KProtocolInfo::showFilePreview( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return false; - - return prot->d->showPreviews; -} - -KURL::URIMode KProtocolInfo::uriParseMode( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return KURL::Auto; - - return prot->d->uriMode; -} - -TQStringList KProtocolInfo::capabilities( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQStringList(); - - return prot->d->capabilities; -} - -TQString KProtocolInfo::proxiedBy( const TQString& _protocol ) -{ - KProtocolInfo::Ptr prot = KProtocolInfoFactory::self()->findProtocol(_protocol); - if ( !prot ) - return TQString::null; - - return prot->d->proxyProtocol; -} - -bool KProtocolInfo::canRenameFromFile() const -{ - return d->canRenameFromFile; -} - -bool KProtocolInfo::canRenameToFile() const -{ - return d->canRenameToFile; -} - -bool KProtocolInfo::canDeleteRecursive() const -{ - return d->canDeleteRecursive; -} - -KProtocolInfo::FileNameUsedForCopying KProtocolInfo::fileNameUsedForCopying() const -{ - return d->fileNameUsedForCopying ? Name : FromURL; -} - -TQDataStream& operator>>( TQDataStream& s, KProtocolInfo::ExtraField& field ) { - s >> field.name; - s >> field.type; - return s; -} - -TQDataStream& operator<<( TQDataStream& s, const KProtocolInfo::ExtraField& field ) { - s << field.name; - s << field.type; - return s; -} - -// KURL based static functions are implemented in ../kio/kio/kprotocolinfo.cpp - -void KProtocolInfo::virtual_hook( int id, void* data ) -{ KSycocaEntry::virtual_hook( id, data ); } - diff --git a/kdecore/kprotocolinfofactory.cpp b/kdecore/kprotocolinfofactory.cpp deleted file mode 100644 index e47cbb881..000000000 --- a/kdecore/kprotocolinfofactory.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - Copyright (C) 2003 Waldo Bastian <bastian@kde.org> - - 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 <kstandarddirs.h> -#include <kglobal.h> -#include <kapplication.h> -#include <kdebug.h> -#include <ksycoca.h> -#include <ksycocadict.h> - -#include "kprotocolinfofactory.h" - - -KProtocolInfoFactory* KProtocolInfoFactory::_self = 0; - -KProtocolInfoFactory::KProtocolInfoFactory() : KSycocaFactory( KST_KProtocolInfoFactory ) -{ - _self = this; -} - -KProtocolInfoFactory::~KProtocolInfoFactory() -{ - _self = 0; -} - - -KProtocolInfo* -KProtocolInfoFactory::createEntry(int offset) -{ - KProtocolInfo *info = 0; - KSycocaType type; - TQDataStream *str = KSycoca::self()->findEntry(offset, type); - switch (type) - { - case KST_KProtocolInfo: - info = new KProtocolInfo(*str, offset); - break; - default: - return 0; - } - if (!info->isValid()) - { - delete info; - info = 0; - } - return info; -} - - -TQStringList KProtocolInfoFactory::protocols() -{ - TQStringList res; - - KSycocaEntry::List list = allEntries(); - for( KSycocaEntry::List::Iterator it = list.begin(); - it != list.end(); - ++it) - { - KSycocaEntry *entry = (*it).data(); - KProtocolInfo *info = static_cast<KProtocolInfo *>(entry); - - res.append( info->name() ); - } - - return res; -} - -KProtocolInfo * -KProtocolInfoFactory::findProtocol(const TQString &protocol) -{ - if (!m_sycocaDict) return 0; // Error! - - TQMap<TQString,KProtocolInfo::Ptr>::iterator it = m_cache.find(protocol); - if (it != m_cache.end()) - return (*it); - - int offset; - - offset = m_sycocaDict->find_string( protocol ); - - if (!offset) return 0; // Not found; - - KProtocolInfo *info = createEntry(offset); - - if (info && (info->name() != protocol)) - { - // No it wasn't... - delete info; - info = 0; // Not found - } - m_cache.insert(protocol,info); - return info; -} - -void KProtocolInfoFactory::virtual_hook( int id, void* data ) -{ KSycocaFactory::virtual_hook( id, data ); } - diff --git a/kdecore/kprotocolinfofactory.h b/kdecore/kprotocolinfofactory.h deleted file mode 100644 index f710e8ecc..000000000 --- a/kdecore/kprotocolinfofactory.h +++ /dev/null @@ -1,91 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Torben Weis <weis@kde.org> - Copyright (C) 2000,2003 Waldo Bastian <bastian@kde.org> - - - 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 __kprotocolinfofactory_h__ -#define __kprotocolinfofactory_h__ - -#include "../kio/kio/kprotocolinfo.h" - -#include <tqmap.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <kurl.h> -#include <ksycocafactory.h> - -class KProtocolInfoPrivate; - -/** - * KProtocolInfoFactory is a factory for getting - * KProtocolInfo. The factory is a singleton - * (only one instance can exist). - * - * @short Factory for KProtocolInfo - */ -class KDECORE_EXPORT KProtocolInfoFactory : public KSycocaFactory -{ - K_SYCOCAFACTORY( KST_KProtocolInfoFactory ) -public: - /** - * The instance of the KProtocolInfoFactory. - * @return the factory instance - */ - static KProtocolInfoFactory* self() - { if ( !_self) new KProtocolInfoFactory(); return _self; } - /** \internal */ - KProtocolInfoFactory(); - virtual ~KProtocolInfoFactory(); - - /* - * Returns protocol info for @p protocol. - * - * Does not take proxy settings into account. - * @param protocol the protocol to search for - * @return the pointer to the KProtocolInfo, or 0 if not found - */ - KProtocolInfo *findProtocol(const TQString &protocol); - - /** - * Returns list of all known protocols. - * @return a list of all protocols - */ - TQStringList protocols(); -protected: - - /** - * @internal Not used. - */ - virtual KSycocaEntry *createEntry(const TQString &, const char *) - { return 0; } - - /** - * @internal - */ - virtual KProtocolInfo *createEntry(int offset); - -protected: - static KProtocolInfoFactory *_self; - - TQMap<TQString,KProtocolInfo::Ptr> m_cache; -protected: - virtual void virtual_hook( int id, void* data ); -private: - class KProtocolInfoFactoryPrivate* d; -}; - -#endif diff --git a/kdecore/kpty.cpp b/kdecore/kpty.cpp deleted file mode 100644 index f6fc9d5cd..000000000 --- a/kdecore/kpty.cpp +++ /dev/null @@ -1,579 +0,0 @@ -/* - - This file is part of the KDE libraries - Copyright (C) 1997-2002 The Konsole Developers - Copyright (C) 2002 Waldo Bastian <bastian@kde.org> - Copyright (C) 2002-2003 Oswald Buddenhagen <ossi@kde.org> - - 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. -*/ - -#include <config.h> - -#include "kpty.h" -#include "kprocess.h" - -#ifdef __sgi -#define __svr4__ -#endif - -#ifdef __osf__ -#define _OSF_SOURCE -#include <float.h> -#endif - -#ifdef _AIX -#define _ALL_SOURCE -#endif - -// __USE_XOPEN isn't defined by default in ICC -// (needed for ptsname(), grantpt() and unlockpt()) -#ifdef __INTEL_COMPILER -# ifndef __USE_XOPEN -# define __USE_XOPEN -# endif -#endif - -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/stat.h> -#include <sys/param.h> - -#ifdef HAVE_SYS_STROPTS_H -# include <sys/stropts.h> // Defines I_PUSH -# define _NEW_TTY_CTRL -#endif - -#include <errno.h> -#include <fcntl.h> -#include <time.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <grp.h> - -#ifdef HAVE_LIBUTIL_H -# include <libutil.h> -# define USE_LOGIN -#elif defined(HAVE_UTIL_H) -# include <util.h> -# define USE_LOGIN -#endif - -#ifdef USE_LOGIN -# include <utmp.h> -#endif - -#ifdef HAVE_TERMIOS_H -/* for HP-UX (some versions) the extern C is needed, and for other - platforms it doesn't hurt */ -extern "C" { -# include <termios.h> -} -#endif - -#if !defined(__osf__) -# ifdef HAVE_TERMIO_H -/* needed at least on AIX */ -# include <termio.h> -# endif -#endif - -#if defined(HAVE_TCGETATTR) -# define _tcgetattr(fd, ttmode) tcgetattr(fd, ttmode) -#elif defined(TIOCGETA) -# define _tcgetattr(fd, ttmode) ioctl(fd, TIOCGETA, (char *)ttmode) -#elif defined(TCGETS) -# define _tcgetattr(fd, ttmode) ioctl(fd, TCGETS, (char *)ttmode) -#else -# error -#endif - -#if defined(HAVE_TCSETATTR) && defined(TCSANOW) -# define _tcsetattr(fd, ttmode) tcsetattr(fd, TCSANOW, ttmode) -#elif defined(TIOCSETA) -# define _tcsetattr(fd, ttmode) ioctl(fd, TIOCSETA, (char *)ttmode) -#elif defined(TCSETS) -# define _tcsetattr(fd, ttmode) ioctl(fd, TCSETS, (char *)ttmode) -#else -# error -#endif - -#if defined (_HPUX_SOURCE) -# define _TERMIOS_INCLUDED -# include <bsdtty.h> -#endif - -#if defined(HAVE_PTY_H) -# include <pty.h> -#endif - -#include <kdebug.h> -#include <kstandarddirs.h> // locate - -#ifndef CINTR -#define CINTR 0x03 -#endif -#ifndef CQUIT -#define CQUIT 0x1c -#endif -#ifndef CERASE -#define CERASE 0x7f -#endif - -#define TTY_GROUP "tty" - -/////////////////////// -// private functions // -/////////////////////// - -#ifdef HAVE_UTEMPTER -class KProcess_Utmp : public KProcess -{ -public: - int commSetupDoneC() - { - dup2(cmdFd, 0); - dup2(cmdFd, 1); - dup2(cmdFd, 3); - return 1; - } - int cmdFd; -}; -#endif - -#define BASE_CHOWN "kgrantpty" - - - -////////////////// -// private data // -////////////////// - -struct KPtyPrivate { - KPtyPrivate() : - xonXoff(false), - utf8(false), - masterFd(-1), slaveFd(-1) - { - memset(&winSize, 0, sizeof(winSize)); - winSize.ws_row = 24; - winSize.ws_col = 80; - } - - bool xonXoff : 1; - bool utf8 : 1; - int masterFd; - int slaveFd; - struct winsize winSize; - - TQCString ttyName; -}; - -///////////////////////////// -// public member functions // -///////////////////////////// - -KPty::KPty() -{ - d = new KPtyPrivate; -} - -KPty::~KPty() -{ - close(); - delete d; -} - -bool KPty::setPty(int pty_master) -{ - kdWarning(175) - << "setPty()" << endl; - // a pty is already open - if(d->masterFd >= 0) { - kdWarning(175) - << "d->masterFd >= 0" << endl; - return false; - } - d->masterFd = pty_master; - return _attachPty(pty_master); -} - -bool KPty::_attachPty(int pty_master) -{ - TQCString ptyName; - - kdWarning(175) - << "_attachPty() " << pty_master << endl; -#if defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT) - char *ptsn = ptsname(d->masterFd); - if (ptsn) { - grantpt(d->masterFd); - d->ttyName = ptsn; - } else { - ::close(d->masterFd); - d->masterFd = -1; - } -#endif - - struct stat st; - if (stat(d->ttyName.data(), &st)) - return false; // this just cannot happen ... *cough* Yeah right, I just - // had it happen when pty #349 was allocated. I guess - // there was some sort of leak? I only had a few open. - if (((st.st_uid != getuid()) || - (st.st_mode & (S_IRGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH))) && - !chownpty(true)) - { - kdWarning(175) - << "chownpty failed for device " << ptyName << "::" << d->ttyName - << "\nThis means the communication can be eavesdropped." << endl; - } - -#ifdef BSD - revoke(d->ttyName.data()); -#endif - -#ifdef HAVE_UNLOCKPT - unlockpt(d->masterFd); -#endif - - d->slaveFd = ::open(d->ttyName.data(), O_RDWR | O_NOCTTY); - if (d->slaveFd < 0) - { - kdWarning(175) << "Can't open slave pseudo teletype" << endl; - ::close(d->masterFd); - d->masterFd = -1; - return false; - } - -#if (defined(__svr4__) || defined(__sgi__)) - // Solaris - ioctl(d->slaveFd, I_PUSH, "ptem"); - ioctl(d->slaveFd, I_PUSH, "ldterm"); -#endif - - // set xon/xoff & control keystrokes - // without the '::' some version of HP-UX thinks, this declares - // the struct in this class, in this method, and fails to find - // the correct tc[gs]etattr - struct ::termios ttmode; - - _tcgetattr(d->slaveFd, &ttmode); - - if (!d->xonXoff) - ttmode.c_iflag &= ~(IXOFF | IXON); - else - ttmode.c_iflag |= (IXOFF | IXON); - -#ifdef IUTF8 - if (!d->utf8) - ttmode.c_iflag &= ~IUTF8; - else - ttmode.c_iflag |= IUTF8; -#endif - - ttmode.c_cc[VINTR] = CINTR; - ttmode.c_cc[VQUIT] = CQUIT; - ttmode.c_cc[VERASE] = CERASE; - - _tcsetattr(d->slaveFd, &ttmode); - - // set screen size - ioctl(d->slaveFd, TIOCSWINSZ, (char *)&d->winSize); - - fcntl(d->masterFd, F_SETFD, FD_CLOEXEC); - fcntl(d->slaveFd, F_SETFD, FD_CLOEXEC); - - return true; -} - -bool KPty::open() -{ - if (d->masterFd >= 0) - return true; - - TQCString ptyName; - - // Find a master pty that we can open //////////////////////////////// - - // Because not all the pty animals are created equal, they want to - // be opened by several different methods. - - // We try, as we know them, one by one. - -#if defined(HAVE_PTSNAME) && defined(HAVE_GRANTPT) -#ifdef _AIX - d->masterFd = ::open("/dev/ptc",O_RDWR); -#else - d->masterFd = ::open("/dev/ptmx",O_RDWR); -#endif - if (d->masterFd >= 0) - { - char *ptsn = ptsname(d->masterFd); - if (ptsn) { - grantpt(d->masterFd); - d->ttyName = ptsn; - goto gotpty; - } else { - ::close(d->masterFd); - d->masterFd = -1; - } - } -#endif - - // Linux device names, FIXME: Trouble on other systems? - for (const char* s3 = "pqrstuvwxyzabcdefghijklmno"; *s3; s3++) - { - for (const char* s4 = "0123456789abcdefghijklmnopqrstuvwxyz"; *s4; s4++) - { - ptyName.sprintf("/dev/pty%c%c", *s3, *s4); - d->ttyName.sprintf("/dev/tty%c%c", *s3, *s4); - - d->masterFd = ::open(ptyName.data(), O_RDWR); - if (d->masterFd >= 0) - { -#ifdef __sun - /* Need to check the process group of the pty. - * If it exists, then the slave pty is in use, - * and we need to get another one. - */ - int pgrp_rtn; - if (ioctl(d->masterFd, TIOCGPGRP, &pgrp_rtn) == 0 || errno != EIO) { - ::close(d->masterFd); - d->masterFd = -1; - continue; - } -#endif /* sun */ - if (!access(d->ttyName.data(),R_OK|W_OK)) // checks availability based on permission bits - { - if (!geteuid()) - { - struct group* p = getgrnam(TTY_GROUP); - if (!p) - p = getgrnam("wheel"); - gid_t gid = p ? p->gr_gid : getgid (); - - chown(d->ttyName.data(), getuid(), gid); - chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IWGRP); - } - goto gotpty; - } - ::close(d->masterFd); - d->masterFd = -1; - } - } - } - - kdWarning(175) << "Can't open a pseudo teletype" << endl; - return false; - - gotpty: - return _attachPty(d->masterFd); - - return true; -} - -void KPty::close() -{ - if (d->masterFd < 0) - return; - // don't bother resetting unix98 pty, it will go away after closing master anyway. - if (memcmp(d->ttyName.data(), "/dev/pts/", 9)) { - if (!geteuid()) { - struct stat st; - if (!stat(d->ttyName.data(), &st)) { - chown(d->ttyName.data(), 0, st.st_gid == getgid() ? 0 : -1); - chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); - } - } else { - fcntl(d->masterFd, F_SETFD, 0); - chownpty(false); - } - } - ::close(d->slaveFd); - ::close(d->masterFd); - d->masterFd = d->slaveFd = -1; -} - -void KPty::setCTty() -{ - // Setup job control ////////////////////////////////// - - // Become session leader, process group leader, - // and get rid of the old controlling terminal. - setsid(); - - // make our slave pty the new controlling terminal. -#ifdef TIOCSCTTY - ioctl(d->slaveFd, TIOCSCTTY, 0); -#else - // SVR4 hack: the first tty opened after setsid() becomes controlling tty - ::close(::open(d->ttyName, O_WRONLY, 0)); -#endif - - // make our new process group the foreground group on the pty - int pgrp = getpid(); -#if defined(_POSIX_VERSION) || defined(__svr4__) - tcsetpgrp (d->slaveFd, pgrp); -#elif defined(TIOCSPGRP) - ioctl(d->slaveFd, TIOCSPGRP, (char *)&pgrp); -#endif -} - -void KPty::login(const char *user, const char *remotehost) -{ -#ifdef HAVE_UTEMPTER - KProcess_Utmp utmp; - utmp.cmdFd = d->masterFd; - utmp << "/usr/lib/utempter/utempter" << "add"; - if (remotehost) - utmp << remotehost; - utmp.start(KProcess::Block); - Q_UNUSED(user); - Q_UNUSED(remotehost); -#elif defined(USE_LOGIN) - const char *str_ptr; - struct utmp l_struct; - memset(&l_struct, 0, sizeof(struct utmp)); - // note: strncpy without terminators _is_ correct here. man 4 utmp - - if (user) - strncpy(l_struct.ut_name, user, UT_NAMESIZE); - - if (remotehost) - strncpy(l_struct.ut_host, remotehost, UT_HOSTSIZE); - -# ifndef __GLIBC__ - str_ptr = d->ttyName.data(); - if (!memcmp(str_ptr, "/dev/", 5)) - str_ptr += 5; - strncpy(l_struct.ut_line, str_ptr, UT_LINESIZE); -# endif - - // Handle 64-bit time_t properly, where it may be larger - // than the integral type of ut_time. - { - time_t ut_time_temp; - time(&ut_time_temp); - l_struct.ut_time=ut_time_temp; - } - - ::login(&l_struct); -#else - Q_UNUSED(user); - Q_UNUSED(remotehost); -#endif -} - -void KPty::logout() -{ -#ifdef HAVE_UTEMPTER - KProcess_Utmp utmp; - utmp.cmdFd = d->masterFd; - utmp << "/usr/lib/utempter/utempter" << "del"; - utmp.start(KProcess::Block); -#elif defined(USE_LOGIN) - const char *str_ptr = d->ttyName.data(); - if (!memcmp(str_ptr, "/dev/", 5)) - str_ptr += 5; -# ifdef __GLIBC__ - else { - const char *sl_ptr = strrchr(str_ptr, '/'); - if (sl_ptr) - str_ptr = sl_ptr + 1; - } -# endif - ::logout(str_ptr); -#endif -} - -void KPty::setWinSize(int lines, int columns) -{ - d->winSize.ws_row = (unsigned short)lines; - d->winSize.ws_col = (unsigned short)columns; - if (d->masterFd >= 0) - ioctl( d->masterFd, TIOCSWINSZ, (char *)&d->winSize ); -} - -void KPty::setXonXoff(bool useXonXoff) -{ - d->xonXoff = useXonXoff; - if (d->masterFd >= 0) { - // without the '::' some version of HP-UX thinks, this declares - // the struct in this class, in this method, and fails to find - // the correct tc[gs]etattr - struct ::termios ttmode; - - _tcgetattr(d->masterFd, &ttmode); - - if (!useXonXoff) - ttmode.c_iflag &= ~(IXOFF | IXON); - else - ttmode.c_iflag |= (IXOFF | IXON); - - _tcsetattr(d->masterFd, &ttmode); - } -} - -void KPty::setUtf8Mode(bool useUtf8) -{ - d->utf8 = useUtf8; -#ifdef IUTF8 - if (d->masterFd >= 0) { - // without the '::' some version of HP-UX thinks, this declares - // the struct in this class, in this method, and fails to find - // the correct tc[gs]etattr - struct ::termios ttmode; - - _tcgetattr(d->masterFd, &ttmode); - - if (!useUtf8) - ttmode.c_iflag &= ~IUTF8; - else - ttmode.c_iflag |= IUTF8; - - _tcsetattr(d->masterFd, &ttmode); - } -#endif -} - -const char *KPty::ttyName() const -{ - return d->ttyName.data(); -} - -int KPty::masterFd() const -{ - return d->masterFd; -} - -int KPty::slaveFd() const -{ - return d->slaveFd; -} - -// private -bool KPty::chownpty(bool grant) -{ - KProcess proc; - proc << locate("exe", BASE_CHOWN) << (grant?"--grant":"--revoke") << TQString::number(d->masterFd); - return proc.start(KProcess::Block) && proc.normalExit() && !proc.exitStatus(); -} - diff --git a/kdecore/kpty.h b/kdecore/kpty.h deleted file mode 100644 index 5b9a94112..000000000 --- a/kdecore/kpty.h +++ /dev/null @@ -1,159 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (C) 1997-2002 The Konsole Developers - Copyright (C) 2002 Waldo Bastian <bastian@kde.org> - Copyright (C) 2002-2003 Oswald Buddenhagen <ossi@kde.org> - - 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 __kpty_h__ -#define __kpty_h__ - -#include <tqglobal.h> -#include <kdelibs_export.h> - -#ifdef Q_OS_UNIX - -struct KPtyPrivate; - -/** - * Provides a high level representation of a pseudo tty pair, including - * utmp support. - * ... - * - * @since 3.2 - **/ -class KDECORE_EXPORT KPty { - -public: - - /** - * Constructor - */ - KPty(); - - /** - * Destructor: - * - * If the pty is still open, it will be closed. Note, however, that - * an utmp registration is @em not undone. - */ - ~KPty(); - - /** - * Create a pty master/slave pair. - * - * @return true if a pty pair was successfully opened - */ - bool open(); - - /** - * Attach a existing pty master - * - * @return true if the pty was successfully added - */ - bool setPty(int pty_master); - - /** - * Close the pty master/slave pair. - */ - void close(); - - /** - * Creates a new session and process group and makes this pty the - * controlling tty. - */ - void setCTty(); - - /** - * Creates an utmp entry for the tty. - * This function must be called after calling setCTty and - * making this pty the stdin. - * @param user the user to be logged on - * @param remotehost the host from which the login is coming. This is - * @em not the local host. For remote logins it should be the hostname - * of the client. For local logins from inside an X session it should - * be the name of the X display. Otherwise it should be empty. - */ - void login(const char *user = 0, const char *remotehost = 0); - - /** - * Removes the utmp entry for this tty. - */ - void logout(); - - /** - * Change the logical (screen) size of the pty. - * The default is 24 lines by 80 columns. - * - * @param lines the number of rows - * @param columns the number of columns - */ - void setWinSize(int lines, int columns); - - /** - * Set whether the pty should honor Xon/Xoff flow control. - * - * Xon/Xoff flow control is off by default. - * - * @param useXonXoff true if Xon/Xoff flow control should be used. - */ - void setXonXoff(bool useXonXoff); - - /** - * Set the pty in utf8 mode on systems that support it. - * - * See the man page of "stty iutf8" for more info. - * - * @since 3.4 - */ - void setUtf8Mode(bool useUtf8); - - - /** - * @return the name of the slave pty device. - * - * This function should be called only while the pty is open. - */ - const char *ttyName() const; - - /** - * @return the file descriptor of the master pty - * - * This function should be called only while the pty is open. - */ - int masterFd() const; - - /** - * @return the file descriptor of the slave pty - * - * This function should be called only while the pty is open. - */ - int slaveFd() const; - -protected: - bool _attachPty(int pty_master); - -private: - bool chownpty(bool grant); - - KPtyPrivate *d; -}; - -#endif //Q_OS_UNIX -#endif - diff --git a/kdecore/kqiodevicegzip_p.cpp b/kdecore/kqiodevicegzip_p.cpp deleted file mode 100644 index 0dcabed74..000000000 --- a/kdecore/kqiodevicegzip_p.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001,2005 Nicolas GOUTTE <nicog@snafu.de> - - 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. -*/ - -// TODO: more error report and control - -#include <tqstring.h> -#include "kqiodevicegzip_p.h" - -KQIODeviceGZip::KQIODeviceGZip(const TQString& filename) -{ - m_gzfile=0; - m_ungetchar=-1; - m_filename=filename; - setFlags(IO_Sequential); // We have no direct access, so it is sequential! - // NOTE: "sequential" also means that you cannot use size() -} - -KQIODeviceGZip::~KQIODeviceGZip(void) -{ - if (m_gzfile) - close(); -} - -bool KQIODeviceGZip::open(TQ_OpenMode mode) -{ - if (m_gzfile) - close(); // One file is already open, so close it first. - if (m_filename.isEmpty()) - return false; // No file name, cannot open! - - if (IO_ReadOnly==mode) - { - m_gzfile=gzopen(TQFile::encodeName(m_filename),"rb"); - } - else if (IO_WriteOnly==mode) - { - m_gzfile=gzopen(TQFile::encodeName(m_filename),"wb9"); // Always set best compression - } - else - { - // We only support read only or write only, nothing else! - return false; - } - return (m_gzfile!=0); -} - -void KQIODeviceGZip::close(void) -{ - if (m_gzfile) - { - gzclose(m_gzfile); - m_gzfile=0; - } -} - -void KQIODeviceGZip::flush(void) -{ - // Always try to flush, do not return any error! - if (m_gzfile) - { - gzflush(m_gzfile,Z_SYNC_FLUSH); - } -} - -#ifdef USE_QT4 -qint64 KQIODeviceGZip::size(void) const -#else // USE_QT4 -TQIODevice::Offset KQIODeviceGZip::size(void) const -#endif // USE_QT4 -{ - return 0; // You cannot determine size! -} - -TQIODevice::Offset KQIODeviceGZip::at() const -{ - if (!m_gzfile) - return 0; - return gztell(m_gzfile); -} - -bool KQIODeviceGZip::at(TQIODevice::Offset pos) -{ - if (!m_gzfile) - return false; - return (gzseek(m_gzfile,pos,SEEK_SET)>=0); -} - -bool KQIODeviceGZip::atEnd() const -{ - if (!m_gzfile) - return true; - return gzeof(m_gzfile); -} - -bool KQIODeviceGZip::reset(void) -{ - if (!m_gzfile) - return false; //Say we arew at end of file - return (gzrewind(m_gzfile)>=0); -} - -TQT_TQIO_LONG KQIODeviceGZip::tqreadBlock( char *data, TQT_TQIO_ULONG maxlen ) -{ - TQ_LONG result=0; - if (m_gzfile) - { - result=gzread(m_gzfile,data,maxlen); - if (result<0) result=0; - } - return result; -} - -TQT_TQIO_LONG KQIODeviceGZip::tqwriteBlock( const char *data, TQT_TQIO_ULONG len ) -{ - TQ_ULONG result=0; - if (m_gzfile) - { - result=gzwrite(m_gzfile,(char*)data,len); - } - return result; -} - -int KQIODeviceGZip::getch() -{ - if (m_ungetchar>0) - { - const int ch=m_ungetchar; - m_ungetchar=-1; - return ch; - } - if (!m_gzfile) - return -1; - return gzgetc(m_gzfile); -} - -int KQIODeviceGZip::putch( int ch) -{ - if (!m_gzfile) - return -1; - return gzputc(m_gzfile,ch); -} - -int KQIODeviceGZip::ungetch(int ch) -{ - m_ungetchar=ch; - return ch; -} diff --git a/kdecore/kqiodevicegzip_p.h b/kdecore/kqiodevicegzip_p.h deleted file mode 100644 index 0581602c1..000000000 --- a/kdecore/kqiodevicegzip_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2001,2005 Nicolas GOUTTE <nicog@snafu.de> - - 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 KDELIBS_KQIODEVICEGZIP_H -#define KDELIBS_KQIODEVICEGZIP_H - -#include <tqiodevice.h> -#include <tqstring.h> -#include <tqfile.h> - -#include <zlib.h> - - -/** - * \brief TQIODevice class for a gzipped file - * \internal This class is internal to KDE. - * The class KFilterDev should be used instead. - */ -class KQIODeviceGZip : public TQIODevice -{ -public: - KQIODeviceGZip(const TQString& filename); - ~KQIODeviceGZip(void); - - bool open(TQ_OpenMode mode); - void close(void); - void flush(void); - -#ifdef USE_QT4 - qint64 size(void) const; -#else // USE_QT4 - Offset size(void) const; -#endif // USE_QT4 - Offset at(void) const; - bool at(Offset pos); - bool atEnd(void) const; - bool reset (void); - - TQT_TQIO_LONG tqreadBlock( char *data, TQT_TQIO_ULONG maxlen ); - TQT_TQIO_LONG tqwriteBlock( const char *data, TQT_TQIO_ULONG len ); - - int getch(void); - int putch(int ch); - int ungetch(int ch); -private: - gzFile m_gzfile; - int m_ungetchar; - TQString m_filename; -}; - - -#endif // KDELIBS_KQIODEVICEGZIP_H diff --git a/kdecore/krandomsequence.cpp b/kdecore/krandomsequence.cpp deleted file mode 100644 index 04240733f..000000000 --- a/kdecore/krandomsequence.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Sean Harmer <sh@astro.keele.ac.uk> - - 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. -*/ - -#include <tqptrlist.h> - -#include "krandomsequence.h" -#include "kapplication.h" - -const int KRandomSequence::m_nShuffleTableSize = 32; - -////////////////////////////////////////////////////////////////////////////// -// Construction / Destruction -////////////////////////////////////////////////////////////////////////////// - -KRandomSequence::KRandomSequence( long lngSeed1 ) -{ - // Seed the generator - setSeed( lngSeed1 ); - - - // Set the size of the shuffle table - m_ShuffleArray = new long [m_nShuffleTableSize]; -} - -KRandomSequence::~KRandomSequence() -{ - delete [] m_ShuffleArray; -} - -KRandomSequence::KRandomSequence(const KRandomSequence &a) -{ - // Set the size of the shuffle table - m_ShuffleArray = new long [m_nShuffleTableSize]; - *this = a; -} - -KRandomSequence & -KRandomSequence::operator=(const KRandomSequence &a) -{ - m_lngSeed1 = a.m_lngSeed1; - m_lngSeed2 = a.m_lngSeed2; - m_lngShufflePos = a.m_lngShufflePos; - memcpy(m_ShuffleArray, a.m_ShuffleArray, sizeof(long)*m_nShuffleTableSize); - return *this; -} - - -////////////////////////////////////////////////////////////////////////////// -// Member Functions -////////////////////////////////////////////////////////////////////////////// - -void KRandomSequence::setSeed( long lngSeed1 ) -{ - // Convert the positive seed number to a negative one so that the Draw() - // function can intialise itself the first time it is called. We just have - // to make sure that the seed used != 0 as zero perpetuates itself in a - // sequence of random numbers. - if ( lngSeed1 < 0 ) - { - m_lngSeed1 = -1; - } - else if (lngSeed1 == 0) - { - m_lngSeed1 = -((KApplication::random() & ~1)+1); - } - else - { - m_lngSeed1 = -lngSeed1; - } -} - -static const long sMod1 = 2147483563; -static const long sMod2 = 2147483399; - -void KRandomSequence::Draw() -{ - static const long sMM1 = sMod1 - 1; - static const long sA1 = 40014; - static const long sA2 = 40692; - static const long sQ1 = 53668; - static const long sQ2 = 52774; - static const long sR1 = 12211; - static const long sR2 = 3791; - static const long sDiv = 1 + sMM1 / m_nShuffleTableSize; - - // Long period (>2 * 10^18) random number generator of L'Ecuyer with - // Bayes-Durham shuffle and added safeguards. Returns a uniform random - // deviate between 0.0 and 1.0 (exclusive of the endpoint values). Call - // with a negative number to initialize; thereafter, do not alter idum - // between successive deviates in a sequence. RNMX should approximate - // the largest floating point value that is less than 1. - - int j; // Index for the shuffle table - long k; - - // Initialise - if ( m_lngSeed1 <= 0 ) - { - m_lngSeed2 = m_lngSeed1; - - // Load the shuffle table after 8 warm-ups - for ( j = m_nShuffleTableSize + 7; j >= 0; j-- ) - { - k = m_lngSeed1 / sQ1; - m_lngSeed1 = sA1 * ( m_lngSeed1 - k*sQ1) - k*sR1; - if ( m_lngSeed1 < 0 ) - { - m_lngSeed1 += sMod1; - } - - if ( j < m_nShuffleTableSize ) - { - m_ShuffleArray[j] = m_lngSeed1; - } - } - - m_lngShufflePos = m_ShuffleArray[0]; - } - - // Start here when not initializing - - // Compute m_lngSeed1 = ( lngIA1*m_lngSeed1 ) % lngIM1 without overflows - // by Schrage's method - k = m_lngSeed1 / sQ1; - m_lngSeed1 = sA1 * ( m_lngSeed1 - k*sQ1 ) - k*sR1; - if ( m_lngSeed1 < 0 ) - { - m_lngSeed1 += sMod1; - } - - // Compute m_lngSeed2 = ( lngIA2*m_lngSeed2 ) % lngIM2 without overflows - // by Schrage's method - k = m_lngSeed2 / sQ2; - m_lngSeed2 = sA2 * ( m_lngSeed2 - k*sQ2 ) - k*sR2; - if ( m_lngSeed2 < 0 ) - { - m_lngSeed2 += sMod2; - } - - j = m_lngShufflePos / sDiv; - m_lngShufflePos = m_ShuffleArray[j] - m_lngSeed2; - m_ShuffleArray[j] = m_lngSeed1; - - if ( m_lngShufflePos < 1 ) - { - m_lngShufflePos += sMM1; - } -} - -void -KRandomSequence::modulate(int i) -{ - m_lngSeed2 -= i; - if ( m_lngSeed2 < 0 ) - { - m_lngShufflePos += sMod2; - } - Draw(); - m_lngSeed1 -= i; - if ( m_lngSeed1 < 0 ) - { - m_lngSeed1 += sMod1; - } - Draw(); -} - -double -KRandomSequence::getDouble() -{ - static const double finalAmp = 1.0 / double( sMod1 ); - static const double epsilon = 1.2E-7; - static const double maxRand = 1.0 - epsilon; - double temp; - Draw(); - // Return a value that is not one of the endpoints - if ( ( temp = finalAmp * m_lngShufflePos ) > maxRand ) - { - // We don't want to return 1.0 - return maxRand; - } - else - { - return temp; - } -} - -unsigned long -KRandomSequence::getLong(unsigned long max) -{ - Draw(); - - return max ? (((unsigned long) m_lngShufflePos) % max) : 0; -} - -bool -KRandomSequence::getBool() -{ - Draw(); - - return (((unsigned long) m_lngShufflePos) & 1); -} - -class KRandomSequenceList : public TQGList -{ - friend class KRandomSequence; -public: - KRandomSequenceList() : TQGList() { } - virtual void deleteItem( TQPtrCollection::Item ) {} -}; - -void -KRandomSequence::randomize(TQGList *_list) -{ - KRandomSequenceList *list = (KRandomSequenceList *)_list; - KRandomSequenceList l; - while(list->count()) - l.append(list->takeFirst()); - - list->append(l.takeFirst()); // Start with 1 - while(l.count()) - list->insertAt(getLong(list->count()+1), l.takeFirst()); -} diff --git a/kdecore/krandomsequence.h b/kdecore/krandomsequence.h deleted file mode 100644 index 383eee9ce..000000000 --- a/kdecore/krandomsequence.h +++ /dev/null @@ -1,145 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Sean Harmer <sh@astro.keele.ac.uk> - - 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 K_RANDOM_SEQUENCE_H -#define K_RANDOM_SEQUENCE_H - -#include "kdelibs_export.h" - -class KRandomSequencePrivate; -class TQGList; -/** - * A class to create a pseudo-random sequence - * - * Given a seed number, this class will produce a sequence of - * pseudo-random numbers. This would typically be used in - * applications like games. - * - * In general, you should instantiate a KRandomSequence object and - * pass along your seed number in the constructor. From then on, - * simply call getDouble() or getLong() to obtain the next - * number in the sequence. - * - * @author Sean Harmer <sh@astro.keele.ac.uk> - */ -class KDECORE_EXPORT KRandomSequence -{ -public: - /** - * Creates a pseudo-random sequence based on the seed lngSeed. - * - * A Pseudo-random sequence is different for each seed but can be - * reproduced by starting the sequence with the same seed. - * - * If you need a single value which needs to be unpredictable, - * you need to use kapp->random() instead. - * - * @param lngSeed Seed to initialize the sequence with. - * If lngSeed is 0, the sequence is initialized with a value from - * KApplication::random(). - */ - KRandomSequence( long lngSeed = 0 ); - - /** - * Standard destructor - */ - virtual ~KRandomSequence(); - - /** - * Copy constructor - */ - KRandomSequence(const KRandomSequence &a); - - /** - * Assignment - */ - KRandomSequence &operator=(const KRandomSequence &a); - - /** - * Restart the sequence based on lngSeed. - * @param lngSeed Seed to initialize the sequence with. - * If lngSeed is 0, the sequence is initialized with a value from - * KApplication::random(). - */ - void setSeed( long lngSeed = 0 ); - - /** - * Get the next number from the pseudo-random sequence. - * - * @return a pseudo-random double value between [0,1[ - */ - double getDouble(); - - /** - * Get the next number from the pseudo-random sequence. - * - * @return a pseudo-random integer value between [0, max[ - * with 0 <= max < 1.000.000 - */ - unsigned long getLong(unsigned long max); - - /** - * Get a boolean from the pseudo-random sequence. - * - * @return a boolean which is either true or false - */ - bool getBool(); - - /** - * Put a list in random order. - * - * @param list the list whose order will be modified - */ - void randomize(TQGList *list); - - /** - * Modulate the random sequence. - * - * If S(i) is the sequence of numbers that will follow - * given the current state after calling modulate(i), - * then S(i) != S(j) for i != j and - * S(i) == S(j) for i == j. - * - * This can be useful in game situation where "undo" restores - * the state of the random sequence. If the game modulates the - * random sequence with the move chosen by the player, the - * random sequence will be identical whenever the player "redo"-s - * his or hers original move, but different when the player - * chooses another move. - * - * With this scenario "undo" can no longer be used to repeat a - * certain move over and over again until the computer reacts - * with a favorable response or to predict the response for a - * certain move based on the response to another move. - * @param i the sequence identified - */ - void modulate(int i); - -private: - void Draw(); // Generate the random number - long m_lngSeed1; - long m_lngSeed2; - long m_lngShufflePos; - - static const int m_nShuffleTableSize; - long *m_ShuffleArray; - - KRandomSequencePrivate *d; -}; - -#endif - diff --git a/kdecore/kregexp.cpp b/kdecore/kregexp.cpp deleted file mode 100644 index 22db51dfa..000000000 --- a/kdecore/kregexp.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Torben Weis <weis@kde.org> - - 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 <sys/types.h> - -#include <string.h> -#include <assert.h> -#include <stdlib.h> - -#include "kregexp.h" -#include "kregpriv.h" -#include "kdebug.h" - -KRegExpPrivate::KRegExpPrivate() -{ - m_bInit = false; - - for ( int i = 0; i < 10; i++ ) - m_strMatches[i] = 0L; -} - -KRegExpPrivate::KRegExpPrivate( const char *_pattern, const char *_mode ) -{ - m_bInit = false; - - for ( int i = 0; i < 10; i++ ) - m_strMatches[i] = 0L; - - compile( _pattern, _mode ); -} - -KRegExpPrivate::~KRegExpPrivate() -{ - for ( int i = 0; i < 10; i++ ) - if ( m_strMatches[i] ) - free( m_strMatches[i] ); - - if ( m_bInit ) - regfree( &m_pattern ); -} - -bool KRegExpPrivate::compile( const char *_pattern, const char *_mode ) -{ - if ( m_bInit ) - regfree( &m_pattern ); - - int res = regcomp( &m_pattern, _pattern, ( strchr( _mode, 'i' ) != 0L ? REG_ICASE : 0 ) | REG_EXTENDED ); - if ( res == 0 ) - m_bInit = true; - - return ( res == 0 ); -} - -bool KRegExpPrivate::match( const char *_string ) -{ - if ( !m_bInit ) - { - kdDebug(128) << "You must compile a pattern before you can try to match it" << endl; - assert( 0 ); - } - - for ( int i = 0; i < 10; i++ ) - { - m_matches[i].rm_so = -1; - m_matches[i].rm_eo = -1; - if ( m_strMatches[i] ) - { - free( m_strMatches[i] ); - m_strMatches[i] = 0L; - } - } - - int res = regexec( &m_pattern, _string, 10, m_matches, 0 ); - if ( res != 0 ) - return false; - - int slen = strlen( _string ); - - for ( int j = 0; j < 10; j++ ) - { - if ( m_matches[j].rm_so >= 0 && m_matches[j].rm_eo >= 0 && - m_matches[j].rm_so <= slen && m_matches[j].rm_eo <= slen && - m_matches[j].rm_so <= m_matches[j].rm_eo ) - { - int len = m_matches[j].rm_eo - m_matches[j].rm_so; - m_strMatches[j] = ( char* )malloc( len + 1 ); - memcpy( m_strMatches[j], _string + m_matches[j].rm_so, len ); - m_strMatches[j][ len ] = 0; - } - } - - return true; -} - -const char* KRegExpPrivate::group( int _grp ) -{ - if ( _grp < 0 || _grp >= 10 ) - { - kdDebug(128) << "You may only use a group in the range of 0..9" << endl; - assert( 0 ); - } - - return m_strMatches[ _grp ]; -} - -int KRegExpPrivate::groupStart( int _grp ) -{ - if ( _grp < 0 || _grp >= 10 ) - { - kdDebug(128) << "You may only use a group in the range of 0..9" << endl; - assert( 0 ); - } - - return m_matches[ _grp ].rm_so; -} - -int KRegExpPrivate::groupEnd( int _grp ) -{ - if ( _grp < 0 || _grp >= 10 ) - { - kdDebug(128) << "You may only use a group in the range of 0..9" << endl; - assert( 0 ); - } - - return m_matches[ _grp ].rm_eo; -} - -KRegExp::KRegExp() -{ - m_pPrivate = new KRegExpPrivate; -} - -KRegExp::KRegExp( const char *_pattern, const char *_mode) -{ - m_pPrivate = new KRegExpPrivate( _pattern, _mode ); -} - -KRegExp::~KRegExp() -{ - delete m_pPrivate; -} - -bool KRegExp::compile( const char *_pattern, const char *_mode) -{ - return m_pPrivate->compile( _pattern, _mode ); -} - -bool KRegExp::match( const char *_string ) -{ - return m_pPrivate->match( _string ); -} - -const char* KRegExp::group( int _grp ) -{ - return m_pPrivate->group( _grp ); -} - -int KRegExp::groupStart( int _grp ) -{ - return m_pPrivate->groupStart( _grp ); -} - -int KRegExp::groupEnd( int _grp ) -{ - return m_pPrivate->groupEnd( _grp ); -} - -/* -int main( int argc, char **argv ) -{ - if ( argc != 3 ) - assert( 0 ); - - KRegExp r( argv[1], "" ); - cout << "Compiled" << endl; - - if ( !r.match( argv[2] ) ) - { - cerr << "Does not match" << endl; - return 0; - } - - cout << "Match" << endl; - - for( int i = 0; i < 10; i++ ) - { - const char *c = r.group( i ); - if ( !c ) - return 0; - cout << "Group #" << i << ":" << c << endl; - } - - return 0; -} -*/ diff --git a/kdecore/kregexp.h b/kdecore/kregexp.h deleted file mode 100644 index 88d16a3c7..000000000 --- a/kdecore/kregexp.h +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Torben Weis <weis@kde.org> - - 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 __kregexp_h__ -#define __kregexp_h__ - -#include "kdelibs_export.h" - -class KRegExpPrivate; - -/** - * @deprecated - * Please use TQRegExp instead. - * - * Regular expression (regexp) matching with back-references. - * - * This was implemented - * because TQRegExp did not support back-references. It now does and - * is recommended over KRegExp because of the tqunicode support and the - * more powerful API. - * - * Back-references are parts of a regexp grouped with parentheses. If a - * string matches the regexp, you can access the text that matched each - * group with the group method. This is similar to regular expressions - * in Perl. - * - * Example: - * \code - * KRegExp ex( "([A-Za-z]+) (.+)" ); - * ex.match( "42 Torben Weis" ); - * kdDebug() << ex.group(0) << endl; - * kdDebug() << ex.group(1) << endl; - * kdDebug() << ex.group(2) << endl; - * \endcode - * Output: - * \code - * Torben Weis - * Torben - * Weis - * \endcode - * - * Please notice that KRegExp does @em not support tqunicode. - * - * @author Torben Weis <weis@kde.org> - */ -class KDECORE_EXPORT KDE_DEPRECATED KRegExp -{ -public: - - /** - * Creates a KRegExp object without a default pattern. - */ - KRegExp(); - - /** - * Creates a KRegExp object. - * @param _pattern The regular expression to use for matches. - * @param _mode If this is "i", case-insensitive matches will be - * performed. - */ - KRegExp( const char *_pattern, const char *_mode = "" ); - ~KRegExp(); - - /** - * Prepare a regular expression for subsequent matches. - * @param _pattern The regular expression to use for matches. - * @param _mode If this is "i", case-insensitive matches will be - * performed. - * @return bool if successful. - */ - bool compile( const char *_pattern, const char *_mode = "" ); - - /** - * Match a string to the last supplied regexp. - * @param _string the string to match - * @return @p true on match, false otherwise. - */ - bool match( const char *_string ); - - - /** - * Returns a group from the match. - * - * @param _grp May be in the range [0..9]. If @p _grp is 0 then the complete - * matched string is returned. - * @return a grouped substring. A substring may be empty. - * In this case 0 is returned. Otherwise you may @em not - * delete or modify the returned value. In addition the - * returned value becomes invalid after the KRegExp instance - * is deleted or after match() was called again. - */ - const char *group( int _grp ); - - /** - * The offset of the given group in the string. - * @param _grp May be in the range [0..9]. If @p _grp is 0 then the start offset - * of the complete matched string is returned. - * @return The start offset of the grouped substring. - */ - int groupStart( int _grp ); - /** - * The offset of the given group's end in the string. - * @param _grp May be in the range [0..9]. If @p _grp is 0 then the end offset - * of the complete matched string is returned. - * @return The end offset of the grouped substring. The "end offset" is the first - * character after the string. - */ - int groupEnd( int _grp ); - -private: - KRegExpPrivate *m_pPrivate; -}; - - -#endif diff --git a/kdecore/kregpriv.h b/kdecore/kregpriv.h deleted file mode 100644 index 2aa34bba5..000000000 --- a/kdecore/kregpriv.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Torben Weis <weis@kde.org> - - 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 __kreg_private_h__ -#define __kreg_private_h__ - -extern "C" { // bug with some libc5 distributions -#include <regex.h> -} - -class KRegExpDataPtr; - -/** - * Used internally by KRegExp. - * @internal - * - * @author Torben Weis <weis@kde.org> - */ -class KRegExpPrivate -{ -public: - KRegExpPrivate(); - KRegExpPrivate( const char *_pattern, const char *_mode = "" ); - ~KRegExpPrivate(); - - bool compile( const char *_pattern, const char *_mode = "" ); - - bool match( const char *_string ); - const char *group( int _grp ); - int groupStart( int _grp ); - int groupEnd( int _grp ); - -protected: - regex_t m_pattern; - regmatch_t m_matches[ 10 ]; - char* m_strMatches[10]; - bool m_bInit; - -private: - KRegExpDataPtr *d; -}; - -#endif diff --git a/kdecore/krfcdate.cpp b/kdecore/krfcdate.cpp deleted file mode 100644 index dabdc7afa..000000000 --- a/kdecore/krfcdate.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* - * - * This file is part of the KDE libraries - * Copyright (c) 2000-2002 Waldo Bastian <bastian@kde.org> - * 2002 Rik Hemsley <rik@kde.org> - * - * $Id$ - * - * 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 <sys/param.h> -#include <ctype.h> -#include <stdlib.h> - -#include <tqstringlist.h> - -#include <krfcdate.h> - -static unsigned int ymdhms_to_seconds(int year, int mon, int day, int hour, int minute, int second) -{ - if (sizeof(time_t) == 4) - { - if ((time_t)-1 < 0) - { - if (year >= 2038) - { - year = 2038; - mon = 0; - day = 1; - hour = 0; - minute = 0; - second = 0; - } - } - else - { - if (year >= 2115) - { - year = 2115; - mon = 0; - day = 1; - hour = 0; - minute = 0; - second = 0; - } - } - } - - unsigned int ret = (day - 32075) /* days */ - + 1461L * (year + 4800L + (mon - 14) / 12) / 4 - + 367 * (mon - 2 - (mon - 14) / 12 * 12) / 12 - - 3 * ((year + 4900L + (mon - 14) / 12) / 100) / 4 - - 2440588; - ret = 24*ret + hour; /* hours */ - ret = 60*ret + minute; /* minutes */ - ret = 60*ret + second; /* seconds */ - - return ret; -} - -static const char haystack[37]="janfebmaraprmayjunjulaugsepoctnovdec"; - -// we follow the recommendation of rfc2822 to consider all -// obsolete time zones not listed here equivalent to "-0000" -static const struct { - const char tzName[4]; - int tzOffset; -} known_zones[] = { - { "UT", 0 }, - { "GMT", 0 }, - { "EST", -300 }, - { "EDT", -240 }, - { "CST", -360 }, - { "CDT", -300 }, - { "MST", -420 }, - { "MDT", -360 }, - { "PST", -480 }, - { "PDT", -420 }, - { { 0,0,0,0 }, 0 } -}; - -time_t -KRFCDate::parseDate(const TQString &_date) -{ - if (_date.isEmpty()) - return 0; - - // This parse a date in the form: - // Wednesday, 09-Nov-99 23:12:40 GMT - // or - // Sat, 01-Jan-2000 08:00:00 GMT - // or - // Sat, 01 Jan 2000 08:00:00 GMT - // or - // 01 Jan 99 22:00 +0100 (exceptions in rfc822/rfc2822) - // - // We ignore the weekday - // - time_t result = 0; - int offset = 0; - char *newPosStr; - const char *dateString = _date.latin1(); - int day = 0; - char monthStr[4]; - int month = -1; - int year = 0; - int hour = 0; - int minute = 0; - int second = 0; - - // Strip leading space - while(*dateString && isspace(*dateString)) - dateString++; - - // Strip weekday - while(*dateString && !isdigit(*dateString) && !isspace(*dateString)) - dateString++; - - // Strip trailing space - while(*dateString && isspace(*dateString)) - dateString++; - - if (!*dateString) - return result; // Invalid date - - if (isalpha(*dateString)) - { - // ' Nov 5 1994 18:15:30 GMT' - // Strip leading space - while(*dateString && isspace(*dateString)) - dateString++; - - for(int i=0; i < 3;i++) - { - if (!*dateString || (*dateString == '-') || isspace(*dateString)) - return result; // Invalid date - monthStr[i] = tolower(*dateString++); - } - monthStr[3] = '\0'; - - newPosStr = (char*)strstr(haystack, monthStr); - - if (!newPosStr) - return result; // Invalid date - - month = (newPosStr-haystack)/3; // Jan=00, Feb=01, Mar=02, .. - - if ((month < 0) || (month > 11)) - return result; // Invalid date - - while (*dateString && isalpha(*dateString)) - dateString++; // Skip rest of month-name - } - - // ' 09-Nov-99 23:12:40 GMT' - // ' 5 1994 18:15:30 GMT' - day = strtol(dateString, &newPosStr, 10); - dateString = newPosStr; - - if ((day < 1) || (day > 31)) - return result; // Invalid date; - - if (!*dateString) - return result; // Invalid date - - while(*dateString && (isspace(*dateString) || (*dateString == '-'))) - dateString++; - - if (month == -1) - { - for(int i=0; i < 3;i++) - { - if (!*dateString || (*dateString == '-') || isspace(*dateString)) - return result; // Invalid date - monthStr[i] = tolower(*dateString++); - } - monthStr[3] = '\0'; - - newPosStr = (char*)strstr(haystack, monthStr); - - if (!newPosStr) - return result; // Invalid date - - month = (newPosStr-haystack)/3; // Jan=00, Feb=01, Mar=02, .. - - if ((month < 0) || (month > 11)) - return result; // Invalid date - - while (*dateString && isalpha(*dateString)) - dateString++; // Skip rest of month-name - - } - - // '-99 23:12:40 GMT' - while(*dateString && (isspace(*dateString) || (*dateString == '-'))) - dateString++; - - if (!*dateString || !isdigit(*dateString)) - return result; // Invalid date - - // '99 23:12:40 GMT' - year = strtol(dateString, &newPosStr, 10); - dateString = newPosStr; - - // Y2K: Solve 2 digit years - if ((year >= 0) && (year < 50)) - year += 2000; - - if ((year >= 50) && (year < 100)) - year += 1900; // Y2K - - if ((year < 1900) || (year > 2500)) - return result; // Invalid date - - // Don't fail if the time is missing. - if (*dateString) - { - // ' 23:12:40 GMT' - if (!isspace(*dateString++)) - return result; // Invalid date - - hour = strtol(dateString, &newPosStr, 10); - dateString = newPosStr; - - if ((hour < 0) || (hour > 23)) - return result; // Invalid date - - if (!*dateString) - return result; // Invalid date - - // ':12:40 GMT' - if (*dateString++ != ':') - return result; // Invalid date - - minute = strtol(dateString, &newPosStr, 10); - dateString = newPosStr; - - if ((minute < 0) || (minute > 59)) - return result; // Invalid date - - if (!*dateString) - return result; // Invalid date - - // ':40 GMT' - if (*dateString != ':' && !isspace(*dateString)) - return result; // Invalid date - - // seconds are optional in rfc822 + rfc2822 - if (*dateString ==':') { - dateString++; - - second = strtol(dateString, &newPosStr, 10); - dateString = newPosStr; - - if ((second < 0) || (second > 59)) - return result; // Invalid date - } else { - dateString++; - } - - while(*dateString && isspace(*dateString)) - dateString++; - } - - // don't fail if the time zone is missing, some - // broken mail-/news-clients omit the time zone - if (*dateString) { - if ((strncasecmp(dateString, "gmt", 3) == 0) || - (strncasecmp(dateString, "utc", 3) == 0)) - { - dateString += 3; - while(*dateString && isspace(*dateString)) - dateString++; - } - - if ((*dateString == '+') || (*dateString == '-')) { - offset = strtol(dateString, &newPosStr, 10); - if (abs(offset) < 30) - { - dateString = newPosStr; - - offset = offset * 100; - - if (*dateString && *(dateString+1)) - { - dateString++; - int minutes = strtol(dateString, &newPosStr, 10); - if (offset > 0) - offset += minutes; - else - offset -= minutes; - } - } - - if ((offset < -9959) || (offset > 9959)) - return result; // Invalid date - - int sgn = (offset < 0)? -1:1; - offset = abs(offset); - offset = ((offset / 100)*60 + (offset % 100))*sgn; - } else { - for (int i=0; known_zones[i].tzName != 0; i++) { - if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) { - offset = known_zones[i].tzOffset; - break; - } - } - } - } - - result = ymdhms_to_seconds(year, month+1, day, hour, minute, second); - - // avoid negative time values - if ((offset > 0) && (offset > result)) - offset = 0; - - result -= offset*60; - - // If epoch 0 return epoch +1 which is Thu, 01-Jan-70 00:00:01 GMT - // This is so that parse error and valid epoch 0 return values won't - // be the same for sensitive applications... - if (result < 1) result = 1; - - return result; -} - -time_t -KRFCDate::parseDateISO8601( const TQString& input_ ) -{ - if (input_.isEmpty()) - return 0; - - // These dates look like this: - // YYYY-MM-DDTHH:MM:SS - // But they may also have 0, 1 or 2 suffixes. - // Suffix 1: .secfrac (fraction of second) - // Suffix 2: Either 'Z' or +zone or -zone, where zone is HHMM - - unsigned int year = 0; - unsigned int month = 0; - unsigned int mday = 0; - unsigned int hour = 0; - unsigned int min = 0; - unsigned int sec = 0; - - int offset = 0; - - TQString input = input_; - - // First find the 'T' separator, if any. - int tPos = input.find('T'); - - // If there is no time, no month or no day specified, fill those missing - // fields so that 'input' matches YYYY-MM-DDTHH:MM:SS - if (-1 == tPos) { - const int dashes = input.contains('-'); - if (0 == dashes) { - input += "-01-01"; - } else if (1 == dashes) { - input += "-01"; - } - tPos = input.length(); - input += "T12:00:00"; - } - - // Now parse the date part. - - TQString dateString = input.left(tPos).stripWhiteSpace(); - - TQString timeString = input.mid(tPos + 1).stripWhiteSpace(); - - TQStringList l = TQStringList::split('-', dateString); - - if (l.size() < 3) - return 0; - - year = l[0].toUInt(); - month = l[1].toUInt(); - mday = l[2].toUInt(); - - // Z suffix means UTC. - if ((QChar)'Z' == timeString.tqat(timeString.length() - 1)) { - timeString.remove(timeString.length() - 1, 1); - } - - // +zone or -zone suffix (offset from UTC). - - int plusPos = timeString.findRev('+'); - - if (-1 != plusPos) { - TQString offsetString = timeString.mid(plusPos + 1); - - offset = offsetString.left(2).toUInt() * 60 + offsetString.right(2).toUInt(); - - timeString = timeString.left(plusPos); - } else { - int minusPos = timeString.findRev('-'); - - if (-1 != minusPos) { - TQString offsetString = timeString.mid(minusPos + 1); - - offset = - int(offsetString.left(2).toUInt() * 60 + offsetString.right(2).toUInt()); - - timeString = timeString.left(minusPos); - } - } - - // secfrac suffix. - int dotPos = timeString.findRev('.'); - - if (-1 != dotPos) { - timeString = timeString.left(dotPos); - } - - // Now parse the time part. - - l = TQStringList::split(':', timeString); - - if (l.size() < 3) - return 0; - - hour = l[0].toUInt(); - min = l[1].toUInt(); - sec = l[2].toUInt(); - - time_t result = ymdhms_to_seconds(year, month, mday, hour, min, sec); - - // avoid negative time values - if ((offset > 0) && (offset > result)) - offset = 0; - - result -= offset*60; - - // If epoch 0 return epoch +1 which is Thu, 01-Jan-70 00:00:01 GMT - // This is so that parse error and valid epoch 0 return values won't - // be the same for sensitive applications... - if (result < 1) result = 1; - - return result; -} - - -int KRFCDate::localUTCOffset() -{ - time_t timeNow = time((time_t*) 0); - - tm *tM = gmtime(&timeNow); - unsigned int timeUTC = ymdhms_to_seconds(tM->tm_year+1900, tM->tm_mon+1, tM->tm_mday, - tM->tm_hour, tM->tm_min, tM->tm_sec); - - tM = localtime(&timeNow); - unsigned int timeLocal = ymdhms_to_seconds(tM->tm_year+1900, tM->tm_mon+1, tM->tm_mday, - tM->tm_hour, tM->tm_min, tM->tm_sec); - - return ((int)(timeLocal-timeUTC))/60; -} - - -static const char * const day_names[] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; - -static const char * const month_names[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; - - -TQCString KRFCDate::rfc2822DateString(time_t utcTime, int utcOffset) -{ - utcTime += utcOffset * 60; - tm *tM = gmtime(&utcTime); - char sgn = (utcOffset < 0) ? '-' : '+'; - int z = (utcOffset < 0) ? -utcOffset : utcOffset; - TQCString dateStr; - - dateStr.sprintf("%s, %02d %s %04d %02d:%02d:%02d %c%02d%02d", - day_names[tM->tm_wday], tM->tm_mday, - month_names[tM->tm_mon], tM->tm_year+1900, - tM->tm_hour, tM->tm_min, tM->tm_sec, - sgn, z/60%24, z%60); - - return dateStr; -} - - -TQCString KRFCDate::rfc2822DateString(time_t utcTime) -{ - return rfc2822DateString(utcTime, localUTCOffset()); -} diff --git a/kdecore/krfcdate.h b/kdecore/krfcdate.h deleted file mode 100644 index ade819622..000000000 --- a/kdecore/krfcdate.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2000 Waldo Bastian <bastian@kde.org> - - 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 _KRFCDATE_H_ -#define _KRFCDATE_H_ - -#include <tqstring.h> -#include <time.h> -#include "kdelibs_export.h" - -/** - * The KRFCDate class contains functions related to the parsing of dates. - * - * @author Waldo Bastian <bastian@kde.org> - */ -class KDECORE_EXPORT KRFCDate -{ -public: - /** - * This function tries to parse a string containing a date/time in any - * of the formats specified by RFC822, RFC850, RFC1036, RFC1123 and RFC2822. - * - * If the date/time could not be parsed, 0 is returned. If the - * parsed date is epoch, then epoch+1 is returned so that a valid - * date will not be confused with an improper date string. - * - * The date/time returned is converted to UTC. - * @param date the date to parse - * @return the date, or 0 if not possible - */ - static time_t parseDate(const TQString &date); - - /** - * This function tries to parse a string containing a date/time in - * any of the formats specified by http://www.w3.org/TR/NOTE-datetime - * - * This is a subset of the formats specified in ISO8601. - * - * If the date/time could not be parsed, 0 is returned. If the - * parsed date is epoch, then epoch+1 is returned so that a valid - * date will not be confused with an improper date string. - * - * The date/time returned is converted to UTC. - * - * @param date the date to parse - * @return the date, or 0 if not possible - */ - static time_t parseDateISO8601(const TQString &date); - - /** - * Returns the local timezone offset to UTC in minutes - * @return the local timezone offset in minutes - */ - static int localUTCOffset(); - - - /** - * Returns a string representation of the given date and time formated - * in conformance to RFC2822. - * - * @param utcTime a date and time in UTC - * @param utcOffset the offset to UTC in minutes - * @return the string representation of the date - */ - - static TQCString rfc2822DateString(time_t utcTime, int utcOffset); - - - /** - * Returns a string representation of the given date and time formated - * in conformance to RFC2822. - * - * Provided for convenience, the function is equivalent to - * rfc2822DateString(t, localUTCOffset()). - * - * @param utcTime a date and time in UTC - * @return the string representation of the date - */ - - static TQCString rfc2822DateString(time_t utcTime); - -}; - -#endif diff --git a/kdecore/krootprop.cpp b/kdecore/krootprop.cpp deleted file mode 100644 index 031e27abf..000000000 --- a/kdecore/krootprop.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Mark Donohoe (donohoe@kde.org) - - 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. -*/ - -#include <tqwidget.h> - -#include "config.h" -#ifdef Q_WS_X11 // not needed anyway :-) - -#include "krootprop.h" -#include "kglobal.h" -#include "klocale.h" -#include "kcharsets.h" -#include "kapplication.h" -#include <tqtextstream.h> - -#include <X11/Xlib.h> -#include <X11/Xatom.h> - -KRootProp::KRootProp(const TQString& rProp ) -{ - atom = 0; - dirty = false; - setProp( rProp ); -} - -KRootProp::~KRootProp() -{ - sync(); - propDict.clear(); -} - -void KRootProp::sync() -{ - if ( !dirty ) - return; - - TQString propString; - if ( !propDict.isEmpty() ) - { - TQMap<TQString,TQString>::Iterator it = propDict.begin(); - TQString keyvalue; - - while ( it != propDict.end() ) - { - keyvalue = TQString( "%1=%2\n").arg(it.key()).arg(it.data()); - propString += keyvalue; - ++it; - } - } - - XChangeProperty( qt_xdisplay(), qt_xrootwin(), atom, - XA_STRING, 8, PropModeReplace, - (const unsigned char *)propString.utf8().data(), - propString.length()); - XFlush( qt_xdisplay() ); -} - -void KRootProp::setProp( const TQString& rProp ) -{ - Atom type; - int format; - unsigned long nitems; - unsigned long bytes_after; - long offset; - - // If a property has already been opened write - // the dictionary back to the root window - - if( atom ) - sync(); - - property_ = rProp; - if( rProp.isEmpty() ) - return; - - atom = XInternAtom( qt_xdisplay(), rProp.utf8(), False); - - TQString s; - offset = 0; bytes_after = 1; - while (bytes_after != 0) - { - unsigned char *buf = 0; - if (XGetWindowProperty( qt_xdisplay(), qt_xrootwin(), atom, offset, 256, - False, XA_STRING, &type, &format, &nitems, &bytes_after, - &buf) == Success && buf) - { - s += TQString::fromUtf8((const char*)buf); - offset += nitems/4; - XFree(buf); - } - } - - // Parse through the property string stripping out key value pairs - // and putting them in the dictionary - - TQString keypair; - int i=0; - TQString key; - TQString value; - - while(s.length() >0 ) - { - // parse the string for first key-value pair separator '\n' - - i = s.find("\n"); - if(i == -1) - i = s.length(); - - // extract the key-values pair and remove from string - - keypair = s.left(i); - s.remove(0,i+1); - - // split key and value and add to dictionary - - keypair.simplifyWhiteSpace(); - - i = keypair.find( "=" ); - if( i != -1 ) - { - key = keypair.left( i ); - value = keypair.mid( i+1 ); - propDict.insert( key, value ); - } - } -} - - -TQString KRootProp::prop() const -{ - return property_; -} - -void KRootProp::destroy() -{ - dirty = false; - propDict.clear(); - if( atom ) { - XDeleteProperty( qt_xdisplay(), qt_xrootwin(), atom ); - atom = 0; - } -} - -TQString KRootProp::readEntry( const TQString& rKey, - const TQString& pDefault ) const -{ - if( propDict.contains( rKey ) ) - return propDict[ rKey ]; - else - return pDefault; -} - -int KRootProp::readNumEntry( const TQString& rKey, int nDefault ) const -{ - - TQString aValue = readEntry( rKey ); - if( !aValue.isNull() ) - { - bool ok; - - int rc = aValue.toInt( &ok ); - if (ok) - return rc; - } - return nDefault; -} - - -TQFont KRootProp::readFontEntry( const TQString& rKey, - const TQFont* pDefault ) const -{ - TQFont aRetFont; - TQFont aDefFont; - - if (pDefault) - aDefFont = *pDefault; - - TQString aValue = readEntry( rKey ); - if( aValue.isNull() ) - return aDefFont; // Return default font - - if ( !aRetFont.fromString( aValue ) && pDefault ) - aRetFont = aDefFont; - - return aRetFont; -} - - -TQColor KRootProp::readColorEntry( const TQString& rKey, - const TQColor* pDefault ) const -{ - TQColor aRetColor; - int nRed = 0, nGreen = 0, nBlue = 0; - - if( pDefault ) - aRetColor = *pDefault; - - TQString aValue = readEntry( rKey ); - if( aValue.isNull() ) - return aRetColor; - - // Support #ffffff style color naming. - // Help ease transistion from legacy KDE setups - if( aValue.find("#") == 0 ) { - aRetColor.setNamedColor( aValue ); - return aRetColor; - } - - // Parse "red,green,blue" - // find first comma - int nIndex1 = aValue.find( ',' ); - if( nIndex1 == -1 ) - return aRetColor; - // find second comma - int nIndex2 = aValue.find( ',', nIndex1+1 ); - if( nIndex2 == -1 ) - return aRetColor; - - bool bOK; - nRed = aValue.left( nIndex1 ).toInt( &bOK ); - nGreen = aValue.mid( nIndex1+1, - nIndex2-nIndex1-1 ).toInt( &bOK ); - nBlue = aValue.mid( nIndex2+1 ).toInt( &bOK ); - - aRetColor.setRgb( nRed, nGreen, nBlue ); - - return aRetColor; -} - -TQString KRootProp::writeEntry( const TQString& rKey, const TQString& rValue ) -{ - dirty = true; - if ( propDict.contains( rKey ) ) { - TQString aValue = propDict[ rKey ]; - propDict.replace( rKey, rValue ); - return aValue; - } - else { - propDict.insert( rKey, rValue ); - return TQString::null; - } -} - -TQString KRootProp::writeEntry( const TQString& rKey, int nValue ) -{ - TQString aValue; - - aValue.setNum( nValue ); - - return writeEntry( rKey, aValue ); -} - -TQString KRootProp::writeEntry( const TQString& rKey, const TQFont& rFont ) -{ - return writeEntry( rKey, TQString(rFont.toString()) ); -} - -TQString KRootProp::writeEntry( const TQString& rKey, const TQColor& rColor ) -{ - TQString aValue = TQString( "%1,%2,%3").arg(rColor.red()).arg(rColor.green()).arg(rColor.blue() ); - - return writeEntry( rKey, aValue ); -} - -TQString KRootProp::removeEntry(const TQString& rKey) -{ - if (propDict.contains(rKey)) { - dirty = true; - TQString aValue = propDict[rKey]; - propDict.remove(rKey); - return aValue; - } else - return TQString::null; -} - -TQStringList KRootProp::listEntries() const -{ - TQMap<TQString,TQString>::ConstIterator it; - TQStringList list; - - TQMap<TQString,TQString>::ConstIterator end(propDict.end()); - for (it=propDict.begin(); it!=end; ++it) - list += it.key(); - - return list; -} -#endif diff --git a/kdecore/krootprop.h b/kdecore/krootprop.h deleted file mode 100644 index 6d6a43a24..000000000 --- a/kdecore/krootprop.h +++ /dev/null @@ -1,206 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Mark Donohoe (donohoe@kde.org) - - 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 _KROOTPROP_H -#define _KROOTPROP_H - -typedef unsigned long Atom; - -#include <tqcolor.h> -#include <tqfont.h> -#include <tqmap.h> -#include <tqstringlist.h> - -#include <kdelibs_export.h> - -class KRootPropPrivate; - -/** -* Access KDE desktop resources stored on the root window. -* -* A companion to the KConfig class. -* -* The KRootProp class is used for reading and writing configuration entries -* to properties on the root window. -* -* All configuration entries are of the form "key=value". -* -* @see KConfig::KConfig -* @author Mark Donohoe (donohe@kde.org) -*/ -class KDECORE_EXPORT KRootProp -{ -private: - Atom atom; - TQMap<TQString,TQString> propDict; - TQString property_; - bool dirty; - KRootPropPrivate *d; - -public: - /** - * Constructs a KRootProp object for the property @p rProp. - * @param rProp the property that will be searched, null to - * do nothing - * @see setProp() - **/ - KRootProp( const TQString& rProp = TQString::null ); - /** - * Destructs the KRootProp object. - * - * Writes back any dirty configuration entries. - **/ - ~KRootProp(); - - /** - * Sets the property in which keys will be searched. - * @param rProp the property that will be searched - **/ - void setProp(const TQString& rProp=TQString()); - /** - * Returns the name of the property under which keys are searched. - * @return the property that will be searched - **/ - TQString prop() const; - - /** - * Destroys the property completely. - * - * I.e. all entries will be cleared - * and the property will be removed from the root window. - **/ - void destroy(); - - /** - * Reads the value of an entry specified by @p rKey in the current property. - * - * @param rKey The key to search for. - * @param pDefault A default value returned if the key was not found. - * @return The value for this key or the default if no value - * was found. - **/ - TQString readEntry( const TQString& rKey, - const TQString& pDefault = TQString::null ) const ; - - /** - * Reads a numerical value. - * - * Reads the value of an entry specified by @p rKey in the current property - * and interprets it numerically. - * - * @param rKey The key to search for. - * @param nDefault A default value returned if the key was not found. - * @return The value for this key or the default if no value was found. - */ - int readNumEntry( const TQString& rKey, int nDefault = 0 ) const; - - /** - * Reads a TQFont value. - * - * Reads the value of an entry specified by @p rKey in the current property - * and interpret it as a font object. - * - * @param rKey The key to search for. - * @param pDefault A default value returned if the key was not found. - * @return The value for this key or a default font if no value was found. - */ - TQFont readFontEntry( const TQString& rKey, - const TQFont* pDefault = 0 ) const; - - /** - * Reads a TQColor. - * - * Reads the value of an entry specified by @p rKey in the current property - * and interprets it as a color. - * - * @param rKey The key to search for. - * @param pDefault A default value returned if the key was not found. - * @return The value for this key or a default color if no value - * was found. - */ - TQColor readColorEntry( const TQString& rKey, - const TQColor* pDefault = 0 ) const; - - - /** - * Writes a (key/value) pair. - * - * This is stored to the current property when destroying the - * config object or when calling sync(). - * - * @param rKey The key to write. - * @param rValue The value to write. - * @return The old value for this key. If this key did not exist, - * a null string is returned. - * - **/ - TQString writeEntry( const TQString& rKey, const TQString& rValue ); - - /** - * Writes the (key/value) pair. - * Same as above, but writes a numerical value. - * @param rKey The key to write. - * @param nValue The value to write. - * @return The old value for this key. If this key did not - * exist, a null string is returned. - **/ - TQString writeEntry( const TQString& rKey, int nValue ); - - /** - * Writes the (key/value) pair. - * Same as above, but writes a font. - * @param rKey The key to write. - * @param rFont The font to write. - * @return The old value for this key. If this key did not - * exist, a null string is returned. - **/ - TQString writeEntry( const TQString& rKey, const TQFont& rFont ); - - /** - * Writes the (key/value) pair. - * Same as above, but writes a color. - * @param rKey The key to write. - * @param rColor The color to write. - * @return The old value for this key. If this key did not - * exist, a null string is returned. - **/ - TQString writeEntry( const TQString& rKey, const TQColor& rColor ); - - /** - * Removes an entry. - * @param rKey The key to remove. - * @return The old value for this key. If this key did not - * exist, a null string is returned. - **/ - TQString removeEntry(const TQString& rKey); - - /** - * Returns a list of all keys. - * @return A TQStringList containing all the keys. - **/ - TQStringList listEntries() const; - - /** - * Flushes the entry cache. - * Writes back dirty configuration entries to the current property, - * This is called automatically from the destructor. - **/ - void sync(); -}; - -#endif diff --git a/kdecore/ksavefile.cpp b/kdecore/ksavefile.cpp deleted file mode 100644 index 72625a9ca..000000000 --- a/kdecore/ksavefile.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 <sys/types.h> - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include <unistd.h> -#include <fcntl.h> - -#ifdef HAVE_TEST -#include <test.h> -#endif - -#include <tqdatetime.h> -#include <tqdir.h> - -#include <kde_file.h> -#include "kapplication.h" -#include "ksavefile.h" -#include "kstandarddirs.h" - -KSaveFile::KSaveFile(const TQString &filename, int mode) - : mTempFile(true) -{ - // follow symbolic link, if any - TQString real_filename = KStandardDirs::realFilePath(filename); - - // we only check here if the directory can be written to - // the actual filename isn't written to, but replaced later - // with the contents of our tempfile - if (!checkAccess(real_filename, W_OK)) - { - mTempFile.setError(EACCES); - return; - } - - if (mTempFile.create(real_filename, TQString::tqfromLatin1(".new"), mode)) - { - mFileName = real_filename; // Set filename upon success - - // if we're overwriting an existing file, ensure temp file's - // permissions are the same as existing file so the existing - // file's permissions are preserved - KDE_struct_stat stat_buf; - if (KDE_stat(TQFile::encodeName(real_filename), &stat_buf)==0) - { - // But only if we own the existing file - if (stat_buf.st_uid == getuid()) - { - bool changePermission = true; - if (stat_buf.st_gid != getgid()) - { - if (fchown(mTempFile.handle(), (uid_t) -1, stat_buf.st_gid) != 0) - { - // Use standard permission if we can't set the group - changePermission = false; - } - } - if (changePermission) - fchmod(mTempFile.handle(), stat_buf.st_mode); - } - } - } -} - -KSaveFile::~KSaveFile() -{ - if (mTempFile.bOpen) - close(); // Close if we were still open -} - -TQString -KSaveFile::name() const -{ - return mFileName; -} - -void -KSaveFile::abort() -{ - mTempFile.close(); - mTempFile.unlink(); -} - -bool -KSaveFile::close() -{ - if (mTempFile.name().isEmpty() || mTempFile.handle()==-1) - return false; // Save was aborted already - if (!mTempFile.sync()) - { - abort(); - return false; - } - if (mTempFile.close()) - { - if (0==KDE_rename(TQFile::encodeName(mTempFile.name()), TQFile::encodeName(mFileName))) - return true; // Success! - mTempFile.setError(errno); - } - // Something went wrong, make sure to delete the interim file. - mTempFile.unlink(); - return false; -} - -static int -write_all(int fd, const char *buf, size_t len) -{ - while (len > 0) - { - int written = write(fd, buf, len); - if (written < 0) - { - if (errno == EINTR) - continue; - return -1; - } - buf += written; - len -= written; - } - return 0; -} - -bool KSaveFile::backupFile( const TQString& qFilename, const TQString& backupDir, - const TQString& backupExtension) -{ - TQCString cFilename = TQFile::encodeName(qFilename); - const char *filename = cFilename.data(); - - int fd = KDE_open( filename, O_RDONLY ); - if (fd < 0) - return false; - - KDE_struct_stat buff; - if ( KDE_fstat( fd, &buff) < 0 ) - { - ::close( fd ); - return false; - } - - TQCString cBackup; - if ( backupDir.isEmpty() ) - cBackup = cFilename; - else - { - TQCString nameOnly; - int slash = cFilename.findRev('/'); - if (slash < 0) - nameOnly = cFilename; - else - nameOnly = cFilename.mid(slash + 1); - cBackup = TQFile::encodeName(backupDir); - if ( backupDir[backupDir.length()-1] != (QChar)'/' ) - cBackup += '/'; - cBackup += nameOnly; - } - cBackup += TQFile::encodeName(backupExtension); - const char *backup = cBackup.data(); - int permissions = buff.st_mode & 07777; - - if ( KDE_stat( backup, &buff) == 0) - { - if ( unlink( backup ) != 0 ) - { - ::close(fd); - return false; - } - } - - mode_t old_umask = umask(0); - int fd2 = KDE_open( backup, O_WRONLY | O_CREAT | O_EXCL, permissions | S_IWUSR); - umask(old_umask); - - if ( fd2 < 0 ) - { - ::close(fd); - return false; - } - - char buffer[ 32*1024 ]; - - while( 1 ) - { - int n = ::read( fd, buffer, 32*1024 ); - if (n == -1) - { - if (errno == EINTR) - continue; - ::close(fd); - ::close(fd2); - return false; - } - if (n == 0) - break; // Finished - - if (write_all( fd2, buffer, n)) - { - ::close(fd); - ::close(fd2); - return false; - } - } - - ::close( fd ); - - if (::close(fd2)) - return false; - return true; -} diff --git a/kdecore/ksavefile.h b/kdecore/ksavefile.h deleted file mode 100644 index 448c9ca1a..000000000 --- a/kdecore/ksavefile.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 _KSAVEFILE_H_ -#define _KSAVEFILE_H_ - -#include <tqstring.h> -#include <stdio.h> -#include <errno.h> -#include <ktempfile.h> - -class KSaveFilePrivate; - -/** - * The KSaveFile class has been made to write out changes to an existing - * file atomically. - * This means that EITHER: - * a) - * All changes have been written successfully to the file. - * - * b) - * Some error occurred, no changes have been written whatsoever and the - * old file is still in place. - */ -class KDECORE_EXPORT KSaveFile -{ -public: - /** - * Creates a new KSaveFile with the given file name. - * @param filename the path of the file - * @param mode the mode of the file (see chmod(1)) - */ - KSaveFile(const TQString &filename, int mode = 0666 ); - - /** - * The destructor closes the file. - * You might want to call close() explicitely though, to test whether it worked. - **/ - ~KSaveFile(); - - /** - * Returns the status of the file based on errno. (see errno.h) - * 0 means OK. - * - * You should check the status after object creation to check - * whether a file could be created in the first place. - * - * You may check the status after closing the file to verify that - * the file has indeed been written correctly. - * @return the errno status, 0 means ok - **/ - int status() const - { return mTempFile.status(); } - - /** - * The name of the file as passed to the constructor. - * @return The name of the file, or TQString::null if opening the - * file has failed - **/ - TQString name() const; - - /** - * An integer file descriptor open for writing to the file. - * @return The file descriptor, or a negative number if opening - * the temporary file failed - **/ - int handle() const - { return mTempFile.handle(); } - - /** - * A FILE* stream open for writing to the file. - * @return FILE* stream open for writing to the file, or 0 - * if opening the temporary file failed - **/ - FILE *fstream() - { return mTempFile.fstream(); } - - /** - * A TQFile* open for writing to the file. - * @return A TQFile open for writing to the file, or 0 if - * opening the temporary file failed. - **/ - TQFile *file() - { return mTempFile.file(); } - - /** - * A TQTextStream* open for writing to the file. - * @return A TQTextStream that is open for writing to the file, or 0 - * if opening the temporary file failed - **/ - TQTextStream *textStream() - { return mTempFile.textStream(); } - - /** - * A TQDataStream* open for writing to the file. - * @return A TQDataStream that is open for writing to the file, or 0 - * if opening the file failed - **/ - TQDataStream *dataStream() - { return mTempFile.dataStream(); } - - /** - * Aborts the write operation and removes any intermediate files - * This implies a close. - **/ - void abort(); - - /** - * Closes the file and makes the changes definitive. - * Returns 'true' is successful, or 'false' if an error has occurred. - * See status() for details about errors. - * @return true if successful, or false if an error has occurred. - **/ - bool close(); - - /** - * Static method to create a backup file before saving. - * You can use this method even if you don't use KSaveFile. - * @param filename the file to backup - * @param backupDir optional directory where to save the backup file in. - * If empty (the default), the backup will be in the same directory as @p filename. - * @param backupExtension the extension to append to @p filename, "~" by default. - * @since 3.2 - */ - static bool backupFile( const TQString& filename, - const TQString& backupDir = TQString::null, - const TQString& backupExtension = TQString::tqfromLatin1( "~" ) ); - -private: - TQString mFileName; - KTempFile mTempFile; - - KSaveFilePrivate *d; -}; - -#endif diff --git a/kdecore/ksharedptr.h b/kdecore/ksharedptr.h deleted file mode 100644 index ada08413b..000000000 --- a/kdecore/ksharedptr.h +++ /dev/null @@ -1,175 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 KSharedPTR_H -#define KSharedPTR_H - -#include "kdelibs_export.h" - -/** - * Reference counting for shared objects. If you derive your object - * from this class, then you may use it in conjunction with - * KSharedPtr to control the lifetime of your object. - * - * Specifically, all classes that derive from KShared have an internal - * counter keeping track of how many other objects have a reference to - * their object. If used with KSharedPtr, then your object will - * not be deleted until all references to the object have been - * released. - * - * You should probably not ever use any of the methods in this class - * directly -- let the KSharedPtr take care of that. Just derive - * your class from KShared and forget about it. - * - * @author Waldo Bastian <bastian@kde.org> - */ -class KDECORE_EXPORT KShared { -public: - /** - * Standard constructor. This will initialize the reference count - * on this object to 0. - */ - KShared() : count(0) { } - - /** - * Copy constructor. This will @em not actually copy the objects - * but it will initialize the reference count on this object to 0. - */ - KShared( const KShared & ) : count(0) { } - - /** - * Overloaded assignment operator. - */ - KShared &operator=(const KShared & ) { return *this; } - - /** - * Increases the reference count by one. - */ - void _KShared_ref() const { count++; } - - /** - * Releases a reference (decreases the reference count by one). If - * the count goes to 0, this object will delete itself. - */ - void _KShared_unref() const { if (!--count) delete this; } - - /** - * Return the current number of references held. - * - * @return Number of references - */ - int _KShared_count() const { return count; } - -protected: - virtual ~KShared() { } -private: - mutable int count; -}; - -/** - * Can be used to control the lifetime of an object that has derived - * KShared. As long a someone holds a KSharedPtr on some KShared - * object it won't become deleted but is deleted once its reference - * count is 0. This struct emulates C++ pointers virtually perfectly. - * So just use it like a simple C++ pointer. - * - * KShared and KSharedPtr are preferred over QShared / QSharedPtr - * since they are more safe. - * - * WARNING: Please note that this class template provides an implicit - * conversion to T*. Do *not* change this pointer or the pointee (don't - * call delete on it, for instance) behind KSharedPtr's back. - * - * @author Waldo Bastian <bastian@kde.org> - */ -template< class T > -class KSharedPtr -{ -public: -/** - * Creates a null pointer. - */ - KSharedPtr() - : ptr(0) { } - /** - * Creates a new pointer. - * @param t the pointer - */ - KSharedPtr( T* t ) - : ptr(t) { if ( ptr ) ptr->_KShared_ref(); } - - /** - * Copies a pointer. - * @param p the pointer to copy - */ - KSharedPtr( const KSharedPtr& p ) - : ptr(p.ptr) { if ( ptr ) ptr->_KShared_ref(); } - - /** - * Unreferences the object that this pointer points to. If it was - * the last reference, the object will be deleted. - */ - ~KSharedPtr() { if ( ptr ) ptr->_KShared_unref(); } - - KSharedPtr<T>& operator= ( const KSharedPtr<T>& p ) { - if ( ptr == p.ptr ) return *this; - if ( ptr ) ptr->_KShared_unref(); - ptr = p.ptr; - if ( ptr ) ptr->_KShared_ref(); - return *this; - } - KSharedPtr<T>& operator= ( T* p ) { - if ( ptr == p ) return *this; - if ( ptr ) ptr->_KShared_unref(); - ptr = p; - if ( ptr ) ptr->_KShared_ref(); - return *this; - } - bool operator== ( const KSharedPtr<T>& p ) const { return ( ptr == p.ptr ); } - bool operator!= ( const KSharedPtr<T>& p ) const { return ( ptr != p.ptr ); } - bool operator== ( const T* p ) const { return ( ptr == p ); } - bool operator!= ( const T* p ) const { return ( ptr != p ); } - bool operator!() const { return ( ptr == 0 ); } - operator T*() const { return ptr; } - - /** - * Returns the pointer. - * @return the pointer - */ - T* data() { return ptr; } - - /** - * Returns the pointer. - * @return the pointer - */ - const T* data() const { return ptr; } - - const T& operator*() const { return *ptr; } - T& operator*() { return *ptr; } - const T* operator->() const { return ptr; } - T* operator->() { return ptr; } - - /** - * Returns the number of references. - * @return the number of references - */ - int count() const { return ptr->_KShared_count(); } // for debugging purposes -private: - T* ptr; -}; - -#endif diff --git a/kdecore/kshell.cpp b/kdecore/kshell.cpp deleted file mode 100644 index 9a9aacfbe..000000000 --- a/kdecore/kshell.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> - - 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. -*/ - -#include <kshell.h> - -#include <tqfile.h> - -#include <stdlib.h> -#include <pwd.h> -#include <sys/types.h> - -static int fromHex( TQChar c ) -{ - if (c >= (TQChar)'0' && c <= (TQChar)'9') - return c - (TQChar)'0'; - else if (c >= (TQChar)'A' && c <= (TQChar)'F') - return c - (TQChar)'A' + 10; - else if (c >= (TQChar)'a' && c <= (TQChar)'f') - return c - (TQChar)'a' + 10; - return -1; -} - -inline static bool isQuoteMeta( uint c ) -{ -#if 0 // it's not worth it, especially after seeing gcc's asm output ... - static const uchar iqm[] = { - 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00 - }; // \'"$ - - return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7))); -#else - return c == (int)'\\' || c == (int)'\'' || c == (int)'"' || c == (int)'$'; -#endif -} - -inline static bool isMeta( uint c ) -{ - static const uchar iqm[] = { - 0x00, 0x00, 0x00, 0x00, 0xdc, 0x07, 0x00, 0xd8, - 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x38 - }; // \'"$`<>|;&(){}*?# - - return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7))); -} - -TQStringList KShell::splitArgs( const TQString &args, int flags, int *err ) -{ - TQStringList ret; - bool firstword = flags & AbortOnMeta; - - for (uint pos = 0; ; ) { - TQChar c; - do { - if (pos >= args.length()) - goto okret; - c = args.tqunicode()[pos++]; - } while (c.isSpace()); - TQString cret; - if ((flags & TildeExpand) && c == (QChar)'~') { - uint opos = pos; - for (; ; pos++) { - if (pos >= args.length()) - break; - c = args.tqunicode()[pos]; - if (c == (QChar)'/' || c.isSpace()) - break; - if (isQuoteMeta( c )) { - pos = opos; - c = (QChar)'~'; - goto notilde; - } - if ((flags & AbortOnMeta) && isMeta( c )) - goto metaerr; - } - TQString ccret = homeDir( TQConstString( args.tqunicode() + opos, pos - opos ).string() ); - if (ccret.isEmpty()) { - pos = opos; - c = (QChar)'~'; - goto notilde; - } - if (pos >= args.length()) { - ret += ccret; - goto okret; - } - pos++; - if (c.isSpace()) { - ret += ccret; - firstword = false; - continue; - } - cret = ccret; - } - // before the notilde label, as a tilde does not match anyway - if (firstword) { - if (c == (QChar)'_' || (c >= (QChar)'A' && c <= (QChar)'Z') || (c >= (QChar)'a' && c <= (QChar)'z')) { - uint pos2 = pos; - TQChar cc; - do - cc = args[pos2++]; - while (cc == (QChar)'_' || (cc >= (QChar)'A' && cc <= (QChar)'Z') || - (cc >= (QChar)'a' && cc <= (QChar)'z') || (cc >= (QChar)'0' && cc <= (QChar)'9')); - if (cc == (QChar)'=') - goto metaerr; - } - } - notilde: - do { - if (c == (QChar)'\'') { - uint spos = pos; - do { - if (pos >= args.length()) - goto quoteerr; - c = args.tqunicode()[pos++]; - } while (c != (QChar)'\''); - cret += TQConstString( args.tqunicode() + spos, pos - spos - 1 ).string(); - } else if (c == (QChar)'"') { - for (;;) { - if (pos >= args.length()) - goto quoteerr; - c = args.tqunicode()[pos++]; - if (c == (QChar)'"') - break; - if (c == (QChar)'\\') { - if (pos >= args.length()) - goto quoteerr; - c = args.tqunicode()[pos++]; - if (c != (QChar)'"' && c != (QChar)'\\' && - !((flags & AbortOnMeta) && (c == (QChar)'$' || c == (QChar)'`'))) - cret += (QChar)'\\'; - } else if ((flags & AbortOnMeta) && (c == (QChar)'$' || c == (QChar)'`')) - goto metaerr; - cret += c; - } - } else if (c == (QChar)'$' && args[pos] == (QChar)'\'') { - pos++; - for (;;) { - if (pos >= args.length()) - goto quoteerr; - c = args.tqunicode()[pos++]; - if (c == (QChar)'\'') - break; - if (c == (QChar)'\\') { - if (pos >= args.length()) - goto quoteerr; - c = args.tqunicode()[pos++]; - switch (c) { - case 'a': cret += (QChar)'\a'; break; - case 'b': cret += (QChar)'\b'; break; - case 'e': cret += (QChar)'\033'; break; - case 'f': cret += (QChar)'\f'; break; - case 'n': cret += (QChar)'\n'; break; - case 'r': cret += (QChar)'\r'; break; - case 't': cret += (QChar)'\t'; break; - case '\\': cret += (QChar)'\\'; break; - case '\'': cret += (QChar)'\''; break; - case 'c': cret += args[pos++] & 31; break; - case 'x': - { - int hv = fromHex( args[pos] ); - if (hv < 0) { - cret += "\\x"; - } else { - int hhv = fromHex( args[++pos] ); - if (hhv > 0) { - hv = hv * 16 + hhv; - pos++; - } - cret += TQChar( hv ); - } - break; - } - default: - if (c >= (QChar)'0' && c <= (QChar)'7') { - int hv = c - '0'; - for (int i = 0; i < 2; i++) { - c = args[pos]; - if (c < (QChar)'0' || c > (QChar)'7') - break; - hv = hv * 8 + (c - '0'); - pos++; - } - cret += TQChar( hv ); - } else { - cret += '\\'; - cret += c; - } - break; - } - } else - cret += c; - } - } else { - if (c == (QChar)'\\') { - if (pos >= args.length()) - goto quoteerr; - c = args.tqunicode()[pos++]; - if (!c.isSpace() && - !((flags & AbortOnMeta) ? isMeta( c ) : isQuoteMeta( c ))) - cret += '\\'; - } else if ((flags & AbortOnMeta) && isMeta( c )) - goto metaerr; - cret += c; - } - if (pos >= args.length()) - break; - c = args.tqunicode()[pos++]; - } while (!c.isSpace()); - ret += cret; - firstword = false; - } - - okret: - if (err) - *err = NoError; - return ret; - - quoteerr: - if (err) - *err = BadQuoting; - return TQStringList(); - - metaerr: - if (err) - *err = FoundMeta; - return TQStringList(); -} - -inline static bool isSpecial( uint c ) -{ - static const uchar iqm[] = { - 0xff, 0xff, 0xff, 0xff, 0xdd, 0x07, 0x00, 0xd8, - 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x38 - }; // 0-32 \'"$`<>|;&(){}*?# - - return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7))); -} - -TQString KShell::joinArgs( const TQStringList &args ) -{ - TQChar q( '\'' ); - TQString ret; - for (TQStringList::ConstIterator it = args.begin(); it != args.end(); ++it) { - if (!ret.isEmpty()) - ret += ' '; - if (!(*it).length()) - ret.append( q ).append( q ); - else { - for (uint i = 0; i < (*it).length(); i++) - if (isSpecial((*it).tqunicode()[i])) { - TQString tmp(*it); - tmp.replace( q, "'\\''" ); - ret += q; - tmp += q; - ret += tmp; - goto ex; - } - ret += *it; - ex: ; - } - } - return ret; -} - -TQString KShell::joinArgs( const char * const *args, int nargs ) -{ - if (!args) - return TQString::null; // well, TQString::empty, in fact. qt sucks ;) - TQChar q( '\'' ); - TQString ret; - for (const char * const *argp = args; nargs && *argp; argp++, nargs--) { - if (!ret.isEmpty()) - ret += ' '; - if (!**argp) - ret.append( q ).append( q ); - else { - TQString tmp( TQFile::decodeName( *argp ) ); - for (uint i = 0; i < tmp.length(); i++) - if (isSpecial(tmp.tqunicode()[i])) { - tmp.replace( q, "'\\''" ); - ret += q; - tmp += q; - ret += tmp; - goto ex; - } - ret += tmp; - ex: ; - } - } - return ret; -} - -TQString KShell::joinArgsDQ( const TQStringList &args ) -{ - TQChar q( '\'' ), sp( ' ' ), bs( '\\' ); - TQString ret; - for (TQStringList::ConstIterator it = args.begin(); it != args.end(); ++it) { - if (!ret.isEmpty()) - ret += sp; - if (!(*it).length()) - ret.append( q ).append( q ); - else { - for (uint i = 0; i < (*it).length(); i++) - if (isSpecial((*it).tqunicode()[i])) { - ret.append( '$' ).append( q ); - for (uint pos = 0; pos < (*it).length(); pos++) { - int c = (*it).tqunicode()[pos]; - if (c < 32) { - ret += bs; - switch (c) { - case '\a': ret += 'a'; break; - case '\b': ret += 'b'; break; - case '\033': ret += 'e'; break; - case '\f': ret += 'f'; break; - case '\n': ret += 'n'; break; - case '\r': ret += 'r'; break; - case '\t': ret += 't'; break; - case '\034': ret += 'c'; ret += '|'; break; - default: ret += 'c'; ret += c + '@'; break; - } - } else { - if (c == '\'' || c == '\\') - ret += bs; - ret += c; - } - } - ret.append( q ); - goto ex; - } - ret += *it; - ex: ; - } - } - return ret; -} - -TQString KShell::tildeExpand( const TQString &fname ) -{ - if (fname[0] == (QChar)'~') { - int pos = fname.find( '/' ); - if (pos < 0) - return homeDir( TQConstString( fname.tqunicode() + 1, fname.length() - 1 ).string() ); - TQString ret = homeDir( TQConstString( fname.tqunicode() + 1, pos - 1 ).string() ); - if (!ret.isNull()) - ret += TQConstString( fname.tqunicode() + pos, fname.length() - pos ).string(); - return ret; - } - return fname; -} - -TQString KShell::homeDir( const TQString &user ) -{ - if (user.isEmpty()) - return TQFile::decodeName( getenv( "HOME" ) ); - struct passwd *pw = getpwnam( TQFile::encodeName( user ).data() ); - if (!pw) - return TQString::null; - return TQFile::decodeName( pw->pw_dir ); -} diff --git a/kdecore/kshell.h b/kdecore/kshell.h deleted file mode 100644 index 2e9f3ad98..000000000 --- a/kdecore/kshell.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> - - 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 _KSHELL_H -#define _KSHELL_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include "kdelibs_export.h" - -/** - * \namespace KShell - * Provides some basic POSIX shell and bash functionality. - * @see KStringHandler - * - * @since 3.2 - */ -namespace KShell { - - /** - * Flags for splitArgs(). - */ - enum Options { - NoOptions = 0, - - /** - * Perform tilde expansion. - */ - TildeExpand = 1, - - /** - * Bail out if a non-quoting and not quoted shell meta character is encoutered. - * Meta characters are the command separators @p semicolon and @p ampersand, - * the redirection symbols @p less-than, @p greater-than and the @p pipe @p symbol, - * the grouping symbols opening and closing @p parens and @p braces, the command - * substitution symbol @p backquote, the generic substitution symbol @p dollar - * (if not followed by an apostrophe), the wildcards @p asterisk and - * @p question @p mark, and the comment symbol @p hash @p mark. Additionally, - * a variable assignment in the first word is recognized. - */ - AbortOnMeta = 2 - }; - - /** - * Status codes from splitArgs() - */ - enum Errors { - /** - * Success. - */ - NoError = 0, - - /** - * Indicates a parsing error, like an unterminated quoted string. - */ - BadQuoting, - - /** - * The AbortOnMeta flag was set and a shell meta character - * was encoutered. - */ - FoundMeta - }; - - /** - * Splits @p cmd according to POSIX shell word splitting and quoting rules. - * Can optionally perform tilde expansion and/or abort if it finds shell - * meta characters it cannot process. - * - * @param cmd the command to split - * @param flags operation flags, see Options - * @param err if not NULL, a status code will be stored at the pointer - * target, see Errors - * @return a list of unquoted words or an empty list if an error occurred - */ - KDECORE_EXPORT TQStringList splitArgs( const TQString &cmd, int flags = 0, int *err = 0 ); - - /** - * Quotes and joins @p args together according to POSIX shell rules. - * - * @param args a list of strings to quote and join - * @return a command suitable for shell execution - */ - KDECORE_EXPORT TQString joinArgs( const TQStringList &args ); - - /** - * Same as above, but $'' is used instead of '' for the quoting. - * The output is suitable for splitArgs(), bash, zsh and possibly - * other bourne-compatible shells, but not for plain sh. The advantage - * is, that control characters (ASCII less than 32) are escaped into - * human-readable strings. - * - * @param args a list of strings to quote and join - * @return a command suitable for shell execution - */ - KDECORE_EXPORT TQString joinArgsDQ( const TQStringList &args ); - - /** - * Quotes and joins @p argv together according to POSIX shell rules. - * - * @param argv an array of c strings to quote and join. - * The strings are expected to be in local-8-bit encoding. - * @param argc maximal number of strings in @p argv. if not supplied, - * @p argv must be null-terminated. - * @return a command suitable for shell execution - */ - KDECORE_EXPORT TQString joinArgs( const char * const *argv, int argc = -1 ); - - /** - * Performs tilde expansion on @p path. Interprets "~/path" and - * "~user/path". - * - * @param path the path to tilde-expand - * @return the expanded path - */ - KDECORE_EXPORT TQString tildeExpand( const TQString &path ); - - /** - * Obtain a @p user's home directory. - * - * @param user The name of the user whose home dir should be obtained. - * An empty string denotes the current user. - * @return The user's home directory. - */ - KDECORE_EXPORT TQString homeDir( const TQString &user ); - -} - - -#endif /* _KSHELL_H */ diff --git a/kdecore/kshortcut.cpp b/kdecore/kshortcut.cpp deleted file mode 100644 index 10c6c31fa..000000000 --- a/kdecore/kshortcut.cpp +++ /dev/null @@ -1,671 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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. -*/ - -#include "kshortcut.h" -#include "kkeynative.h" -#include "kkeyserver.h" - -#include <tqevent.h> -#include <tqstringlist.h> - -#include <kdebug.h> -#include <kglobal.h> -#include <klocale.h> -#include <ksimpleconfig.h> - -//---------------------------------------------------- - -static KKey* g_pspec = 0; -static KKeySequence* g_pseq = 0; -static KShortcut* g_pcut = 0; - -//---------------------------------------------------- -// KKey -//---------------------------------------------------- - -KKey::KKey() { clear(); } -KKey::KKey( uint key, uint modFlags ) { init( key, modFlags ); } -KKey::KKey( int keyQt ) { init( keyQt ); } -KKey::KKey( const TQKeySequence& seq ) { init( seq ); } -KKey::KKey( const TQKeyEvent* pEvent ) { init( pEvent ); } -KKey::KKey( const KKey& key ) { init( key ); } -KKey::KKey( const TQString& sKey ) { init( sKey ); } - -KKey::~KKey() -{ -} - -void KKey::clear() -{ - m_sym = 0; - m_mod = 0; -} - -bool KKey::init( uint key, uint modFlags ) -{ - m_sym = key; - m_mod = modFlags; - return true; -} - -bool KKey::init( int keyQt ) -{ - //KKeyServer::Sym sym; - - //if( sym.initQt( keyQt ) - if( KKeyServer::keyQtToSym( keyQt, m_sym ) - && KKeyServer::keyQtToMod( keyQt, m_mod ) ) - return true; - else { - m_sym = 0; - m_mod = 0; - return false; - } -} - -bool KKey::init( const TQKeySequence& key ) -{ - // TODO: if key.count() > 1, should we return failure? - return init( (int) key ); -} - -bool KKey::init( const TQKeyEvent* pEvent ) -{ - int keyQt = pEvent->key(); - if( pEvent->state() & TQt::ShiftButton ) keyQt |= Qt::SHIFT; - if( pEvent->state() & TQt::ControlButton ) keyQt |= Qt::CTRL; - if( pEvent->state() & TQt::AltButton ) keyQt |= Qt::ALT; - if( pEvent->state() & TQt::MetaButton ) keyQt |= Qt::META; - return init( keyQt ); -} - -bool KKey::init( const KKey& key ) -{ - m_sym = key.m_sym; - m_mod = key.m_mod; - return true; -} - -bool KKey::init( const TQString& sSpec ) -{ - clear(); - - TQString sKey = sSpec.stripWhiteSpace(); - if( sKey.startsWith( "default(" ) && sKey.endsWith( ")" ) ) - sKey = sKey.mid( 8, sKey.length() - 9 ); - // i.e., "Ctrl++" = "Ctrl+Plus" - if( sKey.endsWith( "++" ) ) - sKey = sKey.left( sKey.length() - 1 ) + "plus"; - TQStringList rgs = TQStringList::split( '+', sKey, true ); - - uint i; - // Check for modifier keys first. - for( i = 0; i < rgs.size(); i++ ) { - TQString s = rgs[i].lower(); - if( s == "shift" ) m_mod |= KKey::SHIFT; - else if( s == "ctrl" ) m_mod |= KKey::CTRL; - else if( s == "alt" ) m_mod |= KKey::ALT; - else if( s == "win" ) m_mod |= KKey::WIN; - else if( s == "meta" ) m_mod |= KKey::WIN; - else { - uint m = KKeyServer::stringUserToMod( s ); - if( m != 0 ) m_mod |= m; - else break; - } - } - // If there is one non-blank key left: - if( (i == rgs.size() - 1 && !rgs[i].isEmpty()) ) { - KKeyServer::Sym sym( rgs[i] ); - m_sym = sym.m_sym; - } - - if( m_sym == 0 ) - m_mod = 0; - - kdDebug(125) << "KKey::init( \"" << sSpec << "\" ):" - << " m_sym = " << TQString::number(m_sym, 16) - << ", m_mod = " << TQString::number(m_mod, 16) << endl; - - return m_sym != 0; -} - -bool KKey::isNull() const { return m_sym == 0; } -uint KKey::sym() const { return m_sym; } -uint KKey::modFlags() const { return m_mod; } - -int KKey::compare( const KKey& spec ) const -{ - if( m_sym != spec.m_sym ) - return m_sym - spec.m_sym; - if( m_mod != spec.m_mod ) - return m_mod - spec.m_mod; - return 0; -} - -int KKey::keyCodeQt() const -{ - return KKeyNative( *this ).keyCodeQt(); -} - -TQString KKey::toString() const -{ - TQString s; - - s = KKeyServer::modToStringUser( m_mod ); - if( !s.isEmpty() ) - s += '+'; - s += KKeyServer::Sym(m_sym).toString(); - - return s; -} - -TQString KKey::toStringInternal() const -{ - //kdDebug(125) << "KKey::toStringInternal(): this = " << this - // << " mod = " << TQString::number(m_mod, 16) - // << " key = " << TQString::number(m_sym, 16) << endl; - TQString s; - - s = KKeyServer::modToStringInternal( m_mod ); - if( !s.isEmpty() ) - s += '+'; - s += KKeyServer::Sym(m_sym).toStringInternal(); - return s; -} - -KKey& KKey::null() -{ - if( !g_pspec ) - g_pspec = new KKey; - if( !g_pspec->isNull() ) - g_pspec->clear(); - return *g_pspec; -} - -TQString KKey::modFlagLabel( ModFlag modFlag ) -{ - return KKeyServer::modToStringUser( modFlag ); -} - -//--------------------------------------------------------------------- -// KKeySequence -//--------------------------------------------------------------------- - -KKeySequence::KKeySequence() { clear(); } -KKeySequence::KKeySequence( const TQKeySequence& seq ) { init( seq ); } -KKeySequence::KKeySequence( const KKey& key ) { init( key ); } -KKeySequence::KKeySequence( const KKeySequence& seq ) { init( seq ); } -KKeySequence::KKeySequence( const TQString& s ) { init( s ); } - -KKeySequence::~KKeySequence() -{ -} - -void KKeySequence::clear() -{ - m_nKeys = 0; - m_bTriggerOnRelease = false; -} - -bool KKeySequence::init( const TQKeySequence& seq ) -{ - clear(); - if( !seq.isEmpty() ) { - for( uint i = 0; i < seq.count(); i++ ) { - m_rgvar[i].init( seq[i] ); - if( m_rgvar[i].isNull() ) - return false; - } - m_nKeys = seq.count(); - m_bTriggerOnRelease = false; - } - return true; -} - -bool KKeySequence::init( const KKey& key ) -{ - if( !key.isNull() ) { - m_nKeys = 1; - m_rgvar[0].init( key ); - m_bTriggerOnRelease = false; - } else - clear(); - return true; -} - -bool KKeySequence::init( const KKeySequence& seq ) -{ - m_bTriggerOnRelease = false; - m_nKeys = seq.m_nKeys; - for( uint i = 0; i < m_nKeys; i++ ) { - if( seq.m_rgvar[i].isNull() ) { - kdDebug(125) << "KKeySequence::init( seq ): key[" << i << "] is null." << endl; - m_nKeys = 0; - return false; - } - m_rgvar[i] = seq.m_rgvar[i]; - } - return true; -} - -bool KKeySequence::init( const TQString& s ) -{ - m_bTriggerOnRelease = false; - //kdDebug(125) << "KKeySequence::init( " << s << " )" << endl; - TQStringList rgs = TQStringList::split( ',', s ); - if( s == "none" || rgs.size() == 0 ) { - clear(); - return true; - } else if( rgs.size() <= MAX_KEYS ) { - m_nKeys = rgs.size(); - for( uint i = 0; i < m_nKeys; i++ ) { - m_rgvar[i].init( KKey(rgs[i]) ); - //kdDebug(125) << "\t'" << rgs[i] << "' => " << m_rgvar[i].toStringInternal() << endl; - } - return true; - } else { - clear(); - return false; - } -} - -uint KKeySequence::count() const -{ - return m_nKeys; -} - -const KKey& KKeySequence::key( uint i ) const -{ - if( i < m_nKeys ) - return m_rgvar[i]; - else - return KKey::null(); -} - -bool KKeySequence::isTriggerOnRelease() const - { return m_bTriggerOnRelease; } - -bool KKeySequence::setKey( uint iKey, const KKey& key ) -{ - if( iKey <= m_nKeys && iKey < MAX_KEYS ) { - m_rgvar[iKey].init( key ); - if( iKey == m_nKeys ) - m_nKeys++; - return true; - } else - return false; -} - -bool KKeySequence::isNull() const -{ - return m_nKeys == 0; -} - -bool KKeySequence::startsWith( const KKeySequence& seq ) const -{ - if( m_nKeys < seq.m_nKeys ) - return false; - - for( uint i = 0; i < seq.m_nKeys; i++ ) { - if( m_rgvar[i] != seq.m_rgvar[i] ) - return false; - } - - return true; -} - -int KKeySequence::compare( const KKeySequence& seq ) const -{ - for( uint i = 0; i < m_nKeys && i < seq.m_nKeys; i++ ) { - int ret = m_rgvar[i].compare( seq.m_rgvar[i] ); - if( ret != 0 ) - return ret; - } - if( m_nKeys != seq.m_nKeys ) - return m_nKeys - seq.m_nKeys; - else - return 0; -} - -TQKeySequence KKeySequence::qt() const -{ - int k[4] = { 0, 0, 0, 0 }; - - for( uint i = 0; i < count(); i++ ) - k[i] = KKeyNative(key(i)).keyCodeQt(); - TQKeySequence seq( k[0], k[1], k[2], k[3] ); - return seq; -} - -int KKeySequence::keyCodeQt() const -{ - return (count() == 1) ? KKeyNative(key(0)).keyCodeQt() : 0; -} - -TQString KKeySequence::toString() const -{ - if( m_nKeys < 1 ) return TQString::null; - - TQString s; - s = m_rgvar[0].toString(); - for( uint i = 1; i < m_nKeys; i++ ) { - s += ","; - s += m_rgvar[i].toString(); - } - - return s; -} - -TQString KKeySequence::toStringInternal() const -{ - if( m_nKeys < 1 ) return TQString::null; - - TQString s; - s = m_rgvar[0].toStringInternal(); - for( uint i = 1; i < m_nKeys; i++ ) { - s += ","; - s += m_rgvar[i].toStringInternal(); - } - - return s; -} - -KKeySequence& KKeySequence::null() -{ - if( !g_pseq ) - g_pseq = new KKeySequence; - if( !g_pseq->isNull() ) - g_pseq->clear(); - return *g_pseq; -} - -//--------------------------------------------------------------------- -// KShortcut -//--------------------------------------------------------------------- - -KShortcut::KShortcut() { clear(); } -KShortcut::KShortcut( int keyQt ) { init( keyQt ); } -KShortcut::KShortcut( const TQKeySequence& key ) { init( key ); } -KShortcut::KShortcut( const KKey& key ) { init( key ); } -KShortcut::KShortcut( const KKeySequence& seq ) { init( seq ); } -KShortcut::KShortcut( const KShortcut& cut ) { init( cut ); } -KShortcut::KShortcut( const char* ps ) { init( TQString(ps) ); } -KShortcut::KShortcut( const TQString& s ) { init( s ); } - -KShortcut::~KShortcut() -{ -} - -void KShortcut::clear() -{ - m_nSeqs = 0; -} - -bool KShortcut::init( int keyQt ) -{ - if( keyQt ) { - m_nSeqs = 1; - m_rgseq[0].init( TQKeySequence(keyQt) ); - } else - clear(); - return true; -} - -bool KShortcut::init( const TQKeySequence& key ) -{ - m_nSeqs = 1; - m_rgseq[0].init( key ); - return true; -} - -bool KShortcut::init( const KKey& spec ) -{ - m_nSeqs = 1; - m_rgseq[0].init( spec ); - return true; -} - -bool KShortcut::init( const KKeySequence& seq ) -{ - m_nSeqs = 1; - m_rgseq[0] = seq; - return true; -} - -bool KShortcut::init( const KShortcut& cut ) -{ - m_nSeqs = cut.m_nSeqs; - for( uint i = 0; i < m_nSeqs; i++ ) - m_rgseq[i] = cut.m_rgseq[i]; - return true; -} - -bool KShortcut::init( const TQString& s ) -{ - bool bRet = true; - TQStringList rgs = TQStringList::split( ';', s ); - - if( s == "none" || rgs.size() == 0 ) - clear(); - else if( rgs.size() <= MAX_SEQUENCES ) { - m_nSeqs = rgs.size(); - for( uint i = 0; i < m_nSeqs; i++ ) { - TQString& sSeq = rgs[i]; - if( sSeq.startsWith( "default(" ) ) - sSeq = sSeq.mid( 8, sSeq.length() - 9 ); - m_rgseq[i].init( sSeq ); - //kdDebug(125) << "*\t'" << sSeq << "' => " << m_rgseq[i].toStringInternal() << endl; - } - } else { - clear(); - bRet = false; - } - - if( !s.isEmpty() ) { - TQString sDebug; - TQTextStream os( &sDebug, IO_WriteOnly ); - os << "KShortcut::init( \"" << s << "\" ): "; - for( uint i = 0; i < m_nSeqs; i++ ) { - os << " m_rgseq[" << i << "]: "; - KKeyServer::Variations vars; - vars.init( m_rgseq[i].key(0), true ); - for( uint j = 0; j < vars.count(); j++ ) - os << TQString::number(vars.m_rgkey[j].keyCodeQt(),16) << ','; - } - kdDebug(125) << sDebug << endl; - } - - return bRet; -} - -uint KShortcut::count() const -{ - return m_nSeqs; -} - -const KKeySequence& KShortcut::seq( uint i ) const -{ - return (i < m_nSeqs) ? m_rgseq[i] : KKeySequence::null(); -} - -int KShortcut::keyCodeQt() const -{ - if( m_nSeqs >= 1 ) - return m_rgseq[0].keyCodeQt(); - return TQKeySequence(); -} - -bool KShortcut::isNull() const -{ - return m_nSeqs == 0; -} - -int KShortcut::compare( const KShortcut& cut ) const -{ - for( uint i = 0; i < m_nSeqs && i < cut.m_nSeqs; i++ ) { - int ret = m_rgseq[i].compare( cut.m_rgseq[i] ); - if( ret != 0 ) - return ret; - } - return m_nSeqs - cut.m_nSeqs; -} - -bool KShortcut::contains( const KKey& key ) const -{ - return contains( KKeySequence(key) ); -} - -bool KShortcut::contains( const KKeyNative& keyNative ) const -{ - KKey key = keyNative.key(); - key.simplify(); - - for( uint i = 0; i < count(); i++ ) { - if( !m_rgseq[i].isNull() - && m_rgseq[i].count() == 1 - && m_rgseq[i].key(0) == key ) - return true; - } - return false; -} - -bool KShortcut::contains( const KKeySequence& seq ) const -{ - for( uint i = 0; i < count(); i++ ) { - if( !m_rgseq[i].isNull() && m_rgseq[i] == seq ) - return true; - } - return false; -} - -bool KShortcut::setSeq( uint iSeq, const KKeySequence& seq ) -{ - // TODO: check if seq is null, and act accordingly. - if( iSeq <= m_nSeqs && iSeq < MAX_SEQUENCES ) { - m_rgseq[iSeq] = seq; - if( iSeq == m_nSeqs ) - m_nSeqs++; - return true; - } else - return false; -} - -void KShortcut::remove( const KKeySequence& seq ) -{ - if (seq.isNull()) return; - - for( uint iSeq = 0; iSeq < m_nSeqs; iSeq++ ) - { - if (m_rgseq[iSeq] == seq) - { - for( uint jSeq = iSeq + 1; jSeq < m_nSeqs; jSeq++) - m_rgseq[jSeq-1] = m_rgseq[jSeq]; - m_nSeqs--; - } - } -} - -bool KShortcut::append( const KKeySequence& seq ) -{ - if( m_nSeqs < MAX_SEQUENCES ) { - if( !seq.isNull() ) { - m_rgseq[m_nSeqs] = seq; - m_nSeqs++; - } - return true; - } else - return false; -} - -bool KShortcut::append( const KKey& spec ) -{ - if( m_nSeqs < MAX_SEQUENCES ) { - m_rgseq[m_nSeqs].init( spec ); - m_nSeqs++; - return true; - } else - return false; -} - -bool KShortcut::append( const KShortcut& cut ) -{ - uint seqs = m_nSeqs, co = cut.count(); - for( uint i=0; i<co; i++ ) { - if (!contains(cut.seq(i))) seqs++; - } - if( seqs > MAX_SEQUENCES ) return false; - - for( uint i=0; i<co; i++ ) { - const KKeySequence& seq = cut.seq(i); - if(!contains(seq)) { - m_rgseq[m_nSeqs] = seq; - m_nSeqs++; - } - } - return true; -} - -KShortcut::operator TQKeySequence () const -{ - if( count() >= 1 ) - return m_rgseq[0].qt(); - else - return TQKeySequence(); -} - -TQString KShortcut::toString() const -{ - TQString s; - - for( uint i = 0; i < count(); i++ ) { - s += m_rgseq[i].toString(); - if( i < count() - 1 ) - s += ';'; - } - - return s; -} - -TQString KShortcut::toStringInternal( const KShortcut* pcutDefault ) const -{ - TQString s; - - for( uint i = 0; i < count(); i++ ) { - const KKeySequence& seq = m_rgseq[i]; - if( pcutDefault && i < pcutDefault->count() && seq == (*pcutDefault).seq(i) ) { - s += "default("; - s += seq.toStringInternal(); - s += ")"; - } else - s += seq.toStringInternal(); - if( i < count() - 1 ) - s += ';'; - } - - return s; -} - -KShortcut& KShortcut::null() -{ - if( !g_pcut ) - g_pcut = new KShortcut; - if( !g_pcut->isNull() ) - g_pcut->clear(); - return *g_pcut; -} diff --git a/kdecore/kshortcut.h b/kdecore/kshortcut.h deleted file mode 100644 index 7d62a0041..000000000 --- a/kdecore/kshortcut.h +++ /dev/null @@ -1,851 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> - - 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 __KSHORTCUT_H -#define __KSHORTCUT_H - -#include <tqkeysequence.h> -#include <tqstring.h> -#include "kdelibs_export.h" - -class TQKeyEvent; -class KKeyNative; - -/** -* A KKey object represents a single key with possible modifiers -* (Shift, Ctrl, Alt, Win). It can represent both keys which are -* understood by Qt as well as those which are additionally supported -* by the underlying system (e.g. X11). -* @see KKeyNative -* @see KKeySequence -* @see KShortcut -*/ - -class KDECORE_EXPORT KKey -{ - public: - /** - * The number of flags. - * @see ModFlag - */ - enum { MOD_FLAG_COUNT = 4 }; - enum { QtWIN = (Qt::META) }; - /** - * Flags to represent the modifiers. You can combine modifiers - * by ORing them. - */ - enum ModFlag { - SHIFT = 0x01, - CTRL = 0x02, - ALT = 0x04, - WIN = 0x08 - }; - - /** - * Creates a new null KKey. - * @see clear() - * @see isNull() - * @see null() - */ - KKey(); - - /** - * Creates a new key for the given Qt key code. - * @param keyQt the qt keycode - * @see Qt::Key - */ - KKey( int keyQt ); - - /** - * Creates a new key from the first key code of the given key sequence. - * @param keySeq the key sequence that contains the key - */ - KKey( const TQKeySequence& keySeq ); - - /** - * Extracts the key from the given key event. - * @param keyEvent the key event to get the key from - */ - KKey( const TQKeyEvent* keyEvent ); - - /** - * Copy constructor. - */ - KKey( const KKey& key ); - - /** - * Creates a new key from the given description. The form of the description - * is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or - * "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and - * "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive. - * @param key the description of the key - * @see KKeyServer::Sym::init() - */ - KKey( const TQString& key ); - /** - * @internal - */ - KKey( uint key, uint mod ); - ~KKey(); - - // Initialization methods - /** - * Clears the key. The key is null after calling this function. - * @see isNull() - */ - void clear(); - - /** - * Initializes the key with the given Qt key code. - * @param keyQt the qt keycode - * @return true if successful, false otherwise - * @see Qt::Key - */ - bool init( int keyQt ); - - /** - * Initializes the key with the first key code of the given key sequence. - * @param keySeq the key sequence that contains the key - * @return true if successful, false otherwise - */ - bool init( const TQKeySequence& keySeq ); - - /** - * Initializes the key by extracting the code from the given key event. - * @param keyEvent the key event to get the key from - * @return true if successful, false otherwise - */ - bool init( const TQKeyEvent* keyEvent ); - - /** - * Copies the given key. - * @param key the key to copy - * @return true if successful, false otherwise - */ - bool init( const KKey& key ); - - /** - * Initializes the key with the given description. The form of the description - * is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or - * "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and - * "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive. - * @param key the description of the key - * @return true if successful, false otherwise - * @see KKeyServer::Sym::init() - */ - bool init( const TQString& key); - - /** - * @internal - */ - bool init( uint key, uint mod ); - - /** - * Copies the key. - */ - KKey& operator =( const KKey& key ) - { init( key ); return *this; } - - // Query methods. - /** - * Returns true if the key is null (after clear() or empty - * constructor). - * @return true if the key is null - * @see clear() - * @see null() - */ - bool isNull() const; - - /** - * @internal - */ - uint sym() const; - /** - * @internal - */ - uint modFlags() const; - - // Comparison Methods - /** - * Compares this key with the given KKey object. Returns a negative - * number if the given KKey is larger, 0 if they are equal and - * a positive number this KKey is larger. The returned value - * is the difference between the symbol or, if the symbols - * are equal, the difference between the encoded modifiers. - * @param key the key to compare with this key - * @return a negative number if the given KKey is larger, 0 if - * they are equal and a positive number this KKey is larger - */ - int compare( const KKey& key ) const; - - /** - * Compares the symbol and modifiers of both keys. - * @see compare() - */ - bool operator == ( const KKey& key ) const - { return compare( key ) == 0; } - /** - * Compares the symbol and modifiers of both keys. - * @see compare() - */ - bool operator != ( const KKey& key ) const - { return compare( key ) != 0; } - /** - * Compares the symbol and modifiers of both keys. - * @see compare() - */ - bool operator < ( const KKey& key ) const - { return compare( key ) < 0; } - - // Conversion methods. - /** - * Returns the qt key code. - * @return the qt key code or 0 if there is no key set. - * @see Qt::Key - */ - int keyCodeQt() const; - - /** - * Returns a human-readable representation of the key in the form - * "modifier+key". Note that the representation is localised, - * use toStringInternal() for cases like saving to configuration files. - * @return the string representation of the key - * @see toStringInternal() - */ - TQString toString() const; - - /** - * Returns an untranslated text representation of the key in the form - * "modifier+key", suitable e.g. for saving in configuration files. - */ - TQString toStringInternal() const; - - // Operation methods - /** - * @internal - */ - void simplify(); - - /** - * Returns a null key. - * @return the null key - * @see isNull() - * @see clear() - */ - static KKey& null(); - - /** - * Returns a user-readable representation of the given modifiers. - * @param f the modifiers to convert - * @return the string representation of the modifiers - */ - static TQString modFlagLabel( ModFlag f ); - - private: - /* - * Under X11, m_key will hold an X11 key symbol. - * For Qt/Embedded, it will hold the Qt key code. - */ - /** - * Returns the native key symbol value key. Under X11, this is the X - * keycode. Under Qt/Embedded, this is the Qt keycode. - * @see /usr/include/X11/keysymdef.h - * @see tqnamespace.h - */ - uint m_sym; - /** - * m_mod holds the - */ - uint m_mod; - - private: - friend class KKeyNative; -}; - -/** -* A KKeySequence object holds a sequence of up to 4 keys. -* Ex: Ctrl+X,I -* @see KKey -* @see KShortcut -*/ - -class KDECORE_EXPORT KKeySequence -{ - public: - /// Defines the maximum length of the key sequence - enum { MAX_KEYS = 4 }; - - /** - * Create a new null key sequence. - * @see isNull() - * @see null() - * @see clear() - */ - KKeySequence(); - - /** - * Copies the given qt key sequence. - * @param keySeq the qt key sequence to copy - */ - KKeySequence( const TQKeySequence& keySeq ); - - /** - * Create a new key sequence that only contains the given key. - * @param key the key to add - */ - KKeySequence( const KKey& key ); - - /** - * Create a new key sequence that only contains the given key. - * @param key the key to add - */ - KKeySequence( const KKeyNative& key ); - - /** - * Copies the given key sequence. - * @param keySeq the key sequence to copy - */ - KKeySequence( const KKeySequence& keySeq ); - - /** - * Creates a new key sequence that contains the given key sequence. - * The description consists of comma-separated keys as - * required by KKey::KKey(const TQString&). - * @param keySeq the description of the key - * @see KKeyServer::Sym::init() - * @see KKey::KKey(const TQString&) - */ - KKeySequence( const TQString& keySeq ); - - ~KKeySequence(); - - /** - * Clears the key sequence. The key sequence is null after calling this - * function. - * @see isNull() - */ - void clear(); - - /** - * Copies the given qt key sequence over this key sequence. - * @param keySeq the qt key sequence to copy - * @return true if successful, false otherwise - */ - bool init( const TQKeySequence& keySeq ); - - /** - * Initializes the key sequence to only contain the given key. - * @param key the key to set - * @return true if successful, false otherwise - */ - bool init( const KKey& key ); - - /** - * Initializes the key sequence to only contain the given key. - * @param key the key to set - * @return true if successful, false otherwise - */ - bool init( const KKeyNative& key ); - - /** - * Copies the given key sequence over this key sequence. - * @param keySeq the key sequence to copy - * @return true if successful, false otherwise - */ - bool init( const KKeySequence& keySeq ); - - /** - * Initializes this key sequence to contain the given key sequence. - * The description consists of comma-separated keys as - * required by KKey::KKey(const TQString&). - * @param key the description of the key - * @return true if successful, false otherwise - * @see KKeyServer::Sym::init() - * @see KKey::KKey(const TQString&) - */ - bool init( const TQString& key ); - - /** - * Copy the given key sequence into this sequence. - */ - KKeySequence& operator =( const KKeySequence& seq ) - { init( seq ); return *this; } - - /** - * Returns the number of key strokes of this sequence. - * @return the number of key strokes - * @see MAX_KEYS - */ - uint count() const; - - /** - * Return the @p i'th key of this sequence, or a null key if there - * are less then i keys. - * @param i the key to retrieve - * @return the @p i'th key, or KKey::null() if there are less - * than i keys - * @see MAX_KEYS - */ - const KKey& key( uint i ) const; - - /** - * @internal - */ - bool isTriggerOnRelease() const; - - /** - * Sets the @p i'th key of the sequence. You can not introduce gaps - * in a sequence, so you must use an @p i <= count(). Also note that - * the maximum length of a key sequence is MAX_KEYS. - * @param i the position of the new key (<= count(), <= MAX_KEYS) - * @param key the key to set - * @return true if successful, false otherwise - */ - bool setKey( uint i, const KKey& key ); - - /** - * Returns true if the key sequence is null (after clear() or empty - * constructor). - * @return true if the key sequence is null - * @see clear() - * @see null() - */ - bool isNull() const; - - /** - * Returns true if this key sequence begins with the given sequence. - * @param keySeq the key sequence to search - * @return true if this key sequence begins with the given sequence - */ - bool startsWith( const KKeySequence& keySeq ) const; - - /** - * Compares this object with the given key sequence. Returns a negative - * number if the given KKeySequence is larger, 0 if they are equal and - * a positive number this KKeySequence is larger. Key sequences are - * compared by comparing the individual keys, starting from the beginning - * until an unequal key has been found. If a sequence contains more - * keys, it is considered larger. - * @param keySeq the key sequence to compare to - * @return a negative number if the given KKeySequence is larger, 0 if - * they are equal and a positive number this KKeySequence is larger - * @see KKey::sequence - */ - int compare( const KKeySequence& keySeq ) const; - - /** - * Compares the keys of both sequences. - * @see compare() - */ - bool operator == ( const KKeySequence& seq ) const - { return compare( seq ) == 0; } - - /** - * Compares the keys of both sequences. - * @see compare() - */ - bool operator != ( const KKeySequence& seq ) const - { return compare( seq ) != 0; } - - /** - * Compares the keys of both sequences. - * @see compare() - */ - bool operator < ( const KKeySequence& seq ) const - { return compare( seq ) < 0; } - // TODO: consider adding Qt::SequenceMatch matches(...) methods for TQKeySequence equivalence - - /** - * Converts this key sequence to a TQKeySequence. - * @return the QKeySequence - */ - TQKeySequence qt() const; - - /** - * Returns the qt key code of the first key. - * @return the qt key code of the first key - * @see Qt::Key - * @see KKey::keyCodeQt() - */ - int keyCodeQt() const; - - /** - * Returns the key sequence as a number of key presses as - * returned by KKey::toString(), separated by commas. - * @return the string represenation of this key sequence - * @see KKey::toString() - */ - TQString toString() const; - - /** - * @internal - */ - TQString toStringInternal() const; - - /** - * Returns a null key sequence. - * @return the null key sequence - * @see isNull() - * @see clear() - */ - static KKeySequence& null(); - - protected: - uchar m_nKeys; - uchar m_bTriggerOnRelease; - // BCI: m_rgvar should be renamed to m_rgkey for KDE 4.0 - KKey m_rgvar[MAX_KEYS]; - - private: - class KKeySequencePrivate* d; - friend class KKeyNative; -}; - -/** -* The KShortcut class is used to represent a keyboard shortcut to an action. -* A shortcut is normally a single key with modifiers, such as Ctrl+V. -* A KShortcut object may also contain an alternate key which will also -* activate the action it's associated to, as long as no other actions have -* defined that key as their primary key. Ex: Ctrl+V;Shift+Insert. -* -* This can be used to add additional accelerators to a KAction. For example, -* the below code binds the escape key to the close action. -* -* \code -* KAction *closeAction = KStdAction::close( this, TQT_SLOT( close() ), actionCollection() ); -* KShortcut closeShortcut = closeAction->shortcut(); -* closeShortcut.append( KKey(Key_Escape)); -* closeAction->setShortcut(closeShortcut); -* \endcode -* -* Note that a shortcut cannot have more than 2 key combinations associated with it, so the above -* code would not do anything (and append() would return false) if the closeAction already had -* an key and alternate key. -* -*/ - -class KDECORE_EXPORT KShortcut -{ - public: - /** - * The maximum number of key sequences that can be contained in - * a KShortcut. - */ - enum { MAX_SEQUENCES = 2 }; - - /** - * Creates a new null shortcut. - * @see null() - * @see isNull() - * @see clear() - */ - KShortcut(); - - /** - * Creates a new shortcut with the given Qt key code - * as the only key sequence. - * @param keyQt the qt keycode - * @see Qt::Key - */ - KShortcut( int keyQt ); - - /** - * Creates a new shortcut that contains only the given qt key - * sequence. - * @param keySeq the qt key sequence to add - */ - KShortcut( const TQKeySequence& keySeq ); - - /** - * Creates a new shortcut that contains only the given key - * in its only sequence. - * @param key the key to add - */ - KShortcut( const KKey& key ); - - /** - * Creates a new shortcut that contains only the given key - * sequence. - * @param keySeq the key sequence to add - */ - KShortcut( const KKeySequence& keySeq ); - - /** - * Copies the given shortcut. - * @param shortcut the shortcut to add - */ - KShortcut( const KShortcut& shortcut ); - - /** - * Creates a new key sequence that contains the given key sequence. - * The description consists of semicolon-separated keys as - * used in KKeySequence::KKeySequence(const TQString&). - * @param shortcut the description of the key - * @see KKeySequence::KKeySequence(const TQString&) - */ - KShortcut( const char* shortcut ); - - /** - * Creates a new key sequence that contains the given key sequence. - * The description consists of semicolon-separated keys as - * used in KKeySequence::KKeySequence(const TQString&). - * @param shortcut the description of the key - * @see KKeySequence::KKeySequence(const TQString&) - */ - KShortcut( const TQString& shortcut ); - ~KShortcut(); - - /** - * Clears the shortcut. The shortcut is null after calling this - * function. - * @see isNull() - */ - void clear(); - - /** - * Initializes the shortcut with the given Qt key code - * as the only key sequence. - * @param keyQt the qt keycode - * @see Qt::Key - */ - bool init( int keyQt ); - - /** - * Initializes the shortcut with the given qt key sequence. - * @param keySeq the qt key sequence to add - */ - bool init( const TQKeySequence& keySeq ); - - /** - * Initializes the shortcut with the given key as its only sequence. - * @param key the key to add - */ - bool init( const KKey& key ); - - /** - * Initializes the shortcut with the given qt key sequence. - * @param keySeq the qt key sequence to add - */ - bool init( const KKeySequence& keySeq ); - - /** - * Copies the given shortcut. - * @param shortcut the shortcut to add - */ - bool init( const KShortcut& shortcut ); - - /** - * Initializes the key sequence with the given key sequence. - * The description consists of semicolon-separated keys as - * used in KKeySequence::KKeySequence(const TQString&). - * @param shortcut the description of the key - * @see KKeySequence::KKeySequence(const TQString&) - */ - bool init( const TQString& shortcut ); - - /** - * Copies the given shortcut over this shortcut. - */ - KShortcut& operator =( const KShortcut& cut ) - { init( cut ); return *this; } - - /** - * Returns the number of sequences that are in this - * shortcut. - * @return the number of sequences - * MAX_SEQUENCES - */ - uint count() const; - - /** - * Returns the @p i'th key sequence of this shortcut. - * @param i the number of the key sequence to retrieve - * @return the @p i'th sequence or KKeySequence::null() if - * there are less than @p i key sequences - * MAX_SEQUENCES - */ - const KKeySequence& seq( uint i ) const; - - /** - * Returns the key code of the first key sequence, or - * null if there is no first key sequence. - * @return the key code of the first sequence's first key - * @see Qt::Key - * @see KKeySequence::keyCodeQt() - */ - int keyCodeQt() const; - - /** - * Returns true if the shortcut is null (after clear() or empty - * constructor). - * @return true if the shortcut is null - * @see clear() - * @see null() - */ - bool isNull() const; - - /** - * Compares this object with the given shortcut. Returns a negative - * number if the given shortcut is larger, 0 if they are equal and - * a positive number this shortcut is larger. Shortcuts are - * compared by comparing the individual key sequences, starting from the - * beginning until an unequal key sequences has been found. If a shortcut - * contains more key sequences, it is considered larger. - * @param shortcut the shortcut to compare to - * @return a negative number if the given KShortcut is larger, 0 if - * they are equal and a positive number this KShortcut is larger - * @see KKey::compare() - * @see KKeyShortcut::compare() - */ - int compare( const KShortcut& shortcut ) const; - - /** - * Compares the sequences of both shortcuts. - * @see compare() - */ - bool operator == ( const KShortcut& cut ) const - { return compare( cut ) == 0; } - - /** - * Compares the sequences of both shortcuts. - * @see compare() - */ - bool operator != ( const KShortcut& cut ) const - { return compare( cut ) != 0; } - - /** - * Compares the sequences of both shortcuts. - * @see compare() - */ - bool operator < ( const KShortcut& cut ) const - { return compare( cut ) < 0; } - - /** - * Checks whether this shortcut contains a sequence that starts - * with the given key. - * @param key the key to check - * @return true if a key sequence starts with the key - */ - bool contains( const KKey& key ) const; - - /** - * Checks whether this shortcut contains a sequence that starts - * with the given key. - * @param key the key to check - * @return true if a key sequence starts with the key - */ - bool contains( const KKeyNative& key ) const; - - /** - * Checks whether this shortcut contains the given sequence. - * @param keySeq the key sequence to check - * @return true if the shortcut has the given key sequence - */ - bool contains( const KKeySequence& keySeq ) const; - - /** - * Sets the @p i 'th key sequence of the shortcut. You can not introduce - * gaps in the list of sequences, so you must use an @p i <= count(). - * Also note that the maximum number of key sequences is MAX_SEQUENCES. - * @param i the position of the new key sequence(0 <= i <= count(), 0 <= i < MAX_SEQUENCES) - * @param keySeq the key sequence to set - * @return true if successful, false otherwise - */ - bool setSeq( uint i, const KKeySequence& keySeq ); - - /** - * Appends the given key sequence. This sets it as either the keysequence or - * the alternate keysequence. If the shortcut already has MAX_SEQUENCES - * sequences then this call does nothing, and returns false. - * - * @param keySeq the key sequence to add - * @return true if successful, false otherwise - * @see setSeq() - */ - bool append( const KKeySequence& keySeq ); - - /** - * Removes the given key sequence from this shortcut - * @param keySeq the key sequence to remove - * @since 3.3 - */ - void remove( const KKeySequence& keySeq ); - - /** - * Appends the given key - * @param spec the key to add - * @return true if successful, false otherwise - * @see setSeq() - * @see MAX_SEQUENCES - * @since 3.2 - */ - bool append( const KKey& spec ); - - /** - * Appends the sequences from the given shortcut. - * @param cut the shortcut to append - * @return true if successful, false otherwise - * @see MAX_SEQUENCES - * @since 3.2 - */ - bool append( const KShortcut& cut ); - - /** - * Converts this shortcut to a key sequence. The first key sequence - * will be taken. - */ - operator TQKeySequence () const; - - /** - * Returns a description of the shortcut as semicolon-separated - * ket sequences, as returned by KKeySequence::toString(). - * @return the string represenation of this shortcut - * @see KKey::toString() - * @see KKeySequence::toString() - */ - TQString toString() const; - - /** - * @internal - */ - TQString toStringInternal( const KShortcut* pcutDefault = 0 ) const; - - /** - * Returns a null shortcut. - * @return the null shortcut - * @see isNull() - * @see clear() - */ - static KShortcut& null(); - - protected: - uint m_nSeqs; - KKeySequence m_rgseq[MAX_SEQUENCES]; - - private: - class KShortcutPrivate* d; - friend class KKeyNative; - -#ifndef KDE_NO_COMPAT - public: - operator int () const { return keyCodeQt(); } -#endif -}; - -#endif // __KSHORTCUT_H diff --git a/kdecore/kshortcutlist.cpp b/kdecore/kshortcutlist.cpp deleted file mode 100644 index 865bdc257..000000000 --- a/kdecore/kshortcutlist.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include <tqstring.h> -#include <tqvariant.h> - -#include <kaccel.h> -#include "kaccelaction.h" -#include <kconfig.h> -#include <kdebug.h> -#include <kglobal.h> -#include <kglobalaccel.h> -#include <kinstance.h> -#include <kshortcut.h> -#include "kshortcutlist.h" - -//--------------------------------------------------------------------- -// KShortcutList -//--------------------------------------------------------------------- - -KShortcutList::KShortcutList() -{ -} - -KShortcutList::~KShortcutList() -{ -} - -bool KShortcutList::isGlobal( uint ) const -{ - return false; -} - -int KShortcutList::index( const TQString& sName ) const -{ - uint nSize = count(); - for( uint i = 0; - i < nSize; - ++i ) - if( name( i ) == sName ) - return i; - return -1; -} - -int KShortcutList::index( const KKeySequence& seq ) const -{ - if( seq.isNull() ) - return -1; - - uint nSize = count(); - for( uint i = 0; i < nSize; i++ ) { - if( shortcut(i).contains( seq ) ) - return i; - } - - return -1; -} - -const KInstance* KShortcutList::instance() const -{ - return 0; -} - -TQVariant KShortcutList::getOther( Other, uint ) const -{ - return TQVariant(); -} - -bool KShortcutList::setOther( Other, uint, TQVariant ) -{ - return false; -} - -bool KShortcutList::readSettings( const TQString& sConfigGroup, KConfigBase* pConfig ) -{ - kdDebug(125) << "KShortcutList::readSettings( \"" << sConfigGroup << "\", " << pConfig << " ) start" << endl; - if( !pConfig ) - pConfig = KGlobal::config(); - TQString sGroup = (!sConfigGroup.isEmpty()) ? sConfigGroup : TQString("Shortcuts"); - - // If the config file still has the old group name: - // FIXME: need to rename instead? -- and don't do this if hasGroup( "Shortcuts" ). - if( sGroup == "Shortcuts" && pConfig->hasGroup( "Keys" ) ) { - readSettings( "Keys", pConfig ); - } - - kdDebug(125) << "\treadSettings( \"" << sGroup << "\", " << pConfig << " )" << endl; - if( !pConfig->hasGroup( sGroup ) ) - return true; - KConfigGroupSaver cgs( pConfig, sGroup ); - - uint nSize = count(); - for( uint i = 0; i < nSize; i++ ) { - if( isConfigurable(i) ) { - TQString sEntry = pConfig->readEntry( name(i) ); - if( !sEntry.isEmpty() ) { - if( sEntry == "none" ) - setShortcut( i, KShortcut() ); - else - setShortcut( i, KShortcut(sEntry) ); - } - else // default shortcut - setShortcut( i, shortcutDefault(i) ); - kdDebug(125) << "\t" << name(i) << " = '" << sEntry << "'" << endl; - } - } - - kdDebug(125) << "KShortcutList::readSettings done" << endl; - return true; -} - -bool KShortcutList::writeSettings( const TQString &sConfigGroup, KConfigBase* pConfig, bool bWriteAll, bool bGlobal ) const -{ - kdDebug(125) << "KShortcutList::writeSettings( " << sConfigGroup << ", " << pConfig << ", " << bWriteAll << ", " << bGlobal << " )" << endl; - if( !pConfig ) - pConfig = KGlobal::config(); - - TQString sGroup = (!sConfigGroup.isEmpty()) ? sConfigGroup : TQString("Shortcuts"); - - // If it has the deprecated group [Keys], remove it - if( pConfig->hasGroup( "Keys" ) ) - pConfig->deleteGroup( "Keys", true ); - - KConfigGroupSaver cs( pConfig, sGroup ); - - uint nSize = count(); - for( uint i = 0; i < nSize; i++ ) { - if( isConfigurable(i) ) { - const TQString& sName = name(i); - bool bConfigHasAction = !pConfig->readEntry( sName ).isEmpty(); - bool bSameAsDefault = (shortcut(i) == shortcutDefault(i)); - // If we're using a global config or this setting - // differs from the default, then we want to write. - if( bWriteAll || !bSameAsDefault ) { - TQString s = shortcut(i).toStringInternal(); - if( s.isEmpty() ) - s = "none"; - kdDebug(125) << "\twriting " << sName << " = " << s << endl; - pConfig->writeEntry( sName, s, true, bGlobal ); - } - // Otherwise, this key is the same as default - // but exists in config file. Remove it. - else if( bConfigHasAction ) { - kdDebug(125) << "\tremoving " << sName << " because == default" << endl; - pConfig->deleteEntry( sName, false, bGlobal ); - } - } - } - - pConfig->sync(); - return true; -} - -//--------------------------------------------------------------------- -// KAccelShortcutList -//--------------------------------------------------------------------- - -class KAccelShortcutListPrivate -{ - public: - TQString m_configGroup; -}; - -KAccelShortcutList::KAccelShortcutList( KAccel* pAccel ) -: m_actions( pAccel->actions() ) -{ - d=new KAccelShortcutListPrivate; - m_bGlobal = false; - d->m_configGroup=pAccel->configGroup(); -} - -KAccelShortcutList::KAccelShortcutList( KGlobalAccel* pAccel ) -: m_actions( pAccel->actions() ) -{ - d=new KAccelShortcutListPrivate; - m_bGlobal = true; - d->m_configGroup=pAccel->configGroup(); -} - -KAccelShortcutList::KAccelShortcutList( KAccelActions& actions, bool bGlobal ) -: m_actions( actions ) -{ - d=new KAccelShortcutListPrivate; - m_bGlobal = bGlobal; -} - - -KAccelShortcutList::~KAccelShortcutList() - { delete d;} -uint KAccelShortcutList::count() const - { return m_actions.count(); } -TQString KAccelShortcutList::name( uint i ) const - { return m_actions.actionPtr(i)->name(); } -TQString KAccelShortcutList::label( uint i ) const - { return m_actions.actionPtr(i)->label(); } -TQString KAccelShortcutList::whatsThis( uint i ) const - { return m_actions.actionPtr(i)->whatsThis(); } -const KShortcut& KAccelShortcutList::shortcut( uint i ) const - { return m_actions.actionPtr(i)->shortcut(); } -const KShortcut& KAccelShortcutList::shortcutDefault( uint i ) const - { return m_actions.actionPtr(i)->shortcutDefault(); } -bool KAccelShortcutList::isConfigurable( uint i ) const - { return m_actions.actionPtr(i)->isConfigurable(); } -bool KAccelShortcutList::setShortcut( uint i, const KShortcut& cut ) - { return m_actions.actionPtr(i)->setShortcut( cut ); } -TQVariant KAccelShortcutList::getOther( Other, uint ) const - { return TQVariant(); } -bool KAccelShortcutList::isGlobal( uint ) const - { return m_bGlobal; } -bool KAccelShortcutList::setOther( Other, uint, TQVariant ) - { return false; } -bool KAccelShortcutList::save() const - { return writeSettings( d->m_configGroup ); } - -void KShortcutList::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KAccelShortcutList::virtual_hook( int id, void* data ) -{ KShortcutList::virtual_hook( id, data ); } - -void KStdAccel::ShortcutList::virtual_hook( int id, void* data ) -{ KShortcutList::virtual_hook( id, data ); } - diff --git a/kdecore/kshortcutlist.h b/kdecore/kshortcutlist.h deleted file mode 100644 index 4896bc30a..000000000 --- a/kdecore/kshortcutlist.h +++ /dev/null @@ -1,295 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Ellis Whitehead <ellis@kde.org> - - 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 __KSHORTCUTLIST_H -#define __KSHORTCUTLIST_H - -#include <tqglobal.h> // For uint -#include <tqstring.h> -#include "kdelibs_export.h" - -class TQVariant; -class KConfigBase; -class KInstance; -class KKeySequence; -class KShortcut; - -/********************************************************************** -* This is a wrapper class which allows a function to use one interface -* to KActionCollection, KAccelActions, and KActionPtrList. -**********************************************************************/ - -/** - * KShortcutList is an abstract base class for - * KAccelShortcutList and KStdAccel::ShortcutList. It gives - * you an unified interface for accessing the accelerator lists - * of KAccel (using KAccelShortcutList), - * KGlobalAccel (using KAccelShortcutList), and - * KStdAccel (using KStdAccel::ShortcutList). - * - * @short Base class for accessing accelerator lists - */ -class KDECORE_EXPORT KShortcutList -{ - public: - /** - * Default constructor. - */ - KShortcutList(); - virtual ~KShortcutList(); - - /** - * Returns the number of entries. - * @return the number of entries - */ - virtual uint count() const = 0; - - /** - * Returns the name of the shortcut with the given @p index. - * @param index the index of the shortcut (must be < count()) - * @return the name of the shortcut - */ - virtual TQString name( uint index ) const = 0; - - /** - * Returns the (i18n'd) label of the shortcut with the given @p index. - * @param index the index of the shortcut (must be < count()) - * @return the label (i18n'd) of the shortcut - */ - virtual TQString label( uint index ) const = 0; - - /** - * Returns the (i18n'd) What's This text of the shortcut with the given @p index. - * @param index the index of the shortcut (must be < count()) - * @return the What's This text (i18n'd) of the shortcut - */ - virtual TQString whatsThis( uint index ) const = 0; - - // TODO KDE4: add virtual TQString toolTip( uint index ) const = 0 - // Will then be used by the listview in kkeydialog - - /** - * Returns the shortcut with the given @p index. - * @param index the index of the shortcut (must be < count()) - * @return the shortcut - * @see shortcutDefault() - */ - virtual const KShortcut& shortcut( uint index ) const = 0; - - /** - * Returns default shortcut with the given @p index. - * @param index the index of the shortcut (must be < count()) - * @return the default shortcut - * @see shortcut() - */ - virtual const KShortcut& shortcutDefault( uint index ) const = 0; - - /** - * Checks whether the shortcut with the given @p index is configurable. - * @param index the index of the shortcut (must be < count()) - * @return true if configurable, false otherwise - */ - virtual bool isConfigurable( uint index ) const = 0; - - /** - * Sets the shortcut of the given entry - * @param index the index of the shortcut (must be < count()) - * @param shortcut the shortcut - */ - virtual bool setShortcut( uint index, const KShortcut &shortcut ) = 0; - - /** - * Checks whether the shortcut with the given @p index is saved in the - * global configuration. - * @param index the index of the shortcut (must be < count()) - * @return true if global, false otherwise - */ - virtual bool isGlobal( uint index ) const; - - /** - * Returns the index of the shortcut with he given name. - * @param sName the name of the shortcut to search - * @return the index of the shortcut, of -1 if not found - */ - virtual int index( const TQString& sName ) const; - - /** - * Returns the index of the shortcut with he given key sequence. - * @param keySeq the key sequence to search for - * @return the index of the shortcut, of -1 if not found - */ - virtual int index( const KKeySequence& keySeq ) const; - - /** - * The KInstance. - * @return the KInstance of the list, can be 0 if not available - */ - virtual const KInstance* instance() const; - - // These are here in order to handle expansion. - enum Other { }; - /** \internal */ - virtual TQVariant getOther( Other, uint index ) const = 0; - /** \internal */ - virtual bool setOther( Other, uint index, TQVariant ) = 0; - - /** - * Save the shortcut list. - * @return true if successful, false otherwise - */ - virtual bool save() const = 0; - - /** - * Loads the shortcuts from the given configuration file. - * - * @param sConfigGroup the group in the configuration file - * @param pConfig the configuration file to load from - * @return true if successful, false otherwise - */ - virtual bool readSettings( const TQString& sConfigGroup = TQString::null, KConfigBase* pConfig = 0 ); - - /** - * Writes the shortcuts to the given configuration file. - * - * @param sConfigGroup the group in the configuration file - * @param pConfig the configuration file to save to - * @param bWriteAll true to write all actions - * @param bGlobal true to write to the global configuration file - * @return true if successful, false otherwise - */ - virtual bool writeSettings( const TQString& sConfigGroup = TQString::null, KConfigBase* pConfig = 0, - bool bWriteAll = false, bool bGlobal = false ) const; - - protected: - /// used to extend the interface with virtuals without breaking binary compatibility - virtual void virtual_hook( int id, void* data ); - private: - class KShortcutListPrivate* d; -}; - -//--------------------------------------------------------------------- -// KAccelShortcutList -//--------------------------------------------------------------------- - -class KAccel; -class KAccelActions; -class KGlobalAccel; - -/** - * KShortcutList implementation to access KAccel and - * KGlobalAccel lists. - */ -class KDECORE_EXPORT KAccelShortcutList : public KShortcutList -{ - public: - /** - * Creates a new KShortcutList that accesses the given KAccel. - * @param accel the accelerators to access - */ - KAccelShortcutList( KAccel* accel ); - - /** - * Creates a new KShortcutList that accesses the given - * KGlobalAccel. - * @param accel the accelerators to access - */ - KAccelShortcutList( KGlobalAccel* accel ); - - /** - * @internal - * Creates a new KShortcutList that accesses the given - * KAccelActions collection. - * @param actions the actions to access - * @param bGlobal true to save the actions in the global - * configuration file - */ - KAccelShortcutList( KAccelActions &actions, bool bGlobal ); - virtual ~KAccelShortcutList(); - - virtual uint count() const; - virtual TQString name( uint index ) const; - virtual TQString label( uint index ) const; - virtual TQString whatsThis( uint index ) const; - virtual const KShortcut& shortcut( uint index ) const; - virtual const KShortcut& shortcutDefault( uint index ) const; - virtual bool isConfigurable( uint index ) const; - virtual bool setShortcut( uint index , const KShortcut& shortcut ); - virtual bool isGlobal( uint index ) const; - - /** \internal */ - virtual TQVariant getOther( Other, uint index ) const; - /** \internal */ - virtual bool setOther( Other, uint index, TQVariant ); - - virtual bool save() const; - - protected: - /** Actions (collection) for this shortcut list. Set by constructor. */ - KAccelActions& m_actions; - /** Is this shortcut list global? Access through isGlobal() */ - bool m_bGlobal; - - protected: - virtual void virtual_hook( int id, void* data ); - private: - class KAccelShortcutListPrivate* d; -}; - -namespace KStdAccel { -//--------------------------------------------------------------------- -// ShortcutList -//--------------------------------------------------------------------- - -/** - * KShortcutList implementation that accesses KStdAccel - * actions. - */ -class KDECORE_EXPORT ShortcutList : public KShortcutList -{ - public: - /** - * Creates a new ShortcutList. - */ - ShortcutList(); - virtual ~ShortcutList(); - - virtual uint count() const; - virtual TQString name( uint index ) const; - virtual TQString label( uint index ) const; - virtual TQString whatsThis( uint index ) const; - virtual const KShortcut& shortcut( uint index ) const; - virtual const KShortcut& shortcutDefault( uint index ) const; - virtual bool isConfigurable( uint index ) const; - virtual bool setShortcut( uint index , const KShortcut& shortcut ); - - /** \internal */ - virtual TQVariant getOther( Other, uint index ) const; - /** \internal */ - virtual bool setOther( Other, uint index, TQVariant ); - - virtual bool save() const; - - protected: - virtual void virtual_hook( int id, void* data ); - private: - class ShortcutListPrivate* d; -}; -} - -#endif // __KSHORTCUTLIST_H diff --git a/kdecore/kshortcutmenu.cpp b/kdecore/kshortcutmenu.cpp deleted file mode 100644 index 3df389f07..000000000 --- a/kdecore/kshortcutmenu.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (c) 2002 Ellis Whitehead <ellis@kde.org> - - 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. -*/ - -#include <tqkeysequence.h> -#include <tqlabel.h> -#include <tqpopupmenu.h> - -#include "kaccelaction.h" -#include <kdebug.h> -#include <kglobalsettings.h> -#include "kshortcutmenu.h" -//#include <kkeynative.h> - -KShortcutMenu::KShortcutMenu( TQWidget* pParent, KAccelActions* pActions, KKeySequence seq ) -: TQPopupMenu( pParent ), - m_pActions( pActions ), - m_seq( seq ) -{ - kdDebug() << seq.toStringInternal() << endl; - - TQFont fontTitle = KGlobalSettings::menuFont(); - fontTitle.setBold( true ); - - pTitle = new TQLabel( "", (TQWidget*)0 ); - pTitle->setFont( fontTitle ); - pTitle->setFrameShape( TQFrame::Panel ); - - insertItem( pTitle ); -} - -bool KShortcutMenu::insertAction( uint iAction, KKeySequence seq ) -{ - KAccelAction* pAction = m_pActions->actionPtr( iAction ); - - if( pAction ) { - insertItem( "", iAction ); - m_seqs[indexOf(iAction)] = seq; - return true; - } else - return false; -} - - -void KShortcutMenu::updateShortcuts() -{ - pTitle->setText( m_seq.toString() + ",..." ); - - for( uint iItem = 1; iItem < count(); iItem++ ) { - int iAction = idAt( iItem ); - if( iAction >= 0 ) { - KAccelAction* pAction = m_pActions->actionPtr( iAction ); - if( pAction ) { - KKeySequence seq = m_seqs[iItem]; - TQString sSeq = seq.key(m_seq.count()).toString(); - for( uint iKey = m_seq.count() + 1; iKey < seq.count(); iKey++ ) - sSeq += TQString(",") + seq.key(iKey).toString(); - - kdDebug(125) << "seq = " << seq.toStringInternal() << " sSeq = " << sSeq << endl; - changeItem( iAction, pAction->label() + "\t" + sSeq ); - } - } - } -} - -void KShortcutMenu::keyPressEvent( TQKeyEvent* pEvent ) -{ - kdDebug() << "keypress; " << pEvent->key() << endl; - KKey key( pEvent ); - - switch( pEvent->key() ) { - case TQ_Key_Shift: - case TQ_Key_Control: - case TQ_Key_Alt: - case TQ_Key_Meta: - case TQ_Key_Super_L: - case TQ_Key_Super_R: - case TQ_Key_Hyper_L: - case TQ_Key_Hyper_R: - break; - default: - int iItem = searchForKey( key ); - // If key not found, look for unmodified version. - if( iItem == -1 ) { - key = pEvent->key(); - iItem = searchForKey( key ); - } - - if( iItem == -1 ) { - // Let Up and Down keys navigate menu, - // And permit Enter, Return to select the item. - if( pEvent->key() == Qt::Key_Up || pEvent->key() == Qt::Key_Down || - pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return ) - TQPopupMenu::keyPressEvent( pEvent ); - else - close(); - } - else if( iItem == 0 ) - keepItemsMatching( key ); - else - activateItemAt( iItem ); - } -} - -int KShortcutMenu::searchForKey( KKey key ) -{ - int iItemFound = -1; // -1 indicates no match - uint iKey = m_seq.count(); - - for( uint iItem = 1; iItem < count(); iItem++ ) { - if( m_seqs.contains( iItem ) ) { - KKey keyItem = m_seqs[iItem].key( iKey ); - //kdDebug(125) << "iItem = " << iItem << " key = " << key.toStringInternal() << " keyItem = " << keyItem.toStringInternal() << endl; - if( key == keyItem ) { - if( iItemFound == -1 ) - iItemFound = iItem; - else - return 0; // 0 indicates duplicate matches - } - } - } - - return iItemFound; -} - -void KShortcutMenu::keepItemsMatching( KKey key ) -{ - kdDebug(125) << "MyAccel::keepItemsMatching( " << key.toStringInternal() << " )" << endl; - - uint iKey = m_seq.count(); - m_seq.setKey( iKey, key ); - - for( uint iItem = 1; iItem < count(); iItem++ ) { - if( m_seqs.contains( iItem ) ) { - KKey keyItem = m_seqs[iItem].key( iKey ); - if( key != keyItem ) { - m_seqs.remove( iItem ); - removeItemAt( iItem-- ); - } - } - } - - updateShortcuts(); -} - -#include "kshortcutmenu.moc" diff --git a/kdecore/kshortcutmenu.h b/kdecore/kshortcutmenu.h deleted file mode 100644 index aa641e201..000000000 --- a/kdecore/kshortcutmenu.h +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2002 Ellis Whitehead <ellis@kde.org> - - 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 __KSHORTCUTMENU_H -#define __KSHORTCUTMENU_H - -#include <tqmap.h> -#include <tqpopupmenu.h> - -#include "kshortcut.h" - -class TQLabel; - -class KAccelActions; - -/** - * @internal - */ -class KDECORE_EXPORT KShortcutMenu : public TQPopupMenu -{ - Q_OBJECT - public: - KShortcutMenu( TQWidget* pParent, KAccelActions* pActions, KKeySequence seq ); - - bool insertAction( uint iAction, KKeySequence seq ); - - void updateShortcuts(); - - protected: - void keyPressEvent( TQKeyEvent* pEvent ); - - private: - int searchForKey( KKey key ); - void keepItemsMatching( KKey key ); - - private: - typedef TQMap<uint, KKeySequence> IndexToKKeySequence; - - KAccelActions* m_pActions; - KKeySequence m_seq; - TQLabel* pTitle; - IndexToKKeySequence m_seqs; -}; - -#endif // __KSHORTCUTMENU_H diff --git a/kdecore/ksimpleconfig.cpp b/kdecore/ksimpleconfig.cpp deleted file mode 100644 index 15597826d..000000000 --- a/kdecore/ksimpleconfig.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - 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. -*/ -// $Id$ - -#include <config.h> - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include <stdlib.h> -#include <unistd.h> - -#include <tqfileinfo.h> -#include <tqdir.h> - -#include "kglobal.h" -#include "kstandarddirs.h" -#include "kconfigbackend.h" - -#include "ksimpleconfig.h" - -KSimpleConfig::KSimpleConfig(const TQString &fileName, bool bReadOnly) - : KConfig(TQString::tqfromLatin1(""), bReadOnly, false) -{ - // the difference between KConfig and KSimpleConfig is just that - // for KSimpleConfig an absolute filename is guaranteed - if (!fileName.isNull() && TQDir::isRelativePath(fileName)) { - backEnd->changeFileName( KGlobal::dirs()-> - saveLocation("config", TQString::null, !bReadOnly)+fileName, "config", false); - } else { - backEnd->changeFileName(fileName, "config", false); - } - setReadOnly( bReadOnly ); - reparseConfiguration(); -} - -KSimpleConfig::KSimpleConfig(KConfigBackEnd *backEnd, bool bReadOnly) - : KConfig(backEnd, bReadOnly) -{} - -KSimpleConfig::~KSimpleConfig() -{ - // we need to call the KSimpleConfig version of sync. Relying on the - // regular KConfig sync is bad, because the KSimpleConfig sync has - // different behavior. Syncing here will insure that the sync() call - // in the KConfig destructor doesn't actually do anything. - sync(); -} - -void KSimpleConfig::sync() -{ - if (isReadOnly()) - return; - backEnd->sync(false); - - if (isDirty()) - rollback(); -} - -void KSimpleConfig::virtual_hook( int id, void* data ) -{ KConfig::virtual_hook( id, data ); } - -#include "ksimpleconfig.moc" diff --git a/kdecore/ksimpleconfig.h b/kdecore/ksimpleconfig.h deleted file mode 100644 index 89d380512..000000000 --- a/kdecore/ksimpleconfig.h +++ /dev/null @@ -1,81 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - - 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 _KSIMPLECONFIG_H -#define _KSIMPLECONFIG_H - -#include "kconfig.h" - -class KSimpleConfigPrivate; - -/** - * KDE Configuration entries - * - * This is a trivial extension of KConfig for applications that need - * only one configuration file and no default system. - * A difference with KConfig is that when the data in memory is written back - * it is not merged with what is on disk. - * Whatever is in memory simply replaces what is on disk entirely. - * - * @author Kalle Dalheimer <kalle@kde.org>, Preston Brown <pbrown@kde.org> - * @see KConfigBase KConfig - * @short KDE Configuration Management class with deletion ability - */ -class KDECORE_EXPORT KSimpleConfig : public KConfig -{ - Q_OBJECT - -public: - /** - * Construct a KSimpleConfig object and make it either read-write - * or read-only. - * - * @param fileName The file used for saving the config data. Either - * a full path can be specified or just the filename. - * If only a filename is specified, the default - * directory for "config" files is used. - * @param bReadOnly Whether the object should be read-only. - */ - KSimpleConfig( const TQString &fileName, bool bReadOnly = false); - - KSimpleConfig(KConfigBackEnd *backEnd, bool bReadOnly = false); - - /** - * Destructor. - * - * Writes back any dirty configuration entries. - */ - virtual ~KSimpleConfig(); - - virtual void sync(); - -private: - - // copy-construction and assignment are not allowed - KSimpleConfig( const KSimpleConfig& ); - KSimpleConfig& operator= ( const KSimpleConfig& rConfig ); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KSimpleConfigPrivate *d; -}; - -#endif diff --git a/kdecore/ksock.cpp b/kdecore/ksock.cpp deleted file mode 100644 index 10c694512..000000000 --- a/kdecore/ksock.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 1997 Torben Weis (weis@kde.org) - * - * $Id$ - * - * 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. - **/ - -#include <config.h> - -#include <sys/types.h> -#include <sys/stat.h> -// on Linux/libc5, this includes linux/socket.h where SOMAXCONN is defined -#include <sys/socket.h> -#include <sys/resource.h> -#include <sys/time.h> -#include <sys/un.h> -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif -extern "C" { -#include <netinet/in.h> - -#include <arpa/inet.h> -} - -#define KSOCK_NO_BROKEN -#include "kdebug.h" -#include "ksock.h" -#include "kextsock.h" -#include "ksockaddr.h" - -#include "ksocks.h" - -extern "C" { -#include <errno.h> -#include <fcntl.h> - -#ifdef HAVE_GETADDRINFO -#include <netdb.h> -#endif - -// defines MAXDNAME under Solaris -#include <arpa/nameser.h> -#include <resolv.h> -} -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <signal.h> -#include <unistd.h> -#include <assert.h> - -#ifdef HAVE_SYSENT_H -#include <sysent.h> -#endif - -#if TIME_WITH_SYS_TIME -#include <time.h> -#endif - - -// Play it safe, use a reasonable default, if SOMAXCONN was nowhere defined. -#ifndef SOMAXCONN -#warning Your header files do not seem to support SOMAXCONN -#define SOMAXCONN 5 -#endif - -#include <tqapplication.h> -#include <tqsocketnotifier.h> - -#include "netsupp.h" // leave this last - -#ifdef __CYGWIN__ -#include "tqwindowdefs.h" -#endif - -class KSocketPrivate -{ -public: - TQSocketNotifier *readNotifier; - TQSocketNotifier *writeNotifier; - - KSocketPrivate() : - readNotifier(0), writeNotifier(0) - { } -}; - -// I moved this into here so we could accurately detect the domain, for -// posterity. Really. -KSocket::KSocket( int _sock) - : sock(_sock), d(new KSocketPrivate) -{ - struct sockaddr_in sin; - ksocklen_t len = sizeof(sin); - - memset(&sin, 0, len); - - // getsockname will fill in all the appropriate details, and - // since sockaddr_in will exist everywhere and is somewhat compatible - // with sockaddr_in6, we can use it to avoid needless ifdefs. - KSocks::self()->getsockname(_sock, (struct sockaddr *)&sin, &len); -} - -KSocket::KSocket( const char *_host, unsigned short int _port, int _timeout ) : - sock( -1 ), d(new KSocketPrivate) -{ - connect( _host, _port, _timeout ); -} - -KSocket::KSocket( const char *_path ) : - sock( -1 ), d(new KSocketPrivate) -{ - connect( _path ); -} - -void KSocket::enableRead( bool _state ) -{ - if ( _state ) - { - if ( !d->readNotifier ) - { - d->readNotifier = new TQSocketNotifier( sock, TQSocketNotifier::Read ); - TQObject::connect( d->readNotifier, TQT_SIGNAL( activated(int) ), this, TQT_SLOT( slotRead(int) ) ); - } - else - d->readNotifier->setEnabled( true ); - } - else if ( d->readNotifier ) - d->readNotifier->setEnabled( false ); -} - -void KSocket::enableWrite( bool _state ) -{ - if ( _state ) - { - if ( !d->writeNotifier ) - { - d->writeNotifier = new TQSocketNotifier( sock, TQSocketNotifier::Write ); - TQObject::connect( d->writeNotifier, TQT_SIGNAL( activated(int) ), this, - TQT_SLOT( slotWrite(int) ) ); - } - else - d->writeNotifier->setEnabled( true ); - } - else if ( d->writeNotifier ) - d->writeNotifier->setEnabled( false ); -} - -void KSocket::slotRead( int ) -{ - char buffer[2]; - - int n = recv( sock, buffer, 1, MSG_PEEK ); - if ( n <= 0 ) - emit closeEvent( this ); - else - emit readEvent( this ); -} - -void KSocket::slotWrite( int ) -{ - emit writeEvent( this ); -} - -/* - * Connects the PF_UNIX domain socket to _path. - */ -bool KSocket::connect( const char *_path ) -{ - KExtendedSocket ks(TQString::null, _path, KExtendedSocket::unixSocket); - - ks.connect(); - sock = ks.fd(); - ks.release(); - - return sock >= 0; -} - -/* - * Connects the socket to _host, _port. - */ -bool KSocket::connect( const TQString& _host, unsigned short int _port, int _timeout ) -{ - KExtendedSocket ks(_host, _port, KExtendedSocket::inetSocket); - ks.setTimeout(_timeout, 0); - - ks.connect(); - sock = ks.fd(); - ks.release(); - - return sock >= 0; -} - -// only for doxygen - the define is always true as defined above -#ifdef KSOCK_NO_BROKEN -unsigned long KSocket::ipv4_addr() -{ - unsigned long retval = 0; - KSocketAddress *sa = KExtendedSocket::peerAddress(sock); - if (sa == NULL) - return 0; - - if (sa->address() != NULL && (sa->address()->sa_family == PF_INET -#ifdef PF_INET6 - || sa->address()->sa_family == PF_INET6 -#endif - )) - { - KInetSocketAddress *ksin = (KInetSocketAddress*)sa; - const sockaddr_in *sin = ksin->addressV4(); - if (sin != NULL) - retval = sin->sin_addr.s_addr; - } - delete sa; - return retval; -} - -bool KSocket::initSockaddr (ksockaddr_in *server_name, const char *hostname, unsigned short int port, int domain) -{ - // This function is now IPv4 only - // if you want something better, you should use KExtendedSocket::lookup yourself - - kdWarning(170) << "deprecated KSocket::initSockaddr called" << endl; - - if (domain != PF_INET) - return false; - - TQPtrList<KAddressInfo> list = KExtendedSocket::lookup(hostname, TQString::number(port), - KExtendedSocket::ipv4Socket); - list.setAutoDelete(true); - - if (list.isEmpty()) - return false; - - memset(server_name, 0, sizeof(*server_name)); - - // We are sure that only KInetSocketAddress objects are in the list - KInetSocketAddress *sin = (KInetSocketAddress*)list.getFirst()->address(); - if (sin == NULL) - return false; - - memcpy(server_name, sin->addressV4(), sizeof(*server_name)); - kdDebug(170) << "KSocket::initSockaddr: returning " << sin->pretty() << endl; - return true; -} - -#endif - -KSocket::~KSocket() -{ - // Coolo says delete 0 is ok :) -thiago - delete d->readNotifier; - delete d->writeNotifier; - - delete d; - - if (sock != -1) { - ::close( sock ); - } -} - -class KServerSocketPrivate -{ -public: - bool bind; - TQCString path; - unsigned short int port; - KExtendedSocket *ks; -}; - - -KServerSocket::KServerSocket( const char *_path, bool _bind ) : - sock( -1 ) -{ - d = new KServerSocketPrivate(); - d->bind = _bind; - - init ( _path ); -} - -KServerSocket::KServerSocket( unsigned short int _port, bool _bind ) : - sock( -1 ) -{ - d = new KServerSocketPrivate(); - d->bind = _bind; - - init ( _port ); -} - -bool KServerSocket::init( const char *_path ) -{ - unlink(_path ); - d->path = _path; - - KExtendedSocket *ks = new KExtendedSocket(TQString::null, _path, KExtendedSocket::passiveSocket | - KExtendedSocket::unixSocket); - d->ks = ks; - - if (d->bind) - return bindAndListen(); - return true; -} - - -bool KServerSocket::init( unsigned short int _port ) -{ - d->port = _port; - KExtendedSocket *ks; - ks = new KExtendedSocket(TQString::null, _port, KExtendedSocket::passiveSocket | - KExtendedSocket::inetSocket); - d->ks = ks; - - if (d->bind) - return bindAndListen(); - return true; -} - -bool KServerSocket::bindAndListen() -{ - if (d == NULL || d->ks == NULL) - return false; - - - int ret = d->ks->listen( SOMAXCONN ); - if (ret < 0) - { - kdWarning(170) << "Error listening on socket: " << ret << "\n"; - delete d->ks; - d->ks = NULL; - sock = -1; - return false; - } - - - sock = d->ks->fd(); - - connect( d->ks->readNotifier(), TQT_SIGNAL( activated(int) ), this, TQT_SLOT( slotAccept(int) ) ); - return true; -} - - -unsigned short int KServerSocket::port() -{ - if (d == NULL || d->ks == NULL || sock == -1) - return 0; - const KSocketAddress *sa = d->ks->localAddress(); - if (sa == NULL) - return 0; - - // we can use sockaddr_in here even if it isn't IPv4 - sockaddr_in *sin = (sockaddr_in*)sa->address(); - - if (sin->sin_family == PF_INET) - // correct family - return sin->sin_port; -#ifdef PF_INET6 - else if (sin->sin_family == PF_INET6) - { - kde_sockaddr_in6 *sin6 = (kde_sockaddr_in6*)sin; - return sin6->sin6_port; - } -#endif - return 0; // not a port we know -} - -unsigned long KServerSocket::ipv4_addr() -{ - if (d == NULL || d->ks == NULL || sock == -1) - return 0; - const KSocketAddress *sa = d->ks->localAddress(); - - const sockaddr_in *sin = (sockaddr_in*)sa->address(); - - if (sin->sin_family == PF_INET) - // correct family - return ntohl(sin->sin_addr.s_addr); -#ifdef PF_INET6 - else if (sin->sin_family == PF_INET6) - { - KInetSocketAddress *ksin = (KInetSocketAddress*)sa; - sin = ksin->addressV4(); - if (sin != NULL) - return sin->sin_addr.s_addr; - } -#endif - return 0; // this is dumb, isn't it? -} - -void KServerSocket::slotAccept( int ) -{ - if (d == NULL || d->ks == NULL || sock == -1) - return; // nothing! - - KExtendedSocket *s; - if (d->ks->accept(s) < 0) - { - kdWarning(170) << "Error accepting\n"; - return; - } - - int new_sock = s->fd(); - s->release(); // we're getting rid of the KExtendedSocket - delete s; - - emit accepted( new KSocket( new_sock ) ); -} - -KServerSocket::~KServerSocket() -{ - if (d != NULL) - { - if (d->ks != NULL) - delete d->ks; - delete d; - } - // deleting d->ks closes the socket - // ::close( sock ); -} - -#include "ksock.moc" diff --git a/kdecore/ksock.h b/kdecore/ksock.h deleted file mode 100644 index 5c3eced8a..000000000 --- a/kdecore/ksock.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 1997 Torben Weis (weis@kde.org) - * - * 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 KSOCK_H -#define KSOCK_H - -#include "kdelibs_export.h" - -#ifdef Q_MOC_RUN -#define Q_OS_UNIX -#endif // Q_MOC_RUN - -#ifdef Q_OS_UNIX - -#include <tqobject.h> -#include <sys/types.h> -// we define STRICT_ANSI to get rid of some warnings in glibc -#ifndef __STRICT_ANSI__ -#define __STRICT_ANSI__ -#define _WE_DEFINED_IT_ -#endif -#include <sys/socket.h> -#ifdef _WE_DEFINED_IT_ -#undef __STRICT_ANSI__ -#undef _WE_DEFINED_IT_ -#endif - -#include <sys/un.h> - -#include <netinet/in.h> -class TQSocketNotifier; - -#ifdef KSOCK_NO_BROKEN -// This is here for compatibility with old applications still using the constants -// Never use them in new programs - -// Here are a whole bunch of hackish macros that allow one to -// get at the correct member of ksockaddr_in -// But since ksockaddr_in is IPv4-only, and deprecated... - -typedef sockaddr_in ksockaddr_in; -#define get_sin_addr(x) x.sin_addr -#define get_sin_port(x) x.sin_port -#define get_sin_family(x) x.sin_family -#define get_sin_paddr(x) x->sin_addr -#define get_sin_pport(x) x->sin_port -#define get_sin_pfamily(x) x->sin_family -#endif - -#define KSOCK_DEFAULT_DOMAIN PF_INET - -class KSocketPrivate; -class KServerSocketPrivate; - -/** @deprecated - * You can connect this socket to any Internet address. - * - * This class is deprecated and will be removed in the future. For new - * programs, please use KExtendedSocket class. - * - * The socket gives you three signals: When ready for reading, - * ready for writing or if the connection is broken. - * Using socket() you get a file descriptor - * which you can use with the usual UNIX function like write() or - * read(). - * If you have already such a socket identifier you can construct a KSocket - * on this identifier. - * - * If socket() delivers a value of -1 or less, the connection - * was not successful. - * - * @author Torben Weis <weis@uni-frankfurt.de> - * @short A TCP/IP client socket. - */ -class KDECORE_EXPORT KSocket : public TQObject -{ - Q_OBJECT -public: - /** - * Constructs a KSocket with the provided file descriptor. - * @param _sock The file descriptor to use. - */ - KSocket( int _sock ) KDE_DEPRECATED; - /** - * Creates a socket and connects to a host. - * @param _host The remote host to which to connect. - * @param _port The port on the remote host. - * @param timeOut The number of seconds waiting for connect (default 30). - */ - KSocket( const char *_host, unsigned short int _port, int timeOut = 30) KDE_DEPRECATED; - - /** - * Connects to a UNIX domain socket. - * @param _path The filename of the socket. - */ - KSocket( const char * _path ) KDE_DEPRECATED; - - /** - * Destructor. Closes the socket if it is still open. - */ - virtual ~KSocket(); - - /** - * Returns a file descriptor for this socket. - * @return the file descriptor, or -1 when an error occurred. - */ - int socket() const { return sock; } - - /** - * Enables the socket for reading. - * - * If you enable read mode, the socket will emit the signal - * readEvent() whenever there is something to read out of this - * socket. - * @param enable true to enable reading signals - */ - void enableRead( bool enable ); - - /** - * Enables the socket for writing. - * - * If you enable write mode, the socket will emit the signal - * writeEvent() whenever the socket is ready for writing. - * - * Warning: If you forget to call enableWrite(false) when you are - * not ready to send data, you will get lots of writeEvent() signals, - * in the order of thousands a second ! - * @param enable true to enable writing signals - */ - void enableWrite( bool enable ); - -#ifdef KSOCK_NO_BROKEN - // BCI: remove in libtdecore.so.4 - /** - * Return address. - * This function is dumb. Don't ever use it - * if you need the peer address of this socket, use KExtendedSocket::peerAddress(int) - * instead - * @deprecated - */ - unsigned long ipv4_addr() KDE_DEPRECATED; - - // BCI: remove in libtdecore.so.4 - /** - * A small wrapper around gethostbyname() and such. - * Don't use this in new programs. Use KExtendedSocket::lookup - * @deprecated - */ - static bool initSockaddr(ksockaddr_in *server_name, const char *hostname, unsigned short int port, int domain = PF_INET) KDE_DEPRECATED; -#endif - -signals: - /** - * Data has arrived for reading. - * - * This signal will only be raised if enableRead( @p true ) was called - * first. - * @param s the KSocket that triggered the event - */ - void readEvent( KSocket *s ); - - /** - * Socket is ready for writing. - * - * This signal will only be raised if enableWrite( @p true ) was - * called first. - * - * Warning: If you forget to call enableWrite(false) when you are - * not ready to send data, you will get lots of writeEvent() signals, - * in the order of thousands a second ! - * @param s the KSocket that triggered the event - */ - void writeEvent( KSocket *s ); - - /** - * Raised when the connection is broken. - * @param s the KSocket that triggered the event - */ - void closeEvent( KSocket *s ); - -public slots: - /** - * Connected to the writeNotifier. - * - * Called when - * the socket is ready for writing. - * @param x ignored - */ - void slotWrite( int x); - - /** - * Connected to the readNotifier. - * - * Called when - * the socket is ready for reading. - * @param x ignored - */ - void slotRead( int x ); - -protected: - bool connect( const TQString& _host, unsigned short int _port, int timeout = 0 ); - bool connect( const char *_path ); - - /****************************************************** - * The file descriptor for this socket. sock may be -1. - * This indicates that it is not connected. - */ - int sock; - -private: - KSocket(const KSocket&); - KSocket& operator=(const KSocket&); - - KSocketPrivate *d; - -}; - - -/** - * @short Monitors a port for incoming TCP/IP connections. - * - * @deprecated - * This class is deprecated and will be removed in the future. - * Please use the classes in KNetwork for new programs. - * In special, this class is replaced by KNetwork::KStreamSocket - * and KNetwork::KServerSocket. - * - * You can use a KServerSocket to listen on a port for incoming - * connections. When a connection arrived in the port, a KSocket - * is created and the signal accepted is raised. Make sure you - * always connect to this signal. If you don't the ServerSocket will - * create new KSocket's and no one will delete them! - * - * If socket() is -1 or less the socket was not created properly. - * - * @author Torben Weis <weis@stud.uni-frankfurt.de> -*/ -class KDECORE_EXPORT KServerSocket : public TQObject -{ - Q_OBJECT -public: - /** - * Constructor. - * @param _port the port number to monitor for incoming connections. - * @param _bind if false you need to call bindAndListen yourself. - * This gives you the opportunity to set options on the - * socket. - */ - KServerSocket( unsigned short int _port, bool _bind = true ); - - /** - * Creates a UNIX domain server socket. - * @param _path path used for the socket. - * @param _bind if false you need to call bindAndListen yourself. - * This gives you the opportunity to set options on the - * socket. - */ - KServerSocket( const char *_path, bool _bind = true); - - /** - * Destructor. Closes the socket if it was not already closed. - */ - virtual ~KServerSocket(); - - /** - * Binds the socket and start listening. This should only be called - * once when the constructor was called with _bind false. - * On error the socket will be closed. - * @return true on success. false on error. - */ - bool bindAndListen(); - - /** - * Returns the file descriptor associated with the socket. - * @return the file descriptor, -1 when an error occurred during - * construction or bindAndListen - */ - int socket() const { return sock; } - - /** - * Returns the port number which is being monitored. - * @return the port number - */ - unsigned short int port(); - -#ifdef KSOCK_NO_BROKEN - // BCI: remove in libtdecore.so.4 - /** - * The address. - * This is dumb. Don't use it - * Refer to KExtendedSocket::localAddress(int) - * @deprecated - */ - unsigned long ipv4_addr(); -#endif - -public slots: - /** - * Called when someone connected to our port. - */ - virtual void slotAccept( int ); // why is this virtual? - -signals: - /** - * A connection has been accepted. - * It is your task to delete the KSocket if it is no longer needed. - * - * WARNING: this signal is always emitted, even if you don't connect - * anything to it. That would mean memory loss, because the KSockets - * created go to oblivion. - * @param s the socket that accepted - */ - void accepted( KSocket*s ); - -protected: - bool init( unsigned short int ); - bool init( const char *_path ); - - /** - * The file descriptor for this socket. sock may be -1. - * This indicates that it is not connected. - */ - int sock; - -private: - KServerSocket(const KServerSocket&); - KServerSocket& operator=(const KServerSocket&); - - KServerSocketPrivate *d; -}; - -#endif //Q_OS_UNIX - -#endif diff --git a/kdecore/ksockaddr.cpp b/kdecore/ksockaddr.cpp deleted file mode 100644 index 6ce802716..000000000 --- a/kdecore/ksockaddr.cpp +++ /dev/null @@ -1,894 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000-2002 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - **/ - -#include "ksockaddr.h" -#include <config.h> - -#include <sys/types.h> - -#ifdef Q_OS_UNIX -#include <arpa/inet.h> -#endif -#include <netinet/in.h> - -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#include <sys/un.h> -#include <unistd.h> - -#include <tqglobal.h> -#include <tqfile.h> - -#include "kdebug.h" -#include "klocale.h" -//#include "kextsock.h" - -#ifndef HAVE_STRUCT_SOCKADDR_IN6 -// The system doesn't have sockaddr_in6 -// But we can tell netsupp.h to define it for us, according to the RFC -#define CLOBBER_IN6 -#endif - -#include "netsupp.h" - -#define V6_CAN_CONVERT_TO_V4(addr) (KDE_IN6_IS_ADDR_V4MAPPED(addr) || KDE_IN6_IS_ADDR_V4COMPAT(addr)) - -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN -# define MY_MAX(a, b) ((a) > (b) ? (a) : (b)) -# define MIN_SOCKADDR_LEN MY_MAX(offsetof(sockaddr, sa_family) + sizeof(((sockaddr*)0)->sa_family), \ - offsetof(sockaddr, sa_len) + sizeof(((sockaddr*)0)->sa_len)) -#else -# define MIN_SOCKADDR_LEN (offsetof(sockaddr, sa_family) + sizeof(((sockaddr*)0)->sa_family)) -#endif - -// Minimum size accepted for sockaddr_in6 sockets. -// The scopeid field is missing from some implementations -// that conform to the obsoleted RFC 2133, e.g. Linux glibc 2.1 -#define MIN_SOCKADDR_IN6_LEN (offsetof(sockaddr_in6, sin6_addr) + sizeof(((sockaddr_in6*)0)->sin6_addr)) - -#ifdef offsetof -#undef offsetof -#endif -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -// This is how it is -// 46 == strlen("1234:5678:9abc:def0:1234:5678:255.255.255.255") -#ifndef INET6_ADDRSTRLEN -#define INET6_ADDRSTRLEN 46 -#endif - - -/** - * Class KSocketAddress - */ - -KSocketAddress::KSocketAddress(const sockaddr* sa, ksocklen_t size) -{ - if ( !sa ) - init(); - else { - data = (sockaddr*)malloc(size); - if (data == NULL) - return; - memcpy(data, sa, size); - datasize = size; - owndata = true; - } -} - -void KSocketAddress::init() -{ - data = NULL; - datasize = 0; - owndata = false; -} - -KSocketAddress::~KSocketAddress() -{ - if (owndata && data != NULL) - free(data); -} - -TQString KSocketAddress::pretty() const -{ - return i18n("<unknown socket>"); -} - -int KSocketAddress::family() const -{ - if (data != NULL) - return data->sa_family; - return AF_UNSPEC; -} - -// This creates a new KSocketAddress with given sockaddr -KSocketAddress* KSocketAddress::newAddress(const struct sockaddr* sa, ksocklen_t size) -{ - if (size == 0) - { - kdWarning() << "KSocketAddress::newAddress called with size = 0!\n"; - return NULL; - } - - // make sure we have the right stuff - if (size < MIN_SOCKADDR_LEN) - { - kdWarning() << "KSocketAddress::newAddress called with invalid size\n"; - return NULL; - } - - switch (sa->sa_family) - { - case AF_INET: - if (size >= sizeof(sockaddr_in)) - return new KInetSocketAddress((const sockaddr_in*)sa, size); - return NULL; - -#ifdef AF_INET6 - case AF_INET6: - if (size >= MIN_SOCKADDR_IN6_LEN) - return new KInetSocketAddress((const sockaddr_in6*)sa, size); - return NULL; -#endif - - case AF_UNIX: // AF_LOCAL - return new KUnixSocketAddress((const sockaddr_un*)sa, size); - } - - return new KSocketAddress(sa, size); -} - -bool KSocketAddress::isEqual(const KSocketAddress& other) const -{ - switch(family()) - { - case AF_INET: - return KInetSocketAddress::areEqualInet(*this, other, false); -#ifdef AF_INET6 - case AF_INET6: - return KInetSocketAddress::areEqualInet6(*this, other, false); -#endif - case AF_UNIX: // AF_LOCAL - return KUnixSocketAddress::areEqualUnix(*this, other, false); - } - - // This is not a known socket type - if (other.datasize != datasize) - return false; // can't be equal - return memcmp(data, other.data, datasize) == 0; -} - -bool KSocketAddress::isCoreEqual(const KSocketAddress& other) const -{ - switch(family()) - { - case AF_INET: - return KInetSocketAddress::areEqualInet(*this, other, true); -#ifdef AF_INET6 - case AF_INET6: - return KInetSocketAddress::areEqualInet6(*this, other, true); -#endif - case AF_UNIX: // AF_LOCAL - return KUnixSocketAddress::areEqualUnix(*this, other, true); - } - - return false; -} - -TQString KSocketAddress::nodeName() const -{ - return TQString::null; -} - -TQString KSocketAddress::serviceName() const -{ - return TQString::null; -} - -int KSocketAddress::ianaFamily(int af) -{ - switch (af) - { - case AF_INET: - return 1; -#ifdef AF_INET6 - case AF_INET6: - return 2; -#endif - default: - return 0; - } -} - -int KSocketAddress::fromIanaFamily(int iana) -{ - switch (iana) - { - case 1: - return AF_INET; -#ifdef AF_INET6 - case 2: - return AF_INET6; -#endif - default: - return AF_UNSPEC; - } -} - -/** - * class KInetSocketAddress - */ -class KInetSocketAddressPrivate -{ -public: - int sockfamily; - sockaddr_in sin; -#ifdef AF_INET6 - sockaddr_in6 sin6; -#endif - - KInetSocketAddressPrivate() : - sockfamily(AF_UNSPEC) - { - sin.sin_family = AF_INET; - sin.sin_port = 0; -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin.sin_len = sizeof(sin); -#endif -#ifdef AF_INET6 - sin6.sin6_family = AF_INET6; - sin6.sin6_port = 0; - sin6.sin6_flowinfo = 0; -# ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID - sin6.sin6_scope_id = 0; -# endif -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin6.sin6_len = sizeof(sin6); -# endif -#endif - } - -}; - -KInetSocketAddress::KInetSocketAddress() : - d(new KInetSocketAddressPrivate) -{ -} - -KInetSocketAddress::KInetSocketAddress(const KInetSocketAddress &other) : - KSocketAddress(), d(new KInetSocketAddressPrivate) -{ - setAddress(other); -} - -KInetSocketAddress::KInetSocketAddress(const sockaddr_in* sin, ksocklen_t len) : - d(new KInetSocketAddressPrivate) -{ - setAddress(sin, len); -} - -KInetSocketAddress::KInetSocketAddress(const sockaddr_in6* sin6, ksocklen_t len) : - d(new KInetSocketAddressPrivate) -{ - setAddress(sin6, len); -} - -KInetSocketAddress::KInetSocketAddress(const in_addr& addr, unsigned short port) : - d(new KInetSocketAddressPrivate) -{ - setAddress(addr, port); -} - -KInetSocketAddress::KInetSocketAddress(const in6_addr& addr, unsigned short port) : - d(new KInetSocketAddressPrivate) -{ - setAddress(addr, port); -} - -KInetSocketAddress::KInetSocketAddress(const TQString& addr, unsigned short port, int family) : - d(new KInetSocketAddressPrivate) -{ - setAddress(addr, port, family); -} - -KInetSocketAddress::~KInetSocketAddress() -{ - delete d; - - // KSocketAddress::~KSocketAddress(); -} - -bool KInetSocketAddress::setAddress(const KInetSocketAddress &other) -{ - if (other.family() == AF_INET) - return setAddress(other.addressV4(), other.size()); -#ifdef AF_INET6 - else if (other.family() == AF_INET6) - return setAddress(other.addressV6(), other.size()); -#endif - return false; -} - -bool KInetSocketAddress::setAddress(const sockaddr_in* sin, ksocklen_t len) -{ - // This is supposed to be a AF_INET socket - if ((len < sizeof(sockaddr_in)) || (sin->sin_family != AF_INET)) - { - kdWarning() << "KInetSocketAddress::setAddress(sockaddr_in*) called with invalid sockaddr_in\n"; - return false; - } - - return setHost(sin->sin_addr) && setPort(ntohs(sin->sin_port)); -} - -bool KInetSocketAddress::setAddress(const sockaddr_in6* sin6, ksocklen_t len) -{ -#ifdef AF_INET6 - // should be family AF_INET6 - if ((len < MIN_SOCKADDR_IN6_LEN) || (sin6->sin6_family != AF_INET6)) - { - kdWarning() << "KInetSocketAddress::setAddress(sockaddr_in6*) called with invalid sockaddr_in6\n"; - return 0; - } - - memset(&d->sin6, 0, sizeof(d->sin6)); - if (len > sizeof(d->sin6)) - len = sizeof(d->sin6); - memcpy(&d->sin6, sin6, len); - - /* Now make a sanity check */ - d->sockfamily = d->sin6.sin6_family = AF_INET6; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - d->sin6.sin6_len = sizeof(d->sin6); -# endif - - fromV6(); - return true; -#else // !AF_INET6 - return false; -#endif -} - -bool KInetSocketAddress::setAddress(const in_addr& addr, unsigned short port) -{ - return setHost(addr) && setPort(port); -} - -bool KInetSocketAddress::setAddress(const in6_addr& addr, unsigned short port) -{ - return setHost(addr) && setPort(port); -} - -bool KInetSocketAddress::setAddress(const TQString& addr, unsigned short port, int family) -{ - return setHost(addr, family) && setPort(port); -} - -bool KInetSocketAddress::setHost(const in_addr& addr) -{ - d->sockfamily = AF_INET; // set address to IPv4 type - d->sin.sin_addr = addr; - fromV4(); - return true; -} - -bool KInetSocketAddress::setHost(const in6_addr& addr) -{ -#ifdef AF_INET6 - d->sockfamily = AF_INET6; // set address to IPv6 type - d->sin6.sin6_addr = addr; - fromV6(); - return true; -#else - return false; -#endif -} - -bool KInetSocketAddress::setHost(const TQString& addr, int family) -{ - // if family == -1, we'll try to guess the host name - if ((family != -1) && (family != AF_INET) -#ifdef AF_INET6 - && (family != AF_INET6) -#endif - ) - { - kdWarning() << "KInetSocketAddress::setHost(TQString, int) called with unknown family address\n"; - return false; - } - - if (family == -1) - { - // guess the family type - -#ifdef AF_INET6 - // IPv6 addresses MUST contain colons (:) and IPv4 addresses must not - if (addr.find(':') != -1) - family = AF_INET6; - else - family = AF_INET; -#else - - // There's only one guess: - family = AF_INET; -#endif - } - - /* - * FIXME! What is the decoding process for hostnames? - */ - if (family == AF_INET) - { - inet_pton(family, addr.latin1(), (void*)&(d->sin.sin_addr)); - fromV4(); - } -#ifdef AF_INET6 - else - { - inet_pton(family, addr.latin1(), (void*)&(d->sin6.sin6_addr)); - fromV6(); - } -#endif - d->sockfamily = family; - return true; -} - -bool KInetSocketAddress::setPort(unsigned short port) -{ - // set port on all socket types - d->sin.sin_port = htons(port); -#ifdef AF_INET6 - d->sin6.sin6_port = htons(port); -#endif - - return true; -} - -bool KInetSocketAddress::setFamily(int _family) -{ - if (_family != AF_INET -#ifdef AF_INET6 - && _family != AF_INET6 -#endif - ) - { - kdWarning() << "KInetSocketAddress::setFamily(int) called with unknown family\n"; - return false; - } - - d->sockfamily = _family; - if (_family == AF_INET) - fromV4(); -#ifdef AF_INET6 - else if (_family == AF_INET6) - fromV6(); -#endif - - return true; -} - -bool KInetSocketAddress::setFlowinfo(TQ_UINT32 flowinfo) -{ -#ifdef AF_INET6 - if (d->sockfamily == AF_INET6) - { - d->sin6.sin6_flowinfo = flowinfo; - return true; - } -#endif - return false; -} - -bool KInetSocketAddress::setScopeId(int scopeid) -{ -#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID) - if (d->sockfamily == AF_INET6) - { - d->sin6.sin6_scope_id = scopeid; - return true; - } -#endif - (void)scopeid; - return false; -} - -const sockaddr_in* KInetSocketAddress::addressV4() const -{ - if (d->sockfamily == AF_INET) - return &d->sin; -#ifdef AF_INET6 - else if (d->sockfamily == AF_INET6) - { - // check if this IPv6 address was converted without loss - if (V6_CAN_CONVERT_TO_V4(&d->sin6.sin6_addr)) - return &d->sin; - else - return NULL; // there was loss, so return nothing - } -#endif - - kdWarning() << "KInetSocketAddress::addressV4() called on uninitialized socket\n"; - return NULL; -} - -const sockaddr_in6* KInetSocketAddress::addressV6() const -{ -#ifdef AF_INET6 - return &d->sin6; -#else - return NULL; -#endif -} - -in_addr KInetSocketAddress::hostV4() const -{ - // this might be empty - return d->sin.sin_addr; -} - -/* - * ATTENTION - * This function is left undefined if no IPv6 support exists - * This is intentional - */ -#ifdef AF_INET6 -in6_addr KInetSocketAddress::hostV6() const -{ - return d->sin6.sin6_addr; -} -#endif - -TQString KInetSocketAddress::pretty() const -{ - if (d->sockfamily != AF_INET -#ifdef AF_INET6 - && d->sockfamily != AF_INET6 -#endif - ) - { - kdWarning() << "KInetSocketAddress::pretty() called on uninitialized class\n"; - return i18n("<empty>"); - } - - return i18n("1: hostname, 2: port number", "%1 port %2").arg(nodeName()).arg(serviceName()); -} - -TQString KInetSocketAddress::nodeName() const -{ - char buf[INET6_ADDRSTRLEN]; // INET6_ADDRSTRLEN > INET_ADDRSTRLEN - - if (d->sockfamily == AF_INET) - inet_ntop(d->sockfamily, (void*)&d->sin.sin_addr, buf, sizeof(buf)); -#ifdef AF_INET6 - else if (d->sockfamily == AF_INET6) - inet_ntop(d->sockfamily, (void*)&d->sin6.sin6_addr, buf, sizeof(buf)); -#endif - else - { - kdWarning() << "KInetSocketAddress::nodeName() called on uninitialized class\n"; - return i18n("<empty>"); - } - - return TQString::tqfromLatin1(buf); // FIXME! What's the encoding? -} - -TQString KInetSocketAddress::serviceName() const -{ - return TQString::number(port()); -} - -unsigned short KInetSocketAddress::port() const -{ -#ifdef AF_INET6 - // we prefer sin6 here because fromV6() might make sin.sin_port be 0 - return ntohs(d->sin6.sin6_port); -#else - return ntohs(d->sin.sin_port); -#endif -} - -TQ_UINT32 KInetSocketAddress::flowinfo() const -{ -#ifdef AF_INET6 - if (d->sockfamily == AF_INET6) - return (TQ_UINT32)d->sin6.sin6_flowinfo; -#endif - return 0; -} - -ksocklen_t KInetSocketAddress::size() const -{ - if (d->sockfamily == AF_INET) - return sizeof(d->sin); -#ifdef AF_INET6 - else if (d->sockfamily == AF_INET6) - return sizeof(d->sin6); -#endif - else - return 0; -} - -bool KInetSocketAddress::areEqualInet(const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly) -{ - if (s1.family() != s2.family()) - return false; - if ((s1.size() < sizeof(sockaddr_in)) || (s2.size() < sizeof(sockaddr_in))) - return false; - - struct sockaddr_in *sin1 = (sockaddr_in *) s1.address(); - struct sockaddr_in *sin2 = (sockaddr_in *) s2.address(); - - if (coreOnly) - return (memcmp(&sin1->sin_addr, &sin2->sin_addr, sizeof(struct in_addr)) == 0); - else - return (sin1->sin_port == sin2->sin_port) && - (memcmp(&sin1->sin_addr, &sin2->sin_addr, sizeof(struct in_addr)) == 0); -} - -bool KInetSocketAddress::areEqualInet6(const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly) -{ -#ifdef AF_INET6 - if (s1.family() != s2.family()) - return false; - - if ((s1.size() < sizeof(sockaddr_in6)) || (s2.size() < sizeof(sockaddr_in6))) - return false; - - struct sockaddr_in6 *sin1 = (sockaddr_in6 *) s1.address(); - struct sockaddr_in6 *sin2 = (sockaddr_in6 *) s2.address(); - - if (coreOnly) - return (memcmp(&sin1->sin6_addr, &sin2->sin6_addr, sizeof(struct in6_addr)) == 0); - else - return (sin1->sin6_port == sin2->sin6_port) && - (sin1->sin6_flowinfo == sin2->sin6_flowinfo) && -#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID - (sin1->sin6_scope_id == sin2->sin6_scope_id) && -#endif - (memcmp(&sin1->sin6_addr, &sin2->sin6_addr, sizeof(struct in6_addr)) == 0); -#else - return false; -#endif -} - -void KInetSocketAddress::fromV4() -{ - // converts an address from v4 - -#ifdef AF_INET6 - d->sin6.sin6_port = d->sin.sin_port; - - // Make this a v4-mapped address - ((TQ_UINT32*)&d->sin6.sin6_addr)[0] = ((TQ_UINT32*)&d->sin6.sin6_addr)[1] = 0; - ((TQ_UINT32*)&d->sin6.sin6_addr)[2] = htonl(0xffff); - ((TQ_UINT32*)&d->sin6.sin6_addr)[3] = *(TQ_UINT32*)&d->sin.sin_addr; - - // Clear flowinfo and scopeid - d->sin6.sin6_flowinfo = 0; -# ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID - d->sin6.sin6_scope_id = 0; -# endif -#endif - - // data == KSocketAddress::data - data = (sockaddr*)&d->sin; - datasize = sizeof( sockaddr_in ); -} - -void KInetSocketAddress::fromV6() -{ -#ifdef AF_INET6 - // convert to v4 only if this is a v4-mapped or v4-compat address - if (V6_CAN_CONVERT_TO_V4(&d->sin6.sin6_addr)) - { - d->sin.sin_port = d->sin6.sin6_port; - *(TQ_UINT32*)&d->sin.sin_addr = ((TQ_UINT32*)&d->sin6.sin6_addr)[3]; - } - else - { - d->sin.sin_port = 0; - memset(&d->sin.sin_addr, 0, sizeof(d->sin.sin_addr)); - } - - data = (sockaddr*)&d->sin6; - datasize = sizeof( d->sin6 ); -#endif -} - -TQString KInetSocketAddress::addrToString(int family, const void* addr) -{ - char buf[INET6_ADDRSTRLEN+1]; - - return TQString::tqfromLatin1(inet_ntop(family, addr, buf, INET6_ADDRSTRLEN)); -} - -bool KInetSocketAddress::stringToAddr(int family, const char *text, void *dest) -{ - return inet_pton(family, text, dest) != 0; -} - -/** - * class KUnixSocketAddress - */ - -class KUnixSocketAddressPrivate -{ -public: - sockaddr_un *m_sun; - - KUnixSocketAddressPrivate() : m_sun(NULL) - { } -}; - -KUnixSocketAddress::KUnixSocketAddress() : - d(new KUnixSocketAddressPrivate) -{ -} - -KUnixSocketAddress::KUnixSocketAddress(const sockaddr_un* _sun, ksocklen_t size) : - d(new KUnixSocketAddressPrivate) -{ - setAddress(_sun, size); -} - -KUnixSocketAddress::KUnixSocketAddress(TQCString pathname) : - d(new KUnixSocketAddressPrivate) -{ - setAddress(pathname); -} - -KUnixSocketAddress::~KUnixSocketAddress() -{ - delete d; -} - -bool KUnixSocketAddress::setAddress(const sockaddr_un* _sun, ksocklen_t _size) -{ - if (_sun->sun_family != AF_UNIX) - { - kdWarning() << "KUnixSocketAddress::setAddress called with invalid socket\n"; - return false; - } - - if (owndata && (d->m_sun != NULL) && (datasize >= _size)) - { - // reuse this without reallocating - memcpy(d->m_sun, _sun, _size); - } - else - { - if (owndata && (d->m_sun != NULL)) - free(d->m_sun); - - d->m_sun = (sockaddr_un*)malloc(_size); - - if (d->m_sun == NULL) - { - // problems - owndata = false; - return false; - } - - memcpy(d->m_sun, _sun, _size); - } - - datasize = _size; - data = (sockaddr*)d->m_sun; - owndata = true; -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - data->sa_len = _size; -#endif - return 1; -} - -bool KUnixSocketAddress::setAddress(TQCString path) -{ - // the +1 is necessary for the ending zero - ksocklen_t newsize = offsetof(sockaddr_un, sun_path) + path.length() + 1; - - if (owndata && (d->m_sun != NULL) && (datasize >= newsize)) - { - // we can reuse this - strcpy(d->m_sun->sun_path, path); -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - data->sa_len = newsize; -#endif - return true; - } - - // nah, we have to do better - if (owndata && (d->m_sun != NULL)) - free(d->m_sun); - - d->m_sun = (sockaddr_un*) malloc(newsize); - if (d->m_sun == NULL) - { - owndata = false; - return false; - } - - d->m_sun->sun_family = AF_UNIX; - strcpy(d->m_sun->sun_path, path); - data = (sockaddr*)d->m_sun; - datasize = newsize; -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - data->sa_len = newsize; -#endif - return 1; -} - -TQCString KUnixSocketAddress::pathname() const -{ - if (d->m_sun != NULL) - { - if (datasize > offsetof(sockaddr_un, sun_path)) - return d->m_sun->sun_path; - return ""; - } - return TQCString(0); -} - -TQString KUnixSocketAddress::pretty() const -{ - TQCString pname = pathname(); - if (pname.isEmpty()) - return i18n("<empty UNIX socket>"); - return TQFile::decodeName(pathname()); -} - -TQString KUnixSocketAddress::serviceName() const -{ - return TQString::fromUtf8(pathname()); -} - -const sockaddr_un* KUnixSocketAddress::address() const -{ - return d->m_sun; -} - -bool KUnixSocketAddress::areEqualUnix(const KSocketAddress &s1, const KSocketAddress &s2, bool /* coreOnly */) -{ - if (s1.family() != s2.family()) - return false; - - if ((s1.size() < MIN_SOCKADDR_LEN) || (s2.size() < MIN_SOCKADDR_LEN)) - return false; - - struct sockaddr_un *sun1 = (sockaddr_un *) s1.address(); - struct sockaddr_un *sun2 = (sockaddr_un *) s2.address(); - - if (s1.size() == MIN_SOCKADDR_LEN && s2.size() == MIN_SOCKADDR_LEN) - return true; // unnamed Unix sockets - - return (strcmp(sun1->sun_path, sun2->sun_path) == 0); -} - -void KSocketAddress::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void KInetSocketAddress::virtual_hook( int id, void* data ) -{ KSocketAddress::virtual_hook( id, data ); } - -void KUnixSocketAddress::virtual_hook( int id, void* data ) -{ KSocketAddress::virtual_hook( id, data ); } - - -#include "ksockaddr.moc" diff --git a/kdecore/ksockaddr.h b/kdecore/ksockaddr.h deleted file mode 100644 index 04ae350aa..000000000 --- a/kdecore/ksockaddr.h +++ /dev/null @@ -1,683 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000-2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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 KSOCKADDR_H -#define KSOCKADDR_H - -#include <tqobject.h> -#include <tqcstring.h> -#include <tqstring.h> -#include "kdelibs_export.h" - -/* - * This file defines a class that envelopes most, if not all, socket addresses - */ -typedef unsigned ksocklen_t; - -struct sockaddr; - -class KExtendedSocket; // No need to define it fully - -class KSocketAddressPrivate; -/** - * A socket address. - * - * This class envelopes almost if not all socket addresses. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - * @short a socket address. - */ -class KDECORE_EXPORT KSocketAddress: public TQObject -{ - Q_OBJECT -protected: - /** - * Creates an empty class - */ - KSocketAddress() { init(); } - - /** - * Creates with given data - * @param sa a sockaddr structure - * @param size the size of @p sa - */ - KSocketAddress(const sockaddr* sa, ksocklen_t size); - -public: - /** - * Destructor. - */ - virtual ~KSocketAddress(); - - /** - * Returns a string representation of this socket. - * @return a pretty string representation - */ - virtual TQString pretty() const; - - /** - * Returns a sockaddr structure, for passing down to library functions. - * @return the sockaddr structure, can be 0 - */ - const sockaddr* address() const - { return data; } - - /** - * Returns sockaddr structure size. - * @return the size of the sockaddr structre, 0 if there is none. - */ - virtual ksocklen_t size() const - { return datasize; } - - /** - * Returns a sockaddr structure, for passing down to library functions. - * @return the sockaddr structure, can be 0. - * @see address() - */ - operator const sockaddr*() const - { return data; } - - /** - * Returns the family of this address. - * @return the family of this address, AF_UNSPEC if it's undefined - */ - int family() const; - - /** - * Returns the IANA family number of this address. - * @return the IANA family number of this address (1 for AF_INET. - * 2 for AF_INET6, otherwise 0) - */ - inline int ianaFamily() const - { return ianaFamily(family()); } - - /** - * Returns true if this equals the other socket. - * @param other the other socket - * @return true if both sockets are equal - */ - virtual bool isEqual(const KSocketAddress& other) const; - bool isEqual(const KSocketAddress* other) const - { return isEqual(*other); } - - /** - * Overloaded == operator. - * @see isEqual() - */ - bool operator==(const KSocketAddress& other) const - { return isEqual(other); } - - /** - * Some sockets may differ in such things as services or port numbers, - * like Internet sockets. This function compares only the core part - * of that, if possible. - * - * If not possible, like the default implementation, this returns - * the same as isEqual. - * @param other the other socket - * @return true if the code part is equal - */ - bool isCoreEqual(const KSocketAddress& other) const; - - /** - * Some sockets may differ in such things as services or port numbers, - * like Internet sockets. This function compares only the core part - * of that, if possible. - * - * If not possible, like the default implementation, this returns - * the same as isEqual. - * @param other the other socket - * @return true if the code part is equal - */ - bool isCoreEqual(const KSocketAddress* other) const - { return isCoreEqual(*other); } - - /** - * Returns the node name of this socket, as KExtendedSocket::lookup expects - * as the first argument. - * In the case of Internet sockets, this is the hostname. - * The default implementation returns TQString::null. - * @return the node name, can be TQString::null - */ - virtual TQString nodeName() const; - - /** - * Returns the service name for this socket, as KExtendedSocket::lookup expects - * as the service argument. - * In the case of Internet sockets, this is the port number. - * The default implementation returns TQString::null. - * @return the service name, can be TQString::null - */ - virtual TQString serviceName() const; - -protected: - sockaddr* data; - ksocklen_t datasize; - bool owndata; - -private: - void init(); - /* No copy constructor */ - KSocketAddress(KSocketAddress&); - KSocketAddress& operator=(KSocketAddress&); - -public: - /** - * Creates a new KSocketAddress or descendant class from given - * raw socket address. - * @param sa new socket address - * @param size new socket address's length - * @return the new KSocketAddress, or 0 if the function failed - */ - static KSocketAddress* newAddress(const struct sockaddr *sa, ksocklen_t size); - - /** - * Returns the IANA family number of the given address family. - * Returns 0 if there is no corresponding IANA family number. - * @param af the address family, in AF_* constants - * @return the IANA family number of this address (1 for AF_INET. - * 2 for AF_INET6, otherwise 0) - */ - static int ianaFamily(int af); - - /** - * Returns the address family of the given IANA family number. - * @return the address family, AF_UNSPEC for unknown IANA family numbers - */ - static int fromIanaFamily(int iana); - - friend class KExtendedSocket; -protected: - virtual void virtual_hook( int id, void* data ); -private: - KSocketAddressPrivate* d; -}; - -/* - * External definitions - * We need these for KInetSocketAddress - */ -struct sockaddr_in; -struct sockaddr_in6; -struct in_addr; -struct in6_addr; - -class KInetSocketAddressPrivate; -/** - * An Inet (IPv4 or IPv6) socket address - * - * This is an IPv4 or IPv6 address of the Internet - * - * This class inherits most of the functionality from KSocketAddress, but - * is targeted specifically to Internet addresses - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - * @short an Internet socket address - */ -class KDECORE_EXPORT KInetSocketAddress: public ::KSocketAddress -{ - Q_OBJECT -public: - /** - * Default constructor. Does nothing - */ - KInetSocketAddress(); - - /** - * Copy constructor - */ - KInetSocketAddress(const KInetSocketAddress&); - - /** - * Creates an IPv4 socket from raw sockaddr_in. - * @param sin a sockaddr_in structure to copy from - * @param len the socket address length - */ - KInetSocketAddress(const sockaddr_in* sin, ksocklen_t len); - - /** - * Creates an IPv6 socket from raw sockaddr_in6. - * @param sin6 a sockaddr_in6 structure to copy from - * @param len the socket address length - */ - KInetSocketAddress(const sockaddr_in6* sin6, ksocklen_t len); - - /** - * Creates a socket from information. - * @param addr a binary address - * @param port a port number - */ - KInetSocketAddress(const in_addr& addr, unsigned short port); - - /** - * Creates a socket from information. - * @param addr a binary address - * @param port a port number - */ - KInetSocketAddress(const in6_addr& addr, unsigned short port); - - /** - * Creates a socket from text representation. - * - * @param addr a text representation of the address - * @param port a port number - * @param family the family for this address. Use -1 to guess the - * family type - * @see setAddress - */ - KInetSocketAddress(const TQString& addr, unsigned short port, int family = -1); - - /** - * Destructor - */ - virtual ~KInetSocketAddress(); - - /** - * Sets this socket to given socket. - * @param ksa the other socket - * @return true if successful, false otherwise - */ - bool setAddress(const KInetSocketAddress& ksa); - - /** - * Sets this socket to given raw socket. - * @param sin the raw socket - * @param len the socket address length - * @return true if successful, false otherwise - */ - bool setAddress(const sockaddr_in* sin, ksocklen_t len); - - /** - * Sets this socket to given raw socket. - * - * Note: this function does not clear the scope ID and flow info values - * @param sin6 the raw socket - * @param len the socket address length - * @return true if successful, false otherwise - */ - bool setAddress(const sockaddr_in6* sin6, ksocklen_t len); - - /** - * Sets this socket to raw address and port. - * @param addr the address - * @param port the port number - * @return true if successful, false otherwise - */ - bool setAddress(const in_addr& addr, unsigned short port); - - /** - * Sets this socket to raw address and port. - * @param addr the address - * @param port the port number - * @return true if successful, false otherwise - */ - bool setAddress(const in6_addr& addr, unsigned short port); - - /** - * Sets this socket to text address and port - * - * You can use the @p family parameter to specify what kind of socket - * you want this to be. It could be AF_INET or AF_INET6 or -1. - * - * If the value is -1 (default), this function will make an effort to - * discover what is the family. That isn't too hard, actually, and it - * works in all cases. But, if you want to be sure that your socket - * is of the type you want, use this parameter. - * - * This function returns false if the socket address was not valid. - * @param addr the address - * @param port the port number - * @param family the address family, -1 for any - * @return true if successful, false otherwise - */ - bool setAddress(const TQString& addr, unsigned short port, int family = -1); - - /** - * Sets this socket's host address to given raw address. - * @param addr the address - * @return true if successful, false otherwise - */ - bool setHost(const in_addr& addr); - - /** - * Sets this socket's host address to given raw address. - * @param addr the address - * @return true if successful, false otherwise - */ - bool setHost(const in6_addr& addr); - - /** - * Sets this socket's host address to given text representation. - * @param addr the address - * @param family the address family, -1 to guess the family - * @return true if successful, false otherwise - */ - bool setHost(const TQString& addr, int family = -1); - - /** - * Sets this socket's port number to given port number. - * @param port the port number - * @return true if successful, false otherwise - */ - bool setPort(unsigned short port); - - /** - * Turns this into an IPv4 or IPv6 address. - * - * @param family the new address family - * @return false if this is v6 and information was lost. That doesn't - * mean the conversion was unsuccessful. - */ - bool setFamily(int family); - - /** - * Sets flowinfo information for this socket address if this is IPv6. - * @param flowinfo flowinfo - * @return true if successful, false otherwise - */ - bool setFlowinfo(TQ_UINT32 flowinfo); - - /** - * Sets the scope id for this socket if this is IPv6. - * @param scopeid the scope id - * @return true if successful, false otherwise - */ - bool setScopeId(int scopeid); - - /** - * Returns a pretty representation of this address. - * @return a pretty representation - */ - virtual TQString pretty() const; - - /** - * Returns the text representation of the host address. - * @return a text representation of the host address - */ - virtual TQString nodeName() const; - // TQString prettyHost() const; - - /** - * Returns the text representation of the port number. - * @return the name of the service (a number) - */ - virtual TQString serviceName() const; - - /** - * Returns the socket address. - * - * This will be NULL if this is a non-convertible v6. - * This function will return an IPv4 socket if this IPv6 - * socket is a v4-mapped address. That is, if it's really - * an IPv4 address, but in v6 disguise. - * @return the sockaddr_in struct, can be 0. - */ - const sockaddr_in* addressV4() const; - - /** - * Returns the socket address in IPv6 - * @return the sockaddr_in struct, can be 0 if IPv6 is unsupported. - */ - const sockaddr_in6* addressV6() const; - - /** - * Returns the host address. - * Might be empty. - * @return the host address - */ - in_addr hostV4() const; - - /** - * Returns the host address. - * - * WARNING: this function is not defined if there is no IPv6 support - * @return the host address - */ - in6_addr hostV6() const; - - /** - * Returns the port number. - * @return the port number - */ - unsigned short port() const; - - /** - * Returns flowinfo for IPv6 socket. - * @return the flowinfo, 0 if unsupported - */ - TQ_UINT32 flowinfo() const; - - /** - * Returns the scope id for this IPv6 socket. - * @return the scope id - */ - int scopeId() const; - - /** - * Returns the socket length. - * Will be either sizeof(sockaddr_in) or sizeof(sockaddr_in6) - * @return the length of the socket - */ - virtual ksocklen_t size() const; // should be socklen_t - - /* comparation */ - /** - * Compares two IPv4 addresses. - * @param s1 the first address to compare - * @param s2 the second address to compare - * @param coreOnly true if only core parts should be compared (only - * the address) - * @return true if the given addresses are equal. - * @see areEqualInet6() - * @see KSocketAddress::isEqual() - * @see KSocketAddress::isCoreEqual() - */ - static bool areEqualInet(const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly); - - /** - * Compares two IPv6 addresses. - * @param s1 the first address to compare - * @param s2 the second address to compare - * @param coreOnly true if only core parts should be compared (only - * the address) - * @return true if the given addresses are equal. - * @see areEqualInet() - * @see KSocketAddress::isEqual() - * @see KSocketAddress::isCoreEqual() - */ - static bool areEqualInet6(const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly); - - /* operators */ - - /** - * Returns the socket address. - * This will be NULL if this is a non-convertible v6. - * @return the sockaddr_in structure, can be 0 if v6. - * @see addressV4() - */ - operator const sockaddr_in*() const - { return addressV4(); } - - /** - * Returns the socket address. - * @return the sockaddr_in structure, can be 0 if v6 is unsupported. - * @see addressV6() - */ - operator const sockaddr_in6*() const - { return addressV6(); } - - /** - * Sets this object to be the same as the other. - */ - KInetSocketAddress& operator=(const KInetSocketAddress &other) - { setAddress(other); return *this; } - -private: - - void fromV4(); - void fromV6(); - -public: - /** - * Convert s the given raw address into text form. - * This function returns TQString::null if the address cannot be converted. - * @param family the family of the address - * @param addr the address, in raw form - * @return the converted address, or TQString::null if not possible. - */ - static TQString addrToString(int family, const void *addr); - - /** - * Converts the address given in text form into raw form. - * The size of the destination buffer @p dest is supposed to be - * large enough to hold the address of the given family. - * @param family the family of the address - * @param text the text representation of the address - * @param dest the destination buffer of the address - * @return true if convertion was successful. - */ - static bool stringToAddr(int family, const char *text, void *dest); - - friend class KExtendedSocket; -protected: - virtual void virtual_hook( int id, void* data ); -private: - KInetSocketAddressPrivate* d; -}; - -extern const ::KInetSocketAddress addressAny, addressLoopback; - -/* - * External definition KUnixSocketAddress - */ -struct sockaddr_un; - -class KUnixSocketAddressPrivate; -/** - * A Unix socket address - * - * This is a Unix socket address. - * - * This class expects TQCString instead of TQString values, which means the - * filenames should be encoded in whatever form locale/system deems necessary - * before passing down to the function - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - * @short a Unix socket address - */ -class KDECORE_EXPORT KUnixSocketAddress: public ::KSocketAddress -{ - Q_OBJECT -public: - /** - * Default constructor - */ - KUnixSocketAddress(); - - /** - * Constructor from raw data. - * @param raw_data raw data - * @param size data length - */ - KUnixSocketAddress(const sockaddr_un* raw_data, ksocklen_t size); - - /** - * Constructor from pathname. - * @param pathname pathname - */ - KUnixSocketAddress(TQCString pathname); - - /** - * Destructor - */ - virtual ~KUnixSocketAddress(); - - /** - * Sets this to given sockaddr_un. - * @param socket_address socket address - * @param size the socket length - * @return true if successful, false otherwise - */ - bool setAddress(const sockaddr_un* socket_address, ksocklen_t size); - - /** - * Sets this to given pathname. - * @param path pathname - * @return true if successful, false otherwise - */ - bool setAddress(TQCString path); - - /** - * Returns the pathname. - * @return the pathname, can be TQCString::null if uninitialized, or - * "" if unknown - */ - TQCString pathname() const; - - /** - * Returns pretty representation of this socket. - * @return a pretty text representation of the socket. - */ - virtual TQString pretty() const; - - /* - * Returns the path in the form of a TQString. - * This can be fed into KExtendedSocket. - * @return the path (can be TQString::null). - * @see pathname() - */ - virtual TQString serviceName() const; - - /** - * Returns raw socket address. - * @return the raw socket address (can be 0 if uninitialized) - */ - const sockaddr_un* address() const; - - /** - * Returns raw socket address. - * @return the raw socket address (can be 0 if uninitialized) - * @see address() - */ - operator const sockaddr_un*() const - { return address(); } - - /** - * Compares two unix socket addresses. - * @param s1 the first address to compare - * @param s2 the second address to compare - * @param coreOnly true if only core parts should be compared (currently - * unused) - * @return true if the given addresses are equal. - * @see KSocketAddress::isEqual() - * @see KSocketAddress::isCoreEqual() - */ - static bool areEqualUnix(const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly); - -private: - void init(); - - friend class KExtendedSocket; -protected: - virtual void virtual_hook( int id, void* data ); -private: - KUnixSocketAddressPrivate* d; -}; - -#endif // KSOCKADDR_H diff --git a/kdecore/ksocks.cpp b/kdecore/ksocks.cpp deleted file mode 100644 index e596c50d9..000000000 --- a/kdecore/ksocks.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001-2003 George Staikos <staikos@kde.org> - - 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> - -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif - -#include <tqfile.h> -#include <tqstring.h> -#include <tqmap.h> - -#include <klocale.h> -#include <kdebug.h> -#include "klibloader.h" -#include <kconfig.h> -#include <kapplication.h> - -#include <sys/types.h> -#include <sys/socket.h> - -#include <unistd.h> - -#include "ksocks.h" - -// DO NOT RE-ORDER THESE. -enum SymbolKeys { - S_SOCKSinit = 0, - S_connect = 1, - S_read = 2, - S_write = 3, - S_recvfrom = 4, - S_sendto = 5, - S_recv = 6, - S_send = 7, - S_getsockname = 8, - S_getpeername = 9, - S_accept = 10, - S_select = 11, - S_listen = 12, - S_bind = 13 - }; - - -extern "C" { -// Function pointer table -static int (*F_SOCKSinit) (char *) = 0L; -static int (*F_connect) (int, const struct sockaddr *, ksocklen_t) = 0L; -static signed long int (*F_read) (int, void *, unsigned long int) = 0L; -static signed long int (*F_write) (int, const void *, unsigned long int) = 0L; -static int (*F_recvfrom) (int, void *, unsigned long int, int, struct sockaddr *, - ksocklen_t *) = 0L; -static int (*F_sendto) (int, const void *, unsigned long int, int, - const struct sockaddr *, ksocklen_t) = 0L; -static int (*F_recv) (int, void *, unsigned long int, int) = 0L; -static int (*F_send) (int, const void *, unsigned long int, int) = 0L; -static int (*F_getsockname) (int, struct sockaddr *, ksocklen_t *) = 0L; -static int (*F_getpeername) (int, struct sockaddr *, ksocklen_t *) = 0L; -static int (*F_accept) (int, struct sockaddr *, ksocklen_t *) = 0L; -static int (*F_select) (int, fd_set *, fd_set *, fd_set *, - struct timeval *) = 0L; -static int (*F_listen) (int, int) = 0L; -static int (*F_bind) (int, const struct sockaddr *, ksocklen_t) = 0L; -} - - -class KSocksTable { - public: - KSocksTable(); - virtual ~KSocksTable(); - - // The name of each symbol and it's SOCKS replacement - TQMap<SymbolKeys,TQString> symbols; - // The name of this library - TQString myname; - bool hasWorkingAsyncConnect; -}; - - -KSocksTable::KSocksTable() : myname("Unknown"), hasWorkingAsyncConnect(true) { -} - -KSocksTable::~KSocksTable() { -} - - -/* - * How to add support for a new SOCKS package. - * - * 1) Subclass KSocksTable as is done below and write out all the symbols - * 1.b) Give the class a "myname" - * 2) Make sure that all possible library names are written into the - * _libNames string list. Don't forget that different OSes name shared - * libraries differently. Expect .so, .sl, .a (!) (AIX does this). - * 3) Find a unique symbol in the library that we can use to identify that - * library and write out the test case in the constructor - * 4) Make necessary changes to the KControl module in kdebase/kcontrol/.... - * 5) TEST! - * - */ - -////////////////////////////////////////////////////////////////// -/////// Define each library symbol table here /////// -////////////////////////////////////////////////////////////////// - - -// -// Support for NEC SOCKS client -// - -class KNECSocksTable : public KSocksTable { - public: - KNECSocksTable(); - virtual ~KNECSocksTable(); -}; - - -KNECSocksTable::KNECSocksTable() : KSocksTable() { - myname = i18n("NEC SOCKS client"); - symbols.insert(S_SOCKSinit, "SOCKSinit"); - symbols.insert(S_connect, "connect"); - symbols.insert(S_read, "read"); - symbols.insert(S_write, "write"); - symbols.insert(S_recvfrom, "recvfrom"); - symbols.insert(S_sendto, "sendto"); - symbols.insert(S_recv, "recv"); - symbols.insert(S_send, "send"); - symbols.insert(S_getsockname, "getsockname"); - symbols.insert(S_getpeername, "getpeername"); - symbols.insert(S_accept, "accept"); - symbols.insert(S_select, "select"); - symbols.insert(S_listen, "listen"); - symbols.insert(S_bind, "bind"); -} - -KNECSocksTable::~KNECSocksTable() { -} - - - - -// -// Support for Dante SOCKS client -// - -class KDanteSocksTable : public KSocksTable { - public: - KDanteSocksTable(); - virtual ~KDanteSocksTable(); -}; - -KDanteSocksTable::KDanteSocksTable() : KSocksTable() { - hasWorkingAsyncConnect = false; - myname = i18n("Dante SOCKS client"); - symbols.insert(S_SOCKSinit, "SOCKSinit"); - symbols.insert(S_connect, "Rconnect"); - symbols.insert(S_read, "Rread"); - symbols.insert(S_write, "Rwrite"); - symbols.insert(S_recvfrom, "Rrecvfrom"); - symbols.insert(S_sendto, "Rsendto"); - symbols.insert(S_recv, "Rrecv"); - symbols.insert(S_send, "Rsend"); - symbols.insert(S_getsockname, "Rgetsockname"); - symbols.insert(S_getpeername, "Rgetpeername"); - symbols.insert(S_accept, "Raccept"); - symbols.insert(S_select, "Rselect"); - symbols.insert(S_listen, "Rlisten"); - symbols.insert(S_bind, "Rbind"); -} - - -KDanteSocksTable::~KDanteSocksTable() { -} - - - -////////////////////////////////////////////////////////////////// -/////// End of all symbol table definitions /////// -////////////////////////////////////////////////////////////////// - - -KSocks *KSocks::_me = 0; -#ifdef __CYGWIN__ -bool KSocks::_disabled = true; -#else -bool KSocks::_disabled = false; -#endif -static KStaticDeleter<KSocks> med; - -void KSocks::disable() -{ - if (!_me) - _disabled = true; -} - -KSocks *KSocks::self() { - // Note that we don't use a static deleter here. It makes no sense and tends to cause crashes. - if (!_me) { - if (kapp) { - KConfigGroup cfg(kapp->config(), "Socks"); - _me = new KSocks(&cfg); - } else { - _disabled = true; - _me = new KSocks(0); - } - } - return _me; -} - -void KSocks::setConfig(KConfigBase *config) -{ - // We can change the config from disabled to enabled - // but not the other way around. - if (_me && _disabled) { - delete _me; - _me = 0; - _disabled = false; - } - if (!_me) - _me = new KSocks(config); -} - -bool KSocks::activated() { return (_me != 0L); } - - -KSocks::KSocks(KConfigBase *config) : _socksLib(0L), _st(0L) { - _hasSocks = false; - _useSocks = false; - - if (!config) - return; - - if (!(config->readBoolEntry("SOCKS_enable", false))) { - _disabled = true; - } - - if (_disabled) - return; - - _libPaths << "" - << "/usr/lib" KDELIBSUFF "/" - << "/usr/lib/" - << "/usr/local/lib" KDELIBSUFF "/" - << "/usr/local/lib/" - << "/usr/local/socks5/lib" KDELIBSUFF "/" - << "/usr/local/socks5/lib/" - << "/opt/socks5/lib" KDELIBSUFF "/" - << "/opt/socks5/lib/"; - _libNames << "libsocks.so" // Dante - << "libdsocksd.so.0" // Dante 1.1.14-2 on - // Debian unstable 17-12-2003 - << "libsocks5.so" // ? - << "libsocks5_sh.so"; // NEC - - // Add the custom library paths here - TQStringList newlibs = config->readListEntry("SOCKS_lib_path"); - - for (TQStringList::Iterator it = newlibs.begin(); - it != newlibs.end(); - ++it) { - TQString thisone = *it; - if (thisone[thisone.length()-1] != '/') thisone += "/"; - _libPaths << thisone; - kdDebug(171) << "KSocks added a new library path: " << thisone << endl; - } - - // Load the proper libsocks and KSocksTable - KLibLoader *ll = KLibLoader::self(); - - - int _meth = config->readNumEntry("SOCKS_method", 1); - /**** Current methods - * 1) Autodetect (read: any) 2) NEC - * 3) Dante 4) Custom - */ - - if (_meth == 4) { // try to load^H^H^H^Hguess at a custom library - _socksLib = ll->library(config->readPathEntry("SOCKS_lib").latin1()); - if (_socksLib && _socksLib->symbol("Rconnect")) { // Dante compatible? - _st = new KDanteSocksTable; - _useSocks = true; - _hasSocks = true; - } else if (_socksLib && _socksLib->symbol("connect")) { // NEC compatible? - _st = new KNECSocksTable; - _useSocks = true; - _hasSocks = true; - } else if (_socksLib) { - _socksLib->unload(); - _socksLib = 0L; - } - } else // leave this here "else for {}" - for (TQStringList::Iterator pit = _libPaths.begin(); - !_hasSocks && pit != _libPaths.end(); - ++pit) - for (TQStringList::Iterator it = _libNames.begin(); - it != _libNames.end(); - ++it) { - _socksLib = ll->library((*pit + *it).latin1()); - if (_socksLib) { - if ((_meth == 1 || _meth == 2) && - _socksLib->symbol("S5LogShowThreadIDS") != 0L) { // NEC SOCKS - kdDebug(171) << "Found NEC SOCKS" << endl; - _st = new KNECSocksTable; - _useSocks = true; - _hasSocks = true; - break; - } else if ((_meth == 1 || _meth == 3) && - _socksLib->symbol("sockaddr2ruleaddress") != 0L) { //Dante - kdDebug(171) << "Found Dante SOCKS" << endl; - _st = new KDanteSocksTable; - _useSocks = true; - _hasSocks = true; - break; - } else { - _socksLib->unload(); - _socksLib = 0L; - } - } - } - - // Load in all the symbols - if (_st) { - for (TQMap<SymbolKeys,TQString>::Iterator it = _st->symbols.begin(); - it != _st->symbols.end(); - ++it) { - switch(it.key()) { - case S_SOCKSinit: - F_SOCKSinit = (int (*)(char *)) - _socksLib->symbol(it.data().latin1()); - break; - case S_connect: - F_connect = (int (*)(int, const struct sockaddr *, ksocklen_t)) - _socksLib->symbol(it.data().latin1()); - break; - case S_read: - F_read = (signed long int (*)(int, void *, unsigned long int)) - _socksLib->symbol(it.data().latin1()); - break; - case S_write: - F_write = (signed long int (*)(int, const void *, unsigned long int)) - _socksLib->symbol(it.data().latin1()); - break; - case S_recvfrom: - F_recvfrom = (int (*)(int, void *, unsigned long int, int, - struct sockaddr *, ksocklen_t *)) - _socksLib->symbol(it.data().latin1()); - break; - case S_sendto: - F_sendto = (int (*)(int, const void *, unsigned long int, int, - const struct sockaddr *, ksocklen_t)) - _socksLib->symbol(it.data().latin1()); - break; - case S_recv: - F_recv = (int (*)(int, void *, unsigned long int, int)) - _socksLib->symbol(it.data().latin1()); - break; - case S_send: - F_send = (int (*)(int, const void *, unsigned long int, int)) - _socksLib->symbol(it.data().latin1()); - break; - case S_getsockname: - F_getsockname = (int (*)(int, struct sockaddr *, ksocklen_t *)) - _socksLib->symbol(it.data().latin1()); - break; - case S_getpeername: - F_getpeername = (int (*)(int, struct sockaddr *, ksocklen_t *)) - _socksLib->symbol(it.data().latin1()); - break; - case S_accept: - F_accept = (int (*)(int, struct sockaddr *, ksocklen_t *)) - _socksLib->symbol(it.data().latin1()); - break; - case S_select: - F_select = (int (*)(int, fd_set *, fd_set *, fd_set *, struct timeval *)) - _socksLib->symbol(it.data().latin1()); - break; - case S_listen: - F_listen = (int (*)(int, int)) - _socksLib->symbol(it.data().latin1()); - break; - case S_bind: - F_bind = (int (*)(int, const struct sockaddr *, ksocklen_t)) - _socksLib->symbol(it.data().latin1()); - break; - default: - kdDebug(171) << "KSocks got a symbol it doesn't know about!" << endl; - break; - } - } - - // Now we check for the critical stuff. - if (F_SOCKSinit) { - int rc = (*F_SOCKSinit)((char *)"KDE"); - if (rc != 0) - stopSocks(); - else kdDebug(171) << "SOCKS has been activated!" << endl; - } else { - stopSocks(); - } - } -} - - -KSocks::~KSocks() { - stopSocks(); - _me = 0; -} - -void KSocks::die() { - if (_me == this) { - _me = 0; - delete this; - } -} - -void KSocks::stopSocks() { - if (_hasSocks) { - // This library doesn't even provide the basics. - // It's probably broken. Let's abort. - _useSocks = false; - _hasSocks = false; - if (_socksLib) { - _socksLib->unload(); - _socksLib = 0L; - } - delete _st; - _st = 0L; - } -} - - -bool KSocks::usingSocks() { - return _useSocks; -} - - -bool KSocks::hasSocks() { - return _hasSocks; -} - - -void KSocks::disableSocks() { - _useSocks = false; -} - - -void KSocks::enableSocks() { - if (_hasSocks) - _useSocks = true; -} - -bool KSocks::hasWorkingAsyncConnect() -{ - return (_useSocks && _st) ? _st->hasWorkingAsyncConnect : true; -} - - -/* - * REIMPLEMENTED FUNCTIONS FROM LIBC - * - */ - -int KSocks::connect (int sockfd, const sockaddr *serv_addr, - ksocklen_t addrlen) { - if (_useSocks && F_connect) - return (*F_connect)(sockfd, serv_addr, addrlen); - else return ::connect(sockfd, (sockaddr*) serv_addr, (socklen_t)addrlen); -} - - -signed long int KSocks::read (int fd, void *buf, unsigned long int count) { - if (_useSocks && F_read) - return (*F_read)(fd, buf, count); - else return ::read(fd, buf, count); -} - - -signed long int KSocks::write (int fd, const void *buf, unsigned long int count) { - if (_useSocks && F_write) - return (*F_write)(fd, buf, count); - else return ::write(fd, buf, count); -} - - -int KSocks::recvfrom (int s, void *buf, unsigned long int len, int flags, - sockaddr *from, ksocklen_t *fromlen) { - if (_useSocks && F_recvfrom) { - return (*F_recvfrom)(s, buf, len, flags, from, fromlen); - } else { - socklen_t casted_len = (socklen_t) *fromlen; - int rc = ::recvfrom(s, (char*) buf, len, flags, from, &casted_len); - *fromlen = casted_len; - return rc; - } -} - - -int KSocks::sendto (int s, const void *msg, unsigned long int len, int flags, - const sockaddr *to, ksocklen_t tolen) { - if (_useSocks && F_sendto) - return (*F_sendto)(s, msg, len, flags, to, tolen); - else return ::sendto(s, (char*) msg, len, flags, to, (socklen_t)tolen); -} - - -int KSocks::recv (int s, void *buf, unsigned long int len, int flags) { - if (_useSocks && F_recv) - return (*F_recv)(s, buf, len, flags); - else return ::recv(s, (char*) buf, len, flags); -} - - -int KSocks::send (int s, const void *msg, unsigned long int len, int flags) { - if (_useSocks && F_send) - return (*F_send)(s, msg, len, flags); - else return ::send(s, (char*) msg, len, flags); -} - - -int KSocks::getsockname (int s, sockaddr *name, ksocklen_t *namelen) { - if (_useSocks && F_getsockname) { - return (*F_getsockname)(s, name, namelen); - } else { - socklen_t casted_len = *namelen; - int rc = ::getsockname(s, name, &casted_len); - *namelen = casted_len; - return rc; - } -} - - -int KSocks::getpeername (int s, sockaddr *name, ksocklen_t *namelen) { - if (_useSocks && F_getpeername) { - return (*F_getpeername)(s, name, namelen); - } else { - socklen_t casted_len = *namelen; - int rc = ::getpeername(s, name, &casted_len); - *namelen = casted_len; - return rc; - } -} - - -int KSocks::accept (int s, sockaddr *addr, ksocklen_t *addrlen) { - if (_useSocks && F_accept) { - return (*F_accept)(s, addr, addrlen); - } else { - socklen_t casted_len = *addrlen; - int rc = ::accept(s, addr, &casted_len); - *addrlen = casted_len; - return rc; - } -} - - -int KSocks::select (int n, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) { - if (_useSocks && F_select) - return (*F_select)(n, readfds, writefds, exceptfds, timeout); - else return ::select(n, readfds, writefds, exceptfds, timeout); -} - - -int KSocks::listen (int s, int backlog) { - if (_useSocks && F_listen) - return (*F_listen)(s, backlog); - else return ::listen(s, backlog); -} - - -int KSocks::bind (int sockfd, const sockaddr *my_addr, ksocklen_t addrlen) { - if (_useSocks && F_bind) - return (*F_bind)(sockfd, my_addr, addrlen); - else return ::bind(sockfd, my_addr, (socklen_t)addrlen); -} - -int KSocks::bind (int sockfd, sockaddr *my_addr, ksocklen_t addrlen) { - if (_useSocks && F_bind) - return (*F_bind)(sockfd, my_addr, addrlen); - else return ::bind(sockfd, my_addr, (socklen_t)addrlen); -} - - - diff --git a/kdecore/ksocks.h b/kdecore/ksocks.h deleted file mode 100644 index a95de56d4..000000000 --- a/kdecore/ksocks.h +++ /dev/null @@ -1,210 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001 George Staikos <staikos@kde.org> - - 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 _KSOCKS_H_ -#define _KSOCKS_H_ - -#include <tqstringlist.h> -#include <sys/types.h> -#include <sys/time.h> -#include <kstaticdeleter.h> -#include <kdelibs_export.h> - -#ifdef Q_OS_UNIX - -class KSocksTable; -class KSocksPrivate; -class KLibrary; -class KConfigBase; -struct sockaddr; - -typedef unsigned ksocklen_t; - - -/** - * This class provides you with an interface to a - * <a href="http://www.socks.nec.com/">SOCKS</a> Proxy server. A SOCKS server - * is able to provide full internet access behind a firewall. - * KSocks is a singleton; there can only be one instance at any - * given time. To obtain a reference to that instance, use - * self(). - * - * @short Access to a SOCKS Proxy. - */ -class KDECORE_EXPORT KSocks { - friend class KStaticDeleter<KSocks>; - -public: - - /** - * Return an instance of class KSocks *. - * You cannot delete this object. It is a singleton class. - * @return the KSock instance - */ - static KSocks *self(); - - /** - * Checks whether KSocks has been started (ie someone called self()) - * @return true if activated - */ - static bool activated(); - - /** - * Disable the use of SOCKS immediately - */ - void disableSocks(); - - /** - * Enable the use of SOCKS immediately if hasSocks() is true. - */ - void enableSocks(); - - /** - * Checks whether SOCKS is currently being used. - * @return true if SOCKS is currently being used. - */ - bool usingSocks(); - - /** - * Checks whether SOCKS is available for use. - * @return true if SOCKS is available for use. - */ - bool hasSocks(); - - /** - * Returns whether asynchronous connects work with the - * selected SOCKS impementation - */ - bool hasWorkingAsyncConnect(); - - /* - ** REIMPLEMENTATIONS OF LIBC SOCKET FUNCTIONS - **/ - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int connect (int sockfd, const sockaddr *serv_addr, - ksocklen_t addrlen); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - signed long int read (int fd, void *buf, unsigned long int count); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - signed long int write (int fd, const void *buf, unsigned long int count); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int recvfrom (int s, void *buf, unsigned long int len, int flags, - sockaddr *from, ksocklen_t *fromlen); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int sendto (int s, const void *msg, unsigned long int len, int flags, - const sockaddr *to, ksocklen_t tolen); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int recv (int s, void *buf, unsigned long int len, int flags); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int send (int s, const void *msg, unsigned long int len, int flags); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int getsockname (int s, sockaddr *name, ksocklen_t *namelen); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int getpeername (int s, sockaddr *name, ksocklen_t *namelen); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int accept (int s, sockaddr *addr, ksocklen_t *addrlen); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int select (int n, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout); - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int listen (int s, int backlog); - - /** - * This is the re-implementation of libc's function of the same - * name. Read the appropriate man page. - */ - int bind (int sockfd, sockaddr *my_addr, - ksocklen_t addrlen); - int bind (int sockfd, const sockaddr *my_addr, - ksocklen_t addrlen); - - /** - * If you're using this, you're probably doing something wrong. - * Please don't use it. - * @internal - */ - void die(); - - /** - * Set this before the first call to KSocks::self() and it will fail - * to initialize SOCKS. - */ - static void disable(); - - /** - * Set this before the first call to KSocks::self() and it will use - * @p config to read its configuration from. - */ - static void setConfig(KConfigBase *config); - -private: - KSocks(KConfigBase *config); - ~KSocks(); - - void stopSocks(); - - static KSocks *_me; - static bool _disabled; - TQStringList _libNames; - TQStringList _libPaths; - bool _useSocks, _hasSocks; - KLibrary* _socksLib; - - - KSocksTable *_st; - KSocksPrivate *d; -}; - -#endif //Q_OS_UNIX - -#endif //_KSOCKS_H_ diff --git a/kdecore/ksortablevaluelist.h b/kdecore/ksortablevaluelist.h deleted file mode 100644 index 3f7885ca4..000000000 --- a/kdecore/ksortablevaluelist.h +++ /dev/null @@ -1,171 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 KSORTABLEVALUELIST_H -#define KSORTABLEVALUELIST_H - -#include <tqpair.h> -#include <tqvaluelist.h> -#include "kdelibs_export.h" - -/** - * KSortableItem is a TQPair that provides several operators - * for sorting. - * @see KSortableValueList - */ -template<class T, class Key = int> class KSortableItem : public TQPair<Key,T> -{ -public: - /** - * Creates a new KSortableItem with the given values. - * @param i the first value - * @param t the second value - */ - KSortableItem( Key i, const T& t ) : TQPair<Key, T>( i, t ) {} - /** - * Creates a new KSortableItem that copies another one. - * @param rhs the other item to copy - */ - KSortableItem( const KSortableItem<T, Key> &rhs ) - : TQPair<Key,T>( rhs.first, rhs.second ) {} - - /** - * Creates a new KSortableItem with uninitialized values. - */ - KSortableItem() {} - - /** - * Assignment operator, just copies the item. - */ - KSortableItem<T, Key> &operator=( const KSortableItem<T, Key>& i ) { - this->first = i.first; - this->second = i.second; - return *this; - } - - // operators for sorting - /** - * Compares the two items. This implementation only compares - * the first value. - */ - bool operator> ( const KSortableItem<T, Key>& i2 ) const { - return (i2.first < this->first); - } - /** - * Compares the two items. This implementation only compares - * the first value. - */ - bool operator< ( const KSortableItem<T, Key>& i2 ) const { - return (this->first < i2.first); - } - /** - * Compares the two items. This implementation only compares - * the first value. - */ - bool operator>= ( const KSortableItem<T, Key>& i2 ) const { - return (this->first >= i2.first); - } - /** - * Compares the two items. This implementation only compares - * the first value. - */ - bool operator<= ( const KSortableItem<T, Key>& i2 ) const { - return !(i2.first < this->first); - } - /** - * Compares the two items. This implementation only compares - * the first value. - */ - bool operator== ( const KSortableItem<T, Key>& i2 ) const { - return (this->first == i2.first); - } - /** - * Compares the two items. This implementation only compares - * the first value. - */ - bool operator!= ( const KSortableItem<T, Key>& i2 ) const { - return (this->first != i2.first); - } - - /** - * @return the second value - */ - T& value() { return this->second; } - - /** - * Returns the second value. - */ - const T& value() const { return this->second; } - - /** - * @return the first value. - */ - Key index() const { return this->first; } -}; - - -/** - * KSortableValueList is a special TQValueList for - * KSortableItem. It includes convenience operators - * to get the first value of the KSortableItem and a method - * to sort all items. - */ -template <class T, class Key = int> -class KSortableValueList : public TQValueList<KSortableItem<T, Key> > -{ -public: - /** - * Insert a KSortableItem with the given values. - * @param i the first value - * @param t the second value - */ - void insert( Key i, const T& t ) { - TQValueList<KSortableItem<T, Key> >::append( KSortableItem<T, Key>( i, t ) ); - } - // add more as you please... - - /** - * Returns the first value of the KSortableItem at the given position. - * @return the first value of the KSortableItem - */ - T& operator[]( Key i ) { - return TQValueList<KSortableItem<T, Key> >::operator[]( i ).value(); - } - - /** - * Returns the first value of the KSortableItem at the given position. - * @return the first value of the KSortableItem - */ - const T& operator[]( Key i ) const { - return TQValueList<KSortableItem<T, Key> >::operator[]( i ).value(); - } - - /** - * Sorts the KSortableItems. - */ - void sort() { - qHeapSort( *this ); - } -}; - -// template <class T> class KSortableValueListIterator : public TQValueListIterator<KSortableItem<T> > -// { -// }; - -#endif // KSORTABLEVALUELIST_H diff --git a/kdecore/kstandarddirs.cpp b/kdecore/kstandarddirs.cpp deleted file mode 100644 index 87a509e13..000000000 --- a/kdecore/kstandarddirs.cpp +++ /dev/null @@ -1,1705 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> - Copyright (C) 1999 Stephan Kulow <coolo@kde.org> - Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - - 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. -*/ - -/* - * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> - * Version: $Id$ - * Generated: Thu Mar 5 16:05:28 EST 1998 - */ - -#include "config.h" - -#include <stdlib.h> -#include <assert.h> -#include <errno.h> -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#include <sys/param.h> -#include <sys/types.h> -#include <dirent.h> -#include <pwd.h> -#include <grp.h> - -#include <tqregexp.h> -#include <tqasciidict.h> -#include <tqdict.h> -#include <tqdir.h> -#include <tqfileinfo.h> -#include <tqstring.h> -#include <tqstringlist.h> - -#include "kstandarddirs.h" -#include "kconfig.h" -#include "kdebug.h" -#include "kinstance.h" -#include "kshell.h" -#include "ksimpleconfig.h" -#include "kuser.h" -#include "kstaticdeleter.h" -#include <kde_file.h> - -template class TQDict<TQStringList>; - -class KStandardDirs::KStandardDirsPrivate -{ -public: - KStandardDirsPrivate() - : restrictionsActive(false), - dataRestrictionActive(false), - checkRestrictions(true) - { } - - bool restrictionsActive; - bool dataRestrictionActive; - bool checkRestrictions; - TQAsciiDict<bool> restrictions; - TQStringList xdgdata_prefixes; - TQStringList xdgconf_prefixes; -}; - -// Singleton, with data shared by all kstandarddirs instances. -// Used in static methods like findExe() -class KStandardDirsSingleton -{ -public: - TQString defaultprefix; - TQString defaultbindir; - static KStandardDirsSingleton* self(); -private: - static KStandardDirsSingleton* s_self; -}; -static KStaticDeleter<KStandardDirsSingleton> kstds_sd; -KStandardDirsSingleton* KStandardDirsSingleton::s_self = 0; -KStandardDirsSingleton* KStandardDirsSingleton::self() { - if ( !s_self ) - kstds_sd.setObject( s_self, new KStandardDirsSingleton ); - return s_self; -} - -static const char* const types[] = {"html", "html-bundle", "icon", "apps", "sound", - "data", "locale", "locale-bundle", "services", "mime", - "servicetypes", "config", "exe", - "wallpaper", "lib", "pixmap", "templates", - "module", "qtplugins", - "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", - "xdgdata-icon", "xdgdata-pixmap", "xdgconf-autostart", - "kcfg", "emoticons", 0 }; - -static int tokenize( TQStringList& token, const TQString& str, - const TQString& delim ); - -KStandardDirs::KStandardDirs( ) : addedCustoms(false) -{ - d = new KStandardDirsPrivate; - dircache.setAutoDelete(true); - relatives.setAutoDelete(true); - absolutes.setAutoDelete(true); - savelocations.setAutoDelete(true); - addKDEDefaults(); -} - -KStandardDirs::~KStandardDirs() -{ - delete d; -} - -bool KStandardDirs::isRestrictedResource(const char *type, const TQString& relPath) const -{ - if (!d || !d->restrictionsActive) - return false; - - if (d->restrictions[type]) - return true; - - if (strcmp(type, "data")==0) - { - applyDataRestrictions(relPath); - if (d->dataRestrictionActive) - { - d->dataRestrictionActive = false; - return true; - } - } - return false; -} - -void KStandardDirs::applyDataRestrictions(const TQString &relPath) const -{ - TQString key; - int i = relPath.find(QChar('/')); - if (i != -1) - key = "data_"+relPath.left(i); - else - key = "data_"+relPath; - - if (d && d->restrictions[key.latin1()]) - d->dataRestrictionActive = true; -} - - -TQStringList KStandardDirs::allTypes() const -{ - TQStringList list; - for (int i = 0; types[i] != 0; ++i) - list.append(TQString::tqfromLatin1(types[i])); - return list; -} - -static void priorityAdd(TQStringList &prefixes, const TQString& dir, bool priority) -{ - if (priority && !prefixes.isEmpty()) - { - // Add in front but behind $KDEHOME - TQStringList::iterator it = prefixes.begin(); - it++; - prefixes.insert(it, 1, dir); - } - else - { - prefixes.append(dir); - } -} - -void KStandardDirs::addPrefix( const TQString& _dir ) -{ - addPrefix(_dir, false); -} - -void KStandardDirs::addPrefix( const TQString& _dir, bool priority ) -{ - if (_dir.isEmpty()) - return; - - TQString dir = _dir; - if (dir.tqat(dir.length() - 1) != QChar('/')) - dir += QChar('/'); - - if (!prefixes.contains(dir)) { - priorityAdd(prefixes, dir, priority); - dircache.clear(); - } -} - -void KStandardDirs::addXdgConfigPrefix( const TQString& _dir ) -{ - addXdgConfigPrefix(_dir, false); -} - -void KStandardDirs::addXdgConfigPrefix( const TQString& _dir, bool priority ) -{ - if (_dir.isEmpty()) - return; - - TQString dir = _dir; - if (dir.tqat(dir.length() - 1) != QChar('/')) - dir += QChar('/'); - - if (!d->xdgconf_prefixes.contains(dir)) { - priorityAdd(d->xdgconf_prefixes, dir, priority); - dircache.clear(); - } -} - -void KStandardDirs::addXdgDataPrefix( const TQString& _dir ) -{ - addXdgDataPrefix(_dir, false); -} - -void KStandardDirs::addXdgDataPrefix( const TQString& _dir, bool priority ) -{ - if (_dir.isEmpty()) - return; - - TQString dir = _dir; - if (dir.tqat(dir.length() - 1) != QChar('/')) - dir += QChar('/'); - - if (!d->xdgdata_prefixes.contains(dir)) { - priorityAdd(d->xdgdata_prefixes, dir, priority); - dircache.clear(); - } -} - -TQString KStandardDirs::kfsstnd_prefixes() -{ - return prefixes.join(TQChar(KPATH_SEPARATOR)); -} - -TQString KStandardDirs::kfsstnd_xdg_conf_prefixes() -{ - return d->xdgconf_prefixes.join(TQChar(KPATH_SEPARATOR)); -} - -TQString KStandardDirs::kfsstnd_xdg_data_prefixes() -{ - return d->xdgdata_prefixes.join(TQChar(KPATH_SEPARATOR)); -} - -bool KStandardDirs::addResourceType( const char *type, - const TQString& relativename ) -{ - return addResourceType(type, relativename, true); -} -bool KStandardDirs::addResourceType( const char *type, - const TQString& relativename, - bool priority ) -{ - if (relativename.isEmpty()) - return false; - - TQStringList *rels = relatives.find(type); - if (!rels) { - rels = new TQStringList(); - relatives.insert(type, rels); - } - TQString copy = relativename; - if (copy.tqat(copy.length() - 1) != QChar('/')) - copy += QChar('/'); - if (!rels->contains(copy)) { - if (priority) - rels->prepend(copy); - else - rels->append(copy); - dircache.remove(type); // clean the cache - return true; - } - return false; -} - -bool KStandardDirs::addResourceDir( const char *type, - const TQString& absdir) -{ - // KDE4: change priority to bring in line with addResourceType - return addResourceDir(type, absdir, false); -} - -bool KStandardDirs::addResourceDir( const char *type, - const TQString& absdir, - bool priority) -{ - TQStringList *paths = absolutes.find(type); - if (!paths) { - paths = new TQStringList(); - absolutes.insert(type, paths); - } - TQString copy = absdir; - if (copy.tqat(copy.length() - 1) != QChar('/')) - copy += QChar('/'); - - if (!paths->contains(copy)) { - if (priority) - paths->prepend(copy); - else - paths->append(copy); - dircache.remove(type); // clean the cache - return true; - } - return false; -} - -TQString KStandardDirs::findResource( const char *type, - const TQString& filename ) const -{ - if (!TQDir::isRelativePath(filename)) - return filename; // absolute dirs are absolute dirs, right? :-/ - -#if 0 -kdDebug() << "Find resource: " << type << endl; -for (TQStringList::ConstIterator pit = prefixes.begin(); - pit != prefixes.end(); - pit++) -{ - kdDebug() << "Prefix: " << *pit << endl; -} -#endif - - TQString dir = findResourceDir(type, filename); - if (dir.isEmpty()) - return dir; - else return dir + filename; -} - -static TQ_UINT32 updateHash(const TQString &file, TQ_UINT32 hash) -{ - TQCString cFile = TQFile::encodeName(file); - KDE_struct_stat buff; - if ((access(cFile, R_OK) == 0) && - (KDE_stat( cFile, &buff ) == 0) && - (S_ISREG( buff.st_mode ))) - { - hash = hash + (TQ_UINT32) buff.st_ctime; - } - return hash; -} - -TQ_UINT32 KStandardDirs::calcResourceHash( const char *type, - const TQString& filename, bool deep) const -{ - TQ_UINT32 hash = 0; - - if (!TQDir::isRelativePath(filename)) - { - // absolute dirs are absolute dirs, right? :-/ - return updateHash(filename, hash); - } - if (d && d->restrictionsActive && (strcmp(type, "data")==0)) - applyDataRestrictions(filename); - TQStringList candidates = resourceDirs(type); - TQString fullPath; - - for (TQStringList::ConstIterator it = candidates.begin(); - it != candidates.end(); ++it) - { - hash = updateHash(*it + filename, hash); - if (!deep && hash) - return hash; - } - return hash; -} - - -TQStringList KStandardDirs::findDirs( const char *type, - const TQString& reldir ) const -{ - TQDir testdir; - TQStringList list; - if (!TQDir::isRelativePath(reldir)) - { - testdir.setPath(reldir); - if (testdir.exists()) - { - if (reldir.endsWith("/")) - list.append(reldir); - else - list.append(reldir+QChar('/')); - } - return list; - } - - checkConfig(); - - if (d && d->restrictionsActive && (strcmp(type, "data")==0)) - applyDataRestrictions(reldir); - TQStringList candidates = resourceDirs(type); - - for (TQStringList::ConstIterator it = candidates.begin(); - it != candidates.end(); ++it) { - testdir.setPath(*it + reldir); - if (testdir.exists()) - list.append(testdir.absPath() + QChar('/')); - } - - return list; -} - -TQString KStandardDirs::findResourceDir( const char *type, - const TQString& filename) const -{ -#ifndef NDEBUG - if (filename.isEmpty()) { - kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; - return TQString::null; - } -#endif - - if (d && d->restrictionsActive && (strcmp(type, "data")==0)) - applyDataRestrictions(filename); - TQStringList candidates = resourceDirs(type); - TQString fullPath; - - for (TQStringList::ConstIterator it = candidates.begin(); - it != candidates.end(); ++it) { - if (exists(*it + filename)) { -#ifdef Q_WS_WIN //this ensures we're using installed .la files - if ((*it).isEmpty() && filename.right(3)==".la") { -#ifndef NDEBUG - kdDebug() << "KStandardDirs::findResourceDir() found .la in cwd: skipping. (fname=" << filename << ")" << endl; -#endif - continue; - } -#endif //Q_WS_WIN - return *it; - } - } - -#ifndef NDEBUG - if(false && strcmp(type, "locale")) - kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl; -#endif - - return TQString::null; -} - -bool KStandardDirs::exists(const TQString &fullPath) -{ - KDE_struct_stat buff; - if (access(TQFile::encodeName(fullPath), R_OK) == 0 && KDE_stat( TQFile::encodeName(fullPath), &buff ) == 0) - if (fullPath.tqat(fullPath.length() - 1) != QChar('/')) { - if (S_ISREG( buff.st_mode )) - return true; - } else - if (S_ISDIR( buff.st_mode )) - return true; - return false; -} - -static void lookupDirectory(const TQString& path, const TQString &relPart, - const TQRegExp ®exp, - TQStringList& list, - TQStringList& relList, - bool recursive, bool unique) -{ - TQString pattern = regexp.pattern(); - if (recursive || pattern.contains('?') || pattern.contains('*')) - { - if (path.isEmpty()) //for sanity - return; - // We look for a set of files. - DIR *dp = opendir( TQFile::encodeName(path)); - if (!dp) - return; - -#ifdef Q_WS_WIN - assert(path.tqat(path.length() - 1) == QChar('/') || path.tqat(path.length() - 1) == QChar('\\')); -#else - assert(path.tqat(path.length() - 1) == QChar('/')); -#endif - - struct dirent *ep; - KDE_struct_stat buff; - - TQString _dot("."); - TQString _dotdot(".."); - - while( ( ep = readdir( dp ) ) != 0L ) - { - TQString fn( TQFile::decodeName(ep->d_name)); - if (fn == _dot || fn == _dotdot || TQChar(fn.tqat(fn.length() - 1)).latin1() == TQChar('~').latin1()) - continue; - - if (!recursive && !regexp.exactMatch(fn)) - continue; // No match - - TQString pathfn = path + fn; - if ( KDE_stat( TQFile::encodeName(pathfn), &buff ) != 0 ) { - kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; - continue; // Couldn't stat (e.g. no read permissions) - } - if ( recursive ) { - if ( S_ISDIR( buff.st_mode )) { - lookupDirectory(pathfn + QChar('/'), relPart + fn + QChar('/'), regexp, list, relList, recursive, unique); - } - if (!regexp.exactMatch(fn)) - continue; // No match - } - if ( S_ISREG( buff.st_mode)) - { - if (!unique || !relList.contains(relPart + fn)) - { - list.append( pathfn ); - relList.append( relPart + fn ); - } - } - } - closedir( dp ); - } - else - { - // We look for a single file. - TQString fn = pattern; - TQString pathfn = path + fn; - KDE_struct_stat buff; - if ( KDE_stat( TQFile::encodeName(pathfn), &buff ) != 0 ) - return; // File not found - if ( S_ISREG( buff.st_mode)) - { - if (!unique || !relList.contains(relPart + fn)) - { - list.append( pathfn ); - relList.append( relPart + fn ); - } - } - } -} - -static void lookupPrefix(const TQString& prefix, const TQString& relpath, - const TQString& relPart, - const TQRegExp ®exp, - TQStringList& list, - TQStringList& relList, - bool recursive, bool unique) -{ - if (relpath.isEmpty()) { - lookupDirectory(prefix, relPart, regexp, list, - relList, recursive, unique); - return; - } - TQString path; - TQString rest; - - if (relpath.length()) - { - int slash = relpath.find(QChar('/')); - if (slash < 0) - rest = relpath.left(relpath.length() - 1); - else { - path = relpath.left(slash); - rest = relpath.mid(slash + 1); - } - } - - if (prefix.isEmpty()) //for sanity - return; -#ifdef Q_WS_WIN - assert(prefix.tqat(prefix.length() - 1) == QChar('/') || prefix.tqat(prefix.length() - 1) == QChar('\\')); -#else - assert(prefix.tqat(prefix.length() - 1) == QChar('/')); -#endif - KDE_struct_stat buff; - - if (path.contains('*') || path.contains('?')) { - - TQRegExp pathExp(path, true, true); - DIR *dp = opendir( TQFile::encodeName(prefix) ); - if (!dp) { - return; - } - - struct dirent *ep; - - TQString _dot("."); - TQString _dotdot(".."); - - while( ( ep = readdir( dp ) ) != 0L ) - { - TQString fn( TQFile::decodeName(ep->d_name)); - if (fn == _dot || fn == _dotdot || fn.tqat(fn.length() - 1) == QChar('~')) - continue; - - if ( !pathExp.exactMatch(fn) ) - continue; // No match - TQString rfn = relPart+fn; - fn = prefix + fn; - if ( KDE_stat( TQFile::encodeName(fn), &buff ) != 0 ) { - kdDebug() << "Error statting " << fn << " : " << perror << endl; - continue; // Couldn't stat (e.g. no permissions) - } - if ( S_ISDIR( buff.st_mode )) - lookupPrefix(fn + QChar('/'), rest, rfn + QChar('/'), regexp, list, relList, recursive, unique); - } - - closedir( dp ); - } else { - // Don't stat, if the dir doesn't exist we will find out - // when we try to open it. - lookupPrefix(prefix + path + QChar('/'), rest, - relPart + path + QChar('/'), regexp, list, - relList, recursive, unique); - } -} - -TQStringList -KStandardDirs::findAllResources( const char *type, - const TQString& filter, - bool recursive, - bool unique, - TQStringList &relList) const -{ - TQStringList list; - TQString filterPath; - TQString filterFile; - - if (filter.length()) - { - int slash = filter.findRev('/'); - if (slash < 0) - filterFile = filter; - else { - filterPath = filter.left(slash + 1); - filterFile = filter.mid(slash + 1); - } - } - - checkConfig(); - - TQStringList candidates; - if (!TQDir::isRelativePath(filter)) // absolute path - { -#ifdef Q_OS_WIN - candidates << filterPath.left(3); //e.g. "C:\" - filterPath = filterPath.mid(3); -#else - candidates << "/"; - filterPath = filterPath.mid(1); -#endif - } - else - { - if (d && d->restrictionsActive && (strcmp(type, "data")==0)) - applyDataRestrictions(filter); - candidates = resourceDirs(type); - } - if (filterFile.isEmpty()) - filterFile = "*"; - - TQRegExp regExp(filterFile, true, true); - - for (TQStringList::ConstIterator it = candidates.begin(); - it != candidates.end(); ++it) - { - lookupPrefix(*it, filterPath, "", regExp, list, - relList, recursive, unique); - } - - return list; -} - -TQStringList -KStandardDirs::findAllResources( const char *type, - const TQString& filter, - bool recursive, - bool unique) const -{ - TQStringList relList; - return findAllResources(type, filter, recursive, unique, relList); -} - -TQString -KStandardDirs::realPath(const TQString &dirname) -{ - char realpath_buffer[MAXPATHLEN + 1]; - memset(realpath_buffer, 0, MAXPATHLEN + 1); - - /* If the path contains symlinks, get the real name */ - if (realpath( TQFile::encodeName(dirname).data(), realpath_buffer) != 0) { - // success, use result from realpath - int len = strlen(realpath_buffer); - realpath_buffer[len] = TQChar('/'); - realpath_buffer[len+1] = 0; - return TQFile::decodeName(realpath_buffer); - } - - return dirname; -} - -TQString -KStandardDirs::realFilePath(const TQString &filename) -{ - char realpath_buffer[MAXPATHLEN + 1]; - memset(realpath_buffer, 0, MAXPATHLEN + 1); - - /* If the path contains symlinks, get the real name */ - if (realpath( TQFile::encodeName(filename).data(), realpath_buffer) != 0) { - // success, use result from realpath - return TQFile::decodeName(realpath_buffer); - } - - return filename; -} - -void KStandardDirs::createSpecialResource(const char *type) -{ - char hostname[256]; - hostname[0] = 0; - if( getenv("XAUTHLOCALHOSTNAME")) - strlcpy(hostname, getenv("XAUTHLOCALHOSTNAME"), 255 ); - else - gethostname(hostname, 255); - TQString dir = TQString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname); - char link[1024]; - link[1023] = 0; - int result = readlink(TQFile::encodeName(dir).data(), link, 1023); - bool relink = (result == -1) && (errno == ENOENT); - if (result > 0) - { - link[result] = 0; - if (!TQDir::isRelativePath(link)) - { - KDE_struct_stat stat_buf; - int res = KDE_lstat(link, &stat_buf); - if ((res == -1) && (errno == ENOENT)) - { - relink = true; - } - else if ((res == -1) || (!S_ISDIR(stat_buf.st_mode))) - { - fprintf(stderr, "Error: \"%s\" is not a directory.\n", link); - relink = true; - } - else if (stat_buf.st_uid != getuid()) - { - fprintf(stderr, "Error: \"%s\" is owned by uid %d instead of uid %d.\n", link, stat_buf.st_uid, getuid()); - relink = true; - } - } - } -#ifdef Q_WS_WIN - if (relink) - { - if (!makeDir(dir, 0700)) - fprintf(stderr, "failed to create \"%s\"", dir.latin1()); - else - result = readlink(TQFile::encodeName(dir).data(), link, 1023); - } -#else //UNIX - if (relink) - { - TQString srv = findExe(TQString::tqfromLatin1("lnusertemp"), kfsstnd_defaultbindir()); - if (srv.isEmpty()) - srv = findExe(TQString::tqfromLatin1("lnusertemp")); - if (!srv.isEmpty()) - { - system(TQFile::encodeName(srv)+" "+type); - result = readlink(TQFile::encodeName(dir).data(), link, 1023); - } - } - if (result > 0) - { - link[result] = 0; - if (link[0] == TQChar('/').latin1()) - dir = TQFile::decodeName(link); - else - dir = TQDir::cleanDirPath(dir+TQFile::decodeName(link)); - } -#endif - addResourceDir(type, dir+QChar('/')); -} - -TQStringList KStandardDirs::resourceDirs(const char *type) const -{ - TQStringList *candidates = dircache.find(type); - - if (!candidates) { // filling cache - if (strcmp(type, "socket") == 0) - const_cast<KStandardDirs *>(this)->createSpecialResource(type); - else if (strcmp(type, "tmp") == 0) - const_cast<KStandardDirs *>(this)->createSpecialResource(type); - else if (strcmp(type, "cache") == 0) - const_cast<KStandardDirs *>(this)->createSpecialResource(type); - - TQDir testdir; - - candidates = new TQStringList(); - TQStringList *dirs; - - bool restrictionActive = false; - if (d && d->restrictionsActive) - { - if (d->dataRestrictionActive) - restrictionActive = true; - else if (d->restrictions["all"]) - restrictionActive = true; - else if (d->restrictions[type]) - restrictionActive = true; - d->dataRestrictionActive = false; // Reset - } - - dirs = relatives.find(type); - if (dirs) - { - bool local = true; - const TQStringList *prefixList = 0; - if (strncmp(type, "xdgdata-", 8) == 0) - prefixList = &(d->xdgdata_prefixes); - else if (strncmp(type, "xdgconf-", 8) == 0) - prefixList = &(d->xdgconf_prefixes); - else - prefixList = &prefixes; - - for (TQStringList::ConstIterator pit = prefixList->begin(); - pit != prefixList->end(); - ++pit) - { - for (TQStringList::ConstIterator it = dirs->begin(); - it != dirs->end(); ++it) { - TQString path = realPath(*pit + *it); - testdir.setPath(path); - if (local && restrictionActive) - continue; - if ((local || testdir.exists()) && !candidates->contains(path)) - candidates->append(path); - } - // UGLY HACK - Chris CHeney - if (local && (!strcmp("config", type))) - candidates->append("/etc/trinity/"); - // - local = false; - } - } - dirs = absolutes.find(type); - if (dirs) - for (TQStringList::ConstIterator it = dirs->begin(); - it != dirs->end(); ++it) - { - testdir.setPath(*it); - if (testdir.exists()) - { - TQString filename = realPath(*it); - if (!candidates->contains(filename)) - candidates->append(filename); - } - } - dircache.insert(type, candidates); - } - -#if 0 - kdDebug() << "found dirs for resource " << type << ":" << endl; - for (TQStringList::ConstIterator pit = candidates->begin(); - pit != candidates->end(); - pit++) - { - fprintf(stderr, "%s\n", (*pit).latin1()); - } -#endif - - - return *candidates; -} - -TQStringList KStandardDirs::systemPaths( const TQString& pstr ) -{ - TQStringList tokens; - TQString p = pstr; - - if( p.isNull() ) - { - p = getenv( "PATH" ); - } - - TQString delimiters(TQChar(KPATH_SEPARATOR)); - delimiters += "\b"; - tokenize( tokens, p, delimiters ); - - TQStringList exePaths; - - // split path using : or \b as delimiters - for( unsigned i = 0; i < tokens.count(); i++ ) - { - p = tokens[ i ]; - - if ( p[ 0 ] == QChar('~') ) - { - int len = p.find( QChar('/') ); - if ( len == -1 ) - len = p.length(); - if ( len == 1 ) - { - p.replace( 0, 1, TQDir::homeDirPath() ); - } - else - { - TQString user = p.mid( 1, len - 1 ); - struct passwd *dir = getpwnam( user.local8Bit().data() ); - if ( dir && strlen( dir->pw_dir ) ) - p.replace( 0, len, TQString::fromLocal8Bit( dir->pw_dir ) ); - } - } - - exePaths << p; - } - - return exePaths; -} - - -TQString KStandardDirs::findExe( const TQString& appname, - const TQString& pstr, bool ignore) -{ -#ifdef Q_WS_WIN - TQString real_appname = appname + ".exe"; -#else - TQString real_appname = appname; -#endif - TQFileInfo info; - - // absolute or relative path given - if (real_appname.find(TQDir::separator()) >= 0) - { - info.setFile( real_appname ); - if( info.exists() && ( ignore || info.isExecutable() ) - && info.isFile() ) { - return info.absFilePath(); - } - return TQString::null; - } - - TQString p = TQString("%1/%2").arg(kfsstnd_defaultbindir()).arg(real_appname); - info.setFile( p ); - if( info.exists() && ( ignore || info.isExecutable() ) - && ( info.isFile() || info.isSymLink() ) ) { - return p; - } - - TQStringList exePaths = systemPaths( pstr ); - for (TQStringList::ConstIterator it = exePaths.begin(); it != exePaths.end(); ++it) - { - p = (*it) + "/"; - p += real_appname; - - // Check for executable in this tokenized path - info.setFile( p ); - - if( info.exists() && ( ignore || info.isExecutable() ) - && ( info.isFile() || info.isSymLink() ) ) { - return p; - } - } - - // If we reach here, the executable wasn't found. - // So return empty string. - - return TQString::null; -} - -int KStandardDirs::findAllExe( TQStringList& list, const TQString& appname, - const TQString& pstr, bool ignore ) -{ -#ifdef Q_WS_WIN - TQString real_appname = appname + ".exe"; -#else - TQString real_appname = appname; -#endif - TQFileInfo info; - TQString p; - list.clear(); - - TQStringList exePaths = systemPaths( pstr ); - for (TQStringList::ConstIterator it = exePaths.begin(); it != exePaths.end(); ++it) - { - p = (*it) + "/"; - p += real_appname; - - info.setFile( p ); - - if( info.exists() && (ignore || info.isExecutable()) - && info.isFile() ) { - list.append( p ); - } - } - - return list.count(); -} - -static int tokenize( TQStringList& tokens, const TQString& str, - const TQString& delim ) -{ - int len = str.length(); - TQString token = ""; - - for( int index = 0; index < len; index++) - { - if ( delim.find( str[ index ] ) >= 0 ) - { - tokens.append( token ); - token = ""; - } - else - { - token += str[ index ]; - } - } - if ( token.length() > 0 ) - { - tokens.append( token ); - } - - return tokens.count(); -} - -TQString KStandardDirs::kde_default(const char *type) { - if (!strcmp(type, "data")) - return "share/apps/"; - if (!strcmp(type, "html-bundle")) - return "share/doc-bundle/HTML/"; - if (!strcmp(type, "html")) - return "share/doc/kde/HTML/"; - if (!strcmp(type, "icon")) - return "share/icons/"; - if (!strcmp(type, "config")) - return "share/config/"; - if (!strcmp(type, "pixmap")) - return "share/pixmaps/"; - if (!strcmp(type, "apps")) - return "share/applnk/"; - if (!strcmp(type, "sound")) - return "share/sounds/"; - if (!strcmp(type, "locale-bundle")) - return "share/locale-bundle/"; - if (!strcmp(type, "locale")) - return "share/locale/"; - if (!strcmp(type, "services")) - return "share/services/"; - if (!strcmp(type, "servicetypes")) - return "share/servicetypes/"; - if (!strcmp(type, "mime")) - return "share/mimelnk/"; - if (!strcmp(type, "cgi")) - return "lib/cgi-bin/"; - if (!strcmp(type, "wallpaper")) - return "share/wallpapers/"; - if (!strcmp(type, "templates")) - return "share/templates/"; - if (!strcmp(type, "exe")) - return "bin/"; - if (!strcmp(type, "lib")) - return "lib" KDELIBSUFF "/"; - if (!strcmp(type, "module")) - return "lib" KDELIBSUFF "/trinity/"; - if (!strcmp(type, "qtplugins")) - return "lib" KDELIBSUFF "/trinity/plugins"; - if (!strcmp(type, "xdgdata-apps")) - return "applications/"; - if (!strcmp(type, "xdgdata-icon")) - return "icons/"; - if (!strcmp(type, "xdgdata-pixmap")) - return "pixmaps/"; - if (!strcmp(type, "xdgdata-dirs")) - return "desktop-directories/"; - if (!strcmp(type, "xdgconf-menu")) - return "menus/"; - if (!strcmp(type, "xdgconf-autostart")) - return "autostart/"; - if (!strcmp(type, "kcfg")) - return "share/config.kcfg"; - if (!strcmp(type, "emoticons")) - return "share/emoticons"; - - - qFatal("unknown resource type %s", type); - return TQString::null; -} - -TQString KStandardDirs::saveLocation(const char *type, - const TQString& suffix, - bool create) const -{ - checkConfig(); - - TQString *pPath = savelocations.find(type); - if (!pPath) - { - TQStringList *dirs = relatives.find(type); - if (!dirs && ( - (strcmp(type, "socket") == 0) || - (strcmp(type, "tmp") == 0) || - (strcmp(type, "cache") == 0) )) - { - (void) resourceDirs(type); // Generate socket|tmp|cache resource. - dirs = relatives.find(type); // Search again. - } - if (dirs) - { - // Check for existence of typed directory + suffix - if (strncmp(type, "xdgdata-", 8) == 0) - pPath = new TQString(realPath(localxdgdatadir() + dirs->last())); - else if (strncmp(type, "xdgconf-", 8) == 0) - pPath = new TQString(realPath(localxdgconfdir() + dirs->last())); - else - pPath = new TQString(realPath(localkdedir() + dirs->last())); - } - else { - dirs = absolutes.find(type); - if (!dirs) - qFatal("KStandardDirs: The resource type %s is not registered", type); - pPath = new TQString(realPath(dirs->last())); - } - - savelocations.insert(type, pPath); - } - TQString fullPath = *pPath + (pPath->endsWith("/") ? "" : "/") + suffix; - - KDE_struct_stat st; - if (KDE_stat(TQFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) { - if(!create) { -#ifndef NDEBUG - kdDebug() << TQString("save location %1 doesn't exist").tqarg(fullPath) << endl; -#endif - return fullPath; - } - if(!makeDir(fullPath, 0700)) { - return fullPath; - } - dircache.remove(type); - } - if (!fullPath.endsWith("/")) - fullPath += "/"; - return fullPath; -} - -TQString KStandardDirs::relativeLocation(const char *type, const TQString &absPath) -{ - TQString fullPath = absPath; - int i = absPath.findRev('/'); - if (i != -1) - { - fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize - } - - TQStringList candidates = resourceDirs(type); - - for (TQStringList::ConstIterator it = candidates.begin(); - it != candidates.end(); ++it) - if (fullPath.startsWith(*it)) - { - return fullPath.mid((*it).length()); - } - - return absPath; -} - - -bool KStandardDirs::makeDir(const TQString& dir, int mode) -{ - // we want an absolute path - if (TQDir::isRelativePath(dir)) - return false; - - TQString target = dir; - uint len = target.length(); - - // append trailing slash if missing - if (dir.tqat(len - 1) != QChar('/')) - target += QChar('/'); - - TQString base(""); - uint i = 1; - - while( i < len ) - { - KDE_struct_stat st; - int pos = target.find(QChar('/'), i); - base += target.mid(i - 1, pos - i + 1); - TQCString baseEncoded = TQFile::encodeName(base); - // bail out if we encountered a problem - if (KDE_stat(baseEncoded, &st) != 0) - { - // Directory does not exist.... - // Or maybe a dangling symlink ? - if (KDE_lstat(baseEncoded, &st) == 0) - (void)unlink(baseEncoded); // try removing - - if ( KDE_mkdir(baseEncoded, (mode_t) mode) != 0) { - baseEncoded.prepend( "trying to create local folder " ); - perror(baseEncoded.data()); - return false; // Couldn't create it :-( - } - } - i = pos + 1; - } - return true; -} - -static TQString readEnvPath(const char *env) -{ - TQCString c_path = getenv(env); - if (c_path.isEmpty()) - return TQString::null; -#ifdef Q_OS_WIN - //win32 paths are case-insensitive: avoid duplicates on various dir lists - return TQFile::decodeName(c_path).lower(); -#else - return TQFile::decodeName(c_path); -#endif -} - -#ifdef __linux__ -static TQString executablePrefix() -{ - char path_buffer[MAXPATHLEN + 1]; - path_buffer[MAXPATHLEN] = 0; - int length = readlink ("/proc/self/exe", path_buffer, MAXPATHLEN); - if (length == -1) - return TQString::null; - - path_buffer[length] = TQChar('\0'); - - TQString path = TQFile::decodeName(path_buffer); - - if(path.isEmpty()) - return TQString::null; - - int pos = path.findRev('/'); // Skip filename - if(pos <= 0) - return TQString::null; - pos = path.findRev(TQChar('/'), pos - 1); // Skip last directory - if(pos <= 0) - return TQString::null; - - return path.left(pos); -} -#endif - -TQString KStandardDirs::kfsstnd_defaultprefix() -{ - KStandardDirsSingleton* s = KStandardDirsSingleton::self(); - if (!s->defaultprefix.isEmpty()) - return s->defaultprefix; -#ifdef Q_WS_WIN - s->defaultprefix = readEnvPath("KDEDIR"); - if (s->defaultprefix.isEmpty()) { - s->defaultprefix = TQFile::decodeName("c:\\kde"); - //TODO: find other location (the Registry?) - } -#else //UNIX - s->defaultprefix = KDEDIR; -#endif - if (s->defaultprefix.isEmpty()) - kdWarning() << "KStandardDirs::kfsstnd_defaultprefix(): default KDE prefix not found!" << endl; - return s->defaultprefix; -} - -TQString KStandardDirs::kfsstnd_defaultbindir() -{ - KStandardDirsSingleton* s = KStandardDirsSingleton::self(); - if (!s->defaultbindir.isEmpty()) - return s->defaultbindir; -#ifdef Q_WS_WIN - s->defaultbindir = kfsstnd_defaultprefix() + TQString::tqfromLatin1("/bin"); -#else //UNIX - s->defaultbindir = __KDE_BINDIR; - if (s->defaultbindir.isEmpty()) - s->defaultbindir = kfsstnd_defaultprefix() + TQString::tqfromLatin1("/bin"); -#endif - if (s->defaultbindir.isEmpty()) - kdWarning() << "KStandardDirs::kfsstnd_defaultbindir(): default binary KDE dir not found!" << endl; - return s->defaultbindir; -} - -void KStandardDirs::addKDEDefaults() -{ - TQStringList kdedirList; - - // begin KDEDIRS - TQString kdedirs = readEnvPath("KDEDIRS"); - if (!kdedirs.isEmpty()) - { - tokenize(kdedirList, kdedirs, TQChar(KPATH_SEPARATOR)); - } - else - { - TQString kdedir = readEnvPath("KDEDIR"); - if (!kdedir.isEmpty()) - { - kdedir = KShell::tildeExpand(kdedir); - kdedirList.append(kdedir); - } - } - -#ifndef Q_OS_WIN //no default KDEDIR on win32 defined - kdedirList.append(KDEDIR); -#endif - -#ifdef __KDE_EXECPREFIX - TQString execPrefix(__KDE_EXECPREFIX); - if (execPrefix!="NONE") - kdedirList.append(execPrefix); -#endif -#ifdef __linux__ - const TQString linuxExecPrefix = executablePrefix(); - if ( !linuxExecPrefix.isEmpty() ) - kdedirList.append( linuxExecPrefix ); -#endif - - // We treat root differently to prevent a "su" shell messing up the - // file permissions in the user's home directory. - TQString localKdeDir; - if (getuid() == 0) { - localKdeDir = readEnvPath("KDEROOTHOME"); - if (localKdeDir.isEmpty() == true) - localKdeDir = readEnvPath("KDEHOME"); - } - else { - localKdeDir = readEnvPath("KDEHOME"); - } - if (!localKdeDir.isEmpty()) - { - if (localKdeDir[localKdeDir.length()-1] != QChar('/')) - localKdeDir += QChar('/'); - } - else - { - localKdeDir = TQDir::homeDirPath() + "/.trinity/"; - } - - if (localKdeDir != QString("-/")) - { - localKdeDir = KShell::tildeExpand(localKdeDir); - addPrefix(localKdeDir); - } - - TQStringList::ConstIterator end(kdedirList.end()); - for (TQStringList::ConstIterator it = kdedirList.begin(); - it != end; ++it) - { - TQString dir = KShell::tildeExpand(*it); - addPrefix(dir); - } - // end KDEDIRS - - // begin XDG_CONFIG_XXX - TQStringList xdgdirList; - TQString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); - if (!xdgdirs.isEmpty()) - { - tokenize(xdgdirList, xdgdirs, TQChar(KPATH_SEPARATOR)); - } - else - { - xdgdirList.clear(); - xdgdirList.append("/etc/xdg"); -#ifdef Q_WS_WIN - xdgdirList.append(kfsstnd_defaultprefix() + "/etc/xdg"); -#else - xdgdirList.append(KDESYSCONFDIR "/xdg"); -#endif - } - - TQString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); - if (!localXdgDir.isEmpty()) - { - if (localXdgDir[localXdgDir.length()-1] != QChar('/')) - localXdgDir += QChar('/'); - } - else - { - localXdgDir = TQDir::homeDirPath() + "/.config/"; - } - - localXdgDir = KShell::tildeExpand(localXdgDir); - addXdgConfigPrefix(localXdgDir); - - for (TQStringList::ConstIterator it = xdgdirList.begin(); - it != xdgdirList.end(); ++it) - { - TQString dir = KShell::tildeExpand(*it); - addXdgConfigPrefix(dir); - } - // end XDG_CONFIG_XXX - - // begin XDG_DATA_XXX - xdgdirs = readEnvPath("XDG_DATA_DIRS"); - if (!xdgdirs.isEmpty()) - { - tokenize(xdgdirList, xdgdirs, TQChar(KPATH_SEPARATOR)); - } - else - { - xdgdirList.clear(); - for (TQStringList::ConstIterator it = kdedirList.begin(); - it != kdedirList.end(); ++it) - { - TQString dir = *it; - if (dir[dir.length()-1] != QChar('/')) - dir += QChar('/'); - xdgdirList.append(dir+"share/"); - } - - xdgdirList.append("/usr/local/share/"); - xdgdirList.append("/usr/share/"); - } - - localXdgDir = readEnvPath("XDG_DATA_HOME"); - if (!localXdgDir.isEmpty()) - { - if (localXdgDir[localXdgDir.length()-1] != QChar('/')) - localXdgDir += QChar('/'); - } - else - { - localXdgDir = TQDir::homeDirPath() + "/.local/share/"; - } - - localXdgDir = KShell::tildeExpand(localXdgDir); - addXdgDataPrefix(localXdgDir); - - for (TQStringList::ConstIterator it = xdgdirList.begin(); - it != xdgdirList.end(); ++it) - { - TQString dir = KShell::tildeExpand(*it); - addXdgDataPrefix(dir); - } - // end XDG_DATA_XXX - - - uint index = 0; - while (types[index] != 0) { - addResourceType(types[index], kde_default(types[index])); - index++; - } - - addResourceDir("home", TQDir::homeDirPath()); - - addResourceDir("locale", "/usr/share/locale-langpack/", true); -} - -void KStandardDirs::checkConfig() const -{ - if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) - const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); -} - -static TQStringList lookupProfiles(const TQString &mapFile) -{ - TQStringList profiles; - - if (mapFile.isEmpty() || !TQFile::exists(mapFile)) - { - profiles << "default"; - return profiles; - } - - struct passwd *pw = getpwuid(geteuid()); - if (!pw) - { - profiles << "default"; - return profiles; // Not good - } - - TQCString user = pw->pw_name; - - gid_t sup_gids[512]; - int sup_gids_nr = getgroups(512, sup_gids); - - KSimpleConfig mapCfg(mapFile, true); - mapCfg.setGroup("Users"); - if (mapCfg.hasKey(user.data())) - { - profiles = mapCfg.readListEntry(user.data()); - return profiles; - } - - mapCfg.setGroup("General"); - TQStringList groups = mapCfg.readListEntry("groups"); - - mapCfg.setGroup("Groups"); - - for( TQStringList::ConstIterator it = groups.begin(); - it != groups.end(); ++it ) - { - TQCString grp = (*it).utf8(); - // Check if user is in this group - struct group *grp_ent = getgrnam(grp); - if (!grp_ent) continue; - gid_t gid = grp_ent->gr_gid; - if (pw->pw_gid == gid) - { - // User is in this group --> add profiles - profiles += mapCfg.readListEntry(*it); - } - else - { - for(int i = 0; i < sup_gids_nr; i++) - { - if (sup_gids[i] == gid) - { - // User is in this group --> add profiles - profiles += mapCfg.readListEntry(*it); - break; - } - } - } - } - - if (profiles.isEmpty()) - profiles << "default"; - return profiles; -} - -extern bool kde_kiosk_admin; - -bool KStandardDirs::addCustomized(KConfig *config) -{ - if (addedCustoms && !d->checkRestrictions) // there are already customized entries - return false; // we just quit and hope they are the right ones - - // save the numbers of config directories. If this changes, - // we will return true to give KConfig a chance to reparse - uint configdirs = resourceDirs("config").count(); - - // Remember original group - TQString oldGroup = config->group(); - - if (!addedCustoms) - { - // We only add custom entries once - addedCustoms = true; - - // reading the prefixes in - TQString group = TQString::tqfromLatin1("Directories"); - config->setGroup(group); - - TQString kioskAdmin = config->readEntry("kioskAdmin"); - if (!kioskAdmin.isEmpty() && !kde_kiosk_admin) - { - int i = kioskAdmin.find(':'); - TQString user = kioskAdmin.left(i); - TQString host = kioskAdmin.mid(i+1); - - KUser thisUser; - char hostname[ 256 ]; - hostname[ 0 ] = TQChar('\0'); - if (!gethostname( hostname, 255 )) - hostname[sizeof(hostname)-1] = TQChar('\0'); - - if ((user == thisUser.loginName()) && - (host.isEmpty() || (host == hostname))) - { - kde_kiosk_admin = true; - } - } - - bool readProfiles = true; - - if (kde_kiosk_admin && !TQCString(getenv("KDE_KIOSK_NO_PROFILES")).isEmpty()) - readProfiles = false; - - TQString userMapFile = config->readEntry("userProfileMapFile"); - TQString profileDirsPrefix = config->readEntry("profileDirsPrefix"); - if (!profileDirsPrefix.isEmpty() && !profileDirsPrefix.endsWith("/")) - profileDirsPrefix.append('/'); - - TQStringList profiles; - if (readProfiles) - profiles = lookupProfiles(userMapFile); - TQString profile; - - bool priority = false; - while(true) - { - config->setGroup(group); - TQStringList list = config->readListEntry("prefixes"); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) - { - addPrefix(*it, priority); - addXdgConfigPrefix(*it+"/etc/xdg", priority); - addXdgDataPrefix(*it+"/share", priority); - } - // If there are no prefixes defined, check if there is a directory - // for this profile under <profileDirsPrefix> - if (list.isEmpty() && !profile.isEmpty() && !profileDirsPrefix.isEmpty()) - { - TQString dir = profileDirsPrefix + profile; - addPrefix(dir, priority); - addXdgConfigPrefix(dir+"/etc/xdg", priority); - addXdgDataPrefix(dir+"/share", priority); - } - - // iterating over all entries in the group Directories - // to find entries that start with dir_$type - TQMap<TQString, TQString> entries = config->entryMap(group); - for (TQMap<TQString, TQString>::ConstIterator it2 = entries.begin(); - it2 != entries.end(); it2++) - { - TQString key = it2.key(); - if (key.startsWith("dir_")) { - // generate directory list, there may be more than 1. - TQStringList dirs = TQStringList::split(',', *it2); - TQStringList::Iterator sIt(dirs.begin()); - TQString resType = key.mid(4, key.length()); - for (; sIt != dirs.end(); ++sIt) - { - addResourceDir(resType.latin1(), *sIt, priority); - } - } - } - if (profiles.isEmpty()) - break; - profile = profiles.back(); - group = TQString::tqfromLatin1("Directories-%1").arg(profile); - profiles.pop_back(); - priority = true; - } - } - - // Process KIOSK restrictions. - if (!kde_kiosk_admin || TQCString(getenv("KDE_KIOSK_NO_RESTRICTIONS")).isEmpty()) - { - config->setGroup("KDE Resource Restrictions"); - TQMap<TQString, TQString> entries = config->entryMap("KDE Resource Restrictions"); - for (TQMap<TQString, TQString>::ConstIterator it2 = entries.begin(); - it2 != entries.end(); it2++) - { - TQString key = it2.key(); - if (!config->readBoolEntry(key, true)) - { - d->restrictionsActive = true; - d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do - dircache.remove(key.latin1()); - } - } - } - - config->setGroup(oldGroup); - - // check if the number of config dirs changed - bool configDirsChanged = (resourceDirs("config").count() != configdirs); - // If the config dirs changed, we check kiosk restrictions again. - d->checkRestrictions = configDirsChanged; - // return true if the number of config dirs changed: reparse config file - return configDirsChanged; -} - -TQString KStandardDirs::localkdedir() const -{ - // Return the prefix to use for saving - return prefixes.first(); -} - -TQString KStandardDirs::localxdgdatadir() const -{ - // Return the prefix to use for saving - return d->xdgdata_prefixes.first(); -} - -TQString KStandardDirs::localxdgconfdir() const -{ - // Return the prefix to use for saving - return d->xdgconf_prefixes.first(); -} - - -// just to make code more readable without macros -TQString locate( const char *type, - const TQString& filename, const KInstance* inst ) -{ - return inst->dirs()->findResource(type, filename); -} - -TQString locateLocal( const char *type, - const TQString& filename, const KInstance* inst ) -{ - return locateLocal(type, filename, true, inst); -} - -TQString locateLocal( const char *type, - const TQString& filename, bool createDir, const KInstance* inst ) -{ - // try to find slashes. If there are some, we have to - // create the subdir first - int slash = filename.findRev('/')+1; - if (!slash) // only one filename - return inst->dirs()->saveLocation(type, TQString::null, createDir) + filename; - - // split path from filename - TQString dir = filename.left(slash); - TQString file = filename.mid(slash); - return inst->dirs()->saveLocation(type, dir, createDir) + file; -} diff --git a/kdecore/kstandarddirs.h b/kdecore/kstandarddirs.h deleted file mode 100644 index 3f1fd14c1..000000000 --- a/kdecore/kstandarddirs.h +++ /dev/null @@ -1,729 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> - Copyright (C) 1999 Stephan Kulow <coolo@kde.org> - Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - - 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 SSK_KSTDDIRS_H -#define SSK_KSTDDIRS_H - -#include <tqstring.h> -#include <tqdict.h> -#include <tqstringlist.h> -#include <kglobal.h> - -class KConfig; -class KStandardDirsPrivate; - -/** - * @short Site-independent access to standard KDE directories. - * @author Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> - * - * This is one of the most central classes in kdelibs as - * it provides a basic service: It knows where the files - * reside on the user's hard disk. And it's meant to be the - * only one that knows -- to make the real location as - * transparent as possible to both the user and the applications. - * - * To this end it insulates the application from all information - * and applications always refer to a file with a resource type - * (e.g. icon) and a filename (e.g. khexdit.xpm). In an ideal world - * the application would make no assumption where this file is and - * leave it up to KStandardDirs::findResource("apps", "Home.desktop") - * to apply this knowledge to return /opt/kde/share/applnk/Home.desktop - * or ::locate("data", "kgame/background.jpg") to return - * /opt/kde/share/apps/kgame/background.jpg - * - * The main idea behind KStandardDirs is that there are several - * toplevel prefixes below which the files lie. One of these prefixes is - * the one where the user installed kdelibs, one is where the - * application was installed, and one is $HOME/.kde, but there - * may be even more. Under these prefixes there are several well - * defined suffixes where specific resource types are to be found. - * For example, for the resource type "html" the suffixes could be - * share/doc/HTML and share/doc/kde/HTML. - * So the search algorithm basically appends to each prefix each registered - * suffix and tries to locate the file there. - * To make the thing even more complex, it's also possible to register - * absolute paths that KStandardDirs looks up after not finding anything - * in the former steps. They can be useful if the user wants to provide - * specific directories that aren't in his $HOME/.kde directory for, - * for example, icons. - * - * <b>Standard resources that kdelibs allocates are:</b>\n - * - * @li apps - Applications menu (.desktop files). - * @li cache - Cached information (e.g. favicons, web-pages) - * @li cgi - CGIs to run from kdehelp. - * @li config - Configuration files. - * @li data - Where applications store data. - * @li exe - Executables in $prefix/bin. findExe() for a function that takes $PATH into account. - * @li html - HTML documentation. - * @li icon - Icons, see KIconLoader. - * @li lib - Libraries. - * @li locale - Translation files for KLocale. - * @li mime - Mime types. - * @li module - Module (dynamically loaded library). - * @li qtplugins - Qt plugins (dynamically loaded objects for Qt) - * @li services - Services. - * @li servicetypes - Service types. - * @li scripts - Application scripting additions. - * @li sound - Application sounds. - * @li templates - Templates - * @li wallpaper - Wallpapers. - * @li tmp - Temporary files (specific for both current host and current user) - * @li socket - UNIX Sockets (specific for both current host and current user) - * @li emoticons - Emoticons themes (Since KDE 3.4) - * - * A type that is added by the class KApplication if you use it, is - * appdata. This one makes the use of the type data a bit easier as it - * appends the name of the application. - * So while you had to ::locate("data", "appname/filename") so you can - * also write ::locate("appdata", "filename") if your KApplication instance - * is called "appname" (as set via KApplication's constructor or KAboutData, if - * you use the global KStandardDirs object KGlobal::dirs()). - * Please note though that you cannot use the "appdata" - * type if you intend to use it in an applet for Kicker because 'appname' would - * be "Kicker" instead of the applet's name. Therefore, for applets, you've got - * to work around this by using ::locate("data", "appletname/filename"). - * - * <b>KStandardDirs supports the following environment variables:</b> - * - * @li KDEDIRS: This may set an additional number of directory prefixes to - * search for resources. The directories should be separated - * by ':'. The directories are searched in the order they are - * specified. - * @li KDEDIR: Used for backwards compatibility. As KDEDIRS but only a single - * directory may be specified. If KDEDIRS is set KDEDIR is - * ignored. - * @li KDEHOME: The directory where changes are saved to. This directory is - * used to search for resources first. If KDEHOME is not - * specified it defaults to "$HOME/.kde" - * @li KDEROOTHOME: Like KDEHOME, but used for the root user. - * If KDEROOTHOME is not set it defaults to the .kde directory in the - * home directory of root, usually "/root/.kde". - * Note that the setting of $HOME is ignored in this case. - * - * @see KGlobalSettings - */ -class KDECORE_EXPORT KStandardDirs -{ -public: - /** - * KStandardDirs' constructor. It just initializes the caches. - **/ - KStandardDirs( ); - - /** - * KStandardDirs' destructor. - */ - virtual ~KStandardDirs(); - - /** - * Adds another search dir to front of the @p fsstnd list. - * - * @li When compiling kdelibs, the prefix is added to this. - * @li KDEDIRS or KDEDIR is taking into account - * @li Additional dirs may be loaded from kdeglobals. - * - * @param dir The directory to append relative paths to. - */ - void addPrefix( const TQString& dir ); - - /** - * Adds another search dir to front of the XDG_CONFIG_XXX list - * of prefixes. - * This prefix is only used for resources that start with "xdgconf-" - * - * @param dir The directory to append relative paths to. - */ - void addXdgConfigPrefix( const TQString& dir ); - - /** - * Adds another search dir to front of the XDG_DATA_XXX list - * of prefixes. - * This prefix is only used for resources that start with "xdgdata-" - * - * @param dir The directory to append relative paths to. - */ - void addXdgDataPrefix( const TQString& dir ); - - /** - * Adds suffixes for types. - * - * You may add as many as you need, but it is advised that there - * is exactly one to make writing definite. - * All basic types ( kde_default) are added by addKDEDefaults(), - * but for those you can add more relative paths as well. - * - * The later a suffix is added, the higher its priority. Note, that the - * suffix should end with / but doesn't have to start with one (as prefixes - * should end with one). So adding a suffix for app_pics would look - * like KGlobal::dirs()->addResourceType("app_pics", "share/app/pics"); - * - * @param type Specifies a short descriptive string to access - * files of this type. - * @param relativename Specifies a directory relative to the root - * of the KFSSTND. - * @return true if successful, false otherwise. - */ - bool addResourceType( const char *type, - const TQString& relativename ); - - /** - * Adds absolute path at the end of the search path for - * particular types (for example in case of icons where - * the user specifies extra paths). - * - * You shouldn't need this - * function in 99% of all cases besides adding user-given - * paths. - * - * @param type Specifies a short descriptive string to access files - * of this type. - * @param absdir Points to directory where to look for this specific - * type. Non-existant directories may be saved but pruned. - * @return true if successful, false otherwise. - */ - bool addResourceDir( const char *type, - const TQString& absdir); - - /** - * Tries to find a resource in the following order: - * @li All PREFIX/\<relativename> paths (most recent first). - * @li All absolute paths (most recent first). - * - * The filename should be a filename relative to the base dir - * for resources. So is a way to get the path to libtdecore.la - * to findResource("lib", "libtdecore.la"). KStandardDirs will - * then look into the subdir lib of all elements of all prefixes - * ($KDEDIRS) for a file libtdecore.la and return the path to - * the first one it finds (e.g. /opt/kde/lib/libtdecore.la) - * - * @param type The type of the wanted resource - * @param filename A relative filename of the resource. - * - * @return A full path to the filename specified in the second - * argument, or TQString::null if not found. - */ - TQString findResource( const char *type, - const TQString& filename ) const; - - /** - * Checks whether a resource is restricted as part of the KIOSK - * framework. When a resource is restricted it means that user- - * specific files in the resource are ignored. - * - * E.g. by restricting the "wallpaper" resource, only system-wide - * installed wallpapers will be found by this class. Wallpapers - * installed under the $KDEHOME directory will be ignored. - * - * @param type The type of the resource to check - * @param relPath A relative path in the resource. - * - * @return True if the resource is restricted. - * @since 3.1 - */ - bool isRestrictedResource( const char *type, - const TQString& relPath=TQString::null ) const; - - /** - * Returns a number that identifies this version of the resource. - * When a change is made to the resource this number will change. - * - * @param type The type of the wanted resource - * @param filename A relative filename of the resource. - * @param deep If true, all resources are taken into account - * otherwise only the one returned by findResource(). - * - * @return A number identifying the current version of the - * resource. - */ - TQ_UINT32 calcResourceHash( const char *type, - const TQString& filename, bool deep) const; - - /** - * Tries to find all directories whose names consist of the - * specified type and a relative path. So would - * findDirs("apps", "Settings") return - * @li /opt/kde/share/applnk/Settings/ - * @li /home/joe/.kde/share/applnk/Settings/ - * - * Note that it appends / to the end of the directories, - * so you can use this right away as directory names. - * - * @param type The type of the base directory. - * @param reldir Relative directory. - * - * @return A list of matching directories, or an empty - * list if the resource specified is not found. - */ - TQStringList findDirs( const char *type, - const TQString& reldir ) const; - - /** - * Tries to find the directory the file is in. - * It works the same as findResource(), but it doesn't - * return the filename but the name of the directory. - * - * This way the application can access a couple of files - * that have been installed into the same directory without - * having to look for each file. - * - * findResourceDir("lib", "libtdecore.la") would return the - * path of the subdir libtdecore.la is found first in - * (e.g. /opt/kde/lib/) - * - * @param type The type of the wanted resource - * @param filename A relative filename of the resource. - * @return The directory where the file specified in the second - * argument is located, or TQString::null if the type - * of resource specified is unknown or the resource - * cannot be found. - */ - TQString findResourceDir( const char *type, - const TQString& filename) const; - - - /** - * Tries to find all resources with the specified type. - * - * The function will look into all specified directories - * and return all filenames in these directories. - * - * @param type The type of resource to locate directories for. - * @param filter Only accept filenames that fit to filter. The filter - * may consist of an optional directory and a QRegExp - * wildcard expression. E.g. "images\*.jpg". Use TQString::null - * if you do not want a filter. - * @param recursive Specifies if the function should decend - * into subdirectories. - * @param unique If specified, only return items which have - * unique suffixes - suppressing duplicated filenames. - * - * @return List of all the files whose filename matches the - * specified filter. - */ - TQStringList findAllResources( const char *type, - const TQString& filter = TQString::null, - bool recursive = false, - bool unique = false) const; - - /** - * Tries to find all resources with the specified type. - * - * The function will look into all specified directories - * and return all filenames (full and relative paths) in - * these directories. - * - * @param type The type of resource to locate directories for. - * @param filter Only accept filenames that fit to filter. The filter - * may consist of an optional directory and a QRegExp - * wildcard expression. E.g. "images\*.jpg". Use TQString::null - * if you do not want a filter. - * @param recursive Specifies if the function should decend - * into subdirectories. - * @param unique If specified, only return items which have - * unique suffixes. - * @param relPaths The list to store the relative paths into - * These can be used later to ::locate() the file - * - * @return List of all the files whose filename matches the - * specified filter. - */ - TQStringList findAllResources( const char *type, - const TQString& filter, - bool recursive, - bool unique, - TQStringList &relPaths) const; - - /** - * Returns a TQStringList list of pathnames in the system path. - * - * @param pstr The path which will be searched. If this is - * null (default), the $PATH environment variable will - * be searched. - * - * @return a TQStringList list of pathnames in the system path. - */ - static TQStringList systemPaths( const TQString& pstr=TQString::null ); - - /** - * Finds the executable in the system path. - * - * A valid executable must - * be a file and have its executable bit set. - * - * @param appname The name of the executable file for which to search. - * @param pathstr The path which will be searched. If this is - * null (default), the $PATH environment variable will - * be searched. - * @param ignoreExecBit If true, an existing file will be returned - * even if its executable bit is not set. - * - * @return The path of the executable. If it was not found, - * it will return TQString::null. - * @see findAllExe() - */ - static TQString findExe( const TQString& appname, - const TQString& pathstr=TQString::null, - bool ignoreExecBit=false ); - - /** - * Finds all occurrences of an executable in the system path. - * - * @param list Will be filled with the pathnames of all the - * executables found. Will be empty if the executable - * was not found. - * @param appname The name of the executable for which to - * search. - * @param pathstr The path list which will be searched. If this - * is 0 (default), the $PATH environment variable will - * be searched. - * @param ignoreExecBit If true, an existing file will be returned - * even if its executable bit is not set. - * - * @return The number of executables found, 0 if none were found. - * - * @see findExe() - */ - static int findAllExe( TQStringList& list, const TQString& appname, - const TQString& pathstr=TQString::null, - bool ignoreExecBit=false ); - - /** - * This function adds the defaults that are used by the current - * KDE version. - * - * It's a series of addResourceTypes() - * and addPrefix() calls. - * You normally wouldn't call this function because it's called - * for you from KGlobal. - */ - void addKDEDefaults(); - - /** - * Reads customized entries out of the given config object and add - * them via addResourceDirs(). - * - * @param config The object the entries are read from. This should - * contain global config files - * @return true if new config paths have been added - * from @p config. - **/ - bool addCustomized(KConfig *config); - - /** - * This function is used internally by almost all other function as - * it serves and fills the directories cache. - * - * @param type The type of resource - * @return The list of possible directories for the specified @p type. - * The function updates the cache if possible. If the resource - * type specified is unknown, it will return an empty list. - * Note, that the directories are assured to exist beside the save - * location, which may not exist, but is returned anyway. - */ - TQStringList resourceDirs(const char *type) const; - - /** - * This function will return a list of all the types that KStandardDirs - * supports. - * - * @return All types that KDE supports - */ - TQStringList allTypes() const; - - /** - * Finds a location to save files into for the given type - * in the user's home directory. - * - * @param type The type of location to return. - * @param suffix A subdirectory name. - * Makes it easier for you to create subdirectories. - * You can't pass filenames here, you _have_ to pass - * directory names only and add possible filename in - * that directory yourself. A directory name always has a - * trailing slash ('/'). - * @param create If set, saveLocation() will create the directories - * needed (including those given by @p suffix). - * - * @return A path where resources of the specified type should be - * saved, or TQString::null if the resource type is unknown. - */ - TQString saveLocation(const char *type, - const TQString& suffix = TQString::null, - bool create = true) const; - - /** - * Converts an absolute path to a path relative to a certain - * resource. - * - * If "abs = ::locate(resource, rel)" - * then "rel = relativeLocation(resource, abs)" and vice versa. - * - * @param type The type of resource. - * - * @param absPath An absolute path to make relative. - * - * @return A relative path relative to resource @p type that - * will find @p absPath. If no such relative path exists, absPath - * will be returned unchanged. - */ - TQString relativeLocation(const char *type, const TQString &absPath); - - /** - * Recursively creates still-missing directories in the given path. - * - * The resulting permissions will depend on the current umask setting. - * permission = mode & ~umask. - * - * @param dir Absolute path of the directory to be made. - * @param mode Directory permissions. - * @return true if successful, false otherwise - */ - static bool makeDir(const TQString& dir, int mode = 0755); - - /** - * This returns a default relative path for the standard KDE - * resource types. Below is a list of them so you get an idea - * of what this is all about. - * - * @li data - share/apps - * @li html - share/doc/HTML - * @li icon - share/icon - * @li config - share/config - * @li pixmap - share/pixmaps - * @li apps - share/applnk - * @li sound - share/sounds - * @li locale - share/locale - * @li services - share/services - * @li servicetypes - share/servicetypes - * @li mime - share/mimelnk - * @li wallpaper - share/wallpapers - * @li templates - share/templates - * @li exe - bin - * @li lib - lib - * - * @returns Static default for the specified resource. You - * should probably be using locate() or locateLocal() - * instead. - * @see locate() - * @see locateLocal() - */ - static TQString kde_default(const char *type); - - /** - * @internal (for use by sycoca only) - */ - TQString kfsstnd_prefixes(); - - /** - * @internal (for use by sycoca only) - */ - TQString kfsstnd_xdg_conf_prefixes(); - - /** - * @internal (for use by sycoca only) - */ - TQString kfsstnd_xdg_data_prefixes(); - - /** - * Returns the toplevel directory in which KStandardDirs - * will store things. Most likely $HOME/.kde - * Don't use this function if you can use locateLocal - * @return the toplevel directory - */ - TQString localkdedir() const; - - /** - * @internal - * Returns the default toplevel directory where KDE is installed. - */ - static TQString kfsstnd_defaultprefix(); - - /** - * @internal - * Returns the default bin directory in which KDE executables are stored. - */ - static TQString kfsstnd_defaultbindir(); - - /** - * @return $XDG_DATA_HOME - * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html - */ - TQString localxdgdatadir() const; - - /** - * @return $XDG_CONFIG_HOME - * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html - */ - TQString localxdgconfdir() const; - - /** - * Checks for existence and accessability of a file or directory. - * Faster than creating a TQFileInfo first. - * @param fullPath the path to check. IMPORTANT: must end with a slash if expected to be a directory - * (and no slash for a file, obviously). - * @return true if the directory exists - */ - static bool exists(const TQString &fullPath); - - /** - * Expands all symbolic links and resolves references to - * '/./', '/../' and extra '/' characters in @p dirname - * and returns the canonicalized absolute pathname. - * The resulting path will have no symbolic link, '/./' - * or '/../' components. - * @since 3.1 - */ - static TQString realPath(const TQString &dirname); - - /** - * Expands all symbolic links and resolves references to - * '/./', '/../' and extra '/' characters in @p filename - * and returns the canonicalized absolute pathname. - * The resulting path will have no symbolic link, '/./' - * or '/../' components. - * @since 3.4 - */ - static TQString realFilePath(const TQString &filename); - - private: - - TQStringList prefixes; - - // Directory dictionaries - TQDict<TQStringList> absolutes; - TQDict<TQStringList> relatives; - - mutable TQDict<TQStringList> dircache; - mutable TQDict<TQString> savelocations; - - // Disallow assignment and copy-construction - KStandardDirs( const KStandardDirs& ); - KStandardDirs& operator= ( const KStandardDirs& ); - - bool addedCustoms; - - class KStandardDirsPrivate; - KStandardDirsPrivate *d; - - void checkConfig() const; - void applyDataRestrictions(const TQString &) const; - void createSpecialResource(const char*); - - // Like their public counter parts but with an extra priority argument - // If priority is true, the directory is added directly after - // $KDEHOME/$XDG_DATA_HOME/$XDG_CONFIG_HOME - void addPrefix( const TQString& dir, bool priority ); - void addXdgConfigPrefix( const TQString& dir, bool priority ); - void addXdgDataPrefix( const TQString& dir, bool priority ); - - // If priority is true, the directory is added before any other, - // otherwise after - bool addResourceType( const char *type, - const TQString& relativename, bool priority ); - bool addResourceDir( const char *type, - const TQString& absdir, bool priority); -}; - -/** - * \addtogroup locates Locate Functions - * @{ - * On The Usage Of 'locate' and 'locateLocal' - * - * Typical KDE applications use resource files in one out of - * three ways: - * - * 1) A resource file is read but is never written. A system - * default is supplied but the user can override this - * default in his local .kde directory: - * - * \code - * // Code example - * myFile = locate("appdata", "groups.lst"); - * myData = myReadGroups(myFile); // myFile may be null - * \endcode - * - * 2) A resource file is read and written. If the user has no - * local version of the file the system default is used. - * The resource file is always written to the users local - * .kde directory. - * - * \code - * // Code example - * myFile = locate("appdata", "groups.lst") - * myData = myReadGroups(myFile); - * ... - * doSomething(myData); - * ... - * myFile = locateLocal("appdata", "groups.lst"); - * myWriteGroups(myFile, myData); - * \endcode - * - * 3) A resource file is read and written. No system default - * is used if the user has no local version of the file. - * The resource file is always written to the users local - * .kde directory. - * - * \code - * // Code example - * myFile = locateLocal("appdata", "groups.lst"); - * myData = myReadGroups(myFile); - * ... - * doSomething(myData); - * ... - * myFile = locateLocal("appdata", "groups.lst"); - * myWriteGroups(myFile, myData); - * \endcode - **/ - -/*! - * \relates KStandardDirs - * This function is just for convenience. It simply calls - *instance->dirs()->\link KStandardDirs::findResource() findResource\endlink(type, filename). - **/ -KDECORE_EXPORT TQString locate( const char *type, const TQString& filename, const KInstance* instance = KGlobal::instance() ); - -/*! - * \relates KStandardDirs - * This function is much like locate. However it returns a - * filename suitable for writing to. No check is made if the - * specified filename actually exists. Missing directories - * are created. If filename is only a directory, without a - * specific file, filename must have a trailing slash. - * - **/ -KDECORE_EXPORT TQString locateLocal( const char *type, const TQString& filename, const KInstance* instance = KGlobal::instance() ); - -/*! - * \relates KStandardDirs - * This function is much like locate. No check is made if the - * specified filename actually exists. Missing directories - * are created if @p createDir is true. If filename is only - * a directory, without a specific file, - * filename must have a trailing slash. - * - **/ -KDECORE_EXPORT TQString locateLocal( const char *type, const TQString& filename, bool createDir, const KInstance* instance = KGlobal::instance() ); - -/*! @} */ - -#endif // SSK_KSTDDIRS_H diff --git a/kdecore/kstartupinfo.cpp b/kdecore/kstartupinfo.cpp deleted file mode 100644 index 12825e805..000000000 --- a/kdecore/kstartupinfo.cpp +++ /dev/null @@ -1,1529 +0,0 @@ -/**************************************************************************** - - $Id$ - - Copyright (C) 2001-2003 Lubos Lunak <l.lunak@kde.org> - -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. - -****************************************************************************/ - -// kdDebug() can't be turned off in tdeinit -#if 0 -#define KSTARTUPINFO_ALL_DEBUG -#warning Extra KStartupInfo debug messages enabled. -#endif - -#include <tqwidget.h> - -#include "config.h" -#ifdef Q_WS_X11 -//#ifdef Q_WS_X11 // FIXME(E): Re-implement in a less X11 specific way -#include <tqglobal.h> -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -// need to resolve INT32(tqglobal.h)<>INT32(Xlibint.h) conflict -#ifndef QT_CLEAN_NAMESPACE -#define QT_CLEAN_NAMESPACE -#endif - -#include "kstartupinfo.h" - -#include <unistd.h> -#include <sys/time.h> -#include <stdlib.h> -#include <tqtimer.h> -#ifdef Q_WS_X11 -#include <netwm.h> -#endif -#include <kdebug.h> -#include <kapplication.h> -#include <signal.h> -#ifdef Q_WS_X11 -#include <kwinmodule.h> -#include <kxmessages.h> -#include <kwin.h> -#endif - -static const char* const NET_STARTUP_MSG = "_NET_STARTUP_INFO"; -static const char* const NET_STARTUP_WINDOW = "_NET_STARTUP_ID"; -// DESKTOP_STARTUP_ID is used also in kinit/wrapper.c , -// tdesu in both kdelibs and kdebase and who knows where else -static const char* const NET_STARTUP_ENV = "DESKTOP_STARTUP_ID"; - -static bool auto_app_started_sending = true; - -static long get_num( const TQString& item_P ); -static unsigned long get_unum( const TQString& item_P ); -static TQString get_str( const TQString& item_P ); -static TQCString get_cstr( const TQString& item_P ); -static TQStringList get_fields( const TQString& txt_P ); -static TQString escape_str( const TQString& str_P ); - -static Atom utf8_string_atom = None; - -class KStartupInfo::Data - : public KStartupInfoData - { - public: - Data() : KStartupInfoData(), age(0) {} // just because it's in a QMap - Data( const TQString& txt_P ) - : KStartupInfoData( txt_P ), age( 0 ) {} - unsigned int age; - }; - -struct KStartupInfoPrivate - { - public: - TQMap< KStartupInfoId, KStartupInfo::Data > startups; - // contains silenced ASN's only if !AnnounceSilencedChanges - TQMap< KStartupInfoId, KStartupInfo::Data > silent_startups; - // contains ASN's that had change: but no new: yet - TQMap< KStartupInfoId, KStartupInfo::Data > uninited_startups; -#ifdef Q_WS_X11 - KWinModule* wm_module; - KXMessages msgs; -#endif - TQTimer* cleanup; - int flags; - KStartupInfoPrivate( int flags_P ) - : -#ifdef Q_WS_X11 - msgs( NET_STARTUP_MSG, NULL, false ), -#endif - flags( flags_P ) {} - }; - -KStartupInfo::KStartupInfo( int flags_P, TQObject* parent_P, const char* name_P ) - : TQObject( parent_P, name_P ), - timeout( 60 ), d( NULL ) - { - init( flags_P ); - } - -KStartupInfo::KStartupInfo( bool clean_on_cantdetect_P, TQObject* parent_P, const char* name_P ) - : TQObject( parent_P, name_P ), - timeout( 60 ), d( NULL ) - { - init( clean_on_cantdetect_P ? CleanOnCantDetect : 0 ); - } - -void KStartupInfo::init( int flags_P ) - { - // d == NULL means "disabled" - if( !KApplication::kApplication()) - return; - if( !KApplication::kApplication()->getDisplay()) - return; - - d = new KStartupInfoPrivate( flags_P ); -#ifdef Q_WS_X11 - if( !( d->flags & DisableKWinModule )) - { - d->wm_module = new KWinModule( this ); - connect( d->wm_module, TQT_SIGNAL( windowAdded( WId )), TQT_SLOT( slot_window_added( WId ))); - connect( d->wm_module, TQT_SIGNAL( systemTrayWindowAdded( WId )), TQT_SLOT( slot_window_added( WId ))); - } - else - d->wm_module = NULL; - connect( &d->msgs, TQT_SIGNAL( gotMessage( const TQString& )), TQT_SLOT( got_message( const TQString& ))); -#endif - d->cleanup = new TQTimer( this, "cleanup" ); - connect( d->cleanup, TQT_SIGNAL( timeout()), TQT_SLOT( startups_cleanup())); - } - -KStartupInfo::~KStartupInfo() - { - delete d; - } - -void KStartupInfo::got_message( const TQString& msg_P ) - { -// TODO do something with SCREEN= ? - kdDebug( 172 ) << "got:" << msg_P << endl; - TQString msg = msg_P.stripWhiteSpace(); - if( msg.startsWith( "new:" )) // must match length below - got_startup_info( msg.mid( 4 ), false ); - else if( msg.startsWith( "change:" )) // must match length below - got_startup_info( msg.mid( 7 ), true ); - else if( msg.startsWith( "remove:" )) // must match length below - got_remove_startup_info( msg.mid( 7 )); - } - -// if the application stops responding for a while, KWinModule may get -// the information about the already mapped window before KXMessages -// actually gets the info about the started application (depends -// on their order in X11 event filter in KApplication) -// simply delay info from KWinModule a bit -// SELI??? -namespace -{ -class DelayedWindowEvent - : public TQCustomEvent - { - public: - DelayedWindowEvent( WId w_P ) - : TQCustomEvent( TQEvent::User + 15 ), w( w_P ) {} - Window w; - }; -} - -void KStartupInfo::slot_window_added( WId w_P ) - { - kapp->postEvent( this, new DelayedWindowEvent( w_P )); - } - -void KStartupInfo::customEvent( TQCustomEvent* e_P ) - { - if( e_P->type() == TQEvent::User + 15 ) - window_added( static_cast< DelayedWindowEvent* >( e_P )->w ); - else - TQObject::customEvent( e_P ); - } - -void KStartupInfo::window_added( WId w_P ) - { - KStartupInfoId id; - KStartupInfoData data; - startup_t ret = check_startup_internal( w_P, &id, &data ); - switch( ret ) - { - case Match: - kdDebug( 172 ) << "new window match" << endl; - break; - case NoMatch: - break; // nothing - case CantDetect: - if( d->flags & CleanOnCantDetect ) - clean_all_noncompliant(); - break; - } - } - -void KStartupInfo::got_startup_info( const TQString& msg_P, bool update_P ) - { - KStartupInfoId id( msg_P ); - if( id.none()) - return; - KStartupInfo::Data data( msg_P ); - new_startup_info_internal( id, data, update_P ); - } - -void KStartupInfo::new_startup_info_internal( const KStartupInfoId& id_P, - Data& data_P, bool update_P ) - { - if( d == NULL ) - return; - if( id_P.none()) - return; - if( d->startups.contains( id_P )) - { // already reported, update - d->startups[ id_P ].update( data_P ); - d->startups[ id_P ].age = 0; // CHECKME - kdDebug( 172 ) << "updating" << endl; - if( d->startups[ id_P ].silent() == Data::Yes - && !( d->flags & AnnounceSilenceChanges )) - { - d->silent_startups[ id_P ] = d->startups[ id_P ]; - d->startups.remove( id_P ); - emit gotRemoveStartup( id_P, d->silent_startups[ id_P ] ); - return; - } - emit gotStartupChange( id_P, d->startups[ id_P ] ); - return; - } - if( d->silent_startups.contains( id_P )) - { // already reported, update - d->silent_startups[ id_P ].update( data_P ); - d->silent_startups[ id_P ].age = 0; // CHECKME - kdDebug( 172 ) << "updating silenced" << endl; - if( d->silent_startups[ id_P ].silent() != Data::Yes ) - { - d->startups[ id_P ] = d->silent_startups[ id_P ]; - d->silent_startups.remove( id_P ); - emit gotNewStartup( id_P, d->startups[ id_P ] ); - return; - } - emit gotStartupChange( id_P, d->silent_startups[ id_P ] ); - return; - } - if( d->uninited_startups.contains( id_P )) - { - d->uninited_startups[ id_P ].update( data_P ); - kdDebug( 172 ) << "updating uninited" << endl; - if( !update_P ) // uninited finally got new: - { - d->startups[ id_P ] = d->uninited_startups[ id_P ]; - d->uninited_startups.remove( id_P ); - emit gotNewStartup( id_P, d->startups[ id_P ] ); - return; - } - // no change announce, it's still uninited - return; - } - if( update_P ) // change: without any new: first - { - kdDebug( 172 ) << "adding uninited" << endl; - d->uninited_startups.insert( id_P, data_P ); - } - else if( data_P.silent() != Data::Yes || d->flags & AnnounceSilenceChanges ) - { - kdDebug( 172 ) << "adding" << endl; - d->startups.insert( id_P, data_P ); - emit gotNewStartup( id_P, data_P ); - } - else // new silenced, and silent shouldn't be announced - { - kdDebug( 172 ) << "adding silent" << endl; - d->silent_startups.insert( id_P, data_P ); - } - d->cleanup->start( 1000 ); // 1 sec - } - -void KStartupInfo::got_remove_startup_info( const TQString& msg_P ) - { - KStartupInfoId id( msg_P ); - KStartupInfoData data( msg_P ); - if( data.pids().count() > 0 ) - { - if( !id.none()) - remove_startup_pids( id, data ); - else - remove_startup_pids( data ); - return; - } - remove_startup_info_internal( id ); - } - -void KStartupInfo::remove_startup_info_internal( const KStartupInfoId& id_P ) - { - if( d == NULL ) - return; - if( d->startups.contains( id_P )) - { - kdDebug( 172 ) << "removing" << endl; - emit gotRemoveStartup( id_P, d->startups[ id_P ]); - d->startups.remove( id_P ); - } - else if( d->silent_startups.contains( id_P )) - { - kdDebug( 172 ) << "removing silent" << endl; - d->silent_startups.remove( id_P ); - } - else if( d->uninited_startups.contains( id_P )) - { - kdDebug( 172 ) << "removing uninited" << endl; - d->uninited_startups.remove( id_P ); - } - return; - } - -void KStartupInfo::remove_startup_pids( const KStartupInfoData& data_P ) - { // first find the matching info - if( d == NULL ) - return; - for( TQMap< KStartupInfoId, Data >::Iterator it = d->startups.begin(); - it != d->startups.end(); - ++it ) - { - if( ( *it ).hostname() != data_P.hostname()) - continue; - if( !( *it ).is_pid( data_P.pids().first())) - continue; // not the matching info - remove_startup_pids( it.key(), data_P ); - break; - } - } - -void KStartupInfo::remove_startup_pids( const KStartupInfoId& id_P, - const KStartupInfoData& data_P ) - { - if( d == NULL ) - return; - kdFatal( data_P.pids().count() == 0, 172 ); - Data* data = NULL; - if( d->startups.contains( id_P )) - data = &d->startups[ id_P ]; - else if( d->silent_startups.contains( id_P )) - data = &d->silent_startups[ id_P ]; - else if( d->uninited_startups.contains( id_P )) - data = &d->uninited_startups[ id_P ]; - else - return; - for( TQValueList< pid_t >::ConstIterator it2 = data_P.pids().begin(); - it2 != data_P.pids().end(); - ++it2 ) - data->remove_pid( *it2 ); // remove all pids from the info - if( data->pids().count() == 0 ) // all pids removed -> remove info - remove_startup_info_internal( id_P ); - } - -bool KStartupInfo::sendStartup( const KStartupInfoId& id_P, const KStartupInfoData& data_P ) - { - if( id_P.none()) - return false; - KXMessages msgs; - TQString msg = TQString::tqfromLatin1( "new: %1 %2" ) - .arg( id_P.to_text()).arg( data_P.to_text()); - msg = check_required_startup_fields( msg, data_P, qt_xscreen()); - kdDebug( 172 ) << "sending " << msg << endl; - msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false ); - return true; - } - -bool KStartupInfo::sendStartupX( Display* disp_P, const KStartupInfoId& id_P, - const KStartupInfoData& data_P ) - { - if( id_P.none()) - return false; - TQString msg = TQString::tqfromLatin1( "new: %1 %2" ) - .arg( id_P.to_text()).arg( data_P.to_text()); - msg = check_required_startup_fields( msg, data_P, DefaultScreen( disp_P )); -#ifdef KSTARTUPINFO_ALL_DEBUG - kdDebug( 172 ) << "sending " << msg << endl; -#endif - return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false ); - } - -TQString KStartupInfo::check_required_startup_fields( const TQString& msg, const KStartupInfoData& data_P, - int screen ) - { - TQString ret = msg; - if( data_P.name().isEmpty()) - { -// kdWarning( 172 ) << "NAME not specified in initial startup message" << endl; - TQString name = data_P.bin(); - if( name.isEmpty()) - name = "UNKNOWN"; - ret += TQString( " NAME=\"%1\"" ).arg( escape_str( name )); - } - if( data_P.screen() == -1 ) // add automatically if needed - ret += TQString( " SCREEN=%1" ).arg( screen ); - return ret; - } - -bool KStartupInfo::sendChange( const KStartupInfoId& id_P, const KStartupInfoData& data_P ) - { - if( id_P.none()) - return false; - KXMessages msgs; - TQString msg = TQString::tqfromLatin1( "change: %1 %2" ) - .arg( id_P.to_text()).arg( data_P.to_text()); - kdDebug( 172 ) << "sending " << msg << endl; - msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false ); - return true; - } - -bool KStartupInfo::sendChangeX( Display* disp_P, const KStartupInfoId& id_P, - const KStartupInfoData& data_P ) - { - if( id_P.none()) - return false; - TQString msg = TQString::tqfromLatin1( "change: %1 %2" ) - .arg( id_P.to_text()).arg( data_P.to_text()); -#ifdef KSTARTUPINFO_ALL_DEBUG - kdDebug( 172 ) << "sending " << msg << endl; -#endif - return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false ); - } - -bool KStartupInfo::sendFinish( const KStartupInfoId& id_P ) - { - if( id_P.none()) - return false; - KXMessages msgs; - TQString msg = TQString::tqfromLatin1( "remove: %1" ).arg( id_P.to_text()); - kdDebug( 172 ) << "sending " << msg << endl; - msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false ); - return true; - } - -bool KStartupInfo::sendFinishX( Display* disp_P, const KStartupInfoId& id_P ) - { - if( id_P.none()) - return false; - TQString msg = TQString::tqfromLatin1( "remove: %1" ).arg( id_P.to_text()); -#ifdef KSTARTUPINFO_ALL_DEBUG - kdDebug( 172 ) << "sending " << msg << endl; -#endif - return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false ); - } - -bool KStartupInfo::sendFinish( const KStartupInfoId& id_P, const KStartupInfoData& data_P ) - { -// if( id_P.none()) // id may be none, the pids and hostname matter then -// return false; - KXMessages msgs; - TQString msg = TQString::tqfromLatin1( "remove: %1 %2" ) - .arg( id_P.to_text()).arg( data_P.to_text()); - kdDebug( 172 ) << "sending " << msg << endl; - msgs.broadcastMessage( NET_STARTUP_MSG, msg, -1, false ); - return true; - } - -bool KStartupInfo::sendFinishX( Display* disp_P, const KStartupInfoId& id_P, - const KStartupInfoData& data_P ) - { -// if( id_P.none()) // id may be none, the pids and hostname matter then -// return false; - TQString msg = TQString::tqfromLatin1( "remove: %1 %2" ) - .arg( id_P.to_text()).arg( data_P.to_text()); -#ifdef KSTARTUPINFO_ALL_DEBUG - kdDebug( 172 ) << "sending " << msg << endl; -#endif - return KXMessages::broadcastMessageX( disp_P, NET_STARTUP_MSG, msg, -1, false ); - } - -void KStartupInfo::appStarted() - { - if( kapp != NULL ) // KApplication constructor unsets the env. variable - appStarted( kapp->startupId()); - else - appStarted( KStartupInfo::currentStartupIdEnv().id()); - } - -void KStartupInfo::appStarted( const TQCString& startup_id ) - { - KStartupInfoId id; - id.initId( startup_id ); - if( id.none()) - return; - if( kapp != NULL ) - KStartupInfo::sendFinish( id ); - else if( getenv( "DISPLAY" ) != NULL ) // don't rely on qt_xdisplay() - { -#ifdef Q_WS_X11 - Display* disp = XOpenDisplay( NULL ); - if( disp != NULL ) - { - KStartupInfo::sendFinishX( disp, id ); - XCloseDisplay( disp ); - } -#endif - } - } - -void KStartupInfo::disableAutoAppStartedSending( bool disable ) - { - auto_app_started_sending = !disable; - } - -void KStartupInfo::silenceStartup( bool silence ) - { - KStartupInfoId id; - id.initId( kapp->startupId()); - if( id.none()) - return; - KStartupInfoData data; - data.setSilent( silence ? KStartupInfoData::Yes : KStartupInfoData::No ); - sendChange( id, data ); - } - -void KStartupInfo::handleAutoAppStartedSending() - { - if( auto_app_started_sending ) - appStarted(); - } - -void KStartupInfo::setNewStartupId( TQWidget* window, const TQCString& startup_id ) - { - bool activate = true; - kapp->setStartupId( startup_id ); - if( window != NULL ) - { - if( !startup_id.isEmpty() && startup_id != "0" ) - { - NETRootInfo i( qt_xdisplay(), NET::Supported ); - if( i.isSupported( NET::WM2StartupId )) - { - KStartupInfo::setWindowStartupId( window->winId(), startup_id ); - activate = false; // WM will take care of it - } - } - if( activate ) - { - KWin::setOnDesktop( window->winId(), KWin::currentDesktop()); - // This is not very nice, but there's no way how to get any - // usable timestamp without ASN, so force activating the window. - // And even with ASN, it's not possible to get the timestamp here, - // so if the WM doesn't have support for ASN, it can't be used either. - KWin::forceActiveWindow( window->winId()); - } - } - KStartupInfo::handleAutoAppStartedSending(); - } - -KStartupInfo::startup_t KStartupInfo::checkStartup( WId w_P, KStartupInfoId& id_O, - KStartupInfoData& data_O ) - { - return check_startup_internal( w_P, &id_O, &data_O ); - } - -KStartupInfo::startup_t KStartupInfo::checkStartup( WId w_P, KStartupInfoId& id_O ) - { - return check_startup_internal( w_P, &id_O, NULL ); - } - -KStartupInfo::startup_t KStartupInfo::checkStartup( WId w_P, KStartupInfoData& data_O ) - { - return check_startup_internal( w_P, NULL, &data_O ); - } - -KStartupInfo::startup_t KStartupInfo::checkStartup( WId w_P ) - { - return check_startup_internal( w_P, NULL, NULL ); - } - -KStartupInfo::startup_t KStartupInfo::check_startup_internal( WId w_P, KStartupInfoId* id_O, - KStartupInfoData* data_O ) - { - if( d == NULL ) - return NoMatch; - if( d->startups.count() == 0 ) - return NoMatch; // no startups - // Strategy: - // - // Is this a compliant app ? - // - Yes - test for match - // - No - Is this a NET_WM compliant app ? - // - Yes - test for pid match - // - No - test for WM_CLASS match - kdDebug( 172 ) << "check_startup" << endl; - TQCString id = windowStartupId( w_P ); - if( !id.isNull()) - { - if( id.isEmpty() || id == "0" ) // means ignore this window - { - kdDebug( 172 ) << "ignore" << endl; - return NoMatch; - } - return find_id( id, id_O, data_O ) ? Match : NoMatch; - } -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), w_P, qt_xrootwin(), - NET::WMWindowType | NET::WMPid | NET::WMState ); - pid_t pid = info.pid(); - if( pid > 0 ) - { - TQCString hostname = get_window_hostname( w_P ); - if( !hostname.isEmpty() - && find_pid( pid, hostname, id_O, data_O )) - return Match; - // try XClass matching , this PID stuff sucks :( - } - XClassHint hint; - if( XGetClassHint( qt_xdisplay(), w_P, &hint ) != 0 ) - { // We managed to read the class hint - TQCString res_name = hint.res_name; - TQCString res_class = hint.res_class; - XFree( hint.res_name ); - XFree( hint.res_class ); - if( find_wclass( res_name, res_class, id_O, data_O )) - return Match; - } - // ignore NET::Tool and other special window types, if they can't be matched - NET::WindowType type = info.windowType( NET::NormalMask | NET::DesktopMask - | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask - | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask ); - if( type != NET::Normal - && type != NET::Override - && type != NET::Unknown - && type != NET::Dialog - && type != NET::Utility ) -// && type != NET::Dock ) why did I put this here? - return NoMatch; - // lets see if this is a transient - Window transient_for; - if( XGetTransientForHint( qt_xdisplay(), static_cast< Window >( w_P ), &transient_for ) - && static_cast< WId >( transient_for ) != qt_xrootwin() - && transient_for != None ) - return NoMatch; -#endif - kdDebug( 172 ) << "check_startup:cantdetect" << endl; - return CantDetect; - } - -bool KStartupInfo::find_id( const TQCString& id_P, KStartupInfoId* id_O, - KStartupInfoData* data_O ) - { - if( d == NULL ) - return false; - kdDebug( 172 ) << "find_id:" << id_P << endl; - KStartupInfoId id; - id.initId( id_P ); - if( d->startups.contains( id )) - { - if( id_O != NULL ) - *id_O = id; - if( data_O != NULL ) - *data_O = d->startups[ id ]; - kdDebug( 172 ) << "check_startup_id:match" << endl; - return true; - } - return false; - } - -bool KStartupInfo::find_pid( pid_t pid_P, const TQCString& hostname_P, - KStartupInfoId* id_O, KStartupInfoData* data_O ) - { - if( d == NULL ) - return false; - kdDebug( 172 ) << "find_pid:" << pid_P << endl; - for( TQMap< KStartupInfoId, Data >::Iterator it = d->startups.begin(); - it != d->startups.end(); - ++it ) - { - if( ( *it ).is_pid( pid_P ) && ( *it ).hostname() == hostname_P ) - { // Found it ! - if( id_O != NULL ) - *id_O = it.key(); - if( data_O != NULL ) - *data_O = *it; - // non-compliant, remove on first match - remove_startup_info_internal( it.key()); - kdDebug( 172 ) << "check_startup_pid:match" << endl; - return true; - } - } - return false; - } - -bool KStartupInfo::find_wclass( TQCString res_name, TQCString res_class, - KStartupInfoId* id_O, KStartupInfoData* data_O ) - { - if( d == NULL ) - return false; - res_name = res_name.lower(); - res_class = res_class.lower(); - kdDebug( 172 ) << "find_wclass:" << res_name << ":" << res_class << endl; - for( TQMap< KStartupInfoId, Data >::Iterator it = d->startups.begin(); - it != d->startups.end(); - ++it ) - { - const TQCString wmclass = ( *it ).findWMClass(); - if( wmclass.lower() == res_name || wmclass.lower() == res_class ) - { // Found it ! - if( id_O != NULL ) - *id_O = it.key(); - if( data_O != NULL ) - *data_O = *it; - // non-compliant, remove on first match - remove_startup_info_internal( it.key()); - kdDebug( 172 ) << "check_startup_wclass:match" << endl; - return true; - } - } - return false; - } - -#ifdef Q_WS_X11 -static Atom net_startup_atom = None; - -static TQCString read_startup_id_property( WId w_P ) - { - TQCString ret; - unsigned char *name_ret; - Atom type_ret; - int format_ret; - unsigned long nitems_ret = 0, after_ret = 0; - if( XGetWindowProperty( qt_xdisplay(), w_P, net_startup_atom, 0l, 4096, - False, utf8_string_atom, &type_ret, &format_ret, &nitems_ret, &after_ret, &name_ret ) - == Success ) - { - if( type_ret == utf8_string_atom && format_ret == 8 && name_ret != NULL ) - ret = reinterpret_cast< char* >( name_ret ); - if ( name_ret != NULL ) - XFree( name_ret ); - } - return ret; - } - -#endif - -TQCString KStartupInfo::windowStartupId( WId w_P ) - { -#ifdef Q_WS_X11 - if( net_startup_atom == None ) - net_startup_atom = XInternAtom( qt_xdisplay(), NET_STARTUP_WINDOW, False ); - if( utf8_string_atom == None ) - utf8_string_atom = XInternAtom( qt_xdisplay(), "UTF8_STRING", False ); - TQCString ret = read_startup_id_property( w_P ); - if( ret.isEmpty()) - { // retry with window group leader, as the spec says - XWMHints* hints = XGetWMHints( qt_xdisplay(), w_P ); - if( hints && ( hints->flags & WindowGroupHint ) != 0 ) - ret = read_startup_id_property( hints->window_group ); - if( hints ) - XFree( hints ); - } - return ret; -#else - return TQCString(); -#endif - } - -void KStartupInfo::setWindowStartupId( WId w_P, const TQCString& id_P ) - { -#ifdef Q_WS_X11 - if( id_P.isNull()) - return; - if( net_startup_atom == None ) - net_startup_atom = XInternAtom( qt_xdisplay(), NET_STARTUP_WINDOW, False ); - if( utf8_string_atom == None ) - utf8_string_atom = XInternAtom( qt_xdisplay(), "UTF8_STRING", False ); - XChangeProperty( qt_xdisplay(), w_P, net_startup_atom, utf8_string_atom, 8, - PropModeReplace, reinterpret_cast< unsigned char* >( const_cast<TQCString&>(id_P).data()), id_P.length()); -#endif - } - -TQCString KStartupInfo::get_window_hostname( WId w_P ) - { -#ifdef Q_WS_X11 - XTextProperty tp; - char** hh; - int cnt; - if( XGetWMClientMachine( qt_xdisplay(), w_P, &tp ) != 0 - && XTextPropertyToStringList( &tp, &hh, &cnt ) != 0 ) - { - if( cnt == 1 ) - { - TQCString hostname = hh[ 0 ]; - XFreeStringList( hh ); - return hostname; - } - XFreeStringList( hh ); - } -#endif - // no hostname - return TQCString(); - } - -void KStartupInfo::setTimeout( unsigned int secs_P ) - { - timeout = secs_P; - // schedule removing entries that are older than the new timeout - TQTimer::singleShot( 0, this, TQT_SLOT( startups_cleanup_no_age())); - } - -void KStartupInfo::startups_cleanup_no_age() - { - startups_cleanup_internal( false ); - } - -void KStartupInfo::startups_cleanup() - { - if( d == NULL ) - return; - if( d->startups.count() == 0 && d->silent_startups.count() == 0 - && d->uninited_startups.count() == 0 ) - { - d->cleanup->stop(); - return; - } - startups_cleanup_internal( true ); - } - -void KStartupInfo::startups_cleanup_internal( bool age_P ) - { - if( d == NULL ) - return; - for( TQMap< KStartupInfoId, Data >::Iterator it = d->startups.begin(); - it != d->startups.end(); - ) - { - if( age_P ) - ( *it ).age++; - unsigned int tout = timeout; - if( ( *it ).silent() == Data::Yes ) // TODO - tout *= 20; - if( ( *it ).age >= tout ) - { - const KStartupInfoId& key = it.key(); - ++it; - kdDebug( 172 ) << "startups entry timeout:" << key.id() << endl; - remove_startup_info_internal( key ); - } - else - ++it; - } - for( TQMap< KStartupInfoId, Data >::Iterator it = d->silent_startups.begin(); - it != d->silent_startups.end(); - ) - { - if( age_P ) - ( *it ).age++; - unsigned int tout = timeout; - if( ( *it ).silent() == Data::Yes ) // TODO - tout *= 20; - if( ( *it ).age >= tout ) - { - const KStartupInfoId& key = it.key(); - ++it; - kdDebug( 172 ) << "silent entry timeout:" << key.id() << endl; - remove_startup_info_internal( key ); - } - else - ++it; - } - for( TQMap< KStartupInfoId, Data >::Iterator it = d->uninited_startups.begin(); - it != d->uninited_startups.end(); - ) - { - if( age_P ) - ( *it ).age++; - unsigned int tout = timeout; - if( ( *it ).silent() == Data::Yes ) // TODO - tout *= 20; - if( ( *it ).age >= tout ) - { - const KStartupInfoId& key = it.key(); - ++it; - kdDebug( 172 ) << "uninited entry timeout:" << key.id() << endl; - remove_startup_info_internal( key ); - } - else - ++it; - } - } - -void KStartupInfo::clean_all_noncompliant() - { - if( d == NULL ) - return; - for( TQMap< KStartupInfoId, Data >::Iterator it = d->startups.begin(); - it != d->startups.end(); - ) - { - if( ( *it ).WMClass() != "0" ) - { - ++it; - continue; - } - const KStartupInfoId& key = it.key(); - ++it; - kdDebug( 172 ) << "entry cleaning:" << key.id() << endl; - remove_startup_info_internal( key ); - } - } - -TQCString KStartupInfo::createNewStartupId() - { - // Assign a unique id, use hostname+time+pid, that should be 200% unique. - // Also append the user timestamp (for focus stealing prevention). - struct timeval tm; - gettimeofday( &tm, NULL ); - char hostname[ 256 ]; - hostname[ 0 ] = '\0'; - if (!gethostname( hostname, 255 )) - hostname[sizeof(hostname)-1] = '\0'; - TQCString id = TQString(TQString( "%1;%2;%3;%4_TIME%5" ).arg( hostname ).arg( tm.tv_sec ) - .arg( tm.tv_usec ).arg( getpid()).arg( GET_QT_X_USER_TIME() )).utf8(); - kdDebug( 172 ) << "creating: " << id << ":" << tqAppName() << endl; - return id; - } - - -struct KStartupInfoIdPrivate - { - KStartupInfoIdPrivate() : id( "" ) {} - TQCString id; // id - }; - -const TQCString& KStartupInfoId::id() const - { - return d->id; - } - - -TQString KStartupInfoId::to_text() const - { - return TQString::tqfromLatin1( " ID=\"%1\" " ).arg( escape_str( id())); - } - -KStartupInfoId::KStartupInfoId( const TQString& txt_P ) - { - d = new KStartupInfoIdPrivate; - TQStringList items = get_fields( txt_P ); - const TQString id_str = TQString::tqfromLatin1( "ID=" ); - for( TQStringList::Iterator it = items.begin(); - it != items.end(); - ++it ) - { - if( ( *it ).startsWith( id_str )) - d->id = get_cstr( *it ); - } - } - -void KStartupInfoId::initId( const TQCString& id_P ) - { - if( !id_P.isEmpty()) - { - d->id = id_P; -#ifdef KSTARTUPINFO_ALL_DEBUG - kdDebug( 172 ) << "using: " << d->id << endl; -#endif - return; - } - const char* startup_env = getenv( NET_STARTUP_ENV ); - if( startup_env != NULL && *startup_env != '\0' ) - { // already has id - d->id = startup_env; -#ifdef KSTARTUPINFO_ALL_DEBUG - kdDebug( 172 ) << "reusing: " << d->id << endl; -#endif - return; - } - d->id = KStartupInfo::createNewStartupId(); - } - -bool KStartupInfoId::setupStartupEnv() const - { - if( id().isEmpty()) - { - unsetenv( NET_STARTUP_ENV ); - return false; - } - return setenv( NET_STARTUP_ENV, id(), true ) == 0; - } - -KStartupInfoId KStartupInfo::currentStartupIdEnv() - { - const char* startup_env = getenv( NET_STARTUP_ENV ); - KStartupInfoId id; - if( startup_env != NULL && *startup_env != '\0' ) - id.d->id = startup_env; - else - id.d->id = "0"; - return id; - } - -void KStartupInfo::resetStartupEnv() - { - unsetenv( NET_STARTUP_ENV ); - } - -KStartupInfoId::KStartupInfoId() - { - d = new KStartupInfoIdPrivate; - } - -KStartupInfoId::~KStartupInfoId() - { - delete d; - } - -KStartupInfoId::KStartupInfoId( const KStartupInfoId& id_P ) - { - d = new KStartupInfoIdPrivate( *id_P.d ); - } - -KStartupInfoId& KStartupInfoId::operator=( const KStartupInfoId& id_P ) - { - if( &id_P == this ) - return *this; - delete d; - d = new KStartupInfoIdPrivate( *id_P.d ); - return *this; - } - -bool KStartupInfoId::operator==( const KStartupInfoId& id_P ) const - { - return id() == id_P.id(); - } - -bool KStartupInfoId::operator!=( const KStartupInfoId& id_P ) const - { - return !(*this == id_P ); - } - -// needed for QMap -bool KStartupInfoId::operator<( const KStartupInfoId& id_P ) const - { - return id() < id_P.id(); - } - -bool KStartupInfoId::none() const - { - return d->id.isEmpty() || d->id == "0"; - } - -unsigned long KStartupInfoId::timestamp() const - { - if( none()) - return 0; - int pos = d->id.findRev( "_TIME" ); - if( pos >= 0 ) - { - bool ok; - unsigned long time = d->id.mid( pos + 5 ).toULong( &ok ); - if( !ok && d->id[ pos + 5 ] == '-' ) // try if it's as a negative signed number perhaps - time = d->id.mid( pos + 5 ).toLong( &ok ); - if( ok ) - return time; - } - // libstartup-notification style : - // snprintf (s, len, "%s/%s/%lu/%d-%d-%s", - // canonicalized_launcher, canonicalized_launchee, (unsigned long) timestamp, - // (int) getpid (), (int) sequence_number, hostbuf); - int pos1 = d->id.findRev( '/' ); - if( pos1 > 0 ) - { - int pos2 = d->id.findRev( '/', pos1 - 1 ); - if( pos2 >= 0 ) - { - bool ok; - unsigned long time = d->id.mid( pos2 + 1, pos1 - pos2 - 1 ).toULong( &ok ); - if( !ok && d->id[ pos2 + 1 ] == '-' ) // try if it's as a negative signed number perhaps - time = d->id.mid( pos2 + 1, pos1 - pos2 - 1 ).toLong( &ok ); - if( ok ) - return time; - } - } - // bah ... old KStartupInfo or a problem - return 0; - } - -struct KStartupInfoDataPrivate - { - KStartupInfoDataPrivate() : desktop( 0 ), wmclass( "" ), hostname( "" ), - silent( KStartupInfoData::Unknown ), timestamp( -1U ), screen( -1 ), xinerama( -1 ), launched_by( 0 ) {} - TQString bin; - TQString name; - TQString description; - TQString icon; - int desktop; - TQValueList< pid_t > pids; - TQCString wmclass; - TQCString hostname; - KStartupInfoData::TriState silent; - unsigned long timestamp; - int screen; - int xinerama; - WId launched_by; - }; - -TQString KStartupInfoData::to_text() const - { - TQString ret = ""; - if( !d->bin.isEmpty()) - ret += TQString::tqfromLatin1( " BIN=\"%1\"" ).arg( escape_str( d->bin )); - if( !d->name.isEmpty()) - ret += TQString::tqfromLatin1( " NAME=\"%1\"" ).arg( escape_str( d->name )); - if( !d->description.isEmpty()) - ret += TQString::tqfromLatin1( " DESCRIPTION=\"%1\"" ).arg( escape_str( d->description )); - if( !d->icon.isEmpty()) - ret += TQString::tqfromLatin1( " ICON=%1" ).arg( d->icon ); - if( d->desktop != 0 ) - ret += TQString::tqfromLatin1( " DESKTOP=%1" ) - .arg( d->desktop == NET::OnAllDesktops ? NET::OnAllDesktops : d->desktop - 1 ); // spec counts from 0 - if( !d->wmclass.isEmpty()) - ret += TQString::tqfromLatin1( " WMCLASS=\"%1\"" ).arg( QString(d->wmclass) ); - if( !d->hostname.isEmpty()) - ret += TQString::tqfromLatin1( " HOSTNAME=%1" ).arg( QString(d->hostname) ); - for( TQValueList< pid_t >::ConstIterator it = d->pids.begin(); - it != d->pids.end(); - ++it ) - ret += TQString::tqfromLatin1( " PID=%1" ).arg( *it ); - if( d->silent != Unknown ) - ret += TQString::tqfromLatin1( " SILENT=%1" ).arg( d->silent == Yes ? 1 : 0 ); - if( d->timestamp != -1U ) - ret += TQString::tqfromLatin1( " TIMESTAMP=%1" ).arg( d->timestamp ); - if( d->screen != -1 ) - ret += TQString::tqfromLatin1( " SCREEN=%1" ).arg( d->screen ); - if( d->xinerama != -1 ) - ret += TQString::tqfromLatin1( " XINERAMA=%1" ).arg( d->xinerama ); - if( d->launched_by != 0 ) - ret += TQString::tqfromLatin1( " LAUNCHED_BY=%1" ).arg( d->launched_by ); - return ret; - } - -KStartupInfoData::KStartupInfoData( const TQString& txt_P ) - { - d = new KStartupInfoDataPrivate; - TQStringList items = get_fields( txt_P ); - const TQString bin_str = TQString::tqfromLatin1( "BIN=" ); - const TQString name_str = TQString::tqfromLatin1( "NAME=" ); - const TQString description_str = TQString::tqfromLatin1( "DESCRIPTION=" ); - const TQString icon_str = TQString::tqfromLatin1( "ICON=" ); - const TQString desktop_str = TQString::tqfromLatin1( "DESKTOP=" ); - const TQString wmclass_str = TQString::tqfromLatin1( "WMCLASS=" ); - const TQString hostname_str = TQString::tqfromLatin1( "HOSTNAME=" ); // SELI nonstd - const TQString pid_str = TQString::tqfromLatin1( "PID=" ); // SELI nonstd - const TQString silent_str = TQString::tqfromLatin1( "SILENT=" ); - const TQString timestamp_str = TQString::tqfromLatin1( "TIMESTAMP=" ); - const TQString screen_str = TQString::tqfromLatin1( "SCREEN=" ); - const TQString xinerama_str = TQString::tqfromLatin1( "XINERAMA=" ); - const TQString launched_by_str = TQString::tqfromLatin1( "LAUNCHED_BY=" ); - for( TQStringList::Iterator it = items.begin(); - it != items.end(); - ++it ) - { - if( ( *it ).startsWith( bin_str )) - d->bin = get_str( *it ); - else if( ( *it ).startsWith( name_str )) - d->name = get_str( *it ); - else if( ( *it ).startsWith( description_str )) - d->description = get_str( *it ); - else if( ( *it ).startsWith( icon_str )) - d->icon = get_str( *it ); - else if( ( *it ).startsWith( desktop_str )) - { - d->desktop = get_num( *it ); - if( d->desktop != NET::OnAllDesktops ) - ++d->desktop; // spec counts from 0 - } - else if( ( *it ).startsWith( wmclass_str )) - d->wmclass = get_cstr( *it ); - else if( ( *it ).startsWith( hostname_str )) - d->hostname = get_cstr( *it ); - else if( ( *it ).startsWith( pid_str )) - addPid( get_num( *it )); - else if( ( *it ).startsWith( silent_str )) - d->silent = get_num( *it ) != 0 ? Yes : No; - else if( ( *it ).startsWith( timestamp_str )) - d->timestamp = get_unum( *it ); - else if( ( *it ).startsWith( screen_str )) - d->screen = get_num( *it ); - else if( ( *it ).startsWith( xinerama_str )) - d->xinerama = get_num( *it ); - else if( ( *it ).startsWith( launched_by_str )) - d->launched_by = get_num( *it ); - } - } - -KStartupInfoData::KStartupInfoData( const KStartupInfoData& data ) -{ - d = new KStartupInfoDataPrivate( *data.d ); -} - -KStartupInfoData& KStartupInfoData::operator=( const KStartupInfoData& data ) -{ - if( &data == this ) - return *this; - delete d; - d = new KStartupInfoDataPrivate( *data.d ); - return *this; -} - -void KStartupInfoData::update( const KStartupInfoData& data_P ) - { - if( !data_P.bin().isEmpty()) - d->bin = data_P.bin(); - if( !data_P.name().isEmpty() && name().isEmpty()) // don't overwrite - d->name = data_P.name(); - if( !data_P.description().isEmpty() && description().isEmpty()) // don't overwrite - d->description = data_P.description(); - if( !data_P.icon().isEmpty() && icon().isEmpty()) // don't overwrite - d->icon = data_P.icon(); - if( data_P.desktop() != 0 && desktop() == 0 ) // don't overwrite - d->desktop = data_P.desktop(); - if( !data_P.d->wmclass.isEmpty()) - d->wmclass = data_P.d->wmclass; - if( !data_P.d->hostname.isEmpty()) - d->hostname = data_P.d->hostname; - for( TQValueList< pid_t >::ConstIterator it = data_P.d->pids.begin(); - it != data_P.d->pids.end(); - ++it ) - addPid( *it ); - if( data_P.silent() != Unknown ) - d->silent = data_P.silent(); - if( data_P.timestamp() != -1U && timestamp() == -1U ) // don't overwrite - d->timestamp = data_P.timestamp(); - if( data_P.screen() != -1 ) - d->screen = data_P.screen(); - if( data_P.xinerama() != -1 && xinerama() != -1 ) // don't overwrite - d->xinerama = data_P.xinerama(); - if( data_P.launchedBy() != 0 && launchedBy() != 0 ) // don't overwrite - d->launched_by = data_P.launchedBy(); - } - -KStartupInfoData::KStartupInfoData() -{ - d = new KStartupInfoDataPrivate; -} - -KStartupInfoData::~KStartupInfoData() -{ - delete d; -} - -void KStartupInfoData::setBin( const TQString& bin_P ) - { - d->bin = bin_P; - } - -const TQString& KStartupInfoData::bin() const - { - return d->bin; - } - -void KStartupInfoData::setName( const TQString& name_P ) - { - d->name = name_P; - } - -const TQString& KStartupInfoData::name() const - { - return d->name; - } - -const TQString& KStartupInfoData::findName() const - { - if( !name().isEmpty()) - return name(); - return bin(); - } - -void KStartupInfoData::setDescription( const TQString& desc_P ) - { - d->description = desc_P; - } - -const TQString& KStartupInfoData::description() const - { - return d->description; - } - -const TQString& KStartupInfoData::findDescription() const - { - if( !description().isEmpty()) - return description(); - return name(); - } - -void KStartupInfoData::setIcon( const TQString& icon_P ) - { - d->icon = icon_P; - } - -const TQString& KStartupInfoData::findIcon() const - { - if( !icon().isEmpty()) - return icon(); - return bin(); - } - -const TQString& KStartupInfoData::icon() const - { - return d->icon; - } - -void KStartupInfoData::setDesktop( int desktop_P ) - { - d->desktop = desktop_P; - } - -int KStartupInfoData::desktop() const - { - return d->desktop; - } - -void KStartupInfoData::setWMClass( const TQCString& wmclass_P ) - { - d->wmclass = wmclass_P; - } - -const TQCString KStartupInfoData::findWMClass() const - { - if( !WMClass().isEmpty() && WMClass() != "0" ) - return WMClass(); - return bin().utf8(); - } - -const TQCString& KStartupInfoData::WMClass() const - { - return d->wmclass; - } - -void KStartupInfoData::setHostname( const TQCString& hostname_P ) - { - if( !hostname_P.isNull()) - d->hostname = hostname_P; - else - { - char tmp[ 256 ]; - tmp[ 0 ] = '\0'; - if (!gethostname( tmp, 255 )) - tmp[sizeof(tmp)-1] = '\0'; - d->hostname = tmp; - } - } - -const TQCString& KStartupInfoData::hostname() const - { - return d->hostname; - } - -void KStartupInfoData::addPid( pid_t pid_P ) - { - if( !d->pids.contains( pid_P )) - d->pids.append( pid_P ); - } - -void KStartupInfoData::remove_pid( pid_t pid_P ) - { - d->pids.remove( pid_P ); - } - -const TQValueList< pid_t >& KStartupInfoData::pids() const - { - return d->pids; - } - -bool KStartupInfoData::is_pid( pid_t pid_P ) const - { - return d->pids.contains( pid_P ); - } - -void KStartupInfoData::setSilent( TriState state_P ) - { - d->silent = state_P; - } - -KStartupInfoData::TriState KStartupInfoData::silent() const - { - return d->silent; - } - -void KStartupInfoData::setTimestamp( unsigned long time ) - { - d->timestamp = time; - } - -unsigned long KStartupInfoData::timestamp() const - { - return d->timestamp; - } - -void KStartupInfoData::setScreen( int screen ) - { - d->screen = screen; - } - -int KStartupInfoData::screen() const - { - return d->screen; - } - -void KStartupInfoData::setXinerama( int xinerama ) - { - d->xinerama = xinerama; - } - -int KStartupInfoData::xinerama() const - { - return d->xinerama; - } - -void KStartupInfoData::setLaunchedBy( WId window ) - { - d->launched_by = window; - } - -WId KStartupInfoData::launchedBy() const - { - return d->launched_by; - } - -static -long get_num( const TQString& item_P ) - { - unsigned int pos = item_P.find( '=' ); - return item_P.mid( pos + 1 ).toLong(); - } - -static -unsigned long get_unum( const TQString& item_P ) - { - unsigned int pos = item_P.find( '=' ); - return item_P.mid( pos + 1 ).toULong(); - } - -static -TQString get_str( const TQString& item_P ) - { - unsigned int pos = item_P.find( '=' ); - if( item_P.length() > pos + 2 && item_P[ pos + 1 ] == (QChar)'\"' ) - { - int pos2 = item_P.left( pos + 2 ).find( '\"' ); - if( pos2 < 0 ) - return TQString::null; // 01234 - return item_P.mid( pos + 2, pos2 - 2 - pos ); // A="C" - } - return item_P.mid( pos + 1 ); - } - -static -TQCString get_cstr( const TQString& item_P ) - { - return get_str( item_P ).utf8(); - } - -static -TQStringList get_fields( const TQString& txt_P ) - { - TQString txt = txt_P.simplifyWhiteSpace(); - TQStringList ret; - TQString item = ""; - bool in = false; - bool escape = false; - for( unsigned int pos = 0; - pos < txt.length(); - ++pos ) - { - if( escape ) - { - item += txt[ pos ]; - escape = false; - } - else if( txt[ pos ] == '\\' ) - escape = true; - else if( txt[ pos ] == '\"' ) - in = !in; - else if( txt[ pos ] == ' ' && !in ) - { - ret.append( item ); - item = ""; - } - else - item += txt[ pos ]; - } - ret.append( item ); - return ret; - } - -static TQString escape_str( const TQString& str_P ) - { - TQString ret = ""; - for( unsigned int pos = 0; - pos < str_P.length(); - ++pos ) - { - if( str_P[ pos ] == (QChar)'\\' - || str_P[ pos ] == (QChar)'"' ) - ret += '\\'; - ret += str_P[ pos ]; - } - return ret; - } - -#include "kstartupinfo.moc" -#endif diff --git a/kdecore/kstartupinfo.h b/kdecore/kstartupinfo.h deleted file mode 100644 index 807e484c5..000000000 --- a/kdecore/kstartupinfo.h +++ /dev/null @@ -1,697 +0,0 @@ -/**************************************************************************** - - Copyright (C) 2001-2003 Lubos Lunak <l.lunak@kde.org> - -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 __KSTARTUPINFO_H -#define __KSTARTUPINFO_H - -#include <sys/types.h> -#include <tqobject.h> - -#ifdef Q_MOC_RUN -#define Q_WS_X11 -#endif // Q_MOC_RUN - -#ifdef Q_WS_X11 // FIXME(E): Redo in a less X11-specific way - -#include <tqcstring.h> -#include <tqstring.h> -#include <tqvaluelist.h> -#include "kdelibs_export.h" - -class KStartupInfoId; -class KStartupInfoData; - -class KStartupInfoPrivate; - -/** - * Class for manipulating the application startup notification. - * - * This class can be used to send information about started application, - * change the information and receive this information. For detailed - * description, see kdelibs/tdecore/README.kstartupinfo. - * - * You usually don't need to use this class for sending the notification - * information, as KDE libraries should do this when an application is - * started (e.g. KRun class). - * - * For receiving the startup notification info, create an instance and connect - * to its slots. It will automatically detect started applications and when - * they are ready. - * - * @see KStartupInfoId - * @see KStartupInfoData - * - * @author Lubos Lunak <l.lunak@kde.org> - */ -class KDECORE_EXPORT KStartupInfo - : public TQObject - { - Q_OBJECT - TQ_OBJECT - public: - /** - * By default, the startup notification is ended for the application - * after it shows its first toplevel window. If you app e.g. has - * several toplevel windows after its startup, you can disable - * the automatic handling, and call appStarted() manually after - * all toplevel windows have been shown. - * @since 3.2 - */ - static void disableAutoAppStartedSending( bool disable = true ); - - /** - * Manual notification that the application has started. - * If you do not map a (toplevel) window, then startup - * notification will not disappear for the application - * until a timeout. You can use this as an alternative - * method in this case. - */ - static void appStarted(); - - /** - * Sends explicit notification that the startup notification - * with id startup_id should end. - * @since 3.2 - */ - static void appStarted( const TQCString& startup_id ); - - /** - * Use this function if the application got a request with startup - * notification from outside (for example, when KUniqueApplication::newInstance() - * is called, or e.g. when khelpcenter opens new URL in its window). - * The window can be either an already existing and visible window, - * or a new one, before being shown. Note that this function is usually - * needed only when a window is reused. - * @since 3.2 - */ - static void setNewStartupId( TQWidget* window, const TQCString& startup_id ); - - /** - * If your application shows temporarily some window during its startup, - * for example a dialog, and only after closing it shows the main window, - * startup notification would normally be shown while the dialog is visible. - * To temporarily suspend and resume the notification, use this function. - * Note that this is cumulative, i.e. after suspending twice, you have to - * resume twice. - * @since 3.2 - */ - static void silenceStartup( bool silence ); - - /** - * Creates and returns new startup id. The id includes properly setup - * user timestamp. - * @since 3.3 - */ - static TQCString createNewStartupId(); - /** - * - */ - enum { - CleanOnCantDetect = 1 << 0, - DisableKWinModule = 1 << 1, - AnnounceSilenceChanges = 1 << 2 - }; - - /** - * Creates an instance that will receive the startup notifications. - * The various flags passed may be - * @li CleanOnCantDetect - when a new unknown window appears, all startup - * notifications for applications that are not compliant with - * the startup protocol are removed - * @li DisableKWinModule - KWinModule, which is normally used to detect - * new windows, is disabled. With this flag, checkStartup() must be - * called in order to check newly mapped windows. - * @li AnnounceSilenceChanges - normally, startup notifications are - * "removed" when they're silenced, and "recreated" when they're resumed. - * With this flag, the change is normally announced with gotStartupChange(). - * - * @param flags OR-ed combination of flags - * @param parent the parent of this TQObject (can be 0 for no parent) - * @param name the name of the TQObject (can be 0 for no name) - * - */ - KStartupInfo( int flags, TQObject* parent = NULL, const char* name = NULL ); - /** - * Creates an instance that will receive the startup notifications. - * - * @param clean_on_cantdetect if true, and a new unknown window appears, - * removes all notification for applications that are not compliant - * with the app startup protocol - * @param parent the parent of this TQObject (can be 0 for no parent) - * @param name the name of the TQObject (can be 0 for no name) - * - * @obsolete - */ - KStartupInfo( bool clean_on_cantdetect, TQObject* parent = 0, const char* name = 0 ); - virtual ~KStartupInfo(); - /** - * Sends given notification data about started application - * with the given startup identification. If no notification for this identification - * exists yet, it is created, otherwise it's updated. Note that the name field - * in data is required. - * - * @param id the id of the application - * @param data the application's data - * @return true if successful, false otherwise - * @see KStartupInfoId - * @see KStartupInfoData - */ - static bool sendStartup( const KStartupInfoId& id, const KStartupInfoData& data ); - - /** - * Like sendStartup , uses dpy instead of qt_xdisplay() for sending the info. - * @param dpy the display of the application. Note that the name field - * in data is required. - * @param id the id of the application - * @param data the application's data - * @return true if successful, false otherwise - */ - static bool sendStartupX( Display* dpy, const KStartupInfoId& id, - const KStartupInfoData& data ); - - /** - * Sends given notification data about started application - * with the given startup identification. This is used for updating the notification - * info, if no notification for this identification exists, it's ignored. - * @param id the id of the application - * @param data the application's data - * @return true if successful, false otherwise - * @see KStartupInfoId - * @see KStartupInfoData - */ - static bool sendChange( const KStartupInfoId& id, const KStartupInfoData& data ); - - /** - * Like sendChange , uses dpy instead of qt_xdisplay() for sending the info. - * @param dpy the display of the application. - * @param id the id of the application - * @param data the application's data - * @return true if successful, false otherwise - */ - static bool sendChangeX( Display* dpy, const KStartupInfoId& id, - const KStartupInfoData& data ); - - /** - * Ends startup notification with the given identification. - * @param id the id of the application - * @return true if successful, false otherwise - */ - static bool sendFinish( const KStartupInfoId& id ); - - /** - * Like sendFinish , uses dpy instead of qt_xdisplay() for sending the info. - * @param dpy the display of the application. - * @param id the id of the application - * @return true if successful, false otherwise - */ - static bool sendFinishX( Display* dpy, const KStartupInfoId& id ); - - /** - * Ends startup notification with the given identification and the given data ( e.g. - * PIDs of processes for this startup notification that exited ). - * @param id the id of the application - * @param data the application's data - * @return true if successful, false otherwise - */ - static bool sendFinish( const KStartupInfoId& id, const KStartupInfoData& data ); - - /** - * Like sendFinish , uses dpy instead of qt_xdisplay() for sending the info. - * @param dpy the display of the application. - * @param id the id of the application - * @param data the application's data - * @return true if successful, false otherwise - */ - static bool sendFinishX( Display* dpy, const KStartupInfoId& id, - const KStartupInfoData& data ); - - /** - * Returns the current startup notification identification for the current - * startup notification environment variable. Note that KApplication constructor - * unsets the variable and you have to use KApplication::startupId . - * @return the current startup notification identification - */ - static KStartupInfoId currentStartupIdEnv(); - /** - * Unsets the startup notification environment variable. - */ - static void resetStartupEnv(); - /** - * @li NoMatch - the window doesn't match any existing startup notification - * @li Match - the window matches an existing startup notification - * @li CantDetect - unable to detect if the window matches any existing - * startup notification - */ - enum startup_t { NoMatch, Match, CantDetect }; - /** - * Checks if the given windows matches any existing startup notification. - * @param w the window id to check - * @return the result of the operation - */ - startup_t checkStartup( WId w ); - /** - * Checks if the given windows matches any existing startup notification, and - * if yes, returns the identification in id. - * @param w the window id to check - * @param id if found, the id of the startup notification will be written here - * @return the result of the operation - */ - startup_t checkStartup( WId w, KStartupInfoId& id ); - /** - * Checks if the given windows matches any existing startup notification, and - * if yes, returns the notification data in data. - * @param w the window id to check - * @param data if found, the data of the startup notification will be written here - * @return the result of the operation - */ - startup_t checkStartup( WId w, KStartupInfoData& data ); - /** - * Checks if the given windows matches any existing startup notification, and - * if yes, returns the identification in id and notification data in data. - * @param w the window id to check - * @param id if found, the id of the startup notification will be written here - * @param data if found, the data of the startup notification will be written here - * @return the result of the operation - */ - startup_t checkStartup( WId w, KStartupInfoId& id, KStartupInfoData& data ); - /** - * Sets the timeout for notifications, after this timeout a notification is removed. - * @param secs the new timeout in seconds - */ - void setTimeout( unsigned int secs ); - /** - * Sets the startup notification window property on the given window. - * @param window the id of the window - * @param id the startup notification id - */ - static void setWindowStartupId( WId window, const TQCString& id ); - /** - * Returns startup notification identification of the given window. - * @param w the id of the window - * @return the startup notification id. Can be null if not found. - */ - static TQCString windowStartupId( WId w ); - /** - * @internal - */ - static void handleAutoAppStartedSending(); - /** - * @internal - */ - class Data; - signals: - /** - * Emitted when a new startup notification is created (i.e. a new application is - * being started). - * @param id the notification identification - * @param data the notification data - */ - void gotNewStartup( const KStartupInfoId& id, const KStartupInfoData& data ); - /** - * Emitted when a startup notification changes. - * @param id the notification identification - * @param data the notification data - */ - void gotStartupChange( const KStartupInfoId& id, const KStartupInfoData& data ); - /** - * Emitted when a startup notification is removed (either because it was detected - * that the application is ready or because of a timeout). - * @param id the notification identification - * @param data the notification data - */ - void gotRemoveStartup( const KStartupInfoId& id, const KStartupInfoData& data ); - protected: - /** - * - */ - virtual void customEvent( TQCustomEvent* e_P ); - private slots: - void startups_cleanup(); - void startups_cleanup_no_age(); - void got_message( const TQString& msg ); - void window_added( WId w ); - void slot_window_added( WId w ); - private: - void init( int flags ); - friend class KStartupInfoPrivate; - void got_startup_info( const TQString& msg_P, bool update_only_P ); - void got_remove_startup_info( const TQString& msg_P ); - void new_startup_info_internal( const KStartupInfoId& id_P, - Data& data_P, bool update_only_P ); - void remove_startup_info_internal( const KStartupInfoId& id_P ); - void remove_startup_pids( const KStartupInfoId& id, const KStartupInfoData& data ); - void remove_startup_pids( const KStartupInfoData& data ); - startup_t check_startup_internal( WId w, KStartupInfoId* id, KStartupInfoData* data ); - bool find_id( const TQCString& id_P, KStartupInfoId* id_O, - KStartupInfoData* data_O ); - bool find_pid( pid_t pid_P, const TQCString& hostname, KStartupInfoId* id_O, - KStartupInfoData* data_O ); - bool find_wclass( TQCString res_name_P, TQCString res_class_P, - KStartupInfoId* id_O, KStartupInfoData* data_O ); - static TQCString get_window_hostname( WId w_P ); - void startups_cleanup_internal( bool age_P ); - void clean_all_noncompliant(); - static TQString check_required_startup_fields( const TQString& msg, - const KStartupInfoData& data, int screen ); - bool clean_on_cantdetect_; // KDE4 remove unused - unsigned int timeout; - KStartupInfoPrivate* d; - }; - -class KStartupInfoIdPrivate; - -/** - * Class representing an identification of application startup notification. - * - * Every existing notification about a starting application has its own unique - * identification, that's used to identify and manipulate the notification. - * - * @see KStartupInfo - * @see KStartupInfoData - * - * @author Lubos Lunak <l.lunak@kde.org> - */ -class KDECORE_EXPORT KStartupInfoId - { - public: - /** - * Overloaded operator. - * @return true if the notification identifications are the same - */ - bool operator==( const KStartupInfoId& id ) const; - /** - * Overloaded operator. - * @return true if the notification identifications are different - */ - bool operator!=( const KStartupInfoId& id ) const; - /** - * Checks whether the identifier is valid. - * @return true if this object doesn't represent a valid notification identification - */ - bool none() const; - /** - * Initializes this object with the given identification ( which may be also "0" - * for no notification ), or if "" is given, tries to read it from the startup - * notification environment variable, and if it's not set, creates a new one. - * @param id the new identification, "0" for no notification or "" to read - * the environment variable - */ - void initId( const TQCString& id = "" ); - /** - * Returns the notification identifier as string. - * @return the identification string for the notification - */ - const TQCString& id() const; - /** - * Return the user timestamp for the startup notification, or 0 if no timestamp - * is set. - * @since 3.3 - */ - unsigned long timestamp() const; - /** - * Sets the startup notification environment variable to this identification. - * @return true if successful, false otherwise - */ - bool setupStartupEnv() const; - /** - * Creates an empty identification - */ - KStartupInfoId(); - /** - * Copy constructor. - */ - KStartupInfoId( const KStartupInfoId& data ); - ~KStartupInfoId(); - KStartupInfoId& operator=( const KStartupInfoId& data ); - bool operator<( const KStartupInfoId& id ) const; - private: - KStartupInfoId( const TQString& txt ); - TQString to_text() const; - friend class KStartupInfo; - KStartupInfoIdPrivate* d; - }; - -class KStartupInfoDataPrivate; - -/** - * Class representing data about an application startup notification. - * - * Such data include the icon of the starting application, the desktop on which - * the application should start, the binary name of the application, etc. - * - * @see KStartupInfo - * @see KStartupInfoId - * - * @author Lubos Lunak <l.lunak@kde.org> - */ -class KDECORE_EXPORT KStartupInfoData - { - public: - /** - * Sets the binary name of the application ( e.g. 'kcontrol' ). - * @param bin the new binary name of the application - */ - void setBin( const TQString& bin ); - /** - * Returns the binary name of the starting application - * @return the new binary name of the application - */ - const TQString& bin() const; - /** - * Sets the name for the notification (e.g. 'Control Center') - */ - void setName( const TQString& name ); - /** - * Returns the name of the startup notification. If it's not available, - * it tries to use other information (binary name). - * @return the name of the startup notification - */ - const TQString& findName() const; - /** - * Returns the name of the startup notification, or empty if not available. - * @return the name of the startup notification, or an empty string - * if not set. - */ - const TQString& name() const; - /** - * Sets the description for the notification (e.g. 'Launching Control Center'). - * I.e. name() describes what is being started, while description() is - * the actual action performed by the starting. - * @since 3.2 - */ - void setDescription( const TQString& descr ); - /** - * Returns the description of the startup notification. If it's not available, - * it returns name(). - * @return the description of the startup notification - * @since 3.2 - */ - const TQString& findDescription() const; - /** - * Returns the name of the startup notification, or empty if not available. - * @return the name of the startup notificaiton, or an empty string - * if not set. - * @since 3.2 - */ - const TQString& description() const; - /** - * Sets the icon for the startup notification ( e.g. 'kcontrol' ) - * @param icon the name of the icon - */ - void setIcon( const TQString& icon ); - /** - * Returns the icon of the startup notification, and if it's not available, - * tries to get it from the binary name. - * @return the name of the startup notification's icon, or the name of - * the binary if not set - */ - const TQString& findIcon() const; - /** - * Returns the icon of the startup notification, or empty if not available. - * @return the name of the icon, or an empty string if not set. - */ - const TQString& icon() const; - /** - * Sets the desktop for the startup notification ( i.e. the desktop on which - * the starting application should appear ). - * @param desktop the desktop for the startup notification - */ - void setDesktop( int desktop ); - /** - * Returns the desktop for the startup notification. - * @return the desktop for the startup notification - */ - int desktop() const; - /** - * Sets a WM_CLASS value for the startup notification, it may be used for increasing - * the chance that the windows created by the starting application will be - * detected correctly. - * @param wmclass the WM_CLASS value for the startup notification - */ - void setWMClass( const TQCString& wmclass ); - /** - * Returns the WM_CLASS value for the startup notification, or binary name if not - * available. - * @return the WM_CLASS value for the startup notification, or the binary name - * if not set - */ - const TQCString findWMClass() const; - /** - * Returns the WM_CLASS value for the startup notification, or empty if not available. - * @return the WM_CLASS value for the startup notification, or empty - * if not set - */ - const TQCString& WMClass() const; - /** - * Adds a PID to the list of processes that belong to the startup notification. It - * may be used to increase the chance that the windows created by the starting - * application will be detected correctly, and also for detecting if the application - * has quit without creating any window. - * @param pid the PID to add - */ - void addPid( pid_t pid ); - /** - * Returns all PIDs for the startup notification. - * @return the list of all PIDs - */ - const TQValueList< pid_t >& pids() const; - /** - * Checks whether the given @p pid is in the list of PIDs for starup - * notification. - * @return true if the given @p pid is in the list of PIDs for the startup notification - */ - bool is_pid( pid_t pid ) const; - /** - * Sets the hostname on which the application is starting. It's necessary to set - * it if PIDs are set. - * @param hostname the application's hostname. If it's a null string, the current hostname is used - */ - void setHostname( const TQCString& hostname = TQCString()); - /** - * Returns the hostname for the startup notification. - * @return the hostname - */ - const TQCString& hostname() const; - - /** - * - */ - enum TriState { Yes, No, Unknown }; - - /** - * Sets whether the visual feedback for this startup notification - * should be silenced (temporarily suspended). - * @since 3.1.1 - */ - void setSilent( TriState state ); - - /** - * Return the silence status for the startup notification. - * @return KStartupInfoData::Yes if visual feedback is silenced - * @since 3.1.1 - */ - TriState silent() const; - - /** - * @obsolete Timestamp is already assigned in KStartupInfoId::initId(). - * Sets timestamp for the startup notification. The timestamp is expressed - * as XServer time, and is used to prevent activation of the matching - * window if user interaction took place after this timestamp. - * Value -1 means no timestamp set, value 0 means that the window should - * not be activated. - */ - void setTimestamp( unsigned long time ); - - /** - * @obsolete Use KStartupInfoId::timestamp(). - * Return the timestamp for the startup notification, or -1 if no timestamp - * is set. - */ - unsigned long timestamp() const; - - /** - * The X11 screen on which the startup notification is happening, -1 if unknown. - */ - int screen() const; - - /** - * Sets the X11 screen on which the startup notification should happen. - * This is usually not necessary to set, as it's set by default to qt_xscreen(). - */ - void setScreen( int screen ); - - /** - * The Xinerama screen for the startup notification, -1 if unknown. - */ - int xinerama() const; - - /** - * Sets the Xinerama screen for the startup notification ( i.e. the screeen on which - * the starting application should appear ). - * @param xinerama the Xinerama screen for the startup notification - */ - void setXinerama( int xinerama ); - - /** - * The toplevel window of the application that caused this startup notification, - * 0 if unknown. - */ - WId launchedBy() const; - - /** - * Sets the toplevel window of the application that caused this startup notification. - * @param window window ID of the toplevel window that is responsible for this startup - */ - void setLaunchedBy( WId window ); - - /** - * Updates the notification data from the given data. Some data, such as the desktop - * or the name, won't be rewritten if already set. - * @param data the data to update - */ - void update( const KStartupInfoData& data ); - - /** - * Constructor. Initializes all the data to their default empty values. - */ - KStartupInfoData(); - - /** - * Copy constructor. - */ - KStartupInfoData( const KStartupInfoData& data ); - ~KStartupInfoData(); - KStartupInfoData& operator=( const KStartupInfoData& data ); - private: - KStartupInfoData( const TQString& txt ); - TQString to_text() const; - void remove_pid( pid_t pid ); - friend class KStartupInfo; - friend class KStartupInfo::Data; - KStartupInfoDataPrivate* d; - }; - -#endif //Q_WS_X11 - -#endif diff --git a/kdecore/kstaticdeleter.cpp b/kdecore/kstaticdeleter.cpp deleted file mode 100644 index 27c5cdf6b..000000000 --- a/kdecore/kstaticdeleter.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -#include <kstaticdeleter.h> - -// this helps gcc to emit the vtbl for KStaticDeleterBase -// only once, here in this file, not every time it's -// used, says Seli. -void KStaticDeleterBase::destructObject() -{ -} - diff --git a/kdecore/kstaticdeleter.h b/kdecore/kstaticdeleter.h deleted file mode 100644 index ee3e5755c..000000000 --- a/kdecore/kstaticdeleter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This file is part of the KDE Libraries - * Copyright (C) 2000 Stephan Kulow <coolo@kde.org> - * 2001 KDE Team - * - * 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 _KSTATIC_DELETER_H_ -#define _KSTATIC_DELETER_H_ - -#include <kglobal.h> - -/** - * Static deleters are used to manage static resources. They can register - * themselves with KGlobal. KGlobal will call destructObject() when - * KGlobal::deleteStaticDeleters() is called or when it the process - * finishes. - * - * @see KStaticDeleter - * @see KGlobal::registerStaticDeleter() - * @see KGlobal::unregisterStaticDeleter() - * @see KGlobal::deleteStaticDeleters() - */ -class KDECORE_EXPORT KStaticDeleterBase { -public: - virtual ~KStaticDeleterBase() { } - /** - * Should destruct the resources managed by this KStaticDeleterBase. - * Usually you also want to call it in your destructor. - * @see KGlobal::deleteStaticDeleters() - */ - virtual void destructObject(); -}; - -/** - * Little helper class to clean up static objects that are - * held as pointer. - * When the library is unloaded, or the app terminated, all static deleters - * are destroyed, which in turn destroys those static objects properly. - * There are some rules which you should accept in the KStaticDeleter managed - * class: - * @li Don't rely on the global reference variable in the destructor of the - * object, it will be '0' at destruction time. - * @li Don't rely on other KStaticDeleter managed objects in the destructor - * of the object, because it may be destroyed before your destructor get called. - * This one can be tricky, because you might not know that you actually use a - * KStaticDeleter managed class. So try to keep your destructor simple. - * - * A typical use is - * \code - * static KStaticDeleter<MyClass> sd; - * - * MyClass &MyClass::self() { - * if (!_self) { sd.setObject(_self, new MyClass()); } - * return *_self; - * } - * \endcode - */ -template<class type> class KStaticDeleter : public KStaticDeleterBase { -public: - KStaticDeleter() { deleteit = 0; globalReference = 0; array = false; } - /** - * Sets the object to delete and registers the object to be - * deleted to KGlobal. If the given object is 0, the former - * registration is unregistered. - * @param obj the object to delete - * @param isArray tells the destructor to delete an array instead of an object - * @deprecated See the other setObject variant. - **/ - KDE_DEPRECATED type *setObject( type *obj, bool isArray = false) { - deleteit = obj; - globalReference = 0; - array = isArray; - if (obj) - KGlobal::registerStaticDeleter(this); - else - KGlobal::unregisterStaticDeleter(this); - return obj; - } - /** - * Sets the object to delete and registers the object to be - * deleted to KGlobal. If the given object is 0, the former - * registration is unregistered. - * @param globalRef the static pointer where this object is stored - * This pointer will be reset to 0 after deletion of the object. - * @param obj the object to delete - * @param isArray tells the destructor to delete an array instead of an object - **/ - type *setObject( type* & globalRef, type *obj, bool isArray = false) { - globalReference = &globalRef; - deleteit = obj; - array = isArray; - if (obj) - KGlobal::registerStaticDeleter(this); - else - KGlobal::unregisterStaticDeleter(this); - globalRef = obj; - return obj; - } - - /** - * Destructs the object. This has the same effect as deleting - * the KStaticDeleter. - */ - virtual void destructObject() { - if (globalReference) - *globalReference = 0; - if (array) - delete [] deleteit; - else - delete deleteit; - deleteit = 0; - } - virtual ~KStaticDeleter() { - KGlobal::unregisterStaticDeleter(this); - destructObject(); - } -private: - type *deleteit; - type **globalReference; - bool array; -}; - -#endif diff --git a/kdecore/kstdaccel.cpp b/kdecore/kstdaccel.cpp deleted file mode 100644 index 85f8dda20..000000000 --- a/kdecore/kstdaccel.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Stefan Taferner (taferner@alpin.or.at) - Copyright (C) 2000 Nicolas Hadacek (haadcek@kde.org) - Copyright (C) 2001,2002 Ellis Whitehead (ellis@kde.org) - - 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. -*/ -#define __KSTDACCEL_CPP_ 1 - -#include "kstdaccel.h" - -#include "kaccelaction.h" -#include "kaccelbase.h" -#include <kconfig.h> -#include <kdebug.h> -#include <kglobal.h> -#include <klocale.h> -#include <kshortcut.h> -#include <kshortcutlist.h> - -namespace KStdAccel -{ - -struct KStdAccelInfo -{ - StdAccel id; - const char* psName; - const char* psDesc; - int cutDefault, cutDefault4, cutDefault3B, cutDefault4B; - KShortcut cut; - bool bInitialized; -}; - -/** Array of predefined KStdAccelInfo objects, which cover all - the "standard" accelerators. Each enum value from StdAccel - should appear in this table. -*/ -static KStdAccelInfo g_infoStdAccel[] = -{ - {AccelNone, "Group:File", I18N_NOOP("File"), 0, 0, 0, 0, KShortcut(), false }, - { Open, I18N_NOOP("Open"), 0, Qt::CTRL+Qt::Key_O, 0, 0, 0, KShortcut(), false }, - { New, I18N_NOOP("New"), 0, Qt::CTRL+Qt::Key_N, 0, 0, 0, KShortcut(), false }, - { Close, I18N_NOOP("Close"), 0, Qt::CTRL+Qt::Key_W, Qt::CTRL+Qt::Key_Escape, 0, Qt::CTRL+Qt::Key_W, KShortcut(), false }, - { Save, I18N_NOOP("Save"), 0, Qt::CTRL+Qt::Key_S, 0, 0, 0, KShortcut(), false }, - { Print, I18N_NOOP("Print"), 0, Qt::CTRL+Qt::Key_P, 0, 0, 0, KShortcut(), false }, - { Quit, I18N_NOOP("Quit"), 0, Qt::CTRL+Qt::Key_Q, 0, 0, 0, KShortcut(), false }, - {AccelNone, "Group:Edit", I18N_NOOP("Edit"), 0, 0, 0, 0, KShortcut(), false }, - { Undo, I18N_NOOP("Undo"), 0, Qt::CTRL+Qt::Key_Z, 0, 0, 0, KShortcut(), false }, - { Redo, I18N_NOOP("Redo"), 0, Qt::CTRL+Qt::SHIFT+Qt::Key_Z, 0, 0, 0, KShortcut(), false }, - { Cut, I18N_NOOP("Cut"), 0, Qt::CTRL+Qt::Key_X, 0, Qt::SHIFT+Qt::Key_Delete, 0, KShortcut(), false }, - { Copy, I18N_NOOP("Copy"), 0, Qt::CTRL+Qt::Key_C, 0, Qt::CTRL+Qt::Key_Insert, 0, KShortcut(), false }, - { Paste, I18N_NOOP("Paste"), 0, Qt::CTRL+Qt::Key_V, 0, Qt::SHIFT+Qt::Key_Insert, 0, KShortcut(), false }, - { PasteSelection, I18N_NOOP("Paste Selection"), 0, 0, 0, Qt::CTRL+Qt::SHIFT+Qt::Key_Insert, 0, KShortcut(), false }, - { SelectAll, "SelectAll", I18N_NOOP("Select All"), Qt::CTRL+Qt::Key_A, 0, 0, 0, KShortcut(), false }, - { Deselect, I18N_NOOP("Deselect"), 0, Qt::CTRL+Qt::SHIFT+Qt::Key_A, 0, 0, 0, KShortcut(), false }, - { DeleteWordBack, "DeleteWordBack", I18N_NOOP("Delete Word Backwards"), Qt::CTRL+Qt::Key_Backspace, 0, 0, 0, KShortcut(), false }, - { DeleteWordForward, "DeleteWordForward", I18N_NOOP("Delete Word Forward"), Qt::CTRL+Qt::Key_Delete, 0, 0, 0, KShortcut(), false }, - { Find, I18N_NOOP("Find"), 0, Qt::CTRL+Qt::Key_F, 0, 0, 0, KShortcut(), false }, - { FindNext, "FindNext", I18N_NOOP("Find Next"), Qt::Key_F3, 0, 0, 0, KShortcut(), false }, - { FindPrev, "FindPrev", I18N_NOOP("Find Prev"), Qt::SHIFT+Qt::Key_F3, 0, 0, 0, KShortcut(), false }, - { Replace, I18N_NOOP("Replace"), 0, Qt::CTRL+Qt::Key_R, 0, 0, 0, KShortcut(), false }, - {AccelNone, "Group:Navigation", I18N_NOOP("Navigation"), 0, 0, 0, 0, KShortcut(), false }, - { Home, I18N_NOOP2("Opposite to End","Home"), 0, Qt::CTRL+Qt::Key_Home, 0, Qt::Key_HomePage, 0, KShortcut(), false }, - { End, I18N_NOOP("End"), 0, Qt::CTRL+Qt::Key_End, 0, 0, 0, KShortcut(), false }, - { BeginningOfLine, "BeginningOfLine", I18N_NOOP("Beginning of Line"), Qt::Key_Home, 0, 0, 0, KShortcut(), false}, - { EndOfLine, "EndOfLine", I18N_NOOP("End of Line"), Qt::Key_End, 0, 0, 0, KShortcut(), false}, - { Prior, I18N_NOOP("Prior"), 0, TQt::Key_Prior, 0, 0, 0, KShortcut(), false }, - { Next, I18N_NOOP2("Opposite to Prior","Next"), 0, TQt::Key_Next, 0, 0, 0, KShortcut(), false }, - { GotoLine, "GotoLine", I18N_NOOP("Go to Line"), Qt::CTRL+Qt::Key_G, 0, 0, 0, KShortcut(), false }, - { AddBookmark, "AddBookmark", I18N_NOOP("Add Bookmark"), Qt::CTRL+Qt::Key_B, 0, 0, 0, KShortcut(), false }, - { ZoomIn, "ZoomIn", I18N_NOOP("Zoom In"), Qt::CTRL+Qt::Key_Plus, 0, 0, 0, KShortcut(), false }, - { ZoomOut, "ZoomOut", I18N_NOOP("Zoom Out"), Qt::CTRL+Qt::Key_Minus, 0, 0, 0, KShortcut(), false }, - { Up, I18N_NOOP("Up"), 0, Qt::ALT+Qt::Key_Up, 0, 0, 0, KShortcut(), false }, - { Back, I18N_NOOP("Back"), 0, Qt::ALT+Qt::Key_Left, 0, Qt::Key_Back, 0, KShortcut(), false }, - { Forward, I18N_NOOP("Forward"), 0, Qt::ALT+Qt::Key_Right, 0, Qt::Key_Forward, 0, KShortcut(), false }, - { Reload, I18N_NOOP("Reload"), 0, Qt::Key_F5, 0, Qt::Key_Refresh, 0, KShortcut(), false }, - { PopupMenuContext, "PopupMenuContext", I18N_NOOP("Popup Menu Context"), Qt::Key_Menu, 0, 0, 0, KShortcut(), false }, - { ShowMenubar, "ShowMenubar", I18N_NOOP("Show Menu Bar"), Qt::CTRL+Qt::Key_M, 0, 0, 0, KShortcut(), false }, - { BackwardWord, "BackwardWord", I18N_NOOP("Backward Word"), Qt::CTRL+Qt::Key_Left, 0, 0, 0, KShortcut(), false }, - { ForwardWord, "ForwardWord", I18N_NOOP("Forward Word"), Qt::CTRL+Qt::Key_Right, 0, 0, 0, KShortcut(), false }, - { TabNext, I18N_NOOP("Activate Next Tab"), 0, Qt::CTRL+Qt::Key_Period, 0, Qt::CTRL+Qt::Key_BracketRight, 0, KShortcut(), false }, - { TabPrev, I18N_NOOP("Activate Previous Tab"), 0, Qt::CTRL+Qt::Key_Comma, 0, Qt::CTRL+Qt::Key_BracketLeft, 0, KShortcut(), false }, - { FullScreen, "FullScreen", I18N_NOOP("Full Screen Mode"), Qt::CTRL+Qt::SHIFT+Qt::Key_F, 0, 0, 0, KShortcut(), false }, - {AccelNone, "Group:Help", I18N_NOOP("Help"), 0, 0, 0, 0, KShortcut(), false }, - { Help, I18N_NOOP("Help"), 0, Qt::Key_F1, 0, 0, 0, KShortcut(), false }, - { WhatsThis, "WhatsThis", I18N_NOOP("What's This"), Qt::SHIFT+Qt::Key_F1, 0, 0, 0, KShortcut(), false }, - {AccelNone, "Group:TextCompletion", I18N_NOOP("Text Completion"), 0, 0, 0, 0, KShortcut(), false }, - { TextCompletion, "TextCompletion", I18N_NOOP("Text Completion"), Qt::CTRL+Qt::Key_E, 0, 0, 0, KShortcut(), false }, - { PrevCompletion, "PrevCompletion", I18N_NOOP("Previous Completion Match"), Qt::CTRL+Qt::Key_Up, 0, 0, 0, KShortcut(), false }, - { NextCompletion, "NextCompletion", I18N_NOOP("Next Completion Match"), Qt::CTRL+Qt::Key_Down, 0, 0, 0, KShortcut(), false }, - { SubstringCompletion, "SubstringCompletion", I18N_NOOP("Substring Completion"), Qt::CTRL+Qt::Key_T, 0, 0, 0, KShortcut(), false }, - { RotateUp, "RotateUp", I18N_NOOP("Previous Item in List"), Qt::Key_Up, 0, 0, 0, KShortcut(), false }, - { RotateDown, "RotateDown", I18N_NOOP("Next Item in List"), Qt::Key_Down, 0, 0, 0, KShortcut(), false }, - { AccelNone, 0, 0, 0, 0, 0, 0, KShortcut(), false } -}; - -/** Search for the KStdAccelInfo object associated with the given @p id. */ -static KStdAccelInfo* infoPtr( StdAccel id ) -{ - if( id != AccelNone ) { - // Linear search. Changing the data structure doesn't seem possible - // (since we need groups for the config stuff), but maybe a little - // additional hashtable wouldn't hurt. - for( uint i = 0; g_infoStdAccel[i].psName != 0; i++ ) { - if( g_infoStdAccel[i].id == id ) - return &g_infoStdAccel[i]; - } - } - return 0; -} - -/** Initialize the accelerator @p id by checking if it is overridden - in the configuration file (and if it isn't, use the default). -*/ -static void initialize( StdAccel id ) -{ - KConfigGroupSaver saver( KGlobal::config(), "Shortcuts" ); - KStdAccelInfo* pInfo = infoPtr( id ); - - if( !pInfo ) { - kdWarning(125) << "KStdAccel: id not found!" << endl; // -- ellis - return; - } - - if( saver.config()->hasKey( pInfo->psName ) ) { - TQString s = saver.config()->readEntry( pInfo->psName ); - if( s != "none" ) - pInfo->cut.init( s ); - else - pInfo->cut.clear(); - } else - pInfo->cut = shortcutDefault( id ); - pInfo->bInitialized = true; -} - -TQString name( StdAccel id ) -{ - KStdAccelInfo* pInfo = infoPtr( id ); - if( !pInfo ) - return TQString::null; - return pInfo->psName; -} - -TQString label( StdAccel id ) -{ - KStdAccelInfo* pInfo = infoPtr( id ); - if( !pInfo ) - return TQString::null; - return i18n((pInfo->psDesc) ? pInfo->psDesc : pInfo->psName); -} - -// TODO: Add psWhatsThis entry to KStdAccelInfo -TQString whatsThis( StdAccel /*id*/ ) -{ -// KStdAccelInfo* pInfo = infoPtr( id ); -// if( pInfo && pInfo->psWhatsThis ) -// return i18n(pInfo->psWhatsThis); -// else - return TQString::null; -} - -const KShortcut& shortcut( StdAccel id ) -{ - KStdAccelInfo* pInfo = infoPtr( id ); - if( !pInfo ) - return KShortcut::null(); - - if( !pInfo->bInitialized ) - initialize( id ); - - return pInfo->cut; -} - -StdAccel findStdAccel( const KKeySequence& seq ) -{ - if( !seq.isNull() ) { - for( uint i = 0; g_infoStdAccel[i].psName != 0; i++ ) { - StdAccel id = g_infoStdAccel[i].id; - if( id != AccelNone ) { - if( !g_infoStdAccel[i].bInitialized ) - initialize( id ); - if( g_infoStdAccel[i].cut.contains( seq ) ) - return id; - } - } - } - return AccelNone; -} - -KShortcut shortcutDefault( StdAccel id ) -{ - return (KAccelAction::useFourModifierKeys()) - ? shortcutDefault4(id) : shortcutDefault3(id); -} - -KShortcut shortcutDefault3( StdAccel id ) -{ - KShortcut cut; - - KStdAccelInfo* pInfo = infoPtr( id ); - if( pInfo ) { - if( pInfo->cutDefault ) - cut.init( pInfo->cutDefault ); - // FIXME: if there is no cutDefault, then this we be made the primary - // instead of alternate shortcut. - if( pInfo->cutDefault3B ) - cut.append( KKey(pInfo->cutDefault3B) ); - } - - return cut; -} - -KShortcut shortcutDefault4( StdAccel id ) -{ - KShortcut cut; - - KStdAccelInfo* pInfo = infoPtr( id ); - if( pInfo ) { - KStdAccelInfo& info = *pInfo; - KKeySequence key2; - - cut.init( (info.cutDefault4) ? - TQKeySequence(info.cutDefault) : TQKeySequence(info.cutDefault4) ); - - if( info.cutDefault4B ) - key2.init( TQKeySequence(info.cutDefault4B) ); - else if( info.cutDefault3B ) - key2.init( TQKeySequence(info.cutDefault3B) ); - - if( key2.count() ) - cut.append( key2 ); - } - - return cut; -} - -#if 0 // unused -void createAccelActions( KAccelActions& actions ) -{ - actions.clear(); - - for( uint i = 0; g_infoStdAccel[i].psName != 0; i++ ) { - StdAccel id = g_infoStdAccel[i].id; - KStdAccelInfo* pInfo = &g_infoStdAccel[i]; - - if( id != AccelNone ) { - actions.insert( pInfo->psName, - i18n((pInfo->psDesc) ? pInfo->psDesc : pInfo->psName), - TQString::null, // pInfo->psWhatsThis, - shortcutDefault3(id), - shortcutDefault4(id) ); - } else - actions.insert( pInfo->psName, i18n(pInfo->psDesc) ); - } -} -#endif - -const KShortcut& open() { return shortcut( Open ); } -const KShortcut& openNew() { return shortcut( New ); } -const KShortcut& close() { return shortcut( Close ); } -const KShortcut& save() { return shortcut( Save ); } -const KShortcut& print() { return shortcut( Print ); } -const KShortcut& quit() { return shortcut( Quit ); } -const KShortcut& cut() { return shortcut( Cut ); } -const KShortcut& copy() { return shortcut( Copy ); } -const KShortcut& paste() { return shortcut( Paste ); } -const KShortcut& pasteSelection() { return shortcut( PasteSelection ); } -const KShortcut& deleteWordBack() { return shortcut( DeleteWordBack ); } -const KShortcut& deleteWordForward() { return shortcut( DeleteWordForward ); } -const KShortcut& undo() { return shortcut( Undo ); } -const KShortcut& redo() { return shortcut( Redo ); } -const KShortcut& find() { return shortcut( Find ); } -const KShortcut& findNext() { return shortcut( FindNext ); } -const KShortcut& findPrev() { return shortcut( FindPrev ); } -const KShortcut& replace() { return shortcut( Replace ); } -const KShortcut& home() { return shortcut( Home ); } -const KShortcut& end() { return shortcut( End ); } -const KShortcut& beginningOfLine() { return shortcut( BeginningOfLine ); } -const KShortcut& endOfLine() { return shortcut( EndOfLine ); } -const KShortcut& prior() { return shortcut( Prior ); } -const KShortcut& next() { return shortcut( Next ); } -const KShortcut& backwardWord() { return shortcut( BackwardWord ); } -const KShortcut& forwardWord() { return shortcut( ForwardWord ); } -const KShortcut& gotoLine() { return shortcut( GotoLine ); } -const KShortcut& addBookmark() { return shortcut( AddBookmark ); } -const KShortcut& tabNext() { return shortcut( TabNext ); } -const KShortcut& tabPrev() { return shortcut( TabPrev ); } -const KShortcut& fullScreen() { return shortcut( FullScreen ); } -const KShortcut& zoomIn() { return shortcut( ZoomIn ); } -const KShortcut& zoomOut() { return shortcut( ZoomOut ); } -const KShortcut& help() { return shortcut( Help ); } -const KShortcut& completion() { return shortcut( TextCompletion ); } -const KShortcut& prevCompletion() { return shortcut( PrevCompletion ); } -const KShortcut& nextCompletion() { return shortcut( NextCompletion ); } -const KShortcut& rotateUp() { return shortcut( RotateUp ); } -const KShortcut& rotateDown() { return shortcut( RotateDown ); } -const KShortcut& substringCompletion() { return shortcut( SubstringCompletion ); } -const KShortcut& popupMenuContext() { return shortcut( PopupMenuContext ); } -const KShortcut& whatsThis() { return shortcut( WhatsThis ); } -const KShortcut& reload() { return shortcut( Reload ); } -const KShortcut& selectAll() { return shortcut( SelectAll ); } -const KShortcut& up() { return shortcut( Up ); } -const KShortcut& back() { return shortcut( Back ); } -const KShortcut& forward() { return shortcut( Forward ); } -const KShortcut& showMenubar() { return shortcut( ShowMenubar ); } - -//--------------------------------------------------------------------- -// ShortcutList -//--------------------------------------------------------------------- - -ShortcutList::ShortcutList() - { } - -ShortcutList::~ShortcutList() - { } - -uint ShortcutList::count() const -{ - static uint g_nAccels = 0; - if( g_nAccels == 0 ) { - for( ; g_infoStdAccel[g_nAccels].psName != 0; g_nAccels++ ) - ; - } - return g_nAccels; -} - -TQString ShortcutList::name( uint i ) const - { return g_infoStdAccel[i].psName; } - -TQString ShortcutList::label( uint i ) const - { return i18n((g_infoStdAccel[i].psDesc) ? g_infoStdAccel[i].psDesc : g_infoStdAccel[i].psName); } - -TQString ShortcutList::whatsThis( uint ) const - { return TQString::null; } - -const KShortcut& ShortcutList::shortcut( uint i ) const -{ - if( !g_infoStdAccel[i].bInitialized ) - initialize( g_infoStdAccel[i].id ); - return g_infoStdAccel[i].cut; -} - -const KShortcut& ShortcutList::shortcutDefault( uint i ) const -{ - static KShortcut cut; - cut = KStdAccel::shortcutDefault( g_infoStdAccel[i].id ); - return cut; -} - -bool ShortcutList::isConfigurable( uint i ) const - { return (g_infoStdAccel[i].id != AccelNone); } - -bool ShortcutList::setShortcut( uint i, const KShortcut& cut ) - { g_infoStdAccel[i].cut = cut; return true; } - -TQVariant ShortcutList::getOther( Other, uint ) const - { return TQVariant(); } - -bool ShortcutList::setOther( Other, uint, TQVariant ) - { return false; } - -bool ShortcutList::save() const -{ - return writeSettings( TQString::null, 0, false, true ); -} - -KDECORE_EXPORT TQString action(StdAccel id) - { return name(id); } -KDECORE_EXPORT TQString description(StdAccel id) - { return label(id); } -KDECORE_EXPORT int key(StdAccel id) - { return shortcut(id).keyCodeQt(); } -KDECORE_EXPORT int defaultKey(StdAccel id) - { return shortcutDefault(id).keyCodeQt(); } - -KDECORE_EXPORT bool isEqual(const TQKeyEvent* ev, int keyQt) -{ - KKey key1( ev ), key2( keyQt ); - return key1 == key2; -} - -} - -#undef __KSTDACCEL_CPP_ diff --git a/kdecore/kstdaccel.h b/kdecore/kstdaccel.h deleted file mode 100644 index 9f379b210..000000000 --- a/kdecore/kstdaccel.h +++ /dev/null @@ -1,492 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Stefan Taferner (taferner@kde.org) - Copyright (C) 2000 Nicolas Hadacek (hadacek@kde.org) - Copyright (C) 2001,2002 Ellis Whitehead (ellis@kde.org) - - 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 KSTDACCEL_H -#define KSTDACCEL_H - -#include <tqstring.h> -#include <kshortcut.h> -#include "kdelibs_export.h" - -class TQKeyEvent; -class KAccelActions; - -/** - * \namespace KStdAccel - * Convenient methods for access to the common accelerator keys in - * the key configuration. These are the standard keybindings that should - * be used in all KDE applications. They will be configurable, - * so do not hardcode the default behavior. - * - * If you want real configurable keybindings in your applications, - * please checkout the class KAccel in kaccel.h - * @see KAccelShortcutList - */ -namespace KStdAccel -{ - // Always add new std-accels to the end of this enum, never in the middle! - /** - * Defines the identifier of all standard accelerators. - */ - enum StdAccel { - AccelNone, - // File menu - Open, New, Close, Save, - // The Print item - Print, - Quit, - // Edit menu - Undo, Redo, Cut, Copy, Paste, SelectAll, Deselect, DeleteWordBack, - DeleteWordForward, Find, FindNext, FindPrev, Replace, - // Navigation - Home, End, Prior, Next, GotoLine, AddBookmark, ZoomIn, ZoomOut, - Up, Back, Forward, Reload, PopupMenuContext, ShowMenubar, - // Help menu - Help, WhatsThis, - // Text completion - TextCompletion, PrevCompletion, NextCompletion, SubstringCompletion, - RotateUp, RotateDown, - - // Tabular navigation - TabNext, ///< @since 3.2 - TabPrev, ///< @since 3.2 - - // Full screen mode - FullScreen, ///< @since 3.2 - - // Text Navigation - BackwardWord, ///< @since 3.3 - ForwardWord, ///< @since 3.3 - BeginningOfLine, ///< @since 3.3 - EndOfLine, ///< @since 3.3 - - PasteSelection ///< @since 3.4 - -#ifndef KDE_NO_COMPAT - , WhatThis = WhatsThis -#endif - }; - - /** - * Returns the keybinding for @p accel. - * @param id the id of the accelerator - */ - KDECORE_EXPORT const KShortcut& shortcut(StdAccel id); - - /** - * Returns a unique name for the given accel. - * @param id the id of the accelerator - * @return the unique name of the accelerator - */ - KDECORE_EXPORT TQString name(StdAccel id); - - /** - * Returns a localized label for user-visible display. - * @param id the id of the accelerator - * @return a localized label for the accelerator - */ - KDECORE_EXPORT TQString label(StdAccel id); - - /** - * Returns an extended WhatsThis description for the given accelerator. - * @param id the id of the accelerator - * @return a localized description of the accelerator - */ - KDECORE_EXPORT TQString whatsThis(StdAccel id); - - /** - * Return the StdAccel id of the standard accel action which - * uses this key sequence, or AccelNone if none of them do. - * This is used by class KKeyChooser. - * @param keySeq the key sequence to search - * @return the id of the standard accelerator, or AccelNone if there - * is none - */ - KDECORE_EXPORT StdAccel findStdAccel( const KKeySequence &keySeq ); - - /** - * Returns the hardcoded default shortcut for @p id. - * This does not take into account the user's configuration. - * @param id the id of the accelerator - * @return the default shortcut of the accelerator - */ - KDECORE_EXPORT KShortcut shortcutDefault(StdAccel id); - /** - * Returns the hardcoded default 3 modifier shortcut for @p id. - * This does not take into account the user's configuration. - * @param id the id of the accelerator - * @return the default 3 modifier shortcut - */ - KDECORE_EXPORT KShortcut shortcutDefault3(StdAccel id); - /** - * Returns the hardcoded default 4 modifier shortcut for @p id. - * This does not take into account the user's configuration. - * @param id the id of the accelerator - * @return the default 4 modifier shortcut - */ - KDECORE_EXPORT KShortcut shortcutDefault4(StdAccel id); - - /** - * Open file. Default: Ctrl-o - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& open(); - - /** - * Create a new document (or whatever). Default: Ctrl-n - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& openNew(); - - /** - * Close current document. Default: Ctrl-w - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& close(); - - /** - * Save current document. Default: Ctrl-s - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& save(); - - /** - * Print current document. Default: Ctrl-p - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& print(); - - /** - * Quit the program. Default: Ctrl-q - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& quit(); - - /** - * Undo last operation. Default: Ctrl-z - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& undo(); - - /** - * Redo. Default: Shift-Ctrl-z - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& redo(); - - /** - * Cut selected area and store it in the clipboard. Default: Ctrl-x - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& cut(); - - /** - * Copy selected area into the clipboard. Default: Ctrl-c - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& copy(); - - /** - * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& paste(); - - /** - * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert - * @return the shortcut of the standard accelerator - * @since 3.4 - */ - KDECORE_EXPORT const KShortcut& pasteSelection(); - - /** - * Reload. Default: Ctrl-A - * @return the shortcut of the standard accelerator - **/ - KDECORE_EXPORT const KShortcut& selectAll(); - - /** - * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& deleteWordBack(); - - /** - * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& deleteWordForward(); - - /** - * Find, search. Default: Ctrl-f - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& find(); - - /** - * Find/search next. Default: F3 - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& findNext(); - - /** - * Find/search previous. Default: Shift-F3 - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& findPrev(); - - /** - * Find and replace matches. Default: Ctrl-r - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& replace(); - - /** - * Zoom in. Default: Ctrl-Plus - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& zoomIn(); - - /** - * Zoom out. Default: Ctrl-Minus - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& zoomOut(); - - /** - * Toggle insert/overwrite (with visual feedback, e.g. in the statusbar). Default: Insert - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& insert(); - - /** - * Goto beginning of the document. Default: Ctrl-Home - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& home(); - - /** - * Goto end of the document. Default: Ctrl-End - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& end(); - - /** - * Goto beginning of current line. Default: Home - * @return the shortcut of the standard accelerator - * @since 3.3 - */ - KDECORE_EXPORT const KShortcut& beginningOfLine(); - - /** - * Goto end of current line. Default: End - * @return the shortcut of the standard accelerator - * @since 3.3 - */ - KDECORE_EXPORT const KShortcut& endOfLine(); - - /** - * Scroll up one page. Default: Prior - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& prior(); - - /** - * Scroll down one page. Default: Next - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& next(); - - /** - * Go to line. Default: Ctrl+G - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& gotoLine(); - - /** - * Add current page to bookmarks. Default: Ctrl+B - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& addBookmark(); - - /** - * Next Tab. Default: Ctrl-< - * @return the shortcut of the standard accelerator - * @since 3.2 - */ - KDECORE_EXPORT const KShortcut& tabNext(); - - /** - * Previous Tab. Default: Ctrl-> - * @return the shortcut of the standard accelerator - * @since 3.2 - */ - KDECORE_EXPORT const KShortcut& tabPrev(); - - /** - * Full Screen Mode. Default: Ctrl+Shift+F - * @return the shortcut of the standard accelerator - * @since 3.2 - */ - KDECORE_EXPORT const KShortcut& fullScreen(); - - /** - * Help the user in the current situation. Default: F1 - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& help(); - - /** - * Complete text in input widgets. Default Ctrl+E - * @return the shortcut of the standard accelerator - **/ - KDECORE_EXPORT const KShortcut& completion(); - - /** - * Iterate through a list when completion returns - * multiple items. Default: Ctrl+Up - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& prevCompletion(); - - /** - * Iterate through a list when completion returns - * multiple items. Default: Ctrl+Down - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& nextCompletion(); - - /** - * Find a string within another string or list of strings. - * Default: Ctrl-T - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& substringCompletion(); - - /** - * Help users iterate through a list of entries. Default: Up - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& rotateUp(); - - /** - * Help users iterate through a list of entries. Default: Down - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& rotateDown(); - - /** - * popup a context menu. Default: Menu - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& popupMenuContext(); - - /** - * What's This button. Default: Shift+F1 - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& whatsThis(); - - /** - * Reload. Default: F5 - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& reload(); - - /** - * Up. Default: Alt+Up - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& up(); - - /** - * Back. Default: Alt+Left - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& back(); - - /** - * Forward. Default: ALT+Right - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& forward(); - - /** - * BackwardWord. Default: Ctrl+Left - * @return the shortcut of the standard accelerator - * @since 3.3 - */ - KDECORE_EXPORT const KShortcut& backwardWord(); - - /** - * ForwardWord. Default: Ctrl+Right - * @return the shortcut of the standard accelerator - * @since 3.3 - */ - KDECORE_EXPORT const KShortcut& forwardWord(); - - /** - * Show Menu Bar. Default: Ctrl-M - * @return the shortcut of the standard accelerator - */ - KDECORE_EXPORT const KShortcut& showMenubar(); - -#if !defined(KDE_NO_COMPAT) && !defined(__KSTDACCEL_CPP_) - /** - * @deprecated - * Obsolete. Use name(). Returns a string representation for @p accel. - */ - KDECORE_EXPORT TQString action(StdAccel id) KDE_DEPRECATED; - /** - * @deprecated - * Obsolete. Use desc(). Returns a localized description of @p accel. - */ - KDECORE_EXPORT TQString description(StdAccel id) KDE_DEPRECATED; - /** - * @deprecated - * Obsolete. Use shortcut(). Returns the keybinding for @p accel. - */ - KDECORE_EXPORT int key(StdAccel) KDE_DEPRECATED; - /** - * @deprecated - * Obsolete. Use shortcutDefault(). - */ - KDECORE_EXPORT int defaultKey(StdAccel accel) KDE_DEPRECATED; - - /** - * @deprecated. Use KKey(const TQKeyEvent*) == KKey(int). - * - * Compare the keys generated by the key event with - * the value of the integer. - * - * If a modifier (Shift, Alt, Ctrl) key is present in - * TQKeyEvent, its sum with the actual key value - * is used for comparing it with the integer parameter. - * - * @param pEvent the key event to be used in the comparison. - * @param keyQt the int value to be compared to the key event. - * - * @return true if the int value matches the integer representation of the QKeyEvent - */ - KDECORE_EXPORT bool isEqual(const TQKeyEvent* pEvent, int keyQt) KDE_DEPRECATED; -#endif // !KDE_NO_COMPAT - -} - -#endif diff --git a/kdecore/kstddirs.h b/kdecore/kstddirs.h deleted file mode 100644 index a009a750d..000000000 --- a/kdecore/kstddirs.h +++ /dev/null @@ -1,6 +0,0 @@ -// kstddirs.h is the old name, use #include <kstandarddirs.h> from now on -#ifdef KDE_NO_COMPAT -#error kstddirs.h is the old name, use #include <kstandarddirs.h> from now on -#else -#include <kstandarddirs.h> -#endif diff --git a/kdecore/kstringhandler.cpp b/kdecore/kstringhandler.cpp deleted file mode 100644 index dfabb49ea..000000000 --- a/kdecore/kstringhandler.cpp +++ /dev/null @@ -1,663 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Ian Zepp (icszepp@islc.net) - - 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. -*/ - -#include "kstringhandler.h" -#include "kglobal.h" - -static void parsePythonRange( const TQCString &range, uint &start, uint &end ) -{ - const int colon = range.find( ':' ); - if ( colon == -1 ) { - start = range.toUInt(); - end = start; - } else if ( colon == int( range.length() - 1 ) ) { - start = range.left( colon ).toUInt(); - } else if ( colon == 0 ) { - end = range.mid( 1 ).toUInt(); - } else { - start = range.left( colon ).toInt(); - end = range.mid( colon + 1 ).toInt(); - } -} - -TQString KStringHandler::word( const TQString &text , uint pos ) -{ - return text.section( ' ', pos, pos ); -} - -TQString KStringHandler::word( const TQString &text , const char *range ) -{ - // Format in: START:END - // Note index starts a 0 (zero) - // - // 0: first word to end - // 1:3 second to fourth words - TQStringList list = TQStringList::split( " ", text , true ); - TQString tmp = ""; - TQString r = range; - - if ( text.isEmpty() ) - return tmp; - - uint pos = 0, cnt = list.count(); - parsePythonRange( range, pos, cnt ); - - // - // Extract words - // - int wordsToExtract = cnt-pos+1; - TQStringList::Iterator it = list.tqat( pos); - - while ( (it != list.end()) && (wordsToExtract-- > 0)) - { - tmp += *it; - tmp += " "; - it++; - } - - return tmp.stripWhiteSpace(); -} - -// -// Insertion and removal routines -// -TQString KStringHandler::insword( const TQString &text , const TQString &word , uint pos ) -{ - if ( text.isEmpty() ) - return word; - - if ( word.isEmpty() ) - return text; - - // Split words and add into list - TQStringList list = TQStringList::split( " ", text, true ); - - if ( pos >= list.count() ) - list.append( word ); - else - list.insert( list.tqat(pos) , word ); - - // Rejoin - return list.join( " " ); -} - -TQString KStringHandler::setword( const TQString &text , const TQString &word , uint pos ) -{ - if ( text.isEmpty() ) - return word; - - if ( word.isEmpty() ) - return text; - - // Split words and add into list - TQStringList list = TQStringList::split( " ", text, true ); - - if ( pos >= list.count() ) - list.append( word ); - else - { - list.insert( list.remove( list.tqat(pos) ) , word ); - } - - // Rejoin - return list.join( " " ); -} - -TQString KStringHandler::remrange( const TQString &text , const char *range ) -{ - // Format in: START:END - // Note index starts a 0 (zero) - // - // 0: first word to end - // 1:3 second to fourth words - TQStringList list = TQStringList::split( " ", text , true ); - TQString tmp = ""; - TQString r = range; - - if ( text.isEmpty() ) - return tmp; - - uint pos = 0, cnt = list.count(); - parsePythonRange( range, pos, cnt ); - - // - // Remove that range of words - // - int wordsToDelete = cnt-pos+1; - TQStringList::Iterator it = list.tqat( pos); - - while ( (it != list.end()) && (wordsToDelete-- > 0)) - it = list.remove( it ); - - return list.join( " " ); -} - -TQString KStringHandler::remword( const TQString &text , uint pos ) -{ - TQString tmp = ""; - - if ( text.isEmpty() ) - return tmp; - - // Split words and add into list - TQStringList list = TQStringList::split( " ", text, true ); - - if ( pos < list.count() ) - list.remove( list.tqat( pos ) ); - - // Rejoin - return list.join( " " ); -} - -TQString KStringHandler::remword( const TQString &text , const TQString &word ) -{ - TQString tmp = ""; - - if ( text.isEmpty() ) - return tmp; - - if ( word.isEmpty() ) - return text; - - // Split words and add into list - TQStringList list = TQStringList::split( " ", text, true ); - - TQStringList::Iterator it = list.find(word); - - if (it != list.end()) - list.remove( it ); - - // Rejoin - return list.join( " " ); -} - -// -// Capitalization routines -// -TQString KStringHandler::capwords( const TQString &text ) -{ - if ( text.isEmpty() ) { - return text; - } - - const TQString strippedText = text.stripWhiteSpace(); - const TQStringList words = capwords( TQStringList::split( ' ', strippedText ) ); - - TQString result = text; - result.replace( strippedText, words.join( " " ) ); - return result; -} - -TQStringList KStringHandler::capwords( const TQStringList &list ) -{ - TQStringList tmp = list; - for ( TQStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it ) { - *it = ( *it )[ 0 ].upper() + ( *it ).mid( 1 ); - } - return tmp; -} - -// -// Reverse routines -// -TQString KStringHandler::reverse( const TQString &text ) -{ - TQString tmp; - - if ( text.isEmpty() ) - return tmp; - - TQStringList list; - list = TQStringList::split( " ", text, true ); - list = reverse( list ); - - return list.join( " " ); -} - -TQStringList KStringHandler::reverse( const TQStringList &list ) -{ - TQStringList tmp; - - if ( list.count() == 0 ) - return tmp; - - for ( TQStringList::ConstIterator it= list.begin(); - it != list.end(); - it++) - tmp.prepend( *it ); - - return tmp; -} - -// -// Left, Right, Center justification -// -TQString KStringHandler::ljust( const TQString &text , uint width ) -{ - return text.stripWhiteSpace().leftJustify( width ); -} - -TQString KStringHandler::rjust( const TQString &text , uint width ) -{ - return text.stripWhiteSpace().rightJustify( width ); -} - -TQString KStringHandler::center( const TQString &text , uint width ) -{ - const TQString s = text.stripWhiteSpace(); - const unsigned int length = s.length(); - if ( width <= length ) { - return s; - } - - TQString result; - result.fill( ' ', ( width - length ) / 2 ); - result += s; - - return result.leftJustify( width ); -} - -TQString KStringHandler::lsqueeze( const TQString & str, uint maxlen ) -{ - if (str.length() > maxlen) { - int part = maxlen-3; - return TQString("..." + str.right(part)); - } - else return str; -} - -TQString KStringHandler::csqueeze( const TQString & str, uint maxlen ) -{ - if (str.length() > maxlen && maxlen > 3) { - int part = (maxlen-3)/2; - return TQString(str.left(part) + "..." + str.right(part)); - } - else return str; -} - -TQString KStringHandler::rsqueeze( const TQString & str, uint maxlen ) -{ - if (str.length() > maxlen) { - int part = maxlen-3; - return TQString(str.left(part) + "..."); - } - else return str; -} - -TQString KStringHandler::lEmSqueeze(const TQString &name, const TQFontMetrics& fontMetrics, uint maxlen) -{ - return lPixelSqueeze(name, fontMetrics, fontMetrics.maxWidth() * maxlen); -} - -TQString KStringHandler::lPixelSqueeze(const TQString& name, const TQFontMetrics& fontMetrics, uint maxPixels) -{ - uint nameWidth = fontMetrics.width(name); - - if (maxPixels < nameWidth) - { - TQString tmp = name; - const uint em = fontMetrics.maxWidth(); - maxPixels -= fontMetrics.width("..."); - - while (maxPixels < nameWidth && !tmp.isEmpty()) - { - int delta = (nameWidth - maxPixels) / em; - delta = kClamp(delta, 1, delta); // no max - - tmp.remove(0, delta); - nameWidth = fontMetrics.width(tmp); - } - - return ("..." + tmp); - } - - return name; -} - -TQString KStringHandler::cEmSqueeze(const TQString& name, const TQFontMetrics& fontMetrics, uint maxlen) -{ - return cPixelSqueeze(name, fontMetrics, fontMetrics.maxWidth() * maxlen); -} - -TQString KStringHandler::cPixelSqueeze(const TQString& s, const TQFontMetrics& fm, uint width) -{ - if ( s.isEmpty() || uint( fm.width( s ) ) <= width ) { - return s; - } - - const unsigned int length = s.length(); - if ( length == 2 ) { - return s; - } - - const int maxWidth = width - fm.width( '.' ) * 3; - if ( maxWidth <= 0 ) { - return "..."; - } - - unsigned int leftIdx = 0, rightIdx = length; - unsigned int leftWidth = fm.charWidth( s, leftIdx++ ); - unsigned int rightWidth = fm.charWidth( s, --rightIdx ); - while ( leftWidth + rightWidth < uint( maxWidth ) ) { - while ( leftWidth <= rightWidth && leftWidth + rightWidth < uint( maxWidth ) ) { - leftWidth += fm.charWidth( s, leftIdx++ ); - } - while ( rightWidth <= leftWidth && leftWidth + rightWidth < uint( maxWidth ) ) { - rightWidth += fm.charWidth( s, --rightIdx ); - } - } - - if ( leftWidth > rightWidth ) { - --leftIdx; - } else { - ++rightIdx; - } - - rightIdx = length - rightIdx; - if ( leftIdx == 0 && rightIdx == 1 || leftIdx == 1 && rightIdx == 0 ) { - return "..."; - } - - return s.left( leftIdx ) + "..." + s.right( rightIdx ); -} - -TQString KStringHandler::rEmSqueeze(const TQString& name, const TQFontMetrics& fontMetrics, uint maxlen) -{ - return rPixelSqueeze(name, fontMetrics, fontMetrics.maxWidth() * maxlen); -} - -TQString KStringHandler::rPixelSqueeze(const TQString& name, const TQFontMetrics& fontMetrics, uint maxPixels) -{ - uint nameWidth = fontMetrics.width(name); - - if (maxPixels < nameWidth) - { - TQString tmp = name; - const uint em = fontMetrics.maxWidth(); - maxPixels -= fontMetrics.width("..."); - - while (maxPixels < nameWidth && !tmp.isEmpty()) - { - int length = tmp.length(); - int delta = em ? (nameWidth - maxPixels) / em : length; - delta = kClamp(delta, 1, length) ; - - tmp.remove(length - delta, delta); - nameWidth = fontMetrics.width(tmp); - } - - return (tmp + "..."); - } - - return name; -} - -///// File name patterns (like *.txt) - -bool KStringHandler::matchFileName( const TQString& filename, const TQString& pattern ) -{ - int len = filename.length(); - int pattern_len = pattern.length(); - - if (!pattern_len) - return false; - - // Patterns like "Makefile*" - if ( pattern[ pattern_len - 1 ] == (QChar)'*' && len + 1 >= pattern_len ) { - if ( pattern[ 0 ] == (QChar)'*' ) - { - return filename.find(pattern.mid(1, pattern_len - 2)) != -1; - } - - const TQChar *c1 = pattern.tqunicode(); - const TQChar *c2 = filename.tqunicode(); - int cnt = 1; - while ( cnt < pattern_len && *c1++ == *c2++ ) - ++cnt; - return cnt == pattern_len; - } - - // Patterns like "*~", "*.extension" - if ( pattern[ 0 ] == (QChar)'*' && len + 1 >= pattern_len ) - { - const TQChar *c1 = pattern.tqunicode() + pattern_len - 1; - const TQChar *c2 = filename.tqunicode() + len - 1; - int cnt = 1; - while ( cnt < pattern_len && *c1-- == *c2-- ) - ++cnt; - return cnt == pattern_len; - } - - // Patterns like "Makefile" - return ( filename == pattern ); -} - - TQStringList -KStringHandler::perlSplit(const TQString & sep, const TQString & s, uint max) -{ - bool ignoreMax = 0 == max; - - TQStringList l; - - int searchStart = 0; - - int tokenStart = s.find(sep, searchStart); - - while (-1 != tokenStart && (ignoreMax || l.count() < max - 1)) - { - if (!s.mid(searchStart, tokenStart - searchStart).isEmpty()) - l << s.mid(searchStart, tokenStart - searchStart); - - searchStart = tokenStart + sep.length(); - tokenStart = s.find(sep, searchStart); - } - - if (!s.mid(searchStart, s.length() - searchStart).isEmpty()) - l << s.mid(searchStart, s.length() - searchStart); - - return l; -} - - TQStringList -KStringHandler::perlSplit(const TQChar & sep, const TQString & s, uint max) -{ - bool ignoreMax = 0 == max; - - TQStringList l; - - int searchStart = 0; - - int tokenStart = s.find(sep, searchStart); - - while (-1 != tokenStart && (ignoreMax || l.count() < max - 1)) - { - if (!s.mid(searchStart, tokenStart - searchStart).isEmpty()) - l << s.mid(searchStart, tokenStart - searchStart); - - searchStart = tokenStart + 1; - tokenStart = s.find(sep, searchStart); - } - - if (!s.mid(searchStart, s.length() - searchStart).isEmpty()) - l << s.mid(searchStart, s.length() - searchStart); - - return l; -} - - TQStringList -KStringHandler::perlSplit(const TQRegExp & sep, const TQString & s, uint max) -{ - bool ignoreMax = 0 == max; - - TQStringList l; - - int searchStart = 0; - int tokenStart = sep.search(s, searchStart); - int len = sep.matchedLength(); - - while (-1 != tokenStart && (ignoreMax || l.count() < max - 1)) - { - if (!s.mid(searchStart, tokenStart - searchStart).isEmpty()) - l << s.mid(searchStart, tokenStart - searchStart); - - searchStart = tokenStart + len; - tokenStart = sep.search(s, searchStart); - len = sep.matchedLength(); - } - - if (!s.mid(searchStart, s.length() - searchStart).isEmpty()) - l << s.mid(searchStart, s.length() - searchStart); - - return l; -} - -TQString -KStringHandler::tagURLs( const TQString& text ) -{ - /*static*/ TQRegExp urlEx("(www\\.(?!\\.)|(fish|(f|ht)tp(|s))://)[\\d\\w\\./,:_~\\?=&;#@\\-\\+\\%\\$]+[\\d\\w/]"); - - TQString richText( text ); - int urlPos = 0, urlLen; - while ((urlPos = urlEx.search(richText, urlPos)) >= 0) - { - urlLen = urlEx.matchedLength(); - TQString href = richText.mid( urlPos, urlLen ); - // Qt doesn't support (?<=pattern) so we do it here - if((urlPos > 0) && richText[urlPos-1].isLetterOrNumber()){ - urlPos++; - continue; - } - // Don't use TQString::arg since %01, %20, etc could be in the string - TQString anchor = "<a href=\"" + href + "\">" + href + "</a>"; - richText.replace( urlPos, urlLen, anchor ); - - - urlPos += anchor.length(); - } - return richText; -} - -TQString KStringHandler::obscure( const TQString &str ) -{ - TQString result; - const TQChar *tqunicode = str.tqunicode(); - for ( uint i = 0; i < str.length(); ++i ) - result += ( tqunicode[ i ].tqunicode() < 0x21 ) ? tqunicode[ i ] : - TQChar( 0x1001F - tqunicode[ i ].tqunicode() ); - - return result; -} - -bool KStringHandler::isUtf8(const char *buf) -{ - int i, n; - register unsigned char c; - bool gotone = false; - - if (!buf) - return true; // whatever, just don't crash - -#define F 0 /* character never appears in text */ -#define T 1 /* character appears in plain ASCII text */ -#define I 2 /* character appears in ISO-8859 text */ -#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */ - - static const unsigned char text_chars[256] = { - /* BEL BS HT LF FF CR */ - F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */ - /* ESC */ - F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */ - /* NEL */ - X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */ - X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */ - }; - - /* *ulen = 0; */ - for (i = 0; (c = buf[i]); i++) { - if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */ - /* - * Even if the whole file is valid UTF-8 sequences, - * still reject it if it uses weird control characters. - */ - - if (text_chars[c] != T) - return false; - - } else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */ - return false; - } else { /* 11xxxxxx begins UTF-8 */ - int following; - - if ((c & 0x20) == 0) { /* 110xxxxx */ - following = 1; - } else if ((c & 0x10) == 0) { /* 1110xxxx */ - following = 2; - } else if ((c & 0x08) == 0) { /* 11110xxx */ - following = 3; - } else if ((c & 0x04) == 0) { /* 111110xx */ - following = 4; - } else if ((c & 0x02) == 0) { /* 1111110x */ - following = 5; - } else - return false; - - for (n = 0; n < following; n++) { - i++; - if (!(c = buf[i])) - goto done; - - if ((c & 0x80) == 0 || (c & 0x40)) - return false; - } - gotone = true; - } - } -done: - return gotone; /* don't claim it's UTF-8 if it's all 7-bit */ -} - -#undef F -#undef T -#undef I -#undef X - -TQString KStringHandler::from8Bit( const char *str ) -{ - if (!str) - return TQString::null; - if (!*str) { - static const TQString &emptyString = KGlobal::staticQString(""); - return emptyString; - } - return KStringHandler::isUtf8( str ) ? - TQString::fromUtf8( str ) : - TQString::fromLocal8Bit( str ); -} diff --git a/kdecore/kstringhandler.h b/kdecore/kstringhandler.h deleted file mode 100644 index 47075a066..000000000 --- a/kdecore/kstringhandler.h +++ /dev/null @@ -1,441 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Ian Zepp (icszepp@islc.net) - Copyright (C) 2000 Rik Hemsley (rikkus) <rik@kde.org> - - 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 KSTRINGHANDLER_H -#define KSTRINGHANDLER_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqregexp.h> // for the word ranges -#include <tqfontmetrics.h> -#include "kdelibs_export.h" - -/** - * This class contains utility functions for handling strings. - * - * This class is @em not a substitute for the TQString class. What - * I tried to do with this class is provide an easy way to - * cut/slice/splice words inside sentences in whatever order desired. - * While the main focus of this class are words (ie characters - * separated by spaces/tabs), the two core functions here ( split() - * and join() ) will function given any char to use as a separator. - * This will make it easy to redefine what a 'word' means in the - * future if needed. - * - * I freely stole some of the function names from python. I also think - * some of these were influenced by mIRC (yes, believe it if you will, I - * used to write a LOT of scripts in mIRC). - * - * The ranges are a fairly powerful way of getting/stripping words from - * a string. These ranges function, for the large part, as they would in - * python. See the word(const TQString&, const char *) and remword(const TQString&, uint) functions for more detail. - * - * This class contains no data members of its own. All strings are cut - * on the fly and returned as new qstrings/qstringlists. - * - * Quick example on how to use: - * - * \code - * KStringHandler kstr; - * TQString line = "This is a test of the strings"; - * - * cout << "1> " << kstr.word( line , "4:" ) << "\n"; - * cout << "2> " << kstr.remrange( line , "2:5" ) << "\n"; - * cout << "2> " << kstr.reverse( line ) << "\n"; - * cout << "2> " << kstr.center( kstr.word( line , 4 ) , 15 ) << "\n"; - * \endcode - * - * and so forth. - * - * @short Class for manipulating words and sentences in strings - * @author Ian Zepp <icszepp@islc.net> - * @see KShell - */ -class KDECORE_EXPORT KStringHandler -{ -public: - /** Returns the nth word in the string if found - * Returns a EMPTY (not null) string otherwise. - * Note that the FIRST index is 0. - * @param text the string to search for the words - * @param pos the position of the word to search - * @return the word, or an empty string if not found - * @deprecated use TQString::section instead - */ - static TQString word( const TQString &text , uint pos ) KDE_DEPRECATED; - - /** Returns a range of words from that string. - * Ie: - * @li "0" returns the very first word - * @li "0:" returns the first to the last word - * @li "0:3" returns the first to fourth words - * @li ":3" returns everything up to the fourth word - * - * If you grok python, you're set. - * @param text the string to search for the words - * @param range the words to return (see description) - * @return the words, or an empty string if not found - */ - static TQString word( const TQString &text , const char *range ); - - /** Inserts a word into the string, and returns - * a new string with the word included. the first - * index is zero (0). If there are not @p pos words in the original - * string, the new word will be appended to the end. - * @param text the original text - * @param word the word to insert - * @param pos the position (in words) for the new word - * @return the resulting string - */ - static TQString insword( const TQString &text , const TQString &word , uint pos ); - - /** Replaces a word in the string, and returns - * a new string with the word included. the first - * index is zero (0). If there are not @p pos words in the original - * string, the new word will be appended to the end. - * @param text the original text - * @param word the word to insert - * @param pos the position (in words) for the new word - * @return the resulting string - */ - static TQString setword( const TQString &text , const TQString &word , uint pos ); - - /** Removes a word or ranges of words from the string, - * and returns a new string. The ranges definitions - * follow the definitions for the word() function. - * - * @li "0" removes the very first word - * @li "0:" removes the first the the last word - * @li "0:3" removes the first to fourth words - * @li ":3" removes everything up to the fourth word - * @param text the original text - * @param range the words to remove (see description) - * @return the resulting string - */ - static TQString remrange( const TQString &text , const char *range ); - - - /** Removes a word at the given index, and returns a - * new string. The first index is zero (0). - * @param text the original text - * @param pos the position (in words) of thw word to delete - * @return the resulting string - */ - static TQString remword( const TQString &text , uint pos ); - - /** Removes a matching word from the string, and returns - * a new string. Note that only ONE match is removed. - * @param text the original text - * @param word the word to remove - * @return the resulting string - */ - static TQString remword( const TQString &text , const TQString &word ); - - /** Capitalizes each word in the string - * "hello there" becomes "Hello There" (string) - * @param text the text to capitalize - * @return the resulting string - */ - static TQString capwords( const TQString &text ); - - /** Capitalizes each word in the list - * [hello, there] becomes [Hello, There] (list) - * @param list the list to capitalize - * @return the resulting list - */ - static TQStringList capwords( const TQStringList &list ); - - /** Reverses the order of the words in a string - * "hello there" becomes "there hello" (string) - * @param text the text to reverse - * @return the resulting string - */ - static TQString reverse( const TQString &text ); - - /** Reverses the order of the words in a list - * [hello, there] becomes [there, hello] (list) - * @param list the list to reverse - * @return the resulting list - */ - static TQStringList reverse( const TQStringList &list ); - - /** Left-justifies a string and returns a string at least 'width' characters - * wide. - * If the string is longer than the @p width, the original - * string is returned. It is never truncated. - * @param text the text to justify - * @param width the desired width of the new string - * @return the resulting string - * @deprecated use TQString::leftJustify instead - */ - static TQString ljust( const TQString &text , uint width ) KDE_DEPRECATED; - - /** Right-justifies a string and returns a string at least 'width' characters - * wide. - * If the string is longer than the @p width, the original - * string is returned. It is never truncated. - * @param text the text to justify - * @param width the desired width of the new string - * @return the resulting string - * @deprecated use TQString::rightJustify instead - */ - static TQString rjust( const TQString &text , uint width ) KDE_DEPRECATED; - - /** Centers a string and returns a string at least 'width' characters - * wide. - * If the string is longer than the @p width, the original - * string is returned. It is never truncated. - * @param text the text to justify - * @param width the desired width of the new string - * @return the resulting string - */ - static TQString center( const TQString &text , uint width ); - - /** Substitute characters at the beginning of a string by "...". - * @param str is the string to modify - * @param maxlen is the maximum length the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - */ - static TQString lsqueeze( const TQString & str, uint maxlen = 40 ); - - /** Substitute characters at the beginning of a string by "...". Similar to - * method above, except that it truncates based on pixel width rather than - * the number of characters - * @param name is the string to modify - * @param fontMetrics is the font metrics to use to calculate character sizes - * @param maxlen is the maximum length in ems the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - * @since 3.2 - */ - static TQString lEmSqueeze( const TQString & name, - const TQFontMetrics& fontMetrics, - uint maxlen = 30 ); - - /** Substitute characters at the beginning of a string by "...". Similar to - * method above, except that maxlen is the width in pixels to truncate to - * @param name is the string to modify - * @param fontMetrics is the font metrics to use to calculate character sizes - * @param maxPixels is the maximum pixel length the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - * @since 3.2 - */ - static TQString lPixelSqueeze( const TQString & name, - const TQFontMetrics& fontMetrics, - uint maxPixels ); - - /** Substitute characters at the middle of a string by "...". - * @param str is the string to modify - * @param maxlen is the maximum length the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - */ - static TQString csqueeze( const TQString & str, uint maxlen = 40 ); - - /** Substitute characters in the middle of a string by "...". Similar to - * method above, except that it truncates based on pixel width rather than - * the number of characters - * @param name is the string to modify - * @param fontMetrics is the font metrics to use to calculate character sizes - * @param maxlen is the maximum length in ems the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - * @since 3.2 - */ - static TQString cEmSqueeze( const TQString & name, - const TQFontMetrics& fontMetrics, - uint maxlen = 30 ); - - /** Substitute characters in the middle of a string by "...". Similar to - * method above, except that maxlen is the width in pixels to truncate to - * @param name is the string to modify - * @param fontMetrics is the font metrics to use to calculate character sizes - * @param maxPixels is the maximum pixel length the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - * @since 3.2 - */ - static TQString cPixelSqueeze( const TQString & name, - const TQFontMetrics& fontMetrics, - uint maxPixels ); - - /** Substitute characters at the end of a string by "...". - * @param str is the string to modify - * @param maxlen is the maximum length the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - */ - static TQString rsqueeze( const TQString & str, uint maxlen = 40 ); - - /** Substitute characters at the end of a string by "...". Similar to - * method above, except that it truncates based on pixel width rather than - * the number of characters - * @param name is the string to modify - * @param fontMetrics is the font metrics to use to calculate character sizes - * @param maxlen is the maximum length in ems the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - * @since 3.2 - */ - static TQString rEmSqueeze( const TQString & name, - const TQFontMetrics& fontMetrics, - uint maxlen = 30 ); - - /** Substitute characters at the end of a string by "...". Similar to - * method above, except that maxlen is the width in pixels to truncate to - * @param name is the string to modify - * @param fontMetrics is the font metrics to use to calculate character sizes - * @param maxPixels is the maximum pixel length the modified string will have - * If the original string is shorter than "maxlen", it is returned verbatim - * @return the modified string - * @since 3.2 - */ - static TQString rPixelSqueeze( const TQString & name, - const TQFontMetrics& fontMetrics, - uint maxPixels ); - - /** - * Match a filename. - * @param filename is the real decoded filename (or dirname - * without trailing '/'). - * @param pattern is a pattern like *.txt, *.tar.gz, Makefile.*, *README*, etc. - * Patterns with two asterisks like "*.*pk" are not supported. - * @return true if the given filename matches the given pattern - */ - static bool matchFileName( const TQString& filename, const TQString& pattern ); - // KDE4: move to KShell - - /** - * Split a TQString into a TQStringList in a similar fashion to the static - * TQStringList function in Qt, except you can specify a maximum number - * of tokens. If max is specified (!= 0) then only that number of tokens - * will be extracted. The final token will be the remainder of the string. - * - * Example: - * \code - * perlSplit("__", "some__string__for__you__here", 4) - * TQStringList contains: "some", "string", "for", "you__here" - * \endcode - * - * @param sep is the string to use to delimit s. - * @param s is the input string - * @param max is the maximum number of extractions to perform, or 0. - * @return A TQStringList containing tokens extracted from s. - */ - static TQStringList perlSplit - (const TQString & sep, const TQString & s, uint max = 0); - - /** - * Split a TQString into a TQStringList in a similar fashion to the static - * TQStringList function in Qt, except you can specify a maximum number - * of tokens. If max is specified (!= 0) then only that number of tokens - * will be extracted. The final token will be the remainder of the string. - * - * Example: - * \code - * perlSplit(' ', "kparts reaches the parts other parts can't", 3) - * TQStringList contains: "kparts", "reaches", "the parts other parts can't" - * \endcode - * - * @param sep is the character to use to delimit s. - * @param s is the input string - * @param max is the maximum number of extractions to perform, or 0. - * @return A TQStringList containing tokens extracted from s. - */ - static TQStringList perlSplit - (const TQChar & sep, const TQString & s, uint max = 0); - - /** - * Split a TQString into a TQStringList in a similar fashion to the static - * TQStringList function in Qt, except you can specify a maximum number - * of tokens. If max is specified (!= 0) then only that number of tokens - * will be extracted. The final token will be the remainder of the string. - * - * Example: - * \code - * perlSplit(TQRegExp("[! ]", "Split me up ! I'm bored ! OK ?", 3) - * TQStringList contains: "Split", "me", "up ! I'm bored, OK ?" - * \endcode - * - * @param sep is the regular expression to use to delimit s. - * @param s is the input string - * @param max is the maximum number of extractions to perform, or 0. - * @return A TQStringList containing tokens extracted from s. - */ - static TQStringList perlSplit - (const TQRegExp & sep, const TQString & s, uint max = 0); - - /** - * This method auto-detects URLs in strings, and adds HTML markup to them - * so that richtext or HTML-enabled widgets (such as KActiveLabel) - * will display the URL correctly. - * @param text the string which may contain URLs - * @return the resulting text - * @since 3.1 - */ - static TQString tagURLs( const TQString& text ); - - /** - Obscure string by using a simple symmetric encryption. Applying the - function to a string obscured by this function will result in the original - string. - - The function can be used to obscure passwords stored to configuration - files. Note that this won't give you any more security than preventing - that the password is directly copied and pasted. - - @param str string to be obscured - @return obscured string - @since 3.2 - */ - static TQString obscure( const TQString &str ); - - /** - Guess whether a string is UTF8 encoded. - - @param str the string to check - @return true if UTF8. If false, the string is probably in Local8Bit. - @since 3.2 - */ - static bool isUtf8( const char *str ); - - /** - Construct TQString from a c string, guessing whether it is UTF8- or - Local8Bit-encoded. - - @param str the input string - @return the (hopefully correctly guessed) TQString representation of @p str - @since 3.2 - */ - static TQString from8Bit( const char *str ); - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated Use matchFileName () instead. - */ - static KDE_DEPRECATED bool matchFilename( const TQString& filename, const TQString& pattern ) - { - return matchFileName (filename, pattern); - } - -}; -#endif diff --git a/kdecore/ksycoca.cpp b/kdecore/ksycoca.cpp deleted file mode 100644 index 3a655d617..000000000 --- a/kdecore/ksycoca.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999-2000 Waldo Bastian <bastian@kde.org> - * - * 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 <tqdatastream.h> -#include <tqfile.h> -#include <tqbuffer.h> - -#include <kapplication.h> -#include <dcopclient.h> -#include <kglobal.h> -#include <kdebug.h> -#include <kprocess.h> -#include <kstandarddirs.h> - -#include <assert.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> - -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#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<KSycocaFactory>; - -// 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("KDESYCOCA"); - if (ksycoca_env.isEmpty()) - path = KGlobal::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->tqsetBufferFromCopy(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) { - qAddPostRoutine(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->tqdevice(); -#ifdef HAVE_MMAP - if (device && m_sycoca_mmap) - { - TQBuffer *buf = static_cast<TQBuffer*>(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->tqdevice()->tqat(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->tqdevice()->tqat(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; - KApplication::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->tqdevice()->tqat(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 = KGlobal::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() -{ - qWarning("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. - qWarning("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.tqunicode(); - 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/kdecore/ksycoca.h b/kdecore/ksycoca.h deleted file mode 100644 index 52e712989..000000000 --- a/kdecore/ksycoca.h +++ /dev/null @@ -1,187 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - * - * 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 <dcopobject.h> -#include <tqobject.h> -#include <tqstringlist.h> -#include "ksycocatype.h" -#include <kdelibs_export.h> - -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 KDECORE_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 - * $KDEDIR/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/kdecore/ksycocadict.cpp b/kdecore/ksycocadict.cpp deleted file mode 100644 index 11b16b08b..000000000 --- a/kdecore/ksycocadict.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - * - * 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 <tqptrlist.h> -#include <tqvaluelist.h> -#include <kdebug.h> -#include <stdlib.h> - -namespace -{ -struct string_entry { - string_entry(TQString _key, KSycocaEntry *_payload) - { keyStr = _key; key = keyStr.tqunicode(); length = keyStr.length(); payload = _payload; hash = 0; } - uint hash; - int length; - const TQChar *key; - TQString keyStr; - KSycocaEntry *payload; -}; -} - -template class TQPtrList<string_entry>; - -class KSycocaDictStringList : public TQPtrList<string_entry> -{ -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->tqdevice()->tqat(offset); - (*str) >> test1 >> test2; - if ((test1 > 0x000fffff) || (test2 > 1024)) - { - KSycoca::flagError(); - mHashTableSize = 0; - mOffset = 0; - return; - } - - str->tqdevice()->tqat(offset); - (*str) >> mHashTableSize; - (*str) >> mHashList; - mOffset = str->tqdevice()->tqat(); // 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->tqdevice()->tqat( 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->tqdevice()->tqat(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.tqdevice()->tqat(); - - //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]<mindiv) - { oldvec[pos+maxLength]=0; continue; } - - int diversity = calcDiversity(d, pos, sz); - if (diversity > 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; - // qWarning("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<string_entry> *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<string_entry>(); - hashTable[hash].duplicates->append(hashTable[hash].entry); - hashTable[hash].duplicate_offset = 0; - } - hashTable[hash].duplicates->append(entry); - } - } - - str << mHashTableSize; - str << mHashList; - - mOffset = str.tqdevice()->tqat(); // 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.tqdevice()->tqat(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.tqdevice()->tqat(),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<string_entry> *dups = hashTable[i].duplicates; - hashTable[i].duplicate_offset = str.tqdevice()->tqat(); - - /*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.tqdevice()->tqat(),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/kdecore/ksycocadict.h b/kdecore/ksycocadict.h deleted file mode 100644 index 0cf5eb257..000000000 --- a/kdecore/ksycocadict.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - * - * 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 <tqstring.h> -#include <tqvaluelist.h> -#include <tqdatastream.h> -#include "kdelibs_export.h" - -class KSycocaEntry; -class KSycocaDictStringList; - -/** - * @internal - * Hash table implementation for the sycoca database file - */ -class KDECORE_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<TQ_INT32> mHashList; -}; - -#endif diff --git a/kdecore/ksycocaentry.h b/kdecore/ksycocaentry.h deleted file mode 100644 index 5e3fa2d37..000000000 --- a/kdecore/ksycocaentry.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - * - * 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 <tqstringlist.h> -#include <ksharedptr.h> -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 KDECORE_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<KSycocaEntry> Ptr; - typedef TQValueList<Ptr> 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.tqdevice()->tqat(); // 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/kdecore/ksycocafactory.cpp b/kdecore/ksycocafactory.cpp deleted file mode 100644 index da65619e6..000000000 --- a/kdecore/ksycocafactory.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 David Faure <faure@kde.org> - * - * 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 <tqstringlist.h> -#include <tqdict.h> -#include <kdebug.h> - -template class TQDict<KSycocaEntry>; -template class TQDict<KSharedPtr<KSycocaEntry> >; - -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->tqdevice()->tqat(); - // Init index tables - m_sycocaDict = new KSycocaDict(m_str, m_sycocaDictOffset); - saveOffset = m_str->tqdevice()->tqat(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.tqdevice()->tqat(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.tqdevice()->tqat(); // store position in member variable - m_sycocaDictOffset = 0; - - // Write header (pass #1) - saveHeader(str); - - m_beginEntryOffset = str.tqdevice()->tqat(); - - // Write all entries. - int entryCount = 0; - for(TQDictIterator<KSycocaEntry::Ptr> it ( *m_entryDict ); - it.current(); - ++it) - { - KSycocaEntry *entry = (*it.current()); - entry->save(str); - entryCount++; - } - - m_endEntryOffset = str.tqdevice()->tqat(); - - // Write indices... - // Linear index - str << (TQ_INT32) entryCount; - for(TQDictIterator<KSycocaEntry::Ptr> it ( *m_entryDict ); - it.current(); - ++it) - { - KSycocaEntry *entry = (*it.current()); - str << (TQ_INT32) entry->offset(); - } - - // Dictionary index - m_sycocaDictOffset = str.tqdevice()->tqat(); - m_sycocaDict->save(str); - - int endOfFactoryData = str.tqdevice()->tqat(); - - // Update header (pass #2) - saveHeader(str); - - // Seek to end. - str.tqdevice()->tqat(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->tqdevice()->tqat(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/kdecore/ksycocafactory.h b/kdecore/ksycocafactory.h deleted file mode 100644 index 536da2864..000000000 --- a/kdecore/ksycocafactory.h +++ /dev/null @@ -1,143 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Waldo Bastian <bastian@kde.org> - * - * 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 <tqdict.h> -#include <tqptrlist.h> -class KSycoca; -class TQStringList; -class TQString; -class KSycocaDict; -class KSycocaResourceList; - -typedef TQDict<KSycocaEntry::Ptr> KSycocaEntryDict; - -/** - * @internal - * Base class for sycoca factories - */ -class KDECORE_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 KDECORE_EXPORT KSycocaFactoryList : public TQPtrList<KSycocaFactory> -{ -public: - KSycocaFactoryList() { } -}; - -#endif diff --git a/kdecore/ksycocatype.h b/kdecore/ksycocatype.h deleted file mode 100644 index 889c3be6d..000000000 --- a/kdecore/ksycocatype.h +++ /dev/null @@ -1,64 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> - Waldo Bastian <bastian@kde.org> - - 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/kdecore/ktempdir.cpp b/kdecore/ktempdir.cpp deleted file mode 100644 index dc443b3d5..000000000 --- a/kdecore/ktempdir.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - * - * This file is part of the KDE libraries - * Copyright (c) 2003 Joseph Wenninger <jowenn@kde.org> - * - * $Id$ - * - * 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 <sys/types.h> - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include <fcntl.h> -#include <stdlib.h> -#include <unistd.h> -#include <dirent.h> - -#ifdef HAVE_TEST -#include <test.h> -#endif -#ifdef HAVE_PATHS_H -#include <paths.h> -#endif - -#ifndef _PATH_TMP -#define _PATH_TMP "/tmp" -#endif - -#include <tqdatetime.h> -#include <tqdir.h> - -#include "kglobal.h" -#include "kapplication.h" -#include "kinstance.h" -#include "ktempdir.h" -#include "kstandarddirs.h" -#include "kprocess.h" -#include <kdebug.h> -#include "kde_file.h" - -KTempDir::KTempDir(TQString directoryPrefix, int mode) -{ - bAutoDelete = false; - bExisting = false; - mError=0; - if (directoryPrefix.isEmpty()) - { - directoryPrefix = locateLocal("tmp", KGlobal::instance()->instanceName()); - } - (void) create(directoryPrefix , mode); -} - -bool -KTempDir::create(const TQString &directoryPrefix, int mode) -{ - // make sure the random seed is randomized - (void) KApplication::random(); - - TQCString nme = TQFile::encodeName(directoryPrefix) + "XXXXXX"; - char *realName; - if((realName=mkdtemp(nme.data())) == 0) - { - // Recreate it for the warning, mkdtemps emptied it - TQCString nme = TQFile::encodeName(directoryPrefix) + "XXXXXX"; - qWarning("KTempDir: Error trying to create %s: %s", nme.data(), strerror(errno)); - mError = errno; - mTmpName = TQString::null; - return false; - } - - // got a return value != 0 - TQCString realNameStr(realName); - mTmpName = TQFile::decodeName(realNameStr)+"/"; - kdDebug(180) << "KTempDir: Temporary directory created :" << mTmpName << endl; - mode_t tmp = 0; - mode_t umsk = umask(tmp); - umask(umsk); - chmod(nme, mode&(~umsk)); - - // Success! - bExisting = true; - - // Set uid/gid (necessary for SUID programs) - chown(nme, getuid(), getgid()); - return true; -} - -KTempDir::~KTempDir() -{ - if (bAutoDelete) - unlink(); - -// KTempDirPrivate doesn't exist, so it can't be deleted -// delete d; -} - -int -KTempDir::status() const -{ - return mError; -} - -TQString -KTempDir::name() const -{ - return mTmpName; -} - -bool -KTempDir::existing() const -{ - return bExisting; -} - -TQDir * -KTempDir::qDir() -{ - if (bExisting) return new TQDir(mTmpName); - return 0; -} - -void -KTempDir::unlink() -{ - if (!bExisting) return; - if (KTempDir::removeDir(mTmpName)) - mError=0; - else - mError=errno; - bExisting=false; -} - -// Auxiliary recursive function for removeDirs -static bool -rmtree(const TQCString& name) -{ - kdDebug() << "Checking directory for remove " << name << endl; - KDE_struct_stat st; - if ( KDE_lstat( name.data(), &st ) == -1 ) // Do not dereference symlink! - return false; - if ( S_ISDIR( st.st_mode ) ) - { - // This is a directory, so process it - kdDebug() << "File " << name << " is DIRECTORY!" << endl; - KDE_struct_dirent* ep; - DIR* dp = ::opendir( name.data() ); - if ( !dp ) - return false; - while ( ( ep = KDE_readdir( dp ) ) ) - { - kdDebug() << "CHECKING " << name << "/" << ep->d_name << endl; - if ( !qstrcmp( ep->d_name, "." ) || !qstrcmp( ep->d_name, ".." ) ) - continue; - TQCString newName( name ); - newName += "/"; // Careful: do not add '/' instead or you get problems with Qt3. - newName += ep->d_name; - /* - * Be defensive and close the directory. - * - * Potential problems: - * - opendir/readdir/closedir is not re-entrant - * - unlink and rmdir invalidates a opendir/readdir/closedir - * - limited number of file descriptors for opendir/readdir/closedir - */ - if ( ::closedir( dp ) ) - return false; - // Recurse! - kdDebug() << "RECURSE: " << newName << endl; - if ( ! rmtree( newName ) ) - return false; - // We have to re-open the directory before continuing - dp = ::opendir( name.data() ); - if ( !dp ) - return false; - } - if ( ::closedir( dp ) ) - return false; - kdDebug() << "RMDIR dir " << name << endl; - return ! ::rmdir( name ); - } - else - { - // This is a non-directory file, so remove it - kdDebug() << "UNLINKING file " << name << endl; - return ! ::unlink( name ); - } -} - -bool -KTempDir::removeDir(const TQString& path) -{ - kdDebug() << k_funcinfo << " " << path << endl; - if ( !TQFile::exists( path ) ) - return true; // The goal is that there is no directory - - const TQCString cstr( TQFile::encodeName( path ) ); - return rmtree( cstr ); -} - - diff --git a/kdecore/ktempdir.h b/kdecore/ktempdir.h deleted file mode 100644 index 491a14c4c..000000000 --- a/kdecore/ktempdir.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2003 Joseph Wenninger <jowenn@kde.org> - - 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 _KTEMPDIR_H_ -#define _KTEMPDIR_H_ - -#include <tqstring.h> -#include <stdio.h> -#include <errno.h> -#include "kdelibs_export.h" - -class TQDir; -class KTempDirPrivate; - -/** - * The KTempDir class creates a unique directory for temporary use. - * - * This is especially useful if you need to create a directory in a world - * writable directory like /tmp without being vulnerable to so called - * symlink attacks. - * - * KDE applications, however, shouldn't create files or directories in /tmp in the first - * place but use the "tmp" resource instead. The standard KTempDir - * constructor will do that by default. - * - * To create a temporary directory that starts with a certain name - * in the "tmp" resource, one should use: - * KTempDir(locateLocal("tmp", prefix)); - * - * KTempFile does not create any missing directories, but locateLocal() does. - * - * See also KStandardDirs - * - * @since 3.2 - * @author Joseph Wenninger <jowenn@kde.org> - */ -class KDECORE_EXPORT KTempDir -{ -public: - /** - * Creates a temporary directory with the name: - * \p \<directoryPrefix\>\<six letters\> - * - * The default \p directoryPrefix is "$KDEHOME/tmp-$HOST/appname" - * @param directoryPrefix the prefix of the file name, or - * TQString::null for the default value - * @param mode the file permissions, - * almost always in octal. The first digit selects permissions for - * the user who owns the file: read (4), write (2), and execute - * (1); the second selects permissions for other users in the - * file's group, with the same values; and the fourth for other - * users not in the file's group, with the same values. - * - **/ - KTempDir(TQString directoryPrefix=TQString::null, - int mode = 0700 ); - - - /** - * The destructor deletes the directory and it's contents if autoDelete is enabled - **/ - ~KTempDir(); - - /** - * Turn automatic deletion on or off. - * Automatic deletion is off by default. - * @param autoDelete true to turn automatic deletion on - **/ - void setAutoDelete(bool autoDelete) { bAutoDelete = autoDelete; } - - /** - * Returns the status of the directory creation based on errno. (see errno.h) - * 0 means OK. - * - * You should check the status after object creation to check - * whether a directory could be created in the first place. - * - * @return the errno status, 0 means ok - **/ - int status() const; - - /** - * Returns the full path and name of the directory, including a trailing '/'. - * @return The name of the directory, or TQString::null if creating the - * directory has failed or the directory has been unlinked - **/ - TQString name() const; - - - /** - * Returns the TQDir* of the temporary directory. - * @return TQDir directory information of the directory or 0 if their is no managed directory - * The caller has to free the pointer open for writing to the - **/ - TQDir *qDir(); - - /** - * Deletes the directory recursively - **/ - void unlink(); - - /** - * @return true if a temporary directory has successfully been created and not been unlinked yet - */ - bool existing() const; - - /** - * @brief Remove a directory and all its contents - * - * Remove recursively a directory, even if it is not empty - * or contains other directories. - * - * However the function works too when the @p path given - * is a non-directory file. In that case it simply remove that file. - * - * The function stops on the first error. - * - * @note This function is more meant for removing a directory - * not created by the user. For user-created directories, - * using KIO::NetAccess::del is recommended instead, - * especially as it has user feedback for long operations. - * - * @param path Path of the directory to delete - * @return true if successful, otherwise false - * (Use errno for more details about the error.) - * @since 3.5.2 - */ - static bool removeDir( const TQString& path ); - -protected: - - /** - * Creates a "random" directory with specified mode - * @param directoryPrefix to use when creating temp directory - * (the rest is generated randomly) - * @param mode directory permissions - * @return bool true upon sucess - */ - bool create(const TQString &directoryPrefix, int mode); - - /** - * Sets the errno value - * @param error the value to set the status to. - */ - void setError(int error) { mError = error; } - -private: - int mError; - TQString mTmpName; - bool bExisting; - bool bAutoDelete; - - KTempDirPrivate *d; -}; - -#endif diff --git a/kdecore/ktempfile.cpp b/kdecore/ktempfile.cpp deleted file mode 100644 index f439b55ef..000000000 --- a/kdecore/ktempfile.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * - * This file is part of the KDE libraries - * Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - * - * $Id$ - * - * 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 <sys/types.h> - -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include <fcntl.h> -#include <stdlib.h> -#include <unistd.h> - -#ifdef HAVE_TEST -#include <test.h> -#endif -#ifdef HAVE_PATHS_H -#include <paths.h> -#endif - -#ifndef _PATH_TMP -#define _PATH_TMP "/tmp" -#endif - -#include <tqdatetime.h> -#include <tqfile.h> -#include <tqdatastream.h> -#include <tqtextstream.h> - -#include "kglobal.h" -#include "kapplication.h" -#include "kinstance.h" -#include "ktempfile.h" -#include "kstandarddirs.h" -#include "kde_file.h" -#include "kdebug.h" - -/* antlarr: KDE 4: make the parameters const TQString & */ -KTempFile::KTempFile(TQString filePrefix, TQString fileExtension, int mode) -{ - bAutoDelete = false; - mFd = -1; - mStream = 0; - mFile = 0; - mTextStream = 0; - mDataStream = 0; - mError = 0; - bOpen = false; - if (fileExtension.isEmpty()) - fileExtension = ".tmp"; - if (filePrefix.isEmpty()) - { - filePrefix = locateLocal("tmp", KGlobal::instance()->instanceName()); - } - (void) create(filePrefix, fileExtension, mode); -} - -KTempFile::KTempFile(bool) -{ - bAutoDelete = false; - mFd = -1; - mStream = 0; - mFile = 0; - mTextStream = 0; - mDataStream = 0; - mError = 0; - bOpen = false; -} - -bool -KTempFile::create(const TQString &filePrefix, const TQString &fileExtension, - int mode) -{ - // make sure the random seed is randomized - (void) KApplication::random(); - - TQCString ext = TQFile::encodeName(fileExtension); - TQCString nme = TQFile::encodeName(filePrefix) + "XXXXXX" + ext; - if((mFd = mkstemps(nme.data(), ext.length())) < 0) - { - // Recreate it for the warning, mkstemps emptied it - TQCString nme = TQFile::encodeName(filePrefix) + "XXXXXX" + ext; - kdWarning() << "KTempFile: Error trying to create " << nme << ": " << strerror(errno) << endl; - mError = errno; - mTmpName = TQString::null; - return false; - } - - // got a file descriptor. nme contains the name - mTmpName = TQFile::decodeName(nme); - mode_t tmp = 0; - mode_t umsk = umask(tmp); - umask(umsk); - fchmod(mFd, mode&(~umsk)); - - // Success! - bOpen = true; - - // Set uid/gid (necessary for SUID programs) - fchown(mFd, getuid(), getgid()); - - // Set close on exec - fcntl(mFd, F_SETFD, FD_CLOEXEC); - - return true; -} - -KTempFile::~KTempFile() -{ - close(); - if (bAutoDelete) - unlink(); -} - -int -KTempFile::status() const -{ - return mError; -} - -TQString -KTempFile::name() const -{ - return mTmpName; -} - -int -KTempFile::handle() const -{ - return mFd; -} - -FILE * -KTempFile::fstream() -{ - if (mStream) return mStream; - if (mFd < 0) return 0; - - // Create a stream - mStream = KDE_fdopen(mFd, "r+"); - if (!mStream) { - kdWarning() << "KTempFile: Error trying to open " << mTmpName << ": " << strerror(errno) << endl; - mError = errno; - } - return mStream; -} - -TQFile * -KTempFile::file() -{ - if (mFile) return mFile; - if ( !fstream() ) return 0; - - mFile = new TQFile(); - mFile->setName( name() ); - mFile->open(IO_ReadWrite, mStream); - return mFile; -} - -TQTextStream * -KTempFile::textStream() -{ - if (mTextStream) return mTextStream; - if ( !file() ) return 0; // Initialize mFile - - mTextStream = new TQTextStream( mFile ); - return mTextStream; -} - -TQDataStream * -KTempFile::dataStream() -{ - if (mDataStream) return mDataStream; - if ( !file() ) return 0; // Initialize mFile - - mDataStream = new TQDataStream( mFile ); - return mDataStream; -} - -void -KTempFile::unlink() -{ - if (!mTmpName.isEmpty()) - TQFile::remove( mTmpName ); - mTmpName = TQString::null; -} - -#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 -#define FDATASYNC fdatasync -#else -#define FDATASYNC fsync -#endif - -bool -KTempFile::sync() -{ - int result = 0; - - if (mStream) - { - do { - result = fflush(mStream); // We need to flush first otherwise fsync may not have our data - } - while ((result == -1) && (errno == EINTR)); - - if (result) - { - kdWarning() << "KTempFile: Error trying to flush " << mTmpName << ": " << strerror(errno) << endl; - mError = errno; - } - } - - if (mFd >= 0) - { - if( qstrcmp( getenv( "KDE_EXTRA_FSYNC" ), "1" ) == 0 ) - { - result = FDATASYNC(mFd); - if (result) - { - kdWarning() << "KTempFile: Error trying to sync " << mTmpName << ": " << strerror(errno) << endl; - mError = errno; - } - } - } - - return (mError == 0); -} - -#undef FDATASYNC - -bool -KTempFile::close() -{ - int result = 0; - delete mTextStream; mTextStream = 0; - delete mDataStream; mDataStream = 0; - delete mFile; mFile = 0; - - if (mStream) - { - result = ferror(mStream); - if (result) - mError = ENOSPC; // Assume disk full. - - result = fclose(mStream); - mStream = 0; - mFd = -1; - if (result != 0) { - kdWarning() << "KTempFile: Error trying to close " << mTmpName << ": " << strerror(errno) << endl; - mError = errno; - } - } - - - if (mFd >= 0) - { - result = ::close(mFd); - mFd = -1; - if (result != 0) { - kdWarning() << "KTempFile: Error trying to close " << mTmpName << ": " << strerror(errno) << endl; - mError = errno; - } - } - - bOpen = false; - return (mError == 0); -} - diff --git a/kdecore/ktempfile.h b/kdecore/ktempfile.h deleted file mode 100644 index 5b18bf779..000000000 --- a/kdecore/ktempfile.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 _KTEMPFILE_H_ -#define _KTEMPFILE_H_ - -#include <tqstring.h> -#include <stdio.h> -#include <errno.h> -#include "kdelibs_export.h" - -class TQFile; -class TQTextStream; -class TQDataStream; -class KSaveFile; -class KTempFilePrivate; - -/** - * The KTempFile class creates and opens a unique file for temporary use. - * - * This is especially useful if you need to create a file in a world - * writable directory like /tmp without being vulnerable to so called - * symlink attacks. - * - * KDE applications, however, shouldn't create files in /tmp in the first - * place but use the "tmp" resource instead. The standard KTempFile - * constructor will do that by default. - * - * To create a temporary file that starts with a certain name - * in the "tmp" resource, one should use: - * KTempFile(locateLocal("tmp", prefix), extension); - * - * KTempFile does not create any missing directories, but locateLocal() does. - * - * See also KStandardDirs - * - * @author Waldo Bastian <bastian@kde.org> - */ -class KDECORE_EXPORT KTempFile -{ - friend class KSaveFile; -public: - /** - * Creates a temporary file with the name: - * \<filePrefix>\<six letters>\<fileExtension> - * - * The default @p filePrefix is "$KDEHOME/tmp-$HOST/appname/" - * The default @p fileExtension is ".tmp" - * @param filePrefix the prefix of the file name, or TQString::null - * for the default value - * @param fileExtension the extension of the prefix, or TQString::null for the - * default value - * @param mode the file permissions - **/ - KTempFile(TQString filePrefix=TQString::null, - TQString fileExtension=TQString::null, - int mode = 0600 ); - - - /** - * The destructor closes the file. - * If autoDelete is enabled the file gets unlinked as well. - **/ - ~KTempFile(); - - /** - * Turn automatic deletion on or off. - * Automatic deletion is off by default. - * @param autoDelete true to turn automatic deletion on - **/ - void setAutoDelete(bool autoDelete) { bAutoDelete = autoDelete; } - - /** - * Returns the status of the file based on errno. (see errno.h) - * 0 means OK. - * - * You should check the status after object creation to check - * whether a file could be created in the first place. - * - * You may check the status after closing the file to verify that - * the file has indeed been written correctly. - * @return the errno status, 0 means ok - **/ - int status() const; - - /** - * Returns the full path and name of the file. - * - * Note that in most circumstances the file needs to be closed - * before you use it by name. - * - * In particular, if another process or software part needs to write data - * to the file based on the filename, the file should be closed before doing - * so. Otherwise the act of closing the file later on may cause the file to - * get truncated to a zero-size, resulting in an unexpected loss of the data. - * - * In some cases there is only interest in the filename itself but where the - * actual presence of a file with such name is a problem. In that case the - * file should first be both closed and unlinked. Such usage is not recommended - * since it may lead to the kind of symlink vulnerabilities that the KTempFile - * design attempts to prevent. - * - * @return The name of the file, or TQString::null if opening the - * file has failed or the file has been unlinked already. - **/ - TQString name() const; - - /** - * An integer file descriptor open for writing to the file - * @return The file descriptor, or a negative number if opening - * the file failed - **/ - int handle() const; - - /** - * Returns the FILE* of the temporary file. - * @return FILE* stream open for writing to the file, or 0 - * if opening the file failed - **/ - FILE *fstream(); - - /** - * Returns the TQTextStream for writing. - * @return TQTextStream open for writing to the file, or 0 - * if opening the file failed - **/ - TQTextStream *textStream(); - - /** - * Returns a TQDataStream for writing. - * @return TQDataStream open for writing to the file, or 0 - * if opening the file failed - **/ - TQDataStream *dataStream(); - - /** - * Returns a TQFile. - * @return A TQFile open for writing to the file, or 0 if - * opening the file failed. - **/ - TQFile *file(); - - /** - * Unlinks the file from the directory. The file is - * deleted once the last reader/writer closes it. - **/ - void unlink(); - - /** - * Flushes file to disk (fsync). - * - * If you want to be as sure as possible that the file data has - * actually been physically stored on disk you need to call sync(). - * - * See status() for details about errors. - * @return true if successful, or false if an error has occurred. - * @since 3.3 - **/ - bool sync(); - - /** - * Closes the file. - * - * See status() for details about errors. - * @return true if successful, or false if an error has occurred. - **/ - bool close(); - -protected: - /** - * Constructor used by KSaveFile - **/ - KTempFile(bool); - - /** - * @internal - * Create function used internally by KTempFile and KSaveFile - **/ - bool create(const TQString &filePrefix, - const TQString &fileExtension, int mode); - - void setError(int error) { mError = error; } -private: - int mError; - TQString mTmpName; - int mFd; - FILE *mStream; - TQFile *mFile; - TQTextStream *mTextStream; - TQDataStream *mDataStream; - bool bOpen; - bool bAutoDelete; - - KTempFilePrivate *d; -}; - -#endif diff --git a/kdecore/ktimezones.cpp b/kdecore/ktimezones.cpp deleted file mode 100644 index dbd589d85..000000000 --- a/kdecore/ktimezones.cpp +++ /dev/null @@ -1,790 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2005 S.R.Haque <srhaque@iee.org>. - - 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 <ktimezones.h> -#include <kdebug.h> -#include <kmdcodec.h> -#include <kprocess.h> -#include <kstringhandler.h> -#include <ktempfile.h> - -#include <tqdatetime.h> -#include <tqfile.h> -#include <tqregexp.h> -#include <tqstringlist.h> -#include <tqtextstream.h> - -#include <cerrno> -#include <climits> -#include <cstdlib> -#include <cstring> -#include <ctime> - -#define UTC_ZONE "UTC" - -/** - * Find out if the given standard (e.g. "GMT") and daylight savings time - * (e.g. "BST", but which may be empty) abbreviated timezone names match - * this timezone. - * - * Thus, this class can be used as a heuristic when trying to lookup the - * real timezone from the abbreviated zone names. - */ -class AbbreviationsMatch : - public KTimezoneDetails -{ -public: - AbbreviationsMatch(const TQString &stdZone, const TQString &dstZone = "") - { - m_stdZone = stdZone; - m_dstZone = dstZone; - } - - void parseStarted() - { - m_foundStd = false; - m_foundDst = m_dstZone.isEmpty(); - } - - bool test() - { - return (m_foundStd && m_foundDst); - } - -private: - bool m_foundStd; - bool m_foundDst; - TQString m_stdZone; - TQString m_dstZone; - - virtual void gotAbbreviation(int /*index*/, const TQString &value) - { - if (m_stdZone == value) - { - m_foundStd = true; - } - if (m_dstZone == value) - { - m_foundDst = true; - } - } -}; - -/** - * Internal dummy source for UTC timezone. - */ -class DummySource : - public KTimezoneSource -{ -public: - DummySource() : - KTimezoneSource("") - { - } - - virtual bool parse(const TQString &/*zone*/, KTimezoneDetails &/*dataReceiver*/) const - { - return true; - } -}; - -/** - * Find offset at a particular point in time. - */ -class OffsetFind : - public KTimezoneDetails -{ -public: - OffsetFind(unsigned dateTime) - { - m_dateTime = dateTime; - } - - void parseStarted() - { - m_transitionTimeIndex = 0; - m_localTimeIndex = -1; - m_abbrIndex = -1; - m_offset = 0; - m_isDst = false; - m_abbr = UTC_ZONE; - } - - int offset() - { - return m_offset; - } - - bool isDst() - { - return m_isDst; - } - - TQString abbreviation() - { - return m_abbr; - } - -private: - unsigned m_dateTime; - int m_transitionTimeIndex; - int m_localTimeIndex; - int m_abbrIndex; - int m_offset; - bool m_isDst; - TQString m_abbr; - - virtual void gotTransitionTime(int index, unsigned transitionTime) - { - if (transitionTime <= m_dateTime) - { - // Remember the index of the transition time that relates to dateTime. - m_transitionTimeIndex = index; - } - } - - virtual void gotLocalTimeIndex(int index, unsigned localTimeIndex) - { - if (index == m_transitionTimeIndex) - { - // Remember the index of the local time that relates to dateTime. - m_localTimeIndex = localTimeIndex; - } - } - - virtual void gotLocalTime(int index, int gmtOff, bool isDst, unsigned abbrInd) - { - if (index == m_localTimeIndex) - { - // Remember the results that relate to gmtOffset. - m_offset = gmtOff; - m_isDst = isDst; - m_abbrIndex = abbrInd; - } - } - - virtual void gotAbbreviation(int index, const TQString &value) - { - if (index == m_abbrIndex) - { - m_abbr = value; - } - } -}; - -const float KTimezone::UNKNOWN = 1000.0; - -bool KTimezone::isValidLatitude(float latitude) -{ - return (latitude >= -90.0) && (latitude <= 90.0); -} - -bool KTimezone::isValidLongitude(float longitude) -{ - return (longitude >= -180.0) && (longitude <= 180.0); -} - -KTimezone::KTimezone( - KSharedPtr<KTimezoneSource> db, const TQString& name, - const TQString &countryCode, float latitude, float longitude, - const TQString &comment) : - m_db(db), - m_name(name), - m_countryCode(countryCode), - m_latitude(latitude), - m_longitude(longitude), - m_comment(comment), - d(0) -{ - // Detect duff values. - if (m_latitude * m_latitude > 90 * 90) - m_latitude = UNKNOWN; - if (m_longitude * m_longitude > 180 * 180) - m_longitude = UNKNOWN; -} - -KTimezone::~KTimezone() -{ - // FIXME when needed: - // delete d; -} - -TQString KTimezone::comment() const -{ - return m_comment; -} - -TQDateTime KTimezone::convert(const KTimezone *newZone, const TQDateTime &dateTime) const -{ - char *originalZone = ::getenv("TZ"); - - // Convert the given localtime to UTC. - ::setenv("TZ", m_name.utf8(), 1); - tzset(); - unsigned utc = dateTime.toTime_t(); - - // Set the timezone and convert UTC to localtime. - ::setenv("TZ", newZone->name().utf8(), 1); - tzset(); - TQDateTime remoteTime; - remoteTime.setTime_t(utc, Qt::LocalTime); - - // Now restore things - if (!originalZone) - { - ::unsetenv("TZ"); - } - else - { - ::setenv("TZ", originalZone, 1); - } - tzset(); - return remoteTime; -} - -TQString KTimezone::countryCode() const -{ - return m_countryCode; -} - -float KTimezone::latitude() const -{ - return m_latitude; -} - -float KTimezone::longitude() const -{ - return m_longitude; -} - -TQString KTimezone::name() const -{ - return m_name; -} - -int KTimezone::offset(Qt::TimeSpec basisSpec) const -{ - char *originalZone = ::getenv("TZ"); - - // Get the time in the current timezone. - TQDateTime basisTime = TQDateTime::tqcurrentDateTime(basisSpec); - - // Set the timezone and find out what time it is there compared to the basis. - ::setenv("TZ", m_name.utf8(), 1); - tzset(); - TQDateTime remoteTime = TQDateTime::tqcurrentDateTime(Qt::LocalTime); - int offset = remoteTime.secsTo(basisTime); - - // Now restore things - if (!originalZone) - { - ::unsetenv("TZ"); - } - else - { - ::setenv("TZ", originalZone, 1); - } - tzset(); - return offset; -} - -int KTimezone::offset(const TQDateTime &dateTime) const -{ - OffsetFind finder(dateTime.toTime_t()); - int result = 0; - if (parse(finder)) - { - result = finder.offset(); - } - return result; -} - -bool KTimezone::parse(KTimezoneDetails &dataReceiver) const -{ - dataReceiver.parseStarted(); - bool result = m_db->parse(m_name, dataReceiver); - dataReceiver.parseEnded(); - return result; -} - -KTimezones::KTimezones() : - m_zoneinfoDir(), - m_zones(0), - d(0) -{ - // Create the database (and resolve m_zoneinfoDir!). - allZones(); - m_UTC = new KTimezone(new DummySource(), UTC_ZONE); - add(m_UTC); -} - -KTimezones::~KTimezones() -{ - // FIXME when needed: - // delete d; - - // Autodelete behavior. - if (m_zones) - { - for (ZoneMap::ConstIterator it = m_zones->begin(); it != m_zones->end(); ++it) - { - delete it.data(); - } - } - delete m_zones; -} - -void KTimezones::add(KTimezone *zone) -{ - m_zones->insert(zone->name(), zone); -} - -const KTimezones::ZoneMap KTimezones::allZones() -{ - // Have we already done all the hard work? If not, create the cache. - if (m_zones) - return *m_zones; - m_zones = new ZoneMap(); - - // Go read the database. - // - // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones - // is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure. - // - // For Unix its all easy except knowing where to look. Try the LSB location first. - TQFile f; - m_zoneinfoDir = "/usr/share/zoneinfo"; - f.setName(m_zoneinfoDir + "/zone.tab"); - if (!f.open(IO_ReadOnly)) - { - kdDebug() << "Can't open " << f.name() << endl; - m_zoneinfoDir = "/usr/lib/zoneinfo"; - f.setName(m_zoneinfoDir + "/zone.tab"); - if (!f.open(IO_ReadOnly)) - { - kdDebug() << "Can't open " << f.name() << endl; - m_zoneinfoDir = ::getenv("TZDIR"); - f.setName(m_zoneinfoDir + "/zone.tab"); - if (m_zoneinfoDir.isEmpty() || !f.open(IO_ReadOnly)) - { - kdDebug() << "Can't open " << f.name() << endl; - - // Solaris support. Synthesise something that looks like a zone.tab. - // - // /bin/grep -h ^Zone /usr/share/lib/zoneinfo/src/* | /bin/awk '{print "??\t+9999+99999\t" $2}' - // - // where the country code is set to "??" and the lattitude/longitude - // values are dummies. - m_zoneinfoDir = "/usr/share/lib/zoneinfo"; - KTempFile temp; - KShellProcess reader; - reader << "/bin/grep" << "-h" << "^Zone" << m_zoneinfoDir << "/src/*" << temp.name() << "|" << - "/bin/awk" << "'{print \"??\\t+9999+99999\\t\" $2}'"; - // Note the use of blocking here...it is a trivial amount of data! - temp.close(); - reader.start(KProcess::Block); - f.setName(temp.name()); - if (!temp.status() || !f.open(IO_ReadOnly)) - { - kdDebug() << "Can't open " << f.name() << endl; - return *m_zones; - } - } - } - } - - // Parse the zone.tab. - TQTextStream str(&f); - TQRegExp lineSeparator("[ \t]"); - TQRegExp ordinateSeparator("[+-]"); - KSharedPtr<KTimezoneSource> db(new KTimezoneSource(m_zoneinfoDir)); - while (!str.atEnd()) - { - TQString line = str.readLine(); - if (line.isEmpty() || '#' == line[0]) - continue; - TQStringList tokens = KStringHandler::perlSplit(lineSeparator, line, 4); - if (tokens.count() < 3) - { - kdError() << "invalid record: " << line << endl; - continue; - } - - // Got three tokens. Now check for two ordinates plus first one is "". - TQStringList ordinates = KStringHandler::perlSplit(ordinateSeparator, tokens[1], 2); - if (ordinates.count() < 2) - { - kdError() << "invalid coordinates: " << tokens[1] << endl; - continue; - } - - float latitude = convertCoordinate(ordinates[1]); - float longitude = convertCoordinate(ordinates[2]); - - // Add entry to list. - if (tokens[0] == "??") - tokens[0] = ""; - KTimezone *timezone = new KTimezone(db, tokens[2], tokens[0], latitude, longitude, tokens[3]); - add(timezone); - } - f.close(); - return *m_zones; -} - -/** - * Convert sHHMM or sHHMMSS to a floating point number of degrees. - */ -float KTimezones::convertCoordinate(const TQString &coordinate) -{ - int value = coordinate.toInt(); - int degrees = 0; - int minutes = 0; - int seconds = 0; - - if (coordinate.length() > 11) - { - degrees = value / 10000; - value -= degrees * 10000; - minutes = value / 100; - value -= minutes * 100; - seconds = value; - } - else - { - degrees = value / 100; - value -= degrees * 100; - minutes = value; - } - value = degrees * 3600 + minutes * 60 + seconds; - return value / 3600.0; -} - -const KTimezone *KTimezones::local() -{ - const KTimezone *local = 0; - - // First try the simplest solution of checking for well-formed TZ setting. - char *envZone = ::getenv("TZ"); - if (envZone) - { - if (envZone[0] == '\0') - { - return m_UTC; - } - else - if (envZone[0] == ':') - { - envZone++; - } - local = zone(envZone); - } - if (local) - return local; - - // Try to match /etc/localtime against the list of zoneinfo files. - TQFile f; - f.setName("/etc/localtime"); - if (f.open(IO_ReadOnly)) - { - // Compute the MD5 sum of /etc/localtime. - KMD5 context(""); - context.reset(); - context.update(TQT_TQIODEVICE_OBJECT(f)); - TQIODevice::Offset referenceSize = f.size(); - TQString referenceMd5Sum = context.hexDigest(); - f.close(); - if (!m_zoneinfoDir.isEmpty()) - { - // Compare it with each zoneinfo file. - for (ZoneMap::Iterator it = m_zones->begin(); it != m_zones->end(); ++it) - { - KTimezone *zone = it.data(); - f.setName(m_zoneinfoDir + '/' + zone->name()); - if (f.open(IO_ReadOnly)) - { - TQIODevice::Offset candidateSize = f.size(); - TQString candidateMd5Sum; - if (candidateSize == referenceSize) - { - // Only do the heavy lifting for file sizes which match. - context.reset(); - context.update(TQT_TQIODEVICE_OBJECT(f)); - candidateMd5Sum = context.hexDigest(); - } - f.close(); - if (candidateMd5Sum == referenceMd5Sum) - { - // kdError() << "local=" << zone->name() << endl; - local = zone; - break; - } - } - } - } - } - if (local) - return local; - - // BSD support. - TQString fileZone; - f.setName("/etc/timezone"); - if (!f.open(IO_ReadOnly)) - { - kdDebug() << "Can't open " << f.name() << endl; - - // Solaris support using /etc/default/init. - f.setName("/etc/default/init"); - if (!f.open(IO_ReadOnly)) - { - kdDebug() << "Can't open " << f.name() << endl; - } - else - { - TQTextStream ts(&f); - ts.setEncoding(TQTextStream::Latin1); - - // Read the last line starting "TZ=". - while (!ts.atEnd()) - { - fileZone = ts.readLine(); - if (fileZone.startsWith("TZ=")) - { - fileZone = fileZone.mid(3); - - // kdError() << "local=" << fileZone << endl; - local = zone(fileZone); - } - } - f.close(); - } - } - else - { - TQTextStream ts(&f); - ts.setEncoding(TQTextStream::Latin1); - - // Read the first line. - if (!ts.atEnd()) - { - fileZone = ts.readLine(); - - // kdError() << "local=" << fileZone << endl; - local = zone(fileZone); - } - f.close(); - } - if (local) - return local; - - // None of the deterministic stuff above has worked: try a heuristic. We - // try to find a pair of matching timezone abbreviations...that way, we'll - // likely return a value in the user's own country. - if (!m_zoneinfoDir.isEmpty()) - { - tzset(); - AbbreviationsMatch matcher(tzname[0], tzname[1]); - int bestOffset = INT_MAX; - for (ZoneMap::Iterator it = m_zones->begin(); it != m_zones->end(); ++it) - { - KTimezone *zone = it.data(); - int candidateOffset = QABS(zone->offset(Qt::LocalTime)); - if (zone->parse(matcher) && matcher.test() && (candidateOffset < bestOffset)) - { - // kdError() << "local=" << zone->name() << endl; - bestOffset = candidateOffset; - local = zone; - } - } - } - if (local) - return local; - return m_UTC; -} - -const KTimezone *KTimezones::zone(const TQString &name) -{ - if (name.isEmpty()) - return m_UTC; - ZoneMap::ConstIterator it = m_zones->find(name); - if (it != m_zones->end()) - return it.data(); - - // Error. - return 0; -} - -KTimezoneDetails::KTimezoneDetails() -{ -} - -KTimezoneDetails::~KTimezoneDetails() -{ -} - -void KTimezoneDetails::gotAbbreviation(int /*index*/, const TQString &) -{} - -void KTimezoneDetails::gotHeader( - unsigned, unsigned, unsigned, - unsigned, unsigned, unsigned) -{} - -void KTimezoneDetails::gotLeapAdjustment(int /*index*/, unsigned, unsigned) -{} - -void KTimezoneDetails::gotLocalTime(int /*index*/, int, bool, unsigned) -{} - -void KTimezoneDetails::gotLocalTimeIndex(int /*index*/, unsigned) -{} - -void KTimezoneDetails::gotIsStandard(int /*index*/, bool) -{} - -void KTimezoneDetails::gotTransitionTime(int /*index*/, unsigned) -{} - -void KTimezoneDetails::gotIsUTC(int /*index*/, bool) -{} - -void KTimezoneDetails::parseEnded() -{} - -void KTimezoneDetails::parseStarted() -{} - -KTimezoneSource::KTimezoneSource(const TQString &db) : - m_db(db) -{ -} - -KTimezoneSource::~KTimezoneSource() -{ -} - -TQString KTimezoneSource::db() -{ - return m_db; -} - -bool KTimezoneSource::parse(const TQString &zone, KTimezoneDetails &dataReceiver) const -{ - TQFile f(m_db + '/' + zone); - if (!f.open(IO_ReadOnly)) - { - kdError() << "Cannot open " << f.name() << endl; - return false; - } - - // Structures that represent the zoneinfo file. - TQ_UINT8 T, z, i_, f_; - struct - { - TQ_UINT32 ttisgmtcnt; - TQ_UINT32 ttisstdcnt; - TQ_UINT32 leapcnt; - TQ_UINT32 timecnt; - TQ_UINT32 typecnt; - TQ_UINT32 charcnt; - } tzh; - TQ_UINT32 transitionTime; - TQ_UINT8 localTimeIndex; - struct - { - TQ_INT32 gmtoff; - TQ_INT8 isdst; - TQ_UINT8 abbrind; - } tt; - TQ_UINT32 leapTime; - TQ_UINT32 leapSeconds; - TQ_UINT8 isStandard; - TQ_UINT8 isUTC; - - TQDataStream str(&f); - str >> T >> z >> i_ >> f_; - // kdError() << "signature: " << TQChar(T) << TQChar(z) << TQChar(i_) << TQChar(f_) << endl; - unsigned i; - for (i = 0; i < 4; i++) - str >> tzh.ttisgmtcnt; - str >> tzh.ttisgmtcnt >> tzh.ttisstdcnt >> tzh.leapcnt >> tzh.timecnt >> tzh.typecnt >> tzh.charcnt; - // kdError() << "header: " << tzh.ttisgmtcnt << ", " << tzh.ttisstdcnt << ", " << tzh.leapcnt << ", " << - // tzh.timecnt << ", " << tzh.typecnt << ", " << tzh.charcnt << endl; - dataReceiver.gotHeader(tzh.ttisgmtcnt, tzh.ttisstdcnt, tzh.leapcnt, tzh.timecnt, tzh.typecnt, tzh.charcnt); - for (i = 0; i < tzh.timecnt; i++) - { - str >> transitionTime; - dataReceiver.gotTransitionTime(i, transitionTime); - } - for (i = 0; i < tzh.timecnt; i++) - { - // NB: these appear to be 1-based, not zero-based! - str >> localTimeIndex; - dataReceiver.gotLocalTimeIndex(i, localTimeIndex); - } - for (i = 0; i < tzh.typecnt; i++) - { - str >> tt.gmtoff >> tt.isdst >> tt.abbrind; - // kdError() << "local type: " << tt.gmtoff << ", " << tt.isdst << ", " << tt.abbrind << endl; - dataReceiver.gotLocalTime(i, tt.gmtoff, (tt.isdst != 0), tt.abbrind); - } - - // Make sure we don't run foul of maliciously coded timezone abbreviations. - if (tzh.charcnt > 64) - { - kdError() << "excessive length for timezone abbreviations: " << tzh.charcnt << endl; - return false; - } - TQByteArray array(tzh.charcnt); - str.readRawBytes(array.data(), array.size()); - char *abbrs = array.data(); - if (abbrs[tzh.charcnt - 1] != 0) - { - // These abbrevations are corrupt! - kdError() << "timezone abbreviations not terminated: " << abbrs[tzh.charcnt - 1] << endl; - return false; - } - char *abbr = abbrs; - while (abbr < abbrs + tzh.charcnt) - { - // kdError() << "abbr: " << abbr << endl; - dataReceiver.gotAbbreviation((abbr - abbrs), abbr); - abbr += strlen(abbr) + 1; - } - for (i = 0; i < tzh.leapcnt; i++) - { - str >> leapTime >> leapSeconds; - // kdError() << "leap entry: " << leapTime << ", " << leapSeconds << endl; - dataReceiver.gotLeapAdjustment(i, leapTime, leapSeconds); - } - for (i = 0; i < tzh.ttisstdcnt; i++) - { - str >> isStandard; - // kdError() << "standard: " << isStandard << endl; - dataReceiver.gotIsStandard(i, (isStandard != 0)); - } - for (i = 0; i < tzh.ttisgmtcnt; i++) - { - str >> isUTC; - // kdError() << "UTC: " << isUTC << endl; - dataReceiver.gotIsUTC(i, (isUTC != 0)); - } - return true; -} diff --git a/kdecore/ktimezones.h b/kdecore/ktimezones.h deleted file mode 100644 index 3055f202f..000000000 --- a/kdecore/ktimezones.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2005 S.R.Haque <srhaque@iee.org>. - - 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 _KTIMEZONES_H -#define _KTIMEZONES_H - -#include "kdelibs_export.h" -#include <tqdatetime.h> -#include <tqnamespace.h> -#include <tqmap.h> -#include <tqstring.h> -#include <ksharedptr.h> - -class KTimezoneDetails; -class KTimezoneDetailsPrivate; -class KTimezonePrivate; -class KTimezonesPrivate; - -/** - * The KTimezoneSource class contains information source-dependent functions - * related to a timezone. Create subclasses to implement custom sources of - * timezone information. - * - * For example, to be able to create {@link KTimezone } objects from libical's - * VTIMEZONE objects: - *<ul> - * <li>Subclass this class with a custom {@link parse() } routine. - * <li>Create one or more instances of this class. - * <li>Use the instance(s) to create {@link KTimezone } objects. - * <li>If required, add the objects to a {@link KTimezones } database. - *</ul> - * @since 3.5 - * @author S.R.Haque <srhaque@iee.org>. - */ -class KDECORE_EXPORT KTimezoneSource : - public KShared -{ -public: - KTimezoneSource(const TQString &db); - virtual ~KTimezoneSource(); - - /** - * Location of system timezone information. - * @return value which can be combined with zone name to retrieve timezone info. - */ - virtual TQString db(); - - /** - * Extract timezone detail information. The default implementation consists - * of a parser for zoneinfo files in tzfile(5). - * @return true if the parse encountered no errors. - */ - virtual bool parse(const TQString &zone, KTimezoneDetails &dataReceiver) const; - -private: - TQString m_db; -}; - -/** - * The KTimezone class contains core functions related to a timezone. Instances - * are created in the context of a {@link KTimezoneSource } which provides - * extended functionality via {@link KTimezoneDetails }. - * - * @see KTimezoneSource - * @see KTimezoneDetails - * @since 3.5 - * @author S.R.Haque <srhaque@iee.org>. - */ -class KDECORE_EXPORT KTimezone -{ -public: - /** - * A representation for unknown locations; this is a float - * that does not represent a real latitude or longitude. - */ - static const float UNKNOWN; - - /** - * A test for a valid latitude. The valid range is +90.0 (North Pole) - * to -90.0 (South Pole). - */ - static bool isValidLatitude(float latitude); - - /** - * A test for a valid longitude. The valid range is +180.0 (east of - * Greenwich) to -180.0 (west of Greenwich). - */ - static bool isValidLongitude(float longitude); - - /** - * Create a timezone. - * - * @param db database of timezones. - * @param name in system-dependent format. - * @param countryCode ISO 3166 2-character country code, empty if unknown. - * @param latitude in degrees, UNKNOWN if not known. - * @param longitude in degrees, UNKNOWN if not known. - * @param comment description of the timezone, if any. - */ - KTimezone( - KSharedPtr<KTimezoneSource> db, const TQString &name, - const TQString &countryCode = TQString(), float latitude = UNKNOWN, float longitude = UNKNOWN, - const TQString &comment = TQString()); - ~KTimezone(); - - /** - * Returns the name of the timezone. - * - * @return name in system-dependent format. - */ - TQString name() const; - - /** - * Returns the two-letter country code of the timezone. - * - * @return ISO 3166 2-character country code, empty if unknown. - */ - TQString countryCode() const; - - /** - * Returns the latitude of the timezone. - * - * @return latitude in degrees, UNKNOWN if not known. - */ - float latitude() const; - - /** - * Returns the latitude of the timezone. - * - * @return latitude in degrees, UNKNOWN if not known. - */ - float longitude() const; - - /** - * Returns the current offset of this timezone to UTC or the local - * timezone in seconds. - * - * Take care if you cache the results of this routine; that would - * break if the result were stored across a daylight savings change. - * - * @return offset in seconds. - */ - int offset(Qt::TimeSpec basisSpec = Qt::UTC) const; - - /** - * Returns the offset of the given timezone to UTC at the given - * date/time (which is interpreted as being UTC). - * - * @return offset in seconds. - */ - int offset(const TQDateTime &dateTime) const; - - /** - * Convert a date/time (which is interpreted as being localtime in this - * timezone) into localtime in the given timezone. - * - * @return converted date/time. - */ - TQDateTime convert(const KTimezone *newZone, const TQDateTime &dateTime) const; - - /** - * Returns any comment for the timezone. - * - * @return comment, may be empty. - */ - TQString comment() const; - - /** - * Extract timezone detail information. - * @return true if the parse encountered no errors. - */ - bool parse(KTimezoneDetails &dataReceiver) const; - -private: - KTimezone(const KTimezone&); - KTimezone& operator=(const KTimezone&); - - KSharedPtr<KTimezoneSource> m_db; - TQString m_name; - TQString m_countryCode; - float m_latitude; - float m_longitude; - TQString m_comment; - KTimezonePrivate *d; -}; - -/** - * The KTimezoneDetails class contains extended functions related to a - * timezone. - * - * The parser must be customised by overriding the given virtual callbacks: - *<ul> - * <li>{@link parseEnded() } - * <li>{@link parseStarted() } - * <li>{@link gotHeader() } - * <li>{@link gotTransitionTime() } - * <li>{@link gotLocalTimeIndex() } - * <li>{@link gotLocalTime() } - * <li>{@link gotAbbreviation() } - * <li>{@link gotLeapAdjustment() } - * <li>{@link gotIsStandard() } - * <li>{@link gotIsUTC() } - *</ul> - * - * @see KTimezone - * @since 3.5 - * @author S.R.Haque <srhaque@iee.org>. - */ -class KDECORE_EXPORT KTimezoneDetails -{ -public: - KTimezoneDetails(); - virtual ~KTimezoneDetails(); - - /** - * Always called after all other callbacks. - */ - virtual void parseEnded(); - - /** - * Always called before any other callback. - */ - virtual void parseStarted(); - - /** - * Called when the header is seen. - */ - virtual void gotHeader( - unsigned ttIsGmtCnt, unsigned ttIsStdCnt, unsigned leapCnt, - unsigned timeCnt, unsigned typeCnt, unsigned charCnt); - - /** - * Called when a transition time is seen. - */ - virtual void gotTransitionTime(int index, unsigned transitionTime); - - /** - * Called when a local time index is seen. - */ - virtual void gotLocalTimeIndex(int index, unsigned localTimeIndex); - - /** - * Called when a local time is seen. - */ - virtual void gotLocalTime(int index, int gmtOff, bool isDst, unsigned abbrIndex); - - /** - * Called when a timezone abbreviation is seen. Note that the index here - * is NOT a simple incrementing integer, rather it matches the sequence - * of abbrIndex values from {@link gotLocalTime() }. - */ - virtual void gotAbbreviation(int index, const TQString &abbr); - - /** - * Called when a leap second adjustment is seen. - */ - virtual void gotLeapAdjustment(int index, unsigned leapTime, unsigned leapSeconds); - - /** - * Called when a standard/wall time indicator is seen. - */ - virtual void gotIsStandard(int index, bool isStandard); - - /** - * Called when a UTC/local time indicator is seen. - */ - virtual void gotIsUTC(int index, bool isUTC); - -private: - KTimezoneDetailsPrivate *d; -}; - -/** - * The KTimezones class models a timezone database. It supports system - * timezones, and also has support for private timezone entries. - * - * @since 3.5 - * @author S.R.Haque <srhaque@iee.org>. - */ -class KDECORE_EXPORT KTimezones -{ -public: - KTimezones(); - ~KTimezones(); - - /** - * Returns the local timezone. The idea of this routine is to provide a - * robust lookup of the local timezone. - * - * The problem is that on Unix systems, there are a variety of mechanisms - * for setting this information, and no real way of getting it. For example, - * if you set your timezone to "Europe/London", then the tzname[] - * maintained by tzset() typically returns { "GMT", "BST" }. The point of - * this routine is to actually return "Europe/London" (or rather, the - * corresponding KTimezone). - * - * @return local timezone. If necessary, we will use a series of heuristics - * which end by returning UTC. We will never return NULL. - */ - const KTimezone *local(); - - /** - * Returns the given timezone. - * - * @param name Name of timezone. Empty is equivalent to UTC. - * @return named timezone, NULL on error. - */ - const KTimezone *zone(const TQString &name); - - typedef TQMap<TQString, KTimezone *> ZoneMap; - - /** - * Return timezone database. - * @return known timezones. - */ - const ZoneMap allZones(); - - /** - * Add user-defined timezone to database. - */ - void add(KTimezone *zone); - -private: - KTimezones(const KTimezones&); - KTimezones& operator=(const KTimezones&); - - float convertCoordinate(const TQString &coordinate); - - TQString m_zoneinfoDir; - ZoneMap *m_zones; - KTimezone *m_UTC; - KTimezonesPrivate *d; -}; - -#endif diff --git a/kdecore/ktypelist.h b/kdecore/ktypelist.h deleted file mode 100644 index 343cee2ab..000000000 --- a/kdecore/ktypelist.h +++ /dev/null @@ -1,473 +0,0 @@ -/* - This work is derived from: - ---- - The Loki Library - Copyright (c) 2001 by Andrei Alexandrescu - This code accompanies the book: - Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design - Patterns Applied". Copyright (c) 2001. Addison-Wesley. - Permission to use, copy, modify, distribute and sell this software for any - purpose is hereby granted without fee, provided that the above copyright - notice appear in all copies and that both that copyright notice and this - permission notice appear in supporting documentation. - The author or Addison-Welsey Longman make no representations about the - suitability of this software for any purpose. It is provided "as is" - without express or implied warranty. - ---- - - Simon: Actually we could put a lot more of typelist stuff in here, like - real list management (append, erase, ...) or other things, but - for now I just added the basic typelist and a length template, - to keep compile time at a minimum. If we really need more we can - still add it :) - Holger: Now we add a Template to create the TypeList -*/ -#ifndef __ktypelist_h__ -#define __ktypelist_h__ - -// Convenience macros for transforming flat type enumerations into the -// recursive typelist structure - -#define K_TYPELIST_1(T1) KTypeList<T1, ::KDE::NullType> - -#define K_TYPELIST_2(T1, T2) KTypeList<T1, K_TYPELIST_1(T2) > - -#define K_TYPELIST_3(T1, T2, T3) KTypeList<T1, K_TYPELIST_2(T2, T3) > - -#define K_TYPELIST_4(T1, T2, T3, T4) \ - KTypeList<T1, K_TYPELIST_3(T2, T3, T4) > - -#define K_TYPELIST_5(T1, T2, T3, T4, T5) \ - KTypeList<T1, K_TYPELIST_4(T2, T3, T4, T5) > - -#define K_TYPELIST_6(T1, T2, T3, T4, T5, T6) \ - KTypeList<T1, K_TYPELIST_5(T2, T3, T4, T5, T6) > - -#define K_TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) \ - KTypeList<T1, K_TYPELIST_6(T2, T3, T4, T5, T6, T7) > - -#define K_TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) \ - KTypeList<T1, K_TYPELIST_7(T2, T3, T4, T5, T6, T7, T8) > - -#define K_TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) \ - KTypeList<T1, K_TYPELIST_8(T2, T3, T4, T5, T6, T7, T8, T9) > - -#define K_TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \ - KTypeList<T1, K_TYPELIST_9(T2, T3, T4, T5, T6, T7, T8, T9, T10) > - -#define K_TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \ - KTypeList<T1, K_TYPELIST_10(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) > - -#define K_TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \ - KTypeList<T1, K_TYPELIST_11(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12) > - -#define K_TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \ - KTypeList<T1, K_TYPELIST_12(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13) > - -#define K_TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14) \ - KTypeList<T1, K_TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14) > - -#define K_TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15) \ - KTypeList<T1, K_TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15) > - -#define K_TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16) \ - KTypeList<T1, K_TYPELIST_15(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16) > - -#define K_TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17) \ - KTypeList<T1, K_TYPELIST_16(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17) > - -#define K_TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18) \ - KTypeList<T1, K_TYPELIST_17(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18) > - -#define K_TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19) \ - KTypeList<T1, K_TYPELIST_18(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19) > - -#define K_TYPELIST_20(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) \ - KTypeList<T1, K_TYPELIST_19(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) > - -#define K_TYPELIST_21(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) \ - KTypeList<T1, K_TYPELIST_20(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) > - -#define K_TYPELIST_22(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) \ - KTypeList<T1, K_TYPELIST_21(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) > - -#define K_TYPELIST_23(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) \ - KTypeList<T1, K_TYPELIST_22(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) > - -#define K_TYPELIST_24(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) \ - KTypeList<T1, K_TYPELIST_23(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) > - -#define K_TYPELIST_25(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) \ - KTypeList<T1, K_TYPELIST_24(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25) > - -#define K_TYPELIST_26(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26) \ - KTypeList<T1, K_TYPELIST_25(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26) > - -#define K_TYPELIST_27(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27) \ - KTypeList<T1, K_TYPELIST_26(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27) > - -#define K_TYPELIST_28(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28) \ - KTypeList<T1, K_TYPELIST_27(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28) > - -#define K_TYPELIST_29(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29) \ - KTypeList<T1, K_TYPELIST_28(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29) > - -#define K_TYPELIST_30(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) \ - KTypeList<T1, K_TYPELIST_29(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) > - -#define K_TYPELIST_31(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) \ - KTypeList<T1, K_TYPELIST_30(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) > - -#define K_TYPELIST_32(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) \ - KTypeList<T1, K_TYPELIST_31(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) > - -#define K_TYPELIST_33(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) \ - KTypeList<T1, K_TYPELIST_32(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) > - -#define K_TYPELIST_34(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) \ - KTypeList<T1, K_TYPELIST_33(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) > - -#define K_TYPELIST_35(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35) \ - KTypeList<T1, K_TYPELIST_34(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35) > - -#define K_TYPELIST_36(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36) \ - KTypeList<T1, K_TYPELIST_35(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36) > - -#define K_TYPELIST_37(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37) \ - KTypeList<T1, K_TYPELIST_36(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37) > - -#define K_TYPELIST_38(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38) \ - KTypeList<T1, K_TYPELIST_37(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38) > - -#define K_TYPELIST_39(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39) \ - KTypeList<T1, K_TYPELIST_38(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39) > - -#define K_TYPELIST_40(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) \ - KTypeList<T1, K_TYPELIST_39(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) > - -#define K_TYPELIST_41(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) \ - KTypeList<T1, K_TYPELIST_40(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) > - -#define K_TYPELIST_42(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) \ - KTypeList<T1, K_TYPELIST_41(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) > - -#define K_TYPELIST_43(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) \ - KTypeList<T1, K_TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) > - -#define K_TYPELIST_44(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) \ - KTypeList<T1, K_TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) > - -#define K_TYPELIST_45(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45) \ - KTypeList<T1, K_TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45) > - -#define K_TYPELIST_46(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46) \ - KTypeList<T1, K_TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46) > - -#define K_TYPELIST_47(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47) \ - KTypeList<T1, K_TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47) > - -#define K_TYPELIST_48(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48) \ - KTypeList<T1, K_TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48) > - -#define K_TYPELIST_49(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49) \ - KTypeList<T1, K_TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49) > - -#define K_TYPELIST_50(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) \ - KTypeList<T1, K_TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) > - -namespace KDE -{ - class NullType; -} - -/** - * The building block of typelists of any length. - * Use it through the K_TYPELIST_NN macros. - * Defines nested types: - * @li Head (first element, a non-typelist type by convention) - * @li Tail (second element, can be another typelist) - */ -template <class T, class U> -struct KTypeList -{ - /// first element, a non-typelist type by convention - typedef T Head; - /// second element, can be another typelist - typedef U Tail; -}; - -// forward decl. -template <class TList> struct KTypeListLength; - -template <> -struct KTypeListLength<KDE::NullType> -{ -/** - * Zero length type list. - */ - enum { Value = 0 }; -}; - -/** - * A class template for determining the length of a typelist. To be - * used like KTypeListLength< typelist >::Value; - */ -template <class T, class U> -struct KTypeListLength< KTypeList<T, U> > -{ - /** - * The length of the type list. - */ - enum { Value = 1 + KTypeListLength<U>::Value }; -}; - -/////////////////////////////////////////////////////////////////////////////// -// class template IndexOf -// Finds the index of a type in a typelist -// Invocation (TList is a typelist and T is a type): -// IndexOf<TList, T>::value -// returns the position of T in TList, or NullType if T is not found in TList -//////////////////////////////////////////////////////////////////////////////// - -template <class TList, class T> struct KTypeListIndexOf; - -template <class T> -struct KTypeListIndexOf<KDE::NullType, T> -{ - enum { value = -1 }; -}; - -template <class T, class Tail> -struct KTypeListIndexOf< KTypeList<T, Tail>, T > -{ - enum { value = 0 }; -}; - -template <class Head, class Tail, class T> -struct KTypeListIndexOf< KTypeList<Head, Tail>, T > -{ -private: - enum { temp = KTypeListIndexOf<Tail, T>::value }; -public: - enum { value = (temp == -1 ? -1 : 1 + temp) }; -}; - - - -/** - * KMakeTypeList the prefered way to create a typelist for you. - * - * \code - * typedef KMakeTypeList<MyType1,MyWidget,MyQobject,MyKoffice>::Result Products; - * K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory<Products> ) - * - * \endcode - * - * - * @author Holger Freyther based on the Loki library. See copyright statement at the top - * @since 3.3 - */ -template< - typename T1 = KDE::NullType, typename T2 = KDE::NullType, typename T3 = KDE::NullType, - typename T4 = KDE::NullType, typename T5 = KDE::NullType, typename T6 = KDE::NullType, - typename T7 = KDE::NullType, typename T8 = KDE::NullType, typename T9 = KDE::NullType, - typename T10 = KDE::NullType, typename T11 = KDE::NullType, typename T12 = KDE::NullType, - typename T13 = KDE::NullType, typename T14 = KDE::NullType, typename T15 = KDE::NullType, - typename T16 = KDE::NullType, typename T17 = KDE::NullType, typename T18 = KDE::NullType - > -struct KMakeTypeList{ -private: -typedef typename KMakeTypeList -< - T2 , T3 , T4 , - T5 , T6 , T7 , - T8 , T9 , T10, - T11, T12, T13, - T14, T15, T16, - T17, T18 ->::Result TailResult; - -public: - typedef KTypeList<T1, TailResult> Result; -}; - -template<> -struct KMakeTypeList<> -{ - typedef KDE::NullType Result; -}; - - -#endif - diff --git a/kdecore/kuniqueapp.h b/kdecore/kuniqueapp.h deleted file mode 100644 index d3ec22dd5..000000000 --- a/kdecore/kuniqueapp.h +++ /dev/null @@ -1,6 +0,0 @@ -// kuniqueapp.h is the old name. Use #include <kuniqueapplication.h> from now on -#ifdef KDE_NO_COMPAT -#error kuniqueapp.h is the old name. Use #include <kuniqueapplication.h> from now on -#else -#include <kuniqueapplication.h> -#endif diff --git a/kdecore/kuniqueapplication.cpp b/kdecore/kuniqueapplication.cpp deleted file mode 100644 index 193aafcd3..000000000 --- a/kdecore/kuniqueapplication.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - - $Id$ - - 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. -*/ - -#include <config.h> - -#include <sys/types.h> -#include <sys/wait.h> - -#include <assert.h> -#include <errno.h> -#include <stdlib.h> -#include <unistd.h> - -#include <tqfile.h> -#include <tqptrlist.h> -#include <tqtimer.h> - -#include <dcopclient.h> -#include <kcmdlineargs.h> -#include <kstandarddirs.h> -#include <kaboutdata.h> - -#if defined Q_WS_X11 -#include <kwin.h> -#include <kstartupinfo.h> -#endif - -#include <kconfig.h> -#include "kdebug.h" -#include "kuniqueapplication.h" - -#if defined Q_WS_X11 -#include <netwm.h> -#include <X11/Xlib.h> -#define DISPLAY "DISPLAY" -#else -# ifdef Q_WS_QWS -# define DISPLAY "QWS_DISPLAY" -# else -# define DISPLAY "DISPLAY" -# endif -#endif - -bool KUniqueApplication::s_nofork = false; -bool KUniqueApplication::s_multipleInstances = false; -bool KUniqueApplication::s_uniqueTestDone = false; -bool KUniqueApplication::s_handleAutoStarted = false; - -static KCmdLineOptions kunique_options[] = -{ - { "nofork", "Don't run in the background.", 0 }, - KCmdLineLastOption -}; - -struct DCOPRequest { - TQCString fun; - TQByteArray data; - DCOPClientTransaction *transaction; -}; - -class KUniqueApplicationPrivate { -public: - TQPtrList <DCOPRequest> requestList; - bool processingRequest; - bool firstInstance; -}; - -void -KUniqueApplication::addCmdLineOptions() -{ - KCmdLineArgs::addCmdLineOptions(kunique_options, 0, "kuniqueapp", "kde" ); -} - -bool -KUniqueApplication::start() -{ - if( s_uniqueTestDone ) - return true; - s_uniqueTestDone = true; - addCmdLineOptions(); // Make sure to add cmd line options -#ifdef Q_WS_WIN - s_nofork = true; -#else - KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kuniqueapp"); - s_nofork = !args->isSet("fork"); - delete args; -#endif - - TQCString appName = KCmdLineArgs::about->appName(); - - if (s_nofork) - { - if (s_multipleInstances) - { - TQCString pid; - pid.setNum(getpid()); - appName = appName + "-" + pid; - } - - // Check to make sure that we're actually able to register with the DCOP - // server. - -#ifndef Q_WS_WIN //TODO - if(dcopClient()->registerAs(appName, false).isEmpty()) { - startKdeinit(); - if(dcopClient()->registerAs(appName, false).isEmpty()) { - kdError() << "KUniqueApplication: Can't setup DCOP communication." << endl; - ::exit(255); - } - } -#endif - - // We'll call newInstance in the constructor. Do nothing here. - return true; - } - DCOPClient *dc; - int fd[2]; - signed char result; - if (0 > pipe(fd)) - { - kdError() << "KUniqueApplication: pipe() failed!" << endl; - ::exit(255); - } - int fork_result = fork(); - switch(fork_result) { - case -1: - kdError() << "KUniqueApplication: fork() failed!" << endl; - ::exit(255); - break; - case 0: - // Child - ::close(fd[0]); - if (s_multipleInstances) - appName.append("-").append(TQCString().setNum(getpid())); - dc = dcopClient(); - { - TQCString regName = dc->registerAs(appName, false); - if (regName.isEmpty()) - { - // Check DISPLAY - if (TQCString(getenv(DISPLAY)).isEmpty()) - { - kdError() << "KUniqueApplication: Can't determine DISPLAY. Aborting." << endl; - result = -1; // Error - ::write(fd[1], &result, 1); - ::exit(255); - } - - // Try to launch tdeinit. - startKdeinit(); - regName = dc->registerAs(appName, false); - if (regName.isEmpty()) - { - kdError() << "KUniqueApplication: Can't setup DCOP communication." << endl; - result = -1; - delete dc; // Clean up DCOP commmunication - ::write(fd[1], &result, 1); - ::exit(255); - } - } - if (regName != appName) - { - // Already running. Ok. - result = 0; - delete dc; // Clean up DCOP commmunication - ::write(fd[1], &result, 1); - ::close(fd[1]); -#if 0 -#ifdef Q_WS_X11 - // say we're up and running ( probably no new window will appear ) - KStartupInfoId id; - if( kapp != NULL ) // KApplication constructor unsets the env. variable - id.initId( kapp->startupId()); - else - id = KStartupInfo::currentStartupIdEnv(); - if( !id.none()) - { - Display* disp = XOpenDisplay( NULL ); - if( disp != NULL ) // use extra X connection - { - KStartupInfo::sendFinishX( disp, id ); - XCloseDisplay( disp ); - } - } -#else //FIXME(E): implement -#endif -#endif - return false; - } - dc->setPriorityCall(true); - } - - { -#ifdef Q_WS_X11 - KStartupInfoId id; - if( kapp != NULL ) // KApplication constructor unsets the env. variable - id.initId( kapp->startupId()); - else - id = KStartupInfo::currentStartupIdEnv(); - if( !id.none()) - { // notice about pid change - Display* disp = XOpenDisplay( NULL ); - if( disp != NULL ) // use extra X connection - { - KStartupInfoData data; - data.addPid( getpid()); - KStartupInfo::sendChangeX( disp, id, data ); - XCloseDisplay( disp ); - } - } -#else //FIXME(E): Implement -#endif - } - result = 0; - ::write(fd[1], &result, 1); - ::close(fd[1]); - return true; // Finished. - default: - // Parent -// DCOPClient::emergencyClose(); -// dcopClient()->detach(); - if (s_multipleInstances) - appName.append("-").append(TQCString().setNum(fork_result)); - ::close(fd[1]); - for(;;) - { - int n = ::read(fd[0], &result, 1); - if (n == 1) break; - if (n == 0) - { - kdError() << "KUniqueApplication: Pipe closed unexpectedly." << endl; - ::exit(255); - } - if (errno != EINTR) - { - kdError() << "KUniqueApplication: Error reading from pipe." << endl; - ::exit(255); - } - } - ::close(fd[0]); - - if (result != 0) - ::exit(result); // Error occurred in child. - - dc = new DCOPClient(); - if (!dc->attach()) - { - kdError() << "KUniqueApplication: Parent process can't attach to DCOP." << endl; - delete dc; // Clean up DCOP commmunication - ::exit(255); - } - if (!dc->isApplicationRegistered(appName)) { - kdError() << "KUniqueApplication: Registering failed!" << endl; - } - - TQCString new_asn_id; -#if defined Q_WS_X11 - KStartupInfoId id; - if( kapp != NULL ) // KApplication constructor unsets the env. variable - id.initId( kapp->startupId()); - else - id = KStartupInfo::currentStartupIdEnv(); - if( !id.none()) - new_asn_id = id.id(); -#endif - - TQByteArray data, reply; - TQDataStream ds(data, IO_WriteOnly); - - KCmdLineArgs::saveAppArgs(ds); - ds << new_asn_id; - - dc->setPriorityCall(true); - TQCString replyType; - if (!dc->call(appName, KCmdLineArgs::about->appName(), "newInstance()", data, replyType, reply)) - { - kdError() << "Communication problem with " << KCmdLineArgs::about->appName() << ", it probably crashed." << endl; - delete dc; // Clean up DCOP commmunication - ::exit(255); - } - dc->setPriorityCall(false); - if (replyType != "int") - { - kdError() << "KUniqueApplication: DCOP communication error!" << endl; - delete dc; // Clean up DCOP commmunication - ::exit(255); - } - TQDataStream rs(reply, IO_ReadOnly); - int exitCode; - rs >> exitCode; - delete dc; // Clean up DCOP commmunication - ::exit(exitCode); - break; - } - return false; // make insure++ happy -} - - -KUniqueApplication::KUniqueApplication(bool allowStyles, bool GUIenabled, bool configUnique) - : KApplication( allowStyles, GUIenabled, initHack( configUnique )), - DCOPObject(KCmdLineArgs::about->appName()) -{ - d = new KUniqueApplicationPrivate; - d->processingRequest = false; - d->firstInstance = true; - - if (s_nofork) - // Can't call newInstance directly from the constructor since it's virtual... - TQTimer::singleShot( 0, this, TQT_SLOT(newInstanceNoFork()) ); -} - - -#ifdef Q_WS_X11 -KUniqueApplication::KUniqueApplication(Display *display, Qt::HANDLE visual, - Qt::HANDLE colormap, bool allowStyles, bool configUnique) - : KApplication( display, visual, colormap, allowStyles, initHack( configUnique )), - DCOPObject(KCmdLineArgs::about->appName()) -{ - d = new KUniqueApplicationPrivate; - d->processingRequest = false; - d->firstInstance = true; - - if (s_nofork) - // Can't call newInstance directly from the constructor since it's virtual... - TQTimer::singleShot( 0, this, TQT_SLOT(newInstanceNoFork()) ); -} -#endif - - -KUniqueApplication::~KUniqueApplication() -{ - delete d; -} - -// this gets called before even entering TQApplication::TQApplication() -KInstance* KUniqueApplication::initHack( bool configUnique ) -{ - KInstance* inst = new KInstance( KCmdLineArgs::about ); - if (configUnique) - { - KConfigGroupSaver saver( inst->config(), "KDE" ); - s_multipleInstances = inst->config()->readBoolEntry("MultipleInstances", false); - } - if( !start()) - // Already running - ::exit( 0 ); - return inst; -} - -void KUniqueApplication::newInstanceNoFork() -{ - if (dcopClient()->isSuspended()) - { - // Try again later. - TQTimer::singleShot( 200, this, TQT_SLOT(newInstanceNoFork()) ); - return; - } - - s_handleAutoStarted = false; - newInstance(); - d->firstInstance = false; -#if defined Q_WS_X11 - // KDE4 remove - // A hack to make startup notification stop for apps which override newInstance() - // and reuse an already existing window there, but use KWin::activateWindow() - // instead of KStartupInfo::setNewStartupId(). Therefore KWin::activateWindow() - // for now sets this flag. Automatically ending startup notification always - // would cause problem if the new window would show up with a small delay. - if( s_handleAutoStarted ) - KStartupInfo::handleAutoAppStartedSending(); -#endif - // What to do with the return value ? -} - -bool KUniqueApplication::process(const TQCString &fun, const TQByteArray &data, - TQCString &replyType, TQByteArray &replyData) -{ - if (fun == "newInstance()") - { - delayRequest(fun, data); - return true; - } else - return DCOPObject::process(fun, data, replyType, replyData); -} - -void -KUniqueApplication::delayRequest(const TQCString &fun, const TQByteArray &data) -{ - DCOPRequest *request = new DCOPRequest; - request->fun = fun; - request->data = data; - request->transaction = dcopClient()->beginTransaction(); - d->requestList.append(request); - if (!d->processingRequest) - { - TQTimer::singleShot(0, this, TQT_SLOT(processDelayed())); - } -} - -void -KUniqueApplication::processDelayed() -{ - if (dcopClient()->isSuspended()) - { - // Try again later. - TQTimer::singleShot( 200, this, TQT_SLOT(processDelayed())); - return; - } - d->processingRequest = true; - while( !d->requestList.isEmpty() ) - { - DCOPRequest *request = d->requestList.take(0); - TQByteArray replyData; - TQCString replyType; - if (request->fun == "newInstance()") { - dcopClient()->setPriorityCall(false); - TQDataStream ds(request->data, IO_ReadOnly); - KCmdLineArgs::loadAppArgs(ds); - if( !ds.atEnd()) // backwards compatibility - { - TQCString asn_id; - ds >> asn_id; - setStartupId( asn_id ); - } - s_handleAutoStarted = false; - int exitCode = newInstance(); - d->firstInstance = false; -#if defined Q_WS_X11 - if( s_handleAutoStarted ) - KStartupInfo::handleAutoAppStartedSending(); // KDE4 remove? -#endif - TQDataStream rs(replyData, IO_WriteOnly); - rs << exitCode; - replyType = "int"; - } - dcopClient()->endTransaction( request->transaction, replyType, replyData); - delete request; - } - - d->processingRequest = false; -} - -bool KUniqueApplication::restoringSession() -{ - return d->firstInstance && isRestored(); -} - -int KUniqueApplication::newInstance() -{ - if (!d->firstInstance) - { - - if ( mainWidget() ) - { - mainWidget()->show(); -#if defined Q_WS_X11 - // This is the line that handles window activation if necessary, - // and what's important, it does it properly. If you reimplement newInstance(), - // and don't call the inherited one, use this (but NOT when newInstance() - // is called for the first time, like here). - KStartupInfo::setNewStartupId( mainWidget(), kapp->startupId()); -#endif - } - } - return 0; // do nothing in default implementation -} - -void KUniqueApplication::setHandleAutoStarted() -{ - s_handleAutoStarted = false; -} - -void KUniqueApplication::virtual_hook( int id, void* data ) -{ KApplication::virtual_hook( id, data ); - DCOPObject::virtual_hook( id, data ); } - -#include "kuniqueapplication.moc" diff --git a/kdecore/kuniqueapplication.h b/kdecore/kuniqueapplication.h deleted file mode 100644 index f5c4bcc18..000000000 --- a/kdecore/kuniqueapplication.h +++ /dev/null @@ -1,221 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown <pbrown@kde.org> - Copyright (c) 2000-2001 Waldo Bastian <bastian@kde.org> - - 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 _KUNIQUEAPP_H -#define _KUNIQUEAPP_H - -#include <kapplication.h> -#include <dcopobject.h> - -class KUniqueApplicationPrivate; - -/** - * Maintains only a single - * instance of a running application at a time. - * - * If another instance - * is started, it will determine (via DCOP) whether it is the first instance - * or a second instance. If it is a second instance, it will forward on - * the information to the first instance and then quit. - * - * The .desktop file for the application should state X-DCOP-ServiceType=Unique, - * see kapplication.h - * - * If your application is used to open files, it should also support the --tempfile - * option (see KCmdLineArgs::addTempFileOption()), to delete tempfiles after use. - * Add X-KDE-HasTempFileOption=true to the .desktop file to indicate this. - * - * @see KApplication DCOPObject - * @author Preston Brown <pbrown@kde.org> - */ -class KDECORE_EXPORT KUniqueApplication : public KApplication, public DCOPObject -{ - Q_OBJECT -public: - /** - * Constructor. Takes command line arguments from KCmdLineArgs - * - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * it normally runs in the background but under special circumstances - * displays widgets. Call KApplication::enableStyles() before - * displaying any widgets. - * @param GUIenabled Set to false to disable all GUI stuff. This implies - * no styles either. - * @param configUnique If true, the uniqueness of the application will - * depend on the value of the "MultipleInstances" - * key in the "KDE" group of the application config file. - */ - KUniqueApplication( bool allowStyles=true, - bool GUIenabled=true, - bool configUnique=false); - -#ifdef Q_WS_X11 - /** - * Constructor. Takes command line arguments from KCmdLineArgs - * - * @param display Will be passed to Qt as the X display. The display - * must be valid and already opened. - * @param visual Pointer to the X11 visual that should be used by the - * application. If NULL, the default visual will be used instead. - * @param colormap The colormap that should be used by the application. - * If 0, the default colormap will be used instead. - * @param allowStyles Set to false to disable the loading on plugin based - * styles. This is only useful to applications that do not display a GUI - * normally. If you do create an application with @p allowStyles set to false - * it normally runs in the background but under special circumstances - * displays widgets. Call KApplication::enableStyles() before - * displaying any widgets. - * @param configUnique If true, the uniqueness of the application will - * depend on the value of the "MultipleInstances" - * key in the "KDE" group of the application config file. - * @since KDE 3.3 - */ - KUniqueApplication( Display *display, - Qt::HANDLE visual=0, - Qt::HANDLE colormap=0, - bool allowStyles=true, - bool configUnique=false); -#endif - - /** - * Adds command line options specific for KUniqueApplication. - * - * Should be called before calling KUniqueApplication constructor - * and / or start(). - */ - static void addCmdLineOptions(); - - /** - * Forks and registers with dcop. - * - * The command line arguments are being sent via DCOP to newInstance() - * and will be received once the application enters the event loop. - * - * Typically this is used like: - * \code - * int main(int argc, char **argv) { - * KAboutData about("myappname", "myAppName", .....); - * KCmdLineArgs::init(argc, argv, &about); - * KCmdLineArgs::addCmdLineOptions( myCmdOptions ); - * KUniqueApplication::addCmdLineOptions(); - * - * if (!KUniqueApplication::start()) { - * fprintf(stderr, "myAppName is already running!\n"); - * exit(0); - * } - * KUniqueApplication a; - * a.exec(); - * } - * \endcode - * Note that it's not necessary to call start() explicitly. It will be - * called automatically before creating KUniqueApplication if it hasn't - * been called yet, without any performance impact. - * - * @return true if registration is successful. - * false if another process was already running. - */ - static bool start(); - - /** - * Destructor - */ - virtual ~KUniqueApplication(); - - /** - * Dispatches any incoming DCOP message for a new instance. - * - * If it is not a request for a new instance, return false. - * Overloaded from DCOPObject to make sure that the application - * stays unique. - * @param fun DCOP function signature - * @param data the data for the arguments - * @param replyType the type of the reply value - * @param replyData the reply - * @see DCOPObject - */ - bool process(const TQCString &fun, const TQByteArray &data, - TQCString &replyType, TQByteArray &replyData); - - /** - * Creates a new "instance" of the application. - * - * Usually this will involve making some calls into the GUI portion of your - * application asking for a new window to be created, possibly with - * some data already loaded based on the arguments received. - * - * Command line arguments have been passed to KCmdLineArgs before this - * function is called and can be checked in the usual way. - * - * The default implementation ensures the mainwindow of the already - * running instance is shown and activated if necessary. You should - * prefer using it from your overridden method instead of doing - * it directly. - * - * Note that newInstance() is called also in the first started - * application process. - * - * @return An exit value. The calling process will exit with this value. - */ - virtual int newInstance(); - - /** - * Returns whether newInstance() is being called while session - * restoration is in progress. - * - * @since KDE 3.3 - */ - bool restoringSession(); - - /** - * @internal - */ - static void setHandleAutoStarted(); - -private: - /** - * Delays the processing of a DCOP request. - */ - void delayRequest(const TQCString &fun, const TQByteArray &data); - -private slots: - /** - * Delayed processing of DCOP requests. - */ - void processDelayed(); - - void newInstanceNoFork(); - - static KInstance* initHack( bool configUnique ); - -private: - static bool s_nofork; - static bool s_multipleInstances; - static bool s_uniqueTestDone; - static bool s_handleAutoStarted; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KUniqueApplicationPrivate *d; -}; - -#endif diff --git a/kdecore/kunload.h b/kdecore/kunload.h deleted file mode 100644 index fbdf62556..000000000 --- a/kdecore/kunload.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file is part of the KDE Libraries - * Copyright (C) 2000 Michael Matz <matz@kde.org> - * - * 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. - * - */ - -#define _UNLOAD(p) diff --git a/kdecore/kurl.cpp b/kdecore/kurl.cpp deleted file mode 100644 index 52c8a807a..000000000 --- a/kdecore/kurl.cpp +++ /dev/null @@ -1,2356 +0,0 @@ -/* - Copyright (C) 1999 Torben Weis <weis@kde.org> - - 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. -*/ - -/* - * The currently active RFC for URL/URIs is RFC3986 - * Previous (and now deprecated) RFCs are RFC1738 and RFC2396 - */ - -#include "kurl.h" - -// KDE_QT_ONLY is first used for dcop/client (e.g. marshalling) -#ifndef KDE_QT_ONLY -#include <kdebug.h> -#include <kglobal.h> -#include <kidna.h> -#include <kprotocolinfo.h> -#endif - -#include <stdio.h> -#include <assert.h> -#include <ctype.h> -#include <stdlib.h> -#include <unistd.h> - -#include <tqurl.h> -#include <tqdir.h> -#include <tqstringlist.h> -#include <tqregexp.h> -#include <tqstylesheet.h> -#include <tqmap.h> -#include <tqtextcodec.h> -#include <tqmutex.h> - -#ifdef Q_WS_WIN -# define KURL_ROOTDIR_PATH "C:/" -#else -# define KURL_ROOTDIR_PATH "/" -#endif - -static const TQString fileProt = "file"; - -static TQTextCodec * codecForHint( int encoding_hint /* not 0 ! */ ) -{ - return TQTextCodec::codecForMib( encoding_hint ); -} - -// encoding_offset: -// 0 encode both @ and / -// 1 encode @ but not / -// 2 encode neither @ or / -static TQString encode( const TQString& segment, int encoding_offset, int encoding_hint, bool isRawURI = false ) -{ - const char *encode_string = "/@<>#\"&?={}|^~[]\'`\\:+%"; - encode_string += encoding_offset; - - TQCString local; - if (encoding_hint==0) - local = segment.local8Bit(); - else - { - TQTextCodec * textCodec = codecForHint( encoding_hint ); - if (!textCodec) - local = segment.local8Bit(); - else - local = textCodec->fromUnicode( segment ); - } - - int old_length = isRawURI ? local.size() - 1 : local.length(); - - if ( old_length < 1 ) - return segment.isNull() ? TQString::null : TQString(""); // differentiate null and empty - - // a worst case approximation - TQChar *new_segment = new TQChar[ old_length * 3 + 1 ]; - int new_length = 0; - - for ( int i = 0; i < old_length; i++ ) - { - // 'unsave' and 'reserved' characters - // according to RFC 1738, - // 2.2. URL Character Encoding Issues (pp. 3-4) - // WABA: Added non-ascii - unsigned char character = local[i]; - if ( (character <= 32) || (character >= 127) || - strchr(encode_string, character) ) - { - new_segment[ new_length++ ] = '%'; - - unsigned int c = character / 16; - c += (c > 9) ? ('A' - 10) : '0'; - new_segment[ new_length++ ] = c; - - c = character % 16; - c += (c > 9) ? ('A' - 10) : '0'; - new_segment[ new_length++ ] = c; - - } - else - new_segment[ new_length++ ] = (QChar)local[i]; - } - - TQString result = TQString(new_segment, new_length); - delete [] new_segment; - return result; -} - -static TQString encodeHost( const TQString& segment, bool encode_slash, int encoding_hint ) -{ - // Hostnames are encoded differently - // we use the IDNA transformation instead - - // Note: when merging qt-addon, use QResolver::domainToAscii here -#ifndef KDE_QT_ONLY - Q_UNUSED( encode_slash ); - Q_UNUSED( encoding_hint ); - TQString host = KIDNA::toAscii(segment); - if (host.isEmpty()) - return segment; - return host; -#else - return encode(segment, encode_slash ? 0 : 1, encoding_hint); -#endif -} - -static int hex2int( unsigned int _char ) -{ - if ( _char >= 'A' && _char <='F') - return _char - 'A' + 10; - if ( _char >= 'a' && _char <='f') - return _char - 'a' + 10; - if ( _char >= '0' && _char <='9') - return _char - '0'; - return -1; -} - -// WABA: The result of lazy_encode isn't usable for a URL which -// needs to satisfies RFC requirements. However, the following -// operation will make it usable again: -// encode(decode(...)) -// -// As a result one can see that url.prettyURL() does not result in -// a RFC compliant URL but that the following sequence does: -// KURL(url.prettyURL()).url() - - -static TQString lazy_encode( const TQString& segment, bool encodeAt=true ) -{ - int old_length = segment.length(); - - if ( !old_length ) - return TQString::null; - - // a worst case approximation - TQChar *new_segment = new TQChar[ old_length * 3 + 1 ]; - int new_length = 0; - - for ( int i = 0; i < old_length; i++ ) - { - unsigned int character = segment[i].tqunicode(); // Don't use latin1() - // It returns 0 for non-latin1 values - // Small set of really ambiguous chars - if ((character < 32) || // Low ASCII - ((character == '%') && // The escape character itself - (i+2 < old_length) && // But only if part of a valid escape sequence! - (hex2int(segment[i+1].tqunicode())!= -1) && - (hex2int(segment[i+2].tqunicode())!= -1)) || - (character == '?') || // Start of query delimiter - ((character == '@') && encodeAt) || // Username delimiter - (character == '#') || // Start of reference delimiter - ((character == 32) && (i+1 == old_length || segment[i+1] == (QChar)' '))) // A trailing space - { - new_segment[ new_length++ ] = '%'; - - unsigned int c = character / 16; - c += (c > 9) ? ('A' - 10) : '0'; - new_segment[ new_length++ ] = c; - - c = character % 16; - c += (c > 9) ? ('A' - 10) : '0'; - new_segment[ new_length++ ] = c; - } - else - new_segment[ new_length++ ] = segment[i]; - } - - TQString result = TQString(new_segment, new_length); - delete [] new_segment; - return result; -} - -static void decode( const TQString& segment, TQString &decoded, TQString &encoded, int encoding_hint=0, bool updateDecoded = true, bool isRawURI = false ) -{ - decoded = TQString::null; - encoded = segment; - - int old_length = segment.length(); - if ( !old_length ) - return; - - TQTextCodec *textCodec = 0; - if (encoding_hint) - textCodec = codecForHint( encoding_hint ); - - if (!textCodec) - textCodec = TQTextCodec::codecForLocale(); - - TQCString csegment = textCodec->fromUnicode(segment); - // Check if everything went ok - if (textCodec->toUnicode(csegment) != segment) - { - // Uh oh - textCodec = codecForHint( 106 ); // Fall back to utf-8 - csegment = textCodec->fromUnicode(segment); - } - old_length = csegment.length(); - - int new_length = 0; - int new_length2 = 0; - - // make a copy of the old one - char *new_segment = new char[ old_length + 1 ]; - TQChar *new_usegment = new TQChar[ old_length * 3 + 1 ]; - - int i = 0; - while( i < old_length ) - { - bool bReencode = false; - unsigned char character = csegment[ i++ ]; - if ((character <= ' ') || (character > 127)) - bReencode = true; - - new_usegment [ new_length2++ ] = character; - if (character == '%' ) - { - int a = i+1 < old_length ? hex2int( csegment[i] ) : -1; - int b = i+1 < old_length ? hex2int( csegment[i+1] ) : -1; - if ((a == -1) || (b == -1)) // Only replace if sequence is valid - { - // Contains stray %, make sure to re-encode! - bReencode = true; - } - else - { - // Valid %xx sequence - character = a * 16 + b; // Replace with value of %dd - if (!isRawURI && !character && updateDecoded) - break; // Stop at %00 - - new_usegment [ new_length2++ ] = (unsigned char) csegment[i++]; - new_usegment [ new_length2++ ] = (unsigned char) csegment[i++]; - } - } - if (bReencode) - { - new_length2--; - new_usegment [ new_length2++ ] = '%'; - - unsigned int c = character / 16; - c += (c > 9) ? ('A' - 10) : '0'; - new_usegment[ new_length2++ ] = c; - - c = character % 16; - c += (c > 9) ? ('A' - 10) : '0'; - new_usegment[ new_length2++ ] = c; - } - - new_segment [ new_length++ ] = character; - } - new_segment [ new_length ] = 0; - - encoded = TQString( new_usegment, new_length2); - - // Encoding specified - if (updateDecoded) - { - decoded = textCodec->toUnicode( new_segment ); - if ( isRawURI ) { - int length = tqstrlen( new_segment ); - while ( length < new_length ) { - decoded += TQChar::null; - length += 1; - decoded += textCodec->toUnicode( new_segment + length ); - length += tqstrlen( new_segment + length ); - } - } - - TQCString validate = textCodec->fromUnicode(decoded); - - if (strcmp(validate.data(), new_segment) != 0) - { - decoded = TQString::fromLocal8Bit(new_segment, new_length); - } - } - - delete [] new_segment; - delete [] new_usegment; -} - -static TQString decode(const TQString &segment, int encoding_hint = 0, bool isRawURI = false) -{ - TQString result; - TQString tmp; - decode(segment, result, tmp, encoding_hint, true, isRawURI); - return result; -} - -static TQString cleanpath(const TQString &_path, bool cleanDirSeparator, bool decodeDots) -{ - if (_path.isEmpty()) return TQString::null; - - if (TQDir::isRelativePath(_path)) - return _path; // Don't mangle mailto-style URLs - - TQString path = _path; - - int len = path.length(); - - if (decodeDots) - { -#ifndef KDE_QT_ONLY - static const TQString &encodedDot = KGlobal::staticQString("%2e"); -#else - TQString encodedDot("%2e"); -#endif - if (path.find(encodedDot, 0, false) != -1) - { -#ifndef KDE_QT_ONLY - static const TQString &encodedDOT = KGlobal::staticQString("%2E"); // Uppercase! -#else - TQString encodedDOT("%2E"); -#endif - path.replace(encodedDot, "."); - path.replace(encodedDOT, "."); - len = path.length(); - } - } - - bool slash = (len && path[len-1] == '/') || - (len > 1 && path[len-2] == '/' && path[len-1] == '.'); - - // The following code cleans up directory path much like - // TQDir::cleanDirPath() except it can be made to ignore multiple - // directory separators by setting the flag to false. That fixes - // bug# 15044, mail.altavista.com and other similar brain-dead server - // implementations that do not follow what has been specified in - // RFC 2396!! (dA) - TQString result; - int cdUp, orig_pos, pos; - - cdUp = 0; - pos = orig_pos = len; - while ( pos && (pos = path.findRev('/',--pos)) != -1 ) - { - len = orig_pos - pos - 1; - if ( len == 2 && path[pos+1] == '.' && path[pos+2] == '.' ) - cdUp++; - else - { - // Ignore any occurrences of '.' - // This includes entries that simply do not make sense like /..../ - if ( (len || !cleanDirSeparator) && - (len != 1 || path[pos+1] != '.' ) ) - { - if ( !cdUp ) - result.prepend(path.mid(pos, len+1)); - else - cdUp--; - } - } - orig_pos = pos; - } - -#ifdef Q_WS_WIN // prepend drive letter if exists (js) - if (orig_pos >= 2 && isalpha(path[0].latin1()) && path[1]==':') { - result.prepend(TQString(path[0])+":"); - } -#endif - - if ( result.isEmpty() ) - result = KURL_ROOTDIR_PATH; - else if ( slash && result[result.length()-1] != '/' ) - result.append('/'); - - return result; -} - -bool KURL::isRelativeURL(const TQString &_url) -{ - int len = _url.length(); - if (!len) return true; // Very short relative URL. - const TQChar *str = _url.tqunicode(); - - // Absolute URL must start with alpha-character - if (!isalpha(str[0].latin1())) - return true; // Relative URL - - for(int i = 1; i < len; i++) - { - char c = str[i].latin1(); // Note: non-latin1 chars return 0! - if (c == ':') - return false; // Absolute URL - - // Protocol part may only contain alpha, digit, + or - - if (!isalpha(c) && !isdigit(c) && (c != '+') && (c != '-')) - return true; // Relative URL - } - // URL did not contain ':' - return true; // Relative URL -} - -KURL::List::List(const KURL &url) -{ - append( url ); -} - -KURL::List::List(const TQStringList &list) -{ - for (TQStringList::ConstIterator it = list.begin(); - it != list.end(); - it++) - { - append( KURL(*it) ); - } -} - -TQStringList KURL::List::toStringList() const -{ - TQStringList lst; - for( KURL::List::ConstIterator it = begin(); - it != end(); - it++) - { - lst.append( (*it).url() ); - } - return lst; -} - - -KURL::KURL() -{ - reset(); -} - -KURL::~KURL() -{ -} - - -KURL::KURL( const TQString &url, int encoding_hint ) -{ - reset(); - parse( url, encoding_hint ); -} - -KURL::KURL( const char * url, int encoding_hint ) -{ - reset(); - parse( TQString::tqfromLatin1(url), encoding_hint ); -} - -KURL::KURL( const TQCString& url, int encoding_hint ) -{ - reset(); - parse( TQString::tqfromLatin1(url), encoding_hint ); -} - -KURL::KURL( const KURL& _u ) -{ - *this = _u; -} - -TQDataStream & operator<< (TQDataStream & s, const KURL & a) -{ - TQString QueryForWire=a.m_strQuery_encoded; - if (!a.m_strQuery_encoded.isNull()) - QueryForWire.prepend("?"); - - s << a.m_strProtocol << a.m_strUser << a.m_strPass << a.m_strHost - << a.m_strPath << a.m_strPath_encoded << QueryForWire << a.m_strRef_encoded - << TQ_INT8(a.m_bIsMalformed ? 1 : 0) << a.m_iPort; - return s; -} - -TQDataStream & operator>> (TQDataStream & s, KURL & a) -{ - TQ_INT8 malf; - TQString QueryFromWire; - s >> a.m_strProtocol >> a.m_strUser >> a.m_strPass >> a.m_strHost - >> a.m_strPath >> a.m_strPath_encoded >> QueryFromWire >> a.m_strRef_encoded - >> malf >> a.m_iPort; - a.m_bIsMalformed = (malf != 0); - - if ( QueryFromWire.isNull() ) - a.m_strQuery_encoded = TQString::null; - else if ( QueryFromWire.length() == 1 ) // empty query - a.m_strQuery_encoded = ""; - else - a.m_strQuery_encoded = QueryFromWire.mid(1); - - a.m_iUriMode = KURL::uriModeForProtocol( a.m_strProtocol ); - - return s; -} - -#ifndef QT_NO_NETWORKPROTOCOL -KURL::KURL( const TQUrl &u ) -{ - *this = u; -} -#endif - -KURL::KURL( const KURL& _u, const TQString& _rel_url, int encoding_hint ) -{ - if (_u.hasSubURL()) // Operate on the last suburl, not the first - { - KURL::List lst = split( _u ); - KURL u(lst.last(), _rel_url, encoding_hint); - lst.remove( lst.last() ); - lst.append( u ); - *this = join( lst ); - return; - } - // WORKAROUND THE RFC 1606 LOOPHOLE THAT ALLOWS - // http:/index.html AS A VALID SYNTAX FOR RELATIVE - // URLS. ( RFC 2396 section 5.2 item # 3 ) - TQString rUrl = _rel_url; - int len = _u.m_strProtocol.length(); - if ( !_u.m_strHost.isEmpty() && !rUrl.isEmpty() && - rUrl.find( _u.m_strProtocol, 0, false ) == 0 && - rUrl[len] == ':' && (rUrl[len+1] != '/' || - (rUrl[len+1] == '/' && rUrl[len+2] != '/')) ) - { - rUrl.remove( 0, rUrl.find( ':' ) + 1 ); - } - - if ( rUrl.isEmpty() ) - { - *this = _u; - } - else if ( rUrl[0] == '#' ) - { - *this = _u; - m_strRef_encoded = rUrl.mid(1); - if ( m_strRef_encoded.isNull() ) - m_strRef_encoded = ""; // we know there was an (empty) html ref, we saw the '#' - } - else if ( isRelativeURL( rUrl) ) - { - *this = _u; - m_strQuery_encoded = TQString::null; - m_strRef_encoded = TQString::null; - if ( rUrl[0] == '/') - { - if ((rUrl.length() > 1) && (rUrl[1] == '/')) - { - m_strHost = TQString::null; - // File protocol returns file:/// without host, strip // from rUrl - if (_u.m_strProtocol == fileProt) - rUrl.remove(0, 2); - } - m_strPath = TQString::null; - m_strPath_encoded = TQString::null; - } - else if ( rUrl[0] != '?' ) - { - int pos = m_strPath.findRev( '/' ); - if (pos >= 0) - m_strPath.truncate(pos); - m_strPath += '/'; - if (!m_strPath_encoded.isEmpty()) - { - pos = m_strPath_encoded.findRev( '/' ); - if (pos >= 0) - m_strPath_encoded.truncate(pos); - m_strPath_encoded += '/'; - } - } - else - { - if ( m_strPath.isEmpty() ) - m_strPath = '/'; - } - KURL tmp( url() + rUrl, encoding_hint); - *this = tmp; - cleanPath(false); - } - else - { - KURL tmp( rUrl, encoding_hint); - *this = tmp; - // Preserve userinfo if applicable. - if (!_u.m_strUser.isEmpty() && m_strUser.isEmpty() && (_u.m_strHost == m_strHost) && (_u.m_strProtocol == m_strProtocol)) - { - m_strUser = _u.m_strUser; - m_strPass = _u.m_strPass; - } - cleanPath(false); - } -} - -void KURL::reset() -{ - m_strProtocol = TQString::null; - m_strUser = TQString::null; - m_strPass = TQString::null; - m_strHost = TQString::null; - m_strPath = TQString::null; - m_strPath_encoded = TQString::null; - m_strQuery_encoded = TQString::null; - m_strRef_encoded = TQString::null; - m_bIsMalformed = true; - m_iPort = 0; - m_iUriMode = Auto; -} - -bool KURL::isEmpty() const -{ - return (m_strPath.isEmpty() && m_strProtocol.isEmpty()); -} - -void KURL::parse( const TQString& _url, int encoding_hint ) -{ - if ( _url.isEmpty() || m_iUriMode == Invalid ) - { - m_strProtocol = _url; - m_iUriMode = Invalid; - return; - } - - const TQChar* buf = _url.tqunicode(); - const TQChar* orig = buf; - uint len = _url.length(); - uint pos = 0; - - // Node 1: Accept alpha or slash - TQChar x = buf[pos++]; -#ifdef Q_WS_WIN - /* win32: accept <letter>: or <letter>:/ or <letter>:\ */ - const bool alpha = isalpha((int)x); - if (alpha && len<2) - goto NodeErr; - if (alpha && buf[pos]==':' && (len==2 || (len>2 && (buf[pos+1]=='/' || buf[pos+1]=='\\')))) -#else - if ( x == (QChar)'/' ) -#endif - { - // A slash means we immediately proceed to parse it as a file URL. - m_iUriMode = URL; - m_strProtocol = fileProt; - parseURL( _url, encoding_hint ); - return; - } - if ( !isalpha( (int)x ) ) - goto NodeErr; - - // Node 2: Accept any amount of (alpha|digit|'+'|'-') - // '.' is not currently accepted, because current KURL may be confused. - // Proceed with :// :/ or : - while( pos < len && (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) || - buf[pos] == (QChar)'+' || buf[pos] == (QChar)'-')) pos++; - - if (pos < len && buf[pos] == (QChar)':' ) - { - m_strProtocol = TQString( orig, pos ).lower(); - if ( m_iUriMode == Auto ) - m_iUriMode = uriModeForProtocol( m_strProtocol ); - // Proceed to correct parse function. - switch ( m_iUriMode ) - { - case RawURI: - parseRawURI( _url ); - return; - case Mailto: - parseMailto( _url ); - return; - case URL: - parseURL( _url, encoding_hint ); - return; - default: - // Unknown URI mode results in an invalid URI. - break; - } - } - -NodeErr: - reset(); - m_strProtocol = _url; - m_iUriMode = Invalid; -} - -void KURL::parseRawURI( const TQString& _url, int encoding_hint ) -{ - uint len = _url.length(); - const TQChar* buf = _url.tqunicode(); - - uint pos = 0; - - // Accept any amount of (alpha|digit|'+'|'-') - // '.' is not currently accepted, because current KURL may be confused. - // Proceed with : - while( pos < len && (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) || - buf[pos] == (QChar)'+' || buf[pos] == (QChar)'-')) pos++; - - // Note that m_strProtocol is already set here, so we just skip over the protocol. - if (pos < len && buf[pos] == (QChar)':' ) - pos++; - else { // can't happen, the caller checked all this already - reset(); - m_strProtocol = _url; - m_iUriMode = Invalid; - return; - } - - if ( pos == len ) // can't happen, the caller checked this already - m_strPath = TQString::null; - else - m_strPath = decode( TQString( buf + pos, len - pos ), encoding_hint, true ); - - m_bIsMalformed = false; - - return; -} - -void KURL::parseMailto( const TQString& _url, int encoding_hint ) -{ - parseURL( _url, encoding_hint); - if ( m_bIsMalformed ) - return; - TQRegExp mailre("(.+@)(.+)"); - if ( mailre.exactMatch( m_strPath ) ) - { -#ifndef KDE_QT_ONLY - TQString host = KIDNA::toUnicode( mailre.cap( 2 ) ); - if (host.isEmpty()) - host = TQString(mailre.cap( 2 )).lower(); -#else - TQString host = TQString(mailre.cap( 2 )).lower(); -#endif - m_strPath = mailre.cap( 1 ) + host; - } -} - -void KURL::parseURL( const TQString& _url, int encoding_hint ) -{ - TQString port; - bool badHostName = false; - int start = 0; - uint len = _url.length(); - const TQChar* buf = _url.tqunicode(); - - TQChar delim; - TQString tmp; - - uint pos = 0; - - // Node 1: Accept alpha or slash - TQChar x = buf[pos++]; -#ifdef Q_WS_WIN - /* win32: accept <letter>: or <letter>:/ or <letter>:\ */ - const bool alpha = isalpha((int)x); - if (alpha && len<2) - goto NodeErr; - if (alpha && buf[pos]==(QChar)':' && (len==2 || (len>2 && (buf[pos+1]==(QChar)'/' || buf[pos+1]==(QChar)'\\')))) -#else - if ( x == (QChar)'/' ) -#endif - goto Node9; - if ( !isalpha( (int)x ) ) - goto NodeErr; - - // Node 2: Accept any amount of (alpha|digit|'+'|'-') - // '.' is not currently accepted, because current KURL may be confused. - // Proceed with :// :/ or : - while( pos < len && (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) || - buf[pos] == (QChar)'+' || buf[pos] == (QChar)'-')) pos++; - - // Note that m_strProtocol is already set here, so we just skip over the protocol. - if ( pos+2 < len && buf[pos] == (QChar)':' && buf[pos+1] == (QChar)'/' && buf[pos+2] == (QChar)'/' ) - { - pos += 3; - } - else if (pos+1 < len && buf[pos] == (QChar)':' ) // Need to always compare length()-1 otherwise KURL passes "http:" as legal!! - { - pos++; - start = pos; - goto Node9; - } - else - goto NodeErr; - - //Node 3: We need at least one character here - if ( pos == len ) - goto NodeErr; - start = pos; - - // Node 4: Accept any amount of characters. - if (buf[pos] == (QChar)'[') // An IPv6 host follows. - goto Node8; - // Terminate on / or @ or ? or # or " or ; or < - x = buf[pos]; - while( (x != (QChar)':') && (x != (QChar)'@') && (x != (QChar)'/') && (x != (QChar)'?') && (x != (QChar)'#') ) - { - if ((x == (QChar)'\"') || (x == (QChar)';') || (x == (QChar)'<')) - badHostName = true; - if (++pos == len) - break; - x = buf[pos]; - } - if ( pos == len ) - { - if (badHostName) - goto NodeErr; - - setHost(decode(TQString( buf + start, pos - start ), encoding_hint)); - goto NodeOk; - } - if ( x == (QChar)'@' ) - { - m_strUser = decode(TQString( buf + start, pos - start ), encoding_hint); - pos++; - goto Node7; - } - else if ( (x == (QChar)'/') || (x == (QChar)'?') || (x == (QChar)'#')) - { - if (badHostName) - goto NodeErr; - - setHost(decode(TQString( buf + start, pos - start ), encoding_hint)); - start = pos; - goto Node9; - } - else if ( x != (QChar)':' ) - goto NodeErr; - m_strUser = decode(TQString( buf + start, pos - start ), encoding_hint); - pos++; - - // Node 5: We need at least one character - if ( pos == len ) - goto NodeErr; - start = pos++; - - // Node 6: Read everything until @, /, ? or # - while( (pos < len) && - (buf[pos] != (QChar)'@') && - (buf[pos] != (QChar)'/') && - (buf[pos] != (QChar)'?') && - (buf[pos] != (QChar)'#')) pos++; - // If we now have a '@' the ':' seperates user and password. - // Otherwise it seperates host and port. - if ( (pos == len) || (buf[pos] != (QChar)'@') ) - { - // Ok the : was used to separate host and port - if (badHostName) - goto NodeErr; - setHost(m_strUser); - m_strUser = TQString::null; - TQString tmp( buf + start, pos - start ); - char *endptr; - m_iPort = (unsigned short int)strtol(tmp.ascii(), &endptr, 10); - if ((pos == len) && (strlen(endptr) == 0)) - goto NodeOk; - // there is more after the digits - pos -= strlen(endptr); - if ((buf[pos] != (QChar)'@') && - (buf[pos] != (QChar)'/') && - (buf[pos] != (QChar)'?') && - (buf[pos] != (QChar)'#')) - goto NodeErr; - - start = pos; - goto Node9; - } - m_strPass = decode(TQString( buf + start, pos - start), encoding_hint); - pos++; - - // Node 7: We need at least one character - Node7: - if ( pos == len ) - goto NodeErr; - - Node8: - if (buf[pos] == (QChar)'[') - { - // IPv6 address - start = ++pos; // Skip '[' - - if (pos == len) - { - badHostName = true; - goto NodeErr; - } - // Node 8a: Read everything until ] or terminate - badHostName = false; - x = buf[pos]; - while( (x != (QChar)']') ) - { - if ((x == (QChar)'\"') || (x == (QChar)';') || (x == (QChar)'<')) - badHostName = true; - if (++pos == len) - { - badHostName = true; - break; - } - x = buf[pos]; - } - if (badHostName) - goto NodeErr; - setHost(decode(TQString( buf + start, pos - start ), encoding_hint)); - if (pos < len) pos++; // Skip ']' - if (pos == len) - goto NodeOk; - } - else - { - // Non IPv6 address, with a user - start = pos; - - // Node 8b: Read everything until / : or terminate - badHostName = false; - x = buf[pos]; - while( (x != (QChar)':') && (x != (QChar)'@') && (x != (QChar)'/') && (x != (QChar)'?') && (x != (QChar)'#') ) - { - if ((x == (QChar)'\"') || (x == (QChar)';') || (x == (QChar)'<')) - badHostName = true; - if (++pos == len) - break; - x = buf[pos]; - } - if (badHostName) - goto NodeErr; - if ( pos == len ) - { - setHost(decode(TQString( buf + start, pos - start ), encoding_hint)); - goto NodeOk; - } - setHost(decode(TQString( buf + start, pos - start ), encoding_hint)); - } - x = buf[pos]; - if ( x == (QChar)'/' || x == (QChar)'#' || x == (QChar)'?' ) - { - start = pos; - goto Node9; - } - else if ( x != (QChar)':' ) - goto NodeErr; - pos++; - - // Node 8c: Accept at least one digit - if ( pos == len ) - goto NodeErr; - start = pos; - if ( !isdigit( buf[pos++] ) ) - goto NodeErr; - - // Node 8d: Accept any amount of digits - while( pos < len && isdigit( buf[pos] ) ) pos++; - port = TQString( buf + start, pos - start ); - m_iPort = port.toUShort(); - if ( pos == len ) - goto NodeOk; - start = pos; - - Node9: // parse path until query or reference reached - - while( pos < len && buf[pos] != (QChar)'#' && buf[pos]!=(QChar)'?' ) pos++; - - tmp = TQString( buf + start, pos - start ); - //kdDebug(126)<<" setting encoded path to:"<<tmp<<endl; - setEncodedPath( tmp, encoding_hint ); - - if ( pos == len ) - goto NodeOk; - - //Node10: // parse query or reference depending on what comes first - delim = (buf[pos++]==(QChar)'#'?(QChar)'?':(QChar)'#'); - - start = pos; - - while(pos < len && buf[pos]!=delim ) pos++; - - tmp = TQString(buf + start, pos - start); - if (delim==(QChar)'#') - _setQuery(tmp, encoding_hint); - else - m_strRef_encoded = tmp; - - if (pos == len) - goto NodeOk; - - //Node11: // feed the rest into the remaining variable - tmp = TQString( buf + pos + 1, len - pos - 1); - if (delim == (QChar)'#') - m_strRef_encoded = tmp; - else - _setQuery(tmp, encoding_hint); - - NodeOk: - //kdDebug(126)<<"parsing finished. m_strProtocol="<<m_strProtocol<<" m_strHost="<<m_strHost<<" m_strPath="<<m_strPath<<endl; - m_bIsMalformed = false; // Valid URL - - //kdDebug()<<"Prot="<<m_strProtocol<<"\nUser="<<m_strUser<<"\nPass="<<m_strPass<<"\nHost="<<m_strHost<<"\nPath="<<m_strPath<<"\nQuery="<<m_strQuery_encoded<<"\nRef="<<m_strRef_encoded<<"\nPort="<<m_iPort<<endl; - if (m_strProtocol.isEmpty()) - { - m_iUriMode = URL; - m_strProtocol = fileProt; - } - return; - - NodeErr: -// kdDebug(126) << "KURL couldn't parse URL \"" << _url << "\"" << endl; - reset(); - m_strProtocol = _url; - m_iUriMode = Invalid; -} - -KURL& KURL::operator=( const TQString& _url ) -{ - reset(); - parse( _url ); - - return *this; -} - -KURL& KURL::operator=( const char * _url ) -{ - reset(); - parse( TQString::tqfromLatin1(_url) ); - - return *this; -} - -#ifndef QT_NO_NETWORKPROTOCOL -KURL& KURL::operator=( const TQUrl & u ) -{ - m_strProtocol = u.protocol(); - m_iUriMode = Auto; - m_strUser = u.user(); - m_strPass = u.password(); - m_strHost = u.host(); - m_strPath = u.path( false ); - m_strPath_encoded = TQString::null; - m_strQuery_encoded = u.query(); - m_strRef_encoded = u.ref(); - m_bIsMalformed = !u.isValid(); - m_iPort = u.port(); - - return *this; -} -#endif - -KURL& KURL::operator=( const KURL& _u ) -{ - m_strProtocol = _u.m_strProtocol; - m_strUser = _u.m_strUser; - m_strPass = _u.m_strPass; - m_strHost = _u.m_strHost; - m_strPath = _u.m_strPath; - m_strPath_encoded = _u.m_strPath_encoded; - m_strQuery_encoded = _u.m_strQuery_encoded; - m_strRef_encoded = _u.m_strRef_encoded; - m_bIsMalformed = _u.m_bIsMalformed; - m_iPort = _u.m_iPort; - m_iUriMode = _u.m_iUriMode; - - return *this; -} - -bool KURL::operator<( const KURL& _u) const -{ - int i; - if (!_u.isValid()) - { - if (!isValid()) - { - i = m_strProtocol.compare(_u.m_strProtocol); - return (i < 0); - } - return false; - } - if (!isValid()) - return true; - - i = m_strProtocol.compare(_u.m_strProtocol); - if (i) return (i < 0); - - i = m_strHost.compare(_u.m_strHost); - if (i) return (i < 0); - - if (m_iPort != _u.m_iPort) return (m_iPort < _u.m_iPort); - - i = m_strPath.compare(_u.m_strPath); - if (i) return (i < 0); - - i = m_strQuery_encoded.compare(_u.m_strQuery_encoded); - if (i) return (i < 0); - - i = m_strRef_encoded.compare(_u.m_strRef_encoded); - if (i) return (i < 0); - - i = m_strUser.compare(_u.m_strUser); - if (i) return (i < 0); - - i = m_strPass.compare(_u.m_strPass); - if (i) return (i < 0); - - return false; -} - -bool KURL::operator==( const KURL& _u ) const -{ - if ( !isValid() || !_u.isValid() ) - return false; - - if ( m_strProtocol == _u.m_strProtocol && - m_strUser == _u.m_strUser && - m_strPass == _u.m_strPass && - m_strHost == _u.m_strHost && - m_strPath == _u.m_strPath && - // The encoded path may be null, but the URLs are still equal (David) - ( m_strPath_encoded.isNull() || _u.m_strPath_encoded.isNull() || - m_strPath_encoded == _u.m_strPath_encoded ) && - m_strQuery_encoded == _u.m_strQuery_encoded && - m_strRef_encoded == _u.m_strRef_encoded && - m_iPort == _u.m_iPort ) - { - return true; - } - - return false; -} - -bool KURL::operator==( const TQString& _u ) const -{ - KURL u( _u ); - return ( *this == u ); -} - -bool KURL::cmp( const KURL &u, bool ignore_trailing ) const -{ - return equals( u, ignore_trailing ); -} - -bool KURL::equals( const KURL &_u, bool ignore_trailing ) const -{ - if ( !isValid() || !_u.isValid() ) - return false; - - if ( ignore_trailing ) - { - TQString path1 = path(1); - TQString path2 = _u.path(1); - if ( path1 != path2 ) - return false; - - if ( m_strProtocol == _u.m_strProtocol && - m_strUser == _u.m_strUser && - m_strPass == _u.m_strPass && - m_strHost == _u.m_strHost && - m_strQuery_encoded == _u.m_strQuery_encoded && - m_strRef_encoded == _u.m_strRef_encoded && - m_iPort == _u.m_iPort ) - return true; - - return false; - } - - return ( *this == _u ); -} - -bool KURL::isParentOf( const KURL& _u ) const -{ - if ( !isValid() || !_u.isValid() ) - return false; - - if ( m_strProtocol == _u.m_strProtocol && - m_strUser == _u.m_strUser && - m_strPass == _u.m_strPass && - m_strHost == _u.m_strHost && - m_strQuery_encoded == _u.m_strQuery_encoded && - m_strRef_encoded == _u.m_strRef_encoded && - m_iPort == _u.m_iPort ) - { - if ( path().isEmpty() || _u.path().isEmpty() ) - return false; // can't work with implicit paths - - TQString p1( cleanpath( path(), true, false ) ); - if ( p1[p1.length()-1] != '/' ) - p1 += '/'; - TQString p2( cleanpath( _u.path(), true, false ) ); - if ( p2[p2.length()-1] != '/' ) - p2 += '/'; - - //kdDebug(126) << "p1=" << p1 << endl; - //kdDebug(126) << "p2=" << p2 << endl; - //kdDebug(126) << "p1.length()=" << p1.length() << endl; - //kdDebug(126) << "p2.left(!$)=" << p2.left( p1.length() ) << endl; - return p2.startsWith( p1 ); - } - return false; -} - -void KURL::setFileName( const TQString& _txt ) -{ - m_strRef_encoded = TQString::null; - int i = 0; - while( _txt[i] == (QChar)'/' ) ++i; - TQString tmp; - if ( i ) - tmp = _txt.mid( i ); - else - tmp = _txt; - - TQString path = m_strPath_encoded.isEmpty() ? m_strPath : m_strPath_encoded; - if ( path.isEmpty() ) - path = "/"; - else - { - int lastSlash = path.findRev( '/' ); - if ( lastSlash == -1) - { - // The first character is not a '/' ??? - // This looks strange ... - path = "/"; - } - else if ( path.right(1) != "/" ) - path.truncate( lastSlash+1 ); // keep the "/" - } - if (m_strPath_encoded.isEmpty()) - { - path += tmp; - setPath( path ); - } - else - { - path += encode_string(tmp); - setEncodedPath( path ); - } - cleanPath(); -} - -void KURL::cleanPath( bool cleanDirSeparator ) // taken from the old KURL -{ - if (m_iUriMode != URL) return; - m_strPath = cleanpath(m_strPath, cleanDirSeparator, false); - // WABA: Is this safe when "/../" is encoded with %? - m_strPath_encoded = cleanpath(m_strPath_encoded, cleanDirSeparator, true); -} - -static TQString trailingSlash( int _trailing, const TQString &path ) -{ - TQString result = path; - - if ( _trailing == 0 ) - return result; - else if ( _trailing == 1 ) - { - int len = result.length(); - if ( (len == 0) || (result[ len - 1 ] != (QChar)'/') ) - result += "/"; - return result; - } - else if ( _trailing == -1 ) - { - if ( result == "/" ) - return result; - int len = result.length(); - while (len > 1 && result[ len - 1 ] == (QChar)'/') - { - len--; - } - result.truncate( len ); - return result; - } - else { - assert( 0 ); - return TQString::null; - } -} - -void KURL::adjustPath( int _trailing ) -{ - if (!m_strPath_encoded.isEmpty()) - { - m_strPath_encoded = trailingSlash( _trailing, m_strPath_encoded ); - } - m_strPath = trailingSlash( _trailing, m_strPath ); -} - - -TQString KURL::encodedPathAndQuery( int _trailing, bool _no_empty_path, int encoding_hint ) const -{ - TQString tmp; - if (!m_strPath_encoded.isEmpty() && encoding_hint == 0) - { - tmp = trailingSlash( _trailing, m_strPath_encoded ); - } - else - { - tmp = path( _trailing ); - if ( _no_empty_path && tmp.isEmpty() ) - tmp = "/"; - if (m_iUriMode == Mailto) - { - tmp = encode( tmp, 2, encoding_hint ); - } - else - { - tmp = encode( tmp, 1, encoding_hint ); - } - } - - // TODO apply encoding_hint to the query - if (!m_strQuery_encoded.isNull()) - tmp += '?' + m_strQuery_encoded; - return tmp; -} - -void KURL::setEncodedPath( const TQString& _txt, int encoding_hint ) -{ - m_strPath_encoded = _txt; - - decode( m_strPath_encoded, m_strPath, m_strPath_encoded, encoding_hint ); - // Throw away encoding for local files, makes file-operations faster. - if (m_strProtocol == fileProt) - m_strPath_encoded = TQString::null; - - if ( m_iUriMode == Auto ) - m_iUriMode = URL; -} - - -void KURL::setEncodedPathAndQuery( const TQString& _txt, int encoding_hint ) -{ - int pos = _txt.find( '?' ); - if ( pos == -1 ) - { - setEncodedPath(_txt, encoding_hint); - m_strQuery_encoded = TQString::null; - } - else - { - setEncodedPath(_txt.left( pos ), encoding_hint); - _setQuery(_txt.right(_txt.length() - pos - 1), encoding_hint); - } -} - -TQString KURL::path( int _trailing ) const -{ - return trailingSlash( _trailing, path() ); -} - -bool KURL::isLocalFile() const -{ - if ( (m_strProtocol != fileProt ) || hasSubURL() ) - return false; - - if (m_strHost.isEmpty() || (m_strHost == "localhost")) - return true; - - char hostname[ 256 ]; - hostname[ 0 ] = '\0'; - if (!gethostname( hostname, 255 )) - hostname[sizeof(hostname)-1] = '\0'; - - for(char *p = hostname; *p; p++) - *p = tolower(*p); - - return (m_strHost == hostname); -} - -void KURL::setFileEncoding(const TQString &encoding) -{ - if (!isLocalFile()) - return; - - TQString q = query(); - - if (!q.isEmpty() && (q[0] == '?')) - q = q.mid(1); - - TQStringList args = TQStringList::split('&', q); - for(TQStringList::Iterator it = args.begin(); - it != args.end();) - { - TQString s = decode_string(*it); - if (s.startsWith("charset=")) - it = args.erase(it); - else - ++it; - } - if (!encoding.isEmpty()) - args.append("charset="+encode_string(encoding)); - - if (args.isEmpty()) - _setQuery(TQString::null); - else - _setQuery(args.join("&")); -} - -TQString KURL::fileEncoding() const -{ - if (!isLocalFile()) - return TQString::null; - - TQString q = query(); - - if (q.isEmpty()) - return TQString::null; - - if (q[0] == '?') - q = q.mid(1); - - TQStringList args = TQStringList::split('&', q); - for(TQStringList::ConstIterator it = args.begin(); - it != args.end(); - ++it) - { - TQString s = decode_string(*it); - if (s.startsWith("charset=")) - return s.mid(8); - } - return TQString::null; -} - -bool KURL::hasSubURL() const -{ - if ( m_strProtocol.isEmpty() || m_bIsMalformed ) - return false; - if (m_strRef_encoded.isEmpty()) - return false; - if (m_strRef_encoded.startsWith("gzip:")) - return true; - if (m_strRef_encoded.startsWith("bzip:")) - return true; - if (m_strRef_encoded.startsWith("bzip2:")) - return true; - if (m_strRef_encoded.startsWith("tar:")) - return true; - if (m_strRef_encoded.startsWith("ar:")) - return true; - if (m_strRef_encoded.startsWith("zip:")) - return true; - if ( m_strProtocol == "error" ) // anything that starts with error: has suburls - return true; - return false; -} - -TQString KURL::url( int _trailing, int encoding_hint ) const -{ - if( m_bIsMalformed ) - { - // Return the whole url even when the url is - // malformed. Under such conditions the url - // is stored in m_strProtocol. - return m_strProtocol; - } - - TQString u = m_strProtocol; - if (!u.isEmpty()) - u += ":"; - - if ( hasHost() || (m_strProtocol == fileProt) ) - { - u += "//"; - if ( hasUser() ) - { - u += encode(m_strUser, 0, encoding_hint); - if ( hasPass() ) - { - u += ":"; - u += encode(m_strPass, 0, encoding_hint); - } - u += "@"; - } - if ( m_iUriMode == URL ) - { - bool IPv6 = (m_strHost.find(':') != -1); - if (IPv6) - u += '[' + m_strHost + ']'; - else - u += encodeHost(m_strHost, true, encoding_hint); - if ( m_iPort != 0 ) { - TQString buffer; - buffer.sprintf( ":%u", m_iPort ); - u += buffer; - } - } - else - { - u += m_strHost; - } - } - - if ( m_iUriMode == URL || m_iUriMode == Mailto ) - u += encodedPathAndQuery( _trailing, false, encoding_hint ); - else - u += encode( m_strPath, 21, encoding_hint, true ); - - if ( hasRef() ) - { - u += "#"; - u += m_strRef_encoded; - } - - return u; -} - -TQString KURL::prettyURL( int _trailing ) const -{ - if( m_bIsMalformed ) - { - // Return the whole url even when the url is - // malformed. Under such conditions the url - // is stored in m_strProtocol. - return m_strProtocol; - } - - TQString u = m_strProtocol; - if (!u.isEmpty()) - u += ":"; - - if ( hasHost() || (m_strProtocol == fileProt) ) - { - u += "//"; - if ( hasUser() ) - { - u += encode(m_strUser, 0, 0); - // Don't show password! - u += "@"; - } - if ( m_iUriMode == URL ) - { - bool IPv6 = (m_strHost.find(':') != -1); - if (IPv6) - { - u += '[' + m_strHost + ']'; - } - else - { - u += lazy_encode(m_strHost); - } - } - else - { - u += lazy_encode(m_strHost); - } - if ( m_iPort != 0 ) { - TQString buffer; - buffer.sprintf( ":%u", m_iPort ); - u += buffer; - } - } - - if (m_iUriMode == Mailto) - { - u += lazy_encode( m_strPath, false ); - } - else - { - u += trailingSlash( _trailing, lazy_encode( m_strPath ) ); - } - - if (!m_strQuery_encoded.isNull()) - u += '?' + m_strQuery_encoded; - - if ( hasRef() ) - { - u += "#"; - u += m_strRef_encoded; - } - - return u; -} - -TQString KURL::prettyURL( int _trailing, AdjustementFlags _flags) const -{ - TQString u = prettyURL(_trailing); - if (_flags & StripFileProtocol && u.startsWith("file://")) { - u.remove(0, 7); -#ifdef Q_WS_WIN - return TQDir::convertSeparators(u); -#endif - } - return u; -} - -TQString KURL::pathOrURL() const -{ - if ( isLocalFile() && m_strRef_encoded.isNull() && m_strQuery_encoded.isNull() ) { - return path(); - } else { - return prettyURL(); - } -} - -TQString KURL::htmlURL() const -{ - return TQStyleSheet::escape(prettyURL()); -} - -KURL::List KURL::split( const KURL& _url ) -{ - TQString ref; - KURL::List lst; - KURL url = _url; - - while(true) - { - KURL u = url; - u.m_strRef_encoded = TQString::null; - lst.append(u); - if (url.hasSubURL()) - { - url = KURL(url.m_strRef_encoded); - } - else - { - ref = url.m_strRef_encoded; - break; - } - } - - // Set HTML ref in all URLs. - KURL::List::Iterator it; - for( it = lst.begin() ; it != lst.end(); ++it ) - { - (*it).m_strRef_encoded = ref; - } - - return lst; -} - -KURL::List KURL::split( const TQString& _url ) -{ - return split(KURL(_url)); -} - -KURL KURL::join( const KURL::List & lst ) -{ - if (lst.isEmpty()) return KURL(); - KURL tmp; - - KURL::List::ConstIterator first = lst.fromLast(); - for( KURL::List::ConstIterator it = first; it != lst.end(); --it ) - { - KURL u(*it); - if (it != first) - { - if (!u.m_strRef_encoded) u.m_strRef_encoded = tmp.url(); - else u.m_strRef_encoded += "#" + tmp.url(); // Support more than one suburl thingy - } - tmp = u; - } - - return tmp; -} - -TQString KURL::fileName( bool _strip_trailing_slash ) const -{ - TQString fname; - if (hasSubURL()) { // If we have a suburl, then return the filename from there - KURL::List list = KURL::split(*this); - KURL::List::Iterator it = list.fromLast(); - return (*it).fileName(_strip_trailing_slash); - } - const TQString &path = m_strPath; - - int len = path.length(); - if ( len == 0 ) - return fname; - - if ( _strip_trailing_slash ) - { - while ( len >= 1 && path[ len - 1 ] == TQChar('/') ) - len--; - } - else if ( path[ len - 1 ] == TQChar('/') ) - return fname; - - // Does the path only consist of '/' characters ? - if ( len == 1 && path[ 0 ] == TQChar('/') ) - return fname; - - // Skip last n slashes - int n = 1; - if (!m_strPath_encoded.isEmpty()) - { - // This is hairy, we need the last unencoded slash. - // Count in the encoded string how many encoded slashes follow the last - // unencoded one. - int i = m_strPath_encoded.findRev( TQChar('/'), len - 1 ); - TQString fileName_encoded = m_strPath_encoded.mid(i+1); - n += fileName_encoded.contains("%2f", false); - } - int i = len; - do { - i = path.findRev( TQChar('/'), i - 1 ); - } - while (--n && (i > 0)); - - // If ( i == -1 ) => the first character is not a '/' - // So it's some URL like file:blah.tgz, return the whole path - if ( i == -1 ) { - if ( len == (int)path.length() ) - fname = path; - else - // Might get here if _strip_trailing_slash is true - fname = path.left( len ); - } - else - { - fname = path.mid( i + 1, len - i - 1 ); // TO CHECK - } - return fname; -} - -void KURL::addPath( const TQString& _txt ) -{ - if (hasSubURL()) - { - KURL::List lst = split( *this ); - KURL &u = lst.last(); - u.addPath(_txt); - *this = join( lst ); - return; - } - - m_strPath_encoded = TQString::null; - - if ( _txt.isEmpty() ) - return; - - int i = 0; - int len = m_strPath.length(); - // Add the trailing '/' if it is missing - if ( _txt[0] != (QChar)'/' && ( len == 0 || m_strPath[ len - 1 ] != (QChar)'/' ) ) - m_strPath += "/"; - - // No double '/' characters - i = 0; - if ( len != 0 && m_strPath[ len - 1 ] == (QChar)'/' ) - { - while( _txt[i] == (QChar)'/' ) - ++i; - } - - m_strPath += _txt.mid( i ); -} - -TQString KURL::directory( bool _strip_trailing_slash_from_result, - bool _ignore_trailing_slash_in_path ) const -{ - TQString result = m_strPath_encoded.isEmpty() ? m_strPath : m_strPath_encoded; - if ( _ignore_trailing_slash_in_path ) - result = trailingSlash( -1, result ); - - if ( result.isEmpty() || result == "/" ) - return result; - - int i = result.findRev( "/" ); - // If ( i == -1 ) => the first character is not a '/' - // So it's some URL like file:blah.tgz, with no path - if ( i == -1 ) - return TQString::null; - - if ( i == 0 ) - { - result = "/"; - return result; - } - - if ( _strip_trailing_slash_from_result ) - result = result.left( i ); - else - result = result.left( i + 1 ); - - if (!m_strPath_encoded.isEmpty()) - result = decode(result); - - return result; -} - - -bool KURL::cd( const TQString& _dir ) -{ - if ( _dir.isEmpty() || m_bIsMalformed ) - return false; - - if (hasSubURL()) - { - KURL::List lst = split( *this ); - KURL &u = lst.last(); - u.cd(_dir); - *this = join( lst ); - return true; - } - - // absolute path ? - if ( _dir[0] == (QChar)'/' ) - { - m_strPath_encoded = TQString::null; - m_strPath = _dir; - setHTMLRef( TQString::null ); - m_strQuery_encoded = TQString::null; - return true; - } - - // Users home directory on the local disk ? - if ( ( _dir[0] == (QChar)'~' ) && ( m_strProtocol == fileProt )) - { - m_strPath_encoded = TQString::null; - m_strPath = TQDir::homeDirPath(); - m_strPath += "/"; - m_strPath += _dir.right(m_strPath.length() - 1); - setHTMLRef( TQString::null ); - m_strQuery_encoded = TQString::null; - return true; - } - - // relative path - // we always work on the past of the first url. - // Sub URLs are not touched. - - // append '/' if necessary - TQString p = path(1); - p += _dir; - p = cleanpath( p, true, false ); - setPath( p ); - - setHTMLRef( TQString::null ); - m_strQuery_encoded = TQString::null; - - return true; -} - -KURL KURL::upURL( ) const -{ - if (!query().isEmpty()) - { - KURL u(*this); - u._setQuery(TQString::null); - return u; - }; - - if (!hasSubURL()) - { - KURL u(*this); - - u.cd("../"); - - return u; - } - - // We have a subURL. - KURL::List lst = split( *this ); - if (lst.isEmpty()) - return KURL(); // Huh? - while (true) - { - KURL &u = lst.last(); - TQString old = u.path(); - u.cd("../"); - if (u.path() != old) - break; // Finshed. - if (lst.count() == 1) - break; // Finished. - lst.remove(lst.fromLast()); - } - return join( lst ); -} - -TQString KURL::htmlRef() const -{ - if ( !hasSubURL() ) - { - return decode( ref() ); - } - - List lst = split( *this ); - return decode( (*lst.begin()).ref() ); -} - -TQString KURL::encodedHtmlRef() const -{ - if ( !hasSubURL() ) - { - return ref(); - } - - List lst = split( *this ); - return (*lst.begin()).ref(); -} - -void KURL::setHTMLRef( const TQString& _ref ) -{ - if ( !hasSubURL() ) - { - m_strRef_encoded = encode( _ref, 0, 0 /*?*/); - return; - } - - List lst = split( *this ); - - (*lst.begin()).setRef( encode( _ref, 0, 0 /*?*/) ); - - *this = join( lst ); -} - -bool KURL::hasHTMLRef() const -{ - if ( !hasSubURL() ) - { - return hasRef(); - } - - List lst = split( *this ); - return (*lst.begin()).hasRef(); -} - -void -KURL::setProtocol( const TQString& _txt ) -{ - m_strProtocol = _txt; - if ( m_iUriMode == Auto ) m_iUriMode = uriModeForProtocol( m_strProtocol ); - m_bIsMalformed = false; -} - -void -KURL::setUser( const TQString& _txt ) -{ - if ( _txt.isEmpty() ) - m_strUser = TQString::null; - else - m_strUser = _txt; -} - -void -KURL::setPass( const TQString& _txt ) -{ - if ( _txt.isEmpty() ) - m_strPass = TQString::null; - else - m_strPass = _txt; -} - -void -KURL::setHost( const TQString& _txt ) -{ - if ( m_iUriMode == Auto ) - m_iUriMode = URL; - switch ( m_iUriMode ) - { - case URL: -#ifndef KDE_QT_ONLY - m_strHost = KIDNA::toUnicode(_txt); - if (m_strHost.isEmpty()) - m_strHost = _txt.lower(); // Probably an invalid hostname, but... -#else - m_strHost = _txt.lower(); -#endif - break; - default: - m_strHost = _txt; - break; - } -} - -void -KURL::setPort( unsigned short int _p ) -{ - m_iPort = _p; -} - -void KURL::setPath( const TQString & path ) -{ - if (isEmpty()) - m_bIsMalformed = false; - if (m_strProtocol.isEmpty()) - { - m_strProtocol = fileProt; - } - m_strPath = path; - m_strPath_encoded = TQString::null; - if ( m_iUriMode == Auto ) - m_iUriMode = URL; -} - -void KURL::setDirectory( const TQString &dir) -{ - if ( dir.endsWith("/")) - setPath(dir); - else - setPath(dir+"/"); -} - -void KURL::setQuery( const TQString &_txt, int encoding_hint) -{ - if (_txt[0] == (QChar)'?') - _setQuery( _txt.length() > 1 ? _txt.mid(1) : "" /*empty, not null*/, encoding_hint ); - else - _setQuery( _txt, encoding_hint ); -} - -// This is a private function that expects a query without '?' -void KURL::_setQuery( const TQString &_txt, int encoding_hint) -{ - m_strQuery_encoded = _txt; - if (!_txt.length()) - return; - - int l = m_strQuery_encoded.length(); - int i = 0; - TQString result; - while (i < l) - { - int s = i; - // Re-encode. Break encoded string up according to the reserved - // characters '&:;=/?' and re-encode part by part. - while(i < l) - { - char c = m_strQuery_encoded[i].latin1(); - if ((c == '&') || (c == ':') || (c == ';') || - (c == '=') || (c == '/') || (c == '?')) - break; - i++; - } - if (i > s) - { - TQString tmp = m_strQuery_encoded.mid(s, i-s); - TQString newTmp; - decode( tmp, newTmp, tmp, encoding_hint, false ); - result += tmp; - } - if (i < l) - { - result += m_strQuery_encoded[i]; - i++; - } - } - m_strQuery_encoded = result; -} - -TQString KURL::query() const -{ - if (m_strQuery_encoded.isNull()) - return TQString::null; - return '?'+m_strQuery_encoded; -} - -TQString KURL::decode_string(const TQString &str, int encoding_hint) -{ - return decode(str, encoding_hint); -} - -TQString KURL::encode_string(const TQString &str, int encoding_hint) -{ - return encode(str, 1, encoding_hint); -} - -TQString KURL::encode_string_no_slash(const TQString &str, int encoding_hint) -{ - return encode(str, 0, encoding_hint); -} - -bool urlcmp( const TQString& _url1, const TQString& _url2 ) -{ - // Both empty ? - if ( _url1.isEmpty() && _url2.isEmpty() ) - return true; - // Only one empty ? - if ( _url1.isEmpty() || _url2.isEmpty() ) - return false; - - KURL::List list1 = KURL::split( _url1 ); - KURL::List list2 = KURL::split( _url2 ); - - // Malformed ? - if ( list1.isEmpty() || list2.isEmpty() ) - return false; - - return ( list1 == list2 ); -} - -bool urlcmp( const TQString& _url1, const TQString& _url2, bool _ignore_trailing, bool _ignore_ref ) -{ - // Both empty ? - if ( _url1.isEmpty() && _url2.isEmpty() ) - return true; - // Only one empty ? - if ( _url1.isEmpty() || _url2.isEmpty() ) - return false; - - KURL::List list1 = KURL::split( _url1 ); - KURL::List list2 = KURL::split( _url2 ); - - // Malformed ? - if ( list1.isEmpty() || list2.isEmpty() ) - return false; - - unsigned int size = list1.count(); - if ( list2.count() != size ) - return false; - - if ( _ignore_ref ) - { - (*list1.begin()).setRef(TQString::null); - (*list2.begin()).setRef(TQString::null); - } - - KURL::List::Iterator it1 = list1.begin(); - KURL::List::Iterator it2 = list2.begin(); - for( ; it1 != list1.end() ; ++it1, ++it2 ) - if ( !(*it1).equals( *it2, _ignore_trailing ) ) - return false; - - return true; -} - -TQMap< TQString, TQString > KURL::queryItems( int options ) const { - return queryItems(options, 0); -} - -TQMap< TQString, TQString > KURL::queryItems( int options, int encoding_hint ) const { - if ( m_strQuery_encoded.isEmpty() ) - return TQMap<TQString,TQString>(); - - TQMap< TQString, TQString > result; - TQStringList items = TQStringList::split( '&', m_strQuery_encoded ); - for ( TQStringList::const_iterator it = items.begin() ; it != items.end() ; ++it ) { - int equal_pos = (*it).find( '=' ); - if ( equal_pos > 0 ) { // = is not the first char... - TQString name = (*it).left( equal_pos ); - if ( options & CaseInsensitiveKeys ) - name = name.lower(); - TQString value = (*it).mid( equal_pos + 1 ); - if ( value.isEmpty() ) - result.insert( name, TQString::tqfromLatin1("") ); - else { - // ### why is decoding name not necessary? - value.replace( '+', ' ' ); // + in queries means space - result.insert( name, decode_string( value, encoding_hint ) ); - } - } else if ( equal_pos < 0 ) { // no = - TQString name = (*it); - if ( options & CaseInsensitiveKeys ) - name = name.lower(); - result.insert( name, TQString::null ); - } - } - - return result; -} - -TQString KURL::queryItem( const TQString& _item ) const -{ - return queryItem( _item, 0 ); -} - -TQString KURL::queryItem( const TQString& _item, int encoding_hint ) const -{ - TQString item = _item + '='; - if ( m_strQuery_encoded.length() <= 1 ) - return TQString::null; - - TQStringList items = TQStringList::split( '&', m_strQuery_encoded ); - unsigned int _len = item.length(); - for ( TQStringList::ConstIterator it = items.begin(); it != items.end(); ++it ) - { - if ( (*it).startsWith( item ) ) - { - if ( (*it).length() > _len ) - { - TQString str = (*it).mid( _len ); - str.replace( '+', ' ' ); // + in queries means space. - return decode_string( str, encoding_hint ); - } - else // empty value - return TQString::tqfromLatin1(""); - } - } - - return TQString::null; -} - -void KURL::removeQueryItem( const TQString& _item ) -{ - TQString item = _item + '='; - if ( m_strQuery_encoded.length() <= 1 ) - return; - - TQStringList items = TQStringList::split( '&', m_strQuery_encoded ); - for ( TQStringList::Iterator it = items.begin(); it != items.end(); ) - { - if ( (*it).startsWith( item ) || (*it == _item) ) - { - TQStringList::Iterator deleteIt = it; - ++it; - items.remove(deleteIt); - } - else - { - ++it; - } - } - m_strQuery_encoded = items.join( "&" ); -} - -void KURL::addQueryItem( const TQString& _item, const TQString& _value, int encoding_hint ) -{ - TQString item = _item + '='; - TQString value = encode( _value, 0, encoding_hint ); - - if (!m_strQuery_encoded.isEmpty()) - m_strQuery_encoded += '&'; - m_strQuery_encoded += item + value; -} - -// static -KURL KURL::fromPathOrURL( const TQString& text ) -{ - if ( text.isEmpty() ) - return KURL(); - - KURL url; - if (!TQDir::isRelativePath(text)) - url.setPath( text ); - else - url = text; - - return url; -} - -static TQString _relativePath(const TQString &base_dir, const TQString &path, bool &isParent) -{ - TQString _base_dir(TQDir::cleanDirPath(base_dir)); - TQString _path(TQDir::cleanDirPath(path.isEmpty() || (path[0] != (QChar)'/') ? _base_dir+"/"+path : path)); - - if (_base_dir.isEmpty()) - return _path; - - if (_base_dir[_base_dir.length()-1] != '/') - _base_dir.append('/'); - - TQStringList list1 = TQStringList::split('/', _base_dir); - TQStringList list2 = TQStringList::split('/', _path); - - // Find where they meet - uint level = 0; - uint maxLevel = QMIN(list1.count(), list2.count()); - while((level < maxLevel) && (list1[level] == list2[level])) level++; - - TQString result; - // Need to go down out of the first path to the common branch. - for(uint i = level; i < list1.count(); i++) - result.append("../"); - - // Now up up from the common branch to the second path. - for(uint i = level; i < list2.count(); i++) - result.append(list2[i]).append("/"); - - if ((level < list2.count()) && (path[path.length()-1] != (QChar)'/')) - result.truncate(result.length()-1); - - isParent = (level == list1.count()); - - return result; -} - -TQString KURL::relativePath(const TQString &base_dir, const TQString &path, bool *isParent) -{ - bool parent = false; - TQString result = _relativePath(base_dir, path, parent); - if (parent) - result.prepend("./"); - - if (isParent) - *isParent = parent; - - return result; -} - - -TQString KURL::relativeURL(const KURL &base_url, const KURL &url, int encoding_hint) -{ - if ((url.protocol() != base_url.protocol()) || - (url.host() != base_url.host()) || - (url.port() && url.port() != base_url.port()) || - (url.hasUser() && url.user() != base_url.user()) || - (url.hasPass() && url.pass() != base_url.pass())) - { - return url.url(0, encoding_hint); - } - - TQString relURL; - - if ((base_url.path() != url.path()) || (base_url.query() != url.query())) - { - bool dummy; - TQString basePath = base_url.directory(false, false); - relURL = encode( _relativePath(basePath, url.path(), dummy), 1, encoding_hint); - relURL += url.query(); - } - - if ( url.hasRef() ) - { - relURL += "#"; - relURL += url.ref(); - } - - if ( relURL.isEmpty() ) - return "./"; - - return relURL; -} - -int KURL::uriMode() const -{ - return m_iUriMode; -} - -KURL::URIMode KURL::uriModeForProtocol(const TQString& protocol) -{ -#ifndef KDE_QT_ONLY - KURL::URIMode mode = Auto; - if (protocol == fileProt) - return URL; - if (KGlobal::_instance) - mode = KProtocolInfo::uriParseMode(protocol); - if (mode == Auto ) { -#else - KURL::URIMode mode = Auto; -#endif - if ( protocol == "ed2k" || protocol == "sig2dat" || protocol == "slsk" || protocol == "data" ) mode = RawURI; - else if ( protocol == "mailto" ) mode = Mailto; - else mode = URL; -#ifndef KDE_QT_ONLY - } -#endif - return mode; -} diff --git a/kdecore/kurl.h b/kdecore/kurl.h deleted file mode 100644 index eaa0291b9..000000000 --- a/kdecore/kurl.h +++ /dev/null @@ -1,1828 +0,0 @@ -/* This file is part of the KDE libraries - * Copyright (C) 1999 Torben Weis <weis@kde.org> - * - * 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 __kurl_h__ -#define __kurl_h__ - -#include <tqstring.h> -#include <tqvaluelist.h> -#include "kdelibs_export.h" - -class TQUrl; -class TQStringList; -template <typename K, typename V> class TQMap; - -class KURLPrivate; - -// Defines that file-urls look like file:///path/file instead of file:/path/file -#define KURL_TRIPLE_SLASH_FILE_PROT - -/** - * @brief Represents and parses a URL - * - * A prototypical URL looks like: - * @code - * protocol://user:password@hostname:port/path/to/file.ext#reference - * @endcode - * - * KURL handles escaping of URLs. This means that the specification - * of a full URL will differ from the corresponding string that would specify a - * local file or directory in file-operations like fopen. This is because an URL - * doesn't allow certain characters and escapes them. - * - * For examle: - * - '#' -> "%23" - * (In a URL the hash-character @c '#' is used to specify a "reference", i.e. - * the position within a document) - * - space -> "%20" - * - * The constructor KURL(const TQString&) expects a string properly escaped, - * or at least non-ambiguous. - * For instance a local file or directory <tt>"/bar/#foo#"</tt> would have the - * URL <tt>"file:///bar/%23foo%23"</tt>. - * If you have the absolute path and need the URL-escaping you should create - * KURL via the default-constructor and then call setPath(const TQString&): - * @code - * KURL kurl; - * kurl.setPath( "/bar/#foo#" ); - * TQString url = kurl.url(); // -> "file:///bar/%23foo%23" - * @endcode - * - * If you have the URL of a local file or directory and need the absolute path, - * you would use path(). - * @code - * KURL url( "file:///bar/%23foo%23" ); - * ... - * if ( url.isLocalFile() ) - * TQString path = url.path(); // -> "/bar/#foo#" - * @endcode - * - * The other way round: if the user can enter a string, that can be either a - * path or a URL, then you need to use KURL::fromPathOrURL() to build a KURL. - * - * This must also be considered, when you have separated directory and file - * strings and need to put them together. - * While you can simply concatenate normal path strings, you must take care if - * the directory-part is already an escaped URL. - * (This might be needed if the user specifies a relative path, and your - * program supplies the rest from elsewhere.) - * - * Wrong: - * @code - * TQString dirUrl = "file:///bar/"; - * TQString fileName = "#foo#"; - * TQString invalidURL = dirUrl + fileName; // -> "file:///bar/#foo#" won't behave like you would expect. - * @endcode - * Instead you should use addPath(). - * - * Right: - * @code - * KURL url( "file:///bar/" ); - * TQString fileName = "#foo#"; - * url.addPath( fileName ); - * TQString validURL = url.url(); // -> "file:///bar/%23foo%23" - * @endcode - * - * Also consider that some URLs contain the password, but this shouldn't be - * visible. Your program should use prettyURL() every time it displays a - * URL, whether in the GUI or in debug output or... - * - * @code - * KURL url( "ftp://name:password@ftp.faraway.org/bar/%23foo%23"); - * TQString visibleURL = url.prettyURL(); // -> "ftp://name@ftp.faraway.org/bar/%23foo%23" - * @endcode - * Note that prettyURL() doesn't change the character escapes (like <tt>"%23"</tt>). - * Otherwise the URL would be invalid and the user wouldn't be able to use it in another - * context. - * - * KURL has some restrictions regarding the path - * encoding. KURL works internally with the decoded path and - * and encoded query. For example, - * @code - * http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you - * @endcode - * would result in a decoded path <tt>"/cgi-bin/test me.pl"</tt> - * and in the encoded query <tt>"?cmd=Hello%20you"</tt>. - * Since path is internally always encoded you may @em not use - * <tt>"%00"</tt> in the path, although this is OK for the query. - * - * @author Torben Weis <weis@kde.org> - */ -class KDECORE_EXPORT KURL -{ -public: - /** - * Flags to choose how file: URLs are treated when creating their QString - * representation with prettyURL(int,AdjustementFlags) - * - * However it is recommended to use pathOrURL() instead of this variant of prettyURL() - */ - enum AdjustementFlags - { - /** - * Do not treat file: URLs differently - */ - NoAdjustements = 0, - /** - * Strip the file: protocol from the string, i.e. return only the path and - * filename as a local path - */ - StripFileProtocol = 1 - }; - - /** - * Defines the type of URI we are processing. - */ - enum URIMode - { - /** - * Automatically detected. Using this mode, an appropriate processing - * mode will be selected when the URI is first processed. - */ - Auto, - /** - * Invalid URI. This is something that can't be parsed as a URI at all. - * The contents are accessible through the protocol() method. - */ - Invalid, - /** - * Raw URI. This type of URI should not be processed in any way. - * Contents are accessible through the path() method. - */ - RawURI, - /** - * Standards compliant URL. Process as a syntactically correct URL. - */ - URL, - /** - * Mailto URI. path() contains an email address which should have its - * domain part processed as a DNS name. The email address is accessible - * through the path() method. - */ - Mailto - }; - - /** - * KURL::List is a TQValueList that contains KURLs with a few - * convenience methods. - * @see KURL - * @see QValueList - */ - class KDECORE_EXPORT List : public TQValueList<KURL> - { - public: - /** - * Creates an empty List. - */ - List() { } - /** - * @brief Creates a list that contains the given URL as only item - * - * @param url the URL to add - */ - List(const KURL &url); - /** - * @brief Creates a list that contains the URLs from the given list - * - * This equivalent to iterating over the input list and using each item - * as the argument to KURL's constructor, i.e. the resulting list will - * have as many elements as the input list, but not all entries might - * be valid. - * - * @param list the list containing the URLs as strings - * - * @see KURL(const TQString &, int) - */ - List(const TQStringList &list); - /** - * @brief Converts the URLs of this list to a list of strings - * - * This is equivalent to iterating over the list and calling url() on - * each item. - * If you need a list of user visible URLs, i.e. not containing password - * information, iterate over the list yourself and call prettyURL() on - * each item instead. - * - * @return the list of strings - * - * @see KURL::url() - */ - TQStringList toStringList() const; - }; - /** - * @brief Constructs an empty URL - * - * The created instance will also be invalid, see isValid() - */ - KURL(); - - /** - * @brief Destructs the KURL object - */ - ~KURL(); - - /** - * @brief Usual constructor, to construct from a string - * - * @warning It is dangerous to feed UNIX filenames into this function, - * this will work most of the time but not always. - * - * For example <tt>"/home/Torben%20Weis"</tt> will be considered a URL - * pointing to the file <tt>"/home/Torben Weis"</tt> instead - * of to the file <tt>"/home/Torben%20Weis"</tt>. - * - * This means that if you have a usual UNIX like path you should not use - * this constructor. Instead use fromPathOrURL() - * - * @param url a URL, not a filename. If the URL does not have a protocol - * part, @c "file:" is assumed - * @param encoding_hint MIB of original encoding of URL. - * See TQTextCodec::mibEnum() - * - * @see fromPathOrURL() - */ - KURL( const TQString& url, int encoding_hint = 0 ); - /** - * @brief Constructor taking an URL encoded in a C string - * - * Constructor taking a char * @p url, which is an @em encoded representation - * of the URL, exactly like the usual constructor. This is useful when - * the URL, in its encoded form, is strictly ASCII. - * - * @warning It is dangerous to feed UNIX filenames into this function, - * this will work most of the time but not always. - * - * For example <tt>"/home/Torben%20Weis"</tt> will be considered a URL - * pointing to the file <tt>"/home/Torben Weis"</tt> instead - * of to the file <tt>"/home/Torben%20Weis"</tt>. - * - * This means that if you have a usual UNIX like path you should not use - * this constructor. Instead use fromPathOrURL() - * - * @param url an encoded URL. If the URL does not have a protocol part, - * @c "file:" is assumed - * @param encoding_hint MIB of original encoding of URL. - * See TQTextCodec::mibEnum() - * - * @see fromPathOrURL() - * @see TQString::tqfromLatin1() - */ - KURL( const char * url, int encoding_hint = 0 ); - /** - * @brief Constructor taking an URL encoded in a QCString - * - * Constructor taking a TQCString @p url, which is an @em encoded - * representation of the URL, exactly like the usual constructor. This is - * useful when the URL, in its encoded form, is strictly ASCII. - * - * @warning It is dangerous to feed UNIX filenames into this function, - * this will work most of the time but not always. - * - * For example <tt>"/home/Torben%20Weis"</tt> will be considered a URL - * pointing to the file <tt>"/home/Torben Weis"</tt> instead - * of to the file <tt>"/home/Torben%20Weis"</tt>. - * - * This means that if you have a usual UNIX like path you should not use - * this constructor. Instead use fromPathOrURL() - * - * @param url A encoded URL. If the URL does not have a protocol part, - * @c "file:" is assumed - * @param encoding_hint MIB of original encoding of URL. - * See TQTextCodec::mibEnum() - * - * @see fromPathOrURL() - * @see TQString::tqfromLatin1() - */ - KURL( const TQCString& url, int encoding_hint = 0 ); - - /** - * @brief Copy constructor - * - * @param u the KURL to copy - */ - KURL( const KURL& u ); - /** - * @brief Constructor taking a Qt URL - * - * Converts from a Qt URL. - * - * @param u the QUrl - */ - KURL( const TQUrl &u ); - /** - * @brief Constructor allowing relative URLs - * - * @warning It is dangerous to feed UNIX filenames into this function, - * this will work most of the time but not always. - * - * For example <tt>"/home/Torben%20Weis"</tt> will be considered a URL - * pointing to the file <tt>"/home/Torben Weis"</tt> instead - * of to the file <tt>"/home/Torben%20Weis"</tt>. - * - * This means that if you have a usual UNIX like path you should not use - * this constructor. Instead use fromPathOrURL() - * - * @param _baseurl The base url. - * @param _rel_url A relative or absolute URL. - * If this is an absolute URL then @p _baseurl will be ignored. - * If this is a relative URL it will be combined with @p _baseurl. - * Note that @p _rel_url should be encoded too, in any case. - * So do NOT pass a path here (use setPath() or addPath() or - * fromPathOrURL() instead) - * @param encoding_hint MIB of original encoding of URL. - * See TQTextCodec::mibEnum() - * - * @see fromPathOrURL() - */ - KURL( const KURL& _baseurl, const TQString& _rel_url, int encoding_hint=0 ); - - /** - * @brief Returns the protocol for the URL - * - * Examples for a protocol string are @c "file", @c "http", etc. but also - * @c "mailto:" and other pseudo protocols. - * - * @return the protocol of the URL, does not include the colon. If the - * URL is malformed, @c TQString::null will be returned - * - * @see setProtocol() - * @see isValid() - */ - TQString protocol() const { return m_bIsMalformed ? TQString::null : m_strProtocol; } - /** - * @brief Sets the protocol for the URL - * - * Examples for a protocol string are @c "file", @c "http", etc. but also - * @c "mailto:" and other pseudo protocols. - * - * @param _txt the new protocol of the URL (without colon) - * - * @see protocol() - */ - void setProtocol( const TQString& _txt ); - - /** - * @brief Returns the URI processing mode for the URL - * - * @return the URI processing mode set for this URL - * - * @see URIMode - * @see uriModeForProtocol() - * - * @since 3.2 - */ - int uriMode() const; - - /** - * @brief Returns the decoded user name (login, user id, etc) included in - * the URL - * - * @return the user name or @c TQString::null if there is no user name - * - * @see setUser() - * @see hasUser() - */ - TQString user() const { return m_strUser; } - /** - * @brief Sets the user name (login, user id, etc) to include in the URL - * - * Special characters in the user name will appear encoded in the URL. - * If there is a password associated with the user, it can be set using - * setPass(). - * - * @param _txt the name of the user or @c TQString::null to remove the user - * - * @see user() - * @see hasUser() - * @see hasPass() - */ - void setUser( const TQString& _txt ); - /** - * @brief Tests if this URL has a user name included in it - * - * @return @c true if the URL has an non-empty user name - * - * @see user() - * @see setUser() - * @see hasPass() - */ - bool hasUser() const { return !m_strUser.isEmpty(); } - - /** - * @brief Returns the decoded password (corresponding to user()) included - * in the URL - * - * @note a password can only appear in a URL string if you also set - * a user, see setUser(). - * - * @return the password or @c TQString::null if it does not exist - * - * @see setPass() - * @see hasPass() - * @see hasUser() - */ - TQString pass() const { return m_strPass; } - /** - * @brief Sets the password (corresponding to user()) to include in the URL - * - * Special characters in the password will appear encoded in the URL. - * @note a password can only appear in a URL string if you also set - * a user, see setUser(). - * - * @param _txt the password to set or @c TQString::null to remove the password - * - * @see pass() - * @see hasPass() - * @see hasUser() - */ - void setPass( const TQString& _txt ); - /** - * @brief Tests if this URL has a password included in it - * - * @note a password can only appear in a URL string if you also set - * a user, see setUser(). - * - * @return @c true if there is a non-empty password set - * - * @see pass() - * @see setPass() - * @see hasUser() - */ - bool hasPass() const { return !m_strPass.isEmpty(); } - - /** - * @brief Returns the decoded hostname included in the URL - * - * @return the name of the host or @c TQString::null if no host is set - * - * @see setHost() - * @see hasHost() - */ - TQString host() const { return m_strHost; } - - /** - * @brief Sets the hostname to include in the URL - * - * Special characters in the hostname will appear encoded in the URL. - * - * @param _txt the new name of the host or TQString::null to remove the host - * - * @see host() - * @see hasHost() - */ - void setHost( const TQString& _txt ); - /** - * @brief Tests if this URL has a hostname included in it - * - * @return @c true if the URL has a non-empty host - * - * @see host() - * @see setHost() - */ - bool hasHost() const { return !m_strHost.isEmpty(); } - - /** - * @brief Returns the port number included in the URL - * - * @return the port number or @c 0 if there is no port number specified in - * the URL - * - * @see setPort() - * @see host() - */ - unsigned short int port() const { return m_iPort; } - /** - * @brief Sets the port number to include in the URL - * - * @param _p the new port number or @c 0 to have no port number - * - * @see port() - * @see setHost() - */ - void setPort( unsigned short int _p ); - - /** - * @brief Returns the current decoded path - * - * This does @em not include the query. - * - * @return the path of the URL (without query), or @c TQString::null if no - * path is set - * - * @see path(int) - * @see setPath() - * @see hasPath() - */ - TQString path() const { return m_strPath; } - - /** - * @brief Returns the current decoded path - * - * This does @em not include the query, see query() for accessing it. - * - * The @p _trailing parameter allows to ensure the existance or absence of - * the last (trailing) @c '/' character in the path. - * If the URL has no path, then no @c '/' is added anyway. - * And on the other side: if the path is just @c "/", then this character - * won't be stripped. - * - * Reason: <tt>"ftp://weis@host"</tt> means something completely different - * than <tt>"ftp://weis@host/"</tt>. - * So adding or stripping the '/' would really alter the URL, while - * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same - * directory. - * - * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing - * @c '/', @c +1 adds a trailing @c '/' if there is none yet - * and @c 0 returns the path unchanged - * - * @return the path of the URL (without query), or @c TQString::null if no - * path is set - * - * @see path() - * @see setPath() - * @see hasPath() - * @see adjustPath() - */ - TQString path( int _trailing ) const; - - /** - * @brief Sets the decoded path of the URL - * - * This does @em not changed the query, see setQuery() for that. - * - * The @p path is considered to be decoded, i.e. characters not allowed in - * path, for example @c '?' will be encoded and does not indicate the - * beginning of the query part. Something that might look encoded, - * like @c "%3f" will not become decoded. - * - * @param path the new, decoded, path or @c TQString::null to remove the path - * - * @see path() - * @see path(int) - * @see hasPath() - */ - void setPath( const TQString& path ); - - /** - * @brief Tests if this URL has a path included in it - * - * @return @c true if there is a non-empty path - * - * @see path() - * @see setPath() - */ - bool hasPath() const { return !m_strPath.isEmpty(); } - - /** - * @brief Resolves @c "." and @c ".." components in path - * - * Some servers seem not to like the removal of extra @c '/' - * even though it is against the specification in RFC 2396. - * - * @param cleanDirSeparator if @c true, occurrences of consecutive - * directory separators (e.g. <tt>"/foo//bar"</tt>) are cleaned up as - * well - * - * @see hasPath() - * @see adjustPath() - */ - void cleanPath(bool cleanDirSeparator = true); - - /** - * @brief Adds or removes a trailing slash to/from the path - * - * The @p _trailing parameter allows to ensure the existance or absence of - * the last (trailing) @c '/' character in the path. - * If the URL has no path, then no @c '/' is added anyway. - * And on the other side: if the path is just @c "/", then this character - * won't be stripped. - * - * Reason: <tt>"ftp://weis@host"</tt> means something completely different - * than <tt>"ftp://weis@host/"</tt>. - * So adding or stripping the '/' would really alter the URL, while - * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same - * directory. - * - * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing - * @c '/', @c +1 adds a trailing @c '/' if there is none yet - * and @c 0 returns the path unchanged - * - * @see hasPath() - * @see cleanPath() - */ - void adjustPath(int _trailing); - - /** - * @brief Sets both path and query of the URL in their encoded form - * - * This is useful for HTTP. It looks first for @c '?' and decodes then, - * see setEncodedPath(). - * The encoded path is the concatenation of the current path and the query. - * - * @param _txt the new encoded path and encoded query - * @param encoding_hint MIB of original encoding of @p _txt . - * See TQTextCodec::mibEnum() - * - * @see encodedPathAndQuery() - * @see setPath() - * @see setQuery() - */ - void setEncodedPathAndQuery( const TQString& _txt, int encoding_hint = 0 ); - - /** - * @brief Sets the (already encoded) path of the URL - * - * @param _txt the new encoded path - * @param encoding_hint MIB of original encoding of @p _txt . - * See TQTextCodec::mibEnum() - * - * @see setEncodedPathAndQuery() - * @see setPath() - */ - void setEncodedPath(const TQString& _txt, int encoding_hint = 0 ); - - /** - * @brief Returns the encoded path and the query - * - * The @p _trailing parameter allows to ensure the existance or absence of - * the last (trailing) @c '/' character in the path. - * If the URL has no path, then no @c '/' is added anyway. - * And on the other side: if the path is just @c "/", then this character - * won't be stripped. - * - * Reason: <tt>"ftp://weis@host"</tt> means something completely different - * than <tt>"ftp://weis@host/"</tt>. - * So adding or stripping the '/' would really alter the URL, while - * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same - * directory. - * - * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing - * @c '/', @c +1 adds a trailing @c '/' if there is none yet - * and @c 0 returns the path unchanged - * @param _no_empty_path if set to @c true then an empty path is substituted - * by @c "/" - * @param encoding_hint MIB of desired encoding of URL. - * See TQTextCodec::mibEnum() - * - * @return the concatenation of the encoded path , @c '?' and the - * encoded query - * - * @see setEncodedPathAndQuery() - * @see path() - * @see query() - */ - TQString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const; - - /** - * @brief Sets the encoded query of the URL - * - * The query should start with a @c '?'. If it doesn't @c '?' is prepended. - * - * @param _txt this is considered to be encoded. This has a good reason: - * the query may contain the @c '0' character - * - * @param encoding_hint MIB of the encoding. Reserved, should be @c 0 . - * See TQTextCodec::mibEnum() - * - * @see query() - */ - void setQuery( const TQString& _txt, int encoding_hint = 0); - - /** - * @brief Returns the encoded query of the URL - * - * The query may contain the @c '0' character. - * If a query is present it always starts with a @c '?'. - * A single @c '?' means an empty query. - * An empty string means no query. - * - * @return the encoded query or @c TQString::null if there is none - * - * @see setQuery() - */ - TQString query() const; - - /** - * @brief Returns the encoded reference of the URL - * - * The reference is @em never decoded automatically. - * - * @return the undecoded reference, or @c TQString::null if there is none - * - * @see setRef() - * @see hasRef() - * @see htmlRef() - */ - TQString ref() const { return m_strRef_encoded; } - - /** - * @brief Sets the encoded reference part (everything after @c '#') - * - * This is considered to be encoded, i.e. characters that are not allowed - * as part of the reference will @em not be encoded. - * - * @param _txt the encoded reference or @c TQString::null to remove it - * - * @see ref() - * @see hasRef() - */ - void setRef( const TQString& _txt ) { m_strRef_encoded = _txt; } - - /** - * @brief Tests if the URL has a reference part - * - * @return @c true if the URL has a reference part. In a URL like - * <tt>"http://www.kde.org/kdebase.tar#tar:/README"</tt> it would - * return @c true as well - * - * @see ref() - * @see setRef() - */ - bool hasRef() const { return !m_strRef_encoded.isNull(); } - - /** - * @brief Returns decoded the HTML-style reference - * (the part of the URL after @c '#') - * - * @return the HTML-style reference - * - * @see encodedHtmlRef() - * @see setHTMLRef() - * @see hasHTMLRef() - * @see split() - * @see hasSubURL() - * @see ref() - */ - TQString htmlRef() const; - - /** - * @brief Returns the encoded HTML-style reference - * (the part of the URL after @c '#') - * - * @return the HTML-style reference in its original, encoded, form - * - * @see htmlRef() - * @see setHTMLRef() - * @see hasHTMLRef() - */ - TQString encodedHtmlRef() const; - - /** - * @brief Sets the decoded HTML-style reference - * - * @param _ref the new reference. This is considered to be @em not encoded in - * contrast to setRef(). Use @c TQString::null to remove it - * - * @see htmlRef() - * @see hasHTMLRef() - */ - void setHTMLRef( const TQString& _ref ); - - /** - * @brief Tests if there is an HTML-style reference - * - * @return @c true if the URL has an HTML-style reference - * - * @see htmlRef() - * @see encodedHtmlRef() - * @see setHTMLRef() - * @see hasRef() - */ - bool hasHTMLRef() const; - - /** - * @brief Tests if the URL is well formed - * - * @return @c false if the URL is malformed. This function does @em not test - * whether sub URLs are well-formed as well - */ - bool isValid() const { return !m_bIsMalformed; } - /** - * @brief Tests if the URL is malformed - * - * @return @c true if the URL is malformed. This function does @em not test - * whether sub URLs are well-formed as well - * - * @deprecated Use !isValid() instead - * - * @see isValid() - */ - KDE_DEPRECATED bool isMalformed() const { return !isValid(); } - - /** - * @brief Tests if the file is local - * - * @return @c true if the file is a plain local file and has no filter - * protocols attached to it - */ - bool isLocalFile() const; - - /** - * @brief Adds file encoding information - * - * Adds encoding information to the URL by adding a @c "charset" parameter. - * If there is already a charset parameter, it will be replaced. - * - * @param encoding the encoding to add or @c TQString::null to remove the - * encoding - * - * @see fileEncoding() - * @see TQTextCodec::codecForName() - */ - void setFileEncoding(const TQString &encoding); - - /** - * @brief Returns encoding information of the URL - * - * The encoding information is the content of the @c "charset" parameter. - * - * @return an encoding suitable for TQTextCodec::codecForName() - * or @c TQString::null if not encoding was specified - */ - TQString fileEncoding() const; - - /** - * @brief Tests if the URL has any sub URLs - * - * See split() for examples for sub URLs. - * - * @return @c true if the file has at least one sub URL - * - * @see split() - */ - bool hasSubURL() const; - - /** - * @brief Adds to the current path - * - * Assumes that the current path is a directory. @p _txt is appended to the - * current path. The function adds @c '/' if needed while concatenating. - * This means it does not matter whether the current path has a trailing - * @c '/' or not. If there is none, it becomes appended. If @p _txt - * has a leading @c '/' then this one is stripped. - * - * @param txt the text to add. It is considered to be decoded - * - * @see setPath() - * @see hasPath() - */ - void addPath( const TQString& txt ); - - /** - * @brief Returns the value of a certain query item - * - * @param item item whose value we want - * - * @return the value of the given query item name or @c TQString::null if the - * specified item does not exist - * - * @see addQueryItem() - * @see removeQueryItem() - * @see queryItems() - * @see query() - */ - TQString queryItem( const TQString& item ) const; - - /** - * @brief Returns the value of a certain query item - * - * @param item item whose value we want - * @param encoding_hint MIB of encoding of query. - * See TQTextCodec::mibEnum() - * - * @return the value of the given query item name or @c TQString::null if the - * specified item does not exist - * - * @see addQueryItem() - * @see removeQueryItem() - * @see queryItems() - * @see query() - */ - TQString queryItem( const TQString& item, int encoding_hint ) const; - - /** - * Options for queryItems() - * - * @since 3.1 - */ - enum QueryItemsOptions - { - /** - * Normalize query keys to lowercase - */ - CaseInsensitiveKeys = 1 - }; - - /** - * @internal, override for the below function - */ - TQMap< TQString, TQString > queryItems( int options=0 ) const; - - /** - * @brief Returns the list of query items as a map mapping keys to values - * - * @param options any of QueryItemsOptions <em>OR</em>ed together - * @param encoding_hint MIB of encoding of query. - * See TQTextCodec::mibEnum() - * - * @return the map of query items or the empty map if the URL has no - * query items - * - * @see queryItem() - * @see addQueryItem() - * @see removeQueryItem() - * @see query() - * - * @since 3.1 - */ - TQMap< TQString, TQString > queryItems( int options, int encoding_hint ) const; - - /** - * @brief Adds an additional query item - * - * To replace an existing query item, the item should first be - * removed with removeQueryItem() - * - * @param _item name of item to add - * @param _value value of item to add - * @param encoding_hint MIB of encoding to use for _value. - * See TQTextCodec::mibEnum() - * - * @see queryItem() - * @see queryItems() - * @see query() - */ - void addQueryItem( const TQString& _item, const TQString& _value, int encoding_hint = 0 ); - - /** - * @brief Removea an item from the query - * - * @param _item name of item to remove - * - * @see addQueryItem() - * @see queryItem() - * @see queryItems() - * @see query() - */ - void removeQueryItem( const TQString& _item ); - - /** - * @brief Sets the filename of the path - * - * In comparison to addPath() this function does not assume that the current - * path is a directory. This is only assumed if the current path ends - * with @c '/'. - * - * If the current path ends with @c '/' then @p _txt is just appended, - * otherwise all text behind the last @c '/' in the current path is erased - * and @p _txt is appended then. It does not matter whether @p _txt starts - * with @c '/' or not. - * - * Any reference is reset. - * - * @param _txt the filename to be set. It is considered to be decoded - * - * @see fileName() - * @see setDirectory() - * @see setPath() - */ - void setFileName( const TQString&_txt ); - - /** - * @brief Returns the filename of the path - * - * @p _ignore_trailing_slash_in_path tells whether a trailing @c '/' should - * be ignored. This means that the function would return @c "torben" for - * <tt>"file:///hallo/torben/"</tt> and <tt>"file:///hallo/torben"</tt>. - * - * @param _ignore_trailing_slash_in_path if set to @c false, then everything - * behind the last @c '/' is considered to be the filename - * - * @return the filename of the current path. The returned string is decoded. - * @c TQString::null if there is no file (and thus no path) - * - * @see setFileName() - * @see directory() - * @see path() - */ - TQString fileName( bool _ignore_trailing_slash_in_path = true ) const; - - /** - * @brief Returns the directory of the path - * - * The directory is everything between the last and the second last @c '/' - * is returned. For example <tt>"file:///hallo/torben/"</tt> would return - * <tt>"/hallo/torben/"</tt> while <tt>"file:///hallo/torben"</tt> would - * return <tt>"hallo/"</tt>. - * - * @p _ignore_trailing_slash_in_path tells whether a trailing @c '/' should - * be ignored. This means that the function would return @c "/hallo" - * (or @c "/hallo" depending on @p _strip_trailing_slash_from_result) for - * <tt>"file:///hallo/torben/"</tt> and <tt>"file:///hallo/torben"</tt>. - * - * @param _strip_trailing_slash_from_result tells whether the returned result - * should end with @c '/' or not. If the path is empty or just @c "/" - * then this flag has no effect - * @param _ignore_trailing_slash_in_path if set to @c false, then everything - * behind the last @c '/' is considered to be the filename - * - * @return the directory part of the current path or @c TQString::null when - * there is no path. The returned string is decoded - * - * @see setDirectory() - * @see fileName() - * @see path() - */ - TQString directory( bool _strip_trailing_slash_from_result = true, - bool _ignore_trailing_slash_in_path = true ) const; - - /** - * @brief Sets the directory of the path, leaving the filename empty - * - * @param dir the decoded directory to set - * - * @see directory() - * @see setFileName() - * @see setPath() - */ - void setDirectory(const TQString &dir); - - /** - * @brief Changes the directory by descending into the given directory - * - * It is assumed the current URL represents a directory. - * If @p _dir starts with a @c '/' the current URL will be - * <tt>"protocol://host/dir"</tt> otherwise @p _dir will be appended to the - * path. @p _dir can be @c ".." - * - * This function won't strip protocols. That means that when you are in - * <tt>"file:///dir/dir2/my.tgz#tar:/"</tt> and you do <tt>cd("..")</tt> you - * will still be in <tt>"file:///dir/dir2/my.tgz#tar:/"</tt> - * - * @param _dir the directory to change to - * @return @c true if successful - * - * @see directory() - * @see path() - */ - bool cd( const TQString& _dir ); - - /** - * @brief Returns the URL as string, with all escape sequences intact, - * encoded in a given charset - * - * This is used in particular for encoding URLs in UTF-8 before using them - * in a drag and drop operation. - * - * @note that the string returned by url() will include the password of the - * URL. If you want to show the URL to the user, use prettyURL(). - * - * The @p _trailing parameter allows to ensure the existance or absence of - * the last (trailing) @c '/' character in the path. - * If the URL has no path, then no @c '/' is added anyway. - * And on the other side: if the path is just @c "/", then this character - * won't be stripped. - * - * Reason: <tt>"ftp://weis@host"</tt> means something completely different - * than <tt>"ftp://weis@host/"</tt>. - * So adding or stripping the '/' would really alter the URL, while - * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same - * directory. - * - * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing - * @c '/', @c +1 adds a trailing @c '/' if there is none yet - * and @c 0 returns the path unchanged - * @param encoding_hint MIB of encoding to use. - * See TQTextCodec::mibEnum() - * - * @return the complete URL, with all escape sequences intact, encoded - * in a given charset - * - * @see prettyURL() - * @see pathOrURL() - * @see htmlURL() - */ - TQString url( int _trailing = 0, int encoding_hint = 0) const; - - /** - * @brief Returns the URL as string in human-friendly format - * - * Example: - * @code - * http://localhost:8080/test.cgi?test=hello world&name=fred - * @endcode - * - * Does @em not contain the password if the URL has one, use url() if you - * need to have it in the string. - * - * The @p _trailing parameter allows to ensure the existance or absence of - * the last (trailing) @c '/' character in the path. - * If the URL has no path, then no @c '/' is added anyway. - * And on the other side: if the path is just @c "/", then this character - * won't be stripped. - * - * Reason: <tt>"ftp://weis@host"</tt> means something completely different - * than <tt>"ftp://weis@host/"</tt>. - * So adding or stripping the '/' would really alter the URL, while - * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same - * directory. - * - * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing - * @c '/', @c +1 adds a trailing @c '/' if there is none yet - * and @c 0 returns the path unchanged - * @return a human readable URL, with no non-necessary encodings/escaped - * characters. Password will not be shown - * - * @see url() - * @see pathOrURL() - */ - TQString prettyURL( int _trailing = 0) const; - - /** - * @brief Returns the URL as string in human-friendly format - * Example: - * @code - * http://localhost:8080/test.cgi?test=hello world&name=fred - * @endcode - * - * Does @em not contain the password if the URL has one, use url() if you - * need to have it in the string. - * - * The @p _trailing parameter allows to ensure the existance or absence of - * the last (trailing) @c '/' character in the path. - * If the URL has no path, then no @c '/' is added anyway. - * And on the other side: if the path is just @c "/", then this character - * won't be stripped. - * - * Reason: <tt>"ftp://weis@host"</tt> means something completely different - * than <tt>"ftp://weis@host/"</tt>. - * So adding or stripping the '/' would really alter the URL, while - * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same - * directory. - * - * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing - * @c '/', @c +1 adds a trailing @c '/' if there is none yet - * and @c 0 returns the path unchanged - * @param _flags if StripFileProtocol, @c "file://" will be stripped. - * The use of this method is now discouraged, better use pathOrURL(). - * - * @return a human readable URL, with no non-necessary encodings/escaped - * characters. Password will not be shown - * - * @see prettyURL() - * @see url() - * @see pathOrURL() - */ - TQString prettyURL( int _trailing, AdjustementFlags _flags) const; - // ### BIC: Merge the two above + spell it as "Adjustment" - // Or remove completely, and let people use pathOrURL() instead - - /** - * @brief Returns the URL as a string depending if it is a local file - * - * It will be either the URL (as prettyURL() would return) or, when the URL - * is a local file without query or ref, the path(). - * - * Use this method, together with its opposite, fromPathOrURL(), - * to display and even let the user edit URLs. - * - * @return the path or URL string depending on its properties - * - * @see prettyURL() - * @see path() - * @see url() - * @see isLocalFile() - * - * @since 3.4 - */ - TQString pathOrURL() const; - - /** - * @brief Returns the URL as string, escaped for HTML - * - * @return a human readable URL, with no non-necessary encodings/escaped - * characters which is HTML encoded for safe inclusion in HTML or - * rich text. Password will not be shown. - * - * @see prettyURL() - * @see url() - * @see pathOrURL() - */ - TQString htmlURL() const; - - - /** - * @brief Tests if the KURL is empty - * - * An empty URL has neither path nor protocol set. - * - * @return @c true if the URL is empty - * - * @see hasPath() - * @see protocol() - * @see isValid() - */ - bool isEmpty() const; - - /** - * @brief Returns the URL that is the best possible candidate for on level - * higher in the path hierachy - * - * This function is useful to implement the "Up" button in a file manager for - * example. - * cd() never strips a sub-protocol. That means that if you are in - * <tt>"file:///home/x.tgz#gzip:/#tar:/"</tt> and hit the up button you - * expect to see <tt>"file:///home"</tt>. The algorithm tries to go up on the - * right-most URL. If that is not possible it strips the right most URL. It - * continues stripping URLs until it can go up. - * - * @return a URL that is a level higher - * - * @see cd() - * @see split() - * @see hasSubURL() - * @see path() - */ - KURL upURL( ) const; - - /** - * @brief Tests if this URL is less than the given URL - * - * The current URL is consideres <tt>"less than"</tt> then @p _u if - * (tested in this order): - * - it is not valid but @p _u is. See isValid() - * - its protocol is "less than" @p _u's protocol. See protocol() - * - its host is "less than" @p _u's host. See host() - * - its port is "less than" @p _u's port. See port() - * - its path is "less than" @p _u's path. See path() - * - its encoded query is "less than" @p _u's encoded query. See query() - * - its endoded reference is "less than" @p _u's encoded reference. - * See ref() - * - its username is "less than" @p _u's username. See user() - * - its password is "less than" @p _u's password. See pass() - * - * Examples: - * @code - * KURL url1; - * KURL url2; - * - * bool lessThan = url1 < url2; // false. Both invalid, no protocols - * - * url2.setProtocol( TQString::null ); - * lessThan = url1 < url2; // true. url2 is valid because of setProtocol() - * - * url1.setProtocol( TQString::null ); - * lessThan = url1 < url2; // false. Both valid and everything empty - * - * url1.setProtocol( "http" ); - * url2.setProtocol( "https" ); - * lessThan = url1 < url2; // true. "http" < "https" - * - * url2.setHost( "api.kde.org" ); - * url2.setProtocol( "http" ); - * url2.setProtocol( "www.kde.org" ); - * lessThan = url1 < url2; // true. protocols equal and "api" < "www" - * - * url1.setProtocol( "https" ); - * url2.setProtocol( "http" ); - * lessThan = url1 < url2; // false. "https" > "http". host doesn't matter yet - * @endcode - * - * @param _u the URL to compare to - * - * @return @c true if the URL is less than @p _u. Otherwise @c false - * (equal or greater than) - * - * @see operator==() - * @see TQString::compare() - */ - bool operator<(const KURL& _u) const; - - /** - * @brief Copies the values of the given URL into this one - * - * Just assigns each member using the member's assignment operator. - * - * @param _u the URL to take the values from - * - * @return a reference to this URL (*this) - * - * @see equals() - */ - KURL& operator=( const KURL& _u ); - - /** - * @brief Assigns the URL, given as a string, to this one - * - * This will reset the current URL and parse the given string. - * See the similar constructor for known limitations. - * - * @param _url the TQString to parse for values - * - * @return a reference to this URL (*this) - * - * @see equals() - * @see KURL(const TQString &, int) - */ - KURL& operator=( const TQString& _url ); - - /** - * @brief Assigns the URL, given as a C string, to this one - * - * This will reset the current URL and parse the given string. - * See the similar constructor for known limitations. - * - * @param _url the C string to parse for values - * - * @return a reference to this URL (*this) - * - * @see equals() - * @see KURL(const char *, int) - */ - KURL& operator=( const char * _url ); - - /** - * @brief Assigns the URL, given as a Qt URL, to this one - * - * This will reset the current URL and parse the given string. - * - * @param u the Qt URL to take the values from - * - * @return a reference to this URL (*this) - * - * @see equals() - * @see KURL(const TQUrl &) - */ - KURL& operator=( const TQUrl & u ); - - /** - * @brief Tests if this URL is equal to the given one - * - * Tests each member for equality unless one of the URLs is invalid - * in which case they are not considered equal (even if both are invalid). - * - * Same as equals() when used with @p ignore_trailing set to - * @c false (default) - * - * @param _u the URL to compare to - * - * @return @c true if equal and neither this URL nor @p _u is malformed. - * Otherwise @c false - * - * @see equals() - * @see isValid() - * @see operator!=() - * @see operator<() - */ - bool operator==( const KURL& _u ) const; - - /** - * @brief Tests if this URL is equal to the one given as a string - * - * Creates a KURL instance for @p _u and compares with that using - * the equality operator for two KURLs. - * - * See the respective constructor for known limitations. - * - * @param _u the string to compare to - * - * @return @c true if equal and neither this URL nor @p _u is malformed. - * Otherwise @c false - * - * @see KURL(const TQString &, int) - * @see operator==(const KURL &) - * @see equals() - * @see isValid() - * @see operator!=() - * @see operator<() - */ - bool operator==( const TQString& _u ) const; - - /** - * @brief Tests if this URL is different from the given one - * - * Tests by negating the result of operator==() - * - * @param _u the URL to compare to - * - * @return the negated result of operator==() - * - * @see operator==() - * @see operator<() - */ - bool operator!=( const KURL& _u ) const { return !( *this == _u ); } - - /** - * @brief Tests if this URL is different from the one given as a string - * - * Tests by negating the result of operator==(const TQString &) - * - * @param _u the URL to compare to - * - * @return the negated result of operator==(const TQString &) - * - * @see operator==(const TQString &) - * @see operator<() - */ - bool operator!=( const TQString& _u ) const { return !( *this == _u ); } - - /** - * @brief Compares this URL with another one - * - * The same as equals(), just with a less obvious name. - * - * @param u the URL to compare this one with - * @param ignore_trailing set to @c true to ignore trailing @c '/' characters - * - * @return @c true if both URLs are the same - * - * @see operator==. This function should be used if you want to - * ignore trailing @c '/' characters - * - * @deprecated Use equals() instead. - */ - bool cmp( const KURL &u, bool ignore_trailing = false ) const KDE_DEPRECATED; - - /** - * @brief Compares this URL with another one - * - * @param u the URL to compare this one with - * @param ignore_trailing set to @c true to ignore trailing @c '/' characters - * - * @return @c true if both urls are the same - * - * @see operator==. This function should be used if you want to - * ignore trailing @c '/' characters - * - * @since 3.1 - */ - bool equals( const KURL &u, bool ignore_trailing = false ) const; // TODO KDE4: add bool _ignore_ref = false - - /** - * @brief Tests if the given URL is parent of this URL - * - * For instance, <tt>"ftp://host/dir/"</tt> is a parent of - * <tt>"ftp://host/dir/subdir/subsubdir/"</tt>. - * - * @return @c true if this URL is a parent of @p u (or the same URL as @p u) - * - * @see equals() - * @see cd() - */ - bool isParentOf( const KURL& u ) const; - - /** - * @brief Splits nested URLs into a list of URLs - * - * Example for a nested URL: - * @code - * file:///home/weis/kde.tgz#gzip:/#tar:/kdebase - * @endcode - * A URL like <tt>"http://www.kde.org#tar:/kde/README.hml#ref1"</tt> will be - * split in <tt>"http://www.kde.org#ref1"</tt> and - * <tt>"tar:/kde/README.html#ref1"</tt>. - * - * That means in turn that @c "#ref1" is an HTML-style reference and not a - * new sub URL. Since HTML-style references mark a certain position in a - * document this reference is appended to every URL. - * - * The idea behind this is that browsers, for example, only look at the first - * URL while the rest is not of interest to them. - * - * @param _url the URL that has to be split - * - * @return an empty list on error or the list of split URLs - * - * @see hasSubURL() - * @see KURL(const TQString&, int) - * @see join() - */ - static List split( const TQString& _url ); - - /** - * @brief Splits nested URLs into a list of URLs - * - * Example for a nested URL: - * @code - * file:///home/weis/kde.tgz#gzip:/#tar:/kdebase - * @endcode - * A URL like <tt>"http://www.kde.org#tar:/kde/README.hml#ref1"</tt> will be - * split in <tt>"http://www.kde.org#ref1"</tt> and - * <tt>"tar:/kde/README.html#ref1"</tt>. - * - * That means in turn that @c "#ref1" is an HTML-style reference and not a - * new sub URL. Since HTML-style references mark a certain position in a - * document this reference is appended to every URL. - * - * The idea behind this is that browsers, for example, only look at the first - * URL while the rest is not of interest to them. - * - * @param _url the URL that has to be split - * - * @return an empty list on error or the list of split URLs - * - * @see hasSubURL() - * @see join() - */ - static List split( const KURL& _url ); - - /** - * @brief Joins a list of URLs into a single URL with sub URLs - * - * Reverses split(). Only the first URL may have a reference. This reference - * is considered to be HTML-like and is appended at the end of the resulting - * joined URL. - * - * @param _list the list to join - * - * @return the joined URL or an invalid URL if the list is empty - * - * @see split() - */ - static KURL join( const List& _list ); - - /** - * @brief Creates a KURL object from a TQString representing either an - * absolute path or a real URL - * - * Use this method instead of - * @code - * TQString someDir = ... - * KURL url = someDir; - * @endcode - * - * Otherwise some characters (e.g. the '#') won't be encoded properly. - * - * @param text the string representation of the URL to convert - * - * @return the new KURL - * - * @see pathOrURL() - * @see KURL(const TQString&, int) - * - * @since 3.1 - */ - static KURL fromPathOrURL( const TQString& text ); - - /** - * @brief Encodes a string for use in URLs - * - * Convenience function. - * - * Convert tqunicoded string to local encoding and use %%-style - * encoding for all common delimiters / non-ascii characters. - * - * @param str the string to encode (can be @c TQString::null) - * @param encoding_hint MIB of encoding to use. - * See TQTextCodec::mibEnum() - * - * @return the encoded string - * - * @see encode_string_no_slash() - * @see decode_string() - */ - static TQString encode_string(const TQString &str, int encoding_hint = 0); - - /** - * @brief Encodes a string for use in URLs - * - * Convenience function. - * - * Convert tqunicoded string to local encoding and use %%-style - * encoding for all common delimiters and non-ascii characters - * as well as the slash @c '/'. - * - * @param str the string to encode (can be @c TQString::null) - * @param encoding_hint MIB of encoding to use. - * See TQTextCodec::mibEnum() - * - * @see encode_string() - * @see decode_string() - */ - static TQString encode_string_no_slash(const TQString &str, int encoding_hint = 0); - - /** - * @brief Decodes a string as used in URLs - * - * Convenience function. - * - * Decode %-style encoding and convert from local encoding to tqunicode. - * - * Reverse of encode_string() - * - * @param str the string to decode (can be @c TQString::null) - * @param encoding_hint MIB of original encoding of @p str . - * See TQTextCodec::mibEnum() - * - * @return the decoded string - * - * @see encode_string() - * @see encode_string_no_slash() - */ - static TQString decode_string(const TQString &str, int encoding_hint = 0); - - /** - * @brief Tests if a given URL is a relative as opposed to an absolute URL - * - * Convenience function. - * - * Returns whether @p _url is likely to be a "relative" URL instead of - * an "absolute" URL. - * - * @param _url the URL to examine - * @return @c true when the URL is likely to be "relative", - * @c false otherwise - * - * @see relativeURL() - */ - static bool isRelativeURL(const TQString &_url); - - /** - * @brief Creates an URL relative to a base URL for a given input URL - * - * Convenience function - * - * Returns a "relative URL" based on @p base_url that points to @p url. - * - * If no "relative URL" can be created, e.g. because the protocol - * and/or hostname differ between @p base_url and @p url an absolute - * URL is returned. - * - * @note if @p base_url represents a directory, it should contain - * a trailing slash - * - * @param base_url the URL to derive from - * @param url the URL to point to relatively from @p base_url - * @param encoding_hint MIB of original encoding of @p str . - * See TQTextCodec::mibEnum() - * - * @see isRelativeURL() - * @see relativePath() - * @see adjustPath() - */ - static TQString relativeURL(const KURL &base_url, const KURL &url, int encoding_hint = 0); - - /** - * @brief Creates a path relative to a base path for a given input path - * - * Convenience function - * - * Returns a relative path based on @p base_dir that points to @p path. - * - * @param base_dir the base directory to derive from - * @param path the new target directory - * @param isParent an optional pointer to a boolean which, if provided, will - * be set to reflect whether @p path has @p base_dir as a parent dir - * - * @see relativeURL() - */ - static TQString relativePath(const TQString &base_dir, const TQString &path, bool *isParent=0); - - /** - * @brief Determines which URI mode is suitable for processing URIs of a - * given protocol - * - * @param protocol the protocol name. See protocol() - * - * @return the URIMode suitable for the given protocol - * - * @see uriMode() - * - * @since 3.2 - */ - static URIMode uriModeForProtocol(const TQString& protocol); - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated change code to call fileName() - */ - TQString filename( bool _ignore_trailing_slash_in_path = true ) const - { - return fileName(_ignore_trailing_slash_in_path); - } - -protected: - /** - * @brief Resets the members to their "null" state - * - * All TQString members get reset to @c TQString::null, the port to @c 0 - * the URIMode to @c Auto and the URL becomes invalid. - * - * This is like assigning a null URL, but more efficient as it doesn't - * require the temporary object. - * - * Called by constructors, assignment operators and the parse methods in case - * of a parsing error. - * - * @see isValid() - * @see isEmpty() - */ - void reset(); - - /** - * @brief Parses the given string and fills the URL's values on success - * - * Treats the string as an URL. - * - * @param _url the string to parse - * @param encoding_hint MIB of original encoding of @p str . - * See TQTextCodec::mibEnum() - */ - void parseURL( const TQString& _url, int encoding_hint = 0 ); - /** - * @brief Parses the given string and fills the URL's values on success - * - * Treats the string as a generic URI. - * - * @param _url the string to parse - * @param encoding_hint MIB of original encoding of @p str . - * See TQTextCodec::mibEnum() - */ - void parseRawURI( const TQString& _url, int encoding_hint = 0 ); - /** - * @brief Parses the given string and fills the URL's values on success - * - * Treats the string as a @c "mailto:" URI. - * - * @param _url the string to parse - * @param encoding_hint MIB of original encoding of @p str . - * See TQTextCodec::mibEnum() - */ - void parseMailto( const TQString& _url, int encoding_hint = 0 ); - /** - * @brief Parses the given string and fills the URL's values on success - * - * @param _url the string to parse - * @param encoding_hint MIB of original encoding of @p str . - * See TQTextCodec::mibEnum() - */ - void parse( const TQString& _url, int encoding_hint = 0 ); - -private: - void _setQuery( const TQString& _txt, int encoding_hint = 0); - - TQString m_strProtocol; - TQString m_strUser; - TQString m_strPass; - TQString m_strHost; - TQString m_strPath; - TQString m_strRef_encoded; - TQString m_strQuery_encoded; - bool m_bIsMalformed : 1; - enum URIMode m_iUriMode : 3; - uint freeForUse : 4; - unsigned short int m_iPort; - TQString m_strPath_encoded; - - friend KDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a); - friend KDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a); -private: - KURLPrivate* d; -}; - -/** - * \relates KURL - * Compares URLs. They are parsed, split and compared. - * Two malformed URLs with the same string representation - * are nevertheless considered to be unequal. - * That means no malformed URL equals anything else. - */ -KDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2 ); - -/** - * \relates KURL - * Compares URLs. They are parsed, split and compared. - * Two malformed URLs with the same string representation - * are nevertheless considered to be unequal. - * That means no malformed URL equals anything else. - * - * @param _url1 A reference URL - * @param _url2 A URL that will be compared with the reference URL - * @param _ignore_trailing Described in KURL::cmp - * @param _ignore_ref If true, disables comparison of HTML-style references. - */ -KDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2, bool _ignore_trailing, bool _ignore_ref ); - -KDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a); -KDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a); - -#endif diff --git a/kdecore/kurldrag.cpp b/kdecore/kurldrag.cpp deleted file mode 100644 index e0a7be227..000000000 --- a/kdecore/kurldrag.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2000 David Faure <faure@kde.org> - - 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 "kurldrag.h" -#include <tqstrlist.h> -#include <tqdragobject.h> -#include <tqfont.h> -#include <unistd.h> - -#include <kdeversion.h> -#include <kglobal.h> -#include <klocale.h> -#include <kdebug.h> - -class KURLDragPrivate -{ -public: - bool m_exportAsText; -}; - -KURLDrag::KURLDrag( const KURL::List &urls, TQWidget* dragSource, const char * name ) - : TQUriDrag(dragSource, name), m_metaData(), d( 0 ) -{ - init(urls); -} - -KURLDrag::KURLDrag( const KURL::List &urls, const TQMap<TQString,TQString>& metaData, - TQWidget* dragSource, const char * name ) - : TQUriDrag(dragSource, name), m_metaData(metaData), d( 0 ) -{ - init(urls); -} - -KURLDrag::~KURLDrag() -{ - delete d; -} - -void KURLDrag::init(const KURL::List &urls) -{ - KURL::List::ConstIterator uit = urls.begin(); - KURL::List::ConstIterator uEnd = urls.end(); - // Get each URL encoded in utf8 - and since we get it in escaped - // form on top of that, .latin1() is fine. - for ( ; uit != uEnd ; ++uit ) - { - m_urls.append( urlToString(*uit).latin1() ); - } - setUris(m_urls); -} - -void KURLDrag::setExportAsText( bool exp ) -{ - // For now d is only used here, so create it on demand - if ( !d ) - d = new KURLDragPrivate; - d->m_exportAsText = exp; -} - -KURLDrag * KURLDrag::newDrag( const KURL::List &urls, TQWidget* dragSource, const char * name ) -{ - return new KURLDrag( urls, TQMap<TQString, TQString>(), dragSource, name ); -} - -KURLDrag * KURLDrag::newDrag( const KURL::List &urls, const TQMap<TQString, TQString>& metaData, - TQWidget* dragSource, const char * name ) -{ - return new KURLDrag( urls, metaData, dragSource, name ); -} - -bool KURLDrag::decode( const TQMimeSource *e, KURL::List &uris ) -{ - if ( e->provides( "application/x-kde-urilist" ) ) { - TQByteArray payload = e->tqencodedData( "application/x-kde-urilist" ); - if ( payload.size() ) { - uint c=0; - const char* d = payload.data(); - while (c < payload.size() && d[c]) { - uint f = c; - // Find line end - while (c < payload.size() && d[c] && d[c]!='\r' - && d[c] != '\n') - c++; - TQCString s(d+f,c-f+1); - if ( s[0] != '#' ) // non-comment? - uris.append(stringToUrl(s)); - // Skip junk - while (c < payload.size() && d[c] && - (d[c]=='\n' || d[c]=='\r')) - c++; - } - return !uris.isEmpty(); - } - } - - TQStrList lst; - TQUriDrag::decode( e, lst ); - for (TQStrListIterator it(lst); *it; ++it) - { - KURL url = stringToUrl( *it ); - if ( !url.isValid() ) - { - uris.clear(); - break; - } - uris.append( url ); - } - return !uris.isEmpty(); -} - -bool KURLDrag::decode( const TQMimeSource *e, KURL::List &uris, TQMap<TQString,TQString>& metaData ) -{ - if ( decode( e, uris ) ) // first decode the URLs (see above) - { - TQByteArray ba = e->tqencodedData( "application/x-kio-metadata" ); - if ( ba.size() ) - { - TQString s = ba.data(); - TQStringList l = TQStringList::split( "$@@$", s ); - TQStringList::ConstIterator it = l.begin(); - bool readingKey = true; // true, then false, then true, etc. - TQString key; - for ( ; it != l.end(); ++it ) { - if ( readingKey ) - key = *it; - else - metaData.replace( key, *it ); - readingKey = !readingKey; - } - Q_ASSERT( readingKey ); // an odd number of items would be, well, odd ;-) - } - return true; // Success, even if no metadata was found - } - return false; // Couldn't decode the URLs -} - -#ifdef Q_WS_QWS -bool KURLDrag::decode( TQStringList const &e, KURL::List &uris ) -{ - TQStringList::ConstIterator end(e.end()); - for(TQStringList::ConstIterator it=e.begin(); it!=end; ++it) - { - KURL url = KURL( *it, 106 ); // 106 is mib enum for utf8 codec - if ( !url.isValid() ) - { - uris.clear(); - break; - } - uris.append( url ); - } - return !uris.isEmpty(); -} -#endif - -//// - -const char * KURLDrag::format( int i ) const -{ - if ( i == 0 ) - return "text/uri-list"; - else if ( i == 1 ) - return "application/x-kio-metadata"; - if ( d && d->m_exportAsText == false ) - return 0; - if ( i == 2 ) - return "text/plain"; - else if ( i == 3 ) //Support this for apps that use plain XA_STRING clipboard - return "text/plain;charset=ISO-8859-1"; - else if ( i == 4 ) //Support this for apps that use the UTF_STRING clipboard - return "text/plain;charset=UTF-8"; - else return 0; -} - -TQByteArray KURLDrag::tqencodedData( const char* mime ) const -{ - TQByteArray a; - TQCString mimetype( mime ); - if ( mimetype == "text/uri-list" ) - return TQUriDrag::tqencodedData( mime ); - else if ( mimetype == "text/plain" ) - { - TQStringList uris; - for (TQStrListIterator it(m_urls); *it; ++it) - uris.append(stringToUrl(*it).prettyURL()); - - TQCString s = uris.join( "\n" ).local8Bit(); - if( uris.count() > 1 ) // terminate last line, unless it's the only line - s.append( "\n" ); - a.resize( s.length()); - memcpy( a.data(), s.data(), s.length()); // no trailing zero in clipboard text - } - else if ( mimetype.lower() == "text/plain;charset=iso-8859-1") - { - TQStringList uris; - for (TQStrListIterator it(m_urls); *it; ++it) - for (TQStrListIterator it(m_urls); *it; ++it) - uris.append(stringToUrl(*it).url(0, 4)); // 4 is mib for latin1 - - TQCString s = uris.join( "\n" ).latin1(); - if( uris.count() > 1 ) - s.append( "\n" ); - a.resize( s.length()); - memcpy( a.data(), s.data(), s.length()); - } - else if ( mimetype.lower() == "text/plain;charset=utf-8") - { - TQStringList uris; - for (TQStrListIterator it(m_urls); *it; ++it) - uris.append(stringToUrl(*it).prettyURL()); - - TQCString s = uris.join( "\n" ).utf8(); - if( uris.count() > 1 ) - s.append( "\n" ); - a.resize( s.length()); - memcpy( a.data(), s.data(), s.length()); - } - else if ( mimetype == "application/x-kio-metadata" ) - { - if ( !m_metaData.isEmpty() ) - { - TQString s; - TQMap<TQString,TQString>::ConstIterator it; - for( it = m_metaData.begin(); it != m_metaData.end(); ++it ) - { - s += it.key(); - s += "$@@$"; - s += it.data(); - s += "$@@$"; - } - a.resize( s.length() + 1 ); - memcpy( a.data(), s.latin1(), a.size() ); - } - } - return a; -} - -KURL KURLDrag::stringToUrl(const TQCString &s) -{ - if (strncmp(s.data(), "file:", 5) == 0) - return KURL(s, KGlobal::locale()->fileEncodingMib()); - - return KURL(s, 106); // 106 is mib enum for utf8 codec; -} - -TQString KURLDrag::urlToString(const KURL &url) -{ - if (url.isLocalFile()) - { -#if 1 - return url.url(0, KGlobal::locale()->fileEncodingMib()); -#else - // According to the XDND spec, file:/ URLs for DND must have - // the hostname part. But in really it just breaks many apps, - // so it's disabled for now. - TQString s = url.url(0, KGlobal::locale()->fileEncodingMib()); - if( !s.startsWith( "file://" )) - { - char hostname[257]; - if ( gethostname( hostname, 255 ) == 0 ) - { - hostname[256] = '\0'; - return TQString( "file://" ) + hostname + s.mid( 5 ); - } - } -#endif - } - - if ( url.protocol() == "mailto" ) { - return url.path(); - } - - return url.url(0, 106); // 106 is mib enum for utf8 codec -} - -// deprecated ctor -KURLDrag::KURLDrag( const TQStrList & urls, const TQMap<TQString,TQString>& metaData, - TQWidget * dragSource, const char* name ) : -TQUriDrag( urls, dragSource, name ), m_urls( urls ), m_metaData( metaData ), d( 0 ) {} diff --git a/kdecore/kurldrag.h b/kdecore/kurldrag.h deleted file mode 100644 index 019119600..000000000 --- a/kdecore/kurldrag.h +++ /dev/null @@ -1,165 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2000 David Faure <faure@kde.org> - - 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 __KURLDRAG_H -#define __KURLDRAG_H - -#include <tqstringlist.h> -#include <tqdragobject.h> -#include <kurl.h> -#include "kdelibs_export.h" -class TQMimeSource; - -class KURLDragPrivate; -/** - * This class is to be used instead of TQUriDrag when using KURL. - * The reason is: TQUriDrag (and the XDND/W3C standards) expect URLs to - * be encoded in UTF-8 (tqunicode), but KURL uses the current locale - * by default. - * The other reasons for using this class are: - * @li it exports text/plain (for dropping/pasting into lineedits, mails etc.) - * @li it has support for metadata, shipped as part of the dragobject - * This is important, for instance to set a correct HTTP referrer (some websites - * require it for downloading e.g. an image). - * - * To create a drag object, use the KURLDrag constructor. - * To handle drops, use TQUriDrag::canDecode() and KURLDrag::decode() - */ -class KDECORE_EXPORT KURLDrag : public TQUriDrag -{ -public: - /** - * Constructs an object to drag the list of URLs in @p urls. - * The @p dragSource and @p name arguments are passed on to TQUriDrag, - * and the list of urls is converted to UTF-8 before being passed - * to TQUriDrag. - * @param urls the list of URLs - * @param dragSource the parent of the TQObject. Should be set when doing drag-n-drop, - * but should be 0 when copying to the clipboard - * @param name the name of the QObject - */ - KURLDrag( const KURL::List &urls, TQWidget* dragSource = 0, const char * name = 0 ); - /** - * Constructs an object to drag the list of URLs in @p urls. - * This version also includes metadata. - * @param urls the list of URLs - * @param metaData a map containing meta data - * @param dragSource the parent of the TQObject. Should be set when doing drag-n-drop, - * but should be 0 when copying to the clipboard - * @param name the name of the QObject - * @see metaData() - */ - KURLDrag( const KURL::List &urls, const TQMap<TQString, TQString>& metaData, - TQWidget* dragSource = 0, const char * name = 0 ); - - virtual ~KURLDrag(); - - /** - * By default, KURLDrag also exports the URLs as plain text, for e.g. dropping onto a text editor. - * But in some cases this might not be wanted, e.g. if using the KURLDrag in a KMultipleDrag - * and another component of the multiple-drag provides better plain text data. - * In such a case, setExportAsText( false ) should be called. - * @since 3.4 - */ - void setExportAsText( bool exp ); - - /** - * @deprecated Is equivalent with "new KURLDrag(urls, dragSource, name)". - */ - static KURLDrag * newDrag( const KURL::List &urls, TQWidget* dragSource = 0, const char * name = 0 ) KDE_DEPRECATED; - - /** - * @deprecated Is equivalent with "new KURLDrag(urls, metaData, dragSource, name)". - */ - static KURLDrag * newDrag( const KURL::List &urls, const TQMap<TQString, TQString>& metaData, - TQWidget* dragSource = 0, const char * name = 0 ) KDE_DEPRECATED; - - /** - * Meta-data to associate with those URLs. - * This is an alternative way of setting the metadata: - * either use the constructor to pass it all at once, or use - * drag->metaData()["key"] = data; - * @see KIO::TransferJob - */ - TQMap<TQString, TQString> &metaData() { return m_metaData; } - - /** - * Convenience method that decodes the contents of @p e - * into a list of KURLs. Decoding will fail if at least one decoded value - * is not a valid KURL. - * @param e the mime source - * @param urls the list of urls will be written here - * @return true if successful, false otherwise - */ - static bool decode( const TQMimeSource *e, KURL::List &urls ); - - /** - * Convenience method that decodes the contents of @p e - * into a list of KURLs and a set of metadata. Decoding will fail if - * at least one decoded value is not a valid KURL. - * You should be using this one, if possible. - * @param e the mime source - * @param urls the list of urls will be written here - * @param metaData the metadata map will be written here - * @return true if successful, false otherwise - */ - static bool decode( const TQMimeSource *e, KURL::List &urls, TQMap<TQString,TQString>& metaData ); - - /** - * Converts a URL to a string representation suitable for dragging. - * @since 3.2 - */ - static TQString urlToString(const KURL &url); - - /** - * Converts a string used for dragging to a URL. - * @since 3.2 - */ - static KURL stringToUrl(const TQCString &s); - -#ifdef Q_WS_QWS - /** - * Convenience method that decodes the contents of @p e - * into a list of KURLs for Qt versions without a MIME clipboard. - * Decoding will fail if at least one value in the list is not a valid KURL. - */ - static bool decode( TQStringList const &e, KURL::List &uris ); -#endif - - /// @reimp - virtual const char * format( int i ) const; - /// @reimp - virtual TQByteArray tqencodedData( const char* mime ) const; - -protected: - /** - * @deprecated Use a KURLDrag constructor with a KURL::List - */ - KURLDrag( const TQStrList & urls, const TQMap<TQString,TQString>& metaData, - TQWidget * dragSource, const char* name ) KDE_DEPRECATED; - -private: - void init(const KURL::List &urls); - - TQStrList m_urls; - TQMap<TQString,TQString> m_metaData; - KURLDragPrivate* d; -}; - -#endif diff --git a/kdecore/kuser.cpp b/kdecore/kuser.cpp deleted file mode 100644 index 3fffddf4f..000000000 --- a/kdecore/kuser.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* - * KUser - represent a user/account - * Copyright (C) 2002 Tim Jansen <tim@tjansen.de> - * - * - * 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. - */ - -#include <kuser.h> - -#include "kstringhandler.h" -#include <tqvaluelist.h> -#include <tqstringlist.h> - -#include <sys/types.h> -#include <pwd.h> -#include <unistd.h> -#include <stdlib.h> -#include <grp.h> - - -class KUserPrivate : public KShared -{ -public: - bool valid; - long uid, gid; - TQString loginName, fullName; - TQString roomNumber, workPhone, homePhone; - TQString homeDir, shell; - - KUserPrivate() : valid(false) {} - - KUserPrivate(long _uid, - long _gid, - const TQString &_loginname, - const TQString &_fullname, - const TQString &_room, - const TQString &_workPhone, - const TQString &_homePhone, - const TQString &_homedir, - const TQString &_shell) : - valid(true), - uid(_uid), - gid(_gid), - loginName(_loginname), - fullName(_fullname), - roomNumber(_room), - workPhone(_workPhone), - homePhone(_homePhone), - homeDir(_homedir), - shell(_shell) {} -}; - - -KUser::KUser(UIDMode mode) { - long _uid = ::getuid(), _euid; - if (mode == UseEffectiveUID && (_euid = ::geteuid()) != _uid ) - fillPasswd( ::getpwuid( _euid ) ); - else { - fillName( ::getenv( "LOGNAME" ) ); - if (uid() != _uid) { - fillName( ::getenv( "USER" ) ); - if (uid() != _uid) - fillPasswd( ::getpwuid( _uid ) ); - } - } -} - -KUser::KUser(long uid) { - fillPasswd( ::getpwuid( uid ) ); -} - -KUser::KUser(const TQString& name) { - fillName( name.local8Bit().data() ); -} - -KUser::KUser(const char *name) { - fillName( name ); -} - -KUser::KUser(struct passwd *p) { - fillPasswd(p); -} - -KUser::KUser(const KUser & user) - : d(user.d) -{ -} - -KUser& KUser::operator =(const KUser& user) -{ - d = user.d; - return *this; -} - -bool KUser::operator ==(const KUser& user) const { - if (isValid() != user.isValid()) - return false; - if (isValid()) - return uid() == user.uid(); - else - return true; -} - -bool KUser::operator !=(const KUser& user) const { - return !operator ==(user); -} - -void KUser::fillName(const char *name) { - fillPasswd(name ? ::getpwnam( name ) : 0); -} - -void KUser::fillPasswd(struct passwd *p) { - if (p) { - TQString gecos = KStringHandler::from8Bit(p->pw_gecos); - TQStringList gecosList = TQStringList::split(',', gecos, true); - - d = new KUserPrivate(p->pw_uid, - p->pw_gid, - TQString::fromLocal8Bit(p->pw_name), - (gecosList.size() > 0) ? gecosList[0] : TQString::null, - (gecosList.size() > 1) ? gecosList[1] : TQString::null, - (gecosList.size() > 2) ? gecosList[2] : TQString::null, - (gecosList.size() > 3) ? gecosList[3] : TQString::null, - TQString::fromLocal8Bit(p->pw_dir), - TQString::fromLocal8Bit(p->pw_shell)); - } - else - d = new KUserPrivate(); -} - -bool KUser::isValid() const { - return d->valid; -} - -long KUser::uid() const { - if (d->valid) - return d->uid; - else - return -1; -} - -long KUser::gid() const { - if (d->valid) - return d->gid; - else - return -1; -} - -bool KUser::isSuperUser() const { - return uid() == 0; -} - -TQString KUser::loginName() const { - if (d->valid) - return d->loginName; - else - return TQString::null; -} - -TQString KUser::fullName() const { - if (d->valid) - return d->fullName; - else - return TQString::null; -} - -TQString KUser::roomNumber() const { - if (d->valid) - return d->roomNumber; - else - return TQString::null; -} - -TQString KUser::workPhone() const { - if (d->valid) - return d->workPhone; - else - return TQString::null; -} - -TQString KUser::homePhone() const { - if (d->valid) - return d->homePhone; - else - return TQString::null; -} - -TQString KUser::homeDir() const { - if (d->valid) - return d->homeDir; - else - return TQString::null; -} - -TQString KUser::shell() const { - if (d->valid) - return d->shell; - else - return TQString::null; -} - -TQValueList<KUserGroup> KUser::groups() const { - TQValueList<KUserGroup> result; - TQValueList<KUserGroup> allGroups = KUserGroup::allGroups(); - TQValueList<KUserGroup>::const_iterator it; - for ( it = allGroups.begin(); it != allGroups.end(); ++it ) { - TQValueList<KUser> users = (*it).users(); - if ( users.find( *this ) != users.end()) { - result.append(*it); - } - } - return result; -} - -TQStringList KUser::groupNames() const { - TQStringList result; - TQValueList<KUserGroup> allGroups = KUserGroup::allGroups(); - TQValueList<KUserGroup>::const_iterator it; - for ( it = allGroups.begin(); it != allGroups.end(); ++it ) { - TQValueList<KUser> users = (*it).users(); - if ( users.find( *this ) != users.end()) { - result.append((*it).name()); - } - } - return result; -} - - -TQValueList<KUser> KUser::allUsers() { - TQValueList<KUser> result; - - struct passwd* p; - - while ((p = getpwent())) { - result.append(KUser(p)); - } - - endpwent(); - - return result; -} - -TQStringList KUser::allUserNames() { - TQStringList result; - - struct passwd* p; - - while ((p = getpwent())) { - result.append(TQString::fromLocal8Bit(p->pw_name)); - } - - endpwent(); - return result; -} - - -KUser::~KUser() { -} - -class KUserGroupPrivate : public KShared -{ -public: - bool valid; - long gid; - TQString name; - TQValueList<KUser> users; - - KUserGroupPrivate() : valid(false) {} - - KUserGroupPrivate(long _gid, - const TQString & _name, - const TQValueList<KUser> & _users): - valid(true), - gid(_gid), - name(_name), - users(_users) {} -}; - -KUserGroup::KUserGroup(KUser::UIDMode mode) { - KUser user(mode); - fillGroup(getgrgid(user.gid())); -} - -KUserGroup::KUserGroup(long gid) { - fillGroup(getgrgid(gid)); -} - -KUserGroup::KUserGroup(const TQString& name) { - fillName(name.local8Bit().data()); -} - -KUserGroup::KUserGroup(const char *name) { - fillName(name); -} - -KUserGroup::KUserGroup(struct group *g) { - fillGroup(g); -} - - -KUserGroup::KUserGroup(const KUserGroup & group) - : d(group.d) -{ -} - -KUserGroup& KUserGroup::operator =(const KUserGroup& group) { - d = group.d; - return *this; -} - -bool KUserGroup::operator ==(const KUserGroup& group) const { - if (isValid() != group.isValid()) - return false; - if (isValid()) - return gid() == group.gid(); - else - return true; -} - -bool KUserGroup::operator !=(const KUserGroup& user) const { - return !operator ==(user); -} - -void KUserGroup::fillName(const char *name) { - fillGroup(name ? ::getgrnam( name ) : 0); -} - -void KUserGroup::fillGroup(struct group *p) { - if (!p) { - d = new KUserGroupPrivate(); - return; - } - - TQString name = KStringHandler::from8Bit(p->gr_name); - TQValueList<KUser> users; - - char **user = p->gr_mem; - for ( ; *user; user++) { - KUser kUser(TQString::fromLocal8Bit(*user)); - users.append(kUser); - } - - d = new KUserGroupPrivate(p->gr_gid, - TQString::fromLocal8Bit(p->gr_name), - users); - -} - -bool KUserGroup::isValid() const { - return d->valid; -} - -long KUserGroup::gid() const { - if (d->valid) - return d->gid; - else - return -1; -} - -TQString KUserGroup::name() const { - if (d->valid) - return d->name; - else - return TQString::null; -} - -const TQValueList<KUser>& KUserGroup::users() const { - return d->users; -} - -TQStringList KUserGroup::userNames() const { - TQStringList result; - TQValueList<KUser>::const_iterator it; - for ( it = d->users.begin(); it != d->users.end(); ++it ) { - result.append((*it).loginName()); - } - return result; -} - - - -TQValueList<KUserGroup> KUserGroup::allGroups() { - TQValueList<KUserGroup> result; - - struct group* g; - while ((g = getgrent())) { - result.append(KUserGroup(g)); - } - - endgrent(); - - return result; -} - -TQStringList KUserGroup::allGroupNames() { - TQStringList result; - - struct group* g; - while ((g = getgrent())) { - result.append(TQString::fromLocal8Bit(g->gr_name)); - } - - endgrent(); - - return result; -} - - -KUserGroup::~KUserGroup() { -} - diff --git a/kdecore/kuser.h b/kdecore/kuser.h deleted file mode 100644 index 5c43b6b69..000000000 --- a/kdecore/kuser.h +++ /dev/null @@ -1,384 +0,0 @@ -/* - * KUser - represent a user/account - * Copyright (C) 2002-2003 Tim Jansen <tim@tjansen.de> - * Copyright (C) 2003 Oswald Buddenhagen <ossi@kde.org> - * Copyright (C) 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de> - * - * 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 KUSER_H -#define KUSER_H - -#include "ksharedptr.h" - -class KUserGroup; -class TQString; -class TQStringList; -class KUserPrivate; -struct passwd; -template <class T> class TQValueList; - -/** - * @short Represents a user on your system - * - * This class represents a user on your system. You can either get - * information about the current user, of fetch information about - * a user on the system. Instances of this class will be explicitly shared, - * so copying objects is very cheap and you can safely pass objects by value. - * - * @author Tim Jansen <tim@tjansen.de> - * @since 3.2 - */ -class KDECORE_EXPORT KUser { - -public: - - enum UIDMode { - UseEffectiveUID, ///< Use the effective user id. - UseRealUserID ///< Use the real user id. - }; - - /** - * Creates an object that contains information about the current user. - * (as returned by getuid(2) or geteuid(2), taking $LOGNAME/$USER into - * account). - * @param mode if #UseEffectiveUID is passed the effective - * user is returned. - * If #UseRealUserID is passed the real user will be - * returned. - * The real UID will be different than the effective UID in setuid - * programs; in - * such a case use the effective UID for checking permissions, and - * the real UID for displaying information about the user. - */ - // XXX KDE4: Make this explicit - KUser(UIDMode mode = UseEffectiveUID); - - /** - * Creates an object for the user with the given user id. - * If the user does not exist isValid() will return false. - * @param uid the user id - */ - // XXX KDE4: Make this explicit; give parameter as uid_t instead of "long" - KUser(long uid); - - /** - * Creates an object that contains information about the user with the given - * name. If the user does not exist isValid() will return false. - * - * @param name the name of the user - */ - // XXX KDE4: Make this explicit - KUser(const TQString& name); - - /** - * Creates an object that contains information about the user with the given - * name. If the user does not exist isValid() will return false. - * - * @param name the name of the user - */ - // XXX KDE4: Make this explicit - KUser(const char *name); - - /** - * Creates an object from a passwd structure. - * If the pointer is null isValid() will return false. - * - * @param p the passwd structure to create the user from - */ - // XXX KDE4: Make this explicit - KUser(struct passwd *p); - - /** - * Creates an object from another KUser object - * @param user the user to create the new object from - */ - KUser(const KUser & user); - - /** - * Copies a user - * @param user the user to copy - * @return this object - */ - KUser& operator =(const KUser& user); - - /** - * Two KUser objects are equal if isValid() is true - * and the uid() are identical. - */ - bool operator ==(const KUser& user) const; - - /** - * Two KUser objects are not equal if either isValid() is - * not true or uid() are not identical. - */ - bool operator !=(const KUser &user) const; - - /** - * Returns true if the user is valid. A KUser object can be invalid if - * you created it with an non-existing uid or name. - * @return true if the user is valid - */ - bool isValid() const; - - /** - * Returns the user id of the user. - * @return the id of the user or -1 if user is invalid - */ - // XXX KDE4: Make this return uid_t - long uid() const; - - - /** - * Returns the group id of the user. - * @return the id of the group or -1 if user is invalid - */ - // XXX KDE4: Make this return gid_t - long gid() const; - - /** - * Checks whether the user it the super user (root). - * @return true if the user is root - */ - bool isSuperUser() const; - - /** - * The login name of the user. - * @return the login name of the user or TQString::null if user is invalid - */ - TQString loginName() const; - - /** - * The full name of the user. - * @return the full name of the user or TQString::null if user is invalid - */ - TQString fullName() const; - - /** - * The user's room number. - * @return the room number of the user or TQString::null if not set or the - * user is invalid - */ - TQString roomNumber() const; - - /** - * The user's work phone. - * @return the work phone of the user or TQString::null if not set or the - * user is invalid - */ - TQString workPhone() const; - - /** - * The user's home phone. - * @return the home phone of the user or TQString::null if not set or the - * user is invalid - */ - TQString homePhone() const; - - /** - * The path to the user's home directory. - * @return the home directory of the user or TQString::null if the - * user is invalid - */ - TQString homeDir() const; - - /** - * The path to the user's login shell. - * @return the login shell of the user or TQString::null if the - * user is invalid - */ - TQString shell() const; - - /** - * Returns all groups of the user - * @return all groups of the user - */ - TQValueList<KUserGroup> groups() const; - - /** - * Returns all group names of the user - * @return all group names of the user - */ - TQStringList groupNames() const; - - - /** - * Destructor. - */ - ~KUser(); - - /** - * Returns all users of the system. - * @return all users of the system. - */ - static TQValueList<KUser> allUsers(); - - /** - * Returns all user names of the system. - * @return all user names of the system. - */ - static TQStringList allUserNames(); - -private: - KSharedPtr<KUserPrivate> d; - void fillPasswd(struct passwd* p); - void fillName(const char* name); -}; - -class KUserGroupPrivate; - -struct group; - -/** - * @short Represents a group on your system - * - * This class represents a group on your system. You can either get - * information about the group of the current user, of fetch information about - * a group on the system. Instances of this class will be explicitly shared, - * so copying objects is very cheap and you can safely pass objects by value. - * - * @author Jan Schaefer <j_schaef@informatik.uni-kl.de> - * @since 3.3 - */ -class KDECORE_EXPORT KUserGroup { - -public: - - /** - * Create an object from the group of the current user. - * @param mode if #KUser::UseEffectiveUID is passed the effective user - * will be used. If #KUser::UseRealUserID is passed the real user - * will be used. - * The real UID will be different than the effective UID in setuid - * programs; in such a case use the effective UID for checking - * permissions, and the real UID for displaying information about - * the group associated with the user. - */ - explicit KUserGroup(KUser::UIDMode mode = KUser::UseEffectiveUID); - - /** - * Create an object from a group id. - * If the group does not exist, isValid() will return false. - * @param gid the group id - */ - // XXX KDE4: Give parameter as gid_t instead of "long" - explicit KUserGroup(long gid); - - /** - * Create an object from a group name. - * If the group does not exist, isValid() will return false. - * @param name the name of the group - */ - explicit KUserGroup(const TQString& name); - - /** - * Create an object from a group name. - * If the group does not exist, isValid() will return false. - * @param name the name of the group - */ - explicit KUserGroup(const char *name); - - /** - * Creates an object from a group structure. - * If the pointer is null, isValid() will return false. - * @param g the group structure to create the group from. - */ - explicit KUserGroup(struct group *g); - - /** - * Creates a new KUserGroup instance from another KUserGroup object - * @param group the KUserGroup to copy - */ - KUserGroup(const KUserGroup & group); - - /** - * Copies a group - * @param group the group that should be copied - * @return this group - */ - KUserGroup& operator =(const KUserGroup& group); - - /** - * Two KUserGroup objects are equal if isValid() is true - * and gid() are identical - * @return true if the groups are identical - */ - bool operator ==(const KUserGroup& group) const; - - /** - * Two KUserGroup objects are not equal if either - * isValid() is not true or gid() are not identical - * @return true if the groups are not identical - */ - bool operator !=(const KUserGroup& group) const; - - /** - * Returns wether the group is valid. - * A KUserGroup object can be invalid if it is - * created with a non-existing gid or name. - * @return true if the group is valid - */ - bool isValid() const; - - /** - * Returns the group id of the group. - * @return the group id of the group or -1 if the group is invalid - */ - // XXX KDE4: Return gid_t instead of "long" - long gid() const; - - /** - * The name of the group. - * @return the name of the group - */ - TQString name() const; - - /** - * Returns a list of all users of the group. - * @return a list of all users of the group - */ - const TQValueList<KUser>& users() const; - - /** - * Returns a list of all user login names of the group. - * @return a list of all user login names of the group - */ - TQStringList userNames() const; - - - /** - * Destructor. - */ - ~KUserGroup(); - - /** - * Returns a list of all groups on this system - */ - static TQValueList<KUserGroup> allGroups(); - - /** - * Returns a list of all group names on this system - */ - static TQStringList allGroupNames(); - -private: - KSharedPtr<KUserGroupPrivate> d; - void fillGroup(struct group* g); - void fillName(const char* name); -}; - - -#endif diff --git a/kdecore/kvmallocator.cpp b/kdecore/kvmallocator.cpp deleted file mode 100644 index 996d55791..000000000 --- a/kdecore/kvmallocator.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (C) 1999 Waldo Bastian (bastian@kde.org) - - 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. -*/ -//---------------------------------------------------------------------------- -// -// Virtual Memory Allocator - -// TODO: Add large file support. -// TODO: Error reporting. (e.g. disk-full) - -#include <unistd.h> -#include <sys/mman.h> - -#include <tqintdict.h> -#include <tqmap.h> - -#include <ktempfile.h> -#include <kdebug.h> - -#include "kvmallocator.h" - - -#define KVM_ALIGN 4095 - -struct KVMAllocator::Block -{ - off_t start; - size_t length; // Requested length - size_t size; // Actual size - void *mmap; -}; - - -class KVMAllocatorPrivate -{ -public: - KTempFile *tempfile; - off_t max_length; - TQMap<off_t, KVMAllocator::Block> used_blocks; - TQMap<off_t, KVMAllocator::Block> free_blocks; -}; - -/** - * Create a KVMAllocator - */ -KVMAllocator::KVMAllocator() -{ - d = new KVMAllocatorPrivate; - d->tempfile = 0; - d->max_length = 0; -} - -/** - * Destruct the KVMAllocator and release all memory. - */ -KVMAllocator::~KVMAllocator() -{ - delete d->tempfile; - delete d; -} - -/** - * Allocate a virtual memory block. - * @param _size Size in bytes of the memory block. - */ -KVMAllocator::Block * -KVMAllocator::allocate(size_t _size) -{ - if (!d->tempfile) - { - d->tempfile = new KTempFile(TQString::null, "vmdata"); - d->tempfile->unlink(); - } - // Search in free list - TQMap<off_t,KVMAllocator::Block>::iterator it; - it = d->free_blocks.begin(); - while (it != d->free_blocks.end()) - { - if (it.data().size > _size) - { - Block &free_block = it.data(); - Block block; - kdDebug(180)<<"VM alloc: using block from free list "<<(long)free_block.start<<" size ="<<(long)free_block.size<<" request = "<<_size<< endl; - block.start = free_block.start; - block.length = _size; - block.size = (_size + KVM_ALIGN) & ~KVM_ALIGN; - block.mmap = 0; - free_block.size -= block.size; - free_block.start += block.size; - if (!free_block.size) - d->free_blocks.remove(it); - it = d->used_blocks.replace(block.start, block); - return &(it.data()); - } - ++it; - } - - - // Create new block - Block block; - block.start = d->max_length; - block.length = _size; - block.size = (_size + KVM_ALIGN) & ~KVM_ALIGN; - block.mmap = 0; - kdDebug(180)<<"VM alloc: using new block "<<(long)block.start<<" size ="<<(long)block.size<<" request = "<<_size<< endl; - it = d->used_blocks.replace(block.start, block); - d->max_length += block.size; - return &(it.data()); -} - -/** - * Free a virtual memory block - */ -void -KVMAllocator::free(Block *block_p) -{ - Block block = *block_p; - if (block.mmap) - { - kdDebug(180)<<"VM free: Block "<<(long)block.start<<" is still mmapped!"<<endl; - return; - } - TQMap<off_t,KVMAllocator::Block>::iterator it; - it = d->used_blocks.find(block.start); - if (it == d->used_blocks.end()) - { - kdDebug(180)<<"VM free: Block "<<(long)block.start<<" is not allocated."<<endl; - return; - } - d->used_blocks.remove(it); - it = d->free_blocks.replace(block.start, block); - TQMap<off_t,KVMAllocator::Block>::iterator before = it; - --before; - if (before != d->free_blocks.end()) - { - Block &block_before = before.data(); - if ((block_before.start + off_t(block_before.size)) == block.start) - { - // Merge blocks. - kdDebug(180) << "VM merging: Block "<< (long)block_before.start<< - " with "<< (long)block.start<< " (before)" << endl; - block.size += block_before.size; - block.start = block_before.start; - it.data() = block; - d->free_blocks.remove(before); - } - } - - TQMap<off_t,KVMAllocator::Block>::iterator after = it; - ++after; - if (after != d->free_blocks.end()) - { - Block &block_after = after.data(); - if ((block.start + off_t(block.size)) == block_after.start) - { - // Merge blocks. - kdDebug(180) << "VM merging: Block "<< (long)block.start<< - " with "<< (long)block_after.start<< " (after)" << endl; - block.size += block_after.size; - it.data() = block; - d->free_blocks.remove(after); - } - } -} - -/** - * Copy data from a virtual memory block to normal memory - */ -void -KVMAllocator::copy(void *dest, Block *src, int _offset, size_t length) -{ - (void) copyBlock(dest, src, _offset, length); -} - -bool -KVMAllocator::copyBlock(void *dest, Block *src, int _offset, size_t length) -{ - //kdDebug(180)<<"VM read: seek "<<(long)src->start<<" +"<<_offset<<":"<<length<<endl; - lseek(d->tempfile->handle(), src->start+_offset, SEEK_SET); - if (length == 0) - length = src->length - _offset; - int to_go = length; - int done = 0; - char *buf = (char *) dest; - while(to_go > 0) - { - int n = read(d->tempfile->handle(), buf+done, to_go); - if (n <= 0) - { - if (n < 0) - return false; // Error - else - return true; // End of data - } - done += n; - to_go -= n; - } - // Done. - return true; -} - -/** - * Copy data from normal memory to a virtual memory block - */ -void -KVMAllocator::copy(Block *dest, void *src, int _offset, size_t length) -{ - (void) copyBlock(dest, src, _offset, length); -} - -bool -KVMAllocator::copyBlock(Block *dest, void *src, int _offset, size_t length) -{ - //kdDebug(180)<<"VM write: seek "<<(long)dest->start<<" +"<<_offset<< ":" << length << endl; - lseek(d->tempfile->handle(), dest->start+_offset, SEEK_SET); - if (length == 0) - length = dest->length - _offset; - int to_go = length; - int done = 0; - char *buf = (char *) src; - while(to_go > 0) - { - int n = write(d->tempfile->handle(), buf+done, to_go); - if (n <= 0) return false; // Error - done += n; - to_go -= n; - } - // Done. - return true; -} - -/** - * Map a virtual memory block in memory - */ -void * -KVMAllocator::map(Block *block) -{ - if (block->mmap) - return block->mmap; - - void *result = mmap(0, block->length, PROT_READ| PROT_WRITE, - MAP_SHARED, d->tempfile->handle(), block->start); - block->mmap = result; - return block->mmap; -} - -/** - * Unmap a virtual memory block - */ -void -KVMAllocator::unmap(Block *block) -{ - // The following cast is necassery for Solaris. - // (touch it and die). --Waba - munmap((char *)block->mmap, block->length); - block->mmap = 0; -} diff --git a/kdecore/kvmallocator.h b/kdecore/kvmallocator.h deleted file mode 100644 index 50ce78e8d..000000000 --- a/kdecore/kvmallocator.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - This file is part of the KDE libraries - - Copyright (C) 2000 Waldo Bastian (bastian@kde.org) - - 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. -*/ -//---------------------------------------------------------------------------- -// -// KDE Virtual Memory Allocator - -#ifndef KVMALLOCATOR_H -#define KVMALLOCATOR_H - -#include <sys/types.h> -#include "kdelibs_export.h" - -class KVMAllocatorPrivate; - -/** - * KVMAllocator is a virtual memory allocator. - * Memory is allocated block-wise in a tmp file. - * - * @author Waldo Bastian <bastian@kde.org> - */ -class KDECORE_EXPORT KVMAllocator -{ -public: - struct Block; - - /** - * Create a KVMAllocator - */ - KVMAllocator(); - - /** - * Destruct the KVMAllocator and release all memory. - */ - ~KVMAllocator(); - - /** - * Allocate a virtual memory block. - * @param _size Size in bytes of the memory block. - * @return the allocated memory block - */ - Block *allocate(size_t _size); - - /** - * Free a virtual memory block. - * @param block the block to free - */ - void free(Block *block); - - /** - * Copy @p length bytes from @p _offset in the virtual memory block - * @p src to normal memory at address *dest. - * @param dest the destination of the data - * @param src the source block - * @param _offset the offset in the source block - * @param length the length of the data to copy - * @return true on success, false on failure, see errno for details - * @since 3.2 - */ - bool copyBlock(void *dest, Block *src, int _offset = 0, size_t length = 0); - - /** - * @deprecated - * @see copyBlock - */ - void copy(void *dest, Block *src, int _offset = 0, size_t length = 0) KDE_DEPRECATED; - - /** - * Copy @p length bytes from normal memory at address @p src to - * @p _offset in the virtual memory block @p dest. - * @param dest the block to copy the data to - * @param src the source location of the data - * @param _offset the offset in the destination block - * @param length the length of the data to copy - * @return true on success, false on failure, see errno for details - * @since 3.2 - */ - bool copyBlock(Block *dest, void *src, int _offset = 0, size_t length = 0); - - /** - * @deprecated - * @see copyBlock - */ - void copy(Block *dest, void *src, int _offset = 0, size_t length = 0) KDE_DEPRECATED; - - /** - * Map a virtual memory block in memory - * @param block the block to map - */ - void *map(Block *block); - - /** - * Unmap a virtual memory block - * @param block the block to unmap - */ - void unmap(Block *block); - -private: - KVMAllocatorPrivate *d; -}; - -#endif diff --git a/kdecore/kwin.cpp b/kdecore/kwin.cpp deleted file mode 100644 index fa68da63c..000000000 --- a/kdecore/kwin.cpp +++ /dev/null @@ -1,1267 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org) - - $Id$ - - 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. -*/ - -#include <stdlib.h> -#include <unistd.h> - -#ifdef HAVE_SYSENT_H -#include <sysent.h> -#endif - -#include <kuniqueapplication.h> -#include <tqbitmap.h> -#include <tqimage.h> -#include <tqwhatsthis.h> -#include <tqcstring.h> -#include <tqdialog.h> - -#include "config.h" -#include "kwin.h" -#include "kapplication.h" - -#include <kglobal.h> -#include <kiconloader.h> -#include <kdebug.h> - -#include <kdatastream.h> -#include <klocale.h> -#include <dcopclient.h> -#include <dcopref.h> -#ifdef Q_WS_X11 -#include <kstartupinfo.h> -#include <kxerrorhandler.h> - -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/Xutil.h> - -#include "netwm.h" - -static bool atoms_created = false; -extern Atom qt_wm_protocols; - -static Atom net_wm_context_help; -static Atom kde_wm_change_state; -static Atom kde_wm_window_opacity; -static Atom kde_wm_window_shadow; -static Atom kwin_UTF8_STRING; -static Atom net_wm_cm; - -static void kwin_net_create_atoms() { - if (!atoms_created){ - const int max = 20; - Atom* atoms[max]; - const char* names[max]; - Atom atoms_return[max]; - int n = 0; - - atoms[n] = &net_wm_context_help; - names[n++] = "_NET_WM_CONTEXT_HELP"; - - atoms[n] = &kde_wm_change_state; - names[n++] = "_KDE_WM_CHANGE_STATE"; - - atoms[n] = &kde_wm_window_opacity; - names[n++] = (char*) "_KDE_WM_WINDOW_OPACITY"; - - atoms[n] = &kde_wm_window_shadow; - names[n++] = (char*) "_KDE_WM_WINDOW_SHADOW"; - - char net_wm_cm_name[ 100 ]; - sprintf( net_wm_cm_name, "_NET_WM_CM_S%d", DefaultScreen( qt_xdisplay())); - atoms[n] = &net_wm_cm; - names[n++] = net_wm_cm_name; - - // we need a const_cast for the shitty X API - XInternAtoms( qt_xdisplay(), const_cast<char**>(names), n, false, atoms_return ); - for (int i = 0; i < n; i++ ) - *atoms[i] = atoms_return[i]; - - atoms_created = True; - } -} -#endif - -/* - Sends a client message to the ROOT window. - */ -#ifdef Q_WS_X11 -static void sendClientMessageToRoot(Window w, Atom a, long x, long y = 0, long z = 0 ){ - XEvent ev; - long mask; - - memset(&ev, 0, sizeof(ev)); - ev.xclient.type = ClientMessage; - ev.xclient.window = w; - ev.xclient.message_type = a; - ev.xclient.format = 32; - ev.xclient.data.l[0] = x; - ev.xclient.data.l[1] = y; - ev.xclient.data.l[2] = z; - mask = SubstructureRedirectMask; - XSendEvent(qt_xdisplay(), qt_xrootwin(), False, mask, &ev); -} -#endif - -/* - Send a client message to window w - */ -#ifdef Q_WS_X11 -static void sendClientMessage(Window w, Atom a, long x){ - XEvent ev; - long mask; - - memset(&ev, 0, sizeof(ev)); - ev.xclient.type = ClientMessage; - ev.xclient.window = w; - ev.xclient.message_type = a; - ev.xclient.format = 32; - ev.xclient.data.l[0] = x; - ev.xclient.data.l[1] = CurrentTime; - mask = 0L; - if (w == qt_xrootwin()) - mask = SubstructureRedirectMask; /* magic! */ - XSendEvent(qt_xdisplay(), w, False, mask, &ev); -} -#endif - -bool KWin::compositingActive() -{ -#ifdef Q_WS_X11 - kwin_net_create_atoms(); - return XGetSelectionOwner( qt_xdisplay(), net_wm_cm ) != None; -#else - return false; -#endif -} - -#ifdef Q_WS_X11 -namespace -{ -class ContextWidget : public TQWidget -{ -public: - ContextWidget(); - virtual bool x11Event( XEvent * ev); -}; - -ContextWidget::ContextWidget() - : TQWidget(0,0) - { - kwin_net_create_atoms(); - kapp->installX11EventFilter( this ); - TQWhatsThis::enterWhatsThisMode(); - TQCursor c = *TQApplication::overrideCursor(); - TQWhatsThis::leaveWhatsThisMode(); - XGrabPointer( qt_xdisplay(), qt_xrootwin(), true, - (uint)( ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | EnterWindowMask | - LeaveWindowMask ), - GrabModeAsync, GrabModeAsync, - None, c.handle(), CurrentTime ); - tqApp->enter_loop(); - } - - -bool ContextWidget::x11Event( XEvent * ev) - { - if ( ev->type == ButtonPress && ev->xbutton.button == Button1 ) { - XUngrabPointer( qt_xdisplay(), ev->xbutton.time ); - Window root; - Window child = qt_xrootwin(); - int root_x, root_y, lx, ly; - uint state; - Window w; - do { - w = child; - XQueryPointer( qt_xdisplay(), w, &root, &child, - &root_x, &root_y, &lx, &ly, &state ); - } while ( child != None && child != w ); - - ::sendClientMessage(w, qt_wm_protocols, net_wm_context_help); - XEvent e = *ev; - e.xbutton.window = w; - e.xbutton.subwindow = w; - e.xbutton.x = lx; - e.xbutton.y = ly; - XSendEvent( qt_xdisplay(), w, true, ButtonPressMask, &e ); - tqApp->exit_loop(); - return true; - } - return false; - } -} // namespace -#endif - -void KWin::invokeContextHelp() -{ -#ifdef Q_WS_X11 - ContextWidget w; -#endif -} - -void KWin::setSystemTrayWindowFor( WId trayWin, WId forWin ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), trayWin, qt_xrootwin(), 0 ); - if ( !forWin ) - forWin = qt_xrootwin(); - info.setKDESystemTrayWinFor( forWin ); - NETRootInfo rootinfo( qt_xdisplay(), NET::Supported ); - if( !rootinfo.isSupported( NET::WMKDESystemTrayWinFor )) { - DCOPRef ref( "kded", "kded" ); - if( !ref.send( "loadModule", TQCString( "kdetrayproxy" ))) - kdWarning( 176 ) << "Loading of kdetrayproxy failed." << endl; - } -#endif -} - -void KWin::activateWindow( WId win, long time ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), 0 ); - if( time == 0 ) - time = GET_QT_X_USER_TIME(); - info.setActiveWindow( win, NET::FromApplication, time, - kapp->activeWindow() ? kapp->activeWindow()->winId() : 0 ); -#endif // Q_WS_X11 ... - KUniqueApplication::setHandleAutoStarted(); -} - -void KWin::forceActiveWindow( WId win, long time ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), 0 ); - if( time == 0 ) - time = GET_QT_X_TIME(); - info.setActiveWindow( win, NET::FromTool, time, 0 ); -#endif // Q_WS_X11 - KUniqueApplication::setHandleAutoStarted(); -} - -void KWin::setActiveWindow( WId win ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), 0 ); - info.setActiveWindow( win, NET::FromUnknown, 0, 0 ); -#endif - KUniqueApplication::setHandleAutoStarted(); -} - -void KWin::demandAttention( WId win, bool set ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), 0 ); - info.setState( set ? NET::DemandsAttention : 0, NET::DemandsAttention ); -#endif -} - -void KWin::setUserTime( WId win, long time ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), 0 ); - info.setUserTime( time ); -#endif -} - -KWin::WindowInfo KWin::windowInfo( WId win, unsigned long properties, unsigned long properties2 ) -{ - return WindowInfo( win, properties, properties2 ); -} - - -WId KWin::transientFor( WId win ) -{ -#ifdef Q_WS_X11 - KXErrorHandler handler; // ignore badwindow - Window transient_for = None; - if( XGetTransientForHint( qt_xdisplay(), win, &transient_for )) - return transient_for; - // XGetTransientForHint() did sync - return None; -#else - return 0L; -#endif -} - -void KWin::setMainWindow( TQWidget* subwindow, WId mainwindow ) -{ -#ifdef Q_WS_X11 - if( mainwindow != 0 ) - { - /* - Grmbl. See TQDialog::show(). That should get fixed in Qt somehow. - */ - if( tqqt_cast< TQDialog* >( subwindow ) != NULL - && subwindow->parentWidget() == NULL - && kapp->mainWidget() != NULL ) - { - kdWarning() << "KWin::setMainWindow(): There either mustn't be kapp->mainWidget()," - " or the dialog must have a non-NULL parent, otherwise Qt will reset the change. Bummer." << endl; - } - XSetTransientForHint( qt_xdisplay(), subwindow->winId(), mainwindow ); - } - else - XDeleteProperty( qt_xdisplay(), subwindow->winId(), XA_WM_TRANSIENT_FOR ); -#endif -} - -WId KWin::groupLeader( WId win ) -{ -#ifdef Q_WS_X11 - KXErrorHandler handler; // ignore badwindow - XWMHints *hints = XGetWMHints( qt_xdisplay(), win ); - Window window_group = None; - if ( hints ) - { - if( hints->flags & WindowGroupHint ) - window_group = hints->window_group; - XFree( reinterpret_cast< char* >( hints )); - } - // XGetWMHints() did sync - return window_group; -#else - return 0L; -#endif -} - -// this one is deprecated, KWin::WindowInfo should be used instead -KWin::Info KWin::info( WId win ) -{ - Info w; -#ifdef Q_WS_X11 - NETWinInfo inf( qt_xdisplay(), win, qt_xrootwin(), - NET::WMState | - NET::WMStrut | - NET::WMWindowType | - NET::WMName | - NET::WMVisibleName | - NET::WMDesktop | - NET::WMPid | - NET::WMKDEFrameStrut | - NET::XAWMState - ); - - w.win = win; - w.state = inf.state(); - w.mappingState = inf.mappingState(); - w.strut = inf.strut(); - w.windowType = inf.windowType( -1U ); - if ( inf.name() ) { - w.name = TQString::fromUtf8( inf.name() ); - } else { - char* c = 0; - if ( XFetchName( qt_xdisplay(), win, &c ) != 0 ) { - w.name = TQString::fromLocal8Bit( c ); - XFree( c ); - } - } - if ( inf.visibleName() ) - w.visibleName = TQString::fromUtf8( inf.visibleName() ); - else - w.visibleName = w.name; - - w.desktop = inf.desktop(); - w.onAllDesktops = inf.desktop() == NETWinInfo::OnAllDesktops; - w.pid = inf.pid(); - NETRect frame, geom; - inf.kdeGeometry( frame, geom ); - w.geometry.setRect( geom.pos.x, geom.pos.y, geom.size.width, geom.size.height ); - w.frameGeometry.setRect( frame.pos.x, frame.pos.y, frame.size.width, frame.size.height ); -#endif - return w; -} - -TQPixmap KWin::icon( WId win, int width, int height, bool scale ) -{ - return icon( win, width, height, scale, NETWM | WMHints | ClassHint | XApp ); -} - - -TQPixmap KWin::icon( WId win, int width, int height, bool scale, int flags ) -{ -#ifdef Q_WS_X11 - KXErrorHandler handler; // ignore badwindow -#endif - TQPixmap result; -#ifdef Q_WS_X11 - if( flags & NETWM ) { - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), NET::WMIcon ); - NETIcon ni = info.icon( width, height ); - if ( ni.data && ni.size.width > 0 && ni.size.height > 0 ) { - TQImage img( (uchar*) ni.data, (int) ni.size.width, (int) ni.size.height, 32, 0, 0, TQImage::IgnoreEndian ); - img.setAlphaBuffer( true ); - if ( scale && width > 0 && height > 0 &&img.size() != TQSize( width, height ) && !img.isNull() ) - img = TQImage(img).smoothScale( width, height ); - if ( !img.isNull() ) - result.convertFromImage( img ); - return result; - } - } - - if( flags & WMHints ) { - Pixmap p = None; - Pixmap p_mask = None; - - XWMHints *hints = XGetWMHints(qt_xdisplay(), win ); - if (hints && (hints->flags & IconPixmapHint)){ - p = hints->icon_pixmap; - } - if (hints && (hints->flags & IconMaskHint)){ - p_mask = hints->icon_mask; - } - if (hints) - XFree((char*)hints); - - if (p != None){ - Window root; - int x, y; - unsigned int w = 0; - unsigned int h = 0; - unsigned int border_w, depth; - XGetGeometry(qt_xdisplay(), p, &root, - &x, &y, &w, &h, &border_w, &depth); - if (w > 0 && h > 0){ - TQPixmap pm(w, h, depth); - // Always detach before doing something behind QPixmap's back. - pm.detach(); - XCopyArea(qt_xdisplay(), p, pm.handle(), - qt_xget_temp_gc(qt_xscreen(), depth==1), - 0, 0, w, h, 0, 0); - if (p_mask != None){ - TQBitmap bm(w, h); - XCopyArea(qt_xdisplay(), p_mask, bm.handle(), - qt_xget_temp_gc(qt_xscreen(), true), - 0, 0, w, h, 0, 0); - pm.setMask(bm); - } - if ( scale && width > 0 && height > 0 && !pm.isNull() && - ( (int) w != width || (int) h != height) ){ - result.convertFromImage( TQImage(pm.convertToImage()).smoothScale( width, height ) ); - } else { - result = pm; - } - } - } - } - - // Since width can be any arbitrary size, but the icons cannot, - // take the nearest value for best results (ignoring 22 pixel - // icons as they don't exist for apps): - int iconWidth; - if( width < 24 ) - iconWidth = 16; - else if( width < 40 ) - iconWidth = 32; - else - iconWidth = 48; - - if( flags & ClassHint ) { - // Try to load the icon from the classhint if the app didn't specify - // its own: - if( result.isNull() ) { - - XClassHint hint; - if( XGetClassHint( qt_xdisplay(), win, &hint ) ) { - TQString className = hint.res_class; - - TQPixmap pm = KGlobal::instance()->iconLoader()->loadIcon( className.lower(), KIcon::Small, iconWidth, - KIcon::DefaultState, 0, true ); - if( scale && !pm.isNull() ) - result.convertFromImage( TQImage(pm.convertToImage()).smoothScale( width, height ) ); - else - result = pm; - - XFree( hint.res_name ); - XFree( hint.res_class ); - } - } - } - - if( flags & XApp ) { - // If the icon is still a null pixmap, load the 'xapp' icon - // as a last resort: - if ( result.isNull() ) { - TQPixmap pm = KGlobal::instance()->iconLoader()->loadIcon( "xapp", KIcon::Small, iconWidth, - KIcon::DefaultState, 0, true ); - if( scale && !pm.isNull() ) - result.convertFromImage( TQImage(pm.convertToImage()).smoothScale( width, height ) ); - else - result = pm; - } - } -#endif - return result; -} - -void KWin::setIcons( WId win, const TQPixmap& icon, const TQPixmap& miniIcon ) -{ -#ifdef Q_WS_X11 - if ( icon.isNull() ) - return; - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), 0 ); - TQImage img = TQImage(icon.convertToImage()).convertDepth( 32 ); - NETIcon ni; - ni.size.width = img.size().width(); - ni.size.height = img.size().height(); - ni.data = (unsigned char *) img.bits(); - info.setIcon( ni, true ); - if ( miniIcon.isNull() ) - return; - img = TQImage(miniIcon.convertToImage()).convertDepth( 32 ); - ni.size.width = img.size().width(); - ni.size.height = img.size().height(); - ni.data = (unsigned char *) img.bits(); - info.setIcon( ni, false ); -#endif -} - -void KWin::setType( WId win, NET::WindowType windowType ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), 0 ); - info.setWindowType( windowType ); -#endif -} - -void KWin::setState( WId win, unsigned long state ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), NET::WMState ); - info.setState( state, state ); -#endif -} - -void KWin::clearState( WId win, unsigned long state ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), NET::WMState ); - info.setState( 0, state ); -#endif -} - -void KWin::setOpacity( WId win, uint percent ) -{ -#ifdef Q_WS_X11 - kwin_net_create_atoms(); - if (percent > 99) - XDeleteProperty (qt_xdisplay(), win, kde_wm_window_opacity); - else - { - long opacity = long(0xFFFFFFFF/100.0*percent); - XChangeProperty(qt_xdisplay(), win, kde_wm_window_opacity, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); - } -#endif -} - -void KWin::setShadowSize( WId win, uint percent ) -{ -#ifdef Q_WS_X11 - kwin_net_create_atoms(); - long shadowSize = long(0xFFFFFFFF/100.0*percent); - XChangeProperty(qt_xdisplay(), win, kde_wm_window_shadow, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &shadowSize, 1L); -#endif -} - -void KWin::setOnAllDesktops( WId win, bool b ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), NET::WMDesktop ); - if ( b ) - info.setDesktop( NETWinInfo::OnAllDesktops ); - else if ( info.desktop() == NETWinInfo::OnAllDesktops ) { - NETRootInfo rinfo( qt_xdisplay(), NET::CurrentDesktop ); - info.setDesktop( rinfo.currentDesktop() ); - } -#endif -} - -void KWin::setOnDesktop( WId win, int desktop ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), NET::WMDesktop ); - info.setDesktop( desktop ); -#endif -} - -void KWin::setExtendedStrut( WId win, int left_width, int left_start, int left_end, - int right_width, int right_start, int right_end, int top_width, int top_start, int top_end, - int bottom_width, int bottom_start, int bottom_end ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), 0 ); - NETExtendedStrut strut; - strut.left_width = left_width; - strut.right_width = right_width; - strut.top_width = top_width; - strut.bottom_width = bottom_width; - strut.left_start = left_start; - strut.left_end = left_end; - strut.right_start = right_start; - strut.right_end = right_end; - strut.top_start = top_start; - strut.top_end = top_end; - strut.bottom_start = bottom_start; - strut.bottom_end = bottom_end; - info.setExtendedStrut( strut ); -#endif -} - -void KWin::setStrut( WId win, int left, int right, int top, int bottom ) -{ -#ifdef Q_WS_X11 - NETWinInfo info( qt_xdisplay(), win, qt_xrootwin(), 0 ); - NETStrut strut; - strut.left = left; - strut.right = right; - strut.top = top; - strut.bottom = bottom; - info.setStrut( strut ); -#endif -} - -int KWin::currentDesktop() -{ -#ifdef Q_WS_X11 - if (!qt_xdisplay()) -#endif - return 1; -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), NET::CurrentDesktop ); - return info.currentDesktop(); -#endif -} - -int KWin::numberOfDesktops() -{ -#ifdef Q_WS_X11 - if (!qt_xdisplay()) -#endif - return 0; -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), NET::NumberOfDesktops ); - return info.numberOfDesktops(); -#endif -} - -void KWin::setCurrentDesktop( int desktop ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), NET::CurrentDesktop ); - info.setCurrentDesktop( desktop ); -#endif -} - -void KWin::setCurrentDesktopViewport( int desktop, TQPoint viewport ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), NET::CurrentDesktop ); - NETPoint netview; - netview.x = viewport.x(); - netview.y = viewport.y(); - info.setDesktopViewport( desktop, netview ); -#endif -} - -void KWin::iconifyWindow( WId win, bool animation) -{ -#ifdef Q_WS_X11 - if ( !animation ) - { - kwin_net_create_atoms(); - sendClientMessageToRoot( win, kde_wm_change_state, IconicState, 1 ); - } - XIconifyWindow( qt_xdisplay(), win, qt_xscreen() ); -#endif -} - - -void KWin::deIconifyWindow( WId win, bool animation ) -{ -#ifdef Q_WS_X11 - if ( !animation ) - { - kwin_net_create_atoms(); - sendClientMessageToRoot( win, kde_wm_change_state, NormalState, 1 ); - } - XMapWindow( qt_xdisplay(), win ); -#endif -} - -void KWin::raiseWindow( WId win ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), NET::Supported ); - if( info.isSupported( NET::WM2RestackWindow )) - info.restackRequest( win, None, Above ); - else - XRaiseWindow( qt_xdisplay(), win ); -#endif -} - -void KWin::lowerWindow( WId win ) -{ -#ifdef Q_WS_X11 - NETRootInfo info( qt_xdisplay(), NET::Supported ); - if( info.isSupported( NET::WM2RestackWindow )) - info.restackRequest( win, None, Below ); - else - XLowerWindow( qt_xdisplay(), win ); -#endif -} - -void KWin::appStarted() -{ -#ifdef Q_WS_X11 - KStartupInfo::appStarted(); -#endif -} - -class KWin::WindowInfoPrivate -{ - public: - WindowInfoPrivate() -#ifdef Q_WS_X11 - : info( NULL ) -#endif - {} -#ifdef Q_WS_X11 - ~WindowInfoPrivate() { delete info; } - NETWinInfo* info; -#endif - WId win_; - TQString name_; - TQString iconic_name_; - TQRect geometry_; - TQRect frame_geometry_; - int ref; - bool valid; - private: - WindowInfoPrivate( const WindowInfoPrivate& ); - void operator=( const WindowInfoPrivate& ); -}; - -// KWin::info() should be updated too if something has to be changed here -KWin::WindowInfo::WindowInfo( WId win, unsigned long properties, unsigned long properties2 ) -{ -#ifdef Q_WS_X11 - KXErrorHandler handler; - d = new WindowInfoPrivate; - d->ref = 1; - if( properties == 0 ) - properties = NET::WMState | - NET::WMStrut | - NET::WMWindowType | - NET::WMName | - NET::WMVisibleName | - NET::WMIconName | - NET::WMVisibleIconName | - NET::WMDesktop | - NET::WMPid | - NET::WMKDEFrameStrut | - NET::XAWMState | - NET::WMGeometry; - if( properties & NET::WMVisibleIconName ) - properties |= NET::WMIconName | NET::WMVisibleName; // force, in case it will be used as a fallback - if( properties & NET::WMVisibleName ) - properties |= NET::WMName; // force, in case it will be used as a fallback - if( properties2 & NET::WM2ExtendedStrut ) - properties |= NET::WMStrut; // will be used as fallback - properties |= NET::XAWMState; // force to get error detection for valid() - unsigned long props[ 2 ] = { properties, properties2 }; - d->info = new NETWinInfo( qt_xdisplay(), win, qt_xrootwin(), props, 2 ); - d->win_ = win; - if( properties & NET::WMName ) { - if( d->info->name() && d->info->name()[ 0 ] != '\0' ) - d->name_ = TQString::fromUtf8( d->info->name() ); - else - d->name_ = readNameProperty( win, XA_WM_NAME ); - } - if( properties & NET::WMIconName ) { - if( d->info->iconName() && d->info->iconName()[ 0 ] != '\0' ) - d->iconic_name_ = TQString::fromUtf8( d->info->iconName()); - else - d->iconic_name_ = readNameProperty( win, XA_WM_ICON_NAME ); - } - if( properties & ( NET::WMGeometry | NET::WMKDEFrameStrut )) { - NETRect frame, geom; - d->info->kdeGeometry( frame, geom ); - d->geometry_.setRect( geom.pos.x, geom.pos.y, geom.size.width, geom.size.height ); - d->frame_geometry_.setRect( frame.pos.x, frame.pos.y, frame.size.width, frame.size.height ); - } - d->valid = !handler.error( false ); // no sync - NETWinInfo did roundtrips -#endif -} - -// this one is only to make TQValueList<> or similar happy -KWin::WindowInfo::WindowInfo() - : d( NULL ) -{ -} - -KWin::WindowInfo::~WindowInfo() -{ - if( d != NULL ) { - if( --d->ref == 0 ) { - delete d; - } - } -} - -KWin::WindowInfo::WindowInfo( const WindowInfo& wininfo ) - : d( wininfo.d ) -{ - if( d != NULL ) - ++d->ref; -} - -KWin::WindowInfo& KWin::WindowInfo::operator=( const WindowInfo& wininfo ) -{ - if( d != wininfo.d ) { - if( d != NULL ) - if( --d->ref == 0 ) - delete d; - d = wininfo.d; - if( d != NULL ) - ++d->ref; - } - return *this; -} - -bool KWin::WindowInfo::valid( bool withdrawn_is_valid ) const -{ - if( !d->valid ) - return false; - if( !withdrawn_is_valid && mappingState() == NET::Withdrawn ) - return false; - return true; -} - -WId KWin::WindowInfo::win() const -{ - return d->win_; -} - -unsigned long KWin::WindowInfo::state() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMState ) == 0, 176 ) - << "Pass NET::WMState to KWin::windowInfo()" << endl; - return d->info->state(); -#else - return 0; -#endif -} - -NET::MappingState KWin::WindowInfo::mappingState() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::XAWMState ) == 0, 176 ) - << "Pass NET::XAWMState to KWin::windowInfo()" << endl; - return d->info->mappingState(); -#else - return NET::Visible; -#endif -} - -NETExtendedStrut KWin::WindowInfo::extendedStrut() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2ExtendedStrut ) == 0, 176 ) - << "Pass NET::WM2ExtendedStrut to second argument of KWin::windowInfo()" << endl; - NETExtendedStrut ext = d->info->extendedStrut(); - NETStrut str = d->info->strut(); - if( ext.left_width == 0 && ext.right_width == 0 && ext.top_width == 0 && ext.bottom_width == 0 - && ( str.left != 0 || str.right != 0 || str.top != 0 || str.bottom != 0 )) { - // build extended from simple - if( str.left != 0 ) { - ext.left_width = str.left; - ext.left_start = 0; - ext.left_end = XDisplayHeight( qt_xdisplay(), DefaultScreen( qt_xdisplay())); - } - if( str.right != 0 ) { - ext.right_width = str.right; - ext.right_start = 0; - ext.right_end = XDisplayHeight( qt_xdisplay(), DefaultScreen( qt_xdisplay())); - } - if( str.top != 0 ) { - ext.top_width = str.top; - ext.top_start = 0; - ext.top_end = XDisplayWidth( qt_xdisplay(), DefaultScreen( qt_xdisplay())); - } - if( str.bottom != 0 ) { - ext.bottom_width = str.bottom; - ext.bottom_start = 0; - ext.bottom_end = XDisplayWidth( qt_xdisplay(), DefaultScreen( qt_xdisplay())); - } - } - return ext; -#else - NETExtendedStrut n; - return n; -#endif -} - -NETStrut KWin::WindowInfo::strut() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMStrut ) == 0, 176 ) - << "Pass NET::WMStrut to KWin::windowInfo()" << endl; - return d->info->strut(); -#else - NETStrut n; - return n; -#endif -} - -NET::WindowType KWin::WindowInfo::windowType( int supported_types ) const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMWindowType ) == 0, 176 ) - << "Pass NET::WMWindowType to KWin::windowInfo()" << endl; - return d->info->windowType( supported_types ); -#else - return 0; -#endif -} - -TQString KWin::WindowInfo::visibleNameWithState() const -{ - TQString s = visibleName(); - if ( isMinimized() ) { - s.prepend('('); - s.append(')'); - } - return s; -} - -TQString KWin::Info::visibleNameWithState() const -{ - TQString s = visibleName; - if ( isMinimized() ) { - s.prepend('('); - s.append(')'); - } - return s; -} - -TQString KWin::WindowInfo::visibleName() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMVisibleName ) == 0, 176 ) - << "Pass NET::WMVisibleName to KWin::windowInfo()" << endl; - return d->info->visibleName() && d->info->visibleName()[ 0 ] != '\0' - ? TQString::fromUtf8(d->info->visibleName()) : name(); -#else - return TQString("name"); -#endif -} - -TQString KWin::WindowInfo::name() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMName ) == 0, 176 ) - << "Pass NET::WMName to KWin::windowInfo()" << endl; - return d->name_; -#else - return TQString(); -#endif -} - -TQString KWin::WindowInfo::visibleIconNameWithState() const -{ - TQString s = visibleIconName(); - if ( isMinimized() ) { - s.prepend('('); - s.append(')'); - } - return s; -} - -TQString KWin::WindowInfo::visibleIconName() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMVisibleIconName ) == 0, 176 ) - << "Pass NET::WMVisibleIconName to KWin::windowInfo()" << endl; - if( d->info->visibleIconName() && d->info->visibleIconName()[ 0 ] != '\0' ) - return TQString::fromUtf8( d->info->visibleIconName()); - if( d->info->iconName() && d->info->iconName()[ 0 ] != '\0' ) - return TQString::fromUtf8( d->info->iconName()); - if( !d->iconic_name_.isEmpty()) - return d->iconic_name_; -#endif - return visibleName(); -} - -TQString KWin::WindowInfo::iconName() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMIconName ) == 0, 176 ) - << "Pass NET::WMIconName to KWin::windowInfo()" << endl; - if( d->info->iconName() && d->info->iconName()[ 0 ] != '\0' ) - return TQString::fromUtf8( d->info->iconName()); - if( !d->iconic_name_.isEmpty()) - return d->iconic_name_; -#endif - return name(); -} - -bool KWin::WindowInfo::isOnCurrentDesktop() const -{ -#ifdef Q_WS_X11 - return isOnDesktop( KWin::currentDesktop()); -#else - return false; -#endif -} - -bool KWin::WindowInfo::isOnDesktop( int desktop ) const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMDesktop ) == 0, 176 ) - << "Pass NET::WMDesktop to KWin::windowInfo()" << endl; - return d->info->desktop() == desktop || d->info->desktop() == NET::OnAllDesktops; -#else - return false; -#endif -} - -bool KWin::WindowInfo::onAllDesktops() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMDesktop ) == 0, 176 ) - << "Pass NET::WMDesktop to KWin::windowInfo()" << endl; - return d->info->desktop() == NET::OnAllDesktops; -#else - return false; -#endif -} - -int KWin::WindowInfo::desktop() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMDesktop ) == 0, 176 ) - << "Pass NET::WMDesktop to KWin::windowInfo()" << endl; - return d->info->desktop(); -#else - return 1; -#endif -} - -TQRect KWin::WindowInfo::geometry() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMGeometry ) == 0, 176 ) - << "Pass NET::WMGeometry to KWin::windowInfo()" << endl; - return d->geometry_; -#else - return TQRect( 100, 100, 200, 200 ); -#endif -} - -TQRect KWin::WindowInfo::frameGeometry() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS ] & NET::WMKDEFrameStrut ) == 0, 176 ) - << "Pass NET::WMKDEFrameStrut to KWin::windowInfo()" << endl; - return d->frame_geometry_; -#else - return TQRect(); -#endif -} - -WId KWin::WindowInfo::transientFor() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2TransientFor ) == 0, 176 ) - << "Pass NET::WM2TransientFor to KWin::windowInfo()" << endl; - return d->info->transientFor(); -#else - return 0; -#endif -} - -WId KWin::WindowInfo::groupLeader() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2GroupLeader ) == 0, 176 ) - << "Pass NET::WM2GroupLeader to KWin::windowInfo()" << endl; - return d->info->groupLeader(); -#else - return 0; -#endif -} - -TQCString KWin::WindowInfo::windowClassClass() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2WindowClass ) == 0, 176 ) - << "Pass NET::WM2WindowClass to KWin::windowInfo()" << endl; - return d->info->windowClassClass(); -#else - return 0; -#endif -} - -TQCString KWin::WindowInfo::windowClassName() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2WindowClass ) == 0, 176 ) - << "Pass NET::WM2WindowClass to KWin::windowInfo()" << endl; - return d->info->windowClassName(); -#else - return 0; -#endif -} - -TQCString KWin::WindowInfo::windowRole() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2WindowRole ) == 0, 176 ) - << "Pass NET::WM2WindowRole to KWin::windowInfo()" << endl; - return d->info->windowRole(); -#else - return 0; -#endif -} - -TQCString KWin::WindowInfo::clientMachine() const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2ClientMachine ) == 0, 176 ) - << "Pass NET::WM2ClientMachine to KWin::windowInfo()" << endl; - return d->info->clientMachine(); -#else - return 0; -#endif -} - -bool KWin::WindowInfo::actionSupported( NET::Action action ) const -{ -#ifdef Q_WS_X11 - kdWarning(( d->info->passedProperties()[ NETWinInfo::PROTOCOLS2 ] & NET::WM2AllowedActions ) == 0, 176 ) - << "Pass NET::WM2AllowedActions to KWin::windowInfo()" << endl; - if( allowedActionsSupported()) - return d->info->allowedActions() & action; - else -#endif - return true; // no idea if it's supported or not -> pretend it is -} - -// see NETWM spec section 7.6 -bool KWin::WindowInfo::isMinimized() const -{ -#ifdef Q_WS_X11 - if( mappingState() != NET::Iconic ) - return false; - // NETWM 1.2 compliant WM - uses NET::Hidden for minimized windows - if(( state() & NET::Hidden ) != 0 - && ( state() & NET::Shaded ) == 0 ) // shaded may have NET::Hidden too - return true; - // older WMs use WithdrawnState for other virtual desktops - // and IconicState only for minimized - return icccmCompliantMappingState() ? false : true; -#else - return false; -#endif -} - -bool KWin::Info::isMinimized() const -{ -#ifdef Q_WS_X11 - if( mappingState != NET::Iconic ) - return false; - // NETWM 1.2 compliant WM - uses NET::Hidden for minimized windows - if(( state & NET::Hidden ) != 0 - && ( state & NET::Shaded ) == 0 ) // shaded may have NET::Hidden too - return true; - // older WMs use WithdrawnState for other virtual desktops - // and IconicState only for minimized - return icccmCompliantMappingState() ? false : true; -#else - return false; -#endif -} - -bool KWin::Info::isIconified() const -{ - return isMinimized(); -} - -bool KWin::icccmCompliantMappingState() -{ -#ifdef Q_WS_X11 - static enum { noidea, yes, no } wm_is_1_2_compliant = noidea; - if( wm_is_1_2_compliant == noidea ) { - NETRootInfo info( qt_xdisplay(), NET::Supported ); - wm_is_1_2_compliant = info.isSupported( NET::Hidden ) ? yes : no; - } - return wm_is_1_2_compliant == yes; -#else - return false; -#endif -} - -bool KWin::allowedActionsSupported() -{ -#ifdef Q_WS_X11 - static enum { noidea, yes, no } wm_supports_allowed_actions = noidea; - if( wm_supports_allowed_actions == noidea ) { - NETRootInfo info( qt_xdisplay(), NET::Supported ); - wm_supports_allowed_actions = info.isSupported( NET::WM2AllowedActions ) ? yes : no; - } - return wm_supports_allowed_actions == yes; -#else - return false; -#endif -} - -TQString KWin::readNameProperty( WId win, unsigned long atom ) -{ -#ifdef Q_WS_X11 - XTextProperty tp; - char **text = NULL; - int count; -#endif - TQString result; -#ifdef Q_WS_X11 - if ( XGetTextProperty( qt_xdisplay(), win, &tp, atom ) != 0 && tp.value != NULL ) - { - if (!kwin_UTF8_STRING) - kwin_UTF8_STRING = XInternAtom( qt_xdisplay(), "UTF8_STRING", False); - - if ( tp.encoding == kwin_UTF8_STRING ) { - result = TQString::fromUtf8 ( (const char*) tp.value ); - } - else if ( XmbTextPropertyToTextList( qt_xdisplay(), &tp, &text, &count) == Success && - text != NULL && count > 0 ) { - result = TQString::fromLocal8Bit( text[0] ); - } else if ( tp.encoding == XA_STRING ) - result = TQString::fromLocal8Bit( (const char*) tp.value ); - if( text != NULL ) - XFreeStringList( text ); - XFree( tp.value ); - } -#endif - return result; -} - -//#endif diff --git a/kdecore/kwin.h b/kdecore/kwin.h deleted file mode 100644 index 36cccb125..000000000 --- a/kdecore/kwin.h +++ /dev/null @@ -1,721 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org) - - 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 KWIN_H -#define KWIN_H - -#include <sys/types.h> -#include <tqwindowdefs.h> -#include <tqstring.h> -#include <tqpixmap.h> -#include "kdelibs_export.h" - -#ifdef Q_OS_UNIX - -#include <netwm_def.h> -class NETWinInfo; - -/** - * Convenience access to certain properties and features of the - * window manager. - * - * This class is not supposed to be instantiated. It exists mostly as - * a namespace for the static member functions. - * - * In KDE 2 and KDE 3, communication with the windowmanager is done with the - * NET-protocol, a common window manager specification designed by - * various authors of X11 window managers (including those of the KDE - * project). The full specification can be found at - * www.freedesktop.org/standards/wm-spec . - * - * To access features of the NET-protocol, use the classes NETRootInfo - * and NETWinInfo. - * - * The purpose of this class is to to provide easy access to the - * most-commonly used NET-features with a simpler, KDEish interface. - * - * In addition, it encapsulates KDE functionality not yet provided by - * the NET hints. Currently that is invokeContextHelp() and - * setSystemTrayWindowFor() only. - * - * @short Class for interaction with the window manager. - * @see NET - * @see NetWinInfo - * @author Matthias Ettrich (ettrich@kde.org) -*/ -class KDECORE_EXPORT KWin -{ -public: - - /** - * Requests that window @p win is activated. - * - * There are two ways how to activate a window, by calling - * activateWindow() and forceActiveWindow(). Generally, - * applications shouldn't make attempts to explicitly activate - * their windows, and instead let the user to activate them. - * In the special cases where this may be needed, applications - * should use activateWindow(). Window manager may consider whether - * this request wouldn't result in focus stealing, which - * would be obtrusive, and may refuse the request. - * - * The usage of forceActiveWindow() is meant only for pagers - * and similar tools, which represent direct user actions - * related to window manipulation. - * Except for rare cases, this request will be always honored, - * and normal applications are forbidden to use it. - * - * In case of problems, consult the KWin README in the kdebase - * package (kdebase/kwin/README), or ask on the kwin@kde.org - * mailing list. - * - * @param win the id of the window to make active - * @param time X server timestamp of the user activity that - * caused this request - * @since 3.2 - */ - static void activateWindow( WId win, long time = 0 ); - - /** - * Sets window @p win to be the active window. Note that this - * should be called only in special cases, applications - * shouldn't force themselves or other windows to be the active - * window. Generally, this call should used only by pagers - * and similar tools. See the explanation in description - * of activateWindow(). - * - * @param win the id of the window to make active - * @param time X server timestamp of the user activity that - * caused this request - * - * @since 3.2 - */ - static void forceActiveWindow( WId win, long time = 0 ); - /** - * @deprecated Consider using activateWindow(), use forceActiveWindow() - * only if necessary. - */ - static void setActiveWindow( WId win ) KDE_DEPRECATED; - - /** - * When application finishes some operation and wants to notify - * the user about it, it can call demandAttention(). Instead - * of activating the window, which could be obtrusive, the window - * will be marked specially as demanding user's attention. - * See also explanation in description of activateWindow(). - * - * Note that it's usually better to use KNotifyClient. - * - * @since 3.2 - */ - static void demandAttention( WId win, bool set = true ); - - /** - * Sets user timestamp @p time on window @p win. The timestamp - * is expressed as XServer time. If a window - * is shown with user timestamp older than the time of the last - * user action, it won't be activated after being shown. - * The most common case is the special value 0 which means - * not to activate the window after being shown. - * - * @since 3.2 - */ - static void setUserTime( WId win, long time ); - - /** - * Invokes interactive context help. - */ - static void invokeContextHelp(); - - - /** - * Sets the parent window of @p subwindow to be @p mainwindow. - * This overrides the parent set the usual way as the TQWidget parent, - * but only for the window manager - e.g. stacking order and window grouping - * will be affected, but features like automatic deletion of children - * when the parent is deleted are unaffected and normally use - * the TQWidget parent. - * - * This function should be used before a dialog is shown for a window - * that belongs to another application. - * - * @since 3.4 - */ - static void setMainWindow( TQWidget* subwindow, WId mainwindow ); - - /** - * Makes @p trayWin a system tray window for @p forWin. - * - * A system tray window serves as an icon replacement. It's - * displayed inside the panel's system tray. - * @param trayWin the id of the system tray window - * @param forWin the id of the window represented by the system - * tray window - */ - static void setSystemTrayWindowFor( WId trayWin, WId forWin ); - - class WindowInfo; - class WindowInfoPrivate; - /** - * Returns information about window @p win. It is recommended to check - * whether the returned info is valid by calling the valid() method. - * @param win the id of the window - * @param properties all properties that should be retrieved (see NET::Property - * enum for details) - passing 0 means all properties. Unlisted properties - * cause related information to be invalid in the returned data, but - * make this function faster when not all data is needed. - * @param properties2 additional properties (see NET::Property2 enum). Note that - * specifying 0 means no properties, not all. - * @return the window information - * @since 3.2 - */ - static WindowInfo windowInfo( WId win, unsigned long properties = 0, unsigned long properties2 = 0 ); - - /** - * Returns the WM_TRANSIENT_FOR property for the given window, i.e. the mainwindow - * for this window. - * - * @param window the id of the window - * @since 3.2 - */ - static WId transientFor( WId window ); - - /** - * Returns the leader window for the group the given window is in, if any. - * @param window the id of the window - * @since 3.2 - */ - static WId groupLeader( WId window ); - - /** - * Returns an icon for window @p win. - * - * If @p width and @p height are specified, the best icon for the requested - * size is returned. - * - * If @p scale is true, the icon is smooth-scaled to have exactly - * the requested size. - * - * @param win the id of the window - * @param width the desired width, or -1 - * @param height the desired height, or -1 - * @param scale if true the icon will be scaled to the desired size. Otherwise the - * icon will not be modified. - * @return the icon of the window - */ - static TQPixmap icon( WId win, int width = -1, int height = -1, bool scale = false ); - - /** - * Masks specifying from which sources to read an icon. They are tried from the best - * until an icon is found. - * @li NETWM from property from the window manager specification - * @li WMHints from WMHints property - * @li ClassHint load icon after getting name from the classhint - * @li XApp load the standard X icon (last fallback) - */ - enum IconSource { NETWM = 1, //!< read from property from the window manager specification - WMHints = 2, //!< read from WMHints property - ClassHint = 4, //!< load icon after getting name from the classhint - XApp = 8 //!<load the standard X icon (last fallback) - }; - /** - * @overload - * - * Overloaded variant that allows specifying from which sources the icon should be read. - * You should usually prefer the simpler variant which tries all possibilities to get - * an icon. - * - * @param win the id of the window - * @param width the desired width, or -1 - * @param height the desired height, or -1 - * @param scale if true the icon will be scaled to the desired size. Otherwise the - * icon will not be modified. - * @param flags OR-ed flags from the IconSource enum - * @since 3.2 - */ - static TQPixmap icon( WId win, int width, int height, bool scale, int flags ); - - /** - * Sets an @p icon and a @p miniIcon on window @p win - * @param win the id of the window - * @param icon the new icon - * @param miniIcon the new mini icon - */ - static void setIcons( WId win, const TQPixmap& icon, const TQPixmap& miniIcon ); - - /** - * Sets the type of window @p win to @p windowType. - * - * @param win the id of the window - * @param windowType the type of the window (see NET::WindowType) - */ - static void setType( WId win, NET::WindowType windowType ); - - /** - * Sets the state of window @p win to @p state. - * - * Possible values are or'ed combinations of NET::Modal, - * NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, - * NET::SkipTaskbar, NET::SkipPager, NET::Hidden, - * NET::FullScreen, NET::KeepAbove, NET::KeepBelow, NET::StaysOnTop - * - * @param win the id of the window - * @param state the new flags that will be set - */ - static void setState( WId win, unsigned long state ); - - /** - * Clears the state of window @p win from @p state. - * - * Possible values are or'ed combinations of NET::Modal, - * NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, - * NET::SkipTaskbar, NET::SkipPager, NET::Hidden, - * NET::FullScreen, NET::KeepAbove, NET::KeepBelow, NET::StaysOnTop - * - * @param win the id of the window - * @param state the flags that will be cleared - */ - static void clearState( WId win, unsigned long state ); - - /** - * Sets the opacity of window @p win to percetage @p percent. - * - * Convenience function that just sets an X property - * needs a running composite manager for any visible effect - * - * @param win the id of the window - * @param percent the opacity value in percent (will be justified to [ 0: transparent - 100: opaque ]) - * @since 3.4 - */ - static void setOpacity( WId win, uint percent ); - - /** - * Sets the shadowsize of window @p win to percetage @p percent. - * - * Convenience function that just sets an X property - * needs the running KDE kompmgr manager for any visible effect - * - * @param win the id of the window - * @param percent the opacity value in percent (0 leads to a completely unshadowed window) - * @since 3.4 - */ - static void setShadowSize( WId win, uint percent ); - - /** - * Sets window @p win to be present on all virtual desktops if @p - * is true. Otherwise the window lives only on one single desktop. - * - * @param win the id of the window - * @param b true to show the window on all desktops, false - * otherwise - */ - static void setOnAllDesktops( WId win, bool b ); - - /** - * Moves window @p win to desktop @p desktop. - * - * @param win the id of the window - * @param desktop the number of the new desktop - */ - static void setOnDesktop( WId win, int desktop); - - /** - * Sets the strut of window @p win to @p to @p left width - * ranging from @p left_start to @p left_end on the left edge, - * and simiarly for the other edges. For not reserving a strut, pass 0 as the width. - * E.g. to reserve 10x10 square in the topleft corner, use e.g. - * setExtendedStrut( w, 10, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 ). - * - * @param win the id of the window - * @param left_width width of the strut at the left edge - * @param left_start starting y coordinate of the strut at the left edge - * @param left_end ending y coordinate of the strut at the left edge - * @param right_width width of the strut at the right edge - * @param right_start starting y coordinate of the strut at the right edge - * @param right_end ending y coordinate of the strut at the right edge - * @param top_width width of the strut at the top edge - * @param top_start starting x coordinate of the strut at the top edge - * @param top_end ending x coordinate of the strut at the top edge - * @param bottom_width width of the strut at the bottom edge - * @param bottom_start starting x coordinate of the strut at the bottom edge - * @param bottom_end ending x coordinate of the strut at the bottom edge - */ - static void setExtendedStrut( WId win, int left_width, int left_start, int left_end, - int right_width, int right_start, int right_end, int top_width, int top_start, int top_end, - int bottom_width, int bottom_start, int bottom_end ); - - /** - * @deprecated use setExtendedStrut() - * Sets the strut of window @p win to @p left, @p right, @p top, @p bottom. - * - * @param win the id of the window - * @param left the left strut - * @param right the right strut - * @param top the top strut - * @param bottom the bottom strut - */ - static void setStrut( WId win, int left, int right, int top, int bottom ); - /** - * Convenience function to access the current desktop. See NETRootInfo. - * @return the number of the current desktop - */ - static int currentDesktop(); - - /** - * Convenience function to access the number of desktops. See - * NETRootInfo. - * @return the number of desktops - */ - static int numberOfDesktops(); - - /** - * Convenience function to set the current desktop to @p desktop. - * See NETRootInfo. - * @param desktop the number of the new desktop - */ - static void setCurrentDesktop( int desktop ); - - /** - * Convenience function to set the current viewport to @p viewport. - * See NETRootInfo. - * @param desktop the number of the new desktop - * @param viewport the position of the new viewport - * @since 3.5.5 - */ - static void setCurrentDesktopViewport( int desktop, TQPoint viewport ); - - /** - * Iconifies a window. Compatible to XIconifyWindow but has an - * additional parameter @p animation. - * - * @param win the id of the window - * @param animation true to show an animation - * @see deIconifyWindow() - */ - static void iconifyWindow( WId win, bool animation = true ); - - /** - * DeIconifies a window. Compatible to XMapWindow but has an - * additional parameter @p animation. - * - * @param win the id of the window - * @param animation true to show an animation - * @see iconifyWindow() - */ - static void deIconifyWindow( WId win, bool animation = true ); - - /** - * Raises the given window. This call is only for pagers and similar - * tools that represent direct user actions. Applications should not - * use it, they should keep using TQWidget::raise() or XRaiseWindow() - * if necessary. - * @since 3.2 - */ - static void raiseWindow( WId win ); - - /** - * Lowers the given window. This call is only for pagers and similar - * tools that represent direct user actions. Applications should not - * use it, they should keep using TQWidget::lower() or XLowerWindow() - * if necessary. - * @since 3.2 - */ - static void lowerWindow( WId win ); - - /** - * @internal - * Returns true if the WM uses IconicState also for windows - * on inactive virtual desktops. - */ - static bool icccmCompliantMappingState(); - - /** - * Returns true if the WM announces which actions it allows for windows. - * @since 3.2 - */ - static bool allowedActionsSupported(); - - /** - * Function that reads and returns the contents of the given text - * property (WM_NAME, WM_ICON_NAME,...). - * @since 3.2 - */ - static TQString readNameProperty( WId window, unsigned long atom ); - - /** - * Returns true if a compositing manager is running (i.e. ARGB windows - * are supported, effects will be provided, etc.). - */ - static bool compositingActive(); - - /** - * @deprecated Use WindowInfo . - */ - struct KDECORE_EXPORT Info - { - /// The window's id. - WId win; - /// The window's state. - long unsigned int state; - /// The mapping state. - bool isMinimized() const; - bool isIconified() const; - NET::MappingState mappingState; - /// The strut. - NETStrut strut; - /// The window type. - NET::WindowType windowType; - /// The visible name of the window. - TQString visibleName; - /// The name of the window. - TQString name; - /// The number of the window's desktop. - int desktop; - /// true if the window is on all desktops. - bool onAllDesktops; - /// The process id of the window's owner - pid_t pid; - /// Position and size of the window contents. - TQRect geometry; - /// Position and size of the window's frame. - TQRect frameGeometry; - - TQString visibleNameWithState() const; - }; - - /** - * @deprecated - * Use windowInfo() . - */ - static Info info( WId win ) KDE_DEPRECATED; - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated - * Use KStartupInfo::appStarted - */ - static void appStarted() KDE_DEPRECATED; -}; - - -/** - * Information about a window. - * @since 3.2 - */ -class KDECORE_EXPORT KWin::WindowInfo -{ -public: - /** - * Reads all the info about the given window. - */ - WindowInfo( WId window, unsigned long properties, unsigned long properties2 ); - WindowInfo(); // to make TQValueList and others happy - ~WindowInfo(); - /** - * Returns false if this window info is not valid (most probably the given - * window doesn't exist). - * @param withdrawn_is_valid if true, windows in the withdrawn state - * (i.e. not managed) are also considered. This is usually not the case. - */ - bool valid( bool withdrawn_is_valid = false ) const; - /** - * Returns the window identifier. - */ - WId win() const; - /** - * Returns the window's state flags (see the NET::State enum for details). - * Requires NET::WMState passed to KWin::windowInfo(). - */ - unsigned long state() const; - /** - * Returns true if the window has the given state flag set (see the NET::State enum for details). - * Requires NET::WMState passed to KWin::windowInfo(). - * @since 3.2.1 - */ - bool hasState( unsigned long s ) const { return ( state() & s ) == s; } - /** - * Returns true if the window is minimized. Note that it is true only if - * the window is truly minimized, not shaded or on another virtual desktops, - * which makes it different from mappingState() == NET::Iconic - * or TQWidget::isMinimized(). - * Requires NET::WMState and NET::XAWMState passed to KWin::windowInfo(). - */ - bool isMinimized() const; - /** - * Returns the mapping state of the window (see NET::MappingState). Note that - * it's very likely that you don't want to use this function, and use isOnDesktop(), - * isMinimized() etc. instead. - * Requires NET::XAWMState passed to KWin::windowInfo(). - */ - NET::MappingState mappingState() const; - /** - * Returns the window extended (partial) strut. - * Requires NET::WM2ExtendedStrut passed to KWin::windowInfo(). - */ - NETExtendedStrut extendedStrut() const; - /** - * @deprecated use extendedStrut() - * Returns the window strut. - * Requires NET::WMStrut passed to KWin::windowInfo(). - */ - NETStrut strut() const; - /** - * Returns the window type of this window (see NET::WindowType). The argument - * should be all window types your application supports (see NET::WindowTypeMask). - * Requires NET::WMWindowType passed to KWin::windowInfo(). - */ - NET::WindowType windowType( int supported_types ) const; - /** - * Returns the visible name of the window (i.e. including possible <2> appended - * when there are two or more windows with the same name). - * Requires NET::WMVisibleName passed to KWin::windowInfo(). - */ - TQString visibleName() const; - /** - * Returns a visible name with state. - * - * This is a simple convenience function that returns the - * visible name but with parentheses around minimized windows. - * Requires NET::WMVisibleName, NET::WMState and NET::XAWMState passed - * to KWin::windowInfo(). - * @return the window name with state - */ - TQString visibleNameWithState() const; - /** - * Returns the name of the window, as specified by the application, without - * any modifications. You should often use visibleName() instead. - * Requires NET::WMName passed to KWin::windowInfo(). - */ - TQString name() const; - /** - * Returns the visible name of the window that should be shown in taskbar - * and all other "iconic" representations of the window. Note that this - * has nothing to do with normal icons. - * Requires NET::WMVisibleIconName passed to KWin::windowInfo(). - */ - TQString visibleIconName() const; - /** - * Returns a visible name with state. - * - * This is a simple convenience function that returns the - * visible iconic name but with parentheses around minimized windows. - * Note that this has nothing to do with normal icons. - * Requires NET::WMVisibleIconName, NET::WMState and NET::XAWMState passed - * to KWin::windowInfo(). - * @return the window iconic name with state - */ - TQString visibleIconNameWithState() const; - /** - * Returns the name of the window that should be shown in taskbar and all other - * "iconic" representations of the window. Note that this has nothing to do - * with normal icons. - * Requires NET::WMIconName passed to KWin::windowInfo(). - */ - TQString iconName() const; - /** - * Returns true if the window is on the currently active virtual desktop. - * Requires NET::WMDesktop passed to KWin::windowInfo(). - */ - bool isOnCurrentDesktop() const; - /** - * Returns true if the window is on the given virtual desktop. - * Requires NET::WMDesktop passed to KWin::windowInfo(). - */ - bool isOnDesktop( int desktop ) const; - /** - * Returns true if the window is on all desktops - * (equal to desktop()==NET::OnAllDesktops). - * Requires NET::WMDesktop passed to KWin::windowInfo(). - */ - bool onAllDesktops() const; - /** - * Returns the virtual desktop this window is on (NET::OnAllDesktops if the window - * is on all desktops). You should prefer using isOnDesktop(). - * Requires NET::WMDesktop passed to KWin::windowInfo(). - */ - int desktop() const; - /** - * Returns the position and size of the window contents. - * Requires NET::WMGeometry passed to KWin::windowInfo(). - */ - TQRect geometry() const; - /** - * Returns the frame geometry of the window, i.e. including the window decoration. - * Requires NET::WMKDEFrameStrut passed to KWin::windowInfo(). - */ - TQRect frameGeometry() const; - /** - * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow - * for this window. - * Requires NET::WM2TransientFor passed to KWin::windowInfo(). - */ - WId transientFor() const; - /** - * Returns the leader window for the group the window is in, if any. - * Requires NET::WM2GroupLeader passed to KWin::windowInfo(). - */ - WId groupLeader() const; - - /** - * Returns the class component of the window class for the window - * (i.e. WM_CLASS property). - * Requires NET::WM2WindowClass passed to KWin::windowInfo(). - * @since 3.3 - */ - TQCString windowClassClass() const; - - /** - * Returns the name component of the window class for the window - * (i.e. WM_CLASS property). - * Requires NET::WM2WindowClass passed to KWin::windowInfo(). - * @since 3.3 - */ - TQCString windowClassName() const; - - /** - * Returns the window role for the window (i.e. WM_WINDOW_ROLE property). - * Requires NET::WM2WindowRole passed to KWin::windowInfo(). - * @since 3.3 - */ - TQCString windowRole() const; - - /** - * Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property). - * Requires NET::WMClientMachine passed to KWin::windowInfo(). - * @since 3.3 - */ - TQCString clientMachine() const; - - /** - * Returns true if the given action is currently supported for the window - * by the window manager. - * Requires NET::WM2AllowedActions passed to KWin::windowInfo(). - */ - bool actionSupported( NET::Action action ) const; - - WindowInfo( const WindowInfo& ); - WindowInfo& operator=( const WindowInfo& ); -private: - WindowInfoPrivate* d; -}; - -#endif //Q_OS_UNIX - -#endif diff --git a/kdecore/kwinmodule.cpp b/kdecore/kwinmodule.cpp deleted file mode 100644 index f113570db..000000000 --- a/kdecore/kwinmodule.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/* - $Id$ - - This file is part of the KDE libraries - Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org) - - - 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. -*/ - -#include <tqwidget.h> -#ifdef Q_WS_X11 //FIXME -#include "kwinmodule.h" -#include "kwin.h" -#include <X11/Xatom.h> -#include "kapplication.h" -#include "kdebug.h" -#include <tqtl.h> -#include <tqptrlist.h> -#include <klocale.h> -#include <dcopclient.h> -#include "netwm.h" - -static KWinModulePrivate* static_d = 0; - -static unsigned long windows_properties[ 2 ] = { NET::ClientList | NET::ClientListStacking | - NET::NumberOfDesktops | - NET::DesktopGeometry | - NET::DesktopViewport | - NET::CurrentDesktop | - NET::DesktopNames | - NET::ActiveWindow | - NET::WorkArea | - NET::KDESystemTrayWindows, - NET::WM2ShowingDesktop }; - -static unsigned long desktop_properties[ 2 ] = { - NET::NumberOfDesktops | - NET::DesktopGeometry | - NET::DesktopViewport | - NET::CurrentDesktop | - NET::DesktopNames | - NET::ActiveWindow | - NET::WorkArea | - NET::KDESystemTrayWindows, - NET::WM2ShowingDesktop }; - -class KWinModulePrivate : public TQWidget, public NETRootInfo4 -{ -public: - KWinModulePrivate(int _what) - : TQWidget(0,0), NETRootInfo4( qt_xdisplay(), - _what >= KWinModule::INFO_WINDOWS ? - windows_properties : desktop_properties, - 2, - -1, false - ), - strutSignalConnected( false ), - what( _what ) - { - kapp->installX11EventFilter( this ); - (void ) kapp->desktop(); //trigger desktop widget creation to select root window events - activate(); - updateStackingOrder(); - } - ~KWinModulePrivate() - { - } - TQPtrList<KWinModule> modules; - - TQValueList<WId> windows; - TQValueList<WId> stackingOrder; - TQValueList<WId> systemTrayWindows; - - struct StrutData - { - StrutData( WId window_, const NETStrut& strut_, int desktop_ ) - : window( window_ ), strut( strut_ ), desktop( desktop_ ) {}; - StrutData() {}; // for TQValueList to be happy - WId window; - NETStrut strut; - int desktop; - }; - TQValueList<StrutData> strutWindows; - TQValueList<WId> possibleStrutWindows; - bool strutSignalConnected; - int what; - - void addClient(Window); - void removeClient(Window); - void addSystemTrayWin(Window); - void removeSystemTrayWin(Window); - - bool x11Event( XEvent * ev ); - - void updateStackingOrder(); - bool removeStrutWindow( WId ); - - TQSize numberOfViewports(int desktop) const; - TQPoint currentViewport(int desktop) const; -}; - -KWinModule::KWinModule( TQObject* parent ) - : TQObject( parent, "kwin_module" ) -{ - init(INFO_ALL); -} - -KWinModule::KWinModule( TQObject* parent, int what ) - : TQObject( parent, "kwin_module" ) -{ - init(what); -} - -void KWinModule::init(int what) -{ - if (what >= INFO_WINDOWS) - what = INFO_WINDOWS; - else - what = INFO_DESKTOP; - - if ( !static_d ) - { - static_d = new KWinModulePrivate(what); - } - else if (static_d->what < what) - { - TQPtrList<KWinModule> modules = static_d->modules; - delete static_d; - static_d = new KWinModulePrivate(what); - static_d->modules = modules; - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - (*mit)->d = static_d; - } - - d = static_d; - d->modules.append( this ); -} - -KWinModule::~KWinModule() -{ - d->modules.removeRef( this ); - if ( d->modules.isEmpty() ) { - delete d; - static_d = 0; - } -} - -const TQValueList<WId>& KWinModule::windows() const -{ - return d->windows; -} - -const TQValueList<WId>& KWinModule::stackingOrder() const -{ - return d->stackingOrder; -} - - -bool KWinModule::hasWId(WId w) const -{ - return d->windows.findIndex( w ) != -1; -} - -const TQValueList<WId>& KWinModule::systemTrayWindows() const -{ - return d->systemTrayWindows; -} - -TQSize KWinModulePrivate::numberOfViewports(int desktop) const -{ - NETSize netdesktop = desktopGeometry(desktop); - TQSize s(netdesktop.width / TQApplication::desktop()->width(), - netdesktop.height / TQApplication::desktop()->height()); - - // workaround some kwin bugs - if (s.width() < 1) s.setWidth(1); - if (s.height() < 1) s.setHeight(1); - return s; -} - -TQPoint KWinModulePrivate::currentViewport(int desktop) const -{ - NETPoint netviewport = desktopViewport(desktop); - - return TQPoint(1+(netviewport.x / TQApplication::desktop()->width()), - 1+(netviewport.y / TQApplication::desktop()->height())); -} - -bool KWinModulePrivate::x11Event( XEvent * ev ) -{ - if ( ev->xany.window == qt_xrootwin() ) { - int old_current_desktop = currentDesktop(); - WId old_active_window = activeWindow(); - int old_number_of_desktops = numberOfDesktops(); - bool old_showing_desktop = showingDesktop(); - unsigned long m[ 5 ]; - NETRootInfo::event( ev, m, 5 ); - - if (( m[ PROTOCOLS ] & CurrentDesktop ) && currentDesktop() != old_current_desktop ) - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->currentDesktopChanged( currentDesktop() ); - if (( m[ PROTOCOLS ] & ActiveWindow ) && activeWindow() != old_active_window ) - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->activeWindowChanged( activeWindow() ); - if ( m[ PROTOCOLS ] & DesktopViewport ) { - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->currentDesktopViewportChanged(currentDesktop(), - currentViewport(currentDesktop())); - } - if ( m[ PROTOCOLS ] & DesktopGeometry ) { - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->desktopGeometryChanged(currentDesktop()); - } - if ( m[ PROTOCOLS ] & DesktopNames ) - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->desktopNamesChanged(); - if (( m[ PROTOCOLS ] & NumberOfDesktops ) && numberOfDesktops() != old_number_of_desktops ) - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->numberOfDesktopsChanged( numberOfDesktops() ); - if ( m[ PROTOCOLS ] & WorkArea ) - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->workAreaChanged(); - if ( m[ PROTOCOLS ] & ClientListStacking ) { - updateStackingOrder(); - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->stackingOrderChanged(); - } - if(( m[ PROTOCOLS2 ] & WM2ShowingDesktop ) && showingDesktop() != old_showing_desktop ) { - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->showingDesktopChanged( showingDesktop()); - } - } else if ( windows.findIndex( ev->xany.window ) != -1 ){ - NETWinInfo ni( qt_xdisplay(), ev->xany.window, qt_xrootwin(), 0 ); - unsigned long dirty[ 2 ]; - ni.event( ev, dirty, 2 ); - if ( ev->type ==PropertyNotify ) { - if( ev->xproperty.atom == XA_WM_HINTS ) - dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMIcon; // support for old icons - else if( ev->xproperty.atom == XA_WM_NAME ) - dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMName; // support for old name - else if( ev->xproperty.atom == XA_WM_ICON_NAME ) - dirty[ NETWinInfo::PROTOCOLS ] |= NET::WMIconName; // support for old iconic name - } - if ( (dirty[ NETWinInfo::PROTOCOLS ] & NET::WMStrut) != 0 ) { - removeStrutWindow( ev->xany.window ); - if ( possibleStrutWindows.findIndex( ev->xany.window ) == -1 ) - possibleStrutWindows.append( ev->xany.window ); - } - if ( dirty[ NETWinInfo::PROTOCOLS ] || dirty[ NETWinInfo::PROTOCOLS2 ] ) { - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) { - emit (*mit)->windowChanged( ev->xany.window ); - emit (*mit)->windowChanged( ev->xany.window, dirty ); - emit (*mit)->windowChanged( ev->xany.window, dirty[ NETWinInfo::PROTOCOLS ] ); - if ( (dirty[ NETWinInfo::PROTOCOLS ] & NET::WMStrut) != 0 ) - emit (*mit)->strutChanged(); - } - } - } - - return false; -} - -bool KWinModulePrivate::removeStrutWindow( WId w ) -{ - for( TQValueList< StrutData >::Iterator it = strutWindows.begin(); - it != strutWindows.end(); - ++it ) - if( (*it).window == w ) { - strutWindows.remove( it ); - return true; - } - return false; -} - -void KWinModulePrivate::updateStackingOrder() -{ - stackingOrder.clear(); - for ( int i = 0; i < clientListStackingCount(); i++ ) - stackingOrder.append( clientListStacking()[i] ); -} - -void KWinModulePrivate::addClient(Window w) -{ - if ( (what >= KWinModule::INFO_WINDOWS) && !TQWidget::find( w ) ) - XSelectInput( qt_xdisplay(), w, PropertyChangeMask | StructureNotifyMask ); - bool emit_strutChanged = false; - if( strutSignalConnected && modules.count() > 0 ) { - NETWinInfo info( qt_xdisplay(), w, qt_xrootwin(), NET::WMStrut | NET::WMDesktop ); - NETStrut strut = info.strut(); - if ( strut.left || strut.top || strut.right || strut.bottom ) { - strutWindows.append( StrutData( w, strut, info.desktop())); - emit_strutChanged = true; - } - } else - possibleStrutWindows.append( w ); - windows.append( w ); - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) { - emit (*mit)->windowAdded( w ); - if ( emit_strutChanged ) - emit (*mit)->strutChanged(); - } -} - -void KWinModulePrivate::removeClient(Window w) -{ - bool emit_strutChanged = removeStrutWindow( w ); - if( strutSignalConnected && possibleStrutWindows.findIndex( w ) != -1 && modules.count() > 0 ) { - NETWinInfo info( qt_xdisplay(), w, qt_xrootwin(), NET::WMStrut ); - NETStrut strut = info.strut(); - if ( strut.left || strut.top || strut.right || strut.bottom ) { - emit_strutChanged = true; - } - } - possibleStrutWindows.remove( w ); - windows.remove( w ); - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) { - emit (*mit)->windowRemoved( w ); - if ( emit_strutChanged ) - emit (*mit)->strutChanged(); - } -} - -void KWinModulePrivate::addSystemTrayWin(Window w) -{ - systemTrayWindows.append( w ); - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->systemTrayWindowAdded( w ); -} - -void KWinModulePrivate::removeSystemTrayWin(Window w) -{ - systemTrayWindows.remove( w ); - for ( TQPtrListIterator<KWinModule> mit( modules ); mit.current(); ++mit ) - emit (*mit)->systemTrayWindowRemoved( w ); -} - -int KWinModule::currentDesktop() const -{ - return d->currentDesktop(); -} - -int KWinModule::numberOfDesktops() const -{ - return d->numberOfDesktops(); -} - -TQSize KWinModule::numberOfViewports(int desktop) const -{ - return d->numberOfViewports(desktop); -} - -TQPoint KWinModule::currentViewport(int desktop) const -{ - return d->currentViewport(desktop); -} - -WId KWinModule::activeWindow() const -{ - return d->activeWindow(); -} - -bool KWinModule::showingDesktop() const -{ - return d->showingDesktop(); -} - -TQRect KWinModule::workArea( int desktop ) const -{ - int desk = (desktop > 0 && desktop <= (int) d->numberOfDesktops() ) ? desktop : currentDesktop(); - if ( desk <= 0 ) - return TQApplication::desktop()->geometry(); - NETRect r = d->workArea( desk ); - if( r.size.width <= 0 || r.size.height <= 0 ) // not set - return TQApplication::desktop()->geometry(); - return TQRect( r.pos.x, r.pos.y, r.size.width, r.size.height ); -} - -TQRect KWinModule::workArea( const TQValueList<WId>& exclude, int desktop ) const -{ - TQRect all = TQApplication::desktop()->geometry(); - TQRect a = all; - - if (desktop == -1) - desktop = d->currentDesktop(); - - TQValueList<WId>::ConstIterator it1; - for( it1 = d->windows.begin(); it1 != d->windows.end(); ++it1 ) { - - if(exclude.findIndex(*it1) != -1) continue; - -// Kicker (very) extensively calls this function, causing hundreds of roundtrips just -// to repeatedly find out struts of all windows. Therefore strut values for strut -// windows are cached here. - NETStrut strut; - TQValueList< KWinModulePrivate::StrutData >::Iterator it2 = d->strutWindows.begin(); - for( ; - it2 != d->strutWindows.end(); - ++it2 ) - if( (*it2).window == *it1 ) - break; - if( it2 != d->strutWindows.end()) { - if(!((*it2).desktop == desktop || (*it2).desktop == NETWinInfo::OnAllDesktops )) - continue; - strut = (*it2).strut; - } else if( d->possibleStrutWindows.findIndex( *it1 ) != -1 ) { - NETWinInfo info( qt_xdisplay(), (*it1), qt_xrootwin(), NET::WMStrut | NET::WMDesktop); - strut = info.strut(); - d->possibleStrutWindows.remove( *it1 ); - d->strutWindows.append( KWinModulePrivate::StrutData( *it1, info.strut(), info.desktop())); - if(!(info.desktop() == desktop || info.desktop() == NETWinInfo::OnAllDesktops)) - continue; - } else - continue; // not a strut window - - TQRect r = all; - if ( strut.left > 0 ) - r.setLeft( r.left() + (int) strut.left ); - if ( strut.top > 0 ) - r.setTop( r.top() + (int) strut.top ); - if ( strut.right > 0 ) - r.setRight( r.right() - (int) strut.right ); - if ( strut.bottom > 0 ) - r.setBottom( r.bottom() - (int) strut.bottom ); - - TQRect tmp; - tmp = a.intersect(r); - a = tmp; - } - return a; -} - -void KWinModule::connectNotify( const char* signal ) -{ - if( !d->strutSignalConnected && qstrcmp( signal, TQT_SIGNAL(strutChanged())) == 0 ) - d->strutSignalConnected = true; - TQObject::connectNotify( signal ); -} - -TQString KWinModule::desktopName( int desktop ) const -{ - const char* name = d->desktopName( (desktop > 0 && desktop <= (int) d->numberOfDesktops() ) ? desktop : currentDesktop() ); - if ( name && name[0] ) - return TQString::fromUtf8( name ); - return i18n("Desktop %1").arg( desktop ); -} - -void KWinModule::setDesktopName( int desktop, const TQString& name ) -{ - if (desktop <= 0 || desktop > (int) d->numberOfDesktops() ) - desktop = currentDesktop(); - d->setDesktopName( desktop, name.utf8().data() ); -} - - -void KWinModule::doNotManage( const TQString& title ) -{ - if ( !kapp->dcopClient()->isAttached() ) - kapp->dcopClient()->attach(); - TQByteArray data, replyData; - TQCString replyType; - TQDataStream arg(data, IO_WriteOnly); - arg << title; - kapp->dcopClient()->call("kwin", "", "doNotManage(TQString)", - data, replyType, replyData); -} - -#include "kwinmodule.moc" -#endif diff --git a/kdecore/kwinmodule.h b/kdecore/kwinmodule.h deleted file mode 100644 index 6083d9b85..000000000 --- a/kdecore/kwinmodule.h +++ /dev/null @@ -1,362 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org) - - 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. -*/ -/* - * kwinmodule.h. Part of the KDE project. - */ - -#ifndef KWINMODULE_H -#define KWINMODULE_H - -#include <tqobject.h> -#include <tqvaluelist.h> -#include "kdelibs_export.h" - -#ifdef Q_MOC_RUN -#define Q_OS_UNIX -#endif // Q_MOC_RUN - -#ifdef Q_OS_UNIX - -class KWinModulePrivate; - -/** - * - * The class KWinModule provides information about the state of the - * window manager as required by windowmanager modules. It informs a - * module about all currently managed windows and changes to them (via - * Qt signals). - * - * KWinModule uses NETRootInfo internally. Modules written with this - * class will work fine under any window manager that implements the - * NET_WM protocol. - * - * There are no methods to manipulate windows. Those are defined in - * the classes KWin, NETWinInfo and NETRootInfo. - * - * - * @short Base class for KDE Window Manager modules. - * @author Matthias Ettrich (ettrich@kde.org) - */ -class KDECORE_EXPORT KWinModule : public TQObject -{ - Q_OBJECT - -public: - - enum { INFO_DESKTOP=1, - INFO_WINDOWS=2, - INFO_ALL=32767 }; - /** - * Creates a KWinModule object and connects to the window - * manager. - * @param parent the parent for the QObject - * @param what The information you are interested in: - * INFO_DESKTOP: currentDesktop, - * numberOfDesktops, - * desktopName, - * currentDesktopChanged, - * numberOfDesktopsChanged, - * desktopNameChanged, - * activeWindow, - * activeWindowChanged, - * workArea(int desktop), - * workAreaChanged - * - * INFO_WINDOWS: windows, - * windowAdded, - * windowRemoved, - * stackingOrder, - * systemTrayWindows, - * systemTrayWindowAdded, - * systemTrayWindowRemoved, - * windowChanged, - * strutChanged, - * workArea(const TQValueList<WId> &excludes, int desktop) - **/ - KWinModule( TQObject* parent, int what ); - /** - * Creates a KWinModule object and connects to the window - * manager. - * @param parent the parent for the QObject - **/ - KWinModule( TQObject* parent = 0 ); - - /** - * Destructor. Internal cleanup, nothing fancy. - **/ - ~KWinModule(); - - /** - * Returns the list of all toplevel windows currently managed by the - * window manager in the order of creation. Please do not rely on - * indexes of this list: Whenever you enter Qt's event loop in your - * application, it may happen that entries are removed or added. - * Your module should perhaps work on a copy of this list and verify a - * window with hasWId() before any operations. - * - * Iteration over this list can be done easily with - * \code - * TQValueList<WId>::ConstIterator it; - * for ( it = module->windows().begin(); - * it != modules->windows().end(); ++it ) { - * ... do something here, (*it) is the current WId. - * } - * \endcode - * @return the list of all toplevel windows - */ - const TQValueList<WId>& windows() const; - - /** - * Returns the list of all toplevel windows currently managed by the - * window manager in the current stacking order (from lower to - * higher). May be useful for pagers. - * @return the list of all toplevel windows in stacking order - */ - const TQValueList<WId>& stackingOrder() const; - - /** - * Test to see if @p id still managed at present. - * @param id the window id to test - * @return true if the window id is still managed - **/ - bool hasWId(WId id) const; - - /** - * Returns a list of the system tray windows. - * @return a list of all system tray windows - **/ - const TQValueList<WId>& systemTrayWindows() const; - - /** - * Returns the current virtual desktop. - * @return the current virtual desktop - **/ - int currentDesktop() const; - - /** - * Returns the number of virtual desktops. - * @return the number of virtual desktops - **/ - int numberOfDesktops() const; - - /** - * Returns the number of viewports in x and y direction - * on the virtual desktop. - * @return the number of virtual desktops - * @since 3.5.5 - **/ - TQSize numberOfViewports(int desktop) const; - - /** - * Returns the current viewport on the given virtual desktop - * @return the number of virtual desktops - * @since 3.5.5 - **/ - TQPoint currentViewport(int desktop) const; - - /** - * Returns the currently active window, or 0 if no window is active. - * @return the window id of the active window, or 0 if no window is - * active - **/ - WId activeWindow() const; - - /** - * Returns the workarea for the specified desktop, or the current - * work area if no desktop has been specified. - * @param desktop the number of the desktop to check, -1 for the - * current desktop - * @return the size and position of the desktop - **/ - TQRect workArea( int desktop = - 1 ) const; - - - /** - * Returns the workarea for the specified desktop, or the current - * work area if no desktop has been specified. Excludes struts of - * clients in the exclude List. - * - * @param excludes the list of clients whose struts will be excluded - * @param desktop the number of the desktop to check, -1 for the - * current desktop - * @return the size and position of the desktop - **/ - TQRect workArea( const TQValueList<WId> &excludes, int desktop = -1) const; - - /** - * Returns the name of the specified desktop. - * @param desktop the number of the desktop - * @return the name of the desktop - **/ - TQString desktopName( int desktop ) const; - - /** - * Sets the name of the specified desktop. - * @param desktop the number of the desktop - * @param name the new name for the desktop - **/ - void setDesktopName( int desktop, const TQString& name ); - - /** - * Returns the state of showing the desktop. - * @since 3.5 - */ - bool showingDesktop() const; - - /** - * Informs kwin via dcop to not manage a window with the - * specified @p title. - * - * Useful for swallowing legacy applications, for example java - * applets. - * - * @param title the title of the window - */ - void doNotManage( const TQString& title ); - - -signals: - - /** - * Switched to another virtual desktop. - * @param desktop the number of the new desktop - */ - void currentDesktopChanged( int desktop); - - /** - * A window has been added. - * @param id the id of the the window - */ - void windowAdded(WId id); - - /** - * A window has been removed. - * @param id the id of the window that has been removed - */ - void windowRemoved(WId id); - - /** - * Hint that \<Window> is active (= has focus) now. - * @param id the id of the window that is active - */ - void activeWindowChanged(WId id); - - /** - * Desktops have been renamed. - */ - void desktopNamesChanged(); - - /** - * The number of desktops changed. - * @param num the new number of desktops - */ - void numberOfDesktopsChanged(int num); - - /** - * Emitted when a dock window has been added. - * @param id the id of the new system tray window - */ - void systemTrayWindowAdded(WId id); - - /** - * Emitted when a dock window has been removed. - * @param id the id of the former system tray window - */ - void systemTrayWindowRemoved(WId id); - - /** - * The workarea has changed. - */ - void workAreaChanged(); - - /** - * Something changed with the struts, may or may not have changed - * the work area. Usually just using the workAreaChanged() signal - * is sufficient. - */ - void strutChanged(); - - /** - * Emitted when the stacking order of the window changed. The new order - * can be obtained with stackingOrder(). - */ - void stackingOrderChanged(); - - - /** - * The window changed. - * - * The properties parameter contains the NET properties that - * were modified (see netwm_def.h). First element are NET::Property - * values, second element are NET::Property2 values (i.e. the format - * is the same like for the NETWinInfo class constructor). - * @param id the id of the window - * @param properties the properties that were modified - */ - void windowChanged(WId id, const unsigned long* properties ); - - /** - * @deprecated - * The window changed. - * - * The unsigned int parameter contains the NET properties that - * were modified (see netwm_def.h). - * @param id the id of the window - * @param properties the properties that were modified - */ - void windowChanged(WId id, unsigned int properties); - - /** - * The window changed somehow. - * @param id the id of the window - */ - void windowChanged(WId id); - - /** - * The state of showing the desktop has changed. - * @since 3.5 - */ - void showingDesktopChanged( bool showing ); - - /** - * The state of showing the desktop has changed. - * @since 3.5.5 - */ - void desktopGeometryChanged(int desktop); - - /** - * The viewport position has changed - * @since 3.5 - */ - void currentDesktopViewportChanged(int desktop, const TQPoint& viewport); - -protected: - virtual void connectNotify( const char* signal ); - -private: - void init(int); - - KWinModulePrivate* d; - - friend class KWinModulePrivate; -}; - -#endif //Q_OS_UNIX - -#endif diff --git a/kdecore/kxerrorhandler.cpp b/kdecore/kxerrorhandler.cpp deleted file mode 100644 index 43a05f42e..000000000 --- a/kdecore/kxerrorhandler.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - - Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> - - 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. - -*/ - -#include <tqwidget.h> -#ifdef Q_WS_X11 //FIXME - -#include "kxerrorhandler.h" -#include <assert.h> -#include <stdlib.h> -#include <netwm_def.h> - -KXErrorHandler** KXErrorHandler::handlers = NULL; -int KXErrorHandler::pos = 0; -int KXErrorHandler::size = 0; - -KXErrorHandler::KXErrorHandler( Display* dpy ) - : user_handler1( NULL ), - user_handler2( NULL ), - old_handler( XSetErrorHandler( handler_wrapper )), - first_request( XNextRequest( dpy )), - display( dpy ), - was_error( false ) - { - addHandler(); - } - -KXErrorHandler::KXErrorHandler( bool (*handler)( int request, int error_code, unsigned long resource_id ), Display* dpy ) - : user_handler1( handler ), - user_handler2( NULL ), - old_handler( XSetErrorHandler( handler_wrapper )), - first_request( XNextRequest( dpy )), - display( dpy ), - was_error( false ) - { - addHandler(); - } - -KXErrorHandler::KXErrorHandler( int (*handler)( Display*, XErrorEvent* ), Display* dpy ) - : user_handler1( NULL ), - user_handler2( handler ), - old_handler( XSetErrorHandler( handler_wrapper )), - first_request( XNextRequest( dpy )), - display( dpy ), - was_error( false ) - { - addHandler(); - } - -KXErrorHandler::~KXErrorHandler() - { - XSetErrorHandler( old_handler ); - assert( this == handlers[ pos - 1 ] ); // destroy in reverse order - --pos; - } - -void KXErrorHandler::addHandler() - { - if( size == pos ) - { - size += 16; - handlers = static_cast< KXErrorHandler** >( realloc( handlers, size * sizeof( KXErrorHandler* ))); - } - handlers[ pos++ ] = this; - } - -bool KXErrorHandler::error( bool sync ) const - { - if( sync ) - XSync( display, False ); - return was_error; - } - -int KXErrorHandler::handler_wrapper( Display* dpy, XErrorEvent* e ) - { - --pos; - int ret = handlers[ pos ]->handle( dpy, e ); - ++pos; - return ret; - } - -int KXErrorHandler::handle( Display* dpy, XErrorEvent* e ) - { - if( dpy == display - // e->serial >= first_request , compare like X timestamps to handle wrapping - && NET::timestampCompare( e->serial, first_request ) >= 0 ) - { // it's for us - //qDebug( "Handling: %p", static_cast< void* >( this )); - if( user_handler1 != NULL && user_handler1( e->request_code, e->error_code, e->resourceid )) - was_error = true; - if( user_handler2 != NULL && user_handler2( dpy, e ) != 0 ) - was_error = true; - else // no handler set, simply set that there was an error - was_error = true; - return 0; - } - //qDebug( "Going deeper: %p", static_cast< void* >( this )); - return old_handler( dpy, e ); - } - -#endif diff --git a/kdecore/kxerrorhandler.h b/kdecore/kxerrorhandler.h deleted file mode 100644 index 9c0bd1e24..000000000 --- a/kdecore/kxerrorhandler.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - - Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> - - 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 KXERRORHANDLER_H -#define KXERRORHANDLER_H - -#include <tqvaluelist.h> -#include <tqwindowdefs.h> -#include <kdelibs_export.h> -#include <X11/Xlib.h> - -/** - * This class simplifies handling of X errors. It shouldn't be necessary to use - * with Qt classes, as the toolkit should handle X errors itself, so this - * class will be mainly used with direct Xlib usage, and some lowlevel classes - * like NETWinInfo. - * - * The usual usage is to create a KXErrorHandler instance right before starting - * operations that might cause X errors, and checking if there was an error - * by calling error() after the operations are finished. The handlers - * may be nested, but must be destroyed in reverse order they were created. - * - * There's no need to do X sync before creating an instance, every instance - * will handle only errors for request issued after the instance was created. - * Errors for older requests will be passed to previous error handler. - * When checking for error by calling error() at the end, it is necessary - * to sync with X, to catch all errors that were caused by requests issued - * before the call to error(). This can be done by passing true to error() - * to cause explicit XSync(), however, if the last X request needed a roundtrip - * (e.g. XGetWindowAttributes(), XGetGeometry(), etc.), it is not required - * to do an explicit sync. - * - * @author Lubos Lunak <l.lunak@kde.org> - * @short Handler for X errors - */ -class KDECORE_EXPORT KXErrorHandler - { - public: - /** - * Creates error handler that will set error flag after encountering - * any X error. - */ - KXErrorHandler( Display* dpy = qt_xdisplay()); - /** - * This constructor takes pointer to a function that will get request number, - * error code number and resource id of the failed request, as provided - * by XErrorEvent. If the function returns true, the error flag will be set. - */ - KXErrorHandler( bool (*handler)( int request, int error_code, unsigned long resource_id ), Display* dpy = qt_xdisplay()); - /** - * This constructor takes pointer to a function whose prototype matches - * the one that's used with the XSetErrorHandler() Xlib function. - * NOTE: For the error flag to be set, the function must return non-zero - * value. - */ - KXErrorHandler( int (*handler)( Display*, XErrorEvent* ), Display* dpy = qt_xdisplay()); - /** - * This function returns true if the error flag is set (i.e. no custom handler - * function was used and there was any error, or the custom handler indicated - * an error by its return value). - * - * @param sync if true, and explicit XSync() will be done. Not necessary - * when the last X request required a roundtrip. - */ - bool error( bool sync ) const; - ~KXErrorHandler(); - private: - void addHandler(); - int handle( Display* dpy, XErrorEvent* e ); - bool (*user_handler1)( int request, int error_code, unsigned long resource_id ); - int (*user_handler2)( Display*, XErrorEvent* ); - int (*old_handler)( Display*, XErrorEvent* ); - unsigned long first_request; - Display* display; - bool was_error; - static int handler_wrapper( Display*, XErrorEvent* ); - static KXErrorHandler** handlers; - static int pos; - static int size; - class KXErrorHandlerPrivate* d; - }; - -#endif diff --git a/kdecore/kxmessages.cpp b/kdecore/kxmessages.cpp deleted file mode 100644 index 6b6f971a2..000000000 --- a/kdecore/kxmessages.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** - - $Id$ - - Copyright (C) 2001-2003 Lubos Lunak <l.lunak@kde.org> - -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. - -****************************************************************************/ - -#include "kxmessages.h" - -#include <kapplication.h> - -#ifdef Q_WS_X11 // FIXME(E): Figure out what parts we can/should emulate in QT/E - -#include <X11/Xlib.h> -#include <kdebug.h> - -// for broadcasting -const long BROADCAST_MASK = PropertyChangeMask; -// CHECKME - -KXMessages::KXMessages( const char* accept_broadcast_P, TQWidget* parent_P ) - : TQWidget( parent_P ) - { - if( accept_broadcast_P != NULL ) - { - ( void ) kapp->desktop(); //trigger desktop widget creation to select root window events - kapp->installX11EventFilter( this ); // i.e. PropertyChangeMask - accept_atom1 = XInternAtom( qt_xdisplay(), accept_broadcast_P, false ); - accept_atom2 = accept_atom1; - } - else - { - accept_atom1 = accept_atom2 = None; - } - handle = new TQWidget( this ); - } - -KXMessages::KXMessages( const char* accept_broadcast_P, TQWidget* parent_P, bool obsolete_P ) - : TQWidget( parent_P ) - { - if( accept_broadcast_P != NULL ) - { - ( void ) kapp->desktop(); //trigger desktop widget creation to select root window events - kapp->installX11EventFilter( this ); // i.e. PropertyChangeMask - accept_atom2 = XInternAtom( qt_xdisplay(), accept_broadcast_P, false ); - accept_atom1 = obsolete_P ? accept_atom2 - : XInternAtom( qt_xdisplay(), TQCString( accept_broadcast_P ) + "_BEGIN", false ); - } - else - { - accept_atom1 = accept_atom2 = None; - } - handle = new TQWidget( this ); - } - -KXMessages::~KXMessages() - { -// delete d; no private data yet - } - - -void KXMessages::broadcastMessage( const char* msg_type_P, const TQString& message_P ) - { - broadcastMessage( msg_type_P, message_P, -1, true ); - } - -void KXMessages::broadcastMessage( const char* msg_type_P, const TQString& message_P, - int screen_P, bool obsolete_P ) - { - Atom a2 = XInternAtom( qt_xdisplay(), msg_type_P, false ); - Atom a1 = obsolete_P ? a2 : XInternAtom( qt_xdisplay(), TQCString( msg_type_P ) + "_BEGIN", false ); - Window root = screen_P == -1 ? qt_xrootwin() : qt_xrootwin( screen_P ); - send_message_internal( root, message_P, BROADCAST_MASK, qt_xdisplay(), - a1, a2, handle->winId()); - } - -void KXMessages::sendMessage( WId w_P, const char* msg_type_P, const TQString& message_P ) - { - sendMessage( w_P, msg_type_P, message_P, true ); - } - -void KXMessages::sendMessage( WId w_P, const char* msg_type_P, const TQString& message_P, - bool obsolete_P ) - { - Atom a2 = XInternAtom( qt_xdisplay(), msg_type_P, false ); - Atom a1 = obsolete_P ? a2 : XInternAtom( qt_xdisplay(), TQCString( msg_type_P ) + "_BEGIN", false ); - send_message_internal( w_P, message_P, 0, qt_xdisplay(), a1, a2, handle->winId()); - } - -bool KXMessages::broadcastMessageX( Display* disp, const char* msg_type_P, - const TQString& message_P ) - { - return broadcastMessageX( disp, msg_type_P, message_P, -1, true ); - } - -bool KXMessages::broadcastMessageX( Display* disp, const char* msg_type_P, - const TQString& message_P, int screen_P, bool obsolete_P ) - { - if( disp == NULL ) - return false; - Atom a2 = XInternAtom( disp, msg_type_P, false ); - Atom a1 = obsolete_P ? a2 : XInternAtom( disp, TQCString( msg_type_P ) + "_BEGIN", false ); - Window root = screen_P == -1 ? DefaultRootWindow( disp ) : RootWindow( disp, screen_P ); - Window win = XCreateSimpleWindow( disp, root, 0, 0, 1, 1, - 0, BlackPixel( disp, screen_P == -1 ? DefaultScreen( disp ) : screen_P ), - BlackPixel( disp, screen_P == -1 ? DefaultScreen( disp ) : screen_P )); - send_message_internal( root, message_P, BROADCAST_MASK, disp, - a1, a2, win ); - XDestroyWindow( disp, win ); - return true; - } - -bool KXMessages::sendMessageX( Display* disp, WId w_P, const char* msg_type_P, - const TQString& message_P ) - { - return sendMessageX( disp, w_P, msg_type_P, message_P, true ); - } - -bool KXMessages::sendMessageX( Display* disp, WId w_P, const char* msg_type_P, - const TQString& message_P, bool obsolete_P ) - { - if( disp == NULL ) - return false; - Atom a2 = XInternAtom( disp, msg_type_P, false ); - Atom a1 = obsolete_P ? a2 : XInternAtom( disp, TQCString( msg_type_P ) + "_BEGIN", false ); - Window win = XCreateSimpleWindow( disp, DefaultRootWindow( disp ), 0, 0, 1, 1, - 0, BlackPixelOfScreen( DefaultScreenOfDisplay( disp )), - BlackPixelOfScreen( DefaultScreenOfDisplay( disp ))); - send_message_internal( w_P, message_P, 0, disp, a1, a2, win ); - XDestroyWindow( disp, win ); - return true; - } - -void KXMessages::send_message_internal( WId w_P, const TQString& msg_P, long mask_P, - Display* disp, Atom atom1_P, Atom atom2_P, Window handle_P ) - { - unsigned int pos = 0; - TQCString msg = msg_P.utf8(); - unsigned int len = strlen( msg ); - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = atom1_P; // leading message - e.xclient.display = disp; - e.xclient.window = handle_P; - e.xclient.format = 8; - do - { - unsigned int i; - for( i = 0; - i < 20 && i + pos <= len; - ++i ) - e.xclient.data.b[ i ] = msg[ i + pos ]; - XSendEvent( disp, w_P, false, mask_P, &e ); - e.xclient.message_type = atom2_P; // following messages - pos += i; - } while( pos <= len ); - XFlush( disp ); - } - -bool KXMessages::x11Event( XEvent* ev_P ) - { - if( ev_P->type != ClientMessage || ev_P->xclient.format != 8 ) - return TQWidget::x11Event( ev_P ); - if( ev_P->xclient.message_type != accept_atom1 && ev_P->xclient.message_type != accept_atom2 ) - return TQWidget::x11Event( ev_P ); - char buf[ 21 ]; // can't be longer - int i; - for( i = 0; - i < 20 && ev_P->xclient.data.b[ i ] != '\0'; - ++i ) - buf[ i ] = ev_P->xclient.data.b[ i ]; - buf[ i ] = '\0'; - if( incoming_messages.contains( ev_P->xclient.window )) - { - if( ev_P->xclient.message_type == accept_atom1 && accept_atom1 != accept_atom2 ) - // two different messages on the same window at the same time shouldn't happen anyway - incoming_messages[ ev_P->xclient.window ] = TQCString(); - incoming_messages[ ev_P->xclient.window ] += buf; - } - else - { - if( ev_P->xclient.message_type == accept_atom2 && accept_atom1 != accept_atom2 ) - return false; // middle of message, but we don't have the beginning - incoming_messages[ ev_P->xclient.window ] = buf; - } - if( i < 20 ) // last message fragment - { - emit gotMessage( TQString::fromUtf8( incoming_messages[ ev_P->xclient.window ] )); - incoming_messages.remove( ev_P->xclient.window ); - } - return false; // lets other KXMessages instances get the event too - } - -#include "kxmessages.moc" -#endif diff --git a/kdecore/kxmessages.h b/kdecore/kxmessages.h deleted file mode 100644 index a5604c817..000000000 --- a/kdecore/kxmessages.h +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** - - Copyright (C) 2001-2003 Lubos Lunak <l.lunak@kde.org> - -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 __KXMESSAGES_H -#define __KXMESSAGES_H - -#include <tqwidget.h> -#include <tqcstring.h> -#include <tqmap.h> -#include <kdelibs_export.h> - -#ifdef Q_MOC_RUN -#define Q_WS_X11 -#endif // Q_MOC_RUN - -#ifdef Q_WS_X11 -#include <X11/X.h> - -class TQString; - -class KXMessagesPrivate; -/** - * Sending string messages to other applications using the X Client Messages. - * - * Used internally by KStartupInfo. You usually don't want to use this, use DCOP - * instead. - * - * @author Lubos Lunak <l.lunak@kde.org> - */ -// KDE4 - make this internal for KStartupInfo only? -class KDECORE_EXPORT KXMessages - : public TQWidget - { - Q_OBJECT - public: - /** - * Creates an instance which will receive X messages. - * - * @param accept_broadcast if non-NULL, all broadcast messages with - * this message type will be received. - * @param parent the parent of this widget - * @param obsolete always set to false (needed for backwards compatibility - * with KDE3.1 and older) - */ - KXMessages( const char* accept_broadcast, TQWidget* parent, bool obsolete ); - /** - * @deprecated - * This method is equivalent to the other constructor with obsolete = true. - */ - KXMessages( const char* accept_broadcast = NULL, TQWidget* parent = NULL ); - - virtual ~KXMessages(); - /** - * Sends the given message with the given message type only to given - * window. - * - * @param w X11 handle for the destination window - * @param msg_type the type of the message - * @param message the message itself - * @param obsolete always set to false (needed for backwards compatibility - * with KDE3.1 and older) - */ - void sendMessage( WId w, const char* msg_type, const TQString& message, - bool obsolete ); - /** - * @deprecated - * This method is equivalent to sendMessage() with obsolete = true. - */ - void sendMessage( WId w, const char* msg_type, const TQString& message ); - /** - * Broadcasts the given message with the given message type. - * @param msg_type the type of the message - * @param message the message itself - * @param screen X11 screen to use, -1 for the default - * @param obsolete always set to false (needed for backwards compatibility - * with KDE3.1 and older) - */ - void broadcastMessage( const char* msg_type, const TQString& message, - int screen, bool obsolete ); - /** - * @deprecated - * This method is equivalent to broadcastMessage() with obsolete = true. - */ - void broadcastMessage( const char* msg_type, const TQString& message ); - - /** - * Sends the given message with the given message type only to given - * window. - * - * @param disp X11 connection which will be used instead of - * qt_x11display() - * @param w X11 handle for the destination window - * @param msg_type the type of the message - * @param message the message itself - * @param obsolete always set to false (needed for backwards compatibility - * with KDE3.1 and older) - * @return false when an error occurred, true otherwise - */ - static bool sendMessageX( Display* disp, WId w, const char* msg_type, - const TQString& message, bool obsolete ); - /** - * @deprecated - * This method is equivalent to sendMessageX() with obsolete = true. - */ - static bool sendMessageX( Display* disp, WId w, const char* msg_type, - const TQString& message ); - - /** - * Broadcasts the given message with the given message type. - * - * @param disp X11 connection which will be used instead of - * qt_x11display() - * @param msg_type the type of the message - * @param message the message itself - * @param screen X11 screen to use, -1 for the default - * @param obsolete always set to false (needed for backwards compatibility - * with KDE3.1 and older) - * @return false when an error occurred, true otherwise - */ - static bool broadcastMessageX( Display* disp, const char* msg_type, - const TQString& message, int screen, bool obsolete ); - /** - * @deprecated - * This method is equivalent to broadcastMessageX() with obsolete = true. - */ - static bool broadcastMessageX( Display* disp, const char* msg_type, - const TQString& message ); - signals: - /** - * Emitted when a message was received. - * @param message the message that has been received - */ - void gotMessage( const TQString& message ); - protected: - /** - * @internal - */ - virtual bool x11Event( XEvent* ev ); - private: - static void send_message_internal( WId w_P, const TQString& msg_P, long mask_P, - Display* disp, Atom atom1_P, Atom atom2_P, Window handle_P ); - TQWidget* handle; - Atom accept_atom2; - TQCString cached_atom_name_; // KDE4 unused - Atom accept_atom1; - TQMap< WId, TQCString > incoming_messages; - KXMessagesPrivate* d; - }; - -#endif -#endif diff --git a/kdecore/language.codes b/kdecore/language.codes deleted file mode 100644 index bb33f3456..000000000 --- a/kdecore/language.codes +++ /dev/null @@ -1,3 +0,0 @@ -[TwoLetterCodes] -nb=nb,no -nn=nn,no diff --git a/kdecore/libintl.cpp b/kdecore/libintl.cpp deleted file mode 100644 index 83e2d3711..000000000 --- a/kdecore/libintl.cpp +++ /dev/null @@ -1,420 +0,0 @@ -/* libintl.cpp -- gettext related functions from glibc-2.0.5 - Copyright (C) 1995 Software Foundation, Inc. - -This file is part of the KDE libraries, but it's derived work out -of glibc. The master sources can be found in - - bindtextdom.c - dcgettext.c - dgettext.c - explodename.c - finddomain.c - gettext.c - gettext.h - gettextP.h - hash-string.h - l10nflist.c - libintl.h - loadinfo.h - loadmsgcat.c - localealias.c - textdomain.c - -which are part of glibc. The license is the same as in GLIBC, which -is the GNU Library General Public License. See COPYING.LIB for more -details. - -*/ - -/* gettext.c -- implementation of gettext(3) function - Copyright (C) 1995 Software Foundation, Inc. - -This file is part of the GNU C Library. Its master source is NOT part of -the C library, however. The master source lives in /gd/gnu/lib. - -The GNU C 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. - -The GNU C 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 the GNU C 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 "kdelibs_export.h" -#include "kde_file.h" -#include <config.h> - -#include <tqglobal.h> - -#include <stdlib.h> - -#if defined HAVE_STRING_H -# include <string.h> -#else -# include <strings.h> -#endif - -#include <sys/types.h> -#include <fcntl.h> -#include <sys/stat.h> - -#if defined HAVE_UNISTD_H -# include <unistd.h> -#endif - -#if (defined HAVE_MMAP && defined HAVE_MUNMAP) -# include <sys/mman.h> -#endif - -#ifndef W -# define W(flag, data) ((flag) ? SWAP (data) : (data)) -#endif - -typedef TQ_UINT32 nls_uint32; - -struct loaded_domain -{ - const char *data; -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - int use_mmap; - size_t mmap_size; -#endif - int must_swap; - nls_uint32 nstrings; - struct string_desc *orig_tab; - struct string_desc *trans_tab; - nls_uint32 hash_size; - nls_uint32 *hash_tab; -}; - -struct kde_loaded_l10nfile -{ - const char *filename; - int decided; - - const void *data; - - kde_loaded_l10nfile() : filename(0), decided(0), data(0) {} -}; - -void k_nl_load_domain(struct kde_loaded_l10nfile *__domain); - -static inline nls_uint32 -SWAP (nls_uint32 i) -{ - return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); -} - -/* @@ end of prolog @@ */ - -/* The magic number of the GNU message catalog format. */ -#define _MAGIC 0x950412de -#define _MAGIC_SWAPPED 0xde120495 - -/* Revision number of the currently used .mo (binary) file format. */ -#define MO_REVISION_NUMBER 0 - - -/* Defines the so called `hashpjw' function by P.J. Weinberger - [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, - 1986, 1987 Bell Telephone Laboratories, Inc.] */ -static inline unsigned long hash_string (const char *__str_param); - -/* @@ end of prolog @@ */ - -/* Header for binary .mo file format. */ -struct mo_file_header -{ - /* The magic number. */ - nls_uint32 magic; - /* The revision number of the file format. */ - nls_uint32 revision; - /* The number of strings pairs. */ - nls_uint32 nstrings; - /* Offset of table with start offsets of original strings. */ - nls_uint32 orig_tab_offset; - /* Offset of table with start offsets of translation strings. */ - nls_uint32 trans_tab_offset; - /* Size of hashing table. */ - nls_uint32 hash_tab_size; - /* Offset of first hashing entry. */ - nls_uint32 hash_tab_offset; -}; - -struct string_desc -{ - /* Length of addressed string. */ - nls_uint32 length; - /* Offset of string in file. */ - nls_uint32 offset; -}; - -/* Prototypes for local functions. */ -char *k_nl_find_msg (struct kde_loaded_l10nfile *domain_file, - const char *msgid); - -char * -k_nl_find_msg (struct kde_loaded_l10nfile *domain_file, const char *msgid) -{ - size_t top, act, bottom; - struct loaded_domain *domain; - - if (domain_file->decided == 0) - k_nl_load_domain (domain_file); - - if (domain_file->data == NULL) - return NULL; - - domain = (struct loaded_domain *) domain_file->data; - - /* Locate the MSGID and its translation. */ - if (domain->hash_size > 2 && domain->hash_tab != NULL) - { - /* Use the hashing table. */ - nls_uint32 len = strlen (msgid); - nls_uint32 hash_val = hash_string (msgid); - nls_uint32 idx = hash_val % domain->hash_size; - nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); - nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]); - - if (nstr == 0) - /* Hash table entry is empty. */ - return NULL; - - if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len - && strcmp (msgid, - domain->data + W (domain->must_swap, - domain->orig_tab[nstr - 1].offset)) == 0) - return (char *) domain->data + W (domain->must_swap, - domain->trans_tab[nstr - 1].offset); - - while (1) - { - if (idx >= domain->hash_size - incr) - idx -= domain->hash_size - incr; - else - idx += incr; - - nstr = W (domain->must_swap, domain->hash_tab[idx]); - if (nstr == 0) - /* Hash table entry is empty. */ - return NULL; - - if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len - && strcmp (msgid, - domain->data + W (domain->must_swap, - domain->orig_tab[nstr - 1].offset)) - == 0) - return (char *) domain->data - + W (domain->must_swap, domain->trans_tab[nstr - 1].offset); - } - /* NOTREACHED */ - } - - /* Now we try the default method: binary search in the sorted - array of messages. */ - bottom = 0; - top = domain->nstrings; - act = top; - while (bottom < top) - { - int cmp_val; - - act = (bottom + top) / 2; - cmp_val = strcmp (msgid, domain->data - + W (domain->must_swap, - domain->orig_tab[act].offset)); - if (cmp_val < 0) - top = act; - else if (cmp_val > 0) - bottom = act + 1; - else - break; - } - - /* If an translation is found return this. */ - return bottom >= top ? NULL : (char *) domain->data - + W (domain->must_swap, - domain->trans_tab[act].offset); -} - -/* @@ begin of epilog @@ */ -/* We assume to have `unsigned long int' value with at least 32 bits. */ -#define HASHWORDBITS 32 - -static inline unsigned long -hash_string (const char *str_param) -{ - unsigned long int hval, g; - const char *str = str_param; - - /* Compute the hash value for the given string. */ - hval = 0; - while (*str != '\0') - { - hval <<= 4; - hval += (unsigned long) *str++; - g = hval & ((unsigned long) 0xf << (HASHWORDBITS - 4)); - if (g != 0) - { - hval ^= g >> (HASHWORDBITS - 8); - hval ^= g; - } - } - return hval; -} - -/* Load the message catalogs specified by FILENAME. If it is no valid - message catalog do nothing. */ -void -k_nl_load_domain (struct kde_loaded_l10nfile *domain_file) -{ - int fd; - struct stat st; - struct mo_file_header *data = (struct mo_file_header *) -1; -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - int use_mmap = 0; -#endif - struct loaded_domain *domain; - - domain_file->decided = 1; - domain_file->data = NULL; - - /* If the record does not represent a valid locale the FILENAME - might be NULL. This can happen when according to the given - specification the locale file name is different for XPG and CEN - syntax. */ - if (domain_file->filename == NULL) - return; - - /* Try to open the addressed file. */ - fd = KDE_open (domain_file->filename, O_RDONLY); - if (fd == -1) - return; - - /* We must know about the size of the file. */ - if (fstat (fd, &st) != 0 - || st.st_size < (off_t) sizeof (struct mo_file_header)) - { - /* Something went wrong. */ - close (fd); - return; - } - -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - /* Now we are ready to load the file. If mmap() is available we try - this first. If not available or it failed we try to load it. */ - data = (struct mo_file_header *) mmap (NULL, st.st_size, PROT_READ, - MAP_PRIVATE, fd, 0); - - if (data != (struct mo_file_header *) -1) - { - /* mmap() call was successful. */ - close (fd); - use_mmap = 1; - } -#endif - - /* If the data is not yet available (i.e. mmap'ed) we try to load - it manually. */ - if (data == (struct mo_file_header *) -1) - { - off_t to_read; - char *read_ptr; - - data = (struct mo_file_header *) malloc (st.st_size); - if (data == NULL) - return; - - to_read = st.st_size; - read_ptr = (char *) data; - do - { - long int nb = (long int) read (fd, read_ptr, to_read); - if (nb == -1) - { - close (fd); - return; - } - - read_ptr += nb; - to_read -= nb; - } - while (to_read > 0); - - close (fd); - } - - /* Using the magic number we can test whether it really is a message - catalog file. */ - if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) - { - /* The magic number is wrong: not a message catalog file. */ -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - if (use_mmap) - munmap ((char *) data, st.st_size); - else -#endif - free (data); - return; - } - - domain_file->data - = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); - if (domain_file->data == NULL) - return; - - domain = (struct loaded_domain *) domain_file->data; - domain->data = (char *) data; -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - domain->use_mmap = use_mmap; - domain->mmap_size = st.st_size; -#endif - domain->must_swap = data->magic != _MAGIC; - - /* Fill in the information about the available tables. */ - switch (W (domain->must_swap, data->revision)) - { - case 0: - domain->nstrings = W (domain->must_swap, data->nstrings); - domain->orig_tab = (struct string_desc *) - ((char *) data + W (domain->must_swap, data->orig_tab_offset)); - domain->trans_tab = (struct string_desc *) - ((char *) data + W (domain->must_swap, data->trans_tab_offset)); - domain->hash_size = W (domain->must_swap, data->hash_tab_size); - domain->hash_tab = (nls_uint32 *) - ((char *) data + W (domain->must_swap, data->hash_tab_offset)); - break; - default: - /* This is an illegal revision. */ -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - if (use_mmap) - munmap ((char *) data, st.st_size); - else -#endif - free (data); - free (domain); - domain_file->data = NULL; - return; - } -} - -void -k_nl_unload_domain (struct loaded_domain *domain) -{ -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) - if (domain->use_mmap) - munmap ((caddr_t) domain->data, domain->mmap_size); - else -# endif - free ((void *) domain->data); - - free (domain); -} diff --git a/kdecore/libkdecore.nmcheck b/kdecore/libkdecore.nmcheck deleted file mode 100644 index 7c017a6e4..000000000 --- a/kdecore/libkdecore.nmcheck +++ /dev/null @@ -1,79 +0,0 @@ -# KDE namespace check file - -# tdecore classes -K*::* - -# these should preferably go in some namespace in KDE4 -NETRootInfo::* -NETRootInfo2::* -NETRootInfo3::* -NETWinInfo::* -NET::* -kdbgstream::* -kndbgstream::* -kdDebug -kndDebug -kdWarning -kdError -kdFatal -kdBacktrace -kndBacktrace -kdClearDebugConfig -flush -perror -endl -i18n -DesktopIcon -DesktopIconSet -BarIcon -BarIconSet -SmallIcon -SmallIconSet -MainBarIcon -MainBarIconSet -UserIcon -UserIconSet -IconSize -locate -locateLocal -checkAccess -k_nl_* -kde_* -urlcmp -operator>> -operator<< -qt_qclipboard_bailout_hack -kasciistricmp - -# from libtldl -lt_dl* - -# from tdefakes -setenv -unsetenv -usleep -random -srandom -seteuid -mkstemps -mkstemp -revoke -strlcpy -strlcat -vsnprintf -snprintf - -# from malloc -malloc -free -realloc -calloc -mallinfo -mallopt -cfree -valloc -pvalloc -posix_memalign -memalign -kde_malloc_is_used -kde_malloc_dummy_function diff --git a/kdecore/libkdecore_weak.nmcheck b/kdecore/libkdecore_weak.nmcheck deleted file mode 100644 index 43efca972..000000000 --- a/kdecore/libkdecore_weak.nmcheck +++ /dev/null @@ -1,28 +0,0 @@ -# KDE namespace check file - -# kdelibs classes -KApplication::* - -# these should preferably go in some namespace in KDE4 -kDebugPrivate::* -kMax -kMin -kAbs -NETIcon::* -NETPoint::* -NETRect::* -NETSize::* -NETStrut::* -NETRArray::* -NETWinInfoPrivate::* -NETRootInfoPrivate::* -kdbgstream::* -kndbgstream::* -flush -perror -endl - -# from libc_nonshared -stat -lstat -fstat diff --git a/kdecore/libqt-mt.nmcheck b/kdecore/libqt-mt.nmcheck deleted file mode 100644 index 77b200029..000000000 --- a/kdecore/libqt-mt.nmcheck +++ /dev/null @@ -1,43 +0,0 @@ -# KDE namespace check file - -# Qt classes -Q*::* -qt_* - -# these should preferably go in some namespace in Qt4 -qDebug -qFatal -qWarning -qApp -qAppName -qVersion -qSysInfo -qObsolete -bitBlt -static_QUType_* -TID_QUType_* -operator>> -operator<< -operator== -operator!= -operator<= -operator>= -operator< -operator> -operator= -operator++ -operator* -operator! -operator^ -operator& -operator/ -ws -bin -dec -oct -hex -endl - -# Xinerama -Xinerama* -XPanoramiX* diff --git a/kdecore/libqt-mt_weak.nmcheck b/kdecore/libqt-mt_weak.nmcheck deleted file mode 100644 index d0b00eee4..000000000 --- a/kdecore/libqt-mt_weak.nmcheck +++ /dev/null @@ -1,34 +0,0 @@ -# KDE namespace check file - -# Qt classes -Q*::* - -qstrcmp -qstrcpy -qstrlen -qAlpha -qRed -qGreen -qBlue -qGray -qRgba -qRgb -qSwap -qCopy -qHeapSort -qHeapSortHelper -qHeapSortPushDown -qMakePair - -operator+ -operator- -operator++ -operator-- -operator== -operator!= -operator<= -operator>= -operator> -operator< -operator>> -operator<< diff --git a/kdecore/malloc/CMakeLists.txt b/kdecore/malloc/CMakeLists.txt deleted file mode 100644 index 400320c88..000000000 --- a/kdecore/malloc/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${CMAKE_BINARY_DIR} -) - -tde_add_library( klmalloc STATIC_PIC - SOURCES malloc.c -) diff --git a/kdecore/malloc/Makefile.am b/kdecore/malloc/Makefile.am deleted file mode 100644 index 60befbfa0..000000000 --- a/kdecore/malloc/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# This file is part of the KDE libraries -# -# $Id$ -# -# Copyright (C) 1996-1997 Matthias Kalle Dalheimer (kalle@kde.org) -# (C) 1997 Stephan Kulow (coolo@kde.org) - -# 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. - -INCLUDES = $(all_includes) - -AM_DEFS = $(KDE_FORCE_INLINE) - -noinst_LTLIBRARIES = libklmalloc.la - -libklmalloc_la_SOURCES = malloc.c - -EXTRA_DIST = x86.h glibc.h diff --git a/kdecore/malloc/README b/kdecore/malloc/README deleted file mode 100644 index 6a24a39db..000000000 --- a/kdecore/malloc/README +++ /dev/null @@ -1,56 +0,0 @@ - - This malloc is based on Doug Lea's malloc ( ftp://gee.cs.oswego.edu/pub/misc/ ), the changes -are listed below. See http://lists.kde.org/?l=kde-core-devel&m=101351949010285&w=2 for details. -Basically, it's here because for now it has better performance than both glibc-2.2.x and -FreeBSD's libc. - - There's a new configure switch, --enable-fast-malloc. By default it's turned off, disabling -the system libc one and using this one. Using --enable-fast-malloc=full enables this -malloc unconditionally, aiming for the maximum performance. By using only --enable-fast-malloc, -it's possible to select both malloc implementations at runtime. When $KDE_MALLOC is set to 0, -the system libc malloc is used, otherwise this malloc is used. - - For now, the requirements are : - - x86 CPU (because of the spinlock implementation in assembler), it should be easy to add - new ones - - glibc (for --enable-fast-malloc=yes, =full doesn't need it), because it needs to refer - to the libc implementation of malloc (__libc_malloc etc.) - - gcc (for __inline__ , nothing else should depend on gcc) - - - If you have any problem with this malloc, try first using --enable-fast-malloc=debug and -recompiling libtdecore, or use valgrind. This malloc seems to be more vulnerable to heap -corruption, such as deleting a block twice, so faulty code may run without problems -with standard malloc shipped with your libc, but it will crash with this malloc. In case -you think there's any problem with this malloc, please mail me. - -changes (against malloc-2.7.0): - -#define USE_MALLOC_LOCK -#define INLINE __inline__ -#define USE_MEMCPY 0 -#define MMAP_CLEARS 1 -made all functions INLINE -added #ifdef KDE_MALLOC_DEBUG -> #define DEBUG -reordered all functions in order to avoid 'warning: `XYZ' declared inline after being called' - especially moved the public_* ones at the end of the file -commented out #including malloc.h -added #include <config.h> at the top and enclosed whole file in #ifdef KDE_MALLOC -taken posix_memalign() from glibc -removed public icalloc(),icomalloc(),mtrim(),musable() (they don't exist everywhere anyway) -enclosed the pthreads part by #if 0 and replaced it with spinlock from glibc CVS (in x86.h) - also added : ----------- -static mutex_t spinlock = MUTEX_INITIALIZER; -#define MALLOC_PREACTION lock( &spinlock ) -#define MALLOC_POSTACTION unlock( &spinlock ) ----------- -public functions call either functions in this malloc or in libc, depending on $KDE_MALLOC -the kde_malloc_is_used hack - - -TODO: -malloc_set_state/malloc_get_state ? - - -Lubos Lunak <l.lunak@kde.org> diff --git a/kdecore/malloc/configure.in.in b/kdecore/malloc/configure.in.in deleted file mode 100644 index d669f8daa..000000000 --- a/kdecore/malloc/configure.in.in +++ /dev/null @@ -1,134 +0,0 @@ -dnl --enable-fast-malloc - depends on $KDE_MALLOC -dnl --disable-fast-malloc - disabled -dnl --enable-fast-malloc=full - enabled always -dnl -dnl gcc3.0 needs -finline-limit=100000 (large num) - -kde_fast_malloc= -AC_ARG_ENABLE(fast-malloc, - [ --enable-fast-malloc Use own malloc implementation : yes,no,full,debug], - [ - if test "$enableval" = "full"; then - kde_fast_malloc=full - elif test "$enableval" = "yes"; then - kde_fast_malloc=yes - elif test "$enableval" = "debug"; then - kde_fast_malloc=debug - else - kde_fast_malloc=no - fi - ], - [ - kde_fast_malloc=notgiven - ]) - -dnl gcc needed for __inline__ -if test "$kde_fast_malloc" != "no"; then - if test "$GCC" != "yes"; then - if test "$kde_fast_malloc" = "notgiven"; then - kde_fast_malloc=no - else - AC_MSG_ERROR([Fast malloc needs GCC.]) - kde_fast_malloc=no - fi - fi -fi - -if test "$kde_fast_malloc" != "no"; then -dnl platforms for which there's a spinlock implementation - case $target_cpu in - i?86) - AC_DEFINE(KDE_MALLOC_X86, 1, [The platform is x86]) - ;; - *) - if test "$kde_fast_malloc" = "notgiven"; then - kde_fast_malloc=no - else - AC_MSG_ERROR([Fast malloc is not supported on this platform (missing spinlock implementation).]) - fi - ;; - esac -dnl warn on untested platforms - case $target_os in - linux*) ;; - freebsd*) ;; - *) - if test "$kde_fast_malloc" = "notgiven"; then - kde_fast_malloc=no - else - AC_MSG_WARN([Fast malloc is not tested on this platform. The build may fail or the executables may crash.]) - fi - ;; - esac -fi - -if test "$kde_fast_malloc" = "yes" -o "$kde_fast_malloc" = "notgiven" -o "$kde_fast_malloc" = "debug"; then -dnl $KDE_MALLOC needs glibc (__libc_malloc etc.) - AC_CACHE_CHECK([if the libc is glibc],kde_cv_libc_glibc, - [AC_TRY_COMPILE( - [#include<stdlib.h>], - [ - #ifndef __GLIBC__ - error no glibc - #endif - ], - [kde_cv_libc_glibc=yes], - [kde_cv_libc_glibc=no]) - ]) - if test "$kde_cv_libc_glibc" = "yes"; then - AC_DEFINE(KDE_MALLOC_GLIBC, 1, [The libc used is glibc]) - else - if test "$kde_fast_malloc" = "notgiven"; then - kde_fast_malloc=notgiven_full - elif test "$enableval" = "debug"; then - AC_MSG_WARN([This libc is not supported for fast malloc. Runtime disabling won't work.]) - kde_fast_malloc=debug_full - else - AC_MSG_ERROR([This libc is not supported for fast malloc. Either use --enable-fast-malloc=full, or don't use it at all.]) - fi - fi -fi - -if test "$kde_fast_malloc" = "notgiven"; then - #kde_fast_malloc=yes - kde_fast_malloc=no -fi -if test "$kde_fast_malloc" = "notgiven_full"; then - if test "$kde_use_debug_code" = "no"; then - #kde_fast_malloc=full - kde_fast_malloc=no - else - kde_fast_malloc=no - fi -fi - -AC_MSG_CHECKING(whether to enable fast malloc) -if test "$kde_fast_malloc" = "yes"; then - AC_MSG_RESULT(yes) -elif test "$kde_fast_malloc" = "full"; then - AC_MSG_RESULT([yes(full)]) -elif test "$kde_fast_malloc" = "debug"; then - AC_MSG_RESULT([yes(debug)]) -elif test "$kde_fast_malloc" = "debug_full"; then - AC_MSG_RESULT([yes(full+debug)]) -else - AC_MSG_RESULT(no) -fi - -if test "$kde_fast_malloc" != "no"; then - AC_DEFINE(KDE_MALLOC, 1, [Use own malloc implementation]) -fi - -if test "$kde_fast_malloc" = "debug" -o "$kde_fast_malloc" = "debug_full"; then - AC_DEFINE(KDE_MALLOC_DEBUG, 1, [Enable debugging in fast malloc]) -fi - -if test "$kde_fast_malloc" = "full" -o "$kde_fast_malloc" = "debug_full"; then - AC_DEFINE(KDE_MALLOC_FULL, 1, [Make alloc as fast as possible]) -fi - -dnl -finline-limit=<large num> is needed for gcc3 in order to inline large functions -KDE_CHECK_COMPILER_FLAG(finline-limit=100000, - [KDE_FORCE_INLINE="-finline-limit=100000"], - [KDE_FORCE_INLINE= ]) -AC_SUBST(KDE_FORCE_INLINE) diff --git a/kdecore/malloc/glibc.h b/kdecore/malloc/glibc.h deleted file mode 100644 index 5951cb335..000000000 --- a/kdecore/malloc/glibc.h +++ /dev/null @@ -1,31 +0,0 @@ -#define libc_malloc __libc_malloc -#define libc_free __libc_free -#define libc_realloc __libc_realloc -#define libc_memalign __libc_memalign -#define libc_valloc __libc_valloc -#define libc_pvalloc __libc_pvalloc -#define libc_calloc __libc_calloc -/* return libc_icalloc( n, elem_size, chunks );*/ -/* return libc_icommaloc( n, sizes, chunks );*/ -#define libc_cfree __libc_free -/* return libc_mtrim( s );*/ -/* return libc_musable( m );*/ -/* libc_mstats();*/ -#define libc_mallinfo __libc_mallinfo -#define libc_mallopt __libc_mallopt - -void* __libc_malloc(size_t); -void __libc_free(void*); -void* __libc_calloc(size_t, size_t); -void* __libc_realloc(void*, size_t); -void* __libc_memalign(size_t, size_t); -void* __libc_valloc(size_t); -/*void** independent_calloc(size_t, size_t, void**);*/ -/*void** independent_comalloc(size_t, size_t*, void**);*/ -void* __libc_pvalloc(size_t); -void __libc_cfree(void*); -/*int malloc_trim(size_t);*/ -/*size_t malloc_usable_size(void*);*/ -/*void malloc_stats();*/ -struct mallinfo __libc_mallinfo(void); -int __libc_mallopt(int, int); diff --git a/kdecore/malloc/malloc.c b/kdecore/malloc/malloc.c deleted file mode 100644 index c25800f5d..000000000 --- a/kdecore/malloc/malloc.c +++ /dev/null @@ -1,5758 +0,0 @@ -#include <config.h> - -/* awful hack - This variable is set to 1 after a call to calloc() if this malloc - implementation is active. This is used in konqueror when calling - mallinfo(), which doesn't seem to be that much standardized :(. -*/ -int kde_malloc_is_used = 0; - -#ifdef KDE_MALLOC - -#ifdef KDE_MALLOC_DEBUG -#define DEBUG -#endif - -#define USE_MALLOC_LOCK -#define INLINE __inline__ -/*#define INLINE*/ -#define USE_MEMCPY 0 -#define MMAP_CLEARS 1 - -/* - This is a version (aka dlmalloc) of malloc/free/realloc written by - Doug Lea and released to the public domain. Use, modify, and - redistribute this code without permission or acknowledgment in any - way you wish. Send questions, comments, complaints, performance - data, etc to dl@cs.oswego.edu - -* VERSION 2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) - - Note: There may be an updated version of this malloc obtainable at - ftp://gee.cs.oswego.edu/pub/misc/malloc.c - Check before installing! - -* Quickstart - - This library is all in one file to simplify the most common usage: - ftp it, compile it (-O), and link it into another program. All - of the compile-time options default to reasonable values for use on - most unix platforms. Compile -DWIN32 for reasonable defaults on windows. - You might later want to step through various compile-time and dynamic - tuning options. - - For convenience, an include file for code using this malloc is at: - ftp://gee.cs.oswego.edu/pub/misc/malloc-2.7.0.h - You don't really need this .h file unless you call functions not - defined in your system include files. The .h file contains only the - excerpts from this file needed for using this malloc on ANSI C/C++ - systems, so long as you haven't changed compile-time options about - naming and tuning parameters. If you do, then you can create your - own malloc.h that does include all settings by cutting at the point - indicated below. - -* Why use this malloc? - - This is not the fastest, most space-conserving, most portable, or - most tunable malloc ever written. However it is among the fastest - while also being among the most space-conserving, portable and tunable. - Consistent balance across these factors results in a good general-purpose - allocator for malloc-intensive programs. - - The main properties of the algorithms are: - * For large (>= 512 bytes) requests, it is a pure best-fit allocator, - with ties normally decided via FIFO (i.e. least recently used). - * For small (<= 64 bytes by default) requests, it is a caching - allocator, that maintains pools of quickly recycled chunks. - * In between, and for combinations of large and small requests, it does - the best it can trying to meet both goals at once. - * For very large requests (>= 128KB by default), it relies on system - memory mapping facilities, if supported. - - For a longer but slightly out of date high-level description, see - http://gee.cs.oswego.edu/dl/html/malloc.html - - You may already by default be using a C library containing a malloc - that is based on some version of this malloc (for example in - linux). You might still want to use the one in this file in order to - customize settings or to avoid overheads associated with library - versions. - -* Contents, described in more detail in "description of public routines" below. - - Standard (ANSI/SVID/...) functions: - malloc(size_t n); - calloc(size_t n_elements, size_t element_size); - free(Void_t* p); - realloc(Void_t* p, size_t n); - memalign(size_t tqalignment, size_t n); - valloc(size_t n); - mallinfo() - mallopt(int parameter_number, int parameter_value) - - Additional functions: - independent_calloc(size_t n_elements, size_t size, Void_t* chunks[]); - independent_comalloc(size_t n_elements, size_t sizes[], Void_t* chunks[]); - pvalloc(size_t n); - cfree(Void_t* p); - malloc_trim(size_t pad); - malloc_usable_size(Void_t* p); - malloc_stats(); - -* Vital statistics: - - Supported pointer representation: 4 or 8 bytes - Supported size_t representation: 4 or 8 bytes - Note that size_t is allowed to be 4 bytes even if pointers are 8. - You can adjust this by defining INTERNAL_SIZE_T - - Alignment: 2 * sizeof(size_t) (default) - (i.e., 8 byte tqalignment with 4byte size_t). This suffices for - nearly all current machines and C compilers. However, you can - define MALLOC_ALIGNMENT to be wider than this if necessary. - - Minimum overhead per allocated chunk: 4 or 8 bytes - Each malloced chunk has a hidden word of overhead holding size - and status information. - - Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead) - 8-byte ptrs: 24/32 bytes (including, 4/8 overhead) - - When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte - ptrs but 4 byte size) or 24 (for 8/8) additional bytes are - needed; 4 (8) for a trailing size field and 8 (16) bytes for - free list pointers. Thus, the minimum allocatable size is - 16/24/32 bytes. - - Even a request for zero bytes (i.e., malloc(0)) returns a - pointer to something of the minimum allocatable size. - - The maximum overhead wastage (i.e., number of extra bytes - allocated than were requested in malloc) is less than or equal - to the minimum size, except for requests >= mmap_threshold that - are serviced via mmap(), where the worst case wastage is 2 * - sizeof(size_t) bytes plus the remainder from a system page (the - minimal mmap unit); typically 4096 or 8192 bytes. - - Maximum allocated size: 4-byte size_t: 2^32 minus about two pages - 8-byte size_t: 2^64 minus about two pages - - It is assumed that (possibly signed) size_t values suffice to - represent chunk sizes. `Possibly signed' is due to the fact - that `size_t' may be defined on a system as either a signed or - an unsigned type. The ISO C standard says that it must be - unsigned, but a few systems are known not to adhere to this. - Additionally, even when size_t is unsigned, sbrk (which is by - default used to obtain memory from system) accepts signed - arguments, and may not be able to handle size_t-wide arguments - with negative sign bit. Generally, values that would - appear as negative after accounting for overhead and tqalignment - are supported only via mmap(), which does not have this - limitation. - - Requests for sizes outside the allowed range will perform an optional - failure action and then return null. (Requests may also - also fail because a system is out of memory.) - - Thread-safety: NOT thread-safe unless USE_MALLOC_LOCK defined - - When USE_MALLOC_LOCK is defined, wrappers are created to - surround every public call with either a pthread mutex or - a win32 spinlock (depending on WIN32). This is not - especially fast, and can be a major bottleneck. - It is designed only to provide minimal protection - in concurrent environments, and to provide a basis for - extensions. If you are using malloc in a concurrent program, - you would be far better off obtaining ptmalloc, which is - derived from a version of this malloc, and is well-tuned for - concurrent programs. (See http://www.malloc.de) - - Compliance: I believe it is compliant with the 1997 Single Unix Specification - (See http://www.opennc.org). Also SVID/XPG, ANSI C, and probably - others as well. - -* Synopsis of compile-time options: - - People have reported using previous versions of this malloc on all - versions of Unix, sometimes by tweaking some of the defines - below. It has been tested most extensively on Solaris and - Linux. It is also reported to work on WIN32 platforms. - People also report using it in stand-alone embedded systems. - - The implementation is in straight, hand-tuned ANSI C. It is not - at all modular. (Sorry!) It uses a lot of macros. To be at all - usable, this code should be compiled using an optimizing compiler - (for example gcc -O3) that can simplify expressions and control - paths. (FAQ: some macros import variables as arguments rather than - declare locals because people reported that some debuggers - otherwise get confused.) - - OPTION DEFAULT VALUE - - Compilation Environment options: - - __STD_C derived from C compiler defines - WIN32 NOT defined - HAVE_MEMCPY defined - USE_MEMCPY 1 if HAVE_MEMCPY is defined - HAVE_MMAP defined as 1 - MMAP_CLEARS 1 - HAVE_MREMAP 0 unless linux defined - malloc_getpagesize derived from system #includes, or 4096 if not - HAVE_USR_INCLUDE_MALLOC_H NOT defined - LACKS_UNISTD_H NOT defined unless WIN32 - LACKS_SYS_PARAM_H NOT defined unless WIN32 - LACKS_SYS_MMAN_H NOT defined unless WIN32 - - Changing default word sizes: - - INTERNAL_SIZE_T size_t - MALLOC_ALIGNMENT 2 * sizeof(INTERNAL_SIZE_T) - - Configuration and functionality options: - - USE_DL_PREFIX NOT defined - USE_PUBLIC_MALLOC_WRAPPERS NOT defined - USE_MALLOC_LOCK NOT defined - DEBUG NOT defined - REALLOC_ZERO_BYTES_FREES NOT defined - MALLOC_FAILURE_ACTION errno = ENOMEM, if __STD_C defined, else no-op - TRIM_FASTBINS 0 - - Options for customizing MORECORE: - - MORECORE sbrk - MORECORE_CONTIGUOUS 1 - MORECORE_CANNOT_TRIM NOT defined - MMAP_AS_MORECORE_SIZE (1024 * 1024) - - Tuning options that are also dynamically changeable via mallopt: - - DEFAULT_MXFAST 64 - DEFAULT_TRIM_THRESHOLD 128 * 1024 - DEFAULT_TOP_PAD 0 - DEFAULT_MMAP_THRESHOLD 128 * 1024 - DEFAULT_MMAP_MAX 65536 - - There are several other #defined constants and macros that you - probably don't want to touch unless you are extending or adapting malloc. -*/ - -/* - WIN32 sets up defaults for MS environment and compilers. - Otherwise defaults are for unix. -*/ - -/* #define WIN32 */ - -#ifdef WIN32 - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - -/* Win32 doesn't supply or need the following headers */ -#define LACKS_UNISTD_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H - -/* Use the supplied emulation of sbrk */ -#define MORECORE sbrk -#define MORECORE_CONTIGUOUS 1 -#define MORECORE_FAILURE ((void*)(-1)) - -/* Use the supplied emulation of mmap and munmap */ -#define HAVE_MMAP 1 -#define MUNMAP_FAILURE (-1) -#define MMAP_CLEARS 1 - -/* These values don't really matter in windows mmap emulation */ -#define MAP_PRIVATE 1 -#define MAP_ANONYMOUS 2 -#define PROT_READ 1 -#define PROT_WRITE 2 - -/* Emulation functions defined at the end of this file */ - -/* If USE_MALLOC_LOCK, use supplied critical-section-based lock functions */ -#ifdef USE_MALLOC_LOCK -static int slwait(int *sl); -static int slrelease(int *sl); -#endif - -static long getpagesize(void); -static long getregionsize(void); -static void *sbrk(long size); -static void *mmap(void *ptr, long size, long prot, long type, long handle, long arg); -static long munmap(void *ptr, long size); - -static void vminfo (unsigned long *free, unsigned long *reserved, unsigned long *committed); -static int cpuinfo (int whole, unsigned long *kernel, unsigned long *user); - -#endif - -/* - __STD_C should be nonzero if using ANSI-standard C compiler, a C++ - compiler, or a C compiler sufficiently close to ANSI to get away - with it. -*/ - -#ifndef __STD_C -#if defined(__STDC__) || defined(_cplusplus) -#define __STD_C 1 -#else -#define __STD_C 0 -#endif -#endif /*__STD_C*/ - - -/* - Void_t* is the pointer type that malloc should say it returns -*/ - -#ifndef Void_t -#if (__STD_C || defined(WIN32)) -#define Void_t void -#else -#define Void_t char -#endif -#endif /*Void_t*/ - -#if __STD_C -#include <stddef.h> /* for size_t */ -#else -#include <sys/types.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* define LACKS_UNISTD_H if your system does not have a <unistd.h>. */ - -/* #define LACKS_UNISTD_H */ - -#ifndef LACKS_UNISTD_H -#include <unistd.h> -#endif - -/* define LACKS_SYS_PARAM_H if your system does not have a <sys/param.h>. */ - -/* #define LACKS_SYS_PARAM_H */ - - -#include <stdio.h> /* needed for malloc_stats */ -#include <errno.h> /* needed for optional MALLOC_FAILURE_ACTION */ - - -/* - Debugging: - - Because freed chunks may be overwritten with bookkeeping fields, this - malloc will often die when freed memory is overwritten by user - programs. This can be very effective (albeit in an annoying way) - in helping track down dangling pointers. - - If you compile with -DDEBUG, a number of assertion checks are - enabled that will catch more memory errors. You probably won't be - able to make much sense of the actual assertion errors, but they - should help you locate incorrectly overwritten memory. The - checking is fairly extensive, and will slow down execution - noticeably. Calling malloc_stats or mallinfo with DEBUG set will - attempt to check every non-mmapped allocated and free chunk in the - course of computing the summmaries. (By nature, mmapped regions - cannot be checked very much automatically.) - - Setting DEBUG may also be helpful if you are trying to modify - this code. The assertions in the check routines spell out in more - detail the assumptions and invariants underlying the algorithms. - - Setting DEBUG does NOT provide an automated mechanism for checking - that all accesses to malloced memory stay within their - bounds. However, there are several add-ons and adaptations of this - or other mallocs available that do this. -*/ - -#ifdef DEBUG -#include <assert.h> -#else -#define assert(x) ((void)0) -#endif - - -/* - INTERNAL_SIZE_T is the word-size used for internal bookkeeping - of chunk sizes. - - The default version is the same as size_t. - - While not strictly necessary, it is best to define this as an - unsigned type, even if size_t is a signed type. This may avoid some - artificial size limitations on some systems. - - On a 64-bit machine, you may be able to reduce malloc overhead by - defining INTERNAL_SIZE_T to be a 32 bit `unsigned int' at the - expense of not being able to handle more than 2^32 of malloced - space. If this limitation is acceptable, you are encouraged to set - this unless you are on a platform requiring 16byte alignments. In - this case the tqalignment requirements turn out to negate any - potential advantages of decreasing size_t word size. - - Implementors: Beware of the possible combinations of: - - INTERNAL_SIZE_T might be signed or unsigned, might be 32 or 64 bits, - and might be the same width as int or as long - - size_t might have different width and signedness as INTERNAL_SIZE_T - - int and long might be 32 or 64 bits, and might be the same width - To deal with this, most comparisons and difference computations - among INTERNAL_SIZE_Ts should cast them to unsigned long, being - aware of the fact that casting an unsigned int to a wider long does - not sign-extend. (This also makes checking for negative numbers - awkward.) Some of these casts result in harmless compiler warnings - on some systems. -*/ - -#ifndef INTERNAL_SIZE_T -#define INTERNAL_SIZE_T size_t -#endif - -/* The corresponding word size */ -#define SIZE_SZ (sizeof(INTERNAL_SIZE_T)) - - -/* - MALLOC_ALIGNMENT is the minimum tqalignment for malloc'ed chunks. - It must be a power of two at least 2 * SIZE_SZ, even on machines - for which smaller alignments would suffice. It may be defined as - larger than this though. Note however that code and data structures - are optimized for the case of 8-byte tqalignment. -*/ - - -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT (2 * SIZE_SZ) -#endif - -/* The corresponding bit mask value */ -#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1) - - - -/* - REALLOC_ZERO_BYTES_FREES should be set if a call to - realloc with zero bytes should be the same as a call to free. - Some people think it should. Otherwise, since this malloc - returns a unique pointer for malloc(0), so does realloc(p, 0). -*/ - -/* #define REALLOC_ZERO_BYTES_FREES */ - -/* - TRIM_FASTBINS controls whether free() of a very small chunk can - immediately lead to trimming. Setting to true (1) can reduce memory - footprint, but will almost always slow down programs that use a lot - of small chunks. - - Define this only if you are willing to give up some speed to more - aggressively reduce system-level memory footprint when releasing - memory in programs that use many small chunks. You can get - essentially the same effect by setting MXFAST to 0, but this can - lead to even greater slowdowns in programs using many small chunks. - TRIM_FASTBINS is an in-between compile-time option, that disables - only those chunks bordering topmost memory from being placed in - fastbins. -*/ - -#ifndef TRIM_FASTBINS -#define TRIM_FASTBINS 0 -#endif - - -/* - USE_DL_PREFIX will prefix all public routines with the string 'dl'. - This is necessary when you only want to use this malloc in one part - of a program, using your regular system malloc elsewhere. -*/ - -/* #define USE_DL_PREFIX */ - - -/* - USE_MALLOC_LOCK causes wrapper functions to surround each - callable routine with pthread mutex lock/unlock. - - USE_MALLOC_LOCK forces USE_PUBLIC_MALLOC_WRAPPERS to be defined -*/ - - -/* #define USE_MALLOC_LOCK */ - - -/* - If USE_PUBLIC_MALLOC_WRAPPERS is defined, every public routine is - actually a wrapper function that first calls MALLOC_PREACTION, then - calls the internal routine, and follows it with - MALLOC_POSTACTION. This is needed for locking, but you can also use - this, without USE_MALLOC_LOCK, for purposes of interception, - instrumentation, etc. It is a sad fact that using wrappers often - noticeably degrades performance of malloc-intensive programs. -*/ - -#ifdef USE_MALLOC_LOCK -#define USE_PUBLIC_MALLOC_WRAPPERS -#else -/* #define USE_PUBLIC_MALLOC_WRAPPERS */ -#endif - - -/* - Two-phase name translation. - All of the actual routines are given mangled names. - When wrappers are used, they become the public callable versions. - When DL_PREFIX is used, the callable names are prefixed. -*/ - -#ifndef USE_PUBLIC_MALLOC_WRAPPERS -#define cALLOc public_cALLOc -#define fREe public_fREe -#define cFREe public_cFREe -#define mALLOc public_mALLOc -#define mEMALIGn public_mEMALIGn -#define rEALLOc public_rEALLOc -#define vALLOc public_vALLOc -#define pVALLOc public_pVALLOc -#define mALLINFo public_mALLINFo -#define mALLOPt public_mALLOPt -#define mTRIm public_mTRIm -#define mSTATs public_mSTATs -#define mUSABLe public_mUSABLe -#define iCALLOc public_iCALLOc -#define iCOMALLOc public_iCOMALLOc -#endif - -#ifdef USE_DL_PREFIX -#define public_cALLOc dlcalloc -#define public_fREe dlfree -#define public_cFREe dlcfree -#define public_mALLOc dlmalloc -#define public_mEMALIGn dlmemalign -#define public_rEALLOc dlrealloc -#define public_vALLOc dlvalloc -#define public_pVALLOc dlpvalloc -#define public_mALLINFo dlmallinfo -#define public_mALLOPt dlmallopt -#define public_mTRIm dlmalloc_trim -#define public_mSTATs dlmalloc_stats -#define public_mUSABLe dlmalloc_usable_size -#define public_iCALLOc dlindependent_calloc -#define public_iCOMALLOc dlindependent_comalloc -#else /* USE_DL_PREFIX */ -#define public_cALLOc calloc -#define public_fREe free -#define public_cFREe cfree -#define public_mALLOc malloc -#define public_mEMALIGn memalign -#define public_rEALLOc realloc -#define public_vALLOc valloc -#define public_pVALLOc pvalloc -#define public_mALLINFo mallinfo -#define public_mALLOPt mallopt -#define public_mTRIm malloc_trim -#define public_mSTATs malloc_stats -#define public_mUSABLe malloc_usable_size -#define public_iCALLOc independent_calloc -#define public_iCOMALLOc independent_comalloc -#endif /* USE_DL_PREFIX */ - - -/* - HAVE_MEMCPY should be defined if you are not otherwise using - ANSI STD C, but still have memcpy and memset in your C library - and want to use them in calloc and realloc. Otherwise simple - macro versions are defined below. - - USE_MEMCPY should be defined as 1 if you actually want to - have memset and memcpy called. People report that the macro - versions are faster than libc versions on some systems. - - Even if USE_MEMCPY is set to 1, loops to copy/clear small chunks - (of <= 36 bytes) are manually unrolled in realloc and calloc. -*/ - -/* If it's available it's defined in config.h. */ -/* #define HAVE_MEMCPY */ - -#ifndef USE_MEMCPY -#ifdef HAVE_MEMCPY -#define USE_MEMCPY 1 -#else -#define USE_MEMCPY 0 -#endif -#endif - - -#if (__STD_C || defined(HAVE_MEMCPY)) - -#ifdef WIN32 -/* On Win32 memset and memcpy are already declared in windows.h */ -#else -#if __STD_C -void* memset(void*, int, size_t); -void* memcpy(void*, const void*, size_t); -#else -Void_t* memset(); -Void_t* memcpy(); -#endif -#endif -#endif - -/* - MALLOC_FAILURE_ACTION is the action to take before "return 0" when - malloc fails to be able to return memory, either because memory is - exhausted or because of illegal arguments. - - By default, sets errno if running on STD_C platform, else does nothing. -*/ - -#ifndef MALLOC_FAILURE_ACTION -#if __STD_C -#define MALLOC_FAILURE_ACTION \ - errno = ENOMEM; - -#else -#define MALLOC_FAILURE_ACTION -#endif -#endif - -/* - MORECORE-related declarations. By default, rely on sbrk -*/ - - -#ifdef LACKS_UNISTD_H -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -#if __STD_C -extern Void_t* sbrk(ptrdiff_t); -#else -extern Void_t* sbrk(); -#endif -#endif -#endif - -/* - MORECORE is the name of the routine to call to obtain more memory - from the system. See below for general guidance on writing - alternative MORECORE functions, as well as a version for WIN32 and a - sample version for pre-OSX macos. -*/ - -#ifndef MORECORE -#define MORECORE sbrk -#endif - -/* - MORECORE_FAILURE is the value returned upon failure of MORECORE - as well as mmap. Since it cannot be an otherwise valid memory address, - and must reflect values of standard sys calls, you probably ought not - try to redefine it. -*/ - -#ifndef MORECORE_FAILURE -#define MORECORE_FAILURE (-1) -#endif - -/* - If MORECORE_CONTIGUOUS is true, take advantage of fact that - consecutive calls to MORECORE with positive arguments always return - contiguous increasing addresses. This is true of unix sbrk. Even - if not defined, when regions happen to be contiguous, malloc will - permit allocations spanning regions obtained from different - calls. But defining this when applicable enables some stronger - consistency checks and space efficiencies. -*/ - -#ifndef MORECORE_CONTIGUOUS -#define MORECORE_CONTIGUOUS 1 -#endif - -/* - Define MORECORE_CANNOT_TRIM if your version of MORECORE - cannot release space back to the system when given negative - arguments. This is generally necessary only if you are using - a hand-crafted MORECORE function that cannot handle negative arguments. -*/ - -/* #define MORECORE_CANNOT_TRIM */ - - -/* - Define HAVE_MMAP as true to optionally make malloc() use mmap() to - allocate very large blocks. These will be returned to the - operating system immediately after a free(). Also, if mmap - is available, it is used as a backup strategy in cases where - MORECORE fails to provide space from system. - - This malloc is best tuned to work with mmap for large requests. - If you do not have mmap, operations involving very large chunks (1MB - or so) may be slower than you'd like. -*/ - -#ifndef HAVE_MMAP -#define HAVE_MMAP 1 -#endif - -#if HAVE_MMAP -/* - Standard unix mmap using /dev/zero clears memory so calloc doesn't - need to. -*/ - -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 1 -#endif - -#else /* no mmap */ -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 0 -#endif -#endif - - -/* - MMAP_AS_MORECORE_SIZE is the minimum mmap size argument to use if - sbrk fails, and mmap is used as a backup (which is done only if - HAVE_MMAP). The value must be a multiple of page size. This - backup strategy generally applies only when systems have "holes" in - address space, so sbrk cannot perform contiguous expansion, but - there is still space available on system. On systems for which - this is known to be useful (i.e. most linux kernels), this occurs - only when programs allocate huge amounts of memory. Between this, - and the fact that mmap regions tend to be limited, the size should - be large, to avoid too many mmap calls and thus avoid running out - of kernel resources. -*/ - -#ifndef MMAP_AS_MORECORE_SIZE -#define MMAP_AS_MORECORE_SIZE (1024 * 1024) -#endif - -/* - Define HAVE_MREMAP to make realloc() use mremap() to re-allocate - large blocks. This is currently only possible on Linux with - kernel versions newer than 1.3.77. -*/ - -#ifndef HAVE_MREMAP -#if defined(linux) || defined(__linux__) || defined(__linux) -#define HAVE_MREMAP 1 -#else -#define HAVE_MREMAP 0 -#endif - -#endif /* HAVE_MMAP */ - - -/* - The system page size. To the extent possible, this malloc manages - memory from the system in page-size units. Note that this value is - cached during initialization into a field of malloc_state. So even - if malloc_getpagesize is a function, it is only called once. - - The following mechanics for getpagesize were adapted from bsd/gnu - getpagesize.h. If none of the system-probes here apply, a value of - 4096 is used, which should be OK: If they don't apply, then using - the actual value probably doesn't impact performance. -*/ - - -#ifndef malloc_getpagesize - -#ifndef LACKS_UNISTD_H -# include <unistd.h> -#endif - -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif - -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include <sys/param.h> -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize (4096) -# endif -# endif -# endif -# endif -# endif -# endif -# endif -#endif - -/* - This version of malloc supports the standard SVID/XPG mallinfo - routine that returns a struct containing usage properties and - statistics. It should work on any SVID/XPG compliant system that has - a /usr/include/malloc.h defining struct mallinfo. (If you'd like to - install such a thing yourself, cut out the preliminary declarations - as described above and below and save them in a malloc.h file. But - there's no compelling reason to bother to do this.) - - The main declaration needed is the mallinfo struct that is returned - (by-copy) by mallinfo(). The SVID/XPG malloinfo struct contains a - bunch of field that are not even meaningful in this version of - malloc. These fields are are instead filled by mallinfo() with - other numbers that might be of interest. - - HAVE_USR_INCLUDE_MALLOC_H should be set if you have a - /usr/include/malloc.h file that includes a declaration of struct - mallinfo. If so, it is included; else an SVID2/XPG2 compliant - version is declared below. These must be precisely the same for - mallinfo() to work. The original SVID version of this struct, - defined on most systems with mallinfo, declares all fields as - ints. But some others define as unsigned long. If your system - defines the fields using a type of different width than listed here, - you must #include your system version and #define - HAVE_USR_INCLUDE_MALLOC_H. -*/ - -/* #define HAVE_USR_INCLUDE_MALLOC_H */ - -/*#ifdef HAVE_USR_INCLUDE_MALLOC_H*/ -#if 0 -#include "/usr/include/malloc.h" -#else - -/* SVID2/XPG mallinfo structure */ - -struct mallinfo { - int arena; /* non-mmapped space allocated from system */ - int ordblks; /* number of free chunks */ - int smblks; /* number of fastbin blocks */ - int hblks; /* number of mmapped regions */ - int hblkhd; /* space in mmapped regions */ - int usmblks; /* maximum total allocated space */ - int fsmblks; /* space available in freed fastbin blocks */ - int uordblks; /* total allocated space */ - int fordblks; /* total free space */ - int keepcost; /* top-most, releasable (via malloc_trim) space */ -}; - -/* - SVID/XPG defines four standard parameter numbers for mallopt, - normally defined in malloc.h. Only one of these (M_MXFAST) is used - in this malloc. The others (M_NLBLKS, M_GRAIN, M_KEEP) don't apply, - so setting them has no effect. But this malloc also supports other - options in mallopt described below. -*/ -#endif - - -/* ---------- description of public routines ------------ */ - -/* - malloc(size_t n) - Returns a pointer to a newly allocated chunk of at least n bytes, or null - if no space is available. Additionally, on failure, errno is - set to ENOMEM on ANSI C systems. - - If n is zero, malloc returns a minumum-sized chunk. (The minimum - size is 16 bytes on most 32bit systems, and 24 or 32 bytes on 64bit - systems.) On most systems, size_t is an unsigned type, so calls - with negative arguments are interpreted as requests for huge amounts - of space, which will often fail. The maximum supported value of n - differs across systems, but is in all cases less than the maximum - representable value of a size_t. -*/ -#if __STD_C -Void_t* public_mALLOc(size_t); -#else -Void_t* public_mALLOc(); -#endif - -/* - free(Void_t* p) - Releases the chunk of memory pointed to by p, that had been previously - allocated using malloc or a related routine such as realloc. - It has no effect if p is null. It can have arbitrary (i.e., bad!) - effects if p has already been freed. - - Unless disabled (using mallopt), freeing very large spaces will - when possible, automatically trigger operations that give - back unused memory to the system, thus reducing program footprint. -*/ -#if __STD_C -void public_fREe(Void_t*); -#else -void public_fREe(); -#endif - -/* - calloc(size_t n_elements, size_t element_size); - Returns a pointer to n_elements * element_size bytes, with all locations - set to zero. -*/ -#if __STD_C -Void_t* public_cALLOc(size_t, size_t); -#else -Void_t* public_cALLOc(); -#endif - -/* - realloc(Void_t* p, size_t n) - Returns a pointer to a chunk of size n that contains the same data - as does chunk p up to the minimum of (n, p's size) bytes, or null - if no space is available. - - The returned pointer may or may not be the same as p. The algorithm - prefers extending p when possible, otherwise it employs the - equivalent of a malloc-copy-free sequence. - - If p is null, realloc is equivalent to malloc. - - If space is not available, realloc returns null, errno is set (if on - ANSI) and p is NOT freed. - - if n is for fewer bytes than already held by p, the newly unused - space is lopped off and freed if possible. Unless the #define - REALLOC_ZERO_BYTES_FREES is set, realloc with a size argument of - zero (re)allocates a minimum-sized chunk. - - Large chunks that were internally obtained via mmap will always - be reallocated using malloc-copy-free sequences unless - the system supports MREMAP (currently only linux). - - The old unix realloc convention of allowing the last-free'd chunk - to be used as an argument to realloc is not supported. -*/ -#if __STD_C -Void_t* public_rEALLOc(Void_t*, size_t); -#else -Void_t* public_rEALLOc(); -#endif - -/* - memalign(size_t tqalignment, size_t n); - Returns a pointer to a newly allocated chunk of n bytes, aligned - in accord with the tqalignment argument. - - The tqalignment argument should be a power of two. If the argument is - not a power of two, the nearest greater power is used. - 8-byte tqalignment is guaranteed by normal malloc calls, so don't - bother calling memalign with an argument of 8 or less. - - Overreliance on memalign is a sure way to fragment space. -*/ -#if __STD_C -Void_t* public_mEMALIGn(size_t, size_t); -#else -Void_t* public_mEMALIGn(); -#endif - -/* - valloc(size_t n); - Equivalent to memalign(pagesize, n), where pagesize is the page - size of the system. If the pagesize is unknown, 4096 is used. -*/ -#if __STD_C -Void_t* public_vALLOc(size_t); -#else -Void_t* public_vALLOc(); -#endif - - - -/* - mallopt(int parameter_number, int parameter_value) - Sets tunable parameters The format is to provide a - (parameter-number, parameter-value) pair. mallopt then sets the - corresponding parameter to the argument value if it can (i.e., so - long as the value is meaningful), and returns 1 if successful else - 0. SVID/XPG/ANSI defines four standard param numbers for mallopt, - normally defined in malloc.h. Only one of these (M_MXFAST) is used - in this malloc. The others (M_NLBLKS, M_GRAIN, M_KEEP) don't apply, - so setting them has no effect. But this malloc also supports four - other options in mallopt. See below for details. Briefly, supported - parameters are as follows (listed defaults are for "typical" - configurations). - - Symbol param # default allowed param values - M_MXFAST 1 64 0-80 (0 disables fastbins) - M_TRIM_THRESHOLD -1 128*1024 any (-1U disables trimming) - M_TOP_PAD -2 0 any - M_MMAP_THRESHOLD -3 128*1024 any (or 0 if no MMAP support) - M_MMAP_MAX -4 65536 any (0 disables use of mmap) -*/ -#if __STD_C -int public_mALLOPt(int, int); -#else -int public_mALLOPt(); -#endif - - -/* - mallinfo() - Returns (by copy) a struct containing various summary statistics: - - arena: current total non-mmapped bytes allocated from system - ordblks: the number of free chunks - smblks: the number of fastbin blocks (i.e., small chunks that - have been freed but not use resused or consolidated) - hblks: current number of mmapped regions - hblkhd: total bytes held in mmapped regions - usmblks: the maximum total allocated space. This will be greater - than current total if trimming has occurred. - fsmblks: total bytes held in fastbin blocks - uordblks: current total allocated space (normal or mmapped) - fordblks: total free space - keepcost: the maximum number of bytes that could ideally be released - back to system via malloc_trim. ("ideally" means that - it ignores page restrictions etc.) - - Because these fields are ints, but internal bookkeeping may - be kept as longs, the reported values may wrap around zero and - thus be inaccurate. -*/ -#if __STD_C -struct mallinfo public_mALLINFo(void); -#else -struct mallinfo public_mALLINFo(); -#endif - -/* - independent_calloc(size_t n_elements, size_t element_size, Void_t* chunks[]); - - independent_calloc is similar to calloc, but instead of returning a - single cleared space, it returns an array of pointers to n_elements - independent elements that can hold contents of size elem_size, each - of which starts out cleared, and can be independently freed, - realloc'ed etc. The elements are guaranteed to be adjacently - allocated (this is not guaranteed to occur with multiple callocs or - mallocs), which may also improve cache locality in some - applications. - - The "chunks" argument is optional (i.e., may be null, which is - probably the most typical usage). If it is null, the returned array - is itself dynamically allocated and should also be freed when it is - no longer needed. Otherwise, the chunks array must be of at least - n_elements in length. It is filled in with the pointers to the - chunks. - - In either case, independent_calloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and "chunks" - is null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use regular calloc and assign pointers into this - space to represent elements. (In this case though, you cannot - independently free elements.) - - independent_calloc simplifies and speeds up implementations of many - kinds of pools. It may also be useful when constructing large data - structures that initially have a fixed number of fixed-sized nodes, - but the number is not known at compile time, and some of the nodes - may later need to be freed. For example: - - struct Node { int item; struct Node* next; }; - - struct Node* build_list() { - struct Node** pool; - int n = read_number_of_nodes_needed(); - if (n <= 0) return 0; - pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); - if (pool == 0) die(); - // organize into a linked list... - struct Node* first = pool[0]; - for (i = 0; i < n-1; ++i) - pool[i]->next = pool[i+1]; - free(pool); // Can now free the array (or not, if it is needed later) - return first; - } -*/ -#if __STD_C -Void_t** public_iCALLOc(size_t, size_t, Void_t**); -#else -Void_t** public_iCALLOc(); -#endif - -/* - independent_comalloc(size_t n_elements, size_t sizes[], Void_t* chunks[]); - - independent_comalloc allocates, all at once, a set of n_elements - chunks with sizes indicated in the "sizes" array. It returns - an array of pointers to these elements, each of which can be - independently freed, realloc'ed etc. The elements are guaranteed to - be adjacently allocated (this is not guaranteed to occur with - multiple callocs or mallocs), which may also improve cache locality - in some applications. - - The "chunks" argument is optional (i.e., may be null). If it is null - the returned array is itself dynamically allocated and should also - be freed when it is no longer needed. Otherwise, the chunks array - must be of at least n_elements in length. It is filled in with the - pointers to the chunks. - - In either case, independent_comalloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and chunks is - null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use a single regular malloc, and assign pointers at - particular offsets in the aggregate space. (In this case though, you - cannot independently free elements.) - - independent_comallac differs from independent_calloc in that each - element may have a different size, and also that it does not - automatically clear elements. - - independent_comalloc can be used to speed up allocation in cases - where several structs or objects must always be allocated at the - same time. For example: - - struct Head { ... } - struct Foot { ... } - - void send_message(char* msg) { - int msglen = strlen(msg); - size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; - void* chunks[3]; - if (independent_comalloc(3, sizes, chunks) == 0) - die(); - struct Head* head = (struct Head*)(chunks[0]); - char* body = (char*)(chunks[1]); - struct Foot* foot = (struct Foot*)(chunks[2]); - // ... - } - - In general though, independent_comalloc is worth using only for - larger values of n_elements. For small values, you probably won't - detect enough difference from series of malloc calls to bother. - - Overuse of independent_comalloc can increase overall memory usage, - since it cannot reuse existing noncontiguous small chunks that - might be available for some of the elements. -*/ -#if __STD_C -Void_t** public_iCOMALLOc(size_t, size_t*, Void_t**); -#else -Void_t** public_iCOMALLOc(); -#endif - - -/* - pvalloc(size_t n); - Equivalent to valloc(minimum-page-that-holds(n)), that is, - round up n to nearest pagesize. - */ -#if __STD_C -Void_t* public_pVALLOc(size_t); -#else -Void_t* public_pVALLOc(); -#endif - -/* - cfree(Void_t* p); - Equivalent to free(p). - - cfree is needed/defined on some systems that pair it with calloc, - for odd historical reasons (such as: cfree is used in example - code in the first edition of K&R). -*/ -#if __STD_C -void public_cFREe(Void_t*); -#else -void public_cFREe(); -#endif - -/* - malloc_trim(size_t pad); - - If possible, gives memory back to the system (via negative - arguments to sbrk) if there is unused memory at the `high' end of - the malloc pool. You can call this after freeing large blocks of - memory to potentially reduce the system-level memory requirements - of a program. However, it cannot guarantee to reduce memory. Under - some allocation patterns, some large free blocks of memory will be - locked between two used chunks, so they cannot be given back to - the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, - only the minimum amount of memory to maintain internal data - structures will be left (one page or less). Non-zero arguments - can be supplied to maintain enough trailing space to service - future expected allocations without having to re-obtain memory - from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. - On systems that do not support "negative sbrks", it will always - rreturn 0. -*/ -#if __STD_C -int public_mTRIm(size_t); -#else -int public_mTRIm(); -#endif - -/* - malloc_usable_size(Void_t* p); - - Returns the number of bytes you can actually use in - an allocated chunk, which may be more than you requested (although - often not) due to tqalignment and minimum size constraints. - You can use this many bytes without worrying about - overwriting other allocated objects. This is not a particularly great - programming practice. malloc_usable_size can be more useful in - debugging and assertions, for example: - - p = malloc(n); - assert(malloc_usable_size(p) >= 256); - -*/ -#if __STD_C -size_t public_mUSABLe(Void_t*); -#else -size_t public_mUSABLe(); -#endif - -/* - malloc_stats(); - Prints on stderr the amount of space obtained from the system (both - via sbrk and mmap), the maximum amount (which may be more than - current if malloc_trim and/or munmap got called), and the current - number of bytes allocated via malloc (or realloc, etc) but not yet - freed. Note that this is the number of bytes allocated, not the - number requested. It will be larger than the number requested - because of tqalignment and bookkeeping overhead. Because it includes - tqalignment wastage as being in use, this figure may be greater than - zero even when no user-level chunks are allocated. - - The reported current and maximum system memory can be inaccurate if - a program makes other calls to system memory allocation functions - (normally sbrk) outside of malloc. - - malloc_stats prints only the most commonly interesting statistics. - More information can be obtained by calling mallinfo. - -*/ -#if __STD_C -void public_mSTATs(); -#else -void public_mSTATs(); -#endif - -/* mallopt tuning options */ - -/* - M_MXFAST is the maximum request size used for "fastbins", special bins - that hold returned chunks without consolidating their spaces. This - enables future requests for chunks of the same size to be handled - very quickly, but can increase fragmentation, and thus increase the - overall memory footprint of a program. - - This malloc manages fastbins very conservatively yet still - efficiently, so fragmentation is rarely a problem for values less - than or equal to the default. The maximum supported value of MXFAST - is 80. You wouldn't want it any higher than this anyway. Fastbins - are designed especially for use with many small structs, objects or - strings -- the default handles structs/objects/arrays with sizes up - to 8 4byte fields, or small strings representing words, tokens, - etc. Using fastbins for larger objects normally worsens - fragmentation without improving speed. - - M_MXFAST is set in REQUEST size units. It is internally used in - chunksize units, which adds padding and tqalignment. You can reduce - M_MXFAST to 0 to disable all use of fastbins. This causes the malloc - algorithm to be a closer approximation of fifo-best-fit in all cases, - not just for larger requests, but will generally cause it to be - slower. -*/ - - -/* M_MXFAST is a standard SVID/XPG tuning option, usually listed in malloc.h */ -#ifndef M_MXFAST -#define M_MXFAST 1 -#endif - -#ifndef DEFAULT_MXFAST -#define DEFAULT_MXFAST 64 -#endif - - -/* - M_TRIM_THRESHOLD is the maximum amount of unused top-most memory - to keep before releasing via malloc_trim in free(). - - Automatic trimming is mainly useful in long-lived programs. - Because trimming via sbrk can be slow on some systems, and can - sometimes be wasteful (in cases where programs immediately - afterward allocate more large chunks) the value should be high - enough so that your overall system performance would improve by - releasing this much memory. - - The trim threshold and the mmap control parameters (see below) - can be traded off with one another. Trimming and mmapping are - two different ways of releasing unused memory back to the - system. Between these two, it is often possible to keep - system-level demands of a long-lived program down to a bare - minimum. For example, in one test suite of sessions measuring - the XF86 X server on Linux, using a trim threshold of 128K and a - mmap threshold of 192K led to near-minimal long term resource - consumption. - - If you are using this malloc in a long-lived program, it should - pay to experiment with these values. As a rough guide, you - might set to a value close to the average size of a process - (program) running on your system. Releasing this much memory - would allow such a process to run in memory. Generally, it's - worth it to tune for trimming rather tham memory mapping when a - program undergoes phases where several large chunks are - allocated and released in ways that can reuse each other's - storage, perhaps mixed with phases where there are no such - chunks at all. And in well-behaved long-lived programs, - controlling release of large blocks via trimming versus mapping - is usually faster. - - However, in most programs, these parameters serve mainly as - protection against the system-level effects of carrying around - massive amounts of unneeded memory. Since frequent calls to - sbrk, mmap, and munmap otherwise degrade performance, the default - parameters are set to relatively high values that serve only as - safeguards. - - The trim value It must be greater than page size to have any useful - effect. To disable trimming completely, you can set to - (unsigned long)(-1) - - Trim settings interact with fastbin (MXFAST) settings: Unless - TRIM_FASTBINS is defined, automatic trimming never takes place upon - freeing a chunk with size less than or equal to MXFAST. Trimming is - instead delayed until subsequent freeing of larger chunks. However, - you can still force an attempted trim by calling malloc_trim. - - Also, trimming is not generally possible in cases where - the main arena is obtained via mmap. - - Note that the trick some people use of mallocing a huge space and - then freeing it at program startup, in an attempt to reserve system - memory, doesn't have the intended effect under automatic trimming, - since that memory will immediately be returned to the system. -*/ - -#define M_TRIM_THRESHOLD -1 - -#ifndef DEFAULT_TRIM_THRESHOLD -#define DEFAULT_TRIM_THRESHOLD (128 * 1024) -#endif - -/* - M_TOP_PAD is the amount of extra `padding' space to allocate or - retain whenever sbrk is called. It is used in two ways internally: - - * When sbrk is called to extend the top of the arena to satisfy - a new malloc request, this much padding is added to the sbrk - request. - - * When malloc_trim is called automatically from free(), - it is used as the `pad' argument. - - In both cases, the actual amount of padding is rounded - so that the end of the arena is always a system page boundary. - - The main reason for using padding is to avoid calling sbrk so - often. Having even a small pad greatly reduces the likelihood - that nearly every malloc request during program start-up (or - after trimming) will invoke sbrk, which needlessly wastes - time. - - Automatic rounding-up to page-size units is normally sufficient - to avoid measurable overhead, so the default is 0. However, in - systems where sbrk is relatively slow, it can pay to increase - this value, at the expense of carrying around more memory than - the program needs. -*/ - -#define M_TOP_PAD -2 - -#ifndef DEFAULT_TOP_PAD -#define DEFAULT_TOP_PAD (0) -#endif - -/* - M_MMAP_THRESHOLD is the request size threshold for using mmap() - to service a request. Requests of at least this size that cannot - be allocated using already-existing space will be serviced via mmap. - (If enough normal freed space already exists it is used instead.) - - Using mmap segregates relatively large chunks of memory so that - they can be individually obtained and released from the host - system. A request serviced through mmap is never reused by any - other request (at least not directly; the system may just so - happen to remap successive requests to the same locations). - - Segregating space in this way has the benefits that: - - 1. Mmapped space can ALWAYS be individually released back - to the system, which helps keep the system level memory - demands of a long-lived program low. - 2. Mapped memory can never become `locked' between - other chunks, as can happen with normally allocated chunks, which - means that even trimming via malloc_trim would not release them. - 3. On some systems with "holes" in address spaces, mmap can obtain - memory that sbrk cannot. - - However, it has the disadvantages that: - - 1. The space cannot be reclaimed, consolidated, and then - used to service later requests, as happens with normal chunks. - 2. It can lead to more wastage because of mmap page tqalignment - requirements - 3. It causes malloc performance to be more dependent on host - system memory management support routines which may vary in - implementation quality and may impose arbitrary - limitations. Generally, servicing a request via normal - malloc steps is faster than going through a system's mmap. - - The advantages of mmap nearly always outweigh disadvantages for - "large" chunks, but the value of "large" varies across systems. The - default is an empirically derived value that works well in most - systems. -*/ - -#define M_MMAP_THRESHOLD -3 - -#ifndef DEFAULT_MMAP_THRESHOLD -#define DEFAULT_MMAP_THRESHOLD (128 * 1024) -#endif - -/* - M_MMAP_MAX is the maximum number of requests to simultaneously - service using mmap. This parameter exists because -. Some systems have a limited number of internal tables for - use by mmap, and using more than a few of them may degrade - performance. - - The default is set to a value that serves only as a safeguard. - Setting to 0 disables use of mmap for servicing large requests. If - HAVE_MMAP is not set, the default value is 0, and attempts to set it - to non-zero values in mallopt will fail. -*/ - -#define M_MMAP_MAX -4 - -#ifndef DEFAULT_MMAP_MAX -#if HAVE_MMAP -#define DEFAULT_MMAP_MAX (65536) -#else -#define DEFAULT_MMAP_MAX (0) -#endif -#endif - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - -/* - ======================================================================== - To make a fully customizable malloc.h header file, cut everything - above this line, put into file malloc.h, edit to suit, and #include it - on the next line, as well as in programs that use this malloc. - ======================================================================== -*/ - -/* #include "malloc.h" */ - -/* --------------------- public wrappers ---------------------- */ - -#ifdef USE_PUBLIC_MALLOC_WRAPPERS - -/* Declare all routines as internal */ -#if __STD_C -static Void_t* mALLOc(size_t); -static void fREe(Void_t*); -static Void_t* rEALLOc(Void_t*, size_t); -static Void_t* mEMALIGn(size_t, size_t); -static Void_t* vALLOc(size_t); -static Void_t* pVALLOc(size_t); -static Void_t* cALLOc(size_t, size_t); -static Void_t** iCALLOc(size_t, size_t, Void_t**); -static Void_t** iCOMALLOc(size_t, size_t*, Void_t**); -static void cFREe(Void_t*); -static int mTRIm(size_t); -static size_t mUSABLe(Void_t*); -static void mSTATs(); -static int mALLOPt(int, int); -static struct mallinfo mALLINFo(void); -#else -static Void_t* mALLOc(); -static void fREe(); -static Void_t* rEALLOc(); -static Void_t* mEMALIGn(); -static Void_t* vALLOc(); -static Void_t* pVALLOc(); -static Void_t* cALLOc(); -static Void_t** iCALLOc(); -static Void_t** iCOMALLOc(); -static void cFREe(); -static int mTRIm(); -static size_t mUSABLe(); -static void mSTATs(); -static int mALLOPt(); -static struct mallinfo mALLINFo(); -#endif - -/* - MALLOC_PREACTION and MALLOC_POSTACTION should be - defined to return 0 on success, and nonzero on failure. - The return value of MALLOC_POSTACTION is currently ignored - in wrapper functions since there is no reasonable default - action to take on failure. -*/ - - -#ifdef USE_MALLOC_LOCK - -#ifdef WIN32 - -static int mALLOC_MUTEx; -#define MALLOC_PREACTION slwait(&mALLOC_MUTEx) -#define MALLOC_POSTACTION slrelease(&mALLOC_MUTEx) - -#else - -#if 0 -#include <pthread.h> - -static pthread_mutex_t mALLOC_MUTEx = PTHREAD_MUTEX_INITIALIZER; - -#define MALLOC_PREACTION pthread_mutex_lock(&mALLOC_MUTEx) -#define MALLOC_POSTACTION pthread_mutex_unlock(&mALLOC_MUTEx) - -#else - -#ifdef KDE_MALLOC_X86 -#include "x86.h" -#else -#error Unknown spinlock implementation -#endif - -static mutex_t spinlock = MUTEX_INITIALIZER; - -#define MALLOC_PREACTION lock( &spinlock ) -#define MALLOC_POSTACTION unlock( &spinlock ) - -#endif - -#endif /* USE_MALLOC_LOCK */ - -#else - -/* Substitute anything you like for these */ - -#define MALLOC_PREACTION (0) -#define MALLOC_POSTACTION (0) - -#endif - -#if 0 -Void_t* public_mALLOc(size_t bytes) { - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = mALLOc(bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -void public_fREe(Void_t* m) { - if (MALLOC_PREACTION != 0) { - return; - } - fREe(m); - if (MALLOC_POSTACTION != 0) { - } -} - -Void_t* public_rEALLOc(Void_t* m, size_t bytes) { - if (MALLOC_PREACTION != 0) { - return 0; - } - m = rEALLOc(m, bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -Void_t* public_mEMALIGn(size_t tqalignment, size_t bytes) { - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = mEMALIGn(tqalignment, bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -Void_t* public_vALLOc(size_t bytes) { - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = vALLOc(bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -Void_t* public_pVALLOc(size_t bytes) { - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = pVALLOc(bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -Void_t* public_cALLOc(size_t n, size_t elem_size) { - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = cALLOc(n, elem_size); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - - -Void_t** public_iCALLOc(size_t n, size_t elem_size, Void_t** chunks) { - Void_t** m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = iCALLOc(n, elem_size, chunks); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -Void_t** public_iCOMALLOc(size_t n, size_t sizes[], Void_t** chunks) { - Void_t** m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = iCOMALLOc(n, sizes, chunks); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -void public_cFREe(Void_t* m) { - if (MALLOC_PREACTION != 0) { - return; - } - cFREe(m); - if (MALLOC_POSTACTION != 0) { - } -} - -int public_mTRIm(size_t s) { - int result; - if (MALLOC_PREACTION != 0) { - return 0; - } - result = mTRIm(s); - if (MALLOC_POSTACTION != 0) { - } - return result; -} - -size_t public_mUSABLe(Void_t* m) { - size_t result; - if (MALLOC_PREACTION != 0) { - return 0; - } - result = mUSABLe(m); - if (MALLOC_POSTACTION != 0) { - } - return result; -} - -void public_mSTATs() { - if (MALLOC_PREACTION != 0) { - return; - } - mSTATs(); - if (MALLOC_POSTACTION != 0) { - } -} - -struct mallinfo public_mALLINFo() { - struct mallinfo m; - if (MALLOC_PREACTION != 0) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - return nm; - } - m = mALLINFo(); - if (MALLOC_POSTACTION != 0) { - } - return m; -} - -int public_mALLOPt(int p, int v) { - int result; - if (MALLOC_PREACTION != 0) { - return 0; - } - result = mALLOPt(p, v); - if (MALLOC_POSTACTION != 0) { - } - return result; -} -#endif - -#endif - - - -/* ------------- Optional versions of memcopy ---------------- */ - - -#if USE_MEMCPY - -/* - Note: memcpy is ONLY invoked with non-overlapping regions, - so the (usually slower) memmove is not needed. -*/ - -#define MALLOC_COPY(dest, src, nbytes) memcpy(dest, src, nbytes) -#define MALLOC_ZERO(dest, nbytes) memset(dest, 0, nbytes) - -#else /* !USE_MEMCPY */ - -/* Use Duff's device for good zeroing/copying performance. */ - -#define MALLOC_ZERO(charp, nbytes) \ -do { \ - INTERNAL_SIZE_T* mzp = (INTERNAL_SIZE_T*)(charp); \ - unsigned long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T); \ - long mcn; \ - if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \ - switch (mctmp) { \ - case 0: for(;;) { *mzp++ = 0; \ - case 7: *mzp++ = 0; \ - case 6: *mzp++ = 0; \ - case 5: *mzp++ = 0; \ - case 4: *mzp++ = 0; \ - case 3: *mzp++ = 0; \ - case 2: *mzp++ = 0; \ - case 1: *mzp++ = 0; if(mcn <= 0) break; mcn--; } \ - } \ -} while(0) - -#define MALLOC_COPY(dest,src,nbytes) \ -do { \ - INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) src; \ - INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) dest; \ - unsigned long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T); \ - long mcn; \ - if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \ - switch (mctmp) { \ - case 0: for(;;) { *mcdst++ = *mcsrc++; \ - case 7: *mcdst++ = *mcsrc++; \ - case 6: *mcdst++ = *mcsrc++; \ - case 5: *mcdst++ = *mcsrc++; \ - case 4: *mcdst++ = *mcsrc++; \ - case 3: *mcdst++ = *mcsrc++; \ - case 2: *mcdst++ = *mcsrc++; \ - case 1: *mcdst++ = *mcsrc++; if(mcn <= 0) break; mcn--; } \ - } \ -} while(0) - -#endif - -/* ------------------ MMAP support ------------------ */ - - -#if HAVE_MMAP - -#include <fcntl.h> -#ifndef LACKS_SYS_MMAN_H -#include <sys/mman.h> -#endif - -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif - -/* - Nearly all versions of mmap support MAP_ANONYMOUS, - so the following is unlikely to be needed, but is - supplied just in case. -*/ - -#ifndef MAP_ANONYMOUS - -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ - -#define MMAP(addr, size, prot, flags) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap((addr), (size), (prot), (flags), dev_zero_fd, 0)) : \ - mmap((addr), (size), (prot), (flags), dev_zero_fd, 0)) - -#else - -#define MMAP(addr, size, prot, flags) \ - (mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS, -1, 0)) - -#endif - - -#endif /* HAVE_MMAP */ - - -/* - ----------------------- Chunk representations ----------------------- -*/ - - -/* - This struct declaration is misleading (but accurate and necessary). - It declares a "view" into memory allowing access to necessary - fields at known offsets from a given base. See explanation below. -*/ - -struct malloc_chunk { - - INTERNAL_SIZE_T prev_size; /* Size of previous chunk (if free). */ - INTERNAL_SIZE_T size; /* Size in bytes, including overhead. */ - - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; -}; - - -typedef struct malloc_chunk* mchunkptr; - -/* - malloc_chunk details: - - (The following includes lightly edited explanations by Colin Plumb.) - - Chunks of memory are maintained using a `boundary tag' method as - described in e.g., Knuth or Standish. (See the paper by Paul - Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a - survey of such techniques.) Sizes of free chunks are stored both - in the front of each chunk and at the end. This makes - consolidating fragmented chunks into bigger chunks very fast. The - size fields also hold bits representing whether chunks are free or - in use. - - An allocated chunk looks like this: - - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk, if allocated | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | User data starts here... . - . . - . (malloc_usable_space() bytes) . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - - Where "chunk" is the front of the chunk for the purpose of most of - the malloc code, but "mem" is the pointer that is returned to the - user. "Nextchunk" is the beginning of the next contiguous chunk. - - Chunks always begin on even word boundaries, so the mem portion - (which is returned to the user) is also on an even word boundary, and - thus at least double-word aligned. - - Free chunks are stored in circular doubly-linked lists, and look like this: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space (may be 0 bytes long) . - . . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - The P (PREV_INUSE) bit, stored in the unused low-order bit of the - chunk size (which is always a multiple of two words), is an in-use - bit for the *previous* chunk. If that bit is *clear*, then the - word before the current chunk size contains the previous chunk - size, and can be used to find the front of the previous chunk. - The very first chunk allocated always has this bit set, - preventing access to non-existent (or non-owned) memory. If - prev_inuse is set for any given chunk, then you CANNOT determine - the size of the previous chunk, and might even get a memory - addressing fault when trying to do so. - - Note that the `foot' of the current chunk is actually represented - as the prev_size of the NEXT chunk. This makes it easier to - deal with alignments etc but can be very confusing when trying - to extend or adapt this code. - - The two exceptions to all this are - - 1. The special chunk `top' doesn't bother using the - trailing size field since there is no next contiguous chunk - that would have to index off it. After initialization, `top' - is forced to always exist. If it would become less than - MINSIZE bytes long, it is replenished. - - 2. Chunks allocated via mmap, which have the second-lowest-order - bit (IS_MMAPPED) set in their size fields. Because they are - allocated one-by-one, each must contain its own trailing size field. - -*/ - -/* - ---------- Size and tqalignment checks and conversions ---------- -*/ - -/* conversion from malloc headers to user pointers, and back */ - -#define chunk2mem(p) ((Void_t*)((char*)(p) + 2*SIZE_SZ)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*SIZE_SZ)) - -/* The smallest possible chunk */ -#define MIN_CHUNK_SIZE (sizeof(struct malloc_chunk)) - -/* The smallest size we can malloc is an aligned minimal chunk */ - -#define MINSIZE \ - (unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)) - -/* Check if m has acceptable tqalignment */ - -#define aligned_OK(m) (((unsigned long)((m)) & (MALLOC_ALIGN_MASK)) == 0) - - -/* - Check if a request is so large that it would wrap around zero when - padded and aligned. To simplify some other code, the bound is made - low enough so that adding MINSIZE will also not wrap around zero. -*/ - -#define REQUEST_OUT_OF_RANGE(req) \ - ((unsigned long)(req) >= \ - (unsigned long)(INTERNAL_SIZE_T)(-2 * MINSIZE)) - -/* pad request bytes into a usable size -- internal version */ - -#define request2size(req) \ - (((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) ? \ - MINSIZE : \ - ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) - -/* Same, except also perform argument check */ - -#define checked_request2size(req, sz) \ - if (REQUEST_OUT_OF_RANGE(req)) { \ - MALLOC_FAILURE_ACTION; \ - return 0; \ - } \ - (sz) = request2size(req); - -/* - --------------- Physical chunk operations --------------- -*/ - - -/* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */ -#define PREV_INUSE 0x1 - -/* extract inuse bit of previous chunk */ -#define prev_inuse(p) ((p)->size & PREV_INUSE) - - -/* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */ -#define IS_MMAPPED 0x2 - -/* check for mmap()'ed chunk */ -#define chunk_is_mmapped(p) ((p)->size & IS_MMAPPED) - -/* - Bits to mask off when extracting size - - Note: IS_MMAPPED is intentionally not masked off from size field in - macros for which mmapped chunks should never be seen. This should - cause helpful core dumps to occur if it is tried by accident by - people extending or adapting this malloc. -*/ -#define SIZE_BITS (PREV_INUSE|IS_MMAPPED) - -/* Get size, ignoring use bits */ -#define chunksize(p) ((p)->size & ~(SIZE_BITS)) - - -/* Ptr to next physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->size & ~PREV_INUSE) )) - -/* Ptr to previous physical malloc_chunk */ -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_size) )) - -/* Treat space at ptr + offset as a chunk */ -#define chunk_at_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) - -/* extract p's inuse bit */ -#define inuse(p)\ -((((mchunkptr)(((char*)(p))+((p)->size & ~PREV_INUSE)))->size) & PREV_INUSE) - -/* set/clear chunk as being inuse without otherwise disturbing */ -#define set_inuse(p)\ -((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size |= PREV_INUSE - -#define clear_inuse(p)\ -((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size &= ~(PREV_INUSE) - - -/* check/set/clear inuse bits in known places */ -#define inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size & PREV_INUSE) - -#define set_inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size |= PREV_INUSE) - -#define clear_inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE)) - - -/* Set size at head, without disturbing its use bit */ -#define set_head_size(p, s) ((p)->size = (((p)->size & PREV_INUSE) | (s))) - -/* Set size/use field */ -#define set_head(p, s) ((p)->size = (s)) - -/* Set size at footer (only when chunk is not in use) */ -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_size = (s)) - - -/* - -------------------- Internal data structures -------------------- - - All internal state is held in an instance of malloc_state defined - below. There are no other static variables, except in two optional - cases: - * If USE_MALLOC_LOCK is defined, the mALLOC_MUTEx declared above. - * If HAVE_MMAP is true, but mmap doesn't support - MAP_ANONYMOUS, a dummy file descriptor for mmap. - - Beware of lots of tricks that minimize the total bookkeeping space - requirements. The result is a little over 1K bytes (for 4byte - pointers and size_t.) -*/ - -/* - Bins - - An array of bin headers for free chunks. Each bin is doubly - linked. The bins are approximately proportionally (log) spaced. - There are a lot of these bins (128). This may look excessive, but - works very well in practice. Most bins hold sizes that are - unusual as malloc request sizes, but are more usual for fragments - and consolidated sets of chunks, which is what these bins hold, so - they can be found quickly. All procedures maintain the invariant - that no consolidated chunk physically borders another one, so each - chunk in a list is known to be preceded and followed by either - inuse chunks or the ends of memory. - - Chunks in bins are kept in size order, with ties going to the - approximately least recently used chunk. Ordering isn't needed - for the small bins, which all contain the same-sized chunks, but - facilitates best-fit allocation for larger chunks. These lists - are just sequential. Keeping them in order almost never requires - enough traversal to warrant using fancier ordered data - structures. - - Chunks of the same size are linked with the most - recently freed at the front, and allocations are taken from the - back. This results in LRU (FIFO) allocation order, which tends - to give each chunk an equal opportunity to be consolidated with - adjacent freed chunks, resulting in larger free chunks and less - fragmentation. - - To simplify use in double-linked lists, each bin header acts - as a malloc_chunk. This avoids special-casing for headers. - But to conserve space and improve locality, we allocate - only the fd/bk pointers of bins, and then use repositioning tricks - to treat these as the fields of a malloc_chunk*. -*/ - -typedef struct malloc_chunk* mbinptr; - -/* addressing -- note that bin_at(0) does not exist */ -#define bin_at(m, i) ((mbinptr)((char*)&((m)->bins[(i)<<1]) - (SIZE_SZ<<1))) - -/* analog of ++bin */ -#define next_bin(b) ((mbinptr)((char*)(b) + (sizeof(mchunkptr)<<1))) - -/* Reminders about list directionality within bins */ -#define first(b) ((b)->fd) -#define last(b) ((b)->bk) - -/* Take a chunk off a bin list */ -#define unlink(P, BK, FD) { \ - FD = P->fd; \ - BK = P->bk; \ - FD->bk = BK; \ - BK->fd = FD; \ -} - -/* - Indexing - - Bins for sizes < 512 bytes contain chunks of all the same size, spaced - 8 bytes apart. Larger bins are approximately logarithmically spaced: - - 64 bins of size 8 - 32 bins of size 64 - 16 bins of size 512 - 8 bins of size 4096 - 4 bins of size 32768 - 2 bins of size 262144 - 1 bin of size what's left - - There is actually a little bit of slop in the numbers in bin_index - for the sake of speed. This makes no difference elsewhere. - - The bins top out around 1MB because we expect to service large - requests via mmap. -*/ - -#define NBINS 128 -#define NSMALLBINS 64 -#define SMALLBIN_WIDTH 8 -#define MIN_LARGE_SIZE 512 - -#define in_smallbin_range(sz) \ - ((unsigned long)(sz) < (unsigned long)MIN_LARGE_SIZE) - -#define smallbin_index(sz) (((unsigned)(sz)) >> 3) - -#define largebin_index(sz) \ -(((((unsigned long)(sz)) >> 6) <= 32)? 56 + (((unsigned long)(sz)) >> 6): \ - ((((unsigned long)(sz)) >> 9) <= 20)? 91 + (((unsigned long)(sz)) >> 9): \ - ((((unsigned long)(sz)) >> 12) <= 10)? 110 + (((unsigned long)(sz)) >> 12): \ - ((((unsigned long)(sz)) >> 15) <= 4)? 119 + (((unsigned long)(sz)) >> 15): \ - ((((unsigned long)(sz)) >> 18) <= 2)? 124 + (((unsigned long)(sz)) >> 18): \ - 126) - -#define bin_index(sz) \ - ((in_smallbin_range(sz)) ? smallbin_index(sz) : largebin_index(sz)) - - -/* - Unsorted chunks - - All remainders from chunk splits, as well as all returned chunks, - are first placed in the "unsorted" bin. They are then placed - in regular bins after malloc gives them ONE chance to be used before - binning. So, basically, the unsorted_chunks list acts as a queue, - with chunks being placed on it in free (and malloc_consolidate), - and taken off (to be either used or placed in bins) in malloc. -*/ - -/* The otherwise unindexable 1-bin is used to hold unsorted chunks. */ -#define unsorted_chunks(M) (bin_at(M, 1)) - -/* - Top - - The top-most available chunk (i.e., the one bordering the end of - available memory) is treated specially. It is never included in - any bin, is used only if no other chunk is available, and is - released back to the system if it is very large (see - M_TRIM_THRESHOLD). Because top initially - points to its own bin with initial zero size, thus forcing - extension on the first malloc request, we avoid having any special - code in malloc to check whether it even exists yet. But we still - need to do so when getting memory from system, so we make - initial_top treat the bin as a legal but unusable chunk during the - interval between initialization and the first call to - sYSMALLOc. (This is somewhat delicate, since it relies on - the 2 preceding words to be zero during this interval as well.) -*/ - -/* Conveniently, the unsorted bin can be used as dummy top on first call */ -#define initial_top(M) (unsorted_chunks(M)) - -/* - Binmap - - To help compensate for the large number of bins, a one-level index - structure is used for bin-by-bin searching. `binmap' is a - bitvector recording whether bins are definitely empty so they can - be skipped over during during traversals. The bits are NOT always - cleared as soon as bins are empty, but instead only - when they are noticed to be empty during traversal in malloc. -*/ - -/* Conservatively use 32 bits per map word, even if on 64bit system */ -#define BINMAPSHIFT 5 -#define BITSPERMAP (1U << BINMAPSHIFT) -#define BINMAPSIZE (NBINS / BITSPERMAP) - -#define idx2block(i) ((i) >> BINMAPSHIFT) -#define idx2bit(i) ((1U << ((i) & ((1U << BINMAPSHIFT)-1)))) - -#define mark_bin(m,i) ((m)->binmap[idx2block(i)] |= idx2bit(i)) -#define unmark_bin(m,i) ((m)->binmap[idx2block(i)] &= ~(idx2bit(i))) -#define get_binmap(m,i) ((m)->binmap[idx2block(i)] & idx2bit(i)) - -/* - Fastbins - - An array of lists holding recently freed small chunks. Fastbins - are not doubly linked. It is faster to single-link them, and - since chunks are never removed from the middles of these lists, - double linking is not necessary. Also, unlike regular bins, they - are not even processed in FIFO order (they use faster LIFO) since - ordering doesn't much matter in the transient contexts in which - fastbins are normally used. - - Chunks in fastbins keep their inuse bit set, so they cannot - be consolidated with other free chunks. malloc_consolidate - releases all chunks in fastbins and consolidates them with - other free chunks. -*/ - -typedef struct malloc_chunk* mfastbinptr; - -/* offset 2 to use otherwise unindexable first 2 bins */ -#define fastbin_index(sz) ((((unsigned int)(sz)) >> 3) - 2) - -/* The maximum fastbin request size we support */ -#define MAX_FAST_SIZE 80 - -#define NFASTBINS (fastbin_index(request2size(MAX_FAST_SIZE))+1) - -/* - FASTBIN_CONSOLIDATION_THRESHOLD is the size of a chunk in free() - that triggers automatic consolidation of possibly-surrounding - fastbin chunks. This is a heuristic, so the exact value should not - matter too much. It is defined at half the default trim threshold as a - compromise heuristic to only attempt consolidation if it is likely - to lead to trimming. However, it is not dynamically tunable, since - consolidation reduces fragmentation surrounding loarge chunks even - if trimming is not used. -*/ - -#define FASTBIN_CONSOLIDATION_THRESHOLD (65536UL) - -/* - Since the lowest 2 bits in max_fast don't matter in size comparisons, - they are used as flags. -*/ - -/* - FASTCHUNKS_BIT held in max_fast indicates that there are probably - some fastbin chunks. It is set true on entering a chunk into any - fastbin, and cleared only in malloc_consolidate. - - The truth value is inverted so that have_fastchunks will be true - upon startup (since statics are zero-filled), simplifying - initialization checks. -*/ - -#define FASTCHUNKS_BIT (1U) - -#define have_fastchunks(M) (((M)->max_fast & FASTCHUNKS_BIT) == 0) -#define clear_fastchunks(M) ((M)->max_fast |= FASTCHUNKS_BIT) -#define set_fastchunks(M) ((M)->max_fast &= ~FASTCHUNKS_BIT) - -/* - NONCONTIGUOUS_BIT indicates that MORECORE does not return contiguous - regions. Otherwise, contiguity is exploited in merging together, - when possible, results from consecutive MORECORE calls. - - The initial value comes from MORECORE_CONTIGUOUS, but is - changed dynamically if mmap is ever used as an sbrk substitute. -*/ - -#define NONCONTIGUOUS_BIT (2U) - -#define contiguous(M) (((M)->max_fast & NONCONTIGUOUS_BIT) == 0) -#define noncontiguous(M) (((M)->max_fast & NONCONTIGUOUS_BIT) != 0) -#define set_noncontiguous(M) ((M)->max_fast |= NONCONTIGUOUS_BIT) -#define set_contiguous(M) ((M)->max_fast &= ~NONCONTIGUOUS_BIT) - -/* - Set value of max_fast. - Use impossibly small value if 0. - Precondition: there are no existing fastbin chunks. - Setting the value clears fastchunk bit but preserves noncontiguous bit. -*/ - -#define set_max_fast(M, s) \ - (M)->max_fast = (((s) == 0)? SMALLBIN_WIDTH: request2size(s)) | \ - FASTCHUNKS_BIT | \ - ((M)->max_fast & NONCONTIGUOUS_BIT) - - -/* - ----------- Internal state representation and initialization ----------- -*/ - -struct malloc_state { - - /* The maximum chunk size to be eligible for fastbin */ - INTERNAL_SIZE_T max_fast; /* low 2 bits used as flags */ - - /* Fastbins */ - mfastbinptr fastbins[NFASTBINS]; - - /* Base of the topmost chunk -- not otherwise kept in a bin */ - mchunkptr top; - - /* The remainder from the most recent split of a small request */ - mchunkptr last_remainder; - - /* Normal bins packed as described above */ - mchunkptr bins[NBINS * 2]; - - /* Bitmap of bins */ - unsigned int binmap[BINMAPSIZE]; - - /* Tunable parameters */ - unsigned long trim_threshold; - INTERNAL_SIZE_T top_pad; - INTERNAL_SIZE_T mmap_threshold; - - /* Memory map support */ - int n_mmaps; - int n_mmaps_max; - int max_n_mmaps; - - /* Cache malloc_getpagesize */ - unsigned int pagesize; - - /* Statistics */ - INTERNAL_SIZE_T mmapped_mem; - INTERNAL_SIZE_T sbrked_mem; - INTERNAL_SIZE_T max_sbrked_mem; - INTERNAL_SIZE_T max_mmapped_mem; - INTERNAL_SIZE_T max_total_mem; -}; - -typedef struct malloc_state *mstate; - -/* - There is exactly one instance of this struct in this malloc. - If you are adapting this malloc in a way that does NOT use a static - malloc_state, you MUST explicitly zero-fill it before using. This - malloc relies on the property that malloc_state is initialized to - all zeroes (as is true of C statics). -*/ - -static struct malloc_state av_; /* never directly referenced */ - -/* - All uses of av_ are via get_malloc_state(). - At most one "call" to get_malloc_state is made per invocation of - the public versions of malloc and free, but other routines - that in turn invoke malloc and/or free may call more then once. - Also, it is called in check* routines if DEBUG is set. -*/ - -#define get_malloc_state() (&(av_)) - -/* - Initialize a malloc_state struct. - - This is called only from within malloc_consolidate, which needs - be called in the same contexts anyway. It is never called directly - outside of malloc_consolidate because some optimizing compilers try - to inline it at all call points, which turns out not to be an - optimization at all. (Inlining it in malloc_consolidate is fine though.) -*/ - -#if __STD_C -static void malloc_init_state(mstate av) -#else -static void malloc_init_state(av) mstate av; -#endif -{ - int i; - mbinptr bin; - - /* Establish circular links for normal bins */ - for (i = 1; i < NBINS; ++i) { - bin = bin_at(av,i); - bin->fd = bin->bk = bin; - } - - av->top_pad = DEFAULT_TOP_PAD; - av->n_mmaps_max = DEFAULT_MMAP_MAX; - av->mmap_threshold = DEFAULT_MMAP_THRESHOLD; - av->trim_threshold = DEFAULT_TRIM_THRESHOLD; - -#if !MORECORE_CONTIGUOUS - set_noncontiguous(av); -#endif - - set_max_fast(av, DEFAULT_MXFAST); - - av->top = initial_top(av); - av->pagesize = malloc_getpagesize; -} - -/* - Other internal utilities operating on mstates -*/ - -#if __STD_C -static Void_t* sYSMALLOc(INTERNAL_SIZE_T, mstate); -static int sYSTRIm(size_t, mstate); -static void malloc_consolidate(mstate); -static Void_t** iALLOc(size_t, size_t*, int, Void_t**); -#else -static Void_t* sYSMALLOc(); -static int sYSTRIm(); -static void malloc_consolidate(); -static Void_t** iALLOc(); -#endif - -/* - Debugging support - - These routines make a number of assertions about the states - of data structures that should be true at all times. If any - are not true, it's very likely that a user program has somehow - trashed memory. (It's also possible that there is a coding error - in malloc. In which case, please report it!) -*/ - -#ifndef DEBUG - -#define check_chunk(P) -#define check_free_chunk(P) -#define check_inuse_chunk(P) -#define check_remalloced_chunk(P,N) -#define check_malloced_chunk(P,N) -#define check_malloc_state() - -#else -#define check_chunk(P) do_check_chunk(P) -#define check_free_chunk(P) do_check_free_chunk(P) -#define check_inuse_chunk(P) do_check_inuse_chunk(P) -#define check_remalloced_chunk(P,N) do_check_remalloced_chunk(P,N) -#define check_malloced_chunk(P,N) do_check_malloced_chunk(P,N) -#define check_malloc_state() do_check_malloc_state() - -/* - Properties of all chunks -*/ - -INLINE -#if __STD_C -static void do_check_chunk(mchunkptr p) -#else -static void do_check_chunk(p) mchunkptr p; -#endif -{ - mstate av = get_malloc_state(); - unsigned long sz = chunksize(p); - /* min and max possible addresses assuming contiguous allocation */ - char* max_address = (char*)(av->top) + chunksize(av->top); - char* min_address = max_address - av->sbrked_mem; - - if (!chunk_is_mmapped(p)) { - - /* Has legal address ... */ - if (p != av->top) { - if (contiguous(av)) { - assert(((char*)p) >= min_address); - assert(((char*)p + sz) <= ((char*)(av->top))); - } - } - else { - /* top size is always at least MINSIZE */ - assert((unsigned long)(sz) >= MINSIZE); - /* top predecessor always marked inuse */ - assert(prev_inuse(p)); - } - - } - else { -#if HAVE_MMAP - /* address is outside main heap */ - if (contiguous(av) && av->top != initial_top(av)) { - assert(((char*)p) < min_address || ((char*)p) > max_address); - } - /* chunk is page-aligned */ - assert(((p->prev_size + sz) & (av->pagesize-1)) == 0); - /* mem is aligned */ - assert(aligned_OK(chunk2mem(p))); -#else - /* force an appropriate assert violation if debug set */ - assert(!chunk_is_mmapped(p)); -#endif - } -} - -/* - Properties of free chunks -*/ - -INLINE -#if __STD_C -static void do_check_free_chunk(mchunkptr p) -#else -static void do_check_free_chunk(p) mchunkptr p; -#endif -{ - mstate av = get_malloc_state(); - - INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE; - mchunkptr next = chunk_at_offset(p, sz); - - do_check_chunk(p); - - /* Chunk must claim to be free ... */ - assert(!inuse(p)); - assert (!chunk_is_mmapped(p)); - - /* Unless a special marker, must have OK fields */ - if ((unsigned long)(sz) >= MINSIZE) - { - assert((sz & MALLOC_ALIGN_MASK) == 0); - assert(aligned_OK(chunk2mem(p))); - /* ... matching footer field */ - assert(next->prev_size == sz); - /* ... and is fully consolidated */ - assert(prev_inuse(p)); - assert (next == av->top || inuse(next)); - - /* ... and has minimally sane links */ - assert(p->fd->bk == p); - assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_SZ */ - assert(sz == SIZE_SZ); -} - -/* - Properties of inuse chunks -*/ - -INLINE -#if __STD_C -static void do_check_inuse_chunk(mchunkptr p) -#else -static void do_check_inuse_chunk(p) mchunkptr p; -#endif -{ - mstate av = get_malloc_state(); - mchunkptr next; - do_check_chunk(p); - - if (chunk_is_mmapped(p)) - return; /* mmapped chunks have no next/prev */ - - /* Check whether it claims to be in use ... */ - assert(inuse(p)); - - next = next_chunk(p); - - /* ... and is surrounded by OK chunks. - Since more things can be checked with free chunks than inuse ones, - if an inuse chunk borders them and debug is on, it's worth doing them. - */ - if (!prev_inuse(p)) { - /* Note that we cannot even look at prev unless it is not inuse */ - mchunkptr prv = prev_chunk(p); - assert(next_chunk(prv) == p); - do_check_free_chunk(prv); - } - - if (next == av->top) { - assert(prev_inuse(next)); - assert(chunksize(next) >= MINSIZE); - } - else if (!inuse(next)) - do_check_free_chunk(next); -} - -/* - Properties of chunks recycled from fastbins -*/ - -INLINE -#if __STD_C -static void do_check_remalloced_chunk(mchunkptr p, INTERNAL_SIZE_T s) -#else -static void do_check_remalloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s; -#endif -{ - INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE; - - do_check_inuse_chunk(p); - - /* Legal size ... */ - assert((sz & MALLOC_ALIGN_MASK) == 0); - assert((unsigned long)(sz) >= MINSIZE); - /* ... and tqalignment */ - assert(aligned_OK(chunk2mem(p))); - /* chunk is less than MINSIZE more than request */ - assert((long)(sz) - (long)(s) >= 0); - assert((long)(sz) - (long)(s + MINSIZE) < 0); -} - -/* - Properties of nonrecycled chunks at the point they are malloced -*/ - -INLINE -#if __STD_C -static void do_check_malloced_chunk(mchunkptr p, INTERNAL_SIZE_T s) -#else -static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s; -#endif -{ - /* same as recycled case ... */ - do_check_remalloced_chunk(p, s); - - /* - ... plus, must obey implementation invariant that prev_inuse is - always true of any allocated chunk; i.e., that each allocated - chunk borders either a previously allocated and still in-use - chunk, or the base of its memory arena. This is ensured - by making all allocations from the the `lowest' part of any found - chunk. This does not necessarily hold however for chunks - recycled via fastbins. - */ - - assert(prev_inuse(p)); -} - - -/* - Properties of malloc_state. - - This may be useful for debugging malloc, as well as detecting user - programmer errors that somehow write into malloc_state. - - If you are extending or experimenting with this malloc, you can - probably figure out how to hack this routine to print out or - display chunk addresses, sizes, bins, and other instrumentation. -*/ - -static void do_check_malloc_state() -{ - mstate av = get_malloc_state(); - int i; - mchunkptr p; - mchunkptr q; - mbinptr b; - unsigned int binbit; - int empty; - unsigned int idx; - INTERNAL_SIZE_T size; - unsigned long total = 0; - int max_fast_bin; - - /* internal size_t must be no wider than pointer type */ - assert(sizeof(INTERNAL_SIZE_T) <= sizeof(char*)); - - /* tqalignment is a power of 2 */ - assert((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-1)) == 0); - - /* cannot run remaining checks until fully initialized */ - if (av->top == 0 || av->top == initial_top(av)) - return; - - /* pagesize is a power of 2 */ - assert((av->pagesize & (av->pagesize-1)) == 0); - - /* properties of fastbins */ - - /* max_fast is in allowed range */ - assert((av->max_fast & ~1) <= request2size(MAX_FAST_SIZE)); - - max_fast_bin = fastbin_index(av->max_fast); - - for (i = 0; i < NFASTBINS; ++i) { - p = av->fastbins[i]; - - /* all bins past max_fast are empty */ - if (i > max_fast_bin) - assert(p == 0); - - while (p != 0) { - /* each chunk claims to be inuse */ - do_check_inuse_chunk(p); - total += chunksize(p); - /* chunk belongs in this bin */ - assert(fastbin_index(chunksize(p)) == i); - p = p->fd; - } - } - - if (total != 0) - assert(have_fastchunks(av)); - else if (!have_fastchunks(av)) - assert(total == 0); - - /* check normal bins */ - for (i = 1; i < NBINS; ++i) { - b = bin_at(av,i); - - /* binmap is accurate (except for bin 1 == unsorted_chunks) */ - if (i >= 2) { - binbit = get_binmap(av,i); - empty = last(b) == b; - if (!binbit) - assert(empty); - else if (!empty) - assert(binbit); - } - - for (p = last(b); p != b; p = p->bk) { - /* each chunk claims to be free */ - do_check_free_chunk(p); - size = chunksize(p); - total += size; - if (i >= 2) { - /* chunk belongs in bin */ - idx = bin_index(size); - assert(idx == i); - /* lists are sorted */ - assert(p->bk == b || - (unsigned long)chunksize(p->bk) >= (unsigned long)chunksize(p)); - } - /* chunk is followed by a legal chain of inuse chunks */ - for (q = next_chunk(p); - (q != av->top && inuse(q) && - (unsigned long)(chunksize(q)) >= MINSIZE); - q = next_chunk(q)) - do_check_inuse_chunk(q); - } - } - - /* top chunk is OK */ - check_chunk(av->top); - - /* sanity checks for statistics */ - - assert(total <= (unsigned long)(av->max_total_mem)); - assert(av->n_mmaps >= 0); - assert(av->n_mmaps <= av->n_mmaps_max); - assert(av->n_mmaps <= av->max_n_mmaps); - - assert((unsigned long)(av->sbrked_mem) <= - (unsigned long)(av->max_sbrked_mem)); - - assert((unsigned long)(av->mmapped_mem) <= - (unsigned long)(av->max_mmapped_mem)); - - assert((unsigned long)(av->max_total_mem) >= - (unsigned long)(av->mmapped_mem) + (unsigned long)(av->sbrked_mem)); -} -#endif - - -/* ----------- Routines dealing with system allocation -------------- */ - -/* - sYSTRIm is an inverse of sorts to sYSMALLOc. It gives memory back - to the system (via negative arguments to sbrk) if there is unused - memory at the `high' end of the malloc pool. It is called - automatically by free() when top space exceeds the trim - threshold. It is also called by the public malloc_trim routine. It - returns 1 if it actually released any memory, else 0. -*/ - -INLINE -#if __STD_C -static int sYSTRIm(size_t pad, mstate av) -#else -static int sYSTRIm(pad, av) size_t pad; mstate av; -#endif -{ - long top_size; /* Amount of top-most memory */ - long extra; /* Amount to release */ - long released; /* Amount actually released */ - char* current_brk; /* address returned by pre-check sbrk call */ - char* new_brk; /* address returned by post-check sbrk call */ - size_t pagesz; - - pagesz = av->pagesize; - top_size = chunksize(av->top); - - /* Release in pagesize units, keeping at least one page */ - extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz; - - if (extra > 0) { - - /* - Only proceed if end of memory is where we last set it. - This avoids problems if there were foreign sbrk calls. - */ - current_brk = (char*)(MORECORE(0)); - if (current_brk == (char*)(av->top) + top_size) { - - /* - Attempt to release memory. We ignore MORECORE return value, - and instead call again to find out where new end of memory is. - This avoids problems if first call releases less than we asked, - of if failure somehow altered brk value. (We could still - encounter problems if it altered brk in some very bad way, - but the only thing we can do is adjust anyway, which will cause - some downstream failure.) - */ - - MORECORE(-extra); - new_brk = (char*)(MORECORE(0)); - - if (new_brk != (char*)MORECORE_FAILURE) { - released = (long)(current_brk - new_brk); - - if (released != 0) { - /* Success. Adjust top. */ - av->sbrked_mem -= released; - set_head(av->top, (top_size - released) | PREV_INUSE); - check_malloc_state(); - return 1; - } - } - } - } - return 0; -} - -/* - ------------------------- malloc_consolidate ------------------------- - - malloc_consolidate is a specialized version of free() that tears - down chunks held in fastbins. Free itself cannot be used for this - purpose since, among other things, it might place chunks back onto - fastbins. So, instead, we need to use a minor variant of the same - code. - - Also, because this routine needs to be called the first time through - malloc anyway, it turns out to be the perfect place to trigger - initialization code. -*/ - -INLINE -#if __STD_C -static void malloc_consolidate(mstate av) -#else -static void malloc_consolidate(av) mstate av; -#endif -{ - mfastbinptr* fb; /* current fastbin being consolidated */ - mfastbinptr* maxfb; /* last fastbin (for loop control) */ - mchunkptr p; /* current chunk being consolidated */ - mchunkptr nextp; /* next chunk to consolidate */ - mchunkptr unsorted_bin; /* bin header */ - mchunkptr first_unsorted; /* chunk to link to */ - - /* These have same use as in free() */ - mchunkptr nextchunk; - INTERNAL_SIZE_T size; - INTERNAL_SIZE_T nextsize; - INTERNAL_SIZE_T prevsize; - int nextinuse; - mchunkptr bck; - mchunkptr fwd; - - /* - If max_fast is 0, we know that av hasn't - yet been initialized, in which case do so below - */ - - if (av->max_fast != 0) { - clear_fastchunks(av); - - unsorted_bin = unsorted_chunks(av); - - /* - Remove each chunk from fast bin and consolidate it, placing it - then in unsorted bin. Among other reasons for doing this, - placing in unsorted bin avoids needing to calculate actual bins - until malloc is sure that chunks aren't immediately going to be - reused anyway. - */ - - maxfb = &(av->fastbins[fastbin_index(av->max_fast)]); - fb = &(av->fastbins[0]); - do { - if ( (p = *fb) != 0) { - *fb = 0; - - do { - check_inuse_chunk(p); - nextp = p->fd; - - /* Slightly streamlined version of consolidation code in free() */ - size = p->size & ~PREV_INUSE; - nextchunk = chunk_at_offset(p, size); - nextsize = chunksize(nextchunk); - - if (!prev_inuse(p)) { - prevsize = p->prev_size; - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - unlink(p, bck, fwd); - } - - if (nextchunk != av->top) { - nextinuse = inuse_bit_at_offset(nextchunk, nextsize); - set_head(nextchunk, nextsize); - - if (!nextinuse) { - size += nextsize; - unlink(nextchunk, bck, fwd); - } - - first_unsorted = unsorted_bin->fd; - unsorted_bin->fd = p; - first_unsorted->bk = p; - - set_head(p, size | PREV_INUSE); - p->bk = unsorted_bin; - p->fd = first_unsorted; - set_foot(p, size); - } - - else { - size += nextsize; - set_head(p, size | PREV_INUSE); - av->top = p; - } - - } while ( (p = nextp) != 0); - - } - } while (fb++ != maxfb); - } - else { - malloc_init_state(av); - check_malloc_state(); - } -} - -/* - ------------------------------ free ------------------------------ -*/ - -INLINE -#if __STD_C -void fREe(Void_t* mem) -#else -void fREe(mem) Void_t* mem; -#endif -{ - mstate av = get_malloc_state(); - - mchunkptr p; /* chunk corresponding to mem */ - INTERNAL_SIZE_T size; /* its size */ - mfastbinptr* fb; /* associated fastbin */ - mchunkptr nextchunk; /* next contiguous chunk */ - INTERNAL_SIZE_T nextsize; /* its size */ - int nextinuse; /* true if nextchunk is used */ - INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */ - mchunkptr bck; /* misc temp for linking */ - mchunkptr fwd; /* misc temp for linking */ - - - /* free(0) has no effect */ - if (mem != 0) { - p = mem2chunk(mem); - size = chunksize(p); - - check_inuse_chunk(p); - - /* - If eligible, place chunk on a fastbin so it can be found - and used quickly in malloc. - */ - - if ((unsigned long)(size) <= (unsigned long)(av->max_fast) - -#if TRIM_FASTBINS - /* - If TRIM_FASTBINS set, don't place chunks - bordering top into fastbins - */ - && (chunk_at_offset(p, size) != av->top) -#endif - ) { - - set_fastchunks(av); - fb = &(av->fastbins[fastbin_index(size)]); - p->fd = *fb; - *fb = p; - } - - /* - Consolidate other non-mmapped chunks as they arrive. - */ - - else if (!chunk_is_mmapped(p)) { - nextchunk = chunk_at_offset(p, size); - nextsize = chunksize(nextchunk); - - /* consolidate backward */ - if (!prev_inuse(p)) { - prevsize = p->prev_size; - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - unlink(p, bck, fwd); - } - - if (nextchunk != av->top) { - /* get and clear inuse bit */ - nextinuse = inuse_bit_at_offset(nextchunk, nextsize); - set_head(nextchunk, nextsize); - - /* consolidate forward */ - if (!nextinuse) { - unlink(nextchunk, bck, fwd); - size += nextsize; - } - - /* - Place the chunk in unsorted chunk list. Chunks are - not placed into regular bins until after they have - been given one chance to be used in malloc. - */ - - bck = unsorted_chunks(av); - fwd = bck->fd; - p->bk = bck; - p->fd = fwd; - bck->fd = p; - fwd->bk = p; - - set_head(p, size | PREV_INUSE); - set_foot(p, size); - - check_free_chunk(p); - } - - /* - If the chunk borders the current high end of memory, - consolidate into top - */ - - else { - size += nextsize; - set_head(p, size | PREV_INUSE); - av->top = p; - check_chunk(p); - } - - /* - If freeing a large space, consolidate possibly-surrounding - chunks. Then, if the total unused topmost memory exceeds trim - threshold, ask malloc_trim to reduce top. - - Unless max_fast is 0, we don't know if there are fastbins - bordering top, so we cannot tell for sure whether threshold - has been reached unless fastbins are consolidated. But we - don't want to consolidate on each free. As a compromise, - consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD - is reached. - */ - - if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) { - if (have_fastchunks(av)) - malloc_consolidate(av); - -#ifndef MORECORE_CANNOT_TRIM - if ((unsigned long)(chunksize(av->top)) >= - (unsigned long)(av->trim_threshold)) - sYSTRIm(av->top_pad, av); -#endif - } - - } - /* - If the chunk was allocated via mmap, release via munmap() - Note that if HAVE_MMAP is false but chunk_is_mmapped is - true, then user must have overwritten memory. There's nothing - we can do to catch this error unless DEBUG is set, in which case - check_inuse_chunk (above) will have triggered error. - */ - - else { -#if HAVE_MMAP - int ret; - INTERNAL_SIZE_T offset = p->prev_size; - av->n_mmaps--; - av->mmapped_mem -= (size + offset); - ret = munmap((char*)p - offset, size + offset); - /* munmap returns non-zero on failure */ - assert(ret == 0); -#endif - } - } -} - -/* - sysmalloc handles malloc cases requiring more memory from the system. - On entry, it is assumed that av->top does not have enough - space to service request for nb bytes, thus requiring that av->top - be extended or replaced. -*/ - -INLINE -#if __STD_C -static Void_t* sYSMALLOc(INTERNAL_SIZE_T nb, mstate av) -#else -static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; -#endif -{ - mchunkptr old_top; /* incoming value of av->top */ - INTERNAL_SIZE_T old_size; /* its size */ - char* old_end; /* its end address */ - - long size; /* arg to first MORECORE or mmap call */ - char* brk; /* return value from MORECORE */ - - long correction; /* arg to 2nd MORECORE call */ - char* snd_brk; /* 2nd return val */ - - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ - INTERNAL_SIZE_T end_misalign; /* partial page left at end of new space */ - char* aligned_brk; /* aligned offset into brk */ - - mchunkptr p; /* the allocated/returned chunk */ - mchunkptr remainder; /* remainder from allocation */ - unsigned long remainder_size; /* its size */ - - unsigned long sum; /* for updating stats */ - - size_t pagemask = av->pagesize - 1; - - -#if HAVE_MMAP - - /* - If have mmap, and the request size meets the mmap threshold, and - the system supports mmap, and there are few enough currently - allocated mmapped regions, try to directly map this request - rather than expanding top. - */ - - if ((unsigned long)(nb) >= (unsigned long)(av->mmap_threshold) && - (av->n_mmaps < av->n_mmaps_max)) { - - char* mm; /* return value from mmap call*/ - - /* - Round up size to nearest page. For mmapped chunks, the overhead - is one SIZE_SZ unit larger than for normal chunks, because there - is no following chunk whose prev_size field could be used. - */ - size = (nb + SIZE_SZ + MALLOC_ALIGN_MASK + pagemask) & ~pagemask; - - /* Don't try if size wraps around 0 */ - if ((unsigned long)(size) > (unsigned long)(nb)) { - - mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE)); - - if (mm != (char*)(MORECORE_FAILURE)) { - - /* - The offset to the start of the mmapped region is stored - in the prev_size field of the chunk. This allows us to adjust - returned start address to meet tqalignment requirements here - and in memalign(), and still be able to compute proper - address argument for later munmap in free() and realloc(). - */ - - front_misalign = (INTERNAL_SIZE_T)chunk2mem(mm) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) { - correction = MALLOC_ALIGNMENT - front_misalign; - p = (mchunkptr)(mm + correction); - p->prev_size = correction; - set_head(p, (size - correction) |IS_MMAPPED); - } - else { - p = (mchunkptr)mm; - p->prev_size = 0; - set_head(p, size|IS_MMAPPED); - } - - /* update statistics */ - - if (++av->n_mmaps > av->max_n_mmaps) - av->max_n_mmaps = av->n_mmaps; - - sum = av->mmapped_mem += size; - if (sum > (unsigned long)(av->max_mmapped_mem)) - av->max_mmapped_mem = sum; - sum += av->sbrked_mem; - if (sum > (unsigned long)(av->max_total_mem)) - av->max_total_mem = sum; - - check_chunk(p); - - return chunk2mem(p); - } - } - } -#endif - - /* Record incoming configuration of top */ - - old_top = av->top; - old_size = chunksize(old_top); - old_end = (char*)(chunk_at_offset(old_top, old_size)); - - brk = snd_brk = (char*)(MORECORE_FAILURE); - - /* - If not the first time through, we require old_size to be - at least MINSIZE and to have prev_inuse set. - */ - - assert((old_top == initial_top(av) && old_size == 0) || - ((unsigned long) (old_size) >= MINSIZE && - prev_inuse(old_top))); - - /* Precondition: not enough current space to satisfy nb request */ - assert((unsigned long)(old_size) < (unsigned long)(nb + MINSIZE)); - - /* Precondition: all fastbins are consolidated */ - assert(!have_fastchunks(av)); - - - /* Request enough space for nb + pad + overhead */ - - size = nb + av->top_pad + MINSIZE; - - /* - If contiguous, we can subtract out existing space that we hope to - combine with new space. We add it back later only if - we don't actually get contiguous space. - */ - - if (contiguous(av)) - size -= old_size; - - /* - Round to a multiple of page size. - If MORECORE is not contiguous, this ensures that we only call it - with whole-page arguments. And if MORECORE is contiguous and - this is not first time through, this preserves page-tqalignment of - previous calls. Otherwise, we correct to page-align below. - */ - - size = (size + pagemask) & ~pagemask; - - /* - Don't try to call MORECORE if argument is so big as to appear - negative. Note that since mmap takes size_t arg, it may succeed - below even if we cannot call MORECORE. - */ - - if (size > 0) - brk = (char*)(MORECORE(size)); - - /* - If have mmap, try using it as a backup when MORECORE fails or - cannot be used. This is worth doing on systems that have "holes" in - address space, so sbrk cannot extend to give contiguous space, but - space is available elsewhere. Note that we ignore mmap max count - and threshold limits, since the space will not be used as a - segregated mmap region. - */ - -#if HAVE_MMAP - if (brk == (char*)(MORECORE_FAILURE)) { - - /* Cannot merge with old top, so add its size back in */ - if (contiguous(av)) - size = (size + old_size + pagemask) & ~pagemask; - - /* If we are relying on mmap as backup, then use larger units */ - if ((unsigned long)(size) < (unsigned long)(MMAP_AS_MORECORE_SIZE)) - size = MMAP_AS_MORECORE_SIZE; - - /* Don't try if size wraps around 0 */ - if ((unsigned long)(size) > (unsigned long)(nb)) { - - brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE)); - - if (brk != (char*)(MORECORE_FAILURE)) { - - /* We do not need, and cannot use, another sbrk call to find end */ - snd_brk = brk + size; - - /* - Record that we no longer have a contiguous sbrk region. - After the first time mmap is used as backup, we do not - ever rely on contiguous space since this could incorrectly - bridge regions. - */ - set_noncontiguous(av); - } - } - } -#endif - - if (brk != (char*)(MORECORE_FAILURE)) { - av->sbrked_mem += size; - - /* - If MORECORE extends previous space, we can likewise extend top size. - */ - - if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) { - set_head(old_top, (size + old_size) | PREV_INUSE); - } - - /* - Otherwise, make adjustments: - - * If the first time through or noncontiguous, we need to call sbrk - just to find out where the end of memory lies. - - * We need to ensure that all returned chunks from malloc will meet - MALLOC_ALIGNMENT - - * If there was an intervening foreign sbrk, we need to adjust sbrk - request size to account for fact that we will not be able to - combine new space with existing space in old_top. - - * Almost all systems internally allocate whole pages at a time, in - which case we might as well use the whole last page of request. - So we allocate enough more memory to hit a page boundary now, - which in turn causes future contiguous calls to page-align. - */ - - else { - front_misalign = 0; - end_misalign = 0; - correction = 0; - aligned_brk = brk; - - /* handle contiguous cases */ - if (contiguous(av)) { - - /* Guarantee tqalignment of first new chunk made from this space */ - - front_misalign = (INTERNAL_SIZE_T)chunk2mem(brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) { - - /* - Skip over some bytes to arrive at an aligned position. - We don't need to specially mark these wasted front bytes. - They will never be accessed anyway because - prev_inuse of av->top (and any chunk created from its start) - is always true after initialization. - */ - - correction = MALLOC_ALIGNMENT - front_misalign; - aligned_brk += correction; - } - - /* - If this isn't adjacent to existing space, then we will not - be able to merge with old_top space, so must add to 2nd request. - */ - - correction += old_size; - - /* Extend the end address to hit a page boundary */ - end_misalign = (INTERNAL_SIZE_T)(brk + size + correction); - correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign; - - assert(correction >= 0); - snd_brk = (char*)(MORECORE(correction)); - - /* - If can't allocate correction, try to at least find out current - brk. It might be enough to proceed without failing. - - Note that if second sbrk did NOT fail, we assume that space - is contiguous with first sbrk. This is a safe assumption unless - program is multithreaded but doesn't use locks and a foreign sbrk - occurred between our first and second calls. - */ - - if (snd_brk == (char*)(MORECORE_FAILURE)) { - correction = 0; - snd_brk = (char*)(MORECORE(0)); - } - } - - /* handle non-contiguous cases */ - else { - /* MORECORE/mmap must correctly align */ - assert(((unsigned long)chunk2mem(brk) & MALLOC_ALIGN_MASK) == 0); - - /* Find out current end of memory */ - if (snd_brk == (char*)(MORECORE_FAILURE)) { - snd_brk = (char*)(MORECORE(0)); - } - } - - /* Adjust top based on results of second sbrk */ - if (snd_brk != (char*)(MORECORE_FAILURE)) { - av->top = (mchunkptr)aligned_brk; - set_head(av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); - av->sbrked_mem += correction; - - /* - If not the first time through, we either have a - gap due to foreign sbrk or a non-contiguous region. Insert a - double fencepost at old_top to prevent consolidation with space - we don't own. These fenceposts are artificial chunks that are - marked as inuse and are in any case too small to use. We need - two to make sizes and alignments work out. - */ - - if (old_size != 0) { - /* - Shrink old_top to insert fenceposts, keeping size a - multiple of MALLOC_ALIGNMENT. We know there is at least - enough space in old_top to do this. - */ - old_size = (old_size - 3*SIZE_SZ) & ~MALLOC_ALIGN_MASK; - set_head(old_top, old_size | PREV_INUSE); - - /* - Note that the following assignments completely overwrite - old_top when old_size was previously MINSIZE. This is - intentional. We need the fencepost, even if old_top otherwise gets - lost. - */ - chunk_at_offset(old_top, old_size )->size = - SIZE_SZ|PREV_INUSE; - - chunk_at_offset(old_top, old_size + SIZE_SZ)->size = - SIZE_SZ|PREV_INUSE; - - /* If possible, release the rest. */ - if (old_size >= MINSIZE) { - fREe(chunk2mem(old_top)); - } - - } - } - } - - /* Update statistics */ - sum = av->sbrked_mem; - if (sum > (unsigned long)(av->max_sbrked_mem)) - av->max_sbrked_mem = sum; - - sum += av->mmapped_mem; - if (sum > (unsigned long)(av->max_total_mem)) - av->max_total_mem = sum; - - check_malloc_state(); - - /* finally, do the allocation */ - p = av->top; - size = chunksize(p); - - /* check that one of the above allocation paths succeeded */ - if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { - remainder_size = size - nb; - remainder = chunk_at_offset(p, nb); - av->top = remainder; - set_head(p, nb | PREV_INUSE); - set_head(remainder, remainder_size | PREV_INUSE); - check_malloced_chunk(p, nb); - return chunk2mem(p); - } - } - - /* catch all failure paths */ - MALLOC_FAILURE_ACTION; - return 0; -} - - -/* - ------------------------------ malloc ------------------------------ -*/ - -INLINE -#if __STD_C -Void_t* mALLOc(size_t bytes) -#else - Void_t* mALLOc(bytes) size_t bytes; -#endif -{ - mstate av = get_malloc_state(); - - INTERNAL_SIZE_T nb; /* normalized request size */ - unsigned int idx; /* associated bin index */ - mbinptr bin; /* associated bin */ - mfastbinptr* fb; /* associated fastbin */ - - mchunkptr victim; /* inspected/selected chunk */ - INTERNAL_SIZE_T size; /* its size */ - int victim_index; /* its bin index */ - - mchunkptr remainder; /* remainder from a split */ - unsigned long remainder_size; /* its size */ - - unsigned int block; /* bit map traverser */ - unsigned int bit; /* bit map traverser */ - unsigned int map; /* current word of binmap */ - - mchunkptr fwd; /* misc temp for linking */ - mchunkptr bck; /* misc temp for linking */ - - /* - Convert request size to internal form by adding SIZE_SZ bytes - overhead plus possibly more to obtain necessary tqalignment and/or - to obtain a size of at least MINSIZE, the smallest allocatable - size. Also, checked_request2size traps (returning 0) request sizes - that are so large that they wrap around zero when padded and - aligned. - */ - - checked_request2size(bytes, nb); - - /* - If the size qualifies as a fastbin, first check corresponding bin. - This code is safe to execute even if av is not yet initialized, so we - can try it without checking, which saves some time on this fast path. - */ - - if ((unsigned long)(nb) <= (unsigned long)(av->max_fast)) { - fb = &(av->fastbins[(fastbin_index(nb))]); - if ( (victim = *fb) != 0) { - *fb = victim->fd; - check_remalloced_chunk(victim, nb); - return chunk2mem(victim); - } - } - - /* - If a small request, check regular bin. Since these "smallbins" - hold one size each, no searching within bins is necessary. - (For a large request, we need to wait until unsorted chunks are - processed to find best fit. But for small ones, fits are exact - anyway, so we can check now, which is faster.) - */ - - if (in_smallbin_range(nb)) { - idx = smallbin_index(nb); - bin = bin_at(av,idx); - - if ( (victim = last(bin)) != bin) { - if (victim == 0) /* initialization check */ - malloc_consolidate(av); - else { - bck = victim->bk; - set_inuse_bit_at_offset(victim, nb); - bin->bk = bck; - bck->fd = bin; - - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - } - } - - /* - If this is a large request, consolidate fastbins before continuing. - While it might look excessive to kill all fastbins before - even seeing if there is space available, this avoids - fragmentation problems normally associated with fastbins. - Also, in practice, programs tend to have runs of either small or - large requests, but less often mixtures, so consolidation is not - invoked all that often in most programs. And the programs that - it is called frequently in otherwise tend to fragment. - */ - - else { - idx = largebin_index(nb); - if (have_fastchunks(av)) - malloc_consolidate(av); - } - - /* - Process recently freed or remaindered chunks, taking one only if - it is exact fit, or, if this a small request, the chunk is remainder from - the most recent non-exact fit. Place other traversed chunks in - bins. Note that this step is the only place in any routine where - chunks are placed in bins. - - The outer loop here is needed because we might not realize until - near the end of malloc that we should have consolidated, so must - do so and retry. This happens at most once, and only when we would - otherwise need to expand memory to service a "small" request. - */ - - for(;;) { - - while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) { - bck = victim->bk; - size = chunksize(victim); - - /* - If a small request, try to use last remainder if it is the - only chunk in unsorted bin. This helps promote locality for - runs of consecutive small requests. This is the only - exception to best-fit, and applies only when there is - no exact fit for a small chunk. - */ - - if (in_smallbin_range(nb) && - bck == unsorted_chunks(av) && - victim == av->last_remainder && - (unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { - - /* split and reattach remainder */ - remainder_size = size - nb; - remainder = chunk_at_offset(victim, nb); - unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; - av->last_remainder = remainder; - remainder->bk = remainder->fd = unsorted_chunks(av); - - set_head(victim, nb | PREV_INUSE); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - /* remove from unsorted list */ - unsorted_chunks(av)->bk = bck; - bck->fd = unsorted_chunks(av); - - /* Take now instead of binning if exact fit */ - - if (size == nb) { - set_inuse_bit_at_offset(victim, size); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - /* place chunk in bin */ - - if (in_smallbin_range(size)) { - victim_index = smallbin_index(size); - bck = bin_at(av, victim_index); - fwd = bck->fd; - } - else { - victim_index = largebin_index(size); - bck = bin_at(av, victim_index); - fwd = bck->fd; - - /* maintain large bins in sorted order */ - if (fwd != bck) { - size |= PREV_INUSE; /* Or with inuse bit to speed comparisons */ - /* if smaller than smallest, bypass loop below */ - if ((unsigned long)(size) <= (unsigned long)(bck->bk->size)) { - fwd = bck; - bck = bck->bk; - } - else { - while ((unsigned long)(size) < (unsigned long)(fwd->size)) - fwd = fwd->fd; - bck = fwd->bk; - } - } - } - - mark_bin(av, victim_index); - victim->bk = bck; - victim->fd = fwd; - fwd->bk = victim; - bck->fd = victim; - } - - /* - If a large request, scan through the chunks of current bin in - sorted order to find smallest that fits. This is the only step - where an unbounded number of chunks might be scanned without doing - anything useful with them. However the lists tend to be short. - */ - - if (!in_smallbin_range(nb)) { - bin = bin_at(av, idx); - - /* skip scan if empty or largest chunk is too small */ - if ((victim = last(bin)) != bin && - (unsigned long)(first(bin)->size) >= (unsigned long)(nb)) { - - while (((unsigned long)(size = chunksize(victim)) < - (unsigned long)(nb))) - victim = victim->bk; - - remainder_size = size - nb; - unlink(victim, bck, fwd); - - /* Exhaust */ - if (remainder_size < MINSIZE) { - set_inuse_bit_at_offset(victim, size); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - /* Split */ - else { - remainder = chunk_at_offset(victim, nb); - unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; - remainder->bk = remainder->fd = unsorted_chunks(av); - set_head(victim, nb | PREV_INUSE); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - } - } - - /* - Search for a chunk by scanning bins, starting with next largest - bin. This search is strictly by best-fit; i.e., the smallest - (with ties going to approximately the least recently used) chunk - that fits is selected. - - The bitmap avoids needing to check that most blocks are nonempty. - The particular case of skipping all bins during warm-up phases - when no chunks have been returned yet is faster than it might look. - */ - - ++idx; - bin = bin_at(av,idx); - block = idx2block(idx); - map = av->binmap[block]; - bit = idx2bit(idx); - - for (;;) { - - /* Skip rest of block if there are no more set bits in this block. */ - if (bit > map || bit == 0) { - do { - if (++block >= BINMAPSIZE) /* out of bins */ - goto use_top; - } while ( (map = av->binmap[block]) == 0); - - bin = bin_at(av, (block << BINMAPSHIFT)); - bit = 1; - } - - /* Advance to bin with set bit. There must be one. */ - while ((bit & map) == 0) { - bin = next_bin(bin); - bit <<= 1; - assert(bit != 0); - } - - /* Inspect the bin. It is likely to be non-empty */ - victim = last(bin); - - /* If a false alarm (empty bin), clear the bit. */ - if (victim == bin) { - av->binmap[block] = map &= ~bit; /* Write through */ - bin = next_bin(bin); - bit <<= 1; - } - - else { - size = chunksize(victim); - - /* We know the first chunk in this bin is big enough to use. */ - assert((unsigned long)(size) >= (unsigned long)(nb)); - - remainder_size = size - nb; - - /* unlink */ - bck = victim->bk; - bin->bk = bck; - bck->fd = bin; - - /* Exhaust */ - if (remainder_size < MINSIZE) { - set_inuse_bit_at_offset(victim, size); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - /* Split */ - else { - remainder = chunk_at_offset(victim, nb); - - unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; - remainder->bk = remainder->fd = unsorted_chunks(av); - /* advertise as last remainder */ - if (in_smallbin_range(nb)) - av->last_remainder = remainder; - - set_head(victim, nb | PREV_INUSE); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - } - } - - use_top: - /* - If large enough, split off the chunk bordering the end of memory - (held in av->top). Note that this is in accord with the best-fit - search rule. In effect, av->top is treated as larger (and thus - less well fitting) than any other available chunk since it can - be extended to be as large as necessary (up to system - limitations). - - We require that av->top always exists (i.e., has size >= - MINSIZE) after initialization, so if it would otherwise be - exhuasted by current request, it is replenished. (The main - reason for ensuring it exists is that we may need MINSIZE space - to put in fenceposts in sysmalloc.) - */ - - victim = av->top; - size = chunksize(victim); - - if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { - remainder_size = size - nb; - remainder = chunk_at_offset(victim, nb); - av->top = remainder; - set_head(victim, nb | PREV_INUSE); - set_head(remainder, remainder_size | PREV_INUSE); - - check_malloced_chunk(victim, nb); - return chunk2mem(victim); - } - - /* - If there is space available in fastbins, consolidate and retry, - to possibly avoid expanding memory. This can occur only if nb is - in smallbin range so we didn't consolidate upon entry. - */ - - else if (have_fastchunks(av)) { - assert(in_smallbin_range(nb)); - malloc_consolidate(av); - idx = smallbin_index(nb); /* restore original bin index */ - } - - /* - Otherwise, relay to handle system-dependent cases - */ - else - return sYSMALLOc(nb, av); - } -} - -/* - ------------------------------ realloc ------------------------------ -*/ - - -INLINE -#if __STD_C -Void_t* rEALLOc(Void_t* oldmem, size_t bytes) -#else -Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes; -#endif -{ - mstate av = get_malloc_state(); - - INTERNAL_SIZE_T nb; /* padded request size */ - - mchunkptr oldp; /* chunk corresponding to oldmem */ - INTERNAL_SIZE_T oldsize; /* its size */ - - mchunkptr newp; /* chunk to return */ - INTERNAL_SIZE_T newsize; /* its size */ - Void_t* newmem; /* corresponding user mem */ - - mchunkptr next; /* next contiguous chunk after oldp */ - - mchunkptr remainder; /* extra space at end of newp */ - unsigned long remainder_size; /* its size */ - - mchunkptr bck; /* misc temp for linking */ - mchunkptr fwd; /* misc temp for linking */ - - unsigned long copysize; /* bytes to copy */ - unsigned int ncopies; /* INTERNAL_SIZE_T words to copy */ - INTERNAL_SIZE_T* s; /* copy source */ - INTERNAL_SIZE_T* d; /* copy destination */ - - -#ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - fREe(oldmem); - return 0; - } -#endif - - /* realloc of null is supposed to be same as malloc */ - if (oldmem == 0) return mALLOc(bytes); - - checked_request2size(bytes, nb); - - oldp = mem2chunk(oldmem); - oldsize = chunksize(oldp); - - check_inuse_chunk(oldp); - - if (!chunk_is_mmapped(oldp)) { - - if ((unsigned long)(oldsize) >= (unsigned long)(nb)) { - /* already big enough; split below */ - newp = oldp; - newsize = oldsize; - } - - else { - next = chunk_at_offset(oldp, oldsize); - - /* Try to expand forward into top */ - if (next == av->top && - (unsigned long)(newsize = oldsize + chunksize(next)) >= - (unsigned long)(nb + MINSIZE)) { - set_head_size(oldp, nb); - av->top = chunk_at_offset(oldp, nb); - set_head(av->top, (newsize - nb) | PREV_INUSE); - return chunk2mem(oldp); - } - - /* Try to expand forward into next chunk; split off remainder below */ - else if (next != av->top && - !inuse(next) && - (unsigned long)(newsize = oldsize + chunksize(next)) >= - (unsigned long)(nb)) { - newp = oldp; - unlink(next, bck, fwd); - } - - /* allocate, copy, free */ - else { - newmem = mALLOc(nb - MALLOC_ALIGN_MASK); - if (newmem == 0) - return 0; /* propagate failure */ - - newp = mem2chunk(newmem); - newsize = chunksize(newp); - - /* - Avoid copy if newp is next chunk after oldp. - */ - if (newp == next) { - newsize += oldsize; - newp = oldp; - } - else { - /* - Unroll copy of <= 36 bytes (72 if 8byte sizes) - We know that contents have an odd number of - INTERNAL_SIZE_T-sized words; minimally 3. - */ - - copysize = oldsize - SIZE_SZ; - s = (INTERNAL_SIZE_T*)(oldmem); - d = (INTERNAL_SIZE_T*)(newmem); - ncopies = copysize / sizeof(INTERNAL_SIZE_T); - assert(ncopies >= 3); - - if (ncopies > 9) - MALLOC_COPY(d, s, copysize); - - else { - *(d+0) = *(s+0); - *(d+1) = *(s+1); - *(d+2) = *(s+2); - if (ncopies > 4) { - *(d+3) = *(s+3); - *(d+4) = *(s+4); - if (ncopies > 6) { - *(d+5) = *(s+5); - *(d+6) = *(s+6); - if (ncopies > 8) { - *(d+7) = *(s+7); - *(d+8) = *(s+8); - } - } - } - } - - fREe(oldmem); - check_inuse_chunk(newp); - return chunk2mem(newp); - } - } - } - - /* If possible, free extra space in old or extended chunk */ - - assert((unsigned long)(newsize) >= (unsigned long)(nb)); - - remainder_size = newsize - nb; - - if (remainder_size < MINSIZE) { /* not enough extra to split off */ - set_head_size(newp, newsize); - set_inuse_bit_at_offset(newp, newsize); - } - else { /* split remainder */ - remainder = chunk_at_offset(newp, nb); - set_head_size(newp, nb); - set_head(remainder, remainder_size | PREV_INUSE); - /* Mark remainder as inuse so free() won't complain */ - set_inuse_bit_at_offset(remainder, remainder_size); - fREe(chunk2mem(remainder)); - } - - check_inuse_chunk(newp); - return chunk2mem(newp); - } - - /* - Handle mmap cases - */ - - else { -#if HAVE_MMAP - -#if HAVE_MREMAP - INTERNAL_SIZE_T offset = oldp->prev_size; - size_t pagemask = av->pagesize - 1; - char *cp; - unsigned long sum; - - /* Note the extra SIZE_SZ overhead */ - newsize = (nb + offset + SIZE_SZ + pagemask) & ~pagemask; - - /* don't need to remap if still within same page */ - if (oldsize == newsize - offset) - return oldmem; - - cp = (char*)mremap((char*)oldp - offset, oldsize + offset, newsize, 1); - - if (cp != (char*)MORECORE_FAILURE) { - - newp = (mchunkptr)(cp + offset); - set_head(newp, (newsize - offset)|IS_MMAPPED); - - assert(aligned_OK(chunk2mem(newp))); - assert((newp->prev_size == offset)); - - /* update statistics */ - sum = av->mmapped_mem += newsize - oldsize; - if (sum > (unsigned long)(av->max_mmapped_mem)) - av->max_mmapped_mem = sum; - sum += av->sbrked_mem; - if (sum > (unsigned long)(av->max_total_mem)) - av->max_total_mem = sum; - - return chunk2mem(newp); - } -#endif - - /* Note the extra SIZE_SZ overhead. */ - if ((unsigned long)(oldsize) >= (unsigned long)(nb + SIZE_SZ)) - newmem = oldmem; /* do nothing */ - else { - /* Must alloc, copy, free. */ - newmem = mALLOc(nb - MALLOC_ALIGN_MASK); - if (newmem != 0) { - MALLOC_COPY(newmem, oldmem, oldsize - 2*SIZE_SZ); - fREe(oldmem); - } - } - return newmem; - -#else - /* If !HAVE_MMAP, but chunk_is_mmapped, user must have overwritten mem */ - check_malloc_state(); - MALLOC_FAILURE_ACTION; - return 0; -#endif - } -} - -/* - ------------------------------ memalign ------------------------------ -*/ - -INLINE -#if __STD_C -Void_t* mEMALIGn(size_t tqalignment, size_t bytes) -#else -Void_t* mEMALIGn(tqalignment, bytes) size_t tqalignment; size_t bytes; -#endif -{ - INTERNAL_SIZE_T nb; /* padded request size */ - char* m; /* memory returned by malloc call */ - mchunkptr p; /* corresponding chunk */ - char* brk; /* tqalignment point within p */ - mchunkptr newp; /* chunk to return */ - INTERNAL_SIZE_T newsize; /* its size */ - INTERNAL_SIZE_T leadsize; /* leading space before tqalignment point */ - mchunkptr remainder; /* spare room at end to split off */ - unsigned long remainder_size; /* its size */ - INTERNAL_SIZE_T size; - - /* If need less tqalignment than we give anyway, just relay to malloc */ - - if (tqalignment <= MALLOC_ALIGNMENT) return mALLOc(bytes); - - /* Otherwise, ensure that it is at least a minimum chunk size */ - - if (tqalignment < MINSIZE) tqalignment = MINSIZE; - - /* Make sure tqalignment is power of 2 (in case MINSIZE is not). */ - if ((tqalignment & (tqalignment - 1)) != 0) { - size_t a = MALLOC_ALIGNMENT * 2; - while ((unsigned long)a < (unsigned long)tqalignment) a <<= 1; - tqalignment = a; - } - - checked_request2size(bytes, nb); - - /* - Strategy: find a spot within that chunk that meets the tqalignment - request, and then possibly free the leading and trailing space. - */ - - - /* Call malloc with worst case padding to hit tqalignment. */ - - m = (char*)(mALLOc(nb + tqalignment + MINSIZE)); - - if (m == 0) return 0; /* propagate failure */ - - p = mem2chunk(m); - - if ((((unsigned long)(m)) % tqalignment) != 0) { /* misaligned */ - - /* - Find an aligned spot inside chunk. Since we need to give back - leading space in a chunk of at least MINSIZE, if the first - calculation places us at a spot with less than MINSIZE leader, - we can move to the next aligned spot -- we've allocated enough - total room so that this is always possible. - */ - - brk = (char*)mem2chunk(((unsigned long)(m + tqalignment - 1)) & - -((signed long) tqalignment)); - if ((unsigned long)(brk - (char*)(p)) < MINSIZE) - brk += tqalignment; - - newp = (mchunkptr)brk; - leadsize = brk - (char*)(p); - newsize = chunksize(p) - leadsize; - - /* For mmapped chunks, just adjust offset */ - if (chunk_is_mmapped(p)) { - newp->prev_size = p->prev_size + leadsize; - set_head(newp, newsize|IS_MMAPPED); - return chunk2mem(newp); - } - - /* Otherwise, give back leader, use the rest */ - set_head(newp, newsize | PREV_INUSE); - set_inuse_bit_at_offset(newp, newsize); - set_head_size(p, leadsize); - fREe(chunk2mem(p)); - p = newp; - - assert (newsize >= nb && - (((unsigned long)(chunk2mem(p))) % tqalignment) == 0); - } - - /* Also give back spare room at the end */ - if (!chunk_is_mmapped(p)) { - size = chunksize(p); - if ((unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { - remainder_size = size - nb; - remainder = chunk_at_offset(p, nb); - set_head(remainder, remainder_size | PREV_INUSE); - set_head_size(p, nb); - fREe(chunk2mem(remainder)); - } - } - - check_inuse_chunk(p); - return chunk2mem(p); -} - -/* - ------------------------------ calloc ------------------------------ -*/ - -INLINE -#if __STD_C -Void_t* cALLOc(size_t n_elements, size_t elem_size) -#else -Void_t* cALLOc(n_elements, elem_size) size_t n_elements; size_t elem_size; -#endif -{ - mchunkptr p; - unsigned long clearsize; - unsigned long nclears; - INTERNAL_SIZE_T* d; - - Void_t* mem = mALLOc(n_elements * elem_size); - - /* hack */ - kde_malloc_is_used = 1; - - if (mem != 0) { - p = mem2chunk(mem); - - if (!chunk_is_mmapped(p)) - { - /* - Unroll clear of <= 36 bytes (72 if 8byte sizes) - We know that contents have an odd number of - INTERNAL_SIZE_T-sized words; minimally 3. - */ - - d = (INTERNAL_SIZE_T*)mem; - clearsize = chunksize(p) - SIZE_SZ; - nclears = clearsize / sizeof(INTERNAL_SIZE_T); - assert(nclears >= 3); - - if (nclears > 9) - MALLOC_ZERO(d, clearsize); - - else { - *(d+0) = 0; - *(d+1) = 0; - *(d+2) = 0; - if (nclears > 4) { - *(d+3) = 0; - *(d+4) = 0; - if (nclears > 6) { - *(d+5) = 0; - *(d+6) = 0; - if (nclears > 8) { - *(d+7) = 0; - *(d+8) = 0; - } - } - } - } - } -#if ! MMAP_CLEARS - else - { - d = (INTERNAL_SIZE_T*)mem; - clearsize = chunksize(p) - 2 * SIZE_SZ; - MALLOC_ZERO(d, clearsize); - } -#endif - } - return mem; -} - -/* - ------------------------------ cfree ------------------------------ -*/ - -INLINE -#if __STD_C -void cFREe(Void_t *mem) -#else -void cFREe(mem) Void_t *mem; -#endif -{ - fREe(mem); -} - -/* - ------------------------------ ialloc ------------------------------ - ialloc provides common support for independent_X routines, handling all of - the combinations that can result. - - The opts arg has: - bit 0 set if all elements are same size (using sizes[0]) - bit 1 set if elements should be zeroed -*/ - - -INLINE -#if __STD_C -static Void_t** iALLOc(size_t n_elements, - size_t* sizes, - int opts, - Void_t* chunks[]) -#else -static Void_t** iALLOc(n_elements, sizes, opts, chunks) size_t n_elements; size_t* sizes; int opts; Void_t* chunks[]; -#endif -{ - mstate av = get_malloc_state(); - INTERNAL_SIZE_T element_size; /* chunksize of each element, if all same */ - INTERNAL_SIZE_T contents_size; /* total size of elements */ - INTERNAL_SIZE_T array_size; /* request size of pointer array */ - Void_t* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - INTERNAL_SIZE_T remainder_size; /* remaining bytes while splitting */ - Void_t** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - int mmx; /* to disable mmap */ - INTERNAL_SIZE_T size; - size_t i; - - /* Ensure initialization/consolidation */ - if (have_fastchunks(av)) malloc_consolidate(av); - - /* compute array length, if needed */ - if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ - marray = chunks; - array_size = 0; - } - else { - /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (Void_t**) mALLOc(0); - marray = 0; - array_size = request2size(n_elements * (sizeof(Void_t*))); - } - - /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ - element_size = request2size(*sizes); - contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ - element_size = 0; - contents_size = 0; - for (i = 0; i != n_elements; ++i) - contents_size += request2size(sizes[i]); - } - - /* subtract out tqalignment bytes from total to minimize overallocation */ - size = contents_size + array_size - MALLOC_ALIGN_MASK; - - /* - Allocate the aggregate chunk. - But first disable mmap so malloc won't use it, since - we would not be able to later free/realloc space internal - to a segregated mmap region. - */ - mmx = av->n_mmaps_max; /* disable mmap */ - av->n_mmaps_max = 0; - mem = mALLOc(size); - av->n_mmaps_max = mmx; /* reset mmap */ - if (mem == 0) - return 0; - - p = mem2chunk(mem); - assert(!chunk_is_mmapped(p)); - remainder_size = chunksize(p); - - if (opts & 0x2) { /* optionally clear the elements */ - MALLOC_ZERO(mem, remainder_size - SIZE_SZ - array_size); - } - - /* If not provided, allocate the pointer array as final part of chunk */ - if (marray == 0) { - array_chunk = chunk_at_offset(p, contents_size); - marray = (Void_t**) (chunk2mem(array_chunk)); - set_head(array_chunk, (remainder_size - contents_size) | PREV_INUSE); - remainder_size = contents_size; - } - - /* split out elements */ - for (i = 0; ; ++i) { - marray[i] = chunk2mem(p); - if (i != n_elements-1) { - if (element_size != 0) - size = element_size; - else - size = request2size(sizes[i]); - remainder_size -= size; - set_head(p, size | PREV_INUSE); - p = chunk_at_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ - set_head(p, remainder_size | PREV_INUSE); - break; - } - } - -#ifdef DEBUG - if (marray != chunks) { - /* final element must have exactly exhausted chunk */ - if (element_size != 0) - assert(remainder_size == element_size); - else - assert(remainder_size == request2size(sizes[i])); - check_inuse_chunk(mem2chunk(marray)); - } - - for (i = 0; i != n_elements; ++i) - check_inuse_chunk(mem2chunk(marray[i])); -#endif - - return marray; -} - - -/* - ------------------------- independent_calloc ------------------------- -*/ - -INLINE -#if __STD_C -Void_t** iCALLOc(size_t n_elements, size_t elem_size, Void_t* chunks[]) -#else -Void_t** iCALLOc(n_elements, elem_size, chunks) size_t n_elements; size_t elem_size; Void_t* chunks[]; -#endif -{ - size_t sz = elem_size; /* serves as 1-element array */ - /* opts arg of 3 means all elements are same size, and should be cleared */ - return iALLOc(n_elements, &sz, 3, chunks); -} - -/* - ------------------------- independent_comalloc ------------------------- -*/ - -INLINE -#if __STD_C -Void_t** iCOMALLOc(size_t n_elements, size_t sizes[], Void_t* chunks[]) -#else -Void_t** iCOMALLOc(n_elements, sizes, chunks) size_t n_elements; size_t sizes[]; Void_t* chunks[]; -#endif -{ - return iALLOc(n_elements, sizes, 0, chunks); -} - - -/* - ------------------------------ valloc ------------------------------ -*/ - -INLINE -#if __STD_C -Void_t* vALLOc(size_t bytes) -#else -Void_t* vALLOc(bytes) size_t bytes; -#endif -{ - /* Ensure initialization/consolidation */ - mstate av = get_malloc_state(); - if (have_fastchunks(av)) malloc_consolidate(av); - return mEMALIGn(av->pagesize, bytes); -} - -/* - ------------------------------ pvalloc ------------------------------ -*/ - - -#if __STD_C -Void_t* pVALLOc(size_t bytes) -#else -Void_t* pVALLOc(bytes) size_t bytes; -#endif -{ - mstate av = get_malloc_state(); - size_t pagesz; - - /* Ensure initialization/consolidation */ - if (have_fastchunks(av)) malloc_consolidate(av); - pagesz = av->pagesize; - return mEMALIGn(pagesz, (bytes + pagesz - 1) & ~(pagesz - 1)); -} - - -/* - ------------------------------ malloc_trim ------------------------------ -*/ - -INLINE -#if __STD_C -int mTRIm(size_t pad) -#else -int mTRIm(pad) size_t pad; -#endif -{ - mstate av = get_malloc_state(); - /* Ensure initialization/consolidation */ - malloc_consolidate(av); - -#ifndef MORECORE_CANNOT_TRIM - return sYSTRIm(pad, av); -#else - return 0; -#endif -} - - -/* - ------------------------- malloc_usable_size ------------------------- -*/ - -INLINE -#if __STD_C -size_t mUSABLe(Void_t* mem) -#else -size_t mUSABLe(mem) Void_t* mem; -#endif -{ - mchunkptr p; - if (mem != 0) { - p = mem2chunk(mem); - if (chunk_is_mmapped(p)) - return chunksize(p) - 2*SIZE_SZ; - else if (inuse(p)) - return chunksize(p) - SIZE_SZ; - } - return 0; -} - -/* - ------------------------------ mallinfo ------------------------------ -*/ - -struct mallinfo mALLINFo() -{ - mstate av = get_malloc_state(); - struct mallinfo mi; - unsigned int i; - mbinptr b; - mchunkptr p; - INTERNAL_SIZE_T avail; - INTERNAL_SIZE_T fastavail; - int nblocks; - int nfastblocks; - - /* Ensure initialization */ - if (av->top == 0) malloc_consolidate(av); - - check_malloc_state(); - - /* Account for top */ - avail = chunksize(av->top); - nblocks = 1; /* top always exists */ - - /* traverse fastbins */ - nfastblocks = 0; - fastavail = 0; - - for (i = 0; i < NFASTBINS; ++i) { - for (p = av->fastbins[i]; p != 0; p = p->fd) { - ++nfastblocks; - fastavail += chunksize(p); - } - } - - avail += fastavail; - - /* traverse regular bins */ - for (i = 1; i < NBINS; ++i) { - b = bin_at(av, i); - for (p = last(b); p != b; p = p->bk) { - ++nblocks; - avail += chunksize(p); - } - } - - mi.smblks = nfastblocks; - mi.ordblks = nblocks; - mi.fordblks = avail; - mi.uordblks = av->sbrked_mem - avail; - mi.arena = av->sbrked_mem; - mi.hblks = av->n_mmaps; - mi.hblkhd = av->mmapped_mem; - mi.fsmblks = fastavail; - mi.keepcost = chunksize(av->top); - mi.usmblks = av->max_total_mem; - return mi; -} - -/* - ------------------------------ malloc_stats ------------------------------ -*/ - -void mSTATs() -{ - struct mallinfo mi = mALLINFo(); - -#ifdef WIN32 - { - unsigned long free, reserved, committed; - vminfo (&free, &reserved, &committed); - fprintf(stderr, "free bytes = %10lu\n", - free); - fprintf(stderr, "reserved bytes = %10lu\n", - reserved); - fprintf(stderr, "committed bytes = %10lu\n", - committed); - } -#endif - - - fprintf(stderr, "max system bytes = %10lu\n", - (unsigned long)(mi.usmblks)); - fprintf(stderr, "system bytes = %10lu\n", - (unsigned long)(mi.arena + mi.hblkhd)); - fprintf(stderr, "in use bytes = %10lu\n", - (unsigned long)(mi.uordblks + mi.hblkhd)); - - -#ifdef WIN32 - { - unsigned long kernel, user; - if (cpuinfo (TRUE, &kernel, &user)) { - fprintf(stderr, "kernel ms = %10lu\n", - kernel); - fprintf(stderr, "user ms = %10lu\n", - user); - } - } -#endif -} - - -/* - ------------------------------ mallopt ------------------------------ -*/ - -INLINE -#if __STD_C -int mALLOPt(int param_number, int value) -#else -int mALLOPt(param_number, value) int param_number; int value; -#endif -{ - mstate av = get_malloc_state(); - /* Ensure initialization/consolidation */ - malloc_consolidate(av); - - switch(param_number) { - case M_MXFAST: - if (value >= 0 && value <= MAX_FAST_SIZE) { - set_max_fast(av, value); - return 1; - } - else - return 0; - - case M_TRIM_THRESHOLD: - av->trim_threshold = value; - return 1; - - case M_TOP_PAD: - av->top_pad = value; - return 1; - - case M_MMAP_THRESHOLD: - av->mmap_threshold = value; - return 1; - - case M_MMAP_MAX: -#if !HAVE_MMAP - if (value != 0) - return 0; -#endif - av->n_mmaps_max = value; - return 1; - - default: - return 0; - } -} - - -/* - -------------------- Alternative MORECORE functions -------------------- -*/ - - -/* - General Requirements for MORECORE. - - The MORECORE function must have the following properties: - - If MORECORE_CONTIGUOUS is false: - - * MORECORE must allocate in multiples of pagesize. It will - only be called with arguments that are multiples of pagesize. - - * MORECORE(0) must return an address that is at least - MALLOC_ALIGNMENT aligned. (Page-aligning always suffices.) - - else (i.e. If MORECORE_CONTIGUOUS is true): - - * Consecutive calls to MORECORE with positive arguments - return increasing addresses, indicating that space has been - contiguously extended. - - * MORECORE need not allocate in multiples of pagesize. - Calls to MORECORE need not have args of multiples of pagesize. - - * MORECORE need not page-align. - - In either case: - - * MORECORE may allocate more memory than requested. (Or even less, - but this will generally result in a malloc failure.) - - * MORECORE must not allocate memory when given argument zero, but - instead return one past the end address of memory from previous - nonzero call. This malloc does NOT call MORECORE(0) - until at least one call with positive arguments is made, so - the initial value returned is not important. - - * Even though consecutive calls to MORECORE need not return contiguous - addresses, it must be OK for malloc'ed chunks to span multiple - regions in those cases where they do happen to be contiguous. - - * MORECORE need not handle negative arguments -- it may instead - just return MORECORE_FAILURE when given negative arguments. - Negative arguments are always multiples of pagesize. MORECORE - must not misinterpret negative args as large positive unsigned - args. You can suppress all such calls from even occurring by defining - MORECORE_CANNOT_TRIM, - - There is some variation across systems about the type of the - argument to sbrk/MORECORE. If size_t is unsigned, then it cannot - actually be size_t, because sbrk supports negative args, so it is - normally the signed type of the same width as size_t (sometimes - declared as "intptr_t", and sometimes "ptrdiff_t"). It doesn't much - matter though. Internally, we use "long" as arguments, which should - work across all reasonable possibilities. - - Additionally, if MORECORE ever returns failure for a positive - request, and HAVE_MMAP is true, then mmap is used as a noncontiguous - system allocator. This is a useful backup strategy for systems with - holes in address spaces -- in this case sbrk cannot contiguously - expand the heap, but mmap may be able to map noncontiguous space. - - If you'd like mmap to ALWAYS be used, you can define MORECORE to be - a function that always returns MORECORE_FAILURE. - - If you are using this malloc with something other than sbrk (or its - emulation) to supply memory regions, you probably want to set - MORECORE_CONTIGUOUS as false. As an example, here is a custom - allocator kindly contributed for pre-OSX macOS. It uses virtually - but not necessarily physically contiguous non-paged memory (locked - in, present and won't get swapped out). You can use it by - uncommenting this section, adding some #includes, and setting up the - appropriate defines above: - - #define MORECORE osMoreCore - #define MORECORE_CONTIGUOUS 0 - - There is also a shutdown routine that should somehow be called for - cleanup upon program exit. - - #define MAX_POOL_ENTRIES 100 - #define MINIMUM_MORECORE_SIZE (64 * 1024) - static int next_os_pool; - void *our_os_pools[MAX_POOL_ENTRIES]; - - void *osMoreCore(int size) - { - void *ptr = 0; - static void *sbrk_top = 0; - - if (size > 0) - { - if (size < MINIMUM_MORECORE_SIZE) - size = MINIMUM_MORECORE_SIZE; - if (CurrentExecutionLevel() == kTaskLevel) - ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); - if (ptr == 0) - { - return (void *) MORECORE_FAILURE; - } - // save ptrs so they can be freed during cleanup - our_os_pools[next_os_pool] = ptr; - next_os_pool++; - ptr = (void *) ((((unsigned long) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); - sbrk_top = (char *) ptr + size; - return ptr; - } - else if (size < 0) - { - // we don't currently support shrink behavior - return (void *) MORECORE_FAILURE; - } - else - { - return sbrk_top; - } - } - - // cleanup any allocated memory pools - // called as last thing before shutting down driver - - void osCleanupMem(void) - { - void **ptr; - - for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) - if (*ptr) - { - PoolDeallocate(*ptr); - *ptr = 0; - } - } - -*/ - - -/* - -------------------------------------------------------------- - - Emulation of sbrk for win32. - Donated by J. Walter <Walter@GeNeSys-e.de>. - For additional information about this code, and malloc on Win32, see - http://www.genesys-e.de/jwalter/ -*/ - - -#ifdef WIN32 - -#ifdef _DEBUG -/* #define TRACE */ -#endif - -/* Support for USE_MALLOC_LOCK */ -#ifdef USE_MALLOC_LOCK - -/* Wait for spin lock */ -static int slwait (int *sl) { - while (InterlockedCompareExchange ((void **) sl, (void *) 1, (void *) 0) != 0) - Sleep (0); - return 0; -} - -/* Release spin lock */ -static int slrelease (int *sl) { - InterlockedExchange (sl, 0); - return 0; -} - -#ifdef NEEDED -/* Spin lock for emulation code */ -static int g_sl; -#endif - -#endif /* USE_MALLOC_LOCK */ - -/* getpagesize for windows */ -static long getpagesize (void) { - static long g_pagesize = 0; - if (! g_pagesize) { - SYSTEM_INFO system_info; - GetSystemInfo (&system_info); - g_pagesize = system_info.dwPageSize; - } - return g_pagesize; -} -static long getregionsize (void) { - static long g_regionsize = 0; - if (! g_regionsize) { - SYSTEM_INFO system_info; - GetSystemInfo (&system_info); - g_regionsize = system_info.dwAllocationGranularity; - } - return g_regionsize; -} - -/* A region list entry */ -typedef struct _region_list_entry { - void *top_allocated; - void *top_committed; - void *top_reserved; - long reserve_size; - struct _region_list_entry *previous; -} region_list_entry; - -/* Allocate and link a region entry in the region list */ -static int region_list_append (region_list_entry **last, void *base_reserved, long reserve_size) { - region_list_entry *next = HeapAlloc (GetProcessHeap (), 0, sizeof (region_list_entry)); - if (! next) - return FALSE; - next->top_allocated = (char *) base_reserved; - next->top_committed = (char *) base_reserved; - next->top_reserved = (char *) base_reserved + reserve_size; - next->reserve_size = reserve_size; - next->previous = *last; - *last = next; - return TRUE; -} -/* Free and unlink the last region entry from the region list */ -static int region_list_remove (region_list_entry **last) { - region_list_entry *previous = (*last)->previous; - if (! HeapFree (GetProcessHeap (), sizeof (region_list_entry), *last)) - return FALSE; - *last = previous; - return TRUE; -} - -#define CEIL(size,to) (((size)+(to)-1)&~((to)-1)) -#define FLOOR(size,to) ((size)&~((to)-1)) - -#define SBRK_SCALE 0 -/* #define SBRK_SCALE 1 */ -/* #define SBRK_SCALE 2 */ -/* #define SBRK_SCALE 4 */ - -/* sbrk for windows */ -static void *sbrk (long size) { - static long g_pagesize, g_my_pagesize; - static long g_regionsize, g_my_regionsize; - static region_list_entry *g_last; - void *result = (void *) MORECORE_FAILURE; -#ifdef TRACE - printf ("sbrk %d\n", size); -#endif -#if defined (USE_MALLOC_LOCK) && defined (NEEDED) - /* Wait for spin lock */ - slwait (&g_sl); -#endif - /* First time initialization */ - if (! g_pagesize) { - g_pagesize = getpagesize (); - g_my_pagesize = g_pagesize << SBRK_SCALE; - } - if (! g_regionsize) { - g_regionsize = getregionsize (); - g_my_regionsize = g_regionsize << SBRK_SCALE; - } - if (! g_last) { - if (! region_list_append (&g_last, 0, 0)) - goto sbrk_exit; - } - /* Assert invariants */ - assert (g_last); - assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_allocated && - g_last->top_allocated <= g_last->top_committed); - assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_committed && - g_last->top_committed <= g_last->top_reserved && - (unsigned) g_last->top_committed % g_pagesize == 0); - assert ((unsigned) g_last->top_reserved % g_regionsize == 0); - assert ((unsigned) g_last->reserve_size % g_regionsize == 0); - /* Allocation requested? */ - if (size >= 0) { - /* Allocation size is the requested size */ - long allocate_size = size; - /* Compute the size to commit */ - long to_commit = (char *) g_last->top_allocated + allocate_size - (char *) g_last->top_committed; - /* Do we reach the commit limit? */ - if (to_commit > 0) { - /* Round size to commit */ - long commit_size = CEIL (to_commit, g_my_pagesize); - /* Compute the size to reserve */ - long to_reserve = (char *) g_last->top_committed + commit_size - (char *) g_last->top_reserved; - /* Do we reach the reserve limit? */ - if (to_reserve > 0) { - /* Compute the remaining size to commit in the current region */ - long remaining_commit_size = (char *) g_last->top_reserved - (char *) g_last->top_committed; - if (remaining_commit_size > 0) { - /* Assert preconditions */ - assert ((unsigned) g_last->top_committed % g_pagesize == 0); - assert (0 < remaining_commit_size && remaining_commit_size % g_pagesize == 0); { - /* Commit this */ - void *base_committed = VirtualAlloc (g_last->top_committed, remaining_commit_size, - MEM_COMMIT, PAGE_READWRITE); - /* Check returned pointer for consistency */ - if (base_committed != g_last->top_committed) - goto sbrk_exit; - /* Assert postconditions */ - assert ((unsigned) base_committed % g_pagesize == 0); -#ifdef TRACE - printf ("Commit %p %d\n", base_committed, remaining_commit_size); -#endif - /* Adjust the regions commit top */ - g_last->top_committed = (char *) base_committed + remaining_commit_size; - } - } { - /* Now we are going to search and reserve. */ - int contiguous = -1; - int found = FALSE; - MEMORY_BASIC_INFORMATION memory_info; - void *base_reserved; - long reserve_size; - do { - /* Assume contiguous memory */ - contiguous = TRUE; - /* Round size to reserve */ - reserve_size = CEIL (to_reserve, g_my_regionsize); - /* Start with the current region's top */ - memory_info.BaseAddress = g_last->top_reserved; - /* Assert preconditions */ - assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0); - assert (0 < reserve_size && reserve_size % g_regionsize == 0); - while (VirtualQuery (memory_info.BaseAddress, &memory_info, sizeof (memory_info))) { - /* Assert postconditions */ - assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0); -#ifdef TRACE - printf ("Query %p %d %s\n", memory_info.BaseAddress, memory_info.RegionSize, - memory_info.State == MEM_FREE ? "FREE": - (memory_info.State == MEM_RESERVE ? "RESERVED": - (memory_info.State == MEM_COMMIT ? "COMMITTED": "?"))); -#endif - /* Region is free, well aligned and big enough: we are done */ - if (memory_info.State == MEM_FREE && - (unsigned) memory_info.BaseAddress % g_regionsize == 0 && - memory_info.RegionSize >= (unsigned) reserve_size) { - found = TRUE; - break; - } - /* From now on we can't get contiguous memory! */ - contiguous = FALSE; - /* Recompute size to reserve */ - reserve_size = CEIL (allocate_size, g_my_regionsize); - memory_info.BaseAddress = (char *) memory_info.BaseAddress + memory_info.RegionSize; - /* Assert preconditions */ - assert ((unsigned) memory_info.BaseAddress % g_pagesize == 0); - assert (0 < reserve_size && reserve_size % g_regionsize == 0); - } - /* Search failed? */ - if (! found) - goto sbrk_exit; - /* Assert preconditions */ - assert ((unsigned) memory_info.BaseAddress % g_regionsize == 0); - assert (0 < reserve_size && reserve_size % g_regionsize == 0); - /* Try to reserve this */ - base_reserved = VirtualAlloc (memory_info.BaseAddress, reserve_size, - MEM_RESERVE, PAGE_NOACCESS); - if (! base_reserved) { - int rc = GetLastError (); - if (rc != ERROR_INVALID_ADDRESS) - goto sbrk_exit; - } - /* A null pointer signals (hopefully) a race condition with another thread. */ - /* In this case, we try again. */ - } while (! base_reserved); - /* Check returned pointer for consistency */ - if (memory_info.BaseAddress && base_reserved != memory_info.BaseAddress) - goto sbrk_exit; - /* Assert postconditions */ - assert ((unsigned) base_reserved % g_regionsize == 0); -#ifdef TRACE - printf ("Reserve %p %d\n", base_reserved, reserve_size); -#endif - /* Did we get contiguous memory? */ - if (contiguous) { - long start_size = (char *) g_last->top_committed - (char *) g_last->top_allocated; - /* Adjust allocation size */ - allocate_size -= start_size; - /* Adjust the regions allocation top */ - g_last->top_allocated = g_last->top_committed; - /* Recompute the size to commit */ - to_commit = (char *) g_last->top_allocated + allocate_size - (char *) g_last->top_committed; - /* Round size to commit */ - commit_size = CEIL (to_commit, g_my_pagesize); - } - /* Append the new region to the list */ - if (! region_list_append (&g_last, base_reserved, reserve_size)) - goto sbrk_exit; - /* Didn't we get contiguous memory? */ - if (! contiguous) { - /* Recompute the size to commit */ - to_commit = (char *) g_last->top_allocated + allocate_size - (char *) g_last->top_committed; - /* Round size to commit */ - commit_size = CEIL (to_commit, g_my_pagesize); - } - } - } - /* Assert preconditions */ - assert ((unsigned) g_last->top_committed % g_pagesize == 0); - assert (0 < commit_size && commit_size % g_pagesize == 0); { - /* Commit this */ - void *base_committed = VirtualAlloc (g_last->top_committed, commit_size, - MEM_COMMIT, PAGE_READWRITE); - /* Check returned pointer for consistency */ - if (base_committed != g_last->top_committed) - goto sbrk_exit; - /* Assert postconditions */ - assert ((unsigned) base_committed % g_pagesize == 0); -#ifdef TRACE - printf ("Commit %p %d\n", base_committed, commit_size); -#endif - /* Adjust the regions commit top */ - g_last->top_committed = (char *) base_committed + commit_size; - } - } - /* Adjust the regions allocation top */ - g_last->top_allocated = (char *) g_last->top_allocated + allocate_size; - result = (char *) g_last->top_allocated - size; - /* Deallocation requested? */ - } else if (size < 0) { - long deallocate_size = - size; - /* As long as we have a region to release */ - while ((char *) g_last->top_allocated - deallocate_size < (char *) g_last->top_reserved - g_last->reserve_size) { - /* Get the size to release */ - long release_size = g_last->reserve_size; - /* Get the base address */ - void *base_reserved = (char *) g_last->top_reserved - release_size; - /* Assert preconditions */ - assert ((unsigned) base_reserved % g_regionsize == 0); - assert (0 < release_size && release_size % g_regionsize == 0); { - /* Release this */ - int rc = VirtualFree (base_reserved, 0, - MEM_RELEASE); - /* Check returned code for consistency */ - if (! rc) - goto sbrk_exit; -#ifdef TRACE - printf ("Release %p %d\n", base_reserved, release_size); -#endif - } - /* Adjust deallocation size */ - deallocate_size -= (char *) g_last->top_allocated - (char *) base_reserved; - /* Remove the old region from the list */ - if (! region_list_remove (&g_last)) - goto sbrk_exit; - } { - /* Compute the size to decommit */ - long to_decommit = (char *) g_last->top_committed - ((char *) g_last->top_allocated - deallocate_size); - if (to_decommit >= g_my_pagesize) { - /* Compute the size to decommit */ - long decommit_size = FLOOR (to_decommit, g_my_pagesize); - /* Compute the base address */ - void *base_committed = (char *) g_last->top_committed - decommit_size; - /* Assert preconditions */ - assert ((unsigned) base_committed % g_pagesize == 0); - assert (0 < decommit_size && decommit_size % g_pagesize == 0); { - /* Decommit this */ - int rc = VirtualFree ((char *) base_committed, decommit_size, - MEM_DECOMMIT); - /* Check returned code for consistency */ - if (! rc) - goto sbrk_exit; -#ifdef TRACE - printf ("Decommit %p %d\n", base_committed, decommit_size); -#endif - } - /* Adjust deallocation size and regions commit and allocate top */ - deallocate_size -= (char *) g_last->top_allocated - (char *) base_committed; - g_last->top_committed = base_committed; - g_last->top_allocated = base_committed; - } - } - /* Adjust regions allocate top */ - g_last->top_allocated = (char *) g_last->top_allocated - deallocate_size; - /* Check for underflow */ - if ((char *) g_last->top_reserved - g_last->reserve_size > (char *) g_last->top_allocated || - g_last->top_allocated > g_last->top_committed) { - /* Adjust regions allocate top */ - g_last->top_allocated = (char *) g_last->top_reserved - g_last->reserve_size; - goto sbrk_exit; - } - result = g_last->top_allocated; - } - /* Assert invariants */ - assert (g_last); - assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_allocated && - g_last->top_allocated <= g_last->top_committed); - assert ((char *) g_last->top_reserved - g_last->reserve_size <= (char *) g_last->top_committed && - g_last->top_committed <= g_last->top_reserved && - (unsigned) g_last->top_committed % g_pagesize == 0); - assert ((unsigned) g_last->top_reserved % g_regionsize == 0); - assert ((unsigned) g_last->reserve_size % g_regionsize == 0); - -sbrk_exit: -#if defined (USE_MALLOC_LOCK) && defined (NEEDED) - /* Release spin lock */ - slrelease (&g_sl); -#endif - return result; -} - -/* mmap for windows */ -static void *mmap (void *ptr, long size, long prot, long type, long handle, long arg) { - static long g_pagesize; - static long g_regionsize; -#ifdef TRACE - printf ("mmap %d\n", size); -#endif -#if defined (USE_MALLOC_LOCK) && defined (NEEDED) - /* Wait for spin lock */ - slwait (&g_sl); -#endif - /* First time initialization */ - if (! g_pagesize) - g_pagesize = getpagesize (); - if (! g_regionsize) - g_regionsize = getregionsize (); - /* Assert preconditions */ - assert ((unsigned) ptr % g_regionsize == 0); - assert (size % g_pagesize == 0); - /* Allocate this */ - ptr = VirtualAlloc (ptr, size, - MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE); - if (! ptr) { - ptr = (void *) MORECORE_FAILURE; - goto mmap_exit; - } - /* Assert postconditions */ - assert ((unsigned) ptr % g_regionsize == 0); -#ifdef TRACE - printf ("Commit %p %d\n", ptr, size); -#endif -mmap_exit: -#if defined (USE_MALLOC_LOCK) && defined (NEEDED) - /* Release spin lock */ - slrelease (&g_sl); -#endif - return ptr; -} - -/* munmap for windows */ -static long munmap (void *ptr, long size) { - static long g_pagesize; - static long g_regionsize; - int rc = MUNMAP_FAILURE; -#ifdef TRACE - printf ("munmap %p %d\n", ptr, size); -#endif -#if defined (USE_MALLOC_LOCK) && defined (NEEDED) - /* Wait for spin lock */ - slwait (&g_sl); -#endif - /* First time initialization */ - if (! g_pagesize) - g_pagesize = getpagesize (); - if (! g_regionsize) - g_regionsize = getregionsize (); - /* Assert preconditions */ - assert ((unsigned) ptr % g_regionsize == 0); - assert (size % g_pagesize == 0); - /* Free this */ - if (! VirtualFree (ptr, 0, - MEM_RELEASE)) - goto munmap_exit; - rc = 0; -#ifdef TRACE - printf ("Release %p %d\n", ptr, size); -#endif -munmap_exit: -#if defined (USE_MALLOC_LOCK) && defined (NEEDED) - /* Release spin lock */ - slrelease (&g_sl); -#endif - return rc; -} - -static void vminfo (unsigned long *free, unsigned long *reserved, unsigned long *committed) { - MEMORY_BASIC_INFORMATION memory_info; - memory_info.BaseAddress = 0; - *free = *reserved = *committed = 0; - while (VirtualQuery (memory_info.BaseAddress, &memory_info, sizeof (memory_info))) { - switch (memory_info.State) { - case MEM_FREE: - *free += memory_info.RegionSize; - break; - case MEM_RESERVE: - *reserved += memory_info.RegionSize; - break; - case MEM_COMMIT: - *committed += memory_info.RegionSize; - break; - } - memory_info.BaseAddress = (char *) memory_info.BaseAddress + memory_info.RegionSize; - } -} - -static int cpuinfo (int whole, unsigned long *kernel, unsigned long *user) { - if (whole) { - __int64 creation64, exit64, kernel64, user64; - int rc = GetProcessTimes (GetCurrentProcess (), - (FILETIME *) &creation64, - (FILETIME *) &exit64, - (FILETIME *) &kernel64, - (FILETIME *) &user64); - if (! rc) { - *kernel = 0; - *user = 0; - return FALSE; - } - *kernel = (unsigned long) (kernel64 / 10000); - *user = (unsigned long) (user64 / 10000); - return TRUE; - } else { - __int64 creation64, exit64, kernel64, user64; - int rc = GetThreadTimes (GetCurrentThread (), - (FILETIME *) &creation64, - (FILETIME *) &exit64, - (FILETIME *) &kernel64, - (FILETIME *) &user64); - if (! rc) { - *kernel = 0; - *user = 0; - return FALSE; - } - *kernel = (unsigned long) (kernel64 / 10000); - *user = (unsigned long) (user64 / 10000); - return TRUE; - } -} - -#endif /* WIN32 */ - -/* ------------------------------------------------------------ -History: - - V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) - * Introduce independent_comalloc and independent_calloc. - Thanks to Michael Pachos for motivation and help. - * Make optional .h file available - * Allow > 2GB requests on 32bit systems. - * new WIN32 sbrk, mmap, munmap, lock code from <Walter@GeNeSys-e.de>. - Thanks also to Andreas Mueller <a.mueller at paradatec.de>, - and Anonymous. - * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for - helping test this.) - * memalign: check tqalignment arg - * realloc: don't try to shift chunks backwards, since this - leads to more fragmentation in some programs and doesn't - seem to help in any others. - * Collect all cases in malloc requiring system memory into sYSMALLOc - * Use mmap as backup to sbrk - * Place all internal state in malloc_state - * Introduce fastbins (although similar to 2.5.1) - * Many minor tunings and cosmetic improvements - * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK - * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS - Thanks to Tony E. Bennett <tbennett@nvidia.com> and others. - * Include errno.h to support default failure action. - - V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) - * return null for negative arguments - * Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com> - * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' - (e.g. WIN32 platforms) - * Cleanup header file inclusion for WIN32 platforms - * Cleanup code to avoid Microsoft Visual C++ compiler complaints - * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing - memory allocation routines - * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) - * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to - usage of 'assert' in non-WIN32 code - * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to - avoid infinite loop - * Always call 'fREe()' rather than 'free()' - - V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) - * Fixed ordering problem with boundary-stamping - - V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) - * Added pvalloc, as recommended by H.J. Liu - * Added 64bit pointer support mainly from Wolfram Gloger - * Added anonymously donated WIN32 sbrk emulation - * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen - * malloc_extend_top: fix mask error that caused wastage after - foreign sbrks - * Add linux mremap support code from HJ Liu - - V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) - * Integrated most documentation with the code. - * Add support for mmap, with help from - Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Use last_remainder in more cases. - * Pack bins using idea from colin@nyx10.cs.du.edu - * Use ordered bins instead of best-fit threshold - * Eliminate block-local decls to simplify tracing and debugging. - * Support another case of realloc via move into top - * Fix error occurring when initial sbrk_base not word-aligned. - * Rely on page size for units instead of SBRK_UNIT to - avoid surprises about sbrk tqalignment conventions. - * Add mallinfo, mallopt. Thanks to Raymond Nijssen - (raymond@es.ele.tue.nl) for the suggestion. - * Add `pad' argument to malloc_trim and top_pad mallopt parameter. - * More precautions for cases where other routines call sbrk, - courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). - * Added macros etc., allowing use in linux libc from - H.J. Lu (hjl@gnu.ai.mit.edu) - * Inverted this history list - - V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) - * Re-tuned and fixed to behave more nicely with V2.6.0 changes. - * Removed all preallocation code since under current scheme - the work required to undo bad preallocations exceeds - the work saved in good cases for most test programs. - * No longer use return list or unconsolidated bins since - no scheme using them consistently outperforms those that don't - given above changes. - * Use best fit for very large chunks to prevent some worst-cases. - * Added some support for debugging - - V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) - * Removed footers when chunks are in use. Thanks to - Paul Wilson (wilson@cs.texas.edu) for the suggestion. - - V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) - * Added malloc_trim, with help from Wolfram Gloger - (wmglo@Dent.MED.Uni-Muenchen.DE). - - V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) - - V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) - * realloc: try to expand in both directions - * malloc: swap order of clean-bin strategy; - * realloc: only conditionally expand backwards - * Try not to scavenge used bins - * Use bin counts as a guide to preallocation - * Occasionally bin return list chunks in first scan - * Add a few optimizations from colin@nyx10.cs.du.edu - - V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) - * faster bin computation & slightly different binning - * merged all consolidations to one part of malloc proper - (eliminating old malloc_find_space & malloc_clean_bin) - * Scan 2 returns chunks (not just 1) - * Propagate failure in realloc if malloc returns 0 - * Add stuff to allow compilation on non-ANSI compilers - from kpv@research.att.com - - V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) - * removed potential for odd address access in prev_chunk - * removed dependency on getpagesize.h - * misc cosmetics and a bit more internal documentation - * anticosmetics: mangled names in macros to evade debugger strangeness - * tested on sparc, hp-700, dec-mips, rs6000 - with gcc & native cc (hp, dec only) allowing - Detlefs & Zorn comparison study (in SIGPLAN Notices.) - - Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) - * Based loosely on libg++-1.2X malloc. (It retains some of the overall - structure of old version, but most details differ.) - -*/ - -#ifdef USE_PUBLIC_MALLOC_WRAPPERS - -#ifndef KDE_MALLOC_FULL - -#ifdef KDE_MALLOC_GLIBC -#include "glibc.h" -#else -/* cannot use dlsym(RTLD_NEXT,...) here, it calls malloc()*/ -#error Unknown libc -#endif - -/* 0 - uninitialized - 1 - this malloc - 2 - standard libc malloc*/ -extern char* getenv(const char*); -static int malloc_type = 0; -static void init_malloc_type(void) - { - const char* const env = getenv( "KDE_MALLOC" ); - if( env == NULL ) - malloc_type = 1; - else if( env[ 0 ] == '0' || env[ 0 ] == 'n' || env[ 0 ] == 'N' ) - malloc_type = 2; - else - malloc_type = 1; - } - -#endif - -Void_t* public_mALLOc(size_t bytes) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = mALLOc(bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_malloc( bytes ); - init_malloc_type(); - return public_mALLOc( bytes ); -#endif -} - -void public_fREe(Void_t* m) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - if (MALLOC_PREACTION != 0) { - return; - } - fREe(m); - if (MALLOC_POSTACTION != 0) { - } -#ifndef KDE_MALLOC_FULL - return; - } - if( malloc_type == 2 ) - { - libc_free( m ); - return; - } - init_malloc_type(); - public_fREe( m ); -#endif -} - -Void_t* public_rEALLOc(Void_t* m, size_t bytes) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - if (MALLOC_PREACTION != 0) { - return 0; - } - m = rEALLOc(m, bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_realloc( m, bytes ); - init_malloc_type(); - return public_rEALLOc( m, bytes ); -#endif -} - -Void_t* public_mEMALIGn(size_t tqalignment, size_t bytes) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = mEMALIGn(tqalignment, bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_memalign( tqalignment, bytes ); - init_malloc_type(); - return public_mEMALIGn( tqalignment, bytes ); -#endif -} - -Void_t* public_vALLOc(size_t bytes) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = vALLOc(bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_valloc( bytes ); - init_malloc_type(); - return public_vALLOc( bytes ); -#endif -} - -Void_t* public_pVALLOc(size_t bytes) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = pVALLOc(bytes); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_pvalloc( bytes ); - init_malloc_type(); - return public_pVALLOc( bytes ); -#endif -} - -Void_t* public_cALLOc(size_t n, size_t elem_size) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - Void_t* m; - if (MALLOC_PREACTION != 0) { - return 0; - } - m = cALLOc(n, elem_size); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_calloc( n, elem_size ); - init_malloc_type(); - return public_cALLOc( n, elem_size ); -#endif -} - -void public_cFREe(Void_t* m) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - if (MALLOC_PREACTION != 0) { - return; - } - cFREe(m); - if (MALLOC_POSTACTION != 0) { - } -#ifndef KDE_MALLOC_FULL - return; - } - if( malloc_type == 2 ) - { - libc_cfree( m ); - return; - } - init_malloc_type(); - public_cFREe( m ); -#endif -} - -struct mallinfo public_mALLINFo() { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - struct mallinfo m; - if (MALLOC_PREACTION != 0) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - return nm; - } - m = mALLINFo(); - if (MALLOC_POSTACTION != 0) { - } - return m; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_mallinfo(); - init_malloc_type(); - return public_mALLINFo(); -#endif -} - -int public_mALLOPt(int p, int v) { -#ifndef KDE_MALLOC_FULL - if( malloc_type == 1 ) - { -#endif - int result; - if (MALLOC_PREACTION != 0) { - return 0; - } - result = mALLOPt(p, v); - if (MALLOC_POSTACTION != 0) { - } - return result; -#ifndef KDE_MALLOC_FULL - } - if( malloc_type == 2 ) - return libc_mallopt( p, v ); - init_malloc_type(); - return public_mALLOPt( p, v ); -#endif -} -#endif - -int -posix_memalign (void **memptr, size_t tqalignment, size_t size) -{ - void *mem; - - /* Test whether the SIZE argument is valid. It must be a power of - two multiple of sizeof (void *). */ - if (size % sizeof (void *) != 0 || (size & (size - 1)) != 0) - return EINVAL; - - mem = memalign (tqalignment, size); - - if (mem != NULL) { - *memptr = mem; - return 0; - } - - return ENOMEM; -} - -#else -/* Some linkers (Solaris 2.6) don't like empty archives, but for - easier Makefile's we want to link against libklmalloc.la every time, - so simply make it non-empty. */ -void kde_malloc_dummy_function () -{ - return; -} -#endif diff --git a/kdecore/malloc/x86.h b/kdecore/malloc/x86.h deleted file mode 100644 index b21517374..000000000 --- a/kdecore/malloc/x86.h +++ /dev/null @@ -1,41 +0,0 @@ -#include <sched.h> -#include <time.h> - -typedef struct { - volatile unsigned int lock; - int pad0_; -} mutex_t; - -#define MUTEX_INITIALIZER { 0, 0 } - -static __inline__ int lock(mutex_t *m) { - int cnt = 0, r; - struct timespec tm; - - for(;;) { - __asm__ __volatile__ - ("xchgl %0, %1" - : "=r"(r), "=m"(m->lock) - : "0"(1), "m"(m->lock) - : "memory"); - if(!r) - return 0; -#ifdef _POSIX_PRIORITY_SCHEDULING - if(cnt < 50) { - sched_yield(); - cnt++; - } else -#endif - { - tm.tv_sec = 0; - tm.tv_nsec = 2000001; - nanosleep(&tm, NULL); - cnt = 0; - } - } -} - -static __inline__ int unlock(mutex_t *m) { - __asm __volatile ("movl $0,%0" : "=m" (m->lock)); - return 0; -} diff --git a/kdecore/netsupp.cpp b/kdecore/netsupp.cpp deleted file mode 100644 index 83aec8bc0..000000000 --- a/kdecore/netsupp.cpp +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000,2001 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - **/ - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <netinet/in.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <unistd.h> -#include <arpa/inet.h> - -#include <tqglobal.h> - -// This is so that, if addrinfo is defined, it doesn't clobber our definition -// It might be defined in the few cases in which we are replacing the system's -// broken getaddrinfo -#include <netdb.h> - -#include "config.h" -#include "kdebug.h" -#include "klocale.h" - -#ifndef IN6_IS_ADDR_V4MAPPED -#define NEED_IN6_TESTS -#endif -#undef CLOBBER_IN6 -#include "netsupp.h" - -#if defined(__hpux) || defined(_HPUX_SOURCE) -extern int h_errno; -#endif - -#include <kdemacros.h> - -#if !defined(kde_sockaddr_in6) -/* - * kde_sockaddr_in6 might have got defined even though we #undef'ed - * CLOBBER_IN6. This happens when we are compiling under --enable-final. - * However, in that case, if it was defined, that's because ksockaddr.cpp - * had it defined because sockaddr_in6 didn't exist, and so sockaddr_in6 - * exists and is our kde_sockaddr_in6 - */ -# define sockaddr_in6 kde_sockaddr_in6 -# define in6_addr kde_in6_addr -#endif - -#ifdef offsetof -#undef offsetof -#endif -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -/* - * These constants tell the flags in KDE::resolverFlags - * The user could (but shouldn't) test the variable to know what kind of - * resolution is supported - */ -#define KRF_KNOWS_AF_INET6 0x01 /* if present, the code knows about AF_INET6 */ -#define KRF_USING_OWN_GETADDRINFO 0x02 /* if present, we are using our own getaddrinfo */ -#define KRF_USING_OWN_INET_NTOP 0x04 /* if present, we are using our own inet_ntop */ -#define KRF_USING_OWN_INET_PTON 0x08 /* if present, we are using our own inet_pton */ -#define KRF_CAN_RESOLVE_UNIX 0x100 /* if present, the resolver can resolve Unix sockets */ -#define KRF_CAN_RESOLVE_IPV4 0x200 /* if present, the resolver can resolve to IPv4 */ -#define KRF_CAN_RESOLVE_IPV6 0x400 /* if present, the resolver can resolve to IPv6 */ - - -static void dofreeaddrinfo(struct addrinfo *ai) -{ - while (ai) - { - struct addrinfo *ai2 = ai; - if (ai->ai_canonname != NULL) - free(ai->ai_canonname); - - if (ai->ai_addr != NULL) - free(ai->ai_addr); - - ai = ai->ai_next; - free(ai2); - } -} - -void kde_freeaddrinfo(struct kde_addrinfo *ai) -{ - if (ai->origin == KAI_LOCALUNIX) - { - struct addrinfo *p, *last = NULL; - /* We've added one AF_UNIX socket in here, to the - * tail of the linked list. We have to find it */ - for (p = ai->data; p; p = p->ai_next) - { - if (p->ai_family == AF_UNIX) - { - if (last) - { - last->ai_next = NULL; - freeaddrinfo(ai->data); - } - dofreeaddrinfo(p); - break; - } - last = p; - } - } - else - freeaddrinfo(ai->data); - - free(ai); -} - -static struct addrinfo* -make_unix(const char *name, const char *serv) -{ - const char *buf; - struct addrinfo *p; - struct sockaddr_un *_sun; - int len; - - p = (addrinfo*)malloc(sizeof(*p)); - if (p == NULL) - return NULL; - memset(p, 0, sizeof(*p)); - - if (name != NULL) - buf = name; - else - buf = serv; - - // Calculate length of the binary representation - len = strlen(buf) + offsetof(struct sockaddr_un, sun_path) + 1; - if (*buf != '/') - len += 5; // strlen("/tmp/"); - - _sun = (sockaddr_un*)malloc(len); - if (_sun == NULL) - { - // Oops - free(p); - return NULL; - } - - _sun->sun_family = AF_UNIX; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - _sun->sun_len = len; -# endif - if (*buf == '/') - *_sun->sun_path = '\0'; // empty it - else - strcpy(_sun->sun_path, "/tmp/"); - strcat(_sun->sun_path, buf); - - // Set the addrinfo - p->ai_family = AF_UNIX; - p->ai_addrlen = len; - p->ai_addr = (sockaddr*)_sun; - p->ai_canonname = strdup(buf); - - return p; -} - -// Ugh. I hate #ifdefs -// Anyways, here's what this does: -// KDE_IPV6_LOOKUP_MODE != 1, this function doesn't exist -// AF_INET6 not defined, we say there is no IPv6 stack -// otherwise, we try to create a socket. -// returns: 1 for IPv6 stack available, 2 for not available -#if defined(KDE_IPV6_LOOKUP_MODE) && KDE_IPV6_LOOKUP_MODE == 1 -static int check_ipv6_stack() -{ -# ifndef AF_INET6 - return 2; // how can we check? -# else - if (getenv("KDE_NO_IPV6")) - return 2; - int fd = ::socket(AF_INET6, SOCK_STREAM, 0); - if (fd == -1) - return 2; - - ::close(fd); - return 1; -# endif -} -#endif - - -/* - * Reason for using this function: kde_getaddrinfo - * - * I decided to add this wrapper function for getaddrinfo - * and have this be called by KExtendedSocket instead of - * the real getaddrinfo so that we can make sure that the - * behavior is the desired one. - * - * Currently, the only "undesired" behavior is getaddrinfo - * not returning PF_UNIX sockets in some implementations. - * - * getaddrinfo and family are defined in POSIX 1003.1g - * (Protocol Independent Interfaces) and in RFC 2553 - * (Basic Socket Interface for IPv6). Whereas the RFC is ambiguosly - * vague whether this family of functions should return Internet - * sockets only or not, the name of the POSIX draft says - * otherwise: it should be independent of protocol. - * - * So, my interpretation is that they should return every - * kind of socket available and known and that's how I - * designed KExtendedSocket on top of it. - * - * That's why there's this wrapper, to make sure PF_UNIX - * sockets are returned when expected. - */ - -int kde_getaddrinfo(const char *name, const char *service, - const struct addrinfo* hint, - struct kde_addrinfo** result) -{ - struct kde_addrinfo* res; - struct addrinfo* p; - int err = EAI_SERVICE; -#if defined(KDE_IPV6_LOOKUP_MODE) && KDE_IPV6_LOOKUP_MODE == 1 - // mode 1: do a check on whether we have an IPv6 stack - static int ipv6_stack = 0; // 0: unknown, 1: yes, 2: no -#endif - - // allocate memory for results - res = (kde_addrinfo*)malloc(sizeof(*res)); - if (res == NULL) - return EAI_MEMORY; - res->data = NULL; - res->origin = KAI_SYSTEM; // at first, it'll be only system data - - struct addrinfo* last = NULL; - - // Skip the getaddrinfo call and the ipv6 check for a UNIX socket. - if (hint && (hint->ai_family == PF_UNIX)) - { - if (service == NULL || *service == '\0') - goto out; // can't be Unix if no service was requested - - // Unix sockets must be localhost - // That is, either name is NULL or, if it's not, it must be empty, - // "*" or "localhost" - if (name != NULL && !(name[0] == '\0' || (name[0] == '*' && name[1] == '\0') || - strcmp("localhost", name) == 0)) - goto out; // isn't localhost - - goto do_unix; - } - -#if defined(KDE_IPV6_LOOKUP_MODE) && KDE_IPV6_LOOKUP_MODE != 0 -# if KDE_IPV6_LOOKUP_MODE == 1 - // mode 1: do a check on whether we have an IPv6 stack - if (ipv6_stack == 0) - ipv6_stack = check_ipv6_stack(); - - if (ipv6_stack == 2) - { -# endif - // here we have modes 1 and 2 (no lookups) - // this is shared code - struct addrinfo our_hint; - if (hint != NULL) - { - memcpy(&our_hint, hint, sizeof(our_hint)); - if (our_hint.ai_family == AF_UNSPEC) - our_hint.ai_family = AF_INET; - } - else - { - memset(&our_hint, 0, sizeof(our_hint)); - our_hint.ai_family = AF_INET; - } - - // do the actual resolution - err = getaddrinfo(name, service, &our_hint, &res->data); -# if KDE_IPV6_LOOKUP_MODE == 1 - } - else -# endif -#endif -#if defined(KDE_IPV6_LOOKUP_MODE) && KDE_IPV6_LOOKUP_MODE != 2 - // do the IPV6 resolution - err = getaddrinfo(name, service, hint, &res->data); -#endif - - // Now we have to check whether the user could want a Unix socket - - if (service == NULL || *service == '\0') - goto out; // can't be Unix if no service was requested - - // Unix sockets must be localhost - // That is, either name is NULL or, if it's not, it must be empty, - // "*" or "localhost" - if (name != NULL && !(name[0] == '\0' || (name[0] == '*' && name[1] == '\0') || - strcmp("localhost", name) == 0)) - goto out; // isn't localhost - - // Unix sockets can only be returned if the user asked for a PF_UNSPEC - // or PF_UNIX socket type or gave us a NULL hint - if (hint != NULL && (hint->ai_family != PF_UNSPEC && hint->ai_family != PF_UNIX)) - goto out; // user doesn't want Unix - - // If we got here, then it means that the user might be expecting Unix - // sockets. The user wants a local socket, with a non-null service and - // has told us that they accept PF_UNIX sockets - // Check whether the system implementation returned Unix - if (err == 0) - for (p = res->data; p; p = p->ai_next) - { - last = p; // we have to find out which one is last anyways - if (p->ai_family == AF_UNIX) - // there is an Unix node - goto out; - } - - do_unix: - // So, give the user a PF_UNIX socket - p = make_unix(NULL, service); - if (p == NULL) - { - err = EAI_MEMORY; - goto out; - } - if (hint != NULL) - p->ai_socktype = hint->ai_socktype; - if (p->ai_socktype == 0) - p->ai_socktype = SOCK_STREAM; // default - - if (last) - last->ai_next = p; - else - res->data = p; - res->origin = KAI_LOCALUNIX; - *result = res; - return 0; - - out: - if (res->data != NULL) - freeaddrinfo(res->data); - free(res); - return err; -} - -#if defined(HAVE_GETADDRINFO) && !defined(HAVE_BROKEN_GETADDRINFO) - -#define KRF_getaddrinfo 0 -#define KRF_resolver 0 - -#else // !defined(HAVE_GETADDRINFO) || defined(HAVE_BROKEN_GETADDRINFO) - -#define KRF_getaddrinfo KRF_USING_OWN_GETADDRINFO -#define KRF_resolver KRF_CAN_RESOLVE_UNIX | KRF_CAN_RESOLVE_IPV4 - -/* - * No getaddrinfo() in this system. - * We shall provide our own - */ - -/** TODO - * Try and use gethostbyname2_r before gethostbyname2 and gethostbyname - */ -static int inet_lookup(const char *name, int portnum, int protonum, - struct addrinfo *p, const struct addrinfo *hint, - struct addrinfo** result) -{ - struct addrinfo *q; - struct hostent *h; - struct sockaddr **psa = NULL; - int len; - - // TODO - // Currently, this never resolves IPv6 (need gethostbyname2, etc.) -# ifdef AF_INET6 - if (hint->ai_family == AF_INET6) - { - if (p != NULL) - { - *result = p; - return 0; - } - return EAI_FAIL; - } -# endif - - q = (addrinfo*)malloc(sizeof(*q)); - if (q == NULL) - { - freeaddrinfo(p); - return EAI_MEMORY; - } - - h = gethostbyname(name); - if (h == NULL) - { - if (p != NULL) - { - // There already is a suitable result - *result = p; - return 0; - } - - switch (h_errno) - { - case HOST_NOT_FOUND: - return EAI_NONAME; - case TRY_AGAIN: - return EAI_AGAIN; - case NO_RECOVERY: - return EAI_FAIL; - case NO_ADDRESS: - return EAI_NODATA; - default: - // EH!? - return EAI_FAIL; - } - } - - // convert the hostent to addrinfo - if (h->h_addrtype == AF_INET && (hint->ai_family == AF_INET || hint->ai_family == AF_UNSPEC)) - len = sizeof(struct sockaddr_in); -# ifdef AF_INET6 - else if (h->h_addrtype == AF_INET6 && (hint->ai_family == AF_INET6 || - hint->ai_family == AF_UNSPEC)) - len = sizeof(struct sockaddr_in6); -# endif - else - { - // We don't know what to do with these addresses - // Or gethostbyname returned information we don't want - if (p != NULL) - { - *result = p; - return 0; - } - return EAI_NODATA; - } - - q->ai_flags = 0; - q->ai_family = h->h_addrtype; - q->ai_socktype = hint->ai_socktype; - q->ai_protocol = protonum; - q->ai_addrlen = len; - - q->ai_addr = (sockaddr*)malloc(len); - if (q->ai_addr == NULL) - { - free(q); - freeaddrinfo(p); - return EAI_MEMORY; - } - if (h->h_addrtype == AF_INET) - { - struct sockaddr_in *sin = (sockaddr_in*)q->ai_addr; - sin->sin_family = AF_INET; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin->sin_len = sizeof(*sin); -# endif - sin->sin_port = portnum; - memcpy(&sin->sin_addr, h->h_addr, h->h_length); - } -# ifdef AF_INET6 - else if (h->h_addrtype == AF_INET6) - { - struct sockaddr_in6 *sin6 = (sockaddr_in6*)q->ai_addr; - sin6->sin6_family = AF_INET6; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin6->sin6_len = sizeof(*sin6); -# endif - sin6->sin6_port = portnum; - sin6->sin6_flowinfo = 0; - memcpy(&sin6->sin6_addr, h->h_addr, h->h_length); - sin6->sin6_scope_id = 0; - } -# endif - - if (hint->ai_flags & AI_CANONNAME) - q->ai_canonname = strdup(h->h_name); - else - q->ai_canonname = NULL; - - q->ai_next = p; - p = q; - - // cycle through the rest of the hosts; - for (psa = (sockaddr**)h->h_addr_list + 1; *psa; psa++) - { - q = (addrinfo*)malloc(sizeof(*q)); - if (q == NULL) - { - freeaddrinfo(p); - return EAI_MEMORY; - } - memcpy(q, p, sizeof(*q)); - - q->ai_addr = (sockaddr*)malloc(h->h_length); - if (q->ai_addr == NULL) - { - freeaddrinfo(p); - free(q); - return EAI_MEMORY; - } - if (h->h_addrtype == AF_INET) - { - struct sockaddr_in *sin = (sockaddr_in*)q->ai_addr; - sin->sin_family = AF_INET; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin->sin_len = sizeof(*sin); -# endif - sin->sin_port = portnum; - memcpy(&sin->sin_addr, *psa, h->h_length); - } -# ifdef AF_INET6 - else if (h->h_addrtype == AF_INET6) - { - struct sockaddr_in6 *sin6 = (sockaddr_in6*)q->ai_addr; - sin6->sin6_family = AF_INET6; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin6->sin6_len = sizeof(*sin6); -# endif - sin6->sin6_port = portnum; - sin6->sin6_flowinfo = 0; - memcpy(&sin6->sin6_addr, *psa, h->h_length); - sin6->sin6_scope_id = 0; - } -# endif - - if (q->ai_canonname != NULL) - q->ai_canonname = strdup(q->ai_canonname); - - q->ai_next = p; - p = q; - } - - *result = p; - return 0; // Whew! Success! -} - -static int make_inet(const char *name, int portnum, int protonum, struct addrinfo *p, - const struct addrinfo *hint, struct addrinfo** result) -{ - struct addrinfo *q; - - do - { - // This 'do' is here just so that we can 'break' out of it - - if (name != NULL) - { - // first, try to use inet_pton before resolving - // it will catch IP addresses given without having to go to lookup - struct sockaddr_in *sin; - struct in_addr in; -# ifdef AF_INET6 - struct sockaddr_in6 *sin6; - struct in6_addr in6; - - if (hint->ai_family == AF_INET6 || (hint->ai_family == AF_UNSPEC && - strchr(name, ':') != NULL)) - { - // yes, this is IPv6 - if (inet_pton(AF_INET6, name, &in6) != 1) - { - if (hint->ai_flags & AI_NUMERICHOST) - { - freeaddrinfo(p); - return EAI_FAIL; - } - break; // not a numeric host - } - - sin6 = (sockaddr_in6*)malloc(sizeof(*sin6)); - if (sin6 == NULL) - { - freeaddrinfo(p); - return EAI_MEMORY; - } - memcpy(&sin6->sin6_addr, &in6, sizeof(in6)); - - if (strchr(name, '%') != NULL) - { - errno = 0; - sin6->sin6_scope_id = strtoul(strchr(name, '%') + 1, NULL, 10); - if (errno != 0) - sin6->sin6_scope_id = 0; // no interface - } - - q = (addrinfo*)malloc(sizeof(*q)); - if (q == NULL) - { - freeaddrinfo(p); - free(sin6); - return EAI_MEMORY; - } - - sin6->sin6_family = AF_INET6; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin6->sin6_len = sizeof(*sin6); -# endif - sin6->sin6_port = portnum; - sin6->sin6_flowinfo = 0; - - q->ai_flags = 0; - q->ai_family = AF_INET6; - q->ai_socktype = hint->ai_socktype; - q->ai_protocol = protonum; - q->ai_addrlen = sizeof(*sin6); - q->ai_canonname = NULL; - q->ai_addr = (sockaddr*)sin6; - q->ai_next = p; - - *result = q; - return 0; // success! - } -# endif // AF_INET6 - - if (hint->ai_family == AF_INET || hint->ai_family == AF_UNSPEC) - { - // This has to be IPv4 - if (inet_pton(AF_INET, name, &in) != 1) - { - if (hint->ai_flags & AI_NUMERICHOST) - { - freeaddrinfo(p); - return EAI_FAIL; // invalid, I guess - } - break; // not a numeric host, do lookup - } - - sin = (sockaddr_in*)malloc(sizeof(*sin)); - if (sin == NULL) - { - freeaddrinfo(p); - return EAI_MEMORY; - } - - q = (addrinfo*)malloc(sizeof(*q)); - if (q == NULL) - { - freeaddrinfo(p); - free(sin); - return EAI_MEMORY; - } - - sin->sin_family = AF_INET; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin->sin_len = sizeof(*sin); -# endif - sin->sin_port = portnum; - sin->sin_addr = in; - - q->ai_flags = 0; - q->ai_family = AF_INET; - q->ai_socktype = hint->ai_socktype; - q->ai_protocol = protonum; - q->ai_addrlen = sizeof(*sin); - q->ai_canonname = NULL; - q->ai_addr = (sockaddr*)sin; - q->ai_next = p; - *result = q; - return 0; - } - - // Eh, what!? - // One of the two above has to have matched - kdError() << "I wasn't supposed to get here!"; - } - } while (false); - - // This means localhost - if (name == NULL) - { - struct sockaddr_in *sin = (sockaddr_in*)malloc(sizeof(*sin)); -# ifdef AF_INET6 - struct sockaddr_in6 *sin6; -# endif - - if (hint->ai_family == AF_INET || hint->ai_family == AF_UNSPEC) - { - if (sin == NULL) - { - free(sin); - freeaddrinfo(p); - return EAI_MEMORY; - } - - // Do IPv4 first - q = (addrinfo*)malloc(sizeof(*q)); - if (q == NULL) - { - free(sin); - freeaddrinfo(p); - return EAI_MEMORY; - } - - sin->sin_family = AF_INET; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin->sin_len = sizeof(*sin); -# endif - sin->sin_port = portnum; - if (hint->ai_flags & AI_PASSIVE) - *(TQ_UINT32*)&sin->sin_addr = INADDR_ANY; - else - *(TQ_UINT32*)&sin->sin_addr = htonl(INADDR_LOOPBACK); - q->ai_flags = 0; - q->ai_family = AF_INET; - q->ai_socktype = hint->ai_socktype; - q->ai_protocol = protonum; - q->ai_addrlen = sizeof(*sin); - q->ai_canonname = NULL; - q->ai_addr = (sockaddr*)sin; - q->ai_next = p; - p = q; - } - -# ifdef AF_INET6 - // Try now IPv6 - - if (hint->ai_family == AF_INET6 || hint->ai_family == AF_UNSPEC) - { - sin6 = (sockaddr_in6*)malloc(sizeof(*sin6)); - q = (addrinfo*)malloc(sizeof(*q)); - if (q == NULL || sin6 == NULL) - { - free(sin6); - free(q); - freeaddrinfo(p); - return EAI_MEMORY; - } - - sin6->sin6_family = AF_INET6; -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sin6->sin6_len = sizeof(*sin6); -# endif - sin6->sin6_port = portnum; - sin6->sin6_flowinfo = 0; - sin6->sin6_scope_id = 0; - - // We don't want to use in6addr_loopback and in6addr_any - memset(&sin6->sin6_addr, 0, sizeof(sin6->sin6_addr)); - if ((hint->ai_flags & AI_PASSIVE) == 0) - ((char*)&sin6->sin6_addr)[15] = 1; - - q->ai_flags = 0; - q->ai_family = AF_INET6; - q->ai_socktype = hint->ai_socktype; - q->ai_protocol = protonum; - q->ai_addrlen = sizeof(*sin6); - q->ai_canonname = NULL; - q->ai_addr = (sockaddr*)sin6; - q->ai_next = p; - p = q; - } - -# endif // AF_INET6 - - *result = p; - return 0; // success! - } - - return inet_lookup(name, portnum, protonum, p, hint, result); -} - - -int getaddrinfo(const char *name, const char *serv, - const struct addrinfo* hint, - struct addrinfo** result) -{ - unsigned short portnum; // remember to store in network byte order - int protonum = IPPROTO_TCP; - const char *proto = "tcp"; - struct addrinfo *p = NULL; - - // Sanity checks: - if (hint == NULL || result == NULL) - return EAI_BADFLAGS; - if (hint->ai_family != AF_UNSPEC && hint->ai_family != AF_UNIX && - hint->ai_family != AF_INET -# ifdef AF_INET6 - && hint->ai_family != AF_INET6 -# endif - ) - return EAI_FAMILY; - if (hint->ai_socktype != 0 && hint->ai_socktype != SOCK_STREAM && - hint->ai_socktype != SOCK_DGRAM) - return EAI_SOCKTYPE; - - // Treat hostname of "*" as NULL, which means localhost - if (name != NULL && ((*name == '*' && name[1] == '\0') || *name == '\0')) - name = NULL; - // Treat service of "*" as NULL, which I guess means no port (0) - if (serv != NULL && ((*serv == '*' && serv[1] == '\0') || *serv == '\0')) - serv = NULL; - - if (name == NULL && serv == NULL) // what the hell do you want? - return EAI_NONAME; - - // This is just to make it easier - if (name != NULL && strcmp(name, "localhost") == 0) - name = NULL; - - // First, check for a Unix socket - // family must be either AF_UNIX or AF_UNSPEC - // either of name or serv must be set, the other must be NULL or empty - if (hint->ai_family == AF_UNIX || hint->ai_family == AF_UNSPEC) - { - if (name != NULL && serv != NULL) - { - // This is not allowed - if (hint->ai_family == AF_UNIX) - return EAI_BADFLAGS; - } - else - { - p = make_unix(name, serv); - if (p == NULL) - return EAI_MEMORY; - - p->ai_socktype = hint->ai_socktype; - // If the name/service started with a slash, then this *IS* - // only a Unix socket. Return. - if (hint->ai_family == AF_UNIX || ((name != NULL && *name == '/') || - (serv != NULL && *serv == '/'))) - { - *result = p; - return 0; // successful lookup - } - } - } - - // Lookup the service name, if required - if (serv != NULL) - { - char *tail; - struct servent *sent; - - portnum = htons((unsigned)strtoul(serv, &tail, 10)); - if (*tail != '\0') - { - // not a number. We have to do the lookup - if (hint->ai_socktype == SOCK_DGRAM) - { - proto = "udp"; - protonum = IPPROTO_UDP; - } - - sent = getservbyname(serv, proto); - if (sent == NULL) // no service? - { - if (p == NULL) - return EAI_NONAME; - else - return 0; // a Unix socket available - } - - portnum = sent->s_port; - } - } - else - portnum = 0; // no port number - - return make_inet(name, portnum, protonum, p, hint, result); -} - -void freeaddrinfo(struct addrinfo *p) -{ - dofreeaddrinfo(p); -} - -char *gai_strerror(int errorcode) -{ - static const char * const messages[] = - { - I18N_NOOP("no error"), // 0 - I18N_NOOP("address family for nodename not supported"), // EAI_ADDRFAMILY - I18N_NOOP("temporary failure in name resolution"), // EAI_AGAIN - I18N_NOOP("invalid value for 'ai_flags'"), // EAI_BADFLAGS - I18N_NOOP("non-recoverable failure in name resolution"), // EAI_FAIL - I18N_NOOP("'ai_family' not supported"), // EAI_FAMILY - I18N_NOOP("memory allocation failure"), // EAI_MEMORY - I18N_NOOP("no address associated with nodename"), // EAI_NODATA - I18N_NOOP("name or service not known"), // EAI_NONAME - I18N_NOOP("servname not supported for ai_socktype"), // EAI_SERVICE - I18N_NOOP("'ai_socktype' not supported"), // EAI_SOCKTYPE - I18N_NOOP("system error") // EAI_SYSTEM - }; - - if (errorcode > EAI_SYSTEM || errorcode < 0) - return NULL; - - static char buffer[200]; - strcpy(buffer, i18n(messages[errorcode]).local8Bit()); - return buffer; -} - -static void findport(unsigned short port, char *serv, size_t servlen, int flags) -{ - if (serv == NULL) - return; - - if ((flags & NI_NUMERICSERV) == 0) - { - struct servent *sent; - sent = getservbyport(ntohs(port), flags & NI_DGRAM ? "udp" : "tcp"); - if (sent != NULL && servlen > strlen(sent->s_name)) - { - strcpy(serv, sent->s_name); - return; - } - } - - snprintf(serv, servlen, "%u", ntohs(port)); -} - -int getnameinfo(const struct sockaddr *sa, ksocklen_t salen, - char *host, size_t hostlen, char *serv, size_t servlen, - int flags) -{ - union - { - const sockaddr *sa; - const sockaddr_un *_sun; - const sockaddr_in *sin; - const sockaddr_in6 *sin6; - } s; - - if ((host == NULL || hostlen == 0) && (serv == NULL || servlen == 0)) - return 1; - - s.sa = sa; - if (s.sa->sa_family == AF_UNIX) - { - if (salen < offsetof(struct sockaddr_un, sun_path) + strlen(s._sun->sun_path) + 1) - return 1; // invalid socket - - if (servlen && serv != NULL) - *serv = '\0'; - if (host != NULL && hostlen > strlen(s._sun->sun_path)) - strcpy(host, s._sun->sun_path); - - return 0; - } - else if (s.sa->sa_family == AF_INET) - { - if (salen < offsetof(struct sockaddr_in, sin_addr) + sizeof(s.sin->sin_addr)) - return 1; // invalid socket - - if (flags & NI_NUMERICHOST) - inet_ntop(AF_INET, &s.sin->sin_addr, host, hostlen); - else - { - // have to do lookup - struct hostent *h = gethostbyaddr((const char*)&s.sin->sin_addr, sizeof(s.sin->sin_addr), - AF_INET); - if (h == NULL && flags & NI_NAMEREQD) - return 1; - else if (h == NULL) - inet_ntop(AF_INET, &s.sin->sin_addr, host, hostlen); - else if (host != NULL && hostlen > strlen(h->h_name)) - strcpy(host, h->h_name); - else - return 1; // error - } - - findport(s.sin->sin_port, serv, servlen, flags); - } -# ifdef AF_INET6 - else if (s.sa->sa_family == AF_INET6) - { - if (salen < offsetof(struct sockaddr_in6, sin6_addr) + sizeof(s.sin6->sin6_addr)) - return 1; // invalid socket - - if (flags & NI_NUMERICHOST) - inet_ntop(AF_INET6, &s.sin6->sin6_addr, host, hostlen); - else - { - // have to do lookup - struct hostent *h = gethostbyaddr((const char*)&s.sin->sin_addr, sizeof(s.sin->sin_addr), - AF_INET6); - if (h == NULL && flags & NI_NAMEREQD) - return 1; - else if (h == NULL) - inet_ntop(AF_INET6, &s.sin6->sin6_addr, host, hostlen); - else if (host != NULL && hostlen > strlen(h->h_name)) - strcpy(host, h->h_name); - else - return 1; // error - } - - findport(s.sin6->sin6_port, serv, servlen, flags); - } -# endif // AF_INET6 - - return 1; // invalid family -} - -#endif // HAVE_GETADDRINFO - -#ifndef HAVE_INET_NTOP - -#define KRF_inet_ntop KRF_USING_OWN_INET_NTOP - -static void add_dwords(char *buf, TQ_UINT16 *dw, int count) -{ - int i = 1; - sprintf(buf + strlen(buf), "%x", ntohs(dw[0])); - while (--count) - sprintf(buf + strlen(buf), ":%x", ntohs(dw[i++])); -} - -const char* inet_ntop(int af, const void *cp, char *buf, size_t len) -{ - char buf2[sizeof "1234:5678:9abc:def0:1234:5678:255.255.255.255" + 1]; - TQ_UINT8 *data = (TQ_UINT8*)cp; - - if (af == AF_INET) - { - sprintf(buf2, "%u.%u.%u.%u", data[0], data[1], data[2], data[3]); - - if (len > strlen(buf2)) - { - strcpy(buf, buf2); - return buf; - } - - errno = ENOSPC; - return NULL; // failed - } - -# ifdef AF_INET6 - if (af == AF_INET6) - { - TQ_UINT16 *p = (TQ_UINT16*)data; - TQ_UINT16 *longest = NULL, *cur = NULL; - int longest_length = 0, cur_length; - int i; - - if (KDE_IN6_IS_ADDR_V4MAPPED(p) || KDE_IN6_IS_ADDR_V4COMPAT(p)) - sprintf(buf2, "::%s%u.%u.%u.%u", - KDE_IN6_IS_ADDR_V4MAPPED(p) ? "ffff:" : "", - buf[12], buf[13], buf[14], buf[15]); - else - { - // find the longest sequence of zeroes - for (i = 0; i < 8; i++) - if (cur == NULL && p[i] == 0) - { - // a zero, start the sequence - cur = p + i; - cur_length = 1; - } - else if (cur != NULL && p[i] == 0) - // part of the sequence - cur_length++; - else if (cur != NULL && p[i] != 0) - { - // end of the sequence - if (cur_length > longest_length) - { - longest_length = cur_length; - longest = cur; - } - cur = NULL; // restart sequence - } - if (cur != NULL && cur_length > longest_length) - { - longest_length = cur_length; - longest = cur; - } - - if (longest_length > 1) - { - // We have a candidate - buf2[0] = '\0'; - if (longest != p) - add_dwords(buf2, p, longest - p); - strcat(buf2, "::"); - if (longest + longest_length < p + 8) - add_dwords(buf2, longest + longest_length, 8 - (longest - p) - longest_length); - } - else - { - // Nope, no candidate - buf2[0] = '\0'; - add_dwords(buf2, p, 8); - } - } - - if (strlen(buf2) < len) - { - strcpy(buf, buf2); - return buf; - } - - errno = ENOSPC; - return NULL; - } -# endif - - errno = EAFNOSUPPORT; - return NULL; // a family we don't know about -} - -#else // HAVE_INET_NTOP - -#define KRF_inet_ntop 0 - -#endif // HAVE_INET_NTOP - -#ifndef HAVE_INET_PTON - -#define KRF_inet_pton KRF_USING_OWN_INET_PTON -int inet_pton(int af, const char *cp, void *buf) -{ - if (af == AF_INET) - { - // Piece of cake - unsigned p[4]; - unsigned char *q = (unsigned char*)buf; - if (sscanf(cp, "%u.%u.%u.%u", p, p + 1, p + 2, p + 3) != 4) - return 0; - - if (p[0] > 0xff || p[1] > 0xff || p[2] > 0xff || p[3] > 0xff) - return 0; - - q[0] = p[0]; - q[1] = p[1]; - q[2] = p[2]; - q[3] = p[3]; - - return 1; - } - -# ifdef AF_INET6 - else if (af == AF_INET6) - { - TQ_UINT16 addr[8]; - const char *p = cp; - int n = 0, start = 8; - bool has_v4 = strchr(p, '.') != NULL; - - memset(addr, 0, sizeof(addr)); - - if (*p == '\0' || p[1] == '\0') - return 0; // less than 2 chars is not valid - - if (*p == ':' && p[1] == ':') - { - start = 0; - p += 2; - } - while (*p) - { - if (has_v4 && inet_pton(AF_INET, p, addr + n) != 0) - { - // successful v4 convertion - addr[n] = ntohs(addr[n]); - n++; - addr[n] = ntohs(addr[n]); - n++; - break; - } - if (sscanf(p, "%hx", addr + n++) != 1) - return 0; - - while (*p && *p != ':') - p++; - if (!*p) - break; - p++; - - if (*p == ':') // another ':'? - { - if (start != 8) - return 0; // two :: were found - start = n; - p++; - } - } - - // if start is not 8, then a "::" was found at word 'start' - // n is the number of converted words - // n == 8 means everything was converted and no moving is necessary - // n < 8 means that we have to move n - start words 8 - n words to the right - if (start == 8 && n != 8) - return 0; // bad conversion - memmove(addr + start + (8 - n), addr + start, (n - start) * sizeof(TQ_UINT16)); - memset(addr + start, 0, (8 - n) * sizeof(TQ_UINT16)); - - // check the byte order - // The compiler should optimise this out in big endian machines - if (htons(0x1234) != 0x1234) - for (n = 0; n < 8; n++) - addr[n] = htons(addr[n]); - - memcpy(buf, addr, sizeof(addr)); - return 1; - } -# endif - - errno = EAFNOSUPPORT; - return -1; // unknown family -} - -#else // HAVE_INET_PTON - -#define KRF_inet_pton 0 - -#endif // HAVE_INET_PTON - -#ifdef AF_INET6 -# define KRF_afinet6 KRF_KNOWS_AF_INET6 -#else -# define KRF_afinet6 0 -#endif - -namespace KDE -{ - /** @internal */ - extern const int KDE_EXPORT resolverFlags = KRF_getaddrinfo | KRF_resolver | KRF_afinet6 | KRF_inet_ntop | KRF_inet_pton; -} diff --git a/kdecore/netsupp.h b/kdecore/netsupp.h deleted file mode 100644 index a94040d44..000000000 --- a/kdecore/netsupp.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000-2003 Thiago Macieira <thiago.macieira@kdemail.net>> - * - * 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 _NETSUPP_H_ -#define _NETSUPP_H_ - -#include "kdelibs_export.h" - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <sys/socket.h> -#include <netdb.h> -//#include "ksockaddr.h" - -#ifdef __CYGWIN__ -typedef unsigned ksocklen_t; -#endif - -/* - * Seems some systems don't know about AF_LOCAL - */ -#ifndef AF_LOCAL -#define AF_LOCAL AF_UNIX -#define PF_LOCAL PF_UNIX -#endif - -#ifdef CLOBBER_IN6 -#define kde_in6_addr in6_addr -#define kde_sockaddr_in6 sockaddr_in6 -#endif - -/*** IPv6 structures that might be missing from some implementations ***/ - -/** @internal - * An IPv6 address. - * This is taken from RFC 2553 - */ -struct kde_in6_addr -{ - unsigned char __u6_addr[16]; -}; - -/** @internal - * An IPv6 socket address - * This is taken from RFC 2553. - */ -struct kde_sockaddr_in6 -{ -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - TQ_UINT8 sin6_len; - TQ_UINT8 sin6_family; -#else //HAVE_STRUCT_SOCKADDR_SA_LEN - TQ_UINT16 sin6_family; -#endif - unsigned short sin6_port; /* RFC says in_port_t */ - TQ_UINT32 sin6_flowinfo; - struct kde_in6_addr sin6_addr; - TQ_UINT32 sin6_scope_id; -}; - -/* IPv6 test macros that could be missing from some implementations */ - -#define KDE_IN6_IS_ADDR_UNSPECIFIED(a) \ - (((TQ_UINT32 *) (a))[0] == 0 && ((TQ_UINT32 *) (a))[1] == 0 && \ - ((TQ_UINT32 *) (a))[2] == 0 && ((TQ_UINT32 *) (a))[3] == 0) - -#define KDE_IN6_IS_ADDR_LOOPBACK(a) \ - (((TQ_UINT32 *) (a))[0] == 0 && ((TQ_UINT32 *) (a))[1] == 0 && \ - ((TQ_UINT32 *) (a))[2] == 0 && ((TQ_UINT32 *) (a))[3] == htonl (1)) - -#define KDE_IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff) - -#define KDE_IN6_IS_ADDR_LINKLOCAL(a) \ - ((((TQ_UINT32 *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000)) - -#define KDE_IN6_IS_ADDR_SITELOCAL(a) \ - ((((TQ_UINT32 *) (a))[0] & htonl (0xffc00000)) == htonl (0xfec00000)) - -#define KDE_IN6_IS_ADDR_V4MAPPED(a) \ - ((((TQ_UINT32 *) (a))[0] == 0) && (((TQ_UINT32 *) (a))[1] == 0) && \ - (((TQ_UINT32 *) (a))[2] == htonl (0xffff))) - -#define KDE_IN6_IS_ADDR_V4COMPAT(a) \ - ((((TQ_UINT32 *) (a))[0] == 0) && (((TQ_UINT32 *) (a))[1] == 0) && \ - (((TQ_UINT32 *) (a))[2] == 0) && (ntohl (((TQ_UINT32 *) (a))[3]) > 1)) - -#define KDE_IN6_ARE_ADDR_EQUAL(a,b) \ - ((((TQ_UINT32 *) (a))[0] == ((TQ_UINT32 *) (b))[0]) && \ - (((TQ_UINT32 *) (a))[1] == ((TQ_UINT32 *) (b))[1]) && \ - (((TQ_UINT32 *) (a))[2] == ((TQ_UINT32 *) (b))[2]) && \ - (((TQ_UINT32 *) (a))[3] == ((TQ_UINT32 *) (b))[3])) - -#define KDE_IN6_IS_ADDR_MC_NODELOCAL(a) \ - (KDE_IN6_IS_ADDR_MULTICAST(a) && ((((TQ_UINT8 *) (a))[1] & 0xf) == 0x1)) - -#define KDE_IN6_IS_ADDR_MC_LINKLOCAL(a) \ - (KDE_IN6_IS_ADDR_MULTICAST(a) && ((((TQ_UINT8 *) (a))[1] & 0xf) == 0x2)) - -#define KDE_IN6_IS_ADDR_MC_SITELOCAL(a) \ - (KDE_IN6_IS_ADDR_MULTICAST(a) && ((((TQ_UINT8 *) (a))[1] & 0xf) == 0x5)) - -#define KDE_IN6_IS_ADDR_MC_ORGLOCAL(a) \ - (KDE_IN6_IS_ADDR_MULTICAST(a) && ((((TQ_UINT8 *) (a))[1] & 0xf) == 0x8)) - -#define KDE_IN6_IS_ADDR_MC_GLOBAL(a) \ - (KDE_IN6_IS_ADDR_MULTICAST(a) && ((((TQ_UINT8 *) (a))[1] & 0xf) == 0xe)) - -#ifdef NEED_IN6_TESTS -# define IN6_IS_ADDR_UNSPECIFIED KDE_IN6_IS_ADDR_UNSPECIFIED -# define IN6_IS_ADDR_LOOPBACK KDE_IN6_IS_ADDR_LOOPBACK -# define IN6_IS_ADDR_MULTICAST KDE_IN6_IS_ADDR_MULTICAST -# define IN6_IS_ADDR_LINKLOCAL KDE_IN6_IS_ADDR_LINKLOCAL -# define IN6_IS_ADDR_SITELOCAL KDE_IN6_IS_ADDR_SITELOCAL -# define IN6_IS_ADDR_V4MAPPED KDE_IN6_IS_ADDR_V4MAPPED -# define IN6_IS_ADDR_V4COMPAT KDE_IN6_IS_ADDR_V4COMPAT -# define IN6_ARE_ADDR_EQUAL KDE_IN6_ARE_ADDR_EQUAL -# define IN6_IS_ADDR_MC_NODELOCAL KDE_IN6_IS_ADDR_MC_NODELOCAL -# define IN6_IS_ADDR_MC_LINKLOCAL KDE_IN6_IS_ADDR_MC_LINKLOCAL -# define IN6_IS_ADDR_MC_SITELOCAL KDE_IN6_IS_ADDR_MC_SITELOCAL -# define IN6_IS_ADDR_MC_ORGLOCAL KDE_IN6_IS_ADDR_MC_ORGLOCAL -# define IN6_IS_ADDR_MC_GLOBAL KDE_IN6_IS_ADDR_MC_GLOBAL -#endif - -/* Special internal structure */ - -#define KAI_SYSTEM 0 /* data is all-system */ -#define KAI_LOCALUNIX 1 /* data contains a Unix addrinfo allocated by us */ -#define KAI_QDNS 2 /* data contains data derived from TQDns */ - -struct addrinfo; /* forward declaration; this could be needed */ - -/** - * @internal - * Special purpose structure, to return data from kde_getaddrinfo to the - * library functions. This defines an extra field to let us know how to - * process this better. - * - * Currently, we use it to determine how to deallocate this stuff - */ -struct kde_addrinfo -{ - struct addrinfo *data; - int origin; -}; - -extern KDECORE_EXPORT int kde_getaddrinfo(const char *name, const char *service, - const struct addrinfo* hint, - struct kde_addrinfo** result); -extern KDECORE_EXPORT void kde_freeaddrinfo(struct kde_addrinfo *p); - -#if !defined(HAVE_GETADDRINFO) || defined(HAVE_BROKEN_GETADDRINFO) - -# ifndef HAVE_STRUCT_ADDRINFO -/** - * @internal - */ -struct addrinfo -{ - int ai_flags; /**< Input flags. */ - int ai_family; /**< Protocol family for socket. */ - int ai_socktype; /**< Socket type. */ - int ai_protocol; /**< Protocol for socket. */ - int ai_addrlen; /**< Length of socket address. */ - struct sockaddr *ai_addr; /**< Socket address for socket. */ - char *ai_canonname; /**< Canonical name for service location. */ - struct addrinfo *ai_next; /**< Pointer to next in list. */ -}; -# endif - -# ifdef AI_PASSIVE -# undef AI_PASSIVE -# undef AI_CANONNAME -# undef AI_NUMERICHOST -# endif - -/* Possible values for `ai_flags' field in `addrinfo' structure. */ -# define AI_PASSIVE 1 /* Socket address is intended for `bind'. */ -# define AI_CANONNAME 2 /* Request for canonical name. */ -# define AI_NUMERICHOST 4 /* Don't use name resolution. */ - -# ifdef EAI_ADDRFAMILY -# undef EAI_ADDRFAMILY -# undef EAI_AGAIN -# undef EAI_BADFLAGS -# undef EAI_FAIL -# undef EAI_FAMILY -# undef EAI_MEMORY -# undef EAI_NODATA -# undef EAI_NONAME -# undef EAI_SERVICE -# undef EAI_SOCKTYPE -# undef EAI_SYSTEM -# endif - -/* Error values for `getaddrinfo' function. */ -# define EAI_ADDRFAMILY 1 /* Address family for NAME not supported. */ -# define EAI_AGAIN 2 /* Temporary failure in name resolution. */ -# define EAI_BADFLAGS 3 /* Invalid value for `ai_flags' field. */ -# define EAI_FAIL 4 /* Non-recoverable failure in name res. */ -# define EAI_FAMILY 5 /* `ai_family' not supported. */ -# define EAI_MEMORY 6 /* Memory allocation failure. */ -# define EAI_NODATA 7 /* No address associated with NAME. */ -# define EAI_NONAME 8 /* NAME or SERVICE is unknown. */ -# define EAI_SERVICE 9 /* SERVICE not supported for `ai_socktype'. */ -# define EAI_SOCKTYPE 10 /* `ai_socktype' not supported. */ -# define EAI_SYSTEM 11 /* System error returned in `errno'. */ - -/* - * These are specified in the RFC - * We won't undefine them. If someone defined them to a different value - * the preprocessor will generate an error - */ -# define NI_MAXHOST 1025 -# define NI_MAXSERV 32 - -# ifdef NI_NUMERICHOST -# undef NI_NUMERICHOST -# undef NI_NUMERICSERV -# undef NI_NOFQDN -# undef NI_NAMEREQD -# undef NI_DGRAM -# endif - -# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */ -# define NI_NUMERICSERV 2 /* Don't convert port number to name. */ -# define NI_NOFQDN 4 /* Only return nodename portion. */ -# define NI_NAMEREQD 8 /* Don't return numeric addresses. */ -# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */ - -# ifdef getaddrinfo -# undef getaddrinfo -# endif - -namespace KDE -{ - /** \internal */ - extern KDECORE_EXPORT int getaddrinfo(const char *name, const char *service, - const struct addrinfo* hint, - struct addrinfo** result); - /** \internal */ - extern KDECORE_EXPORT void freeaddrinfo(struct addrinfo* ai); - /** \internal */ - extern KDECORE_EXPORT char *gai_strerror(int errorcode); - /** \internal */ - extern KDECORE_EXPORT int getnameinfo(const struct sockaddr *sa, - unsigned int salen, - char *host, size_t hostlen, - char *serv, size_t servlen, - int flags); -} - -# define getaddrinfo KDE::getaddrinfo -# define freeaddrinfo KDE::freeaddrinfo -# define gai_strerror KDE::gai_strerror -# define getnameinfo KDE::getnameinfo - - -#endif - -#ifndef HAVE_INET_PTON - -namespace KDE -{ - /** \internal */ - extern KDECORE_EXPORT int inet_pton(int af, const char *cp, void* buf); -} - -# define inet_pton KDE::inet_pton -#endif - -#ifndef HAVE_INET_NTOP - -namespace KDE -{ - /** \internal */ - extern KDECORE_EXPORT const char* inet_ntop(int af, const void *cp, char *buf, size_t len); -} - -# define inet_ntop KDE::inet_ntop -#endif - -#endif diff --git a/kdecore/netsupp_win32.cpp b/kdecore/netsupp_win32.cpp deleted file mode 100644 index 316c5f4cd..000000000 --- a/kdecore/netsupp_win32.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2000-2003 Thiago Macieira <thiago.macieira@kdemail.net>> - * - * win32 version of netsupp.cpp - * - * 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. - **/ - - -#include "netsupp.h" - -KDECORE_EXPORT void kde_freeaddrinfo(struct kde_addrinfo *ai) -{ - //TODO -} - -KDECORE_EXPORT int kde_getaddrinfo(const char *name, const char *service, - const struct addrinfo* hint, - struct kde_addrinfo** result) -{ - //TODO - int err = EAI_SERVICE; - return err; -} - -KDECORE_EXPORT char *gai_strerror(int errorcode) -{ - return 0; -} -int getnameinfo(const struct sockaddr *sa, - unsigned int salen, - char *host, size_t hostlen, - char *serv, size_t servlen, - int flags) -{ - //TODO - return -1; -} - -KDECORE_EXPORT const char* inet_ntop(int af, const void *cp, char *buf, size_t len) -{ - //TODO - return 0; -} - -KDECORE_EXPORT int inet_pton(int af, const char *cp, void *buf) -{ - //TODO - return -1; -} - diff --git a/kdecore/netwm.cpp b/kdecore/netwm.cpp deleted file mode 100644 index 455b6db65..000000000 --- a/kdecore/netwm.cpp +++ /dev/null @@ -1,4645 +0,0 @@ -/* - - Copyright (c) 2000 Troll Tech AS - Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> - - 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. - -*/ - -//#define NETWMDEBUG - -#include <tqwidget.h> -#include <tqapplication.h> -#ifdef Q_WS_X11 //FIXME - -#include "netwm.h" - -#include <string.h> -#include <stdio.h> -#include <assert.h> -#include <stdlib.h> - -#include <X11/Xmd.h> - -#include "netwm_p.h" - -// UTF-8 string -static Atom UTF8_STRING = 0; - -// root window properties -static Atom net_supported = 0; -static Atom net_client_list = 0; -static Atom net_client_list_stacking = 0; -static Atom net_desktop_geometry = 0; -static Atom net_desktop_viewport = 0; -static Atom net_current_desktop = 0; -static Atom net_desktop_names = 0; -static Atom net_number_of_desktops = 0; -static Atom net_active_window = 0; -static Atom net_workarea = 0; -static Atom net_supporting_wm_check = 0; -static Atom net_virtual_roots = 0; -static Atom net_showing_desktop = 0; -static Atom net_desktop_layout = 0; - -// root window messages -static Atom net_close_window = 0; -static Atom net_restack_window = 0; -static Atom net_wm_moveresize = 0; -static Atom net_moveresize_window = 0; - -// application window properties -static Atom net_wm_name = 0; -static Atom net_wm_visible_name = 0; -static Atom net_wm_icon_name = 0; -static Atom net_wm_visible_icon_name = 0; -static Atom net_wm_desktop = 0; -static Atom net_wm_window_type = 0; -static Atom net_wm_state = 0; -static Atom net_wm_strut = 0; -static Atom net_wm_extended_strut = 0; // the atom is called _NET_WM_STRUT_PARTIAL -static Atom net_wm_icon_geometry = 0; -static Atom net_wm_icon = 0; -static Atom net_wm_pid = 0; -static Atom net_wm_user_time = 0; -static Atom net_wm_handled_icons = 0; -static Atom net_startup_id = 0; -static Atom net_wm_allowed_actions = 0; -static Atom wm_window_role = 0; -static Atom net_frame_extents = 0; - -// KDE extensions -static Atom kde_net_system_tray_windows = 0; -static Atom kde_net_wm_system_tray_window_for = 0; -static Atom kde_net_wm_frame_strut = 0; -static Atom kde_net_wm_window_type_override = 0; -static Atom kde_net_wm_window_type_topmenu = 0; -static Atom kde_net_wm_temporary_rules = 0; - -// application protocols -static Atom wm_protocols = 0; -static Atom net_wm_ping = 0; -static Atom net_wm_take_activity = 0; - -// application window types -static Atom net_wm_window_type_normal = 0; -static Atom net_wm_window_type_desktop = 0; -static Atom net_wm_window_type_dock = 0; -static Atom net_wm_window_type_toolbar = 0; -static Atom net_wm_window_type_menu = 0; -static Atom net_wm_window_type_dialog = 0; -static Atom net_wm_window_type_utility = 0; -static Atom net_wm_window_type_splash = 0; -static Atom net_wm_window_type_dropdown_menu = 0; -static Atom net_wm_window_type_popup_menu = 0; -static Atom net_wm_window_type_tooltip = 0; -static Atom net_wm_window_type_notification = 0; -static Atom net_wm_window_type_combobox = 0; -static Atom net_wm_window_type_dnd = 0; - -// application window state -static Atom net_wm_state_modal = 0; -static Atom net_wm_state_sticky = 0; -static Atom net_wm_state_max_vert = 0; -static Atom net_wm_state_max_horiz = 0; -static Atom net_wm_state_shaded = 0; -static Atom net_wm_state_skip_taskbar = 0; -static Atom net_wm_state_skip_pager = 0; -static Atom net_wm_state_hidden = 0; -static Atom net_wm_state_fullscreen = 0; -static Atom net_wm_state_above = 0; -static Atom net_wm_state_below = 0; -static Atom net_wm_state_demands_attention = 0; - -// allowed actions -static Atom net_wm_action_move = 0; -static Atom net_wm_action_resize = 0; -static Atom net_wm_action_minimize = 0; -static Atom net_wm_action_shade = 0; -static Atom net_wm_action_stick = 0; -static Atom net_wm_action_max_vert = 0; -static Atom net_wm_action_max_horiz = 0; -static Atom net_wm_action_fullscreen = 0; -static Atom net_wm_action_change_desk = 0; -static Atom net_wm_action_close = 0; - -// KDE extension that's not in the specs - Replaced by state_above now? -static Atom net_wm_state_stays_on_top = 0; - -// used to determine whether application window is managed or not -static Atom xa_wm_state = 0; - -// ability flags -static Atom net_wm_full_placement = 0; - -static Bool netwm_atoms_created = False; -const unsigned long netwm_sendevent_mask = (SubstructureRedirectMask| - SubstructureNotifyMask); - - -const long MAX_PROP_SIZE = 100000; - -static char *nstrdup(const char *s1) { - if (! s1) return (char *) 0; - - int l = strlen(s1) + 1; - char *s2 = new char[l]; - strncpy(s2, s1, l); - return s2; -} - - -static char *nstrndup(const char *s1, int l) { - if (! s1 || l == 0) return (char *) 0; - - char *s2 = new char[l+1]; - strncpy(s2, s1, l); - s2[l] = '\0'; - return s2; -} - - -static Window *nwindup(Window *w1, int n) { - if (! w1 || n == 0) return (Window *) 0; - - Window *w2 = new Window[n]; - while (n--) w2[n] = w1[n]; - return w2; -} - - -static void refdec_nri(NETRootInfoPrivate *p) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NET: decrementing NETRootInfoPrivate::ref (%d)\n", p->ref - 1); -#endif - - if (! --p->ref) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NET: \tno more references, deleting\n"); -#endif - - delete [] p->name; - delete [] p->stacking; - delete [] p->clients; - delete [] p->virtual_roots; - delete [] p->kde_system_tray_windows; - - int i; - for (i = 0; i < p->desktop_names.size(); i++) - delete [] p->desktop_names[i]; - } -} - - -static void refdec_nwi(NETWinInfoPrivate *p) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NET: decrementing NETWinInfoPrivate::ref (%d)\n", p->ref - 1); -#endif - - if (! --p->ref) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NET: \tno more references, deleting\n"); -#endif - - delete [] p->name; - delete [] p->visible_name; - delete [] p->icon_name; - delete [] p->visible_icon_name; - delete [] p->startup_id; - - int i; - for (i = 0; i < p->icons.size(); i++) - delete [] p->icons[i].data; - } -} - - -static int wcmp(const void *a, const void *b) { - return *((Window *) a) - *((Window *) b); -} - - -static const int netAtomCount = 85; -static void create_atoms(Display *d) { - static const char * const names[netAtomCount] = - { - "UTF8_STRING", - "_NET_SUPPORTED", - "_NET_SUPPORTING_WM_CHECK", - "_NET_CLIENT_LIST", - "_NET_CLIENT_LIST_STACKING", - "_NET_NUMBER_OF_DESKTOPS", - "_NET_DESKTOP_GEOMETRY", - "_NET_DESKTOP_VIEWPORT", - "_NET_CURRENT_DESKTOP", - "_NET_DESKTOP_NAMES", - "_NET_ACTIVE_WINDOW", - "_NET_WORKAREA", - "_NET_VIRTUAL_ROOTS", - "_NET_DESKTOP_LAYOUT", - "_NET_SHOWING_DESKTOP", - "_NET_CLOSE_WINDOW", - "_NET_RESTACK_WINDOW", - - "_NET_WM_MOVERESIZE", - "_NET_MOVERESIZE_WINDOW", - "_NET_WM_NAME", - "_NET_WM_VISIBLE_NAME", - "_NET_WM_ICON_NAME", - "_NET_WM_VISIBLE_ICON_NAME", - "_NET_WM_DESKTOP", - "_NET_WM_WINDOW_TYPE", - "_NET_WM_STATE", - "_NET_WM_STRUT", - "_NET_WM_STRUT_PARTIAL", - "_NET_WM_ICON_GEOMETRY", - "_NET_WM_ICON", - "_NET_WM_PID", - "_NET_WM_USER_TIME", - "_NET_WM_HANDLED_ICONS", - "_NET_STARTUP_ID", - "_NET_WM_ALLOWED_ACTIONS", - "_NET_WM_PING", - "_NET_WM_TAKE_ACTIVITY", - "WM_WINDOW_ROLE", - "_NET_FRAME_EXTENTS", - - "_NET_WM_WINDOW_TYPE_NORMAL", - "_NET_WM_WINDOW_TYPE_DESKTOP", - "_NET_WM_WINDOW_TYPE_DOCK", - "_NET_WM_WINDOW_TYPE_TOOLBAR", - "_NET_WM_WINDOW_TYPE_MENU", - "_NET_WM_WINDOW_TYPE_DIALOG", - "_NET_WM_WINDOW_TYPE_UTILITY", - "_NET_WM_WINDOW_TYPE_SPLASH", - "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", - "_NET_WM_WINDOW_TYPE_POPUP_MENU", - "_NET_WM_WINDOW_TYPE_TOOLTIP", - "_NET_WM_WINDOW_TYPE_NOTIFICATION", - "_NET_WM_WINDOW_TYPE_COMBOBOX", - "_NET_WM_WINDOW_TYPE_DND", - - "_NET_WM_STATE_MODAL", - "_NET_WM_STATE_STICKY", - "_NET_WM_STATE_MAXIMIZED_VERT", - "_NET_WM_STATE_MAXIMIZED_HORZ", - "_NET_WM_STATE_SHADED", - "_NET_WM_STATE_SKIP_TASKBAR", - "_NET_WM_STATE_SKIP_PAGER", - "_NET_WM_STATE_HIDDEN", - "_NET_WM_STATE_FULLSCREEN", - "_NET_WM_STATE_ABOVE", - "_NET_WM_STATE_BELOW", - "_NET_WM_STATE_DEMANDS_ATTENTION", - - "_NET_WM_ACTION_MOVE", - "_NET_WM_ACTION_RESIZE", - "_NET_WM_ACTION_MINIMIZE", - "_NET_WM_ACTION_SHADE", - "_NET_WM_ACTION_STICK", - "_NET_WM_ACTION_MAXIMIZE_VERT", - "_NET_WM_ACTION_MAXIMIZE_HORZ", - "_NET_WM_ACTION_FULLSCREEN", - "_NET_WM_ACTION_CHANGE_DESKTOP", - "_NET_WM_ACTION_CLOSE", - - "_NET_WM_STATE_STAYS_ON_TOP", - - "_KDE_NET_SYSTEM_TRAY_WINDOWS", - "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", - "_KDE_NET_WM_FRAME_STRUT", - "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", - "_KDE_NET_WM_WINDOW_TYPE_TOPMENU", - "_KDE_NET_WM_TEMPORARY_RULES", - - "WM_STATE", - "WM_PROTOCOLS", - - "_NET_WM_FULL_PLACEMENT" - }; - - Atom atoms[netAtomCount], *atomsp[netAtomCount] = - { - &UTF8_STRING, - &net_supported, - &net_supporting_wm_check, - &net_client_list, - &net_client_list_stacking, - &net_number_of_desktops, - &net_desktop_geometry, - &net_desktop_viewport, - &net_current_desktop, - &net_desktop_names, - &net_active_window, - &net_workarea, - &net_virtual_roots, - &net_desktop_layout, - &net_showing_desktop, - &net_close_window, - &net_restack_window, - - &net_wm_moveresize, - &net_moveresize_window, - &net_wm_name, - &net_wm_visible_name, - &net_wm_icon_name, - &net_wm_visible_icon_name, - &net_wm_desktop, - &net_wm_window_type, - &net_wm_state, - &net_wm_strut, - &net_wm_extended_strut, - &net_wm_icon_geometry, - &net_wm_icon, - &net_wm_pid, - &net_wm_user_time, - &net_wm_handled_icons, - &net_startup_id, - &net_wm_allowed_actions, - &net_wm_ping, - &net_wm_take_activity, - &wm_window_role, - &net_frame_extents, - - &net_wm_window_type_normal, - &net_wm_window_type_desktop, - &net_wm_window_type_dock, - &net_wm_window_type_toolbar, - &net_wm_window_type_menu, - &net_wm_window_type_dialog, - &net_wm_window_type_utility, - &net_wm_window_type_splash, - &net_wm_window_type_dropdown_menu, - &net_wm_window_type_popup_menu, - &net_wm_window_type_tooltip, - &net_wm_window_type_notification, - &net_wm_window_type_combobox, - &net_wm_window_type_dnd, - - &net_wm_state_modal, - &net_wm_state_sticky, - &net_wm_state_max_vert, - &net_wm_state_max_horiz, - &net_wm_state_shaded, - &net_wm_state_skip_taskbar, - &net_wm_state_skip_pager, - &net_wm_state_hidden, - &net_wm_state_fullscreen, - &net_wm_state_above, - &net_wm_state_below, - &net_wm_state_demands_attention, - - &net_wm_action_move, - &net_wm_action_resize, - &net_wm_action_minimize, - &net_wm_action_shade, - &net_wm_action_stick, - &net_wm_action_max_vert, - &net_wm_action_max_horiz, - &net_wm_action_fullscreen, - &net_wm_action_change_desk, - &net_wm_action_close, - - &net_wm_state_stays_on_top, - - &kde_net_system_tray_windows, - &kde_net_wm_system_tray_window_for, - &kde_net_wm_frame_strut, - &kde_net_wm_window_type_override, - &kde_net_wm_window_type_topmenu, - &kde_net_wm_temporary_rules, - - &xa_wm_state, - &wm_protocols, - - &net_wm_full_placement - }; - - assert( !netwm_atoms_created ); - - int i = netAtomCount; - while (i--) - atoms[i] = 0; - - XInternAtoms(d, (char **) names, netAtomCount, False, atoms); - - i = netAtomCount; - while (i--) - *atomsp[i] = atoms[i]; - - netwm_atoms_created = True; -} - - -static void readIcon(Display* display, Window window, Atom property, NETRArray<NETIcon>& icons, int& icon_count) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NET: readIcon\n"); -#endif - - Atom type_ret; - int format_ret; - unsigned long nitems_ret = 0, after_ret = 0; - unsigned char *data_ret = 0; - - // reset - for (int i = 0; i < icons.size(); i++) - delete [] icons[i].data; - icons.reset(); - icon_count = 0; - - // allocate buffers - unsigned char *buffer = 0; - unsigned long offset = 0; - unsigned long buffer_offset = 0; - unsigned long bufsize = 0; - - // read data - do { - if (XGetWindowProperty(display, window, property, offset, - MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret, - &format_ret, &nitems_ret, &after_ret, &data_ret) - == Success) { - if (!bufsize) - { - if (nitems_ret < 3 || type_ret != XA_CARDINAL || - format_ret != 32) { - // either we didn't get the property, or the property has less than - // 3 elements in it - // NOTE: 3 is the ABSOLUTE minimum: - // width = 1, height = 1, length(data) = 1 (width * height) - if ( data_ret ) - XFree(data_ret); - return; - } - - bufsize = nitems_ret * sizeof(long) + after_ret; - buffer = (unsigned char *) malloc(bufsize); - } - else if (buffer_offset + nitems_ret*sizeof(long) > bufsize) - { -fprintf(stderr, "NETWM: Warning readIcon() needs buffer adjustment!\n"); - bufsize = buffer_offset + nitems_ret * sizeof(long) + after_ret; - buffer = (unsigned char *) realloc(buffer, bufsize); - } - memcpy((buffer + buffer_offset), data_ret, nitems_ret * sizeof(long)); - buffer_offset += nitems_ret * sizeof(long); - offset += nitems_ret; - - if ( data_ret ) - XFree(data_ret); - } else { - if (buffer) - free(buffer); - return; // Some error occurred cq. property didn't exist. - } - } - while (after_ret > 0); - - CARD32 *data32; - unsigned long i, j, k, sz, s; - unsigned long *d = (unsigned long *) buffer; - for (i = 0, j = 0; i < bufsize;) { - icons[j].size.width = *d++; - i += sizeof(long); - icons[j].size.height = *d++; - i += sizeof(long); - - sz = icons[j].size.width * icons[j].size.height; - s = sz * sizeof(long); - - if ( i + s - 1 > bufsize || sz == 0 || sz > 1024 * 1024 ) { - break; - } - - delete [] icons[j].data; - data32 = new CARD32[sz]; - icons[j].data = (unsigned char *) data32; - for (k = 0; k < sz; k++, i += sizeof(long)) { - *data32++ = (CARD32) *d++; - } - j++; - icon_count++; - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NET: readIcon got %d icons\n", icon_count); -#endif - - free(buffer); -} - - -template <class Z> -NETRArray<Z>::NETRArray() - : sz(0), capacity(2) -{ - d = (Z*) calloc(capacity, sizeof(Z)); // allocate 2 elts and set to zero -} - - -template <class Z> -NETRArray<Z>::~NETRArray() { - free(d); -} - - -template <class Z> -void NETRArray<Z>::reset() { - sz = 0; - capacity = 2; - d = (Z*) realloc(d, sizeof(Z)*capacity); - memset( (void*) d, 0, sizeof(Z)*capacity ); -} - -template <class Z> -Z &NETRArray<Z>::operator[](int index) { - if (index >= capacity) { - // allocate space for the new data - // open table has amortized O(1) access time - // when N elements appended consecutively -- exa - int newcapacity = 2*capacity > index+1 ? 2*capacity : index+1; // max - // copy into new larger memory block using realloc - d = (Z*) realloc(d, sizeof(Z)*newcapacity); - memset( (void*) &d[capacity], 0, sizeof(Z)*(newcapacity-capacity) ); - capacity = newcapacity; - } - if (index >= sz) // at this point capacity>index - sz = index + 1; - - return d[index]; -} - - -// Construct a new NETRootInfo object. - -NETRootInfo::NETRootInfo(Display *display, Window supportWindow, const char *wmName, - const unsigned long properties[], int properties_size, - int screen, bool doActivate) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::NETRootInfo: using window manager constructor\n"); -#endif - - p = new NETRootInfoPrivate; - p->ref = 1; - - p->display = display; - p->name = nstrdup(wmName); - - if (screen != -1) { - p->screen = screen; - } else { - p->screen = DefaultScreen(p->display); - } - - p->root = RootWindow(p->display, p->screen); - p->supportwindow = supportWindow; - p->number_of_desktops = p->current_desktop = 0; - p->active = None; - p->clients = p->stacking = p->virtual_roots = (Window *) 0; - p->clients_count = p->stacking_count = p->virtual_roots_count = 0; - p->kde_system_tray_windows = 0; - p->kde_system_tray_windows_count = 0; - p->showing_desktop = false; - p->desktop_layout_orientation = OrientationHorizontal; - p->desktop_layout_corner = DesktopLayoutCornerTopLeft; - p->desktop_layout_columns = p->desktop_layout_rows = 0; - setDefaultProperties(); - if( properties_size > PROPERTIES_SIZE ) { - fprintf( stderr, "NETRootInfo::NETRootInfo(): properties array too large\n"); - properties_size = PROPERTIES_SIZE; - } - for( int i = 0; i < properties_size; ++i ) - p->properties[ i ] = properties[ i ]; - // force support for Supported and SupportingWMCheck for window managers - p->properties[ PROTOCOLS ] |= ( Supported | SupportingWMCheck ); - p->client_properties[ PROTOCOLS ] = DesktopNames // the only thing that can be changed by clients - | WMPing; // or they can reply to this - p->client_properties[ PROTOCOLS2 ] = WM2TakeActivity | WM2DesktopLayout; - - role = WindowManager; - - if (! netwm_atoms_created) create_atoms(p->display); - - if (doActivate) activate(); -} - -NETRootInfo::NETRootInfo(Display *display, Window supportWindow, const char *wmName, - unsigned long properties, int screen, bool doActivate) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::NETRootInfo: using window manager constructor\n"); -#endif - - p = new NETRootInfoPrivate; - p->ref = 1; - - p->display = display; - p->name = nstrdup(wmName); - - if (screen != -1) { - p->screen = screen; - } else { - p->screen = DefaultScreen(p->display); - } - - p->root = RootWindow(p->display, p->screen); - p->supportwindow = supportWindow; - p->number_of_desktops = p->current_desktop = 0; - p->active = None; - p->clients = p->stacking = p->virtual_roots = (Window *) 0; - p->clients_count = p->stacking_count = p->virtual_roots_count = 0; - p->kde_system_tray_windows = 0; - p->kde_system_tray_windows_count = 0; - p->showing_desktop = false; - setDefaultProperties(); - p->properties[ PROTOCOLS ] = properties; - // force support for Supported and SupportingWMCheck for window managers - p->properties[ PROTOCOLS ] |= ( Supported | SupportingWMCheck ); - p->client_properties[ PROTOCOLS ] = DesktopNames // the only thing that can be changed by clients - | WMPing; // or they can reply to this - p->client_properties[ PROTOCOLS2 ] = WM2TakeActivity; - - role = WindowManager; - - if (! netwm_atoms_created) create_atoms(p->display); - - if (doActivate) activate(); -} - - -NETRootInfo::NETRootInfo(Display *display, const unsigned long properties[], int properties_size, - int screen, bool doActivate) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::NETRootInfo: using Client constructor\n"); -#endif - - p = new NETRootInfoPrivate; - p->ref = 1; - - p->name = 0; - - p->display = display; - - if (screen != -1) { - p->screen = screen; - } else { - p->screen = DefaultScreen(p->display); - } - - p->root = RootWindow(p->display, p->screen); - p->rootSize.width = WidthOfScreen(ScreenOfDisplay(p->display, p->screen)); - p->rootSize.height = HeightOfScreen(ScreenOfDisplay(p->display, p->screen)); - - p->supportwindow = None; - p->number_of_desktops = p->current_desktop = 0; - p->active = None; - p->clients = p->stacking = p->virtual_roots = (Window *) 0; - p->clients_count = p->stacking_count = p->virtual_roots_count = 0; - p->kde_system_tray_windows = 0; - p->kde_system_tray_windows_count = 0; - p->showing_desktop = false; - p->desktop_layout_orientation = OrientationHorizontal; - p->desktop_layout_corner = DesktopLayoutCornerTopLeft; - p->desktop_layout_columns = p->desktop_layout_rows = 0; - setDefaultProperties(); - if( properties_size > 2 ) { - fprintf( stderr, "NETWinInfo::NETWinInfo(): properties array too large\n"); - properties_size = 2; - } - for( int i = 0; i < properties_size; ++i ) - // remap from [0]=NET::Property,[1]=NET::Property2 - switch( i ) { - case 0: - p->client_properties[ PROTOCOLS ] = properties[ i ]; - break; - case 1: - p->client_properties[ PROTOCOLS2 ] = properties[ i ]; - break; - } - for( int i = 0; i < PROPERTIES_SIZE; ++i ) - p->properties[ i ] = 0; - - role = Client; - - if (! netwm_atoms_created) create_atoms(p->display); - - if (doActivate) activate(); -} - -NETRootInfo::NETRootInfo(Display *display, unsigned long properties, int screen, - bool doActivate) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::NETRootInfo: using Client constructor\n"); -#endif - - p = new NETRootInfoPrivate; - p->ref = 1; - - p->name = 0; - - p->display = display; - - if (screen != -1) { - p->screen = screen; - } else { - p->screen = DefaultScreen(p->display); - } - - p->root = RootWindow(p->display, p->screen); - p->rootSize.width = WidthOfScreen(ScreenOfDisplay(p->display, p->screen)); - p->rootSize.height = HeightOfScreen(ScreenOfDisplay(p->display, p->screen)); - - p->supportwindow = None; - p->number_of_desktops = p->current_desktop = 0; - p->active = None; - p->clients = p->stacking = p->virtual_roots = (Window *) 0; - p->clients_count = p->stacking_count = p->virtual_roots_count = 0; - p->kde_system_tray_windows = 0; - p->kde_system_tray_windows_count = 0; - p->showing_desktop = false; - p->desktop_layout_orientation = OrientationHorizontal; - p->desktop_layout_corner = DesktopLayoutCornerTopLeft; - p->desktop_layout_columns = p->desktop_layout_rows = 0; - setDefaultProperties(); - p->client_properties[ PROTOCOLS ] = properties; - for( int i = 0; i < PROPERTIES_SIZE; ++i ) - p->properties[ i ] = 0; - - role = Client; - - if (! netwm_atoms_created) create_atoms(p->display); - - if (doActivate) activate(); -} - - -NETRootInfo2::NETRootInfo2(Display *display, Window supportWindow, const char *wmName, - unsigned long properties[], int properties_size, - int screen, bool doActivate) - : NETRootInfo( display, supportWindow, wmName, properties, properties_size, - screen, doActivate ) -{ -} - -NETRootInfo2::NETRootInfo2(Display *display, const unsigned long properties[], int properties_size, - int screen, bool doActivate) - : NETRootInfo( display, properties, properties_size, screen, doActivate ) -{ -} - -NETRootInfo3::NETRootInfo3(Display *display, Window supportWindow, const char *wmName, - unsigned long properties[], int properties_size, - int screen, bool doActivate) - : NETRootInfo2( display, supportWindow, wmName, properties, properties_size, - screen, doActivate ) -{ -} - -NETRootInfo3::NETRootInfo3(Display *display, const unsigned long properties[], int properties_size, - int screen, bool doActivate) - : NETRootInfo2( display, properties, properties_size, screen, doActivate ) -{ -} - -NETRootInfo4::NETRootInfo4(Display *display, Window supportWindow, const char *wmName, - unsigned long properties[], int properties_size, - int screen, bool doActivate) - : NETRootInfo3( display, supportWindow, wmName, properties, properties_size, - screen, doActivate ) -{ -} - -NETRootInfo4::NETRootInfo4(Display *display, const unsigned long properties[], int properties_size, - int screen, bool doActivate) - : NETRootInfo3( display, properties, properties_size, screen, doActivate ) -{ -} - -// Copy an existing NETRootInfo object. - -NETRootInfo::NETRootInfo(const NETRootInfo &rootinfo) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::NETRootInfo: using copy constructor\n"); -#endif - - p = rootinfo.p; - role = rootinfo.role; - - p->ref++; -} - - -// Be gone with our NETRootInfo. - -NETRootInfo::~NETRootInfo() { - refdec_nri(p); - - if (! p->ref) delete p; -} - - -void NETRootInfo::setDefaultProperties() -{ - p->properties[ PROTOCOLS ] = Supported | SupportingWMCheck; - p->properties[ WINDOW_TYPES ] = NormalMask | DesktopMask | DockMask - | ToolbarMask | MenuMask | DialogMask; - p->properties[ STATES ] = Modal | Sticky | MaxVert | MaxHoriz | Shaded - | SkipTaskbar | StaysOnTop; - p->properties[ PROTOCOLS2 ] = 0; - p->properties[ ACTIONS ] = 0; - p->client_properties[ PROTOCOLS ] = 0; - p->client_properties[ WINDOW_TYPES ] = 0; // these two actually don't - p->client_properties[ STATES ] = 0; // make sense in client_properties - p->client_properties[ PROTOCOLS2 ] = 0; - p->client_properties[ ACTIONS ] = 0; -} - -void NETRootInfo::activate() { - if (role == WindowManager) { - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::activate: setting supported properties on root\n"); -#endif - - setSupported(); - update(p->client_properties); - } else { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::activate: updating client information\n"); -#endif - - update(p->client_properties); - } -} - - -void NETRootInfo::setClientList(Window *windows, unsigned int count) { - if (role != WindowManager) return; - - p->clients_count = count; - - delete [] p->clients; - p->clients = nwindup(windows, count); - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setClientList: setting list with %ld windows\n", - p->clients_count); -#endif - - XChangeProperty(p->display, p->root, net_client_list, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)p->clients, - p->clients_count); -} - - -void NETRootInfo::setClientListStacking(Window *windows, unsigned int count) { - if (role != WindowManager) return; - - p->stacking_count = count; - delete [] p->stacking; - p->stacking = nwindup(windows, count); - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::setClientListStacking: setting list with %ld windows\n", - p->clients_count); -#endif - - XChangeProperty(p->display, p->root, net_client_list_stacking, XA_WINDOW, 32, - PropModeReplace, (unsigned char *) p->stacking, - p->stacking_count); -} - - -void NETRootInfo::setKDESystemTrayWindows(Window *windows, unsigned int count) { - if (role != WindowManager) return; - - p->kde_system_tray_windows_count = count; - delete [] p->kde_system_tray_windows; - p->kde_system_tray_windows = nwindup(windows, count); - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::setKDESystemTrayWindows: setting list with %ld windows\n", - p->kde_system_tray_windows_count); -#endif - - XChangeProperty(p->display, p->root, kde_net_system_tray_windows, XA_WINDOW, 32, - PropModeReplace, - (unsigned char *) p->kde_system_tray_windows, - p->kde_system_tray_windows_count); -} - - -void NETRootInfo::setNumberOfDesktops(int numberOfDesktops) { - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::setNumberOfDesktops: setting desktop count to %d (%s)\n", - numberOfDesktops, (role == WindowManager) ? "WM" : "Client"); -#endif - - if (role == WindowManager) { - p->number_of_desktops = numberOfDesktops; - long d = numberOfDesktops; - XChangeProperty(p->display, p->root, net_number_of_desktops, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); - } else { - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_number_of_desktops; - e.xclient.display = p->display; - e.xclient.window = p->root; - e.xclient.format = 32; - e.xclient.data.l[0] = numberOfDesktops; - e.xclient.data.l[1] = 0l; - e.xclient.data.l[2] = 0l; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } -} - - -void NETRootInfo::setCurrentDesktop(int desktop) { - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::setCurrentDesktop: setting current desktop = %d (%s)\n", - desktop, (role == WindowManager) ? "WM" : "Client"); -#endif - - if (role == WindowManager) { - p->current_desktop = desktop; - long d = p->current_desktop - 1; - XChangeProperty(p->display, p->root, net_current_desktop, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); - } else { - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_current_desktop; - e.xclient.display = p->display; - e.xclient.window = p->root; - e.xclient.format = 32; - e.xclient.data.l[0] = desktop - 1; - e.xclient.data.l[1] = 0l; - e.xclient.data.l[2] = 0l; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } -} - - -void NETRootInfo::setDesktopName(int desktop, const char *desktopName) { - // allow setting desktop names even for non-existant desktops, see the spec, sect.3.7. - if (desktop < 1) return; - - delete [] p->desktop_names[desktop - 1]; - p->desktop_names[desktop - 1] = nstrdup(desktopName); - - unsigned int i, proplen, - num = ((p->number_of_desktops > p->desktop_names.size()) ? - p->number_of_desktops : p->desktop_names.size()); - for (i = 0, proplen = 0; i < num; i++) - proplen += (p->desktop_names[i] != 0 ? strlen(p->desktop_names[i])+1 : 1 ); - - char *prop = new char[proplen], *propp = prop; - - for (i = 0; i < num; i++) - if (p->desktop_names[i]) { - strcpy(propp, p->desktop_names[i]); - propp += strlen(p->desktop_names[i]) + 1; - } else - *propp++ = '\0'; - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::setDesktopName(%d, '%s')\n" - "NETRootInfo::setDesktopName: total property length = %d", - desktop, desktopName, proplen); -#endif - - XChangeProperty(p->display, p->root, net_desktop_names, UTF8_STRING, 8, - PropModeReplace, (unsigned char *) prop, proplen); - - delete [] prop; -} - - -void NETRootInfo::setDesktopGeometry(int , const NETSize &geometry) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setDesktopGeometry( -- , { %d, %d }) (%s)\n", - geometry.width, geometry.height, (role == WindowManager) ? "WM" : "Client"); -#endif - - if (role == WindowManager) { - p->geometry = geometry; - - long data[2]; - data[0] = p->geometry.width; - data[1] = p->geometry.height; - - XChangeProperty(p->display, p->root, net_desktop_geometry, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) data, 2); - } else { - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_desktop_geometry; - e.xclient.display = p->display; - e.xclient.window = p->root; - e.xclient.format = 32; - e.xclient.data.l[0] = geometry.width; - e.xclient.data.l[1] = geometry.height; - e.xclient.data.l[2] = 0l; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } -} - - -void NETRootInfo::setDesktopViewport(int desktop, const NETPoint &viewport) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setDesktopViewport(%d, { %d, %d }) (%s)\n", - desktop, viewport.x, viewport.y, (role == WindowManager) ? "WM" : "Client"); -#endif - - if (desktop < 1) return; - - if (role == WindowManager) { - p->viewport[desktop - 1] = viewport; - - int d, i, l; - l = p->number_of_desktops * 2; - long *data = new long[l]; - for (d = 0, i = 0; d < p->number_of_desktops; d++) { - data[i++] = p->viewport[d].x; - data[i++] = p->viewport[d].y; - } - - XChangeProperty(p->display, p->root, net_desktop_viewport, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) data, l); - - delete [] data; - } else { - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_desktop_viewport; - e.xclient.display = p->display; - e.xclient.window = p->root; - e.xclient.format = 32; - e.xclient.data.l[0] = viewport.x; - e.xclient.data.l[1] = viewport.y; - e.xclient.data.l[2] = 0l; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } -} - - -void NETRootInfo::setSupported() { - if (role != WindowManager) { -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setSupported - role != WindowManager\n"); -#endif - - return; - } - - Atom atoms[netAtomCount]; - int pnum = 2; - - // Root window properties/messages - atoms[0] = net_supported; - atoms[1] = net_supporting_wm_check; - - if (p->properties[ PROTOCOLS ] & ClientList) - atoms[pnum++] = net_client_list; - - if (p->properties[ PROTOCOLS ] & ClientListStacking) - atoms[pnum++] = net_client_list_stacking; - - if (p->properties[ PROTOCOLS ] & NumberOfDesktops) - atoms[pnum++] = net_number_of_desktops; - - if (p->properties[ PROTOCOLS ] & DesktopGeometry) - atoms[pnum++] = net_desktop_geometry; - - if (p->properties[ PROTOCOLS ] & DesktopViewport) - atoms[pnum++] = net_desktop_viewport; - - if (p->properties[ PROTOCOLS ] & CurrentDesktop) - atoms[pnum++] = net_current_desktop; - - if (p->properties[ PROTOCOLS ] & DesktopNames) - atoms[pnum++] = net_desktop_names; - - if (p->properties[ PROTOCOLS ] & ActiveWindow) - atoms[pnum++] = net_active_window; - - if (p->properties[ PROTOCOLS ] & WorkArea) - atoms[pnum++] = net_workarea; - - if (p->properties[ PROTOCOLS ] & VirtualRoots) - atoms[pnum++] = net_virtual_roots; - - if (p->properties[ PROTOCOLS2 ] & WM2DesktopLayout) - atoms[pnum++] = net_desktop_layout; - - if (p->properties[ PROTOCOLS ] & CloseWindow) - atoms[pnum++] = net_close_window; - - if (p->properties[ PROTOCOLS2 ] & WM2RestackWindow) - atoms[pnum++] = net_restack_window; - - if (p->properties[ PROTOCOLS2 ] & WM2ShowingDesktop) - atoms[pnum++] = net_showing_desktop; - - // Application window properties/messages - if (p->properties[ PROTOCOLS ] & WMMoveResize) - atoms[pnum++] = net_wm_moveresize; - - if (p->properties[ PROTOCOLS2 ] & WM2MoveResizeWindow) - atoms[pnum++] = net_moveresize_window; - - if (p->properties[ PROTOCOLS ] & WMName) - atoms[pnum++] = net_wm_name; - - if (p->properties[ PROTOCOLS ] & WMVisibleName) - atoms[pnum++] = net_wm_visible_name; - - if (p->properties[ PROTOCOLS ] & WMIconName) - atoms[pnum++] = net_wm_icon_name; - - if (p->properties[ PROTOCOLS ] & WMVisibleIconName) - atoms[pnum++] = net_wm_visible_icon_name; - - if (p->properties[ PROTOCOLS ] & WMDesktop) - atoms[pnum++] = net_wm_desktop; - - if (p->properties[ PROTOCOLS ] & WMWindowType) { - atoms[pnum++] = net_wm_window_type; - - // Application window types - if (p->properties[ WINDOW_TYPES ] & NormalMask) - atoms[pnum++] = net_wm_window_type_normal; - if (p->properties[ WINDOW_TYPES ] & DesktopMask) - atoms[pnum++] = net_wm_window_type_desktop; - if (p->properties[ WINDOW_TYPES ] & DockMask) - atoms[pnum++] = net_wm_window_type_dock; - if (p->properties[ WINDOW_TYPES ] & ToolbarMask) - atoms[pnum++] = net_wm_window_type_toolbar; - if (p->properties[ WINDOW_TYPES ] & MenuMask) - atoms[pnum++] = net_wm_window_type_menu; - if (p->properties[ WINDOW_TYPES ] & DialogMask) - atoms[pnum++] = net_wm_window_type_dialog; - if (p->properties[ WINDOW_TYPES ] & UtilityMask) - atoms[pnum++] = net_wm_window_type_utility; - if (p->properties[ WINDOW_TYPES ] & SplashMask) - atoms[pnum++] = net_wm_window_type_splash; - if (p->properties[ WINDOW_TYPES ] & DropdownMenuMask) - atoms[pnum++] = net_wm_window_type_dropdown_menu; - if (p->properties[ WINDOW_TYPES ] & PopupMenuMask) - atoms[pnum++] = net_wm_window_type_popup_menu; - if (p->properties[ WINDOW_TYPES ] & TooltipMask) - atoms[pnum++] = net_wm_window_type_tooltip; - if (p->properties[ WINDOW_TYPES ] & NotificationMask) - atoms[pnum++] = net_wm_window_type_notification; - if (p->properties[ WINDOW_TYPES ] & ComboBoxMask) - atoms[pnum++] = net_wm_window_type_combobox; - if (p->properties[ WINDOW_TYPES ] & DNDIconMask) - atoms[pnum++] = net_wm_window_type_dnd; - // KDE extensions - if (p->properties[ WINDOW_TYPES ] & OverrideMask) - atoms[pnum++] = kde_net_wm_window_type_override; - if (p->properties[ WINDOW_TYPES ] & TopMenuMask) - atoms[pnum++] = kde_net_wm_window_type_topmenu; - } - - if (p->properties[ PROTOCOLS ] & WMState) { - atoms[pnum++] = net_wm_state; - - // Application window states - if (p->properties[ STATES ] & Modal) - atoms[pnum++] = net_wm_state_modal; - if (p->properties[ STATES ] & Sticky) - atoms[pnum++] = net_wm_state_sticky; - if (p->properties[ STATES ] & MaxVert) - atoms[pnum++] = net_wm_state_max_vert; - if (p->properties[ STATES ] & MaxHoriz) - atoms[pnum++] = net_wm_state_max_horiz; - if (p->properties[ STATES ] & Shaded) - atoms[pnum++] = net_wm_state_shaded; - if (p->properties[ STATES ] & SkipTaskbar) - atoms[pnum++] = net_wm_state_skip_taskbar; - if (p->properties[ STATES ] & SkipPager) - atoms[pnum++] = net_wm_state_skip_pager; - if (p->properties[ STATES ] & Hidden) - atoms[pnum++] = net_wm_state_hidden; - if (p->properties[ STATES ] & FullScreen) - atoms[pnum++] = net_wm_state_fullscreen; - if (p->properties[ STATES ] & KeepAbove) - atoms[pnum++] = net_wm_state_above; - if (p->properties[ STATES ] & KeepBelow) - atoms[pnum++] = net_wm_state_below; - if (p->properties[ STATES ] & DemandsAttention) - atoms[pnum++] = net_wm_state_demands_attention; - - if (p->properties[ STATES ] & StaysOnTop) - atoms[pnum++] = net_wm_state_stays_on_top; - } - - if (p->properties[ PROTOCOLS ] & WMStrut) - atoms[pnum++] = net_wm_strut; - - if (p->properties[ PROTOCOLS2 ] & WM2ExtendedStrut) - atoms[pnum++] = net_wm_extended_strut; - - if (p->properties[ PROTOCOLS ] & WMIconGeometry) - atoms[pnum++] = net_wm_icon_geometry; - - if (p->properties[ PROTOCOLS ] & WMIcon) - atoms[pnum++] = net_wm_icon; - - if (p->properties[ PROTOCOLS ] & WMPid) - atoms[pnum++] = net_wm_pid; - - if (p->properties[ PROTOCOLS ] & WMHandledIcons) - atoms[pnum++] = net_wm_handled_icons; - - if (p->properties[ PROTOCOLS ] & WMPing) - atoms[pnum++] = net_wm_ping; - - if (p->properties[ PROTOCOLS2 ] & WM2TakeActivity) - atoms[pnum++] = net_wm_take_activity; - - if (p->properties[ PROTOCOLS2 ] & WM2UserTime) - atoms[pnum++] = net_wm_user_time; - - if (p->properties[ PROTOCOLS2 ] & WM2StartupId) - atoms[pnum++] = net_startup_id; - - if (p->properties[ PROTOCOLS2 ] & WM2AllowedActions) { - atoms[pnum++] = net_wm_allowed_actions; - - // Actions - if (p->properties[ ACTIONS ] & ActionMove) - atoms[pnum++] = net_wm_action_move; - if (p->properties[ ACTIONS ] & ActionResize) - atoms[pnum++] = net_wm_action_resize; - if (p->properties[ ACTIONS ] & ActionMinimize) - atoms[pnum++] = net_wm_action_minimize; - if (p->properties[ ACTIONS ] & ActionShade) - atoms[pnum++] = net_wm_action_shade; - if (p->properties[ ACTIONS ] & ActionStick) - atoms[pnum++] = net_wm_action_stick; - if (p->properties[ ACTIONS ] & ActionMaxVert) - atoms[pnum++] = net_wm_action_max_vert; - if (p->properties[ ACTIONS ] & ActionMaxHoriz) - atoms[pnum++] = net_wm_action_max_horiz; - if (p->properties[ ACTIONS ] & ActionFullScreen) - atoms[pnum++] = net_wm_action_fullscreen; - if (p->properties[ ACTIONS ] & ActionChangeDesktop) - atoms[pnum++] = net_wm_action_change_desk; - if (p->properties[ ACTIONS ] & ActionClose) - atoms[pnum++] = net_wm_action_close; - } - - // KDE specific extensions - if (p->properties[ PROTOCOLS ] & KDESystemTrayWindows) - atoms[pnum++] = kde_net_system_tray_windows; - - if (p->properties[ PROTOCOLS ] & WMKDESystemTrayWinFor) - atoms[pnum++] = kde_net_wm_system_tray_window_for; - - if (p->properties[ PROTOCOLS ] & WMFrameExtents) { - atoms[pnum++] = net_frame_extents; - atoms[pnum++] = kde_net_wm_frame_strut; - } - - if (p->properties[ PROTOCOLS2 ] & WM2KDETemporaryRules) - atoms[pnum++] = kde_net_wm_temporary_rules; - if (p->properties[ PROTOCOLS2 ] & WM2FullPlacement) - atoms[pnum++] = net_wm_full_placement; - - XChangeProperty(p->display, p->root, net_supported, XA_ATOM, 32, - PropModeReplace, (unsigned char *) atoms, pnum); - XChangeProperty(p->display, p->root, net_supporting_wm_check, XA_WINDOW, 32, - PropModeReplace, (unsigned char *) &(p->supportwindow), 1); - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::setSupported: _NET_SUPPORTING_WM_CHECK = 0x%lx on 0x%lx\n" - " : _NET_WM_NAME = '%s' on 0x%lx\n", - p->supportwindow, p->supportwindow, p->name, p->supportwindow); -#endif - - XChangeProperty(p->display, p->supportwindow, net_supporting_wm_check, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *) &(p->supportwindow), 1); - XChangeProperty(p->display, p->supportwindow, net_wm_name, UTF8_STRING, 8, - PropModeReplace, (unsigned char *) p->name, - strlen(p->name)); -} - -void NETRootInfo::updateSupportedProperties( Atom atom ) -{ - if( atom == net_supported ) - p->properties[ PROTOCOLS ] |= Supported; - - else if( atom == net_supporting_wm_check ) - p->properties[ PROTOCOLS ] |= SupportingWMCheck; - - else if( atom == net_client_list ) - p->properties[ PROTOCOLS ] |= ClientList; - - else if( atom == net_client_list_stacking ) - p->properties[ PROTOCOLS ] |= ClientListStacking; - - else if( atom == net_number_of_desktops ) - p->properties[ PROTOCOLS ] |= NumberOfDesktops; - - else if( atom == net_desktop_geometry ) - p->properties[ PROTOCOLS ] |= DesktopGeometry; - - else if( atom == net_desktop_viewport ) - p->properties[ PROTOCOLS ] |= DesktopViewport; - - else if( atom == net_current_desktop ) - p->properties[ PROTOCOLS ] |= CurrentDesktop; - - else if( atom == net_desktop_names ) - p->properties[ PROTOCOLS ] |= DesktopNames; - - else if( atom == net_active_window ) - p->properties[ PROTOCOLS ] |= ActiveWindow; - - else if( atom == net_workarea ) - p->properties[ PROTOCOLS ] |= WorkArea; - - else if( atom == net_virtual_roots ) - p->properties[ PROTOCOLS ] |= VirtualRoots; - - else if( atom == net_desktop_layout ) - p->properties[ PROTOCOLS2 ] |= WM2DesktopLayout; - - else if( atom == net_close_window ) - p->properties[ PROTOCOLS ] |= CloseWindow; - - else if( atom == net_restack_window ) - p->properties[ PROTOCOLS2 ] |= WM2RestackWindow; - - else if( atom == net_showing_desktop ) - p->properties[ PROTOCOLS2 ] |= WM2ShowingDesktop; - - // Application window properties/messages - else if( atom == net_wm_moveresize ) - p->properties[ PROTOCOLS ] |= WMMoveResize; - - else if( atom == net_moveresize_window ) - p->properties[ PROTOCOLS2 ] |= WM2MoveResizeWindow; - - else if( atom == net_wm_name ) - p->properties[ PROTOCOLS ] |= WMName; - - else if( atom == net_wm_visible_name ) - p->properties[ PROTOCOLS ] |= WMVisibleName; - - else if( atom == net_wm_icon_name ) - p->properties[ PROTOCOLS ] |= WMIconName; - - else if( atom == net_wm_visible_icon_name ) - p->properties[ PROTOCOLS ] |= WMVisibleIconName; - - else if( atom == net_wm_desktop ) - p->properties[ PROTOCOLS ] |= WMDesktop; - - else if( atom == net_wm_window_type ) - p->properties[ PROTOCOLS ] |= WMWindowType; - - // Application window types - else if( atom == net_wm_window_type_normal ) - p->properties[ WINDOW_TYPES ] |= NormalMask; - else if( atom == net_wm_window_type_desktop ) - p->properties[ WINDOW_TYPES ] |= DesktopMask; - else if( atom == net_wm_window_type_dock ) - p->properties[ WINDOW_TYPES ] |= DockMask; - else if( atom == net_wm_window_type_toolbar ) - p->properties[ WINDOW_TYPES ] |= ToolbarMask; - else if( atom == net_wm_window_type_menu ) - p->properties[ WINDOW_TYPES ] |= MenuMask; - else if( atom == net_wm_window_type_dialog ) - p->properties[ WINDOW_TYPES ] |= DialogMask; - else if( atom == net_wm_window_type_utility ) - p->properties[ WINDOW_TYPES ] |= UtilityMask; - else if( atom == net_wm_window_type_splash ) - p->properties[ WINDOW_TYPES ] |= SplashMask; - else if( atom == net_wm_window_type_dropdown_menu ) - p->properties[ WINDOW_TYPES ] |= DropdownMenuMask; - else if( atom == net_wm_window_type_popup_menu ) - p->properties[ WINDOW_TYPES ] |= PopupMenuMask; - else if( atom == net_wm_window_type_tooltip ) - p->properties[ WINDOW_TYPES ] |= TooltipMask; - else if( atom == net_wm_window_type_notification ) - p->properties[ WINDOW_TYPES ] |= NotificationMask; - else if( atom == net_wm_window_type_combobox ) - p->properties[ WINDOW_TYPES ] |= ComboBoxMask; - else if( atom == net_wm_window_type_dnd ) - p->properties[ WINDOW_TYPES ] |= DNDIconMask; - // KDE extensions - else if( atom == kde_net_wm_window_type_override ) - p->properties[ WINDOW_TYPES ] |= OverrideMask; - else if( atom == kde_net_wm_window_type_topmenu ) - p->properties[ WINDOW_TYPES ] |= TopMenuMask; - - else if( atom == net_wm_state ) - p->properties[ PROTOCOLS ] |= WMState; - - // Application window states - else if( atom == net_wm_state_modal ) - p->properties[ STATES ] |= Modal; - else if( atom == net_wm_state_sticky ) - p->properties[ STATES ] |= Sticky; - else if( atom == net_wm_state_max_vert ) - p->properties[ STATES ] |= MaxVert; - else if( atom == net_wm_state_max_horiz ) - p->properties[ STATES ] |= MaxHoriz; - else if( atom == net_wm_state_shaded ) - p->properties[ STATES ] |= Shaded; - else if( atom == net_wm_state_skip_taskbar ) - p->properties[ STATES ] |= SkipTaskbar; - else if( atom == net_wm_state_skip_pager ) - p->properties[ STATES ] |= SkipPager; - else if( atom == net_wm_state_hidden ) - p->properties[ STATES ] |= Hidden; - else if( atom == net_wm_state_fullscreen ) - p->properties[ STATES ] |= FullScreen; - else if( atom == net_wm_state_above ) - p->properties[ STATES ] |= KeepAbove; - else if( atom == net_wm_state_below ) - p->properties[ STATES ] |= KeepBelow; - else if( atom == net_wm_state_demands_attention ) - p->properties[ STATES ] |= DemandsAttention; - - else if( atom == net_wm_state_stays_on_top ) - p->properties[ STATES ] |= StaysOnTop; - - else if( atom == net_wm_strut ) - p->properties[ PROTOCOLS ] |= WMStrut; - - else if( atom == net_wm_extended_strut ) - p->properties[ PROTOCOLS2 ] |= WM2ExtendedStrut; - - else if( atom == net_wm_icon_geometry ) - p->properties[ PROTOCOLS ] |= WMIconGeometry; - - else if( atom == net_wm_icon ) - p->properties[ PROTOCOLS ] |= WMIcon; - - else if( atom == net_wm_pid ) - p->properties[ PROTOCOLS ] |= WMPid; - - else if( atom == net_wm_handled_icons ) - p->properties[ PROTOCOLS ] |= WMHandledIcons; - - else if( atom == net_wm_ping ) - p->properties[ PROTOCOLS ] |= WMPing; - - else if( atom == net_wm_take_activity ) - p->properties[ PROTOCOLS2 ] |= WM2TakeActivity; - - else if( atom == net_wm_user_time ) - p->properties[ PROTOCOLS2 ] |= WM2UserTime; - - else if( atom == net_startup_id ) - p->properties[ PROTOCOLS2 ] |= WM2StartupId; - - else if( atom == net_wm_allowed_actions ) - p->properties[ PROTOCOLS2 ] |= WM2AllowedActions; - - // Actions - else if( atom == net_wm_action_move ) - p->properties[ ACTIONS ] |= ActionMove; - else if( atom == net_wm_action_resize ) - p->properties[ ACTIONS ] |= ActionResize; - else if( atom == net_wm_action_minimize ) - p->properties[ ACTIONS ] |= ActionMinimize; - else if( atom == net_wm_action_shade ) - p->properties[ ACTIONS ] |= ActionShade; - else if( atom == net_wm_action_stick ) - p->properties[ ACTIONS ] |= ActionStick; - else if( atom == net_wm_action_max_vert ) - p->properties[ ACTIONS ] |= ActionMaxVert; - else if( atom == net_wm_action_max_horiz ) - p->properties[ ACTIONS ] |= ActionMaxHoriz; - else if( atom == net_wm_action_fullscreen ) - p->properties[ ACTIONS ] |= ActionFullScreen; - else if( atom == net_wm_action_change_desk ) - p->properties[ ACTIONS ] |= ActionChangeDesktop; - else if( atom == net_wm_action_close ) - p->properties[ ACTIONS ] |= ActionClose; - - // KDE specific extensions - else if( atom == kde_net_system_tray_windows ) - p->properties[ PROTOCOLS ] |= KDESystemTrayWindows; - - else if( atom == kde_net_wm_system_tray_window_for ) - p->properties[ PROTOCOLS ] |= WMKDESystemTrayWinFor; - - else if( atom == net_frame_extents ) - p->properties[ PROTOCOLS ] |= WMFrameExtents; - else if( atom == kde_net_wm_frame_strut ) - p->properties[ PROTOCOLS ] |= WMKDEFrameStrut; - - else if( atom == kde_net_wm_temporary_rules ) - p->properties[ PROTOCOLS2 ] |= WM2KDETemporaryRules; - else if( atom == net_wm_full_placement ) - p->properties[ PROTOCOLS2 ] |= WM2FullPlacement; -} - -void NETRootInfo::setActiveWindow(Window window) { - setActiveWindow( window, FromUnknown, GET_QT_X_USER_TIME(), None ); -} - -void NETRootInfo::setActiveWindow(Window window, NET::RequestSource src, - Time timestamp, Window active_window ) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setActiveWindow(0x%lx) (%s)\n", - window, (role == WindowManager) ? "WM" : "Client"); -#endif - - if (role == WindowManager) { - p->active = window; - XChangeProperty(p->display, p->root, net_active_window, XA_WINDOW, 32, - PropModeReplace, (unsigned char *) &(p->active), 1); - } else { - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_active_window; - e.xclient.display = p->display; - e.xclient.window = window; - e.xclient.format = 32; - e.xclient.data.l[0] = src; - e.xclient.data.l[1] = timestamp; - e.xclient.data.l[2] = active_window; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } -} - - -void NETRootInfo::setWorkArea(int desktop, const NETRect &workarea) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setWorkArea(%d, { %d, %d, %d, %d }) (%s)\n", - desktop, workarea.pos.x, workarea.pos.y, workarea.size.width, workarea.size.height, - (role == WindowManager) ? "WM" : "Client"); -#endif - - if (role != WindowManager || desktop < 1) return; - - p->workarea[desktop - 1] = workarea; - - long *wa = new long[p->number_of_desktops * 4]; - int i, o; - for (i = 0, o = 0; i < p->number_of_desktops; i++) { - wa[o++] = p->workarea[i].pos.x; - wa[o++] = p->workarea[i].pos.y; - wa[o++] = p->workarea[i].size.width; - wa[o++] = p->workarea[i].size.height; - } - - XChangeProperty(p->display, p->root, net_workarea, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) wa, - p->number_of_desktops * 4); - - delete [] wa; -} - - -void NETRootInfo::setVirtualRoots(Window *windows, unsigned int count) { - if (role != WindowManager) return; - - p->virtual_roots_count = count; - p->virtual_roots = windows; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setVirtualRoots: setting list with %ld windows\n", - p->virtual_roots_count); -#endif - - XChangeProperty(p->display, p->root, net_virtual_roots, XA_WINDOW, 32, - PropModeReplace, (unsigned char *) p->virtual_roots, - p->virtual_roots_count); -} - - -void NETRootInfo::setDesktopLayout(NET::Orientation orientation, int columns, int rows, - NET::DesktopLayoutCorner corner) -{ - p->desktop_layout_orientation = orientation; - p->desktop_layout_columns = columns; - p->desktop_layout_rows = rows; - p->desktop_layout_corner = corner; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::setDesktopLayout: %d %d %d %d\n", - orientation, columns, rows, corner); -#endif - - long data[ 4 ]; - data[ 0 ] = orientation; - data[ 1 ] = columns; - data[ 2 ] = rows; - data[ 3 ] = corner; - XChangeProperty(p->display, p->root, net_desktop_layout, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &data, 4); -} - - -void NETRootInfo::setShowingDesktop( bool showing ) { - if (role == WindowManager) { - long d = p->showing_desktop = showing; - XChangeProperty(p->display, p->root, net_showing_desktop, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); - } else { - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_showing_desktop; - e.xclient.display = p->display; - e.xclient.window = 0; - e.xclient.format = 32; - e.xclient.data.l[0] = showing ? 1 : 0; - e.xclient.data.l[1] = 0; - e.xclient.data.l[2] = 0; - e.xclient.data.l[3] = 0; - e.xclient.data.l[4] = 0; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } -} - - -bool NETRootInfo::showingDesktop() const { - return p->showing_desktop; -} - - -void NETRootInfo::closeWindowRequest(Window window) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::closeWindowRequest: requesting close for 0x%lx\n", - window); -#endif - - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_close_window; - e.xclient.display = p->display; - e.xclient.window = window; - e.xclient.format = 32; - e.xclient.data.l[0] = 0l; - e.xclient.data.l[1] = 0l; - e.xclient.data.l[2] = 0l; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); -} - - -void NETRootInfo::moveResizeRequest(Window window, int x_root, int y_root, - Direction direction) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::moveResizeRequest: requesting resize/move for 0x%lx (%d, %d, %d)\n", - window, x_root, y_root, direction); -#endif - - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_wm_moveresize; - e.xclient.display = p->display; - e.xclient.window = window, - e.xclient.format = 32; - e.xclient.data.l[0] = x_root; - e.xclient.data.l[1] = y_root; - e.xclient.data.l[2] = direction; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); -} - -void NETRootInfo::moveResizeWindowRequest(Window window, int flags, int x, int y, int width, int height ) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::moveResizeWindowRequest: resizing/moving 0x%lx (%d, %d, %d, %d, %d)\n", - window, flags, x, y, width, height); -#endif - - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_moveresize_window; - e.xclient.display = p->display; - e.xclient.window = window, - e.xclient.format = 32; - e.xclient.data.l[0] = flags; - e.xclient.data.l[1] = x; - e.xclient.data.l[2] = y; - e.xclient.data.l[3] = width; - e.xclient.data.l[4] = height; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); -} - -void NETRootInfo::restackRequest(Window window, Window above, int detail) -{ - restackRequest( window, FromTool, above, detail, GET_QT_X_USER_TIME() ); -} - -void NETRootInfo::restackRequest(Window window, RequestSource src, Window above, int detail, Time timestamp ) -{ -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::restackRequest: requesting restack for 0x%lx (%lx, %d)\n", - window, above, detail); -#endif - - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_restack_window; - e.xclient.display = p->display; - e.xclient.window = window, - e.xclient.format = 32; - e.xclient.data.l[0] = src; - e.xclient.data.l[1] = above; - e.xclient.data.l[2] = detail; - e.xclient.data.l[3] = timestamp; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); -} - -void NETRootInfo2::sendPing( Window window, Time timestamp ) -{ - if (role != WindowManager) return; -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo2::setPing: window 0x%lx, timestamp %lu\n", - window, timestamp ); -#endif - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = wm_protocols; - e.xclient.display = p->display; - e.xclient.window = window, - e.xclient.format = 32; - e.xclient.data.l[0] = net_wm_ping; - e.xclient.data.l[1] = timestamp; - e.xclient.data.l[2] = window; - e.xclient.data.l[3] = 0; - e.xclient.data.l[4] = 0; - - XSendEvent(p->display, window, False, 0, &e); -} - -void NETRootInfo3::takeActivity( Window window, Time timestamp, long flags ) -{ - if (role != WindowManager) return; -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo2::takeActivity: window 0x%lx, timestamp %lu, flags 0x%lx\n", - window, timestamp, flags ); -#endif - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = wm_protocols; - e.xclient.display = p->display; - e.xclient.window = window, - e.xclient.format = 32; - e.xclient.data.l[0] = net_wm_take_activity; - e.xclient.data.l[1] = timestamp; - e.xclient.data.l[2] = window; - e.xclient.data.l[3] = flags; - e.xclient.data.l[4] = 0; - - XSendEvent(p->display, window, False, 0, &e); -} - - - -// assignment operator - -const NETRootInfo &NETRootInfo::operator=(const NETRootInfo &rootinfo) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::operator=()\n"); -#endif - - if (p != rootinfo.p) { - refdec_nri(p); - - if (! p->ref) delete p; - } - - p = rootinfo.p; - role = rootinfo.role; - p->ref++; - - return *this; -} - -unsigned long NETRootInfo::event(XEvent *ev ) -{ - unsigned long props[ 1 ]; - event( ev, props, 1 ); - return props[ 0 ]; -} - -void NETRootInfo::event(XEvent *event, unsigned long* properties, int properties_size ) -{ - unsigned long props[ PROPERTIES_SIZE ] = { 0, 0, 0, 0, 0 }; - assert( PROPERTIES_SIZE == 5 ); // add elements above - unsigned long& dirty = props[ PROTOCOLS ]; - unsigned long& dirty2 = props[ PROTOCOLS2 ]; - bool do_update = false; - - // the window manager will be interested in client messages... no other - // client should get these messages - if (role == WindowManager && event->type == ClientMessage && - event->xclient.format == 32) { -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: handling ClientMessage event\n"); -#endif - - if (event->xclient.message_type == net_number_of_desktops) { - dirty = NumberOfDesktops; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: changeNumberOfDesktops(%ld)\n", - event->xclient.data.l[0]); -#endif - - changeNumberOfDesktops(event->xclient.data.l[0]); - } else if (event->xclient.message_type == net_desktop_geometry) { - dirty = DesktopGeometry; - - NETSize sz; - sz.width = event->xclient.data.l[0]; - sz.height = event->xclient.data.l[1]; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: changeDesktopGeometry( -- , { %d, %d })\n", - sz.width, sz.height); -#endif - - changeDesktopGeometry(~0, sz); - } else if (event->xclient.message_type == net_desktop_viewport) { - dirty = DesktopViewport; - - NETPoint pt; - pt.x = event->xclient.data.l[0]; - pt.y = event->xclient.data.l[1]; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: changeDesktopViewport(%d, { %d, %d })\n", - p->current_desktop, pt.x, pt.y); -#endif - - changeDesktopViewport(p->current_desktop, pt); - } else if (event->xclient.message_type == net_current_desktop) { - dirty = CurrentDesktop; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: changeCurrentDesktop(%ld)\n", - event->xclient.data.l[0] + 1); -#endif - - changeCurrentDesktop(event->xclient.data.l[0] + 1); - } else if (event->xclient.message_type == net_active_window) { - dirty = ActiveWindow; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: changeActiveWindow(0x%lx)\n", - event->xclient.window); -#endif - - changeActiveWindow(event->xclient.window); - if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >( this )) - { - RequestSource src = FromUnknown; - Time timestamp = CurrentTime; - Window active_window = None; - // make sure there aren't unknown values - if( event->xclient.data.l[0] >= FromUnknown - && event->xclient.data.l[0] <= FromTool ) - { - src = static_cast< RequestSource >( event->xclient.data.l[0] ); - timestamp = event->xclient.data.l[1]; - active_window = event->xclient.data.l[2]; - } - this2->changeActiveWindow( event->xclient.window, src, timestamp, active_window ); - } - } else if (event->xclient.message_type == net_wm_moveresize) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: moveResize(%ld, %ld, %ld, %ld)\n", - event->xclient.window, - event->xclient.data.l[0], - event->xclient.data.l[1], - event->xclient.data.l[2] - ); -#endif - - moveResize(event->xclient.window, - event->xclient.data.l[0], - event->xclient.data.l[1], - event->xclient.data.l[2]); - } else if (event->xclient.message_type == net_moveresize_window) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: moveResizeWindow(%ld, %ld, %ld, %ld, %ld, %ld)\n", - event->xclient.window, - event->xclient.data.l[0], - event->xclient.data.l[1], - event->xclient.data.l[2], - event->xclient.data.l[3], - event->xclient.data.l[4] - ); -#endif - - if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >( this )) - this2->moveResizeWindow(event->xclient.window, - event->xclient.data.l[0], - event->xclient.data.l[1], - event->xclient.data.l[2], - event->xclient.data.l[3], - event->xclient.data.l[4]); - } else if (event->xclient.message_type == net_close_window) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: closeWindow(0x%lx)\n", - event->xclient.window); -#endif - - closeWindow(event->xclient.window); - } else if (event->xclient.message_type == net_restack_window) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: restackWindow(0x%lx)\n", - event->xclient.window); -#endif - - if( NETRootInfo3* this3 = dynamic_cast< NETRootInfo3* >( this )) - { - RequestSource src = FromUnknown; - Time timestamp = CurrentTime; - // make sure there aren't unknown values - if( event->xclient.data.l[0] >= FromUnknown - && event->xclient.data.l[0] <= FromTool ) - { - src = static_cast< RequestSource >( event->xclient.data.l[0] ); - timestamp = event->xclient.data.l[3]; - } - this3->restackWindow(event->xclient.window, src, - event->xclient.data.l[1], event->xclient.data.l[2], timestamp); - } - else if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >( this )) - this2->restackWindow(event->xclient.window, - event->xclient.data.l[1], event->xclient.data.l[2]); - } else if (event->xclient.message_type == wm_protocols - && (Atom)event->xclient.data.l[ 0 ] == net_wm_ping) { - dirty = WMPing; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo2::event: gotPing(0x%lx,%lu)\n", - event->xclient.window, event->xclient.data.l[1]); -#endif - if( NETRootInfo2* this2 = dynamic_cast< NETRootInfo2* >( this )) - this2->gotPing( event->xclient.data.l[2], event->xclient.data.l[1]); - } else if (event->xclient.message_type == wm_protocols - && (Atom)event->xclient.data.l[ 0 ] == net_wm_take_activity) { - dirty2 = WM2TakeActivity; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo2::event: gotTakeActivity(0x%lx,%lu,0x%lx)\n", - event->xclient.window, event->xclient.data.l[1], event->xclient.data.l[3]); -#endif - if( NETRootInfo3* this3 = dynamic_cast< NETRootInfo3* >( this )) - this3->gotTakeActivity( event->xclient.data.l[2], event->xclient.data.l[1], - event->xclient.data.l[3]); - } else if (event->xclient.message_type == net_showing_desktop) { - dirty2 = WM2ShowingDesktop; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: changeShowingDesktop(%ld)\n", - event->xclient.data.l[0]); -#endif - - if( NETRootInfo4* this4 = dynamic_cast< NETRootInfo4* >( this )) - this4->changeShowingDesktop(event->xclient.data.l[0]); - } - } - - if (event->type == PropertyNotify) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: handling PropertyNotify event\n"); -#endif - - XEvent pe = *event; - - Bool done = False; - Bool compaction = False; - while (! done) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: loop fire\n"); -#endif - - if (pe.xproperty.atom == net_client_list) - dirty |= ClientList; - else if (pe.xproperty.atom == net_client_list_stacking) - dirty |= ClientListStacking; - else if (pe.xproperty.atom == kde_net_system_tray_windows) - dirty |= KDESystemTrayWindows; - else if (pe.xproperty.atom == net_desktop_names) - dirty |= DesktopNames; - else if (pe.xproperty.atom == net_workarea) - dirty |= WorkArea; - else if (pe.xproperty.atom == net_number_of_desktops) - dirty |= NumberOfDesktops; - else if (pe.xproperty.atom == net_desktop_geometry) - dirty |= DesktopGeometry; - else if (pe.xproperty.atom == net_desktop_viewport) - dirty |= DesktopViewport; - else if (pe.xproperty.atom == net_current_desktop) - dirty |= CurrentDesktop; - else if (pe.xproperty.atom == net_active_window) - dirty |= ActiveWindow; - else if (pe.xproperty.atom == net_showing_desktop) - dirty2 |= WM2ShowingDesktop; -// else if (pe.xproperty.atom == net_supported ) -// dirty |= Supported; // update here? - else if (pe.xproperty.atom == net_supporting_wm_check ) - dirty |= SupportingWMCheck; - else if (pe.xproperty.atom == net_virtual_roots ) - dirty |= VirtualRoots; - else if (pe.xproperty.atom == net_desktop_layout ) - dirty2 |= WM2DesktopLayout; - else { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: putting back event and breaking\n"); -#endif - - if ( compaction ) - XPutBackEvent(p->display, &pe); - break; - } - - if (XCheckTypedWindowEvent(p->display, p->root, PropertyNotify, &pe) ) - compaction = True; - else - break; - } - - do_update = true; - } - - if( do_update ) - update( props ); - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::event: handled events, returning dirty = 0x%lx, 0x%lx\n", - dirty, dirty2); -#endif - - if( properties_size > PROPERTIES_SIZE ) - properties_size = PROPERTIES_SIZE; - for( int i = 0; - i < properties_size; - ++i ) - properties[ i ] = props[ i ]; -} - - -// private functions to update the data we keep - -void NETRootInfo::update( const unsigned long dirty_props[] ) -{ - Atom type_ret; - int format_ret; - unsigned char *data_ret; - unsigned long nitems_ret, unused; - unsigned long props[ PROPERTIES_SIZE ]; - for( int i = 0; - i < PROPERTIES_SIZE; - ++i ) - props[ i ] = dirty_props[ i ] & p->client_properties[ i ]; - const unsigned long& dirty = props[ PROTOCOLS ]; - const unsigned long& dirty2 = props[ PROTOCOLS2 ]; - - if (dirty & Supported ) { - // only in Client mode - for( int i = 0; i < PROPERTIES_SIZE; ++i ) - p->properties[ i ] = 0; - if( XGetWindowProperty(p->display, p->root, net_supported, - 0l, MAX_PROP_SIZE, False, XA_ATOM, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success ) { - if( type_ret == XA_ATOM && format_ret == 32 ) { - Atom* atoms = (Atom*) data_ret; - for( unsigned int i = 0; - i < nitems_ret; - ++i ) - updateSupportedProperties( atoms[ i ] ); - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & ClientList) { - bool read_ok = false; - if (XGetWindowProperty(p->display, p->root, net_client_list, - 0l, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32) { - Window *wins = (Window *) data_ret; - - qsort(wins, nitems_ret, sizeof(Window), wcmp); - - if (p->clients) { - if (role == Client) { - unsigned long new_index = 0, old_index = 0; - unsigned long new_count = nitems_ret, - old_count = p->clients_count; - - while (old_index < old_count || new_index < new_count) { - if (old_index == old_count) { - addClient(wins[new_index++]); - } else if (new_index == new_count) { - removeClient(p->clients[old_index++]); - } else { - if (p->clients[old_index] < - wins[new_index]) { - removeClient(p->clients[old_index++]); - } else if (wins[new_index] < - p->clients[old_index]) { - addClient(wins[new_index++]); - } else { - new_index++; - old_index++; - } - } - } - } - - delete [] p->clients; - } else { -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: client list null, creating\n"); -#endif - - unsigned long n; - for (n = 0; n < nitems_ret; n++) { - addClient(wins[n]); - } - } - - p->clients_count = nitems_ret; - p->clients = nwindup(wins, p->clients_count); - read_ok = true; - } - - if ( data_ret ) - XFree(data_ret); - } - if( !read_ok ) { - for( unsigned int i = 0; i < p->clients_count; ++ i ) - removeClient(p->clients[i]); - p->clients_count = 0; - delete[] p->clients; - p->clients = NULL; - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: client list updated (%ld clients)\n", - p->clients_count); -#endif - } - - if (dirty & KDESystemTrayWindows) { - bool read_ok = false; - if (XGetWindowProperty(p->display, p->root, kde_net_system_tray_windows, - 0l, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32) { - Window *wins = (Window *) data_ret; - - qsort(wins, nitems_ret, sizeof(Window), wcmp); - - if (p->kde_system_tray_windows) { - if (role == Client) { - unsigned long new_index = 0, new_count = nitems_ret; - unsigned long old_index = 0, - old_count = p->kde_system_tray_windows_count; - - while(old_index < old_count || new_index < new_count) { - if (old_index == old_count) { - addSystemTrayWin(wins[new_index++]); - } else if (new_index == new_count) { - removeSystemTrayWin(p->kde_system_tray_windows[old_index++]); - } else { - if (p->kde_system_tray_windows[old_index] < - wins[new_index]) { - removeSystemTrayWin(p->kde_system_tray_windows[old_index++]); - } else if (wins[new_index] < - p->kde_system_tray_windows[old_index]) { - addSystemTrayWin(wins[new_index++]); - } else { - new_index++; - old_index++; - } - } - } - } - - } else { - unsigned long n; - for (n = 0; n < nitems_ret; n++) { - addSystemTrayWin(wins[n]); - } - } - - p->kde_system_tray_windows_count = nitems_ret; - delete [] p->kde_system_tray_windows; - p->kde_system_tray_windows = - nwindup(wins, p->kde_system_tray_windows_count); - read_ok = true; - } - - if ( data_ret ) - XFree(data_ret); - } - if( !read_ok ) { - for( unsigned int i = 0; i < p->kde_system_tray_windows_count; ++i ) - removeSystemTrayWin(p->kde_system_tray_windows[i]); - p->kde_system_tray_windows_count = 0; - delete [] p->kde_system_tray_windows; - p->kde_system_tray_windows = NULL; - } - } - - if (dirty & ClientListStacking) { - p->stacking_count = 0; - delete[] p->stacking; - p->stacking = NULL; - if (XGetWindowProperty(p->display, p->root, net_client_list_stacking, - 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32) { - Window *wins = (Window *) data_ret; - - p->stacking_count = nitems_ret; - p->stacking = nwindup(wins, p->stacking_count); - } - -#ifdef NETWMDEBUG - fprintf(stderr,"NETRootInfo::update: client stacking updated (%ld clients)\n", - p->stacking_count); -#endif - - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & NumberOfDesktops) { - p->number_of_desktops = 0; - - if (XGetWindowProperty(p->display, p->root, net_number_of_desktops, - 0l, 1l, False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) { - p->number_of_desktops = *((long *) data_ret); - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: number of desktops = %d\n", - p->number_of_desktops); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & DesktopGeometry) { - p->geometry = p->rootSize; - if (XGetWindowProperty(p->display, p->root, net_desktop_geometry, - 0l, 2l, False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == 2) { - long *data = (long *) data_ret; - - p->geometry.width = data[0]; - p->geometry.height = data[1]; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: desktop geometry updated\n"); -#endif - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & DesktopViewport) { - for (int i = 0; i < p->viewport.size(); i++) - p->viewport[i].x = p->viewport[i].y = 0; - if (XGetWindowProperty(p->display, p->root, net_desktop_viewport, - 0l, 2l, False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == 2) { - long *data = (long *) data_ret; - - int d, i, n; - n = nitems_ret / 2; - for (d = 0, i = 0; d < n; d++) { - p->viewport[d].x = data[i++]; - p->viewport[d].y = data[i++]; - } - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::update: desktop viewport array updated (%d entries)\n", - p->viewport.size()); - - if (nitems_ret % 2 != 0) { - fprintf(stderr, - "NETRootInfo::update(): desktop viewport array " - "size not a multiple of 2\n"); - } -#endif - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & CurrentDesktop) { - p->current_desktop = 0; - if (XGetWindowProperty(p->display, p->root, net_current_desktop, - 0l, 1l, False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) { - p->current_desktop = *((long *) data_ret) + 1; - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: current desktop = %d\n", - p->current_desktop); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & DesktopNames) { - for( int i = 0; i < p->desktop_names.size(); ++i ) - delete[] p->desktop_names[ i ]; - p->desktop_names.reset(); - if (XGetWindowProperty(p->display, p->root, net_desktop_names, - 0l, MAX_PROP_SIZE, False, UTF8_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8) { - const char *d = (const char *) data_ret; - unsigned int s, n, index; - - for (s = 0, n = 0, index = 0; n < nitems_ret; n++) { - if (d[n] == '\0') { - delete [] p->desktop_names[index]; - p->desktop_names[index++] = nstrndup((d + s), n - s + 1); - s = n + 1; - } - } - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: desktop names array updated (%d entries)\n", - p->desktop_names.size()); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & ActiveWindow) { - p->active = None; - if (XGetWindowProperty(p->display, p->root, net_active_window, 0l, 1l, - False, XA_WINDOW, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32 && nitems_ret == 1) { - p->active = *((Window *) data_ret); - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: active window = 0x%lx\n", - p->active); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WorkArea) { - p->workarea.reset(); - if (XGetWindowProperty(p->display, p->root, net_workarea, 0l, - (p->number_of_desktops * 4), False, XA_CARDINAL, - &type_ret, &format_ret, &nitems_ret, &unused, - &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == (unsigned) (p->number_of_desktops * 4)) { - long *d = (long *) data_ret; - int i, j; - for (i = 0, j = 0; i < p->number_of_desktops; i++) { - p->workarea[i].pos.x = d[j++]; - p->workarea[i].pos.y = d[j++]; - p->workarea[i].size.width = d[j++]; - p->workarea[i].size.height = d[j++]; - } - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: work area array updated (%d entries)\n", - p->workarea.size()); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - - if (dirty & SupportingWMCheck) { - p->supportwindow = None; - delete[] p->name; - p->name = NULL; - if (XGetWindowProperty(p->display, p->root, net_supporting_wm_check, - 0l, 1l, False, XA_WINDOW, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32 && nitems_ret == 1) { - p->supportwindow = *((Window *) data_ret); - - unsigned char *name_ret; - if (XGetWindowProperty(p->display, p->supportwindow, - net_wm_name, 0l, MAX_PROP_SIZE, False, - UTF8_STRING, &type_ret, &format_ret, - &nitems_ret, &unused, &name_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8) - p->name = nstrndup((const char *) name_ret, nitems_ret); - - if ( name_ret ) - XFree(name_ret); - } - } - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETRootInfo::update: supporting window manager = '%s'\n", - p->name); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & VirtualRoots) { - p->virtual_roots_count = 0; - delete[] p->virtual_roots; - p->virtual_roots = NULL; - if (XGetWindowProperty(p->display, p->root, net_virtual_roots, - 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32) { - Window *wins = (Window *) data_ret; - - p->virtual_roots_count = nitems_ret; - p->virtual_roots = nwindup(wins, p->virtual_roots_count); - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::updated: virtual roots updated (%ld windows)\n", - p->virtual_roots_count); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty2 & WM2DesktopLayout) { - p->desktop_layout_orientation = OrientationHorizontal; - p->desktop_layout_corner = DesktopLayoutCornerTopLeft; - p->desktop_layout_columns = p->desktop_layout_rows = 0; - if (XGetWindowProperty(p->display, p->root, net_desktop_layout, - 0, MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32) { - long* data = (long*) data_ret; - if( nitems_ret >= 4 && data[ 3 ] >= 0 && data[ 3 ] <= 3 ) - p->desktop_layout_corner = (NET::DesktopLayoutCorner)data[ 3 ]; - if( nitems_ret >= 3 ) { - if( data[ 0 ] >= 0 && data[ 0 ] <= 1 ) - p->desktop_layout_orientation = (NET::Orientation)data[ 0 ]; - p->desktop_layout_columns = data[ 1 ]; - p->desktop_layout_rows = data[ 2 ]; - } - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::updated: desktop layout updated (%d %d %d %d)\n", - p->desktop_layout_orientation, p->desktop_layout_columns, - p->desktop_layout_rows, p->desktop_layout_corner ); -#endif - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty2 & WM2ShowingDesktop) { - p->showing_desktop = false; - if (XGetWindowProperty(p->display, p->root, net_showing_desktop, - 0, MAX_PROP_SIZE, False, XA_CARDINAL, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) { - p->showing_desktop = *((long *) data_ret); - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETRootInfo::update: showing desktop = %d\n", - p->showing_desktop); -#endif - if ( data_ret ) - XFree(data_ret); - } - } -} - - -Display *NETRootInfo::x11Display() const { - return p->display; -} - - -Window NETRootInfo::rootWindow() const { - return p->root; -} - - -Window NETRootInfo::supportWindow() const { - return p->supportwindow; -} - - -const char *NETRootInfo::wmName() const { - return p->name; } - - -int NETRootInfo::screenNumber() const { - return p->screen; -} - - -unsigned long NETRootInfo::supported() const { - return role == WindowManager - ? p->properties[ PROTOCOLS ] - : p->client_properties[ PROTOCOLS ]; -} - -const unsigned long* NETRootInfo::supportedProperties() const { - return p->properties; -} - -const unsigned long* NETRootInfo::passedProperties() const { - return role == WindowManager - ? p->properties - : p->client_properties; -} - -bool NETRootInfo::isSupported( NET::Property property ) const { - return p->properties[ PROTOCOLS ] & property; -} - -bool NETRootInfo::isSupported( NET::Property2 property ) const { - return p->properties[ PROTOCOLS2 ] & property; -} - -bool NETRootInfo::isSupported( NET::WindowType type ) const { - return p->properties[ WINDOW_TYPES ] & type; -} - -bool NETRootInfo::isSupported( NET::State state ) const { - return p->properties[ STATES ] & state; -} - -bool NETRootInfo::isSupported( NET::Action action ) const { - return p->properties[ ACTIONS ] & action; -} - -const Window *NETRootInfo::clientList() const { - return p->clients; -} - - -int NETRootInfo::clientListCount() const { - return p->clients_count; -} - - -const Window *NETRootInfo::clientListStacking() const { - return p->stacking; -} - - -int NETRootInfo::clientListStackingCount() const { - return p->stacking_count; -} - - -const Window *NETRootInfo::kdeSystemTrayWindows() const { - return p->kde_system_tray_windows; -} - - -int NETRootInfo::kdeSystemTrayWindowsCount() const { - return p->kde_system_tray_windows_count; -} - - -NETSize NETRootInfo::desktopGeometry(int) const { - return p->geometry.width != 0 ? p->geometry : p->rootSize; -} - - -NETPoint NETRootInfo::desktopViewport(int desktop) const { - if (desktop < 1) { - NETPoint pt; // set to (0,0) - return pt; - } - - return p->viewport[desktop - 1]; -} - - -NETRect NETRootInfo::workArea(int desktop) const { - if (desktop < 1) { - NETRect rt; - return rt; - } - - return p->workarea[desktop - 1]; -} - - -const char *NETRootInfo::desktopName(int desktop) const { - if (desktop < 1) { - return 0; - } - - return p->desktop_names[desktop - 1]; -} - - -const Window *NETRootInfo::virtualRoots( ) const { - return p->virtual_roots; -} - - -int NETRootInfo::virtualRootsCount() const { - return p->virtual_roots_count; -} - - -NET::Orientation NETRootInfo::desktopLayoutOrientation() const { - return p->desktop_layout_orientation; -} - - -TQSize NETRootInfo::desktopLayoutColumnsRows() const { - return TQSize( p->desktop_layout_columns, p->desktop_layout_rows ); -} - - -NET::DesktopLayoutCorner NETRootInfo::desktopLayoutCorner() const { - return p->desktop_layout_corner; -} - - -int NETRootInfo::numberOfDesktops() const { - return p->number_of_desktops == 0 ? 1 : p->number_of_desktops; -} - - -int NETRootInfo::currentDesktop() const { - return p->current_desktop == 0 ? 1 : p->current_desktop; -} - - -Window NETRootInfo::activeWindow() const { - return p->active; -} - - -// NETWinInfo stuffs - -const int NETWinInfo::OnAllDesktops = NET::OnAllDesktops; - -NETWinInfo::NETWinInfo(Display *display, Window window, Window rootWindow, - const unsigned long properties[], int properties_size, - Role role) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::NETWinInfo: constructing object with role '%s'\n", - (role == WindowManager) ? "WindowManager" : "Client"); -#endif - - p = new NETWinInfoPrivate; - p->ref = 1; - - p->display = display; - p->window = window; - p->root = rootWindow; - p->mapping_state = Withdrawn; - p->mapping_state_dirty = True; - p->state = 0; - p->types[ 0 ] = Unknown; - p->name = (char *) 0; - p->visible_name = (char *) 0; - p->icon_name = (char *) 0; - p->visible_icon_name = (char *) 0; - p->desktop = p->pid = p->handled_icons = 0; - p->user_time = -1U; - p->startup_id = NULL; - p->transient_for = None; - p->window_group = None; - p->allowed_actions = 0; - p->has_net_support = false; - p->class_class = (char*) 0; - p->class_name = (char*) 0; - p->role = (char*) 0; - p->client_machine = (char*) 0; - - // p->strut.left = p->strut.right = p->strut.top = p->strut.bottom = 0; - // p->frame_strut.left = p->frame_strut.right = p->frame_strut.top = - // p->frame_strut.bottom = 0; - - p->kde_system_tray_win_for = 0; - - for( int i = 0; - i < PROPERTIES_SIZE; - ++i ) - p->properties[ i ] = 0; - if( properties_size > PROPERTIES_SIZE ) - properties_size = PROPERTIES_SIZE; - for( int i = 0; - i < properties_size; - ++i ) - p->properties[ i ] = properties[ i ]; - - p->icon_count = 0; - - this->role = role; - - if (! netwm_atoms_created) create_atoms(p->display); - - update(p->properties); -} - - -NETWinInfo::NETWinInfo(Display *display, Window window, Window rootWindow, - unsigned long properties, Role role) -{ - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::NETWinInfo: constructing object with role '%s'\n", - (role == WindowManager) ? "WindowManager" : "Client"); -#endif - - p = new NETWinInfoPrivate; - p->ref = 1; - - p->display = display; - p->window = window; - p->root = rootWindow; - p->mapping_state = Withdrawn; - p->mapping_state_dirty = True; - p->state = 0; - p->types[ 0 ] = Unknown; - p->name = (char *) 0; - p->visible_name = (char *) 0; - p->icon_name = (char *) 0; - p->visible_icon_name = (char *) 0; - p->desktop = p->pid = p->handled_icons = 0; - p->user_time = -1U; - p->startup_id = NULL; - p->transient_for = None; - p->window_group = None; - p->allowed_actions = 0; - p->has_net_support = false; - p->class_class = (char*) 0; - p->class_name = (char*) 0; - p->role = (char*) 0; - p->client_machine = (char*) 0; - - // p->strut.left = p->strut.right = p->strut.top = p->strut.bottom = 0; - // p->frame_strut.left = p->frame_strut.right = p->frame_strut.top = - // p->frame_strut.bottom = 0; - - p->kde_system_tray_win_for = 0; - - for( int i = 0; - i < PROPERTIES_SIZE; - ++i ) - p->properties[ i ] = 0; - p->properties[ PROTOCOLS ] = properties; - - p->icon_count = 0; - - this->role = role; - - if (! netwm_atoms_created) create_atoms(p->display); - - update(p->properties); -} - - -NETWinInfo::NETWinInfo(const NETWinInfo &wininfo) { - p = wininfo.p; - p->ref++; -} - - -NETWinInfo::~NETWinInfo() { - refdec_nwi(p); - - if (! p->ref) delete p; -} - - -// assignment operator - -const NETWinInfo &NETWinInfo::operator=(const NETWinInfo &wininfo) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::operator=()\n"); -#endif - - if (p != wininfo.p) { - refdec_nwi(p); - - if (! p->ref) delete p; - } - - p = wininfo.p; - role = wininfo.role; - p->ref++; - - return *this; -} - - -void NETWinInfo::setIcon(NETIcon icon, Bool replace) { - setIconInternal( p->icons, p->icon_count, net_wm_icon, icon, replace ); -} - -void NETWinInfo::setIconInternal(NETRArray<NETIcon>& icons, int& icon_count, Atom property, NETIcon icon, Bool replace) { - if (role != Client) return; - - int proplen, i, sz, j; - - if (replace) { - - for (i = 0; i < icons.size(); i++) { - delete [] icons[i].data; - icons[i].data = 0; - icons[i].size.width = 0; - icons[i].size.height = 0; - } - - icon_count = 0; - } - - // assign icon - icons[icon_count] = icon; - icon_count++; - - // do a deep copy, we want to own the data - NETIcon &ni = icons[icon_count - 1]; - sz = ni.size.width * ni.size.height; - CARD32 *d = new CARD32[sz]; - ni.data = (unsigned char *) d; - memcpy(d, icon.data, sz * sizeof(CARD32)); - - // compute property length - for (i = 0, proplen = 0; i < icon_count; i++) { - proplen += 2 + (icons[i].size.width * - icons[i].size.height); - } - - CARD32 *d32; - long *prop = new long[proplen], *pprop = prop; - for (i = 0; i < icon_count; i++) { - // copy size into property - *pprop++ = icons[i].size.width; - *pprop++ = icons[i].size.height; - - // copy data into property - sz = (icons[i].size.width * icons[i].size.height); - d32 = (CARD32 *) icons[i].data; - for (j = 0; j < sz; j++) *pprop++ = *d32++; - } - - XChangeProperty(p->display, p->window, property, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) prop, proplen); - - delete [] prop; -} - - -void NETWinInfo::setIconGeometry(NETRect geometry) { - if (role != Client) return; - - p->icon_geom = geometry; - - if( geometry.size.width == 0 ) // empty - XDeleteProperty(p->display, p->window, net_wm_icon_geometry); - else { - long data[4]; - data[0] = geometry.pos.x; - data[1] = geometry.pos.y; - data[2] = geometry.size.width; - data[3] = geometry.size.height; - - XChangeProperty(p->display, p->window, net_wm_icon_geometry, XA_CARDINAL, - 32, PropModeReplace, (unsigned char *) data, 4); - } -} - - -void NETWinInfo::setExtendedStrut(const NETExtendedStrut& extended_strut ) { - if (role != Client) return; - - p->extended_strut = extended_strut; - - long data[12]; - data[0] = extended_strut.left_width; - data[1] = extended_strut.right_width; - data[2] = extended_strut.top_width; - data[3] = extended_strut.bottom_width; - data[4] = extended_strut.left_start; - data[5] = extended_strut.left_end; - data[6] = extended_strut.right_start; - data[7] = extended_strut.right_end; - data[8] = extended_strut.top_start; - data[9] = extended_strut.top_end; - data[10] = extended_strut.bottom_start; - data[11] = extended_strut.bottom_end; - - XChangeProperty(p->display, p->window, net_wm_extended_strut, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) data, 12); -} - - -void NETWinInfo::setStrut(NETStrut strut) { - if (role != Client) return; - - p->strut = strut; - - long data[4]; - data[0] = strut.left; - data[1] = strut.right; - data[2] = strut.top; - data[3] = strut.bottom; - - XChangeProperty(p->display, p->window, net_wm_strut, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) data, 4); -} - - -void NETWinInfo::setState(unsigned long state, unsigned long mask) { - if (p->mapping_state_dirty) - updateWMState(); - - // setState() needs to know the current state, so read it even if not requested - if( ( p->properties[ PROTOCOLS ] & WMState ) == 0 ) { - p->properties[ PROTOCOLS ] |= WMState; - unsigned long props[ PROPERTIES_SIZE ] = { WMState, 0 }; - assert( PROPERTIES_SIZE == 2 ); // add elements above - update( props ); - p->properties[ PROTOCOLS ] &= ~WMState; - } - - if (role == Client && p->mapping_state != Withdrawn) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::setState (0x%lx, 0x%lx) (Client)\n", - state, mask); -#endif // NETWMDEBUG - - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = net_wm_state; - e.xclient.display = p->display; - e.xclient.window = p->window; - e.xclient.format = 32; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - if ((mask & Modal) && ((p->state & Modal) != (state & Modal))) { - e.xclient.data.l[0] = (state & Modal) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_modal; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & Sticky) && ((p->state & Sticky) != (state & Sticky))) { - e.xclient.data.l[0] = (state & Sticky) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_sticky; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & Max) && (( (p->state&mask) & Max) != (state & Max))) { - - unsigned long wishstate = (p->state & ~mask) | (state & mask); - if ( ( (wishstate & MaxHoriz) != (p->state & MaxHoriz) ) - && ( (wishstate & MaxVert) != (p->state & MaxVert) ) ) { - if ( (wishstate & Max) == Max ) { - e.xclient.data.l[0] = 1; - e.xclient.data.l[1] = net_wm_state_max_horiz; - e.xclient.data.l[2] = net_wm_state_max_vert; - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } else if ( (wishstate & Max) == 0 ) { - e.xclient.data.l[0] = 0; - e.xclient.data.l[1] = net_wm_state_max_horiz; - e.xclient.data.l[2] = net_wm_state_max_vert; - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } else { - e.xclient.data.l[0] = ( wishstate & MaxHoriz ) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_max_horiz; - e.xclient.data.l[2] = 0; - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - e.xclient.data.l[0] = ( wishstate & MaxVert ) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_max_vert; - e.xclient.data.l[2] = 0; - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - } else if ( (wishstate & MaxVert) != (p->state & MaxVert) ) { - e.xclient.data.l[0] = ( wishstate & MaxVert ) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_max_vert; - e.xclient.data.l[2] = 0; - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } else if ( (wishstate & MaxHoriz) != (p->state & MaxHoriz) ) { - e.xclient.data.l[0] = ( wishstate & MaxHoriz ) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_max_horiz; - e.xclient.data.l[2] = 0; - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - } - - if ((mask & Shaded) && ((p->state & Shaded) != (state & Shaded))) { - e.xclient.data.l[0] = (state & Shaded) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_shaded; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & SkipTaskbar) && - ((p->state & SkipTaskbar) != (state & SkipTaskbar))) { - e.xclient.data.l[0] = (state & SkipTaskbar) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_skip_taskbar; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & SkipPager) && - ((p->state & SkipPager) != (state & SkipPager))) { - e.xclient.data.l[0] = (state & SkipPager) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_skip_pager; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & Hidden) && - ((p->state & Hidden) != (state & Hidden))) { - e.xclient.data.l[0] = (state & Hidden) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_hidden; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & FullScreen) && - ((p->state & FullScreen) != (state & FullScreen))) { - e.xclient.data.l[0] = (state & FullScreen) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_fullscreen; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & KeepAbove) && - ((p->state & KeepAbove) != (state & KeepAbove))) { - e.xclient.data.l[0] = (state & KeepAbove) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_above; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & KeepBelow) && - ((p->state & KeepBelow) != (state & KeepBelow))) { - e.xclient.data.l[0] = (state & KeepBelow) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_below; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & StaysOnTop) && ((p->state & StaysOnTop) != (state & StaysOnTop))) { - e.xclient.data.l[0] = (state & StaysOnTop) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_stays_on_top; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - if ((mask & DemandsAttention) && - ((p->state & DemandsAttention) != (state & DemandsAttention))) { - e.xclient.data.l[0] = (state & DemandsAttention) ? 1 : 0; - e.xclient.data.l[1] = net_wm_state_demands_attention; - e.xclient.data.l[2] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } - - } else { - p->state &= ~mask; - p->state |= state; - - long data[50]; - int count = 0; - - // hints - if (p->state & Modal) data[count++] = net_wm_state_modal; - if (p->state & MaxVert) data[count++] = net_wm_state_max_vert; - if (p->state & MaxHoriz) data[count++] = net_wm_state_max_horiz; - if (p->state & Shaded) data[count++] = net_wm_state_shaded; - if (p->state & Hidden) data[count++] = net_wm_state_hidden; - if (p->state & FullScreen) data[count++] = net_wm_state_fullscreen; - if (p->state & DemandsAttention) data[count++] = net_wm_state_demands_attention; - - // policy - if (p->state & KeepAbove) data[count++] = net_wm_state_above; - if (p->state & KeepBelow) data[count++] = net_wm_state_below; - if (p->state & StaysOnTop) data[count++] = net_wm_state_stays_on_top; - if (p->state & Sticky) data[count++] = net_wm_state_sticky; - if (p->state & SkipTaskbar) data[count++] = net_wm_state_skip_taskbar; - if (p->state & SkipPager) data[count++] = net_wm_state_skip_pager; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::setState: setting state property (%d)\n", count); - for (int i = 0; i < count; i++) { - char* data_ret = XGetAtomName(p->display, (Atom) data[i]); - fprintf(stderr, "NETWinInfo::setState: state %ld '%s'\n", - data[i], data_ret); - if ( data_ret ) - XFree( data_ret ); - } - -#endif - - XChangeProperty(p->display, p->window, net_wm_state, XA_ATOM, 32, - PropModeReplace, (unsigned char *) data, count); - } -} - - -void NETWinInfo::setWindowType(WindowType type) { - if (role != Client) return; - - int len; - long data[2]; - - switch (type) { - case Override: - // spec extension: override window type. we must comply with the spec - // and provide a fall back (normal seems best) - data[0] = kde_net_wm_window_type_override; - data[1] = net_wm_window_type_normal; - len = 2; - break; - - case Dialog: - data[0] = net_wm_window_type_dialog; - data[1] = None; - len = 1; - break; - - case Menu: - data[0] = net_wm_window_type_menu; - data[1] = None; - len = 1; - break; - - case TopMenu: - // spec extension: override window type. we must comply with the spec - // and provide a fall back (dock seems best) - data[0] = kde_net_wm_window_type_topmenu; - data[1] = net_wm_window_type_dock; - len = 2; - break; - - case Tool: - data[0] = net_wm_window_type_toolbar; - data[1] = None; - len = 1; - break; - - case Dock: - data[0] = net_wm_window_type_dock; - data[1] = None; - len = 1; - break; - - case Desktop: - data[0] = net_wm_window_type_desktop; - data[1] = None; - len = 1; - break; - - case Utility: - data[0] = net_wm_window_type_utility; - data[1] = net_wm_window_type_dialog; // fallback for old netwm version - len = 2; - break; - - case Splash: - data[0] = net_wm_window_type_splash; - data[1] = net_wm_window_type_dock; // fallback (dock seems best) - len = 2; - break; - - case DropdownMenu: - data[0] = net_wm_window_type_dropdown_menu; - data[1] = None; - len = 1; - break; - - case PopupMenu: - data[0] = net_wm_window_type_popup_menu; - data[1] = None; - len = 1; - break; - - case Tooltip: - data[0] = net_wm_window_type_tooltip; - data[1] = None; - len = 1; - break; - - case Notification: - data[0] = net_wm_window_type_notification; - data[1] = None; - len = 1; - break; - - case ComboBox: - data[0] = net_wm_window_type_combobox; - data[1] = None; - len = 1; - break; - - case DNDIcon: - data[0] = net_wm_window_type_dnd; - data[1] = None; - len = 1; - break; - - default: - case Normal: - data[0] = net_wm_window_type_normal; - data[1] = None; - len = 1; - break; - } - - XChangeProperty(p->display, p->window, net_wm_window_type, XA_ATOM, 32, - PropModeReplace, (unsigned char *) &data, len); -} - - -void NETWinInfo::setName(const char *name) { - if (role != Client) return; - - delete [] p->name; - p->name = nstrdup(name); - if( p->name[ 0 ] != '\0' ) - XChangeProperty(p->display, p->window, net_wm_name, UTF8_STRING, 8, - PropModeReplace, (unsigned char *) p->name, - strlen(p->name)); - else - XDeleteProperty(p->display, p->window, net_wm_name); -} - - -void NETWinInfo::setVisibleName(const char *visibleName) { - if (role != WindowManager) return; - - delete [] p->visible_name; - p->visible_name = nstrdup(visibleName); - if( p->visible_name[ 0 ] != '\0' ) - XChangeProperty(p->display, p->window, net_wm_visible_name, UTF8_STRING, 8, - PropModeReplace, (unsigned char *) p->visible_name, - strlen(p->visible_name)); - else - XDeleteProperty(p->display, p->window, net_wm_visible_name); -} - - -void NETWinInfo::setIconName(const char *iconName) { - if (role != Client) return; - - delete [] p->icon_name; - p->icon_name = nstrdup(iconName); - if( p->icon_name[ 0 ] != '\0' ) - XChangeProperty(p->display, p->window, net_wm_icon_name, UTF8_STRING, 8, - PropModeReplace, (unsigned char *) p->icon_name, - strlen(p->icon_name)); - else - XDeleteProperty(p->display, p->window, net_wm_icon_name); -} - - -void NETWinInfo::setVisibleIconName(const char *visibleIconName) { - if (role != WindowManager) return; - - delete [] p->visible_icon_name; - p->visible_icon_name = nstrdup(visibleIconName); - if( p->visible_icon_name[ 0 ] != '\0' ) - XChangeProperty(p->display, p->window, net_wm_visible_icon_name, UTF8_STRING, 8, - PropModeReplace, (unsigned char *) p->visible_icon_name, - strlen(p->visible_icon_name)); - else - XDeleteProperty(p->display, p->window, net_wm_visible_icon_name); -} - - -void NETWinInfo::setDesktop(int desktop) { - if (p->mapping_state_dirty) - updateWMState(); - - if (role == Client && p->mapping_state != Withdrawn) { - // we only send a ClientMessage if we are 1) a client and 2) managed - - if ( desktop == 0 ) - return; // we can't do that while being managed - - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.message_type = net_wm_desktop; - e.xclient.display = p->display; - e.xclient.window = p->window; - e.xclient.format = 32; - e.xclient.data.l[0] = desktop == OnAllDesktops ? OnAllDesktops : desktop - 1; - e.xclient.data.l[1] = 0l; - e.xclient.data.l[2] = 0l; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; - - XSendEvent(p->display, p->root, False, netwm_sendevent_mask, &e); - } else { - // otherwise we just set or remove the property directly - p->desktop = desktop; - long d = desktop; - - if ( d != OnAllDesktops ) { - if ( d == 0 ) { - XDeleteProperty( p->display, p->window, net_wm_desktop ); - return; - } - - d -= 1; - } - - XChangeProperty(p->display, p->window, net_wm_desktop, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); - } -} - - -void NETWinInfo::setPid(int pid) { - if (role != Client) return; - - p->pid = pid; - long d = pid; - XChangeProperty(p->display, p->window, net_wm_pid, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); -} - - -void NETWinInfo::setHandledIcons(Bool handled) { - if (role != Client) return; - - p->handled_icons = handled; - long d = handled; - XChangeProperty(p->display, p->window, net_wm_handled_icons, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); -} - -void NETWinInfo::setStartupId(const char* id) { - if (role != Client) return; - - delete[] p->startup_id; - p->startup_id = nstrdup(id); - XChangeProperty(p->display, p->window, net_startup_id, UTF8_STRING, 8, - PropModeReplace, reinterpret_cast< unsigned char* >( p->startup_id ), - strlen( p->startup_id )); -} - -void NETWinInfo::setAllowedActions( unsigned long actions ) { - if( role != WindowManager ) - return; - long data[50]; - int count = 0; - - p->allowed_actions = actions; - if (p->allowed_actions & ActionMove) data[count++] = net_wm_action_move; - if (p->allowed_actions & ActionResize) data[count++] = net_wm_action_resize; - if (p->allowed_actions & ActionMinimize) data[count++] = net_wm_action_minimize; - if (p->allowed_actions & ActionShade) data[count++] = net_wm_action_shade; - if (p->allowed_actions & ActionStick) data[count++] = net_wm_action_stick; - if (p->allowed_actions & ActionMaxVert) data[count++] = net_wm_action_max_vert; - if (p->allowed_actions & ActionMaxHoriz) data[count++] = net_wm_action_max_horiz; - if (p->allowed_actions & ActionFullScreen) data[count++] = net_wm_action_fullscreen; - if (p->allowed_actions & ActionChangeDesktop) data[count++] = net_wm_action_change_desk; - if (p->allowed_actions & ActionClose) data[count++] = net_wm_action_close; - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::setAllowedActions: setting property (%d)\n", count); - for (int i = 0; i < count; i++) { - char* data_ret = XGetAtomName(p->display, (Atom) data[i]); - fprintf(stderr, "NETWinInfo::setAllowedActions: action %ld '%s'\n", - data[i], data_ret); - if ( data_ret ) - XFree(data_ret); - } -#endif - - XChangeProperty(p->display, p->window, net_wm_allowed_actions, XA_ATOM, 32, - PropModeReplace, (unsigned char *) data, count); -} - -void NETWinInfo::setKDESystemTrayWinFor(Window window) { - if (role != Client) return; - - p->kde_system_tray_win_for = window; - XChangeProperty(p->display, p->window, kde_net_wm_system_tray_window_for, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *) &(p->kde_system_tray_win_for), 1); -} - - -void NETWinInfo::setKDEFrameStrut(NETStrut strut) { - setFrameExtents( strut ); -} - -void NETWinInfo::setFrameExtents(NETStrut strut) { - if (role != WindowManager) return; - - p->frame_strut = strut; - - long d[4]; - d[0] = strut.left; - d[1] = strut.right; - d[2] = strut.top; - d[3] = strut.bottom; - - XChangeProperty(p->display, p->window, net_frame_extents, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) d, 4); - XChangeProperty(p->display, p->window, kde_net_wm_frame_strut, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) d, 4); -} - - -void NETWinInfo::kdeGeometry(NETRect& frame, NETRect& window) { - if (p->win_geom.size.width == 0 || p->win_geom.size.height == 0) { - Window unused; - int x, y; - unsigned int w, h, junk; - XGetGeometry(p->display, p->window, &unused, &x, &y, &w, &h, &junk, &junk); - XTranslateCoordinates(p->display, p->window, p->root, 0, 0, &x, &y, &unused - ); - - p->win_geom.pos.x = x; - p->win_geom.pos.y = y; - - p->win_geom.size.width = w; - p->win_geom.size.height = h; - } -// TODO try to work also without _KDE_NET_WM_FRAME_STRUT - window = p->win_geom; - - frame.pos.x = window.pos.x - p->frame_strut.left; - frame.pos.y = window.pos.y - p->frame_strut.top; - frame.size.width = window.size.width + p->frame_strut.left + p->frame_strut.right; - frame.size.height = window.size.height + p->frame_strut.top + p->frame_strut.bottom; -} - - -NETIcon NETWinInfo::icon(int width, int height) const { - return iconInternal( p->icons, p->icon_count, width, height ); -} - -NETIcon NETWinInfo::iconInternal(NETRArray<NETIcon>& icons, int icon_count, int width, int height) const { - NETIcon result; - - if ( !icon_count ) { - result.size.width = 0; - result.size.height = 0; - result.data = 0; - return result; - } - - // find the largest icon - result = icons[0]; - for (int i = 1; i < icons.size(); i++) { - if( icons[i].size.width >= result.size.width && - icons[i].size.height >= result.size.height ) - result = icons[i]; - } - - // return the largest icon if w and h are -1 - if (width == -1 && height == -1) return result; - - // find the icon that's closest in size to w x h... - for (int i = 0; i < icons.size(); i++) { - if ((icons[i].size.width >= width && - icons[i].size.width < result.size.width) && - (icons[i].size.height >= height && - icons[i].size.height < result.size.height)) - result = icons[i]; - } - - return result; -} - -void NETWinInfo::setUserTime( Time time ) { - if (role != Client) return; - - p->user_time = time; - long d = time; - XChangeProperty(p->display, p->window, net_wm_user_time, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) &d, 1); -} - - -unsigned long NETWinInfo::event(XEvent *ev ) -{ - unsigned long props[ 1 ]; - event( ev, props, 1 ); - return props[ 0 ]; -} - -void NETWinInfo::event(XEvent *event, unsigned long* properties, int properties_size ) { - unsigned long props[ PROPERTIES_SIZE ] = { 0, 0 }; - assert( PROPERTIES_SIZE == 2 ); // add elements above - unsigned long& dirty = props[ PROTOCOLS ]; - unsigned long& dirty2 = props[ PROTOCOLS2 ]; - bool do_update = false; - - if (role == WindowManager && event->type == ClientMessage && - event->xclient.format == 32) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::event: handling ClientMessage event\n"); -#endif // NETWMDEBUG - - if (event->xclient.message_type == net_wm_state) { - dirty = WMState; - - // we need to generate a change mask - -#ifdef NETWMDEBUG - fprintf(stderr, - "NETWinInfo::event: state client message, getting new state/mask\n"); -#endif - - int i; - long state = 0, mask = 0; - - for (i = 1; i < 3; i++) { -#ifdef NETWMDEBUG - char* debug_txt = XGetAtomName(p->display, (Atom) event->xclient.data.l[i]); - fprintf(stderr, "NETWinInfo::event: message %ld '%s'\n", - event->xclient.data.l[i], debug_txt ); - if ( debug_txt ) - XFree( debug_txt ); -#endif - - if ((Atom) event->xclient.data.l[i] == net_wm_state_modal) - mask |= Modal; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_sticky) - mask |= Sticky; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_max_vert) - mask |= MaxVert; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_max_horiz) - mask |= MaxHoriz; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_shaded) - mask |= Shaded; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_skip_taskbar) - mask |= SkipTaskbar; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_skip_pager) - mask |= SkipPager; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_hidden) - mask |= Hidden; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_fullscreen) - mask |= FullScreen; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_above) - mask |= KeepAbove; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_below) - mask |= KeepBelow; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_demands_attention) - mask |= DemandsAttention; - else if ((Atom) event->xclient.data.l[i] == net_wm_state_stays_on_top) - mask |= StaysOnTop; - } - - // when removing, we just leave newstate == 0 - switch (event->xclient.data.l[0]) { - case 1: // set - // to set... the change state should be the same as the mask - state = mask; - break; - - case 2: // toggle - // to toggle, we need to xor the current state with the new state - state = (p->state & mask) ^ mask; - break; - - default: - // to clear state, the new state should stay zero - ; - } - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::event: calling changeState(%lx, %lx)\n", - state, mask); -#endif - - changeState(state, mask); - } else if (event->xclient.message_type == net_wm_desktop) { - dirty = WMDesktop; - - if( event->xclient.data.l[0] == OnAllDesktops ) - changeDesktop( OnAllDesktops ); - else - changeDesktop(event->xclient.data.l[0] + 1); - } - } - - if (event->type == PropertyNotify) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::event: handling PropertyNotify event\n"); -#endif - - XEvent pe = *event; - - Bool done = False; - Bool compaction = False; - while (! done) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::event: loop fire\n"); -#endif - - if (pe.xproperty.atom == net_wm_name) - dirty |= WMName; - else if (pe.xproperty.atom == net_wm_visible_name) - dirty |= WMVisibleName; - else if (pe.xproperty.atom == net_wm_desktop) - dirty |= WMDesktop; - else if (pe.xproperty.atom == net_wm_window_type) - dirty |=WMWindowType; - else if (pe.xproperty.atom == net_wm_state) - dirty |= WMState; - else if (pe.xproperty.atom == net_wm_strut) - dirty |= WMStrut; - else if (pe.xproperty.atom == net_wm_extended_strut) - dirty2 |= WM2ExtendedStrut; - else if (pe.xproperty.atom == net_wm_icon_geometry) - dirty |= WMIconGeometry; - else if (pe.xproperty.atom == net_wm_icon) - dirty |= WMIcon; - else if (pe.xproperty.atom == net_wm_pid) - dirty |= WMPid; - else if (pe.xproperty.atom == net_wm_handled_icons) - dirty |= WMHandledIcons; - else if (pe.xproperty.atom == net_startup_id) - dirty2 |= WM2StartupId; - else if (pe.xproperty.atom == net_wm_allowed_actions) - dirty2 |= WM2AllowedActions; - else if (pe.xproperty.atom == kde_net_wm_system_tray_window_for) - dirty |= WMKDESystemTrayWinFor; - else if (pe.xproperty.atom == xa_wm_state) - dirty |= XAWMState; - else if (pe.xproperty.atom == net_frame_extents) - dirty |= WMFrameExtents; - else if (pe.xproperty.atom == kde_net_wm_frame_strut) - dirty |= WMKDEFrameStrut; - else if (pe.xproperty.atom == net_wm_icon_name) - dirty |= WMIconName; - else if (pe.xproperty.atom == net_wm_visible_icon_name) - dirty |= WMVisibleIconName; - else if (pe.xproperty.atom == net_wm_user_time) - dirty2 |= WM2UserTime; - else if (pe.xproperty.atom == XA_WM_HINTS) - dirty2 |= WM2GroupLeader; - else if (pe.xproperty.atom == XA_WM_TRANSIENT_FOR) - dirty2 |= WM2TransientFor; - else if (pe.xproperty.atom == XA_WM_CLASS) - dirty2 |= WM2WindowClass; - else if (pe.xproperty.atom == wm_window_role) - dirty2 |= WM2WindowRole; - else if (pe.xproperty.atom == XA_WM_CLIENT_MACHINE) - dirty2 |= WM2ClientMachine; - else { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::event: putting back event and breaking\n"); -#endif - - if ( compaction ) - XPutBackEvent(p->display, &pe); - break; - } - - if (XCheckTypedWindowEvent(p->display, p->window, PropertyNotify, &pe) ) - compaction = True; - else - break; - } - - do_update = true; - } else if (event->type == ConfigureNotify) { - -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::event: handling ConfigureNotify event\n"); -#endif - - dirty |= WMGeometry; - - // update window geometry - p->win_geom.pos.x = event->xconfigure.x; - p->win_geom.pos.y = event->xconfigure.y; - p->win_geom.size.width = event->xconfigure.width; - p->win_geom.size.height = event->xconfigure.height; - } - - if( do_update ) - update( props ); - - if( properties_size > PROPERTIES_SIZE ) - properties_size = PROPERTIES_SIZE; - for( int i = 0; - i < properties_size; - ++i ) - properties[ i ] = props[ i ]; -} - -void NETWinInfo::updateWMState() { - unsigned long props[ PROPERTIES_SIZE ] = { XAWMState, 0 }; - assert( PROPERTIES_SIZE == 2 ); // add elements above - update( props ); -} - -void NETWinInfo::update(const unsigned long dirty_props[]) { - Atom type_ret; - int format_ret; - unsigned long nitems_ret, unused; - unsigned char *data_ret; - unsigned long props[ PROPERTIES_SIZE ]; - for( int i = 0; - i < PROPERTIES_SIZE; - ++i ) - props[ i ] = dirty_props[ i ] & p->properties[ i ]; - const unsigned long& dirty = props[ PROTOCOLS ]; - const unsigned long& dirty2 = props[ PROTOCOLS2 ]; - - // we *always* want to update WM_STATE if set in dirty_props - if( dirty_props[ PROTOCOLS ] & XAWMState ) - props[ PROTOCOLS ] |= XAWMState; - - if (dirty & XAWMState) { - p->mapping_state = Withdrawn; - if (XGetWindowProperty(p->display, p->window, xa_wm_state, 0l, 1l, - False, xa_wm_state, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == xa_wm_state && format_ret == 32 && - nitems_ret == 1) { - long *state = (long *) data_ret; - - switch(*state) { - case IconicState: - p->mapping_state = Iconic; - break; - case NormalState: - p->mapping_state = Visible; - break; - case WithdrawnState: - default: - p->mapping_state = Withdrawn; - break; - } - - p->mapping_state_dirty = False; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMState) { - p->state = 0; - if (XGetWindowProperty(p->display, p->window, net_wm_state, 0l, 2048l, - False, XA_ATOM, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) { - // determine window state -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::update: updating window state (%ld)\n", - nitems_ret); -#endif - - long *states = (long *) data_ret; - unsigned long count; - - for (count = 0; count < nitems_ret; count++) { -#ifdef NETWMDEBUG - char* data_ret = XGetAtomName(p->display, (Atom) states[count]); - fprintf(stderr, - "NETWinInfo::update: adding window state %ld '%s'\n", - states[count], data_ret ); - if ( data_ret ) - XFree( data_ret ); -#endif - - if ((Atom) states[count] == net_wm_state_modal) - p->state |= Modal; - else if ((Atom) states[count] == net_wm_state_sticky) - p->state |= Sticky; - else if ((Atom) states[count] == net_wm_state_max_vert) - p->state |= MaxVert; - else if ((Atom) states[count] == net_wm_state_max_horiz) - p->state |= MaxHoriz; - else if ((Atom) states[count] == net_wm_state_shaded) - p->state |= Shaded; - else if ((Atom) states[count] == net_wm_state_skip_taskbar) - p->state |= SkipTaskbar; - else if ((Atom) states[count] == net_wm_state_skip_pager) - p->state |= SkipPager; - else if ((Atom) states[count] == net_wm_state_hidden) - p->state |= Hidden; - else if ((Atom) states[count] == net_wm_state_fullscreen) - p->state |= FullScreen; - else if ((Atom) states[count] == net_wm_state_above) - p->state |= KeepAbove; - else if ((Atom) states[count] == net_wm_state_below) - p->state |= KeepBelow; - else if ((Atom) states[count] == net_wm_state_demands_attention) - p->state |= DemandsAttention; - else if ((Atom) states[count] == net_wm_state_stays_on_top) - p->state |= StaysOnTop; - } - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMDesktop) { - p->desktop = 0; - if (XGetWindowProperty(p->display, p->window, net_wm_desktop, 0l, 1l, - False, XA_CARDINAL, &type_ret, - &format_ret, &nitems_ret, - &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == 1) { - p->desktop = *((long *) data_ret); - if ((signed) p->desktop != OnAllDesktops) - p->desktop++; - - if ( p->desktop == 0 ) - p->desktop = OnAllDesktops; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMName) { - delete[] p->name; - p->name = NULL; - if (XGetWindowProperty(p->display, p->window, net_wm_name, 0l, - MAX_PROP_SIZE, False, UTF8_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) { - p->name = nstrndup((const char *) data_ret, nitems_ret); - } - - if( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMVisibleName) { - delete[] p->visible_name; - p->visible_name = NULL; - if (XGetWindowProperty(p->display, p->window, net_wm_visible_name, 0l, - MAX_PROP_SIZE, False, UTF8_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) { - p->visible_name = nstrndup((const char *) data_ret, nitems_ret); - } - - if( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMIconName) { - delete[] p->icon_name; - p->icon_name = NULL; - if (XGetWindowProperty(p->display, p->window, net_wm_icon_name, 0l, - MAX_PROP_SIZE, False, UTF8_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) { - p->icon_name = nstrndup((const char *) data_ret, nitems_ret); - } - - if( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMVisibleIconName) - { - delete[] p->visible_icon_name; - p->visible_icon_name = NULL; - if (XGetWindowProperty(p->display, p->window, net_wm_visible_icon_name, 0l, - MAX_PROP_SIZE, False, UTF8_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) { - p->visible_icon_name = nstrndup((const char *) data_ret, nitems_ret); - } - - if( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMWindowType) { - p->types.reset(); - p->types[ 0 ] = Unknown; - p->has_net_support = false; - if (XGetWindowProperty(p->display, p->window, net_wm_window_type, 0l, 2048l, - False, XA_ATOM, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) { - // determine the window type -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::update: getting window type (%ld)\n", - nitems_ret); -#endif - - p->has_net_support = true; - - unsigned long count = 0; - long *types = (long *) data_ret; - int pos = 0; - - while (count < nitems_ret) { - // remember all window types we know -#ifdef NETWMDEBUG - char* debug_type = XGetAtomName(p->display, (Atom) types[count]); - fprintf(stderr, - "NETWinInfo::update: examining window type %ld %s\n", - types[count], debug_type ); - if ( debug_type ) - XFree( debug_type ); -#endif - - if ((Atom) types[count] == net_wm_window_type_normal) - p->types[ pos++ ] = Normal; - else if ((Atom) types[count] == net_wm_window_type_desktop) - p->types[ pos++ ] = Desktop; - else if ((Atom) types[count] == net_wm_window_type_dock) - p->types[ pos++ ] = Dock; - else if ((Atom) types[count] == net_wm_window_type_toolbar) - p->types[ pos++ ] = Tool; - else if ((Atom) types[count] == net_wm_window_type_menu) - p->types[ pos++ ] = Menu; - else if ((Atom) types[count] == net_wm_window_type_dialog) - p->types[ pos++ ] = Dialog; - else if ((Atom) types[count] == net_wm_window_type_utility) - p->types[ pos++ ] = Utility; - else if ((Atom) types[count] == net_wm_window_type_splash) - p->types[ pos++ ] = Splash; - else if ((Atom) types[count] == net_wm_window_type_dropdown_menu) - p->types[ pos++ ] = DropdownMenu; - else if ((Atom) types[count] == net_wm_window_type_popup_menu) - p->types[ pos++ ] = PopupMenu; - else if ((Atom) types[count] == net_wm_window_type_tooltip) - p->types[ pos++ ] = Tooltip; - else if ((Atom) types[count] == net_wm_window_type_notification) - p->types[ pos++ ] = Notification; - else if ((Atom) types[count] == net_wm_window_type_combobox) - p->types[ pos++ ] = ComboBox; - else if ((Atom) types[count] == net_wm_window_type_dnd) - p->types[ pos++ ] = DNDIcon; - else if ((Atom) types[count] == kde_net_wm_window_type_override) - p->types[ pos++ ] = Override; - else if ((Atom) types[count] == kde_net_wm_window_type_topmenu) - p->types[ pos++ ] = TopMenu; - - count++; - } - } - - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMStrut) { - p->strut = NETStrut(); - if (XGetWindowProperty(p->display, p->window, net_wm_strut, 0l, 4l, - False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == 4) { - long *d = (long *) data_ret; - p->strut.left = d[0]; - p->strut.right = d[1]; - p->strut.top = d[2]; - p->strut.bottom = d[3]; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty2 & WM2ExtendedStrut) { - p->extended_strut = NETExtendedStrut(); - if (XGetWindowProperty(p->display, p->window, net_wm_extended_strut, 0l, 12l, - False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == 12) { - long *d = (long *) data_ret; - p->extended_strut.left_width = d[0]; - p->extended_strut.right_width = d[1]; - p->extended_strut.top_width = d[2]; - p->extended_strut.bottom_width = d[3]; - p->extended_strut.left_start = d[4]; - p->extended_strut.left_end = d[5]; - p->extended_strut.right_start = d[6]; - p->extended_strut.right_end = d[7]; - p->extended_strut.top_start = d[8]; - p->extended_strut.top_end = d[9]; - p->extended_strut.bottom_start = d[10]; - p->extended_strut.bottom_end = d[11]; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMIconGeometry) { - p->icon_geom = NETRect(); - if (XGetWindowProperty(p->display, p->window, net_wm_icon_geometry, 0l, 4l, - False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && - nitems_ret == 4) { - long *d = (long *) data_ret; - p->icon_geom.pos.x = d[0]; - p->icon_geom.pos.y = d[1]; - p->icon_geom.size.width = d[2]; - p->icon_geom.size.height = d[3]; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMIcon) { - readIcon(p->display,p->window,net_wm_icon,p->icons,p->icon_count); - } - - if (dirty & WMKDESystemTrayWinFor) { - p->kde_system_tray_win_for = 0; - if (XGetWindowProperty(p->display, p->window, kde_net_wm_system_tray_window_for, - 0l, 1l, False, XA_WINDOW, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_WINDOW && format_ret == 32 && - nitems_ret == 1) { - p->kde_system_tray_win_for = *((Window *) data_ret); - if ( p->kde_system_tray_win_for == 0 ) - p->kde_system_tray_win_for = p->root; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMFrameExtents) { - p->frame_strut = NETStrut(); - bool ok = false; - if (XGetWindowProperty(p->display, p->window, net_frame_extents, - 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) { - ok = true; - long *d = (long *) data_ret; - - p->frame_strut.left = d[0]; - p->frame_strut.right = d[1]; - p->frame_strut.top = d[2]; - p->frame_strut.bottom = d[3]; - } - if ( data_ret ) - XFree(data_ret); - } - if (!ok && XGetWindowProperty(p->display, p->window, kde_net_wm_frame_strut, - 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) { - ok = true; - long *d = (long *) data_ret; - - p->frame_strut.left = d[0]; - p->frame_strut.right = d[1]; - p->frame_strut.top = d[2]; - p->frame_strut.bottom = d[3]; - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty & WMPid) { - p->pid = 0; - if (XGetWindowProperty(p->display, p->window, net_wm_pid, 0l, 1l, - False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) == Success) { - if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) { - p->pid = *((long *) data_ret); - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty2 & WM2StartupId) - { - delete[] p->startup_id; - p->startup_id = NULL; - if (XGetWindowProperty(p->display, p->window, net_startup_id, 0l, - MAX_PROP_SIZE, False, UTF8_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == UTF8_STRING && format_ret == 8 && nitems_ret > 0) { - p->startup_id = nstrndup((const char *) data_ret, nitems_ret); - } - - if( data_ret ) - XFree(data_ret); - } - } - - if( dirty2 & WM2AllowedActions ) { - p->allowed_actions = 0; - if (XGetWindowProperty(p->display, p->window, net_wm_allowed_actions, 0l, 2048l, - False, XA_ATOM, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) { - // determine actions -#ifdef NETWMDEBUG - fprintf(stderr, "NETWinInfo::update: updating allowed actions (%ld)\n", - nitems_ret); -#endif - - long *actions = (long *) data_ret; - unsigned long count; - - for (count = 0; count < nitems_ret; count++) { -#ifdef NETWMDEBUG - fprintf(stderr, - "NETWinInfo::update: adding allowed action %ld '%s'\n", - actions[count], - XGetAtomName(p->display, (Atom) actions[count])); -#endif - - if ((Atom) actions[count] == net_wm_action_move) - p->allowed_actions |= ActionMove; - if ((Atom) actions[count] == net_wm_action_resize) - p->allowed_actions |= ActionResize; - if ((Atom) actions[count] == net_wm_action_minimize) - p->allowed_actions |= ActionMinimize; - if ((Atom) actions[count] == net_wm_action_shade) - p->allowed_actions |= ActionShade; - if ((Atom) actions[count] == net_wm_action_stick) - p->allowed_actions |= ActionStick; - if ((Atom) actions[count] == net_wm_action_max_vert) - p->allowed_actions |= ActionMaxVert; - if ((Atom) actions[count] == net_wm_action_max_horiz) - p->allowed_actions |= ActionMaxHoriz; - if ((Atom) actions[count] == net_wm_action_fullscreen) - p->allowed_actions |= ActionFullScreen; - if ((Atom) actions[count] == net_wm_action_change_desk) - p->allowed_actions |= ActionChangeDesktop; - if ((Atom) actions[count] == net_wm_action_close) - p->allowed_actions |= ActionClose; - } - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty2 & WM2UserTime) { - p->user_time = -1U; - if (XGetWindowProperty(p->display, p->window, net_wm_user_time, 0l, 1l, - False, XA_CARDINAL, &type_ret, &format_ret, - &nitems_ret, &unused, &data_ret) == Success) { - // don't do nitems_ret check - Qt does PropModeAppend to avoid API call for it - if (type_ret == XA_CARDINAL && format_ret == 32 /*&& nitems_ret == 1*/) { - p->user_time = *((long *) data_ret); - } - if ( data_ret ) - XFree(data_ret); - } - } - - if (dirty2 & WM2TransientFor) { - p->transient_for = None; - XGetTransientForHint(p->display, p->window, &p->transient_for); - } - - if (dirty2 & WM2GroupLeader) { - XWMHints *hints = XGetWMHints(p->display, p->window); - p->window_group = None; - if ( hints ) - { - if( hints->flags & WindowGroupHint ) - p->window_group = hints->window_group; - XFree( reinterpret_cast< char* >( hints )); - } - } - - if( dirty2 & WM2WindowClass ) { - delete[] p->class_class; - delete[] p->class_name; - p->class_class = NULL; - p->class_name = NULL; - XClassHint hint; - if( XGetClassHint( p->display, p->window, &hint )) { - p->class_class = strdup( hint.res_class ); - p->class_name = strdup( hint.res_name ); - XFree( hint.res_class ); - XFree( hint.res_name ); - } - } - - if( dirty2 & WM2WindowRole ) { - delete[] p->role; - p->role = NULL; - if (XGetWindowProperty(p->display, p->window, wm_window_role, 0l, - MAX_PROP_SIZE, False, XA_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) { - p->role = nstrndup((const char *) data_ret, nitems_ret); - } - if( data_ret ) - XFree(data_ret); - } - } - - if( dirty2 & WM2ClientMachine ) { - delete[] p->client_machine; - p->client_machine = NULL; - if (XGetWindowProperty(p->display, p->window, XA_WM_CLIENT_MACHINE, 0l, - MAX_PROP_SIZE, False, XA_STRING, &type_ret, - &format_ret, &nitems_ret, &unused, &data_ret) - == Success) { - if (type_ret == XA_STRING && format_ret == 8 && nitems_ret > 0) { - p->client_machine = nstrndup((const char *) data_ret, nitems_ret); - } - if( data_ret ) - XFree(data_ret); - } - } -} - - -NETRect NETWinInfo::iconGeometry() const { - return p->icon_geom; -} - - -unsigned long NETWinInfo::state() const { - return p->state; -} - - -NETStrut NETWinInfo::strut() const { - return p->strut; -} - -NETExtendedStrut NETWinInfo::extendedStrut() const { - return p->extended_strut; -} - -bool NET::typeMatchesMask( WindowType type, unsigned long mask ) { - switch( type ) { -#define CHECK_TYPE_MASK( type ) \ - case type: \ - if( mask & type##Mask ) \ - return true; \ - break; - CHECK_TYPE_MASK( Normal ) - CHECK_TYPE_MASK( Desktop ) - CHECK_TYPE_MASK( Dock ) - CHECK_TYPE_MASK( Toolbar ) - CHECK_TYPE_MASK( Menu ) - CHECK_TYPE_MASK( Dialog ) - CHECK_TYPE_MASK( Override ) - CHECK_TYPE_MASK( TopMenu ) - CHECK_TYPE_MASK( Utility ) - CHECK_TYPE_MASK( Splash ) - CHECK_TYPE_MASK( DropdownMenu ) - CHECK_TYPE_MASK( PopupMenu ) - CHECK_TYPE_MASK( Tooltip ) - CHECK_TYPE_MASK( Notification ) - CHECK_TYPE_MASK( ComboBox ) - CHECK_TYPE_MASK( DNDIcon ) -#undef CHECK_TYPE_MASK - default: - break; - } - return false; -} - -NET::WindowType NETWinInfo::windowType( unsigned long supported_types ) const { - for( int i = 0; - i < p->types.size(); - ++i ) { - // return the type only if the application supports it - if( typeMatchesMask( p->types[ i ], supported_types )) - return p->types[ i ]; - } - return Unknown; -} - -NET::WindowType NETWinInfo::windowType() const { - return p->types[ 0 ]; -} - - -const char *NETWinInfo::name() const { - return p->name; -} - - -const char *NETWinInfo::visibleName() const { - return p->visible_name; -} - - -const char *NETWinInfo::iconName() const { - return p->icon_name; -} - - -const char *NETWinInfo::visibleIconName() const { - return p->visible_icon_name; -} - - -int NETWinInfo::desktop() const { - return p->desktop; -} - -int NETWinInfo::pid() const { - return p->pid; -} - -Time NETWinInfo::userTime() const { - return p->user_time; -} - -const char* NETWinInfo::startupId() const { - return p->startup_id; -} - -unsigned long NETWinInfo::allowedActions() const { - return p->allowed_actions; -} - -bool NETWinInfo::hasNETSupport() const { - return p->has_net_support; -} - -Window NETWinInfo::transientFor() const { - return p->transient_for; -} - -Window NETWinInfo::groupLeader() const { - return p->window_group; -} - -const char* NETWinInfo::windowClassClass() const { - return p->class_class; -} - -const char* NETWinInfo::windowClassName() const { - return p->class_name; -} - -const char* NETWinInfo::windowRole() const { - return p->role; -} - -const char* NETWinInfo::clientMachine() const { - return p->client_machine; -} - -Bool NETWinInfo::handledIcons() const { - return p->handled_icons; -} - - -Window NETWinInfo::kdeSystemTrayWinFor() const { - return p->kde_system_tray_win_for; -} - -const unsigned long* NETWinInfo::passedProperties() const { - return p->properties; -} - -unsigned long NETWinInfo::properties() const { - return p->properties[ PROTOCOLS ]; -} - - -NET::MappingState NETWinInfo::mappingState() const { - return p->mapping_state; -} - -void NETRootInfo::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void NETWinInfo::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -// Functions for X timestamp comparing. For Time being 32bit they're fairly simple -// (the #if 0 part), but on 64bit architectures Time is 64bit unsigned long, -// so there special care needs to be taken to always use only the lower 32bits. -#if 0 -int NET::timestampCompare( Time time1, Time time2 ) // like strcmp() - { - if( time1 == time2 ) - return 0; - return ( time1 - time2 ) < 0x7fffffffU ? 1 : -1; // time1 > time2 -> 1, handle wrapping - } - -Time NET::timestampDiff( Time time1, Time time2 ) // returns time2 - time1 - { // no need to handle wrapping? - return time2 - time1; - } -#else -int NET::timestampCompare( unsigned long time1_, unsigned long time2_ ) // like strcmp() - { - TQ_UINT32 time1 = time1_; - TQ_UINT32 time2 = time2_; - if( time1 == time2 ) - return 0; - return TQ_UINT32( time1 - time2 ) < 0x7fffffffU ? 1 : -1; // time1 > time2 -> 1, handle wrapping - } - -int NET::timestampDiff( unsigned long time1_, unsigned long time2_ ) // returns time2 - time1 - { // no need to handle wrapping? - TQ_UINT32 time1 = time1_; - TQ_UINT32 time2 = time2_; - return TQ_UINT32( time2 - time1 ); - } -#endif - - -#endif diff --git a/kdecore/netwm.h b/kdecore/netwm.h deleted file mode 100644 index cc39ada1d..000000000 --- a/kdecore/netwm.h +++ /dev/null @@ -1,1471 +0,0 @@ -/* - - Copyright (c) 2000 Troll Tech AS - Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> - - 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 __net_wm_h -#define __net_wm_h - -#include "kdelibs_export.h" -#include <tqwidget.h> -#ifdef Q_WS_X11 -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xatom.h> - -#include "netwm_def.h" - -// forward declaration -struct NETRootInfoPrivate; -struct NETWinInfoPrivate; -template <class Z> class NETRArray; - - -/** - Common API for root window properties/protocols. - - The NETRootInfo class provides a common API for clients and window managers - to set/read/change properties on the root window as defined by the NET Window - Manager Specification.. - - @author Bradley T. Hughes <bhughes@trolltech.com> - @see NET - @see NETWinInfo - @see KWin - **/ - -class KDECORE_EXPORT NETRootInfo : public NET { -public: - /** - Indexes for the properties array. - @since 3.2 - **/ - // update also NETRootInfoPrivate::properties[] size when extending this - enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS, - PROPERTIES_SIZE }; - - /** - Window Managers should use this constructor to create a NETRootInfo object, - which will be used to set/update information stored on the rootWindow. - The application role is automatically set to WindowManager - when using this constructor. - - @param display An X11 Display struct. - - @param supportWindow The Window id of the supportWindow. The supportWindow - must be created by the window manager as a child of the rootWindow. The - supportWindow must not be destroyed until the Window Manager exits. - - @param wmName A string which should be the window manager's name (ie. "KWin" - or "Blackbox"). - - @param properties An array of elements listing all properties and protocols - the window manager supports. The elements contain OR'ed values of constants - from the NET base class, in the following order: [0]= NET::Property, - [1]= NET::WindowTypeMask (not NET::WindowType!), [2]= NET::State, - [3]= NET::Property2, [4]= NET::Action. - In future versions, the list may be extended. In case you pass less elements, - the missing ones will be replaced with default values. - - @param properties_size The number of elements in the properties array. - - @param screen For Window Managers that support multiple screen (ie. - "multiheaded") displays, the screen number may be explicitly defined. If - this argument is omitted, the default screen will be used. - - @param doActivate true to activate the window - - @since 3.2 - **/ - NETRootInfo(Display *display, Window supportWindow, const char *wmName, - const unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - - /** - @deprecated - This constructor differs from the above one only in the way it accepts - the list of supported properties. The properties argument is equivalent - to the first element of the properties array in the above constructor. - **/ - NETRootInfo(Display *display, Window supportWindow, const char *wmName, - unsigned long properties, int screen = -1, bool doActivate = true) KDE_DEPRECATED; - - /** - Clients should use this constructor to create a NETRootInfo object, which - will be used to query information set on the root window. The application - role is automatically set to Client when using this constructor. - - @param display An X11 Display struct. - - @param properties An array of elements listing all protocols the client - is interested in. The elements contain OR'ed values of constants - from the NET base class, in the following order: [0]= NET::Property, - [1]= NET::Property2. - - @param properties_size The number of elements in the properties array. - - @param screen For Clients that support multiple screen (ie. "multiheaded") - displays, the screen number may be explicitly defined. If this argument is - omitted, the default screen will be used. - - @param doActivate true to activate the window - - @since 3.2 - **/ - NETRootInfo(Display *display, const unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - - /** - This constructor differs from the above one only in the way it accepts - the list of supported properties. The properties argument is equivalent - to the first element of the properties array in the above constructor, - and therefore you cannot read all root window properties using it. - **/ - NETRootInfo(Display *display, unsigned long properties, int screen = -1, - bool doActivate = true); - - /** - Creates a shared copy of the specified NETRootInfo object. - - @param rootinfo the NETRootInfo object to copy - **/ - NETRootInfo(const NETRootInfo &rootinfo); - - /** - Destroys the NETRootInfo object. - **/ - virtual ~NETRootInfo(); - - /** - Returns the X11 Display struct used. - - @return the X11 Display - **/ - Display *x11Display() const; - - /** - Returns the Window id of the rootWindow. - - @return the id of the root window - **/ - Window rootWindow() const; - - /** - Returns the Window id of the supportWindow. - - @return the id of the support window - **/ - Window supportWindow() const; - - /** - Returns the name of the Window Manager. - - @return the name of the window manager - **/ - const char *wmName() const; - - /** - Returns the screenNumber. - - @return the screen number - **/ - int screenNumber() const; - - /** - Returns true if the given property is supported by the window - manager. Note that for Client mode, NET::Supported needs - to be passed in the properties argument for this to work. - @since 3.2 - **/ - bool isSupported( NET::Property property ) const; - /** - @overload - @since 3.2 - **/ - bool isSupported( NET::Property2 property ) const; - /** - @overload - @since 3.2 - **/ - bool isSupported( NET::WindowType type ) const; - /** - @overload - @since 3.2 - **/ - bool isSupported( NET::State state ) const; - - /** - @overload - @since 3.2 - **/ - bool isSupported( NET::Action action ) const; - - /** - In the Window Manager mode, this is equivalent to the properties - argument passed to the constructor. In the Client mode, if - NET::Supported was passed in the properties argument, the returned - value is array of all protocols and properties supported - by the Window Manager. The elements of the array are the same - as they would be passed to the Window Manager mode constructor, - the size is the maximum array size the constructor accepts. - - @since 3.2 - **/ - const unsigned long* supportedProperties() const; - - /** - Returns the properties argument passed to the constructor. - The size is the maximum array size the constructor accepts. - - @since 3.2 - **/ - // KDE4 better name? - const unsigned long* passedProperties() const; - - /** - @deprecated - - Returns an OR'ed list of protocols passed to the constructor. - For the constructor used by Window Managers, this is equivalent - to the first element of the properties argument, for the constructor - for Clients, it's the properties argument. - - Clients willing to find out all properties and protocols supported - by the WindowManager should use supportedProperties(). - - @return an OR'ed list of protocols - - @see NET::Property - **/ - unsigned long supported() const KDE_DEPRECATED; - - /** - Returns an array of Window id's, which contain all managed windows. - - @return the array of Window id's - - @see clientListCount() - **/ - const Window *clientList() const; - - /** - Returns the number of managed windows in clientList array. - - @return the number of managed windows in the clientList array - - @see clientList() - **/ - int clientListCount() const; - - /** - Returns an array of Window id's, which contain all managed windows in - stacking order. - - @return the array of Window id's in stacking order - - @see clientListStackingCount() - **/ - const Window *clientListStacking() const; - - /** - Returns the number of managed windows in the clientListStacking array. - - @return the number of Window id's in the client list - - @see clientListStacking() - **/ - int clientListStackingCount() const; - - /** - Returns an array of Window id's, which contain all KDE system tray windows. - - @return the array of Window id's of system tray windows - - @see kdeSystemTrayWindowsCount() - **/ - const Window *kdeSystemTrayWindows() const; - - /** - Returns the number of windows in the kdeSystemTrayWindows array. - - @return the number of Window id's in the system tray list - - @see kdeSystemTrayWindows() - **/ - int kdeSystemTrayWindowsCount() const; - - /** - Returns the desktop geometry size. - - The desktop argument is ignored. Early drafts of the NET WM - Specification were unclear about the semantics of this property. - - @param desktop the number of the desktop - - @return the size of the desktop - **/ - NETSize desktopGeometry(int desktop) const; - - /** - Returns the viewport of the specified desktop. - - @param desktop the number of the desktop - - @return the position of the desktop's viewport - **/ - NETPoint desktopViewport(int desktop) const; - - /** - Returns the workArea for the specified desktop. - - @param desktop the number of the desktop - - @return the size of the work area - **/ - NETRect workArea(int desktop) const; - - /** - Returns the name for the specified desktop. - - @param desktop the number of the desktop - - @return the name of the desktop - **/ - const char *desktopName(int desktop) const; - - /** - Returns an array of Window id's, which contain the virtual root windows. - - @return the array of Window id's - - @see virtualRootsCount() - **/ - const Window *virtualRoots( ) const; - - /** - Returns the number of window in the virtualRoots array. - - @return the number of Window id's in the virtual root array - - @see virtualRoots() - **/ - int virtualRootsCount() const; - - /** - Returns the desktop layout orientation. - **/ - NET::Orientation desktopLayoutOrientation() const; - - /** - Returns the desktop layout number of columns and rows. Note that - either may be 0 (see _NET_DESKTOP_LAYOUT). - **/ - TQSize desktopLayoutColumnsRows() const; - - /** - Returns the desktop layout starting corner. - **/ - NET::DesktopLayoutCorner desktopLayoutCorner() const; - - /** - Returns the number of desktops. - - @return the number of desktops - **/ - int numberOfDesktops() const; - - /** - Returns the current desktop. - - @return the number of the current desktop - **/ - int currentDesktop() const; - - /** - Returns the active (focused) window. - - @return the id of the active window - **/ - Window activeWindow() const; - - /** - Window Managers must call this after creating the NETRootInfo object, and - before using any other method in the class. This method sets initial data - on the root window and does other post-construction duties. - - Clients must also call this after creating the object to do an initial - data read/update. - **/ - void activate(); - - /** - Sets the list of managed windows on the Root/Desktop window. - - @param windows The array of Window id's - - @param count The number of windows in the array - **/ - // KDE4 'const Window*', also in the others below - void setClientList(Window *windows, unsigned int count); - - /** - Sets the list of managed windows in stacking order on the Root/Desktop - window. - - @param windows The array of Window id's - - @param count The number of windows in the array. - **/ - void setClientListStacking(Window *windows, unsigned int count); - - /** - Sets the list of KDE system tray windows on the root window. - - @param windows The array of window id's - - @param count The number of windows in the array. - **/ - void setKDESystemTrayWindows(Window *windows, unsigned int count); - - /** - Sets the current desktop to the specified desktop. - - @param desktop the number of the desktop - **/ - void setCurrentDesktop(int desktop); - - /** - Sets the desktop geometry to the specified geometry. - - The desktop argument is ignored. Early drafts of the NET WM - Specification were unclear about the semantics of this property. - - @param desktop the number of the desktop - - @param geometry the new size of the desktop - **/ - void setDesktopGeometry(int desktop, const NETSize &geometry); - - /** - Sets the viewport for the current desktop to the specified point. - - @param desktop the number of the desktop - - @param viewport the new position of the desktop's viewport - **/ - void setDesktopViewport(int desktop, const NETPoint &viewport); - - /** - Sets the number of desktops the the specified number. - - @param numberOfDesktops the number of desktops - **/ - void setNumberOfDesktops(int numberOfDesktops); - - /** - Sets the name of the specified desktop. - - @param desktop the number of the desktop - - @param desktopName the new name of the desktop - **/ - void setDesktopName(int desktop, const char *desktopName); - - /** - Requests that the specified window becomes the active (focused) one. - - @param window the id of the new active window - @param src whether the request comes from normal application - or from a pager or similar tool - @param timestamp X server timestamp of the user action that - caused the request - @param active_window active window of the requesting application, if any - - @since 3.2 - **/ - void setActiveWindow(Window window, NET::RequestSource src, - Time timestamp, Window active_window); - - /** - Sets the active (focused) window the specified window. This should - be used only in the window manager mode. - - @param window the if of the new active window - **/ - void setActiveWindow(Window window); - - /** - Sets the workarea for the specified desktop - - @param desktop the number of the desktop - - @param workArea the new work area of the desktop - **/ - void setWorkArea(int desktop, const NETRect &workArea); - - /** - Sets the list of virtual root windows on the root window. - - @param windows The array of Window id's - - @param count The number of windows in the array. - **/ - void setVirtualRoots(Window *windows, unsigned int count); - - /** - Sets the desktop layout. This is set by the pager. When setting, the pager must - own the _NET_DESKTOP_LAYOUT_Sn manager selection. See _NET_DESKTOP_LAYOUT for details. - **/ - void setDesktopLayout(NET::Orientation orientation, int columns, int rows, - NET::DesktopLayoutCorner corner); - - /** - * Sets the _NET_SHOWING_DESKTOP status (whether desktop is being shown). - * @since 3.5 - */ - void setShowingDesktop( bool showing ); - /** - * Returns the status of _NET_SHOWING_DESKTOP. - * @since 3.5 - */ - bool showingDesktop() const; - - /** - Assignment operator. Ensures that the shared data reference counts are - correct. - **/ - const NETRootInfo &operator=(const NETRootInfo &rootinfo); - - /** - Clients (such as pagers/taskbars) that wish to close a window should call - this function. This will send a request to the Window Manager, which - usually can usually decide how to react to such requests. - - @param window the id of the window to close - **/ - void closeWindowRequest(Window window); - - /** - Clients (such as pagers/taskbars) that wish to start a WMMoveResize - (where the window manager controls the resize/movement, - i.e. _NET_WM_MOVERESIZE) should call this function. - This will send a request to the Window Manager. - - @param window The client window that would be resized/moved. - - @param x_root X position of the cursor relative to the root window. - - @param y_root Y position of the cursor relative to the root window. - - @param direction One of NET::Direction (see base class documentation for - a description of the different directions). - **/ - void moveResizeRequest(Window window, int x_root, int y_root, - Direction direction); - - /** - Clients (such as pagers/taskbars) that wish to move/resize a window - using WM2MoveResizeWindow (_NET_MOVERESIZE_WINDOW) should call this function. - This will send a request to the Window Manager. See _NET_MOVERESIZE_WINDOW - description for details. - - @param window The client window that would be resized/moved. - @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description) - @param x Requested X position for the window - @param y Requested Y position for the window - @param width Requested width for the window - @param height Requested height for the window - - @since 3.2 - **/ - void moveResizeWindowRequest(Window window, int flags, int x, int y, int width, int height ); - - /** - Sends the _NET_RESTACK_WINDOW request. - @since 3.3 - **/ - void restackRequest(Window window, RequestSource source, Window above, int detail, Time timestamp); - /** - @obsolete - @since 3.2 - **/ - void restackRequest(Window window, Window above, int detail); - - /** - This function takes the passed XEvent and returns an OR'ed list of - NETRootInfo properties that have changed in the properties argument. - The new information will be read immediately by the class. - The elements of the properties argument are as they would be passed - to the constructor, if the array is not large enough, - changed properties that don't fit in it won't be listed there - (they'll be updated in the class though). - - @param event the event - @param properties properties that changed - @param properties_size size of the passed properties array - @since 3.2 - - **/ - void event( XEvent* event, unsigned long* properties, int properties_size ); - - /** - This function takes the passed XEvent and returns an OR'ed list of - NETRootInfo properties that have changed. The new information will be - read immediately by the class. This overloaded version returns - only a single mask, and therefore cannot check state of all properties - like the other variant. - - @param event the event - - @return the properties - **/ - unsigned long event(XEvent *event); - - -protected: - /** - A Client should subclass NETRootInfo and reimplement this function when - it wants to know when a window has been added. - - @param window the id of the window to add - **/ - virtual void addClient(Window window) { Q_UNUSED(window); } - - /** - A Client should subclass NETRootInfo and reimplement this function when - it wants to know when a window has been removed. - - @param window the id of the window to remove - **/ - virtual void removeClient(Window window) { Q_UNUSED(window); } - - /** - A Client should subclass NETRootInfo and reimplement this function when - it wants to know when a system tray window has been added. This is a KDE 2.0 - extension. - - @param window the id of the window to add - **/ - virtual void addSystemTrayWin(Window window) { Q_UNUSED(window); } - - /** - A Client should subclass NETRootInfo and reimplement this function when - it wants to know when a system tray window has been removed. This is a KDE 2.0 - extension. - - @param window the id of the window to remove - **/ - virtual void removeSystemTrayWin(Window window) { Q_UNUSED(window); } - - /** - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to change the number - of desktops. - - @param numberOfDesktops the new number of desktops - **/ - virtual void changeNumberOfDesktops(int numberOfDesktops) { Q_UNUSED(numberOfDesktops); } - - /** - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to change the specified - desktop geometry. - - @param desktop the number of the desktop - - @param geom the new size - **/ - virtual void changeDesktopGeometry(int desktop, const NETSize &geom) { Q_UNUSED(desktop); Q_UNUSED(geom); } - - /** - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to change the specified - desktop viewport. - - @param desktop the number of the desktop - - @param viewport the new position of the viewport - **/ - virtual void changeDesktopViewport(int desktop, const NETPoint &viewport) { Q_UNUSED(desktop); Q_UNUSED(viewport); } - - /** - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to change the current - desktop. - - @param desktop the number of the desktop - **/ - virtual void changeCurrentDesktop(int desktop) { Q_UNUSED(desktop); } - - /** - @deprecated Use NETRootInfo2::changeActiveWindow() instead. - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to change the active - (focused) window. The changeActiveWindow() method in NETRootInfo2 - should be used instead. - - @param window the id of the window to activate - **/ - virtual KDE_DEPRECATED void changeActiveWindow(Window window) { Q_UNUSED(window); } - - /** - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to close a window. - - @param window the id of the window to close - **/ - virtual void closeWindow(Window window) { Q_UNUSED(window); } - - /** - A Window Manager should subclass NETRootInfo and reimplement this function - when it wants to know when a Client made a request to start a move/resize. - - @param window The window that wants to move/resize - - @param x_root X position of the cursor relative to the root window. - - @param y_root Y position of the cursor relative to the root window. - - @param direction One of NET::Direction (see base class documentation for - a description of the different directions). - **/ - virtual void moveResize(Window window, int x_root, int y_root, - unsigned long direction) { Q_UNUSED(window); Q_UNUSED(x_root); Q_UNUSED(y_root); Q_UNUSED(direction); } - - -private: - void update( const unsigned long[] ); - void setSupported(); - void setDefaultProperties(); - void updateSupportedProperties( Atom atom ); - Role role; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - NETRootInfoPrivate *p; - friend class NETRootInfo2; - friend class NETRootInfo3; -}; - -/** - This class is an extension of the NETRootInfo class, and exists solely - for binary compatibility reasons (adds new virtual methods). Simply - use it instead of NETRootInfo and override also the added virtual methods. - @since 3.2 -*/ -class KDECORE_EXPORT NETRootInfo2 - : public NETRootInfo -{ -public: - NETRootInfo2(Display *display, Window supportWindow, const char *wmName, - unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - /** - * @since 3.5 - */ - NETRootInfo2(Display *display, const unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - /** - Sends a ping with the given timestamp to the window, using - the _NET_WM_PING protocol. - */ - void sendPing( Window window, Time timestamp ); -protected: - friend class NETRootInfo; - /** - A Window Manager should subclass NETRootInfo2 and reimplement this function - when it wants to receive replies to the _NET_WM_PING protocol. - @param window the window from which the reply came - @param timestamp timestamp of the ping - */ - virtual void gotPing( Window window, Time timestamp ) { Q_UNUSED(window); Q_UNUSED(timestamp); } - /** - A Window Manager should subclass NETRootInfo2 and reimplement this function - when it wants to know when a Client made a request to change the active - (focused) window. - - @param window the id of the window to activate - @param src the source from which the request came - @param timestamp the timestamp of the user action causing this request - @param active_window active window of the requesting application, if any - **/ - virtual void changeActiveWindow(Window window,NET::RequestSource src, - Time timestamp, Window active_window ) { Q_UNUSED(window); Q_UNUSED(src); Q_UNUSED(timestamp); Q_UNUSED(active_window);} - /** - A Window Manager should subclass NETRootInfo2 and reimplement this function - when it wants to know when a Client made a request to restack a window. - See _NET_RESTACK_WINDOW for details. - - @param window the id of the window to restack - @param above other window in the restack request - @param detail restack detail - **/ - virtual void restackWindow(Window window, Window above, int detail) { Q_UNUSED(window); Q_UNUSED(above); Q_UNUSED(detail); } - - /** - A Window Manager should subclass NETRootInfo2 and reimplement this function - when it wants to know when a pager made a request to move/resize a window. - See _NET_MOVERESIZE_WINDOW for details. - - @param window the id of the window to more/resize - @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description) - @param x Requested X position for the window - @param y Requested Y position for the window - @param width Requested width for the window - @param height Requested height for the window - **/ - virtual void moveResizeWindow(Window window, int flags, int x, int y, int width, int height) { Q_UNUSED(window); Q_UNUSED(flags); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(width); Q_UNUSED(height); } - -// no private data, use NETRootInfoPrivate -}; - -/** - This class is an extension of the NETRootInfo class, and exists solely - for binary compatibility reasons (adds new virtual methods). Simply - use it instead of NETRootInfo and override also the added virtual methods. - @since 3.3 -*/ -class KDECORE_EXPORT NETRootInfo3 - : public NETRootInfo2 -{ -public: - NETRootInfo3(Display *display, Window supportWindow, const char *wmName, - unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - /** - * @since 3.5 - */ - NETRootInfo3(Display *display, const unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - /** - Sends a take activity message with the given timestamp to the window, using - the _NET_WM_TAKE_ACTIVITY protocol (see the WM spec for details). - @param window the window to which the message should be sent - @param timestamp timestamp of the message - @param flags arbitrary flags - */ - void takeActivity( Window window, Time timestamp, long flags ); -protected: - friend class NETRootInfo; - /** - A Window Manager should subclass NETRootInfo3 and reimplement this function - when it wants to know when a Client made a request to restack a window. - See _NET_RESTACK_WINDOW for details. - - @param window the id of the window to restack - @param source the source of the request - @param above other window in the restack request - @param detail restack detail - @param timestamp the timestamp of the request - **/ - virtual void restackWindow(Window window, RequestSource source, - Window above, int detail, Time timestamp) { Q_UNUSED(window); Q_UNUSED(source); Q_UNUSED(above); Q_UNUSED(detail); Q_UNUSED(timestamp); } - /** - A Window Manager should subclass NETRootInfo3 and reimplement this function - when it wants to receive replies to the _NET_WM_TAKE_ACTIVITY protocol. - @param window the window from which the reply came - @param timestamp timestamp of the ping - @param flags flags passed in the original message - */ - virtual void gotTakeActivity(Window window, Time timestamp, long flags ) { Q_UNUSED(window); Q_UNUSED(timestamp); Q_UNUSED(flags); } -// no private data, use NETRootInfoPrivate -}; - -/** - This class is an extension of the NETRootInfo class, and exists solely - for binary compatibility reasons (adds new virtual methods). Simply - use it instead of NETRootInfo and override also the added virtual methods. - @since 3.5 -*/ -class KDECORE_EXPORT NETRootInfo4 - : public NETRootInfo3 -{ -public: - NETRootInfo4(Display *display, Window supportWindow, const char *wmName, - unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - NETRootInfo4(Display *display, const unsigned long properties[], int properties_size, - int screen = -1, bool doActivate = true); - -protected: - friend class NETRootInfo; - /** - A Window Manager should subclass NETRootInfo2 and reimplement this function - when it wants to know when a pager made a request to change showing the desktop. - See _NET_SHOWING_DESKTOP for details. - - @param showing whether to activate the showing desktop mode - **/ - virtual void changeShowingDesktop(bool showing) { Q_UNUSED(showing); } -// no private data, use NETRootInfoPrivate -}; - -/** - Common API for application window properties/protocols. - - The NETWinInfo class provides a common API for clients and window managers to - set/read/change properties on an application window as defined by the NET - Window Manager Specification. - - @author Bradley T. Hughes <bhughes@trolltech.com> - @see NET - @see NETRootInfo - @see KWin - @see http://www.freedesktop.org/standards/wm-spec/ - **/ - -class KDECORE_EXPORT NETWinInfo : public NET { -public: - /** - Indexes for the properties array. - @since 3.2 - **/ - // update also NETWinInfoPrivate::properties[] size when extending this - enum { PROTOCOLS, PROTOCOLS2, - PROPERTIES_SIZE }; - /** - Create a NETWinInfo object, which will be used to set/read/change - information stored on an application window. - - @param display An X11 Display struct. - - @param window The Window id of the application window. - - @param rootWindow The Window id of the root window. - - @param properties An array of elements listing all properties the client - is interested in.The elements contain OR'ed values of constants - from the NET base class, in the following order: [0]= NET::Property, - [1]= NET::Property2. - In future versions, the list may be extended. In case you pass less elements, - the missing ones will be replaced with default values. - - @param properties_size The number of elements in the properties array. - - @param role Select the application role. If this argument is omitted, - the role will default to Client. - - @since 3.2 - **/ - NETWinInfo(Display *display, Window window, Window rootWindow, - const unsigned long properties[], int properties_size, - Role role = Client); - - /** - This constructor differs from the above one only in the way it accepts - the list of properties the client is interested in. The properties argument - is equivalent to the first element of the properties array - in the above constructor. - **/ - NETWinInfo(Display *display, Window window, - Window rootWindow, unsigned long properties, - Role role = Client); - - /** - Creates a shared copy of the specified NETWinInfo object. - - @param wininfo the NETWinInfo to copy - **/ - NETWinInfo(const NETWinInfo & wininfo); - - /** - Destroys the NETWinInfo object. - **/ - virtual ~NETWinInfo(); - - /** - Assignment operator. Ensures that the shared data reference counts are - correct. - **/ - const NETWinInfo &operator=(const NETWinInfo &wintinfo); - - /** - Returns true if the window has any window type set, even if the type - itself is not known to this implementation. Presence of a window type - as specified by the NETWM spec is considered as the window supporting - this specification. - @since 3.2 - @return true if the window has support for the NETWM spec - **/ - bool hasNETSupport() const; - - /** - Returns the properties argument passed to the constructor. - The size is the maximum array size the constructor accepts. - - @since 3.2 - **/ - // KDE4 better name? - const unsigned long* passedProperties() const; - - /** - @deprecated - - Returns an OR'ed list of protocols passed to the constructor. - - @return an OR'ed list of protocols - - @see NET::Property - **/ - unsigned long properties() const KDE_DEPRECATED; - - /** - Returns the icon geometry. - - @return the geometry of the icon - **/ - NETRect iconGeometry() const; - - /** - Returns the state of the window (see the NET base class documentation for a - description of the various states). - - @return the state of the window - **/ - unsigned long state() const; - - /** - Returns the extended (partial) strut specified by this client. - See _NET_WM_STRUT_PARTIAL in the spec. - **/ - NETExtendedStrut extendedStrut() const; - - /** - @deprecated use strutPartial() - Returns the strut specified by this client. - - @return the strut of the window - **/ - NETStrut strut() const; - - /** - Returns the window type for this client (see the NET base class - documentation for a description of the various window types). - Since clients may specify several windows types for a window - in order to support backwards compatibility and extensions - not available in the NETWM spec, you should specify all - window types you application supports (see the NET::WindowTypeMask - mask values for various window types). This method will - return the first window type that is listed in the supported types, - or NET::Unknown if none of the window types is supported. - - @return the type of the window - @since 3.2 - **/ - WindowType windowType( unsigned long supported_types ) const; - - /** - @deprecated - Returns the window type for this client (see the NET base class - documentation for a description of the various window types). - - @return the type of the window - **/ - WindowType windowType() const KDE_DEPRECATED; - - /** - Returns the name of the window in UTF-8 format. - - @return the name of the window - **/ - const char *name() const; - - /** - Returns the visible name as set by the window manager in UTF-8 format. - - @return the visible name of the window - **/ - const char *visibleName() const; - - /** - Returns the iconic name of the window in UTF-8 format. Note that this has - nothing to do with icons, but it's for "iconic" - representations of the window (taskbars etc.), that should be shown - when the window is in iconic state. See description of _NET_WM_ICON_NAME - for details. - - @return the iconic name - **/ - const char *iconName() const; - - /** - Returns the visible iconic name as set by the window manager in UTF-8 format. - Note that this has nothing to do with icons, but it's for "iconic" - representations of the window (taskbars etc.), that should be shown - when the window is in iconic state. See description of _NET_WM_VISIBLE_ICON_NAME - for details. - - @return the visible iconic name - **/ - const char *visibleIconName() const; - - /** - Returns the desktop where the window is residing. - - @return the number of the window's desktop - - @see OnAllDesktops() - **/ - int desktop() const; - - /** - Returns the process id for the client window. - - @return the process id of the window - **/ - int pid() const; - - /** - Returns whether or not this client handles icons. - - @return true if this client handles icons, false otherwise - **/ - Bool handledIcons() const; - - /** - Returns a Window id, telling the window manager which window we are - representing. - - @return the window id - **/ - Window kdeSystemTrayWinFor() const; - - /** - Returns the mapping state for the window (see the NET base class - documentation for a description of mapping state). - - @return the mapping state - **/ - MappingState mappingState() const; - - /** - Set icons for the application window. If replace is True, then - the specified icon is defined to be the only icon. If replace is False, - then the specified icon is added to a list of icons. - - @param icon the new icon - - @param replace true to replace, false to append to the list of icons - **/ - void setIcon(NETIcon icon, Bool replace = True); - - /** - Set the icon geometry for the application window. - - @param geometry the new icon geometry - **/ - void setIconGeometry(NETRect geometry); - - /** - Set the extended (partial) strut for the application window. - - @param extended_strut the new strut - **/ - void setExtendedStrut(const NETExtendedStrut& extended_strut ); - - /** - @deprecated use setExtendedStrut() - Set the strut for the application window. - - @param strut the new strut - **/ - void setStrut(NETStrut strut); - - /** - Set the state for the application window (see the NET base class documentation - for a description of window state). Note that the constructor needs to be - passed NET::WMState in properties even if it's only used for setting the state - without reading it. - - @param state the name state - - @param mask the mask for the state - **/ - void setState(unsigned long state, unsigned long mask); - - /** - Sets the window type for this client (see the NET base class - documentation for a description of the various window types). - - @param type the window type - **/ - void setWindowType(WindowType type); - - /** - Sets the name for the application window. - - @param name the new name of the window - **/ - void setName(const char *name); - - /** - For Window Managers only: set the visible name ( i.e. xterm, xterm <2>, - xterm <3>, ... ) - - @param visibleName the new visible name - **/ - void setVisibleName(const char *visibleName); - - /** - Sets the iconic name for the application window. - - @param name the new iconic name - **/ - void setIconName(const char *name); - - /** - For Window Managers only: set the visible iconic name ( i.e. xterm, xterm <2>, - xterm <3>, ... ) - - @param name the new visible iconic name - **/ - void setVisibleIconName(const char *name); - - /** - Set which window the desktop is (should be) on. - - @param desktop the number of the new desktop - - @see OnAllDesktops() - **/ - void setDesktop(int desktop); - - /** - Set the application window's process id. - - @param pid the window's process id - **/ - void setPid(int pid); - - /** - Set whether this application window handles icons. - - @param handled true if the window handles icons, false otherwise - **/ - void setHandledIcons(Bool handled); - - /** - Set which window we are representing as a system tray window. - - @param window the window that is represented by the system tray icon - **/ - void setKDESystemTrayWinFor(Window window); - - /** - Set the frame decoration strut, i.e. the width of the decoration borders. - - @param strut the new strut - @since 3.5 - **/ - void setFrameExtents(NETStrut strut); - - /** - Set the frame decoration strut. This is a KDE 2.0 extension to aid in - writing pager applications. - - @param strut the new strut - **/ - void setKDEFrameStrut(NETStrut strut); - - /** - Returns an icon. If width and height are passed, the icon returned will be - the closest it can find (the next biggest). If width and height are omitted, - then the largest icon in the list is returned. - - @param width the preferred width for the icon, -1 to ignore - - @param height the preferred height for the icon, -1 to ignore - - @return the icon - **/ - NETIcon icon(int width = -1, int height = -1) const; - - /* - * Sets user timestamp @p time on the window (property _NET_WM_USER_TIME). - * The timestamp is expressed as XServer time. If a window - * is shown with user timestamp older than the time of the last - * user action, it won't be activated after being shown, with the special - * value 0 meaning not to activate the window after being shown. - * @since 3.2 - */ - void setUserTime( Time time ); - - /** - * Returns the time of last user action on the window, or -1 if not set. - * @since 3.2 - */ - Time userTime() const; - - /* - * Sets the startup notification id @p id on the window. - * @since 3.2 - */ - void setStartupId( const char* startup_id ); - - /** - * Returns the startup notification id of the window. - * @since 3.2 - */ - const char* startupId() const; - - /** - * Sets actions that the window manager allows for the window. - * @since 3.2 - */ - void setAllowedActions( unsigned long actions ); - - /** - * Returns actions that the window manager allows for the window. - * @since 3.2 - */ - unsigned long allowedActions() const; - - /* - * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow - * for this window. - * @since 3.2 - */ - Window transientFor() const; - - /** - * Returns the leader window for the group the window is in, if any. - * @since 3.2 - */ - Window groupLeader() const; - - /** - * Returns the class component of the window class for the window - * (i.e. WM_CLASS property). - * @since 3.3 - */ - const char* windowClassClass() const; - - /** - * Returns the name component of the window class for the window - * (i.e. WM_CLASS property). - * @since 3.3 - */ - const char* windowClassName() const; - - /** - * Returns the window role for the window (i.e. WM_WINDOW_ROLE property). - * @since 3.3 - */ - const char* windowRole() const; - - /** - * Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property). - * @since 3.3 - */ - const char* clientMachine() const; - - /** - Places the window frame geometry in frame, and the application window - geometry in window. Both geometries are relative to the root window. - - @param frame the geometry for the frame - - @param window the geometry for the window - **/ - void kdeGeometry(NETRect &frame, NETRect &window); - - /** - This function takes the passed XEvent and returns an OR'ed list of - NETWinInfo properties that have changed in the properties argument. - The new information will be read immediately by the class. - The elements of the properties argument are as they would be passed - to the constructor, if the array is not large enough, - changed properties that don't fit in it won't be listed there - (they'll be updated in the class though). - - @param event the event - @param properties properties that changed - @param properties_size size of the passed properties array - @since 3.2 - - **/ - void event( XEvent* event, unsigned long* properties, int properties_size ); - - /** - This function takes the pass XEvent and returns an OR'ed list of NETWinInfo - properties that have changed. The new information will be read - immediately by the class. This overloaded version returns - only a single mask, and therefore cannot check state of all properties - like the other variant. - - @param event the event - - @return the properties - **/ - unsigned long event(XEvent *event); - - /** - Sentinel value to indicate that the client wishes to be visible on - all desktops. - - @return the value to be on all desktops - **/ - static const int OnAllDesktops; - - -protected: - /** - A Window Manager should subclass NETWinInfo and reimplement this function when - it wants to know when a Client made a request to change desktops (ie. move to - another desktop). - - @param desktop the number of the desktop - **/ - virtual void changeDesktop(int desktop) { Q_UNUSED(desktop); } - - /** - A Window Manager should subclass NETWinInfo and reimplement this function when - it wants to know when a Client made a request to change state (ie. to - Shade / Unshade). - - @param state the new state - - @param mask the mask for the state - **/ - virtual void changeState(unsigned long state, unsigned long mask) { Q_UNUSED(state); Q_UNUSED(mask); } - -private: - void update( const unsigned long[] ); - void updateWMState(); - void setIconInternal(NETRArray<NETIcon>& icons, int& icon_count, Atom property, NETIcon icon, Bool replace); - NETIcon iconInternal(NETRArray<NETIcon>& icons, int icon_count, int width, int height) const; - Role role; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - NETWinInfoPrivate *p; -}; - - -//#define KWIN_FOCUS - -#endif -#endif // __net_wm_h diff --git a/kdecore/netwm_def.h b/kdecore/netwm_def.h deleted file mode 100644 index 1f6860243..000000000 --- a/kdecore/netwm_def.h +++ /dev/null @@ -1,671 +0,0 @@ -/* - - Copyright (c) 2000 Troll Tech AS - Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> - - 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 __netwm_def_h -#define __netwm_def_h - -#include <kdelibs_export.h> - -/** - Simple point class for NET classes. - - This class is a convenience class defining a point x, y. The existence of - this class is to keep the implementation from being dependant on a - separate framework/library. - - NETPoint is only used by the NET API. Usually TQPoint is the - appropriate class for representing a point. - - @author Bradley T. Hughes <bhughes@trolltech.com> -**/ - -struct NETPoint { - /** - Constructor to initialize this point to 0,0. - **/ - NETPoint() : x(0), y(0) { } - - /* - Public data member. - **/ - int x, ///< x coordinate. - y; ///< y coordinate -}; - - -/** - Simple size class for NET classes. - - This class is a convenience class defining a size width by height. The - existence of this class is to keep the implementation from being dependant - on a separate framework/library. - - NETSize is only used by the NET API. Usually TQSize is the - appropriate class for representing a size. - - @author Bradley T. Hughes <bhughes@trolltech.com> -**/ - -struct NETSize { - /** - Constructor to initialize this size to 0x0 - **/ - NETSize() : width(0), height(0) { } - - /* - Public data member. - **/ - int width, ///< Width. - height; ///< Height. -}; - -/** - Simple rectangle class for NET classes. - - This class is a convenience class defining a rectangle as a point x,y with a - size width by height. The existence of this class is to keep the implementation - from being dependant on a separate framework/library; - - NETRect is only used by the NET API. Usually TQRect is the - appropriate class for representing a rectangle. -**/ -struct NETRect { - /** - Position of the rectangle. - - @see NETPoint - **/ - NETPoint pos; - - /** - Size of the rectangle. - - @see NETSize - **/ - NETSize size; -}; - - -/** - Simple icon class for NET classes. - - This class is a convenience class defining an icon of size width by height. - The existence of this class is to keep the implementation from being - dependant on a separate framework/library. - - NETIcon is only used by the NET API. Usually QIcon is the - appropriate class for representing an icon. -**/ - -struct NETIcon { - /** - Constructor to initialize this icon to 0x0 with data=0 - **/ - NETIcon() : data(0) { } - - /** - Size of the icon. - - @see NETSize - **/ - NETSize size; - - /** - Image data for the icon. This is an array of 32bit packed CARDINAL ARGB - with high byte being A, low byte being B. First two bytes are width, height. - Data is in rows, left to right and top to bottom. - **/ - unsigned char *data; -}; - - -/** - Partial strut class for NET classes. - - This class is a convenience class defining a strut with left, right, top and - bottom border values, and ranges for them. The existence of this class is to - keep the implementation from being dependant on a separate framework/library. - See the _NET_WM_STRUT_PARTIAL property in the NETWM spec. -**/ - -struct NETExtendedStrut { - /** - Constructor to initialize this struct to 0,0,0,0 - **/ - NETExtendedStrut() : left_width(0), left_start(0), left_end(0), - right_width(0), right_start(0), right_end(0), top_width(0), top_start(0), top_end(0), - bottom_width(0), bottom_start(0), bottom_end(0) {} - - /** - Left border of the strut, width and range. - **/ - int left_width, left_start, left_end; - - /** - Right border of the strut, width and range. - **/ - int right_width, right_start, right_end; - - /** - Top border of the strut, width and range. - **/ - int top_width, top_start, top_end; - - /** - Bottom border of the strut, width and range. - **/ - int bottom_width, bottom_start, bottom_end; - -}; - - -/** - @deprecated use NETExtendedStrut - - Simple strut class for NET classes. - - This class is a convenience class defining a strut with left, right, top and - bottom border values. The existence of this class is to keep the implementation - from being dependant on a separate framework/library. See the _NET_WM_STRUT - property in the NETWM spec. -**/ - -struct NETStrut { - /** - Constructor to initialize this struct to 0,0,0,0 - **/ - NETStrut() : left(0), right(0), top(0), bottom(0) { } - - /** - Left border of the strut. - **/ - int left; - - /** - Right border of the strut. - **/ - int right; - - /** - Top border of the strut. - **/ - int top; - - /** - Bottom border of the strut. - **/ - int bottom; -}; - - -/** - Base namespace class. - - The NET API is an implementation of the NET Window Manager Specification. - - This class is the base class for the NETRootInfo and NETWinInfo classes, which - are used to retrieve and modify the properties of windows. To keep - the namespace relatively clean, all enums are defined here. - - @see http://www.freedesktop.org/standards/wm-spec/ - **/ - -class KDECORE_EXPORT NET { -public: - /** - Application role. This is used internally to determine how several action - should be performed (if at all). - - @li Client indicates that the application is a client application. - - @li WindowManager indicates that the application is a window manager - application. - **/ - - enum Role { - Client, - WindowManager - }; - - /** - Window type. - - @li Unknown indicates that the window did not define a window type. - - @li Normal indicates that this is a normal, top-level window. Windows with - Unknown window type or WM_TRANSIENT_FOR unset must be taken as this type. - - @li Desktop indicates a desktop feature. This can include a single window - containing desktop icons with the same dimensions as the screen, allowing - the desktop environment to have full control of the desktop, without the - need for proxying root window clicks. - - @li Dock indicates a dock or panel feature. Typically a window manager would - keep such windows on top of all other windows. - - @li Toolbar and Menu indicate toolbar and pinnable menu windows, respectively. - - @li Dialog indicates that this is a dialog window. If _NET_WM_WINDOW_TYPE is - not set, then windows with WM_TRANSIENT_FOR set must be taken as this type. - - @li Override - deprecated, has unclear meaning and is KDE-only. - - @li TopMenu indicates a toplevel menu (AKA macmenu). This is a KDE extension to the - _NET_WM_WINDOW_TYPE mechanism. - - @li DropdownMenu - dropdown menu (from a menubar typically) - - @li PopupMenu - a popup menu (a context menu typically) - - @li Tooltip - a tooltip window - - @li Notification - a notification window - - @li ComboBox - a list window for a combobox - - @li DNDIcon - a window that represents the dragged object during DND operation - - Note that some window types are typically used only on override-redirect - windows (WX11BypassWM flag). - **/ - - enum WindowType { - Unknown = -1, - Normal = 0, - Desktop = 1, - Dock = 2, - Toolbar = 3, - Menu = 4, - Dialog = 5, - Override = 6, ///< @deprecated - TopMenu = 7, // NON STANDARD - Tool = Toolbar, // This will go away soon, COMPAT (How soon? :) - Utility = 8, ///< @since 3.2 - Splash = 9, ///< @since 3.2 - DropdownMenu = 10, ///< @since 3.5.7 - PopupMenu = 11, ///< @since 3.5.7 - Tooltip = 12, ///< @since 3.5.7 - Notification = 13, ///< @since 3.5.7 - ComboBox = 14, ///< @since 3.5.7 - DNDIcon = 15 ///< @since 3.5.7 - }; - - /** - Values for WindowType when they should be OR'ed together, e.g. - for the properties argument of the NETRootInfo constructor. - @since 3.2 - **/ - enum WindowTypeMask { - NormalMask = 1<<0, - DesktopMask = 1<<1, - DockMask = 1<<2, - ToolbarMask = 1<<3, - MenuMask = 1<<4, - DialogMask = 1<<5, - OverrideMask = 1<<6, - TopMenuMask = 1<<7, - UtilityMask = 1<<8, - SplashMask = 1<<9, - DropdownMenuMask = 1<<10, ///< @since 3.5.7 - PopupMenuMask = 1<<11, ///< @since 3.5.7 - TooltipMask = 1<<12, ///< @since 3.5.7 - NotificationMask = 1<<13, ///< @since 3.5.7 - ComboBoxMask = 1<<14, ///< @since 3.5.7 - DNDIconMask = 1<<15 ///< @since 3.5.7 - }; - - // KDE4 move to WindowTypeMask - enum { AllTypesMask = 0LU-1 }; - - /** - * Returns true if the given window type matches the mask given - * using WindowTypeMask flags. - */ - static bool typeMatchesMask( WindowType type, unsigned long mask ); - - /** - Window state. - - @li Modal ndicates that this is a modal dialog box. The WM_TRANSIENT_FOR hint - MUST be set to indicate which window the dialog is a modal for, or set to - the root window if the dialog is a modal for its window group. - - @li Sticky indicates that the Window Manager SHOULD keep the window's position - fixed on the screen, even when the virtual desktop scrolls. Note that this is - different from being kept on all desktops. - - @li Max{Vert,Horiz} indicates that the window is {vertically,horizontally} - maximized. - - @li Max is more convenient than MaxVert | MaxHoriz. - - @li Shaded indicates that the window is shaded (rolled-up). - - @li SkipTaskbar indicates that a window should not be included on a taskbar. - - @li SkipPager indicates that a window should not be included on a pager. - - @li Hidden indicates that a window should not be visible on the screen (e.g. when minimised). - Only the window manager is allowed to change it. - - @li FullScreen indicates that a window should fill the entire screen and have no window decorations. - - @li KeepAbove indicates that a window should on top of most windows (but below fullscreen windows). - - @li KeepBelow indicates that a window should be below most windows (but above any desktop windows). - - @li StaysOnTop is an obsolete name for KeepAbove. - - @li DemandsAttention there was an attempt to activate this window, but the window manager prevented - this. E.g. taskbar should mark such window specially to bring user's attention to this window. - Only the window manager is allowed to change it. - - Note that KeepAbove (StaysOnTop) and KeepBelow are meant as user preference and applications - should avoid setting these states themselves. - **/ - - enum State { - Modal = 1<<0, - Sticky = 1<<1, - MaxVert = 1<<2, - MaxHoriz = 1<<3, - Max = MaxVert | MaxHoriz, - Shaded = 1<<4, - SkipTaskbar = 1<<5, - KeepAbove = 1<<6, ///< @since 3.2 - StaysOnTop = KeepAbove, // NOT STANDARD - SkipPager = 1<<7, - Hidden = 1<<8, ///< @since 3.2 - FullScreen = 1<<9, ///< @since 3.2 - KeepBelow = 1<<10, ///< @since 3.2 - DemandsAttention = 1<<11 ///< @since 3.2 - }; - - /** - Direction for WMMoveResize. - - When a client wants the Window Manager to start a WMMoveResize, it should - specify one of: - - @li TopLeft - @li Top - @li TopRight - @li Right - @li BottomRight - @li Bottom - @li BottomLeft - @li Left - @li Move (for movement only) - @li KeyboardSize (resizing via keyboard) - @li KeyboardMove (movement via keyboard) - **/ - - enum Direction { - TopLeft = 0, - Top = 1, - TopRight = 2, - Right = 3, - BottomRight = 4, - Bottom = 5, - BottomLeft = 6, - Left = 7, - Move = 8, // movement only - /** - @since 3.2 - **/ - KeyboardSize = 9, // size via keyboard - /** - @since 3.2 - **/ - KeyboardMove = 10, // move via keyboard - /** - @since 3.5.1 - **/ - MoveResizeCancel = 11 // to ask the WM to stop moving a window - }; - - /** - Client window mapping state. The class automatically watches the mapping - state of the client windows, and uses the mapping state to determine how - to set/change different properties. - - @li Visible indicates the client window is visible to the user. - - @li Withdrawn indicates that neither the client window nor its icon is visible. - - @li Iconic indicates that the client window is not visible, but its icon is. - This can be when the window is minimized or when it's on a different - virtual desktop. See also NET::Hidden. - **/ - - // KDE4 aaarghl, this doesn't map correctly to Xlib #defines - enum MappingState { - Visible, // ie. NormalState - Withdrawn, - Iconic - }; - - /** - Actions that can be done with a window (_NET_WM_ALLOWED_ACTIONS). - @since 3.2 - **/ - enum Action { - ActionMove = 1<<0, - ActionResize = 1<<1, - ActionMinimize = 1<<2, - ActionShade = 1<<3, - ActionStick = 1<<4, - ActionMaxVert = 1<<5, - ActionMaxHoriz = 1<<6, - ActionMax = ActionMaxVert | ActionMaxHoriz, - ActionFullScreen = 1<<7, - ActionChangeDesktop = 1<<8, - ActionClose = 1<<9 - }; - - /** - Supported properties. Clients and Window Managers must define which - properties/protocols it wants to support. - - Root/Desktop window properties and protocols: - - @li Supported - @li ClientList - @li ClientListStacking - @li NumberOfDesktops - @li DesktopGeometry - @li DesktopViewport - @li CurrentDesktop - @li DesktopNames - @li ActiveWindow - @li WorkArea - @li SupportingWMCheck - @li VirtualRoots - @li CloseWindow - @li WMMoveResize - - Client window properties and protocols: - - @li WMName - @li WMVisibleName - @li WMDesktop - @li WMWindowType - @li WMState - @li WMStrut (obsoleted by WM2ExtendedStrut) - @li WMIconGeometry - @li WMIcon - @li WMPid - @li WMVisibleIconName - @li WMIconName - - ICCCM properties (provided for convenience): - - @li XAWMState - - Extended KDE protocols and properties (NOT STANDARD): - - @li KDESystemTrayWindows - @li WMKDESystemTrayWinFor - @li WMKDEFrameStrut - **/ - - enum Property { - // root - Supported = 1<<0, - ClientList = 1<<1, - ClientListStacking = 1<<2, - NumberOfDesktops = 1<<3, - DesktopGeometry = 1<<4, - DesktopViewport = 1<<5, - CurrentDesktop = 1<<6, - DesktopNames = 1<<7, - ActiveWindow = 1<<8, - WorkArea = 1<<9, - SupportingWMCheck = 1<<10, - VirtualRoots = 1<<11, - KDESystemTrayWindows = 1<<12, // NOT STANDARD - CloseWindow = 1<<13, - WMMoveResize = 1<<14, - - // window - WMName = 1<<15, - WMVisibleName = 1<<16, - WMDesktop = 1<<17, - WMWindowType = 1<<18, - WMState = 1<<19, - WMStrut = 1<<20, - WMIconGeometry = 1<<21, - WMIcon = 1<<22, - WMPid = 1<<23, - WMHandledIcons = 1<<24, - WMPing = 1<<25, - WMKDESystemTrayWinFor = 1<<26, // NOT STANDARD - XAWMState = 1<<27, // NOT STANDARD - WMFrameExtents = 1<<28, ///< @since 3.5 - WMKDEFrameStrut = WMFrameExtents, // NOT STANDARD - - // Need to be reordered - WMIconName = 1<<29, - WMVisibleIconName = 1<<30, - WMGeometry = 1<<31 - }; - - /** - Supported properties. This enum is an extension to NET::Property, - because them enum is limited only to 32 bits. - - Client window properties and protocols: - - @li WM2UserTime - @li WM2StartupId - @li WM2TransientFor mainwindow for the window (WM_TRANSIENT_FOR) - @li WM2GroupLeader group leader (window_group in WM_HINTS) - @li WM2AllowedActions - @li WM2RestackWindow - @li WM2MoveResizeWindow - @li WM2ExtendedStrut - @li WM2TemporaryRules internal, for kstart - @li WM2WindowClass WM_CLASS - @li WM2WindowRole WM_WINDOW_ROLE - @li WM2ClientMachine WM_CLIENT_MACHINE - @li WM2DesktopLayout _NET_DESKTOP_LAYOUT - - @since 3.2 - - **/ - enum Property2 { - WM2UserTime = 1<<0, - WM2StartupId = 1<<1, - WM2TransientFor = 1<<2, - WM2GroupLeader = 1<<3, - WM2AllowedActions = 1<<4, - WM2RestackWindow = 1<<5, - WM2MoveResizeWindow = 1<<6, - WM2ExtendedStrut = 1<<7, - WM2TakeActivity = 1<<8, - WM2KDETemporaryRules = 1<<9, // NOT STANDARD - WM2WindowClass = 1<<10, ///< @since 3.3 - WM2WindowRole = 1<<11, ///< @since 3.3 - WM2ClientMachine = 1<<12, ///< @since 3.3 - WM2ShowingDesktop = 1<<13, ///< @since 3.5 - WM2FullPlacement = 1<<14, - WM2DesktopLayout = 1<<15 ///< @since 3.5.8 - }; - - /** - Sentinel value to indicate that the client wishes to be visible on - all desktops. - @since 3.2 - **/ - enum { OnAllDesktops = -1 }; - - /** - Source of the request. - @li FromApplication the request comes from a normal application - @li FromTool the request comes from pager or similar tool - @since 3.2 - **/ - // must match the values for data.l[0] field in _NET_ACTIVE_WINDOW message - enum RequestSource { - FromUnknown, // internal - FromApplication, - FromTool - }; - - /** - Orientation. - **/ - enum Orientation { - OrientationHorizontal = 0, - OrientationVertical = 1 - }; - - /** - Starting corner for desktop layout. - **/ - enum DesktopLayoutCorner { - DesktopLayoutCornerTopLeft = 0, - DesktopLayoutCornerTopRight = 1, - DesktopLayoutCornerBottomLeft = 2, - DesktopLayoutCornerBottomRight = 3 - }; - - /** - Compares two X timestamps, taking into account wrapping and 64bit architectures. - Return value is like with strcmp(), 0 for equal, -1 for time1 < time2, 1 for time1 > time2. - @since 3.5.3 - */ - static int timestampCompare( unsigned long time1, unsigned long time2 ); - /** - Returns a difference of two X timestamps, time2 - time1, where time2 must be later than time1, - as returned by timestampCompare(). - @since 3.5.3 - */ - static int timestampDiff( unsigned long time1_, unsigned long time2_ ); - -}; - - -#endif // __netwm_def_h diff --git a/kdecore/netwm_p.h b/kdecore/netwm_p.h deleted file mode 100644 index a2395c4ac..000000000 --- a/kdecore/netwm_p.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - - Copyright (c) 2000 Troll Tech AS - Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org> - - 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 __net_wm_p_h -#define __net_wm_p_h - -/** - Resizable array class. - - This resizable array is used to simplify the implementation. The existence of - this class is to keep the implementation from depending on a separate - framework/library. - @internal -**/ - -template <class Z> class NETRArray { -public: - /** - Constructs an empty (size == 0) array. - **/ - - NETRArray(); - - /** - Resizable array destructor. - **/ - - ~NETRArray(); - - /** - The [] operator does the work. If the index is larger than the current - size of the array, it is resized. - **/ - - Z &operator[](int); - - /** - Returns the size of the array. - **/ - - int size() const { return sz; } - - /** - Resets the array (size == 0). - **/ - void reset(); - -private: - int sz; - int capacity; - Z *d; -}; - - -/** - Private data for the NETRootInfo class. - @internal -**/ - -struct NETRootInfoPrivate { - // information about the X server - Display *display; - NETSize rootSize; - Window root; - Window supportwindow; - const char *name; - int screen; - - // data that changes (either by the window manager or by a client) - // and requires updates - NETRArray<NETPoint> viewport; - NETRArray<NETRect> workarea; - NETSize geometry; - Window active; - Window *clients, *stacking, *virtual_roots, *kde_system_tray_windows; - NETRArray<const char *> desktop_names; - int number_of_desktops; - int current_desktop; - - unsigned long clients_count, stacking_count, virtual_roots_count, - kde_system_tray_windows_count; - bool showing_desktop; - NET::Orientation desktop_layout_orientation; - NET::DesktopLayoutCorner desktop_layout_corner; - int desktop_layout_columns, desktop_layout_rows; - - unsigned long properties[ 5 ]; - unsigned long client_properties[ 5 ]; // properties the client is interested in - - int ref; -}; - - -/** - Private data for the NETWinInfo class. - @internal -**/ - -struct NETWinInfoPrivate { - Display *display; - Window window, root; - NET::MappingState mapping_state; - Bool mapping_state_dirty; - - NETRArray<NETIcon> icons; - int icon_count; - - NETRect icon_geom, win_geom; - unsigned long state; - NETExtendedStrut extended_strut; - NETStrut strut; - NETStrut frame_strut; // strut? - NETRArray<NET::WindowType> types; - char *name, *visible_name, *icon_name, *visible_icon_name; - int desktop; - int pid; - int handled_icons; - Window kde_system_tray_win_for; - Time user_time; - char* startup_id; - Window transient_for, window_group; - unsigned long allowed_actions; - char* class_class, *class_name, *role, *client_machine; - - unsigned long properties[ 2 ]; - bool has_net_support; - - int ref; -}; - - -#endif // __net_wm_p_h diff --git a/kdecore/network/CMakeLists.txt b/kdecore/network/CMakeLists.txt deleted file mode 100644 index 101da4843..000000000 --- a/kdecore/network/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_BINARY_DIR}/tdecore -) - - -##### headers ################################### - -install( FILES - kresolver.h kreverseresolver.h ksocketaddress.h - ksocketbase.h ksocketdevice.h kclientsocketbase.h - kstreamsocket.h kserversocket.h kdatagramsocket.h - kmulticastsocketdevice.h kmulticastsocket.h - knetworkinterface.h khttpproxysocketdevice.h - ksockssocketdevice.h kbufferedsocket.h kiobuffer.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - - -##### other files ############################### - -install( FILES ipv6blacklist DESTINATION ${CONFIG_INSTALL_DIR} ) - - -##### tdecorenetwork ############################ - -set( target tdecorenetwork ) - -set( ${target}_SRCS - kresolver.cpp kresolvermanager.cpp kresolverworkerbase.cpp - ksocketaddress.cpp kresolverstandardworkers.cpp - kreverseresolver.cpp ksocketdevice.cpp ksocketbase.cpp - kclientsocketbase.cpp kstreamsocket.cpp kserversocket.cpp - kdatagramsocket.cpp khttpproxysocketdevice.cpp - ksockssocketdevice.cpp kbufferedsocket.cpp ksocketbuffer.cpp - ksrvresolverworker.cpp -) - -tde_add_library( ${target} STATIC_PIC AUTOMOC - SOURCES ${${target}_SRCS} -) diff --git a/kdecore/network/Makefile.am b/kdecore/network/Makefile.am deleted file mode 100644 index f686a50ca..000000000 --- a/kdecore/network/Makefile.am +++ /dev/null @@ -1,59 +0,0 @@ -## Makefile.am for libqt-addon - -# this is the program that gets installed. it's name is used for all -# of the other Makefile.am variables -noinst_LTLIBRARIES = libtdecorenetwork.la - -# set the include path for X, qt and KDE -INCLUDES = $(all_includes) - -# the library search path. -# convenience lib - no LDFLAGS or LIBADD ! -# Note: -# ksocketdevice.cpp must appear before any inclusion of ksocketdevice.h -libtdecorenetwork_la_SOURCES = kresolver.cpp \ - kresolvermanager.cpp \ - kresolverworkerbase.cpp \ - ksocketaddress.cpp \ - kresolverstandardworkers.cpp \ - kreverseresolver.cpp \ - ksocketdevice.cpp \ - ksocketbase.cpp \ - kclientsocketbase.cpp \ - kstreamsocket.cpp \ - kserversocket.cpp \ - kdatagramsocket.cpp \ - khttpproxysocketdevice.cpp \ - ksockssocketdevice.cpp \ - kbufferedsocket.cpp \ - ksocketbuffer.cpp \ - ksrvresolverworker.cpp - -include_HEADERS = kresolver.h \ - kreverseresolver.h \ - ksocketaddress.h \ - ksocketbase.h \ - ksocketdevice.h \ - kclientsocketbase.h \ - kstreamsocket.h \ - kserversocket.h \ - kdatagramsocket.h \ - kmulticastsocketdevice.h \ - kmulticastsocket.h \ - knetworkinterface.h \ - khttpproxysocketdevice.h \ - ksockssocketdevice.h \ - kbufferedsocket.h \ - kiobuffer.h -noinst_HEADERS = kresolver_p.h \ - kresolverworkerbase.h \ - kresolverstandardworkers_p.h \ - ksocketbuffer_p.h \ - ksrvresolverworker_p.h \ - syssocket.h - -configdir = $(kde_confdir) -config_DATA = ipv6blacklist - -# let automoc handle all of the meta source files (moc) -METASOURCES = AUTO diff --git a/kdecore/network/ipv6blacklist b/kdecore/network/ipv6blacklist deleted file mode 100644 index f4d4d1252..000000000 --- a/kdecore/network/ipv6blacklist +++ /dev/null @@ -1,3 +0,0 @@ -.doubleclick.net -.linebourse.fr -.banquepopulaire.fr diff --git a/kdecore/network/kbufferedsocket.cpp b/kdecore/network/kbufferedsocket.cpp deleted file mode 100644 index ffac2e98b..000000000 --- a/kdecore/network/kbufferedsocket.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003-2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <tqmutex.h> -#include <tqtimer.h> - -#include "ksocketdevice.h" -#include "ksocketaddress.h" -#include "ksocketbuffer_p.h" -#include "kbufferedsocket.h" - -using namespace KNetwork; -using namespace KNetwork::Internal; - -class KNetwork::KBufferedSocketPrivate -{ -public: - mutable KSocketBuffer *input, *output; - - KBufferedSocketPrivate() - { - input = 0L; - output = 0L; - } -}; - -KBufferedSocket::KBufferedSocket(const TQString& host, const TQString& service, - TQObject *parent, const char *name) - : KStreamSocket(host, service, parent, name), - d(new KBufferedSocketPrivate) -{ - setInputBuffering(true); - setOutputBuffering(true); -} - -KBufferedSocket::~KBufferedSocket() -{ - closeNow(); - delete d->input; - delete d->output; - delete d; -} - -void KBufferedSocket::setSocketDevice(KSocketDevice* device) -{ - KStreamSocket::setSocketDevice(device); - device->setBlocking(false); -} - -bool KBufferedSocket::setSocketOptions(int opts) -{ - if (opts == Blocking) - return false; - - opts &= ~Blocking; - return KStreamSocket::setSocketOptions(opts); -} - -void KBufferedSocket::close() -{ - if (!d->output || d->output->isEmpty()) - closeNow(); - else - { - setState(Closing); - TQSocketNotifier *n = socketDevice()->readNotifier(); - if (n) - n->setEnabled(false); - emit stateChanged(Closing); - } -} - -#ifdef USE_QT3 -TQ_LONG KBufferedSocket::bytesAvailable() const -#endif -#ifdef USE_QT4 -qint64 KBufferedSocket::bytesAvailable() const -#endif -{ - if (!d->input) - return KStreamSocket::bytesAvailable(); - - return d->input->length(); -} - -TQ_LONG KBufferedSocket::waitForMore(int msecs, bool *timeout) -{ - TQ_LONG retval = KStreamSocket::waitForMore(msecs, timeout); - if (d->input) - { - resetError(); - slotReadActivity(); - return bytesAvailable(); - } - return retval; -} - -TQT_TQIO_LONG KBufferedSocket::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen) -{ - if (d->input) - { - if (d->input->isEmpty()) - { - setError(IO_ReadError, WouldBlock); - emit gotError(WouldBlock); - return -1; - } - resetError(); - return d->input->consumeBuffer(data, maxlen); - } - return KStreamSocket::tqreadBlock(data, maxlen); -} - -TQT_TQIO_LONG KBufferedSocket::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from) -{ - from = peerAddress(); - return tqreadBlock(data, maxlen); -} - -TQ_LONG KBufferedSocket::peekBlock(char *data, TQ_ULONG maxlen) -{ - if (d->input) - { - if (d->input->isEmpty()) - { - setError(IO_ReadError, WouldBlock); - emit gotError(WouldBlock); - return -1; - } - resetError(); - return d->input->consumeBuffer(data, maxlen, false); - } - return KStreamSocket::peekBlock(data, maxlen); -} - -TQ_LONG KBufferedSocket::peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from) -{ - from = peerAddress(); - return peekBlock(data, maxlen); -} - -TQT_TQIO_LONG KBufferedSocket::tqwriteBlock(const char *data, TQT_TQIO_ULONG len) -{ - if (state() != Connected) - { - // cannot write now! - setError(IO_WriteError, NotConnected); - return -1; - } - - if (d->output) - { - if (d->output->isFull()) - { - setError(IO_WriteError, WouldBlock); - emit gotError(WouldBlock); - return -1; - } - resetError(); - - // enable notifier to send data - TQSocketNotifier *n = socketDevice()->writeNotifier(); - if (n) - n->setEnabled(true); - - return d->output->feedBuffer(data, len); - } - - return KStreamSocket::tqwriteBlock(data, len); -} - -TQT_TQIO_LONG KBufferedSocket::tqwriteBlock(const char *data, TQT_TQIO_ULONG maxlen, - const KSocketAddress&) -{ - // ignore the third parameter - return tqwriteBlock(data, maxlen); -} - -void KBufferedSocket::enableRead(bool enable) -{ - KStreamSocket::enableRead(enable); - if (!enable && d->input) - { - // reenable it - TQSocketNotifier *n = socketDevice()->readNotifier(); - if (n) - n->setEnabled(true); - } - - if (enable && state() != Connected && d->input && !d->input->isEmpty()) - // this means the buffer is still dirty - // allow the signal to be emitted - TQTimer::singleShot(0, this, TQT_SLOT(slotReadActivity())); -} - -void KBufferedSocket::enableWrite(bool enable) -{ - KStreamSocket::enableWrite(enable); - if (!enable && d->output && !d->output->isEmpty()) - { - // reenable it - TQSocketNotifier *n = socketDevice()->writeNotifier(); - if (n) - n->setEnabled(true); - } -} - -void KBufferedSocket::stateChanging(SocketState newState) -{ - if (newState == Connecting || newState == Connected) - { - // we're going to connect - // make sure the buffers are clean - if (d->input) - d->input->clear(); - if (d->output) - d->output->clear(); - - // also, turn on notifiers - enableRead(emitsReadyRead()); - enableWrite(emitsReadyWrite()); - } - KStreamSocket::stateChanging(newState); -} - -void KBufferedSocket::setInputBuffering(bool enable) -{ - TQMutexLocker locker(mutex()); - if (!enable) - { - delete d->input; - d->input = 0L; - } - else if (d->input == 0L) - { - d->input = new KSocketBuffer; - } -} - -KIOBufferBase* KBufferedSocket::inputBuffer() -{ - return d->input; -} - -void KBufferedSocket::setOutputBuffering(bool enable) -{ - TQMutexLocker locker(mutex()); - if (!enable) - { - delete d->output; - d->output = 0L; - } - else if (d->output == 0L) - { - d->output = new KSocketBuffer; - } -} - -KIOBufferBase* KBufferedSocket::outputBuffer() -{ - return d->output; -} - -#ifdef USE_QT3 -TQ_ULONG KBufferedSocket::bytesToWrite() const -#endif -#ifdef USE_QT4 -qint64 KBufferedSocket::bytesToWrite() const -#endif -{ - if (!d->output) - return 0; - - return d->output->length(); -} - -void KBufferedSocket::closeNow() -{ - KStreamSocket::close(); - if (d->output) - d->output->clear(); -} - -bool KBufferedSocket::canReadLine() const -{ - if (!d->input) - return false; - - return d->input->canReadLine(); -} - -TQCString KBufferedSocket::readLine() -{ - return d->input->readLine(); -} - -void KBufferedSocket::waitForConnect() -{ - if (state() != Connecting) - return; // nothing to be waited on - - KStreamSocket::setSocketOptions(socketOptions() | Blocking); - connectionEvent(); - KStreamSocket::setSocketOptions(socketOptions() & ~Blocking); -} - -void KBufferedSocket::slotReadActivity() -{ - if (d->input && state() == Connected) - { - mutex()->lock(); - TQ_LONG len = d->input->receiveFrom(socketDevice()); - - if (len == -1) - { - if (socketDevice()->error() != WouldBlock) - { - // nope, another error! - copyError(); - mutex()->unlock(); - emit gotError(error()); - closeNow(); // emits closed - return; - } - } - else if (len == 0) - { - // remotely closed - setError(IO_ReadError, RemotelyDisconnected); - mutex()->unlock(); - emit gotError(error()); - closeNow(); // emits closed - return; - } - - // no error - mutex()->unlock(); - } - - if (state() == Connected) - KStreamSocket::slotReadActivity(); // this emits readyRead - else if (emitsReadyRead()) // state() != Connected - { - if (d->input && !d->input->isEmpty()) - { - // buffer isn't empty - // keep emitting signals till it is - TQTimer::singleShot(0, this, TQT_SLOT(slotReadActivity())); - emit readyRead(); - } - } -} - -void KBufferedSocket::slotWriteActivity() -{ - if (d->output && !d->output->isEmpty() && - (state() == Connected || state() == Closing)) - { - mutex()->lock(); - TQ_LONG len = d->output->sendTo(socketDevice()); - - if (len == -1) - { - if (socketDevice()->error() != WouldBlock) - { - // nope, another error! - copyError(); - mutex()->unlock(); - emit gotError(error()); - closeNow(); - return; - } - } - else if (len == 0) - { - // remotely closed - setError(IO_ReadError, RemotelyDisconnected); - mutex()->unlock(); - emit gotError(error()); - closeNow(); - return; - } - - if (d->output->isEmpty()) - // deactivate the notifier until we have something to send - // writeNotifier can't return NULL here - socketDevice()->writeNotifier()->setEnabled(false); - - mutex()->unlock(); - emit bytesWritten(len); - } - - if (state() != Closing) - KStreamSocket::slotWriteActivity(); - else if (d->output && d->output->isEmpty() && state() == Closing) - { - KStreamSocket::close(); // finished sending data - } -} - -#include "kbufferedsocket.moc" diff --git a/kdecore/network/kbufferedsocket.h b/kdecore/network/kbufferedsocket.h deleted file mode 100644 index 8f9dde92c..000000000 --- a/kdecore/network/kbufferedsocket.h +++ /dev/null @@ -1,269 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago@kde.org> - * - * - * 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 KBUFFEREDSOCKET_H -#define KBUFFEREDSOCKET_H - -#include <tqobject.h> -#include <tqcstring.h> -#include <tqvaluelist.h> -#include "kstreamsocket.h" -#include <kdelibs_export.h> - -class KIOBufferBase; - -namespace KNetwork { - -class KBufferedSocketPrivate; -/** @class KBufferedSocket kbufferedsocket.h kbufferedsocket.h - * @brief Buffered stream sockets. - * - * This class allows the user to create and operate buffered stream sockets - * such as those used in most Internet connections. This class is - * also the one that resembles the most to the old @ref QSocket - * implementation. - * - * Objects of this type operate only in non-blocking mode. A call to - * setBlocking(true) will result in an error. - * - * @note Buffered sockets only make sense if you're using them from - * the main (event-loop) thread. This is actually a restriction - * imposed by Qt's TQSocketNotifier. If you want to use a socket - * in an auxiliary thread, please use KStreamSocket. - * - * @see KNetwork::KStreamSocket, KNetwork::KServerSocket - * @author Thiago Macieira <thiago@kde.org> - */ -class KDECORE_EXPORT KBufferedSocket: public KStreamSocket -{ - Q_OBJECT - TQ_OBJECT -public: - /** - * Default constructor. - * - * @param node destination host - * @param service destination service to connect to - * @param parent the parent object for this object - * @param name the internal name for this object - */ - KBufferedSocket(const TQString& node = TQString::null, const TQString& service = TQString::null, - TQObject* parent = 0L, const char *name = 0L); - - /** - * Destructor. - */ - virtual ~KBufferedSocket(); - - /** - * Be sure to catch new devices. - */ - virtual void setSocketDevice(KSocketDevice* device); - -protected: - /** - * Buffered sockets can only operate in non-blocking mode. - */ - virtual bool setSocketOptions(int opts); - -public: - /** - * Closes the socket for new data, but allow data that had been buffered - * for output with @ref writeBlock to be still be written. - * - * @sa closeNow - */ - virtual void close(); - - /** - * Make use of the buffers. - */ -#ifdef USE_QT3 - virtual TQ_LONG bytesAvailable() const; -#endif -#ifdef USE_QT4 - virtual qint64 bytesAvailable() const; -#endif - - /** - * Make use of buffers. - */ - virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L); - - /** - * Reads data from the socket. Make use of buffers. - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen); - - /** - * @overload - * Reads data from a socket. - * - * The @p from parameter is always set to @ref peerAddress() - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from); - - /** - * Peeks data from the socket. - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen); - - /** - * @overload - * Peeks data from the socket. - * - * The @p from parameter is always set to @ref peerAddress() - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress &from); - - /** - * Writes data to the socket. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len); - - /** - * @overload - * Writes data to the socket. - * - * The @p to parameter is discarded. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to); - - /** - * Catch changes. - */ - virtual void enableRead(bool enable); - - /** - * Catch changes. - */ - virtual void enableWrite(bool enable); - - /** - * Sets the use of input buffering. - */ - void setInputBuffering(bool enable); - - /** - * Retrieves the input buffer object. - */ - KIOBufferBase* inputBuffer(); - - /** - * Sets the use of output buffering. - */ - void setOutputBuffering(bool enable); - - /** - * Retrieves the output buffer object. - */ - KIOBufferBase* outputBuffer(); - - /** - * Returns the length of the output buffer. - */ -#ifdef USE_QT3 - virtual TQ_ULONG bytesToWrite() const; -#endif -#ifdef USE_QT4 - virtual qint64 bytesToWrite() const; -#endif - - /** - * Closes the socket and discards any output data that had been buffered - * with @ref writeBlock but that had not yet been written. - * - * @sa close - */ - virtual void closeNow(); - - /** - * Returns true if a line can be read with @ref readLine - */ - bool canReadLine() const; - - /** - * Reads a line of data from the socket buffers. - */ - TQCString readLine(); - - // KDE4: make virtual, add timeout to match the Qt4 signature - // and move to another class up the hierarchy - /** - * Blocks until the connection is either established, or completely - * failed. - */ - void waitForConnect(); - -protected: - /** - * Catch connection to clear the buffers - */ - virtual void stateChanging(SocketState newState); - -protected slots: - /** - * Slot called when there's read activity. - */ - virtual void slotReadActivity(); - - /** - * Slot called when there's write activity. - */ - virtual void slotWriteActivity(); - -signals: - /** - * This signal is emitted whenever data is written. - */ - void bytesWritten(int bytes); - -private: - KBufferedSocket(const KBufferedSocket&); - KBufferedSocket& operator=(const KBufferedSocket&); - - KBufferedSocketPrivate *d; - -public: - // KDE4: remove this function - /** - * @deprecated - * Closes the socket. - * - * This function is provided to ease porting from KExtendedSocket, - * which required a call to reset() in order to be able to connect again - * using the same device. This is not necessary in KBufferedSocket any more. - */ -#ifdef USE_QT3 - inline void reset() -#endif -#ifdef USE_QT4 - inline bool reset() -#endif - { closeNow(); } -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kclientsocketbase.cpp b/kdecore/network/kclientsocketbase.cpp deleted file mode 100644 index 9785ce36c..000000000 --- a/kdecore/network/kclientsocketbase.cpp +++ /dev/null @@ -1,490 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <tqsocketnotifier.h> -#include <tqtimer.h> -#include <tqmutex.h> - -#include "ksocketaddress.h" -#include "kresolver.h" -#include "ksocketbase.h" -#include "ksocketdevice.h" -#include "kclientsocketbase.h" - -using namespace KNetwork; - -class KNetwork::KClientSocketBasePrivate -{ -public: - int state; - - KResolver localResolver, peerResolver; - KResolverResults localResults, peerResults; - - bool enableRead : 1, enableWrite : 1; -}; - -KClientSocketBase::KClientSocketBase(TQObject *parent, const char *name) : -#ifdef USE_QT4 -#else // USE_QT4 - TQObject(parent, name), -#endif // USE_QT4 - d(new KClientSocketBasePrivate) -{ -#ifdef USE_QT4 - setParent(parent); - setObjectName(name); -#endif // USE_QT4 - d->state = Idle; - d->enableRead = true; - d->enableWrite = false; -} - -KClientSocketBase::~KClientSocketBase() -{ - close(); - delete d; -} - -KClientSocketBase::SocketState KClientSocketBase::state() const -{ - return static_cast<SocketState>(d->state); -} - -void KClientSocketBase::setState(SocketState state) -{ - d->state = state; - stateChanging(state); -} - -bool KClientSocketBase::setSocketOptions(int opts) -{ - TQMutexLocker locker(mutex()); - KSocketBase::setSocketOptions(opts); // call parent - - // don't create the device unnecessarily - if (hasDevice()) - { - bool result = socketDevice()->setSocketOptions(opts); // and set the implementation - copyError(); - return result; - } - - return true; -} - -KResolver& KClientSocketBase::peerResolver() const -{ - return d->peerResolver; -} - -const KResolverResults& KClientSocketBase::peerResults() const -{ - return d->peerResults; -} - -KResolver& KClientSocketBase::localResolver() const -{ - return d->localResolver; -} - -const KResolverResults& KClientSocketBase::localResults() const -{ - return d->localResults; -} - -void KClientSocketBase::setResolutionEnabled(bool enable) -{ - if (enable) - { - d->localResolver.setFlags(d->localResolver.flags() & ~KResolver::NoResolve); - d->peerResolver.setFlags(d->peerResolver.flags() & ~KResolver::NoResolve); - } - else - { - d->localResolver.setFlags(d->localResolver.flags() | KResolver::NoResolve); - d->peerResolver.setFlags(d->peerResolver.flags() | KResolver::NoResolve); - } -} - -void KClientSocketBase::setFamily(int families) -{ - d->localResolver.setFamily(families); - d->peerResolver.setFamily(families); -} - -bool KClientSocketBase::lookup() -{ - if (state() == HostLookup && !blocking()) - return true; // already doing lookup - - if (state() > HostLookup) - return true; // results are already available - - if (state() < HostLookup) - { - if (d->localResolver.serviceName().isNull() && - !d->localResolver.nodeName().isNull()) - d->localResolver.setServiceName(TQString::tqfromLatin1("")); - - // don't restart the lookups if they had succeeded and - // the input values weren't changed - TQObject::connect(&d->peerResolver, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(lookupFinishedSlot())); - TQObject::connect(&d->localResolver, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(lookupFinishedSlot())); - - if (d->localResolver.status() <= 0) - d->localResolver.start(); - if (d->peerResolver.status() <= 0) - d->peerResolver.start(); - - setState(HostLookup); - emit stateChanged(HostLookup); - - if (!d->localResolver.isRunning() && !d->peerResolver.isRunning()) - { - // if nothing is running, then the lookup results are still valid - // pretend we had done lookup - if (blocking()) - lookupFinishedSlot(); - else - TQTimer::singleShot(0, this, TQT_SLOT(lookupFinishedSlot())); - } - else - { - d->localResults = d->peerResults = KResolverResults(); - } - } - - if (blocking()) - { - // we're in blocking mode operation - // wait for the results - - localResolver().wait(); - peerResolver().wait(); - - // lookupFinishedSlot has been called - } - - return true; -} - -bool KClientSocketBase::bind(const KResolverEntry& address) -{ - if (state() == HostLookup || state() > Connecting) - return false; - - if (socketDevice()->bind(address)) - { - resetError(); - - // don't set the state or emit signals if we are in a higher state - if (state() < Bound) - { - setState(Bound); - emit stateChanged(Bound); - emit bound(address); - } - return true; - } - return false; -} - -bool KClientSocketBase::connect(const KResolverEntry& address) -{ - if (state() == Connected) - return true; // to be compliant with the other classes - if (state() == HostLookup || state() > Connecting) - return false; - - bool ok = socketDevice()->connect(address); - copyError(); - - if (ok) - { - SocketState newstate; - if (error() == InProgress) - newstate = Connecting; - else - newstate = Connected; - - if (state() < newstate) - { - setState(newstate); - emit stateChanged(newstate); - if (error() == NoError) - { - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - emit connected(address); - } - } - - return true; - } - return false; -} - -bool KClientSocketBase::disconnect() -{ - if (state() != Connected) - return false; - - bool ok = socketDevice()->disconnect(); - copyError(); - - if (ok) - { - setState(Unconnected); - emit stateChanged(Unconnected); - return true; - } - return false; -} - -void KClientSocketBase::close() -{ - if (state() == Idle) - return; // nothing to do - - if (state() == HostLookup) - { - d->peerResolver.cancel(false); - d->localResolver.cancel(false); - } - - d->localResults = d->peerResults = KResolverResults(); - - socketDevice()->close(); - setState(Idle); - emit stateChanged(Idle); - emit closed(); -} - -// This function is unlike all the others because it is const -#ifdef USE_QT3 -TQ_LONG KClientSocketBase::bytesAvailable() const -#endif -#ifdef USE_QT4 -qint64 KClientSocketBase::bytesAvailable() const -#endif -{ - return socketDevice()->bytesAvailable(); -} - -// All the functions below look really alike -// Should I use a macro to define them? - -TQ_LONG KClientSocketBase::waitForMore(int msecs, bool *timeout) -{ - resetError(); - TQ_LONG retval = socketDevice()->waitForMore(msecs, timeout); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -TQT_TQIO_LONG KClientSocketBase::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen) -{ - resetError(); - TQ_LONG retval = socketDevice()->tqreadBlock(data, maxlen); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -TQT_TQIO_LONG KClientSocketBase::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from) -{ - resetError(); - TQ_LONG retval = socketDevice()->tqreadBlock(data, maxlen, from); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -TQ_LONG KClientSocketBase::peekBlock(char *data, TQ_ULONG maxlen) -{ - resetError(); - TQ_LONG retval = socketDevice()->peekBlock(data, maxlen); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -TQ_LONG KClientSocketBase::peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from) -{ - resetError(); - TQ_LONG retval = socketDevice()->peekBlock(data, maxlen, from); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -TQT_TQIO_LONG KClientSocketBase::tqwriteBlock(const char *data, TQT_TQIO_ULONG len) -{ - resetError(); - TQ_LONG retval = socketDevice()->tqwriteBlock(data, len); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -TQT_TQIO_LONG KClientSocketBase::tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to) -{ - resetError(); - TQ_LONG retval = socketDevice()->tqwriteBlock(data, len, to); - if (retval == -1) - { - copyError(); - emit gotError(error()); - } - return retval; -} - -KSocketAddress KClientSocketBase::localAddress() const -{ - return socketDevice()->localAddress(); -} - -KSocketAddress KClientSocketBase::peerAddress() const -{ - return socketDevice()->peerAddress(); -} - -bool KClientSocketBase::emitsReadyRead() const -{ - return d->enableRead; -} - -void KClientSocketBase::enableRead(bool enable) -{ - TQMutexLocker locker(mutex()); - - d->enableRead = enable; - TQSocketNotifier *n = socketDevice()->readNotifier(); - if (n) - n->setEnabled(enable); -} - -bool KClientSocketBase::emitsReadyWrite() const -{ - return d->enableWrite; -} - -void KClientSocketBase::enableWrite(bool enable) -{ - TQMutexLocker locker(mutex()); - - d->enableWrite = enable; - TQSocketNotifier *n = socketDevice()->writeNotifier(); - if (n) - n->setEnabled(enable); -} - -void KClientSocketBase::slotReadActivity() -{ - if (d->enableRead) - emit readyRead(); -} - -void KClientSocketBase::slotWriteActivity() -{ - if (d->enableWrite) - emit readyWrite(); -} - -void KClientSocketBase::lookupFinishedSlot() -{ - if (d->peerResolver.isRunning() || d->localResolver.isRunning() || state() != HostLookup) - return; - - TQObject::disconnect(&d->peerResolver, 0L, this, TQT_SLOT(lookupFinishedSlot())); - TQObject::disconnect(&d->localResolver, 0L, this, TQT_SLOT(lookupFinishedSlot())); - if (d->peerResolver.status() < 0 || d->localResolver.status() < 0) - { - setState(Idle); // backtrack - setError(IO_LookupError, LookupFailure); - emit stateChanged(Idle); - emit gotError(LookupFailure); - return; - } - - d->localResults = d->localResolver.results(); - d->peerResults = d->peerResolver.results(); - setState(HostFound); - emit stateChanged(HostFound); - emit hostFound(); -} - -void KClientSocketBase::stateChanging(SocketState newState) -{ - if (newState == Connected && socketDevice()) - { - TQSocketNotifier *n = socketDevice()->readNotifier(); - if (n) - { - n->setEnabled(d->enableRead); - TQObject::connect(n, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotReadActivity())); - } - else - return; - - n = socketDevice()->writeNotifier(); - if (n) - { - n->setEnabled(d->enableWrite); - TQObject::connect(n, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotWriteActivity())); - } - else - return; - } -} - -void KClientSocketBase::copyError() -{ - setError(socketDevice()->status(), socketDevice()->error()); -} - -#include "kclientsocketbase.moc" diff --git a/kdecore/network/kclientsocketbase.h b/kdecore/network/kclientsocketbase.h deleted file mode 100644 index 75e796ffc..000000000 --- a/kdecore/network/kclientsocketbase.h +++ /dev/null @@ -1,532 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KCLIENTSOCKETBASE_H -#define KCLIENTSOCKETBASE_H - -#include <tqobject.h> -#include <tqstring.h> - -#include "ksocketbase.h" -#include "kresolver.h" -#include <kdelibs_export.h> - -#ifdef Q_MOC_RUN -#define USE_QT4 -#endif // Q_MOC_RUN - -namespace KNetwork { - -class KClientSocketBasePrivate; -/** @class KClientSocketBase kclientsocketbase.h kclientsocketbase.h - * @brief Abstract client socket class. - * - * This class provides the base functionality for client sockets, - * such as, and especially, name resolution and signals. - * - * @note This class is abstract. If you're looking for a normal, - * client socket class, see @ref KStreamSocket and KBufferedSocket - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KClientSocketBase : -#ifdef USE_QT4 -#else // USE_QT4 -public TQObject, -#endif // USE_QT4 -public KActiveSocketBase -{ - Q_OBJECT - TQ_OBJECT - -public: - /** - * Socket states. - * - * These are the possible states for a KClientSocketBase: - * - Idle: socket is not connected - * - HostLookup: socket is doing host lookup prior to connecting - * - HostFound: name lookup is complete - * - Bound: the socket is locally bound - * - Connecting: socket is attempting connection - * - Open: socket is open - * - Connected (=Open): socket is connected - * - Connection (=Open): yet another name for a connected socket - * - Closing: socket is shutting down - * - * Whenever the socket state changes, the @ref stateChanged(int) signal - * will be emitted. - */ - enum SocketState - { - Idle, - HostLookup, - HostFound, - Bound, - Connecting, - Open, - Closing, - - Unconnected = Bound, - Connected = Open, - Connection = Open - }; - -public: - /** - * Default constructor. - * - * @param parent the parent TQObject object - * @param name the name of this object - */ - KClientSocketBase(TQObject* parent, const char *name); - - /** - * Destructor. - */ - virtual ~KClientSocketBase(); - - /** - * Returns the current state for this socket. - * @see SocketState - */ - SocketState state() const; - -protected: - /** - * Sets the socket options. Reimplemented from KSocketBase. - */ - virtual bool setSocketOptions(int opts); - -public: - /** - * Returns the internal KResolver object used for - * looking up the peer host name and service. - * - * This can be used to set extra options to the - * lookup process other than the default values, as well - * as obtaining the error codes in case of lookup failure. - */ - KResolver& peerResolver() const; - - /** - * Returns the internal list of resolved results for the peer address. - */ - const KResolverResults& peerResults() const; - - /** - * Returns the internal KResolver object used for - * looking up the local host name and service. - * - * This can be used to set extra options to the - * lookup process other than the default values, as well - * as obtaining the error codes in case of lookup failure. - */ - KResolver& localResolver() const; - - /** - * Returns the internal list of resolved results for the local address. - */ - const KResolverResults& localResults() const; - - /** - * Enables or disables name resolution. If this flag is set to true, - * @ref bind and @ref connect operations will trigger name lookup - * operations (i.e., converting a hostname into its binary form). - * If the flag is set to false, those operations will instead - * try to convert a string representation of an address without - * attempting name resolution. - * - * This is useful, for instance, when IP addresses are in - * their string representation (such as "1.2.3.4") or come - * from other sources like @ref KSocketAddress. - * - * @param enable whether to enable - */ - void setResolutionEnabled(bool enable); - - /** - * Sets the allowed families for the resolutions. - * - * @param families the families that we want/accept - * @see KResolver::SocketFamilies for possible values - */ - void setFamily(int families); - - /** - * Starts the lookup for peer and local hostnames as - * well as their services. - * - * If the blocking mode for this object is on, this function will - * wait for the lookup results to be available (by calling the - * @ref KResolver::wait method on the resolver objects). - * - * When the lookup is done, the signal @ref hostFound will be - * emitted (only once, even if we're doing a double lookup). - * If the lookup failed (for any of the two lookups) the - * @ref gotError signal will be emitted with the appropriate - * error condition (see @ref KSocketBase::SocketError). - * - * This function returns true on success and false on error. Note that - * this is not the lookup result! - */ - virtual bool lookup(); - - /** - * Binds this socket to the given nodename and service, - * or use the default ones if none are given. - * - * Upon successful binding, the @ref bound signal will be - * emitted. If an error is found, the @ref gotError - * signal will be emitted. - * - * @note Due to the internals of the name lookup and binding - * mechanism, some (if not most) implementations of this function - * do not actually bind the socket until the connection - * is requested (see @ref connect). They only set the values - * for future reference. - * - * This function returns true on success. - * - * @param node the nodename - * @param service the service - */ - virtual bool bind(const TQString& node = TQString::null, - const TQString& service = TQString::null) = 0; - - /** - * Reimplemented from KSocketBase. Connect this socket to this - * specific address. - * - * Unlike @ref bind(const TQString&, const TQString&) above, this function - * really does bind the socket. No lookup is performed. The @ref bound - * signal will be emitted. - */ - virtual bool bind(const KResolverEntry& address); - - /** - * Attempts to connect to the these hostname and service, - * or use the default ones if none are given. If a connection attempt - * is already in progress, check on its state and set the error status - * (NoError or InProgress). - * - * If the blocking mode for this object is on, this function will only - * return when all the resolved peer addresses have been tried or when - * a connection is established. - * - * Upon successfully connecting, the @ref connected signal - * will be emitted. If an error is found, the @ref gotError - * signal will be emitted. - * - * @par Note for derived classes: - * Derived classes must implement this function. The implementation - * will set the parameters for the lookup (using the peer KResolver - * object) and call @ref lookup to start it. - * - * @par - * The implementation should use the @ref hostFound - * signal to be notified of the completion of the lookup process and - * then proceed to start the connection itself. Care should be taken - * regarding the value of @ref blocking flag. - * - * @param node the nodename - * @param service the service - */ - virtual bool connect(const TQString& node = TQString::null, - const TQString& service = TQString::null) = 0; - - /** - * @overload - * Reimplemented from KSocketBase. - */ - virtual bool connect(const KResolverEntry& address); - - /** - * @deprecated - * This is a convenience function provided to ease migrating from - * Qt 3.x's TQSocket class. - */ - inline void connectToHost(const TQString& host, TQ_UINT16 port) - { connect(host, TQString::number(port)); } - - /** - * Disconnects the socket. - * Note that not all socket types can disconnect. - */ - virtual bool disconnect(); - - /** - * Opens the socket. Reimplemented from TQIODevice. - * - * You should not call this function; instead, use @ref connect - */ - virtual inline bool open(TQ_OpenMode) - { return connect(); } - - /** - * Closes the socket. Reimplemented from TQIODevice. - * - * The closing of the socket causes the emission of the - * signal @ref closed. - */ - virtual void close(); - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - */ - virtual void flush() - { } - - /** - * Returns the number of bytes available on this socket. - * Reimplemented from KSocketBase. - */ -#ifdef USE_QT3 - virtual TQ_LONG bytesAvailable() const; -#endif -#ifdef USE_QT4 - virtual qint64 bytesAvailable() const; -#endif - - /** - * Waits for more data. Reimplemented from KSocketBase. - */ - virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L); - - /** - * Reads data from a socket. Reimplemented from KSocketBase. - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen); - - /** - * @overload - * Reads data from a socket. Reimplemented from KSocketBase. - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from); - - /** - * Peeks data from the socket. Reimplemented from KSocketBase. - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen); - - /** - * @overload - * Peeks data from the socket. Reimplemented from KSocketBase. - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress &from); - - /** - * Writes data to the socket. Reimplemented from KSocketBase. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len); - - /** - * @overload - * Writes data to the socket. Reimplemented from KSocketBase. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to); - - /** - * Returns the local socket address. Reimplemented from KSocketBase. - */ - virtual KSocketAddress localAddress() const; - - /** - * Returns the peer socket address. Reimplemented from KSocketBase. - */ - virtual KSocketAddress peerAddress() const; - - /** - * Returns true if the readyRead signal is set to be emitted. - */ - bool emitsReadyRead() const; - - /** - * Enables the emission of the readyRead signal. - * By default, this signal is enabled. - * - * @param enable whether to enable the signal - */ - virtual void enableRead(bool enable); - - /** - * Returns true if the readyWrite signal is set to be emitted. - */ - bool emitsReadyWrite() const; - - /** - * Enables the emission of the readyWrite signal. - * By default, this signal is disabled. - * - * @param enable whether to enable the signal - */ - virtual void enableWrite(bool enable); - -protected slots: - // protected slots - - /** - * This slot is connected to the read notifier's signal meaning - * the socket can read more data. - * - * The default implementation only emits the readyRead signal. - * - * Override if your class requires processing of incoming - * data. - */ - virtual void slotReadActivity(); - - /** - * This slot is connected to the write notifier's signal - * meaning the socket can write more data. - * - * The default implementation only emits the readyWrite signal. - * - * Override if your class writes data from another source - * (like a buffer). - */ - virtual void slotWriteActivity(); - -private slots: - void lookupFinishedSlot(); - -signals: - /** - * This signal is emitted whenever the socket state changes. - * - * Note: do not delete this object inside the slot called by this - * signal. - * - * @param newstate the new state of the socket object - */ - void stateChanged(int newstate); - - /** - * This signal is emitted when this object finds an error. - * The @p code parameter contains the error code that can - * also be found by calling @ref error. - */ - void gotError(int code); - - /** - * This signal is emitted when the lookup is successfully completed. - */ - void hostFound(); - - /** - * This signal is emitted when the socket successfully binds - * to an address. - * - * @param local the local address we bound to - */ - void bound(const KResolverEntry& local); - - /** - * This signal is emitted when the socket is about to connect - * to an address (but before doing so). - * - * The @p skip parameter can be used to make the loop skip this address. - * Its value is initially false: change it to true if you want to - * skip the current address (as given by @p remote). - * - * This function is also useful if one wants to reset the timeout. - * - * @param remote the address we're about to connect to - * @param skip set to true if you want to skip this address - * @note if the connection is successful, the @ref connected signal will be - * emitted. - */ - void aboutToConnect(const KResolverEntry& remote, bool& skip); - - /** - * This socket is emitted when the socket successfully connects - * to a remote address. - * - * @param remote the remote address we did connect to - */ - void connected(const KResolverEntry& remote); - - /** - * This signal is emitted when the socket completes the - * closing/shut down process. - */ - void closed(); - - /** - * This signal is emitted whenever the socket is ready for - * reading -- i.e., there is data to be read in the buffers. - * The subsequent read operation is guaranteed to be non-blocking. - * - * You can toggle the emission of this signal with the @ref enableRead - * function. This signal is by default enabled. - */ - void readyRead(); - - /** - * This signal is emitted whenever the socket is ready for - * writing -- i.e., whenever there's space available in the buffers - * to receive more data. The subsequent write operation is - * guaranteed to be non-blocking. - * - * You can toggle the emission of this signal with the @ref enableWrite - * function. This signal is by default disabled. You will - * want to disable this signal after the first reception, since - * it'll probably fire at every event loop. - */ - void readyWrite(); - -protected: - /** - * Sets the socket state to @p state. This function does not - * emit the @ref stateChanged signal. - */ - void setState(SocketState state); - - /** - * This function is called by @ref setState whenever the state - * changes. You should override it if you need to specify any - * actions to be done when the state changes. - * - * The default implementation acts for these states only: - * - Connected: it sets up the socket notifiers to fire readyRead and - * readyWrite signals. - */ - virtual void stateChanging(SocketState newState); - - /** - * Convenience function to set this object's error code to match - * that of the socket device. - */ - void copyError(); - -private: - KClientSocketBase(const KClientSocketBase&); - KClientSocketBase& operator=(const KClientSocketBase&); - - KClientSocketBasePrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kdatagramsocket.cpp b/kdecore/network/kdatagramsocket.cpp deleted file mode 100644 index d4bddc543..000000000 --- a/kdecore/network/kdatagramsocket.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <sys/types.h> -#include <sys/socket.h> - -#include "ksocketaddress.h" -#include "kresolver.h" -#include "ksocketdevice.h" -#include "kdatagramsocket.h" - -using namespace KNetwork; - -/* - * TODO: - * - * don't use signals and slots to track state changes: use stateChanging - * - */ - -KDatagramSocket::KDatagramSocket(TQObject* parent, const char *name) - : KClientSocketBase(parent, name), d(0L) -{ - peerResolver().setFamily(KResolver::KnownFamily); - localResolver().setFamily(KResolver::KnownFamily); - - peerResolver().setSocketType(SOCK_DGRAM); - localResolver().setSocketType(SOCK_DGRAM); - - localResolver().setFlags(KResolver::Passive); - - // TQObject::connect(localResolver(), TQT_SIGNAL(finished(KResolverResults)), - // this, TQT_SLOT(lookupFinishedLocal())); - TQObject::connect(&peerResolver(), TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(lookupFinishedPeer())); - TQObject::connect(this, TQT_SIGNAL(hostFound()), this, TQT_SLOT(lookupFinishedLocal())); -} - -KDatagramSocket::~KDatagramSocket() -{ - // KClientSocketBase's destructor closes the socket - - //delete d; -} - -bool KDatagramSocket::bind(const TQString& node, const TQString& service) -{ - if (state() >= Bound) - return false; - - if (localResolver().isRunning()) - localResolver().cancel(false); - - // no, we must do a host lookup - localResolver().setAddress(node, service); - - if (!lookup()) - return false; - - // see if lookup has finished already - // this also catches blocking mode, since lookup has to finish - // its processing if we're in blocking mode - if (state() > HostLookup) - return doBind(); - - return true; -} - -bool KDatagramSocket::connect(const TQString& node, const TQString& service) -{ - if (state() >= Connected) - return true; // already connected - - if (peerResolver().nodeName() != node || - peerResolver().serviceName() != service) - peerResolver().setAddress(node, service); // this resets the resolver's state - - // KClientSocketBase::lookup only works if the state is Idle or HostLookup - // therefore, we store the old state, call the lookup routine and then set - // it back. - SocketState s = state(); - setState(s == Connecting ? HostLookup : Idle); - bool ok = lookup(); - if (!ok) - { - setState(s); // go back - return false; - } - - // check if lookup is finished - // if we're in blocking mode, then the lookup has to be finished - if (state() == HostLookup) - { - // it hasn't finished - setState(Connecting); - emit stateChanged(Connecting); - return true; - } - - // it has to be finished here - if (state() != Connected) - { - setState(Connecting); - emit stateChanged(Connecting); - lookupFinishedPeer(); - } - - return state() == Connected; -} - -KDatagramPacket KDatagramSocket::receive() -{ - TQ_LONG size = bytesAvailable(); - if (size == 0) - { - // nothing available yet to read - // wait for data if we're not blocking - if (blocking()) - socketDevice()->waitForMore(-1); // wait forever - else - { - // mimic error - setError(IO_ReadError, WouldBlock); - emit gotError(WouldBlock); - return KDatagramPacket(); - } - - // try again - size = bytesAvailable(); - } - - TQByteArray data(size); - KSocketAddress address; - - // now do the reading - size = tqreadBlock(data.data(), size, address); - if (size < 0) - // error has been set - return KDatagramPacket(); - - data.resize(size); // just to be sure - return KDatagramPacket(data, address); -} - -TQ_LONG KDatagramSocket::send(const KDatagramPacket& packet) -{ - return tqwriteBlock(packet.data(), packet.size(), packet.address()); -} - -TQ_LONG KDatagramSocket::tqwriteBlock(const char *data, TQ_ULONG len, const KSocketAddress& to) -{ - if (to.family() != AF_UNSPEC) - { - // make sure the socket is open at this point - if (!socketDevice()->isOpen()) - // error handling will happen below - socketDevice()->create(to.family(), SOCK_DGRAM, 0); - } - return KClientSocketBase::tqwriteBlock(data, len, to); -} - -void KDatagramSocket::lookupFinishedLocal() -{ - // bind lookup has finished and succeeded - // state() == HostFound - - if (!doBind()) - return; // failed binding - - if (peerResults().count() > 0) - { - setState(Connecting); - emit stateChanged(Connecting); - - lookupFinishedPeer(); - } -} - -void KDatagramSocket::lookupFinishedPeer() -{ - // this function is called by lookupFinishedLocal above - // and is also connected to a signal - // so it might be called twice. - - if (state() != Connecting) - return; - - if (peerResults().count() == 0) - { - setState(Unconnected); - emit stateChanged(Unconnected); - return; - } - - KResolverResults::ConstIterator it = peerResults().begin(); - for ( ; it != peerResults().end(); ++it) - if (connect(*it)) - { - // weee, we connected - - setState(Connected); // this sets up signals - //setupSignals(); // setState sets up the signals - - emit stateChanged(Connected); - emit connected(*it); - return; - } - - // no connection - copyError(); - setState(Unconnected); - emit stateChanged(Unconnected); - emit gotError(error()); -} - -bool KDatagramSocket::doBind() -{ - if (localResults().count() == 0) - return true; - if (state() >= Bound) - return true; // already bound - - KResolverResults::ConstIterator it = localResults().begin(); - for ( ; it != localResults().end(); ++it) - if (bind(*it)) - { - // bound - setupSignals(); - return true; - } - - // not bound - // no need to set state since it can only be HostFound already - copyError(); - emit gotError(error()); - return false; -} - -void KDatagramSocket::setupSignals() -{ - TQSocketNotifier *n = socketDevice()->readNotifier(); - if (n) - { - n->setEnabled(emitsReadyRead()); - TQObject::connect(n, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotReadActivity())); - } - else - return; - - n = socketDevice()->writeNotifier(); - if (n) - { - n->setEnabled(emitsReadyWrite()); - TQObject::connect(n, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotWriteActivity())); - } - else - return; -} - -#include "kdatagramsocket.moc" diff --git a/kdecore/network/kdatagramsocket.h b/kdecore/network/kdatagramsocket.h deleted file mode 100644 index becbe404a..000000000 --- a/kdecore/network/kdatagramsocket.h +++ /dev/null @@ -1,279 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KDATAGRAMSOCKET_H -#define KDATAGRAMSOCKET_H - -#include <tqcstring.h> - -#include "ksocketaddress.h" -#include "kclientsocketbase.h" - -namespace KNetwork { - -class KResolverEntry; - -/** - * @class KDatagramPacket kdatagramsocket.h kdatagramsocket.h - * @brief one datagram - * - * This object represents one datagram of data sent or received through - * a datagram socket (as @ref KDatagramSocket or derived classes). A datagram - * consists of data as well as a network address associated (whither to send - * the data or whence it came). - * - * This is a lightweight class. Data is stored in a @ref TQByteArray, which means - * that it is explicitly shared. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KDatagramPacket -{ - TQByteArray m_data; - KSocketAddress m_address; - -public: - /** - * Default constructor. - */ - KDatagramPacket() - { } - - /** - * Constructs the datagram with the specified content. - */ - KDatagramPacket(const TQByteArray& content) - : m_data(content) - { } - - /** - * Constructs the datagram with the specified content. - * - * @see setData for information on data sharing. - */ - KDatagramPacket(const char* content, uint length) - { setData(content, length); } - - /** - * Constructs the datagram with the specified content and address. - */ - KDatagramPacket(const TQByteArray& content, const KSocketAddress& addr) - : m_data(content), m_address(addr) - { } - - /** - * Constructs the datagram with the specified content and address. - */ - KDatagramPacket(const char *content, uint length, const KSocketAddress& addr) - : m_address(addr) - { setData(content, length); } - - /** - * Copy constructor. Note that data is explicitly shared. - */ - KDatagramPacket(const KDatagramPacket& other) - { *this = other; } - - /** - * Destructor. Non-virtual. - */ - ~KDatagramPacket() - { } - - /** - * Returns the data. - */ - const TQByteArray& data() const - { return m_data; } - - /** - * Returns the data length. - */ - uint length() const - { return m_data.size(); } - - /** - * Returns the data length. - */ - uint size() const - { return m_data.size(); } - - /** - * Returns true if this object is empty. - */ - bool isEmpty() const - { return m_data.isEmpty(); } - - /** - * Returns true if this object is null. - */ - bool isNull() const - { return m_data.isNull(); } - - /** - * Returns the socket address - */ - const KSocketAddress& address() const - { return m_address; } - - /** - * Sets the address stored to the given value. - */ - void setAddress(const KSocketAddress& addr) - { m_address = addr; } - - /** - * Detaches our data from a shared pool. - * @see TQByteArray::detach - */ - void detach() - { m_data.detach(); } - - /** - * Sets the data to the given value. Data is explicitly shared. - */ - void setData(const TQByteArray& data) - { m_data = data; } - - /** - * Sets the data to the given buffer and size. - */ - void setData(const char* data, uint length) - { m_data.duplicate(data, length); } -}; - -class KDatagramSocketPrivate; -/** - * @class KDatagramSocket kdatagramsocket.h kdatagramsocket.h - * @brief A socket that operates on datagrams. - * - * Unlike @ref KStreamSocket, which operates on a connection-based stream - * socket (generally TCP), this class and its descendants operates on datagrams, - * which are normally connectionless. - * - * This class in specific provides easy access to the system's connectionless - * SOCK_DGRAM sockets. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KDatagramSocket: public KClientSocketBase -{ - Q_OBJECT - TQ_OBJECT - -public: - /** - * Default constructor. - */ - KDatagramSocket(TQObject* parent = 0L, const char *name = 0L); - - /** - * Destructor. This closes the socket. - */ - virtual ~KDatagramSocket(); - - /** - * Performs host lookups. - */ - // virtual bool lookup(); - - /** - * Binds this socket to the given address. If the socket is blocking, - * the socket will be bound when this function returns. - * - * Note that binding a socket is not necessary to be able to send datagrams. - * Some protocol families will use anonymous source addresses, while others - * will allocate an address automatically. - */ - virtual bool bind(const TQString& node = TQString::null, - const TQString& service = TQString::null); - - /** - * @overload - * Binds this socket to the given address. - */ - virtual bool bind(const KResolverEntry& entry) - { return KClientSocketBase::bind(entry); } - - /** - * "Connects" this socket to the given address. Note that connecting - * a datagram socket normally does not establish a permanent connection - * with the peer nor normally returns an error in case of failure. - * - * Connecting means only to designate the given address as the default - * destination address for datagrams sent without destination addresses - * ( tqwriteBlock(const char *, TQ_ULONG) ). - * - * @note Calling connect will not cause the socket to be bound. You have - * to call @ref bind explicitly. - */ - virtual bool connect(const TQString& node = TQString::null, - const TQString& service = TQString::null); - - /** - * @overload - * "Connects" this socket to the given address. - */ - virtual bool connect(const KResolverEntry& entry) - { return KClientSocketBase::connect(entry); } - - /** - * Writes data to the socket. Reimplemented from KClientSocketBase. - */ - virtual TQ_LONG tqwriteBlock(const char *data, TQ_ULONG len, const KSocketAddress& to); - - /** - * Receives one datagram from the stream. The reading process is guaranteed - * to be atomical and not lose data from the packet. - * - * If nothing could be read, a null object will be returned. - */ - virtual KDatagramPacket receive(); - - /** - * Sends one datagram into the stream. The destination address must be - * set if this socket has not been connected (see @ref connect). - * - * The data in this packet will be sent only in one single datagram. If the - * system cannot send it like that, this function will fail. So, please take - * into consideration the datagram size limits. - * - * @returns the number of bytes written or -1 in case of error. - */ - virtual TQ_LONG send(const KDatagramPacket& packet); - -private slots: - void lookupFinishedLocal(); - void lookupFinishedPeer(); - -private: - bool doBind(); - void setupSignals(); - - KDatagramSocketPrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/khttpproxysocketdevice.cpp b/kdecore/network/khttpproxysocketdevice.cpp deleted file mode 100644 index 648f4e571..000000000 --- a/kdecore/network/khttpproxysocketdevice.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <sys/types.h> -#include <sys/socket.h> - -#include <tqsocketnotifier.h> -#include <tqcstring.h> - -#include "kresolver.h" -#include "ksocketaddress.h" -#include "ksocketdevice.h" -#include "khttpproxysocketdevice.h" - -using namespace KNetwork; - -KResolverEntry KHttpProxySocketDevice::defaultProxy; - -class KNetwork::KHttpProxySocketDevicePrivate -{ -public: - KResolverEntry proxy; - TQCString request; - TQCString reply; - KSocketAddress peer; - - KHttpProxySocketDevicePrivate() - : proxy(KHttpProxySocketDevice::defaultProxy) - { } -}; - -KHttpProxySocketDevice::KHttpProxySocketDevice(const KSocketBase* parent) - : KSocketDevice(parent), d(new KHttpProxySocketDevicePrivate) -{ -} - -KHttpProxySocketDevice::KHttpProxySocketDevice(const KResolverEntry& proxy) - : d(new KHttpProxySocketDevicePrivate) -{ - d->proxy = proxy; -} - -KHttpProxySocketDevice::~KHttpProxySocketDevice() -{ - // nothing special to be done during closing - // KSocketDevice::~KSocketDevice closes the socket - - delete d; -} - -int KHttpProxySocketDevice::capabilities() const -{ - return CanConnectString | CanNotBind | CanNotListen | CanNotUseDatagrams; -} - -const KResolverEntry& -KHttpProxySocketDevice::proxyServer() const -{ - return d->proxy; -} - -void KHttpProxySocketDevice::setProxyServer(const KResolverEntry& proxy) -{ - d->proxy = proxy; -} - -void KHttpProxySocketDevice::close() -{ - d->reply = d->request = TQCString(); - d->peer = KSocketAddress(); - KSocketDevice::close(); -} - -KSocketAddress KHttpProxySocketDevice::peerAddress() const -{ - if (isOpen()) - return d->peer; - return KSocketAddress(); -} - -KSocketAddress KHttpProxySocketDevice::externalAddress() const -{ - return KSocketAddress(); -} - -bool KHttpProxySocketDevice::connect(const KResolverEntry& address) -{ - if (d->proxy.family() == AF_UNSPEC) - // no proxy server set ! - return KSocketDevice::connect(address); - - if (isOpen()) - { - // socket is already open - resetError(); - return true; - } - - if (m_sockfd == -1) - // socket isn't created yet - return connect(address.address().nodeName(), - address.address().serviceName()); - - d->peer = address.address(); - return parseServerReply(); -} - -bool KHttpProxySocketDevice::connect(const TQString& node, const TQString& service) -{ - // same safety checks as above - if (m_sockfd == -1 && (d->proxy.family() == AF_UNSPEC || - node.isEmpty() || service.isEmpty())) - { - // no proxy server set ! - setError(IO_ConnectError, NotSupported); - return false; - } - - if (isOpen()) - { - // socket is already open - return true; - } - - if (m_sockfd == -1) - { - // must create the socket - if (!KSocketDevice::connect(d->proxy)) - return false; // also unable to contact proxy server - setState(0); // unset open flag - - // prepare the request - TQString request = TQString::tqfromLatin1("CONNECT %1:%2 HTTP/1.1\r\n" - "Cache-Control: no-cache\r\n" - "Host: \r\n" - "\r\n"); - TQString node2 = node; - if (node.contains(':')) - node2 = '[' + node + ']'; - - d->request = TQString(request.arg(node2).arg(service)).latin1(); - } - - return parseServerReply(); -} - -bool KHttpProxySocketDevice::parseServerReply() -{ - // make sure we're connected - if (!KSocketDevice::connect(d->proxy)) - if (error() == InProgress) - return true; - else if (error() != NoError) - return false; - - if (!d->request.isEmpty()) - { - // send request - TQ_LONG written = tqwriteBlock(d->request, d->request.length()); - if (written < 0) - { - qDebug("KHttpProxySocketDevice: would block writing request!"); - if (error() == WouldBlock) - setError(IO_ConnectError, InProgress); - return error() == WouldBlock; // error - } - qDebug("KHttpProxySocketDevice: request written"); - - d->request.remove(0, written); - - if (!d->request.isEmpty()) - { - setError(IO_ConnectError, InProgress); - return true; // still in progress - } - } - - // request header is sent - // must parse reply, but must also be careful not to read too much - // from the buffer - - int index; - if (!blocking()) - { - TQ_LONG avail = bytesAvailable(); - qDebug("KHttpProxySocketDevice: %ld bytes available", avail); - setState(0); - if (avail == 0) - { - setError(IO_ConnectError, InProgress); - return true; - } - else if (avail < 0) - return false; // error! - - TQByteArray buf(avail); - if (peekBlock(buf.data(), avail) < 0) - return false; // error! - - TQCString fullHeaders = d->reply + buf.data(); - // search for the end of the headers - index = fullHeaders.find("\r\n\r\n"); - if (index == -1) - { - // no, headers not yet finished... - // consume data from socket - tqreadBlock(buf.data(), avail); - d->reply += buf.data(); - setError(IO_ConnectError, InProgress); - return true; - } - - // headers are finished - index -= d->reply.length(); - d->reply += fullHeaders.mid(d->reply.length(), index + 4); - - // consume from socket - tqreadBlock(buf.data(), index + 4); - } - else - { - int state = 0; - if (d->reply.right(3) == "\r\n\r") - state = 3; - else if (d->reply.right(2) == "\r\n") - state = 2; - else if (d->reply.right(1) == "\r") - state = 1; - while (state != 4) - { - char c = getch(); - d->reply += c; - - if ((state == 3 && c == '\n') || - (state == 1 && c == '\n') || - c == '\r') - ++state; - else - state = 0; - } - } - - // now really parse the reply - qDebug("KHttpProxySocketDevice: get reply: %s\n", - d->reply.left(d->reply.find('\r')).data()); - if (d->reply.left(7) != "HTTP/1." || - (index = d->reply.find(' ')) == -1 || - d->reply[index + 1] != '2') - { - setError(IO_ConnectError, NetFailure); - return false; - } - - // we've got it - resetError(); - setState(IO_Open); - return true; -} diff --git a/kdecore/network/khttpproxysocketdevice.h b/kdecore/network/khttpproxysocketdevice.h deleted file mode 100644 index 7c9908ad5..000000000 --- a/kdecore/network/khttpproxysocketdevice.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KHTTPPROXYSOCKETDEVICE_H -#define KHTTPPROXYSOCKETDEVICE_H - -#include "ksocketdevice.h" - -namespace KNetwork { - -class KHttpProxySocketDevicePrivate; - -/** - * @class KHttpProxySocketDevice khttpproxysocketdevice.h khttproxysocketdevice.h - * @brief The low-level backend for HTTP proxying. - * - * This class derives from @ref KSocketDevice and implements the necessary - * calls to make a connection through an HTTP proxy. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KHttpProxySocketDevice: public KSocketDevice -{ -public: - /** - * Constructor. - */ - KHttpProxySocketDevice(const KSocketBase* = 0L); - - /** - * Constructor with proxy server's address. - */ - KHttpProxySocketDevice(const KResolverEntry& proxy); - - /** - * Destructor - */ - virtual ~KHttpProxySocketDevice(); - - /** - * Sets our capabilities. - */ - virtual int capabilities() const; - - /** - * Retrieves the proxy server address. - */ - const KResolverEntry& proxyServer() const; - - /** - * Sets the proxy server address. - */ - void setProxyServer(const KResolverEntry& proxy); - - /** - * Closes the socket. - */ - virtual void close(); - - /** - * Overrides connection. - */ - virtual bool connect(const KResolverEntry& address); - - /** - * Name-based connection. - * We can tell the HTTP proxy server the full name. - */ - virtual bool connect(const TQString& name, const TQString& service); - - /** - * Return the peer address. - */ - virtual KSocketAddress peerAddress() const; - - /** - * Return the externally visible address. We can't tell what that address is, - * so this function always returns an empty object. - */ - virtual KSocketAddress externalAddress() const; - -private: - /** - * Parses the server reply after sending the connect command. - * Returns true on success and false on failure. - */ - bool parseServerReply(); - KHttpProxySocketDevicePrivate *d; - -public: - /** - * This is the default proxy server to be used. - * Applications may want to set this value so that calling @ref setProxyServer - * is unnecessary. - */ - static KResolverEntry defaultProxy; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kiobuffer.h b/kdecore/network/kiobuffer.h deleted file mode 100644 index 02f75a420..000000000 --- a/kdecore/network/kiobuffer.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KIOBUFFER_H -#define KIOBUFFER_H - -#include <tqcstring.h> - -#include <kdelibs_export.h> - -class TQIODevice; - -/** - * @class KIOBufferBase kiobuffer.h kiobuffer.h - * @brief base for I/O buffer implementation - * - * This class declares the base methods to interface with an I/O buffer. - * Most applications will not need to access this class directly, since - * it is all handled by @ref KNetwork::KBufferedSocket and other buffering - * classes. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KIOBufferBase -{ -public: - /** - * Default constructor. Does nothing. - */ - KIOBufferBase() - { } - - /** - * Copy constructor. Does nothing here. - */ - KIOBufferBase(const KIOBufferBase& ) - { } - - /** - * Virtual destructor. Does nothing. - */ - virtual ~KIOBufferBase() - { } - - /** - * Assignment operator. Does nothing. - */ - KIOBufferBase& operator=(const KIOBufferBase& ) - { return *this; } - - /** - * Returns true if a line can be read from the buffer. - */ - virtual bool canReadLine() const = 0; - - /** - * Reads a line from the buffer and discards it. - */ - virtual TQCString readLine() = 0; - - /** - * Returns the number of bytes in the buffer. Note that this is not - * the size of the buffer. - * - * @sa size - */ - virtual TQ_LONG length() const = 0; - - /** - * Returns true if the buffer is empty of data. - */ - inline bool isEmpty() const - { return length() == 0; } - - /** - * Retrieves the buffer size. The value of -1 indicates that - * the buffer has no defined upper limit. - * - * @sa length for the length of the data stored - */ - virtual TQ_LONG size() const = 0; - - /** - * Returns true if the buffer is full (i.e., cannot receive more data) - */ - inline bool isFull() const - { return size() != -1 && size() == length(); } - - /** - * Sets the size of the buffer, if allowed. - * - * @param size the maximum size, use -1 for unlimited. - * @returns true on success, false if an error occurred. - * @note if the new size is less than length(), the buffer will be truncated - */ - virtual bool setSize(TQ_LONG size) = 0; - - /** - * Adds data to the end of the buffer. - * - * @param data the data to be added - * @param len the data length, in bytes - * @returns the number of bytes added to the end of the buffer. - */ - virtual TQ_LONG feedBuffer(const char *data, TQ_LONG len) = 0; - - /** - * Consumes data from the beginning of the buffer. - * - * @param data where to copy the data to - * @param maxlen the maximum length to copy, in bytes - * @param discard if true, the bytes copied will be discarded - * @returns the number of bytes copied from the buffer - */ - virtual TQ_LONG consumeBuffer(char *data, TQ_LONG maxlen, bool discard = true) = 0; - - /** - * Clears the buffer. - */ - virtual void clear() = 0; -}; - -#endif diff --git a/kdecore/network/kmulticastsocket.h b/kdecore/network/kmulticastsocket.h deleted file mode 100644 index 7fbd6e0f2..000000000 --- a/kdecore/network/kmulticastsocket.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 <thiago.macieira@kdemail.net> - */ -class KDECORE_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 KSocketAddress& group); - - /** - * @overload - * Joins a multicast group. This function also specifies the network interface - * to be used. - */ - virtual bool joinGroup(const KSocketAddress& 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 KSocketAddress& group); - - /** - * @overload - * Leaves a multicast group. - */ - virtual bool leaveGroup(const KSocketAddress& group, - const KNetworkInterface& iface); - -private: - KMulticastSocketPrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kmulticastsocketdevice.h b/kdecore/network/kmulticastsocketdevice.h deleted file mode 100644 index 7710fe5c1..000000000 --- a/kdecore/network/kmulticastsocketdevice.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 "ksocketdevice.h" -#include "knetworkinterface.h" -#include "ksocketaddress.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 <thiago.macieira@kdemail.net> - */ -class KMulticastSocketImpl: public KSocketDevice -{ -public: - /** - * Constructor. - */ - KMulticastSocketImpl(const KSocketBase* = 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 KSocketAddress& group); - - /** - * @overload - * Joins a multicast group. This function also specifies the network interface - * to be used. - */ - virtual bool joinGroup(const KSocketAddress& 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 KSocketAddress& group); - - /** - * @overload - * Leaves a multicast group. - */ - virtual bool leaveGroup(const KSocketAddress& group, - const KNetworkInterface& iface); -private: - KMulticastSocketImplPrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/knetworkinterface.h b/kdecore/network/knetworkinterface.h deleted file mode 100644 index 74fd52d55..000000000 --- a/kdecore/network/knetworkinterface.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KNETWORKINTERFACE_H -#define KNETWORKINTERFACE_H - -#include <kdelibs_export.h> - -namespace KNetwork { - -/** - * A place-holder class for a future network interface class. - * This class is to be replaced with a more powerful version, inspired - * by: - * - KInetInterface (kdenetwork/krfb/srvloc) - * - NWInterface (kdenonbeta/knot/lib) - * - java.net.NetworkInterface - */ -class KNetworkInterface -{ -}; - -} // namespace KNetwork - -#endif - diff --git a/kdecore/network/kresolver.cpp b/kdecore/network/kresolver.cpp deleted file mode 100644 index 93c029b8e..000000000 --- a/kdecore/network/kresolver.cpp +++ /dev/null @@ -1,1164 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003-2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include "config.h" - -// System includes -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/param.h> -#include <errno.h> -#include <netdb.h> -#include <time.h> -#include <arpa/inet.h> -#include <netinet/in.h> -#include <stdlib.h> -#include <unistd.h> - -// Qt includes -#include <tqapplication.h> -#include <tqstring.h> -#include <tqcstring.h> -#include <tqstrlist.h> -#include <tqstringlist.h> -#include <tqshared.h> -#include <tqdatetime.h> -#include <tqtimer.h> -#include <tqmutex.h> -#include <tqguardedptr.h> - -// IDN -#ifdef HAVE_IDNA_H -# include <idna.h> -#endif - -// KDE -#include <klocale.h> - -// Us -#include "kresolver.h" -#include "kresolver_p.h" -#include "ksocketaddress.h" - -#ifdef NEED_MUTEX -#warning "mutex" -TQMutex getXXbyYYmutex; -#endif - -using namespace KNetwork; -using namespace KNetwork::Internal; - -///////////////////////////////////////////// -// class KResolverEntry - -class KNetwork::KResolverEntryPrivate: public TQShared -{ -public: - KSocketAddress addr; - int socktype; - int protocol; - TQString canonName; - TQCString encodedName; - - inline KResolverEntryPrivate() : - socktype(0), protocol(0) - { } -}; - -// default constructor -KResolverEntry::KResolverEntry() : - d(0L) -{ -} - -// constructor with stuff -KResolverEntry::KResolverEntry(const KSocketAddress& addr, int socktype, int protocol, - const TQString& canonName, const TQCString& encodedName) : - d(new KResolverEntryPrivate) -{ - d->addr = addr; - d->socktype = socktype; - d->protocol = protocol; - d->canonName = canonName; - d->encodedName = encodedName; -} - -// constructor with even more stuff -KResolverEntry::KResolverEntry(const struct sockaddr* sa, TQ_UINT16 salen, int socktype, - int protocol, const TQString& canonName, - const TQCString& encodedName) : - d(new KResolverEntryPrivate) -{ - d->addr = KSocketAddress(sa, salen); - d->socktype = socktype; - d->protocol = protocol; - d->canonName = canonName; - d->encodedName = encodedName; -} - -// copy constructor -KResolverEntry::KResolverEntry(const KResolverEntry& that) : - d(0L) -{ - *this = that; -} - -// destructor -KResolverEntry::~KResolverEntry() -{ - if (d == 0L) - return; - - if (d->deref()) - delete d; -} - -// returns the socket address -KSocketAddress KResolverEntry::address() const -{ - return d ? d->addr : KSocketAddress(); -} - -// returns the length -TQ_UINT16 KResolverEntry::length() const -{ - return d ? d->addr.length() : 0; -} - -// returns the family -int KResolverEntry::family() const -{ - return d ? d->addr.family() : AF_UNSPEC; -} - -// returns the canonical name -TQString KResolverEntry::canonicalName() const -{ - return d ? d->canonName : TQString::null; -} - -// returns the encoded name -TQCString KResolverEntry::encodedName() const -{ - return d ? d->encodedName : TQCString(); -} - -// returns the socket type -int KResolverEntry::socketType() const -{ - return d ? d->socktype : 0; -} - -// returns the protocol -int KResolverEntry::protocol() const -{ - return d ? d->protocol : 0; -} - -// assignment operator -KResolverEntry& KResolverEntry::operator= (const KResolverEntry& that) -{ - // copy the data - if (that.d) - that.d->ref(); - - if (d && d->deref()) - delete d; - - d = that.d; - return *this; -} - -///////////////////////////////////////////// -// class KResolverResults - -class KNetwork::KResolverResultsPrivate -{ -public: - TQString node, service; - int errorcode, syserror; - - KResolverResultsPrivate() : - errorcode(0), syserror(0) - { } -}; - -// default constructor -KResolverResults::KResolverResults() - : d(new KResolverResultsPrivate) -{ -} - -// copy constructor -KResolverResults::KResolverResults(const KResolverResults& other) - : TQValueList<KResolverEntry>(other), d(new KResolverResultsPrivate) -{ - *d = *other.d; -} - -// destructor -KResolverResults::~KResolverResults() -{ - delete d; -} - -// assignment operator -KResolverResults& -KResolverResults::operator= (const KResolverResults& other) -{ - if (this == &other) - return *this; - - // copy over the other data - *d = *other.d; - - // now let TQValueList do the rest of the work - TQValueList<KResolverEntry>::operator =(other); - - return *this; -} - -// gets the error code -int KResolverResults::error() const -{ - return d->errorcode; -} - -// gets the system errno -int KResolverResults::systemError() const -{ - return d->syserror; -} - -// sets the error codes -void KResolverResults::setError(int errorcode, int systemerror) -{ - d->errorcode = errorcode; - d->syserror = systemerror; -} - -// gets the hostname -TQString KResolverResults::nodeName() const -{ - return d->node; -} - -// gets the service name -TQString KResolverResults::serviceName() const -{ - return d->service; -} - -// sets the address -void KResolverResults::setAddress(const TQString& node, - const TQString& service) -{ - d->node = node; - d->service = service; -} - -void KResolverResults::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - - -/////////////////////// -// class KResolver - -TQStringList *KResolver::idnDomains = 0; - - -// default constructor -KResolver::KResolver(TQObject *parent, const char *name) - : TQObject(parent, name), d(new KResolverPrivate(this)) -{ -} - -// constructor with host and service -KResolver::KResolver(const TQString& nodename, const TQString& servicename, - TQObject *parent, const char *name) - : TQObject(parent, name), d(new KResolverPrivate(this, nodename, servicename)) -{ -} - -// destructor -KResolver::~KResolver() -{ - cancel(false); - delete d; -} - -// get the status -int KResolver::status() const -{ - return d->status; -} - -// get the error code -int KResolver::error() const -{ - return d->errorcode; -} - -// get the errno -int KResolver::systemError() const -{ - return d->syserror; -} - -// are we running? -bool KResolver::isRunning() const -{ - return d->status > 0 && d->status < Success; -} - -// get the hostname -TQString KResolver::nodeName() const -{ - return d->input.node; -} - -// get the service -TQString KResolver::serviceName() const -{ - return d->input.service; -} - -// sets the hostname -void KResolver::setNodeName(const TQString& nodename) -{ - // don't touch those values if we're working! - if (!isRunning()) - { - d->input.node = nodename; - d->status = Idle; - d->results.setAddress(nodename, d->input.service); - } -} - -// sets the service -void KResolver::setServiceName(const TQString& service) -{ - // don't change if running - if (!isRunning()) - { - d->input.service = service; - d->status = Idle; - d->results.setAddress(d->input.node, service); - } -} - -// sets the address -void KResolver::setAddress(const TQString& nodename, const TQString& service) -{ - setNodeName(nodename); - setServiceName(service); -} - -// get the flags -int KResolver::flags() const -{ - return d->input.flags; -} - -// sets the flags -int KResolver::setFlags(int flags) -{ - int oldflags = d->input.flags; - if (!isRunning()) - { - d->input.flags = flags; - d->status = Idle; - } - return oldflags; -} - -// sets the family mask -void KResolver::setFamily(int families) -{ - if (!isRunning()) - { - d->input.familyMask = families; - d->status = Idle; - } -} - -// sets the socket type -void KResolver::setSocketType(int type) -{ - if (!isRunning()) - { - d->input.socktype = type; - d->status = Idle; - } -} - -// sets the protocol -void KResolver::setProtocol(int protonum, const char *name) -{ - if (isRunning()) - return; // can't change now - - // we copy the given protocol name. If it isn't an empty string - // and the protocol number was 0, we will look it up in /etc/protocols - // we also leave the error reporting to the actual lookup routines, in - // case the given protocol name doesn't exist - - d->input.protocolName = name; - if (protonum == 0 && name != 0L && *name != '\0') - { - // must look up the protocol number - d->input.protocol = KResolver::protocolNumber(name); - } - else - d->input.protocol = protonum; - d->status = Idle; -} - -bool KResolver::start() -{ - if (!isRunning()) - { - d->results.empty(); - - // is there anything to be queued? - if (d->input.node.isEmpty() && d->input.service.isEmpty()) - { - d->status = KResolver::Success; - emitFinished(); - } - else - KResolverManager::manager()->enqueue(this, 0L); - } - - return true; -} - -bool KResolver::wait(int msec) -{ - if (!isRunning()) - { - emitFinished(); - return true; - } - - TQMutexLocker locker(&d->mutex); - - if (!isRunning()) - { - // it was running and no longer is? - // That means the manager has finished its processing and has posted - // an event for the signal to be emitted already. This means the signal - // will be emitted twice! - - emitFinished(); - return true; - } - else - { - TQTime t; - t.start(); - - while (!msec || t.elapsed() < msec) - { - // wait on the manager to broadcast completion - d->waiting = true; - if (msec) - KResolverManager::manager()->notifyWaiters.wait(&d->mutex, msec - t.elapsed()); - else - KResolverManager::manager()->notifyWaiters.wait(&d->mutex); - - // the manager has processed - // see if this object is done - if (!isRunning()) - { - // it's done - d->waiting = false; - emitFinished(); - return true; - } - } - - // if we've got here, we've timed out - d->waiting = false; - return false; - } -} - -void KResolver::cancel(bool emitSignal) -{ - KResolverManager::manager()->dequeue(this); - if (emitSignal) - emitFinished(); -} - -KResolverResults -KResolver::results() const -{ - if (!isRunning()) - return d->results; - - // return a dummy, empty result - KResolverResults r; - r.setAddress(d->input.node, d->input.service); - r.setError(d->errorcode, d->syserror); - return r; -} - -bool KResolver::event(TQEvent* e) -{ - if (static_cast<int>(e->type()) == KResolverManager::ResolutionCompleted) - { - emitFinished(); - return true; - } - - return false; -} - -void KResolver::emitFinished() -{ - if (isRunning()) - d->status = KResolver::Success; - - TQGuardedPtr<TQObject> p = this; // guard against deletion - - emit finished(d->results); - - if (p && d->deleteWhenDone) - deleteLater(); // in QObject -} - -TQString KResolver::errorString(int errorcode, int syserror) -{ - // no i18n now... - static const char * const messages[] = - { - I18N_NOOP("no error"), // NoError - I18N_NOOP("requested family not supported for this host name"), // AddrFamily - I18N_NOOP("temporary failure in name resolution"), // TryAgain - I18N_NOOP("non-recoverable failure in name resolution"), // NonRecoverable - I18N_NOOP("invalid flags"), // BadFlags - I18N_NOOP("memory allocation failure"), // Memory - I18N_NOOP("name or service not known"), // NoName - I18N_NOOP("requested family not supported"), // UnsupportedFamily - I18N_NOOP("requested service not supported for this socket type"), // UnsupportedService - I18N_NOOP("requested socket type not supported"), // UnsupportedSocketType - I18N_NOOP("unknown error"), // UnknownError - I18N_NOOP2("1: the i18n'ed system error code, from errno", - "system error: %1") // SystemError - }; - - // handle the special value - if (errorcode == Canceled) - return i18n("request was canceled"); - - if (errorcode > 0 || errorcode < SystemError) - return TQString::null; - - TQString msg = i18n(messages[-errorcode]); - if (errorcode == SystemError) - msg.arg(TQString::fromLocal8Bit(strerror(syserror))); - - return msg; -} - -KResolverResults -KResolver::resolve(const TQString& host, const TQString& service, int flags, - int families) -{ - KResolver qres(host, service, TQT_TQOBJECT(tqApp), "synchronous KResolver"); - qres.setFlags(flags); - qres.setFamily(families); - qres.start(); - qres.wait(); - return qres.results(); -} - -bool KResolver::resolveAsync(TQObject* userObj, const char *userSlot, - const TQString& host, const TQString& service, - int flags, int families) -{ - KResolver* qres = new KResolver(host, service, TQT_TQOBJECT(tqApp), "asynchronous KResolver"); - TQObject::connect(qres, TQT_SIGNAL(finished(KResolverResults)), userObj, userSlot); - qres->setFlags(flags); - qres->setFamily(families); - qres->d->deleteWhenDone = true; // this is the only difference from the example code - return qres->start(); -} - -TQStrList KResolver::protocolName(int protonum) -{ - struct protoent *pe = 0L; -#ifndef HAVE_GETPROTOBYNAME_R - TQMutexLocker locker(&getXXbyYYmutex); - - pe = getprotobynumber(protonum); - -#else - size_t buflen = 1024; - struct protoent protobuf; - char *buf; - do - { - buf = new char[buflen]; -# ifdef USE_SOLARIS // Solaris uses a 4 argument getprotobynumber_r which returns struct *protoent or NULL - if ((pe = getprotobynumber_r(protonum, &protobuf, buf, buflen)) && (errno == ERANGE)) -# else - if (getprotobynumber_r(protonum, &protobuf, buf, buflen, &pe) == ERANGE) -# endif - { - pe = 0L; - buflen += 1024; - delete [] buf; - } - else - break; - } - while (pe == 0L); -#endif - - // Do common processing - TQStrList lst(true); // use deep copies - if (pe != NULL) - { - lst.append(pe->p_name); - for (char **p = pe->p_aliases; *p; p++) - lst.append(*p); - } - -#ifdef HAVE_GETPROTOBYNAME_R - delete [] buf; -#endif - - return lst; -} - -TQStrList KResolver::protocolName(const char *protoname) -{ - struct protoent *pe = 0L; -#ifndef HAVE_GETPROTOBYNAME_R - TQMutexLocker locker(&getXXbyYYmutex); - - pe = getprotobyname(protoname); - -#else - size_t buflen = 1024; - struct protoent protobuf; - char *buf; - do - { - buf = new char[buflen]; -# ifdef USE_SOLARIS // Solaris uses a 4 argument getprotobyname_r which returns struct *protoent or NULL - if ((pe = getprotobyname_r(protoname, &protobuf, buf, buflen)) && (errno == ERANGE)) -# else - if (getprotobyname_r(protoname, &protobuf, buf, buflen, &pe) == ERANGE) -# endif - { - pe = 0L; - buflen += 1024; - delete [] buf; - } - else - break; - } - while (pe == 0L); -#endif - - // Do common processing - TQStrList lst(true); // use deep copies - if (pe != NULL) - { - lst.append(pe->p_name); - for (char **p = pe->p_aliases; *p; p++) - lst.append(*p); - } - -#ifdef HAVE_GETPROTOBYNAME_R - delete [] buf; -#endif - - return lst; -} - -int KResolver::protocolNumber(const char *protoname) -{ - struct protoent *pe = 0L; -#ifndef HAVE_GETPROTOBYNAME_R - TQMutexLocker locker(&getXXbyYYmutex); - - pe = getprotobyname(protoname); - -#else - size_t buflen = 1024; - struct protoent protobuf; - char *buf; - do - { - buf = new char[buflen]; -# ifdef USE_SOLARIS // Solaris uses a 4 argument getprotobyname_r which returns struct *protoent or NULL - if ((pe = getprotobyname_r(protoname, &protobuf, buf, buflen)) && (errno == ERANGE)) -# else - if (getprotobyname_r(protoname, &protobuf, buf, buflen, &pe) == ERANGE) -# endif - { - pe = 0L; - buflen += 1024; - delete [] buf; - } - else - break; - } - while (pe == 0L); -#endif - - // Do common processing - int protonum = -1; - if (pe != NULL) - protonum = pe->p_proto; - -#ifdef HAVE_GETPROTOBYNAME_R - delete [] buf; -#endif - - return protonum; -} - -int KResolver::servicePort(const char *servname, const char *protoname) -{ - struct servent *se = 0L; -#ifndef HAVE_GETSERVBYNAME_R - TQMutexLocker locker(&getXXbyYYmutex); - - se = getservbyname(servname, protoname); - -#else - size_t buflen = 1024; - struct servent servbuf; - char *buf; - do - { - buf = new char[buflen]; -# ifdef USE_SOLARIS // Solaris uses a 5 argument getservbyname_r which returns struct *servent or NULL - if ((se = getservbyname_r(servname, protoname, &servbuf, buf, buflen)) && (errno == ERANGE)) -# else - if (getservbyname_r(servname, protoname, &servbuf, buf, buflen, &se) == ERANGE) -# endif - { - se = 0L; - buflen += 1024; - delete [] buf; - } - else - break; - } - while (se == 0L); -#endif - - // Do common processing - int servport = -1; - if (se != NULL) - servport = ntohs(se->s_port); - -#ifdef HAVE_GETSERVBYNAME_R - delete [] buf; -#endif - - return servport; -} - -TQStrList KResolver::serviceName(const char* servname, const char *protoname) -{ - struct servent *se = 0L; -#ifndef HAVE_GETSERVBYNAME_R - TQMutexLocker locker(&getXXbyYYmutex); - - se = getservbyname(servname, protoname); - -#else - size_t buflen = 1024; - struct servent servbuf; - char *buf; - do - { - buf = new char[buflen]; -# ifdef USE_SOLARIS // Solaris uses a 5 argument getservbyname_r which returns struct *servent or NULL - if ((se = getservbyname_r(servname, protoname, &servbuf, buf, buflen)) && (errno == ERANGE)) -# else - if (getservbyname_r(servname, protoname, &servbuf, buf, buflen, &se) == ERANGE) -# endif - { - se = 0L; - buflen += 1024; - delete [] buf; - } - else - break; - } - while (se == 0L); -#endif - - // Do common processing - TQStrList lst(true); // use deep copies - if (se != NULL) - { - lst.append(se->s_name); - for (char **p = se->s_aliases; *p; p++) - lst.append(*p); - } - -#ifdef HAVE_GETSERVBYNAME_R - delete [] buf; -#endif - - return lst; -} - -TQStrList KResolver::serviceName(int port, const char *protoname) -{ - struct servent *se = 0L; -#ifndef HAVE_GETSERVBYPORT_R - TQMutexLocker locker(&getXXbyYYmutex); - - se = getservbyport(port, protoname); - -#else - size_t buflen = 1024; - struct servent servbuf; - char *buf; - do - { - buf = new char[buflen]; -# ifdef USE_SOLARIS // Solaris uses a 5 argument getservbyport_r which returns struct *servent or NULL - if ((se = getservbyport_r(port, protoname, &servbuf, buf, buflen)) && (errno == ERANGE)) -# else - if (getservbyport_r(port, protoname, &servbuf, buf, buflen, &se) == ERANGE) -# endif - { - se = 0L; - buflen += 1024; - delete [] buf; - } - else - break; - } - while (se == 0L); -#endif - - // Do common processing - TQStrList lst(true); // use deep copies - if (se != NULL) - { - lst.append(se->s_name); - for (char **p = se->s_aliases; *p; p++) - lst.append(*p); - } - -#ifdef HAVE_GETSERVBYPORT_R - delete [] buf; -#endif - - return lst; -} - -TQString KResolver::localHostName() -{ - TQCString name; - int len; - -#ifdef MAXHOSTNAMELEN - len = MAXHOSTNAMELEN; -#else - len = 256; -#endif - - while (true) - { - name.resize(len); - - if (gethostname(name.data(), len - 1) == 0) - { - // Call succeeded, but it's not guaranteed to be NUL-terminated - // Note that some systems return success even if they did truncation - name[len - 1] = '\0'; - break; - } - - // Call failed - if (errno == ENAMETOOLONG || errno == EINVAL) - len += 256; - else - { - // Oops! Unknown error! - name = TQCString(); - } - } - - if (name.isEmpty()) - return TQString::tqfromLatin1("localhost"); - - if (name.find('.') == -1) - { - // not fully qualified - // must resolve - KResolverResults results = resolve(name, "0", CanonName); - if (results.isEmpty()) - // cannot find a valid hostname! - return TQString::tqfromLatin1("localhost"); - else - return results.first().canonicalName(); - } - - return domainToUnicode(name); -} - - -// forward declaration -static TQStringList splitLabels(const TQString& tqunicodeDomain); -static TQCString ToASCII(const TQString& label); -static TQString ToUnicode(const TQString& label); - -static TQStringList *KResolver_initIdnDomains() -{ - const char *kde_use_idn = getenv("KDE_USE_IDN"); - if (!kde_use_idn) - kde_use_idn = "ac:at:br:cat:ch:cl:cn:de:dk:fi:gr:hu:info:io:is:jp:kr:li:lt:museum:org:no:se:sh:th:tm:tw:vn"; - return new TQStringList(TQStringList::split(':', TQString::tqfromLatin1(kde_use_idn).lower())); -} - -// implement the ToAscii function, as described by IDN documents -TQCString KResolver::domainToAscii(const TQString& tqunicodeDomain) -{ - if (!idnDomains) - idnDomains = KResolver_initIdnDomains(); - - TQCString retval; - // RFC 3490, section 4 describes the operation: - // 1) this is a query, so don't allow unassigned - - // 2) split the domain into individual labels, without - // separators. - TQStringList input = splitLabels(tqunicodeDomain); - - // Do we allow IDN names for this TLD? - if (input.count() && !idnDomains->contains(input[input.count()-1].lower())) - return input.join(".").lower().latin1(); // No IDN allowed for this TLD - - // 3) decide whether to enforce the STD3 rules for chars < 0x7F - // we don't enforce - - // 4) for each label, apply ToASCII - TQStringList::Iterator it = input.begin(); - const TQStringList::Iterator end = input.end(); - for ( ; it != end; ++it) - { - TQCString cs = ToASCII(*it); - if (cs.isNull()) - return TQCString(); // error! - - // no, all is Ok. - if (!retval.isEmpty()) - retval += '.'; - retval += cs; - } - - return retval; -} - -TQString KResolver::domainToUnicode(const TQCString& asciiDomain) -{ - return domainToUnicode(TQString::tqfromLatin1(asciiDomain)); -} - -// implement the ToUnicode function, as described by IDN documents -TQString KResolver::domainToUnicode(const TQString& asciiDomain) -{ - if (asciiDomain.isEmpty()) - return asciiDomain; - if (!idnDomains) - idnDomains = KResolver_initIdnDomains(); - - TQString retval; - - // draft-idn-idna-14.txt, section 4 describes the operation: - // 1) this is a query, so don't allow unassigned - // besides, input is ASCII - - // 2) split the domain into individual labels, without - // separators. - TQStringList input = splitLabels(asciiDomain); - - // Do we allow IDN names for this TLD? - if (input.count() && !idnDomains->contains(input[input.count()-1].lower())) - return asciiDomain.lower(); // No TLDs allowed - - // 3) decide whether to enforce the STD3 rules for chars < 0x7F - // we don't enforce - - // 4) for each label, apply ToUnicode - TQStringList::Iterator it; - const TQStringList::Iterator end = input.end(); - for (it = input.begin(); it != end; ++it) - { - TQString label = ToUnicode(*it).lower(); - - // ToUnicode can't fail - if (!retval.isEmpty()) - retval += '.'; - retval += label; - } - - return retval; -} - -TQString KResolver::normalizeDomain(const TQString& domain) -{ - return domainToUnicode(domainToAscii(domain)); -} - -void KResolver::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -// here follows IDN functions -// all IDN functions conform to the following documents: -// RFC 3454 - Preparation of Internationalized Strings -// RFC 3490 - Internationalizing Domain Names in Applications (IDNA) -// RFC 3491 - Nameprep: A Stringprep Profile for -// Internationalized Domain Names (IDN -// RFC 3492 - Punycode: A Bootstring encoding of Unicode -// for Internationalized Domain Names in Applications (IDNA) - -static TQStringList splitLabels(const TQString& tqunicodeDomain) -{ - // From RFC 3490 section 3.1: - // "Whenever dots are used as label separators, the following characters - // MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full - // stop), U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full - // stop)." - static const unsigned int separators[] = { 0x002E, 0x3002, 0xFF0E, 0xFF61 }; - - TQStringList lst; - int start = 0; - uint i; - for (i = 0; i < tqunicodeDomain.length(); i++) - { - unsigned int c = tqunicodeDomain[i].tqunicode(); - - if (c == separators[0] || - c == separators[1] || - c == separators[2] || - c == separators[3]) - { - // found a separator! - lst << tqunicodeDomain.mid(start, i - start); - start = i + 1; - } - } - if ((long)i >= start) - // there is still one left - lst << tqunicodeDomain.mid(start, i - start); - - return lst; -} - -static TQCString ToASCII(const TQString& label) -{ -#ifdef HAVE_IDNA_H - // We have idna.h, so we can use the idna_to_ascii - // function :) - - if (label.length() > 64) - return (char*)0L; // invalid label - - if (label.length() == 0) - // this is allowed - return TQCString(""); // empty, not null - - TQCString retval; - char buf[65]; - - TQ_UINT32* ucs4 = new TQ_UINT32[label.length() + 1]; - - uint i; - for (i = 0; i < label.length(); i++) - ucs4[i] = (unsigned long)label[i].tqunicode(); - ucs4[i] = 0; // terminate with NUL, just to be on the safe side - - if (idna_to_ascii_4i(ucs4, label.length(), buf, 0) == IDNA_SUCCESS) - // success! - retval = buf; - - delete [] ucs4; - return retval; -#else - return label.latin1(); -#endif -} - -static TQString ToUnicode(const TQString& label) -{ -#ifdef HAVE_IDNA_H - // We have idna.h, so we can use the idna_to_tqunicode - // function :) - - TQ_UINT32 *ucs4_input, *ucs4_output; - size_t outlen; - - ucs4_input = new TQ_UINT32[label.length() + 1]; - for (uint i = 0; i < label.length(); i++) - ucs4_input[i] = (unsigned long)label[i].tqunicode(); - - // try the same length for output - ucs4_output = new TQ_UINT32[outlen = label.length()]; - - idna_to_unicode_44i(ucs4_input, label.length(), - ucs4_output, &outlen, - 0); - - if (outlen > label.length()) - { - // it must have failed - delete [] ucs4_output; - ucs4_output = new TQ_UINT32[outlen]; - - idna_to_unicode_44i(ucs4_input, label.length(), - ucs4_output, &outlen, - 0); - } - - // now set the answer - TQString result; - result.setLength(outlen); - for (uint i = 0; i < outlen; i++) - result[i] = (unsigned int)ucs4_output[i]; - - delete [] ucs4_input; - delete [] ucs4_output; - - return result; -#else - return label; -#endif -} - -#include "kresolver.moc" diff --git a/kdecore/network/kresolver.h b/kdecore/network/kresolver.h deleted file mode 100644 index 069428904..000000000 --- a/kdecore/network/kresolver.h +++ /dev/null @@ -1,946 +0,0 @@ -/* -*- mode: C++; coding: utf-8; -*- - * Copyright (C) 2003,2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KRESOLVER_H -#define KRESOLVER_H - -////////////////// -// Needed includes -#include <tqvaluelist.h> -#include <tqobject.h> -#include "ksocketaddress.h" - - -//////////////////////// -// Forward declarations -struct sockaddr; -class TQString; -class TQCString; -class TQStrList; - -////////////////// -// Our definitions - -namespace KNetwork { - - namespace Internal { class KResolverManager; } - -class KResolverEntryPrivate; -/** @class KResolverEntry kresolver.h kresolver.h - * @brief One resolution entry. - * - * This class is one element in the resolution results list. - * It contains the socket address for connecting, as well as - * a bit more of information: the socket type, address family - * and protocol numbers. - * - * This class contains all the information required for creating, - * binding and connecting a socket. - * - * KResolverEntry objects implicitly share data, so copying them - * is quite efficient. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KResolverEntry -{ -public: - /** - * Default constructor - * - */ - KResolverEntry(); - - /** - * Constructs a new KResolverEntry from a KSocketAddress - * and other data. - * - * The KSocketAddress @p addr parameter will be deep-copied. - * - * @param addr the address that was resolved - * @param socktype the socket type of the resolved address - * @param protocol the protocol of the resolved address - * @param canonName the canonical name of the resolved hostname - * @param encodedName the ASCII-compatible encoding of the hostname - */ - KResolverEntry(const KSocketAddress& addr, int socktype, int protocol, - const TQString& canonName = TQString::null, - const TQCString& encodedName = TQCString()); - - /** - * Constructs a new KResolverEntry from raw forms of - * socket addresses and other data. - * - * This constructor instead creates an internal KSocketAddress object. - * - * @param sa the sockaddr structure containing the raw address - * @param salen the length of the sockaddr structure - * @param socktype the socket type of the resolved address - * @param protocol the protocol of the resolved address - * @param canonName the canonical name of the resolved hostname - * @param encodedName the ASCII-compatible encoding of the hostname - */ - KResolverEntry(const struct sockaddr *sa, TQ_UINT16 salen, int socktype, - int protocol, const TQString& canonName = TQString::null, - const TQCString& encodedName = TQCString()); - - /** - * Copy constructor. - * - * This constructor performs a shallow-copy of the other object. - */ - KResolverEntry(const KResolverEntry &other); - - /** - * Destructor. - * - * The destructor frees associated resources with this object. It does - * not destroy shared data. - */ - ~KResolverEntry(); - - /** - * Retrieves the socket address associated with this entry. - */ - KSocketAddress address() const; - - /** - * Retrieves the length of the socket address structure. - */ - TQ_UINT16 length() const; - - /** - * Retrieves the family associated with this socket address. - */ - int family() const; - - /** - * Retrieves the canonical name associated with this entry, if there is any. - * If the canonical name was not found, this function returns TQString::null. - */ - TQString canonicalName() const; - - /** - * Retrieves the encoded domain name associated with this entry, if there is - * any. If this domain has been resolved through DNS, this will be the - * the ACE-encoded hostname. - * - * Returns a null TQCString if such information is not available. - * - * Please note that this information is NOT to be presented to the user, - * unless requested. - */ - TQCString encodedName() const; - - /** - * Retrieves the socket type associated with this entry. - */ - int socketType() const; - - /** - * Retrieves the protocol associated with this entry. - */ - int protocol() const; - - /** - * Assignment operator - * - * This function copies the contents of the other object into this one. - * Data will be shared between the two of them. - */ - KResolverEntry& operator=(const KResolverEntry& other); - -private: - KResolverEntryPrivate* d; -}; - -class KResolverResultsPrivate; -/** - * @class KResolverResults kresolver.h kresolver.h - * @brief Name and service resolution results. - * - * This object contains the results of a name and service resolution, as - * those performed by @ref KResolver. It is also a descendant of TQValueList, so - * you may use all its member functions here to access the elements. - * - * A KResolverResults object is associated with a resolution, so, in addition - * to the resolved elements, you can also retrieve information about the - * resolution process itself, like the nodename that was resolved or an error - * code. - * - * Note Resolver also uses KResolverResults objects to indicate failure, so - * you should test for failure. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KResolverResults: public TQValueList<KResolverEntry> -{ -public: - /** - * Default constructor. - * - * Constructs an empty list. - */ - KResolverResults(); - - /** - * Copy constructor - * - * Creates a new object with the contents of the other one. Data will be - * shared by the two objects, like QValueList - */ - KResolverResults(const KResolverResults& other); - - /** - * Destructor - * - * Destroys the object and frees associated resources. - */ - virtual ~KResolverResults(); - - /** - * Assignment operator - * - * Copies the contents of the other container into this one, discarding - * our current values. - */ - KResolverResults& operator=(const KResolverResults& other); - - /** - * Retrieves the error code associated with this resolution. The values - * here are the same as in @ref KResolver::ErrorCodes. - */ - int error() const; - - /** - * Retrieves the system error code, if any. - * @see KResolver::systemError for more information - */ - int systemError() const; - - /** - * Sets the error codes - * - * @param errorcode the error code in @ref KResolver::ErrorCodes - * @param systemerror the system error code associated, if any - */ - void setError(int errorcode, int systemerror = 0); - - /** - * The nodename to which the resolution was performed. - */ - TQString nodeName() const; - - /** - * The service name to which the resolution was performed. - */ - TQString serviceName() const; - - /** - * Sets the new nodename and service name - */ - void setAddress(const TQString& host, const TQString& service); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - KResolverResultsPrivate* d; -}; - -class KResolverPrivate; -/** - * @class KResolver kresolver.h kresolver.h - * @brief Name and service resolution class. - * - * This class provides support for doing name-to-binary resolution - * for nodenames and service ports. You should use this class if you - * need specific resolution techniques when creating a socket or if you - * want to inspect the results before calling the socket functions. - * - * You can either create an object and set the options you want in it - * or you can simply call the static member functions, which will create - * standard Resolver objects and dispatch the resolution for you. Normally, - * the static functions will be used, except in cases where specific options - * must be set. - * - * A Resolver object defaults to the following: - * @li address family: any address family - * @li socket type: streaming socket - * @li protocol: implementation-defined. Generally, TCP - * @li host and service: unset - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KResolver: public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - - /** - * Address family selection types - * - * These values can be OR-ed together to form a composite family selection. - * - * @li UnknownFamily: a family that is unknown to the current implementation - * @li KnownFamily: a family that is known to the implementation (the exact - * opposite of UnknownFamily) - * @li AnyFamilies: any address family is acceptable - * @li InternetFamily: an address for connecting to the Internet - * @li InetFamily: alias for InternetFamily - * @li IPv6Family: an IPv6 address only - * @li IPv4Family: an IPv4 address only - * @li UnixFamily: an address for the local Unix namespace (i.e., Unix sockets) - * @li LocalFamily: alias for UnixFamily - */ - enum SocketFamilies - { - UnknownFamily = 0x0001, - - UnixFamily = 0x0002, - LocalFamily = UnixFamily, - - IPv4Family = 0x0004, - IPv6Family = 0x0008, - InternetFamily = IPv4Family | IPv6Family, - InetFamily = InternetFamily, - - KnownFamily = ~UnknownFamily, - AnyFamily = KnownFamily | UnknownFamily - }; - - /** - * Flags for the resolution. - * - * These flags are used for setting the resolution behaviour for this - * object: - * @li Passive: resolve to a passive socket (i.e., one that can be used for - * binding to a local interface) - * @li CanonName: request that the canonical name for the given nodename - * be found and recorded - * @li NoResolve: request that no external resolution be performed. The given - * nodename and servicename will be resolved locally only. - * @li NoSrv: don't try to use SRV-based name-resolution. (deprecated) - * @li UseSrv: use SRV-based name resolution. - * @li Multiport: the port/service argument is a list of port numbers and - * ranges. (future extension) - * - * @note SRV-based lookup and Multiport are not implemented yet. - */ - enum Flags - { - Passive = 0x01, - CanonName = 0x02, - NoResolve = 0x04, - NoSrv = 0x08, - Multiport = 0x10, - UseSrv = 0x20 - }; - - /** - * Error codes - * - * These are the possible error values that objects of this class - * may return. See \ref errorString() for getting a string representation - * for these errors. - * - * @li AddrFamily: Address family for the given nodename is not supported. - * @li TryAgain: Temporary failure in name resolution. You should try again. - * @li NonRecoverable: Non-recoverable failure in name resolution. - * @li BadFlags: Invalid flags were given. - * @li Memory: Memory allocation failure. - * @li NoName: The specified name or service doesn't exist. - * @li UnsupportedFamily: The requested socket family is not supported. - * @li UnsupportedService: The requested service is not supported for this - * socket type (i.e., a datagram service in a streaming socket). - * @li UnsupportedSocketType: The requested socket type is not supported. - * @li UnknownError: An unknown, unexpected error occurred. - * @li SystemError: A system error occurred. See @ref systemError. - * @li Canceled: This request was cancelled by the user. - */ - enum ErrorCodes - { - // note: if you change this enum, take a look at KResolver::errorString - NoError = 0, - AddrFamily = -1, - TryAgain = -2, - NonRecoverable = -3, - BadFlags = -4, - Memory = -5, - NoName = -6, - UnsupportedFamily = -7, - UnsupportedService = -8, - UnsupportedSocketType = -9, - UnknownError = -10, - SystemError = -11, - Canceled = -100 - }; - - /** - * Status codes. - * - * These are the possible status for a Resolver object. A value - * greater than zero indicates normal behaviour, while negative - * values either indicate failure or error. - * - * @li Idle: resolution has not yet been started. - * @li Queued: resolution is queued but not yet in progress. - * @li InProgress: resolution is in progress. - * @li PostProcessing: resolution is in progress. - * @li Success: resolution is done; you can retrieve the results. - * @li Canceled: request cancelled by the user. - * @li Failed: resolution is done, but failed. - * - * Note: the status Canceled and the error code Canceled are the same. - * - * Note 2: the status Queued and InProgress might not be distinguishable. - * Some implementations might not differentiate one from the other. - */ - enum StatusCodes - { - Idle = 0, - Queued = 1, - InProgress = 5, - PostProcessing = 6, - Success = 10, - //Canceled = -100, // already defined above - Failed = -101 - }; - - /** - * Default constructor. - * - * Creates an empty Resolver object. You should set the wanted - * names and flags using the member functions before starting - * the name resolution. - */ - KResolver(TQObject * = 0L, const char * = 0L); - - /** - * Constructor with host and service names. - * - * Creates a Resolver object with the given host and - * service names. Flags are initialised to 0 and any address family - * will be accepted. - * - * @param nodename The host name we want resolved. - * @param servicename The service name associated, like "http". - */ - KResolver(const TQString& nodename, const TQString& servicename = TQString::null, - TQObject * = 0L, const char * = 0L); - - /** - * Destructor. - * - * When this object is deleted, it'll destroy all associated - * resources. If the resolution is still in progress, it will be - * cancelled and the signal will \b not be emitted. - */ - virtual ~KResolver(); - - /** - * Retrieve the current status of this object. - * - * @see StatusCodes for the possible status codes. - */ - int status() const; - - /** - * Retrieve the error code in this object. - * - * This function will return NoError if we are not in - * an error condition. See @ref status and @ref StatusCodes to - * find out what the current status is. - * - * @see errorString for getting a textual representation of - * this error - */ - int error() const; - - /** - * Retrieve the associated system error code in this object. - * - * Many resolution operations may generate an extra error code - * as given by the C errno variable. That value is stored in the - * object and can be retrieved by this function. - */ - int systemError() const; - - /** - * Returns the textual representation of the error in this object. - */ - inline TQString errorString() const - { return errorString(error(), systemError()); } - - /** - * Returns true if this object is currently running - */ - bool isRunning() const; - - /** - * The nodename to which the resolution was/is to be performed. - */ - TQString nodeName() const; - - /** - * The service name to which the resolution was/is to be performed. - */ - TQString serviceName() const; - - /** - * Sets the nodename for the resolution. - * - * Set the nodename to TQString::null to unset it. - * @param nodename The nodename to be resolved. - */ - void setNodeName(const TQString& nodename); - - /** - * Sets the service name to be resolved. - * - * Set it to TQString::null to unset it. - * @param service The service to be resolved. - */ - void setServiceName(const TQString& service); - - /** - * Sets both the host and the service names. - * - * Setting either value to TQString::null will unset them. - * @param node The nodename - * @param service The service name - */ - void setAddress(const TQString& node, const TQString& service); - - /** - * Retrieves the flags set for the resolution. - * - * @see Flags for an explanation on what flags are possible - */ - int flags() const; - - /** - * Sets the flags. - * - * @param flags the new flags - * @return the old flags - * @see Flags for an explanation on the flags - */ - int setFlags(int flags); - - /** - * Sets the allowed socket families. - * - * @param families the families that we want/accept - * @see SocketFamilies for possible values - */ - void setFamily(int families); - - /** - * Sets the socket type we want. - * - * The values for the @p type parameter are the SOCK_* - * constants, defined in <sys/socket.h>. The most common - * values are: - * @li SOCK_STREAM streaming socket (= reliable, sequenced, - * connection-based) - * @li SOCK_DGRAM datagram socket (= unreliable, connectionless) - * @li SOCK_RAW raw socket, with direct access to the - * container protocol (such as IP) - * - * These three are the only values to which it is guaranteed that - * resolution will work. Some systems may define other constants (such as - * SOCK_RDM for reliable datagrams), but support is implementation-defined. - * - * @param type the wanted socket type (SOCK_* constants). Set - * 0 to use the default. - */ - void setSocketType(int type); - - /** - * Sets the protocol we want. - * - * Protocols are dependant on the selected address family, so you should know - * what you are doing if you use this function. Besides, protocols generally - * are either stream-based or datagram-based, so the value of the socket - * type is also important. The resolution will fail if these values don't match. - * - * When using an Internet socket, the values for the protocol are the - * IPPROTO_* constants, defined in <netinet/in.h>. - * - * You may choose to set the protocol either by its number or by its name, or - * by both. If you set: - * @li the number and the name: both values will be stored internally; you - * may set the name to an empty value, if wanted - * @li the number only (name = NULL): the name will be searched in the - * protocols database - * @li the name only (number = 0): the number will be searched in the - * database - * @li neither name nor number: reset to default behaviour - * - * @param protonum the protocol number we want - * @param name the protocol name - */ - void setProtocol(int protonum, const char *name = 0L); - - /** - * Starts the name resolution asynchronously. - * - * This function will queue this object for resolution - * and will return immediately. The status upon exit will either be - * Queued or InProgress or Failed. - * - * This function does nothing if the object is already queued. But if - * it had already succeeded or failed, this function will re-start it. - * - * Note: if both the nodename and the servicename are unset, this function - * will not queue, but will set a success state and emit the signal. Also - * note that in this case and maybe others, the signal @ref finished might - * be emitted before this function returns. - * - * @return true if this request was successfully queued for asynchronous - * resolution - */ - bool start(); - - /** - * Waits for a request to finish resolving. - * - * This function will wait on a running request for its termination. The - * status upon exit will either be Success or Failed or Canceled. - * - * This function may be called from any thread, even one that is not the - * GUI thread or the one that started the resolution process. But note this - * function is not thread-safe nor reentrant: i.e., only one thread can be - * waiting on one given object. - * - * Also note that this function ensures that the @ref finished signal is - * emitted before it returns. That means that, as a side-effect, whenever - * wait() is called, the signal is emitted on the thread calling wait(). - * - * @param msec the time to wait, in milliseconds or 0 to - * wait forever - * @return true if the resolution has finished processing, even when it - * failed or was canceled. False means the wait timed out and - * the resolution is still running. - */ - bool wait(int msec = 0); - - /** - * Cancels a running request - * - * This function will cancel a running request. If the request is not - * currently running or queued, this function does nothing. - * - * Note: if you tell the signal to be emitted, be aware that it might - * or might not be emitted before this function returns. - * - * @param emitSignal whether to emit the @ref finished signal or not - */ - void cancel(bool emitSignal = true); - - /** - * Retrieves the results of this resolution - * - * Use this function to retrieve the results of the resolution. If no - * data was resolved (yet) or if we failed, this function will return - * an empty object. - * - * @return the resolved data - * @see status for information on finding out if the resolution was successful - */ - KResolverResults results() const; - - /** - * Handles events. Reimplemented from TQObject. - * - * This function handles the events generated by the manager indicating that - * this object has finished processing. - * - * Do not post events to this object. - */ - virtual bool event(TQEvent*); - -signals: - // signals - - /** - * This signal is emitted whenever the resolution is finished, one - * way or another (success or failure). The @p results parameter - * will contain the resolved data. - * - * Note: if you are doing multiple resolutions, you can use the - * TQObject::sender() function to distinguish one Resolver object from - * another. - * - * @param results the resolved data; might be empty if the resolution - * failed - * @see results for information on what the results are - * - * @note This signal is @b always delivered in the GUI event thread, even for - * resolutions that were started in secondary threads. - */ - void finished(KResolverResults results); - -private: - void emitFinished(); - -public: - // Static functions - - /** - * Returns the string representation of this error code. - * - * @param errorcode the error code. See @ref ErrorCodes. - * @param syserror the system error code associated. - * @return the string representation. This is already - * i18n'ed. - */ - static TQString errorString(int errorcode, int syserror = 0); - - /** - * Resolve the nodename and service name synchronously - * - * This static function is provided as convenience for simplifying - * name resolution. It resolves the given host and service names synchronously - * and returns the results it found. It is equivalent to the following code: - * - * \code - * KResolver qres(host, service); - * qres.setFlags(flags); - * qres.setFamily(families) - * qres.start(); - * qres.wait(); - * return qres.results(); - * \endcode - * - * @param host the nodename to resolve - * @param service the service to resolve - * @param flags flags to be used - * @param families the families to be searched - * @return a KResolverResults object containing the results - * @see KResolverResults for information on how to obtain the error code - */ - static KResolverResults resolve(const TQString& host, const TQString& service, - int flags = 0, int families = KResolver::InternetFamily); - - /** - * Start an asynchronous name resolution - * - * This function is provided as a convenience to simplify the resolution - * process. It creates an internal KResolver object, connects the - * @ref finished signal to the given slot and starts the resolution - * asynchronously. It is more or less equivalent to the following code: - * - * \b Note: this function may trigger the signal before it returns, so - * your code must be prepared for this situation. - * - * \code - * KResolver* qres = new KResolver(host, service); - * TQObject::connect(qres, TQT_SIGNAL(finished(KResolverResults)), - * userObj, userSlot); - * qres->setFlags(flags); - * qres->setFamily(families); - * return qres->start(); - * \endcode - * - * You should use it like this in your code: - * \code - * KResolver::resolveAsync(myObj, TQT_SLOT(mySlot(KResolverResults)), host, service); - * \endcode - * - * @param userObj the object whose slot @p userSlot we will connect - * @param userSlot the slot to which we'll connect - * @param host the nodename to resolve - * @param service the service to resolve - * @param flags flags to be used - * @param families families to be searcheed - * @return true if the queueing was successful, false if not - * @see KResolverResults for information on how to obtain the error code - */ - static bool resolveAsync(TQObject* userObj, const char *userSlot, - const TQString& host, const TQString& service, - int flags = 0, int families = KResolver::InternetFamily); - - /** - * Returns the domain name in an ASCII Compatible Encoding form, suitable - * for DNS lookups. This is the base for International Domain Name support - * over the Internet. - * - * Note this function may fail, in which case it'll return a null - * TQCString. Reasons for failure include use of unknown code - * points (Unicode characters). - * - * Note that the encoding is illegible and, thus, should not be presented - * to the user, except if requested. - * - * @param tqunicodeDomain the domain name to be encoded - * @return the ACE-encoded suitable for DNS queries if successful, a null - * TQCString if failure. - */ - static TQCString domainToAscii(const TQString& tqunicodeDomain); - - /** - * Does the inverse of @ref domainToAscii and return an Unicode domain - * name from the given ACE-encoded domain. - * - * This function may fail if the given domain cannot be successfully - * converted back to Unicode. Reasons for failure include a malformed - * domain name or good ones whose reencoding back to ACE don't match - * the form given here (e.g., ACE-encoding of an already - * ASCII-compatible domain). - * - * It is, however, guaranteed that domains returned - * by @ref domainToAscii will work. - * - * @param asciiDomain the ACE-encoded domain name to be decoded - * @return the Unicode representation of the given domain name - * if successful, the original string if not - * @note ACE = ASCII-Compatible Encoding, i.e., 7-bit - */ - static TQString domainToUnicode(const TQCString& asciiDomain); - - /** - * The same as above, but taking a TQString argument. - * - * @param asciiDomain the ACE-encoded domain name to be decoded - * @return the Unicode representation of the given domain name - * if successful, TQString::null if not. - */ - static TQString domainToUnicode(const TQString& asciiDomain); - - /** - * Normalise a domain name. - * - * In order to prevent simple mistakes in International Domain - * Names (IDN), it has been decided that certain code points - * (characters in Unicode) would be instead converted to others. - * This includes turning them all to lower case, as well certain - * other specific operations, as specified in the documents. - * - * For instance, the German 'ß' will be changed into 'ss', while - * the micro symbol 'µ' will be changed to the Greek mu 'μ'. - * - * Two equivalent domains have the same normalised form. And the - * normalised form of a normalised domain is itself (i.e., if - * d is normalised, the following is true: d == normalizeDomain(d) ) - * - * This operation is equivalent to encoding and the decoding a Unicode - * hostname. - * - * @param domain a domain to be normalised - * @return the normalised domain, or TQString::null if the domain is - * invalid. - */ - static TQString normalizeDomain(const TQString& domain); - - /** - * Resolves a protocol number to its names - * - * Note: the returned TQStrList operates on deep-copies. - * - * @param protonum the protocol number to be looked for - * @return all the protocol names in a list. The first is the "proper" - * name. - */ - static TQStrList protocolName(int protonum); - - /** - * Finds all aliases for a given protocol name - * - * @param protoname the protocol name to be looked for - * @return all the protocol names in a list. The first is the "proper" - * name. - */ - static TQStrList protocolName(const char *protoname); - - /** - * Resolves a protocol name to its number - * - * @param protoname the protocol name to be looked for - * @return the protocol number or -1 if we couldn't locate it - */ - static int protocolNumber(const char *protoname); - - /** - * Resolves a service name to its port number - * - * @param servname the service name to be looked for - * @param protoname the protocol it is associated with - * @return the port number in host byte-order or -1 in case of error - */ - static int servicePort(const char *servname, const char *protoname); - - /** - * Finds all the aliases for a given service name - * - * Note: the returned TQStrList operates on deep-copies. - * - * @param servname the service alias to be looked for - * @param protoname the protocol it is associated with - * @return all the service names in a list. The first is the "proper" - * name. - */ - static TQStrList serviceName(const char *servname, const char *protoname); - - /** - * Resolves a port number to its names - * - * Note: the returned TQStrList operates on deep copies. - * - * @param port the port number, in host byte-order - * @param protoname the protocol it is associated with - * @return all the service names in a list. The first is the "proper" - * name. - */ - static TQStrList serviceName(int port, const char *protoname); - - /** - * Returns this machine's local hostname. - * - * @return this machine's local hostname - * @since 3.5 - */ - static TQString localHostName(); - -protected: - - /** - * Sets the error codes - */ - void setError(int errorcode, int systemerror = 0); - - virtual void virtual_hook( int id, void* data ); -private: - KResolverPrivate* d; - friend class KResolverResults; - friend class ::KNetwork::Internal::KResolverManager; - - static TQStringList *idnDomains; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kresolver_p.h b/kdecore/network/kresolver_p.h deleted file mode 100644 index 7f74c6fe6..000000000 --- a/kdecore/network/kresolver_p.h +++ /dev/null @@ -1,353 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003-2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KRESOLVER_P_H -#define KRESOLVER_P_H - -#include <config.h> -#include <sys/types.h> - -#include <tqstring.h> -#include <tqcstring.h> -#include <tqvaluelist.h> -#include <tqptrlist.h> -#include <tqptrqueue.h> -#include <tqthread.h> -#include <tqmutex.h> -#include <tqwaitcondition.h> -#include <tqsemaphore.h> -#include <tqevent.h> - -#include "kresolver.h" - -/* decide whether we need a mutex */ -#if !defined(HAVE_GETPROTOBYNAME_R) || !defined(HAVE_GETSERVBYNAME_R) || !defined(HAVE_GETHOSTBYNAME_R) || !defined(HAVE_GETSERVBYPORT_R) -# define NEED_MUTEX -extern TQMutex getXXbyYYmutex; -#endif - -/* some systems have the functions, but don't declare them */ -#if defined(HAVE_GETSERVBYNAME_R) && !HAVE_DECL_GETSERVBYNAME_R -extern "C" { - struct servent; - extern int getservbyname_r(const char* serv, const char* proto, - struct servent* servbuf, - char* buf, size_t buflen, - struct servent** result); - extern int getservbyport_r(int port, const char* proto, - struct servent* servbuf, - char* buf, size_t buflen, - struct servent** result); - - struct protoent; - extern int getprotobyname_r(const char* proto, struct protoent* protobuf, - char *buf, size_t buflen, - struct protoent** result); - extern int getprotobynumber_r(int proto, struct protoent* protobuf, - char *buf, size_t buflen, - struct protoent** result); -} -#endif - -/* decide whether res_init is thread-safe or not */ -#if defined(__GLIBC__) -# undef RES_INIT_THREADSAFE -#endif - -namespace KNetwork -{ - // defined in network/qresolverworkerbase.h - class KResolverWorkerBase; - class KResolverWorkerFactoryBase; - class KResolverPrivate; - - namespace Internal - { - class KResolverManager; - class KResolverThread; - struct RequestData; - - struct InputData - { - TQString node, service; - TQCString protocolName; - int flags; - int familyMask; - int socktype; - int protocol; - }; - } - - class KResolverPrivate - { - public: - // parent class. Should never be changed! - KResolver* parent; - bool deleteWhenDone : 1; - bool waiting : 1; - - // class status. Should not be changed by worker threads! - volatile int status; - volatile int errorcode, syserror; - - // input data. Should not be changed by worker threads! - Internal::InputData input; - - // mutex - TQMutex mutex; - - // output data - KResolverResults results; - - KResolverPrivate(KResolver* _parent, - const TQString& _node = TQString::null, - const TQString& _service = TQString::null) - : parent(_parent), deleteWhenDone(false), waiting(false), - status(0), errorcode(0), syserror(0) - { - input.node = _node; - input.service = _service; - input.flags = 0; - input.familyMask = KResolver::AnyFamily; - input.socktype = 0; - input.protocol = 0; - - results.setAddress(_node, _service); - } - }; - - namespace Internal - { - struct RequestData - { - // worker threads should not change values in the input data - KNetwork::KResolverPrivate *obj; - const KNetwork::Internal::InputData *input; - KNetwork::KResolverWorkerBase *worker; // worker class - RequestData *requestor; // class that requested us - - volatile int nRequests; // how many requests that we made we still have left - }; - - /* - * @internal - * This class is the resolver manager - */ - class KResolverManager - { - public: - enum EventTypes - { ResolutionCompleted = 1576 }; // arbitrary value; - - /* - * This wait condition is used to notify wait states (KResolver::wait) that - * the resolver manager has finished processing one or more objects. All - * objects in wait state will be woken up and will check if they are done. - * If they aren't, they will go back to sleeping. - */ - TQWaitCondition notifyWaiters; - - private: - /* - * This variable is used to count the number of threads that are running - */ - volatile unsigned short runningThreads; - - /* - * This variable is used to count the number of threads that are currently - * waiting for data. - */ - unsigned short availableThreads; - - /* - * This wait condition is used to notify worker threads that there is new - * data available that has to be processed. All worker threads wait on this - * waitcond for a limited amount of time. - */ - TQWaitCondition feedWorkers; - - // this mutex protects the data in this object - TQMutex mutex; - - // hold a list of all the current threads we have - TQPtrList<KResolverThread> workers; - - // hold a list of all the new requests we have - TQPtrList<RequestData> newRequests; - - // hold a list of all the requests in progress we have - TQPtrList<RequestData> currentRequests; - - // hold a list of all the workers we have - TQPtrList<KNetwork::KResolverWorkerFactoryBase> workerFactories; - - // private constructor - KResolverManager(); - - public: - static KResolverManager* manager() KDE_NO_EXPORT; // creates and returns the global manager - - // destructor - ~KResolverManager(); - - /* - * Register this thread in the pool - */ - void registerThread(KResolverThread* id); - - /* - * Unregister this thread from the pool - */ - void unregisterThread(KResolverThread* id); - - /* - * Requests new data to work on. - * - * This function should only be called from a worker thread. This function - * is thread-safe. - * - * If there is data to be worked on, this function will return it. If there is - * none, this function will return a null pointer. - */ - RequestData* requestData(KResolverThread* id, int maxWaitTime); - - /* - * Releases the resources and returns the resolved data. - * - * This function should only be called from a worker thread. It is - * thread-safe. It does not post the event to the manager. - */ - void releaseData(KResolverThread *id, RequestData* data); - - /* - * Registers a new worker class by way of its factory. - * - * This function is NOT thread-safe. - */ - void registerNewWorker(KNetwork::KResolverWorkerFactoryBase *factory); - - /* - * Enqueues new resolutions. - */ - void enqueue(KNetwork::KResolver *obj, RequestData* requestor); - - /* - * Dispatch a new request - */ - void dispatch(RequestData* data); - - /* - * Dequeues a resolution. - */ - void dequeue(KNetwork::KResolver *obj); - - /* - * Notifies the manager that the given resolution is about to - * be deleted. This function should only be called by the - * KResolver destructor. - */ - void aboutToBeDeleted(KNetwork::KResolver *obj); - - /* - * Notifies the manager that new events are ready. - */ - void newEvent(); - - /* - * This function is called by the manager to receive a new event. It operates - * on the @ref eventSemaphore semaphore, which means it will block till there - * is at least one event to go. - */ - void receiveEvent(); - - private: - /* - * finds a suitable worker for this request - */ - KNetwork::KResolverWorkerBase *findWorker(KNetwork::KResolverPrivate *p); - - /* - * finds data for this request - */ - RequestData* findData(KResolverThread*); - - /* - * Handle completed requests. - * - * This function is called by releaseData above - */ - void handleFinished(); - - /* - * Handle one completed request. - * - * This function is called by handleFinished above. - */ - bool handleFinishedItem(RequestData* item); - - /* - * Notifies the parent class that this request is done. - * - * This function deletes the request - */ - void doNotifying(RequestData *p); - - /* - * Dequeues and notifies an object that is in Queued state - * Returns true if the object is no longer queued; false if it could not - * be dequeued (i.e., it's running) - */ - bool dequeueNew(KNetwork::KResolver* obj); - }; - - /* - * @internal - * This class is a worker thread in the resolver system. - * This class must be thread-safe. - */ - class KResolverThread: public TQThread - { - private: - // private constructor. Only the manager can create worker threads - KResolverThread(); - RequestData* data; - - protected: - virtual void run(); // here the thread starts - - friend class KNetwork::Internal::KResolverManager; - friend class KNetwork::KResolverWorkerBase; - - public: - bool checkResolver(); // see KResolverWorkerBase::checkResolver - void acquireResolver(); // see KResolverWorkerBase::acquireResolver - void releaseResolver(); // see KResolverWorkerBase::releaseResolver - }; - - } // namespace Internal - -} // namespace KNetwork - - -#endif diff --git a/kdecore/network/kresolvermanager.cpp b/kdecore/network/kresolvermanager.cpp deleted file mode 100644 index b3c7172ae..000000000 --- a/kdecore/network/kresolvermanager.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003-2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include "config.h" - -#include <sys/types.h> -#include <netinet/in.h> -#include <limits.h> -#include <unistd.h> // only needed for pid_t - -#ifdef HAVE_RES_INIT -# include <sys/stat.h> -extern "C" { -# include <arpa/nameser.h> -} -# include <time.h> -# include <resolv.h> -#endif - -#include <tqapplication.h> -#include <tqstring.h> -#include <tqcstring.h> -#include <tqptrlist.h> -#include <tqtimer.h> -#include <tqmutex.h> -#include <tqthread.h> -#include <tqwaitcondition.h> -#include <tqsemaphore.h> - -#include <kde_file.h> -#include <kdebug.h> -#include "kresolver.h" -#include "kresolver_p.h" -#include "kresolverworkerbase.h" - -namespace KNetwork -{ - namespace Internal - { - void initSrvWorker(); - void initStandardWorkers(); - } -} - -using namespace KNetwork; -using namespace KNetwork::Internal; - -/* - * Explanation on how the resolver system works - - When KResolver::start is called, it calls KResolverManager::enqueue to add - an entry to the queue. KResolverManager::enqueue will verify the availability - of a worker thread: if one is available, it will dispatch the request to it. - If no threads are available, it will then decide whether to launch a thread - or to queue for the future. - - (This process is achieved by always queueing the new request, starting a - new thread if necessary and then notifying of the availability of data - to all worker threads). - - * Worker thread - A new thread, when started, will enter its event loop - immediately. That is, it'll first try to acquire new data to - process, which means it will lock and unlock the manager mutex in - the process. - - If it finds no new data, it'll wait on the feedWorkers condition - for a certain maximum time. If that time expires and there's still - no data, the thread will exit, in order to save system resources. - - If it finds data, however, it'll set up and call the worker class - that has been selected by the manager. Once that worker is done, - the thread releases the data through KResolverManager::releaseData. - - * Data requesting/releasing - A worker thread always calls upon functions on the resolver manager - in order to acquire and release data. - - When data is being requested, the KResolverManager::requestData - function will look the currentRequests list and return the first - Queued request it finds, while marking it to be InProgress. - - When the worker class has returned, the worker thread will release - that data through the KResolverManager::releaseData function. If the - worker class has requested no further data (nRequests == 0), the - request's status is marked to be Done. It'll then look at the - requestor for that data: if it was requested by another worker, - it'll decrement the requests count for that one and add the results - to a list. And, finally, if the requests count for the requestor - becomes 0, it'll repeat this process for the requestor as well - (change status to Done, check for a requestor). - */ - -namespace -{ - -/* - * This class is used to control the access to the - * system's resolver API. - * - * It is necessary to periodically poll /etc/resolv.conf and reload - * it if any changes are noticed. This class does exactly that. - * - * However, there's also the problem of reloading the structure while - * some threads are in progress. Therefore, we keep a usage reference count. - */ -class ResInitUsage -{ -public: - -#ifdef HAVE_RES_INIT - time_t mTime; - int useCount; - -# ifndef RES_INIT_THREADSAFE - TQWaitCondition cond; - TQMutex mutex; -# endif - - bool shouldResInit() - { - // check if /etc/resolv.conf has changed - KDE_struct_stat st; - if (KDE_stat("/etc/resolv.conf", &st) != 0) - return false; - - if (mTime != st.st_mtime) - { - kdDebug(179) << "shouldResInit: /etc/resolv.conf updated" << endl; - return true; - } - return false; - } - - void callResInit() - { - if (mTime != 0) - { - // don't call it the first time - // let it be initialised naturally - kdDebug(179) << "callResInit: calling res_init()" << endl; - res_init(); - } - - KDE_struct_stat st; - if (KDE_stat("/etc/resolv.conf", &st) == 0) - mTime = st.st_mtime; - } - - ResInitUsage() - : mTime(0), useCount(0) - { } - - /* - * Marks the end of usage to the resolver tools - */ - void release() - { -# ifndef RES_INIT_THREADSAFE - TQMutexLocker locker(&mutex); - if (--useCount == 0) - { - if (shouldResInit()) - callResInit(); - - // we've reached 0, wake up anyone that's waiting to call res_init - cond.wakeAll(); - } -# else - // do nothing -# endif - } - - /* - * Marks the beginning of usage of the resolver API - */ - void acquire() - { -# ifndef RES_INIT_THREADSAFE - mutex.lock(); - - if (shouldResInit()) - { - if (useCount) - { - // other threads are already using the API, so wait till - // it's all clear - // the thread that emits this condition will also call res_init - //qDebug("ResInitUsage: waiting for libresolv to be clear"); - cond.wait(&mutex); - } - else - // we're clear - callResInit(); - } - useCount++; - mutex.unlock(); - -# else - if (shouldResInit()) - callResInit(); - -# endif - } - -#else - ResInitUsage() - { } - - bool shouldResInit() - { return false; } - - void acquire() - { } - - void release() - { } -#endif - -} resInit; - -} // anonymous namespace - -/* - * parameters - */ -// a thread will try maxThreadRetries to get data, waiting at most -// maxThreadWaitTime milliseconds between each attempt. After that, it'll -// exit -static const int maxThreadWaitTime = 2000; // 2 seconds -static const int maxThreads = 5; - -static pid_t pid; // FIXME -- disable when everything is ok - -KResolverThread::KResolverThread() - : data(0L) -{ -} - -// remember! This function runs in a separate thread! -void KResolverThread::run() -{ - // initialisation - // enter the loop already - - //qDebug("KResolverThread(thread %u/%p): started", pid, (void*)TQThread::currentThread()); - KResolverManager::manager()->registerThread(this); - while (true) - { - data = KResolverManager::manager()->requestData(this, ::maxThreadWaitTime); - //qDebug("KResolverThread(thread %u/%p) got data %p", KResolverManager::pid, - // (void*)TQThread::currentThread(), (void*)data); - if (data) - { - // yes, we got data - // process it! - - // 1) set up - ; - - // 2) run it - data->worker->run(); - - // 3) release data - KResolverManager::manager()->releaseData(this, data); - - // now go back to the loop - } - else - break; - } - - KResolverManager::manager()->unregisterThread(this); - //qDebug("KResolverThread(thread %u/%p): exiting", pid, (void*)TQThread::currentThread()); -} - -bool KResolverThread::checkResolver() -{ - return resInit.shouldResInit(); -} - -void KResolverThread::acquireResolver() -{ -#if defined(NEED_MUTEX) && !defined(Q_OS_FREEBSD) - getXXbyYYmutex.lock(); -#endif - - resInit.acquire(); -} - -void KResolverThread::releaseResolver() -{ -#if defined(NEED_MUTEX) && !defined(Q_OS_FREEBSD) - getXXbyYYmutex.unlock(); -#endif - - resInit.release(); -} - -static KResolverManager *globalManager; - -KResolverManager* KResolverManager::manager() -{ - if (globalManager == 0L) - new KResolverManager(); - return globalManager; -} - -KResolverManager::KResolverManager() - : runningThreads(0), availableThreads(0) -{ - globalManager = this; - workers.setAutoDelete(true); - currentRequests.setAutoDelete(true); - initSrvWorker(); - initStandardWorkers(); - - pid = getpid(); -} - -KResolverManager::~KResolverManager() -{ - // this should never be called - - // kill off running threads - for (workers.first(); workers.current(); workers.next()) - workers.current()->terminate(); -} - -void KResolverManager::registerThread(KResolverThread* ) -{ -} - -void KResolverManager::unregisterThread(KResolverThread*) -{ - runningThreads--; -} - -// this function is called by KResolverThread::run -RequestData* KResolverManager::requestData(KResolverThread *th, int maxWaitTime) -{ - ///// - // This function is called in a worker thread!! - ///// - - // lock the mutex, so that the manager thread or other threads won't - // interfere. - TQMutexLocker locker(&mutex); - RequestData *data = findData(th); - - if (data) - // it found something, that's good - return data; - - // nope, nothing found; sleep for a while - availableThreads++; - feedWorkers.wait(&mutex, maxWaitTime); - availableThreads--; - - data = findData(th); - return data; -} - -RequestData* KResolverManager::findData(KResolverThread* th) -{ - ///// - // This function is called by @ref requestData above and must - // always be called with a locked mutex - ///// - - // now find data to be processed - for (RequestData *curr = newRequests.first(); curr; curr = newRequests.next()) - if (!curr->worker->m_finished) - { - // found one - if (curr->obj) - curr->obj->status = KResolver::InProgress; - curr->worker->th = th; - - // move it to the currentRequests list - currentRequests.append(newRequests.take()); - - return curr; - } - - // found nothing! - return 0L; -} - -// this function is called by KResolverThread::run -void KResolverManager::releaseData(KResolverThread *, RequestData* data) -{ - ///// - // This function is called in a worker thread!! - ///// - - //qDebug("KResolverManager::releaseData(%u/%p): %p has been released", pid, -// (void*)TQThread::currentThread(), (void*)data); - - if (data->obj) - { - data->obj->status = KResolver::PostProcessing; - } - - data->worker->m_finished = true; - data->worker->th = 0L; // this releases the object - - // handle finished requests - handleFinished(); -} - -// this function is called by KResolverManager::releaseData above -void KResolverManager::handleFinished() -{ - bool redo = false; - TQPtrQueue<RequestData> doneRequests; - - mutex.lock(); - - // loop over all items on the currently running list - // we loop from the last to the first so that we catch requests with "requestors" before - // we catch the requestor itself. - RequestData *curr = currentRequests.last(); - while (curr) - { - if (curr->worker->th == 0L) - { - if (handleFinishedItem(curr)) - { - doneRequests.enqueue(currentRequests.take()); - if (curr->requestor && - curr->requestor->nRequests == 0 && - curr->requestor->worker->m_finished) - // there's a requestor that is now finished - redo = true; - } - } - - curr = currentRequests.prev(); - } - - //qDebug("KResolverManager::handleFinished(%u): %d requests to notify", pid, doneRequests.count()); - while (RequestData *d = doneRequests.dequeue()) - doNotifying(d); - - mutex.unlock(); - - if (redo) - { - //qDebug("KResolverManager::handleFinished(%u): restarting processing to catch requestor", - // pid); - handleFinished(); - } -} - -// This function is called by KResolverManager::handleFinished above -bool KResolverManager::handleFinishedItem(RequestData* curr) - -{ - // for all items that aren't currently running, remove from the list - // this includes all finished or cancelled requests - - if (curr->worker->m_finished && curr->nRequests == 0) - { - // this one has finished - if (curr->obj) - curr->obj->status = KResolver::PostProcessing; // post-processing is run in doNotifying() - - if (curr->requestor) - --curr->requestor->nRequests; - - //qDebug("KResolverManager::handleFinishedItem(%u): removing %p since it's done", - // pid, (void*)curr); - return true; - } - return false; -} - - - -void KResolverManager::registerNewWorker(KResolverWorkerFactoryBase *factory) -{ - workerFactories.append(factory); -} - -KResolverWorkerBase* KResolverManager::findWorker(KResolverPrivate* p) -{ - ///// - // this function can be called on any user thread - ///// - - // this function is called with an unlocked mutex and it's expected to be - // thread-safe! - // but the factory list is expected not to be changed asynchronously - - // This function is responsible for finding a suitable worker for the given - // input. That means we have to do a costly operation to create each worker - // class and call their preprocessing functions. The first one that - // says they can process (i.e., preprocess() returns true) will get the job. - - KResolverWorkerBase *worker; - for (KResolverWorkerFactoryBase *factory = workerFactories.first(); factory; - factory = workerFactories.next()) - { - worker = factory->create(); - - // set up the data the worker needs to preprocess - worker->input = &p->input; - - if (worker->preprocess()) - { - // good, this one says it can process - if (worker->m_finished) - p->status = KResolver::PostProcessing; - else - p->status = KResolver::Queued; - return worker; - } - - // no, try again - delete worker; - } - - // found no worker - return 0L; -} - -void KResolverManager::doNotifying(RequestData *p) -{ - ///// - // This function may be called on any thread - // any thread at all: user threads, GUI thread, manager thread or worker thread - ///// - - // Notification and finalisation - // - // Once a request has finished the normal processing, we call the - // post processing function. - // - // After that is done, we will consolidate all results in the object's - // KResolverResults and then post an event indicating that the signal - // be emitted - // - // In case we detect that the object is waiting for completion, we do not - // post the event, for KResolver::wait will take care of emitting the - // signal. - // - // Once we release the mutex on the object, we may no longer reference it - // for it might have been deleted. - - // "User" objects are those that are not created by the manager. Note that - // objects created by worker threads are considered "user" objects. Objects - // created by the manager are those created for KResolver::resolveAsync. - // We should delete them. - - if (p->obj) - { - // lock the object - p->obj->mutex.lock(); - KResolver* parent = p->obj->parent; // is 0 for non-"user" objects - KResolverResults& r = p->obj->results; - - if (p->obj->status == KResolver::Canceled) - { - p->obj->status = KResolver::Canceled; - p->obj->errorcode = KResolver::Canceled; - p->obj->syserror = 0; - r.setError(KResolver::Canceled, 0); - } - else if (p->worker) - { - // post processing - p->worker->postprocess(); // ignore the result - - // copy the results from the worker thread to the final - // object - r = p->worker->results; - - // reset address - r.setAddress(p->input->node, p->input->service); - - //qDebug("KResolverManager::doNotifying(%u/%p): for %p whose status is %d and has %d results", - //pid, (void*)TQThread::currentThread(), (void*)p, p->obj->status, r.count()); - - p->obj->errorcode = r.error(); - p->obj->syserror = r.systemError(); - p->obj->status = !r.isEmpty() ? - KResolver::Success : KResolver::Failed; - } - else - { - r.empty(); - r.setError(p->obj->errorcode, p->obj->syserror); - } - - // check whether there's someone waiting - if (!p->obj->waiting && parent) - // no, so we must post an event requesting that the signal be emitted - // sorry for the C-style cast, but neither static nor reintepret cast work - // here; I'd have to do two casts - TQApplication::postEvent(parent, new TQEvent((TQEvent::Type)(ResolutionCompleted))); - - // release the mutex - p->obj->mutex.unlock(); - } - else - { - // there's no object! - if (p->worker) - p->worker->postprocess(); - } - - delete p->worker; - - // ignore p->requestor and p->nRequests - // they have been dealt with by the main loop - - delete p; - - // notify any objects waiting in KResolver::wait - notifyWaiters.wakeAll(); -} - -// enqueue a new request -// this function is called from KResolver::start and -// from KResolverWorkerBase::enqueue -void KResolverManager::enqueue(KResolver *obj, RequestData *requestor) -{ - RequestData *newrequest = new RequestData; - newrequest->nRequests = 0; - newrequest->obj = obj->d; - newrequest->input = &obj->d->input; - newrequest->requestor = requestor; - - // when processing a new request, find the most - // suitable worker - if ((newrequest->worker = findWorker(obj->d)) == 0L) - { - // oops, problem - // cannot find a worker class for this guy - obj->d->status = KResolver::Failed; - obj->d->errorcode = KResolver::UnsupportedFamily; - obj->d->syserror = 0; - - doNotifying(newrequest); - return; - } - - // no, queue it - // p->status was set in findWorker! - if (requestor) - requestor->nRequests++; - - if (!newrequest->worker->m_finished) - dispatch(newrequest); - else if (newrequest->nRequests > 0) - { - mutex.lock(); - currentRequests.append(newrequest); - mutex.unlock(); - } - else - // already done - doNotifying(newrequest); -} - -// a new request has been created -// dispatch it -void KResolverManager::dispatch(RequestData *data) -{ - // As stated in the beginning of the file, this function - // is supposed to verify the availability of threads, start - // any if necessary - - TQMutexLocker locker(&mutex); - - // add to the queue - newRequests.append(data); - - // check if we need to start a new thread - // - // we depend on the variables availableThreads and runningThreads to - // know if we are supposed to start any threads: - // - if availableThreads > 0, then there is at least one thread waiting, - // blocked in KResolverManager::requestData. It can't unblock - // while we are holding the mutex locked, therefore we are sure that - // our event will be handled - // - if availableThreads == 0: - // - if runningThreads < maxThreads - // we will start a new thread, which will certainly block in - // KResolverManager::requestData because we are holding the mutex locked - // - if runningThreads == maxThreads - // This situation generally means that we have already maxThreads running - // and that all of them are processing. We will not start any new threads, - // but will instead wait for one to finish processing and request new data - // - // There's a possible race condition here, which goes unhandled: if one of - // threads has timed out waiting for new data and is in the process of - // exiting. In that case, availableThreads == 0 and runningThreads will not - // have decremented yet. This means that we will not start a new thread - // that we could have. However, since there are other threads working, our - // event should be handled soon. - // It won't be handled if and only if ALL threads are in the process of - // exiting. That situation is EXTREMELY unlikely and is not handled either. - // - if (availableThreads == 0 && runningThreads < maxThreads) - { - // yes, a new thread should be started - - // find if there's a finished one - KResolverThread *th = workers.first(); - while (th && th->running()) - th = workers.next(); - - if (th == 0L) - // no, create one - th = new KResolverThread; - else - workers.take(); - - th->start(); - workers.append(th); - runningThreads++; - } - - feedWorkers.wakeAll(); - - // clean up idle threads - workers.first(); - while (workers.current()) - { - if (!workers.current()->running()) - workers.remove(); - else - workers.next(); - } -} - -// this function is called by KResolverManager::dequeue -bool KResolverManager::dequeueNew(KResolver* obj) -{ - // This function must be called with a locked mutex - // Deadlock warning: - // always lock the global mutex first if both mutexes must be locked - - KResolverPrivate *d = obj->d; - - // check if it's in the new request list - RequestData *curr = newRequests.first(); - while (curr) - if (curr->obj == d) - { - // yes, this object is still in the list - // but it has never been processed - d->status = KResolver::Canceled; - d->errorcode = KResolver::Canceled; - d->syserror = 0; - newRequests.take(); - - delete curr->worker; - delete curr; - - return true; - } - else - curr = newRequests.next(); - - // check if it's running - curr = currentRequests.first(); - while (curr) - if (curr->obj == d) - { - // it's running. We cannot simply take it out of the list. - // it will be handled when the thread that is working on it finishes - d->mutex.lock(); - - d->status = KResolver::Canceled; - d->errorcode = KResolver::Canceled; - d->syserror = 0; - - // disengage from the running threads - curr->obj = 0L; - curr->input = 0L; - if (curr->worker) - curr->worker->input = 0L; - - d->mutex.unlock(); - } - else - curr = currentRequests.next(); - - return false; -} - -// this function is called by KResolver::cancel -// it's expected to be thread-safe -void KResolverManager::dequeue(KResolver *obj) -{ - TQMutexLocker locker(&mutex); - dequeueNew(obj); -} diff --git a/kdecore/network/kresolverstandardworkers.cpp b/kdecore/network/kresolverstandardworkers.cpp deleted file mode 100644 index 6236cc15d..000000000 --- a/kdecore/network/kresolverstandardworkers.cpp +++ /dev/null @@ -1,1028 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <netinet/in.h> -#include <netdb.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#ifdef HAVE_NET_IF_H -#include <net/if.h> -#endif - -#include <tqthread.h> -#include <tqmutex.h> -#include <tqstrlist.h> -#include <tqfile.h> - -#include "kdebug.h" -#include "kglobal.h" -#include "kstandarddirs.h" -#include "kapplication.h" - -#include "kresolver.h" -#include "ksocketaddress.h" -#include "kresolverstandardworkers_p.h" - -struct hostent; -struct addrinfo; - -using namespace KNetwork; -using namespace KNetwork::Internal; - -static bool hasIPv6() -{ -#ifndef AF_INET6 - return false; -#else - if (getenv("KDE_NO_IPV6") != 0L) - return false; - - int fd = ::socket(AF_INET6, SOCK_STREAM, 0); - if (fd == -1) - return false; - - ::close(fd); - return true; -#endif -} - -// blacklist management -static TQMutex blacklistMutex; // KDE4: change to a QReadWriteLock -TQStringList KBlacklistWorker::blacklist; - -void KBlacklistWorker::init() -{ - // HACK! - // FIXME KDE4: How do I detect there is an instance, without triggering - // its creation or an assertion fault? - if (!KGlobal::_instance) - return; - - static bool beenhere = false; - - if (beenhere) - return; - - beenhere = true; - loadBlacklist(); -} - -void KBlacklistWorker::loadBlacklist() -{ - TQMutexLocker locker(&blacklistMutex); - TQStringList filelist = KGlobal::dirs()->findAllResources("config", "ipv6blacklist"); - - TQStringList::ConstIterator it = filelist.constBegin(), - end = filelist.constEnd(); - for ( ; it != end; ++it) - { - // for each file, each line is a domainname to be blacklisted - TQFile f(*it); - if (!f.open(IO_ReadOnly)) - continue; - - TQTextStream stream(&f); - stream.setEncoding(TQTextStream::Latin1); - for (TQString line = stream.readLine(); !line.isNull(); - line = stream.readLine()) - { - if (line.isEmpty()) - continue; - - // make sure there are no surrounding whitespaces - // and that it starts with . - line = line.stripWhiteSpace(); - if (line[0] != '.') - line.prepend('.'); - - blacklist.append(line.lower()); - } - } -} - -// checks the blacklist to see if the domain is listed -// it matches the domain ending part -bool KBlacklistWorker::isBlacklisted(const TQString& host) -{ - KBlacklistWorker::init(); - - // empty hostnames cannot be blacklisted - if (host.isEmpty()) - return false; - - // KDE4: QLatin1String - TQString ascii = TQString::tqfromLatin1(KResolver::domainToAscii(host)); - - TQMutexLocker locker(&blacklistMutex); - - // now find out if this hostname is present - TQStringList::ConstIterator it = blacklist.constBegin(), - end = blacklist.constEnd(); - for ( ; it != end; ++it) - if (ascii.endsWith(*it)) - return true; - - // no match: - return false; -} - -bool KBlacklistWorker::preprocess() -{ - if (isBlacklisted(nodeName())) - { - results.setError(KResolver::NoName); - finished(); - return true; - } - return false; -} - -bool KBlacklistWorker::run() -{ - results.setError(KResolver::NoName); - finished(); - return false; // resolution failure -} - -namespace -{ - /* - * Note on the use of the system resolver functions: - * - * In all cases, we prefer to use the new getaddrinfo(3) call. That means - * it will always be used if it is found. - * - * If it's not found, we have the option to use gethostbyname2_r, - * gethostbyname_r, gethostbyname2 and gethostbyname. If gethostbyname2_r - * is defined, we will use it. - * - * If it's not defined, we have to choose between the non-reentrant - * gethostbyname2 and the reentrant but IPv4-only gethostbyname_r: - * we will choose gethostbyname2 if AF_INET6 is defined. - * - * Lastly, gethostbyname will be used if nothing else is present. - */ - -#ifndef HAVE_GETADDRINFO - -# if defined(HAVE_GETHOSTBYNAME2_R) -# define USE_GETHOSTBYNAME2_R -# elif defined(HAVE_GETHOSTBYNAME_R) && (!defined(AF_INET6) || !defined(HAVE_GETHOSTBYNAME2)) -# define USE_GETHOSTBYNAME_R -# elif defined(HAVE_GETHOSTBYNAME2) -# define USE_GETHOSTBYNAME2) -# else -# define USE_GETHOSTBYNAME -# endif - - class GetHostByNameThread: public KResolverWorkerBase - { - public: - TQCString m_hostname; // might be different! - TQ_UINT16 m_port; - int m_scopeid; - int m_af; - KResolverResults& results; - - GetHostByNameThread(const char * hostname, TQ_UINT16 port, - int scopeid, int af, KResolverResults* res) : - m_hostname(hostname), m_port(port), m_scopeid(scopeid), m_af(af), - results(*res) - { } - - ~GetHostByNameThread() - { } - - virtual bool preprocess() - { return true; } - - virtual bool run(); - - void processResults(hostent* he, int my_h_errno); - }; - - bool GetHostByNameThread::run() - { - - hostent *resultptr; - hostent my_results; - unsigned buflen = 1024; - int res; - int my_h_errno; - char *buf = 0L; - - // qDebug("ResolveThread::run(): started threaded gethostbyname for %s (af = %d)", - // m_hostname.data(), m_af); - - ResolverLocker resLock( this ); - do - { - res = 0; - my_h_errno = HOST_NOT_FOUND; - - // check blacklist - if (m_af != AF_INET && - KBlacklistWorker::isBlacklisted(TQString::tqfromLatin1(m_hostname))) - break; - -# ifdef USE_GETHOSTBYNAME2_R - buf = new char[buflen]; - res = gethostbyname2_r(m_hostname, m_af, &my_results, buf, buflen, - &resultptr, &my_h_errno); - -# elif defined(USE_GETHOSTBYNAME_R) - if (m_af == AF_INET) - { - buf = new char[buflen]; - res = gethostbyname_r(m_hostname, &my_results, buf, buflen, - &resultptr, &my_h_errno); - } - else - resultptr = 0; // signal error - -# elif defined(USE_GETHOSTBYNAME2) - // must lock mutex - resultptr = gethostbyname2(m_hostname, m_af); - my_h_errno = h_errno; - -# else - if (m_af == AF_INET) - { - // must lock mutex - resultptr = gethostbyname(m_hostname); - my_h_errno = h_errno; - } - else - resultptr = 0; -# endif - - if (resultptr != 0L) - my_h_errno = 0; - // qDebug("GetHostByNameThread::run(): gethostbyname for %s (af = %d) returned: %d", - // m_hostname.data(), m_af, my_h_errno); - - if (res == ERANGE) - { - // Enlarge the buffer - buflen += 1024; - delete [] buf; - buf = new char[buflen]; - } - - if ((res == ERANGE || my_h_errno != 0) && checkResolver()) - { - // resolver needs updating, so we might as well do it now - resLock.openClose(); - } - } - while (res == ERANGE); - processResults(resultptr, my_h_errno); - - delete [] buf; - - finished(); - return results.error() == KResolver::NoError; - } - - void GetHostByNameThread::processResults(hostent *he, int herrno) - { - if (herrno) - { - qDebug("KStandardWorker::processResults: got error %d", herrno); - switch (herrno) - { - case HOST_NOT_FOUND: - results.setError(KResolver::NoName); - return; - - case TRY_AGAIN: - results.setError(KResolver::TryAgain); - return; - - case NO_RECOVERY: - results.setError(KResolver::NonRecoverable); - return; - - case NO_ADDRESS: - results.setError(KResolver::NoName); - return; - - default: - results.setError(KResolver::UnknownError); - return; - } - } - else if (he == 0L) - { - results.setError(KResolver::NoName); - return; // this was an error - } - - // clear any errors - setError(KResolver::NoError); - results.setError(KResolver::NoError); - - // we process results in the reverse order - // that is, we prepend each result to the list of results - int proto = protocol(); - int socktype = socketType(); - if (socktype == 0) - socktype = SOCK_STREAM; // default - - TQString canon = KResolver::domainToUnicode(TQString::tqfromLatin1(he->h_name)); - KInetSocketAddress sa; - sa.setPort(m_port); - if (he->h_addrtype != AF_INET) - sa.setScopeId(m_scopeid); // this will also change the socket into IPv6 - - for (int i = 0; he->h_addr_list[i]; i++) - { - sa.setHost(KIpAddress(he->h_addr_list[i], he->h_addrtype == AF_INET ? 4 : 6)); - results.prepend(KResolverEntry(sa, socktype, proto, canon, m_hostname)); - // qDebug("KStandardWorker::processResults: adding %s", sa.toString().latin1()); - } - // qDebug("KStandardWorker::processResults: added %d entries", i); - } - -#else // HAVE_GETADDRINFO - - class GetAddrInfoThread: public KResolverWorkerBase - { - public: - TQCString m_node; - TQCString m_serv; - int m_af; - int m_flags; - KResolverResults& results; - - GetAddrInfoThread(const char* node, const char* serv, int af, int flags, - KResolverResults* res) : - m_node(node), m_serv(serv), m_af(af), m_flags(flags), results(*res) - { } - - ~GetAddrInfoThread() - { } - - virtual bool preprocess() - { return true; } - - virtual bool run(); - - void processResults(addrinfo* ai, int ret_code, KResolverResults& rr); - }; - - bool GetAddrInfoThread::run() - { - // check blacklist - if ((m_af != AF_INET && m_af != AF_UNSPEC) && - KBlacklistWorker::isBlacklisted(TQString::tqfromLatin1(m_node))) - { - results.setError(KResolver::NoName); - finished(); - return false; // failed - } - - do - { - ResolverLocker resLock( this ); - - // process hints - addrinfo hint; - memset(&hint, 0, sizeof(hint)); - hint.ai_family = m_af; - hint.ai_socktype = socketType(); - hint.ai_protocol = protocol(); - - if (hint.ai_socktype == 0) - hint.ai_socktype = SOCK_STREAM; // default - - if (m_flags & KResolver::Passive) - hint.ai_flags |= AI_PASSIVE; - if (m_flags & KResolver::CanonName) - hint.ai_flags |= AI_CANONNAME; -# ifdef AI_NUMERICHOST - if (m_flags & KResolver::NoResolve) - hint.ai_flags |= AI_NUMERICHOST; -# endif -# ifdef AI_ADDRCONFIG - hint.ai_flags |= AI_ADDRCONFIG; -# endif - - // now we do the blocking processing - if (m_node.isEmpty()) - m_node = "*"; - - addrinfo *result; - int res = getaddrinfo(m_node, m_serv, &hint, &result); - // kdDebug(179) << k_funcinfo << "getaddrinfo(\"" - // << m_node << "\", \"" << m_serv << "\", af=" - // << m_af << ") returned " << res << endl; - - if (res != 0) - { - if (checkResolver()) - { - // resolver requires reinitialisation - resLock.openClose(); - continue; - } - - switch (res) - { - case EAI_BADFLAGS: - results.setError(KResolver::BadFlags); - break; - -#ifdef EAI_NODATA - // In some systems, EAI_NODATA was #define'd to EAI_NONAME which would break this case. -#if EAI_NODATA != EAI_NONAME - case EAI_NODATA: // it was removed in RFC 3493 -#endif -#endif - case EAI_NONAME: - results.setError(KResolver::NoName); - break; - - case EAI_AGAIN: - results.setError(KResolver::TryAgain); - break; - - case EAI_FAIL: - results.setError(KResolver::NonRecoverable); - break; - - case EAI_FAMILY: - results.setError(KResolver::UnsupportedFamily); - break; - - case EAI_SOCKTYPE: - results.setError(KResolver::UnsupportedSocketType); - break; - - case EAI_SERVICE: - results.setError(KResolver::UnsupportedService); - break; - - case EAI_MEMORY: - results.setError(KResolver::Memory); - break; - - case EAI_SYSTEM: - results.setError(KResolver::SystemError, errno); - break; - - default: - results.setError(KResolver::UnknownError, errno); - break; - } - - finished(); - return false; // failed - } - - // if we are here, lookup succeeded - TQString canon; - const char *previous_canon = 0L; - - for (addrinfo* p = result; p; p = p->ai_next) - { - // cache the last canon name to avoid doing the ToUnicode processing unnecessarily - if ((previous_canon && !p->ai_canonname) || - (!previous_canon && p->ai_canonname) || - (p->ai_canonname != previous_canon && - strcmp(p->ai_canonname, previous_canon) != 0)) - { - canon = KResolver::domainToUnicode(TQString::fromAscii(p->ai_canonname)); - previous_canon = p->ai_canonname; - } - - results.append(KResolverEntry(p->ai_addr, p->ai_addrlen, p->ai_socktype, - p->ai_protocol, canon, m_node)); - } - - freeaddrinfo(result); - results.setError(KResolver::NoError); - finished(); - return results.error() == KResolver::NoError; - } - while (true); - } - -#endif // HAVE_GETADDRINFO -} // namespace - -bool KStandardWorker::sanityCheck() -{ - // check that the requested values are sensible - - if (!nodeName().isEmpty()) - { - TQString node = nodeName(); - if (node.find('%') != -1) - node.truncate(node.find('%')); - - if (node.isEmpty() || node == TQString::tqfromLatin1("*") || - node == TQString::tqfromLatin1("localhost")) - m_encodedName.truncate(0); - else - { - m_encodedName = KResolver::domainToAscii(node); - - if (m_encodedName.isNull()) - { - qDebug("could not encode hostname '%s' (UTF-8)", node.utf8().data()); - setError(KResolver::NoName); - return false; // invalid hostname! - } - - // qDebug("Using encoded hostname '%s' for '%s' (UTF-8)", m_encodedName.data(), - // node.utf8().data()); - } - } - else - m_encodedName.truncate(0); // just to be sure, but it should be clear already - - if (protocol() == -1) - { - setError(KResolver::NonRecoverable); - return false; // user passed invalid protocol name - } - - return true; // it's sane -} - -bool KStandardWorker::resolveScopeId() -{ - // we must test the original name, not the encoded one - scopeid = 0; - int pos = nodeName().findRev('%'); - if (pos == -1) - return true; - - TQString scopename = nodeName().mid(pos + 1); - - bool ok; - scopeid = scopename.toInt(&ok); - if (!ok) - { - // it's not a number - // therefore, it's an interface name -#ifdef HAVE_IF_NAMETOINDEX - scopeid = if_nametoindex(scopename.latin1()); -#else - scopeid = 0; -#endif - } - - return true; -} - -bool KStandardWorker::resolveService() -{ - // find the service first - bool ok; - port = serviceName().toUInt(&ok); - if (!ok) - { - // service name does not contain a port number - // must be a name - - if (serviceName().isEmpty() || serviceName().compare(TQString::tqfromLatin1("*")) == 0) - port = 0; - else - { - // it's a name. We need the protocol name in order to lookup. - TQCString protoname = protocolName(); - - if (protoname.isEmpty() && protocol()) - { - protoname = KResolver::protocolName(protocol()).first(); - - // if it's still empty... - if (protoname.isEmpty()) - { - // lookup failed! - setError(KResolver::NoName); - return false; - } - } - else - protoname = "tcp"; - - // it's not, so we can do a port lookup - int result = KResolver::servicePort(serviceName().latin1(), protoname); - if (result == -1) - { - // lookup failed! - setError(KResolver::NoName); - return false; - } - - // it worked, we have a port number - port = (TQ_UINT16)result; - } - } - - // we found a port - return true; -} - -KResolver::ErrorCodes KStandardWorker::addUnix() -{ - // before trying to add, see if the user wants Unix sockets - if ((familyMask() & KResolver::UnixFamily) == 0) - // no, Unix sockets are not wanted - return KResolver::UnsupportedFamily; - - // now check if the requested data are good for a Unix socket - if (!m_encodedName.isEmpty()) - return KResolver::AddrFamily; // non local hostname - - if (protocol() || !protocolName().isEmpty()) - return KResolver::BadFlags; // cannot have Unix sockets with protocols - - TQString pathname = serviceName(); - if (pathname.isEmpty()) - return KResolver::NoName;; // no path? - - if (pathname[0] != '/') - // non absolute pathname - // put it in /tmp - pathname.prepend("/tmp/"); - - // qDebug("QNoResolveWorker::addUnix(): adding Unix socket for %s", pathname.local8Bit().data()); - KUnixSocketAddress sa(pathname); - int socktype = socketType(); - if (socktype == 0) - socktype = SOCK_STREAM; // default - - results.append(KResolverEntry(sa, socktype, 0)); - setError(KResolver::NoError); - - return KResolver::NoError; -} - -bool KStandardWorker::resolveNumerically() -{ - // if the NoResolve flag is active, our result from this point forward - // will always be true, even if the resolution failed. - // that indicates that our result is authoritative. - - bool wantV4 = familyMask() & KResolver::IPv4Family, - wantV6 = familyMask() & KResolver::IPv6Family; - - if (!wantV6 && !wantV4) - // no Internet address is wanted! - return (flags() & KResolver::NoResolve); - - // now try to find results - if (!resolveScopeId() || !resolveService()) - return (flags() & KResolver::NoResolve); - - // we have scope IDs and port numbers - // now try to resolve the hostname numerically - KInetSocketAddress sa; - setError(KResolver::NoError); - sa.setHost(KIpAddress(TQString::tqfromLatin1(m_encodedName))); - - // if it failed, the length was reset to 0 - bool ok = sa.length() != 0; - - sa.setPort(port); - if (sa.ipVersion() == 6) - sa.setScopeId(scopeid); - int proto = protocol(); - int socktype = socketType(); - if (socktype == 0) - socktype = SOCK_STREAM; - - if (ok) - { - // the given hostname was successfully converted to an IP address - // check if the user wanted this kind of address - - if ((sa.ipVersion() == 4 && wantV4) || - (sa.ipVersion() == 6 && wantV6)) - results.append(KResolverEntry(sa, socktype, proto)); - else - { - // Note: the address *IS* a numeric IP - // but it's not of the kind the user asked for - // - // that means that it cannot be a Unix socket (because it's an IP) - // and that means that no resolution will tell us otherwise - // - // This is a failed resolution - - setError(KResolver::AddrFamily); - return true; - } - } - else if (m_encodedName.isEmpty()) - { - // user wanted localhost - if (flags() & KResolver::Passive) - { - if (wantV6) - { - sa.setHost(KIpAddress::anyhostV6); - results.append(KResolverEntry(sa, socktype, proto)); - } - - if (wantV4) - { - sa.setHost(KIpAddress::anyhostV4); - results.append(KResolverEntry(sa, socktype, proto)); - } - } - else - { - if (wantV6) - { - sa.setHost(KIpAddress::localhostV6); - results.append(KResolverEntry(sa, socktype, proto)); - } - - if (wantV4) - { - sa.setHost(KIpAddress::localhostV4); - results.append(KResolverEntry(sa, socktype, proto)); - } - } - - ok = true; - } - else - { - // probably bad flags, since the address is not convertible without - // resolution - - setError(KResolver::BadFlags); - ok = false; - } - - return ok || (flags() & KResolver::NoResolve); -} - -bool KStandardWorker::preprocess() -{ - // check sanity - if (!sanityCheck()) - return false; - - // this worker class can only handle known families - if (familyMask() & KResolver::UnknownFamily) - { - setError(KResolver::UnsupportedFamily); - return false; // we don't know about this - } - - // check the socket types - if (socketType() != SOCK_STREAM && socketType() != SOCK_DGRAM && socketType() != 0) - { - setError(KResolver::UnsupportedSocketType); - return false; - } - - // check if we can resolve all numerically - // resolveNumerically always returns true if the NoResolve flag is set - if (resolveNumerically() || m_encodedName.isEmpty()) - { - // indeed, we have resolved numerically - setError(addUnix()); - if (results.count()) - setError(KResolver::NoError); - finished(); - return true; - } - - // check if the user wants something we know about -#ifdef AF_INET6 -# define mask (KResolver::IPv6Family | KResolver::IPv4Family | KResolver::UnixFamily) -#else -# define mask (KResolver::IPv4Family | KResolver::UnixFamily) -#endif - - if ((familyMask() & mask) == 0) - // errr... nothing we know about - return false; - -#undef mask - - return true; // it's ok -} - -bool KStandardWorker::run() -{ -#ifndef HAVE_GETADDRINFO - // check the scope id first - // since most of the resolutions won't have a scope id, this should be fast - // and we won't have wasted time on services if this fails - if (!resolveScopeId()) - return false; - - // resolve the service now, before entering the blocking operation - if (!resolveService()) - return false; -#endif - - // good - // now we need the hostname - setError(KResolver::NoName); - - // these are the family types that we know of - struct - { - KResolver::SocketFamilies mask; - int af; - } families[] = { { KResolver::IPv4Family, AF_INET } -#ifdef AF_INET6 - , { KResolver::IPv6Family, AF_INET6 } -#endif - }; - int familyCount = sizeof(families)/sizeof(families[0]); - bool skipIPv6 = !hasIPv6(); - resultList.setAutoDelete(true); - - for (int i = 0; i < familyCount; i++) - if (familyMask() & families[i].mask) - { -#ifdef AF_INET6 - if (skipIPv6 && families[i].af == AF_INET6) - continue; -#endif - - KResolverWorkerBase *worker; - KResolverResults *res = new KResolverResults; - resultList.append(res); -#ifdef HAVE_GETADDRINFO - worker = new GetAddrInfoThread(m_encodedName, - serviceName().latin1(), - families[i].af, flags(), res); -#else - worker = new GetHostByNameThread(m_encodedName, port, scopeid, - families[i].af, res); -#endif - - enqueue(worker); - } - - // not finished - return true; -} - -bool KStandardWorker::postprocess() -{ - if (results.count()) - return true; // no need - // now copy over what we need from the underlying results - - // start backwards because IPv6 was launched later (if at all) - if (resultList.isEmpty()) - { - results.setError(KResolver::NoName); - return true; - } - - KResolverResults *rr = resultList.last(); - while (rr) - { - if (!rr->isEmpty()) - { - results.setError(KResolver::NoError); - KResolverResults::Iterator it = rr->begin(); - for ( ; it != rr->end(); ++it) - results.append(*it); - } - else if (results.isEmpty()) - // this generated an error - // copy the error code over - setError(rr->error(), rr->systemError()); - - rr = resultList.prev(); - } - - resultList.clear(); - return true; -} - -#ifdef HAVE_GETADDRINFO -KGetAddrinfoWorker::~KGetAddrinfoWorker() -{ -} - -bool KGetAddrinfoWorker::preprocess() -{ - // getaddrinfo(3) can always handle any kind of request that makes sense - if (!sanityCheck()) - return false; - - if (flags() & KResolver::NoResolve) - // oops, numeric resolution? - return run(); - - return true; -} - -bool KGetAddrinfoWorker::run() -{ - // make an AF_UNSPEC getaddrinfo(3) call - GetAddrInfoThread worker(m_encodedName, serviceName().latin1(), - AF_UNSPEC, flags(), &results); - - if (!worker.run()) - { - if (wantThis(AF_UNIX)) - { - if (addUnix() == KResolver::NoError) - setError(KResolver::NoError); - } - else - setError(worker.results.error(), worker.results.systemError()); - - return false; - } - - // The worker has finished working - // now copy over only what we may want - // keep track of any Unix-domain sockets - - bool seen_unix = false; - KResolverResults::Iterator it = results.begin(); - for ( ; it != results.end(); ) - { - if ((*it).family() == AF_UNIX) - seen_unix = true; - if (!wantThis((*it).family())) - it = results.remove(it); - else - ++it; - } - - if (!seen_unix) - addUnix(); - - finished(); - return true; -} - -bool KGetAddrinfoWorker::wantThis(int family) -{ - // tells us if the user wants a socket of this family - -#ifdef AF_INET6 - if (family == AF_INET6 && familyMask() & KResolver::IPv6Family) - return true; -#endif - if (family == AF_INET && familyMask() & KResolver::IPv4Family) - return true; - if (family == AF_UNIX && familyMask() & KResolver::UnixFamily) - return true; - - // it's not a family we know about... - if (familyMask() & KResolver::UnknownFamily) - return true; - - return false; -} - -#endif - -void KNetwork::Internal::initStandardWorkers() -{ - //KResolverWorkerFactoryBase::registerNewWorker(new KResolverWorkerFactory<KBlacklistWorker>); - KResolverWorkerFactoryBase::registerNewWorker(new KResolverWorkerFactory<KStandardWorker>); - -#ifdef HAVE_GETADDRINFO - KResolverWorkerFactoryBase::registerNewWorker(new KResolverWorkerFactory<KGetAddrinfoWorker>); -#endif -} diff --git a/kdecore/network/kresolverstandardworkers_p.h b/kdecore/network/kresolverstandardworkers_p.h deleted file mode 100644 index 2db460bef..000000000 --- a/kdecore/network/kresolverstandardworkers_p.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KRESOLVERSTANDARDWORKERS_P_H -#define KRESOLVERSTANDARDWORKERS_P_H - -#include <sys/types.h> -#include <netdb.h> - -#include <tqptrlist.h> -#include <tqcstring.h> -#include <tqstringlist.h> - -#include "kresolver.h" -#include "kresolverworkerbase.h" - -#include <config.h> - -namespace KNetwork { namespace Internal -{ - extern void initStandardWorkers() KDE_NO_EXPORT; - - /** - * @internal - * The blacklist worker. - */ - class KBlacklistWorker: public KNetwork::KResolverWorkerBase - { - public: - static TQStringList blacklist; - - static void loadBlacklist(); - static void init(); - static bool isBlacklisted(const TQString&); - - virtual bool preprocess(); - virtual bool run(); - virtual bool postprocess() { return true; } - }; - - /** @internal - * Standard worker. - */ - class KStandardWorker: public KNetwork::KResolverWorkerBase - { - protected: - mutable TQCString m_encodedName; - TQ_UINT16 port; - int scopeid; - TQPtrList<KNetwork::KResolverResults> resultList; - - public: - bool sanityCheck(); - - virtual bool preprocess(); - virtual bool run(); - virtual bool postprocess(); - - bool resolveScopeId(); - bool resolveService(); - bool resolveNumerically(); - - KNetwork::KResolver::ErrorCodes addUnix(); - }; - -#if defined(HAVE_GETADDRINFO) - /** @internal - * Worker class based on getaddrinfo(3). - * - * This class does not do post-processing. - */ - class KGetAddrinfoWorker: public KStandardWorker - { - public: - KGetAddrinfoWorker() - { } - - virtual ~KGetAddrinfoWorker(); - virtual bool preprocess(); - virtual bool run(); - virtual bool postprocess() { return true; } - - bool wantThis(int family); - }; -#endif // HAVE_GETADDRINFO - -} } // namespace KNetwork::Internal - - -#endif diff --git a/kdecore/network/kresolverworkerbase.cpp b/kdecore/network/kresolverworkerbase.cpp deleted file mode 100644 index ee6ee1011..000000000 --- a/kdecore/network/kresolverworkerbase.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include "config.h" - -#include <assert.h> - -#include <tqcstring.h> -#include <tqstring.h> - -#include "kresolver.h" -#include "kresolver_p.h" -#include "kresolverworkerbase.h" - -using namespace KNetwork; -using namespace KNetwork::Internal; - -KResolverWorkerBase::KResolverWorkerBase() - : th(0L), input(0L), m_finished(0), m_reserved(0) -{ -} - -KResolverWorkerBase::~KResolverWorkerBase() -{ -} - -TQString KResolverWorkerBase::nodeName() const -{ - if (input) - return input->node; - return TQString::null; -} - -TQString KResolverWorkerBase::serviceName() const -{ - if (input) - return input->service; - return TQString::null; -} - -int KResolverWorkerBase::flags() const -{ - if (input) - return input->flags; - return 0; -} - -int KResolverWorkerBase::familyMask() const -{ - if (input) - return input->familyMask; - return 0; -} - -int KResolverWorkerBase::socketType() const -{ - if (input) - return input->socktype; - return 0; -} - -int KResolverWorkerBase::protocol() const -{ - if (input) - return input->protocol; - return 0; -} - -TQCString KResolverWorkerBase::protocolName() const -{ - TQCString res; - if (input) - res = input->protocolName; - return res; -} - -void KResolverWorkerBase::finished() -{ - m_finished = true; -} - -bool KResolverWorkerBase::postprocess() -{ - return true; // no post-processing is a always successful postprocessing -} - -bool KResolverWorkerBase::enqueue(KResolver* res) -{ - KResolverManager::manager()->enqueue(res, th->data); - return true; -} - -bool KResolverWorkerBase::enqueue(KResolverWorkerBase* worker) -{ - RequestData *myself = th->data; - RequestData *newrequest = new RequestData; - newrequest->obj = 0; - newrequest->input = input; // same input - newrequest->requestor = myself; - newrequest->nRequests = 0; - newrequest->worker = worker; - myself->nRequests++; - KResolverManager::manager()->dispatch(newrequest); - return true; -} - -bool KResolverWorkerBase::checkResolver() -{ - return th->checkResolver(); -} - -void KResolverWorkerBase::acquireResolver() -{ - th->acquireResolver(); -} - -void KResolverWorkerBase::releaseResolver() -{ - th->releaseResolver(); -} - -void KResolverWorkerFactoryBase::registerNewWorker(KResolverWorkerFactoryBase* factory) -{ - KResolverManager::manager()->registerNewWorker(factory); -} - diff --git a/kdecore/network/kresolverworkerbase.h b/kdecore/network/kresolverworkerbase.h deleted file mode 100644 index 4dee33239..000000000 --- a/kdecore/network/kresolverworkerbase.h +++ /dev/null @@ -1,317 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KRESOLVERWORKERBASE_H -#define KRESOLVERWORKERBASE_H - -#include "kresolver.h" - -// forward declarations -class TQString; -template <class T> class TQValueList; - -namespace KNetwork { - - namespace Internal - { - class KResolverThread; - struct InputData; - } - -/** @internal - * This class is the base functionality for a resolver worker. That is, - * the class that does the actual work. - * - * In the future, this class might be exposed to allow plug-ins. So, try and - * make it binary compatible. - * - * Note that hostnames are still encoded in Unicode at this point. It's up to - * the worker class to decide which encoding to use. In the case of DNS, - * an ASCII Compatible Encoding (ACE) must be used. - * See @ref KResolver::domainToAscii. - * - * Also specially note that the run method in this class is called in a - * thread that is not the program's main thread. So do not do anything there - * that you shouldn't! - * - * @class KResolverWorkerBase kresolverworkerbase.h kresolverworkerbase.h - */ -class KResolverWorkerBase -{ -public: - - /** - * Helper class for locking the resolver subsystem. - * Similar to TQMutexLocker. - * - * @author Luís Pedro Coelho - * @since 3.4 - */ - class ResolverLocker - { - public: - /** - * Constructor. Acquires a lock. - */ - ResolverLocker(KResolverWorkerBase* parent) - : parent( parent ) - { - parent->acquireResolver(); - } - - /** - * Destructor. Releases the lock. - */ - ~ResolverLocker() - { - parent->releaseResolver(); - } - - /** - * Releases the lock and then reacquires it. - * It may be necessary to call this if the resolving function - * decides to retry. - */ - void openClose() - { - parent->releaseResolver(); - parent->acquireResolver(); - } - - private: - /// @internal - KResolverWorkerBase* parent; - }; -private: - // this will be like our d pointer - KNetwork::Internal::KResolverThread *th; - const KNetwork::Internal::InputData *input; - friend class KNetwork::Internal::KResolverThread; - friend class KNetwork::Internal::KResolverManager; - friend class KResolverWorkerBase::ResolverLocker; - - int m_finished : 1; - int m_reserved : 31; // reserved - -public: - /** - * Derived classes will put their resolved data in this list, or will - * leave it empty in case of error. - * - * Status and error codes should also be stored in this object (the - * @ref setError function does that). - */ - KResolverResults results; - -public: - // default constructor - KResolverWorkerBase(); - - // virtual destructor - virtual ~KResolverWorkerBase(); - - /** - * This is the hostname to be looked for - */ - TQString nodeName() const; - - /** - * And this is the service name - */ - TQString serviceName() const; - - /** - * gets the flags - */ - int flags() const; - - /** - * gets the family mask - */ - int familyMask() const; - - /** - * gets the socket type - */ - int socketType() const; - - /** - * gets the protocol number - */ - int protocol() const; - - /** - * gets the protocol name, if applicable - */ - TQCString protocolName() const; - - /** - * Call this function to indicate that processing - * has finished. This is useful in the preprocessing - * stage, to indicate that @ref run doesn't have to be - * called. - */ - void finished(); - -protected: - // like a QThread - /** - * This is the function that should be overriden in derived classes. - * - * Derived classes will do their blocking job in this function and return - * either success or failure to work (not the lookup). That is, whether the - * lookup result was a domain found or not, if we got our answer, we should - * indicate success. The error itself must be set with @ref setError. - * - * \b Important: this function gets called in a separate thread! - * - * @return true on success - */ - virtual bool run() = 0; - - /** - * This function gets called during pre processing for this class and you must - * override it. - * - * \b Important: this function gets called in the main event thread. And it MUST - * NOT block. - * - * This function can be used for an object to determine if it will be able - * to resolve the given data or not even before launching into a blocking - * operation. This function should return true if the object is capable of - * handling this kind of data; false otherwise. Note that the return value - * of 'true' means that the object's blocking answer will be considered authoritative. - * - * This function MUST NOT queue further requests. Leave that to @ref run. - * - * This function is pure virtual; you must override it. - * - * @return true on success - */ - virtual bool preprocess() = 0; - - /** - * This function gets called during post processing for this class. - * - * \b Important: this function gets called in the main event thread. And it MUST - * NOT block. - * - * @returns true on success - */ - virtual bool postprocess(); - - /** - * Sets the error - */ - inline void setError(int errorcode, int syserror = 0) - { results.setError(errorcode, syserror); } - - /** - * Enqueue the given resolver for post-processing. - * - * Use this function to make the manager call for another resolution. - * This is suitable for workers that do post-processing. - * - * The manager will make sure that any requests enqueued by this function - * are done before calling the postprocessing function, which you should - * override. - * - * \b Important: do use KResolver's own enqueueing functions (i.e., @ref KResolver::start). - * Instead, use this function. - * - * @returns true on successful queueing or false if a problem ocurred - */ - bool enqueue(KResolver* other); - - /** - * @overload - */ - bool enqueue(KResolverWorkerBase* worker); - - /** - * Checks the resolver subsystem status. - * @returns true if the resolver subsystem changed, false otherwise. - * If this function returns true, it might be necessary to - * restart the resolution altogether. - * @since 3.4 - */ - bool checkResolver(); - - /** - * This function has to be called from the resolver workers that require - * use of the DNS resolver code (i.e., res_* functions, generally in - * libresolv). It indicates that the function is starting a resolution - * and that the resolver backend shouldn't change asynchronously. - * - * If any pending res_init's are required, they will be performed before - * this function returns. - * - * @since 3.4 - */ - void acquireResolver(); - - /** - * This function is the counterpart for @ref acquireResolver: the worker - * thread indicates that it's done with the resolver. - * - * @since 3.4 - */ - void releaseResolver(); - -}; - -/** @internal - * This class provides functionality for creating and registering worker classes. - * - * @class KResolverWorkerFactoryBase kresolverworkerbase.h kresolverworkerbase.h - */ -class KResolverWorkerFactoryBase -{ -public: - virtual KResolverWorkerBase* create() const = 0; - - /** - * Wrapper call to register workers - * - * It is NOT thread-safe! - */ - static void registerNewWorker(KResolverWorkerFactoryBase* factory); -}; - -/** @internal - * This class provides functionality for creating and registering worker classes. - * - * @class KResolverWorkerFactory kresolverworkerbase.h kresolverworkerbase.h - */ -template<class Worker> -class KResolverWorkerFactory: public KResolverWorkerFactoryBase -{ -public: - virtual KResolverWorkerBase* create() const - { return new Worker; } -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kreverseresolver.cpp b/kdecore/network/kreverseresolver.cpp deleted file mode 100644 index 00ef7f81d..000000000 --- a/kdecore/network/kreverseresolver.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include "config.h" - -// System includes -#include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> -#include <signal.h> - -// Qt -#include <tqevent.h> -#include <tqmutex.h> -#include <tqapplication.h> - -// Us -#include "kreverseresolver.h" -#include "kresolver_p.h" -#include "kresolverworkerbase.h" -#include "ksocketaddress.h" - -#ifndef HAVE_GETNAMEINFO -// FIXME KDE4: -// move to syssocket or adapt -# include "netsupp.h" -#endif - -using namespace KNetwork; -using namespace KNetwork::Internal; - -namespace -{ - class ReverseThread: public KResolverWorkerBase - { - public: - ReverseThread(const KSocketAddress& addr, int flags) - : m_addr(addr), m_flags(flags), m_parent(0L) - { } - - virtual ~ReverseThread() - { } - - virtual bool preprocess() - { return true; } - virtual bool run(); - virtual bool postprocess(); - - // input: - KSocketAddress m_addr; - int m_flags; - KReverseResolver *m_parent; - - // output: - TQString node; - TQString service; - bool success; - }; - - class KReverseResolverEvent: public TQEvent - { - public: - static const int myType = TQEvent::User + 63; // arbitrary value - TQString node; - TQString service; - bool success; - - KReverseResolverEvent(const TQString& _node, const TQString& _service, - bool _success) - : TQEvent((Type)myType), node(_node), - service(_service), success(_success) - { } - }; -} - -class KNetwork::KReverseResolverPrivate -{ -public: - TQString node; - TQString service; - KSocketAddress addr; - int flags; - - ReverseThread* worker; - bool success; - - inline KReverseResolverPrivate(const KSocketAddress& _addr) - : addr(_addr), worker(0L), success(false) - { } -}; - -KReverseResolver::KReverseResolver(const KSocketAddress& addr, int flags, - TQObject *parent, const char* name) - : TQObject(parent, name), d(new KReverseResolverPrivate(addr)) -{ - d->flags = flags; -} - -KReverseResolver::~KReverseResolver() -{ - if (d->worker) - d->worker->m_parent = 0L; -} - -bool KReverseResolver::isRunning() const -{ - return d->worker != 0L; -} - -bool KReverseResolver::success() const -{ - return !isRunning() && d->success; -} - -bool KReverseResolver::failure() const -{ - return !isRunning() && !d->success; -} - -TQString KReverseResolver::node() const -{ - return d->node; -} - -TQString KReverseResolver::service() const -{ - return d->service; -} - -const KSocketAddress& KReverseResolver::address() const -{ - return d->addr; -} - -bool KReverseResolver::start() -{ - if (d->worker != 0L) - return true; // already started - - d->worker = new ReverseThread(d->addr, d->flags); - d->worker->m_parent = this; - - RequestData *req = new RequestData; - req->obj = 0L; - req->input = 0L; - req->requestor = 0L; - req->worker = d->worker; - KResolverManager::manager()->dispatch(req); - return true; -} - -bool KReverseResolver::event(TQEvent *e) -{ - if (e->type() != KReverseResolverEvent::myType) - return TQObject::event(e); // call parent - - KReverseResolverEvent *re = static_cast<KReverseResolverEvent*>(e); - d->node = re->node; - d->service = re->service; - d->success = re->success; - - // don't delete d->worker! - // KResolverManager::doNotifying takes care of that, if it hasn't already - d->worker = 0L; - - // emit signal - emit finished(*this); - - return true; -} - -bool KReverseResolver::resolve(const KSocketAddress& addr, TQString& node, - TQString& serv, int flags) -{ - ReverseThread th(addr, flags); - if (th.run()) - { - node = th.node; - serv = th.service; - return true; - } - return false; -} - -bool KReverseResolver::resolve(const struct sockaddr* sa, TQ_UINT16 salen, - TQString& node, TQString& serv, int flags) -{ - return resolve(KSocketAddress(sa, salen), node, serv, flags); -} - -bool ReverseThread::run() -{ - int err; - char h[NI_MAXHOST], s[NI_MAXSERV]; - int niflags = 0; - - h[0] = s[0] = '\0'; - - if (m_flags & KReverseResolver::NumericHost) - niflags |= NI_NUMERICHOST; - if (m_flags & KReverseResolver::NumericService) - niflags |= NI_NUMERICSERV; - if (m_flags & KReverseResolver::NodeNameOnly) - niflags |= NI_NOFQDN; - if (m_flags & KReverseResolver::Datagram) - niflags |= NI_DGRAM; - if (m_flags & KReverseResolver::ResolutionRequired) - niflags |= NI_NAMEREQD; - - { -#ifdef NEED_MUTEX - TQMutexLocker locker(&::getXXbyYYmutex); -#endif - err = ::getnameinfo(m_addr, m_addr.length(), - h, sizeof(h) - 1, s, sizeof(s) - 1, niflags); - } - - if (err == 0) - { - node = KResolver::domainToUnicode(TQString::tqfromLatin1(h)); - service = TQString::tqfromLatin1(s); - success = true; - } - else - { - node = service = TQString::null; - success = false; - } - - return success; -} - -bool ReverseThread::postprocess() -{ - // post an event - if (m_parent) - TQApplication::postEvent(m_parent, - new KReverseResolverEvent(node, service, success)); - return true; -} - -#include "kreverseresolver.moc" diff --git a/kdecore/network/kreverseresolver.h b/kdecore/network/kreverseresolver.h deleted file mode 100644 index 1f26f4a2a..000000000 --- a/kdecore/network/kreverseresolver.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KREVERSERESOLVER_H -#define KREVERSERESOLVER_H - -////////////////// -// Needed includes -#include <tqobject.h> -#include <tqstring.h> - -#include "ksocketaddress.h" - -namespace KNetwork { - -class KReverseResolverPrivate; -/** @class KReverseResolver kreverseresolver.h kreverseresolver.h - * @brief Run a reverse-resolution on a socket address. - * - * This class is provided as a counterpart to KResolver in such a way - * as it produces a reverse resolution: it resolves a socket address - * from its binary representations into a textual representation. - * - * Most users will use the static functions @ref resolve, which work - * both synchronously (blocking) and asynchronously (non-blocking). - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KReverseResolver: public TQObject -{ - Q_OBJECT - TQ_OBJECT - -public: - /** - * Flags for the reverse resolution. - * - * These flags are used by the reverse resolution functions for - * setting resolution parameters. The possible values are: - * @li NumericHost: don't try to resolve the host address to a text form. - * Instead, convert the address to its numeric textual representation. - * @li NumericService: the same as NumericHost, but for the service name - * @li NodeNameOnly: returns the node name only (i.e., not the Fully - * Qualified Domain Name) - * @li Datagram: in case of ambiguity in the service name, prefer the - * name associated with the datagram protocol - * @li NumericScope: for those addresses which have the concept of scope, - * resolve using the numeric value instead of the proper scope name. - * @li ResolutionRequired: normally, when resolving, if the name resolution - * fails, the process normally converts the numeric address into its - * presentation forms. This flag causes the function to return - * with error instead. - */ - enum Flags - { - NumericHost = 0x01, - NumericService = 0x02, - NodeNameOnly = 0x04, - Datagram = 0x08, - NumericScope = 0x10, - ResolutionRequired = 0x20 - }; - - /** - * Constructs this object to resolve the given socket address. - * - * @param addr the address to resolve - * @param flags the flags to use, see @ref Flags - */ - KReverseResolver(const KSocketAddress& addr, int flags = 0, - TQObject * = 0L, const char * = 0L); - - /** - * Destructor. - */ - virtual ~KReverseResolver(); - - /** - * This function returns 'true' if the processing is still running. - */ - bool isRunning() const; - - /** - * This function returns true if the processing has finished with - * success, false if it's still running or failed. - */ - bool success() const; - - /** - * This function returns true if the processing has finished with - * failure, false if it's still running or succeeded. - */ - bool failure() const; - - /** - * Returns the resolved node name, if the resolution has finished - * successfully, or TQString::null otherwise. - */ - TQString node() const; - - /** - * Returns the resolved service name, if the resolution has finished - * successfully, or TQString::null otherwise. - */ - TQString service() const; - - /** - * Returns the socket address which was subject to resolution. - */ - const KSocketAddress& address() const; - - /** - * Starts the resolution. This function returns 'true' - * if the resolution has started successfully. - */ - bool start(); - - /** - * Overrides event handling - */ - virtual bool event(TQEvent* ); - -signals: - /** - * This signal is emitted when the resolution has finished. - * - * @param obj this class, which contains the results - */ - void finished(const KReverseResolver& obj); - -public: - /** - * Resolves a socket address to its textual representation - * - * FIXME!! How can we do this in a non-blocking manner!? - * - * This function is used to resolve a socket address from its - * binary representation to a textual form, even if numeric only. - * - * @param addr the socket address to be resolved - * @param node the TQString where we will store the resolved node - * @param serv the TQString where we will store the resolved service - * @param flags flags to be used for this resolution. - * @return true if the resolution succeeded, false if not - * @see ReverseFlags for the possible values for @p flags - */ - static bool resolve(const KSocketAddress& addr, TQString& node, - TQString& serv, int flags = 0); - - /** - * Resolves a socket address to its textual representation - * - * FIXME!! How can we do this in a non-blocking manner!? - * - * This function behaves just like the above one, except it takes - * a sockaddr structure and its size as parameters. - * - * @param sa the sockaddr structure containing the address to be resolved - * @param salen the length of the sockaddr structure - * @param node the TQString where we will store the resolved node - * @param serv the TQString where we will store the resolved service - * @param flags flags to be used for this resolution. - * @return true if the resolution succeeded, false if not - * @see ReverseFlags for the possible values for @p flags - */ - static bool resolve(const struct sockaddr* sa, TQ_UINT16 salen, - TQString& node, TQString& serv, int flags = 0); - -private: - KReverseResolverPrivate* d; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/kserversocket.cpp b/kdecore/network/kserversocket.cpp deleted file mode 100644 index bd63d6306..000000000 --- a/kdecore/network/kserversocket.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <tqsocketnotifier.h> -#include <tqmutex.h> - -#include "ksocketaddress.h" -#include "kresolver.h" -#include "ksocketbase.h" -#include "ksocketdevice.h" -#include "kstreamsocket.h" -#include "kbufferedsocket.h" -#include "kserversocket.h" - -using namespace KNetwork; - -class KNetwork::KServerSocketPrivate -{ -public: - KResolver resolver; - KResolverResults resolverResults; - - enum { None, LookupDone, Bound, Listening } state; - int backlog; - int timeout; - - bool bindWhenFound : 1, listenWhenBound : 1, useKBufferedSocket : 1; - - KServerSocketPrivate() - : state(None), timeout(0), bindWhenFound(false), listenWhenBound(false), - useKBufferedSocket(true) - { - resolver.setFlags(KResolver::Passive); - resolver.setFamily(KResolver::KnownFamily); - } -}; - -KServerSocket::KServerSocket(TQObject* parent, const char *name) - : TQObject(parent, name), d(new KServerSocketPrivate) -{ - TQObject::connect(&d->resolver, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(lookupFinishedSlot())); -} - -KServerSocket::KServerSocket(const TQString& service, TQObject* parent, const char *name) - : TQObject(parent, name), d(new KServerSocketPrivate) -{ - TQObject::connect(&d->resolver, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(lookupFinishedSlot())); - d->resolver.setServiceName(service); -} - -KServerSocket::KServerSocket(const TQString& node, const TQString& service, - TQObject* parent, const char* name) - : TQObject(parent, name), d(new KServerSocketPrivate) -{ - TQObject::connect(&d->resolver, TQT_SIGNAL(finished(KResolverResults)), - this, TQT_SLOT(lookupFinishedSlot())); - setAddress(node, service); -} - -KServerSocket::~KServerSocket() -{ - close(); - delete d; -} - -bool KServerSocket::setSocketOptions(int opts) -{ - TQMutexLocker locker(mutex()); - KSocketBase::setSocketOptions(opts); // call parent - bool result = socketDevice()->setSocketOptions(opts); // and set the implementation - copyError(); - return result; -} - -KResolver& KServerSocket::resolver() const -{ - return d->resolver; -} - -const KResolverResults& KServerSocket::resolverResults() const -{ - return d->resolverResults; -} - -void KServerSocket::setResolutionEnabled(bool enable) -{ - if (enable) - d->resolver.setFlags(d->resolver.flags() & ~KResolver::NoResolve); - else - d->resolver.setFlags(d->resolver.flags() | KResolver::NoResolve); -} - -void KServerSocket::setFamily(int families) -{ - d->resolver.setFamily(families); -} - -void KServerSocket::setAddress(const TQString& service) -{ - d->resolver.setNodeName(TQString::null); - d->resolver.setServiceName(service); - d->resolverResults.empty(); - if (d->state <= KServerSocketPrivate::LookupDone) - d->state = KServerSocketPrivate::None; -} - -void KServerSocket::setAddress(const TQString& node, const TQString& service) -{ - d->resolver.setNodeName(node); - d->resolver.setServiceName(service); - d->resolverResults.empty(); - if (d->state <= KServerSocketPrivate::LookupDone) - d->state = KServerSocketPrivate::None; -} - -void KServerSocket::setTimeout(int msec) -{ - d->timeout = msec; -} - -bool KServerSocket::lookup() -{ - setError(NoError); - if (d->resolver.isRunning() && !blocking()) - return true; // already doing lookup - - if (d->state >= KServerSocketPrivate::LookupDone) - return true; // results are already available - - // make sure we have at least one parameter for lookup - if (d->resolver.serviceName().isNull() && - !d->resolver.nodeName().isNull()) - d->resolver.setServiceName(TQString::tqfromLatin1("")); - - // don't restart the lookups if they had succeeded and - // the input values weren't changed - - // reset results - d->resolverResults = KResolverResults(); - - if (d->resolver.status() <= 0) - // if it's already running, there's no harm in calling again - d->resolver.start(); // signal may emit - - if (blocking()) - { - // we're in blocking mode operation - // wait for the results - - d->resolver.wait(); // signal may be emitted again - // lookupFinishedSlot has been called - } - - return true; -} - -bool KServerSocket::bind(const KResolverEntry& address) -{ - if (socketDevice()->bind(address)) - { - setError(NoError); - - d->state = KServerSocketPrivate::Bound; - emit bound(address); - return true; - } - copyError(); - return false; -} - -bool KServerSocket::bind(const TQString& node, const TQString& service) -{ - setAddress(node, service); - return bind(); -} - -bool KServerSocket::bind(const TQString& service) -{ - setAddress(service); - return bind(); -} - -bool KServerSocket::bind() -{ - if (d->state >= KServerSocketPrivate::Bound) - return true; - - if (d->state < KServerSocketPrivate::LookupDone) - { - if (!blocking()) - { - d->bindWhenFound = true; - bool ok = lookup(); // will call doBind - if (d->state >= KServerSocketPrivate::Bound) - d->bindWhenFound = false; - return ok; - } - - // not blocking - if (!lookup()) - return false; - } - - return doBind(); -} - -bool KServerSocket::listen(int backlog) -{ - // WARNING - // this function has to be reentrant - // due to the mechanisms used for binding, this function might - // end up calling itself - - if (d->state == KServerSocketPrivate::Listening) - return true; // already listening - - d->backlog = backlog; - - if (d->state < KServerSocketPrivate::Bound) - { - // we must bind - // note that we can end up calling ourselves here - d->listenWhenBound = true; - if (!bind()) - { - d->listenWhenBound = false; - return false; - } - - if (d->state < KServerSocketPrivate::Bound) - // asynchronous lookup in progress... - // we can't be blocking here anyways - return true; - - d->listenWhenBound = false; - } - - if (d->state < KServerSocketPrivate::Listening) - return doListen(); - - return true; -} - -void KServerSocket::close() -{ - socketDevice()->close(); - if (d->resolver.isRunning()) - d->resolver.cancel(false); - d->state = KServerSocketPrivate::None; - emit closed(); -} - -void KServerSocket::setAcceptBuffered(bool enable) -{ - d->useKBufferedSocket = enable; -} - -KActiveSocketBase* KServerSocket::accept() -{ - if (d->state < KServerSocketPrivate::Listening) - { - if (!blocking()) - { - listen(); - setError(WouldBlock); - return NULL; - } - else if (!listen()) - // error happened during listen - return false; - } - - // check to see if we're doing a timeout - if (blocking() && d->timeout > 0) - { - bool timedout; - if (!socketDevice()->poll(d->timeout, &timedout)) - { - copyError(); - return NULL; - } - - if (timedout) - return 0L; - } - - // we're listening here - KSocketDevice* accepted = socketDevice()->accept(); - if (!accepted) - { - // error happened during accept - copyError(); - return NULL; - } - - KStreamSocket* streamsocket; - if (d->useKBufferedSocket) - streamsocket = new KBufferedSocket(); - else - streamsocket = new KStreamSocket(); - streamsocket->setSocketDevice(accepted); - - // FIXME! - // when KStreamSocket can find out the state of the socket passed through - // setSocketDevice, this will probably be unnecessary: - streamsocket->setState(KStreamSocket::Connected); - streamsocket->setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - - return streamsocket; -} - -KSocketAddress KServerSocket::localAddress() const -{ - return socketDevice()->localAddress(); -} - -KSocketAddress KServerSocket::externalAddress() const -{ - return socketDevice()->externalAddress(); -} - -void KServerSocket::lookupFinishedSlot() -{ - if (d->resolver.isRunning() || d->state > KServerSocketPrivate::LookupDone) - return; - - if (d->resolver.status() < 0) - { - setError(LookupFailure); - emit gotError(LookupFailure); - d->bindWhenFound = d->listenWhenBound = false; - d->state = KServerSocketPrivate::None; - return; - } - - // lookup succeeded - d->resolverResults = d->resolver.results(); - d->state = KServerSocketPrivate::LookupDone; - emit hostFound(); - - if (d->bindWhenFound) - doBind(); -} - -void KServerSocket::copyError() -{ - setError(socketDevice()->error()); -} - -bool KServerSocket::doBind() -{ - d->bindWhenFound = false; - // loop through the results and bind to the first that works - - KResolverResults::ConstIterator it = d->resolverResults.begin(); - for ( ; it != d->resolverResults.end(); ++it) - if (bind(*it)) - { - if (d->listenWhenBound) - return doListen(); - return true; - } - else - socketDevice()->close(); // didn't work, try again - - // failed to bind - emit gotError(error()); - return false; -} - -bool KServerSocket::doListen() -{ - if (!socketDevice()->listen(d->backlog)) - { - copyError(); - emit gotError(error()); - return false; // failed to listen - } - - // set up ready accept signal - TQObject::connect(socketDevice()->readNotifier(), TQT_SIGNAL(activated(int)), - this, TQT_SIGNAL(readyAccept())); - d->state = KServerSocketPrivate::Listening; - return true; -} - - -#include "kserversocket.moc" diff --git a/kdecore/network/kserversocket.h b/kdecore/network/kserversocket.h deleted file mode 100644 index a07ed54a1..000000000 --- a/kdecore/network/kserversocket.h +++ /dev/null @@ -1,436 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago@kde.org> - * - * - * 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 KSERVERSOCKET_H -#define KSERVERSOCKET_H - -#include <tqobject.h> -#include "ksocketbase.h" - -namespace KNetwork { - -class KSocketDevice; -class KStreamSocket; -class KResolver; -class KResolverResults; - -class KServerSocketPrivate; -/** - * @class KServerSocket kserversocket.h kserversocket.h - * @brief A server socket for accepting connections. - * - * This class provides functionality for creating a socket to - * listen for incoming connections and subsequently accept them. - * - * To use this class, you must first set the parameters for the listening - * socket's address, then place it in listening mode. - * - * A typical example would look like: - * \code - * TQString service = "http"; - * KServerSocket *ss = new KServerSocket(service); - * connect(ss, TQT_SIGNAL(readyAccept()), this, TQT_SLOT(slotReadyAccept())); - * connect(ss, TQT_SIGNAL(gotError(int)), this, TQT_SLOT(slotSocketError(int))); - * ss->listen(); - * \endcode - * - * In this case, this class will place the socket into listening mode on the - * service pointed to by @p service and will emit the @ref readyAccept signal - * when a connection is ready for accepting. The called slot is responsible for - * calling @ref accept. - * - * The location of the services file (where @p service is looked up) - * is defined by _PATH_SERVICES in /usr/include/netdb.h. This is - * usually set to /etc/services. - * See RFC 1700 for more information on services. - * You can specify @p service as a port number directly, rather than as a service - * name. This is discouraged as it prevents the end user from easily modifying - * the port number. - * - * For another example of usage, this below code attempts to make a connection on any port within a range: - * \code - * KServerSocket *ss = new KServerSocket(); - * ss->setFamily(KResolver::InetFamily); - * bool found = false; - * for( unsigned int port = firstport; port <= lastport; ++port) { - * ss->setAddress( TQString::number( port ) ); - * bool success = ss->listen(); - * if( found = ( success && ss->error() == - * KSocketBase::NoError ) ) - * break; - * ss->close(); - * } - * if( !found ) { - * // Couldn't connect to any port. - * } else { - * connect(ss, TQT_SIGNAL(readyAccept()), this, TQT_SLOT(slotReadyAccept())); - * connect(ss, TQT_SIGNAL(gotError(int)), this, TQT_SLOT(slotSocketError(int))); - * ss->listen(); - * } - * \endcode - * - * The called slot slotReadyAccept() is responsible for calling - * @ref accept. - * - * It is important to note that @ref accept can return either an - * object of type KNetwork::KStreamSocket or - * KNetwork::KBufferedSocket (default). If you want to accept a - * non-buffered socket, you must first call setAcceptBuffered. - * - * @warning If you use KServerSocket in an auxiliary (non-GUI) thread, - * you need to accept only KNetwork::KStreamSocket objects. - * - * @see KNetwork::KStreamSocket, KNetwork::KBufferedSocket - * @author Thiago Macieira <thiago@kde.org> - */ -class KDECORE_EXPORT KServerSocket: public TQObject, public KPassiveSocketBase -{ - Q_OBJECT - TQ_OBJECT -public: - /** - * Default constructor. - * - * If the binding address isn't changed by setAddress, this socket will - * bind to all interfaces on this node and the port will be selected by the - * operating system. - * - * @param parent the parent TQObject object - * @param name the name of this object - */ - KServerSocket(TQObject* parent = 0L, const char *name = 0L); - - /** - * Construct this object specifying the service to listen on. - * - * If the binding address isn't changed by setAddress, this socket will - * bind to all interfaces and will listen on the port specified by - * @p service. This is either a service name (e.g. 'www') or a port - * number (e.g. '80'). - * - * The location of the services file (where @p service is looked up) - * is defined by _PATH_SERVICES in /usr/include/netdb.h. This is - * usually set to /etc/services. - * See RFC 1700 for more information on services. - * - * @param service the service name to listen on - * @param parent the parent TQObject object - * @param name the name of this object - */ - KServerSocket(const TQString& service, TQObject* parent = 0L, const char *name = 0L); - - /** - * Construct this object specifying the node and service names to listen on. - * - * If the binding address isn't changed by setAddress, this socket will - * bind to the interface specified by @p node and the port specified by - * @p service. This is either a service name (e.g. 'www') or a port - * number (e.g. '80'). - * - * The location of the services file (where @p service is looked up) - * is defined by _PATH_SERVICES in /usr/include/netdb.h. This is - * usually set to /etc/services. - * See RFC 1700 for more information on services. - * - * @param node the node to bind to - * @param service the service port to listen on - * @param parent the parent TQObject object - * @param name the name of this object - */ - KServerSocket(const TQString& node, const TQString& service, - TQObject* parent = 0L, const char *name = 0L); - - /** - * Destructor. This will close the socket, if open. - * - * Note, however, that accepted sockets do not get closed when this - * object closes. - */ - ~KServerSocket(); - -protected: - /** - * Sets the socket options. Reimplemented from KSocketBase. - */ - virtual bool setSocketOptions(int opts); - -public: - /** - * Returns the internal KResolver object used for - * looking up the host name and service. - * - * This can be used to set extra options to the - * lookup process other than the default values, as well - * as obtaining the error codes in case of lookup failure. - */ - KResolver& resolver() const; - - /** - * Returns the internal list of resolved results for the binding address. - */ - const KResolverResults& resolverResults() const; - - /** - * Enables or disables name resolution. If this flag is set to true, - * the @ref bind operation will trigger name lookup - * operations (i.e., converting a hostname into its binary form). - * If the flag is set to false, those operations will instead - * try to convert a string representation of an address without - * attempting name resolution. - * - * This is useful, for instance, when IP addresses are in - * their string representation (such as "1.2.3.4") or come - * from other sources like @ref KSocketAddress. - * - * @param enable whether to enable - */ - void setResolutionEnabled(bool enable); - - /** - * Sets the allowed families for the resolutions. - * - * @param families the families that we want/accept - * @see KResolver::SocketFamilies for possible values - */ - void setFamily(int families); - - /** - * Sets the address on which we will listen. The port to listen on is given by - * @p service, and we will bind to all interfaces. To let the operating system choose a - * port, set the service to "0". @p service can either be a service name - * (e.g. 'www') or a port number (e.g. '80'). - * - * The location of the services file (where @p service is looked up) - * is defined by _PATH_SERVICES in /usr/include/netdb.h. This is - * usually set to /etc/services. - * See RFC 1700 for more information on services. - * - * @param service the service name to listen on - */ - void setAddress(const TQString& service); - - /** - * @overload - * Sets the address on which we will listen. This will cause the socket to listen - * only on the interface given by @p node and on the port given by @p service. - * @p service can either be a service name (e.g. 'www') or a port number - * (e.g. '80'). - * - * The location of the services file (where @p service is looked up) - * is defined by _PATH_SERVICES in /usr/include/netdb.h. This is - * usually set to /etc/services. - * See RFC 1700 for more information on services. - * - * @param node the node to bind to - * @param service the service port to listen on - */ - void setAddress(const TQString& node, const TQString& service); - - /** - * Sets the timeout for accepting. When you call @ref accept, - * it will wait at most @p msecs milliseconds or return with an error - * (returning a NULL object). - * - * @param msecs the time in milliseconds to wait, 0 to wait forever - */ - void setTimeout(int msecs); - - /** - * Starts the lookup for peer and local hostnames as - * well as their services. - * - * If the blocking mode for this object is on, this function will - * wait for the lookup results to be available (by calling the - * @ref KResolver::wait method on the resolver objects). - * - * When the lookup is done, the signal @ref hostFound will be - * emitted (only once, even if we're doing a double lookup). - * If the lookup failed (for any of the two lookups) the - * @ref gotError signal will be emitted with the appropriate - * error condition (see @ref KSocketBase::SocketError). - * - * This function returns true on success and false on error. Note that - * this is not the lookup result! - */ - virtual bool lookup(); - - /** - * Binds this socket to the given nodename and service, - * or use the default ones if none are given. - * - * Upon successful binding, the @ref bound signal will be - * emitted. If an error is found, the @ref gotError - * signal will be emitted. - * - * This function returns true on success. - * - * @param node the nodename - * @param service the service - */ - virtual bool bind(const TQString& node, const TQString& service); - - /** - * Binds the socket to the given service name. - * @overload - * - * @param service the service - */ - virtual bool bind(const TQString& service); - - /** - * Binds the socket to the addresses previously set with @ref setAddress. - * @overload - * - */ - virtual bool bind(); - - /** - * Connect this socket to this specific address. Reimplemented from KSocketBase. - * - * Unlike @ref bind(const TQString&, const TQString&) above, this function - * really does bind the socket. No lookup is performed. The @ref bound signal - * will be emitted. - */ - virtual bool bind(const KResolverEntry& address); - - /** - * Puts this socket into listening mode. Reimplemented from @ref KPassiveSocketBase. - * - * Placing a socket into listening mode means it will be able to receive incoming - * connections through the @ref accept method. - * - * If you do not call this method but call @ref accept directly, the socket will - * be placed into listening mode automatically. - * - * @param backlog the number of connection the system is to - * queue without @ref accept being called - * @returns true if the socket is now in listening mode. - */ - virtual bool listen(int backlog = 5); // 5 is arbitrary - - /** - * Closes this socket. - */ - virtual void close(); - - /** - * Toggles whether the accepted socket will be buffered or not. - * That is, the @ref accept function will always return a KStreamSocket - * object or descended from it. If buffering is enabled, the class - * to be returned will be KBufferedSocket. - * - * By default, this flag is set to true. - * - * @param enable whether to set the accepted socket to - * buffered mode - */ - void setAcceptBuffered(bool enable); - - /** - * Accepts one incoming connection and return the associated, open - * socket. - * - * If this function cannot accept a new connection, it will return NULL. - * The specific object class returned by this function may vary according - * to the implementation: derived classes may return specialised objects - * descended from KStreamSocket. - * - * @note This function should return a KStreamSocket object, but compiler - * deficiencies prevent such an adjustment. Therefore, we return - * the base class for active sockets, but it is guaranteed - * that the object will be a KStreamSocket or derived from it. - * - * @sa KBufferedSocket - * @sa setAcceptBuffered - */ - virtual KActiveSocketBase* accept(); - - /** - * Returns this socket's local address. - */ - virtual KSocketAddress localAddress() const; - - /** - * Returns this socket's externally-visible address if know. - */ - virtual KSocketAddress externalAddress() const; - -private slots: - void lookupFinishedSlot(); - -signals: - /** - * This signal is emitted when this object finds an error. - * The @p code parameter contains the error code that can - * also be found by calling @ref error. - */ - void gotError(int code); - - /** - * This signal is emitted when the lookup is successfully completed. - */ - void hostFound(); - - /** - * This signal is emitted when the socket successfully binds - * to an address. - * - * @param local the local address we bound to - */ - void bound(const KResolverEntry& local); - - /** - * This signal is emitted when the socket completes the - * closing/shut down process. - */ - void closed(); - - /** - * This signal is emitted whenever the socket is ready for - * accepting -- i.e., there is at least one connection waiting to - * be accepted. - */ - void readyAccept(); - -protected: - /** - * Convenience function to set this object's error code to match - * that of the socket device. - */ - void copyError(); - -private: - bool doBind(); - bool doListen(); - -private: - KServerSocket(const KServerSocket&); - KServerSocket& operator=(const KServerSocket&); - - KServerSocketPrivate *d; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/ksocketaddress.cpp b/kdecore/network/ksocketaddress.cpp deleted file mode 100644 index feaabfab5..000000000 --- a/kdecore/network/ksocketaddress.cpp +++ /dev/null @@ -1,957 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include "config.h" - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <arpa/inet.h> -#include <netinet/in.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#include <tqfile.h> -#include <tqobject.h> - -#include "klocale.h" -#include "ksocketaddress.h" - -#include "netsupp.h" - -using namespace KNetwork; - -#if 0 -class KIpAddress_localhostV4 : public KIpAddress -{ -public: - KIpAddress_localhostV4() - { - *m_data = htonl(0x7f000001); - m_version = 4; - } -}; - -class KIpAddress_localhostV6 : public KIpAddress -{ -public: - KIpAddress_localhostV6() - : KIpAddress(0L, 6) - { - m_data[3] = htonl(1); - } -}; -#endif - -static const char localhostV4_data[] = { 127, 0, 0, 1 }; -static const char localhostV6_data[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,1 }; - -const KIpAddress KIpAddress::localhostV4(&localhostV4_data, 4); -const KIpAddress KIpAddress::localhostV6(&localhostV6_data, 6); -const KIpAddress KIpAddress::anyhostV4(0L, 4); -const KIpAddress KIpAddress::anyhostV6(0L, 6); - -// helper function to test if an IPv6 v4-mapped address is equal to its IPv4 counterpart -static bool check_v4mapped(const TQ_UINT32* v6addr, TQ_UINT32 v4addr) -{ - // check that the v6 is a v4-mapped address - if (!(v6addr[0] == 0 && v6addr[1] == 0 && v6addr[2] == htonl(0x0000ffff))) - return false; // not a v4-mapped address - - return v6addr[3] == v4addr; -} - -// copy operator -KIpAddress& KIpAddress::operator =(const KIpAddress& other) -{ - m_version = other.m_version; - if (m_version == 4 || m_version == 6) - memcpy(m_data, other.m_data, sizeof(m_data)); - return *this; -} - -// comparison -bool KIpAddress::compare(const KIpAddress& other, bool checkMapped) const -{ - if (m_version == other.m_version) - switch (m_version) - { - case 0: - // both objects are empty - return true; - - case 4: - // IPv4 address - return *m_data == *other.m_data; - - case 6: - // IPv6 address - // they are 128-bit long, that is, 16 bytes - return memcmp(m_data, other.m_data, 16) == 0; - } - - if (checkMapped) - { - // check the possibility of a v4-mapped address being compared to an IPv4 one - if (m_version == 6 && other.m_version == 4 && check_v4mapped(m_data, *other.m_data)) - return true; - - if (other.m_version == 6 && m_version == 4 && check_v4mapped(other.m_data, *m_data)) - return true; - } - - return false; -} - -// sets the address to the given address -bool KIpAddress::setAddress(const TQString& address) -{ - m_version = 0; - - // try to guess the address version - if (address.find(':') != -1) - { -#ifdef AF_INET6 - // guessing IPv6 - - TQ_UINT32 buf[4]; - if (inet_pton(AF_INET6, address.latin1(), buf)) - { - memcpy(m_data, buf, sizeof(m_data)); - m_version = 6; - return true; - } -#endif - - return false; - } - else - { - TQ_UINT32 buf; - if (inet_pton(AF_INET, address.latin1(), &buf)) - { - *m_data = buf; - m_version = 4; - return true; - } - - return false; - } - - return false; // can never happen! -} - -bool KIpAddress::setAddress(const char* address) -{ - return setAddress(TQString::tqfromLatin1(address)); -} - -// set from binary data -bool KIpAddress::setAddress(const void* raw, int version) -{ - // this always succeeds - // except if version is invalid - if (version != 4 && version != 6) - return false; - - m_version = version; - if (raw != 0L) - memcpy(m_data, raw, version == 4 ? 4 : 16); - else - memset(m_data, 0, 16); - - return true; -} - -// presentation form -TQString KIpAddress::toString() const -{ - char buf[sizeof "1111:2222:3333:4444:5555:6666:255.255.255.255" + 2]; - buf[0] = '\0'; - switch (m_version) - { - case 4: - inet_ntop(AF_INET, m_data, buf, sizeof(buf) - 1); - return TQString::tqfromLatin1(buf); - - case 6: -#ifdef AF_INET6 - inet_ntop(AF_INET6, m_data, buf, sizeof(buf) - 1); -#endif - return TQString::tqfromLatin1(buf); - } - - return TQString::null; -} - -TQ_UINT32 KIpAddress::hostIPv4Addr(bool convertMapped) const -{ - TQ_UINT32 addr = IPv4Addr(convertMapped); - return ntohl(addr); -} - -/* - * An IPv6 socket address - * This is taken from RFC 2553. - */ -struct our_sockaddr_in6 -{ -# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - TQ_UINT8 sin6_len; - TQ_UINT8 sin6_family; -# else //!HAVE_STRUCT_SOCKADDR_SA_LEN - TQ_UINT16 sin6_family; -# endif - TQ_UINT16 sin6_port; /* RFC says in_port_t */ - TQ_UINT32 sin6_flowinfo; - TQ_UINT8 sin6_addr[16]; // 24 bytes up to here - TQ_UINT32 sin6_scope_id; // 28 bytes total -}; - -// useful definitions -#define MIN_SOCKADDR_LEN sizeof(TQ_UINT16) -#define SOCKADDR_IN_LEN sizeof(sockaddr_in) -#define MIN_SOCKADDR_IN6_LEN ((unsigned long) &(((our_sockaddr_in6*)0)->sin6_scope_id)) -#define SOCKADDR_IN6_LEN sizeof(our_sockaddr_in6) -#define MIN_SOCKADDR_UN_LEN (sizeof(TQ_UINT16) + sizeof(char)) - - -class KNetwork::KSocketAddressData -{ -public: - /* - * Note: maybe this should be virtual - * But since the data is shared via the d pointer, it doesn't really matter - * what one class sees, so will the other - */ - class QMixSocketAddressRef : public KInetSocketAddress, public KUnixSocketAddress - { - public: - QMixSocketAddressRef(KSocketAddressData* d) - : KInetSocketAddress(d), KUnixSocketAddress(d) - { - } - }; - QMixSocketAddressRef ref; - - union - { - struct sockaddr *generic; - struct sockaddr_in *in; - struct our_sockaddr_in6 *in6; - struct sockaddr_un *un; - } addr; - TQ_UINT16 curlen, reallen; - - KSocketAddressData() - : ref(this) - { - addr.generic = 0L; - curlen = 0; - tqinvalidate(); - } - - ~KSocketAddressData() - { - if (addr.generic != 0L) - free(addr.generic); - } - - inline bool invalid() const - { return reallen == 0; } - - inline void tqinvalidate() - { reallen = 0; } - - void dup(const sockaddr* sa, TQ_UINT16 len, bool clear = true); - - void makeipv4() - { - short oldport = 0; - if (!invalid()) - switch (addr.generic->sa_family) - { - case AF_INET: - return; // nothing to do here -#ifdef AF_INET6 - case AF_INET6: - oldport = addr.in6->sin6_port; - break; -#endif - } - - // create new space - dup(0L, SOCKADDR_IN_LEN); - - addr.in->sin_family = AF_INET; -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - addr.in->sin_len = SOCKADDR_IN_LEN; -#endif - addr.in->sin_port = oldport; - } - - void makeipv6() - { - short oldport = 0; - if (!invalid()) - switch (addr.generic->sa_family) - { - case AF_INET: - oldport = addr.in->sin_port; - break; - -#ifdef AF_INET6 - case AF_INET6: - return; // nothing to do here -#endif - } - - // make room - dup(0L, SOCKADDR_IN6_LEN); -#ifdef AF_INET6 - addr.in6->sin6_family = AF_INET6; -#endif -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - addr.in6->sin6_len = SOCKADDR_IN6_LEN; -#endif - addr.in6->sin6_port = oldport; - // sin6_scope_id and sin6_flowid are zero - } - -}; - -// create duplicates of -void KSocketAddressData::dup(const sockaddr* sa, TQ_UINT16 len, bool clear) -{ - if (len < MIN_SOCKADDR_LEN) - { - // certainly invalid - tqinvalidate(); - return; - } - - if (sa && ((sa->sa_family == AF_INET && len < SOCKADDR_IN_LEN) || -#ifdef AF_INET6 - (sa->sa_family == AF_INET6 && len < MIN_SOCKADDR_IN6_LEN) || -#endif - (sa->sa_family == AF_UNIX && len < MIN_SOCKADDR_UN_LEN))) - { - // also invalid - tqinvalidate(); - return; - } - - // good - reallen = len; - if (len > curlen) - { - if (len < 32) - curlen = 32; // big enough for sockaddr_in and sockaddr_in6 - else - curlen = len; - addr.generic = (sockaddr*)realloc(addr.generic, curlen); - } - - if (sa != 0L) - { - memcpy(addr.generic, sa, len); // copy - - // now, normalise the data - if (addr.generic->sa_family == AF_INET) - reallen = SOCKADDR_IN_LEN; // no need to be larger -#ifdef AF_INET6 - else if (addr.generic->sa_family == AF_INET6) - { - // set the extra field (sin6_scope_id) - - // the buffer is never smaller than 32 bytes, so this is always - // allowed - if (reallen < SOCKADDR_IN6_LEN) - addr.in6->sin6_scope_id = 0; - - reallen = SOCKADDR_IN6_LEN; - } -#endif - else if (addr.generic->sa_family == AF_UNIX) - reallen = MIN_SOCKADDR_UN_LEN + strlen(addr.un->sun_path); - } - else if (clear) - { - memset(addr.generic, 0, len); - addr.generic->sa_family = AF_UNSPEC; - } -} - -// default constructor -KSocketAddress::KSocketAddress() - : d(new KSocketAddressData) -{ -} - -// constructor from binary data -KSocketAddress::KSocketAddress(const sockaddr *sa, TQ_UINT16 len) - : d(new KSocketAddressData) -{ - setAddress(sa, len); -} - -KSocketAddress::KSocketAddress(const KSocketAddress& other) - : d(new(KSocketAddressData)) -{ - *this = other; -} - -KSocketAddress::KSocketAddress(KSocketAddressData *d2) - : d(d2) -{ -} - -KSocketAddress::~KSocketAddress() -{ - // prevent double-deletion, since we're already being deleted - if (d) - { - d->ref.KInetSocketAddress::d = 0L; - d->ref.KUnixSocketAddress::d = 0L; - delete d; - } -} - -KSocketAddress& KSocketAddress::operator =(const KSocketAddress& other) -{ - if (other.d && !other.d->invalid()) - d->dup(other.d->addr.generic, other.d->reallen); - else - d->tqinvalidate(); - return *this; -} - -const sockaddr* KSocketAddress::address() const -{ - if (d->invalid()) - return 0L; - return d->addr.generic; -} - -sockaddr* KSocketAddress::address() -{ - if (d->invalid()) - return 0L; - return d->addr.generic; -} - -KSocketAddress& KSocketAddress::setAddress(const sockaddr* sa, TQ_UINT16 len) -{ - if (sa != 0L && len >= MIN_SOCKADDR_LEN) - d->dup(sa, len); - else - d->tqinvalidate(); - - return *this; -} - -TQ_UINT16 KSocketAddress::length() const -{ - if (d->invalid()) - return 0; - return d->reallen; -} - -KSocketAddress& KSocketAddress::setLength(TQ_UINT16 len) -{ - d->dup((sockaddr*)0L, len, false); - - return *this; -} - -int KSocketAddress::family() const -{ - if (d->invalid()) - return AF_UNSPEC; - return d->addr.generic->sa_family; -} - -KSocketAddress& KSocketAddress::setFamily(int family) -{ - if (d->invalid()) - d->dup((sockaddr*)0L, MIN_SOCKADDR_LEN); - d->addr.generic->sa_family = family; - - return *this; -} - -bool KSocketAddress::operator ==(const KSocketAddress& other) const -{ - // if this is invalid, it's only equal if the other one is invalid as well - if (d->invalid()) - return other.d->invalid(); - - // check the family to make sure we don't do unnecessary comparison - if (d->addr.generic->sa_family != other.d->addr.generic->sa_family) - return false; // not the same family, not equal - - // same family then - // check the ones we know already - switch (d->addr.generic->sa_family) - { - case AF_INET: - Q_ASSERT(d->reallen == SOCKADDR_IN_LEN); - Q_ASSERT(other.d->reallen == SOCKADDR_IN_LEN); - return memcmp(d->addr.in, other.d->addr.in, SOCKADDR_IN_LEN) == 0; - -#ifdef AF_INET6 - case AF_INET6: - Q_ASSERT(d->reallen >= MIN_SOCKADDR_IN6_LEN); - Q_ASSERT(other.d->reallen >= MIN_SOCKADDR_IN6_LEN); - -# if !defined(HAVE_STRUCT_SOCKADDR_IN6) || defined(HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID) - // check for the case where sin6_scope_id isn't present - if (d->reallen != other.d->reallen) - { - if (memcmp(d->addr.in6, other.d->addr.in6, MIN_SOCKADDR_IN6_LEN) != 0) - return false; // not equal - if (d->reallen > other.d->reallen) - return d->addr.in6->sin6_scope_id == 0; - else - return other.d->addr.in6->sin6_scope_id == 0; - } -# endif - - return memcmp(d->addr.in6, other.d->addr.in6, d->reallen) == 0; -#endif - - case AF_UNIX: - Q_ASSERT(d->reallen >= MIN_SOCKADDR_UN_LEN); - Q_ASSERT(other.d->reallen >= MIN_SOCKADDR_UN_LEN); - - // do a string comparison here - return strcmp(d->addr.un->sun_path, other.d->addr.un->sun_path) == 0; - - default: - // something else we don't know about - // they are equal if and only if they are exactly equal - if (d->reallen == other.d->reallen) - return memcmp(d->addr.generic, other.d->addr.generic, d->reallen) == 0; - } - - return false; // not equal in any other case -} - -TQString KSocketAddress::nodeName() const -{ - if (d->invalid()) - return TQString::null; - - switch (d->addr.generic->sa_family) - { - case AF_INET: -#ifdef AF_INET6 - case AF_INET6: - - TQString scopeid("%"); - if (d->addr.generic->sa_family == AF_INET6 && d->addr.in6->sin6_scope_id) - scopeid += TQString::number(d->addr.in6->sin6_scope_id); - else - scopeid.truncate(0); - return d->ref.ipAddress().toString() + scopeid; -#else - return d->ref.ipAddress().toString(); -#endif - } - - // any other case, including AF_UNIX - return TQString::null; -} - -TQString KSocketAddress::serviceName() const -{ - if (d->invalid()) - return TQString::null; - - switch (d->addr.generic->sa_family) - { - case AF_INET: -#ifdef AF_INET6 - case AF_INET6: -#endif - return TQString::number(d->ref.port()); - - case AF_UNIX: - return d->ref.pathname(); - } - - return TQString::null; -} - -TQString KSocketAddress::toString() const -{ - if (d->invalid()) - return TQString::null; - - TQString fmt; - - if (d->addr.generic->sa_family == AF_INET) - fmt = "%1:%2"; -#ifdef AF_INET6 - else if (d->addr.generic->sa_family == AF_INET6) - fmt = "[%1]:%2"; -#endif - else if (d->addr.generic->sa_family == AF_UNIX) - return TQString::tqfromLatin1("unix:%1").arg(serviceName()); - else - return i18n("1: the unknown socket address family number", - "Unknown family %1").arg(d->addr.generic->sa_family); - - return fmt.arg(nodeName()).arg(serviceName()); -} - -KInetSocketAddress& KSocketAddress::asInet() -{ - return d->ref; -} - -KInetSocketAddress KSocketAddress::asInet() const -{ - return d->ref; -} - -KUnixSocketAddress& KSocketAddress::asUnix() -{ - return d->ref; -} - -KUnixSocketAddress KSocketAddress::asUnix() const -{ - return d->ref; -} - -int KSocketAddress::ianaFamily(int af) -{ - switch (af) - { - case AF_INET: - return 1; - -#ifdef AF_INET6 - case AF_INET6: - return 2; -#endif - - default: - return 0; - } -} - -int KSocketAddress::fromIanaFamily(int iana) -{ - switch (iana) - { - case 1: - return AF_INET; - -#ifdef AF_INET6 - case 2: - return AF_INET6; -#endif - - default: - return AF_UNSPEC; - } -} - -// default constructor -KInetSocketAddress::KInetSocketAddress() -{ -} - -// binary data constructor -KInetSocketAddress::KInetSocketAddress(const sockaddr* sa, TQ_UINT16 len) - : KSocketAddress(sa, len) -{ - if (!d->invalid()) - update(); -} - -// create from IP and port -KInetSocketAddress::KInetSocketAddress(const KIpAddress& host, TQ_UINT16 port) -{ - setHost(host); - setPort(port); -} - -// copy constructor -KInetSocketAddress::KInetSocketAddress(const KInetSocketAddress& other) - : KSocketAddress(other) -{ -} - -// special copy constructor -KInetSocketAddress::KInetSocketAddress(const KSocketAddress& other) - : KSocketAddress(other) -{ - if (!d->invalid()) - update(); -} - -// special constructor -KInetSocketAddress::KInetSocketAddress(KSocketAddressData *d) - : KSocketAddress(d) -{ -} - -// destructor -KInetSocketAddress::~KInetSocketAddress() -{ - /* nothing to do */ -} - -// copy operator -KInetSocketAddress& KInetSocketAddress::operator =(const KInetSocketAddress& other) -{ - KSocketAddress::operator =(other); - return *this; -} - -// IP version -int KInetSocketAddress::ipVersion() const -{ - if (d->invalid()) - return 0; - - switch (d->addr.generic->sa_family) - { - case AF_INET: - return 4; - -#ifdef AF_INET6 - case AF_INET6: - return 6; -#endif - } - - return 0; // for all other cases -} - -KIpAddress KInetSocketAddress::ipAddress() const -{ - if (d->invalid()) - return KIpAddress(); // return an empty address as well - - switch (d->addr.generic->sa_family) - { - case AF_INET: - return KIpAddress(&d->addr.in->sin_addr, 4); -#ifdef AF_INET6 - case AF_INET6: - return KIpAddress(&d->addr.in6->sin6_addr, 6); -#endif - } - - return KIpAddress(); // empty in all other cases -} - -KInetSocketAddress& KInetSocketAddress::setHost(const KIpAddress& ip) -{ - switch (ip.version()) - { - case 4: - makeIPv4(); - memcpy(&d->addr.in->sin_addr, ip.addr(), sizeof(d->addr.in->sin_addr)); - break; - - case 6: - makeIPv6(); - memcpy(&d->addr.in6->sin6_addr, ip.addr(), sizeof(d->addr.in6->sin6_addr)); - break; - - default: - // empty - d->tqinvalidate(); - } - - return *this; -} - -// returns the port -TQ_UINT16 KInetSocketAddress::port() const -{ - if (d->invalid()) - return 0; - - switch (d->addr.generic->sa_family) - { - case AF_INET: - return ntohs(d->addr.in->sin_port); - -#ifdef AF_INET6 - case AF_INET6: - return ntohs(d->addr.in6->sin6_port); -#endif - } - - return 0; -} - -KInetSocketAddress& KInetSocketAddress::setPort(TQ_UINT16 port) -{ - if (d->invalid()) - makeIPv4(); - - switch (d->addr.generic->sa_family) - { - case AF_INET: - d->addr.in->sin_port = htons(port); - break; - -#ifdef AF_INET6 - case AF_INET6: - d->addr.in6->sin6_port = htons(port); - break; -#endif - - default: - d->tqinvalidate(); // setting the port on something else - } - - return *this; -} - -KInetSocketAddress& KInetSocketAddress::makeIPv4() -{ - d->makeipv4(); - return *this; -} - -KInetSocketAddress& KInetSocketAddress::makeIPv6() -{ - d->makeipv6(); - return *this; -} - -TQ_UINT32 KInetSocketAddress::flowinfo() const -{ -#ifndef AF_INET6 - return 0; -#else - - if (!d->invalid() && d->addr.in6->sin6_family == AF_INET6) - return d->addr.in6->sin6_flowinfo; - return 0; -#endif -} - -KInetSocketAddress& KInetSocketAddress::setFlowinfo(TQ_UINT32 flowinfo) -{ - makeIPv6(); // must set here - d->addr.in6->sin6_flowinfo = flowinfo; - return *this; -} - -int KInetSocketAddress::scopeId() const -{ -#ifndef AF_INET6 - return 0; -#else - - if (!d->invalid() && d->addr.in6->sin6_family == AF_INET6) - return d->addr.in6->sin6_scope_id; - return 0; -#endif -} - -KInetSocketAddress& KInetSocketAddress::setScopeId(int scopeid) -{ - makeIPv6(); // must set here - d->addr.in6->sin6_scope_id = scopeid; - return *this; -} - -void KInetSocketAddress::update() -{ - if (d->addr.generic->sa_family == AF_INET) - return; -#ifdef AF_INET6 - else if (d->addr.generic->sa_family == AF_INET6) - return; -#endif - else - d->tqinvalidate(); -} - -KUnixSocketAddress::KUnixSocketAddress() -{ -} - -KUnixSocketAddress::KUnixSocketAddress(const sockaddr* sa, TQ_UINT16 len) - : KSocketAddress(sa, len) -{ - if (!d->invalid() && d->addr.un->sun_family != AF_UNIX) - d->tqinvalidate(); -} - -KUnixSocketAddress::KUnixSocketAddress(const KUnixSocketAddress& other) - : KSocketAddress(other) -{ -} - -KUnixSocketAddress::KUnixSocketAddress(const TQString& pathname) -{ - setPathname(pathname); -} - -KUnixSocketAddress::KUnixSocketAddress(KSocketAddressData* d) - : KSocketAddress(d) -{ -} - -KUnixSocketAddress::~KUnixSocketAddress() -{ -} - -KUnixSocketAddress& KUnixSocketAddress::operator =(const KUnixSocketAddress& other) -{ - KSocketAddress::operator =(other); - return *this; -} - -TQString KUnixSocketAddress::pathname() const -{ - if (!d->invalid() && d->addr.un->sun_family == AF_UNIX) - return TQFile::decodeName(d->addr.un->sun_path); - return TQString::null; -} - -KUnixSocketAddress& KUnixSocketAddress::setPathname(const TQString& path) -{ - d->dup(0L, MIN_SOCKADDR_UN_LEN + path.length()); - d->addr.un->sun_family = AF_UNIX; - strcpy(d->addr.un->sun_path, TQFile::encodeName(path)); - -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - d->addr.un->sun_len = d->reallen; -#endif - - return *this; -} diff --git a/kdecore/network/ksocketaddress.h b/kdecore/network/ksocketaddress.h deleted file mode 100644 index 75deb60ae..000000000 --- a/kdecore/network/ksocketaddress.h +++ /dev/null @@ -1,912 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KSOCKETADDRESS_H -#define KSOCKETADDRESS_H - -#include <tqstring.h> -#include <tqcstring.h> - -#include <kdelibs_export.h> - -struct sockaddr; -struct sockaddr_in; -struct sockaddr_in6; -struct sockaddr_un; - -namespace KNetwork { - -class KIpAddress; -class KSocketAddress; -class KInetSocketAddress; -class KUnixSocketAddress; - -/** @class KIpAddress ksocketaddress.h ksocketaddress.h - * @brief An IP address. - * - * This class represents one IP address, version 4 or 6. This is only - * the address, not including port information or other data. - * - * It is not a good programming practice to create address from objects - * like this. Instead, prefer a more thorough function like - * @ref KResolver::resolve, which also handle extra information like scope - * ids. - * - * This is a light-weight class. Most of the member functions are inlined and - * there are no virtual functions. This object's size should be less than 20 - * bytes. Also note that there is no sharing of data. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KIpAddress -{ -public: - /** - * Default constructor. Creates an empty address. - * It defaults to IP version 4. - */ - inline KIpAddress() : m_version(0) - { } - - /** - * Copy constructor. Copies the data from the other - * object. - * - * Data is not shared. - * - * @param other the other - */ - inline KIpAddress(const KIpAddress& other) - { *this = other; } - - /** - * Creates an object from the given string representation. - * - * The IP version is guessed from the address format. - * - * @param addr the address - */ - inline KIpAddress(const TQString& addr) - { setAddress(addr); } - - /** - * Creates an object from the given string representation. - * - * The IP version is guessed from the address format. - * - * @param addr the address - */ - inline KIpAddress(const char* addr) - { setAddress(addr); } - - /** - * Creates an object from the given raw data and IP version. - * - * @param addr the raw data - * @param version the IP version (4 or 6) - */ - inline KIpAddress(const void* addr, int version = 4) - { setAddress(addr, version); } - - /** - * This is a convenience constructor. Constructs an object - * from the given IPv4 address in the form of an integer. - * - * Note: do not write code to depend on IPv4 addresses being - * integer types. Instead, treat them as a special type, like - * a KIpAddress or the system's in_addr. - * - * @param ip4addr the IPv4 address - */ - inline KIpAddress(TQ_UINT32 ip4addr) - { setAddress(&ip4addr, 4); } - - /** - * Destructor. This frees resources associated with this object. - * - * Note: destructor is non-virtual. The compiler will happily optimise it - * out of the way. - */ - inline ~KIpAddress() - { } - - /** - * Copy operator. - * - * Copies the data from the other object into this one. - * - * @param other the object to copy - */ - KIpAddress& operator =(const KIpAddress& other); - - /** - * Returns true if the two addresses match. - * This function performs a v4-mapped check. - * @see compare - */ - inline bool operator ==(const KIpAddress& other) const - { return compare(other, true); } - - /** - * Compares this address against the other, supplied one and return - * true if they match. The @p checkMapped parameter controls whether - * a check for an IPv6 v4-mapped address will be performed. - * - * An IPv6 v4-mapped address is an IPv6 address that is, for all purposes, - * equivalent to an IPv4 one. The default behaviour of this function - * is to take that into account. If you want a strict matching, - * pass @b false to the @p checkMapped parameter. - * - * @param other the other IP address - * @param checkMapped whether v4-mapped addresses will be taken into account - */ - bool compare(const KIpAddress& other, bool checkMapped = true) const; - - /** - * Retrieves the IP version in this object. - * - * @returns the version: 4 or 6 - */ - inline int version() const - { return m_version; } - - /** - * Returns true if this is an IPv4 address. - */ - inline bool isIPv4Addr() const - { return version() == 4; } - - /** - * Returns true if this is an IPv6 address. - */ - inline bool isIPv6Addr() const - { return version() == 6; } - - /** - * Sets the address to the given string representation. - * - * @return true if the address was successfully parsed; otherwise returns - * false and leaves the object unchanged. - */ - bool setAddress(const TQString& address); - - /** - * Sets the address to the given string representation. - * - * @return true if the address was successfully parsed; otherwise returns - * false and leaves the object unchanged. - */ - bool setAddress(const char* address); - - /** - * Sets the address to the given raw binary representation. - * - * @param raw a pointer to the raw binary data - * @param version the IP version - * @return true if the address was successfully parsed; otherwise returns - * false and leaves the object unchanged. - */ - bool setAddress(const void* raw, int version = 4); - - /** - * Returns the address as a string. - */ - TQString toString() const; - - /** - * Returns a pointer to binary raw data representing the address. - */ - inline const void *addr() const - { return m_data; } - - /** - * This is a convenience function. Returns the IPv4 address in a - * 32-bit integer. The result is only valid if @ref isIPv4Addr returns - * true. Alternatively, if the contained IPv6 address is a v4-mapped one - * and the @p convertMapped parameter is true, the result will also be - * valid. The address returned is in network byte order. - * - * Note: you should not treat IP addresses as integers. Instead, - * use types defined for that purpose, such as KIpAddress or the - * system's in_addr type. - * - */ - inline TQ_UINT32 IPv4Addr(bool convertMapped = true) const - { - return (convertMapped && isV4Mapped()) ? m_data[3] : m_data[0]; - } - - /** - * This is a convenience function. Returns the IPv4 address in a - * 32-bit integer. The result is only valid if @ref isIPv4Addr returns - * true. Alternatively, if the contained IPv6 address is a v4-mapped one - * and the @p convertMapped parameter is true, the result will also be - * valid. The address returned is in host byte order. - * - */ - TQ_UINT32 hostIPv4Addr(bool convertMapped = true) const; - -public: - /*-- tests --*/ - - /** - * Returns true if this is the IPv4 or IPv6 unspecified address. - */ - inline bool isUnspecified() const - { return version() == 0 ? true : (*this == anyhostV4 || *this == anyhostV6); } - - /** - * Returns true if this is either the IPv4 or the IPv6 localhost address. - */ - inline bool isLocalhost() const - { return version() == 0 ? false : (*this == localhostV4 || *this == localhostV6); } - - /** - * This is an alias for @ref isLocalhost. - */ - inline bool isLoopback() const - { return isLocalhost(); } - - /** - * Returns true if this is an IPv4 class A address, i.e., - * from 0.0.0.0 to 127.255.255.255. - * - * This function does not test for v4-mapped addresses. - */ - inline bool isClassA() const - { return version() != 4 ? false : (hostIPv4Addr() & 0x80000000) == 0; } - - /** - * Returns true if this is an IPv4 class B address, i.e., one from - * 128.0.0.0 to 191.255.255.255. - * - * This function does not test for v4-mapped addresses. - */ - inline bool isClassB() const - { return version() != 4 ? false : (hostIPv4Addr() & 0xc0000000) == 0x80000000; } - - /** - * Returns true if this is an IPv4 class C address, i.e., one from - * 192.0.0.0 to 223.255.255.255. - * - * This function does not test for v4-mapped addresses. - */ - inline bool isClassC() const - { return version() != 4 ? false : (hostIPv4Addr() & 0xe0000000) == 0xc0000000; } - - /** - * Returns true if this is an IPv4 class D (a.k.a. multicast) address. - * - * Note: this function is not the same as @ref isMulticast. isMulticast also - * tests for IPv6 multicast addresses. - */ - inline bool isClassD() const - { return version() != 4 ? false : (hostIPv4Addr() & 0xf0000000) == 0xe0000000; } - - /** - * Returns true if this is a multicast address, be it IPv4 or IPv6. - */ - inline bool isMulticast() const - { - if (version() == 4) return isClassD(); - if (version() == 6) return ((TQ_UINT8*)addr())[0] == 0xff; - return false; - } - - /** - * Returns true if this is an IPv6 link-local address. - */ - inline bool isLinkLocal() const - { - if (version() != 6) return false; - TQ_UINT8* addr = (TQ_UINT8*)this->addr(); - return (addr[0] & 0xff) == 0xfe && - (addr[1] & 0xc0) == 0x80; - } - - /** - * Returns true if this is an IPv6 site-local address. - */ - inline bool isSiteLocal() const - { - if (version() != 6) return false; - TQ_UINT8* addr = (TQ_UINT8*)this->addr(); - return (addr[0] & 0xff) == 0xfe && - (addr[1] & 0xc0) == 0xc0; - } - - /** - * Returns true if this is a global IPv6 address. - */ - inline bool isGlobal() const - { return version() != 6 ? false : !(isMulticast() || isLinkLocal() || isSiteLocal()); } - - /** - * Returns true if this is a v4-mapped IPv6 address. - */ - inline bool isV4Mapped() const - { - if (version() != 6) return false; - TQ_UINT32* addr = (TQ_UINT32*)this->addr(); - return addr[0] == 0 && addr[1] == 0 && - ((TQ_UINT16*)&addr[2])[0] == 0 && - ((TQ_UINT16*)&addr[2])[1] == 0xffff; - } - - /** - * Returns true if this is a v4-compat IPv6 address. - */ - inline bool isV4Compat() const - { - if (version() != 6 || isLocalhost()) return false; - TQ_UINT32* addr = (TQ_UINT32*)this->addr(); - return addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] != 0; - } - - /** - * Returns true if this is an IPv6 node-local multicast address. - */ - inline bool isMulticastNodeLocal() const - { return version() == 6 && isMulticast() && (((TQ_UINT32*)addr())[0] & 0xf) == 0x1; } - - /** - * Returns true if this is an IPv6 link-local multicast address. - */ - inline bool isMulticastLinkLocal() const - { return version() == 6 && isMulticast() && (((TQ_UINT32*)addr())[0] & 0xf) == 0x2; } - - /** - * Returns true if this is an IPv6 site-local multicast address. - */ - inline bool isMulticastSiteLocal() const - { return version() == 6 && isMulticast() && (((TQ_UINT32*)addr())[0] & 0xf) == 0x5; } - - /** - * Returns true if this is an IPv6 organisational-local multicast address. - */ - inline bool isMulticastOrgLocal() const - { return version() == 6 && isMulticast() && (((TQ_UINT32*)addr())[0] & 0xf) == 0x8; } - - /** - * Returns true if this is an IPv6 global multicast address. - */ - inline bool isMulticastGlobal() const - { return version() == 6 && isMulticast() && (((TQ_UINT32*)addr())[0] & 0xf) == 0xe; } - -protected: - TQ_UINT32 m_data[4]; // 16 bytes, needed for an IPv6 address - - char m_version; - -public: - /// localhost in IPv4 (127.0.0.1) - static const KIpAddress localhostV4; - /// the any host or undefined address in IPv4 (0.0.0.0) - static const KIpAddress anyhostV4; - - /// localhost in IPv6 (::1) - static const KIpAddress localhostV6; - /// the any host or undefined address in IPv6 (::) - static const KIpAddress anyhostV6; -}; - - -class KSocketAddressData; -/** @class KSocketAddress ksocketaddress.h ksocketaddress.h - * @brief A generic socket address. - * - * This class holds one generic socket address. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KSocketAddress -{ -public: - /** - * Default constructor. - * - * Creates an empty object - */ - KSocketAddress(); - - /** - * Creates this object with the given data. - * The raw socket address is copied into this object. - * - * @param sa the socket address structure - * @param len the socket address length - */ - KSocketAddress(const sockaddr* sa, TQ_UINT16 len); - - /** - * Copy constructor. This creates a copy of the other - * object. - * - * Data is not shared. - * - * @param other the object to copy from - */ - KSocketAddress(const KSocketAddress& other); - - /** - * Destructor. Frees any associated resources. - */ - virtual ~KSocketAddress(); - - /** - * Performs a shallow copy of the other object into this one. - * Data will be copied. - * - * @param other the object to copy from - */ - KSocketAddress& operator =(const KSocketAddress& other); - - /** - * Returns the socket address structure, to be passed down to - * low level functions. - * - * Note that this function returns NULL for invalid or empty sockets, - * so you may use to to test for validity. - */ - const sockaddr* address() const; - - /** - * Returns the socket address structure, to be passed down to - * low level functions. - * - * Note that this function returns NULL for invalid or empty sockets, - * so you may use to to test for validity. - * - * The returned value, if not NULL, is an internal buffer which is guaranteed - * to be at least @ref length() bytes long. - */ - sockaddr* address(); - - /** - * Sets the address to the given address. - * The raw socket address is copied into this object. - * - * @param sa the socket address structure - * @param len the socket address length - */ - KSocketAddress& setAddress(const sockaddr *sa, TQ_UINT16 len); - - /** - * Returns the socket address structure, to be passed down to - * low level functions. - */ - inline operator const sockaddr*() const - { return address(); } - - /** - * Returns the length of this socket address structure. - */ - TQ_UINT16 length() const; - - /** - * Sets the length of this socket structure. - * - * Use this function with care. It allows you to resize the internal - * buffer to fit needs. This function should not be used except for handling - * unknown socket address structures. - * - * Also note that this function may tqinvalidate the socket if a known - * family is set (Internet or Unix socket) and the new length would be - * too small to hold the system's sockaddr_* structure. If unsure, reset - * the family: - * - * \code - * KSocketAddress qsa; - * [...] - * qsa.setFamily(AF_UNSPEC).setLength(newlen); - * \endcode - * - * @param len the new length - */ - KSocketAddress& setLength(TQ_UINT16 len); - - /** - * Returns the family of this address. - * @return the family of this address, AF_UNSPEC if it's undefined - */ - int family() const; - - /** - * Sets the family of this object. - * - * Note: setting the family will probably tqinvalidate any address data - * contained in this object. Use this function with care. - * - * @param family the new family to set - */ - virtual KSocketAddress& setFamily(int family); - - /** - * Returns the IANA family number of this address. - * @return the IANA family number of this address (1 for AF_INET. - * 2 for AF_INET6, otherwise 0) - */ - inline int ianaFamily() const - { return ianaFamily(family()); } - - /** - * Returns true if this equals the other socket. - * - * Socket addresses are considered matching if and only if all data is the same. - * - * @param other the other socket - * @return true if both sockets are equal - */ - bool operator ==(const KSocketAddress& other) const; - - /** - * Returns the node name of this socket. - * - * In the case of Internet sockets, this is string representation of the IP address. - * The default implementation returns TQString::null. - * - * @return the node name, can be TQString::null - * @bug use KResolver to resolve unknown families - */ - virtual TQString nodeName() const; - - /** - * Returns the service name for this socket. - * - * In the case of Internet sockets, this is the port number. - * The default implementation returns TQString::null. - * - * @return the service name, can be TQString::null - * @bug use KResolver to resolve unknown families - */ - virtual TQString serviceName() const; - - /** - * Returns this socket address as a string suitable for - * printing. Family, node and service are part of this address. - * - * @bug use KResolver to resolve unknown families - */ - virtual TQString toString() const; - - /** - * Returns an object reference that can be used to manipulate this socket - * as an Internet socket address. Both objects share the same data. - */ - KInetSocketAddress& asInet(); - - /** - * Returns an object is equal to this object's data, but they don't share it. - */ - KInetSocketAddress asInet() const; - - /** - * Returns an object reference that can be used to manipulate this socket - * as a Unix socket address. Both objects share the same data. - */ - KUnixSocketAddress& asUnix(); - - /** - * Returns an object is equal to this object's data, but they don't share it. - */ - KUnixSocketAddress asUnix() const; - -protected: - /// @internal - /// private data - KSocketAddressData *d; - - /// @internal - /// extra constructor - KSocketAddress(KSocketAddressData* d); - -public: // static - /** - * Returns the IANA family number of the given address family. - * Returns 0 if there is no corresponding IANA family number. - * @param af the address family, in AF_* constants - * @return the IANA family number of this address (1 for AF_INET. - * 2 for AF_INET6, otherwise 0) - */ - static int ianaFamily(int af); - - /** - * Returns the address family of the given IANA family number. - * @return the address family, AF_UNSPEC for unknown IANA family numbers - */ - static int fromIanaFamily(int iana); -}; - - -/** @class KInetSocketAddress ksocketaddress.h ksocketaddress.h - * @brief an Internet socket address - * - * An Inet (IPv4 or IPv6) socket address - * - * This is an IPv4 or IPv6 address of the Internet. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KInetSocketAddress: public KSocketAddress -{ - friend class KSocketAddress; -public: - /** - * Public constructor. Creates an empty object. - */ - KInetSocketAddress(); - - /** - * Creates an object from raw data. - * - * Note: if the socket address @p sa does not contain a valid Internet - * socket (IPv4 or IPv6), this object will be empty. - * - * @param sa the sockaddr structure - * @param len the structure's length - */ - KInetSocketAddress(const sockaddr* sa, TQ_UINT16 len); - - /** - * Creates an object from an IP address and port. - * - * @param host the IP address - * @param port the port number - */ - KInetSocketAddress(const KIpAddress& host, TQ_UINT16 port); - - /** - * Copy constructor. - * - * Data is not shared. - * - * @param other the other object - */ - KInetSocketAddress(const KInetSocketAddress& other); - - /** - * Copy constructor. - * - * If the other, generic socket address contains an Internet address, - * it will be copied. Otherwise, this object will be empty. - * - * @param other the other object - */ - KInetSocketAddress(const KSocketAddress& other); - - /** - * Destroys this object. - */ - virtual ~KInetSocketAddress(); - - /** - * Copy operator. - * - * Copies the other object into this one. - * - * @param other the other object - */ - KInetSocketAddress& operator =(const KInetSocketAddress& other); - - /** - * Cast operator to sockaddr_in. - */ - inline operator const sockaddr_in*() const - { return (const sockaddr_in*)address(); } - - /** - * Cast operator to sockaddr_in6. - */ - inline operator const sockaddr_in6*() const - { return (const sockaddr_in6*)address(); } - - /** - * Returns the IP version of the address this object holds. - * - * @return 4 or 6, if IPv4 or IPv6, respectively; 0 if this object is empty - */ - int ipVersion() const; - - /** - * Returns the IP address component. - */ - KIpAddress ipAddress() const; - - /** - * Sets the IP address to the given raw address. - * - * This call will preserve port numbers accross IP versions, but will lose - * IPv6 specific data if the address is set to IPv4. - * - * @param addr the address to set to - * @return a reference to itself - */ - KInetSocketAddress& setHost(const KIpAddress& addr); - - /** - * Retrieves the port number stored in this object. - * - * @return a port number in the range 0 to 65535, inclusive. An empty or - * invalid object will have a port number of 0. - */ - TQ_UINT16 port() const; - - /** - * Sets the port number. If this object is empty, this function will default to - * creating an IPv4 address. - * - * @param port the port number to set - * @return a reference to itself - */ - KInetSocketAddress& setPort(TQ_UINT16 port); - - /** - * Converts this object to an IPv4 socket address. It has no effect if the object - * is already an IPv4 socket address. - * - * If this object is an IPv6 address, the port number is preserved. All other information - * is lost. - * - * @return a reference to itself - */ - KInetSocketAddress& makeIPv4(); - - /** - * Converts this object to an IPv6 socket address. It has no effect if the object - * is already an IPv6 socket address. - * - * If this object is an IPv4 address, the port number is preserved. - * - * @return a reference to itself - */ - KInetSocketAddress& makeIPv6(); - - /** - * Returns the flowinfo information from the IPv6 socket address. - * - * @return the flowinfo information or 0 if this object is empty or IPv4 - */ - TQ_UINT32 flowinfo() const; - - /** - * Sets the flowinfo information for an IPv6 socket address. If this is not - * an IPv6 socket address, this function converts it to one. See makeIPv6. - * - * @param flowinfo the flowinfo to set - * @return a reference to itself - */ - KInetSocketAddress& setFlowinfo(TQ_UINT32 flowinfo); - - /** - * Returns the scope id this IPv6 socket is bound to. - * - * @return the scope id, or 0 if this is not an IPv6 object - */ - int scopeId() const; - - /** - * Sets the scope id for this IPv6 object. If this is not an IPv6 socket - * address, this function converts it to one. See makeIPv6 - * - * @param scopeid the scopeid to set - * @return a reference to itself - */ - KInetSocketAddress& setScopeId(int scopeid); - -protected: - /// @internal - /// extra constructor - KInetSocketAddress(KSocketAddressData* d); - -private: - void update(); -}; - -/* - * External definition - */ - -/** @class KUnixSocketAddress ksocketaddress.h ksocketaddress.h - * @brief A Unix (local) socket address. - * - * This is a Unix socket address. - * - * Note that this class uses QStrings to represent filenames, which means - * the proper encoding is used to translate into valid filesystem file names. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KUnixSocketAddress: public KSocketAddress -{ - friend class KSocketAddress; -public: - /** - * Default constructor. Creates an empty object. - */ - KUnixSocketAddress(); - - /** - * Creates this object with the given raw data. If - * the sockaddr structure does not contain a Local namespace - * (Unix) socket, this object will be created empty. - * - * @param sa the socket address structure - * @param len the structure's length - */ - KUnixSocketAddress(const sockaddr* sa, TQ_UINT16 len); - - /** - * Copy constructor. Creates a copy of the other object, - * sharing the data explicitly. - * - * @param other the other object - */ - KUnixSocketAddress(const KUnixSocketAddress& other); - - /** - * Constructs an object from the given pathname. - */ - KUnixSocketAddress(const TQString& pathname); - - /** - * Destructor. - */ - virtual ~KUnixSocketAddress(); - - /** - * Copy operator. Copies the contents of the other object into - * this one. Data is explicitly shared. - * - * @param other the other - */ - KUnixSocketAddress& operator =(const KUnixSocketAddress& other); - - /** - * Cast operator to sockaddr_un. - */ - inline operator const sockaddr_un*() const - { return (const sockaddr_un*)address(); } - - /** - * Returns the pathname associated with this object. Will return - * TQString::null if this object is empty. - */ - TQString pathname() const; - - /** - * Sets the pathname for the object. - * - * @return a reference to itself - */ - KUnixSocketAddress& setPathname(const TQString& path); - -protected: - /// @internal - /// extra constructor - KUnixSocketAddress(KSocketAddressData* d); -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/ksocketbase.cpp b/kdecore/network/ksocketbase.cpp deleted file mode 100644 index f5410f3e8..000000000 --- a/kdecore/network/ksocketbase.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003-2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> -#include <tqmutex.h> -#include "klocale.h" - -#include "ksocketbase.h" -#include "ksocketdevice.h" - -using namespace KNetwork; - -class KNetwork::KSocketBasePrivate -{ -public: - int socketOptions; - int socketError; - int capabilities; - - mutable KSocketDevice* device; - - TQMutex mutex; - - KSocketBasePrivate() - : mutex(true) // create recursive - { } -}; - -KSocketBase::KSocketBase() - : d(new KSocketBasePrivate) -{ - d->socketOptions = Blocking; - d->socketError = 0; - d->device = 0L; - d->capabilities = 0; -} - -KSocketBase::~KSocketBase() -{ - delete d->device; - delete d; -} - -bool KSocketBase::setSocketOptions(int opts) -{ - d->socketOptions = opts; - return true; -} - -int KSocketBase::socketOptions() const -{ - return d->socketOptions; -} - -bool KSocketBase::setBlocking(bool enable) -{ - return setSocketOptions((socketOptions() & ~Blocking) | (enable ? Blocking : 0)); -} - -bool KSocketBase::blocking() const -{ - return socketOptions() & Blocking; -} - -bool KSocketBase::setAddressReuseable(bool enable) -{ - return setSocketOptions((socketOptions() & ~AddressReuseable) | (enable ? AddressReuseable : 0)); -} - -bool KSocketBase::addressReuseable() const -{ - return socketOptions() & AddressReuseable; -} - -bool KSocketBase::setIPv6Only(bool enable) -{ - return setSocketOptions((socketOptions() & ~IPv6Only) | (enable ? IPv6Only : 0)); -} - -bool KSocketBase::isIPv6Only() const -{ - return socketOptions() & IPv6Only; -} - -bool KSocketBase::setBroadcast(bool enable) -{ - return setSocketOptions((socketOptions() & ~Broadcast) | (enable ? Broadcast : 0)); -} - -bool KSocketBase::broadcast() const -{ - return socketOptions() & Broadcast; -} - -KSocketDevice* KSocketBase::socketDevice() const -{ - if (d->device) - return d->device; - - // it doesn't exist, so create it - TQMutexLocker locker(mutex()); - if (d->device) - return d->device; - - KSocketBase* that = const_cast<KSocketBase*>(this); - KSocketDevice* dev = 0; - if (d->capabilities) - dev = KSocketDevice::createDefault(that, d->capabilities); - if (!dev) - dev = KSocketDevice::createDefault(that); - that->setSocketDevice(dev); - return d->device; -} - -void KSocketBase::setSocketDevice(KSocketDevice* device) -{ - TQMutexLocker locker(mutex()); - if (d->device == 0L) - d->device = device; -} - -int KSocketBase::setRequestedCapabilities(int add, int remove) -{ - d->capabilities |= add; - d->capabilities &= ~remove; - return d->capabilities; -} - -bool KSocketBase::hasDevice() const -{ - return d->device != 0L; -} - -void KSocketBase::setError(SocketError error) -{ - d->socketError = error; -} - -KSocketBase::SocketError KSocketBase::error() const -{ - return static_cast<KSocketBase::SocketError>(d->socketError); -} - -// static -TQString KSocketBase::errorString(KSocketBase::SocketError code) -{ - TQString reason; - switch (code) - { - case NoError: - reason = i18n("Socket error code NoError", "no error"); - break; - - case LookupFailure: - reason = i18n("Socket error code LookupFailure", - "name lookup has failed"); - break; - - case AddressInUse: - reason = i18n("Socket error code AddressInUse", - "address already in use"); - break; - - case AlreadyBound: - reason = i18n("Socket error code AlreadyBound", - "socket is already bound"); - break; - - case AlreadyCreated: - reason = i18n("Socket error code AlreadyCreated", - "socket is already created"); - break; - - case NotBound: - reason = i18n("Socket error code NotBound", - "socket is not bound"); - break; - - case NotCreated: - reason = i18n("Socket error code NotCreated", - "socket has not been created"); - break; - - case WouldBlock: - reason = i18n("Socket error code WouldBlock", - "operation would block"); - break; - - case ConnectionRefused: - reason = i18n("Socket error code ConnectionRefused", - "connection actively refused"); - break; - - case ConnectionTimedOut: - reason = i18n("Socket error code ConnectionTimedOut", - "connection timed out"); - break; - - case InProgress: - reason = i18n("Socket error code InProgress", - "operation is already in progress"); - break; - - case NetFailure: - reason = i18n("Socket error code NetFailure", - "network failure occurred"); - break; - - case NotSupported: - reason = i18n("Socket error code NotSupported", - "operation is not supported"); - break; - - case Timeout: - reason = i18n("Socket error code Timeout", - "timed operation timed out"); - break; - - case UnknownError: - reason = i18n("Socket error code UnknownError", - "an unknown/unexpected error has happened"); - break; - - case RemotelyDisconnected: - reason = i18n("Socket error code RemotelyDisconnected", - "remote host closed connection"); - break; - - default: - reason = TQString::null; - break; - } - - return reason; -} - -// static -bool KSocketBase::isFatalError(int code) -{ - switch (code) - { - case WouldBlock: - case InProgress: - case NoError: - case RemotelyDisconnected: - return false; - } - - return true; -} - -void KSocketBase::unsetSocketDevice() -{ - d->device = 0L; -} - -TQMutex* KSocketBase::mutex() const -{ - return &d->mutex; -} - -KActiveSocketBase::KActiveSocketBase() -{ -} - -KActiveSocketBase::~KActiveSocketBase() -{ -} - -int KActiveSocketBase::getch() -{ - unsigned char c; - if (tqreadBlock((char*)&c, 1) != 1) - return -1; - - return c; -} - -int KActiveSocketBase::putch(int ch) -{ - unsigned char c = (unsigned char)ch; - if (tqwriteBlock((char*)&c, 1) != 1) - return -1; - - return c; -} - -void KActiveSocketBase::setError(int status, SocketError error) -{ - KSocketBase::setError(error); - setqStatus(status); -} - -void KActiveSocketBase::resetError() -{ - KSocketBase::setError(NoError); - resetStatus(); -} - -KPassiveSocketBase::KPassiveSocketBase() -{ -} - -KPassiveSocketBase::~KPassiveSocketBase() -{ -} diff --git a/kdecore/network/ksocketbase.h b/kdecore/network/ksocketbase.h deleted file mode 100644 index 8a94cbbcb..000000000 --- a/kdecore/network/ksocketbase.h +++ /dev/null @@ -1,771 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -/* - * Even before our #ifdef, clean up the namespace - */ -#ifdef socket -#undef socket -#endif - -#ifdef bind -#undef bind -#endif - -#ifdef listen -#undef listen -#endif - -#ifdef connect -#undef connect -#endif - -#ifdef accept -#undef accept -#endif - -#ifdef getpeername -#undef getpeername -#endif - -#ifdef getsockname -#undef getsockname -#endif - -#ifndef KSOCKETBASE_H -#define KSOCKETBASE_H - -#include <tqiodevice.h> -#include <tqstring.h> - -#include "ksocketaddress.h" -#include <kdelibs_export.h> - -/* - * This is extending QIODevice's error codes - * - * According to tqiodevice.h, the last error is IO_UnspecifiedError - * These errors will never occur in functions declared in QIODevice - * (except open, but you shouldn't call open) - */ -#define IO_ListenError (IO_UnspecifiedError+1) -#define IO_AcceptError (IO_UnspecifiedError+2) -#define IO_LookupError (IO_UnspecifiedError+3) -#define IO_SocketCreateError (IO_UnspecifiedError+4) -#define IO_BindError (IO_UnspecifiedError+5) - -class TQMutex; - -namespace KNetwork { - -class KResolverEntry; -class KSocketDevice; - -class KSocketBasePrivate; -/** @class KSocketBase ksocketbase.h ksocketbase.h - * @brief Basic socket functionality. - * - * This class provides the basic socket functionlity for descended classes. - * Socket classes are thread-safe and provide a recursive mutex should it be - * needed. - * - * @note This class is abstract. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KSocketBase -{ -public: - /** - * Possible socket options. - * - * These are the options that may be set on a socket: - * - Blocking: whether the socket shall operate in blocking - * or non-blocking mode. This flag defaults to on. - * See @ref setBlocking. - * - AddressReusable: whether the address used by this socket will - * be available for reuse by other sockets. This flag defaults to off. - * See @ref setAddressReuseable. - * - IPv6Only: whether an IPv6 socket will accept IPv4 connections - * through a mapped address. This flag defaults to off. - * See @ref setIPv6Only. - * - KeepAlive: whether TCP should send keepalive probes when a connection - * has gone idle for far too long. - * - Broadcast: whether this socket is allowed to send broadcast packets - * and will receive packets sent to broadcast. - */ - enum SocketOptions - { - Blocking = 0x01, - AddressReuseable = 0x02, - IPv6Only = 0x04, - Keepalive = 0x08, - Broadcast = 0x10 - }; - - /** - * Possible socket error codes. - * - * This is a list of possible error conditions that socket classes may - * be expected to find. - * - * - NoError: no error has been detected - * - LookupFailure: if a name lookup has failed - * - AddressInUse: address is already in use - * - AlreadyBound: cannot bind again - * - AlreadyCreated: cannot recreate the socket - * - NotBound: operation required socket to be bound and it isn't - * - NotCreated: operation required socket to exist and it doesn't - * - WouldBlock: requested I/O operation would block - * - ConnectionRefused: connection actively refused - * - ConnectionTimedOut: connection timed out - * - InProgress: operation (connection) is already in progress - * - NetFailure: a network failure occurred (no route, host down, host unreachable or similar) - * - NotSupported: requested operation is not supported - * - Timeout: a timed operation timed out - * - UnknownError: an unknown/unexpected error has happened - * - RemotelyDisconnected: when a connection is disconnected by the other end (since 3.4) - * - * @sa error, errorString - */ - enum SocketError - { - NoError = 0, - LookupFailure, - AddressInUse, - AlreadyCreated, - AlreadyBound, - AlreadyConnected, - NotConnected, - NotBound, - NotCreated, - WouldBlock, - ConnectionRefused, - ConnectionTimedOut, - InProgress, - NetFailure, - NotSupported, - Timeout, - UnknownError, - RemotelyDisconnected - }; - -public: - /** - * Default constructor. - */ - KSocketBase(); - - /** - * Destructor. - */ - virtual ~KSocketBase(); - - /* - * The following functions are shared by all descended classes and will have - * to be reimplemented. - */ - -protected: - /** - * Set the given socket options. - * - * The default implementation does nothing but store the mask internally. - * Descended classes must override this function to achieve functionality and - * must also call this implementation. - * - * @param opts a mask of @ref SocketOptions or-ed bits of options to set - * or unset - * @returns true on success - * @note this function sets the options corresponding to the bits enabled in @p opts - * but will also unset the optiosn corresponding to the bits not set. - */ - virtual bool setSocketOptions(int opts); - - /** - * Retrieves the socket options that have been set. - * - * The default implementation just retrieves the mask from an internal variable. - * Descended classes may choose to override this function to read the values - * from the operating system. - * - * @returns the mask of the options set - */ - virtual int socketOptions() const; - -public: - /** - * Sets this socket's blocking mode. - * - * In blocking operation, all I/O functions are susceptible to blocking -- - * i.e., will not return unless the I/O can be satisfied. In non-blocking - * operation, if the I/O would block, the function will return an error - * and set the corresponding error code. - * - * The default implementation toggles the Blocking flag with the current - * socket options and calls @ref setSocketOptions. - * - * @param enable whether to set this socket to blocking mode - * @returns whether setting this value was successful; it is NOT the - * final blocking mode. - */ - virtual bool setBlocking(bool enable); - - /** - * Retrieves this socket's blocking mode. - * - * @returns true if this socket is/will be operated in blocking mode, - * false if non-blocking. - */ - bool blocking() const; - - /** - * Sets this socket's address reuseable flag. - * - * When the address reuseable flag is active, the address used by - * this socket is left reuseable for other sockets to bind. If - * the flag is not active, no other sockets may reuse the same - * address. - * - * The default implementation toggles the AddressReuseable flag with the current - * socket options and calls @ref setSocketOptions. - * - * @param enable whether to set the flag on or off - * @returns true if setting this flag was successful - */ - virtual bool setAddressReuseable(bool enable); - - /** - * Retrieves this socket's address reuseability flag. - * - * @returns true if this socket's address can be reused, - * false if it can't. - */ - bool addressReuseable() const; - - /** - * Sets this socket's IPv6 Only flag. - * - * When this flag is on, an IPv6 socket will only accept, connect, send to or - * receive from IPv6 addresses. When it is off, it will also talk to - * IPv4 addresses through v4-mapped addresses. - * - * This option has no effect on non-IPv6 sockets. - * - * The default implementation toggles the IPv6Only flag with the current - * socket options and calls @ref setSocketOptions. - * - * @param enable whether to set the flag on or off - * @returns true if setting this flag was successful - */ - virtual bool setIPv6Only(bool enable); - - /** - * Retrieves this socket's IPv6 Only flag. - * - * @returns true if this socket will ignore IPv4-compatible and IPv4-mapped - * addresses, false if it will accept them. - */ - bool isIPv6Only() const; - - /** - * Sets this socket Broadcast flag. - * - * Datagram-oriented sockets cannot normally send packets to broadcast - * addresses, nor will they receive packets that were sent to a broadcast - * address. To do so, you need to enable the Broadcast flag. - * - * This option has no effect on stream-oriented sockets. - * - * @returns true if setting this flag was successful. - */ - virtual bool setBroadcast(bool enable); - - /** - * Retrieves this socket's Broadcast flag. - * - * @returns true if this socket can send and receive broadcast packets, - * false if it can't. - */ - bool broadcast() const; - - /** - * Retrieves the socket implementation used on this socket. - * - * This function creates the device if none has been set - * using the default factory. - */ - KSocketDevice* socketDevice() const; - - /** - * Sets the socket implementation to be used on this socket. - * - * Note: it is an error to set this if the socket device has - * already been set once. - * - * This function is provided virtual so that derived classes can catch - * the setting of a device and properly set their own states and internal - * variables. The parent class must be called. - * - * This function is called by @ref socketDevice above when the socket is - * first created. - */ - virtual void setSocketDevice(KSocketDevice* device); - - /** - * Sets the internally requested capabilities for a socket device. - * - * Most socket classes can use any back-end implementation. However, a few - * may require specific capabilities not provided in the default - * implementation. By using this function, derived classes can request - * that a backend with those capabilities be created when necessary. - * - * For the possible flags, see @ref KSocketDevice::Capabilities. However, note - * that only the Can* flags make sense in this context. - * - * @note Since socketDevice must always return a valid backend object, it - * is is possible that the created device does not conform to all - * requirements requested. Implementations sensitive to this fact - * should test the object returned by @ref socketDevice (through - * @ref KSocketDevice::capabilities, for instance) the availability. - * - * @param add mask of @ref KSocketDevice::Capabilities to add - * @param remove mask of bits to remove from the requirements - * @return the current mask of requested capabilities - */ - int setRequestedCapabilities(int add, int remove = 0); - -protected: - /** - * Returns true if the socket device has been initialised in this - * object, either by calling @ref socketDevice() or @ref setSocketDevice - */ - bool hasDevice() const; - - /** - * Sets the socket's error code. - * - * @param error the error code - */ - void setError(SocketError error); - -public: - /** - * Retrieves the socket error code. - * @sa errorString - */ - SocketError error() const; - - /** - * Returns the error string corresponding to this error condition. - */ - inline TQString errorString() const - { return errorString(error()); } - - /** - * Returns the internal mutex for this class. - * - * Note on multithreaded use of sockets: - * the socket classes are thread-safe by design, but you should be aware of - * problems regarding socket creation, connection and destruction in - * multi-threaded programs. The classes are guaranteed to work while - * the socket exists, but it's not wise to call connect in multiple - * threads. - * - * Also, this mutex must be unlocked before the object is destroyed, which - * means you cannot use it to guard against other threads accessing the object - * while destroying it. You must ensure there are no further references to this - * object when deleting it. - */ - TQMutex* mutex() const; - -public: - /** - * Returns the string describing the given error code, i18n'ed. - * - * @param code the error code - */ - static TQString errorString(SocketError code); - - /** - * Returns true if the given error code is a fatal one, false - * otherwise. The parameter here is of type int so that - * casting isn't necessary when using the parameter to signal - * QClientSocketBase::gotError. - * - * @param code the code to test - */ - static bool isFatalError(int code); - -private: - /// @internal - /// called by KSocketDevice - void unsetSocketDevice(); - - KSocketBase(const KSocketBase&); - KSocketBase& operator =(const KSocketBase&); - - KSocketBasePrivate *d; - - friend class KSocketDevice; -}; - -/** - * @class KActiveSocketBase ksocketbase.h ksocketbase.h - * @brief Abstract class for active sockets - * - * This class provides the standard interfaces for active sockets, i.e., - * sockets that are used to connect to external addresses. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KActiveSocketBase: public TQIODevice, virtual public KSocketBase -{ -public: - /** - * Constructor. - */ - KActiveSocketBase(); - - /** - * Destructor. - */ - virtual ~KActiveSocketBase(); - - /** - * Binds this socket to the given address. - * - * The socket will be constructed with the address family, - * socket type and protocol as those given in the - * @p address object. - * - * @param address the address to bind to - * @returns true if the binding was successful, false otherwise - */ - virtual bool bind(const KResolverEntry& address) = 0; - - /** - * Connect to a remote host. - * - * This will make this socket try to connect to the remote host. - * If the socket is not yet created, it will be created using the - * address family, socket type and protocol specified in the - * @p address object. - * - * If this function returns with error InProgress, calling it - * again with the same address after a time will cause it to test - * if the connection has succeeded in the mean time. - * - * @param address the address to connect to - * @returns true if the connection was successful or has been successfully - * queued; false if an error occurred. - */ - virtual bool connect(const KResolverEntry& address) = 0; - - /** - * Disconnects this socket from a connection, if possible. - * - * If this socket was connected to an endpoint, the connection - * is severed, but the socket is not closed. If the socket wasn't - * connected, this function does nothing. - * - * If the socket hadn't yet been created, this function does nothing - * either. - * - * Not all socket types can disconnect. Most notably, only - * connectionless datagram protocols such as UDP support this operation. - * - * @return true if the socket is now disconnected or false on error. - */ - virtual bool disconnect() = 0; - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - * This will always return 0. - */ -#ifdef USE_QT4 - virtual qint64 size() const -#else // USE_QT4 - virtual Offset size() const -#endif // USE_QT4 - { return 0; } - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - * This will always return 0. - */ - virtual Offset at() const - { return 0; } - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - * This will always return false. - */ - virtual bool at(Offset) - { return false; } - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - * This will always return true. - */ - virtual bool atEnd() const - { return true; } - - /** - * Returns the number of bytes available for reading without - * blocking. - */ -#ifdef USE_QT3 - virtual TQ_LONG bytesAvailable() const = 0; -#endif -#ifdef USE_QT4 - virtual qint64 bytesAvailable() const = 0; -#endif - - /** - * Waits up to @p msecs for more data to be available on this socket. - * - * If msecs is -1, this call will block indefinetely until more data - * is indeed available; if it's 0, this function returns immediately. - * - * If @p timeout is not NULL, this function will set it to indicate - * if a timeout occurred. - * - * @returns the number of bytes available - */ - virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L) = 0; - - /** - * Reads data from the socket. - * - * Reimplemented from TQIODevice. See TQIODevice::readBlock for - * more information. - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG len) = 0; - - /** @overload - * Receives data and the source address. - * - * This call will read data in the socket and will also - * place the sender's address in @p from object. - * - * @param data where to write the read data to - * @param maxlen the maximum number of bytes to read - * @param from the address of the sender will be stored here - * @returns the actual number of bytes read - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from) = 0; - - /** - * Peeks the data in the socket. - * - * This call will allow you to peek the data to be received without actually - * receiving it -- that is, it will be available for further peekings and - * for the next read call. - * - * @param data where to write the peeked data to - * @param maxlen the maximum number of bytes to peek - * @returns the actual number of bytes copied into @p data - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen) = 0; - - /** @overload - * Peeks the data in the socket and the source address. - * - * This call will allow you to peek the data to be received without actually - * receiving it -- that is, it will be available for further peekings and - * for the next read call. - * - * @param data where to write the peeked data to - * @param maxlen the maximum number of bytes to peek - * @param from the address of the sender will be stored here - * @returns the actual number of bytes copied into @p data - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from) = 0; - - /** - * Writes the given data to the socket. - * - * Reimplemented from TQIODevice. See TQIODevice::writeBlock for - * more information. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len) = 0; - - /** @overload - * Writes the given data to the destination address. - * - * Note that not all socket connections allow sending data to different - * addresses than the one the socket is connected to. - * - * @param data the data to write - * @param len the length of the data - * @param to the address to send to - * @returns the number of bytes actually sent - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to) = 0; - - /** - * Reads one character from the socket. - * Reimplementation from TQIODevice. See TQIODevice::getch for more information. - */ - virtual int getch(); - - /** - * Writes one character to the socket. - * Reimplementation from TQIODevice. See TQIODevice::putch for more information. - */ - virtual int putch(int ch); - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - * This will always return -1; - */ - virtual int ungetch(int) - { return -1; } - - /** - * Returns this socket's local address. - */ - virtual KSocketAddress localAddress() const = 0; - - /** - * Return this socket's peer address, if we are connected. - * If the address cannot be retrieved, the returned object will contain - * an invalid address. - */ - virtual KSocketAddress peerAddress() const = 0; - - // FIXME KDE 4.0: - // enable this function -#if 0 - /** - * Returns this socket's externally-visible address, if known. - */ - virtual KSocketAddress externalAddress() const = 0; -#endif - -protected: - /** - * Sets the socket's error code and the I/O Device's status. - * - * @param status the I/O Device status - * @param error the error code - */ - void setError(int status, SocketError error); - - /** - * Resets the socket error code and the I/O Device's status. - */ - void resetError(); -}; - -/** - * @class KPassiveSocketBase ksocketbase.h ksocketbase.h - * @brief Abstract base class for passive sockets. - * - * This socket provides the initial functionality for passive sockets, - * i.e., sockets that accept incoming connections. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KPassiveSocketBase: virtual public KSocketBase -{ -public: - /** - * Constructor - */ - KPassiveSocketBase(); - - /** - * Destructor - */ - virtual ~KPassiveSocketBase(); - - /** - * Binds this socket to the given address. - * - * The socket will be constructed with the address family, - * socket type and protocol as those given in the - * @p address object. - * - * @param address the address to bind to - * @returns true if the binding was successful, false otherwise - */ - virtual bool bind(const KResolverEntry& address) = 0; - - /** - * Puts this socket into listening mode. - * - * Placing a socket in listening mode means that it will - * be allowed to receive incoming connections from - * remote hosts. - * - * Note that some socket types or protocols cannot be - * put in listening mode. - * - * @param backlog the number of accepted connections to - * hold before starting to refuse - * @returns true if the socket is now in listening mode - */ - virtual bool listen(int backlog) = 0; - - /** - * Closes this socket. All resources used are freed. Note that closing - * a passive socket does not close the connections accepted with it. - */ - virtual void close() = 0; - - /** - * Accepts a new incoming connection. - * - * If this socket was in listening mode, you can call this - * function to accept an incoming connection. - * - * If this function cannot accept a new connection (either - * because it is not listening for one or because the operation - * would block), it will return NULL. - * - * Also note that descended classes will override this function - * to return specialised socket classes. - */ - virtual KActiveSocketBase* accept() = 0; - - /** - * Returns this socket's local address. - */ - virtual KSocketAddress localAddress() const = 0; - - /** - * Returns this socket's externally-visible address if known. - */ - virtual KSocketAddress externalAddress() const = 0; - -private: - KPassiveSocketBase(const KPassiveSocketBase&); - KPassiveSocketBase& operator = (const KPassiveSocketBase&); -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/ksocketbuffer.cpp b/kdecore/network/ksocketbuffer.cpp deleted file mode 100644 index aacffde45..000000000 --- a/kdecore/network/ksocketbuffer.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <assert.h> -#include <string.h> - -#include "ksocketbase.h" -#include "ksocketbuffer_p.h" - -using namespace KNetwork; -using namespace KNetwork::Internal; - -KSocketBuffer::KSocketBuffer(TQ_LONG size) - : m_mutex(true), m_offset(0), m_size(size), m_length(0) -{ -} - -KSocketBuffer::KSocketBuffer(const KSocketBuffer& other) - : KIOBufferBase(other), m_mutex(true) -{ - *this = other; -} - -KSocketBuffer::~KSocketBuffer() -{ - // TQValueList takes care of deallocating memory -} - -KSocketBuffer& KSocketBuffer::operator=(const KSocketBuffer& other) -{ - TQMutexLocker locker1(&m_mutex); - TQMutexLocker locker2(&other.m_mutex); - - KIOBufferBase::operator=(other); - - m_list = other.m_list; // copy-on-write - m_offset = other.m_offset; - m_size = other.m_size; - m_length = other.m_length; - - return *this; -} - -bool KSocketBuffer::canReadLine() const -{ - TQMutexLocker locker(&m_mutex); - - TQValueListConstIterator<TQByteArray> it = m_list.constBegin(), - end = m_list.constEnd(); - TQIODevice::Offset offset = m_offset; - - // walk the buffer - for ( ; it != end; ++it) - { - if ((*it).find('\n', offset) != -1) - return true; - if ((*it).find('\r', offset) != -1) - return true; - offset = 0; - } - - return false; // not found -} - -TQCString KSocketBuffer::readLine() -{ - if (!canReadLine()) - return TQCString(); // empty - - TQMutexLocker locker(&m_mutex); - - // find the offset of the newline in the buffer - int newline = 0; - TQValueListConstIterator<TQByteArray> it = m_list.constBegin(), - end = m_list.constEnd(); - TQIODevice::Offset offset = m_offset; - - // walk the buffer - for ( ; it != end; ++it) - { - int posnl = (*it).find('\n', offset); - if (posnl == -1) - { - // not found in this one - newline += (*it).size(); - offset = 0; - continue; - } - - // we found it - newline += posnl; - break; - } - - TQCString result(newline + 2 - m_offset); - consumeBuffer(result.data(), newline + 1 - m_offset); - return result; -} - -TQ_LONG KSocketBuffer::length() const -{ - return m_length; -} - -TQ_LONG KSocketBuffer::size() const -{ - return m_size; -} - -bool KSocketBuffer::setSize(TQ_LONG size) -{ - m_size = size; - if (size == -1 || m_length < m_size) - return true; - - // size is now smaller than length - TQMutexLocker locker(&m_mutex); - - // repeat the test - if (m_length < m_size) - return true; - - // discard from the beginning - return (m_length - m_size) == consumeBuffer(0L, m_length - m_size, true); -} - -TQ_LONG KSocketBuffer::feedBuffer(const char *data, TQ_LONG len) -{ - if (data == 0L || len == 0) - return 0; // nothing to write - if (isFull()) - return -1; // can't write - - TQMutexLocker locker(&m_mutex); - - // verify if we can add len bytes - if (m_size != -1 && (m_size - m_length) < len) - len = m_size - m_length; - - TQByteArray a(len); - a.duplicate(data, len); - m_list.append(a); - - m_length += len; - return len; -} - -TQ_LONG KSocketBuffer::consumeBuffer(char *destbuffer, TQ_LONG maxlen, bool discard) -{ - if (maxlen == 0 || isEmpty()) - return 0; - - TQValueListIterator<TQByteArray> it = m_list.begin(), - end = m_list.end(); - TQIODevice::Offset offset = m_offset; - TQ_LONG copied = 0; - - // walk the buffer - while (it != end && maxlen) - { - // calculate how much we'll copy - size_t to_copy = (*it).size() - offset; - if (to_copy > maxlen) - to_copy = maxlen; - - // do the copying - if (destbuffer) - memcpy(destbuffer + copied, (*it).data() + offset, to_copy); - maxlen -= to_copy; - copied += to_copy; - - if ((*it).size() - offset > to_copy) - { - // we did not copy everything - offset += to_copy; - break; - } - else - { - // we copied everything - // discard this element; - offset = 0; - if (discard) - it = m_list.remove(it); - else - ++it; - } - } - - if (discard) - { - m_offset = offset; - m_length -= copied; - assert(m_length >= 0); - } - - return copied; -} - -void KSocketBuffer::clear() -{ - TQMutexLocker locker(&m_mutex); - m_list.clear(); - m_offset = 0; - m_length = 0; -} - -TQ_LONG KSocketBuffer::sendTo(KActiveSocketBase* dev, TQ_LONG len) -{ - if (len == 0 || isEmpty()) - return 0; - - TQMutexLocker locker(&m_mutex); - - TQValueListIterator<TQByteArray> it = m_list.begin(), - end = m_list.end(); - TQIODevice::Offset offset = m_offset; - TQ_LONG written = 0; - - // walk the buffer - while (it != end && (len || len == -1)) - { - // we have to write each element up to len bytes - // but since we can have several very small buffers, we can make things - // better by concatenating a few of them into a big buffer - // question is: how big should that buffer be? 2 kB should be enough - - TQ_ULONG bufsize = 1460; - if (len != -1 && len < bufsize) - bufsize = len; - TQByteArray buf(bufsize); - TQ_LONG count = 0; - - while (it != end && count + ((*it).size() - offset) <= bufsize) - { - memcpy(buf.data() + count, (*it).data() + offset, (*it).size() - offset); - count += (*it).size() - offset; - offset = 0; - ++it; - } - - // see if we can still fit more - if (count < bufsize && it != end) - { - // getting here means this buffer (*it) is larger than - // (bufsize - count) (even for count == 0). - memcpy(buf.data() + count, (*it).data() + offset, bufsize - count); - offset += bufsize - count; - count = bufsize; - } - - // now try to write those bytes - TQ_LONG wrote = dev->tqwriteBlock(buf, count); - - if (wrote == -1) - // error? - break; - - written += wrote; - if (wrote != count) - // can't fit more? - break; - } - - // discard data that has been written - // this updates m_length too - if (written) - consumeBuffer(0L, written); - - return written; -} - -TQ_LONG KSocketBuffer::receiveFrom(KActiveSocketBase* dev, TQ_LONG len) -{ - if (len == 0 || isFull()) - return 0; - - TQMutexLocker locker(&m_mutex); - - if (len == -1) - len = dev->bytesAvailable(); - if (len <= 0) - // error or closing socket - return len; - - // see if we can read that much - if (m_size != -1 && len > (m_size - m_length)) - len = m_size - m_length; - - // here, len contains just as many bytes as we're supposed to read - - // now do the reading - TQByteArray a(len); - len = dev->tqreadBlock(a.data(), len); - - if (len == -1) - // error? - return -1; - - // success - // resize the buffer and add it - a.truncate(len); - m_list.append(a); - m_length += len; - return len; -} diff --git a/kdecore/network/ksocketbuffer_p.h b/kdecore/network/ksocketbuffer_p.h deleted file mode 100644 index 0b8e96205..000000000 --- a/kdecore/network/ksocketbuffer_p.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KSOCKETBUFFER_P_H -#define KSOCKETBUFFER_P_H - -#include <tqmutex.h> -#include <tqcstring.h> -#include <tqvaluelist.h> -#include "kiobuffer.h" - -namespace KNetwork { - -class KActiveSocketBase; - - namespace Internal { - -/** - * @internal - * @class KSocketBuffer ksocketbuffer_p.h ksocketbuffer_p.h - * @brief generic socket buffering code - * - * This class implements generic buffering used by @ref KBufferedSocket. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KSocketBuffer: public KIOBufferBase -{ -public: - /** - * Default constructor. - * - * @param size the maximum size of the buffer - */ - KSocketBuffer(TQ_LONG size = -1); - - /** - * Copy constructor. - */ - KSocketBuffer(const KSocketBuffer& other); - - /** - * Virtual destructor. Frees the buffer and discards its contents. - */ - virtual ~KSocketBuffer(); - - /** - * Assignment operator. - */ - KSocketBuffer& operator=(const KSocketBuffer& other); - - /** - * Returns true if a line can be read from the buffer. - */ - virtual bool canReadLine() const; - - /** - * Reads a line from the buffer and discard it from the buffer. - */ - virtual TQCString readLine(); - - /** - * Returns the number of bytes in the buffer. Note that this is not - * the size of the buffer. - * - * @sa size - */ - virtual TQ_LONG length() const; - - /** - * Retrieves the buffer size. The value of -1 indicates that - * the buffer has no defined upper limit. - * - * @sa length for the length of the data stored - */ - virtual TQ_LONG size() const; - - /** - * Sets the size of the buffer, if allowed. - * - * @param size the maximum size, use -1 for unlimited. - * @returns true on success, false if an error occurred. - * @note if the new size is less than length(), the buffer will be truncated - */ - virtual bool setSize(TQ_LONG size); - - /** - * Adds data to the end of the buffer. - * - * @param data the data to be added - * @param len the data length, in bytes - * @returns the number of bytes added to the end of the buffer. - */ - virtual TQ_LONG feedBuffer(const char *data, TQ_LONG len); - - /** - * Clears the buffer. - */ - virtual void clear(); - - /** - * Consumes data from the beginning of the buffer. - * - * @param data where to copy the data to - * @param maxlen the maximum length to copy, in bytes - * @param discard if true, the bytes copied will be discarded - * @returns the number of bytes copied from the buffer - */ - virtual TQ_LONG consumeBuffer(char *data, TQ_LONG maxlen, bool discard = true); - - /** - * Sends at most @p len bytes of data to the I/O Device. - * - * @param device the device to which to send data - * @param len the amount of data to send; -1 to send everything - * @returns the number of bytes sent and discarded from the buffer, -1 - * indicates an error. - */ - virtual TQ_LONG sendTo(KActiveSocketBase* device, TQ_LONG len = -1); - - /** - * Tries to receive @p len bytes of data from the I/O device. - * - * @param device the device to receive from - * @param len the number of bytes to receive; -1 to read as much - * as possible - * @returns the number of bytes received and copied into the buffer, - * -1 indicates an error. - */ - virtual TQ_LONG receiveFrom(KActiveSocketBase* device, TQ_LONG len = -1); - -protected: - mutable TQMutex m_mutex; - TQValueList<TQByteArray> m_list; - TQIODevice::Offset m_offset; ///< offset of the start of data in the first element - - TQ_LONG m_size; ///< the maximum length of the buffer - mutable TQ_LONG m_length; -}; - -} } // namespace KNetwork::Internal - -#endif diff --git a/kdecore/network/ksocketdevice.cpp b/kdecore/network/ksocketdevice.cpp deleted file mode 100644 index 68651b8e2..000000000 --- a/kdecore/network/ksocketdevice.cpp +++ /dev/null @@ -1,891 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003,2005 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <tqmap.h> - -#ifdef USE_SOLARIS -# include <sys/filio.h> -#endif -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/time.h> -#include <sys/ioctl.h> -#include <errno.h> -#include <fcntl.h> -#include <netinet/in.h> -#include <unistd.h> - -#ifdef HAVE_POLL -# include <sys/poll.h> -#else -# ifdef HAVE_SYS_SELECT -# include <sys/select.h> -# endif -#endif - -// Include syssocket before our local includes -#include "syssocket.h" - -#include <tqmutex.h> -#include <tqsocketnotifier.h> - -#include "kresolver.h" -#include "ksocketaddress.h" -#include "ksocketbase.h" -#include "ksocketdevice.h" -#include "ksockssocketdevice.h" - -using namespace KNetwork; - -class KNetwork::KSocketDevicePrivate -{ -public: - mutable TQSocketNotifier *input, *output, *exception; - KSocketAddress local, peer; - int af; - - inline KSocketDevicePrivate() - { - input = output = exception = 0L; - af = 0; - } -}; - - -KSocketDevice::KSocketDevice(const KSocketBase* parent) - : m_sockfd(-1), d(new KSocketDevicePrivate) -{ - setSocketDevice(this); - if (parent) - setSocketOptions(parent->socketOptions()); -} - -KSocketDevice::KSocketDevice(int fd) - : m_sockfd(fd), d(new KSocketDevicePrivate) -{ - setState(IO_Open); - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - setSocketDevice(this); - d->af = localAddress().family(); -} - -KSocketDevice::KSocketDevice(bool, const KSocketBase* parent) - : m_sockfd(-1), d(new KSocketDevicePrivate) -{ - // do not set parent - if (parent) - setSocketOptions(parent->socketOptions()); -} - -KSocketDevice::~KSocketDevice() -{ - close(); // deletes the notifiers - unsetSocketDevice(); // prevent double deletion - delete d; -} - -bool KSocketDevice::setSocketOptions(int opts) -{ - // must call parent - TQMutexLocker locker(mutex()); - KSocketBase::setSocketOptions(opts); - - if (m_sockfd == -1) - return true; // flags are stored - - { - int fdflags = fcntl(m_sockfd, F_GETFL, 0); - if (fdflags == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; // error - } - - if (opts & Blocking) - fdflags &= ~O_NONBLOCK; - else - fdflags |= O_NONBLOCK; - - if (fcntl(m_sockfd, F_SETFL, fdflags) == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; // error - } - } - - { - int on = opts & AddressReuseable ? 1 : 0; - if (setsockopt(m_sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on)) == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; // error - } - } - -#if defined(IPV6_V6ONLY) && defined(AF_INET6) - if (d->af == AF_INET6) - { - // don't try this on non-IPv6 sockets, or we'll get an error - - int on = opts & IPv6Only ? 1 : 0; - if (setsockopt(m_sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&on, sizeof(on)) == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; // error - } - } -#endif - - { - int on = opts & Broadcast ? 1 : 0; - if (setsockopt(m_sockfd, SOL_SOCKET, SO_BROADCAST, (char*)&on, sizeof(on)) == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; // error - } - } - - return true; // all went well -} - -bool KSocketDevice::open(TQ_OpenMode) -{ - resetError(); - return false; -} - -void KSocketDevice::close() -{ - resetError(); - if (m_sockfd != -1) - { - delete d->input; - delete d->output; - delete d->exception; - - d->input = d->output = d->exception = 0L; - - d->local.setFamily(AF_UNSPEC); - d->peer.setFamily(AF_UNSPEC); - - ::close(m_sockfd); - } - setState(0); - - m_sockfd = -1; -} - -bool KSocketDevice::create(int family, int type, int protocol) -{ - resetError(); - - if (m_sockfd != -1) - { - // it's already created! - setError(IO_SocketCreateError, AlreadyCreated); - return false; - } - - // no socket yet; we have to create it - m_sockfd = kde_socket(family, type, protocol); - - if (m_sockfd == -1) - { - setError(IO_SocketCreateError, NotSupported); - return false; - } - - d->af = family; - setSocketOptions(socketOptions()); - setState(IO_Open); - return true; // successfully created -} - -bool KSocketDevice::create(const KResolverEntry& address) -{ - return create(address.family(), address.socketType(), address.protocol()); -} - -bool KSocketDevice::bind(const KResolverEntry& address) -{ - resetError(); - - if (m_sockfd == -1 && !create(address)) - return false; // failed creating - - // we have a socket, so try and bind - if (kde_bind(m_sockfd, address.address(), address.length()) == -1) - { - if (errno == EADDRINUSE) - setError(IO_BindError, AddressInUse); - else if (errno == EINVAL) - setError(IO_BindError, AlreadyBound); - else - // assume the address is the cause - setError(IO_BindError, NotSupported); - return false; - } - - return true; -} - -bool KSocketDevice::listen(int backlog) -{ - if (m_sockfd != -1) - { - if (kde_listen(m_sockfd, backlog) == -1) - { - setError(IO_ListenError, NotSupported); - return false; - } - - resetError(); - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - return true; - } - - // we don't have a socket - // can't listen - setError(IO_ListenError, NotCreated); - return false; -} - -bool KSocketDevice::connect(const KResolverEntry& address) -{ - resetError(); - - if (m_sockfd == -1 && !create(address)) - return false; // failed creating! - - if (kde_connect(m_sockfd, address.address(), address.length()) == -1) - { - if (errno == EISCONN) - return true; // we're already connected - else if (errno == EALREADY || errno == EINPROGRESS) - { - setError(IO_ConnectError, InProgress); - return true; - } - else if (errno == ECONNREFUSED) - setError(IO_ConnectError, ConnectionRefused); - else if (errno == ENETDOWN || errno == ENETUNREACH || - errno == ENETRESET || errno == ECONNABORTED || - errno == ECONNRESET || errno == EHOSTDOWN || - errno == EHOSTUNREACH) - setError(IO_ConnectError, NetFailure); - else - setError(IO_ConnectError, NotSupported); - - return false; - } - - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - return true; // all is well -} - -KSocketDevice* KSocketDevice::accept() -{ - if (m_sockfd == -1) - { - // can't accept without a socket - setError(IO_AcceptError, NotCreated); - return 0L; - } - - struct sockaddr sa; - socklen_t len = sizeof(sa); - int newfd = kde_accept(m_sockfd, &sa, &len); - if (newfd == -1) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) - setError(IO_AcceptError, WouldBlock); - else - setError(IO_AcceptError, UnknownError); - return NULL; - } - - return new KSocketDevice(newfd); -} - -bool KSocketDevice::disconnect() -{ - resetError(); - - if (m_sockfd == -1) - return false; // can't create - - KSocketAddress address; - address.setFamily(AF_UNSPEC); - if (kde_connect(m_sockfd, address.address(), address.length()) == -1) - { - if (errno == EALREADY || errno == EINPROGRESS) - { - setError(IO_ConnectError, InProgress); - return false; - } - else if (errno == ECONNREFUSED) - setError(IO_ConnectError, ConnectionRefused); - else if (errno == ENETDOWN || errno == ENETUNREACH || - errno == ENETRESET || errno == ECONNABORTED || - errno == ECONNRESET || errno == EHOSTDOWN || - errno == EHOSTUNREACH) - setError(IO_ConnectError, NetFailure); - else - setError(IO_ConnectError, NotSupported); - - return false; - } - - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - setState(IO_Open); - return true; // all is well -} - -#ifdef USE_QT3 -TQ_LONG KSocketDevice::bytesAvailable() const -#endif -#ifdef USE_QT4 -qint64 KSocketDevice::bytesAvailable() const -#endif -{ - if (m_sockfd == -1) - return -1; // there's nothing to read in a closed socket - - int nchars; - if (ioctl(m_sockfd, FIONREAD, &nchars) == -1) - return -1; // error! - - return nchars; -} - -TQ_LONG KSocketDevice::waitForMore(int msecs, bool *timeout) -{ - if (m_sockfd == -1) - return -1; // there won't ever be anything to read... - - bool input; - if (!poll(&input, 0, 0, msecs, timeout)) - return -1; // failed polling - - return bytesAvailable(); -} - -static int do_read_common(int sockfd, char *data, TQ_ULONG maxlen, KSocketAddress* from, ssize_t &retval, bool peek = false) -{ - socklen_t len; - if (from) - { - from->setLength(len = 128); // arbitrary length - retval = ::recvfrom(sockfd, data, maxlen, peek ? MSG_PEEK : 0, from->address(), &len); - } - else - retval = ::recvfrom(sockfd, data, maxlen, peek ? MSG_PEEK : 0, NULL, NULL); - - if (retval == -1) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) - return KSocketDevice::WouldBlock; - else - return KSocketDevice::UnknownError; - } - if (retval == 0) - return KSocketDevice::RemotelyDisconnected; - - if (from) - from->setLength(len); - return 0; -} - -TQT_TQIO_LONG KSocketDevice::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen) -{ - resetError(); - if (m_sockfd == -1) - return -1; - - if (maxlen == 0 || data == 0L) - return 0; // can't read - - ssize_t retval; - int err = do_read_common(m_sockfd, data, maxlen, 0L, retval); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQT_TQIO_LONG KSocketDevice::tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress &from) -{ - resetError(); - if (m_sockfd == -1) - return -1; // nothing to do here - - if (data == 0L || maxlen == 0) - return 0; // user doesn't want to read - - ssize_t retval; - int err = do_read_common(m_sockfd, data, maxlen, &from, retval); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQ_LONG KSocketDevice::peekBlock(char *data, TQ_ULONG maxlen) -{ - resetError(); - if (m_sockfd == -1) - return -1; - - if (maxlen == 0 || data == 0L) - return 0; // can't read - - ssize_t retval; - int err = do_read_common(m_sockfd, data, maxlen, 0L, retval, true); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQ_LONG KSocketDevice::peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from) -{ - resetError(); - if (m_sockfd == -1) - return -1; // nothing to do here - - if (data == 0L || maxlen == 0) - return 0; // user doesn't want to read - - ssize_t retval; - int err = do_read_common(m_sockfd, data, maxlen, &from, retval, true); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQT_TQIO_LONG KSocketDevice::tqwriteBlock(const char *data, TQT_TQIO_ULONG len) -{ - return tqwriteBlock(data, len, KSocketAddress()); -} - -TQT_TQIO_LONG KSocketDevice::tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to) -{ - resetError(); - if (m_sockfd == -1) - return -1; // can't write to unopen socket - - if (data == 0L || len == 0) - return 0; // nothing to be written - - ssize_t retval = ::sendto(m_sockfd, data, len, 0, to.address(), to.length()); - if (retval == -1) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) - setError(IO_WriteError, WouldBlock); - else - setError(IO_WriteError, UnknownError); - return -1; // nothing written - } - else if (retval == 0) - setError(IO_WriteError, RemotelyDisconnected); - - return retval; -} - -KSocketAddress KSocketDevice::localAddress() const -{ - if (m_sockfd == -1) - return KSocketAddress(); // not open, empty value - - if (d->local.family() != AF_UNSPEC) - return d->local; - - socklen_t len; - KSocketAddress localAddress; - localAddress.setLength(len = 32); // arbitrary value - if (kde_getsockname(m_sockfd, localAddress.address(), &len) == -1) - // error! - return d->local = KSocketAddress(); - -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - len = localAddress.address()->sa_len; -#endif - - if (len <= localAddress.length()) - { - // it has fit already - localAddress.setLength(len); - return d->local = localAddress; - } - - // no, the socket address is actually larger than we had anticipated - // call again - localAddress.setLength(len); - if (kde_getsockname(m_sockfd, localAddress.address(), &len) == -1) - // error! - return d->local = KSocketAddress(); - - return d->local = localAddress; -} - -KSocketAddress KSocketDevice::peerAddress() const -{ - if (m_sockfd == -1) - return KSocketAddress(); // not open, empty value - - if (d->peer.family() != AF_UNSPEC) - return d->peer; - - socklen_t len; - KSocketAddress peerAddress; - peerAddress.setLength(len = 32); // arbitrary value - if (kde_getpeername(m_sockfd, peerAddress.address(), &len) == -1) - // error! - return d->peer = KSocketAddress(); - -#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - len = peerAddress.address()->sa_len; -#endif - - if (len <= peerAddress.length()) - { - // it has fit already - peerAddress.setLength(len); - return d->peer = peerAddress; - } - - // no, the socket address is actually larger than we had anticipated - // call again - peerAddress.setLength(len); - if (kde_getpeername(m_sockfd, peerAddress.address(), &len) == -1) - // error! - return d->peer = KSocketAddress(); - - return d->peer = peerAddress; -} - -KSocketAddress KSocketDevice::externalAddress() const -{ - // for normal sockets, the externally visible address is the same - // as the local address - return localAddress(); -} - -TQSocketNotifier* KSocketDevice::readNotifier() const -{ - if (d->input) - return d->input; - - TQMutexLocker locker(mutex()); - if (d->input) - return d->input; - - if (m_sockfd == -1) - { - // socket doesn't exist; can't create notifier - return 0L; - } - - return d->input = createNotifier(TQSocketNotifier::Read); -} - -TQSocketNotifier* KSocketDevice::writeNotifier() const -{ - if (d->output) - return d->output; - - TQMutexLocker locker(mutex()); - if (d->output) - return d->output; - - if (m_sockfd == -1) - { - // socket doesn't exist; can't create notifier - return 0L; - } - - return d->output = createNotifier(TQSocketNotifier::Write); -} - -TQSocketNotifier* KSocketDevice::exceptionNotifier() const -{ - if (d->exception) - return d->exception; - - TQMutexLocker locker(mutex()); - if (d->exception) - return d->exception; - - if (m_sockfd == -1) - { - // socket doesn't exist; can't create notifier - return 0L; - } - - return d->exception = createNotifier(TQSocketNotifier::Exception); -} - -bool KSocketDevice::poll(bool *input, bool *output, bool *exception, - int timeout, bool* timedout) -{ - if (m_sockfd == -1) - { - setError(IO_UnspecifiedError, NotCreated); - return false; - } - - resetError(); -#ifdef HAVE_POLL - struct pollfd fds; - fds.fd = m_sockfd; - fds.events = 0; - - if (input) - { - fds.events |= POLLIN; - *input = false; - } - if (output) - { - fds.events |= POLLOUT; - *output = false; - } - if (exception) - { - fds.events |= POLLPRI; - *exception = false; - } - - int retval = ::poll(&fds, 1, timeout); - if (retval == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; - } - if (retval == 0) - { - // timeout - if (timedout) - *timedout = true; - return true; - } - - if (input && fds.revents & POLLIN) - *input = true; - if (output && fds.revents & POLLOUT) - *output = true; - if (exception && fds.revents & POLLPRI) - *exception = true; - if (timedout) - *timedout = false; - - return true; -#else - /* - * We don't have poll(2). We'll have to make do with select(2). - */ - - fd_set readfds, writefds, exceptfds; - fd_set *preadfds = 0L, *pwritefds = 0L, *pexceptfds = 0L; - - if (input) - { - preadfds = &readfds; - FD_ZERO(preadfds); - FD_SET(m_sockfd, preadfds); - *input = false; - } - if (output) - { - pwritefds = &writefds; - FD_ZERO(pwritefds); - FD_SET(m_sockfd, pwritefds); - *output = false; - } - if (exception) - { - pexceptfds = &exceptfds; - FD_ZERO(pexceptfds); - FD_SET(m_sockfd, pexceptfds); - *exception = false; - } - - int retval; - if (timeout < 0) - retval = select(m_sockfd + 1, preadfds, pwritefds, pexceptfds, 0L); - else - { - // convert the milliseconds to timeval - struct timeval tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = timeout % 1000 * 1000; - - retval = select(m_sockfd + 1, preadfds, pwritefds, pexceptfds, &tv); - } - - if (retval == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; - } - if (retval == 0) - { - // timeout - if (timedout) - *timedout = true; - return true; - } - - if (input && FD_ISSET(m_sockfd, preadfds)) - *input = true; - if (output && FD_ISSET(m_sockfd, pwritefds)) - *output = true; - if (exception && FD_ISSET(m_sockfd, pexceptfds)) - *exception = true; - - return true; -#endif -} - -bool KSocketDevice::poll(int timeout, bool *timedout) -{ - bool input, output, exception; - return poll(&input, &output, &exception, timeout, timedout); -} - -TQSocketNotifier* KSocketDevice::createNotifier(TQSocketNotifier::Type type) const -{ - if (m_sockfd == -1) - return 0L; - - return new TQSocketNotifier(m_sockfd, type); -} - -namespace -{ - // simple class to avoid pointer stuff - template<class T> class ptr - { - typedef T type; - type* obj; - public: - ptr() : obj(0) - { } - - ptr(const ptr<T>& other) : obj(other.obj) - { } - - ptr(type* _obj) : obj(_obj) - { } - - ~ptr() - { } - - ptr<T>& operator=(const ptr<T>& other) - { obj = other.obj; return *this; } - - ptr<T>& operator=(T* _obj) - { obj = _obj; return *this; } - - type* operator->() const { return obj; } - - operator T*() const { return obj; } - - bool isNull() const - { return obj == 0; } - }; -} - -static KSocketDeviceFactoryBase* defaultImplFactory; -static TQMutex defaultImplFactoryMutex; -typedef TQMap<int, KSocketDeviceFactoryBase* > factoryMap; -static factoryMap factories; - -KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent) -{ - KSocketDevice* device = dynamic_cast<KSocketDevice*>(parent); - if (device != 0L) - return device; - - KSocksSocketDevice::initSocks(); - - if (defaultImplFactory) - return defaultImplFactory->create(parent); - - // the really default - return new KSocketDevice(parent); -} - -KSocketDevice* KSocketDevice::createDefault(KSocketBase* parent, int capabilities) -{ - KSocketDevice* device = dynamic_cast<KSocketDevice*>(parent); - if (device != 0L) - return device; - - TQMutexLocker locker(&defaultImplFactoryMutex); - factoryMap::ConstIterator it = factories.constBegin(); - for ( ; it != factories.constEnd(); ++it) - if ((it.key() & capabilities) == capabilities) - // found a match - return it.data()->create(parent); - - return 0L; // no default -} - -KSocketDeviceFactoryBase* -KSocketDevice::setDefaultImpl(KSocketDeviceFactoryBase* factory) -{ - TQMutexLocker locker(&defaultImplFactoryMutex); - KSocketDeviceFactoryBase* old = defaultImplFactory; - defaultImplFactory = factory; - return old; -} - -void KSocketDevice::addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities) -{ - TQMutexLocker locker(&defaultImplFactoryMutex); - if (factories.contains(capabilities)) - delete factories[capabilities]; - factories.insert(capabilities, factory); -} - diff --git a/kdecore/network/ksocketdevice.h b/kdecore/network/ksocketdevice.h deleted file mode 100644 index 7c288b722..000000000 --- a/kdecore/network/ksocketdevice.h +++ /dev/null @@ -1,433 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KSOCKETDEVICE_H -#define KSOCKETDEVICE_H - -#include <tqsocketnotifier.h> -#include "ksocketbase.h" - -namespace KNetwork { - -class KSocketDevice; -class KSocketDeviceFactoryBase; - -class KSocketDevicePrivate; -/** @class KSocketDevice ksocketdevice.h ksocketdevice.h - * @brief Low-level socket functionality. - * - * This class provides low-level socket functionality. - * - * Most users will prefer "cooked" interfaces like those of @ref KStreamSocket or - * @ref KServerSocket. - * - * Descended classes from this one provide some other kinds of socket functionality, - * like proxying or specific socket types. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - */ -class KDECORE_EXPORT KSocketDevice: public KActiveSocketBase, public KPassiveSocketBase -{ -public: - /** - * Capabilities for the socket implementation. - * - * KSocketDevice-derived classes can implement certain capabilities that are not - * available in the default class. These capabilities are described by these flags. - * The default KSocketDevice class has none of these capabilities. - * - * For the negative capabilities (inabilities, the CanNot* forms), when a capability - * is not present, the implementation will default to the original behaviour. - */ - enum Capabilities - { - /** Can connect to hostnames. - * If this flag is present, the string form of @ref connect can be used. */ - CanConnectString = 0x01, - - /** Can bind to hostnames. - * If this flag is present, the string form of @ref bind can be used */ - CanBindString = 0x02, - - /** Can not bind. - * If this flag is present, this implementation cannot bind */ - CanNotBind = 0x04, - - /** Can not listen. - * If this flag is present, this implementation cannot listen */ - CanNotListen = 0x08, - - /** - * Can send multicast as well as join/leave multicast groups. - */ - CanMulticast = 0x10, - - /** - * Can not use datagrams. - * Note that this implies multicast capability not being available either. - */ - CanNotUseDatagrams = 0x20 - }; -protected: - /// The socket file descriptor. It is used throughout the implementation - /// and subclasses. - int m_sockfd; - -public: - /** - * Default constructor. - * - * The parameter is used to specify which socket this object is used as - * a device for. - */ - explicit KSocketDevice(const KSocketBase* = 0L); - - /** - * Constructs a new object around an already-open socket. - * - * Note: you should write programs that create sockets through - * the classes whenever possible. - */ - explicit KSocketDevice(int fd); - - /** - * Destructor. This closes the socket if it's open. - */ - virtual ~KSocketDevice(); - - /** - * Returns the file descriptor for this socket. - */ - inline int socket() const - { return m_sockfd; } - - /** - * Returns the set of capabilities this socket class implements. - * The set of capabilities is defined as an OR-ed mask of - * @ref Capabilities bits. - * - * The default implementation is guaranteed to always return 0. That - * is, derived implementations always return bits where they differ - * from the system standard sockets. - */ - virtual int capabilities() const - { return 0; } - - /** - * This implementation sets the options on the socket. - */ - virtual bool setSocketOptions(int opts); - - /** - * Reimplementation from TQIODevice. You should not call this function in sockets. - */ - virtual bool open(TQ_OpenMode mode); - - /** - * Closes the socket. Reimplemented from TQIODevice. - * - * Use this function to close the socket this object is holding open. - */ - virtual void close(); - - /** - * This call is not supported on sockets. Reimplemented from TQIODevice. - */ - virtual void flush() - { } - - /** - * Creates a socket but don't connect or bind anywhere. - * This function is the equivalent of the system call socket(2). - */ - virtual bool create(int family, int type, int protocol); - - /** - * @overload - * Creates a socket but don't connect or bind anywhere. - */ - bool create(const KResolverEntry& address); - - /** - * Binds this socket to the given address. - */ - virtual bool bind(const KResolverEntry& address); - - /** - * Puts this socket into listening mode. - */ - virtual bool listen(int backlog = 5); // 5 is arbitrary - - /** - * Connect to a remote host. - */ - virtual bool connect(const KResolverEntry& address); - - /** - * Accepts a new incoming connection. - * Note: this function returns a socket of type KSocketDevice. - */ - virtual KSocketDevice* accept(); - - /** - * Disconnects this socket. - */ - virtual bool disconnect(); - - /** - * Returns the number of bytes available for reading without blocking. - */ -#ifdef USE_QT3 - virtual TQ_LONG bytesAvailable() const; -#endif -#ifdef USE_QT4 - virtual qint64 bytesAvailable() const; -#endif - - /** - * Waits up to @p msecs for more data to be available on this socket. - * - * This function is a wrapper against @ref poll. This function will wait - * for any read events. - */ - virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L); - - /** - * Reads data from this socket. - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen); - - /** - * Reads data and the source address from this socket. - */ - virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from); - - /** - * Peeks data in the socket. - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen); - - /** - * Peeks the data in the socket and the source address. - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from); - - /** - * Writes data to the socket. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len); - - /** - * Writes the given data to the given destination address. - */ - virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to); - - /** - * Returns this socket's local address. - */ - virtual KSocketAddress localAddress() const; - - /** - * Returns this socket's peer address. If this implementation does proxying - * of some sort, this is the real external address, not the proxy's address. - */ - virtual KSocketAddress peerAddress() const; - - /** - * Returns this socket's externally visible local address. - * - * If this socket has a local address visible externally different - * from the normal local address (as returned by @ref localAddress), then - * return it. - * - * Certain implementations will use proxies and thus have externally visible - * addresses different from the local socket values. The default implementation - * returns the same value as @ref localAddress. - * - * @note This function may return an empty KSocketAddress. In that case, the - * externally visible address could/can not be determined. - */ - virtual KSocketAddress externalAddress() const; - - /** - * Returns a socket notifier for input on this socket. - * The notifier is created only when requested. Whether - * it is enabled or not depends on the implementation. - * - * This function might return NULL. - */ - TQSocketNotifier* readNotifier() const; - - /** - * Returns a socket notifier for output on this socket. - * The is created only when requested. - * - * This function might return NULL. - */ - TQSocketNotifier* writeNotifier() const; - - /** - * Returns a socket notifier for exceptional events on this socket. - * The is created only when requested. - * - * This function might return NULL. - */ - TQSocketNotifier* exceptionNotifier() const; - - /** - * Executes a poll in the socket, via select(2) or poll(2). - * The events polled are returned in the parameters pointers. - * Set any of them to NULL to disable polling of that event. - * - * On exit, @p input, @p output and @p exception will contain - * true if an event of that kind is waiting on the socket or false - * if not. If a timeout occurred, set @p timedout to true (all other - * parameters are necessarily set to false). - * - * @param input if set, turns on polling for input events - * @param output if set, turns on polling for output events - * @param exception if set, turns on polling for exceptional events - * @param timeout the time in milliseconds to wait for an event; - * 0 for no wait and any negative value to wait forever - * @param timedout on exit, will contain true if the polling timed out - * @return true if the poll call succeeded and false if an error occurred - */ - virtual bool poll(bool* input, bool* output, bool* exception = 0L, - int timeout = -1, bool* timedout = 0L); - - /** - * Shorter version to poll for any events in a socket. This call - * polls for input, output and exceptional events in a socket but - * does not return their states. This is useful if you need to wait for - * any event, but don't need to know which; or for timeouts. - * - * @param timeout the time in milliseconds to wait for an event; - * 0 for no wait and any negative value to wait forever - * @param timedout on exit, will contain true if the polling timed out - * @return true if the poll call succeeded and false if an error occurred - */ - bool poll(int timeout = -1, bool* timedout = 0L); - -protected: - /** - * Special constructor. This constructor will cause the internal - * socket device NOT to be set. Use this if your socket device class - * takes another underlying socket device. - * - * @param parent the parent, if any - */ - KSocketDevice(bool, const KSocketBase* parent = 0L); - - /** - * Creates a socket notifier of the given type. - * - * This function is called by @ref readNotifier, @ref writeNotifier and - * @ref exceptionNotifier when they need to create a socket notifier - * (i.e., the first call to those functions after the socket is open). - * After that call, those functions cache the socket notifier and will - * not need to call this function again. - * - * Reimplement this function in your derived class if your socket type - * requires a different kind of TQSocketNotifier. The return value should - * be deleteable with delete. (@ref close deletes them). - * - * @param type the socket notifier type - */ - virtual TQSocketNotifier* createNotifier(TQSocketNotifier::Type type) const; - -public: - /** - * Creates a new default KSocketDevice object given - * the parent object. - * - * The capabilities flag indicates the desired capabilities the object being - * created should possess. Those capabilities are not guaranteed: if no factory - * can provide such an object, a default object will be created. - * - * @param parent the KSocketBase parent - */ - static KSocketDevice* createDefault(KSocketBase* parent); - - /** - * @overload - * - * This will create an object only if the requested capabilities match. - * - * @param parent the parent - * @param capabilities the requested capabilities - */ - static KSocketDevice* createDefault(KSocketBase* parent, int capabilities); - - /** - * Sets the default KSocketDevice implementation to use and - * return the old factory. - * - * @param factory the factory object for the implementation - */ - static KSocketDeviceFactoryBase* setDefaultImpl(KSocketDeviceFactoryBase* factory); - - /** - * Adds a factory of KSocketDevice objects to the list, along with its - * capabilities flag. - */ - static void addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities); - -private: - KSocketDevice(const KSocketDevice&); - KSocketDevice& operator=(const KSocketDevice&); - - KSocketDevicePrivate *d; -}; - -/** @internal - * This class provides functionality for creating and registering - * socket implementations. - */ -class KSocketDeviceFactoryBase -{ -public: - KSocketDeviceFactoryBase() {} - virtual ~KSocketDeviceFactoryBase() {} - - virtual KSocketDevice* create(KSocketBase*) const = 0; -}; - -/** - * This class provides functionality for creating and registering - * socket implementations. - */ -template<class Impl> -class KSocketDeviceFactory: public KSocketDeviceFactoryBase -{ -public: - KSocketDeviceFactory() {} - virtual ~KSocketDeviceFactory() {} - - virtual KSocketDevice* create(KSocketBase* parent) const - { return new Impl(parent); } -}; - -} // namespaces - -#endif diff --git a/kdecore/network/ksockssocketdevice.cpp b/kdecore/network/ksockssocketdevice.cpp deleted file mode 100644 index 3432ef84f..000000000 --- a/kdecore/network/ksockssocketdevice.cpp +++ /dev/null @@ -1,487 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - */ - -#include <config.h> - -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> - -#if defined(HAVE_UNISTD_H) -#include <unistd.h> -#endif - -#ifdef __CYGWIN__ -#undef kde_socklen_t -#define kde_socklen_t ksocklen_t -#endif - -#include "kapplication.h" - -#include "ksocks.h" -#include "ksocketaddress.h" -#include "kresolver.h" -#include "ksockssocketdevice.h" - -using namespace KNetwork; - -// constructor -// nothing to do -KSocksSocketDevice::KSocksSocketDevice(const KSocketBase* obj) - : KSocketDevice(obj) -{ -} - -// constructor with argument -// nothing to do -KSocksSocketDevice::KSocksSocketDevice(int fd) - : KSocketDevice(fd) -{ -} - -// destructor -// also nothing to do -KSocksSocketDevice::~KSocksSocketDevice() -{ -} - -// returns the capabilities -int KSocksSocketDevice::capabilities() const -{ - return 0; // can do everything! -} - -// From here on, the code is almost exactly a copy of KSocketDevice -// the differences are the use of KSocks where appropriate - -bool KSocksSocketDevice::bind(const KResolverEntry& address) -{ - resetError(); - - if (m_sockfd == -1 && !create(address)) - return false; // failed creating - - // we have a socket, so try and bind - if (KSocks::self()->bind(m_sockfd, address.address(), address.length()) == -1) - { - if (errno == EADDRINUSE) - setError(IO_BindError, AddressInUse); - else if (errno == EINVAL) - setError(IO_BindError, AlreadyBound); - else - // assume the address is the cause - setError(IO_BindError, NotSupported); - return false; - } - - return true; -} - - -bool KSocksSocketDevice::listen(int backlog) -{ - if (m_sockfd != -1) - { - if (KSocks::self()->listen(m_sockfd, backlog) == -1) - { - setError(IO_ListenError, NotSupported); - return false; - } - - resetError(); - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - setState(IO_Open); - return true; - } - - // we don't have a socket - // can't listen - setError(IO_ListenError, NotCreated); - return false; -} - -bool KSocksSocketDevice::connect(const KResolverEntry& address) -{ - resetError(); - - if (m_sockfd == -1 && !create(address)) - return false; // failed creating! - - int retval; - if (KSocks::self()->hasWorkingAsyncConnect()) - retval = KSocks::self()->connect(m_sockfd, address.address(), - address.length()); - else - { - // work around some SOCKS implementation bugs - // we will do a *synchronous* connection here! - // FIXME: KDE4, write a proper SOCKS implementation - bool isBlocking = blocking(); - setBlocking(true); - retval = KSocks::self()->connect(m_sockfd, address.address(), - address.length()); - setBlocking(isBlocking); - } - - if (retval == -1) - { - if (errno == EISCONN) - return true; // we're already connected - else if (errno == EALREADY || errno == EINPROGRESS) - { - setError(IO_ConnectError, InProgress); - return true; - } - else if (errno == ECONNREFUSED) - setError(IO_ConnectError, ConnectionRefused); - else if (errno == ENETDOWN || errno == ENETUNREACH || - errno == ENETRESET || errno == ECONNABORTED || - errno == ECONNRESET || errno == EHOSTDOWN || - errno == EHOSTUNREACH) - setError(IO_ConnectError, NetFailure); - else - setError(IO_ConnectError, NotSupported); - - return false; - } - - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite); - setState(IO_Open); - return true; // all is well -} - -KSocksSocketDevice* KSocksSocketDevice::accept() -{ - if (m_sockfd == -1) - { - // can't accept without a socket - setError(IO_AcceptError, NotCreated); - return 0L; - } - - struct sockaddr sa; - kde_socklen_t len = sizeof(sa); - int newfd = KSocks::self()->accept(m_sockfd, &sa, &len); - if (newfd == -1) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) - setError(IO_AcceptError, WouldBlock); - else - setError(IO_AcceptError, UnknownError); - return NULL; - } - - return new KSocksSocketDevice(newfd); -} - -static int socks_read_common(int sockfd, char *data, TQ_ULONG maxlen, KSocketAddress* from, ssize_t &retval, bool peek = false) -{ - kde_socklen_t len; - if (from) - { - from->setLength(len = 128); // arbitrary length - retval = KSocks::self()->recvfrom(sockfd, data, maxlen, peek ? MSG_PEEK : 0, from->address(), &len); - } - else - retval = KSocks::self()->recvfrom(sockfd, data, maxlen, peek ? MSG_PEEK : 0, NULL, NULL); - - if (retval == -1) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) - return KSocketDevice::WouldBlock; - else - return KSocketDevice::UnknownError; - } - - if (from) - from->setLength(len); - return 0; -} - -TQ_LONG KSocksSocketDevice::tqreadBlock(char *data, TQ_ULONG maxlen) -{ - resetError(); - if (m_sockfd == -1) - return -1; - - if (maxlen == 0 || data == 0L) - return 0; // can't read - - ssize_t retval; - int err = socks_read_common(m_sockfd, data, maxlen, 0L, retval); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQ_LONG KSocksSocketDevice::tqreadBlock(char *data, TQ_ULONG maxlen, KSocketAddress &from) -{ - resetError(); - if (m_sockfd == -1) - return -1; // nothing to do here - - if (data == 0L || maxlen == 0) - return 0; // user doesn't want to read - - ssize_t retval; - int err = socks_read_common(m_sockfd, data, maxlen, &from, retval); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQ_LONG KSocksSocketDevice::peekBlock(char *data, TQ_ULONG maxlen) -{ - resetError(); - if (m_sockfd == -1) - return -1; - - if (maxlen == 0 || data == 0L) - return 0; // can't read - - ssize_t retval; - int err = socks_read_common(m_sockfd, data, maxlen, 0L, retval, true); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQ_LONG KSocksSocketDevice::peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from) -{ - resetError(); - if (m_sockfd == -1) - return -1; // nothing to do here - - if (data == 0L || maxlen == 0) - return 0; // user doesn't want to read - - ssize_t retval; - int err = socks_read_common(m_sockfd, data, maxlen, &from, retval, true); - - if (err) - { - setError(IO_ReadError, static_cast<SocketError>(err)); - return -1; - } - - return retval; -} - -TQ_LONG KSocksSocketDevice::tqwriteBlock(const char *data, TQ_ULONG len) -{ - return tqwriteBlock(data, len, KSocketAddress()); -} - -TQ_LONG KSocksSocketDevice::tqwriteBlock(const char *data, TQ_ULONG len, const KSocketAddress& to) -{ - resetError(); - if (m_sockfd == -1) - return -1; // can't write to unopen socket - - if (data == 0L || len == 0) - return 0; // nothing to be written - - ssize_t retval = KSocks::self()->sendto(m_sockfd, data, len, 0, to.address(), to.length()); - if (retval == -1) - { - if (errno == EAGAIN || errno == EWOULDBLOCK) - setError(IO_WriteError, WouldBlock); - else - setError(IO_WriteError, UnknownError); - return -1; // nothing written - } - - return retval; -} - -KSocketAddress KSocksSocketDevice::localAddress() const -{ - if (m_sockfd == -1) - return KSocketAddress(); // not open, empty value - - kde_socklen_t len; - KSocketAddress localAddress; - localAddress.setLength(len = 32); // arbitrary value - if (KSocks::self()->getsockname(m_sockfd, localAddress.address(), &len) == -1) - // error! - return KSocketAddress(); - - if (len <= localAddress.length()) - { - // it has fit already - localAddress.setLength(len); - return localAddress; - } - - // no, the socket address is actually larger than we had anticipated - // call again - localAddress.setLength(len); - if (KSocks::self()->getsockname(m_sockfd, localAddress.address(), &len) == -1) - // error! - return KSocketAddress(); - - return localAddress; -} - -KSocketAddress KSocksSocketDevice::peerAddress() const -{ - if (m_sockfd == -1) - return KSocketAddress(); // not open, empty value - - kde_socklen_t len; - KSocketAddress peerAddress; - peerAddress.setLength(len = 32); // arbitrary value - if (KSocks::self()->getpeername(m_sockfd, peerAddress.address(), &len) == -1) - // error! - return KSocketAddress(); - - if (len <= peerAddress.length()) - { - // it has fit already - peerAddress.setLength(len); - return peerAddress; - } - - // no, the socket address is actually larger than we had anticipated - // call again - peerAddress.setLength(len); - if (KSocks::self()->getpeername(m_sockfd, peerAddress.address(), &len) == -1) - // error! - return KSocketAddress(); - - return peerAddress; -} - -KSocketAddress KSocksSocketDevice::externalAddress() const -{ - // return empty, indicating unknown external address - return KSocketAddress(); -} - -bool KSocksSocketDevice::poll(bool *input, bool *output, bool *exception, - int timeout, bool *timedout) -{ - if (m_sockfd == -1) - { - setError(IO_UnspecifiedError, NotCreated); - return false; - } - - resetError(); - fd_set readfds, writefds, exceptfds; - fd_set *preadfds = 0L, *pwritefds = 0L, *pexceptfds = 0L; - - if (input) - { - preadfds = &readfds; - FD_ZERO(preadfds); - FD_SET(m_sockfd, preadfds); - *input = false; - } - if (output) - { - pwritefds = &writefds; - FD_ZERO(pwritefds); - FD_SET(m_sockfd, pwritefds); - *output = false; - } - if (exception) - { - pexceptfds = &exceptfds; - FD_ZERO(pexceptfds); - FD_SET(m_sockfd, pexceptfds); - *exception = false; - } - - int retval; - if (timeout < 0) - retval = KSocks::self()->select(m_sockfd + 1, preadfds, pwritefds, pexceptfds, 0L); - else - { - // convert the milliseconds to timeval - struct timeval tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = timeout % 1000 * 1000; - - retval = select(m_sockfd + 1, preadfds, pwritefds, pexceptfds, &tv); - } - - if (retval == -1) - { - setError(IO_UnspecifiedError, UnknownError); - return false; - } - if (retval == 0) - { - // timeout - if (timedout) - *timedout = true; - return true; - } - - if (input && FD_ISSET(m_sockfd, preadfds)) - *input = true; - if (output && FD_ISSET(m_sockfd, pwritefds)) - *output = true; - if (exception && FD_ISSET(m_sockfd, pexceptfds)) - *exception = true; - - return true; -} - -void KSocksSocketDevice::initSocks() -{ - static bool init = false; - - if (init) - return; - - if (kapp == 0L) - return; // no KApplication, so don't initialise - // this should, however, test for KInstance - - init = true; - - if (KSocks::self()->hasSocks()) - delete KSocketDevice::setDefaultImpl(new KSocketDeviceFactory<KSocksSocketDevice>); -} - -#if 0 -static bool register() -{ - KSocketDevice::addNewImpl(new KSocketDeviceFactory<KSocksSocketDevice>, 0); -} - -static bool register = registered(); -#endif diff --git a/kdecore/network/ksockssocketdevice.h b/kdecore/network/ksockssocketdevice.h deleted file mode 100644 index 4db5d1e01..000000000 --- a/kdecore/network/ksockssocketdevice.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2004 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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 KSOCKSSOCKETDEVICE_H -#define KSOCKSSOCKETDEVICE_H - -#include "ksocketdevice.h" - -namespace KNetwork { - -/** - * @class KSocksSocketDevice ksockssocketdevice.h ksockssocketdevice.h - * @brief The low-level class for SOCKS proxying. - * - * This class reimplements several functions from @ref KSocketDevice in order - * to implement SOCKS support. - * - * This works by using KSocks. - * - * @author Thiago Macieira <thiago.macieira@kdemail.net> - * - * @warning This code is untested! - */ -class KDECORE_EXPORT KSocksSocketDevice: public KSocketDevice -{ -public: - /** - * Constructor. - */ - KSocksSocketDevice(const KSocketBase* = 0L); - - /** - * Construct from a file descriptor. - */ - explicit KSocksSocketDevice(int fd); - - /** - * Destructor. - */ - virtual ~KSocksSocketDevice(); - - /** - * Sets our capabilities. - */ - virtual int capabilities() const; - - /** - * Overrides binding. - */ - virtual bool bind(const KResolverEntry& address); - - /** - * Overrides listening. - */ - virtual bool listen(int backlog); - - /** - * Overrides connection. - */ - virtual bool connect(const KResolverEntry& address); - - /** - * Overrides accepting. The return type is specialised. - */ - virtual KSocksSocketDevice* accept(); - - /** - * Overrides reading. - */ - virtual TQ_LONG tqreadBlock(char *data, TQ_ULONG maxlen); - virtual TQ_LONG tqreadBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from); - - /** - * Overrides peeking. - */ - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen); - virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from); - - /** - * Overrides writing. - */ - virtual TQ_LONG tqwriteBlock(const char *data, TQ_ULONG len); - virtual TQ_LONG tqwriteBlock(const char *data, TQ_ULONG len, const KSocketAddress& to); - - /** - * Overrides getting socket address. - */ - virtual KSocketAddress localAddress() const; - - /** - * Overrides getting peer address. - */ - virtual KSocketAddress peerAddress() const; - - /** - * Overrides getting external address. - */ - virtual KSocketAddress externalAddress() const; - - /** - * Overrides polling. - */ - virtual bool poll(bool* input, bool* output, bool* exception = 0L, - int timeout = -1, bool* timedout = 0L); - -private: - static void initSocks(); - friend class KSocketDevice; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/ksrvresolverworker.cpp b/kdecore/network/ksrvresolverworker.cpp deleted file mode 100644 index 2ec5bb4bf..000000000 --- a/kdecore/network/ksrvresolverworker.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2005 Thiago Macieira <thiago@kde.org> - * - * 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. - */ - -#include <config.h> - -#include "ksrvresolverworker_p.h" - -#include <sys/types.h> -#include <sys/socket.h> -#include <stdlib.h> - -#include <tqapplication.h> -#include <tqevent.h> - -using namespace KNetwork; -using namespace KNetwork::Internal; - -namespace -{ - struct KSrvStartEvent: public TQCustomEvent - { - inline KSrvStartEvent() : TQCustomEvent(TQEvent::User) { } - }; -} - -static void sortPriorityClass(KSrvResolverWorker::PriorityClass&) -{ - // do nothing -} - -bool KSrvResolverWorker::preprocess() -{ - // check if the resolver flags mention SRV-based lookup - if ((flags() & (KResolver::NoSrv | KResolver::UseSrv)) != KResolver::UseSrv) - return false; - - TQString node = nodeName(); - if (node.find('%') != -1) - node.truncate(node.find('%')); - - if (node.isEmpty() || node == TQString::tqfromLatin1("*") || - node == TQString::tqfromLatin1("localhost")) - return false; // empty == localhost - - encodedName = KResolver::domainToAscii(node); - if (encodedName.isNull()) - return false; - - // we only work with Internet-based families - if ((familyMask() & KResolver::InternetFamily) == 0) - return false; - - // SRV-based resolution only works if the service isn't numeric - bool ok; - serviceName().toUInt(&ok); - if (ok) - return false; // it is numeric - - // check the protocol for something we know - TQCString protoname; - int sockettype = socketType(); - if (!protocolName().isEmpty()) - protoname = protocolName(); - else if (protocol() != 0) - { - TQStrList names = KResolver::protocolName(protocol()); - names.setAutoDelete(true); - if (names.isEmpty()) - return false; - - protoname = "_"; - protoname += names.tqat(0); - } - else if (sockettype == SOCK_STREAM || sockettype == 0) - protoname = "_tcp"; - else if (sockettype == SOCK_DGRAM) - protoname = "_udp"; - else - return false; // unknown protocol and socket type - - encodedName.prepend("."); - encodedName.prepend(protoname); - encodedName.prepend("."); - encodedName.prepend(serviceName().latin1()); - encodedName.prepend("_"); - - // looks like something we could process - return true; -} - -bool KSrvResolverWorker::run() -{ - sem = new TQSemaphore(1); - // zero out - sem->tryAccess(sem->available()); - - TQApplication::postEvent(this, new KSrvStartEvent); - - // block - (*sem)++; - delete sem; - sem = 0L; - - if (rawResults.isEmpty()) - { - // normal lookup - KResolver *r = new KResolver(nodeName(), serviceName()); - r->setFlags(flags() | KResolver::NoSrv); - r->setFamily(familyMask()); - r->setSocketType(socketType()); - r->setProtocol(protocol(), protocolName()); - - enqueue(r); - - Entry e; - PriorityClass cl; - e.resolver = r; - cl.entries.append(e); - myResults[0] = cl; - - return true; - } - else if (rawResults.count() == 1 && rawResults.first().name == ".") - { - // no name - setError(KResolver::NoName); - finished(); - return true; - } - else - { - // now process the results - TQValueList<TQDns::Server>::ConstIterator it = rawResults.begin(); - while (it != rawResults.end()) - { - const TQDns::Server& srv = *it; - PriorityClass& r = myResults[srv.priority]; - r.totalWeight += srv.weight; - - Entry e; - e.name = srv.name; - e.port = srv.port; - e.weight = srv.weight; - e.resolver = 0L; - r.entries.append(e); - - ++it; - } - rawResults.clear(); // free memory - - Results::Iterator mapit; - for (mapit = myResults.begin(); mapit != myResults.end(); ++mapit) - { - // sort the priority - sortPriorityClass(*mapit); - - TQValueList<Entry>& entries = (*mapit).entries; - - // start the resolvers - for (TQValueList<Entry>::Iterator it = entries.begin(); - it != entries.end(); ++it) - { - Entry &e = *it; - - KResolver* r = new KResolver(e.name, TQString::number(e.port)); - r->setFlags(flags() | KResolver::NoSrv); - r->setFamily(familyMask()); - r->setSocketType(socketType()); - r->setProtocol(protocol(), protocolName()); - - enqueue(r); - e.resolver = r; - } - } - - return true; - } -} - -bool KSrvResolverWorker::postprocess() -{ - setError(KResolver::NoName); - if (myResults.isEmpty()) - return false; - - Results::Iterator mapit, mapend; - for (mapit = myResults.begin(), mapend = myResults.end(); - mapit != mapend; ++mapit) - { - TQValueList<Entry>::Iterator it = (*mapit).entries.begin(), - end = (*mapit).entries.end(); - for ( ; it != end; ++it) - { - Entry &e = *it; - KResolverResults r = e.resolver->results(); - if (r.isEmpty() && results.isEmpty()) - setError(r.error(), r.systemError()); - else - { - setError(KResolver::NoError); - results += r; - } - } - } - - finished(); - return true; -} - -void KSrvResolverWorker::customEvent(TQCustomEvent*) -{ - dns = new TQDns(TQString::tqfromLatin1(encodedName), TQDns::Srv); - TQObject::connect(dns, TQT_SIGNAL(resultsReady()), this, TQT_SLOT(dnsResultsReady())); -} - -void KSrvResolverWorker::dnsResultsReady() -{ - (*sem)--; - rawResults = dns->servers(); - dns->deleteLater(); - dns = 0L; -} - -namespace KNetwork -{ - namespace Internal - { - - void initSrvWorker() KDE_NO_EXPORT; - void initSrvWorker() - { - if (getenv("KDE_NO_SRV") != NULL) - return; - - KResolverWorkerFactoryBase::registerNewWorker(new KResolverWorkerFactory<KSrvResolverWorker>); - } - - } -} - -#include "ksrvresolverworker_p.moc" diff --git a/kdecore/network/ksrvresolverworker_p.h b/kdecore/network/ksrvresolverworker_p.h deleted file mode 100644 index 293308544..000000000 --- a/kdecore/network/ksrvresolverworker_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2005 Thiago Macieira <thiago@kde.org> - * - * 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 KSRVRESOLVERWORKER_P_H -#define KSRVRESOLVERWORKER_P_H - -#include <tqobject.h> -#include <tqdns.h> -#include <tqsemaphore.h> -#include <tqvaluelist.h> -#include <tqdict.h> -#include "kresolver.h" -#include "kresolverworkerbase.h" - -class TQCustomEvent; - -namespace KNetwork -{ - namespace Internal - { - /** - * @internal - * This class implements SRV-based resolution - */ - class KSrvResolverWorker: public TQObject, - public KNetwork::KResolverWorkerBase - { - Q_OBJECT - TQ_OBJECT - - public: - struct Entry - { - TQString name; - TQ_UINT16 port; - TQ_UINT16 weight; - KNetwork::KResolver* resolver; - }; - - struct PriorityClass - { - PriorityClass() : totalWeight(0) { } - - TQValueList<Entry> entries; - TQ_UINT16 totalWeight; - }; - - private: - TQDns *dns; - TQValueList<TQDns::Server> rawResults; - TQCString encodedName; - TQSemaphore *sem; - - typedef TQMap<TQ_UINT16, PriorityClass> Results; - Results myResults; - - public: - virtual bool preprocess(); - virtual bool run(); - virtual bool postprocess(); - - virtual void customEvent(TQCustomEvent*); - - public slots: - void dnsResultsReady(); - }; - } -} - -#endif diff --git a/kdecore/network/kstreamsocket.cpp b/kdecore/network/kstreamsocket.cpp deleted file mode 100644 index 3861a4e09..000000000 --- a/kdecore/network/kstreamsocket.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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. - */ - -#include <config.h> - -#include <tqsocketnotifier.h> -#include <tqdatetime.h> -#include <tqtimer.h> -#include <tqguardedptr.h> - -#include "ksocketaddress.h" -#include "kresolver.h" -#include "ksocketdevice.h" -#include "kstreamsocket.h" - -using namespace KNetwork; - -class KNetwork::KStreamSocketPrivate -{ -public: - KResolverResults::ConstIterator local, peer; - TQTime startTime; - TQTimer timer; - - int timeout; - - inline KStreamSocketPrivate() - : timeout(0) - { } -}; - -KStreamSocket::KStreamSocket(const TQString& node, const TQString& service, - TQObject* parent, const char *name) - : KClientSocketBase(parent, name), d(new KStreamSocketPrivate) -{ - peerResolver().setNodeName(node); - peerResolver().setServiceName(service); - peerResolver().setFamily(KResolver::KnownFamily); - localResolver().setFamily(KResolver::KnownFamily); - - setSocketOptions(socketOptions() & ~Blocking); - - TQObject::connect(&d->timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeoutSlot())); -} - -KStreamSocket::~KStreamSocket() -{ - delete d; - // KClientSocketBase's destructor closes the socket -} - -int KStreamSocket::timeout() const -{ - return d->timeout; -} - -int KStreamSocket::remainingTimeout() const -{ - if (state() != Connecting) - return timeout(); - if (timeout() <= 0) - return 0; - - return timeout() - d->startTime.elapsed(); -} - -void KStreamSocket::setTimeout(int msecs) -{ - d->timeout = msecs; - - if (state() == Connecting) - d->timer.changeInterval(msecs); -} - -bool KStreamSocket::bind(const TQString& node, const TQString& service) -{ - if (state() != Idle) - return false; - - if (!node.isNull()) - localResolver().setNodeName(node); - if (!service.isNull()) - localResolver().setServiceName(service); - return true; -} - -bool KStreamSocket::connect(const TQString& node, const TQString& service) -{ - if (state() == Connected) - return true; // already connected - - if (state() > Connected) - return false; // can't do much here - - if (!node.isNull()) - peerResolver().setNodeName(node); - if (!service.isNull()) - peerResolver().setServiceName(service); - - if (state() == Connecting && !blocking()) - { - setError(IO_ConnectError, InProgress); - emit gotError(InProgress); - return true; // we're already connecting - } - - if (state() < HostFound) - { - // connection hasn't started yet - if (!blocking()) - { - QObject::connect(this, TQT_SIGNAL(hostFound()), TQT_SLOT(hostFoundSlot())); - return lookup(); - } - - // blocking mode - if (!lookup()) - return false; // lookup failure - } - - /* - * lookup results are available here - */ - - if (timeout() > 0) - { - if (!blocking() && !d->timer.isActive()) - d->timer.start(timeout(), true); - else - { - // blocking connection with timeout - // this must be handled as a special case because it requires a - // non-blocking socket - - d->timer.stop(); // no need for a timer here - - socketDevice()->setBlocking(false); - while (true) - { - connectionEvent(); - if (state() < Connecting) - return false; // error connecting - if (state() == Connected) - return true; // connected! - - if (remainingTimeout() <= 0) - { - // we've timed out - timeoutSlot(); - return false; - } - - if (socketDevice()->error() == InProgress) - { - bool timedout; - socketDevice()->poll(remainingTimeout(), &timedout); - if (timedout) - { - timeoutSlot(); - return false; - } - } - } - } - } - - connectionEvent(); - return error() == NoError; -} - -bool KStreamSocket::connect(const KResolverEntry& entry) -{ - return KClientSocketBase::connect(entry); -} - -void KStreamSocket::hostFoundSlot() -{ - QObject::disconnect(this, TQT_SLOT(hostFoundSlot())); - if (timeout() > 0) - d->timer.start(timeout(), true); - TQTimer::singleShot(0, this, TQT_SLOT(connectionEvent())); -} - -void KStreamSocket::connectionEvent() -{ - if (state() != HostFound && state() != Connecting) - return; // nothing to do - - const KResolverResults& peer = peerResults(); - if (state() == HostFound) - { - d->startTime.start(); - - setState(Connecting); - emit stateChanged(Connecting); - d->peer = peer.begin(); - d->local = localResults().begin(); // just to be on the safe side - } - - while (d->peer != peer.end()) - { - const KResolverEntry &r = *d->peer; - - if (socketDevice()->socket() != -1) - { - // we have an existing file descriptor - // this means that we've got activity in it (connection result) - if (socketDevice()->connect(r) && socketDevice()->error() == NoError) - { - // yes, it did connect! - connectionSucceeded(r); - return; - } - else if (socketDevice()->error() == InProgress) - // nope, still in progress - return; - - // no, the socket failed to connect - copyError(); - socketDevice()->close(); - ++d->peer; - continue; - } - - // try to bind - if (!bindLocallyFor(r)) - { - // could not find a matching family - ++d->peer; - continue; - } - - { - bool skip = false; - emit aboutToConnect(r, skip); - if (skip) - { - ++d->peer; - continue; - } - } - - if (socketDevice()->connect(r) || socketDevice()->error() == InProgress) - { - // socket is attempting to connect - if (socketDevice()->error() == InProgress) - { - TQSocketNotifier *n = socketDevice()->readNotifier(); - TQObject::connect(n, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(connectionEvent())); - n->setEnabled(true); - - n = socketDevice()->writeNotifier(); - TQObject::connect(n, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(connectionEvent())); - n->setEnabled(true); - - return; // wait for activity - } - - // socket has connected - connectionSucceeded(r); - return; - } - - // connection failed - // try next - copyError(); - socketDevice()->close(); - ++d->peer; - } - - // that was the last item - socketDevice()->setSocketOptions(socketOptions()); - setState(Idle); - emit stateChanged(Idle); - emit gotError(error()); - return; -} - -void KStreamSocket::timeoutSlot() -{ - if (state() != Connecting) - return; - - // halt the connections - socketDevice()->close(); // this also kills the notifiers - - setError(IO_TimeOutError, Timeout); - setState(HostFound); - emit stateChanged(HostFound); - - TQGuardedPtr<KStreamSocket> that = this; - emit gotError(Timeout); - if (!that.isNull()) - emit timedOut(); -} - -bool KStreamSocket::bindLocallyFor(const KResolverEntry& peer) -{ - const KResolverResults& local = localResults(); - - if (local.isEmpty()) - // user doesn't want to bind to any specific local address - return true; - - bool foundone = false; - // scan the local resolution for a matching family - for (d->local = local.begin(); d->local != local.end(); ++d->local) - if ((*d->local).family() == peer.family()) - { - // found a suitable address! - foundone = true; - - if (socketDevice()->bind(*d->local)) - return true; - } - - if (!foundone) - { - // found nothing - setError(IO_BindError, NotSupported); - emit gotError(NotSupported); - } - else - copyError(); - return false; -} - -void KStreamSocket::connectionSucceeded(const KResolverEntry& peer) -{ - TQObject::disconnect(socketDevice()->readNotifier(), 0, this, TQT_SLOT(connectionEvent())); - TQObject::disconnect(socketDevice()->writeNotifier(), 0, this, TQT_SLOT(connectionEvent())); - - resetError(); - setFlags(IO_Sequential | IO_Raw | IO_ReadWrite | IO_Open | IO_Async); - setState(Connected); - socketDevice()->setSocketOptions(socketOptions()); - d->timer.stop(); - emit stateChanged(Connected); - - if (!localResults().isEmpty()) - emit bound(*d->local); - emit connected(peer); -} - -#include "kstreamsocket.moc" diff --git a/kdecore/network/kstreamsocket.h b/kdecore/network/kstreamsocket.h deleted file mode 100644 index 9b58bf23a..000000000 --- a/kdecore/network/kstreamsocket.h +++ /dev/null @@ -1,250 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago@kde.org> - * - * - * 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 KSTREAMSOCKET_H -#define KSTREAMSOCKET_H - -#include <tqstring.h> - -#include "kclientsocketbase.h" - -/** A namespace to store all networking-related (socket) classes. */ -namespace KNetwork { - -class KResolverEntry; -class KResolverResults; -class KServerSocket; -class KBufferedSocket; - -class KStreamSocketPrivate; -/** @class KStreamSocket kstreamsocket.h kstreamsocket.h - * @brief Simple stream socket - * - * This class provides functionality to creating unbuffered, stream - * sockets. In the case of Internet (IP) sockets, this class creates and - * uses TCP/IP sockets. - * - * Objects of this class start, by default, on non-blocking mode. Call - * setBlocking if you wish to change that. - * - * KStreamSocket objects are thread-safe and can be used in auxiliary - * threads (i.e., not the thread in which the Qt event loop runs in). - * Note that KBufferedSocket cannot be used reliably in an auxiliary thread. - * - * Sample usage: - * \code - * TQByteArray httpGet(const TQString& hostname) - * { - * KStreamSocket socket(hostname, "http"); - * if (!socket.connect()) - * return TQByteArray(); - * TQByteArray data = socket.readAll(); - * return data; - * } - * \endcode - * - * Here's another sample, showing asynchronous operation: - * \code - * DataRetriever::DataRetriever(const TQString& hostname, const TQString& port) - * : socket(hostname, port) - * { - * // connect signals to our slots - * TQObject::connect(&socket, TQT_SIGNAL(connected(const KResolverEntry&)), - * this, TQT_SLOT(slotSocketConnected())); - * TQObject::connect(&socket, TQT_SIGNAL(gotError(int)), - * this, TQT_SLOT(slotSocketError(int))); - * TQObject::connect(&socket, TQT_SIGNAL(readyRead()), - * this, TQT_SLOT(slotSocketReadyToRead())); - * TQObject::connect(&socket, TQT_SIGNAL(readyWrite()), - * this, TQT_SLOT(slotSocketReadyToWrite())); - * - * // set non-blocking mode in order to work asynchronously - * socket.setBlocking(false); - * - * // turn on signal emission - * socket.enableRead(true); - * socket.enableWrite(true); - * - * // start connecting - * socket.connect(); - * } - * \endcode - * - * @see KNetwork::KBufferedSocket, KNetwork::KServerSocket - * @author Thiago Macieira <thiago@kde.org> - */ -class KDECORE_EXPORT KStreamSocket: public KClientSocketBase -{ - Q_OBJECT - TQ_OBJECT - -public: - /** - * Default constructor. - * - * @param node destination host - * @param service destination service to connect to - * @param parent the parent TQObject object - * @param name name for this object - */ - KStreamSocket(const TQString& node = TQString::null, const TQString& service = TQString::null, - TQObject* parent = 0L, const char *name = 0L); - - /** - * Destructor. This closes the socket. - */ - virtual ~KStreamSocket(); - - /** - * Retrieves the timeout value (in milliseconds). - */ - int timeout() const; - - /** - * Retrieves the remaining timeout time (in milliseconds). This value - * equals @ref timeout() if there's no connection in progress. - */ - int remainingTimeout() const; - - /** - * Sets the timeout value. Setting this value while a connection attempt - * is in progress will reset the timer. - * - * Please note that the timeout value is valid for the connection attempt - * only. No other operations are timed against this value -- including the - * name lookup associated. - * - * @param msecs the timeout value in milliseconds - */ - void setTimeout(int msecs); - - /** - * Binds this socket to the given nodename and service, - * or use the default ones if none are given. In order to bind to a service - * and allow the operating system to choose the interface, set @p node to - * TQString::null. - * - * Reimplemented from KClientSocketBase. - * - * Upon successful binding, the @ref bound signal will be - * emitted. If an error is found, the @ref gotError - * signal will be emitted. - * - * @note Due to the internals of the name lookup and binding - * mechanism, some (if not most) implementations of this function - * do not actually bind the socket until the connection - * is requested (see @ref connect). They only set the values - * for future reference. - * - * This function returns true on success. - * - * @param node the nodename - * @param service the service - */ - virtual bool bind(const TQString& node = TQString::null, - const TQString& service = TQString::null); - - /** - * Reimplemented from KClientSocketBase. Connect this socket to this - * specific address. - * - * Unlike @ref bind(const TQString&, const TQString&) above, this function - * really does bind the socket. No lookup is performed. The @ref bound - * signal will be emitted. - */ - virtual bool bind(const KResolverEntry& entry) - { return KClientSocketBase::bind(entry); } - - /** - * Reimplemented from KClientSocketBase. - * - * Attempts to connect to the these hostname and service, - * or use the default ones if none are given. If a connection attempt - * is already in progress, check on its state and set the error status - * (NoError, meaning the connection is completed, or InProgress). - * - * If the blocking mode for this object is on, this function will only - * return when all the resolved peer addresses have been tried or when - * a connection is established. - * - * Upon successfully connecting, the @ref connected signal - * will be emitted. If an error is found, the @ref gotError - * signal will be emitted. - * - * This function also implements timeout handling. - * - * @param node the remote node to connect to - * @param service the service on the remote node to connect to - */ - virtual bool connect(const TQString& node = TQString::null, - const TQString& service = TQString::null); - - /** - * Unshadowing from KClientSocketBase. - */ - virtual bool connect(const KResolverEntry& entry); - -signals: - /** - * This signal is emitted when a connection timeout occurs. - */ - void timedOut(); - -private slots: - void hostFoundSlot(); - void connectionEvent(); - void timeoutSlot(); - -private: - /** - * @internal - * If the user requested local bind before connection, bind the socket to one - * suitable address and return true. Also sets d->local to the address used. - * - * Return false in case of error. - */ - bool bindLocallyFor(const KResolverEntry& peer); - - /** - * @internal - * Finishes the connection process by setting internal values and - * emitting the proper signals. - * - * Note: assumes d->local iterator points to the address that we bound - * to. - */ - void connectionSucceeded(const KResolverEntry& peer); - - KStreamSocket(const KStreamSocket&); - KStreamSocket& operator=(const KStreamSocket&); - - KStreamSocketPrivate *d; - - friend class KServerSocket; - friend class KBufferedSocket; -}; - -} // namespace KNetwork - -#endif diff --git a/kdecore/network/syssocket.h b/kdecore/network/syssocket.h deleted file mode 100644 index e34db1bd1..000000000 --- a/kdecore/network/syssocket.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- C++ -*- - * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> - * - * - * 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 KDE_SYSSOCKET_H -#define KDE_SYSSOCKET_H - -#ifdef KSOCKETBASE_H -#error syssocket.h must be included before ksocketbase.h! -#endif - -#include <sys/types.h> -#include <sys/socket.h> - -namespace { - - /* - * These function here are just wrappers for the real system calls. - * - * Unfortunately, a number of systems out there work by redefining - * symbols through the preprocessor -- symbols that we need. - * - * So we write wrappers for all the low-level system calls. - * - * Qt has a very similar implementation. I got the idea from them, but - * I copied no code. - */ - - // socket - inline int kde_socket(int af, int style, int protocol) - { - return ::socket(af, style, protocol); - } - - // bind - inline int kde_bind(int fd, const struct sockaddr* sa, socklen_t len) - { - return ::bind(fd, sa, len); - } - - // listen - inline int kde_listen(int fd, int backlog) - { - return ::listen(fd, backlog); - } - - // connect - inline int kde_connect(int fd, const struct sockaddr* sa, socklen_t len) - { - return ::connect(fd, (struct sockaddr*)sa, len); - } - - // accept - inline int kde_accept(int fd, struct sockaddr* sa, socklen_t* len) - { - return ::accept(fd, sa, len); - } - - // getpeername - inline int kde_getpeername(int fd, struct sockaddr* sa, socklen_t* len) - { - return ::getpeername(fd, sa, len); - } - - // getsockname - inline int kde_getsockname(int fd, struct sockaddr* sa, socklen_t* len) - { - return ::getsockname(fd, sa, len); - } - -} // anonymous namespace - -#endif diff --git a/kdecore/standard_weak.nmcheck b/kdecore/standard_weak.nmcheck deleted file mode 100644 index 27c3bac7e..000000000 --- a/kdecore/standard_weak.nmcheck +++ /dev/null @@ -1,6 +0,0 @@ -# KDE namespace check file - -# various symbols coming from other non-Qt/KDE libraries - -# libstdc++ -std::* diff --git a/kdecore/svgicons/CMakeLists.txt b/kdecore/svgicons/CMakeLists.txt deleted file mode 100644 index 4f2345510..000000000 --- a/kdecore/svgicons/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore - ${LIBART_INCLUDE_DIRS} -) - - -##### headers ################################### - -install( FILES - ksvgiconengine.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - - -##### kdesvgicons ############################### - -set( target kdesvgicons ) - -set( ${target}_SRCS - ksvgiconengine.cpp ksvgiconpainter.cpp -) - -tde_add_library( ${target} STATIC_PIC - SOURCES ${${target}_SRCS} - LINK ${LIBART_LIBRARIES} -) diff --git a/kdecore/svgicons/Makefile.am b/kdecore/svgicons/Makefile.am deleted file mode 100644 index ca398a5bd..000000000 --- a/kdecore/svgicons/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDES = -I$(srcdir)/.. $(LIBART_CFLAGS) $(all_includes) - -noinst_LTLIBRARIES = libkdesvgicons.la - -include_HEADERS = ksvgiconengine.h -libkdesvgicons_la_SOURCES = ksvgiconengine.cpp ksvgiconpainter.cpp diff --git a/kdecore/svgicons/TODO b/kdecore/svgicons/TODO deleted file mode 100644 index 6ecafb8bf..000000000 --- a/kdecore/svgicons/TODO +++ /dev/null @@ -1,5 +0,0 @@ -* Units.svg is wrong -* faster implementations of parseStyle, parseTransform, if needed -* smaller art_render_new areas, if needed -* make gradients work for boundingbox as well -* patterns diff --git a/kdecore/svgicons/ksvgiconengine.cpp b/kdecore/svgicons/ksvgiconengine.cpp deleted file mode 100644 index 85830126b..000000000 --- a/kdecore/svgicons/ksvgiconengine.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/* - Copyright (C) 2002 Nikolas Zimmermann <wildfox@kde.org> - This file is part of the KDE project - - 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. -*/ - -#include <tqdom.h> -#include <tqfile.h> -#include <tqcolor.h> -#include <tqimage.h> -#include <tqwmatrix.h> -#include <tqregexp.h> - -#include <kmdcodec.h> - -#include <zlib.h> - -#include "ksvgiconpainter.h" -#include "ksvgiconengine.h" - -class KSVGIconEngineHelper -{ -public: - KSVGIconEngineHelper(KSVGIconEngine *engine) - { - m_engine = engine; - } - - ~KSVGIconEngineHelper() - { - } - - double toPixel(const TQString &s, bool hmode) - { - return m_engine->painter()->toPixel(s, hmode); - } - - ArtGradientStop *parseGradientStops(TQDomElement element, int &offsets) - { - if (!element.hasChildNodes()) - return 0; - - TQValueList<ArtGradientStop> stopList; - - float oldOffset = -1, newOffset = -1; - for(TQDomNode node = element.firstChild(); !node.isNull(); node = node.nextSibling()) - { - TQDomElement element = node.toElement(); - - oldOffset = newOffset; - TQString temp = element.attribute("offset"); - - if(temp.contains("%")) - { - temp = temp.left(temp.length() - 1); - newOffset = temp.toFloat() / 100.0; - } - else - newOffset = temp.toFloat(); - - // Spec skip double offset specifications - if(oldOffset == newOffset) - continue; - - offsets++; - stopList.append(ArtGradientStop()); - - ArtGradientStop &stop = stopList.last(); - - stop.offset = newOffset; - - TQString parseOpacity; - TQString parseColor; - - if(element.hasAttribute("stop-opacity")) - parseOpacity = element.attribute("stop-opacity"); - - if(element.hasAttribute("stop-color")) - parseColor = element.attribute("stop-color"); - - if(parseOpacity.isEmpty() || parseColor.isEmpty()) - { - TQString style = element.attribute("style"); - - TQStringList substyles = TQStringList::split(';', style); - for(TQStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) - { - TQStringList substyle = TQStringList::split(':', (*it)); - TQString command = substyle[0]; - TQString params = substyle[1]; - command = command.stripWhiteSpace(); - params = params.stripWhiteSpace(); - - if(command == "stop-color") - { - parseColor = params; - - if(!parseOpacity.isEmpty()) - break; - } - else if(command == "stop-opacity") - { - parseOpacity = params; - - if(!parseColor.isEmpty()) - break; - } - } - } - - // Parse color using KSVGIconPainter (which uses Qt) - // Supports all svg-needed color formats - TQColor qStopColor = m_engine->painter()->parseColor(parseColor); - - // Convert in a libart suitable form - TQ_UINT32 stopColor = m_engine->painter()->toArtColor(qStopColor); - - int opacity = m_engine->painter()->parseOpacity(parseOpacity); - - TQ_UINT32 rgba = (stopColor << 8) | opacity; - TQ_UINT32 r, g, b, a; - - // Convert from separated to premultiplied alpha - a = rgba & 0xff; - r = (rgba >> 24) * a + 0x80; - r = (r + (r >> 8)) >> 8; - g = ((rgba >> 16) & 0xff) * a + 0x80; - g = (g + (g >> 8)) >> 8; - b = ((rgba >> 8) & 0xff) * a + 0x80; - b = (b + (b >> 8)) >> 8; - - stop.color[0] = ART_PIX_MAX_FROM_8(r); - stop.color[1] = ART_PIX_MAX_FROM_8(g); - stop.color[2] = ART_PIX_MAX_FROM_8(b); - stop.color[3] = ART_PIX_MAX_FROM_8(a); - } - - if (stopList.isEmpty()) - return 0; - - ArtGradientStop *stops = new ArtGradientStop[stopList.count()]; - - TQValueList<ArtGradientStop>::iterator it = stopList.begin(); - TQValueList<ArtGradientStop>::iterator end = stopList.end(); - - for (int i = 0; it != end; ++i, ++it) - stops[i] = *it; - - return stops; - } - - TQPointArray parsePoints(TQString points) - { - if(points.isEmpty()) - return TQPointArray(); - - points = points.simplifyWhiteSpace(); - - if(points.contains(",,") || points.contains(", ,")) - return TQPointArray(); - - points.replace(',', ' '); - points.replace('\r', TQString()); - points.replace('\n', TQString()); - - points = points.simplifyWhiteSpace(); - - TQStringList pointList = TQStringList::split(' ', points); - - TQPointArray array(pointList.count() / 2); - int i = 0; - - for(TQStringList::Iterator it = pointList.begin(); it != pointList.end(); it++) - { - float x = (*(it++)).toFloat(); - float y = (*(it)).toFloat(); - - array.setPoint(i, static_cast<int>(x), static_cast<int>(y)); - i++; - } - - return array; - } - - void parseTransform(const TQString &transform) - { - // Combine new and old matrix - TQWMatrix matrix = m_engine->painter()->parseTransform(transform); - - TQWMatrix *current = m_engine->painter()->tqworldMatrix(); -#ifdef USE_QT4 -printf("[FIXME] *current = matrix * *current locks up under Qt4; bypassing for now\n\r"); -#else // USE_QT4 - *current = matrix * *current; -#endif // USE_QT4 - } - - void parseCommonAttributes(TQDomNode &node) - { - // Set important default attributes - m_engine->painter()->setFillColor("black"); - m_engine->painter()->setStrokeColor("none"); - m_engine->painter()->setStrokeDashArray(""); - m_engine->painter()->setStrokeWidth(1); - m_engine->painter()->setJoinStyle(""); - m_engine->painter()->setCapStyle(""); - // m_engine->painter()->setFillOpacity(255, true); - // m_engine->painter()->setStrokeOpacity(255, true); - - // Collect parent node's attributes - TQPtrList<TQDomNamedNodeMap> applyList; - applyList.setAutoDelete(true); - - TQDomNode tqshape = node.parentNode(); - for(; !tqshape.isNull() ; tqshape = tqshape.parentNode()) - applyList.prepend(new TQDomNamedNodeMap(tqshape.attributes())); - - // Apply parent attributes - for(TQDomNamedNodeMap *map = applyList.first(); map != 0; map = applyList.next()) - { - TQDomNamedNodeMap attr = *map; - - for(unsigned int i = 0; i < attr.count(); i++) - { - TQString name, value; - - name = attr.item(i).nodeName().lower(); - value = attr.item(i).nodeValue(); - - if(name == "transform") - parseTransform(value); - else if(name == "style") - parseStyle(value); - else - parsePA(name, value); - } - } - - // Apply local attributes - TQDomNamedNodeMap attr = node.attributes(); - - for(unsigned int i = 0; i < attr.count(); i++) - { - TQDomNode current = attr.item(i); - - if(current.nodeName().lower() == "transform") - parseTransform(current.nodeValue()); - else if(current.nodeName().lower() == "style") - parseStyle(current.nodeValue()); - else - parsePA(current.nodeName().lower(), current.nodeValue()); - } - } - - bool handleTags(TQDomElement element, bool paint) - { - if(element.attribute("display") == "none") - return false; - if(element.tagName() == "linearGradient") - { - ArtGradientLinear *gradient = new ArtGradientLinear(); - - int offsets = -1; - gradient->stops = parseGradientStops(element, offsets); - gradient->n_stops = offsets + 1; - - TQString spread = element.attribute("spreadMethod"); - if(spread == "repeat") - gradient->spread = ART_GRADIENT_REPEAT; - else if(spread == "reflect") - gradient->spread = ART_GRADIENT_REFLECT; - else - gradient->spread = ART_GRADIENT_PAD; - - m_engine->painter()->addLinearGradient(element.attribute("id"), gradient); - m_engine->painter()->addLinearGradientElement(gradient, element); - return true; - } - else if(element.tagName() == "radialGradient") - { - ArtGradientRadial *gradient = new ArtGradientRadial(); - - int offsets = -1; - gradient->stops = parseGradientStops(element, offsets); - gradient->n_stops = offsets + 1; - - m_engine->painter()->addRadialGradient(element.attribute("id"), gradient); - m_engine->painter()->addRadialGradientElement(gradient, element); - return true; - } - - if(!paint) - return true; - - // TODO: Default attribute values - if(element.tagName() == "rect") - { - double x = toPixel(element.attribute("x"), true); - double y = toPixel(element.attribute("y"), false); - double w = toPixel(element.attribute("width"), true); - double h = toPixel(element.attribute("height"), false); - - double rx = 0.0; - double ry = 0.0; - - if(element.hasAttribute("rx")) - rx = toPixel(element.attribute("rx"), true); - - if(element.hasAttribute("ry")) - ry = toPixel(element.attribute("ry"), false); - - m_engine->painter()->drawRectangle(x, y, w, h, rx, ry); - } - else if(element.tagName() == "switch") - { - TQDomNode iterate = element.firstChild(); - - while(!iterate.isNull()) - { - // Reset matrix - m_engine->painter()->setWorldMatrix(new TQWMatrix(m_initialMatrix)); - - // Parse common attributes, style / transform - parseCommonAttributes(iterate); - - if(handleTags(iterate.toElement(), true)) - return true; - iterate = iterate.nextSibling(); - } - return true; - } - else if(element.tagName() == "g" || element.tagName() == "defs") - { - TQDomNode iterate = element.firstChild(); - - while(!iterate.isNull()) - { - // Reset matrix - m_engine->painter()->setWorldMatrix(new TQWMatrix(m_initialMatrix)); - - // Parse common attributes, style / transform - parseCommonAttributes(iterate); - - handleTags(iterate.toElement(), (element.tagName() == "defs") ? false : true); - iterate = iterate.nextSibling(); - } - return true; - } - else if(element.tagName() == "line") - { - double x1 = toPixel(element.attribute("x1"), true); - double y1 = toPixel(element.attribute("y1"), false); - double x2 = toPixel(element.attribute("x2"), true); - double y2 = toPixel(element.attribute("y2"), false); - - m_engine->painter()->drawLine(x1, y1, x2, y2); - return true; - } - else if(element.tagName() == "circle") - { - double cx = toPixel(element.attribute("cx"), true); - double cy = toPixel(element.attribute("cy"), false); - - double r = toPixel(element.attribute("r"), true); // TODO: horiz correct? - - m_engine->painter()->drawEllipse(cx, cy, r, r); - return true; - } - else if(element.tagName() == "ellipse") - { - double cx = toPixel(element.attribute("cx"), true); - double cy = toPixel(element.attribute("cy"), false); - - double rx = toPixel(element.attribute("rx"), true); - double ry = toPixel(element.attribute("ry"), false); - - m_engine->painter()->drawEllipse(cx, cy, rx, ry); - return true; - } - else if(element.tagName() == "polyline") - { - TQPointArray polyline = parsePoints(element.attribute("points")); - m_engine->painter()->drawPolyline(polyline); - return true; - } - else if(element.tagName() == "polygon") - { - TQPointArray polygon = parsePoints(element.attribute("points")); - m_engine->painter()->drawPolygon(polygon); - return true; - } - else if(element.tagName() == "path") - { - bool filled = true; - - if(element.hasAttribute("fill") && element.attribute("fill").contains("none")) - filled = false; - - if(element.attribute("style").contains("fill") && element.attribute("style").stripWhiteSpace().contains("fill:none")) - filled = false; - - m_engine->painter()->drawPath(element.attribute("d"), filled); - return true; - } - else if(element.tagName() == "image") - { - double x = toPixel(element.attribute("x"), true); - double y = toPixel(element.attribute("y"), false); - double w = toPixel(element.attribute("width"), true); - double h = toPixel(element.attribute("height"), false); - - TQString href = element.attribute("xlink:href"); - - TQImage image; - if(href.startsWith("data:")) - { - // Get input - TQCString input = TQString(href.remove(TQRegExp("^data:image/.*;base64,"))).utf8(); - - // Decode into 'output' - TQByteArray output; - KCodecs::base64Decode(input, output); - - // Display - image.loadFromData(output); - } - else - image.load(href); - - if (!image.isNull()) - { - // Scale, if needed - if(image.width() != (int) w || image.height() != (int) h) - image = image.smoothScale((int) w, (int) h, TQ_ScaleFree); - - m_engine->painter()->drawImage(x, y, image); - } - - return true; - } - return false; - } - - void parseStyle(const TQString &style) - { - TQStringList substyles = TQStringList::split(';', style); - for(TQStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) - { - TQStringList substyle = TQStringList::split(':', (*it)); - TQString command = substyle[0]; - TQString params = substyle[1]; - command = command.stripWhiteSpace(); - params = params.stripWhiteSpace(); - - parsePA(command, params); - } - } - - void parsePA(const TQString &command, const TQString &value) - { - if(command == "stroke-width") // TODO: horiz:false correct? - m_engine->painter()->setStrokeWidth(toPixel(value, false)); - else if(command == "stroke-miterlimit") - m_engine->painter()->setStrokeMiterLimit(value); - else if(command == "stroke-linecap") - m_engine->painter()->setCapStyle(value); - else if(command == "stroke-linejoin") - m_engine->painter()->setJoinStyle(value); - else if(command == "stroke-dashoffset") - m_engine->painter()->setStrokeDashOffset(value); - else if(command == "stroke-dasharray" && value != "none") - m_engine->painter()->setStrokeDashArray(value); - else if(command == "stroke") - m_engine->painter()->setStrokeColor(value); - else if(command == "fill") - m_engine->painter()->setFillColor(value); - else if(command == "fill-rule") - m_engine->painter()->setFillRule(value); - else if(command == "fill-opacity" || command == "stroke-opacity" || command == "opacity") - { - if(command == "fill-opacity") - m_engine->painter()->setFillOpacity(value); - else if(command == "stroke-value") - m_engine->painter()->setStrokeOpacity(value); - else - { - m_engine->painter()->setOpacity(value); - m_engine->painter()->setFillOpacity(value); - m_engine->painter()->setStrokeOpacity(value); - } - } - } - -private: - friend class KSVGIconEngine; - - KSVGIconEngine *m_engine; - TQWMatrix m_initialMatrix; -}; - -struct KSVGIconEngine::Private -{ - KSVGIconPainter *painter; - KSVGIconEngineHelper *helper; - - double width; - double height; -}; - -KSVGIconEngine::KSVGIconEngine() : d(new Private()) -{ - d->painter = 0; - d->helper = new KSVGIconEngineHelper(this); - - d->width = 0.0; - d->height = 0.0; -} - -KSVGIconEngine::~KSVGIconEngine() -{ - if(d->painter) - delete d->painter; - - delete d->helper; - - delete d; -} - -bool KSVGIconEngine::load(int width, int height, const TQString &path) -{ - if(path.isNull()) return false; - - TQDomDocument svgDocument("svg"); - TQFile file(path); - - if(path.right(3).upper() == "SVG") - { - // Open SVG Icon - if(!file.open(IO_ReadOnly)) - return false; - - svgDocument.setContent(&file); - } - else // SVGZ - { - gzFile svgz = gzopen(path.latin1(), "ro"); - if(!svgz) - return false; - - TQString data; - bool done = false; - - TQCString buffer(1024); - int length = 0; - - while(!done) - { - int ret = gzread(svgz, buffer.data() + length, 1024); - if(ret == 0) - done = true; - else if(ret == -1) - return false; - else { - buffer.resize(buffer.size()+1024); - length += ret; - } - } - - gzclose(svgz); - - svgDocument.setContent(buffer); - } - - if(svgDocument.isNull()) - return false; - - // Check for root element - TQDomNode rootNode = svgDocument.namedItem("svg"); - if(rootNode.isNull() || !rootNode.isElement()) - return false; - - // Detect width and height - TQDomElement rootElement = rootNode.toElement(); - - // Create icon painter - d->painter = new KSVGIconPainter(width, height); - - d->width = width; // this sets default for no width -> 100% case - if(rootElement.hasAttribute("width")) - d->width = d->helper->toPixel(rootElement.attribute("width"), true); - - d->height = height; // this sets default for no height -> 100% case - if(rootElement.hasAttribute("height")) - d->height = d->helper->toPixel(rootElement.attribute("height"), false); - - // Create icon painter - d->painter->setDrawWidth(static_cast<int>(d->width)); - d->painter->setDrawHeight(static_cast<int>(d->height)); - - // Set viewport clipping rect - d->painter->setClippingRect(0, 0, width, height); - - // Apply viewbox - if(rootElement.hasAttribute("viewBox")) - { - TQStringList points = TQStringList::split(' ', rootElement.attribute("viewBox").simplifyWhiteSpace()); - - float w = points[2].toFloat(); - float h = points[3].toFloat(); - - double vratiow = width / w; - double vratioh = height / h; - - d->width = w; - d->height = h; - - d->painter->tqworldMatrix()->scale(vratiow, vratioh); - } - else - { - // Fit into 'width' and 'height' - // FIXME: Use an aspect ratio - double ratiow = width / d->width; - double ratioh = height / d->height; - - d->painter->tqworldMatrix()->scale(ratiow, ratioh); - } - - TQWMatrix initialMatrix = *d->painter->tqworldMatrix(); - d->helper->m_initialMatrix = initialMatrix; - - // Apply transform - if(rootElement.hasAttribute("transform")) - d->helper->parseTransform(rootElement.attribute("transform")); - - // Go through all elements - TQDomNode svgNode = rootElement.firstChild(); - while(!svgNode.isNull()) - { - TQDomElement svgChild = svgNode.toElement(); - if(!svgChild.isNull()) - { - d->helper->parseCommonAttributes(svgNode); - d->helper->handleTags(svgChild, true); - } - - svgNode = svgNode.nextSibling(); - - // Reset matrix - d->painter->setWorldMatrix(new TQWMatrix(initialMatrix)); - } - - d->painter->finish(); - - return true; -} - -KSVGIconPainter *KSVGIconEngine::painter() -{ - return d->painter; -} - -TQImage *KSVGIconEngine::image() -{ - return d->painter->image(); -} - -double KSVGIconEngine::width() -{ - return d->width; -} - -double KSVGIconEngine::height() -{ - return d->height; -} - -// vim:ts=4:noet diff --git a/kdecore/svgicons/ksvgiconengine.h b/kdecore/svgicons/ksvgiconengine.h deleted file mode 100644 index 3ef2063e9..000000000 --- a/kdecore/svgicons/ksvgiconengine.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2002 Nikolas Zimmermann <wildfox@kde.org> - This file is part of the KDE project - - 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 KSVGIconEngine_H -#define KSVGIconEngine_H - -#include <kdelibs_export.h> - -/** \internal DO NOT USE! */ - -class KSVGIconPainter; - -class KDECORE_EXPORT KSVGIconEngine -{ -public: - KSVGIconEngine(); - ~KSVGIconEngine(); - - bool load(int width, int height, const TQString &path); - - KSVGIconPainter *painter(); - TQImage *image(); - - double width(); - double height(); - -private: - struct Private; - Private *d; -}; - -#endif diff --git a/kdecore/svgicons/ksvgiconpainter.cpp b/kdecore/svgicons/ksvgiconpainter.cpp deleted file mode 100644 index 2f988ce78..000000000 --- a/kdecore/svgicons/ksvgiconpainter.cpp +++ /dev/null @@ -1,2837 +0,0 @@ -/* - Copyright (C) 2002 Nikolas Zimmermann <wildfox@kde.org> - This file is part of the KDE project - - 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 - aint 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 <tqvaluevector.h> -#include <tqstringlist.h> -#include <tqwmatrix.h> -#include <tqregexp.h> -#include <tqimage.h> -#include <tqdict.h> -#include <tqmap.h> -#include <tqdom.h> - -#include <math.h> - -#include <kdebug.h> - -#include <libart_lgpl/art_rgba.h> -#include <libart_lgpl/art_bpath.h> -#include <libart_lgpl/art_vpath.h> -#include <libart_lgpl/art_vpath_dash.h> -#include <libart_lgpl/art_affine.h> -#include <libart_lgpl/art_render_svp.h> -#include <libart_lgpl/art_svp.h> -#include <libart_lgpl/art_svp_vpath.h> -#include <libart_lgpl/art_svp_intersect.h> -#include <libart_lgpl/art_svp_vpath_stroke.h> - -#include "ksvgiconpainter.h" - -#define ART_END2 10 - -const double deg2rad = 0.017453292519943295769; // pi/180 - -class KSVGIconPainterHelper -{ -public: - KSVGIconPainterHelper(int width, int height, KSVGIconPainter *painter) - { - m_painter = painter; - - m_clipSVP = 0; - - m_fillColor = Qt::black; - - m_useFill = true; - m_useStroke = false; - - m_useFillGradient = false; - m_useStrokeGradient = false; - - m_tqworldMatrix = new TQWMatrix(); - - // Create new image with alpha support - m_image = new TQImage(width, height, 32); - m_image->setAlphaBuffer(true); - - m_strokeWidth = 1.0; - m_strokeMiterLimit = 4; - m_dashOffset = 0; - m_dashes = ""; - - m_opacity = 0xff; - m_fillOpacity = 0xff; - m_strokeOpacity = 0xff; - - m_fillRule = "nonzero"; - - m_width = width; - m_height = height; - - m_rowstride = m_width * 4; - - // Make internal libart rendering buffer transparent - m_buffer = art_new(art_u8, m_rowstride * m_height); - memset(m_buffer, 0, m_rowstride * m_height); - - m_tempBuffer = 0; - } - - ~KSVGIconPainterHelper() - { - if(m_clipSVP) - art_svp_free(m_clipSVP); - - art_free(m_buffer); - - delete m_image; - delete m_tqworldMatrix; - - for(TQMap<TQString, ArtGradientLinear *>::Iterator it = m_linearGradientMap.begin(); it != m_linearGradientMap.end(); ++it) - { - if (!it.data()) - continue; - delete [] it.data()->stops; - delete it.data(); - } - for(TQMap<TQString, ArtGradientRadial *>::Iterator it = m_radialGradientMap.begin(); it != m_radialGradientMap.end(); ++it) - { - if (!it.data()) - continue; - delete [] it.data()->stops; - delete it.data(); - } - } - - ArtVpath *allocVPath(int number) - { - return art_new(ArtVpath, number); - } - - ArtBpath *allocBPath(int number) - { - return art_new(ArtBpath, number); - } - - void ensureSpace(TQMemArray<ArtBpath> &vec, int index) - { - if(vec.size() == (unsigned int) index) - vec.resize(index + 1); - } - - void createBuffer() - { - m_tempBuffer = art_new(art_u8, m_rowstride * m_height); - memset(m_tempBuffer, 0, m_rowstride * m_height); - - // Swap buffers, so we work with the new one internally... - art_u8 *temp = m_buffer; - m_buffer = m_tempBuffer; - m_tempBuffer = temp; - } - - void mixBuffer(int opacity) - { - art_u8 *srcPixel = m_buffer; - art_u8 *dstPixel = m_tempBuffer; - - for(int y = 0; y < m_height; y++) - { - for(int x = 0; x < m_width; x++) - { - art_u8 r, g, b, a; - - a = srcPixel[4 * x + 3]; - - if(a) - { - r = srcPixel[4 * x]; - g = srcPixel[4 * x + 1]; - b = srcPixel[4 * x + 2]; - - int temp = a * opacity + 0x80; - a = (temp + (temp >> 8)) >> 8; - art_rgba_run_alpha(dstPixel + 4 * x, r, g, b, a, 1); - } - } - - srcPixel += m_rowstride; - dstPixel += m_rowstride; - } - - // Re-swap again... - art_u8 *temp = m_buffer; - m_buffer = m_tempBuffer; - m_tempBuffer = temp; - - art_free(m_tempBuffer); - m_tempBuffer = 0; - } - - TQ_UINT32 toArtColor(const TQColor &color) - { - // Convert in a libart suitable form - TQString tempName = color.name(); - const char *str = tempName.latin1(); - - int result = 0; - - for(int i = 1; str[i]; i++) - { - int hexval; - if(str[i] >= '0' && str[i] <= '9') - hexval = str[i] - '0'; - else if (str[i] >= 'A' && str[i] <= 'F') - hexval = str[i] - 'A' + 10; - else if (str[i] >= 'a' && str[i] <= 'f') - hexval = str[i] - 'a' + 10; - else - break; - - result = (result << 4) + hexval; - } - - return result; - } - - void drawSVP(ArtSVP *svp, TQ_UINT32 rgb, int opacity) - { - if(!svp) - return; - - ArtRender *render = art_render_new(0, 0, m_width, m_height, m_buffer, m_rowstride, 3, 8, ART_ALPHA_SEPARATE, 0); - art_render_svp(render, svp); - - art_render_mask_solid(render, (opacity << 8) + opacity + (opacity >> 7)); - - ArtPixMaxDepth color[3]; - color[0] = ART_PIX_MAX_FROM_8(rgb >> 16); - color[1] = ART_PIX_MAX_FROM_8((rgb >> 8) & 0xff); - color[2] = ART_PIX_MAX_FROM_8(rgb & 0xff); - - art_render_image_solid(render, color); - art_render_invoke(render); - } - - void drawBPath(ArtBpath *bpath) - { - double affine[6]; - affine[0] = m_tqworldMatrix->m11(); - affine[1] = m_tqworldMatrix->m12(); - affine[2] = m_tqworldMatrix->m21(); - affine[3] = m_tqworldMatrix->m22(); - affine[4] = m_tqworldMatrix->dx(); - affine[5] = m_tqworldMatrix->dy(); - - ArtBpath *temp = art_bpath_affine_transform(bpath, affine); - ArtVpath *vec = art_bez_path_to_vec(temp, 0.25); - art_free(temp); - drawPathInternal(vec, affine); - } - - void drawVPath(ArtVpath *vec) - { - double affine[6]; - affine[0] = m_tqworldMatrix->m11(); - affine[1] = m_tqworldMatrix->m12(); - affine[2] = m_tqworldMatrix->m21(); - affine[3] = m_tqworldMatrix->m22(); - affine[4] = m_tqworldMatrix->dx(); - affine[5] = m_tqworldMatrix->dy(); - - ArtVpath *temp = art_vpath_affine_transform(vec, affine); - art_free(vec); - vec = temp; - drawPathInternal(vec, affine); - } - - void drawPathInternal(ArtVpath *vec, double *affine) - { - ArtSVP *svp; - ArtSVP *fillSVP = 0, *strokeSVP = 0; - - TQ_UINT32 fillColor = 0, strokeColor = 0; - - // Filling - { - int index = -1; - TQValueVector<int> toCorrect; - while(vec[++index].code != ART_END) - { - if(vec[index].code == ART_END2) - { - vec[index].code = ART_LINETO; - toCorrect.push_back(index); - } - } - - fillColor = toArtColor(m_fillColor); - - ArtSvpWriter *swr; - ArtSVP *temp; - temp = art_svp_from_vpath(vec); - - if(m_fillRule == "evenodd") - swr = art_svp_writer_rewind_new(ART_WIND_RULE_ODDEVEN); - else - swr = art_svp_writer_rewind_new(ART_WIND_RULE_NONZERO); - - art_svp_intersector(temp, swr); - svp = art_svp_writer_rewind_reap(swr); - - fillSVP = svp; - - art_svp_free(temp); - - TQValueVector<int>::iterator it; - for(it = toCorrect.begin(); it != toCorrect.end(); ++it) - vec[(*it)].code = (ArtPathcode)ART_END2; - } - - // There seems to be a problem when stroke width is zero, this is a quick - // fix (Rob). - if(m_strokeWidth <= 0) - m_useStroke = m_useStrokeGradient = false; - - // Stroking - if(m_useStroke || m_useStrokeGradient) - { - strokeColor = toArtColor(m_strokeColor); - - double ratio = art_affine_expansion(affine); - double strokeWidth = m_strokeWidth * ratio; - - ArtPathStrokeJoinType joinStyle = ART_PATH_STROKE_JOIN_MITER; - ArtPathStrokeCapType capStyle = ART_PATH_STROKE_CAP_BUTT; - - if(m_joinStyle == "miter") - joinStyle = ART_PATH_STROKE_JOIN_MITER; - else if(m_joinStyle == "round") - joinStyle = ART_PATH_STROKE_JOIN_ROUND; - else if(m_joinStyle == "bevel") - joinStyle = ART_PATH_STROKE_JOIN_BEVEL; - - if(m_capStyle == "butt") - capStyle = ART_PATH_STROKE_CAP_BUTT; - else if(m_capStyle == "round") - capStyle = ART_PATH_STROKE_CAP_ROUND; - else if(m_capStyle == "square") - capStyle = ART_PATH_STROKE_CAP_SQUARE; - - if(m_dashes.length() > 0) - { - TQRegExp reg("[, ]"); - TQStringList dashList = TQStringList::split(reg, m_dashes); - - double *dashes = new double[dashList.count()]; - for(unsigned int i = 0; i < dashList.count(); i++) - dashes[i] = m_painter->toPixel(dashList[i], true); - - ArtVpathDash dash; - dash.offset = m_dashOffset; - dash.n_dash = dashList.count(); - - dash.dash = dashes; - - ArtVpath *vec2 = art_vpath_dash(vec, &dash); - art_free(vec); - - delete[] dashes; - - vec = vec2; - } - - svp = art_svp_vpath_stroke(vec, joinStyle, capStyle, strokeWidth, m_strokeMiterLimit, 0.25); - - strokeSVP = svp; - } - - // Apply opacity - int fillOpacity = static_cast<int>(m_fillOpacity); - int strokeOpacity = static_cast<int>(m_strokeOpacity); - int opacity = static_cast<int>(m_opacity); - - // Needed hack, to support both transparent - // paths and transparent gradients - if(fillOpacity == strokeOpacity && fillOpacity == opacity && !m_useFillGradient && !m_useStrokeGradient) - opacity = 255; - - if(fillOpacity != 255) - { - int temp = fillOpacity * opacity + 0x80; - fillOpacity = (temp + (temp >> 8)) >> 8; - } - - if(strokeOpacity != 255) - { - int temp = strokeOpacity * opacity + 0x80; - strokeOpacity = (temp + (temp >> 8)) >> 8; - } - - // Create temporary buffer if necessary - bool tempDone = false; - if(m_opacity != 0xff) - { - tempDone = true; - createBuffer(); - } - - // Apply Gradients on fill/stroke - if(m_useFillGradient) - applyGradient(fillSVP, true); - else if(m_useFill) - drawSVP(fillSVP, fillColor, fillOpacity); - - if(m_useStrokeGradient) - applyGradient(strokeSVP, false); - else if(m_useStroke) - drawSVP(strokeSVP, strokeColor, strokeOpacity); - - // Mix in temporary buffer, if possible - if(tempDone) - mixBuffer(opacity); - - if(m_clipSVP) - { - art_svp_free(m_clipSVP); - m_clipSVP = 0; - } - - if(fillSVP) - art_svp_free(fillSVP); - - if(strokeSVP) - art_svp_free(strokeSVP); - - // Reset opacity values - m_opacity = 255.0; - m_fillOpacity = 255.0; - m_strokeOpacity = 255.0; - - art_free(vec); - } - - void applyLinearGradient(ArtSVP *svp, const TQString &ref) - { - ArtGradientLinear *linear = m_linearGradientMap[ref]; - if(linear) - { - TQDomElement element = m_linearGradientElementMap[linear]; - - double x1, y1, x2, y2; - if(element.hasAttribute("x1")) - x1 = m_painter->toPixel(element.attribute("x1"), true); - else - x1 = 0; - - if(element.hasAttribute("y1")) - y1 = m_painter->toPixel(element.attribute("y1"), false); - else - y1 = 0; - - if(element.hasAttribute("x2")) - x2 = m_painter->toPixel(element.attribute("x2"), true); - else - x2 = 100; - - if(element.hasAttribute("y2")) - y2 = m_painter->toPixel(element.attribute("y2"), false); - else - y2 = 0; - - // Adjust to gradientTransform - TQWMatrix m = m_painter->parseTransform(element.attribute("gradientTransform")); - m.map(x1, y1, &x1, &y1); - m.map(x2, y2, &x2, &y2); - - double x1n = x1 * m_tqworldMatrix->m11() + y1 * m_tqworldMatrix->m21() + m_tqworldMatrix->dx(); - double y1n = x1 * m_tqworldMatrix->m12() + y1 * m_tqworldMatrix->m22() + m_tqworldMatrix->dy(); - double x2n = x2 * m_tqworldMatrix->m11() + y2 * m_tqworldMatrix->m21() + m_tqworldMatrix->dx(); - double y2n = x2 * m_tqworldMatrix->m12() + y2 * m_tqworldMatrix->m22() + m_tqworldMatrix->dy(); - - double dx = x2n - x1n; - double dy = y2n - y1n; - double scale = 1.0 / (dx * dx + dy * dy); - - linear->a = dx * scale; - linear->b = dy * scale; - linear->c = -(x1n * linear->a + y1n * linear->b); - - ArtRender *render = art_render_new(0, 0, m_width, m_height, m_buffer, m_rowstride, 3, 8, ART_ALPHA_SEPARATE, 0); - art_render_svp(render, svp); - - art_render_gradient_linear(render, linear, ART_FILTER_HYPER); - art_render_invoke(render); - } - } - - void applyRadialGradient(ArtSVP *svp, const TQString &ref) - { - ArtGradientRadial *radial = m_radialGradientMap[ref]; - if(radial) - { - TQDomElement element = m_radialGradientElementMap[radial]; - - double cx, cy, r, fx, fy; - if(element.hasAttribute("cx")) - cx = m_painter->toPixel(element.attribute("cx"), true); - else - cx = 50; - - if(element.hasAttribute("cy")) - cy = m_painter->toPixel(element.attribute("cy"), false); - else - cy = 50; - - if(element.hasAttribute("r")) - r = m_painter->toPixel(element.attribute("r"), true); - else - r = 50; - - if(element.hasAttribute("fx")) - fx = m_painter->toPixel(element.attribute("fx"), false); - else - fx = cx; - - if(element.hasAttribute("fy")) - fy = m_painter->toPixel(element.attribute("fy"), false); - else - fy = cy; - - radial->affine[0] = m_tqworldMatrix->m11(); - radial->affine[1] = m_tqworldMatrix->m12(); - radial->affine[2] = m_tqworldMatrix->m21(); - radial->affine[3] = m_tqworldMatrix->m22(); - radial->affine[4] = m_tqworldMatrix->dx(); - radial->affine[5] = m_tqworldMatrix->dy(); - - radial->fx = (fx - cx) / r; - radial->fy = (fy - cy) / r; - - double aff1[6], aff2[6], gradTransform[6]; - - // Respect gradientTransform - TQWMatrix m = m_painter->parseTransform(element.attribute("gradientTransform")); - - gradTransform[0] = m.m11(); - gradTransform[1] = m.m12(); - gradTransform[2] = m.m21(); - gradTransform[3] = m.m22(); - gradTransform[4] = m.dx(); - gradTransform[5] = m.dy(); - - art_affine_scale(aff1, r, r); - art_affine_translate(aff2, cx, cy); - - art_affine_multiply(aff1, aff1, aff2); - art_affine_multiply(aff1, aff1, gradTransform); - art_affine_multiply(aff1, aff1, radial->affine); - art_affine_invert(radial->affine, aff1); - - ArtRender *render = art_render_new(0, 0, m_width, m_height, m_buffer, m_rowstride, 3, 8, ART_ALPHA_SEPARATE, 0); - art_render_svp(render, svp); - - art_render_gradient_radial(render, radial, ART_FILTER_HYPER); - art_render_invoke(render); - } - } - - void applyGradient(ArtSVP *svp, const TQString &ref) - { - ArtGradientLinear *linear = m_linearGradientMap[ref]; - if(linear) - { - TQDomElement element = m_linearGradientElementMap[linear]; - - if(!element.hasAttribute("xlink:href")) - { - applyLinearGradient(svp, ref); - return; - } - else - { - ArtGradientLinear *linear = m_linearGradientMap[element.attribute("xlink:href").mid(1)]; - TQDomElement newElement = m_linearGradientElementMap[linear]; - - // Saved 'old' attributes - TQDict<TQString> refattrs; - refattrs.setAutoDelete(true); - - for(unsigned int i = 0; i < newElement.attributes().length(); ++i) - refattrs.insert(newElement.attributes().item(i).nodeName(), new TQString(newElement.attributes().item(i).nodeValue())); - - // Copy attributes - if(!newElement.isNull()) - { - TQDomNamedNodeMap attr = element.attributes(); - - for(unsigned int i = 0; i < attr.length(); i++) - { - TQString name = attr.item(i).nodeName(); - if(name != "xlink:href" && name != "id") - newElement.setAttribute(name, attr.item(i).nodeValue()); - } - } - - applyGradient(svp, element.attribute("xlink:href").mid(1)); - - // Restore attributes - TQDictIterator<TQString> itr(refattrs); - for(; itr.current(); ++itr) - newElement.setAttribute(itr.currentKey(), *(itr.current())); - - return; - } - } - - ArtGradientRadial *radial = m_radialGradientMap[ref]; - if(radial) - { - TQDomElement element = m_radialGradientElementMap[radial]; - - if(!element.hasAttribute("xlink:href")) - { - applyRadialGradient(svp, ref); - return; - } - else - { - ArtGradientRadial *radial = m_radialGradientMap[element.attribute("xlink:href").mid(1)]; - TQDomElement newElement = m_radialGradientElementMap[radial]; - - // Saved 'old' attributes - TQDict<TQString> refattrs; - refattrs.setAutoDelete(true); - - for(unsigned int i = 0; i < newElement.attributes().length(); ++i) - refattrs.insert(newElement.attributes().item(i).nodeName(), new TQString(newElement.attributes().item(i).nodeValue())); - - // Copy attributes - if(!newElement.isNull()) - { - TQDomNamedNodeMap attr = element.attributes(); - - for(unsigned int i = 0; i < attr.length(); i++) - { - TQString name = attr.item(i).nodeName(); - if(name != "xlink:href" && name != "id") - newElement.setAttribute(name, attr.item(i).nodeValue()); - } - } - - applyGradient(svp, element.attribute("xlink:href").mid(1)); - - // Restore attributes - TQDictIterator<TQString> itr(refattrs); - for(; itr.current(); ++itr) - newElement.setAttribute(itr.currentKey(), *(itr.current())); - - return; - } - } - } - - void applyGradient(ArtSVP *svp, bool fill) - { - TQString ref; - - if(fill) - { - m_useFillGradient = false; - ref = m_fillGradientReference; - } - else - { - m_useStrokeGradient = false; - ref = m_strokeGradientReference; - } - - applyGradient(svp, ref); - } - - void blit() - { - unsigned char *line = m_buffer; - - for(int y = 0; y < m_height; y++) - { - QRgb *sl = reinterpret_cast<QRgb *>(m_image->scanLine(y)); - for(int x = 0; x < m_width; x++) - sl[x] = tqRgba(line[x * 4], line[x * 4 + 1], line[x * 4 + 2], line[x * 4 + 3]); - - line += m_rowstride; - } - } - - void calculateArc(bool relative, TQMemArray<ArtBpath> &vec, int &index, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag) - { - double sin_th, cos_th; - double a00, a01, a10, a11; - double x0, y0, x1, y1, xc, yc; - double d, sfactor, sfactor_sq; - double th0, th1, th_arc; - int i, n_segs; - - sin_th = sin(angle * (M_PI / 180.0)); - cos_th = cos(angle * (M_PI / 180.0)); - - double dx; - - if(!relative) - dx = (curx - x) / 2.0; - else - dx = -x / 2.0; - - double dy; - - if(!relative) - dy = (cury - y) / 2.0; - else - dy = -y / 2.0; - - double _x1 = cos_th * dx + sin_th * dy; - double _y1 = -sin_th * dx + cos_th * dy; - double Pr1 = r1 * r1; - double Pr2 = r2 * r2; - double Px = _x1 * _x1; - double Py = _y1 * _y1; - - // Spec : check if radii are large enough - double check = Px / Pr1 + Py / Pr2; - if(check > 1) - { - r1 = r1 * sqrt(check); - r2 = r2 * sqrt(check); - } - - a00 = cos_th / r1; - a01 = sin_th / r1; - a10 = -sin_th / r2; - a11 = cos_th / r2; - - x0 = a00 * curx + a01 * cury; - y0 = a10 * curx + a11 * cury; - - if(!relative) - x1 = a00 * x + a01 * y; - else - x1 = a00 * (curx + x) + a01 * (cury + y); - - if(!relative) - y1 = a10 * x + a11 * y; - else - y1 = a10 * (curx + x) + a11 * (cury + y); - - /* (x0, y0) is current point in transformed coordinate space. - (x1, y1) is new point in transformed coordinate space. - - The arc fits a unit-radius circle in this space. - */ - - d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); - - sfactor_sq = 1.0 / d - 0.25; - - if(sfactor_sq < 0) - sfactor_sq = 0; - - sfactor = sqrt(sfactor_sq); - - if(sweepFlag == largeArcFlag) - sfactor = -sfactor; - - xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0); - yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0); - - /* (xc, yc) is center of the circle. */ - th0 = atan2(y0 - yc, x0 - xc); - th1 = atan2(y1 - yc, x1 - xc); - - th_arc = th1 - th0; - if(th_arc < 0 && sweepFlag) - th_arc += 2 * M_PI; - else if(th_arc > 0 && !sweepFlag) - th_arc -= 2 * M_PI; - - n_segs = (int) (int) ceil(fabs(th_arc / (M_PI * 0.5 + 0.001))); - - for(i = 0; i < n_segs; i++) - { - index++; - - ensureSpace(vec, index); - - { - double sin_th, cos_th; - double a00, a01, a10, a11; - double x1, y1, x2, y2, x3, y3; - double t; - double th_half; - - double _th0 = th0 + i * th_arc / n_segs; - double _th1 = th0 + (i + 1) * th_arc / n_segs; - - sin_th = sin(angle * (M_PI / 180.0)); - cos_th = cos(angle * (M_PI / 180.0)); - - /* inverse transform compared with rsvg_path_arc */ - a00 = cos_th * r1; - a01 = -sin_th * r2; - a10 = sin_th * r1; - a11 = cos_th * r2; - - th_half = 0.5 * (_th1 - _th0); - t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half); - x1 = xc + cos(_th0) - t * sin(_th0); - y1 = yc + sin(_th0) + t * cos(_th0); - x3 = xc + cos(_th1); - y3 = yc + sin(_th1); - x2 = x3 + t * sin(_th1); - y2 = y3 - t * cos(_th1); - - ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = a00 * x1 + a01 * y1; - vec[index].y1 = a10 * x1 + a11 * y1; - vec[index].x2 = a00 * x2 + a01 * y2; - vec[index].y2 = a10 * x2 + a11 * y2; - vec[index].x3 = a00 * x3 + a01 * y3; - vec[index].y3 = a10 * x3 + a11 * y3; - } - } - - if(!relative) - curx = x; - else - curx += x; - - if(!relative) - cury = y; - else - cury += y; - } - - // For any docs, see the libart library - static void art_vpath_render_bez(ArtVpath **p_vpath, int *pn, int *pn_max, - double x0, double y0, - double x1, double y1, - double x2, double y2, - double x3, double y3, - double flatness) - { - double x3_0, y3_0, z3_0_dot, z1_dot, z2_dot; - double z1_perp, z2_perp, max_perp_sq; - - double x_m, y_m, xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2; - - x3_0 = x3 - x0; - y3_0 = y3 - y0; - - z3_0_dot = x3_0 * x3_0 + y3_0 * y3_0; - - if (z3_0_dot < 0.001) - goto nosubdivide; - - max_perp_sq = flatness * flatness * z3_0_dot; - - z1_perp = (y1 - y0) * x3_0 - (x1 - x0) * y3_0; - if (z1_perp * z1_perp > max_perp_sq) - goto subdivide; - - z2_perp = (y3 - y2) * x3_0 - (x3 - x2) * y3_0; - if (z2_perp * z2_perp > max_perp_sq) - goto subdivide; - - z1_dot = (x1 - x0) * x3_0 + (y1 - y0) * y3_0; - if (z1_dot < 0 && z1_dot * z1_dot > max_perp_sq) - goto subdivide; - - z2_dot = (x3 - x2) * x3_0 + (y3 - y2) * y3_0; - if (z2_dot < 0 && z2_dot * z2_dot > max_perp_sq) - goto subdivide; - - if (z1_dot + z1_dot > z3_0_dot) - goto subdivide; - - if (z2_dot + z2_dot > z3_0_dot) - goto subdivide; - - nosubdivide: - art_vpath_add_point (p_vpath, pn, pn_max, ART_LINETO, x3, y3); - return; - - subdivide: - xa1 = (x0 + x1) * 0.5; - ya1 = (y0 + y1) * 0.5; - xa2 = (x0 + 2 * x1 + x2) * 0.25; - ya2 = (y0 + 2 * y1 + y2) * 0.25; - xb1 = (x1 + 2 * x2 + x3) * 0.25; - yb1 = (y1 + 2 * y2 + y3) * 0.25; - xb2 = (x2 + x3) * 0.5; - yb2 = (y2 + y3) * 0.5; - x_m = (xa2 + xb1) * 0.5; - y_m = (ya2 + yb1) * 0.5; - art_vpath_render_bez (p_vpath, pn, pn_max, x0, y0, xa1, ya1, xa2, ya2, x_m, y_m, flatness); - art_vpath_render_bez (p_vpath, pn, pn_max, x_m, y_m, xb1, yb1, xb2, yb2, x3, y3, flatness); - } - - ArtVpath *art_bez_path_to_vec(const ArtBpath *bez, double flatness) - { - ArtVpath *vec; - int vec_n, vec_n_max; - int bez_index; - double x, y; - - vec_n = 0; - vec_n_max = (1 << 4); - vec = art_new (ArtVpath, vec_n_max); - - x = 0; - y = 0; - - bez_index = 0; - do - { - if(vec_n >= vec_n_max) - art_expand (vec, ArtVpath, vec_n_max); - - switch (bez[bez_index].code) - { - case ART_MOVETO_OPEN: - case ART_MOVETO: - case ART_LINETO: - x = bez[bez_index].x3; - y = bez[bez_index].y3; - vec[vec_n].code = bez[bez_index].code; - vec[vec_n].x = x; - vec[vec_n].y = y; - vec_n++; - break; - case ART_END: - vec[vec_n].code = ART_END; - vec[vec_n].x = 0; - vec[vec_n].y = 0; - vec_n++; - break; - case ART_END2: - vec[vec_n].code = (ArtPathcode)ART_END2; - vec[vec_n].x = bez[bez_index].x3; - vec[vec_n].y = bez[bez_index].y3; - vec_n++; - break; - case ART_CURVETO: - art_vpath_render_bez (&vec, &vec_n, &vec_n_max, - x, y, - bez[bez_index].x1, bez[bez_index].y1, - bez[bez_index].x2, bez[bez_index].y2, - bez[bez_index].x3, bez[bez_index].y3, - flatness); - x = bez[bez_index].x3; - y = bez[bez_index].y3; - break; - } - } - - while (bez[bez_index++].code != ART_END); - return vec; - } - - static void art_rgb_affine_run(int *p_x0, int *p_x1, int y, - int src_width, int src_height, - const double affine[6]) - { - int x0, x1; - double z; - double x_intercept; - int xi; - - x0 = *p_x0; - x1 = *p_x1; - - if (affine[0] > 1e-6) - { - z = affine[2] * (y + 0.5) + affine[4]; - x_intercept = -z / affine[0]; - xi = (int) (int) ceil (x_intercept + 1e-6 - 0.5); - if (xi > x0) - x0 = xi; - x_intercept = (-z + src_width) / affine[0]; - xi = (int) ceil (x_intercept - 1e-6 - 0.5); - if (xi < x1) - x1 = xi; - } - else if (affine[0] < -1e-6) - { - z = affine[2] * (y + 0.5) + affine[4]; - x_intercept = (-z + src_width) / affine[0]; - xi = (int) ceil (x_intercept + 1e-6 - 0.5); - if (xi > x0) - x0 = xi; - x_intercept = -z / affine[0]; - xi = (int) ceil (x_intercept - 1e-6 - 0.5); - if (xi < x1) - x1 = xi; - } - else - { - z = affine[2] * (y + 0.5) + affine[4]; - if (z < 0 || z >= src_width) - { - *p_x1 = *p_x0; - return; - } - } - if (affine[1] > 1e-6) - { - z = affine[3] * (y + 0.5) + affine[5]; - x_intercept = -z / affine[1]; - xi = (int) ceil (x_intercept + 1e-6 - 0.5); - if (xi > x0) - x0 = xi; - x_intercept = (-z + src_height) / affine[1]; - xi = (int) ceil (x_intercept - 1e-6 - 0.5); - if (xi < x1) - x1 = xi; - } - else if (affine[1] < -1e-6) - { - z = affine[3] * (y + 0.5) + affine[5]; - x_intercept = (-z + src_height) / affine[1]; - xi = (int) ceil (x_intercept + 1e-6 - 0.5); - if (xi > x0) - x0 = xi; - x_intercept = -z / affine[1]; - xi = (int) ceil (x_intercept - 1e-6 - 0.5); - if (xi < x1) - x1 = xi; - } - else - { - z = affine[3] * (y + 0.5) + affine[5]; - if (z < 0 || z >= src_height) - { - *p_x1 = *p_x0; - return; - } - } - - *p_x0 = x0; - *p_x1 = x1; - } - - // Slightly modified version to support RGBA buffers, copied from gnome-print - static void art_rgba_rgba_affine(art_u8 *dst, - int x0, int y0, int x1, int y1, int dst_rowstride, - const art_u8 *src, - int src_width, int src_height, int src_rowstride, - const double affine[6]) - { - int x, y; - double inv[6]; - art_u8 *dst_p, *dst_linestart; - const art_u8 *src_p; - ArtPoint pt, src_pt; - int src_x, src_y; - int alpha; - art_u8 bg_r, bg_g, bg_b, bg_a, cr, cg, cb; - art_u8 fg_r, fg_g, fg_b; - int tmp; - int run_x0, run_x1; - - dst_linestart = dst; - art_affine_invert (inv, affine); - for (y = y0; y < y1; y++) - { - pt.y = y + 0.5; - run_x0 = x0; - run_x1 = x1; - art_rgb_affine_run (&run_x0, &run_x1, y, src_width, src_height, - inv); - dst_p = dst_linestart + (run_x0 - x0) * 4; - for (x = run_x0; x < run_x1; x++) - { - pt.x = x + 0.5; - art_affine_point (&src_pt, &pt, inv); - src_x = (int) floor (src_pt.x); - src_y = (int) floor (src_pt.y); - src_p = src + (src_y * src_rowstride) + src_x * 4; - if (src_x >= 0 && src_x < src_width && - src_y >= 0 && src_y < src_height) - { - - alpha = src_p[3]; - if (alpha) - { - if (alpha == 255) - { - dst_p[0] = src_p[0]; - dst_p[1] = src_p[1]; - dst_p[2] = src_p[2]; - dst_p[3] = 255; - } - else - { - bg_r = dst_p[0]; - bg_g = dst_p[1]; - bg_b = dst_p[2]; - bg_a = dst_p[3]; - - cr = (bg_r * bg_a + 0x80) >> 8; - cg = (bg_g * bg_g + 0x80) >> 8; - cb = (bg_b * bg_b + 0x80) >> 8; - - tmp = (src_p[0] - bg_r) * alpha; - fg_r = bg_r + ((tmp + (tmp >> 8) + 0x80) >> 8); - tmp = (src_p[1] - bg_g) * alpha; - fg_g = bg_g + ((tmp + (tmp >> 8) + 0x80) >> 8); - tmp = (src_p[2] - bg_b) * alpha; - fg_b = bg_b + ((tmp + (tmp >> 8) + 0x80) >> 8); - - dst_p[0] = fg_r; - dst_p[1] = fg_g; - dst_p[2] = fg_b; - dst_p[3] = bg_a + (((255 - bg_a) * alpha + 0x80) >> 8); - } - } - } else { dst_p[0] = 255; dst_p[1] = 0; dst_p[2] = 0; dst_p[3] = 255;} - dst_p += 4; - } - dst_linestart += dst_rowstride; - } - } - -private: - friend class KSVGIconPainter; - ArtSVP *m_clipSVP; - - TQImage *m_image; - TQWMatrix *m_tqworldMatrix; - - TQString m_fillRule; - TQString m_joinStyle; - TQString m_capStyle; - - int m_strokeMiterLimit; - - TQString m_dashes; - unsigned short m_dashOffset; - - TQColor m_fillColor; - TQColor m_strokeColor; - - art_u8 *m_buffer; - art_u8 *m_tempBuffer; - - int m_width; - int m_height; - - int m_rowstride; - - double m_opacity; - double m_fillOpacity; - double m_strokeOpacity; - - bool m_useFill; - bool m_useStroke; - - bool m_useFillGradient; - bool m_useStrokeGradient; - - TQString m_fillGradientReference; - TQString m_strokeGradientReference; - - TQMap<TQString, ArtGradientLinear *> m_linearGradientMap; - TQMap<ArtGradientLinear *, TQDomElement> m_linearGradientElementMap; - - TQMap<TQString, ArtGradientRadial *> m_radialGradientMap; - TQMap<ArtGradientRadial *, TQDomElement> m_radialGradientElementMap; - - KSVGIconPainter *m_painter; - - double m_strokeWidth; -}; - -struct KSVGIconPainter::Private -{ - KSVGIconPainterHelper *helper; - - int drawWidth; - int drawHeight; -}; - -KSVGIconPainter::KSVGIconPainter(int width, int height) : d(new Private()) -{ - d->helper = new KSVGIconPainterHelper(width, height, this); - - d->drawWidth = width; - d->drawHeight = height; -} - -KSVGIconPainter::~KSVGIconPainter() -{ - delete d->helper; - delete d; -} - -void KSVGIconPainter::setDrawWidth(int dwidth) -{ - d->drawWidth = dwidth; -} - -void KSVGIconPainter::setDrawHeight(int dheight) -{ - d->drawHeight = dheight; -} - -void KSVGIconPainter::finish() -{ - d->helper->blit(); -} - -TQImage *KSVGIconPainter::image() -{ - return new TQImage(*d->helper->m_image); -} - -TQWMatrix *KSVGIconPainter::tqworldMatrix() -{ - return d->helper->m_tqworldMatrix; -} - -void KSVGIconPainter::setWorldMatrix(TQWMatrix *matrix) -{ - if(d->helper->m_tqworldMatrix) - delete d->helper->m_tqworldMatrix; - - d->helper->m_tqworldMatrix = matrix; -} - -void KSVGIconPainter::setStrokeWidth(double width) -{ - d->helper->m_strokeWidth = width; -} - -void KSVGIconPainter::setStrokeMiterLimit(const TQString &miter) -{ - d->helper->m_strokeMiterLimit = miter.toInt(); -} - -void KSVGIconPainter::setStrokeDashOffset(const TQString &dashOffset) -{ - d->helper->m_dashOffset = dashOffset.toUInt(); -} - -void KSVGIconPainter::setStrokeDashArray(const TQString &dashes) -{ - d->helper->m_dashes = dashes; -} - -void KSVGIconPainter::setCapStyle(const TQString &cap) -{ - d->helper->m_capStyle = cap; -} - -void KSVGIconPainter::setJoinStyle(const TQString &join) -{ - d->helper->m_joinStyle = join; -} - -void KSVGIconPainter::setStrokeColor(const TQString &stroke) -{ - if(stroke.startsWith("url")) - { - d->helper->m_useStroke = false; - d->helper->m_useStrokeGradient = true; - - TQString url = stroke; - - unsigned int start = url.find("#") + 1; - unsigned int end = url.findRev(")"); - - d->helper->m_strokeGradientReference = url.mid(start, end - start); - } - else - { - d->helper->m_strokeColor = parseColor(stroke); - - d->helper->m_useStrokeGradient = false; - d->helper->m_strokeGradientReference = TQString::null; - - if(stroke.stripWhiteSpace().lower() != "none") - setUseStroke(true); - else - setUseStroke(false); - } -} - -void KSVGIconPainter::setFillColor(const TQString &fill) -{ - if(fill.startsWith("url")) - { - d->helper->m_useFill = false; - d->helper->m_useFillGradient = true; - - TQString url = fill; - - unsigned int start = url.find("#") + 1; - unsigned int end = url.findRev(")"); - - d->helper->m_fillGradientReference = url.mid(start, end - start); - } - else - { - d->helper->m_fillColor = parseColor(fill); - - d->helper->m_useFillGradient = false; - d->helper->m_fillGradientReference = TQString::null; - - if(fill.stripWhiteSpace().lower() != "none") - setUseFill(true); - else - setUseFill(false); - } -} - -void KSVGIconPainter::setFillRule(const TQString &fillRule) -{ - d->helper->m_fillRule = fillRule; -} - -TQ_UINT32 KSVGIconPainter::parseOpacity(const TQString &data) -{ - int opacity = 255; - - if(!data.isEmpty()) - { - double temp; - - if(data.contains("%")) - { - TQString tempString = data.left(data.length() - 1); - temp = double(255 * tempString.toDouble()) / 100.0; - } - else - temp = data.toDouble(); - - opacity = (int) floor(temp * 255 + 0.5); - } - - return opacity; -} - -void KSVGIconPainter::setFillOpacity(const TQString &fillOpacity) -{ - d->helper->m_fillOpacity = parseOpacity(fillOpacity); -} - -void KSVGIconPainter::setStrokeOpacity(const TQString &strokeOpacity) -{ - d->helper->m_strokeOpacity = parseOpacity(strokeOpacity); -} - -void KSVGIconPainter::setOpacity(const TQString &opacity) -{ - d->helper->m_opacity = parseOpacity(opacity); -} - -void KSVGIconPainter::setUseFill(bool fill) -{ - d->helper->m_useFill = fill; -} - -void KSVGIconPainter::setUseStroke(bool stroke) -{ - d->helper->m_useStroke = stroke; -} - -void KSVGIconPainter::setClippingRect(int x, int y, int w, int h) -{ - ArtVpath *vec = d->helper->allocVPath(6); - - vec[0].code = ART_MOVETO; - vec[0].x = x; - vec[0].y = y; - - vec[1].code = ART_LINETO; - vec[1].x = x; - vec[1].y = y + h; - - vec[2].code = ART_LINETO; - vec[2].x = x + w; - vec[2].y = y + h; - - vec[3].code = ART_LINETO; - vec[3].x = x + w; - vec[3].y = y; - - vec[4].code = ART_LINETO; - vec[4].x = x; - vec[4].y = y; - - vec[5].code = ART_END; - - if(d->helper->m_clipSVP) - art_svp_free(d->helper->m_clipSVP); - - d->helper->m_clipSVP = art_svp_from_vpath(vec); - - art_free(vec); -} - -void KSVGIconPainter::drawRectangle(double x, double y, double w, double h, double rx, double ry) -{ - if((int) rx != 0 && (int) ry != 0) - { - ArtVpath *res; - ArtBpath *vec = d->helper->allocBPath(10); - - int i = 0; - - if(rx > w / 2) - rx = w / 2; - - if(ry > h / 2) - ry = h / 2; - - vec[i].code = ART_MOVETO_OPEN; - vec[i].x3 = x + rx; - vec[i].y3 = y; - - i++; - - vec[i].code = ART_CURVETO; - vec[i].x1 = x + rx * (1 - 0.552); - vec[i].y1 = y; - vec[i].x2 = x; - vec[i].y2 = y + ry * (1 - 0.552); - vec[i].x3 = x; - vec[i].y3 = y + ry; - - i++; - - if(ry < h / 2) - { - vec[i].code = ART_LINETO; - vec[i].x3 = x; - vec[i].y3 = y + h - ry; - - i++; - } - - vec[i].code = ART_CURVETO; - vec[i].x1 = x; - vec[i].y1 = y + h - ry * (1 - 0.552); - vec[i].x2 = x + rx * (1 - 0.552); - vec[i].y2 = y + h; - vec[i].x3 = x + rx; - vec[i].y3 = y + h; - - i++; - - if(rx < w / 2) - { - vec[i].code = ART_LINETO; - vec[i].x3 = x + w - rx; - vec[i].y3 = y + h; - - i++; - } - - vec[i].code = ART_CURVETO; - vec[i].x1 = x + w - rx * (1 - 0.552); - vec[i].y1 = y + h; - vec[i].x2 = x + w; - vec[i].y2 = y + h - ry * (1 - 0.552); - vec[i].x3 = x + w; - - vec[i].y3 = y + h - ry; - - i++; - - if(ry < h / 2) - { - vec[i].code = ART_LINETO; - vec[i].x3 = x + w; - vec[i].y3 = y + ry; - - i++; - } - - vec[i].code = ART_CURVETO; - vec[i].x1 = x + w; - vec[i].y1 = y + ry * (1 - 0.552); - vec[i].x2 = x + w - rx * (1 - 0.552); - vec[i].y2 = y; - vec[i].x3 = x + w - rx; - vec[i].y3 = y; - - i++; - - if(rx < w / 2) - { - vec[i].code = ART_LINETO; - vec[i].x3 = x + rx; - vec[i].y3 = y; - - i++; - } - - vec[i].code = ART_END; - - res = d->helper->art_bez_path_to_vec(vec, 0.25); - art_free(vec); - d->helper->drawVPath(res); - } - else - { - ArtVpath *vec = d->helper->allocVPath(6); - - vec[0].code = ART_MOVETO; - vec[0].x = x; - vec[0].y = y; - - vec[1].code = ART_LINETO; - vec[1].x = x; - vec[1].y = y + h; - - vec[2].code = ART_LINETO; - vec[2].x = x + w; - vec[2].y = y + h; - - vec[3].code = ART_LINETO; - vec[3].x = x + w; - vec[3].y = y; - - vec[4].code = ART_LINETO; - vec[4].x = x; - vec[4].y = y; - - vec[5].code = ART_END; - - d->helper->drawVPath(vec); - } -} - -void KSVGIconPainter::drawEllipse(double cx, double cy, double rx, double ry) -{ - ArtBpath *temp; - - temp = d->helper->allocBPath(6); - - double x1, y1, x2, y2, x3, y3; - double len = 0.55228474983079356; - double cos4[] = {1.0, 0.0, -1.0, 0.0, 1.0}; - double sin4[] = {0.0, 1.0, 0.0, -1.0, 0.0}; - int i = 0; - - temp[i].code = ART_MOVETO; - temp[i].x3 = cx + rx; - temp[i].y3 = cy; - - i++; - - while(i < 5) - { - x1 = cos4[i-1] + len * cos4[i]; - y1 = sin4[i-1] + len * sin4[i]; - x2 = cos4[i] + len * cos4[i-1]; - y2 = sin4[i] + len * sin4[i-1]; - x3 = cos4[i]; - y3 = sin4[i]; - - temp[i].code = ART_CURVETO; - temp[i].x1 = cx + x1 * rx; - temp[i].y1 = cy + y1 * ry; - temp[i].x2 = cx + x2 * rx; - temp[i].y2 = cy + y2 * ry; - temp[i].x3 = cx + x3 * rx; - temp[i].y3 = cy + y3 * ry; - - i++; - } - - temp[i].code = ART_END; - - d->helper->drawBPath(temp); - - art_free(temp); -} - -void KSVGIconPainter::drawLine(double x1, double y1, double x2, double y2) -{ - ArtVpath *vec; - - vec = d->helper->allocVPath(3); - - vec[0].code = ART_MOVETO_OPEN; - vec[0].x = x1; - vec[0].y = y1; - - vec[1].code = ART_LINETO; - vec[1].x = x2; - vec[1].y = y2; - - vec[2].code = ART_END; - - d->helper->drawVPath(vec); -} - -void KSVGIconPainter::drawPolyline(TQPointArray polyArray, int points) -{ - if(polyArray.point(0).x() == -1 || polyArray.point(0).y() == -1) - return; - - ArtVpath *polyline; - - if(points == -1) - points = polyArray.count(); - - polyline = d->helper->allocVPath(3 + points); - polyline[0].code = ART_MOVETO; - polyline[0].x = polyArray.point(0).x(); - polyline[0].y = polyArray.point(0).y(); - - int index; - for(index = 1; index < points; index++) - { - TQPoint point = polyArray.point(index); - polyline[index].code = ART_LINETO; - polyline[index].x = point.x(); - polyline[index].y = point.y(); - } - - if(d->helper->m_useFill) // if the polyline must be filled, inform libart that it should not be closed. - { - polyline[index].code = (ArtPathcode)ART_END2; - polyline[index].x = polyArray.point(0).x(); - polyline[index++].y = polyArray.point(0).y(); - } - - polyline[index].code = ART_END; - - d->helper->drawVPath(polyline); -} - -void KSVGIconPainter::drawPolygon(TQPointArray polyArray) -{ - ArtVpath *polygon; - - polygon = d->helper->allocVPath(3 + polyArray.count()); - polygon[0].code = ART_MOVETO; - polygon[0].x = polyArray.point(0).x(); - polygon[0].y = polyArray.point(0).y(); - - unsigned int index; - for(index = 1; index < polyArray.count(); index++) - { - TQPoint point = polyArray.point(index); - polygon[index].code = ART_LINETO; - polygon[index].x = point.x(); - polygon[index].y = point.y(); - } - - polygon[index].code = ART_LINETO; - polygon[index].x = polyArray.point(0).x(); - polygon[index].y = polyArray.point(0).y(); - - index++; - polygon[index].code = ART_END; - - d->helper->drawVPath(polygon); -} - -// Path parsing tool -// parses the coord into number and forwards to the next token -static const char *getCoord(const char *ptr, double &number) -{ - int integer, exponent; - double decimal, frac; - int sign, expsign; - - exponent = 0; - integer = 0; - frac = 1.0; - decimal = 0; - sign = 1; - expsign = 1; - - // read the sign - if(*ptr == '+') - ptr++; - else if(*ptr == '-') - { - ptr++; - sign = -1; - } - // read the integer part - while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9') - integer = (integer * 10) + *(ptr++) - '0'; - - if(*ptr == '.') // read the decimals - { - ptr++; - while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9') - decimal += (*(ptr++) - '0') * (frac *= 0.1); - } - - if(*ptr == 'e' || *ptr == 'E') // read the exponent part - { - ptr++; - - // read the sign of the exponent - if(*ptr == '+') - ptr++; - else if(*ptr == '-') - { - ptr++; - expsign = -1; - } - - exponent = 0; - while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9') - { - exponent *= 10; - exponent += *ptr - '0'; - ptr++; - } - } - - number = integer + decimal; - number *= sign * pow(10.0, expsign * exponent); - - // skip the following space - if(*ptr == ' ') - ptr++; - - return ptr; -} - -void KSVGIconPainter::drawPath(const TQString &data, bool filled) -{ - if (!data.isEmpty()) - { - TQString value = data; - - TQMemArray<ArtBpath> vec; - int index = -1; - - double curx = 0.0, cury = 0.0, contrlx = 0.0, contrly = 0.0, xc, yc; - unsigned int lastCommand = 0; - - TQString _d = value.replace(",", " "); - _d = _d.simplifyWhiteSpace(); - const char *ptr = _d.latin1(); - const char *end = _d.latin1() + _d.length() + 1; - - double tox, toy, x1, y1, x2, y2, rx, ry, angle; - bool largeArc, sweep; - char command = *(ptr++); - - while(ptr < end) - { - if(*ptr == ' ') - ptr++; - - switch(command) - { - case 'm': - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - if(index != -1 && lastCommand != 'z') - { - // Find last subpath - int find = -1; - for(int i = index; i >= 0; i--) - { - if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO) - { - find = i; - break; - } - } - - index++; - - if(vec.size() == (unsigned int) index) - vec.resize(index + 1); - - vec[index].code = (ArtPathcode)ART_END2; - vec[index].x3 = vec[find].x3; - vec[index].y3 = vec[find].y3; - } - - curx += tox; - cury += toy; - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = (index == 0) ? ART_MOVETO : ART_MOVETO_OPEN; - vec[index].x3 = curx; - vec[index].y3 = cury; - - lastCommand = 'm'; - break; - case 'M': - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - if(index != -1 && lastCommand != 'z') - { - // Find last subpath - int find = -1; - for(int i = index; i >= 0; i--) - { - if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO) - { - find = i; - break; - } - } - - index++; - - if(vec.size() == (unsigned int) index) - vec.resize(index + 1); - - vec[index].code = (ArtPathcode)ART_END2; - vec[index].x3 = vec[find].x3; - vec[index].y3 = vec[find].y3; - } - - curx = tox; - cury = toy; - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = (index == 0) ? ART_MOVETO : ART_MOVETO_OPEN; - vec[index].x3 = curx; - vec[index].y3 = cury; - - lastCommand = 'M'; - break; - case 'l': - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = curx + tox; - vec[index].y3 = cury + toy; - - curx += tox; - cury += toy; - - lastCommand = 'l'; - break; - case 'L': - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = tox; - vec[index].y3 = toy; - - curx = tox; - cury = toy; - - lastCommand = 'L'; - break; - case 'h': - ptr = getCoord(ptr, tox); - - index++; - - curx += tox; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = curx; - vec[index].y3 = cury; - - lastCommand = 'h'; - break; - case 'H': - ptr = getCoord(ptr, tox); - - index++; - - curx = tox; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = curx; - vec[index].y3 = cury; - - lastCommand = 'H'; - break; - case 'v': - ptr = getCoord(ptr, toy); - - index++; - - cury += toy; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = curx; - vec[index].y3 = cury; - - lastCommand = 'v'; - break; - case 'V': - ptr = getCoord(ptr, toy); - - index++; - - cury = toy; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = curx; - vec[index].y3 = cury; - - lastCommand = 'V'; - break; - case 'c': - ptr = getCoord(ptr, x1); - ptr = getCoord(ptr, y1); - ptr = getCoord(ptr, x2); - ptr = getCoord(ptr, y2); - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = curx + x1; - vec[index].y1 = cury + y1; - vec[index].x2 = curx + x2; - vec[index].y2 = cury + y2; - vec[index].x3 = curx + tox; - vec[index].y3 = cury + toy; - - curx += tox; - cury += toy; - - contrlx = vec[index].x2; - contrly = vec[index].y2; - - lastCommand = 'c'; - break; - case 'C': - ptr = getCoord(ptr, x1); - ptr = getCoord(ptr, y1); - ptr = getCoord(ptr, x2); - ptr = getCoord(ptr, y2); - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = x1; - vec[index].y1 = y1; - vec[index].x2 = x2; - vec[index].y2 = y2; - vec[index].x3 = tox; - vec[index].y3 = toy; - - curx = vec[index].x3; - cury = vec[index].y3; - contrlx = vec[index].x2; - contrly = vec[index].y2; - - lastCommand = 'C'; - break; - case 's': - ptr = getCoord(ptr, x2); - ptr = getCoord(ptr, y2); - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = 2 * curx - contrlx; - vec[index].y1 = 2 * cury - contrly; - vec[index].x2 = curx + x2; - vec[index].y2 = cury + y2; - vec[index].x3 = curx + tox; - vec[index].y3 = cury + toy; - - curx += tox; - cury += toy; - - contrlx = vec[index].x2; - contrly = vec[index].y2; - - lastCommand = 's'; - break; - case 'S': - ptr = getCoord(ptr, x2); - ptr = getCoord(ptr, y2); - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = 2 * curx - contrlx; - vec[index].y1 = 2 * cury - contrly; - vec[index].x2 = x2; - vec[index].y2 = y2; - vec[index].x3 = tox; - vec[index].y3 = toy; - - curx = vec[index].x3; - cury = vec[index].y3; - contrlx = vec[index].x2; - contrly = vec[index].y2; - - lastCommand = 'S'; - break; - case 'q': - ptr = getCoord(ptr, x1); - ptr = getCoord(ptr, y1); - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = (curx + 2 * (x1 + curx)) * (1.0 / 3.0); - vec[index].y1 = (cury + 2 * (y1 + cury)) * (1.0 / 3.0); - vec[index].x2 = ((curx + tox) + 2 * (x1 + curx)) * (1.0 / 3.0); - vec[index].y2 = ((cury + toy) + 2 * (y1 + cury)) * (1.0 / 3.0); - vec[index].x3 = curx + tox; - vec[index].y3 = cury + toy; - - contrlx = curx + x1; - contrly = cury + y1; - curx += tox; - cury += toy; - - lastCommand = 'q'; - break; - case 'Q': - ptr = getCoord(ptr, x1); - ptr = getCoord(ptr, y1); - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - index++; - - d->helper->ensureSpace(vec, index); - - // TODO : if this fails make it more like QuadraticRel - vec[index].code = ART_CURVETO; - vec[index].x1 = (curx + 2 * x1) * (1.0 / 3.0); - vec[index].y1 = (cury + 2 * y1) * (1.0 / 3.0); - vec[index].x2 = (tox + 2 * x1) * (1.0 / 3.0); - vec[index].y2 = (toy + 2 * y1) * (1.0 / 3.0); - vec[index].x3 = tox; - vec[index].y3 = toy; - - curx = vec[index].x3; - cury = vec[index].y3; - contrlx = vec[index].x2; - contrly = vec[index].y2; - - lastCommand = 'Q'; - break; - case 't': - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - xc = 2 * curx - contrlx; - yc = 2 * cury - contrly; - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = (curx + 2 * xc) * (1.0 / 3.0); - vec[index].y1 = (cury + 2 * yc) * (1.0 / 3.0); - vec[index].x2 = ((curx + tox) + 2 * xc) * (1.0 / 3.0); - vec[index].y2 = ((cury + toy) + 2 * yc) * (1.0 / 3.0); - - vec[index].x3 = curx + tox; - vec[index].y3 = cury + toy; - - curx += tox; - cury += toy; - contrlx = xc; - contrly = yc; - - lastCommand = 't'; - break; - case 'T': - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - xc = 2 * curx - contrlx; - yc = 2 * cury - contrly; - - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_CURVETO; - vec[index].x1 = (curx + 2 * xc) * (1.0 / 3.0); - vec[index].y1 = (cury + 2 * yc) * (1.0 / 3.0); - vec[index].x2 = (tox + 2 * xc) * (1.0 / 3.0); - vec[index].y2 = (toy + 2 * yc) * (1.0 / 3.0); - vec[index].x3 = tox; - vec[index].y3 = toy; - - curx = tox; - cury = toy; - contrlx = xc; - contrly = yc; - - lastCommand = 'T'; - break; - case 'z': - case 'Z': - int find; - find = -1; - for(int i = index; i >= 0; i--) - { - if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO) - { - find = i; - break; - } - } - - if(find != -1) - { - if(vec[find].x3 != curx || vec[find].y3 != cury) - { - index++; - - d->helper->ensureSpace(vec, index); - - vec[index].code = ART_LINETO; - vec[index].x3 = vec[find].x3; - vec[index].y3 = vec[find].y3; - } - } - - // reset for next (sub)path - curx = vec[find].x3; - cury = vec[find].y3; - - lastCommand = 'z'; - break; - case 'a': - ptr = getCoord(ptr, rx); - ptr = getCoord(ptr, ry); - ptr = getCoord(ptr, angle); - ptr = getCoord(ptr, tox); - largeArc = tox == 1; - ptr = getCoord(ptr, tox); - sweep = tox == 1; - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - // Spec: radii are nonnegative numbers - rx = fabs(rx); - ry = fabs(ry); - - d->helper->calculateArc(true, vec, index, curx, cury, angle, tox, toy, rx, ry, largeArc, sweep); - - lastCommand = 'a'; - break; - case 'A': - ptr = getCoord(ptr, rx); - ptr = getCoord(ptr, ry); - ptr = getCoord(ptr, angle); - ptr = getCoord(ptr, tox); - largeArc = tox == 1; - ptr = getCoord(ptr, tox); - sweep = tox == 1; - ptr = getCoord(ptr, tox); - ptr = getCoord(ptr, toy); - - // Spec: radii are nonnegative numbers - rx = fabs(rx); - ry = fabs(ry); - - d->helper->calculateArc(false, vec, index, curx, cury, angle, tox, toy, rx, ry, largeArc, sweep); - - lastCommand = 'A'; - break; - } - - if(*ptr == '+' || *ptr == '-' || (*ptr >= '0' && *ptr <= '9')) - { - // there are still coords in this command - if(command == 'M') - command = 'L'; - else if(command == 'm') - command = 'l'; - } - else - command = *(ptr++); - - // Detect reflection points - if(lastCommand != 'C' && lastCommand != 'c' && - lastCommand != 'S' && lastCommand != 's' && - lastCommand != 'Q' && lastCommand != 'q' && - lastCommand != 'T' && lastCommand != 't') - { - contrlx = curx; - contrly = cury; - } - } - - // Find last subpath - int find = -1; - for(int i = index; i >= 0; i--) - { - if(vec[i].code == ART_MOVETO_OPEN || vec[i].code == ART_MOVETO) - { - find = i; - break; - } - } - - // Fix a problem where the .svg file used doubles as values... (sofico.svg) - if(curx != vec[find].x3 && cury != vec[find].y3) - { - if((int) curx == (int) vec[find].x3 && (int) cury == (int) vec[find].y3) - { - index++; - - if(vec.size() == (unsigned int) index) - vec.resize(index + 1); - - vec[index].code = ART_LINETO; - vec[index].x3 = vec[find].x3; - vec[index].y3 = vec[find].y3; - - curx = vec[find].x3; - cury = vec[find].y3; - } - } - - // Handle filled paths that are not closed explicitly - if(filled) - { - if((int) curx != (int) vec[find].x3 || (int) cury != (int) vec[find].y3) - { - index++; - - if(vec.size() == (unsigned int) index) - vec.resize(index + 1); - - vec[index].code = (ArtPathcode)ART_END2; - vec[index].x3 = vec[find].x3; - vec[index].y3 = vec[find].y3; - - curx = vec[find].x3; - cury = vec[find].y3; - } - } - - // Close - index++; - - if(vec.size() == (unsigned int) index) - vec.resize(index + 1); - - vec[index].code = ART_END; - - // There are pure-moveto paths which reference paint servers *bah* - // Do NOT render them - bool render = false; - for(int i = index; i >= 0; i--) - { - if(vec[i].code != ART_MOVETO_OPEN && vec[i].code != ART_MOVETO && !(vec[i].code >= ART_END)) - { - render = true; - break; - } - } - - if(render) - d->helper->drawBPath(vec.data()); - } -} - -void KSVGIconPainter::drawImage(double x, double y, TQImage &image) -{ - if(image.depth() != 32) - image = image.convertDepth(32); - - double affine[6]; - affine[0] = d->helper->m_tqworldMatrix->m11(); - affine[1] = d->helper->m_tqworldMatrix->m12(); - affine[2] = d->helper->m_tqworldMatrix->m21(); - affine[3] = d->helper->m_tqworldMatrix->m22(); - // use the world matrix to convert the coordinates - d->helper->m_tqworldMatrix->map(x, y, &affine[4], &affine[5]); - - d->helper->art_rgba_rgba_affine(d->helper->m_buffer, 0, 0, d->helper->m_width, d->helper->m_height, - d->helper->m_rowstride, image.bits(), image.width(), image.height(), - image.width() * 4, affine); -} - -TQColor KSVGIconPainter::parseColor(const TQString ¶m) -{ - if(param.stripWhiteSpace().startsWith("#")) - { - TQColor color; - color.setNamedColor(param.stripWhiteSpace()); - return color; - } - else if(param.stripWhiteSpace().startsWith("rgb(")) - { - TQString parse = param.stripWhiteSpace(); - TQStringList colors = TQStringList::split(',', parse); - TQString r = colors[0].right((colors[0].length() - 4)); - TQString g = colors[1]; - TQString b = colors[2].left((colors[2].length() - 1)); - - if(r.contains("%")) - { - r = r.left(r.length() - 1); - r = TQString::number(int((double(255 * r.toDouble()) / 100.0))); - } - - if(g.contains("%")) - { - g = g.left(g.length() - 1); - g = TQString::number(int((double(255 * g.toDouble()) / 100.0))); - } - - if(b.contains("%")) - { - b = b.left(b.length() - 1); - b = TQString::number(int((double(255 * b.toDouble()) / 100.0))); - } - - return TQColor(r.toInt(), g.toInt(), b.toInt()); - } - else - { - TQString rgbColor = param.stripWhiteSpace(); - - if(rgbColor == "aliceblue") - return TQColor(240, 248, 255); - else if(rgbColor == "antiquewhite") - return TQColor(250, 235, 215); - else if(rgbColor == "aqua") - return TQColor(0, 255, 255); - else if(rgbColor == "aquamarine") - return TQColor(127, 255, 212); - else if(rgbColor == "azure") - return TQColor(240, 255, 255); - else if(rgbColor == "beige") - return TQColor(245, 245, 220); - else if(rgbColor == "bisque") - return TQColor(255, 228, 196); - else if(rgbColor == "black") - return TQColor(0, 0, 0); - else if(rgbColor == "blanchedalmond") - return TQColor(255, 235, 205); - else if(rgbColor == "blue") - return TQColor(0, 0, 255); - else if(rgbColor == "blueviolet") - return TQColor(138, 43, 226); - else if(rgbColor == "brown") - return TQColor(165, 42, 42); - else if(rgbColor == "burlywood") - return TQColor(222, 184, 135); - else if(rgbColor == "cadetblue") - return TQColor(95, 158, 160); - else if(rgbColor == "chartreuse") - return TQColor(127, 255, 0); - else if(rgbColor == "chocolate") - return TQColor(210, 105, 30); - else if(rgbColor == "coral") - return TQColor(255, 127, 80); - else if(rgbColor == "cornflowerblue") - return TQColor(100, 149, 237); - else if(rgbColor == "cornsilk") - return TQColor(255, 248, 220); - else if(rgbColor == "crimson") - return TQColor(220, 20, 60); - else if(rgbColor == "cyan") - return TQColor(0, 255, 255); - else if(rgbColor == "darkblue") - return TQColor(0, 0, 139); - else if(rgbColor == "darkcyan") - return TQColor(0, 139, 139); - else if(rgbColor == "darkgoldenrod") - return TQColor(184, 134, 11); - else if(rgbColor == "darkgray") - return TQColor(169, 169, 169); - else if(rgbColor == "darkgrey") - return TQColor(169, 169, 169); - else if(rgbColor == "darkgreen") - return TQColor(0, 100, 0); - else if(rgbColor == "darkkhaki") - return TQColor(189, 183, 107); - else if(rgbColor == "darkmagenta") - return TQColor(139, 0, 139); - else if(rgbColor == "darkolivegreen") - return TQColor(85, 107, 47); - else if(rgbColor == "darkorange") - return TQColor(255, 140, 0); - else if(rgbColor == "darkorchid") - return TQColor(153, 50, 204); - else if(rgbColor == "darkred") - return TQColor(139, 0, 0); - else if(rgbColor == "darksalmon") - return TQColor(233, 150, 122); - else if(rgbColor == "darkseagreen") - return TQColor(143, 188, 143); - else if(rgbColor == "darkslateblue") - return TQColor(72, 61, 139); - else if(rgbColor == "darkslategray") - return TQColor(47, 79, 79); - else if(rgbColor == "darkslategrey") - return TQColor(47, 79, 79); - else if(rgbColor == "darkturquoise") - return TQColor(0, 206, 209); - else if(rgbColor == "darkviolet") - return TQColor(148, 0, 211); - else if(rgbColor == "deeppink") - return TQColor(255, 20, 147); - else if(rgbColor == "deepskyblue") - return TQColor(0, 191, 255); - else if(rgbColor == "dimgray") - return TQColor(105, 105, 105); - else if(rgbColor == "dimgrey") - return TQColor(105, 105, 105); - else if(rgbColor == "dodgerblue") - return TQColor(30, 144, 255); - else if(rgbColor == "firebrick") - return TQColor(178, 34, 34); - else if(rgbColor == "floralwhite") - return TQColor(255, 250, 240); - else if(rgbColor == "forestgreen") - return TQColor(34, 139, 34); - else if(rgbColor == "fuchsia") - return TQColor(255, 0, 255); - else if(rgbColor == "gainsboro") - return TQColor(220, 220, 220); - else if(rgbColor == "ghostwhite") - return TQColor(248, 248, 255); - else if(rgbColor == "gold") - return TQColor(255, 215, 0); - else if(rgbColor == "goldenrod") - return TQColor(218, 165, 32); - else if(rgbColor == "gray") - return TQColor(128, 128, 128); - else if(rgbColor == "grey") - return TQColor(128, 128, 128); - else if(rgbColor == "green") - return TQColor(0, 128, 0); - else if(rgbColor == "greenyellow") - return TQColor(173, 255, 47); - else if(rgbColor == "honeydew") - return TQColor(240, 255, 240); - else if(rgbColor == "hotpink") - return TQColor(255, 105, 180); - else if(rgbColor == "indianred") - return TQColor(205, 92, 92); - else if(rgbColor == "indigo") - return TQColor(75, 0, 130); - else if(rgbColor == "ivory") - return TQColor(255, 255, 240); - else if(rgbColor == "khaki") - return TQColor(240, 230, 140); - else if(rgbColor == "lavender") - return TQColor(230, 230, 250); - else if(rgbColor == "lavenderblush") - return TQColor(255, 240, 245); - else if(rgbColor == "lawngreen") - return TQColor(124, 252, 0); - else if(rgbColor == "lemonchiffon") - return TQColor(255, 250, 205); - else if(rgbColor == "lightblue") - return TQColor(173, 216, 230); - else if(rgbColor == "lightcoral") - return TQColor(240, 128, 128); - else if(rgbColor == "lightcyan") - return TQColor(224, 255, 255); - else if(rgbColor == "lightgoldenrodyellow") - return TQColor(250, 250, 210); - else if(rgbColor == "lightgray") - return TQColor(211, 211, 211); - else if(rgbColor == "lightgrey") - return TQColor(211, 211, 211); - else if(rgbColor == "lightgreen") - return TQColor(144, 238, 144); - else if(rgbColor == "lightpink") - return TQColor(255, 182, 193); - else if(rgbColor == "lightsalmon") - return TQColor(255, 160, 122); - else if(rgbColor == "lightseagreen") - return TQColor(32, 178, 170); - else if(rgbColor == "lightskyblue") - return TQColor(135, 206, 250); - else if(rgbColor == "lightslategray") - return TQColor(119, 136, 153); - else if(rgbColor == "lightslategrey") - return TQColor(119, 136, 153); - else if(rgbColor == "lightsteelblue") - return TQColor(176, 196, 222); - else if(rgbColor == "lightyellow") - return TQColor(255, 255, 224); - else if(rgbColor == "lime") - return TQColor(0, 255, 0); - else if(rgbColor == "limegreen") - return TQColor(50, 205, 50); - else if(rgbColor == "linen") - return TQColor(250, 240, 230); - else if(rgbColor == "magenta") - return TQColor(255, 0, 255); - else if(rgbColor == "maroon") - return TQColor(128, 0, 0); - else if(rgbColor == "mediumaquamarine") - return TQColor(102, 205, 170); - else if(rgbColor == "mediumblue") - return TQColor(0, 0, 205); - else if(rgbColor == "mediumorchid") - return TQColor(186, 85, 211); - else if(rgbColor == "mediumpurple") - return TQColor(147, 112, 219); - else if(rgbColor == "mediumseagreen") - return TQColor(60, 179, 113); - else if(rgbColor == "mediumslateblue") - return TQColor(123, 104, 238); - else if(rgbColor == "mediumspringgreen") - return TQColor(0, 250, 154); - else if(rgbColor == "mediumturquoise") - return TQColor(72, 209, 204); - else if(rgbColor == "mediumvioletred") - return TQColor(199, 21, 133); - else if(rgbColor == "midnightblue") - return TQColor(25, 25, 112); - else if(rgbColor == "mintcream") - return TQColor(245, 255, 250); - else if(rgbColor == "mistyrose") - return TQColor(255, 228, 225); - else if(rgbColor == "tqmoccasin") - return TQColor(255, 228, 181); - else if(rgbColor == "navajowhite") - return TQColor(255, 222, 173); - else if(rgbColor == "navy") - return TQColor(0, 0, 128); - else if(rgbColor == "oldlace") - return TQColor(253, 245, 230); - else if(rgbColor == "olive") - return TQColor(128, 128, 0); - else if(rgbColor == "olivedrab") - return TQColor(107, 142, 35); - else if(rgbColor == "orange") - return TQColor(255, 165, 0); - else if(rgbColor == "orangered") - return TQColor(255, 69, 0); - else if(rgbColor == "orchid") - return TQColor(218, 112, 214); - else if(rgbColor == "palegoldenrod") - return TQColor(238, 232, 170); - else if(rgbColor == "palegreen") - return TQColor(152, 251, 152); - else if(rgbColor == "paleturquoise") - return TQColor(175, 238, 238); - else if(rgbColor == "palevioletred") - return TQColor(219, 112, 147); - else if(rgbColor == "papayawhip") - return TQColor(255, 239, 213); - else if(rgbColor == "peachpuff") - return TQColor(255, 218, 185); - else if(rgbColor == "peru") - return TQColor(205, 133, 63); - else if(rgbColor == "pink") - return TQColor(255, 192, 203); - else if(rgbColor == "plum") - return TQColor(221, 160, 221); - else if(rgbColor == "powderblue") - return TQColor(176, 224, 230); - else if(rgbColor == "purple") - return TQColor(128, 0, 128); - else if(rgbColor == "red") - return TQColor(255, 0, 0); - else if(rgbColor == "rosybrown") - return TQColor(188, 143, 143); - else if(rgbColor == "royalblue") - return TQColor(65, 105, 225); - else if(rgbColor == "saddlebrown") - return TQColor(139, 69, 19); - else if(rgbColor == "salmon") - return TQColor(250, 128, 114); - else if(rgbColor == "sandybrown") - return TQColor(244, 164, 96); - else if(rgbColor == "seagreen") - return TQColor(46, 139, 87); - else if(rgbColor == "seashell") - return TQColor(255, 245, 238); - else if(rgbColor == "sienna") - return TQColor(160, 82, 45); - else if(rgbColor == "silver") - return TQColor(192, 192, 192); - else if(rgbColor == "skyblue") - return TQColor(135, 206, 235); - else if(rgbColor == "slateblue") - return TQColor(106, 90, 205); - else if(rgbColor == "slategray") - return TQColor(112, 128, 144); - else if(rgbColor == "slategrey") - return TQColor(112, 128, 144); - else if(rgbColor == "snow") - return TQColor(255, 250, 250); - else if(rgbColor == "springgreen") - return TQColor(0, 255, 127); - else if(rgbColor == "steelblue") - return TQColor(70, 130, 180); - else if(rgbColor == "tan") - return TQColor(210, 180, 140); - else if(rgbColor == "teal") - return TQColor(0, 128, 128); - else if(rgbColor == "thistle") - return TQColor(216, 191, 216); - else if(rgbColor == "tomato") - return TQColor(255, 99, 71); - else if(rgbColor == "turquoise") - return TQColor(64, 224, 208); - else if(rgbColor == "violet") - return TQColor(238, 130, 238); - else if(rgbColor == "wheat") - return TQColor(245, 222, 179); - else if(rgbColor == "white") - return TQColor(255, 255, 255); - else if(rgbColor == "whitesmoke") - return TQColor(245, 245, 245); - else if(rgbColor == "yellow") - return TQColor(255, 255, 0); - else if(rgbColor == "yellowgreen") - return TQColor(154, 205, 50); - } - - return TQColor(); -} - -double KSVGIconPainter::dpi() -{ - return 90.0; // TODO: make modal? -} - -double KSVGIconPainter::toPixel(const TQString &s, bool hmode) -{ - if(s.isEmpty()) - return 0.0; - - TQString check = s; - - double ret = 0.0; - - double value = 0; - const char *start = check.latin1(); - const char *end = getCoord(start, value); - - if(uint(end - start) < check.length()) - { - if(check.endsWith("px")) - ret = value; - else if(check.endsWith("cm")) - ret = (value / 2.54) * dpi(); - else if(check.endsWith("pc")) - ret = (value / 6.0) * dpi(); - else if(check.endsWith("mm")) - ret = (value / 25.4) * dpi(); - else if(check.endsWith("in")) - ret = value * dpi(); - else if(check.endsWith("pt")) - ret = (value / 72.0) * dpi(); - else if(check.endsWith("%")) - { - ret = value / 100.0; - - if(hmode) - ret *= d->drawWidth; - else - ret *= d->drawHeight; - } - else if(check.endsWith("em")) - { - ret = value * 10.0; // TODO make this depend on actual font size - } - } - else - ret = value; - - return ret; -} - -ArtGradientLinear *KSVGIconPainter::linearGradient(const TQString &id) -{ - return d->helper->m_linearGradientMap[id]; -} - -void KSVGIconPainter::addLinearGradient(const TQString &id, ArtGradientLinear *gradient) -{ - d->helper->m_linearGradientMap.insert(id, gradient); -} - -TQDomElement KSVGIconPainter::linearGradientElement(ArtGradientLinear *linear) -{ - return d->helper->m_linearGradientElementMap[linear]; -} - -void KSVGIconPainter::addLinearGradientElement(ArtGradientLinear *gradient, TQDomElement element) -{ - d->helper->m_linearGradientElementMap.insert(gradient, element); -} - -ArtGradientRadial *KSVGIconPainter::radialGradient(const TQString &id) -{ - return d->helper->m_radialGradientMap[id]; -} - -void KSVGIconPainter::addRadialGradient(const TQString &id, ArtGradientRadial *gradient) -{ - d->helper->m_radialGradientMap.insert(id, gradient); -} - -TQDomElement KSVGIconPainter::radialGradientElement(ArtGradientRadial *radial) -{ - return d->helper->m_radialGradientElementMap[radial]; -} - -void KSVGIconPainter::addRadialGradientElement(ArtGradientRadial *gradient, TQDomElement element) -{ - d->helper->m_radialGradientElementMap.insert(gradient, element); -} - -TQ_UINT32 KSVGIconPainter::toArtColor(const TQColor &color) -{ - return d->helper->toArtColor(color); -} - -TQWMatrix KSVGIconPainter::parseTransform(const TQString &transform) -{ - TQWMatrix result; - - // Split string for handling 1 transform statement at a time - TQStringList subtransforms = TQStringList::split(')', transform); - TQStringList::ConstIterator it = subtransforms.begin(); - TQStringList::ConstIterator end = subtransforms.end(); - for(; it != end; ++it) - { - TQStringList subtransform = TQStringList::split('(', (*it)); - - subtransform[0] = subtransform[0].stripWhiteSpace().lower(); - subtransform[1] = subtransform[1].simplifyWhiteSpace(); - TQRegExp reg("([-]?\\d*\\.?\\d+(?:e[-]?\\d+)?)"); - - int pos = 0; - TQStringList params; - - while(pos >= 0) - { - pos = reg.search(subtransform[1], pos); - if(pos != -1) - { - params += reg.cap(1); - pos += reg.matchedLength(); - } - } - - if(subtransform[0].startsWith(";") || subtransform[0].startsWith(",")) - subtransform[0] = subtransform[0].right(subtransform[0].length() - 1); - - if(subtransform[0] == "rotate") - { - if(params.count() == 3) - { - double x = params[1].toDouble(); - double y = params[2].toDouble(); - - result.translate(x, y); - result.rotate(params[0].toDouble()); - result.translate(-x, -y); - } - else - result.rotate(params[0].toDouble()); - } - else if(subtransform[0] == "translate") - { - if(params.count() == 2) - result.translate(params[0].toDouble(), params[1].toDouble()); - else // Spec : if only one param given, assume 2nd param to be 0 - result.translate(params[0].toDouble() , 0); - } - else if(subtransform[0] == "scale") - { - if(params.count() == 2) - result.scale(params[0].toDouble(), params[1].toDouble()); - else // Spec : if only one param given, assume uniform scaling - result.scale(params[0].toDouble(), params[0].toDouble()); - } - else if(subtransform[0] == "skewx") - result.shear(tan(params[0].toDouble() * deg2rad), 0.0F); - else if(subtransform[0] == "skewy") - result.shear(tan(params[0].toDouble() * deg2rad), 0.0F); - else if(subtransform[0] == "skewy") - result.shear(0.0F, tan(params[0].toDouble() * deg2rad)); - else if(subtransform[0] == "matrix") - { - if(params.count() >= 6) - { - result.setMatrix(params[0].toDouble(), params[1].toDouble(), params[2].toDouble(), params[3].toDouble(), params[4].toDouble(), params[5].toDouble()); - } - } - } - - return result; -} diff --git a/kdecore/svgicons/ksvgiconpainter.h b/kdecore/svgicons/ksvgiconpainter.h deleted file mode 100644 index 6b00d9d7c..000000000 --- a/kdecore/svgicons/ksvgiconpainter.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2002 Nikolas Zimmermann <wildfox@kde.org> - This file is part of the KDE project - - 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 - aint 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 KSVGIconPainter_H -#define KSVGIconPainter_H - -#include <libart_lgpl/art_render.h> -#include <libart_lgpl/art_render_gradient.h> - -class TQImage; -class TQColor; -class TQWMatrix; -class TQDomElement; -class TQPointArray; - -class KDECORE_EXPORT KSVGIconPainter -{ -public: - KSVGIconPainter(int width, int height); - ~KSVGIconPainter(); - - void setDrawWidth(int dwidth); - void setDrawHeight(int dheight); - - TQImage *image(); - - TQWMatrix *tqworldMatrix(); - - void finish(); - - void setUseFill(bool fill); - void setUseStroke(bool stroke); - - void setStrokeWidth(double width); - void setStrokeMiterLimit(const TQString &miter); - void setCapStyle(const TQString &cap); - void setJoinStyle(const TQString &join); - void setStrokeColor(const TQString &stroke); - void setFillColor(const TQString &fill); - void setFillRule(const TQString &fillRule); - void setOpacity(const TQString &opacity); - void setFillOpacity(const TQString &fillOpacity); - void setStrokeOpacity(const TQString &strokeOpacity); - void setStrokeDashOffset(const TQString &dashOffset); - void setStrokeDashArray(const TQString &dashes); - - void setWorldMatrix(TQWMatrix *tqworldMatrix); - void setClippingRect(int x, int y, int w, int h); - - void drawRectangle(double x, double y, double w, double h, double rx, double ry); - void drawEllipse(double cx, double cy, double rx, double ry); - void drawLine(double x1, double y1, double x2, double y2); - void drawPolyline(TQPointArray polyArray, int points = -1); - void drawPolygon(TQPointArray polyArray); - void drawPath(const TQString &data, bool fill); - void drawImage(double x, double y, TQImage &image); - - TQColor parseColor(const TQString ¶m); - TQ_UINT32 toArtColor(const TQColor &color); - TQ_UINT32 parseOpacity(const TQString &data); - - double toPixel(const TQString &s, bool hmode); - double dpi(); - - ArtGradientLinear *linearGradient(const TQString &id); - void addLinearGradient(const TQString &id, ArtGradientLinear *gradient); - - TQDomElement linearGradientElement(ArtGradientLinear *linear); - void addLinearGradientElement(ArtGradientLinear *gradient, TQDomElement element); - - ArtGradientRadial *radialGradient(const TQString &id); - void addRadialGradient(const TQString &id, ArtGradientRadial *gradient); - - TQDomElement radialGradientElement(ArtGradientRadial *radial); - void addRadialGradientElement(ArtGradientRadial *gradient, TQDomElement element); - - TQWMatrix parseTransform(const TQString &transform); - -private: - struct Private; - Private *d; -}; - -#endif diff --git a/kdecore/tests/KIDLTest.cpp b/kdecore/tests/KIDLTest.cpp deleted file mode 100644 index a763f85c8..000000000 --- a/kdecore/tests/KIDLTest.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "KIDLTest.h" - -#include <kapplication.h> -#include <dcopclient.h> - -KIDLTest::KIDLTest( const TQCString& id ) - : DCOPObject( id ) -{ -} - -TQString KIDLTest::hello( const TQString& name ) -{ - qDebug("Du heter %s", name.latin1() ); - qDebug("Ha det %s", name.latin1() ); - - return TQString("Jeg heter KIDLTest"); -} - -int main( int argc, char** argv ) -{ - KApplication app( argc, argv, "kidlservertest", false /* No GUI */ ); - - app.dcopClient()->attach(); - app.dcopClient()->registerAs( "kidlservertest" ); - - qDebug("Server process started..."); - - (void) new KIDLTest( "Hello" ); - - qDebug("Server listening ..."); - - return app.exec(); -} diff --git a/kdecore/tests/KIDLTest.h b/kdecore/tests/KIDLTest.h deleted file mode 100644 index 6955bb6ca..000000000 --- a/kdecore/tests/KIDLTest.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef KIDLTEST_H -#define KIDLTEST_H - -#include <dcopobject.h> - -class KIDLTest : virtual public DCOPObject -{ - K_DCOP -public: - KIDLTest( const TQCString& id ); - -k_dcop: - virtual TQString hello( const TQString& name ); -}; - -#endif diff --git a/kdecore/tests/KIDLTestClient.cpp b/kdecore/tests/KIDLTestClient.cpp deleted file mode 100644 index 21125bff5..000000000 --- a/kdecore/tests/KIDLTestClient.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include <kapplication.h> -#include <dcopclient.h> - -#include "KIDLTest_stub.h" - -int main( int argc, char** argv ) -{ - KApplication app( argc, argv, "KIDLTestClient", false /* No GUI */ ); - - kapp->dcopClient()->attach(); - // kapp->dcopClient()->registerAs( "kidlclienttest" ); - - KIDLTest_stub* t = new KIDLTest_stub( "kidlservertest", "Hello" ); - - TQString ret = t->hello("Torben"); - qDebug("Server says: %s", ret.latin1() ); -} diff --git a/kdecore/tests/Makefile.am b/kdecore/tests/Makefile.am deleted file mode 100644 index e35ae68a4..000000000 --- a/kdecore/tests/Makefile.am +++ /dev/null @@ -1,86 +0,0 @@ -# This file is part of the KDE libraries -# Copyright (C) 1996-1997 Matthias Kalle Dalheimer (kalle@kde.org) -# (C) 1997-1998 Stephan Kulow (coolo@kde.org) - -# 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. - -INCLUDES = -I$(top_srcdir)/tdecore $(all_includes) - -AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH) - -check_PROGRAMS = kconfigtestgui klocaletest kprocesstest ksimpleconfigtest \ - kstddirstest kurltest kuniqueapptest ktempfiletest krandomsequencetest \ - kdebugtest ksocktest kstringhandlertest kcmdlineargstest kapptest \ - kmemtest kidlservertest kidlclienttest dcopkonqtest kipctest \ - cplusplustest kiconloadertest kresolvertest kmdcodectest knotifytest \ - ksortablevaluelisttest krfcdatetest testqtargs kprociotest \ - kcharsetstest kcalendartest kmacroexpandertest kshelltest \ - kxerrorhandlertest startserviceby kstdacceltest kglobaltest ktimezonestest - -TESTS = kurltest kstdacceltest - -noinst_HEADERS = klocaletest.h kprocesstest.h KIDLTest.h \ - kipctest.h kprociotest.h - -METASOURCES = AUTO - -LDADD = ../libtdecore.la -kconfigtestgui_SOURCES = kconfigtestgui.cpp -kdebugtest_SOURCES = kdebugtest.cpp -klocaletest_SOURCES = klocaletest.cpp -#klocaletest2_SOURCES = klocaletest2.cpp klocale.cpp libintl.cpp kcatalogue.cpp -#kcatalogue_SOURCES = kcatalogue.cpp libintl.cpp -ksimpleconfigtest_SOURCES = ksimpleconfigtest.cpp -kurltest_SOURCES = kurltest.cpp -kstddirstest_SOURCES = kstddirstest.cpp -kprocesstest_SOURCES = kprocesstest.cpp -kuniqueapptest_SOURCES = kuniqueapptest.cpp -kapptest_SOURCES = kapptest.cpp -ksocktest_SOURCES = ksocktest.cpp -ktempfiletest_SOURCES = ktempfiletest.cpp -krandomsequencetest_SOURCES = krandomsequencetest.cpp -kstringhandlertest_SOURCES = kstringhandlertest.cpp -kcmdlineargstest_SOURCES = kcmdlineargstest.cpp -dcopkonqtest_SOURCES = dcopkonqtest.cpp -kmemtest_SOURCES = kmemtest.cpp -kidlservertest_SOURCES = KIDLTest.cpp KIDLTest.skel -kidlclienttest_SOURCES = KIDLTestClient.cpp KIDLTest.stub -$(srcdir)/KIDLTestClient.cpp: KIDLTest_stub.h -kipctest_SOURCES = kipctest.cpp -cplusplustest_SOURCES = cplusplustest.cpp -kiconloadertest_SOURCES = kiconloadertest.cpp -kresolvertest_SOURCES = kresolvertest.cpp -kmdcodectest_SOURCES = kmdcodectest.cpp -knotifytest_SOURCES = knotifytest.cpp -ksortablevaluelisttest_SOURCES = ksortablevaluelisttest.cpp -krfcdatetest_SOURCES = krfcdatetest.cpp -testqtargs_SOURCES = testqtargs.cpp -kprociotest_SOURCES = kprociotest.cpp -kcharsetstest_SOURCES = kcharsetstest.cpp -kcalendartest_SOURCES = kcalendartest.cpp -kmacroexpandertest_SOURCES = kmacroexpandertest.cpp -kshelltest_SOURCES = kshelltest.cpp -kxerrorhandlertest_SOURCES = kxerrorhandlertest.cpp -startserviceby_SOURCES = startserviceby.cpp -kstdacceltest_SOURCES = kstdacceltest.cpp -kglobaltest_SOURCES = kglobaltest.cpp -ktimezonestest_SOURCES = ktimezonestest.cpp - -check_LTLIBRARIES = kunittest_kconfig.la - -kunittest_kconfig_la_SOURCES = kconfigtest.cpp -kunittest_kconfig_la_LIBADD = $(LIB_KUNITTEST) -kunittest_kconfig_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) diff --git a/kdecore/tests/cplusplustest.cpp b/kdecore/tests/cplusplustest.cpp deleted file mode 100644 index 1f789fea7..000000000 --- a/kdecore/tests/cplusplustest.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 <tqstring.h> -#include <tqdict.h> - -class A { int foo; }; -class B { int bar; }; -class C : public A, public B { int foobar; }; - -TQDict<A> dictA; -TQDict<B> dictB; - -int main(int , char *[]) -{ - C obj; - A *pA = &obj; - B *pB = &obj; - C *pC = &obj; -qWarning("pA = %p, pB = %p, pC = %p", pA, pB, pC); - if (pA == pC) qWarning("pA == pC"); - if (pB == pC) qWarning("pB == pC"); - - dictA.insert("hello", pC); - dictB.insert("hello", pC); - - if (dictA["hello"] == pC) qWarning("dictA['hello'] == pC"); - if (dictB["hello"] == pC) qWarning("dictB['hello'] == pC"); -} diff --git a/kdecore/tests/dcopkonqtest.cpp b/kdecore/tests/dcopkonqtest.cpp deleted file mode 100644 index 8830d34c7..000000000 --- a/kdecore/tests/dcopkonqtest.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include <kapplication.h> -#include <kdebug.h> -#include <dcopclient.h> - -int main( int argc, char** argv ) -{ - KApplication app( argc, argv, "KIDLTestClient", false ); - - kapp->dcopClient()->attach(); - // kapp->dcopClient()->registerAs( "kidlclienttest" ); - - TQByteArray data; - - kdDebug() << "sending reparseConfiguration to object KonquerorIface in konqueror" << endl; - TQByteArray snd; - TQByteArray rcv; - TQCString _type_; - kapp->dcopClient()->call( "konqueror", "KonquerorIface", "reparseConfiguration()", snd, _type_, rcv ); - kdDebug() << _type_ << endl; - if( _type_ != "void" ) kdDebug() << "void expected, " << _type_.data() << " returned" << endl; - -/* -debug("sending configure to object KonquerorIface in konqueror"); - if (kapp->dcopClient()->send( "konqueror", "KonquerorIface", "configure()", data )) - debug("ok"); - else - debug("ko"); - -/// BROADCAST -debug("sending databaseChanged to object ksycoca in all apps"); - if (kapp->dcopClient()->send( "*", "ksycoca", "databaseChanged()", data )) - debug("ok"); - else - debug("ko"); -*/ -} diff --git a/kdecore/tests/kapptest.cpp b/kdecore/tests/kapptest.cpp deleted file mode 100644 index 4a6465099..000000000 --- a/kdecore/tests/kapptest.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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. -*/ - -#define private public -#include "kapplication.h" -#include <stdio.h> - -#include <kcmdlineargs.h> -#include <kaboutdata.h> -#include <kglobalsettings.h> -#include <ksycoca.h> - -int -main(int argc, char *argv[]) -{ - KAboutData about("kapptest", "kapptest", "version"); - KCmdLineArgs::init(argc, argv, &about); - - KApplication a; - - KSycoca *s = KSycoca::self(); - - qWarning("s->language() %s", s->language().latin1()); - qWarning("Offset of aIconName: %ld", (long) &(static_cast<KApplication *>(0)->aIconName)); -} diff --git a/kdecore/tests/kcalendartest.cpp b/kdecore/tests/kcalendartest.cpp deleted file mode 100644 index 8b6e8eea4..000000000 --- a/kdecore/tests/kcalendartest.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Simplest example using two kde calendar systems (gregorian and hijri) -// Carlos Moro <cfmoro@correo.uniovi.es> -// GNU-GPL v.2 - -#include "kcalendarsystemfactory.h" -#include "kcalendarsystem.h" - -#include <tqstringlist.h> - -#include <kapplication.h> -#include <kaboutdata.h> -#include <kdebug.h> -#include <kglobal.h> -#include <klocale.h> -#include <kcmdlineargs.h> - -class KLocale; - -void test(TQDate & date); - -static const char description[] = "KCalendarTest"; - -static KCmdLineOptions options[] = -{ - { "help", I18N_NOOP("Prints this help"), 0 }, - { "type hijri|gregorian|jalali|hebrew", I18N_NOOP("Supported calendar types"), 0 }, - { "date <date>", I18N_NOOP("Show day info"), 0 }, -}; - -int main(int argc, char **argv) { - - TQDate date; - TQString calType, option; - - KAboutData aboutData( "kcalendartest", "KCalendarTest" , - "0.1", description, KAboutData::License_GPL, - "(c) 2002, Carlos Moro", 0, 0, - "cfmoro@correo.uniovi.es"); - aboutData.addAuthor("Carlos Moro",0, "cfmoro@correo.uniovi.es"); - - - KCmdLineArgs::init( argc, argv, &aboutData ); - KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. - - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - KApplication app(false, false); - - TQStringList lst = KCalendarSystemFactory::calendarSystems(); - kdDebug() << "Supported calendar types: " << endl; - for (TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it) - kdDebug() << *it << endl; - kdDebug() << endl; - - - if ( args->isSet("type") ) - calType = args->getOption("type"); - - - KGlobal::locale()->setCalendar(calType); - - /* - * If we like to see some date - * - */ - if ( args->isSet("date") ) { - option = args->getOption("date"); - date = KGlobal::locale()->readDate(option); - } else - date = TQDate::tqcurrentDate(); - - args->clear(); // Free up some memory. - - test(date); - - return 0; - - - -} - -void test(TQDate & date) { - - kdDebug() << "(KLocale) readDate" << endl; - - kdDebug() << "Created calendar: " << KGlobal::locale()->calendar()->calendarName() << endl; - - kdDebug() << "Day name for first day of week is " << KGlobal::locale()->calendar()->weekDayName(1) << endl; - kdDebug() << "Short month name for second month is " << KGlobal::locale()->calendar()->weekDayName(1, true) << endl; - - kdDebug() << "Month name for second month is " << KGlobal::locale()->calendar()->monthName(2, KGlobal::locale()->calendar()->year(date)) << endl; - kdDebug() << "Short month name for second month is " << KGlobal::locale()->calendar()->monthName(2, KGlobal::locale()->calendar()->year(date), true) << endl; - kdDebug() << "Month name possessive for second month is " << KGlobal::locale()->calendar()->monthNamePossessive(2, KGlobal::locale()->calendar()->year(date)) << endl; - kdDebug() << "Short month name possessive for second month is " << KGlobal::locale()->calendar()->monthNamePossessive(2, KGlobal::locale()->calendar()->year(date), true) << endl; - kdDebug() << "Month name for fifth month is " << KGlobal::locale()->calendar()->monthName(5, KGlobal::locale()->calendar()->year(date)) << endl; - kdDebug() << "Short month name for fifth month is " << KGlobal::locale()->calendar()->monthName(5, KGlobal::locale()->calendar()->year(date), true) << endl; - kdDebug() << "Month name possessive for fifth month is " << KGlobal::locale()->calendar()->monthNamePossessive(5, KGlobal::locale()->calendar()->year(date)) << endl; - kdDebug() << "Short month name possessive for fifth month is " << KGlobal::locale()->calendar()->monthNamePossessive(5, KGlobal::locale()->calendar()->year(date), true) << endl; - - kdDebug() << "Day for date " << date.toString() << " is " << KGlobal::locale()->calendar()->day(date) << endl; - kdDebug() << "Month for date " << date.toString() << " is " << KGlobal::locale()->calendar()->month(date) << endl; - kdDebug() << "Year for date " << date.toString() << " is " << KGlobal::locale()->calendar()->year(date) << endl; - - kdDebug() << "Day for date " << date.toString() << " as a string is " << KGlobal::locale()->calendar()->dayString(date, true) << endl; - kdDebug() << "Month for date " << date.toString() << " as a string is " << KGlobal::locale()->calendar()->monthString(date, true) << endl; - kdDebug() << "Year for date " << date.toString() << " as a string is " << KGlobal::locale()->calendar()->yearString(date, true) << endl; - - kdDebug() << "Day of week for date " << date.toString() << " is number " << KGlobal::locale()->calendar()->dayOfWeek(date) << endl; - kdDebug() << "Week name for date " << date.toString() << " is " << KGlobal::locale()->calendar()->weekDayName(date) << endl; - kdDebug() << "Short week name for date " << date.toString() << " is " << KGlobal::locale()->calendar()->weekDayName(date, true) << endl; - - kdDebug() << "Month name for date " << date.toString() << " is " << KGlobal::locale()->calendar()->monthName(date) << endl; - kdDebug() << "Short month name for date " << date.toString() << " is " << KGlobal::locale()->calendar()->monthName(date, true) << endl; - kdDebug() << "Month name possessive for date " << date.toString() << " is " << KGlobal::locale()->calendar()->monthNamePossessive(date) << endl; - kdDebug() << "Short month name possessive for date " << date.toString() << " is " << KGlobal::locale()->calendar()->monthNamePossessive(date, true) << endl; - - kdDebug() << "It's week number " << KGlobal::locale()->calendar()->weekNumber(date) << endl; - - - kdDebug() << "(KLocale) Formatted date: " << KGlobal::locale()->formatDate(date) << endl; - kdDebug() << "(KLocale) Short formatted date: " << KGlobal::locale()->formatDate(date, true) << endl; - - kdDebug() << "That month have : " << KGlobal::locale()->calendar()->daysInMonth(date) << " days" << endl; - - kdDebug() << "That year has " << KGlobal::locale()->calendar()->monthsInYear(date) << " months" << endl; - kdDebug() << "There are " << KGlobal::locale()->calendar()->weeksInYear(KGlobal::locale()->calendar()->year(date)) << " weeks that year" << endl; - kdDebug() << "There are " << KGlobal::locale()->calendar()->daysInYear(date) << " days that year" << endl; - - kdDebug() << "The day of pray is number " << KGlobal::locale()->calendar()->weekDayOfPray() << endl; - - kdDebug() << "Max valid year supported is " << KGlobal::locale()->calendar()->maxValidYear() << endl; - kdDebug() << "Min valid year supported is " << KGlobal::locale()->calendar()->minValidYear() << endl; - - kdDebug() << "It's the day number " << KGlobal::locale()->calendar()->dayOfYear(date) << " of year" << endl; - - kdDebug() << "Add 3 days" << endl; - date = KGlobal::locale()->calendar()->addDays(date, 3); - kdDebug() << "It's " << KGlobal::locale()->formatDate(date) << endl; - - kdDebug() << "Then add 3 months" << endl; - date = KGlobal::locale()->calendar()->addMonths(date, 3); - kdDebug() << "It's " << KGlobal::locale()->formatDate(date) << endl; - - kdDebug() << "And last, add -3 years" << endl; - date = KGlobal::locale()->calendar()->addYears(date, -3); - kdDebug() << "It's " << KGlobal::locale()->formatDate(date) << endl; - - kdDebug() << "Is lunar based: " << KGlobal::locale()->calendar()->isLunar() << endl; - kdDebug() << "Is lunisolar based: " << KGlobal::locale()->calendar()->isLunisolar() << endl; - kdDebug() << "Is solar based: " << KGlobal::locale()->calendar()->isSolar() << endl; - -} diff --git a/kdecore/tests/kcharsetstest.cpp b/kdecore/tests/kcharsetstest.cpp deleted file mode 100644 index 09b9486c0..000000000 --- a/kdecore/tests/kcharsetstest.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -#include <kcharsets.h> - -#include <assert.h> - -int main() -{ - TQString input( "<Hello &World>" ); - TQString output = KCharsets::resolveEntities( input ); - assert( output == "<Hello &World>" ); - return 0; -} diff --git a/kdecore/tests/kcmdlineargstest.cpp b/kdecore/tests/kcmdlineargstest.cpp deleted file mode 100644 index 0ad9807c9..000000000 --- a/kdecore/tests/kcmdlineargstest.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include <kcmdlineargs.h> -#include <klocale.h> -#include <kapplication.h> - -#include <stdio.h> - -// we use our own macro to not bother translators -// but still demonstrate the use. You would use I18N_NOOP -#define I18N_NOP(x) x - -static const char version[] = "v0.0.2 1999 (c) Waldo Bastian"; -static const char description[] = I18N_NOP("This is a test program."); - -static KCmdLineOptions options[] = -{ - { "test", I18N_NOP("do a short test only, note that\n" - "this is rather long comment"), 0 }, - { "baud <baudrate>", I18N_NOP("set baudrate"), "9600" }, - { "+file(s)", I18N_NOP("Files to load"), 0 }, - KCmdLineLastOption -}; - -#if 1 -int -main(int argc, char *argv[]) -{ - KLocale::setMainCatalogue("kdelibs"); - KCmdLineArgs::init( argc, argv, "testapp", description, version); - - KCmdLineArgs::addCmdLineOptions( options ); // Add my own options. - - // MyWidget::addCmdLineOptions(); - - KApplication k( false, false /*true, true*/ ); - - // Get application specific arguments - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - // Check if an option is set - if (args->isSet("test")) - { - // Do stuff - printf("Option 'test' is set.\n"); - } - - if (args->isSet("baud")) - { - // Do stuff - printf("Option 'baud' is set.\n"); - } - - // Read the value of an option. - TQCString baudrate = args->getOption("baud"); // 9600 is the default value. - - printf("Baudrate = %s\n", baudrate.data()); - - printf("Full list of baudrates:\n"); - QCStringList result = args->getOptionList("baud"); - for(QCStringList::ConstIterator it=result.begin(); - it != result.end(); - ++it) - { - printf("Baudrate = %s\n", (*it).data()); - } - printf("End of list\n"); - - for(int i = 0; i < args->count(); i++) - { - printf("%d: %s\n", i, args->arg(i)); - printf("%d: %s\n", i, args->url(i).url().ascii()); - } - - args->clear(); // Free up memory. - - -// k.exec(); - return 0; -} -#else -int -main(int argc, char *argv[]) -{ - KCmdLineArgs::init( argc, argv, "testapp", description, version); - - KApplication k( true, true ); - - k.exec(); - return 0; -} -#endif - - diff --git a/kdecore/tests/kconfigtest.cpp b/kdecore/tests/kconfigtest.cpp deleted file mode 100644 index 1842b5036..000000000 --- a/kdecore/tests/kconfigtest.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - 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. -*/ - -#include <kunittest/tester.h> -#include <kunittest/module.h> - -#include <kconfig.h> - -class KConfigTest : public KUnitTest::Tester -{ -public: - void allTests(); -private: - void writeConfigFile(); - void revertEntries(); -}; - -KUNITTEST_MODULE( kunittest_kconfig, "KConfigTest" ) -KUNITTEST_MODULE_REGISTER_TESTER( KConfigTest ) - -// test data -#define BOOLENTRY1 true -#define BOOLENTRY2 false -#define STRINGENTRY1 "hello" -#define STRINGENTRY2 " hello" -#define STRINGENTRY3 "hello " -#define STRINGENTRY4 " hello " -#define STRINGENTRY5 " " -#define STRINGENTRY6 "" -#define LOCAL8BITENTRY "Hello äöü" -#define POINTENTRY TQPoint( 4351, 1235 ) -#define SIZEENTRY TQSize( 10, 20 ) -#define RECTENTRY TQRect( 10, 23, 5321, 13 ) -#define DATETIMEENTRY TQDateTime( TQDate( 2002, 06, 23 ), TQTime( 12, 55, 40 ) ) -#define STRINGLISTENTRY TQStringList( "Hello," ) - -void KConfigTest::writeConfigFile() -{ - KConfig sc( "kconfigtest" ); - - sc.setGroup("AAA"); - sc.writeEntry("stringEntry1", STRINGENTRY1, true, true); - sc.deleteEntry("stringEntry2", false, true); - - sc.setGroup("Hello"); - sc.writeEntry( "boolEntry1", BOOLENTRY1 ); - sc.writeEntry( "boolEntry2", BOOLENTRY2 ); - - sc.writeEntry( "Test", TQString::fromLocal8Bit( LOCAL8BITENTRY ) ); - sc.writeEntry( "Test2", ""); - sc.writeEntry( "stringEntry1", STRINGENTRY1 ); - sc.writeEntry( "stringEntry2", STRINGENTRY2 ); - sc.writeEntry( "stringEntry3", STRINGENTRY3 ); - sc.writeEntry( "stringEntry4", STRINGENTRY4 ); - sc.writeEntry( "stringEntry5", STRINGENTRY5 ); -// sc.writeEntry( "stringEntry6", STRINGENTRY6 ); - sc.writeEntry( "keywith=equalsign", STRINGENTRY1 ); - sc.deleteEntry( "stringEntry5" ); - sc.deleteEntry( "stringEntry6" ); - - sc.deleteGroup("deleteMe", true); - - sc.setGroup("Bye"); - sc.writeEntry( "rectEntry", RECTENTRY ); - sc.writeEntry( "pointEntry", POINTENTRY ); - sc.writeEntry( "sizeEntry", SIZEENTRY ); - sc.writeEntry( "dateTimeEntry", DATETIMEENTRY ); - sc.writeEntry( "stringListEntry", STRINGLISTENTRY ); - sc.sync(); -} - -// ### TODO: call this, and test the state of things afterwards -void KConfigTest::revertEntries() -{ - qWarning("Reverting entries"); - KConfig sc( "kconfigtest" ); - - sc.setGroup("Hello"); - sc.revertToDefault( "boolEntry1"); - sc.revertToDefault( "boolEntry2"); - - sc.revertToDefault( "Test" ); - sc.revertToDefault( "Test2" ); - sc.revertToDefault( "stringEntry1" ); - sc.revertToDefault( "stringEntry2" ); - sc.revertToDefault( "stringEntry3" ); - sc.revertToDefault( "stringEntry4" ); - sc.revertToDefault( "stringEntry5" ); - sc.sync(); -} - -void KConfigTest::allTests() -{ - writeConfigFile(); - - KConfig sc2( "kconfigtest" ); - - KConfigGroup sc3( &sc2, "AAA"); - bool bImmutable = sc3.entryIsImmutable("stringEntry1"); - - CHECK( bImmutable, false ); - //qWarning("sc3.entryIsImmutable() 1: %s", bImmutable ? "true" : "false"); - - sc2.setGroup("AAA"); - CHECK( sc2.hasKey( "stringEntry1" ), true ); - CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) ); - CHECK( sc2.entryIsImmutable("stringEntry1"), bImmutable ); - CHECK( sc2.hasKey( "stringEntry2" ), false ); - CHECK( sc2.readEntry( "stringEntry2", "bla" ), TQString( "bla" ) ); - - CHECK( sc2.hasDefault( "stringEntry1" ), false ); - - sc2.setGroup("Hello"); - CHECK( sc2.readEntry( "Test" ), TQString::fromLocal8Bit( LOCAL8BITENTRY ) ); - CHECK( sc2.readEntry("Test2", "Fietsbel").isEmpty(), true ); - CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) ); - CHECK( sc2.readEntry( "stringEntry2" ), TQString( STRINGENTRY2 ) ); - CHECK( sc2.readEntry( "stringEntry3" ), TQString( STRINGENTRY3 ) ); - CHECK( sc2.readEntry( "stringEntry4" ), TQString( STRINGENTRY4 ) ); - CHECK( sc2.hasKey( "stringEntry5" ), false); - CHECK( sc2.readEntry( "stringEntry5", "test" ), TQString( "test" ) ); - CHECK( sc2.hasKey( "stringEntry6" ), false); - CHECK( sc2.readEntry( "stringEntry6", "foo" ), TQString( "foo" ) ); - CHECK( sc2.readBoolEntry( "boolEntry1" ), BOOLENTRY1 ); - CHECK( sc2.readBoolEntry( "boolEntry2" ), BOOLENTRY2 ); - -#if 0 - TQString s; - s = sc2.readEntry( "keywith=equalsign" ); - fprintf(stderr, "comparing keywith=equalsign %s with %s -> ", STRINGENTRY1, s.latin1()); - if (s == STRINGENTRY1) - fprintf(stderr, "OK\n"); - else { - fprintf(stderr, "not OK\n"); - exit(-1); - } -#endif - - sc2.setGroup("Bye"); - - CHECK( sc2.readPointEntry( "pointEntry" ), POINTENTRY ); - CHECK( sc2.readSizeEntry( "sizeEntry" ), SIZEENTRY); - CHECK( sc2.readRectEntry( "rectEntry" ), RECTENTRY ); - CHECK( sc2.readDateTimeEntry( "dateTimeEntry" ).toString(), DATETIMEENTRY.toString() ); - CHECK( sc2.readListEntry( "stringListEntry").join( "," ), STRINGLISTENTRY.join( "," ) ); -} diff --git a/kdecore/tests/kconfigtestgui.cpp b/kdecore/tests/kconfigtestgui.cpp deleted file mode 100644 index af560b496..000000000 --- a/kdecore/tests/kconfigtestgui.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - 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. -*/ - -#include "kconfigtestgui.h" -#include "kconfigtestgui.moc" - -// -// configtest.cpp: libKDEcore example -// -// demonstrates use of KConfig class -// -// adapted from Qt widgets demo - -#include <unistd.h> -#include <stdlib.h> -#include <kapplication.h> -#include <tqdialog.h> -#include <tqfile.h> -#include <tqfileinfo.h> -#include <tqdatetime.h> -#include <kdebug.h> -#include <ksimpleconfig.h> -#include <config.h> - -// Standard Qt widgets - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqpushbutton.h> - -// KDE includes -#include <kconfig.h> - -#ifdef HAVE_PATHS_H -#include <paths.h> -#endif - -#ifndef _PATH_TMP -#define _PATH_TMP "/tmp/" -#endif - -// -// Construct the KConfigTestView with buttons -// - -KConfigTestView::KConfigTestView( TQWidget *parent, const char *name ) - : TQDialog( parent, name ), - pConfig( 0L ), - pFile( 0L ), - pStream( 0L ) -{ - // Set the window caption/title - - setCaption( "KConfig test" ); - - // Label and edit for the app config file - pAppFileLabel = new TQLabel( this, "appconfiglabel" ); - pAppFileLabel->setText( "Application config file:" ); - pAppFileLabel->setGeometry( 20, 20, 200, 20 ); - - pAppFileEdit = new TQLineEdit( this, "appconfigedit" ); - pAppFileEdit->setGeometry( 240, 20, 160, 20 ); - connect( pAppFileEdit, TQT_SIGNAL(returnPressed()), - TQT_SLOT(appConfigEditReturnPressed())); - - // Label and edit for the group - pGroupLabel = new TQLabel( this, "grouplabel" ); - pGroupLabel->setText( "Group:" ); - pGroupLabel->setGeometry( 20, 60, 80, 20 ); - - pGroupEdit = new TQLineEdit( this, "groupedit" ); - pGroupEdit->setGeometry( 120, 60, 100, 20 ); - connect( pGroupEdit, TQT_SIGNAL(returnPressed()), - TQT_SLOT(groupEditReturnPressed())); - - // Edit and label for the key/value pair - pKeyEdit = new TQLineEdit( this, "keyedit" ); - pKeyEdit->setGeometry( 20, 100, 80, 20 ); - connect( pKeyEdit, TQT_SIGNAL( returnPressed()), - TQT_SLOT(keyEditReturnPressed())); - - pEqualsLabel = new TQLabel( this, "equalslabel" ); - pEqualsLabel->setGeometry( 105, 100, 20, 20 ); - pEqualsLabel->setText( "=" ); - - pValueEdit = new TQLineEdit( this, "valueedit" ); - pValueEdit->setGeometry( 120, 100, 100, 20 ); - pValueEdit->setText( "---" ); - - pWriteButton = new TQPushButton( this, "writebutton" ); - pWriteButton->setGeometry( 20,140, 80, 20 ); - pWriteButton->setText( "Write entry" ); - connect( pWriteButton, TQT_SIGNAL(clicked()), TQT_SLOT( writeButtonClicked() ) ); - - // Labels for the info line - pInfoLabel1 = new TQLabel( this, "infolabel1" ); - pInfoLabel1->setGeometry( 20, 200, 60, 20 ); - pInfoLabel1->setText( "Info:" ); - - pInfoLabel2 = new TQLabel( this, "infolabel2" ); - pInfoLabel2->setGeometry( 100, 200, 300, 20 ); - pInfoLabel2->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); - - // Quit button - pQuitButton = new TQPushButton( this, "quitbutton" ); - pQuitButton->setText( "Quit" ); - pQuitButton->setGeometry( 340, 60, 60, 60 ); - connect( pQuitButton, TQT_SIGNAL(clicked()), tqApp, TQT_SLOT(quit()) ); - - // create a default KConfig object in order to be able to start right away - pConfig = new KConfig( TQString::null ); -} - -KConfigTestView::~KConfigTestView() -{ - delete pConfig; - delete pFile; - delete pStream; -} - -void KConfigTestView::appConfigEditReturnPressed() -{ - // if there already was a config object, delete it and its associated data - delete pConfig; - pConfig = 0L; - delete pFile; - pFile = 0L; - delete pStream; - pStream = 0L; - - // create a new config object - if( !pAppFileEdit->text().isEmpty() ) - pConfig = new KConfig( pAppFileEdit->text() ); - - pInfoLabel2->setText( "New config object created." ); -} - -void KConfigTestView::groupEditReturnPressed() -{ - pConfig->setGroup( pGroupEdit->text() ); - // according to the Qt doc, this is begging for trouble, but for a - // test program this will do - TQString aText; - aText.sprintf( "Group set to %s", TQString( pConfig->group() ).isEmpty() ? - TQString("<default>").ascii() : pConfig->group().ascii() ); - pInfoLabel2->setText( aText ); -} - -void KConfigTestView::keyEditReturnPressed() -{ - TQString aValue = pConfig->readEntry( pKeyEdit->text() ); - // just checking aValue.isNull() would be easier here, but this is - // to demonstrate the HasKey()-method. Besides, it is better data - // encapsulation because we do not make any assumption about coding - // non-values here. - if( !pConfig->hasKey( pKeyEdit->text() ) ) - { - pInfoLabel2->setText( "Key not found!" ); - pValueEdit->setText( "---" ); - } - else - { - pInfoLabel2->setText( "Key found!" ); - pValueEdit->setText( aValue ); - } -} - -void KConfigTestView::writeButtonClicked() -{ - pConfig->writeEntry( pKeyEdit->text(), TQString( pValueEdit->text() ) ); - pInfoLabel2->setText( "Entry written" ); - - kdDebug() << "Entry written: " << 27 << endl; -} - - -int main( int argc, char **argv ) -{ - KApplication a( argc, argv, "bla" ); - - KConfigTestView *w = new KConfigTestView(); - a.setMainWidget( w ); - return w->exec(); -} diff --git a/kdecore/tests/kconfigtestgui.h b/kdecore/tests/kconfigtestgui.h deleted file mode 100644 index 7655c8142..000000000 --- a/kdecore/tests/kconfigtestgui.h +++ /dev/null @@ -1,72 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - 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 _KCONFIG_TEST_H -#define _KCONFIG_TEST_H - -#include <kapplication.h> -#include <tqdialog.h> -#include <tqfile.h> -#include <tqfileinfo.h> -#include <kdebug.h> -#include <ksimpleconfig.h> -#include <tqtextstream.h> - -// Standard Qt widgets - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqpushbutton.h> - -#include <kconfig.h> - -// -// KConfigTestView contains lots of Qt widgets. -// - -class KConfigTestView : public TQDialog -{ - Q_OBJECT -public: - KConfigTestView( TQWidget *parent=0, const char *name=0 ); - ~KConfigTestView(); - -private slots: - void appConfigEditReturnPressed(); - void groupEditReturnPressed(); - void keyEditReturnPressed(); - void writeButtonClicked(); - -private: - TQLabel* pAppFileLabel; - TQLineEdit* pAppFileEdit; - TQLabel* pGroupLabel; - TQLineEdit* pGroupEdit; - TQLineEdit* pKeyEdit; - TQLabel* pEqualsLabel; - TQLineEdit* pValueEdit; - TQPushButton* pWriteButton; - TQLabel* pInfoLabel1, *pInfoLabel2; - TQPushButton* pQuitButton; - - KConfig* pConfig; - TQFile* pFile; - TQTextStream* pStream; -}; - -#endif diff --git a/kdecore/tests/kdebugtest.cpp b/kdecore/tests/kdebugtest.cpp deleted file mode 100644 index ee49127ea..000000000 --- a/kdecore/tests/kdebugtest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "kdebug.h" -#include <tqwidget.h> -#include <kinstance.h> -#include <iostream> -#include <tqapplication.h> -#include <tqpen.h> -#include <tqvariant.h> - -class TestWidget : public QWidget -{ - -public: - TestWidget(TQWidget* parent, const char* name) - : TQWidget(parent, name) - { - kdDebug().form("mytest %s", "hello") << endl; - TQString test = "%20C this is a string"; - kdDebug(150) << test << endl; - TQCString cstr = test.latin1(); - kdDebug(150) << test << endl; - TQChar ch = 'a'; - kdDebug() << "TQChar a: " << ch << endl; - ch = '\r'; - kdDebug() << "TQChar \\r: " << ch << endl; - kdDebug() << k_lineinfo << "error on this line" << endl; - kdDebug(2 == 2) << "this is right " << perror << endl; - kdDebug() << "Before instance creation" << endl; - kdDebug(1202) << "Before instance creation" << endl; - KInstance i("kdebugtest"); - kdDebug(1) << "kDebugInfo with inexisting area number" << endl; - kdDebug(1202) << "This number has a value of " << 5 << endl; - // kdDebug() << "This number should come out as appname " << 5 << " " << "test" << endl; - kdWarning() << "1+1 = " << 1+1+1 << endl; - kdError(1+1 != 2) << "there is something really odd!" << endl; - TQString s = "mystring"; - kdDebug() << s << endl; - kdError(1202) << "Error !!!" << endl; - kdError() << "Error with no area" << endl; - - kdDebug() << "Printing a null TQWidget pointer: " << (TQWidget*)0 << endl; - - kdDebug() << "char " << '^' << " " << char(26) << endl; - TQPoint p(0,9); - kdDebug() << p << endl; - - TQRect r(9,12,58,234); - kdDebug() << r << endl; - - TQRegion reg(r); - reg += TQRect(1,60,200,59); - kdDebug() << reg << endl; - - TQStringList sl; - sl << "hi" << "this" << "list" << "is" << "short"; - kdDebug() << sl << endl; - - TQValueList<int> il; - kdDebug() << "Empty TQValueList<int>: " << il << endl; - il << 1 << 2 << 3 << 4 << 5; - kdDebug() << "TQValueList<int> filled: " << il << endl; - - Q_LLONG big = 65536LL*65536*500; - kdDebug() << big << endl; - - TQVariant v( 0.12345 ); - kdDebug() << "Variant: " << v << endl; - v = TQPen( Qt::red ); - kdDebug() << "Variant: " << v << endl; - - TQByteArray data( 6 ); - data[0] = 42; - data[1] = 'H'; - data[2] = 'e'; - data[3] = 'l'; - data[4] = 'l'; - data[5] = 'o'; - kdDebug() << data << endl; - data.resize( 80 ); - data.fill( 42 ); - kdDebug() << data << endl; - } - void resizeEvent(TQResizeEvent*) - { - kdDebug() << this << endl; - } -}; - -int main(int argc, char** argv) -{ - TQApplication app(argc, argv); - TestWidget widget(0, "NoNameWidget"); - widget.setGeometry(45, 54, 120, 80); - widget.show(); - app.setMainWidget(&widget); - app.exec(); - return 0; -} - diff --git a/kdecore/tests/kglobaltest.cpp b/kdecore/tests/kglobaltest.cpp deleted file mode 100644 index d03be209e..000000000 --- a/kdecore/tests/kglobaltest.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include <config.h> - -#include <kglobal.h> -#include <stdio.h> -#include <kapplication.h> -#include <stdlib.h> -#include <kdebug.h> -#include <assert.h> -#include <kcmdlineargs.h> - -static bool check(const TQString& txt, TQString a, TQString b) -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -void testkasciistricmp() -{ - assert( kasciistricmp( "test", "test" ) == 0 ); - assert( kasciistricmp( "test", "Test" ) == 0 ); - assert( kasciistricmp( "TeSt", "tEst" ) == 0 ); - - assert( kasciistricmp( 0, 0 ) == 0 ); - assert( kasciistricmp( "", "" ) == 0 ); - assert( kasciistricmp( 0, "" ) < 0 ); - assert( kasciistricmp( "", 0 ) > 0 ); - - assert( kasciistricmp( "", "foo" ) < 0 ); - assert( kasciistricmp( "foo", "" ) > 0 ); - - assert( kasciistricmp( "test", "testtest" ) < 0 ); - assert( kasciistricmp( "testtest", "test" ) > 0 ); - - assert( kasciistricmp( "a", "b" ) < 0 ); - assert( kasciistricmp( "b", "a" ) > 0 ); - assert( kasciistricmp( "A", "b" ) < 0 ); - assert( kasciistricmp( "b", "A" ) > 0 ); - assert( kasciistricmp( "a", "B" ) < 0 ); - assert( kasciistricmp( "B", "a" ) > 0 ); - assert( kasciistricmp( "A", "B" ) < 0 ); - assert( kasciistricmp( "B", "A" ) > 0 ); -} - -int main(int argc, char *argv[]) -{ - KApplication::disableAutoDcopRegistration(); - KCmdLineArgs::init( argc, argv, "kglobaltest", 0, 0, 0, 0 ); - KApplication app( false, false ); - - testkasciistricmp(); - - printf("\nTest OK !\n"); -} - diff --git a/kdecore/tests/kiconloadertest.cpp b/kdecore/tests/kiconloadertest.cpp deleted file mode 100644 index 96a7a6813..000000000 --- a/kdecore/tests/kiconloadertest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include <kiconloader.h> -#include <tqdatetime.h> -#include <stdio.h> -#include <kapplication.h> -#include <stdlib.h> -#include <kdebug.h> - -int main(int argc, char *argv[]) -{ - KApplication app(argc,argv,"kiconloadertest"/*,false,false*/); - - KIconLoader * mpLoader = KGlobal::iconLoader(); - KIcon::Context mContext = KIcon::Application; - TQTime dt; - dt.start(); - int count = 0; - for ( int mGroup = 0; mGroup < KIcon::LastGroup ; ++mGroup ) - { - kdDebug() << "queryIcons " << mGroup << "," << mContext << endl; - TQStringList filelist=mpLoader->queryIcons(mGroup, mContext); - kdDebug() << " -> found " << filelist.count() << " icons." << endl; - int i=0; - for(TQStringList::Iterator it = filelist.begin(); - it != filelist.end() /*&& i<10*/; - ++it, ++i ) - { - //kdDebug() << ( i==9 ? "..." : (*it) ) << endl; - mpLoader->loadIcon( (*it), (KIcon::Group)mGroup ); - ++count; - } - } - kdDebug() << "Loading " << count << " icons took " << (float)(dt.elapsed()) / 1000 << " seconds" << endl; -} - diff --git a/kdecore/tests/kipctest.cpp b/kdecore/tests/kipctest.cpp deleted file mode 100644 index 136aa6d70..000000000 --- a/kdecore/tests/kipctest.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <tqobject.h> -#include <kapplication.h> -#include <kipc.h> -#include "kipctest.h" - -MyObject::MyObject() - : TQObject(0L, "testobj") -{ - connect(kapp, TQT_SIGNAL(kdisplayPaletteChanged()), TQT_SLOT(slotPaletteChanged())); - connect(kapp, TQT_SIGNAL(kdisplayFontChanged()), TQT_SLOT(slotFontChanged())); - connect(kapp, TQT_SIGNAL(kdisplayStyleChanged()), TQT_SLOT(slotStyleChanged())); - connect(kapp, TQT_SIGNAL(backgroundChanged(int)), TQT_SLOT(slotBackgroundChanged(int))); - connect(kapp, TQT_SIGNAL(appearanceChanged()), TQT_SLOT(slotAppearanceChanged())); - connect(kapp, TQT_SIGNAL(kipcMessage(int,int)), TQT_SLOT(slotMessage(int,int))); -} - -int main(int argc, char **argv) -{ - KApplication app(argc, argv, "kipc"); - - if (argc == 3) - { - KIPC::sendMessageAll((KIPC::Message) atoi(argv[1]), atoi(argv[2])); - return 0; - } - - MyObject obj; - return app.exec(); -} - -#include "kipctest.moc" diff --git a/kdecore/tests/kipctest.h b/kdecore/tests/kipctest.h deleted file mode 100644 index 17122fbd8..000000000 --- a/kdecore/tests/kipctest.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __blah__h__ -#define __blah__h__ - -#include <tqobject.h> - -class MyObject: public TQObject -{ - Q_OBJECT -public: - MyObject(); - -public slots: - void slotPaletteChanged() { printf("SIGNAL: Palette changed\n"); } - void slotStyleChanged() { printf("SIGNAL: Style changed\n"); } - void slotFontChanged() { printf("SIGNAL: Font changed\n"); } - void slotBackgroundChanged(int i) { printf("SIGNAL: Background %d changed\n", i); } - void slotAppearanceChanged() { printf("SIGNAL: Appearance changed\n"); } - void slotMessage(int id, int arg) { printf("SIGNAL: user message: %d,%d\n", id, arg); } -}; - -#endif diff --git a/kdecore/tests/klocaletest.cpp b/kdecore/tests/klocaletest.cpp deleted file mode 100644 index 39bef8dde..000000000 --- a/kdecore/tests/klocaletest.cpp +++ /dev/null @@ -1,199 +0,0 @@ -// klocaletest.cpp -*- C++ -*- -// -// $Id$ -// -// Author: Jacek Konieczny <jajcus@zeus.polsl.gliwice.pl> -// - -#include <stdlib.h> -#include <stdio.h> - -#include <tqdatetime.h> -#include <tqlabel.h> - -#include <kglobal.h> -#include <kglobalsettings.h> -#include "klocale.h" -#include <kapplication.h> -#include <kcharsets.h> -#include <kdebug.h> - -#include "klocaletest.h" - -bool check(TQString txt, TQString a, TQString b) -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -bool checkDate(TQString txt, TQDate a, TQDate b) -{ - if (a == b) { - kdDebug() << txt << " : checking '" << a.toString() << "' against expected value '" << b.toString() << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a.toString() << "' against expected value '" << b.toString() << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -Test::Test( TQWidget *parent, const char *name ) - : TQWidget( parent, name ) -{ - setCaption("Testing KLocale"); - - TQWidget *d = tqApp->desktop(); - setGeometry((d->width()-320)>>1, (d->height()-160)>>1, 420, 420); - - createFields(); - show(); -} - -Test::~Test() -{ - ; -} - -void Test::createFields() -{ - TQString string; - - string+="Selected languages: "; - string+=KGlobal::locale()->languages()+"\n"; - - // This will show nothing, as there is no klocaletest.mo - // but you can copy other *.mo file - string+="Used language: "; - string+=KGlobal::locale()->language()+"\n"; - string+="Locale encoding: "; - string+=TQString::tqfromLatin1(KGlobal::locale()->encoding())+"\n"; - - string+="Localized date and time: "; - string+=KGlobal::locale()->formatDateTime(TQDateTime::tqcurrentDateTime()); - string+="\nLocalized monetary numbers: "; - string+=KGlobal::locale()->formatMoney(1234567.89) + " / \n" +KGlobal::locale()->formatMoney(-1234567.89); - // This will not work - // but you can copy other *.mo file - string+="\nSome localized strings:\n"; - string+=TQString::tqfromLatin1("Yes = ")+i18n("Yes")+"\n"; - string+=TQString::tqfromLatin1("No = ")+i18n("No")+"\n"; - string+=TQString::tqfromLatin1("Help = ")+i18n("Help")+"\n"; - string+=TQString::tqfromLatin1("Cancel = ")+i18n("Cancel")+"\n"; - - label=new TQLabel(string,this,"Label"); - label->setGeometry(10,10,400,400); - label->setFont(KGlobalSettings::generalFont()); - label->show(); -} - -int main( int argc, char ** argv ) -{ - KLocale::setMainCatalogue("kdelibs"); - KApplication a( argc, argv, "klocaletest" ); - - KGlobal::locale()->setLanguage(TQString::tqfromLatin1("en_US")); - KGlobal::locale()->setCountry(TQString::tqfromLatin1("C")); - KGlobal::locale()->setThousandsSeparator(TQString::tqfromLatin1(",")); - - TQString formatted; - formatted = KGlobal::locale()->formatNumber( 70 ); check("formatNumber(70)",formatted,"70.00"); - formatted = KGlobal::locale()->formatNumber( 70, 0 ); check("formatNumber(70, 0)",formatted,"70"); - formatted = KGlobal::locale()->formatNumber( 70.2 ); check("formatNumber(70.2)",formatted,"70.20"); - formatted = KGlobal::locale()->formatNumber( 70.24 ); check("formatNumber(70.24)",formatted,"70.24"); - formatted = KGlobal::locale()->formatNumber( 70.245 ); check("formatNumber(70.245)",formatted,"70.25"); /*rounded*/ - formatted = KGlobal::locale()->formatNumber(1234567.89123456789,8); check("formatNumber(1234567.89123456789,8)",formatted,"1,234,567.89123457"); - - formatted = KGlobal::locale()->formatNumber("70"); check("formatNumber(\"70\")",formatted,"70.00"); - formatted = KGlobal::locale()->formatNumber("70", true, 2); check("formatNumber(\"70\", true, 2)",formatted,"70.00"); - formatted = KGlobal::locale()->formatNumber("70", true, 0); check("formatNumber(\"70\", true, 0)",formatted,"70"); - formatted = KGlobal::locale()->formatNumber("70.9123", true, 0); check("formatNumber(\"70.9123\", true, 0)",formatted,"71"); /* rounded */ - formatted = KGlobal::locale()->formatNumber("-70.2", true, 2); check("formatNumber(\"-70.2\", true, 2)",formatted,"-70.20"); - formatted = KGlobal::locale()->formatNumber("+70.24", true, 2); check("formatNumber(\"+70.24\", true, 2)",formatted,"70.24"); - formatted = KGlobal::locale()->formatNumber("70.245", true, 2); check("formatNumber(\"70.245\", true, 2)",formatted,"70.25"); /*rounded*/ - formatted = KGlobal::locale()->formatNumber("99.996", true, 2); check("formatNumber(\"99.996\", true, 2)",formatted,"100.00"); /*rounded*/ - formatted = KGlobal::locale()->formatNumber("12345678901234567.89123456789", false, 0); check("formatNumber(\"12345678901234567.89123456789\", false, 0)",formatted,"12,345,678,901,234,567.89123456789"); - - - - double num; - bool ok; - num = KGlobal::locale()->readNumber( "12,1", &ok ); check("readNumber(12,1)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,100", &ok ); check("readNumber(12,100)",ok?"yes":"no","yes"); - num = KGlobal::locale()->readNumber( "12,100000,000", &ok ); check("readNumber(12,100000,000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,100000000", &ok ); check("readNumber(12,100000000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,100000,000", &ok ); check("readNumber(12,100000,000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,,100,000", &ok ); check("readNumber(12,,100,000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,1000,000", &ok ); check("readNumber(12,1000,000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,0000000,000", &ok ); check("readNumber(12,0000000,000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,0000000", &ok ); check("readNumber(12,0000000)",ok?"yes":"no","no"); - num = KGlobal::locale()->readNumber( "12,146,131.12", &ok ); check("readNumber(12,146,131.12)",ok?"yes":"no","yes"); - num = KGlobal::locale()->readNumber( "1.12345678912", &ok ); - qDebug( "%s", TQString::number( num, 'g', 12 ).latin1() ); // warning this is the only way to see all decimals - check("readNumber(1.12345678912)",ok && num==1.12345678912?"yes":"no","yes"); - // bug 95511 - KLocale locale(*KGlobal::locale()); - locale.setCurrencySymbol("$$"); - num = locale.readMoney("1,234,567.89$$", &ok); - check("readMoney(1,234,567.89$$)",ok?"yes":"no","yes"); - num = locale.readMoney("-1,234,567.89$$", &ok); - check("readMoney(-1,234,567.89$$)",ok?"yes":"no","yes"); - - TQDate date; - date.setYMD( 2002, 5, 3 ); - checkDate("readDate( 3, 5, 2002 )",date,KGlobal::locale()->readDate( KGlobal::locale()->formatDate( date ) ) ); - date = TQDate::tqcurrentDate(); - checkDate("readDate( TQDate::tqcurrentDate() )",date,KGlobal::locale()->readDate( KGlobal::locale()->formatDate( date ) ) ); - - TQTime time; - time = KGlobal::locale()->readTime( "11:22:33", &ok ); - check("readTime(\"11:22:33\")", (ok && time == TQTime(11, 22, 33)) ? - "yes" : "no", "yes"); - time = KGlobal::locale()->readTime( "11:22", &ok ); - check("readTime(\"11:22\")", (ok && time == TQTime(11, 22, 0)) ? - "yes" : "no", "yes"); - time = KGlobal::locale()->readTime( "foo", &ok ); - check("readTime(\"foo\")", (!ok && !time.isValid()) ? - "invalid" : "valid", "invalid"); - - time = KGlobal::locale()->readTime( "11:22:33", KLocale::WithoutSeconds, &ok ); - check("readTime(\"11:22:33\", WithoutSeconds)", (!ok && !time.isValid()) ? - "invalid" : "valid", "invalid"); - time = KGlobal::locale()->readTime( "11:22", KLocale::WithoutSeconds, &ok ); - check("readTime(\"11:22\", WithoutSeconds)", (ok && time == TQTime(11, 22, 0)) ? - "yes" : "no", "yes"); - - KGlobal::locale()->setTimeFormat( "%H:%M %p" ); - time = TQTime( 0, 22, 33 ); - TQString timeStr = KGlobal::locale()->formatTime( time, true /*seconds*/, false /*duration*/ ); - check("formatTime(\"0:22\", as time)", timeStr, "00:22 am" ); - timeStr = KGlobal::locale()->formatTime( time, true /*seconds*/, true /*duration*/ ); - check("formatTime(\"0:22\", as duration)", timeStr, "00:22" ); - - kdDebug() << "setLanguage C\n"; - KGlobal::locale()->setLanguage(TQString::tqfromLatin1("C")); - kdDebug() << "C: " << i18n("yes") << " " << i18n(TQACCEL_OBJECT_NAME_STRING, "Space") << endl; - - kdDebug() << "setLanguage de\n"; - KGlobal::locale()->setLanguage(TQString::tqfromLatin1("de")); - kdDebug() << "de: " << i18n("yes") << " " << i18n(TQACCEL_OBJECT_NAME_STRING, "Space") << endl; - - - Test m; - a.setMainWidget( &m ); - m.show(); - - return a.exec(); -} - -#include "klocaletest.moc" diff --git a/kdecore/tests/klocaletest.h b/kdecore/tests/klocaletest.h deleted file mode 100644 index 83f4f5cef..000000000 --- a/kdecore/tests/klocaletest.h +++ /dev/null @@ -1,32 +0,0 @@ -// $Id$ - -#ifndef KLOCALETEST_H -#define KLOCALETEST_H - -#include <tqwidget.h> - -class TQLabel; - -/** test: a small test program for KLocale - */ -class Test : public TQWidget -{ - Q_OBJECT - -public: - /**@name methods */ - //@{ - /** Constructor - */ - Test( TQWidget *parent=0, const char *name=0 ); - /** Destructor - */ - ~Test(); - -private: - TQString showLocale(TQString cat); - void createFields(); - - TQLabel *label; -}; -#endif // TEST_H diff --git a/kdecore/tests/kmacroexpandertest.cpp b/kdecore/tests/kmacroexpandertest.cpp deleted file mode 100644 index 0c41a309b..000000000 --- a/kdecore/tests/kmacroexpandertest.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include <kmacroexpander.h> - -#include <kapplication.h> -#include <kcmdlineargs.h> -#include <kdebug.h> - -#include <stdlib.h> - -bool check(TQString txt, TQString s, TQString a, TQString b) -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) - kdDebug() << txt << " (" << s << ") : '" << a << "' - ok" << endl; - else { - kdDebug() << txt << " (" << s << ") : got '" << a << "' but expected '" << b << "' - KO!" << endl; - exit(1); - } - return true; -} - -class MyCExpander : public KCharMacroExpander { -public: - MyCExpander() : KCharMacroExpander() {} -protected: - bool expandMacro(TQChar chr, TQStringList &ret) - { - if (chr == 'm') { - ret = TQString("expanded"); - return true; - } - return false; - } -}; - -class MyWExpander : public KWordMacroExpander { -public: - MyWExpander() : KWordMacroExpander() {} -protected: - bool expandMacro(const TQString &str, TQStringList &ret) - { - if (str == "macro") { - ret = TQString("expanded"); - return true; - } - return false; - } -}; - -int main(int argc, char *argv[]) -{ - KCmdLineArgs::init(argc, argv, ":", "", "", ""); - KApplication app(false,false); - TQString s, s2; - - TQMap<TQChar,TQStringList> map1; - map1.insert('n', "Restaurant \"Chew It\""); - TQStringList li; - li << "element1" << "'element2'"; - map1.insert('l', li); - - s = "text %l %n text"; - check( "KMacroExpander::expandMacros", s, KMacroExpander::expandMacros(s, map1), "text element1 'element2' Restaurant \"Chew It\" text"); - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map1), "text 'element1' ''\\''element2'\\''' 'Restaurant \"Chew It\"' text"); - s = "text \"%l %n\" text"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map1), "text \"element1 'element2' Restaurant \\\"Chew It\\\"\" text"); - - TQMap<TQChar,TQString> map; - map.insert('a', "%n"); - map.insert('f', "filename.txt"); - map.insert('u', "http://www.kde.org/index.html"); - map.insert('n', "Restaurant \"Chew It\""); - - s = "Title: %a - %f - %u - %n - %%"; - check( "KMacroExpander::expandMacros", s, KMacroExpander::expandMacros(s, map), "Title: %n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\" - %"); - - s = "kedit --caption %n %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption 'Restaurant \"Chew It\"' 'filename.txt'"); - - map.replace('n', "Restaurant 'Chew It'"); - s = "kedit --caption %n %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption 'Restaurant '\\''Chew It'\\''' 'filename.txt'"); - - s = "kedit --caption \"%n\" %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption \"Restaurant 'Chew It'\" 'filename.txt'"); - - map.replace('n', "Restaurant \"Chew It\""); - s = "kedit --caption \"%n\" %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption \"Restaurant \\\"Chew It\\\"\" 'filename.txt'"); - - map.replace('n', "Restaurant $HOME"); - s = "kedit --caption \"%n\" %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption \"Restaurant \\$HOME\" 'filename.txt'"); - - map.replace('n', "Restaurant `echo hello`"); - s = "kedit --caption \"%n\" %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption \"Restaurant \\`echo hello\\`\" 'filename.txt'"); - - map.replace('n', "Restaurant `echo hello`"); - s = "kedit --caption \"`echo %n`\" %f"; - check( "KMacroExpander::expandMacrosShellQuote", s, KMacroExpander::expandMacrosShellQuote(s, map), "kedit --caption \"$( echo 'Restaurant `echo hello`')\" 'filename.txt'"); - - TQMap<TQString,TQString> smap; - smap.insert("foo", "%n"); - smap.insert("file", "filename.txt"); - smap.insert("url", "http://www.kde.org/index.html"); - smap.insert("name", "Restaurant \"Chew It\""); - - s = "Title: %foo - %file - %url - %name - %"; - check( "KMacroExpander::expandMacros", s, KMacroExpander::expandMacros(s, smap), "Title: %n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\" - %"); - - s = "Title: %{foo} - %{file} - %{url} - %{name} - %"; - check( "KMacroExpander::expandMacros", s, KMacroExpander::expandMacros(s, smap), "Title: %n - filename.txt - http://www.kde.org/index.html - Restaurant \"Chew It\" - %"); - - s = "Title: %foo-%file-%url-%name-%"; - check( "KMacroExpander::expandMacros", s, KMacroExpander::expandMacros(s, smap), "Title: %n-filename.txt-http://www.kde.org/index.html-Restaurant \"Chew It\"-%"); - - s = "Title: %{file} %{url"; - check( "KMacroExpander::expandMacros", s, KMacroExpander::expandMacros(s, smap), "Title: filename.txt %{url"); - - MyCExpander mx1; - s = "subst %m but not %n equ %%"; - s2 = s; - mx1.expandMacros(s2); - check( "MyCExpander::expandMacros", s, s2, "subst expanded but not %n equ %"); - - MyWExpander mx2; - s = "subst %macro but not %not equ %%"; - s2 = s; - mx2.expandMacros(s2); - check( "MyWExpander::expandMacros", s, s2, "subst expanded but not %not equ %"); - - kdDebug() << endl << "Test OK!" << endl; -} - diff --git a/kdecore/tests/kmdcodectest.cpp b/kdecore/tests/kmdcodectest.cpp deleted file mode 100644 index e74d6f4b4..000000000 --- a/kdecore/tests/kmdcodectest.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000,2001 Dawit Alemayehu <adawit@kde.org> - - 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. -*/ - -#include <config.h> -#include <unistd.h> -#include <time.h> - -#include <iostream> - -#include <tqbuffer.h> -#include <tqfile.h> - -#include <kdebug.h> -#include <klocale.h> -#include <kcmdlineargs.h> -#include <kapplication.h> - -#include <kmdcodec.h> - -using namespace std; - -#define TEST_BLOCK_LEN 1000 // Length of test blocks. -#define TEST_BLOCK_COUNT 10000 // Number of test blocks. -#define MAX_READ_BUF_SIZE 8192 - -enum Codec -{ - Unspecified=0, - Base64Encode, - Base64Decode, - UUEncode, - UUDecode, - QPEncode, - QPDecode -}; - -void MD5_timeTrial (); -void MD5_testSuite (); -void testCodec (const char*, Codec, bool); -void MD5_verify (const char*, const char*, bool); -void MD5_file (const char * , bool rawOutput = false); -void MD5_string (const char *, const char *expected = 0, bool rawOutput = false); - -long readContent (const TQFile& f, long count, TQByteArray& buf) -{ - long result; - int old_size; - - old_size = buf.size(); - buf.resize(old_size+count); - - result = read (f.handle (), buf.data()+old_size, count); - - if ( result > 0 && result < count ) - { - buf.resize( old_size + result ); - } - else if ( result == 0 ) - { - buf.resize( old_size ); - } - else if ( result == -1 ) - { - kdError() << "Could not read the file!" << endl; - } - - return result; -} - -void testCodec (const char* msg, Codec type, bool isFile) -{ - TQByteArray output; - - if ( isFile ) - { - int count; - TQByteArray data; - - TQFile f (TQFile::encodeName(msg)); - - if (!f.exists()) - { - kdError() << "Could not find: " << f.name () << endl; - return; - } - - if (!f.open(IO_ReadOnly)) - { - f.close (); - kdError() << "Could not open: " << f.name() << endl; - return; - } - - // Read contents of file... - count = 0; - - while ((count= readContent(f, MAX_READ_BUF_SIZE, data)) > 0); - - // Error! Exit! - if ( count == -1 ) - { - kdError () << "Error reading from: " << f.name() << endl; - f.close (); - return; - } - - f.close (); - - // Perform the requested encoding or decoding... - switch (type) - { - case Base64Encode: - KCodecs::base64Encode(data, output, true); - break; - case Base64Decode: - KCodecs::base64Decode(data, output); - break; - case UUEncode: - KCodecs::uuencode(data, output); - break; - case UUDecode: - KCodecs::uudecode(data, output); - break; - case QPEncode: - KCodecs::quotedPrintableEncode(data, output, true); - break; - case QPDecode: - KCodecs::quotedPrintableDecode(data, output); - break; - default: - break; - } - - TQCString result (output.data(), output.size()+1); - cout << "Result: " << endl << result << endl; - } - else - { - TQCString result; - - const size_t len = strlen(msg); - output.resize(len); - memcpy (output.data(), msg, len); - - switch (type) - { - case Base64Encode: - result = KCodecs::base64Encode(output); - break; - case Base64Decode: - result = KCodecs::base64Decode(output); - break; - case UUEncode: - result = KCodecs::uuencode(output); - break; - case UUDecode: - result = KCodecs::uudecode(output); - break; - case QPEncode: - result = KCodecs::quotedPrintableEncode(output); - break; - case QPDecode: - result = KCodecs::quotedPrintableDecode(output); - break; - default: - break; - } - cout << result << endl; - } -} - -void MD5_timeTrial () -{ - KMD5 context; - - time_t endTime; - time_t startTime; - - TQ_UINT8 block[TEST_BLOCK_LEN]; - TQ_UINT32 i; - - cout << "Timing test. Digesting " << TEST_BLOCK_COUNT << " blocks of " - << TEST_BLOCK_LEN << "-byte..." << endl; - - // Initialize block - for (i = 0; i < TEST_BLOCK_LEN; i++) - block[i] = (TQ_UINT8)(i & 0xff); - - // Start timer - time (&startTime); - - // Digest blocks - for (i = 0; i < TEST_BLOCK_COUNT; i++) - context.update (block, TEST_BLOCK_LEN); - - // Stop timer - time (&endTime); - - long duration = endTime - startTime; - long speed; - if (duration) - speed = (TEST_BLOCK_LEN * (TEST_BLOCK_COUNT/duration)); - else - speed = TEST_BLOCK_COUNT; - - cout << "Result: " << endl; - cout << " Time = " << duration << " seconds" << endl; - cout << " Speed = " << speed << " bytes/second" << endl; - cout << " Digest = " << context.hexDigest() << endl; -} - -void MD5_testSuite () -{ - cout << "MD5 preset test suite as defined in RFC 1321:" << endl; - MD5_string ( "", "d41d8cd98f00b204e9800998ecf8427e" ); - MD5_string ( "a", "0cc175b9c0f1b6a831c399e269772661" ); - MD5_string ( "abc", "900150983cd24fb0d6963f7d28e17f72" ); - MD5_string ( "message digest", "f96b697d7cb7938d525a2f31aaf161d0" ); - MD5_string ( "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b" ); - MD5_string ( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "d174ab98d277d9f5a5611c2c9f419d9f" ); - MD5_string ( "12345678901234567890123456789012345678901234567890123456789012" - "345678901234567890", "57edf4a22be3c955ac49da2e2107b67a" ); -} - -void MD5_verify( const char *input, const char *digest, bool isFile ) -{ - bool result; - KMD5 context; - - if ( !isFile ) - { - context.update (TQCString(input)); - result = context.verify( digest ); - cout << "Input string: " << input << endl; - } - else - { - TQFile f (input); - - if (!f.open (IO_ReadOnly)) - { - f.close (); - kdFatal() << "Cannot open file for reading!" << endl; - } - - result = context.verify (digest); - f.close (); - - cout << "Input filename: " << input << endl; - } - - cout << "Calculated Digest = " << context.hexDigest() << endl; - cout << "Supplied Digest = " << digest << endl; - cout << "Matches: " << (result ? "TRUE":"FALSE") << endl; -} - -void MD5_file (const char *filename, bool rawOutput ) -{ - TQFile f (TQFile::encodeName(filename)); - - if (!f.open(IO_ReadOnly)) - { - f.close(); - kdError() << "(" << filename << ") cannot be opened!" << endl; - return; - } - - KMD5 context; - context.update( f ); - - if ( rawOutput ) - cout << "MD5 (" << filename << ") = " << context.rawDigest() << endl; - else - cout << "MD5 (" << filename << ") = " << context.hexDigest() << endl; - - f.close (); -} - -void MD5_string (const char *input, const char* expected, bool rawOutput ) -{ - KMD5 context; - context.update (TQCString(input)); - - cout << "Checking MD5 for: " << input << endl; - - if ( rawOutput ) - cout << "Result: " << context.rawDigest() << endl; - else - cout << "Result: " << context.hexDigest() << endl; - - if ( expected ) - { - cout << "Expected: " << expected << endl; - cout << "Status: " << context.verify (expected) << endl; - } -} - -int main (int argc, char *argv[]) -{ - const char *version = "1.0"; - const char *description = "Unit test for md5, base64 encode/decode and uuencode/decode facilities"; - KCmdLineOptions options[] = - { - { "c <digest>", "compare <digest> with the calculated digest for a string or file.", 0 }, - { "d", "decode the given string or file using base64", 0 }, - { "e", "encode the given string or file using base64", 0 }, - { "f", "the filename to be used as input", "default" }, - { "p", "encode the given string or file using quoted-printable", 0}, - { "q", "decode the given string or file using quoted-printable", 0}, - { "r", "calculate the raw md5 for the given string or file", 0 }, - { "s", "the string to be used as input", 0 }, - { "t", "perform a timed message-digest test", 0 }, - { "u", "uuencode the given string or file", 0 }, - { "x", "uudecode the given string or file", 0 }, - { "z", "run a preset message-digest test", 0 }, - { "+command", "[input1, input2,...]", 0 }, - KCmdLineLastOption - }; - - KCmdLineArgs::init( argc, argv, "kmdcodectest", description, version ); - KCmdLineArgs::addCmdLineOptions( options ); - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - int count = args->count(); - - KApplication app; - - if (!count) - { - if ( args->isSet("t") ) - MD5_timeTrial (); - else if ( args->isSet("z") ) - MD5_testSuite (); - else - args->usage(); - } - else - { - bool isVerify = args->isSet("c"); - bool isString = args->isSet("s"); - bool isFile = args->isSet( "f" ); - Codec type = Unspecified; - if ( args->isSet("d") ) - type = Base64Decode; - else if ( args->isSet("e") ) - type = Base64Encode; - else if ( args->isSet("u") ) - type = UUEncode; - else if ( args->isSet("x") ) - type = UUDecode; - else if ( args->isSet("p") ) - type = QPEncode; - else if ( args->isSet("q") ) - type = QPDecode; - if ( isVerify ) - { - const char* opt = args->getOption( "c" ).data(); - for ( int i=0 ; i < count; i++ ) - MD5_verify ( TQCString(args->arg(i)), opt, (isString || !isFile) ); - } - else - { - for ( int i=0 ; i < count; i++ ) - { - if ( type != Unspecified ) - testCodec( args->arg(i), type, isFile ); - else - { - if ( isString ) - MD5_string( args->arg( i ), 0, args->isSet("r") ); - else - MD5_file( args->arg( i ), args->isSet("r") ); - } - } - } - } - args->clear(); - return (0); -} diff --git a/kdecore/tests/kmemtest.cpp b/kdecore/tests/kmemtest.cpp deleted file mode 100644 index 83c452e50..000000000 --- a/kdecore/tests/kmemtest.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include <stdio.h> -#include <kapplication.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/mman.h> - -void showMem() -{ - char buf[257]; - - printf("Reported Memory Usage Of This Process:\n"); - - FILE *fs = fopen("/proc/self/status", "r"); - bool done = false; - while (!done) - { - fgets(buf, 256, fs); - buf[256] = 0; - if ((strncmp(buf, "VmLib", 5)==0) || - (strncmp(buf, "VmData", 6)==0) || - (strncmp(buf, "VmSize", 6)==0) || - (strncmp(buf, "VmExe", 5)==0) || - (strncmp(buf, "VmRSS", 5)==0) || - (strncmp(buf, "VmLck", 5)==0)) - printf("%s", buf); - done = (strncmp(buf, "VmLib", 5) == 0); - } - fclose(fs); -} - -long showTotalMem() -{ - long realMem = 0; - char buf[257]; - - FILE *fs = fopen("/proc/meminfo", "r"); - bool done = false; - while (!done) - { - fgets(buf, 256, fs); - buf[256] = 0; - if (strlen(buf)==0) done = true; - if (strncmp(buf, "Mem:", 4)==0) - { - long total = 0; - long used = 0; - long free = 0; - long shared = 0; - long buffers = 0; - long cached = 0; - sscanf(buf, "Mem: %ld %ld %ld %ld %ld %ld", - &total, &used, &free, &shared, &buffers, &cached); - realMem = used-buffers-cached; - printf("Actual Total Memory Usage: %0.1fKb\n", realMem/1024.0); - done = true; - } - } - fclose(fs); - return realMem; -} - -long memSize() -{ - long realMem = 0; - char buf[257]; - - FILE *fs = fopen("/proc/meminfo", "r"); - bool done = false; - while (!done) - { - fgets(buf, 256, fs); - buf[256] = 0; - if (strlen(buf)==0) done = true; - if (strncmp(buf, "Mem:", 4)==0) - { - long total = 0; - long used = 0; - long free = 0; - long shared = 0; - long buffers = 0; - long cached = 0; - sscanf(buf, "Mem: %ld %ld %ld %ld %ld %ld", - &total, &used, &free, &shared, &buffers, &cached); - realMem = total; - done = true; - } - } - fclose(fs); - return realMem; -} - -void *mmapFile(const char *file) -{ - int fd = open(file, O_RDONLY); - if (fd == 0) - { - printf("open: %s\n", strerror(errno)); - exit(-1); - } - - struct stat stat_s; - int result = fstat(fd, &stat_s); - if (result) - { - printf("stat: %s\n", strerror(errno)); - exit(-1); - } - - void *ptr = mmap(0, stat_s.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (ptr == 0) - { - printf("mmap: %s\n", strerror(errno)); - exit(-1); - } - return ptr; -} - -int main(int argc, char *argv[]) -{ - if ((argc==2) && (strcmp(argv[1], "all")==0)) - { - long mem_size = memSize(); - mem_size += mem_size / 16; - printf("Malloc... %0.1fMb\n", mem_size/(1024.0*1024.0)); - char *mem = (char *) malloc(mem_size); - for(long i=0; i < mem_size; i+=1024) - { - mem[i] = 99; - } - printf("Done!\n"); - exit(1); - } - - if ((argc==3) && (strcmp(argv[1], "calc")==0)) - { - char buf[257]; - int total = 0; - long val; - while(true) - { - buf[0] = 0; - fgets(buf, sizeof(buf), stdin); - if (!strlen(buf)) - { - printf("%s total = %0.1fKb (%d bytes)\n", argv[2], total/1024.0, total); - exit(1); - } - sscanf(buf, "%lx", &val); - total += val; -// printf("Val = %ld\n", val); - } - exit(1); - } - - - if ((argc>=2) && (strcmp(argv[1], "launch")==0)) - { - showMem(); - - char buf[200]; - - if (argc >=3) - snprintf(buf, 200, "%s &", argv[2]); - else - snprintf(buf, 200, "%s &", argv[0]); - - printf("Waiting for memory usage to settle down....\n"); - long prev = showTotalMem(); - long diff = 0; - do { - sleep(15); - long next = showTotalMem(); - if (next > prev) - diff = next - prev; - else - diff = prev-next; - prev = next; - } - while (diff > 2*1024); - - for(int i=0; i < 5; i++) - { - printf("Launching #%d\n", i); - system(buf); - sleep(2); - } - - sleep(10); - printf("Waiting for memory usage to settle down....\n"); - prev = showTotalMem(); - diff = 0; - do { - sleep(15); - long next = showTotalMem(); - if (next > prev) - diff = next - prev; - else - diff = prev-next; - prev = next; - } - while (diff > 2*1024); - long fiveMem = prev; - - for(int i=5; i < 15; i++) - { - printf("Launching #%d\n", i); - system(buf); - sleep(2); - } - - sleep(10); - printf("Waiting for memory usage to settle down....\n"); - prev = showTotalMem(); - diff = 0; - do { - sleep(15); - long next = showTotalMem(); - if (next > prev) - diff = next - prev; - else - diff = prev-next; - prev = next; - } - while (diff > 2*1024); - long fifteenMem = prev; - showMem(); - - printf("Actual memory usage of 1 instance = %0.1f Kb\n", - (fifteenMem - fiveMem) /10240.0); - } -// showMem("second"); - - KApplication app(argc,argv,"kurltest"); - -// showMem("After KApplication constructor"); - -// malloc(10*1024); - -// showMem("After 10K malloc"); - - printf("Sleeping...\n"); - sleep(8000); -} diff --git a/kdecore/tests/knotifytest.cpp b/kdecore/tests/knotifytest.cpp deleted file mode 100644 index 8eb0586c0..000000000 --- a/kdecore/tests/knotifytest.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include <knotifyclient.h> -#include <kapplication.h> - -int main( int argc, char **argv ) -{ - KApplication app( argc, argv, "knotifytest" ); - KNotifyClient::userEvent( "This is a notification to notify you :)", - KNotifyClient::Messagebox, - KNotifyClient::Error ); -} diff --git a/kdecore/tests/kprocesstest.cpp b/kdecore/tests/kprocesstest.cpp deleted file mode 100644 index af04cd421..000000000 --- a/kdecore/tests/kprocesstest.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// -// MAIN -- a little demo of the capabilities of the "KProcess" class -// -// version 0.2, Aug 2nd 1997 -// $Id$ -// -// (C) Christian Czezatke -// e9025461@student.tuwien.ac.at -// - - -#include "kprocess.h" - -#include <stdio.h> -#include <string.h> -#include <kapplication.h> - -#include <signal.h> - -#include "kprocesstest.h" - -#define PROCNO 10 - - -// -// A nice input for "sort"... ;- ) -// -static const char txt[] = "hat\nder\nalte\nhexenmeister\nsich\ndoch\neinmal\nwegbegeben\n\ -und\nnun\nsollen\nseine\ngeister\nsich\nnach\nmeinem\nwillen\nregen\nseine\nwort\nund\n\ -werke\nmerkt\nich\nund\nden\nbrauch\nund\nmit\ngeistesstaerke\ntu\nich\nwunder\nauch\n"; - - -int main(int argc, char *argv[]) -{ - KProcess p1, p2, p3, p4; - Dummy dummy; - KApplication app(argc, argv, "kprocesstest"); - - - printf("Welcome to the KProcess Demo Application!\n"); - - // - // The kghostview demo -- Starts a kghostview instance blocking. -- After - // kghostview has exited, kghostview is restarted non-blocking. When the process exits, - // the signal "processExited" will be emitted. - // - - p1 << "kghostview"; - TQObject::connect(&p1, TQT_SIGNAL(processExited(KProcess *)), &dummy, TQT_SLOT(printMessage(KProcess *))); - - printf("starting kghostview blocking (close to continue)\n"); - p1.start(KProcess::Block); - printf("restarting kghostview non blocking\n"); - p1.start(); - - - // - // A konsole with tcsh to demonstrate how to pass command line options to a process - // with "KProcess" (is run blocking) - // - - printf("Starting konsole with /bin/tcsh as shell (close to continue)\n"); - p2 << "konsole" << "-e" << "/bin/tcsh"; - p2.setWorkingDirectory("/tmp"); - TQObject::connect(&p2, TQT_SIGNAL(processExited(KProcess *)), &dummy, TQT_SLOT(printMessage(KProcess *))); - p2.start(KProcess::Block); - - // - // Getting the output from a process. "ls" with parameter "-l" is called and it output is captured - // - - p3 << "ls" << "-l"; - TQObject::connect(&p3, TQT_SIGNAL(processExited(KProcess *)), - &dummy, TQT_SLOT(printMessage(KProcess *))); - - TQObject::connect(&p3, TQT_SIGNAL(receivedStdout(KProcess *, char *, int)), - &dummy, TQT_SLOT(gotOutput(KProcess *, char *, int))); - TQObject::connect(&p3, TQT_SIGNAL(receivedStderr(KProcess *, char *, int)), - &dummy, TQT_SLOT(gotOutput(KProcess *, char *, int))); - - p3.start(KProcess::NotifyOnExit, KProcess::AllOutput); - - - // - // An even more advanced example of communicating with a child proces. -- A "sort" command - // is started. After it has been started a list of words (as stored in "txt") is written - // to its stdin. When the sort command has absorbed all its input it will emit the signal - // "inputSent". -- This signal is connected to "outputDone" in the Dummy object. - // - // "OutputDone" will do a "sendEof" to p4. -- This will cause "sort" to perform its task. - // The output of sort is then captured once more by connecting to the signal "outputWaiting" - // - // - - p4 << "sort"; - TQObject::connect(&p4, TQT_SIGNAL(processExited(KProcess *)), - &dummy, TQT_SLOT(printMessage(KProcess *))); - - TQObject::connect(&p4, TQT_SIGNAL(receivedStdout(KProcess *, char *, int)), - &dummy, TQT_SLOT(gotOutput(KProcess *, char *, int))); - TQObject::connect(&p4, TQT_SIGNAL(receivedStderr(KProcess *, char *, int)), - &dummy, TQT_SLOT(gotOutput(KProcess *, char *, int))); - - TQObject::connect(&p4, TQT_SIGNAL(wroteStdin(KProcess *)), - &dummy, TQT_SLOT(outputDone(KProcess *))); - - p4.start(KProcess::NotifyOnExit, KProcess::All); - printf("after p4.start"); - p4.writeStdin(txt, strlen(txt)); - - printf("Entering man Qt event loop -- press <CTRL><C> to abort\n"); - app.exec(); - - return 0; -} -#include "kprocesstest.moc" diff --git a/kdecore/tests/kprocesstest.h b/kdecore/tests/kprocesstest.h deleted file mode 100644 index 23ac443dd..000000000 --- a/kdecore/tests/kprocesstest.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// DUMMY -- A dummy class with a slot to demonstrate KProcess signals -// -// version 0.2, Aug 2nd 1997 -// -// (C) Christian Czezatke -// e9025461@student.tuwien.ac.at -// - - -#ifndef __DUMMY_H__ -#define __DUMMY_H__ - -#include <stdio.h> -#include <tqobject.h> -#include "kprocess.h" - -class Dummy : public TQObject -{ - Q_OBJECT - - public slots: - void printMessage(KProcess *proc) - { - printf("Process %d exited!\n", (int)proc->getPid()); - } - - void gotOutput(KProcess*, char *buffer, int len) - { - char result[1025]; // this is ugly since it relys on the internal buffer size of KProcess, - memcpy(result, buffer, len); // NEVER do that in your own application... ;-) - result[len] = '\0'; - printf("OUTPUT>>%s", result); - } - - void outputDone(KProcess *proc) - /* - Slot Procedure for the "sort" example. -- If it is indicated that the "sort" command has - absorbed all its input, we send an "EOF" to it to indicate that there is no more - data to be processed. - */ - { - proc->closeStdin(); - } - -}; - -#endif - - diff --git a/kdecore/tests/kprociotest.cpp b/kdecore/tests/kprociotest.cpp deleted file mode 100644 index 446dacb30..000000000 --- a/kdecore/tests/kprociotest.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -// MAIN -- a little demo of the capabilities of the "KProcess" class -// -// version 0.2, Aug 2nd 1997 -// $Id$ -// -// (C) Christian Czezatke -// e9025461@student.tuwien.ac.at -// - - -#include "kprocess.h" - -#include <stdio.h> -#include <string.h> -#include <kapplication.h> - -#include <signal.h> - -#include "kprociotest.h" - - - -// -// A nice input for "sort"... ;- ) -// -static const char txt[] = "hat\nder\nalte\nhexenmeister\nsich\ndoch\neinmal\nwegbegeben\n\ -und\nnun\nsollen\nseine\ngeister\nsich\nnach\nmeinem\nwillen\nregen\nseine\nwort\nund\n\ -werke\nmerkt\nich\nund\nden\nbrauch\nund\nmit\ngeistesstaerke\ntu\nich\nwunder\nauch\n"; - - -int main(int argc, char *argv[]) -{ - Dummy dummy; - KApplication app(argc, argv, "kprociotest"); - - printf("Welcome to the KProcIO Demo Application!\n"); - - - KProcIO p; - - p << "rev"; - - p.connect(&p, TQT_SIGNAL(processExited(KProcess*)), &dummy, TQT_SLOT(printMessage(KProcess*))); - p.connect(&p, TQT_SIGNAL(readReady(KProcIO*)), &dummy, TQT_SLOT(gotOutput(KProcIO*))); - - bool b; - - b = p.start(); - printf("Start returns %s\n", b ? "true" : "false"); - - b = p.fputs("Hello World!"); - printf("fputs returns %s\n", b ? "true" : "false"); - - b = p.fputs("This is a test. It should come out in reverse (esrever)"); - printf("fputs returns %s\n", b ? "true" : "false"); - - p.closeWhenDone(); - - printf("Entering man Qt event loop -- press <CTRL><C> to abort\n"); - app.exec(); - - return 0; -} -#include "kprociotest.moc" diff --git a/kdecore/tests/kprociotest.h b/kdecore/tests/kprociotest.h deleted file mode 100644 index 9f948e644..000000000 --- a/kdecore/tests/kprociotest.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// DUMMY -- A dummy class with a slot to demonstrate KProcess signals -// -// version 0.2, Aug 2nd 1997 -// -// (C) Christian Czezatke -// e9025461@student.tuwien.ac.at -// - - -#ifndef __DUMMY_H__ -#define __DUMMY_H__ - -#include <stdio.h> -#include <tqobject.h> -#include "kprocio.h" - -class Dummy : public TQObject -{ - Q_OBJECT - - public slots: - void printMessage(KProcess *proc) - { - printf("Process %d exited!\n", (int)proc->getPid()); - } - - void gotOutput(KProcIO*proc) - { - TQString line; - while(true) { - int result = proc->readln(line); - if (result == -1) return; - printf("OUTPUT>> [%d] '%s'\n", result, line.latin1()); - } - } - -}; - -#endif - - diff --git a/kdecore/tests/krandomsequencetest.cpp b/kdecore/tests/krandomsequencetest.cpp deleted file mode 100644 index 8f337c2f1..000000000 --- a/kdecore/tests/krandomsequencetest.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 <tqptrlist.h> - -#include "krandomsequence.h" -#include "kapplication.h" - -#include <stdio.h> - -int -main(int argc, char *argv[]) -{ - KApplication a(argc, argv, "krandomsequencetest"); - - long seed; - KRandomSequence seq; - - seed = 2; - seq.setSeed(seed);printf("Seed = %4ld :", seed); - for(int i = 0; i < 20; i++) - printf("%3ld ", seq.getLong(100)); - printf("\n"); - - seed = 0; - seq.setSeed(seed);printf("Seed = %4ld :", seed); - for(int i = 0; i < 20; i++) - printf("%3ld ", seq.getLong(100)); - printf("\n"); - - seed = 0; - seq.setSeed(seed);printf("Seed = %4ld :", seed); - for(int i = 0; i < 20; i++) - printf("%3ld ", seq.getLong(100)); - printf("\n"); - - seed = 2; - seq.setSeed(seed);printf("Seed = %4ld :", seed); - for(int i = 0; i < 20; i++) - printf("%3ld ", seq.getLong(100)); - - seq.setSeed(kapp->random()); - - TQPtrList<TQString> list; - list.append(new TQString("A")); - list.append(new TQString("B")); - list.append(new TQString("C")); - list.append(new TQString("D")); - list.append(new TQString("E")); - list.append(new TQString("F")); - list.append(new TQString("G")); - - for(TQString *str = list.first(); str; str = list.next()) - printf("%s", str->latin1()); - printf("\n\n"); - - seq.randomize(&list); - - for(TQString *str = list.first(); str; str = list.next()) - printf("%s", str->latin1()); - printf("\n\n"); - - seq.randomize(&list); - - for(TQString *str = list.first(); str; str = list.next()) - printf("%s", str->latin1()); - printf("\n\n"); - - seq.randomize(&list); - - for(TQString *str = list.first(); str; str = list.next()) - printf("%s", str->latin1()); - printf("\n\n"); - - printf("\n"); -} diff --git a/kdecore/tests/kresolvertest.cpp b/kdecore/tests/kresolvertest.cpp deleted file mode 100644 index 1b2f5148d..000000000 --- a/kdecore/tests/kresolvertest.cpp +++ /dev/null @@ -1,420 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net> - * - * 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. - **/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <sys/types.h> -#include <sys/socket.h> -#include <arpa/inet.h> - -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <netinet/in.h> -#include <sys/socket.h> -#include <unistd.h> - -#include <tqptrlist.h> -#include <tqstring.h> - -#include <kuniqueapplication.h> -#include <ksocks.h> -#include <ksockaddr.h> -#include <kextsock.h> -#include <kaboutdata.h> -#include <kcmdlineargs.h> - -#include "netsupp.h" - -/* - * These constants tell the flags in KDE::resolverFlags - * This is copied from ../netsupp.cpp - */ -#define KRF_KNOWS_AF_INET6 0x01 /* if present, the code knows about AF_INET6 */ -#define KRF_USING_OWN_GETADDRINFO 0x02 /* if present, we are using our own getaddrinfo */ -#define KRF_USING_OWN_INET_NTOP 0x04 /* if present, we are using our own inet_ntop */ -#define KRF_USING_OWN_INET_PTON 0x08 /* if present, we are using our own inet_pton */ -#define KRF_CAN_RESOLVE_UNIX 0x100 /* if present, the resolver can resolve Unix sockets */ -#define KRF_CAN_RESOLVE_IPV4 0x200 /* if present, the resolver can resolve to IPv4 */ -#define KRF_CAN_RESOLVE_IPV6 0x400 /* if present, the resolver can resolve to IPv6 */ - -namespace KDE -{ - extern const int resolverFlags; -} - -class TestApp : public KUniqueApplication -{ -public: - TestApp() : - KUniqueApplication() - { } - - int newInstance(TQValueList<TQCString> params); -}; - -bool tryLookup(const char* node, const char *serv) -{ - int error; - TQString _node = TQString::tqfromLatin1(node); - TQString _serv = TQString::tqfromLatin1(serv); - - printf("\tTrying to lookup %s|%s... ", node, serv); - TQPtrList<KAddressInfo> list = KExtendedSocket::lookup(_node, _serv, 0, &error); - list.setAutoDelete(true); - if (!list.isEmpty()) - { - printf("worked\n"); - return true; - } - - printf("failed\n\tReason was: %s\n", - (const char*)KExtendedSocket::strError(IO_LookupError, error).local8Bit()); - return false; -} - -#ifdef AF_INET6 -bool try_ntop() -{ - char buf[50]; // 46 is enough - kde_in6_addr in; - - memset(&in, 0, sizeof(in)); - ((unsigned char*)&in)[15] = 1; // set this to be ::1 - - printf("\tTrying to convert ::1 into string..."); - if (inet_ntop(AF_INET6, &in, buf, sizeof(buf)) == NULL) - { - printf("failed\n"); - return false; - } - - printf("suceeded\n\treturned '%s'\n", buf); - return strcmp(buf, "::1") == 0; -} - -bool try_pton() -{ - const char *buf = "::1"; - kde_in6_addr in; - - printf("\tTrying to convert '::1' into binary form..."); - if (inet_pton(AF_INET6, buf, &in) == 0) - { - printf("failed\n"); - return false; - } - - if (KDE_IN6_IS_ADDR_LOOPBACK(&in)) - { - printf("succeeded\n"); - return true; - } - - printf("claims to have suceeded, but returned invalid value\n"); - return false; -} -#endif - -bool tryLookup6(const char *node, const char *serv) -{ - int error; - TQString _node = TQString::tqfromLatin1(node); - TQString _serv = TQString::tqfromLatin1(serv); - - printf("\tTrying to lookup IPv6 of %s|%s... ", node, serv); - TQPtrList<KAddressInfo> list = KExtendedSocket::lookup(_node, _serv, KExtendedSocket::ipv6Socket, &error); - list.setAutoDelete(true); - if (!list.isEmpty()) - { - printf("worked\n"); - return true; - } - - printf("failed\n\tReason was: %s\n", - (const char*)KExtendedSocket::strError(IO_LookupError, error).local8Bit()); - return false; -} - -bool testKernel() -{ -#ifndef AF_INET6 - printf("\tAF_INET6 unknown. Can't test anything\n"); - return false; - -#else - int sock; - kde_sockaddr_in6 sin6; - socklen_t len = sizeof(sin6); - - printf("\tAF_INET6 == %d\n", AF_INET6); - printf("\tTrying to create an IPv6 socket..."); - sock = socket(AF_INET6, SOCK_STREAM, 0); - if (sock == -1) - printf("failed\n\tReason was: %s", strerror(errno)); - else - { - printf("succeeded\n"); - - if (getsockname(sock, (struct sockaddr*)&sin6, &len) == 0) - printf("\tSize of kernel's sockaddr_in6 is %d bytes\n", len); - else - printf("\tCould not get socket name\n"); - } - - printf("\tSize of KDE's internal sockaddr_in6 is %d bytes\n", - sizeof(kde_sockaddr_in6)); - -# ifdef HAVE_SOCKADDR_IN6 - printf("\tSize of system libraries' sockaddr_in6 is %d bytes\n", - sizeof(sockaddr_in6)); -# else - printf("\tSystem libraries don't define sockaddr_in6\n"); -# endif - - if (sock == -1) - return false; - - printf("\tTrying to bind the socket to an address..."); - sin6.sin6_family = AF_INET6; -# ifdef HAVE_SOCKADDR_SA_LEN - sin6.sin6_len = sizeof(sin6); -# endif - sin6.sin6_flowinfo = 0; - sin6.sin6_scope_id = 0; - sin6.sin6_port = 0; // bind to any port - memset(&sin6.sin6_addr, 0, sizeof(sin6.sin6_addr)); // any address - - if (bind(sock, (sockaddr*)&sin6, sizeof(sin6)) == -1) - { - printf("failed\n\tReason was: %s\n", strerror(errno)); - close(sock); - return false; - } - - printf("succeeded\n"); - - KSocketAddress *ksin = KExtendedSocket::localAddress(sock); - if (ksin != NULL) - { - printf("\tWe got socket %s\n", (const char*)ksin->pretty().latin1()); - delete ksin; - } - - close(sock); - return true; -#endif // AF_INET6 -} - -bool tryConnectLocal() -{ - KExtendedSocket ks1("::", "0", KExtendedSocket::ipv6Socket | KExtendedSocket::passiveSocket), - ks2; - const KInetSocketAddress *ksin1, *ksin2; - - printf("Attempting a loop-back connection\n\tTrying to listen on socket..."); - if (ks1.listen() != 0) - { - printf("failed\n\tReason was: %s\n", - (const char*)KExtendedSocket::strError(ks1.status(), ks1.systemError()).local8Bit()); - return false; - } - - ks1.setBlockingMode(false); - ksin1 = (KInetSocketAddress*)ks1.localAddress(); - - printf("succeeded\n\tWe have socket %s listening\n", - (const char*)ksin1->pretty().local8Bit()); - - ks2.setAddress("::1", ksin1->port()); - ks2.setSocketFlags(KExtendedSocket::ipv6Socket | KExtendedSocket::noResolve); - - printf("\tTrying to connect to that socket..."); - if (ks2.connect() != 0) - { - printf("failed\n\tReason was: %s\n", - (const char*)KExtendedSocket::strError(ks2.status(), ks2.systemError()).local8Bit()); - return false; - } - - printf("suceeded\n"); - - ksin2 = dynamic_cast<const KInetSocketAddress *>(ks2.localAddress()); - printf("\tIf you may flip to another terminal/xterm and run netstat to see\n" - "\tthis connection. It should be a connection from %s to %s.\n" - "\tPress any key to continue\n", - (const char*)ksin2->pretty().local8Bit(), (const char*)ksin1->pretty().local8Bit()); - getchar(); - return true; -} - -bool tryConnectRemote() -{ - KExtendedSocket ks("www.6bone.net", "80", KExtendedSocket::ipv6Socket); - - printf("\nAttempting a remote connection to www.6bone.net|80\n"); - - if (ks.connect() != 0) - { - printf("\tConnection failed with error: %s\n", - (const char*)KExtendedSocket::strError(ks.status(), ks.systemError()).local8Bit()); - return false; - } - - printf("\tConnection succeeded\n"); - return true; -} - -void go() -{ - int rf = KDE::resolverFlags; - printf("The resolver claims to:\n"); - if (rf & KRF_USING_OWN_GETADDRINFO) - { - printf(" - Be using its own version of getaddrinfo()\n"); - if (rf & KRF_CAN_RESOLVE_UNIX) - printf(" - Be able to resolve Unix-domain sockets\n"); - else - printf(" - Be unable to resolve Unix-domain sockets -- This shouldn't happen\n"); - if (rf & KRF_CAN_RESOLVE_IPV4) - printf(" - Be able to resolve IPv4 Internet sockets\n"); - else - printf(" - Be unable to resolve IPv4 Internet sockets -- This shouldn't happen\n"); - if (rf & KRF_CAN_RESOLVE_IPV6) - printf(" - Be able to resolve IPv6 Internet sockets\n"); - else - printf(" - Be unable to resolve IPv6 Internet sockets\n"); - } - else - printf(" - Be using the system getaddrinfo()\n"); - - if (rf & KRF_USING_OWN_INET_NTOP) - printf(" - Be using its own inet_ntop()\n"); - else - printf(" - Be using the system inet_ntop()\n"); - - if (rf & KRF_USING_OWN_INET_PTON) - printf(" - Be using its own inet_pton()\n"); - else - printf(" - Be using the system inet_pton()\n"); - - if (rf & KRF_KNOWS_AF_INET6) - printf(" - To know the value of AF_INET6\n"); - else - printf(" - Not to know the value of AF_INET6\n"); - - printf("\n\nGeneral conclusion is:\n"); - if ((rf & KRF_USING_OWN_GETADDRINFO) == 0 && - rf & KRF_KNOWS_AF_INET6) - printf(" Your system probably supports full IPv6 implementation.\n" - " This depends on whether your system's getaddrinfo() supports IPv6.\n" - " However, KDE Libraries were compiled to use the support whenever available.\n"); - else if ((rf & (KRF_USING_OWN_GETADDRINFO|KRF_KNOWS_AF_INET6)) == 0) - printf(" Your system supports partial IPv6 implementation.\n" - " That is, your system has a getaddrinfo() implementation, but KDE Libraries\n" - " don't know how to detect an IPv6 socket. That means that only request to" - " any kind of socket will use IPv6, if your getaddrinfo() returns them."); - else if (rf & KRF_USING_OWN_GETADDRINFO) - { - if (rf & KRF_KNOWS_AF_INET6) - { - printf(" Your system supports partial IPv6 implementation.\n"); - if (rf & KRF_CAN_RESOLVE_IPV6) - printf(" The KDE implementation of getaddrinfo() claims to be able to resolve\n" - " IPv6 lookups and the value of AF_INET6 is known.\n"); - else - printf(" The KDE implementation of getaddrinfo() cannot resolve IPv6 lookups.\n" - " That means that IPv6 support is limited to two addresses (:: and ::1)\n"); - } - else - printf(" Your system doesn't support IPv6\n"); - } - - /* Make sure KSocks doesn't interfere in testing */ - KSocks::disable(); - - /* Begin testing */ - printf("\nReady to start testing\nPress any key to continue..."); - getchar(); - printf("\n"); - - /* Start with simple lookups */ - printf("Trying simple lookups\n" - "All of the following look ups should work\n\n"); - tryLookup(NULL, "/tmp/something"); - tryLookup("127.0.0.1", "80"); - tryLookup("localhost", "http"); - -#ifdef AF_INET6 - printf("\nPress any key for next test"); - getchar(); - - printf("\nThis test determines if the inet_ntop and inet_pton functions work\n"); - try_ntop(); - try_pton(); -#endif - - printf("\nPress any key for next test"); - getchar(); - - printf("\nThis test determines how far the IPv6 resolution can go\n"); - if (!tryLookup6("::1", "80")) - printf("Your system can't resolve a numeric IPv6 address\n"); - else if (!tryLookup6("localhost", "80")) - printf("Your system can resolve a numeric IPv6 address, but not localhost\n"); - else if (!tryLookup6("www.6bone.net", "80")) - printf("Your system can resolve numeric IPv6 addresses and localhost, \n" - "but cannot resolve an external address to IPv6 (www.6bone.net)\n"); - else - printf("Your system can resolve any kind of IPv6 addresses\n"); - - printf("\nPress any key for next test"); - getchar(); - - printf("\nThis test determines how supported IPv6 is in your kernel\n"); - testKernel(); - - printf("\nPress any key for next test"); - getchar(); - - printf("\nThis test determines if you can connect to IPv6 addresses via TCP\n"); - tryConnectLocal(); - tryConnectRemote(); - - printf("\n\nTest finished\n"); -} - -int TestApp::newInstance(TQValueList<TQCString> /*params*/) -{ - go(); -} - -int main(int argc, char **argv) -{ - KAboutData about("socktest2", "SockTest", "1.0"); - KCmdLineArgs::init(argc, argv, &about); - KUniqueApplication::addCmdLineOptions(); - - /* TestApp a; - a.exec();*/ - go(); -} diff --git a/kdecore/tests/krfcdatetest.cpp b/kdecore/tests/krfcdatetest.cpp deleted file mode 100644 index 368a1106f..000000000 --- a/kdecore/tests/krfcdatetest.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include <stdio.h> -#include <kapplication.h> -#include <stdlib.h> -#include <kdebug.h> -#include <kglobal.h> -#include <kcharsets.h> -#include <tqtextcodec.h> -#include <krfcdate.h> - -bool check(TQString txt, time_t a, time_t b) -{ - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -int main(int argc, char *argv[]) -{ - KApplication app(argc,argv,"kurltest",false,false); - - time_t a; - time_t b; - - // From http://www.w3.org/TR/NOTE-datetime - b = KRFCDate::parseDateISO8601("1994-11-05T13:15:30Z"); - a = KRFCDate::parseDateISO8601("1994-11-05T08:15:30-05:00"); - check( "1994-11-05T08:15:30-05:00", a, b); - - a = KRFCDate::parseDateISO8601("1994-11-05T18:15:30+05:00"); - check( "1994-11-05T18:15:30+05:00", a, b); - - a = KRFCDate::parseDate("Thu Nov 5 1994 18:15:30 GMT+0500"); - check( "Thu Nov 5 1994 18:15:30 GMT+0500", a, b); - - a = KRFCDate::parseDate("Thu Nov 5 1994 18:15:30 GMT+05:00"); - check( "Thu Nov 5 1994 18:15:30 GMT+05:00", a, b); - - a = KRFCDate::parseDate("Wednesday, 05-Nov-94 13:15:30 GMT"); - check( "Wednesday, 05-Nov-94 13:15:30 GMT", a, b); - - a = KRFCDate::parseDate("Wed, 05-Nov-1994 13:15:30 GMT"); - check( "Wed, 05-Nov-1994 13:15:30 GMT", a, b); - - a = KRFCDate::parseDate("Wed, 05-November-1994 13:15:30 GMT"); - check( "Wed, 05-November-1994 13:15:30 GMT", a, b); - - b = KRFCDate::parseDateISO8601("1994-01-01T12:00:00"); - a = KRFCDate::parseDateISO8601("1994"); - check( "1994", a, b ); - - a = KRFCDate::parseDateISO8601("1994-01"); - check( "1994-01", a, b ); - - a = KRFCDate::parseDateISO8601("1994-01-01"); - check( "1994-01-01", a, b ); - - b = 0; - - // pass RFC date to ISO parser - a = KRFCDate::parseDateISO8601("Thu, 01 Jan 2004 19:48:21 GMT"); - check("pass RFC date \"Thu, 01 Jan 2004 19:48:21 GMT\" to parseDateISO8601", a, b); - - // pass ISO date to RFC parser - a = KRFCDate::parseDate("1994-01-01T12:00:00"); - check("pass ISO date \"1994-01-01T12:00:00\" to parseDate()", a, b); - - // empty/null strings - - check("parseDateISO8601(TQString())", KRFCDate::parseDateISO8601(TQString()), b); - check("parseDateISO8601(\"\")", KRFCDate::parseDateISO8601(""), b); - check("parseDate(TQString())", KRFCDate::parseDate(TQString()), b); - check("parseDate(\"\")", KRFCDate::parseDate(""), b); - - printf("\nTest OK !\n"); -} - diff --git a/kdecore/tests/kshelltest.cpp b/kdecore/tests/kshelltest.cpp deleted file mode 100644 index 394394e28..000000000 --- a/kdecore/tests/kshelltest.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include <kshell.h> - -#include <iostream> - -static QCString -ps(const TQString &s) -{ - if (s.isNull()) - return "(null)"; - else - return s.local8Bit(); -} - -static void -tx(const char *t) -{ - std::cout << t << " -> " << ps(KShell::tildeExpand(t)) << std::endl; -} - -static void -sj(const char *t, int flg) -{ - int err; - std::cout << t << " (" << flg << ") -> " << ps(KShell::joinArgsDQ(KShell::splitArgs(t, flg, &err))) << " (" << err << ")" << std::endl; -} - -int main() -{ -#if 1 - tx("~"); - tx("~/sulli"); - tx("~root"); - tx("~root/sulli"); - tx("~sulli"); -#endif -#if 1 - TQStringList lst; - lst << "this" << "is" << "text"; - std::cout << KShell::joinArgs(lst).latin1() << std::endl; -#endif -#if 1 - sj("\"~sulli\" 'text' 'jo'\"jo\" $'crap' $'\\\\\\'\\ca\\e\\x21' ha\\ lo ", KShell::NoOptions); - sj("\"~sulli\" 'text'", KShell::TildeExpand); - sj("~\"sulli\" 'text'", KShell::TildeExpand); - sj("~/\"sulli\" 'text'", KShell::TildeExpand); - sj("~ 'text' ~", KShell::TildeExpand); - sj("~sulli ~root", KShell::TildeExpand); -#endif - sj("say \" error", KShell::NoOptions); - sj("say `echo no error`", KShell::NoOptions); - sj("say \" still error", KShell::AbortOnMeta); - sj("say `echo meta error`", KShell::AbortOnMeta); - sj("BLA=say echo meta", KShell::AbortOnMeta); - sj("B\"L\"A=say FOO=bar echo meta", KShell::AbortOnMeta); -} diff --git a/kdecore/tests/ksimpleconfigtest.cpp b/kdecore/tests/ksimpleconfigtest.cpp deleted file mode 100644 index 6aa93c06d..000000000 --- a/kdecore/tests/ksimpleconfigtest.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// $Id$ - -// -// configtest.cpp: libKDEcore example -// -// demonstrates use of KSimpleConfig class - -#include <ksimpleconfig.h> -#include <kapplication.h> -#include <unistd.h> -#include <stdio.h> - -#ifdef HAVE_PATHS_H -#include <paths.h> -#endif - -#ifndef _PATH_TMP -#define _PATH_TMP "/tmp/" -#endif - -int main( int argc, char **argv ) -{ - KApplication a( argc, argv, "kconfigtest" ); - - KSimpleConfig aConfig( _PATH_TMP"/simpleconfig.cfg" ); - - aConfig.setGroup( "Test group" ); - aConfig.writeEntry( "key1", "value1" ); - aConfig.writeEntry( "key2", "value2" ); - - aConfig.setGroup( "Another Test group" ); - aConfig.writeEntry( "akey1", "avalue1" ); - aConfig.writeEntry( "akey2", "avalue2" ); - - fprintf( stderr, "entries written, sleeping for 10 seconds\n" ); - aConfig.sync(); - sleep( 10 ); - - aConfig.setGroup( "Test group" ); - aConfig.deleteEntry( "key2", false ); - fprintf( stderr, "Deleted on entry from Test group, sleeping\n" ); - aConfig.sync(); - sleep( 10 ); - - aConfig.deleteGroup( "Another Test group", true ); - fprintf( stderr, "Deleted Another Test group\n" ); -} - diff --git a/kdecore/tests/ksocktest.cpp b/kdecore/tests/ksocktest.cpp deleted file mode 100644 index 042701c93..000000000 --- a/kdecore/tests/ksocktest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 "kuniqueapplication.h" -#include "kglobal.h" -#include "kdebug.h" -#include "ksock.h" -#include "ksockaddr.h" -#include "kextsock.h" - -#include <kaboutdata.h> -#include <kcmdlineargs.h> -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <dirent.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <arpa/inet.h> -#include <netdb.h> - -bool check(TQString txt, TQString a, TQString b) -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - - -int -main(int argc, char *argv[]) -{ - KAboutData about("socktest", "SockTest", "version"); - KCmdLineArgs::init(argc, argv, &about); - KApplication::addCmdLineOptions(); - - KApplication app; - - TQString host, port; - - KInetSocketAddress host_address("213.203.58.36", 80); - - check("KInetSocketAddress(\"213.203.58.36\", 80)", host_address.pretty(), "213.203.58.36 port 80"); - - int result = KExtendedSocket::resolve(&host_address, host, port, NI_NAMEREQD); - printf( "resolve result: %d\n", result ); - check("KExtendedSocket::resolve() host=", host, "www.kde.org"); -// check("KExtendedSocket::resolve() port=", port, "http"); - TQPtrList<KAddressInfo> list; - list = KExtendedSocket::lookup("www.kde.org", "http", KExtendedSocket::inetSocket); - for(KAddressInfo *info = list.first(); info; info = list.next()) - { - qWarning("Lookup: %s %s %s", info->address()->pretty().latin1(), - info->address()->isEqual(KInetSocketAddress("213.203.58.36", 80)) ? - "is equal to" : "is NOT equal to", - "213.203.58.36 port 80"); - } - check("KExtendedSocket::lookup()", list.first()->address()->pretty(), "213.203.58.36 port 80"); - - - - int err; - - TQPtrList<KAddressInfo> cns = KExtendedSocket::lookup("www.kde.org", 0, KExtendedSocket::canonName, &err); - for (KAddressInfo *x = cns.first(); x; x = cns.next()) { - const char *canon = x->canonname(); - qWarning( "Lookup: %s", canon ? canon : "<Null>"); - } - check("KExtendedSocket::lookup() canonical", cns.first()->canonname(), "www.kde.org"); - - KExtendedSocket * sock2 = new KExtendedSocket( "www.kde.org", 80 ); - check( "KExtendedSocket ctor / connect", TQString::number( sock2->connect() ), "0" ); - - printf("FD %d\n", sock2->fd()); - - KSocketAddress* addr = KExtendedSocket::peerAddress( sock2->fd() ); - check( "peerAddress:", addr->nodeName().latin1(), "213.203.58.36" ); - - check( "isEqual:", addr->isEqual(KInetSocketAddress("213.203.58.36", 80)) ? "TRUE" : "FALSE", "TRUE"); - check( "isEqual:", addr->isEqual(KInetSocketAddress("213.203.58.36", 8080)) ? "TRUE" : "FALSE", "FALSE"); - check( "isEqual:", addr->isCoreEqual(KInetSocketAddress("213.203.58.36", 8080)) ? "TRUE" : "FALSE", "TRUE"); -} diff --git a/kdecore/tests/ksortablevaluelisttest.cpp b/kdecore/tests/ksortablevaluelisttest.cpp deleted file mode 100644 index 301054045..000000000 --- a/kdecore/tests/ksortablevaluelisttest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include <tqstring.h> -#include <ksortablevaluelist.h> - -int main( int argc, char **argv ) -{ - KSortableValueList<TQString> list; - list.insert( 1, "FOO (1)" ); - list.insert( 2, "Test (2)" ); - list.insert( 1, "Huba! (1)" ); - list.insert( 5, "MAAOOAM! (5)" ); - list.insert( 10, "Teeheeest (10)" ); - list.insert( 2, "I was here :) (2)" ); - list.insert( 4, "Yeehaa... (4)" ); - - TQValueListIterator<KSortableItem<TQString> > it = list.begin(); - - qDebug("Insertion order:"); - qDebug("================"); - for ( ; it != list.end(); ++it ) - qDebug( "%i: %s", (*it).index(), (*it).value().latin1() ); - - list.sort(); - - qDebug("\nSorted:"); - qDebug("======="); - - it = list.begin(); - for ( ; it != list.end(); ++it ) - qDebug( "%i: %s", (*it).index(), (*it).value().latin1() ); - - return 0; -} diff --git a/kdecore/tests/kstdacceltest.cpp b/kdecore/tests/kstdacceltest.cpp deleted file mode 100644 index ff8842139..000000000 --- a/kdecore/tests/kstdacceltest.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include <config.h> - -#include <kapplication.h> -#include <kdebug.h> -#include <kstdaccel.h> -#include <stdlib.h> // for exit - -static bool check(TQString txt, TQString a, TQString b) -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -int main(int argc, char *argv[]) -{ - KApplication::disableAutoDcopRegistration(); - KApplication app(argc,argv,"kstdacceltest",false,false); - - check( "shortcutDefault FullScreen", KStdAccel::shortcutDefault( KStdAccel::FullScreen ).toString(), "Ctrl+Shift+F" ); - check( "shortcutDefault BeginningOfLine", KStdAccel::shortcutDefault( KStdAccel::BeginningOfLine ).toString(), "Home" ); - check( "shortcutDefault EndOfLine", KStdAccel::shortcutDefault( KStdAccel::EndOfLine ).toString(), "End" ); - - check( "name BeginningOfLine", KStdAccel::name( KStdAccel::BeginningOfLine ), "BeginningOfLine" ); - check( "name EndOfLine", KStdAccel::name( KStdAccel::EndOfLine ), "EndOfLine" ); - - check( "shortcut method", KStdAccel::shortcut( KStdAccel::ZoomIn ).toString(), KStdAccel::zoomIn().toString() ); - - return 0; -} diff --git a/kdecore/tests/kstddirstest.cpp b/kdecore/tests/kstddirstest.cpp deleted file mode 100644 index fa797d665..000000000 --- a/kdecore/tests/kstddirstest.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include <kapplication.h> -#include <kdebug.h> -#include <kinstance.h> -#include <kstandarddirs.h> -#include <kconfig.h> - -int main(int argc, char **argv) -{ - KApplication a(argc, argv, "whatever", false); - KStandardDirs t; - KConfig config; // to add custom entries - a bit tricky :/ - - TQStringList list; - TQString s; - - t.saveLocation("icon"); - - s = t.findResource("icon", "xv.xpm"); - if (!s.isNull()) kdDebug() << s << endl; - - list = t.findAllResources("data", "kfind/toolbar", true); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - kdDebug() << "data " << (*it).ascii() << endl; - } - - list = t.findAllResources("config", "kcmdisplayrc"); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - kdDebug() << "config " << (*it).ascii() << endl; - } - - list = t.findAllResources("config", "kcmdisplayrc", false, true); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - kdDebug() << "config2 " << (*it).ascii() << endl; - } - - list = t.findAllResources("html", "en/*/index.html", false); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - kdDebug() << "docs " << (*it).ascii() << endl; - } - - list = t.findAllResources("html", "*/*/*.html", false); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - kdDebug() << "docs " << (*it).ascii() << endl; - } - - list = t.findDirs("data", "kwin"); - for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - kdDebug() << "kwin dirs " << (*it).ascii() << endl; - } - - kdDebug() << "hit " << t.findResourceDir("config", "kcmdisplayrc") << endl; -} diff --git a/kdecore/tests/kstringhandlertest.cpp b/kdecore/tests/kstringhandlertest.cpp deleted file mode 100644 index 2efdc96fc..000000000 --- a/kdecore/tests/kstringhandlertest.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "kstringhandler.h" -#include <iostream> -using std::cout; -using std::endl; - -bool check(const TQString &txt, const TQString &a, const TQString &b) -{ - if ( a != b ) { - cout << "ERROR: Tested " << txt.latin1() << ", expected" << endl; - cout << "'" << b.latin1() << "' (" << b.length() << " chars)" << endl; - cout << "but got" << endl; - cout << "'" << a.latin1() << "' (" << a.length() << " chars)" << endl; - exit( 1 ); - } - return true; -} - -int main(int argc, char *argv[]) -{ - TQString test = "The quick brown fox jumped over the lazy bridge. "; - - check("word(test, 3)", - KStringHandler::word(test, 2), - "brown"); - check("word(test, \"3:5\")", - KStringHandler::word(test, "2:4"), - "brown fox jumped"); - check("insword(test, \"very\", 1)", - KStringHandler::insword(test, "very", 1), - "The very quick brown fox jumped over the lazy bridge. "); - check("setword(test, \"very\", 1)", - KStringHandler::setword(test, "very", 1), - "The very brown fox jumped over the lazy bridge. "); - check("remrange(test, \"4:6\")", - KStringHandler::remrange(test, "4:6"), - "The quick brown fox lazy bridge. " ); - check("remrange(test, \"4:8\")", - KStringHandler::remrange(test, "4:8"), - "The quick brown fox "); - check("remword(test, 4)", - KStringHandler::remword(test, 4), - "The quick brown fox over the lazy bridge. "); - check("remword(test, \"lazy\")", - KStringHandler::remword(test, "lazy"), - "The quick brown fox jumped over the bridge. "); - check("capwords(test)", - KStringHandler::capwords(test), - "The Quick Brown Fox Jumped Over The Lazy Bridge. "); - check("reverse(test)", - KStringHandler::reverse(test), - " bridge. lazy the over jumped fox brown quick The"); - TQString result; - result = KStringHandler::ljust(test, 70); - if (result.length() != 70) - { - printf("Length = %d, expected 70.\n", result.length()); - exit(1); - } - check("ljust(test, 70)", - result, - "The quick brown fox jumped over the lazy bridge. "); - result = KStringHandler::rjust(test, 70); - if (result.length() != 70) - { - printf("Length = %d, expected 70.\n", result.length()); - exit(1); - } - check("rjust(test, 70)", - result, - " The quick brown fox jumped over the lazy bridge."); - result = KStringHandler::center(test, 70); - if (result.length() != 70) - { - printf("Length = %d, expected 70.\n", result.length()); - exit(1); - } - check("center(test, 70)", - result, - " The quick brown fox jumped over the lazy bridge. "); - - test = "Click on http://foo@bar:www.kde.org/yoyo/dyne.html#a1 for info."; - check( "tagURLs()", KStringHandler::tagURLs( test ), - "Click on <a href=\"http://foo@bar:www.kde.org/yoyo/dyne.html#a1\">http://foo@bar:www.kde.org/yoyo/dyne.html#a1</a> for info." ); - - test = "http://www.foo.org/story$806"; - check( "tagURLs()", KStringHandler::tagURLs( test ), - "<a href=\"http://www.foo.org/story$806\">http://www.foo.org/story$806</a>" ); - -#if 0 - // XFAIL - i.e. this needs to be fixed, but has never been - test = "<a href=www.foo.com>"; - check( "tagURLs()", KStringHandler::tagURLs( test ), - "<a href=<a href=\"www.foo.com\">www.foo.com</a>>" ); -#endif - - cout << "All OK!" << endl; -} diff --git a/kdecore/tests/ktempfiletest.cpp b/kdecore/tests/ktempfiletest.cpp deleted file mode 100644 index 60404f03a..000000000 --- a/kdecore/tests/ktempfiletest.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 "ktempfile.h" -#include "kapplication.h" -#include "kstandarddirs.h" -#include <tqstring.h> - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> - -int -main(int argc, char *argv[]) -{ - KApplication a(argc, argv, "ktempfiletest"); - printf("Making tempfile after KApplication constructor.\n"); - KTempFile f4; - printf("Filename = %s\n", f4.name().ascii()); - - printf("Making tempfile with \".ps\" extension.\n"); - KTempFile f2(TQString::null, ".ps"); - printf("Filename = %s\n", f2.name().ascii()); - - printf("Making tempfile in home directory.\n"); - KTempFile f3(TQString((const char *)getenv("HOME"))+"/testXXX", ".myEXT", 0666); - printf("Filename = %s\n", f3.name().ascii()); - - TQString name = locateLocal("socket", "test"); - printf("Socket Filename = %s\n", name.ascii()); - - printf("Done.\n"); -} diff --git a/kdecore/tests/ktimezonestest.cpp b/kdecore/tests/ktimezonestest.cpp deleted file mode 100644 index 69ea7c8a1..000000000 --- a/kdecore/tests/ktimezonestest.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "ktimezones.h" -#include <kapplication.h> -#include <stdio.h> -#include <stdlib.h> - -int main(int argc, char *argv[]) -{ - KInstance instance("ktimezonestest"); - - if ((argc==2) && (strcmp(argv[1], "local")==0)) - { - KTimezones timezones; - - // Find the local timezone. - const KTimezone *timezone = timezones.local(); - printf( "Local timezone: %s\n", timezone->name().latin1() ); - - // Find the current offset of the UTC timezone. - timezone = timezones.zone("UTC"); - printf( "UTC timezone offset should be 0: %d\n", timezone->offset(TQDateTime::tqcurrentDateTime()) ); - - // Find some offsets for Europe/London. - char *london = "Europe/London"; - timezone = timezones.zone(london); - TQDateTime winter(TQDateTime::fromString("2005-01-01T00:00:00", Qt::ISODate)); - TQDateTime summer(TQDateTime::fromString("2005-06-01T00:00:00", Qt::ISODate)); - printf( "%s winter timezone offset should be 0: %d\n", london, timezone->offset(winter) ); - printf( "%s summer timezone offset should be 3600: %d\n", london, timezone->offset(summer) ); - - // Try timezone conversions. - const KTimezone *losAngeles = timezones.zone("America/Los_Angeles"); - char *bstBeforePdt = "2005-03-28T00:00:00"; - char *bstAfterPdt = "2005-05-01T00:00:00"; - char *gmtBeforePst = "2005-10-30T01:00:00"; - char *gmtAfterPst = "2005-12-01T00:00:00"; - TQString result; - result = timezone->convert(losAngeles, TQDateTime::fromString(bstBeforePdt, Qt::ISODate)).toString(Qt::ISODate); - printf( "BST before PDT, %s should be 2005-03-27T15:00:00: %s\n", bstBeforePdt, result.latin1() ); - result = timezone->convert(losAngeles, TQDateTime::fromString(bstAfterPdt, Qt::ISODate)).toString(Qt::ISODate); - printf( "BST and PDT, %s should be 2005-04-30T16:00:00: %s\n", bstAfterPdt, result.latin1() ); - result = timezone->convert(losAngeles, TQDateTime::fromString(gmtBeforePst, Qt::ISODate)).toString(Qt::ISODate); - printf( "GMT before PST, %s should be 2005-10-29T17:00:00: %s\n", gmtBeforePst, result.latin1() ); - result = timezone->convert(losAngeles, TQDateTime::fromString(gmtAfterPst, Qt::ISODate)).toString(Qt::ISODate); - printf( "GMT and PST, %s should be 2005-11-30T16:00:00: %s\n", gmtAfterPst, result.latin1() ); - printf( "Latitude 89 should be valid: %svalid\n", KTimezone::isValidLatitude(89.0) ? "" : "in"); - printf( "Latitude 91 should be invalid: %svalid\n", KTimezone::isValidLatitude(91.0) ? "" : "in"); - printf( "Longitude 179 should be valid: %svalid\n", KTimezone::isValidLongitude(179.0) ? "" : "in"); - printf( "Longitude 181 should be valid: %svalid\n", KTimezone::isValidLongitude(181.0) ? "" : "in"); - return 0; - } - - if ((argc==2) && (strcmp(argv[1], "all")==0)) - { - KTimezones timezones; - KTimezones::ZoneMap allZones = timezones.allZones(); - for ( KTimezones::ZoneMap::const_iterator it = allZones.begin(), end = allZones.end(); it != end; ++it ) - printf( "%s\n", it.key().latin1() ); - } - - printf( "Usage: ktimezonestest [local|all]!\n" ); - return 1; -} diff --git a/kdecore/tests/kuniqueapptest.cpp b/kdecore/tests/kuniqueapptest.cpp deleted file mode 100644 index 699c99539..000000000 --- a/kdecore/tests/kuniqueapptest.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 "kuniqueapplication.h" -#include "kglobalsettings.h" - -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <kcmdlineargs.h> -#include <kaboutdata.h> - -class TestApp : public KUniqueApplication -{ -public: - TestApp() : KUniqueApplication("TestApp") { } - virtual int newInstance( ); -}; - - -int -TestApp::newInstance( ) -{ - qWarning("NewInstance"); - return 0; -} - -int -main(int argc, char *argv[]) -{ - KAboutData about("kuniqueapptest", "kuniqueapptest", "version"); - KCmdLineArgs::init(argc, argv, &about); - KUniqueApplication::addCmdLineOptions(); - - if (!TestApp::start()) - { - exit(0); - } - TestApp a; - - printf("Running.\n"); - kapp->exec(); - printf("Terminating.\n"); -} diff --git a/kdecore/tests/kurltest.cpp b/kdecore/tests/kurltest.cpp deleted file mode 100644 index c8e5bcced..000000000 --- a/kdecore/tests/kurltest.cpp +++ /dev/null @@ -1,1124 +0,0 @@ -#include <config.h> - -#include <kurl.h> -#include <stdio.h> -#include <kapplication.h> -#include <stdlib.h> -#include <kdebug.h> -#include <kglobal.h> -#include <kcharsets.h> -#include <tqtextcodec.h> -#include <tqdatastream.h> -#include <assert.h> -#include <kcmdlineargs.h> - -static bool check(TQString txt, TQString a, TQString b) -{ - if (a.isEmpty()) - a = TQString::null; - if (b.isEmpty()) - b = TQString::null; - if (a == b) { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; - } - else { - kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; - exit(1); - } - return true; -} - -void testAdjustPath() -{ - KURL url1("file:///home/kde/"); - url1.adjustPath(0); - check( "adjustPath(0)", url1.path(), "/home/kde/" ); - url1.adjustPath(-1); - check( "adjustPath(-1) removes last slash", url1.path(), "/home/kde" ); - url1.adjustPath(-1); - check( "adjustPath(-1) again", url1.path(), "/home/kde" ); - url1.adjustPath(1); - check( "adjustPath(1)", url1.path(), "/home/kde/" ); - - KURL url2("file:///home/kde//"); - url2.adjustPath(0); - check( "adjustPath(0)", url2.path(), "/home/kde//" ); - url2.adjustPath(-1); - check( "adjustPath(-1) removes all trailing slashes", url2.path(), "/home/kde" ); - url2.adjustPath(1); - check( "adjustPath(1)", url2.path(), "/home/kde/" ); - - KURL ftpurl1("ftp://ftp.kde.org/"); - ftpurl1.adjustPath(0); - check( "adjustPath(0)", ftpurl1.path(), "/" ); - ftpurl1.adjustPath(-1); - check( "adjustPath(-1) preserves last slash", ftpurl1.path(), "/" ); - - KURL ftpurl2("ftp://ftp.kde.org///"); - ftpurl2.adjustPath(0); - check( "adjustPath(0)", ftpurl2.path(), "///" ); - ftpurl2.adjustPath(-1); - check( "adjustPath(-1) removes all but last slash", ftpurl2.path(), "/" ); - ftpurl2.adjustPath(1); - check( "adjustPath(1)", ftpurl2.path(), "/" ); - - // Equivalent tests written by the KDirLister maintainer :) - - KURL u3( TQCString("ftp://brade@ftp.kde.org///") ); - u3.adjustPath(-1); - check("KURL::adjustPath()", u3.url(), "ftp://brade@ftp.kde.org/"); - - KURL u4( TQCString("ftp://brade@ftp.kde.org/kde///") ); - u4.adjustPath(-1); - check("KURL::adjustPath()", u4.url(), "ftp://brade@ftp.kde.org/kde"); - - // applying adjustPath(-1) twice should not yield two different urls - // (follows from the above test) - KURL u5 = u4; - u5.adjustPath(-1); - check("KURL::adjustPath()", u5.url(), u4.url()); -} - -int main(int argc, char *argv[]) -{ - KApplication::disableAutoDcopRegistration(); - KCmdLineArgs::init( argc, argv, "kurltest", 0, 0, 0, 0 ); - KApplication app( false, false ); - - KURL::List lst; - - KURL emptyURL; - check( "KURL::isMalformed()", emptyURL.isMalformed() ? "TRUE":"FALSE", "TRUE"); - check( "KURL::isValid()", emptyURL.isValid() ? "TRUE":"FALSE", "FALSE"); - check( "KURL::isEmpty()", emptyURL.isEmpty() ? "TRUE":"FALSE", "TRUE"); - check( "prettyURL()", emptyURL.prettyURL(), ""); - check( "isLocalFile()", emptyURL.isLocalFile()?"TRUE":"FALSE", "FALSE" ); - - emptyURL = ""; - check( "KURL::isMalformed()", emptyURL.isMalformed() ? "TRUE":"FALSE", "TRUE"); - check( "KURL::isValid()", emptyURL.isValid() ? "TRUE":"FALSE", "FALSE"); - check( "KURL::isEmpty()", emptyURL.isEmpty() ? "TRUE":"FALSE", "TRUE"); - - KURL fileURL = "file:/"; - check( "KURL::isEmpty()", fileURL.isEmpty() ? "TRUE":"FALSE", "FALSE"); - - fileURL = "file:///"; - check( "KURL::isEmpty()", fileURL.isEmpty() ? "TRUE":"FALSE", "FALSE"); - - KURL baseURL ("hTTp://www.foo.bar:80" ); - check( "KURL::isValid()", baseURL.isValid() ? "TRUE":"FALSE", "TRUE"); - check( "KURL::protocol()", baseURL.protocol(), "http"); // lowercase - KURL url1 ( baseURL, "//www1.foo.bar" ); - check( "KURL::host()", url1.host(), "www1.foo.bar"); - check( "KURL::url()", url1.url(), "http://www1.foo.bar"); - - baseURL = "http://www.Abc.de"; - check( "KURL::host() is lowercase", baseURL.host(), "www.abc.de"); - baseURL = "donkey://Abc/DE"; - check( "KURL::host() is lowercase", baseURL.host(), "abc"); - - baseURL = "http://www.foo.bar"; - KURL rel_url( baseURL, "/top//test/../test1/file.html" ); - check( "KURL::url()", rel_url.url(), "http://www.foo.bar/top//test1/file.html" ); - - - baseURL = "http://www.foo.bar/top//test2/file2.html"; - check( "KURL::url()", baseURL.url(), "http://www.foo.bar/top//test2/file2.html" ); - - baseURL = "file:/usr/local/src/kde2/////kdelibs/kio"; - check( "KURL::url()", baseURL.url(), "file:///usr/local/src/kde2/////kdelibs/kio" ); - - baseURL = "http://www.foo.bar"; - KURL rel_url2( baseURL, "mailto:bastian@kde.org" ); - check( "KURL::url()", rel_url2.url(), "mailto:bastian@kde.org" ); - - baseURL = "mailto:bastian@kde.org?subject=hello"; - check( "KURL::url()", baseURL.url(), "mailto:bastian@kde.org?subject=hello" ); - - baseURL = "file:/usr/local/src/kde2/kdelibs/kio/"; - KURL url2( baseURL, "../../////kdebase/konqueror" ); - check( "KURL::url()", url2.url(), "file:///usr/local/src/kde2/////kdebase/konqueror" ); - - TQString u1 = "file:/home/dfaure/my#myref"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my#myref"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::htmlRef()", url1.htmlRef(), "myref"); - check("KURL::upURL()", url1.upURL().url(), "file:///home/dfaure/"); - - u1 = "file:/home/dfaure/my#%2f"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my#%2f"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::encodedHtmlRef()", url1.ref(), "%2f"); - check("KURL::htmlRef()", url1.htmlRef(), "/"); - - url1 = KURL(url1, "#%6a"); - check("KURL::url()", url1.url(), "file:///home/dfaure/my#%6a"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::encodedHtmlRef()", url1.ref(), "%6a"); - check("KURL::htmlRef()", url1.htmlRef(), "j"); - - KURL dxOffEagle( KURL("http://something/other.html"), "newpage.html?[{\"foo: bar\"}]" ); - check("isValid", dxOffEagle.isValid() ? "OK" : "KO", "OK"); - check("url", dxOffEagle.url(), TQString("http://something/newpage.html?[{\"foo:%20bar\"}]") ); - - KURL javascript( KURL("javascript:window.location+\"__flashplugin_unique__\"") ); - check("isValid", javascript.isValid() ? "OK" : "KO", "OK"); - check("url", javascript.url(), TQString("javascript:window.location+\"__flashplugin_unique__\"") ); - - - u1 = "file:///home/dfaure/my#myref"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my#myref"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::htmlRef()", url1.htmlRef(), "myref"); - check("KURL::upURL()", url1.upURL().url(), "file:///home/dfaure/"); - - url1 = "gg:www.kde.org"; - check("KURL::isValid()", url1.isValid()?"TRUE":"FALSE", "TRUE" ); - - url1= "KDE"; - check("KURL::isValid()", url1.isValid()?"TRUE":"FALSE", "FALSE" ); - - url1= "$HOME/.kde/share/config"; - check("KURL::isValid()", url1.isValid()?"TRUE":"FALSE", "FALSE" ); - - u1 = "file:/opt/kde2/qt2/doc/html/showimg-main-cpp.html#TQObject::connect"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///opt/kde2/qt2/doc/html/showimg-main-cpp.html#TQObject::connect"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::htmlRef()", url1.htmlRef(), "TQObject::connect"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::upURL()", url1.upURL().url(), "file:///opt/kde2/qt2/doc/html/"); - - url1 = KURL( TQCString( "http://www.kde.org/foo.cgi?foo=bar" ) ); - check("query", url1.query(), "?foo=bar" ); - url1.setQuery( "toto=titi&kde=rocks" ); - check("query", url1.query(), "?toto=titi&kde=rocks" ); - url1.setQuery( "?kde=rocks&a=b" ); - check("query", url1.query(), "?kde=rocks&a=b" ); - url1.setQuery( "?" ); - check("setQuery(\"?\") -> query", url1.query(), "?" ); - url1.setQuery( "" ); - check("setQuery(\"\") -> query", url1.query(), "?" ); - url1.setQuery( TQString::null ); - check("setQuery(TQString::null) -> query", url1.query(), TQString::null ); - - u1 = "file:///opt/kde2/qt2/doc/html/showimg-main-cpp.html#TQObject::connect"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///opt/kde2/qt2/doc/html/showimg-main-cpp.html#TQObject::connect"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::htmlRef()", url1.htmlRef(), "TQObject::connect"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::upURL()", url1.upURL().url(), "file:///opt/kde2/qt2/doc/html/"); - - u1 = "file:/opt/kde2/qt2/doc/html/showimg-main-cpp.html#TQObject:connect"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///opt/kde2/qt2/doc/html/showimg-main-cpp.html#TQObject:connect"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::htmlRef()", url1.htmlRef(), "TQObject:connect"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "no"); - check("KURL::upURL()", url1.upURL().url(), "file:///opt/kde2/qt2/doc/html/"); - - u1 = "file:/home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/#myref"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/#myref"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::isLocalFile()", url1.isLocalFile() ? "yes" : "no", "no"); // Not strictly local! - //check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "yes"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "yes"); - //check("KURL::htmlRef()", url1.htmlRef(), "myref"); - check("KURL::upURL()", url1.upURL().url(), "file:///home/dfaure/"); - - u1 = "error:/?error=14&errText=Unknown%20host%20asdfu.adgi.sdfgoi#http://asdfu.adgi.sdfgoi"; - url1 = u1; - check("KURL::url()", url1.url(), "error:/?error=14&errText=Unknown%20host%20asdfu.adgi.sdfgoi#http://asdfu.adgi.sdfgoi"); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "yes"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::isLocalFile()", url1.isLocalFile() ? "yes" : "no", "no"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "no"); - //check("KURL::htmlRef()", url1.htmlRef(), "myref"); - - u1 = "file:/home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "no"); - check("KURL::htmlRef()", url1.htmlRef(), ""); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "yes"); - check("KURL::upURL()", url1.upURL().url(), "file:///home/dfaure/"); - - u1 = "file:///home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "no"); - check("KURL::htmlRef()", url1.htmlRef(), ""); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "yes"); - check("KURL::upURL()", url1.upURL().url(), "file:///home/dfaure/"); - -#if 0 -// This URL is broken, '#' should be escaped. - u1 = "file:/home/dfaure/cdrdao-1.1.5/dao/#CdrDriver.cc#"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/cdrdao-1.1.5/dao/#CdrDriver.cc#"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "no"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "no"); - check("KURL::htmlRef()", url1.htmlRef(), ""); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "yes"); - check("KURL::prettyURL()", url1.upURL().url(), "file:///home/dfaure/cdrdao-1.1.5/dao/#CdrDriver.cc#"); -#endif - - u1 = "file:/home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/README"; - url1 = u1; - check("KURL::url()", url1.url(), "file:///home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/README"); - check("KURL::hasRef()", url1.hasRef() ? "yes" : "no", "yes"); - check("KURL::hasHTMLRef()", url1.hasHTMLRef() ? "yes" : "no", "no"); - check("KURL::htmlRef()", url1.htmlRef(), ""); - check("KURL::hasSubURL()", url1.hasSubURL() ? "yes" : "no", "yes"); - check("KURL::upURL()", url1.upURL().url(), "file:///home/dfaure/my%20tar%20file.tgz#gzip:/#tar:/"); - - KURL notPretty("http://ferret.lmh.ox.ac.uk/%7Ekdecvs/"); - check("KURL::prettyURL()", notPretty.prettyURL(), "http://ferret.lmh.ox.ac.uk/~kdecvs/"); - KURL notPretty2("file:/home/test/directory%20with%20spaces"); - check("KURL::prettyURL()", notPretty2.prettyURL(), "file:///home/test/directory with spaces"); - KURL notPretty3("fish://foo/%23README%23"); - check("KURL::prettyURL()", notPretty3.prettyURL(), "fish://foo/%23README%23"); - KURL url15581("http://alain.knaff.linux.lu/bug-reports/kde/spaces in url.html"); - check("KURL::prettyURL()", url15581.prettyURL(), "http://alain.knaff.linux.lu/bug-reports/kde/spaces in url.html"); - check("KURL::url()", url15581.url(), "http://alain.knaff.linux.lu/bug-reports/kde/spaces%20in%20url.html"); - KURL url15582("http://alain.knaff.linux.lu/bug-reports/kde/percentage%in%url.html"); - check("KURL::prettyURL()", url15582.prettyURL(), "http://alain.knaff.linux.lu/bug-reports/kde/percentage%in%url.html"); - check("KURL::url()", url15582.url(), "http://alain.knaff.linux.lu/bug-reports/kde/percentage%25in%25url.html"); - - KURL longUserName("http://thisisaverylongusername@foobar.com/"); - check("KURL::prettyURL()", longUserName.prettyURL(), "http://thisisaverylongusername@foobar.com/"); - check("KURL(KURL::prettyURL())", KURL(longUserName.prettyURL()).url(), "http://thisisaverylongusername@foobar.com/"); - - KURL whitespaceInUser("http://google.com%20%20%20@foobar.com/"); - check("KURL::prettyURL()", whitespaceInUser.prettyURL(), "http://google.com%20%20%20@foobar.com/"); - - KURL whitespaceInPath("http://www.google.com/foo%20bar/"); - check("KURL::prettyURL()", whitespaceInPath.prettyURL(), "http://www.google.com/foo bar/"); - - KURL whitespaceInPath2("http://www.google.com/foo%20%20%20%20%20%20%20bar/"); - check("KURL::prettyURL()", whitespaceInPath2.prettyURL(), - "http://www.google.com/foo%20%20%20%20%20%20 bar/"); - - KURL carsten; - carsten.setPath("/home/gis/src/kde/kdelibs/kfile/.#kfiledetailview.cpp.1.18"); - check("KURL::path()", carsten.path(), "/home/gis/src/kde/kdelibs/kfile/.#kfiledetailview.cpp.1.18"); - - KURL charles; - charles.setPath( "/home/charles/foo%20moo" ); - check("KURL::path()", charles.path(), "/home/charles/foo%20moo"); - KURL charles2("file:/home/charles/foo%20moo"); - check("KURL::path()", charles2.path(), "/home/charles/foo moo"); - - KURL udir; - printf("\n* Empty URL\n"); - check("KURL::url()", udir.url(), TQString::null); - check("KURL::isEmpty()", udir.isEmpty() ? "ok" : "ko", "ok"); - check("KURL::isValid()", udir.isValid() ? "ok" : "ko", "ko"); - udir = udir.upURL(); - check("KURL::upURL()", udir.upURL().isEmpty() ? "ok" : "ko", "ok"); - - udir.setPath("/home/dfaure/file.txt"); - printf("\n* URL is %s\n",udir.url().ascii()); - check("KURL::path()", udir.path(), "/home/dfaure/file.txt"); - check("KURL::url()", udir.url(), "file:///home/dfaure/file.txt"); - check("KURL::directory(false,false)", udir.directory(false,false), "/home/dfaure/"); - check("KURL::directory(true,false)", udir.directory(true,false), "/home/dfaure"); - - KURL u2( TQCString("/home/dfaure/") ); - printf("\n* URL is %s\n",u2.url().ascii()); - // not ignoring trailing slash - check("KURL::directory(false,false)", u2.directory(false,false), "/home/dfaure/"); - check("KURL::directory(true,false)", u2.directory(true,false), "/home/dfaure"); - // ignoring trailing slash - check("KURL::directory(false,true)", u2.directory(false,true), "/home/"); - check("KURL::directory(true,true)", u2.directory(true,true), "/home"); - - // cleanPath() tests (before cd() since cd uses that) - u2.cleanPath(); - check("cleanPath(false)", u2.url(), "file:///home/dfaure/"); - u2.addPath( "/..//foo" ); - check("addPath", u2.url(), "file:///home/dfaure/..//foo"); - u2.cleanPath(false); - check("cleanPath()", u2.url(), "file:///home//foo"); - u2.cleanPath(true); - check("cleanPath()", u2.url(), "file:///home/foo"); - - u2.cd(".."); - check("KURL::cd(\"..\")", u2.url(), "file:///home"); - u2.cd("thomas"); - check("KURL::cd(\"thomas\")", u2.url(), "file:///home/thomas"); - u2.cd("../"); - check("KURL::cd(\"../\")", u2.url(), "file:///home/"); - u2.cd("/opt/kde/bin/"); - check("KURL::cd(\"/opt/kde/bin/\")", u2.url(), "file:///opt/kde/bin/"); - u2 = "ftp://ftp.kde.org/"; - printf("\n* URL is %s\n",u2.url().ascii()); - u2.cd("pub"); - check("KURL::cd(\"pub\")", u2.url(), "ftp://ftp.kde.org/pub"); - u2 = u2.upURL(); - check("KURL::upURL()", u2.url(), "ftp://ftp.kde.org/"); - u2 = u1; - printf("\n* URL is %s\n",u2.url().ascii()); - // setFileName - u2.setFileName( "myfile.txt" ); - check("KURL::setFileName()", u2.url(), "file:///home/dfaure/myfile.txt"); - u2.setFileName( "myotherfile.txt" ); - check("KURL::setFileName()", u2.url(), "file:///home/dfaure/myotherfile.txt"); - // more tricky, renaming a directory (kpropsdlg.cc, line ~ 238) - TQString tmpurl = "file:/home/dfaure/myolddir/"; - if ( tmpurl.tqat(tmpurl.length() - 1) == '/') - // It's a directory, so strip the trailing slash first - tmpurl.truncate( tmpurl.length() - 1); - KURL newUrl = tmpurl; - newUrl.setFileName( "mynewdir" ); - check("KURL::setFileName() special", newUrl.url(), "file:///home/dfaure/mynewdir"); - // addPath tests - newUrl.addPath( "subdir" ); - check("KURL::addPath(\"subdir\")", newUrl.url(), "file:///home/dfaure/mynewdir/subdir"); - newUrl.addPath( "/foo/" ); - check("KURL::addPath(\"/foo/\")", newUrl.url(), "file:///home/dfaure/mynewdir/subdir/foo/"); - u2 = "http://www.kde.org"; // no path - u2.addPath( "subdir" ); - check("KURL::addPath(\"subdir\")", u2.url(), "http://www.kde.org/subdir"); - u2.addPath( "" ); - check("KURL::addPath(\"subdir\")", u2.url(), "http://www.kde.org/subdir"); // unchanged - - // even more tricky - u2 = "print:/specials/Print%20To%20File%20(PDF%2FAcrobat)"; - printf("\n* URL is %s\n",u2.url().ascii()); - check("KURL::path()", u2.path(), "/specials/Print To File (PDF/Acrobat)"); - check("KURL::fileName()", u2.fileName(), "Print To File (PDF/Acrobat)"); - u2.setFileName( "" ); - check("KURL::setFileName()", u2.url(), "print:/specials/"); - - u2 = "file:/specials/Print"; - printf("\n* URL is %s\n",u2.url().ascii()); - check("KURL::path()", u2.path(), "/specials/Print"); - check("KURL::fileName()", u2.fileName(), "Print"); - u2.setFileName( "" ); - check("KURL::setFileName()", u2.url(), "file:///specials/"); - - const char * u6 = "ftp://host/dir1/dir2/myfile.txt"; - printf("\n* URL is %s\n",u6); - check("KURL::hasSubURL()", KURL(u6).hasSubURL() ? "yes" : "no", "no"); - lst.clear(); - lst = KURL::split( KURL(u6) ); - check("KURL::split()", lst.count()==1 ? "1" : "error", "1"); - check("KURL::split()", lst.first().url(), "ftp://host/dir1/dir2/myfile.txt"); - // cdUp code - KURL lastUrl = lst.last(); - TQString dir = lastUrl.directory( true, true ); - check( "KURL::directory(true,true)", dir, "/dir1/dir2"); - - /// Comparisons - TQString ucmp1 = "ftp://ftp.de.kde.org/dir"; - TQString ucmp2 = "ftp://ftp.de.kde.org/dir/"; - check("urlcmp(only slash difference)", urlcmp(ucmp1,ucmp2)?"ko":"ok","ok"); - check("urlcmp(only slash difference, ignore_trailing)", urlcmp(ucmp1,ucmp2,true,false)?"ok":"ko","ok"); - TQString ucmp3 = "ftp://ftp.de.kde.org/dir/#"; - check("urlcmp(only hash difference)", urlcmp(ucmp2,ucmp3)?"ko":"ok","ok"); - check("urlcmp(only hash difference, ignore_ref)", urlcmp(ucmp2,ucmp3,false,true)?"ok":"ko","ok"); - check("urlcmp(slash and hash difference, ignore_trailing, ignore_ref)", urlcmp(ucmp2,ucmp3,true,true)?"ok":"ko","ok"); - check("urlcmp(empty, empty)", urlcmp("","",false,true)?"ok":"ko","ok"); - check("urlcmp(empty, empty)", urlcmp("","")?"ok":"ko","ok"); - check("urlcmp(empty, not empty)", urlcmp("",ucmp1)?"ok":"ko","ko"); - check("urlcmp(empty, not empty)", urlcmp("",ucmp1,false,true)?"ok":"ko","ko"); - check("urlcmp(malformed, not empty)", urlcmp("file",ucmp1)?"ok":"ko","ko"); - check("urlcmp(malformed, not empty)", urlcmp("file",ucmp1,false,true)?"ok":"ko","ko"); - - KURL ftpUrl ( "ftp://ftp.de.kde.org" ); - printf("\n* URL is %s\n",ftpUrl.url().latin1()); - check("KURL::path()", ftpUrl.path(), TQString::null); - ftpUrl = "ftp://ftp.de.kde.org/"; - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp.de.kde.org/host/subdir/") ? "yes" : "no", "yes"); - ftpUrl = "ftp://ftp/host/subdir/"; - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp/host/subdir/") ? "yes" : "no", "yes"); - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp/host/subdir") ? "yes" : "no", "yes"); - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp/host/subdi") ? "yes" : "no", "no"); - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp/host/subdir/blah/") ? "yes" : "no", "yes"); - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp/blah/subdir") ? "yes" : "no", "no"); - check("KURL::isParentOf()", ftpUrl.isParentOf( "file:////ftp/host/subdir/") ? "yes" : "no", "no"); - check("KURL::isParentOf()", ftpUrl.isParentOf( "ftp://ftp/host/subdir/subsub") ? "yes" : "no", "yes"); - - // WABA: The following tests are to test the handling of relative URLs as - // found on web-pages. - - KURL waba1( "http://www.website.com/directory/?hello#ref" ); - { - KURL waba2( waba1, "relative.html"); - check("http: Relative URL, single file", waba2.url(), "http://www.website.com/directory/relative.html"); - } - { - KURL waba2( waba1, "../relative.html"); - check("http: Relative URL, single file, directory up", waba2.url(), "http://www.website.com/relative.html"); - } - { - KURL waba2( waba1, "down/relative.html"); - check("http: Relative URL, single file, directory down", waba2.url(), "http://www.website.com/directory/down/relative.html"); - } - { - KURL waba2( waba1, "/down/relative.html"); - check("http: Relative URL, full path", waba2.url(), "http://www.website.com/down/relative.html"); - } - { - KURL waba2( waba1, "//www.kde.org/relative.html"); - check("http: Relative URL, with host", waba2.url(), "http://www.kde.org/relative.html"); - } - { - KURL waba2( waba1, "relative.html?query=test&name=harry"); - check("http: Relative URL, with query", waba2.url(), "http://www.website.com/directory/relative.html?query=test&name=harry"); - waba2.removeQueryItem("query"); - check("http: Removing query item", waba2.url(), "http://www.website.com/directory/relative.html?name=harry"); - waba2.addQueryItem("age", "18"); - check("http: Adding query item", waba2.url(), "http://www.website.com/directory/relative.html?name=harry&age=18"); - waba2.addQueryItem("age", "21"); - check("http: Adding query item", waba2.url(), "http://www.website.com/directory/relative.html?name=harry&age=18&age=21"); - waba2.addQueryItem("fullname", "Harry Potter"); - check("http: Adding query item", waba2.url(), "http://www.website.com/directory/relative.html?name=harry&age=18&age=21&fullname=Harry%20Potter"); - } - { - KURL waba2( waba1, "?query=test&name=harry"); - check("http: Relative URL, with query and no filename", waba2.url(), "http://www.website.com/directory/?query=test&name=harry"); - } - { - KURL waba2( waba1, "relative.html#with_reference"); - check("http: Relative URL, with reference", waba2.url(), "http://www.website.com/directory/relative.html#with_reference"); - } - { - KURL waba2( waba1, "#"); - check("http: Relative URL, with empty reference", waba2.url(), "http://www.website.com/directory/?hello#"); - } - { - KURL waba2( waba1, ""); - check("http: Empty relative URL", waba2.url(), "http://www.website.com/directory/?hello#ref"); - } - { - KURL base( "http://faure@www.kde.org" ); // no path - KURL waba2( base, "filename.html"); - check("http: Relative URL, orig URL had no path", waba2.url(), "http://faure@www.kde.org/filename.html"); - } - { - KURL base( "http://faure:pass@www.kde.org:81?query" ); - KURL rel1( base, "http://www.kde.org/bleh/"); // same host - check("http: Relative URL, orig URL had username", rel1.url(), "http://faure:pass@www.kde.org/bleh/"); - KURL rel2( base, "http://www.yahoo.org"); // different host - check("http: Relative URL, orig URL had username", rel2.url(), "http://www.yahoo.org"); - } - - waba1 = "http://www.website.com/directory/filename?bla#blub"; - { - KURL waba2( waba1, "relative.html"); - check("http: Relative URL, single file", waba2.url(), "http://www.website.com/directory/relative.html"); - } - { - KURL waba2( waba1, "../relative.html"); - check("http: Relative URL, single file, directory up", waba2.url(), "http://www.website.com/relative.html"); - } - { - KURL waba2( waba1, "down/relative.html"); - check("http: Relative URL, single file, directory down", waba2.url(), "http://www.website.com/directory/down/relative.html"); - } - { - KURL waba2( waba1, "/down/relative.html"); - check("http: Relative URL, full path", waba2.url(), "http://www.website.com/down/relative.html"); - } - { - KURL waba2( waba1, "relative.html?query=test&name=harry"); - check("http: Relative URL, with query", waba2.url(), "http://www.website.com/directory/relative.html?query=test&name=harry"); - } - { - KURL waba2( waba1, "?query=test&name=harry"); - check("http: Relative URL, with query and no filename", waba2.url(), "http://www.website.com/directory/filename?query=test&name=harry"); - } - { - KURL waba2( waba1, "relative.html#with_reference"); - check("http: Relative URL, with reference", waba2.url(), "http://www.website.com/directory/relative.html#with_reference"); - } - { - KURL waba2( waba1, "http:/relative.html"); // "rfc 1606 loophole" - check("http: Strange relative URL", waba2.url(), "http://www.website.com/relative.html"); - } - waba1.setUser("waldo"); - check("http: Set user", waba1.url(), "http://waldo@www.website.com/directory/filename?bla#blub"); - waba1.setUser("waldo/bastian"); - check("http: Set user with slash in it", waba1.url(), "http://waldo%2Fbastian@www.website.com/directory/filename?bla#blub"); - waba1.setRef( TQString::null ); - waba1.setPass( "pass" ); - waba1.setDirectory( "/foo" ); - waba1.setProtocol( "https" ); - waba1.setHost( "web.com" ); - waba1.setPort( 881 ); - check("http: setRef/setPass/setDirectory/setHost/setPort", waba1.url(), "https://waldo%2Fbastian:pass@web.com:881/foo/?bla"); - waba1.setDirectory( "/foo/" ); - check("http: setDirectory #2", waba1.url(), "https://waldo%2Fbastian:pass@web.com:881/foo/?bla"); - - // Empty queries should be preserved! - waba1 = "http://www.kde.org/cgi/test.cgi?"; - check("http: URL with empty query string", waba1.url(), - "http://www.kde.org/cgi/test.cgi?"); - - // Empty references should be preserved - waba1 = "http://www.kde.org/cgi/test.cgi#"; - check("http: URL with empty reference string", waba1.url(), - "http://www.kde.org/cgi/test.cgi#"); - check("hasRef()", waba1.hasRef()?"true":"false","true"); - check("hasHTMLRef()", waba1.hasHTMLRef()?"true":"false","true"); - check("encodedHtmlRef()", waba1.encodedHtmlRef(),TQString::null); - - // URLs who forgot to encode spaces in the query. - waba1 = "http://www.kde.org/cgi/test.cgi?hello=My Value"; - check("http: URL with incorrect encoded query", waba1.url(), - "http://www.kde.org/cgi/test.cgi?hello=My%20Value"); - - // URL with ':' in query (':' should NOT be encoded!) - waba1.setQuery("hello:My Value"); - check("http: URL with ':' in query", waba1.url(), - "http://www.kde.org/cgi/test.cgi?hello:My%20Value"); - check("upURL() removes query", waba1.upURL().url(), - "http://www.kde.org/cgi/test.cgi"); - - // URLs who forgot to encode spaces in the query. - waba1 = "http://www.kde.org/cgi/test.cgi?hello=My Value+20"; - check("http: URL with incorrect encoded query", waba1.url(), - "http://www.kde.org/cgi/test.cgi?hello=My%20Value+20"); - - // Urls without path (BR21387) - waba1 = "http://meine.db24.de?link=home_c_login_login"; - check("http: URL with empty path string", waba1.url(), - "http://meine.db24.de?link=home_c_login_login"); - check("http: URL with empty path string path", waba1.path(), - ""); - check("http: URL with empty path string query", waba1.query(), - "?link=home_c_login_login"); - - waba1 = "http://a:389?b=c"; - check( "http: URL with port, query, and empty path; url", waba1.url(), "http://a:389?b=c" ); - check( "http: URL with port, query, and empty path; host", waba1.host(), "a" ); - check( "http: URL with port, query, and empty path; port", TQString::number( waba1.port() ), "389" ); - check( "http: URL with port, query, and empty path; path", waba1.path(), "" ); - check( "http: URL with port, query, and empty path; query", waba1.query(), "?b=c" ); - - // Urls without path (BR21387) - waba1 = "http://meine.db24.de#link=home_c_login_login"; - check("http: URL with empty path string", waba1.url(), - "http://meine.db24.de#link=home_c_login_login"); - check("http: URL with empty path string path", waba1.path(), - ""); - - waba1 = "http://www.meinestadt.de&url_plain=http"; - check("http: URL with empty path string", waba1.host(), - "www.meinestadt.de&url_plain=http"); - check("http: URL with empty path string", waba1.htmlURL(), - "http://www.meinestadt.de&url_plain=http"); - - check("http: URL with empty path string", waba1.path(), - ""); - - waba1 = "http://a:389#b=c"; - check( "http: URL with port, ref, and empty path; url", waba1.url(), "http://a:389#b=c" ); - check( "http: URL with port, ref, and empty path; host", waba1.host(), "a" ); - check( "http: URL with port, ref, and empty path; port", TQString::number( waba1.port() ), "389" ); - check( "http: URL with port, ref, and empty path; path", waba1.path(), "" ); - check( "http: URL with port, ref, and empty path; ref", waba1.ref(), "b=c" ); - check( "http: URL with port, ref, and empty path; query", waba1.query(), "" ); - - // IPV6 - waba1 = "http://[::FFFF:129.144.52.38]:81/index.html"; - check("http: IPV6 host", waba1.host(), - "::ffff:129.144.52.38"); - check("http: IPV6 port", TQString("%1").arg(waba1.port()), - "81"); - - // IPV6 - waba1 = "http://waba:pass@[::FFFF:129.144.52.38]:81/index.html"; - check("http: IPV6 host", waba1.host(), - "::ffff:129.144.52.38"); - check("http: IPV6 host", waba1.user(), - "waba"); - check("http: IPV6 host", waba1.pass(), - "pass"); - check("http: IPV6 port", TQString("%1").arg(waba1.port()), - "81"); - - // IPV6 - waba1 = "http://www.kde.org/cgi/test.cgi"; - waba1.setHost("::ffff:129.144.52.38"); - check("http: IPV6 host", waba1.url(), - "http://[::ffff:129.144.52.38]/cgi/test.cgi"); - waba1 = "http://[::ffff:129.144.52.38]/cgi/test.cgi"; - assert( waba1.isValid() ); - - // IPV6 without path - waba1 = "http://[::ffff:129.144.52.38]?query"; - assert( waba1.isValid() ); - check("http: IPV6 without path", waba1.url(), - "http://[::ffff:129.144.52.38]?query"); - check("http: IPV6 without path; query", waba1.query(), - "?query"); - waba1 = "http://[::ffff:129.144.52.38]#ref"; - assert( waba1.isValid() ); - check("http: IPV6 without path", waba1.url(), - "http://[::ffff:129.144.52.38]#ref"); - check("http: IPV6 without path; ref", waba1.ref(), - "ref"); - // IPV6 without path but with a port - waba1 = "http://[::ffff:129.144.52.38]:81?query"; - assert( waba1.isValid() ); - check("http: IPV6 without path", waba1.url(), - "http://[::ffff:129.144.52.38]:81?query"); - check("http: IPV6 without path; port", TQString::number( waba1.port() ), "81" ); - check("http: IPV6 without path; query", waba1.query(), "?query"); - waba1 = "http://[::ffff:129.144.52.38]:81#ref"; - assert( waba1.isValid() ); - check("http: IPV6 without path", waba1.url(), - "http://[::ffff:129.144.52.38]:81#ref"); - check("http: IPV6 without path; port", TQString::number( waba1.port() ), "81" ); - check("http: IPV6 without path; ref", waba1.ref(), "ref"); - - // Streaming operators - KURL origURL( "http://www.website.com/directory/?#ref" ); - waba1 = "http://[::ffff:129.144.52.38]:81?query"; - TQByteArray buffer; - { - TQDataStream stream( buffer, IO_WriteOnly ); - stream << origURL - << KURL( "file:" ) // an invalid one - << waba1; // the IPv6 one - } - { - TQDataStream stream( buffer, IO_ReadOnly ); - KURL restoredURL; - stream >> restoredURL; - check( "Streaming valid URL", origURL.url(), restoredURL.url() ); - stream >> restoredURL; - check( "Streaming invalid URL", restoredURL.isValid()?"valid":"malformed", "malformed" ); - check( "Streaming invalid URL", restoredURL.url(), "file:" ); - stream >> restoredURL; - check( "Streaming ipv6 URL with query", restoredURL.url(), waba1.url() ); - } - - // Broken stuff - waba1 = "file:a"; - check("Broken stuff #1 path", waba1.path(), "a"); - check("Broken stuff #1 fileName(false)", waba1.fileName(false), "a"); - check("Broken stuff #1 fileName(true)", waba1.fileName(true), "a"); - check("Broken stuff #1 directory(false, false)", waba1.directory(false, false), ""); - check("Broken stuff #1 directory(true, false)", waba1.directory(true, false), ""); - check("Broken stuff #1 directory(false, true)", waba1.directory(true, true), ""); - - waba1 = "file:a/"; - check("Broken stuff #2 path", waba1.path(), "a/"); - check("Broken stuff #2 fileName(false)", waba1.fileName(false), ""); - check("Broken stuff #2 fileName(true)", waba1.fileName(true), "a"); - check("Broken stuff #2 directory(false, false)", waba1.directory(false, false), "a/"); - check("Broken stuff #2 directory(true, false)", waba1.directory(true, false), "a"); - check("Broken stuff #2 directory(false, true)", waba1.directory(true, true), ""); - - waba1 = "file:"; - check("Broken stuff #3 empty", waba1.isEmpty()?"EMPTY":"NOT", "NOT"); - check("Broken stuff #3 valid", waba1.isValid()?"VALID":"MALFORMED", "MALFORMED"); - check("Broken stuff #3 path", waba1.path(), ""); - check("Broken stuff #3 fileName(false)", waba1.fileName(false), ""); - check("Broken stuff #3 fileName(true)", waba1.fileName(true), ""); - check("Broken stuff #3 directory(false, false)", waba1.directory(false, false), ""); - check("Broken stuff #3 directory(true, false)", waba1.directory(true, false), ""); - check("Broken stuff #3 directory(false, true)", waba1.directory(true, true), ""); - KURL broken; - broken.setPath( TQString::null ); - check("Broken stuff #4 empty", broken.isEmpty()?"EMPTY":"NOT", "NOT"); - // It's valid: because isValid refers to parsing, not to what happens afterwards. - check("Broken stuff #4 valid", broken.isValid()?"VALID":"MALFORMED", "VALID"); - check("Broken stuff #4 path", broken.path(), ""); - broken = "file://"; // just because coolo wondered - check("Broken stuff #5 empty", broken.isEmpty()?"EMPTY":"NOT", "NOT"); - check("Broken stuff #5 valid", broken.isValid()?"VALID":"MALFORMED", "MALFORMED"); - check("Broken stuff #5 path", broken.path(), ""); - broken = "file"; - check("Broken stuff #6 valid", broken.isValid()?"VALID":"MALFORMED", "MALFORMED"); - broken = "/"; - check("Broken stuff #7 valid", broken.isValid()?"VALID":"MALFORMED", "VALID"); - check("Broken stuff #7 path", broken.path(), "/" ); - check("Broken stuff #7 url", broken.url(), "file:///" ); - check("Broken stuff #7 file", broken.protocol(), "file" ); - - broken = "LABEL=USB_STICK"; // 71430, can we use KURL for this? - check("Broken stuff #6 valid", broken.isValid()?"VALID":"MALFORMED", "MALFORMED"); - check("Broken stuff #6 empty", broken.isEmpty()?"EMPTY":"NOT", "NOT"); - check("Broken stuff #6 path", broken.path(), ""); - -#if 0 // BROKEN? - // UNC like names - KURL unc1("FILE://localhost/home/root"); - check("UNC, with localhost", unc1.path(), "/home/root"); - check("UNC, with localhost", unc1.url(), "file:///home/root"); -#endif - KURL unc2("file:///home/root"); - check("UNC, with empty host", unc2.path(), "/home/root"); - check("UNC, with empty host", unc2.url(), "file:///home/root"); - - { - KURL unc3("FILE://remotehost/home/root"); -#if 0 // BROKEN? - check("UNC, with remote host", unc3.path(), "//remotehost/home/root"); -#endif - check("UNC, with remote host", unc3.url(), "file://remotehost/home/root"); - KURL url2("file://atlas/dfaure"); - check("KURL::host()", url2.host(), "atlas"); - check("KURL::path()", url2.path(), "/dfaure"); - //check("KURL::path()", url3.path(), "//atlas/dfaure"); // says Waba - //KURL url3("file:////atlas/dfaure"); - //check("KURL::path()", url3.path(), "//atlas/dfaure"); // says Waba - - KURL url4(url2, "//remotehost/home/root"); - check("KURL::host()", url4.host(), "remotehost"); - check("KURL::path()", url4.path(), "/home/root"); - } - - KURL umail1 ( "mailto:faure@kde.org" ); - check("mailto: URL, general form", umail1.protocol(), "mailto"); - check("mailto: URL, general form", umail1.path(), "faure@kde.org"); - check("mailto: URL, is relative", KURL::isRelativeURL("mailto:faure@kde.org") ? "true" : "false", "false"); - KURL umail2 ( "mailto:Faure David <faure@kde.org>" ); - check("mailto: URL, general form", umail2.protocol(), "mailto"); - check("mailto: URL, general form", umail2.path(), "Faure David <faure@kde.org>"); - check("isRelativeURL(\"mailto:faure@kde.org\")", KURL::isRelativeURL("mailto:faure@kde.org") ? "yes" : "no", "no"); - KURL umail3 ( "mailto:" ); - check("mailto: invalid URL", umail3.isValid()?"valid":"malformed", "malformed"); - - check("man: URL, is relative", KURL::isRelativeURL("man:mmap") ? "true" : "false", "false"); - check("javascript: URL, is relative", KURL::isRelativeURL("javascript:doSomething()") ? "true" : "false", "false"); - // more isRelative - check("file: URL, is relative", KURL::isRelativeURL("file:///blah") ? "true" : "false", "false"); - check("/path, is relative", KURL::isRelativeURL("/path") ? "true" : "false", "true"); // arguable, but necessary for KURL( baseURL, "//www1.foo.bar" ); - check("something, is relative", KURL::isRelativeURL("something") ? "true" : "false", "true"); - KURL about("about:konqueror"); - check("about:",about.path(),"konqueror"); - - KURL ulong("https://swww.gad.de:443/servlet/CookieAccepted?MAIL=s@gad.de&VER=25901"); - check("host",ulong.host(),"swww.gad.de"); - check("path",ulong.path(),"/servlet/CookieAccepted"); - -#if QT_VERSION < 300 - qt_set_locale_codec( KGlobal::charsets()->codecForName( "iso-8859-1" ) ); -#else - TQTextCodec::setCodecForLocale( KGlobal::charsets()->codecForName( "iso-8859-1" ) ); -#endif - TQString raw = "data:text/html,%00%2540%00"; - check("data URL: encode-decode of %00", KURL(raw).url(), raw ); - - // UTF8 tests - KURL uloc("/home/dfaure/konqtests/Matériel"); - check("url",uloc.url().latin1(),"file:///home/dfaure/konqtests/Mat%E9riel"); - check("pretty",uloc.prettyURL(),"file:///home/dfaure/konqtests/Matériel"); // escaping the letter would be correct too - check("pretty + strip",uloc.prettyURL(0, KURL::StripFileProtocol),"/home/dfaure/konqtests/Matériel"); // escaping the letter would be correct too - // 106 is MIB for UTF-8 - check("UTF8",uloc.url(0, 106),"file:///home/dfaure/konqtests/Mat%C3%A9riel"); - uloc = KURL("file:///home/dfaure/konqtests/Mat%C3%A9riel", 106); - check("UTF8 path", uloc.path(), "/home/dfaure/konqtests/Matériel"); - check("encodedPathAndQuery", uloc.encodedPathAndQuery(), "/home/dfaure/konqtests/Mat%E9riel"); - - // fromPathOrURL tests - uloc = KURL::fromPathOrURL( "/home/dfaure/konqtests/Mat%E9riel" ); - check("fromPathOrURL path", uloc.path(), "/home/dfaure/konqtests/Mat%E9riel"); - uloc = KURL::fromPathOrURL( "http://www.kde.org" ); - check("pathOrURL url", uloc.pathOrURL(), uloc.url() ); - uloc = KURL::fromPathOrURL( "www.kde.org" ); - check("fromPathOrURL malformed", uloc.isValid()?"valid":"malformed", "malformed"); - uloc = KURL::fromPathOrURL( "index.html" ); - check("fromPathOrURL malformed", uloc.isValid()?"valid":"malformed", "malformed"); - uloc = KURL::fromPathOrURL( "" ); - check("fromPathOrURL malformed", uloc.isValid()?"valid":"malformed", "malformed"); - - // pathOrURL tests - uloc = KURL::fromPathOrURL( "/home/dfaure/konqtests/Mat%E9riel" ); - check("pathOrURL path", uloc.pathOrURL(), uloc.path() ); - uloc = "http://www.kde.org"; - check("pathOrURL url", uloc.url(), "http://www.kde.org"); - uloc = "file:///home/dfaure/konq%20tests/Mat%E9riel#ref"; - check("pathOrURL local file with ref", uloc.pathOrURL(), "file:///home/dfaure/konq tests/Matériel#ref" ); - uloc = "file:///home/dfaure/konq%20tests/Mat%E9riel?query"; - check("pathOrURL local file with query", uloc.pathOrURL(), "file:///home/dfaure/konq tests/Matériel?query" ); - uloc = KURL::fromPathOrURL( "/home/dfaure/file#with#hash" ); - check("pathOrURL local path with #", uloc.pathOrURL(), "/home/dfaure/file#with#hash" ); - - testAdjustPath(); - -#if QT_VERSION < 300 - qt_set_locale_codec( KGlobal::charsets()->codecForName( "koi8-r" ) ); -#else - TQTextCodec::setCodecForLocale( KGlobal::charsets()->codecForName( "koi8-r" ) ); -#endif - baseURL = "file:/home/coolo"; - KURL russian = baseURL.directory(false, true) + TQString::fromLocal8Bit( "ÆÇÎ7" ); - check( "russian", russian.url(), "file:///home/%C6%C7%CE7" ); - - KURL tobi1("http://some.host.net/path/to/file#fragmentPrecedes?theQuery"); - check("wrong order of query and hypertext reference #1", tobi1.ref(), "fragmentPrecedes"); - check("wrong order of query and hypertext reference #2", tobi1.query(), "?theQuery"); - - tobi1 = "http://host.net/path/?#http://brokenäadsfküpoij31ü029muß2890zupycÜ*!*'O´+ß0i"; - check("zero-length query",tobi1.query(),"?"); - - tobi1 = "http://host.net/path/#no-query"; - check("no query", tobi1.query(),""); - check("encodedPathAndQuery", tobi1.encodedPathAndQuery(), "/path/"); - - tobi1 = "http://host.net/path?myfirstquery#andsomeReference"; - tobi1.setEncodedPathAndQuery("another/path/?another&query"); - check("setEncodedPathAndQuery test#1", tobi1.query(), "?another&query"); - check("setEncodedPathAndQuery test#2", tobi1.path(), "another/path/"); // with trailing slash - check("encodedPathAndQuery", tobi1.encodedPathAndQuery(), "another/path/?another&query"); - tobi1.setEncodedPathAndQuery("another/path?another&query"); - check("setEncodedPathAndQuery test#1", tobi1.query(), "?another&query"); - check("setEncodedPathAndQuery test#2", tobi1.path(), "another/path"); // without trailing slash - check("encodedPathAndQuery", tobi1.encodedPathAndQuery(), "another/path?another&query"); - - KURL theKow = "http://www.google.de/search?q=frerich&hlx=xx&hl=de&empty=&lr=lang+de&test=%2B%20%3A%25"; - check("queryItem (first item)", theKow.queryItem("q"), "frerich"); - check("queryItem (middle item)", theKow.queryItem("hl"), "de"); - check("queryItem (last item)", theKow.queryItem("lr"), "lang de"); - check("queryItem (invalid item)", theKow.queryItem("InterstellarCounselor"), TQString::null); - check("queryItem (empty item)", theKow.queryItem("empty"), ""); - check("queryItem (item with encoded chars)", theKow.queryItem("test"), "+ :%"); - check("encodedPathAndQuery", theKow.encodedPathAndQuery(), "/search?q=frerich&hlx=xx&hl=de&empty=&lr=lang+de&test=%2B%20%3A%25"); - - // checks for queryItems(), which returns a TQMap<TQString,TQString>: - KURL queryUrl( "mailto:Marc%20Mutz%20%3cmutz@kde.org%3E?" - "Subject=subscribe+me&" - "body=subscribe+mutz%40kde.org&" - "Cc=majordomo%40lists.kde.org" ); - check("queryItems (c.s. keys)", - TQStringList(queryUrl.queryItems().keys()).join(", "), - "Cc, Subject, body" ); - check("queryItems (c.i.s. keys)", - TQStringList(queryUrl.queryItems(KURL::CaseInsensitiveKeys).keys()).join(", "), - "body, cc, subject" ); - check("queryItems (values; c.s. keys)", - TQStringList(queryUrl.queryItems().values()).join(", "), - "majordomo@lists.kde.org, subscribe me, subscribe mutz@kde.org" ); - check("queryItems (values; c.i.s. keys)", - TQStringList(queryUrl.queryItems(KURL::CaseInsensitiveKeys).values()).join(", "), - "subscribe mutz@kde.org, majordomo@lists.kde.org, subscribe me" ); - - KURL umlaut1("http://www.clever-tanken.de/liste.asp?ort=N%FCrnberg&typ=Diesel"); - check("umlaut1.url()", umlaut1.url(), "http://www.clever-tanken.de/liste.asp?ort=N%FCrnberg&typ=Diesel"); - - KURL umlaut2("http://www.clever-tanken.de/liste.asp?ort=N%FCrnberg&typ=Diesel", 106); - check("umlaut2.url()", umlaut2.url(), "http://www.clever-tanken.de/liste.asp?ort=N%FCrnberg&typ=Diesel"); - - // Needed for #49616 - check( "encode_string('C++')", KURL::encode_string( "C++" ), "C%2B%2B" ); - check( "decode_string('C%2B%2B')", KURL::decode_string( "C%2B%2B" ), "C++" ); - check( "decode_string('C%00A')", KURL::decode_string( "C%00%A" ), "C" ); // we stop at %00 - - check( "encode_string('%')", KURL::encode_string( "%" ), "%25" ); - check( "encode_string(':')", KURL::encode_string( ":" ), "%3A" ); - - KURL amantia( "http://%E1.foo.de" ); - check("amantia.isValid()", amantia.isValid() ? "true" : "false", "true"); -#ifdef HAVE_IDNA_H - check("amantia.url()", amantia.url(), "http://xn--80a.foo.de"); // Non-ascii is allowed in IDN domain names. -#else - check("amantia.url()", amantia.url(), "http://?.foo.de"); // why not -#endif - - KURL thiago( TQString::fromUtf8( "http://\303\244.de" ) ); // ä in utf8 - check("thiago.isValid()", thiago.isValid() ? "true" : "false", "true"); -#ifdef HAVE_IDNA_H - check("thiago.url()", thiago.url(), "http://xn--4ca.de"); // Non-ascii is allowed in IDN domain names. -#else - check("thiago.url()", thiago.url(), TQString::fromUtf8( "http://\303\244.de" ) ); -#endif - - - KURL smb("smb://domain;username:password@server/share"); - check("smb.isValid()", smb.isValid() ? "true" : "false", "true"); - check("smb.user()", smb.user(), "domain;username"); - smb = "smb:/"; - check("smb:/", smb.isValid()?"VALID":"MALFORMED", "VALID"); - smb = "smb://"; // kurl.cpp rev 1.106 - check("smb://", smb.isValid()?"VALID":"MALFORMED", "MALFORMED"); - smb = "smb://host"; - check("smb://host", smb.isValid()?"VALID":"MALFORMED", "VALID"); - smb = "smb:///"; - check("smb:///", smb.isValid()?"VALID":"MALFORMED", "VALID"); - - KURL weird; - weird = "http://strange<hostname>/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "false"); - - weird = "http://strange<username>@strange<hostname>/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "false"); - - weird = "http://strange<username>@ok_hostname/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "true"); - check("weird.host()", weird.host(), "ok_hostname"); - - weird = "http://strange;hostname/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "false"); - - weird = "http://strange;username@strange;hostname/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "false"); - - weird = "http://strange;username@ok_hostname/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "true"); - check("weird.host()", weird.host(), "ok_hostname"); - - weird = "http://strange;username:password@strange;hostname/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "false"); - - weird = "http://strange;username:password@ok_hostname/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "true"); - check("weird.host()", weird.host(), "ok_hostname"); - - weird = "http://[strange;hostname]/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "false"); - - weird = "http://[::fff:1:23]/"; - check("weird.isValid()", weird.isValid() ? "true" : "false", "true"); - check("weird.host()", weird.host(), "::fff:1:23"); - - KURL com1("http://server.com/dir/", "."); - check("com1.url()", com1.url(), "http://server.com/dir/"); - - KURL com2("http://server.com/dir/blubb/", "blah/"); - check("com2.url()", com2.url(), "http://server.com/dir/blubb/blah/"); - - KURL utf8_1("audiocd:/By%20Name/15%20Geantra%C3%AE.wav", 106); - check("utf8_1.fileName()", utf8_1.fileName(), TQString::fromLatin1("15 Geantraî.wav")); - - KURL utf8_2("audiocd:/By%20Name/15%2fGeantra%C3%AE.wav", 106); - check("utf8_2.fileName()", utf8_2.fileName(), TQString::fromLatin1("15/Geantraî.wav")); - - KURL url_newline_1("http://www.foo.bar/foo/bar\ngnork"); - check("url_newline_1.url()", url_newline_1.url(), TQString::fromLatin1("http://www.foo.bar/foo/bar%0Agnork")); - - KURL url_newline_2("http://www.foo.bar/foo?bar\ngnork"); - check("url_newline_2.url()", url_newline_2.url(), TQString::fromLatin1("http://www.foo.bar/foo?bar%0Agnork")); - - KURL local_file_1("file://localhost/my/file"); - check("local_file_1.isLocalFile()", local_file_1.isLocalFile() ? "true" : "false", "true"); - - KURL local_file_2("file://www.kde.org/my/file"); - check("local_file_2.isLocalFile()", local_file_2.isLocalFile() ? "true" : "false", "false"); - - KURL local_file_3; - local_file_3.setHost(getenv("HOSTNAME")); - local_file_3.setPath("/my/file"); - printf("\nURL=%s\n", local_file_3.url().latin1()); - check("local_file_3.isLocalFile()", local_file_3.isLocalFile() ? "true" : "false", "true"); - - KURL local_file_4("file:///my/file"); - check("local_file_4.isLocalFile()", local_file_4.isLocalFile() ? "true" : "false", "true"); - - KURL local_file_5; - local_file_5.setPath("/foo?bar"); - check("local_file_5.url()", local_file_5.url(), "file:///foo%3Fbar"); - - TQString basePath = "/home/bastian"; - - check("relativePath(\"/home/bastian\", \"/home/bastian\")", KURL::relativePath(basePath, "/home/bastian"), "./"); - bool b; - check("relativePath(\"/home/bastian\", \"/home/bastian/src/plugins\")", KURL::relativePath(basePath, "/home/bastian/src/plugins", &b), "./src/plugins"); - check("Is a subdirectory?", b ? "true" : "false", "true"); - check("relativePath(\"/home/bastian\", \"./src/plugins\")", KURL::relativePath(basePath, "./src/plugins"), "./src/plugins"); - check("relativePath(\"/home/bastian\", \"/home/waba/src/plugins\")", KURL::relativePath(basePath, "/home/waba/src/plugins", &b), "../waba/src/plugins"); - check("Is a subdirectory?", b ? "true" : "false", "false"); - check("relativePath(\"/home/bastian\", \"/\")", KURL::relativePath(basePath, "/"), "../../"); - - check("relativePath(\"/\", \"/\")", KURL::relativePath("/", "/"), "./"); - check("relativePath(\"/\", \"/home/bastian\")", KURL::relativePath("/", "/home/bastian"), "./home/bastian"); - check("relativePath(\"\", \"/home/bastian\")", KURL::relativePath("", "/home/bastian"), "/home/bastian"); - - baseURL = "http://www.kde.org/index.html"; - check("relativeURL(\"http://www.kde.org/index.html\", \"http://www.kde.org/index.html#help\")", KURL::relativeURL(baseURL, "http://www.kde.org/index.html#help"), "#help"); - check("relativeURL(\"http://www.kde.org/index.html\", \"http://www.kde.org/index.html?help=true\")", KURL::relativeURL(baseURL, "http://www.kde.org/index.html?help=true"), "index.html?help=true"); - check("relativeURL(\"http://www.kde.org/index.html\", \"http://www.kde.org/contact.html\")", KURL::relativeURL(baseURL, "http://www.kde.org/contact.html"), "contact.html"); - check("relativeURL(\"http://www.kde.org/index.html\", \"ftp://ftp.kde.org/pub/kde\")", KURL::relativeURL(baseURL, "ftp://ftp.kde.org/pub/kde"), "ftp://ftp.kde.org/pub/kde"); - check("relativeURL(\"http://www.kde.org/index.html\", \"http://www.kde.org/index.html\")", KURL::relativeURL(baseURL, "http://www.kde.org/index.html"), "./"); - - baseURL = "http://www.kde.org/info/index.html"; - check("relativeURL(\"http://www.kde.org/info/index.html\", \"http://www.kde.org/bugs/contact.html\")", KURL::relativeURL(baseURL, "http://www.kde.org/bugs/contact.html"), "../bugs/contact.html"); - - baseURL = "ptal://mlc:usb:PC_970"; - check("isValid()?", baseURL.isValid() ? "true" : "false", "false"); - check("url()", baseURL.url(), "ptal://mlc:usb:PC_970"); - - baseURL = "http://mlc:80/"; - check("isValid()?", baseURL.isValid() ? "true" : "false", "true"); - check("port()?", TQString::number(baseURL.port()), "80"); - check("path()?", baseURL.path(), "/"); - - baseURL = "ptal://mlc:usb@PC_970"; // User=mlc, password=usb, host=PC_970 - check("isValid()?", baseURL.isValid() ? "true" : "false", "true"); - check("host()?", baseURL.host(), "pc_970"); - check("user()?", baseURL.user(), "mlc"); - check("pass()?", baseURL.pass(), "usb"); - - weird = "ftp://user%40host.com@ftp.host.com/var/www/"; - check("user()?", weird.user(), "user@host.com" ); - check("host()?", weird.host(), "ftp.host.com" ); - KURL up = weird.upURL(); - check("KURL::upURL()", up.url(), "ftp://user%40host.com@ftp.host.com/var/"); - up = up.upURL(); - check("KURL::upURL()", up.url(), "ftp://user%40host.com@ftp.host.com/"); - up = up.upURL(); - check("KURL::upURL()", up.url(), "ftp://user%40host.com@ftp.host.com/"); // unchanged - - KURL ldap = "ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)"; - check("host()?", ldap.host(), "host.com"); - check("port()?", TQString("%1").arg(ldap.port()), "6666"); - check("path()?", ldap.path(), "/o=University of Michigan,c=US"); - check("query()?", ldap.query(), "??sub?(cn=Babs%20Jensen)"); - check("url()?", ldap.url(), "ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)"); - ldap.setQuery("??sub?(cn=Karl%20Marx)"); - check("query()?", ldap.query(), "??sub?(cn=Karl%20Marx)"); - check("url()?", ldap.url(), "ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Karl%20Marx)"); - - KURL leo = "data:text/html,http://www.invalid/"; - check("data URL: isValid", leo.isValid()?"valid":"malformed", "valid" ); - check("data URL: protocol", leo.protocol(), "data" ); - check("data URL: url", leo.url(), "data:text/html,http://www.invalid/" ); - check("data URL: path", leo.path(), "text/html,http://www.invalid/" ); - - // URI Mode tests - url1 = "http://www.foobar.com/"; - check("KURL(\"http://www.foobar.com/\").uriMode()", TQString::number(url1.uriMode()), TQString::number(KURL::URL)); - url1 = "mailto:user@host.com"; - check("KURL(\"mailto:user@host.com\").uriMode()", TQString::number(url1.uriMode()), TQString::number(KURL::Mailto)); - check("KURL(\"mailto:user@host.com\").url()", url1.url(), "mailto:user@host.com"); - check("KURL(\"mailto:user@host.com\").url(0, 106)", url1.url(0, 106), "mailto:user@host.com"); - url1 = "data:text/plain,foobar?gazonk=flarp"; - check("KURL(\"data:text/plain,foobar?gazonk=flarp\").uriMode()", TQString::number(url1.uriMode()), TQString::number(KURL::RawURI)); - check("KURL(\"data:text/plain,foobar?gazonk=flarp\").path()", url1.path(), "text/plain,foobar?gazonk=flarp"); - url1 = "mailto:User@Host.COM?subject=Hello"; - check("KURL(\"mailto:User@Host.COM?subject=Hello\").path()", url1.path(), "User@host.com"); - - KURL emptyUserTest1("http://www.foobar.com/"); - KURL emptyUserTest2("http://www.foobar.com/"); - emptyUserTest2.setUser(""); - check("Empty vs. null fields: user", emptyUserTest1==emptyUserTest2?"TRUE":"FALSE","TRUE"); - emptyUserTest2.setPass(""); - check("Empty vs. null fields: password", emptyUserTest1==emptyUserTest2?"TRUE":"FALSE","TRUE"); - - printf("\nTest OK !\n"); -} - diff --git a/kdecore/tests/kxerrorhandlertest.cpp b/kdecore/tests/kxerrorhandlertest.cpp deleted file mode 100644 index c2efc7443..000000000 --- a/kdecore/tests/kxerrorhandlertest.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include <tqwidget.h> -#include <X11/Xlib.h> -#include <iostream> -using namespace std; - -#include <kxerrorhandler.h> - -int handler1( Display*, XErrorEvent* e ) - { - cout << "ERR1:" << e->resourceid << ":" << (int)e->error_code << ":" << (int)e->request_code << ":" << e->serial << endl; - return 1; - } - -bool handler3( int request, int error_code, unsigned long resourceid ) - { - cout << "ERR3:" << resourceid << ":" << error_code << ":" << request << endl; - return true; - } - -int main() - { - Display* dpy = XOpenDisplay( NULL ); - XSetWindowAttributes attrs; - Window w = XCreateWindow( dpy, DefaultRootWindow( dpy ), 0, 0, 100, 100, 0, CopyFromParent, CopyFromParent, - CopyFromParent, 0, &attrs ); - cout << w << ":" << XNextRequest( dpy ) << endl; - XMapWindow( dpy, w ); - ++w; -// XSetInputFocus( dpy, w, RevertToParent, CurrentTime ); - { - KXErrorHandler handle1( handler1, dpy ); - cout << w << ":" << XNextRequest( dpy ) << endl; - XMapWindow( dpy, w ); - XWindowAttributes attr; - { - KXErrorHandler handle2( dpy ); - XGetWindowAttributes(dpy, w, &attr); - { - KXErrorHandler handle3( handler3, dpy ); - XSetInputFocus( dpy, w, RevertToParent, CurrentTime ); - cout << "WAS3:" << handle3.error( /*false*/ true ) << endl; - } - cout << "WAS2:" << handle2.error( false ) << endl; - } -// XSync( dpy, False ); - cout << "WAS1:" << handle1.error( false ) << endl; - } - for(;;) - { - XEvent ev; - XNextEvent( dpy, &ev ); - } - XCloseDisplay( dpy ); - } diff --git a/kdecore/tests/startserviceby.cpp b/kdecore/tests/startserviceby.cpp deleted file mode 100644 index 93e6716ef..000000000 --- a/kdecore/tests/startserviceby.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Waldo Bastian <bastian@kde.org> - - 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 "kapplication.h" -#include <stdio.h> - -#include <kcmdlineargs.h> -#include <kaboutdata.h> -#include <kglobalsettings.h> -#include <kdebug.h> - -int -main(int argc, char *argv[]) -{ - KAboutData about("kapptest", "kapptest", "version"); - KCmdLineArgs::init(argc, argv, &about); - - KApplication a; - - TQString error; - TQCString dcopService; - int pid; - a.startServiceByDesktopName( "kaddressbook", TQString::null, &error, &dcopService, &pid ); - kdDebug() << "Started. error=" << error << " dcopService=" << dcopService << " pid=" << pid << endl; - a.exec(); -} diff --git a/kdecore/tests/testqtargs.cpp b/kdecore/tests/testqtargs.cpp deleted file mode 100644 index d1c8ff244..000000000 --- a/kdecore/tests/testqtargs.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - testqtargs -- is there really a bug in KCmdLineArgs or am I on crack? - - I used the following compile options: - - g++ -g -Wall -o testqtargs testqtargs.cpp -I/usr/X11R6/include \ - -I/opt/qt3/include -I/opt/trinity/include -L/usr/X11R6/lib -L/opt/qt3/lib \ - -L/opt/trinity/lib -lqt -ltdecore - - if invoked like this ./testqtargs --bg blue --caption something --hello hi - - The program should list argv[] then produce output like this: - - qt arg[0] = background - qt arg[1] = blue - arg bg = blue - arg caption = something - arg hello = hi - - Instead for me it prints: - - qt arg[0] = -background - qt arg[1] = blue - arg caption = something - arg hello = hi - - See the extra dash in qt arg[0]? I believe that is the cause of the problem. - --bg is aliased to --background but If you try it with --background or - -background, you get the same thing. - - in tdecore/kapplication.cpp, KCmdLineOption qt_options is defined and used - by the static method Kapplication::addCmdLineOptions to add the Qt options - but its' entries look like this: - - { "background <color>", I18N_NOOP("sets the default background color and an\n -application palette (light and dark shades are\ncalculated)."), 0}, - - it looks for "background" instead of "-background" so never find the arg. - - Software: g++ 2.95, kdelibs from CVS Jan 28, Qt 3.01 - OS: Debian GNU/Linux 3.0 (sid) - - -*/ - -#include <kapplication.h> -#include <kcmdlineargs.h> -#include <kaboutdata.h> -#include <klocale.h> - -static const KCmdLineOptions options[] = -{ - { "hello ", I18N_NOOP("Says hello"), 0 }, - KCmdLineLastOption -}; - -int main(int argc, char *argv[]) -{ - for (int i = 0; i < argc; i++) - { - qDebug("argv[%d] = %s", i, argv[i]); - } - KAboutData aboutData( "testqtargs", I18N_NOOP("testqtargs"), - "1.0", I18N_NOOP("testqtargs"), KAboutData::License_GPL, - "", "", "", ""); - - KCmdLineArgs::init(argc, argv, &aboutData); - KCmdLineArgs::addCmdLineOptions(options); - - KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt"); - for (int i = 0; i < qtargs->count(); i++) - { - qDebug("qt arg[%d] = %s", i, qtargs->arg(i)); - } - - KApplication app; - - KCmdLineArgs *kdeargs = KCmdLineArgs::parsedArgs("kde"); - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - // An arg set by Qt - if(qtargs->isSet("background")) - { - qDebug("arg bg = %s", (const char*)qtargs->getOption("background")); - } - // An arg set by KDE - if(kdeargs->isSet("caption")) - { - qDebug("arg caption = %s", (const char*)kdeargs->getOption("caption")); - } - // An arg set by us. - if(args->isSet("hello")) - { - qDebug("arg hello = %s", (const char*)args->getOption("hello")); - } - args->clear(); - - TQWidget *w = new TQWidget(); - app.setMainWidget(w); - w->show(); - - return app.exec(); -} - diff --git a/kdecore/vsnprintf.c b/kdecore/vsnprintf.c deleted file mode 100644 index 257392aa4..000000000 --- a/kdecore/vsnprintf.c +++ /dev/null @@ -1,170 +0,0 @@ -#include "config.h" -#ifndef HAVE_VSNPRINTF - -/* - * Revision 12: http://theos.com/~deraadt/snprintf.c - * - * Copyright (c) 1997 Theo de Raadt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <signal.h> -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#if __STDC__ -#include <stdarg.h> -#include <stdlib.h> -#else -#include <varargs.h> -#endif -#include <setjmp.h> - -#ifndef roundup -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) -#endif - -static int pgsize; -static char *curobj; -static sigjmp_buf bail; - -#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */ - -static char * -msetup(str, n) - char *str; - size_t n; -{ - char *e; - - if (n == 0) - return NULL; - if (pgsize == 0) - pgsize = getpagesize(); - curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2); - if (curobj == NULL) - return NULL; - e = curobj + n + EXTRABYTES; - e = (char *)roundup((unsigned long)e, pgsize); - if (mprotect(e, pgsize, PROT_NONE) == -1) { - free(curobj); - curobj = NULL; - return NULL; - } - e = e - n - EXTRABYTES; - *e = '\0'; - return (e); -} - -static void -mcatch() -{ - siglongjmp(bail, 1); -} - -static void -mcleanup(str, n, p) - char *str; - size_t n; - char *p; -{ - int l = strlen(p); - - if (l > n - 1) - l = n - 1; - memcpy(str, p, l); - str[l] = '\0'; - if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize, - PROT_READ|PROT_WRITE|PROT_EXEC) == -1) - mprotect((caddr_t)(p + n + EXTRABYTES), pgsize, - PROT_READ|PROT_WRITE); - free(curobj); -} - -int -#if __STDC__ -vsnprintf(char *str, size_t n, char const *fmt, va_list ap) -#else -vsnprintf(str, n, fmt, ap) - char *str; - size_t n; - char *fmt; - char *ap; -#endif -{ - struct sigaction osa, nsa; - char *p; - int ret = n + 1; /* if we bail, indicated we overflowed */ - - memset(&nsa, 0, sizeof nsa); - nsa.sa_handler = mcatch; - sigemptyset(&nsa.sa_mask); - - p = msetup(str, n); - if (p == NULL) { - *str = '\0'; - return 0; - } - if (sigsetjmp(bail, 1) == 0) { - if (sigaction(SIGSEGV, &nsa, &osa) == -1) { - mcleanup(str, n, p); - return (0); - } - ret = vsprintf(p, fmt, ap); - } - mcleanup(str, n, p); - (void) sigaction(SIGSEGV, &osa, NULL); - return (ret); -} - -int -#if __STDC__ -snprintf(char *str, size_t n, char const *fmt, ...) -#else -snprintf(str, n, fmt, va_alist) - char *str; - size_t n; - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - - return (vsnprintf(str, n, fmt, ap)); - va_end(ap); -} - - -#endif - -/* ANSI C forbids an empty source file... */ -static void dummy_func() { - dummy_func(); -} diff --git a/kdefx/CMakeLists.txt b/kdefx/CMakeLists.txt deleted file mode 100644 index 1aa52627f..000000000 --- a/kdefx/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - kpixmap.h kpixmapsplitter.h kpixmapeffect.h - kimageeffect.h kdrawutil.h kstyle.h kcpuinfo.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - - -##### libtdefx ################################## - -set( target tdefx ) - -set( ${target}_SRCS - kpixmap.cpp kpixmapsplitter.cpp kpixmapeffect.cpp - kimageeffect.cpp kdrawutil.cpp kstyle.cpp kcpuinfo.cpp -) - -tde_add_library( ${target} SHARED AUTOMOC - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - LINK ${TQT_LIBRARIES} ${XRENDER_LIBRARIES} - DESTINATION ${LIB_INSTALL_DIR} -) diff --git a/kdefx/Mainpage.dox b/kdefx/Mainpage.dox deleted file mode 100644 index 65fcadfc8..000000000 --- a/kdefx/Mainpage.dox +++ /dev/null @@ -1,32 +0,0 @@ -/** - * \mainpage The Trinity special effects [fx] Library - * - * This library provides various classes related to image and pixmap - * manipulation, a class that provides information about CPU support - * for architecture specific features, as well as the base class for - * the %Trinity widget styles. - * - * The two graphical effects classes, KImageEffect and KPixmapEffect, - * provide static methods for applying graphical effects to images and - * pixmaps respectively. KImageEffect also provides highly optimized - * methods for compositing images. - * - * A class that's related to those two is KPixmapSplitter, which is - * used for calculating the positions of items in pixmaps with - * multiple items arranged in rows and columns. - * Another is KPixmap, which extends QPixmap with the capability to - * ensure that a 256 color pixmap uses a specific system wide - * palette. - * - * The KCPUInfo class provides a means for applications to obtain - * information at runtime about processor support for certain - * architecture extensions that are useful when processing images, - * such as MMX, SSE, 3DNow! and AltiVec. - * - * KStyle is the base class for the %Trinity widget styles. It simplifies - * and extends the QStyle API in order to make style coding easier. - * It also provides an internal menu transparency and drop shadow - * engine, which means that all styles inheriting this class will - * automatically support those features. - */ - diff --git a/kdefx/Makefile.am b/kdefx/Makefile.am deleted file mode 100644 index 2b588ba54..000000000 --- a/kdefx/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ - -# This file is part of the KDE libraries -# Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) -# (C) 1997 Stephan Kulow (coolo@kde.org) - -# 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 General Public License -# along with this library; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -#SUBDIRS = . tests - -INCLUDES= $(all_includes) - -lib_LTLIBRARIES = libtdefx.la -libtdefx_la_LDFLAGS = $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(all_libraries) -no-undefined -version-info 6:0:2 -libtdefx_la_LIBADD = $(LIB_QT) $(LIB_XRENDER) $(LIB_X11) -libtdefx_la_NMCHECK = $(srcdir)/libtdefx.nmcheck -libtdefx_la_NMCHECKWEAK = $(srcdir)/libtdefx_weak.nmcheck $(top_srcdir)/tdecore/libqt-mt_weak.nmcheck \ - $(top_srcdir)/tdecore/standard_weak.nmcheck - -include_HEADERS = kpixmap.h kpixmapsplitter.h \ - kpixmapeffect.h kimageeffect.h kdrawutil.h kstyle.h kcpuinfo.h - -libtdefx_la_SOURCES = kpixmap.cpp kpixmapsplitter.cpp \ - kpixmapeffect.cpp kimageeffect.cpp kdrawutil.cpp kstyle.cpp \ - kcpuinfo.cpp - -METASOURCES = AUTO - -EXTRA_DIST = Mainpage.dox - -DOXYGEN_REFERENCES = tdecore -include ../admin/Doxyfile.am - diff --git a/kdefx/configure.in.in b/kdefx/configure.in.in deleted file mode 100644 index 9afed6f96..000000000 --- a/kdefx/configure.in.in +++ /dev/null @@ -1,63 +0,0 @@ - -dnl ----------------------------------------------------- -dnl XRender check -dnl ----------------------------------------------------- -LIB_XRENDER= -if test "$kde_use_qt_emb" = "no" && test "$kde_use_qt_mac" = "no"; then - KDE_CHECK_HEADER(X11/extensions/Xrender.h, [xrender_h=yes], [xrender_h=no]) - if test "$xrender_h" = yes; then - KDE_CHECK_LIB(Xrender, XRenderComposite, [ - LIB_XRENDER=-lXrender - AC_DEFINE_UNQUOTED(HAVE_XRENDER, 1, [Defined if your system has XRender support]) - ], [], -lXext -lX11 $X_EXTRA_LIBS) - fi -fi -AC_SUBST(LIB_XRENDER) - -dnl ----------------------------------------------------- -dnl IA32 checks -dnl ----------------------------------------------------- -case $host_cpu in - i*86 ) - AC_MSG_CHECKING(for assembler support for IA32 extensions) - - dnl MMX check - AC_TRY_COMPILE(, [ __asm__("pxor %mm0, %mm0") ], - [ - echo $ECHO_N "MMX yes$ECHO_C" - AC_DEFINE_UNQUOTED(HAVE_X86_MMX, 1, [Define to 1 if the assembler supports MMX instructions.]) - ], [ echo $ECHO_N "MMX no$ECHO_C" ]) - - dnl SSE check - AC_TRY_COMPILE(,[ __asm__("xorps %xmm0, %xmm0") ], - [ - echo $ECHO_N ", SSE yes$ECHO_C" - AC_DEFINE_UNQUOTED(HAVE_X86_SSE, 1, [Define to 1 if the assembler supports SSE instructions.]) - ], [ echo $ECHO_N ", SSE no$ECHO_C" ]) - - dnl SSE2 check - AC_TRY_COMPILE(, [ __asm__("xorpd %xmm0, %xmm0") ], - [ - echo $ECHO_N ", SSE2 yes$ECHO_C" - AC_DEFINE_UNQUOTED(HAVE_X86_SSE2, 1, [Define to 1 if the assembler supports SSE2 instructions.]) - ], [ echo $ECHO_N ", SSE2 no$ECHO_C" ]) - - dnl 3DNOW check - AC_TRY_COMPILE(, [ __asm__("femms") ], - [ - echo $ECHO_N ", 3DNOW yes$ECHO_C" - AC_DEFINE_UNQUOTED(HAVE_X86_3DNOW, 1, [Define to 1 if the assembler supports 3DNOW instructions.]) - ], [ echo $ECHO_N ", 3DNOW no$ECHO_C" ]) - echo - ;; - powerpc ) - AC_MSG_CHECKING(for assembler support for AltiVec instructions) - dnl AltiVec check - AC_TRY_COMPILE(, [ __asm__("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0" : : "r"(-1) ) ], - [ - echo $ECHO_N " yes$ECHO_C" - AC_DEFINE_UNQUOTED(HAVE_PPC_ALTIVEC, 1, [Define to 1 if the assembler supports AltiVec instructions.]) - ], [ echo $ECHO_N ", AltiVec no$ECHO_C" ]) - echo - ;; -esac diff --git a/kdefx/kcpuinfo.cpp b/kdefx/kcpuinfo.cpp deleted file mode 100644 index 97c99f8d9..000000000 --- a/kdefx/kcpuinfo.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Fredrik Höglund <fredrik@kde.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <csignal> -#include <csetjmp> - -#include <config.h> -#include "kcpuinfo.h" - - -#if defined(__GNUC__) || defined(__INTEL_COMPILER) -# define HAVE_GNU_INLINE_ASM -#endif - -typedef void (*kde_sighandler_t) (int); - -#ifdef __i386__ -static jmp_buf env; - -// Sighandler for the SSE OS support check -static void sighandler( int ) -{ - std::longjmp( env, 1 ); -} -#endif - -#ifdef __PPC__ -static sigjmp_buf KDE_NO_EXPORT jmpbuf; -static sig_atomic_t KDE_NO_EXPORT canjump = 0; - -static void KDE_NO_EXPORT sigill_handler( int sig ) -{ - if ( !canjump ) { - signal( sig, SIG_DFL ); - raise( sig ); - } - canjump = 0; - siglongjmp( jmpbuf, 1 ); -} -#endif - -static int getCpuFeatures() -{ - volatile int features = 0; - -#if defined( HAVE_GNU_INLINE_ASM ) -#if defined( __i386__ ) - bool haveCPUID = false; - bool have3DNOW = false; - int result = 0; - - // First check if the CPU supports the CPUID instruction - __asm__ __volatile__( - // Try to toggle the CPUID bit in the EFLAGS register - "pushf \n\t" // Push the EFLAGS register onto the stack - "popl %%ecx \n\t" // Pop the value into ECX - "movl %%ecx, %%edx \n\t" // Copy ECX to EDX - "xorl $0x00200000, %%ecx \n\t" // Toggle bit 21 (CPUID) in ECX - "pushl %%ecx \n\t" // Push the modified value onto the stack - "popf \n\t" // Pop it back into EFLAGS - - // Check if the CPUID bit was successfully toggled - "pushf \n\t" // Push EFLAGS back onto the stack - "popl %%ecx \n\t" // Pop the value into ECX - "xorl %%eax, %%eax \n\t" // Zero out the EAX register - "cmpl %%ecx, %%edx \n\t" // Compare ECX with EDX - "je .Lno_cpuid_support%= \n\t" // Jump if they're identical - "movl $1, %%eax \n\t" // Set EAX to true - ".Lno_cpuid_support%=: \n\t" - : "=a"(haveCPUID) : : "%ecx", "%edx" ); - - // If we don't have CPUID we won't have the other extensions either - if ( ! haveCPUID ) - return 0L; - - // Execute CPUID with the feature request bit set - __asm__ __volatile__( - "pushl %%ebx \n\t" // Save EBX - "movl $1, %%eax \n\t" // Set EAX to 1 (features request) - "cpuid \n\t" // Call CPUID - "popl %%ebx \n\t" // Restore EBX - : "=d"(result) : : "%eax", "%ecx" ); - - // Test bit 23 (MMX support) - if ( result & 0x00800000 ) - features |= KCPUInfo::IntelMMX; - - __asm__ __volatile__( - "pushl %%ebx \n\t" - "movl $0x80000000, %%eax \n\t" - "cpuid \n\t" - "cmpl $0x80000000, %%eax \n\t" - "jbe .Lno_extended%= \n\t" - "movl $0x80000001, %%eax \n\t" - "cpuid \n\t" - "test $0x80000000, %%edx \n\t" - "jz .Lno_extended%= \n\t" - "movl $1, %%eax \n\t" // // Set EAX to true - ".Lno_extended%=: \n\t" - "popl %%ebx \n\t" // Restore EBX - : "=a"(have3DNOW) : ); - - if ( have3DNOW ) - features |= KCPUInfo::AMD3DNOW; - -#ifdef HAVE_X86_SSE - // Test bit 25 (SSE support) - if ( result & 0x00200000 ) { - features |= KCPUInfo::IntelSSE; - - // OS support test for SSE. - // Install our own sighandler for SIGILL. - kde_sighandler_t oldhandler = std::signal( SIGILL, sighandler ); - - // Try executing an SSE insn to see if we get a SIGILL - if ( setjmp( env ) ) - features ^= KCPUInfo::IntelSSE; // The OS support test failed - else - __asm__ __volatile__("xorps %xmm0, %xmm0"); - - // Restore the default sighandler - std::signal( SIGILL, oldhandler ); - - // Test bit 26 (SSE2 support) - if ( (result & 0x00400000) && (features & KCPUInfo::IntelSSE) ) - features |= KCPUInfo::IntelSSE2; - - // Note: The OS requirements for SSE2 are the same as for SSE - // so we don't have to do any additional tests for that. - } -#endif // HAVE_X86_SSE -#elif defined __PPC__ && defined HAVE_PPC_ALTIVEC - signal( SIGILL, sigill_handler ); - if ( sigsetjmp( jmpbuf, 1 ) ) { - signal( SIGILL, SIG_DFL ); - } else { - canjump = 1; - __asm__ __volatile__( "mtspr 256, %0\n\t" - "vand %%v0, %%v0, %%v0" - : /* none */ - : "r" (-1) ); - signal( SIGILL, SIG_DFL ); - features |= KCPUInfo::AltiVec; - } -#endif // __i386__ -#endif //HAVE_GNU_INLINE_ASM - - return features; -} - -unsigned int KCPUInfo::s_features = getCpuFeatures(); - - diff --git a/kdefx/kcpuinfo.h b/kdefx/kcpuinfo.h deleted file mode 100644 index ce39ded82..000000000 --- a/kdefx/kcpuinfo.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Fredrik Höglund <fredrik@kde.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __KCPUINFO_H -#define __KCPUINFO_H - -#include <kdelibs_export.h> - -/** - * This class provides a means for applications to obtain information at - * runtime about processor support for certain architecture extensions, - * such as MMX, SSE, 3DNow and AltiVec. - * - * @since 3.2 - */ -class KDEFX_EXPORT KCPUInfo -{ - public: - /** - * This enum contains the list of architecture extensions you - * can query. - */ - enum Extensions { - IntelMMX = 1 << 0, //!< Intel's MMX instructions. - IntelSSE = 1 << 1, //!< Intel's SSE instructions. - IntelSSE2 = 1 << 2, //!< Intel's SSE2 instructions. - AMD3DNOW = 1 << 3, //!< AMD 3DNOW instructions - AltiVec = 1 << 4 //!< Motorola AltiVec instructions - }; - - /** - * Returns true if the processor supports @p extension, - * and false otherwise. - * - * @param extension the feature to query. - * @return If true, the processor supports @p extension. - * @see Extensions - */ - static bool haveExtension( unsigned int extension ) - { return (s_features & extension) != 0; } - - private: - static unsigned int s_features; -}; - -#endif - diff --git a/kdefx/kdrawutil.cpp b/kdefx/kdrawutil.cpp deleted file mode 100644 index 83fe7d300..000000000 --- a/kdefx/kdrawutil.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> - - 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 "kdrawutil.h" -#include <tqdrawutil.h> - -KDEFX_EXPORT void kDrawNextButton(TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken, - const TQBrush *fill) -{ - TQPen oldPen = p->pen(); - int x2 = x+w-1; - int y2 = y+h-1; - p->fillRect(x+1, y+1, w-2, h-2, - fill ? *fill : g.brush(TQColorGroup::Button)); - p->setPen(sunken ? Qt::black : g.light()); - p->drawLine(x, y, x2-1, y); - p->drawLine(x, y, x, y2-1); - p->setPen(sunken ? g.midlight() : g.mid()); - p->drawLine(x+1, y2-1, x2-1, y2-1); - p->drawLine(x2-1, y+1, x2-1, y2-1); - p->setPen(sunken ? g.light() : Qt::black); - p->drawLine(x, y2, x2, y2); - p->drawLine(x2, y, x2, y2); - p->setPen(oldPen); -} - - -KDEFX_EXPORT void kDrawNextButton(TQPainter *p, const TQRect &r, const TQColorGroup &g, - bool sunken, const TQBrush *fill) -{ - kDrawNextButton(p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill); -} - -KDEFX_EXPORT void kDrawBeButton(TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken, const TQBrush *fill) -{ - TQPen oldPen = p->pen(); - int x2 = x+w-1; - int y2 = y+h-1; - p->setPen(g.dark()); - p->drawLine(x+1, y, x2-1, y); - p->drawLine(x, y+1, x, y2-1); - p->drawLine(x+1, y2, x2-1, y2); - p->drawLine(x2, y+1, x2, y2-1); - - - if(!sunken){ - p->setPen(g.light()); - p->drawLine(x+2, y+2, x2-1, y+2); - p->drawLine(x+2, y+3, x2-2, y+3); - p->drawLine(x+2, y+4, x+2, y2-1); - p->drawLine(x+3, y+4, x+3, y2-2); - } - else{ - p->setPen(g.mid()); - p->drawLine(x+2, y+2, x2-1, y+2); - p->drawLine(x+2, y+3, x2-2, y+3); - p->drawLine(x+2, y+4, x+2, y2-1); - p->drawLine(x+3, y+4, x+3, y2-2); - } - - - p->setPen(sunken? g.light() : g.mid()); - p->drawLine(x2-1, y+2, x2-1, y2-1); - p->drawLine(x+2, y2-1, x2-1, y2-1); - - p->setPen(g.mid()); - p->drawLine(x+1, y+1, x2-1, y+1); - p->drawLine(x+1, y+2, x+1, y2-1); - p->drawLine(x2-2, y+3, x2-2, y2-2); - - if(fill) - p->fillRect(x+4, y+4, w-6, h-6, *fill); - - p->setPen(oldPen); -} - -KDEFX_EXPORT void kDrawBeButton(TQPainter *p, TQRect &r, const TQColorGroup &g, bool sunken, - const TQBrush *fill) -{ - kDrawBeButton(p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill); -} - -KDEFX_EXPORT void kDrawRoundButton(TQPainter *p, const TQRect &r, const TQColorGroup &g, - bool sunken) -{ - int x, y, x2, y2; - r.coords(&x, &y, &x2, &y2); - if(r.width() > 16 && r.height() > 16){ - TQPen oldPen = p->pen(); - TQPointArray hPntArray, lPntArray; - hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left - x+3,y+2, x+2,y+3, x+1,y+4, x+1,y+5, - x+1,y2-5, x+1,y2-4, x+2,y2-3, // half corners - x2-5,y+1, x2-4,y+1, x2-3,y+2); - - lPntArray.putPoints(0, 17, x2-5,y2-1, x2-4,y2-1, // btm right - x2-3,y2-2, x2-2,y2-3, x2-1,y2-5, x2-1,y2-4, - - x+3,y2-2, x+4,y2-1, x+5,y2-1, //half corners - x2-2,y+3, x2-1,y+4, x2-1,y+5, - - x2-5,y2-2, x2-4,y2-2, // testing - x2-3,y2-3, - x2-2,y2-5, x2-2,y2-4); - - p->setPen(sunken ? g.dark() : g.light()); - p->drawLine(x+6, y, x2-6, y); - p->drawLine(0, y+6, 0, y2-6); - p->drawPoints(hPntArray); - - p->setPen(sunken ? g.light() : g.dark()); - p->drawLine(x+6, y2, x2-6, y2); - p->drawLine(x+6, y2-1, x2-6, y2-1); - p->drawLine(x2, y+6, x2, y2-6); - p->drawLine(x2-1, y+6, x2-1, y2-6); - p->drawPoints(lPntArray); - p->setPen(oldPen); - } - else - qDrawWinPanel(p, x, y, r.width(), r.height(), g, sunken); -} - -KDEFX_EXPORT void kDrawRoundButton(TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken) -{ - TQRect r(x, y, w, h); - kDrawRoundButton(p, r, g, sunken); -} - -#define QCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2) - -KDEFX_EXPORT void kDrawRoundMask(TQPainter *p, int x, int y, int w, int h, bool clear) -{ - // round edge fills - static const TQCOORD btm_left_fill[]={ 0,0,1,0,2,0,3,0,4,0,0,1,1,1,2,1,3,1,4,1, - 1,2,2,2,3,2,4,2,2,3,3,3,4,3,3,4,4,4 }; - - static const TQCOORD btm_right_fill[]={ 0,0,1,0,2,0,3,0,4,0,0,1,1,1,2,1,3,1,4, - 1,0,2,1,2,2,2,3,2,0,3,1,3,2,3,0,4,1,4 }; - - static const TQCOORD top_left_fill[]={ 3,0,4,0,2,1,3,1,4,1,1,2,2,2,3,2,4,2,0,3, - 1,3,2,3,3,3,4,3,0,4,1,4,2,4,3,4,4,4 }; - - static const TQCOORD top_right_fill[]={ 0,0,1,0,0,1,1,1,2,1,0,2,1,2,2,2,3,2,0, - 3,1,3,2,3,3,3,4,3,0,4,1,4,2,4,3,4,4,4 }; - - if(clear) - p->fillRect(x, y, w, h, TQBrush(Qt::color0, Qt::SolidPattern)); - - TQBrush fillBrush(Qt::color1, Qt::SolidPattern); - p->setPen(Qt::color1); - if(w > 16 && h > 16){ - int x2 = x+w-1; - int y2 = y+h-1; - TQPointArray a(QCOORDARRLEN(top_left_fill), top_left_fill); - a.translate(1, 1); - p->drawPoints(a); - a.setPoints(QCOORDARRLEN(btm_left_fill), btm_left_fill); - a.translate(1, h-6); - p->drawPoints(a); - a.setPoints(QCOORDARRLEN(top_right_fill), top_right_fill); - a.translate(w-6, 1); - p->drawPoints(a); - a.setPoints(QCOORDARRLEN(btm_right_fill), btm_right_fill); - a.translate(w-6, h-6); - p->drawPoints(a); - - p->fillRect(x+6, y, w-12, h, fillBrush); - p->fillRect(x, y+6, x+6, h-12, fillBrush); - p->fillRect(x2-6, y+6, x2, h-12, fillBrush); - p->drawLine(x+6, y, x2-6, y); - p->drawLine(x+6, y2, x2-6, y2); - p->drawLine(x, y+6, x, y2-6); - p->drawLine(x2, y+6, x2, y2-6); - - } - else - p->fillRect(x, y, w, h, fillBrush); -} - -KDEFX_EXPORT void kRoundMaskRegion(TQRegion &r, int x, int y, int w, int h) -{ - // using a bunch of TQRect lines seems much more efficient than bitmaps or - // point arrays, even tho it uses more statements - r += TQRect(x+6, y+0, w-12, h); - r += TQRect(x+5, y+1, 1, h-2); // left - r += TQRect(x+4, y+1, 1, h-2); - r += TQRect(x+3, y+2, 1, h-4); - r += TQRect(x+2, y+3, 1, h-6); - r += TQRect(x+1, y+4, 1, h-8); - r += TQRect(x, y+6, 1, h-12); - int x2 = x+w-1; - r += TQRect(x2-5, y+1, 1, h-2); // right - r += TQRect(x2-4, y+1, 1, h-2); - r += TQRect(x2-3, y+2, 1, h-4); - r += TQRect(x2-2, y+3, 1, h-6); - r += TQRect(x2-1, y+4, 1, h-8); - r += TQRect(x2, y+6, 1, h-12); -} - -KDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y, - TQBitmap *lightColor, TQBitmap *midColor, - TQBitmap *midlightColor, TQBitmap *darkColor, - TQBitmap *blackColor, TQBitmap *whiteColor) -{ - TQBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor, - blackColor, whiteColor}; - - TQColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(), - Qt::black, Qt::white}; - - int i; - for(i=0; i < 6; ++i){ - if(bitmaps[i]){ - if(!bitmaps[i]->mask()) - bitmaps[i]->setMask(*bitmaps[i]); - p->setPen(colors[i]); - p->drawPixmap(x, y, *bitmaps[i]); - } - } -} - -KDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y, int w, - int h, bool isXBitmaps, const uchar *lightColor, - const uchar *midColor, const uchar *midlightColor, - const uchar *darkColor, const uchar *blackColor, - const uchar *whiteColor) -{ - const uchar *data[]={lightColor, midColor, midlightColor, darkColor, - blackColor, whiteColor}; - - TQColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(), - Qt::black, Qt::white}; - - int i; - TQBitmap b; - for(i=0; i < 6; ++i){ - if(data[i]){ - b = TQBitmap(w, h, data[i], isXBitmaps); - b.setMask(b); - p->setPen(colors[i]); - p->drawPixmap(x, y, b); - } - } -} - - - diff --git a/kdefx/kdrawutil.h b/kdefx/kdrawutil.h deleted file mode 100644 index 6aa0f3c44..000000000 --- a/kdefx/kdrawutil.h +++ /dev/null @@ -1,180 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> - - 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 __KDRAWUTIL_H -#define __KDRAWUTIL_H - -#include <tqnamespace.h> -#include <tqpainter.h> -#include <tqbitmap.h> -#include <tqpalette.h> - -#include <kdelibs_export.h> - -/* - * Various drawing routines. Also see Qt's tqdrawutil.h for some more routines - * contained in Qt. - * - * (C) Daniel M. Duley <mosfet@kde.org> - */ - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * - * Draws a Next-style button (solid black shadow with light and midlight highlight). - * - * @param p The painter to use for drawing the button. - * @param r Specifies the rect in which to draw the button. - * @param g Specifies the shading colors. - * @param sunken Whether to draw the button as sunken (pressed) or not. - * @param fill The brush to use for filling the interior of the button. - * Pass @a null to prevent the button from being filled. - */ -KDEFX_EXPORT void kDrawNextButton(TQPainter *p, const TQRect &r, const TQColorGroup &g, - bool sunken=false, const TQBrush *fill=0); - -/** - * @relates KStyle - * @overload - */ -KDEFX_EXPORT void kDrawNextButton(TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken=false, - const TQBrush *fill=0); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * - * Draws a Be-style button. - * - * @param p The painter to use for drawing the button. - * @param r Specifies the rect in which to draw the button. - * @param g Specifies the shading colors. - * @param sunken Whether to draw the button as sunken (pressed) or not. - * @param fill The brush to use for filling the interior of the button. - * Pass @a null to prevent the button from being filled. - */ -KDEFX_EXPORT void kDrawBeButton(TQPainter *p, TQRect &r, const TQColorGroup &g, - bool sunken=false, const TQBrush *fill=0); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * @overload - */ -KDEFX_EXPORT void kDrawBeButton(TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken=false, - const TQBrush *fill=0); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * - * Draws a rounded oval button. This function doesn't fill the button. - * See kRoundMaskRegion() for setting masks for fills. - * - * @param p The painter to use for drawing the button. - * @param r Specifies the rect in which to draw the button. - * @param g Specifies the shading colors. - * @param sunken Whether to draw the button as sunken (pressed) or not. - */ -KDEFX_EXPORT void kDrawRoundButton(TQPainter *p, const TQRect &r, const TQColorGroup &g, - bool sunken=false); - -/** - * @relates KStyle - * @overload - */ -KDEFX_EXPORT void kDrawRoundButton(TQPainter *p, int x, int y, int w, int h, - const TQColorGroup &g, bool sunken=false); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * - * Sets a region to the pixels covered by a round button of the given - * size. You can use this to set clipping regions. - * - * @param r Reference to the region to set. - * @param x The X coordinate of the button. - * @param y The Y coordinate of the button. - * @param w The width of the button. - * @param h The height of the button. - * - * @see kDrawRoundButton() and kDrawRoundMask() - */ -KDEFX_EXPORT void kRoundMaskRegion(TQRegion &r, int x, int y, int w, int h); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * - * Paints the pixels covered by a round button of the given size with - * Qt::color1. This function is useful in TQStyle::tqdrawControlMask(). - * - * @param p The painter to use for drawing the button. - * @param x The X coordinate of the button. - * @param y The Y coordinate of the button. - * @param w The width of the button. - * @param h The height of the button. - * @param clear Whether to clear the rectangle specified by @p (x, y, w, h) to - * Qt::color0 before drawing the mask. - */ -KDEFX_EXPORT void kDrawRoundMask(TQPainter *p, int x, int y, int w, int h, bool clear=false); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * - * Paints the provided bitmaps in the painter, using the supplied colorgroup for - * the foreground colors. There's one bitmap for each color. If you want to skip - * a color, pass @a null for the corresponding bitmap. - * - * @note The bitmaps will be self-masked automatically if not masked - * prior to calling this routine. - * - * @param p The painter to use for drawing the bitmaps. - * @param g Specifies the shading colors. - * @param x The X coordinate at which to draw the bitmaps. - * @param y The Y coordinate at which to draw the bitmaps. - * @param lightColor The bitmap to use for the light part. - * @param midColor The bitmap to use for the mid part. - * @param midlightColor The bitmap to use for the midlight part. - * @param darkColor The bitmap to use for the dark part. - * @param blackColor The bitmap to use for the black part. - * @param whiteColor The bitmap to use for the white part. - * - * @see QColorGroup - */ -KDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y, - TQBitmap *lightColor=0, TQBitmap *midColor=0, - TQBitmap *midlightColor=0, TQBitmap *darkColor=0, - TQBitmap *blackColor=0, TQBitmap *whiteColor=0); - -/** - * @relates KStyle - * @c \#include @c <kdrawutil.h> - * @overload - */ - KDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y, int w, - int h, bool isXBitmaps=true, const uchar *lightColor = 0, - const uchar *midColor=0, const uchar *midlightColor=0, - const uchar *darkColor=0, const uchar *blackColor=0, - const uchar *whiteColor=0); - -#endif diff --git a/kdefx/kimageeffect.cpp b/kdefx/kimageeffect.cpp deleted file mode 100644 index d2955403a..000000000 --- a/kdefx/kimageeffect.cpp +++ /dev/null @@ -1,4980 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@kde.org> - (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> - (C) 1998, 1999 Dirk Mueller <mueller@kde.org> - (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl> - (C) 2000 Josef Weidendorfer <weidendo@in.tum.de> - (C) 2004 Zack Rusin <zack@kde.org> - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -// $Id$ - -#include <math.h> -#include <assert.h> - -#include <tqimage.h> -#include <stdlib.h> -#include <iostream> - -#include "kimageeffect.h" -#include "kcpuinfo.h" - -#include <config.h> - -#if 0 -//disabled until #74478 fixed. - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) -# if defined( HAVE_X86_MMX ) -# define USE_MMX_INLINE_ASM -# endif -# if defined( HAVE_X86_SSE2 ) -# define USE_SSE2_INLINE_ASM -# endif -#endif - -#endif -//====================================================================== -// -// Utility stuff for effects ported from ImageMagick to QImage -// -//====================================================================== -#define MaxRGB 255L -#define DegreesToRadians(x) ((x)*M_PI/180.0) -#define MagickSQ2PI 2.50662827463100024161235523934010416269302368164062 -#define MagickEpsilon 1.0e-12 -#define MagickPI 3.14159265358979323846264338327950288419716939937510 -#define MOD(x, y) ((x) < 0 ? ((y) - 1 - ((y) - 1 - (x)) % (y)) : (x) % (y)) - -/** - * \relates KGlobal - * A typesafe function that returns x if it's between low and high values. - * low if x is smaller than then low and high if x is bigger than high. - */ -#define FXCLAMP(x,low,high) fxClamp(x,low,high) -template<class T> -inline const T& fxClamp( const T& x, const T& low, const T& high ) -{ - if ( x < low ) return low; - else if ( x > high ) return high; - else return x; -} - -static inline unsigned int intensityValue(unsigned int color) -{ - return((unsigned int)((0.299*tqRed(color) + - 0.587*tqGreen(color) + - 0.1140000000000001*tqBlue(color)))); -} - -template<typename T> -static inline void liberateMemory(T **memory) -{ - assert(memory != NULL); - if(*memory == NULL) return; - free((char*)*memory); - *memory=NULL; -} - -struct double_packet -{ - double red; - double green; - double blue; - double alpha; -}; - -struct short_packet -{ - unsigned short int red; - unsigned short int green; - unsigned short int blue; - unsigned short int alpha; -}; - - -//====================================================================== -// -// Gradient effects -// -//====================================================================== - -TQImage KImageEffect::gradient(const TQSize &size, const TQColor &ca, - const TQColor &cb, GradientType eff, int ncols) -{ - int rDiff, gDiff, bDiff; - int rca, gca, bca, rcb, gcb, bcb; - - TQImage image(size, 32); - - if (size.width() == 0 || size.height() == 0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::gradient: invalid image" << std::endl; -#endif - return image; - } - - register int x, y; - - rDiff = (rcb = cb.red()) - (rca = ca.red()); - gDiff = (gcb = cb.green()) - (gca = ca.green()); - bDiff = (bcb = cb.blue()) - (bca = ca.blue()); - - if( eff == VerticalGradient || eff == HorizontalGradient ){ - - uint *p; - uint rgb; - - register int rl = rca << 16; - register int gl = gca << 16; - register int bl = bca << 16; - - if( eff == VerticalGradient ) { - - int rcdelta = ((1<<16) / size.height()) * rDiff; - int gcdelta = ((1<<16) / size.height()) * gDiff; - int bcdelta = ((1<<16) / size.height()) * bDiff; - - for ( y = 0; y < size.height(); y++ ) { - p = (uint *) image.scanLine(y); - - rl += rcdelta; - gl += gcdelta; - bl += bcdelta; - - rgb = tqRgb( (rl>>16), (gl>>16), (bl>>16) ); - - for( x = 0; x < size.width(); x++ ) { - *p = rgb; - p++; - } - } - - } - else { // must be HorizontalGradient - - unsigned int *o_src = (unsigned int *)image.scanLine(0); - unsigned int *src = o_src; - - int rcdelta = ((1<<16) / size.width()) * rDiff; - int gcdelta = ((1<<16) / size.width()) * gDiff; - int bcdelta = ((1<<16) / size.width()) * bDiff; - - for( x = 0; x < size.width(); x++) { - - rl += rcdelta; - gl += gcdelta; - bl += bcdelta; - - *src++ = tqRgb( (rl>>16), (gl>>16), (bl>>16)); - } - - src = o_src; - - // Believe it or not, manually copying in a for loop is faster - // than calling memcpy for each scanline (on the order of ms...). - // I think this is due to the function call overhead (mosfet). - - for (y = 1; y < size.height(); ++y) { - - p = (unsigned int *)image.scanLine(y); - src = o_src; - for(x=0; x < size.width(); ++x) - *p++ = *src++; - } - } - } - - else { - - float rfd, gfd, bfd; - float rd = rca, gd = gca, bd = bca; - - unsigned char *xtable[3]; - unsigned char *ytable[3]; - - unsigned int w = size.width(), h = size.height(); - xtable[0] = new unsigned char[w]; - xtable[1] = new unsigned char[w]; - xtable[2] = new unsigned char[w]; - ytable[0] = new unsigned char[h]; - ytable[1] = new unsigned char[h]; - ytable[2] = new unsigned char[h]; - w*=2, h*=2; - - if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) { - // Diagonal dgradient code inspired by BlackBox (mosfet) - // BlackBox dgradient is (C) Brad Hughes, <bhughes@tcac.net> and - // Mike Cole <mike@mydot.com>. - - rfd = (float)rDiff/w; - gfd = (float)gDiff/w; - bfd = (float)bDiff/w; - - int dir; - for (x = 0; x < size.width(); x++, rd+=rfd, gd+=gfd, bd+=bfd) { - dir = eff == DiagonalGradient? x : size.width() - x - 1; - xtable[0][dir] = (unsigned char) rd; - xtable[1][dir] = (unsigned char) gd; - xtable[2][dir] = (unsigned char) bd; - } - rfd = (float)rDiff/h; - gfd = (float)gDiff/h; - bfd = (float)bDiff/h; - rd = gd = bd = 0; - for (y = 0; y < size.height(); y++, rd+=rfd, gd+=gfd, bd+=bfd) { - ytable[0][y] = (unsigned char) rd; - ytable[1][y] = (unsigned char) gd; - ytable[2][y] = (unsigned char) bd; - } - - for (y = 0; y < size.height(); y++) { - unsigned int *scanline = (unsigned int *)image.scanLine(y); - for (x = 0; x < size.width(); x++) { - scanline[x] = tqRgb(xtable[0][x] + ytable[0][y], - xtable[1][x] + ytable[1][y], - xtable[2][x] + ytable[2][y]); - } - } - } - - else if (eff == RectangleGradient || - eff == PyramidGradient || - eff == PipeCrossGradient || - eff == EllipticGradient) - { - int rSign = rDiff>0? 1: -1; - int gSign = gDiff>0? 1: -1; - int bSign = bDiff>0? 1: -1; - - rfd = (float)rDiff / size.width(); - gfd = (float)gDiff / size.width(); - bfd = (float)bDiff / size.width(); - - rd = (float)rDiff/2; - gd = (float)gDiff/2; - bd = (float)bDiff/2; - - for (x = 0; x < size.width(); x++, rd-=rfd, gd-=gfd, bd-=bfd) - { - xtable[0][x] = (unsigned char) abs((int)rd); - xtable[1][x] = (unsigned char) abs((int)gd); - xtable[2][x] = (unsigned char) abs((int)bd); - } - - rfd = (float)rDiff/size.height(); - gfd = (float)gDiff/size.height(); - bfd = (float)bDiff/size.height(); - - rd = (float)rDiff/2; - gd = (float)gDiff/2; - bd = (float)bDiff/2; - - for (y = 0; y < size.height(); y++, rd-=rfd, gd-=gfd, bd-=bfd) - { - ytable[0][y] = (unsigned char) abs((int)rd); - ytable[1][y] = (unsigned char) abs((int)gd); - ytable[2][y] = (unsigned char) abs((int)bd); - } - - int h = (size.height()+1)>>1; - for (y = 0; y < h; y++) { - unsigned int *sl1 = (unsigned int *)image.scanLine(y); - unsigned int *sl2 = (unsigned int *)image.scanLine(QMAX(size.height()-y-1, y)); - - int w = (size.width()+1)>>1; - int x2 = size.width()-1; - - for (x = 0; x < w; x++, x2--) { - unsigned int rgb = 0; - if (eff == PyramidGradient) { - rgb = tqRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), - gcb-gSign*(xtable[1][x]+ytable[1][y]), - bcb-bSign*(xtable[2][x]+ytable[2][y])); - } - if (eff == RectangleGradient) { - rgb = tqRgb(rcb - rSign * - QMAX(xtable[0][x], ytable[0][y]) * 2, - gcb - gSign * - QMAX(xtable[1][x], ytable[1][y]) * 2, - bcb - bSign * - QMAX(xtable[2][x], ytable[2][y]) * 2); - } - if (eff == PipeCrossGradient) { - rgb = tqRgb(rcb - rSign * - QMIN(xtable[0][x], ytable[0][y]) * 2, - gcb - gSign * - QMIN(xtable[1][x], ytable[1][y]) * 2, - bcb - bSign * - QMIN(xtable[2][x], ytable[2][y]) * 2); - } - if (eff == EllipticGradient) { - rgb = tqRgb(rcb - rSign * - (int)sqrt((xtable[0][x]*xtable[0][x] + - ytable[0][y]*ytable[0][y])*2.0), - gcb - gSign * - (int)sqrt((xtable[1][x]*xtable[1][x] + - ytable[1][y]*ytable[1][y])*2.0), - bcb - bSign * - (int)sqrt((xtable[2][x]*xtable[2][x] + - ytable[2][y]*ytable[2][y])*2.0)); - } - - sl1[x] = sl2[x] = rgb; - sl1[x2] = sl2[x2] = rgb; - } - } - } - - delete [] xtable[0]; - delete [] xtable[1]; - delete [] xtable[2]; - delete [] ytable[0]; - delete [] ytable[1]; - delete [] ytable[2]; - } - - // dither if necessary - if (ncols && (TQPixmap::defaultDepth() < 15 )) { - if ( ncols < 2 || ncols > 256 ) - ncols = 3; - TQColor *dPal = new TQColor[ncols]; - for (int i=0; i<ncols; i++) { - dPal[i].setRgb ( rca + rDiff * i / ( ncols - 1 ), - gca + gDiff * i / ( ncols - 1 ), - bca + bDiff * i / ( ncols - 1 ) ); - } - dither(image, dPal, ncols); - delete [] dPal; - } - - return image; -} - - -// ----------------------------------------------------------------------------- - -//CT this was (before Dirk A. Mueller's speedup changes) -// merely the same code as in the above method, but it's supposedly -// way less performant since it introduces a lot of supplementary tests -// and simple math operations for the calculus of the balance. -// (surprizingly, it isn't less performant, in the contrary :-) -// Yes, I could have merged them, but then the excellent performance of -// the balanced code would suffer with no other gain than a mere -// source code and byte code size economy. - -TQImage KImageEffect::unbalancedGradient(const TQSize &size, const TQColor &ca, - const TQColor &cb, GradientType eff, int xfactor, int yfactor, - int ncols) -{ - int dir; // general parameter used for direction switches - - bool _xanti = false , _yanti = false; - - if (xfactor < 0) _xanti = true; // negative on X direction - if (yfactor < 0) _yanti = true; // negative on Y direction - - xfactor = abs(xfactor); - yfactor = abs(yfactor); - - if (!xfactor) xfactor = 1; - if (!yfactor) yfactor = 1; - - if (xfactor > 200 ) xfactor = 200; - if (yfactor > 200 ) yfactor = 200; - - - // float xbal = xfactor/5000.; - // float ybal = yfactor/5000.; - float xbal = xfactor/30./size.width(); - float ybal = yfactor/30./size.height(); - float rat; - - int rDiff, gDiff, bDiff; - int rca, gca, bca, rcb, gcb, bcb; - - TQImage image(size, 32); - - if (size.width() == 0 || size.height() == 0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::unbalancedGradient : invalid image\n"; -#endif - return image; - } - - register int x, y; - unsigned int *scanline; - - rDiff = (rcb = cb.red()) - (rca = ca.red()); - gDiff = (gcb = cb.green()) - (gca = ca.green()); - bDiff = (bcb = cb.blue()) - (bca = ca.blue()); - - if( eff == VerticalGradient || eff == HorizontalGradient){ - TQColor cRow; - - uint *p; - uint rgbRow; - - if( eff == VerticalGradient) { - for ( y = 0; y < size.height(); y++ ) { - dir = _yanti ? y : size.height() - 1 - y; - p = (uint *) image.scanLine(dir); - rat = 1 - exp( - (float)y * ybal ); - - cRow.setRgb( rcb - (int) ( rDiff * rat ), - gcb - (int) ( gDiff * rat ), - bcb - (int) ( bDiff * rat ) ); - - rgbRow = cRow.rgb(); - - for( x = 0; x < size.width(); x++ ) { - *p = rgbRow; - p++; - } - } - } - else { - - unsigned int *src = (unsigned int *)image.scanLine(0); - for(x = 0; x < size.width(); x++ ) - { - dir = _xanti ? x : size.width() - 1 - x; - rat = 1 - exp( - (float)x * xbal ); - - src[dir] = tqRgb(rcb - (int) ( rDiff * rat ), - gcb - (int) ( gDiff * rat ), - bcb - (int) ( bDiff * rat )); - } - - // Believe it or not, manually copying in a for loop is faster - // than calling memcpy for each scanline (on the order of ms...). - // I think this is due to the function call overhead (mosfet). - - for(y = 1; y < size.height(); ++y) - { - scanline = (unsigned int *)image.scanLine(y); - for(x=0; x < size.width(); ++x) - scanline[x] = src[x]; - } - } - } - - else { - int w=size.width(), h=size.height(); - - unsigned char *xtable[3]; - unsigned char *ytable[3]; - xtable[0] = new unsigned char[w]; - xtable[1] = new unsigned char[w]; - xtable[2] = new unsigned char[w]; - ytable[0] = new unsigned char[h]; - ytable[1] = new unsigned char[h]; - ytable[2] = new unsigned char[h]; - - if ( eff == DiagonalGradient || eff == CrossDiagonalGradient) - { - for (x = 0; x < w; x++) { - dir = _xanti ? x : w - 1 - x; - rat = 1 - exp( - (float)x * xbal ); - - xtable[0][dir] = (unsigned char) ( rDiff/2 * rat ); - xtable[1][dir] = (unsigned char) ( gDiff/2 * rat ); - xtable[2][dir] = (unsigned char) ( bDiff/2 * rat ); - } - - for (y = 0; y < h; y++) { - dir = _yanti ? y : h - 1 - y; - rat = 1 - exp( - (float)y * ybal ); - - ytable[0][dir] = (unsigned char) ( rDiff/2 * rat ); - ytable[1][dir] = (unsigned char) ( gDiff/2 * rat ); - ytable[2][dir] = (unsigned char) ( bDiff/2 * rat ); - } - - for (y = 0; y < h; y++) { - unsigned int *scanline = (unsigned int *)image.scanLine(y); - for (x = 0; x < w; x++) { - scanline[x] = tqRgb(rcb - (xtable[0][x] + ytable[0][y]), - gcb - (xtable[1][x] + ytable[1][y]), - bcb - (xtable[2][x] + ytable[2][y])); - } - } - } - - else if (eff == RectangleGradient || - eff == PyramidGradient || - eff == PipeCrossGradient || - eff == EllipticGradient) - { - int rSign = rDiff>0? 1: -1; - int gSign = gDiff>0? 1: -1; - int bSign = bDiff>0? 1: -1; - - for (x = 0; x < w; x++) - { - dir = _xanti ? x : w - 1 - x; - rat = 1 - exp( - (float)x * xbal ); - - xtable[0][dir] = (unsigned char) abs((int)(rDiff*(0.5-rat))); - xtable[1][dir] = (unsigned char) abs((int)(gDiff*(0.5-rat))); - xtable[2][dir] = (unsigned char) abs((int)(bDiff*(0.5-rat))); - } - - for (y = 0; y < h; y++) - { - dir = _yanti ? y : h - 1 - y; - - rat = 1 - exp( - (float)y * ybal ); - - ytable[0][dir] = (unsigned char) abs((int)(rDiff*(0.5-rat))); - ytable[1][dir] = (unsigned char) abs((int)(gDiff*(0.5-rat))); - ytable[2][dir] = (unsigned char) abs((int)(bDiff*(0.5-rat))); - } - - for (y = 0; y < h; y++) { - unsigned int *scanline = (unsigned int *)image.scanLine(y); - for (x = 0; x < w; x++) { - if (eff == PyramidGradient) - { - scanline[x] = tqRgb(rcb-rSign*(xtable[0][x]+ytable[0][y]), - gcb-gSign*(xtable[1][x]+ytable[1][y]), - bcb-bSign*(xtable[2][x]+ytable[2][y])); - } - else if (eff == RectangleGradient) - { - scanline[x] = tqRgb(rcb - rSign * - QMAX(xtable[0][x], ytable[0][y]) * 2, - gcb - gSign * - QMAX(xtable[1][x], ytable[1][y]) * 2, - bcb - bSign * - QMAX(xtable[2][x], ytable[2][y]) * 2); - } - else if (eff == PipeCrossGradient) - { - scanline[x] = tqRgb(rcb - rSign * - QMIN(xtable[0][x], ytable[0][y]) * 2, - gcb - gSign * - QMIN(xtable[1][x], ytable[1][y]) * 2, - bcb - bSign * - QMIN(xtable[2][x], ytable[2][y]) * 2); - } - else if (eff == EllipticGradient) - { - scanline[x] = tqRgb(rcb - rSign * - (int)sqrt((xtable[0][x]*xtable[0][x] + - ytable[0][y]*ytable[0][y])*2.0), - gcb - gSign * - (int)sqrt((xtable[1][x]*xtable[1][x] + - ytable[1][y]*ytable[1][y])*2.0), - bcb - bSign * - (int)sqrt((xtable[2][x]*xtable[2][x] + - ytable[2][y]*ytable[2][y])*2.0)); - } - } - } - } - - if (ncols && (TQPixmap::defaultDepth() < 15 )) { - if ( ncols < 2 || ncols > 256 ) - ncols = 3; - TQColor *dPal = new TQColor[ncols]; - for (int i=0; i<ncols; i++) { - dPal[i].setRgb ( rca + rDiff * i / ( ncols - 1 ), - gca + gDiff * i / ( ncols - 1 ), - bca + bDiff * i / ( ncols - 1 ) ); - } - dither(image, dPal, ncols); - delete [] dPal; - } - - delete [] xtable[0]; - delete [] xtable[1]; - delete [] xtable[2]; - delete [] ytable[0]; - delete [] ytable[1]; - delete [] ytable[2]; - - } - - return image; -} - -/** -Types for MMX and SSE packing of colors, for safe constraints -*/ -namespace { - -struct KIE4Pack -{ - TQ_UINT16 data[4]; -}; - -struct KIE8Pack -{ - TQ_UINT16 data[8]; -}; - -} - -//====================================================================== -// -// Intensity effects -// -//====================================================================== - - -/* This builds a 256 byte unsigned char lookup table with all - * the possible percent values prior to applying the effect, then uses - * integer math for the pixels. For any image larger than 9x9 this will be - * less expensive than doing a float operation on the 3 color components of - * each pixel. (mosfet) - */ -TQImage& KImageEffect::intensity(TQImage &image, float percent) -{ - if (image.width() == 0 || image.height() == 0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::intensity : invalid image\n"; -#endif - return image; - } - - int segColors = image.depth() > 8 ? 256 : image.numColors(); - int pixels = image.depth() > 8 ? image.width()*image.height() : - image.numColors(); - unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : - (unsigned int *)image.tqcolorTable(); - - bool brighten = (percent >= 0); - if(percent < 0) - percent = -percent; - -#ifdef USE_MMX_INLINE_ASM - bool haveMMX = KCPUInfo::haveExtension( KCPUInfo::IntelMMX ); - - if(haveMMX) - { - TQ_UINT16 p = TQ_UINT16(256.0f*(percent)); - KIE4Pack mult = {{p,p,p,0}}; - - __asm__ __volatile__( - "pxor %%mm7, %%mm7\n\t" // zero mm7 for unpacking - "movq (%0), %%mm6\n\t" // copy intensity change to mm6 - : : "r"(&mult), "m"(mult)); - - unsigned int rem = pixels % 4; - pixels -= rem; - TQ_UINT32 *end = ( data + pixels ); - - if (brighten) - { - while ( data != end ) { - __asm__ __volatile__( - "movq (%0), %%mm0\n\t" - "movq 8(%0), %%mm4\n\t" // copy 4 pixels of data to mm0 and mm4 - "movq %%mm0, %%mm1\n\t" - "movq %%mm0, %%mm3\n\t" - "movq %%mm4, %%mm5\n\t" // copy to registers for unpacking - "punpcklbw %%mm7, %%mm0\n\t" - "punpckhbw %%mm7, %%mm1\n\t" // unpack the two pixels from mm0 - "pmullw %%mm6, %%mm0\n\t" - "punpcklbw %%mm7, %%mm4\n\t" - "pmullw %%mm6, %%mm1\n\t" // multiply by intensity*256 - "psrlw $8, %%mm0\n\t" // divide by 256 - "pmullw %%mm6, %%mm4\n\t" - "psrlw $8, %%mm1\n\t" - "psrlw $8, %%mm4\n\t" - "packuswb %%mm1, %%mm0\n\t" // pack solution into mm0. saturates at 255 - "movq %%mm5, %%mm1\n\t" - - "punpckhbw %%mm7, %%mm1\n\t" // unpack 4th pixel in mm1 - - "pmullw %%mm6, %%mm1\n\t" - "paddusb %%mm3, %%mm0\n\t" // add intesity result to original of mm0 - "psrlw $8, %%mm1\n\t" - "packuswb %%mm1, %%mm4\n\t" // pack upper two pixels into mm4 - - "movq %%mm0, (%0)\n\t" // rewrite to memory lower two pixels - "paddusb %%mm5, %%mm4\n\t" - "movq %%mm4, 8(%0)\n\t" // rewrite upper two pixels - : : "r"(data) ); - data += 4; - } - - end += rem; - while ( data != end ) { - __asm__ __volatile__( - "movd (%0), %%mm0\n\t" // repeat above but for - "punpcklbw %%mm7, %%mm0\n\t" // one pixel at a time - "movq %%mm0, %%mm3\n\t" - "pmullw %%mm6, %%mm0\n\t" - "psrlw $8, %%mm0\n\t" - "paddw %%mm3, %%mm0\n\t" - "packuswb %%mm0, %%mm0\n\t" - "movd %%mm0, (%0)\n\t" - : : "r"(data) ); - data++; - } - } - else - { - while ( data != end ) { - __asm__ __volatile__( - "movq (%0), %%mm0\n\t" - "movq 8(%0), %%mm4\n\t" - "movq %%mm0, %%mm1\n\t" - "movq %%mm0, %%mm3\n\t" - - "movq %%mm4, %%mm5\n\t" - - "punpcklbw %%mm7, %%mm0\n\t" - "punpckhbw %%mm7, %%mm1\n\t" - "pmullw %%mm6, %%mm0\n\t" - "punpcklbw %%mm7, %%mm4\n\t" - "pmullw %%mm6, %%mm1\n\t" - "psrlw $8, %%mm0\n\t" - "pmullw %%mm6, %%mm4\n\t" - "psrlw $8, %%mm1\n\t" - "psrlw $8, %%mm4\n\t" - "packuswb %%mm1, %%mm0\n\t" - "movq %%mm5, %%mm1\n\t" - - "punpckhbw %%mm7, %%mm1\n\t" - - "pmullw %%mm6, %%mm1\n\t" - "psubusb %%mm0, %%mm3\n\t" // subtract darkening amount - "psrlw $8, %%mm1\n\t" - "packuswb %%mm1, %%mm4\n\t" - - "movq %%mm3, (%0)\n\t" - "psubusb %%mm4, %%mm5\n\t" // only change for this version is - "movq %%mm5, 8(%0)\n\t" // subtraction here as we are darkening image - : : "r"(data) ); - data += 4; - } - - end += rem; - while ( data != end ) { - __asm__ __volatile__( - "movd (%0), %%mm0\n\t" - "punpcklbw %%mm7, %%mm0\n\t" - "movq %%mm0, %%mm3\n\t" - "pmullw %%mm6, %%mm0\n\t" - "psrlw $8, %%mm0\n\t" - "psubusw %%mm0, %%mm3\n\t" - "packuswb %%mm3, %%mm3\n\t" - "movd %%mm3, (%0)\n\t" - : : "r"(data) ); - data++; - } - } - __asm__ __volatile__("emms"); // clear mmx state - } - else -#endif // USE_MMX_INLINE_ASM - { - unsigned char *segTbl = new unsigned char[segColors]; - int tmp; - if(brighten){ // keep overflow check out of loops - for(int i=0; i < segColors; ++i){ - tmp = (int)(i*percent); - if(tmp > 255) - tmp = 255; - segTbl[i] = tmp; - } - } - else{ - for(int i=0; i < segColors; ++i){ - tmp = (int)(i*percent); - if(tmp < 0) - tmp = 0; - segTbl[i] = tmp; - } - } - - if(brighten){ // same here - for(int i=0; i < pixels; ++i){ - int r = tqRed(data[i]); - int g = tqGreen(data[i]); - int b = tqBlue(data[i]); - int a = tqAlpha(data[i]); - r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; - g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; - b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; - data[i] = tqRgba(r, g, b,a); - } - } - else{ - for(int i=0; i < pixels; ++i){ - int r = tqRed(data[i]); - int g = tqGreen(data[i]); - int b = tqBlue(data[i]); - int a = tqAlpha(data[i]); - r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; - g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; - b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; - data[i] = tqRgba(r, g, b, a); - } - } - delete [] segTbl; - } - - return image; -} - -TQImage& KImageEffect::channelIntensity(TQImage &image, float percent, - RGBComponent channel) -{ - if (image.width() == 0 || image.height() == 0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::channelIntensity : invalid image\n"; -#endif - return image; - } - - int segColors = image.depth() > 8 ? 256 : image.numColors(); - unsigned char *segTbl = new unsigned char[segColors]; - int pixels = image.depth() > 8 ? image.width()*image.height() : - image.numColors(); - unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : - (unsigned int *)image.tqcolorTable(); - bool brighten = (percent >= 0); - if(percent < 0) - percent = -percent; - - if(brighten){ // keep overflow check out of loops - for(int i=0; i < segColors; ++i){ - int tmp = (int)(i*percent); - if(tmp > 255) - tmp = 255; - segTbl[i] = tmp; - } - } - else{ - for(int i=0; i < segColors; ++i){ - int tmp = (int)(i*percent); - if(tmp < 0) - tmp = 0; - segTbl[i] = tmp; - } - } - - if(brighten){ // same here - if(channel == Red){ // and here ;-) - for(int i=0; i < pixels; ++i){ - int c = tqRed(data[i]); - c = c + segTbl[c] > 255 ? 255 : c + segTbl[c]; - data[i] = tqRgba(c, tqGreen(data[i]), tqBlue(data[i]), tqAlpha(data[i])); - } - } - else if(channel == Green){ - for(int i=0; i < pixels; ++i){ - int c = tqGreen(data[i]); - c = c + segTbl[c] > 255 ? 255 : c + segTbl[c]; - data[i] = tqRgba(tqRed(data[i]), c, tqBlue(data[i]), tqAlpha(data[i])); - } - } - else{ - for(int i=0; i < pixels; ++i){ - int c = tqBlue(data[i]); - c = c + segTbl[c] > 255 ? 255 : c + segTbl[c]; - data[i] = tqRgba(tqRed(data[i]), tqGreen(data[i]), c, tqAlpha(data[i])); - } - } - - } - else{ - if(channel == Red){ - for(int i=0; i < pixels; ++i){ - int c = tqRed(data[i]); - c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; - data[i] = tqRgba(c, tqGreen(data[i]), tqBlue(data[i]), tqAlpha(data[i])); - } - } - else if(channel == Green){ - for(int i=0; i < pixels; ++i){ - int c = tqGreen(data[i]); - c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; - data[i] = tqRgba(tqRed(data[i]), c, tqBlue(data[i]), tqAlpha(data[i])); - } - } - else{ - for(int i=0; i < pixels; ++i){ - int c = tqBlue(data[i]); - c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; - data[i] = tqRgba(tqRed(data[i]), tqGreen(data[i]), c, tqAlpha(data[i])); - } - } - } - delete [] segTbl; - - return image; -} - -// Modulate an image with an RBG channel of another image -// -TQImage& KImageEffect::modulate(TQImage &image, TQImage &modImage, bool reverse, - ModulationType type, int factor, RGBComponent channel) -{ - if (image.width() == 0 || image.height() == 0 || - modImage.width() == 0 || modImage.height() == 0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::modulate : invalid image\n"; -#endif - return image; - } - - int r, g, b, h, s, v, a; - TQColor clr; - int mod=0; - unsigned int x1, x2, y1, y2; - register int x, y; - - // for image, we handle only depth 32 - if (image.depth()<32) image = image.convertDepth(32); - - // for modImage, we handle depth 8 and 32 - if (modImage.depth()<8) modImage = modImage.convertDepth(8); - - unsigned int *colorTable2 = (modImage.depth()==8) ? - modImage.tqcolorTable():0; - unsigned int *data1, *data2; - unsigned char *data2b; - unsigned int color1, color2; - - x1 = image.width(); y1 = image.height(); - x2 = modImage.width(); y2 = modImage.height(); - - for (y = 0; y < (int)y1; y++) { - data1 = (unsigned int *) image.scanLine(y); - data2 = (unsigned int *) modImage.scanLine( y%y2 ); - data2b = (unsigned char *) modImage.scanLine( y%y2 ); - - x=0; - while(x < (int)x1) { - color2 = (colorTable2) ? colorTable2[*data2b] : *data2; - if (reverse) { - color1 = color2; - color2 = *data1; - } - else - color1 = *data1; - - if (type == Intensity || type == Contrast) { - r = tqRed(color1); - g = tqGreen(color1); - b = tqBlue(color1); - if (channel != All) { - mod = (channel == Red) ? tqRed(color2) : - (channel == Green) ? tqGreen(color2) : - (channel == Blue) ? tqBlue(color2) : - (channel == Gray) ? tqGray(color2) : 0; - mod = mod*factor/50; - } - - if (type == Intensity) { - if (channel == All) { - r += r * factor/50 * tqRed(color2)/256; - g += g * factor/50 * tqGreen(color2)/256; - b += b * factor/50 * tqBlue(color2)/256; - } - else { - r += r * mod/256; - g += g * mod/256; - b += b * mod/256; - } - } - else { // Contrast - if (channel == All) { - r += (r-128) * factor/50 * tqRed(color2)/128; - g += (g-128) * factor/50 * tqGreen(color2)/128; - b += (b-128) * factor/50 * tqBlue(color2)/128; - } - else { - r += (r-128) * mod/128; - g += (g-128) * mod/128; - b += (b-128) * mod/128; - } - } - - if (r<0) r=0; if (r>255) r=255; - if (g<0) g=0; if (g>255) g=255; - if (b<0) b=0; if (b>255) b=255; - a = tqAlpha(*data1); - *data1 = tqRgba(r, g, b, a); - } - else if (type == Saturation || type == HueShift) { - clr.setRgb(color1); - clr.hsv(&h, &s, &v); - mod = (channel == Red) ? tqRed(color2) : - (channel == Green) ? tqGreen(color2) : - (channel == Blue) ? tqBlue(color2) : - (channel == Gray) ? tqGray(color2) : 0; - mod = mod*factor/50; - - if (type == Saturation) { - s -= s * mod/256; - if (s<0) s=0; if (s>255) s=255; - } - else { // HueShift - h += mod; - while(h<0) h+=360; - h %= 360; - } - - clr.setHsv(h, s, v); - a = tqAlpha(*data1); - *data1 = clr.rgb() | ((uint)(a & 0xff) << 24); - } - data1++; data2++; data2b++; x++; - if ( (x%x2) ==0) { data2 -= x2; data2b -= x2; } - } - } - return image; -} - - - -//====================================================================== -// -// Blend effects -// -//====================================================================== - - -// Nice and fast direct pixel manipulation -TQImage& KImageEffect::blend(const TQColor& clr, TQImage& dst, float opacity) -{ - if (dst.width() <= 0 || dst.height() <= 0) - return dst; - - if (opacity < 0.0 || opacity > 1.0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::blend : invalid opacity. Range [0, 1]\n"; -#endif - return dst; - } - - if (dst.depth() != 32) - dst = dst.convertDepth(32); - -#ifdef USE_QT4 - if (dst.format() != QImage::Format_ARGB32) - dst = dst.convertToFormat(QImage::Format_ARGB32); // This is needed because Qt4 has multiple variants with a 32 bit depth, and the routines below expect one specific variant (ARGB) -#endif - - int pixels = dst.width() * dst.height(); - -#ifdef USE_SSE2_INLINE_ASM - if ( KCPUInfo::haveExtension( KCPUInfo::IntelSSE2 ) && pixels > 16 ) { - TQ_UINT16 alpha = TQ_UINT16( ( 1.0 - opacity ) * 256.0 ); - - KIE8Pack packedalpha = { { alpha, alpha, alpha, 256, - alpha, alpha, alpha, 256 } }; - - TQ_UINT16 red = TQ_UINT16( clr.red() * 256 * opacity ); - TQ_UINT16 green = TQ_UINT16( clr.green() * 256 * opacity ); - TQ_UINT16 blue = TQ_UINT16( clr.blue() * 256 * opacity ); - - KIE8Pack packedcolor = { { blue, green, red, 0, - blue, green, red, 0 } }; - - // Prepare the XMM5, XMM6 and XMM7 registers for unpacking and blending - __asm__ __volatile__( - "pxor %%xmm7, %%xmm7\n\t" // Zero out XMM7 for unpacking - "movdqu (%0), %%xmm6\n\t" // Set up (1 - alpha) * 256 in XMM6 - "movdqu (%1), %%xmm5\n\t" // Set up color * alpha * 256 in XMM5 - : : "r"(&packedalpha), "r"(&packedcolor), - "m"(packedcolor), "m"(packedalpha) ); - - TQ_UINT32 *data = reinterpret_cast<TQ_UINT32*>( dst.bits() ); - - // Check how many pixels we need to process to achieve 16 byte tqalignment - int offset = (16 - (TQ_UINT32( data ) & 0x0f)) / 4; - - // The main loop processes 8 pixels / iteration - int remainder = (pixels - offset) % 8; - pixels -= remainder; - - // Alignment loop - for ( int i = 0; i < offset; i++ ) { - __asm__ __volatile__( - "movd (%0,%1,4), %%xmm0\n\t" // Load one pixel to XMM1 - "punpcklbw %%xmm7, %%xmm0\n\t" // Unpack the pixel - "pmullw %%xmm6, %%xmm0\n\t" // Multiply the pixel with (1 - alpha) * 256 - "paddw %%xmm5, %%xmm0\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%xmm0\n\t" // Divide by 256 - "packuswb %%xmm1, %%xmm0\n\t" // Pack the pixel to a dword - "movd %%xmm0, (%0,%1,4)\n\t" // Write the pixel to the image - : : "r"(data), "r"(i) ); - } - - // Main loop - for ( int i = offset; i < pixels; i += 8 ) { - __asm__ __volatile( - // Load 8 pixels to XMM registers 1 - 4 - "movq (%0,%1,4), %%xmm0\n\t" // Load pixels 1 and 2 to XMM1 - "movq 8(%0,%1,4), %%xmm1\n\t" // Load pixels 3 and 4 to XMM2 - "movq 16(%0,%1,4), %%xmm2\n\t" // Load pixels 5 and 6 to XMM3 - "movq 24(%0,%1,4), %%xmm3\n\t" // Load pixels 7 and 8 to XMM4 - - // Prefetch the pixels for next iteration - "prefetchnta 32(%0,%1,4) \n\t" - - // Blend pixels 1 and 2 - "punpcklbw %%xmm7, %%xmm0\n\t" // Unpack the pixels - "pmullw %%xmm6, %%xmm0\n\t" // Multiply the pixels with (1 - alpha) * 256 - "paddw %%xmm5, %%xmm0\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%xmm0\n\t" // Divide by 256 - - // Blend pixels 3 and 4 - "punpcklbw %%xmm7, %%xmm1\n\t" // Unpack the pixels - "pmullw %%xmm6, %%xmm1\n\t" // Multiply the pixels with (1 - alpha) * 256 - "paddw %%xmm5, %%xmm1\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%xmm1\n\t" // Divide by 256 - - // Blend pixels 5 and 6 - "punpcklbw %%xmm7, %%xmm2\n\t" // Unpack the pixels - "pmullw %%xmm6, %%xmm2\n\t" // Multiply the pixels with (1 - alpha) * 256 - "paddw %%xmm5, %%xmm2\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%xmm2\n\t" // Divide by 256 - - // Blend pixels 7 and 8 - "punpcklbw %%xmm7, %%xmm3\n\t" // Unpack the pixels - "pmullw %%xmm6, %%xmm3\n\t" // Multiply the pixels with (1 - alpha) * 256 - "paddw %%xmm5, %%xmm3\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%xmm3\n\t" // Divide by 256 - - // Pack the pixels into 2 double quadwords - "packuswb %%xmm1, %%xmm0\n\t" // Pack pixels 1 - 4 to a double qword - "packuswb %%xmm3, %%xmm2\n\t" // Pack pixles 5 - 8 to a double qword - - // Write the pixels back to the image - "movdqa %%xmm0, (%0,%1,4)\n\t" // Store pixels 1 - 4 - "movdqa %%xmm2, 16(%0,%1,4)\n\t" // Store pixels 5 - 8 - : : "r"(data), "r"(i) ); - } - - // Cleanup loop - for ( int i = pixels; i < pixels + remainder; i++ ) { - __asm__ __volatile__( - "movd (%0,%1,4), %%xmm0\n\t" // Load one pixel to XMM1 - "punpcklbw %%xmm7, %%xmm0\n\t" // Unpack the pixel - "pmullw %%xmm6, %%xmm0\n\t" // Multiply the pixel with (1 - alpha) * 256 - "paddw %%xmm5, %%xmm0\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%xmm0\n\t" // Divide by 256 - "packuswb %%xmm1, %%xmm0\n\t" // Pack the pixel to a dword - "movd %%xmm0, (%0,%1,4)\n\t" // Write the pixel to the image - : : "r"(data), "r"(i) ); - } - } else -#endif - -#ifdef USE_MMX_INLINE_ASM - if ( KCPUInfo::haveExtension( KCPUInfo::IntelMMX ) && pixels > 1 ) { - TQ_UINT16 alpha = TQ_UINT16( ( 1.0 - opacity ) * 256.0 ); - KIE4Pack packedalpha = { { alpha, alpha, alpha, 256 } }; - - TQ_UINT16 red = TQ_UINT16( clr.red() * 256 * opacity ); - TQ_UINT16 green = TQ_UINT16( clr.green() * 256 * opacity ); - TQ_UINT16 blue = TQ_UINT16( clr.blue() * 256 * opacity ); - - KIE4Pack packedcolor = { { blue, green, red, 0 } }; - - __asm__ __volatile__( - "pxor %%mm7, %%mm7\n\t" // Zero out MM7 for unpacking - "movq (%0), %%mm6\n\t" // Set up (1 - alpha) * 256 in MM6 - "movq (%1), %%mm5\n\t" // Set up color * alpha * 256 in MM5 - : : "r"(&packedalpha), "r"(&packedcolor), "m"(packedcolor), "m"(packedalpha) ); - - TQ_UINT32 *data = reinterpret_cast<TQ_UINT32*>( dst.bits() ); - - // The main loop processes 4 pixels / iteration - int remainder = pixels % 4; - pixels -= remainder; - - // Main loop - for ( int i = 0; i < pixels; i += 4 ) { - __asm__ __volatile__( - // Load 4 pixels to MM registers 1 - 4 - "movd (%0,%1,4), %%mm0\n\t" // Load the 1st pixel to MM0 - "movd 4(%0,%1,4), %%mm1\n\t" // Load the 2nd pixel to MM1 - "movd 8(%0,%1,4), %%mm2\n\t" // Load the 3rd pixel to MM2 - "movd 12(%0,%1,4), %%mm3\n\t" // Load the 4th pixel to MM3 - - // Blend the first pixel - "punpcklbw %%mm7, %%mm0\n\t" // Unpack the pixel - "pmullw %%mm6, %%mm0\n\t" // Multiply the pixel with (1 - alpha) * 256 - "paddw %%mm5, %%mm0\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%mm0\n\t" // Divide by 256 - - // Blend the second pixel - "punpcklbw %%mm7, %%mm1\n\t" // Unpack the pixel - "pmullw %%mm6, %%mm1\n\t" // Multiply the pixel with (1 - alpha) * 256 - "paddw %%mm5, %%mm1\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%mm1\n\t" // Divide by 256 - - // Blend the third pixel - "punpcklbw %%mm7, %%mm2\n\t" // Unpack the pixel - "pmullw %%mm6, %%mm2\n\t" // Multiply the pixel with (1 - alpha) * 256 - "paddw %%mm5, %%mm2\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%mm2\n\t" // Divide by 256 - - // Blend the fourth pixel - "punpcklbw %%mm7, %%mm3\n\t" // Unpack the pixel - "pmullw %%mm6, %%mm3\n\t" // Multiply the pixel with (1 - alpha) * 256 - "paddw %%mm5, %%mm3\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%mm3\n\t" // Divide by 256 - - // Pack the pixels into 2 quadwords - "packuswb %%mm1, %%mm0\n\t" // Pack pixels 1 and 2 to a qword - "packuswb %%mm3, %%mm2\n\t" // Pack pixels 3 and 4 to a qword - - // Write the pixels back to the image - "movq %%mm0, (%0,%1,4)\n\t" // Store pixels 1 and 2 - "movq %%mm2, 8(%0,%1,4)\n\t" // Store pixels 3 and 4 - : : "r"(data), "r"(i) ); - } - - // Cleanup loop - for ( int i = pixels; i < pixels + remainder; i++ ) { - __asm__ __volatile__( - "movd (%0,%1,4), %%mm0\n\t" // Load one pixel to MM1 - "punpcklbw %%mm7, %%mm0\n\t" // Unpack the pixel - "pmullw %%mm6, %%mm0\n\t" // Multiply the pixel with 1 - alpha * 256 - "paddw %%mm5, %%mm0\n\t" // Add color * alpha * 256 to the result - "psrlw $8, %%mm0\n\t" // Divide by 256 - "packuswb %%mm0, %%mm0\n\t" // Pack the pixel to a dword - "movd %%mm0, (%0,%1,4)\n\t" // Write the pixel to the image - : : "r"(data), "r"(i) ); - } - - // Empty the MMX state - __asm__ __volatile__("emms"); - } else -#endif // USE_MMX_INLINE_ASM - - { - int rcol, gcol, bcol; - clr.rgb(&rcol, &gcol, &bcol); - -#ifdef WORDS_BIGENDIAN // ARGB (skip alpha) - register unsigned char *data = (unsigned char *)dst.bits() + 1; -#else // BGRA - register unsigned char *data = (unsigned char *)dst.bits(); -#endif - - for (register int i=0; i<pixels; i++) - { -#ifdef WORDS_BIGENDIAN - *data += (unsigned char)((rcol - *data) * opacity); - data++; - *data += (unsigned char)((gcol - *data) * opacity); - data++; - *data += (unsigned char)((bcol - *data) * opacity); - data++; -#else - *data += (unsigned char)((bcol - *data) * opacity); - data++; - *data += (unsigned char)((gcol - *data) * opacity); - data++; - *data += (unsigned char)((rcol - *data) * opacity); - data++; -#endif - data++; // skip alpha - } - } - - return dst; -} - -// Nice and fast direct pixel manipulation -TQImage& KImageEffect::blend(TQImage& src, TQImage& dst, float opacity) -{ - if (src.width() <= 0 || src.height() <= 0) - return dst; - if (dst.width() <= 0 || dst.height() <= 0) - return dst; - - if (src.width() != dst.width() || src.height() != dst.height()) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::blend : src and destination images are not the same size\n"; -#endif - return dst; - } - - if (opacity < 0.0 || opacity > 1.0) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::blend : invalid opacity. Range [0, 1]\n"; -#endif - return dst; - } - - if (src.depth() != 32) src = src.convertDepth(32); - if (dst.depth() != 32) dst = dst.convertDepth(32); - -#ifdef USE_QT4 - if (src.format() != QImage::Format_ARGB32) - src = dst.convertToFormat(QImage::Format_ARGB32); // This is needed because Qt4 has multiple variants with a 32 bit depth, and the routines below expect one specific variant (ARGB) - if (dst.format() != QImage::Format_ARGB32) - dst = dst.convertToFormat(QImage::Format_ARGB32); // This is needed because Qt4 has multiple variants with a 32 bit depth, and the routines below expect one specific variant (ARGB) -#endif - - int pixels = src.width() * src.height(); - -#ifdef USE_SSE2_INLINE_ASM - if ( KCPUInfo::haveExtension( KCPUInfo::IntelSSE2 ) && pixels > 16 ) { - TQ_UINT16 alpha = TQ_UINT16( opacity * 256.0 ); - KIE8Pack packedalpha = { { alpha, alpha, alpha, 0, - alpha, alpha, alpha, 0 } }; - - // Prepare the XMM6 and XMM7 registers for unpacking and blending - __asm__ __volatile__( - "pxor %%xmm7, %%xmm7\n\t" // Zero out XMM7 for unpacking - "movdqu (%0), %%xmm6\n\t" // Set up alpha * 256 in XMM6 - : : "r"(&packedalpha), "m"(packedalpha) ); - - TQ_UINT32 *data1 = reinterpret_cast<TQ_UINT32*>( src.bits() ); - TQ_UINT32 *data2 = reinterpret_cast<TQ_UINT32*>( dst.bits() ); - - // Check how many pixels we need to process to achieve 16 byte tqalignment - int offset = (16 - (TQ_UINT32( data2 ) & 0x0f)) / 4; - - // The main loop processes 4 pixels / iteration - int remainder = (pixels - offset) % 4; - pixels -= remainder; - - // Alignment loop - for ( int i = 0; i < offset; i++ ) { - __asm__ __volatile__( - "movd (%1,%2,4), %%xmm1\n\t" // Load one dst pixel to XMM1 - "punpcklbw %%xmm7, %%xmm1\n\t" // Unpack the pixel - "movd (%0,%2,4), %%xmm0\n\t" // Load one src pixel to XMM0 - "punpcklbw %%xmm7, %%xmm0\n\t" // Unpack the pixel - "psubw %%xmm1, %%xmm0\n\t" // Subtract dst from src - "pmullw %%xmm6, %%xmm0\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%xmm1\n\t" // Multiply dst with 256 - "paddw %%xmm1, %%xmm0\n\t" // Add dst to result - "psrlw $8, %%xmm0\n\t" // Divide by 256 - "packuswb %%xmm1, %%xmm0\n\t" // Pack the pixel to a dword - "movd %%xmm0, (%1,%2,4)\n\t" // Write the pixel to the image - : : "r"(data1), "r"(data2), "r"(i) ); - } - - // Main loop - for ( int i = offset; i < pixels; i += 4 ) { - __asm__ __volatile__( - // Load 4 src pixels to XMM0 and XMM2 and 4 dst pixels to XMM1 and XMM3 - "movq (%0,%2,4), %%xmm0\n\t" // Load two src pixels to XMM0 - "movq (%1,%2,4), %%xmm1\n\t" // Load two dst pixels to XMM1 - "movq 8(%0,%2,4), %%xmm2\n\t" // Load two src pixels to XMM2 - "movq 8(%1,%2,4), %%xmm3\n\t" // Load two dst pixels to XMM3 - - // Prefetch the pixels for the iteration after the next one - "prefetchnta 32(%0,%2,4) \n\t" - "prefetchnta 32(%1,%2,4) \n\t" - - // Blend the first two pixels - "punpcklbw %%xmm7, %%xmm1\n\t" // Unpack the dst pixels - "punpcklbw %%xmm7, %%xmm0\n\t" // Unpack the src pixels - "psubw %%xmm1, %%xmm0\n\t" // Subtract dst from src - "pmullw %%xmm6, %%xmm0\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%xmm1\n\t" // Multiply dst with 256 - "paddw %%xmm1, %%xmm0\n\t" // Add dst to the result - "psrlw $8, %%xmm0\n\t" // Divide by 256 - - // Blend the next two pixels - "punpcklbw %%xmm7, %%xmm3\n\t" // Unpack the dst pixels - "punpcklbw %%xmm7, %%xmm2\n\t" // Unpack the src pixels - "psubw %%xmm3, %%xmm2\n\t" // Subtract dst from src - "pmullw %%xmm6, %%xmm2\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%xmm3\n\t" // Multiply dst with 256 - "paddw %%xmm3, %%xmm2\n\t" // Add dst to the result - "psrlw $8, %%xmm2\n\t" // Divide by 256 - - // Write the pixels back to the image - "packuswb %%xmm2, %%xmm0\n\t" // Pack the pixels to a double qword - "movdqa %%xmm0, (%1,%2,4)\n\t" // Store the pixels - : : "r"(data1), "r"(data2), "r"(i) ); - } - - // Cleanup loop - for ( int i = pixels; i < pixels + remainder; i++ ) { - __asm__ __volatile__( - "movd (%1,%2,4), %%xmm1\n\t" // Load one dst pixel to XMM1 - "punpcklbw %%xmm7, %%xmm1\n\t" // Unpack the pixel - "movd (%0,%2,4), %%xmm0\n\t" // Load one src pixel to XMM0 - "punpcklbw %%xmm7, %%xmm0\n\t" // Unpack the pixel - "psubw %%xmm1, %%xmm0\n\t" // Subtract dst from src - "pmullw %%xmm6, %%xmm0\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%xmm1\n\t" // Multiply dst with 256 - "paddw %%xmm1, %%xmm0\n\t" // Add dst to result - "psrlw $8, %%xmm0\n\t" // Divide by 256 - "packuswb %%xmm1, %%xmm0\n\t" // Pack the pixel to a dword - "movd %%xmm0, (%1,%2,4)\n\t" // Write the pixel to the image - : : "r"(data1), "r"(data2), "r"(i) ); - } - } else -#endif // USE_SSE2_INLINE_ASM - -#ifdef USE_MMX_INLINE_ASM - if ( KCPUInfo::haveExtension( KCPUInfo::IntelMMX ) && pixels > 1 ) { - TQ_UINT16 alpha = TQ_UINT16( opacity * 256.0 ); - KIE4Pack packedalpha = { { alpha, alpha, alpha, 0 } }; - - // Prepare the MM6 and MM7 registers for blending and unpacking - __asm__ __volatile__( - "pxor %%mm7, %%mm7\n\t" // Zero out MM7 for unpacking - "movq (%0), %%mm6\n\t" // Set up alpha * 256 in MM6 - : : "r"(&packedalpha), "m"(packedalpha) ); - - TQ_UINT32 *data1 = reinterpret_cast<TQ_UINT32*>( src.bits() ); - TQ_UINT32 *data2 = reinterpret_cast<TQ_UINT32*>( dst.bits() ); - - // The main loop processes 2 pixels / iteration - int remainder = pixels % 2; - pixels -= remainder; - - // Main loop - for ( int i = 0; i < pixels; i += 2 ) { - __asm__ __volatile__( - // Load 2 src pixels to MM0 and MM2 and 2 dst pixels to MM1 and MM3 - "movd (%0,%2,4), %%mm0\n\t" // Load the 1st src pixel to MM0 - "movd (%1,%2,4), %%mm1\n\t" // Load the 1st dst pixel to MM1 - "movd 4(%0,%2,4), %%mm2\n\t" // Load the 2nd src pixel to MM2 - "movd 4(%1,%2,4), %%mm3\n\t" // Load the 2nd dst pixel to MM3 - - // Blend the first pixel - "punpcklbw %%mm7, %%mm0\n\t" // Unpack the src pixel - "punpcklbw %%mm7, %%mm1\n\t" // Unpack the dst pixel - "psubw %%mm1, %%mm0\n\t" // Subtract dst from src - "pmullw %%mm6, %%mm0\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%mm1\n\t" // Multiply dst with 256 - "paddw %%mm1, %%mm0\n\t" // Add dst to the result - "psrlw $8, %%mm0\n\t" // Divide by 256 - - // Blend the second pixel - "punpcklbw %%mm7, %%mm2\n\t" // Unpack the src pixel - "punpcklbw %%mm7, %%mm3\n\t" // Unpack the dst pixel - "psubw %%mm3, %%mm2\n\t" // Subtract dst from src - "pmullw %%mm6, %%mm2\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%mm3\n\t" // Multiply dst with 256 - "paddw %%mm3, %%mm2\n\t" // Add dst to the result - "psrlw $8, %%mm2\n\t" // Divide by 256 - - // Write the pixels back to the image - "packuswb %%mm2, %%mm0\n\t" // Pack the pixels to a qword - "movq %%mm0, (%1,%2,4)\n\t" // Store the pixels - : : "r"(data1), "r"(data2), "r"(i) ); - } - - // Blend the remaining pixel (if there is one) - if ( remainder ) { - __asm__ __volatile__( - "movd (%0), %%mm0\n\t" // Load one src pixel to MM0 - "punpcklbw %%mm7, %%mm0\n\t" // Unpack the src pixel - "movd (%1), %%mm1\n\t" // Load one dst pixel to MM1 - "punpcklbw %%mm7, %%mm1\n\t" // Unpack the dst pixel - "psubw %%mm1, %%mm0\n\t" // Subtract dst from src - "pmullw %%mm6, %%mm0\n\t" // Multiply the result with alpha * 256 - "psllw $8, %%mm1\n\t" // Multiply dst with 256 - "paddw %%mm1, %%mm0\n\t" // Add dst to result - "psrlw $8, %%mm0\n\t" // Divide by 256 - "packuswb %%mm0, %%mm0\n\t" // Pack the pixel to a dword - "movd %%mm0, (%1)\n\t" // Write the pixel to the image - : : "r"(data1 + pixels), "r"(data2 + pixels) ); - } - - // Empty the MMX state - __asm__ __volatile__("emms"); - } else -#endif // USE_MMX_INLINE_ASM - - { -#ifdef WORDS_BIGENDIAN // ARGB (skip alpha) - register unsigned char *data1 = (unsigned char *)dst.bits() + 1; - register unsigned char *data2 = (unsigned char *)src.bits() + 1; -#else // BGRA - register unsigned char *data1 = (unsigned char *)dst.bits(); - register unsigned char *data2 = (unsigned char *)src.bits(); -#endif - - for (register int i=0; i<pixels; i++) - { -#ifdef WORDS_BIGENDIAN - *data1 += (unsigned char)((*(data2++) - *data1) * opacity); - data1++; - *data1 += (unsigned char)((*(data2++) - *data1) * opacity); - data1++; - *data1 += (unsigned char)((*(data2++) - *data1) * opacity); - data1++; -#else - *data1 += (unsigned char)((*(data2++) - *data1) * opacity); - data1++; - *data1 += (unsigned char)((*(data2++) - *data1) * opacity); - data1++; - *data1 += (unsigned char)((*(data2++) - *data1) * opacity); - data1++; -#endif - data1++; // skip alpha - data2++; - } - } - - return dst; -} - - -TQImage& KImageEffect::blend(TQImage &image, float initial_intensity, - const TQColor &bgnd, GradientType eff, - bool anti_dir) -{ - if (image.width() == 0 || image.height() == 0 || image.depth()!=32 ) { -#ifndef NDEBUG - std::cerr << "WARNING: KImageEffect::blend : invalid image\n"; -#endif - return image; - } - - int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); - int r, g, b; - int ind; - - unsigned int xi, xf, yi, yf; - unsigned int a; - - // check the boundaries of the initial intesity param - float unaffected = 1; - if (initial_intensity > 1) initial_intensity = 1; - if (initial_intensity < -1) initial_intensity = -1; - if (initial_intensity < 0) { - unaffected = 1. + initial_intensity; - initial_intensity = 0; - } - - - float intensity = initial_intensity; - float var = 1. - initial_intensity; - - if (anti_dir) { - initial_intensity = intensity = 1.; - var = -var; - } - - register int x, y; - - unsigned int *data = (unsigned int *)image.bits(); - - int image_width = image.width(); //Those can't change - int image_height = image.height(); - - - if( eff == VerticalGradient || eff == HorizontalGradient ) { - - // set the image domain to apply the effect to - xi = 0, xf = image_width; - yi = 0, yf = image_height; - if (eff == VerticalGradient) { - if (anti_dir) yf = (int)(image_height * unaffected); - else yi = (int)(image_height * (1 - unaffected)); - } - else { - if (anti_dir) xf = (int)(image_width * unaffected); - else xi = (int)(image_height * (1 - unaffected)); - } - - var /= (eff == VerticalGradient?yf-yi:xf-xi); - - int ind_base; - for (y = yi; y < (int)yf; y++) { - intensity = eff == VerticalGradient? intensity + var : - initial_intensity; - ind_base = image_width * y ; - for (x = xi; x < (int)xf ; x++) { - if (eff == HorizontalGradient) intensity += var; - ind = x + ind_base; - r = tqRed (data[ind]) + (int)(intensity * - (r_bgnd - tqRed (data[ind]))); - g = tqGreen(data[ind]) + (int)(intensity * - (g_bgnd - tqGreen(data[ind]))); - b = tqBlue (data[ind]) + (int)(intensity * - (b_bgnd - tqBlue (data[ind]))); - if (r > 255) r = 255; if (r < 0 ) r = 0; - if (g > 255) g = 255; if (g < 0 ) g = 0; - if (b > 255) b = 255; if (b < 0 ) b = 0; - a = tqAlpha(data[ind]); - data[ind] = tqRgba(r, g, b, a); - } - } - } - else if (eff == DiagonalGradient || eff == CrossDiagonalGradient) { - float xvar = var / 2 / image_width; // / unaffected; - float yvar = var / 2 / image_height; // / unaffected; - float tmp; - - for (x = 0; x < image_width ; x++) { - tmp = xvar * (eff == DiagonalGradient? x : image.width()-x-1); - ind = x; - for (y = 0; y < image_height ; y++) { - intensity = initial_intensity + tmp + yvar * y; - - r = tqRed (data[ind]) + (int)(intensity * - (r_bgnd - tqRed (data[ind]))); - g = tqGreen(data[ind]) + (int)(intensity * - (g_bgnd - tqGreen(data[ind]))); - b = tqBlue (data[ind]) + (int)(intensity * - (b_bgnd - tqBlue (data[ind]))); - if (r > 255) r = 255; if (r < 0 ) r = 0; - if (g > 255) g = 255; if (g < 0 ) g = 0; - if (b > 255) b = 255; if (b < 0 ) b = 0; - a = tqAlpha(data[ind]); - data[ind] = tqRgba(r, g, b, a); - - ind += image_width; - } - } - } - - else if (eff == RectangleGradient || eff == EllipticGradient) { - float xvar; - float yvar; - - for (x = 0; x < image_width / 2 + image_width % 2; x++) { - xvar = var / image_width * (image_width - x*2/unaffected-1); - for (y = 0; y < image_height / 2 + image_height % 2; y++) { - yvar = var / image_height * (image_height - y*2/unaffected -1); - - if (eff == RectangleGradient) - intensity = initial_intensity + QMAX(xvar, yvar); - else - intensity = initial_intensity + sqrt(xvar * xvar + yvar * yvar); - if (intensity > 1) intensity = 1; - if (intensity < 0) intensity = 0; - - //NW - ind = x + image_width * y ; - r = tqRed (data[ind]) + (int)(intensity * - (r_bgnd - tqRed (data[ind]))); - g = tqGreen(data[ind]) + (int)(intensity * - (g_bgnd - tqGreen(data[ind]))); - b = tqBlue (data[ind]) + (int)(intensity * - (b_bgnd - tqBlue (data[ind]))); - if (r > 255) r = 255; if (r < 0 ) r = 0; - if (g > 255) g = 255; if (g < 0 ) g = 0; - if (b > 255) b = 255; if (b < 0 ) b = 0; - a = tqAlpha(data[ind]); - data[ind] = tqRgba(r, g, b, a); - - //NE - ind = image_width - x - 1 + image_width * y ; - r = tqRed (data[ind]) + (int)(intensity * - (r_bgnd - tqRed (data[ind]))); - g = tqGreen(data[ind]) + (int)(intensity * - (g_bgnd - tqGreen(data[ind]))); - b = tqBlue (data[ind]) + (int)(intensity * - (b_bgnd - tqBlue (data[ind]))); - if (r > 255) r = 255; if (r < 0 ) r = 0; - if (g > 255) g = 255; if (g < 0 ) g = 0; - if (b > 255) b = 255; if (b < 0 ) b = 0; - a = tqAlpha(data[ind]); - data[ind] = tqRgba(r, g, b, a); - } - } - - //CT loop is doubled because of stupid central row/column issue. - // other solution? - for (x = 0; x < image_width / 2; x++) { - xvar = var / image_width * (image_width - x*2/unaffected-1); - for (y = 0; y < image_height / 2; y++) { - yvar = var / image_height * (image_height - y*2/unaffected -1); - - if (eff == RectangleGradient) - intensity = initial_intensity + QMAX(xvar, yvar); - else - intensity = initial_intensity + sqrt(xvar * xvar + yvar * yvar); - if (intensity > 1) intensity = 1; - if (intensity < 0) intensity = 0; - - //SW - ind = x + image_width * (image_height - y -1) ; - r = tqRed (data[ind]) + (int)(intensity * - (r_bgnd - tqRed (data[ind]))); - g = tqGreen(data[ind]) + (int)(intensity * - (g_bgnd - tqGreen(data[ind]))); - b = tqBlue (data[ind]) + (int)(intensity * - (b_bgnd - tqBlue (data[ind]))); - if (r > 255) r = 255; if (r < 0 ) r = 0; - if (g > 255) g = 255; if (g < 0 ) g = 0; - if (b > 255) b = 255; if (b < 0 ) b = 0; - a = tqAlpha(data[ind]); - data[ind] = tqRgba(r, g, b, a); - - //SE - ind = image_width-x-1 + image_width * (image_height - y - 1) ; - r = tqRed (data[ind]) + (int)(intensity * - (r_bgnd - tqRed (data[ind]))); - g = tqGreen(data[ind]) + (int)(intensity * - (g_bgnd - tqGreen(data[ind]))); - b = tqBlue (data[ind]) + (int)(intensity * - (b_bgnd - tqBlue (data[ind]))); - if (r > 255) r = 255; if (r < 0 ) r = 0; - if (g > 255) g = 255; if (g < 0 ) g = 0; - if (b > 255) b = 255; if (b < 0 ) b = 0; - a = tqAlpha(data[ind]); - data[ind] = tqRgba(r, g, b, a); - } - } - } -#ifndef NDEBUG - else std::cerr << "KImageEffect::blend effect not implemented" << std::endl; -#endif - return image; -} - -// Not very efficient as we create a third big image... -// -TQImage& KImageEffect::blend(TQImage &image1, TQImage &image2, - GradientType gt, int xf, int yf) -{ - if (image1.width() == 0 || image1.height() == 0 || - image2.width() == 0 || image2.height() == 0) - return image1; - - TQImage image3; - - image3 = KImageEffect::unbalancedGradient(image1.size(), - TQColor(0,0,0), TQColor(255,255,255), - gt, xf, yf, 0); - - return blend(image1,image2,image3, Red); // Channel to use is arbitrary -} - -// Blend image2 into image1, using an RBG channel of blendImage -// -TQImage& KImageEffect::blend(TQImage &image1, TQImage &image2, - TQImage &blendImage, RGBComponent channel) -{ - if (image1.width() == 0 || image1.height() == 0 || - image2.width() == 0 || image2.height() == 0 || - blendImage.width() == 0 || blendImage.height() == 0) { -#ifndef NDEBUG - std::cerr << "KImageEffect::blend effect invalid image" << std::endl; -#endif - return image1; - } - - int r, g, b; - int ind1, ind2, ind3; - - unsigned int x1, x2, x3, y1, y2, y3; - unsigned int a; - - register int x, y; - - // for image1 and image2, we only handle depth 32 - if (image1.depth()<32) image1 = image1.convertDepth(32); - if (image2.depth()<32) image2 = image2.convertDepth(32); - - // for blendImage, we handle depth 8 and 32 - if (blendImage.depth()<8) blendImage = blendImage.convertDepth(8); - - unsigned int *colorTable3 = (blendImage.depth()==8) ? - blendImage.tqcolorTable():0; - - unsigned int *data1 = (unsigned int *)image1.bits(); - unsigned int *data2 = (unsigned int *)image2.bits(); - unsigned int *data3 = (unsigned int *)blendImage.bits(); - unsigned char *data3b = (unsigned char *)blendImage.bits(); - unsigned int color3; - - x1 = image1.width(); y1 = image1.height(); - x2 = image2.width(); y2 = image2.height(); - x3 = blendImage.width(); y3 = blendImage.height(); - - for (y = 0; y < (int)y1; y++) { - ind1 = x1*y; - ind2 = x2*(y%y2); - ind3 = x3*(y%y3); - - x=0; - while(x < (int)x1) { - color3 = (colorTable3) ? colorTable3[data3b[ind3]] : data3[ind3]; - - a = (channel == Red) ? tqRed(color3) : - (channel == Green) ? tqGreen(color3) : - (channel == Blue) ? tqBlue(color3) : tqGray(color3); - - r = (a*tqRed(data1[ind1]) + (256-a)*tqRed(data2[ind2]))/256; - g = (a*tqGreen(data1[ind1]) + (256-a)*tqGreen(data2[ind2]))/256; - b = (a*tqBlue(data1[ind1]) + (256-a)*tqBlue(data2[ind2]))/256; - - a = tqAlpha(data1[ind1]); - data1[ind1] = tqRgba(r, g, b, a); - - ind1++; ind2++; ind3++; x++; - if ( (x%x2) ==0) ind2 -= x2; - if ( (x%x3) ==0) ind3 -= x3; - } - } - return image1; -} - - -//====================================================================== -// -// Hash effects -// -//====================================================================== - -unsigned int KImageEffect::lHash(unsigned int c) -{ - unsigned char r = tqRed(c), g = tqGreen(c), b = tqBlue(c), a = tqAlpha(c); - unsigned char nr, ng, nb; - nr =(r >> 1) + (r >> 2); nr = nr > r ? 0 : nr; - ng =(g >> 1) + (g >> 2); ng = ng > g ? 0 : ng; - nb =(b >> 1) + (b >> 2); nb = nb > b ? 0 : nb; - - return tqRgba(nr, ng, nb, a); -} - - -// ----------------------------------------------------------------------------- - -unsigned int KImageEffect::uHash(unsigned int c) -{ - unsigned char r = tqRed(c), g = tqGreen(c), b = tqBlue(c), a = tqAlpha(c); - unsigned char nr, ng, nb; - nr = r + (r >> 3); nr = nr < r ? ~0 : nr; - ng = g + (g >> 3); ng = ng < g ? ~0 : ng; - nb = b + (b >> 3); nb = nb < b ? ~0 : nb; - - return tqRgba(nr, ng, nb, a); -} - - -// ----------------------------------------------------------------------------- - -TQImage& KImageEffect::hash(TQImage &image, Lighting lite, unsigned int spacing) -{ - if (image.width() == 0 || image.height() == 0) { -#ifndef NDEBUG - std::cerr << "KImageEffect::hash effect invalid image" << std::endl; -#endif - return image; - } - - register int x, y; - unsigned int *data = (unsigned int *)image.bits(); - unsigned int ind; - - //CT no need to do it if not enough space - if ((lite == NorthLite || - lite == SouthLite)&& - (unsigned)image.height() < 2+spacing) return image; - if ((lite == EastLite || - lite == WestLite)&& - (unsigned)image.height() < 2+spacing) return image; - - if (lite == NorthLite || lite == SouthLite) { - for (y = 0 ; y < image.height(); y = y + 2 + spacing) { - for (x = 0; x < image.width(); x++) { - ind = x + image.width() * y; - data[ind] = lite==NorthLite?uHash(data[ind]):lHash(data[ind]); - - ind = ind + image.width(); - data[ind] = lite==NorthLite?lHash(data[ind]):uHash(data[ind]); - } - } - } - - else if (lite == EastLite || lite == WestLite) { - for (y = 0 ; y < image.height(); y++) { - for (x = 0; x < image.width(); x = x + 2 + spacing) { - ind = x + image.width() * y; - data[ind] = lite==EastLite?uHash(data[ind]):lHash(data[ind]); - - ind++; - data[ind] = lite==EastLite?lHash(data[ind]):uHash(data[ind]); - } - } - } - - else if (lite == NWLite || lite == SELite) { - for (y = 0 ; y < image.height(); y++) { - for (x = 0; - x < (int)(image.width() - ((y & 1)? 1 : 0) * spacing); - x = x + 2 + spacing) { - ind = x + image.width() * y + ((y & 1)? 1 : 0); - data[ind] = lite==NWLite?uHash(data[ind]):lHash(data[ind]); - - ind++; - data[ind] = lite==NWLite?lHash(data[ind]):uHash(data[ind]); - } - } - } - - else if (lite == SWLite || lite == NELite) { - for (y = 0 ; y < image.height(); y++) { - for (x = 0 + ((y & 1)? 1 : 0); x < image.width(); x = x + 2 + spacing) { - ind = x + image.width() * y - ((y & 1)? 1 : 0); - data[ind] = lite==SWLite?uHash(data[ind]):lHash(data[ind]); - - ind++; - data[ind] = lite==SWLite?lHash(data[ind]):uHash(data[ind]); - } - } - } - - return image; -} - - -//====================================================================== -// -// Flatten effects -// -//====================================================================== - -TQImage& KImageEffect::flatten(TQImage &img, const TQColor &ca, - const TQColor &cb, int ncols) -{ - if (img.width() == 0 || img.height() == 0) - return img; - - // a bitmap is easy... - if (img.depth() == 1) { - img.setColor(0, ca.rgb()); - img.setColor(1, cb.rgb()); - return img; - } - - int r1 = ca.red(); int r2 = cb.red(); - int g1 = ca.green(); int g2 = cb.green(); - int b1 = ca.blue(); int b2 = cb.blue(); - int min = 0, max = 255; - - QRgb col; - - // Get minimum and maximum greylevel. - if (img.numColors()) { - // pseudocolor - for (int i = 0; i < img.numColors(); i++) { - col = img.color(i); - int mean = (tqRed(col) + tqGreen(col) + tqBlue(col)) / 3; - min = QMIN(min, mean); - max = QMAX(max, mean); - } - } else { - // truecolor - for (int y=0; y < img.height(); y++) - for (int x=0; x < img.width(); x++) { - col = img.pixel(x, y); - int mean = (tqRed(col) + tqGreen(col) + tqBlue(col)) / 3; - min = QMIN(min, mean); - max = QMAX(max, mean); - } - } - - // Conversion factors - float sr = ((float) r2 - r1) / (max - min); - float sg = ((float) g2 - g1) / (max - min); - float sb = ((float) b2 - b1) / (max - min); - - - // Repaint the image - if (img.numColors()) { - for (int i=0; i < img.numColors(); i++) { - col = img.color(i); - int mean = (tqRed(col) + tqGreen(col) + tqBlue(col)) / 3; - int r = (int) (sr * (mean - min) + r1 + 0.5); - int g = (int) (sg * (mean - min) + g1 + 0.5); - int b = (int) (sb * (mean - min) + b1 + 0.5); - img.setColor(i, tqRgba(r, g, b, tqAlpha(col))); - } - } else { - for (int y=0; y < img.height(); y++) - for (int x=0; x < img.width(); x++) { - col = img.pixel(x, y); - int mean = (tqRed(col) + tqGreen(col) + tqBlue(col)) / 3; - int r = (int) (sr * (mean - min) + r1 + 0.5); - int g = (int) (sg * (mean - min) + g1 + 0.5); - int b = (int) (sb * (mean - min) + b1 + 0.5); - img.setPixel(x, y, tqRgba(r, g, b, tqAlpha(col))); - } - } - - - // Dither if necessary - if ( (ncols <= 0) || ((img.numColors() != 0) && (img.numColors() <= ncols))) - return img; - - if (ncols == 1) ncols++; - if (ncols > 256) ncols = 256; - - TQColor *pal = new TQColor[ncols]; - sr = ((float) r2 - r1) / (ncols - 1); - sg = ((float) g2 - g1) / (ncols - 1); - sb = ((float) b2 - b1) / (ncols - 1); - - for (int i=0; i<ncols; i++) - pal[i] = TQColor(r1 + int(sr*i), g1 + int(sg*i), b1 + int(sb*i)); - - dither(img, pal, ncols); - - delete[] pal; - return img; -} - - -//====================================================================== -// -// Fade effects -// -//====================================================================== - -TQImage& KImageEffect::fade(TQImage &img, float val, const TQColor &color) -{ - if (img.width() == 0 || img.height() == 0) - return img; - - // We don't handle bitmaps - if (img.depth() == 1) - return img; - - unsigned char tbl[256]; - for (int i=0; i<256; i++) - tbl[i] = (int) (val * i + 0.5); - - int red = color.red(); - int green = color.green(); - int blue = color.blue(); - - QRgb col; - int r, g, b, cr, cg, cb; - - if (img.depth() <= 8) { - // pseudo color - for (int i=0; i<img.numColors(); i++) { - col = img.color(i); - cr = tqRed(col); cg = tqGreen(col); cb = tqBlue(col); - if (cr > red) - r = cr - tbl[cr - red]; - else - r = cr + tbl[red - cr]; - if (cg > green) - g = cg - tbl[cg - green]; - else - g = cg + tbl[green - cg]; - if (cb > blue) - b = cb - tbl[cb - blue]; - else - b = cb + tbl[blue - cb]; - img.setColor(i, tqRgba(r, g, b, tqAlpha(col))); - } - - } else { - // truecolor - for (int y=0; y<img.height(); y++) { - QRgb *data = (QRgb *) img.scanLine(y); - for (int x=0; x<img.width(); x++) { - col = *data; - cr = tqRed(col); cg = tqGreen(col); cb = tqBlue(col); - if (cr > red) - r = cr - tbl[cr - red]; - else - r = cr + tbl[red - cr]; - if (cg > green) - g = cg - tbl[cg - green]; - else - g = cg + tbl[green - cg]; - if (cb > blue) - b = cb - tbl[cb - blue]; - else - b = cb + tbl[blue - cb]; - *data++ = tqRgba(r, g, b, tqAlpha(col)); - } - } - } - - return img; -} - -//====================================================================== -// -// Color effects -// -//====================================================================== - -// This code is adapted from code (C) Rik Hemsley <rik@kde.org> -// -// The formula used (r + b + g) /3 is different from the tqGray formula -// used by Qt. This is because our formula is much much faster. If, -// however, it turns out that this is producing sub-optimal images, -// then it will have to change (kurt) -// -// It does produce lower quality grayscale ;-) Use fast == true for the fast -// algorithm, false for the higher quality one (mosfet). -TQImage& KImageEffect::toGray(TQImage &img, bool fast) -{ - if (img.width() == 0 || img.height() == 0) - return img; - - if(fast){ - if (img.depth() == 32) { - register uchar * r(img.bits()); - register uchar * g(img.bits() + 1); - register uchar * b(img.bits() + 2); - - uchar * end(img.bits() + img.numBytes()); - - while (r != end) { - - *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3 - - r += 4; - g += 4; - b += 4; - } - } - else - { - for (int i = 0; i < img.numColors(); i++) - { - register uint r = tqRed(img.color(i)); - register uint g = tqGreen(img.color(i)); - register uint b = tqBlue(img.color(i)); - - register uint gray = (((r + g) >> 1) + b) >> 1; - img.setColor(i, tqRgba(gray, gray, gray, tqAlpha(img.color(i)))); - } - } - } - else{ - int pixels = img.depth() > 8 ? img.width()*img.height() : - img.numColors(); - unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : - (unsigned int *)img.tqcolorTable(); - int val, i; - for(i=0; i < pixels; ++i){ - val = tqGray(data[i]); - data[i] = tqRgba(val, val, val, tqAlpha(data[i])); - } - } - return img; -} - -// CT 29Jan2000 - desaturation algorithms -TQImage& KImageEffect::desaturate(TQImage &img, float desat) -{ - if (img.width() == 0 || img.height() == 0) - return img; - - if (desat < 0) desat = 0.; - if (desat > 1) desat = 1.; - int pixels = img.depth() > 8 ? img.width()*img.height() : - img.numColors(); - unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : - (unsigned int *)img.tqcolorTable(); - int h, s, v, i; - TQColor clr; // keep constructor out of loop (mosfet) - for(i=0; i < pixels; ++i){ - clr.setRgb(data[i]); - clr.hsv(&h, &s, &v); - clr.setHsv(h, (int)(s * (1. - desat)), v); - data[i] = clr.rgb(); - } - return img; -} - -// Contrast stuff (mosfet) -TQImage& KImageEffect::contrast(TQImage &img, int c) -{ - if (img.width() == 0 || img.height() == 0) - return img; - - if(c > 255) - c = 255; - if(c < -255) - c = -255; - int pixels = img.depth() > 8 ? img.width()*img.height() : - img.numColors(); - unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : - (unsigned int *)img.tqcolorTable(); - int i, r, g, b; - for(i=0; i < pixels; ++i){ - r = tqRed(data[i]); - g = tqGreen(data[i]); - b = tqBlue(data[i]); - if(tqGray(data[i]) <= 127){ - if(r - c > 0) - r -= c; - else - r = 0; - if(g - c > 0) - g -= c; - else - g = 0; - if(b - c > 0) - b -= c; - else - b = 0; - } - else{ - if(r + c <= 255) - r += c; - else - r = 255; - if(g + c <= 255) - g += c; - else - g = 255; - if(b + c <= 255) - b += c; - else - b = 255; - } - data[i] = tqRgba(r, g, b, tqAlpha(data[i])); - } - return(img); -} - -//====================================================================== -// -// Dithering effects -// -//====================================================================== - -// adapted from kFSDither (C) 1997 Martin Jones (mjones@kde.org) -// -// Floyd-Steinberg dithering -// Ref: Bitmapped Graphics Programming in C++ -// Marv Luse, Addison-Wesley Publishing, 1993. -TQImage& KImageEffect::dither(TQImage &img, const TQColor *palette, int size) -{ - if (img.width() == 0 || img.height() == 0 || - palette == 0 || img.depth() <= 8) - return img; - - TQImage dImage( img.width(), img.height(), 8, size ); - int i; - - dImage.setNumColors( size ); - for ( i = 0; i < size; i++ ) - dImage.setColor( i, palette[ i ].rgb() ); - - int *rerr1 = new int [ img.width() * 2 ]; - int *gerr1 = new int [ img.width() * 2 ]; - int *berr1 = new int [ img.width() * 2 ]; - - memset( rerr1, 0, sizeof( int ) * img.width() * 2 ); - memset( gerr1, 0, sizeof( int ) * img.width() * 2 ); - memset( berr1, 0, sizeof( int ) * img.width() * 2 ); - - int *rerr2 = rerr1 + img.width(); - int *gerr2 = gerr1 + img.width(); - int *berr2 = berr1 + img.width(); - - for ( int j = 0; j < img.height(); j++ ) - { - uint *ip = (uint * )img.scanLine( j ); - uchar *dp = dImage.scanLine( j ); - - for ( i = 0; i < img.width(); i++ ) - { - rerr1[i] = rerr2[i] + tqRed( *ip ); - rerr2[i] = 0; - gerr1[i] = gerr2[i] + tqGreen( *ip ); - gerr2[i] = 0; - berr1[i] = berr2[i] + tqBlue( *ip ); - berr2[i] = 0; - ip++; - } - - *dp++ = nearestColor( rerr1[0], gerr1[0], berr1[0], palette, size ); - - for ( i = 1; i < img.width()-1; i++ ) - { - int indx = nearestColor( rerr1[i], gerr1[i], berr1[i], palette, size ); - *dp = indx; - - int rerr = rerr1[i]; - rerr -= palette[indx].red(); - int gerr = gerr1[i]; - gerr -= palette[indx].green(); - int berr = berr1[i]; - berr -= palette[indx].blue(); - - // diffuse red error - rerr1[ i+1 ] += ( rerr * 7 ) >> 4; - rerr2[ i-1 ] += ( rerr * 3 ) >> 4; - rerr2[ i ] += ( rerr * 5 ) >> 4; - rerr2[ i+1 ] += ( rerr ) >> 4; - - // diffuse green error - gerr1[ i+1 ] += ( gerr * 7 ) >> 4; - gerr2[ i-1 ] += ( gerr * 3 ) >> 4; - gerr2[ i ] += ( gerr * 5 ) >> 4; - gerr2[ i+1 ] += ( gerr ) >> 4; - - // diffuse red error - berr1[ i+1 ] += ( berr * 7 ) >> 4; - berr2[ i-1 ] += ( berr * 3 ) >> 4; - berr2[ i ] += ( berr * 5 ) >> 4; - berr2[ i+1 ] += ( berr ) >> 4; - - dp++; - } - - *dp = nearestColor( rerr1[i], gerr1[i], berr1[i], palette, size ); - } - - delete [] rerr1; - delete [] gerr1; - delete [] berr1; - - img = dImage; - return img; -} - -int KImageEffect::nearestColor( int r, int g, int b, const TQColor *palette, int size ) -{ - if (palette == 0) - return 0; - - int dr = palette[0].red() - r; - int dg = palette[0].green() - g; - int db = palette[0].blue() - b; - - int minDist = dr*dr + dg*dg + db*db; - int nearest = 0; - - for (int i = 1; i < size; i++ ) - { - dr = palette[i].red() - r; - dg = palette[i].green() - g; - db = palette[i].blue() - b; - - int dist = dr*dr + dg*dg + db*db; - - if ( dist < minDist ) - { - minDist = dist; - nearest = i; - } - } - - return nearest; -} - -bool KImageEffect::blend( - const TQImage & upper, - const TQImage & lower, - TQImage & output -) -{ - if ( - upper.width() > lower.width() || - upper.height() > lower.height() || - upper.depth() != 32 || - lower.depth() != 32 - ) - { -#ifndef NDEBUG - std::cerr << "KImageEffect::blend : Sizes not correct\n" ; -#endif - return false; - } - - output = lower.copy(); - - register uchar *i, *o; - register int a; - register int col; - register int w = upper.width(); - int row(upper.height() - 1); - - do { - - i = const_cast<TQImage&>(upper).scanLine(row); - o = const_cast<TQImage&>(output).scanLine(row); - - col = w << 2; - --col; - - do { - - while (!(a = i[col]) && (col != 3)) { - --col; --col; --col; --col; - } - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - - } while (col--); - - } while (row--); - - return true; -} - -#if 0 -// Not yet... -bool KImageEffect::blend( - const TQImage & upper, - const TQImage & lower, - TQImage & output, - const TQRect & destRect -) -{ - output = lower.copy(); - return output; -} - -#endif - -bool KImageEffect::blend( - int &x, int &y, - const TQImage & upper, - const TQImage & lower, - TQImage & output -) -{ - int cx=0, cy=0, cw=upper.width(), ch=upper.height(); - - if ( upper.width() + x > lower.width() || - upper.height() + y > lower.height() || - x < 0 || y < 0 || - upper.depth() != 32 || lower.depth() != 32 ) - { - if ( x > lower.width() || y > lower.height() ) return false; - if ( upper.width()<=0 || upper.height() <= 0 ) return false; - if ( lower.width()<=0 || lower.height() <= 0 ) return false; - - if (x<0) {cx=-x; cw+=x; x=0; }; - if (cw + x > lower.width()) { cw=lower.width()-x; }; - if (y<0) {cy=-y; ch+=y; y=0; }; - if (ch + y > lower.height()) { ch=lower.height()-y; }; - - if ( cx >= upper.width() || cy >= upper.height() ) return true; - if ( cw <= 0 || ch <= 0 ) return true; - } - - output.create(cw,ch,32); -// output.setAlphaBuffer(true); // I should do some benchmarks to see if - // this is worth the effort - - register QRgb *i, *o, *b; - - register int a; - register int j,k; - for (j=0; j<ch; j++) - { - b=reinterpret_cast<QRgb *>(&const_cast<TQImage&>(lower).scanLine(y+j) [ (x+cw) << 2 ]); - i=reinterpret_cast<QRgb *>(&const_cast<TQImage&>(upper).scanLine(cy+j)[ (cx+cw) << 2 ]); - o=reinterpret_cast<QRgb *>(&const_cast<TQImage&>(output).scanLine(j) [ cw << 2 ]); - - k=cw-1; - --b; --i; --o; - do - { - while ( !(a=tqAlpha(*i)) && k>0 ) - { - i--; -// *o=0; - *o=*b; - --o; --b; - k--; - }; -// *o=0xFF; - *o = tqRgb(tqRed(*b) + (((tqRed(*i) - tqRed(*b)) * a) >> 8), - tqGreen(*b) + (((tqGreen(*i) - tqGreen(*b)) * a) >> 8), - tqBlue(*b) + (((tqBlue(*i) - tqBlue(*b)) * a) >> 8)); - --i; --o; --b; - } while (k--); - } - - return true; -} - -bool KImageEffect::blendOnLower( - int x, int y, - const TQImage & upper, - const TQImage & lower -) -{ - int cx=0, cy=0, cw=upper.width(), ch=upper.height(); - - if ( upper.depth() != 32 || lower.depth() != 32 ) return false; - if ( x + cw > lower.width() || - y + ch > lower.height() || - x < 0 || y < 0 ) - { - if ( x > lower.width() || y > lower.height() ) return true; - if ( upper.width()<=0 || upper.height() <= 0 ) return true; - if ( lower.width()<=0 || lower.height() <= 0 ) return true; - - if (x<0) {cx=-x; cw+=x; x=0; }; - if (cw + x > lower.width()) { cw=lower.width()-x; }; - if (y<0) {cy=-y; ch+=y; y=0; }; - if (ch + y > lower.height()) { ch=lower.height()-y; }; - - if ( cx >= upper.width() || cy >= upper.height() ) return true; - if ( cw <= 0 || ch <= 0 ) return true; - } - - register uchar *i, *b; - register int a; - register int k; - - for (int j=0; j<ch; j++) - { - b=&const_cast<TQImage&>(lower).scanLine(y+j) [ (x+cw) << 2 ]; - i=&const_cast<TQImage&>(upper).scanLine(cy+j)[ (cx+cw) << 2 ]; - - k=cw-1; - --b; --i; - do - { -#ifndef WORDS_BIGENDIAN - while ( !(a=*i) && k>0 ) -#else - while ( !(a=*(i-3)) && k>0 ) -#endif - { - i-=4; b-=4; k--; - }; - -#ifndef WORDS_BIGENDIAN - --i; --b; - *b += ( ((*i - *b) * a) >> 8 ); - --i; --b; - *b += ( ((*i - *b) * a) >> 8 ); - --i; --b; - *b += ( ((*i - *b) * a) >> 8 ); - --i; --b; -#else - *b += ( ((*i - *b) * a) >> 8 ); - --i; --b; - *b += ( ((*i - *b) * a) >> 8 ); - --i; --b; - *b += ( ((*i - *b) * a) >> 8 ); - i -= 2; b -= 2; -#endif - } while (k--); - } - - return true; -} - -void KImageEffect::blendOnLower(const TQImage &upper, const TQPoint &upperOffset, - TQImage &lower, const TQRect &lowerRect) -{ - // clip rect - TQRect lr = lowerRect & lower.rect(); - lr.setWidth( QMIN(lr.width(), upper.width()-upperOffset.x()) ); - lr.setHeight( QMIN(lr.height(), upper.height()-upperOffset.y()) ); - if ( !lr.isValid() ) return; - - // blend - for (int y = 0; y < lr.height(); y++) { - for (int x = 0; x < lr.width(); x++) { - QRgb *b = reinterpret_cast<QRgb*>(const_cast<TQImage&>(lower).scanLine(lr.y() + y)+ (lr.x() + x) * sizeof(QRgb)); - QRgb *d = reinterpret_cast<QRgb*>(const_cast<TQImage&>(upper).scanLine(upperOffset.y() + y) + (upperOffset.x() + x) * sizeof(QRgb)); - int a = tqAlpha(*d); - *b = tqRgb(tqRed(*b) - (((tqRed(*b) - tqRed(*d)) * a) >> 8), - tqGreen(*b) - (((tqGreen(*b) - tqGreen(*d)) * a) >> 8), - tqBlue(*b) - (((tqBlue(*b) - tqBlue(*d)) * a) >> 8)); - } - } -} - -void KImageEffect::blendOnLower(const TQImage &upper, const TQPoint &upperOffset, - TQImage &lower, const TQRect &lowerRect, float opacity) -{ - // clip rect - TQRect lr = lowerRect & lower.rect(); - lr.setWidth( QMIN(lr.width(), upper.width()-upperOffset.x()) ); - lr.setHeight( QMIN(lr.height(), upper.height()-upperOffset.y()) ); - if ( !lr.isValid() ) return; - - // blend - for (int y = 0; y < lr.height(); y++) { - for (int x = 0; x < lr.width(); x++) { - QRgb *b = reinterpret_cast<QRgb*>(const_cast<TQImage&>(lower).scanLine(lr.y() + y)+ (lr.x() + x) * sizeof(QRgb)); - QRgb *d = reinterpret_cast<QRgb*>(const_cast<TQImage&>(upper).scanLine(upperOffset.y() + y) + (upperOffset.x() + x) * sizeof(QRgb)); - int a = tqRound(opacity * tqAlpha(*d)); - *b = tqRgb(tqRed(*b) - (((tqRed(*b) - tqRed(*d)) * a) >> 8), - tqGreen(*b) - (((tqGreen(*b) - tqGreen(*d)) * a) >> 8), - tqBlue(*b) - (((tqBlue(*b) - tqBlue(*d)) * a) >> 8)); - } - } -} - -TQRect KImageEffect::computeDestinationRect(const TQSize &lowerSize, - Disposition disposition, TQImage &upper) -{ - int w = lowerSize.width(); - int h = lowerSize.height(); - int ww = upper.width(); - int wh = upper.height(); - TQRect d; - - switch (disposition) { - case NoImage: - break; - case Centered: - d.setRect((w - ww) / 2, (h - wh) / 2, ww, wh); - break; - case Tiled: - d.setRect(0, 0, w, h); - break; - case CenterTiled: - d.setCoords(-ww + ((w - ww) / 2) % ww, -wh + ((h - wh) / 2) % wh, - w-1, h-1); - break; - case Scaled: - upper = upper.smoothScale(w, h); - d.setRect(0, 0, w, h); - break; - case CenteredAutoFit: - if( ww <= w && wh <= h ) { - d.setRect((w - ww) / 2, (h - wh) / 2, ww, wh); // like Centered - break; - } - // fall through - case CenteredMaxpect: { - double sx = (double) w / ww; - double sy = (double) h / wh; - if (sx > sy) { - ww = (int)(sy * ww); - wh = h; - } else { - wh = (int)(sx * wh); - ww = w; - } - upper = upper.smoothScale(ww, wh); - d.setRect((w - ww) / 2, (h - wh) / 2, ww, wh); - break; - } - case TiledMaxpect: { - double sx = (double) w / ww; - double sy = (double) h / wh; - if (sx > sy) { - ww = (int)(sy * ww); - wh = h; - } else { - wh = (int)(sx * wh); - ww = w; - } - upper = upper.smoothScale(ww, wh); - d.setRect(0, 0, w, h); - break; - } - } - - return d; -} - -void KImageEffect::blendOnLower(TQImage &upper, TQImage &lower, - Disposition disposition, float opacity) -{ - TQRect r = computeDestinationRect(lower.size(), disposition, upper); - for (int y = r.top(); y<r.bottom(); y += upper.height()) - for (int x = r.left(); x<r.right(); x += upper.width()) - blendOnLower(upper, TQPoint(-QMIN(x, 0), -QMIN(y, 0)), - lower, TQRect(x, y, upper.width(), upper.height()), opacity); -} - - -// For selected icons -TQImage& KImageEffect::selectedImage( TQImage &img, const TQColor &col ) -{ - return blend( col, img, 0.5); -} - -// -// =================================================================== -// Effects originally ported from ImageMagick for PixiePlus, plus a few -// new ones. (mosfet 05/26/2003) -// =================================================================== -// -/* - Portions of this software are based on ImageMagick. Such portions are clearly -marked as being ported from ImageMagick. ImageMagick is copyrighted under the -following conditions: - -Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to -making software imaging solutions freely available. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files ("ImageMagick"), to deal -in ImageMagick without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of ImageMagick, and to permit persons to whom the ImageMagick 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 ImageMagick. - -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 -ImageMagick Studio 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 ImageMagick or the use or other dealings in ImageMagick. - -Except as contained in this notice, the name of the ImageMagick Studio shall -not be used in advertising or otherwise to promote the sale, use or other -dealings in ImageMagick without prior written authorization from the -ImageMagick Studio. -*/ - -TQImage KImageEffect::sample(TQImage &src, int w, int h) -{ - if(w == src.width() && h == src.height()) - return(src); - - int depth = src.depth(); - TQImage dest(w, h, depth, depth <= 8 ? src.numColors() : 0, - depth == 1 ? TQImage::LittleEndian : TQImage::IgnoreEndian); - int *x_offset = (int *)malloc(w*sizeof(int)); - int *y_offset = (int *)malloc(h*sizeof(int)); - if(!x_offset || !y_offset){ -#ifndef NDEBUG - qWarning("KImageEffect::sample(): Unable to allocate pixel buffer"); -#endif - free(x_offset); - free(y_offset); - return(src); - } - - // init pixel offsets - for(int x=0; x < w; ++x) - x_offset[x] = (int)(x*src.width()/((double)w)); - for(int y=0; y < h; ++y) - y_offset[y] = (int)(y*src.height()/((double)h)); - - if(depth > 8){ // DirectClass source image - for(int y=0; y < h; ++y){ - unsigned int *destData = (unsigned int *)dest.scanLine(y); - unsigned int *srcData = (unsigned int *)src.scanLine(y_offset[y]); - for(int x=0; x < w; ++x) - destData[x] = srcData[x_offset[x]]; - } - } - else if(depth == 1) { - int r = src.bitOrder() == TQImage::LittleEndian; - memcpy(dest.tqcolorTable(), src.tqcolorTable(), src.numColors()*sizeof(QRgb)); - for(int y=0; y < h; ++y){ - unsigned char *destData = dest.scanLine(y); - unsigned char *srcData = src.scanLine(y_offset[y]); - for(int x=0; x < w; ++x){ - int k = x_offset[x]; - int l = r ? (k & 7) : (7 - (k&7)); - if(srcData[k >> 3] & (1 << l)) - destData[x >> 3] |= 1 << (x & 7); - else - destData[x >> 3] &= ~(1 << (x & 7)); - } - } - } - else{ // PseudoClass source image - memcpy(dest.tqcolorTable(), src.tqcolorTable(), src.numColors()*sizeof(QRgb)); - for(int y=0; y < h; ++y){ - unsigned char *destData = dest.scanLine(y); - unsigned char *srcData = src.scanLine(y_offset[y]); - for(int x=0; x < w; ++x) - destData[x] = srcData[x_offset[x]]; - } - } - free(x_offset); - free(y_offset); - return(dest); -} - -void KImageEffect::threshold(TQImage &img, unsigned int threshold) -{ - int i, count; - unsigned int *data; - if(img.depth() > 8){ // DirectClass - count = img.width()*img.height(); - data = (unsigned int *)img.bits(); - } - else{ // PsudeoClass - count = img.numColors(); - data = (unsigned int *)img.tqcolorTable(); - } - for(i=0; i < count; ++i) - data[i] = intensityValue(data[i]) < threshold ? QColor(Qt::black).rgb() : QColor(Qt::white).rgb(); -} - -void KImageEffect::hull(const int x_offset, const int y_offset, - const int polarity, const int columns, - const int rows, - unsigned int *f, unsigned int *g) -{ - int x, y; - - unsigned int *p, *q, *r, *s; - unsigned int v; - if(f == NULL || g == NULL) - return; - p=f+(columns+2); - q=g+(columns+2); - r=p+(y_offset*(columns+2)+x_offset); - for (y=0; y < rows; y++){ - p++; - q++; - r++; - if(polarity > 0) - for (x=0; x < columns; x++){ - v=(*p); - if (*r > v) - v++; - *q=v; - p++; - q++; - r++; - } - else - for(x=0; x < columns; x++){ - v=(*p); - if (v > (unsigned int) (*r+1)) - v--; - *q=v; - p++; - q++; - r++; - } - p++; - q++; - r++; - } - p=f+(columns+2); - q=g+(columns+2); - r=q+(y_offset*(columns+2)+x_offset); - s=q-(y_offset*(columns+2)+x_offset); - for(y=0; y < rows; y++){ - p++; - q++; - r++; - s++; - if(polarity > 0) - for(x=0; x < (int) columns; x++){ - v=(*q); - if (((unsigned int) (*s+1) > v) && (*r > v)) - v++; - *p=v; - p++; - q++; - r++; - s++; - } - else - for (x=0; x < columns; x++){ - v=(*q); - if (((unsigned int) (*s+1) < v) && (*r < v)) - v--; - *p=v; - p++; - q++; - r++; - s++; - } - p++; - q++; - r++; - s++; - } -} - -TQImage KImageEffect::despeckle(TQImage &src) -{ - int i, j, x, y; - unsigned int *blue_channel, *red_channel, *green_channel, *buffer, - *alpha_channel; - int packets; - static const int - X[4]= {0, 1, 1,-1}, - Y[4]= {1, 0, 1, 1}; - - unsigned int *destData; - TQImage dest(src.width(), src.height(), 32); - - packets = (src.width()+2)*(src.height()+2); - red_channel = (unsigned int *)calloc(packets, sizeof(unsigned int)); - green_channel = (unsigned int *)calloc(packets, sizeof(unsigned int)); - blue_channel = (unsigned int *)calloc(packets, sizeof(unsigned int)); - alpha_channel = (unsigned int *)calloc(packets, sizeof(unsigned int)); - buffer = (unsigned int *)calloc(packets, sizeof(unsigned int)); - if(!red_channel || ! green_channel || ! blue_channel || ! alpha_channel || - !buffer){ - free(red_channel); - free(green_channel); - free(blue_channel); - free(alpha_channel); - free(buffer); - return(src); - } - - // copy image pixels to color component buffers - j = src.width()+2; - if(src.depth() > 8){ // DirectClass source image - unsigned int *srcData; - for(y=0; y < src.height(); ++y){ - srcData = (unsigned int *)src.scanLine(y); - ++j; - for(x=0; x < src.width(); ++x){ - red_channel[j] = tqRed(srcData[x]); - green_channel[j] = tqGreen(srcData[x]); - blue_channel[j] = tqBlue(srcData[x]); - alpha_channel[j] = tqAlpha(srcData[x]); - ++j; - } - ++j; - } - } - else{ // PsudeoClass source image - unsigned char *srcData; - unsigned int *cTable = src.tqcolorTable(); - unsigned int pixel; - for(y=0; y < src.height(); ++y){ - srcData = (unsigned char *)src.scanLine(y); - ++j; - for(x=0; x < src.width(); ++x){ - pixel = *(cTable+srcData[x]); - red_channel[j] = tqRed(pixel); - green_channel[j] = tqGreen(pixel); - blue_channel[j] = tqBlue(pixel); - alpha_channel[j] = tqAlpha(pixel); - ++j; - } - ++j; - } - } - // reduce speckle in red channel - for(i=0; i < 4; i++){ - hull(X[i],Y[i],1,src.width(),src.height(),red_channel,buffer); - hull(-X[i],-Y[i],1,src.width(),src.height(),red_channel,buffer); - hull(-X[i],-Y[i],-1,src.width(),src.height(),red_channel,buffer); - hull(X[i],Y[i],-1,src.width(),src.height(),red_channel,buffer); - } - // reduce speckle in green channel - for (i=0; i < packets; i++) - buffer[i]=0; - for (i=0; i < 4; i++){ - hull(X[i],Y[i],1,src.width(),src.height(),green_channel,buffer); - hull(-X[i],-Y[i],1,src.width(),src.height(),green_channel,buffer); - hull(-X[i],-Y[i],-1,src.width(),src.height(),green_channel,buffer); - hull(X[i],Y[i],-1,src.width(),src.height(),green_channel,buffer); - } - // reduce speckle in blue channel - for (i=0; i < packets; i++) - buffer[i]=0; - for (i=0; i < 4; i++){ - hull(X[i],Y[i],1,src.width(),src.height(),blue_channel,buffer); - hull(-X[i],-Y[i],1,src.width(),src.height(),blue_channel,buffer); - hull(-X[i],-Y[i],-1,src.width(),src.height(),blue_channel,buffer); - hull(X[i],Y[i],-1,src.width(),src.height(),blue_channel,buffer); - } - // copy color component buffers to despeckled image - j = dest.width()+2; - for(y=0; y < dest.height(); ++y) - { - destData = (unsigned int *)dest.scanLine(y); - ++j; - for (x=0; x < dest.width(); ++x) - { - destData[x] = tqRgba(red_channel[j], green_channel[j], - blue_channel[j], alpha_channel[j]); - ++j; - } - ++j; - } - free(buffer); - free(red_channel); - free(green_channel); - free(blue_channel); - free(alpha_channel); - return(dest); -} - -unsigned int KImageEffect::generateNoise(unsigned int pixel, - NoiseType noise_type) -{ -#define NoiseEpsilon 1.0e-5 -#define NoiseMask 0x7fff -#define SigmaUniform 4.0 -#define SigmaGaussian 4.0 -#define SigmaImpulse 0.10 -#define SigmaLaplacian 10.0 -#define SigmaMultiplicativeGaussian 0.5 -#define SigmaPoisson 0.05 -#define TauGaussian 20.0 - - double alpha, beta, sigma, value; - alpha=(double) (rand() & NoiseMask)/NoiseMask; - if (alpha == 0.0) - alpha=1.0; - switch(noise_type){ - case UniformNoise: - default: - { - value=(double) pixel+SigmaUniform*(alpha-0.5); - break; - } - case GaussianNoise: - { - double tau; - - beta=(double) (rand() & NoiseMask)/NoiseMask; - sigma=sqrt(-2.0*log(alpha))*cos(2.0*M_PI*beta); - tau=sqrt(-2.0*log(alpha))*sin(2.0*M_PI*beta); - value=(double) pixel+ - (sqrt((double) pixel)*SigmaGaussian*sigma)+(TauGaussian*tau); - break; - } - case MultiplicativeGaussianNoise: - { - if (alpha <= NoiseEpsilon) - sigma=MaxRGB; - else - sigma=sqrt(-2.0*log(alpha)); - beta=(rand() & NoiseMask)/NoiseMask; - value=(double) pixel+ - pixel*SigmaMultiplicativeGaussian*sigma*cos(2.0*M_PI*beta); - break; - } - case ImpulseNoise: - { - if (alpha < (SigmaImpulse/2.0)) - value=0; - else - if (alpha >= (1.0-(SigmaImpulse/2.0))) - value=MaxRGB; - else - value=pixel; - break; - } - case LaplacianNoise: - { - if (alpha <= 0.5) - { - if (alpha <= NoiseEpsilon) - value=(double) pixel-MaxRGB; - else - value=(double) pixel+SigmaLaplacian*log(2.0*alpha); - break; - } - beta=1.0-alpha; - if (beta <= (0.5*NoiseEpsilon)) - value=(double) pixel+MaxRGB; - else - value=(double) pixel-SigmaLaplacian*log(2.0*beta); - break; - } - case PoissonNoise: - { - register int - i; - - for (i=0; alpha > exp(-SigmaPoisson*pixel); i++) - { - beta=(double) (rand() & NoiseMask)/NoiseMask; - alpha=alpha*beta; - } - value=i/SigmaPoisson; - break; - } - } - if(value < 0.0) - return(0); - if(value > MaxRGB) - return(MaxRGB); - return((unsigned int) (value+0.5)); -} - -TQImage KImageEffect::addNoise(TQImage &src, NoiseType noise_type) -{ - int x, y; - TQImage dest(src.width(), src.height(), 32); - unsigned int *destData; - - if(src.depth() > 8){ // DirectClass source image - unsigned int *srcData; - for(y=0; y < src.height(); ++y){ - srcData = (unsigned int *)src.scanLine(y); - destData = (unsigned int *)dest.scanLine(y); - for(x=0; x < src.width(); ++x){ - destData[x] = tqRgba(generateNoise(tqRed(srcData[x]), noise_type), - generateNoise(tqGreen(srcData[x]), noise_type), - generateNoise(tqBlue(srcData[x]), noise_type), - tqAlpha(srcData[x])); - } - } - } - else{ // PsudeoClass source image - unsigned char *srcData; - unsigned int *cTable = src.tqcolorTable(); - unsigned int pixel; - for(y=0; y < src.height(); ++y){ - srcData = (unsigned char *)src.scanLine(y); - destData = (unsigned int *)dest.scanLine(y); - for(x=0; x < src.width(); ++x){ - pixel = *(cTable+srcData[x]); - destData[x] = tqRgba(generateNoise(tqRed(pixel), noise_type), - generateNoise(tqGreen(pixel), noise_type), - generateNoise(tqBlue(pixel), noise_type), - tqAlpha(pixel)); - } - } - - } - return(dest); -} - -unsigned int KImageEffect::interpolateColor(TQImage *image, double x_offset, - double y_offset, - unsigned int background) -{ - double alpha, beta; - unsigned int p, q, r, s; - int x, y; - - x = (int)x_offset; - y = (int)y_offset; - if((x < -1) || (x >= image->width()) || (y < -1) || (y >= image->height())) - return(background); - if(image->depth() > 8){ - if((x >= 0) && (y >= 0) && (x < (image->width()-1)) && (y < (image->height()-1))) { - unsigned int *t = (unsigned int *)image->scanLine(y); - p = t[x]; - q = t[x+1]; - r = t[x+image->width()]; - s = t[x+image->width()+1]; - } - else{ - unsigned int *t = (unsigned int *)image->scanLine(y); - p = background; - if((x >= 0) && (y >= 0)){ - p = t[x]; - } - q = background; - if(((x+1) < image->width()) && (y >= 0)){ - q = t[x+1]; - } - r = background; - if((x >= 0) && ((y+1) < image->height())){ - t = (unsigned int *)image->scanLine(y+1); - r = t[x+image->width()]; - } - s = background; - if(((x+1) < image->width()) && ((y+1) < image->height())){ - t = (unsigned int *)image->scanLine(y+1); - s = t[x+image->width()+1]; - } - - } - } - else{ - unsigned int *colorTable = (unsigned int *)image->tqcolorTable(); - if((x >= 0) && (y >= 0) && (x < (image->width()-1)) && (y < (image->height()-1))) { - unsigned char *t; - t = (unsigned char *)image->scanLine(y); - p = *(colorTable+t[x]); - q = *(colorTable+t[x+1]); - t = (unsigned char *)image->scanLine(y+1); - r = *(colorTable+t[x]); - s = *(colorTable+t[x+1]); - } - else{ - unsigned char *t; - p = background; - if((x >= 0) && (y >= 0)){ - t = (unsigned char *)image->scanLine(y); - p = *(colorTable+t[x]); - } - q = background; - if(((x+1) < image->width()) && (y >= 0)){ - t = (unsigned char *)image->scanLine(y); - q = *(colorTable+t[x+1]); - } - r = background; - if((x >= 0) && ((y+1) < image->height())){ - t = (unsigned char *)image->scanLine(y+1); - r = *(colorTable+t[x]); - } - s = background; - if(((x+1) < image->width()) && ((y+1) < image->height())){ - t = (unsigned char *)image->scanLine(y+1); - s = *(colorTable+t[x+1]); - } - - } - - } - x_offset -= floor(x_offset); - y_offset -= floor(y_offset); - alpha = 1.0-x_offset; - beta = 1.0-y_offset; - - return(tqRgba((unsigned char)(beta*(alpha*tqRed(p)+x_offset*tqRed(q))+y_offset*(alpha*tqRed(r)+x_offset*tqRed(s))), - (unsigned char)(beta*(alpha*tqGreen(p)+x_offset*tqGreen(q))+y_offset*(alpha*tqGreen(r)+x_offset*tqGreen(s))), - (unsigned char)(beta*(alpha*tqBlue(p)+x_offset*tqBlue(q))+y_offset*(alpha*tqBlue(r)+x_offset*tqBlue(s))), - (unsigned char)(beta*(alpha*tqAlpha(p)+x_offset*tqAlpha(q))+y_offset*(alpha*tqAlpha(r)+x_offset*tqAlpha(s))))); -} - -TQImage KImageEffect::implode(TQImage &src, double factor, - unsigned int background) -{ - double amount, distance, radius; - double x_center, x_distance, x_scale; - double y_center, y_distance, y_scale; - unsigned int *destData; - int x, y; - - TQImage dest(src.width(), src.height(), 32); - - // compute scaling factor - x_scale = 1.0; - y_scale = 1.0; - x_center = (double)0.5*src.width(); - y_center = (double)0.5*src.height(); - radius=x_center; - if(src.width() > src.height()) - y_scale = (double)src.width()/src.height(); - else if(src.width() < src.height()){ - x_scale = (double) src.height()/src.width(); - radius = y_center; - } - amount=factor/10.0; - if(amount >= 0) - amount/=10.0; - if(src.depth() > 8){ // DirectClass source image - unsigned int *srcData; - for(y=0; y < src.height(); ++y){ - srcData = (unsigned int *)src.scanLine(y); - destData = (unsigned int *)dest.scanLine(y); - y_distance=y_scale*(y-y_center); - for(x=0; x < src.width(); ++x){ - destData[x] = srcData[x]; - x_distance = x_scale*(x-x_center); - distance= x_distance*x_distance+y_distance*y_distance; - if(distance < (radius*radius)){ - double factor; - // Implode the pixel. - factor=1.0; - if(distance > 0.0) - factor= - pow(sin(0.5000000000000001*M_PI*sqrt(distance)/radius),-amount); - destData[x] = interpolateColor(&src, factor*x_distance/x_scale+x_center, - factor*y_distance/y_scale+y_center, - background); - } - } - } - } - else{ // PsudeoClass source image - unsigned char *srcData; - unsigned char idx; - unsigned int *cTable = src.tqcolorTable(); - for(y=0; y < src.height(); ++y){ - srcData = (unsigned char *)src.scanLine(y); - destData = (unsigned int *)dest.scanLine(y); - y_distance=y_scale*(y-y_center); - for(x=0; x < src.width(); ++x){ - idx = srcData[x]; - destData[x] = cTable[idx]; - x_distance = x_scale*(x-x_center); - distance= x_distance*x_distance+y_distance*y_distance; - if(distance < (radius*radius)){ - double factor; - // Implode the pixel. - factor=1.0; - if(distance > 0.0) - factor= - pow(sin(0.5000000000000001*M_PI*sqrt(distance)/radius),-amount); - destData[x] = interpolateColor(&src, factor*x_distance/x_scale+x_center, - factor*y_distance/y_scale+y_center, - background); - } - } - } - - } - return(dest); -} - -TQImage KImageEffect::rotate(TQImage &img, RotateDirection r) -{ - TQImage dest; - int x, y; - if(img.depth() > 8){ - unsigned int *srcData, *destData; - switch(r){ - case Rotate90: - dest.create(img.height(), img.width(), img.depth()); - for(y=0; y < img.height(); ++y){ - srcData = (unsigned int *)img.scanLine(y); - for(x=0; x < img.width(); ++x){ - destData = (unsigned int *)dest.scanLine(x); - destData[img.height()-y-1] = srcData[x]; - } - } - break; - case Rotate180: - dest.create(img.width(), img.height(), img.depth()); - for(y=0; y < img.height(); ++y){ - srcData = (unsigned int *)img.scanLine(y); - destData = (unsigned int *)dest.scanLine(img.height()-y-1); - for(x=0; x < img.width(); ++x) - destData[img.width()-x-1] = srcData[x]; - } - break; - case Rotate270: - dest.create(img.height(), img.width(), img.depth()); - for(y=0; y < img.height(); ++y){ - srcData = (unsigned int *)img.scanLine(y); - for(x=0; x < img.width(); ++x){ - destData = (unsigned int *)dest.scanLine(img.width()-x-1); - destData[y] = srcData[x]; - } - } - break; - default: - dest = img; - break; - } - } - else{ - unsigned char *srcData, *destData; - unsigned int *srcTable, *destTable; - switch(r){ - case Rotate90: - dest.create(img.height(), img.width(), img.depth()); - dest.setNumColors(img.numColors()); - srcTable = (unsigned int *)img.tqcolorTable(); - destTable = (unsigned int *)dest.tqcolorTable(); - for(x=0; x < img.numColors(); ++x) - destTable[x] = srcTable[x]; - for(y=0; y < img.height(); ++y){ - srcData = (unsigned char *)img.scanLine(y); - for(x=0; x < img.width(); ++x){ - destData = (unsigned char *)dest.scanLine(x); - destData[img.height()-y-1] = srcData[x]; - } - } - break; - case Rotate180: - dest.create(img.width(), img.height(), img.depth()); - dest.setNumColors(img.numColors()); - srcTable = (unsigned int *)img.tqcolorTable(); - destTable = (unsigned int *)dest.tqcolorTable(); - for(x=0; x < img.numColors(); ++x) - destTable[x] = srcTable[x]; - for(y=0; y < img.height(); ++y){ - srcData = (unsigned char *)img.scanLine(y); - destData = (unsigned char *)dest.scanLine(img.height()-y-1); - for(x=0; x < img.width(); ++x) - destData[img.width()-x-1] = srcData[x]; - } - break; - case Rotate270: - dest.create(img.height(), img.width(), img.depth()); - dest.setNumColors(img.numColors()); - srcTable = (unsigned int *)img.tqcolorTable(); - destTable = (unsigned int *)dest.tqcolorTable(); - for(x=0; x < img.numColors(); ++x) - destTable[x] = srcTable[x]; - for(y=0; y < img.height(); ++y){ - srcData = (unsigned char *)img.scanLine(y); - for(x=0; x < img.width(); ++x){ - destData = (unsigned char *)dest.scanLine(img.width()-x-1); - destData[y] = srcData[x]; - } - } - break; - default: - dest = img; - break; - } - - } - return(dest); -} - -void KImageEffect::solarize(TQImage &img, double factor) -{ - int i, count; - int threshold; - unsigned int *data; - - threshold = (int)(factor*(MaxRGB+1)/100.0); - if(img.depth() < 32){ - data = (unsigned int *)img.tqcolorTable(); - count = img.numColors(); - } - else{ - data = (unsigned int *)img.bits(); - count = img.width()*img.height(); - } - for(i=0; i < count; ++i){ - data[i] = tqRgba(tqRed(data[i]) > threshold ? MaxRGB-tqRed(data[i]) : tqRed(data[i]), - tqGreen(data[i]) > threshold ? MaxRGB-tqGreen(data[i]) : tqGreen(data[i]), - tqBlue(data[i]) > threshold ? MaxRGB-tqBlue(data[i]) : tqBlue(data[i]), - tqAlpha(data[i])); - } -} - -TQImage KImageEffect::spread(TQImage &src, unsigned int amount) -{ - int quantum, x, y; - int x_distance, y_distance; - if(src.width() < 3 || src.height() < 3) - return(src); - TQImage dest(src); - dest.detach(); - quantum=(amount+1) >> 1; - if(src.depth() > 8){ // DirectClass source image - unsigned int *p, *q; - for(y=0; y < src.height(); y++){ - q = (unsigned int *)dest.scanLine(y); - for(x=0; x < src.width(); x++){ - x_distance = x + ((rand() & (amount+1))-quantum); - y_distance = y + ((rand() & (amount+1))-quantum); - x_distance = QMIN(x_distance, src.width()-1); - y_distance = QMIN(y_distance, src.height()-1); - if(x_distance < 0) - x_distance = 0; - if(y_distance < 0) - y_distance = 0; - p = (unsigned int *)src.scanLine(y_distance); - p += x_distance; - *q++=(*p); - } - } - } - else{ // PsudeoClass source image - // just do colortable values - unsigned char *p, *q; - for(y=0; y < src.height(); y++){ - q = (unsigned char *)dest.scanLine(y); - for(x=0; x < src.width(); x++){ - x_distance = x + ((rand() & (amount+1))-quantum); - y_distance = y + ((rand() & (amount+1))-quantum); - x_distance = QMIN(x_distance, src.width()-1); - y_distance = QMIN(y_distance, src.height()-1); - if(x_distance < 0) - x_distance = 0; - if(y_distance < 0) - y_distance = 0; - p = (unsigned char *)src.scanLine(y_distance); - p += x_distance; - *q++=(*p); - } - } - } - return(dest); -} - -TQImage KImageEffect::swirl(TQImage &src, double degrees, - unsigned int background) -{ - double cosine, distance, factor, radius, sine, x_center, x_distance, - x_scale, y_center, y_distance, y_scale; - int x, y; - unsigned int *q; - TQImage dest(src.width(), src.height(), 32); - - // compute scaling factor - x_center = src.width()/2.0; - y_center = src.height()/2.0; - radius = QMAX(x_center,y_center); - x_scale=1.0; - y_scale=1.0; - if(src.width() > src.height()) - y_scale=(double)src.width()/src.height(); - else if(src.width() < src.height()) - x_scale=(double)src.height()/src.width(); - degrees=DegreesToRadians(degrees); - // swirl each row - if(src.depth() > 8){ // DirectClass source image - unsigned int *p; - for(y=0; y < src.height(); y++){ - p = (unsigned int *)src.scanLine(y); - q = (unsigned int *)dest.scanLine(y); - y_distance = y_scale*(y-y_center); - for(x=0; x < src.width(); x++){ - // determine if the pixel is within an ellipse - *q=(*p); - x_distance = x_scale*(x-x_center); - distance = x_distance*x_distance+y_distance*y_distance; - if (distance < (radius*radius)){ - // swirl - factor = 1.0-sqrt(distance)/radius; - sine = sin(degrees*factor*factor); - cosine = cos(degrees*factor*factor); - *q = interpolateColor(&src, - (cosine*x_distance-sine*y_distance)/x_scale+x_center, - (sine*x_distance+cosine*y_distance)/y_scale+y_center, - background); - } - p++; - q++; - } - } - } - else{ // PsudeoClass source image - unsigned char *p; - unsigned int *cTable = (unsigned int *)src.tqcolorTable(); - for(y=0; y < src.height(); y++){ - p = (unsigned char *)src.scanLine(y); - q = (unsigned int *)dest.scanLine(y); - y_distance = y_scale*(y-y_center); - for(x=0; x < src.width(); x++){ - // determine if the pixel is within an ellipse - *q = *(cTable+(*p)); - x_distance = x_scale*(x-x_center); - distance = x_distance*x_distance+y_distance*y_distance; - if (distance < (radius*radius)){ - // swirl - factor = 1.0-sqrt(distance)/radius; - sine = sin(degrees*factor*factor); - cosine = cos(degrees*factor*factor); - *q = interpolateColor(&src, - (cosine*x_distance-sine*y_distance)/x_scale+x_center, - (sine*x_distance+cosine*y_distance)/y_scale+y_center, - background); - } - p++; - q++; - } - } - - } - return(dest); -} - -TQImage KImageEffect::wave(TQImage &src, double amplitude, double wavelength, - unsigned int background) -{ - double *sine_map; - int x, y; - unsigned int *q; - - TQImage dest(src.width(), src.height() + (int)(2*fabs(amplitude)), 32); - // allocate sine map - sine_map = (double *)malloc(dest.width()*sizeof(double)); - if(!sine_map) - return(src); - for(x=0; x < dest.width(); ++x) - sine_map[x]=fabs(amplitude)+amplitude*sin((2*M_PI*x)/wavelength); - // wave image - for(y=0; y < dest.height(); ++y){ - q = (unsigned int *)dest.scanLine(y); - for (x=0; x < dest.width(); x++){ - *q=interpolateColor(&src, x, (int)(y-sine_map[x]), background); - ++q; - } - } - free(sine_map); - return(dest); -} - -// -// The following methods work by computing a value from neighboring pixels -// (mosfet 05/26/03) -// - -// New algorithms based on ImageMagick 5.5.6 (05/26/03) - -TQImage KImageEffect::oilPaint(TQImage &src, int /*radius*/) -{ - /* binary compat method - remove me when possible! */ - return(oilPaintConvolve(src, 0)); -} - -TQImage KImageEffect::oilPaintConvolve(TQImage &src, double radius) -{ - unsigned long count /*,*histogram*/; - unsigned long histogram[256]; - unsigned int k; - int width; - int x, y, mx, my, sx, sy; - int mcx, mcy; - unsigned int *s=0, *q; - - if(src.depth() < 32) - src.convertDepth(32); - TQImage dest(src); - dest.detach(); - - width = getOptimalKernelWidth(radius, 0.5); - if(src.width() < width){ - qWarning("KImageEffect::oilPaintConvolve(): Image is smaller than radius!"); - return(dest); - } - /* - histogram = (unsigned long *)malloc(256*sizeof(unsigned long)); - if(!histogram){ - qWarning("KImageEffect::oilPaintColvolve(): Unable to allocate memory!"); - return(dest); - } - */ - unsigned int **jumpTable = (unsigned int **)src.jumpTable(); - for(y=0; y < dest.height(); ++y){ - sy = y-(width/2); - q = (unsigned int *)dest.scanLine(y); - for(x=0; x < dest.width(); ++x){ - count = 0; - memset(histogram, 0, 256*sizeof(unsigned long)); - //memset(histogram, 0, 256); - sy = y-(width/2); - for(mcy=0; mcy < width; ++mcy, ++sy){ - my = sy < 0 ? 0 : sy > src.height()-1 ? - src.height()-1 : sy; - sx = x+(-width/2); - for(mcx=0; mcx < width; ++mcx, ++sx){ - mx = sx < 0 ? 0 : sx > src.width()-1 ? - src.width()-1 : sx; - - k = intensityValue(jumpTable[my][mx]); - if(k > 255){ - qWarning("KImageEffect::oilPaintConvolve(): k is %d", - k); - k = 255; - } - histogram[k]++; - if(histogram[k] > count){ - count = histogram[k]; - s = jumpTable[my]+mx; - } - } - } - if (s) - *q++ = (*s); - } - } - /* liberateMemory((histogram); */ - return(dest); -} - -TQImage KImageEffect::charcoal(TQImage &src, double /*factor*/) -{ - /* binary compat method - remove me when possible! */ - return(charcoal(src, 0, 1)); -} - -TQImage KImageEffect::charcoal(TQImage &src, double radius, double sigma) -{ - TQImage img(edge(src, radius)); - img = blur(img, radius, sigma); - normalize(img); - img.tqinvertPixels(false); - KImageEffect::toGray(img); - return(img); -} - -void KImageEffect::normalize(TQImage &image) -{ - struct double_packet high, low, intensity, *histogram; - struct short_packet *normalize_map; - TQ_INT64 number_pixels; - int x, y; - unsigned int *p, *q; - register long i; - unsigned long threshold_intensity; - unsigned char r, g, b, a; - - if(image.depth() < 32) // result will always be 32bpp - image = image.convertDepth(32); - - histogram = (struct double_packet *) - malloc(256*sizeof(struct double_packet)); - normalize_map = (struct short_packet *) - malloc(256*sizeof(struct short_packet)); - - if(!histogram || !normalize_map){ - if(histogram) - liberateMemory(&histogram); - if(normalize_map) - liberateMemory(&normalize_map); - qWarning("KImageEffect::normalize(): Unable to allocate memory!"); - return; - } - - /* - Form histogram. - */ - memset(histogram, 0, 256*sizeof(struct double_packet)); - for(y=0; y < image.height(); ++y){ - p = (unsigned int *)image.scanLine(y); - for(x=0; x < image.width(); ++x){ - histogram[(unsigned char)(tqRed(*p))].red++; - histogram[(unsigned char)(tqGreen(*p))].green++; - histogram[(unsigned char)(tqBlue(*p))].blue++; - histogram[(unsigned char)(tqAlpha(*p))].alpha++; - p++; - } - } - - /* - Find the histogram boundaries by locating the 0.1 percent levels. - */ - number_pixels = (TQ_INT64)image.width()*image.height(); - threshold_intensity = number_pixels/1000; - - /* red */ - memset(&intensity, 0, sizeof(struct double_packet)); - memset(&high, 0, sizeof(struct double_packet)); - memset(&low, 0, sizeof(struct double_packet)); - for(high.red=255; high.red != 0; high.red--){ - intensity.red+=histogram[(unsigned char)high.red].red; - if(intensity.red > threshold_intensity) - break; - } - if(low.red == high.red){ - threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); - for(low.red=0; low.red < 255; low.red++){ - intensity.red+=histogram[(unsigned char)low.red].red; - if(intensity.red > threshold_intensity) - break; - } - memset(&intensity, 0, sizeof(struct double_packet)); - for(high.red=255; high.red != 0; high.red--){ - intensity.red+=histogram[(unsigned char)high.red].red; - if(intensity.red > threshold_intensity) - break; - } - } - - /* green */ - memset(&intensity, 0, sizeof(struct double_packet)); - for(high.green=255; high.green != 0; high.green--){ - intensity.green+=histogram[(unsigned char)high.green].green; - if(intensity.green > threshold_intensity) - break; - } - if(low.green == high.green){ - threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); - for(low.green=0; low.green < 255; low.green++){ - intensity.green+=histogram[(unsigned char)low.green].green; - if(intensity.green > threshold_intensity) - break; - } - memset(&intensity,0,sizeof(struct double_packet)); - for(high.green=255; high.green != 0; high.green--){ - intensity.green+=histogram[(unsigned char)high.green].green; - if(intensity.green > threshold_intensity) - break; - } - } - - /* blue */ - memset(&intensity, 0, sizeof(struct double_packet)); - for(high.blue=255; high.blue != 0; high.blue--){ - intensity.blue+=histogram[(unsigned char)high.blue].blue; - if(intensity.blue > threshold_intensity) - break; - } - if(low.blue == high.blue){ - threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); - for(low.blue=0; low.blue < 255; low.blue++){ - intensity.blue+=histogram[(unsigned char)low.blue].blue; - if(intensity.blue > threshold_intensity) - break; - } - memset(&intensity,0,sizeof(struct double_packet)); - for(high.blue=255; high.blue != 0; high.blue--){ - intensity.blue+=histogram[(unsigned char)high.blue].blue; - if(intensity.blue > threshold_intensity) - break; - } - } - - /* alpha */ - memset(&intensity, 0, sizeof(struct double_packet)); - for(high.alpha=255; high.alpha != 0; high.alpha--){ - intensity.alpha+=histogram[(unsigned char)high.alpha].alpha; - if(intensity.alpha > threshold_intensity) - break; - } - if(low.alpha == high.alpha){ - threshold_intensity = 0; - memset(&intensity, 0, sizeof(struct double_packet)); - for(low.alpha=0; low.alpha < 255; low.alpha++){ - intensity.alpha+=histogram[(unsigned char)low.alpha].alpha; - if(intensity.alpha > threshold_intensity) - break; - } - memset(&intensity,0,sizeof(struct double_packet)); - for(high.alpha=255; high.alpha != 0; high.alpha--){ - intensity.alpha+=histogram[(unsigned char)high.alpha].alpha; - if(intensity.alpha > threshold_intensity) - break; - } - } - liberateMemory(&histogram); - - /* - Stretch the histogram to create the normalized image mapping. - */ - - // should the maxes be 65535? - memset(normalize_map, 0 ,256*sizeof(struct short_packet)); - for(i=0; i <= (long) 255; i++){ - if(i < (long) low.red) - normalize_map[i].red=0; - else if (i > (long) high.red) - normalize_map[i].red=65535; - else if (low.red != high.red) - normalize_map[i].red = - (unsigned short)((65535*(i-low.red))/(high.red-low.red)); - - if(i < (long) low.green) - normalize_map[i].green=0; - else if (i > (long) high.green) - normalize_map[i].green=65535; - else if (low.green != high.green) - normalize_map[i].green = - (unsigned short)((65535*(i-low.green))/(high.green-low.green)); - - if(i < (long) low.blue) - normalize_map[i].blue=0; - else if (i > (long) high.blue) - normalize_map[i].blue=65535; - else if (low.blue != high.blue) - normalize_map[i].blue = - (unsigned short)((65535*(i-low.blue))/(high.blue-low.blue)); - - if(i < (long) low.alpha) - normalize_map[i].alpha=0; - else if (i > (long) high.alpha) - normalize_map[i].alpha=65535; - else if (low.alpha != high.alpha) - normalize_map[i].alpha = - (unsigned short)((65535*(i-low.alpha))/(high.alpha-low.alpha)); - - } - - for(y=0; y < image.height(); ++y){ - q = (unsigned int *)image.scanLine(y); - for(x=0; x < image.width(); ++x){ - if(low.red != high.red) - r = (normalize_map[(unsigned short)(tqRed(q[x]))].red)/257; - else - r = tqRed(q[x]); - if(low.green != high.green) - g = (normalize_map[(unsigned short)(tqGreen(q[x]))].green)/257; - else - g = tqGreen(q[x]); - if(low.blue != high.blue) - b = (normalize_map[(unsigned short)(tqBlue(q[x]))].blue)/257; - else - b = tqBlue(q[x]); - if(low.alpha != high.alpha) - a = (normalize_map[(unsigned short)(tqAlpha(q[x]))].alpha)/257; - else - a = tqAlpha(q[x]); - q[x] = tqRgba(r, g, b, a); - } - } - liberateMemory(&normalize_map); -} - -void KImageEffect::equalize(TQImage &image) -{ - struct double_packet high, low, intensity, *map, *histogram; - struct short_packet *equalize_map; - int x, y; - unsigned int *p, *q; - long i; - unsigned char r, g, b, a; - - if(image.depth() < 32) // result will always be 32bpp - image = image.convertDepth(32); - - histogram=(struct double_packet *) malloc(256*sizeof(struct double_packet)); - map=(struct double_packet *) malloc(256*sizeof(struct double_packet)); - equalize_map=(struct short_packet *)malloc(256*sizeof(struct short_packet)); - if(!histogram || !map || !equalize_map){ - if(histogram) - liberateMemory(&histogram); - if(map) - liberateMemory(&map); - if(equalize_map) - liberateMemory(&equalize_map); - qWarning("KImageEffect::equalize(): Unable to allocate memory!"); - return; - } - - /* - Form histogram. - */ - memset(histogram, 0, 256*sizeof(struct double_packet)); - for(y=0; y < image.height(); ++y){ - p = (unsigned int *)image.scanLine(y); - for(x=0; x < image.width(); ++x){ - histogram[(unsigned char)(tqRed(*p))].red++; - histogram[(unsigned char)(tqGreen(*p))].green++; - histogram[(unsigned char)(tqBlue(*p))].blue++; - histogram[(unsigned char)(tqAlpha(*p))].alpha++; - p++; - } - } - /* - Integrate the histogram to get the equalization map. - */ - memset(&intensity, 0 ,sizeof(struct double_packet)); - for(i=0; i <= 255; ++i){ - intensity.red += histogram[i].red; - intensity.green += histogram[i].green; - intensity.blue += histogram[i].blue; - intensity.alpha += histogram[i].alpha; - map[i]=intensity; - } - low=map[0]; - high=map[255]; - memset(equalize_map, 0, 256*sizeof(short_packet)); - for(i=0; i <= 255; ++i){ - if(high.red != low.red) - equalize_map[i].red=(unsigned short) - ((65535*(map[i].red-low.red))/(high.red-low.red)); - if(high.green != low.green) - equalize_map[i].green=(unsigned short) - ((65535*(map[i].green-low.green))/(high.green-low.green)); - if(high.blue != low.blue) - equalize_map[i].blue=(unsigned short) - ((65535*(map[i].blue-low.blue))/(high.blue-low.blue)); - if(high.alpha != low.alpha) - equalize_map[i].alpha=(unsigned short) - ((65535*(map[i].alpha-low.alpha))/(high.alpha-low.alpha)); - } - liberateMemory(&histogram); - liberateMemory(&map); - - /* - Stretch the histogram. - */ - for(y=0; y < image.height(); ++y){ - q = (unsigned int *)image.scanLine(y); - for(x=0; x < image.width(); ++x){ - if(low.red != high.red) - r = (equalize_map[(unsigned short)(tqRed(q[x]))].red/257); - else - r = tqRed(q[x]); - if(low.green != high.green) - g = (equalize_map[(unsigned short)(tqGreen(q[x]))].green/257); - else - g = tqGreen(q[x]); - if(low.blue != high.blue) - b = (equalize_map[(unsigned short)(tqBlue(q[x]))].blue/257); - else - b = tqBlue(q[x]); - if(low.alpha != high.alpha) - a = (equalize_map[(unsigned short)(tqAlpha(q[x]))].alpha/257); - else - a = tqAlpha(q[x]); - q[x] = tqRgba(r, g, b, a); - } - } - liberateMemory(&equalize_map); - -} - -TQImage KImageEffect::edge(TQImage &image, double radius) -{ - double *kernel; - int width; - register long i; - TQImage dest; - - if(radius == 50.0){ - /* For binary compatability! Remove me when possible! This used to - * take a different parameter, a factor, and this was the default - * value */ - radius = 0.0; - } - - width = getOptimalKernelWidth(radius, 0.5); - if(image.width() < width || image.height() < width){ - qWarning("KImageEffect::edge(): Image is smaller than radius!"); - return(dest); - } - kernel= (double *)malloc(width*width*sizeof(double)); - if(!kernel){ - qWarning("KImageEffect::edge(): Unable to allocate memory!"); - return(dest); - } - for(i=0; i < (width*width); i++) - kernel[i]=(-1.0); - kernel[i/2]=width*width-1.0; - convolveImage(&image, &dest, width, kernel); - free(kernel); - return(dest); -} - -TQImage KImageEffect::emboss(TQImage &src) -{ - /* binary compat method - remove me when possible! */ - return(emboss(src, 0, 1)); -} - -TQImage KImageEffect::emboss(TQImage &image, double radius, double sigma) -{ - double alpha, *kernel; - int j, width; - register long i, u, v; - TQImage dest; - - if(sigma == 0.0){ - qWarning("KImageEffect::emboss(): Zero sigma is not permitted!"); - return(dest); - } - - width = getOptimalKernelWidth(radius, sigma); - if(image.width() < width || image.height() < width){ - qWarning("KImageEffect::emboss(): Image is smaller than radius!"); - return(dest); - } - kernel= (double *)malloc(width*width*sizeof(double)); - if(!kernel){ - qWarning("KImageEffect::emboss(): Unable to allocate memory!"); - return(dest); - } - if(image.depth() < 32) - image = image.convertDepth(32); - - i=0; - j=width/2; - for(v=(-width/2); v <= (width/2); v++){ - for(u=(-width/2); u <= (width/2); u++){ - alpha=exp(-((double) u*u+v*v)/(2.0*sigma*sigma)); - kernel[i]=((u < 0) || (v < 0) ? -8.0 : 8.0)*alpha/ - (2.0*MagickPI*sigma*sigma); - if (u == j) - kernel[i]=0.0; - i++; - } - j--; - } - convolveImage(&image, &dest, width, kernel); - liberateMemory(&kernel); - - equalize(dest); - return(dest); -} - -void KImageEffect::blurScanLine(double *kernel, int width, - unsigned int *src, unsigned int *dest, - int columns) -{ - register double *p; - unsigned int *q; - register int x; - register long i; - double red, green, blue, alpha; - double scale = 0.0; - - if(width > columns){ - for(x=0; x < columns; ++x){ - scale = 0.0; - red = blue = green = alpha = 0.0; - p = kernel; - q = src; - for(i=0; i < columns; ++i){ - if((i >= (x-width/2)) && (i <= (x+width/2))){ - red += (*p)*(tqRed(*q)*257); - green += (*p)*(tqGreen(*q)*257); - blue += (*p)*(tqBlue(*q)*257); - alpha += (*p)*(tqAlpha(*q)*257); - } - if(((i+width/2-x) >= 0) && ((i+width/2-x) < width)) - scale+=kernel[i+width/2-x]; - p++; - q++; - } - scale = 1.0/scale; - red = scale*(red+0.5); - green = scale*(green+0.5); - blue = scale*(blue+0.5); - alpha = scale*(alpha+0.5); - - red = red < 0 ? 0 : red > 65535 ? 65535 : red; - green = green < 0 ? 0 : green > 65535 ? 65535 : green; - blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue; - alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha; - - dest[x] = tqRgba((unsigned char)(red/257UL), - (unsigned char)(green/257UL), - (unsigned char)(blue/257UL), - (unsigned char)(alpha/257UL)); - } - return; - } - - for(x=0; x < width/2; ++x){ - scale = 0.0; - red = blue = green = alpha = 0.0; - p = kernel+width/2-x; - q = src; - for(i=width/2-x; i < width; ++i){ - red += (*p)*(tqRed(*q)*257); - green += (*p)*(tqGreen(*q)*257); - blue += (*p)*(tqBlue(*q)*257); - alpha += (*p)*(tqAlpha(*q)*257); - scale += (*p); - p++; - q++; - } - scale=1.0/scale; - - red = scale*(red+0.5); - green = scale*(green+0.5); - blue = scale*(blue+0.5); - alpha = scale*(alpha+0.5); - - red = red < 0 ? 0 : red > 65535 ? 65535 : red; - green = green < 0 ? 0 : green > 65535 ? 65535 : green; - blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue; - alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha; - - dest[x] = tqRgba((unsigned char)(red/257UL), - (unsigned char)(green/257UL), - (unsigned char)(blue/257UL), - (unsigned char)(alpha/257UL)); - } - - for(; x < columns-width/2; ++x){ - red = blue = green = alpha = 0.0; - p = kernel; - q = src+(x-width/2); - for (i=0; i < (long) width; ++i){ - red += (*p)*(tqRed(*q)*257); - green += (*p)*(tqGreen(*q)*257); - blue += (*p)*(tqBlue(*q)*257); - alpha += (*p)*(tqAlpha(*q)*257); - p++; - q++; - } - red = scale*(red+0.5); - green = scale*(green+0.5); - blue = scale*(blue+0.5); - alpha = scale*(alpha+0.5); - - red = red < 0 ? 0 : red > 65535 ? 65535 : red; - green = green < 0 ? 0 : green > 65535 ? 65535 : green; - blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue; - alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha; - - dest[x] = tqRgba((unsigned char)(red/257UL), - (unsigned char)(green/257UL), - (unsigned char)(blue/257UL), - (unsigned char)(alpha/257UL)); - } - - for(; x < columns; ++x){ - red = blue = green = alpha = 0.0; - scale=0; - p = kernel; - q = src+(x-width/2); - for(i=0; i < columns-x+width/2; ++i){ - red += (*p)*(tqRed(*q)*257); - green += (*p)*(tqGreen(*q)*257); - blue += (*p)*(tqBlue(*q)*257); - alpha += (*p)*(tqAlpha(*q)*257); - scale += (*p); - p++; - q++; - } - scale=1.0/scale; - red = scale*(red+0.5); - green = scale*(green+0.5); - blue = scale*(blue+0.5); - alpha = scale*(alpha+0.5); - - red = red < 0 ? 0 : red > 65535 ? 65535 : red; - green = green < 0 ? 0 : green > 65535 ? 65535 : green; - blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue; - alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha; - - dest[x] = tqRgba((unsigned char)(red/257UL), - (unsigned char)(green/257UL), - (unsigned char)(blue/257UL), - (unsigned char)(alpha/257UL)); - } -} - -int KImageEffect::getBlurKernel(int width, double sigma, double **kernel) -{ -#define KernelRank 3 - double alpha, normalize; - register long i; - int bias; - - assert(sigma != 0.0); - if(width == 0) - width = 3; - *kernel=(double *)malloc(width*sizeof(double)); - if(*kernel == (double *)NULL) - return(0); - memset(*kernel, 0, width*sizeof(double)); - bias = KernelRank*width/2; - for(i=(-bias); i <= bias; i++){ - alpha=exp(-((double) i*i)/(2.0*KernelRank*KernelRank*sigma*sigma)); - (*kernel)[(i+bias)/KernelRank]+=alpha/(MagickSQ2PI*sigma); - } - normalize=0; - for(i=0; i < width; i++) - normalize+=(*kernel)[i]; - for(i=0; i < width; i++) - (*kernel)[i]/=normalize; - - return(width); -} - -TQImage KImageEffect::blur(TQImage &src, double /*factor*/) -{ - /* binary compat method - remove me when possible! */ - return(blur(src, 0, 1)); -} - -TQImage KImageEffect::blur(TQImage &src, double radius, double sigma) -{ - double *kernel; - TQImage dest; - int width; - int x, y; - unsigned int *scanline, *temp; - unsigned int *p, *q; - - if(sigma == 0.0){ - qWarning("KImageEffect::blur(): Zero sigma is not permitted!"); - return(dest); - } - if(src.depth() < 32) - src = src.convertDepth(32); - - kernel=(double *) NULL; - if(radius > 0) - width=getBlurKernel((int) (2*ceil(radius)+1),sigma,&kernel); - else{ - double *last_kernel; - last_kernel=(double *) NULL; - width=getBlurKernel(3,sigma,&kernel); - - while ((long) (MaxRGB*kernel[0]) > 0){ - if(last_kernel != (double *)NULL){ - liberateMemory(&last_kernel); - } - last_kernel=kernel; - kernel = (double *)NULL; - width = getBlurKernel(width+2, sigma, &kernel); - } - if(last_kernel != (double *) NULL){ - liberateMemory(&kernel); - width-=2; - kernel = last_kernel; - } - } - - if(width < 3){ - qWarning("KImageEffect::blur(): Kernel radius is too small!"); - liberateMemory(&kernel); - return(dest); - } - - dest.create(src.width(), src.height(), 32); - - // Horizontal convolution - scanline = (unsigned int *)malloc(sizeof(unsigned int)*src.height()); - temp = (unsigned int *)malloc(sizeof(unsigned int)*src.height()); - for(y=0; y < src.height(); ++y){ - p = (unsigned int *)src.scanLine(y); - q = (unsigned int *)dest.scanLine(y); - blurScanLine(kernel, width, p, q, src.width()); - } - - TQImage partial = dest; - - // Vertical convolution - unsigned int **srcTable = (unsigned int **)partial.jumpTable(); - unsigned int **destTable = (unsigned int **)dest.jumpTable(); - for(x=0; x < partial.width(); ++x){ - for(y=0; y < partial.height(); ++y){ - scanline[y] = srcTable[y][x]; - } - blurScanLine(kernel, width, scanline, temp, partial.height()); - for(y=0; y < partial.height(); ++y){ - destTable[y][x] = temp[y]; - } - } - free(scanline); - free(temp); - free(kernel); - return(dest); -} - -bool KImageEffect::convolveImage(TQImage *image, TQImage *dest, - const unsigned int order, - const double *kernel) -{ - long width; - double red, green, blue, alpha; - double normalize, *normal_kernel; - register const double *k; - register unsigned int *q; - int x, y, mx, my, sx, sy; - long i; - int mcx, mcy; - - width = order; - if((width % 2) == 0){ - qWarning("KImageEffect: Kernel width must be an odd number!"); - return(false); - } - normal_kernel = (double *)malloc(width*width*sizeof(double)); - if(!normal_kernel){ - qWarning("KImageEffect: Unable to allocate memory!"); - return(false); - } - dest->reset(); - dest->create(image->width(), image->height(), 32); - if(image->depth() < 32) - *image = image->convertDepth(32); - - normalize=0.0; - for(i=0; i < (width*width); i++) - normalize += kernel[i]; - if(fabs(normalize) <= MagickEpsilon) - normalize=1.0; - normalize=1.0/normalize; - for(i=0; i < (width*width); i++) - normal_kernel[i] = normalize*kernel[i]; - - unsigned int **jumpTable = (unsigned int **)image->jumpTable(); - for(y=0; y < dest->height(); ++y){ - sy = y-(width/2); - q = (unsigned int *)dest->scanLine(y); - for(x=0; x < dest->width(); ++x){ - k = normal_kernel; - red = green = blue = alpha = 0; - sy = y-(width/2); - for(mcy=0; mcy < width; ++mcy, ++sy){ - my = sy < 0 ? 0 : sy > image->height()-1 ? - image->height()-1 : sy; - sx = x+(-width/2); - for(mcx=0; mcx < width; ++mcx, ++sx){ - mx = sx < 0 ? 0 : sx > image->width()-1 ? - image->width()-1 : sx; - red += (*k)*(tqRed(jumpTable[my][mx])*257); - green += (*k)*(tqGreen(jumpTable[my][mx])*257); - blue += (*k)*(tqBlue(jumpTable[my][mx])*257); - alpha += (*k)*(tqAlpha(jumpTable[my][mx])*257); - ++k; - } - } - - red = red < 0 ? 0 : red > 65535 ? 65535 : red+0.5; - green = green < 0 ? 0 : green > 65535 ? 65535 : green+0.5; - blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue+0.5; - alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha+0.5; - - *q++ = tqRgba((unsigned char)(red/257UL), - (unsigned char)(green/257UL), - (unsigned char)(blue/257UL), - (unsigned char)(alpha/257UL)); - } - } - free(normal_kernel); - return(true); - -} - -int KImageEffect::getOptimalKernelWidth(double radius, double sigma) -{ - double normalize, value; - long width; - register long u; - - assert(sigma != 0.0); - if(radius > 0.0) - return((int)(2.0*ceil(radius)+1.0)); - for(width=5; ;){ - normalize=0.0; - for(u=(-width/2); u <= (width/2); u++) - normalize+=exp(-((double) u*u)/(2.0*sigma*sigma))/(MagickSQ2PI*sigma); - u=width/2; - value=exp(-((double) u*u)/(2.0*sigma*sigma))/(MagickSQ2PI*sigma)/normalize; - if((long)(65535*value) <= 0) - break; - width+=2; - } - return((int)width-2); -} - -TQImage KImageEffect::sharpen(TQImage &src, double /*factor*/) -{ - /* binary compat method - remove me when possible! */ - return(sharpen(src, 0, 1)); -} - -TQImage KImageEffect::sharpen(TQImage &image, double radius, double sigma) -{ - double alpha, normalize, *kernel; - int width; - register long i, u, v; - TQImage dest; - - if(sigma == 0.0){ - qWarning("KImageEffect::sharpen(): Zero sigma is not permitted!"); - return(dest); - } - width = getOptimalKernelWidth(radius, sigma); - if(image.width() < width){ - qWarning("KImageEffect::sharpen(): Image is smaller than radius!"); - return(dest); - } - kernel = (double *)malloc(width*width*sizeof(double)); - if(!kernel){ - qWarning("KImageEffect::sharpen(): Unable to allocate memory!"); - return(dest); - } - - i = 0; - normalize=0.0; - for(v=(-width/2); v <= (width/2); v++){ - for(u=(-width/2); u <= (width/2); u++){ - alpha=exp(-((double) u*u+v*v)/(2.0*sigma*sigma)); - kernel[i]=alpha/(2.0*MagickPI*sigma*sigma); - normalize+=kernel[i]; - i++; - } - } - kernel[i/2]=(-2.0)*normalize; - convolveImage(&image, &dest, width, kernel); - free(kernel); - return(dest); -} - -// End of new algorithms - -TQImage KImageEffect::shade(TQImage &src, bool color_shading, double azimuth, - double elevation) -{ - struct PointInfo{ - double x, y, z; - }; - - double distance, normal_distance, shade; - int x, y; - - struct PointInfo light, normal; - - unsigned int *q; - - TQImage dest(src.width(), src.height(), 32); - - azimuth = DegreesToRadians(azimuth); - elevation = DegreesToRadians(elevation); - light.x = MaxRGB*cos(azimuth)*cos(elevation); - light.y = MaxRGB*sin(azimuth)*cos(elevation); - light.z = MaxRGB*sin(elevation); - normal.z= 2*MaxRGB; // constant Z of surface normal - - if(src.depth() > 8){ // DirectClass source image - unsigned int *p, *s0, *s1, *s2; - for(y=0; y < src.height(); ++y){ - p = (unsigned int *)src.scanLine(QMIN(QMAX(y-1,0),src.height()-3)); - q = (unsigned int *)dest.scanLine(y); - // shade this row of pixels. - *q++=(*(p+src.width())); - p++; - s0 = p; - s1 = p + src.width(); - s2 = p + 2*src.width(); - for(x=1; x < src.width()-1; ++x){ - // determine the surface normal and compute shading. - normal.x=intensityValue(*(s0-1))+intensityValue(*(s1-1))+intensityValue(*(s2-1))- - (double) intensityValue(*(s0+1))-(double) intensityValue(*(s1+1))- - (double) intensityValue(*(s2+1)); - normal.y=intensityValue(*(s2-1))+intensityValue(*s2)+intensityValue(*(s2+1))- - (double) intensityValue(*(s0-1))-(double) intensityValue(*s0)- - (double) intensityValue(*(s0+1)); - if((normal.x == 0) && (normal.y == 0)) - shade=light.z; - else{ - shade=0.0; - distance=normal.x*light.x+normal.y*light.y+normal.z*light.z; - if (distance > 0.0){ - normal_distance= - normal.x*normal.x+normal.y*normal.y+normal.z*normal.z; - if(fabs(normal_distance) > 0.0000001) - shade=distance/sqrt(normal_distance); - } - } - if(!color_shading){ - *q = tqRgba((unsigned char)(shade), - (unsigned char)(shade), - (unsigned char)(shade), - tqAlpha(*s1)); - } - else{ - *q = tqRgba((unsigned char)((shade*tqRed(*s1))/(MaxRGB+1)), - (unsigned char)((shade*tqGreen(*s1))/(MaxRGB+1)), - (unsigned char)((shade*tqBlue(*s1))/(MaxRGB+1)), - tqAlpha(*s1)); - } - ++s0; - ++s1; - ++s2; - q++; - } - *q++=(*s1); - } - } - else{ // PsudeoClass source image - unsigned char *p, *s0, *s1, *s2; - int scanLineIdx; - unsigned int *cTable = (unsigned int *)src.tqcolorTable(); - for(y=0; y < src.height(); ++y){ - scanLineIdx = QMIN(QMAX(y-1,0),src.height()-3); - p = (unsigned char *)src.scanLine(scanLineIdx); - q = (unsigned int *)dest.scanLine(y); - // shade this row of pixels. - s0 = p; - s1 = (unsigned char *) src.scanLine(scanLineIdx+1); - s2 = (unsigned char *) src.scanLine(scanLineIdx+2); - *q++=(*(cTable+(*s1))); - ++p; - ++s0; - ++s1; - ++s2; - for(x=1; x < src.width()-1; ++x){ - // determine the surface normal and compute shading. - normal.x=intensityValue(*(cTable+(*(s0-1))))+intensityValue(*(cTable+(*(s1-1))))+intensityValue(*(cTable+(*(s2-1))))- - (double) intensityValue(*(cTable+(*(s0+1))))-(double) intensityValue(*(cTable+(*(s1+1))))- - (double) intensityValue(*(cTable+(*(s2+1)))); - normal.y=intensityValue(*(cTable+(*(s2-1))))+intensityValue(*(cTable+(*s2)))+intensityValue(*(cTable+(*(s2+1))))- - (double) intensityValue(*(cTable+(*(s0-1))))-(double) intensityValue(*(cTable+(*s0)))- - (double) intensityValue(*(cTable+(*(s0+1)))); - if((normal.x == 0) && (normal.y == 0)) - shade=light.z; - else{ - shade=0.0; - distance=normal.x*light.x+normal.y*light.y+normal.z*light.z; - if (distance > 0.0){ - normal_distance= - normal.x*normal.x+normal.y*normal.y+normal.z*normal.z; - if(fabs(normal_distance) > 0.0000001) - shade=distance/sqrt(normal_distance); - } - } - if(!color_shading){ - *q = tqRgba((unsigned char)(shade), - (unsigned char)(shade), - (unsigned char)(shade), - tqAlpha(*(cTable+(*s1)))); - } - else{ - *q = tqRgba((unsigned char)((shade*tqRed(*(cTable+(*s1))))/(MaxRGB+1)), - (unsigned char)((shade*tqGreen(*(cTable+(*s1))))/(MaxRGB+1)), - (unsigned char)((shade*tqBlue(*(cTable+(*s1))))/(MaxRGB+1)), - tqAlpha(*s1)); - } - ++s0; - ++s1; - ++s2; - q++; - } - *q++=(*(cTable+(*s1))); - } - } - return(dest); -} - -// High quality, expensive HSV contrast. You can do a faster one by just -// taking a grayscale threshold (ie: 128) and incrementing RGB color -// channels above it and decrementing those below it, but this gives much -// better results. (mosfet 12/28/01) -void KImageEffect::contrastHSV(TQImage &img, bool sharpen) -{ - int i, sign; - unsigned int *data; - int count; - double brightness, scale, theta; - TQColor c; - int h, s, v; - - sign = sharpen ? 1 : -1; - scale=0.5000000000000001; - if(img.depth() > 8){ - count = img.width()*img.height(); - data = (unsigned int *)img.bits(); - } - else{ - count = img.numColors(); - data = (unsigned int *)img.tqcolorTable(); - } - for(i=0; i < count; ++i){ - c.setRgb(data[i]); - c.hsv(&h, &s, &v); - brightness = v/255.0; - theta=(brightness-0.5)*M_PI; - brightness+=scale*(((scale*((sin(theta)+1.0)))-brightness)*sign); - if (brightness > 1.0) - brightness=1.0; - else - if (brightness < 0) - brightness=0.0; - v = (int)(brightness*255); - c.setHsv(h, s, v); - data[i] = tqRgba(c.red(), c.green(), c.blue(), tqAlpha(data[i])); - } -} - - -struct BumpmapParams { - BumpmapParams( double bm_azimuth, double bm_elevation, - int bm_depth, KImageEffect::BumpmapType bm_type, - bool invert ) { - /* Convert to radians */ - double azimuth = DegreesToRadians( bm_azimuth ); - double elevation = DegreesToRadians( bm_elevation ); - - /* Calculate the light vector */ - lx = (int)( cos(azimuth) * cos(elevation) * 255.0 ); - ly = (int)( sin(azimuth) * cos(elevation) * 255.0 ); - int lz = (int)( sin(elevation) * 255.0 ); - - /* Calculate constant Z component of surface normal */ - int nz = (6 * 255) / bm_depth; - nz2 = nz * nz; - nzlz = nz * lz; - - /* Optimize for vertical normals */ - background = lz; - - /* Calculate darkness compensation factor */ - compensation = sin(elevation); - - /* Create look-up table for map type */ - for (int i = 0; i < 256; i++) - { - double n = 0; - switch (bm_type) - { - case KImageEffect::Spherical: - n = i / 255.0 - 1.0; - lut[i] = (int) (255.0 * sqrt(1.0 - n * n) + 0.5); - break; - - case KImageEffect::Sinuosidal: - n = i / 255.0; - lut[i] = (int) (255.0 * (sin((-M_PI / 2.0) + M_PI * n) + 1.0) / - 2.0 + 0.5); - break; - - case KImageEffect::Linear: - default: - lut[i] = i; - } - - if (invert) - lut[i] = 255 - lut[i]; - } - } - int lx, ly; - int nz2, nzlz; - int background; - double compensation; - uchar lut[256]; -}; - - -static void bumpmap_convert_row( uint *row, - int width, - int bpp, - int has_alpha, - uchar *lut, - int waterlevel ) -{ - uint *p; - - p = row; - - has_alpha = has_alpha ? 1 : 0; - - if (bpp >= 3) - for (; width; width--) - { - if (has_alpha) { - unsigned int idx = (unsigned int)(intensityValue( *row ) + 0.5); - *p++ = lut[(unsigned int) ( waterlevel + - ( ( idx - - waterlevel) * tqBlue( *row )) / 255.0 )]; - } else { - unsigned int idx = (unsigned int)(intensityValue( *row ) + 0.5); - *p++ = lut[idx]; - } - - ++row; - } -} - -static void bumpmap_row( uint *src, - uint *dest, - int width, - int bpp, - int has_alpha, - uint *bm_row1, - uint *bm_row2, - uint *bm_row3, - int bm_width, - int bm_xofs, - bool tiled, - bool row_in_bumpmap, - int ambient, - bool compensate, - BumpmapParams *params ) -{ - int xofs1, xofs2, xofs3; - int shade; - int ndotl; - int nx, ny; - int x; - int tmp; - - tmp = bm_xofs; - xofs2 = MOD(tmp, bm_width); - - for (x = 0; x < width; x++) - { - /* Calculate surface normal from bump map */ - - if (tiled || (row_in_bumpmap && - x >= - tmp && x < - tmp + bm_width)) { - if (tiled) { - xofs1 = MOD(xofs2 - 1, bm_width); - xofs3 = MOD(xofs2 + 1, bm_width); - } else { - xofs1 = FXCLAMP(xofs2 - 1, 0, bm_width - 1); - xofs3 = FXCLAMP(xofs2 + 1, 0, bm_width - 1); - } - nx = (bm_row1[xofs1] + bm_row2[xofs1] + bm_row3[xofs1] - - bm_row1[xofs3] - bm_row2[xofs3] - bm_row3[xofs3]); - ny = (bm_row3[xofs1] + bm_row3[xofs2] + bm_row3[xofs3] - - bm_row1[xofs1] - bm_row1[xofs2] - bm_row1[xofs3]); - } else { - nx = ny = 0; - } - - /* Shade */ - - if ((nx == 0) && (ny == 0)) - shade = params->background; - else { - ndotl = nx * params->lx + ny * params->ly + params->nzlz; - - if (ndotl < 0) - shade = (int)( params->compensation * ambient ); - else { - shade = (int)( ndotl / sqrt(double(nx * nx + ny * ny + params->nz2)) ); - - shade = (int)( shade + QMAX(0.0, (255 * params->compensation - shade)) * - ambient / 255 ); - } - } - - /* Paint */ - - /** - * NOTE: if we want to work with non-32bit images the alpha handling would - * also change - */ - if (compensate) { - int red = (int)((tqRed( *src ) * shade) / (params->compensation * 255)); - int green = (int)((tqGreen( *src ) * shade) / (params->compensation * 255)); - int blue = (int)((tqBlue( *src ) * shade) / (params->compensation * 255)); - int alpha = (int)((tqAlpha( *src ) * shade) / (params->compensation * 255)); - ++src; - *dest++ = tqRgba( red, green, blue, alpha ); - } else { - int red = tqRed( *src ) * shade / 255; - int green = tqGreen( *src ) * shade / 255; - int blue = tqBlue( *src ) * shade / 255; - int alpha = tqAlpha( *src ) * shade / 255; - ++src; - *dest++ = tqRgba( red, green, blue, alpha ); - } - - /* Next pixel */ - - if (++xofs2 == bm_width) - xofs2 = 0; - } -} - -/** - * A bumpmapping algorithm. - * - * @param img the image you want bumpmap - * @param map the map used - * @param azimuth azimuth - * @param elevation elevation - * @param depth depth (not the depth of the image, but of the map) - * @param xofs X offset - * @param yofs Y offset - * @param waterlevel level that full transparency should represent - * @param ambient ambient lighting factor - * @param compensate compensate for darkening - * @param invert invert bumpmap - * @param type type of the bumpmap - * - * @return The destination image (dst) containing the result. - * @author Zack Rusin <zack@kde.org> - */ -TQImage KImageEffect::bumpmap(TQImage &img, TQImage &map, double azimuth, double elevation, - int depth, int xofs, int yofs, int waterlevel, - int ambient, bool compensate, bool invert, - BumpmapType type, bool tiled) -{ - TQImage dst; - - if ( img.depth() != 32 || img.depth() != 32 ) { - qWarning( "Bump-mapping effect works only with 32 bit images"); - return dst; - } - - dst.create( img.width(), img.height(), img.depth() ); - int bm_width = map.width(); - int bm_height = map.height(); - int bm_bpp = map.depth(); - int bm_has_alpha = map.hasAlphaBuffer(); - - int yofs1, yofs2, yofs3; - - if ( tiled ) { - yofs2 = MOD( yofs, bm_height ); - yofs1 = MOD( yofs2 - 1, bm_height); - yofs3 = MOD( yofs2 + 1, bm_height); - } else { - yofs1 = 0; - yofs2 = 0; - yofs3 = FXCLAMP( yofs2+1, 0, bm_height - 1 ); - } - - BumpmapParams params( azimuth, elevation, depth, type, invert ); - - uint* bm_row1 = (unsigned int*)map.scanLine( yofs1 ); - uint* bm_row2 = (unsigned int*)map.scanLine( yofs2 ); - uint* bm_row3 = (unsigned int*)map.scanLine( yofs3 ); - - bumpmap_convert_row( bm_row1, bm_width, bm_bpp, bm_has_alpha, params.lut, waterlevel ); - bumpmap_convert_row( bm_row2, bm_width, bm_bpp, bm_has_alpha, params.lut, waterlevel ); - bumpmap_convert_row( bm_row3, bm_width, bm_bpp, bm_has_alpha, params.lut, waterlevel ); - - for (int y = 0; y < img.height(); ++y) - { - int row_in_bumpmap = (y >= - yofs && y < - yofs + bm_height); - - uint* src_row = (unsigned int*)img.scanLine( y ); - uint* dest_row = (unsigned int*)dst.scanLine( y ); - - bumpmap_row( src_row, dest_row, img.width(), img.depth(), img.hasAlphaBuffer(), - bm_row1, bm_row2, bm_row3, bm_width, xofs, - tiled, - row_in_bumpmap, ambient, compensate, - ¶ms ); - - /* Next line */ - - if (tiled || row_in_bumpmap) - { - uint* bm_tmprow = bm_row1; - bm_row1 = bm_row2; - bm_row2 = bm_row3; - bm_row3 = bm_tmprow; - - if (++yofs2 == bm_height) - yofs2 = 0; - - if (tiled) - yofs3 = MOD(yofs2 + 1, bm_height); - else - yofs3 = FXCLAMP(yofs2 + 1, 0, bm_height - 1); - - bm_row3 = (unsigned int*)map.scanLine( yofs3 ); - bumpmap_convert_row( bm_row3, bm_width, bm_bpp, bm_has_alpha, - params.lut, waterlevel ); - } - } - return dst; -} - -/** - * Convert an image with standard alpha to premultiplied alpha - * - * @param img the image you want convert - * - * @return The destination image (dst) containing the result. - * @author Timothy Pearson <kb9vqf@pearsoncomputing.net> - */ -TQImage KImageEffect::convertToPremultipliedAlpha(TQImage input) { - TQImage alphaImage = input; - if (!alphaImage.isNull()) alphaImage = alphaImage.convertDepth( 32 ); - - int w = alphaImage.width(); - int h = alphaImage.height(); - - register int r; - register int g; - register int b; - register int a; - register float alpha_adjust; - register TQRgb l; - TQRgb *ls; - for (int y = 0; y < h; ++y) { - ls = (TQRgb *)alphaImage.scanLine( y ); - for (int x = 0; x < w; ++x) { - l = ls[x]; - alpha_adjust = (tqAlpha( l )/255.0); - r = int( tqRed( l ) * alpha_adjust ); - g = int( tqGreen( l ) * alpha_adjust ); - b = int( tqBlue( l ) * alpha_adjust ); - a = int( tqAlpha( l ) * 1.0 ); - ls[x] = tqRgba( r, g, b, a ); - } - } - return alphaImage; -} \ No newline at end of file diff --git a/kdefx/kimageeffect.h b/kdefx/kimageeffect.h deleted file mode 100644 index 8d73e5bfb..000000000 --- a/kdefx/kimageeffect.h +++ /dev/null @@ -1,817 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com> - (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> - (C) 1998, 1999 Dirk Mueller <mueller@kde.org> - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -// $Id$ - -#ifndef __KIMAGE_EFFECT_H -#define __KIMAGE_EFFECT_H - -#include <kdelibs_export.h> - -class TQImage; -class TQSize; -class TQColor; -class TQPoint; -class TQRect; - -/** - * This class includes various TQImage based graphical effects. - * - * Everything is - * static, so there is no need to create an instance of this class. You can - * just call the static methods. They are encapsulated here merely to provide - * a common namespace. - */ -class KDEFX_EXPORT KImageEffect -{ -public: - /** - * This enum provides a gradient type specification - * @see KImageEffect::blend(), KImageEffect::gradient(), - * KImageEffect::unbalancedGradient() - */ - enum GradientType { VerticalGradient, - HorizontalGradient, - DiagonalGradient, - CrossDiagonalGradient, - PyramidGradient, - RectangleGradient, - PipeCrossGradient, - EllipticGradient - }; - - /** - * This enum provides a RGB channel specification - * @see KImageEffect::blend(), KImageEffect::channelIntensity(), - * KImageEffect::modulate() - */ - enum RGBComponent { Red, //!< Red channel - Green, //!< Green channel - Blue, //!< Blue channel - Gray, //!< Grey channel - All //!< All channels - }; - - /** - * This enum provides a lighting direction specification - * @see KImageEffect::hash() - */ - enum Lighting {NorthLite, //!< Lighting from the top of the image - NWLite, //!< Lighting from the top left of the image - WestLite, //!< Lighting from the left of the image - SWLite, //!< Lighting from the bottom left of the image - SouthLite, //!< Lighting from the bottom of the image - SELite, //!< Lighting from the bottom right of the image - EastLite, //!< Lighting from the right of the image - NELite //!< Lighting from the top right of the image - }; - - /** - * This enum provides a modulation type specification - * @see KImageEffect::modulate() - */ - enum ModulationType { Intensity, //!< Modulate image intensity - Saturation, //!< Modulate image saturation - HueShift, //!< Modulate image hue - Contrast //!< Modulate image contrast - }; - - /** - * This enum provides a noise type specification - * @see KImageEffect::addNoise() - */ - enum NoiseType { UniformNoise=0, //!< Uniform distribution - GaussianNoise, //!< Gaussian distribution - MultiplicativeGaussianNoise, //!< Multiplicative Gaussian distribution - ImpulseNoise, //!< Impulse distribution - LaplacianNoise, //!< Laplacian distribution - PoissonNoise //!< Poisson distribution - }; - - /** - * This enum provides a rotation specification. - * @see KImageEffect::rotate() - */ - enum RotateDirection{ Rotate90, //!< Rotate 90 degrees to the right. - Rotate180, //!< Rotate 180 degrees. - Rotate270 //!< Rotate 90 degrees to the left. - }; - - /** - * This enum lists possible bumpmapping implementations. - * @see KImageEffect::bumpmap() - */ - enum BumpmapType { - Linear, - Spherical, - Sinuosidal - }; - - /** - * Create a gradient from color a to color b of the specified type. - * - * @param size The desired size of the gradient. - * @param ca Color a - * @param cb Color b - * @param type The type of gradient. - * @param ncols The number of colors to use when not running on a - * truecolor display. The gradient will be dithered to this number of - * colors. Pass 0 to prevent dithering. - */ - static TQImage gradient(const TQSize &size, const TQColor &ca, - const TQColor &cb, GradientType type, int ncols=3); - - /** - * Create an unbalanced gradient. - * - * An unbalanced gradient is a gradient where the transition from - * color a to color b is not linear, but in this case, exponential. - * - * @param size The desired size of the gradient. - * @param ca Color a - * @param cb Color b - * @param type The type of gradient. - * @param xfactor The x decay length. Use a value between -200 and 200. - * @param yfactor The y decay length. - * @param ncols The number of colors. See KImageEffect:gradient. - */ - static TQImage unbalancedGradient(const TQSize &size, const TQColor &ca, - const TQColor &cb, GradientType type, int xfactor = 100, - int yfactor = 100, int ncols = 3); - - /** - * Blends a color into the destination image, using an opacity - * value for blending one into another. Very fast direct pixel - * manipulation is used. - * - * This function uses MMX and SSE2 instructions to blend the - * image on processors that support it. - * - * @param clr source color to be blended into the destination image. - * @param dst destination image in which the source will be blended into. - * @param opacity opacity (between 0.0 and 1.0) which determines how much - * the source color will be blended into the destination image. - * @return The destination image (dst) containing the result. - * @author Karol Szwed (gallium@kde.org) - * @author Fredrik Höglund (fredrik@kde.org) - */ - static TQImage& blend(const TQColor& clr, TQImage& dst, float opacity); - - /** - * Blend the src image into the destination image, using an opacity - * value for blending one into another. Very fast direct pixel - * manipulation is used. - * - * This function uses MMX and SSE2 instructions to blend the - * images on processors that support it. - * - * @param src source image to be blended into the destination image. - * @param dst destination image in which the source will be blended into. - * @param opacity opacity (between 0.0 and 1.0) which determines how much - * the source image will be blended into the destination image. - * @return The destination image (dst) containing the result. - * @author Karol Szwed (gallium@kde.org) - * @author Fredrik Höglund (fredrik@kde.org) - */ - static TQImage& blend(TQImage& src, TQImage& dst, float opacity); - - /** - * Blend the provided image into a background of the indicated color. - * - * @param initial_intensity this parameter takes values from -1 to 1: - * a) if positive: how much to fade the image in its - * less affected spot - * b) if negative: roughly indicates how much of the image - * remains unaffected - * @param bgnd indicates the color of the background to blend in - * @param eff lets you choose what kind of blending you like - * @param anti_dir blend in the opposite direction (makes no much sense - * with concentric blending effects) - * @param image must be 32bpp - */ - static TQImage& blend(TQImage &image, float initial_intensity, - const TQColor &bgnd, GradientType eff, - bool anti_dir=false); - - /** - * Blend an image into another one, using a gradient type - * for blending from one to another. - * - * @param image1 source1 and result of blending - * @param image2 source2 of blending - * @param gt gradient type for blending between source1 and source2 - * @param xf x decay length for unbalanced gradient tpye - * @param yf y decay length for unbalanced gradient tpye - */ - static TQImage& blend(TQImage &image1,TQImage &image2, - GradientType gt, int xf=100, int yf=100); - - /** - * Blend an image into another one, using a color channel of a - * third image for the decision of blending from one to another. - * - * @param image1 Source 1 and result of blending - * @param image2 Source 2 of blending - * @param blendImage If the gray value of of pixel is 0, the result - * for this pixel is that of image1; for a gray value - * of 1, the pixel of image2 is used; for a value - * in between, a corresponding blending is used. - * @param channel The RBG channel to use for the blending decision. - */ - static TQImage& blend(TQImage &image1, TQImage &image2, - TQImage &blendImage, RGBComponent channel); - - /** - * Blend an image into another one, using alpha in the expected way. - * @param upper the "upper" image - * @param lower the "lower" image - * @param output the target image - * @author Rik Hemsley (rikkus) <rik@kde.org> - */ - static bool blend(const TQImage & upper, const TQImage & lower, TQImage & output); -// Not yet... static bool blend(const TQImage & image1, const TQImage & image2, TQImage & output, const TQRect & destRect); - - /** - * Blend an image into another one, using alpha in the expected way and - * over coordinates @p x and @p y with respect to the lower image. - * The output is a TQImage which is the @p upper image already blended - * with the @p lower one, so its size will be (in general) the same than - * @p upper instead of the same size than @p lower like the method above. - * In fact, the size of @p output is like upper's one only when it can be - * painted on lower, if there has to be some clipping, output's size will - * be the clipped area and x and y will be set to the correct up-left corner - * where the clipped rectangle begins. - * @param x x-coordinate of lower image - * @param y y-coordinate of lower image - * @param upper the "upper" image - * @param lower the "lower" image - * @param output the target image - */ - static bool blend(int &x, int &y, const TQImage & upper, const TQImage & lower, TQImage & output); - - /** - * Blend an image into another one, using alpha in the expected way and - * over coordinates @p x and @p y with respect to the lower image. - * The output is painted in the own @p lower image. This is an optimization - * of the blend method above provided by convenience. - * @param x x-coordinate of lower image - * @param y y-coordinate of lower image - * @param upper the "upper" image - * @param lower the "lower" image, which becomes the output image - */ - static bool blendOnLower(int x, int y, const TQImage & upper, const TQImage & lower); - - /** - * Blend part of an image into part of another, using the alpha channel in - * the expected way. - * Note that the destination rectangle will be correctly clipped. - * - * @param upper the "upper" image - * @param upperOffset Offset for the part of the upper image to be used. - * @param lower the "lower" image - * @param lowerRect Rectangle for the part of the lower image where the - * blending will occur. - * @since 3.2 - */ - static void blendOnLower(const TQImage &upper, const TQPoint &upperOffset, - TQImage &lower, const TQRect &lowerRect); - - /** - * Blend part of an image into part of another, using the opacity value - * and the alpha channel in the expected way. - * Note that the destination rectangle will be correctly clipped. - * - * @param upper the "upper" image - * @param upperOffset Offset for the part of the upper image to be used. - * @param lower the "lower" image - * @param lowerRect Rectangle for the part of the lower image where the - * blending will occur. - * @param opacity Opacity (between 0.0 and 1.0) which determines how much - * the source image will be blended into the destination image. - * @since 3.2 - */ - static void blendOnLower(const TQImage &upper, const TQPoint &upperOffset, - TQImage &lower, const TQRect &lowerRect, float opacity); - - /** - * Disposition of a source image on top of a destination image. - * @see KImageEffect::computeDestinationRect, KImageEffect::blendOnLower - * @since 3.2 - */ - enum Disposition { NoImage = 0, //!< Don't overlay - Centered, //!< Center top image on botton image - Tiled, //!< Tile top image on bottom image - CenterTiled, //!< Center and tile top image on bottom image - CenteredMaxpect, //!< Center and scale aspect - TiledMaxpect, //!< Tile and scale aspect - Scaled, //!< Scale - CenteredAutoFit //!< Center and scale or scale aspect - }; - - /** - * Compute the destination rectangle where to draw the upper image on top - * of another image using the given disposition. For tiled - * disposition, the rectangle should be duplicated on the whole area to - * obtained the wanted effect. - * - * @param lowerSize The size of the destination image. - * @param disposition The wanted disposition. - * @param upper The upper image. Note that this image may be scaled to - * adjust to the requested disposition. - * - * @return the computed rectangle. Its size may exceed @e lowerSize. - * @since 3.2 - */ - static TQRect computeDestinationRect(const TQSize &lowerSize, - Disposition disposition, TQImage &upper); - - /** - * Blend an image on top of another using a given disposition and a given - * opacity. The alpha channel of the upper image is used in the expected - * way. Beware the upper image may be modified. - * @since 3.2 - */ - static void blendOnLower(TQImage &upper, TQImage &lower, - Disposition disposition, float opacity); - - /** - * Modifies the intensity of a pixmap's RGB channel component. - * - * @param image The TQImage to process. - * @param percent Percent value. Use a negative value to dim. - * @param channel Which channel(s) should be modified - * @return The @p image, provided for convenience. - * @author Daniel M. Duley (mosfet) - */ - static TQImage& channelIntensity(TQImage &image, float percent, - RGBComponent channel); - - /** - * Fade an image to a certain background color. - * - * The number of colors will not be changed. - * - * @param image The TQImage to process. - * @param val The strength of the effect. 0 <= val <= 1. - * @param color The background color. - * @return Returns the image(), provided for convenience. - */ - static TQImage& fade(TQImage &image, float val, const TQColor &color); - - - /** - * This recolors a pixmap. The most dark color will become color a, - * the most bright one color b, and in between. - * - * @param image A TQImage to process. - * @param ca Color a - * @param cb Color b - * @param ncols The number of colors to dither the image to. - * Pass 0 to prevent dithering. - */ - static TQImage& flatten(TQImage &image, const TQColor &ca, - const TQColor &cb, int ncols=0); - - /** - * Build a hash on any given QImage - * - * @param image The TQImage to process - * @param lite The hash faces the indicated lighting (cardinal poles). - * @param spacing How many unmodified pixels in between hashes. - * @return Returns the image(), provided for convenience. - */ - static TQImage& hash(TQImage &image, Lighting lite=NorthLite, - unsigned int spacing=0); - - /** - * Either brighten or dim the image by a specified percent. - * For example, .50 will modify the colors by 50%. - * - * This function uses MMX instructions to process the image - * on processors that support it. - * - * @param image The TQImage to process. - * @param percent The percent value. Use a negative value to dim. - * @return Returns The image(), provided for convenience. - * @author Daniel M. Duley (mosfet) - * @author Benjamin Roe (ben@benroe.com) - */ - static TQImage& intensity(TQImage &image, float percent); - - /** - * Modulate the image with a color channel of another image. - * - * @param image The TQImage to modulate and result. - * @param modImage The TQImage to use for modulation. - * @param reverse Invert the meaning of image/modImage; result is image! - * @param type The modulation Type to use. - * @param factor The modulation amplitude; with 0 no effect [-200;200]. - * @param channel The RBG channel of image2 to use for modulation. - * @return Returns the image(), provided for convenience. - */ - static TQImage& modulate(TQImage &image, TQImage &modImage, bool reverse, - ModulationType type, int factor, RGBComponent channel); - - /** - * Convert an image to grayscale. - * - * @param image The TQImage to process. - * @param fast Set to @p true in order to use a faster but non-photographic - * quality algorithm. Appropriate for things such as toolbar icons. - * @return Returns the image(), provided for convenience. - * @author Daniel M. Duley (mosfet) - */ - static TQImage& toGray(TQImage &image, bool fast = false); - - /** - * Desaturate an image evenly. - * - * @param image The TQImage to process. - * @param desat A value between 0 and 1 setting the degree of desaturation - * @return Returns the image(), provided for convenience. - */ - static TQImage& desaturate(TQImage &image, float desat = 0.3); - - /** - * Fast, but low quality contrast of an image. Also see contrastHSV. - * - * @param image The TQImage to process. - * @param c A contrast value between -255 to 255. - * @return The image(), provided for convenience. - * @author Daniel M. Duley (mosfet) - * ### KDE 4: remove - */ - static TQImage& contrast(TQImage &image, int c); - - /** - * Dither an image using Floyd-Steinberg dithering for low-color - * situations. - * - * @param image The TQImage to process. - * @param palette The color palette to use - * @param size The size of the palette - * @return Returns the image(), provided for convenience. - */ - static TQImage& dither(TQImage &image, const TQColor *palette, int size); - - /** - * Calculate the image for a selected image, for instance a selected icon - * on the desktop. - * @param img the TQImage to select - * @param col the selected color, usually from TQColorGroup::highlight(). - */ - static TQImage& selectedImage( TQImage &img, const TQColor &col ); - - /** - * High quality, expensive HSV contrast. You can do a faster one by just - * taking a intensity threshold (ie: 128) and incrementing RGB color - * channels above it and decrementing those below it, but this gives much - * better results. - * - * @param img The TQImage to process. - * @param sharpen If true sharpness is increase, (spiffed). Otherwise - * it is decreased, (dulled). - * @author Daniel M. Duley (mosfet) - */ - static void contrastHSV(TQImage &img, bool sharpen=true); - - /** - * Normalises the pixel values to span the full range of color values. - * This is a contrast enhancement technique. - * @param img the image that is normalised - * @author Daniel M. Duley (mosfet) - */ - static void normalize(TQImage &img); - - /** - * Performs histogram equalisation on the reference - * image. - * @param img the image that is equalised - * @author Daniel M. Duley (mosfet) - */ - static void equalize(TQImage &img); - - /** - * Thresholds the reference image. You can also threshold images by using - * ThresholdDither in the various QPixmap/TQImage convert methods, but this - * lets you specify a threshold value. - * - * @param img The TQImage to process. - * @param value The threshold value. - * @author Daniel M. Duley (mosfet) - */ - static void threshold(TQImage &img, unsigned int value=128); - - /** - * Produces a 'solarization' effect seen when exposing a photographic - * film to light during the development process. - * - * @param img The TQImage to process. - * @param factor The extent of the solarization (0-99.9) - * @author Daniel M. Duley (mosfet) - */ - static void solarize(TQImage &img, double factor=50.0); - - /** - * Embosses the source image. This involves highlighting the edges - * and applying various other enhancements in order to get a metal - * effect. - * - * @param src The TQImage to process. - * @param radius The radius of the gaussian not counting the - * center pixel. Use 0 and a suitable radius will be automatically used. - * @param sigma The standard deviation of the gaussian. Use 1 if you're not - * sure. - * @return The embossed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage emboss(TQImage &src, double radius, double sigma); - - /** - * Convenience method. - */ - static TQImage emboss(TQImage &src); - - /** - * Minimizes speckle noise in the source image using the 8 hull - * algorithm. - * - * @param src The TQImage to process. - * @return The despeckled image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage despeckle(TQImage &src); - - /** - * Produces a neat little "charcoal" effect. - * - * @param src The TQImage to process. - * @param radius The radius of the gaussian not counting the - * center pixel. Use 0 and a suitable radius will be automatically used. - * @param sigma The standard deviation of the gaussian. Use 1 if you're not - * sure. - * @return The charcoal image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage charcoal(TQImage &src, double radius, double sigma); - - /** - * This is provided for binary compatability only! Use the above method - * with a radius and sigma instead! - */ - static TQImage charcoal(TQImage &src, double factor=50.0); - - /** - * Rotates the image by the specified amount - * - * @param src The TQImage to process. - * @param r The rotate direction. - * @return The rotated image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage rotate(TQImage &src, RotateDirection r); - - /** - * Scales an image using simple pixel sampling. This does not produce - * nearly as nice a result as TQImage::smoothScale(), but has the - * advantage of being much faster - only a few milliseconds. - * - * @param src The TQImage to process. - * @param w The new width. - * @param h The new height. - * @return The scaled image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage sample(TQImage &src, int w, int h); - - /** - * Adds noise to an image. - * - * @param src The TQImage to process. - * @param type The algorithm used to generate the noise. - * @return The image with noise added. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage addNoise(TQImage &src, NoiseType type = GaussianNoise); - - /** - * Blurs an image by convolving pixel neighborhoods. - * - * @param src The TQImage to process. - * @param radius The radius of the gaussian not counting the - * center pixel. Use 0 and a suitable radius will be automatically used. - * @param sigma The standard deviation of the gaussian. Use 1 if you're not - * sure. - * @return The blurred image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage blur(TQImage &src, double radius, double sigma); - - /** - * This is provided for binary compatability only! Use the above method - * with a radius and sigma instead! - */ - static TQImage blur(TQImage &src, double factor=50.0); - - /** - * Detects edges in an image using pixel neighborhoods and an edge - * detection mask. - * - * @param src The TQImage to process. - * @param radius The radius of the gaussian not counting the - * center pixel. Use 0 and a suitable radius will be automatically used. - * @return The image with edges detected. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage edge(TQImage &src, double radius); - - /** - * Implodes an image by a specified percent. - * - * @param src The TQImage to process. - * @param factor The extent of the implosion. - * @param background An RGBA value to use for the background. After the - * effect some pixels may be "empty". This value is used for those pixels. - * @return The imploded image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage implode(TQImage &src, double factor=30.0, - unsigned int background = 0xFFFFFFFF); - - /** - * Produces an oil painting effect. - * - * @param src The TQImage to process. - * @param radius The radius of the gaussian not counting the - * center pixel. Use 0 and a suitable radius will be automatically used. - * @return The new image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage oilPaintConvolve(TQImage &src, double radius); - - /** - * This is provided for binary compatability only! Use the above method - * instead! - */ - static TQImage oilPaint(TQImage &src, int radius=3); - - /** - * Sharpens the pixels in the image using pixel neighborhoods. - * - * @param src The TQImage to process. - * @param radius The radius of the gaussian not counting the - * center pixel. Use 0 and a suitable radius will be automatically used. - * @param sigma The standard deviation of the gaussian. Use 1 if you're not - * sure. - * @return The sharpened image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage sharpen(TQImage &src, double radius, double sigma); - - /** - * This is provided for binary compatability only! Use the above method - * instead! - */ - static TQImage sharpen(TQImage &src, double factor=30.0); - - /** - * Randomly displaces pixels. - * - * @param src The TQImage to process. - * @param amount The vicinity for choosing a random pixel to swap. - * @return The image with pixels displaced. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage spread(TQImage &src, unsigned int amount=3); - - /** - * Shades the image using a distance light source. - * - * @param src The TQImage to process. - * @param color_shading If true do color shading, otherwise do grayscale. - * @param azimuth Determines the light source and direction. - * @param elevation Determines the light source and direction. - * @return The shaded image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage shade(TQImage &src, bool color_shading=true, double azimuth=30.0, - double elevation=30.0); - /** - * Swirls the image by a specified amount - * - * @param src The TQImage to process. - * @param degrees The tightness of the swirl. - * @param background An RGBA value to use for the background. After the - * effect some pixels may be "empty". This value is used for those pixels. - * @return The swirled image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage swirl(TQImage &src, double degrees=50.0, unsigned int background = - 0xFFFFFFFF); - - /** - * Modifies the pixels along a sine wave. - * - * @param src The TQImage to process. - * @param amplitude The amplitude of the sine wave. - * @param frequency The frequency of the sine wave. - * @param background An RGBA value to use for the background. After the - * effect some pixels may be "empty". This value is used for those pixels. - * @return The new image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static TQImage wave(TQImage &src, double amplitude=25.0, double frequency=150.0, - unsigned int background = 0xFFFFFFFF); - - /** - * A bumpmapping algorithm. - * - * @param img the image you want bumpmap - * @param map the map used - * @param azimuth azimuth - * @param elevation elevation - * @param depth depth (not the depth of the image, but of the map) - * @param xofs X offset - * @param yofs Y offset - * @param waterlevel level that full transparency should represent - * @param ambient ambient lighting factor - * @param compensate compensate for darkening - * @param invert invert bumpmap - * @param type type of the bumpmap - * @param tiled tile the bumpmap over the image through the Y offset - * - * @return The destination image (dst) containing the result. - * @author Zack Rusin <zack@kde.org> - */ - static TQImage bumpmap(TQImage &img, TQImage &map, double azimuth, double elevation, - int depth, int xofs, int yofs, int waterlevel, - int ambient, bool compensate, bool invert, - BumpmapType type, bool tiled); - - /** - * Convert an image with standard alpha to premultiplied alpha - * - * @param img the image you want convert - * - * @return The destination image (dst) containing the result. - * @author Timothy Pearson <kb9vqf@pearsoncomputing.net> - */ - static TQImage convertToPremultipliedAlpha(TQImage input); - -private: - - /** - * Helper function to fast calc some altered (lighten, shaded) colors - * - */ - static unsigned int lHash(unsigned int c); - static unsigned int uHash(unsigned int c); - - /** - * Helper function to find the nearest color to the RBG triplet - */ - static int nearestColor( int r, int g, int b, const TQColor *pal, int size ); - - static void hull(const int x_offset, const int y_offset, const int polarity, - const int width, const int height, - unsigned int *f, unsigned int *g); - static unsigned int generateNoise(unsigned int pixel, NoiseType type); - static unsigned int interpolateColor(TQImage *image, double x, double y, - unsigned int background); - /* Various convolve routines */ - static int getOptimalKernelWidth(double radius, double sigma); - static bool convolveImage(TQImage *image, TQImage *dest, - const unsigned int order, - const double *kernel); - static void blurScanLine(double *kernel, int width, - unsigned int *src, unsigned int *dest, - int columns); - static int getBlurKernel(int width, double sigma, double **kernel); -}; - -#endif diff --git a/kdefx/kpixmap.cpp b/kdefx/kpixmap.cpp deleted file mode 100644 index 152ae6e83..000000000 --- a/kdefx/kpixmap.cpp +++ /dev/null @@ -1,389 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 1998 Mark Donohoe <donohoe@kde.org> - * Stephan Kulow <coolo@kde.org> - * - * $Id$ - * - * 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. - */ - -#include <tqpixmap.h> -#include <tqpainter.h> -#include <tqimage.h> -#include <tqbitmap.h> -#include <tqcolor.h> - -#include <stdlib.h> -#include "kpixmap.h" - -// Fast diffuse dither to 3x3x3 color cube -// Based on Qt's image conversion functions -static bool kdither_32_to_8( const TQImage *src, TQImage *dst ) -{ - // register QRgb *p; - uchar *b; - int y; - - if ( !dst->create(src->width(), src->height(), 8, 256) ) { - qWarning("KPixmap: destination image not valid\n"); - return false; - } - - dst->setNumColors( 256 ); - -#define MAX_R 2 -#define MAX_G 2 -#define MAX_B 2 -#define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b)) - - int rc, gc, bc; - - for ( rc=0; rc<=MAX_R; rc++ ) // build 2x2x2 color cube - for ( gc=0; gc<=MAX_G; gc++ ) - for ( bc=0; bc<=MAX_B; bc++ ) { - dst->setColor( INDEXOF(rc,gc,bc), - tqRgb( rc*255/MAX_R, gc*255/MAX_G, bc*255/MAX_B ) ); - } - - int sw = src->width(); - int* line1[3]; - int* line2[3]; - int* pv[3]; - - line1[0] = new int[src->width()]; - line2[0] = new int[src->width()]; - line1[1] = new int[src->width()]; - line2[1] = new int[src->width()]; - line1[2] = new int[src->width()]; - line2[2] = new int[src->width()]; - pv[0] = new int[sw]; - pv[1] = new int[sw]; - pv[2] = new int[sw]; - - for ( y=0; y < src->height(); y++ ) { - // p = (QRgb *)src->scanLine(y); - b = dst->scanLine(y); - int endian = (TQImage::systemBitOrder() == TQImage::BigEndian); - int x; - uchar* q = const_cast<TQImage*>(src)->scanLine(y); - uchar* q2 = const_cast<TQImage*>(src)->scanLine(y+1 < src->height() ? y + 1 : 0); - - for (int chan = 0; chan < 3; chan++) { - b = dst->scanLine(y); - int *l1 = (y&1) ? line2[chan] : line1[chan]; - int *l2 = (y&1) ? line1[chan] : line2[chan]; - if ( y == 0 ) { - for (int i=0; i<sw; i++) - l1[i] = q[i*4+chan+endian]; - } - if ( y+1 < src->height() ) { - for (int i=0; i<sw; i++) - l2[i] = q2[i*4+chan+endian]; - } - - // Bi-directional error diffusion - if ( y&1 ) { - for (x=0; x<sw; x++) { - int pix = QMAX(QMIN(2, (l1[x] * 2 + 128)/ 255), 0); - int err = l1[x] - pix * 255 / 2; - pv[chan][x] = pix; - - // Spread the error around... - if ( x+1<sw ) { - l1[x+1] += (err*7)>>4; - l2[x+1] += err>>4; - } - l2[x]+=(err*5)>>4; - if (x>1) - l2[x-1]+=(err*3)>>4; - } - } else { - for (x=sw; x-->0; ) { - int pix = QMAX(QMIN(2, (l1[x] * 2 + 128)/ 255), 0); - int err = l1[x] - pix * 255 / 2; - pv[chan][x] = pix; - - // Spread the error around... - if ( x > 0 ) { - l1[x-1] += (err*7)>>4; - l2[x-1] += err>>4; - } - l2[x]+=(err*5)>>4; - if (x+1 < sw) - l2[x+1]+=(err*3)>>4; - } - } - } - - if (!endian) { - for (x=0; x<sw; x++) - *b++ = INDEXOF(pv[2][x],pv[1][x],pv[0][x]); - } else { - for (x=0; x<sw; x++) - *b++ = INDEXOF(pv[0][x],pv[1][x],pv[2][x]); - } - - } - - delete [] line1[0]; - delete [] line2[0]; - delete [] line1[1]; - delete [] line2[1]; - delete [] line1[2]; - delete [] line2[2]; - delete [] pv[0]; - delete [] pv[1]; - delete [] pv[2]; - -#undef MAX_R -#undef MAX_G -#undef MAX_B -#undef INDEXOF - - return true; -} - -KPixmap::~KPixmap() -{ -} - -bool KPixmap::load( const TQString& fileName, const char *format, - int conversion_flags ) -{ - TQImageIO io( fileName, format ); - - bool result = io.read(); - - if ( result ) { - detach(); - result = convertFromImage( io.image(), conversion_flags ); - } - return result; -} - -bool KPixmap::load( const TQString& fileName, const char *format, - ColorMode mode ) -{ - int conversion_flags = 0; - switch (mode) { - case Color: - conversion_flags |= ColorOnly; - break; - case Mono: - conversion_flags |= MonoOnly; - break; - case LowColor: - conversion_flags |= LowOnly; - break; - case WebColor: - conversion_flags |= WebOnly; - break; - default: - break;// Nothing. - } - return load( fileName, format, conversion_flags ); -} - -bool KPixmap::convertFromImage( const TQImage &img, ColorMode mode ) -{ - int conversion_flags = 0; - switch (mode) { - case Color: - conversion_flags |= ColorOnly; - break; - case Mono: - conversion_flags |= MonoOnly; - break; - case LowColor: - conversion_flags |= LowOnly; - break; - case WebColor: - conversion_flags |= WebOnly; - break; - default: - break; // Nothing. - } - return convertFromImage( img, conversion_flags ); -} - -bool KPixmap::convertFromImage( const TQImage &img, int conversion_flags ) -{ - if ( img.isNull() ) { -#if defined(CHECK_NULL) - qWarning( "KPixmap::convertFromImage: Cannot convert a null image" ); -#endif - return false; - } - detach(); // detach other references - - int dd = defaultDepth(); - - // If color mode not one of KPixmaps extra modes nothing to do - if ( ( conversion_flags & KColorMode_Mask ) != LowOnly && - ( conversion_flags & KColorMode_Mask ) != WebOnly ) { - return TQPixmap::convertFromImage ( img, conversion_flags ); - } - - // If the default pixmap depth is not 8bpp, KPixmap color modes have no - // effect. Ignore them and use AutoColor instead. - if ( dd > 8 ) { - if ( ( conversion_flags & KColorMode_Mask ) == LowOnly || - ( conversion_flags & KColorMode_Mask ) == WebOnly ) - conversion_flags = (conversion_flags & ~KColorMode_Mask) | Auto; - return TQPixmap::convertFromImage ( img, conversion_flags ); - } - - if ( ( conversion_flags & KColorMode_Mask ) == LowOnly ) { - // Here we skimp a little on the possible conversion modes - // Don't offer ordered or threshold dither of RGB channels or - // diffuse or ordered dither of alpha channel. It hardly seems - // worth the effort for this specialized mode. - - // If image uses icon palette don't dither it. - if( img.numColors() > 0 && img.numColors() <=40 ) { - if ( checkColorTable( img ) ) - return TQPixmap::convertFromImage( img, TQPixmap::Auto ); - } - - TQBitmap mask; - bool isMask = false; - - TQImage image = img.convertDepth(32); - TQImage tImage( image.width(), image.height(), 8, 256 ); - - if( img.hasAlphaBuffer() ) { - image.setAlphaBuffer( true ); - tImage.setAlphaBuffer( true ); - isMask = mask.convertFromImage( img.createAlphaMask() ); - } - - kdither_32_to_8( &image, &tImage ); - - if( TQPixmap::convertFromImage( tImage ) ) { - if ( isMask ) TQPixmap::setMask( mask ); - return true; - } else - return false; - } else { - TQImage image = img.convertDepth( 32 ); - image.setAlphaBuffer( img.hasAlphaBuffer() ); - conversion_flags = (conversion_flags & ~ColorMode_Mask) | Auto; - return TQPixmap::convertFromImage ( image, conversion_flags ); - } -} - -static TQColor* kpixmap_iconPalette = 0; - -bool KPixmap::checkColorTable( const TQImage &image ) -{ - int i = 0; - - if (kpixmap_iconPalette == 0) { - kpixmap_iconPalette = new TQColor[40]; - - // Standard palette - kpixmap_iconPalette[i++] = red; - kpixmap_iconPalette[i++] = green; - kpixmap_iconPalette[i++] = blue; - kpixmap_iconPalette[i++] = cyan; - kpixmap_iconPalette[i++] = magenta; - kpixmap_iconPalette[i++] = yellow; - kpixmap_iconPalette[i++] = darkRed; - kpixmap_iconPalette[i++] = darkGreen; - kpixmap_iconPalette[i++] = darkBlue; - kpixmap_iconPalette[i++] = darkCyan; - kpixmap_iconPalette[i++] = darkMagenta; - kpixmap_iconPalette[i++] = darkYellow; - kpixmap_iconPalette[i++] = white; - kpixmap_iconPalette[i++] = lightGray; - kpixmap_iconPalette[i++] = gray; - kpixmap_iconPalette[i++] = darkGray; - kpixmap_iconPalette[i++] = black; - - // Pastels - kpixmap_iconPalette[i++] = TQColor( 255, 192, 192 ); - kpixmap_iconPalette[i++] = TQColor( 192, 255, 192 ); - kpixmap_iconPalette[i++] = TQColor( 192, 192, 255 ); - kpixmap_iconPalette[i++] = TQColor( 255, 255, 192 ); - kpixmap_iconPalette[i++] = TQColor( 255, 192, 255 ); - kpixmap_iconPalette[i++] = TQColor( 192, 255, 255 ); - - // Reds - kpixmap_iconPalette[i++] = TQColor( 64, 0, 0 ); - kpixmap_iconPalette[i++] = TQColor( 192, 0, 0 ); - - // Oranges - kpixmap_iconPalette[i++] = TQColor( 255, 128, 0 ); - kpixmap_iconPalette[i++] = TQColor( 192, 88, 0 ); - kpixmap_iconPalette[i++] = TQColor( 255, 168, 88 ); - kpixmap_iconPalette[i++] = TQColor( 255, 220, 168 ); - - // Blues - kpixmap_iconPalette[i++] = TQColor( 0, 0, 192 ); - - // Turquoise - kpixmap_iconPalette[i++] = TQColor( 0, 64, 64 ); - kpixmap_iconPalette[i++] = TQColor( 0, 192, 192 ); - - // Yellows - kpixmap_iconPalette[i++] = TQColor( 64, 64, 0 ); - kpixmap_iconPalette[i++] = TQColor( 192, 192, 0 ); - - // Greens - kpixmap_iconPalette[i++] = TQColor( 0, 64, 0 ); - kpixmap_iconPalette[i++] = TQColor( 0, 192, 0 ); - - // Purples - kpixmap_iconPalette[i++] = TQColor( 192, 0, 192 ); - - // Greys - kpixmap_iconPalette[i++] = TQColor( 88, 88, 88 ); - kpixmap_iconPalette[i++] = TQColor( 48, 48, 48 ); - kpixmap_iconPalette[i++] = TQColor( 220, 220, 220 ); - - } - - QRgb* ctable = image.tqcolorTable(); - - int ncols = image.numColors(); - int j; - - // Allow one failure which could be transparent background - int failures = 0; - - for ( i=0; i<ncols; i++ ) { - for ( j=0; j<40; j++ ) { - if ( kpixmap_iconPalette[j].red() == tqRed( ctable[i] ) && - kpixmap_iconPalette[j].green() == tqGreen( ctable[i] ) && - kpixmap_iconPalette[j].blue() == tqBlue( ctable[i] ) ) { - break; - } - } - - if ( j == 40 ) { - failures ++; - } - } - - return ( failures <= 1 ); - -} - -KPixmap::KPixmap(const TQPixmap& p) - : TQPixmap(p) -{ -} diff --git a/kdefx/kpixmap.h b/kdefx/kpixmap.h deleted file mode 100644 index 34397791e..000000000 --- a/kdefx/kpixmap.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 1998 Mark Donohoe <donohoe@kde.org> - * Stephan Kulow <coolo@kde.org> - * - * $Id$ - * - * 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 __KPIXMAP_H__ -#define __KPIXMAP_H__ - -#include <tqpixmap.h> - -#include <kdelibs_export.h> - -const int KColorMode_Mask = 0x00000300; -const int WebOnly = 0x00000200; -const int LowOnly = 0x00000300; - -class KPixmapPrivate; - -/** - * Off-screen paint device with extended features. - - * KPixmap has two new color modes, WebColor and LowColor, applicable - * to 8bpp displays. - - * In WebColor mode all images are dithered to the Netscape palette, - * even when they have their own color table. WebColor is the default - * mode for KPixmap so that standard applications can share the Netscape - * palette across the desktop. - - * In LowColor mode images are checked to see if their color table - * matches the KDE icon palette. If the color tables do not match, the - * images are dithered to a minimal 3x3x3 color cube. LowColor mode can - * be used to load icons, background images etc. so that components of - * the desktop which are always present use no more than 40 colors. - - * @author Mark Donohoe (donohoe@kde.org) - * @version $Id$ - */ -class KDEFX_EXPORT KPixmap : public TQPixmap -{ -public: - /** - * This enumeration provides a color pallete specification - * @see KPixmap::convertFromImage(), KPixmap::load() - */ - enum ColorMode { Auto, //!< Convert to monochrome if possible - Color, //!< Native display depth - Mono, //!< Monochrome pixmap - LowColor, //!< 3x3x3 color cube (or monochrome) - WebColor //!< Netscape pallete (or monochrome) - }; - /** - * This enumeration provides a gradient mode specification - */ - enum GradientMode { Horizontal, - Vertical, - Diagonal, - CrossDiagonal - }; - - /** - * Constructs a null pixmap. - */ - KPixmap() : TQPixmap() {}; - - /** - * Destructs the pixmap. - * ### KDE 4: remove - */ - ~KPixmap(); - - /** - * Copies the TQPixmap @p pix. - */ - KPixmap(const TQPixmap& pix); - - /** - * Converts an image and sets this pixmap. - * - * The conversion_flags argument is a bitwise-OR from the - * following choices. The options marked (default) are the - * choice if no other choice from the list is included (they - * are zero): - * - * Color/Mono preference - * - * @li WebColor - If the image has depth 1 and contains - * only black and white pixels then the pixmap becomes monochrome. If - * the pixmap has a depth of 8 bits per pixel then the Netscape - * palette is used for the pixmap color table. - * @li LowColor - If the image has depth 1 and contains only black and - * white pixels then the pixmap becomes monochrome. If the pixmap has a - * depth of 8 bits per pixel and the image does not posess a color table - * that matches the Icon palette a 3x3x3 color cube is used for the - * pixmap color table. - * @li AutoColor (default) - If the image has depth 1 and contains - * only black and white pixels, then the pixmap becomes - * monochrome. - * @li ColorOnly - The pixmap is dithered/converted to the native - * display depth. - * @li MonoOnly - The pixmap becomes monochrome. If necessary, it - * is dithered using the chosen dithering algorithm. - * - * Dithering mode preference, for RGB channels - * - * @li DiffuseDither (default) - A high quality dither. - * @li OrderedDither - A faster more ordered dither. - * @li ThresholdDither - No dithering, closest color is used. - * - * Dithering mode preference, for alpha channel - * - * @li DiffuseAlphaDither - A high quality dither. - * @li OrderedAlphaDither - A faster more ordered dither. - * @li ThresholdAlphaDither (default) - No dithering. - * - * Color matching versus dithering preference - * - * @li PreferDither - Always dither 32-bit images when the image - * is being converted to 8-bits. This is the default when - * converting to a pixmap. - * @li AvoidDither - Only dither 32-bit images if the image has - * more than 256 colors and it is being converted to 8-bits. - * This is the default when an image is converted for the - * purpose of saving to a file. - * - * Passing 0 for @p conversion_flags gives all the default - * options. - * - * @param img the image to convert - * @param conversion_flags bitmask, described above - * @return @p true if successful. - **/ - bool convertFromImage( const TQImage &img, int conversion_flags ); - - /** - * This is an overloaded member function, provided for - * convenience. It differs from the above function only in - * what argument(s) it accepts. - * @param img the image to convert - * @param mode a ColorMode to apply - * @return @p true if successful. - **/ - bool convertFromImage( const TQImage &img, ColorMode mode = WebColor ); - - /** - * Loads a pixmap from the file @p fileName. - * - * If format is specified, the loader attempts to read the - * pixmap using the specified format. If format is not - * specified (default), the loader reads a few bytes from the - * header to guess the file format. - * - * The TQImageIO documentation lists the supported image - * formats and explains how to add extra formats. - * - * @param fileName the name of the file to load the image from - * @param format the format for the image - * @param conversion_flags a bitmask, as described in - * convertFromImage() - * @return @p true if successful, or false if the pixmap - * could not be loaded. - **/ - bool load( const TQString& fileName, const char *format, - int conversion_flags ); - - /** - * This is an overloaded member function, provided for - * convenience. It differs from the above function only in - * what argument(s) it accepts. - * @param fileName the name of the file to load the image from - * @param format the format for the image - * @param mode a ColorMode to apply - * @return @p true if successful, or false if the pixmap - * could not be loaded. - **/ - bool load( const TQString& fileName, - const char *format = 0, - ColorMode mode = WebColor ); - - /** - * Returns true if the image posesses a color table that - * matches the Icon palette or false otherwise. - * - * An image with one color not found in the Icon palette is - * considered to be a match, since this extra color may be a - * transparent background. - * @param image the image to test - **/ - bool checkColorTable(const TQImage &image); - -private: - KPixmapPrivate *d; -}; - -#endif diff --git a/kdefx/kpixmapeffect.cpp b/kdefx/kpixmapeffect.cpp deleted file mode 100644 index c4bf04dae..000000000 --- a/kdefx/kpixmapeffect.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> - (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> - (C) 1998, 1999 Dirk A. Mueller <mueller@kde.org> - -*/ - -// $Id$ - -#include <tqimage.h> -#include <tqpainter.h> - -#include "kpixmapeffect.h" -#include "kpixmap.h" -#include "kimageeffect.h" - -//====================================================================== -// -// Gradient effects -// -//====================================================================== - - -KPixmap& KPixmapEffect::gradient(KPixmap &pixmap, const TQColor &ca, - const TQColor &cb, GradientType eff, int ncols) -{ - if(pixmap.depth() > 8 && - (eff == VerticalGradient || eff == HorizontalGradient)) { - - int rDiff, gDiff, bDiff; - int rca, gca, bca /*, rcb, gcb, bcb*/; - - register int x, y; - - rDiff = (/*rcb = */ cb.red()) - (rca = ca.red()); - gDiff = (/*gcb = */ cb.green()) - (gca = ca.green()); - bDiff = (/*bcb = */ cb.blue()) - (bca = ca.blue()); - - register int rl = rca << 16; - register int gl = gca << 16; - register int bl = bca << 16; - - int rcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * rDiff; - int gcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * gDiff; - int bcdelta = ((1<<16) / (eff == VerticalGradient ? pixmap.height() : pixmap.width())) * bDiff; - - TQPainter p(&pixmap); - - // these for-loops could be merged, but the if's in the inner loop - // would make it slow - switch(eff) { - case VerticalGradient: - for ( y = 0; y < pixmap.height(); y++ ) { - rl += rcdelta; - gl += gcdelta; - bl += bcdelta; - - p.setPen(TQColor(rl>>16, gl>>16, bl>>16)); - p.drawLine(0, y, pixmap.width()-1, y); - } - break; - case HorizontalGradient: - for( x = 0; x < pixmap.width(); x++) { - rl += rcdelta; - gl += gcdelta; - bl += bcdelta; - - p.setPen(TQColor(rl>>16, gl>>16, bl>>16)); - p.drawLine(x, 0, x, pixmap.height()-1); - } - break; - default: - ; - } - } - else { - TQImage image = KImageEffect::gradient(pixmap.size(), ca, cb, - (KImageEffect::GradientType) eff, ncols); - pixmap.convertFromImage(image); - } - - return pixmap; -} - - -// ----------------------------------------------------------------------------- - -KPixmap& KPixmapEffect::unbalancedGradient(KPixmap &pixmap, const TQColor &ca, - const TQColor &cb, GradientType eff, int xfactor, int yfactor, - int ncols) -{ - TQImage image = KImageEffect::unbalancedGradient(pixmap.size(), ca, cb, - (KImageEffect::GradientType) eff, - xfactor, yfactor, ncols); - pixmap.convertFromImage(image); - - return pixmap; -} - - -//====================================================================== -// -// Intensity effects -// -//====================================================================== - - - -KPixmap& KPixmapEffect::intensity(KPixmap &pixmap, float percent) -{ - TQImage image = pixmap.convertToImage(); - KImageEffect::intensity(image, percent); - pixmap.convertFromImage(image); - - return pixmap; -} - - -// ----------------------------------------------------------------------------- - -KPixmap& KPixmapEffect::channelIntensity(KPixmap &pixmap, float percent, - RGBComponent channel) -{ - TQImage image = pixmap.convertToImage(); - KImageEffect::channelIntensity(image, percent, - (KImageEffect::RGBComponent) channel); - pixmap.convertFromImage(image); - - return pixmap; -} - - -//====================================================================== -// -// Blend effects -// -//====================================================================== - - -KPixmap& KPixmapEffect::blend(KPixmap &pixmap, float initial_intensity, - const TQColor &bgnd, GradientType eff, - bool anti_dir, int ncols) -{ - - TQImage image = pixmap.convertToImage(); - if (image.depth() <=8) - image = image.convertDepth(32); //Sloww.. - - KImageEffect::blend(image, initial_intensity, bgnd, - (KImageEffect::GradientType) eff, anti_dir); - - unsigned int tmp; - - if(pixmap.depth() <= 8 ) { - if ( ncols < 2 || ncols > 256 ) - ncols = 3; - TQColor *dPal = new TQColor[ncols]; - for (int i=0; i<ncols; i++) { - tmp = 0 + 255 * i / ( ncols - 1 ); - dPal[i].setRgb ( tmp, tmp, tmp ); - } - KImageEffect::dither(image, dPal, ncols); - pixmap.convertFromImage(image); - delete [] dPal; - } - else - pixmap.convertFromImage(image); - - return pixmap; -} - - -//====================================================================== -// -// Hash effects -// -//====================================================================== - -KPixmap& KPixmapEffect::hash(KPixmap &pixmap, Lighting lite, - unsigned int spacing, int ncols) -{ - TQImage image = pixmap.convertToImage(); - KImageEffect::hash(image, (KImageEffect::Lighting) lite, spacing); - - unsigned int tmp; - - if(pixmap.depth() <= 8 ) { - if ( ncols < 2 || ncols > 256 ) - ncols = 3; - TQColor *dPal = new TQColor[ncols]; - for (int i=0; i<ncols; i++) { - tmp = 0 + 255 * i / ( ncols - 1 ); - dPal[i].setRgb ( tmp, tmp, tmp ); - } - KImageEffect::dither(image, dPal, ncols); - pixmap.convertFromImage(image); - delete [] dPal; - } - else - pixmap.convertFromImage(image); - - return pixmap; -} - - -//====================================================================== -// -// Pattern effects -// -//====================================================================== - -#if 0 -void KPixmapEffect::pattern(KPixmap &pixmap, const TQColor &ca, - const TQColor &cb, unsigned pat[8]) -{ - TQImage img = pattern(pixmap.size(), ca, cb, pat); - pixmap.convertFromImage(img); -} -#endif - -// ----------------------------------------------------------------------------- - -KPixmap KPixmapEffect::pattern(const KPixmap& pmtile, TQSize size, - const TQColor &ca, const TQColor &cb, int ncols) -{ - if (pmtile.depth() > 8) - ncols = 0; - - TQImage img = pmtile.convertToImage(); - KImageEffect::flatten(img, ca, cb, ncols); - KPixmap pixmap; - pixmap.convertFromImage(img); - - return KPixmapEffect::createTiled(pixmap, size); -} - - -// ----------------------------------------------------------------------------- - -KPixmap KPixmapEffect::createTiled(const KPixmap& pixmap, TQSize size) -{ - KPixmap pix(size); - - TQPainter p(&pix); - p.drawTiledPixmap(0, 0, size.width(), size.height(), pixmap); - - return pix; -} - - -//====================================================================== -// -// Fade effects -// -//====================================================================== - -KPixmap& KPixmapEffect::fade(KPixmap &pixmap, double val, const TQColor &color) -{ - TQImage img = pixmap.convertToImage(); - KImageEffect::fade(img, val, color); - pixmap.convertFromImage(img); - - return pixmap; -} - - -// ----------------------------------------------------------------------------- -KPixmap& KPixmapEffect::toGray(KPixmap &pixmap, bool fast) -{ - TQImage img = pixmap.convertToImage(); - KImageEffect::toGray(img, fast); - pixmap.convertFromImage(img); - - return pixmap; -} - -// ----------------------------------------------------------------------------- -KPixmap& KPixmapEffect::desaturate(KPixmap &pixmap, float desat) -{ - TQImage img = pixmap.convertToImage(); - KImageEffect::desaturate(img, desat); - pixmap.convertFromImage(img); - - return pixmap; -} -// ----------------------------------------------------------------------------- -KPixmap& KPixmapEffect::contrast(KPixmap &pixmap, int c) -{ - TQImage img = pixmap.convertToImage(); - KImageEffect::contrast(img, c); - pixmap.convertFromImage(img); - - return pixmap; -} - -//====================================================================== -// -// Dither effects -// -//====================================================================== - -// ----------------------------------------------------------------------------- -KPixmap& KPixmapEffect::dither(KPixmap &pixmap, const TQColor *palette, int size) -{ - TQImage img = pixmap.convertToImage(); - KImageEffect::dither(img, palette, size); - pixmap.convertFromImage(img); - - return pixmap; -} - -//====================================================================== -// -// Other effects -// -//====================================================================== - -KPixmap KPixmapEffect::selectedPixmap( const KPixmap &pix, const TQColor &col ) -{ - TQImage img = pix.convertToImage(); - KImageEffect::selectedImage(img, col); - KPixmap outPix; - outPix.convertFromImage(img); - return outPix; -} diff --git a/kdefx/kpixmapeffect.h b/kdefx/kpixmapeffect.h deleted file mode 100644 index c0c8ac68c..000000000 --- a/kdefx/kpixmapeffect.h +++ /dev/null @@ -1,218 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net> - (C) 1998, 1999 Daniel M. Duley <mosfet@kde.org> - (C) 1998, 1999 Dirk Mueller <mueller@kde.org> - -*/ - -// $Id$ - -#ifndef __KPIXMAP_EFFECT_H -#define __KPIXMAP_EFFECT_H - -#include <kdelibs_export.h> - -#include <tqsize.h> -class KPixmap; -class TQColor; - -/** - * This class includes various pixmap-based graphical effects. - * - * Everything is - * static, so there is no need to create an instance of this class. You can - * just call the static methods. They are encapsulated here merely to provide - * a common namespace. - */ -class KDEFX_EXPORT KPixmapEffect -{ -public: - enum GradientType { VerticalGradient, HorizontalGradient, - DiagonalGradient, CrossDiagonalGradient, - PyramidGradient, RectangleGradient, - PipeCrossGradient, EllipticGradient }; - enum RGBComponent { Red, Green, Blue }; - - enum Lighting {NorthLite, NWLite, WestLite, SWLite, - SouthLite, SELite, EastLite, NELite}; - - /** - * Creates a gradient from color a to color b of the specified type. - * - * @param pixmap The pixmap to process. - * @param ca Color a. - * @param cb Color b. - * @param type The type of gradient. - * @param ncols The number of colors to use when not running on a - * truecolor display. The gradient will be dithered to this number of - * colors. Pass 0 to prevent dithering. - * @return Returns the generated pixmap, for convenience. - */ - static KPixmap& gradient(KPixmap& pixmap, const TQColor &ca, const TQColor &cb, - GradientType type, int ncols=3); - - /** - * Creates an unbalanced gradient. - * - * An unbalanced gradient is a gradient where the transition from - * color a to color b is not linear, but in this case, exponential. - * - * @param pixmap The pixmap that should be written. - * @param ca Color a. - * @param cb Color b. - * @param type The type of gradient. - * @param xfactor The x decay length. Use a value between -200 and 200. - * @param yfactor The y decay length. - * @param ncols The number of colors. See #gradient. - * @return The generated pixmap, for convencience. - */ - static KPixmap& unbalancedGradient(KPixmap& pixmap, const TQColor &ca, - const TQColor &cb, GradientType type, int xfactor = 100, - int yfactor = 100, int ncols=3); - - /** - * Creates a pixmap of a given size with the given pixmap. - * - * if the - * given size is bigger than the size of the pixmap, the pixmap is - * tiled. - * - * @param pixmap This is the source pixmap - * @param size The size the new pixmap should have. - * @return The generated, tiled pixmap. - */ - static KPixmap createTiled(const KPixmap& pixmap, TQSize size); - - /** - * Either brightens or dims a pixmap by a specified ratio. - * - * @param pixmap The pixmap to process. - * @param ratio The ratio to use. Use negative value to dim. - * @return Returns The pixmap(), provided for convenience. - */ - static KPixmap& intensity(KPixmap& pixmap, float ratio); - - /** - * Modifies the intensity of a pixmap's RGB channel component. - * - * @param pixmap The pixmap to process. - * @param ratio value. Use negative value to dim. - * @param channel Which channel(s) should be modified - * @return Returns the pixmap(), provided for convenience. - */ - static KPixmap& channelIntensity(KPixmap& pixmap, float ratio, - RGBComponent channel); - - /** - * Blends the provided pixmap into a background of the indicated color. - * - * @param pixmap The pixmap to process. - * @param initial_intensity this parameter takes values from -1 to 1: - * @li If positive, it tells how much to fade the image in its - * less affected spot. - * @li If negative, it tells roughly indicates how much of the image - * remains unaffected - * @param bgnd Indicates the color of the background to blend in. - * @param eff Lets you choose what kind of blending you like. - * @param anti_dir Blend in the opposite direction (makes no much sense - * with concentric blending effects). - * @param ncols The number of colors to dither the pixmap to. Only - * used for 8 bpp pixmaps. - * @return Returns the pixmap(), provided for convenience. - */ - static KPixmap& blend(KPixmap& pixmap, float initial_intensity, - const TQColor &bgnd, GradientType eff, - bool anti_dir=false, int ncols=3); - - /** - * Builds a hash on any given pixmap. - * - * @param pixmap The pixmap to process. - * @param lite The hash faces the indicated lighting (cardinal poles) - * @param spacing How many unmodified pixels inbetween hashes. - * @param ncols The number of colors to dither the pixmap to. - * Only used for 8 bpp pixmaps. - * @return Returns The pixmap(), provided for convenience. - */ - static KPixmap& hash(KPixmap& pixmap, Lighting lite=NorthLite, - unsigned int spacing=0, int ncols=3); - - /** - * Creates a pattern from a pixmap. - * - * The given pixmap is "flattened" - * between color a to color b. - * Doesn't change the original pixmap. - * - * @param pixmap The pixmap to process. - * @param size The size of the returned pixmap. If @p size is larger than - * the original, the resulting pixmap will be tiled. - * @param ca Color a. - * @param cb Color b. - * @param ncols The number of colors to use. The image will be - * dithered to this depth. Pass zero to prevent dithering. - * @return The resulting pixmap. - */ - static KPixmap pattern(const KPixmap& pixmap, TQSize size, - const TQColor &ca, const TQColor &cb, int ncols=8); - - /** - * Fades a pixmap to a certain color. - * - * @param pixmap The pixmap to process. - * @param val The strength of the effect. 0 <= val <= 1. - * @param color The color to blend to. - * @return Returns the pixmap(), provided for convenience. - */ - static KPixmap& fade(KPixmap& pixmap, double val, const TQColor &color); - - /** - * Converts a pixmap to grayscale. - * - * @param pixmap The pixmap to process. - * @param fast Set to @p true in order to use a faster but non-photographic - * quality algorithm. Appropriate for things such as toolbar icons. - * @return Returns the pixmap(), provided for convenience. - */ - static KPixmap& toGray(KPixmap& pixmap, bool fast=false); - - /** - * Desaturates a pixmap. - * - * @param pixmap The pixmap to process. - * @param desat A value between 0 and 1 setting the degree of desaturation - * @return Returns The pixmap(), provided for convenience. - */ - static KPixmap& desaturate(KPixmap& pixmap, float desat = 0.3); - - /** - * Modifies the contrast of a pixmap. - * - * @param pixmap The pixmap to process. - * @param c A contrast value between -255 and 255. - * @return Returns the pixmap(), provided for convenience. - */ - static KPixmap& contrast(KPixmap& pixmap, int c); - - /** - * Dithers a pixmap using Floyd-Steinberg dithering for low-color - * situations. - * - * @param pixmap The pixmap to process. - * @param palette The color palette to use. - * @param size The size of the palette. - * @return Returns the pixmap(), provided for convenience. - */ - static KPixmap& dither(KPixmap &pixmap, const TQColor *palette, int size); - - /** - * Calculate a 'selected' pixmap, for instance a selected icon - * on the desktop. - * @param pixmap the pixmap to select - * @param col the selected color, usually from TQColorGroup::highlight(). - */ - static KPixmap selectedPixmap( const KPixmap &pixmap, const TQColor &col ); -}; - - -#endif diff --git a/kdefx/kpixmapsplitter.cpp b/kdefx/kpixmapsplitter.cpp deleted file mode 100644 index 44b8f01fa..000000000 --- a/kdefx/kpixmapsplitter.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> - - 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. -*/ - -#include "kpixmapsplitter.h" - -KPixmapSplitter::KPixmapSplitter() - : m_itemSize( 4, 7 ), - m_vSpacing( 0 ), - m_hSpacing( 0 ), - m_numCols( 0 ), - m_numRows( 0 ), - m_dirty( false ) -{ -} - -KPixmapSplitter::~KPixmapSplitter() -{ -} - -void KPixmapSplitter::setPixmap( const TQPixmap& pixmap ) -{ - m_pixmap = pixmap; - m_dirty = true; -} - -void KPixmapSplitter::setItemSize( const TQSize& size ) -{ - if ( size != m_itemSize ) { - m_itemSize = size; - m_dirty = true; - } -} - -void KPixmapSplitter::setVSpacing( int spacing ) -{ - if ( spacing != m_vSpacing ) { - m_vSpacing = spacing; - m_dirty = true; - } -} - -void KPixmapSplitter::setHSpacing( int spacing ) -{ - if ( spacing != m_hSpacing ) { - m_hSpacing = spacing; - m_dirty = true; - } -} - - -TQRect KPixmapSplitter::coordinates( int pos ) -{ - if ( pos < 0 || m_pixmap.isNull() ) - return TQRect(); - - if ( m_dirty ) { - m_numCols = m_pixmap.width() / ( m_itemSize.width() + m_hSpacing ); - m_numRows = m_pixmap.height() / ( m_itemSize.height() + m_vSpacing ); - m_dirty = false; - // qDebug("cols: %i, rows: %i (pixmap: %i, %i)", m_numCols, m_numRows, m_pixmap.width(), m_pixmap.height()); - } - - if ( m_numCols == 0 || m_numRows == 0 ) - return TQRect(); - - int row = pos / m_numCols; - int col = pos - (row * m_numCols); - - return TQRect( col * (m_itemSize.width() + m_hSpacing), - row * (m_itemSize.height() + m_vSpacing), - m_itemSize.width(), - m_itemSize.height() ); -} - -TQRect KPixmapSplitter::coordinates( const TQChar& ch ) -{ - return coordinates( (unsigned char) ch.latin1() ); -} - diff --git a/kdefx/kpixmapsplitter.h b/kdefx/kpixmapsplitter.h deleted file mode 100644 index 84b5a8647..000000000 --- a/kdefx/kpixmapsplitter.h +++ /dev/null @@ -1,123 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> - - 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 KPIXMAPSPLITTER_H -#define KPIXMAPSPLITTER_H - -#include <tqpixmap.h> -#include <tqrect.h> -#include <tqsize.h> -#include <tqstring.h> - -#include <kdelibs_export.h> - -class KPixmapSplitterPrivate; -/** - * @short A class to split a pixmap into several items. - * - * If you have a pixmap containing several items (icons), you can use this - * class to get the coordinates of each item. - * - * For example, if you have a pixmap with 25 items and you want to get the - * 4th item as a pixmap (every item being 20x10 pixels): - * \code - * KPixmapSplitter splitter; - * splitter.setPixmap( somePixmap ); - * splitter.setItemSize( TQSize( 20, 10 )); - * - * TQPixmap item( 20, 10 ); - * item.fill( Qt::white ); - * TQRect rect = splitter.coordinates( 4 ); - * if ( !rect.isEmpty() ) - * bitBlt( &item, TQPoint(0,0), &somePixmap, rect, CopyROP ); - * \endcode - * - * @author Carsten Pfeiffer <pfeiffer@kde.org> - */ -class KDEFX_EXPORT KPixmapSplitter -{ -public: - /** - * Constructor, does nothing but initialize some default-values. - */ - KPixmapSplitter(); - ~KPixmapSplitter(); - - /** - * Sets the pixmap to be split. - */ - void setPixmap( const TQPixmap& pixmap ); - - /** - * @returns the pixmap that has been set via setPixmap(). - */ - const TQPixmap& pixmap() const { return m_pixmap; } - - /** - * Sets the size of the items you want to get out of the given pixmap. - * The TQRect of #coordinates(int) will have the width and height of exactly - * this @p size. - */ - void setItemSize( const TQSize& size ); - - /** - * @returns the set size of the items (coordinates) you want to get - * out of the given pixmap. - */ - TQSize itemSize() const { return m_itemSize; } - - /** - * If there is space between rows in the given pixmap, you have to specify - * how many pixels there are. - */ - void setVSpacing( int spacing ); - - /** - * If there is space between columns in the given pixmap, you have to - * specify how many pixels there are. - */ - void setHSpacing( int spacing ); - - /** - * @returns the coordinates of the item at position pos in the given - * pixmap. - */ - TQRect coordinates( int pos ); - - /** - * Overloaded for convenience. Returns the item at the position of the - * given character (when using a latin1 font-pixmap) - */ - TQRect coordinates( const TQChar& ch ); - -private: - TQPixmap m_pixmap; - TQSize m_itemSize; - - int m_vSpacing; - int m_hSpacing; - - int m_numCols; - int m_numRows; - - bool m_dirty; - KPixmapSplitterPrivate* d; -}; - -#endif // KPIXMAPSPLITTER_H diff --git a/kdefx/kstyle.cpp b/kdefx/kstyle.cpp deleted file mode 100644 index f80094fe4..000000000 --- a/kdefx/kstyle.cpp +++ /dev/null @@ -1,2370 +0,0 @@ -/* - * - * KStyle - * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> - * - * TQWindowsStyle CC_ListView and style images were kindly donated by TrollTech, - * Copyright (C) 1998-2000 TrollTech AS. - * - * Many thanks to Bradley T. Hughes for the 3 button scrollbar code. - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "kstyle.h" - -#include <tqapplication.h> -#include <tqbitmap.h> -#include <tqmetaobject.h> -#include <tqcleanuphandler.h> -#include <tqmap.h> -#include <tqimage.h> -#include <tqlistview.h> -#include <tqmenubar.h> -#include <tqpainter.h> -#include <tqpixmap.h> -#include <tqpopupmenu.h> -#include <tqprogressbar.h> -#include <tqscrollbar.h> -#include <tqsettings.h> -#include <tqslider.h> -#include <tqstylefactory.h> -#include <tqtabbar.h> -#include <tqtoolbar.h> -#include <tqframe.h> - -#include <kpixmap.h> -#include <kpixmapeffect.h> -#include <kimageeffect.h> - -#ifdef Q_WS_X11 -# include <X11/Xlib.h> -# ifdef HAVE_XRENDER -# include <X11/extensions/Xrender.h> // schroder - extern bool qt_use_xrender; -# endif -#else -#undef HAVE_XRENDER -#endif - -#ifdef HAVE_XCOMPOSITE -#include <X11/extensions/Xrender.h> -#include <X11/extensions/Xcomposite.h> -#include <dlfcn.h> -#endif - -#include <limits.h> - -namespace -{ - // INTERNAL - enum TransparencyEngine { - Disabled = 0, - SoftwareTint, - SoftwareBlend, - XRender - }; - - // Drop Shadow - struct ShadowElements { - TQWidget* w1; - TQWidget* w2; - }; - typedef TQMap<const TQWidget*,ShadowElements> ShadowMap; - static ShadowMap *_shadowMap = 0; - TQSingleCleanupHandler<ShadowMap> cleanupShadowMap; - ShadowMap &shadowMap() { - if ( !_shadowMap ) { - _shadowMap = new ShadowMap; - cleanupShadowMap.set( &_shadowMap ); - } - return *_shadowMap; - } - - - // DO NOT ASK ME HOW I MADE THESE TABLES! - // (I probably won't remember anyway ;) - const double top_right_corner[16] = - { 0.949, 0.965, 0.980, 0.992, - 0.851, 0.890, 0.945, 0.980, - 0.706, 0.780, 0.890, 0.960, - 0.608, 0.706, 0.851, 0.949 }; - - const double bottom_right_corner[16] = - { 0.608, 0.706, 0.851, 0.949, - 0.706, 0.780, 0.890, 0.960, - 0.851, 0.890, 0.945, 0.980, - 0.949, 0.965, 0.980, 0.992 }; - - const double bottom_left_corner[16] = - { 0.949, 0.851, 0.706, 0.608, - 0.965, 0.890, 0.780, 0.706, - 0.980, 0.945, 0.890, 0.851, - 0.992, 0.980, 0.960, 0.949 }; - - const double shadow_strip[4] = - { 0.565, 0.675, 0.835, 0.945 }; - - static bool useDropShadow(TQWidget* w) - { - return w && w->tqmetaObject() && - w->tqmetaObject()->findProperty("KStyleMenuDropShadow") != -1; - } -} - -namespace -{ -class TransparencyHandler : public TQObject -{ - public: - TransparencyHandler(KStyle* style, TransparencyEngine tEngine, - float menuOpacity, bool useDropShadow); - ~TransparencyHandler(); - bool eventFilter(TQObject* object, TQEvent* event); - - protected: - void blendToColor(const TQColor &col); - void blendToPixmap(const TQColorGroup &cg, const TQWidget* p); -#ifdef HAVE_XRENDER - void XRenderBlendToPixmap(const TQWidget* p); -#endif - bool haveX11RGBASupport(); - TQImage handleRealAlpha(TQImage); - void createShadowWindows(const TQWidget* p); - void removeShadowWindows(const TQWidget* p); - void rightShadow(TQImage& dst); - void bottomShadow(TQImage& dst); - private: - bool dropShadow; - float opacity; - TQPixmap pix; - KStyle* kstyle; - TransparencyEngine te; -}; -} // namespace - -struct KStylePrivate -{ - bool highcolor : 1; - bool useFilledFrameWorkaround : 1; - bool etchDisabledText : 1; - bool scrollablePopupmenus : 1; - bool menuAltKeyNavigation : 1; - bool menuDropShadow : 1; - bool sloppySubMenus : 1; - bool semiTransparentRubberband : 1; - int popupMenuDelay; - float menuOpacity; - - TransparencyEngine transparencyEngine; - KStyle::KStyleScrollBarType scrollbarType; - TransparencyHandler* menuHandler; - KStyle::KStyleFlags flags; - - //For KPE_ListViewBranch - TQBitmap *verticalLine; - TQBitmap *horizontalLine; -}; - -// ----------------------------------------------------------------------------- - - -KStyle::KStyle( KStyleFlags flags, KStyleScrollBarType sbtype ) - : TQCommonStyle(), d(new KStylePrivate) -{ - d->flags = flags; - bool useMenuTransparency = (flags & AllowMenuTransparency); - d->useFilledFrameWorkaround = (flags & FilledFrameWorkaround); - d->scrollbarType = sbtype; - d->highcolor = TQPixmap::defaultDepth() > 8; - - // Read style settings - TQSettings settings; - d->popupMenuDelay = settings.readNumEntry ("/KStyle/Settings/PopupMenuDelay", 256); - d->sloppySubMenus = settings.readBoolEntry("/KStyle/Settings/SloppySubMenus", false); - d->etchDisabledText = settings.readBoolEntry("/KStyle/Settings/EtchDisabledText", true); - d->menuAltKeyNavigation = settings.readBoolEntry("/KStyle/Settings/MenuAltKeyNavigation", true); - d->scrollablePopupmenus = settings.readBoolEntry("/KStyle/Settings/ScrollablePopupMenus", false); - d->menuDropShadow = settings.readBoolEntry("/KStyle/Settings/MenuDropShadow", false); - d->semiTransparentRubberband = settings.readBoolEntry("/KStyle/Settings/SemiTransparentRubberband", false); - d->menuHandler = NULL; - - if (useMenuTransparency) { - TQString effectEngine = settings.readEntry("/KStyle/Settings/MenuTransparencyEngine", "Disabled"); - -#ifdef HAVE_XRENDER - if (effectEngine == "XRender") - d->transparencyEngine = XRender; -#else - if (effectEngine == "XRender") - d->transparencyEngine = SoftwareBlend; -#endif - else if (effectEngine == "SoftwareBlend") - d->transparencyEngine = SoftwareBlend; - else if (effectEngine == "SoftwareTint") - d->transparencyEngine = SoftwareTint; - else - d->transparencyEngine = Disabled; - - if (d->transparencyEngine != Disabled) { - // Create an instance of the menu transparency handler - d->menuOpacity = settings.readDoubleEntry("/KStyle/Settings/MenuOpacity", 0.90); - d->menuHandler = new TransparencyHandler(this, d->transparencyEngine, - d->menuOpacity, d->menuDropShadow); - } - } - - d->verticalLine = 0; - d->horizontalLine = 0; - - // Create a transparency handler if only drop shadows are enabled. - if (!d->menuHandler && d->menuDropShadow) - d->menuHandler = new TransparencyHandler(this, Disabled, 1.0, d->menuDropShadow); -} - - -KStyle::~KStyle() -{ - delete d->verticalLine; - delete d->horizontalLine; - - delete d->menuHandler; - - d->menuHandler = NULL; - delete d; -} - - -TQString KStyle::defaultStyle() -{ - if (TQPixmap::defaultDepth() > 8) - return TQString("plastik"); - else - return TQString("light, 3rd revision"); -} - -void KStyle::polish( TQWidget* widget ) -{ - if ( d->useFilledFrameWorkaround ) - { - if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) { - TQFrame::Shape tqshape = frame->frameShape(); - if (tqshape == TQFrame::ToolBarPanel || tqshape == TQFrame::MenuBarPanel) - widget->installEventFilter(this); - } - } - if (widget->isTopLevel()) - { - if (!d->menuHandler && useDropShadow(widget)) - d->menuHandler = new TransparencyHandler(this, Disabled, 1.0, false); - - if (d->menuHandler && useDropShadow(widget)) - widget->installEventFilter(d->menuHandler); - } -} - - -void KStyle::unPolish( TQWidget* widget ) -{ - if ( d->useFilledFrameWorkaround ) - { - if ( TQFrame *frame = ::tqqt_cast< TQFrame* >( widget ) ) { - TQFrame::Shape tqshape = frame->frameShape(); - if (tqshape == TQFrame::ToolBarPanel || tqshape == TQFrame::MenuBarPanel) - widget->removeEventFilter(this); - } - } - if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget)) - widget->removeEventFilter(d->menuHandler); -} - - -// Style changes (should) always re-polish popups. -void KStyle::polishPopupMenu( TQPopupMenu* p ) -{ - if (!p->testWState( WState_Polished )) - p->setCheckable(true); - - // Install transparency handler if the effect is enabled. - if ( d->menuHandler && - (strcmp(p->name(), "tear off menu") != 0)) - p->installEventFilter(d->menuHandler); -} - - -// ----------------------------------------------------------------------------- -// KStyle extensions -// ----------------------------------------------------------------------------- - -void KStyle::setScrollBarType(KStyleScrollBarType sbtype) -{ - d->scrollbarType = sbtype; -} - -KStyle::KStyleFlags KStyle::styleFlags() const -{ - return d->flags; -} - -void KStyle::renderMenuBlendPixmap( KPixmap &pix, const TQColorGroup &cg, - const TQPopupMenu* /* popup */ ) const -{ - pix.fill(cg.button()); // Just tint as the default behavior -} - - -void KStyle::drawKStylePrimitive( KStylePrimitive kpe, - TQPainter* p, - const TQWidget* widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption& /* opt */ ) const -{ - switch( kpe ) - { - // Dock / Toolbar / General handles. - // --------------------------------- - - case KPE_DockWindowHandle: { - - // Draws a nice DockWindow handle including the dock title. - TQWidget* wid = const_cast<TQWidget*>(widget); - bool horizontal = flags & Style_Horizontal; - int x,y,w,h,x2,y2; - - r.rect( &x, &y, &w, &h ); - if ((w <= 2) || (h <= 2)) { - p->fillRect(r, cg.highlight()); - return; - } - - - x2 = x + w - 1; - y2 = y + h - 1; - - TQFont fnt; - fnt = TQApplication::font(wid); - fnt.setPointSize( fnt.pointSize()-2 ); - - // Draw the item on an off-screen pixmap - // to preserve Xft antialiasing for - // vertically oriented handles. - TQPixmap pix; - if (horizontal) - pix.resize( h-2, w-2 ); - else - pix.resize( w-2, h-2 ); - - TQString title = wid->parentWidget()->caption(); - TQPainter p2; - p2.begin(&pix); - p2.fillRect(pix.rect(), cg.brush(TQColorGroup::Highlight)); - p2.setPen(cg.highlightedText()); - p2.setFont(fnt); - p2.drawText(pix.rect(), AlignCenter, title); - p2.end(); - - // Draw a sunken bevel - p->setPen(cg.dark()); - p->drawLine(x, y, x2, y); - p->drawLine(x, y, x, y2); - p->setPen(cg.light()); - p->drawLine(x+1, y2, x2, y2); - p->drawLine(x2, y+1, x2, y2); - - if (horizontal) { - TQWMatrix m; - m.rotate(-90.0); - TQPixmap vpix = pix.xForm(m); - bitBlt(wid, r.x()+1, r.y()+1, &vpix); - } else - bitBlt(wid, r.x()+1, r.y()+1, &pix); - - break; - } - - - /* - * KPE_ListViewExpander and KPE_ListViewBranch are based on code from - * QWindowStyle's CC_ListView, kindly donated by TrollTech. - * CC_ListView code is Copyright (C) 1998-2000 TrollTech AS. - */ - - case KPE_ListViewExpander: { - // Typical Windows style expand/collapse element. - int radius = (r.width() - 4) / 2; - int centerx = r.x() + r.width()/2; - int centery = r.y() + r.height()/2; - - // Outer box - p->setPen( cg.mid() ); - p->drawRect( r ); - - // plus or minus - p->setPen( cg.text() ); - p->drawLine( centerx - radius, centery, centerx + radius, centery ); - if ( flags & Style_On ) // Collapsed = On - p->drawLine( centerx, centery - radius, centerx, centery + radius ); - break; - } - - case KPE_ListViewBranch: { - // Typical Windows style listview branch element (dotted line). - - // Create the dotline pixmaps if not already created - if ( !d->verticalLine ) - { - // make 128*1 and 1*128 bitmaps that can be used for - // drawing the right sort of lines. - d->verticalLine = new TQBitmap( 1, 129, true ); - d->horizontalLine = new TQBitmap( 128, 1, true ); - TQPointArray a( 64 ); - TQPainter p2; - p2.begin( d->verticalLine ); - - int i; - for( i=0; i < 64; i++ ) - a.setPoint( i, 0, i*2+1 ); - p2.setPen( color1 ); - p2.drawPoints( a ); - p2.end(); - TQApplication::flushX(); - d->verticalLine->setMask( *d->verticalLine ); - - p2.begin( d->horizontalLine ); - for( i=0; i < 64; i++ ) - a.setPoint( i, i*2+1, 0 ); - p2.setPen( color1 ); - p2.drawPoints( a ); - p2.end(); - TQApplication::flushX(); - d->horizontalLine->setMask( *d->horizontalLine ); - } - - p->setPen( cg.text() ); // cg.dark() is bad for dark color schemes. - - if (flags & Style_Horizontal) - { - int point = r.x(); - int other = r.y(); - int end = r.x()+r.width(); - int thickness = r.height(); - - while( point < end ) - { - int i = 128; - if ( i+point > end ) - i = end-point; - p->drawPixmap( point, other, *d->horizontalLine, 0, 0, i, thickness ); - point += i; - } - - } else { - int point = r.y(); - int other = r.x(); - int end = r.y()+r.height(); - int thickness = r.width(); - int pixmapoffset = (flags & Style_NoChange) ? 0 : 1; // ### Hackish - - while( point < end ) - { - int i = 128; - if ( i+point > end ) - i = end-point; - p->drawPixmap( other, point, *d->verticalLine, 0, pixmapoffset, thickness, i ); - point += i; - } - } - - break; - } - - // Reimplement the other primitives in your styles. - // The current implementation just paints something visibly different. - case KPE_ToolBarHandle: - case KPE_GeneralHandle: - case KPE_SliderHandle: - p->fillRect(r, cg.light()); - break; - - case KPE_SliderGroove: - p->fillRect(r, cg.dark()); - break; - - default: - p->fillRect(r, Qt::yellow); // Something really bad happened - highlight. - break; - } -} - - -int KStyle::kPixelMetric( KStylePixelMetric kpm, const TQWidget* /* widget */) const -{ - int value; - switch(kpm) - { - case KPM_ListViewBranchThickness: - value = 1; - break; - - case KPM_MenuItemSeparatorHeight: - case KPM_MenuItemHMargin: - case KPM_MenuItemVMargin: - case KPM_MenuItemHFrame: - case KPM_MenuItemVFrame: - case KPM_MenuItemCheckMarkHMargin: - case KPM_MenuItemArrowHMargin: - case KPM_MenuItemTabSpacing: - default: - value = 0; - } - - return value; -} - -// ----------------------------------------------------------------------------- - -// #ifdef USE_QT4 // kdebindings / smoke needs this function declaration available at all times. Furthermore I don't think it would hurt to have the declaration available at all times...so leave these commented out for now - -//void KStyle::tqdrawPrimitive( TQ_ControlElement pe, -// TQPainter* p, -// const TQRect &r, -// const TQColorGroup &cg, -// SFlags flags, -// const TQStyleOption& opt ) const -//{ -// // FIXME: -// // What should "widget" be in actuality? How should I get it? From where? -// // Almost certainly it should not be null! -// TQWidget *widget = 0; -// tqdrawControl(pe, p, widget, r, cg, flags, opt); -//} - -// #endif // USE_QT4 - -// ----------------------------------------------------------------------------- - -void KStyle::tqdrawPrimitive( TQ_PrimitiveElement pe, - TQPainter* p, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption& opt ) const -{ - // TOOLBAR/DOCK WINDOW HANDLE - // ------------------------------------------------------------------------ - if (pe == PE_DockWindowHandle) - { - // Wild workarounds are here. Beware. - TQWidget *widget, *parent; - - if (p && p->device()->devType() == TQInternal::Widget) { - widget = static_cast<TQWidget*>(p->device()); - parent = widget->parentWidget(); - } else - return; // Don't paint on non-widgets - - // Check if we are a normal toolbar or a hidden dockwidget. - if ( parent && - (parent->inherits(TQTOOLBAR_OBJECT_NAME_STRING) || // Normal toolbar - (parent->inherits(TQMAINWINDOW_OBJECT_NAME_STRING)) )) // Collapsed dock - - // Draw a toolbar handle - drawKStylePrimitive( KPE_ToolBarHandle, p, widget, r, cg, flags, opt ); - - else if ( widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) ) - - // Draw a dock window handle - drawKStylePrimitive( KPE_DockWindowHandle, p, widget, r, cg, flags, opt ); - - else - // General handle, probably a kicker applet handle. - drawKStylePrimitive( KPE_GeneralHandle, p, widget, r, cg, flags, opt ); -#if QT_VERSION >= 0x030300 -#ifdef HAVE_XRENDER - } else if ( d->semiTransparentRubberband && pe == TQStyle::PE_RubberBand ) { - TQRect rect = r.normalize(); - TQPoint point; - point = p->xForm( point ); - - static XRenderColor clr = { 0, 0, 0, 0 }; - static unsigned long fillColor = 0; - if ( fillColor != cg.highlight().rgb() ) { - fillColor = cg.highlight().rgb(); - - unsigned long color = fillColor << 8 | 0x40; - - int red = (color >> 24) & 0xff; - int green = (color >> 16) & 0xff; - int blue = (color >> 8) & 0xff; - int alpha = (color >> 0) & 0xff; - - red = red * alpha / 255; - green = green * alpha / 255; - blue = blue * alpha / 255; - - clr.red = (red << 8) + red; - clr.green = (green << 8) + green; - clr.blue = (blue << 8) + blue; - clr.alpha = (alpha << 8) + alpha; - } - - XRenderFillRectangle( - p->tqdevice()->x11Display(), - PictOpOver, - p->tqdevice()->x11RenderHandle(), - &clr, - rect.x() + point.x(), - rect.y() + point.y(), - rect.width(), - rect.height() ); - - p->save(); - p->setRasterOp( TQt::CopyROP ); - p->setPen( TQPen( cg.highlight().dark( 160 ), 1 ) ); - p->setBrush( NoBrush ); - p->drawRect( - rect.x() + point.x(), - rect.y() + point.y(), - rect.width(), - rect.height() ); - p->restore(); -#endif -#endif - } else - TQCommonStyle::tqdrawPrimitive( pe, p, r, cg, flags, opt ); -} - - - -void KStyle::tqdrawControl( TQ_ControlElement element, - TQPainter* p, - const TQWidget* widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption &opt ) const -{ - switch (element) - { - // TABS - // ------------------------------------------------------------------------ - case CE_TabBarTab: { - const TQTabBar* tb = (const TQTabBar*) widget; - TQTabBar::Shape tbs = tb->tqshape(); - bool selected = flags & Style_Selected; - int x = r.x(), y=r.y(), bottom=r.bottom(), right=r.right(); - - switch (tbs) { - - case TQTabBar::RoundedAbove: { - if (!selected) - p->translate(0,1); - p->setPen(selected ? cg.light() : cg.shadow()); - p->drawLine(x, y+4, x, bottom); - p->drawLine(x, y+4, x+4, y); - p->drawLine(x+4, y, right-1, y); - if (selected) - p->setPen(cg.shadow()); - p->drawLine(right, y+1, right, bottom); - - p->setPen(cg.midlight()); - p->drawLine(x+1, y+4, x+1, bottom); - p->drawLine(x+1, y+4, x+4, y+1); - p->drawLine(x+5, y+1, right-2, y+1); - - if (selected) { - p->setPen(cg.mid()); - p->drawLine(right-1, y+1, right-1, bottom); - } else { - p->setPen(cg.mid()); - p->drawPoint(right-1, y+1); - p->drawLine(x+4, y+2, right-1, y+2); - p->drawLine(x+3, y+3, right-1, y+3); - p->fillRect(x+2, y+4, r.width()-3, r.height()-6, cg.mid()); - - p->setPen(cg.light()); - p->drawLine(x, bottom-1, right, bottom-1); - p->translate(0,-1); - } - break; - } - - case TQTabBar::RoundedBelow: { - if (!selected) - p->translate(0,-1); - p->setPen(selected ? cg.light() : cg.shadow()); - p->drawLine(x, bottom-4, x, y); - if (selected) - p->setPen(cg.mid()); - p->drawLine(x, bottom-4, x+4, bottom); - if (selected) - p->setPen(cg.shadow()); - p->drawLine(x+4, bottom, right-1, bottom); - p->drawLine(right, bottom-1, right, y); - - p->setPen(cg.midlight()); - p->drawLine(x+1, bottom-4, x+1, y); - p->drawLine(x+1, bottom-4, x+4, bottom-1); - p->drawLine(x+5, bottom-1, right-2, bottom-1); - - if (selected) { - p->setPen(cg.mid()); - p->drawLine(right-1, y, right-1, bottom-1); - } else { - p->setPen(cg.mid()); - p->drawPoint(right-1, bottom-1); - p->drawLine(x+4, bottom-2, right-1, bottom-2); - p->drawLine(x+3, bottom-3, right-1, bottom-3); - p->fillRect(x+2, y+2, r.width()-3, r.height()-6, cg.mid()); - p->translate(0,1); - p->setPen(cg.dark()); - p->drawLine(x, y, right, y); - } - break; - } - - case TQTabBar::TriangularAbove: { - if (!selected) - p->translate(0,1); - p->setPen(selected ? cg.light() : cg.shadow()); - p->drawLine(x, bottom, x, y+6); - p->drawLine(x, y+6, x+6, y); - p->drawLine(x+6, y, right-6, y); - if (selected) - p->setPen(cg.mid()); - p->drawLine(right-5, y+1, right-1, y+5); - p->setPen(cg.shadow()); - p->drawLine(right, y+6, right, bottom); - - p->setPen(cg.midlight()); - p->drawLine(x+1, bottom, x+1, y+6); - p->drawLine(x+1, y+6, x+6, y+1); - p->drawLine(x+6, y+1, right-6, y+1); - p->drawLine(right-5, y+2, right-2, y+5); - p->setPen(cg.mid()); - p->drawLine(right-1, y+6, right-1, bottom); - - TQPointArray a(6); - a.setPoint(0, x+2, bottom); - a.setPoint(1, x+2, y+7); - a.setPoint(2, x+7, y+2); - a.setPoint(3, right-7, y+2); - a.setPoint(4, right-2, y+7); - a.setPoint(5, right-2, bottom); - p->setPen (selected ? cg.background() : cg.mid()); - p->setBrush(selected ? cg.background() : cg.mid()); - p->drawPolygon(a); - p->setBrush(NoBrush); - if (!selected) { - p->translate(0,-1); - p->setPen(cg.light()); - p->drawLine(x, bottom, right, bottom); - } - break; - } - - default: { // TQTabBar::TriangularBelow - if (!selected) - p->translate(0,-1); - p->setPen(selected ? cg.light() : cg.shadow()); - p->drawLine(x, y, x, bottom-6); - if (selected) - p->setPen(cg.mid()); - p->drawLine(x, bottom-6, x+6, bottom); - if (selected) - p->setPen(cg.shadow()); - p->drawLine(x+6, bottom, right-6, bottom); - p->drawLine(right-5, bottom-1, right-1, bottom-5); - if (!selected) - p->setPen(cg.shadow()); - p->drawLine(right, bottom-6, right, y); - - p->setPen(cg.midlight()); - p->drawLine(x+1, y, x+1, bottom-6); - p->drawLine(x+1, bottom-6, x+6, bottom-1); - p->drawLine(x+6, bottom-1, right-6, bottom-1); - p->drawLine(right-5, bottom-2, right-2, bottom-5); - p->setPen(cg.mid()); - p->drawLine(right-1, bottom-6, right-1, y); - - TQPointArray a(6); - a.setPoint(0, x+2, y); - a.setPoint(1, x+2, bottom-7); - a.setPoint(2, x+7, bottom-2); - a.setPoint(3, right-7, bottom-2); - a.setPoint(4, right-2, bottom-7); - a.setPoint(5, right-2, y); - p->setPen (selected ? cg.background() : cg.mid()); - p->setBrush(selected ? cg.background() : cg.mid()); - p->drawPolygon(a); - p->setBrush(NoBrush); - if (!selected) { - p->translate(0,1); - p->setPen(cg.dark()); - p->drawLine(x, y, right, y); - } - break; - } - }; - - break; - } - - // Popup menu scroller - // ------------------------------------------------------------------------ - case CE_PopupMenuScroller: { - p->fillRect(r, cg.background()); - tqdrawPrimitive(PE_ButtonTool, p, r, cg, Style_Enabled); - tqdrawPrimitive((flags & Style_Up) ? PE_ArrowUp : PE_ArrowDown, p, r, cg, Style_Enabled); - break; - } - - - // PROGRESSBAR - // ------------------------------------------------------------------------ - case CE_ProgressBarGroove: { - TQRect fr = subRect(SR_ProgressBarGroove, widget); - tqdrawPrimitive(PE_Panel, p, fr, cg, Style_Sunken, TQStyleOption::SO_Default); - break; - } - - case CE_ProgressBarContents: { - // ### Take into account totalSteps() for busy indicator - const TQProgressBar* pb = (const TQProgressBar*)widget; - TQRect cr = subRect(SR_ProgressBarContents, widget); - double progress = pb->progress(); - bool reverse = TQApplication::reverseLayout(); - int steps = pb->totalSteps(); - - if (!cr.isValid()) - return; - - // Draw progress bar - if (progress > 0 || steps == 0) { - double pg = (steps == 0) ? 0.1 : progress / steps; - int width = QMIN(cr.width(), (int)(pg * cr.width())); - if (steps == 0) { //Busy indicator - - if (width < 1) width = 1; //A busy indicator with width 0 is kind of useless - - int remWidth = cr.width() - width; //Never disappear completely - if (remWidth <= 0) remWidth = 1; //Do something non-crashy when too small... - - int pstep = int(progress) % ( 2 * remWidth ); - - if ( pstep > remWidth ) { - //Bounce about.. We're remWidth + some delta, we want to be remWidth - delta... - // - ( (remWidth + some delta) - 2* remWidth ) = - (some deleta - remWidth) = remWidth - some delta.. - pstep = - (pstep - 2 * remWidth ); - } - - if (reverse) - p->fillRect(cr.x() + cr.width() - width - pstep, cr.y(), width, cr.height(), - cg.brush(TQColorGroup::Highlight)); - else - p->fillRect(cr.x() + pstep, cr.y(), width, cr.height(), - cg.brush(TQColorGroup::Highlight)); - - return; - } - - - // Do fancy gradient for highcolor displays - if (d->highcolor) { - TQColor c(cg.highlight()); - KPixmap pix; - pix.resize(cr.width(), cr.height()); - KPixmapEffect::gradient(pix, reverse ? c.light(150) : c.dark(150), - reverse ? c.dark(150) : c.light(150), - KPixmapEffect::HorizontalGradient); - if (reverse) - p->drawPixmap(cr.x()+(cr.width()-width), cr.y(), pix, - cr.width()-width, 0, width, cr.height()); - else - p->drawPixmap(cr.x(), cr.y(), pix, 0, 0, width, cr.height()); - } else - if (reverse) - p->fillRect(cr.x()+(cr.width()-width), cr.y(), width, cr.height(), - cg.brush(TQColorGroup::Highlight)); - else - p->fillRect(cr.x(), cr.y(), width, cr.height(), - cg.brush(TQColorGroup::Highlight)); - } - break; - } - - case CE_ProgressBarLabel: { - const TQProgressBar* pb = (const TQProgressBar*)widget; - TQRect cr = subRect(SR_ProgressBarContents, widget); - double progress = pb->progress(); - bool reverse = TQApplication::reverseLayout(); - int steps = pb->totalSteps(); - - if (!cr.isValid()) - return; - - TQFont font = p->font(); - font.setBold(true); - p->setFont(font); - - // Draw label - if (progress > 0 || steps == 0) { - double pg = (steps == 0) ? 1.0 : progress / steps; - int width = QMIN(cr.width(), (int)(pg * cr.width())); - TQRect crect; - if (reverse) - crect.setRect(cr.x()+(cr.width()-width), cr.y(), cr.width(), cr.height()); - else - crect.setRect(cr.x()+width, cr.y(), cr.width(), cr.height()); - - p->save(); - p->setPen(pb->isEnabled() ? (reverse ? cg.text() : cg.highlightedText()) : cg.text()); - p->drawText(r, AlignCenter, pb->progressString()); - p->setClipRect(crect); - p->setPen(reverse ? cg.highlightedText() : cg.text()); - p->drawText(r, AlignCenter, pb->progressString()); - p->restore(); - - } else { - p->setPen(cg.text()); - p->drawText(r, AlignCenter, pb->progressString()); - } - - break; - } - - default: - TQCommonStyle::tqdrawControl(element, p, widget, r, cg, flags, opt); - } -} - - -TQRect KStyle::subRect(SubRect r, const TQWidget* widget) const -{ - switch(r) - { - // KDE2 look smooth progress bar - // ------------------------------------------------------------------------ - case SR_ProgressBarGroove: - return widget->rect(); - - case SR_ProgressBarContents: - case SR_ProgressBarLabel: { - // ### take into account indicatorFollowsStyle() - TQRect rt = widget->rect(); - return TQRect(rt.x()+2, rt.y()+2, rt.width()-4, rt.height()-4); - } - - default: - return TQCommonStyle::subRect(r, widget); - } -} - - -int KStyle::tqpixelMetric(PixelMetric m, const TQWidget* widget) const -{ - switch(m) - { - // BUTTONS - // ------------------------------------------------------------------------ - case PM_ButtonShiftHorizontal: // Offset by 1 - case PM_ButtonShiftVertical: // ### Make configurable - return 1; - - case PM_DockWindowHandleExtent: - { - TQWidget* parent = 0; - // Check that we are not a normal toolbar or a hidden dockwidget, - // in which case we need to adjust the height for font size - if (widget && (parent = widget->parentWidget() ) - && !parent->inherits(TQTOOLBAR_OBJECT_NAME_STRING) - && !parent->inherits(TQMAINWINDOW_OBJECT_NAME_STRING) - && widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) ) - return widget->fontMetrics().lineSpacing(); - else - return TQCommonStyle::tqpixelMetric(m, widget); - } - - // TABS - // ------------------------------------------------------------------------ - case PM_TabBarTabHSpace: - return 24; - - case PM_TabBarTabVSpace: { - const TQTabBar * tb = (const TQTabBar *) widget; - if ( tb->tqshape() == TQTabBar::RoundedAbove || - tb->tqshape() == TQTabBar::RoundedBelow ) - return 10; - else - return 4; - } - - case PM_TabBarTabOverlap: { - const TQTabBar* tb = (const TQTabBar*)widget; - TQTabBar::Shape tbs = tb->tqshape(); - - if ( (tbs == TQTabBar::RoundedAbove) || - (tbs == TQTabBar::RoundedBelow) ) - return 0; - else - return 2; - } - - // SLIDER - // ------------------------------------------------------------------------ - case PM_SliderLength: - return 18; - - case PM_SliderThickness: - return 24; - - // Determines how much space to leave for the actual non-tickmark - // portion of the slider. - case PM_SliderControlThickness: { - const TQSlider* slider = (const TQSlider*)widget; - TQSlider::TickSetting ts = slider->tickmarks(); - int thickness = (slider->orientation() == Qt::Horizontal) ? - slider->height() : slider->width(); - switch (ts) { - case TQSlider::NoMarks: // Use total area. - break; - case TQSlider::Both: - thickness = (thickness/2) + 3; // Use approx. 1/2 of area. - break; - default: // Use approx. 2/3 of area - thickness = ((thickness*2)/3) + 3; - break; - }; - return thickness; - } - - // SPLITTER - // ------------------------------------------------------------------------ - case PM_SplitterWidth: - if (widget && widget->inherits("QDockWindowResizeHandle")) - return 8; // ### why do we need 2pix extra? - else - return 6; - - // FRAMES - // ------------------------------------------------------------------------ - case PM_MenuBarFrameWidth: - return 1; - - case PM_DockWindowFrameWidth: - return 1; - - // GENERAL - // ------------------------------------------------------------------------ - case PM_MaximumDragDistance: - return -1; - - case PM_MenuBarItemSpacing: - return 5; - - case PM_ToolBarItemSpacing: - return 0; - - case PM_PopupMenuScrollerHeight: - return tqpixelMetric( PM_ScrollBarExtent, 0); - - default: - return TQCommonStyle::tqpixelMetric( m, widget ); - } -} - -//Helper to find the next sibling that's not hidden -static TQListViewItem* nextVisibleSibling(TQListViewItem* item) -{ - TQListViewItem* sibling = item; - do - { - sibling = sibling->nextSibling(); - } - while (sibling && !sibling->isVisible()); - - return sibling; -} - -void KStyle::tqdrawComplexControl( TQ_ComplexControl control, - TQPainter* p, - const TQWidget* widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - SCFlags controls, - SCFlags active, - const TQStyleOption &opt ) const -{ - switch(control) - { - // 3 BUTTON SCROLLBAR - // ------------------------------------------------------------------------ - case CC_ScrollBar: { - // Many thanks to Brad Hughes for contributing this code. - bool useThreeButtonScrollBar = (d->scrollbarType & ThreeButtonScrollBar); - - const TQScrollBar *sb = (const TQScrollBar*)widget; - bool maxedOut = (sb->minValue() == sb->maxValue()); - bool horizontal = (sb->orientation() == Qt::Horizontal); - SFlags sflags = ((horizontal ? Style_Horizontal : Style_Default) | - (maxedOut ? Style_Default : Style_Enabled)); - - TQRect addline, subline, subline2, addpage, subpage, slider, first, last; - subline = querySubControlMetrics(control, widget, SC_ScrollBarSubLine, opt); - addline = querySubControlMetrics(control, widget, SC_ScrollBarAddLine, opt); - subpage = querySubControlMetrics(control, widget, SC_ScrollBarSubPage, opt); - addpage = querySubControlMetrics(control, widget, SC_ScrollBarAddPage, opt); - slider = querySubControlMetrics(control, widget, SC_ScrollBarSlider, opt); - first = querySubControlMetrics(control, widget, SC_ScrollBarFirst, opt); - last = querySubControlMetrics(control, widget, SC_ScrollBarLast, opt); - subline2 = addline; - - if ( useThreeButtonScrollBar ) - if (horizontal) - subline2.moveBy(-addline.width(), 0); - else - subline2.moveBy(0, -addline.height()); - - // Draw the up/left button set - if ((controls & SC_ScrollBarSubLine) && subline.isValid()) { - tqdrawPrimitive(PE_ScrollBarSubLine, p, subline, cg, - sflags | (active == SC_ScrollBarSubLine ? - Style_Down : Style_Default)); - - if (useThreeButtonScrollBar && subline2.isValid()) - tqdrawPrimitive(PE_ScrollBarSubLine, p, subline2, cg, - sflags | (active == SC_ScrollBarSubLine ? - Style_Down : Style_Default)); - } - - if ((controls & SC_ScrollBarAddLine) && addline.isValid()) - tqdrawPrimitive(PE_ScrollBarAddLine, p, addline, cg, - sflags | ((active == SC_ScrollBarAddLine) ? - Style_Down : Style_Default)); - - if ((controls & SC_ScrollBarSubPage) && subpage.isValid()) - tqdrawPrimitive(PE_ScrollBarSubPage, p, subpage, cg, - sflags | ((active == SC_ScrollBarSubPage) ? - Style_Down : Style_Default)); - - if ((controls & SC_ScrollBarAddPage) && addpage.isValid()) - tqdrawPrimitive(PE_ScrollBarAddPage, p, addpage, cg, - sflags | ((active == SC_ScrollBarAddPage) ? - Style_Down : Style_Default)); - - if ((controls & SC_ScrollBarFirst) && first.isValid()) - tqdrawPrimitive(PE_ScrollBarFirst, p, first, cg, - sflags | ((active == SC_ScrollBarFirst) ? - Style_Down : Style_Default)); - - if ((controls & SC_ScrollBarLast) && last.isValid()) - tqdrawPrimitive(PE_ScrollBarLast, p, last, cg, - sflags | ((active == SC_ScrollBarLast) ? - Style_Down : Style_Default)); - - if ((controls & SC_ScrollBarSlider) && slider.isValid()) { - tqdrawPrimitive(PE_ScrollBarSlider, p, slider, cg, - sflags | ((active == SC_ScrollBarSlider) ? - Style_Down : Style_Default)); - // Draw focus rect - if (sb->hasFocus()) { - TQRect fr(slider.x() + 2, slider.y() + 2, - slider.width() - 5, slider.height() - 5); - tqdrawPrimitive(PE_FocusRect, p, fr, cg, Style_Default); - } - } - break; - } - - - // SLIDER - // ------------------------------------------------------------------- - case CC_Slider: { - const TQSlider* slider = (const TQSlider*)widget; - TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, opt); - TQRect handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, opt); - - // Double-buffer slider for no flicker - TQPixmap pix(widget->size()); - TQPainter p2; - p2.begin(&pix); - - if ( slider->parentWidget() && - slider->parentWidget()->backgroundPixmap() && - !slider->parentWidget()->backgroundPixmap()->isNull() ) { - TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap()); - p2.drawTiledPixmap(r, pixmap, slider->pos()); - } else - pix.fill(cg.background()); - - // Draw slider groove - if ((controls & SC_SliderGroove) && groove.isValid()) { - drawKStylePrimitive( KPE_SliderGroove, &p2, widget, groove, cg, flags, opt ); - - // Draw the focus rect around the groove - if (slider->hasFocus()) - tqdrawPrimitive(PE_FocusRect, &p2, groove, cg); - } - - // Draw the tickmarks - if (controls & SC_SliderTickmarks) - TQCommonStyle::tqdrawComplexControl(control, &p2, widget, - r, cg, flags, SC_SliderTickmarks, active, opt); - - // Draw the slider handle - if ((controls & SC_SliderHandle) && handle.isValid()) { - if (active == SC_SliderHandle) - flags |= Style_Active; - drawKStylePrimitive( KPE_SliderHandle, &p2, widget, handle, cg, flags, opt ); - } - - p2.end(); - bitBlt((TQWidget*)widget, r.x(), r.y(), &pix); - break; - } - - // LISTVIEW - // ------------------------------------------------------------------- - case CC_ListView: { - - /* - * Many thanks to TrollTech AS for donating CC_ListView from TQWindowsStyle. - * CC_ListView code is Copyright (C) 1998-2000 TrollTech AS. - */ - - // Paint the icon and text. - if ( controls & SC_ListView ) - TQCommonStyle::tqdrawComplexControl( control, p, widget, r, cg, flags, controls, active, opt ); - - // If we're have a branch or are expanded... - if ( controls & (SC_ListViewBranch | SC_ListViewExpand) ) - { - // If no list view item was supplied, break - if (opt.isDefault()) - break; - - TQListViewItem *item = opt.listViewItem(); - TQListViewItem *child = item->firstChild(); - - int y = r.y(); - int c; // dotline vertice count - int dotoffset = 0; - TQPointArray dotlines; - - if ( active == SC_All && controls == SC_ListViewExpand ) { - // We only need to draw a vertical line - c = 2; - dotlines.resize(2); - dotlines[0] = TQPoint( r.right(), r.top() ); - dotlines[1] = TQPoint( r.right(), r.bottom() ); - - } else { - - int linetop = 0, linebot = 0; - // each branch needs at most two lines, ie. four end points - dotoffset = (item->itemPos() + item->height() - y) % 2; - dotlines.resize( item->childCount() * 4 ); - c = 0; - - // skip the stuff above the exposed rectangle - while ( child && y + child->height() <= 0 ) - { - y += child->totalHeight(); - child = nextVisibleSibling(child); - } - - int bx = r.width() / 2; - - // paint stuff in the magical area - TQListView* v = item->listView(); - int lh = QMAX( p->fontMetrics().height() + 2 * v->itemMargin(), - TQApplication::globalStrut().height() ); - if ( lh % 2 > 0 ) - lh++; - - // Draw all the expand/close boxes... - TQRect boxrect; - TQStyle::StyleFlags boxflags; - while ( child && y < r.height() ) - { - linebot = y + lh/2; - if ( (child->isExpandable() || child->childCount()) && - (child->height() > 0) ) - { - // The primitive requires a rect. - boxrect = TQRect( bx-4, linebot-4, 9, 9 ); - boxflags = child->isOpen() ? TQStyle::Style_Off : TQStyle::Style_On; - - // KStyle extension: Draw the box and expand/collapse indicator - drawKStylePrimitive( KPE_ListViewExpander, p, NULL, boxrect, cg, boxflags, opt ); - - // dotlinery - p->setPen( cg.mid() ); - dotlines[c++] = TQPoint( bx, linetop ); - dotlines[c++] = TQPoint( bx, linebot - 5 ); - dotlines[c++] = TQPoint( bx + 5, linebot ); - dotlines[c++] = TQPoint( r.width(), linebot ); - linetop = linebot + 5; - } else { - // just dotlinery - dotlines[c++] = TQPoint( bx+1, linebot ); - dotlines[c++] = TQPoint( r.width(), linebot ); - } - - y += child->totalHeight(); - child = nextVisibleSibling(child); - } - - if ( child ) // there's a child to draw, so move linebot to edge of rectangle - linebot = r.height(); - - if ( linetop < linebot ) - { - dotlines[c++] = TQPoint( bx, linetop ); - dotlines[c++] = TQPoint( bx, linebot ); - } - } - - // Draw all the branches... - static int thickness = kPixelMetric( KPM_ListViewBranchThickness ); - int line; // index into dotlines - TQRect branchrect; - TQStyle::StyleFlags branchflags; - for( line = 0; line < c; line += 2 ) - { - // assumptions here: lines are horizontal or vertical. - // lines always start with the numerically lowest - // coordinate. - - // point ... relevant coordinate of current point - // end ..... same coordinate of the end of the current line - // other ... the other coordinate of the current point/line - if ( dotlines[line].y() == dotlines[line+1].y() ) - { - // Horizontal branch - int end = dotlines[line+1].x(); - int point = dotlines[line].x(); - int other = dotlines[line].y(); - - branchrect = TQRect( point, other-(thickness/2), end-point, thickness ); - branchflags = TQStyle::Style_Horizontal; - - // KStyle extension: Draw the horizontal branch - drawKStylePrimitive( KPE_ListViewBranch, p, NULL, branchrect, cg, branchflags, opt ); - - } else { - // Vertical branch - int end = dotlines[line+1].y(); - int point = dotlines[line].y(); - int other = dotlines[line].x(); - int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0; - - branchrect = TQRect( other-(thickness/2), point, thickness, end-point ); - if (!pixmapoffset) // ### Hackish - used to hint the offset - branchflags = TQStyle::Style_NoChange; - else - branchflags = TQStyle::Style_Default; - - // KStyle extension: Draw the vertical branch - drawKStylePrimitive( KPE_ListViewBranch, p, NULL, branchrect, cg, branchflags, opt ); - } - } - } - break; - } - - default: - TQCommonStyle::tqdrawComplexControl( control, p, widget, r, cg, - flags, controls, active, opt ); - break; - } -} - - -TQStyle::SubControl KStyle::querySubControl( TQ_ComplexControl control, - const TQWidget* widget, - const TQPoint &pos, - const TQStyleOption &opt ) const -{ - TQStyle::SubControl ret = TQCommonStyle::querySubControl(control, widget, pos, opt); - - if (d->scrollbarType == ThreeButtonScrollBar) { - // Enable third button - if (control == CC_ScrollBar && ret == SC_None) - ret = SC_ScrollBarSubLine; - } - return ret; -} - - -TQRect KStyle::querySubControlMetrics( TQ_ComplexControl control, - const TQWidget* widget, - SubControl sc, - const TQStyleOption &opt ) const -{ - TQRect ret; - - if (control == CC_ScrollBar) - { - bool threeButtonScrollBar = d->scrollbarType & ThreeButtonScrollBar; - bool platinumScrollBar = d->scrollbarType & PlatinumStyleScrollBar; - bool nextScrollBar = d->scrollbarType & NextStyleScrollBar; - - const TQScrollBar *sb = (const TQScrollBar*)widget; - bool horizontal = sb->orientation() == Qt::Horizontal; - int sliderstart = sb->sliderStart(); - int sbextent = tqpixelMetric(PM_ScrollBarExtent, widget); - int maxlen = (horizontal ? sb->width() : sb->height()) - - (sbextent * (threeButtonScrollBar ? 3 : 2)); - int sliderlen; - - // calculate slider length - if (sb->maxValue() != sb->minValue()) - { - uint range = sb->maxValue() - sb->minValue(); - sliderlen = (sb->pageStep() * maxlen) / (range + sb->pageStep()); - - int slidermin = tqpixelMetric( PM_ScrollBarSliderMin, widget ); - if ( sliderlen < slidermin || range > INT_MAX / 2 ) - sliderlen = slidermin; - if ( sliderlen > maxlen ) - sliderlen = maxlen; - } else - sliderlen = maxlen; - - // Subcontrols - switch (sc) - { - case SC_ScrollBarSubLine: { - // top/left button - if (platinumScrollBar) { - if (horizontal) - ret.setRect(sb->width() - 2 * sbextent, 0, sbextent, sbextent); - else - ret.setRect(0, sb->height() - 2 * sbextent, sbextent, sbextent); - } else - ret.setRect(0, 0, sbextent, sbextent); - break; - } - - case SC_ScrollBarAddLine: { - // bottom/right button - if (nextScrollBar) { - if (horizontal) - ret.setRect(sbextent, 0, sbextent, sbextent); - else - ret.setRect(0, sbextent, sbextent, sbextent); - } else { - if (horizontal) - ret.setRect(sb->width() - sbextent, 0, sbextent, sbextent); - else - ret.setRect(0, sb->height() - sbextent, sbextent, sbextent); - } - break; - } - - case SC_ScrollBarSubPage: { - // between top/left button and slider - if (platinumScrollBar) { - if (horizontal) - ret.setRect(0, 0, sliderstart, sbextent); - else - ret.setRect(0, 0, sbextent, sliderstart); - } else if (nextScrollBar) { - if (horizontal) - ret.setRect(sbextent*2, 0, sliderstart-2*sbextent, sbextent); - else - ret.setRect(0, sbextent*2, sbextent, sliderstart-2*sbextent); - } else { - if (horizontal) - ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent); - else - ret.setRect(0, sbextent, sbextent, sliderstart - sbextent); - } - break; - } - - case SC_ScrollBarAddPage: { - // between bottom/right button and slider - int fudge; - - if (platinumScrollBar) - fudge = 0; - else if (nextScrollBar) - fudge = 2*sbextent; - else - fudge = sbextent; - - if (horizontal) - ret.setRect(sliderstart + sliderlen, 0, - maxlen - sliderstart - sliderlen + fudge, sbextent); - else - ret.setRect(0, sliderstart + sliderlen, sbextent, - maxlen - sliderstart - sliderlen + fudge); - break; - } - - case SC_ScrollBarGroove: { - int multi = threeButtonScrollBar ? 3 : 2; - int fudge; - - if (platinumScrollBar) - fudge = 0; - else if (nextScrollBar) - fudge = 2*sbextent; - else - fudge = sbextent; - - if (horizontal) - ret.setRect(fudge, 0, sb->width() - sbextent * multi, sb->height()); - else - ret.setRect(0, fudge, sb->width(), sb->height() - sbextent * multi); - break; - } - - case SC_ScrollBarSlider: { - if (horizontal) - ret.setRect(sliderstart, 0, sliderlen, sbextent); - else - ret.setRect(0, sliderstart, sbextent, sliderlen); - break; - } - - default: - ret = TQCommonStyle::querySubControlMetrics(control, widget, sc, opt); - break; - } - } else - ret = TQCommonStyle::querySubControlMetrics(control, widget, sc, opt); - - return ret; -} - -static const char * const kstyle_close_xpm[] = { -"12 12 2 1", -"# c #000000", -". c None", -"............", -"............", -"..##....##..", -"...##..##...", -"....####....", -".....##.....", -"....####....", -"...##..##...", -"..##....##..", -"............", -"............", -"............"}; - -static const char * const kstyle_maximize_xpm[]={ -"12 12 2 1", -"# c #000000", -". c None", -"............", -"............", -".##########.", -".##########.", -".#........#.", -".#........#.", -".#........#.", -".#........#.", -".#........#.", -".#........#.", -".##########.", -"............"}; - - -static const char * const kstyle_minimize_xpm[] = { -"12 12 2 1", -"# c #000000", -". c None", -"............", -"............", -"............", -"............", -"............", -"............", -"............", -"...######...", -"...######...", -"............", -"............", -"............"}; - -static const char * const kstyle_normalizeup_xpm[] = { -"12 12 2 1", -"# c #000000", -". c None", -"............", -"...#######..", -"...#######..", -"...#.....#..", -".#######.#..", -".#######.#..", -".#.....#.#..", -".#.....###..", -".#.....#....", -".#.....#....", -".#######....", -"............"}; - - -static const char * const kstyle_shade_xpm[] = { -"12 12 2 1", -"# c #000000", -". c None", -"............", -"............", -"............", -"............", -"............", -".....#......", -"....###.....", -"...#####....", -"..#######...", -"............", -"............", -"............"}; - -static const char * const kstyle_unshade_xpm[] = { -"12 12 2 1", -"# c #000000", -". c None", -"............", -"............", -"............", -"............", -"..#######...", -"...#####....", -"....###.....", -".....#......", -"............", -"............", -"............", -"............"}; - -static const char * const dock_window_close_xpm[] = { -"8 8 2 1", -"# c #000000", -". c None", -"##....##", -".##..##.", -"..####..", -"...##...", -"..####..", -".##..##.", -"##....##", -"........"}; - -// Message box icons, from page 210 of the Windows style guide. - -// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape -// palette. The "question mark" icon, which Microsoft recommends not -// using but a lot of people still use, is left out. - -/* XPM */ -static const char * const information_xpm[]={ -"32 32 5 1", -". c None", -"c c #000000", -"* c #999999", -"a c #ffffff", -"b c #0000ff", -"...........********.............", -"........***aaaaaaaa***..........", -"......**aaaaaaaaaaaaaa**........", -".....*aaaaaaaaaaaaaaaaaa*.......", -"....*aaaaaaaabbbbaaaaaaaac......", -"...*aaaaaaaabbbbbbaaaaaaaac.....", -"..*aaaaaaaaabbbbbbaaaaaaaaac....", -".*aaaaaaaaaaabbbbaaaaaaaaaaac...", -".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..", -"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.", -"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.", -"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", -"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", -"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", -"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", -"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**", -".*aaaaaaaaaaabbbbbaaaaaaaaaac***", -".*aaaaaaaaaaabbbbbaaaaaaaaaac***", -"..*aaaaaaaaaabbbbbaaaaaaaaac***.", -"...caaaaaaabbbbbbbbbaaaaaac****.", -"....caaaaaaaaaaaaaaaaaaaac****..", -".....caaaaaaaaaaaaaaaaaac****...", -"......ccaaaaaaaaaaaaaacc****....", -".......*cccaaaaaaaaccc*****.....", -"........***cccaaaac*******......", -"..........****caaac*****........", -".............*caaac**...........", -"...............caac**...........", -"................cac**...........", -".................cc**...........", -"..................***...........", -"...................**..........."}; -/* XPM */ -static const char* const warning_xpm[]={ -"32 32 4 1", -". c None", -"a c #ffff00", -"* c #000000", -"b c #999999", -".............***................", -"............*aaa*...............", -"...........*aaaaa*b.............", -"...........*aaaaa*bb............", -"..........*aaaaaaa*bb...........", -"..........*aaaaaaa*bb...........", -".........*aaaaaaaaa*bb..........", -".........*aaaaaaaaa*bb..........", -"........*aaaaaaaaaaa*bb.........", -"........*aaaa***aaaa*bb.........", -".......*aaaa*****aaaa*bb........", -".......*aaaa*****aaaa*bb........", -"......*aaaaa*****aaaaa*bb.......", -"......*aaaaa*****aaaaa*bb.......", -".....*aaaaaa*****aaaaaa*bb......", -".....*aaaaaa*****aaaaaa*bb......", -"....*aaaaaaaa***aaaaaaaa*bb.....", -"....*aaaaaaaa***aaaaaaaa*bb.....", -"...*aaaaaaaaa***aaaaaaaaa*bb....", -"...*aaaaaaaaaa*aaaaaaaaaa*bb....", -"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...", -"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...", -".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..", -".*aaaaaaaaaaa****aaaaaaaaaa*bb..", -"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.", -"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.", -"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb", -"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb", -".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb", -"..*************************bbbbb", -"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.", -".....bbbbbbbbbbbbbbbbbbbbbbbbb.."}; -/* XPM */ -static const char* const critical_xpm[]={ -"32 32 4 1", -". c None", -"a c #999999", -"* c #ff0000", -"b c #ffffff", -"...........********.............", -".........************...........", -".......****************.........", -"......******************........", -".....********************a......", -"....**********************a.....", -"...************************a....", -"..*******b**********b*******a...", -"..******bbb********bbb******a...", -".******bbbbb******bbbbb******a..", -".*******bbbbb****bbbbb*******a..", -"*********bbbbb**bbbbb*********a.", -"**********bbbbbbbbbb**********a.", -"***********bbbbbbbb***********aa", -"************bbbbbb************aa", -"************bbbbbb************aa", -"***********bbbbbbbb***********aa", -"**********bbbbbbbbbb**********aa", -"*********bbbbb**bbbbb*********aa", -".*******bbbbb****bbbbb*******aa.", -".******bbbbb******bbbbb******aa.", -"..******bbb********bbb******aaa.", -"..*******b**********b*******aa..", -"...************************aaa..", -"....**********************aaa...", -"....a********************aaa....", -".....a******************aaa.....", -"......a****************aaa......", -".......aa************aaaa.......", -".........aa********aaaaa........", -"...........aaaaaaaaaaa..........", -".............aaaaaaa............"}; - -TQPixmap KStyle::stylePixmap( StylePixmap stylepixmap, - const TQWidget* widget, - const TQStyleOption& opt) const -{ - switch (stylepixmap) { - case SP_TitleBarShadeButton: - return TQPixmap(const_cast<const char**>(kstyle_shade_xpm)); - case SP_TitleBarUnshadeButton: - return TQPixmap(const_cast<const char**>(kstyle_unshade_xpm)); - case SP_TitleBarNormalButton: - return TQPixmap(const_cast<const char**>(kstyle_normalizeup_xpm)); - case SP_TitleBarMinButton: - return TQPixmap(const_cast<const char**>(kstyle_minimize_xpm)); - case SP_TitleBarMaxButton: - return TQPixmap(const_cast<const char**>(kstyle_maximize_xpm)); - case SP_TitleBarCloseButton: - return TQPixmap(const_cast<const char**>(kstyle_close_xpm)); - case SP_DockWindowCloseButton: - return TQPixmap(const_cast<const char**>(dock_window_close_xpm )); - case SP_MessageBoxInformation: - return TQPixmap(const_cast<const char**>(information_xpm)); - case SP_MessageBoxWarning: - return TQPixmap(const_cast<const char**>(warning_xpm)); - case SP_MessageBoxCritical: - return TQPixmap(const_cast<const char**>(critical_xpm)); - default: - break; - } - return TQCommonStyle::stylePixmap(stylepixmap, widget, opt); -} - - -int KStyle::tqstyleHint( TQ_StyleHint sh, const TQWidget* w, - const TQStyleOption &opt, TQStyleHintReturn* shr) const -{ - switch (sh) - { - case SH_EtchDisabledText: - return d->etchDisabledText ? 1 : 0; - - case SH_PopupMenu_Scrollable: - return d->scrollablePopupmenus ? 1 : 0; - - case SH_MenuBar_AltKeyNavigation: - return d->menuAltKeyNavigation ? 1 : 0; - - case SH_PopupMenu_SubMenuPopupDelay: - if ( tqstyleHint( SH_PopupMenu_SloppySubMenus, w ) ) - return QMIN( 100, d->popupMenuDelay ); - else - return d->popupMenuDelay; - - case SH_PopupMenu_SloppySubMenus: - return d->sloppySubMenus; - - case SH_ItemView_ChangeHighlightOnFocus: - case SH_Slider_SloppyKeyEvents: - case SH_MainWindow_SpaceBelowMenuBar: - case SH_PopupMenu_AllowActiveAndDisabled: - return 0; - - case SH_Slider_SnapToValue: - case SH_PrintDialog_RightAlignButtons: - case SH_FontDialog_SelectAssociatedText: - case SH_MenuBar_MouseTracking: - case SH_PopupMenu_MouseTracking: - case SH_ComboBox_ListMouseTracking: - case SH_ScrollBar_MiddleClickAbsolutePosition: - return 1; - case SH_LineEdit_PasswordCharacter: - { - if (w) { - const TQFontMetrics &fm = w->fontMetrics(); - if (fm.inFont(TQChar(0x25CF))) { - return 0x25CF; - } else if (fm.inFont(TQChar(0x2022))) { - return 0x2022; - } - } - return '*'; - } - - default: - return TQCommonStyle::tqstyleHint(sh, w, opt, shr); - } -} - - -bool KStyle::eventFilter( TQObject* object, TQEvent* event ) -{ - if ( d->useFilledFrameWorkaround ) - { - // Make the QMenuBar/TQToolBar paintEvent() cover a larger area to - // ensure that the filled frame contents are properly painted. - // We essentially modify the paintEvent's rect to include the - // panel border, which also paints the widget's interior. - // This is nasty, but I see no other way to properly tqrepaint - // filled frames in all QMenuBars and QToolBars. - // -- Karol. - TQFrame *frame = 0; - if ( event->type() == TQEvent::Paint - && (frame = ::tqqt_cast<TQFrame*>(object)) ) - { - if (frame->frameShape() != TQFrame::ToolBarPanel && frame->frameShape() != TQFrame::MenuBarPanel) - return false; - - bool horizontal = true; - TQPaintEvent* pe = (TQPaintEvent*)event; - TQToolBar *toolbar = ::tqqt_cast< TQToolBar *>( frame ); - TQRect r = pe->rect(); - - if (toolbar && toolbar->orientation() == Qt::Vertical) - horizontal = false; - - if (horizontal) { - if ( r.height() == frame->height() ) - return false; // Let TQFrame handle the painting now. - - // Else, send a new paint event with an updated paint rect. - TQPaintEvent dummyPE( TQRect( r.x(), 0, r.width(), frame->height()) ); - TQApplication::sendEvent( frame, &dummyPE ); - } - else { // Vertical - if ( r.width() == frame->width() ) - return false; - - TQPaintEvent dummyPE( TQRect( 0, r.y(), frame->width(), r.height()) ); - TQApplication::sendEvent( frame, &dummyPE ); - } - - // Discard this event as we sent a new paintEvent. - return true; - } - } - - return false; -} - - -// ----------------------------------------------------------------------------- -// I N T E R N A L - KStyle menu transparency handler -// ----------------------------------------------------------------------------- - -TransparencyHandler::TransparencyHandler( KStyle* style, - TransparencyEngine tEngine, float menuOpacity, bool useDropShadow ) - : TQObject() -{ - te = tEngine; - kstyle = style; - opacity = menuOpacity; - dropShadow = useDropShadow; - pix.setOptimization(TQPixmap::BestOptim); -} - -TransparencyHandler::~TransparencyHandler() -{ -} - -bool TransparencyHandler::haveX11RGBASupport() -{ - // Simple way to determine if we have ARGB support - if (TQPaintDevice::x11AppDepth() == 32) { - return true; - } - else { - return false; - } -} - -#define REAL_ALPHA_STRENGTH 255.0 - -// This is meant to be ugly but fast. -void TransparencyHandler::rightShadow(TQImage& dst) -{ - bool have_composite = haveX11RGBASupport(); - - if (dst.depth() != 32) - dst = dst.convertDepth(32); - - // blend top-right corner. - int pixels = dst.width() * dst.height(); -#ifdef WORDS_BIGENDIAN - register unsigned char* data = dst.bits() + 1; // Skip alpha -#else - register unsigned char* data = dst.bits(); // Skip alpha -#endif - for(register int i = 0; i < 16; i++) { - if (have_composite) { - data++; - data++; - data++; - *data = (unsigned char)(REAL_ALPHA_STRENGTH*(1.0-top_right_corner[i])); data++; - } - else { - *data = (unsigned char)((*data)*top_right_corner[i]); data++; - *data = (unsigned char)((*data)*top_right_corner[i]); data++; - *data = (unsigned char)((*data)*top_right_corner[i]); data++; - data++; // skip alpha - } - } - - pixels -= 32; // tint right strip without rounded edges. - register int c = 0; - for(register int i = 0; i < pixels; i++) { - if (have_composite) { - data++; - data++; - data++;; - *data = (unsigned char)(REAL_ALPHA_STRENGTH*(1.0-shadow_strip[c])); data++; - } - else { - *data = (unsigned char)((*data)*shadow_strip[c]); data++; - *data = (unsigned char)((*data)*shadow_strip[c]); data++; - *data = (unsigned char)((*data)*shadow_strip[c]); data++; - data++; // skip alpha - } - ++c; - c %= 4; - } - - // tint bottom edge - for(register int i = 0; i < 16; i++) { - if (have_composite) { - data++; - data++; - data++; - *data = (unsigned char)(REAL_ALPHA_STRENGTH*(1.0-bottom_right_corner[i])); data++; - } - else { - *data = (unsigned char)((*data)*bottom_right_corner[i]); data++; - *data = (unsigned char)((*data)*bottom_right_corner[i]); data++; - *data = (unsigned char)((*data)*bottom_right_corner[i]); data++; - data++; // skip alpha - } - } -} - -void TransparencyHandler::bottomShadow(TQImage& dst) -{ - bool have_composite = haveX11RGBASupport(); - - if (dst.depth() != 32) - dst = dst.convertDepth(32); - - int line = 0; - int width = dst.width() - 4; - double strip_data = shadow_strip[0]; - double* corner = const_cast<double*>(bottom_left_corner); - -#ifdef WORDS_BIGENDIAN - register unsigned char* data = dst.bits() + 1; // Skip alpha -#else - register unsigned char* data = dst.bits(); // Skip alpha -#endif - - for(int y = 0; y < 4; y++) - { - // Bottom-left Corner - for(register int x = 0; x < 4; x++) { - if (have_composite) { - data++; - data++; - data++; - *data = (unsigned char)(REAL_ALPHA_STRENGTH*(1.0-(*corner))); data++; - } - else { - *data = (unsigned char)((*data)*(*corner)); data++; - *data = (unsigned char)((*data)*(*corner)); data++; - *data = (unsigned char)((*data)*(*corner)); data++; - data++; // skip alpha - } - corner++; - } - - // Scanline - for(register int x = 0; x < width; x++) { - if (have_composite) { - data++; - data++; - data++; - *data = (unsigned char)(REAL_ALPHA_STRENGTH*(1.0-strip_data)); data++; - } - else { - *data = (unsigned char)((*data)*strip_data); data++; - *data = (unsigned char)((*data)*strip_data); data++; - *data = (unsigned char)((*data)*strip_data); data++; - data++; // skip alpha - } - } - - strip_data = shadow_strip[++line]; - } -} - -TQImage TransparencyHandler::handleRealAlpha(TQImage img) { - TQImage clearImage = img.convertDepth(32); - clearImage.setAlphaBuffer(true); - - int w = clearImage.width(); - int h = clearImage.height(); - - for (int y = 0; y < h; ++y) { - TQRgb *ls = (TQRgb *)clearImage.scanLine( y ); - for (int x = 0; x < w; ++x) { - TQRgb l = ls[x]; - ls[x] = tqRgba( 0, 0, 0, 0 ); - } - } - - return clearImage; -} - -// Create a shadow of thickness 4. -void TransparencyHandler::createShadowWindows(const TQWidget* p) -{ -#ifdef Q_WS_X11 - int x2 = p->x()+p->width(); - int y2 = p->y()+p->height(); - TQRect shadow1(x2, p->y() + 4, 4, p->height()); - TQRect shadow2(p->x() + 4, y2, p->width() - 4, 4); - - bool have_composite = haveX11RGBASupport(); - - // Create a fake drop-down shadow effect via blended Xwindows - ShadowElements se; - se.w1 = new TQWidget(0, 0, (WFlags)(WStyle_Customize | WType_Popup | WX11BypassWM) ); - se.w2 = new TQWidget(0, 0, (WFlags)(WStyle_Customize | WType_Popup | WX11BypassWM) ); - se.w1->setGeometry(shadow1); - se.w2->setGeometry(shadow2); - XSelectInput(qt_xdisplay(), se.w1->winId(), StructureNotifyMask ); - XSelectInput(qt_xdisplay(), se.w2->winId(), StructureNotifyMask ); - - // Insert a new ShadowMap entry - shadowMap()[p] = se; - - // Some hocus-pocus here to create the drop-shadow. - TQPixmap pix_shadow1; - TQPixmap pix_shadow2; - if (have_composite) { - pix_shadow1 = TQPixmap(shadow1.width(), shadow1.height()); - pix_shadow2 = TQPixmap(shadow2.width(), shadow2.height()); - } - else { - pix_shadow1 = TQPixmap::grabWindow(qt_xrootwin(), - shadow1.x(), shadow1.y(), shadow1.width(), shadow1.height()); - pix_shadow2 = TQPixmap::grabWindow(qt_xrootwin(), - shadow2.x(), shadow2.y(), shadow2.width(), shadow2.height()); - } - - TQImage img; - img = pix_shadow1.convertToImage(); - if (have_composite) img = handleRealAlpha(img); - rightShadow(img); - pix_shadow1.convertFromImage(img); - img = pix_shadow2.convertToImage(); - if (have_composite) img = handleRealAlpha(img); - bottomShadow(img); - pix_shadow2.convertFromImage(img); - - // Set the background pixmaps - se.w1->setErasePixmap(pix_shadow1); - se.w2->setErasePixmap(pix_shadow2); - - // Show the 'shadow' just before showing the popup menu window - // Don't use TQWidget::show() so we don't confuse QEffects, thus causing broken focus. - XMapWindow(qt_xdisplay(), se.w1->winId()); - XMapWindow(qt_xdisplay(), se.w2->winId()); -#else - Q_UNUSED( p ) -#endif -} - -void TransparencyHandler::removeShadowWindows(const TQWidget* p) -{ -#ifdef Q_WS_X11 - ShadowMap::iterator it = shadowMap().find(p); - if (it != shadowMap().end()) - { - ShadowElements se = it.data(); - XUnmapWindow(qt_xdisplay(), se.w1->winId()); // hide - XUnmapWindow(qt_xdisplay(), se.w2->winId()); - XFlush(qt_xdisplay()); // try to hide faster - delete se.w1; - delete se.w2; - shadowMap().erase(it); - } -#else - Q_UNUSED( p ) -#endif -} - -bool TransparencyHandler::eventFilter( TQObject* object, TQEvent* event ) -{ -#if !defined Q_WS_MAC && !defined Q_WS_WIN - // Transparency idea was borrowed from KDE2's "MegaGradient" Style, - // Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> - - // Added 'fake' menu shadows <04-Jul-2002> -- Karol - TQWidget* p = (TQWidget*)object; - TQEvent::Type et = event->type(); - - if (et == TQEvent::Show) - { - // Handle translucency - if (te != Disabled) - { - pix = TQPixmap::grabWindow(qt_xrootwin(), - p->x(), p->y(), p->width(), p->height()); - - switch (te) { -#ifdef HAVE_XRENDER - case XRender: - if (qt_use_xrender) { - XRenderBlendToPixmap(p); - break; - } - // Fall through intended -#else - case XRender: -#endif - case SoftwareBlend: - blendToPixmap(p->tqcolorGroup(), p); - break; - - case SoftwareTint: - default: - blendToColor(p->tqcolorGroup().button()); - }; - - p->setErasePixmap(pix); - } - - // Handle drop shadow - // * FIXME : !shadowMap().contains(p) is a workaround for leftover - // * shadows after duplicate show events. - // * TODO : determine real cause for duplicate events - // * till 20021005 - if ((dropShadow || useDropShadow(p)) - && p->width() > 16 && p->height() > 16 && !shadowMap().contains( p )) - createShadowWindows(p); - } - else if (et == TQEvent::Resize && p->isShown() && p->isTopLevel()) - { - // Handle drop shadow - if (dropShadow || useDropShadow(p)) - { - removeShadowWindows(p); - createShadowWindows(p); - } - } - else if (et == TQEvent::Hide) - { - // Handle drop shadow - if (dropShadow || useDropShadow(p)) - removeShadowWindows(p); - - // Handle translucency - if (te != Disabled) - p->setErasePixmap(TQPixmap()); - } - -#endif - return false; -} - - -// Blends a TQImage to a predefined color, with a given opacity. -void TransparencyHandler::blendToColor(const TQColor &col) -{ - if (opacity < 0.0 || opacity > 1.0) - return; - - TQImage img = pix.convertToImage(); - KImageEffect::blend(col, img, opacity); - pix.convertFromImage(img); -} - - -void TransparencyHandler::blendToPixmap(const TQColorGroup &cg, const TQWidget* p) -{ - if (opacity < 0.0 || opacity > 1.0) - return; - - KPixmap blendPix; - blendPix.resize( pix.width(), pix.height() ); - - if (blendPix.width() != pix.width() || - blendPix.height() != pix.height()) - return; - - // Allow styles to define the blend pixmap - allows for some interesting effects. - if (::tqqt_cast<TQPopupMenu*>(p)) - kstyle->renderMenuBlendPixmap( blendPix, cg, ::tqqt_cast<TQPopupMenu*>(p) ); - else - blendPix.fill(cg.button()); // Just tint as the default behavior - - TQImage blendImg = blendPix.convertToImage(); - TQImage backImg = pix.convertToImage(); - KImageEffect::blend(blendImg, backImg, opacity); - pix.convertFromImage(backImg); -} - - -#ifdef HAVE_XRENDER -// Here we go, use XRender in all its glory. -// NOTE: This is actually a bit slower than the above routines -// on non-accelerated displays. -- Karol. -void TransparencyHandler::XRenderBlendToPixmap(const TQWidget* p) -{ - KPixmap renderPix; - renderPix.resize( pix.width(), pix.height() ); - - // Allow styles to define the blend pixmap - allows for some interesting effects. - if (::tqqt_cast<TQPopupMenu*>(p)) - kstyle->renderMenuBlendPixmap( renderPix, p->tqcolorGroup(), - ::tqqt_cast<TQPopupMenu*>(p) ); - else - renderPix.fill(p->tqcolorGroup().button()); // Just tint as the default behavior - - Display* dpy = qt_xdisplay(); - Pixmap alphaPixmap; - Picture alphaPicture; - XRenderPictFormat Rpf; - XRenderPictureAttributes Rpa; - XRenderColor clr; - clr.alpha = ((unsigned short)(255*opacity) << 8); - - Rpf.type = PictTypeDirect; - Rpf.depth = 8; - Rpf.direct.alphaMask = 0xff; - Rpa.repeat = True; // Tile - - XRenderPictFormat* xformat = XRenderFindFormat(dpy, - PictFormatType | PictFormatDepth | PictFormatAlphaMask, &Rpf, 0); - - alphaPixmap = XCreatePixmap(dpy, p->handle(), 1, 1, 8); - alphaPicture = XRenderCreatePicture(dpy, alphaPixmap, xformat, CPRepeat, &Rpa); - - XRenderFillRectangle(dpy, PictOpSrc, alphaPicture, &clr, 0, 0, 1, 1); - - XRenderComposite(dpy, PictOpOver, - renderPix.x11RenderHandle(), alphaPicture, pix.x11RenderHandle(), // src, mask, dst - 0, 0, // srcx, srcy - 0, 0, // maskx, masky - 0, 0, // dstx, dsty - pix.width(), pix.height()); - - XRenderFreePicture(dpy, alphaPicture); - XFreePixmap(dpy, alphaPixmap); -} -#endif - -void KStyle::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -// HACK for gtk-qt-engine - -KDE_EXPORT extern "C" -void kde_kstyle_set_scrollbar_type_windows( void* style ) -{ - ((KStyle*)style)->setScrollBarType( KStyle::WindowsStyleScrollBar ); -} - -// vim: set noet ts=4 sw=4: -// kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off; - -#include "kstyle.moc" diff --git a/kdefx/kstyle.h b/kdefx/kstyle.h deleted file mode 100644 index 42bd1a231..000000000 --- a/kdefx/kstyle.h +++ /dev/null @@ -1,356 +0,0 @@ -/* - * $Id$ - * - * KStyle - * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> - * - * TQWindowsStyle CC_ListView and style images were kindly donated by TrollTech, - * Copyright (C) 1998-2000 TrollTech AS. - * - * Many thanks to Bradley T. Hughes for the 3 button scrollbar code. - * - * 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 __KSTYLE_H -#define __KSTYLE_H - -// W A R N I N G -// ------------- -// This API is still subject to change. -// I will remove this warning when I feel the API is sufficiently flexible. - -#include <tqcommonstyle.h> - -#include <kdelibs_export.h> - -class KPixmap; - -struct KStylePrivate; -/** - * Simplifies and extends the TQStyle API to make style coding easier. - * - * The KStyle class provides a simple internal menu transparency engine - * which attempts to use XRender for accelerated blending where requested, - * or falls back to fast internal software tinting/blending routines. - * It also simplifies more complex portions of the TQStyle API, such as - * the PopupMenuItems, ScrollBars and Sliders by providing extra "primitive - * elements" which are simple to implement by the style writer. - * - * @see TQStyle::QStyle - * @see TQCommonStyle::QCommonStyle - * @author Karol Szwed (gallium@kde.org) - * @version $Id$ - */ -class KDEFX_EXPORT KStyle: public TQCommonStyle -{ - Q_OBJECT - TQ_OBJECT - - public: - - /** - * KStyle Flags: - * - * @li Default - Default style setting, where menu transparency - * and the FilledFrameWorkaround are disabled. - * - * @li AllowMenuTransparency - Enable this flag to use KStyle's - * internal menu transparency engine. - * - * @li FilledFrameWorkaround - Enable this flag to facilitate - * proper repaints of QMenuBars and QToolBars when the style chooses - * to paint the interior of a TQFrame. The style primitives in question - * are PE_PanelMenuBar and PE_PanelDockWindow. The HighColor style uses - * this workaround to enable painting of gradients in menubars and - * toolbars. - */ - typedef uint KStyleFlags; - enum KStyleOption { - Default = 0x00000000, //!< All options disabled - AllowMenuTransparency = 0x00000001, //!< Internal transparency enabled - FilledFrameWorkaround = 0x00000002 //!< Filled frames enabled - }; - - /** - * KStyle ScrollBarType: - * - * Allows the style writer to easily select what type of scrollbar - * should be used without having to duplicate large amounts of source - * code by implementing the complex control CC_ScrollBar. - * - * @li WindowsStyleScrollBar - Two button scrollbar with the previous - * button at the top/left, and the next button at the bottom/right. - * - * @li PlatinumStyleScrollBar - Two button scrollbar with both the - * previous and next buttons at the bottom/right. - * - * @li ThreeButtonScrollBar - %KDE style three button scrollbar with - * two previous buttons, and one next button. The next button is always - * at the bottom/right, whilst the two previous buttons are on either - * end of the scrollbar. - * - * @li NextStyleScrollBar - Similar to the PlatinumStyle scroll bar, but - * with the buttons grouped on the opposite end of the scrollbar. - * - * @see KStyle::KStyle() - */ - enum KStyleScrollBarType { - WindowsStyleScrollBar = 0x00000000, //!< two button, windows style - PlatinumStyleScrollBar = 0x00000001, //!< two button, platinum style - ThreeButtonScrollBar = 0x00000002, //!< three buttons, %KDE style - NextStyleScrollBar = 0x00000004 //!< two button, NeXT style - }; - - /** - * Constructs a KStyle object. - * - * Select the appropriate KStyle flags and scrollbar type - * for your style. The user's style preferences selected in KControl - * are read by using TQSettings and are automatically applied to the style. - * As a fallback, KStyle paints progressbars and tabbars. It inherits from - * TQCommonStyle for speed, so don't expect much to be implemented. - * - * It is advisable to use a currently implemented style such as the HighColor - * style as a foundation for any new KStyle, so the limited number of - * drawing fallbacks should not prove problematic. - * - * @param flags the style to be applied - * @param sbtype the scroll bar type - * @see KStyle::KStyleFlags - * @see KStyle::KStyleScrollBarType - * @author Karol Szwed (gallium@kde.org) - */ - KStyle( KStyleFlags flags = KStyle::Default, - KStyleScrollBarType sbtype = KStyle::WindowsStyleScrollBar ); - - /** - * Destructs the KStyle object. - */ - ~KStyle(); - - /** - * Returns the default widget style depending on color depth. - */ - static TQString defaultStyle(); - - /** - * Modifies the scrollbar type used by the style. - * - * This function is only provided for convenience. It allows - * you to make a late decision about what scrollbar type to use for the - * style after performing some processing in your style's constructor. - * In most situations however, setting the scrollbar type via the KStyle - * constructor should suffice. - * @param sbtype the scroll bar type - * @see KStyle::KStyleScrollBarType - */ - void setScrollBarType(KStyleScrollBarType sbtype); - - /** - * Returns the KStyle flags used to initialize the style. - * - * This is used solely for the kcmstyle module, and hence is internal. - */ - KStyleFlags styleFlags() const; - - // --------------------------------------------------------------------------- - - /** - * This virtual function defines the pixmap used to blend between the popup - * menu and the background to create different menu transparency effects. - * For example, you can fill the pixmap "pix" with a gradient based on the - * popup's tqcolorGroup, a texture, or some other fancy painting routine. - * KStyle will then internally blend this pixmap with a snapshot of the - * background behind the popupMenu to create the illusion of transparency. - * - * This virtual is never called if XRender/Software blending is disabled by - * the user in KDE's style control module. - */ - virtual void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup& cg, - const TQPopupMenu* popup ) const; - - /** - * KStyle Primitive Elements: - * - * The KStyle class extends the Qt's Style API by providing certain - * simplifications for parts of TQStyle. To do this, the KStylePrimitive - * elements were defined, which are very similar to Qt's PrimitiveElement. - * - * The first three Handle primitives simplify and extend PE_DockWindowHandle, - * so do not reimplement PE_DockWindowHandle if you want the KStyle handle - * simplifications to be operable. Similarly do not reimplement CC_Slider, - * SC_SliderGroove and SC_SliderHandle when using the KStyle slider - * primitives. KStyle automatically double-buffers slider painting - * when they are drawn via these KStyle primitives to avoid flicker. - * - * @li KPE_DockWindowHandle - This primitive is already implemented in KStyle, - * and paints a bevelled rect with the DockWindow caption text. Re-implement - * this primitive to perform other more fancy effects when drawing the dock window - * handle. - * - * @li KPE_ToolBarHandle - This primitive must be reimplemented. It currently - * only paints a filled rectangle as default behavior. This primitive is used - * to render TQToolBar handles. - * - * @li KPE_GeneralHandle - This primitive must be reimplemented. It is used - * to render general handles that are not part of a TQToolBar or TQDockWindow, such - * as the applet handles used in Kicker. The default implementation paints a filled - * rect of arbitrary color. - * - * @li KPE_SliderGroove - This primitive must be reimplemented. It is used to - * paint the slider groove. The default implementation paints a filled rect of - * arbitrary color. - * - * @li KPE_SliderHandle - This primitive must be reimplemented. It is used to - * paint the slider handle. The default implementation paints a filled rect of - * arbitrary color. - * - * @li KPE_ListViewExpander - This primitive is already implemented in KStyle. It - * is used to draw the Expand/Collapse element in QListViews. To indicate the - * expanded state, the style flags are set to Style_Off, while Style_On implies collapsed. - * - * @li KPE_ListViewBranch - This primitive is already implemented in KStyle. It is - * used to draw the ListView branches where necessary. - */ - enum KStylePrimitive { - KPE_DockWindowHandle, - KPE_ToolBarHandle, - KPE_GeneralHandle, - - KPE_SliderGroove, - KPE_SliderHandle, - - KPE_ListViewExpander, - KPE_ListViewBranch - }; - - /** - * This function is identical to Qt's TQStyle::tqdrawPrimitive(), except that - * it adds one further parameter, 'widget', that can be used to determine - * the widget state of the KStylePrimitive in question. - * - * @see KStyle::KStylePrimitive - * @see TQStyle::tqdrawPrimitive - * @see TQStyle::tqdrawComplexControl - */ - virtual void drawKStylePrimitive( KStylePrimitive kpe, - TQPainter* p, - const TQWidget* widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - - - enum KStylePixelMetric { - KPM_MenuItemSeparatorHeight = 0x00000001, - KPM_MenuItemHMargin = 0x00000002, - KPM_MenuItemVMargin = 0x00000004, - KPM_MenuItemHFrame = 0x00000008, - KPM_MenuItemVFrame = 0x00000010, - KPM_MenuItemCheckMarkHMargin = 0x00000020, - KPM_MenuItemArrowHMargin = 0x00000040, - KPM_MenuItemTabSpacing = 0x00000080, - KPM_ListViewBranchThickness = 0x00000100 - }; - - int kPixelMetric( KStylePixelMetric kpm, const TQWidget* widget = 0 ) const; - - // --------------------------------------------------------------------------- - - void polish( TQWidget* widget ); - void unPolish( TQWidget* widget ); - void polishPopupMenu( TQPopupMenu* ); - - void tqdrawPrimitive( TQ_PrimitiveElement pe, - TQPainter* p, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - -// #ifdef USE_QT4 // kdebindings / smoke needs this function declaration available at all times. Furthermore I don't think it would hurt to have the declaration available at all times...so leave these commented out for now - -// void tqdrawPrimitive( TQ_ControlElement pe, -// TQPainter* p, -// const TQRect &r, -// const TQColorGroup &cg, -// SFlags flags = Style_Default, -// const TQStyleOption& = TQStyleOption::SO_Default ) const; - -// #endif // USE_QT4 - - void tqdrawControl( TQ_ControlElement element, - TQPainter* p, - const TQWidget* widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - - void tqdrawComplexControl( TQ_ComplexControl control, - TQPainter *p, - const TQWidget* widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - SCFlags controls = SC_All, - SCFlags active = SC_None, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - - SubControl querySubControl( TQ_ComplexControl control, - const TQWidget* widget, - const TQPoint &pos, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - - TQRect querySubControlMetrics( TQ_ComplexControl control, - const TQWidget* widget, - SubControl sc, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - - int tqpixelMetric( PixelMetric m, - const TQWidget* widget = 0 ) const; - - TQRect subRect( SubRect r, - const TQWidget* widget ) const; - - TQPixmap stylePixmap( StylePixmap stylepixmap, - const TQWidget* widget = 0, - const TQStyleOption& = TQStyleOption::SO_Default ) const; - - int tqstyleHint( TQ_StyleHint sh, - const TQWidget* w = 0, - const TQStyleOption &opt = TQStyleOption::SO_Default, - TQStyleHintReturn* shr = 0 ) const; - - protected: - bool eventFilter( TQObject* object, TQEvent* event ); - - private: - // Disable copy constructor and = operator - KStyle( const KStyle & ); - KStyle& operator=( const KStyle & ); - - protected: - virtual void virtual_hook( int id, void* data ); - private: - KStylePrivate *d; -}; - - -// vim: set noet ts=4 sw=4: -#endif - diff --git a/kdefx/libkdefx.nmcheck b/kdefx/libkdefx.nmcheck deleted file mode 100644 index bebebf28c..000000000 --- a/kdefx/libkdefx.nmcheck +++ /dev/null @@ -1,12 +0,0 @@ -# KDE namespace check file - -# tdefx classes -K*::* - -# these should preferably go in some namespace in KDE4 -kColorBitmaps -kDrawBeButton -kDrawRoundMask -kDrawNextButton -kDrawRoundButton -kRoundMaskRegion diff --git a/kdefx/libkdefx_weak.nmcheck b/kdefx/libkdefx_weak.nmcheck deleted file mode 100644 index 6482e1938..000000000 --- a/kdefx/libkdefx_weak.nmcheck +++ /dev/null @@ -1,3 +0,0 @@ -# KDE namespace check file - -# KDE classes diff --git a/kdeprint/CMakeLists.txt b/kdeprint/CMakeLists.txt deleted file mode 100644 index bdbacc0bb..000000000 --- a/kdeprint/CMakeLists.txt +++ /dev/null @@ -1,124 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_subdirectory( management ) -add_subdirectory( lpdunix ) -if( CUPS_FOUND ) - add_subdirectory( cups ) -endif( CUPS_FOUND ) -add_subdirectory( lpr ) -add_subdirectory( rlpr ) -add_subdirectory( ext ) -add_subdirectory( filters ) -add_subdirectory( pics ) -add_subdirectory( tools ) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdefx - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile - ${CMAKE_SOURCE_DIR}/kded -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - kprinter.h kprintaction.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - -install( FILES - kprintdialogpage.h kpreloadobject.h kmmanager.h - kmprinter.h kmobject.h kprintdialog.h driver.h - kmjobmanager.h kmjob.h - DESTINATION ${INCLUDE_INSTALL_DIR}/tdeprint ) - - -##### other data ################################ - -install( FILES kprintpreviewui.rc DESTINATION ${CONFIG_INSTALL_DIR}/ui ) -install( FILES testprint.ps specials.desktop DESTINATION ${DATA_INSTALL_DIR}/tdeprint ) -install( FILES tdeprintd.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded ) -install( FILES tdeprintrc DESTINATION ${CONFIG_INSTALL_DIR} ) -install( FILES tdeprintrc.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR} ) - - -##### driverparse ############################### - -set( target driverparse ) - -tde_add_library( ${target} STATIC_PIC - SOURCES driverparse.c -) - - -##### kded_tdeprintd ############################ - -set( target kded_tdeprintd ) - -set( ${target}_SRCS - tdeprintd.cpp kprintprocess.cpp tdeprintd.skel -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK kio-shared tdeinit_kded-shared - DEPENDENCIES dcopidl dcopidl2cpp - DESTINATION ${PLUGIN_INSTALL_DIR} -) - - -#### tdeprint ################################### - -set( target tdeprint ) - -set( ${target}_SRCS - kmfactory.cpp kmjob.cpp kmjobmanager.cpp kmmanager.cpp - kmprinter.cpp kmuimanager.cpp kmvirtualmanager.cpp - driver.cpp driveritem.cpp droptionview.cpp driverview.cpp - kmdbentry.cpp kprintpreview.cpp kprintdialog.cpp - kprinter.cpp kprinterimpl.cpp kprintdialogpage.cpp - kpcopiespage.cpp kpdriverpage.cpp kprinterpropertydialog.cpp - kpgeneralpage.cpp kpqtpage.cpp kmthreadjob.cpp - kpipeprocess.cpp kpfilterpage.cpp kmspecialmanager.cpp - tdeprintcheck.cpp plugincombobox.cpp kpreloadobject.cpp - kfilelist.cpp kprintaction.cpp kpfileselectpage.cpp - treecombobox.cpp kxmlcommand.cpp util.cpp printerfilter.cpp - marginpreview.cpp marginvaluewidget.cpp marginwidget.cpp - kpmarginpage.cpp messagewindow.cpp posterpreview.cpp - kpposterpage.cpp foomatic2loader.cpp fooparser.cpp - fooscanner.cpp ppdparser.cpp ppdscanner.cpp ppdloader.cpp - kmfactory.skel -) - -tde_add_library( ${target} SHARED AUTOMOC - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - LINK kio-shared - DEPENDENCIES dcopidl dcopidl2cpp - DESTINATION ${LIB_INSTALL_DIR} -) - -set_target_properties( ${target}-shared PROPERTIES COMPILE_FLAGS -D_KDEPRINT_COMPILE ) diff --git a/kdeprint/ChangeLog b/kdeprint/ChangeLog deleted file mode 100644 index 5ce11bd36..000000000 --- a/kdeprint/ChangeLog +++ /dev/null @@ -1,619 +0,0 @@ -Since 2.2 release, Michael Goffioul <tdeprint@swing.be> - * automatic filtering: if the input file format is not directly supported - by the print spooler, tdeprint will try to convert the file to the - primary supported input format (usually PostScript). To achieve this, - tdeprint uses the available filters (defined in XML files) and tries to - build up a filter chain. - * mime type checking: when building a filter chain, tdeprint checks that - each output format is supported as an input by the next filter - * possibility to specify input file from the print dialog in StandAlone - mode (like XPP) - * kmvirtualmanager.cpp: KMPrinter::Virtual is only set for pure virtual - printers (== non empty instance name). This makes KPrinter::isVirtual() - more useful. - * CUPS plugin: - - support for quotas and user access restrictions (in wizard and - print manager) - - added missing options in server configuration tool - * Possibility to use an external preview program (still need a GUI to - configure this). - * print dialog: possibility to select the files to print in standalone - mode (like XPP). - -27/08/2001 Michael Goffioul <tdeprint@swing.be> - * implementation of "Schedule" tab in print dialog for the CUPS plugin - (job-hold-until attribute). - * Printer aliases are now handled gracefully in the LPR plugin (they - are actually discarded) - * kprinter.cpp: implementation of setPrintProgram() as: - setOption("kde-isspecial", "1"); - setOption("kde-special-command", cmd); - -28/08/2001 Michael Goffioul <tdeprint@swing.be> - * implementation of KPrintAction, which provides a quick access to - a class of printers (special, regular or both). An application just - needs to create a KPrintAction anc connect to print(KPrinter*). - -31/08/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: fix crash for Qt3 port, must check if attr->name is NULL - before comparing it with strcmp or strncmp. - -12/09/2001 Michael Goffioul <tdeprint@swing.be> - * Management library: set all toolbars non movable to avoid move handles - -13/09/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: fix multiple showing of password dialog for password- - protected printers (timer is now blocked when the password dialog is - shown) - -14/09/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: configuration wizard rewritten using the structure of - ESP PrintPro: more consistent, less pages and widgets. Not used as - default config wizard yet. - * QList -> QPtrList - -25/09/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: made the new configuration wizard as default one. - * other QList -> QPtrList fixes (committed to CVS) - * Avoid to call plugin functions "completePrinter<xxx>" for pseudo - printers (to not confuse the CUPS daemon for example) - * Improved how the default printer is selected in print dialog to - work in any cases - * General: make use of KLocale::pageSize() to determine the default - page size (used for example for pseudo printers and classes) - * Wizard: fix buffer overflow when adding a remote LPD queue having - a lot of jobs waiting - -03/10/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: make use of GET/PUT request to handle configuration - file. Possibility to admin a remote CUPS server (if allowed) - * CUPS plugin: added "/jobs" in the available resources list - -09/10/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: added 2 missing pages in stand-alone mode, "Image" - and "Text". - -10/10/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: "HP-GL/2" page added - * General: added a GUI to configure the preview program, into the - config dialog of the print manager - -12/10/2001 Michael Goffioul <tdeprint@swing.be> - * general: added the possibility for a plugin to add new actions - to the toolbar and context menu (main use = export driver in - CUPS). - * CUPS plugin: added support to export driver to Windows client - through samba. Threaded operation with progress bar to notify - the user. Graphical equivalent to cupsaddsmb from cups-1.1.11. - -16/10/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: removed the "file" backend as it doesn't seem to - be available since a couple of releases, and added a "Other" - page to the wizard for any third-party backend (like pdf). - -18/10/2001 Michael Goffioul <tdeprint@swing.be> - * tdeprintfax: don't hardcode program path, use the $PATH variable - first to find the program. Default to /usr/bin if not found. - -02/11/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: - . fix for remote printers when there's also a local - printer with the same name: the printer-uri-supported - is not used by default anymore - . implementation of IPP report for installed printers - as well as detected IPP printers on the network (in - the wizard) - -05/11/2001 Michael Goffioul <tdeprint@swing.be> - * tdeprintfax: added possibility to view files being faxed and - file action (remove and view) are enabled only when needed. - * KPrinter: when printing to a file, support encoding and spaces - in file names + system --> KProcess. - -07/11/2001 Michael Goffioul <tdeprint@swing.be> - * tdeprint: fixed some problems: - . collate entirely handled by tdeprint, even in the case - of page selection on application-side. - . set KPrinter object in KPrintDialog before adding other - dialog pages (some pages may need it) - * wizard: changed button layout and added a side graphic. Not - committed as the graphic comes from HP driver (copyright). - -08/11/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: - . complete IPP report for job added - . implementation of dynamically added plugin menus for - jobs in the job viewer (used for IPP report) - . printer infos are now retrieved from the correct host - for remote printers and classes (idem for IPP report) - * general: implementation of a DCOP signal communication to - synchronize all tdeprint apps, a plugin change in one app is - notified to all other opened apps (via DCOP). - * kicker extension: made extension aware of plugin change in - other apps (using new DCOP signal comm). - -09/11/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS plugin: added the possibility to list jobs on remote - printers. No management is allowed on remote jobs (yet?). - -10/11/2001 Michael Goffioul <tdeprint@swing.be> - * general: use KShellProcess::quote() for any quoting. Normally, - all quoting problem should be fixed now. - -12/11/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS: redesigned the "cups-add-smb" dialog to make it more - user-driendly. - -13/11/2001 Michael GOffioul <tdeprint@swing.be> - * general: implementation of a KActiveLabel class to embed active - links in labels. Clicking on it "exec" the associated URL. - * general: make use of KActiveLabel in the first page of the - "add-printer" wizard. - * CUPS: make use of KActiveLabel in the "cups-add-smb" wizard. - * wizard: SMB printers with space in their name are now shown - correctly when scanning the network (however it should be - avoided as smbspool seems to be unable to handle it). - -14/11/2001 Michael Goffioul <tdeprint@swing.be> - * ioslave: uploaded new templates from Chris (which adds support - for pseudo printers - * manager: modified RootOnly message for better consistency between - "root" and "administrator" concepts - * print dialog: updated accels (general, Qt, copies and other CUPS - pages) - * print dialog: - . file selection: line edit -> listview - . file selection made as print dialog page and inserted at - the same level than "Copies" - . added hiding mechanism to make the dialog more compact - (show/hide button can probably be improved) - -15/11/2001 Michael Goffioul <tdeprint@swing.be> - * CUPS: drivers are now downloaded from the actual server for remote - printers. This allows to have access to all options set for any - printer (even remote ones). However remote printer's drivers are - kept read-only. - -16/11/2001 Michael Goffioul <tdeprint@swing.be> - * print dialog: instances are now presented in a tree structure in - the combo box -> cleaner view. - * general: ported the use of a global instance file to 2.2 branch - (file is /etc/cups/lpoptions). - * CUPS: added support for Adobe PPD file compliance (foomatic will - introduce them very soon in normal distributions), where numerical - options are mapped into enum options. KDEPrint still uses the - numerical option and update the corresponding enum one with the - closest value. - -21/11/2001 Michael Goffioul <tdeprint@swing.be> - * job viewer: clicking on 'x' button only hide the job viewer but - doesn't quit the app. To quit, either use menu item (from window - or system tray) or accel when job viewer is visible. - * general: print preview has been embedded in a real dialog, so that - it is always centered on its parent now. It also have the dialog - buttons in title bar (no minimize). - -23/11/2001 Michael Goffioul <tdeprint@swing.be> - * job management: the job management has been re-engineered to follow - the paradigm "1 window == 1 queue". There's still the possibility to - view jobs for all printers within a single window. This should enhance - the usability of job management tools (I hope). - -26/11/2001 Michael Goffioul <tdeprint@swing.be> - * job management: job type (active/completed) is now handled on a - printer basis instead of a global property of the manager. This allows - different windows to show different job type, and also ease the - management of "All Printers" windows. - * job management: sorting jobs on numerical values is fixed (ID, - size, ...) - * job management: added the possibility to customize (from the plugin) - what's shown as job attributes. New attributes can be added. This - will be used for priority support in CUPS plugin. - * job management: re-engineered how dynamic plugin actions are handled - internally to fix problems when dealing with several windows opened. - This new mechanism should also be applied to print management dynamic - actions (more consistent). - -28/11/2001 Michael Goffioul <tdeprint@swing.be> - * special printers: added the possibility to have configurable options - in pseudo-printers. Options are described in an additional XML file - (like filters) and configured through an "Advanced" tab in the property - dialog. TODO: graphical configuration widget + apply KXmlCommand to - normal filters. - -29/11/2001 Michael Goffioul <tdeprint@swing.be> - * general: fixed sorting of options in driver view. They should be shown - in order of appearance now. - * general: make use of the new KXmlCommand class for filters too. - * filters: removed the "Page Size" from the options of enscript filter, - this is taken from the KPrinter object now. - -04/12/2001 Michael Goffioul <tdeprint@swing.be> - * general: finalized the new XML command mechanism: - . graphical command builder - . pseudo-printers and filters are completely based on new XML - object, though old style is supported (only requirements from - previous mechanism are not used). - . KPrintFilter and KMFilterManager are now obsolete and replaced - by KXmlCommand and KXmlCommandManager respectively. - * tdeprintfax: made the log window a "real" log window. It is dynamically - refreshed on new debug output arrival (suggested by user). - -10/12/2001 Michael Goffioul <tdeprint@swing.be> - * general: make use of "Detail" mechanism of KDialogBase in XML command - editor. - -11/12/2001 Michael Goffioul <tdeprint@swing.be> - * instances: for root, instances are saved in global file - /etc/cups/lpoptions. This allows to easily create global instances - (just be root and create the instance). - * pseudo-printers: for root, pseudo printers are saved in a global - file, such that root is able to manage global pseudo printers. Locale - pseudo printers still override global ones if they have the same name. - -12/12/2001 Michael Goffioul <tdeprint@swing.be> - * general: added error messages when the printer list cannot be retrieved - in print manager and print dialog. With CUPS, if the server is not - running, an error message is shown to the user. - * CUPS: disabled all backends if no server is running. - -13/12/2001 Michael Goffioul <tdeprint@swing.be> - * general: preleminary support for external printer tool. Only escputil - at this moment. - -03/01/2002 Michael Goffioul <tdeprint@swing.be> - * general: - . added a "ID name" label to the first dialog for command editing - . put "View Printer Infos" in front of orientation and view type - change (more logical) - . added a confirmation dialog before sending a test page to a - printer (printer and instance test) - . added a short summary below the command selector containing the - ID and the output type ("not allowed" if no output supported). - . added a WhatsThis help to the "Instances" tab briefly explaining - what's an instance. - -09/01/2002 Michael Goffioul <tdeprint@swing.be> - * general: when filtering, the file type is checked against supported - formats. If the format is not supported, a warning is issued and the - user has the possibility to auto-convert the file to a supported - format. Consequence: you can now safely perform page selection on any - file type with any printer and any spooler, tdeprint will try to convert - the file to PS. - * preview dialog: rewrote the code in a cleaner way, avoiding the use - of a non toplevel main window. Preview dialog looks simpler now. New - issue: toolbuttons overlap the toolbar border (only for toolbar not - children of main window). - * general: made the "Files" page a standard page in KPrinter. Modified - kprinter's code to add that page -> will be easier to remove it when - implementing a "--stdin" option. - * kprinter: - . added a "--stdin" option. If this option is set, only printing - from stdin is allowed and the "Files" tab is hidden. Can be used in - Netscape. If files are given on the command line, this option is - forced unset. - . added a "--nodialog" option for quick print. - . added the persistent feature (with some code rewrite in tdeprint - library) - -10/01/2002 Michael Goffioul <tdeprint@swing.be> - * general: added (temporary) workaround for drawing problems in fixed - toolbars, until a real fix gets implemented: - static_cast<QWidget*>(tb)->layout()->setMargin(1); - * general: started to used new icons provided by Bogdan, for the toolbar - * general: added KPrinter::autoConfigure(), to automatically configure - a KPrinter object without the need for a print dialog. - -14/01/2002 Michael Goffioul <tdeprint@swing.be> - * slave: made case-insensitive for backward compatibility (old URLs may - come from history). Now print:/Classes should work OK. - * CUPS: moved the IPP report to an separate dialog and added the - possibility to print the result. - -15/01/2002 Michael Goffioul <tdeprint@swing.be> - * started the implementation of a new LPR/LPRng plugin: this implementation - is designed to be modular to provide support for various systems like - Foomatic, APSFilter, GNUlpr or Printtool(RH). - -17/01/2002 Michael Goffioul <tdeprint@swing.be> - * LPR: first implementation of a job manager. Make use of asynchronous - lpc and lpq processes. Major problem: delay between new state and - screen update due to the fact that data are started to be updated when - the info is needed for showing. As data are retrieved asynchronously, - they are not available for the update. - * general: clean up refresh code of the job viewer - * KPrinter: added the DocFileName feature (suggested by David) to define - the default basename for output file. - * test: updated to Qt3 and demonstrate the use of the DocFileName feature - -21/01/2002 Michael Goffioul <tdeprint@swing.be> - * LPR: added basic implementation of a KPrinterImpl object -> plugin is - functional (though far from complete...) - -22/01/2002 Michael Goffioul <tdeprint@swing.be> - * tdeprintfax: make use of new address book (libkabc) instead of the old - one (libkab). - -29/01/2002 Michael Goffioul <tdeprint@swing.be> - * LPR: enhancement of the APSFilter handler. Still missing: setup the - options in the print command line - * wizard: removed the garbage '&' in last page - * general: added SMB util functions -> to be used whenever it's - possible (CUPS plugin, Foomatic handler => TO BE DONE) - -30/01/2002 Michael Goffioul <tdeprint@swing.be> - * general: use QGuardedPtr to keep KPrinterImpl object in KPrinter, this - should avoid some crashes. - * LPR: - . added print options for APSFilter handler - . make use of smb-url conversion functions in Foomatic handler - . fix problem with rmote lpd queues: force lp=<empty string> in - printcap entry - -07/02/2002 Michael Goffioul <tdeprint@swing.be> - * job viewer: fix crash when switching the print plugin elsewhere and - there's some jobs shown + fix refresh problem when switching plugin - * general: fix small bug when removing a filter in "Filters" page - * general: discard the toolbar use in the "Instances" page to avoid the - problem with non-docked vertical toolbars. Use plain QPushButton - instead, but this has some drawing problems in HighColor style. - -11/02/2002 Michael Goffioul <tdeprint@swing.be> - * LPR: added support for LPRngTool+IFHP (not complete yet though) - * general: various fixes for crashes, inconsistencies, ... - -12/02/2002 Michael Goffioul <tdeprint@swing.be> - * tdeprintfax: added %email to possible command tags. The e-mail address - is retrieved from standard settings in KControl module. The tag can - also be used in the "Name" field of the options dialog - * LPR: completion of the LPRngTool handler + implementation of dynamic - driver directories (to be done: should also be configurable in the - options dialog) - * general: Fixed bug -> XML commands couild not be saved - * CUPS: FontPath directive is now considered as a string list, multiple - directives are supported and a listview is used in the GUI - * CUPS: configuration tool now handles gracefully unrecognized options, - a warning is issued, and they are restored as-is on file saving. - -13/02/2002 Michael Goffioul <tdeprint@swing.be> - * CUPS: added support for job-billing and page-label, and put them - along with the scredule option into a single "Advanced" tab. - * CUPS: added job billing info to the job viewer - * CUPS: added job priority selection in the Advanced tab of the print - dialog - * general: allow multi selection in the file list of print dialog - -14/02/2002 Michael Goffioul <tdeprint@swing.be> - * CUPS: added the possibility to edit job attributes on-the-fly using - a dialog similar to the printer properties dialog. Still the be fixed: - page ranges (problem with option encoding in CUPS). - -15/02/2002 Michael Goffioul <tdeprint@swing.be> - * general: fixed infinite recursion bug in KIconSelectAction - * CUPS: temporarily disabled edition of page-ranges as it seems CUPS is - buggy. I should find a workaround. - * general (CUPS): enable some actions for jobs on remote hosts. It seems - to work OK between my local LM-8.1 and a remote LM-7.2. - -16/02/2002 Michael Goffioul <tdeprint@swing.be> - * CUPS: added direct Foomatic driver support (no need the all PPD package - from foomatic anymore, driver are loaded directly from Foomatic) - -17/02/2002 Michael GOffioul <tdeprint@swing.be> - * preview: - . better algorithm to find a preview object - . more comprehensive error report - . possibility to cancel printing even with external PS viewers - * general: added the backend stuff for printer filtering, needs GUI - -> allows to only show a selected set of printers - -18/02/2002 Michael Goffioul <tdeprint@swing.be> - * general: simple printer filtering mechanism based on printer name - and location regexp. Graphical configuration for printer name. - -19/02/2002 Michael Goffioul <tdeprint@swing.be> - * general: - . completion of the printer filtering mechanism (added location - string filter) - . notification system between applications when config file has - changed - . possibility to open the main option dialog from print dialog - (for example to change the filter or default preview program) - . added icon on push buttons when useful - . changed plugin names to tdeprint_* (stripped the leading "lib") - -20/02/2002 Michael Goffioul <tdeprint@swing.be> - * slave: prevent konqueror to consider a trailing slash as a directory - specification (simply add a config entry in protocol file) - * general: large UI standardization by making use of KDialogBase along - with KGuiItem - * kicker menu: possibility to open main Options Dialog from the menu - -21/02/2002 Michael Goffioul <tdeprint@swing.be> - * general: splitted the printer state into enable/disable and start/stop - and modified the GUI to reflect this - * general: removed the KMManager::configure(), obsoleted by the complete - options dialog being shown - * kicker extension: extension of the menu plugin to allow access to the - server configuration tool as well as the "kprinter" utility. - -25/02/2002 Michael Goffioul <tdeprint@swing.be> - * LPR: added printer testing support - -26/02/2002 Michael Goffioul <tdeprint@swing.be> - * general: printer filtering specs are now ORed instead of ANDed - * general: changed "Advanced" to "Driver Settings" - * CUPS: fixed RIPCache problem, added support for possible suffixes - -27/02/2002 Michael Goffioul <tdeprint@swing.be> - * CUPS: workaround to allow special characters in login/password without - breaking security. Possible now to use safely chars like '@' and '/' - in login. - * general: added a check box in the config dialog to enable/disable - font embedding into PS data (compatible with Qt settings). - -28/02/2002 Michael Goffioul <tdeprint@swing.be> - * general: job viewer updated correctly on plugin reload -> additional - columns and "history" action state - * general: internal *Settings objects are synchonized on config changes - (CupsInfos and LprSettings) - * general: improved feedback to user when creating driver DB - * CUPS: speed optimization when creating driver DB (simple hack to avoid - to parse the entire PPD file each time => much better) - * tdeprintfax: added "-n" and "-f %email" by default for the Hylafax - system - * general: various small UI improvements (suggested by Thomas) - -02/03/2002 Michael Goffioul <tdeprint@swing.be> - * general: modified the driver structure to support dynamic options - as in SuSE - * LPR: more management support for SuSE handler -> drver settings can - be modified now. - * general: needed stuff to provide translations for filters (Coolo will - now extract the strings from XML files for translators) - -10/03/2002 Michael Goffioul <tdeprint@swing.be> - * CUPS: allow any integer value for RIPCache + don't upload the cupsd.conf - with wrong settings - -***************** -* KDE-3 RELEASE * -***************** - -(CeBIT) Michael Goffioul <tdeprint@swing.be> - * Fix various crashes: - . when changing the CUPS server (notify registered object before - reloading) - . when building the driver DB: don't destroy the progress dlg - * job viewer: possibility to view only the jobs of the current user - * CUPS: "dynamic" changing of the text margins in the preview using - rubber bands - * general: started generealization of a margin widget to configure the - margins of the KPrinter object - -25/03/2002 Michael Goffioul <tdeprint@swing.be> - * general: do not use pointers in various views, to avoid dangling - pointers (and crashes) when changing something (plugin, config file, ...). - This makes the aboutToReload functions quite useless, but it has to - be tested. - * general: finished the generic print margins widget to be used in non - full page mode. Requires a patched Qt (hope TrollTech will add the - missing setMargins soon) -> cannot be committed. - * general: added help button to the wizard and the print dialog. They - are connected to the main help (should probably add an anchor to go - directly to the associated part). - * tdeprintfax: more support/sync with standard addressbook: - . possibility to start the ab editor from tdeprintfax - . make use of the "Organization" field as enterprise - . fix problem with empty phone number (ex: no business fax). - -26/03/2002 Michael Goffioul <tdeprint@swing.be> - * tdeprintfax: - . added support for Mgetty-sendfax - . added support for page size in filters - . make use of the localized page size as default - . regrouped the options in the option dialog for more - consistency - . added support for scheduling in HylaFax and Mgetty-sendfax - . bugfix in logview: behaves safely when closed using the title - bar button - -27/03/2002 Michael Goffioul <tdeprint@swing.be> - * general: created a separate "Fonts" section in the KDEPrint settings - dialog and removed the "Embed Fonts" option from the general section - (moved to the new section). - * tdeprintfax: fixed disabled background for "Comment" widget, use QBrush - instead of QColor. OK with styles like Liquid. - -28/03/2002 Michael Goffioul <tdeprint@swing.be> - * general: added a user feedback mechanism in the form of a dialog showgin - status messages, including initialization, number of the page currently - generated, filtering and sending to the printer. - -29/03/2002 Michael Goffioul <tdeprint@swing.be> - * general: enhanced the status feedback mechanism - . possibility to have multiple status boxes (one for each app) - . added an icon (eye-candy) and the document name being printed - . made it configurable in the options dialog - * general: possibility to use the default printer on first print instead - of the last printer used. Configurable in the options dialog. Now, I - should probably re-add the "Set as default" button. - * print dialog: re-added the "Set as default" button in the case the - user default printer is used on first print instead of the last used - printer (it does make sense again to have it) - * general: added a small (but useful) information string about the - current plugin below the plugin combobox (ex: in CUPS, shows the current - server:port). - -02/04/2002 Michael Goffioul <tdeprint@swing.be> - * general: - . fixed various conflicting shortcuts - . made KMVirtualManager inherit from KPReloadObject to force instance - reloading when something has changed - * print dialog: added buttons to move files up and down - * CUPS: added a generic job tagging mechanism in the form of an additional - tab in the print dialog. It contain a 2-columns table where custom tags - can be added. Read-only in job editing mode (hope to change that soon). - -03/04/2002 Michael Goffioul <tdeprint@swing.be> - * manager: show instances as children of the real printer in the tree view. - No instance management is possible from the tree view itself. The user - still has to use the "Instances" tab. - * ioslave: added support for print jobs browsing, per printer or for all - printers together (-> print:/jobs) - -04/04/2002 Michael Goffioul <tdeprint@swing.be> - * ioslave: added support to view the driver of a printer in HTML form - (print:/printers/lp1?driver) - * CUPS: allows editing of page-ranges for pending jobs, work around - small problem in CUPS. - * LPR: - . added a "ppdfile" field in printcap file for Foomatic drivers - with LPRng. This should make printers created with KDEPrint - work with gpr (from GNUlpr) - . added support for "bool" directives in Foomatic drivers - -23/05/2002 Michael Goffioul <tdeprint@swing.be> - * job manager: added the possibility to control the username for jobs - filtering, and the possibility to limit the number of jobs shown. - -16/08/2002 Michael Goffioul <tdeprint@swing.be> - * filters/command: added the possibility to have comments about a specific - command, including clickable URL's. Modified the command selector to use - those comments. - * commands: added the "poster" command, but based on a modified version - of the original program. Still need to publish it somehow. - * job viewer: added possibility to drop files on the job viewer to print - them. - * print dialog: use the correct extension for output file in all cases, - even on first dialog showing (call slotPrinterSelected after setting - the output file name). - -20/08/2002 Michael Goffioul <tdeprint@swing.be> - * print dialog: - . added a method to disable a page in the main dialog - . make the filename persistent in the SaveFile dialog - . use a rename dialog if the output file already exists - -26/08/2002 Michael Goffioul <tdeprint@swing.be> - * general: added a generic PS driver to (missing for too long) - -02/09/2002 Michael Goffioul <tdeprint@swing.be> - * print dialog: added graphical interface to the poster XML command - (still to be committed) - * manager: added a condensed toolbar with actions grouped by topics in - sub-menus. - -03/09/2002 Michael Goffioul <tdeprint@swing.be> - * print dialog: enabled preview even in standalone mode, either the - internal PS viewer or any other registered app will be used, - according to the user preferences. - -04/09/2002 Michael Goffioul <tdeprint@swing.be> - * commands: make unavailability of a command more visual by showing a - red text, and disabling the OK button of the current dialog (only - if needed). - -05/09/2002 Michael Goffioul <tdeprint@swing.be> - * CUPS: shows all possible URI detected by CUPS when selecting the "Others" - printer type in the wizard, like the web interface is doing. diff --git a/kdeprint/Makefile.am b/kdeprint/Makefile.am deleted file mode 100644 index fecf25c64..000000000 --- a/kdeprint/Makefile.am +++ /dev/null @@ -1,114 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -if include_cups_SUBDIR -CUPSSUBDIR=cups -endif - -SUBDIRS = . management lpdunix $(CUPSSUBDIR) lpr rlpr ext filters pics tools tests - -INCLUDES= -I$(top_srcdir)/tdefx -I$(top_srcdir)/kded -I$(top_srcdir) $(all_includes) - -kde_module_LTLIBRARIES = kded_tdeprintd.la - -kded_tdeprintd_la_SOURCES = tdeprintd.skel tdeprintd.cpp kprintprocess.cpp -kded_tdeprintd_la_LIBADD = $(LIB_KIO) $(LIB_KDED) $(LIB_QT) $(LIB_KDEUI) $(top_builddir)/dcop/libDCOP.la $(LIB_KDECORE) $(top_builddir)/kded/libtdeinit_kded.la -kded_tdeprintd_la_LDFLAGS = $(all_libraries) -module -avoid-version -#kded_tdeprintd_la_METASOURCES = AUTO - -lib_LTLIBRARIES = libtdeprint.la - -libtdeprint_la_SOURCES = kmfactory.cpp kmjob.cpp kmjobmanager.cpp kmmanager.cpp kmprinter.cpp \ - kmuimanager.cpp kmvirtualmanager.cpp driver.cpp driveritem.cpp droptionview.cpp \ - driverview.cpp kmdbentry.cpp \ - kprintpreview.cpp kprintdialog.cpp kprinter.cpp kprinterimpl.cpp kprintdialogpage.cpp \ - kpcopiespage.cpp kpdriverpage.cpp kprinterpropertydialog.cpp kpgeneralpage.cpp kpqtpage.cpp \ - kmthreadjob.cpp kpipeprocess.cpp kpfilterpage.cpp \ - kmspecialmanager.cpp tdeprintcheck.cpp plugincombobox.cpp kpreloadobject.cpp kfilelist.cpp \ - kprintaction.cpp kpfileselectpage.cpp treecombobox.cpp kmfactory.skel kxmlcommand.cpp \ - util.cpp printerfilter.cpp marginpreview.cpp marginvaluewidget.cpp marginwidget.cpp \ - kpmarginpage.cpp messagewindow.cpp posterpreview.cpp kpposterpage.cpp foomatic2loader.cpp \ - fooparser.cpp fooscanner.cpp ppdparser.cpp ppdscanner.cpp ppdloader.cpp - -libtdeprint_la_LDFLAGS = $(all_libraries) -version-info 6:0:2 -no-undefined -libtdeprint_la_LIBADD = $(LIBZ) $(LIB_QT) $(LIB_KDEUI) $(top_builddir)/dcop/libDCOP.la $(LIB_KDECORE) $(LIB_KFILE) -libtdeprint_la_DEPENDENCIES = $(LIB_KPARTS) -libtdeprint_la_METASOURCES = AUTO - -noinst_HEADERS = kmdbentry.h kmfactory.h \ - kmuimanager.h kmvirtualmanager.h driveritem.h droptionview.h \ - driverview.h kprintpreview.h kprinterimpl.h kprintdialog.h \ - kpcopiespage.h kpdriverpage.h kprinterpropertydialog.h kpgeneralpage.h \ - kpqtpage.h kprintprocess.h kmthreadjob.h kpipeprocess.h tdeprintd.h \ - kpfilterpage.h kmspecialmanager.h tdeprintcheck.h plugincombobox.h \ - kfilelist.h kpfileselectpage.h treecombobox.h kxmlcommand.h \ - util.h driverparse.h printerfilter.h marginpreview.h marginwidget.h \ - marginvaluewidget.h kpmarginpage.h messagewindow.h \ - posterpreview.h kpposterpage.h foomatic2loader.h ppdloader.h - -include_HEADERS = kprinter.h kprintaction.h - -tdeprint_HEADERS = kprintdialogpage.h kpreloadobject.h kmmanager.h kmprinter.h kmobject.h kprintdialog.h \ - driver.h kmjobmanager.h kmjob.h -tdeprintdir = $(includedir)/tdeprint - -EXTRA_DIST = fooparser.y fooscanner.l kprintpreviewui.rc - -KDE_OPTIONS = nofinal - -# installation of UI files -uidata_DATA = kprintpreviewui.rc -uidatadir = $(kde_confdir)/ui - -# Test page -printdata_DATA = testprint.ps specials.desktop -printdatadir = $(kde_datadir)/tdeprint - -# Services -servicesdir = $(kde_servicesdir)/kded -services_DATA = tdeprintd.desktop - -# Config file -configdir = $(kde_confdir) -config_DATA = tdeprintrc - -# parser and scanner -fooparser: - rm -f fooparser.cpp.h - bison -v -d -p tdeprint_foomatic2 $(srcdir)/fooparser.y -o $(srcdir)/fooparser.cpp - if test -f "$(srcdir)/fooparser.hpp"; then mv $(srcdir)/fooparser.hpp $(srcdir)/fooparser.cpp.h; fi - flex -o$(srcdir)/fooscanner.cpp -Ptdeprint_foomatic2 $(srcdir)/fooscanner.l - echo "#ifndef fooparser_cpp_h" > $(srcdir)/fooparser.cpp.hh - echo "#define fooparser_cpp_h" >> $(srcdir)/fooparser.cpp.hh - cat $(srcdir)/fooparser.cpp.h >> $(srcdir)/fooparser.cpp.hh - echo "#endif" >> $(srcdir)/fooparser.cpp.hh - mv $(srcdir)/fooparser.cpp.hh $(srcdir)/fooparser.cpp.h - -ppdparser: - rm -f ppdparser.cpp.h - bison -v -d -p tdeprint_ppd $(srcdir)/ppdparser.y -o $(srcdir)/ppdparser.cpp - if test -f "$(srcdir)/ppdparser.hpp"; then mv $(srcdir)/ppdparser.hpp $(srcdir)/ppdparser.cpp.h; fi - flex -o$(srcdir)/ppdscanner.cpp -Ptdeprint_ppd $(srcdir)/ppdscanner.l - echo "#ifndef ppdparser_cpp_h" > $(srcdir)/ppdparser.cpp.hh - echo "#define ppdparser_cpp_h" >> $(srcdir)/ppdparser.cpp.hh - cat $(srcdir)/ppdparser.cpp.h >> $(srcdir)/ppdparser.cpp.hh - echo "#endif" >> $(srcdir)/ppdparser.cpp.hh - mv $(srcdir)/ppdparser.cpp.hh $(srcdir)/ppdparser.cpp.h - -noinst_DATA = tdeprint - -tdeprint: - $(LN_S) $(srcdir)/management tdeprint - -# convenience static library -noinst_LIBRARIES = libdriverparse.a -libdriverparse_a_SOURCES = driverparse.c - -update_DATA = tdeprintrc.upd -updatedir = $(kde_datadir)/kconf_update - -messages: rc.cpp - $(EXTRACTRC) `find . -name "*.rc" -o -name "*.ui" | grep -v /cupsdconf` >> rc.cpp - $(XGETTEXT) `find . -name "*.cpp" | grep -v /cupsdconf` -o $(podir)/tdeprint.pot - -include ../admin/Doxyfile.am - diff --git a/kdeprint/TODO b/kdeprint/TODO deleted file mode 100644 index 7c67dccdb..000000000 --- a/kdeprint/TODO +++ /dev/null @@ -1,75 +0,0 @@ -BUGS ----- - -- Administration of remote printers: driver settings - -- Allow to view a set of specified printers in the job viewer - (instead of "one or all"). - - -WISHES ------- - -- Implement a generic banner behavior: banners would be insrted - as standard print file before and/or after the actual file. This - would allow for KDE-specific banners and translated banners. - -- Possibility to specify a different input slot for first page??? - -- add "Subject" or "Regarding" to tdeprintfax interface: look first - if this is possible in efax and/or hylafax - -- add the possibility to view a printjob file (if possible) - -- restarting server: use of "ps" in a subshell to get the pid, possibility - of authentification (put this into separate program that would restart - itself using tdesu). - -- CUPS: a "Printer/Server Debugging Helper" would be nice: you could - vary the LogLevel there, restart the server, provide a viewer - for the error_log (maybe the other logs too) with life updates - including means to "grep" for errors and keywords. It could even - become extended to provide for some automatic reporting tool that - collects the data to be send in for bug reports (like PPD in use, - CUPS version, KDEPrint version, printer-make-and-modell, usage - of foomatic/cupsomatic, ghostscript version etc.). -kp- - -- log viewer: page_log, error_log, ... This could be based on XML - templates and produce printable HTML reports. - -- in CUPS possibility to filter printer using printer-type attribute, - to get only printers having a specified capability. Service Location - Protocol might be useful here (perhaps via the Knot). - -- show information from Foomatic DB in some way (comments) - -- "Save as new instance" possibility in the print dialog - -- raw printing option - -- add a generic option edit line to let the user specify any option - he wants - -- support new options for N-up printing in CUPS, put everything in - a separate page with graphical widgets, and replace the N-up zone - of the "General" page with Color/GrayScale. - -- allow to set the job title in kprinter - -- preview multi files sequentially - -- support for ICC (have a look at GS-7.05 that support ICC) - http://www.macup.ru/reviews/3_2002/HP_1ab.html - http://www.macup.ru/reviews/3_2002/HP_2ab.html - http://www.macup.ru/reviews/3_2002/HP_3.html - http://www.macup.ru/reviews/3_2002/HP_4ab.html - -- accessing Fax settings from "Fax" printer configuration dialog?? - -- allow extracting PPD files from exe (like those from Adobe) using - the cabextract utility http://www.kyz.uklinux.net/cabextract.php3 - -- cupsaddsmb: allow downloading/extracting the Adobe PS driver package - using cabextract utility. Note: in cups-1.1.16, a free Windows - driver should be included, such that Adobe drivers won't be needed - anymore. diff --git a/kdeprint/TODO.cups12 b/kdeprint/TODO.cups12 deleted file mode 100644 index 436f7d0b0..000000000 --- a/kdeprint/TODO.cups12 +++ /dev/null @@ -1,293 +0,0 @@ - -TODO.cups12 -=========== - -This is a list of features that need to be implemented in KDEPrint for -KDE4. - -Many gaps have opened by the continuing CUPS 1.1.x development already -(which added quite some new parameters and features), while KDEPrint -development got dormant in recent years. Plus, even more new gaps by -the recent CUPS 1.2 release (which added even more new features). - - - --------------------------- - In General: - --------------------------- -* a GUI to configure client.conf is missing [1.1] -* a GUI to configure snmp.conf is missing [1.2] -* a GUI to configure subscriptions.conf is missing [1.2] - -Other stuff that's new: - -- port monitor support [1.2] -- unique job IDs support [1.2] -- print a self test page (if driver supports CUPS command file format, - you can now print the printer's self-test page) [1.2] -- perform a self-cleaning of print heads (if driver supports CUPS - command file format, you can now clean print heads) [1.2] -- per-printer sharing support [1.2] -- per-printer error policy support [1.2] -- per-printer operation policy support [1.2] -- IPP notifications support [1.2] -- cupsd.conf environment variable support [1.2] -- driver interfaces support (CUPS 1.2 supports "driver interfaces" - which allow a driver to advertise the printers it supports and - automatically generate the PPD file as needed) [1.2] -- improved error handling support (CUPS 1.2 API provides convenience - functions to get full error message of last request) [1.2] -- improved "backchannel" support (CUPS 1.2 API provides backends and - filters with access to information sent back from a printer) [1.2] -- globalized PPD support [1.2] -- custom PPD option support [1.2] -- extended PPD API support (CUPS 1.2 PPD API got added new functions: - reading from CUPS files; localization of globalized PPD files; - emitting of arbitrary ranges of options; custom option support [like - passwords, passcodes, curves, integers, points, reals and strings]; - enhanced JCL support; and access to all options in a PPD file) [1.2] -- CUPS ICC profiles support [1.2] - - - -------------------------------- - More specifically: - -------------------------------- - -kprinter --------- - -* add support for "-U username somebody" (or, in a more IPP-conforming - syntax: "-o job-originating-username=username"). - -* add support for multilanguage PPD files - -* add support for other CUPS extensions re. PPD parameters; especially - important is support for handling custom PPD options! - - -kaddprinterwizard ------------------ - -* add support for IPv6 syntax when specifying or parsing network - addresses - -* add support for new "snmp" backend in CUPS 1.2. - - The snmp backend can auto-discover most printer types which are - attached to the LAN with a NIC. For a sort of introduction to its - features see http://www.kdedevelopers.org/node/2138/. - - To check it from the commandline, just run it without any parameter: - "/usr/lib/cups/backend/snmp" (Ubuntu Dapper users have it disabled - by default; just run "/usr/lib/cups/backend-available/snmp". If you - have network printers in your LAN, you'll likely see an output like - - network ipp://10.162.2.92:631/ipp "Ricoh IPP Printer v2.0" "Ricoh IPP Printer v2.0 10.162.2.92" "" - network socket://10.162.2.93 "infotec ISC824" "infotec ISC824 10.162.2.93" "" - network lpd://10.162.2.94/passthru "Canon iR5000-6000" "Canon iR5000-6000 10.162.2.94" "" - - kaddprintwizard should be able to parse the CUPS snmp backend's - output for adding the auto-discovered network printers to the - local setup. - -* add support for the following parameters in printers.conf (which - where newly added in CUPS 1.2.0): - - ErrorPolicy - - OpPolicy - - Option - - PortMonitor - - Shared - - StateTime - For information purposes: currently supported parameters are: - - Accepting - - AllowUser - - DenyUser - - DeviceURI - - Info - - JobSheets - - KLimit - - Location - - PageLimit - - QuotaPeriod - - State - - StateMessage - - - -kaddprinterwizard --kdeconfig ------------------------------ - -* add support for unix domain socket support (was added in CUPS 1.2.x) - - CUPS 1.2 newly introduced the option to communicate via "unix - domain sockets" for local cases (CUPS client and server on the - same host [=localhost]. That means, you can now have 2 types of - "Listen" directives (concurrently): - Listen localhost:631 - Listen /path/to/domain.sock.name - - Support for unix domain socket communication should be added at - "CUPS Server Settings" --> "Server information". - - -kaddprinterwizard --serverconfig --------------------------------- - -* Add support for currently unsupported cupsd.conf 1.1.x parameters. - All in all 15 unsupported parameters: - - ConfigFilePerm - - FaxRetryInterval - - FaxRetryLimit - - FileDevice - - FilterNice - - Include - - LimitRequestBody - - LogFilePerm - - MaxClientsPerHost - - MaxCopies - - PrintcapGUI - - ReloadTimeout - - RootCertDuration - - RunAsUser - - ServerTokens - -* add support for cupsd.conf parameters newly introduced in CUPS 1.2.0. - Note, "RunAsUser" is no longer supported in CUPS 1.2.x! - All in all about 18 new parameters (on top of the 15 unsupported ones - from CUPS 1.1.x): - - BrowseLDAPBindDN - - BrowseLDAPDN - - BrowseLDAPPassword - - BrowseLDAPServer - - BrowseLocalOptions - - BrowseLocalProtocols - - BrowseRemoteOptions - - BrowseRemoteProtocols - - DefaultEncryption - - DefaultPolicy - - DefaultShared - - JobRetryInterval - - JobRetryLimit - - PassEnv - - Policy - - SetEnv - - UseNetworkDefault - - -Complete list of 1.2.0 cupsd.conf directives --------------------------------------------- - -This is a complete list of all cupsd.conf parameters that may be -used in CUPS 1.2.x, alongside a listing if they are supported in -KDEPrint 3.5.3: - - - ++ = supported - -- = unsupported - - ------------+----------------------------------------------------- - Supported? | cupsd.conf directive - ------------+----------------------------------------------------- - ++ | AccessLog - ++ | Allow - ++ | AuthClass - ++ | AuthGroupName - ++ | AuthType - ++ | AutoPurgeJobs - ++ | BrowseAddress - ++ | BrowseAllow - ++ | BrowseDeny - ++ | BrowseInterval - -- (1.2) | BrowseLDAPBindDN - -- (1.2) | BrowseLDAPDN - -- (1.2) | BrowseLDAPPassword - -- (1.2) | BrowseLDAPServer - -- (1.2) | BrowseLocalOptions - -- (1.2) | BrowseLocalProtocols - ++ | BrowseOrder - ++ | BrowsePoll - ++ | BrowsePort - ++ | BrowseProtocols - ++ | BrowseRelay - ++ | BrowseRemoteOptions - ++ | BrowseRemoteProtocols - ++ | BrowseShortNames - ++ | BrowseTimeout - ++ | Browsing - ++ | Classification - ++ | ClassifyOverride - -- (1.1) | ConfigFilePerm - ++ | DataDir - ++ | DefaultAuthType - ++ | DefaultCharset - -- (1.2) | DefaultEncryption - ++ | DefaultLanguage - -- (1.2) | DefaultPolicy - -- (1.2) | DefaultShared - ++ | Deny - ++ | DocumentRoot - ++ | Encryption - ++ | ErrorLog - -- (1.1) | FileDevice - ++ | FilterLimit - -- (1.1) | FilterNice - ++ | FontPath - ++ | Group - ++ | HideImplicitMembers - ++ | HostNameLookups - ++ | ImplicitAnyClasses - ++ | ImplicitClasses - -- (1.1) | Include - -- (1.2) | JobRetryInterval # 1.1 had "FaxRetryInterval" - -- (1.2) | JobRetryLimit # 1.1 had "FaxRetryLimit" - ++ | KeepAlive - ++ | KeepAliveTimeout - ++ | Limit (Location) - ++ | Limit (Policy) - ++ | LimitExcept - -- (1.1) | LimitRequestBody - ++ | Listen - ++ | ListenBackLog - ++ | Location - -- (1.1) | LogFilePerm - ++ | LogLevel - ++ | MaxClients - -- (1.1) | MaxClientsPerHost - -- (1.1) | MaxCopies - ++ | MaxJobs - ++ | MaxJobsPerPrinter - ++ | MaxJobsPerUser - ++ | MaxLogSize - ++ | MaxRequestSize - ++ | Order - ++ | PageLog - ++ | PassEnv - -- (1.2) | Policy - ++ | Port - ++ | PreserveJobFiles - ++ | PreserveJobHistory - ++ | Printcap - ++ | PrintcapFormat - -- (1.1) | PrintcapGUI - -- (1.1) | ReloadTimeout - ++ | RemoteRoot - ++ | RequestRoot - ++ | Require - ++ | RIPCache - -- (1.1) | RootCertDuration - --(removed)| (RunAsUser) # present in 1.1 - ++ | Satisfy - ++ | ServerAdmin - ++ | ServerBin - ++ | ServerCertificate - ++ | ServerKey - ++ | ServerRoot - -- (1.1) | ServerTokens - ++ | SetEnv - -- (1.2) | SSLListen - ++ | SSLPort - ++ | SystemGroup - ++ | TempDir - ++ | Timeout - -- (1.2) | UseNetworkDefault - ++ | User - ------------+----------------------------------------------------- \ No newline at end of file diff --git a/kdeprint/configure.in.in b/kdeprint/configure.in.in deleted file mode 100644 index 3165cc4c4..000000000 --- a/kdeprint/configure.in.in +++ /dev/null @@ -1,99 +0,0 @@ -AC_DEFUN([AC_CHECK_CUPS_VERSION], -[ -kde_save_cflags="$CFLAGS" -kde_save_libs="$LIBS" -LIBS="$all_libraries $USER_LDFLAGS $kde_cups_libs" -CFLAGS="$CFLAGS $all_includes $USER_INCLUDES" -AC_MSG_CHECKING(CUPS version >= $1) -kde_save_link=$ac_link -ac_link='${CC} $CFLAGS -o conftest conftest.c $LIBS 1>&5' -cat > conftest.c <<EOF -#include <cups/cups.h> -#include <stdio.h> -int main() -{ - if (CUPS_VERSION < -EOF -echo "$1" >> conftest.c -cat >> conftest.c <<EOF -) - printf("no\n"); - else - printf("yes\n"); -} -EOF -if AC_TRY_EVAL(ac_link) && test -x conftest; then - ac_have_new_cups=`./conftest` -else -dnl don't bail out if not found! -dnl AC_MSG_ERROR([Unable to compile test program. See config.log for more informations]) -dnl echo "configure: failed program was:" >&AC_FD_CC -dnl cat conftest.c >&AC_FD_CC - ac_have_new_cups="no" -fi -rm -f conftest* -ac_link="$kde_save_link" -CFLAGS="$kde_save_cflags" -LIBS="$kde_save_libs" -AC_MSG_RESULT($ac_have_new_cups) -]) - -dnl CUPS stuffs (to be changed) -ac_use_cups="yes" -ac_have_new_cups="yes" -ac_cups_libs=0 -CUPSSUBDIR= -LIB_CUPS= -AC_ARG_ENABLE(cups,[ --disable-cups disable CUPS support [default=auto]],ac_use_cups=$enableval, ac_use_cups=yes) -if test "$ac_use_cups" = "yes"; then - ac_CPPFLAGS_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $all_includes" - ac_LDFLAGS_save="$LDFLAGS" - LDFLAGS="$LDFLAGS $all_libraries" - kde_cups_config= - kde_cups_libs="-lcups" - AC_PATH_PROG(kde_cups_config,cups-config) - if test -n "$kde_cups_config"; then -# kde_cups_libs=`$kde_cups_config --libs` - kde_cups_libs="$kde_cups_libs" - else - AC_MSG_RESULT(cups-config not found, using default libraries: $kde_cups_libs. You should consider upgrading CUPS) - fi - KDE_CHECK_LIB(cups,cupsServer,[ac_cups_libs=1],[ac_cups_libs=0],[$LIBDL $LIBSOCKET]) - if test "$ac_cups_libs" = "0"; then - AC_MSG_WARN(CUPS library not found. CUPS support disabled) - ac_use_cups="no" - fi - if test "$ac_use_cups" = "yes"; then - dnl check existence of CUPS header files - ac_cups_headers=0 - AC_CHECK_HEADER(cups/cups.h,[ac_cups_headers=1]) - if test "$ac_cups_headers" = "0"; then - AC_MSG_WARN(CUPS headers not found. CUPS support disabled) - ac_use_cups="no" - else - dnl check that version is at least 1.1.9 - AC_CHECK_CUPS_VERSION(1.0109) - if test "$ac_have_new_cups" = "no"; then - AC_MSG_WARN(CUPS version too old. You should upgrade to version >= 1.1.9) - ac_use_cups="no" - fi - - dnl check if CUPS is at least 1.1.20 - ac_have_new_cups="no" - AC_CHECK_CUPS_VERSION(1.0120) - if test "$ac_have_new_cups" = "yes"; then - AC_DEFINE(HAVE_CUPS_NO_PWD_CACHE, 1, CUPS doesn't have password caching) - fi - fi - fi - LDFLAGS="$ac_LDFLAGS_save" - CPPFLAGS="$ac_CPPFLAGS_save" -fi -if test "$ac_use_cups" = "yes"; then - CUPSSUBDIR="cups" - LIB_CUPS="$kde_cups_libs" - AC_DEFINE(HAVE_CUPS, 1, [Defines if you have CUPS (Common UNIX Printing System)]) -fi -AM_CONDITIONAL(include_cups_SUBDIR, test -n "$CUPSSUBDIR") -AC_SUBST(LIB_CUPS) diff --git a/kdeprint/cups/CMakeLists.txt b/kdeprint/cups/CMakeLists.txt deleted file mode 100644 index 2166cc08f..000000000 --- a/kdeprint/cups/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_subdirectory( cupsdconf2 ) - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore/network - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile - ${CMAKE_SOURCE_DIR}/tdeprint - ${CMAKE_SOURCE_DIR}/tdeprint/management -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES cups.print DESTINATION ${DATA_INSTALL_DIR}/tdeprint/plugins ) -install( FILES preview.png preview-mini.png DESTINATION ${DATA_INSTALL_DIR}/tdeprint ) - - -#### tdeprint_cups ############################## - -set( target tdeprint_cups ) - -set( ${target}_SRCS - cupsinfos.cpp ipprequest.cpp kmcupsfactory.cpp - kmcupsjobmanager.cpp kmcupsmanager.cpp kmcupsuimanager.cpp - kmpropbanners.cpp kmwbanners.cpp kmwipp.cpp kmwippselect.cpp - kcupsprinterimpl.cpp kmcupsconfigwidget.cpp kmconfigcups.cpp - kmconfigcupsdir.cpp kmwippprinter.cpp kmwfax.cpp kmwquota.cpp - kmpropquota.cpp kmwusers.cpp kmpropusers.cpp kpschedulepage.cpp - image.cpp imagepreview.cpp imageposition.cpp kpimagepage.cpp - kptextpage.cpp kphpgl2page.cpp cupsaddsmb2.cpp - kmwother.cpp ippreportdlg.cpp kptagspage.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint_management-shared ${CUPS_LIBRARIES} - DESTINATION ${PLUGIN_INSTALL_DIR} -) - - -#### make_driver_db_cups ######################## - -set( target make_driver_db_cups ) - -set( ${target}_SRCS - make_driver_db_cups.c -) - -tde_add_executable( ${target} - SOURCES ${${target}_SRCS} - LINK driverparse-static tdefakes-shared ${ZLIB_LIBRARIES} ${DL_LIBRARIES} - DESTINATION ${BIN_INSTALL_DIR} -) - - -#### cupsdoprint ################################ - -set( target cupsdoprint ) - -set( ${target}_SRCS - cupsdoprint.c -) - -tde_add_executable( ${target} - SOURCES ${${target}_SRCS} - LINK tdefakes-shared ${CUPS_LIBRARIES} - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/kdeprint/cups/Makefile.am b/kdeprint/cups/Makefile.am deleted file mode 100644 index 6f3d7edec..000000000 --- a/kdeprint/cups/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -SUBDIRS = cupsdconf2 - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/kio -I$(top_srcdir)/kfile -I$(top_srcdir)/tdeprint -I$(top_srcdir)/tdeprint/management -I$(top_srcdir)/tdecore/network $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_cups.la - -tdeprint_cups_la_SOURCES = cupsinfos.cpp ipprequest.cpp kmcupsfactory.cpp kmcupsjobmanager.cpp \ - kmcupsmanager.cpp kmcupsuimanager.cpp kmpropbanners.cpp kmwbanners.cpp kmwipp.cpp \ - kmwippselect.cpp kcupsprinterimpl.cpp kmcupsconfigwidget.cpp \ - kmconfigcups.cpp kmconfigcupsdir.cpp kmwippprinter.cpp kmwfax.cpp kmwquota.cpp \ - kmpropquota.cpp kmwusers.cpp kmpropusers.cpp kpschedulepage.cpp image.cpp \ - imagepreview.cpp imageposition.cpp kpimagepage.cpp \ - kptextpage.cpp kphpgl2page.cpp cupsaddsmb2.cpp kmwother.cpp ippreportdlg.cpp \ - kptagspage.cpp -tdeprint_cups_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_cups_la_LIBADD = $(top_builddir)/tdeprint/management/libtdeprint_management.la $(LIB_KIO) $(LIB_CUPS) $(LIB_QT) $(LIB_KDEPRINT) $(LIB_KDECORE) $(LIB_KDEUI) -tdeprint_cups_la_METASOURCES = AUTO - -noinst_HEADERS = cupsinfos.h ipprequest.h kmcupsjobmanager.h kmcupsmanager.h kmcupsuimanager.h \ - kmpropbanners.h kmwbanners.h kmwipp.h kmwippselect.h kcupsprinterimpl.h \ - kmcupsconfigwidget.h kmconfigcups.h kmconfigcupsdir.h kmwippprinter.h kmwfax.h kmwquota.h \ - kmpropquota.h kmwusers.h kmpropusers.h kpschedulepage.h imagepreview.h imageposition.h \ - kpimagepage.h kptextpage.h kphpgl2page.h cupsaddsmb2.h \ - kmwother.h ippreportdlg.h kptagspage.h - -bin_PROGRAMS = make_driver_db_cups cupsdoprint -make_driver_db_cups_SOURCES = make_driver_db_cups.c -make_driver_db_cups_LDADD = ../libdriverparse.a $(top_builddir)/tdecore/libtdefakes.la $(LIBDL) $(LIBZ) -make_driver_db_cups_LDFLAGS = $(all_libraries) - -cupsdoprint_SOURCES = cupsdoprint.c -cupsdoprint_LDADD = $(LIB_CUPS) $(top_builddir)/tdecore/libtdefakes.la -cupsdoprint_LDFLAGS = $(all_libraries) - -entry_DATA = cups.print -entrydir = $(kde_datadir)/tdeprint/plugins - -misc_DATA = preview.png preview-mini.png -miscdir = $(kde_datadir)/tdeprint - -EXTRA_DIST = postscript.ppd.gz - -install-data-local: - if test -n "$(cups_modeldir)"; then \ - $(INSTALL_DATA) $(srcdir)/postscript.ppd.gz $(DESTDIR)$(cups_modeldir)/postscript.ppd.gz || true ;\ - fi - diff --git a/kdeprint/cups/configure.in.in b/kdeprint/cups/configure.in.in deleted file mode 100644 index b37ba67a1..000000000 --- a/kdeprint/cups/configure.in.in +++ /dev/null @@ -1,18 +0,0 @@ -dnl Whether to install the PostScript driver -AC_MSG_CHECKING([installation of PS driver needed]) -ac_cups_share_test="/usr/share/cups /usr/local/share/cups /opt/share/cups /opt/local/share/cups" -cups_modeldir="" -for d in $ac_cups_share_test; do - if test -d $d && test -d $d/model; then - cups_modeldir=$d/model - break - fi -done - -AC_SUBST(cups_modeldir) - -if test -n "$cups_modeldir"; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi diff --git a/kdeprint/cups/cups.print b/kdeprint/cups/cups.print deleted file mode 100644 index 03b2474ee..000000000 --- a/kdeprint/cups/cups.print +++ /dev/null @@ -1,68 +0,0 @@ -[KDE Print Entry] -PrintSystem=cups -Comment=CUPS (Common UNIX Print System) -Comment[af]=Cups (Gemeenskaplike Unix Druk Stelsel) -Comment[ar]=CUPS (نظام طباعة يونيكس الشائع) -Comment[az]=CUPS (Ãœmumi UNIX Çap Sistemi) -Comment[be]=CUPS (ÐÐ³ÑƒÐ»ÑŒÐ½Ð°Ñ ÑÑ–ÑÑ‚Ñма друку UNIX) -Comment[bn]=কাপà§à¦¸ (Common UNIX Print System) -Comment[ca]=CUPS (Sistema d'impressió comú de Unix) -Comment[cs]=CUPS (Common Unix Print System) -Comment[csb]=CUPS (Zbiérnô Systema Drëkù dlô Uniksa) -Comment[cy]=CUPS (Cysawd Argraffu UNIX Cyffredinol) -Comment[da]=CUPS (Common UNIX Print System = Fælles UNIX-udskriftssystem) -Comment[el]=CUPS (Κοινό σÏστημα εκτÏπωσης του UNIX) -Comment[eo]=CUPS (Kapabla Uniks-pressistemo) -Comment[es]=CUPS (sistema de impresión común para Unix) -Comment[eu]=CUPS (Common UNIX Print System) -Comment[fa]=CUPS)سیستم چاپ مشترک یونیکس( -Comment[fr]=CUPS (Common Unix Print System) -Comment[fy]=CUPS (Common Unix Print System) -Comment[gl]=CUPS (Sistema Comun de Impresión para UNIX) -Comment[he]=מערכת הדפסה נפוצה ליוניקס (CUPS) -Comment[hi]=CUPS (सामानà¥à¤¯ यूनिकà¥à¤¸ पà¥à¤°à¤¿à¤‚ट सिसà¥à¤Ÿà¤®) -Comment[hr]=CUPS (Common Unix Print System) -Comment[is]=CUPS (Common Unix Print System) -Comment[ja]=CUPS (Common UNIX Printing System) -Comment[ka]=CUPS (სáƒáƒ”რთრUnix ბეჭდვის სიტემáƒ) -Comment[kk]=CUPS (Common UNIX Print System) баÑып шығару жүйеÑÑ– -Comment[ko]=CUPS (공통 유닉스 ì¸ì‡„ 시스템) -Comment[lt]=CUPS (Bendra Unix Spausdinimo Sistema) -Comment[mn]=CUPS (ЮникÑын Ерөнхий Ð¥ÑвлÑÑ… СиÑтем) -Comment[mt]=CUPS (Common Unix Print System) -Comment[ne]=CUPS (साà¤à¤¾ UNIX मà¥à¤¦à¥à¤°à¤£ पà¥à¤°à¤£à¤¾à¤²à¥€) -Comment[nn]=CUPS («Common Unix Print System», utskriftssystem) -Comment[nso]=CUPS (System yago Swana ya Kgatiso ya UNIX) -Comment[pa]=CUPS (ਕਾਮਨ UNIX ਪà©à¨°à¨¿à©°à¨Ÿà¨° ਸਿਸਟਮ) -Comment[pl]=CUPS (Wspólny System Drukowania dla Uniksa) -Comment[pt]=CUPS (Common Unix Print System) -Comment[pt_BR]=Servidor de Impressão CUPS (Common Unix Print System) -Comment[ro]=CUPS (Sistem de tipărire Unix comun) -Comment[ru]=СиÑтема печати CUPS (Common Unix Print System) -Comment[rw]=CUPS (Sisitemu Rusange yo Gucapa ya UNIX ) -Comment[se]=CUPS («Common Unix Print System», Äálihanvuogádat) -Comment[sl]=CUPS (skupni tiskalniÅ¡ki sistem za Unix) -Comment[sr]=CUPS (Common Unix Print System) -Comment[sr@Latn]=CUPS (Common Unix Print System) -Comment[ss]=CUPS (Umshini lovamile wekushicelela we UNIX) -Comment[sv]=Cups (Common Unix print system) -Comment[ta]=CUPS (பொத௠யà¯à®©à®¿à®•à¯à®¸à¯ அசà¯à®šà¯à®¤à¯ தொகà¯à®¤à®¿) -Comment[te]=కెయà±à°ªà°¿à°Žà°¸à± (సామానà±à°¯ à°¯à±à°¨à°¿à°•à±à°¸à± à°ªà±à°°à°šà±à°°à°£ à°µà±à°¯à°µà°¸à±à°¥) -Comment[tg]=СиÑтемаи чопи CUPS (Common UNIX Print System) -Comment[th]=CUPS (ระบบà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¸žà¸·à¹‰à¸™à¸à¸²à¸™à¸‚องยูนิà¸à¸‹à¹Œ) -Comment[tr]=CUPS (Common Unix Print System - Genel Unix Yazdırma Sistemi) -Comment[tt]=CUPS atlı bastıru sisteme (Common UNIX Print System) -Comment[uz]=CUPS (UNIX uchun umumiy bosib chiqarish tizimi) -Comment[uz@cyrillic]=CUPS (UNIX учун умумий боÑиб чиқариш тизими) -Comment[ven]=CUPS (Maitele au phirintha a UNIX zwao) -Comment[vi]=CUPS (hệ thống in UNIX dùng chung) -Comment[wa]=CUPS (Comon Sistinme d' Imprimaedje po UNIX) -Comment[xh]=CUPS (Indlela Elula Yoshicilelo lwe UNIX) -Comment[zh_CN]=CUPS (通用 Unix 打å°ç³»ç»Ÿ) -Comment[zh_HK]=CUPS (通用 Unix 列å°ç³»çµ±) -Comment[zh_TW]=CUPS (通用 Unix 列å°ç³»çµ±) -Comment[zu]=CUPS (Isistimu Yokushicilela ye-Unix Eyejwayelekile) -DetectUris=service:/ipp,config:/cups/cupsd.conf -DetectPrecedence=10 -MimeTypes=application/postscript,application/pdf,image/gif,image/jpeg,image/png,image/x-bmp,image/x-xpm -PrimaryMimeType=application/postscript diff --git a/kdeprint/cups/cupsaddsmb2.cpp b/kdeprint/cups/cupsaddsmb2.cpp deleted file mode 100644 index ca40a10a7..000000000 --- a/kdeprint/cups/cupsaddsmb2.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsaddsmb2.h" -#include "cupsinfos.h" -#include "sidepixmap.h" - -#include <tqtimer.h> -#include <tqprogressbar.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqlineedit.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <tqmessagebox.h> -#include <tqfile.h> -#include <kio/passdlg.h> -#include <kdebug.h> -#include <kseparator.h> -#include <kactivelabel.h> -#include <tqwhatsthis.h> -#include <kpushbutton.h> -#include <kstdguiitem.h> - -#include <cups/cups.h> -#include <ctype.h> - -CupsAddSmb::CupsAddSmb(TQWidget *parent, const char *name) -: KDialog(parent, name) -{ - m_state = None; - m_status = false; - m_actionindex = 0; - connect(&m_proc, TQT_SIGNAL(receivedStdout(KProcess*,char*,int)), TQT_SLOT(slotReceived(KProcess*,char*,int))); - connect(&m_proc, TQT_SIGNAL(receivedStderr(KProcess*,char*,int)), TQT_SLOT(slotReceived(KProcess*,char*,int))); - connect(&m_proc, TQT_SIGNAL(processExited(KProcess*)), TQT_SLOT(slotProcessExited(KProcess*))); - - m_side = new SidePixmap(this); - m_doit = new TQPushButton(i18n("&Export"), this); - m_cancel = new KPushButton(KStdGuiItem::cancel(), this); - connect(m_cancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject())); - connect(m_doit, TQT_SIGNAL(clicked()), TQT_SLOT(slotActionClicked())); - m_bar = new TQProgressBar(this); - m_text = new KActiveLabel(this); - TQLabel *m_title = new TQLabel(i18n("Export Printer Driver to Windows Clients"), this); - setCaption(m_title->text()); - TQFont f(m_title->font()); - f.setBold(true); - m_title->setFont(f); - KSeparator *m_sep = new KSeparator(Qt::Horizontal, this); - m_textinfo = new TQLabel( this ); - m_logined = new TQLineEdit( this ); - m_passwded = new TQLineEdit( this ); - m_passwded->setEchoMode( TQLineEdit::Password ); - m_servered = new TQLineEdit( this ); - TQLabel *m_loginlab = new TQLabel( i18n( "&Username:" ), this ); - TQLabel *m_serverlab = new TQLabel( i18n( "&Samba server:" ), this ); - TQLabel *m_passwdlab = new TQLabel( i18n( "&Password:" ), this ); - m_loginlab->setBuddy( m_logined ); - m_serverlab->setBuddy( m_servered ); - m_passwdlab->setBuddy( m_passwded ); - - TQString txt = i18n( "<p><b>Samba server</b></p>" - "Adobe Windows PostScript driver files plus the CUPS printer PPD will be " - "exported to the <tt>[print$]</tt> special share of the Samba server (to change " - "the source CUPS server, use the <nobr><i>Configure Manager -> CUPS server</i></nobr> first). " - "The <tt>[print$]</tt> share must exist on the Samba side prior to clicking the " - "<b>Export</b> button below." ); - TQWhatsThis::add( m_serverlab, txt ); - TQWhatsThis::add( m_servered, txt ); - - txt = i18n( "<p><b>Samba username</b></p>" - "User needs to have write access to the <tt>[print$]</tt> share on the Samba server. " - "<tt>[print$]</tt> holds printer drivers prepared for download to Windows clients. " - "This dialog does not work for Samba servers configured with <tt>security = share</tt> " - "(but works fine with <tt>security = user</tt>)." ); - TQWhatsThis::add( m_loginlab, txt ); - TQWhatsThis::add( m_logined, txt ); - - txt = i18n( "<p><b>Samba password</b></p>" - "The Samba setting <tt>encrypt passwords = yes</tt> " - "(default) requires prior use of <tt>smbpasswd -a [username]</tt> command, " - "to create an encrypted Samba password and have Samba recognize it." ); - TQWhatsThis::add( m_passwdlab, txt ); - TQWhatsThis::add( m_passwded, txt ); - - TQHBoxLayout *l0 = new TQHBoxLayout(this, 10, 10); - TQVBoxLayout *l1 = new TQVBoxLayout(0, 0, 10); - l0->addWidget(m_side); - l0->addLayout(l1); - l1->addWidget(m_title); - l1->addWidget(m_sep); - l1->addWidget(m_text); - TQGridLayout *l3 = new TQGridLayout( 0, 3, 2, 0, 10 ); - l1->addLayout( TQT_TQLAYOUT(l3) ); - l3->addWidget( m_loginlab, 1, 0 ); - l3->addWidget( m_passwdlab, 2, 0 ); - l3->addWidget( m_serverlab, 0, 0 ); - l3->addWidget( m_logined, 1, 1 ); - l3->addWidget( m_passwded, 2, 1 ); - l3->addWidget( m_servered, 0, 1 ); - l3->setColStretch( 1, 1 ); - l1->addSpacing( 10 ); - l1->addWidget(m_bar); - l1->addWidget( m_textinfo ); - l1->addSpacing(30); - TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 10); - l1->addLayout(l2); - l2->addStretch(1); - l2->addWidget(m_doit); - l2->addWidget(m_cancel); - - m_logined->setText( CupsInfos::self()->login() ); - m_passwded->setText( CupsInfos::self()->password() ); - m_servered->setText( cupsServer() ); - - setMinimumHeight(400); -} - -CupsAddSmb::~CupsAddSmb() -{ -} - -void CupsAddSmb::slotActionClicked() -{ - if (m_state == None) - doExport(); - else if (m_proc.isRunning()) - m_proc.kill(); -} - -void CupsAddSmb::slotReceived(KProcess*, char *buf, int buflen) -{ - TQString line; - int index(0); - bool partial(false); - static bool incomplete(false); - - kdDebug(500) << "slotReceived()" << endl; - while (1) - { - // read a line - line = TQString::tqfromLatin1(""); - partial = true; - while (index < buflen) - { - TQChar c(buf[index++]); - if (c == '\n') - { - partial = false; - break; - } - else if (c.isPrint()) - line += c; - } - - if (line.isEmpty()) - { - kdDebug(500) << "NOTHING TO READ" << endl; - return; - } - - kdDebug(500) << "ANSWER = " << line << " (END = " << line.length() << ")" << endl; - if (!partial) - { - if (incomplete && m_buffer.count() > 0) - m_buffer[m_buffer.size()-1].append(line); - else - m_buffer << line; - incomplete = false; - kdDebug(500) << "COMPLETE LINE READ (" << m_buffer.count() << ")" << endl; - } - else - { - if (line.startsWith("smb:") || line.startsWith("rpcclient $")) - { - kdDebug(500) << "END OF ACTION" << endl; - checkActionStatus(); - if (m_status) - nextAction(); - else - { - // quit program - kdDebug(500) << "EXITING PROGRAM..." << endl; - m_proc.writeStdin("quit\n", 5); - kdDebug(500) << "SENT" << endl; - } - return; - } - else - { - if (incomplete && m_buffer.count() > 0) - m_buffer[m_buffer.size()-1].append(line); - else - m_buffer << line; - incomplete = true; - kdDebug(500) << "INCOMPLETE LINE READ (" << m_buffer.count() << ")" << endl; - } - } - } -} - -void CupsAddSmb::checkActionStatus() -{ - m_status = false; - // when checking the status, we need to take into account the - // echo of the command in the output buffer. - switch (m_state) - { - case None: - case Start: - m_status = true; - break; - case Copy: - m_status = (m_buffer.count() == 0); - break; - case MkDir: - m_status = (m_buffer.count() == 1 || m_buffer[1].find("ERRfilexists") != -1); - break; - case AddDriver: - case AddPrinter: - m_status = (m_buffer.count() == 1 || !m_buffer[1].startsWith("result")); - break; - } - kdDebug(500) << "ACTION STATUS = " << m_status << endl; -} - -void CupsAddSmb::nextAction() -{ - if (m_actionindex < (int)(m_actions.count())) - TQTimer::singleShot(1, this, TQT_SLOT(doNextAction())); -} - -void CupsAddSmb::doNextAction() -{ - m_buffer.clear(); - m_state = None; - if (m_proc.isRunning()) - { - TQCString s = m_actions[m_actionindex++].latin1(); - m_bar->setProgress(m_bar->progress()+1); - kdDebug(500) << "NEXT ACTION = " << s << endl; - if (s == "quit") - { - // do nothing - } - else if (s == "mkdir") - { - m_state = MkDir; - //m_text->setText(i18n("Creating directory %1").arg(m_actions[m_actionindex])); - m_textinfo->setText(i18n("Creating folder %1").arg(m_actions[m_actionindex])); - s.append(" ").append(m_actions[m_actionindex].latin1()); - m_actionindex++; - } - else if (s == "put") - { - m_state = Copy; - //m_text->setText(i18n("Uploading %1").arg(m_actions[m_actionindex+1])); - m_textinfo->setText(i18n("Uploading %1").arg(m_actions[m_actionindex+1])); - s.append(" ").append(TQFile::encodeName(m_actions[m_actionindex]).data()).append(" ").append(m_actions[m_actionindex+1].latin1()); - m_actionindex += 2; - } - else if (s == "adddriver") - { - m_state = AddDriver; - //m_text->setText(i18n("Installing driver for %1").arg(m_actions[m_actionindex])); - m_textinfo->setText(i18n("Installing driver for %1").arg(m_actions[m_actionindex])); - s.append(" \"").append(m_actions[m_actionindex].latin1()).append("\" \"").append(m_actions[m_actionindex+1].latin1()).append("\""); - m_actionindex += 2; - } - else if (s == "addprinter" || s == "setdriver") - { - m_state = AddPrinter; - //m_text->setText(i18n("Installing printer %1").arg(m_actions[m_actionindex])); - m_textinfo->setText(i18n("Installing printer %1").arg(m_actions[m_actionindex])); - TQCString dest = m_actions[m_actionindex].local8Bit(); - if (s == "addprinter") - s.append(" ").append(dest).append(" ").append(dest).append(" \"").append(dest).append("\" \"\""); - else - s.append(" ").append(dest).append(" ").append(dest); - m_actionindex++; - } - else - { - kdDebug(500) << "ACTION = unknown action" << endl; - m_proc.kill(); - return; - } - // send action - kdDebug(500) << "ACTION = " << s << endl; - s.append("\n"); - m_proc.writeStdin(s.data(), s.length()); - } -} - -void CupsAddSmb::slotProcessExited(KProcess*) -{ - kdDebug(500) << "PROCESS EXITED (" << m_state << ")" << endl; - if (m_proc.normalExit() && m_state != Start && m_status) - { - // last process went OK. If it was smbclient, then switch to rpcclient - if (tqstrncmp(m_proc.args().first(), "smbclient", 9) == 0) - { - doInstall(); - return; - } - else - { - m_doit->setEnabled(false); - m_cancel->setEnabled(true); - m_cancel->setText(i18n("&Close")); - m_cancel->setDefault(true); - m_cancel->setFocus(); - m_logined->setEnabled( true ); - m_servered->setEnabled( true ); - m_passwded->setEnabled( true ); - m_text->setText(i18n("Driver successfully exported.")); - m_bar->reset(); - m_textinfo->setText( TQString::null ); - return; - } - } - - if (m_proc.normalExit()) - { - showError( - i18n("Operation failed. Possible reasons are: permission denied " - "or invalid Samba configuration (see <a href=\"man:/cupsaddsmb\">" - "cupsaddsmb</a> manual page for detailed information, you need " - "<a href=\"http://www.cups.org\">CUPS</a> version 1.1.11 or higher). " - "You may want to try again with another login/password.")); - - } - else - { - showError(i18n("Operation aborted (process killed).")); - } -} - -void CupsAddSmb::showError(const TQString& msg) -{ - m_text->setText(i18n("<h3>Operation failed.</h3><p>%1</p>").arg(msg)); - m_cancel->setEnabled(true); - m_logined->setEnabled( true ); - m_servered->setEnabled( true ); - m_passwded->setEnabled( true ); - m_doit->setText(i18n("&Export")); - m_state = None; -} - -bool CupsAddSmb::exportDest(const TQString &dest, const TQString& datadir) -{ - CupsAddSmb dlg; - dlg.m_dest = dest; - dlg.m_datadir = datadir; - dlg.m_text->setText( - i18n( "You are about to prepare the <b>%1</b> driver to be " - "shared out to Windows clients through Samba. This operation " - "requires the <a href=\"http://www.adobe.com/products/printerdrivers/main.html\">Adobe PostScript Driver</a>, a recent version of " - "Samba 2.2.x and a running SMB service on the target server. " - "Click <b>Export</b> to start the operation. Read the <a href=\"man:/cupsaddsmb\">cupsaddsmb</a> " - "manual page in Konqueror or type <tt>man cupsaddsmb</tt> in a " - "console window to learn more about this functionality." ).arg( dest ) ); - dlg.exec(); - return dlg.m_status; -} - -bool CupsAddSmb::doExport() -{ - m_status = false; - m_state = None; - - if (!TQFile::exists(m_datadir+"/drivers/ADOBEPS5.DLL") || - !TQFile::exists(m_datadir+"/drivers/ADOBEPS4.DRV")) - { - showError( - i18n("Some driver files are missing. You can get them on " - "<a href=\"http://www.adobe.com\">Adobe</a> web site. " - "See <a href=\"man:/cupsaddsmb\">cupsaddsmb</a> manual " - "page for more details (you need <a href=\"http://www.cups.org\">CUPS</a> " - "version 1.1.11 or higher).")); - return false; - } - - m_bar->setTotalSteps(18); - m_bar->setProgress(0); - //m_text->setText(i18n("<p>Preparing to upload driver to host <b>%1</b>").arg(m_servered->text())); - m_textinfo->setText(i18n("Preparing to upload driver to host %1").arg(m_servered->text())); - m_cancel->setEnabled(false); - m_logined->setEnabled( false ); - m_servered->setEnabled( false ); - m_passwded->setEnabled( false ); - m_doit->setText(i18n("&Abort")); - - const char *ppdfile; - - if ((ppdfile = cupsGetPPD(m_dest.local8Bit())) == NULL) - { - showError(i18n("The driver for printer <b>%1</b> could not be found.").arg(m_dest)); - return false; - } - - m_actions.clear(); - m_actions << "mkdir" << "W32X86"; - m_actions << "put" << ppdfile << "W32X86/"+m_dest+".PPD"; - m_actions << "put" << m_datadir+"/drivers/ADOBEPS5.DLL" << "W32X86/ADOBEPS5.DLL"; - m_actions << "put" << m_datadir+"/drivers/ADOBEPSU.DLL" << "W32X86/ADOBEPSU.DLL"; - m_actions << "put" << m_datadir+"/drivers/ADOBEPSU.HLP" << "W32X86/ADOBEPSU.HLP"; - m_actions << "mkdir" << "WIN40"; - m_actions << "put" << ppdfile << "WIN40/"+m_dest+".PPD"; - m_actions << "put" << m_datadir+"/drivers/ADFONTS.MFM" << "WIN40/ADFONTS.MFM"; - m_actions << "put" << m_datadir+"/drivers/ADOBEPS4.DRV" << "WIN40/ADOBEPS4.DRV"; - m_actions << "put" << m_datadir+"/drivers/ADOBEPS4.HLP" << "WIN40/ADOBEPS4.HLP"; - m_actions << "put" << m_datadir+"/drivers/DEFPRTR2.PPD" << "WIN40/DEFPRTR2.PPD"; - m_actions << "put" << m_datadir+"/drivers/ICONLIB.DLL" << "WIN40/ICONLIB.DLL"; - m_actions << "put" << m_datadir+"/drivers/PSMON.DLL" << "WIN40/PSMON.DLL"; - m_actions << "quit"; - - m_proc.clearArguments(); - m_proc << "smbclient" << TQString::tqfromLatin1("//")+m_servered->text()+"/print$"; - return startProcess(); -} - -bool CupsAddSmb::doInstall() -{ - m_status = false; - m_state = None; - - m_actions.clear(); - m_actions << "adddriver" << "Windows NT x86" << m_dest+":ADOBEPS5.DLL:"+m_dest+".PPD:ADOBEPSU.DLL:ADOBEPSU.HLP:NULL:RAW:NULL"; - // seems to be wrong with newer versions of Samba - //m_actions << "addprinter" << m_dest; - m_actions << "adddriver" << "Windows 4.0" << m_dest+":ADOBEPS4.DRV:"+m_dest+".PPD:NULL:ADOBEPS4.HLP:PSMON.DLL:RAW:ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL"; - // seems to be ok with newer versions of Samba - m_actions << "setdriver" << m_dest; - m_actions << "quit"; - - //m_text->setText(i18n("Preparing to install driver on host <b>%1</b>").arg(m_servered->text())); - m_textinfo->setText(i18n("Preparing to install driver on host %1").arg(m_servered->text())); - - m_proc.clearArguments(); - m_proc << "rpcclient" << m_servered->text(); - return startProcess(); -} - -bool CupsAddSmb::startProcess() -{ - m_proc << "-d" << "0" << "-N" << "-U"; - if (m_passwded->text().isEmpty()) - m_proc << m_logined->text(); - else - m_proc << m_logined->text()+"%"+m_passwded->text(); - m_state = Start; - m_actionindex = 0; - m_buffer.clear(); - kdDebug(500) << "PROCESS STARTED = " << m_proc.args()[0] << endl; - return m_proc.start(KProcess::NotifyOnExit, KProcess::All); -} - -#include "cupsaddsmb2.moc" diff --git a/kdeprint/cups/cupsaddsmb2.h b/kdeprint/cups/cupsaddsmb2.h deleted file mode 100644 index 84166f53c..000000000 --- a/kdeprint/cups/cupsaddsmb2.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSADDSMB_H -#define CUPSADDSMB_H - -#include <tqobject.h> -#include <tqstringlist.h> -#include <kprocess.h> -#include <kdialog.h> - -class TQProgressBar; -class SidePixmap; -class TQPushButton; -class TQLabel; -class KActiveLabel; -class TQLineEdit; - -class CupsAddSmb : public KDialog -{ - Q_OBJECT - -public: - enum State { None, Start, MkDir, Copy, AddDriver, AddPrinter }; - CupsAddSmb(TQWidget *parent = 0, const char *name = 0); - ~CupsAddSmb(); - - static bool exportDest(const TQString& dest, const TQString& datadir); - -protected slots: - void slotReceived(KProcess*, char*, int); - void doNextAction(); - void slotProcessExited(KProcess*); - void slotActionClicked(); - -protected: - void checkActionStatus(); - void nextAction(); - bool startProcess(); - bool doExport(); - bool doInstall(); - void showError(const TQString& msg); - -private: - KProcess m_proc; - TQStringList m_buffer; - int m_state; - TQStringList m_actions; - int m_actionindex; - bool m_status; - TQProgressBar *m_bar; - TQString m_dest; - SidePixmap *m_side; - TQPushButton *m_doit, *m_cancel; - KActiveLabel *m_text; - TQLabel *m_textinfo; - TQLineEdit *m_logined, *m_passwded, *m_servered; - TQString m_datadir; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/CMakeLists.txt b/kdeprint/cups/cupsdconf2/CMakeLists.txt deleted file mode 100644 index ceee1bc47..000000000 --- a/kdeprint/cups/cupsdconf2/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES - kde_logo.png cups_logo.png cupsd.conf.template - DESTINATION ${DATA_INSTALL_DIR}/tdeprint ) - - -#### cupsdconf ################################## - -set( target cupsdconf ) - -set( ${target}_SRCS - cupsdconf.cpp cupsddialog.cpp cupsdpage.cpp cupsdcomment.cpp - cupsdsplash.cpp cupsdserverpage.cpp cupsdlogpage.cpp - cupsdjobspage.cpp cupsdfilterpage.cpp qdirlineedit.cpp - cupsddirpage.cpp portdialog.cpp cupsdnetworkpage.cpp - editlist.cpp cupsdbrowsingpage.cpp browsedialog.cpp - cupsdsecuritypage.cpp locationdialog.cpp addressdialog.cpp - cups-util.c qdirmultilineedit.cpp sizewidget.cpp main.cpp -) - -tde_add_tdeinit_executable( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK kio-shared ${CUPS_LIBRARIES} -) diff --git a/kdeprint/cups/cupsdconf2/Makefile.am b/kdeprint/cups/cupsdconf2/Makefile.am deleted file mode 100644 index 434af6a3c..000000000 --- a/kdeprint/cups/cupsdconf2/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -#$Id$ - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/kio -I$(top_srcdir)/kfile $(all_includes) - -bin_PROGRAMS = -lib_LTLIBRARIES = -tdeinit_LTLIBRARIES = cupsdconf.la - -# library creation -cupsdconf_la_SOURCES = cupsdconf.cpp cupsddialog.cpp cupsdpage.cpp cupsdcomment.cpp cupsdsplash.cpp \ - cupsdserverpage.cpp cupsdlogpage.cpp cupsdjobspage.cpp cupsdfilterpage.cpp \ - qdirlineedit.cpp cupsddirpage.cpp portdialog.cpp cupsdnetworkpage.cpp \ - editlist.cpp cupsdbrowsingpage.cpp browsedialog.cpp cupsdsecuritypage.cpp \ - locationdialog.cpp addressdialog.cpp cups-util.c \ - qdirmultilineedit.cpp sizewidget.cpp main.cpp -cupsdconf_la_METASOURCES = AUTO -cupsdconf_la_LDFLAGS = -avoid-version -module $(all_libraries) $(KDE_RPATH) -cupsdconf_la_LIBADD = $(LIB_KIO) $(LIB_CUPS) $(LIB_QT) $(LIB_KDEUI) $(LIB_KDECORE) - -noinst_HEADERS = cupsdconf.h cupsdpage.h cupsddialog.h cupsdcomment.h cupsdsplash.h \ - cupsdserverpage.h cupsdlogpage.h cupsdjobspage.h cupsdfilterpage.h \ - qdirlineedit.h cupsddirpage.h portdialog.h cupsdnetworkpage.h \ - editlist.h cupsdbrowsingpage.h browsedialog.h cupsdsecuritypage.h \ - locationdialog.h addressdialog.h cups-util.h qdirmultilineedit.h \ - sizewidget.h - -# Data -cupsdconfdata_DATA = kde_logo.png cups_logo.png cupsd.conf.template -cupsdconfdatadir = $(kde_datadir)/tdeprint - -# Translations -messages: - perl cupsdcomment.pl < cupsd.conf.template > cupsd.conf.template.txt - $(XGETTEXT) *.cpp -o $(podir)/cupsdconf.pot - rm -f cupsd.conf.template.txt diff --git a/kdeprint/cups/cupsdconf2/addressdialog.cpp b/kdeprint/cups/cupsdconf2/addressdialog.cpp deleted file mode 100644 index fab6a6fba..000000000 --- a/kdeprint/cups/cupsdconf2/addressdialog.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "addressdialog.h" - -#include <tqcombobox.h> -#include <tqlineedit.h> -#include <tqlabel.h> -#include <tqlayout.h> - -#include <klocale.h> - -AddressDialog::AddressDialog(TQWidget *parent, const char *name) - : KDialogBase(Swallow, i18n("ACL Address"), Ok|Cancel, Ok, parent, name, true, true) -{ - TQWidget *w = new TQWidget(this); - type_ = new TQComboBox(w); - address_ = new TQLineEdit(w); - - type_->insertItem(i18n("Allow")); - type_->insertItem(i18n("Deny")); - - TQLabel *l1 = new TQLabel(i18n("Type:"), w); - TQLabel *l2 = new TQLabel(i18n("Address:"), w); - - TQGridLayout *m1 = new TQGridLayout(w, 2, 2, 0, 5); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(type_, 0, 1); - m1->addWidget(address_, 1, 1); - - setMainWidget(w); - resize(300, 100); -} - -TQString AddressDialog::addressString() -{ - TQString s; - if (type_->currentItem() == 0) - s.append("Allow "); - else - s.append("Deny "); - if (address_->text().isEmpty()) - s.append("All"); - else - s.append(address_->text()); - return s; -} - -TQString AddressDialog::newAddress(TQWidget *parent) -{ - AddressDialog dlg(parent); - if (dlg.exec()) - return dlg.addressString(); - else - return TQString::null; -} - -TQString AddressDialog::editAddress(const TQString& addr, TQWidget *parent) -{ - AddressDialog dlg(parent); - int p = addr.find(' '); - if (p != -1) - { - dlg.type_->setCurrentItem(addr.left(p).lower() == "deny" ? 1 : 0); - dlg.address_->setText(addr.mid(p+1)); - } - if (dlg.exec()) - return dlg.addressString(); - else - return TQString::null; -} diff --git a/kdeprint/cups/cupsdconf2/addressdialog.h b/kdeprint/cups/cupsdconf2/addressdialog.h deleted file mode 100644 index 7fdb6fb6f..000000000 --- a/kdeprint/cups/cupsdconf2/addressdialog.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 ADDRESSDIALOG_H -#define ADDRESSDIALOG_H - -#include <kdialogbase.h> - -class TQComboBox; -class TQLineEdit; - -class AddressDialog : public KDialogBase -{ -public: - AddressDialog(TQWidget *parent = 0, const char *name = 0); - - TQString addressString(); - static TQString newAddress(TQWidget *parent = 0); - static TQString editAddress(const TQString& s, TQWidget *parent = 0); - -private: - TQComboBox *type_; - TQLineEdit *address_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/browsedialog.cpp b/kdeprint/cups/cupsdconf2/browsedialog.cpp deleted file mode 100644 index b337eb883..000000000 --- a/kdeprint/cups/cupsdconf2/browsedialog.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "browsedialog.h" -#include "cupsdconf.h" - -#include <tqlineedit.h> -#include <tqpushbutton.h> -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <tqregexp.h> - -#include <klocale.h> - -BrowseDialog::BrowseDialog(TQWidget *parent, const char *name) - : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true) -{ - TQWidget *dummy = new TQWidget(this); - setMainWidget(dummy); - type_ = new TQComboBox(dummy); - from_ = new TQLineEdit(dummy); - to_ = new TQLineEdit(dummy); - type_->insertItem(i18n("Send")); - type_->insertItem(i18n("Allow")); - type_->insertItem(i18n("Deny")); - type_->insertItem(i18n("Relay")); - type_->insertItem(i18n("Poll")); - - TQLabel *l1 = new TQLabel(i18n("Type:"), dummy); - TQLabel *l2 = new TQLabel(i18n("From:"), dummy); - TQLabel *l3 = new TQLabel(i18n("To:"), dummy); - - TQGridLayout *m1 = new TQGridLayout(dummy, 3, 2, 0, 5); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight); - m1->addWidget(type_, 0, 1); - m1->addWidget(from_, 1, 1); - m1->addWidget(to_, 2, 1); - - connect(type_, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged(int))); - slotTypeChanged(type_->currentItem()); - - setCaption(i18n("Browse Address")); - resize(250, 100); -} - -TQString BrowseDialog::addressString() -{ - TQString s; - switch (type_->currentItem()) - { - case 0: - s.append("Send"); - break; - case 1: - s.append("Allow"); - break; - case 2: - s.append("Deny"); - break; - case 3: - s.append("Relay"); - break; - case 4: - s.append("Poll"); - break; - } - if (from_->isEnabled()) - s.append(" ").append(from_->text()); - if (to_->isEnabled()) - s.append(" ").append(to_->text()); - return s; -} - -void BrowseDialog::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(type_, conf->comments_.toolTip("browsetype")); -} - -TQString BrowseDialog::newAddress(TQWidget *parent, CupsdConf *conf) -{ - BrowseDialog dlg(parent); - dlg.setInfos(conf); - if (dlg.exec()) - { - return dlg.addressString(); - } - return TQString::null; -} - -TQString BrowseDialog::editAddress(const TQString& s, TQWidget *parent, CupsdConf *conf) -{ - BrowseDialog dlg(parent); - dlg.setInfos(conf); - TQStringList l = TQStringList::split(TQRegExp("\\s"), s, false); - if (l.count() > 1) - { - if (l[0] == "Send") dlg.type_->setCurrentItem(0); - else if (l[0] == "Allow") dlg.type_->setCurrentItem(1); - else if (l[0] == "Deny") dlg.type_->setCurrentItem(2); - else if (l[0] == "Relay") dlg.type_->setCurrentItem(3); - else if (l[0] == "Poll") dlg.type_->setCurrentItem(4); - dlg.slotTypeChanged(dlg.type_->currentItem()); - int index(1); - if (dlg.from_->isEnabled()) - dlg.from_->setText(l[index++]); - if (dlg.to_->isEnabled()) - dlg.to_->setText(l[index]); - } - if (dlg.exec()) - { - return dlg.addressString(); - } - return TQString::null; -} - -void BrowseDialog::slotTypeChanged(int index) -{ - bool useFrom(true), useTo(true); - switch (index) - { - case 0: useFrom = false; break; - case 1: - case 4: - case 2: useTo = false; break; - } - from_->setEnabled(useFrom); - to_->setEnabled(useTo); -} - -#include "browsedialog.moc" diff --git a/kdeprint/cups/cupsdconf2/browsedialog.h b/kdeprint/cups/cupsdconf2/browsedialog.h deleted file mode 100644 index 8db12bc34..000000000 --- a/kdeprint/cups/cupsdconf2/browsedialog.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 BROWSEDIALOG_H -#define BROWSEDIALOG_H - -#include <kdialogbase.h> - -class TQLineEdit; -class TQComboBox; -struct CupsdConf; - -class BrowseDialog : public KDialogBase -{ - Q_OBJECT - -public: - BrowseDialog(TQWidget *parent = 0, const char *name = 0); - - TQString addressString(); - void setInfos(CupsdConf*); - static TQString newAddress(TQWidget *parent = 0, CupsdConf *conf = 0); - static TQString editAddress(const TQString& s, TQWidget *parent = 0, CupsdConf *conf = 0); - -protected slots: - void slotTypeChanged(int); - -private: - TQComboBox *type_; - TQLineEdit *from_, *to_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cups-util.c b/kdeprint/cups/cupsdconf2/cups-util.c deleted file mode 100644 index eadd6b629..000000000 --- a/kdeprint/cups/cupsdconf2/cups-util.c +++ /dev/null @@ -1,557 +0,0 @@ -#include <stdio.h> -#include <cups/ipp.h> -#include <cups/http.h> -#include <cups/cups.h> -#include <stdlib.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <unistd.h> - -#define CUPS_SERVERROOT "/etc/cups" -static http_t *cups_server; -static ipp_status_t last_error; -static char authstring[HTTP_MAX_VALUE]; -static char pwdstring[33]; -static int cups_local_auth(http_t *http); - -const char* cupsGetConf( void ); -int cupsPutConf( const char* ); - -const char * /* O - Filename for PPD file */ -cupsGetConf(void) -{ - int fd; /* PPD file */ - int bytes; /* Number of bytes read */ - char buffer[8192]; /* Buffer for file */ - char resource[HTTP_MAX_URI]; /* Resource name */ - const char *password; /* Password string */ - char realm[HTTP_MAX_VALUE], /* realm="xyz" string */ - nonce[HTTP_MAX_VALUE], /* nonce="xyz" string */ - plain[255], /* Plaintext username:password */ - encode[512]; /* Encoded username:password */ - http_status_t status; /* HTTP status from server */ - char prompt[1024]; /* Prompt string */ - int digest_tries; /* Number of tries with Digest */ - static char filename[HTTP_MAX_URI]; /* Local filename */ -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - const char *fqdn = 0; -#else - char fqdn[ HTTP_MAX_URI ]; /* Server name buffer */ -#endif - - - /* - * Connect to the correct server as needed... - */ - - if ((cups_server = httpConnectEncrypt(cupsServer(), ippPort(), - cupsEncryption())) == NULL) - { - last_error = IPP_SERVICE_UNAVAILABLE; - return (NULL); - } - - /* - * Get a temp file... - */ - - if ((fd = cupsTempFd(filename, sizeof(filename))) < 0) - { - /* - * Can't open file; close the server connection and return NULL... - */ - - httpFlush(cups_server); - httpClose(cups_server); - cups_server = NULL; - return (NULL); - } - - /* - * And send a request to the HTTP server... - */ - - snprintf(resource, sizeof(resource), "/admin/conf/cupsd.conf"); - - digest_tries = 0; - - do - { - httpClearFields(cups_server); - httpSetField(cups_server, HTTP_FIELD_HOST, cupsServer()); - httpSetField(cups_server, HTTP_FIELD_AUTHORIZATION, authstring); - - if (httpGet(cups_server, resource)) - { - if (httpReconnect(cups_server)) - { - status = HTTP_ERROR; - break; - } - else - { - status = HTTP_UNAUTHORIZED; - continue; - } - } - - while ((status = httpUpdate(cups_server)) == HTTP_CONTINUE); - - if (status == HTTP_UNAUTHORIZED) - { - const char *www_authenticate; - fprintf(stderr,"cupsGetConf: unauthorized...\n"); - - /* - * Flush any error message... - */ - - httpFlush(cups_server); - - /* - * See if we can do local authentication... - */ - - if (cups_local_auth(cups_server)) - continue; - - /* - * See if we should retry the current digest password... - */ - -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - www_authenticate = cups_server->fields[HTTP_FIELD_WWW_AUTHENTICATE]; -#else - www_authenticate = httpGetField( cups_server, HTTP_FIELD_WWW_AUTHENTICATE ); -#endif - if (strncmp(www_authenticate, "Basic", 5) == 0 || - digest_tries > 1 || !pwdstring[0]) - { - /* - * Nope - get a password from the user... - */ -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - fqdn = cups_server->hostname; -#else - httpGetHostname( cups_server, fqdn, sizeof( fqdn ) ); -#endif - - snprintf(prompt, sizeof(prompt), "Password for %s on %s? ", cupsUser(), fqdn ); - - if ((password = cupsGetPassword(prompt)) == NULL) - break; - if (!password[0]) - break; - - strncpy(pwdstring, password, sizeof(pwdstring) - 1); - pwdstring[sizeof(pwdstring) - 1] = '\0'; - - digest_tries = 0; - } - else - digest_tries ++; - - /* - * Got a password; encode it for the server... - */ - -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - www_authenticate = cups_server->fields[HTTP_FIELD_WWW_AUTHENTICATE]; -#else - www_authenticate = httpGetField( cups_server, HTTP_FIELD_WWW_AUTHENTICATE ); -#endif - if (strncmp(www_authenticate, "Basic", 5) == 0) - { - /* - * Basic authentication... - */ - - snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring); -#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 - httpEncode64_2(encode, sizeof(encode), plain, sizeof(plain)); -#else - httpEncode64(encode, plain); -#endif - snprintf(authstring, sizeof(authstring), "Basic %s", encode); - } - else - { - /* - * Digest authentication... - */ - - httpGetSubField(cups_server, HTTP_FIELD_WWW_AUTHENTICATE, "realm", realm); - httpGetSubField(cups_server, HTTP_FIELD_WWW_AUTHENTICATE, "nonce", nonce); - - httpMD5(cupsUser(), realm, pwdstring, encode); - httpMD5Final(nonce, "GET", resource, encode); - snprintf(authstring, sizeof(authstring), - "Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", " - "response=\"%s\"", cupsUser(), realm, nonce, encode); - } - - continue; - } -#ifdef HAVE_LIBSSL - else if (status == HTTP_UPGRADE_REQUIRED) - { - /* - * Flush any error message... - */ - - httpFlush(cups_server); - - /* - * Upgrade with encryption... - */ - - httpEncryption(cups_server, HTTP_ENCRYPT_REQUIRED); - - /* - * Try again, this time with encryption enabled... - */ - - continue; - } -#endif /* HAVE_LIBSSL */ - } - while (status == HTTP_UNAUTHORIZED || status == HTTP_UPGRADE_REQUIRED); - - /* - * See if we actually got the file or an error... - */ - - if (status != HTTP_OK) - { - close(fd); - unlink(filename); - httpFlush(cups_server); - httpClose(cups_server); - cups_server = NULL; - return (NULL); - } - - /* - * OK, we need to copy the file... - */ - - while ((bytes = -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - httpRead -#else - httpRead2 -#endif - (cups_server, buffer, sizeof(buffer))) > 0) - { - write(fd, buffer, bytes); - } - - close(fd); - - return (filename); -} - -int /* O - Status of operation */ -cupsPutConf(const char *name) /* I - Name of the config file to send */ -{ - int fd; /* PPD file */ - int bytes; /* Number of bytes read */ - char buffer[8192]; /* Buffer for file */ - char resource[HTTP_MAX_URI]; /* Resource name */ - const char *password; /* Password string */ - char realm[HTTP_MAX_VALUE], /* realm="xyz" string */ - nonce[HTTP_MAX_VALUE], /* nonce="xyz" string */ - plain[255], /* Plaintext username:password */ - encode[512]; /* Encoded username:password */ - http_status_t status; /* HTTP status from server */ - char prompt[1024]; /* Prompt string */ - int digest_tries; /* Number of tries with Digest */ -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - const char *fqdn = 0; -#else - char fqdn[ HTTP_MAX_URI ]; /* Server name buffer */ -#endif - - if (name == NULL) - return 0; - - /* - * Connect to the correct server as needed... - */ - - if ((cups_server = httpConnectEncrypt(cupsServer(), ippPort(), - cupsEncryption())) == NULL) - { - last_error = IPP_SERVICE_UNAVAILABLE; - return 0; - } - - /* - * Open the local config file... - */ - - if ((fd = open(name, O_RDONLY)) < 0) - { - /* - * Can't open file; close the server connection and return NULL... - */ - - httpFlush(cups_server); - httpClose(cups_server); - cups_server = NULL; - return 0; - } - - /* - * And send a request to the HTTP server... - */ - - strncpy(resource, "/admin/conf/cupsd.conf", sizeof(resource)); - - digest_tries = 0; - - do - { - httpClearFields(cups_server); - httpSetField(cups_server, HTTP_FIELD_HOST, cupsServer()); - httpSetField(cups_server, HTTP_FIELD_AUTHORIZATION, authstring); - httpSetField(cups_server, HTTP_FIELD_TRANSFER_ENCODING, "chunked"); - - if (httpPut(cups_server, resource)) - { - if (httpReconnect(cups_server)) - { - status = HTTP_ERROR; - break; - } - else - { - status = HTTP_UNAUTHORIZED; - continue; - } - } - - /* send the file now */ - lseek(fd, 0, SEEK_SET); - status = HTTP_CONTINUE; - while ((bytes = read(fd, buffer, sizeof(buffer))) > 0) - if (httpCheck(cups_server)) - { - if ((status = httpUpdate(cups_server)) != HTTP_CONTINUE) - break; - } - else -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - httpWrite -#else - httpWrite2 -#endif - (cups_server, buffer, bytes); - - if (status == HTTP_CONTINUE) - { -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - httpWrite -#else - httpWrite2 -#endif - (cups_server, buffer, 0); - while ((status = httpUpdate(cups_server)) == HTTP_CONTINUE); - } - - if (status == HTTP_UNAUTHORIZED) - { - const char *www_authenticate; - fprintf(stderr,"cupsPutConf: unauthorized..."); - - /* - * Flush any error message... - */ - - httpFlush(cups_server); - - /* - * See if we can do local authentication... - */ - - if (cups_local_auth(cups_server)) - continue; - - /* - * See if we should retry the current digest password... - */ - -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - www_authenticate = cups_server->fields[HTTP_FIELD_WWW_AUTHENTICATE]; -#else - www_authenticate = httpGetField( cups_server, HTTP_FIELD_WWW_AUTHENTICATE ); -#endif - if (strncmp(www_authenticate, "Basic", 5) == 0 || - digest_tries > 1 || !pwdstring[0]) - { - /* - * Nope - get a password from the user... - */ - - -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - fqdn = cups_server->hostname; -#else - httpGetHostname( cups_server, fqdn, sizeof( fqdn ) ); -#endif - snprintf(prompt, sizeof(prompt), "Password for %s on %s? ", cupsUser(), fqdn ); - - if ((password = cupsGetPassword(prompt)) == NULL) - break; - if (!password[0]) - break; - - strncpy(pwdstring, password, sizeof(pwdstring) - 1); - pwdstring[sizeof(pwdstring) - 1] = '\0'; - - digest_tries = 0; - } - else - digest_tries ++; - - /* - * Got a password; encode it for the server... - */ - -#if CUPS_VERSION_MAJOR - 0 <= 1 && CUPS_VERSION_MINOR - 0 < 2 - www_authenticate = cups_server->fields[HTTP_FIELD_WWW_AUTHENTICATE]; -#else - www_authenticate = httpGetField( cups_server, HTTP_FIELD_WWW_AUTHENTICATE ); -#endif - if (strncmp(www_authenticate, "Basic", 5) == 0) - { - /* - * Basic authentication... - */ - - snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring); -#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 - httpEncode64_2(encode, sizeof(encode), plain, sizeof(plain)); -#else - httpEncode64(encode, plain); -#endif - snprintf(authstring, sizeof(authstring), "Basic %s", encode); - } - else - { - /* - * Digest authentication... - */ - - httpGetSubField(cups_server, HTTP_FIELD_WWW_AUTHENTICATE, "realm", realm); - httpGetSubField(cups_server, HTTP_FIELD_WWW_AUTHENTICATE, "nonce", nonce); - - httpMD5(cupsUser(), realm, pwdstring, encode); - httpMD5Final(nonce, "GET", resource, encode); - snprintf(authstring, sizeof(authstring), - "Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", " - "response=\"%s\"", cupsUser(), realm, nonce, encode); - } - - continue; - } -#ifdef HAVE_LIBSSL - else if (status == HTTP_UPGRADE_REQUIRED) - { - /* - * Flush any error message... - */ - - httpFlush(cups_server); - - /* - * Upgrade with encryption... - */ - - httpEncryption(cups_server, HTTP_ENCRYPT_REQUIRED); - - /* - * Try again, this time with encryption enabled... - */ - - continue; - } -#endif /* HAVE_LIBSSL */ - } - while (status == HTTP_UNAUTHORIZED || status == HTTP_UPGRADE_REQUIRED); - - /* - * See if we actually got the file or an error... - */ - - if (status != HTTP_CREATED) - { - httpFlush(cups_server); - httpClose(cups_server); - cups_server = NULL; - close(fd); - return 0; - } - - close(fd); - - return 1; -} - -static int /* O - 1 if available, 0 if not */ -cups_local_auth(http_t *http) /* I - Connection */ -{ - int pid; /* Current process ID */ - FILE *fp; /* Certificate file */ - char filename[1024], /* Certificate filename */ - certificate[33];/* Certificate string */ - const char *root; /* Server root directory */ - - - /* - * See if we are accessing localhost... - the struct has changed in newer versions - PiggZ (adam@piggz.co.uk) - */ -#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 - if (!httpAddrLocalhost(http)) -#else - if (ntohl(*(int*)&http->hostaddr.sin_addr) != 0x7f000001 && - strcasecmp(http->hostname, "localhost") != 0) -#endif - return (0); - - /* - * Try opening a certificate file for this PID. If that fails, - * try the root certificate... - */ - - if ((root = getenv("CUPS_SERVERROOT")) == NULL) - root = CUPS_SERVERROOT; - - pid = getpid(); - snprintf(filename, sizeof(filename), "%s/certs/%d", root, pid); - if ((fp = fopen(filename, "r")) == NULL && pid > 0) - { - snprintf(filename, sizeof(filename), "%s/certs/0", root); - fp = fopen(filename, "r"); - } - - if (fp == NULL) - return (0); - - /* - * Read the certificate from the file... - */ - - fgets(certificate, sizeof(certificate), fp); - fclose(fp); - - /* - * Set the authorization string and return... - */ - - snprintf(authstring, sizeof(authstring), "Local %s", certificate); - - return (1); -} - diff --git a/kdeprint/cups/cupsdconf2/cups-util.h b/kdeprint/cups/cupsdconf2/cups-util.h deleted file mode 100644 index 9c23c0c5e..000000000 --- a/kdeprint/cups/cupsdconf2/cups-util.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPS_UTIL_H -#define CUPS_UTIL_H - -const char* cupsGetConf(void); -int cupsPutConf(const char *filename); - -#endif diff --git a/kdeprint/cups/cupsdconf2/cups_logo.png b/kdeprint/cups/cupsdconf2/cups_logo.png deleted file mode 100644 index e6f9b5919..000000000 Binary files a/kdeprint/cups/cupsdconf2/cups_logo.png and /dev/null differ diff --git a/kdeprint/cups/cupsdconf2/cupsd.conf.template b/kdeprint/cups/cupsdconf2/cupsd.conf.template deleted file mode 100644 index 08d4b9425..000000000 --- a/kdeprint/cups/cupsdconf2/cupsd.conf.template +++ /dev/null @@ -1,977 +0,0 @@ -%%header -# CUPS configuration file, generated by CUPS configuration tool. -# This tool is part of KDEPrint, the printing framework for KDE -# since version 2.2.2 and is used by the CUPS supporting module -# in KDEPrint. The predecessors to KDEPrint in former KDE releases -# were KUPS and QtCUPS; they are deprecated and no longer maintained. -# -# Author: Michael Goffioul <tdeprint@swing.be> -# -# Web site: http://printing.kde.org/ -# -######################################################################## -# # -# This is the CUPS configuration file. If you are familiar with # -# Apache or any of the other popular web servers, we've followed the # -# same format. Any configuration variable used here has the same # -# semantics as the corresponding variable in Apache. If we need # -# different functionality then a different name is used to avoid # -# confusion... # -# # -######################################################################## -@@ - -%%servername -# <b>Server name (ServerName)</b> -# <p> -# The hostname of your server, as advertised to the world. -# By default CUPS will use the hostname of the system.</p> -# <p> -# To set the default server used by clients, see the client.conf file.</p> -# <p> -# <i>ex</i>: myhost.domain.com</p> -$$ -#ServerName myhost.domain.com -@@ - -%%serveradmin -# <b>Server administrator (ServerAdmin)</b> -# <p> -# The email address to send all complaints or problems to. -# By default CUPS will use "root@hostname".</p> -# <p> -# <i>ex</i>: root@myhost.com</p> -$$ -#ServerAdmin root@your.domain.com -@@ - -%%accesslog -# <b>Access log (AccessLog)</b> -# <p> -# The access log file; if this does not start with a leading / -# then it is assumed to be relative to ServerRoot. By default set to -# "/var/log/cups/access_log".</p> -# <p> -# You can also use the special name <b>syslog</b> to send the output to the -# syslog file or daemon.</p> -# <p> -# <i>ex</i>: /var/log/cups/access_log</p> -$$ -#AccessLog /var/log/cups/access_log -@@ - -%%datadir -# <b>Data directory (DataDir)</b> -# <p> -# The root directory for the CUPS data files. -# By default /usr/share/cups.</p> -# <p> -# <i>ex</i>: /usr/share/cups</p> -$$ -#DataDir /usr/share/cups -@@ - -%%defaultcharset -# <b>Default character set (DefaultCharset)</b> -# <p> -# The default character set to use. If not specified, -# defaults to utf-8. Note that this can also be overridden in -# HTML documents...</p> -# <p> -# <i>ex</i>: utf-8</p> -$$ -#DefaultCharset utf-8 -@@ - -%%defaultlanguage -# <b>Default language (DefaultLanguage)</b> -# <p> -# The default language if not specified by the browser. -# If not specified, the current locale is used.</p> -# <p> -# <i>ex</i>: en</p> -$$ -#DefaultLanguage en -@@ - -%%documentroot -# <b>Document directory (DocumentRoot)</b> -# <p> -# The root directory for HTTP documents that are served. -# By default the compiled-in directory.</p> -# <p> -# <i>ex</i>: /usr/share/cups/doc-root</p> -$$ -#DocumentRoot /usr/share/cups/doc-root -@@ - -%%errorlog -# <b>Error log (ErrorLog)</b> -# <p> -# The error log file; if this does not start with a leading / -# then it is assumed to be relative to ServerRoot. By default set to -# "/var/log/cups/error_log".</p> -# <p> -# You can also use the special name <b>syslog</b> to send the output to the -# syslog file or daemon.</p> -# <p> -# <i>ex</i>: /var/log/cups/error_log</p> -$$ -#ErrorLog /var/log/cups/error_log -@@ - -%%fontpath -# <b>Font path (FontPath)</b> -# <p> -# The path to locate all font files (currently only for pstoraster). -# By default /usr/share/cups/fonts.</p> -# <p> -# <i>ex</i>: /usr/share/cups/fonts</p> -$$ -#FontPath /usr/share/cups/fonts -@@ - -%%loglevel -# <b>Log level (LogLevel)</b> -# <p> -# Controls the number of messages logged to the ErrorLog -# file and can be one of the following:</p> -# <ul type=circle> -# <li><i>debug2</i>: Log everything.</li> -# <li><i>debug</i>: Log almost everything.</li> -# <li><i>info</i>: Log all requests and state changes.</li> -# <li><i>warn</i>: Log errors and warnings.</li> -# <li><i>error</i>: Log only errors.</li> -# <li><i>none</i>: Log nothing.</li> -# </ul><p> -# <i>ex</i>: info</p> -$$ -#LogLevel info -@@ - -%%maxlogsize -# <b>Max log size (MaxLogSize)</b> -# <p> -# Controls the maximum size of each log file before they are -# rotated. Defaults to 1048576 (1MB). Set to 0 to disable log rotating.</p> -# <p> -# <i>ex</i>: 1048576</p> -$$ -#MaxLogSize 0 -@@ - -%%pagelog -# <b>Page log (PageLog)</b> -# <p> -# The page log file; if this does not start with a leading / -# then it is assumed to be relative to ServerRoot. By default set to -# "/var/log/cups/page_log".</p> -# <p> -# You can also use the special name <b>syslog</b> to send the output to the -# syslog file or daemon.</p> -# <p> -# <i>ex</i>: /var/log/cups/page_log</p> -$$ -#PageLog /var/log/cups/page_log -@@ - -%%preservejobhistory -# <b>Preserve job history (PreserveJobHistory)</b> -# <p> -# Whether or not to preserve the job history after a -# job is completed, canceled, or stopped. Default is Yes.</p> -# <p> -# <i>ex</i>: Yes</p> -$$ -#PreserveJobHistory Yes -@@ - -%%preservejobfiles -# <b>Preserve job files (PreserveJobFiles)</b> -# <p> -# Whether or not to preserve the job files after a -# job is completed, canceled, or stopped. Default is No.</p> -# <p> -# <i>ex</i>: No</p> -$$ -#PreserveJobFiles No -@@ - -%%printcap -# <b>Printcap file (Printcap)</b> -# <p> -# The name of the printcap file. Default is no filename. -# Leave blank to disable printcap file generation.</p> -# <p> -# <i>ex</i>: /etc/printcap</p> -$$ -#Printcap /etc/printcap -@@ - -%%requestroot -# <b>Request directory (RequestRoot)</b> -# <p> -# The directory where request files are stored. -# By default /var/spool/cups.</p> -# <p> -# <i>ex</i>: /var/spool/cups</p> -$$ -#RequestRoot /var/spool/cups -@@ - -%%remoteroot -# <b>Remote root user (RemoteRoot)</b> -# <p> -# The name of the user assigned to unauthenticated accesses -# from remote systems. By default "remroot".</p> -# <p> -# <i>ex</i>: remroot</p> -$$ -#RemoteRoot remroot -@@ - -%%serverbin -# <b>Server binaries (ServerBin)</b> -# <p> -# The root directory for the scheduler executables. -# By default /usr/lib/cups or /usr/lib32/cups (IRIX 6.5).</p> -# <p> -# <i>ex</i>: /usr/lib/cups</p> -$$ -#ServerBin /usr/lib/cups -@@ - -%%serverroot -# <b>Server files (ServerRoot)</b> -# <p> -# The root directory for the scheduler. -# By default /etc/cups.</p> -# <p> -# <i>ex</i>: /etc/cups</p> -$$ -#ServerRoot /etc/cups -@@ - -%%user -# <b>User (User)</b> -# <p> -# The user the server runs under. Normally this -# must be <b>lp</b>, however you can configure things for another user -# as needed.</p> -# <p> -# Note: the server must be run initially as root to support the -# default IPP port of 631. It changes users whenever an external -# program is run...</p> -# <p> -# <i>ex</i>: lp</p> -$$ -#User lp -@@ - -%%group -# <b>Group (Group)</b> -# <p> -# The group the server runs under. Normally this -# must be <b>lpadmin</b>, however you can configure things for another -# group as needed.</p> -# <p> -# <i>ex</i>: lpadmin</p> -$$ -#Group lpadmin -@@ - -%%ripcache -# <b>RIP cache (RIPCache)</b> -# <p> -# The amount of memory that each RIP should use to cache -# bitmaps. The value can be any real number followed by "k" for -# kilobytes, "m" for megabytes, "g" for gigabytes, or "t" for tiles -# (1 tile = 256x256 pixels). Defaults to "8m" (8 megabytes).</p> -# <p> -# <i>ex</i>: 8m</p> -$$ -#RIPCache 8m -@@ - -%%tempdir -# <b>Temporary files (TempDir)</b> -# <p> -# The directory to put temporary files in. This directory must be -# writable by the user defined above! Defaults to "/var/spool/cups/tmp" or -# the value of the TMPDIR environment variable.</p> -# <p> -# <i>ex</i>: /var/spool/cups/tmp</p> -$$ -#TempDir /var/spool/cups/tmp -@@ - -%%filterlimit -# <b>Filter limit (FilterLimit)</b> -# <p> -# Sets the maximum cost of all job filters that can be run -# at the same time. A limit of 0 means no limit. A typical job may need -# a filter limit of at least 200; limits less than the minimum required -# by a job force a single job to be printed at any time.</p> -# <p> -# The default limit is 0 (unlimited).</p> -# <p> -# <i>ex</i>: 200</p> -$$ -#FilterLimit 0 -@@ - -%%listen -# <b>Listen to (Port/Listen)</b> -# <p> -# Ports/addresses that are listened to. The default port 631 is reserved -# for the Internet Printing Protocol (IPP) and is what is used here.</p> -# <p> -# You can have multiple Port/Listen lines to listen to more than one -# port or address, or to restrict access.</p> -# <p> -# Note: Unfortunately, most web browsers don't support TLS or HTTP Upgrades -# for encryption. If you want to support web-based encryption you will -# probably need to listen on port 443 (the "HTTPS" port...).</p> -# <p> -# <i>ex</i>: 631, myhost:80, 1.2.3.4:631</p> -$$ -# Port 80 -# Port 631 -# Listen hostname -# Listen hostname:80 -# Listen hostname:631 -# Listen 1.2.3.4 -# Listen 1.2.3.4:631 -# -#Port 631 -@@ - -%%hostnamelookups -# <b>Hostname lookups (HostNameLookups)</b> -# <p> -# Whether or not to do lookups on IP addresses to get a -# fully-qualified hostname. This defaults to Off for performance reasons...</p> -# <p> -# <i>ex</i>: On</p> -$$ -#HostNameLookups On -@@ - -%%keepalive -# <b>Keep alive (KeepAlive)</b> -# <p> -# Whether or not to support the Keep-Alive connection -# option. Default is on.</p> -# <p> -# <i>ex</i>: On</p> -$$ -#KeepAlive On -@@ - -%%keepalivetimeout -# <b>Keep-alive timeout (KeepAliveTimeout)</b> -# <p> -# The timeout (in seconds) before Keep-Alive connections are -# automatically closed. Default is 60 seconds.</p> -# <p> -# <i>ex</i>: 60</p> -$$ -#KeepAliveTimeout 60 -@@ - -%%maxclients -# <b>Max clients (MaxClients)</b> -# <p> -# Controls the maximum number of simultaneous clients that -# will be handled. Defaults to 100.</p> -# <p> -# <i>ex</i>: 100</p> -$$ -#MaxClients 100 -@@ - -%%maxrequestsize -# <b>Max request size (MaxRequestSize)</b> -# <p> -# Controls the maximum size of HTTP requests and print files. -# Set to 0 to disable this feature (defaults to 0).</p> -# <p> -# <i>ex</i>: 0</p> -$$ -#MaxRequestSize 0 -@@ - -%%timeout -# <b>Client timeout (Timeout)</b> -# <p> -# The timeout (in seconds) before requests time out. Default is 300 seconds.</p> -# <p> -# <i>ex</i>: 300</p> -$$ -#Timeout 300 -@@ - -%%browsing -# <b>Use browsing (Browsing)</b> -# <p> -# Whether or not to <b>listen</b> to printer -# information from other CUPS servers. -# </p> -# <p> -# Enabled by default. -# </p> -# <p> -# Note: to enable the <b>sending</b> of browsing -# information from this CUPS server to the LAN, -# specify a valid <i>BrowseAddress</i>. -# </p> -# <p> -# <i>ex</i>: On</p> -$$ -#Browsing On -@@ - -%%browseshortnames -# <b>Use short names (BrowseShortNames)</b> -# <p> -# Whether or not to use "short" names for remote printers -# when possible (e.g. "printer" instead of "printer@host"). Enabled by -# default.</p> -# <p> -# <i>ex</i>: Yes</p> -$$ -#BrowseShortNames Yes -@@ - -%%browseaddress -# <b>Browse addresses (BrowseAddress)</b> -# <p> -# Specifies a broadcast address to be used. By -# default browsing information is broadcast to all active interfaces.</p> -# <p> -# Note: HP-UX 10.20 and earlier do not properly handle broadcast unless -# you have a Class A, B, C, or D netmask (i.e. no CIDR support).</p> -# <p> -# <i>ex</i>: x.y.z.255, x.y.255.255</p> -$$ -#BrowseAddress x.y.z.255 -#BrowseAddress x.y.255.255 -#BrowseAddress x.255.255.255 -@@ - -%%browseallow -# <b>Browse allow/deny (BrowseAllow/BrowseDeny)</b> -# <p> -# <u>BrowseAllow</u>: specifies an address mask to allow for incoming browser -# packets. The default is to allow packets from all addresses.</p> -# <p> -# <u>BrowseDeny</u>: specifies an address mask to deny for incoming browser -# packets. The default is to deny packets from no addresses.</p> -# <p> -# Both "BrowseAllow" and "BrowseDeny" accept the following notations for -# addresses:</p> -# <pre> -# All -# None -# *.domain.com -# .domain.com -# host.domain.com -# nnn.* -# nnn.nnn.* -# nnn.nnn.nnn.* -# nnn.nnn.nnn.nnn -# nnn.nnn.nnn.nnn/mm -# nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm -# </pre><p> -# The hostname/domainname restrictions only work if you have turned hostname -# lookups on!</p> -$$ -#BrowseAllow address -#BrowseDeny address -@@ - -%%browseinterval -# <b>Browse interval (BrowseInterval)</b> -# <p> -# The time between browsing updates in seconds. Default -# is 30 seconds.</p> -# <p> -# Note that browsing information is sent whenever a printer's state changes -# as well, so this represents the maximum time between updates.</p> -# <p> -# Set this to 0 to disable outgoing broadcasts so your local printers are -# not advertised but you can still see printers on other hosts.</p> -# <p> -# <i>ex</i>: 30</p> -$$ -#BrowseInterval 30 -@@ - -%%browseorder -# <b>Browse order (BrowseOrder)</b> -# <p> -# Specifies the order of BrowseAllow/BrowseDeny comparisons.</p> -# <p> -# <i>ex</i>: allow,deny</p> -$$ -#BrowseOrder allow,deny -#BrowseOrder deny,allow -@@ - -%%browsepoll -# <b>Browse poll (BrowsePoll)</b> -# <p> -# Poll the named server(s) for printers.</p> -# <p> -# <i>ex</i>: myhost:631</p> -$$ -#BrowsePoll address:port -@@ - -%%browseport -# <b>Browse port (BrowsePort)</b> -# <p> -# The port used for UDP broadcasts. By default this is -# the IPP port; if you change this you need to do it on all servers. -# Only one BrowsePort is recognized.</p> -# <p> -# <i>ex</i>: 631</p> -$$ -#BrowsePort 631 -@@ - -%%browserelay -# <b>Browse relay (BrowseRelay)</b> -# <p> -# Relay browser packets from one address/network to another.</p> -# <p> -# <i>ex</i>: src-address dest-address</p> -$$ -#BrowseRelay source-address destination-address -@@ - -%%browsetimeout -# <b>Browse timeout (BrowseTimeout)</b> -# <p> -# The timeout (in seconds) for network printers - if we don't -# get an update within this time the printer will be removed -# from the printer list. This number definitely should not be -# less the BrowseInterval value for obvious reasons. Defaults -# to 300 seconds.</p> -# <p> -# <i>ex</i>: 300</p> -$$ -#BrowseTimeout 300 -@@ - -%%implicitclasses -# <b>Implicit classes (ImplicitClasses)</b> -# <p> -# Whether or not to use implicit classes.</p> -# <p> -# Printer classes can be specified explicitly in the classes.conf -# file, implicitly based upon the printers available on the LAN, or -# both.</p> -# <p> -# When ImplicitClasses is On, printers on the LAN with the same name -# (e.g. Acme-LaserPrint-1000) will be put into a class with the same -# name. This allows you to setup multiple redundant queues on a LAN -# without a lot of administrative difficulties. If a user sends a -# job to Acme-LaserPrint-1000, the job will go to the first available -# queue.</p> -# <p> -# Enabled by default.</p> -$$ -#ImplicitClasses Off -@@ - -%%systemgroup -# <b>System group (SystemGroup)</b> -# <p> -# The group name for "System" (printer administration) -# access. The default varies depending on the operating system, but -# will be <b>sys</b>, <b>system</b>, or <b>root</b> (checked for in that order).</p> -# <p> -# <i>ex</i>: lpadmin</p> -$$ -#SystemGroup lpadmin -@@ - -%%servercertificate -# <b>Encryption certificate (ServerCertificate)</b> -# <p> -# The file to read containing the server's certificate. -# Defaults to "/etc/cups/ssl/server.crt".</p> -# <p> -# <i>ex</i>: /etc/cups/ssl/server.crt</p> -$$ -#ServerCertificate /etc/cups/ssl/server.crt -@@ - -%%serverkey -# <b>Encryption key (ServerKey)</b> -# <p> -# The file to read containing the server's key. -# Defaults to "/etc/cups/ssl/server.key".</p> -# <p> -# <i>ex</i>: /etc/cups/ssl/server.key</p> -$$ -#ServerKey /etc/cups/ssl/server.key -@@ - -%%locations -# Access permissions -# -# Access permissions for each directory served by the scheduler. -# Locations are relative to DocumentRoot... -# -# AuthType: the authorization to use: -# -# None - Perform no authentication -# Basic - Perform authentication using the HTTP Basic method. -# Digest - Perform authentication using the HTTP Digest method. -# -# (Note: local certificate authentication can be substituted by -# the client for Basic or Digest when connecting to the -# localhost interface) -# -# AuthClass: the authorization class; currently only Anonymous, User, -# System (valid user belonging to group SystemGroup), and Group -# (valid user belonging to the specified group) are supported. -# -# AuthGroupName: the group name for "Group" authorization. -# -# Order: the order of Allow/Deny processing. -# -# Allow: allows access from the specified hostname, domain, IP address, or -# network. -# -# Deny: denies access from the specified hostname, domain, IP address, or -# network. -# -# Both "Allow" and "Deny" accept the following notations for addresses: -# -# All -# None -# *.domain.com -# .domain.com -# host.domain.com -# nnn.* -# nnn.nnn.* -# nnn.nnn.nnn.* -# nnn.nnn.nnn.nnn -# nnn.nnn.nnn.nnn/mm -# nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm -# -# The host and domain address require that you enable hostname lookups -# with "HostNameLookups On" above. -# -# Encryption: whether or not to use encryption; this depends on having -# the OpenSSL library linked into the CUPS library and scheduler. -# -# Possible values: -# -# Always - Always use encryption (SSL) -# Never - Never use encryption -# Required - Use TLS encryption upgrade -# IfRequested - Use encryption if the server requests it -# -# The default value is "IfRequested". -$$ -#<Location [resource_name]> -# -# You may wish to limit access to printers and classes, either with Allow -# and Deny lines, or by requiring a username and password. -# -# -## Anonymous access (default) -#AuthType None -# -## Require a username and password (Basic authentication) -#AuthType Basic -#AuthClass User -# -## Require a username and password (Digest/MD5 authentication) -#AuthType Digest -#AuthClass User -# -## Restrict access to local domain -#Order Deny,Allow -#Deny From All -#Allow From .mydomain.com -# -## Use encryption if requested -#Encryption IfRequested -#</Location> -@@ - -%%authtype -# <b>Authentication (AuthType)</b> -# <p> -# The authorization to use:<p> -# <ul type=circle> -# <li><i>None</i> - Perform no authentication.</li> -# <li><i>Basic</i> - Perform authentication using the HTTP Basic method.</li> -# <li><i>Digest</i> - Perform authentication using the HTTP Digest method.</li> -# </ul><p> -# Note: local certificate authentication can be substituted by -# the client for <i>Basic</i> or <i>Digest</i> when connecting to the -# localhost interface.</p> -@@ - -%%authclass -# <b>Class (AuthClass)</b> -# <p> -# The authorization class; currently only <i>Anonymous</i>, <i>User</i>, -# <i>System</i> (valid user belonging to group SystemGroup), and <i>Group</i> -# (valid user belonging to the specified group) are supported.</p> -@@ - -%%authname -# <p>The user/group names allowed to access the resource. The format is a -# comma separated list.</p> -@@ - -%%satisfy -# <b>Satisfy (Satisfy)</b> -# <p> -# This directive controls whether all specified conditions must -# be satisfied to allow access to the resource. If set to "all", -# then all authentication and access control conditions must be -# satisfied to allow access. -# </p> -# <p> -# Setting Satisfy to "any" allows a user to gain access if the -# authentication <i>or</i> access control requirements are satisfied. -# For example, you might require authentication for remote access, -# but allow local access without authentication. -# </p> -# <p> -# The default is "all". -# </p> -@@ - -%%authgroupname -# <b>Authentication group name (AuthGroupName)</b> -# <p> -# The group name for <i>Group</i> authorization.</p> -@@ - -%%order -# <b>ACL order (Order)</b> -# <p> -# The order of Allow/Deny processing.</p> -@@ - -%%allow -# <b>Allow</b> -# <p> -# Allows access from the specified hostname, domain, IP address, or -# network. Possible values are:</p> -# <pre> -# All -# None -# *.domain.com -# .domain.com -# host.domain.com -# nnn.* -# nnn.nnn.* -# nnn.nnn.nnn.* -# nnn.nnn.nnn.nnn -# nnn.nnn.nnn.nnn/mm -# nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm -# </pre><p> -# The host and domain address require that you enable hostname lookups -# with "HostNameLookups On" above.</p> -@@ - -%%allowdeny -# <b>ACL addresses (Allow/Deny)</b> -# <p> -# Allows/Denies access from the specified hostname, domain, IP address, or -# network. Possible values are:</p> -# <pre> -# All -# None -# *.domain.com -# .domain.com -# host.domain.com -# nnn.* -# nnn.nnn.* -# nnn.nnn.nnn.* -# nnn.nnn.nnn.nnn -# nnn.nnn.nnn.nnn/mm -# nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm -# </pre><p> -# The host and domain address require that you enable hostname lookups -# with "HostNameLookups On" above.</p> -@@ - -%%encryption -# <b>Encryption (Encryption)</b> -# <p> -# Whether or not to use encryption; this depends on having -# the OpenSSL library linked into the CUPS library and scheduler.</p> -# <p> -# Possible values:</p> -# <ul type=circle> -# <li><i>Always</i> - Always use encryption (SSL)</li> -# <li><i>Never</i> - Never use encryption</li> -# <li><i>Required</i> - Use TLS encryption upgrade</li> -# <li><i>IfRequested</i> - Use encryption if the server requests it</li> -# </ul><p> -# The default value is "IfRequested".</p> -@@ - -%%locationsshort -# <b>Access permissions</b> -# <p> -# Access permissions for each directory served by the scheduler. -# Locations are relative to DocumentRoot...</p> -@@ - -%%autopurgejobs -# <b>Auto purge jobs (AutoPurgeJobs)</b> -# <p> -# Automatically purge jobs when not needed for quotas. -# Default is No.</p> -$$ -#AutoPurgeJobs No -@@ - -%%browseprotocols -# <b>Browse protocols (BrowseProtocols)</b> -# <p> -# Which protocols to use for browsing. Can be -# any of the following separated by whitespace and/or commas:</p> -# <ul type=circle> -# <li><i>all</i> - Use all supported protocols.</li> -# <li><i>cups</i> - Use the CUPS browse protocol.</li> -# <li><i>slp</i> - Use the SLPv2 protocol.</li> -# </ul><p> -# The default is <b>cups</b>.</p> -# <p> -# Note: If you choose to use SLPv2, it is <b>strongly</b> recommended that -# you have at least one SLP Directory Agent (DA) on your -# network. Otherwise, browse updates can take several seconds, -# during which the scheduler will not response to client -# requests.</p> -$$ -#BrowseProtocols cups -@@ - -%%classification -# <b>Classification (Classification)</b> -# <p> -# The classification level of the server. If set, this -# classification is displayed on all pages, and raw printing is disabled. -# The default is the empty string.</p> -# <p> -# <i>ex</i>: confidential -$$ -#Classification classified -@@ - -%%classifyoverride -# <b>Allow overrides (ClassifyOverride)</b> -# <p> -# Whether to allow users to override the classification -# on printouts. If enabled, users can limit banner pages to before or -# after the job, and can change the classification of a job, but cannot -# completely eliminate the classification or banners.</p> -# <p> -# The default is off.</p> -$$ -#ClassifyOverride off -@@ - -%%hideimplicitmembers -# <b>Hide implicit members (HideImplicitMembers)</b> -# <p> -# Whether or not to show the members of an -# implicit class.</p> -# <p> -# When HideImplicitMembers is On, any remote printers that are -# part of an implicit class are hidden from the user, who will -# then only see a single queue even though many queues will be -# supporting the implicit class.</p> -# <p> -# Enabled by default.</p> -$$ -#HideImplicitMembers On -@@ - -%%implicitanyclasses -# <b>Use "any" classes (ImplicitAnyClasses)</b> -# <p> -# Whether or not to create <b>AnyPrinter</b> implicit -# classes.</p> -# <p> -# When ImplicitAnyClasses is On and a local queue of the same name -# exists, e.g. "printer", "printer@server1", "printer@server1", then -# an implicit class called "Anyprinter" is created instead.</p> -# <p> -# When ImplicitAnyClasses is Off, implicit classes are not created -# when there is a local queue of the same name.</p> -# <p> -# Disabled by default.</p> -$$ -#ImplicitAnyCLasses Off -@@ - -%%maxjobs -# <b>Max jobs (MaxJobs)</b> -# <p> -# Maximum number of jobs to keep in memory (active and completed). -# Default is 0 (no limit).</p> -$$ -#MaxJobs 0 -@@ - -%%maxjobsperuser -# <b>Max jobs per user (MaxJobsPerUser)</b> -# <p> -# The MaxJobsPerUser directive controls the maximum number of <i>active</i> -# jobs that are allowed for each user. Once a user reaches the limit, new -# jobs will be rejected until one of the active jobs is completed, stopped, -# aborted, or canceled.</p> -# <p> -# Setting the maximum to 0 disables this functionality. -# Default is 0 (no limit). -# </p> -$$ -#MaxJobsPerUser 0 -@@ - -%%maxjobsperprinter -# <b>Max jobs per printer (MaxJobsPerPrinter)</b> -# <p> -# The MaxJobsPerPrinter directive controls the maximum number of <i>active</i> -# jobs that are allowed for each printer or class. Once a printer or class -# reaches the limit, new jobs will be rejected until one of the active jobs -# is completed, stopped, aborted, or canceled.</p> -# <p> -# Setting the maximum to 0 disables this functionality. -# Default is 0 (no limit). -# </p> -$$ -#MaxJobsPerPrinter 0 -@@ - -%%port -# <b>Port</b> -# <p> -# The port value that the CUPS daemon is listening to. Default is 631.</p> -@@ - -%%address -# <b>Address</b> -# <p> -# The address that the CUPS daemon is listening at. Leave it empty or use -# an asterisk (*) to specify a port value on the entire subnetwork.</p> -@@ - -%%usessl -# <p>Check this box if you want to use SSL encryption with this address/port. -# </p> -@@ diff --git a/kdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp b/kdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp deleted file mode 100644 index 4b056cdb0..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdbrowsingpage.h" -#include "cupsdconf.h" -#include "editlist.h" -#include "browsedialog.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <knuminput.h> - -CupsdBrowsingPage::CupsdBrowsingPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Browsing")); - setHeader(i18n("Browsing Settings")); - setPixmap("tdeprint_printer_remote"); - - browseinterval_ = new KIntNumInput(this); - browseport_ = new KIntNumInput(this); - browsetimeout_ = new KIntNumInput(this); - browsing_ = new TQCheckBox(i18n("Use browsing"), this); - cups_ = new TQCheckBox("CUPS", this); - slp_ = new TQCheckBox("SLP", this); - browseaddresses_ = new EditList(this); - browseorder_ = new TQComboBox(this); - useimplicitclasses_ = new TQCheckBox(i18n("Implicit classes"), this); - hideimplicitmembers_ = new TQCheckBox(i18n("Hide implicit members"), this); - useshortnames_ = new TQCheckBox(i18n("Use short names"), this); - useanyclasses_ = new TQCheckBox(i18n("Use \"any\" classes"), this); - - browseorder_->insertItem(i18n("Allow, Deny")); - browseorder_->insertItem(i18n("Deny, Allow")); - - browseport_->setRange(0, 9999, 1, true); - browseport_->setSteps(1, 5); - browseinterval_->setRange(0, 10000, 1, true); - browseinterval_->setSteps(1, 10); - browseinterval_->setSuffix(i18n(" sec")); - browsetimeout_->setRange(0, 10000, 1, true); - browsetimeout_->setSteps(1, 10); - browsetimeout_->setSuffix(i18n(" sec")); - - TQLabel *l1 = new TQLabel(i18n("Browse port:"), this); - TQLabel *l2 = new TQLabel(i18n("Browse interval:"), this); - TQLabel *l3 = new TQLabel(i18n("Browse timeout:"), this); - TQLabel *l4 = new TQLabel(i18n("Browse addresses:"), this); - TQLabel *l5 = new TQLabel(i18n("Browse order:"), this); - TQLabel *l6 = new TQLabel(i18n("Browse options:"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 8, 2, 10, 7); - m1->setRowStretch(7, 1); - m1->setColStretch(1, 1); - TQHBoxLayout *m2 = new TQHBoxLayout(0, 0, 10); - m1->addMultiCellLayout(m2, 0, 0, 0, 1); - m2->addWidget(browsing_); - m2->addWidget(cups_); - m2->addWidget(slp_); - m2->addStretch(1); - m1->addWidget(l1, 1, 0, Qt::AlignRight); - m1->addWidget(l2, 2, 0, Qt::AlignRight); - m1->addWidget(l3, 3, 0, Qt::AlignRight); - m1->addWidget(l4, 4, 0, Qt::AlignRight|Qt::AlignTop); - m1->addWidget(l5, 5, 0, Qt::AlignRight); - m1->addWidget(l6, 6, 0, Qt::AlignRight|Qt::AlignTop); - m1->addWidget(browseport_, 1, 1); - m1->addWidget(browseinterval_, 2, 1); - m1->addWidget(browsetimeout_, 3, 1); - m1->addWidget(browseaddresses_, 4, 1); - m1->addWidget(browseorder_, 5, 1); - TQGridLayout *m3 = new TQGridLayout(0, 2, 2, 0, 5); - m1->addLayout(m3, 6, 1); - m3->addWidget(useimplicitclasses_, 0, 0); - m3->addWidget(useanyclasses_, 0, 1); - m3->addWidget(hideimplicitmembers_, 1, 0); - m3->addWidget(useshortnames_, 1, 1); - - connect(browsing_, TQT_SIGNAL(toggled(bool)), cups_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), slp_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), browseport_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), browseinterval_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), browsetimeout_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), browseaddresses_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), browseorder_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), useimplicitclasses_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), useanyclasses_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), hideimplicitmembers_, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), useshortnames_, TQT_SLOT(setEnabled(bool))); - - connect(browsing_, TQT_SIGNAL(toggled(bool)), l1, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), l2, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), l3, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), l4, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), l5, TQT_SLOT(setEnabled(bool))); - connect(browsing_, TQT_SIGNAL(toggled(bool)), l6, TQT_SLOT(setEnabled(bool))); - - connect(browseaddresses_, TQT_SIGNAL(add()), TQT_SLOT(slotAdd())); - connect(browseaddresses_, TQT_SIGNAL(edit(int)), TQT_SLOT(slotEdit(int))); - connect(browseaddresses_, TQT_SIGNAL(defaultList()), TQT_SLOT(slotDefaultList())); - connect(browseinterval_, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(intervalChanged(int))); - browsing_->setChecked(true); -} - -bool CupsdBrowsingPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - browsing_->setChecked(conf_->browsing_); - cups_->setChecked(conf_->browseprotocols_.findIndex("CUPS") != -1); - slp_->setChecked(conf_->browseprotocols_.findIndex("SLP") != -1); - browseport_->setValue(conf_->browseport_); - browseinterval_->setValue(conf_->browseinterval_); - browsetimeout_->setValue(conf_->browsetimeout_); - browseaddresses_->insertItems(conf_->browseaddresses_); - browseorder_->setCurrentItem(conf_->browseorder_); - useimplicitclasses_->setChecked(conf_->useimplicitclasses_); - useanyclasses_->setChecked(conf_->useanyclasses_); - hideimplicitmembers_->setChecked(conf_->hideimplicitmembers_); - useshortnames_->setChecked(conf_->useshortnames_); - - return true; -} - -bool CupsdBrowsingPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->browsing_ = browsing_->isChecked(); - TQStringList l; - if (cups_->isChecked()) l << "CUPS"; - if (slp_->isChecked()) l << "SLP"; - conf->browseprotocols_ = l; - conf->browseport_ = browseport_->value(); - conf->browseinterval_ = browseinterval_->value(); - conf->browsetimeout_ = browsetimeout_->value(); - conf->browseaddresses_ = browseaddresses_->items(); - conf->browseorder_ = browseorder_->currentItem(); - conf->useimplicitclasses_ = useimplicitclasses_->isChecked(); - conf->useanyclasses_ = useanyclasses_->isChecked(); - conf->hideimplicitmembers_ = hideimplicitmembers_->isChecked(); - conf->useshortnames_ = useshortnames_->isChecked(); - - return true; -} - -void CupsdBrowsingPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(browsing_, conf->comments_.toolTip("browsing")); - TQWhatsThis::add(cups_, conf->comments_.toolTip("browseprotocols")); - TQWhatsThis::add(slp_, conf->comments_.toolTip("browseprotocols")); - TQWhatsThis::add(browseinterval_, conf->comments_.toolTip("browseinterval")); - TQWhatsThis::add(browseport_, conf->comments_.toolTip("browseport")); - TQWhatsThis::add(browsetimeout_, conf->comments_.toolTip("browsetimeout")); - TQWhatsThis::add(browseaddresses_, conf->comments_.toolTip("browseaddresses")); - TQWhatsThis::add(browseorder_, conf->comments_.toolTip("browseorder")); - TQWhatsThis::add(useimplicitclasses_, conf->comments_.toolTip("implicitclasses")); - TQWhatsThis::add(useanyclasses_, conf->comments_.toolTip("implicitanyclasses")); - TQWhatsThis::add(hideimplicitmembers_, conf->comments_.toolTip("hideimplicitmembers")); - TQWhatsThis::add(useshortnames_, conf->comments_.toolTip("browseshortnames")); -} - -void CupsdBrowsingPage::slotAdd() -{ - TQString s = BrowseDialog::newAddress(this, conf_); - if (!s.isEmpty()) - browseaddresses_->insertItem(s); -} - -void CupsdBrowsingPage::slotEdit(int index) -{ - TQString s = browseaddresses_->text(index); - s = BrowseDialog::editAddress(s, this, conf_); - if (!s.isEmpty()) - browseaddresses_->setText(index, s); -} - -void CupsdBrowsingPage::slotDefaultList() -{ - browseaddresses_->clear(); - TQStringList l; - l << "Send 255.255.255.255"; - browseaddresses_->insertItems(l); -} - -void CupsdBrowsingPage::intervalChanged(int val) -{ - browsetimeout_->setRange(val, 10000, 1, true); - browsetimeout_->setSteps(1, 10); -} - -#include "cupsdbrowsingpage.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsdbrowsingpage.h b/kdeprint/cups/cupsdconf2/cupsdbrowsingpage.h deleted file mode 100644 index bdbff1844..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdbrowsingpage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDBROWSINGPAGE_H -#define CUPSDBROWSINGPAGE_H - -#include "cupsdpage.h" - -class KIntNumInput; -class TQCheckBox; -class EditList; -class TQComboBox; - -class CupsdBrowsingPage : public CupsdPage -{ - Q_OBJECT - -public: - CupsdBrowsingPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -protected slots: - void slotAdd(); - void slotEdit(int); - void slotDefaultList(); - void intervalChanged(int); - -private: - KIntNumInput *browseport_, *browseinterval_, *browsetimeout_; - EditList *browseaddresses_; - TQComboBox *browseorder_; - TQCheckBox *browsing_, *cups_, *slp_; - TQCheckBox *useimplicitclasses_, *hideimplicitmembers_, *useshortnames_, *useanyclasses_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdcomment.cpp b/kdeprint/cups/cupsdconf2/cupsdcomment.cpp deleted file mode 100644 index d17c8bd0c..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdcomment.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdcomment.h" - -#include <tqfile.h> -#include <tqregexp.h> -#include <klocale.h> -#include <kstandarddirs.h> - -TQString Comment::comment() -{ - TQString str = comment_; - str.replace(TQRegExp("<[^>]*>"), ""); - str += ("#\n" + example_); - return str; -} - -TQString Comment::toolTip() -{ - TQString str = comment_; - str.replace(TQRegExp("^#[\\s]*"), "").replace(TQRegExp("\n#[\\s]*"), "\n"); - return i18n("Do not translate the keyword between brackets (e.g. ServerName, ServerAdmin, etc.)", str.utf8()); -} - -TQString Comment::key() -{ - return key_; -} - -bool Comment::load(TQFile *f) -{ - comment_ = ""; - example_ = ""; - key_ = ""; - TQString line, *current = &comment_; - while (!f->atEnd()) - { - f->readLine(line, 1024); - if (line.left(2) == "$$") - { - current = &example_; - } - else if (line.left(2) == "%%") - { - key_ = line.mid(2).stripWhiteSpace(); - } - else if (line.left(2) == "@@") - { - return true; - } - else if (line.stripWhiteSpace().isEmpty()) - { - ; // do nothing - } - else - { - if (line[0] != '#') break; - else - { - current->append(line); - } - } - } - return false; -} - -//------------------------------------------------------------------------------------------------------------ - -TQString CupsdComment::operator[] (const TQString& key) -{ - return comment(key); -} - -TQString CupsdComment::comment(const TQString& key) -{ - if (comments_.count() != 0 || loadComments()) - { - Comment *comm = comments_.find(key); - if (comm) - return comm->comment(); - } - return TQString::null; -} - -TQString CupsdComment::toolTip(const TQString& key) -{ - if (comments_.count() != 0 || loadComments()) - { - Comment *comm = comments_.find(key); - if (comm) - return comm->toolTip(); - } - return TQString::null; -} - -bool CupsdComment::loadComments() -{ - comments_.setAutoDelete(true); - comments_.clear(); - TQFile f(locate("data", "tdeprint/cupsd.conf.template")); - if (f.exists() && f.open(IO_ReadOnly)) - { - Comment *comm; - while (!f.atEnd()) - { - comm = new Comment(); - if (!comm->load(&f)) - break; - else - { - if (comm->key().isEmpty()) - delete comm; - else - comments_.insert(comm->key(), comm); - } - } - } - return true; -} diff --git a/kdeprint/cups/cupsdconf2/cupsdcomment.h b/kdeprint/cups/cupsdconf2/cupsdcomment.h deleted file mode 100644 index 35f9e0515..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdcomment.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDCOMMENT_H -#define CUPSDCOMMENT_H - -#include <tqstringlist.h> -#include <tqdict.h> - -class TQFile; - -class Comment -{ -public: - bool load(TQFile* f); - TQString toolTip(); - TQString comment(); - TQString key(); -private: - TQString comment_; - TQString example_; - TQString key_; -}; - -class CupsdComment -{ -public: - TQString operator[] (const TQString& key); - TQString comment(const TQString& key); - TQString toolTip(const TQString& key); - -private: - bool loadComments(); - -private: - TQDict<Comment> comments_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdcomment.pl b/kdeprint/cups/cupsdconf2/cupsdcomment.pl deleted file mode 100644 index b3da5ee7e..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdcomment.pl +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl -w -# -# Filter to extract comments for translation from cupsd.conf.template -# -# This code should produce strings identical to tooltips in cupsdcomment.cpp -# -my ($comment_, $example_); -$example_ = ""; - -load(); # Skip header - -while ( <STDIN> ) -{ - if(load()) - { - print toolTip(); - } -} - -# Corresponds to Comment::load in cupsdcomment.cpp -sub load -{ - $comment_ = ""; - my($current) = \$comment_; - while ( <STDIN> ) - { - if (/^\$\$/) - { - $current = \$example_; - } - elsif (/^\%\%/) - { - next; # Do nothing - } - elsif (/^\@\@/) - { - return 1; - } - elsif (/^[\s]*$/) - { - next; # Do nothing - } - else - { - last if (!/^\#/); - ${$current} = ${$current} . $_; - } - } - return 0; -} - -# Corresponds to Comment::toolTip in cupsdcomment.cpp -sub toolTip -{ - my($str) = $comment_; - $str =~ s/\"/\\\"/g; - $str =~ s/^\#[\s]*/i18n\(\"Do not translate the keyword between brackets \(e\.g\. ServerName, ServerAdmin, etc\.\)\",\"/; - $str =~ s/\n\#[\s]*/\\n\"\n\"/g; - $str =~ s/\n$/\\n\"\n\)\;\n\n/; - return $str; -} diff --git a/kdeprint/cups/cupsdconf2/cupsdconf.cpp b/kdeprint/cups/cupsdconf2/cupsdconf.cpp deleted file mode 100644 index 0cd041d48..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdconf.cpp +++ /dev/null @@ -1,884 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdconf.h" - -#include <tqfile.h> -#include <tqregexp.h> -#include <klocale.h> -#include <kdebug.h> -#include <kconfig.h> - -#include <stdlib.h> -#include <cups/cups.h> -#include <cups/ipp.h> -#include <cups/language.h> - -TQString findDir(const TQStringList& list) -{ - for (TQStringList::ConstIterator it=list.begin(); it!=list.end(); ++it) - if (TQFile::exists(*it)) - return *it; - // if nothing found, just use the first as default value - return list[0]; -} - -void splitSizeSpec(const TQString& s, int& sz, int& suff) -{ - int p = s.find(TQRegExp("\\D")); - sz = s.mid(0, p).toInt(); - if (p != -1) - { - switch (s[p].latin1()) - { - case 'k': suff = UNIT_KB; break; - default: - case 'm': suff = UNIT_MB; break; - case 'g': suff = UNIT_GB; break; - case 't': suff = UNIT_TILE; break; - } - } - else - suff = UNIT_MB; -} - -CupsdConf::CupsdConf() -{ - // start by trying to find CUPS directories (useful later) - datadir_ = findDir(TQStringList("/usr/share/cups") - << "/usr/local/share/cups" - << "/opt/share/cups" - << "/opt/local/share/cups"); - documentdir_ = findDir(TQStringList(datadir_+"/doc-root") - << datadir_.left(datadir_.length()-5)+"/doc/cups"); - //fontpath_ << (datadir_+"/fonts"); - requestdir_ = findDir(TQStringList("/var/spool/cups") - << "/var/cups"); - serverbin_ = findDir(TQStringList("/usr/lib" KDELIBSUFF "/cups") - << "/usr/local/lib" KDELIBSUFF "/cups" - << "/opt/lib" KDELIBSUFF "/cups" - << "/opt/local/lib" KDELIBSUFF "/cups"); - serverfiles_ = findDir(TQStringList("/etc/cups") - << "/usr/local/etc/cups"); - tmpfiles_ = requestdir_+"/tmp"; - - // other options - servername_ = TQString::null; - serveradmin_ = TQString::null; - classification_ = CLASS_NONE; - otherclassname_ = TQString::null; - classoverride_ = false; - charset_ = "utf-8"; - language_ = "en"; - printcap_ = "/etc/printcap"; - printcapformat_ = PRINTCAP_BSD; - remoteroot_ = "remroot"; - systemgroup_ = "lpadmin"; - encryptcert_ = serverfiles_+"/ssl/server.crt"; - encryptkey_ = serverfiles_+"/ssl/server.key"; - hostnamelookup_ = HOSTNAME_OFF; - keepalive_ = true; - keepalivetimeout_ = 60; - maxclients_ = 100; - maxrequestsize_ = "0"; - clienttimeout_ = 300; - // listenaddresses_ - TQString logdir = findDir(TQStringList("/var/log/cups") - << "/var/spool/cups/log" - << "/var/cups/log"); - accesslog_ = logdir+"/access_log"; - errorlog_ = logdir+"/error_log"; - pagelog_ = logdir+"/page_log"; - maxlogsize_ = "1m"; - loglevel_ = LOGLEVEL_INFO; - keepjobhistory_ = true; - keepjobfiles_ = false; - autopurgejobs_ = false; - maxjobs_ = 0; - maxjobsperprinter_ = 0; - maxjobsperuser_ = 0; - user_ = "lp"; - group_ = "lpadmin"; - ripcache_ = "8m"; - filterlimit_ = 0; - browsing_ = true; - browseprotocols_ << "CUPS"; - browseport_ = ippPort(); - browseinterval_ = 30; - browsetimeout_ = 300; - // browseaddresses_ - browseorder_ = ORDER_ALLOW_DENY; - useimplicitclasses_ = true; - hideimplicitmembers_ = true; - useshortnames_ = true; - useanyclasses_ = false; - - loadAvailableResources(); -} - -CupsdConf::~CupsdConf() -{ -} - -bool CupsdConf::loadFromFile(const TQString& filename) -{ - TQFile f(filename); - if (!f.exists() || !f.open(IO_ReadOnly)) return false; - else - { - TQTextStream t(&f); - TQString line; - bool done(false), value(true); - while (!done && value) - { - line = t.readLine().simplifyWhiteSpace(); - if (line.isEmpty()) - { - if (t.atEnd()) done = true; - else continue; - } - else if (line[0] == '#') continue; - else if (line.left(9).lower() == "<location") - { - CupsLocation *location = new CupsLocation(); - locations_.append(location); - if (!location->parseResource(line) || !parseLocation(location, t)) - value = false; - // search corresponding resource - for (resources_.first();resources_.current();resources_.next()) - if (resources_.current()->path_ == location->resourcename_) - location->resource_ = resources_.current(); - } - else value = parseOption(line); - } - f.close(); - return value; - } -} - -bool CupsdConf::saveToFile(const TQString& filename) -{ - TQFile f(filename); - if (!f.open(IO_WriteOnly)) - return false; - else - { - TQTextStream t(&f); - t << comments_["header"] << endl; - t << "# Server" << endl << endl; - - t << comments_["servername"] << endl; - if ( !servername_.isEmpty() ) - t << "ServerName " << servername_ << endl; - - t << endl << comments_["serveradmin"] << endl; - if ( !serveradmin_.isEmpty() ) - t << "ServerAdmin " << serveradmin_ << endl; - - t << endl << comments_["classification"] << endl; - t << "Classification "; - switch (classification_) - { - default: - case CLASS_NONE: t << "none"; break; - case CLASS_CLASSIFIED: t << "classified"; break; - case CLASS_CONFIDENTIAL: t << "confidential"; break; - case CLASS_SECRET: t << "secret"; break; - case CLASS_TOPSECRET: t << "topsecret"; break; - case CLASS_UNCLASSIFIED: t << "unclassified"; break; - case CLASS_OTHER: t << otherclassname_; break; - } - t << endl; - - t << endl << comments_["classifyoverride"] << endl; - if (classification_ != CLASS_NONE) t << "ClassifyOverride " << (classoverride_ ? "Yes" : "No") << endl; - - t << endl << comments_["defaultcharset"] << endl; - t << "DefaultCharset " << charset_.upper() << endl; - - t << endl << comments_["defaultlanguage"] << endl; - t << "DefaultLanguage " << language_.lower() << endl; - - t << endl << comments_["printcap"] << endl; - t << "Printcap " << printcap_ << endl; - - t << endl << comments_["printcapformat"] << endl; - t << "PrintcapFormat " << (printcapformat_ == PRINTCAP_SOLARIS ? "Solaris" : "BSD") << endl; - - t << endl << "# Security" << endl; - t << endl << comments_["remoteroot"] << endl; - t << "RemoteRoot " << remoteroot_ << endl; - - t << endl << comments_["systemgroup"] << endl; - t << "SystemGroup " << systemgroup_ << endl; - - t << endl << comments_["servercertificate"] << endl; - t << "ServerCertificate " << encryptcert_ << endl; - - t << endl << comments_["serverkey"] << endl; - t << "ServerKey " << encryptkey_ << endl; - - t << endl << comments_["locations"] << endl; - for (locations_.first(); locations_.current(); locations_.next()) - { - CupsLocation *loc = locations_.current(); - t << "<Location " << loc->resourcename_ << ">" << endl; - if (loc->authtype_ != AUTHTYPE_NONE) - { - t << "AuthType "; - switch (loc->authtype_) - { - case AUTHTYPE_BASIC: t << "Basic"; break; - case AUTHTYPE_DIGEST: t << "Digest"; break; - } - t << endl; - } - if (loc->authclass_ != AUTHCLASS_ANONYMOUS) - { - switch (loc->authclass_) - { - case AUTHCLASS_USER: - if (!loc->authname_.isEmpty()) - t << "Require user " << loc->authname_ << endl; - else - t << "AuthClass User" << endl; - break; - case AUTHCLASS_GROUP: - if (!loc->authname_.isEmpty()) - t << "Require group " << loc->authname_ << endl; - else - t << "AuthClass Group" << endl; - break; - case AUTHCLASS_SYSTEM: - t << "AuthClass System" << endl; - break; - } - } - t << "Encryption "; - switch (loc->encryption_) - { - case ENCRYPT_ALWAYS: t << "Always"; break; - case ENCRYPT_NEVER: t << "Never"; break; - case ENCRYPT_REQUIRED: t << "Required"; break; - default: - case ENCRYPT_IFREQUESTED: t << "IfRequested"; break; - } - t << endl; - t << "Satisfy " << (loc->satisfy_ == SATISFY_ALL ? "All" : "Any") << endl; - t << "Order " << (loc->order_ == ORDER_ALLOW_DENY ? "allow,deny" : "deny,allow") << endl; - for (TQStringList::ConstIterator it=loc->addresses_.begin(); it!=loc->addresses_.end(); ++it) - t << *it << endl; - t << "</Location>" << endl; - } - - t << endl << "# Network" << endl; - t << endl << comments_["hostnamelookups"] << endl; - t << "HostnameLookups "; - switch (hostnamelookup_) - { - default: - case HOSTNAME_OFF: t << "Off"; break; - case HOSTNAME_ON: t << "On"; break; - case HOSTNAME_DOUBLE: t << "Double"; break; - } - t << endl; - - t << endl << comments_["keepalive"] << endl; - t << "KeepAlive " << (keepalive_ ? "On" : "Off") << endl; - - t << endl << comments_["keepalivetimeout"] << endl; - t << "KeepAliveTimeout " << keepalivetimeout_ << endl; - - t << endl << comments_["maxclients"] << endl; - t << "MaxClients " << maxclients_ << endl; - - t << endl << comments_["maxrequestsize"] << endl; - t << "MaxRequestSize " << maxrequestsize_ << endl; - - t << endl << comments_["timeout"] << endl; - t << "Timeout " << clienttimeout_ << endl; - - t << endl << comments_["listen"] << endl; - for (TQStringList::ConstIterator it=listenaddresses_.begin(); it!=listenaddresses_.end(); ++it) - t << *it << endl; - - t << endl << "# Log" << endl; - t << endl << comments_["accesslog"] << endl; - t << "AccessLog " << accesslog_ << endl; - - t << endl << comments_["errorlog"] << endl; - t << "ErrorLog " << errorlog_ << endl; - - t << endl << comments_["pagelog"] << endl; - t << "PageLog " << pagelog_ << endl; - - t << endl << comments_["maxlogsize"] << endl; - //t << "MaxLogSize " << maxlogsize_ << "m" << endl; - t << "MaxLogSize " << maxlogsize_ << endl; - - t << endl << comments_["loglevel"] << endl; - t << "LogLevel "; - switch (loglevel_) - { - case LOGLEVEL_NONE: t << "none"; break; - default: - case LOGLEVEL_INFO: t << "info"; break; - case LOGLEVEL_ERROR: t << "error"; break; - case LOGLEVEL_WARN: t << "warn"; break; - case LOGLEVEL_DEBUG: t << "debug"; break; - case LOGLEVEL_DEBUG2: t << "debug2"; break; - } - t << endl; - - t << endl << "# Jobs" << endl; - t << endl << comments_["preservejobhistory"] << endl; - t << "PreserveJobHistory " << (keepjobhistory_ ? "On" : "Off") << endl; - - t << endl << comments_["preservejobfiles"] << endl; - if (keepjobhistory_) t << "PreserveJobFiles " << (keepjobfiles_ ? "On" : "Off") << endl; - - t << endl << comments_["autopurgejobs"] << endl; - if (keepjobhistory_) t << "AutoPurgeJobs " << (autopurgejobs_ ? "Yes" : "No") << endl; - - t << endl << comments_["maxjobs"] << endl; - t << "MaxJobs " << maxjobs_ << endl; - - t << endl << comments_["maxjobsperprinter"] << endl; - t << "MaxJobsPerPrinter " << maxjobsperprinter_ << endl; - - t << endl << comments_["maxjobsperuser"] << endl; - t << "MaxJobsPerUser " << maxjobsperuser_ << endl; - - t << endl << "# Filter" << endl; - t << endl << comments_["user"] << endl; - t << "User " << user_ << endl; - - t << endl << comments_["group"] << endl; - t << "Group " << group_ << endl; - - t << endl << comments_["ripcache"] << endl; - t << "RIPCache " << ripcache_ << endl; - - t << endl << comments_["filterlimit"] << endl; - t << "FilterLimit " << filterlimit_ << endl; - - t << endl << "# Directories" << endl; - t << endl << comments_["datadir"] << endl; - t << "DataDir " << datadir_ << endl; - - t << endl << comments_["documentroot"] << endl; - t << "DocumentRoot " << documentdir_ << endl; - - t << endl << comments_["fontpath"] << endl; - for (TQStringList::ConstIterator it=fontpath_.begin(); it!=fontpath_.end(); ++it) - t << "FontPath " << *it << endl; - - t << endl << comments_["requestroot"] << endl; - t << "RequestRoot " << requestdir_ << endl; - - t << endl << comments_["serverbin"] << endl; - t << "ServerBin " << serverbin_ << endl; - - t << endl << comments_["serverroot"] << endl; - t << "ServerRoot " << serverfiles_ << endl; - - t << endl << comments_["tempdir"] << endl; - t << "TempDir " << tmpfiles_ << endl; - - t << endl << "# Browsing" << endl; - t << endl << comments_["browsing"] << endl; - t << "Browsing " << (browsing_ ? "On" : "Off") << endl; - - t << endl << comments_["browseprotocols"] << endl; - if (browsing_) - { - t << "BrowseProtocols "; - for (TQStringList::ConstIterator it=browseprotocols_.begin(); it!=browseprotocols_.end(); ++it) - t << (*it).upper() << " "; - t << endl; - } - - t << endl << comments_["browseport"] << endl; - if (browsing_) t << "BrowsePort " << browseport_ << endl; - - t << endl << comments_["browseinterval"] << endl; - if (browsing_) t << "BrowseInterval " << browseinterval_ << endl; - - t << endl << comments_["browsetimeout"] << endl; - if (browsing_) t << "BrowseTimeout " << browsetimeout_ << endl; - - t << endl << comments_["browseaddress"] << endl; - if (browsing_) - for (TQStringList::ConstIterator it=browseaddresses_.begin(); it!=browseaddresses_.end(); ++it) - if ((*it).startsWith("Send")) - t << "BrowseAddress " << (*it).mid(5) << endl; - else - t << "Browse" << (*it) << endl; - - t << endl << comments_["browseorder"] << endl; - if (browsing_) t << "BrowseOrder " << (browseorder_ == ORDER_ALLOW_DENY ? "allow,deny" : "deny,allow") << endl; - - t << endl << comments_["implicitclasses"] << endl; - if (browsing_) t << "ImplicitClasses " << (useimplicitclasses_ ? "On" : "Off") << endl; - - t << endl << comments_["implicitanyclasses"] << endl; - if (browsing_) t << "ImplicitAnyClasses " << (useanyclasses_ ? "On" : "Off") << endl; - - t << endl << comments_["hideimplicitmembers"] << endl; - if (browsing_) t << "HideImplicitMembers " << (hideimplicitmembers_ ? "Yes" : "No") << endl; - - t << endl << comments_["browseshortnames"] << endl; - if (browsing_) t << "BrowseShortNames " << (useshortnames_ ? "Yes" : "No") << endl; - - t << endl << "# Unknown" << endl; - for (TQValueList< TQPair<TQString,TQString> >::ConstIterator it=unknown_.begin(); it!=unknown_.end(); ++it) - t << (*it).first << " " << (*it).second << endl; - - return true; - } -} - -bool CupsdConf::parseLocation(CupsLocation *location, TQTextStream& file) -{ - TQString line; - bool done(false); - bool value(true); - while (!done && value) - { - line = file.readLine().simplifyWhiteSpace(); - if (line.isEmpty()) - { - if (file.atEnd()) - { - value = false; - done = true; - } - else continue; - } - else if (line[0] == '#') continue; - else if (line.lower() == "</location>") done = true; - else value = location->parseOption(line); - } - return value; -} - -bool CupsdConf::parseOption(const TQString& line) -{ - int p(-1); - TQString keyword, value, l(line.simplifyWhiteSpace()); - - if ((p=l.find(' ')) != -1) - { - keyword = l.left(p).lower(); - value = l.mid(p+1); - } - else - { - keyword = l.lower(); - } - - //kdDebug() << "cupsd.conf keyword=" << keyword << endl; - if (keyword == "accesslog") accesslog_ = value; - else if (keyword == "autopurgejobs") autopurgejobs_ = (value.lower() == "yes"); - else if (keyword == "browseaddress") browseaddresses_.append("Send "+value); - else if (keyword == "browseallow") browseaddresses_.append("Allow "+value); - else if (keyword == "browsedeny") browseaddresses_.append("Deny "+value); - else if (keyword == "browseinterval") browseinterval_ = value.toInt(); - else if (keyword == "browseorder") browseorder_ = (value.lower() == "deny,allow" ? ORDER_DENY_ALLOW : ORDER_ALLOW_DENY); - else if (keyword == "browsepoll") browseaddresses_.append("Poll "+value); - else if (keyword == "browseport") browseport_ = value.toInt(); - else if (keyword == "browseprotocols") - { - browseprotocols_.clear(); - TQStringList prots = TQStringList::split(TQRegExp("\\s"), value, false); - if (prots.find("all") != prots.end()) - browseprotocols_ << "CUPS" << "SLP"; - else - for (TQStringList::ConstIterator it=prots.begin(); it!=prots.end(); ++it) - browseprotocols_ << (*it).upper(); - } - else if (keyword == "browserelay") browseaddresses_.append("Relay "+value); - else if (keyword == "browseshortnames") useshortnames_ = (value.lower() != "no"); - else if (keyword == "browsetimeout") browsetimeout_ = value.toInt(); - else if (keyword == "browsing") browsing_ = (value.lower() != "off"); - else if (keyword == "classification") - { - TQString cl = value.lower(); - if (cl == "none") classification_ = CLASS_NONE; - else if (cl == "classified") classification_ = CLASS_CLASSIFIED; - else if (cl == "confidential") classification_ = CLASS_CONFIDENTIAL; - else if (cl == "secret") classification_ = CLASS_SECRET; - else if (cl == "topsecret") classification_ = CLASS_TOPSECRET; - else if (cl == "unclassified") classification_ = CLASS_UNCLASSIFIED; - else - { - classification_ = CLASS_OTHER; - otherclassname_ = cl; - } - } - else if (keyword == "classifyoverride") classoverride_ = (value.lower() == "yes"); - else if (keyword == "datadir") datadir_ = value; - else if (keyword == "defaultcharset") charset_ = value; - else if (keyword == "defaultlanguage") language_ = value; - else if (keyword == "documentroot") documentdir_ = value; - else if (keyword == "errorlog") errorlog_ = value; - else if (keyword == "filterlimit") filterlimit_ = value.toInt(); - else if (keyword == "fontpath") fontpath_ += TQStringList::split(':', value, false); - else if (keyword == "group") group_ = value; - else if (keyword == "hideimplicitmembers") hideimplicitmembers_ = (value.lower() != "no"); - else if (keyword == "hostnamelookups") - { - TQString h = value.lower(); - if (h == "on") hostnamelookup_ = HOSTNAME_ON; - else if (h == "double") hostnamelookup_ = HOSTNAME_DOUBLE; - else hostnamelookup_ = HOSTNAME_OFF; - } - else if (keyword == "implicitclasses") useimplicitclasses_ = (value.lower() != "off"); - else if (keyword == "implicitanyclasses") useanyclasses_ = (value.lower() == "on"); - else if (keyword == "keepalive") keepalive_ = (value.lower() != "off"); - else if (keyword == "keepalivetimeout") keepalivetimeout_ = value.toInt(); - else if (keyword == "listen") listenaddresses_.append("Listen "+value); - else if (keyword == "loglevel") - { - TQString ll = value.lower(); - if (ll == "none") loglevel_ = LOGLEVEL_NONE; - else if (ll == "error") loglevel_ = LOGLEVEL_ERROR; - else if (ll == "warn") loglevel_ = LOGLEVEL_WARN; - else if (ll == "info") loglevel_ = LOGLEVEL_INFO; - else if (ll == "debug") loglevel_ = LOGLEVEL_DEBUG; - else if (ll == "debug2") loglevel_ = LOGLEVEL_DEBUG2; - } - else if (keyword == "maxclients") maxclients_ = value.toInt(); - else if (keyword == "maxjobs") maxjobs_ = value.toInt(); - else if (keyword == "maxjobsperprinter") maxjobsperprinter_ = value.toInt(); - else if (keyword == "maxjobsperuser") maxjobsperuser_ = value.toInt(); - else if (keyword == "maxrequestsize") maxrequestsize_ = value; - else if (keyword == "maxlogsize") maxlogsize_ = value; - /*{ - // FIXME: support for suffixes - int suffix; - splitSizeSpec( value, maxlogsize_, suffix ); - }*/ - else if (keyword == "pagelog") pagelog_ = value; - else if (keyword == "port") listenaddresses_.append("Listen *:"+value); - else if (keyword == "preservejobhistory") keepjobhistory_ = (value != "off"); - else if (keyword == "preservejobfiles") keepjobfiles_ = (value == "on"); - else if (keyword == "printcap") printcap_ = value; - else if (keyword == "printcapformat") printcapformat_ = (value.lower() == "solaris" ? PRINTCAP_SOLARIS : PRINTCAP_BSD); - else if (keyword == "requestroot") requestdir_ = value; - else if (keyword == "remoteroot") remoteroot_ = value; - else if (keyword == "ripcache") ripcache_ = value; - else if (keyword == "serveradmin") serveradmin_ = value; - else if (keyword == "serverbin") serverbin_ = value; - else if (keyword == "servercertificate") encryptcert_ = value; - else if (keyword == "serverkey") encryptkey_ = value; - else if (keyword == "servername") servername_ = value; - else if (keyword == "serverroot") serverfiles_ = value; - else if (keyword == "ssllisten") listenaddresses_.append("SSLListen "+value); - else if (keyword == "sslport") listenaddresses_.append("SSLListen *:"+value); - else if (keyword == "systemgroup") systemgroup_ = value; - else if (keyword == "tempdir") tmpfiles_ = value; - else if (keyword == "timeout") clienttimeout_ = value.toInt(); - else if (keyword == "user") user_ = value; - else - { - // unrecognized option - unknown_ << TQPair<TQString,TQString>(keyword, value); - } - return true; -} - -bool CupsdConf::loadAvailableResources() -{ - KConfig conf("tdeprintrc"); - conf.setGroup("CUPS"); - TQString host = conf.readEntry("Host",cupsServer()); - int port = conf.readNumEntry("Port",ippPort()); - http_t *http_ = httpConnect(host.local8Bit(),port); - - resources_.clear(); - // standard resources - resources_.append(new CupsResource("/")); - resources_.append(new CupsResource("/admin")); - resources_.append(new CupsResource("/printers")); - resources_.append(new CupsResource("/classes")); - resources_.append(new CupsResource("/jobs")); - - if (!http_) - return false; - - // printer resources - ipp_t *request_ = ippNew(); - cups_lang_t* lang = cupsLangDefault(); - ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang)); - ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language); - request_->request.op.operation_id = CUPS_GET_PRINTERS; - request_ = cupsDoRequest(http_, request_, "/printers/"); - if (request_) - { - TQString name; - int type(0); - ipp_attribute_t *attr = request_->attrs; - while (attr) - { - // check new printer (keep only local non-implicit printers) - if (!attr->name) - { - if (!(type & CUPS_PRINTER_REMOTE) && !(type & CUPS_PRINTER_IMPLICIT) && !name.isEmpty()) - resources_.append(new CupsResource("/printers/"+name)); - name = ""; - type = 0; - } - else if (strcmp(attr->name, "printer-name") == 0) name = attr->values[0].string.text; - else if (strcmp(attr->name, "printer-type") == 0) type = attr->values[0].integer; - attr = attr->next; - } - if (!(type & CUPS_PRINTER_REMOTE) && !(type & CUPS_PRINTER_IMPLICIT) && !name.isEmpty()) - resources_.append(new CupsResource("/printers/"+name)); - ippDelete(request_); - } - // class resources - request_ = ippNew(); - ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang)); - ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language); - request_->request.op.operation_id = CUPS_GET_CLASSES; - request_ = cupsDoRequest(http_, request_, "/classes/"); - if (request_) - { - TQString name; - int type(0); - ipp_attribute_t *attr = request_->attrs; - while (attr) - { - // check new class (keep only local classes) - if (!attr->name) - { - if (!(type & CUPS_PRINTER_REMOTE) && !name.isEmpty()) - resources_.append(new CupsResource("/classes/"+name)); - name = ""; - type = 0; - } - else if (strcmp(attr->name, "printer-name") == 0) name = attr->values[0].string.text; - else if (strcmp(attr->name, "printer-type") == 0) type = attr->values[0].integer; - attr = attr->next; - } - if (!(type & CUPS_PRINTER_REMOTE) && !name.isEmpty()) - resources_.append(new CupsResource("/classes/"+name)); - ippDelete(request_); - } - httpClose(http_); - return true; -} - -//------------------------------------------------------------------------------------------------ - -CupsLocation::CupsLocation() -{ - resource_ = 0; - resourcename_ = ""; - authtype_ = AUTHTYPE_NONE; - authclass_ = AUTHCLASS_ANONYMOUS; - authname_ = TQString::null; - encryption_ = ENCRYPT_IFREQUESTED; - satisfy_ = SATISFY_ALL; - order_ = ORDER_ALLOW_DENY; - // addresses_ -} - -CupsLocation::CupsLocation(const CupsLocation& loc) -: resource_(loc.resource_), - resourcename_(loc.resourcename_), - authtype_(loc.authtype_), - authclass_(loc.authclass_), - authname_(loc.authname_), - encryption_(loc.encryption_), - satisfy_(loc.satisfy_), - order_(loc.order_), - addresses_(loc.addresses_) -{ -} - -bool CupsLocation::parseResource(const TQString& line) -{ - TQString str = line.simplifyWhiteSpace(); - int p1 = line.find(' '), p2 = line.find('>'); - if (p1 != -1 && p2 != -1) - { - resourcename_ = str.mid(p1+1,p2-p1-1); - return true; - } - else return false; -} - -bool CupsLocation::parseOption(const TQString& line) -{ - int p(-1); - TQString keyword, value, l(line.simplifyWhiteSpace()); - - if ((p=l.find(' ')) != -1) - { - keyword = l.left(p).lower(); - value = l.mid(p+1); - } - else - { - keyword = l.lower(); - } - - if (keyword == "authtype") - { - TQString a = value.lower(); - if (a == "basic") authtype_ = AUTHTYPE_BASIC; - else if (a == "digest") authtype_ = AUTHTYPE_DIGEST; - else authtype_ = AUTHTYPE_NONE; - } - else if (keyword == "authclass") - { - TQString a = value.lower(); - if (a == "user") authclass_ = AUTHCLASS_USER; - else if (a == "system") authclass_ = AUTHCLASS_SYSTEM; - else if (a == "group") authclass_ = AUTHCLASS_GROUP; - else authclass_ = AUTHCLASS_ANONYMOUS; - } - else if (keyword == "authgroupname") authname_ = value; - else if (keyword == "require") - { - int p = value.find(' '); - if (p != -1) - { - authname_ = value.mid(p+1); - TQString cl = value.left(p).lower(); - if (cl == "user") - authclass_ = AUTHCLASS_USER; - else if (cl == "group") - authclass_ = AUTHCLASS_GROUP; - } - } - else if (keyword == "allow") addresses_.append("Allow "+value); - else if (keyword == "deny") addresses_.append("Deny "+value); - else if (keyword == "order") order_ = (value.lower() == "deny,allow" ? ORDER_DENY_ALLOW : ORDER_ALLOW_DENY); - else if (keyword == "encryption") - { - TQString e = value.lower(); - if (e == "always") encryption_ = ENCRYPT_ALWAYS; - else if (e == "never") encryption_ = ENCRYPT_NEVER; - else if (e == "required") encryption_ = ENCRYPT_REQUIRED; - else encryption_ = ENCRYPT_IFREQUESTED; - } - else if (keyword == "satisfy") satisfy_ = (value.lower() == "any" ? SATISFY_ANY : SATISFY_ALL); - else return false; - return true; -} - -//------------------------------------------------------------------------------------------------ - -CupsResource::CupsResource() -{ - type_ = RESOURCE_GLOBAL; -} - -CupsResource::CupsResource(const TQString& path) -{ - setPath(path); -} - -void CupsResource::setPath(const TQString& path) -{ - path_ = path; - type_ = typeFromPath(path_); - text_ = pathToText(path_); -} - -int CupsResource::typeFromText(const TQString& text) -{ - if (text == i18n("Base", "Root") || text == i18n("All printers") || text == i18n("All classes") || text == i18n("Print jobs")) return RESOURCE_GLOBAL; - else if (text == i18n("Administration")) return RESOURCE_ADMIN; - else if (text.find(i18n("Class")) == 0) return RESOURCE_CLASS; - else if (text.find(i18n("Printer")) == 0) return RESOURCE_PRINTER; - else return RESOURCE_PRINTER; -} - -int CupsResource::typeFromPath(const TQString& path) -{ - if (path == "/admin") return RESOURCE_ADMIN; - else if (path == "/printers" || path == "/classes" || path == "/" || path == "/jobs") return RESOURCE_GLOBAL; - else if (path.left(9) == "/printers") return RESOURCE_PRINTER; - else if (path.left(8) == "/classes") return RESOURCE_CLASS; - else return RESOURCE_GLOBAL; -} - -TQString CupsResource::textToPath(const TQString& text) -{ - TQString path("/"); - if (text == i18n("Administration")) path = "/admin"; - else if (text == i18n("All printers")) path = "/printers"; - else if (text == i18n("All classes")) path = "/classes"; - else if (text == i18n("Print jobs")) path = "/jobs"; - else if (text == i18n("Base", "Root")) path = "/"; - else if (text.find(i18n("Printer")) == 0) - { - path = "/printers/"; - path.append(text.right(text.length()-i18n("Printer").length()-1)); - } - else if (text.find(i18n("Class")) == 0) - { - path = "/classes/"; - path.append(text.right(text.length()-i18n("Class").length()-1)); - } - return path; -} - -TQString CupsResource::pathToText(const TQString& path) -{ - TQString text(i18n("Base", "Root")); - if (path == "/admin") text = i18n("Administration"); - else if (path == "/printers") text = i18n("All printers"); - else if (path == "/classes") text = i18n("All classes"); - else if (path == "/") text = i18n("Root"); - else if (path == "/jobs") text = i18n("Print jobs"); - else if (path.find("/printers/") == 0) - { - text = i18n("Printer"); - text.append(" "); - text.append(path.right(path.length()-10)); - } - else if (path.find("/classes/") == 0) - { - text = i18n("Class"); - text.append(" "); - text.append(path.right(path.length()-9)); - } - return text; -} - -TQString CupsResource::typeToIconName(int type) -{ - switch (type) - { - case RESOURCE_ADMIN: - case RESOURCE_GLOBAL: - return TQString("folder"); - case RESOURCE_PRINTER: - return TQString("tdeprint_printer"); - case RESOURCE_CLASS: - return TQString("tdeprint_printer_class"); - } - return TQString("folder"); -} diff --git a/kdeprint/cups/cupsdconf2/cupsdconf.h b/kdeprint/cups/cupsdconf2/cupsdconf.h deleted file mode 100644 index 70b4f591b..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdconf.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDCONF_H -#define CUPSDCONF_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqptrlist.h> -#include <tqtextstream.h> -#include <tqpair.h> - -#include "cupsdcomment.h" - -enum LogLevelType { LOGLEVEL_DEBUG2 = 0, LOGLEVEL_DEBUG, LOGLEVEL_INFO, LOGLEVEL_WARN, LOGLEVEL_ERROR, LOGLEVEL_NONE }; -enum OrderType { ORDER_ALLOW_DENY = 0, ORDER_DENY_ALLOW }; -enum AuthTypeType { AUTHTYPE_NONE = 0, AUTHTYPE_BASIC, AUTHTYPE_DIGEST }; -enum AuthClassType { AUTHCLASS_ANONYMOUS = 0, AUTHCLASS_USER, AUTHCLASS_SYSTEM, AUTHCLASS_GROUP }; -enum EncryptionType { ENCRYPT_ALWAYS = 0, ENCRYPT_NEVER, ENCRYPT_REQUIRED, ENCRYPT_IFREQUESTED }; -enum BrowseProtocolType { BROWSE_ALL = 0, BROWSE_CUPS, BROWSE_SLP }; -enum PrintcapFormatType { PRINTCAP_BSD = 0, PRINTCAP_SOLARIS }; -enum HostnameLookupType { HOSTNAME_OFF = 0, HOSTNAME_ON, HOSTNAME_DOUBLE }; -enum ClassificationType { CLASS_NONE = 0, CLASS_CLASSIFIED, CLASS_CONFIDENTIAL, CLASS_SECRET, CLASS_TOPSECRET, CLASS_UNCLASSIFIED, CLASS_OTHER }; -enum SatisfyType { SATISFY_ALL = 0, SATISFY_ANY }; -enum UnitType { UNIT_KB = 0, UNIT_MB, UNIT_GB, UNIT_TILE }; - -struct CupsLocation; -struct CupsResource; -enum ResourceType { RESOURCE_GLOBAL, RESOURCE_PRINTER, RESOURCE_CLASS, RESOURCE_ADMIN }; - -struct CupsdConf -{ -// functions member - CupsdConf(); - ~CupsdConf(); - - bool loadFromFile(const TQString& filename); - bool saveToFile(const TQString& filename); - bool parseOption(const TQString& line); - bool parseLocation(CupsLocation *location, TQTextStream& file); - - bool loadAvailableResources(); - - static CupsdConf* get(); - static void release(); - -// data members - static CupsdConf *unique_; - - // Server - TQString servername_; - TQString serveradmin_; - int classification_; - TQString otherclassname_; - bool classoverride_; - TQString charset_; - TQString language_; - TQString printcap_; - int printcapformat_; - - // Security - TQString remoteroot_; - TQString systemgroup_; - TQString encryptcert_; - TQString encryptkey_; - TQPtrList<CupsLocation> locations_; - TQPtrList<CupsResource> resources_; - - // Network - int hostnamelookup_; - bool keepalive_; - int keepalivetimeout_; - int maxclients_; - TQString maxrequestsize_; - int clienttimeout_; - TQStringList listenaddresses_; - - // Log - TQString accesslog_; - TQString errorlog_; - TQString pagelog_; - TQString maxlogsize_; - int loglevel_; - - // Jobs - bool keepjobhistory_; - bool keepjobfiles_; - bool autopurgejobs_; - int maxjobs_; - int maxjobsperprinter_; - int maxjobsperuser_; - - // Filter - TQString user_; - TQString group_; - TQString ripcache_; - int filterlimit_; - - // Directories - TQString datadir_; - TQString documentdir_; - TQStringList fontpath_; - TQString requestdir_; - TQString serverbin_; - TQString serverfiles_; - TQString tmpfiles_; - - // Browsing - bool browsing_; - TQStringList browseprotocols_; - int browseport_; - int browseinterval_; - int browsetimeout_; - TQStringList browseaddresses_; - int browseorder_; - bool useimplicitclasses_; - bool hideimplicitmembers_; - bool useshortnames_; - bool useanyclasses_; - - // cupsd.conf file comments - CupsdComment comments_; - - // unrecognized options - TQValueList< TQPair<TQString,TQString> > unknown_; -}; - -struct CupsLocation -{ - CupsLocation(); - CupsLocation(const CupsLocation& loc); - - bool parseOption(const TQString& line); - bool parseResource(const TQString& line); - - CupsResource *resource_; - TQString resourcename_; - int authtype_; - int authclass_; - TQString authname_; - int encryption_; - int satisfy_; - int order_; - TQStringList addresses_; -}; - -struct CupsResource -{ - CupsResource(); - CupsResource(const TQString& path); - - void setPath(const TQString& path); - - int type_; - TQString path_; - TQString text_; - - static TQString textToPath(const TQString& text); - static TQString pathToText(const TQString& path); - static int typeFromPath(const TQString& path); - static int typeFromText(const TQString& text); - static TQString typeToIconName(int type); -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsddialog.cpp b/kdeprint/cups/cupsdconf2/cupsddialog.cpp deleted file mode 100644 index e6338eb8c..000000000 --- a/kdeprint/cups/cupsdconf2/cupsddialog.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsddialog.h" - -#include "cupsdpage.h" -#include "cupsdconf.h" -#include "cupsdsplash.h" -#include "cupsdserverpage.h" -#include "cupsdlogpage.h" -#include "cupsdjobspage.h" -#include "cupsdfilterpage.h" -#include "cupsddirpage.h" -#include "cupsdnetworkpage.h" -#include "cupsdbrowsingpage.h" -#include "cupsdsecuritypage.h" - -#include <tqdir.h> -#include <tqvbox.h> -#include <kmessagebox.h> -#include <klocale.h> -#include <tqfile.h> -#include <tqfileinfo.h> -#include <kglobal.h> -#include <kiconloader.h> -#include <tqstringlist.h> -#include <tqwhatsthis.h> -#include <kio/passdlg.h> -#include <kguiitem.h> -#include <kprocess.h> - -#include <stdlib.h> -#include <signal.h> -#include <cups/cups.h> - -static bool dynamically_loaded = false; -static TQString pass_string; - -extern "C" -{ -#include "cups-util.h" - KDEPRINT_EXPORT bool restartServer(TQString& msg) - { - return CupsdDialog::restartServer(msg); - } - KDEPRINT_EXPORT bool configureServer(TQWidget *parent, TQString& msg) - { - dynamically_loaded = true; - bool result = CupsdDialog::configure(TQString::null, parent, &msg); - dynamically_loaded = false; - return result; - } -} - -int getServerPid() -{ - TQDir dir("/proc",TQString::null,TQDir::Name,TQDir::Dirs); - for (uint i=0;i<dir.count();i++) - { - if (dir[i] == "." || dir[i] == ".." || dir[i] == "self") continue; - TQFile f("/proc/" + dir[i] + "/cmdline"); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - t >> line; - f.close(); - if (line.right(5) == "cupsd" || - line.right(6).left(5) == "cupsd") // second condition for 2.4.x kernels - // which add a null byte at the end - return dir[i].toInt(); - } - } - return (-1); -} - -const char* getPassword(const char*) -{ - TQString user(cupsUser()); - TQString pass; - - if (KIO::PasswordDialog::getNameAndPassword(user, pass, NULL) == TQDialog::Accepted) - { - cupsSetUser(user.latin1()); - pass_string = pass; - if (pass_string.isEmpty()) - return ""; - else - return pass_string.latin1(); - } - else - return NULL; -} - -//--------------------------------------------------- - -CupsdDialog::CupsdDialog(TQWidget *parent, const char *name) - : KDialogBase(IconList, "", Ok|Cancel|User1, Ok, parent, name, true, true, KGuiItem(i18n("Short Help"), "help")) -{ - KGlobal::iconLoader()->addAppDir("tdeprint"); - KGlobal::locale()->insertCatalogue("cupsdconf"); - - setShowIconsInTreeList(true); - setRootIsDecorated(false); - - pagelist_.setAutoDelete(false); - filename_ = ""; - conf_ = 0; - constructDialog(); - - setCaption(i18n("CUPS Server Configuration")); - - //resize(500, 400); -} - -CupsdDialog::~CupsdDialog() -{ - delete conf_; -} - -void CupsdDialog::addConfPage(CupsdPage *page) -{ - TQPixmap icon = KGlobal::instance()->iconLoader()->loadIcon( - page->pixmap(), - KIcon::NoGroup, - KIcon::SizeMedium - ); - - TQVBox *box = addVBoxPage(page->pageLabel(), page->header(), icon); - page->reparent(box, TQPoint(0,0)); - pagelist_.append(page); -} - -void CupsdDialog::constructDialog() -{ - addConfPage(new CupsdSplash(0)); - addConfPage(new CupsdServerPage(0)); - addConfPage(new CupsdNetworkPage(0)); - addConfPage(new CupsdSecurityPage(0)); - addConfPage(new CupsdLogPage(0)); - addConfPage(new CupsdJobsPage(0)); - addConfPage(new CupsdFilterPage(0)); - addConfPage(new CupsdDirPage(0)); - addConfPage(new CupsdBrowsingPage(0)); - - conf_ = new CupsdConf(); - for (pagelist_.first();pagelist_.current();pagelist_.next()) - { - pagelist_.current()->setInfos(conf_); - } -} - -bool CupsdDialog::setConfigFile(const TQString& filename) -{ - filename_ = filename; - if (!conf_->loadFromFile(filename_)) - { - KMessageBox::error(this, i18n("Error while loading configuration file!"), i18n("CUPS Configuration Error")); - return false; - } - if (conf_->unknown_.count() > 0) - { - // there were some unknown options, warn the user - TQString msg; - for (TQValueList< TQPair<TQString,TQString> >::ConstIterator it=conf_->unknown_.begin(); it!=conf_->unknown_.end(); ++it) - msg += ((*it).first + " = " + (*it).second + "<br>"); - msg.prepend("<p>" + i18n("Some options were not recognized by this configuration tool. " - "They will be left untouched and you won't be able to change them.") + "</p>"); - KMessageBox::sorry(this, msg, i18n("Unrecognized Options")); - } - bool ok(true); - TQString msg; - for (pagelist_.first();pagelist_.current() && ok;pagelist_.next()) - ok = pagelist_.current()->loadConfig(conf_, msg); - if (!ok) - { - KMessageBox::error(this, msg.prepend("<qt>").append("</qt>"), i18n("CUPS Configuration Error")); - return false; - } - return true; -} - -bool CupsdDialog::restartServer(TQString& msg) -{ - int serverPid = getServerPid(); - msg.truncate(0); - if (serverPid <= 0) - { - msg = i18n("Unable to find a running CUPS server"); - } - else - { - bool success = false; - KProcess proc; - proc << "tdesu" << "-c" << "/etc/init.d/cupsys restart"; - success = proc.start( KProcess::Block ) && proc.normalExit(); - if( !success ) - msg = i18n("Unable to restart CUPS server (pid = %1)").arg(serverPid); - } - return (msg.isEmpty()); -} - -bool CupsdDialog::configure(const TQString& filename, TQWidget *parent, TQString *msg) -{ - bool needUpload(false); - TQString errormsg; - bool result = true; - - // init password dialog if needed - if (!dynamically_loaded) - cupsSetPasswordCB(getPassword); - - // load config file from server - TQString fn(filename); - if (fn.isEmpty()) - { - fn = cupsGetConf(); - if (fn.isEmpty()) - errormsg = i18n("Unable to retrieve configuration file from the CUPS server. " - "You probably don't have the access permissions to perform this operation."); - else needUpload = true; - } - - // check read state (only if needed) - if (!fn.isEmpty()) - { - TQFileInfo fi(fn); - if (!fi.exists() || !fi.isReadable() || !fi.isWritable()) - errormsg = i18n("Internal error: file '%1' not readable/writable!").arg(fn); - // check file size - if (fi.size() == 0) - errormsg = i18n("Internal error: empty file '%1'!").arg(fn); - } - - if (!errormsg.isEmpty()) - { - if ( !dynamically_loaded ) - KMessageBox::error(parent, errormsg.prepend("<qt>").append("</qt>"), i18n("CUPS Configuration Error")); - result = false; - } - else - { - KGlobal::locale()->insertCatalogue("cupsdconf"); // Must be before dialog is created to translate "Short Help" - CupsdDialog dlg(parent); - if (dlg.setConfigFile(fn) && dlg.exec()) - { - TQCString encodedFn = TQFile::encodeName(fn); - if (!needUpload) - KMessageBox::information(parent, - i18n("The config file has not been uploaded to the " - "CUPS server. The daemon will not be restarted.")); - else if (!cupsPutConf(encodedFn.data())) - { - errormsg = i18n("Unable to upload the configuration file to CUPS server. " - "You probably don't have the access permissions to perform this operation."); - if ( !dynamically_loaded ) - KMessageBox::error(parent, errormsg, i18n("CUPS configuration error")); - result = false; - } - } - - } - if (needUpload) - TQFile::remove(fn); - - if ( msg ) - *msg = errormsg; - return result; -} - -void CupsdDialog::slotOk() -{ - if (conf_ && !filename_.isEmpty()) - { // try to save the file - bool ok(true); - TQString msg; - CupsdConf newconf_; - for (pagelist_.first();pagelist_.current() && ok;pagelist_.next()) - ok = pagelist_.current()->saveConfig(&newconf_, msg); - // copy unknown options - newconf_.unknown_ = conf_->unknown_; - if (!ok) - { - ; // do nothing - } - else if (!newconf_.saveToFile(filename_)) - { - msg = i18n("Unable to write configuration file %1").arg(filename_); - ok = false; - } - if (!ok) - { - KMessageBox::error(this, msg.prepend("<qt>").append("</qt>"), i18n("CUPS Configuration Error")); - } - else - KDialogBase::slotOk(); - } -} - -void CupsdDialog::slotUser1() -{ - TQWhatsThis::enterWhatsThisMode(); -} - -int CupsdDialog::serverPid() -{ - return getServerPid(); -} - -int CupsdDialog::serverOwner() -{ - int pid = getServerPid(); - if (pid > 0) - { - TQString str; - str.sprintf("/proc/%d/status",pid); - TQFile f(str); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - while (!t.eof()) - { - str = t.readLine(); - if (str.find("Uid:",0,false) == 0) - { - TQStringList list = TQStringList::split('\t', str, false); - if (list.count() >= 2) - { - bool ok; - int u = list[1].toInt(&ok); - if (ok) return u; - } - } - } - } - } - return (-1); -} - -#include "cupsddialog.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsddialog.h b/kdeprint/cups/cupsdconf2/cupsddialog.h deleted file mode 100644 index 85eee172e..000000000 --- a/kdeprint/cups/cupsdconf2/cupsddialog.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDDIALOG_H -#define CUPSDDIALOG_H - -#include <kdialogbase.h> -#include <tqptrlist.h> - -class CupsdPage; -struct CupsdConf; - -class CupsdDialog : public KDialogBase -{ - Q_OBJECT -public: - CupsdDialog(TQWidget *parent = 0, const char *name = 0); - ~CupsdDialog(); - - bool setConfigFile(const TQString& filename); - - static bool configure(const TQString& filename = TQString::null, TQWidget *parent = 0, TQString *errormsg = 0); - static bool restartServer(TQString& msg); - static int serverPid(); - static int serverOwner(); - -protected slots: - void slotOk(); - void slotUser1(); - -protected: - void addConfPage(CupsdPage*); - void constructDialog(); - void restartServer(); - -private: - TQPtrList<CupsdPage> pagelist_; - CupsdConf *conf_; - QString filename_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsddirpage.cpp b/kdeprint/cups/cupsdconf2/cupsddirpage.cpp deleted file mode 100644 index 268465a76..000000000 --- a/kdeprint/cups/cupsdconf2/cupsddirpage.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsddirpage.h" -#include "cupsdconf.h" -#include "qdirlineedit.h" -#include "qdirmultilineedit.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> - -CupsdDirPage::CupsdDirPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Folders")); - setHeader(i18n("Folders Settings")); - setPixmap("folder"); - - datadir_ = new QDirLineEdit(false, this); - documentdir_ = new QDirLineEdit(false, this); - fontpath_ = new QDirMultiLineEdit(this); - requestdir_ = new QDirLineEdit(false, this); - serverbin_ = new QDirLineEdit(false, this); - serverfiles_ = new QDirLineEdit(false, this); - tmpfiles_ = new QDirLineEdit(false, this); - - TQLabel *l1 = new TQLabel(i18n("Data folder:"), this); - TQLabel *l2 = new TQLabel(i18n("Document folder:"), this); - TQLabel *l3 = new TQLabel(i18n("Font path:"), this); - TQLabel *l4 = new TQLabel(i18n("Request folder:"), this); - TQLabel *l5 = new TQLabel(i18n("Server binaries:"), this); - TQLabel *l6 = new TQLabel(i18n("Server files:"), this); - TQLabel *l7 = new TQLabel(i18n("Temporary files:"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 8, 2, 10, 7); - m1->setRowStretch(7, 1); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight|Qt::AlignTop); - m1->addWidget(l4, 3, 0, Qt::AlignRight); - m1->addWidget(l5, 4, 0, Qt::AlignRight); - m1->addWidget(l6, 5, 0, Qt::AlignRight); - m1->addWidget(l7, 6, 0, Qt::AlignRight); - m1->addWidget(datadir_, 0, 1); - m1->addWidget(documentdir_, 1, 1); - m1->addWidget(fontpath_, 2, 1); - m1->addWidget(requestdir_, 3, 1); - m1->addWidget(serverbin_, 4, 1); - m1->addWidget(serverfiles_, 5, 1); - m1->addWidget(tmpfiles_, 6, 1); -} - -bool CupsdDirPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - datadir_->setURL(conf_->datadir_); - documentdir_->setURL(conf_->documentdir_); - fontpath_->setURLs(conf_->fontpath_); - requestdir_->setURL(conf_->requestdir_); - serverbin_->setURL(conf_->serverbin_); - serverfiles_->setURL(conf_->serverfiles_); - tmpfiles_->setURL(conf_->tmpfiles_); - - return true; -} - -bool CupsdDirPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->datadir_ = datadir_->url(); - conf->documentdir_ = documentdir_->url(); - conf->fontpath_ = fontpath_->urls(); - conf->requestdir_ = requestdir_->url(); - conf->serverbin_ = serverbin_->url(); - conf->serverfiles_ = serverfiles_->url(); - conf->tmpfiles_ = tmpfiles_->url(); - - return true; -} - -void CupsdDirPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(datadir_, conf->comments_.toolTip("datadir")); - TQWhatsThis::add(documentdir_, conf->comments_.toolTip("documentroot")); - TQWhatsThis::add(fontpath_, conf->comments_.toolTip("fontpath")); - TQWhatsThis::add(requestdir_, conf->comments_.toolTip("requestroot")); - TQWhatsThis::add(serverbin_, conf->comments_.toolTip("serverbin")); - TQWhatsThis::add(serverfiles_, conf->comments_.toolTip("serverroot")); - TQWhatsThis::add(tmpfiles_, conf->comments_.toolTip("tempdir")); -} diff --git a/kdeprint/cups/cupsdconf2/cupsddirpage.h b/kdeprint/cups/cupsdconf2/cupsddirpage.h deleted file mode 100644 index 571c79f21..000000000 --- a/kdeprint/cups/cupsdconf2/cupsddirpage.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDDIRPAGE_H -#define CUPSDDIRPAGE_H - -#include "cupsdpage.h" - -class QDirLineEdit; -class QDirMultiLineEdit; - -class CupsdDirPage : public CupsdPage -{ -public: - CupsdDirPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -private: - QDirLineEdit *datadir_, - *documentdir_, - *requestdir_, - *serverbin_, - *serverfiles_, - *tmpfiles_; - QDirMultiLineEdit *fontpath_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdfilterpage.cpp b/kdeprint/cups/cupsdconf2/cupsdfilterpage.cpp deleted file mode 100644 index 79c8a9401..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdfilterpage.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdfilterpage.h" -#include "cupsdconf.h" -#include "sizewidget.h" - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <tqcombobox.h> - -#include <klocale.h> -#include <knuminput.h> - -CupsdFilterPage::CupsdFilterPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Filter")); - setHeader(i18n("Filter Settings")); - setPixmap("filter"); - - user_ = new TQLineEdit(this); - group_ = new TQLineEdit(this); - ripcache_ = new SizeWidget(this); - filterlimit_ = new KIntNumInput(this); - - filterlimit_->setRange(0, 1000, 1, true); - filterlimit_->setSpecialValueText(i18n("Unlimited")); - filterlimit_->setSteps(1, 10); - - TQLabel *l1 = new TQLabel(i18n("User:"), this); - TQLabel *l2 = new TQLabel(i18n("Group:"), this); - TQLabel *l3 = new TQLabel(i18n("RIP cache:"), this); - TQLabel *l4 = new TQLabel(i18n("Filter limit:"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 5, 2, 10, 7); - m1->setRowStretch(4, 1); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight); - m1->addWidget(l4, 3, 0, Qt::AlignRight); - m1->addWidget(user_, 0, 1); - m1->addWidget(group_, 1, 1); - m1->addWidget(ripcache_, 2, 1); - m1->addWidget(filterlimit_, 3, 1); -} - -bool CupsdFilterPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - user_->setText(conf_->user_); - group_->setText(conf_->group_); - ripcache_->setSizeString(conf_->ripcache_); - filterlimit_->setValue(conf_->filterlimit_); - - return true; -} - -bool CupsdFilterPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->user_ = user_->text(); - conf->group_ = group_->text(); - conf->ripcache_ = ripcache_->sizeString(); - conf->filterlimit_ = filterlimit_->value(); - - return true; -} - -void CupsdFilterPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(user_, conf->comments_.toolTip("user")); - TQWhatsThis::add(group_, conf->comments_.toolTip("group")); - TQWhatsThis::add(ripcache_, conf->comments_.toolTip("ripcache")); - TQWhatsThis::add(filterlimit_, conf->comments_.toolTip("filterlimit")); -} diff --git a/kdeprint/cups/cupsdconf2/cupsdfilterpage.h b/kdeprint/cups/cupsdconf2/cupsdfilterpage.h deleted file mode 100644 index 18fc5d405..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdfilterpage.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDFILTERPAGE_H -#define CUPSDFILTERPAGE_H - -#include "cupsdpage.h" - -class SizeWidget; -class TQLineEdit; -class TQComboBox; -class KIntNumInput; - -class CupsdFilterPage : public CupsdPage -{ -public: - CupsdFilterPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -private: - TQLineEdit *user_, *group_; - KIntNumInput *filterlimit_; - SizeWidget *ripcache_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdjobspage.cpp b/kdeprint/cups/cupsdconf2/cupsdjobspage.cpp deleted file mode 100644 index f12f82f1e..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdjobspage.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdjobspage.h" -#include "cupsdconf.h" - -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <knuminput.h> - -CupsdJobsPage::CupsdJobsPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Jobs")); - setHeader(i18n("Print Jobs Settings")); - setPixmap("fileprint"); - - keepjobhistory_ = new TQCheckBox(i18n("Preserve job history"), this); - keepjobfiles_ = new TQCheckBox(i18n("Preserve job files"), this); - autopurgejobs_ = new TQCheckBox(i18n("Auto purge jobs"), this); - maxjobs_ = new KIntNumInput(this); - maxjobsperprinter_ = new KIntNumInput(this); - maxjobsperuser_ = new KIntNumInput(this); - - maxjobs_->setRange(0, 1000, 1, true); - maxjobs_->setSteps(1, 10); - maxjobs_->setSpecialValueText(i18n("Unlimited")); - maxjobsperprinter_->setRange(0, 1000, 1, true); - maxjobsperprinter_->setSpecialValueText(i18n("Unlimited")); - maxjobsperprinter_->setSteps(1, 10); - maxjobsperuser_->setRange(0, 1000, 1, true); - maxjobsperuser_->setSpecialValueText(i18n("Unlimited")); - maxjobsperuser_->setSteps(1, 10); - - TQLabel *l1 = new TQLabel(i18n("Max jobs:"), this); - TQLabel *l2 = new TQLabel(i18n("Max jobs per printer:"), this); - TQLabel *l3 = new TQLabel(i18n("Max jobs per user:"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 7, 2, 10, 7); - m1->setRowStretch(6, 1); - m1->setColStretch(1, 1); - m1->addWidget(keepjobhistory_, 0, 1); - m1->addWidget(keepjobfiles_, 1, 1); - m1->addWidget(autopurgejobs_, 2, 1); - m1->addWidget(l1, 3, 0, Qt::AlignRight); - m1->addWidget(l2, 4, 0, Qt::AlignRight); - m1->addWidget(l3, 5, 0, Qt::AlignRight); - m1->addWidget(maxjobs_, 3, 1); - m1->addWidget(maxjobsperprinter_, 4, 1); - m1->addWidget(maxjobsperuser_, 5, 1); - - connect(keepjobhistory_, TQT_SIGNAL(toggled(bool)), TQT_SLOT(historyChanged(bool))); - keepjobhistory_->setChecked(true); -} - -bool CupsdJobsPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - keepjobhistory_->setChecked(conf_->keepjobhistory_); - if (conf_->keepjobhistory_) - { - keepjobfiles_->setChecked(conf_->keepjobfiles_); - autopurgejobs_->setChecked(conf_->autopurgejobs_); - } - maxjobs_->setValue(conf_->maxjobs_); - maxjobsperprinter_->setValue(conf_->maxjobsperprinter_); - maxjobsperuser_->setValue(conf_->maxjobsperuser_); - - return true; -} - -bool CupsdJobsPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->keepjobhistory_ = keepjobhistory_->isChecked(); - if (conf->keepjobhistory_) - { - conf->keepjobfiles_ = keepjobfiles_->isChecked(); - conf->autopurgejobs_ = autopurgejobs_->isChecked(); - } - conf->maxjobs_ = maxjobs_->value(); - conf->maxjobsperprinter_ = maxjobsperprinter_->value(); - conf->maxjobsperuser_ = maxjobsperuser_->value(); - - return true; -} - -void CupsdJobsPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(keepjobhistory_, conf->comments_.toolTip("preservejobhistory")); - TQWhatsThis::add(keepjobfiles_, conf->comments_.toolTip("preservejobfiles")); - TQWhatsThis::add(autopurgejobs_, conf->comments_.toolTip("autopurgejobs")); - TQWhatsThis::add(maxjobs_, conf->comments_.toolTip("maxjobs")); - TQWhatsThis::add(maxjobsperprinter_, conf->comments_.toolTip("maxjobsperprinter")); - TQWhatsThis::add(maxjobsperuser_, conf->comments_.toolTip("maxjobsperuser")); -} - -void CupsdJobsPage::historyChanged(bool on) -{ - keepjobfiles_->setEnabled(on); - autopurgejobs_->setEnabled(on); -} - -#include "cupsdjobspage.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsdjobspage.h b/kdeprint/cups/cupsdconf2/cupsdjobspage.h deleted file mode 100644 index abbbd140d..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdjobspage.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDJOBSPAGE_H -#define CUPSDJOBSPAGE_H - -#include "cupsdpage.h" - -class KIntNumInput; -class TQCheckBox; - -class CupsdJobsPage : public CupsdPage -{ - Q_OBJECT - -public: - CupsdJobsPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -protected slots: - void historyChanged(bool); - -private: - KIntNumInput *maxjobs_, *maxjobsperprinter_, *maxjobsperuser_; - TQCheckBox *keepjobhistory_, *keepjobfiles_, *autopurgejobs_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdlogpage.cpp b/kdeprint/cups/cupsdconf2/cupsdlogpage.cpp deleted file mode 100644 index 61a89f933..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdlogpage.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdlogpage.h" -#include "cupsdconf.h" -#include "qdirlineedit.h" -#include "sizewidget.h" - -#include <tqlabel.h> -#include <tqcombobox.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <kfiledialog.h> - -CupsdLogPage::CupsdLogPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Log")); - setHeader(i18n("Log Settings")); - setPixmap("contents"); - - accesslog_ = new QDirLineEdit(true, this); - errorlog_ = new QDirLineEdit(true, this); - pagelog_ = new QDirLineEdit(true, this); - maxlogsize_ = new SizeWidget(this); - loglevel_ = new TQComboBox(this); - - loglevel_->insertItem(i18n("Detailed Debugging")); - loglevel_->insertItem(i18n("Debug Information")); - loglevel_->insertItem(i18n("General Information")); - loglevel_->insertItem(i18n("Warnings")); - loglevel_->insertItem(i18n("Errors")); - loglevel_->insertItem(i18n("No Logging")); - - /*maxlogsize_->setRange(0, 100, 1, true); - maxlogsize_->setSteps(1, 5); - maxlogsize_->setSpecialValueText(i18n("Unlimited")); - maxlogsize_->setSuffix(i18n("MB"));*/ - - TQLabel *l1 = new TQLabel(i18n("Access log:"), this); - TQLabel *l2 = new TQLabel(i18n("Error log:"), this); - TQLabel *l3 = new TQLabel(i18n("Page log:"), this); - TQLabel *l4 = new TQLabel(i18n("Max log size:"), this); - TQLabel *l5 = new TQLabel(i18n("Log level:"), this); - - loglevel_->setCurrentItem(2); - - TQGridLayout *m1 = new TQGridLayout(this, 6, 2, 10, 7); - m1->setRowStretch(5, 1); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight); - m1->addWidget(l4, 3, 0, Qt::AlignRight); - m1->addWidget(l5, 4, 0, Qt::AlignRight); - m1->addWidget(accesslog_, 0, 1); - m1->addWidget(errorlog_, 1, 1); - m1->addWidget(pagelog_, 2, 1); - m1->addWidget(maxlogsize_, 3, 1); - m1->addWidget(loglevel_, 4, 1); -} - -bool CupsdLogPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - accesslog_->setURL(conf_->accesslog_); - errorlog_->setURL(conf_->errorlog_); - pagelog_->setURL(conf_->pagelog_); - maxlogsize_->setSizeString(conf_->maxlogsize_); - loglevel_->setCurrentItem(conf_->loglevel_); - - return true; -} - -bool CupsdLogPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->accesslog_ = accesslog_->url(); - conf->errorlog_ = errorlog_->url(); - conf->pagelog_ = pagelog_->url(); - conf->maxlogsize_ = maxlogsize_->sizeString(); - conf->loglevel_ = loglevel_->currentItem(); - - return true; -} - -void CupsdLogPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(accesslog_, conf->comments_.toolTip("accesslog")); - TQWhatsThis::add(errorlog_, conf->comments_.toolTip("errorlog")); - TQWhatsThis::add(pagelog_, conf->comments_.toolTip("pagelog")); - TQWhatsThis::add(maxlogsize_, conf->comments_.toolTip("maxlogsize")); - TQWhatsThis::add(loglevel_, conf->comments_.toolTip("loglevel")); -} diff --git a/kdeprint/cups/cupsdconf2/cupsdlogpage.h b/kdeprint/cups/cupsdconf2/cupsdlogpage.h deleted file mode 100644 index 618f612be..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdlogpage.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDLOGPAGE_H -#define CUPSDLOGPAGE_H - -#include "cupsdpage.h" - -class QDirLineEdit; -class SizeWidget; -class TQComboBox; - -class CupsdLogPage : public CupsdPage -{ -public: - CupsdLogPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -private: - QDirLineEdit *accesslog_, *errorlog_, *pagelog_; - TQComboBox *loglevel_; - SizeWidget *maxlogsize_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp b/kdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp deleted file mode 100644 index 9edca5868..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdnetworkpage.h" -#include "cupsdconf.h" -#include "editlist.h" -#include "portdialog.h" -#include "sizewidget.h" - -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <knuminput.h> - -CupsdNetworkPage::CupsdNetworkPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Network")); - setHeader(i18n("Network Settings")); - setPixmap("network"); - - keepalive_ = new TQCheckBox(i18n("Keep alive"), this); - keepalivetimeout_ = new KIntNumInput(this); - maxclients_ = new KIntNumInput(this); - maxrequestsize_ = new SizeWidget(this); - clienttimeout_ = new KIntNumInput(this); - hostnamelookup_ = new TQComboBox(this); - listen_ = new EditList(this); - - keepalivetimeout_->setRange(0, 10000, 1, true); - keepalivetimeout_->setSteps(1, 10); - keepalivetimeout_->setSpecialValueText(i18n("Unlimited")); - keepalivetimeout_->setSuffix(i18n(" sec")); - - maxclients_->setRange(1, 1000, 1, true); - maxclients_->setSteps(1, 10); - - clienttimeout_->setRange(0, 10000, 1, true); - clienttimeout_->setSteps(1, 10); - clienttimeout_->setSpecialValueText(i18n("Unlimited")); - clienttimeout_->setSuffix(i18n(" sec")); - - hostnamelookup_->insertItem(i18n("Off")); - hostnamelookup_->insertItem(i18n("On")); - hostnamelookup_->insertItem(i18n("Double")); - - TQLabel *l1 = new TQLabel(i18n("Hostname lookups:"), this); - TQLabel *l2 = new TQLabel(i18n("Keep-alive timeout:"), this); - TQLabel *l3 = new TQLabel(i18n("Max clients:"), this); - TQLabel *l4 = new TQLabel(i18n("Max request size:"), this); - TQLabel *l5 = new TQLabel(i18n("Client timeout:"), this); - TQLabel *l6 = new TQLabel(i18n("Listen to:"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 8, 2, 10, 7); - m1->setRowStretch(7, 1); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 2, 0, Qt::AlignRight); - m1->addWidget(l3, 3, 0, Qt::AlignRight); - m1->addWidget(l4, 4, 0, Qt::AlignRight); - m1->addWidget(l5, 5, 0, Qt::AlignRight); - m1->addWidget(l6, 6, 0, Qt::AlignTop|Qt::AlignRight); - m1->addWidget(keepalive_, 1, 1); - m1->addWidget(hostnamelookup_, 0, 1); - m1->addWidget(keepalivetimeout_, 2, 1); - m1->addWidget(maxclients_, 3, 1); - m1->addWidget(maxrequestsize_, 4, 1); - m1->addWidget(clienttimeout_, 5, 1); - m1->addWidget(listen_, 6, 1); - - connect(listen_, TQT_SIGNAL(add()), TQT_SLOT(slotAdd())); - connect(listen_, TQT_SIGNAL(edit(int)), TQT_SLOT(slotEdit(int))); - connect(listen_, TQT_SIGNAL(defaultList()), TQT_SLOT(slotDefaultList())); - connect(keepalive_, TQT_SIGNAL(toggled(bool)), keepalivetimeout_, TQT_SLOT(setEnabled(bool))); - keepalive_->setChecked(true); -} - -bool CupsdNetworkPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - hostnamelookup_->setCurrentItem(conf_->hostnamelookup_); - keepalive_->setChecked(conf_->keepalive_); - keepalivetimeout_->setValue(conf_->keepalivetimeout_); - maxclients_->setValue(conf_->maxclients_); - maxrequestsize_->setSizeString(conf_->maxrequestsize_); - clienttimeout_->setValue(conf_->clienttimeout_); - listen_->insertItems(conf_->listenaddresses_); - - return true; -} - -bool CupsdNetworkPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->hostnamelookup_ = hostnamelookup_->currentItem(); - conf->keepalive_ = keepalive_->isChecked(); - conf->keepalivetimeout_ = keepalivetimeout_->value(); - conf->maxclients_ = maxclients_->value(); - conf->maxrequestsize_ = maxrequestsize_->sizeString(); - conf->clienttimeout_ = clienttimeout_->value(); - conf->listenaddresses_ = listen_->items(); - - return true; -} - -void CupsdNetworkPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(hostnamelookup_, conf->comments_.toolTip("hostnamelookups")); - TQWhatsThis::add(keepalive_, conf->comments_.toolTip("keepalive")); - TQWhatsThis::add(keepalivetimeout_, conf->comments_.toolTip("keepalivetimeout")); - TQWhatsThis::add(maxclients_, conf->comments_.toolTip("maxclients")); - TQWhatsThis::add(maxrequestsize_, conf->comments_.toolTip("maxrequestsize")); - TQWhatsThis::add(clienttimeout_, conf->comments_.toolTip("timeout")); - TQWhatsThis::add(listen_, conf->comments_.toolTip("listen")); -} - -void CupsdNetworkPage::slotAdd() -{ - TQString s = PortDialog::newListen(this, conf_); - if (!s.isEmpty()) - listen_->insertItem(s); -} - -void CupsdNetworkPage::slotEdit(int index) -{ - TQString s = listen_->text(index); - s = PortDialog::editListen(s, this, conf_); - if (!s.isEmpty()) - listen_->setText(index, s); -} - -void CupsdNetworkPage::slotDefaultList() -{ - listen_->clear(); - TQStringList l; - l << "Listen *:631"; - listen_->insertItems(l); -} - -#include "cupsdnetworkpage.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsdnetworkpage.h b/kdeprint/cups/cupsdconf2/cupsdnetworkpage.h deleted file mode 100644 index be46c280f..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdnetworkpage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDNETWORKPAGE_H -#define CUPSDNETWORKPAGE_H - -#include "cupsdpage.h" - -class KIntNumInput; -class TQCheckBox; -class TQComboBox; -class EditList; -class SizeWidget; - -class CupsdNetworkPage : public CupsdPage -{ - Q_OBJECT - -public: - CupsdNetworkPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -protected slots: - void slotAdd(); - void slotEdit(int); - void slotDefaultList(); - -private: - KIntNumInput *keepalivetimeout_, *maxclients_, *clienttimeout_; - TQComboBox *hostnamelookup_; - TQCheckBox *keepalive_; - EditList *listen_; - SizeWidget *maxrequestsize_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdpage.cpp b/kdeprint/cups/cupsdconf2/cupsdpage.cpp deleted file mode 100644 index 68bdde7a6..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdpage.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdpage.h" - -CupsdPage::CupsdPage(TQWidget *parent, const char *name) - : TQWidget(parent, name) -{ - conf_ = 0; -} - -CupsdPage::~CupsdPage() -{ -} - -#include "cupsdpage.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsdpage.h b/kdeprint/cups/cupsdconf2/cupsdpage.h deleted file mode 100644 index aadbd54b9..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdpage.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDPAGE_H -#define CUPSDPAGE_H - -#include <tqwidget.h> - -struct CupsdConf; - -class CupsdPage : public TQWidget -{ - Q_OBJECT -public: - CupsdPage(TQWidget *parent = 0, const char *name = 0); - virtual ~CupsdPage(); - - virtual bool loadConfig(CupsdConf *conf, TQString& msg) = 0; - virtual bool saveConfig(CupsdConf *conf, TQString& msg) = 0; - virtual void setInfos(CupsdConf*) {} - - TQString pageLabel() const { return label_; } - TQString header() const { return header_; } - TQString pixmap() const { return pixmap_; } - -protected: - void setPageLabel(const TQString& s) { label_ = s; } - void setHeader(const TQString& s) { header_ = s; } - void setPixmap(const TQString& s) { pixmap_ = s; } - -protected: - CupsdConf *conf_; - QString label_; - QString header_; - QString pixmap_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp b/kdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp deleted file mode 100644 index 092e1a7e5..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdsecuritypage.h" -#include "cupsdconf.h" -#include "qdirlineedit.h" -#include "editlist.h" -#include "locationdialog.h" - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <kiconloader.h> -#include <kmessagebox.h> - -CupsdSecurityPage::CupsdSecurityPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Security")); - setHeader(i18n("Security Settings")); - setPixmap("password"); - locs_.setAutoDelete(true); - - remoteroot_ = new TQLineEdit(this); - systemgroup_ = new TQLineEdit(this); - encryptcert_ = new QDirLineEdit(true, this); - encryptkey_ = new QDirLineEdit(true, this); - locations_ = new EditList(this); - - TQLabel *l1 = new TQLabel(i18n("Remote root user:"), this); - TQLabel *l2 = new TQLabel(i18n("System group:"), this); - TQLabel *l3 = new TQLabel(i18n("Encryption certificate:"), this); - TQLabel *l4 = new TQLabel(i18n("Encryption key:"), this); - TQLabel *l5 = new TQLabel(i18n("Locations:"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 6, 2, 10, 7); - m1->setRowStretch(5, 1); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight); - m1->addWidget(l4, 3, 0, Qt::AlignRight); - m1->addWidget(l5, 4, 0, Qt::AlignRight|Qt::AlignTop); - m1->addWidget(remoteroot_, 0, 1); - m1->addWidget(systemgroup_, 1, 1); - m1->addWidget(encryptcert_, 2, 1); - m1->addWidget(encryptkey_, 3, 1); - m1->addWidget(locations_, 4, 1); - - connect(locations_, TQT_SIGNAL(add()), TQT_SLOT(slotAdd())); - connect(locations_, TQT_SIGNAL(edit(int)), TQT_SLOT(slotEdit(int))); - connect(locations_, TQT_SIGNAL(defaultList()), TQT_SLOT(slotDefaultList())); - connect(locations_, TQT_SIGNAL(deleted(int)), TQT_SLOT(slotDeleted(int))); -} - -bool CupsdSecurityPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - remoteroot_->setText(conf_->remoteroot_); - systemgroup_->setText(conf_->systemgroup_); - encryptcert_->setURL(conf_->encryptcert_); - encryptkey_->setURL(conf_->encryptkey_); - locs_.clear(); - TQPtrListIterator<CupsLocation> it(conf_->locations_); - for (;it.current();++it) - { - locs_.append(new CupsLocation(*(it.current()))); - if (it.current()->resource_) - locations_->insertItem(SmallIcon(CupsResource::typeToIconName(it.current()->resource_->type_)), it.current()->resource_->text_); - else - locations_->insertItem(it.current()->resourcename_); - } - - return true; -} - -bool CupsdSecurityPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->remoteroot_ = remoteroot_->text(); - conf->systemgroup_ = systemgroup_->text(); - conf->encryptcert_ = encryptcert_->url(); - conf->encryptkey_ = encryptkey_->url(); - conf->locations_.clear(); - TQPtrListIterator<CupsLocation> it(locs_); - for (;it.current();++it) - conf->locations_.append(new CupsLocation(*(it.current()))); - - return true; -} - -void CupsdSecurityPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(remoteroot_, conf->comments_.toolTip("remoteroot")); - TQWhatsThis::add(systemgroup_, conf->comments_.toolTip("systemgroup")); - TQWhatsThis::add(encryptcert_, conf->comments_.toolTip("servercertificate")); - TQWhatsThis::add(encryptkey_, conf->comments_.toolTip("serverkey")); - TQWhatsThis::add(locations_, conf->comments_.toolTip("locationsshort")); -} - -void CupsdSecurityPage::slotAdd() -{ - CupsLocation *loc = new CupsLocation; - if (LocationDialog::newLocation(loc, this, conf_)) - { - int index(-1); - for (locs_.first(); locs_.current(); locs_.next()) - if (locs_.current()->resource_ == loc->resource_) - { - if (KMessageBox::warningContinueCancel(this, i18n("This location is already defined. Do you want to replace the existing one?"),TQString::null,i18n("Replace")) == KMessageBox::Continue) - { - index = locs_.tqat(); - locs_.remove(); - break; - } - else - { - delete loc; - return; - } - } - - if (index == -1) - index = locs_.count(); - locs_.insert(index, loc); - locations_->insertItem(SmallIcon(loc->resource_->typeToIconName(loc->resource_->type_)), loc->resource_->text_); - } - else - delete loc; -} - -void CupsdSecurityPage::slotEdit(int index) -{ - CupsLocation *loc = locs_.tqat(index); - LocationDialog::editLocation(loc, this, conf_); -} - -void CupsdSecurityPage::slotDefaultList() -{ - locs_.clear(); - locations_->clear(); -} - -void CupsdSecurityPage::slotDeleted(int index) -{ - if (index >= 0 && index < (int)(locs_.count())) - locs_.remove(index); -} - -#include "cupsdsecuritypage.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsdsecuritypage.h b/kdeprint/cups/cupsdconf2/cupsdsecuritypage.h deleted file mode 100644 index 5e97c1cf8..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdsecuritypage.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDSECURITYPAGE_H -#define CUPSDSECURITYPAGE_H - -#include "cupsdpage.h" -#include <tqptrlist.h> - -class TQLineEdit; -class EditList; -class QDirLineEdit; -struct CupsLocation; - -class CupsdSecurityPage : public CupsdPage -{ - Q_OBJECT - -public: - CupsdSecurityPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -protected slots: - void slotAdd(); - void slotEdit(int); - void slotDefaultList(); - void slotDeleted(int); - -private: - TQLineEdit *remoteroot_, *systemgroup_; - QDirLineEdit *encryptcert_, *encryptkey_; - EditList *locations_; - - TQPtrList<CupsLocation> locs_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdserverpage.cpp b/kdeprint/cups/cupsdconf2/cupsdserverpage.cpp deleted file mode 100644 index cfd731430..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdserverpage.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdserverpage.h" -#include "cupsdconf.h" - -#include <tqlineedit.h> -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> - -int findComboItem(TQComboBox *cb, const TQString& str) -{ - for (int i=0; i<cb->count(); i++) - if (cb->text(i) == str) - return i; - return (-1); -} - -CupsdServerPage::CupsdServerPage(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setPageLabel(i18n("Server")); - setHeader(i18n("Server Settings")); - setPixmap("gear"); - - servername_ = new TQLineEdit(this); - serveradmin_ = new TQLineEdit(this); - otherclassname_ = new TQLineEdit(this); - language_ = new TQLineEdit(this); - printcap_ = new TQLineEdit(this); - classification_ = new TQComboBox(this); - charset_ = new TQComboBox(this); - printcapformat_ = new TQComboBox(this); - classoverride_ = new TQCheckBox(i18n("Allow overrides"), this); - - classification_->insertItem(i18n("None")); - classification_->insertItem(i18n("Classified")); - classification_->insertItem(i18n("Confidential")); - classification_->insertItem(i18n("Secret")); - classification_->insertItem(i18n("Top Secret")); - classification_->insertItem(i18n("Unclassified")); - classification_->insertItem(i18n("Other")); - - charset_->insertItem("UTF-8"); - charset_->insertItem("ISO-8859-1"); - charset_->insertItem("ISO-8859-2"); - charset_->insertItem("ISO-8859-3"); - charset_->insertItem("ISO-8859-4"); - charset_->insertItem("ISO-8859-5"); - charset_->insertItem("ISO-8859-6"); - charset_->insertItem("ISO-8859-7"); - charset_->insertItem("ISO-8859-8"); - charset_->insertItem("ISO-8859-9"); - charset_->insertItem("ISO-8859-10"); - charset_->insertItem("ISO-8859-13"); - charset_->insertItem("ISO-8859-14"); - charset_->insertItem("ISO-8859-15"); - - printcapformat_->insertItem("BSD"); - printcapformat_->insertItem("SOLARIS"); - - TQLabel *l1 = new TQLabel(i18n("Server name:"), this); - TQLabel *l2 = new TQLabel(i18n("Server administrator:"), this); - TQLabel *l3 = new TQLabel(i18n("Classification:"), this); - TQLabel *l4 = new TQLabel(i18n("Default character set:"), this); - TQLabel *l5 = new TQLabel(i18n("Default language:"), this); - TQLabel *l6 = new TQLabel(i18n("Printcap file:"), this); - TQLabel *l7 = new TQLabel(i18n("Printcap format:"), this); - - connect(classification_, TQT_SIGNAL(activated(int)), TQT_SLOT(classChanged(int))); - classification_->setCurrentItem(0); - charset_->setCurrentItem(0); - printcapformat_->setCurrentItem(0); - classChanged(0); - - TQGridLayout *m1 = new TQGridLayout(this, 9, 2, 10, 7); - m1->setRowStretch(8, 1); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight); - m1->addWidget(l4, 4, 0, Qt::AlignRight); - m1->addWidget(l5, 5, 0, Qt::AlignRight); - m1->addWidget(l6, 6, 0, Qt::AlignRight); - m1->addWidget(l7, 7, 0, Qt::AlignRight); - m1->addWidget(servername_, 0, 1); - m1->addWidget(serveradmin_, 1, 1); - m1->addWidget(charset_, 4, 1); - m1->addWidget(language_, 5, 1); - m1->addWidget(printcap_, 6, 1); - m1->addWidget(printcapformat_, 7, 1); - TQHBoxLayout *m2 = new TQHBoxLayout(0, 0, 5); - m1->addLayout(m2, 2, 1); - m2->addWidget(classification_); - m2->addWidget(otherclassname_); - TQWidget *w = new TQWidget(this); - w->setFixedWidth(20); - TQHBoxLayout *m3 = new TQHBoxLayout(0, 0, 0); - m1->addLayout(m3, 3, 1); - m3->addWidget(w); - m3->addWidget(classoverride_); -} - -bool CupsdServerPage::loadConfig(CupsdConf *conf, TQString&) -{ - conf_ = conf; - servername_->setText(conf_->servername_); - serveradmin_->setText(conf_->serveradmin_); - classification_->setCurrentItem(conf_->classification_); - classChanged(conf_->classification_); - if (conf->classification_ != CLASS_NONE) - classoverride_->setChecked(conf_->classoverride_); - if (conf->classification_ == CLASS_OTHER) - otherclassname_->setText(conf_->otherclassname_); - int index = findComboItem(charset_, conf_->charset_.upper()); - if (index != -1) - charset_->setCurrentItem(index); - language_->setText(conf_->language_); - printcap_->setText(conf_->printcap_); - printcapformat_->setCurrentItem(conf_->printcapformat_); - - return true; -} - -bool CupsdServerPage::saveConfig(CupsdConf *conf, TQString&) -{ - conf->servername_ = servername_->text(); - conf->serveradmin_ = serveradmin_->text(); - conf->classification_ = classification_->currentItem(); - if (conf->classification_ != CLASS_NONE) - conf->classoverride_ = classoverride_->isChecked(); - if (conf->classification_ == CLASS_OTHER) - conf->otherclassname_ = otherclassname_->text(); - conf->charset_ = charset_->currentText(); - conf->language_ = language_->text(); - conf->printcap_ = printcap_->text(); - conf->printcapformat_ = printcapformat_->currentItem(); - - return true; -} - -void CupsdServerPage::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(servername_, conf->comments_.toolTip("servername")); - TQWhatsThis::add(serveradmin_, conf->comments_.toolTip("serveradmin")); - TQWhatsThis::add(classification_, conf->comments_.toolTip("classification")); - TQWhatsThis::add(classoverride_, conf->comments_.toolTip("classifyoverride")); - TQWhatsThis::add(charset_, conf->comments_.toolTip("defaultcharset")); - TQWhatsThis::add(language_, conf->comments_.toolTip("defaultlanguage")); - TQWhatsThis::add(printcap_, conf->comments_.toolTip("printcap")); - TQWhatsThis::add(printcapformat_, conf->comments_.toolTip("printcapformat")); -} - -void CupsdServerPage::classChanged(int index) -{ - classoverride_->setEnabled(index != 0); - otherclassname_->setEnabled(index == CLASS_OTHER); -} - -#include "cupsdserverpage.moc" diff --git a/kdeprint/cups/cupsdconf2/cupsdserverpage.h b/kdeprint/cups/cupsdconf2/cupsdserverpage.h deleted file mode 100644 index f1f9eed2f..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdserverpage.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDSERVERPAGE_H -#define CUPSDSERVERPAGE_H - -#include "cupsdpage.h" - -class TQLineEdit; -class TQCheckBox; -class TQComboBox; - -class CupsdServerPage : public CupsdPage -{ - Q_OBJECT - -public: - CupsdServerPage(TQWidget *parent = 0, const char *name = 0); - - bool loadConfig(CupsdConf*, TQString&); - bool saveConfig(CupsdConf*, TQString&); - void setInfos(CupsdConf*); - -protected slots: - void classChanged(int); - -private: - TQLineEdit *servername_, *serveradmin_, *language_, *printcap_, *otherclassname_; - TQComboBox *classification_, *charset_, *printcapformat_; - TQCheckBox *classoverride_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/cupsdsplash.cpp b/kdeprint/cups/cupsdconf2/cupsdsplash.cpp deleted file mode 100644 index c26b65fd7..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdsplash.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsdsplash.h" - -#include <tqlabel.h> -#include <tqpixmap.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kstandarddirs.h> - -CupsdSplash::CupsdSplash(TQWidget *parent, const char *name) - : CupsdPage(parent, name) -{ - setHeader(i18n("Welcome to the CUPS Server Configuration Tool")); - setPageLabel(i18n("Welcome")); - setPixmap("go"); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 10, 10); - TQHBoxLayout *sub_ = new TQHBoxLayout(0, 0, 10); - main_->addLayout(sub_); - - TQLabel *cupslogo_ = new TQLabel(this); - TQString logopath = locate("data", TQString("tdeprint/cups_logo.png")); - cupslogo_->setPixmap(logopath.isEmpty() ? TQPixmap() : TQPixmap(logopath)); - cupslogo_->tqsetAlignment(Qt::AlignCenter); - TQLabel *kupslogo_ = new TQLabel(this); - logopath = locate("data", TQString("tdeprint/kde_logo.png")); - kupslogo_->setPixmap(logopath.isEmpty() ? TQPixmap() : TQPixmap(logopath)); - kupslogo_->tqsetAlignment(Qt::AlignCenter); - - TQLabel *helptxt_ = new TQLabel(this); - helptxt_->setText(i18n( "<p>This tool will help you to configure graphically the server of the CUPS printing system. " - "The available options are grouped into sets of related topics and can be accessed " - "quickly through the icon view located on the left. Each option has a default value that is " - "shown if it has not been previously set. This default value should be OK in most cases.</p><br>" - "<p>You can access a short help message for each option using either the '?' button in the " - "the title bar, or the button at the bottom of this dialog.</p>")); - - sub_->addWidget(cupslogo_); - sub_->addWidget(kupslogo_); - main_->addWidget(helptxt_, 1); -} - -CupsdSplash::~CupsdSplash() -{ -} - -bool CupsdSplash::loadConfig(CupsdConf*, TQString&) -{ - return true; -} - -bool CupsdSplash::saveConfig(CupsdConf*, TQString&) -{ - return true; -} diff --git a/kdeprint/cups/cupsdconf2/cupsdsplash.h b/kdeprint/cups/cupsdconf2/cupsdsplash.h deleted file mode 100644 index f484958d4..000000000 --- a/kdeprint/cups/cupsdconf2/cupsdsplash.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSDSPLASH_H -#define CUPSDSPLASH_H - -#include "cupsdpage.h" - -class CupsdSplash : public CupsdPage -{ -public: - CupsdSplash(TQWidget *parent = 0, const char *name = 0); - ~CupsdSplash(); - - bool loadConfig(CupsdConf *conf, TQString& msg); - bool saveConfig(CupsdConf *conf, TQString& msg); -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/editlist.cpp b/kdeprint/cups/cupsdconf2/editlist.cpp deleted file mode 100644 index 754c9659e..000000000 --- a/kdeprint/cups/cupsdconf2/editlist.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "editlist.h" - -#include <klistbox.h> -#include <kpushbutton.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kguiitem.h> - -EditList::EditList(TQWidget *parent, const char *name) - : TQWidget(parent, name) -{ - list_ = new KListBox(this); - addbtn_ = new KPushButton(KGuiItem(i18n("Add..."), "filenew"), this); - editbtn_ = new KPushButton(KGuiItem(i18n("Edit..."), "edit"), this); - delbtn_ = new KPushButton(KGuiItem(i18n("Delete"), "editdelete"), this); - defbtn_ = new KPushButton(KGuiItem(i18n("Default List"), "history"), this); - - TQGridLayout *m1 = new TQGridLayout(this, 4, 2, 0, 0); - m1->setColStretch(0, 1); - m1->addMultiCellWidget(list_, 0, 3, 0, 1); - m1->addWidget(addbtn_, 0, 1); - m1->addWidget(editbtn_, 1, 1); - m1->addWidget(delbtn_, 2, 1); - m1->addWidget(defbtn_, 3, 1); - - connect(addbtn_, TQT_SIGNAL(clicked()), TQT_SIGNAL(add())); - connect(editbtn_, TQT_SIGNAL(clicked()), TQT_SLOT(slotEdit())); - connect(delbtn_, TQT_SIGNAL(clicked()), TQT_SLOT(slotDelete())); - connect(defbtn_, TQT_SIGNAL(clicked()), TQT_SIGNAL(defaultList())); - connect(list_, TQT_SIGNAL(highlighted(int)), TQT_SLOT(slotSelected(int))); - slotSelected(-1); -} - -void EditList::slotEdit() -{ - int index = list_->currentItem(); - if (index >= 0) - emit edit(index); -} - -void EditList::slotDelete() -{ - int index = list_->currentItem(); - list_->removeItem(index); - slotSelected((list_->count() > 0 ? list_->currentItem() : -1)); - emit deleted(index); -} - -void EditList::slotSelected(int index) -{ - editbtn_->setEnabled(index >= 0); - delbtn_->setEnabled(index >= 0); -} - -TQString EditList::text(int index) -{ - return list_->text(index); -} - -void EditList::setText(int index, const TQString& s) -{ - if (list_->text(index) != s) - { - TQListBoxItem *it = list_->findItem(s, TQt::ExactMatch); - if (!it) - list_->changeItem(s, index); - else - list_->removeItem(index); - } -} - -void EditList::clear() -{ - list_->clear(); - slotSelected(-1); -} - -void EditList::insertItem(const TQString& s) -{ - if (!list_->findItem(s, TQt::ExactMatch)) - list_->insertItem(s); -} - -void EditList::insertItem(const TQPixmap& icon, const TQString& s) -{ - if (!list_->findItem(s, TQt::ExactMatch)) - list_->insertItem(icon, s); -} - -void EditList::insertItems(const TQStringList& l) -{ - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - insertItem(*it); -} - -TQStringList EditList::items() -{ - TQStringList l; - for (uint i=0; i<list_->count(); i++) - l << list_->text(i); - return l; -} - -#include "editlist.moc" diff --git a/kdeprint/cups/cupsdconf2/editlist.h b/kdeprint/cups/cupsdconf2/editlist.h deleted file mode 100644 index a0fc7ee0a..000000000 --- a/kdeprint/cups/cupsdconf2/editlist.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 EDITLIST_H -#define EDITLIST_H - -#include <tqwidget.h> -#include <tqpixmap.h> - -class KListBox; -class TQPushButton; - -class EditList : public TQWidget -{ - Q_OBJECT - -public: - EditList(TQWidget *parent = 0, const char *name = 0); - - TQString text(int); - void setText(int, const TQString&); - void insertItem(const TQString&); - void insertItem(const TQPixmap&, const TQString&); - void insertItems(const TQStringList&); - TQStringList items(); - void clear(); - -signals: - void add(); - void edit(int); - void defaultList(); - void deleted(int); - -protected slots: - void slotDelete(); - void slotEdit(); - void slotSelected(int); - -private: - KListBox *list_; - TQPushButton *addbtn_, *editbtn_, *delbtn_, *defbtn_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/kde_logo.png b/kdeprint/cups/cupsdconf2/kde_logo.png deleted file mode 100644 index 6ba204607..000000000 Binary files a/kdeprint/cups/cupsdconf2/kde_logo.png and /dev/null differ diff --git a/kdeprint/cups/cupsdconf2/locationdialog.cpp b/kdeprint/cups/cupsdconf2/locationdialog.cpp deleted file mode 100644 index 7e1858cc7..000000000 --- a/kdeprint/cups/cupsdconf2/locationdialog.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "locationdialog.h" -#include "cupsdconf.h" -#include "editlist.h" -#include "addressdialog.h" - -#include <tqlineedit.h> -#include <tqcombobox.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqpushbutton.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <kiconloader.h> - -LocationDialog::LocationDialog(TQWidget *parent, const char *name) - : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true) -{ - TQWidget *dummy = new TQWidget(this); - setMainWidget(dummy); - resource_ = new TQComboBox(dummy); - authtype_ = new TQComboBox(dummy); - authclass_ = new TQComboBox(dummy); - authname_ = new TQLineEdit(dummy); - encryption_ = new TQComboBox(dummy); - satisfy_ = new TQComboBox(dummy); - order_ = new TQComboBox(dummy); - addresses_ = new EditList(dummy); - - authtype_->insertItem(i18n("None")); - authtype_->insertItem(i18n("Basic")); - authtype_->insertItem(i18n("Digest")); - - authclass_->insertItem(i18n("None")); - authclass_->insertItem(i18n("User")); - authclass_->insertItem(i18n("System")); - authclass_->insertItem(i18n("Group")); - - encryption_->insertItem(i18n("Always")); - encryption_->insertItem(i18n("Never")); - encryption_->insertItem(i18n("Required")); - encryption_->insertItem(i18n("If Requested")); - - satisfy_->insertItem(i18n("All")); - satisfy_->insertItem(i18n("Any")); - - order_->insertItem(i18n("Allow, Deny")); - order_->insertItem(i18n("Deny, Allow")); - - connect(authclass_, TQT_SIGNAL(activated(int)), TQT_SLOT(slotClassChanged(int))); - connect(authtype_, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged(int))); - - TQLabel *l1 = new TQLabel(i18n("Resource:"), dummy); - TQLabel *l2 = new TQLabel(i18n("Authentication:"), dummy); - TQLabel *l3 = new TQLabel(i18n("Class:"), dummy); - TQLabel *l4 = new TQLabel(i18n("Names:"), dummy); - TQLabel *l5 = new TQLabel(i18n("Encryption:"), dummy); - TQLabel *l6 = new TQLabel(i18n("Satisfy:"), dummy); - TQLabel *l7 = new TQLabel(i18n("ACL order:"), dummy); - TQLabel *l8 = new TQLabel(i18n("ACL addresses:"),dummy); - - TQGridLayout *m1 = new TQGridLayout(dummy, 8, 2, 0, 5); - m1->setColStretch(1, 1); - m1->addWidget(l1, 0, 0, Qt::AlignRight); - m1->addWidget(l2, 1, 0, Qt::AlignRight); - m1->addWidget(l3, 2, 0, Qt::AlignRight); - m1->addWidget(l4, 3, 0, Qt::AlignRight); - m1->addWidget(l5, 4, 0, Qt::AlignRight); - m1->addWidget(l6, 5, 0, Qt::AlignRight); - m1->addWidget(l7, 6, 0, Qt::AlignRight); - m1->addWidget(l8, 7, 0, Qt::AlignRight|Qt::AlignTop); - m1->addWidget(resource_, 0, 1); - m1->addWidget(authtype_, 1, 1); - m1->addWidget(authclass_, 2, 1); - m1->addWidget(authname_, 3, 1); - m1->addWidget(encryption_, 4, 1); - m1->addWidget(satisfy_, 5, 1); - m1->addWidget(order_, 6, 1); - m1->addWidget(addresses_, 7, 1); - - setCaption(i18n("Location")); - resize(400, 100); - - slotTypeChanged(AUTHTYPE_NONE); - slotClassChanged(AUTHCLASS_ANONYMOUS); - encryption_->setCurrentItem(ENCRYPT_IFREQUESTED); - - connect(addresses_, TQT_SIGNAL(add()), TQT_SLOT(slotAdd())); - connect(addresses_, TQT_SIGNAL(edit(int)), TQT_SLOT(slotEdit(int))); - connect(addresses_, TQT_SIGNAL(defaultList()), TQT_SLOT(slotDefaultList())); -} - -void LocationDialog::setInfos(CupsdConf *conf) -{ - conf_ = conf; - - TQPtrListIterator<CupsResource> it(conf->resources_); - for (; it.current(); ++it) - resource_->insertItem(SmallIcon(it.current()->typeToIconName(it.current()->type_)), it.current()->text_); - - TQWhatsThis::add(encryption_, conf_->comments_.toolTip("encryption")); - TQWhatsThis::add(order_, conf_->comments_.toolTip("order")); - TQWhatsThis::add(authclass_, conf_->comments_.toolTip("authclass")); - TQWhatsThis::add(authtype_, conf_->comments_.toolTip("authtype")); - TQWhatsThis::add(authname_, conf_->comments_.toolTip("authname")); - TQWhatsThis::add(satisfy_, conf_->comments_.toolTip("satisfy")); - TQWhatsThis::add(addresses_, conf_->comments_.toolTip("allowdeny")); -} - -void LocationDialog::fillLocation(CupsLocation *loc) -{ - loc->resource_ = conf_->resources_.tqat(resource_->currentItem()); - loc->resourcename_ = loc->resource_->path_; - loc->authtype_ = authtype_->currentItem(); - loc->authclass_ = (loc->authtype_ == AUTHTYPE_NONE ? AUTHCLASS_ANONYMOUS : authclass_->currentItem()); - loc->authname_ = (loc->authclass_ == AUTHCLASS_USER || loc->authclass_ == AUTHCLASS_GROUP ? authname_->text() : TQString::null); - loc->encryption_ = encryption_->currentItem(); - loc->satisfy_ = satisfy_->currentItem(); - loc->order_ = order_->currentItem(); - loc->addresses_ = addresses_->items(); -} - -void LocationDialog::setLocation(CupsLocation *loc) -{ - int index = conf_->resources_.findRef(loc->resource_); - resource_->setCurrentItem(index); - authtype_->setCurrentItem(loc->authtype_); - authclass_->setCurrentItem(loc->authclass_); - authname_->setText(loc->authname_); - encryption_->setCurrentItem(loc->encryption_); - satisfy_->setCurrentItem(loc->satisfy_); - order_->setCurrentItem(loc->order_); - addresses_->insertItems(loc->addresses_); - - slotTypeChanged(loc->authtype_); - slotClassChanged(loc->authclass_); -} - -void LocationDialog::slotTypeChanged(int index) -{ - authclass_->setEnabled(index != AUTHTYPE_NONE); - if (index != AUTHTYPE_NONE) - slotClassChanged(authclass_->currentItem()); - else - authname_->setEnabled(false); -} - -void LocationDialog::slotClassChanged(int index) -{ - authname_->setEnabled((index == AUTHCLASS_USER || index == AUTHCLASS_GROUP)); -} - -bool LocationDialog::newLocation(CupsLocation *loc, TQWidget *parent, CupsdConf *conf) -{ - LocationDialog dlg(parent); - if (conf) - dlg.setInfos(conf); - if (dlg.exec()) - { - dlg.fillLocation(loc); - return true; - } - else - return false; -} - -bool LocationDialog::editLocation(CupsLocation *loc, TQWidget *parent, CupsdConf *conf) -{ - LocationDialog dlg(parent); - if (conf) - dlg.setInfos(conf); - dlg.setLocation(loc); - dlg.resource_->setEnabled(false); - if (dlg.exec()) - { - dlg.fillLocation(loc); - return true; - } - else - return false; -} - -void LocationDialog::slotAdd() -{ - TQString addr = AddressDialog::newAddress(this); - if (!addr.isEmpty()) - addresses_->insertItem(addr); -} - -void LocationDialog::slotEdit(int index) -{ - TQString addr = addresses_->text(index); - addr = AddressDialog::editAddress(addr, this); - if (!addr.isEmpty()) - addresses_->insertItem(addr); -} - -void LocationDialog::slotDefaultList() -{ - addresses_->clear(); -} - -#include "locationdialog.moc" diff --git a/kdeprint/cups/cupsdconf2/locationdialog.h b/kdeprint/cups/cupsdconf2/locationdialog.h deleted file mode 100644 index f0c182f42..000000000 --- a/kdeprint/cups/cupsdconf2/locationdialog.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 LOCATIONDIALOG_H -#define LOCATIONDIALOG_H - -#include <kdialogbase.h> - -class TQComboBox; -class TQLineEdit; -class EditList; -struct CupsdConf; -struct CupsLocation; - -class LocationDialog : public KDialogBase -{ - Q_OBJECT -public: - LocationDialog(TQWidget *parent = 0, const char *name = 0); - - void setInfos(CupsdConf*); - void fillLocation(CupsLocation*); - void setLocation(CupsLocation*); - - static bool newLocation(CupsLocation*, TQWidget *parent = 0, CupsdConf *conf = 0); - static bool editLocation(CupsLocation*, TQWidget *parent = 0, CupsdConf *conf = 0); - -protected slots: - void slotTypeChanged(int); - void slotClassChanged(int); - void slotAdd(); - void slotEdit(int); - void slotDefaultList(); - -private: - TQComboBox *resource_, *authtype_, *authclass_, *encryption_, *satisfy_, *order_; - TQLineEdit *authname_; - EditList *addresses_; - CupsdConf *conf_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/main.cpp b/kdeprint/cups/cupsdconf2/main.cpp deleted file mode 100644 index f3c317afd..000000000 --- a/kdeprint/cups/cupsdconf2/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsddialog.h" - -#include <tqfile.h> -#include <klocale.h> -#include <kcmdlineargs.h> -#include <kapplication.h> - -static KCmdLineOptions options[] = -{ - { "+[file]", I18N_NOOP("Configuration file to load"), 0}, - KCmdLineLastOption -}; - -extern "C" KDE_EXPORT int kdemain(int argc, char *argv[]) -{ - KCmdLineArgs::init(argc,argv,"cupsdconf", - I18N_NOOP("A CUPS configuration tool"), - I18N_NOOP("A CUPS configuration tool"),"0.0.1"); - KCmdLineArgs::addCmdLineOptions(options); - KApplication app; - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - KURL configfile; - if (args->count() > 0) - CupsdDialog::configure(args->url(0).path()); - else - CupsdDialog::configure(); - return (0); -} diff --git a/kdeprint/cups/cupsdconf2/portdialog.cpp b/kdeprint/cups/cupsdconf2/portdialog.cpp deleted file mode 100644 index 18cade9fc..000000000 --- a/kdeprint/cups/cupsdconf2/portdialog.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "portdialog.h" -#include "cupsdconf.h" - -#include <tqlineedit.h> -#include <tqspinbox.h> -#include <tqcheckbox.h> -#include <tqpushbutton.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <klocale.h> - -PortDialog::PortDialog(TQWidget *parent, const char *name) - : KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true) -{ - TQWidget *dummy = new TQWidget(this); - setMainWidget(dummy); - address_ = new TQLineEdit(dummy); - port_ = new TQSpinBox(0, 9999, 1, dummy); - port_->setValue(631); - usessl_ = new TQCheckBox(i18n("Use SSL encryption"), dummy); - - TQLabel *l1 = new TQLabel(i18n("Address:"), dummy); - TQLabel *l2 = new TQLabel(i18n("Port:"), dummy); - - TQVBoxLayout *m1 = new TQVBoxLayout(dummy, 0, 10); - TQGridLayout *m2 = new TQGridLayout(0, 3, 2, 0, 5); - m1->addLayout(TQT_TQLAYOUT(m2)); - m2->addWidget(l1, 0, 0, Qt::AlignRight); - m2->addWidget(l2, 1, 0, Qt::AlignRight); - m2->addMultiCellWidget(usessl_, 2, 2, 0, 1); - m2->addWidget(address_, 0, 1); - m2->addWidget(port_, 1, 1); - - setCaption(i18n("Listen To")); - resize(250, 100); -} - -TQString PortDialog::listenString() -{ - TQString s; - if (usessl_->isChecked()) - s.append("SSLListen "); - else - s.append("Listen "); - if (!address_->text().isEmpty()) - s.append(address_->text()); - else - s.append("*"); - s.append(":").append(port_->text()); - return s; -} - -void PortDialog::setInfos(CupsdConf *conf) -{ - TQWhatsThis::add(address_, conf->comments_.toolTip("address")); - TQWhatsThis::add(port_, conf->comments_.toolTip("port")); - TQWhatsThis::add(usessl_, conf->comments_.toolTip("usessl")); -} - -TQString PortDialog::newListen(TQWidget *parent, CupsdConf *conf) -{ - PortDialog dlg(parent); - dlg.setInfos(conf); - if (dlg.exec()) - { - return dlg.listenString(); - } - return TQString::null; -} - -TQString PortDialog::editListen(const TQString& s, TQWidget *parent, CupsdConf *conf) -{ - PortDialog dlg(parent); - dlg.setInfos(conf); - int p = s.find(' '); - if (p != -1) - { - dlg.usessl_->setChecked(s.left(p).startsWith("SSL")); - TQString addr = s.mid(p+1).stripWhiteSpace(); - int p1 = addr.find(':'); - if (p1 == -1) - { - dlg.address_->setText(addr); - dlg.port_->setValue(631); - } - else - { - dlg.address_->setText(addr.left(p1)); - dlg.port_->setValue(addr.mid(p1+1).toInt()); - } - } - if (dlg.exec()) - { - return dlg.listenString(); - } - return TQString::null; -} diff --git a/kdeprint/cups/cupsdconf2/portdialog.h b/kdeprint/cups/cupsdconf2/portdialog.h deleted file mode 100644 index 42dd7037b..000000000 --- a/kdeprint/cups/cupsdconf2/portdialog.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 PORTDIALOG_H -#define PORTDIALOG_H - -#include <kdialogbase.h> - -class TQLineEdit; -class TQSpinBox; -class TQCheckBox; -struct CupsdConf; - -class PortDialog : public KDialogBase -{ -public: - PortDialog(TQWidget *parent = 0, const char *name = 0); - - TQString listenString(); - void setInfos(CupsdConf*); - static TQString newListen(TQWidget *parent = 0, CupsdConf *conf = 0); - static TQString editListen(const TQString& s, TQWidget *parent = 0, CupsdConf *conf = 0); - -private: - TQLineEdit *address_; - TQSpinBox *port_; - TQCheckBox *usessl_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/qdirlineedit.cpp b/kdeprint/cups/cupsdconf2/qdirlineedit.cpp deleted file mode 100644 index 7cf0ea74e..000000000 --- a/kdeprint/cups/cupsdconf2/qdirlineedit.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "qdirlineedit.h" - -#include <tqlineedit.h> -#include <tqlayout.h> -#include <kpushbutton.h> -#include <kfiledialog.h> -#include <kiconloader.h> - -QDirLineEdit::QDirLineEdit(bool file, TQWidget *parent, const char *name) - : TQWidget(parent, name) -{ - edit_ = new TQLineEdit(this); - button_ = new KPushButton(this); - button_->setPixmap(SmallIcon("fileopen")); - connect(button_,TQT_SIGNAL(clicked()),TQT_SLOT(buttonClicked())); - - TQHBoxLayout *main_ = new TQHBoxLayout(this, 0, 3); - main_->addWidget(edit_); - main_->addWidget(button_); - - fileedit_ = file; -} - -QDirLineEdit::~QDirLineEdit() -{ -} - -void QDirLineEdit::setURL(const TQString& txt) -{ - edit_->setText(txt); -} - -TQString QDirLineEdit::url() -{ - return edit_->text(); -} - -void QDirLineEdit::buttonClicked() -{ - TQString dirname; - if (!fileedit_) - dirname = KFileDialog::getExistingDirectory(edit_->text(), this); - else - dirname = KFileDialog::getOpenFileName(edit_->text(), TQString::null, this); - if (!dirname.isEmpty()) - edit_->setText(dirname); -} - -void QDirLineEdit::setFileEdit(bool on) -{ - fileedit_ = on; -} - -#include "qdirlineedit.moc" diff --git a/kdeprint/cups/cupsdconf2/qdirlineedit.h b/kdeprint/cups/cupsdconf2/qdirlineedit.h deleted file mode 100644 index d852897c3..000000000 --- a/kdeprint/cups/cupsdconf2/qdirlineedit.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 QDIRLINEEDIT_H -#define QDIRLINEEDIT_H - -#include <tqwidget.h> -#include <tqstring.h> - -class TQLineEdit; -class TQPushButton; - -class QDirLineEdit : public TQWidget -{ - Q_OBJECT -public: - QDirLineEdit(bool file, TQWidget *parent = 0, const char *name = 0); - ~QDirLineEdit(); - - void setURL(const TQString& txt); - TQString url(); - void setFileEdit(bool on = true); - -private slots: - void buttonClicked(); - -private: - TQLineEdit *edit_; - TQPushButton *button_; - bool fileedit_; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/qdirmultilineedit.cpp b/kdeprint/cups/cupsdconf2/qdirmultilineedit.cpp deleted file mode 100644 index e677da988..000000000 --- a/kdeprint/cups/cupsdconf2/qdirmultilineedit.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "qdirmultilineedit.h" - -#include <tqlayout.h> -#include <tqheader.h> -#include <tqpushbutton.h> -#include <klistview.h> -#include <klocale.h> -#include <kfiledialog.h> -#include <kiconloader.h> - -QDirMultiLineEdit::QDirMultiLineEdit(TQWidget *parent, const char *name) -: TQWidget(parent, name) -{ - m_view = new KListView(this); - m_view->header()->hide(); - m_view->addColumn(""); - m_view->setFullWidth(true); - connect(m_view, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotSelected(TQListViewItem*))); - - m_add = new TQPushButton(this); - m_add->setPixmap(SmallIcon("folder_new")); - connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddClicked())); - m_remove = new TQPushButton(this); - m_remove->setPixmap(SmallIcon("editdelete")); - connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveClicked())); - m_remove->setEnabled(false); - - m_view->setFixedHeight(TQMAX(m_view->fontMetrics().lineSpacing()*3+m_view->lineWidth()*2, m_add->tqsizeHint().height()*2)); - - TQHBoxLayout *l0 = new TQHBoxLayout(this, 0, 3); - TQVBoxLayout *l1 = new TQVBoxLayout(0, 0, 0); - l0->addWidget(m_view); - l0->addLayout(l1); - l1->addWidget(m_add); - l1->addWidget(m_remove); - l1->addStretch(1); -} - -QDirMultiLineEdit::~QDirMultiLineEdit() -{ -} - -void QDirMultiLineEdit::setURLs(const TQStringList& urls) -{ - m_view->clear(); - for (TQStringList::ConstIterator it=urls.begin(); it!=urls.end(); ++it) - addURL(*it); -} - -TQStringList QDirMultiLineEdit::urls() -{ - TQListViewItem *item = m_view->firstChild(); - TQStringList l; - while (item) - { - l << item->text(0); - item = item->nextSibling(); - } - return l; -} - -void QDirMultiLineEdit::addURL(const TQString& url) -{ - TQListViewItem *item = new TQListViewItem(m_view, url); - item->setRenameEnabled(0, true); -} - -void QDirMultiLineEdit::slotAddClicked() -{ - TQString dirname = KFileDialog::getExistingDirectory(TQString::null, this); - if (!dirname.isEmpty()) - addURL(dirname); -} - -void QDirMultiLineEdit::slotRemoveClicked() -{ - TQListViewItem *item = m_view->currentItem(); - if (item) - { - delete item; - slotSelected(m_view->currentItem()); - } -} - -void QDirMultiLineEdit::slotSelected(TQListViewItem *item) -{ - m_remove->setEnabled((item != NULL)); -} - -#include "qdirmultilineedit.moc" diff --git a/kdeprint/cups/cupsdconf2/qdirmultilineedit.h b/kdeprint/cups/cupsdconf2/qdirmultilineedit.h deleted file mode 100644 index c3765362e..000000000 --- a/kdeprint/cups/cupsdconf2/qdirmultilineedit.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 QDIRMULTILINEEDIT_H -#define QDIRMULTILINEEDIT_H - -#include <tqwidget.h> - -class KListView; -class TQListViewItem; -class TQPushButton; - -class QDirMultiLineEdit : public TQWidget -{ - Q_OBJECT - -public: - QDirMultiLineEdit(TQWidget *parent = 0, const char *name = 0); - ~QDirMultiLineEdit(); - - void setURLs(const TQStringList&); - TQStringList urls(); - -protected: - void addURL(const TQString&); - -private slots: - void slotAddClicked(); - void slotRemoveClicked(); - void slotSelected(TQListViewItem*); - -private: - KListView *m_view; - TQPushButton *m_add, *m_remove; -}; - -#endif diff --git a/kdeprint/cups/cupsdconf2/sizewidget.cpp b/kdeprint/cups/cupsdconf2/sizewidget.cpp deleted file mode 100644 index 742702e48..000000000 --- a/kdeprint/cups/cupsdconf2/sizewidget.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "sizewidget.h" - -#include <tqcombobox.h> -#include <tqspinbox.h> -#include <tqlayout.h> -#include <tqregexp.h> -#include <klocale.h> - -SizeWidget::SizeWidget( TQWidget *parent, const char *name ) - : TQWidget( parent, name ) -{ - m_size = new TQSpinBox( 0, 9999, 1, this ); - m_unit = new TQComboBox( this ); - - m_unit->insertItem( i18n( "KB" ) ); - m_unit->insertItem( i18n( "MB" ) ); - m_unit->insertItem( i18n( "GB" ) ); - m_unit->insertItem( i18n( "Tiles" ) ); - m_unit->setCurrentItem( 1 ); - m_size->setSpecialValueText( i18n( "Unlimited" ) ); - - TQHBoxLayout *l0 = new TQHBoxLayout( this, 0, 5 ); - l0->addWidget( m_size, 1 ); - l0->addWidget( m_unit, 0 ); -} - -void SizeWidget::setSizeString( const TQString& sz ) -{ - int p = sz.find( TQRegExp( "\\D" ) ); - m_size->setValue( sz.left( p ).toInt() ); - switch( sz[ p ].latin1() ) - { - case 'k': p = 0; break; - default: - case 'm': p = 1; break; - case 'g': p = 2; break; - case 't': p = 3; break; - } - m_unit->setCurrentItem( p ); -} - -TQString SizeWidget::sizeString() const -{ - TQString result = TQString::number( m_size->value() ); - switch ( m_unit->currentItem() ) - { - case 0: result.append( "k" ); break; - case 1: result.append( "m" ); break; - case 2: result.append( "g" ); break; - case 3: result.append( "t" ); break; - } - return result; -} - -void SizeWidget::setValue( int value ) -{ - m_size->setValue( value ); - m_unit->setCurrentItem( 1 ); -} - -int SizeWidget::value() const -{ - return m_size->value(); -} diff --git a/kdeprint/cups/cupsdconf2/sizewidget.h b/kdeprint/cups/cupsdconf2/sizewidget.h deleted file mode 100644 index 000fb22bc..000000000 --- a/kdeprint/cups/cupsdconf2/sizewidget.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 SIZEWIDGET_H -#define SIZEWIDGET_H - -#include <tqwidget.h> - -class TQSpinBox; -class TQComboBox; - -class SizeWidget : public TQWidget -{ -public: - SizeWidget( TQWidget *parent = 0, const char *name = 0 ); - - void setSizeString( const TQString& sizeString ); - TQString sizeString() const; - void setValue( int sz ); - int value() const; - -private: - TQSpinBox *m_size; - TQComboBox *m_unit; -}; - -#endif diff --git a/kdeprint/cups/cupsdoprint.c b/kdeprint/cups/cupsdoprint.c deleted file mode 100644 index a12a2adf8..000000000 --- a/kdeprint/cups/cupsdoprint.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 <unistd.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> - -#include <cups/cups.h> -#include <cups/ipp.h> - -#define BUFSIZE 1024 -#define BUFSIZE2 32 - -#define USE_LOG 0 - -/* global variables */ -char passwd[BUFSIZE2] = {0}; -int pwd_asked = 0; -#if USE_LOG -FILE *debugF = NULL; -#endif - -/* utility functions */ -static void error(const char* msg) -{ - fprintf(stderr, "%s\n", msg); -#if USE_LOG - if (debugF != NULL) fclose(debugF); -#endif - exit(-1); -} - -static void usage() -{ - error("usage: cupsdoprint [-H host[:port]][-P dest][-J name][-o opt=value[,...]][-U login[:password]] files..."); -} - -static char * shell_quote(const char *s) -{ - char *result; - char *p; - p = result = malloc(strlen(s)*4+3); - *p++ = '\''; - while(*s) - { - if (*s == '\'') - { - *p++ = '\''; - *p++ = '\\'; - *p++ = '\''; - *p++ = '\''; - s++; - } - else - { - *p++ = *s++; - } - } - *p++ = '\''; - *p = '\0'; - return result; -} - -static const char* getPasswordCB(const char* prompt) -{ - char buf[ 256 ] = {0}, *c; - char *_user = shell_quote( cupsUser() ), *_passwd = NULL; - FILE *output; - - snprintf( buf, sizeof( buf )-1, "dcop kded tdeprintd requestPassword %s %s %d %d", - _user, - cupsServer(), - ippPort(), - pwd_asked ); - free( _user ); - _user = NULL; - output = popen( buf, "r" ); - if ( output != NULL ) - { - while ( fgets( buf, sizeof( buf )-1, output ) ) - { - _user = _passwd = NULL; - if ( strcmp( buf, "::" ) != 0 ) - { - c = strchr( buf, ':' ); - if ( c != NULL ) - { - *c = '\0'; - _user = buf; - _passwd = ++c; - c = strchr( c, ':' ); - if ( c != NULL ) - { - *c = '\0'; - /* retrieve password sequence number */ - pwd_asked = atoi( ++c ); - /* update CUPS with current username */ - cupsSetUser( _user ); - /* copy password to a non temporary location */ - strlcpy( passwd, _passwd, BUFSIZE2 ); - _passwd = passwd; - } - else - _passwd = NULL; - } - } - } - pclose( output ); - } - else - return NULL; - - /* erase buffer containing unencrypted password, for security */ - memset( buf, 0, 256 ); - - /* if OK, _passwd should point to global passwd variable, otherwise it should be NULL */ - return _passwd; -} - -/* main function */ -int main(int argc, char* argv[]) -{ - int c, port = -1; - char printer[BUFSIZE] = {0}, jobname[BUFSIZE] = {0}, host[BUFSIZE] = {0}; - char login[BUFSIZE2] = {0}; - char *a; - cups_option_t *options = NULL; - int num_options = 0; - char* files[100] = {0}; - int num_files = 0; - int jobID = 0; - -#if USE_LOG - debugF = fopen("/tmp/cupsdoprint.debug","w"); - if (debugF == NULL) - error("unable to open log file"); -#endif - - while ((c=getopt(argc, argv, "P:J:H:o:U:?")) != -1) - { -#if USE_LOG - fprintf(debugF,"%c: %s\n",c,optarg); -#endif - switch (c) - { - case 'P': - strlcpy(printer, optarg, BUFSIZE); - if ((a=strchr(printer, '/')) != NULL) - error("This utility doesn't support printer instances"); - break; - case 'J': - strlcpy(jobname, optarg, BUFSIZE); - break; - case 'H': - strlcpy(host, optarg, BUFSIZE); - if ((a=strchr(host, ':')) != NULL) - { - *a = 0; - port = atoi(++a); - if (port == 0) - error("Wrong port value"); - } - break; - case 'U': - strlcpy(login, optarg, BUFSIZE2); - if ((a=strchr(login, ':')) != NULL) - { - *a = 0; - strlcpy(passwd, ++a, BUFSIZE2); - } - break; - case 'o': -#if USE_LOG - fprintf(debugF,"Parsing options (n=%d)\n",num_options); -#endif - num_options = cupsParseOptions(optarg, num_options, &options); -#if USE_LOG - fprintf(debugF,"Options parsed (n=%d)\n",num_options); -#endif - break; - case '?': - default: - usage(); - break; - } - } - - /* check the printer */ - if (!*printer) - { - printer[BUFSIZE-1] = '\0'; - if (getenv("PRINTER") != NULL) - strlcpy(printer, getenv("PRINTER"), BUFSIZE-1); - else - error("No printer specified (and PRINTER variable is empty)"); - } - - /* CUPS settings */ - if (host[0] != 0) cupsSetServer(host); - if (port > 0) ippSetPort(port); - if (login[0] != 0) cupsSetUser(login); - if (jobname[0] == 0) strcpy(jobname,"KDE Print System"); - cupsSetPasswordCB(getPasswordCB); - - /* check for files */ - if (optind < 1 || optind >= argc) - error("This utility doesn't support printing from STDIN"); - else - for (c=optind; c<argc; c++) - { - if (access(argv[c], R_OK) != 0) - { - fprintf(stderr, "%s: ", argv[c]); - error("file not found or not readable"); - } - else - files[num_files++] = strdup(argv[c]); - } - -#if USE_LOG - fprintf(debugF,"Processed options:\n"); - for (c=0; c<num_options; c++) - fprintf(debugF,"%s = %s\n",options[c].name,options[c].value); -#endif - /* print files */ - jobID = cupsPrintFiles(printer, num_files, files, jobname, num_options, options); - /* erase unemcrypted password for security */ - memset( passwd, 0, BUFSIZE2 ); - /* check job creation status */ - if (jobID <= 0) - error(ippErrorString(cupsLastError())); - -#if USE_LOG - fclose(debugF); -#endif - return 0; -} diff --git a/kdeprint/cups/cupsinfos.cpp b/kdeprint/cups/cupsinfos.cpp deleted file mode 100644 index 1fae8e0db..000000000 --- a/kdeprint/cups/cupsinfos.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cupsinfos.h" -#include "kmfactory.h" -#include "kmtimer.h" -#include "messagewindow.h" - -#include <kio/passdlg.h> -#include <kio/authinfo.h> -#include <klocale.h> -#include <kconfig.h> -#include <kapplication.h> -#include <dcopclient.h> -#include <kdebug.h> -#include <kstringhandler.h> - -#include <cups/cups.h> -#include <cups/ipp.h> - -const char* cupsGetPasswordCB(const char*) -{ - return CupsInfos::self()->getPasswordCB(); -} - -CupsInfos* CupsInfos::unique_ = 0; - -CupsInfos* CupsInfos::self() -{ - if (!unique_) - { - unique_ = new CupsInfos(); - } - return unique_; -} - -CupsInfos::CupsInfos() -: KPReloadObject(true) -{ - count_ = 0; - - load(); -/* host_ = cupsServer(); - login_ = cupsUser(); - if (login_.isEmpty()) login_ = TQString(); - port_ = ippPort(); - password_ = TQString();*/ - - cupsSetPasswordCB(cupsGetPasswordCB); -} - -CupsInfos::~CupsInfos() -{ -} - -TQString CupsInfos::hostaddr() const -{ - if (host_[0] != '/') - return host_ + ":" + TQString::number(port_); - return "localhost"; -} - -void CupsInfos::setHost(const TQString& s) -{ - host_ = s; - cupsSetServer(s.latin1()); -} - -void CupsInfos::setPort(int p) -{ - port_ = p; - ippSetPort(p); -} - -void CupsInfos::setLogin(const TQString& s) -{ - login_ = s; - cupsSetUser(s.latin1()); -} - -void CupsInfos::setPassword(const TQString& s) -{ - password_ = s; -} - -void CupsInfos::setSavePassword( bool on ) -{ - savepwd_ = on; -} - -const char* CupsInfos::getPasswordCB() -{ - TQPair<TQString,TQString> pwd = KMFactory::self()->requestPassword( count_, login_, host_, port_ ); - - if ( pwd.first.isEmpty() && pwd.second.isEmpty() ) - return NULL; - setLogin( pwd.first ); - setPassword( pwd.second ); - return pwd.second.latin1(); -} - -void CupsInfos::load() -{ - KConfig *conf_ = KMFactory::self()->printConfig(); - conf_->setGroup("CUPS"); - host_ = conf_->readEntry("Host",TQString::tqfromLatin1(cupsServer())); - port_ = conf_->readNumEntry("Port",ippPort()); - login_ = conf_->readEntry("Login",TQString::tqfromLatin1(cupsUser())); - savepwd_ = conf_->readBoolEntry( "SavePassword", false ); - if ( savepwd_ ) - { - password_ = KStringHandler::obscure( conf_->readEntry( "Password" ) ); - KMFactory::self()->initPassword( login_, password_, host_, port_ ); - } - else - password_ = TQString(); - if (login_.isEmpty()) login_ = TQString(); - reallogin_ = cupsUser(); - - // synchronize with CUPS - cupsSetServer(host_.latin1()); - cupsSetUser(login_.latin1()); - ippSetPort(port_); -} - -void CupsInfos::save() -{ - KConfig *conf_ = KMFactory::self()->printConfig(); - conf_->setGroup("CUPS"); - conf_->writeEntry("Host",host_); - conf_->writeEntry("Port",port_); - conf_->writeEntry("Login",login_); - conf_->writeEntry( "SavePassword", savepwd_ ); - if ( savepwd_ ) - conf_->writeEntry( "Password", KStringHandler::obscure( password_ ) ); - else - conf_->deleteEntry( "Password" ); - conf_->sync(); -} - -void CupsInfos::reload() -{ - // do nothing, but needs to be implemented -} - -void CupsInfos::configChanged() -{ - // we need to reload settings - load(); -} diff --git a/kdeprint/cups/cupsinfos.h b/kdeprint/cups/cupsinfos.h deleted file mode 100644 index 5f74d3636..000000000 --- a/kdeprint/cups/cupsinfos.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CUPSINFOS_H -#define CUPSINFOS_H - -#include <tqstring.h> -#include "kpreloadobject.h" - -class CupsInfos : public KPReloadObject -{ -public: - static CupsInfos* self(); - - CupsInfos(); - ~CupsInfos(); - - const TQString& host() const; - TQString hostaddr() const; - int port() const; - const TQString& login() const; - const TQString& password() const; - const TQString& realLogin() const; - bool savePassword() const; - - void setHost(const TQString& s); - void setPort(int p); - void setLogin(const TQString& s); - void setPassword(const TQString& s); - void setSavePassword( bool on ); - - const char* getPasswordCB(); - - void load(); - void save(); - -protected: - void reload(); - void configChanged(); - -private: - static CupsInfos *unique_; - - TQString host_; - int port_; - TQString login_; - TQString password_; - TQString reallogin_; - bool savepwd_; - - int count_; -}; - -inline const TQString& CupsInfos::host() const -{ return host_; } - -inline int CupsInfos::port() const -{ return port_; } - -inline const TQString& CupsInfos::login() const -{ return login_; } - -inline const TQString& CupsInfos::password() const -{ return password_; } - -inline const TQString& CupsInfos::realLogin() const -{ return reallogin_; } - -inline bool CupsInfos::savePassword() const -{ return savepwd_; } - -#endif diff --git a/kdeprint/cups/image.cpp b/kdeprint/cups/image.cpp deleted file mode 100644 index ce56bb4b9..000000000 --- a/kdeprint/cups/image.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 <tqimage.h> -#include <math.h> - -void -mult(float a[3][3], /* I - First matrix */ - float b[3][3], /* I - Second matrix */ - float c[3][3]) /* I - Destination matrix */ -{ - int x, y; /* Looping vars */ - float temp[3][3]; /* Temporary matrix */ - - - /* - * Multiply a and b, putting the result in temp... - */ - - for (y = 0; y < 3; y ++) - for (x = 0; x < 3; x ++) - temp[y][x] = b[y][0] * a[0][x] + - b[y][1] * a[1][x] + - b[y][2] * a[2][x]; - - /* - * Copy temp to c (that way c can be a pointer to a or b). - */ - - memcpy(c, temp, sizeof(temp)); -} - -void -saturate(float mat[3][3], /* I - Matrix to append to */ - float sat) /* I - Desired color saturation */ -{ - float smat[3][3]; /* Saturation matrix */ - - - smat[0][0] = (1.0 - sat) * 0.3086 + sat; - smat[0][1] = (1.0 - sat) * 0.3086; - smat[0][2] = (1.0 - sat) * 0.3086; - smat[1][0] = (1.0 - sat) * 0.6094; - smat[1][1] = (1.0 - sat) * 0.6094 + sat; - smat[1][2] = (1.0 - sat) * 0.6094; - smat[2][0] = (1.0 - sat) * 0.0820; - smat[2][1] = (1.0 - sat) * 0.0820; - smat[2][2] = (1.0 - sat) * 0.0820 + sat; - - mult(smat, mat, mat); -} - -void -xform(float mat[3][3], /* I - Matrix */ - float x, /* I - Input X coordinate */ - float y, /* I - Input Y coordinate */ - float z, /* I - Input Z coordinate */ - float *tx, /* O - Output X coordinate */ - float *ty, /* O - Output Y coordinate */ - float *tz) /* O - Output Z coordinate */ -{ - *tx = x * mat[0][0] + y * mat[1][0] + z * mat[2][0]; - *ty = x * mat[0][1] + y * mat[1][1] + z * mat[2][1]; - *tz = x * mat[0][2] + y * mat[1][2] + z * mat[2][2]; -} - -void -xrotate(float mat[3][3], /* I - Matrix */ - float rs, /* I - Rotation angle sine */ - float rc) /* I - Rotation angle cosine */ -{ - float rmat[3][3]; /* I - Rotation matrix */ - - - rmat[0][0] = 1.0; - rmat[0][1] = 0.0; - rmat[0][2] = 0.0; - - rmat[1][0] = 0.0; - rmat[1][1] = rc; - rmat[1][2] = rs; - - rmat[2][0] = 0.0; - rmat[2][1] = -rs; - rmat[2][2] = rc; - - mult(rmat, mat, mat); -} - -void -yrotate(float mat[3][3], /* I - Matrix */ - float rs, /* I - Rotation angle sine */ - float rc) /* I - Rotation angle cosine */ -{ - float rmat[3][3]; /* I - Rotation matrix */ - - - rmat[0][0] = rc; - rmat[0][1] = 0.0; - rmat[0][2] = -rs; - - rmat[1][0] = 0.0; - rmat[1][1] = 1.0; - rmat[1][2] = 0.0; - - rmat[2][0] = rs; - rmat[2][1] = 0.0; - rmat[2][2] = rc; - - mult(rmat,mat,mat); -} - -void -zrotate(float mat[3][3], /* I - Matrix */ - float rs, /* I - Rotation angle sine */ - float rc) /* I - Rotation angle cosine */ -{ - float rmat[3][3]; /* I - Rotation matrix */ - - - rmat[0][0] = rc; - rmat[0][1] = rs; - rmat[0][2] = 0.0; - - rmat[1][0] = -rs; - rmat[1][1] = rc; - rmat[1][2] = 0.0; - - rmat[2][0] = 0.0; - rmat[2][1] = 0.0; - rmat[2][2] = 1.0; - - mult(rmat,mat,mat); -} - -void -zshear(float mat[3][3], /* I - Matrix */ - float dx, /* I - X shear */ - float dy) /* I - Y shear */ -{ - float smat[3][3]; /* Shear matrix */ - - - smat[0][0] = 1.0; - smat[0][1] = 0.0; - smat[0][2] = dx; - - smat[1][0] = 0.0; - smat[1][1] = 1.0; - smat[1][2] = dy; - - smat[2][0] = 0.0; - smat[2][1] = 0.0; - smat[2][2] = 1.0; - - mult(smat, mat, mat); -} - -void -huerotate(float mat[3][3], /* I - Matrix to append to */ - float rot) /* I - Hue rotation in degrees */ -{ - float hmat[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}; /* Hue matrix */ - float lx, ly, lz; /* Luminance vector */ - float xrs, xrc; /* X rotation sine/cosine */ - float yrs, yrc; /* Y rotation sine/cosine */ - float zrs, zrc; /* Z rotation sine/cosine */ - float zsx, zsy; /* Z shear x/y */ - - - /* - * Rotate the gray vector into positive Z... - */ - - xrs = M_SQRT1_2; - xrc = M_SQRT1_2; - xrotate(hmat,xrs,xrc); - - yrs = -1.0 / sqrt(3.0); - yrc = -M_SQRT2 * yrs; - yrotate(hmat,yrs,yrc); - - /* - * Shear the space to make the luminance plane horizontal... - */ - - xform(hmat, 0.3086, 0.6094, 0.0820, &lx, &ly, &lz); - zsx = lx / lz; - zsy = ly / lz; - zshear(hmat, zsx, zsy); - - /* - * Rotate the hue... - */ - - zrs = sin(rot * M_PI / 180.0); - zrc = cos(rot * M_PI / 180.0); - - zrotate(hmat, zrs, zrc); - - /* - * Unshear the space to put the luminance plane back... - */ - - zshear(hmat, -zsx, -zsy); - - /* - * Rotate the gray vector back into place... - */ - - yrotate(hmat, -yrs, yrc); - xrotate(hmat, -xrs, xrc); - - /* - * Append it to the current matrix... - */ - - mult(hmat, mat, mat); -} - -void -bright(float mat[3][3], - float scale) -{ - for (int i=0;i<3;i++) - for (int j=0;j<3;j++) - mat[i][j] *= scale; -} - -//---------------------------------------------------------------------------------------------------- - -TQImage convertImage(const TQImage& image, int hue, int saturation, int brightness, int gamma) -{ - float mat[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}; - int lut[3][3][256]; - QRgb c; - int r,g,b,v,r2,g2,b2; - float gam = 1.0/(float(gamma)/1000.0); - QImage img(image); - - saturate(mat,saturation*0.01); - huerotate(mat,(float)hue); - bright(mat,brightness*0.01); - for (int i = 0; i < 3; i ++) - for (int j = 0; j < 3; j ++) - for (int k = 0; k < 256; k ++) - lut[i][j][k] = (int)(mat[i][j] * k + 0.5); - - img.detach(); - for (int i=0;i<image.width();i++) - for (int j=0;j<image.height();j++) - { - c = image.pixel(i,j); - r = tqRed(c); - g = tqGreen(c); - b = tqBlue(c); - - v = lut[0][0][r] + lut[1][0][g] + lut[2][0][b]; - if (gamma != 1000) v = (int)rint(pow(v,gam)); - if (v < 0) r2 = 0; - else if (v > 255) r2 = 255; - else r2 = v; - - v = lut[0][1][r] + lut[1][1][g] + lut[2][1][b]; - if (gamma != 1000) v = (int)rint(pow(v,gam)); - if (v < 0) g2 = 0; - else if (v > 255) g2 = 255; - else g2 = v; - - v = lut[0][2][r] + lut[1][2][g] + lut[2][2][b]; - if (gamma != 1000) v = (int)rint(pow(v,gam)); - if (v < 0) b2 = 0; - else if (v > 255) b2 = 255; - else b2 = v; - - img.setPixel(i,j,tqRgb(r2,g2,b2)); - } - return img; -} diff --git a/kdeprint/cups/imageposition.cpp b/kdeprint/cups/imageposition.cpp deleted file mode 100644 index 70a84ba7f..000000000 --- a/kdeprint/cups/imageposition.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "imageposition.h" - -#include <tqpainter.h> -#include <kstandarddirs.h> - -static void draw3DPage(TQPainter *p, TQRect r) -{ - // draw white page - p->fillRect(r,Qt::white); - // draw 3D border - p->setPen(Qt::black); - p->moveTo(r.left(),r.bottom()); - p->lineTo(r.right(),r.bottom()); - p->lineTo(r.right(),r.top()); - p->setPen(Qt::darkGray); - p->lineTo(r.left(),r.top()); - p->lineTo(r.left(),r.bottom()); - p->setPen(Qt::gray); - p->moveTo(r.left()+1,r.bottom()-1); - p->lineTo(r.right()-1,r.bottom()-1); - p->lineTo(r.right()-1,r.top()+1); -} - -ImagePosition::ImagePosition(TQWidget *parent, const char *name) - : TQWidget(parent,name) -{ - position_ = Center; - setMinimumSize(tqsizeHint()); - tqsetSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding)); - pix_.load(locate("data", "tdeprint/preview-mini.png")); -} - -ImagePosition::~ImagePosition() -{ -} - -void ImagePosition::setPosition(const char *type) -{ - int pos(Center); - if (strcmp(type,"top-left") == 0) pos = TopLeft; - else if (strcmp(type,"top") == 0) pos = Top; - else if (strcmp(type,"top-right") == 0) pos = TopRight; - else if (strcmp(type,"left") == 0) pos = Left; - else if (strcmp(type,"center") == 0) pos = Center; - else if (strcmp(type,"right") == 0) pos = Right; - else if (strcmp(type,"bottom-left") == 0) pos = BottomLeft; - else if (strcmp(type,"bottom") == 0) pos = Bottom; - else if (strcmp(type,"bottom-right") == 0) pos = BottomRight; - setPosition((PositionType)pos); -} - -void ImagePosition::setPosition(PositionType type) -{ - if (position_ != type) { - position_ = type; - update(); - } -} - -void ImagePosition::setPosition(int horiz, int vert) -{ - int type = vert*3+horiz; - setPosition((PositionType)type); -} - -TQString ImagePosition::positionString() const -{ - switch (position_) { - case TopLeft: return "top-left"; - case Top: return "top"; - case TopRight: return "top-right"; - case Left: return "left"; - case Center: return "center"; - case Right: return "right"; - case BottomLeft: return "bottom-left"; - case Bottom: return "bottom"; - case BottomRight: return "bottom-right"; - } - return "center"; -} - -void ImagePosition::paintEvent(TQPaintEvent*) -{ - int horiz, vert, x, y; - int margin = 5; - int pw(width()), ph(height()), px(0), py(0); - - if (pw > ((ph * 3) / 4)) - { - pw = (ph * 3) / 4; - px = (width() - pw) / 2; - } - else - { - ph = (pw * 4) / 3; - py = (height() - ph) / 2; - } - TQRect page(px, py, pw, ph), img(0, 0, pix_.width(), pix_.height()); - - // compute img position - horiz = position_%3; - vert = position_/3; - switch (horiz) { - case 0: x = page.left()+margin; break; - default: - case 1: x = (page.left()+page.right()-img.width())/2; break; - case 2: x = page.right()-margin-img.width(); break; - } - switch (vert) { - case 0: y = page.top()+margin; break; - default: - case 1: y = (page.top()+page.bottom()-img.height())/2; break; - case 2: y = page.bottom()-margin-img.height(); break; - } - img.moveTopLeft(TQPoint(x,y)); - - // draw page - TQPainter p(this); - draw3DPage(&p,page); - - // draw img - /*p.setPen(darkRed); - p.drawRect(img); - p.drawLine(img.topLeft(),img.bottomRight()); - p.drawLine(img.topRight(),img.bottomLeft());*/ - p.drawPixmap(x, y, pix_); - - p.end(); -} - -TQSize ImagePosition::tqsizeHint() const -{ - return TQSize(60, 80); -} diff --git a/kdeprint/cups/imageposition.h b/kdeprint/cups/imageposition.h deleted file mode 100644 index 6d6645365..000000000 --- a/kdeprint/cups/imageposition.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 IMAGEPOSITION_H -#define IMAGEPOSITION_H - -#include <tqwidget.h> -#include <tqstring.h> -#include <tqpixmap.h> - -class ImagePosition : public TQWidget -{ -public: - enum PositionType {TopLeft, - Top, - TopRight, - Left, - Center, - Right, - BottomLeft, - Bottom, - BottomRight}; - - ImagePosition(TQWidget *parent = 0, const char *name = 0); - ~ImagePosition(); - - void setPosition(const char *type = "center"); - void setPosition(PositionType type = Center); - void setPosition(int horiz = 1, int vert = 1); - PositionType position() const { return (PositionType)position_; } - TQString positionString() const; - TQSize tqsizeHint() const; - -protected: - void paintEvent(TQPaintEvent *); - -private: - int position_; - QPixmap pix_; -}; - -#endif diff --git a/kdeprint/cups/imagepreview.cpp b/kdeprint/cups/imagepreview.cpp deleted file mode 100644 index 2290f6a96..000000000 --- a/kdeprint/cups/imagepreview.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "imagepreview.h" - -#include <tqpainter.h> -#include <tqpixmap.h> -#include <tqpaintdevice.h> - -// forward definition -TQImage convertImage(const TQImage& image, int hue, int saturation, int brightness, int gamma); - -ImagePreview::ImagePreview(TQWidget *parent, const char *name ) : TQWidget(parent,name) { - brightness_ = 100; - hue_ = 0; - saturation_ = 100; - gamma_ = 1000; - bw_ = false; - - setBackgroundMode(NoBackground); -} - -ImagePreview::~ImagePreview(){ -} - -void ImagePreview::setImage(const TQImage& image){ - image_ = image.convertDepth(32); - image_.detach(); - resize(image_.size()); - update(); -} - -void ImagePreview::setParameters(int brightness, int hue, int saturation, int gamma){ - brightness_ = brightness; - hue_ = hue; - saturation_ = saturation; - gamma_ = gamma; - tqrepaint(); -} - -void ImagePreview::paintEvent(TQPaintEvent*){ - QImage tmpImage = convertImage(image_,hue_,(bw_ ? 0 : saturation_),brightness_,gamma_); - int x = (width()-tmpImage.width())/2, y = (height()-tmpImage.height())/2; - - QPixmap buffer(width(), height()); - buffer.fill(parentWidget(), 0, 0); - QPainter p(&buffer); - p.drawImage(x,y,tmpImage); - p.end(); - - bitBlt(this, TQPoint(0, 0), &buffer, buffer.rect(), TQt::CopyROP); -} - -void ImagePreview::setBlackAndWhite(bool on){ - bw_ = on; - update(); -} - -TQSize ImagePreview::tqminimumSizeHint() const -{ - return image_.size(); -} diff --git a/kdeprint/cups/imagepreview.h b/kdeprint/cups/imagepreview.h deleted file mode 100644 index 12a57ddb3..000000000 --- a/kdeprint/cups/imagepreview.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 IMAGEPREVIEW_H -#define IMAGEPREVIEW_H - -#include <tqwidget.h> -#include <tqimage.h> - -class ImagePreview : public TQWidget -{ -public: - ImagePreview(TQWidget *parent=0, const char *name=0); - ~ImagePreview(); - - void setParameters(int brightness, int hue, int saturation, int gamma); - void setImage(const TQImage& image); - void setBlackAndWhite(bool on); - TQSize tqminimumSizeHint() const; - -private: // Private attributes - int brightness_; - int hue_; - int saturation_; - int gamma_; - bool bw_; - TQImage image_; - -protected: // Protected methods - void paintEvent(TQPaintEvent*); -}; - -#endif diff --git a/kdeprint/cups/ippreportdlg.cpp b/kdeprint/cups/ippreportdlg.cpp deleted file mode 100644 index 5fa54e11e..000000000 --- a/kdeprint/cups/ippreportdlg.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "ippreportdlg.h" -#include "ipprequest.h" -#include "kprinter.h" - -#include <klocale.h> -#include <kguiitem.h> -#include <kmessagebox.h> -#include <kdebug.h> -#include <ktextedit.h> -#include <tqsimplerichtext.h> -#include <tqpainter.h> -#include <tqpaintdevicemetrics.h> - -IppReportDlg::IppReportDlg(TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, i18n("IPP Report"), Close|User1, Close, false, KGuiItem(i18n("&Print"), "fileprint")) -{ - m_edit = new KTextEdit(this); - m_edit->setReadOnly(true); - setMainWidget(m_edit); - resize(540, 500); - setFocusProxy(m_edit); - setButtonGuiItem(User1, KGuiItem(i18n("&Print"),"fileprint")); -} - -void IppReportDlg::slotUser1() -{ - KPrinter printer; - printer.setFullPage(true); - printer.setDocName(caption()); - if (printer.setup(this)) - { - TQPainter painter(&printer); - TQPaintDeviceMetrics metrics(&printer); - - // report is printed using TQSimpleRichText - TQSimpleRichText rich(m_edit->text(), font()); - rich.setWidth(&painter, metrics.width()); - int margin = (int)(1.5 / 2.54 * metrics.logicalDpiY()); // 1.5 cm - TQRect r(margin, margin, metrics.width()-2*margin, metrics.height()-2*margin); - int hh = rich.height(), page(1); - while (1) - { - rich.draw(&painter, margin, margin, r, tqcolorGroup()); - TQString s = caption() + ": " + TQString::number(page); - TQRect br = painter.fontMetrics().boundingRect(s); - painter.drawText(r.right()-br.width()-5, r.top()-br.height()-4, br.width()+5, br.height()+4, Qt::AlignRight|Qt::AlignTop, s); - r.moveBy(0, r.height()-10); - painter.translate(0, -(r.height()-10)); - if (r.top() < hh) - { - printer.newPage(); - page++; - } - else - break; - } - } -} - -void IppReportDlg::report(IppRequest *req, int group, const TQString& caption) -{ - TQString str_report; - TQTextStream t(&str_report, IO_WriteOnly); - - if (req->htmlReport(group, t)) - { - IppReportDlg dlg; - if (!caption.isEmpty()) - dlg.setCaption(caption); - dlg.m_edit->setText(str_report); - dlg.exec(); - } - else - KMessageBox::error(0, i18n("Internal error: unable to generate HTML report.")); -} - -#include "ippreportdlg.moc" diff --git a/kdeprint/cups/ippreportdlg.h b/kdeprint/cups/ippreportdlg.h deleted file mode 100644 index e61ccd7b7..000000000 --- a/kdeprint/cups/ippreportdlg.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 IPPREPORTDLG_H -#define IPPREPORTDLG_H - -#include <kdialogbase.h> - -class IppRequest; -class KTextEdit; - -class IppReportDlg : public KDialogBase -{ - Q_OBJECT -public: - IppReportDlg(TQWidget *parent = 0, const char *name = 0); - static void report(IppRequest *req, int group, const TQString& caption = TQString::null); - -protected slots: - void slotUser1(); - -private: - KTextEdit *m_edit; -}; - -#endif diff --git a/kdeprint/cups/ipprequest.cpp b/kdeprint/cups/ipprequest.cpp deleted file mode 100644 index 16cbe3308..000000000 --- a/kdeprint/cups/ipprequest.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "ipprequest.h" -#include "cupsinfos.h" - -#include <stdlib.h> -#include <cups/language.h> -#include <kdebug.h> -#include <kglobal.h> -#include <klocale.h> -#include <tqdatetime.h> -#include <tqregexp.h> -#include <cups/cups.h> - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef HAVE_CUPS_NO_PWD_CACHE -#include <tqcstring.h> -static TQCString cups_authstring = ""; -#endif - -void dumpRequest(ipp_t *req, bool answer = false, const TQString& s = TQString::null) -{ - kdDebug(500) << "==========" << endl; - if (s.isEmpty()) - kdDebug(500) << (answer ? "Answer" : "Request") << endl; - else - kdDebug(500) << s << endl; - kdDebug(500) << "==========" << endl; - if (!req) - { - kdDebug(500) << "Null request" << endl; - return; - } - kdDebug(500) << "State = 0x" << TQString::number(req->state, 16) << endl; - kdDebug(500) << "ID = 0x" << TQString::number(req->request.status.request_id, 16) << endl; - if (answer) - { - kdDebug(500) << "Status = 0x" << TQString::number(req->request.status.status_code, 16) << endl; - kdDebug(500) << "Status message = " << ippErrorString(req->request.status.status_code) << endl; - } - else - kdDebug(500) << "Operation = 0x" << TQString::number(req->request.op.operation_id, 16) << endl; - kdDebug(500) << "Version = " << (int)(req->request.status.version[0]) << "." << (int)(req->request.status.version[1]) << endl; - kdDebug(500) << endl; - - ipp_attribute_t *attr = req->attrs; - while (attr) - { - TQString s = TQString::tqfromLatin1("%1 (0x%2) = ").arg(attr->name).arg(attr->value_tag, 0, 16); - for (int i=0;i<attr->num_values;i++) - { - switch (attr->value_tag) - { - case IPP_TAG_INTEGER: - case IPP_TAG_ENUM: - s += ("0x"+TQString::number(attr->values[i].integer, 16)); - break; - case IPP_TAG_BOOLEAN: - s += (attr->values[i].boolean ? "true" : "false"); - break; - case IPP_TAG_STRING: - case IPP_TAG_TEXT: - case IPP_TAG_NAME: - case IPP_TAG_KEYWORD: - case IPP_TAG_URI: - case IPP_TAG_MIMETYPE: - case IPP_TAG_NAMELANG: - case IPP_TAG_TEXTLANG: - case IPP_TAG_CHARSET: - case IPP_TAG_LANGUAGE: - s += attr->values[i].string.text; - break; - default: - break; - } - if (i != (attr->num_values-1)) - s += ", "; - } - kdDebug(500) << s << endl; - attr = attr->next; - } -} - -TQString errorString(int status) -{ - TQString str; - switch (status) - { - case IPP_FORBIDDEN: - str = i18n("You don't have access to the requested resource."); - break; - case IPP_NOT_AUTHORIZED: - str = i18n("You are not authorized to access the requested resource."); - break; - case IPP_NOT_POSSIBLE: - str = i18n("The requested operation cannot be completed."); - break; - case IPP_SERVICE_UNAVAILABLE: - str = i18n("The requested service is currently unavailable."); - break; - case IPP_NOT_ACCEPTING: - str = i18n("The target printer is not accepting print jobs."); - break; - default: - str = TQString::fromLocal8Bit(ippErrorString((ipp_status_t)status)); - break; - } - return str; -} - -//************************************************************************************* - -IppRequest::IppRequest() -{ - request_ = 0; - port_ = -1; - host_ = TQString(); - dump_ = 0; - init(); -} - -IppRequest::~IppRequest() -{ - ippDelete(request_); -} - -void IppRequest::init() -{ - connect_ = true; - - if (request_) - { - ippDelete(request_); - request_ = 0; - } - request_ = ippNew(); - //kdDebug(500) << "tdeprint: IPP request, lang=" << KGlobal::locale()->language() << endl; - TQCString langstr = KGlobal::locale()->language().latin1(); - cups_lang_t* lang = cupsLangGet(langstr.data()); - // default charset to UTF-8 (ugly hack) - lang->encoding = CUPS_UTF8; - ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang)); - ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language); - cupsLangFree(lang); -} - -void IppRequest::addString_p(int group, int type, const TQString& name, const TQString& value) -{ - if (!name.isEmpty()) - ippAddString(request_,(ipp_tag_t)group,(ipp_tag_t)type,name.latin1(),NULL,(value.isEmpty() ? "" : value.local8Bit().data())); -} - -void IppRequest::addStringList_p(int group, int type, const TQString& name, const TQStringList& values) -{ - if (!name.isEmpty()) - { - ipp_attribute_t *attr = ippAddStrings(request_,(ipp_tag_t)group,(ipp_tag_t)type,name.latin1(),(int)(values.count()),NULL,NULL); - int i(0); - for (TQStringList::ConstIterator it=values.begin(); it != values.end(); ++it, i++) - attr->values[i].string.text = strdup((*it).local8Bit()); - } -} - -void IppRequest::addInteger_p(int group, int type, const TQString& name, int value) -{ - if (!name.isEmpty()) ippAddInteger(request_,(ipp_tag_t)group,(ipp_tag_t)type,name.latin1(),value); -} - -void IppRequest::addIntegerList_p(int group, int type, const TQString& name, const TQValueList<int>& values) -{ - if (!name.isEmpty()) - { - ipp_attribute_t *attr = ippAddIntegers(request_,(ipp_tag_t)group,(ipp_tag_t)type,name.latin1(),(int)(values.count()),NULL); - int i(0); - for (TQValueList<int>::ConstIterator it=values.begin(); it != values.end(); ++it, i++) - attr->values[i].integer = *it; - } -} - -void IppRequest::addBoolean(int group, const TQString& name, bool value) -{ - if (!name.isEmpty()) ippAddBoolean(request_,(ipp_tag_t)group,name.latin1(),(char)value); -} - -void IppRequest::addBoolean(int group, const TQString& name, const TQValueList<bool>& values) -{ - if (!name.isEmpty()) - { - ipp_attribute_t *attr = ippAddBooleans(request_,(ipp_tag_t)group,name.latin1(),(int)(values.count()),NULL); - int i(0); - for (TQValueList<bool>::ConstIterator it=values.begin(); it != values.end(); ++it, i++) - attr->values[i].boolean = (char)(*it); - } -} - -void IppRequest::setOperation(int op) -{ - request_->request.op.operation_id = (ipp_op_t)op; - request_->request.op.request_id = 1; // 0 is not RFC-compliant, should be at least 1 -} - -int IppRequest::status() -{ - return (request_ ? request_->request.status.status_code : (connect_ ? cupsLastError() : -2)); -} - -TQString IppRequest::statusMessage() -{ - TQString msg; - switch (status()) - { - case -2: - msg = i18n("Connection to CUPS server failed. Check that the CUPS server is correctly installed and running."); - break; - case -1: - msg = i18n("The IPP request failed for an unknown reason."); - break; - default: - msg = errorString(status()); - break; - } - return msg; -} - -bool IppRequest::integerValue_p(const TQString& name, int& value, int type) -{ - if (!request_ || name.isEmpty()) return false; - ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), (ipp_tag_t)type); - if (attr) - { - value = attr->values[0].integer; - return true; - } - else return false; -} - -bool IppRequest::stringValue_p(const TQString& name, TQString& value, int type) -{ - if (!request_ || name.isEmpty()) return false; - ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), (ipp_tag_t)type); - if (attr) - { - value = TQString::fromLocal8Bit(attr->values[0].string.text); - return true; - } - else return false; -} - -bool IppRequest::stringListValue_p(const TQString& name, TQStringList& values, int type) -{ - if (!request_ || name.isEmpty()) return false; - ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), (ipp_tag_t)type); - values.clear(); - if (attr) - { - for (int i=0;i<attr->num_values;i++) - values.append(TQString::fromLocal8Bit(attr->values[i].string.text)); - return true; - } - else return false; -} - -bool IppRequest::boolean(const TQString& name, bool& value) -{ - if (!request_ || name.isEmpty()) return false; - ipp_attribute_t *attr = ippFindAttribute(request_, name.latin1(), IPP_TAG_BOOLEAN); - if (attr) - { - value = (bool)attr->values[0].boolean; - return true; - } - else return false; -} - -bool IppRequest::doFileRequest(const TQString& res, const TQString& filename) -{ - TQString myHost = host_; - int myPort = port_; - if (myHost.isEmpty()) myHost = CupsInfos::self()->host(); - if (myPort <= 0) myPort = CupsInfos::self()->port(); - http_t *HTTP = httpConnect(myHost.latin1(),myPort); - - connect_ = (HTTP != NULL); - - if (HTTP == NULL) - { - ippDelete(request_); - request_ = 0; - return false; - } - -#ifdef HAVE_CUPS_NO_PWD_CACHE -#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR <= 2 - strncpy( HTTP->authstring, cups_authstring.data(), HTTP_MAX_VALUE ); -#else - httpSetAuthString( HTTP, NULL, cups_authstring.data() ); -#endif -#endif - - if (dump_ > 0) - { - dumpRequest(request_, false, "Request to "+myHost+":"+TQString::number(myPort)); - } - - request_ = cupsDoFileRequest(HTTP, request_, (res.isEmpty() ? "/" : res.latin1()), (filename.isEmpty() ? NULL : filename.latin1())); -#ifdef HAVE_CUPS_NO_PWD_CACHE -#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR <= 2 - cups_authstring = HTTP->authstring; -#else - cups_authstring = httpGetAuthString( HTTP ); -#endif -#endif - httpClose(HTTP); - - if (dump_ > 1) - { - dumpRequest(request_, true); - } - - /* No printers found */ - if ( request_ && request_->request.status.status_code == 0x406 ) - return true; - - if (!request_ || request_->state == IPP_ERROR || (request_->request.status.status_code & 0x0F00)) - return false; - - - return true; -} - -bool IppRequest::htmlReport(int group, TQTextStream& output) -{ - if (!request_) return false; - // start table - output << "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">" << endl; - output << "<tr><th bgcolor=\"dark blue\"><font color=\"white\">" << i18n("Attribute") << "</font></th>" << endl; - output << "<th bgcolor=\"dark blue\"><font color=\"white\">" << i18n("Values") << "</font></th></tr>" << endl; - // go to the first attribute of the specified group - ipp_attribute_t *attr = request_->attrs; - while (attr && attr->group_tag != group) - attr = attr->next; - // print each attribute - ipp_uchar_t *d; - TQCString dateStr; - TQDateTime dt; - bool bg(false); - while (attr && attr->group_tag == group) - { - output << " <tr bgcolor=\"" << (bg ? "#ffffd9" : "#ffffff") << "\">\n <td><b>" << attr->name << "</b></td>\n <td>" << endl; - bg = !bg; - for (int i=0; i<attr->num_values; i++) - { - switch (attr->value_tag) - { - case IPP_TAG_INTEGER: - if (attr->name && strstr(attr->name, "time")) - { - dt.setTime_t((unsigned int)(attr->values[i].integer)); - output << dt.toString(); - } - else - output << attr->values[i].integer; - break; - case IPP_TAG_ENUM: - output << "0x" << hex << attr->values[i].integer << dec; - break; - case IPP_TAG_BOOLEAN: - output << (attr->values[i].boolean ? i18n("True") : i18n("False")); - break; - case IPP_TAG_STRING: - case IPP_TAG_TEXTLANG: - case IPP_TAG_NAMELANG: - case IPP_TAG_TEXT: - case IPP_TAG_NAME: - case IPP_TAG_KEYWORD: - case IPP_TAG_URI: - case IPP_TAG_CHARSET: - case IPP_TAG_LANGUAGE: - case IPP_TAG_MIMETYPE: - output << attr->values[i].string.text; - break; - case IPP_TAG_RESOLUTION: - output << "( " << attr->values[i].resolution.xres - << ", " << attr->values[i].resolution.yres << " )"; - break; - case IPP_TAG_RANGE: - output << "[ " << (attr->values[i].range.lower > 0 ? attr->values[i].range.lower : 1) - << ", " << (attr->values[i].range.upper > 0 ? attr->values[i].range.upper : 65535) << " ]"; - break; - case IPP_TAG_DATE: - d = attr->values[i].date; - dateStr.sprintf("%.4d-%.2d-%.2d, %.2d:%.2d:%.2d %c%.2d%.2d", - d[0]*256+d[1], d[2], d[3], - d[4], d[5], d[6], - d[8], d[9], d[10]); - output << dateStr; - break; - default: - continue; - } - if (i < attr->num_values-1) - output << "<br>"; - } - output << "</td>\n </tr>" << endl; - attr = attr->next; - } - // end table - output << "</table>" << endl; - - return true; -} - -TQMap<TQString,TQString> IppRequest::toMap(int group) -{ - TQMap<TQString,TQString> opts; - if (request_) - { - ipp_attribute_t *attr = first(); - while (attr) - { - if (group != -1 && attr->group_tag != group) - { - attr = attr->next; - continue; - } - TQString value; - for (int i=0; i<attr->num_values; i++) - { - switch (attr->value_tag) - { - case IPP_TAG_INTEGER: - case IPP_TAG_ENUM: - value.append(TQString::number(attr->values[i].integer)).append(","); - break; - case IPP_TAG_BOOLEAN: - value.append((attr->values[i].boolean ? "true" : "false")).append(","); - break; - case IPP_TAG_RANGE: - if (attr->values[i].range.lower > 0) - value.append(TQString::number(attr->values[i].range.lower)); - if (attr->values[i].range.lower != attr->values[i].range.upper) - { - value.append("-"); - if (attr->values[i].range.upper > 0) - value.append(TQString::number(attr->values[i].range.upper)); - } - value.append(","); - break; - case IPP_TAG_STRING: - case IPP_TAG_TEXT: - case IPP_TAG_NAME: - case IPP_TAG_KEYWORD: - case IPP_TAG_URI: - case IPP_TAG_MIMETYPE: - case IPP_TAG_NAMELANG: - case IPP_TAG_TEXTLANG: - case IPP_TAG_CHARSET: - case IPP_TAG_LANGUAGE: - value.append(TQString::fromLocal8Bit(attr->values[i].string.text)).append(","); - break; - default: - break; - } - } - if (!value.isEmpty()) - value.truncate(value.length()-1); - opts[TQString::fromLocal8Bit(attr->name)] = value; - attr = attr->next; - } - } - return opts; -} - -void IppRequest::setMap(const TQMap<TQString,TQString>& opts) -{ - if (!request_) - return; - - TQRegExp re("^\"|\"$"); - cups_option_t *options = NULL; - int n = 0; - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("app-")) - continue; - TQString value = it.data().stripWhiteSpace(), lovalue; - value.replace(re, ""); - lovalue = value.lower(); - - // handles specific cases: boolean, empty strings, or option that has that boolean - // keyword as value (to prevent them from conversion to real boolean) - if (value == "true" || value == "false") - addBoolean(IPP_TAG_JOB, it.key(), (value == "true")); - else if (value.isEmpty() || lovalue == "off" || lovalue == "on" - || lovalue == "yes" || lovalue == "no" - || lovalue == "true" || lovalue == "false") - addName(IPP_TAG_JOB, it.key(), value); - else - n = cupsAddOption(it.key().local8Bit(), value.local8Bit(), n, &options); - } - if (n > 0) - cupsEncodeOptions(request_, n, options); - cupsFreeOptions(n, options); - - // find an remove that annoying "document-format" attribute -#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 - ipp_attribute_t *attr = ippFindAttribute(request_, "document-format", IPP_TAG_NAME); - ippDeleteAttribute(request_, attr); -#else - // (can't use IppDeleteAttribute as older cups doesn't have that) - ipp_attribute_t *attr = request_->attrs; - while (attr) - { - if (attr->next && strcmp(attr->next->name, "document-format") == 0) - { - ipp_attribute_t *attr2 = attr->next; - attr->next = attr2->next; - _ipp_free_attr(attr2); - break; - } - attr = attr->next; - } -#endif -} diff --git a/kdeprint/cups/ipprequest.h b/kdeprint/cups/ipprequest.h deleted file mode 100644 index ba8b2f081..000000000 --- a/kdeprint/cups/ipprequest.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 IPPREQUEST_H -#define IPPREQUEST_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqtextstream.h> -#include <tqmap.h> - -#include <cups/ipp.h> - -class IppRequest -{ -public: - IppRequest(); - ~IppRequest(); - - void init(); // re-initializes the request - - // request building functions - void addMime(int group, const TQString& name, const TQString& mime); - void addKeyword(int group, const TQString& name, const TQString& key); - void addKeyword(int group, const TQString& name, const TQStringList& keys); - void addURI(int group, const TQString& name, const TQString& uri); - void addURI(int group, const TQString& name, const TQStringList& uris); - void addText(int group, const TQString& name, const TQString& txt); - void addText(int group, const TQString& name, const TQStringList& txts); - void addName(int group, const TQString& name, const TQString& nm); - void addName(int group, const TQString& name, const TQStringList& nms); - void addInteger(int group, const TQString& name, int value); - void addInteger(int group, const TQString& name, const TQValueList<int>& values); - void addEnum(int group, const TQString& name, int value); - void addEnum(int group, const TQString& name, const TQValueList<int>& values); - void addBoolean(int group, const TQString& name, bool value); - void addBoolean(int group, const TQString& name, const TQValueList<bool>& values); - - void setOperation(int op); - void setHost(const TQString& host); - void setPort(int p); - - // request answer functions - int status(); - TQString statusMessage(); - bool integer(const TQString& name, int& value); - bool boolean(const TQString& name, bool& value); - bool enumvalue(const TQString& name, int& value); - bool name(const TQString& name, TQString& value); - bool name(const TQString& name, TQStringList& value); - bool text(const TQString& name, TQString& value); - bool text(const TQString& name, TQStringList& value); - bool uri(const TQString& name, TQString& value); - bool uri(const TQString& name, TQStringList& value); - bool keyword(const TQString& name, TQString& value); - bool keyword(const TQString& name, TQStringList& value); - bool mime(const TQString& name, TQString& value); - ipp_attribute_t* first(); - ipp_attribute_t* last(); - TQMap<TQString,TQString> toMap(int group = -1); - void setMap(const TQMap<TQString,TQString>& opts); - - // processing functions - bool doRequest(const TQString& res); - bool doFileRequest(const TQString& res, const TQString& filename = TQString::null); - - // report functions - bool htmlReport(int group, TQTextStream& output); - - // debug function - void dump(int state); - -protected: - void addString_p(int group, int type, const TQString& name, const TQString& value); - void addStringList_p(int group, int type, const TQString& name, const TQStringList& values); - void addInteger_p(int group, int type, const TQString& name, int value); - void addIntegerList_p(int group, int type, const TQString& name, const TQValueList<int>& values); - bool stringValue_p(const TQString& name, TQString& value, int type); - bool stringListValue_p(const TQString& name, TQStringList& values, int type); - bool integerValue_p(const TQString& name, int& value, int type); - -private: - ipp_t *request_; - QString host_; - int port_; - bool connect_; - int dump_; -}; - -inline void IppRequest::addMime(int group, const TQString& name, const TQString& mime) -{ addString_p(group, IPP_TAG_MIMETYPE, name, mime); } - -inline void IppRequest::addKeyword(int group, const TQString& name, const TQString& key) -{ addString_p(group, IPP_TAG_KEYWORD, name, key); } - -inline void IppRequest::addKeyword(int group, const TQString& name, const TQStringList& keys) -{ addStringList_p(group, IPP_TAG_KEYWORD, name, keys); } - -inline void IppRequest::addURI(int group, const TQString& name, const TQString& uri) -{ addString_p(group, IPP_TAG_URI, name, uri); } - -inline void IppRequest::addURI(int group, const TQString& name, const TQStringList& uris) -{ addStringList_p(group, IPP_TAG_URI, name, uris); } - -inline void IppRequest::addText(int group, const TQString& name, const TQString& txt) -{ addString_p(group, IPP_TAG_TEXT, name, txt); } - -inline void IppRequest::addText(int group, const TQString& name, const TQStringList& txts) -{ addStringList_p(group, IPP_TAG_TEXT, name, txts); } - -inline void IppRequest::addName(int group, const TQString& name, const TQString& nm) -{ addString_p(group, IPP_TAG_NAME, name, nm); } - -inline void IppRequest::addName(int group, const TQString& name, const TQStringList& nms) -{ addStringList_p(group, IPP_TAG_NAME, name, nms); } - -inline void IppRequest::addInteger(int group, const TQString& name, int value) -{ addInteger_p(group, IPP_TAG_INTEGER, name, value); } - -inline void IppRequest::addInteger(int group, const TQString& name, const TQValueList<int>& values) -{ addIntegerList_p(group, IPP_TAG_INTEGER, name, values); } - -inline void IppRequest::addEnum(int group, const TQString& name, int value) -{ addInteger_p(group, IPP_TAG_ENUM, name, value); } - -inline void IppRequest::addEnum(int group, const TQString& name, const TQValueList<int>& values) -{ addIntegerList_p(group, IPP_TAG_ENUM, name, values); } - -inline bool IppRequest::integer(const TQString& name, int& value) -{ return integerValue_p(name, value, IPP_TAG_INTEGER); } - -inline bool IppRequest::enumvalue(const TQString& name, int& value) -{ return integerValue_p(name, value, IPP_TAG_ENUM); } - -inline bool IppRequest::name(const TQString& name, TQString& value) -{ return stringValue_p(name, value, IPP_TAG_NAME); } - -inline bool IppRequest::name(const TQString& name, TQStringList& values) -{ return stringListValue_p(name, values, IPP_TAG_NAME); } - -inline bool IppRequest::text(const TQString& name, TQString& value) -{ return stringValue_p(name, value, IPP_TAG_TEXT); } - -inline bool IppRequest::text(const TQString& name, TQStringList& values) -{ return stringListValue_p(name, values, IPP_TAG_TEXT); } - -inline bool IppRequest::uri(const TQString& name, TQString& value) -{ return stringValue_p(name, value, IPP_TAG_URI); } - -inline bool IppRequest::uri(const TQString& name, TQStringList& values) -{ return stringListValue_p(name, values, IPP_TAG_URI); } - -inline bool IppRequest::keyword(const TQString& name, TQString& value) -{ return stringValue_p(name, value, IPP_TAG_KEYWORD); } - -inline bool IppRequest::keyword(const TQString& name, TQStringList& values) -{ return stringListValue_p(name, values, IPP_TAG_KEYWORD); } - -inline bool IppRequest::mime(const TQString& name, TQString& value) -{ return stringValue_p(name, value, IPP_TAG_MIMETYPE); } - -inline bool IppRequest::doRequest(const TQString& res) -{ return doFileRequest(res); } - -inline ipp_attribute_t* IppRequest::first() -{ return (request_ ? request_->attrs : NULL); } - -inline ipp_attribute_t* IppRequest::last() -{ return (request_ ? request_->last : NULL); } - -inline void IppRequest::setHost(const TQString& host) -{ host_ = host; } - -inline void IppRequest::setPort(int p) -{ port_ = p; } - -inline void IppRequest::dump(int state) -{ dump_ = state; } - -#endif diff --git a/kdeprint/cups/kcupsprinterimpl.cpp b/kdeprint/cups/kcupsprinterimpl.cpp deleted file mode 100644 index e016e9954..000000000 --- a/kdeprint/cups/kcupsprinterimpl.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kcupsprinterimpl.h" -#include "kprinter.h" -#include "driver.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "cupsinfos.h" - -#include <tqfile.h> -#include <cups/cups.h> -#include <stdlib.h> -#include <kprocess.h> - -static void mapToCupsOptions(const TQMap<TQString,TQString>& opts, TQString& cmd); - -TQSize rangeToSize(const TQString& s) -{ - TQString range = s; - int p(-1); - int from, to; - - if ((p=range.find(',')) != -1) - range.truncate(p); - if ((p=range.find('-')) != -1) - { - from = range.left(p).toInt(); - to = range.right(range.length()-p-1).toInt(); - } - else if (!range.isEmpty()) - from = to = range.toInt(); - else - from = to = 0; - - return TQSize(from,to); -} -//****************************************************************************************************** - -KCupsPrinterImpl::KCupsPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ -} - -KCupsPrinterImpl::~KCupsPrinterImpl() -{ -} - -bool KCupsPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - // check printer object - if (!printer) return false; - - TQString hoststr = TQString::tqfromLatin1("%1:%2").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()); - cmd = TQString::tqfromLatin1("cupsdoprint -P %1 -J %3 -H %2").arg(quote(printer->printerName())).arg(quote(hoststr)).arg(quote(printer->docName())); - if (!CupsInfos::self()->login().isEmpty()) - { - TQString userstr(CupsInfos::self()->login()); - //if (!CupsInfos::self()->password().isEmpty()) - // userstr += (":" + CupsInfos::self()->password()); - cmd.append(" -U ").append(quote(userstr)); - } - mapToCupsOptions(printer->options(),cmd); - return true; -} - -void KCupsPrinterImpl::preparePrinting(KPrinter *printer) -{ - // process orientation - TQString o = printer->option("orientation-requested"); - printer->setOption("kde-orientation",(o == "4" || o == "5" ? "Landscape" : "Portrait")); - // if it's a TQt application, then convert orientation as it will be handled by TQt directly - if (printer->applicationType() == KPrinter::Dialog) - printer->setOption("orientation-requested",(o == "5" || o == "6" ? "6" : "3")); - - // translate copies number - if (!printer->option("kde-copies").isEmpty()) printer->setOption("copies",printer->option("kde-copies")); - - // page ranges are handled by CUPS, so application should print all pages - if (printer->pageSelection() == KPrinter::SystemSide) - { // TQt => CUPS - // translations - if (!printer->option("kde-range").isEmpty()) - printer->setOption("page-ranges",printer->option("kde-range")); - if (printer->option("kde-pageorder") == "Reverse") - printer->setOption("OutputOrder",printer->option("kde-pageorder")); - o = printer->option("kde-pageset"); - if (!o.isEmpty() && o != "0") - printer->setOption("page-set",(o == "1" ? "odd" : "even")); - printer->setOption("multiple-document-handling",(printer->option("kde-collate") == "Collate" ? "separate-documents-collated-copies" : "separate-documents-uncollated-copies")); - } - else - { // No translation needed (but range => (from,to)) - TQString range = printer->option("kde-range"); - if (!range.isEmpty()) - { - TQSize s = rangeToSize(range); - printer->setOption("kde-from",TQString::number(s.width())); - printer->setOption("kde-to",TQString::number(s.height())); - } - } - - // needed for page size and margins - KPrinterImpl::preparePrinting(printer); -} - -void KCupsPrinterImpl::broadcastOption(const TQString& key, const TQString& value) -{ - KPrinterImpl::broadcastOption(key,value); - if (key == "kde-orientation") - KPrinterImpl::broadcastOption("orientation-requested",(value == "Landscape" ? "4" : "3")); - else if (key == "kde-pagesize") - { - TQString pagename = TQString::tqfromLatin1(pageSizeToPageName((KPrinter::PageSize)value.toInt())); - KPrinterImpl::broadcastOption("PageSize",pagename); - // simple hack for classes - KPrinterImpl::broadcastOption("media",pagename); - } -} - -//****************************************************************************************************** - -static void mapToCupsOptions(const TQMap<TQString,TQString>& opts, TQString& cmd) -{ - TQString optstr; - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - // only encode those options that doesn't start with "kde-" or "app-". - if (!it.key().startsWith("kde-") && !it.key().startsWith("app-") && !it.key().startsWith("_kde")) - { - TQString key = it.key(); - if (key.startsWith("KDEPrint-")) - /* Those are keys added by the "Additional Tags" page. * - * Strip the prefix to build valid a CUPS option. */ - key = key.mid(9); - optstr.append(" ").append(key); - if (!it.data().isEmpty()) - optstr.append("=").append(it.data()); - } - } - if (!optstr.isEmpty()) - cmd.append(" -o ").append( KProcess::quote( optstr ) ); -} diff --git a/kdeprint/cups/kcupsprinterimpl.h b/kdeprint/cups/kcupsprinterimpl.h deleted file mode 100644 index b86db8aac..000000000 --- a/kdeprint/cups/kcupsprinterimpl.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KCUPSPRINTERIMPL_H -#define KCUPSPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KCupsPrinterImpl : public KPrinterImpl -{ -public: - KCupsPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/ = TQStringList()); - ~KCupsPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); - void preparePrinting(KPrinter*); - void broadcastOption(const TQString& key, const TQString& value); -}; - -#endif diff --git a/kdeprint/cups/kmconfigcups.cpp b/kdeprint/cups/kmconfigcups.cpp deleted file mode 100644 index 7e03dae01..000000000 --- a/kdeprint/cups/kmconfigcups.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigcups.h" -#include "kmcupsconfigwidget.h" - -#include <klocale.h> -#include <kconfig.h> -#include <kdialog.h> - -#include <tqlayout.h> - -KMConfigCups::KMConfigCups(TQWidget *parent) -: KMConfigPage(parent,"ConfigCups") -{ - setPageName(i18n("CUPS Server")); - setPageHeader(i18n("CUPS Server Settings")); - setPagePixmap("gear"); - - m_widget = new KMCupsConfigWidget(this); - - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - lay0->addWidget(m_widget); - lay0->addStretch(1); -} - -void KMConfigCups::loadConfig(KConfig *) -{ - m_widget->load(); -} - -void KMConfigCups::saveConfig(KConfig *conf) -{ - m_widget->saveConfig(conf); -} diff --git a/kdeprint/cups/kmconfigcups.h b/kdeprint/cups/kmconfigcups.h deleted file mode 100644 index c0f1ab2ba..000000000 --- a/kdeprint/cups/kmconfigcups.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGCUPS_H -#define KMCONFIGCUPS_H - -#include "kmconfigpage.h" - -class KMCupsConfigWidget; - -class KMConfigCups : public KMConfigPage -{ -public: - KMConfigCups(TQWidget *parent = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - KMCupsConfigWidget *m_widget; -}; - -#endif diff --git a/kdeprint/cups/kmconfigcupsdir.cpp b/kdeprint/cups/kmconfigcupsdir.cpp deleted file mode 100644 index fbec34f2a..000000000 --- a/kdeprint/cups/kmconfigcupsdir.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigcupsdir.h" - -#include <tqcheckbox.h> -#include <kurlrequester.h> -#include <klocale.h> -#include <kdialog.h> -#include <kconfig.h> -#include <tqgroupbox.h> -#include <tqlayout.h> -#include <kcursor.h> - -KMConfigCupsDir::KMConfigCupsDir(TQWidget *parent) -: KMConfigPage(parent,"ConfigCupsDir") -{ - setPageName(i18n("Folder")); - setPageHeader(i18n("CUPS Folder Settings")); - setPagePixmap("folder"); - - TQGroupBox *m_dirbox = new TQGroupBox(0, Qt::Vertical, i18n("Installation Folder"), this); - m_installdir = new KURLRequester(m_dirbox); - m_installdir->setMode((KFile::Mode)(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly)); - m_stddir = new TQCheckBox(i18n("Standard installation (/)"), m_dirbox); - m_stddir->setCursor(KCursor::handCursor()); - - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - lay0->addWidget(m_dirbox); - lay0->addStretch(1); - TQVBoxLayout *lay1 = new TQVBoxLayout(TQT_TQLAYOUT(m_dirbox->layout()), 10); - lay1->addWidget(m_stddir); - lay1->addWidget(m_installdir); - - connect(m_stddir,TQT_SIGNAL(toggled(bool)),m_installdir,TQT_SLOT(setDisabled(bool))); - m_stddir->setChecked(true); -} - -void KMConfigCupsDir::loadConfig(KConfig *conf) -{ - conf->setGroup("CUPS"); - QString dir = conf->readPathEntry("InstallDir"); - m_stddir->setChecked(dir.isEmpty()); - m_installdir->setURL(dir); -} - -void KMConfigCupsDir::saveConfig(KConfig *conf) -{ - conf->setGroup("CUPS"); - conf->writePathEntry("InstallDir",(m_stddir->isChecked() ? TQString::null : m_installdir->url())); -} diff --git a/kdeprint/cups/kmconfigcupsdir.h b/kdeprint/cups/kmconfigcupsdir.h deleted file mode 100644 index 352388c99..000000000 --- a/kdeprint/cups/kmconfigcupsdir.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGCUPSDIR_H -#define KMCONFIGCUPSDIR_H - -#include "kmconfigpage.h" - -class KURLRequester; -class TQCheckBox; - -class KMConfigCupsDir : public KMConfigPage -{ -public: - KMConfigCupsDir(TQWidget *parent = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - KURLRequester *m_installdir; - TQCheckBox *m_stddir; -}; - -#endif diff --git a/kdeprint/cups/kmcupsconfigwidget.cpp b/kdeprint/cups/kmcupsconfigwidget.cpp deleted file mode 100644 index 482680bd6..000000000 --- a/kdeprint/cups/kmcupsconfigwidget.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmcupsconfigwidget.h" -#include "cupsinfos.h" - -#include <tqlabel.h> -#include <tqgroupbox.h> -#include <tqlineedit.h> -#include <tqcheckbox.h> -#include <tqlayout.h> -#include <tqpushbutton.h> -#include <tqvalidator.h> - -#include <klocale.h> -#include <kcursor.h> -#include <kconfig.h> -#include <kstringhandler.h> - -class PortValidator : public TQIntValidator -{ -public: - PortValidator(TQWidget *parent, const char *name = 0); - virtual TQValidator::State validate(TQString&, int&) const; -}; - -PortValidator::PortValidator(TQWidget *parent, const char *name) -: TQIntValidator(1, 65535, TQT_TQOBJECT(parent), name) -{ -} - -TQValidator::State PortValidator::validate(TQString& txt, int&) const -{ - bool ok(false); - int p = txt.toInt(&ok); - if (txt.isEmpty()) - return TQValidator::Intermediate; - else if (ok && p >= bottom() && p <= top()) - return TQValidator::Acceptable; - return TQValidator::Invalid; -} - -//****************************************************************************************** - -KMCupsConfigWidget::KMCupsConfigWidget(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - // widget creation - TQGroupBox *m_hostbox = new TQGroupBox(0, Qt::Vertical, i18n("Server Information"), this); - TQGroupBox *m_loginbox = new TQGroupBox(0, Qt::Vertical, i18n("Account Information"), this); - TQLabel *m_hostlabel = new TQLabel(i18n("&Host:"), m_hostbox); - TQLabel *m_portlabel = new TQLabel(i18n("&Port:"), m_hostbox); - m_host = new TQLineEdit(m_hostbox); - m_port = new TQLineEdit(m_hostbox); - m_hostlabel->setBuddy(m_host); - m_portlabel->setBuddy(m_port); - m_port->setValidator(new PortValidator(m_port)); - m_login = new TQLineEdit(m_loginbox); - TQLabel *m_loginlabel = new TQLabel(i18n("&User:"), m_loginbox); - TQLabel *m_passwordlabel = new TQLabel(i18n("Pass&word:"), m_loginbox); - m_password = new TQLineEdit(m_loginbox); - m_password->setEchoMode(TQLineEdit::Password); - m_savepwd = new TQCheckBox( i18n( "&Store password in configuration file" ), m_loginbox ); - m_savepwd->setCursor( KCursor::handCursor() ); - m_anonymous = new TQCheckBox(i18n("Use &anonymous access"), m_loginbox); - m_anonymous->setCursor(KCursor::handCursor()); - m_loginlabel->setBuddy(m_login); - m_passwordlabel->setBuddy(m_password); - - // layout creation - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, 10); - lay0->addWidget(m_hostbox,1); - lay0->addWidget(m_loginbox,1); - TQGridLayout *lay2 = new TQGridLayout(m_hostbox->tqlayout(), 2, 2, 10); - lay2->setColStretch(1,1); - lay2->addWidget(m_hostlabel,0,0); - lay2->addWidget(m_portlabel,1,0); - lay2->addWidget(m_host,0,1); - lay2->addWidget(m_port,1,1); - TQGridLayout *lay3 = new TQGridLayout(m_loginbox->tqlayout(), 4, 2, 10); - lay3->setColStretch(1,1); - lay3->addWidget(m_loginlabel,0,0); - lay3->addWidget(m_passwordlabel,1,0); - lay3->addWidget(m_login,0,1); - lay3->addWidget(m_password,1,1); - lay3->addMultiCellWidget(m_savepwd,2,2,0,1); - lay3->addMultiCellWidget(m_anonymous,3,3,0,1); - - // connections - connect(m_anonymous,TQT_SIGNAL(toggled(bool)),m_login,TQT_SLOT(setDisabled(bool))); - connect(m_anonymous,TQT_SIGNAL(toggled(bool)),m_password,TQT_SLOT(setDisabled(bool))); - connect(m_anonymous,TQT_SIGNAL(toggled(bool)),m_savepwd,TQT_SLOT(setDisabled(bool))); -} - -void KMCupsConfigWidget::load() -{ - CupsInfos *inf = CupsInfos::self(); - m_host->setText(inf->host()); - m_port->setText(TQString::number(inf->port())); - if (inf->login().isEmpty()) - m_anonymous->setChecked(true); - else - { - m_login->setText(inf->login()); - m_password->setText(inf->password()); - m_savepwd->setChecked( inf->savePassword() ); - } -} - -void KMCupsConfigWidget::save(bool sync) -{ - CupsInfos *inf = CupsInfos::self(); - inf->setHost(m_host->text()); - inf->setPort(m_port->text().toInt()); - if (m_anonymous->isChecked()) - { - inf->setLogin(TQString::null); - inf->setPassword(TQString::null); - inf->setSavePassword( false ); - } - else - { - inf->setLogin(m_login->text()); - inf->setPassword(m_password->text()); - inf->setSavePassword( m_savepwd->isChecked() ); - } - if (sync) inf->save(); -} - -void KMCupsConfigWidget::saveConfig(KConfig *conf) -{ - conf->setGroup("CUPS"); - conf->writeEntry("Host",m_host->text()); - conf->writeEntry("Port",m_port->text().toInt()); - conf->writeEntry("Login",(m_anonymous->isChecked() ? TQString::null : m_login->text())); - conf->writeEntry( "SavePassword", ( m_anonymous->isChecked() ? false : m_savepwd->isChecked() ) ); - if ( m_savepwd->isChecked() && !m_anonymous->isChecked() ) - conf->writeEntry( "Password", ( m_anonymous->isChecked() ? TQString::null : KStringHandler::obscure( m_password->text() ) ) ); - else - conf->deleteEntry( "Password" ); - // synchronize CupsInfos object - save(false); -} diff --git a/kdeprint/cups/kmcupsconfigwidget.h b/kdeprint/cups/kmcupsconfigwidget.h deleted file mode 100644 index 7eee42d80..000000000 --- a/kdeprint/cups/kmcupsconfigwidget.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCUPSCONFIGWIDGET_H -#define KMCUPSCONFIGWIDGET_H - -#include <tqwidget.h> - -class TQLineEdit; -class TQCheckBox; -class KConfig; - -class KMCupsConfigWidget : public TQWidget -{ -public: - KMCupsConfigWidget(TQWidget *parent = 0, const char *name = 0); - - void load(); - void save(bool sync = true); - void saveConfig(KConfig*); - -protected: - TQLineEdit *m_host, *m_port, *m_login, *m_password; - TQCheckBox *m_anonymous, *m_savepwd; -}; - -#endif diff --git a/kdeprint/cups/kmcupsfactory.cpp b/kdeprint/cups/kmcupsfactory.cpp deleted file mode 100644 index 47384eab6..000000000 --- a/kdeprint/cups/kmcupsfactory.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmcupsmanager.h" -#include "kmcupsjobmanager.h" -#include "kmcupsuimanager.h" -#include "kcupsprinterimpl.h" - -#include <kglobal.h> -#include <kgenericfactory.h> - -typedef K_TYPELIST_4( KMCupsManager, KMCupsJobManager, KMCupsUiManager, KCupsPrinterImpl ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_cups, KGenericFactory< Products >( "ppdtranslations" ) ) - diff --git a/kdeprint/cups/kmcupsjobmanager.cpp b/kdeprint/cups/kmcupsjobmanager.cpp deleted file mode 100644 index 58de0818a..000000000 --- a/kdeprint/cups/kmcupsjobmanager.cpp +++ /dev/null @@ -1,452 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmcupsjobmanager.h" -#include "kmcupsmanager.h" -#include "kmjob.h" -#include "cupsinfos.h" -#include "ipprequest.h" -#include "pluginaction.h" -#include "kprinter.h" -#include "kprinterpropertydialog.h" -#include "kmuimanager.h" -#include "kmfactory.h" -#include "kpdriverpage.h" -#include "kpschedulepage.h" -#include "kpcopiespage.h" -#include "kptagspage.h" - -#include <klocale.h> -#include <kdebug.h> -#include <kurl.h> - -KMCupsJobManager::KMCupsJobManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMJobManager(parent,name) -{ -} - -KMCupsJobManager::~KMCupsJobManager() -{ -} - -int KMCupsJobManager::actions() -{ - return KMJob::All; -} - -bool KMCupsJobManager::sendCommandSystemJob(const TQPtrList<KMJob>& jobs, int action, const TQString& argstr) -{ - IppRequest req; - TQString uri; - bool value(true); - - TQPtrListIterator<KMJob> it(jobs); - for (;it.current() && value;++it) - { - // hypothesis: job operation are always done on local jobs. The only operation - // allowed on remote jobs is listing (done elsewhere). - - req.addURI(IPP_TAG_OPERATION,"job-uri",it.current()->uri()); - req.addName(IPP_TAG_OPERATION,"requesting-user-name",CupsInfos::self()->login()); - /* - TQString jobHost; - if (!it.current()->uri().isEmpty()) - { - KURL url(it.current()->uri()); - req.setHost(url.host()); - req.setPort(url.port()); - jobHost = url.host(); - } - */ - - switch (action) - { - case KMJob::Remove: - req.setOperation(IPP_CANCEL_JOB); - break; - case KMJob::Hold: - req.setOperation(IPP_HOLD_JOB); - break; - case KMJob::Resume: - req.setOperation(IPP_RELEASE_JOB); - break; - case KMJob::Restart: - req.setOperation(IPP_RESTART_JOB); - break; - case KMJob::Move: - if (argstr.isEmpty()) return false; - req.setOperation(CUPS_MOVE_JOB); - uri = - TQString::tqfromLatin1("ipp://%1/printers/%2").arg(CupsInfos::self()->hostaddr(), - argstr); - req.addURI(IPP_TAG_OPERATION, "job-printer-uri", uri); - break; - default: - return false; - } - - if (!(value = req.doRequest("/jobs/"))) - KMManager::self()->setErrorMsg(req.statusMessage()); - } - - return value; -} - -bool KMCupsJobManager::listJobs(const TQString& prname, KMJobManager::JobType type, int limit) -{ - IppRequest req; - TQStringList keys; - CupsInfos *infos = CupsInfos::self(); - - // wanted attributes - keys.append("job-id"); - keys.append("job-uri"); - keys.append("job-name"); - keys.append("job-state"); - keys.append("job-printer-uri"); - keys.append("job-k-octets"); - keys.append("job-originating-user-name"); - keys.append("job-k-octets-completed"); - keys.append("job-media-sheets"); - keys.append("job-media-sheets-completed"); - keys.append("job-priority"); - keys.append("job-billing"); - - req.setOperation(IPP_GET_JOBS); - - // add printer-uri - KMPrinter *mp = KMManager::self()->findPrinter(prname); - if (!mp) - return false; - - if (!mp->uri().isEmpty()) - { - req.addURI(IPP_TAG_OPERATION, "printer-uri", mp->uri().prettyURL()); - /* - req.setHost(mp->uri().host()); - req.setPort(mp->uri().port()); - */ - } - else - req.addURI(IPP_TAG_OPERATION, "printer-uri", TQString("ipp://%1/%2/%3").arg(infos->hostaddr(), - (mp&&mp->isClass())?"classes":"printers", prname)); - - // other attributes - req.addKeyword(IPP_TAG_OPERATION, "requested-attributes", keys); - if (type == KMJobManager::CompletedJobs) - req.addKeyword(IPP_TAG_OPERATION,"which-jobs",TQString::tqfromLatin1("completed")); - if (limit > 0) - req.addInteger(IPP_TAG_OPERATION,"limit",limit); - - // send request - if (req.doRequest("/")) - parseListAnswer(req, mp); - else - return false; - - return true; -} - -void KMCupsJobManager::parseListAnswer(IppRequest& req, KMPrinter *pr) -{ - ipp_attribute_t *attr = req.first(); - KMJob *job = new KMJob(); - TQString uri; - while (attr) - { - TQString name(attr->name); - if (name == "job-id") job->setId(attr->values[0].integer); - else if (name == "job-uri") job->setUri(TQString::fromLocal8Bit(attr->values[0].string.text)); - else if (name == "job-name") job->setName(TQString::fromLocal8Bit(attr->values[0].string.text)); - else if (name == "job-state") - { - switch (attr->values[0].integer) - { - case IPP_JOB_PENDING: - job->setState(KMJob::Queued); - break; - case IPP_JOB_HELD: - job->setState(KMJob::Held); - break; - case IPP_JOB_PROCESSING: - job->setState(KMJob::Printing); - break; - case IPP_JOB_STOPPED: - job->setState(KMJob::Error); - break; - case IPP_JOB_CANCELLED: - job->setState(KMJob::Cancelled); - break; - case IPP_JOB_ABORTED: - job->setState(KMJob::Aborted); - break; - case IPP_JOB_COMPLETED: - job->setState(KMJob::Completed); - break; - default: - job->setState(KMJob::Unknown); - break; - } - } - else if (name == "job-k-octets") job->setSize(attr->values[0].integer); - else if (name == "job-originating-user-name") job->setOwner(TQString::fromLocal8Bit(attr->values[0].string.text)); - else if (name == "job-k-octets-completed") job->setProcessedSize(attr->values[0].integer); - else if (name == "job-media-sheets") job->setPages(attr->values[0].integer); - else if (name == "job-media-sheets-completed") job->setProcessedPages(attr->values[0].integer); - else if (name == "job-printer-uri" && !pr->isRemote()) - { - TQString str(attr->values[0].string.text); - int p = str.findRev('/'); - if (p != -1) - job->setPrinter(str.mid(p+1)); - } - else if (name == "job-priority") - { - job->setAttribute(0, TQString::tqfromLatin1("%1").arg(attr->values[0].integer, 3)); - } - else if (name == "job-billing") - { - job->setAttributeCount(2); - job->setAttribute(1, TQString::fromLocal8Bit(attr->values[0].string.text)); - } - - if (name.isEmpty() || attr == req.last()) - { - if (job->printer().isEmpty()) - job->setPrinter(pr->printerName()); - job->setRemote(pr->isRemote()); - addJob(job); // don't use job after this call !!! - job = new KMJob(); - } - - attr = attr->next; - } - delete job; -} - -bool KMCupsJobManager::doPluginAction(int ID, const TQPtrList<KMJob>& jobs) -{ - switch (ID) - { - case 0: - if (jobs.count() == 1) - return jobIppReport(jobs.getFirst()); - break; - case 1: - return changePriority(jobs, true); - case 2: - return changePriority(jobs, false); - case 3: - return editJobAttributes(jobs.getFirst()); - } - return false; -} - -bool KMCupsJobManager::jobIppReport(KMJob *j) -{ - IppRequest req; - - req.setOperation(IPP_GET_JOB_ATTRIBUTES); - req.addURI(IPP_TAG_OPERATION, "job-uri", j->uri()); - bool result(true); - /* - if (!j->uri().isEmpty()) - { - KURL url(j->uri()); - req.setHost(url.host()); - req.setPort(url.port()); - } - */ - if ((result=req.doRequest("/"))) - static_cast<KMCupsManager*>(KMManager::self())->ippReport(req, IPP_TAG_JOB, i18n("Job Report")); - else - KMManager::self()->setErrorMsg(i18n("Unable to retrieve job information: ")+req.statusMessage()); - return result; -} - -TQValueList<KAction*> KMCupsJobManager::createPluginActions(KActionCollection *coll) -{ - TQValueList<KAction*> list; - KAction *act(0); - - list << (act = new PluginAction(0, i18n("&Job IPP Report"), "tdeprint_report", 0, coll, "plugin_ipp")); - act->setGroup("plugin"); - list << (act = new PluginAction(1, i18n("&Increase Priority"), "up", 0, coll, "plugin_prioup")); - act->setGroup("plugin"); - list << (act = new PluginAction(2, i18n("&Decrease Priority"), "down", 0, coll, "plugin_priodown")); - act->setGroup("plugin"); - list << (act = new PluginAction(3, i18n("&Edit Attributes..."), "edit", 0, coll, "plugin_editjob")); - act->setGroup("plugin"); - - return list; -} - -void KMCupsJobManager::validatePluginActions(KActionCollection *coll, const TQPtrList<KMJob>& joblist) -{ - TQPtrListIterator<KMJob> it(joblist); - bool flag(true); - for (; it.current(); ++it) - { - flag = (flag && it.current()->type() == KMJob::System - && (it.current()->state() == KMJob::Queued || it.current()->state() == KMJob::Held) - /*&& !it.current()->isRemote()*/); - } - flag = (flag && joblist.count() > 0); - KAction *a; - if ( ( a = coll->action( "plugin_ipp" ) ) ) - a->setEnabled( joblist.count() == 1 ); - if ( ( a = coll->action( "plugin_prioup" ) ) ) - a->setEnabled( flag ); - if ( ( a = coll->action( "plugin_priodown" ) ) ) - a->setEnabled( flag ); - if ( ( a = coll->action( "plugin_editjob" ) ) ) - a->setEnabled( flag && ( joblist.count() == 1 ) ); -} - -bool KMCupsJobManager::changePriority(const TQPtrList<KMJob>& jobs, bool up) -{ - TQPtrListIterator<KMJob> it(jobs); - bool result(true); - for (; it.current() && result; ++it) - { - int value = it.current()->attribute(0).toInt(); - if (up) value = TQMIN(value+10, 100); - else value = TQMAX(value-10, 1); - - IppRequest req; - /* - if (!it.current()->uri().isEmpty()) - { - KURL url(it.current()->uri()); - req.setHost(url.host()); - req.setPort(url.port()); - } - */ - req.setOperation(IPP_SET_JOB_ATTRIBUTES); - req.addURI(IPP_TAG_OPERATION, "job-uri", it.current()->uri()); - req.addName(IPP_TAG_OPERATION, "requesting-user-name", CupsInfos::self()->login()); - req.addInteger(IPP_TAG_JOB, "job-priority", value); - - if (!(result = req.doRequest("/jobs/"))) - KMManager::self()->setErrorMsg(i18n("Unable to change job priority: ")+req.statusMessage()); - } - return result; -} - -static TQString processRange(const TQString& range) -{ - TQStringList l = TQStringList::split(',', range, false); - TQString s; - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - s.append(*it); - if ((*it).find('-') == -1) - s.append("-").append(*it); - s.append(","); - } - if (!s.isEmpty()) - s.truncate(s.length()-1); - return s; -} - -bool KMCupsJobManager::editJobAttributes(KMJob *j) -{ - IppRequest req; - - req.setOperation(IPP_GET_JOB_ATTRIBUTES); - req.addURI(IPP_TAG_OPERATION, "job-uri", j->uri()); - /* - if (!j->uri().isEmpty()) - { - KURL url(j->uri()); - req.setHost(url.host()); - req.setPort(url.port()); - } - */ - if (!req.doRequest("/")) - { - KMManager::self()->setErrorMsg(i18n("Unable to retrieve job information: ")+req.statusMessage()); - return false; - } - - TQMap<TQString,TQString> opts = req.toMap(IPP_TAG_JOB); - // translate the "Copies" option to non-CUPS syntax - if (opts.contains("copies")) - opts["kde-copies"] = opts["copies"]; - if (opts.contains("page-set")) - opts["kde-pageset"] = (opts["page-set"] == "even" ? "2" : (opts["page-set"] == "odd" ? "1" : "0")); - if (opts.contains("OutputOrder")) - opts["kde-pageorder"] = opts["OutputOrder"]; - if (opts.contains("multiple-document-handling")) - opts["kde-collate"] = (opts["multiple-document-handling"] == "separate-documents-collated-copies" ? "Collate" : "Uncollate"); - if (opts.contains("page-ranges")) - opts["kde-range"] = opts["page-ranges"]; - - // find printer and construct dialog - KMPrinter *prt = KMManager::self()->findPrinter(j->printer()); - if (!prt) - { - KMManager::self()->setErrorMsg(i18n("Unable to find printer %1.").arg(j->printer())); - return false; - } - KMManager::self()->completePrinterShort(prt); - KPrinter::ApplicationType oldAppType = KPrinter::applicationType(); - KPrinter::setApplicationType(KPrinter::StandAlone); - KPrinterPropertyDialog dlg(prt); - dlg.setDriver(KMManager::self()->loadPrinterDriver(prt)); - KMFactory::self()->uiManager()->setupPrinterPropertyDialog(&dlg); - KPrinter::setApplicationType( oldAppType ); - if (dlg.driver()) - dlg.addPage(new KPDriverPage(prt, dlg.driver(), &dlg)); - dlg.addPage(new KPCopiesPage(0, &dlg)); - dlg.addPage(new KPSchedulePage(&dlg)); - dlg.addPage(new KPTagsPage(true, &dlg)); - dlg.setOptions(opts); - dlg.enableSaveButton(false); - dlg.setCaption(i18n("Attributes of Job %1@%2 (%3)").arg(j->id()).arg(j->printer()).arg(j->name())); - if (dlg.exec()) - { - opts.clear(); - // include default values to override non-default values - dlg.getOptions(opts, true); - // translate the "Copies" options from non-CUPS syntax - opts["copies"] = opts["kde-copies"]; - opts["OutputOrder"] = opts["kde-pageorder"]; - opts["multiple-document-handling"] = (opts["kde-collate"] == "Collate" ? "separate-documents-collated-copies" : "separate-documents-uncollated-copies"); - opts["page-set"] = (opts["kde-pageset"] == "1" ? "odd" : (opts["kde-pageset"] == "2" ? "even" : "all")); - // it seems CUPS is buggy. Disable page-ranges modification, otherwise nothing gets printed - opts["page-ranges"] = processRange(opts["kde-range"]); - - req.init(); - req.setOperation(IPP_SET_JOB_ATTRIBUTES); - req.addURI(IPP_TAG_OPERATION, "job-uri", j->uri()); - req.addName(IPP_TAG_OPERATION, "requesting-user-name", CupsInfos::self()->login()); - req.setMap(opts); - //req.dump(1); - if (!req.doRequest("/jobs/")) - { - KMManager::self()->setErrorMsg(i18n("Unable to set job attributes: ")+req.statusMessage()); - return false; - } - } - - return true; -} - -#include "kmcupsjobmanager.moc" diff --git a/kdeprint/cups/kmcupsjobmanager.h b/kdeprint/cups/kmcupsjobmanager.h deleted file mode 100644 index 7e8a75a53..000000000 --- a/kdeprint/cups/kmcupsjobmanager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCUPSJOBMANAGER_H -#define KMCUPSJOBMANAGER_H - -#include "kmjobmanager.h" -#include "ipprequest.h" -#include <tqstringlist.h> - -class KMPrinter; - -class KMCupsJobManager : public KMJobManager -{ - Q_OBJECT - -public: - KMCupsJobManager(TQObject *parent, const char *name, const TQStringList &/*args*/); - virtual ~KMCupsJobManager(); - - int actions(); - TQValueList<KAction*> createPluginActions(KActionCollection*); - void validatePluginActions(KActionCollection*, const TQPtrList<KMJob>&); - bool doPluginAction(int, const TQPtrList<KMJob>&); - -protected: - bool jobIppReport(KMJob*); - bool changePriority(const TQPtrList<KMJob>&, bool); - bool editJobAttributes(KMJob*); - -protected: - bool listJobs(const TQString&, JobType, int = 0); - bool sendCommandSystemJob(const TQPtrList<KMJob>& jobs, int action, const TQString& arg = TQString::null); - void parseListAnswer(IppRequest& req, KMPrinter *pr); -}; - -#endif diff --git a/kdeprint/cups/kmcupsmanager.cpp b/kdeprint/cups/kmcupsmanager.cpp deleted file mode 100644 index 8db6bdc6d..000000000 --- a/kdeprint/cups/kmcupsmanager.cpp +++ /dev/null @@ -1,1077 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmcupsmanager.h" -#include "kmprinter.h" -#include "ipprequest.h" -#include "cupsinfos.h" -#include "driver.h" -#include "kmfactory.h" -#include "kmdbentry.h" -#include "cupsaddsmb2.h" -#include "ippreportdlg.h" -#include "kpipeprocess.h" -#include "util.h" -#include "foomatic2loader.h" -#include "ppdloader.h" - -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqregexp.h> -#include <tqtimer.h> -#include <tqsocket.h> -#include <tqdatetime.h> - -#include <kdebug.h> -#include <kapplication.h> -#include <klocale.h> -#include <kconfig.h> -#include <kstandarddirs.h> -#include <ksocketbase.h> -#include <klibloader.h> -#include <kmessagebox.h> -#include <kaction.h> -#include <kdialogbase.h> -#include <kextendedsocket.h> -#include <kprocess.h> -#include <kbufferedsocket.h> -#include <kfilterdev.h> -#include <cups/cups.h> -#include <cups/ppd.h> -#include <math.h> - -#define ppdi18n(s) i18n(TQString::fromLocal8Bit(s).utf8()) - -static void extractMaticData(TQString& buf, const TQString& filename); -static TQString printerURI(KMPrinter *p, bool useExistingURI); -static TQString downloadDriver(KMPrinter *p); - -static int trials = 5; - -//***************************************************************************************************** - - KMCupsManager::KMCupsManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - // be sure to create the CupsInfos object -> password - // management is handled correctly. - CupsInfos::self(); - m_cupsdconf = 0; - m_currentprinter = 0; - m_socket = 0; - - setHasManagement(true); - setPrinterOperationMask(KMManager::PrinterAll); - setServerOperationMask(KMManager::ServerAll); - - // change LANG variable so that CUPS is always using - // english language: translation may only come from the PPD - // itself, or from KDE. - setenv("LANG", "en_US.UTF-8", 1); -} - -KMCupsManager::~KMCupsManager() -{ - delete m_socket; -} - -TQString KMCupsManager::driverDbCreationProgram() -{ - return TQString::tqfromLatin1("/opt/trinity/bin/make_driver_db_cups"); -} - -TQString KMCupsManager::driverDirectory() -{ - TQString d = cupsInstallDir(); - if (d.isEmpty()) - d = "/usr"; - d.append("/share/cups/model"); - // raw foomatic support - d.append(":/usr/share/foomatic/db/source"); - return d; -} - -TQString KMCupsManager::cupsInstallDir() -{ - KConfig *conf= KMFactory::self()->printConfig(); - conf->setGroup("CUPS"); - TQString dir = conf->readPathEntry("InstallDir"); - return dir; -} - -void KMCupsManager::reportIppError(IppRequest *req) -{ - setErrorMsg(req->statusMessage()); -} - -bool KMCupsManager::createPrinter(KMPrinter *p) -{ - bool isclass = p->isClass(false), result(false); - IppRequest req; - TQString uri; - - uri = printerURI(p,false); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - // needed to avoid problems when changing printer name - p->setUri(KURL(uri)); - - if (isclass) - { - req.setOperation(CUPS_ADD_CLASS); - TQStringList members = p->members(), uris; - TQString s; - s = TQString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); - for (TQStringList::ConstIterator it=members.begin(); it!=members.end(); ++it) - uris.append(s+(*it)); - req.addURI(IPP_TAG_PRINTER,"member-uris",uris); - } - else - { - req.setOperation(CUPS_ADD_PRINTER); - // only set the device-uri if needed, otherwise you may loose authentification - // data (login/password in URI's like smb or ipp). - KMPrinter *otherP = findPrinter(p->printerName()); - if (!otherP || otherP->device() != p->device()) - { - /** - * As now the device is a TQString instead of KURL, special encoding - * required for SMB is not needed anymore. Use a unique mechanism - * for all backends. - */ - req.addURI(IPP_TAG_PRINTER,"device-uri",p->device()); - } - if (!p->option("kde-banners").isEmpty()) - { - TQStringList bans = TQStringList::split(',',p->option("kde-banners"),false); - while (bans.count() < 2) - bans.append("none"); - req.addName(IPP_TAG_PRINTER,"job-sheets-default",bans); - } - req.addInteger(IPP_TAG_PRINTER,"job-quota-period",p->option("job-quota-period").toInt()); - req.addInteger(IPP_TAG_PRINTER,"job-k-limit",p->option("job-k-limit").toInt()); - req.addInteger(IPP_TAG_PRINTER,"job-page-limit",p->option("job-page-limit").toInt()); - if (!p->option("requesting-user-name-denied").isEmpty()) - req.addName(IPP_TAG_PRINTER,"requesting-user-name-denied",TQStringList::split(",",p->option("requesting-user-name-denied"),false)); - else if (!p->option("requesting-user-name-allowed").isEmpty()) - req.addName(IPP_TAG_PRINTER,"requesting-user-name-allowed",TQStringList::split(",",p->option("requesting-user-name-allowed"),false)); - else - req.addName(IPP_TAG_PRINTER,"requesting-user-name-allowed",TQString::tqfromLatin1("all")); - } - req.addText(IPP_TAG_PRINTER,"printer-info",p->description()); - req.addText(IPP_TAG_PRINTER,"printer-location",p->location()); - - if (req.doRequest("/admin/")) - { - result = true; - if (p->driver()) - result = savePrinterDriver(p,p->driver()); - if (result) - upPrinter(p, true); - } - else reportIppError(&req); - - return result; -} - -bool KMCupsManager::removePrinter(KMPrinter *p) -{ - bool result = setPrinterState(p,CUPS_DELETE_PRINTER); - return result; -} - -bool KMCupsManager::enablePrinter(KMPrinter *p, bool state) -{ - return setPrinterState(p, (state ? CUPS_ACCEPT_JOBS : CUPS_REJECT_JOBS)); -} - -bool KMCupsManager::startPrinter(KMPrinter *p, bool state) -{ - return setPrinterState(p, (state ? IPP_RESUME_PRINTER : IPP_PAUSE_PRINTER)); -} - -bool KMCupsManager::setDefaultPrinter(KMPrinter *p) -{ - return setPrinterState(p,CUPS_SET_DEFAULT); -} - -bool KMCupsManager::setPrinterState(KMPrinter *p, int state) -{ - IppRequest req; - TQString uri; - - req.setOperation(state); - uri = printerURI(p, true); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - if (req.doRequest("/admin/")) - return true; - reportIppError(&req); - return false; -} - -bool KMCupsManager::completePrinter(KMPrinter *p) -{ - if (completePrinterShort(p)) - { - // driver informations - TQString ppdname = downloadDriver(p); - ppd_file_t *ppd = (ppdname.isEmpty() ? NULL : ppdOpenFile(ppdname.local8Bit())); - if (ppd) - { - KMDBEntry entry; - // use the validation mechanism of KMDBEntry to - // fill possible missing entries like manufacturer - // or model. - entry.manufacturer = ppd->manufacturer; - entry.model = ppd->shortnickname; - entry.modelname = ppd->modelname; - // do not check the driver regarding the manager - entry.validate(false); - // update the KMPrinter object - p->setManufacturer(entry.manufacturer); - p->setModel(entry.model); - p->setDriverInfo(TQString::fromLocal8Bit(ppd->nickname)); - ppdClose(ppd); - } - if (!ppdname.isEmpty()) - TQFile::remove(ppdname); - - return true; - } - return false; -} - -bool KMCupsManager::completePrinterShort(KMPrinter *p) -{ - IppRequest req; - TQStringList keys; - TQString uri; - - req.setOperation(IPP_GET_PRINTER_ATTRIBUTES); - uri = printerURI(p, true); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - - /* - // change host and port for remote stuffs - if (!p->uri().isEmpty()) - { - // THIS IS AN UGLY HACK!! FIXME - // This attempts a "pre-connection" to see if the host is - // actually reachable. It times out after 2 seconds at most, - // preventing application freezes. - m_hostSuccess = false; - m_lookupDone = false; - // Give 2 seconds to connect to the printer, or abort - KExtendedSocket *kes = new KExtendedSocket(p->uri().host(), - p->uri().port()); - connect(kes, TQT_SIGNAL(connectionSuccess()), this, TQT_SLOT(hostPingSlot())); - connect(kes, TQT_SIGNAL(connectionFailed(int)), this, TQT_SLOT(hostPingFailedSlot())); - if (kes->startAsyncConnect() != 0) { - delete kes; - m_hostSuccess = false; - } else { - TQDateTime tm = TQDateTime::tqcurrentDateTime().addSecs(2); - while (!m_lookupDone && (TQDateTime::tqcurrentDateTime() < tm)) - tqApp->processEvents(); - - kes->cancelAsyncConnect(); - - delete kes; - - if (!m_lookupDone) - m_hostSuccess = false; - } - - if (m_hostSuccess == true) { - req.setHost(p->uri().host()); - req.setPort(p->uri().port()); - } - } - */ - - // disable location as it has been transferred to listing (for filtering) - //keys.append("printer-location"); - keys.append("printer-info"); - keys.append("printer-make-and-model"); - keys.append("job-sheets-default"); - keys.append("job-sheets-supported"); - keys.append("job-quota-period"); - keys.append("job-k-limit"); - keys.append("job-page-limit"); - keys.append("requesting-user-name-allowed"); - keys.append("requesting-user-name-denied"); - if (p->isClass(true)) - { - keys.append("member-uris"); - keys.append("member-names"); - } - else - keys.append("device-uri"); - req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",keys); - - if (req.doRequest("/printers/")) - { - TQString value; - if (req.text("printer-info",value)) p->setDescription(value); - // disabled location - //if (req.text("printer-location",value)) p->setLocation(value); - if (req.text("printer-make-and-model",value)) p->setDriverInfo(value); - if (req.uri("device-uri",value)) - { - /** - * No specific treatment required as the device is - * a normal TQString instead of a KURL - */ - p->setDevice( value ); - } - TQStringList values; - /* if (req.uri("member-uris",values)) - { - TQStringList members; - for (TQStringList::ConstIterator it=values.begin(); it!=values.end(); ++it) - { - int p = (*it).findRev('/'); - if (p != -1) - members.append((*it).right((*it).length()-p-1)); - } - p->setMembers(members); - }*/ - if (req.name("member-names",values)) - p->setMembers(values); - // banners - req.name("job-sheets-default",values); - while (values.count() < 2) values.append("none"); - p->setOption("kde-banners",values.join(TQString::tqfromLatin1(","))); - if (req.name("job-sheets-supported",values)) p->setOption("kde-banners-supported",values.join(TQString::tqfromLatin1(","))); - - // quotas - int ival; - if (req.integer("job-quota-period",ival)) p->setOption("job-quota-period",TQString::number(ival)); - if (req.integer("job-k-limit",ival)) p->setOption("job-k-limit",TQString::number(ival)); - if (req.integer("job-page-limit",ival)) p->setOption("job-page-limit",TQString::number(ival)); - - // access permissions (allow and deny are mutually exclusives) - if (req.name("requesting-user-name-allowed",values) && values.count() > 0) - { - p->removeOption("requesting-user-name-denied"); - p->setOption("requesting-user-name-allowed",values.join(",")); - } - if (req.name("requesting-user-name-denied",values) && values.count() > 0) - { - p->removeOption("requesting-user-name-allowed"); - p->setOption("requesting-user-name-denied",values.join(",")); - } - - return true; - } - - reportIppError(&req); - return false; -} - -bool KMCupsManager::testPrinter(KMPrinter *p) -{ - return KMManager::testPrinter(p); - /* - TQString testpage = testPage(); - if (testpage.isEmpty()) - { - setErrorMsg(i18n("Unable to locate test page.")); - return false; - } - - IppRequest req; - TQString uri; - - req.setOperation(IPP_PRINT_JOB); - uri = printerURI(p); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - req.addMime(IPP_TAG_OPERATION,"document-format","application/postscript"); - if (!CupsInfos::self()->login().isEmpty()) req.addName(IPP_TAG_OPERATION,"requesting-user-name",CupsInfos::self()->login()); - req.addName(IPP_TAG_OPERATION,"job-name",TQString::tqfromLatin1("KDE Print Test")); - if (req.doFileRequest("/printers/",testpage)) - return true; - reportIppError(&req); - return false; - */ -} - -void KMCupsManager::listPrinters() -{ - loadServerPrinters(); -} - -void KMCupsManager::loadServerPrinters() -{ - IppRequest req; - TQStringList keys; - - // get printers - req.setOperation(CUPS_GET_PRINTERS); - keys.append("printer-name"); - keys.append("printer-type"); - keys.append("printer-state"); - // location needed for filtering - keys.append("printer-location"); - keys.append("printer-uri-supported"); - keys.append("printer-is-accepting-jobs"); - req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",keys); - - // filtering by username (hides printers user doesn't have allowance to use) - req.addName(IPP_TAG_OPERATION, "requesting-user-name", TQString(cupsUser())); - - if (req.doRequest("/printers/")) - { - processRequest(&req); - - // get classes - req.init(); - req.setOperation(CUPS_GET_CLASSES); - req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",keys); - - if (req.doRequest("/classes/")) - { - processRequest(&req); - - // load default - req.init(); - req.setOperation(CUPS_GET_DEFAULT); - req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",TQString::tqfromLatin1("printer-name")); - if (req.doRequest("/printers/")) - { - TQString s = TQString::null; - req.name("printer-name",s); - setHardDefault(findPrinter(s)); - } - // This request may fails for example if no printer is defined. Just - // discard the error message. Indeed as we successfully got printers - // and classes, the most probable reason why this request may fail is - // because of no printer defined. The best would be to actually check - // there's no printer (TODO). - return; - } - } - - // something went wrong if we get there, report the error - reportIppError(&req); -} - -void KMCupsManager::processRequest(IppRequest* req) -{ - ipp_attribute_t *attr = req->first(); - KMPrinter *printer = new KMPrinter(); - while (attr) - { - TQString attrname(attr->name); - if (attrname == "printer-name") - { - TQString value = TQString::fromLocal8Bit(attr->values[0].string.text); - printer->setName(value); - printer->setPrinterName(value); - } - else if (attrname == "printer-type") - { - int value = attr->values[0].integer; - printer->setType(0); - printer->addType(((value & CUPS_PRINTER_CLASS) || (value & CUPS_PRINTER_IMPLICIT) ? KMPrinter::Class : KMPrinter::Printer)); - if ((value & CUPS_PRINTER_REMOTE)) printer->addType(KMPrinter::Remote); - if ((value & CUPS_PRINTER_IMPLICIT)) printer->addType(KMPrinter::Implicit); - - // convert printer-type attribute - printer->setPrinterCap( ( value & CUPS_PRINTER_OPTIONS ) >> 2 ); - } - else if (attrname == "printer-state") - { - switch (attr->values[0].integer) - { - case IPP_PRINTER_IDLE: printer->setState(KMPrinter::Idle); break; - case IPP_PRINTER_PROCESSING: printer->setState(KMPrinter::Processing); break; - case IPP_PRINTER_STOPPED: printer->setState(KMPrinter::Stopped); break; - } - } - else if (attrname == "printer-uri-supported") - { - printer->setUri(KURL(attr->values[0].string.text)); - } - else if (attrname == "printer-location") - { - printer->setLocation(TQString::fromLocal8Bit(attr->values[0].string.text)); - } - else if (attrname == "printer-is-accepting-jobs") - { - printer->setAcceptJobs(attr->values[0].boolean); - } - if (attrname.isEmpty() || attr == req->last()) - { - addPrinter(printer); - printer = new KMPrinter(); - } - attr = attr->next; - } - delete printer; -} - -DrMain* KMCupsManager::loadPrinterDriver(KMPrinter *p, bool) -{ - if (!p) - return NULL; - - if (p->isClass(true)) - { - KMPrinter *first_class_member = NULL; - /* find the first printer in the class */ - first_class_member = findPrinter(p->members().first()); - - if (first_class_member == NULL) - { - /* we didn't find a printer in the class */ - return NULL; - } - else - { - p = first_class_member; - } - } - - TQString fname = downloadDriver(p); - DrMain *driver(0); - if (!fname.isEmpty()) - { - driver = loadDriverFile(fname); - if (driver) - driver->set("temporary",fname); - } - - return driver; -} - -DrMain* KMCupsManager::loadFileDriver(const TQString& filename) -{ - if (filename.startsWith("ppd:")) - return loadDriverFile(filename.mid(4)); - else if (filename.startsWith("foomatic/")) - return loadMaticDriver(filename); - else - return loadDriverFile(filename); -} - -DrMain* KMCupsManager::loadMaticDriver(const TQString& drname) -{ - TQStringList comps = TQStringList::split('/', drname, false); - TQString tmpFile = locateLocal("tmp", "foomatic_" + kapp->randomString(8)); - TQString PATH = getenv("PATH") + TQString::tqfromLatin1(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - TQString exe = KStandardDirs::findExe("foomatic-datafile", PATH); - if (exe.isEmpty()) - { - setErrorMsg(i18n("Unable to find the executable foomatic-datafile " - "in your PATH. Check that Foomatic is correctly installed.")); - return NULL; - } - - KPipeProcess in; - TQFile out(tmpFile); - TQString cmd = KProcess::quote(exe); - cmd += " -t cups -d "; - cmd += KProcess::quote(comps[2]); - cmd += " -p "; - cmd += KProcess::quote(comps[1]); - if (in.open(cmd) && out.open(IO_WriteOnly)) - { - TQTextStream tin(&in), tout(&out); - TQString line; - while (!tin.atEnd()) - { - line = tin.readLine(); - tout << line << endl; - } - in.close(); - out.close(); - - DrMain *driver = loadDriverFile(tmpFile); - if (driver) - { - driver->set("template", tmpFile); - driver->set("temporary", tmpFile); - return driver; - } - } - setErrorMsg(i18n("Unable to create the Foomatic driver [%1,%2]. " - "Either that driver does not exist, or you don't have " - "the required permissions to perform that operation.").arg(comps[1]).arg(comps[2])); - TQFile::remove(tmpFile); - return NULL; -} - -DrMain* KMCupsManager::loadDriverFile(const TQString& fname) -{ - if (TQFile::exists(fname)) - { - TQString msg; /* possible error message */ - DrMain *driver = PPDLoader::loadDriver( fname, &msg ); - if ( driver ) - { - driver->set( "template", fname ); - // FIXME: should fix option in group "install" - } - else - setErrorMsg( msg ); - return driver; - } - return NULL; -} - -void KMCupsManager::saveDriverFile(DrMain *driver, const TQString& filename) -{ - kdDebug( 500 ) << "Saving PPD file with template=" << driver->get( "template" ) << endl; - TQIODevice *in = KFilterDev::deviceForFile( driver->get( "template" ) ); - TQFile out(filename); - if (in && in->open(IO_ReadOnly) && out.open(IO_WriteOnly)) - { - TQTextStream tin(in), tout(&out); - TQString line, keyword; - bool isnumeric(false); - DrBase *opt(0); - - while (!tin.eof()) - { - line = tin.readLine(); - if (line.startsWith("*% COMDATA #")) - { - int p(-1), q(-1); - if ((p=line.find("'name'")) != -1) - { - p = line.find('\'',p+6)+1; - q = line.find('\'',p); - keyword = line.mid(p,q-p); - opt = driver->findOption(keyword); - if (opt && (opt->type() == DrBase::Integer || opt->type() == DrBase::Float)) - isnumeric = true; - else - isnumeric = false; - } - /*else if ((p=line.find("'type'")) != -1) - { - p = line.find('\'',p+6)+1; - if (line.find("float",p) != -1 || line.find("int",p) != -1) - isnumeric = true; - else - isnumeric = false; - }*/ - else if ((p=line.find("'default'")) != -1 && !keyword.isEmpty() && opt && isnumeric) - { - TQString prefix = line.left(p+9); - tout << prefix << " => '" << opt->valueText() << '\''; - if (line.find(',',p) != -1) - tout << ','; - tout << endl; - continue; - } - tout << line << endl; - } - else if (line.startsWith("*Default")) - { - int p = line.find(':',8); - keyword = line.mid(8,p-8); - DrBase *bopt = 0; - if ( keyword == "PageRegion" || keyword == "ImageableArea" || keyword == "PaperDimension" ) - bopt = driver->findOption( TQString::tqfromLatin1( "PageSize" ) ); - else - bopt = driver->findOption( keyword ); - if (bopt) - switch (bopt->type()) - { - case DrBase::List: - case DrBase::Boolean: - { - DrListOption *opt = static_cast<DrListOption*>(bopt); - if (opt && opt->currentChoice()) - tout << "*Default" << keyword << ": " << opt->currentChoice()->name() << endl; - else - tout << line << endl; - } - break; - case DrBase::Integer: - { - DrIntegerOption *opt = static_cast<DrIntegerOption*>(bopt); - tout << "*Default" << keyword << ": " << opt->fixedVal() << endl; - } - break; - case DrBase::Float: - { - DrFloatOption *opt = static_cast<DrFloatOption*>(bopt); - tout << "*Default" << keyword << ": " << opt->fixedVal() << endl; - } - break; - default: - tout << line << endl; - break; - } - else - tout << line << endl; - } - else - tout << line << endl; - } - } - delete in; -} - -bool KMCupsManager::savePrinterDriver(KMPrinter *p, DrMain *d) -{ - TQString tmpfilename = locateLocal("tmp","print_") + kapp->randomString(8); - - // first save the driver in a temporary file - saveDriverFile(d,tmpfilename); - - // then send a request - IppRequest req; - TQString uri; - bool result(false); - - req.setOperation(CUPS_ADD_PRINTER); - uri = printerURI(p, true); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - result = req.doFileRequest("/admin/",tmpfilename); - - // remove temporary file - TQFile::remove(tmpfilename); - - if (!result) - reportIppError(&req); - return result; -} - -void* KMCupsManager::loadCupsdConfFunction(const char *name) -{ - if (!m_cupsdconf) - { - m_cupsdconf = KLibLoader::self()->library("cupsdconf"); - if (!m_cupsdconf) - { - setErrorMsg(i18n("Library cupsdconf not found. Check your installation.")); - return NULL; - } - } - void* func = m_cupsdconf->symbol(name); - if (!func) - setErrorMsg(i18n("Symbol %1 not found in cupsdconf library.").arg(name)); - return func; -} - -void KMCupsManager::unloadCupsdConf() -{ - if (m_cupsdconf) - { - KLibLoader::self()->unloadLibrary("libcupsdconf"); - m_cupsdconf = 0; - } -} - -bool KMCupsManager::restartServer() -{ - TQString msg; - bool (*f1)(TQString&) = (bool(*)(TQString&))loadCupsdConfFunction("restartServer"); - bool result(false); - if (f1) - { - result = f1(msg); - if (!result) setErrorMsg(msg); - } - unloadCupsdConf(); - return result; -} - -bool KMCupsManager::configureServer(TQWidget *parent) -{ - TQString msg; - bool (*f2)(TQWidget*, TQString&) = (bool(*)(TQWidget*, TQString&))loadCupsdConfFunction("configureServer"); - bool result(false); - if (f2) - { - result = f2(parent, msg); - if ( !result ) - setErrorMsg( msg ); - } - unloadCupsdConf(); - return result; -} - -TQStringList KMCupsManager::detectLocalPrinters() -{ - TQStringList list; - IppRequest req; - req.setOperation(CUPS_GET_DEVICES); - if (req.doRequest("/")) - { - TQString desc, uri, printer, cl; - ipp_attribute_t *attr = req.first(); - while (attr) - { - TQString attrname(attr->name); - if (attrname == "device-info") desc = attr->values[0].string.text; - else if (attrname == "device-make-and-model") printer = attr->values[0].string.text; - else if (attrname == "device-uri") uri = attr->values[0].string.text; - else if ( attrname == "device-class" ) cl = attr->values[ 0 ].string.text; - if (attrname.isEmpty() || attr == req.last()) - { - if (!uri.isEmpty()) - { - if (printer == "Unknown") printer = TQString::null; - list << cl << uri << desc << printer; - } - uri = desc = printer = cl = TQString::null; - } - attr = attr->next; - } - } - return list; -} - -void KMCupsManager::createPluginActions(KActionCollection *coll) -{ - KAction *act = new KAction(i18n("&Export Driver..."), "tdeprint_uploadsmb", 0, this, TQT_SLOT(exportDriver()), coll, "plugin_export_driver"); - act->setGroup("plugin"); - act = new KAction(i18n("&Printer IPP Report"), "tdeprint_report", 0, this, TQT_SLOT(printerIppReport()), coll, "plugin_printer_ipp_report"); - act->setGroup("plugin"); -} - -void KMCupsManager::validatePluginActions(KActionCollection *coll, KMPrinter *pr) -{ - // save selected printer for future use in slots - m_currentprinter = pr; - coll->action("plugin_export_driver")->setEnabled(pr && pr->isLocal() && !pr->isClass(true) && !pr->isSpecial()); - coll->action("plugin_printer_ipp_report")->setEnabled(pr && !pr->isSpecial()); -} - -void KMCupsManager::exportDriver() -{ - if (m_currentprinter && m_currentprinter->isLocal() && - !m_currentprinter->isClass(true) && !m_currentprinter->isSpecial()) - { - TQString path = cupsInstallDir(); - if (path.isEmpty()) - path = "/usr/share/cups"; - else - path += "/share/cups"; - CupsAddSmb::exportDest(m_currentprinter->printerName(), path); - } -} - -void KMCupsManager::printerIppReport() -{ - if (m_currentprinter && !m_currentprinter->isSpecial()) - { - IppRequest req; - TQString uri; - - req.setOperation(IPP_GET_PRINTER_ATTRIBUTES); - uri = printerURI(m_currentprinter, true); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - /* - if (!m_currentprinter->uri().isEmpty()) - { - req.setHost(m_currentprinter->uri().host()); - req.setPort(m_currentprinter->uri().port()); - } - */ - req.dump(2); - if (req.doRequest("/printers/")) - { - ippReport(req, IPP_TAG_PRINTER, i18n("IPP Report for %1").arg(m_currentprinter->printerName())); - } - else - { - KMessageBox::error(0, "<p>"+i18n("Unable to retrieve printer information. Error received:")+"</p>"+req.statusMessage()); - } - } -} - -void KMCupsManager::ippReport(IppRequest& req, int group, const TQString& caption) -{ - IppReportDlg::report(&req, group, caption); -} - -TQString KMCupsManager::stateInformation() -{ - return TQString("%1: %2") - .arg(i18n("Server")) - .arg(CupsInfos::self()->host()[0] != '/' ? - TQString(TQString("%1:%2").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port())) - : CupsInfos::self()->host()); -} - -void KMCupsManager::checkUpdatePossibleInternal() -{ - kdDebug(500) << "Checking for update possible" << endl; - delete m_socket; - m_socket = new KNetwork::KBufferedSocket; - m_socket->setTimeout( 1500 ); - connect( m_socket, TQT_SIGNAL( connected(const KResolverEntry&) ), - TQT_SLOT( slotConnectionSuccess() ) ); - connect( m_socket, TQT_SIGNAL( gotError( int ) ), TQT_SLOT( slotConnectionFailed( int ) ) ); - - trials = 5; - TQTimer::singleShot( 1, this, TQT_SLOT( slotAsyncConnect() ) ); -} - -void KMCupsManager::slotConnectionSuccess() -{ - kdDebug(500) << "Connection success, trying to send a request..." << endl; - m_socket->close(); - - IppRequest req; - req.setOperation( CUPS_GET_PRINTERS ); - req.addKeyword( IPP_TAG_OPERATION, "requested-attributes", TQString::tqfromLatin1( "printer-name" ) ); - if ( req.doRequest( "/printers/" ) ) - setUpdatePossible( true ); - else - { - kdDebug(500) << "Unable to get printer list" << endl; - if ( trials > 0 ) - { - trials--; - TQTimer::singleShot( 1000, this, TQT_SLOT( slotAsyncConnect() ) ); - } - else - { - setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. " - "Error: %1." ).arg( i18n( "the IPP request failed for an unknown reason" ) ) ); - setUpdatePossible( false ); - } - } -} - -void KMCupsManager::slotAsyncConnect() -{ - kdDebug(500) << "Starting async connect to " << CupsInfos::self()->hostaddr() << endl; - //m_socket->startAsyncConnect(); - if (CupsInfos::self()->host().startsWith("/")) - m_socket->connect( TQString(), CupsInfos::self()->host()); - else - m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() ); -} - -void KMCupsManager::slotConnectionFailed( int errcode ) -{ - kdDebug(500) << "Connection failed trials=" << trials << endl; - if ( trials > 0 ) - { - //m_socket->setTimeout( ++to ); - //m_socket->cancelAsyncConnect(); - trials--; - m_socket->close(); - TQTimer::singleShot( 1000, this, TQT_SLOT( slotAsyncConnect() ) ); - return; - } - - TQString einfo; - - switch (errcode) { - case KNetwork::KSocketBase::ConnectionRefused: - case KNetwork::KSocketBase::ConnectionTimedOut: - einfo = i18n("connection refused") + TQString(" (%1)").arg(errcode); - break; - case KNetwork::KSocketBase::LookupFailure: - einfo = i18n("host not found") + TQString(" (%1)").arg(errcode); - break; - case KNetwork::KSocketBase::WouldBlock: - default: - einfo = i18n("read failed (%1)").arg(errcode); - break; - } - - setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. " - "Error: %2: %1." ).arg( einfo, CupsInfos::self()->host())); - setUpdatePossible( false ); -} - -void KMCupsManager::hostPingSlot() { - m_hostSuccess = true; - m_lookupDone = true; -} - -void KMCupsManager::hostPingFailedSlot() { - m_hostSuccess = false; - m_lookupDone = true; -} - -//***************************************************************************************************** - -static void extractMaticData(TQString& buf, const TQString& filename) -{ - TQFile f(filename); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - while (!t.eof()) - { - line = t.readLine(); - if (line.startsWith("*% COMDATA #")) - buf.append(line.right(line.length()-12)).append('\n'); - } - } -} - -static TQString printerURI(KMPrinter *p, bool use) -{ - TQString uri; - if (use && !p->uri().isEmpty()) - uri = p->uri().prettyURL(); - else - uri = TQString("ipp://%1/%3/%2").arg(CupsInfos::self()->hostaddr()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers")); - return uri; -} - -static TQString downloadDriver(KMPrinter *p) -{ - TQString driverfile, prname = p->printerName(); - bool changed(false); - - /* - if (!p->uri().isEmpty()) - { - // try to load the driver from the host:port - // specified in its URI. Doing so may also change - // the printer name to use. Note that for remote - // printer, this operation is read-only, no counterpart - // for saving operation. - cupsSetServer(p->uri().host().local8Bit()); - ippSetPort(p->uri().port()); - // strip any "@..." from the printer name - prname = prname.replace(TQRegExp("@.*"), ""); - changed = true; - } - */ - - // download driver - driverfile = cupsGetPPD(prname.local8Bit()); - - // restore host:port (if they have changed) - if (changed) - { - cupsSetServer(CupsInfos::self()->host().local8Bit()); - ippSetPort(CupsInfos::self()->port()); - } - - return driverfile; -} - -#include "kmcupsmanager.moc" diff --git a/kdeprint/cups/kmcupsmanager.h b/kdeprint/cups/kmcupsmanager.h deleted file mode 100644 index d574bb686..000000000 --- a/kdeprint/cups/kmcupsmanager.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCUPSMANAGER_H -#define KMCUPSMANAGER_H - -#include "kmmanager.h" - -class IppRequest; -class KLibrary; -class KExtendedSocket; - -namespace KNetwork { - class KStreamSocket; -} - -class KMCupsManager : public KMManager -{ - friend class KMWIppPrinter; - friend class KMCupsJobManager; - - Q_OBJECT -public: - KMCupsManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - virtual ~KMCupsManager(); - - // printer management functions - bool createPrinter(KMPrinter *p); - bool removePrinter(KMPrinter *p); - bool enablePrinter(KMPrinter *p, bool state); - bool startPrinter(KMPrinter *p, bool state); - bool completePrinter(KMPrinter *p); - bool completePrinterShort(KMPrinter *p); - bool setDefaultPrinter(KMPrinter *p); - bool testPrinter(KMPrinter *p); - - // printer listing functions - // driver DB functions - TQString driverDbCreationProgram(); - TQString driverDirectory(); - - DrMain* loadPrinterDriver(KMPrinter *p, bool config = false); - DrMain* loadFileDriver(const TQString& filename); - bool savePrinterDriver(KMPrinter *p, DrMain *d); - - bool restartServer(); - bool configureServer(TQWidget *parent = 0); - TQStringList detectLocalPrinters(); - - void createPluginActions(KActionCollection*); - void validatePluginActions(KActionCollection*, KMPrinter*); - TQString stateInformation(); - -public slots: - void exportDriver(); - void printerIppReport(); - -protected slots: - void slotConnectionFailed( int ); - void slotConnectionSuccess(); - void slotAsyncConnect(); - - void hostPingSlot(); - void hostPingFailedSlot(); - -protected: - // the real printer listing job is done here - void listPrinters(); - void loadServerPrinters(); - void processRequest(IppRequest*); - bool setPrinterState(KMPrinter *p, int st); - DrMain* loadDriverFile(const TQString& filename); - DrMain* loadMaticDriver(const TQString& drname); - void saveDriverFile(DrMain *driver, const TQString& filename); - void reportIppError(IppRequest*); - void* loadCupsdConfFunction(const char*); - void unloadCupsdConf(); - TQString cupsInstallDir(); - void ippReport(IppRequest&, int, const TQString&); - void checkUpdatePossibleInternal(); - -private: - KLibrary *m_cupsdconf; - KMPrinter *m_currentprinter; - KNetwork::KStreamSocket *m_socket; - bool m_hostSuccess; - bool m_lookupDone; -}; - -#endif diff --git a/kdeprint/cups/kmcupsuimanager.cpp b/kdeprint/cups/kmcupsuimanager.cpp deleted file mode 100644 index c3dfcb1ac..000000000 --- a/kdeprint/cups/kmcupsuimanager.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmcupsuimanager.h" -#include "kmpropertypage.h" -#include "kmwizard.h" -#include "kmconfigdialog.h" -#include "kmwbackend.h" -#include "kmfactory.h" -#include "kprinter.h" - -#include "kmpropbanners.h" -#include "kmpropmembers.h" -#include "kmpropbackend.h" -#include "kmpropdriver.h" -#include "kmwbanners.h" -#include "kmwipp.h" -#include "kmwippselect.h" -#include "kmwippprinter.h" -#include "kmconfigcups.h" -#include "kmconfigcupsdir.h" -#include "kmwfax.h" -#include "kmwother.h" -#include "kmwquota.h" -#include "kmpropquota.h" -#include "kmwusers.h" -#include "kmpropusers.h" -#include "kpschedulepage.h" -#include "kptagspage.h" - -#include "kprinterpropertydialog.h" -#include "kpgeneralpage.h" -#include "kpimagepage.h" -#include "kptextpage.h" -#include "kphpgl2page.h" - -#include "ipprequest.h" -#include "cupsinfos.h" - -#include <tqlistview.h> -#include <tqwhatsthis.h> -#include <klocale.h> -#include <kdebug.h> -#include <kaction.h> -#include <kmessagebox.h> - -KMCupsUiManager::KMCupsUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMUiManager(parent,name) -{ -} - -KMCupsUiManager::~KMCupsUiManager() -{ -} - -void KMCupsUiManager::setupPropertyPages(KMPropertyPage *p) -{ - p->addPropPage(new KMPropMembers(p, "Members")); - p->addPropPage(new KMPropBackend(p, "Backend")); - p->addPropPage(new KMPropDriver(p, "Driver")); - p->addPropPage(new KMPropBanners(p, "Banners")); - p->addPropPage(new KMPropQuota(p, "Quotas")); - p->addPropPage(new KMPropUsers(p, "Users")); -} - -void KMCupsUiManager::setupWizard(KMWizard *wizard) -{ - TQString whatsThisRemoteCUPSIPPBackend = - i18n( "<qt><p>Print queue on remote CUPS server</p>" - "<p>Use this for a print queue installed on a remote " - "machine running a CUPS server. This allows to use " - "remote printers when CUPS browsing is turned off.</p></qt>" - ); - - TQString whatsThisRemotePrinterIPPBackend = - i18n( "<qt><p>Network IPP printer</p>" - "<p>Use this for a network-enabled printer using the " - "IPP protocol. Modern high-end printers can use this mode. " - "Use this mode instead of TCP if your printer can do both.</p></qt>" - ); - - TQString whatsThisSerialFaxModemBackend = - i18n( "<qt><p>Fax/Modem printer</p>" - "<p>Use this for a fax/modem printer. This requires the installation " - "of the <a href=\"http://vigna.dsi.unimi.it/fax4CUPS/\">fax4CUPS</a> backend. Documents sent on this printer will be faxed " - "to the given target fax number.</p></qt>" - ); - - TQString whatsThisOtherPrintertypeBackend = - i18n( "<qt><p>Other printer</p>" - "<p>Use this for any printer type. To use this option, you must know " - "the URI of the printer you want to install. Refer to the CUPS documentation " - "for more information about the printer URI. This option is mainly useful for " - "printer types using 3rd party backends not covered by the other possibilities.</p></qt>" - ); - - TQString whatsThisClassOfPrinters = - i18n( "<qt><p>Class of printers</p>" - "<p>Use this to create a class of printers. When sending a document to a class, " - "the document is actually sent to the first available (idle) printer in the class. " - "Refer to the CUPS documentation for more information about class of printers.</p></qt>" - ); - - KMWBackend *backend = wizard->backendPage(); - if (!backend) - return; - backend->addBackend(KMWizard::Local,false); - backend->addBackend(KMWizard::LPD,false); - backend->addBackend(KMWizard::SMB,false,KMWizard::Password); - backend->addBackend(KMWizard::TCP,false); - backend->addBackend(KMWizard::IPP,i18n("Re&mote CUPS server (IPP/HTTP)"),false,whatsThisRemoteCUPSIPPBackend,KMWizard::Password); - backend->addBackend(KMWizard::Custom+1,i18n("Network printer w/&IPP (IPP/HTTP)"),false,whatsThisRemotePrinterIPPBackend); - backend->addBackend(KMWizard::Custom+2,i18n("S&erial Fax/Modem printer"),false,whatsThisSerialFaxModemBackend); - backend->addBackend(KMWizard::Custom+5,i18n("Other &printer type"),false,whatsThisOtherPrintertypeBackend); - backend->addBackend(); - backend->addBackend(KMWizard::Class,i18n("Cl&ass of printers"),false,whatsThisClassOfPrinters); - - IppRequest req; - QString uri; - - req.setOperation(CUPS_GET_DEVICES); - uri = TQString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - - if (req.doRequest("/")) - { - ipp_attribute_t *attr = req.first(); - while (attr) - { - if (attr->name && strcmp(attr->name,"device-uri") == 0) - { - if (strncmp(attr->values[0].string.text,"socket",6) == 0) backend->enableBackend(KMWizard::TCP,true); - else if (strncmp(attr->values[0].string.text,"parallel",8) == 0) backend->enableBackend(KMWizard::Local,true); - else if (strncmp(attr->values[0].string.text,"serial",6) == 0) backend->enableBackend(KMWizard::Local,true); - else if (strncmp(attr->values[0].string.text,"smb",3) == 0) backend->enableBackend(KMWizard::SMB,true); - else if (strncmp(attr->values[0].string.text,"lpd",3) == 0) backend->enableBackend(KMWizard::LPD,true); - else if (strncmp(attr->values[0].string.text,"usb",3) == 0) backend->enableBackend(KMWizard::Local,true); - else if (strncmp(attr->values[0].string.text,"http",4) == 0 || strncmp(attr->values[0].string.text,"ipp",3) == 0) - { - backend->enableBackend(KMWizard::IPP,true); - backend->enableBackend(KMWizard::Custom+1,true); - } - else if (strncmp(attr->values[0].string.text,"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,true); - } - attr = attr->next; - } - backend->enableBackend(KMWizard::Class, true); - backend->enableBackend(KMWizard::Custom+5, true); - } - else - KMessageBox::error(wizard, - "<qt><nobr>" + - i18n("An error occurred while retrieving the list of available backends:") + - "</nobr><br><br>" + req.statusMessage() + "</qt>"); - - // banners page - wizard->addPage(new KMWBanners(wizard)); - wizard->setNextPage(KMWizard::DriverTest,KMWizard::Banners); - wizard->addPage(new KMWIpp(wizard)); - wizard->addPage(new KMWIppSelect(wizard)); - wizard->addPage(new KMWIppPrinter(wizard)); - wizard->addPage(new KMWFax(wizard)); - wizard->addPage(new KMWQuota(wizard)); - wizard->addPage(new KMWUsers(wizard)); - wizard->addPage(new KMWOther(wizard)); -} - -void KMCupsUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg) -{ - // add general page - dlg->addPage(new KPGeneralPage(dlg->printer(),dlg->driver(),dlg,"GeneralPage")); - if (KMFactory::self()->settings()->application != KPrinter::Dialog) - { - dlg->addPage(new KPImagePage(dlg->driver(), dlg, "ImagePage")); - dlg->addPage(new KPTextPage(dlg->driver(), dlg, "TextPage")); - dlg->addPage(new KPHpgl2Page(dlg, "Hpgl2Page")); - } -} - -void KMCupsUiManager::setupConfigDialog(KMConfigDialog *dlg) -{ - dlg->addConfigPage(new KMConfigCups(dlg)); - dlg->addConfigPage(new KMConfigCupsDir(dlg)); -} - -int KMCupsUiManager::pluginPageCap() -{ - return (KMUiManager::CopyAll & ~KMUiManager::Current); -} - -void KMCupsUiManager::setupPrintDialogPages(TQPtrList<KPrintDialogPage>* pages) -{ - pages->append(new KPSchedulePage()); - pages->append(new KPTagsPage()); -} - -void KMCupsUiManager::setupJobViewer(TQListView *lv) -{ - lv->addColumn(i18n("Priority")); - lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter); - lv->addColumn(i18n("Billing Information")); - lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter); -} diff --git a/kdeprint/cups/kmcupsuimanager.h b/kdeprint/cups/kmcupsuimanager.h deleted file mode 100644 index 6ad0f574f..000000000 --- a/kdeprint/cups/kmcupsuimanager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCUPSUIMANAGER_H -#define KMCUPSUIMANAGER_H - -#include "kmuimanager.h" - -class KMCupsUiManager : public KMUiManager -{ -public: - KMCupsUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMCupsUiManager(); - - void setupPropertyPages(KMPropertyPage*); - void setupWizard(KMWizard*); - void setupPrinterPropertyDialog(KPrinterPropertyDialog*); - void setupConfigDialog(KMConfigDialog*); - int pluginPageCap(); - void setupPrintDialogPages(TQPtrList<KPrintDialogPage>*); - void setupJobViewer(TQListView*); -}; - -#endif diff --git a/kdeprint/cups/kmpropbanners.cpp b/kdeprint/cups/kmpropbanners.cpp deleted file mode 100644 index 22098cdff..000000000 --- a/kdeprint/cups/kmpropbanners.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropbanners.h" -#include "kmprinter.h" -#include "kmwizard.h" -#include "kmwbanners.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropBanners::KMPropBanners(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_startbanner = new TQLabel(this); - m_stopbanner = new TQLabel(this); - - TQLabel *l1 = new TQLabel(i18n("&Starting banner:"), this); - TQLabel *l2 = new TQLabel(i18n("&Ending banner:"), this); - - l1->setBuddy(m_startbanner); - l2->setBuddy(m_stopbanner); - - TQGridLayout *main_ = new TQGridLayout(this, 3, 2, 10, 10); - main_->setColStretch(1,1); - main_->setRowStretch(2,1); - main_->addWidget(l1,0,0); - main_->addWidget(l2,1,0); - main_->addWidget(m_startbanner,0,1); - main_->addWidget(m_stopbanner,1,1); - - m_title = i18n("Banners"); - m_header = i18n("Banner Settings"); - m_pixmap = "editcopy"; -} - -KMPropBanners::~KMPropBanners() -{ -} - -void KMPropBanners::setPrinter(KMPrinter *p) -{ - if (p && p->isPrinter()) - { - TQStringList l = TQStringList::split(',',p->option("kde-banners"),false); - while ( l.count() < 2 ) - l.append( "none" ); - m_startbanner->setText(i18n(mapBanner(l[0]).utf8())); - m_stopbanner->setText(i18n(mapBanner(l[1]).utf8())); - emit enable(true); - emit enableChange(p->isLocal()); - } - else - { - emit enable(false); - m_startbanner->setText(""); - m_stopbanner->setText(""); - } -} - -void KMPropBanners::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Banners,KMWizard::Banners,true); -} diff --git a/kdeprint/cups/kmpropbanners.h b/kdeprint/cups/kmpropbanners.h deleted file mode 100644 index 770419dc5..000000000 --- a/kdeprint/cups/kmpropbanners.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPBANNERS_H -#define KMPROPBANNERS_H - -#include "kmpropwidget.h" - -class TQLabel; - -class KMPropBanners : public KMPropWidget -{ -public: - KMPropBanners(TQWidget *parent = 0, const char *name = 0); - ~KMPropBanners(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQLabel *m_startbanner; - TQLabel *m_stopbanner; -}; - -#endif diff --git a/kdeprint/cups/kmpropquota.cpp b/kdeprint/cups/kmpropquota.cpp deleted file mode 100644 index 9df6cbcb2..000000000 --- a/kdeprint/cups/kmpropquota.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropquota.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> - -// some forward declarations (see kmwquota.cpp) -const char* unitKeyword(int); -int findUnit(int&); - -KMPropQuota::KMPropQuota(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_period = new TQLabel(this); - m_sizelimit = new TQLabel(this); - m_pagelimit = new TQLabel(this); - - TQLabel *l1 = new TQLabel(i18n("&Period:"), this); - TQLabel *l2 = new TQLabel(i18n("&Size limit (KB):"), this); - TQLabel *l3 = new TQLabel(i18n("&Page limit:"), this); - - l1->setBuddy(m_period); - l2->setBuddy(m_sizelimit); - l3->setBuddy(m_pagelimit); - - TQGridLayout *main_ = new TQGridLayout(this, 4, 2, 10, 10); - main_->setColStretch(1,1); - main_->setRowStretch(3,1); - main_->addWidget(l1,0,0); - main_->addWidget(l2,1,0); - main_->addWidget(l3,2,0); - main_->addWidget(m_period,0,1); - main_->addWidget(m_sizelimit,1,1); - main_->addWidget(m_pagelimit,2,1); - - m_title = i18n("Quotas"); - m_header = i18n("Quota Settings"); - m_pixmap = "lock"; -} - -KMPropQuota::~KMPropQuota() -{ -} - -void KMPropQuota::setPrinter(KMPrinter *p) -{ - if (p && p->isPrinter()) - { - int qu(0), si(0), pa(0), un(0); - qu = p->option("job-quota-period").toInt(); - si = p->option("job-k-limit").toInt(); - pa = p->option("job-page-limit").toInt(); - if (si == 0 && pa == 0) - qu = -1; - if (qu > 0) - un = findUnit(qu); - m_period->setText(qu == -1 ? i18n("No quota") : TQString::number(qu).append(" ").append(i18n(unitKeyword(un)))); - m_sizelimit->setText(si ? TQString::number(si) : i18n("None")); - m_pagelimit->setText(pa ? TQString::number(pa) : i18n("None")); - emit enable(true); - emit enableChange(p->isLocal()); - } - else - { - emit enable(false); - m_period->setText(""); - m_sizelimit->setText(""); - m_pagelimit->setText(""); - } -} - -void KMPropQuota::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Custom+3,KMWizard::Custom+3,true); -} diff --git a/kdeprint/cups/kmpropquota.h b/kdeprint/cups/kmpropquota.h deleted file mode 100644 index 8ebeb323b..000000000 --- a/kdeprint/cups/kmpropquota.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPQUOTA_H -#define KMPROPQUOTA_H - -#include "kmpropwidget.h" - -class TQLabel; - -class KMPropQuota : public KMPropWidget -{ -public: - KMPropQuota(TQWidget *parent = 0, const char *name = 0); - ~KMPropQuota(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQLabel *m_period; - TQLabel *m_sizelimit; - TQLabel *m_pagelimit; -}; - -#endif diff --git a/kdeprint/cups/kmpropusers.cpp b/kdeprint/cups/kmpropusers.cpp deleted file mode 100644 index 65a9e4dbd..000000000 --- a/kdeprint/cups/kmpropusers.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropusers.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqtextview.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropUsers::KMPropUsers(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_text = new TQTextView(this); - m_text->setPaper(tqcolorGroup().background()); - m_text->setFrameStyle(TQFrame::NoFrame); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 10, 0); - l0->addWidget(m_text, 1); - - m_title = i18n("Users"); - m_header = i18n("Users Access Settings"); - m_pixmap = "tdeprint_printer_users"; -} - -KMPropUsers::~KMPropUsers() -{ -} - -void KMPropUsers::setPrinter(KMPrinter *p) -{ - if (p && p->isPrinter()) - { - TQString txt("<p>%1:<ul>%1</ul></p>"); - TQStringList users; - if (!p->option("requesting-user-name-denied").isEmpty()) - { - txt = txt.arg(i18n("Denied users")); - users = TQStringList::split(",", p->option("requesting-user-name-denied"), false); - if (users.count() == 1 && users[0] == "none") - users.clear(); - } - else if (!p->option("requesting-user-name-allowed").isEmpty()) - { - txt = txt.arg(i18n("Allowed users")); - users = TQStringList::split(",", p->option("requesting-user-name-allowed"), false); - if (users.count() == 1 && users[0] == "all") - users.clear(); - } - if (users.count() > 0) - { - TQString s; - for (TQStringList::ConstIterator it=users.begin(); it!=users.end(); ++it) - s.append("<li>").append(*it).append("</li>"); - txt = txt.arg(s); - m_text->setText(txt); - } - else - m_text->setText(i18n("All users allowed")); - emit enable(true); - emit enableChange(p->isLocal()); - } - else - { - emit enable(false); - m_text->setText(""); - } -} - -void KMPropUsers::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Custom+4,KMWizard::Custom+4,true); -} diff --git a/kdeprint/cups/kmpropusers.h b/kdeprint/cups/kmpropusers.h deleted file mode 100644 index 35e935adb..000000000 --- a/kdeprint/cups/kmpropusers.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPUSERS_H -#define KMPROPUSERS_H - -#include "kmpropwidget.h" - -class TQTextView; - -class KMPropUsers : public KMPropWidget -{ -public: - KMPropUsers(TQWidget *parent = 0, const char *name = 0); - ~KMPropUsers(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQTextView *m_text; -}; - -#endif diff --git a/kdeprint/cups/kmwbanners.cpp b/kdeprint/cups/kmwbanners.cpp deleted file mode 100644 index c221f69d7..000000000 --- a/kdeprint/cups/kmwbanners.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwbanners.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "kmfactory.h" -#include "kmmanager.h" - -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqmap.h> -#include <klocale.h> - -TQStringList defaultBanners() -{ - TQStringList bans; - TQPtrList<KMPrinter> *list = KMFactory::self()->manager()->printerList(false); - if (list && list->count() > 0) - { - TQPtrListIterator<KMPrinter> it(*list); - for (;it.current() && !it.current()->isPrinter(); ++it) ; - if (it.current() && KMFactory::self()->manager()->completePrinter(it.current())) - { - TQString s = list->getFirst()->option("kde-banners-supported"); - bans = TQStringList::split(',',s,false); - } - } - if (bans.count() == 0) - bans.append("none"); - return bans; -} - -static struct -{ - const char *banner; - const char *name; -} bannermap[] = -{ - { "none", I18N_NOOP( "No Banner" ) }, - { "classified", I18N_NOOP( "Classified" ) }, - { "confidential", I18N_NOOP( "Confidential" ) }, - { "secret", I18N_NOOP( "Secret" ) }, - { "standard", I18N_NOOP( "Standard" ) }, - { "topsecret", I18N_NOOP( "Top Secret" ) }, - { "unclassified", I18N_NOOP( "Unclassified" ) }, - { 0, 0 } -}; - -TQString mapBanner( const TQString& ban ) -{ - static TQMap<TQString,TQString> map; - if ( map.size() == 0 ) - for ( int i=0; bannermap[ i ].banner; i++ ) - map[ bannermap[ i ].banner ] = bannermap[ i ].name; - TQMap<TQString,TQString>::ConstIterator it = map.find( ban ); - if ( it == map.end() ) - return ban; - else - return it.data(); -} - -//************************************************************************************************************** - -KMWBanners::KMWBanners(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Banners; - m_title = i18n("Banner Selection"); - m_nextpage = KMWizard::Custom+3; - - m_start = new TQComboBox(this); - m_end = new TQComboBox(this); - - TQLabel *l1 = new TQLabel(i18n("&Starting banner:"),this); - TQLabel *l2 = new TQLabel(i18n("&Ending banner:"),this); - - l1->setBuddy(m_start); - l2->setBuddy(m_end); - - TQLabel *l0 = new TQLabel(this); - l0->setText(i18n("<p>Select the default banners associated with this printer. These " - "banners will be inserted before and/or after each print job sent " - "to the printer. If you don't want to use banners, select <b>No Banner</b>.</p>")); - - TQGridLayout *lay = new TQGridLayout(this, 5, 2, 0, 10); - lay->setColStretch(1,1); - lay->addRowSpacing(1,20); - lay->setRowStretch(4,1); - lay->addMultiCellWidget(l0,0,0,0,1); - lay->addWidget(l1,2,0); - lay->addWidget(l2,3,0); - lay->addWidget(m_start,2,1); - lay->addWidget(m_end,3,1); -} - -void KMWBanners::initPrinter(KMPrinter *p) -{ - if (p) - { - if (m_start->count() == 0) - { - m_bans = TQStringList::split(',',p->option("kde-banners-supported"),false); - if (m_bans.count() == 0) - m_bans = defaultBanners(); - if (m_bans.find("none") == m_bans.end()) - m_bans.prepend("none"); - for ( TQStringList::Iterator it=m_bans.begin(); it!=m_bans.end(); ++it ) - { - m_start->insertItem( i18n( mapBanner(*it).utf8() ) ); - m_end->insertItem( i18n( mapBanner(*it).utf8() ) ); - } - } - TQStringList l = TQStringList::split(',',p->option("kde-banners"),false); - while (l.count() < 2) - l.append("none"); - m_start->setCurrentItem(m_bans.findIndex(l[0])); - m_end->setCurrentItem(m_bans.findIndex(l[1])); - } -} - -void KMWBanners::updatePrinter(KMPrinter *p) -{ - if (m_start->count() > 0) - { - p->setOption("kde-banners",m_bans[m_start->currentItem()]+","+m_bans[m_end->currentItem()]); - } -} diff --git a/kdeprint/cups/kmwbanners.h b/kdeprint/cups/kmwbanners.h deleted file mode 100644 index 6f8650848..000000000 --- a/kdeprint/cups/kmwbanners.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWBANNERS_H -#define KMWBANNERS_H - -#include "kmwizardpage.h" -#include <tqstringlist.h> - -class TQComboBox; - -class KMWBanners : public KMWizardPage -{ -public: - KMWBanners(TQWidget *parent = 0, const char *name = 0); - - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -private: - TQComboBox *m_start, *m_end; - TQStringList m_bans; -}; - -TQString mapBanner( const TQString& ); - -#endif diff --git a/kdeprint/cups/kmwfax.cpp b/kdeprint/cups/kmwfax.cpp deleted file mode 100644 index 352081f6c..000000000 --- a/kdeprint/cups/kmwfax.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwfax.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "ipprequest.h" -#include "cupsinfos.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klistbox.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kurl.h> - -KMWFax::KMWFax(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Custom+2; - m_title = i18n("Fax Serial Device"); - m_nextpage = KMWizard::Driver; - - TQLabel *lab = new TQLabel(this); - lab->setText(i18n("<p>Select the device which your serial Fax/Modem is connected to.</p>")); - m_list = new KListBox(this); - - TQVBoxLayout *l1 = new TQVBoxLayout(this,0,10); - l1->addWidget(lab,0); - l1->addWidget(m_list,1); - - // initialize - IppRequest req; - req.setOperation(CUPS_GET_DEVICES); - TQString uri = TQString::tqfromLatin1("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - if (req.doRequest("/")) - { - ipp_attribute_t *attr = req.first(); - while (attr) - { - if (attr->name && strcmp(attr->name,"device-uri") == 0 && strncmp(attr->values[0].string.text,"fax",3) == 0) - { - m_list->insertItem(SmallIcon("blockdevice"),TQString::tqfromLatin1(attr->values[0].string.text)); - } - attr = attr->next; - } - } -} - -bool KMWFax::isValid(TQString& msg) -{ - if (m_list->currentItem() == -1) - { - msg = i18n("You must select a device."); - return false; - } - return true; -} - -void KMWFax::updatePrinter(KMPrinter *printer) -{ - TQString uri = m_list->currentText(); - printer->setDevice(uri); -} diff --git a/kdeprint/cups/kmwfax.h b/kdeprint/cups/kmwfax.h deleted file mode 100644 index 1a822165e..000000000 --- a/kdeprint/cups/kmwfax.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWFAX_H -#define KMWFAX_H - -#include "kmwizardpage.h" - -class KListBox; - -class KMWFax : public KMWizardPage -{ -public: - KMWFax(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - -private: - KListBox *m_list; -}; - -#endif diff --git a/kdeprint/cups/kmwipp.cpp b/kdeprint/cups/kmwipp.cpp deleted file mode 100644 index 119da629a..000000000 --- a/kdeprint/cups/kmwipp.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwipp.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <klocale.h> -#include <tqvalidator.h> - -#include <cups/http.h> - -KMWIpp::KMWIpp(TQWidget *parent, const char *name) -: KMWInfoBase(2,parent,name) -{ - m_ID = KMWizard::IPP; - m_title = i18n("Remote IPP server"); - m_nextpage = KMWizard::IPPSelect; - lineEdit( 1 )->setValidator( new TQIntValidator( TQT_TQOBJECT(this) ) ); - - setInfo(i18n("<p>Enter the information concerning the remote IPP server " - "owning the targeted printer. This wizard will poll the server " - "before continuing.</p>")); - setLabel(0,i18n("Host:")); - setLabel(1,i18n("Port:")); - setText( 1, TQString::tqfromLatin1( "631" ) ); -} - -bool KMWIpp::isValid(TQString& msg) -{ - // check informations - if (text(0).isEmpty()) - { - msg = i18n("Empty server name."); - return false; - } - bool ok(false); - int p = text(1).toInt(&ok); - if (!ok) - { - msg = i18n("Incorrect port number."); - return false; - } - - // check server - http_t *HTTP = httpConnect(text(0).latin1(),p); - if (HTTP) - { - httpClose(HTTP); - return true; - } - else - { - msg = i18n("<nobr>Unable to connect to <b>%1</b> on port <b>%2</b> .</nobr>").arg(text(0)).arg(p); - return false; - } -} - -void KMWIpp::updatePrinter(KMPrinter *p) -{ - KURL url; - url.setProtocol("ipp"); - url.setHost(text(0)); - url.setPort(text(1).toInt()); - if (!p->option("kde-login").isEmpty()) url.setUser(p->option("kde-login")); - if (!p->option("kde-password").isEmpty()) url.setPass(p->option("kde-password")); - p->setDevice(url.url()); -} diff --git a/kdeprint/cups/kmwipp.h b/kdeprint/cups/kmwipp.h deleted file mode 100644 index 33d02629b..000000000 --- a/kdeprint/cups/kmwipp.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWIPP_H -#define KMWIPP_H - -#include "kmwinfobase.h" - -class KMWIpp : public KMWInfoBase -{ -public: - KMWIpp(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); -}; - -#endif diff --git a/kdeprint/cups/kmwippprinter.cpp b/kdeprint/cups/kmwippprinter.cpp deleted file mode 100644 index 0a0c7b672..000000000 --- a/kdeprint/cups/kmwippprinter.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwippprinter.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "ipprequest.h" -#include "kmcupsmanager.h" -#include "networkscanner.h" - -#include <klistview.h> -#include <tqheader.h> -#include <kpushbutton.h> -#include <tqlineedit.h> -#include <tqlabel.h> -#include <kmessagebox.h> -#include <tqtextview.h> -#include <tqlayout.h> -#include <tqregexp.h> -#include <kseparator.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kguiitem.h> -#include <kurl.h> - -KMWIppPrinter::KMWIppPrinter(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_title = i18n("IPP Printer Information"); - m_ID = KMWizard::Custom+1; - m_nextpage = KMWizard::Driver; - - m_list = new KListView(this); - m_list->addColumn(""); - m_list->header()->hide(); - m_list->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - m_list->setLineWidth(1); - - TQLabel *l1 = new TQLabel(i18n("&Printer URI:"),this); - - m_uri = new TQLineEdit(this); - - l1->setBuddy(m_uri); - - m_info = new TQTextView(this); - m_info->setPaper(tqcolorGroup().background()); - m_info->setMinimumHeight(100); - m_info->setText(i18n("<p>Either enter the printer URI directly, or use the network scanning facility.</p>")); - m_ippreport = new KPushButton(KGuiItem(i18n("&IPP Report"), "tdeprint_report"), this); - m_ippreport->setEnabled(false); - - m_scanner = new NetworkScanner( 631, this ); - - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - sep->setFixedHeight(20); - - connect(m_list,TQT_SIGNAL(selectionChanged(TQListViewItem*)),TQT_SLOT(slotPrinterSelected(TQListViewItem*))); - connect( m_scanner, TQT_SIGNAL( scanStarted() ), TQT_SLOT( slotScanStarted() ) ); - connect( m_scanner, TQT_SIGNAL( scanFinished() ), TQT_SLOT( slotScanFinished() ) ); - connect( m_scanner, TQT_SIGNAL( scanStarted() ), parent, TQT_SLOT( disableWizard() ) ); - connect( m_scanner, TQT_SIGNAL( scanFinished() ), parent, TQT_SLOT( enableWizard() ) ); - connect(m_ippreport, TQT_SIGNAL(clicked()), TQT_SLOT(slotIppReport())); - - // layout - TQHBoxLayout *lay3 = new TQHBoxLayout(this, 0, 10); - TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 0); - TQHBoxLayout *lay4 = new TQHBoxLayout(0, 0, 0); - - lay3->addWidget(m_list,1); - lay3->addLayout(lay2,1); - lay2->addWidget(l1); - lay2->addWidget(m_uri); - lay2->addSpacing(10); - lay2->addWidget(m_info, 1); - lay2->addSpacing(5); - lay2->addLayout(lay4); - lay4->addStretch(1); - lay4->addWidget(m_ippreport); - lay2->addWidget(sep); - lay2->addWidget( m_scanner ); -} - -KMWIppPrinter::~KMWIppPrinter() -{ -} - -void KMWIppPrinter::updatePrinter(KMPrinter *p) -{ - p->setDevice(m_uri->text()); -} - -bool KMWIppPrinter::isValid(TQString& msg) -{ - if (m_uri->text().isEmpty()) - { - msg = i18n("You must enter a printer URI."); - return false; - } - - KURL uri( m_uri->text() ); - if (!m_scanner->checkPrinter(uri.host(),(uri.port()==0?631:uri.port()))) - { - msg = i18n("No printer found at this address/port."); - return false; - } - return true; -} - -void KMWIppPrinter::slotScanStarted() -{ - m_list->clear(); -} - -void KMWIppPrinter::slotScanFinished() -{ - m_ippreport->setEnabled(false); - const TQPtrList<NetworkScanner::SocketInfo> *list = m_scanner->printerList(); - TQPtrListIterator<NetworkScanner::SocketInfo> it(*list); - for (;it.current();++it) - { - TQString name; - if (it.current()->Name.isEmpty()) - name = i18n("Unknown host - 1 is the IP", "<Unknown> (%1)").arg(it.current()->IP); - else - name = it.current()->Name; - TQListViewItem *item = new TQListViewItem(m_list,name,it.current()->IP,TQString::number(it.current()->Port)); - item->setPixmap(0,SmallIcon("tdeprint_printer")); - } -} - -void KMWIppPrinter::slotPrinterSelected(TQListViewItem *item) -{ - m_ippreport->setEnabled(item != 0); - if (!item) return; - - // trying to get printer attributes - IppRequest req; - TQString uri; - TQStringList keys; - - req.setOperation(IPP_GET_PRINTER_ATTRIBUTES); - req.setHost(item->text(1)); - req.setPort(item->text(2).toInt()); - uri = TQString::tqfromLatin1("ipp://%1:%2/ipp").arg(item->text(1)).arg(item->text(2)); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - keys.append("printer-name"); - keys.append("printer-state"); - keys.append("printer-info"); - keys.append("printer-uri-supported"); - keys.append("printer-make-and-model"); - keys.append("printer-location"); - req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",keys); - if (req.doRequest("/ipp/") && (req.status() == IPP_OK || req.status() == IPP_OK_SUBST || req.status() == IPP_OK_CONFLICT)) - { - TQString value, txt; - int state; - if (req.name("printer-name",value)) txt.append(i18n("<b>Name</b>: %1<br>").arg(value)); - if (req.text("printer-location",value) && !value.isEmpty()) txt.append(i18n("<b>Location</b>: %1<br>").arg(value)); - if (req.text("printer-info",value) && !value.isEmpty()) txt.append(i18n("<b>Description</b>: %1<br>").arg(value.replace(TQRegExp(";"),"<br>"))); - if (req.uri("printer-uri-supported",value)) - { - if (value[0] == '/') - value.prepend(TQString::tqfromLatin1("ipp://%1:%2").arg(item->text(1)).arg(item->text(2))); - m_uri->setText(value); - } - if (req.text("printer-make-and-model",value) && !value.isEmpty()) txt.append(i18n("<b>Model</b>: %1<br>").arg(value)); - if (req.enumvalue("printer-state",state)) - { - switch (state) - { - case IPP_PRINTER_IDLE: value = i18n("Idle"); break; - case IPP_PRINTER_STOPPED: value = i18n("Stopped"); break; - case IPP_PRINTER_PROCESSING: value = i18n("Processing..."); break; - default: value = i18n("Unknown State", "Unknown"); break; - } - txt.append(i18n("<b>State</b>: %1<br>").arg(value)); - } - m_info->setText(txt); - } - else - { - m_uri->setText(uri); - m_info->setText(i18n("Unable to retrieve printer info. Printer answered:<br><br>%1").arg(ippErrorString((ipp_status_t)req.status()))); - } -} - -void KMWIppPrinter::slotIppReport() -{ - IppRequest req; - TQString uri("ipp://%1:%2/ipp"); - TQListViewItem *item = m_list->currentItem(); - - if (item) - { - req.setOperation(IPP_GET_PRINTER_ATTRIBUTES); - req.setHost(item->text(1)); - req.setPort(item->text(2).toInt()); - uri = uri.arg(item->text(1)).arg(item->text(2)); - req.addURI(IPP_TAG_OPERATION, "printer-uri", uri); - if (req.doRequest("/ipp/")) - { - TQString caption = i18n("IPP Report for %1").arg(item->text(0)); - static_cast<KMCupsManager*>(KMManager::self())->ippReport(req, IPP_TAG_PRINTER, caption); - } - else - KMessageBox::error(this, i18n("Unable to generate report. IPP request failed with message: " - "%1 (0x%2).").arg(ippErrorString((ipp_status_t)req.status())).arg(req.status(),0,16)); - } -} - -#include "kmwippprinter.moc" diff --git a/kdeprint/cups/kmwippprinter.h b/kdeprint/cups/kmwippprinter.h deleted file mode 100644 index 5d9d33f7a..000000000 --- a/kdeprint/cups/kmwippprinter.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWIPPPRINTER_H -#define KMWIPPPRINTER_H - -#include "kmwizardpage.h" - -class KListView; -class TQListViewItem; -class TQLineEdit; -class TQTextView; -class TQPushButton; -class NetworkScanner; - -class KMWIppPrinter : public KMWizardPage -{ - Q_OBJECT -public: - KMWIppPrinter(TQWidget *parent = 0, const char *name = 0); - ~KMWIppPrinter(); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - -protected slots: - void slotScanStarted(); - void slotScanFinished(); - void slotPrinterSelected(TQListViewItem*); - void slotIppReport(); - -private: - KListView *m_list; - NetworkScanner *m_scanner; - TQLineEdit *m_uri; - TQTextView *m_info; - TQPushButton *m_ippreport; -}; - -#endif diff --git a/kdeprint/cups/kmwippselect.cpp b/kdeprint/cups/kmwippselect.cpp deleted file mode 100644 index 5c9cad356..000000000 --- a/kdeprint/cups/kmwippselect.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwippselect.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "cupsinfos.h" -#include "ipprequest.h" - -#include <klistbox.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kdebug.h> -#include <kiconloader.h> - -KMWIppSelect::KMWIppSelect(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::IPPSelect; - m_title = i18n("Remote IPP Printer Selection"); - m_nextpage = KMWizard::Driver; - - m_list = new KListBox(this); - - TQVBoxLayout *lay = new TQVBoxLayout(this, 0, 0); - lay->addWidget(m_list); -} - -bool KMWIppSelect::isValid(TQString& msg) -{ - if (m_list->currentItem() == -1) - { - msg = i18n("You must select a printer."); - return false; - } - return true; -} - -void KMWIppSelect::initPrinter(KMPrinter *p) -{ - // storage variables - TQString host, login, password; - int port; - - // save config - host = CupsInfos::self()->host(); - login = CupsInfos::self()->login(); - password = CupsInfos::self()->password(); - port = CupsInfos::self()->port(); - - m_list->clear(); - - // retrieve printer list - KURL url = p->device(); - CupsInfos::self()->setHost(url.host()); - CupsInfos::self()->setLogin(url.user()); - CupsInfos::self()->setPassword(url.pass()); - CupsInfos::self()->setPort(url.port()); - IppRequest req; - TQString uri; - req.setOperation(CUPS_GET_PRINTERS); - uri = TQString::tqfromLatin1("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); - req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); - req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",TQString::tqfromLatin1("printer-name")); - if (req.doRequest("/printers/")) - { - ipp_attribute_t *attr = req.first(); - while (attr) - { - if (attr->name && strcmp(attr->name,"printer-name") == 0) - m_list->insertItem(SmallIcon("tdeprint_printer"),TQString::tqfromLatin1(attr->values[0].string.text)); - attr = attr->next; - } - m_list->sort(); - } - - // restore config - CupsInfos::self()->setHost(host); - CupsInfos::self()->setLogin(login); - CupsInfos::self()->setPassword(password); - CupsInfos::self()->setPort(port); -} - -void KMWIppSelect::updatePrinter(KMPrinter *p) -{ - KURL url = p->device(); - TQString path = m_list->currentText(); - path.prepend("/printers/"); - url.setPath(path); - p->setDevice(url.url()); -kdDebug(500) << url.url() << endl; -} diff --git a/kdeprint/cups/kmwippselect.h b/kdeprint/cups/kmwippselect.h deleted file mode 100644 index 8d1711e8c..000000000 --- a/kdeprint/cups/kmwippselect.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWIPPSELECT_H -#define KMWIPPSELECT_H - -#include "kmwizardpage.h" - -class KListBox; - -class KMWIppSelect : public KMWizardPage -{ -public: - KMWIppSelect(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -private: - KListBox *m_list; -}; - -#endif diff --git a/kdeprint/cups/kmwother.cpp b/kdeprint/cups/kmwother.cpp deleted file mode 100644 index 596f61990..000000000 --- a/kdeprint/cups/kmwother.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwother.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "kmmanager.h" -#include "cupsinfos.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqlineedit.h> -#include <tqheader.h> -#include <tqdict.h> - -#include <klocale.h> -#include <klistview.h> -#include <kiconloader.h> -#include <kdebug.h> - -KMWOther::KMWOther(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Custom+5; - m_title = i18n("URI Selection"); - m_nextpage = KMWizard::Driver; - - m_uri = new TQLineEdit(this); - TQLabel *l1 = new TQLabel(this); - l1->setText(i18n("<p>Enter the URI corresponding to the printer to be installed. " - "Examples:</p><ul>" - "<li>smb://[login[:passwd]@]server/printer</li>" - "<li>lpd://server/queue</li>" - "<li>parallel:/dev/lp0</li></ul>")); - TQLabel *l2 = new TQLabel(i18n("URI:"), this); - m_uriview = new KListView( this ); - m_uriview->addColumn( "" ); - m_uriview->header()->hide(); - m_uriview->setSorting( -1 ); - connect( m_uriview, TQT_SIGNAL( pressed( TQListViewItem* ) ), TQT_SLOT( slotPressed( TQListViewItem* ) ) ); - - TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 15); - TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 5); - lay1->addWidget(l1); - lay1->addLayout(lay2); - lay1->addWidget( m_uriview ); - lay2->addWidget(l2); - lay2->addWidget(m_uri); -} - -void KMWOther::initPrinter(KMPrinter *p) -{ - m_uri->setText(p->device()); - - if ( m_uriview->childCount() == 0 ) - { - TQStringList l = KMManager::self()->detectLocalPrinters(); - if ( l.isEmpty() || l.count() % 4 != 0 ) - return; - - TQListViewItem *item = 0, *lastparent = 0, *root; - root = new TQListViewItem( m_uriview, i18n( "CUPS Server %1:%2" ).arg( CupsInfos::self()->host() ).arg( CupsInfos::self()->port() ) ); - root->setPixmap( 0, SmallIcon( "gear" ) ); - root->setOpen( true ); - TQDict<TQListViewItem> parents, last; - parents.setAutoDelete( false ); - last.setAutoDelete( false ); - for ( TQStringList::Iterator it=l.begin(); it!=l.end(); ++it ) - { - TQString cl = *it; - TQString uri = *( ++it ); - TQString desc = *( ++it ); - TQString prt = *( ++it ); - if ( !prt.isEmpty() ) - desc.append( " [" + prt + "]" ); - TQListViewItem *parent = parents.find( cl ); - if ( !parent ) - { - parent = new TQListViewItem( root, lastparent, cl ); - parent->setOpen( true ); - if ( cl == "network" ) - parent->setPixmap( 0, SmallIcon( "network" ) ); - else if ( cl == "direct" ) - parent->setPixmap( 0, SmallIcon( "tdeprint_computer" ) ); - else if ( cl == "serial" ) - parent->setPixmap( 0, SmallIcon( "usb" ) ); - else - parent->setPixmap( 0, SmallIcon( "package" ) ); - lastparent = parent; - parents.insert( cl, parent ); - } - item = new TQListViewItem( parent, last.find( cl ), desc, uri); - last.insert( cl, item ); - } - } -} - -void KMWOther::updatePrinter(KMPrinter *p) -{ - p->setDevice( m_uri->text() ); -} - -void KMWOther::slotPressed( TQListViewItem *item ) -{ - if ( item && !item->text( 1 ).isEmpty() ) - m_uri->setText( item->text( 1 ) ); -} - -#include "kmwother.moc" diff --git a/kdeprint/cups/kmwother.h b/kdeprint/cups/kmwother.h deleted file mode 100644 index eba5ac2b1..000000000 --- a/kdeprint/cups/kmwother.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWOTHER_H -#define KMWOTHER_H - -#include "kmwizardpage.h" - -class TQLineEdit; -class KListView; -class TQListViewItem; - -class KMWOther : public KMWizardPage -{ - Q_OBJECT -public: - KMWOther(TQWidget *parent = 0, const char *name = 0); - - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -protected slots: - void slotPressed( TQListViewItem* ); - -private: - TQLineEdit *m_uri; - KListView *m_uriview; -}; - -#endif diff --git a/kdeprint/cups/kmwquota.cpp b/kdeprint/cups/kmwquota.cpp deleted file mode 100644 index 67245fb20..000000000 --- a/kdeprint/cups/kmwquota.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwquota.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqspinbox.h> -#include <tqlabel.h> -#include <tqcombobox.h> -#include <tqlayout.h> -#include <klocale.h> - -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif - -#define N_TIME_LIMITS 6 -static int time_periods[] = { - 1, // second - 60, // minute - 3600, // hour - 86400, // day - 604800, // week - 2592000 // month (30 days) -}; -static const char* time_keywords[] = { - I18N_NOOP("second(s)"), - I18N_NOOP("minute(s)"), - I18N_NOOP("hour(s)"), - I18N_NOOP("day(s)"), - I18N_NOOP("week(s)"), - I18N_NOOP("month(s)") -}; - -int findUnit(int& period) -{ - int unit(0); - for (int i=N_TIME_LIMITS-1;i>=0;i--) - { - if (period < time_periods[i]) - continue; - int d = period / time_periods[i]; - if ((d*time_periods[i]) == period) - { - unit = i; - break; - } - } - period /= time_periods[unit]; - return unit; -} - -const char* unitKeyword(int i) -{ return time_keywords[i]; } - -KMWQuota::KMWQuota(TQWidget *parent, const char *name) -: KMWizardPage(parent, name) -{ - m_ID = KMWizard::Custom+3; - m_title = i18n("Printer Quota Settings"); - m_nextpage = KMWizard::Custom+4; - - m_period = new TQSpinBox(this); - m_period->setRange(-1, INT_MAX); - m_period->setSpecialValueText(i18n("No quota")); - m_sizelimit = new TQSpinBox(this); - m_sizelimit->setRange(0, INT_MAX); - m_sizelimit->setSpecialValueText(i18n("None")); - m_pagelimit = new TQSpinBox(this); - m_pagelimit->setRange(0, INT_MAX); - m_pagelimit->setSpecialValueText(i18n("None")); - m_timeunit = new TQComboBox(this); - for (int i=0;i<N_TIME_LIMITS;i++) - m_timeunit->insertItem(i18n(time_keywords[i])); - m_timeunit->setCurrentItem(3); - - TQLabel *lab1 = new TQLabel(i18n("&Period:"), this); - TQLabel *lab2 = new TQLabel(i18n("&Size limit (KB):"), this); - TQLabel *lab3 = new TQLabel(i18n("&Page limit:"), this); - - lab1->setBuddy(m_period); - lab2->setBuddy(m_sizelimit); - lab3->setBuddy(m_pagelimit); - - TQLabel *lab4 = new TQLabel(i18n("<p>Set here the quota for this printer. Using limits of <b>0</b> means " - "that no quota will be used. This is equivalent to set quota period to " - "<b><nobr>No quota</nobr></b> (-1). Quota limits are defined on a per-user base and " - "applied to all users.</p>"), this); - - TQGridLayout *l0 = new TQGridLayout(this, 5, 3, 0, 10); - l0->setRowStretch(4, 1); - l0->setColStretch(1, 1); - l0->addMultiCellWidget(lab4, 0, 0, 0, 2); - l0->addWidget(lab1, 1, 0); - l0->addWidget(lab2, 2, 0); - l0->addWidget(lab3, 3, 0); - l0->addWidget(m_period, 1, 1); - l0->addWidget(m_timeunit, 1, 2); - l0->addMultiCellWidget(m_sizelimit, 2, 2, 1, 2); - l0->addMultiCellWidget(m_pagelimit, 3, 3, 1, 2); -} - -KMWQuota::~KMWQuota() -{ -} - -bool KMWQuota::isValid(TQString& msg) -{ - if (m_period->value() >= 0 && m_sizelimit->value() == 0 && m_pagelimit->value() == 0) - { - msg = i18n("You must specify at least one quota limit."); - return false; - } - return true; -} - -void KMWQuota::initPrinter(KMPrinter *p) -{ - int qu(-1), si(0), pa(0), un(3); - qu = p->option("job-quota-period").toInt(); - si = p->option("job-k-limit").toInt(); - pa = p->option("job-page-limit").toInt(); - if (si == 0 && pa == 0) - // no quota - qu = -1; - m_sizelimit->setValue(si); - m_pagelimit->setValue(pa); - if (qu > 0) - { - un = findUnit(qu); - } - m_timeunit->setCurrentItem(un); - m_period->setValue(qu); -} - -void KMWQuota::updatePrinter(KMPrinter *p) -{ - int qu(m_period->value()), si(m_sizelimit->value()), pa(m_pagelimit->value()); - if (qu == -1) - { - // no quota, set limits to 0 - si = 0; - pa = 0; - qu = 0; - } - qu *= time_periods[m_timeunit->currentItem()]; - - p->setOption("job-quota-period", TQString::number(qu)); - p->setOption("job-k-limit", TQString::number(si)); - p->setOption("job-page-limit", TQString::number(pa)); -} -#include "kmwquota.moc" diff --git a/kdeprint/cups/kmwquota.h b/kdeprint/cups/kmwquota.h deleted file mode 100644 index d8895c80d..000000000 --- a/kdeprint/cups/kmwquota.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWQUOTA_H -#define KMWQUOTA_H - -#include <kmwizardpage.h> - -class TQSpinBox; -class TQComboBox; - -class KMWQuota : public KMWizardPage -{ - Q_OBJECT -public: - KMWQuota(TQWidget *parent = 0, const char *name = 0); - virtual ~KMWQuota(); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -private: - TQSpinBox *m_period; - TQSpinBox *m_sizelimit; - TQSpinBox *m_pagelimit; - TQComboBox *m_timeunit; -}; - -#endif diff --git a/kdeprint/cups/kmwusers.cpp b/kdeprint/cups/kmwusers.cpp deleted file mode 100644 index 714f6f4d4..000000000 --- a/kdeprint/cups/kmwusers.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwusers.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqcombobox.h> -#include <klocale.h> -#include <keditlistbox.h> - -KMWUsers::KMWUsers(TQWidget *parent, const char *name) -: KMWizardPage(parent, name) -{ - m_ID = KMWizard::Custom+4; - m_title = i18n("Users Access Settings"); - m_nextpage = KMWizard::Name; - - m_users = new KEditListBox(i18n("Users"), this, 0, false, KEditListBox::Add|KEditListBox::Remove); - m_type = new TQComboBox(this); - m_type->insertItem(i18n("Allowed Users")); - m_type->insertItem(i18n("Denied Users")); - - TQLabel *lab1 = new TQLabel(i18n("Define here a group of allowed/denied users for this printer."), this); - TQLabel *lab2 = new TQLabel(i18n("&Type:"), this); - - lab2->setBuddy(m_type); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 10); - TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 10); - l0->addWidget(lab1, 0); - l0->addLayout(l1, 0); - l1->addWidget(lab2, 0); - l1->addWidget(m_type, 1); - l0->addWidget(m_users, 1); -} - -KMWUsers::~KMWUsers() -{ -} - -void KMWUsers::initPrinter(KMPrinter *p) -{ - TQStringList l; - int i(1); - if (!p->option("requesting-user-name-denied").isEmpty()) - { - l = TQStringList::split(",", p->option("requesting-user-name-denied"), false); - if (l.count() == 1 && l[0] == "none") - l.clear(); - } - else if (!p->option("requesting-user-name-allowed").isEmpty()) - { - i = 0; - l = TQStringList::split(",", p->option("requesting-user-name-allowed"), false); - if (l.count() && l[0] == "all") - l.clear(); - } - m_users->insertStringList(l); - m_type->setCurrentItem(i); -} - -void KMWUsers::updatePrinter(KMPrinter *p) -{ - p->removeOption("requesting-user-name-denied"); - p->removeOption("requesting-user-name-allowed"); - - TQString str; - if (m_users->count() > 0) - str = m_users->items().join(","); - else - str = (m_type->currentItem() == 0 ? "all" : "none"); - TQString optname = (m_type->currentItem() == 0 ? "requesting-user-name-allowed" : "requesting-user-name-denied"); - p->setOption(optname, str); -} -#include "kmwusers.moc" diff --git a/kdeprint/cups/kmwusers.h b/kdeprint/cups/kmwusers.h deleted file mode 100644 index cae8844a6..000000000 --- a/kdeprint/cups/kmwusers.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWUSERS_H -#define KMWUSERS_H - -#include <kmwizardpage.h> - -class KEditListBox; -class TQComboBox; - -class KMWUsers : public KMWizardPage -{ - Q_OBJECT -public: - KMWUsers(TQWidget *parent = 0, const char *name = 0); - virtual ~KMWUsers(); - - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -private: - KEditListBox *m_users; - TQComboBox *m_type; -}; - -#endif diff --git a/kdeprint/cups/kphpgl2page.cpp b/kdeprint/cups/kphpgl2page.cpp deleted file mode 100644 index 080cdf453..000000000 --- a/kdeprint/cups/kphpgl2page.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kphpgl2page.h" - -#include <tqcheckbox.h> -#include <tqgroupbox.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <klocale.h> -#include <knuminput.h> - -KPHpgl2Page::KPHpgl2Page(TQWidget *parent, const char *name) -: KPrintDialogPage(parent, name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisBlackplotHpgl2Page = i18n( " <qt> " - " <b>Print in Black Only (Blackplot)</b> " - " <p>The \'blackplot\' option specifies that all pens should plot in black-only:" - " The default is to use the colors defined in the plot file, or the standard " - " pen colors defined in the HP-GL/2 reference manual from Hewlett Packard. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o blackplot=true " - " </pre> " - " </p> " - " </qt>" ); - - TQString whatsThisFitplotHpgl2Page = i18n( " <qt> " - " <b>Scale Print Image to Page Size</b> " - " <p>The 'fitplot' option specifies that the HP-GL image should be scaled to fill " - " exactly the page with the (elsewhere selected) media size. </p> " - " <p>The default is 'fitplot is disabled'. The default will therefore use the absolute " - " distances specified in the plot file. (You should be aware that HP-GL files are very " - " often CAD drawings intended for large format plotters. On standard office printers " - " they will therefore lead to the drawing printout being spread across multiple pages.) </p> " - " <p><b>Note:</b>This feature depends upon an accurate plot size (PS) command in the " - " HP-GL/2 file. If no plot size is given in the file the filter converting the HP-GL " - " to PostScript assumes the plot is ANSI E size. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches with the CUPS commandline job option parameter:</em> " - " <pre> " - " -o fitplot=true " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPenwidthHpgl2Page = i18n( " <qt> " - " <b>Set Pen Width for HP-GL (if not defined in file)</b>. " - " <p>The pen width value can be set here in case the original HP-GL file does not have it " - " set. The pen width specifies the value in micrometers. The default value of 1000 produces " - " lines that are 1000 micrometers == 1 millimeter in width. Specifying a pen width of 0 " - " produces lines that are exactly 1 pixel wide. </p> " - " <p><b>Note:</b> The penwidth option set here is ignored if the pen widths are set inside " - " the plot file itself..</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o penwidth=... # example: \"2000\" or \"500\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisAllOptionsHpgl2Page = i18n( " <qt> " - " <b>HP-GL Print Options</b> " - " <p>All options on this page are only applicable if you use KDEPrint to send HP-GL and " - " HP-GL/2 files to one of your printers. </p> " - " <p>HP-GL and HP-GL/2 are page description languages developed by Hewlett-Packard to drive " - " Pen Plotting devices. </p> " - " <p>KDEPrint can (with the help of CUPS) convert the HP-GL file format and print it " - " on any installed printer. </p> " - " <p><b>Note 1:</b> To print HP-GL files, start 'kprinter' and simply load the file into " - " the running kprinter.</p>" - " <p><b>Note 2:</b> The 'fitplot' parameter provided on this dialog does also work for " - " printing PDF files (if your CUPS version is more recent than 1.1.22).</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> These KDEPrint GUI elements match with CUPS commandline job option parameters:</em> " - " <pre>" - " -o blackplot=... # examples: \"true\" or \"false\" " - " <br> " - " -o fitplot=... # examples: \"true\" or \"false\" " - " <br> " - " -o penwidth=... # examples: \"true\" or \"false\" " - " </pre>" - " </p> " - " </qt>" ); - - - setTitle("HP-GL/2"); - - TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("HP-GL/2 Options"), this); - - m_blackplot = new TQCheckBox(i18n("&Use only black pen"), box); - TQWhatsThis::add(m_blackplot, whatsThisBlackplotHpgl2Page); - - m_fitplot = new TQCheckBox(i18n("&Fit plot to page"), box); - TQWhatsThis::add(m_fitplot, whatsThisFitplotHpgl2Page); - - m_penwidth = new KIntNumInput(1000, box); - m_penwidth->setLabel(i18n("&Pen width:"), Qt::AlignLeft|Qt::AlignVCenter); - m_penwidth->setSuffix(" [um]"); - m_penwidth->setRange(0, 10000, 100, true); - TQWhatsThis::add(m_penwidth, whatsThisPenwidthHpgl2Page); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 10); - l0->addWidget(box); - l0->addStretch(1); - - TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), 10); - l1->addWidget(m_blackplot); - l1->addWidget(m_fitplot); - l1->addWidget(m_penwidth); - TQWhatsThis::add(this, whatsThisAllOptionsHpgl2Page); -} - -KPHpgl2Page::~KPHpgl2Page() -{ -} - -void KPHpgl2Page::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQString value; - if (opts.contains("blackplot") && ((value=opts["blackplot"]).isEmpty() || value == "true")) - m_blackplot->setChecked(true); - if (opts.contains("fitplot") && ((value=opts["fitplot"]).isEmpty() || value == "true")) - m_fitplot->setChecked(true); - if (!(value=opts["penwidth"]).isEmpty()) - m_penwidth->setValue(value.toInt()); -} - -void KPHpgl2Page::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - if (incldef || m_penwidth->value() != 1000) - opts["penwidth"] = TQString::number(m_penwidth->value()); - if (m_blackplot->isChecked()) - opts["blackplot"] = "true"; - else if (incldef) - opts["blackplot"] = "false"; - else - opts.remove("blackplot"); - if (m_fitplot->isChecked()) - opts["fitplot"] = "true"; - else if (incldef) - opts["fitplot"] = "false"; - else - opts.remove("fitplot"); -} diff --git a/kdeprint/cups/kphpgl2page.h b/kdeprint/cups/kphpgl2page.h deleted file mode 100644 index 397efb1a8..000000000 --- a/kdeprint/cups/kphpgl2page.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPHPGL2PAGE_H -#define KPHPGL2PAGE_H - -#include "kprintdialogpage.h" - -class KIntNumInput; -class TQCheckBox; - -class KPHpgl2Page : public KPrintDialogPage -{ -public: - KPHpgl2Page(TQWidget *parent = 0, const char *name = 0); - ~KPHpgl2Page(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -private: - KIntNumInput *m_penwidth; - TQCheckBox *m_blackplot, *m_fitplot; -}; - -#endif diff --git a/kdeprint/cups/kpimagepage.cpp b/kdeprint/cups/kpimagepage.cpp deleted file mode 100644 index d3e438389..000000000 --- a/kdeprint/cups/kpimagepage.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpimagepage.h" -#include "imageposition.h" -#include "imagepreview.h" -#include "driver.h" - -#include <tqcombobox.h> -#include <tqbuttongroup.h> -#include <tqradiobutton.h> -#include <tqgroupbox.h> -#include <tqpushbutton.h> -#include <tqapplication.h> -#include <tqimage.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <klocale.h> -#include <knuminput.h> -#include <kseparator.h> -#include <kstandarddirs.h> - -KPImagePage::KPImagePage(DrMain *driver, TQWidget *parent, const char *name) -: KPrintDialogPage(parent, name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisBrightnessImagePage = i18n( " <qt> " - " <p><b>Brightness:</b> Slider to control the brightness value of all colors used.</p>" - " <p> The brightness value can range from 0 to 200. Values greater than 100 will " - " lighten the print. Values less than 100 will darken the print. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o brightness=... # use range from \"0\" to \"200\" " - " </pre> " - " </p> " - " </qt>" ); - - TQString whatsThisHueImagePage = i18n( " <qt> " - " <p><b>Hue (Tint):</b> Slider to control the hue value for color rotation.</p>" - " <p> The hue value is a number from -360 to 360 and represents the color hue rotation. " - " The following table summarizes the change you will see for the base colors: " - " <center> " - " <table border=\"1\" width=\"70%\"> " - " <tr><th><b>Original</b></th> <th><b>hue=-45</b></th> <th><b>hue=45</b></th> </tr> " - " <tr><td>Red</td> <td>Purple</td> <td>Yellow-orange</td> </tr> " - " <tr><td>Green</td> <td>Yellow-green</td> <td>Blue-green</td> </tr> " - " <tr><td>Yellow</td> <td>Orange</td> <td>Green-yellow</td> </tr> " - " <tr><td>Blue</td> <td>Sky-blue</td> <td>Purple</td> </tr> " - " <tr><td>Magenta</td> <td>Indigo</td> <td>Crimson</td> </tr> " - " <tr><td>Cyan</td> <td>Blue-green</td> <td>Light-navy-blue</td> </tr> " - " </table> " - " </center> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o hue=... # use range from \"-360\" to \"360\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisSaturationImagePage = i18n( " <qt> " - " <p><b>Saturation:</b> Slider to control the saturation value for all colors used.</p>" - " <p> The saturation value adjusts the saturation of the colors in an image, similar to " - " the color knob on your television. The color saturation value.can range from 0 to 200." - " On inkjet printers, a higher saturation value uses more ink. On laserjet printers, a " - " higher saturation uses more toner. " - " A color saturation of 0 produces a black-and-white print, while a value of 200 will " - " make the colors extremely intense. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o saturation=... # use range from \"0\" to \"200\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisGammaImagePage = i18n( " <qt> " - " <p><b>Gamma:</b> Slider to control the gamma value for color correction.</p>" - " <p> The gamma value can range from 1 to 3000. " - " A gamma values greater than 1000 lightens the print. A gamma value less than 1000 " - " darken the print. The default gamma is 1000. </p>" - " <p><b>Note:</b></p> the gamma value adjustment is not visible in the thumbnail " - " preview. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o gamma=... # use range from \"1\" to \"3000\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisImagePage = i18n( " <qt> " - " <p><b>Image Printing Options</b></p> " - " <p>All options controlled on this page only apply to printing images. " - " Most image file formats are supported. To name a few: JPEG, TIFF, PNG, GIF, " - " PNM (PBM/PGM/PNM/PPM), Sun Raster, SGI RGB, Windows BMP." - " Options to influence color output of image printouts are: " - " <ul> " - " <li> Brightness </li>" - " <li> Hue </li>" - " <li> Saturation </li>" - " <li> Gamma </li>" - " </ul> " - " <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please " - " look at the 'WhatsThis' items provided for these controls. " - " </p> " - " </p> " - " </qt>" ); - - TQString whatsThisColorationPreviewImagePage = i18n( " <qt> " - " <p><b>Coloration Preview Thumbnail</b></p> " - " <p>The coloration preview thumbnail indicates change of image coloration by different settings. " - " Options to influence output are: " - " <ul> " - " <li> Brightness </li>" - " <li> Hue (Tint) </li>" - " <li> Saturation </li>" - " <li> Gamma </li>" - " </ul> " - " </p> " - " <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please " - " look at the 'WhatsThis' items provided for these controls. " - " </p> " - " </qt>" ); - - TQString whatsThisSizeImagePage = i18n( " <qt> " - " <p><b>Image Size:</b> Dropdown menu to control the image size on the printed paper. Dropdown " - " works in conjunction with slider below. Dropdown options are:.</p>" - " <ul> " - " <li> <b>Natural Image Size:</b> Image prints in its natural image size. If it does not fit onto " - " one sheet, the printout will be spread across multiple sheets. Note, that the slider is disabled " - " when selecting 'natural image size' in the dropdown menu. </li>" - " <li> <b>Resolution (ppi):</b> The resolution value slider covers a number range from 1 to 1200. " - " It specifies the resolution of the image in Pixels Per Inch (PPI). An image that is 3000x2400 pixels " - " will print 10x8 inches at 300 pixels per inch, for example, but 5x4 inches at 600 pixels per inch." - " If the specified resolution makes the image larger than the page, multiple pages will be printed. " - " Resolution defaults to 72 ppi. " - " </li>" - " <li> <b>% of Page Size:</b> The percent value slider covers numbers from 1 to 800. It specifies the size " - " in relation to the page (not the image). A scaling of 100 percent will fill the page as completely " - " as the image aspect ratio allows (doing auto-rotation of the image as needed). " - " A scaling of more than 100 will print the image across multiple " - " sheets. A scaling of 200 percent will print on up to 4 pages. </li>" - " Scaling in % of page size defaults to 100 %. " - " <li> <b>% of Natural Image Size:</b> The percent value slider moves from 1 to 800. It specifies " - " the printout size in relation " - " to the natural image size. A scaling of 100 percent will print the image at its natural size, while a " - " scaling of 50 percent will print the image at half its natural size. If the specified scaling makes " - " the image larger than the page, multiple pages will be printed. " - " Scaling in % of natural image size defaults to 100 %. " - " </ul> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o natural-scaling=... # range in % is 1....800 " - " <br> " - " -o scaling=... # range in % is 1....800 " - " <br> " - " -o ppi=... # range in ppi is 1...1200 " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPreviewPositionImagePage = i18n( " <qt> " - " <p><b>Position Preview Thumbnail</b></p> " - " <p>This position preview thumbnail indicates the position of the image on the paper sheet. " - " <p>Click on horizontal and vertical radio buttons to move image tqalignment on paper around. Options are: " - " <ul> " - " <li> center </li>" - " <li> top </li>" - " <li> top-left </li>" - " <li> left </li>" - " <li> bottom-left </li>" - " <li> bottom </li>" - " <li> bottom-right</li>" - " <li> right </li>" - " <li> top-right </li>" - " </ul> " - " </p> " - " </qt>" ); - - TQString whatsThisResetButtonImagePage = i18n( " <qt> " - " <p><b>Reset to Default Values</b> </p> " - " <p> Reset all coloration settings to default values. Default values are: " - " <ul> " - " <li> Brightness: 100 </li>" - " <li> Hue (Tint). 0 </li>" - " <li> Saturation: 100 </li>" - " <li> Gamma: 1000 </li>" - " </ul> " - " </p> " - " </qt>" ); - - TQString whatsThisPositionImagePage = i18n( " <qt> " - " <p><b>Image Positioning:</b></p> " - " <p>Select a pair of radiobuttons to " - " move image to the position you want on the paper printout. Default " - " is 'center'. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o position=... # examples: \"top-left\" or \"bottom\" " - " </pre>" - " </p> " - " </qt>" ); - - setTitle(i18n("Image")); - - TQGroupBox *colorbox = new TQGroupBox(0, Qt::Vertical, i18n("Color Settings"), this); - TQWhatsThis::add(this, whatsThisImagePage); - TQGroupBox *sizebox = new TQGroupBox(0, Qt::Vertical, i18n("Image Size"), this); - TQWhatsThis::add(sizebox, whatsThisSizeImagePage); - TQGroupBox *positionbox = new TQGroupBox(0, Qt::Vertical, i18n("Image Position"), this); - TQWhatsThis::add(positionbox, whatsThisPositionImagePage); - - m_brightness = new KIntNumInput(100, colorbox); - m_brightness->setLabel(i18n("&Brightness:")); - m_brightness->setRange(0, 200, 20, true); - TQWhatsThis::add(m_brightness, whatsThisBrightnessImagePage); - - m_hue = new KIntNumInput(m_brightness, 0, colorbox); - m_hue->setLabel(i18n("&Hue (Color rotation):")); - m_hue->setRange(-360, 360, 36, true); - TQWhatsThis::add(m_hue, whatsThisHueImagePage); - - m_saturation = new KIntNumInput(m_brightness, 100, colorbox); - m_saturation->setLabel(i18n("&Saturation:")); - m_saturation->setRange(0, 200, 20, true); - TQWhatsThis::add(m_saturation, whatsThisSaturationImagePage); - - m_gamma = new KIntNumInput(m_saturation, 1000, colorbox); - m_gamma->setLabel(i18n("&Gamma (Color correction):")); - m_gamma->setRange(1, 3000, 100, true); - TQWhatsThis::add(m_gamma, whatsThisGammaImagePage); - - connect(m_brightness, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotImageSettingsChanged())); - connect(m_hue, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotImageSettingsChanged())); - connect(m_saturation, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotImageSettingsChanged())); - //connect(m_gamma, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotImageSettingsChanged())); - - m_preview = new ImagePreview(colorbox); - bool useColor = (driver ? driver->get("colordevice") == "1" : true); - m_preview->setBlackAndWhite(!useColor); - TQWhatsThis::add(m_preview, whatsThisColorationPreviewImagePage); - - m_hue->setEnabled(useColor); - m_saturation->setEnabled(useColor); - TQImage img(locate("data", "tdeprint/preview.png")); - m_preview->setImage(img); - - KSeparator *sep = new KSeparator(Qt::Horizontal, colorbox); - - TQPushButton *defbtn = new TQPushButton(i18n("&Default Settings"), colorbox); - TQWhatsThis::add(defbtn, whatsThisResetButtonImagePage); - connect(defbtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotDefaultClicked())); - slotDefaultClicked(); - - m_sizetype = new TQComboBox(sizebox); - m_sizetype->insertItem(i18n("Natural Image Size")); - m_sizetype->insertItem(i18n("Resolution (ppi)")); - // xgettext:no-c-format - m_sizetype->insertItem(i18n("% of Page")); - // xgettext:no-c-format - m_sizetype->insertItem(i18n("% of Natural Image Size")); - - m_size = new KIntNumInput(sizebox); - m_size->setRange(1, 1200, 20, true); - m_size->setValue(72); - - connect(m_sizetype, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSizeTypeChanged(int))); - m_sizetype->setCurrentItem(0); - slotSizeTypeChanged(0); - - TQLabel *lab = new TQLabel(i18n("&Image size type:"), sizebox); - lab->setBuddy(m_sizetype); - - m_position = new ImagePosition(positionbox); - TQWhatsThis::add(m_position, whatsThisPreviewPositionImagePage); - - TQRadioButton *bottom = new TQRadioButton(positionbox); - TQRadioButton *top = new TQRadioButton(positionbox); - TQRadioButton *vcenter = new TQRadioButton(positionbox); - TQRadioButton *left = new TQRadioButton(positionbox); - TQRadioButton *right = new TQRadioButton(positionbox); - TQRadioButton *hcenter = new TQRadioButton(positionbox); - TQSize sz = bottom->tqsizeHint(); - bottom->setFixedSize(sz); - vcenter->setFixedSize(sz); - top->setFixedSize(sz); - left->setFixedSize(sz); - hcenter->setFixedSize(sz); - right->setFixedSize(sz); - - m_vertgrp = new TQButtonGroup(positionbox); - m_vertgrp->hide(); - - m_horizgrp = new TQButtonGroup(positionbox); - m_horizgrp->hide(); - - m_vertgrp->insert(top, 0); - m_vertgrp->insert(vcenter, 1); - m_vertgrp->insert(bottom, 2); - if ( TQApplication::reverseLayout() ) - { - m_horizgrp->insert(left, 2); - m_horizgrp->insert(hcenter, 1); - m_horizgrp->insert(right, 0); - } - else - { - m_horizgrp->insert(left, 0); - m_horizgrp->insert(hcenter, 1); - m_horizgrp->insert(right, 2); - } - connect(m_vertgrp, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotPositionChanged())); - connect(m_horizgrp, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotPositionChanged())); - m_vertgrp->setButton(1); - m_horizgrp->setButton(1); - slotPositionChanged(); - - TQGridLayout *l0 = new TQGridLayout(this, 2, 2, 0, 10); - l0->addMultiCellWidget(colorbox, 0, 0, 0, 1); - l0->addWidget(sizebox, 1, 0); - l0->addWidget(positionbox, 1, 1); - l0->setColStretch(0, 1); - TQGridLayout *l1 = new TQGridLayout(colorbox->tqlayout(), 5, 2, 10); - l1->addWidget(m_brightness, 0, 0); - l1->addWidget(m_hue, 1, 0); - l1->addWidget(m_saturation, 2, 0); - l1->addWidget(sep, 3, 0); - l1->addWidget(m_gamma, 4, 0); - l1->addMultiCellWidget(m_preview, 0, 3, 1, 1); - l1->addWidget(defbtn, 4, 1); - TQVBoxLayout *l2 = new TQVBoxLayout(TQT_TQLAYOUT(sizebox->tqlayout()), 3); - l2->addStretch(1); - l2->addWidget(lab); - l2->addWidget(m_sizetype); - l2->addSpacing(10); - l2->addWidget(m_size); - l2->addStretch(1); - TQGridLayout *l3 = new TQGridLayout(positionbox->tqlayout(), 2, 2, 10); - TQHBoxLayout *l4 = new TQHBoxLayout(0, 0, 10); - TQVBoxLayout *l5 = new TQVBoxLayout(0, 0, 10); - l3->addLayout(l4, 0, 1); - l3->addLayout(l5, 1, 0); - l3->addWidget(m_position, 1, 1); - l4->addWidget(left, Qt::AlignLeft); - l4->addWidget(hcenter, Qt::AlignCenter); - l4->addWidget(right, Qt::AlignRight); - l5->addWidget(top, Qt::AlignTop); - l5->addWidget(vcenter, Qt::AlignVCenter); - l5->addWidget(bottom, Qt::AlignBottom); -} - -KPImagePage::~KPImagePage() -{ -} - -void KPImagePage::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQString value; - if (!(value=opts["brightness"]).isEmpty()) - m_brightness->setValue(value.toInt()); - if (!(value=opts["hue"]).isEmpty()) - m_hue->setValue(value.toInt()); - if (!(value=opts["saturation"]).isEmpty()) - m_saturation->setValue(value.toInt()); - if (!(value=opts["gamma"]).isEmpty()) - m_gamma->setValue(value.toInt()); - - int type = 0; - int ival(0); - if ((ival = opts["ppi"].toInt()) != 0) - type = 1; - else if ((ival = opts["scaling"].toInt()) != 0) - type = 2; - else if (!opts["natural-scaling"].isEmpty() && (ival = opts["natural-scaling"].toInt()) != 1) - type = 3; - m_sizetype->setCurrentItem(type); - slotSizeTypeChanged(type); - if (type != 0) - m_size->setValue(ival); - - if (!(value=opts["position"]).isEmpty()) - { - m_position->setPosition(value.latin1()); - int pos = m_position->position(); - m_vertgrp->setButton(pos/3); - m_horizgrp->setButton(pos%3); - } -} - -void KPImagePage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - if (incldef || m_brightness->value() != 100) - opts["brightness"] = TQString::number(m_brightness->value()); - if (m_hue->isEnabled()) - { - if (incldef || m_hue->value() != 0) - opts["hue"] = TQString::number(m_hue->value()); - if (incldef || m_saturation->value() != 100) - opts["saturation"] = TQString::number(m_saturation->value()); - } - if (incldef || m_gamma->value() != 1000) - opts["gamma"] = TQString::number(m_gamma->value()); - - TQString name; - if (incldef) - { - opts["ppi"] = "0"; - opts["scaling"] = "0"; - opts["natural-scaling"] = "1"; - } - switch (m_sizetype->currentItem()) - { - case 0: break; - case 1: name = "ppi"; break; - case 2: name = "scaling"; break; - case 3: name = "natural-scaling"; break; - } - if (!name.isEmpty()) - opts[name] = TQString::number(m_size->value()); - - if (incldef || m_position->position() != ImagePosition::Center) - opts["position"] = m_position->positionString(); -} - -void KPImagePage::slotSizeTypeChanged(int t) -{ - m_size->setEnabled(t > 0); - if (t > 0) - { - int minval, maxval, defval; - if (t == 1) - { - minval = 1; - maxval = 1200; - defval = 72; - } - else - { - minval = 1; - maxval = 800; - defval = 100; - } - m_size->setRange(minval, maxval); - m_size->setValue(defval); - } -} - -void KPImagePage::slotPositionChanged() -{ - int h = m_horizgrp->id(m_horizgrp->selected()), v = m_vertgrp->id(m_vertgrp->selected()); - m_position->setPosition(h, v); -} - -void KPImagePage::slotImageSettingsChanged() -{ - int b = m_brightness->value(), h = m_hue->value(), s = m_saturation->value(); - //int g = m_gamma->value(); - int g = 1000; - m_preview->setParameters(b, h, s, g); -} - -void KPImagePage::slotDefaultClicked() -{ - m_brightness->setValue(100); - m_hue->setValue(0); - m_saturation->setValue(100); - m_gamma->setValue(1000); -} - -#include "kpimagepage.moc" diff --git a/kdeprint/cups/kpimagepage.h b/kdeprint/cups/kpimagepage.h deleted file mode 100644 index 1a6bc6e44..000000000 --- a/kdeprint/cups/kpimagepage.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPIMAGEPAGE_H -#define KPIMAGEPAGE_H - -#include "kprintdialogpage.h" - -class KIntNumInput; -class TQComboBox; -class TQButtonGroup; -class ImagePreview; -class ImagePosition; - -class KPImagePage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPImagePage(DrMain *driver = 0, TQWidget *parent = 0, const char *name = 0); - ~KPImagePage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected slots: - void slotSizeTypeChanged(int); - void slotPositionChanged(); - void slotImageSettingsChanged(); - void slotDefaultClicked(); - -private: - KIntNumInput *m_brightness, *m_hue, *m_saturation, *m_gamma; - TQComboBox *m_sizetype; - KIntNumInput *m_size; - TQButtonGroup *m_vertgrp, *m_horizgrp; - ImagePreview *m_preview; - ImagePosition *m_position; -}; - -#endif diff --git a/kdeprint/cups/kpschedulepage.cpp b/kdeprint/cups/kpschedulepage.cpp deleted file mode 100644 index 4d8bab4d1..000000000 --- a/kdeprint/cups/kpschedulepage.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpschedulepage.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqcombobox.h> -#include <tqregexp.h> -#include <tqdatetimeedit.h> -#include <tqdatetime.h> -#include <tqlineedit.h> -#include <tqwhatsthis.h> -#include <klocale.h> -#include <kseparator.h> -#include <knuminput.h> - -#include <time.h> - -KPSchedulePage::KPSchedulePage(TQWidget *parent, const char *name) -: KPrintDialogPage(parent, name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisBillingInfo = i18n( " <qt> <p><b>Print Job Billing and Accounting</b></p> " - " <p>Insert a meaningful string here to associate" - " the current print job with a certain account. This" - " string will appear in the CUPS \"page_log\" to help" - " with the print accounting in your organization. (Leave" - " it empty if you do not need it.)" - " <p> It is useful for people" - " who print on behalf of different \"customers\", like" - " print service bureaux, letter shops, press and prepress" - " companies, or secretaries who serve different bosses, etc.</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o job-billing=... # example: \"Marketing_Department\" or \"Joe_Doe\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisScheduledPrinting = i18n(" <qt> <p><b>Scheduled Printing</b></p> " - " <p>Scheduled printing lets you control the time" - " of the actual printout, while you can still send away your" - " job <b>now</b> and have it out of your way." - " <p> Especially useful" - " is the \"Never (hold indefinitely)\" option. It allows you" - " to park your job until a time when you (or a printer administrator)" - " decides to manually release it." - " <p> This is often required in" - " enterprise environments, where you normally are not" - " allowed to directly and immediately access the huge production" - " printers in your <em>Central Repro Department</em>. However it" - " is okay to send jobs to the queue which is under the control of the" - " operators (who, after all, need to make sure that the 10,000" - " sheets of pink paper which is required by the Marketing" - " Department for a particular job are available and loaded" - " into the paper trays).</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o job-hold-until=... # example: \"indefinite\" or \"no-hold\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPageLabel = i18n( " <qt> <p><b>Page Labels</b></p> " - " <p>Page Labels are printed by CUPS at the top and bottom" - " of each page. They appear on the pages surrounded by a little" - " frame box." - " <p>They contain any string you type into the line edit field.</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-label=\"...\" # example: \"Company Confidential\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisJobPriority = i18n( " <qt> <p><b>Job Priority</b></p> " - " <p>Usually CUPS prints all jobs per queue according to" - " the \"FIFO\" principle: <em>First In, First Out</em>." - " <p> The" - " job priority option allows you to re-order the queue according" - " to your needs." - " <p> It works in both directions: you can increase" - " as well as decrease priorities. (Usually you can only control" - " your <b>own</b> jobs)." - " <p> Since the default job priority is \"50\", any job sent" - " with, for example, \"49\" will be printed only after all those" - " others have finished. Conversely, a" - " \"51\" or higher priority job will go right to the top of" - " a populated queue (if no other, higher prioritized one is present).</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o job-priority=... # example: \"10\" or \"66\" or \"99\" " - " </pre>" - " </p> " - " </qt>" ); - - setTitle(i18n("Advanced Options")); - setOnlyRealPrinters(true); - - // compute difference in hours between GMT and local time - time_t ct = time(0); - struct tm *ts = gmtime(&ct); - m_gmtdiff = ts->tm_hour; - ts = localtime(&ct); - m_gmtdiff -= ts->tm_hour; - - m_time = new TQComboBox(this); - m_time->insertItem(i18n("Immediately")); - m_time->insertItem(i18n("Never (hold indefinitely)")); - m_time->insertItem(i18n("Daytime (6 am - 6 pm)")); - m_time->insertItem(i18n("Evening (6 pm - 6 am)")); - m_time->insertItem(i18n("Night (6 pm - 6 am)")); - m_time->insertItem(i18n("Weekend")); - m_time->insertItem(i18n("Second Shift (4 pm - 12 am)")); - m_time->insertItem(i18n("Third Shift (12 am - 8 am)")); - m_time->insertItem(i18n("Specified Time")); - TQWhatsThis::add(m_time, whatsThisScheduledPrinting); - m_tedit = new TQTimeEdit(this); - m_tedit->setAutoAdvance(true); - m_tedit->setTime(TQTime::currentTime()); - m_tedit->setEnabled(false); - TQWhatsThis::add(m_tedit, whatsThisScheduledPrinting); - m_billing = new TQLineEdit(this); - TQWhatsThis::add(m_billing, whatsThisBillingInfo); - m_pagelabel = new TQLineEdit(this); - TQWhatsThis::add(m_pagelabel, whatsThisPageLabel); - m_priority = new KIntNumInput(50, this); - TQWhatsThis::add(m_priority, whatsThisJobPriority); - m_priority->setRange(1, 100, 10, true); - - TQLabel *lab = new TQLabel(i18n("&Scheduled printing:"), this); - lab->setBuddy(m_time); - TQWhatsThis::add(lab, whatsThisScheduledPrinting); - TQLabel *lab1 = new TQLabel(i18n("&Billing information:"), this); - TQWhatsThis::add(lab1, whatsThisBillingInfo); - lab1->setBuddy(m_billing); - TQLabel *lab2 = new TQLabel(i18n("T&op/Bottom page label:"), this); - TQWhatsThis::add(lab2, whatsThisPageLabel); - lab2->setBuddy(m_pagelabel); - m_priority->setLabel(i18n("&Job priority:"), Qt::AlignVCenter|Qt::AlignLeft); - TQWhatsThis::add(m_priority, whatsThisJobPriority); - - KSeparator *sep0 = new KSeparator(this); - sep0->setFixedHeight(10); - - TQGridLayout *l0 = new TQGridLayout(this, 6, 2, 0, 7); - l0->addWidget(lab, 0, 0); - TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 5); - l0->addLayout(l1, 0, 1); - l1->addWidget(m_time); - l1->addWidget(m_tedit); - l0->addWidget(lab1, 1, 0); - l0->addWidget(lab2, 2, 0); - l0->addWidget(m_billing, 1, 1); - l0->addWidget(m_pagelabel, 2, 1); - l0->addMultiCellWidget(sep0, 3, 3, 0, 1); - l0->addMultiCellWidget(m_priority, 4, 4, 0, 1); - l0->setRowStretch(5, 1); - - connect(m_time, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTimeChanged())); -} - -KPSchedulePage::~KPSchedulePage() -{ -} - -bool KPSchedulePage::isValid(TQString& msg) -{ - if (m_time->currentItem() == 8 && !m_tedit->time().isValid()) - { - msg = i18n("The time specified is not valid."); - return false; - } - return true; -} - -void KPSchedulePage::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQString t = opts["job-hold-until"]; - if (!t.isEmpty()) - { - int item(-1); - - if (t == "no-hold") item = 0; - else if (t == "indefinite") item = 1; - else if (t == "day-time") item = 2; - else if (t == "evening") item = 3; - else if (t == "night") item = 4; - else if (t == "weekend") item = 5; - else if (t == "second-shift") item = 6; - else if (t == "third-shift") item = 7; - else - { - TQTime qt = TQT_TQTIME_OBJECT(TQTime::fromString(t)); - m_tedit->setTime(TQT_TQTIME_OBJECT(qt.addSecs(-3600 * m_gmtdiff))); - item = 8; - } - - if (item != -1) - { - m_time->setCurrentItem(item); - slotTimeChanged(); - } - } - TQRegExp re("^\"|\"$"); - t = opts["job-billing"].stripWhiteSpace(); - t.replace(re, ""); - m_billing->setText(t); - t = opts["page-label"].stripWhiteSpace(); - t.replace(re, ""); - m_pagelabel->setText(t); - int val = opts["job-priority"].toInt(); - if (val != 0) - m_priority->setValue(val); -} - -void KPSchedulePage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - if (incldef || m_time->currentItem() != 0) - { - TQString t; - switch (m_time->currentItem()) - { - case 0: t = "no-hold"; break; - case 1: t = "indefinite"; break; - case 2: t = "day-time"; break; - case 3: t = "evening"; break; - case 4: t = "night"; break; - case 5: t = "weekend"; break; - case 6: t = "second-shift"; break; - case 7: t = "third-shift"; break; - case 8: - t = m_tedit->time().addSecs(3600 * m_gmtdiff).toString(); - break; - } - opts["job-hold-until"] = t; - } - if (incldef || !m_billing->text().isEmpty()) - opts["job-billing"] = "\"" + m_billing->text() + "\""; - if (incldef || !m_pagelabel->text().isEmpty()) - opts["page-label"] = "\"" + m_pagelabel->text() + "\""; - if (incldef || m_priority->value() != 50) - opts["job-priority"] = TQString::number(m_priority->value()); -} - -void KPSchedulePage::slotTimeChanged() -{ - m_tedit->setEnabled(m_time->currentItem() == 8); - if (m_time->currentItem() == 8) - m_tedit->setFocus(); -} - -#include "kpschedulepage.moc" diff --git a/kdeprint/cups/kpschedulepage.h b/kdeprint/cups/kpschedulepage.h deleted file mode 100644 index 4be11fab9..000000000 --- a/kdeprint/cups/kpschedulepage.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPSCHEDULEPAGE_H -#define KPSCHEDULEPAGE_H - -#include <kprintdialogpage.h> - -class TQComboBox; -class TQTimeEdit; -class TQLineEdit; -class KIntNumInput; - -class KPSchedulePage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPSchedulePage(TQWidget *parent = 0, const char *name = 0); - ~KPSchedulePage(); - - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - void setOptions(const TQMap<TQString,TQString>& opts); - bool isValid(TQString& msg); - -protected slots: - void slotTimeChanged(); - -private: - TQComboBox *m_time; - TQTimeEdit *m_tedit; - TQLineEdit *m_billing, *m_pagelabel; - KIntNumInput *m_priority; - int m_gmtdiff; -}; - -#endif diff --git a/kdeprint/cups/kptagspage.cpp b/kdeprint/cups/kptagspage.cpp deleted file mode 100644 index d91a8b427..000000000 --- a/kdeprint/cups/kptagspage.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kptagspage.h" - -#include <tqtable.h> -#include <tqheader.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqregexp.h> -#include <tqwhatsthis.h> - -#include <klocale.h> - -KPTagsPage::KPTagsPage(bool ro, TQWidget *parent, const char *name) -: KPrintDialogPage(parent, name) -{ - - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisAdditionalTagsTable = i18n(" <qt><p><b>Additional Tags</b></p>" - " You may send additional commands to the CUPS server via this editable list. " - " There are 3 purposes for this:" - " <ul>" - " <li>Use any current or future standard CUPS job option not supported by the " - " KDEPrint GUI. </li>" - " <li>Control any custom job option you may want to support in custom CUPS filters " - " and backends plugged into the CUPS filtering chain.</li> " - " <li>Send short messages to the operators of your production printers in your " - " <em>Central Repro Department</em>." - " </ul> " - " <p><b>Standard CUPS job options:</b> A complete list of standard CUPS job " - " options is in the <a href=\"http://localhost:631/sum.html\">CUPS User Manual</a>. " - " Mappings of the kprinter user interface widgets to respective CUPS job option " - " names are named in the various <em>WhatsThis</em> help items..</p>" - " <p><b>Custom CUPS job options:</b> CUPS print servers may be customized with additional " - " print filters and backends which understand custom job options. You can specify such " - " custom job options here. If in doubt, ask your system administrator..</p>" - " <p><b> </b></p>" - " <p><b>Operator Messages:</b> You may send additional messages to the operator(s) of your" - " production printers (e.g. in your <em>Central Repro Department</p>)" - " Messages can be read by the operator(s) (or yourself) by viewing" - " the <em>\"Job IPP Report\"</em> for the job.</p>" - " <b>Examples:</b><br>" - " <pre>" - " A standard CUPS job option:<br> " - " <em>(Name) number-up</em> -- <em>(Value) 9</em> <br>" - " <br>" - " A job option for custom CUPS filters or backends:<br> " - " <em>(Name) DANKA_watermark</em> -- <em>(Value) Company_Confidential</em> <br>" - " <br>" - " A message to the operator(s):<br> " - " <em>(Name) Deliver_after_completion</em> -- <em>(Value) to_Marketing_Departm.</em><br>" - " </pre>" - " <p><b>Note:</b> the fields must not include spaces, tabs or quotes. You may need to " - " double-click on a field to edit it." - " <p><b>Warning:</b> Do not use such standard CUPS option names which also can be used " - " through the KDEPrint GUI. Results may be unpredictable if they conflict, " - " or if they are sent multiple times. For all options supported by the GUI, please do use " - " the GUI. (Each GUI element's 'WhatsThis' names the related CUPS option name.) </p> " - " </qt>" ); - setTitle(i18n("Additional Tags")); - setOnlyRealPrinters(true); - - m_tags = new TQTable(10, 2, this); - m_tags->horizontalHeader()->setStretchEnabled(true); - m_tags->horizontalHeader()->setLabel(0, i18n("Name")); - m_tags->horizontalHeader()->setLabel(1, i18n("Value")); - m_tags->setReadOnly(ro); - TQWhatsThis::add(m_tags, whatsThisAdditionalTagsTable); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 5); - l0->addWidget(m_tags); - - if (ro) - { - TQLabel *lab = new TQLabel(i18n("Read-Only"), this); - TQFont f = lab->font(); - f.setBold(true); - lab->setFont(f); - lab->tqsetAlignment(AlignVCenter|AlignRight); - l0->addWidget(lab); - } -} - -KPTagsPage::~KPTagsPage() -{ -} - -bool KPTagsPage::isValid(TQString& msg) -{ - TQRegExp re("\\s"); - for (int r=0; r<m_tags->numCols(); r++) - { - TQString tag(m_tags->text(r, 0)); - if (tag.isEmpty()) - continue; - else if (tag.find(re) != -1) - { - msg = i18n("The tag name must not contain any spaces, tabs or quotes: <b>%1</b>.").arg(tag); - return false; - } - } - return true; -} - -void KPTagsPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - int r(0); - TQRegExp re("^\"|\"$"); - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end() && r<m_tags->numRows(); ++it) - { - if (it.key().startsWith("KDEPrint-")) - { - m_tags->setText(r, 0, it.key().mid(9)); - TQString data = it.data(); - m_tags->setText(r, 1, data.replace(re, "")); - r++; - } - } - for (; r<m_tags->numRows(); r++) - { - m_tags->setText(r, 0, TQString::null); - m_tags->setText(r, 1, TQString::null); - } -} - -void KPTagsPage::getOptions(TQMap<TQString,TQString>& opts, bool) -{ - for (int r=0; r<m_tags->numRows(); r++) - { - TQString tag(m_tags->text(r, 0)), val(m_tags->text(r, 1)); - if (!tag.isEmpty()) - { - tag.prepend("KDEPrint-"); - opts[tag] = val.prepend("\"").append("\""); - } - } -} - -TQSize KPTagsPage::tqsizeHint() const -{ - return TQSize(-1, -1); -} - -TQSize KPTagsPage::tqminimumSizeHint() const -{ - return TQSize(-1, -1); -} diff --git a/kdeprint/cups/kptagspage.h b/kdeprint/cups/kptagspage.h deleted file mode 100644 index ac99072ec..000000000 --- a/kdeprint/cups/kptagspage.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPTAGSPAGE_H -#define KPTAGSPAGE_H - -#include <kprintdialogpage.h> - -class TQTable; - -class KPTagsPage : public KPrintDialogPage -{ -public: - KPTagsPage(bool ro = false, TQWidget *parent = 0, const char *name = 0); - ~KPTagsPage(); - - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - void setOptions(const TQMap<TQString,TQString>& opts); - bool isValid(TQString& msg); - - TQSize tqsizeHint() const; - TQSize tqminimumSizeHint() const; - -private: - TQTable *m_tags; -}; - -#endif diff --git a/kdeprint/cups/kptextpage.cpp b/kdeprint/cups/kptextpage.cpp deleted file mode 100644 index 0bee387c6..000000000 --- a/kdeprint/cups/kptextpage.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kptextpage.h" -#include "marginwidget.h" -#include "driver.h" -#include "kprinter.h" - -#include <tqbuttongroup.h> -#include <tqgroupbox.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqradiobutton.h> -#include <tqwhatsthis.h> -#include <knuminput.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kseparator.h> -#include <kdebug.h> - -KPTextPage::KPTextPage(DrMain *driver, TQWidget *parent, const char *name) -: KPrintDialogPage(0, driver, parent, name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisCPITextPage = i18n( " <qt> " - " <p><b>Characters Per Inch</b></p> " - " <p>This setting controls the horizontal size of characters when printing a text file. </p>" - " <p>The default value is 10, meaning that the font is scaled in a way that 10 characters " - " per inch will be printed. </p> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o cpi=... # example: \"8\" or \"12\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisLPITextPage = i18n( " <qt> " - " <p><b>Lines Per Inch</b></p> " - " <p>This setting controls the vertical size of characters when printing a text file. </p>" - " <p>The default value is 6, meaning that the font is scaled in a way that 6 lines " - " per inch will be printed. </p> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o lpi=... # example \"5\" or \"7\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisColumnsTextPage = i18n( " <qt> " - " <p><b>Columns</b></p> " - " <p>This setting controls how many columns of text will be printed on each page when." - " printing text files. </p> " - " <p>The default value is 1, meaning that only one column of text per page " - " will be printed. </p> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o columns=... # example: \"2\" or \"4\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPrettyprintPreviewIconTextPage = i18n( " <qt> " - " Preview icon changes when you turn on or off prettyprint. " - " </qt>" ); - TQString whatsThisFormatTextPage = i18n( " <qt> " - " <p><b>Text Formats</b></p> " - " <p>These settings control the appearance of text on printouts. They are only valid for " - " printing text files or input directly through kprinter. </p> " - " <p><b>Note:</b> These settings have no effect whatsoever for other input formats than " - " text, or for printing from applications such as the KDE Advanced Text Editor. (Applications " - " in general send PostScript to the print system, and 'kate' in particular has its own " - " knobs to control the print output. </p>." - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o cpi=... # example: \"8\" or \"12\" " - " <br> " - " -o lpi=... # example: \"5\" or \"7\" " - " <br> " - " -o columns=... # example: \"2\" or \"4\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisMarginsTextPage = i18n( " <qt> " - " <p><b>Margins</b></p> " - " <p>These settings control the margins of printouts on the paper. They are not valid for " - " jobs originating from applications which define their own page layout internally and " - " send PostScript to KDEPrint (such as KOffice or OpenOffice.org). </p> " - " <p>When printing from KDE applications, such as KMail and Konqueror, or printing an ASCII text " - " file through kprinter, you can choose your preferred margin settings here. </p> " - " <p>Margins may be set individually for each edge of the paper. The combo box at the bottom lets you change " - " the units of measurement between Pixels, Millimeters, Centimeters, and Inches. </p> " - " <p>You can even use the mouse to grab one margin and drag it to the intended position (see the " - " preview picture on the right side). </p> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-top=... # example: \"72\" " - " <br> " - " -o page-bottom=... # example: \"24\" " - " <br> " - " -o page-left=... # example: \"36\" " - " <br> " - " -o page-right=... # example: \"12\" " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPrettyprintButtonOnTextPage = i18n( " <qt> " - " <p><b>Turn Text Printing with Syntax Highlighting (Prettyprint) On!</b></p> " - " <p>ASCII text file printouts can be 'prettyfied' by enabling this option. If you do so, " - " a header is printed at the top of each page. The header contains " - " the page number, job title (usually the filename), and the date. In addition, C and " - " C++ keywords are highlighted, and comment lines are italicized.</p>" - " <p>This prettyprint option is handled by CUPS.</p> " - " <p>If you prefer another 'plaintext-to-prettyprint' converter, look for the <em>enscript</em> " - " pre-filter on the <em>Filters</em> tab. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o prettyprint=true. " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPrettyprintButtonOffTextPage = i18n( " <qt> " - " <p><b>Turn Text Printing with Syntax Highlighting (Prettyprint) Off! </b></p> " - " <p>ASCII text file printing with this option turned off are appearing without a page " - " header and without syntax highlighting. (You can still set the page margins, though.) </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o prettyprint=false " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisPrettyprintFrameTextPage = i18n( " <qt> " - " <p><b>Print Text with Syntax Highlighting (Prettyprint)</b></p> " - " <p>ASCII file printouts can be 'prettyfied' by enabling this option. If you do so, " - " a header is printed at the top of each page. The header contains " - " the page number, job title (usually the filename), and the date. In addition, C and " - " C++ keywords are highlighted, and comment lines are italicized.</p>" - " <p>This prettyprint option is handled by CUPS.</p> " - " <p>If you prefer another 'plaintext-to-prettyprint' converter, look for the <em>enscript</em> " - " pre-filter on the <em>Filters</em> tab. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o prettyprint=true. " - " <br> " - " -o prettyprint=false " - " </pre>" - " </p> " - " </qt>" ); - - setTitle(i18n("Text")); - m_block = false; - - TQGroupBox *formatbox = new TQGroupBox(0, Qt::Vertical, i18n("Text Format"), this); - TQWhatsThis::add(formatbox, whatsThisFormatTextPage); - TQGroupBox *prettybox = new TQGroupBox(0, Qt::Vertical, i18n("Syntax Highlighting"), this); - TQWhatsThis::add(prettybox, whatsThisPrettyprintFrameTextPage); - TQGroupBox *marginbox = new TQGroupBox(0, Qt::Vertical, i18n("Margins"), this); - TQWhatsThis::add(marginbox, whatsThisMarginsTextPage); - - m_cpi = new KIntNumInput(10, formatbox); - TQWhatsThis::add(m_cpi, whatsThisCPITextPage); - m_cpi->setLabel(i18n("&Chars per inch:"), Qt::AlignLeft|Qt::AlignVCenter); - m_cpi->setRange(1, 999, 1, false); - m_lpi = new KIntNumInput(m_cpi, 6, formatbox); - TQWhatsThis::add(m_lpi, whatsThisLPITextPage); - m_lpi->setLabel(i18n("&Lines per inch:"), Qt::AlignLeft|Qt::AlignVCenter); - m_lpi->setRange(1, 999, 1, false); - m_columns = new KIntNumInput(m_lpi, 1, formatbox); - TQWhatsThis::add(m_columns, whatsThisColumnsTextPage); - m_columns->setLabel(i18n("C&olumns:"), Qt::AlignLeft|Qt::AlignVCenter); - m_columns->setRange(1, 10, 1, false); - KSeparator *sep = new KSeparator(Qt::Horizontal, formatbox); - connect(m_columns, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotColumnsChanged(int))); - - m_prettypix = new TQLabel(prettybox); - TQWhatsThis::add(m_prettypix, whatsThisPrettyprintPreviewIconTextPage); - m_prettypix->tqsetAlignment(Qt::AlignCenter); - TQRadioButton *off = new TQRadioButton(i18n("&Disabled"), prettybox); - TQWhatsThis::add(off, whatsThisPrettyprintButtonOffTextPage); - TQRadioButton *on = new TQRadioButton(i18n("&Enabled"), prettybox); - TQWhatsThis::add(on, whatsThisPrettyprintButtonOnTextPage); - m_prettyprint = new TQButtonGroup(prettybox); - m_prettyprint->hide(); - m_prettyprint->insert(off, 0); - m_prettyprint->insert(on, 1); - m_prettyprint->setButton(0); - connect(m_prettyprint, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotPrettyChanged(int))); - slotPrettyChanged(0); - - m_margin = new MarginWidget(marginbox); - TQWhatsThis::add(m_margin, whatsThisMarginsTextPage); - m_margin->setPageSize(595, 842); - - TQGridLayout *l0 = new TQGridLayout(this, 2, 2, 0, 10); - l0->addWidget(formatbox, 0, 0); - l0->addWidget(prettybox, 0, 1); - l0->addMultiCellWidget(marginbox, 1, 1, 0, 1); - TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(formatbox->layout()), 5); - l1->addWidget(m_cpi); - l1->addWidget(m_lpi); - l1->addWidget(sep); - l1->addWidget(m_columns); - TQGridLayout *l2 = new TQGridLayout(TQT_TQLAYOUT(prettybox->layout()), 2, 2, 10); - l2->addWidget(off, 0, 0); - l2->addWidget(on, 1, 0); - l2->addMultiCellWidget(m_prettypix, 0, 1, 1, 1); - TQVBoxLayout *l3 = new TQVBoxLayout(TQT_TQLAYOUT(marginbox->layout()), 10); - l3->addWidget(m_margin); -} - -KPTextPage::~KPTextPage() -{ -} - -void KPTextPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQString value; - - if (!(value=opts["cpi"]).isEmpty()) - m_cpi->setValue(value.toInt()); - if (!(value=opts["lpi"]).isEmpty()) - m_lpi->setValue(value.toInt()); - if (!(value=opts["columns"]).isEmpty()) - m_columns->setValue(value.toInt()); - int ID(0); - if (opts.contains("prettyprint") && (opts["prettyprint"].isEmpty() || opts["prettyprint"] == "true")) - ID = 1; - m_prettyprint->setButton(ID); - slotPrettyChanged(ID); - - // get default margins - m_currentps = opts["PageSize"]; - TQString orient = opts["orientation-requested"]; - bool landscape = (orient == "4" || orient == "5"); - initPageSize(landscape); - - bool marginset(false); - if (!(value=opts["page-top"]).isEmpty() && value.toFloat() != m_margin->top()) - { - marginset = true; - m_margin->setTop(value.toFloat()); - } - if (!(value=opts["page-bottom"]).isEmpty() && value.toFloat() != m_margin->bottom()) - { - marginset = true; - m_margin->setBottom(value.toFloat()); - } - if (!(value=opts["page-left"]).isEmpty() && value.toFloat() != m_margin->left()) - { - marginset = true; - m_margin->setLeft(value.toFloat()); - } - if (!(value=opts["page-right"]).isEmpty() && value.toFloat() != m_margin->right()) - { - marginset = true; - m_margin->setRight(value.toFloat()); - } - m_margin->setCustomEnabled(marginset); -} - -void KPTextPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - if (incldef || m_cpi->value() != 10) - opts["cpi"] = TQString::number(m_cpi->value()); - if (incldef || m_lpi->value() != 6) - opts["lpi"] = TQString::number(m_lpi->value()); - if (incldef || m_columns->value() != 1) - opts["columns"] = TQString::number(m_columns->value()); - - //if (m_margin->isCustomEnabled() || incldef) - if (m_margin->isCustomEnabled()) - { - opts["page-top"] = TQString::number(( int )( m_margin->top()+0.5 )); - opts["page-bottom"] = TQString::number(( int )( m_margin->bottom()+0.5 )); - opts["page-left"] = TQString::number(( int )( m_margin->left()+0.5 )); - opts["page-right"] = TQString::number(( int )( m_margin->right()+0.5 )); - } - else - { - opts.remove("page-top"); - opts.remove("page-bottom"); - opts.remove("page-left"); - opts.remove("page-right"); - } - - if (m_prettyprint->id(m_prettyprint->selected()) == 1) - opts["prettyprint"] = "true"; - else if (incldef) - opts["prettyprint"] = "false"; - else - opts.remove("prettyprint"); -} - -void KPTextPage::slotPrettyChanged(int ID) -{ - TQString iconstr = (ID == 0 ? "tdeprint_nup1" : "tdeprint_prettyprint"); - m_prettypix->setPixmap(UserIcon(iconstr)); -} - -void KPTextPage::slotColumnsChanged(int) -{ - // TO BE IMPLEMENTED -} - -void KPTextPage::initPageSize(bool landscape) -{ - float w( -1 ), h( -1 ); - float mt( 36 ), mb( mt ), ml( 18 ), mr( ml ); - if (driver()) - { - if (m_currentps.isEmpty()) - { - DrListOption *o = (DrListOption*)driver()->findOption("PageSize"); - if (o) - m_currentps = o->get("default"); - } - if (!m_currentps.isEmpty()) - { - DrPageSize *ps = driver()->findPageSize(m_currentps); - if (ps) - { - w = ps->pageWidth(); - h = ps->pageHeight(); - mt = ps->topMargin(); - ml = ps->leftMargin(); - mr = ps->rightMargin(); - mb = ps->bottomMargin(); - } - } - } - m_margin->setPageSize(w, h); - m_margin->setOrientation(landscape ? KPrinter::Landscape : KPrinter::Portrait); - m_margin->setDefaultMargins( mt, mb, ml, mr ); - m_margin->setCustomEnabled(false); -} - -#include "kptextpage.moc" diff --git a/kdeprint/cups/kptextpage.h b/kdeprint/cups/kptextpage.h deleted file mode 100644 index 504e2d5c2..000000000 --- a/kdeprint/cups/kptextpage.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPTEXTPAGE_H -#define KPTEXTPAGE_H - -#include "kprintdialogpage.h" - -class DrMain; -class KIntNumInput; -class TQButtonGroup; -class TQLabel; -class MarginWidget; - -class KPTextPage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPTextPage(DrMain *driver, TQWidget *parent = 0, const char *name = 0); - ~KPTextPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected slots: - void slotPrettyChanged(int); - void slotColumnsChanged(int); - -protected: - void initPageSize(bool landscape); - -private: - KIntNumInput *m_cpi, *m_lpi, *m_columns; - TQButtonGroup *m_prettyprint; - MarginWidget *m_margin; - TQLabel *m_prettypix; - TQString m_currentps; - bool m_block; -}; - -#endif diff --git a/kdeprint/cups/make_driver_db_cups.c b/kdeprint/cups/make_driver_db_cups.c deleted file mode 100644 index b39dda8de..000000000 --- a/kdeprint/cups/make_driver_db_cups.c +++ /dev/null @@ -1,149 +0,0 @@ -#include <config.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> -#include <unistd.h> -#include <ctype.h> -#include <zlib.h> - -#include "driverparse.h" - -void initPpd(const char *dirname) -{ - DIR *dir = opendir(dirname); - struct dirent *entry; - char buffer[4096] = {0}; - char drFile[256]; - int len = strlen(dirname); - - if (dir == NULL) - { - fprintf(stderr, "Can't open drivers directory : %s\n", dirname); - return; - } - while ((entry=readdir(dir)) != NULL) - { - if (strcmp(entry->d_name,".") == 0 || strcmp(entry->d_name,"..") == 0) - { - continue; - } - if (len+strlen(entry->d_name)+1 < 4096) - { - struct stat st; - - strcpy(buffer,dirname); - strcat(buffer,"/"); - strcat(buffer,entry->d_name); - if (stat(buffer,&st) == 0) - { - if (S_ISDIR(st.st_mode)) - { - initPpd(buffer); - } - else if (S_ISREG(st.st_mode)) - { - char *c = strrchr(buffer,'.'); - snprintf(drFile, 255, "ppd:%s", buffer); - if (c && strncmp(c,".ppd",4) == 0) - { - addFile(drFile); - } - else if (c && strncmp(c, ".gz", 3) == 0) - { /* keep also compressed driver files */ - while (c != buffer) - { - if (*(--c) == '.') break; - } - if (*c == '.' && strncmp(c, ".ppd",4) == 0) - { - addFile(drFile); - } - } - } - } - } - } - closedir(dir); -} - -int parsePpdFile(const char *filename, FILE *output_file) -{ - gzFile ppd_file; - char line[4096], value[256], langver[64] = {0}, desc[256] = {0}; - char *c1, *c2; - int count = 0; - - ppd_file = gzopen(filename,"r"); - if (ppd_file == NULL) - { - fprintf(stderr, "Can't open driver file : %s\n", filename); - return 0; - } - fprintf(output_file,"FILE=ppd:%s\n",filename); - - while (gzgets(ppd_file,line,4095) != Z_NULL) - { - memset(value,0,256); - c1 = strchr(line,':'); - if (c1) - { - c2 = strchr(c1,'"'); - if (c2) - { - c2++; - c1 = strchr(c2,'"'); - if (c1) strlcpy(value,c2,c1-c2+1); - } - else - { - c1++; - while (*c1 && isspace(*c1)) - c1++; - if (!*c1) - continue; - c2 = line+strlen(line)-1; /* point to \n */ - while (*c2 && isspace(*c2)) - c2--; - strlcpy(value,c1,c2-c1+2); - } - } - count++; - if (strncmp(line,"*Manufacturer:",14) == 0) fprintf(output_file,"MANUFACTURER=%s\n",value); - else if (strncmp(line,"*ShortNickName:",15) == 0) fprintf(output_file,"MODEL=%s\n",value); - else if (strncmp(line,"*ModelName:",11) == 0) fprintf(output_file,"MODELNAME=%s\n",value); - else if (strncmp(line,"*NickName:",10) == 0) strncat(desc,value,255-strlen(desc)); - else if (strncmp(line,"*pnpManufacturer:",17) == 0) fprintf(output_file,"PNPMANUFACTURER=%s\n",value); - else if (strncmp(line,"*pnpModel:",10) == 0) fprintf(output_file,"PNPMODEL=%s\n",value); - else if (strncmp(line,"*LanguageVersion:",17) == 0) strncat(langver,value,63-strlen(langver)); - else count--; - /* Either we got everything we needed, or we encountered an "OpenUI" directive - * and it's reasonable to assume that there's no needed info further in the file, - * just stop here */ - if (count >= 7 || strncmp(line, "*OpenUI", 7) == 0) - { - if (strlen(langver) > 0) - { - strncat(desc, " [", 255-strlen(desc)); - strncat(desc, langver, 255-strlen(desc)); - strncat(desc, "]", 255-strlen(desc)); - } - if (strlen(desc) > 0) - fprintf(output_file, "DESCRIPTION=%s\n", desc); - break; - } - } - fprintf(output_file,"\n"); - - gzclose(ppd_file); - return 1; -} - -int main(int argc, char *argv[]) -{ - registerHandler("ppd:", initPpd, parsePpdFile); - initFoomatic(); - return execute(argc, argv); -} diff --git a/kdeprint/cups/postscript.ppd.gz b/kdeprint/cups/postscript.ppd.gz deleted file mode 100644 index 92fd6862c..000000000 Binary files a/kdeprint/cups/postscript.ppd.gz and /dev/null differ diff --git a/kdeprint/cups/preview-mini.png b/kdeprint/cups/preview-mini.png deleted file mode 100644 index 7212eaf51..000000000 Binary files a/kdeprint/cups/preview-mini.png and /dev/null differ diff --git a/kdeprint/cups/preview.png b/kdeprint/cups/preview.png deleted file mode 100644 index 8e436dbd1..000000000 Binary files a/kdeprint/cups/preview.png and /dev/null differ diff --git a/kdeprint/driver.cpp b/kdeprint/driver.cpp deleted file mode 100644 index 072f125c6..000000000 --- a/kdeprint/driver.cpp +++ /dev/null @@ -1,714 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "driver.h" -#include "driveritem.h" - -#include <tqfile.h> -#include <tqstringlist.h> -#include <kdebug.h> -#include <klocale.h> -#include <stdlib.h> -#include <math.h> - -/****************** - * DrBase members * - ******************/ - -DrBase::DrBase() -: m_type(DrBase::Base), m_conflict(false) -{ -} - -DrBase::~DrBase() -{ -} - -TQString DrBase::valueText() -{ - return TQString::null; -} - -TQString DrBase::prettyText() -{ - return valueText(); -} - -void DrBase::setValueText(const TQString&) -{ -} - -DriverItem* DrBase::createItem(DriverItem *parent, DriverItem *after) -{ - return new DriverItem(parent, after, this); -} - -void DrBase::setOptions(const TQMap<TQString,TQString>& opts) -{ - if (opts.contains(name())) setValueText(opts[name()]); -} - -void DrBase::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - QString val = valueText(); - if ( incldef || get( "persistent" ) == "1" || get("default") != val ) - opts[name()] = val; -} - -DrBase* DrBase::clone() -{ - DrBase *opt(0); - switch (type()) - { - case Main: opt = new DrMain; break; - case Group: opt = new DrGroup; break; - case String: opt = new DrStringOption; break; - case Integer: opt = new DrIntegerOption; break; - case Float: opt = new DrFloatOption; break; - case List: opt = new DrListOption; break; - case Boolean: opt = new DrBooleanOption; break; - default: opt = new DrBase; break; - } - opt->m_map = m_map; - opt->m_name = m_name; - opt->m_conflict = m_conflict; - opt->setValueText(valueText()); - - return opt; -} - -/****************** - * DrMain members * - ******************/ - -DrMain::DrMain() -: DrGroup() -{ - m_type = DrBase::Main; - m_constraints.setAutoDelete(true); - m_pagesizes.setAutoDelete(true); -} - -DrMain::~DrMain() -{ - // remove a possible temporary file - if (has("temporary")) - TQFile::remove(get("temporary")); -} - -DriverItem* DrMain::createTreeView(TQListView *parent) -{ - DriverItem *root = new DriverItem(parent, this); - createTree(root); - return root; -} - -int DrMain::checkConstraints() -{ - int result(0); - clearConflict(); - TQPtrListIterator<DrConstraint> it(m_constraints); - for (;it.current();++it) - if (it.current()->check(this)) - result++; - return result; -} - -void DrMain::addPageSize(DrPageSize *ps) -{ - m_pagesizes.insert(ps->pageName(),ps); -} - -void DrMain::removeOptionGlobally(const TQString& name) -{ - DrGroup *grp(0); - DrBase *opt = findOption(name, &grp); - - if (opt && grp) - { - grp->removeOption(name); - if (grp->isEmpty()) - removeGroup(grp); - } -} - -void DrMain::removeGroupGlobally(DrGroup *grp) -{ - DrGroup *parent(0); - if (findGroup(grp, &parent) && parent) - { - parent->removeGroup(grp); - if (parent->isEmpty() && parent != this) - removeGroupGlobally(parent); - } -} - -TQMap<TQString, DrBase*> DrMain::flatten() -{ - TQMap<TQString, DrBase*> optmap; - int index(0); - flattenGroup(optmap, index); - return optmap; -} - -DrMain* DrMain::cloneDriver() -{ - DrMain *driver = static_cast<DrMain*>(clone()); - - TQPtrListIterator<DrConstraint> cit(m_constraints); - for (; cit.current(); ++cit) - driver->addConstraint(new DrConstraint(*(cit.current()))); - - TQDictIterator<DrPageSize> pit(m_pagesizes); - for (; pit.current(); ++pit) - driver->addPageSize(new DrPageSize(*(pit.current()))); - - return driver; -} - -/******************* - * DrGroup members * - *******************/ - -DrGroup::DrGroup() -: DrBase() -{ - m_type = DrBase::Group; - - m_subgroups.setAutoDelete(true); - m_options.setAutoDelete(true); - m_listoptions.setAutoDelete(false); -} - -DrGroup::~DrGroup() -{ -} - -void DrGroup::addOption(DrBase *opt) -{ - if (!opt->name().isEmpty()) - { - m_options.insert(opt->name(),opt); - m_listoptions.append(opt); - } -} - -void DrGroup::addGroup(DrGroup *grp) -{ - m_subgroups.append(grp); -} - -void DrGroup::addObject(DrBase *optgrp) -{ - if (optgrp->isOption()) - addOption(optgrp); - else if (optgrp->type() == DrBase::Group) - addGroup(static_cast<DrGroup*>(optgrp)); -} - -void DrGroup::removeOption(const TQString& name) -{ - DrBase *opt = m_options.find(name); - if (opt) - { - m_listoptions.removeRef(opt); - m_options.remove(name); - } -} - -void DrGroup::removeGroup(DrGroup *grp) -{ - m_subgroups.removeRef(grp); -} - -bool DrGroup::isEmpty() -{ - return (m_options.count()+m_subgroups.count() == 0); -} - -DriverItem* DrGroup::createItem(DriverItem *parent, DriverItem *after) -{ - DriverItem *item = DrBase::createItem(parent, after); - createTree(item); - return item; -} - -void DrGroup::createTree(DriverItem *parent) -{ - DriverItem *item(0); - - TQPtrListIterator<DrGroup> lit(m_subgroups); - for (;lit.current();++lit) - item = lit.current()->createItem(parent, item); - - TQPtrListIterator<DrBase> dit(m_listoptions); - for (;dit.current();++dit) - item = dit.current()->createItem(parent, item); -} - -DrBase* DrGroup::findOption(const TQString& name, DrGroup **parentGroup) -{ - DrBase *opt = m_options.find(name); - if (!opt) - { - TQPtrListIterator<DrGroup> it(m_subgroups); - for (;it.current() && !opt; ++it) - opt = it.current()->findOption(name, parentGroup); - } - else if (parentGroup) - *parentGroup = this; - return opt; -} - -DrGroup* DrGroup::findGroup(DrGroup *grp, DrGroup ** parentGroup) -{ - DrGroup *group = (m_subgroups.findRef(grp) == -1 ? 0 : grp); - if (!group) - { - TQPtrListIterator<DrGroup> it(m_subgroups); - for (;it.current() && !group; ++it) - group = it.current()->findGroup(grp, parentGroup); - } - else if (parentGroup) - *parentGroup = this; - return group; -} - -void DrGroup::clearConflict() -{ - TQDictIterator<DrBase> dit(m_options); - for (;dit.current();++dit) - dit.current()->setConflict(false); - - TQPtrListIterator<DrGroup> lit(m_subgroups); - for (;lit.current();++lit) - lit.current()->clearConflict(); -} - -void DrGroup::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQDictIterator<DrBase> dit(m_options); - for (;dit.current();++dit) - dit.current()->setOptions(opts); - - TQPtrListIterator<DrGroup> lit(m_subgroups); - for (;lit.current();++lit) - lit.current()->setOptions(opts); -} - -void DrGroup::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - TQDictIterator<DrBase> dit(m_options); - for (;dit.current();++dit) - dit.current()->getOptions(opts,incldef); - - TQPtrListIterator<DrGroup> lit(m_subgroups); - for (;lit.current();++lit) - lit.current()->getOptions(opts,incldef); -} - -void DrGroup::flattenGroup(TQMap<TQString, DrBase*>& optmap, int& index) -{ - TQPtrListIterator<DrGroup> git(m_subgroups); - for (; git.current(); ++git) - git.current()->flattenGroup(optmap, index); - - TQDictIterator<DrBase> oit(m_options); - for (; oit.current(); ++oit) - optmap[oit.current()->name()] = oit.current(); - - if (name().isEmpty()) - optmap[TQString::tqfromLatin1("group%1").arg(index++)] = this; - else - optmap[name()] = this; - - m_subgroups.setAutoDelete(false); - m_options.setAutoDelete(false); - m_subgroups.clear(); - m_options.clear(); - m_listoptions.clear(); - m_subgroups.setAutoDelete(true); - m_options.setAutoDelete(true); -} - -DrBase* DrGroup::clone() -{ - DrGroup *grp = static_cast<DrGroup*>(DrBase::clone()); - - TQPtrListIterator<DrGroup> git(m_subgroups); - for (; git.current(); ++git) - grp->addGroup(static_cast<DrGroup*>(git.current()->clone())); - - TQPtrListIterator<DrBase> oit(m_listoptions); - for (; oit.current(); ++oit) - grp->addOption(oit.current()->clone()); - - return static_cast<DrBase*>(grp); -} - -TQString DrGroup::groupForOption( const TQString& optname ) -{ - TQString grpname; - if ( optname == "PageSize" || - optname == "InputSlot" || - optname == "ManualFeed" || - optname == "MediaType" || - optname == "MediaColor" || - optname == "MediaWeight" || - optname == "Duplex" || - optname == "DoubleSided" || - optname == "Copies" ) - grpname = i18n( "General" ); - else if ( optname.startsWith( "stp" ) || - optname == "Cyan" || - optname == "Yellow" || - optname == "Magenta" || - optname == "Black" || - optname == "Density" || - optname == "Contrast" ) - grpname = i18n( "Adjustments" ); - else if ( optname.startsWith( "JCL" ) ) - grpname = i18n( "JCL" ); - else - grpname = i18n( "Others" ); - return grpname; -} - -/************************* - * DrChoiceGroup members * - *************************/ - -DrChoiceGroup::DrChoiceGroup() -: DrGroup() -{ - m_type = DrBase::ChoiceGroup; -} - -DrChoiceGroup::~DrChoiceGroup() -{ -} - -DriverItem* DrChoiceGroup::createItem(DriverItem *parent, DriverItem*) -{ - createTree(parent); - return NULL; -} - -/************************** - * DrStringOption members * - **************************/ - -DrStringOption::DrStringOption() -: DrBase() -{ - m_type = DrBase::String; -} - -DrStringOption::~DrStringOption() -{ -} - -TQString DrStringOption::valueText() -{ - return m_value; -} - -void DrStringOption::setValueText(const TQString& s) -{ - m_value = s; -} - -/*************************** - * DrIntegerOption members * - ***************************/ - -DrIntegerOption::DrIntegerOption() -: DrBase() -{ - m_type = DrBase::Integer; - m_value = 0; - set("minval","0"); - set("maxval","10"); -} - -DrIntegerOption::~DrIntegerOption() -{ -} - -TQString DrIntegerOption::valueText() -{ - QString s = TQString::number(m_value); - return s; -} - -void DrIntegerOption::setValueText(const TQString& s) -{ - m_value = s.toInt(); -} - -TQString DrIntegerOption::fixedVal() -{ - TQStringList vals = TQStringList::split("|", get("fixedvals"), false); - if (vals.count() == 0) - return valueText(); - int d(0); - TQString val; - for (TQStringList::Iterator it=vals.begin(); it!=vals.end(); ++it) - { - int thisVal = (*it).toInt(); - if (val.isEmpty() || abs(thisVal - m_value) < d) - { - d = abs(thisVal - m_value); - val = *it; - } - } - if (val.isEmpty()) - return valueText(); - else - return val; -} - -/************************* - * DrFloatOption members * - *************************/ - -DrFloatOption::DrFloatOption() -: DrBase() -{ - m_type = DrBase::Float; - m_value = 0.0; - set("minval","0.0"); - set("maxval","1.0"); -} - -DrFloatOption::~DrFloatOption() -{ -} - -TQString DrFloatOption::valueText() -{ - QString s = TQString::number(m_value,'f',3); - return s; -} - -void DrFloatOption::setValueText(const TQString& s) -{ - m_value = s.toFloat(); -} - -TQString DrFloatOption::fixedVal() -{ - TQStringList vals = TQStringList::split("|", get("fixedvals"), false); - if (vals.count() == 0) - return valueText(); - float d(0); - TQString val; - for (TQStringList::Iterator it=vals.begin(); it!=vals.end(); ++it) - { - float thisVal = (*it).toFloat(); - if (val.isEmpty() || fabs(thisVal - m_value) < d) - { - d = fabs(thisVal - m_value); - val = *it; - } - } - if (val.isEmpty()) - return valueText(); - else - return val; -} - -/************************ - * DrListOption members * - ************************/ - -DrListOption::DrListOption() -: DrBase() -{ - m_type = DrBase::List; - - m_choices.setAutoDelete(true); - m_current = 0; -} - -DrListOption::~DrListOption() -{ -} - -TQString DrListOption::valueText() -{ - QString s = (m_current ? m_current->name() : TQString::null); - return s; -} - -TQString DrListOption::prettyText() -{ - if (m_current) - return m_current->get("text"); - else - return TQString::null; -} - -void DrListOption::setValueText(const TQString& s) -{ - m_current = findChoice(s); - if (!m_current) - { - bool ok; - int index = s.toInt(&ok); - if (ok) - setChoice(index); - } -} - -DrBase* DrListOption::findChoice(const TQString& txt) -{ - TQPtrListIterator<DrBase> it(m_choices); - for (;it.current();++it) - if (it.current()->name() == txt) - return it.current(); - return NULL; -} - -DrBase* DrListOption::clone() -{ - DrListOption *opt = static_cast<DrListOption*>(DrBase::clone()); - - TQPtrListIterator<DrBase> it(m_choices); - for (; it.current(); ++it) - opt->addChoice(it.current()->clone()); - - opt->setValueText(valueText()); - - return static_cast<DrBase*>(opt); -} - -void DrListOption::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - DrBase::getOptions(opts, incldef); - if (currentChoice() && currentChoice()->type() == DrBase::ChoiceGroup) - currentChoice()->getOptions(opts, incldef); -} - -void DrListOption::setOptions(const TQMap<TQString,TQString>& opts) -{ - DrBase::setOptions(opts); - if (currentChoice() && currentChoice()->type() == DrBase::ChoiceGroup) - currentChoice()->setOptions(opts); -} - -DriverItem* DrListOption::createItem(DriverItem *parent, DriverItem *after) -{ - DriverItem *item = DrBase::createItem(parent, after); - /*if (currentChoice() && currentChoice()->type() == DrBase::ChoiceGroup) - { - currentChoice()->createItem(item); - }*/ - return item; -} - -void DrListOption::setChoice(int choicenum) -{ - if (choicenum >= 0 && choicenum < (int)m_choices.count()) - { - setValueText(m_choices.tqat(choicenum)->name()); - } -} - -/************************ - * DrConstraint members * - ************************/ - -DrConstraint::DrConstraint(const TQString& o1, const TQString& o2, const TQString& c1, const TQString& c2) -: m_opt1(o1), m_opt2(o2), m_choice1(c1), m_choice2(c2), m_option1(0), m_option2(0) -{ -} - -DrConstraint::DrConstraint(const DrConstraint& d) -: m_opt1(d.m_opt1), m_opt2(d.m_opt2), m_choice1(d.m_choice1), m_choice2(d.m_choice2), m_option1(0), m_option2(0) -{ -} - -bool DrConstraint::check(DrMain *driver) -{ - if (!m_option1) m_option1 = (DrListOption*)driver->findOption(m_opt1); - if (!m_option2) m_option2 = (DrListOption*)driver->findOption(m_opt2); - if (m_option1 && m_option2 && m_option1->currentChoice() && m_option2->currentChoice()) - { - bool f1(false), f2(false); - QString c1(m_option1->currentChoice()->name()), c2(m_option2->currentChoice()->name()); - // check choices - if (m_choice1.isEmpty()) - f1 = (c1 != "None" && c1 != "Off" && c1 != "False"); - else - f1 = (c1 == m_choice1); - if (m_choice2.isEmpty()) - f2 = (c2 != "None" && c2 != "Off" && c2 != "False"); - else - f2 = (c2 == m_choice2); - // tag options - QString s((f1 && f2 ? "1" : "0")); - if (!m_option1->conflict()) m_option1->setConflict(f1 && f2); - if (!m_option2->conflict()) m_option2->setConflict(f1 && f2); - // return value - return (f1 && f2); - } - return false; -} - -/********************** - * DrPageSize members * - **********************/ - -DrPageSize::DrPageSize(const TQString& s, float width, float height, float left, float bottom, float right, float top) -: m_name(s), - m_width( width ), - m_height( height ), - m_left( left ), - m_bottom( bottom ), - m_right( right ), - m_top( top ) -{ -} - -DrPageSize::DrPageSize(const DrPageSize& d) -: m_name(d.m_name), - m_width( d.m_width ), - m_height( d.m_height ), - m_left( d.m_left ), - m_bottom( d.m_bottom ), - m_right( d.m_right ), - m_top( d.m_top ) -{ -} - -TQSize DrPageSize::pageSize() const -{ - return TQSize( ( int )m_width, ( int )m_height ); -} - -TQRect DrPageSize::pageRect() const -{ - return TQRect( ( int )( m_left+0.5 ), ( int )( m_top+0.5 ), ( int )( m_width-m_left-m_right ), ( int )( m_height-m_top-m_bottom ) ); -} - -TQSize DrPageSize::margins() const -{ - return TQSize( ( int )( m_left+0.5 ), ( int )( m_top+0.5 ) ); -} diff --git a/kdeprint/driver.h b/kdeprint/driver.h deleted file mode 100644 index 7064e5335..000000000 --- a/kdeprint/driver.h +++ /dev/null @@ -1,383 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 DRIVER_H -#define DRIVER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqstring.h> -#include <tqptrlist.h> -#include <tqdict.h> -#include <tqmap.h> -#include <tqrect.h> -#include <tqsize.h> - -#include <kdelibs_export.h> - -class DriverItem; -class TQListView; - -/*********************** - * Forward definitions * - ***********************/ - -class DrBase; -class DrMain; -class DrGroup; -class DrConstraint; -class DrPageSize; - -/************************************* - * Base class for all driver objects * - *************************************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrBase -{ -public: - enum Type { Base = 0, Main, ChoiceGroup, Group, String, Integer, Float, List, Boolean }; - - DrBase(); - virtual ~DrBase(); - - Type type() const { return m_type; } - bool isOption() const { return (m_type >= DrBase::String); } - - const TQString& get(const TQString& key) const { return m_map[key]; } - void set(const TQString& key, const TQString& val) { m_map[key] = val; } - bool has(const TQString& key) const { return m_map.contains(key); } - const TQString& name() const { return m_name; } - void setName(const TQString& s) { m_name = s; } - bool conflict() const { return m_conflict; } - void setConflict(bool on) { m_conflict = on; } - - virtual TQString valueText(); - virtual TQString prettyText(); - virtual void setValueText(const TQString&); - virtual DriverItem* createItem(DriverItem *parent, DriverItem *after = 0); - virtual void setOptions(const TQMap<TQString,TQString>& opts); - virtual void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - virtual DrBase* clone(); - -protected: - TQMap<TQString,TQString> m_map; - QString m_name; // used as a search key, better to have defined directly - Type m_type; - bool m_conflict; -}; - -/********************** - * Option group class * - **********************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrGroup : public DrBase -{ -public: - DrGroup(); - ~DrGroup(); - - void addOption(DrBase *opt); - void addGroup(DrGroup *grp); - void addObject(DrBase *optgrp); - void clearConflict(); - void removeOption(const TQString& name); - void removeGroup(DrGroup *grp); - bool isEmpty(); - - virtual DriverItem* createItem(DriverItem *parent, DriverItem *after = 0); - DrBase* findOption(const TQString& name, DrGroup **parentGroup = 0); - DrGroup* findGroup(DrGroup *grp, DrGroup **parentGroup = 0); - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - DrBase* clone(); - - const TQPtrList<DrGroup>& groups() { return m_subgroups; } - const TQPtrList<DrBase>& options() { return m_listoptions; } - - static TQString groupForOption( const TQString& optname ); - -protected: - void createTree(DriverItem *parent); - void flattenGroup(TQMap<TQString, DrBase*>&, int&); - -protected: - TQPtrList<DrGroup> m_subgroups; - TQDict<DrBase> m_options; - TQPtrList<DrBase> m_listoptions; // keep track of order of appearance -}; - -/********************* - * Main driver class * - *********************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrMain : public DrGroup -{ -public: - DrMain(); - ~DrMain(); - - DriverItem* createTreeView(TQListView *parent); - void addConstraint(DrConstraint *c) { m_constraints.append(c); } - int checkConstraints(); - DrPageSize* findPageSize(const TQString& name) { return m_pagesizes.find(name); } - void addPageSize(DrPageSize *sz); - void removeOptionGlobally(const TQString& name); - void removeGroupGlobally(DrGroup *grp); - TQMap<TQString, DrBase*> flatten(); - DrMain* cloneDriver(); - -protected: - TQPtrList<DrConstraint> m_constraints; - TQDict<DrPageSize> m_pagesizes; -}; - -/********************************************************** - * Choice group class: a choice that involve a sub-option * - **********************************************************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class DrChoiceGroup : public DrGroup -{ -public: - DrChoiceGroup(); - ~DrChoiceGroup(); - - DriverItem* createItem(DriverItem *parent, DriverItem *after = 0); -}; - -/*********************** - * String option class * - ***********************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrStringOption : public DrBase -{ -public: - DrStringOption(); - ~DrStringOption(); - - virtual TQString valueText(); - virtual void setValueText(const TQString& s); - -protected: - QString m_value; -}; - -/********************************** - * Integer numerical option class * - **********************************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrIntegerOption : public DrBase -{ -public: - DrIntegerOption(); - ~DrIntegerOption(); - - virtual TQString valueText(); - virtual void setValueText(const TQString& s); - TQString fixedVal(); - -protected: - int m_value; -}; - -/******************************** - * Float numerical option class * - ********************************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrFloatOption : public DrBase -{ -public: - DrFloatOption(); - ~DrFloatOption(); - - virtual TQString valueText(); - virtual void setValueText(const TQString& s); - TQString fixedVal(); - -protected: - float m_value; -}; - -/*********************** - * Single choice class * - ***********************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrListOption : public DrBase -{ -public: - DrListOption(); - ~DrListOption(); - - void addChoice(DrBase *ch) { m_choices.append(ch); } - TQPtrList<DrBase>* choices() { return &m_choices; } - DrBase* currentChoice() const { return m_current; } - DrBase* findChoice(const TQString& txt); - void setChoice(int choicenum); - - virtual TQString valueText(); - virtual TQString prettyText(); - virtual void setValueText(const TQString& s); - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - DriverItem* createItem(DriverItem *parent, DriverItem *after = 0); - DrBase* clone(); - -protected: - TQPtrList<DrBase> m_choices; - DrBase *m_current; -}; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT DrBooleanOption : public DrListOption -{ - /* just an overloaded class, with different type */ -public: - DrBooleanOption() : DrListOption() { m_type = DrBase::Boolean; } - ~DrBooleanOption() {} -}; - -/******************** - * Constraint class * - ********************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class DrConstraint -{ -public: - DrConstraint(const TQString& o1, const TQString& o2, const TQString& c1 = TQString::null, const TQString& c2 = TQString::null); - DrConstraint(const DrConstraint&); - - bool check(DrMain*); - -protected: - QString m_opt1, m_opt2; - QString m_choice1, m_choice2; - DrListOption *m_option1, *m_option2; -}; - -/******************* - * Page Size class * - *******************/ - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class DrPageSize -{ -public: - DrPageSize(const TQString& s, float width, float height, float left, float bottom, float right, float top); - DrPageSize(const DrPageSize&); - - /** - * All dimensions are int dot: 1/72th of an inch ( PostScript ). - * When rounded, the rounding is made safely: upward for a margin, - * downward for a page size. - */ - float pageWidth() const { return m_width; } - float pageHeight() const { return m_height; } - float leftMargin() const { return m_left; } - float rightMargin() const { return m_right; } - float topMargin() const { return m_top; } - float bottomMargin() const { return m_bottom; } - TQString pageName() const { return m_name; } - - TQSize pageSize() const; - TQRect pageRect() const; - TQSize margins() const; - -protected: - QString m_name; - float m_width, m_height, m_left, m_bottom, m_right, m_top; -}; - -#endif diff --git a/kdeprint/driveritem.cpp b/kdeprint/driveritem.cpp deleted file mode 100644 index b6531fef2..000000000 --- a/kdeprint/driveritem.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "driveritem.h" -#include "driver.h" - -#include <tqpainter.h> -#include <kiconloader.h> -#include <kdebug.h> - -DriverItem::DriverItem(TQListView *parent, DrBase *item) -: TQListViewItem(parent), m_item(item), m_conflict(false) -{ - setOpen(depth() < 3); - setPixmap(0,SmallIcon("fileprint")); - updateText(); -} - -DriverItem::DriverItem(TQListViewItem *parent, TQListViewItem *after, DrBase *item) -: TQListViewItem(parent, after), m_item(item), m_conflict(false) -{ - setOpen(depth() < 3); - if (item) setPixmap(0,SmallIcon((item->isOption() ? "document" : "folder"))); - updateText(); -} - -void DriverItem::updateText() -{ - if (m_item) - { - QString s(m_item->get("text")); - if (m_item->isOption()) - s.append(TQString::tqfromLatin1(": <%1>").arg(m_item->prettyText())); - if (m_item->type() == DrBase::List) - { - // remove all children: something has changed (otherwise this - // function would not be called), so it make sense to remove - // those children in all cases. - while (firstChild()) - delete firstChild(); - DrBase *ch = static_cast<DrListOption*>(m_item)->currentChoice(); - if (ch && ch->type() == DrBase::ChoiceGroup) - { - // add new children - static_cast<DrChoiceGroup*>(ch)->createItem(this); - setOpen(true); - } - } - setText(0,s); - } - else - setText(0,"ERROR"); - widthChanged(); -} - -void DriverItem::paintCell(TQPainter *p, const TQColorGroup& cg, int, int width, int) -{ - // background - p->fillRect(0, 0, width, height(), cg.base()); - - // highlight rectangle - if (isSelected()) - p->fillRect(0, 0, /*2+p->fontMetrics().width(text(0))+(pixmap(0) ? pixmap(0)->width()+2 : 0)*/ width, height(), (m_conflict ? red : cg.highlight())); - - // draw pixmap - int w(0); - if (pixmap(0) && !pixmap(0)->isNull()) - { - int h((height()-pixmap(0)->height())/2); - p->drawPixmap(w,h,*pixmap(0)); - w += (pixmap(0)->width()+2); - } - - // draw Text - if (!m_item || !m_item->isOption() || isSelected()) - { - p->setPen((isSelected() ? cg.highlightedText() : (m_conflict ? red : cg.text()))); - p->drawText(w,0,width-w,height(),Qt::AlignLeft|Qt::AlignVCenter,text(0)); - } - else - { - int w1(0); - QString s(m_item->get("text") + ": <"); - w1 = p->fontMetrics().width(s); - p->setPen(cg.text()); - p->drawText(w,0,w1,height(),Qt::AlignLeft|Qt::AlignVCenter,s); - w += w1; - p->setPen((m_conflict ? red : darkGreen)); - s = m_item->prettyText(); - w1 = p->fontMetrics().width(s); - p->drawText(w,0,w1,height(),Qt::AlignLeft|Qt::AlignVCenter,s); - w += w1; - p->setPen(cg.text()); - s = TQString::tqfromLatin1(">"); - w1 = p->fontMetrics().width(s); - p->drawText(w,0,w1,height(),Qt::AlignLeft|Qt::AlignVCenter,s); - } -} - -bool DriverItem::updateConflict() -{ - m_conflict = false; - if (m_item) - { - if (!m_item->isOption()) - { - DriverItem *item = (DriverItem*)firstChild(); - while (item) - { - if (item->updateConflict()) - m_conflict = true; - item = (DriverItem*)item->nextSibling(); - } - } - else - { - m_conflict = (m_item->conflict()); - } - } - tqrepaint(); - return m_conflict; -} - -void DriverItem::updateTextRecursive() -{ - if ( m_item->isOption() ) - updateText(); - - DriverItem *item = static_cast<DriverItem*>( firstChild() ); - while ( item ) - { - item->updateTextRecursive(); - item = static_cast<DriverItem*>( item->nextSibling() ); - } -} diff --git a/kdeprint/driveritem.h b/kdeprint/driveritem.h deleted file mode 100644 index 506cbe34d..000000000 --- a/kdeprint/driveritem.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 DRIVERITEM_H -#define DRIVERITEM_H - -#include <tqlistview.h> - -class DrBase; - -class DriverItem : public TQListViewItem -{ -public: - DriverItem(TQListView *parent, DrBase *item); - DriverItem(TQListViewItem *parent, TQListViewItem *after, DrBase *item); - - void updateText(); - void updateTextRecursive(); - DrBase* drItem() const { return m_item; } - bool hasConflict() { return m_conflict; } - bool updateConflict(); - - void paintCell(TQPainter*, const TQColorGroup&, int, int, int); - -private: - DrBase *m_item; - bool m_conflict; -}; - -#endif diff --git a/kdeprint/driverparse.c b/kdeprint/driverparse.c deleted file mode 100644 index 2b7a93d60..000000000 --- a/kdeprint/driverparse.c +++ /dev/null @@ -1,434 +0,0 @@ -#include "driverparse.h" - -#include <string.h> -#include <dirent.h> -#include <ctype.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <dlfcn.h> -#include <unistd.h> - -char **files = NULL; -int nfiles = 0, maxfiles = 0; -int nhandlers = 0, maxhandlers = 0; -int nlibs = 0, maxlibs = 0; -typedef struct -{ - void (*init)(const char*); - int (*parse)(const char*, FILE*); - char *name; - int namelen; -} handler; -handler **handlers = NULL; -void **libs = NULL; - -void initHandlers(void) -{ - maxhandlers = 10; - handlers = (handler**)malloc(sizeof(handler*) * maxhandlers); -} - -void freeHandlers(void) -{ - int i; - for (i=0; i<nhandlers; i++) - { - free(handlers[i]->name); - free(handlers[i]); - } - free(handlers); -} - -void registerHandler(const char *name, void(*initf)(const char*), int(*parsef)(const char*, FILE*)) -{ - handler *h = (handler*)malloc(sizeof(handler)); - h->init = initf; - h->parse = parsef; - h->name = strdup(name); - h->namelen = strlen(h->name); - if (maxhandlers == 0) - initHandlers(); - if (nhandlers == maxhandlers) - { - maxhandlers += 10; - handlers = (handler**)realloc(handlers, sizeof(handler*) * maxhandlers); - } - handlers[nhandlers++] = h; -} - -void addLib(const char *filename) -{ - void *handle = dlopen(filename, RTLD_LAZY); - if (handle) - { - void(*f)(void); - if (nlibs == maxlibs) - { - maxlibs += 5; - libs = (void**)realloc(libs, sizeof(void*) * maxlibs); - } - libs[nlibs++] = handle; - f = dlsym(handle, "initialize"); - if (f) - { - (*f)(); - } - } -} - -void freeLibs(void) -{ - int i; - for (i=0; i<maxlibs; i++) - dlclose(libs[i]); - free(libs); -} - -void initFiles(void) -{ - maxfiles = 100; - files = (char**)malloc(sizeof(char*) * maxfiles); -} - -void freeFiles(void) -{ - int i; - for (i=0; i<nfiles; i++) - free(files[i]); - free(files); -} - -void checkSize(void) -{ - if (nfiles == maxfiles) - { - maxfiles += 100; - files = (char**)realloc(files, sizeof(char*) * maxfiles); - } -} - -void addFile(const char *filename) -{ - if (maxfiles == 0) - initFiles(); - checkSize(); - files[nfiles++] = strdup(filename); -} - -void nextTag(FILE *f, char *tag, int len) -{ - int p = 0; - int c; - - while (!feof(f) && fgetc(f) != '<') ; - while (!feof(f) && p < (len-1) && (c = fgetc(f)) != '>') - tag[p++] = c; - tag[p] = 0; -} - -void readValue(FILE *f, char *value, int len) -{ - char c; - int p = 0; - - while (!feof(f) && p < (len-1) && (c = fgetc(f)) != '<') - { - if (isspace(c)) - c = ' '; - value[p++] = c; - } - value[p] = 0; -} - -void readComment(FILE *f, char *comment, int len) -{ - char tag[32] = {0}; - - do nextTag(f, tag, 32); - while (tag[0] && strcmp(tag, "en") != 0 && strcmp(tag, "/comments") != 0); - if (strcmp(tag, "en") == 0) - readValue(f, comment, len); -} - -int getMaticPrinterInfos(const char *base, const char *id, char *make, char *model, char *recomm, char *comment, char *pnpmake, char *pnpmodel) -{ - char filePath[256]; - FILE *xmlFile; - char tag[32] = {0}; - int n = 0; - int in_autodetect = 0; - - snprintf(filePath, 256, "%s/%s.xml", base, id); - if ( access( filePath, F_OK ) != 0 ) - { - /* file doesn't seem to exists, see if Foomatic ID translation file can help */ - const char *c; - char ID1[ 256 ], ID2[ 256 ]; - int found = 0; - - /* Locate the actual ID part in the given "id" argument whose format is "printer/<ID>" */ - c = id; - while ( *c && *c != '/' ) - c++; - c++; - /* Translation file is usually /usr/share/foomatic/db/oldprinterids */ - snprintf( filePath, 256, "%s/../oldprinterids", base ); - if ( ( xmlFile = fopen( filePath, "r" ) ) == NULL ) - return 0; - /* Look for possible translated ID */ - while ( !feof( xmlFile ) ) - { - if ( fscanf( xmlFile, "%256s %256s", ID1, ID2 ) == 2 ) - { - if ( strcmp( c, ID1 ) == 0 ) - { - snprintf( filePath, 256, "%s/printer/%s.xml", base, ID2 ); - found = 1; - break; - } - } - else - break; - } - fclose( xmlFile ); - if ( !found ) - return 0; - } - xmlFile = fopen(filePath, "r"); - if (xmlFile == NULL) - return 0; - while (!feof(xmlFile) && n < 6) - { - tag[0] = 0; - nextTag(xmlFile, tag, 32); - if (tag[0]) - { - char *c; - - if ( strcmp( tag, "autodetect" ) == 0 ) - { - in_autodetect = 1; - continue; - } - else if ( strcmp( tag, "/autodetect" ) == 0 ) - { - in_autodetect = 0; - continue; - } - else if (!make[0] && strcmp(tag, "make") == 0) - c = make; - else if (strcmp(tag, "model") == 0) - { - if ( in_autodetect && !pnpmodel[ 0 ] ) - c = pnpmodel; - else if ( !in_autodetect && !model[ 0 ] ) - c = model; - else - continue; - } - else if ( !pnpmake[0] && in_autodetect && strcmp( tag, "manufacturer" ) == 0 ) - c = pnpmake; - else if (!recomm[0] && strcmp(tag, "driver") == 0) - c = recomm; - else if (comment && !comment[0] && strcmp(tag, "comments") == 0) - { - readComment(xmlFile, comment, 4096); - n++; - continue; - } - else - continue; - n++; - readValue(xmlFile, c, 64); - } - } - fclose(xmlFile); - return 1; -} - -int parseMaticFile(const char *driver, FILE *output) -{ - FILE *drFile; - char name[32] = {0}, - make[64] = {0}, - model[64] = {0}, - tag[32] = {0}, - recomm[64] = {0}, - comment[4096] = {0}, - comment2[4096] = {0}, - pnpmake[64] = {0}, - pnpmodel[64] = {0}; - char id[128]; - char path[256], *c; - - drFile = fopen(driver, "r"); - if (drFile == NULL) - return 0; - strncpy(path, driver, 255); - path[ 255 ] = '\0'; - if ((c = strstr(path, "/driver/")) != NULL) - *c = 0; - c = comment; - while (!feof(drFile)) - { - tag[0] = 0; - nextTag(drFile, tag, 32); - if (tag[0]) - { - if (strcmp(tag, "name") == 0) - readValue(drFile, name, 32); - else if (strcmp(tag, "comments") == 0) - readComment(drFile, c, 4096); - else if (strcmp(tag, "printers") == 0) - c = comment2; - else if (strcmp(tag, "printer") == 0) - { - id[0] = 0; - comment2[0] = 0; - } - else if (strcmp(tag, "id") == 0) - readValue(drFile, id, 128); - else if (strcmp(tag, "/printer") == 0 && id[0]) - { - fprintf(output, "FILE=foomatic/%s/%s\n", id+8, name); - make[0] = 0; - model[0] = 0; - recomm[0] = 0; - pnpmake[0] = 0; - pnpmodel[0] = 0; - getMaticPrinterInfos(path, id, make, model, recomm, NULL, pnpmake, pnpmodel); - fprintf(output, "MANUFACTURER=%s\n", make); - fprintf(output, "MODELNAME=%s\n", model); - fprintf(output, "MODEL=%s\n", model); - fprintf(output, "DESCRIPTION=%s %s (Foomatic + %s)\n", make, model, name); - if (recomm[0] && strcmp(name, recomm) == 0) - fprintf(output, "RECOMMANDED=yes\n"); - if (comment[0] || comment2[0]) - { - fprintf(output, "DRIVERCOMMENT="); - if (comment2[0]) - { - fprintf(output, "<h3>Printer note</h3>%s", comment2); - } - if (comment[0]) - fprintf(output, "<h3>General driver note</h3>%s", comment); - fprintf(output, "\n"); - } - if ( pnpmake[0] ) - fprintf( output, "PNPMANUFACTURER=%s\n", pnpmake ); - if ( pnpmodel[0] ) - fprintf( output, "PNPMODEL=%s\n", pnpmodel ); - fprintf(output, "\n"); - } - else if (strcmp(tag, "/printers") == 0) - break; - } - } - fclose(drFile); - return 1; -} - -void initMatic(const char *base) -{ - char drPath[256]; - char drFile[256]; - DIR *foodir; - struct dirent *d; - struct stat st; - - if (strstr(base, "foomatic") == NULL) - return; - - snprintf(drPath, 256, "%s/driver", base); - foodir = opendir(drPath); - if (foodir == NULL) - return; - while ((d = readdir(foodir)) != NULL) - { - snprintf(drFile, 256, "foomatic:%s/%s", drPath, d->d_name); - if (stat(drFile+9, &st) != 0) - continue; - else if (!S_ISREG(st.st_mode)) - continue; - addFile(drFile); - } - closedir(foodir); -} - -void initFoomatic(void) -{ - registerHandler("foomatic:", initMatic, parseMaticFile); -} - -int execute(int argc, char *argv[]) -{ - FILE *dbFile; - int i; - char *c, *d; - - /* open output driver DB file */ - if (argc < 2 || argc > 3) - { - fprintf(stderr, "usage: make_driver_db <db_directory> [output_filename]\n"); - return -1; - } - if (argc == 3) - { - dbFile = fopen(argv[2], "w"); - if (dbFile == NULL) - { - fprintf(stderr, "unable to open DB file for writing\n"); - return -1; - } - } - else - dbFile = stdout; - - /* init parsing */ - c = argv[1]; - do - { - d = strchr(c, ':'); - if (d != NULL) - *d = 0; - if (strncmp(c, "module:", 7) == 0) - { - addLib(c+7); - } - else - { - for (i=0; i<nhandlers; i++) - { - (*(handlers[i]->init))(c); - } - } - if (d != NULL) - c = d+1; - } while (d && *c); - - - /* do actual parsing */ - fprintf(stdout, "%d\n", nfiles); - fflush(stdout); - for (i=0; i<nfiles; i++) - { - int hi; - for (hi=0; hi<nhandlers; hi++) - if (strncmp(files[i], handlers[hi]->name, handlers[hi]->namelen) == 0) - { - handlers[hi]->parse(files[i]+handlers[hi]->namelen, dbFile); - break; - } - fprintf(stdout, "%d\n", i); - fflush(stdout); - } - - /* free everything */ - freeFiles(); - freeHandlers(); - freeLibs(); - if (dbFile != stdout) - fclose(dbFile); - - return 0; -} diff --git a/kdeprint/driverparse.h b/kdeprint/driverparse.h deleted file mode 100644 index 775c81187..000000000 --- a/kdeprint/driverparse.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 DRIVERPARSE_H -#define DRIVERPARSE_H - -#include <stdio.h> - -void registerHandler(const char *name, void(*initf)(const char*), int(*parsef)(const char*, FILE*)); -void initFoomatic(void); -int execute(int argc, char *argv[]); -void addFile(const char *filename); - -#endif diff --git a/kdeprint/driverview.cpp b/kdeprint/driverview.cpp deleted file mode 100644 index f7feabb06..000000000 --- a/kdeprint/driverview.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "driverview.h" -#include "droptionview.h" -#include "driveritem.h" -#include "driver.h" - -#include <tqlistview.h> -#include <tqsplitter.h> -#include <tqheader.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <klocale.h> - -DrListView::DrListView(TQWidget *parent, const char *name) -: KListView(parent,name) -{ - addColumn(""); - header()->hide(); - setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - setSorting(-1); -} - -//**************************************************************************************************** - -DriverView::DriverView(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisPPDOptionsDriverPage = i18n( " <qt> " - " <b>List of Driver Options (from PPD)</b>. " - " <p>The upper pane of this dialog page contains all printjob options as laid " - " down in the printer's description file (PostScript Printer Description == 'PPD') </p>" - " <p>Click on any item in the list and watch the lower pane of this dialog page " - " display the available values. </p> " - " <p>Set the values as needed. Then use one of the pushbuttons below to proceed:</p> " - " <ul> " - " <li><em>'Save'</em> your settings if you want to re-use " - " them in your next job(s) too. <em>'Save'</em> will store your settings permanently until " - " you change them again. </li>." - " <li>Click <em>'OK'</em> (without a prior click on <em>'Save'</em>, if you want to use " - " your selected settings just once, for the next print job. <em>'OK'</em> " - " will forget your current settings when kprinter is closed again, and will start next time " - " with the previously saved defaults. </li>" - " <li><em>'Cancel'</em> will not change anything. If you proceed to print after clicking " - " <em>'Cancel'</em>, the job will print with the default settings of this queue. " - " </ul>" - " <p><b>Note.</b> The number of available job options depends strongly on the actual " - " driver used for your print queue. <em>'Raw'</em> queues do not have a driver or a " - " PPD. For raw queues this tab page is not loaded by KDEPrint, and thus is not present " - " in the kprinter dialog.</p> " - " </qt>" ); - - TQString whatsThisOptionSettingsDriverPage = i18n( " <qt> " - " <b>List of Possible Values for given Option (from PPD)</b>. " - " <p>The lower pane of this dialog page contains all possible values of the printoption " - " highlighted above, as laid " - " down in the printer's description file (PostScript Printer Description == 'PPD') </p>" - " <p>Select the value you want and proceed. </p> " - " <p>Then use one of the pushbuttons below to leave this dialog:</p> " - " <ul> " - " <li><em>'Save'</em> your settings if you want to re-use " - " them in your next job(s) too. <em>'Save'</em> will store your settings permanently until " - " you change them again. </li>." - " <li>Click <em>'OK'</em> if you want to use your selected settings just once, for the " - " next print job. <em>'OK'</em> " - " will forget your current settings when kprinter is closed again, and will start next time " - " with your previous defaults. </li>" - " <li><em>'Cancel'</em> will not change anything. If you proceed to print after clicking " - " <em>'Cancel'</em>, the job will print with the default settings of this queue. " - " </ul>" - " <p><b>Note.</b> The number of available job options depends strongly on the actual " - " driver used for your print queue. <em>'Raw'</em> queues do not have a driver or a " - " PPD. For raw queues this tab page is not loaded by KDEPrint, and thus is not present " - " in the kprinter dialog.</p> " - " </qt>" ); - - m_driver = 0; - - TQSplitter *splitter = new TQSplitter(this); - splitter->setOrientation(Qt::Vertical); - - TQVBoxLayout *vbox = new TQVBoxLayout(this, 0, 10); - vbox->addWidget(splitter); - - m_view = new DrListView(splitter); - TQWhatsThis::add(m_view, whatsThisPPDOptionsDriverPage); - m_optview = new DrOptionView(splitter); - TQWhatsThis::add(m_optview, whatsThisOptionSettingsDriverPage); - - connect(m_view,TQT_SIGNAL(selectionChanged(TQListViewItem*)),m_optview,TQT_SLOT(slotItemSelected(TQListViewItem*))); - connect(m_optview,TQT_SIGNAL(changed()),TQT_SLOT(slotChanged())); -} - -DriverView::~DriverView() -{ -} - -void DriverView::setDriver(DrMain *driver) -{ - m_driver = driver; - if (m_driver) - { - m_view->clear(); - m_driver->createTreeView(m_view); - slotChanged(); - } -} - -void DriverView::slotChanged() -{ - if (m_driver) - { - m_conflict = m_driver->checkConstraints(); - ((DriverItem*)m_view->firstChild())->updateConflict(); - } -} - -void DriverView::setOptions(const TQMap<TQString,TQString>& opts) -{ - if (m_driver) - { - m_driver->setOptions(opts); - static_cast<DriverItem*>( m_view->firstChild() )->updateTextRecursive(); - slotChanged(); - m_optview->slotItemSelected(m_view->currentItem()); - } -} - -void DriverView::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - if (m_driver) - m_driver->getOptions(opts,incldef); -} - -void DriverView::setAllowFixed(bool on) -{ - m_optview->setAllowFixed(on); -} -#include "driverview.moc" diff --git a/kdeprint/driverview.h b/kdeprint/driverview.h deleted file mode 100644 index 4ec06c5fa..000000000 --- a/kdeprint/driverview.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 DRIVERVIEW_H -#define DRIVERVIEW_H - -#include <tqwidget.h> -#include <klistview.h> -#include <tqmap.h> - -#include <kdelibs_export.h> - -class DrOptionView; -class DrMain; - -class KDEPRINT_EXPORT DrListView : public KListView -{ -public: - DrListView(TQWidget *parent = 0, const char *name = 0); -}; - -class KDEPRINT_EXPORT DriverView : public TQWidget -{ - Q_OBJECT -public: - DriverView(TQWidget *parent = 0, const char *name = 0); - ~DriverView(); - - void setDriver(DrMain*); - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - void setAllowFixed(bool on); - bool hasConflict() const { return (m_conflict != 0); } - -protected slots: - void slotChanged(); - -private: - DrListView *m_view; - DrOptionView *m_optview; - DrMain *m_driver; - int m_conflict; -}; - -#endif diff --git a/kdeprint/droptionview.cpp b/kdeprint/droptionview.cpp deleted file mode 100644 index 2ba4d1799..000000000 --- a/kdeprint/droptionview.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "droptionview.h" -#include "driver.h" -#include "driveritem.h" - -#include <math.h> -#include <tqlineedit.h> -#include <tqslider.h> -#include <tqlabel.h> -#include <klistbox.h> -#include <tqvbuttongroup.h> -#include <tqradiobutton.h> -#include <tqwidgetstack.h> -#include <tqlayout.h> -#include <tqapplication.h> - -#include <kcursor.h> -#include <kdialog.h> -#include <klocale.h> - -OptionBaseView::OptionBaseView(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - blockSS = false; -} - -void OptionBaseView::setOption(DrBase*) -{ -} - -void OptionBaseView::setValue(const TQString&) -{ -} - -//****************************************************************************************************** - -OptionNumericView::OptionNumericView(TQWidget *parent, const char *name) -: OptionBaseView(parent,name) -{ - m_edit = new TQLineEdit(this); - m_slider = new TQSlider(Qt::Horizontal,this); - m_slider->setTickmarks(TQSlider::Below); - TQLabel *lab = new TQLabel(i18n("Value:"),this); - m_minval = new TQLabel(this); - m_maxval = new TQLabel(this); - - m_integer = true; - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); - TQHBoxLayout *sub_ = new TQHBoxLayout(0, 0, 10); - TQHBoxLayout *sub2_ = new TQHBoxLayout(0, 0, 5); - main_->addStretch(1); - main_->addLayout(sub_,0); - main_->addLayout(sub2_,0); - main_->addStretch(1); - sub_->addWidget(lab,0); - sub_->addWidget(m_edit,0); - sub_->addStretch(1); - sub2_->addWidget(m_minval,0); - sub2_->addWidget(m_slider,1); - sub2_->addWidget(m_maxval,0); - - connect(m_slider,TQT_SIGNAL(valueChanged(int)),TQT_SLOT(slotSliderChanged(int))); - connect(m_edit,TQT_SIGNAL(textChanged(const TQString&)),TQT_SLOT(slotEditChanged(const TQString&))); -} - -void OptionNumericView::setOption(DrBase *opt) -{ - if (opt->type() != DrBase::Integer && opt->type() != DrBase::Float) - return; - - blockSS = true; - if (opt->type() == DrBase::Integer) - { - m_integer = true; - int min_ = opt->get("minval").toInt(); - int max_ = opt->get("maxval").toInt(); - m_slider->setRange(min_,max_); - m_slider->setSteps(1,QMAX((max_-min_)/20,1)); - m_minval->setText(TQString::number(min_)); - m_maxval->setText(TQString::number(max_)); - } - else - { - m_integer = false; - int min_ = (int)rint(opt->get("minval").toFloat()*1000); - int max_ = (int)rint(opt->get("maxval").toFloat()*1000); - m_slider->setRange(min_,max_); - m_slider->setSteps(1,QMAX((max_-min_)/20,1)); - m_minval->setText(opt->get("minval")); - m_maxval->setText(opt->get("maxval")); - } - m_slider->update(); - blockSS = false; - - setValue(opt->valueText()); -} - -void OptionNumericView::setValue(const TQString& val) -{ - m_edit->setText(val); -} - -void OptionNumericView::slotSliderChanged(int value) -{ - if (blockSS) return; - - QString txt; - if (m_integer) - txt = TQString::number(value); - else - txt = TQString::number(float(value)/1000.0,'f',3); - blockSS = true; - m_edit->setText(txt); - blockSS = false; - emit valueChanged(txt); -} - -void OptionNumericView::slotEditChanged(const TQString& txt) -{ - if (blockSS) return; - - bool ok(false); - int val(0); - if (m_integer) - val = txt.toInt(&ok); - else - val = (int)rint(txt.toFloat(&ok)*1000); - if (ok) - { - blockSS = true; - m_slider->setValue(val); - blockSS = false; - emit valueChanged(txt); - } - else - { - m_edit->selectAll(); - TQApplication::beep(); - } -} - -//****************************************************************************************************** - -OptionStringView::OptionStringView(TQWidget *parent, const char *name) -: OptionBaseView(parent,name) -{ - m_edit = new TQLineEdit(this); - TQLabel *lab = new TQLabel(i18n("String value:"),this); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 5); - main_->addStretch(1); - main_->addWidget(lab,0); - main_->addWidget(m_edit,0); - main_->addStretch(1); - - connect(m_edit,TQT_SIGNAL(textChanged(const TQString&)),TQT_SIGNAL(valueChanged(const TQString&))); -} - -void OptionStringView::setOption(DrBase *opt) -{ - if (opt->type() == DrBase::String) - m_edit->setText(opt->valueText()); -} - -void OptionStringView::setValue(const TQString& val) -{ - m_edit->setText(val); -} - -//****************************************************************************************************** - -OptionListView::OptionListView(TQWidget *parent, const char *name) -: OptionBaseView(parent,name) -{ - m_list = new KListBox(this); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); - main_->addWidget(m_list); - - connect(m_list,TQT_SIGNAL(selectionChanged()),TQT_SLOT(slotSelectionChanged())); -} - -void OptionListView::setOption(DrBase *opt) -{ - if (opt->type() == DrBase::List) - { - blockSS = true; - m_list->clear(); - m_choices.clear(); - TQPtrListIterator<DrBase> it(*(((DrListOption*)opt)->choices())); - for (;it.current();++it) - { - m_list->insertItem(it.current()->get("text")); - m_choices.append(it.current()->name()); - } - blockSS = false; - setValue(opt->valueText()); - } -} - -void OptionListView::setValue(const TQString& val) -{ - m_list->setCurrentItem(m_choices.findIndex(val)); -} - -void OptionListView::slotSelectionChanged() -{ - if (blockSS) return; - - QString s = m_choices[m_list->currentItem()]; - emit valueChanged(s); -} - -//****************************************************************************************************** - -OptionBooleanView::OptionBooleanView(TQWidget *parent, const char *name) -: OptionBaseView(parent,name) -{ - m_group = new TQVButtonGroup(this); - m_group->setFrameStyle(TQFrame::NoFrame); - - TQRadioButton *btn = new TQRadioButton(m_group); - btn->setCursor(KCursor::handCursor()); - btn = new TQRadioButton(m_group); - btn->setCursor(KCursor::handCursor()); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); - main_->addWidget(m_group); - - connect(m_group,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotSelected(int))); -} - -void OptionBooleanView::setOption(DrBase *opt) -{ - if (opt->type() == DrBase::Boolean) - { - TQPtrListIterator<DrBase> it(*(((DrBooleanOption*)opt)->choices())); - m_choices.clear(); - static_cast<TQButton*>(m_group->find(0))->setText(it.toFirst()->get("text")); - m_choices.append(it.toFirst()->name()); - static_cast<TQButton*>(m_group->find(1))->setText(it.toLast()->get("text")); - m_choices.append(it.toLast()->name()); - setValue(opt->valueText()); - } -} - -void OptionBooleanView::setValue(const TQString& val) -{ - int ID = m_choices.findIndex(val); - m_group->setButton(ID); -} - -void OptionBooleanView::slotSelected(int ID) -{ - TQString s = m_choices[ID]; - emit valueChanged(s); -} - -//****************************************************************************************************** - -DrOptionView::DrOptionView(TQWidget *parent, const char *name) -: TQGroupBox(parent,name) -{ - m_stack = new TQWidgetStack(this); - - OptionBaseView *w = new OptionListView(m_stack); - connect(w,TQT_SIGNAL(valueChanged(const TQString&)),TQT_SLOT(slotValueChanged(const TQString&))); - m_stack->addWidget(w,DrBase::List); - - w = new OptionStringView(m_stack); - connect(w,TQT_SIGNAL(valueChanged(const TQString&)),TQT_SLOT(slotValueChanged(const TQString&))); - m_stack->addWidget(w,DrBase::String); - - w = new OptionNumericView(m_stack); - connect(w,TQT_SIGNAL(valueChanged(const TQString&)),TQT_SLOT(slotValueChanged(const TQString&))); - m_stack->addWidget(w,DrBase::Integer); - - w = new OptionBooleanView(m_stack); - connect(w,TQT_SIGNAL(valueChanged(const TQString&)),TQT_SLOT(slotValueChanged(const TQString&))); - m_stack->addWidget(w,DrBase::Boolean); - - w = new OptionBaseView(m_stack); - connect(w,TQT_SIGNAL(valueChanged(const TQString&)),TQT_SLOT(slotValueChanged(const TQString&))); - m_stack->addWidget(w,0); // empty widget - - m_stack->raiseWidget(w); - setTitle(i18n("No Option Selected")); - - setColumnLayout(0, Qt::Vertical ); - layout()->setSpacing( KDialog::spacingHint() ); - layout()->setMargin( KDialog::marginHint() ); - TQVBoxLayout *main_ = new TQVBoxLayout(TQT_TQLAYOUT(layout()), KDialog::marginHint()); - main_->addWidget(m_stack); - - m_item = 0; - m_block = false; - m_allowfixed = true; -} - -void DrOptionView::slotItemSelected(TQListViewItem *i) -{ - m_item = (DriverItem*)i; - if (m_item && !m_item->drItem()->isOption()) - m_item = 0; - int ID(0); - if (m_item) - if (m_item->drItem()->type() == DrBase::Float) ID = DrBase::Integer; - else ID = m_item->drItem()->type(); - - OptionBaseView *w = (OptionBaseView*)m_stack->widget(ID); - if (w) - { - m_block = true; - bool enabled(true); - if (m_item) - { - w->setOption((m_item ? m_item->drItem() : 0)); - setTitle(m_item->drItem()->get("text")); - enabled = ((m_item->drItem()->get("fixed") != "1") || m_allowfixed); - } - else - setTitle(i18n("No Option Selected")); - m_stack->raiseWidget(w); - w->setEnabled(enabled); - m_block = false; - } -} - -void DrOptionView::slotValueChanged(const TQString& val) -{ - if (m_item && m_item->drItem() && !m_block) - { - m_item->drItem()->setValueText(val); - m_item->updateText(); - emit changed(); - } -} - -#include "droptionview.moc" diff --git a/kdeprint/droptionview.h b/kdeprint/droptionview.h deleted file mode 100644 index 70f60a814..000000000 --- a/kdeprint/droptionview.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 DROPTIONVIEW_H -#define DROPTIONVIEW_H - -#include <tqwidget.h> -#include <tqgroupbox.h> -#include <tqstringlist.h> - -class TQLineEdit; -class TQSlider; -class TQLabel; -class KListBox; -class TQListBoxItem; -class TQVButtonGroup; -class TQWidgetStack; -class TQListViewItem; -class DrBase; -class DriverItem; - -class OptionBaseView : public TQWidget -{ - Q_OBJECT -public: - OptionBaseView(TQWidget *parent = 0, const char *name = 0); - virtual void setOption(DrBase*); - virtual void setValue(const TQString&); - -signals: - void valueChanged(const TQString&); - -protected: - bool blockSS; -}; - -class OptionNumericView : public OptionBaseView -{ - Q_OBJECT -public: - OptionNumericView(TQWidget *parent = 0, const char *name = 0); - void setOption(DrBase *opt); - void setValue(const TQString& val); - -protected slots: - void slotSliderChanged(int); - void slotEditChanged(const TQString&); - -private: - TQLineEdit *m_edit; - TQSlider *m_slider; - TQLabel *m_minval, *m_maxval; - bool m_integer; -}; - -class OptionStringView : public OptionBaseView -{ -public: - OptionStringView(TQWidget *parent = 0, const char *name = 0); - void setOption(DrBase *opt); - void setValue(const TQString& val); - -private: - TQLineEdit *m_edit; -}; - -class OptionListView : public OptionBaseView -{ - Q_OBJECT -public: - OptionListView(TQWidget *parent = 0, const char *name = 0); - void setOption(DrBase *opt); - void setValue(const TQString& val); - -protected slots: - void slotSelectionChanged(); - -private: - KListBox *m_list; - TQStringList m_choices; -}; - -class OptionBooleanView : public OptionBaseView -{ - Q_OBJECT -public: - OptionBooleanView(TQWidget *parent = 0, const char *name = 0); - void setOption(DrBase *opt); - void setValue(const TQString& val); - -protected slots: - void slotSelected(int); - -private: - TQVButtonGroup *m_group; - TQStringList m_choices; -}; - -class DrOptionView : public TQGroupBox -{ - Q_OBJECT -public: - DrOptionView(TQWidget *parent = 0, const char *name = 0); - void setAllowFixed(bool on) { m_allowfixed = on; } - -signals: - void changed(); - -public slots: - void slotValueChanged(const TQString&); - void slotItemSelected(TQListViewItem*); - -private: - TQWidgetStack *m_stack; - DriverItem *m_item; - bool m_block; - bool m_allowfixed; -}; - -#endif diff --git a/kdeprint/ext/CMakeLists.txt b/kdeprint/ext/CMakeLists.txt deleted file mode 100644 index 9f4b2d629..000000000 --- a/kdeprint/ext/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/tdeprint -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES ext.print DESTINATION ${DATA_INSTALL_DIR}/tdeprint/plugins ) - - -##### tdeprint_ext ############################## - -set( target tdeprint_ext ) - -set( ${target}_SRCS - kmextfactory.cpp kmextmanager.cpp kextprinterimpl.cpp - kmextuimanager.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) diff --git a/kdeprint/ext/Makefile.am b/kdeprint/ext/Makefile.am deleted file mode 100644 index 66e547c9d..000000000 --- a/kdeprint/ext/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/tdeprint $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_ext.la - -tdeprint_ext_la_SOURCES = kmextfactory.cpp kmextmanager.cpp kextprinterimpl.cpp kmextuimanager.cpp -tdeprint_ext_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_ext_la_LIBADD = $(LIB_KDEPRINT) $(LIB_QT) $(LIB_KDECORE) -tdeprint_ext_la_METASOURCES = AUTO - -noinst_HEADERS = kmextmanager.h kextprinterimpl.h kmextuimanager.h - -entry_DATA = ext.print -entrydir = $(kde_datadir)/tdeprint/plugins diff --git a/kdeprint/ext/ext.print b/kdeprint/ext/ext.print deleted file mode 100644 index ce300e5ae..000000000 --- a/kdeprint/ext/ext.print +++ /dev/null @@ -1,84 +0,0 @@ -[KDE Print Entry] -PrintSystem=ext -Comment=Print Through an External Program (generic) -Comment[af]=Druk Deur 'n Eksterne Program (generies) -Comment[ar]=اطبع من خلال برنامج خارجي (شائع) -Comment[az]=Xarici Proqram VasitÉ™silÉ™ Çap Et (ümumi) -Comment[be]=Друкаваць праз вонкавую праграму (прадвызначана) -Comment[bn]=বহিঃসà§à¦¥ পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à§‡à¦° (generic) সাহাযà§à¦¯à§‡ ছাপানো হোক -Comment[bs]=Å tampajte pomoću eksternog programa (generic) -Comment[ca]=Impressió mitjançant un programa extern (genèric) -Comment[cs]=Tisk pomocí externího programu (obecné) -Comment[csb]=Drëkùjë brëkùjÄ…c bùtnowi programë -Comment[cy]=Argraffu drwy Raglen Allanol (cyffredinol) -Comment[da]=Udskriv gennem et eksternt program (generisk) -Comment[de]=Ãœber externes Programm drucken -Comment[el]=ΕκτÏπωση μέσω ενός εξωτεÏÎ¹ÎºÎ¿Ï Ï€ÏογÏάμματος (γενικό) -Comment[eo]=Presi per ekstera programo (Äenerala) -Comment[es]=Imprime a través de un programa externo (genérico) -Comment[et]=Trükkimine läbi välise rakenduse (üldine) -Comment[eu]=Inprimatu kanpoko programa bat erabiliz (orokorra) -Comment[fa]=چاپ از طریق یک برنامۀ خارجی)عمومی( -Comment[fi]=Tulosta ulkoisen sovelluksen kautta (yleinen) -Comment[fr]=Imprimer via un programme externe (générique) -Comment[fy]=Printsje mei help fan een ekstern programma (algemien) -Comment[ga]=Priontáil trí chlár eachtrach (cineálach) -Comment[gl]=Imprimir Mediante un Programa Externo (xenérico) -Comment[he]=הדפסה ב×מצעות תוכנית חיצונית -Comment[hi]=à¤à¤• बाहरी पà¥à¤°à¥‹à¤—à¥à¤°à¤¾à¤® के दà¥à¤µà¤¾à¤°à¤¾ छापें(जेनरिक) -Comment[hr]=Ispis putem vanjskog programa (generiÄki) -Comment[hsb]=pÅ™ez eksterny program ćišćeć (generisce) -Comment[hu]=KülsÅ‘ nyomtatóprogram -Comment[id]=Cetak dengan Program Eksternal (generik) -Comment[is]=Prenta í gegnum utanaðkomandi forrit (almennt) -Comment[it]=Stampa attraverso un programma esterno (generico) -Comment[ja]=外部プログラムを通ã—ã¦å°åˆ· (一般的) -Comment[ka]=ბეჭდვრგáƒáƒ áƒ” პრáƒáƒ’რáƒáƒ›áƒ˜áƒ“áƒáƒœ (სáƒáƒ–áƒáƒ’áƒáƒ“áƒ) -Comment[kk]=Сыртқы жалпы бағдарлама арқылы баÑып шығару -Comment[km]=បោះពុម្ព​ážáž¶áž˜â€‹ážšáž™áŸˆâ€‹áž€áž˜áŸ’មវិធី​ážáž¶áž„​ក្រៅ​មួយ (ទូទៅ) -Comment[ko]=바깥 í”„ë¡œê·¸ëž¨ì„ í†µí•´ ì¸ì‡„ (ì¼ë°˜) -Comment[lb]=Duerch en externe Programm drécken (allgemeng) -Comment[lt]=Spausdinti naudojant iÅ¡orinÄ™ programÄ… (bendra) -Comment[lv]=DrukÄt caur ÄrÄ“ju programmu (vispÄrÄ“ji) -Comment[mk]=Печатење преку надворешен програм (општо) -Comment[mn]=Гадаад программаар дамжуулан Ñ…ÑвлÑÑ… -Comment[ms]=Cetak Melalui Program Luaran (biasa) -Comment[mt]=Printja permezz ta' programm estern (Ä¡eneriku) -Comment[nb]=Skriv ut gjennom et eksternt program (generisk) -Comment[nds]=Över extern Programm drucken -Comment[ne]=बाहà¥à¤¯ कारà¥à¤¯à¤•à¥à¤°à¤® (जेनेरिक) बाट मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ -Comment[nl]=Afdrukken met behulp van een extern programma (algemeen) -Comment[nn]=Skriv ut gjennom eit eksternt program (generelt) -Comment[nso]=Gatisetsa go Lenaneo la Kantle (kakaretso) -Comment[pa]=ਬਾਹਰੀ ਕਾਰਜ ਨਾਲ ਛਪਾਈ (ਸਧਾਰਨ) -Comment[pl]=Drukuj używajÄ…c zewnÄ™trznego programu -Comment[pt]=Imprimir através dum programa externo (genérico) -Comment[pt_BR]=Imprime através de um programa externo (genérico) -Comment[ro]=TipăreÅŸte prin intermediul unui program extern (generic) -Comment[ru]=Печать поÑредÑтвом внешней программы (общаÑ) -Comment[rw]=Gucapa uciye muri Porogaramu y'Inyuma (rusange) -Comment[se]=Čálit olggoldas prográmma bokte (oppalaÅ¡) -Comment[sk]=TlaÄ pomocou externého programu (generické) -Comment[sl]=Tiskanje skozi zunanji program (sploÅ¡no) -Comment[sq]=Shtyp përmes një programi të jashtëm (përgjithshëm) -Comment[sr]=Штампање преко Ñпољњег програма (генерички) -Comment[sr@Latn]=Å tampanje preko spoljnjeg programa (generiÄki) -Comment[ss]=Shicelela ngekusebentisa luhlelo lwangaphandle (banti) -Comment[sv]=Skriv ut genom ett externt program (generellt) -Comment[ta]=ஒர௠பà¯à®± நிரலை à®®à¯à®´à¯à®µà®¤à¯à®®à¯ அசà¯à®šà®¿à®Ÿà®µà¯à®®à¯ (பொதà¯) -Comment[te]=బయటి కారà±à°¯à°®à± (సాధరణ) à°¦à±à°µà°¾à°°à°¾ à°ªà±à°°à°šà±à°°à°¿à°‚à°šà± -Comment[tg]=Чоп ба воÑитаи барномаи зоҳирӣ (умумӣ) -Comment[th]=พิมพ์ผ่านโปรà¹à¸à¸£à¸¡à¸ à¸²à¸¢à¸™à¸­à¸ (โปรà¹à¸à¸£à¸¡à¸—ั่วไป) -Comment[tr]=Harici program kullanarak yazdır (genel) -Comment[tt]=Tışqı Yazılım aÅŸa Bastıru (töp) -Comment[uk]=Друк через зовнішню програму (загальна) -Comment[uz]=Tashqi dastur yordamida bosib chiqarish (umumiy) -Comment[uz@cyrillic]=Ташқи даÑтур ёрдамида боÑиб чиқариш (умумий) -Comment[ven]=Phirinthani nga Mbekanyamushumo yanga nnda (tshigwada) -Comment[vi]=In bằng má»™t chÆ°Æ¡ng trình bên ngoài (giống loài). -Comment[wa]=Imprimer Ã¥d truviè d' on dfoûtrin programe (djenerike) -Comment[xh]=Shicilela Ngapha Kodweliso lwenkqubo olungaphandle (ngokubanzi) -Comment[zh_CN]=通过外部程åºæ‰“å°(通用) -Comment[zh_HK]=使用外部程å¼é€²è¡Œåˆ—å° (通用) -Comment[zh_TW]=使用外部程å¼é€²è¡Œåˆ—å° (一般) -Comment[zu]=Shicilela Ngokwedlulela Kuhlelo lwemisebenzi Langaphandle (okukawonke wonke) diff --git a/kdeprint/ext/kextprinterimpl.cpp b/kdeprint/ext/kextprinterimpl.cpp deleted file mode 100644 index c976f54e0..000000000 --- a/kdeprint/ext/kextprinterimpl.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kextprinterimpl.h" -#include "kprinter.h" - -#include <tqfile.h> -#include <kstandarddirs.h> -#include <kconfig.h> -#include <klocale.h> - -KExtPrinterImpl::KExtPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ -} - -KExtPrinterImpl::~KExtPrinterImpl() -{ -} - -void KExtPrinterImpl::preparePrinting(KPrinter *printer) -{ - printer->setOption("kde-qtcopies",TQString::number(printer->numCopies())); -} - -bool KExtPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - cmd = printer->option("kde-printcommand").stripWhiteSpace(); - if (cmd.isEmpty()) - { - printer->setErrorMessage(i18n("Empty print command.")); - return false; - } - - return true; -} diff --git a/kdeprint/ext/kextprinterimpl.h b/kdeprint/ext/kextprinterimpl.h deleted file mode 100644 index 169e06bf4..000000000 --- a/kdeprint/ext/kextprinterimpl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KEXTPRINTERIMPL_H -#define KEXTPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KExtPrinterImpl : public KPrinterImpl -{ -public: - KExtPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KExtPrinterImpl(); - - void preparePrinting(KPrinter*); - bool setupCommand(TQString&, KPrinter*); -}; - -#endif diff --git a/kdeprint/ext/kmextfactory.cpp b/kdeprint/ext/kmextfactory.cpp deleted file mode 100644 index de8c58dfe..000000000 --- a/kdeprint/ext/kmextfactory.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmextmanager.h" -#include "kmextuimanager.h" -#include "kextprinterimpl.h" - -#include <kgenericfactory.h> - -typedef K_TYPELIST_3( KMExtManager, KMExtUiManager, KExtPrinterImpl ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_ext, KGenericFactory< Products > ) - diff --git a/kdeprint/ext/kmextmanager.cpp b/kdeprint/ext/kmextmanager.cpp deleted file mode 100644 index 598dd6648..000000000 --- a/kdeprint/ext/kmextmanager.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmextmanager.h" -#include "kmprinter.h" - -#include <klocale.h> - -KMExtManager::KMExtManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - setHasManagement(false); - m_psprinter = 0; -} - -KMExtManager::~KMExtManager() -{ -} - -void KMExtManager::listPrinters() -{ - if (!m_psprinter) - { - m_psprinter = new KMPrinter; - m_psprinter->setName(i18n("PS_printer")); - m_psprinter->setPrinterName(m_psprinter->name()); - m_psprinter->setDescription(i18n("PostScript file generator")); - m_psprinter->setState(KMPrinter::Idle); - addPrinter(m_psprinter); - } - else - m_psprinter->setDiscarded(false); -} diff --git a/kdeprint/ext/kmextmanager.h b/kdeprint/ext/kmextmanager.h deleted file mode 100644 index c7faab6cf..000000000 --- a/kdeprint/ext/kmextmanager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMEXTMANAGER_H -#define KMEXTMANAGER_H - -#include "kmmanager.h" -#include <tqdict.h> -#include <tqdatetime.h> - -class KMExtManager : public KMManager -{ -public: - KMExtManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMExtManager(); - -protected: - void listPrinters(); - -private: - KMPrinter *m_psprinter; -}; - -#endif diff --git a/kdeprint/ext/kmextuimanager.cpp b/kdeprint/ext/kmextuimanager.cpp deleted file mode 100644 index 2fa200848..000000000 --- a/kdeprint/ext/kmextuimanager.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmextuimanager.h" -#include "kpqtpage.h" -#include "kprinterpropertydialog.h" - -#include <klocale.h> - -KMExtUiManager::KMExtUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMUiManager(parent,name) -{ - m_printdialogflags |= KMUiManager::PrintCommand; -} - -KMExtUiManager::~KMExtUiManager() -{ -} - -int KMExtUiManager::pluginPageCap() -{ - return KMUiManager::NoAutoCollate; -} - -void KMExtUiManager::setupPrinterPropertyDialog( KPrinterPropertyDialog *dlg ) -{ - dlg->addPage( new KPQtPage( dlg, "QtPage" ) ); -} diff --git a/kdeprint/ext/kmextuimanager.h b/kdeprint/ext/kmextuimanager.h deleted file mode 100644 index bca161c60..000000000 --- a/kdeprint/ext/kmextuimanager.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMEXTUIMANAGER_H -#define KMEXTUIMANAGER_H - -#include "kmuimanager.h" - -class KMExtUiManager : public KMUiManager -{ -public: - KMExtUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMExtUiManager(); - - int pluginPageCap(); - void setupPrinterPropertyDialog( KPrinterPropertyDialog* ); -}; - -#endif diff --git a/kdeprint/filters/CMakeLists.txt b/kdeprint/filters/CMakeLists.txt deleted file mode 100644 index 2d36e16bb..000000000 --- a/kdeprint/filters/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -##### other data ################################ - -install( FILES - enscript.desktop enscript.xml psnup.desktop psnup.xml - imagetops.desktop imagetops.xml pdfwrite.desktop - pdfwrite.xml psbook1.desktop psbook1.xml psbook2.desktop - psbook2.xml psbook.desktop psbook.xml psselect.desktop - psselect.xml ps2pdf.desktop ps2pdf.xml pdf2ps.desktop - pdf2ps.xml poster.desktop poster.xml - DESTINATION ${DATA_INSTALL_DIR}/tdeprint/filters ) - -install( PROGRAMS imagetops DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/kdeprint/filters/Makefile.am b/kdeprint/filters/Makefile.am deleted file mode 100644 index f9c9f9120..000000000 --- a/kdeprint/filters/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -filtersdir = $(kde_datadir)/tdeprint/filters -filters_DATA = enscript.desktop enscript.xml\ - psnup.desktop psnup.xml \ - imagetops.desktop imagetops.xml \ - pdfwrite.desktop pdfwrite.xml \ - psbook1.desktop psbook1.xml \ - psbook2.desktop psbook2.xml \ - psbook.desktop psbook.xml \ - psselect.desktop psselect.xml \ - ps2pdf.desktop ps2pdf.xml \ - pdf2ps.desktop pdf2ps.xml \ - poster.desktop poster.xml - -bin_SCRIPTS = imagetops diff --git a/kdeprint/filters/enscript.desktop b/kdeprint/filters/enscript.desktop deleted file mode 100644 index 1750977e5..000000000 --- a/kdeprint/filters/enscript.desktop +++ /dev/null @@ -1,104 +0,0 @@ -[KDE Print Filter Entry] -Name=enscript -Name[af]=gravering -Name[az]=enskript -Name[de]=Enscript -Name[eo]=Enskripto -Name[fy]=Enscript -Name[hi]=à¤à¤¨à¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ -Name[lb]=Enscript -Name[mn]=Enscript -Name[nds]=Enscript -Name[ne]=इनसà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ -Name[nl]=Enscript -Name[nso]=entshwaelo -Name[ss]=bhala ngamakhodi -Name[sv]=Enscript -Name[ta]=எனà¯à®¸à¯à®•à®¿à®°à®¿à®ªà¯à®Ÿà¯ -Name[te]=à°Žà°¨à±à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± -Name[xh]=okushicilelwe phantsi kuyo -Require=exec:/enscript -Comment=Enscript Text Filter -Comment[af]=Gravering Teks Filter -Comment[ar]=مرشح نصوص Enscript -Comment[az]=Enscript MÉ™tn Filtri -Comment[be]=ТÑкÑтавы фільтр enscript -Comment[bn]=enscript টেকà§à¦¸à¦Ÿ ফিলà§à¦Ÿà¦¾à¦° -Comment[br]=Sil skrid Enscript -Comment[bs]=Enscript tekst filter -Comment[ca]=Filtre de text enscript -Comment[cs]=Textový filtr Enscript -Comment[csb]=Tekstowi filter enscript -Comment[cy]=Hidl Testun Enscript -Comment[da]=Enscript-tekstfilter -Comment[de]=Enscript-Textfilter -Comment[el]=ΦίλτÏο κειμένου enscript -Comment[eo]=Tekstfiltrilo por Enskripto -Comment[es]=Filtro de textos Enscript -Comment[et]=Enscript tekstifilter -Comment[eu]=Enscript testu-iragazkia -Comment[fa]=پالایۀ متن Enscript -Comment[fi]=Enscript-tekstisuodin -Comment[fr]=Filtre de texte Enscript -Comment[fy]=Enscript-tekstfilter -Comment[ga]=Scagaire Téacs Enscript -Comment[gl]=Filtro de Texto Enscript -Comment[he]=מסנן טקסט Enscript -Comment[hi]=à¤à¤¨à¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ पाठ फ़िलà¥à¤Ÿà¤° -Comment[hr]=Enscript tekstualni filtar -Comment[hsb]=Enscript tekstowy filter -Comment[hu]=Enscript szövegszűrÅ‘ -Comment[id]=Filter Teks Enscript -Comment[is]=Enscript textasía -Comment[it]=Filtro di testi Enscript -Comment[ja]=Enscript テキストフィルタ -Comment[ka]=Enscript ტექსტის ფილტრი -Comment[kk]=Enscript мәтін ÑүзгіÑÑ– -Comment[km]=ážáž˜áŸ’រង​អážáŸ’ážáž”áž‘ Enscript -Comment[lb]=Enscript-Textfilter -Comment[lt]=Enscript teksto filtras -Comment[lv]=Enscript teksta filtrs -Comment[mk]=Enscript текÑÑ‚ филтер -Comment[mn]=Enscript текÑÑ‚ шүүлтүүр -Comment[ms]=Penyaring Teks Enscript -Comment[mt]=Filtru tat-test Enscript -Comment[nb]=Enscript tekstfilter -Comment[nds]=Enscript-Textfilter -Comment[ne]=इनसà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ पाठ फिलà¥à¤Ÿà¤° -Comment[nl]=Enscript-tekstfilter -Comment[nn]=Enscript-tekstfilter -Comment[nso]=Sesekodi sa Sengwalwana sa Enstshwaelo -Comment[pa]=ਇੰਸਕà©à¨°à¨¿à¨ªà¨Ÿ ਪਾਠ ਫਿਲਟਰ -Comment[pl]=Filtr tekstowy enscript -Comment[pt]=O filtro de texto enscript -Comment[pt_BR]=Filtro de Texto Enscript -Comment[ro]=Filtru de text Enscript -Comment[ru]=Фильтр текÑта Enscript -Comment[rw]=Kwandika Muyuguruzi Mwandiko -Comment[se]=Enscript teakstasilli -Comment[sk]=Textový filter Enscript -Comment[sl]=Besedilni filter enscript -Comment[sq]=Filter Teksti për Enscript -Comment[sr]=Enscript филтер за текÑÑ‚ -Comment[sr@Latn]=Enscript filter za tekst -Comment[ss]=Bhala ngemakhodi sisefo sembhalo -Comment[sv]=Enscript-textfilter -Comment[ta]=எனà¯à®¸à¯à®•à®¿à®°à®¿à®ªà¯à®Ÿà¯ உரை வடிகடà¯à®Ÿà®¿ -Comment[te]=à°Žà°¨à±à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± వాచక గలని -Comment[tg]=Филтри матни Enscript -Comment[th]=ตัวà¸à¸£à¸­à¸‡à¸‚้อความ Enscript -Comment[tr]=Enscript Metin Filtresi -Comment[tt]=Enscript atlı Mäten Sözgeçe -Comment[uk]=ТекÑтовий фільтр enscript -Comment[uz]=Enscript matn filteri -Comment[uz@cyrillic]=Enscript матн филтери -Comment[ven]=Nwalani ya filithara ya manwalwa -Comment[vi]=Bá»™ lá»c văn bản enscript. -Comment[wa]=Passete po-z imprimer do peur tecse avou enscript -Comment[xh]=Enscript Uhluzo Lombhalo -Comment[zh_CN]=Enscript æ–‡æœ¬è¿‡æ»¤ç¨‹åº -Comment[zh_HK]=Enscript 文字éŽæ¿¾å™¨ -Comment[zh_TW]=Enscript 文字éŽæ¿¾å™¨ -Comment[zu]=Qopha Ihluzo Lombhalo -MimeTypeIn=text/html,text/plain,text/sgml,text/x-c++hdr,text/x-c++src,text/x-chdr,text/x-csrc,text/x-java,text/x-makefile,text/x-pascal,text/x-python,text/x-tcl,text/x-tex,text/xml,text/x-fortran,application/x-perl,appication/x-perl-module,application/x-python,text/docbook,text/x-log,text/x-diff,application/x-ruby -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/enscript.xml b/kdeprint/filters/enscript.xml deleted file mode 100644 index edf43716a..000000000 --- a/kdeprint/filters/enscript.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="enscript"> - <filtercommand data="enscript -M %psu %filterargs %filteroutput %filterinput" /> - <filterargs> - <filtergroup name="group1" description="Columns"> - <filterarg name="columns" description="Number of columns" format="--columns=%value" type="int" min="1" max="10" default="1" /> - <filterarg name="landscape" description="Landscape mode" format="-r" type="bool" default="false"> - <value name="true" description="Yes" /> - <value name="false" description="No" /> - </filterarg> - </filtergroup> - <filtergroup name="group2" description="Header format"> - <filterarg name="noheader" description="Disable header" format="-B" type="bool" default="false"> - <value name="true" description="Yes" /> - <value name="false" description="No" /> - </filterarg> - <filterarg name="header" description="Header format" format="-b %value" type="string" default="" /> - </filtergroup> - <filtergroup name="group3" description="Syntax"> - <filterarg name="prettyprint" description="Syntax highlighting" format="-E" type="bool" default="false"> - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg name="colormode" description="Use colors" format="--color" type="bool" default="false"> - <value name="true" description="Yes" /> - <value name="false" description="No" /> - </filterarg> - </filtergroup> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="-p %out" /> - <filterarg name="pipe" format="-p -" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/imagetops b/kdeprint/filters/imagetops deleted file mode 100755 index 634a2caf5..000000000 --- a/kdeprint/filters/imagetops +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# extract file name and arguments from command line. File name -# is supposed to be the last one, if it doesn't exist, then it -# is assumed to be another argument. -FILE= -ARGS= -GRAYSCALE= -for arg in "$@"; do - if [ "$arg" = "-gray" ]; then - GRAYSCALE=1 - else - ARGS="$ARGS $FILE" - FILE=$arg; - fi -done - -# we're reading from STDIN, store it into a temporary file -temp=0 -if test -z "$FILE" -o ! -f "$FILE" ; then - ARGS="$ARGS $FILE" - FILE=`mktemp /tmp/imagetops.XXXXXX` || exit 1 - cat > "$FILE" - temp=1 -fi - -# check the file mime type, and set the command correspondingly -cmd= -magic=`file -bi "$FILE"` -magicbase=`echo $magic | cut -f 1 -d "/"` -magictype=`echo $magic | cut -f 2- -d "/"` -if test "$magicbase" != "image" ; then - echo "Not an image" - exit 1; -fi -case $magictype in - jpeg) - cmd="jpegtopnm" - ;; - png|x-png) - cmd="pngtopnm" - ;; - bmp|x-bmp) - cmd="bmptoppm" - ;; - gif) - cmd="giftopnm" - ;; - tiff) - cmd="tifftopnm" - ;; - *) - echo "Unsupported image type: $magic" - exit 1 - ;; - -esac - -# executing command -if [ "$GRAYSCALE" = "1" ]; then - exec $cmd "$FILE" | ppmtopgm | pnmtops $ARGS -else - exec $cmd "$FILE" | pnmtops $ARGS -fi - -# removing temporary file -if test "$temp" = "1"; then - rm -f "$FILE" -fi diff --git a/kdeprint/filters/imagetops.desktop b/kdeprint/filters/imagetops.desktop deleted file mode 100644 index 5d23f414a..000000000 --- a/kdeprint/filters/imagetops.desktop +++ /dev/null @@ -1,107 +0,0 @@ -[KDE Print Filter Entry] -Name=imagetops -Name[af]=beeldpieke -Name[az]=rÉ™smlÉ™r -Name[da]=billedtoppe -Name[eo]=Bildsuproj -Name[fa]=بالای تصویر -Name[fr]=Imagetops -Name[fy]=Imagetops -Name[hi]=इमेजटॉपà¥à¤¸ -Name[ne]=इमेजटप -Name[nl]=Imagetops -Name[nso]=mabogodimo a diponagalo -Name[pt_BR]=Imagenstops -Name[sr]=врхови Ñлика -Name[sr@Latn]=vrhovi slika -Name[sv]=Bildtoppar -Name[ta]=மேலà¯à®ªà®¿à®®à¯à®ªà®™à¯à®•à®³à¯ -Name[te]=ఇమెజౠటాపà±à°¸à± -Name[ven]=Zwa ntha zwa zwifanyiso -Name[zu]=uphahla lwesithombe -Require=exec:/imagetops -Comment=Generic Image to PS Filter -Comment[af]=Generies Beeld na Ps Filter -Comment[ar]=مرشح الصور الى بوست سكريبت -Comment[az]=Ãœmumi RÉ™sm-PS Filtri -Comment[be]=Звычайнае пераўтварÑнне відарыÑаў у файл PS -Comment[bn]=জেনেরিক চিতà§à¦° থেকে পোসà§à¦Ÿà¦¸à§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ ফিলà§à¦Ÿà¦¾à¦° -Comment[br]=Sil rummel skeudenn da PS -Comment[bs]=OpÅ¡ti Image-to-PS filter -Comment[ca]=Imatge genèrica per al filtre PS -Comment[cs]=Obecný filtr pro pÅ™evod obrázku do PS souboru -Comment[csb]=Filter òbrôzków do Postscriptu -Comment[cy]=Hidl Cyffredinol Delwedd i PS -Comment[da]=Generisk billede-til-PS-filter -Comment[de]=Umwandlung von Bildern in PostScript -Comment[el]=Γενικό φίλτÏο εικόνας σε PS -Comment[eo]=Äœenerala filtrilo de bildo al PS -Comment[es]=Imagen genérica a filtro PS -Comment[et]=Lihtne pilt->PostScript filter -Comment[eu]=Irudi generikoa PS iragazkira -Comment[fa]=تصویر عمومی به پالایۀ PS -Comment[fi]=Muunnin yleisestä kuvasta PS-muotoon -Comment[fr]=Filtre d'image générique vers PS -Comment[fy]=Algemiene ôfbylding nei PS-filter -Comment[ga]=Scagaire cineálach Ãomhá go PS -Comment[gl]=Imaxe Xenérica para o Filtro PS -Comment[he]=מסנן כללי מתמונה ל־PS -Comment[hi]= जेनरिक छवि से PS फ़िलà¥à¤Ÿà¤° -Comment[hr]=GeneriÄki filtar slike za PS -Comment[hsb]=Generiski konwerter wobrazow na PS -Comment[hu]=Ãltalános PS szűrÅ‘ képekhez -Comment[id]=Fiter Gambar ke PS -Comment[is]=Almenn sía til að breyta mynd í Postscript -Comment[it]=Filtro generico da immagine a PostScript -Comment[ja]=一般的ãªç”»åƒã‚’ PS ã«å¤‰æ› -Comment[ka]=გáƒáƒ›áƒáƒ¡áƒáƒ®áƒ£áƒšáƒ”ბის PostScript გáƒáƒ¤áƒ˜áƒšáƒ¢áƒ•áƒ áƒ -Comment[kk]=Жалпы кеÑкінді PostScript-ке аудару ÑүзгіÑÑ– -Comment[km]=រូបភាព Generic ទៅ​ážáž˜áŸ’ážšáž„ PS -Comment[ko]=ì¼ë°˜ ê·¸ë¦¼ì„ PSë¡œ 바꿔주는 거르개 -Comment[lb]=Allgemenge Filter vu Biller zu PS -Comment[lt]=Bendras filtras iÅ¡ paveiksliukų į PS -Comment[lv]=VispÄrÄ“js attÄ“la uz PS filtrs -Comment[mk]=Општ филтер од Ñлика во PS -Comment[mn]=Ерөнхий Ð·ÑƒÑ€Ð³Ð°Ð°Ñ PostScript-файл руу хөрвүүлÑÑ… шүүлтүүр -Comment[ms]=Imej Generik kepada Penyaring PS -Comment[mt]=Filtru Ä¡eneriku minn stampa għal PS -Comment[nb]=Bilder til PS-filter -Comment[nds]=Allgemeen Filter för't Ãœmwanneln vun'n Bild na PostScript -Comment[ne]=जेनेरिक छवि देखि PS फिलà¥à¤Ÿà¤° समà¥à¤® -Comment[nl]=Generieke afbeelding naar PS-filter -Comment[nn]=Generelt bilete-til-PS-filter -Comment[nso]=Ponagalo ya Kakaretso go Sesekodi sa PS -Comment[pa]=ਆਮ ਚਿੱਤਰ ਤੋਂ PS ਫਿਲਟਰ -Comment[pl]=Filtr obrazków do Postscriptu -Comment[pt]=O filtro genérico de imagens para PS -Comment[pt_BR]=Imagem genérica para filtro PS -Comment[ro]=Filtru generic de imagine către PS -Comment[ru]=Преобразование изображений в PostScript -Comment[rw]=Ishusho Rusange kuri Muyunguruzi PS -Comment[se]=OppalaÅ¡ govva PS:ai filter -Comment[sk]=Generický filter z obrázku do PS -Comment[sl]=Filter iz sploÅ¡nih slik v postscript -Comment[sq]=Filter i përgjithshëm për Shëndrimin e imazheve në skeda PS -Comment[sr]=Генерички „Ñлика у PS“ филтер -Comment[sr@Latn]=GeneriÄki „slika u PS“ filter -Comment[ss]=Umfanekiso lobanti kusisefo sePS -Comment[sv]=Generell bild till PS-filter -Comment[ta]=பிஎஸà¯à®•à¯à®•à®¾à®© வடிகடà¯à®Ÿà®¿à®•à¯à®•à®¾à®© பொத௠பிமà¯à®ªà®®à¯ -Comment[te]=సాధారణ à°ªà±à°°à°¤à°¿à°¬à°¿à°‚బాలనౠపిఎసౠకౠమారà±à°šà± గలని -Comment[tg]=Табодули таÑвирот ба Post Script -Comment[th]=ตัวà¸à¸£à¸­à¸‡à¸ à¸²à¸žà¹„ปเป็นโพสต์สคริปต์ทั่วไป -Comment[tr]=Genel Resimden PS'e Süzgeç -Comment[tt]=Sürätlärne PS'qa äyländerü Sözgeçe -Comment[uk]=Загальний фільтр зображень в файли PS -Comment[uz]=Rasmni PS'ga aylantiradigan oddiy filtr -Comment[uz@cyrillic]=РаÑмни PS'га айлантирадиган оддий филтр -Comment[ven]=Tshifanyiso kha tshigwada kha filithara ya PS -Comment[vi]=Bá»™ lá»c ảnh sang PS giống loài. -Comment[wa]=Passete djenerike imÃ¥djes viè PostScript -Comment[xh]=Umfanekiso ngokubanzi kwicebo lokucoca ulwelo le PS -Comment[zh_CN]=通用图åƒåˆ° PS è¿‡æ»¤ç¨‹åº -Comment[zh_HK]=å°‡ä¸€èˆ¬åœ–æª”è½‰æˆ PS çš„éŽæ¿¾å™¨ -Comment[zh_TW]=ä¸€èˆ¬åœ–æª”è½‰æˆ PS çš„éŽæ¿¾å™¨ -Comment[zu]=Isithombe Sawowonke Sehluzo le-PS -MimeTypeIn=image/jpeg,image/png,image/x-png,image/bmp,image/x-bmp,image/gif,image/tiff -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/imagetops.xml b/kdeprint/filters/imagetops.xml deleted file mode 100644 index aba7f883a..000000000 --- a/kdeprint/filters/imagetops.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="imagetops"> - <filtercommand data="imagetops %filterargs %filterinput %filteroutput" /> - <filterargs> - <filterarg name="center" description="Image centering" format="-nocenter" type="bool" default="true"> - <value name="true" description="Yes" /> - <value name="false" description="No" /> - </filterarg> - <filterarg name="turn" description="Image rotation" format="-%value" type="list" default="auto"> - <value name="auto" description="Automatic" /> - <value name="noturn" description="None" /> - <value name="turn" description="90 deg" /> - </filterarg> - <filterarg name="scale" description="Image scale" format="-scale %value" type="float" min="0.0" max="1.0" default="1.000" /> - <filterarg name="dpi" description="Image resolution" format="-dpi %value" type="int" min="72" max="1200" default="300" /> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/pdf2ps.desktop b/kdeprint/filters/pdf2ps.desktop deleted file mode 100644 index 2f97c7289..000000000 --- a/kdeprint/filters/pdf2ps.desktop +++ /dev/null @@ -1,40 +0,0 @@ -[KDE Print Filter Entry] -Name=pdf2ps -Name[pl]=Konwersja PDF do PS -Name[sv]=Pdf2ps -Require=exec:/gs -Comment=PDF to PostScript Converter -Comment[bg]=Конвертор от PDF в PostScript -Comment[ca]=Convertidor de PDF a PostScript -Comment[da]=PDF-til-PostScript-konvertering -Comment[de]=Umwandlung von PDF in PostScript -Comment[el]=ΜετατÏοπέας από PostScript σε PDF -Comment[eo]=Konvertilo de la dokumenttipo PDF al PS -Comment[es]=Conversor de PDF a PostScript -Comment[et]=PDF->PostScript teisendamine -Comment[fr]=Convertisseur PDF vers PostScript -Comment[hr]=Pretvaranje iz PDF-a u PostScript -Comment[hu]=PDF -> PostScript konvertálóprogram -Comment[is]=Breytir PDF skjölum í Postscript-skjöl -Comment[it]=Convertitore da PDF a PostScript -Comment[ja]=PDF ã‹ã‚‰ PostScript ã«å¤‰æ› -Comment[km]=កម្មវិធីបម្លែង PDF ទៅ​ជា PostScript -Comment[nds]=Wannelt PDF na PostScript üm -Comment[nl]=Conversie van PDF naar PostScript -Comment[pl]=Konwerter plików z formatu PDF do PostScriptu -Comment[pt]=Conversor de PDF para PostScript -Comment[pt_BR]=Conversor de PDF para PostScript -Comment[ru]=Преобразование PDF в PostScript -Comment[sk]=Prevod súborov z PDF do PostScript -Comment[sl]=Pretvornik datotek PDF v PostScript -Comment[sr]=Конвертор из PDF-а у PostScript -Comment[sr@Latn]=Konvertor iz PDF-a u PostScript -Comment[sv]=PDF till Postscript-konverterare -Comment[tg]=Конвертори PDF ба PostScript -Comment[th]=ตัวà¹à¸›à¸¥à¸‡ PDF ไปเป็นà¹à¸Ÿà¹‰à¸¡à¹‚พสต์สคริปต์ -Comment[uk]=Конвертер документів з формату PDF в PostScript -Comment[uz]=PDF'ni PostScrip'ga aylantiradigan dastur -Comment[uz@cyrillic]=PDF'ни PostScrip'га айлантирадиган даÑтур -Comment[zh_TW]=PDF 至 PostScript 轉æ›å™¨ -MimeTypeIn=application/pdf -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/pdf2ps.xml b/kdeprint/filters/pdf2ps.xml deleted file mode 100644 index 0afa52e8e..000000000 --- a/kdeprint/filters/pdf2ps.xml +++ /dev/null @@ -1,152 +0,0 @@ -<!DOCTYPE kprintfilter> -<kprintfilter name="pdf2ps" > - <filtercommand data="gs -q -dSAFER -dPARANOIDSAFER -dNOPAUSE -dBATCH -sDEVICE=pswrite -sOutputFile=%filteroutput -sPAPERSIZE=%psl %filterargs -f %filterinput" /> - <filterargs name="__root__" description="pdf2ps" > - <filtergroup name="general" description="General" > - <filterarg format="-dPDFSETTINGS=%value" type="list" name="targetdevice" default="/default" description="Target device" > - <value name="/default" description="Default" /> - <value name="/screen" description="Screen" /> - <value name="/printer" description="Printer" /> - <value name="/prepress" description="Prepress" /> - </filterarg> - <filterarg format="-dCompatibilityLevel=%value" type="list" name="compat" default="gs-def" description="Compatibility Level" > - <value name="gs-def" description="GhostScript Default Setting" /> - <value name="1.2" description="Level 1.2" /> - <value name="1.3" description="Level 1.3" /> - </filterarg> - <filterarg format="-dAutoRotatePages=%value" type="list" name="autorotate" default="/PageByPage" description="Auto rotate pages" > - <value name="/None" description="Disabled" /> - <value name="/PageByPage" description="Page by Page" /> - <value name="/All" description="Dominant orientation" /> - </filterarg> - </filtergroup> - <filtergroup name="image" description="Image Options" > - <filtergroup name="colorimage" description="Color Images" > - <filtergroup name="colorcompress" description="Compression" > - <filterarg format="-dEncodeColorImages=%value" type="bool" name="colorencode" default="true" description="Encode color images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dAutoFilterColorImages=%value" type="bool" name="colorautofilt" default="true" description="Auto encode color images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dColorImageFilter=%value" type="bool" name="colorencodetype" default="/DCTEncode" description="Manual color image encoding method" > - <value name="/FlateEncode" description="Flate compression" /> - <value name="/DCTEncode" description="JPEG compression" /> - </filterarg> - </filtergroup> - <filterarg format="-dDownsampleColorImages=%value" type="bool" name="coldownsampl" default="false" description="Downsample color images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dColorImageResolution=%value" type="int" min="9" max="2400" name="colimageres" default="300" description="Maximum color image resolution" /> - <filterarg format="-sColorImageDownsampleType=%value" type="list" name="colsampltype" default="Subsample" description="Color image downsampling method" > - <value name="Subsample" description="Sub-sampling" /> - <value name="Average" description="Averaging" /> - <value name="Bicubic" description="Bicubic interpolation" /> - </filterarg> - <filterarg format="-dColorImageDepth=%value" type="list" name="coldepth" default="-1" description="Color image depth" > - <value name="-1" description="Use the depth of the original" /> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - </filterarg> - </filtergroup> - <filtergroup name="grayimage" description="Grayscale Images" > - <filtergroup name="graycompress" description="Compression" > - <filterarg format="-dEncodeGrayImages=%value" type="bool" name="grayencode" default="true" description="Encode grayscale images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dAutoFilterGrayImages=%value" type="bool" name="grayautofilt" default="true" description="Auto encode grayscale images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dEncodeGrayImages=%value" type="bool" name="grayencodetype" default="/DCTEncode" description="Manual grayscale image encoding method" > - <value name="/FlateEncode" description="Flate compression" /> - <value name="/DCTEncode" description="JPEG compression" /> - </filterarg> - </filtergroup> - <filterarg format="-dDownsampleGrayImages=%value" type="bool" name="graydownsampl" default="false" description="Downsample grayscale images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dGrayImageResolution=%value" type="int" min="9" max="2400" name="grayimageres" default="300" description="Maximum grayscale image resolution" /> - <filterarg format="-sGrayImageDownsampleType=%value" type="list" name="graysampltype" default="Subsample" description="Grayscale image downsampling method" > - <value name="Subsample" description="Sub-sampling" /> - <value name="Average" description="Averaging" /> - <value name="Bicubic" description="Bicubic interpolation" /> - </filterarg> - <filterarg format="-dGrayImageDepth=%value" type="list" name="graydepth" default="-1" description="Grayscale image depth" > - <value name="-1" description="Use the depth of the original" /> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - </filterarg> - </filtergroup> - <filtergroup name="monoimage" description="Mono Images" > - <filtergroup name="monocompress" description="Compression" > - <filterarg format="-dEncodeMonoImages=%value" type="bool" name="monoencode" default="true" description="Encode mono images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dAutoFilterMonoImages=%value" type="bool" name="monoautofilt" default="true" description="Auto encode mono images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dEncodeMonoImages=%value" type="bool" name="monoencodetype" default="/CCITTFaxEncode" description="Manual mono image encoding method" > - <value name="/CCITTFaxEncode" description="CCITT compression" /> - <value name="/FlateEncode" description="Flate compression" /> - </filterarg> - </filtergroup> - <filterarg format="-dDownsampleMonoImages=%value" type="bool" name="downsamplmono" default="false" description="Downsample mono images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dMonoImageResolution=%value" type="int" min="0" max="2400" name="monores" default="300" description="Maximum mono image resolution" /> - <filterarg format="-sMonoImageDownsampleType=%value" type="list" name="monosampltype" default="Subsample" description="Mono image downsampling method" > - <value name="Subsample" description="Sub-sampling" /> - <value name="Average" description="Averaging" /> - <value name="Bicubic" description="Bicubic interpolation" /> - </filterarg> - <filterarg format="-dMonoImageDepth=%value" type="list" name="monodepth" default="-1" description="Mono image depth" > - <value name="-1" description="Use the depth of the original" /> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - </filterarg> - </filtergroup> - </filtergroup> - <filtergroup name="fonts" description="Fonts" > - <filterarg format="-dEmbedAllFonts=%value" type="bool" name="embedfonts" default="true" description="Embed all fonts" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dSubsetFonts=%value" type="bool" name="fontsubsets" default="true" description="Embed font subsets" > - <value name="true" description="Embed subset" /> - <value name="false" description="Embed complete font" /> - </filterarg> - <filterarg format="-dMaxSubsetPct=%value" type="int" min="0" max="100" name="fontsubsetpct" default="100" description="Maximum font subset percentage" /> - <filterarg format="-r%value" type="list" name="resol" default="300x300" description="Bitmap font resolution" > - <value name="72x72" description="72 dpi" /> - <value name="144x144" description="144 dpi" /> - <value name="300x300" description="300 dpi" /> - <value name="600x600" description="600 dpi" /> - <value name="1200x1200" description="1200 dpi" /> - <value name="2400x2400" description="2400 dpi" /> - </filterarg> - </filtergroup> - </filterargs> - <filterinput> - <filterarg format="%in" name="file" /> - <filterarg format="-" name="pipe" /> - </filterinput> - <filteroutput> - <filterarg format="%out" name="file" /> - <filterarg format="-" name="pipe" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/pdfwrite.desktop b/kdeprint/filters/pdfwrite.desktop deleted file mode 100644 index f42e2cf84..000000000 --- a/kdeprint/filters/pdfwrite.desktop +++ /dev/null @@ -1,102 +0,0 @@ -[KDE Print Filter Entry] -Name=pdfwrite -Name[de]=PDF-Write -Name[eo]=PDF-skribilo -Name[fy]=PDFwrite -Name[hi]=पीडीà¤à¤«-राइट -Name[mn]=PDF-Write -Name[nl]=PDFwrite -Name[nso]=pdfngwala -Name[pt_BR]=PDFWrite -Name[sv]=PDFwrite -Name[ta]=பிடிஎஃப௠எழà¯à®¤à®¿ -Name[te]=పిడిఎఫౠవà±à°°à±ˆà°Ÿà± -Name[tr]=pdfyaz -Name[ven]=pdfnwala -Name[zu]=bhala kwe-pdf -Require=exec:/gs -Comment=PDF Writer (needs Ghostscript) -Comment[af]=Pdf Skrywer (verlang Ghostscript) -Comment[ar]=كاتب ملÙات PDF (يحتاج الى غوست سكريبت) -Comment[az]=PDF Yazıcı (Ghostscript-É™ ehtiyacı var) -Comment[be]=Стварыць файл PDF (патрÑбны Ghostscript) -Comment[bn]=পি-ডি-à¦à¦« (PDF) Writer (ঘোসà§à¦Ÿà¦¸à§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ লাগে) -Comment[br]=Skriver PDF (red eo da endevout Ghostscript) -Comment[bs]=Pravljenje PDFa (potreban je GhostScript) -Comment[ca]=Escriptor de PDF (necessita Ghostscript) -Comment[cs]=PDF writer (vyžaduje GhostScript) -Comment[csb]=Zapisëwôcz PDF (wëmôgô GhostScripta) -Comment[cy]=Ysgrifennydd PDF (angen Ghostscript) -Comment[da]=PDF Writer (kræver Ghostscript) -Comment[de]=PDF-Erstellung (via Ghostscript) -Comment[el]=ΕγγÏαφέας PDF (χÏειάζεται το Ghostscript) -Comment[eo]=PDF-skribilo (bezonas la programon GhostScript) -Comment[es]=Escritor de PDF (requiere Ghostscript) -Comment[et]=PDF-i kirjutaja (vajab Ghostscripti) -Comment[eu]=PDF idazlea (GhostScript behar du) -Comment[fa]=نویسندۀ PDF)به Ghostscriptنیاز دارد( -Comment[fi]=PDF-tulostussuodin (tarvitsee Ghostscriptin) -Comment[fr]=Impression PDF (nécessite GhostScript) -Comment[fy]=PDF Writer (hat Ghostskript nedich) -Comment[ga]=Scríbhneoir PDF (Ghostscript de dhíth) -Comment[gl]=Escritor de PDF (precisa Ghostscript) -Comment[he]=כתבן ×”Ö¾PDF (זקוק ל־Ghostscript) -Comment[hi]=पीडीà¤à¤« राइटर (घोसà¥à¤Ÿà¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ आवशà¥à¤¯à¤• है) -Comment[hr]=PDF Writer (zahtjeva GhostScript) -Comment[hsb]=PDF pisanje (trjeba ghostscript) -Comment[hu]=PDF-író (a GhostScript szükséges hozzá) -Comment[id]=Pembuat PDF (memerlukan Ghostscript) -Comment[is]=PDF skrifari (krefst GhostScript) -Comment[it]=Scrittura di PDF (richiede GhostScript) -Comment[ja]=PDF ライター (GhostScript ãŒå¿…è¦) -Comment[ka]=PDF ჩáƒáƒ›áƒ¬áƒ”რი (სáƒáƒ­áƒ˜áƒ áƒáƒ”ბს GhostScript-ს) -Comment[kk]=PDF жазуы (Ghostscript керек) -Comment[km]=PDF Writer (ážáŸ’រូវការ Ghostscript) -Comment[ko]=PDF 쓰기 (고스트스í¬ë¦½íŠ¸ê°€ 필요함) -Comment[lb]=PDF-Schreiwer (brauch Ghostscript) -Comment[lt]=PDF raÅ¡iklis (reikalauja GhostScript) -Comment[lv]=PDF rakstÄ«tÄjs (nepiecieÅ¡ams GhostScript) -Comment[mk]=PDF Writer (бара Ghostscript) -Comment[mn]=PDF-Ò®Ò¯ÑгÑгч (GhostScript Ñ…ÑÑ€ÑгтÑй) -Comment[ms]=Penulis PDF (perlukan Ghostscript) -Comment[mt]=Kittieb PDF (jeħtieÄ¡ GhostScript) -Comment[nb]=PDF-skriver (trenger Ghostscript) -Comment[nds]=PDF-Maker (bruukt Ghostscript) -Comment[ne]=PDF राइटर (घोसà¥à¤Ÿà¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ आवशà¥à¤¯à¤• हà¥à¤¨à¥à¤›) -Comment[nl]=PDF Writer (heeft ghostscript nodig) -Comment[nn]=PDF-skrivar (treng GhostScript) -Comment[nso]=Mongwadi wa PDF (o hloka tshwaelo yaGhost) -Comment[pa]=PDF ਲੇਖਕ (ਗੋਸਟ ਸਕà©à¨°à¨¿à¨ªà¨Ÿ) -Comment[pl]=Zapisywacz PDF (wymaga GhostScripta) -Comment[pt]=Gravador de PDF (necessita do Ghostscript) -Comment[pt_BR]= Editor PDF (necessita do GhostScript) -Comment[ro]=Generator de PDF (are nevoie de Ghostscript) -Comment[ru]=Сохранение в PDF (должен быть уÑтановлен GhostScript) -Comment[rw]=Mwanditsi PDF (ikeneye agaporogaramuBaringa) -Comment[se]=PDF-Äálli (dárbbaÅ¡a Ghostscript:a) -Comment[sk]=PDF Writer (vyžaduje GhostScript) -Comment[sl]=Izdelovalnik PDF (potrebuje GhostScript) -Comment[sq]=PDF Shkrues (kërkon Ghostscript-in) -Comment[sr]=PDF Writer (пиÑач, захтева GhostScript) -Comment[sr@Latn]=PDF Writer (pisaÄ, zahteva GhostScript) -Comment[ss]=Umbhali we PDF (yidzinga i-Ghostscript) -Comment[sv]=PDF-skrivare (behöver Ghostscript) -Comment[ta]=PDF எழà¯à®¤à®¿ (கோஸà¯à®Ÿà¯ ஸà¯à®•à®¿à®°à®¿à®ªà¯à®Ÿà¯ தேவை) -Comment[te]=పిడిఎఫౠలనౠవà±à°°à°¾à°¸à±†à°¦à°¿ (ఘొసà±à°Ÿà± à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± కావలెనà±) -Comment[tg]=Ðигоҳ доштан ба формати PDF (боÑд Ghostscript Ñабт шуда бошад) -Comment[th]=ตัวเขียน PDF (จำเป็นต้องใช้ GhostScript) -Comment[tr]=PDF yazıcı (GhostScript'e ihtiyacı var) -Comment[tt]=PDF Yazdırğıç (Ghostscript kiräk) -Comment[uk]=Генератор PDF (потребує GhostScript) -Comment[uz]=PDF yozgich (Ghostscript oÊ»rnatilgan boÊ»lishi shart) -Comment[uz@cyrillic]=PDF ёзгич (Ghostscript ўрнатилган бўлиши шарт) -Comment[ven]=Munwali wa PDF (I toda bammbiri la tshipuku) -Comment[vi]=Bá»™ ghi PDF (cần Ghostscript) -Comment[wa]=Fijheu di fitchîs PDF (a mezÃ¥jhe di Ghostscript) -Comment[xh]=Umbhali we PDF (ufuna i Ghostscript) -Comment[zh_CN]=PDF 书写器 (éœ€è¦ GhostScript) -Comment[zh_HK]=PDF 產生器 (éœ€è¦ GhostScript) -Comment[zh_TW]=PDF 產生器 (éœ€è¦ GhostScript) -Comment[zu]=Umbhali we-PDF (idinga i-Ghostscript) -MimeTypeIn=application/postscript -MimeTypeOut=application/pdf diff --git a/kdeprint/filters/pdfwrite.xml b/kdeprint/filters/pdfwrite.xml deleted file mode 100644 index 9ba166138..000000000 --- a/kdeprint/filters/pdfwrite.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="pdfwrite"> - <filtercommand data="gs -q -dNOPAUSE -dSAFER -dPARANOIDSAFER -sDEVICE=pdfwrite -sPAPERSIZE=%psl -sOutputFile=%filteroutput %filterargs -c save pop -f %filterinput" /> - <filterargs> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="-" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="%out" /> - <filterarg name="pipe" format="-" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/poster.desktop b/kdeprint/filters/poster.desktop deleted file mode 100644 index 843290fab..000000000 --- a/kdeprint/filters/poster.desktop +++ /dev/null @@ -1,163 +0,0 @@ -[KDE Print Filter Entry] -Comment=Poster Printing -Comment[af]=Stuurder Besig om te druk -Comment[ar]=طباعة اللاÙتة -Comment[az]=Poster Çapı -Comment[be]=Друк плаката -Comment[bn]=পোসà§à¦Ÿà¦¾à¦° মà§à¦¦à§à¦°à¦£ -Comment[bs]=Å tampanje postera -Comment[ca]=Impressió de pòster -Comment[cs]=Tisk posteru -Comment[csb]=Drëkòwanié plakatów -Comment[cy]=Argraffu Posteri -Comment[da]=Plakatudskrift -Comment[de]=Plakatdruck -Comment[el]=ΕκτÏπωση αφισών -Comment[eo]=Plakato presado -Comment[es]=Impresión de poster -Comment[et]=Postri trükkimine -Comment[eu]=Posterra inprimatzea -Comment[fa]=چاپ پوستر -Comment[fi]=Julistetulostus -Comment[fr]=Impression d'affiches -Comment[fy]=Posterprint -Comment[ga]=Priontáil Postaera -Comment[gl]=Impresión de Carteis -Comment[he]=הדפסת כרזות -Comment[hi]=पोसà¥à¤Ÿà¤° छपाई -Comment[hr]=Ispisivanje postera -Comment[hsb]=ćišćenje postera -Comment[hu]=Poszternyomtatás -Comment[id]=Pencetakan Poster -Comment[is]=Veggspjaldaprentun -Comment[it]=Stampa poster -Comment[ja]=ãƒã‚¹ã‚¿ãƒ¼å°åˆ· -Comment[ka]=პლáƒáƒ™áƒáƒ¢áƒ˜áƒ¡ ბეჭდვრ-Comment[kk]=Плакатты баÑып шығару -Comment[km]=ការ​បោះពុម្ព​បáŸážŽáŸ’ណ​ប្រកាស -Comment[ko]=í¬ìŠ¤í„° ì¸ì‡„ -Comment[lb]=Plakatdrock -Comment[lt]=Afišų spausdinimas -Comment[lv]=PlakÄtu drukÄÅ¡ana -Comment[mk]=Печатење поÑтер -Comment[mn]=Зарлал Ñ…ÑвлÑÑ… -Comment[ms]=Cetakan Poster -Comment[nb]=Platakutskrift -Comment[nds]=Posterdruck -Comment[ne]=पोषà¥à¤Ÿà¤° मà¥à¤¦à¥à¤°à¤£ -Comment[nl]=Posterafdruk -Comment[nn]=Plakatutskrift -Comment[nso]=Kgatiso ya Seswantsho -Comment[pa]=ਪੋਸਟਰ ਛਾਪਣਾ -Comment[pl]=Drukowanie plakatów -Comment[pt]=Impressão em Posters -Comment[pt_BR]=Impressão de Cartazes -Comment[ro]=Tipărire poster -Comment[ru]=Печать плаката -Comment[rw]=Gucapa Ishusho -Comment[se]=PlakáhtaÄáliheapmi -Comment[sk]=TlaÄ plagátov -Comment[sl]=Tiskanje plakatov -Comment[sq]=Shtyp Pllakate -Comment[sr]=Штампање поÑтера -Comment[sr@Latn]=Å tampanje postera -Comment[ss]=Kushicelela umbukiso -Comment[sv]=Skriv ut affisch -Comment[ta]=சà¯à®µà®°à¯Šà®Ÿà¯à®Ÿà®¿ அசà¯à®šà®¿à®Ÿà®²à¯ -Comment[te]=పోసà±à°Ÿà°°à±à°²à°¨à± à°ªà±à°°à°šà±à°°à°¿à°‚చేది -Comment[tg]=Чопи плакат -Comment[th]=à¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¹‚ปสเตอร์ -Comment[tr]=Poster Yazdırma -Comment[tt]=Poster Bastıru -Comment[uk]=Друк плакатів -Comment[uz]=Plakat bosib chiqarish -Comment[uz@cyrillic]=Плакат боÑиб чиқариш -Comment[ven]=Phirinthani ya phosithara -Comment[vi]=In bích chÆ°Æ¡ng -Comment[wa]=Imprimaedje poster -Comment[xh]=Ushicilelo Lwephepha elinomyalezo -Comment[zh_CN]=æµ·æŠ¥æ‰“å° -Comment[zh_HK]=æµ·å ±åˆ—å° -Comment[zh_TW]=æµ·å ±åˆ—å° -Comment[zu]=Ukushicilela Kwebhodi lezithombe -Description=Utility to print large posters on multiple small paper sheets. To use this command, the <b>poster</b> executable must be accessible in your <tt>PATH</tt>. Source code for this utility can be on the <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. <p><b><u>WARNING:</u></b> The package found on the KDEPrint web site is a modified version of the original one that can be found on any CTAN archive mirror, but the original package will <b>not</b> work with KDE. You <b>must</b> use the package found on the <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. -Description[af]=Program wat jou toelaat om groot plakate op veelvuldige kleiner blaaie te druk. Om hierdie opdrag te gebruik moet die <b>poster</b> program in jou <tt>soekpad</tt> beskikbaar wees. Bronkode vir hierdie program kan beskikbaar wees op die <a href="http://printing.kde.org/downloads">KDEPrint web bediener</a>. <p><b><u>WARNING:</u></b> Die pakket gevind op die KdePrint web bediener is ´n modifiseerde weergawe van die oorspronklike een wat gevind kan word op enige CTAN argiewe spieël, maar die oorspronklike pakket sal <b>nie</b> werk met Kde. U <b>moet</b> gebruik die pakket gevind op die <a href="http://printing.kde.org/downloads">KDEPrint web bediener</a>. -Description[ar]=أداة لطباعة ملصقات عريضة على أوراق صغيرة عديدة. لإستعمال هذا الأمر، يجب أن يكون البرنامج <b>poster</b> ÙÙŠ ال<tt>PATH</tt>. الشÙرة المصدرية لهذه الأداة توجد على <a href="http://printing.kde.org/downloads">موقع ويب KDEPrint</a>. <p><b><u>تحذير:</u></b> الحزمة الموجودة على موقع ويب KDEPrint هي نسخة مغيرة من النسخة الأصلية Ùˆ التي يمكن أن تجدها ÙÙŠ أي مرآة ارشي٠CTANØŒ لكن الحزمة الأصلية <b>لن </b> تعمل مع كيدي. يجب استعمال الحزمة الموجودة على <a href="http://printing.kde.org/downloads">موقع ويب KDEPrint</a>. -Description[az]=Böyük posterlÉ™ri kiçik kağızlara çap etmÉ™yÉ™ yardım edÉ™n vasitÉ™. -Description[be]=Ð¡Ð»ÑƒÐ¶Ð±Ð¾Ð²Ð°Ñ Ð¿Ñ€Ð°Ð³Ñ€Ð°Ð¼Ð° Ð´Ð»Ñ Ð´Ñ€ÑƒÐºÐ°Ð²Ð°Ð½Ð½Ñ Ð²Ñлікіх плакатаў на некалькіх меншых аркушах паперы. Каб ÑкарыÑтаць гÑтую магчымаÑць, праграма <b>poster</b> павінна зноходзіцца Ñž вашым шлÑху пошуку праграмаў <tt>PATH</tt>. Зыходны код гÑтай праграмы можна знайÑці на <a href="http://printing.kde.org/downloads">ПлÑцоўка KDEPrint</a>. <p><b><u>УВÐГÐ:</u></b> Пакет, змешчаны на плÑцоўцы KDEPrint, з'ÑўлÑецца змененай верÑÑ–Ñй арыгінальнай праграмы, Ñкую можна знайÑці Ñž архіве CTAN, аднак Ð°Ñ€Ñ‹Ð³Ñ–Ð½Ð°Ð»ÑŒÐ½Ð°Ñ Ð²ÐµÑ€ÑÑ–Ñ <b>не будзе працаваць</b> з KDE. Вам <b>Ñ‚Ñ€Ñба</b> ÑкарыÑтаць пакунак, Ñкі знаходзіцца на <a href="http://printing.kde.org/downloads">плÑцоўцы KDEPrint</a>. -Description[bg]=Програма за печат на големи поÑтери (плакати) на нÑколко малки лиÑта. За да използвате командата <b>poster</b>, Ñ‚Ñ Ñ‚Ñ€Ñбва да е в Ð´Ð¸Ñ€ÐµÐºÑ‚Ð¾Ñ€Ð¸Ñ Ð¾Ð¿Ð¸Ñана от ÑиÑтемната променлива <tt>PATH</tt>. ИзходниÑÑ‚ код на тази програма може да бъде намерен на Ñтраницата на <a href="http://printing.kde.org/downloads">ÑиÑтемата за печат в KDE</a>. <p><b><u>Ð’ÐИМÐÐИЕ:</u></b> Програмата, коÑто Ñе намира на Ñайта на KDE, е модифицирана верÑÐ¸Ñ Ð½Ð° оригиналната програма, коÑто може да бъде намерена в архивите на CTAN. Оригиналната програма <b>ÐЕ</b> работи ÑÑŠÑ ÑиÑтемата за печат в KDE. Така, че Ñ‚Ñ€Ñбва да използвате модифицираната верÑÐ¸Ñ Ð½Ð° програмата, коÑто Ñе намира на Ñтраницата на <a href="http://printing.kde.org/downloads">ÑиÑтемата за печат в KDE</a>. -Description[bn]=অনেকগà§à¦²à¦¿ ছোটো কাগজে à¦à¦•à¦Ÿà¦¿ বড় পোসà§à¦Ÿà¦¾à¦° ছাপানোর পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à¥¤ বà§à¦¯à¦¬à¦¹à¦¾à¦° করতে হলে <b>poster</b> পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à¦Ÿà¦¿ আপনার <tt>PATH</tt>-ঠথাকতে হবে। à¦à¦‡ পà§à¦°à§‹à¦—à§à¦°à¦¾à¦®à¦Ÿà¦¿à¦° সোরà§à¦¸ কোড পাওয়া যায় <a href="http://printing.kde.org/downloads">কে.ডি.ই.পà§à¦°à¦¿à¦¨à§à¦Ÿ ওয়েব সাইট</a> থেকে।<p><b><u>মনে রাখবেন:</u></b> কে.ডি.ই.পà§à¦°à¦¿à¦¨à§à¦Ÿ ওয়েব সাইটের পà§à¦¯à¦¾à¦•à§‡à¦œà¦Ÿà¦¿ মূল পà§à¦¯à¦¾à¦•à§‡à¦œà¦Ÿà¦¿à¦° (যেটি যে কোনো CTAN আরà§à¦•à¦¾à¦‡à¦­ মিরর-ঠপাওয়া যাবে) রূপানà§à¦¤à¦°à¦¿à¦¤ সংসà§à¦•à¦°à¦£, কিনà§à¦¤à§ মূল পà§à¦¯à¦¾à¦•à§‡à¦œà¦Ÿà¦¿ কে.ডি.ই.র সঙà§à¦—ে কাজ <b>করবে না</b>। <a href="http://printing.kde.org/downloads">কে.ডি.ই.পà§à¦°à¦¿à¦¨à§à¦Ÿ ওয়েব সাইট</a> থেকে পাওয়া পà§à¦¯à¦¾à¦•à§‡à¦œà¦Ÿà¦¿à¦‡ <b>বà§à¦¯à¦¬à¦¹à¦¾à¦° করতে হবে</b>। -Description[bs]=Alat za Å¡tampanje velikih postera na nekoliko manjih listova papira. Da biste koristili ovu naredbu, izvrÅ¡na datoteka <b>poster</b> mora biti dostupna u vaÅ¡em <tt>PATH</tt>-u. Izvorni kod za ovaj alat možete naći na <a href="http://printing.kde.org/downloads">KDEPrint web stranici</a>. <p><b><u>UPOZORENJE:</u></b> Paket koji se nalazi na KDEPrint web stranici je izmijenjena verzija originalnog koji se može naći na bilo kojem CTAN archive mirror, ali originalni paket <b>neće</b> raditi sa KDEom. <b>Morate</b> koristiti paket koji se nalazi na <a href="http://printing.kde.org/downloads">KDEPrint web stranici</a>. -Description[ca]=Utilitat per a imprimir grans pòsters en diversos fulls de paper. Per a usar aquest comandament, l'executable <b>poster</b> haurà d'estar accessible a la vostra <tt>PATH</tt>. El codi font per aquesta utilitat pot trobar-se en el <a href="http://printing.kde.org/downloads">lloc web del KDEPrint</a>. <p><b><u>ATENCIÓ:</u></b> El paquet en el lloc web del KDEPrint és una versió modificada de l'original que pot trobar-se en qualsevol rèplica de l'arxiu CTAN, però el paquet original <b>no</b> funciona amb el KDE. Així que <b>haureu</b> d'emprar el paquet que es troba en <a href="http://printing.kde.org/downloads">el lloc web del KDEPrint</a>. -Description[cs]=Nástroj pro tisk velkých plakátů na více menších listů. Aby bylo možné použít tento nástroj, je nutné aby byl dostupný program <b>poster</b>, tj. aby byl k nalezení v cestÄ› udané promnÄ›nnou <tt>PATH</tt>. Zdrojový kó tohoto nástroje je možné nalézt na <a href="http://printing.kde.org/downloads">www stránce nástroje KDEPrint</a>. <p><b><u>VAROVÃNÃ:</u></b> Balík, který je možné nalézt na webové stránce KDEPrintu je upravená verze originálu, který je k nalezení na každém archívu CTANu. Originální balík <b>nebude</b> s KDE fungovat. <b>Musíte</b> požít balík ze stránky<a href="http://printing.kde.org/downloads">KDEPrintu</a>. -Description[csb]=Nôrzãdze do drëkòwaniô wiôldżich plakatów (pòsterów) na wielu môłëch kôrtkach papióru. Bë gó brëkòwac na stegnie (zmiennô <tt>PATH</tt>) mòszi bëc przistãpnô programa <b>poster</b>. Zdrojowi kòd do ti programë je mòżno nalezc <a href="http://printing.kde.org/downloads"> na internetowi starnie Systemë Drëkù KDE</a>. <p><b><u>BÔCZËNK:</u></b> Paczét na starnie Systemë Drëkù KDE je zmòdifikòwónÄ… wersëjÄ… paczétu, chtërnegò originaÅ‚ przistãpny je w kôżdim archiwùm CPAN. Ã’riginôł równak <b>nie</b> dzałô pòd KDE. Mùszebnô je wersëjô ze <a href="http://printing.kde.org/downloads">staronë Systemë Drëkù KDE</a>. -Description[cy]=Cyleuster i argraffu posteri mawr ar dalennau bach lluosol o bapur. Er mwyn defnyddio'r gorchymyn yma, rhaid i'r gweithredadwyn <b>poster</b> fod yn gyraeddadwy yn eich <tt>PATH</tt>. Gall côd tarddiad i'r cyfleuster yma fod ar y <a href="http://printing.kde.org/downloads">wefan KDEPrint</a>. <p><b><u>RHYBUDD:</u></b>Mae'r pecyn sydd ar gael ar y wefan KDEPrint yn fersiwn addasiedig o'r un gwreiddiol sydd i'w ganfod ar unrhyw drych archif CTAN, ond <b>ni fydd</b> y pecyn gwreiddiol yn gweithio efo KDE. <b>Rhaid</b> i chi ddefnyddio'r pecyn sydd ar gael ar y <a href="http://printing.kde.org/downloads">wefan KDEPrint</a>. -Description[da]=Værktøj til udskrift af store plakater pÃ¥ flere smÃ¥ ark papir. Programmet <b>poster</b> skal være tilgængelig fra din sti (<tt>PATH</tt>) for at du kan bruge denne kommando. Værktøjets kildekode kan findes pÃ¥ <a href="http://printing.kde.org/downloads">KDEPrint's hjemmeside</a>. <p><b><u>ADVARSEL:</u></b> Pakken der findes pÃ¥ KDEPrint's hjemmeside, er en ændret version af den oprindelige som kan findes pÃ¥ enhver CTAN-arkivspejlside, men den oprindelige pakke vil <b>ikke</b> fungere med KDE. Du er <b>nødt til</b> at bruge pakken fra <a href="http://printing.kde.org/downloads">KDEPrint's hjemmeside</a>. -Description[de]=Dienstprogramm zum Drucken von Plakaten auf mehreren kleineren Blättern. Um diesen Befehl verwenden zu können, muss sich das Programm <b>poster</b> in Ihrem <tt>PATH</tt> befinden. Der Quellcode dafür lässt sich über die <a href="http://printing.kde.org/downloads">Webseiten des KDEPrint-Projekts</a> herunterladen.<p><b><u>Achtung:</u></b> Das Paket auf den KDEPrint-Seiten weist einige Veränderungen gegenüber dem Original auf. Letzeres ist beziehbar über jeden Spiegelserver des CTAN-Archivs, aber leider funktioniert diese Originalversion <b>nicht</b> mit KDE. Verwenden Sie also bitte die Version auf den <a href="http://printing.kde.org/downloads">KDEPrint-Seiten</a>. -Description[el]=ΕÏγαλείο για εκτÏπωση μεγάλων αφισών σε πολλές μικÏές σελίδες. Για να χÏησιμοποιήσετε αυτή την εντολή, το εκτελέσιμο <b>poster</b> Ï€Ïέπει να βÏίσκεται στο <tt>PATH</tt> σας. Ο πηγαίος κώδικας γι' αυτό το εÏγαλείο μποÏεί να βÏεθεί στο <a href="http://printing.kde.org/downloads">Δικτυακός τόπος του KDEPrint</a>. <p><b><u>ΠΡΟΕΙΔΟΠΟΙΗΣΗ:</u></b> Το πακέτο που βÏίσκεται στο δικτυακό τόπο του KDEPrint είναι μια Ï„Ïοποποιημένη έκδοση του Ï€Ïωτότυπου που μποÏεί να βÏεθεί σε οποιοδήποτε αÏχειοθήκη CTAN, αλλά το αÏχικό πακέτο <b>δε</b> θα δουλέψει με το KDE. <b>ΠÏέπει</b> να χÏησιμοποιήσετε το πακέτο που βÏίσκεται στο <a href="http://printing.kde.org/downloads">Δικτυακός τόπος του KDEPrint</a>. -Description[eo]=Ilo por presi grandajn plakatojn al multaj malgrandaj paperfolioj. Vi bezonas la programon <b>poster</b>. La kodon por tiu programo troveblas ĉe: <a href="http://printing.kde.org/downloads">KDEPresado ttt-paÄo</a>. <p><b><u>AVERTO:</u></b> la programo trovebla sur la KDEPresado ttt-paÄo estas ÅanÄita versio de tiu sur la CTAN-ttt-paÄo. La origina pakaĵo de CTAN ne laborus sub la KDE sistemo. Vi <b>devas</b> uzi la pakaĵon trovebla ĉe <a href="http://printing.kde.org/downloads">KDEPresado ttt-paÄo</a>. -Description[es]=Aplicación para imprimir posters grandes en varias hojas de papel. Para usar esta orden, el ejecutable <b>poster</b> debe estar accesible en su <tt>PATH</tt>. El código fuente de esta utilidad puede encontrarse en la <a href="http://printing.kde.org/downloads">página web de KDEPrint</a>. <p><b><u>AVISO:</u></b> el paquete en la página web KDEPrint es una versión modificada de la original que se puede encontrar en cualquier réplica de archivos de CTAN. Pero el paquete original <b>no</b> funciona con KDE,. Usted <b>debe</b> usar el paquete que se encuentra en <a href="http://printing.kde.org/downloads">el servidor web de KDEPrint</a>. -Description[et]=Vahend suurte postrite trükkimiseks mitmele väikesele paberilehele. Käsu kasutamiseks peab <b>postri</b> käivitusfail asuma sinu otsingurajal. Rakenduse lähtekoodi leiab <a href="http://printing.kde.org/downloads">KDEPrinti veebileheküljel</a>. <p><b><u>HOIATUS</u></b> KDEPrinti veebileheküljel olev pakett on muudetud võrreldes algsega, mille leiab suvaliselt CTAN-i arhiivi peeglilt, kuid originaalpakett <b>ei</b> toimi KDE-s. Sa lihtsalt <b>pead</b> kasutama paketti, mis asub <a href="http://printing.kde.org/downloads">KDEPrinti veebileheküljel</a>. -Description[eu]=Poster handiak orri txiki askotan inprimatzeko tresna. Komando hau erabiltzeko <b>poster</b> exekutagarriak zure <tt>BIDE-IZENEA</tt>an egon behar du. Tresna honen iturburua <a href="http://printing.kde.org/downloads">KDEPrint web gunen</a> egon daiteke. <p><b><u>ABISUA:</u></b> KDEPrint web gunean dagoen paketea jatorrizkoaren bertsio eraldatua da, edozein CTAN fitxategi-ispilutan aurki dezakezuna, baina jatorrizko paketeak <b>ez</b> du KDErekin funtzionatzen.<a href="http://printing.kde.org/downloads"> gunean dagoen paketea erabili <b>behar</b> duzu.</a> -Description[fa]=برنامۀ سودمندی برای چاپ پوسترهای بزرگ بر روی صÙحات کاغذ Ú©ÙˆÚ†Ú© چندگانه. برای استÙاده از این دستور <b>پوستر</b> باید در <tt>PATH</tt>شما قابل دسترسی باشد. کد منبع این ابزار می‌تواند در <a href="http://printing.kde.org/downloads">وب‌گاه KDEPrint</a> یاÙت شود. <p><b><u>اخطار:</u></b> بسته‌ی موجود در وب‌گاه KDEPrint نسخه‌ی تغییر یاÙته‌ای از بستۀ اصلی است، Ú©Ù‡ آن را می‌توان در هر آیینۀ بایگانی CTAN پیدا کرد، ولی نسخۀ اصلی با KDE کار >b/<نمی‌کند> b< شما باید از بسته‌ی <a href="http://printing.kde.org/downloads">وب‌گاه KDEPrint</a> استÙاده کنید. -Description[fi]=Työkalu isojen julisteiden tulostamiseen pienille paperiarkeille. Käyttääksesi komentoa <b>poster</b> ohjelman tulee olla polussasi. Tämän työkalun lähdekoodi löytyy KDEPrintin <a href="http://printing.kde.org/downloads">WWW-sivustolta</a>. <p><b><u>VAROITUS:</u></b>KDEPrintin sivuilla oleva paketti on muokattu versio alkuperäisestä CTAN-arkistossa olevasta paketista. Alkuperäinen paketti <b>ei</b> toimi KDE:n kanssa. Sinun <b>täytyy</b> käyttää KDEPrint WWW-sivuilta löytyvää versiota. -Description[fr]=Utilitaire pour imprimer de grandes affiches sur de multiples petites feuilles de papier. Pour utiliser cette commande, l'exécutable <b>poster</b> doit être accessible dans votre <tt>PATH</tt>. Vous pouvez trouver le code source de cet utilitaire à l'adresse <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. <p><b><u>Attention :</u></b> le paquetage présent sur le site web de KDEPrint est une version modifiée de l'original se trouvant sur n'importe quel miroir des archives du CTAN, mais le paquetage d'origine <b>ne fonctionnera pas</b> avec KDE. Vous <b>devez</b> utiliser le paquetage qui se trouve sur le <a href="http://printing.kde.org/downloads">site web de KDEPrint</a>. -Description[fy]=Helpprogramma foar it printsjen fan grutte posterformaten op lytse bôgen papier. Om dit kommando te brûken moat it programmma <b>poster</b> yn jo (<tt>$PATH</tt>) wêze. De boarnekoade foar dit helpprogramma fine jo op de <a href="http://printing.kde.org/downloads">webside</a> fan KDEPrint. <p><b><u>Warskôging:</u></b>It pakket dat oanbean wurdt op de webside fan KDEPrint is in fariant fan it orizjineel dat jo fine op eltse CTAN-argyfmirror, mar dit orizjineel wurket <b>net</b> op KDE. Jo moatte hjirre it pakket hawwe dat oanbean wurdt op de <a href="http://printing.kde.org/downloads">webside</a> fan KDEPrint. -Description[gl]=Utilidade para imprimir grandes cartaces en múltiplas follas de pequeno tamaño. Para empregar este comando, o executábel <b>poster</b> debe estar no seu <tt>PATH</tt>. O código fonte desta utilidade pode obter-se no <a href="http://printing.kde.org/downloads">Sítio Web de KDEPrint</a>. <p><b><u>PRECAUCIÓN:</u></b> O pacote que se atopa no sítio web de KDEPrint é unha versión modificada do programa orixinal que se pode atopar en calquer réplica CTAN, pero o pacote orixinal <b>non</b> funcionará con KDE. Vocé <b>deberá</b> empregar o pacote do <a href="http://printing.kde.org/downloads">Sítio Web de KDEPrint</a>. -Description[he]=כלי להדפסת כרזות גדולות על גבי מספר גיליונות נייר קטני×. כדי להשתמש בפקודה זו, קובץ התוכנית <b>poster</b> צריך להיות נגיש ב־<tt>PATH</tt> שלך. ×ת קוד המקור של כלי ×–×” ניתן ×œ×ž×¦×•× ×‘<a href="http://printing.kde.org/downloads">×תר ×”×ינטרנט של KDEPrint</a>.<p><b><u>×זהרה:</u></b> החבילה שנמצ×ת ב×תר של KDEPrint ×”×™× ×’×™×¨×¡×” ×¢× ×©×™× ×•×™×™× ×œ×¢×•×ž×ª הגירסה המקורית שניתן ×œ×ž×¦×•× ×‘×›×œ ×תר מר××” של ×רכיון CTAN. החבילה המקורית <b>ל×</b> תעבוד ×¢× KDE. ×תה <b>חייב</b> להשתמש בחבילה שנמצ×ת ב<a href="http://printing.kde.org/downloads">×תר ×”×ינטרנט של KDEPrint</a>. -Description[hi]=बहà¥à¤¤ से छोटे-छोटे कागज के पनà¥à¤¨à¥‹à¤‚ में बड़े पोसà¥à¤Ÿà¤° छापने की यूटिलिटी. इस कमांड- <b>poster</b> का उपयोग करने के लिठà¤à¤•à¥à¤œà¤¿à¤•à¥à¤¯à¥‚टेबल आपके पथ <tt>PATH</tt> के पà¤à¤¹à¥à¤š में होना चाहिà¤. इस यूटिलिटी का सà¥à¤°à¥‹à¤¤ कोड इस वेबसाइट से पà¥à¤°à¤¾à¤ªà¥à¤¤ किया जा सकता है- <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. <p><b><u>चेतावनी:</u></b> केडीई पà¥à¤°à¤¿à¤‚ट वेब साइट से पà¥à¤°à¤¾à¤ªà¥à¤¤ पैकेज मूल संसकरण का बदला क़िसà¥à¤® है जो किसी भी CTAN आरà¥à¤•à¤¾à¤‡à¤µ मिरर से पà¥à¤°à¤¾à¤ªà¥à¤¤ हो सकता है, परंतॠमूल पैकेज केडीई के साथ कारà¥à¤¯ <b>नहीं</b> करेगा. आप <b>आवशà¥à¤¯à¤• रूप से</b>इस साइट पर उपलबà¥à¤§ पैकेज इसà¥à¤¤à¥‡à¤®à¤¾à¤² करें <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. -Description[hr]=Alat za ispisivanje velikih postera na većem broju papira manje veliÄine. Za upotrijebljavanje ove naredbe potrebno je da izvrÅ¡na datoteka <b>poster</b> bude dostupna unutar opisa <tt>PATH</tt>. Izvodni kod ovog alata može se pronaći na <a href="http://printing.kde.org/downloads">KDEPrint web lokaciji</a>. <p><b><u>UPOZORENJE:</u></b> Paket na KDEPrint web lokaciji izmijenjena je verzija izvornog paketa, koji se može pronaći na bilo kojoj CTAN zrcalnoj lokaciji, ali izvorni paket <b>ne funkcionira</b> unutar KDE. <b>Morate</b> upotrijebiti paket koji se nalazi na <a href="http://printing.kde.org/downloads">KDEPrint web lokaciji</a>. -Description[hu]=Ezzel a szűrÅ‘vel nagy posztereket lehet kinyomtatni sok kis lapra. A parancs használatához a <b>poster</b> programfájl könyvtárának szerepelnie kell a <tt>PATH</tt> változóban. A program forráskódja letölthetÅ‘ <a href="http://printing.kde.org/downloads">a KDEPrint website</a>-ról. <p><b><u>Figyelem:</u></b> a website-on található csomag az eredeti program egy módosított változata (az eredeti bármelyik CTAN archívumból letölthetÅ‘), de az eredeti változat <b>nem</b> működik a KDE-vel, ezért <b>feltétlenül</b> a <a href="http://printing.kde.org/downloads">KDEPrint website</a>-on levÅ‘t használja! -Description[id]=Utilitas untuk mencetak poster besar dalam beberapa lembar kertas yang lebih kecil. Untuk menggunakan perintah ini, program <b>poster</b> harus dapat ditemukan di <tt>PATH</tt> Anda. Kode sumber untuk utilitas ini dapat diambil di <a href="http://printing.kde.org/downloads">situs web KDEPrint</a>. <p><b><u>PERINGATAN:</u></b> Paket yang ada di situs web KDEPrint web site adalah versi modifikasi dari program asli yang terdapat di mirror arsip CTAN manapun, tetapi paket yang asli <b>tidak</b> berfungsi dengan KDE. Anda <b>harus</b> menggunakan paket yagn ada di <a href="http://printing.kde.org/downloads">situs web KDEPrint</a>. -Description[is]=Forrit til að prenta stór veggspjöld á lítil blöð. Til að nota þessa skipun verður <b>poster</b>forritið að vera aðgengilegt á slóðinni <tt>path</tt> fumkóði að þessu forriti finnst á <a href="http://printing.kde.org/downloads">KDEPrint web site</a> <p><b><u>Aðvörun:</u></b> Forritið sem finnst á KDEPrint vefsíðunni er breytt útgáfa af upprunalegu útgáfunni sem finnst á öllum CTAN vefsvæðum, en upprunalegi pakkinn virkar <b>ekki</b> með KDE. Þú <b>verður</b> að nota pakkann sem er á:<a href="http://printing.kde.org/downloads">KDEPrint web site</a>. -Description[it]=Utilità per stampare poster grandi su più fogli piccoli. Per usare questo comando, l'eseguibile <b>poster</b> deve essere accessibile nel tuo <tt>PATH</tt>. È possibile trovare il codice sorgente di questa utilità sul <a href="http://printing.kde.org/downloads">sito Web di KDEPrint</a>. <p><b><u>ATTENZIONE:</u></b> il pacchetto presente sul sito Web di KDEPrint è una versione modificata dell'originale reperibile in un qualsiasi mirror CTAN, ma il pacchetto originale <b>non</b> funziona con KDE. <b>È necessario</b> usare il pacchetto del <a href="http://printing.kde.org/downloads">sito Web di KDEPrint</a>. -Description[ja]=複数ã®å°ã•ã„用紙を使ã£ã¦å¤§ããªãƒã‚¹ã‚¿ãƒ¼ã‚’å°åˆ·ã™ã‚‹ãŸã‚ã®ãƒ¦ãƒ¼ãƒ†ã‚£ãƒªãƒ†ã‚£ã§ã™ã€‚ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’使用ã™ã‚‹ã«ã¯ <tt>PATH</tt> ã« <b>poster</b> 実行ファイルãŒå­˜åœ¨ã™ã‚‹å¿…è¦ãŒã‚ã‚Šã¾ã™ã€‚ã“ã®ãƒ¦ãƒ¼ãƒ†ã‚£ãƒªãƒ†ã‚£ã®ã‚½ãƒ¼ã‚¹ã‚³ãƒ¼ãƒ‰ã¯ <a href="http://printing.kde.org/downloads">KDEPrint ウェブサイト</a> ã«ã‚ã‚Šã¾ã™ã€‚<p>注æ„: KDEPrint ウェブサイトã«ã‚るパッケージ㯠CTAN アーカイブミラーã«ã‚るオリジナルã«å¤‰æ›´ã‚’加ãˆãŸã‚‚ã®ã§ã™ã€‚オリジナルã®ã‚‚ã®ã¯ KDE ã§ã¯å‹•ãã¾ã›ã‚“。必㚠<a href="http://printing.kde.org/downloads">KDEPrint ウェブサイト</a> ã«ã‚るパッケージを使用ã—ã¦ãã ã•ã„。 -Description[ka]=პლáƒáƒ™áƒáƒ¢áƒ”ბის მცირე ზáƒáƒ›áƒ˜áƒ¡ ქáƒáƒ¦áƒáƒšáƒ“ებზე ბეჭდვის პáƒáƒ™áƒ”ტი. მის áƒáƒ¡áƒáƒ›áƒ£áƒ¨áƒáƒ•áƒ”ბლáƒáƒ“ სáƒáƒ­áƒ˜áƒ áƒáƒ, რáƒáƒ› პრáƒáƒ’რáƒáƒ›áƒ <b>poster</b> მისáƒáƒ¬áƒ•áƒ“áƒáƒ›áƒ˜ იყáƒáƒ¡ თქვენს <tt>PATH</tt>-ზე. áƒáƒ› პრáƒáƒ’რáƒáƒ›áƒ˜áƒ¡ პირველწყáƒáƒ áƒ შესáƒáƒ«áƒšáƒáƒ მáƒáƒ«áƒ”ბნáƒáƒ— სáƒáƒ˜áƒ¢áƒ–ე <a href="http://printing.kde.org/downloads">KDEPrint</a>. <p><b><u>ყურáƒáƒ“ღებáƒ:</u></b> პáƒáƒ™áƒ”ტები KDEPrint სáƒáƒ˜áƒ¢áƒ–ე მáƒáƒ“იფიცირებულირდრგáƒáƒœáƒ¡áƒ®áƒ•áƒáƒ•áƒ“ებრმáƒáƒ—გáƒáƒœ, რáƒáƒ›áƒšáƒ”ბიც CTAN áƒáƒ áƒ¥áƒ˜áƒ•áƒ¨áƒ˜áƒ, თუმცრპირველწყáƒáƒ áƒ პáƒáƒ™áƒ”ტები KDE-ში <b>áƒáƒ  იმუშáƒáƒ•áƒ”ბენ</b>. <b>áƒáƒ£áƒªáƒ˜áƒšáƒ”ბელიáƒ</b> პáƒáƒ™áƒ”ტები სáƒáƒ˜áƒ¢áƒ˜áƒ“áƒáƒœ <a href="http://printing.kde.org/downloads">KDEPrint</a>. -Description[kk]=Үлкен плакаттарды кішкентай парақтардан құраÑтырып баÑып шығару утилитаÑÑ‹. Бұл команданы қолдану үшін <b>poster</b> бағдарламаÑÑ‹ <tt>PATH</tt> жолыңызда орындауға дайын болу керек. Бұл утилитаның баÑтапқы мәтіні <a href="http://printing.kde.org/downloads">KDEPrint web site</a> Ñайтынан алуға болады. <p><b><u>ЕСКЕРТУ:</u></b> KDEPrint веб-Ñайттағы деÑте әрбір CTAN архив айнаÑындағы өзгерілген нұÑқаÑÑ‹, бірақ айнадағы нұÑқаÑÑ‹ KDE-де Ð¶Ò±Ð¼Ñ‹Ñ <b>Ñ–Ñтемейді</b>. ДеÑтені <b>міндетті</b>түрде <a href="http://printing.kde.org/downloads">KDEPrint web site</a> Ñайтынан алу керек. -Description[km]=ឧបករណáŸâ€‹áž”ោះពុម្ព​បáŸážŽáŸ’ណប្រកាស​ធំ​លើ​សន្លឹក​ក្រដាស​ážáž¼áž…​ៗជា​ច្រើន ។ ដើម្បី​ប្រើ​ពាក្យ​បញ្ជា​នáŸáŸ‡ <b>poster</b> ដែល​អាច​ប្រážáž·áž”ážáŸ’ážáž·áž”ាន ážáŸ’រូវ​ážáŸ‚​មាន​នៅ​ក្នុង <tt>PATH</tt> របស់​អ្នក ហើយ​ážáŸ‚ម​ទាំង​អាចចូលដំណើរការ​បាន ។កូដ​របស់​ឧបករណáŸâ€‹áž“áŸáŸ‡áž˜áž¶áž“នៅលើ <a href="http://printing.kde.org/downloads">áž‚áŸáž áž‘ំពáŸážš KDEPrint</a> ។ <p><b><u>ព្រមាន ៖</u></b> កញ្ចប់​ដែល​មាន​នៅ​លើ​គáŸáž áž‘ំពáŸážš KDEPrint គឺ​ជា​កំណែ​កែប្រែ​មួយ​របស់​កំណែ​ដើមដែល​មាន​នៅ​លើ​កញ្ចក់​បáŸážŽáŸ’ណសារ​របស់ CTAN ណាមួយ ប៉ុន្ážáŸ‚​កញ្ចប់​ដើម <b>មិន</b>ដំណើរការ​ជាមួយ KDE នោះទáŸÂ áŸ” អ្នក <b>ážáŸ’រូវážáŸ‚</b> ប្រើ​កញ្ចប់​ដែល​មាន​នៅលើ <a href="http://printing.kde.org/downloads">áž‚áŸáž áž‘ំពáŸážšâ€‹ážšáž”ស់ KDEPrint</a> ។ -Description[ko]=í° í¬ìŠ¤í„°ë¥¼ ìž‘ì€ ì¢…ì´ ì—¬ëŸ¬ìž¥ì— ë‚˜ëˆ  ì°ëŠ”ë° ì“°ì´ëŠ” ë„구입니다. ì´ ëª…ë ¹ì„ ì“°ë ¤ë©´ <tt>PATH</tt>ì— <b>poster</b>를 실행할 수 있는 경로가 들어 있어야 합니다. ì´ ëª…ë ¹ì€ <a href="http://printing.kde.org/downloads">KDE ì¸ì‡„ 웹 사ì´íŠ¸</a>ì—ì„œ ì°¾ì„ ìˆ˜ 있습니다. <p><b><u>경고:</u></b> KDE ì¸ì‡„ 웹 사ì´íŠ¸ì— 있는 꾸러미는 CTAN 저장고 미러ì—ì„œ ë‚´ë ¤ë°›ì€ ë³¸ë”” 꾸러미를 고친 것입니다. 본디 꾸러미는 KDEì—ì„œ ëŒì•„가지 <b>않습니다</b>. ë”°ë¼ì„œ <b>ê¼­</b> <a href="http://printing.kde.org/downloads">KDE ì¸ì‡„ 웹 사ì´íŠ¸</a>ì— ìžˆëŠ” 꾸러미를 쓰십시오. -Description[lb]=Hëllefsmëttel fir grouss Plakater op kleng Pabeiergréissten ze drécken. Fir dëse Kommando benotzen ze kënnen, muss den <b>poster</b> Programm an ärem <tt>PATH</tt> sinn. Den Quellcode vun dësem Hëllefsprogramm kann een op der <a href="http://printing.kde.org/downloads">KDEPrint-Websäit</a> fannen. <p><b><u>WARNUNG:</u></b>D'Distributioun, déi een op der KDEPrint-Websäit fënnt, ass eng modifizéiert Versioun vun der originaler, déi een op iergend engem CTAN-Archiv Mirror fanne kann. Déi original Distributioun funktionéiert <b>net</b> mat KDE. Dir <b>musst</b> dofir d'Distributioun vun der <a href="http://printing.kde.org/downloads"> KDEPrint web site</a> Websäit benotzen. -Description[lt]=ProgramÄ—lÄ—, skirta didelių afišų ant daugelio mažų popieriaus lapų spausdinimui. Norint naudoti Å¡iÄ… komandÄ…, <b>poster</b> vykdomoji byla turÄ—tų bÅ«ti JÅ«sų kelyje <tt>PATH</tt>. Å ios programÄ—lÄ—s iÅ¡eities tekstas yra <a href="http://printing.kde.org/downloads">KDEPrint žiniatinklio srityje</a>. <p><b><u>PERSPÄ–JIMAS:</u></b> KDEPrint žiniatinklio srityje esantis paketas yra modifikuota originalaus paketo, randamo bet kuriame CTAN archyve, versija, taÄiau originalus paketas <b>neveiks</b> su KDE. JÅ«s <b>turite</b> naudoti paketÄ… iÅ¡ <a href="http://printing.kde.org/downloads">KDEPrint žiniatinklio srities</a>. -Description[lv]=UtilÄ«ta plakÄtu drukÄÅ¡anai uz daudzÄm mazÄm lapÄm. Lai lietotu Å¡o komandu, <b>poster</b> jÄbÅ«t pieejamam JÅ«su ceÄ¼Ä <tt>PATH</tt>. Å Ä«s utilÄ«tas izejas kods ir atrodams <a href="http://printing.kde.org/downloads">KDEPrint tÄ«mekļa lapÄ</a>. <p><b><u>BRĪDINÄ€JUMS:</u></b> KDEPrint tÄ«mekļa lapÄ atodamÄ programmas versija ir modificÄ“ta. OrÄ£inÄls ir atrodams jebkurÄ CTAN arhÄ«va spoguļserverÄ«,bet orÄ£inÄlÄ programma <b>nedarbosies</b> ar KDE. Jums <b>ir jÄlieto</b> <a href="http://printing.kde.org/downloads">KDEPrint tÄ«mekļa lapÄ</a> atrodamÄ programmas versija. -Description[mk]=Ðлатка за печатење големи поÑтери на повеќе мали лиÑтови хартија.За да ја кориÑтите оваа команда, извршната датотека <b>poster</b>мора да е доÑтапна преку Вашиот <tt>PATH</tt>. Изворниот код за оваа алатка може да Ñе најде на <a href="http://printing.kde.org/downloads">KDEPrint веб Ñтраницата</a>. <p><b><u>ПРЕДУПРЕДУВÐЊЕ:</u></b> Пакетот што Ñе наоѓа на KDEPrint веб Ñтраницата е модифицирана верзија на оригиналниот кој може да Ñе најде на било која CTAN огледало-архива, но оригиналниот пакет<b>нема</b> да работи Ñо KDE. <b>Морате</b> да го кориÑтите пакетот што Ñенаоѓа на <a href="http://printing.kde.org/downloads">KDEPrint веб Ñајтот</a>. -Description[mn]=Том зарлалыг олон жижиг хуудÑууд дÑÑÑ€ Ñ…ÑвлÑÑ… Ñ…ÑÑ€ÑгÑÑл.Ð­Ð½Ñ Ñ‚ÑƒÑˆÐ°Ð°Ð»Ñ‹Ð³ Ñ…ÑÑ€ÑглÑхдÑÑ <b>poster</b>-ггүйцÑтгÑÑ…ÑÑÑ€ болгохдоо өөрийн<tt>PATH</tt> даа ханддаг болгох Ñ‘Ñтой. Ð­Ð½Ñ Ñ…ÑÑ€ÑгÑлийн ÑÑ… код <a href="http://printing.kde.org/downloads">KDEPrint вÑб хуудÑанд байгаа байх</a>. <p><b><u>СÐÐÐМЖ:</u></b> KDEPrint вÑб хуудÑанд ÑÑ… хувилбарын өөрчилөгдÑөн хувилбарууд олдох ба CTAN ариваар шахагдаж Ñ‚ÑƒÑ Ñ‚ÑƒÑын Ñайтан дÑÑÑ€ тавигдÑан байгаа.Харин ÑÑ… пакет КДЭ-Ñ‚Ñй <b>ажиллахгүй</b>. Та <a href="http://printing.kde.org/downloads">KDEPrint веб хуудÑааÑ</a> авÑан пакетаа Ñ…ÑÑ€ÑглÑÑ… <b>Ñ‘Ñтой</b>. -Description[ms]=Utiliti untuk mencetak poster besar pada banyak helaian kertas. Untuk menggunakan fungsi ini ini, <b>poster</b> boleh laksana mesti ada pada <tt>PATH</tt> anda.Kod sumber untuk utiliti ini ada di <a href="http://printing.kde.org/downloads">Laman KDEPrint</a>. <p><b><u>AMARAN:</u></b> Pakej di laman KDEPrint ialah versi telah diubah dari versi asal yang boleh diperoleh dari mana-mana cermin arkib CTAN. Namun, pakej asal <b>tidak</b> boleh berfungsi dengan KDE. Anda <b>mesti</b> menggunakan pakej yang terdapat di <a href="http://printing.kde.org/downloads">Laman KDEPrint</a>. -Description[nb]=Hjelpeprogram for Ã¥ skrive ut store plakater fordelt pÃ¥ mange smÃ¥ papirark. Du mÃ¥ ha <b>poster</b>-programmet i søkestien din, <tt>PATH</tt>. Kildekoden for dette programmet kan hentes fra <a href="http://printing.kde.org/downloads">KDEPrint-siden</a>. <p><b>ADVARSEL</u></b> Pakken som finnes pÃ¥ KDEPrint-siden er en modifisert utgave av originalen som kan finnes pÃ¥ alle CTAN-arkivspeil, men originalen virker <b>ikke</b> med KDE. Du <b>mÃ¥</b> bruke utgaven fra <a href="http://printing.kde.org/downloads">KDEPrint-siden</a>. -Description[nds]=Warktüüch, mit dat grote Biller op mennige lütte Sieden druckt warrn kann. Wenn Du dat bruken wullt, mutt dat Programm <b>poster</b> binnen Dien <tt>PATH</tt> wesen. De Bornkode dorför kann vun de <a href="http://printing.kde.org/downloads">KDEPrint-Nettsiet</a> daallaadt warrn.<p><b><u>Wohrscho:</u></b> Dat Paket vun KDEPrint is en ännert Verschoon vun dat Orginaalpaket, dat op jichtenseen CTAN Archiv-Mirror liggt, aver dat Orginaalpaket warrt <b>nich</b> mit KDE arbeiden. Du <b>muttst</b> dat Paket vun de <a href="http://printing.kde.org/downloads">KDEPrint-Nettsiet</a> bruken. -Description[ne]=बहà¥à¤µà¤¿à¤§ साना कागज पानाहरूमा ठूला पोषà¥à¤Ÿà¤°à¤¹à¤°à¥‚ मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¨ उपयोगी हà¥à¤¨à¥à¤› । यो आदेश पà¥à¤°à¤¯à¥‹à¤— गरà¥à¤¨, <b>पोषà¥à¤Ÿà¤°</b> कारà¥à¤¯à¤¾à¤¨à¥à¤µà¤¯à¤¨ योगà¥à¤¯ तपाईà¤à¤•à¥‹ <tt>बाटो</tt> मा पहà¥à¤à¤š पà¥à¤—à¥à¤¨à¥‡ हà¥à¤¨à¥à¤ªà¤°à¥à¤› । <a href="http://printing.kde.org/downloads">KDE मà¥à¤¦à¥à¤°à¤£ वेब साइट </a> मा यà¥à¤Ÿà¤¿à¤²à¤¿à¤Ÿà¥€à¤•à¤¾ लागि सà¥à¤°à¥‹à¤¤ सङà¥à¤•à¥‡à¤¤ हà¥à¤¨à¥à¤¸à¤•à¥à¤› । <p><b><u>चेतावनी:</u></b> KDE मà¥à¤¦à¥à¤°à¤£ वेब साइडमा फेला परेको पà¥à¤¯à¤¾à¤•à¥‡à¤œ मौलिक à¤à¤•à¤•à¥‹ परिमारà¥à¤œà¤¿à¤¤ ससà¥à¤•à¤°à¤£ हो जà¥à¤¨ कà¥à¤¨à¥ˆà¤ªà¤¨à¤¿ CTAN सङà¥à¤—à¥à¤°à¤¹ à¤à¤¨à¤¾à¤®à¤¾ फेला परà¥à¤¨ सकà¥à¤›, तर मौलिक पà¥à¤¯à¤¾à¤•à¥‡à¤œ KDE सà¤à¤— कारà¥à¤¯ <b>नगरà¥à¤¨</b>सकà¥à¤› । तपाईà¤à¤²à¥‡ <b>पà¥à¤°à¤¯à¥‹à¤— गरà¥à¤¨à¥à¤ªà¤°à¥à¤›</b> जà¥à¤¨ पà¥à¤¯à¤¾à¤•à¥‡à¤œ <a href="http://printing.kde.org/downloads">मा फेला परà¥à¤› </a> -Description[nl]=Hulpprogramma voor het afdrukken van grote posterformaten op kleine vellen papier. Om dit commando te gebruiken dient het programmma <b>poster</b> zich in uw zoekpad (<tt>$PATH</tt>) te bevinden. De broncode voor dit hulpprogramma kunt u vinden op de <a href="http://printing.kde.org/downloads">website</a> van KDEPrint. <p><b><u>Waarschuwing:</u></b> het pakket dat aangeboden wordt op de website van KDEPrint is een afgeleide versie. Het originele pakket kunt u vinden op elke CTAN-archiefmirror, maar dit pakket zal <b>niet</b> met KDE werken. U kunt <b>alleen</b> het pakket dat aangeboden wordt op de <a href="http://printing.kde.org/downloads">website</a> van KDEPrint gebruiken. -Description[nn]=Verktøy som let deg skriva ut store plakatar pÃ¥ fleire smÃ¥ ark. For Ã¥ bruka denne kommandoen, mÃ¥ programmet <b>poster</b> vera tilgjengeleg i søkjestigen (<tt>PATH</tt>). Kjeldekoden til dette verktøyet finn du pÃ¥ <a href="http://printing.kde.org/downloads">nettstaden til KDEPrint</a>. <p><b><u>Ã…TVARING:</u></b> Pakken som ligg pÃ¥ KDEPrint-nettstaden er ei tilpassa utgÃ¥ve av den opphavlege som du kan finna i CTAN-arkivet. Den opphavlege pakken fungerer <b>ikkje</b> med KDE. Du <b>mÃ¥</b> bruka pakken som ligg pÃ¥ <a href="http://printing.kde.org/downloads">KDEPrint-nettstaden</a>. -Description[nso]=Sebereka sago gatisa diswantsho tse kgolo go matlakala a mantshi a mannyane. Go somisa taelo ye, phethagatsego ya <b>seswantsho</b> e swanetse go tsenelega kago <tt>TSEJANA</tt> ya gago. Khoutu ya mothopo wa sebereka se ekaba ele go <a href="http://printing.kde.org/downloads">Lefelo la web la Kgatiso ya KDE</a>. <p> <b><u>TEMOSO:</u></b> Pakana yeo e hweditswego kago lefelo la web la Kgatiso ya KDE ke tsweletso yeo e kaonafaditswego ya ya mathomothomo yeo eka hwetswago kago seipone sa polokelo ya CTAN, efela pakana ya mathomothomo e <b>kase</b> beereke le KDE. O <b>swanetse</b> go somisa pakana yeo e hweditswego kago <a href="http://printing.kde.org/downloads">lefelo la web la Kgatiso ya KDE</a>. -Description[pa]=ਕਈ ਛੋਟੇ ਆਕਾਰ ਦੇ ਸਫਿਆ ਤੇ ਵੱਡਾ ਪੋਸਟਰ ਛਾਪਣ ਦੀ ਸਹੂਲਤ। ਇਹ ਕਮਾਂਡ , <b>ਪੋਸਟਰ</b> ਚੱਲਣਯੋਗ ਤà©à¨¹à¨¾à¨¡à©‡ <tt>ਰਸਤੇ</tt> ਵਿੱਚ ਹੋਣੀ ਲਾਜ਼ਮੀ ਹੈ। ਇਸ ਦਾ ਸਰੋਤ <a href="http://printing.kde.org/downloads">KDEPrint ਵੈੱਬ ਸਾਈਟ</a> ਤੋਂ ਲਿਆ ਜਾ ਸਕਦਾ ਹੈ <p><b><u>ਚੇਤਾਵਨੀ:</u></b> ਵੈੱਬ ਸਾਇਟ KDEPrint ਅਸਲੀ ਵਰਜਨ, ਜੋ ਕਿ CTAN ਸੰਕà©à¨šà¨¿à¨¤ ਤੇ ਮਿਲ ਸਕਦਾ ਹੈ, ਤੋਂ ਬਿਲਕà©à©±à¨² ਵੱਖਰਾ ਹੈ, ਪਰ ਅਸਲੀ ਪੈਕੇਜ KDE ਨਾਲ ਕੰਮ <b>ਨਹੀਂ</b> ਕਰਦਾ ਹੈ। ਤà©à¨¹à¨¾à¨¨à©‚à©° <b>ਇੱਥੇ</b>ਉਪਲੱਬਧ ਪੈਕੇਜ ਹੀ ਵਰਤਣਾ ਚਾਹੀਦਾ ਹੈ <a href="http://printing.kde.org/downloads">KDEPrint ਵੈੱਬ ਸਾਇਟ</a>। -Description[pl]=NarzÄ™dzie do drukowania dużych plakatów (posterów) na wielu maÅ‚ych kartkach papieru. Aby z niego skorzystać na Å›cieżce (zmienna <tt>PATH</tt>) musi być dostÄ™pny program <b>poster</>. Kod źródÅ‚owy do tego programu można znaleźć <a href="http://printing.kde.org/downloads"> na stronie internetowej Systemu Druku KDE</a>. <p><b><u>UWAGA:</u></b> Pakiet na stronie Systemu Druku KDE jest zmodyfikowanÄ… wersjÄ… pakietu, którego oryginaÅ‚ dostÄ™pny jest w każdym archiwum CPAN. Niestety oryginaÅ‚ <b>nie</b> dziaÅ‚a pod KDE. Konieczna jest wersja ze <a href="http://printing.kde.org/downloads">strony Systemu Druku KDE</a>. -Description[pt]=Um utilitário para imprimir posters grandes em várias folhas de papel mais pequenas. Para usar este comando, o executável <b>poster</b> deve estar acessível no seu <tt>PATH</tt>. O código-fonte para este utilitário pode ser encontrado no <a href="http://printing.kde.org/downloads">'site' Web do KDEPrint</a>. <p><b><u>ATENÇÃO:</u></b> O pacote existente no 'site' Web do KDEPrint é uma versão modificada do original que pode ser encontrado em qualquer réplica do CTAN, contudo o pacote original <b>não</b> irá funcionar no KDE. O utilizador <b>deve</b> usar o pacote existente no <a href="http://printing.kde.org/downloads">sítio Web do KDEPrint</a>. -Description[pt_BR]=Utilitário para a impressão de grandes cartazes em múltiplos papéis. Para usar este comando, o executável <b>poster</b> deve estar acessível em suia variável <tt>PATH</tt>. O código fonte para este utilitário pode ser encontrado no <a href="http://printing.kde.org/downloads">site do KDEPrint</a>. <p><b><u>AVISO:</u></b> O pacote encontrado no site do KDEPrint é uma versão modificada da original, que pode ser encontrada em qualquer mirror da CTAN, mas o pacote original <b>não</b> funcionará com o KDE. Você<b>deve</b> usar o pacote encontrado em um site do <a href="http://printing.kde.org/downloads">KDEPrint</a>. -Description[ro]=Utilitar de tipărit postere mari pe foi de hîrtie mici. Pentru a utiliza această comandă trebuie ca programul <b>poster</b> să fie accesibil prin variabila de mediu <tt>PATH</tt>. Codul sursă pentru acest utilitar poate fi găsit pe <a href="http://printing.kde.org/downloads">site-ul de web KDEPrint</a>. <p><b><u>ATENÅ¢IE:</u></b> Pachetul pe care îl găsiÅ£i pe site-ul de web KDEPrint este o versiune modificată a celui original aflat în arhiva CTAN. Versiunea originală <b>nu</b> va funcÅ£iona sub KDE. <b>Trebuie</b> să utilizaÅ£i versiunea modificată. -Description[ru]=Утилита печати больших плакатов на бумаге небольшого размера. Чтобы она работала, нужно чтобы программа <b>poster</b> была доÑтупна в вашем <tt>PATH</tt>. ИÑходники Ñтой утилиты можно найти на Ñайте <a href="http://printing.kde.org/downloads">KDEPrint</a>. <p><b><u>Ð’ÐИМÐÐИЕ:</u></b> Пакеты на Ñайте KDEPrint отличаютÑÑ Ð¾Ñ‚ тех, которые можно Ñкачать Ñ Ð·ÐµÑ€ÐºÐ°Ð»Ð° CTAN, но оригинальные пакеты <b>не будут</b> работать в KDE. Вам <b>необходимо</b> иÑпользовать пакеты Ñ Ñайта <a href="http://printing.kde.org/downloads">KDEPrint</a>. -Description[rw]=Porogaramu yo gucapa amashusho manini ku mpapuro ntoya nyinshi. Gukoresha iri bwirizwa, <b>ishusho</b> ritangizwa rigomba kuba rigerwaho mu <tt>NZIRA</tt> yawe. Kode nkomoko ijyanye n'yi porogaramu ishobora kuba<a href="http://printing.kde.org/downloads"> k'urubugamakuru KDEGucapa</a>.<p><b><u>IBURIRA:</u></b> Rukomatanya iboneka ku rubugamakuru KDEGucapa ni verisiyo ihinduwe y'iy'umwimerere ishobora gusangwa ku ndorerwamo bushyinguro CTAN iyo ariyo yose, ariko rukomatanya mwimerere <b>ntabwo</a>izakorana na KDE. <b>Ugomba</b> gukoresha rukomatanya iboneka <a href="http://printing.kde.org/downloads"> k'urubugamakuru KDEGucapa</a>. -Description[se]=Veahkkeprográmma stuorra plakáhtaid Äáliheapmái máŋgga unna báberárkii. Dán gohÄÄuma geavaheami várás <b>poster</b> prográmma galgá leat olamuttus du bálgás (<tt>PATH</tt>). Gáldokoda dán prográmma várás lea dáppe: <ahref="http://printing.kde.org/downloads">KDEPrint fierpmádatÄujuhus</a>.<p><b><u>VÃRUHUS:</u></b> KDEPrint:a fierbmádatbáikkis leahkki prográmma lea heivehuvvon verÅ¡uvdna originála prográmmas, mii gávdno man beare CTAN arkiivas. Originálaprográmma <b>ii<b> doaimma KDEs. Don <b>galggat<b> geavahit dan prográmma, mii lea dáppe: <a href="http://printing.kde.org/downloads">KDEPrint fierpmádatÄujuhus</a>. -Description[sk]=Nástroj pre tlaÄ veľkých plagátov na viacerých malých listoch. Aby ste ho mohli použiÅ¥, musíte maÅ¥ nainÅ¡talovaný program <b>poster</b> vo vaÅ¡ej <tt>PATH</tt>. Zdrojový kód tohto nástroja nájdete na <a href="http://printing.kde.org/downloads">WWW stránke KDEPrint</a>. <p><b><u>VAROVANIE:</u></b> Balík, ktorý je na WWW stránke KDEPrint je upravená verzia originálu, ktorý je v každom archíve CTANm ale originálny balík <b>nebude</b> v KDE fungovaÅ¥. <b>Musíte</b> použiÅ¥ balík z <a href="http://printing.kde.org/downloads">WWW stránky KDEPrint</a>. -Description[sl]=Orodje za tiskanje velikih plakatov na majhnih listih papirja. Za uporabo tega ukaza mora biti izvedljiva datoteka <b>poster</b> v vaÅ¡i poti <tt>PATH</tt>. Izvirna koda za to orodje je na voljo na <a href="http://printing.kde.org/downloads">spletni strani KDEPrint</a>. <p><b><u>OPOZORILO:</u></b> Paket, ki je na strani KDEPrint je spremenjena razliÄica originalne, ki je na voljo na vsakem zrcalnem strežniku arhivov CTAN, vendar pa ta <b>ne</b> dela s KDE. Uporabiti <b>morate</b> paket s <a href="http://printing.kde.org/downloads">spletne strani KDEPrint</a>. -Description[sq]=Vegël për shtypjen edhe ndarjen e pllakatave në letra të vogla. Për ta përdorur këtë komandë, <b>pllakata</b> ekzekutuese duhet të jetë e arrijshme në <tt>PATH</tt> e juaj. Kodi burimor për këtë vegël mund të gjindet në <a href="http://printing.kde.org/downloads">Web Faqën KDEPrint</a>. <p><b><u>VËREJTJE:</u></b> Pako e gjetur në web faqën e KDEPrint është verzion i ndryshuar nga origjinali, ky verzion mund të gjindet në çdo web faqe arkivore të CTAN pasqyrave, por verzioni origjinal <b>nuk punon</b> me sistemin KDE. Ju <b>duheni</b> ta përdorni pakon që gjendet në këtë web faqe: <a href="http://printing.kde.org/downloads">Web Faqja KDEPrint</a>. -Description[sr]=Ðлатка за штампање великих поÑтера на више малих папира. Да би Ñте кориÑтили ову наредбу, извршни фајл <b>poster</b> мора бити приÑтупачан кроз ваш <tt>PATH(путању)</tt>. Изворни код овог алата можете наћи на <a href="http=://printing.kde.org/downloads">KDEPrint веб Ñајту</a>. <p><b><u>Упозорење:</u></b> Пакет који Ñе налази на KDE Print веб Ñајту је измењена верзија оригинала који Ñе може наћи на било ком CTAN огледалу, али оригинални пакет <b>неће</b> радити Ñа KDE-ом. <b>Морате</b> кориÑтити пакет Ñа <a href="http://printing.kde.org/downloads">KDEPrint веб Ñајта</a>. -Description[sr@Latn]=Alatka za Å¡tampanje velikih postera na viÅ¡e malih papira. Da bi ste koristili ovu naredbu, izvrÅ¡ni fajl <b>poster</b> mora biti pristupaÄan kroz vaÅ¡ <tt>PATH(putanju)</tt>. Izvorni kod ovog alata možete naći na <a href="http=://printing.kde.org/downloads">KDEPrint veb sajtu</a>. <p><b><u>Upozorenje:</u></b> Paket koji se nalazi na KDE Print veb sajtu je izmenjena verzija originala koji se može naći na bilo kom CTAN ogledalu, ali originalni paket <b>neće</b> raditi sa KDE-om. <b>Morate</b> koristiti paket sa <a href="http://printing.kde.org/downloads">KDEPrint veb sajta</a>. -Description[sv]=Verktyg för att skriva ut stora affischer pÃ¥ flera smÃ¥ blad. För att använda kommandot mÃ¥ste det körbara programmet <b>poster</b> vara tillgängligt i <tt>PATH</tt>. Källkod för detta verktyg kan finnas pÃ¥ <a href="http://printing.kde.org/downloads">KDEPrints webbplats</a>. <p><b><u>Varning:</u></b> Paketet som finns pÃ¥ KDEPrints webbplats är en ändrad version av originalet som finns pÃ¥ alla CTAN-arkivplatser. Men originalpaketet fungerar <b>inte</b> med KDE, man <b>mÃ¥ste</b> använda paketet som finns pÃ¥ <a href="http://printing.kde.org/downloads">KDEPrints webbplats</a>. -Description[ta]=பலவித சிறிய தாளà¯à®•à®³à®¿à®²à¯ பெரிய போஸà¯à®Ÿà®°à¯à®•à®³à¯ˆ அசà¯à®šà®¿à®ªà¯à®ªà®¤à®±à¯à®•à®¾à®© பயனà¯à®ªà®¾à®Ÿà¯. இநà¯à®¤ கடà¯à®Ÿà®³à¯ˆà®¯à¯ˆ பயனà¯à®ªà®Ÿà¯à®¤à¯à®¤ <b>போஸà¯à®Ÿà®°à¯ </b>நிறà¯à®µà®²à¯ அணà¯à®•à®•à¯à®•à¯‚டியதாக <tt>உஙà¯à®•à®³à¯ பாதை இரà¯à®•à¯à®• வேணà¯à®Ÿà¯à®®à¯</tt>. இநà¯à®¤ பயனà¯à®ªà®¾à®Ÿà¯à®Ÿà¯à®•à¯à®•à®¾à®© மூல கà¯à®±à®¿à®¯à¯€à®Ÿà¯ கேடிஇஅசà¯à®šà¯ வலைதளதà¯à®¤à®¿à®²à¯ <a href="http://printing.kde.org/downloads">இரà¯à®•à¯à®•à¯à®®à¯</a>. <p><b><u>எசà¯à®šà®°à®¿à®•à¯à®•à¯ˆ:</u></b>கேடிஇ அசà¯à®šà¯ வலைதà¯à®¤à®³à®¤à¯à®¤à®¿à®²à¯ காணபà¯à®ªà®Ÿà¯à®®à¯ தொகà¯à®ªà¯à®ªà¯ மாறà¯à®±à®ªà¯à®ªà®Ÿà¯à®Ÿà¯à®³à¯à®³à®¤à¯. இத௠எலà¯à®²à®¾ CTAN காபà¯à®ªà®¤à¯à®¤à®¿à®²à¯à®®à¯ காணபà¯à®ªà®Ÿà¯à®®à¯.ஆனால௠அசல௠தொகà¯à®ªà¯à®ªà¯ கேடிஇயà¯à®Ÿà®©à¯ இயஙà¯à®•à®¾à®¤à¯.நீஙà¯à®•à®³à¯ <b></b> <a href="http://printing.kde.org/downloads">கேடிஇஅசà¯à®šà¯ வலைதளதà¯à®¤à®¿à®²à¯</a> உளà¯à®³ தொகà¯à®ªà¯à®ªà¯ˆà®¤à¯à®¤à®¾à®©à¯ பயனà¯à®ªà®Ÿà¯à®¤à¯à®¤ வேணà¯à®Ÿà¯à®®à¯</a>. -Description[te]=పెదà±à°¦ పొసà±à°Ÿà°°à±à°²à°¨à± చాలా à°šà°¿à°¨à±à°¨ కాగితాలపై à°ªà±à°°à°šà±à°°à°¿à°‚చెందà±à°•à± వాడె à°¯à±à°Ÿà°¿à°²à°¿à°Ÿà°¿. à°ˆ కారà±à°¯à°¾à°¨à±à°¨à°¿ వాడెందà±à°•à±, <b>poster</b> కారà±à°¯à°‚ మి <tt>PATH<tt> à°¦à±à°µà°¾à°°à°¾ à°…à°‚à°¦à±à°¬à°¾à°Ÿà±à°²à±Š à°µà±à°‚డాలి. దీని సంకేత à°°à°šà°¨ <a href="http://printing.kde.org/downloads">కెడిఈపà±à°°à°šà±à°°à°£ వెబౠసైటౠలొ దొరకవచà±à°šà± </a>. <p><b><u>హెచà±à°šà°°à°¿à°•:</u></b> కెడిఈపà±à°°à°šà±à°°à°£ వెబౠసైటౠలొ à°µà±à°¨à±à°¨ à°•à°Ÿà±à°Ÿ అసలà±à°¨à± కొదà±à°¦à°¿à°—à°¾ మారà±à°šà°¬à°¡à°¿à°¨ వివరణం, అసలౠఅదైనా సిటిà°à°à°¨à± ఆరà±à°•à±ˆà°µà± మిరà±à°°à°°à± లొ దొరà±à°•à±à°¤à±à°‚ది, కాని అసలౠకటà±à°Ÿ కెడిఈ తొ పని<b>చెయదà±</b>. మీరౠ<a href="http://printing.kde.org/downloads">కెడిఈపà±à°°à°šà±à°°à°£ వెబౠసైటà±</a> లొ దొరికె à°•à°Ÿà±à°Ÿà°¨à°¿ <b>మాతà±à°°à°®à±†</b> వాడాలి. -Description[tg]=Барномаҳои барои чопи Ñатроҳои бузург барои Ñафҳоти коғаз купак. Барои иÑтифода аз ин даÑтур <b>поÑтер</b> боÑд дар <tt>РОҲЧÐ</tt> шумо кобали даÑтурӣ бошад. Коди марҷа ин обзор метавонад дар <a href="http://printing.kde.org/downloads">KDEPrint Ñйти Ð’Ñб ёфта шавад</a>. <p><b><u>Огоҳӣ:</u></b> Пакете, ки нуÑхаи таъғиршуда буд, дар Ð’Ñби KDEPrint ёфта шуд, ва он дар Ñгон CTAN archive mirror мумкин аÑÑ‚ ки ёбад, лекин нуÑхаи аÑлиаш <b>дар KDE</b> кор намекунад. Шумо <b>боÑд</b> пакети ёфташударо иÑтифода кунед дар <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. -Description[th]=โปรà¹à¸à¸£à¸¡à¸­à¸£à¸£à¸–ประโยชน์สำหรับทำà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¹‚ปสเตอร์ขนาดใหà¸à¹ˆà¸¥à¸‡à¸šà¸™à¸à¸²à¸£à¸”าษà¹à¸œà¹ˆà¸™à¹€à¸¥à¹‡à¸à¸«à¸¥à¸²à¸¢à¹† à¹à¸œà¹ˆà¸™ ในà¸à¸²à¸£à¹ƒà¸Šà¹‰à¸„ำสั่งนี้ โปรà¹à¸à¸£à¸¡à¸„ำสั่ง <b>poster</b> จะต้องอยู่ใน <tt>พาธ</tt> ของคุณที่สามารถเข้าถึงได้ รหัสต้นฉบับของโปรà¹à¸à¸£à¸¡à¸™à¸µà¹‰à¸­à¸¢à¸¹à¹ˆà¸—ี่ <a href="http://printing.kde.org/downloads">เว็บไซต์ KDEPrint</a> <p><b><u>คำเตือน:</u></b> à¹à¸žà¹‡à¸„เà¸à¸ˆà¸—ี่พบบนเว็บไซต์ KDEPrint นั้นคือรุ่นที่มีà¸à¸²à¸£à¸›à¸£à¸±à¸šà¹€à¸›à¸¥à¸µà¹ˆà¸¢à¸™à¹„ปจาà¸à¸£à¸¸à¹ˆà¸™à¸”ั้งเดิม ที่คุณอาจจะพบที่เว็บสำรองของ CTAN à¹à¸•à¹ˆà¸£à¸¸à¹ˆà¸™à¸”ั้งเดิมนั้น <b>ไม่</b> สามารถทำงานà¸à¸±à¸š KDE ได้ คุณ<b>ต้อง</b> ใช้รุ่นที่พบที่เว็บไซต์ <a href="http://printing.kde.org/downloads">KDEPrint</a> เท่านั้น -Description[tt]=Olı posternı berniçä keçkenä qäğäz bitlärenä bastıruçı qoral bu. Anı qullanu öçen, <b>poster</b> yazılımı sineñ <tt>PATH</tt> aÅŸa tabılırlıq bulırÄŸa tieÅŸ. Bu qoral çığanaqların <a href="http://printing.kde.org/downloads">KDEPrint säxifäsendä</a> tabıp bula. <p><b><u>KÄ°SÄTMÄ:</u></b> KDEPrint säxifäsendäge çığanaqlar CTAN tuplamasındağı baÅŸ çığanaqlarınıñ üzgärtelgän söreme ul. BaÅŸ çığanaqlar KDE astında <b>eÅŸlämi</b>. Åžuña kürä, yazılım tuplamasın <a href="http://printing.kde.org/downloads">KDEPrint säxifäsennän</a> alırÄŸa <b>kiräk</b>. -Description[uk]=Утиліта Ð´Ð»Ñ Ð´Ñ€ÑƒÐºÑƒ великих плакатів на декількох малих аркушах. Щоб виконати цю команду, програма <b>poster</b> повинна знаходитиÑÑŒ у <tt>PATH</tt>. Вихідні файли цієї програми можна знайти на <a href="http://printing.kde.org/downloads">Ñайті заÑобу друку Ð´Ð»Ñ KDE - KDEPrint</a>. <p><b><u>ПОПЕРЕДЖЕÐÐЯ:</u></b> пакунок, що знаходитьÑÑ Ð½Ð° Ñайті KDEPrint, це змінена верÑÑ–Ñ Ð¾Ñ€Ð¸Ð³Ñ–Ð½Ð°Ð»ÑŒÐ½Ð¾Ñ— програми, Ñку можна знайти на будь-Ñкому дзеркалі архіву CTAN. Ðе змінена верÑÑ–Ñ <b>не</b> буде працювати з KDE. Ви <b>повинні</b> кориÑтуватиÑÑŒ пакунком з <a href="http://printing.kde.org/downloads">Ñайту KDEPrint</a>. -Description[uz]=Katta plakatlarni bir nechta kichik varaqlarga bosib chiqarish vositasi. Bu imkoniyatdan foydalanish uchun <b>poster</b> dasturi oÊ»rnatilgan direktoriya sizning <tt>$PATH</tt> muhit oÊ»zgaruvchingizda koÊ»rsatilgan boÊ»lishi shart. Bu dasturning kodini <a href="http://printing.kde.org/downloads">KDEPrint veb-saytidan</a> topsa boÊ»ladi.<p><b><u>DIQQAT:</u></b> KDEPrint veb-saytidagi paket hamma CTAN arxivlaridan topib boÊ»ladigan dasturning oÊ»zgartirilgan nusxasi. Dasturning asl nusxasi KDE bilan <b>ishlamaydi</b>. <a href="http://printing.kde.org/downloads">KDEPrint veb-saytidagi</a> paketni ishlatishingiz <b>shart</b>. -Description[uz@cyrillic]=Катта плакатларни бир нечта кичик варақларга боÑиб чиқариш воÑитаÑи. Бу имкониÑтдан фойдаланиш учун <b>poster</b> даÑтури ўрнатилган Ð´Ð¸Ñ€ÐµÐºÑ‚Ð¾Ñ€Ð¸Ñ Ñизнинг <tt>$PATH</tt> муҳит ўзгарувчингизда кўрÑатилган бўлиши шарт. Бу даÑтурнинг кодини <a href="http://printing.kde.org/downloads">KDEPrint веб-Ñайтидан</a> топÑа бўлади.<p><b><u>ДИҚҚÐТ:</u></b> KDEPrint веб-Ñайтидаги пакет ҳамма CTAN архивларидан топиб бўладиган даÑтурнинг ўзгартирилган нуÑхаÑи. ДаÑтурнинг аÑл нуÑхаÑи KDE билан <b>ишламайди</b>. <a href="http://printing.kde.org/downloads">KDEPrint веб-Ñайтидаги</a> пакетни ишлатишингиз <b>шарт</b>. -Description[ven]=Tshitikedzi khau phirintha dziphosithara khulwane kha ma bammbiri matuku manzhi. U shumisa muthetho uyu, <b>Phosithara</b> zwinotumulea zwi fanela u dzhenea kha <tt>PATH</tt>. Khoudu ya vhubvo ya tshitikedzi itshi ingavha kha <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. <p><b><u>WARNING:</u></b> Tshiputo tshi wanalaho kha KDEPrint web site ndi tshivhumbeo tsho dzudzanywaho tsha vhukuma tshine tshinga wanala kha tshivhoni, fhedzi tshiputo tsha tshavhukuma tshinga <b>si</b> shume nga KDE. Ni <b>u</b> shumisa tshiputo tsho wanalaho kha <a href="http://printing.kde.org/downloads">KDEPrint web site</a>. -Description[vi]=Tiện ích để in bích chÆ°Æ¡ng lá»›n ra nhiá»u tá» giấy nhá». Äể có khả năng sá»­ dụng lệnh này, tập tin chạy được <b>poster</b> phải cho phép truy cập trong Ä‘Æ°á»ng dẫn <tt>PATH</tt> của bạn. Có thể tìm mã nguồn cho tiện ích này trên <a href="http://printing.kde.org/downloads">nÆ¡i Mạng KDEPrint</a>. <p><b><u>CẢNH BÃO :</u></b> Gói được tìm trên nÆ¡i Mạng KDEPrint là má»™t phiên bản đã sá»­a đổi của gói gốc mà có thể được tìm trên bất kỳ máy nhân bản kho CTAN nào, nhÆ°ng mà gói gốc sẽ <b>không</b> hoạt Ä‘á»™ng vá»›i KDE. Bạn <b>phải</b> sá»­ dụng gói được tìm trên <a href="http://printing.kde.org/downloads">nÆ¡i Mạng KDEPrint</a>. -Description[wa]=Usteye po-z imprimer des lÃ¥djes posters so sacwantès foyes pus ptites et les poleur mete eshonne po-z aveur li grand poster. Po-z eployî l' comande, li programe <b>poster</b> doet esse dins vosse tchimin (<tt>PATH</tt>). Li côde sourdant po ciste usteye si trove sol <a href="http://printing.kde.org/downloads">waibe di KDEPrint</a>. <p><b><u>ASTEME:</u></b> Li pacaedje ki s' trove sol waibe da KDEPrint est ene modêye ene miete candjeye di l' oridjinÃ¥ (ki s' pout trover so tot l' minme li ké muroe d' årtchives do CTAN), ca l' oridjinÃ¥ n' rote <b>nén</b> avou KDE. Vos <b>dvoz</b> eployî li pacaedje k' est sol <a href="http://printing.kde.org/downloads">waibe di KDEPrint</a>. -Description[xh]=Uncedo lokushicilela izazisi eszinkulu kumakhasi amaphepha amaninzi. Ukusebenzisa lomyalelo, <b>isazisi</b> esiphumezekayo kufuneka sikwazi ukufumaneka kowakho <tt>UMENDO<tt>. Ikhowudi yemvelaphi yalento eluncedo inga kwi <a href="http://printing.kde.org/downloads">web site ye KDEPrint</a>. <p><b><u>ISILUMKISO:</u></b> Impahla efumaneke kwi we site ye KDEPrint iluguqulelo kancincane lomsesebenzi woqobo enokwazi ukufumaneka kuso nayiphi indawo yogcino yesipili se CTAN, kodwa impahla yoqobo ayizukusebenzelana ne KDE. Kufuneka usebenzise impahla ifumanwe <a href="http://printing.kde.org/downloads">kwi web site ye KDEPrint</a>. -Description[zh_CN]=此工具用于在多张纸上打å°å¤§åž‹çš„海报。è¦ä½¿ç”¨æ­¤å‘½ä»¤ï¼Œ<b>poster</b> å¯æ‰§è¡Œæ–‡ä»¶å¿…é¡»å¯åœ¨æ‚¨çš„ <tt>PATH</tt> 中访问到。此工具的æºä»£ç ä½äºŽ<a href="http://printing.kde.org/downloads">KDEPrint 网站</a>。<p><b><u>警告:</u></b>您虽然å¯ä»¥åœ¨ä»»ä½• CTAN 归档镜åƒæ‰¾åˆ°çš„原始版本,但是在 KDEPrint 网站上找到的包对其进行了修改,原因是原始的包<b>无法</b>用于 KDE。您<b>å¿…é¡»</b>使用在 <a href="http://printing.kde.org/downloads">KDEPrint 网站</a>上找到的包。 -Description[zh_HK]=將大型海報列å°åœ¨å¤šå¼µå°åž‹ç´™å¼µä¸Šçš„公用程å¼ã€‚è¦ä½¿ç”¨é€™å€‹å‘½ä»¤ï¼Œå¯åŸ·è¡Œæª”<b>poster</b>必須在你的<tt>PATH</tt>中。這個公用程å¼çš„原始碼å¯ä»¥åœ¨<a href="http://printing.kde.org/downloads"KDEPrint 網站</a>。<p><b><u>警告:</u></b>在 KDEPrint 網站上找到的套件是修改éŽçš„版本,而éžåœ¨ä»»ä½• CTAN 檔案庫é¡å°„站中å¯ä»¥æ‰¾åˆ°çš„原始版本,其原始套件<b>無法</b>在 KDE 下é‹ä½œã€‚ä½ <b>å¿…é ˆ</b>使用在<a href="http://printing.kde.org/downloads">KDEPrint 網站</a>上的套件。 -Description[zh_TW]=將大型海報列å°åœ¨å¤šå¼µå°åž‹ç´™å¼µä¸Šçš„公用程å¼ã€‚è¦ä½¿ç”¨é€™å€‹å‘½ä»¤ï¼Œå¯åŸ·è¡Œæª”<b>poster</b>必須在您的<tt>PATH</tt>中。這個公用程å¼çš„原始碼å¯ä»¥åœ¨<a href="http://printing.kde.org/downloads"KDEPrint 網站</a>。<p><b><u>警告:</u></b>在 KDEPrint 網站上找到的套件是修改éŽçš„版本,而éžåœ¨ä»»ä½• CTAN 檔案庫é¡å°„站中å¯ä»¥æ‰¾åˆ°çš„原始版本,其原始套件<b>無法</b>在 KDE 下é‹ä½œã€‚您<b>å¿…é ˆ</b>使用在<a href="http://printing.kde.org/downloads">KDEPrint 網站</a>上的套件。 -Description[zu]=Insebenziso yokushicicela amabhodi emiyalezo emikhulu kumapheshana ekhasi eliningana elincane. Ukusebenzisa lomyalelo, ibhodi <b> lomyalezo</b> eliphumelelisekayo kumele lingeniswe ngokunemvume kweyakho <tt>Indlela</tt>. Ikhodi lemvelaphi lalokhu k kusebenzisa kungaba kwi <a href="http://printing.kde.org/downloads"> kwindawo yeweb ye KDEPrint</a>. <p><b><u>Isexwayiso:</u></b> Iphakethe elitholakala kwindawo yeweb ye-KDEPrint inguguqulelo olushintshiweyo lwasekuqaleni lolo olungatholakala kunoma yisiphi isibuko somqulu we CTAN, kodwa iphakethe lasekuqaleni <b>angeke </b> lisebenze nge-KDE. Wena<b>kumele</b> usebenzise iphakethe elitholakala e <a href="http://printing.kde.org/downloads">kwindawo yeweb ye-KDEPrint</a>. -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript -Require=exec:/poster diff --git a/kdeprint/filters/poster.xml b/kdeprint/filters/poster.xml deleted file mode 100644 index a56b60db2..000000000 --- a/kdeprint/filters/poster.xml +++ /dev/null @@ -1,82 +0,0 @@ -<!DOCTYPE kprintfilter> -<kprintfilter name="poster" > -<filtercommand data="poster %filterargs %filterinput %filteroutput" /> - <filterargs name="__root__" description="Poster Printing" > -<filtergroup name="general" description="General" > -<filterarg format="-m%value" type="list" name="media" default="A4" description="Media Size" > - <value name="A0" description="A0" /> - <value name="A1" description="A1" /> - <value name="A2" description="A2" /> - <value name="A3" description="A3" /> - <value name="A4" description="A4" /> - <value name="A5" description="A5" /> - <value name="A6" description="A6" /> - <value name="A7" description="A7" /> - <value name="A8" description="A8" /> - <value name="A9" description="A9" /> - <value name="B1" description="B1" /> - <value name="B2" description="B2" /> - <value name="B3" description="B3" /> - <value name="B4" description="B4" /> - <value name="B5" description="B5" /> - <value name="B6" description="B6" /> - <value name="B7" description="B7" /> - <value name="B8" description="B8" /> - <value name="B9" description="B9" /> - <value name="B10" description="B10" /> - <value name="C5" description="Envelope C5" /> - <value name="DL" description="Envelope DL" /> - <value name="Comm10" description="Envelope US #10" /> - <value name="Tabloid" description="Tabloid" /> - <value name="Ledger" description="Ledger" /> - <value name="Executive" description="Executive" /> - <value name="Folio" description="Folio" /> - <value name="Legal" description="US Legal" /> - <value name="Letter" description="US Letter" /> -</filterarg> - <filterarg format="-p%value" type="list" name="size" default="default" description="Poster Size" > - <value name="A0" description="A0" /> - <value name="A1" description="A1" /> - <value name="A2" description="A2" /> - <value name="A3" description="A3" /> - <value name="A4" description="A4" /> - <value name="A5" description="A5" /> - <value name="A6" description="A6" /> - <value name="A7" description="A7" /> - <value name="A8" description="A8" /> - <value name="A9" description="A9" /> - <value name="B1" description="B1" /> - <value name="B2" description="B2" /> - <value name="B3" description="B3" /> - <value name="B4" description="B4" /> - <value name="B5" description="B5" /> - <value name="B6" description="B6" /> - <value name="B7" description="B7" /> - <value name="B8" description="B8" /> - <value name="B9" description="B9" /> - <value name="B10" description="B10" /> - <value name="C5" description="Envelope C5" /> - <value name="DL" description="Envelope DL" /> - <value name="Comm10" description="Envelope US #10" /> - <value name="Tabloid" description="Tabloid" /> - <value name="Ledger" description="Ledger" /> - <value name="Executive" description="Executive" /> - <value name="Folio" description="Folio" /> - <value name="Legal" description="US Legal" /> - <value name="Letter" description="US Letter" /> - <value name="default" description="Use Media Size" /> - <value name="%psu" description="Use Original Print Size" /> </filterarg> </filtergroup> - <filtergroup name="margin" description="Margins" > -<filterarg format="-c%value%" type="int" min="0" max="100" name="cut" default="5" description="Cut Margin (% of media size)" /> - <filterarg format="-w%value%" type="int" min="0" max="100" name="white" default="0" description="White Margin (% of media size)" /> </filtergroup> - <filtergroup name="extra" description="Misc" > -<filterarg format="-f" type="bool" name="feed" default="false" description="Manual Feed" > -<value name="false" description="Disabled" /> - <value name="true" description="Enabled" /> </filterarg> - <filterarg format="-P%value" type="string" name="select" default="" description="Page Selection" /> </filtergroup> </filterargs> - <filterinput> -<filterarg format="%in" name="file" /> - <filterarg format="" name="pipe" /> </filterinput> - <filteroutput> -<filterarg format="-o%out" name="file" /> - <filterarg format="> %out" name="pipe" /> </filteroutput></kprintfilter> diff --git a/kdeprint/filters/ps2pdf.desktop b/kdeprint/filters/ps2pdf.desktop deleted file mode 100644 index 841795040..000000000 --- a/kdeprint/filters/ps2pdf.desktop +++ /dev/null @@ -1,92 +0,0 @@ -[KDE Print Filter Entry] -Name=ps2pdf -Name[af]=ps-na-pdf -Name[csb]=Kònwersëjô PS do PDF -Name[pl]=Konwersja PS do PDF -Name[pt_BR]=Conversão de PS para PDF -Name[sv]=Ps2pdf -Name[te]=పిఎసà±2పిడిఎఫౠ-Require=exec:/gs -Comment=PostScript to PDF Converter -Comment[af]=Postscript na Pdf Omskakelaar -Comment[ar]=محول مستندات بوست سكريبت إلى PDF -Comment[az]=PostScript - PDF Çeviricisi -Comment[be]=ПераўтварÑнне з PostScript у PDF -Comment[bs]=Pretvaranje PostScripta u PDF -Comment[ca]=Convertidor de PostScript a PDF -Comment[cs]=Konvertor Postscriptu do PDF -Comment[csb]=Kònwerter lopków z fòrmatu PostScriptu do PDF -Comment[cy]=Trosydd PostScript i PDF -Comment[da]=PostScript-til-PDF-konvertering -Comment[de]=Umwandlung von PDF-Dateien in PostScript -Comment[el]=ΜετατÏοπέας από PostScript σε PDF -Comment[eo]=Konvertilo de la dokumenttipo PS al PDF -Comment[es]=Conversor de PostScript a PDF -Comment[et]=PostScript->PDF teisendamine -Comment[eu]=PostScript-etik PDFrako bihurtzailea -Comment[fa]=مبدل پست‌اسکریپت به PDF -Comment[fi]=Muunnin PostScriptistä PDF-muotoon -Comment[fr]=Convertisseur PostScript vers PDF -Comment[fy]=Konversje fan PostSkript nei PDF -Comment[ga]=Tiontaire PostScript go PDF -Comment[gl]=Conversor de PostScript a PDF -Comment[he]=ממיר מ־PostScript ל־PDF -Comment[hi]=PS से PDF के लिठरूपानà¥à¤¤à¤°à¤• -Comment[hr]=Pretvaranje iz PostScripta u PDF -Comment[hsb]=konwerter PostScript na PDF -Comment[hu]=PostScript -> PDF konvertálóprogram -Comment[id]=Konverter PostScript ke PDF -Comment[is]=Breytir Postscript skjölum í PDF-skjöl -Comment[it]=Convertitore da PostScript a PDF -Comment[ja]=PostScript ã‹ã‚‰ PDF ã«å¤‰æ› -Comment[ka]=PostScript-ის PDF-ში გáƒáƒ áƒ“áƒáƒ¥áƒ›áƒœáƒ -Comment[kk]=PostScript пішімнен PDF пішімге айналдыру -Comment[km]=កម្មវិធី​បម្លែង PostScript ទៅ PDF -Comment[ko]=í¬ìŠ¤íŠ¸ìŠ¤í¬ë¦½íŠ¸ë¥¼ PDF 문서로 바꿔ì¤ë‹ˆë‹¤ -Comment[lb]=PostScript zu PDF Konvertéierer -Comment[lt]=PostScript į PDF konverteris -Comment[lv]=No PostScript uz PDF konvertors -Comment[mk]=Конвертор од PostScript во PDF -Comment[mn]=PostScript-ÑÑÑ PDF-Ñ€Ò¯Ò¯ хөрвүүлÑлÑгч -Comment[ms]=Pengubah PostScript ke PDF -Comment[mt]=Konvertitur PostScript għal PDF -Comment[nb]=Postscript/PDF-dokumentkonvertering -Comment[nds]=Wannelt PostScript na PDF üm -Comment[ne]=PDF रूपानà¥à¤¤à¤°à¤•à¤®à¤¾ पोषà¥à¤Ÿà¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ -Comment[nl]=Conversie van PostScript naar PDF -Comment[nn]=Konvertering mellom PostScript og PDF -Comment[nso]=Mofetosetsi wa PostScript go PDF -Comment[pa]=ਪੋਸਟ ਸਕà©à¨°à¨¿à¨ªà¨Ÿ ਤੋਂ PDF ਤਬਦੀਲੀਕਾਰ -Comment[pl]=Konwerter plików z formatu PostScriptu do PDF -Comment[pt]=Conversor de PostScript para PDF -Comment[pt_BR]=Conversão de PostScript para PDF -Comment[ro]=Convertor de la PDF la PostScript -Comment[ru]=Преобразование PostScript в PDF -Comment[rw]=Iyandikanyuma kuri Muhindura PDF -Comment[se]=Konverter PostScript:as PDF'ii -Comment[sk]=Prevod súborov PostScript do PDF -Comment[sl]=Pretvornik datotek PostScript v PDF -Comment[sq]=Shëndrues i skedave PostScript ne PDF -Comment[sr]=Конвертор из PostScript-а у PDF -Comment[sr@Latn]=Konvertor iz PostScript-a u PDF -Comment[ss]=Kusukela ku-PostScript kuya kusiguculi se PDF -Comment[sv]=Postscript till PDF-konverterare -Comment[ta]=PostScript இலிரà¯à®¨à¯à®¤à¯ PDF இறà¯à®•à¯ மாறà¯à®±à®¿ -Comment[te]=పొసà±à°Ÿà± à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± à°¨à±à°‚à°šà°¿ పిడిఎఫౠమారà±à°šà±†à°¦à°¿ -Comment[tg]=Табодули PostScript ба PDF -Comment[th]=ตัวà¹à¸›à¸¥à¸‡à¹‚พสต์สคริปต์ไปเป็น PDF -Comment[tr]=PostScript'ten PDF'e Çevirici -Comment[tt]=PostScript–›PDF Äyländergeçe -Comment[uk]=Конвертер документів з формату PostScript в PDF -Comment[uz]=PostScrip'ni PDF'ga aylantiradigan dastur -Comment[uz@cyrillic]=PostScrip'ни PDF'га айлантирадиган даÑтур -Comment[ven]=Bammbiri la poso uya kha mushandukisi wa PDF -Comment[vi]=Bá»™ chuyển đổi PostScript sang PDF -Comment[wa]=Covierseu di PostScript viè PDF -Comment[xh]=PostScript Kumguqili we PDF -Comment[zh_CN]=PostScript 到 PDF 的转æ¢å™¨ -Comment[zh_HK]=PostScript 至 PDF 轉æ›å™¨ -Comment[zh_TW]=PostScript 至 PDF 轉æ›å™¨ -Comment[zu]=Umguquli we-PostScript se-DPF -MimeTypeIn=application/postscript -MimeTypeOut=application/pdf diff --git a/kdeprint/filters/ps2pdf.xml b/kdeprint/filters/ps2pdf.xml deleted file mode 100644 index 15b1005b6..000000000 --- a/kdeprint/filters/ps2pdf.xml +++ /dev/null @@ -1,152 +0,0 @@ -<!DOCTYPE kprintfilter> -<kprintfilter name="ps2pdf" > - <filtercommand data="gs -q -dSAFER -dPARANOIDSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%filteroutput -sPAPERSIZE=%psl %filterargs -c .setpdfwrite -f %filterinput" /> - <filterargs name="__root__" description="ps2pdf" > - <filtergroup name="general" description="General" > - <filterarg format="-dPDFSETTINGS=%value" type="list" name="targetdevice" default="/default" description="Target device" > - <value name="/default" description="Default" /> - <value name="/screen" description="Screen" /> - <value name="/printer" description="Printer" /> - <value name="/prepress" description="Prepress" /> - </filterarg> - <filterarg format="-dCompatibilityLevel=%value" type="list" name="compat" default="gs-def" description="Compatibility Level" > - <value name="gs-def" description="GhostScript Default Setting" /> - <value name="1.2" description="Level 1.2" /> - <value name="1.3" description="Level 1.3" /> - </filterarg> - <filterarg format="-dAutoRotatePages=%value" type="list" name="autorotate" default="/PageByPage" description="Auto rotate pages" > - <value name="/None" description="Disabled" /> - <value name="/PageByPage" description="Page by Page" /> - <value name="/All" description="Dominant orientation" /> - </filterarg> - </filtergroup> - <filtergroup name="image" description="Image Options" > - <filtergroup name="colorimage" description="Color Images" > - <filtergroup name="colorcompress" description="Compression" > - <filterarg format="-dEncodeColorImages=%value" type="bool" name="colorencode" default="true" description="Encode color images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dAutoFilterColorImages=%value" type="bool" name="colorautofilt" default="true" description="Auto encode color images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dColorImageFilter=%value" type="bool" name="colorencodetype" default="/DCTEncode" description="Manual color image encoding method" > - <value name="/FlateEncode" description="Flate compression" /> - <value name="/DCTEncode" description="JPEG compression" /> - </filterarg> - </filtergroup> - <filterarg format="-dDownsampleColorImages=%value" type="bool" name="coldownsampl" default="false" description="Downsample color images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dColorImageResolution=%value" type="int" min="9" max="2400" name="colimageres" default="300" description="Maximum color image resolution" /> - <filterarg format="-sColorImageDownsampleType=%value" type="list" name="colsampltype" default="Subsample" description="Color image downsampling method" > - <value name="Subsample" description="Sub-sampling" /> - <value name="Average" description="Averaging" /> - <value name="Bicubic" description="Bicubic interpolation" /> - </filterarg> - <filterarg format="-dColorImageDepth=%value" type="list" name="coldepth" default="-1" description="Color image depth" > - <value name="-1" description="Use the depth of the original" /> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - </filterarg> - </filtergroup> - <filtergroup name="grayimage" description="Grayscale Images" > - <filtergroup name="graycompress" description="Compression" > - <filterarg format="-dEncodeGrayImages=%value" type="bool" name="grayencode" default="true" description="Encode grayscale images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dAutoFilterGrayImages=%value" type="bool" name="grayautofilt" default="true" description="Auto encode grayscale images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dEncodeGrayImages=%value" type="bool" name="grayencodetype" default="/DCTEncode" description="Manual grayscale image encoding method" > - <value name="/FlateEncode" description="Flate compression" /> - <value name="/DCTEncode" description="JPEG compression" /> - </filterarg> - </filtergroup> - <filterarg format="-dDownsampleGrayImages=%value" type="bool" name="graydownsampl" default="false" description="Downsample grayscale images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dGrayImageResolution=%value" type="int" min="9" max="2400" name="grayimageres" default="300" description="Maximum grayscale image resolution" /> - <filterarg format="-sGrayImageDownsampleType=%value" type="list" name="graysampltype" default="Subsample" description="Grayscale image downsampling method" > - <value name="Subsample" description="Sub-sampling" /> - <value name="Average" description="Averaging" /> - <value name="Bicubic" description="Bicubic interpolation" /> - </filterarg> - <filterarg format="-dGrayImageDepth=%value" type="list" name="graydepth" default="-1" description="Grayscale image depth" > - <value name="-1" description="Use the depth of the original" /> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - </filterarg> - </filtergroup> - <filtergroup name="monoimage" description="Mono Images" > - <filtergroup name="monocompress" description="Compression" > - <filterarg format="-dEncodeMonoImages=%value" type="bool" name="monoencode" default="true" description="Encode mono images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dAutoFilterMonoImages=%value" type="bool" name="monoautofilt" default="true" description="Auto encode mono images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dEncodeMonoImages=%value" type="bool" name="monoencodetype" default="/CCITTFaxEncode" description="Manual mono image encoding method" > - <value name="/CCITTFaxEncode" description="CCITT compression" /> - <value name="/FlateEncode" description="Flate compression" /> - </filterarg> - </filtergroup> - <filterarg format="-dDownsampleMonoImages=%value" type="bool" name="downsamplmono" default="false" description="Downsample mono images" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dMonoImageResolution=%value" type="int" min="0" max="2400" name="monores" default="300" description="Maximum mono image resolution" /> - <filterarg format="-sMonoImageDownsampleType=%value" type="list" name="monosampltype" default="Subsample" description="Mono image downsampling method" > - <value name="Subsample" description="Sub-sampling" /> - <value name="Average" description="Averaging" /> - <value name="Bicubic" description="Bicubic interpolation" /> - </filterarg> - <filterarg format="-dMonoImageDepth=%value" type="list" name="monodepth" default="-1" description="Mono image depth" > - <value name="-1" description="Use the depth of the original" /> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - </filterarg> - </filtergroup> - </filtergroup> - <filtergroup name="fonts" description="Fonts" > - <filterarg format="-dEmbedAllFonts=%value" type="bool" name="embedfonts" default="true" description="Embed all fonts" > - <value name="true" description="Enabled" /> - <value name="false" description="Disabled" /> - </filterarg> - <filterarg format="-dSubsetFonts=%value" type="bool" name="fontsubsets" default="true" description="Embed font subsets" > - <value name="true" description="Embed subset" /> - <value name="false" description="Embed complete font" /> - </filterarg> - <filterarg format="-dMaxSubsetPct=%value" type="int" min="0" max="100" name="fontsubsetpct" default="100" description="Maximum font subset percentage" /> - <filterarg format="-r%value" type="list" name="resol" default="300x300" description="Bitmap font resolution" > - <value name="72x72" description="72 dpi" /> - <value name="144x144" description="144 dpi" /> - <value name="300x300" description="300 dpi" /> - <value name="600x600" description="600 dpi" /> - <value name="1200x1200" description="1200 dpi" /> - <value name="2400x2400" description="2400 dpi" /> - </filterarg> - </filtergroup> - </filterargs> - <filterinput> - <filterarg format="%in" name="file" /> - <filterarg format="-" name="pipe" /> - </filterinput> - <filteroutput> - <filterarg format="%out" name="file" /> - <filterarg format="-" name="pipe" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/psbook.desktop b/kdeprint/filters/psbook.desktop deleted file mode 100644 index c574fd9bb..000000000 --- a/kdeprint/filters/psbook.desktop +++ /dev/null @@ -1,93 +0,0 @@ -[KDE Print Filter Entry] -Name=psbook -Name[af]=psboek -Name[de]=PS-Book -Name[eo]=PS-libro -Name[hi]=पीà¤à¤¸-बà¥à¤• -Name[mn]=PS-ном -Name[nso]=psbuka -Name[sv]=broschyr -Name[ta]=psபà¯à®¤à¯à®¤à®•à®®à¯ -Name[te]=పిఎసౠబà±à°•à± -Name[ven]=Bugu ya ps -Name[zu]=incwadi ye-ps -Require=exec:/psbook,exec:/psnup -Comment=Pamphlet Printing (use with small side duplex printing) -Comment[af]=Pamflet Besig om te druk (gebruik met klein kant dupleks Besig om te druk) -Comment[ar]=طباعة الكتيبات (استخدمه مع الطباعة المزدوجة الصغيرة) -Comment[az]=Pamphlet Çap Sistemi -Comment[bn]=পà§à¦¯à¦¾à¦®à¦«à§à¦²à§‡à¦Ÿ মà§à¦¦à§à¦°à¦£ (ছোট মাপের ডà§à¦ªà§à¦²à§‡à¦•à§à¦¸ পà§à¦°à¦¿à¦¨à§à¦Ÿà¦¿à¦‚ সহযোগে বà§à¦¯à¦¬à¦¹à¦¾à¦° করà§à¦¨) -Comment[bs]=Å tampanje pamfleta (koristiti sa small side duplex Å¡tampanjem) -Comment[ca]=Impressor de pamflets (emprar amb la impressió a doble cara petita) -Comment[cs]=Tisk letáku (použití pro oboustranný tisk s úzkými okraji) -Comment[csb]=Dëkòwanié broszurów (brëkòwac z dwastarnym wëdrëkã krótszÄ… starnÄ…) -Comment[cy]=Argraffu Pamffled (defnyddio efo argraffu dwy-ochr, ochr bach) -Comment[da]=Pamflet-udskrift - (brug med lille side dupleks-udskrift) -Comment[de]=Booklet-Druck (mit schmalseitigem Duplexdruck verwendbar) -Comment[el]=ΕκτÏπωση φυλλαδίου (χÏήση μαζί με εκτÏπωση διπλής όψης μικÏής πλευÏάς) -Comment[eo]=Pamflet-presado (uzu kun duflanka laÅ­larÄa presado) -Comment[es]=Impresión de folleto (usar con impresión de doble cara pequeña) -Comment[et]=Brošüüri trükkimine - (kasutatakse duplekstrükkimisel) -Comment[eu]=Liburuxka inprimatzea (erabili orrialde txikiko inprimatze-bikoitzean) -Comment[fa]=چاپ جزوه)با استÙاده از سمت Ú©ÙˆÚ†Ú© چاپ دوسویه( -Comment[fi]=Lentolehtistulostus (käytä lyhyen sivun kaksipuoleistulostusta) -Comment[fr]=Impression au format livret (à utiliser avec l'impression duplex de petits feuillets) -Comment[fy]=Pamflet printsje(te brûken mei smelle kant fan dupleksôfdruk) -Comment[ga]=Priontáil Phaimfléid (úsáid le priontáil dhéphléacsach - taobh gearr) -Comment[gl]=Impresión de Panfletos (utilice con impresión en duplex polo lado pequeno) -Comment[he]=הדפסת חוברות (לשימוש ×¢× ×”×“×¤×¡×” דו־כיוונית בצד הקטן) -Comment[hi]=पेमà¥à¤«à¤²à¥‡à¤Ÿ छपाई(small side duplex printing के साथ ईसà¥à¤¤à¤®à¤¾à¤² करें) -Comment[hr]=Ispis pamfleta (za dvostruki ispis na male stranice) -Comment[hu]=Szórólapnyomtatás (kisalakú duplex nyomtatáshoz) -Comment[id]=Pencetakan Pamflet (gunakan pencetakan dupleks sisi pendek) -Comment[is]=Bæklingaprentun (nota með smárri tvíhliðaprentun) -Comment[it]=Stampa libretto (da usare con la stampa fronte/retro dal lato corto) -Comment[ja]=å°å†Šå­ã®å°åˆ· - (短辺ã¨ã˜ä¸¡é¢å°åˆ·ã‚’使用) -Comment[ka]=პáƒáƒ›áƒ¤áƒšáƒ”ტური ბეჭდვრ(áƒáƒ áƒ›áƒ®áƒ áƒ˜áƒ•áƒ˜ ბეჭდვრმáƒáƒ™áƒšáƒ” მხრიდáƒáƒœ) -Comment[kk]=Кітапшаны баÑып шығару (кішірейтілген екі жакты баÑу) -Comment[km]=ការបោះពុម្ព​ážáž·ážáž”áŸážŽáŸ’ណ (ប្រើ​ជាមួយ​នឹង​ការបោះពុម្ព​សងážáž¶áž„​ážáž¼áž…ៗ) -Comment[lb]=Booklet-Drock (mat schmuelsäitegem Duplexdrock benotzen) -Comment[lt]=BroÅ¡iÅ«ros spausdinimas (naudokite dvipusiam spausdinimui) -Comment[lv]=Pamfleta drukÄÅ¡ana (izmanto ar mazÄs puses duplekso drukÄÅ¡anu) -Comment[mk]=Печатење памфлет (за кориÑтење Ñо Ð´ÑƒÐ¿Ð»ÐµÐºÑ Ð¿ÐµÑ‡Ð°Ñ‚ÐµÑšÐµ од помалата Ñтрана) -Comment[mn]="Pamphlet"-Ñ…ÑвлÑÑ…: (ЖижгÑÑÑ€ хоёр талаар Ñ…ÑвлÑÑ…Ñд Ñ…ÑÑ€ÑглÑ) -Comment[ms]=Cetakan Pamplet (guna cetakan dupleks sisi kecil) -Comment[mt]=Printjar ta' fuljett (uża printjar dupleks min-naħa l-qasira) -Comment[nb]=Brosjyreutskrift (brukes for dobbeltsidig utskrift med liten papirstørrelse) -Comment[nds]=Lütte Böker drucken (mit Duplexdruck för lütte Sieden bruken) -Comment[ne]=पतà¥à¤°à¤¿à¤•à¤¾ मà¥à¤¦à¥à¤°à¤£ (सानो भाग डà¥à¤ªà¥à¤²à¥‡à¤•à¥à¤¸ मà¥à¤¦à¥à¤°à¤£ पà¥à¤°à¤¯à¥‹à¤— गरà¥à¤¨à¥à¤¹à¥‹à¤¸à¥) -Comment[nl]=Pamflet afdrukken (gebruik i.c.m. smalle kant duplexafdruk) -Comment[nn]=Brosjyreutskrift (bruk ved dupleksutskrift pÃ¥ smÃ¥ sider) -Comment[nso]=Kgatiso ya Pamphlet (sumisa le kgatiso ya duplex ya lehlakori le lennyane) -Comment[pa]=Pamphlet ਛਾਪਾਈ (ਛੋਟੀ ਦੋ-ਪਾਸੀ ਛਾਪਾਈ ਨਾਲ ਵਰਤੋਂ) -Comment[pl]=Drukowanie broszur (używać z wydrukiem dwustronnym krótszÄ… stronÄ…) -Comment[pt]=Impressão de panfletos (usar na impressão duplex pelo lado menor) -Comment[pt_BR]= Impressão de Panfletos (usar o modo de impressão lateral pequeno) -Comment[ro]=Tipărire pamflete (utilizează tipărirea duplex cu margini mici) -Comment[ru]=ÐŸÐ°Ð¼Ñ„Ð»ÐµÑ‚Ð½Ð°Ñ Ð¿ÐµÑ‡Ð°Ñ‚ÑŒ (Ñ Ð¸Ñпользованием дуплекÑной печати по короткой Ñтороне) -Comment[rw]=Gucapa Umuzinge (gukoresha hamwe n'icapa ry'uruhande ruto inyabubiri) -Comment[se]=GihppagaÄÄa Äáliheapmi (geavat unna siidduid guovttebealat Äáliheapmái) -Comment[sk]=TlaÄ brožúry (použitie s obojstrannou tlaÄou na krátkom okraji) -Comment[sl]=Tiskanje pamfletov (uporabljajte pri dupleksnem tiskanju z malim robom) -Comment[sr]=Штампање памфлета (кориÑтите Ñа Ð´ÑƒÐ¿Ð»ÐµÐºÑ ÑˆÑ‚Ð°Ð¼Ð¿Ð°ÑšÐµÐ¼ малих Ñтрана) -Comment[sr@Latn]=Å tampanje pamfleta (koristite sa dupleks Å¡tampanjem malih strana) -Comment[ss]=Kushicelela emapheshana (sebentisa nelicadzi lelincane lekushicelela lokuphindaphindziwe) -Comment[sv]=Broschyrutskrift (använd med duplexutskrift längs kortsidan) -Comment[ta]=கைநூல௠பதிபà¯à®ªà¯ (சிற௠பகà¯à®• இரடà¯à®Ÿà¯ˆ அசà¯à®šà¯à®Ÿà®©à¯ பாவிகà¯à®•à®µà¯à®®à¯) -Comment[te]=కరపతà±à°° à°ªà±à°°à°šà±à°°à°£ (à°šà°¿à°¨à±à°¨ సైజౠతొ à°¦à±à°µà°‚à°¦à±à°µ à°ªà±à°°à°šà±à°°à°£ వాడండి) -Comment[tg]=Чопи ҳаҷвиÑвӣ (бо иÑтифода аз чопи дуплекÑÓ£ аз рӯи паҳлӯи кӯтоҳ) -Comment[th]=à¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¹à¸œà¹ˆà¸™à¸žà¸±à¸š (ใช้à¸à¸±à¸šà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œ 2 หน้าขนาดเล็à¸) -Comment[tr]=Broşür Yazdırma -Comment[tt]=Kitaplap Bastıru (ike-yaqlı bastıru) -Comment[uk]=Друк брошури (викориÑтовуйте з двоÑтороннім друком за меншою Ñтороною) -Comment[uz]=Pamflet bosib chiqarish (kichik taraflama varaqning ikkita tomoniga bosib chiqarish) -Comment[uz@cyrillic]=Памфлет боÑиб чиқариш (кичик тарафлама варақнинг иккита томонига боÑиб чиқариш) -Comment[ven]=U phirintha ha tshibugwana (shumisa na lurumbu lutuku lwa u phirintha a duplex) -Comment[vi]=Khả năng in pam-phÆ¡-lê (sá»­ dụng vá»›i việc in hai chiá»u mặt nhá») -Comment[xh]=Ushicilelo Lwephetshana (sebenzisa ngoshicilelo oluncinane olusecaleni oluphindwe kabini) -Comment[zh_CN]=打å°å°å†Œ (使用å°å¼ åŒé¢æ‰“å°) -Comment[zh_HK]=列å°å°å†Šå­ (使用å°å¼µé›™é¢åˆ—å°) -Comment[zh_TW]=列å°å°å†Š (使用å°å¼µé›™é¢åˆ—å°) -Comment[zu]=Ibhukwana Lokushicilela (sebenzisa ngecala elincane lukushicilela okuphindwe kabili) -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/psbook.xml b/kdeprint/filters/psbook.xml deleted file mode 100644 index 11c4132da..000000000 --- a/kdeprint/filters/psbook.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="psbook"> - <filtercommand data="psbook %filterinput | psnup -2 -p%psl %filterargs %filteroutput" /> - <filterargs> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/psbook1.desktop b/kdeprint/filters/psbook1.desktop deleted file mode 100644 index 445b18e29..000000000 --- a/kdeprint/filters/psbook1.desktop +++ /dev/null @@ -1,94 +0,0 @@ -[KDE Print Filter Entry] -Name=psbook1 -Name[af]=psboek1 -Name[de]=PS-Book 1 -Name[eo]=PS-libro 1 -Name[fr]=psbook 1 -Name[hi]=पीà¤à¤¸-बà¥à¤•1 -Name[mn]=PS-ном 1 -Name[nso]=psbuka1 -Name[sv]=broschyr 1 -Name[ta]=psபà¯à®¤à¯à®¤à®•à®®à¯1 -Name[te]=పిఎసౠబà±à°•à±1 -Name[ven]=Bugu ya ps yau thoma -Name[zu]=incwadi ye ps yokuqala -Require=exec:/psbook,exec:/psnup,exec:/psselect -Comment=Pamphlet Printing - Even Pages (step 1) -Comment[af]=Pamflet Besig om te druk - Ewe Bladsye (step 1) -Comment[ar]=طباعة الكتيبات - الصÙحات الزوجية (الخطوة 1) -Comment[az]=Pamphlet Çap Sistemi - TÉ™k SÉ™hifÉ™lÉ™r (addım 1) -Comment[bn]=পà§à¦¯à¦¾à¦®à¦«à§à¦²à§‡à¦Ÿ মà§à¦¦à§à¦°à¦£ - জোড় সংখà§à¦¯à¦• পাতা (পà§à¦°à¦¥à¦® ধাপ) -Comment[bs]=Å tampanje pamfleta - parne strane (prvi korak) -Comment[ca]=Impressor de pamflets - pàgines parells (passa 1) -Comment[cs]=Tisk letáku - sudé stránky (krok 1) -Comment[csb]=Dëkòwanié broszurów - pôrzësté starnë(krok 1) -Comment[cy]=Argraffu Pamffled - Tudalennau Ailrif (cam 1) -Comment[da]=Pamflet-udskrift - lige sider (trin 1) -Comment[de]=Booklet-Druck - Gerade Seiten (erster Schritt) -Comment[el]=ΕκτÏπωση φυλλαδίου - Ζυγές σελίδες (βήμα 1) -Comment[eo]=Pamflet-presado - paraj paÄoj (paÅo 1) -Comment[es]=Impresión de folleto - páginas pares (paso 1) -Comment[et]=Brošüüri trükkimine - paarislehed (1. samm) -Comment[eu]=Liburuxka inprimatzea - Orrialde bikoitiak (1. urratsa) -Comment[fa]=چاپ جزوه - صÙحات زوج )گام Û±( -Comment[fi]=Lentolehtistulostus - parilliset sivut (vaihe 1) -Comment[fr]=Impression au format livret - Pages paires (étape 1) -Comment[fy]=Pamflet printsje - even bledsiden (stap 1) -Comment[ga]=Priontáil Phaimfléid - Leathanaigh Chothroma (céim 1) -Comment[gl]=Impresión de Panfletos - Páxinas pares (paso 1) -Comment[he]=הדפסת חוברות - ×¢×ž×•×“×™× ×–×•×’×™×™× (שלב 1) -Comment[hi]=पेमà¥à¤«à¤²à¥‡à¤Ÿ छपाई सम पृषà¥à¤  (सà¥à¤Ÿà¥‡à¤ª 1) -Comment[hr]=Ispisivanje pamfleta - Parne stranice (korak 1) -Comment[hsb]=Pamphlet Printing - rune strony (prÄ›nja kroÄel) -Comment[hu]=Szórólapnyomtatás - csak a páros oldalak (1. lépés) -Comment[id]=Cetak Pamflet - Halaman Genap (langkah 1) -Comment[is]=Bæklingaprentun - slétttölusíður (skref 1) -Comment[it]=Stampa libretto - pagine pari (passo 1) -Comment[ja]=å°å†Šå­ã®å°åˆ· - å¶æ•°ãƒšãƒ¼ã‚¸ (ステップ 1) -Comment[ka]=პáƒáƒ›áƒ¤áƒšáƒ”ტური ბეჭდვრ- ლუწი გვერდები (ნáƒáƒ‘იჯი 1) -Comment[kk]=Кітапшаны баÑып шығару - жұп беттері (1-қадам) -Comment[km]=ការ​បោះពុម្ព​ážáž·ážáž”áŸážŽáŸ’ណ - ទំពáŸážšâ€‹áž‚áž¼ (ជំហាន​ទី ១) -Comment[lb]=Booklet-Drock - Gerued Säiten (Schrëtt 1) -Comment[lt]=BroÅ¡iÅ«ros spausdinimas – lyginiai puslapiai (1 žingsnis) -Comment[lv]=Pamfleta drukÄÅ¡ana - pÄra lapas (1. solis) -Comment[mk]=Печатење памфлет - парни Ñтраници (чекор 1) -Comment[mn]="Pamphlet"-Ð¥ÑвлÑÑ…: ТÑгш хуудÑуудаар (Ðлхам 1) -Comment[ms]=Cetakan Pamplet Muka Genap (langkah 1) -Comment[mt]=Printjar ta' fuljett - paÄ¡ni żewÄ¡ (pass 1) -Comment[nb]=Brosjyre-utskrift – like sider (steg 1) -Comment[nds]=Lütte Böker drucken - evene Sieden (Stoop 1) -Comment[ne]=पतà¥à¤°à¤¿à¤•à¤¾ मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¦à¥ˆ - जोर पृषà¥à¤ à¤¹à¤°à¥‚ (चरण १) -Comment[nl]=Pamflet afdrukken - even pagina's (stap 1) -Comment[nn]=Brosjyreutskrift – partalssider (steg 1) -Comment[nso]=Kgatiso ya Pamphlet - Matlakala a Even (kgato 1) -Comment[pa]=Pamphlet ਛਾਪਾਈ - ਜਿਸਤ ਸਫ਼ੇ(ਪਗ 1) -Comment[pl]=Drukowanie broszur - strony parzyste (krok 1) -Comment[pt]=Impressão de panfletos - páginas pares (passo 1) -Comment[pt_BR]= Impressão de Panfletos - páginas pares (passo 1) -Comment[ro]=Tipărire pamflete - pagini pare (pasul 1) -Comment[ru]=ÐŸÐ°Ð¼Ñ„Ð»ÐµÑ‚Ð½Ð°Ñ Ð¿ÐµÑ‡Ð°Ñ‚ÑŒ - чётные Ñтраницы (шаг 1) -Comment[rw]=Gucapa Umuzinge - Amapaji Atari Igiharwe (Intera 1) -Comment[se]=GihppagaÄÄa Äáliheapmi – BáralaÅ¡ siiddut (1. lávki) -Comment[sk]=TlaÄ brožúry - párne stránky (krok 1) -Comment[sl]=Tiskanje pamfletov - sode strani (1. korak) -Comment[sr]=Штампање памфлета - парне Ñтране (корак 1) -Comment[sr@Latn]=Å tampanje pamfleta - parne strane (korak 1) -Comment[sv]=Broschyrutskrift - jämna sidor (steg 1) -Comment[ta]=கைநூல௠பதிபà¯à®ªà¯ - இரடà¯à®Ÿà¯ˆà®ªà¯ பகà¯à®•à®™à¯à®•à®³à¯ (படி 1) -Comment[te]=కరపతà±à°° à°ªà±à°°à°šà±à°°à°£ - సరి à°ªà±à°Ÿà°²à± (మెటà±à°Ÿà± 1) -Comment[tg]=Чопи ҳаҷвиÑвӣ - Ñаҳифаҳои ҷуфт (иқдоми 1) -Comment[th]=à¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¹à¸œà¹ˆà¸™à¸žà¸±à¸š - พิมพ์หน้าคู่ (ขั้นที่ 1) -Comment[tr]=Broşür Yazdırma - Çift Sayfalar (1. adım) -Comment[tt]=Kitaplap Bastıru - Cöp Bitlär (1. adım) -Comment[uk]=Друк брошури - парні Ñторінки (крок 1) -Comment[uz]=Pamflet bosib chiqarish - Juft betlar (qadam 1) -Comment[uz@cyrillic]=Памфлет боÑиб чиқариш - Жуфт бетлар (қадам 1) -Comment[ven]=U phirintha ha tshibugwana - masiatari (tshitepe tshau thoma) -Comment[vi]=Khả năng in pam-phÆ¡-lê — các trang chẵn (bÆ°á»›c 1) -Comment[xh]=Ushicilelo Lwephetshana - Amaphepha Alinganayo (inyathelo 1) -Comment[zh_CN]=打å°å°å†Œ - å¶æ•°é¡µ(第一步) -Comment[zh_HK]=列å°å°å†Šå­ - å¶æ•¸é (第一步) -Comment[zh_TW]=列å°å°å†Š - å¶æ•¸é (第一步) -Comment[zu]=Ukushicilela Ibhukwana - Amaphepha Alinganayo (isiqendu 1) -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/psbook1.xml b/kdeprint/filters/psbook1.xml deleted file mode 100644 index 4e5b84aa8..000000000 --- a/kdeprint/filters/psbook1.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="psbook1"> - <filtercommand data="psbook %filterinput | psnup -2 -p%psl | psselect -e %filteroutput" /> - <filterargs> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/psbook2.desktop b/kdeprint/filters/psbook2.desktop deleted file mode 100644 index 1cadd42eb..000000000 --- a/kdeprint/filters/psbook2.desktop +++ /dev/null @@ -1,95 +0,0 @@ -[KDE Print Filter Entry] -Name=psbook2 -Name[af]=psboek2 -Name[de]=PS-Book 2 -Name[eo]=PS-libro 2 -Name[fr]=psbook 2 -Name[hi]=पीà¤à¤¸-बà¥à¤•2 -Name[mn]=PS-ном 2 -Name[nso]=psbuka2 -Name[sv]=broschyr 2 -Name[ta]=psபà¯à®¤à¯à®¤à®•à®®à¯2 -Name[te]=పిఎసౠబà±à°•à±2 -Name[ven]=Bugu ya ps ya vhuvhili -Name[zu]=incwadi ye ps yesibili -Require=exec:/psbook,exec:/psnup,exec:/psselect -Comment=Pamphlet Printing - Odd Pages (step 2) -Comment[af]=Pamflet Besig om te druk - Onewe Bladsye (step 2) -Comment[ar]=طباعة الكتيبات - الصÙحات الÙردية (الخطوة 2) -Comment[az]=Pamphlet Çap Sistemi - Cüt SÉ™hifÉ™lÉ™r (addım 2) -Comment[bn]=পà§à¦¯à¦¾à¦®à¦«à§à¦²à§‡à¦Ÿ মà§à¦¦à§à¦°à¦£ - বিজোড় সংখà§à¦¯à¦• পাতা (দà§à¦¬à¦¿à¦¤à§€à§Ÿ ধাপ) -Comment[bs]=Å tampanje pamfleta - neparne strane (drugi korak) -Comment[ca]=Impressor de pamflets - pàgines parells (passa 2) -Comment[cs]=Tisk letáku - sudé stránky (krok 2) -Comment[csb]=Dëkòwanié broszurów - niepôrzësté starnë(krok 2) -Comment[cy]=Argraffu Pamffled - Tudalennau Odrif (cam 2) -Comment[da]=Pamflet-udskrift - ulige sider (trin 2) -Comment[de]=Booklet-Druck - Ungerade Seiten (zweiter Schritt) -Comment[el]=ΕκτÏπωση φυλλαδίου - Μονές σελίδες (βήμα 2) -Comment[eo]=Pamflet-presado - malparaj paÄoj (paÅo 2) -Comment[es]=Impresión de folleto - páginas impares (paso 2) -Comment[et]=Brošüüri trükkimine - paaritud lehed (2. samm) -Comment[eu]=Liburuxka inprimatzea - Orrialde bakoitiak (2 urratsa) -Comment[fa]=چاپ جزوه - صÙحات Ùرد )گام Û²( -Comment[fi]=Lentolehtistulostus - parittomat sivut (vaihe 2) -Comment[fr]=Impression au format livret - Pages impaires (étape 2) -Comment[fy]=Pamflet printsje - ûneven bledsiden (stap 2) -Comment[ga]=Priontáil Phaimfléid - Leathanaigh Chorra (céim 2) -Comment[gl]=Impresión de Panfletos - Páxinas impares (paso 2) -Comment[he]=הדפסת חוברות - ×¢×ž×•×“×™× ××™Ö¾×–×•×’×™×™× (שלב 2) -Comment[hi]=पेमà¥à¤«à¤²à¥‡à¤Ÿ छपाई विषम पृषà¥à¤  (सà¥à¤Ÿà¥‡à¤ª 2) -Comment[hr]=Ispis pamfleta - Neparne stranice (korak 2) -Comment[hsb]=Pamphlet Printing - njerune strony (prÄ›nja kroÄel) -Comment[hu]=Szórólapnyomtatás - csak a páratlan oldalak (2. lépés) -Comment[id]=Cetak Pamflet - Halaman Ganjil (langkah 2) -Comment[is]=Bæklingaprentun - oddatölusíður (skref 2) -Comment[it]=Stampa libretto - pagine dispari (passo 2) -Comment[ja]=å°å†Šå­ã®å°åˆ· - 奇数ページ (ステップ 2) -Comment[ka]=პáƒáƒ›áƒ¤áƒšáƒ”ტური ბეჭდვრ- კენტი გვერდები (ნáƒáƒ‘იჯი 2) -Comment[kk]=Кітапшаны баÑып шығару - тақ беттері (2-қадам) -Comment[km]=ការ​បោះពុម្ព​ážáž·ážáž”áŸážŽáŸ’ណ - ទំពáŸážšâ€‹ážŸáŸážŸ (ជំហាន​ទី ២) -Comment[lb]=Booklet-Drock - Ongerued Säiten (Schrëtt 2) -Comment[lt]=BroÅ¡iÅ«ros spausdinimas – nelyginiai puslapiai (2 žingsnis) -Comment[lv]=Pamfleta drukÄÅ¡ana - nepÄra lapas (2. solis) -Comment[mk]=Печатење памфлет - непарни Ñтраници (чекор 2) -Comment[mn]="Pamphlet"-Ð¥ÑвлÑÑ…: Сондгой хуудÑуудаар (Ðлхам 2) -Comment[ms]=Cetakan Pamplet Muka Genap (langkah 2) -Comment[mt]=Printjar ta' fuljett - paÄ¡ni fard (pass 2) -Comment[nb]=Brosjyre-utskrift – odde sider (steg 2) -Comment[nds]=Lütte Böker drucken - unevene Sieden (Stoop 2) -Comment[ne]=पतà¥à¤°à¤¿à¤•à¤¾ मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¦à¥ˆ - बिजोर पृषà¥à¤ à¤¹à¤°à¥‚ (चरण २) -Comment[nl]=Pamflet afdrukken - oneven pagina's (stap 2) -Comment[nn]=Brosjyreutskrift – oddetalssider (steg 2) -Comment[nso]=Kgatiso ya Pamphlet - Matlakala a Odd (kgato 2) -Comment[pa]=Pamphlet ਛਾਪਾਈ - ਟਾਂਕ ਸਫੇ(ਪਗ 2) -Comment[pl]=Drukowanie broszur - strony nieparzyste (krok 2) -Comment[pt]=Impressão de panfletos - páginas ímpares (passo 2) -Comment[pt_BR]= Impressão de Panfletos - páginas ímpares (passo 2) -Comment[ro]=Tipărire pamflete - pagini impare (pasul 2) -Comment[ru]=ÐŸÐ°Ð¼Ñ„Ð»ÐµÑ‚Ð½Ð°Ñ Ð¿ÐµÑ‡Ð°Ñ‚ÑŒ - нечётные Ñтраницы (шаг 2) -Comment[rw]=Gucapa Umuzinge - Amapaji Giharwe (Intera 2) -Comment[se]=GihppagaÄÄa Äáliheapmi – Bárrahissiiddut (2. lávki) -Comment[sk]=TlaÄ brožúry - nepárne stránky (krok 2) -Comment[sl]=Tiskanje pamfletov - lihe strani (2. korak) -Comment[sr]=Штампање памфлета - непарне Ñтране (корак 2) -Comment[sr@Latn]=Å tampanje pamfleta - neparne strane (korak 2) -Comment[ss]=Kushicelela emapheshana - Emakhasi labala ngalokuzuba kunye (sigama 2) -Comment[sv]=Broschyrutskrift - udda sidor (steg 2) -Comment[ta]=கைநூல௠பதிபà¯à®ªà¯ - à®’à®±à¯à®±à¯ˆà®ªà¯ பகà¯à®•à®™à¯à®•à®³à¯ (படி 2) -Comment[te]=కరపతà±à°° à°ªà±à°°à°šà±à°°à°£ - బేసి à°ªà±à°Ÿà°²à± (మెటà±à°Ÿà± ౨) -Comment[tg]=Чопи ҳаҷвиÑвӣ - Ñаҳифаҳои тоқ (иқдоми 2) -Comment[th]=à¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¹à¸œà¹ˆà¸™à¸žà¸±à¸š - หน้าคี่ (ขั้นที่ 2) -Comment[tr]=Broşür yazdırma - Tek Sayfalar (2.adım) -Comment[tt]=Kitaplap Bastıru - Tap Bitlär (2. adım) -Comment[uk]=Друк брошури - непарні Ñторінки (крок 2) -Comment[uz]=Pamflet bosib chiqarish - Toq betlar (qadam 2) -Comment[uz@cyrillic]=Памфлет боÑиб чиқариш - Тоқ бетлар (қадам 2) -Comment[ven]=U phirintha tshibugwana - masaitari (tshitepe tsha vhuvhili) -Comment[vi]=Khả năng in pam-phÆ¡-lê — các trang lẻ (bÆ°á»›c 2) -Comment[xh]=Ushicilelo Lwephetshana - Amaphepha Amnqakathi (inyathelo 2) -Comment[zh_CN]=打å°å°å†Œ - 奇数页(第二步) -Comment[zh_HK]=列å°å°å†Šå­ - 奇數é (第二步) -Comment[zh_TW]=列å°å°å†Š - 奇數é (第二步) -Comment[zu]=Ukushicilela Kwebhukwana - Amaphepha Angalingani (isiqendu 2) -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/psbook2.xml b/kdeprint/filters/psbook2.xml deleted file mode 100644 index 5aa8df006..000000000 --- a/kdeprint/filters/psbook2.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="psbook2"> - <filtercommand data="psbook %filterinput | psnup -2 -p%psl | psselect -o %filteroutput" /> - <filterargs> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/psnup.desktop b/kdeprint/filters/psnup.desktop deleted file mode 100644 index 19aafa627..000000000 --- a/kdeprint/filters/psnup.desktop +++ /dev/null @@ -1,89 +0,0 @@ -[KDE Print Filter Entry] -Name=psnup -Name[sv]=Psnup -Name[te]=పిà°à°¸à± à°¨à±à°ªà± -Name[th]=อินเดีย -Require=exec:/psnup -Comment=Multiple Pages per Sheet Filter -Comment[af]=Veelvuldige Bladsye per blaai Filter -Comment[ar]=مرشّح صÙحات متعددة ÙÙŠ ورقة واحدة -Comment[az]=Lay Filtri Başına BirdÉ™n Çox SÉ™hifÉ™ -Comment[be]=Друкаваць некалькі Ñтаронак на адным аркушы паперы -Comment[bn]=à¦à¦•à§‡à¦•à¦Ÿà¦¿ কাগজে à¦à¦•à¦¾à¦§à¦¿à¦• পৃষà§à¦ à¦¾ ছাপানোর জনà§à¦¯ ফিলà§à¦Ÿà¦¾à¦° -Comment[bs]=Filter za viÅ¡e strana po listu -Comment[ca]=Filtre per a múltiples pàgines per full -Comment[cs]=Filtr pro tisk více stran na jeden list papíru -Comment[csb]=Filter do wëdrëkù wielu starów na jednym cedlu -Comment[cy]=Hidl am Dudalennau lluosol ar bob Dalen -Comment[da]=Flere sider pr. arkfilter -Comment[de]=Ausdruck mehrerer Seiten auf einem Blatt -Comment[el]=ΦίλτÏο πολλών σελίδων ανά φÏλλο -Comment[eo]=Filtrilo por aranÄi plurajn paÄojn sur folio -Comment[es]=Filtro para múltiples páginas por hoja -Comment[et]=Mitme lehekülje ühele lehele trükkimise filter -Comment[eu]='Orrialde anitzak orriko' iragazkia -Comment[fa]=صÙحات چندگانه در پالایۀ صÙحه -Comment[fi]=Useita sivuja samalle arkille -Comment[fr]=Plusieurs pages par feuille -Comment[fy]=Mear as ien side op in bôge -Comment[gl]=Filtro de Múltiplas Páxinas por Folla -Comment[he]=מסנן ×¢×ž×•×“×™× ×ž×¨×•×‘×™× ×œ×’×™×œ×™×•×Ÿ -Comment[hi]=पà¥à¤°à¤¤à¤¿ शीट à¤à¤• से अघिक पृषà¥à¤  फ़िलà¥à¤Ÿà¤° -Comment[hr]=Filtar viÅ¡estrukih stranica po listu -Comment[hsb]=Filter za wjacore strony na Å‚opjeno -Comment[hu]=SzűrÅ‘ több lap egy oldalra helyezéséhez -Comment[id]=Filter Banyak Halaman per Lembar -Comment[is]=Sía fyrir margar síður á hvert blað -Comment[it]=Più pagine sullo stesso foglio -Comment[ja]=一枚ã‚ãŸã‚Šè¤‡æ•°ãƒšãƒ¼ã‚¸å°åˆ·ãƒ•ã‚£ãƒ«ã‚¿ -Comment[ka]=რáƒáƒ›áƒ“ენიმე გვერდის ერთ ფურცელზე ბეჭდვრ-Comment[kk]=Бірнеше беттерді бір параққа баÑып шығару ÑүзгіÑÑ– -Comment[km]=ទំពáŸážšâ€‹áž…្រើន​ក្នុង​មួយ​ážáž˜áŸ’រង​សន្លឹក -Comment[ko]=여러 쪽으로 나눠주는 거르개 -Comment[lb]=Filter fir e puer Säiten op ee Blat ze drécken -Comment[lt]=Kelių puslapių popieriaus lakÅ¡te filtras -Comment[lv]=VairÄkas lapas uz vienas lapas filtrs -Comment[mk]=Филтер за повеќе Ñтраници по лиÑÑ‚ -Comment[mn]=Олон хуудаÑыг нÑг цааÑан дÑÑÑ€ Ñ…ÑвлÑÑ… үеийн шүүлтүүр -Comment[ms]=Penapis Pelbagai Laman setiap Helaian -Comment[mt]=Filtru għal iżjed minn paÄ¡na waħda fuq kull karta -Comment[nb]=Filter for flere sider pÃ¥ hvert ark -Comment[nds]=Mehr as een Siet per Blatt drucken -Comment[ne]=पà¥à¤°à¤¤à¤¿ पाना फिलà¥à¤Ÿà¤° बहà¥à¤µà¤¿à¤§ पृषà¥à¤  -Comment[nl]=Meerdere pagina's per vel afdrukken -Comment[nn]=Filter for fleire sider pÃ¥ kvart ark -Comment[nso]=Matlakala A Mantshintshi ka Sesekodi sa Letlakala -Comment[pa]=ਬਹ੠ਸਫੇ ਪà©à¨°à¨¤à©€ ਸ਼ੀਟ ਫਿਲਟਰ -Comment[pl]=Filtr do wydruku wielu stron na jednej kartce -Comment[pt]=Filtro de múltiplas páginas por folha -Comment[pt_BR]= Múltiplas páginas por filtro da planilha -Comment[ro]=Filtru pentru mai multe pagini pe o foaie de hîrtie -Comment[ru]=Печать неÑкольких Ñтраниц на лиÑте -Comment[rw]=Ipaji Nyinshi kuri Muyunguruzi Urupapuro -Comment[se]=Máŋga siiddu ovtta báhpárii -filter -Comment[sk]=Filter pre viac strán na jednom liste -Comment[sl]=Filter za veÄ strani na enem listu papirja. -Comment[sq]=Filter për Shumë Faqe për një Tabak -Comment[sr]=Филтер за вишеÑтруке Ñтране по лиÑту -Comment[sr@Latn]=Filter za viÅ¡estruke strane po listu -Comment[ss]=Emakhasi laphindzaphindziwe kuya ngelishidi lesisefo -Comment[sv]=Filter för flera sidor per blad -Comment[ta]=ஒர௠பகà¯à®• வடிகடà¯à®Ÿà®¿à®•à¯à®•à®¾à®© பல பகà¯à®•à®™à¯à®•à®³à¯ -Comment[te]=పతà±à°° గలని à°•à°¿ పలౠపà±à°Ÿà°²à± చొపà±à°ªà±à°¨ -Comment[tg]=Чопи Ñкчанд Ñаҳифа дар варақа -Comment[th]=ตัวà¸à¸£à¸­à¸‡à¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¸«à¸¥à¸²à¸¢à¸«à¸™à¹‰à¸²à¸•à¹ˆà¸­à¸«à¸™à¹‰à¸²à¸à¸£à¸°à¸”าษ -Comment[tr]=Her Kağıda Birden Çok Sayfa Süzgeci -Comment[tt]=Qäğäz Bitendä berniçä Basma Bite -Comment[uk]=Фільтр ÑƒÐºÐ»Ð°Ð´Ð°Ð½Ð½Ñ Ð´ÐµÐºÑ–Ð»ÑŒÐºÐ¾Ñ… Ñторінок на аркуш -Comment[uz]=Bitta varaqga bir nechta bet chiqarish filteri -Comment[uz@cyrillic]=Битта варақга бир нечта бет чиқариш филтери -Comment[ven]=Masiatari manzhi kha filithara ya bammbiri -Comment[vi]=Nhiá»u trang cho má»—i bá»™ lá»c tá» giấy. -Comment[wa]=Passete pus d' ene pÃ¥dje par foye -Comment[xh]=Amaphepha Amaninzi Ngekhasi Lesihluzi ngasinye -Comment[zh_CN]=æ¯å¼ å¤šé¡µè¿‡æ»¤ç¨‹åº -Comment[zh_HK]=單張多é éŽæ¿¾å™¨ -Comment[zh_TW]=單張多é éŽæ¿¾å™¨ -Comment[zu]=Amakhasi Amaningana Kumhlaziyi Wepheshana ngamunye -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/psnup.xml b/kdeprint/filters/psnup.xml deleted file mode 100644 index 54b71531f..000000000 --- a/kdeprint/filters/psnup.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="psnup"> - <filtercommand data="psnup -p%psl %filterargs %filterinput %filteroutput" /> - <filterargs> - <filterarg name="nup" description="Pages per sheet" format="-%value" type="list" default="1" persistent="1"> - <value name="1" description="1" /> - <value name="2" description="2" /> - <value name="4" description="4" /> - <value name="8" description="8" /> - <value name="16" description="16" /> - </filterarg> - <filterarg name="box" description="Border line width" format="-d%value" type="int" min="0" max="20" default="0" /> - <filterarg name="margin" description="Additional margin" format="-b%value" type="int" min="0" max="100" default="0" /> - <filterarg name="orientation" description="Orientation" format="%value" type="list" default=""> - <value name="" description="Normal" /> - <value name="-l" description="Landscape" /> - <value name="-r" description="Seascape" /> - </filterarg> - <filterarg name="layout" description="Layout" format="%value" type="list" default=""> - <value name="" description="Row-Major" /> - <value name="-c" description="Column-Major" /> - </filterarg> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/psresize.desktop b/kdeprint/filters/psresize.desktop deleted file mode 100644 index 2c90c5ad6..000000000 --- a/kdeprint/filters/psresize.desktop +++ /dev/null @@ -1,99 +0,0 @@ -[KDE Print Filter Entry] -Name=psresize -Name[af]=ps-weer grote bepaal -Name[csb]=Skalowanié wëdrëkù -Name[eo]=PS-grandecÅanÄilo -Name[hu]=PSResize -Name[nso]=psnbeabogolo la boswa -Name[pl]=Skalowanie wydruku -Name[pt_BR]=Redimensionamento do PS -Name[sv]=Psresize -Name[ta]=psஅளவ௠மாறà¯à®±à¯ -Name[te]=పిఎసౠరిసైజౠ-Name[ven]=U linganisela ps -Name[xh]=psresiza -Name[zu]=psphinda ushintshe usayizi -Require=exec:/psresize -Comment=Scale Print Content to Fit on Another Paper Size -Comment[af]=Skaal Druk Inhoud na Pas op Nog 'n Papier Grootte -Comment[ar]=قم بتحجيم محتويات الطباعة حتى تتناسب مع حجم صÙحة أخرى -Comment[az]=BaÅŸqa SÉ™hifÉ™yÉ™ Sığdırmaq Üçün Çap MÉ™zmununu Miqyaslandır -Comment[be]=Маштабаваць змеÑÑ‚ Ñтаронак Ð´Ð»Ñ Ð·Ð¼ÑшчÑÐ½Ð½Ñ Ð½Ð° адным аркушы паперы іншых памераў -Comment[bn]=অনà§à¦¯ মাপের কাগজে ছাপানোর জনà§à¦¯ পà§à¦°à§Ÿà§‹à¦œà¦¨à¦®à¦¤ ছোটবড় করতে পারে -Comment[bs]=Skaliraj Å¡tampani sadržaj kako bi stao na drugu veliÄinu papira -Comment[ca]=Escala el contingut de la impressió per a ajustar-la a una altra mida de paper -Comment[cs]=Roztáhne tiÅ¡tÄ›ný obsah na jiný rozmÄ›r papíru -Comment[csb]=Skalowanié wëdrëkù tak, bë pasowôł do jinszi miarë starnë -Comment[cy]=Graddu Cynnwys Argraffu i Ffitio ar Faint Papur Arall -Comment[da]=Skalér udskriftsindhold til at passe pÃ¥ en anden papirstørrelse -Comment[de]=Druckgröße der Seite anpassen -Comment[el]=ΠÏοσαÏμογή πεÏιεχομένου εκτÏπωσης για ταίÏιασμα σε διαφοÏετικό μέγεθος χαÏÏ„Î¹Î¿Ï -Comment[eo]=Etendas presaĵon konvene al alia paperformato -Comment[es]=Escalar el contenido de la impresión para ajustar en otro tamaño del papel -Comment[et]=Sisu suuruse muutmine mahutamaks teise suurusega paberile -Comment[eu]=Eskalatu inprimatzeko edukiak beste paper-tamainari doitzeko -Comment[fa]=مقیاس محتوای چاپ برای تناسب با اندازۀ کاغذ دیگر -Comment[fi]=Skaalaa tulostettava sisältö mahtumaan erikokoiselle paperille -Comment[fr]=Ajuste le contenu imprimé pour l'adapter à un autre format de papier -Comment[fy]=Pas de ôfdruk oan oan in oar formaat papier -Comment[gl]=Escalar o Contido da Impresión para Axustá-lo a Outro Tamaño de Papel -Comment[he]=שינוי גודל תוכן ההדפסה כך שית××™× ×œ×’×•×“×œ דף ×חר -Comment[hi]=छपाई सामगà¥à¤°à¥€ को किसी अनà¥à¤¯ पृषà¥à¤  पर फिट करने के लिठबङा/छोटा करें -Comment[hr]=PrilagoÄ‘avanje veliÄine sadržaja za ispis na papir druge veliÄine -Comment[hsb]=ZmÄ›njenje wulkosće za wućišć na hinaÅ¡u papjeru -Comment[hu]=Nyomtatandó anyag átméretezése más papírméretre -Comment[id]=Skalakan Pencetakan ke Ukuran Kertas Lain -Comment[is]=Skala prentun til að setja á aðra pappírsstærð -Comment[it]=Adatta il contenuto della stampa ad una diversa dimensione della carta -Comment[ja]=用紙サイズã«åˆã†ã‚ˆã†ã«å°åˆ·å†…容を拡大/ç¸®å° -Comment[ka]=ბეჭდვის მáƒáƒ¡áƒ¨áƒ¢áƒáƒ‘ირებრსხვრზáƒáƒ›áƒ˜áƒ¡ ფურცელზე დáƒáƒ¡áƒáƒ‘ეჭდáƒáƒ“ -Comment[kk]=БаÑатынды баÑқа өлшемге шақтап баÑып шығару -Comment[km]=ធ្វើ​មាážáŸ’រដ្ឋាន​មាážáž·áž€áž¶â€‹áž”ោះពុម្ព​ឲ្យ​សម​នឹង​ទំហំ​ក្រដាស​ផ្សáŸáž„​ទៀហ-Comment[ko]=ì°ì„ 알맹ì´ë¥¼ 다른 쪽 í¬ê¸°ì— 맞춰ì¤ë‹ˆë‹¤ -Comment[lb]=Gréisst vum Ausdrock op eng aner Pabeiergréisst upassen -Comment[lt]=Keisti spausdinamo turinio dydį taip, kad tilptų į kito dydžio popieriaus lapÄ… -Comment[lv]=MÄ“rogo drukas saturu, lai ietilptu citÄ papÄ«ra izmÄ“rÄ -Comment[mk]=Размер на Ñодржината за печатење, за да ја Ñобере на лиÑÑ‚ Ñо друга големина -Comment[mn]=Ð¥ÑвлÑÑ… зайг Ó©Ó©Ñ€ Ñ…ÑмжÑÑÑ‚Ñй цааÑанд тааруулах -Comment[ms]=Skala Cetak Kandungan untuk menepati Saiz Kertas Lain -Comment[mt]=Kabbar/Ä‹ekken id-daqs ta'l-print biex joqgħod fuq karta ta' daqs differenti -Comment[nb]=Tilpass utskrifta til en annen papirstørrelse -Comment[nds]=Utdruck en anner Papeergrött topassen -Comment[ne]=अनà¥à¤¯ कागज साइजमा ठीक गरà¥à¤¨ मापन मà¥à¤¦à¥à¤°à¤£ सामगà¥à¤°à¥€ -Comment[nl]=Schaal de afdrukinhoud zodat deze past op een andere papierformaat -Comment[nn]=Skaler utskrifta til ein annan papirstorleik -Comment[nso]=Kala Bokagare bja Kgatiso gore bo Lekanele go Bogolo bjo Bongwe bja Letlakala -Comment[pa]=ਹੋਰ ਸਫਾ ਆਕਾਰ ਤੇ ਛਾਪਾਈ ਕਰਨ ਲਈ ਭਾਗ ਅਨà©à¨•à©‚ਲਣ -Comment[pl]=Przeskalowanie wydruku, by pasowaÅ‚ do innego rozmiaru strony -Comment[pt]=Muda o tamanho do conteúdo a ser impresso para caber noutro tamanho de papel -Comment[pt_BR]=Conteúdo da escala de impressão para ajustar em outro Tamanho de Papel -Comment[ro]=Scalează tipăritura pentru a se potrivi cu foaia de hîrtie -Comment[ru]=МаÑштабирование печати Ð´Ð»Ñ Ñ€Ð°Ð·Ð¼ÐµÑ‰ÐµÐ½Ð¸Ñ Ð½Ð° другом размере бумаги -Comment[rw]=Gupima Ibiri mu Gucapa mu Gukwiza kuyindi Ngano y'Urupapuro -Comment[se]=Skále Äállosa sisdoalu heivet mannu eará bábersturrodahkii -Comment[sk]=Roztiahnutie tlaÄe pre iný rozmer papiera -Comment[sl]=Prilagajanje vsebine tiskanja za drugo velikost papirja -Comment[sq]=Përshtat të Dhënat që të Shtypen në një Letër me Madhësi të Ndryshme -Comment[sr]=Увећава или умањује Ñадржај за штампање како би Ñтао на папир друге величине -Comment[sr@Latn]=Uvećava ili umanjuje sadržaj za Å¡tampanje kako bi stao na papir druge veliÄine -Comment[ss]=Sikali sishicilela lokucuketfwe kuze kwanele bukhulu balelinye liphepha -Comment[sv]=Ändra storlek pÃ¥ utskriften för att passa en annan sidstorlek -Comment[ta]=வேறொர௠பகà¯à®• அளவிறà¯à®•à¯ பொரà¯à®¨à¯à®¤à¯à®®à®¾à®±à¯ அசà¯à®šà¯ உளà¯à®³à®Ÿà®•à¯à®•à®™à¯à®•à®³à¯ˆ உரà¯à®®à®¾à®±à¯à®±à¯ -Comment[te]=à°ªà±à°°à°šà±à°°à°£ సారానà±à°¨à°¿ ఇంకొక à°ªà±à°Ÿ కొలత లొ పటà±à°Ÿà°¿à°‚à°šà±à°¨à± -Comment[tg]=МаÑштабкунонии чоп барои ҷой намудан дар дигар ҳаҷми коғаз -Comment[th]=ปรับขนาดเนื้อหาให้พอดีà¸à¸±à¸šà¸‚นาดà¸à¸£à¸°à¸”าษ -Comment[tr]=Yazıcıya gönderilecekleri baÅŸka bir kağıt boyutuna uyması için yeniden boyutlandır -Comment[tt]=Bastıru Eçtälegen BaÅŸqa Ãœlçämle Bitkä sıydırırlıq it -Comment[uk]=МаÑштабувати зміÑÑ‚ друку до іншого розміру паперу -Comment[uz]=Varaqning boshqa oÊ»lchamiga mos keltirish -Comment[uz@cyrillic]=Варақнинг бошқа ўлчамига Ð¼Ð¾Ñ ÐºÐµÐ»Ñ‚Ð¸Ñ€Ð¸Ñˆ -Comment[ven]=Zwirengomu ha tshikeili tshau phirintha uitela u dzhena kha saizi inwe ya siatari -Comment[vi]=Co dãn ná»™i dung in để vừa khít má»™t kích cỡ giấy khác. -Comment[wa]=Mete al schÃ¥le çou ki va esse imprimer po k' ça rimplixhe ene pÃ¥dje d' ene ôte grandeu di papî -Comment[xh]=Isikali Soshicelela Somphakati esinokungena Kwelinye Uhlobo Lephepa -Comment[zh_CN]=缩放打å°å†…容以适åˆå…¶å®ƒçº¸å¼ å¤§å° -Comment[zh_HK]=調整列å°å…§å®¹å¤§å°ä»¥ç¬¦åˆç´™å¼µå°ºå¯¸ -Comment[zh_TW]=調整列å°å…§å®¹ä»¥ç¬¦åˆå…¶å®ƒçš„ç´™å¼µå¤§å° -Comment[zu]=Kala Okuphakathi Kokushicilela Ukugcwalisa Omunye Usayizi Wephepha -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/psresize.xml b/kdeprint/filters/psresize.xml deleted file mode 100644 index 6efc99eed..000000000 --- a/kdeprint/filters/psresize.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="psresize"> - <filtercommand data="psresize -p%psl %filterargs %filterinput %filteroutput" /> - <filterargs> - <filterarg name="insize" description="Input paper size" format="-P%value" type="list" default="a4"> - <value name="a3" description="A3" /> - <value name="a4" description="A4" /> - <value name="a5" description="A5" /> - <value name="b5" description="B5" /> - <value name="letter" description="US Letter" /> - <value name="legal" description="US Legal" /> - <value name="tabloid" description="Tabloid" /> - <value name="executive" description="Executive" /> - </filterarg> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/filters/psselect.desktop b/kdeprint/filters/psselect.desktop deleted file mode 100644 index e44191356..000000000 --- a/kdeprint/filters/psselect.desktop +++ /dev/null @@ -1,97 +0,0 @@ -[KDE Print Filter Entry] -Name=psselect -Name[af]=ps-kies -Name[ar]=psseleect -Name[csb]=Wëbór starnów wëdrëkù -Name[eo]=PS-elektilo -Name[nso]=pskgetha -Name[pl]=Wybór stron wydruku -Name[sv]=Psselect -Name[ta]=psதேரà¯à®¨à¯à®¤à¯†à®Ÿà¯ -Name[te]=పిఎసౠసెలెకà±à°Ÿà± -Name[ven]=U nanga ha ps -Name[zu]=pskhetha -Require=exec:/psselect -Comment=Page Selection/Ordering Filter -Comment[af]=Bladsy Keuse/Rangskikking Filter -Comment[ar]=مرشح اختيار/ترتيب الصÙحات -Comment[az]=SÉ™hifÉ™ Seçki/Ä°stiqamÉ™tlÉ™ndirmÉ™ Filtri -Comment[be]=Выбар Ñтаронак Ñ– Ñ–Ñ… парадку -Comment[bn]=পৃষà§à¦ à¦¾ নিরà§à¦¬à¦¾à¦šà¦¨/কà§à¦°à¦® ফিলà§à¦Ÿà¦¾à¦° -Comment[bs]=Filter za izbor/poredak stranica -Comment[ca]=Filtre d'ordenament/selecció de pàgina -Comment[cs]=Filtr pro výbÄ›r a uspořádání stran -Comment[csb]=Filter do wëbòru ë pòrzÄ…dkòwaniô stranów wëdrëkù -Comment[cy]=Hidl i Ddewis/Drefnu Tudalennau -Comment[da]=Sideudvalg/rækkefølge-filter -Comment[de]=Seitenauswahl/Sortierung -Comment[el]=ΦίλτÏο επιλογής/διευθέτησης σελίδων -Comment[eo]=PaÄelektilo/paÄordigilo -Comment[es]=Filtro de ordenamiento/selección de página -Comment[et]=Lehekülgede valimise/järjestamise filter -Comment[eu]=Orrialdeak hautatzeko/ordenatzeko iragazkia -Comment[fa]=گزینش صÙحه/پالایه مرتب -Comment[fi]=Sivun valinta/järjestys-suodin -Comment[fr]=Sélection de pages / Filtre de tri -Comment[fy]=Bledsiden selektearje/op oarder bringe -Comment[ga]=Scagaire chun leathanaigh a roghnú agus a chur in ord -Comment[gl]=Filtro de Selección/Ordenamento de Páxina -Comment[he]=מסנן בחירת\סידור ×¢×ž×•×“×™× -Comment[hi]=पृषà¥à¤  चà¥à¤¨à¤¾à¤µ/कà¥à¤°à¤®à¤µà¤¾à¤° करने का फ़िलà¥à¤Ÿà¤° -Comment[hr]=Filtar za odabir i poredak stranica -Comment[hsb]=Filter za wubÄ›r/rjadowanje stronow -Comment[hu]=OldalkijelölÅ‘ és -rendezÅ‘ szűrÅ‘ -Comment[id]=Filter Pemilihan/Pengurutan Halaman -Comment[is]=Síðuval / röðunarsía -Comment[it]=Filtro per la selezione e l'ordinamento delle pagine -Comment[ja]=ページé¸æŠž/並ã¹æ›¿ãˆãƒ•ã‚£ãƒ«ã‚¿ -Comment[ka]=გვერდის áƒáƒ áƒ©áƒ”ვის/რიგის ფილტრი -Comment[kk]=Парақтарды таңдау/реттеу ÑүзгіÑÑ– -Comment[km]=ážáž˜áŸ’ážšáž„ ជ្រើស/រៀប​លំដាប់​ទំពáŸážš -Comment[ko]=ìª½ì„ ê³ ë¥´ê±°ë‚˜ 정렬하는 거르개 -Comment[lb]=Säitenauswiel-/Sortéierungsfilter -Comment[lt]=Puslapių pasirinkimo/rÅ«Å¡iavimo filtras -Comment[lv]=Lapu izvÄ“les/kÄrtoÅ¡anas filtrs -Comment[mk]=Филтер за Ñелекција/подредување на Ñтраници -Comment[mn]=ХуудаÑны Ñонголт болон дарааллыг шүүх -Comment[ms]=Penapis Pilihan Laman/Susunan -Comment[mt]=Filtru biex tagħżel/tissortja l-karti -Comment[nb]=Filter for valg og sortering av sider -Comment[nds]=Sieden utsöken / ornen -Comment[ne]=पृषà¥à¤  चयन/फिलà¥à¤Ÿà¤° कà¥à¤°à¤®à¤¬à¤¦à¥à¤§ -Comment[nl]=Pagina selecteren/ordenen -Comment[nn]=Filter for sideval/siderekkjefølgje -Comment[nso]=Sesekodi sa Kgetho/Otara ya Letlakala -Comment[pa]=ਸਫ਼ਾ ਚੋਣ/ਕà©à¨°à¨® ਫਿਲਟਰ -Comment[pl]=Filtr do wyboru i porzÄ…dkowania stron wydruku -Comment[pt]=O filtro de ordenação/selecção de páginas -Comment[pt_BR]=Seleção de Página/Filtro de ordenação -Comment[ro]=Filtru de selecÅ£ie/ordonare pagini -Comment[ru]=Фильтр печати выделениÑ/упорÑдоченного набора -Comment[rw]=Ihitamo ry'Ipaji/Muyunguruzi Gutunganya -Comment[se]=Siidduid válljema/ordnema filter -Comment[sk]=Filter pre výber strán a ich poradie -Comment[sl]=Filter za izbiranje/naroÄanje strani -Comment[sq]=Filter për Zgjedhjen apo Renditjen e Faqeve -Comment[sr]=Филтер за избор и ређање Ñтраница -Comment[sr@Latn]=Filter za izbor i reÄ‘anje stranica -Comment[ss]=kukhetfwa kwelikhasi/ku-oda sisefo -Comment[sv]=Filter för sidval och sidordning -Comment[ta]=பகà¯à®•à®¤à¯ தேரà¯à®µà¯/வரிசைபà¯à®ªà®Ÿà¯à®¤à¯à®¤à¯ வடிகடà¯à®Ÿà®¿ -Comment[te]=à°ªà±à°Ÿ ఎంపిక/వరà±à°¸à°²à±Š పెటà±à°Ÿà± గలని -Comment[tg]=Филтри чопи ҷудокунӣ/маҷмӯи тарбидодашуда -Comment[th]=ตัวà¸à¸£à¸­à¸‡à¸à¸²à¸£à¹€à¸¥à¸·à¸­à¸à¸«à¸™à¹‰à¸²/à¸à¸²à¸£à¸ˆà¸±à¸”ลำดับ -Comment[tr]=Sayfa Seçimi/Sıra Filtresi -Comment[tt]=Bit Saylaw/Täripläw Sözgeçe -Comment[uk]=Фільтр вибору/порÑдку Ñторінок -Comment[uz]=Betlarni tanlash/tartiblash filteri -Comment[uz@cyrillic]=Бетларни танлаш/тартиблаш филтери -Comment[ven]=U nanga ha siatari/u vhekanya filithara -Comment[vi]=Chá»n trang / bá»™ lá»c sắp xếp -Comment[xh]=Ukhetho Lwephepha/Isihluzi Sokulungisa kakuhle -Comment[zh_CN]=页é¢é€‰æ‹©/排åºè¿‡æ»¤ç¨‹åº -Comment[zh_HK]=紙張é¸æ“‡/排åºéŽæ¿¾å™¨ -Comment[zh_TW]=紙張é¸æ“‡/排åºéŽæ¿¾å™¨ -Comment[zu]=Ukhetho Lwephepha/Ukuthumela Isihlaziya samafayela -MimeTypeIn=application/postscript -MimeTypeOut=application/postscript diff --git a/kdeprint/filters/psselect.xml b/kdeprint/filters/psselect.xml deleted file mode 100644 index d125c4089..000000000 --- a/kdeprint/filters/psselect.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<kprintfilter name="psselect"> - <filtercommand data="psselect %filterargs %filterinput %filteroutput" /> - <filterargs> - <filterarg name="set" description="Page set" format="%value" type="list" default="-e -o"> - <value name="-e -o" description="All pages" /> - <value name="-e" description="Even pages" /> - <value name="-o" description="Odd pages" /> - </filterarg> - <filterarg name="order" description="Page ordering" format="-%value" default="f" type="bool"> - <value name="f" description="Forward" /> - <value name="r" description="Reverse" /> - </filterarg> - <filterarg name="range" description="Page range" format="-p%value" type="string" default="" /> - </filterargs> - <filterinput> - <filterarg name="file" format="%in" /> - <filterarg name="pipe" format="" /> - </filterinput> - <filteroutput> - <filterarg name="file" format="> %out" /> - <filterarg name="pipe" format="" /> - </filteroutput> -</kprintfilter> diff --git a/kdeprint/foomatic/Makefile.am b/kdeprint/foomatic/Makefile.am deleted file mode 100644 index 7a57fd40e..000000000 --- a/kdeprint/foomatic/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -INCLUDES = -I$(top_srcdir)/tdeprint $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_foomatic.la - -tdeprint_foomatic_la_SOURCES = kmfoomaticfactory.cpp \ - kmfoomaticmanager.cpp \ - kfoomaticprinterimpl.cpp -tdeprint_foomatic_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_foomatic_la_LIBADD = $(top_builddir)/tdeprint/management/libtdeprint_management.la -tdeprint_foomatic_la_METASOURCES = AUTO - -noinst_HEADERS = kmfoomaticmanager.h \ - kfoomaticprinterimpl.h - -bin_PROGRAMS = make_driver_db_foomatic - -make_driver_db_foomatic_SOURCES = make_driver_db_foomatic.c - -entry_DATA = foomatic.print -entrydir = $(kde_datadir)/tdeprint/plugins diff --git a/kdeprint/foomatic/foomatic.print b/kdeprint/foomatic/foomatic.print deleted file mode 100644 index 0ead9632c..000000000 --- a/kdeprint/foomatic/foomatic.print +++ /dev/null @@ -1,17 +0,0 @@ -[KDE Print Entry] -PrintSystem=foomatic -Comment=Foomatic (CUPS, LPRng, PDQ) -Comment[af]=Foomaties (Cups, Lprng, Pdq) -Comment[ar]= Foomatic (CUPS, LPRng, PDQ) -Comment[bn]=ফà§à¦®à§à¦¯à¦¾à¦Ÿà¦¿à¦• (CUPS, LPRng, PDQ) -Comment[cy]=Foomatic (CUPS, LPRng, PDQ) -Comment[eo]=Presprogramo "Foomatic" (CUPS, LPRng, PDQ) -Comment[fa]=)Foomatic (CUPS,LPRng,PDQ -Comment[hi]=फूमेटिक (CUPS, LPRng, PDQ) -Comment[ne]=फà¥à¤®à¥à¤¯à¤¾à¤Ÿà¤¿à¤• (CUPS, LPRng, PDQ) -Comment[rw]=Fumatike (CUPS, LPRng, PDQ) -Comment[sq]=Foomatik (CUPS, LPRng, PDQ) -Comment[sv]=Foomatic (Cups, LPRng, PDQ) -Comment[te]=ఫూమెటికౠ(సియà±à°ªà°¿à°Žà°¸à±, ఎలౠపి ఆరౠఅనౠజి,పిడికà±à°¯à±) -DetectUris=exec:/foomatic-configure,config:/foomatic/ -DetectPrecedence=0 diff --git a/kdeprint/foomatic/kfoomaticprinterimpl.cpp b/kdeprint/foomatic/kfoomaticprinterimpl.cpp deleted file mode 100644 index d47a5e134..000000000 --- a/kdeprint/foomatic/kfoomaticprinterimpl.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kfoomaticprinterimpl.h" -#include "kprinter.h" - -#include <kstandarddirs.h> -#include <klocale.h> - -KFoomaticPrinterImpl::KFoomaticPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ -} - -KFoomaticPrinterImpl::~KFoomaticPrinterImpl() -{ -} - -// look for executable -TQString KFoomaticPrinterImpl::executable() -{ - QString exe = KStandardDirs::findExe("foomatic-printjob"); - return exe; -} - -bool KFoomaticPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - QString exe = executable(); - if (!exe.isEmpty()) - { - cmd = exe + TQString::tqfromLatin1(" -P %1 -# %2").arg(quote(printer->printerName())).arg(printer->numCopies()); - return true; - } - else - printer->setErrorMessage(i18n("No valid print executable was found in your path. Check your installation.")); - return false; -} diff --git a/kdeprint/foomatic/kfoomaticprinterimpl.h b/kdeprint/foomatic/kfoomaticprinterimpl.h deleted file mode 100644 index 9d4a27155..000000000 --- a/kdeprint/foomatic/kfoomaticprinterimpl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KFOOMATICPRINTERIMPL_H -#define KFOOMATICPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KFoomaticPrinterImpl : public KPrinterImpl -{ -public: - KFoomaticPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KFoomaticPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); - -protected: - TQString executable(); -}; - -#endif diff --git a/kdeprint/foomatic/kmfoomaticfactory.cpp b/kdeprint/foomatic/kmfoomaticfactory.cpp deleted file mode 100644 index 660e5faff..000000000 --- a/kdeprint/foomatic/kmfoomaticfactory.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmfoomaticfactory.h" -#include "kmfoomaticmanager.h" -#include "kfoomaticprinterimpl.h" - -#include <kgenericfactory.h> -typedef K_TYPELIST_2( KMFoomaticManager, KFoomaticPrinterImpl ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_foomatic, KGenericFactory< Products > ) - diff --git a/kdeprint/foomatic/kmfoomaticmanager.cpp b/kdeprint/foomatic/kmfoomaticmanager.cpp deleted file mode 100644 index 53049852b..000000000 --- a/kdeprint/foomatic/kmfoomaticmanager.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmfoomaticmanager.h" -#include "kpipeprocess.h" -#include "driver.h" - -#include <tqdom.h> -#include <klocale.h> -#include <kdebug.h> -#include <kprocess.h> - -#include <unistd.h> - -KMFoomaticManager::KMFoomaticManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - setHasManagement(getuid() == 0); - setPrinterOperationMask(KMManager::PrinterConfigure); -} - -KMFoomaticManager::~KMFoomaticManager() -{ -} - -void KMFoomaticManager::listPrinters() -{ - KPipeProcess proc("foomatic-configure -Q -q -r"); - QDomDocument doc; - - doc.setContent(&proc); - QDomElement docElem = doc.documentElement(); - if (docElem.isNull() || docElem.tagName() != "queues") - return; - - QDomNode queueNode = docElem.firstChild(); - while (!queueNode.isNull()) - { - QDomElement queueElem = queueNode.toElement(); - if (!queueElem.isNull() && queueElem.tagName() == "queue") - { - KMPrinter *printer = createPrinterFromElement(&queueElem); - if (printer) - addPrinter(printer); - } - queueNode = queueNode.nextSibling(); - } -} - -DrMain* KMFoomaticManager::loadPrinterDriver(KMPrinter *printer, bool) -{ - if (printer->option("foomatic") != "1") - { - setErrorMsg(i18n("This is not a Foomatic printer")); - return NULL; - } - else if (printer->option("driver").isEmpty() || printer->option("printer").isEmpty()) - { - setErrorMsg(i18n("Some printer information are missing")); - return NULL; - } - - QString cmd = "foomatic-combo-xml -p "; - cmd += KProcess::quote(printer->option("printer")); - cmd += " -d "; - cmd += KProcess::quote(printer->option("driver")); - KPipeProcess proc(cmd); - QDomDocument doc; - doc.setContent(&proc); - QDomElement docElem = doc.documentElement(); - return createDriverFromXML(&docElem); -} - -KMPrinter* KMFoomaticManager::createPrinterFromElement(TQDomElement *elem) -{ - QDomElement e = elem->namedItem("name").toElement(); - if (!e.isNull()) - { - KMPrinter *printer = new KMPrinter; - printer->setType(KMPrinter::Printer); - printer->setName(e.text()); - printer->setPrinterName(e.text()); - printer->setState(KMPrinter::Idle); - /*if (printer->name().find('/') != -1) - { - QString s(printer->name()); - int p = s.find('/'); - printer->setPrinterName(s.left(p)); - printer->setInstanceName(s.mid(p+1)); - printer->addType(KMPrinter::Virtual); - }*/ - - if (!(e=elem->namedItem("description").toElement()).isNull()) - printer->setDescription(e.text()); - if (!(e=elem->namedItem("location").toElement()).isNull()) - printer->setLocation(e.text()); - if (!(e=elem->namedItem("connect").toElement()).isNull()) - printer->setDevice(e.text()); - - printer->setOption("foomatic", elem->attribute("foomatic")); - printer->setOption("spooler", elem->attribute("spooler")); - if (elem->attribute("foomatic") == "1") - { - if (!(e=elem->namedItem("printer").toElement()).isNull()) - printer->setOption("printer", e.text()); - if (!(e=elem->namedItem("driver").toElement()).isNull()) - printer->setOption("driver", e.text()); - } - - return printer; - } - return NULL; -} - -DrMain* KMFoomaticManager::createDriverFromXML(TQDomElement *elem) -{ - DrMain *driver = new DrMain(); - QDomElement pelem = elem->namedItem("printer").toElement(), delem = elem->namedItem("driver").toElement(); - if (!pelem.isNull() && !delem.isNull()) - { - driver->set("manufacturer", pelem.namedItem("make").toElement().text()); - driver->set("model", pelem.namedItem("model").toElement().text()); - QString s = TQString::tqfromLatin1("%1 %2 (%3)").arg(driver->get("manufacturer")).arg(driver->get("model")).arg(delem.namedItem("name").toElement().text()); - driver->set("description", s); - driver->set("text", s); - - QDomElement opts = elem->namedItem("options").toElement(); - if (!opts.isNull()) - { - QDomElement o = opts.firstChild().toElement(); - while (!o.isNull()) - { - if (o.tagName() == "option") - { - QString type = o.attribute("type"); - DrBase *dropt(0); - - if (type == "bool" || type == "enum") - { - if (type == "bool") dropt = new DrBooleanOption(); - else dropt = new DrListOption(); - QString defval = o.namedItem("arg_defval").toElement().text(), valuetext; - QDomNode val = o.namedItem("enum_vals").firstChild(); - while (!val.isNull()) - { - DrBase *choice = new DrBase(); - choice->setName(val.namedItem("ev_shortname").namedItem("en").toElement().text()); - choice->set("text", i18n(val.namedItem("ev_longname").namedItem("en").toElement().text().latin1())); - static_cast<DrListOption*>(dropt)->addChoice(choice); - if (val.toElement().attribute("id") == defval) - valuetext = choice->name(); - - val = val.nextSibling(); - } - dropt->set("default", valuetext); - dropt->setValueText(valuetext); - } - else if (type == "int" || type == "float") - { - if (type == "int") dropt = new DrIntegerOption(); - else dropt = new DrFloatOption(); - dropt->set("minval", o.namedItem("arg_min").toElement().text()); - dropt->set("maxval", o.namedItem("arg_max").toElement().text()); - QString defval = o.namedItem("arg_defval").toElement().text(); - dropt->set("default", defval); - dropt->setValueText(defval); - } - - if (dropt) - { - dropt->setName(o.namedItem("arg_shortname").namedItem("en").toElement().text()); - dropt->set("text", i18n(o.namedItem("arg_longname").namedItem("en").toElement().text().latin1())); - driver->addOption(dropt); - } - } - o = o.nextSibling().toElement(); - } - } - } - return driver; -} diff --git a/kdeprint/foomatic/kmfoomaticmanager.h b/kdeprint/foomatic/kmfoomaticmanager.h deleted file mode 100644 index f3796904a..000000000 --- a/kdeprint/foomatic/kmfoomaticmanager.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMFOOMATICMANAGER_H -#define KMFOOMATICMANAGER_H - -#include "kmmanager.h" - -class TQDomElement; -class KMPrinter; - -class KMFoomaticManager : public KMManager -{ -public: - KMFoomaticManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - virtual ~KMFoomaticManager(); - - DrMain* loadPrinterDriver(KMPrinter *p, bool config = false); - -protected: - void listPrinters(); - KMPrinter* createPrinterFromElement(TQDomElement*); - DrMain* createDriverFromXML(TQDomElement*); -}; - -#endif diff --git a/kdeprint/foomatic/make_driver_db_foomatic.c b/kdeprint/foomatic/make_driver_db_foomatic.c deleted file mode 100644 index 986a24447..000000000 --- a/kdeprint/foomatic/make_driver_db_foomatic.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#define BUFFER_SIZE 1024 -#define WORD_SIZE 256 - -int parseOverview(const char *dbdir, FILE *out); - -int main(int argc, char *argv[]) -{ - FILE *out; - - if (argc != 3) - { - fprintf(stderr,"usage: make_driver_db_foomatic <dbdirectory> <dbfilename>\n"); - exit(-1); - } - out = fopen(argv[2],"w"); - if (out == NULL) - { - fprintf(stderr,"Unable to open DB file: %s\n",argv[2]); - exit(-1); - } - /* first parse RHS driver DB */ - if (!parseOverview(argv[1], out)) - fprintf(stderr,"Unable to parse printer DB\n"); - return 0; -} - -char* skipSpaces(char *c) -{ - char *cc = c; - while (cc && *cc && isspace(*cc)) cc++; - return cc; -} - -int nextEntity(char *s, FILE *in) -{ - char c, p[WORD_SIZE] = {0}; - int index, istag; - - index = 0; - do - { - c = fgetc(in); - } while (isspace(c) && c != EOF); - if (c == EOF) - return -1; - if (c == '<') - { - istag = 1; - c = fgetc(in); - if (c != '/') - ungetc(c, in); - } - else - { - istag = 0; - p[index++] = c; - } - while (index < WORD_SIZE) - { - c = fgetc(in); - if (c != '>' && c != '<') - p[index++] = c; - else - { - if (c == '<') - ungetc(c, in); - break; - } - } - - p[WORD_SIZE - 1] = 0; - strcpy(s, p); - return istag; -} - -void discardTag(const char *tagname, FILE *in) -{ - char entity[WORD_SIZE]; - int istag; - - while ((istag=nextEntity(entity, in)) != -1) - { - if (istag == 1 && strcmp(tagname, entity) == 0) - break; - } -} - -void clearDrivers(char **d) -{ - int index = 0; - - while (d[index]) - { - free(d[index]); - d[index++] = 0; - } -} - -int parseOverview(const char *dbdir, FILE *out) -{ - FILE *in; - char printerid[WORD_SIZE], manu[WORD_SIZE], model[WORD_SIZE], tag[WORD_SIZE], driver[WORD_SIZE]; - char *drivers[20] = {0}; - int index = 0; - char cmd[BUFFER_SIZE] = {0}; - - snprintf(cmd, BUFFER_SIZE, "foomatic-combo-xml -O -l %s", dbdir); - in = popen(cmd, "r"); - if (in == NULL) - return 0; - if (nextEntity(tag, in) == 1 && strcmp(tag, "overview") == 0) - { - printf("-1\n"); - while (nextEntity(tag, in) == 1) - { - if (strcmp(tag, "overview") == 0 || strcmp(tag, "printer") != 0) - break; - strcpy(printerid, ""); - strcpy(manu, ""); - strcpy(model, ""); - clearDrivers(drivers); - while (nextEntity(tag, in) == 1) - { - if (strcmp(tag, "id") == 0) nextEntity(printerid, in); - else if (strcmp(tag, "make") == 0) nextEntity(manu, in); - else if (strcmp(tag, "model") == 0) nextEntity(model, in); - else if (strcmp(tag, "drivers") == 0) - { - index = 0; - while (nextEntity(tag, in) == 1 && strcmp(tag, "driver") == 0 && index < 20) - { - nextEntity(driver, in); - drivers[index++] = strdup(driver); - nextEntity(driver, in); - } - continue; - } - else if (strcmp(tag, "printer") == 0) - { - printf("%s %s\n", manu, model); - index = 0; - while (drivers[index]) - { - fprintf(out, "FILE=%s|%s\n", printerid, drivers[index]); - fprintf(out, "MANUFACTURER=%s\n", manu); - fprintf(out, "MODELNAME=%s\n", model); - fprintf(out, "MODEL=%s\n", model); - fprintf(out, "DESCRIPTION=%s %s (%s)\n", manu, model, drivers[index]); - fprintf(out, "\n"); - index++; - } - break; - } - else - { - discardTag(tag, in); - continue; - } - nextEntity(tag, in); - } - } - } - if (pclose(in) == 0) - index = 1; - else - index = 0; - return index; -} diff --git a/kdeprint/foomatic2loader.cpp b/kdeprint/foomatic2loader.cpp deleted file mode 100644 index 6add13378..000000000 --- a/kdeprint/foomatic2loader.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 "foomatic2loader.h" -#include "driver.h" - -#include <tqfile.h> -#include <tqregexp.h> -#include <tqbuffer.h> -#include <kdebug.h> -#include <klocale.h> - -void tdeprint_foomatic2scanner_init( TQIODevice* ); -void tdeprint_foomatic2scanner_terminate(); - -Foomatic2Loader::Foomatic2Loader() -{ -} - -Foomatic2Loader::~Foomatic2Loader() -{ -} - -bool Foomatic2Loader::read( TQIODevice *d ) -{ - bool result = true; - m_foodata.clear(); - tdeprint_foomatic2scanner_init( d ); - if ( tdeprint_foomatic2parse( this ) != 0 ) - result = false; - tdeprint_foomatic2scanner_terminate(); - return result; -} - -bool Foomatic2Loader::readFromFile( const TQString& filename ) -{ - TQFile f( filename ); - m_foodata.clear(); - if ( f.open( IO_ReadOnly ) ) - return read( TQT_TQIODEVICE(&f) ); - return false; -} - -bool Foomatic2Loader::readFromBuffer( const TQString& buffer ) -{ - TQCString buf = buffer.utf8(); - TQBuffer d( buf ); - m_foodata.clear(); - if ( d.open( IO_ReadOnly ) ) - return read( TQT_TQIODEVICE(&d) ); - return false; -} - -DrBase* Foomatic2Loader::createValue( const TQString& name, const TQMap<TQString,TQVariant>& m ) const -{ - DrBase *choice = new DrBase; - choice->setName( name ); - choice->set( "text", m.operator[]( "comment" ).toString() ); - return choice; -} - -DrBase* Foomatic2Loader::createOption( const TQMap<TQString,TQVariant>& m ) const -{ - TQString type = m.operator[]( "type" ).toString(); - DrBase *opt = NULL; - if ( type == "enum" ) - { - DrListOption *lopt = new DrListOption; - TQVariant a = m.operator[]( "vals_byname" ); - TQMap<TQString,TQVariant>::ConstIterator it = a.mapBegin(); - for ( ; it!=a.mapEnd(); ++it ) - { - if ( it.data().type() != TQVariant::Map ) - continue; - DrBase *ch = createValue( it.key(), it.data().toMap() ); - if ( ch ) - lopt->addChoice( ch ); - } - opt = lopt; - } - else if ( type == "int" || type == "float" ) - { - if ( type == "int" ) - opt = new DrIntegerOption; - else - opt = new DrFloatOption; - opt->set( "minval", m.operator[]( "min" ).toString() ); - opt->set( "maxval", m.operator[]( "max" ).toString() ); - } - else if ( type == "bool" ) - { - DrBooleanOption *bopt = new DrBooleanOption; - DrBase *choice; - // choice 1 - choice = new DrBase; - choice->setName( "0" ); - choice->set( "text", m.operator[]( "name_false" ).toString() ); - bopt->addChoice( choice ); - choice = new DrBase; - choice->setName( "1" ); - choice->set( "text", m.operator[]( "name_true" ).toString() ); - bopt->addChoice( choice ); - opt = bopt; - } - else if ( type == "string" ) - { - opt = new DrStringOption; - } - if ( opt ) - { - opt->setName( m.operator[]( "name" ).toString() ); - opt->set( "text", m.operator[]( "comment" ).toString() ); - TQString defval = m.operator[]( "default" ).toString(); - if ( !defval.isEmpty() ) - { - opt->setValueText( defval ); - opt->set( "default", defval ); - } - } - return opt; -} - -DrMain* Foomatic2Loader::buildDriver() const -{ - if ( m_foodata.isEmpty() ) - return NULL; - - TQVariant v = m_foodata.find( "VAR" ).data(); - if ( !v.isNull() && v.type() == TQVariant::Map ) - { - DrMain *driver = new DrMain; - TQMap<TQString,DrGroup*> groups; - driver->set( "manufacturer", v.mapFind( "make" ).data().toString() ); - driver->set( "model", v.mapFind( "model" ).data().toString() ); - driver->set( "matic_printer", v.mapFind( "id" ).data().toString() ); - driver->set( "matic_driver", v.mapFind( "driver" ).data().toString() ); - driver->set( "text", TQString( "%1 %2 (%3)" ).arg( driver->get( "manufacturer" ) ).arg( driver->get( "model" ) ).arg( driver->get( "matic_driver" ) ) ); - if ( m_foodata.contains( "POSTPIPE" ) ) - driver->set( "postpipe", m_foodata.find( "POSTPIPE" ).data().toString() ); - v = v.mapFind( "args" ).data(); - if ( !v.isNull() && v.type() == TQVariant::List ) - { - TQValueList<TQVariant>::ConstIterator it = v.listBegin(); - for ( ; it!=v.listEnd(); ++it ) - { - if ( ( *it ).type() != TQVariant::Map ) - continue; - DrBase *opt = createOption( ( *it ).toMap() ); - if ( opt ) - { - TQString group = DrGroup::groupForOption( opt->name() ); - DrGroup *grp = NULL; - if ( !groups.contains( group ) ) - { - grp = new DrGroup; - grp->set( "text", group ); - driver->addGroup( grp ); - groups.insert( group, grp ); - } - else - grp = groups[ group ]; - grp->addOption( opt ); - if ( opt->name() == "PageSize" ) - { - // try to add the corresponding page sizes - TQVariant choices = ( *it ).mapFind( "vals_byname" ).data(); - TQRegExp re( "(\\d+) +(\\d+)" ); - if ( choices.type() == TQVariant::Map ) - { - TQMap<TQString,TQVariant>::ConstIterator it = choices.mapBegin(); - for ( ; it!=choices.mapEnd(); ++it ) - { - TQString driverval = ( *it ).mapFind( "driverval" ).data().toString(); - if ( re.exactMatch( driverval ) ) - { - driver->addPageSize( new DrPageSize( it.key(), re.cap( 1 ).toInt(), re.cap( 2 ).toInt(), 36, 24, 36, 24 ) ); - } - } - } - } - } - else - kdWarning( 500 ) << "Failed to create option: " << ( *it ).toMap()[ "name" ].toString() << endl; - } - } - return driver; - } - return NULL; -} - -DrMain* Foomatic2Loader::modifyDriver( DrMain *driver ) const -{ - if ( !m_foodata.isEmpty() ) - { - TQValueList<DrBase*> optList; - DrGroup *grp = NULL; - - TQVariant V = m_foodata.find( "VAR" ).data(); - if ( !V.isNull() && V.type() == TQVariant::Map ) - { - TQVariant v = V.mapFind( "args" ).data(); - if ( !v.isNull() && v.type() == TQVariant::List ) - { - TQValueList<TQVariant>::ConstIterator it = v.listBegin(); - for ( ; it!=v.listEnd(); ++it ) - { - if ( ( *it ).type() != TQVariant::Map ) - continue; - DrBase *opt = createOption( ( *it ).toMap() ); - if ( opt ) - optList.append( opt ); - else - kdWarning( 500 ) << "Failed to create option: " << ( *it ).toMap()[ "name" ].toString() << endl; - } - } - else - { - v = V.mapFind( "args_byname" ).data(); - if ( !v.isNull() && v.type() == TQVariant::Map ) - { - TQMap<TQString,TQVariant>::ConstIterator it = v.mapBegin(); - for ( ; it!=v.mapEnd(); ++it ) - { - if ( ( *it ).type() != TQVariant::Map ) - continue; - DrBase *opt = createOption( ( *it ).toMap() ); - if ( opt ) - optList.append( opt ); - else - kdWarning( 500 ) << "Failed to create option: " << ( *it ).toMap()[ "name" ].toString() << endl; - } - } - } - } - - for ( TQValueList<DrBase*>::ConstIterator it=optList.begin(); it!=optList.end(); ++it ) - { - DrBase *opt = ( *it ); - if ( opt ) - { - switch ( opt->type() ) - { - case DrBase::List: - case DrBase::Boolean: - delete opt; - break; - default: - { - if ( !grp ) - { - grp = new DrGroup; - grp->set( "text", i18n( "Adjustments" ) ); - driver->addGroup( grp ); - } - DrBase *oldOpt = driver->findOption( opt->name() ); - if ( oldOpt && oldOpt->type() == DrBase::List ) - { - TQPtrListIterator<DrBase> it( *( static_cast<DrListOption*>( oldOpt )->choices() ) ); - TQString fixedvals; - for ( ; it.current(); ++it ) - { - fixedvals.append( it.current()->name() ); - if ( !it.atLast() ) - fixedvals.append( "|" ); - } - opt->set( "fixedvals", fixedvals ); - } - driver->removeOptionGlobally( opt->name() ); - grp->addOption( opt ); - break; - } - } - } - } - } - return driver; -} - -DrMain* Foomatic2Loader::loadDriver( const TQString& filename ) -{ - Foomatic2Loader loader; - if ( loader.readFromFile( filename ) ) - return loader.buildDriver(); - else - return NULL; -} diff --git a/kdeprint/foomatic2loader.h b/kdeprint/foomatic2loader.h deleted file mode 100644 index 19cfc9d9d..000000000 --- a/kdeprint/foomatic2loader.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 FOOMATIC2LOADER_H -#define FOOMATIC2LOADER_H - -#include <tqmap.h> -#include <tqvariant.h> - -#include <kdelibs_export.h> - -class DrBase; -class DrMain; - -class KDEPRINT_EXPORT Foomatic2Loader -{ -public: - Foomatic2Loader(); - ~Foomatic2Loader(); - - bool read( TQIODevice *d ); - bool readFromBuffer( const TQString& buffer ); - bool readFromFile( const TQString& filename ); - TQMap<TQString,TQVariant> data() const; - DrMain* buildDriver() const; - DrMain* modifyDriver( DrMain* ) const; - - static DrMain* loadDriver( const TQString& filename ); - -private: - TQMap<TQString,TQVariant> m_foodata; - - friend int tdeprint_foomatic2parse( void* ); - DrBase* createValue( const TQString&, const TQMap<TQString,TQVariant>& ) const; - DrBase* createOption( const TQMap<TQString,TQVariant>& ) const; -}; - -inline TQMap<TQString,TQVariant> Foomatic2Loader::data() const -{ return m_foodata; } - -#endif /* FOOMATIC2LOADER_H */ diff --git a/kdeprint/fooparser.cpp b/kdeprint/fooparser.cpp deleted file mode 100644 index e919616ab..000000000 --- a/kdeprint/fooparser.cpp +++ /dev/null @@ -1,1005 +0,0 @@ - -/* A Bison parser, made from ./fooparser.y - by GNU Bison version 1.28 */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define yyparse tdeprint_foomatic2parse -#define yylex tdeprint_foomatic2lex -#define yyerror tdeprint_foomatic2error -#define yylval tdeprint_foomatic2lval -#define yychar tdeprint_foomatic2char -#define yydebug tdeprint_foomatic2debug -#define yynerrs tdeprint_foomatic2nerrs -#define VAR 257 -#define STRING 258 -#define NUMBER 259 -#define UNDEF 260 -#define POSTPIPE 261 -#define QUOTED 262 - -#line 1 "./fooparser.y" - -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -#define YYSTYPE TQVariant -#define YYPARSE_PARAM fooloader -#define YYDEBUG 1 - -#include <stdlib.h> -#include <tqvariant.h> -#include "foomatic2loader.h" - -void yyerror(const char*) {} -int yylex(); -#ifndef YYSTYPE -#define YYSTYPE int -#endif -#include <stdio.h> - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 36 -#define YYFLAG -32768 -#define YYNTBASE 17 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 23) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, - 9, 14, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 15, 2, 16, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 10, 2, 11, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, - 7, 8 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 5, 12, 17, 19, 23, 28, 30, 34, - 36, 38, 40, 44, 48, 51 -}; - -static const short yyrhs[] = { 18, - 0, 17, 18, 0, 3, 9, 10, 19, 11, 12, - 0, 7, 9, 8, 12, 0, 20, 0, 19, 13, - 20, 0, 4, 9, 14, 22, 0, 22, 0, 21, - 13, 22, 0, 6, 0, 4, 0, 5, 0, 15, - 21, 16, 0, 10, 19, 11, 0, 15, 16, 0, - 10, 11, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 42, 43, 46, 47, 50, 51, 54, 57, 58, 61, - 62, 63, 64, 65, 66, 67 -}; -#endif - - -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","VAR","STRING", -"NUMBER","UNDEF","POSTPIPE","QUOTED","'='","'{'","'}'","';'","','","'>'","'['", -"']'","foo","foodata","fieldlist","assignment","valuelist","value", NULL -}; -#endif - -static const short yyr1[] = { 0, - 17, 17, 18, 18, 19, 19, 20, 21, 21, 22, - 22, 22, 22, 22, 22, 22 -}; - -static const short yyr2[] = { 0, - 1, 2, 6, 4, 1, 3, 4, 1, 3, 1, - 1, 1, 3, 3, 2, 2 -}; - -static const short yydefact[] = { 0, - 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, - 0, 5, 4, 0, 0, 0, 0, 3, 6, 11, - 12, 10, 0, 0, 7, 16, 0, 15, 0, 8, - 14, 0, 13, 9, 0, 0 -}; - -static const short yydefgoto[] = { 3, - 4, 11, 12, 29, 25 -}; - -static const short yypact[] = { 15, - 11, 20, 10,-32768, -2, 18,-32768, 27, 7, 23, - 14,-32768,-32768, 19, 22, 27, -1,-32768,-32768,-32768, --32768,-32768, 12, -4,-32768,-32768, 17,-32768, 8,-32768, --32768, -1,-32768,-32768, 35,-32768 -}; - -static const short yypgoto[] = {-32768, - 33, 16, 21,-32768, -17 -}; - - -#define YYLAST 39 - - -static const short yytable[] = { 20, - 21, 22, 20, 21, 22, 23, 30, 8, 23, 35, - 24, 28, 1, 24, 34, 10, 2, 1, 13, 5, - 32, 2, 26, 33, 15, 9, 16, 31, 6, 16, - 10, 14, 17, 18, 36, 7, 19, 0, 27 -}; - -static const short yycheck[] = { 4, - 5, 6, 4, 5, 6, 10, 24, 10, 10, 0, - 15, 16, 3, 15, 32, 4, 7, 3, 12, 9, - 13, 7, 11, 16, 11, 8, 13, 11, 9, 13, - 4, 9, 14, 12, 0, 3, 16, -1, 23 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/lib/bison.simple" -/* This file comes from bison-1.28. */ - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include <alloca.h> -#else /* not sparc */ -/* We think this test detects Watcom and Microsoft C. */ -/* This used to test MSDOS, but that is a bad idea - since that symbol is in the user namespace. */ -#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) -#if 0 /* No need for malloc.h, which pollutes the namespace; - instead, just don't use alloca. */ -#include <malloc.h> -#endif -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -/* I don't know what this was needed for, but it pollutes the namespace. - So I turned it off. rms, 2 May 1997. */ -/* #include <malloc.h> */ - #pragma alloca -#define YYSTACK_USE_ALLOCA -#else /* not MSDOS, or __TURBOC__, or _AIX */ -#if 0 -#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, - and on HPUX 10. Eventually we can turn this on. */ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#endif /* __hpux */ -#endif -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc -#endif - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Define __yy_memcpy. Note that the size argument - should be passed with type unsigned int, because that is what the non-GCC - definitions require. With GCC, __builtin_memcpy takes an arg - of type size_t, but it can handle unsigned int. */ - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - unsigned int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, unsigned int count) -{ - register char *t = to; - register char *f = from; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 217 "/usr/lib/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -#ifdef YYPARSE_PARAM -int yyparse (void *); -#else -int yyparse (void); -#endif -#endif - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - int yyfree_stacks = 0; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -#endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 3: -#line 46 "./fooparser.y" -{ static_cast<Foomatic2Loader*>(fooloader)->m_foodata.insert("VAR",yyvsp[-2]); ; - break;} -case 4: -#line 47 "./fooparser.y" -{ static_cast<Foomatic2Loader*>(fooloader)->m_foodata.insert("POSTPIPE",yyvsp[-1]); ; - break;} -case 5: -#line 50 "./fooparser.y" -{ yyval = yyvsp[0]; ; - break;} -case 6: -#line 51 "./fooparser.y" -{ TQMap<TQString,TQVariant>::ConstIterator it = yyvsp[0].mapBegin(); yyvsp[-2].asMap().insert(it.key(), it.data()); yyval = yyvsp[-2]; ; - break;} -case 7: -#line 54 "./fooparser.y" -{ yyval.asMap().insert(yyvsp[-3].toString(), yyvsp[0]); ; - break;} -case 8: -#line 57 "./fooparser.y" -{ yyval.asList().append(yyvsp[0]); ; - break;} -case 9: -#line 58 "./fooparser.y" -{ yyvsp[-2].asList().append(yyvsp[0]); yyval = yyvsp[-2]; ; - break;} -case 10: -#line 61 "./fooparser.y" -{ yyval = TQVariant(); ; - break;} -case 11: -#line 62 "./fooparser.y" -{ yyval = yyvsp[0]; ; - break;} -case 12: -#line 63 "./fooparser.y" -{ yyval = yyvsp[0]; ; - break;} -case 13: -#line 64 "./fooparser.y" -{ yyval = yyvsp[-1]; ; - break;} -case 14: -#line 65 "./fooparser.y" -{ yyval = yyvsp[-1]; ; - break;} -case 15: -#line 66 "./fooparser.y" -{ yyval = TQVariant(); ; - break;} -case 16: -#line 67 "./fooparser.y" -{ yyval = TQVariant(); ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/lib/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; - - yyacceptlab: - /* YYACCEPT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 0; - - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 1; -} -#line 70 "./fooparser.y" - diff --git a/kdeprint/fooparser.cpp.h b/kdeprint/fooparser.cpp.h deleted file mode 100644 index dd694b5de..000000000 --- a/kdeprint/fooparser.cpp.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef fooparser_cpp_h -#define fooparser_cpp_h -#ifndef YYSTYPE -#define YYSTYPE int -#endif -#define VAR 257 -#define STRING 258 -#define NUMBER 259 -#define UNDEF 260 -#define POSTPIPE 261 -#define QUOTED 262 - - -extern YYSTYPE tdeprint_foomatic2lval; -#endif diff --git a/kdeprint/fooparser.y b/kdeprint/fooparser.y deleted file mode 100644 index 20626ce59..000000000 --- a/kdeprint/fooparser.y +++ /dev/null @@ -1,70 +0,0 @@ -%{ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -#define YYSTYPE TQVariant -#define YYPARSE_PARAM fooloader -#define YYDEBUG 1 - -#include <stdlib.h> -#include <tqvariant.h> -#include "foomatic2loader.h" - -void yyerror(const char*) {} -int yylex(); -%} - -%token VAR -%token STRING -%token NUMBER -%token UNDEF -%token POSTPIPE -%token QUOTED - -%% - -foo: foodata - | foo foodata -; - -foodata: VAR '=' '{' fieldlist '}' ';' { static_cast<Foomatic2Loader*>(fooloader)->m_foodata.insert("VAR",$4); } - | POSTPIPE '=' QUOTED ';' { static_cast<Foomatic2Loader*>(fooloader)->m_foodata.insert("POSTPIPE",$3); } -; - -fieldlist: assignment { $$ = $1; } - | fieldlist ',' assignment { TQMap<TQString,TQVariant>::ConstIterator it = $3.mapBegin(); $1.asMap().insert(it.key(), it.data()); $$ = $1; } -; - -assignment: STRING '=' '>' value { $$.asMap().insert($1.toString(), $4); } -; - -valuelist: value { $$.asList().append($1); } - | valuelist ',' value { $1.asList().append($3); $$ = $1; } -; - -value: UNDEF { $$ = TQVariant(); } - | STRING { $$ = $1; } - | NUMBER { $$ = $1; } - | '[' valuelist ']' { $$ = $2; } - | '{' fieldlist '}' { $$ = $2; } - | '[' ']' { $$ = TQVariant(); } - | '{' '}' { $$ = TQVariant(); } -; - -%% diff --git a/kdeprint/fooscanner.cpp b/kdeprint/fooscanner.cpp deleted file mode 100644 index 3cdd4feb6..000000000 --- a/kdeprint/fooscanner.cpp +++ /dev/null @@ -1,1707 +0,0 @@ -#define yy_create_buffer tdeprint_foomatic2_create_buffer -#define yy_delete_buffer tdeprint_foomatic2_delete_buffer -#define yy_scan_buffer tdeprint_foomatic2_scan_buffer -#define yy_scan_string tdeprint_foomatic2_scan_string -#define yy_scan_bytes tdeprint_foomatic2_scan_bytes -#define yy_flex_debug tdeprint_foomatic2_flex_debug -#define yy_init_buffer tdeprint_foomatic2_init_buffer -#define yy_flush_buffer tdeprint_foomatic2_flush_buffer -#define yy_load_buffer_state tdeprint_foomatic2_load_buffer_state -#define yy_switch_to_buffer tdeprint_foomatic2_switch_to_buffer -#define yyin tdeprint_foomatic2in -#define yyleng tdeprint_foomatic2leng -#define yylex tdeprint_foomatic2lex -#define yyout tdeprint_foomatic2out -#define yyrestart tdeprint_foomatic2restart -#define yytext tdeprint_foomatic2text - -#line 19 "./fooscanner.cpp" -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include <stdio.h> -#include <unistd.h> - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - - -#define yywrap() 1 -#define YY_SKIP_YYWRAP -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 21 -#define YY_END_OF_BUFFER 22 -static yyconst short int yy_accept[55] = - { 0, - 0, 0, 22, 20, 19, 20, 5, 20, 8, 20, - 16, 13, 6, 7, 11, 12, 20, 9, 10, 20, - 0, 15, 5, 0, 14, 0, 16, 0, 0, 0, - 0, 14, 17, 0, 0, 0, 0, 0, 0, 0, - 0, 18, 4, 2, 0, 0, 0, 0, 0, 0, - 1, 0, 3, 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 4, 5, 1, 1, 6, 1, - 1, 1, 1, 7, 8, 9, 1, 10, 11, 10, - 10, 10, 10, 10, 10, 10, 10, 1, 12, 1, - 13, 14, 1, 1, 15, 1, 1, 1, 16, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 17, 1, 1, 1, 18, 1, 1, 1, 1, - 19, 20, 21, 1, 1, 1, 1, 1, 1, 22, - - 23, 24, 1, 1, 25, 1, 1, 1, 1, 26, - 27, 28, 1, 1, 29, 30, 31, 1, 1, 1, - 1, 1, 32, 1, 33, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[34] = - { 0, - 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1 - } ; - -static yyconst short int yy_base[59] = - { 0, - 0, 88, 92, 94, 94, 88, 0, 28, 94, 25, - 28, 94, 94, 94, 94, 94, 64, 94, 94, 22, - 86, 94, 0, 35, 94, 36, 34, 36, 66, 72, - 59, 43, 41, 62, 67, 54, 50, 58, 70, 50, - 43, 55, 94, 71, 50, 63, 51, 73, 46, 71, - 94, 39, 94, 94, 66, 58, 68, 70 - } ; - -static yyconst short int yy_def[59] = - { 0, - 54, 1, 54, 54, 54, 55, 56, 57, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 55, 54, 56, 57, 54, 57, 54, 54, 54, 54, - 54, 57, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 58, 54, 58, - 54, 54, 54, 0, 54, 54, 54, 54 - } ; - -static yyconst short int yy_nxt[128] = - { 0, - 4, 5, 6, 7, 4, 8, 9, 10, 4, 11, - 11, 12, 13, 14, 4, 4, 4, 4, 15, 4, - 16, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 17, 18, 19, 25, 27, 27, 28, 27, 27, 30, - 25, 32, 28, 27, 27, 33, 33, 26, 25, 31, - 33, 33, 42, 42, 26, 26, 37, 41, 23, 42, - 42, 53, 26, 37, 42, 42, 21, 21, 24, 24, - 50, 50, 51, 52, 51, 49, 48, 47, 46, 45, - 44, 43, 40, 39, 38, 36, 35, 34, 22, 29, - 22, 54, 20, 3, 54, 54, 54, 54, 54, 54, - - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54 - } ; - -static yyconst short int yy_chk[128] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 8, 10, 10, 11, 11, 11, 20, - 24, 26, 27, 27, 27, 28, 28, 8, 32, 20, - 33, 33, 41, 41, 24, 26, 33, 37, 56, 37, - 37, 52, 32, 33, 42, 42, 55, 55, 57, 57, - 58, 58, 50, 49, 48, 47, 46, 45, 44, 40, - 39, 38, 36, 35, 34, 31, 30, 29, 21, 17, - 6, 3, 2, 54, 54, 54, 54, 54, 54, 54, - - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "./fooscanner.l" -#define INITIAL 0 -#line 2 "./fooscanner.l" -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 <tqvariant.h> -#include <tqiodevice.h> -#define YYSTYPE QVariant -#include "fooparser.cpp.h" - -#define yylval tdeprint_foomatic2lval - -#define YY_INPUT( buf, result, max_size ) \ - { \ - if ( tdeprint_foomatic2scanner_device ) \ - { \ - result = tdeprint_foomatic2scanner_device->readBlock( buf, max_size ); \ - if ( result < 0 ) \ - result = 0; \ - } \ - else \ - result = 0; \ - } - -TQIODevice* tdeprint_foomatic2scanner_device = NULL; -#line 468 "./fooscanner.cpp" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if ( yyleng > 0 ) \ - yy_current_buffer->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 47 "./fooscanner.l" - - -#line 625 "./fooscanner.cpp" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; - yy_current_state += YY_AT_BOL(); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 55 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 94 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 49 "./fooscanner.l" -{ /* eat up those assignments */ } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 50 "./fooscanner.l" -{ return VAR; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 51 "./fooscanner.l" -{ return POSTPIPE; } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 52 "./fooscanner.l" -{ return UNDEF; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 53 "./fooscanner.l" -{ /* eat up comment parts */ } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 55 "./fooscanner.l" -{ return '='; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 56 "./fooscanner.l" -{ return '>'; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 57 "./fooscanner.l" -{ return ','; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 58 "./fooscanner.l" -{ return '{'; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 59 "./fooscanner.l" -{ return '}'; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 60 "./fooscanner.l" -{ return '['; } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 61 "./fooscanner.l" -{ return ']'; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 62 "./fooscanner.l" -{ return ';'; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 64 "./fooscanner.l" -{ yylval = TQCString(yytext+1, strlen(yytext)-1); return STRING; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 65 "./fooscanner.l" -{ yylval = TQCString(yytext+1, strlen(yytext)-1); return QUOTED; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 66 "./fooscanner.l" -{ yylval = yytext; return NUMBER; } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 67 "./fooscanner.l" -{ yylval = yytext; return NUMBER; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 68 "./fooscanner.l" -{ yylval = yytext; return NUMBER; } - YY_BREAK -case 19: -#line 71 "./fooscanner.l" -case 20: -YY_RULE_SETUP -#line 71 "./fooscanner.l" -{ /* eat up anything else */ } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 73 "./fooscanner.l" -ECHO; - YY_BREAK -#line 814 "./fooscanner.cpp" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - yy_current_state += YY_AT_BOL(); - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 55 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 55 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 54); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - yy_current_buffer->yy_at_bol = (c == '\n'); - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 73 "./fooscanner.l" - - -void tdeprint_foomatic2scanner_init( TQIODevice *d ) -{ - tdeprint_foomatic2scanner_device = d; -} - -void tdeprint_foomatic2scanner_terminate() -{ - tdeprint_foomatic2scanner_device = NULL; -} diff --git a/kdeprint/fooscanner.l b/kdeprint/fooscanner.l deleted file mode 100644 index ddd5bb974..000000000 --- a/kdeprint/fooscanner.l +++ /dev/null @@ -1,83 +0,0 @@ -%{ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 <qvariant.h> -#include <qiodevice.h> -#define YYSTYPE QVariant -#include "fooparser.cpp.h" - -#define yylval tdeprint_foomatic2lval - -#define YY_INPUT( buf, result, max_size ) \ - { \ - if ( tdeprint_foomatic2scanner_device ) \ - { \ - result = tdeprint_foomatic2scanner_device->readBlock( buf, max_size ); \ - if ( result < 0 ) \ - result = 0; \ - } \ - else \ - result = 0; \ - } - -QIODevice* tdeprint_foomatic2scanner_device = NULL; -%} - -%option noyywrap - -D [[:digit:]] - -%% - -^"$VAR1->".*$ { /* eat up those assignments */ } -^"$VAR1" { return VAR; } -^"$postpipe" { return POSTPIPE; } -"undef" { return UNDEF; } -#.* { /* eat up comment parts */ } - -"=" { return '='; } -">" { return '>'; } -"," { return ','; } -"{" { return '{'; } -"}" { return '}'; } -"[" { return '['; } -"]" { return ']'; } -";" { return ';'; } - -'([^']|"\\'")*' { yylval = QCString(yytext+1, strlen(yytext)-1); return STRING; } -\"[^\"]*\" { yylval = QCString(yytext+1, strlen(yytext)-1); return QUOTED; } --?{D}+ { yylval = yytext; return NUMBER; } --?{D}+"."{D}+ { yylval = yytext; return NUMBER; } --?{D}+"."{D}+(e|E)-?{D}+ { yylval = yytext; return NUMBER; } - -\n | -. { /* eat up anything else */ } - -%% - -void tdeprint_foomatic2scanner_init( QIODevice *d ) -{ - tdeprint_foomatic2scanner_device = d; -} - -void tdeprint_foomatic2scanner_terminate() -{ - tdeprint_foomatic2scanner_device = NULL; -} diff --git a/kdeprint/kdeprintcheck.cpp b/kdeprint/kdeprintcheck.cpp deleted file mode 100644 index 1ace082a4..000000000 --- a/kdeprint/kdeprintcheck.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -/* - * Implementation of simple checking mechanism. Rules are defined in - * the form of an URI. Available syntax is: - * - exec:/<execname> -> check for an executable in - * $PATH variable. - * - config:/path/to/file -> check for the existence of a file - * or directory in KDE or standard - * UNIX config locations - * - file:/path/to/file - * - dir:/path/to/dir -> simply check the existence of the - * a file or directory - * - service:/serv -> try to connect to a port on the - * specified host (usually localhost) - * "serv" can be a port value or service name - * - * TO BE IMPLEMENTED: - * - run:/<execname> -> check for a running executable - */ - -#include "tdeprintcheck.h" - -#include <kstandarddirs.h> -#include <kdebug.h> -#include <kextsock.h> -#include <tqfile.h> -#include <unistd.h> - -static const char* const config_stddirs[] = { - "/etc/", - "/usr/etc/", - "/usr/local/etc/", - "/opt/etc/", - "/opt/local/etc/", - 0 -}; - -bool KdeprintChecker::check(KConfig *conf, const TQString& group) -{ - if (!group.isEmpty()) - conf->setGroup(group); - TQStringList uris = conf->readListEntry("Require"); - return check(uris); -} - -bool KdeprintChecker::check(const TQStringList& uris) -{ - bool state(true); - for (TQStringList::ConstIterator it=uris.begin(); it!=uris.end() && state; ++it) - { - state = (state && checkURL(KURL(*it))); - // kdDebug( 500 ) << "auto-detection uri=" << *it << ", state=" << state << endl; - } - return state; -} - -bool KdeprintChecker::checkURL(const KURL& url) -{ - QString prot(url.protocol()); - if (prot == "config") - return checkConfig(url); - else if (prot == "exec") - return checkExec(url); - else if (prot == "file" || prot == "dir") - return KStandardDirs::exists(url.url()); - else if (prot == "service") - return checkService(url); - return false; -} - -bool KdeprintChecker::checkConfig(const KURL& url) -{ - // get the config filename (may contain a path) - QString f(url.path().mid(1)); - bool state(false); - - // first check for standard KDE config file - if (!locate("config",f).isEmpty()) - state = true; - else - // otherwise check in standard UNIX config directories - { - const char* const *p = config_stddirs; - while (*p) - { - // kdDebug( 500 ) << "checkConfig() with " << TQString::tqfromLatin1( *p ) + f << endl; - if ( TQFile::exists( TQString::tqfromLatin1( *p ) + f ) ) - { - state = true; - break; - } - else - p++; - } - } - return state; -} - -bool KdeprintChecker::checkExec(const KURL& url) -{ - QString execname(url.path().mid(1)); - return !(KStandardDirs::findExe(execname).isEmpty()); -} - -bool KdeprintChecker::checkService(const KURL& url) -{ - QString serv(url.path().mid(1)); - KExtendedSocket sock; - - bool ok; - int port = serv.toInt(&ok); - - if (ok) sock.setAddress("localhost", port); - else sock.setAddress("localhost", serv); - return (sock.connect() == 0); -} diff --git a/kdeprint/kdeprintcheck.h b/kdeprint/kdeprintcheck.h deleted file mode 100644 index ae1264a97..000000000 --- a/kdeprint/kdeprintcheck.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KDEPRINTCHECK_H -#define KDEPRINTCHECK_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include <kconfig.h> -#include <kurl.h> - -class KDEPRINT_EXPORT KdeprintChecker -{ -public: - static bool check(KConfig *conf, const TQString& group = TQString::null); - static bool check(const TQStringList& uris); - -private: - static bool checkURL(const KURL&); - static bool checkConfig(const KURL&); - static bool checkExec(const KURL&); - static bool checkService(const KURL&); -}; - -#endif diff --git a/kdeprint/kdeprintd.cpp b/kdeprint/kdeprintd.cpp deleted file mode 100644 index d6237b2b2..000000000 --- a/kdeprint/kdeprintd.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "tdeprintd.h" -#include "kprintprocess.h" - -#include <tqfile.h> -#include <klocale.h> -#include <knotifyclient.h> -#include <kmessagebox.h> -#include <kdebug.h> -#include <dcopclient.h> -#include <kio/passdlg.h> -#include <kio/authinfo.h> -#include <tqlabel.h> -#include <kpushbutton.h> -#include <kiconloader.h> -#include <kstandarddirs.h> -#include <kwin.h> -#include <kapplication.h> -#include <tqlayout.h> -#include <tqtimer.h> -#include <tqregexp.h> - -#include <unistd.h> - -extern "C" -{ - KDE_EXPORT KDEDModule *create_tdeprintd(const TQCString& name) - { - return new KDEPrintd(name); - } -} - -class StatusWindow : public TQWidget -{ -public: - StatusWindow(int pid = -1); - void setMessage(const TQString&); - int pid() const { return m_pid; } - -private: - TQLabel *m_label; - TQPushButton *m_button; - int m_pid; - TQLabel *m_icon; -}; - -StatusWindow::StatusWindow(int pid) -: TQWidget(NULL, "StatusWindow", (WFlags)(WType_TopLevel|WStyle_DialogBorder|WStyle_StaysOnTop|WDestructiveClose)), m_pid(pid) -{ - m_label = new TQLabel(this); - m_label->tqsetAlignment(AlignCenter); - m_button = new KPushButton(KStdGuiItem::close(), this); - m_icon = new TQLabel(this); - m_icon->setPixmap(DesktopIcon("fileprint")); - m_icon->tqsetAlignment(AlignCenter); - KWin::setIcons(winId(), *(m_icon->pixmap()), SmallIcon("fileprint")); - TQGridLayout *l0 = new TQGridLayout(this, 2, 3, 10, 10); - l0->setRowStretch(0, 1); - l0->setColStretch(1, 1); - l0->addMultiCellWidget(m_label, 0, 0, 1, 2); - l0->addWidget(m_button, 1, 2); - l0->addMultiCellWidget(m_icon, 0, 1, 0, 0); - connect(m_button, TQT_SIGNAL(clicked()), TQT_SLOT(hide())); - resize(200, 50); -} - -void StatusWindow::setMessage(const TQString& msg) -{ - //QSize oldSz = size(); - m_label->setText(msg); - //QSize sz = m_label->tqsizeHint(); - //sz += TQSize(layout()->margin()*2, layout()->margin()*2+layout()->spacing()+m_button->tqsizeHint().height()); - // dialog will never be smaller - //sz = sz.expandedTo(oldSz); - //resize(sz); - //setFixedSize(sz); - //layout()->activate(); -} - -//***************************************************************************************************** - -KDEPrintd::KDEPrintd(const TQCString& obj) -: KDEDModule(obj) -{ - m_processpool.setAutoDelete(true); - m_windows.setAutoDelete(false); - m_requestsPending.setAutoDelete( true ); -} - -KDEPrintd::~KDEPrintd() -{ -} - -int KDEPrintd::print(const TQString& cmd, const TQStringList& files, bool remflag) -{ - KPrintProcess *proc = new KPrintProcess; - TQString command(cmd); - TQRegExp re( "\\$out\\{([^}]*)\\}" ); - - connect(proc,TQT_SIGNAL(printTerminated(KPrintProcess*)),TQT_SLOT(slotPrintTerminated(KPrintProcess*))); - connect(proc,TQT_SIGNAL(printError(KPrintProcess*,const TQString&)),TQT_SLOT(slotPrintError(KPrintProcess*,const TQString&))); - proc->setCommand( command ); - if ( re.search( command ) != -1 ) - { - KURL url( re.cap( 1 ) ); - if ( !url.isLocalFile() ) - { - TQString tmpFilename = locateLocal( "tmp", "tdeprint_" + kapp->randomString( 8 ) ); - command.replace( re, KProcess::quote( tmpFilename ) ); - proc->setOutput( re.cap( 1 ) ); - proc->setTempOutput( tmpFilename ); - } - else - command.replace( re, KProcess::quote( re.cap( 1 ) ) ); - } - - if ( checkFiles( command, files ) ) - { - *proc << command; - if ( remflag ) - proc->setTempFiles( files ); - if ( proc->print() ) - { - m_processpool.append( proc ); - return ( int )proc->pid(); - } - } - - delete proc; - return -1; -} - -void KDEPrintd::slotPrintTerminated( KPrintProcess *proc ) -{ - m_processpool.removeRef( proc ); -} - -void KDEPrintd::slotPrintError( KPrintProcess *proc, const TQString& msg ) -{ - KNotifyClient::event("printerror",i18n("<p><nobr>A print error occurred. Error message received from system:</nobr></p><br>%1").arg(msg)); - m_processpool.removeRef( proc ); -} - -TQString KDEPrintd::openPassDlg(const TQString& user) -{ - TQString user_(user), pass_, result; - if (KIO::PasswordDialog::getNameAndPassword(user_, pass_, NULL) == KDialog::Accepted) - result.append(user_).append(":").append(pass_); - return result; -} - -bool KDEPrintd::checkFiles(TQString& cmd, const TQStringList& files) -{ - for (TQStringList::ConstIterator it=files.begin(); it!=files.end(); ++it) - if (::access(TQFile::encodeName(*it).data(), R_OK) != 0) - { - if (KMessageBox::warningContinueCancel(0, - i18n("Some of the files to print are not readable by the KDE " - "print daemon. This may happen if you are trying to print " - "as a different user to the one currently logged in. To continue " - "printing, you need to provide root's password."), - TQString::null, - i18n("Provide root's Password"), - "provideRootsPassword") == KMessageBox::Continue) - { - cmd = ("tdesu -c " + KProcess::quote(cmd)); - break; - } - else - return false; - } - return true; -} - -void KDEPrintd::statusMessage(const TQString& msg, int pid, const TQString& appName) -{ - StatusWindow *w = m_windows.find(pid); - if (!w && !msg.isEmpty()) - { - w = new StatusWindow(pid); - if (appName.isEmpty()) - w->setCaption(i18n("Printing Status - %1").arg("(pid="+TQString::number(pid)+")")); - else - w->setCaption(i18n("Printing Status - %1").arg(appName)); - connect(w, TQT_SIGNAL(destroyed()), TQT_SLOT(slotClosed())); - w->show(); - m_windows.insert(pid, w); - } - if (w) - { - if (!msg.isEmpty()) - w->setMessage(msg); - else - w->close(); - } -} - -void KDEPrintd::slotClosed() -{ - const StatusWindow *w = static_cast<const StatusWindow*>(sender()); - if (w) - { - m_windows.remove(w->pid()); - } -} - -//****************************************************************************************** - -class KDEPrintd::Request -{ -public: - DCOPClientTransaction *transaction; - TQString user; - TQString uri; - int seqNbr; -}; - -TQString KDEPrintd::requestPassword( const TQString& user, const TQString& host, int port, int seqNbr ) -{ - Request *req = new Request; - req->user = user; - req->uri = "print://" + user + "@" + host + ":" + TQString::number(port); - req->seqNbr = seqNbr; - req->transaction = callingDcopClient()->beginTransaction(); - m_requestsPending.append( req ); - if ( m_requestsPending.count() == 1 ) - TQTimer::singleShot( 0, this, TQT_SLOT( processRequest() ) ); - return "::"; -} - -void KDEPrintd::processRequest() -{ - if ( m_requestsPending.count() == 0 ) - return; - - Request *req = m_requestsPending.first(); - KIO::AuthInfo info; - TQByteArray params, reply; - TQCString replyType; - TQString authString( "::" ); - - info.username = req->user; - info.keepPassword = true; - info.url = req->uri; - info.comment = i18n( "Printing system" ); - - TQDataStream input( params, IO_WriteOnly ); - input << info << TQString(i18n( "Authentication failed (user name=%1)" ).arg( info.username )) << 0L << (long int) req->seqNbr; - if ( callingDcopClient()->call( "kded", "kpasswdserver", "queryAuthInfo(KIO::AuthInfo,TQString,long int,long int)", - params, replyType, reply ) ) - { - if ( replyType == "KIO::AuthInfo" ) - { - TQDataStream output( reply, IO_ReadOnly ); - KIO::AuthInfo result; - int seqNbr; - output >> result >> seqNbr; - - if ( result.isModified() ) - authString = result.username + ":" + result.password + ":" + TQString::number( seqNbr ); - } - else - kdWarning( 500 ) << "DCOP returned type error, expected KIO::AuthInfo, received " << replyType << endl; - } - else - kdWarning( 500 ) << "Cannot communicate with kded_kpasswdserver" << endl; - - TQByteArray outputData; - TQDataStream output( outputData, IO_WriteOnly ); - output << authString; - replyType = "TQString"; - callingDcopClient()->endTransaction( req->transaction, replyType, outputData ); - - m_requestsPending.remove( ( unsigned int )0 ); - if ( m_requestsPending.count() > 0 ) - TQTimer::singleShot( 0, this, TQT_SLOT( processRequest() ) ); -} - -void KDEPrintd::initPassword( const TQString& user, const TQString& passwd, const TQString& host, int port ) -{ - TQByteArray params, reply; - TQCString replyType; - KIO::AuthInfo info; - - info.username = user; - info.password = passwd; - info.url = "print://" + user + "@" + host + ":" + TQString::number(port); - - TQDataStream input( params, IO_WriteOnly ); - input << info << ( long int )0; - - if ( !callingDcopClient()->call( "kded", "kpasswdserver", "addAuthInfo(KIO::AuthInfo,long int)", - params, replyType, reply ) ) - kdWarning( 500 ) << "Unable to initialize password, cannot communicate with kded_kpasswdserver" << endl; -} - -#include "tdeprintd.moc" diff --git a/kdeprint/kdeprintd.desktop b/kdeprint/kdeprintd.desktop deleted file mode 100644 index 45cf8ece4..000000000 --- a/kdeprint/kdeprintd.desktop +++ /dev/null @@ -1,162 +0,0 @@ -[Desktop Entry] -Type=Service - -ServiceTypes=KDEDModule -X-KDE-ModuleType=Library -X-KDE-Library=tdeprintd -X-KDE-FactoryName=tdeprintd -X-KDE-Kded-autoload=false -X-KDE-Kded-load-on-demand=true - -Name=KDE Print Daemon -Name[af]=Kde Druk Bediener -Name[ar]=مراقب طباعة كيدي -Name[az]=KDE Çap Demonu -Name[be]=ДÑман друку KDE -Name[bg]=Демон за печат в KDE -Name[bn]=কে.ডি.ই মà§à¦¦à§à¦°à¦£ ডিমন -Name[br]=Diaoul moulañ KDE -Name[bs]=KDE Print Deamon -Name[ca]=Dimoni d'impressió del KDE -Name[cs]=Tiskový démon KDE -Name[csb]=Drëkòwanié -Name[cy]=Daemon Argraffu KDE -Name[da]=KDE's udskriftsdæmon -Name[de]=Druckdienst -Name[el]=Δαίμονας εκτυπώσεων του KDE -Name[eo]=Preso-demono -Name[es]=Demonio de impresión de KDE -Name[et]=KDE trükkimise deemon -Name[eu]=KDEren inprimatze-daemona -Name[fa]=شبح چاپ KDE -Name[fi]=KDE:n tulostuspalvelin -Name[fr]=Démon d'impression de KDE -Name[fy]=KDE ôfdruk Daemon -Name[ga]=Deamhan Priontála KDE -Name[gl]=Demo de Impresión de KDE -Name[he]=תהליך הרקע הדפסה של KDE -Name[hi]=केडीई छपाई ङेमन -Name[hr]=KDE demon za ispis -Name[hsb]=KDE ćišćenski demon -Name[hu]=KDE nyomtatószolgáltatás -Name[id]=Daemon KDE Write -Name[is]=KDE prentþjónn -Name[it]=Demone di stampa KDE -Name[ja]=KDE å°åˆ·ãƒ‡ãƒ¼ãƒ¢ãƒ³ -Name[ka]=KDE-ს ბეჭდვის მáƒáƒ“ული -Name[kk]=KDE баÑып шығару қызметі -Name[km]=Daemon បោះពុម្ព KDE -Name[ko]=KDE ì¸ì‡„ ë°ëª¬ -Name[lb]=KDE-Dréck-Dämon -Name[lt]=KDE spausdinimo tarnyba -Name[lv]=KDE Drukas DÄ“mons -Name[mn]= КДЭ Ð¥ÑвлÑÑ… программ -Name[ms]=Daemon Cetak KDE -Name[mt]=ProÄ‹ess tal-ipprintjar KDE -Name[nb]=KDE-utskriftsnisse -Name[nds]=KDE-Druckdämoon -Name[ne]=KDE मà¥à¤¦à¥à¤°à¤£ डेइमन -Name[nn]=KDE-utskriftsnisse -Name[nso]=Daemon ya Kgatiso ya KDE -Name[pa]=KDE ਪà©à¨°à¨¿à©°à¨Ÿà¨° ਡਾਈਮੋਨ -Name[pl]=Drukowanie -Name[pt]=Servidor de Impressão do KDE -Name[pt_BR]=Serviço de Impressão do KDE -Name[ro]=Demon de tipărire KDE -Name[ru]=Служба печати -Name[rw]=Dayimoni yo Gucapa KDE -Name[se]=KDE Äálihanbálvá -Name[sk]=KDE démon tlaÄe -Name[sl]=TiskalniÅ¡ki strežnik za KDE -Name[sq]=KDE Demoni për Shypje -Name[sr]=KDE-ов демон за штампање -Name[sr@Latn]=KDE-ov demon za Å¡tampanje -Name[ss]=Lidimoni lekushicilela ku KDE -Name[sv]=KDE:s skrivardemon -Name[ta]=கேமேசைச௠சூழல௠அசà¯à®šà¯ டேமன௠-Name[te]=కెడిఈ à°ªà±à°°à°šà±à°°à°£ సూతà±à°°à°§à°¾à°°à°¿ -Name[tg]=Демони чопи KDE -Name[th]=โปรà¹à¸à¸£à¸¡à¹€à¸à¹‰à¸²à¸”ูà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¸‚อง KDE -Name[tr]=KDE Yazdırma Programı -Name[tt]=KDE Bastıru Xezmäte -Name[uk]=Демон друку KDE -Name[uz]=KDE bosib chiqarish xizmati -Name[uz@cyrillic]=KDE боÑиб чиқариш хизмати -Name[ven]=Daemon yau phirintha ya KDE -Name[vi]=Trình ná»n in KDE -Name[wa]=Démon d' imprimaedje di KDE -Name[xh]=Daemon Yoshicilelo lwe KDE -Name[zh_CN]=KDE 打å°å®ˆæŠ¤è¿›ç¨‹ -Name[zh_HK]=KDE 列å°ä¼ºæœç¨‹å¼ -Name[zh_TW]=KDE 列å°ä¼ºæœç¨‹å¼ -Name[zu]= I-Daemon Yokushicilela kwe-KDE -Comment=Print daemon for KDE -Comment[af]=Druk Bediener vir KDE -Comment[bg]=Демон за печат в KDE -Comment[bn]=কে.ডি.ই-র মà§à¦¦à§à¦°à¦£ ডিমন -Comment[br]=Diaoul moulañ evit KDE -Comment[bs]=Demon za Å¡tampu za KDE -Comment[ca]=Dimoni d'impressió per al KDE -Comment[cs]=Tiskový démon KDE -Comment[csb]=Drëkòwanié w KDE -Comment[da]=Udskriftsdæmon for KDE -Comment[de]=Die KDE-Druckdienste "KDEPrint" -Comment[el]=Ένας δαίμονας εκτυπώσεων για το KDE -Comment[eo]=Presodemono por KDE -Comment[es]=Demonio de impresión para KDE -Comment[et]=KDE trükkimise deemon -Comment[eu]=KDEren inprimatze-daemona -Comment[fa]=شبح چاپ برای KDE -Comment[fi]=KDE:n tulostuspalvelin -Comment[fr]=Un démon d'impression pour KDE -Comment[fy]=ôfdruk deamon foar KDE -Comment[ga]=Deamhan priontála le haghaidh KDE -Comment[gl]=Un Demo de Impresión para KDE -Comment[he]=תהליך רקע של KDE להדפסה -Comment[hi]=केडीई के लिठà¤à¤• छपाई डेमन -Comment[hr]=KDE demon za ispisivanje -Comment[hsb]=KDE ćišćenski demon -Comment[hu]=Nyomtatószolgáltatás a KDE-hez -Comment[id]=Daemon pencetakan KDE -Comment[is]=Prentþjónn fyrir KDE -Comment[it]=Demone di stampa per KDE -Comment[ja]=KDE ã®ãŸã‚ã®å°åˆ·ãƒ‡ãƒ¼ãƒ¢ãƒ³ -Comment[ka]=KDE-ს ბეჭდვის მáƒáƒ“ული -Comment[kk]=KDE-нің баÑып шығару қызметі -Comment[km]=Daemon បោះពុម្ព​របស់ KDE -Comment[lb]=Dréck-Dämon fir KDE -Comment[lt]=Spausdinimo tarnyba, skirta KDE -Comment[lv]=Drukas DÄ“mons priekÅ¡ KDE -Comment[mk]=KDE даемон за печатење -Comment[ms]=Daemon Cetak untuk KDE -Comment[nb]=Utskriftsnisse for KDE -Comment[nds]=En Druck-Dämoon för KDE -Comment[ne]=KDE का लागि डेइमन मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ -Comment[nl]=Printer-daemon voor KDE -Comment[nn]=Utskriftsnisse for KDE -Comment[pa]=KDE ਲਈ ਪà©à¨°à¨¿à©°à¨Ÿà¨° ਡਾਈਮੋਨ -Comment[pl]=Drukowanie w KDE -Comment[pt]=Servidor de impressão para o KDE -Comment[pt_BR]=Serviço de Impressão para o KDE -Comment[ro]=Demon de tipărire KDE -Comment[ru]=Служба печати KDE -Comment[rw]=Dayimoni yo gucapa ya KDE -Comment[se]=KDE:a Äálihanbálvá -Comment[sk]=Démon tlaÄe pre KDE -Comment[sl]=TiskalniÅ¡ki strežnik za KDE -Comment[sr]=KDE-ов демон за штампање -Comment[sr@Latn]=KDE-ov demon za Å¡tampanje -Comment[sv]=Skrivardemon för KDE -Comment[ta]=கேடிஇகà¯à®•à®¾à®© ஒர௠அசà¯à®šà¯ டெமான௠-Comment[te]=కెడిఈ కొరకౠసూతà±à°°à°§à°¾à°°à°¿ -Comment[tg]=Демони чопи KDE -Comment[th]=เดมอนระบบà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¸ªà¸³à¸«à¸£à¸±à¸š KDE -Comment[tr]=KDE için bir yazdırma programı -Comment[tt]=KDE öçen bastıru xezmäte -Comment[uk]=Демон друку KDE -Comment[uz]=KDE uchun bosib chiqarish xizmati -Comment[uz@cyrillic]=KDE учун боÑиб чиқариш хизмати -Comment[vi]=Trình ná»n in cho môi trÆ°á»ng KDE. -Comment[zh_CN]=KDE 的打å°å®ˆæŠ¤è¿›ç¨‹ -Comment[zh_HK]=KDE 的列å°ä¼ºæœç¨‹å¼ -Comment[zh_TW]=KDE 的列å°æœå‹™ç¨‹å¼ diff --git a/kdeprint/kdeprintd.h b/kdeprint/kdeprintd.h deleted file mode 100644 index 597ffbc5b..000000000 --- a/kdeprint/kdeprintd.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KDEPRINTD_H -#define KDEPRINTD_H - -#include <kdedmodule.h> -#include <tqptrlist.h> -#include <tqstringlist.h> -#include <tqptrdict.h> -#include <tqguardedptr.h> -#include <tqintdict.h> - -class KPrintProcess; -class KProcess; -class StatusWindow; - -class KDEPrintd : public KDEDModule -{ - Q_OBJECT - K_DCOP - -public: - KDEPrintd(const TQCString& obj); - ~KDEPrintd(); - -k_dcop: - int print(const TQString& cmd, const TQStringList& files, bool remove); - TQString openPassDlg(const TQString& user); - ASYNC statusMessage(const TQString& msg, int pid = -1, const TQString& appName = TQString::null); - TQString requestPassword( const TQString& user, const TQString& host, int port, int seqNbr ); - void initPassword( const TQString& user, const TQString& passwd, const TQString& host, int port ); - -protected slots: - void slotPrintTerminated( KPrintProcess* ); - void slotPrintError( KPrintProcess*, const TQString& ); - void slotClosed(); - void processRequest(); - -protected: - bool checkFiles(TQString& cmd, const TQStringList& files); - -private: - class Request; - TQPtrList<KPrintProcess> m_processpool; - TQIntDict<StatusWindow> m_windows; - TQPtrList<Request> m_requestsPending; -}; - -#endif diff --git a/kdeprint/kdeprintrc b/kdeprint/kdeprintrc deleted file mode 100644 index 7e34d8e9e..000000000 --- a/kdeprint/kdeprintrc +++ /dev/null @@ -1,7 +0,0 @@ -[General] -PrintSystem=cups -Orientation=1 -ViewType=1 -ViewToolBar=false -ViewMenuBar=true -ViewPrinterInfos=true diff --git a/kdeprint/kdeprintrc.upd b/kdeprint/kdeprintrc.upd deleted file mode 100644 index faf6abab8..000000000 --- a/kdeprint/kdeprintrc.upd +++ /dev/null @@ -1,6 +0,0 @@ -Id=kde-3.1-toolbar -File=tdeprintrc -Group=General -Options=copy -Key=ViewToolBar,ViewMenuBar -RemoveKey=ViewToolBar diff --git a/kdeprint/kfilelist.cpp b/kdeprint/kfilelist.cpp deleted file mode 100644 index 1f67851c6..000000000 --- a/kdeprint/kfilelist.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kfilelist.h" - -#include <tqtoolbutton.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqtooltip.h> -#include <tqheader.h> -#include <tqwhatsthis.h> - -#include <kio/netaccess.h> -#include <kurldrag.h> -#include <kfiledialog.h> -#include <klocale.h> -#include <kiconloader.h> -#include <klistview.h> -#include <krun.h> -#include <kmimetype.h> - -KFileList::KFileList(TQWidget *parent, const char *name) -: TQWidget(parent, name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisAddFileButton = i18n( " <qt> <b>Add File button</b>" - " <p>This button calls the <em>'File Open'</em> dialog to let you" - " select a file for printing. Note, that " - " <ul><li>you can select ASCII or International Text, PDF," - " PostScript, JPEG, TIFF, PNG, GIF and many other graphic" - " formats." - " <li>you can select various files from different paths" - " and send them as one \"multi-file job\" to the printing" - " system." - " </ul>" - " </qt>" ); - - TQString whatsThisRemoveFileButton = i18n(" <qt> <b>Remove File button</b>" - " <p>This button removes the highlighted file from the" - " list of to-be-printed files." - " </qt>" ); - - TQString whatsThisMoveFileUpButton = i18n(" <qt> <b>Move File Up button</b>" - " <p>This button moves the highlighted file up in the list" - " of files to be printed.</p>" - " <p>In effect, this changes the order" - " of the files' printout.</p>" - " </qt>" ); - - TQString whatsThisMoveFileDownButton = i18n(" <qt> <b>Move File Down button</b>" - " <p>This button moves the highlighted file down in the list" - " of files to be printed.</p>" - " <p>In effect, this changes the order" - " of the files' printout.</p>" - " </qt>" ); - - TQString whatsThisOpenFileButton = i18n( " <qt> <b>File Open button</b>" - " <p>This button tries to open the highlighted file, so" - " you can view or edit it before you send it to the printing" - " system.</p>" - " <p>If you open" - " files, KDEPrint will use the application matching the MIME type of" - " the file.</p>" - " </qt>" ); - - TQString whatsThisFileSelectionListview = i18n( " <qt> <b>File List view</b>" - " <p>This list displays all the files you selected for printing." - " You can see the file name(s), file path(s) and the file" - " (MIME) type(s) as determined by KDEPrint. You may re-arrange the " - " initial order of the list " - " with the help of the arrow buttons on the right.</p>" - " <p>The files will be printed as a single job," - " in the same order as displayed in the list.</p>" - " <p><b>Note:</b> You can select multiple files. The files may be in multiple" - " locations. The files may be of multiple MIME types. The buttons on the right" - " side let you add more files, remove already selected files from the list, " - " re-order the list (by moving files up or down), and open files. If you open" - " files, KDEPrint will use the application matching the MIME type of" - " the file.</p>" - " </qt>" ); - - m_block = false; - - m_files = new KListView(this); - m_files->addColumn(i18n("Name")); - m_files->addColumn(i18n("Type")); - m_files->addColumn(i18n("Path")); - m_files->setAllColumnsShowFocus(true); - m_files->setSorting(-1); - m_files->setAcceptDrops(false); - m_files->setSelectionMode(TQListView::Extended); - m_files->header()->setStretchEnabled(true, 2); - TQWhatsThis::add(m_files, whatsThisFileSelectionListview); - connect(m_files, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged())); - - m_add = new TQToolButton(this); - m_add->setIconSet(SmallIconSet("fileopen")); - connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddFile())); - TQToolTip::add(m_add, i18n("Add file")); - TQWhatsThis::add(m_add, whatsThisAddFileButton); - - m_remove = new TQToolButton(this); - m_remove->setIconSet(SmallIconSet("remove")); - connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveFile())); - TQToolTip::add(m_remove, i18n("Remove file")); - TQWhatsThis::add(m_remove, whatsThisRemoveFileButton); - m_remove->setEnabled(false); - - m_open = new TQToolButton(this); - m_open->setIconSet(SmallIconSet("filefind")); - connect(m_open, TQT_SIGNAL(clicked()), TQT_SLOT(slotOpenFile())); - TQToolTip::add(m_open, i18n("Open file")); - TQWhatsThis::add(m_open, whatsThisOpenFileButton); - m_open->setEnabled(false); - - m_up = new TQToolButton(this); - m_up->setIconSet(SmallIconSet("up")); - connect(m_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotUp())); - TQToolTip::add(m_up, i18n("Move up")); - TQWhatsThis::add(m_up, whatsThisMoveFileUpButton); - m_up->setEnabled(false); - - m_down = new TQToolButton(this); - m_down->setIconSet(SmallIconSet("down")); - connect(m_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotDown())); - TQToolTip::add(m_down, i18n("Move down")); - TQWhatsThis::add(m_down, whatsThisMoveFileDownButton); - m_down->setEnabled(false); - - setAcceptDrops(true); - - TQToolTip::add(m_files, i18n( - "Drag file(s) here or use the button to open a file dialog. " - "Leave empty for <b><STDIN></b>.")); - - TQHBoxLayout *l0 = new TQHBoxLayout(this, 0, KDialog::spacingHint()); - TQVBoxLayout *l1 = new TQVBoxLayout(0, 0, 1); - l0->addWidget(m_files); - l0->addLayout(l1); - l1->addWidget(m_add); - l1->addWidget(m_remove); - l1->addWidget(m_open); - l1->addSpacing(10); - l1->addWidget(m_up); - l1->addWidget(m_down); - l1->addStretch(1); -} - -KFileList::~KFileList() -{ -} - -void KFileList::dragEnterEvent(TQDragEnterEvent *e) -{ - e->accept(KURLDrag::canDecode(e)); -} - -void KFileList::dropEvent(TQDropEvent *e) -{ - KURL::List files; - if (KURLDrag::decode(e, files)) - { - addFiles(files); - } -} - -void KFileList::addFiles(const KURL::List& files) -{ - if (files.count() > 0) - { - // search last item in current list, to add new ones at the end - TQListViewItem *item = m_files->firstChild(); - while (item && item->nextSibling()) - item = item->nextSibling(); - - for (KURL::List::ConstIterator it=files.begin(); it!=files.end(); ++it) - { - KMimeType::Ptr mime = KMimeType::findByURL( *it, 0, true, false); - item = new TQListViewItem(m_files, item, (*it).fileName(), mime->comment(), (*it).url()); - item->setPixmap(0, mime->pixmap(*it, KIcon::Small)); - } - - slotSelectionChanged(); - /* - if (m_files->childCount() > 0) - { - m_remove->setEnabled(true); - m_open->setEnabled(true); - if (m_files->currentItem() == 0) - m_files->setSelected(m_files->firstChild(), true); - } - */ - } -} - -void KFileList::setFileList(const TQStringList& files) -{ - m_files->clear(); - TQListViewItem *item = 0; - for (TQStringList::ConstIterator it=files.begin(); it!=files.end(); ++it) - { - KURL url = KURL::fromPathOrURL( *it ); - KMimeType::Ptr mime = KMimeType::findByURL(url, 0, true, false); - item = new TQListViewItem(m_files, item, url.fileName(), mime->comment(), url.url()); - item->setPixmap(0, mime->pixmap(url, KIcon::Small)); - } - slotSelectionChanged(); -} - -TQStringList KFileList::fileList() const -{ - TQStringList l; - TQListViewItem *item = m_files->firstChild(); - while (item) - { - l << item->text(2); - item = item->nextSibling(); - } - return l; -} - -void KFileList::slotAddFile() -{ - KURL::List fnames = KFileDialog::getOpenURLs(TQString::null, TQString::null, this); - if (!fnames.empty()) - addFiles(fnames); -} - -void KFileList::slotRemoveFile() -{ - TQPtrList<TQListViewItem> l; - selection(l); - l.setAutoDelete(true); - m_block = true; - l.clear(); - m_block = false; - slotSelectionChanged(); -} - -void KFileList::slotOpenFile() -{ - TQListViewItem *item = m_files->currentItem(); - if (item) - { - KURL url( item->text( 2 ) ); - new KRun(url); - } -} - -TQSize KFileList::tqsizeHint() const -{ - return TQSize(100, 100); -} - -void KFileList::selection(TQPtrList<TQListViewItem>& l) -{ - l.setAutoDelete(false); - TQListViewItem *item = m_files->firstChild(); - while (item) - { - if (item->isSelected()) - l.append(item); - item = item->nextSibling(); - } -} - -void KFileList::slotSelectionChanged() -{ - if (m_block) - return; - - TQPtrList<TQListViewItem> l; - selection(l); - m_remove->setEnabled(l.count() > 0); - m_open->setEnabled(l.count() == 1); - m_up->setEnabled(l.count() == 1 && l.first()->itemAbove()); - m_down->setEnabled(l.count() == 1 && l.first()->itemBelow()); -} - -void KFileList::slotUp() -{ - TQPtrList<TQListViewItem> l; - selection(l); - if (l.count() == 1 && l.first()->itemAbove()) - { - TQListViewItem *item(l.first()), *clone; - clone = new TQListViewItem(m_files, item->itemAbove()->itemAbove(), item->text(0), item->text(1), item->text(2)); - clone->setPixmap(0, *(item->pixmap(0))); - delete item; - m_files->setCurrentItem(clone); - m_files->setSelected(clone, true); - } -} - -void KFileList::slotDown() -{ - TQPtrList<TQListViewItem> l; - selection(l); - if (l.count() == 1 && l.first()->itemBelow()) - { - TQListViewItem *item(l.first()), *clone; - clone = new TQListViewItem(m_files, item->itemBelow(), item->text(0), item->text(1), item->text(2)); - clone->setPixmap(0, *(item->pixmap(0))); - delete item; - m_files->setCurrentItem(clone); - m_files->setSelected(clone, true); - } -} - -#include "kfilelist.moc" diff --git a/kdeprint/kfilelist.h b/kdeprint/kfilelist.h deleted file mode 100644 index 03b7977d8..000000000 --- a/kdeprint/kfilelist.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KFILELIST_H -#define KFILELIST_H - -#include <tqwidget.h> -#include <tqptrlist.h> -#include <kurl.h> - -class KListView; -class TQToolButton; -class TQListViewItem; - -class KFileList : public TQWidget -{ - Q_OBJECT -public: - KFileList(TQWidget *parent = 0, const char *name = 0); - virtual ~KFileList(); - - void setFileList(const TQStringList&); - TQStringList fileList() const; - TQSize tqsizeHint() const; - -protected slots: - void slotAddFile(); - void slotRemoveFile(); - void slotOpenFile(); - void slotSelectionChanged(); - void slotUp(); - void slotDown(); - -protected: - void dragEnterEvent(TQDragEnterEvent*); - void dropEvent(TQDropEvent*); - void addFiles(const KURL::List&); - void selection(TQPtrList<TQListViewItem>&); - -private: - KListView *m_files; - TQToolButton *m_add, *m_remove, *m_open, *m_up, *m_down; - bool m_block; -}; - -#endif diff --git a/kdeprint/kmdbentry.cpp b/kdeprint/kmdbentry.cpp deleted file mode 100644 index 34a0b60b4..000000000 --- a/kdeprint/kmdbentry.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmdbentry.h" -#include "kmfactory.h" -#include "kmmanager.h" - -KMDBEntry::KMDBEntry() : recommended(false) -{ -} - -bool KMDBEntry::validate(bool checkIt) -{ - // check model: if one of "model" or "modelname" is empty, replace - // by the other one. At the end, "model" must be non empty. - if (model.isEmpty()) - { - model = modelname; - } - if (modelname.isEmpty()) - { - modelname = model; - } - if (model.isEmpty()) - return false; - - // check manufacturer - if (manufacturer.isEmpty()) - { - int p = model.find(' ',0); - if (p != -1) manufacturer = model.left(p); - if (manufacturer.isEmpty()) return false; - } - - // extract manufacturer from model - if (model.find(manufacturer,0,false) == 0) - { - model = model.right(model.length()-manufacturer.length()-1).stripWhiteSpace(); - if (model.isEmpty()) return false; - } - - if (checkIt) - return KMFactory::self()->manager()->validateDbDriver(this); - else - return true; -} diff --git a/kdeprint/kmdbentry.h b/kdeprint/kmdbentry.h deleted file mode 100644 index cccec92b6..000000000 --- a/kdeprint/kmdbentry.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMDBENTRY_H -#define KMDBENTRY_H - -#include <tqstring.h> -#include <tqptrlist.h> - -#include <kdelibs_export.h> - -struct KDEPRINT_EXPORT KMDBEntry -{ - // the file location of the driver - TQString file; - // normal information - TQString manufacturer; - TQString model; - TQString modelname; - // information used for auto-detection - TQString pnpmanufacturer; - TQString pnpmodel; - // short driver description (if any) - TQString description; - // tell whether this is the recommended driver - bool recommended; - TQString drivercomment; - - KMDBEntry(); - bool validate(bool checkIt = true); -}; - -typedef TQPtrList<KMDBEntry> KMDBEntryList; -typedef TQPtrListIterator<KMDBEntry> KMDBEntryListIterator; - -#endif diff --git a/kdeprint/kmfactory.cpp b/kdeprint/kmfactory.cpp deleted file mode 100644 index 3206d3cee..000000000 --- a/kdeprint/kmfactory.cpp +++ /dev/null @@ -1,453 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmfactory.h" -#include "kmmanager.h" -#include "kmjobmanager.h" -#include "kmuimanager.h" -#include "kprinterimpl.h" -#include "kprinter.h" -#include "kpreloadobject.h" -#include "tdeprintcheck.h" -#include "kxmlcommand.h" - -#include <tqdir.h> -#include <tqfile.h> -#include <tqsettings.h> - -#include <klibloader.h> -#include <kconfig.h> -#include <kstandarddirs.h> -#include <kiconloader.h> -#include <kdebug.h> -#include <kmessagebox.h> -#include <klocale.h> -#include <ksimpleconfig.h> -#include <kstaticdeleter.h> -#include <kapplication.h> -#include <dcopclient.h> -#include <dcopref.h> -#include <kio/authinfo.h> - -#include <unistd.h> - -#define UNLOAD_OBJECT(x) if (x != 0) { delete x; x = 0; } - -#ifdef Q_WS_X11 -extern void qt_generate_epsf( bool b ); -#endif - -KMFactory* KMFactory::m_self = 0; -static KStaticDeleter<KMFactory> s_kmfactorysd; - -KMFactory* KMFactory::self() -{ - if (!m_self) - m_self = s_kmfactorysd.setObject(m_self, new KMFactory()); - return m_self; -} - -bool KMFactory::exists() -{ - return m_self != 0L; -} - -void KMFactory::release() -{ - if (m_self) - { - KMFactory* p = m_self; - m_self = 0; // so that exists() says false - delete p; - } -} - -KMFactory::KMFactory() - : TQObject(NULL, "Factory") -{ - m_settings = new Settings; - m_settings->application = KPrinter::Dialog; - m_settings->pageSelection = KPrinter::SystemSide; - m_settings->standardDialogPages = KPrinter::CopiesPage; - m_settings->pageSize = -1; - m_settings->orientation = -1; - - m_objects.setAutoDelete(false); - - m_manager = 0; - m_jobmanager = 0; - m_uimanager = 0; - m_implementation = 0; - m_factory = 0; - m_printconfig = 0; -#if QT_VERSION >= 230 - // Qt's default behavior, to generate EPS in some cases and not in others, sucks. - // This is fixed in Qt 3.0, but for Qt 2.x we need to disable it explicitly. - // If this is a problem for anyone, we can add a public method to set this flag. - // (David Faure, doing as advised by Lars Knoll) -#ifdef Q_WS_X11 - qt_generate_epsf( false ); -#endif -#endif - - // By default, embed PS fonts - bool ok = false; - TQSettings settings; - settings.readBoolEntry( "/qt/embedFonts", true, &ok ); - if ( !ok ) - settings.writeEntry( "/qt/embedFonts", true ); - - KGlobal::iconLoader()->addAppDir("tdeprint"); - KGlobal::locale()->insertCatalogue("tdeprint"); - - // create DCOP signal connection - connectDCOPSignal(0, 0, "pluginChanged(pid_t)", "slot_pluginChanged(pid_t)", false); - connectDCOPSignal(0, 0, "configChanged()", "slot_configChanged()", false); -} - -KMFactory::~KMFactory() -{ - delete m_settings; - // The only object to be destroyed is m_printconfig. All other objects have been - // created with "this" as parent, so we don't need to care about their destruction - UNLOAD_OBJECT(m_printconfig); - m_self = 0; -} - -KMManager* KMFactory::manager() -{ - if (!m_manager) - createManager(); - Q_CHECK_PTR(m_manager); - return m_manager; -} - -KMJobManager* KMFactory::jobManager() -{ - if (!m_jobmanager) - createJobManager(); - Q_CHECK_PTR(m_jobmanager); - return m_jobmanager; -} - -KMUiManager* KMFactory::uiManager() -{ - if (!m_uimanager) - createUiManager(); - Q_CHECK_PTR(m_uimanager); - return m_uimanager; -} - -KPrinterImpl* KMFactory::printerImplementation() -{ - if (!m_implementation) - createPrinterImpl(); - Q_CHECK_PTR(m_implementation); - return m_implementation; -} - -KMVirtualManager* KMFactory::virtualManager() -{ - return manager()->m_virtualmgr; -} - -KMSpecialManager* KMFactory::specialManager() -{ - return manager()->m_specialmgr; -} - -KXmlCommandManager* KMFactory::commandManager() -{ - return KXmlCommandManager::self(); -} - -void KMFactory::createManager() -{ - loadFactory(); - if (m_factory) m_manager = (KMManager*)m_factory->create(this,"Manager","KMManager"); - if (!m_manager) m_manager = new KMManager(this,"Manager"); -} - -void KMFactory::createJobManager() -{ - loadFactory(); - if (m_factory) m_jobmanager = (KMJobManager*)m_factory->create(this,"JobManager","KMJobManager"); - if (!m_jobmanager) m_jobmanager = new KMJobManager(this,"JobManager"); -} - -void KMFactory::createUiManager() -{ - loadFactory(); - if (m_factory) m_uimanager = (KMUiManager*)m_factory->create(this,"UiManager","KMUiManager"); - if (!m_uimanager) m_uimanager = new KMUiManager(this,"UiManager"); -} - -void KMFactory::createPrinterImpl() -{ - loadFactory(); - if (m_factory) m_implementation = (KPrinterImpl*)m_factory->create(this,"PrinterImpl","KPrinterImpl"); - if (!m_implementation) m_implementation = new KPrinterImpl(this,"PrinterImpl"); -} - -void KMFactory::loadFactory(const TQString& syst) -{ - if (!m_factory) - { - TQString sys(syst); - if (sys.isEmpty()) - // load default configured print plugin - sys = printSystem(); - TQString libname = TQString::tqfromLatin1("tdeprint_%1").arg(sys); - m_factory = KLibLoader::self()->factory(TQFile::encodeName(libname)); - if (!m_factory) - { - KMessageBox::error(0, - i18n("<qt>There was an error loading %1. The diagnostic is:<p>%2</p></qt>") - .arg(libname).arg(KLibLoader::self()->lastErrorMessage())); - } - } -} - -KConfig* KMFactory::printConfig(const TQString& group) -{ - if (!m_printconfig) - { - m_printconfig = new KConfig("tdeprintrc"); - Q_CHECK_PTR(m_printconfig); - } - if (!group.isEmpty()) - m_printconfig->setGroup(group); - return m_printconfig; -} - -TQString KMFactory::printSystem() -{ - KConfig *conf = printConfig(); - conf->setGroup("General"); - TQString sys = conf->readEntry("PrintSystem"); - if (sys.isEmpty()) - { - // perform auto-detection (will at least return "lpdunix") - sys = autoDetect(); - // save the result - conf->writeEntry("PrintSystem", sys); - conf->sync(); - } - else if ( sys.length()==1 && sys[0].isDigit() ) // discard old-style settings - sys = "lpdunix"; - return sys; -} - -void KMFactory::unload() -{ - UNLOAD_OBJECT(m_manager); - UNLOAD_OBJECT(m_jobmanager); - UNLOAD_OBJECT(m_uimanager); - UNLOAD_OBJECT(m_implementation); - // factory will be automatically unloaded by KLibLoader as all object have been deleted. - // But to have loadFactory() to work, we need to set m_factory to NULL. - m_factory = 0; -} - -void KMFactory::reload(const TQString& syst, bool saveSyst) -{ - // notify all registered objects about the coming reload - TQPtrListIterator<KPReloadObject> it(m_objects); - for (;it.current();++it) - it.current()->aboutToReload(); - - // unload all objects from the plugin - unload(); - if (saveSyst) - { - KConfig *conf = printConfig(); - conf->setGroup("General"); - conf->writeEntry("PrintSystem", syst); - conf->sync(); - - // notify all other apps using DCOP signal - emit pluginChanged(getpid()); - } - - // reload the factory - loadFactory(syst); - - // notify all registered objects - for (it.toFirst();it.current();++it) - it.current()->reload(); -} - -TQValueList<KMFactory::PluginInfo> KMFactory::pluginList() -{ - TQDir d(locate("data", "tdeprint/plugins/"), "*.print", TQDir::Name, TQDir::Files); - TQValueList<PluginInfo> list; - for (uint i=0; i<d.count(); i++) - { - PluginInfo info(pluginInfo(d.absFilePath(d[i]))); - if (info.name.isEmpty()) - continue; - list.append(info); - } - return list; -} - -KMFactory::PluginInfo KMFactory::pluginInfo(const TQString& name) -{ - TQString path(name); - if (path[0] != '/') - path = locate("data", TQString::tqfromLatin1("tdeprint/plugins/%1.print").arg(name)); - KSimpleConfig conf(path); - PluginInfo info; - - conf.setGroup("KDE Print Entry"); - info.name = conf.readEntry("PrintSystem"); - info.comment = conf.readEntry("Comment"); - if (info.comment.isEmpty()) - info.comment = info.name; - info.detectUris = conf.readListEntry("DetectUris"); - info.detectPrecedence = conf.readNumEntry("DetectPrecedence", 0); - info.mimeTypes = conf.readListEntry("MimeTypes"); - if (info.mimeTypes.isEmpty()) - info.mimeTypes << "application/postscript"; - info.primaryMimeType = conf.readEntry("PrimaryMimeType", info.mimeTypes[0]); - - return info; -} - -void KMFactory::registerObject(KPReloadObject *obj, bool priority) -{ - // check if object already registered, then add it - if (m_objects.findRef(obj) == -1) - { - if (priority) - m_objects.prepend(obj); - else - m_objects.append(obj); - kdDebug(500) << "tdeprint: registering " << (void*)obj << ", number of objects = " << m_objects.count() << endl; - } -} - -void KMFactory::unregisterObject(KPReloadObject *obj) -{ - // remove object from list (not deleted as autoDelete is false) - m_objects.removeRef(obj); - kdDebug(500) << "tdeprint: unregistering " << (void*)obj << ", number of objects = " << m_objects.count() << endl; -} - -TQString KMFactory::autoDetect() -{ - TQValueList<PluginInfo> plugins = pluginList(); - int pluginIndex(-1), currentPrecedence(0); - for (uint i=0;i<plugins.count();i++) - { - if (plugins[i].detectUris.count() > 0 && KdeprintChecker::check(plugins[i].detectUris) - && (pluginIndex == -1 || plugins[i].detectPrecedence >= currentPrecedence)) - { - pluginIndex = i; - currentPrecedence = plugins[i].detectPrecedence; - } - } - return (pluginIndex == -1 ? TQString::tqfromLatin1("lpdunix") : plugins[pluginIndex].name); -} - -void KMFactory::slot_pluginChanged(pid_t pid) -{ - // only do something if the notification comes from another process - if (pid != getpid()) - { - // Unload config object (avoid saving it) - printConfig()->rollback(); - UNLOAD_OBJECT(m_printconfig); - // Then reload everything and notified registered objects. - // Do NOT re-save the new print system. - TQString syst = printSystem(); - reload(syst, false); - } -} - -void KMFactory::slot_configChanged() -{ - kdDebug(500) << "KMFactory (" << getpid() << ") receiving DCOP signal configChanged()" << endl; - // unload/reload config object (make it non dirty to - // avoid saving it and overwriting the newly saved options - // in the other application) - printConfig()->rollback(); - UNLOAD_OBJECT(m_printconfig); - printConfig(); - - // notify all registered objects about the coming reload - TQPtrListIterator<KPReloadObject> it(m_objects); - /*for (;it.current();++it) - it.current()->aboutToReload();*/ - - // notify all object about the change - for (it.toFirst(); it.current();++it) - it.current()->configChanged(); -} - -void KMFactory::saveConfig() -{ - KConfig *conf = printConfig(); - conf->sync(); - kdDebug(500) << "KMFactory (" << getpid() << ") emitting DCOP signal configChanged()" << endl; - emit configChanged(); - // normally, the self application should also receive the signal, - // anyway the config object has been updated "locally", so ne real - // need to reload the config file. -} - -TQPair<TQString,TQString> KMFactory::requestPassword( int& seqNbr, const TQString& user, const TQString& host, int port ) -{ - DCOPRef tdeprintd( "kded", "tdeprintd" ); - /** - * We do not use an internal event loop for 2 potential problems: - * - the MessageWindow modality (appearing afterwards, it pops up on top - * of the password dialog) - * - KMTimer should be stopped, but it's unavailable from this object - */ - DCOPReply reply = tdeprintd.call( "requestPassword", user, host, port, seqNbr ); - if ( reply.isValid() ) - { - TQString replyString = reply; - if ( replyString != "::" ) - { - TQStringList l = TQStringList::split( ':', replyString, true ); - if ( l.count() == 3 ) - { - seqNbr = l[ 2 ].toInt(); - return TQPair<TQString,TQString>( l[ 0 ], l[ 1 ] ); - } - } - } - return TQPair<TQString,TQString>( TQString::null, TQString::null ); -} - -void KMFactory::initPassword( const TQString& user, const TQString& password, const TQString& host, int port ) -{ - DCOPRef tdeprintd( "kded", "tdeprintd" ); - /** - * We do not use an internal event loop for 2 potential problems: - * - the MessageWindow modality (appearing afterwards, it pops up on top - * of the password dialog) - * - KMTimer should be stopped, but it's unavailable from this object - */ - tdeprintd.call( "initPassword", user, password, host, port ); -} - -#include "kmfactory.moc" diff --git a/kdeprint/kmfactory.h b/kdeprint/kmfactory.h deleted file mode 100644 index 168385f6e..000000000 --- a/kdeprint/kmfactory.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KMFACTORY_H -#define KMFACTORY_H - -#include <tqstring.h> -#include <tqvaluelist.h> -#include <tqstringlist.h> -#include <tqptrlist.h> -#include <tqobject.h> -#include <tqpair.h> -#include <dcopobject.h> - -#include <sys/types.h> - -class KMManager; -class KMJobManager; -class KMUiManager; -class KMVirtualManager; -class KXmlCommandManager; -class KMSpecialManager; -class KPrinterImpl; -class KLibFactory; -class KConfig; -class KPReloadObject; - -class KDEPRINT_EXPORT KMFactory : public TQObject, public DCOPObject -{ - Q_OBJECT - K_DCOP - -public: - struct PluginInfo - { - TQString name; - TQString comment; - TQStringList detectUris; - int detectPrecedence; - TQStringList mimeTypes; - TQString primaryMimeType; - }; - - static KMFactory* self(); - static bool exists(); - static void release(); - - KMFactory(); - ~KMFactory(); - - KMManager* manager(); - KMJobManager* jobManager(); - KMUiManager* uiManager(); - KMVirtualManager* virtualManager(); - KMSpecialManager* specialManager(); - KXmlCommandManager* commandManager(); - KPrinterImpl* printerImplementation(); - KConfig* printConfig(const TQString& group = TQString::null); - TQString printSystem(); - TQValueList<PluginInfo> pluginList(); - PluginInfo pluginInfo(const TQString& name); - void saveConfig(); - - void reload(const TQString& syst, bool saveSyst = true); - void registerObject(KPReloadObject*, bool = false); - void unregisterObject(KPReloadObject*); - - struct Settings - { - int application; - int standardDialogPages; - int pageSelection; - int orientation; - int pageSize; - }; - Settings* settings() const { return m_settings; } - - TQPair<TQString,TQString> requestPassword( int& seqNbr, const TQString& user, const TQString& host = "localhost", int port = 0 ); - void initPassword( const TQString& user, const TQString& password, const TQString& host = "localhsot", int port = 0 ); - -k_dcop: - ASYNC slot_pluginChanged(pid_t); - ASYNC slot_configChanged(); - -k_dcop_signals: - void pluginChanged(pid_t); - void configChanged(); - -private: - void createManager(); - void createJobManager(); - void createUiManager(); - void createPrinterImpl(); - void loadFactory(const TQString& syst = TQString::null); - void unload(); - TQString autoDetect(); - -private: - static KMFactory *m_self; - - KMManager *m_manager; - KMJobManager *m_jobmanager; - KMUiManager *m_uimanager; - KPrinterImpl *m_implementation; - KLibFactory *m_factory; - - KConfig *m_printconfig; - Settings *m_settings; - TQPtrList<KPReloadObject> m_objects; -}; - -#endif diff --git a/kdeprint/kmjob.cpp b/kdeprint/kmjob.cpp deleted file mode 100644 index ce7e95993..000000000 --- a/kdeprint/kmjob.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmjob.h" - -#include <klocale.h> - -KMJob::KMJob() -: KMObject() -{ - init(); -} - -KMJob::KMJob(const KMJob& j) -: KMObject() -{ - init(); - copy(j); -} - -KMJob& KMJob::operator=(const KMJob& j) -{ - init(); - copy(j); - return *this; -} - -void KMJob::init() -{ - m_ID = -1; - m_state = KMJob::Error; - m_size = m_processedsize = 0; - m_type = KMJob::System; - m_pages = m_processedpages = 0; - m_remote = false; - m_attributes.resize(1, 0); -} - -void KMJob::copy(const KMJob& j) -{ - m_ID = j.m_ID; - m_name = j.m_name; - m_printer = j.m_printer; - m_owner = j.m_owner; - m_state = j.m_state; - m_size = j.m_size; - m_uri = j.m_uri; - m_type = j.m_type; - m_pages = j.m_pages; - m_processedsize = j.m_processedsize; - m_processedpages = j.m_processedpages; - m_remote = j.m_remote; - m_attributes = j.m_attributes; - - setDiscarded(false); -} - -TQString KMJob::pixmap() -{ - // special case - if (m_type == KMJob::Threaded) - return TQString::tqfromLatin1("exec"); - - // normal case - QString str("tdeprint_job"); - switch (m_state) - { - case KMJob::Printing: - str.append("_process"); - break; - case KMJob::Held: - str.append("_stopped"); - break; - case KMJob::Error: - str.append("_error"); - break; - case KMJob::Completed: - str.append("_completed"); - break; - case KMJob::Cancelled: - str.append("_cancelled"); - break; - default: - break; - } - return str; -} - -TQString KMJob::stateString() -{ - QString str; - switch (m_state) - { - case KMJob::Printing: - str = i18n("Processing..."); - break; - case KMJob::Queued: - str = i18n("Queued"); - break; - case KMJob::Held: - str = i18n("Held"); - break; - case KMJob::Error: - str = i18n("Error"); - break; - case KMJob::Cancelled: - str = i18n("Canceled"); - break; - case KMJob::Aborted: - str = i18n("Aborted"); - break; - case KMJob::Completed: - str = i18n("Completed"); - break; - default: - str = i18n("Unknown State", "Unknown"); - break; - } - return str; -} diff --git a/kdeprint/kmjob.h b/kdeprint/kmjob.h deleted file mode 100644 index d8fed5e8d..000000000 --- a/kdeprint/kmjob.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KMJOB_H -#define KMJOB_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqstring.h> -#include <tqvaluevector.h> -#include <tdeprint/kmobject.h> -#include <kdelibs_export.h> - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMJob : public KMObject -{ -public: - enum JobAction { - Remove = 0x01, - Move = 0x02, - Hold = 0x04, - Resume = 0x08, - Restart = 0x10, - ShowCompleted = 0x20, - All = 0xFF - }; - enum JobState { - Printing = 1, - Queued = 2, - Held = 3, - Error = 4, - Cancelled = 5, - Aborted = 6, - Completed = 7, - Unknown = 8 - }; - enum JobType { - System = 0, - Threaded = 1 - }; - - KMJob(); - KMJob(const KMJob& j); - - KMJob& operator=(const KMJob& j); - void copy(const KMJob& j); - TQString pixmap(); - TQString stateString(); - bool isCompleted() const { return (m_state >= Cancelled && m_state <= Completed); } - bool isActive() const { return !isCompleted(); } - - // inline access functions - int id() const { return m_ID; } - void setId(int id) { m_ID = id; } - const TQString& name() const { return m_name; } - void setName(const TQString& s) { m_name = s; } - const TQString& printer() const { return m_printer; } - void setPrinter(const TQString& s) { m_printer = s; } - const TQString& owner() const { return m_owner; } - void setOwner(const TQString& s) { m_owner = s; } - int state() const { return m_state; } - void setState(int s) { m_state = s; } - int size() const { return m_size; } - void setSize(int s) { m_size = s; } - const TQString& uri() const { return m_uri; } - void setUri(const TQString& s) { m_uri = s; } - int type() const { return m_type; } - void setType(int t) { m_type = t; } - int pages() const { return m_pages; } - void setPages(int p) { m_pages = p; }; - int processedPages() const { return m_processedpages; } - void setProcessedPages(int p) { m_processedpages = p; } - int processedSize() const { return m_processedsize; } - void setProcessedSize(int s) { m_processedsize = s; } - bool isRemote() const { return m_remote; } - void setRemote(bool on) { m_remote = on; } - - TQString attribute(int i) const { return m_attributes[i]; } - void setAttribute(int i, const TQString& att) { m_attributes[i] = att; } - int attributeCount() const { return m_attributes.size(); } - void setAttributeCount(int c) { m_attributes.resize(c); } - -protected: - void init(); - -protected: - // normal members - int m_ID; - QString m_name; - QString m_printer; - QString m_owner; - int m_state; - int m_size; - int m_type; - int m_pages; - int m_processedsize; - int m_processedpages; - bool m_remote; - - // internal members - QString m_uri; - TQValueVector<TQString> m_attributes; -}; - -#endif diff --git a/kdeprint/kmjobmanager.cpp b/kdeprint/kmjobmanager.cpp deleted file mode 100644 index 918c14ff2..000000000 --- a/kdeprint/kmjobmanager.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmjobmanager.h" -#include "kmjob.h" -#include "kmthreadjob.h" -#include "kmfactory.h" - -#include <kaction.h> -#include <kdebug.h> -#include <kconfig.h> - -KMJobManager::KMJobManager(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - m_jobs.setAutoDelete(true); - m_threadjob = new KMThreadJob(this, "ThreadJob"); - m_filter.setAutoDelete(true); -} - -KMJobManager::~KMJobManager() -{ -} - -KMJobManager* KMJobManager::self() -{ - return KMFactory::self()->jobManager(); -} - -void KMJobManager::discardAllJobs() -{ - TQPtrListIterator<KMJob> it(m_jobs); - for (;it.current();++it) - it.current()->setDiscarded(true); -} - -void KMJobManager::removeDiscardedJobs() -{ - for (uint i=0;i<m_jobs.count();i++) - if (m_jobs.tqat(i)->isDiscarded()) - { - m_jobs.remove(i); - i--; - } -} - -/*KMJob* KMJobManager::findJob(int ID) -{ - TQPtrListIterator<KMJob> it(m_jobs); - for (;it.current();++it) - if (it.current()->id() == ID) - return it.current(); - return 0; -}*/ - -KMJob* KMJobManager::findJob(const TQString& uri) -{ - TQPtrListIterator<KMJob> it(m_jobs); - for (;it.current();++it) - if (it.current()->uri() == uri) - return it.current(); - return 0; -} - -void KMJobManager::addJob(KMJob *job) -{ - // only keep it if "printer" is not empty, and in printer filter - if (!job->uri().isEmpty() && !job->printer().isEmpty()) - { - KMJob *aJob = findJob(job->uri()); - if (aJob) - { - aJob->copy(*job); - delete job; - } - else - { - job->setDiscarded(false); - m_jobs.append(job); - } - } - else - delete job; -} - -/*bool KMJobManager::sendCommand(int ID, int action, const TQString& arg) -{ - KMJob *job = findJob(ID); - if (job) - { - TQPtrList<KMJob> l; - l.setAutoDelete(false); - l.append(job); - return sendCommand(l,action,arg); - } - return false; -}*/ - -bool KMJobManager::sendCommand(const TQString& uri, int action, const TQString& arg) -{ - KMJob *job = findJob(uri); - if (job) - { - TQPtrList<KMJob> l; - l.setAutoDelete(false); - l.append(job); - return sendCommand(l,action,arg); - } - return false; -} - -bool KMJobManager::sendCommand(const TQPtrList<KMJob>& jobs, int action, const TQString& args) -{ - // split jobs in 2 classes - TQPtrList<KMJob> csystem, cthread; - csystem.setAutoDelete(false); - cthread.setAutoDelete(false); - TQPtrListIterator<KMJob> it(jobs); - for (;it.current();++it) - if (it.current()->type() == KMJob::Threaded) cthread.append(it.current()); - else csystem.append(it.current()); - - // perform operation on both classes - if (cthread.count() > 0 && !sendCommandThreadJob(cthread, action, args)) - return false; - if (csystem.count() > 0 && !sendCommandSystemJob(csystem, action, args)) - return false; - return true; -} - -bool KMJobManager::sendCommandSystemJob(const TQPtrList<KMJob>&, int, const TQString&) -{ - return false; -} - -bool KMJobManager::sendCommandThreadJob(const TQPtrList<KMJob>& jobs, int action, const TQString&) -{ - if (action != KMJob::Remove) - return false; - - TQPtrListIterator<KMJob> it(jobs); - bool result(true); - for (;it.current() && result; ++it) - result = m_threadjob->removeJob(it.current()->id()); - return result; -} - -bool KMJobManager::listJobs(const TQString&, KMJobManager::JobType, int) -{ - return true; -} - -const TQPtrList<KMJob>& KMJobManager::jobList(bool reload) -{ - if (reload || m_jobs.count() == 0) - { - discardAllJobs(); - TQDictIterator<JobFilter> it(m_filter); - int joblimit = limit(); - bool threadjobs_updated = false; - for (; it.current(); ++it) - { - if ( it.current()->m_isspecial ) - { - if ( !threadjobs_updated ) - { - threadJob()->updateManager( this ); - threadjobs_updated = true; - } - } - else - { - if (it.current()->m_type[ActiveJobs] > 0) - listJobs(it.currentKey(), ActiveJobs, joblimit); - if (it.current()->m_type[CompletedJobs] > 0) - listJobs(it.currentKey(), CompletedJobs, joblimit); - } - } - m_threadjob->updateManager(this); - removeDiscardedJobs(); - } - return m_jobs; -} - -int KMJobManager::actions() -{ - return 0; -} - -TQValueList<KAction*> KMJobManager::createPluginActions(KActionCollection*) -{ - return TQValueList<KAction*>(); -} - -void KMJobManager::validatePluginActions(KActionCollection*, const TQPtrList<KMJob>&) -{ -} - -void KMJobManager::addPrinter(const TQString& pr, KMJobManager::JobType type, bool isSpecial) -{ - struct JobFilter *jf = m_filter.find(pr); - if (!jf) - { - jf = new JobFilter; - m_filter.insert(pr, jf); - } - jf->m_type[type]++; - jf->m_isspecial = isSpecial; -} - -void KMJobManager::removePrinter(const TQString& pr, KMJobManager::JobType type) -{ - struct JobFilter *jf = m_filter.find(pr); - if (jf) - { - jf->m_type[type] = QMAX(0, jf->m_type[type]-1); - if (!jf->m_type[0] && !jf->m_type[1]) - m_filter.remove(pr); - } -} - -bool KMJobManager::doPluginAction(int, const TQPtrList<KMJob>&) -{ - return true; -} - -void KMJobManager::setLimit(int val) -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("Jobs"); - conf->writeEntry("Limit", val); -} - -int KMJobManager::limit() -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("Jobs"); - return conf->readNumEntry("Limit", 0); -} - -#include "kmjobmanager.moc" diff --git a/kdeprint/kmjobmanager.h b/kdeprint/kmjobmanager.h deleted file mode 100644 index 89cabaa7c..000000000 --- a/kdeprint/kmjobmanager.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMJOBMANAGER_H -#define KMJOBMANAGER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqobject.h> -#include <tqptrlist.h> -#include <tqdict.h> -#include <tqvaluelist.h> - -#include <kdelibs_export.h> - -class KMJob; -class KMThreadJob; -class KActionCollection; -class KAction; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMJobManager : public TQObject -{ - Q_OBJECT - -public: - enum JobType { ActiveJobs = 0, CompletedJobs = 1 }; - struct JobFilter - { - JobFilter() { m_type[0] = m_type[1] = 0; m_isspecial = false; } - int m_type[2]; - bool m_isspecial; - }; - - KMJobManager(TQObject *parent = 0, const char *name = 0); - virtual ~KMJobManager(); - - static KMJobManager* self(); - - void addPrinter(const TQString& pr, JobType type = ActiveJobs, bool isSpecial = false); - void removePrinter(const TQString& pr, JobType type = ActiveJobs); - void clearFilter(); - TQDict<JobFilter>* filter(); - int limit(); - void setLimit(int val); - - //KMJob* findJob(int ID); - KMJob* findJob(const TQString& uri); - //bool sendCommand(int ID, int action, const TQString& arg = TQString::null); - bool sendCommand(const TQString& uri, int action, const TQString& arg = TQString::null); - bool sendCommand(const TQPtrList<KMJob>& jobs, int action, const TQString& arg = TQString::null); - const TQPtrList<KMJob>& jobList(bool reload = true); - void addJob(KMJob*); - KMThreadJob* threadJob(); - - virtual int actions(); - virtual TQValueList<KAction*> createPluginActions(KActionCollection*); - virtual void validatePluginActions(KActionCollection*, const TQPtrList<KMJob>&); - virtual bool doPluginAction(int, const TQPtrList<KMJob>&); - -protected: - void discardAllJobs(); - void removeDiscardedJobs(); - -protected: - virtual bool listJobs(const TQString& prname, JobType type, int limit = 0); - virtual bool sendCommandSystemJob(const TQPtrList<KMJob>& jobs, int action, const TQString& arg = TQString::null); - bool sendCommandThreadJob(const TQPtrList<KMJob>& jobs, int action, const TQString& arg = TQString::null); - -protected: - TQPtrList<KMJob> m_jobs; - TQDict<JobFilter> m_filter; - KMThreadJob *m_threadjob; -}; - -inline TQDict<KMJobManager::JobFilter>* KMJobManager::filter() -{ return &m_filter; } - -inline void KMJobManager::clearFilter() -{ m_filter.clear(); } - -inline KMThreadJob* KMJobManager::threadJob() -{ return m_threadjob; } - -#endif diff --git a/kdeprint/kmmanager.cpp b/kdeprint/kmmanager.cpp deleted file mode 100644 index 01ca0dc77..000000000 --- a/kdeprint/kmmanager.cpp +++ /dev/null @@ -1,556 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmmanager.h" -#include "kmprinter.h" -#include "kmdbentry.h" -#include "kmfactory.h" -#include "kmvirtualmanager.h" -#include "kmspecialmanager.h" -#include "printerfilter.h" -#include "kprinter.h" - -#include <zlib.h> -#include <tqfile.h> -#include <kstandarddirs.h> -#include <kconfig.h> -#include <klocale.h> -#include <kdebug.h> -#include <kapplication.h> -#include <klibloader.h> -#include <unistd.h> - -KMManager::KMManager(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - m_printers.setAutoDelete(true); - m_fprinters.setAutoDelete(false); - m_hasmanagement = false; - m_printeroperationmask = 0; - m_serveroperationmask = 0; - m_printerfilter = new PrinterFilter(this); - - m_specialmgr = new KMSpecialManager(this); - Q_CHECK_PTR(m_specialmgr); - m_virtualmgr = new KMVirtualManager(this); - Q_CHECK_PTR(m_virtualmgr); - - // set default to true to not disturb code that - // hasn't been adapted yet. Otherwise, should be false - m_updatepossible = true; -} - -KMManager::~KMManager() -{ -} - -KMManager* KMManager::self() -{ - return KMFactory::self()->manager(); -} - -bool KMManager::notImplemented() -{ - setErrorMsg(i18n("This operation is not implemented.")); - return false; -} - -bool KMManager::modifyPrinter(KMPrinter *oldp, KMPrinter *newp) -{ - if (oldp->printerName() != newp->printerName()) - { - // remove the old one, then create the new one. But before removing - // the old one, retrieve its driver so that the new printer has the - // same. - DrMain *driver = loadPrinterDriver(oldp, true); - newp->setDriver(driver); - if (!removePrinter(oldp)) - return false; - } - return createPrinter(newp); -} - -bool KMManager::createPrinter(KMPrinter*) -{ - return notImplemented(); -} - -bool KMManager::removePrinter(KMPrinter*) -{ - return notImplemented(); -} - -bool KMManager::removePrinter(const TQString& name) -{ - KMPrinter *p = findPrinter(name); - return (p ? removePrinter(p) : false); -} - -bool KMManager::enablePrinter(KMPrinter*, bool) -{ - return notImplemented(); -} - -bool KMManager::enablePrinter(const TQString& name, bool state) -{ - KMPrinter *p = findPrinter(name); - return (p ? enablePrinter(p, state) : false); -} - -bool KMManager::startPrinter(KMPrinter*, bool) -{ - return notImplemented(); -} - -bool KMManager::startPrinter(const TQString& name, bool state) -{ - KMPrinter *p = findPrinter(name); - return (p ? startPrinter(p, state) : false); -} - -bool KMManager::upPrinter(KMPrinter *p, bool state) -{ - bool result = enablePrinter(p, state); - if (result) - result = startPrinter(p, state); - return result; -} - -bool KMManager::completePrinter(KMPrinter*) -{ - notImplemented(); - return true; // not false to allow instance config/creation -} - -bool KMManager::completePrinterShort(KMPrinter *p) -{ - return completePrinter(p); -} - -bool KMManager::completePrinter(const TQString& name) -{ - KMPrinter *p = findPrinter(name); - return (p ? completePrinter(p) : false); -} - -bool KMManager::setDefaultPrinter(KMPrinter*) -{ - return notImplemented(); -} - -bool KMManager::setDefaultPrinter(const TQString& name) -{ - KMPrinter *p = findPrinter(name); - return (p ? setDefaultPrinter(p) : false); -} - -bool KMManager::testPrinter(KMPrinter *prt) -{ - // standard Test mechanism - TQString testpage = testPage(); - if (testpage.isEmpty()) - { - setErrorMsg(i18n("Unable to locate test page.")); - return false; - } - KPrinter pr; - bool prExist = (findPrinter(prt->printerName()) != 0), result(false); - pr.setPrinterName(prt->printerName()); - pr.setSearchName(prt->name()); - pr.setDocName("KDE Print Test"); - // the printing mechanism may involve some needed operations on the - // printer, so temporary printers (created when testing) should be - // temporarily added to the printer list, then taken out. - if (!prExist) - m_printers.append(prt); - result = pr.printFiles(testpage, false, false); - if (!prExist) - m_printers.take(m_printers.count()-1); - return result; - // return notImplemented(); -} - -KMPrinter* KMManager::findPrinter(const TQString& name) -{ - TQPtrListIterator<KMPrinter> it(m_printers); - for (;it.current();++it) - if (it.current()->name() == name) return it.current(); - //setErrorMsg(i18n("%1: printer not found.").arg(name)); - return 0; -} - -KMPrinter* KMManager::softDefault() const -{ - TQPtrListIterator<KMPrinter> it(m_printers); - for (;it.current();++it) - if (it.current()->isSoftDefault()) return it.current(); - return 0; -} - -KMPrinter* KMManager::hardDefault() const -{ - TQPtrListIterator<KMPrinter> it(m_printers); - for (; it.current();++it) - if (it.current()->isHardDefault()) - return it.current(); - return 0; -} - -KMPrinter* KMManager::defaultPrinter() -{ - printerList(false); - KMPrinter *prt = softDefault(); - if (!prt) - prt = hardDefault(); - return prt; -} - -TQPtrList<KMPrinter>* KMManager::printerList(bool reload) -{ - setErrorMsg(TQString::null); - //kdDebug(500) << "Getting printer list: " << reload << endl; - - if (reload || m_printers.count() == 0) - { - // reset filter - m_printerfilter->update(); - m_fprinters.clear(); - - // first discard all printers - discardAllPrinters(true); - - // make sure virtual printers will be reloaded if we don't have - // any printer (for example if settings are wrong) - if (m_printers.count() == 0) - m_virtualmgr->reset(); - - // List real printers (in subclasses) - if ( m_updatepossible ) - listPrinters(); - // Listing of special printers has to be done before the instances - // because now special printers can also have instances - m_specialmgr->refresh(); - // list virtual printers (and undiscard virtual printers if necessary) - if ( m_updatepossible ) - m_virtualmgr->refresh(); - - // remove discarded printers - for (uint i=0; i<m_printers.count(); i++) - { - KMPrinter *prt = m_printers.tqat(i); - if (prt->isDiscarded()) - { - m_printers.remove(i); - i--; - } - else if (prt->isSpecial() || m_printerfilter->filter(prt)) - m_fprinters.append(prt); - } - - // try to find the default printer from these situations: - // - it already exists from .lpoptions file - // - use the PRINTER variable - if (!softDefault()) - { - KMPrinter *defprinter = findPrinter(TQString::tqfromLatin1(getenv("PRINTER"))); - if (defprinter) - setSoftDefault(defprinter); - } - } - - return &m_fprinters; -} - -TQPtrList<KMPrinter>* KMManager::printerListComplete(bool reload) -{ - printerList(reload); - return &m_printers; -} - -void KMManager::listPrinters() -{ - // do nothing -} - -void KMManager::addPrinter(KMPrinter *p) -{ - if (p) - { - if (p->name().isEmpty()) - // discard printer with empty name - delete p; - else - { - KMPrinter *other = findPrinter(p->name()); - if (other) - { - other->copy(*p); - delete p; - } - else - { - p->setDiscarded(false); - m_printers.inSort(p); - } - } - } -} - -TQString KMManager::driverDbCreationProgram() -{ - return TQString::null; -} - -TQString KMManager::driverDirectory() -{ - return TQString::null; -} - -DrMain* KMManager::loadPrinterDriver(KMPrinter*, bool) -{ - return NULL; -} - -DrMain* KMManager::loadDbDriver(KMDBEntry *entry) -{ - return loadFileDriver(entry->file); -} - -DrMain* KMManager::loadFileDriver(const TQString&) -{ - return NULL; -} - -DrMain* KMManager::loadDriver(KMPrinter *p, bool config) -{ - if (p->isSpecial()) - return m_specialmgr->loadDriver(p); - else - return loadPrinterDriver(p, config); -} - -bool KMManager::savePrinterDriver(KMPrinter*,DrMain*) -{ - return notImplemented(); -} - -bool KMManager::uncompressFile(const TQString& filename, TQString& destname) -{ - TQFile f(filename); - bool result(true); - destname = TQString::null; - if (f.exists() && f.open(IO_ReadOnly)) - { - char buf[1024] = {0}; - f.readBlock(buf,2); - if ((uchar)(buf[0]) == 037 && (uchar)(buf[1]) == 0213) - { - f.close(); - destname = locateLocal("tmp","tdeprint_") + KApplication::randomString(8); - f.setName(destname); - - if (f.open(IO_WriteOnly)) - { - gzFile in = gzopen(filename.latin1(),"r"); - int n(0); - while ((n=gzread(in,buf,1024)) > 0) - if (f.writeBlock(buf,n) != n) - break; - if (n != 0) result = false; - gzclose(in); - f.close(); - } - } - } - return result; -} - -void KMManager::setHardDefault(KMPrinter *p) -{ - TQPtrListIterator<KMPrinter> it(m_printers); - for (;it.current();++it) - it.current()->setHardDefault(false); - if (p) p->setHardDefault(true); -} - -void KMManager::setSoftDefault(KMPrinter *p) -{ - TQPtrListIterator<KMPrinter> it(m_printers); - for (;it.current();++it) - { - it.current()->setSoftDefault(false); - it.current()->setOwnSoftDefault(false); - } - if (p) - { - p->setSoftDefault(true); - KMPrinter *pp = findPrinter(p->printerName()); - if (pp) - pp->setOwnSoftDefault(true); - } -} - -bool KMManager::restartServer() -{ - return notImplemented(); -} - -bool KMManager::configureServer(TQWidget*) -{ - return notImplemented(); -} - -TQString KMManager::testPage() -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("General"); - QString tpage = conf->readPathEntry("TestPage"); - if (tpage.isEmpty()) - tpage = locate("data","tdeprint/testprint.ps"); - return tpage; -} - -void KMManager::discardAllPrinters(bool on) -{ - TQPtrListIterator<KMPrinter> it(m_printers); - for (;it.current();++it) - if (!on || !it.current()->isSpecial()) - it.current()->setDiscarded(on); -} - -bool KMManager::validateDbDriver(KMDBEntry*) -{ - return true; -} - -bool KMManager::createSpecialPrinter(KMPrinter *p) -{ - if (p && p->isSpecial()) - { - KMPrinter *old = findPrinter(p->name()); - if (old && !old->isSpecial()) - { - setErrorMsg(i18n("Can't overwrite regular printer with special printer settings.")); - return false; - } - // if the special printer already exists, it will be overwritten - addPrinter(p); - return m_specialmgr->savePrinters(); - } - return false; -} - -bool KMManager::removeSpecialPrinter(KMPrinter *p) -{ - if (p && p->isSpecial() && m_printers.findRef(p) != -1) - { - m_printers.removeRef(p); - return m_specialmgr->savePrinters(); - } - return false; -} - -/* format of output: - Class0, URI0, Desc0, Printer0, Class1, URI1, Desc1, Printer1, ... - - Defaults to 3 parallel printers -*/ -TQStringList KMManager::detectLocalPrinters() -{ - TQStringList list; - for (int i=0; i<3; i++) - list << TQString() << TQString::tqfromLatin1("parallel:/dev/lp%1").arg(i) << i18n("Parallel Port #%1").arg(i+1) << TQString(); - return list; -} - -int KMManager::addPrinterWizard(TQWidget *parent) -{ - KLibrary *lib = KLibLoader::self()->library("libtdeprint_management_module"); - if (!lib) - setErrorMsg(i18n("Unable to load KDE print management library: %1").arg(KLibLoader::self()->lastErrorMessage())); - else - { - int (*func)(TQWidget*) = (int(*)(TQWidget*))lib->symbol("add_printer_wizard"); - if (!func) - setErrorMsg(i18n("Unable to find wizard object in management library.")); - else - return func(parent); - } - return (-1); -} - -bool KMManager::invokeOptionsDialog(TQWidget *parent) -{ - KLibrary *lib = KLibLoader::self()->library("libtdeprint_management_module"); - if (!lib) - setErrorMsg(i18n("Unable to load KDE print management library: %1").arg(KLibLoader::self()->lastErrorMessage())); - else - { - bool (*func)(TQWidget*) = (bool(*)(TQWidget*))lib->symbol("config_dialog"); - if (!func) - setErrorMsg(i18n("Unable to find options dialog in management library.")); - else - return func(parent); - } - return false; -} - -void KMManager::createPluginActions(KActionCollection*) -{ -} - -void KMManager::validatePluginActions(KActionCollection*, KMPrinter*) -{ -} - -void KMManager::enableFilter(bool on) -{ - m_printerfilter->setEnabled(on); -} - -bool KMManager::isFilterEnabled() const -{ - return m_printerfilter->isEnabled(); -} - -TQString KMManager::stateInformation() -{ - return i18n("No plugin information available"); -} - -void KMManager::checkUpdatePossible() -{ - m_updatepossible = false; - checkUpdatePossibleInternal(); -} - -void KMManager::checkUpdatePossibleInternal() -{ - setUpdatePossible( true ); -} - -void KMManager::setUpdatePossible( bool value ) -{ - if ( value != m_updatepossible ) - m_virtualmgr->reset(); - m_updatepossible = value; - emit updatePossible( m_updatepossible ); -} - -#include "kmmanager.moc" diff --git a/kdeprint/kmmanager.h b/kdeprint/kmmanager.h deleted file mode 100644 index df78adcd3..000000000 --- a/kdeprint/kmmanager.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMMANAGER_H -#define KMMANAGER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tdeprint/kmprinter.h> - -#include <tqobject.h> -#include <tqstring.h> -#include <tqptrlist.h> - -class DrMain; -class KMDBEntry; -class KMVirtualManager; -class KMSpecialManager; -class TQWidget; -class KActionCollection; -class PrinterFilter; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMManager : public TQObject -{ - Q_OBJECT - -friend class KMVirtualManager; -friend class KMSpecialManager; -friend class KMFactory; - -public: - enum PrinterOperations { - PrinterEnabling = 0x01, - PrinterCreation = 0x02, - PrinterDefault = 0x04, - PrinterTesting = 0x08, - PrinterConfigure = 0x10, - PrinterRemoval = 0x20, - PrinterAll = 0xFF - }; - enum ServerOperations { - ServerRestarting = 0x1, - ServerConfigure = 0x2, - ServerAll = 0xF - }; - - KMManager(TQObject *parent = 0, const char *name = 0); - virtual ~KMManager(); - - static KMManager* self(); - - // error management functions - TQString errorMsg() const { return m_errormsg; } - void setErrorMsg(const TQString& s) { m_errormsg = s; } - - // support management ? - bool hasManagement() const { return m_hasmanagement; } - - // printer management functions - virtual bool createPrinter(KMPrinter *p); - virtual bool removePrinter(KMPrinter *p); - virtual bool enablePrinter(KMPrinter *p, bool on); - virtual bool startPrinter(KMPrinter *p, bool on); - virtual bool completePrinter(KMPrinter *p); - virtual bool completePrinterShort(KMPrinter *p); - virtual bool setDefaultPrinter(KMPrinter *p); - virtual bool testPrinter(KMPrinter *p); - bool upPrinter(KMPrinter *p, bool state); - bool modifyPrinter(KMPrinter *oldp, KMPrinter *newp); - bool removePrinter(const TQString& name); - bool enablePrinter(const TQString& name, bool state); - bool startPrinter(const TQString& name, bool state); - bool completePrinter(const TQString& name); - bool setDefaultPrinter(const TQString& name); - int printerOperationMask() const { return m_printeroperationmask; } - int addPrinterWizard(TQWidget *parent = 0); - - // special printer management functions - bool createSpecialPrinter(KMPrinter *p); - bool removeSpecialPrinter(KMPrinter *p); - - // printer listing functions - KMPrinter* findPrinter(const TQString& name); - TQPtrList<KMPrinter>* printerList(bool reload = true); - TQPtrList<KMPrinter>* printerListComplete(bool reload = true); - KMPrinter* defaultPrinter(); - void enableFilter(bool on); - bool isFilterEnabled() const; - - // driver DB functions - virtual TQString driverDbCreationProgram(); - virtual TQString driverDirectory(); - - // driver functions - virtual DrMain* loadPrinterDriver(KMPrinter *p, bool config = false); - virtual DrMain* loadDbDriver(KMDBEntry *entry); - virtual DrMain* loadFileDriver(const TQString& filename); - DrMain* loadDriver(KMPrinter *p, bool config = false); - virtual bool savePrinterDriver(KMPrinter *p, DrMain *d); - virtual bool validateDbDriver(KMDBEntry *entry); - - // configuration functions - bool invokeOptionsDialog(TQWidget *parent = 0); - virtual TQString stateInformation(); - - // server functions - int serverOperationMask() const { return m_serveroperationmask; } - virtual bool restartServer(); - virtual bool configureServer(TQWidget *parent = 0); - virtual TQStringList detectLocalPrinters(); - - // additional actions (for print manager) - virtual void createPluginActions(KActionCollection*); - virtual void validatePluginActions(KActionCollection*, KMPrinter*); - - // utility function - void checkUpdatePossible(); - -signals: - void updatePossible( bool ); - -protected: - // the real printer listing job is done here - virtual void listPrinters(); - - // utility functions - void addPrinter(KMPrinter *p); // in any case, the pointer given MUST not be used after - // calling this function. Useful when listing printers. - void setHardDefault(KMPrinter*); - void setSoftDefault(KMPrinter*); - KMPrinter* softDefault() const; - KMPrinter* hardDefault() const; - // this function uncompress the given file (or does nothing - // if the file is not compressed). Returns wether the file was - // compressed or not. - bool uncompressFile(const TQString& srcname, TQString& destname); - bool notImplemented(); - void setHasManagement(bool on) { m_hasmanagement = on; } - void setPrinterOperationMask(int m) { m_printeroperationmask = m; } - void setServerOperationMask(int m) { m_serveroperationmask = m; } - TQString testPage(); - void discardAllPrinters(bool); - void setUpdatePossible( bool ); - virtual void checkUpdatePossibleInternal(); - -protected: - QString m_errormsg; - KMPrinterList m_printers, m_fprinters; // filtered printers - bool m_hasmanagement; - int m_printeroperationmask; - int m_serveroperationmask; - KMSpecialManager *m_specialmgr; - KMVirtualManager *m_virtualmgr; - PrinterFilter *m_printerfilter; - bool m_updatepossible; -}; - -#endif diff --git a/kdeprint/kmobject.h b/kdeprint/kmobject.h deleted file mode 100644 index 5b9358c49..000000000 --- a/kdeprint/kmobject.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KMOBJECT_H -#define KMOBJECT_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KMObject -{ -public: - KMObject(); - - bool isDiscarded() const; - void setDiscarded(bool on = true); - -protected: - bool m_discarded; -}; - -inline KMObject::KMObject() : m_discarded(false) -{ } - -inline bool KMObject::isDiscarded() const -{ return m_discarded; } - -inline void KMObject::setDiscarded(bool on) -{ m_discarded = on; } - -#endif diff --git a/kdeprint/kmprinter.cpp b/kdeprint/kmprinter.cpp deleted file mode 100644 index b18116ef8..000000000 --- a/kdeprint/kmprinter.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmprinter.h" -#include "kprinter.h" -#include "driver.h" - -#include <klocale.h> -#include <kfiledialog.h> - -KMPrinter::KMPrinter() -: KMObject() -{ - m_type = KMPrinter::Printer; - m_dbentry = 0; - m_harddefault = m_softdefault = m_ownsoftdefault = false; - m_driver = 0; - m_isedited = false; - m_printercap = 0; -} - -KMPrinter::KMPrinter(const KMPrinter& p) -: KMObject() -{ - m_driver = 0; // don't copy driver structure - m_harddefault = m_softdefault = m_ownsoftdefault = false; - m_isedited = false; - copy(p); -} - -KMPrinter::~KMPrinter() -{ - delete m_driver; -} - -void KMPrinter::copy(const KMPrinter& p) -{ - m_name = p.m_name; - m_printername = p.m_printername; - m_instancename = p.m_instancename; - m_type = p.m_type; - m_state = p.m_state; - m_device = p.m_device; - m_members = p.m_members; - m_description = p.m_description; - m_location = p.m_location; - m_manufacturer = p.m_manufacturer; - m_model = p.m_model; - m_uri = p.m_uri; - m_driverinfo = p.m_driverinfo; - m_dbentry = p.m_dbentry; - m_pixmap = p.m_pixmap; - //m_harddefault = p.m_harddefault; - //m_softdefault = p.m_softdefault; - m_options = p.m_options; - m_printercap = p.m_printercap; - setDiscarded(false); -} - -void KMPrinter::setDriver(DrMain *driver) -{ - delete m_driver; - m_driver = driver; -} - -DrMain* KMPrinter::takeDriver() -{ - DrMain *dr = m_driver; - m_driver = 0; - return dr; -} - -TQString KMPrinter::pixmap() -{ - if (!m_pixmap.isEmpty()) return m_pixmap; - - QString str("tdeprint_printer"); - if (!isValid()) str.append("_defect"); - else - { - //if (isHardDefault()) str.append("_default"); - if (isClass(true)) str.append("_class"); - else if (isRemote()) str.append("_remote"); - switch (state()) - { - case KMPrinter::Stopped: - str.append("_stopped"); - break; - case KMPrinter::Processing: - str.append("_process"); - break; - default: - break; - } - } - return str; -} - -int KMPrinter::compare(KMPrinter *p1, KMPrinter *p2) -{ - if (p1 && p2) - { - bool s1(p1->isSpecial()), s2(p2->isSpecial()); - if (s1 && s2) return TQString::compare(p1->name(),p2->name()); - else if (s1) return 1; - else if (s2) return -1; - else - { - bool c1(p1->isClass(false)), c2(p2->isClass(false)); - if (c1 == c2) return TQString::compare(p1->name(),p2->name()); - else if (c1 && !c2) return -1; - else if (!c1 && c2) return 1; - } - } - return 0; -} - -TQString KMPrinter::stateString() const -{ - QString s; - switch (state()) - { - case KMPrinter::Idle: s = i18n("Idle"); break; - case KMPrinter::Processing: s = i18n("Processing..."); break; - case KMPrinter::Stopped: s = i18n("Stopped"); break; - default: return i18n("Unknown State", "Unknown"); - } - s += (" " + (m_state & Rejecting ? i18n("(rejecting jobs)") : i18n("(accepting jobs)"))); - return s; -} - -bool KMPrinter::autoConfigure(KPrinter *printer, TQWidget *parent) -{ - // standard settings - printer->setPrinterName(printerName()); - printer->setSearchName(name()); - // printer default settings (useful for instances) - printer->setOptions(defaultOptions()); - // special printer case: - // - add command - // - ask for output file (if needed) using default extension. - if (isSpecial()) - { - if (option("kde-special-file") == "1") - { - // build-up default filename/directory - TQString fName = printer->docFileName(), ext = option( "kde-special-extension" ); - if ( fName.isEmpty() ) - fName = ( printer->docName() + "." + ext ); - else - { - int p = fName.findRev( '.' ); - if ( p == -1 ) - fName.append( "." ).append( ext ); - else - { - fName.truncate( p+1 ); - fName.append( ext ); - } - } - fName.prepend( "/" ).prepend( printer->docDirectory() ); - - // build-up file dialog - KFileDialog *dialog = new KFileDialog (fName, - TQString::null, - parent, - "filedialog", - true); - dialog->setOperationMode (KFileDialog::Saving); - - QString mimetype = option("kde-special-mimetype"); - - if (!mimetype.isEmpty()) - { - TQStringList filter; - filter << mimetype; - filter << "all/allfiles"; - dialog->setMimeFilter (filter, mimetype); - } - else if (!ext.isEmpty()) - dialog->setFilter ("*." + ext + "\n*|" + i18n ("All Files")); - - if (dialog->exec ()) - { - printer->setOutputToFile(true); - printer->setOutputFileName(dialog->selectedFile ()); - } - else - { - // action canceled - return false; - } - } - printer->setOption( "kde-isspecial", "1" ); - printer->setOption( "kde-special-command", option( "kde-special-command" ) ); - } - - return true; -} - -TQString KMPrinter::deviceProtocol() const -{ - int p = m_device.find( ':' ); - if ( p != -1 ) - return m_device.left( p ); - else - return TQString::null; -} diff --git a/kdeprint/kmprinter.h b/kdeprint/kmprinter.h deleted file mode 100644 index c6c2995e9..000000000 --- a/kdeprint/kmprinter.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPRINTER_H -#define KMPRINTER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqptrlist.h> -#include <kurl.h> -#include <tqmap.h> -#include <tdeprint/kmobject.h> - -class KMDBEntry; -class DrMain; -class KPrinter; -class TQWidget; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMPrinter : public KMObject -{ -public: - enum PrinterType { - Printer = 0x01, - Class = 0x02, - Implicit = 0x04, - Virtual = 0x08, - Remote = 0x10, - Invalid = 0x20, - Special = 0x40 - }; - enum PrinterState { - Idle = 0x01, - Stopped = 0x02, - Processing = 0x03, - Unknown = 0x04, - Rejecting = 0x08, - StateMask = 0x07 - }; - enum PrinterCap { - CapBW = 0x0001, - CapColor = 0x0002, - CapDuplex = 0x0004, - CapStaple = 0x0008, - CapCopies = 0x0010, - CapCollate = 0x0020, - CapPunch = 0x0040, - CapCover = 0x0080, - CapBind = 0x0100, - CapSort = 0x0200, - CapSmall = 0x0400, - CapMedium = 0x0800, - CapLarge = 0x1000, - CapVariable = 0x2000 - }; - - // constructor functions - KMPrinter(); - KMPrinter(const KMPrinter& p); - ~KMPrinter(); - void copy(const KMPrinter& p); - - - // inline access functions - const TQString& name() const { return m_name; } - void setName(const TQString& s) { m_name = s; if (m_printername.isEmpty()) m_printername = s; } - const TQString& printerName() const { return m_printername; } - void setPrinterName(const TQString& s) { m_printername = s; if (m_name.isEmpty()) m_name = s; } - const TQString& instanceName() const { return m_instancename; } - void setInstanceName(const TQString& s) { m_instancename = s; } - int type() const { return m_type; } - void setType(int t) { m_type = t; } - void addType(int t) { m_type |= t; } - PrinterState state(bool complete = false) const { return PrinterState(m_state & (complete ? ~0x0 : StateMask)); } - TQString stateString() const; - void setState(PrinterState s) { m_state = PrinterState((m_state & ~StateMask) | s); } - bool acceptJobs() const { return !(m_state & Rejecting); } - void setAcceptJobs(bool on) { m_state = PrinterState((m_state & StateMask) | (on ? 0 : Rejecting)); } - const TQString& device() const { return m_device; } - TQString deviceProtocol() const; - void setDevice(const TQString& d) { m_device = d; } - const TQStringList& members() const { return m_members; } - void setMembers(const TQStringList& l) { m_members = l; } - void addMember(const TQString& s) { m_members.append(s); } - const TQString& description() const { return m_description; } - void setDescription(const TQString& s) { m_description = s; } - const TQString& location() const { return m_location; } - void setLocation(const TQString& s) { m_location = s; } - const KURL& uri() const { return m_uri; } - void setUri(const KURL& u) { m_uri = u; } - const TQString& manufacturer() const { return m_manufacturer; } - void setManufacturer(const TQString&s ) { m_manufacturer = s; } - const TQString& model() const { return m_model; } - void setModel(const TQString& s) { m_model = s; } - const TQString& driverInfo() const { return m_driverinfo; } - void setDriverInfo(const TQString& s) { m_driverinfo = s; } - int printerCap() const { return m_printercap; } - void setPrinterCap( int c ) { m_printercap = c; } - void addPrinterCap( int c ) { m_printercap |= c; } - - // some useful functions - bool isClass(bool useImplicit = true) const { return ((m_type & KMPrinter::Class) || (useImplicit && isImplicit())); } - bool isImplicit() const { return (m_type & KMPrinter::Implicit); } - bool isPrinter() const { return (m_type & KMPrinter::Printer); } - bool isRemote() const { return (m_type & KMPrinter::Remote); } - bool isLocal() const { return !isRemote(); } - bool isVirtual() const { return (m_type & KMPrinter::Virtual); } - bool isValid() const { return !(m_type & KMPrinter::Invalid); } - bool isSpecial() const { return (m_type & KMPrinter::Special); } - - // misc - KMDBEntry* dbEntry() const { return m_dbentry; } - void setDbEntry(KMDBEntry *e) { m_dbentry = e; } - TQString pixmap(); - void setPixmap(const TQString& s) { m_pixmap = s; } - bool isHardDefault() const { return m_harddefault; } - void setHardDefault(bool on) { m_harddefault = on; } - bool isSoftDefault() const { return m_softdefault; } - void setSoftDefault(bool on) { m_softdefault = on; } - bool ownSoftDefault() const { return m_ownsoftdefault; } - void setOwnSoftDefault(bool on) { m_ownsoftdefault = on; } - static int compare(KMPrinter *p1, KMPrinter *p2); - const TQString& option(const TQString& key) const { return m_options[key]; } - bool hasOption(const TQString& key) const { return m_options.contains(key); } - void setOption(const TQString& key, const TQString& value) { if (!key.isEmpty()) m_options[key] = value; } - void removeOption(const TQString& key) { m_options.remove(key); } - TQMap<TQString,TQString> options() const { return m_options; } - void setOptions(const TQMap<TQString,TQString>& opts) { m_options = opts; } - DrMain* driver() const { return m_driver; } - void setDriver(DrMain*); - DrMain* takeDriver(); - - // configure an existing KPrinter object - bool autoConfigure(KPrinter *prt, TQWidget *parent = 0); - - // default options - const TQString& defaultOption(const TQString& key) const { return m_defaultoptions[key]; } - void setDefaultOption(const TQString& key, const TQString& value) { if (!key.isEmpty()) m_defaultoptions[key] = value; } - TQMap<TQString,TQString> defaultOptions() const { return m_defaultoptions; } - void setDefaultOptions(const TQMap<TQString,TQString>& opts) { m_defaultoptions = opts; } - // edited options - const TQString& editedOption(const TQString& key) const { return m_editedoptions[key]; } - void setEditedOption(const TQString& key, const TQString& value) { if (!key.isEmpty()) m_editedoptions[key] = value; } - TQMap<TQString,TQString> editedOptions() const { return m_editedoptions; } - void setEditedOptions(const TQMap<TQString,TQString>& opts) { m_editedoptions = opts; } - // edited flag - bool isEdited() const { return m_isedited; } - void setEdited(bool on) { m_isedited = on; } - - -protected: - // mandantory information - TQString m_name; // identification name - TQString m_printername; // real printer name - TQString m_instancename; // instance name (human-readable) - int m_type; // printer type (any PrinterType flag OR-ed together) - PrinterState m_state; // printer state - /** - * Represent the device as a string, to provide native - * support for exotic devices. Conversion to URL is done - * only when really needed - */ - TQString m_device; // printer device - - // class specific information - TQStringList m_members; // members of the class - - // other useful information that should be completed by manager on demand - TQString m_description; // short description, comment - TQString m_location; // printer location - KURL m_uri; // URI printer identification - TQString m_manufacturer; // printer manufacturer (driver) - TQString m_model; // printer model (driver) - TQString m_driverinfo; // short driver info (ex: nick name in PPD) - - // DB driver entry (used when creating a printer). Internal use only !!! - KMDBEntry *m_dbentry; - DrMain *m_driver; - TQString m_pixmap; - - // default flags - bool m_harddefault; - bool m_softdefault; - bool m_ownsoftdefault; - - // other options (for any use) - TQMap<TQString,TQString> m_options; - - // options used for instances, and print library. These options are not - // overwritten when copying from another KMPrinter object. This allows to - // to keep the user settings through an application session. The difference - // between "default" and "edited" can be used for option saving (only save - // the options corresponding to current edited printer). - TQMap<TQString,TQString> m_defaultoptions; - TQMap<TQString,TQString> m_editedoptions; - bool m_isedited; - - // printer capabilities (based on CUPS model) - int m_printercap; -}; - -class KMPrinterList : public TQPtrList<KMPrinter> -{ -public: - KMPrinterList() : TQPtrList<KMPrinter>() {} - virtual int compareItems(TQPtrCollection::Item i1, TQPtrCollection::Item i2) - { return KMPrinter::compare((KMPrinter*)i1, (KMPrinter*)i2); } -}; - -#endif diff --git a/kdeprint/kmspecialmanager.cpp b/kdeprint/kmspecialmanager.cpp deleted file mode 100644 index 6da7f4ed7..000000000 --- a/kdeprint/kmspecialmanager.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmspecialmanager.h" -#include "kmmanager.h" -#include "kmprinter.h" -#include "tdeprintcheck.h" -#include "kxmlcommand.h" -#include "driver.h" - -#include <tqfile.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <ksimpleconfig.h> -#include <klocale.h> -#include <kdebug.h> - -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> - -KMSpecialManager::KMSpecialManager(KMManager *parent, const char *name) -: TQObject(parent,name), m_mgr(parent), m_loaded(false) -{ -} - -bool KMSpecialManager::savePrinters() -{ - // for root, use a global location. - QString confname; - if (getuid() == 0) - { - confname = locate("data", "tdeprint/specials.desktop"); - if (confname.startsWith(KGlobal::dirs()->localkdedir())) - { - // seems there's a problem here - m_mgr->setErrorMsg(i18n("A file share/tdeprint/specials.desktop was found in your " - "local KDE directory. This file probably comes from a previous KDE " - "release and should be removed in order to manage global pseudo " - "printers.")); - return false; - } - } - else - confname = locateLocal("data","tdeprint/specials.desktop"); - - KSimpleConfig conf(confname); - - // first clear existing groups - conf.setGroup("General"); - int n = conf.readNumEntry("Number",0); - for (int i=0;i<n;i++) - conf.deleteGroup(TQString::tqfromLatin1("Printer %1").arg(i),true); - - // then add printers - n = 0; - TQPtrListIterator<KMPrinter> it(m_mgr->m_printers); - for (;it.current();++it) - { - if (!it.current()->isSpecial() || it.current()->isVirtual()) continue; - conf.setGroup(TQString::tqfromLatin1("Printer %1").arg(n)); - conf.writeEntry("Name",it.current()->name()); - conf.writeEntry("Description",it.current()->description()); - conf.writeEntry("Comment",it.current()->location()); - conf.writePathEntry("Command",it.current()->option("kde-special-command")); - conf.writePathEntry("File",it.current()->option("kde-special-file")); - conf.writeEntry("Icon",it.current()->pixmap()); - conf.writeEntry("Extension",it.current()->option("kde-special-extension")); - conf.writeEntry("Mimetype",it.current()->option("kde-special-mimetype")); - conf.writeEntry("Require",it.current()->option("kde-special-require")); - n++; - } - conf.setGroup("General"); - conf.writeEntry("Number",n); - - // set read access for anybody in case of global location - if (getuid() == 0) - { - conf.sync(); - ::chmod(TQFile::encodeName(confname), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); - } - - // force reload on next update - m_loaded = false; - - return true; -} - -bool KMSpecialManager::loadPrinters() -{ - if (m_loaded) return true; - - bool result(true); - TQString localDir = KGlobal::dirs()->localkdedir(); - TQStringList files = KGlobal::dirs()->findAllResources("data", "tdeprint/specials.desktop"); - // local files should processed last, so we need to reorder the list - // and put local files at the end - TQStringList orderedFiles; - for (TQStringList::ConstIterator it=files.begin(); it!=files.end(); ++it) - { - if ((*it).startsWith(localDir)) - orderedFiles.append(*it); - else - orderedFiles.prepend(*it); - } - // then parse the ordered list - for (TQStringList::ConstIterator it=orderedFiles.begin(); it!=orderedFiles.end() && result; ++it) - { - // skip the local file for root - if (getuid() == 0 && (*it).startsWith(localDir)) - break; - else - result = loadDesktopFile(*it); - } - - return result; -} - -bool KMSpecialManager::loadDesktopFile(const TQString& filename) -{ - KSimpleConfig conf(filename); - conf.setGroup("General"); - int n = conf.readNumEntry("Number",0); - for (int i=0;i<n;i++) - { - QString grpname = TQString::tqfromLatin1("Printer %1").arg(i); - if (!conf.hasGroup(grpname)) continue; - conf.setGroup(grpname); - KMPrinter *printer = new KMPrinter; - printer->setName(conf.readEntry("Name")); - printer->setPrinterName(printer->name()); - printer->setDescription(conf.readEntry("Description")); - printer->setLocation(conf.readEntry("Comment")); - printer->setOption("kde-special-command",conf.readPathEntry("Command")); - printer->setOption("kde-special-file",conf.readPathEntry("File")); - printer->setOption("kde-special-extension",conf.readEntry("Extension")); - printer->setOption("kde-special-mimetype",conf.readEntry("Mimetype")); - printer->setOption("kde-special-require",conf.readEntry("Require")); - printer->setPixmap(conf.readEntry("Icon","unknown")); - printer->setType(KMPrinter::Special); - if ( !KdeprintChecker::check( &conf ) || - !KXmlCommandManager::self()->checkCommand( printer->option( "kde-special-command" ), - KXmlCommandManager::None, KXmlCommandManager::None, 0 ) ) - printer->addType(KMPrinter::Invalid); - printer->setState(KMPrinter::Idle); - printer->setAcceptJobs(true); - m_mgr->addPrinter(printer); - } - - return true; -} - -void KMSpecialManager::refresh() -{ - if (!m_loaded) - loadPrinters(); - else - { - TQPtrListIterator<KMPrinter> it(m_mgr->m_printers); - for (;it.current();++it) - if (it.current()->isSpecial()) - { - it.current()->setDiscarded(false); - it.current()->setType(KMPrinter::Special); - if (KdeprintChecker::check(TQStringList::split(',',it.current()->option("kde-special-require"),false))) - it.current()->addType(KMPrinter::Invalid); - } - } -} - -KXmlCommand* KMSpecialManager::loadCommand(KMPrinter *pr) -{ - KXmlCommand *xmlCmd = loadCommand(pr->option("kde-special-command")); - if (xmlCmd && xmlCmd->driver()) - xmlCmd->driver()->set("text", pr->printerName()); - return xmlCmd; -} - -KXmlCommand* KMSpecialManager::loadCommand(const TQString& xmlId) -{ - return KXmlCommandManager::self()->loadCommand(xmlId, true); -} - -DrMain* KMSpecialManager::loadDriver(KMPrinter *pr) -{ - KXmlCommand *xmlCmd; - DrMain *driver(0); - - if ((xmlCmd=loadCommand(pr)) != 0) - { - driver = xmlCmd->takeDriver(); - delete xmlCmd; - } - - return driver; -} - -TQString KMSpecialManager::setupCommand(const TQString& cmd, const TQMap<TQString,TQString>& opts) -{ - QString s(cmd); - if (!s.isEmpty()) - { - KXmlCommand *xmlCmd = loadCommand(cmd); - if (xmlCmd) - { - s = xmlCmd->buildCommand(opts, false, false); - delete xmlCmd; - } - } - - return s; -} diff --git a/kdeprint/kmspecialmanager.h b/kdeprint/kmspecialmanager.h deleted file mode 100644 index b42aea1df..000000000 --- a/kdeprint/kmspecialmanager.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMSPECIALMANAGER_H -#define KMSPECIALMANAGER_H - -#include <tqobject.h> -#include <tqmap.h> - -class KMPrinter; -class KMManager; -class KXmlCommand; -class DrMain; - -class KMSpecialManager : public TQObject -{ -public: - KMSpecialManager(KMManager *parent, const char *name = 0); - - bool loadPrinters(); - bool savePrinters(); - void refresh(); - KXmlCommand* loadCommand(KMPrinter*); - KXmlCommand* loadCommand(const TQString& cmd); - DrMain* loadDriver(KMPrinter*); - TQString setupCommand(const TQString& cmd, const TQMap<TQString,TQString>& opts); - -protected: - bool loadDesktopFile(const TQString&); - -private: - KMManager *m_mgr; - bool m_loaded; -}; - -#endif diff --git a/kdeprint/kmthreadjob.cpp b/kdeprint/kmthreadjob.cpp deleted file mode 100644 index fcee4877f..000000000 --- a/kdeprint/kmthreadjob.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmthreadjob.h" -#include "kmjob.h" -#include "kmjobmanager.h" - -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqstringlist.h> -#include <kstandarddirs.h> - -#include <errno.h> -#include <sys/types.h> -#include <signal.h> - -#define CHARSEP '$' - -KMThreadJob::KMThreadJob(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - m_jobs.setAutoDelete(true); -} - -KMThreadJob::~KMThreadJob() -{ -} - -TQString KMThreadJob::jobFile() -{ - QString f = locateLocal("data","tdeprint/printjobs"); - return f; -} - -bool KMThreadJob::saveJobs() -{ - TQFile f(jobFile()); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - TQIntDictIterator<KMJob> it(m_jobs); - for (;it.current();++it) - t << it.current()->id() << CHARSEP << it.current()->name() << CHARSEP << it.current()->printer() << CHARSEP << it.current()->owner() << CHARSEP << it.current()->size() << endl; - return true; - } - return false; -} - -bool KMThreadJob::loadJobs() -{ - TQFile f(jobFile()); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - - m_jobs.clear(); - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) - continue; - QStringList ll = TQStringList::split(CHARSEP,line,true); - if (ll.count() == 5) - { - KMJob *job = new KMJob(); - job->setId(ll[0].toInt()); - job->setName(ll[1]); - job->setPrinter(ll[2]); - job->setOwner(ll[3]); - job->setSize(ll[4].toInt()); - job->setState(KMJob::Printing); - job->setType(KMJob::Threaded); - job->setUri("proc:/"+ll[0]); - if (job->id() > 0 && checkJob(job->id())) - m_jobs.insert(job->id(),job); - else - delete job; - } - } - return true; - } - return false; -} - -bool KMThreadJob::checkJob(int ID) -{ - return (kill((pid_t)ID,0) == 0 || errno == EPERM); -} - -KMJob* KMThreadJob::findJob(int ID) -{ - return m_jobs.find(ID); -} - -KMJob* KMThreadJob::findJob(const TQString& uri) -{ - if (uri.startsWith("proc:/")) - { - int pid = uri.mid(6).toInt(); - if (pid > 0) - return m_jobs.find(pid); - } - return NULL; -} - -bool KMThreadJob::removeJob(int ID) -{ - if (!checkJob(ID) || kill((pid_t)ID, SIGTERM) == 0) - { - m_jobs.remove(ID); - saveJobs(); - return true; - } - else - return false; -} - -void KMThreadJob::createJob(int ID, const TQString& printer, const TQString& name, const TQString& owner, int size) -{ - KMThreadJob mth(0); - KMJob *job = new KMJob(); - job->setId(ID); - job->setPrinter(printer); - job->setName(name); - job->setOwner(owner); - job->setSize(size); - job->setType(KMJob::Threaded); - mth.createJob(job); -} - -void KMThreadJob::createJob(KMJob *job) -{ - if (job->id() > 0) - { - loadJobs(); - if (!m_jobs.find(job->id())) - { - m_jobs.insert(job->id(),job); - saveJobs(); - } - } -} - -void KMThreadJob::updateManager(KMJobManager *mgr) -{ - loadJobs(); - TQIntDictIterator<KMJob> it(m_jobs); - for (;it.current();++it) - { - KMJob *job = new KMJob(*(it.current())); - mgr->addJob(job); - } -} diff --git a/kdeprint/kmthreadjob.h b/kdeprint/kmthreadjob.h deleted file mode 100644 index 5bded6274..000000000 --- a/kdeprint/kmthreadjob.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMTHREADJOB_H -#define KMTHREADJOB_H - -#include <tqintdict.h> -#include <tqobject.h> - -class KMJob; -class KMJobManager; - -class KMThreadJob : public TQObject -{ -public: - KMThreadJob(TQObject *parent = 0, const char *name = 0); - ~KMThreadJob(); - - KMJob* findJob(int ID); - KMJob* findJob(const TQString& uri); - bool removeJob(int ID); - void createJob(KMJob*); - void updateManager(KMJobManager*); - - static void createJob(int ID, const TQString& printer, const TQString& name = TQString::null, const TQString& owner = TQString::null, int size = 0); - -protected: - TQString jobFile(); - bool loadJobs(); - bool saveJobs(); - bool checkJob(int ID); - -private: - TQIntDict<KMJob> m_jobs; -}; - -#endif diff --git a/kdeprint/kmuimanager.cpp b/kdeprint/kmuimanager.cpp deleted file mode 100644 index 962653dd2..000000000 --- a/kdeprint/kmuimanager.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmuimanager.h" -#include "kprintdialog.h" -#include "kprintdialogpage.h" -#include "kpcopiespage.h" -#include "kprinter.h" -#include "kprinterpropertydialog.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmprinter.h" -#include "kpdriverpage.h" -#include "kpmarginpage.h" -#include "kpqtpage.h" -#include "kpfilterpage.h" -#include "kpfileselectpage.h" -#include "kxmlcommand.h" -#include "kpposterpage.h" - -#include <klocale.h> -#include <kdebug.h> - -KMUiManager::KMUiManager(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - m_printdialogflags = KMUiManager::PrintDialogAll; - m_printdialogpages.setAutoDelete(false); -} - -KMUiManager::~KMUiManager() -{ -} - -void KMUiManager::setupPropertyPages(KMPropertyPage*) -{ -} - -void KMUiManager::setupWizard(KMWizard*) -{ -} - -void KMUiManager::setupConfigDialog(KMConfigDialog*) -{ -} - -int KMUiManager::copyFlags(KPrinter *pr, bool usePlugin) -{ - int fl(0), pcap(pluginPageCap()); - if (KMFactory::self()->settings()->pageSelection == KPrinter::ApplicationSide) - { - if (pr) - { - if (pr->currentPage() > 0) fl |= Current; - if (pr->minPage() > 0 && pr->maxPage() > 0) - fl |= (Range|PageSet|Order); - } - //else fl = CopyAll; - if (usePlugin) - fl |= (pcap & (Collate|NoAutoCollate)); - else - fl |= NoAutoCollate; - } - else if (usePlugin) - // in this case, we want page capabilities with plugin, it means - // for a regular real printer. - fl = pageCap(); - else - // int this case, we want page capabilities for non standard - // printer, set auto-collate to false as copies will be handled - // by Qt - fl = systemPageCap() | NoAutoCollate; - return fl; -} - -int KMUiManager::dialogFlags() -{ - int f = m_printdialogflags; - int appf = KMFactory::self()->settings()->application; - if (appf != KPrinter::Dialog) - { - f &= ~(KMUiManager::Preview); - if ( appf == KPrinter::StandAlonePersistent) - f |= KMUiManager::Persistent; - } - return f; -} - -void KMUiManager::setupPrintDialog(KPrintDialog *dlg) -{ - // dialog flags - int f = dialogFlags(); - dlg->setFlags(f); - - // add standard dialog pages - int stdpages = KMFactory::self()->settings()->standardDialogPages; - if (stdpages & KPrinter::CopiesPage) - m_printdialogpages.prepend(new KPCopiesPage(dlg->printer(), 0, "CopiesPage")); - if (stdpages & KPrinter::FilesPage) - m_printdialogpages.prepend(new KPFileSelectPage(0, "FileSelectPage")); - - // add plugins pages - setupPrintDialogPages(&m_printdialogpages); - - dlg->setDialogPages(&m_printdialogpages); -} - -void KMUiManager::setupPropertyDialog(KPrinterPropertyDialog *dlg) -{ - if (dlg->printer()) - { - DrMain *driver = KMManager::self()->loadDriver(dlg->printer(), false); - dlg->setDriver(driver); - - if (dlg->printer()->isSpecial()) - { // special case - dlg->addPage(new KPQtPage(dlg,"QtPage")); - //dlg->enableSaveButton(false); - } - else - { - // add pages specific to print system - setupPrinterPropertyDialog(dlg); - } - - // retrieve the KPrinter object - KPrinter *prt(0); - if (dlg->parent() && dlg->parent()->isA("KPrintDialog")) - prt = static_cast<KPrintDialog*>(TQT_TQWIDGET(dlg->parent()))->printer(); - - // add margin page - if ( ( prt && !prt->fullPage() && prt->applicationType() == KPrinter::Dialog ) - || prt->applicationType() < 0 ) - dlg->addPage(new KPMarginPage(prt, driver, dlg, "MarginPage")); - - // add driver page - if (driver) - dlg->addPage(new KPDriverPage(dlg->printer(),driver,dlg,"DriverPage")); - - dlg->setCaption(i18n("Configuration of %1").arg(dlg->printer()->name())); - if ( KXmlCommandManager::self()->checkCommand( "poster", KXmlCommandManager::None, KXmlCommandManager::None ) ) - dlg->addPage( new KPPosterPage( dlg, "PosterPage" ) ); - dlg->addPage(new KPFilterPage(dlg,"FilterPage")); - dlg->resize(100,100); - } -} - -void KMUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg) -{ - if (KMFactory::self()->settings()->application == KPrinter::Dialog - || KMFactory::self()->settings()->application < 0 ) - dlg->addPage(new KPQtPage(dlg,"QtPage")); -} - -int KMUiManager::pageCap() -{ - int val = systemPageCap(); - val |= pluginPageCap(); - return val; -} - -int KMUiManager::systemPageCap() -{ - int val(0); - if (KXmlCommandManager::self()->checkCommand("psselect")) - val |= KMUiManager::PSSelect; - return val; -} - -int KMUiManager::pluginPageCap() -{ - return 0; -} - -void KMUiManager::setupPrintDialogPages(TQPtrList<KPrintDialogPage>*) -{ -} - -void KMUiManager::setupJobViewer(TQListView*) -{ -} - -#include "kmuimanager.moc" diff --git a/kdeprint/kmuimanager.h b/kdeprint/kmuimanager.h deleted file mode 100644 index 248ad4ed7..000000000 --- a/kdeprint/kmuimanager.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMUIMANAGER_H -#define KMUIMANAGER_H - -#include <tqobject.h> -#include <tqptrlist.h> - -#include "kprinter.h" - -class KMPropertyPage; -class KMWizard; -class KPrintDialogPage; -class KPrintDialog; -class KPrinterPropertyDialog; -class KMConfigDialog; -class TQListView; - -class KDEPRINT_EXPORT KMUiManager : public TQObject -{ - Q_OBJECT -public: - enum PrintDialogFlagType - { - Properties = 0x0001, - Default = 0x0002, - Preview = 0x0004, - OutputToFile = 0x0008, - PrintCommand = 0x0020, - Persistent = 0x0040, - PrintDialogAll = 0x001F - }; - enum CopyFlagType - { - Current = 0x001, - Range = 0x002, - Collate = 0x004, - Order = 0x008, - PageSet = 0x010, - CopyAll = 0x0FF, - PSSelect = Range|Order|PageSet, - NoAutoCollate = 0x100 - }; - - KMUiManager(TQObject *parent = 0, const char *name = 0); - virtual ~KMUiManager(); - - // print management - virtual void setupPropertyPages(KMPropertyPage*); - virtual void setupWizard(KMWizard*); - virtual void setupConfigDialog(KMConfigDialog*); - - // print dialog - void addPrintDialogPage(KPrintDialogPage *page) { m_printdialogpages.append(page); } - int copyFlags(KPrinter *pr = 0, bool usePlugin = true); - int dialogFlags(); - void setupPrintDialog(KPrintDialog*); - virtual void setupPrintDialogPages(TQPtrList<KPrintDialogPage>*); - - // printer property dialog - void setupPropertyDialog(KPrinterPropertyDialog*); - virtual void setupPrinterPropertyDialog(KPrinterPropertyDialog*); - - // page processing capabilities - int systemPageCap(); - virtual int pluginPageCap(); - int pageCap(); - - // job management - virtual void setupJobViewer(TQListView*); - -protected: - int m_printdialogflags; - TQPtrList<KPrintDialogPage> m_printdialogpages; -}; - -#endif diff --git a/kdeprint/kmvirtualmanager.cpp b/kdeprint/kmvirtualmanager.cpp deleted file mode 100644 index 78757decd..000000000 --- a/kdeprint/kmvirtualmanager.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmvirtualmanager.h" -#include "kmprinter.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kprinter.h" - -#include <stdlib.h> -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqdir.h> -#include <tqfileinfo.h> -#include <klocale.h> -#include <kstandarddirs.h> -#include <kurl.h> -#include <kdebug.h> -#include <kmessagebox.h> - -#include <unistd.h> - -static TQString instanceName(const TQString& prname, const TQString& instname) -{ - QString str(prname); - if (!instname.isEmpty()) - str.append("/"+instname); - return str; -} - -KMVirtualManager::KMVirtualManager(KMManager *parent, const char *name) -: TQObject(parent,name), m_manager(parent) -{ -} - -KMVirtualManager::~KMVirtualManager() -{ -} - -KMPrinter* KMVirtualManager::findPrinter(const TQString& name) -{ - return m_manager->findPrinter(name); -} - -KMPrinter* KMVirtualManager::findInstance(KMPrinter *p, const TQString& name) -{ - QString instname(instanceName(p->printerName(),name)); - return findPrinter(instname); -} - -void KMVirtualManager::addPrinter(KMPrinter *p) -{ - if (p && p->isValid()) - { - KMPrinter *other = findPrinter(p->name()); - if (other) - { - other->copy(*p); - // Replace default options with the new loaded ones: this is needed - // if we want to handle 2 lpoptions correctly (system-wide and local). - // Anyway, the virtual printers will be reloaded only if something has - // changed in one of the files, so it's better to reset everything, to - // be sure to use the new changes. Edited options will be left unchanged. - other->setDefaultOptions(p->defaultOptions()); - delete p; - } - else - m_manager->addPrinter(p); - } - else - delete p; -} - -void KMVirtualManager::setDefault(KMPrinter *p, bool saveflag) -{ - m_manager->setSoftDefault(p); - m_defaultprinter = (p ? p->printerName() : TQString::null); - if (saveflag) triggerSave(); -} - -bool KMVirtualManager::isDefault(KMPrinter *p, const TQString& name) -{ - QString instname(instanceName(p->printerName(),name)); - KMPrinter *printer = findPrinter(instname); - if (printer) - return printer->isSoftDefault(); - else - return false; -} - -void KMVirtualManager::create(KMPrinter *p, const TQString& name) -{ - QString instname = instanceName(p->printerName(),name); - if (findPrinter(instname) != NULL) return; - KMPrinter *printer = new KMPrinter; - printer->setName(instname); - printer->setPrinterName(p->printerName()); - printer->setInstanceName(name); - if (!name.isEmpty()) - printer->setType(p->type()|KMPrinter::Virtual); - // we need some options to know how to load the driver - if (p->isSpecial()) - printer->setOptions(p->options()); - m_manager->addPrinter(printer); - triggerSave(); -} - -void KMVirtualManager::copy(KMPrinter *p, const TQString& src, const TQString& name) -{ - QString instsrc(instanceName(p->printerName(),src)), instname(instanceName(p->printerName(),name)); - KMPrinter *prsrc = findPrinter(instsrc); - if (!prsrc || findPrinter(instname) != NULL) return; - KMPrinter *printer = new KMPrinter; - printer->copy(*prsrc); - printer->setName(instname); - printer->setInstanceName(name); - printer->setDefaultOptions(prsrc->defaultOptions()); - m_manager->addPrinter(printer); - triggerSave(); -} - -void KMVirtualManager::remove(KMPrinter *p, const TQString& name) -{ - QString instname = instanceName(p->printerName(),name); - KMPrinter *printer = findPrinter(instname); - if (!printer) return; - if (name.isEmpty()) - { // remove default instance => only remove options, keep the KMPrinter object - printer->setDefaultOptions(TQMap<TQString,TQString>()); - printer->setEditedOptions(TQMap<TQString,TQString>()); - printer->setEdited(false); - } - else - m_manager->m_printers.removeRef(printer); - triggerSave(); -} - -void KMVirtualManager::setAsDefault(KMPrinter *p, const TQString& name, TQWidget *parent) -{ - QString instname(instanceName(p->printerName(),name)); - - if ( p->isSpecial() ) - { - if ( KMessageBox::warningContinueCancel( parent, - i18n( "<qt>You are about to set a pseudo-printer as your personal default. " - "This setting is specific to KDE and will not be available outside KDE " - "applications. Note that this will only make your personal default printer " - "as undefined for non-KDE applications and should not prevent you from " - "printing normally. Do you really want to set <b>%1</b> as your personal default?</qt>" ).arg( instname ), - TQString::null, i18n("Set as Default"), "setSpecialAsDefault" ) == KMessageBox::No ) - return; - } - - KMPrinter *printer = findPrinter(instname); - if (!printer) - { // create it if necessary - create(p,name); - printer = findPrinter(instname); - } - if (printer) - setDefault(printer,true); -} - -void KMVirtualManager::refresh() -{ - TQFileInfo fi(TQDir::homeDirPath() + TQFile::decodeName("/.cups/lpoptions")); - TQFileInfo fi2(TQFile::decodeName("/etc/cups/lpoptions")); - - // if root, then only use global file: trick -> use twice the same file - if (getuid() == 0) - fi.setFile(fi2.absFilePath()); - - if (!m_checktime.isValid() || m_checktime < QMAX(fi.lastModified(),fi2.lastModified())) - { - m_defaultprinter = TQString::null; - if (fi2.exists()) - loadFile(fi2.absFilePath()); - if (fi.exists() && fi.absFilePath() != fi2.absFilePath()) - loadFile(fi.absFilePath()); - m_checktime = QMAX(fi.lastModified(),fi2.lastModified()); - } - else - { // parse printers looking for instances -> undiscarded them, real printers - // are undiscarded by the manager itself. Also update printer status. - TQPtrListIterator<KMPrinter> it(m_manager->m_printers); - for (;it.current();++it) - if (!it.current()->instanceName().isEmpty()) - { - checkPrinter(it.current()); - if (it.current()->isValid()) it.current()->setDiscarded(false); - } - } -} - -void KMVirtualManager::checkPrinter(KMPrinter *p) -{ - KMPrinter *realprinter = m_manager->findPrinter(p->printerName()); - if (!realprinter || realprinter->isDiscarded()) - { - p->setType(KMPrinter::Invalid); - p->setState(KMPrinter::Unknown); - } - else - { - if (!p->instanceName().isEmpty()) - p->setType(realprinter->type()|KMPrinter::Virtual); - p->setState(realprinter->state()); - } -} - -TQString KMVirtualManager::defaultPrinterName() -{ - return m_defaultprinter; -} - -void KMVirtualManager::virtualList(TQPtrList<KMPrinter>& list, const TQString& prname) -{ - // load printers if necessary - refresh(); - - // then look for instances - list.setAutoDelete(false); - list.clear(); - kdDebug(500) << "KMVirtualManager::virtualList() prname=" << prname << endl; - TQPtrListIterator<KMPrinter> it(m_manager->m_printers); - for (;it.current();++it) - if (it.current()->printerName() == prname) - list.append(it.current()); -} - -void KMVirtualManager::loadFile(const TQString& filename) -{ - TQFile f(filename); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - - TQString line; - TQStringList words; - TQStringList pair; - KMPrinter *printer, *realprinter; - - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) continue; - words = TQStringList::split(' ',line,false); - if (words.count() < 2) continue; - pair = TQStringList::split('/',words[1],false); - realprinter = m_manager->findPrinter(KURL::decode_string(pair[0])); - if (realprinter && !realprinter->isDiscarded()) - { // keep only instances corresponding to an existing and - // non discarded printer. - // "clone" the real printer and modify settings as needed - printer = new KMPrinter(*realprinter); - printer->setName(KURL::decode_string(words[1])); - printer->setPrinterName(KURL::decode_string(pair[0])); - if (pair.count() > 1) - { - printer->setInstanceName(KURL::decode_string(pair[1])); - printer->addType(KMPrinter::Virtual); - } - // parse options - for (uint i=2; i<words.count(); i++) - { - pair = TQStringList::split('=',words[i],false); - printer->setDefaultOption(pair[0],(pair.count() > 1 ? pair[1] : TQString::null)); - } - // add printer to the manager - addPrinter(printer); // don't use "printer" after this point !!! - // check default state - if (words[0].lower().startsWith("default")) - setDefault(findPrinter(KURL::decode_string(words[1])),false); - } - } - } -} - -void KMVirtualManager::triggerSave() -{ - QString filename; - if (getuid() == 0) - { - if (KStandardDirs::makeDir(TQFile::decodeName("/etc/cups"))) - filename = TQFile::decodeName("/etc/cups/lpoptions"); - } - else - { - TQDir cupsDir(TQDir::home().absPath()+"/.cups"); - if (!cupsDir.exists()) - cupsDir.mkdir(TQDir::home().absPath()+"/.cups"); - filename = TQDir::homeDirPath() + TQFile::decodeName("/.cups/lpoptions"); - } - - if (!filename.isEmpty()) - { - saveFile(filename); - m_checktime = TQFileInfo(filename).lastModified(); - } -} - -void KMVirtualManager::saveFile(const TQString& filename) -{ - TQFile f(filename); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - TQPtrListIterator<KMPrinter> it(m_manager->m_printers); - for (;it.current();++it) - { - if (it.current()->isSpecial()) - { - t << ( it.current()->isSoftDefault() ? "DefaultSpecial " : "Special " ); - t << KURL::encode_string_no_slash( it.current()->printerName() ); - if ( !it.current()->instanceName().isEmpty() ) - t << "/" << KURL::encode_string_no_slash( it.current()->instanceName() ); - } - else - t << (it.current()->isSoftDefault() ? "Default " : "Dest ") << it.current()->name(); - TQMap<TQString,TQString> opts = it.current()->defaultOptions(); - for (TQMap<TQString,TQString>::ConstIterator oit=opts.begin(); oit!=opts.end(); ++oit) - { - t << ' ' << oit.key(); - if (!oit.data().isEmpty()) - t << '=' << oit.data(); - } - t << endl; - } - } -} - -bool KMVirtualManager::testInstance(KMPrinter *p) -{ - TQString testpage = KMManager::self()->testPage(); - if (testpage.isEmpty()) - return false; - else - { - KPrinter pr; - pr.setPrinterName(p->printerName()); - pr.setSearchName(p->name()); - pr.setOptions(p->defaultOptions()); - return (pr.printFiles(testpage)); - } -} - -void KMVirtualManager::reload() -{ - reset(); -} - -void KMVirtualManager::configChanged() -{ - reset(); -} diff --git a/kdeprint/kmvirtualmanager.h b/kdeprint/kmvirtualmanager.h deleted file mode 100644 index 1b7ab4867..000000000 --- a/kdeprint/kmvirtualmanager.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMVIRTUALMANAGER_H -#define KMVIRTUALMANAGER_H - -#include <tqobject.h> -#include <tqptrlist.h> -#include <tqdatetime.h> - -#include <kdelibs_export.h> - -#include "kpreloadobject.h" - -class KMPrinter; -class KMManager; -class TQWidget; - -class KDEPRINT_EXPORT KMVirtualManager : public TQObject, public KPReloadObject -{ -public: - KMVirtualManager(KMManager *parent = 0, const char *name = 0); - ~KMVirtualManager(); - - void refresh(); - void reset(); - void virtualList(TQPtrList<KMPrinter>& list, const TQString& prname); - void triggerSave(); - - KMPrinter* findPrinter(const TQString& name); - KMPrinter* findInstance(KMPrinter *p, const TQString& name); - void setDefault(KMPrinter *p, bool save = true); - TQString defaultPrinterName(); - bool isDefault(KMPrinter *p, const TQString& name); - bool testInstance(KMPrinter *p); - - void create(KMPrinter *p, const TQString& name); - void remove(KMPrinter *p, const TQString& name); - void copy(KMPrinter *p, const TQString& src, const TQString& name); - void setAsDefault(KMPrinter *p, const TQString& name, TQWidget *parent = NULL); - -protected: - void loadFile(const TQString& filename); - void saveFile(const TQString& filename); - void addPrinter(KMPrinter *p); - void checkPrinter(KMPrinter*); - void reload(); - void configChanged(); - -private: - KMManager *m_manager; - QDateTime m_checktime; - TQString m_defaultprinter; -}; - -inline void KMVirtualManager::reset() -{ m_checktime = TQDateTime(); } - -#endif diff --git a/kdeprint/kpcopiespage.cpp b/kdeprint/kpcopiespage.cpp deleted file mode 100644 index bc0e03e0d..000000000 --- a/kdeprint/kpcopiespage.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpcopiespage.h" -#include "kmfactory.h" -#include "kmuimanager.h" -#include "kprinter.h" -#include "kxmlcommand.h" - -#include <tqlabel.h> -#include <tqcombobox.h> -#include <tqspinbox.h> -#include <tqbuttongroup.h> -#include <tqradiobutton.h> -#include <tqlineedit.h> -#include <tqcheckbox.h> -#include <tqtooltip.h> -#include <tqwhatsthis.h> -#include <tqlayout.h> - -#include <kapplication.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kseparator.h> - -KPCopiesPage::KPCopiesPage(KPrinter *prt, TQWidget *parent, const char *name) -: KPrintDialogPage(parent,name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisPageSelectionLabel = i18n( " <qt><p><b>Page Selection</b></p> " - " <p>Here you can control if you print a certain selection only out of all" - " the pages from the complete document." - " </p>" - " </qt>" ); - TQString whatsThisAllPagesLabel = i18n( " <qt><b>All Pages:</b> Select \"All\" to print the complete document." - " Since this is the default, it is pre-selected." - " </p>" - " </qt>" ); - TQString whatsThisCurrentPagesLabel = i18n( " <qt><b>Current Page:</b> Select <em>\"Current\"</em> if you want " - " to print the page currently visible in your KDE application.</p>" - " <p><b>Note:</b> this field is disabled if you print from" - " non-KDE applications like Mozilla or OpenOffice.org, since here KDEPrint has no" - " means to determine which document page you are currently viewing.</p></qt>" ); - TQString whatsThisPageRangeLabel = i18n( " <qt><b>Page Range:</b> Choose a \"Page Range\" to select a subset of the" - " complete document pages" - " to be printed. The format is <em>\"n,m,o-p,q,r,s-t, u\"</em>.</p>" - " <p><b>Example:</b> <em>\"4,6,10-13,17,20,23-25\"</em> will print" - " the pages 4, 6, 10, 11, 12, 13, 17, 20, 23, 24, 25 of your document.</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-ranges=... # example: \"4,6,10-13,17,20,23-25\" " - " </pre>" - " </p> " - "</qt>" ); - TQString whatsThisPageSetLabel = i18n( " <qt><b>Page Set:</b>" - " <p>Choose <em>\"All Pages\"</em>, <em>\"Even Pages\"</em> or" - " <em>\"Odd Pages\"</em>" - " if you want to print a page selection matching one of these terms. The default" - " is <em>\"All Pages\"</em>.</p>" - " <p><b>Note:</b> If you combine a selection of a <em>\"Page Range\"</em> with a" - " <em>\"Page Set\"</em> of <em>\"Odd\"</em> or <em>\"Even\"</em>, you will only get the" - " odd or even pages from the originally selected page range. This is useful if you" - " odd or even pages from the originally selected page range. This is useful if you" - " want to print a page range in duplex on a simplex-only printer. In this case you" - " can feed the paper to the printer twice; in the first pass, select \"Odd\" or" - " \"Even\" (depending on your printer model), in second pass select the other" - " option. You may need to <em>\"Reverse\"</em> the output in one of the passes (depending" - " on your printer model).</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-set=... # example: \"odd\" or \"even\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisCopiesLabel = i18n( " <qt><b>Output Settings:</b>" - " Here you can determine the number of copies, the output order and the collate" - " mode for the pages of your printjob. (Note, that the maximum number of copies " - " allowed to print may be restricted by your print subsystem.)</p>" - " <p>The 'Copies' setting defaults to 1. </p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o copies=... # examples: \"5\" or \"42\" " - " <br> " - " -o outputorder=... # example: \"reverse\"" - " <br> " - " -o Collate=... # example: \"true\" or \"false\" " - " </pre>" - " </p> " - ".</qt>" ); - TQString whatsThisNumberOfCopiesLabel = i18n( " <qt><b>Number of Copies:</b> Determine the number of requested copies here." - " You can increase or decrease" - " the number of printed copies by clicking on the up and down arrows. You can also type the figure" - " directly into the box. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o copies=... # examples: \"5\" or \"42\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisCollateLabel = i18n( " <qt><b>Collate Copies</b>" - " <p>If the <em>\"Collate\"</em> checkbox is enabled (default), the output order for" - " multiple copies of a multi-page document will be \"1-2-3-..., 1-2-3-..., 1-2-3-...\".</p>" - " <p>If the <em>\"Collate\"</em> checkbox is disabled, the output order for" - " multiple copies of a multi-page document will be \"1-1-1-..., 2-2-2-..., 3-3-3-...\".</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o Collate=... # example: \"true\" or \"false\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisReverseLabel = i18n( " <qt><b>Reverse Order</b>" - " <p> If the <em>\"Reverse\"</em> checkbox is enabled, the output order for" - " multiple copies of a multi-page document will be \"...-3-2-1, ...-3-2-1, ...-3-2-1\", if you" - " also have <em>en</em>abled the <em>\"Collate\"</em> checkbox at the same time" - " (the usual usecase).</p>" - " <p>If the <em>\"Reverse\"</em> checkbox is enabled, the output order for" - " multiple copies of a multi-page document will be \"...-3-3-3, ...-2-2-2, ...-1-1-1\", if you" - " have <em>dis</em>abled the <em>\"Collate\"</em> checkbox at the same time. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o outputorder=... # example: \"reverse\"" - " " - " </pre>" - " </p> " - " </qt>" ); - m_printer = prt; - m_useplugin = true; - - setTitle(i18n("C&opies")); - setId(KPrinter::CopiesPage); - - // widget creation - TQButtonGroup *m_pagebox = new TQButtonGroup(0, Qt::Vertical, i18n("Page Selection"), this); - TQWhatsThis::add(m_pagebox, whatsThisPageSelectionLabel); - m_all = new TQRadioButton(i18n("&All"), m_pagebox); - TQWhatsThis::add(m_all, whatsThisAllPagesLabel); - m_current = new TQRadioButton(i18n("Cu&rrent"), m_pagebox); - TQWhatsThis::add(m_current, whatsThisCurrentPagesLabel); - m_range = new TQRadioButton(i18n("Ran&ge"), m_pagebox); - TQWhatsThis::add(m_range, whatsThisPageRangeLabel); - m_rangeedit = new TQLineEdit(m_pagebox); - TQWhatsThis::add(m_rangeedit, whatsThisPageRangeLabel); - connect(m_range, TQT_SIGNAL(clicked()), m_rangeedit, TQT_SLOT(setFocus())); - TQToolTip::add(m_rangeedit, i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>")); -// TQWhatsThis::add(m_rangeedit, i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>")); - //TQLabel *m_rangeexpl = new TQLabel(m_pagebox); - //m_rangeexpl->setText(i18n("<p>Enter pages or group of pages to print separated by commas (1,2-5,8).</p>")); - TQGroupBox *m_copybox = new TQGroupBox(0, Qt::Vertical, i18n("Output Settings"), this); - TQWhatsThis::add(m_copybox, whatsThisCopiesLabel); - m_collate = new TQCheckBox(i18n("Co&llate"), m_copybox); - TQWhatsThis::add(m_collate, whatsThisCollateLabel); - m_order = new TQCheckBox(i18n("Re&verse"), m_copybox); - TQWhatsThis::add(m_order, whatsThisReverseLabel); - m_collatepix = new TQLabel(m_copybox); - m_collatepix->tqsetAlignment(Qt::AlignCenter); - m_collatepix->setMinimumHeight(70); - TQLabel *m_copieslabel = new TQLabel(i18n("Cop&ies:"), m_copybox); - m_copies = new TQSpinBox(m_copybox); - m_copies->setRange(1,999); - TQWhatsThis::add(m_copies, whatsThisNumberOfCopiesLabel); - m_copieslabel->setBuddy(m_copies); - TQWhatsThis::add(m_copieslabel, whatsThisNumberOfCopiesLabel); - m_pageset = new TQComboBox(m_pagebox); - m_pageset->insertItem(i18n("All Pages")); - m_pageset->insertItem(i18n("Odd Pages")); - m_pageset->insertItem(i18n("Even Pages")); - TQWhatsThis::add(m_pageset, whatsThisPageSetLabel); - TQLabel *m_pagesetlabel = new TQLabel(i18n("Page &set:"), m_pagebox); - m_pagesetlabel->setBuddy(m_pageset); - TQWhatsThis::add(m_pagesetlabel, whatsThisPageSetLabel); - KSeparator *sepline = new KSeparator(Qt::Horizontal, m_pagebox); - sepline->setMinimumHeight(10); - - TQWidget::setTabOrder( m_all, m_current ); - TQWidget::setTabOrder( m_current, m_range ); - TQWidget::setTabOrder( m_range, m_rangeedit ); - TQWidget::setTabOrder( m_rangeedit, m_pageset ); - TQWidget::setTabOrder( m_pageset, m_copies ); - TQWidget::setTabOrder( m_copies, m_collate ); - TQWidget::setTabOrder( m_collate, m_order ); - - // layout creation - TQGridLayout *l1 = new TQGridLayout(this, 2, 2, 0, 5); - l1->setRowStretch(1,1); - l1->setColStretch(0,1); - l1->setColStretch(1,1); - l1->addWidget(m_pagebox,0,0); - l1->addWidget(m_copybox,0,1); - TQVBoxLayout *l3 = new TQVBoxLayout(TQT_TQLAYOUT(m_pagebox->tqlayout()), 5); - l3->addWidget(m_all); - l3->addWidget(m_current); - TQHBoxLayout *l4 = new TQHBoxLayout(0, 0, 5); - l3->addLayout(l4); - l4->addWidget(m_range,0); - l4->addWidget(m_rangeedit,1); - //l3->addWidget(m_rangeexpl); - l3->addWidget(sepline); - TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 5); - l3->addLayout(l2); - l2->addWidget(m_pagesetlabel,0); - l2->addWidget(m_pageset,1); - TQGridLayout *l5 = new TQGridLayout(m_copybox->tqlayout(), 4, 2, 10); - l5->setRowStretch(4,1); - l5->addWidget(m_copieslabel,0,0); - l5->addWidget(m_copies,0,1); - l5->addMultiCellWidget(m_collatepix,1,2,0,0); - l5->addWidget(m_collate,1,1); - l5->addWidget(m_order,2,1); - - // some initialization - m_all->setChecked(true); - m_copies->setValue(1); - initialize(m_useplugin); - slotCollateClicked(); - - // connections - connect(m_rangeedit,TQT_SIGNAL(textChanged(const TQString&)),TQT_SLOT(slotRangeEntered())); - connect(m_collate,TQT_SIGNAL(clicked()),TQT_SLOT(slotCollateClicked())); - connect(m_order,TQT_SIGNAL(clicked()),TQT_SLOT(slotCollateClicked())); - - if (!kapp->authorize("print/copies")) - { - setTitle(i18n("Pages")); - m_copybox->hide(); - } -} - -KPCopiesPage::~KPCopiesPage() -{ -} - -void KPCopiesPage::slotRangeEntered() -{ - m_range->setChecked(true); -} - -void KPCopiesPage::slotCollateClicked() -{ - TQString s("tdeprint_"); - s.append((m_collate->isChecked() ? "collate" : "uncollate")); - if (m_order->isChecked()) s.append("_reverse"); - m_collatepix->setPixmap(UserIcon(s)); -} - -void KPCopiesPage::initialize(bool usePlugin) -{ - m_useplugin = usePlugin; - int f = KMFactory::self()->uiManager()->copyFlags(m_printer, m_useplugin); - - m_current->setEnabled((f & KMUiManager::Current)); - m_range->setEnabled((f & KMUiManager::Range)); - m_rangeedit->setEnabled((f & KMUiManager::Range)); - m_collate->setEnabled((f & KMUiManager::Collate)); - m_order->setEnabled((f & KMUiManager::Order)); - m_pageset->setEnabled((f & KMUiManager::PageSet)); - - // by default, if collate disabled, set it to true - m_collate->setChecked(!(f & KMUiManager::NoAutoCollate)); - slotCollateClicked(); -} - -void KPCopiesPage::setOptions(const TQMap<TQString,TQString>& options) -{ - TQString value; - // copies - value = options["kde-copies"]; - if (!value.isEmpty()) m_copies->setValue(value.toInt()); - // output order - value = options["kde-pageorder"]; - if (m_order->isEnabled()) m_order->setChecked(value == "Reverse"); - // collate - value = options["kde-collate"]; - if (m_collate->isEnabled()) m_collate->setChecked(!(value == "Uncollate")); - // update pixmap - slotCollateClicked(); - // page ranges - value = options["kde-range"]; - if (!value.isEmpty() && m_range->isEnabled() && value != "1-") - { - m_rangeedit->setText(value); - m_range->setChecked(true); - } - else if (options["kde-current"] == "1") - m_current->setChecked(true); - else - m_all->setChecked(true); - // page set - value = options["kde-pageset"]; - if (!value.isEmpty() && m_pageset->isEnabled()) - m_pageset->setCurrentItem(value.toInt()); - else - m_pageset->setCurrentItem(0); -} - -void KPCopiesPage::getOptions(TQMap<TQString,TQString>& options, bool incldef) -{ - // copies - options["kde-copies"] = m_copies->text(); - // output order - options["kde-pageorder"] = (m_order->isChecked() ? "Reverse" : "Forward"); - // collate - options["kde-collate"] = (m_collate->isChecked() ? "Collate" : "Uncollate"); - // ranges - options["kde-current"] = (m_current->isChecked() ? "1" : "0"); - options["kde-range"] = (m_range->isChecked() ? m_rangeedit->text() : (incldef ? TQString::tqfromLatin1("1-") : TQString::tqfromLatin1(""))); - // page set - options["kde-pageset"] = TQString::number(m_pageset->currentItem()); -} - -void KPCopiesPage::reload() -{ - initialize(m_useplugin); -} - -#include "kpcopiespage.moc" diff --git a/kdeprint/kpcopiespage.h b/kdeprint/kpcopiespage.h deleted file mode 100644 index 1e1532ce9..000000000 --- a/kdeprint/kpcopiespage.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPCOPIESPAGE_H -#define KPCOPIESPAGE_H - -#include "kprintdialogpage.h" -#include <tdeprint/kpreloadobject.h> - -class TQRadioButton; -class TQLineEdit; -class TQComboBox; -class TQCheckBox; -class TQSpinBox; -class TQLabel; -class KPrinter; - -class KDEPRINT_EXPORT KPCopiesPage : public KPrintDialogPage, public KPReloadObject -{ - Q_OBJECT -public: - KPCopiesPage(KPrinter *prt = 0, TQWidget *parent = 0, const char *name = 0); - ~KPCopiesPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - void initialize(bool usePlugin = true); - -protected slots: - void slotRangeEntered(); - void slotCollateClicked(); - -protected: - void reload(); - -protected: - TQRadioButton *m_all, *m_current, *m_range; - TQLineEdit *m_rangeedit; - TQComboBox *m_pageset; - TQCheckBox *m_collate, *m_order; - TQSpinBox *m_copies; - TQLabel *m_collatepix; - bool m_useplugin; - - KPrinter *m_printer; -}; - -#endif diff --git a/kdeprint/kpdriverpage.cpp b/kdeprint/kpdriverpage.cpp deleted file mode 100644 index 18cfeb207..000000000 --- a/kdeprint/kpdriverpage.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpdriverpage.h" -#include "driverview.h" -#include "driver.h" - -#include <tqlayout.h> -#include <klocale.h> - -KPDriverPage::KPDriverPage(KMPrinter *p, DrMain *d, TQWidget *parent, const char *name) -: KPrintDialogPage(p,d,parent,name) -{ - setTitle(i18n("Driver Settings")); - - m_view = new DriverView(this); - m_view->setAllowFixed(false); - if (driver()) m_view->setDriver(driver()); - - TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 0); - lay1->addWidget(m_view); -} - -KPDriverPage::~KPDriverPage() -{ -} - -bool KPDriverPage::isValid(TQString& msg) -{ - if (m_view->hasConflict()) - { - msg = i18n("<qt>Some options selected are in conflict. You must resolve these conflicts " - "before continuing. See <b>Driver Settings</b> tab for detailed information.</qt>"); - return false; - } - return true; -} - -void KPDriverPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - m_view->setOptions(opts); -} - -void KPDriverPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - m_view->getOptions(opts,incldef); -} diff --git a/kdeprint/kpdriverpage.h b/kdeprint/kpdriverpage.h deleted file mode 100644 index 5c3936e49..000000000 --- a/kdeprint/kpdriverpage.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPDRIVERPAGE_H -#define KPDRIVERPAGE_H - -#include "kprintdialogpage.h" - -class DriverView; - -class KDEPRINT_EXPORT KPDriverPage : public KPrintDialogPage -{ -public: - KPDriverPage(KMPrinter *p, DrMain *d = 0, TQWidget *parent = 0, const char *name = 0); - ~KPDriverPage(); - - bool isValid(TQString& msg); - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected: - DriverView *m_view; -}; - -#endif diff --git a/kdeprint/kpfileselectpage.cpp b/kdeprint/kpfileselectpage.cpp deleted file mode 100644 index f3131717a..000000000 --- a/kdeprint/kpfileselectpage.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpfileselectpage.h" -#include "kfilelist.h" - -#include <tqlayout.h> -#include <tqstringlist.h> -#include <tqregexp.h> -#include <tqheader.h> -#include <klocale.h> -#include <kiconloader.h> - -KPFileSelectPage::KPFileSelectPage(TQWidget *parent, const char *name) -: KPrintDialogPage(parent, name) -{ - setTitle(i18n("&Files")); - m_first = true; - - m_files = new KFileList(this); - - TQHBoxLayout *l0 = new TQHBoxLayout(this, 0, 10); - l0->addWidget(m_files); - - resize(100, 100); -} - -void KPFileSelectPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - // (incldef == false) is a hint telling that it should be the last time - // and we want to do it only once - if (!incldef) - { - TQStringList l = m_files->fileList(); - opts["kde-filelist"] = l.join("@@"); - } -} - -void KPFileSelectPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - // do it only once as files will only be selected there - if (m_first) - { - TQStringList l = TQStringList::split("@@", opts["kde-filelist"], false); - m_files->setFileList(l); - - m_first = false; - } -} diff --git a/kdeprint/kpfileselectpage.h b/kdeprint/kpfileselectpage.h deleted file mode 100644 index 11ed378ff..000000000 --- a/kdeprint/kpfileselectpage.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPFILESELECT_H -#define KPFILESELECT_H - -#include "kprintdialogpage.h" - -class KFileList; - -class KPFileSelectPage : public KPrintDialogPage -{ -public: - KPFileSelectPage(TQWidget *parent = 0, const char *name = 0); - - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - void setOptions(const TQMap<TQString,TQString>& opts); - -private: - KFileList *m_files; - bool m_first; -}; - -#endif diff --git a/kdeprint/kpfilterpage.cpp b/kdeprint/kpfilterpage.cpp deleted file mode 100644 index b321b3141..000000000 --- a/kdeprint/kpfilterpage.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpfilterpage.h" -#include "kmfactory.h" -#include "kxmlcommand.h" - -#include <tqtoolbutton.h> -#include <tqheader.h> -#include <tqtooltip.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <klistview.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kmessagebox.h> -#include <kactivelabel.h> -#include <kdebug.h> -#include <kapplication.h> -#include <kdialog.h> - -KPFilterPage::KPFilterPage(TQWidget *parent, const char *name) -: KPrintDialogPage(parent,name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisAddFilterButton = i18n( " <qt> <b>Add Filter button</b>" - " <p>This button calls a little dialog to let you" - " select a filter here. </p>" - " <p><b>Note 1:</b> You can chain different filters as long as you make " - " sure that the output of one fits as input of the next. (KDEPrint " - " checks your filtering chain and will warn you if you fail to do so.</p> " - " <p><b>Note 2:</b> The filters you define here are applied to your jobfile " - " <em><b>before</b></em> it is handed downstream to your spooler and print " - " subsystem (e.g. CUPS, LPRng, LPD).</p>" - " </ul>" - " </qt>" ); - - TQString whatsThisRemoveFilterButton = i18n(" <qt> <b>Remove Filter button</b>" - " <p>This button removes the highlighted filter from the" - " list of filters." - " </qt>" ); - - TQString whatsThisMoveFilterUpButton = i18n(" <qt> <b>Move Filter Up button</b>" - " <p>This button moves the highlighted filter up in the list" - " of filters, towards the front of the filtering chain. </p>" - " </qt>" ); - - TQString whatsThisMoveFilterDownButton = i18n(" <qt> <b>Move Filter Down button</b>" - " <p>This button moves the highlighted filter down in the list" - " of filters, towards the end of the filtering chain..</p>" - " </qt>" ); - - TQString whatsThisConfigureFilterButton = i18n( " <qt> <b>Configure Filter button</b>" - " <p>This button lets you configure the currently highlighted filter." - " It opens a separate dialog. " - " </p>" - " </qt>" ); - - TQString whatsThisFilterInfoPane = i18n( " <qt> <b>Filter Info Pane</b>" - " <p>This field shows some general info about the selected filter. " - " Amongst them are: " - " <ul> " - " <li>the <em>filter name</em> (as displayed in the KDEPrint user interface); </li> " - " <li>the <em>filter requirements</em> (that is the external program that needs " - " to present and executable on this system); </li> " - " <li>the <em>filter input format</em> (in the form of one or several <em>MIME types</em>" - " accepted by the filter); </li> " - " <li>the <em>filter output format</em> (in the form of a <em>MIME type</em> " - " generated by the filter); </li> " - " <li>a more or less verbose text describing the filter's operation.</li> " - " </ul> " - " </p>" - " </qt>" ); - - TQString whatsThisFilterchainListView = i18n( " <qt> <b>Filtering Chain</b> (if enabled, is run <em>before</em> actual " - " job submission to print system)" - " <p>This field shows which filters are currently selected to act as 'pre-filters' " - " for KDEPrint. Pre-filters are processing the print files <em>before</em> they are " - " send downstream to your real print subsystem. </p> " - " <p>The list shown in this field may be empty (default). </p> " - " <p>The pre-filters act on the printjob in the order they are listed (from top to bottom). " - " This is done by acting as a <em>filtering chain</em> where the output of one filter " - " acts as input to the next. By putting the filters into the wrong order, you can make " - " the filtering chain fail. For example: if your file is ASCII text, and you want the " - " output being processed by the 'Multipage per Sheet' filter, the first filter must be " - " one that processes ASCII into PostScript. </p> " - " <p>KDEPrint can utilize <em>any</em> external filtering program which you may find useful " - " through this interface. </p> " - " <p>KDEPrint ships preconfigured with support for a selection of common filters. These " - " filters however need to be " - " installed independently from KDEPrint. These pre-filters work <em>for all</em> print subsystems" - " supported by KDEPrint (such as CUPS, LPRng and LPD), because they are not depending on these.</p> " - ".<p> Amongst the pre-configured filters shipping with KDEPrint are: </p> " - " <ul> " - " <li>the <em>Enscript text filter</em> </li> " - " <li>a <em>Multiple Pages per Sheet filter</em </li> " - " <li>a <em>PostScript to PDF converter</em>.</li> " - " <li>a <em>Page Selection/Ordering filter</em>.</li> " - " <li>a <em>Poster Printing filter</em>.</li> " - " <li>and some more..</li> " - " </ul> " - " To insert a filter into this list, simply click on the <em>funnel</em> icon (topmost on " - " the right icon column group) and proceed. </p>" - " <p>Please click on the other elements of this dialog to learn more about the KDEPrint " - " pre-filters. " - " </p>" - " </qt>" ); - - setTitle(i18n("Filters")); - m_activefilters.setAutoDelete(true); - m_valid = true; - - m_view = new KListView(this); - TQWhatsThis::add(m_view, whatsThisFilterchainListView); - m_view->addColumn(""); - m_view->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - m_view->setLineWidth(1); - m_view->setSorting(-1); - m_view->header()->hide(); - connect(m_view,TQT_SIGNAL(selectionChanged(TQListViewItem*)),TQT_SLOT(slotItemSelected(TQListViewItem*))); - - m_add = new TQToolButton(this); - TQWhatsThis::add(m_add, whatsThisAddFilterButton); - m_add->setIconSet(BarIconSet("filter")); - TQToolTip::add(m_add, i18n("Add filter")); - - m_remove = new TQToolButton(this); - TQWhatsThis::add(m_remove, whatsThisRemoveFilterButton); - m_remove->setIconSet(BarIconSet("remove")); - TQToolTip::add(m_remove, i18n("Remove filter")); - - m_up = new TQToolButton(this); - TQWhatsThis::add(m_up, whatsThisMoveFilterUpButton); - m_up->setIconSet(BarIconSet("up")); - TQToolTip::add(m_up, i18n("Move filter up")); - - m_down = new TQToolButton(this); - TQWhatsThis::add(m_down, whatsThisMoveFilterDownButton); - m_down->setIconSet(BarIconSet("down")); - TQToolTip::add(m_down, i18n("Move filter down")); - - m_configure = new TQToolButton(this); - TQWhatsThis::add(m_configure, whatsThisConfigureFilterButton); - m_configure->setIconSet(BarIconSet("configure")); - TQToolTip::add(m_configure, i18n("Configure filter")); - - connect(m_add,TQT_SIGNAL(clicked()),TQT_SLOT(slotAddClicked())); - connect(m_remove,TQT_SIGNAL(clicked()),TQT_SLOT(slotRemoveClicked())); - connect(m_up,TQT_SIGNAL(clicked()),TQT_SLOT(slotUpClicked())); - connect(m_down,TQT_SIGNAL(clicked()),TQT_SLOT(slotDownClicked())); - connect(m_configure,TQT_SIGNAL(clicked()),TQT_SLOT(slotConfigureClicked())); - connect(m_view,TQT_SIGNAL(doubleClicked(TQListViewItem*)),TQT_SLOT(slotConfigureClicked())); - - m_info = new KActiveLabel(this); - TQWhatsThis::add(m_info, whatsThisFilterInfoPane); - m_info->setVScrollBarMode( TQScrollView::Auto ); - m_info->setHScrollBarMode( TQScrollView::Auto ); - m_info->setFrameStyle( TQFrame::Panel|TQFrame::Sunken ); - m_info->setMinimumSize( TQSize( 240, 100 ) ); - - TQGridLayout *l1 = new TQGridLayout(this, 2, 2, 0, KDialog::spacingHint()); - l1->setColStretch(0, 1); - TQVBoxLayout *l2 = new TQVBoxLayout(0, 0, 1); - l1->addWidget(m_view, 0, 0); - l1->addLayout(l2, 0, 1); - l2->addWidget(m_add); - l2->addWidget(m_remove); - l2->addSpacing(5); - l2->addWidget(m_up); - l2->addWidget(m_down); - l2->addSpacing(5); - l2->addWidget(m_configure); - l2->addStretch(1); - l1->addMultiCellWidget(m_info, 1, 1, 0, 1); - slotItemSelected(0); - - resize(100,50); -} - -KPFilterPage::~KPFilterPage() -{ -} - -void KPFilterPage::updateButton() -{ -/* TQListViewItem *item = m_view->currentItem(); - bool state=(item!=0); - m_remove->setEnabled(state); - m_up->setEnabled((state && item->itemAbove() != 0)); - m_down->setEnabled((state && item->itemBelow() != 0)); - m_configure->setEnabled(state);*/ -} - -void KPFilterPage::slotAddClicked() -{ - bool ok; - TQString choice = KXmlCommandManager::self()->selectCommand( this ); - ok = !choice.isEmpty(); - if (ok) - { - KXmlCommand *cmd = KXmlCommandManager::self()->loadCommand(choice); - if (!cmd) return; // Error - TQStringList filters = activeList(); - int pos = KXmlCommandManager::self()->insertCommand(filters, cmd->name()); - TQListViewItem *prev(0); - if (pos > 0) - { - prev = m_view->firstChild(); - for (int i=1;prev && i<pos;i++) - prev = prev->nextSibling(); - } - m_activefilters.insert(cmd->name(), cmd); - TQListViewItem *item = new TQListViewItem(m_view, prev, cmd->description(), cmd->name()); - item->setPixmap(0, SmallIcon("filter")); - checkFilterChain(); - } -} - -void KPFilterPage::slotRemoveClicked() -{ - if (m_view->selectedItem()) - { - TQString idname = m_view->selectedItem()->text(1); - delete m_view->selectedItem(); - m_activefilters.remove(idname); - checkFilterChain(); - if (m_view->currentItem()) - m_view->setSelected(m_view->currentItem(), true); - slotItemSelected(m_view->currentItem()); - } -} - -void KPFilterPage::slotUpClicked() -{ - TQListViewItem *item = m_view->selectedItem(); - if (item && item->itemAbove()) - { - TQListViewItem *clone = new TQListViewItem(m_view,item->itemAbove()->itemAbove(),item->text(0),item->text(1)); - clone->setPixmap(0, SmallIcon("filter")); - delete item; - m_view->setSelected(clone, true); - checkFilterChain(); - } -} - -void KPFilterPage::slotDownClicked() -{ - TQListViewItem *item = m_view->selectedItem(); - if (item && item->itemBelow()) - { - TQListViewItem *clone = new TQListViewItem(m_view,item->itemBelow(),item->text(0),item->text(1)); - clone->setPixmap(0, SmallIcon("filter")); - delete item; - m_view->setSelected(clone, true); - checkFilterChain(); - } -} - -void KPFilterPage::slotConfigureClicked() -{ - KXmlCommand *filter = currentFilter(); - if (!filter || !KXmlCommandManager::self()->configure(filter, this)) - KMessageBox::error(this,i18n("Internal error: unable to load filter.")); -} - -void KPFilterPage::slotItemSelected(TQListViewItem *item) -{ - m_remove->setEnabled((item != 0)); - m_up->setEnabled((item != 0 && item->itemAbove() != 0)); - m_down->setEnabled((item != 0 && item->itemBelow() != 0)); - m_configure->setEnabled((item != 0)); - updateInfo(); -} - -void KPFilterPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQStringList filters = TQStringList::split(',',opts["_kde-filters"],false); - // remove unneeded filters - TQDictIterator<KXmlCommand> dit(m_activefilters); - for (;dit.current();) - { - if (filters.find(dit.currentKey()) == filters.end()) - m_activefilters.remove(dit.currentKey()); - else - { - dit.current()->setOptions(opts); - ++dit; - } - } - // add needed filters - m_view->clear(); - TQListViewItem *item(0); - for (TQStringList::ConstIterator sit=filters.begin(); sit!=filters.end(); ++sit) - { - KXmlCommand *f(0); - if ((f=m_activefilters.find(*sit)) == 0) - { - f = KXmlCommandManager::self()->loadCommand(*sit); - if (f) - { - m_activefilters.insert(*sit,f); - f->setOptions(opts); - } - } - if (f) - item = new TQListViewItem(m_view,item,f->description(),f->name()); - } - checkFilterChain(); -} - -void KPFilterPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - TQStringList filters = activeList(); - for (TQStringList::ConstIterator it=filters.begin(); it!=filters.end(); ++it) - { - KXmlCommand *f = m_activefilters.find(*it); - if (f) - f->getOptions(opts, incldef); - } - if (filters.count() > 0 || incldef) - { - opts["_kde-filters"] = filters.join(","); - } -} - -TQStringList KPFilterPage::activeList() -{ - TQStringList list; - TQListViewItem *item = m_view->firstChild(); - while (item) - { - list.append(item->text(1)); - item = item->nextSibling(); - } - return list; -} - -KXmlCommand* KPFilterPage::currentFilter() -{ - KXmlCommand *filter(0); - if (m_view->selectedItem()) - filter = m_activefilters.find(m_view->selectedItem()->text(1)); - return filter; -} - -void KPFilterPage::checkFilterChain() -{ - TQListViewItem *item = m_view->firstChild(); - bool ok(true); - m_valid = true; - while (item) - { - item->setPixmap(0, (ok ? SmallIcon("filter") : SmallIcon("filterstop"))); - KXmlCommand *f1 = m_activefilters.find(item->text(1)); - if (f1 && item->nextSibling()) - { - KXmlCommand *f2 = m_activefilters.find(item->nextSibling()->text(1)); - if (f2) - { - if (!f2->acceptMimeType(f1->mimeType())) - { - item->setPixmap(0, SmallIcon("filterstop")); - ok = false; - m_valid = false; - } - else - ok = true; - } - } - item = item->nextSibling(); - } -} - -bool KPFilterPage::isValid(TQString& msg) -{ - if (!m_valid) - { - msg = i18n("<p>The filter chain is wrong. The output format of at least one filter is not supported by its follower. See <b>Filters</b> tab for more information.</p>"); - } - return m_valid; -} - -void KPFilterPage::updateInfo() -{ - TQString txt; - KXmlCommand *f = currentFilter(); - if (f) - { - TQString templ("<b>%1:</b> %2<br>"); - txt.append(templ.arg(i18n("Name")).arg(f->name())); - txt.append(templ.arg(i18n("Requirements")).arg(f->requirements().join(", "))); - txt.append(templ.arg(i18n("Input")).arg(f->inputMimeTypes().join(", "))); - txt.append(templ.arg(i18n("Output")).arg(f->mimeType())); - if ( !f->comment().isEmpty() ) - txt.append( "<br>" ).append( f->comment() ); - } - m_info->setText(txt); -} - -#include "kpfilterpage.moc" diff --git a/kdeprint/kpfilterpage.h b/kdeprint/kpfilterpage.h deleted file mode 100644 index 72065b3f1..000000000 --- a/kdeprint/kpfilterpage.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPFILTERPAGE_H -#define KPFILTERPAGE_H - -#include "kprintdialogpage.h" - -#include <tqdict.h> -#include <tqstringlist.h> - -class KListView; -class KXmlCommand; -class TQListViewItem; -class TQToolButton; -class TQTextBrowser; - -class KPFilterPage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPFilterPage(TQWidget *parent = 0, const char *name = 0); - ~KPFilterPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - bool isValid(TQString& msg); - -protected slots: - void slotAddClicked(); - void slotRemoveClicked(); - void slotUpClicked(); - void slotDownClicked(); - void slotConfigureClicked(); - void slotItemSelected(TQListViewItem*); - -protected: - KXmlCommand* currentFilter(); - void checkFilterChain(); - void updateInfo(); - TQStringList activeList(); - void updateButton(); -private: - KListView *m_view; - TQStringList m_filters; // <idname,description> pairs - TQDict<KXmlCommand> m_activefilters; - TQToolButton *m_add, *m_remove, *m_up, *m_down, *m_configure; - bool m_valid; - TQTextBrowser *m_info; -}; - -#endif diff --git a/kdeprint/kpgeneralpage.cpp b/kdeprint/kpgeneralpage.cpp deleted file mode 100644 index 98ab5d4a6..000000000 --- a/kdeprint/kpgeneralpage.cpp +++ /dev/null @@ -1,736 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpgeneralpage.h" -#include "driver.h" -#include "kmprinter.h" -#include "kprinter.h" - -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqbutton.h> -#include <tqbuttongroup.h> -#include <tqlayout.h> -#include <tqradiobutton.h> -#include <tqwhatsthis.h> - -#include <kcursor.h> -#include <kdebug.h> -#include <kdialog.h> -#include <kiconloader.h> -#include <klocale.h> - -// Some ID's -#define ORIENT_PORTRAIT_ID 0 -#define ORIENT_LANDSCAPE_ID 1 -#define ORIENT_REVLANDSCAPE_ID 2 -#define ORIENT_REVPORTRAIT_ID 3 - -#define DUPLEX_NONE_ID 0 -#define DUPLEX_LONG_ID 1 -#define DUPLEX_SHORT_ID 2 - -#define NUP_1_ID 0 -#define NUP_2_ID 1 -#define NUP_4_ID 2 - -static void initCombo(TQComboBox *cb, DrListOption *opt) -{ - cb->clear(); - TQPtrListIterator<DrBase> it(*(opt->choices())); - for (;it.current();++it) - { - cb->insertItem(it.current()->get("text")); - if (it.current() == opt->currentChoice()) - cb->setCurrentItem(cb->count()-1); - } -} - -static void setComboItem(TQComboBox *cb, const TQString& txt) -{ - for (int i=0;i<cb->count();i++) - if (cb->text(i) == txt) - { - cb->setCurrentItem(i); - return; - } -} - -static int findOption(const char *strs[], int n, const TQString& txt) -{ - for (int i=0;i<n;i+=2) - if (txt == strs[i]) return (i/2); - return (-1); -} - -//************************************************************************************************* - -// default values in case of NULL driver -static const char* default_size[] = { - "A4", I18N_NOOP("ISO A4"), - "Letter", I18N_NOOP("US Letter"), - "Legal", I18N_NOOP("US Legal"), - "Ledger", I18N_NOOP("Ledger"), - "Folio", I18N_NOOP("Folio"), - "Comm10", I18N_NOOP("US #10 Envelope"), - "DL", I18N_NOOP("ISO DL Envelope"), - "Tabloid", I18N_NOOP("Tabloid"), - "A3", I18N_NOOP( "ISO A3" ), - "A2", I18N_NOOP( "ISO A2" ), - "A1", I18N_NOOP( "ISO A1" ), - "A0", I18N_NOOP( "ISO A0" ) -}; - -#define SMALLSIZE_BEGIN 0 -#define MEDIUMSIZE_BEGIN 14 -#define HIGHSIZE_BEGIN 20 -#define DEFAULT_SIZE 24 - -#define DEFAULT_SOURCE 8 -static const char* default_source[] = { - "Upper", I18N_NOOP("Upper Tray"), - "Lower", I18N_NOOP("Lower Tray"), - "MultiPurpose", I18N_NOOP("Multi-Purpose Tray"), - "LargeCapacity", I18N_NOOP("Large Capacity Tray") -}; -#define DEFAULT_TYPE 4 -static const char* default_type[] = { - "Normal", I18N_NOOP("Normal"), - "Transparency", I18N_NOOP("Transparency") -}; - -//*************************************************************************************************** - -KPGeneralPage::KPGeneralPage(KMPrinter *pr, DrMain *dr, TQWidget *parent, const char *name) -: KPrintDialogPage(pr,dr,parent,name) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisPrintPropertiesGeneralPage = i18n( " <qt> " - " <p><b>\"General\"</b> </p> " - " <p>This dialog page contains <em>general</em> print job settings." - " General settings are applicable to most printers, most jobs " - " and most job file types. " - " <p>To get more specific help, enable the \"WhatsThis\" cursor and click on any of the " - " text labels or GUI elements of this dialog. " - " </qt>" ); - TQString whatsThisGeneralPageSizeLabel = i18n( " <qt> " - " <p><b>Page size:</b> Select paper size to be printed on from " - " the drop-down menu. </p>" - " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed.</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o PageSize=... # examples: \"A4\" or \"Letter\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisGeneralPaperTypeLabel = i18n( " <qt> " - " <p><b>Paper type:</b> Select paper type to be printed on from " - " the drop-down menu. </p>" - " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o MediaType=... # example: \"Transparency\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisGeneralPaperSourceLabel = i18n( " <qt> " - " <p><b>Paper source:</b> Select paper source tray for the paper" - " to be printed on from the drop-down menu. " - " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o InputSlot=... # examples: \"Lower\" or \"LargeCapacity\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisGeneralOrientationLabel = i18n( " <qt> " - " <p><b>Image Orientation:</b> Orientation of the printed " - " page image on your paper is controlled by the radio buttons. By default, " - " the orientation is <em>Portrait</em> " - " <p>You can select 4 alternatives: " - " <ul> " - " <li> <b>Portrait.</b>.Portrait is the default setting. </li> " - " <li> <b>Landscape.</b> </li> " - " <li> <b>Reverse Landscape.</b> Reverse Landscape prints the images upside down. </li> " - " <li> <b>Reverse Portrait.</b> Reverse Portrait prints the image upside down.</li> " - " </ul> " - " The icon changes according to your selection.</p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o orientation-requested=... # examples: \"landscape\" or \"reverse-portrait\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisGeneralDuplexLabel = i18n( " <qt> " - " <p><b>Duplex Printing:</b> These controls may be grayed out if your printer " - " does not support <em>duplex printing</em> (i.e. printing on both sides of the sheet). " - " These controls are active if your printer supports duplex printing. " - " <p> " - " You can choose from 3 alternatives: </p>" - " <ul> " - " <li> <b>None.</b> This prints each page of the job on one side of the sheets only. </li> " - " <li> <b>Long Side.</b> This prints the job on both sides of the paper sheets. " - " It prints the job in a way so that the backside has the same orientation as the front " - " side if you turn the paper over the long edge. (Some printer drivers name this mode " - " <em>duplex-non-tumbled</em>). </li> " - " <li> <b>Short Side.</b> This prints the job on both sides of the paper sheets. " - " It prints the job so that the backside has the reverse orientation from the front " - " side if you turn the paper over the long edge, but the same orientation, if you turn it over " - " the short edge. (Some printer drivers name this mode " - " <em>duplex-tumbled</em>). </li> " - " </ul> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o duplex=... # examples: \"tumble\" or \"two-sided-short-edge\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisGeneralBannersLabel = i18n( " <qt> " - " <p><b>Banner Page(s):</b> Select banner(s) to print one or two special sheets " - " of paper just before or after your main job. </p>" - " <p>Banners may contain some pieces of job information, such as user name, time of printing, job" - " title and more. </p>" - " <p>Banner pages are useful to separate different jobs more easily, especially in a multi-user " - " environment. </p>" - " <p><em><b>Hint:</em></b> You can design your own banner pages. To make use of them, just put the banner " - " file into the standard CUPS <em>banners</em> directory (This is usually <em>\"/usr/share/cups/banner/\"</em> " - " Your custom banner(s) must have one of the supported printable formats. " - " Supported formats are ASCII text, PostScript, PDF and nearly any image format such as PNG, JPEG or " - " GIF. Your added banner pages will appear in the drop down menu after a restart of CUPS. </p>" - " <p>CUPS comes with a selection of banner pages. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o job-sheets=... # examples: \"standard\" or \"topsecret\" " - " </pre>" - " </p> " - " </qt>" ); - TQString whatsThisGeneralPagesPerSheetLabel = i18n( " <qt> " - " <p><b>Pages per Sheet:</b> " - " You can choose to print more than one page onto each sheet of paper. " - " This is sometimes useful to save paper. </p>" - " <p><b>Note 1:</b> the page images get scaled down accordingly to print 2 or 4 pages per sheet. " - " The page image does not get scaled if you print 1 page per sheet (the default setting.). " - " <p><b>Note 2:</b> If you select multiple pages per sheet here, the scaling and re-arranging is done " - " by your printing system. Be aware, that some printers can by themselves print multiple pages per sheet. " - " In this case you find the option in the printer driver settings. Be careful: if you enable multiple " - " pages per sheet in both places, your printout will not look as you intended. </p>" - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o number-up=... # examples: \"2\" or \"4\" " - " </pre>" - " </p> " - " </qt>" ); - - - setTitle(i18n("General")); - - // widget creation - TQLabel *m_pagesizelabel = new TQLabel(i18n("Page s&ize:"), this); - m_pagesizelabel->tqsetAlignment(Qt::AlignVCenter|Qt::AlignRight); - TQWhatsThis::add(m_pagesizelabel, whatsThisGeneralPageSizeLabel); - - TQLabel *m_papertypelabel = new TQLabel(i18n("Paper t&ype:"), this); - m_papertypelabel->tqsetAlignment(Qt::AlignVCenter|Qt::AlignRight); - TQWhatsThis::add(m_papertypelabel, whatsThisGeneralPaperTypeLabel); - - TQLabel *m_inputslotlabel = new TQLabel(i18n("Paper so&urce:"), this); - m_inputslotlabel->tqsetAlignment(Qt::AlignVCenter|Qt::AlignRight); - TQWhatsThis::add(m_inputslotlabel, whatsThisGeneralPaperSourceLabel); - - m_pagesize = new TQComboBox(this); - TQWhatsThis::add(m_pagesize, whatsThisGeneralPageSizeLabel); - - m_papertype = new TQComboBox(this); - TQWhatsThis::add(m_papertype, whatsThisGeneralPaperTypeLabel); - - m_inputslot = new TQComboBox(this); - TQWhatsThis::add(m_inputslot, whatsThisGeneralPaperSourceLabel); - - m_pagesizelabel->setBuddy(m_pagesize); - m_papertypelabel->setBuddy(m_papertype); - m_inputslotlabel->setBuddy(m_inputslot); - - m_orientbox = new TQButtonGroup(0, Qt::Vertical, i18n("Orientation"), this); - TQWhatsThis::add(m_orientbox, whatsThisGeneralOrientationLabel); - - m_duplexbox = new TQButtonGroup(0, Qt::Vertical, i18n("Duplex Printing"), this); - TQWhatsThis::add(m_duplexbox, whatsThisGeneralDuplexLabel); - - m_nupbox = new TQButtonGroup(0, Qt::Vertical, i18n("Pages per Sheet"), this); - TQWhatsThis::add(m_nupbox, whatsThisGeneralPagesPerSheetLabel); - - m_bannerbox = new TQGroupBox(0, Qt::Vertical, i18n("Banners"), this); - TQWhatsThis::add(m_bannerbox, whatsThisGeneralBannersLabel); - - TQRadioButton *m_portrait = new TQRadioButton(i18n("&Portrait"), m_orientbox); - TQRadioButton *m_landscape = new TQRadioButton(i18n("&Landscape"), m_orientbox); - TQRadioButton *m_revland = new TQRadioButton(i18n("&Reverse landscape"), m_orientbox); - TQRadioButton *m_revport = new TQRadioButton(i18n("R&everse portrait"), m_orientbox); - - m_portrait->setChecked(true); - m_orientpix = new TQLabel(m_orientbox); - m_orientpix->tqsetAlignment(Qt::AlignCenter); - TQRadioButton *m_dupnone = new TQRadioButton(i18n("duplex orientation", "&None"), m_duplexbox); - TQRadioButton *m_duplong = new TQRadioButton(i18n("duplex orientation", "Lon&g side"), m_duplexbox); - TQRadioButton *m_dupshort = new TQRadioButton(i18n("duplex orientation", "S&hort side"), m_duplexbox); - m_dupnone->setChecked(true); - m_duplexpix = new TQLabel(m_duplexbox); - m_duplexpix->tqsetAlignment(Qt::AlignCenter); - TQRadioButton *m_nup1 = new TQRadioButton("&1", m_nupbox); - TQRadioButton *m_nup2 = new TQRadioButton("&2", m_nupbox); - TQRadioButton *m_nup4 = new TQRadioButton("&4", m_nupbox); - m_nup1->setChecked(true); - m_nuppix = new TQLabel(m_nupbox); - m_nuppix->tqsetAlignment(Qt::AlignCenter); - m_startbanner = new TQComboBox(m_bannerbox); - m_endbanner = new TQComboBox(m_bannerbox); - TQLabel *m_startbannerlabel = new TQLabel(i18n("S&tart:"), m_bannerbox); - TQLabel *m_endbannerlabel = new TQLabel(i18n("En&d:"), m_bannerbox); - m_startbannerlabel->setBuddy(m_startbanner); - m_endbannerlabel->setBuddy(m_endbanner); - - // layout creation - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - TQWhatsThis::add(this, whatsThisPrintPropertiesGeneralPage); - TQGridLayout *lay1 = new TQGridLayout(0, 3, 2, 0, KDialog::spacingHint()); - TQGridLayout *lay2 = new TQGridLayout(0, 2, 2, 0, KDialog::spacingHint()); - lay0->addStretch(1); - lay0->addLayout(TQT_TQLAYOUT(lay1)); - lay0->addStretch(1); - lay0->addLayout(TQT_TQLAYOUT(lay2)); - lay0->addStretch(2); - lay1->addWidget(m_pagesizelabel, 0, 0); - lay1->addWidget(m_papertypelabel, 1, 0); - lay1->addWidget(m_inputslotlabel, 2, 0); - lay1->addWidget(m_pagesize, 0, 1); - lay1->addWidget(m_papertype, 1, 1); - lay1->addWidget(m_inputslot, 2, 1); - lay2->addWidget(m_orientbox, 0, 0); - lay2->addWidget(m_bannerbox, 1, 0); - lay2->addWidget(m_duplexbox, 0, 1); - lay2->addWidget(m_nupbox, 1, 1); - lay2->setColStretch(0, 1); - lay2->setColStretch(1, 1); - TQGridLayout *lay3 = new TQGridLayout(m_orientbox->tqlayout(), 4, 2, - KDialog::spacingHint()); - lay3->addWidget(m_portrait, 0, 0); - lay3->addWidget(m_landscape, 1, 0); - lay3->addWidget(m_revland, 2, 0); - lay3->addWidget(m_revport, 3, 0); - lay3->addMultiCellWidget(m_orientpix, 0, 3, 1, 1); - TQGridLayout *lay4 = new TQGridLayout(m_duplexbox->tqlayout(), 3, 2, - KDialog::spacingHint()); - lay4->addWidget(m_dupnone, 0, 0); - lay4->addWidget(m_duplong, 1, 0); - lay4->addWidget(m_dupshort, 2, 0); - lay4->addMultiCellWidget(m_duplexpix, 0, 2, 1, 1); - lay4->setRowStretch( 0, 1 ); - TQGridLayout *lay5 = new TQGridLayout(m_nupbox->tqlayout(), 3, 2, - KDialog::spacingHint()); - lay5->addWidget(m_nup1, 0, 0); - lay5->addWidget(m_nup2, 1, 0); - lay5->addWidget(m_nup4, 2, 0); - lay5->addMultiCellWidget(m_nuppix, 0, 2, 1, 1); - TQGridLayout *lay6 = new TQGridLayout(m_bannerbox->tqlayout(), 2, 2, - KDialog::spacingHint()); - lay6->addWidget(m_startbannerlabel, 0, 0); - lay6->addWidget(m_endbannerlabel, 1, 0); - lay6->addWidget(m_startbanner, 0, 1); - lay6->addWidget(m_endbanner, 1, 1); - lay6->setColStretch(1, 1); - - // connections (+ misc) - connect(m_orientbox,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotOrientationChanged(int))); - connect(m_nupbox,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotNupChanged(int))); - connect(m_duplexbox,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotDuplexChanged(int))); - - // init - initialize(); -} - -KPGeneralPage::~KPGeneralPage() -{ -} - -void KPGeneralPage::initialize() -{ - if (driver()) - { - // Size, Type and Source - DrListOption *opt = (DrListOption*)driver()->findOption("PageSize"); - if (opt) initCombo(m_pagesize,opt); - else m_pagesize->setEnabled(false); - opt = (DrListOption*)driver()->findOption("MediaType"); - if (opt) initCombo(m_papertype,opt); - else m_papertype->setEnabled(false); - opt = (DrListOption*)driver()->findOption("InputSlot"); - if (opt) initCombo(m_inputslot,opt); - else m_inputslot->setEnabled(false); - // Duplex - opt = (DrListOption*)driver()->findOption("Duplex"); - if (opt) - { - if ( opt->choices()->count() == 2 ) - { - // probably a On/Off option instead of the standard PS one - TQButton *btn = static_cast<TQButton*>(m_duplexbox->find( DUPLEX_SHORT_ID )); - m_duplexbox->remove( btn ); - btn->hide(); - //delete btn; - static_cast<TQButton*>(m_duplexbox->find( DUPLEX_NONE_ID ))->setText( i18n( "Disabled" ) ); - static_cast<TQButton*>(m_duplexbox->find( DUPLEX_LONG_ID ))->setText( i18n( "Enabled" ) ); - m_duplexpix->hide(); - } - if (opt->currentChoice()) - { - int ID(DUPLEX_NONE_ID); - if (opt->currentChoice()->name() == "DuplexNoTumble" || opt->currentChoice()->name() == "On") ID = DUPLEX_LONG_ID; - else if (opt->currentChoice()->name() == "DuplexTumble") ID = DUPLEX_SHORT_ID; - m_duplexbox->setButton(ID); - slotDuplexChanged(ID); - } - } - else m_duplexbox->setEnabled(false); - } - else - { - // PageSize - for (int i=SMALLSIZE_BEGIN+1;i<MEDIUMSIZE_BEGIN;i+=2) - m_pagesize->insertItem(i18n(default_size[i])); - if ( printer()->printerCap() & KMPrinter::CapMedium ) - for ( int i=MEDIUMSIZE_BEGIN+1; i<HIGHSIZE_BEGIN; i+=2 ) - m_pagesize->insertItem(i18n(default_size[i])); - if ( printer()->printerCap() & KMPrinter::CapLarge ) - for ( int i=HIGHSIZE_BEGIN+1; i<DEFAULT_SIZE; i+=2 ) - m_pagesize->insertItem(i18n(default_size[i])); - // set default page size using locale settings - TQString psname = pageSizeToPageName((KPrinter::PageSize)(KGlobal::locale()->pageSize())); - int index = findOption(default_size, DEFAULT_SIZE, psname); - if (index >= 0) - m_pagesize->setCurrentItem(index); - // MediaType - for (int i=1;i<DEFAULT_TYPE;i+=2) - m_papertype->insertItem(i18n(default_type[i])); - // PageSize - for (int i=1;i<DEFAULT_SOURCE;i+=2) - m_inputslot->insertItem(i18n(default_source[i])); - - // Enable duplex setting if supported - m_duplexbox->setEnabled( printer()->printerCap() & KMPrinter::CapDuplex ); - } - - // Banners - TQStringList values = TQStringList::split(',',printer()->option("kde-banners-supported"),false); - if (values.count() > 0) - { - for (TQStringList::ConstIterator it = values.begin(); it != values.end(); ++it) - { - m_startbanner->insertItem(*it); - m_endbanner->insertItem(*it); - } - values = TQStringList::split(',',printer()->option("kde-banners"),false); - while (values.count() < 2) values.append("none"); - setComboItem(m_startbanner, values[0]); - setComboItem(m_endbanner, values[1]); - } - else - m_bannerbox->setEnabled(false); - - slotOrientationChanged(ORIENT_PORTRAIT_ID); - slotNupChanged(NUP_1_ID); -} - -void KPGeneralPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - TQString value; - - if (driver()) - { - value = opts["media"]; - TQStringList l = TQStringList::split(',',value,false); - for(TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it) - { - value = *it; - DrBase *ch; - if ((ch = (driver()->findOption("PageSize"))) && - (ch = (static_cast<DrListOption*>(ch))->findChoice(value))) - { - if (m_pagesize->isEnabled()) - setComboItem(m_pagesize, ch->get("text")); - } - else if ((ch = (driver()->findOption("MediaType"))) && - (ch = (static_cast<DrListOption*>(ch))->findChoice(value))) - { - if (m_papertype->isEnabled()) - setComboItem(m_papertype, ch->get("text")); - } - else if ((ch = (driver()->findOption("InputSlot"))) && - (ch = static_cast<DrListOption*>(ch)->findChoice(value))) - { - if (m_inputslot) - setComboItem(m_inputslot, ch->get("text")); - } - else - { - kdWarning() << "media option '" << value << "' not handled." << endl; - } - } - value = opts["PageSize"]; - if (m_pagesize->isEnabled() && !value.isEmpty()) - { - DrBase *ch = ((DrListOption*)driver()->findOption("PageSize"))->findChoice(value); - if (ch) setComboItem(m_pagesize, ch->get("text")); - } - value = opts["MediaType"]; - if (m_papertype->isEnabled() && !value.isEmpty()) - { - DrBase *ch = ((DrListOption*)driver()->findOption("MediaType"))->findChoice(value); - if (ch) setComboItem(m_papertype, ch->get("text")); - } - value = opts["InputSlot"]; - if (m_inputslot && m_inputslot->isEnabled() && !value.isEmpty()) - { - DrBase *ch = ((DrListOption*)driver()->findOption("InputSlot"))->findChoice(value); - if (ch) setComboItem(m_inputslot, ch->get("text")); - } - - value = opts["Duplex"]; - if (m_duplexbox->isEnabled() && !value.isEmpty()) - { - int ID(0); - if (value == "DuplexNoTumble" || value == "On") ID = 1; - else if (value == "DuplexTumble") ID = 2; - m_duplexbox->setButton(ID); - slotDuplexChanged(ID); - } - } - else - { - // Try to find "media" option - value = opts["media"]; - if (!value.isEmpty()) - { - int index(-1); - TQStringList l = TQStringList::split(',',value,false); - for(TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it) - { - value = *it; - - if ((index=findOption(default_size,DEFAULT_SIZE,value)) >= 0) - m_pagesize->setCurrentItem(index); - else if ((index=findOption(default_type,DEFAULT_TYPE,value)) >= 0) - m_papertype->setCurrentItem(index); - else if ((index=findOption(default_source,DEFAULT_SOURCE,value)) >= 0) - m_inputslot->setCurrentItem(index); - else - kdWarning() << "media option '" << value << "' not handled." << endl; - } - } - - // Try to find "sides" option - value = opts["sides"]; - int ID(0); - if (value == "two-sided-long-edge") ID = 1; - else if (value == "two-sided-short-edge") ID = 2; - m_duplexbox->setButton(ID); - slotDuplexChanged(ID); - } - - // Banners - value = opts["job-sheets"]; - if (!value.isEmpty()) - { - TQStringList l = TQStringList::split(',',value,false); - if (l.count() > 0) setComboItem(m_startbanner,l[0]); - if (l.count() > 1) setComboItem(m_endbanner,l[1]); - } - - // Orientation - value = opts["orientation-requested"]; - if (!value.isEmpty()) - { - bool ok; - int ID = value.toInt(&ok)-3; - if (ok) - { - m_orientbox->setButton(ID); - slotOrientationChanged(ID); - } - } - - // N-up - value = opts["number-up"]; - if (!value.isEmpty()) - { - bool ok; - int ID = TQMIN(value.toInt(&ok)-1,2); - if (ok) - { - m_nupbox->setButton(ID); - slotNupChanged(ID); - } - } - - if ( m_orientbox->isEnabled() ) - m_orientbox->setDisabled( opts[ "kde-orientation-fixed" ] == "1" ); - if ( m_pagesize->isEnabled() ) - m_pagesize->setDisabled( opts[ "kde-pagesize-fixed" ] == "1" ); -} - -void KPGeneralPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - TQString value; - - if (driver()) - { - DrListOption *opt; - if ((opt=(DrListOption*)driver()->findOption("PageSize")) != NULL) - { - DrBase *ch = opt->choices()->tqat(m_pagesize->currentItem()); - if (incldef || ch->name() != opt->get("default")) opts["PageSize"] = ch->name(); - } - if ((opt=(DrListOption*)driver()->findOption("MediaType")) != NULL) - { - DrBase *ch = opt->choices()->tqat(m_papertype->currentItem()); - if (incldef || ch->name() != opt->get("default")) opts["MediaType"] = ch->name(); - } - if ((opt=(DrListOption*)driver()->findOption("InputSlot")) != NULL) - { - DrBase *ch = opt->choices()->tqat(m_inputslot->currentItem()); - if (incldef || ch->name() != opt->get("default")) opts["InputSlot"] = ch->name(); - } - - if (m_duplexbox->isEnabled() && (opt=(DrListOption*)driver()->findOption("Duplex")) != NULL) - { - bool twoChoices = ( m_duplexbox->count() == 2 ); - switch (m_duplexbox->id(m_duplexbox->selected())) - { - case DUPLEX_NONE_ID: value = ( twoChoices ? "Off" : "None" ); break; - case DUPLEX_LONG_ID: value = ( twoChoices ? "On" : "DuplexNoTumble" ); break; - case DUPLEX_SHORT_ID: value = "DuplexTumble"; break; - } - if (incldef || value != opt->get("default")) opts["Duplex"] = value; - } - } - else - { - value = TQString("%1,%2,%3").arg(default_size[m_pagesize->currentItem()*2]).arg(default_type[m_papertype->currentItem()*2]).arg(default_source[m_inputslot->currentItem()*2]); - opts["media"] = value; - - if (m_duplexbox->isEnabled()) - { - switch (m_duplexbox->id(m_duplexbox->selected())) - { - case 0: value = "one-sided"; break; - case 1: value = "two-sided-long-edge"; break; - case 2: value = "two-sided-short-edge"; break; - } - opts["sides"] = value; - } - } - - value = TQString::number(m_orientbox->id(m_orientbox->selected())+3); - if (value != "3" || incldef) opts["orientation-requested"] = value; - - if (m_nupbox->isEnabled()) - { - switch (m_nupbox->id(m_nupbox->selected())) - { - case 0: value = "1"; break; - case 1: value = "2"; break; - case 2: value = "4"; break; - } - if (value != "1" || incldef) opts["number-up"] = value; - } - - if (m_bannerbox->isEnabled()) - { - TQStringList l = TQStringList::split(',',printer()->option("kde-banners"),false); - if (incldef || (l.count() == 2 && (l[0] != m_startbanner->currentText() || l[1] != m_endbanner->currentText())) - || (l.count() == 0 && (m_startbanner->currentText() != "none" || m_endbanner->currentText() != "none"))) - { - value = TQString("%1,%2").arg(m_startbanner->currentText()).arg(m_endbanner->currentText()); - opts["job-sheets"] = value; - } - } -} - -void KPGeneralPage::slotOrientationChanged(int ID) -{ - TQString iconstr; - switch (ID) - { - case ORIENT_PORTRAIT_ID: iconstr = "tdeprint_portrait"; break; - case ORIENT_LANDSCAPE_ID: iconstr = "tdeprint_landscape"; break; - case ORIENT_REVPORTRAIT_ID: iconstr = "tdeprint_revportrait"; break; - case ORIENT_REVLANDSCAPE_ID: iconstr = "tdeprint_revlandscape"; break; - default: iconstr = "tdeprint_portrait"; break; - } - m_orientpix->setPixmap(UserIcon(iconstr)); -} - -void KPGeneralPage::slotNupChanged(int ID) -{ - TQString iconstr; - switch (ID) - { - case NUP_1_ID: iconstr = "tdeprint_nup1"; break; - case NUP_2_ID: iconstr = "tdeprint_nup2"; break; - case NUP_4_ID: iconstr = "tdeprint_nup4"; break; - default: iconstr = "tdeprint_nup1"; break; - } - m_nuppix->setPixmap(UserIcon(iconstr)); -} - -void KPGeneralPage::slotDuplexChanged(int ID) -{ - if (m_duplexbox->isEnabled()) - { - TQString iconstr; - switch (ID) - { - case DUPLEX_NONE_ID: iconstr = "tdeprint_duplex_none"; break; - case DUPLEX_LONG_ID: iconstr = "tdeprint_duplex_long"; break; - case DUPLEX_SHORT_ID: iconstr = "tdeprint_duplex_short"; break; - default: iconstr = "tdeprint_duplex_none"; break; - } - m_duplexpix->setPixmap(UserIcon(iconstr)); - } -} -#include "kpgeneralpage.moc" diff --git a/kdeprint/kpgeneralpage.h b/kdeprint/kpgeneralpage.h deleted file mode 100644 index 2a211ab04..000000000 --- a/kdeprint/kpgeneralpage.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KPGENERALPAGE_H -#define KPGENERALPAGE_H - -#include "kprintdialogpage.h" - -class TQComboBox; -class TQButtonGroup; -class TQGroupBox; -class TQLabel; - -class KDEPRINT_EXPORT KPGeneralPage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPGeneralPage(KMPrinter *pr, DrMain *dr, TQWidget *parent = 0, const char *name = 0); - ~KPGeneralPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected: - void initialize(); - -protected slots: - void slotOrientationChanged(int); - void slotDuplexChanged(int); - void slotNupChanged(int); - -protected: - TQComboBox *m_pagesize, *m_papertype, *m_inputslot; - TQComboBox *m_startbanner, *m_endbanner; - TQButtonGroup *m_orientbox, *m_duplexbox, *m_nupbox; - TQGroupBox *m_bannerbox; - TQLabel *m_orientpix, *m_duplexpix, *m_nuppix; -}; - -#endif diff --git a/kdeprint/kpipeprocess.cpp b/kdeprint/kpipeprocess.cpp deleted file mode 100644 index daf3c2900..000000000 --- a/kdeprint/kpipeprocess.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpipeprocess.h" - -KPipeProcess::KPipeProcess(const TQString& cmd, int mode) -: TQFile() -{ - m_pipe = NULL; - if (!cmd.isEmpty()) - open(cmd,mode); -} - -KPipeProcess::~KPipeProcess() -{ - close(); -} - -bool KPipeProcess::open(const TQString& cmd, int mode) -{ - // close first if needed - close(); - // check supported modes - if (mode != IO_ReadOnly && mode != IO_WriteOnly) - return false; - - // create the pipe - m_pipe = popen(cmd.latin1(),(mode == IO_WriteOnly ? "w" : "r")); - if (m_pipe) - if (!TQFile::open(mode,m_pipe)) - close(); - return (m_pipe != NULL); -} - -void KPipeProcess::close() -{ - if (m_pipe != NULL) - { - TQFile::close(); - /* pipe must be close to be sure the process is terminated */ - pclose( m_pipe ); - m_pipe = NULL; - } -} diff --git a/kdeprint/kpipeprocess.h b/kdeprint/kpipeprocess.h deleted file mode 100644 index 0ead3da78..000000000 --- a/kdeprint/kpipeprocess.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPIPEPROCESS_H -#define KPIPEPROCESS_H - -#include <tqfile.h> -#include <stdio.h> - -#include <kdelibs_export.h> - -class KDEPRINT_EXPORT KPipeProcess : public TQFile -{ -public: - KPipeProcess(const TQString& cmd = TQString::null, int mode = IO_ReadOnly); - ~KPipeProcess(); - - bool open(const TQString& cmd, int mode = IO_ReadOnly); - void close(); - -private: - FILE *m_pipe; -}; - -#endif diff --git a/kdeprint/kpmarginpage.cpp b/kdeprint/kpmarginpage.cpp deleted file mode 100644 index 554679ee7..000000000 --- a/kdeprint/kpmarginpage.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 "kpmarginpage.h" -#include "kprinter.h" -#include "driver.h" -#include "marginwidget.h" - -#include <tqgroupbox.h> -#include <tqlayout.h> -#include <tqprinter.h> -#include <tqpaintdevicemetrics.h> - -#include <kiconloader.h> -#include <klocale.h> -#include <kdebug.h> -#include <kglobal.h> - -KPMarginPage::KPMarginPage(KPrinter *prt, DrMain *driver, TQWidget *parent, const char *name) -: KPrintDialogPage(0, driver, parent, name) -{ - m_printer = prt; - setTitle(i18n("Margins")); - m_usedriver = true; - - TQGroupBox *box = new TQGroupBox(1, Qt::Vertical, i18n("Margins"), this); - m_margin = new MarginWidget(box, "MarginWidget", (m_printer != 0)); - //m_margin->setSymetricMargins(true); - //if (m_printer) - // m_margin->setResolution(m_printer->resolution()); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 10); - l0->addWidget(box); - l0->addStretch(1); -} - -KPMarginPage::~KPMarginPage() -{ -} - -void KPMarginPage::initPageSize(const TQString& ps, bool landscape) -{ - // first retrieve the Qt values for page size and margins - TQPrinter prt(TQPrinter::PrinterResolution); - prt.setFullPage(true); - prt.setPageSize((TQPrinter::PageSize)(ps.isEmpty() ? KGlobal::locale()->pageSize() : ps.toInt())); - TQPaintDeviceMetrics metrics(&prt); - float w = metrics.width(); - float h = metrics.height(); - unsigned int it, il, ib, ir; - prt.margins( &it, &il, &ib, &ir ); - float mt = it; - float ml = il; - float mb = ib; - float mr = ir; - - if (driver() && m_usedriver ) - { - QString pageSize(ps); - - if (pageSize.isEmpty()) - { - DrListOption *o = (DrListOption*)driver()->findOption("PageSize"); - if (o) - pageSize = o->get("default"); - } - if (!pageSize.isEmpty()) - { - DrPageSize *dps = driver()->findPageSize(pageSize); - if (dps) - { - w = dps->pageWidth(); - h = dps->pageHeight(); - mt = QMAX( mt, dps->topMargin() ); - ml = QMAX( ml, dps->leftMargin() ); - mb = QMAX( mb, dps->bottomMargin() ); - mr = QMAX( mr, dps->rightMargin() ); - } - } - } - m_margin->setPageSize(w, h); - m_margin->setOrientation(landscape ? KPrinter::Landscape : KPrinter::Portrait); - m_margin->setDefaultMargins( mt, mb, ml, mr ); - m_margin->setCustomEnabled(false); -} - -void KPMarginPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - QString orient = opts["orientation-requested"]; - bool land = (orient.isEmpty()? opts["kde-orientation"] == "Landscape" : orient == "4" || orient == "5"); - TQString ps = opts[ "kde-printsize" ]; - if ( ps.isEmpty() ) - { - m_usedriver = true; - ps = opts[ "PageSize" ]; - if (ps.isEmpty()) - ps = opts["kde-pagesize"]; - } - else - m_usedriver = false; - initPageSize(ps, land); - - bool marginset(false); - QString value; - if (!(value=opts["kde-margin-top"]).isEmpty() && value.toFloat() != m_margin->top()) - { - marginset = true; - m_margin->setTop(value.toFloat()); - } - if (!(value=opts["kde-margin-left"]).isEmpty() && value.toFloat() != m_margin->left()) - { - marginset = true; - m_margin->setLeft(value.toFloat()); - } - if (!(value=opts["kde-margin-bottom"]).isEmpty() && value.toFloat() != m_margin->bottom()) - { - marginset = true; - m_margin->setBottom(value.toFloat()); - } - if (!(value=opts["kde-margin-right"]).isEmpty() && value.toFloat() != m_margin->right()) - { - marginset = true; - m_margin->setRight(value.toFloat()); - } - m_margin->setCustomEnabled(marginset); -} - -void KPMarginPage::getOptions(TQMap<TQString,TQString>& opts, bool /* incldef */) -{ - if (m_margin->isCustomEnabled() /*|| incldef*/) - { - opts["kde-margin-top"] = TQString::number(m_margin->top()); - opts["kde-margin-left"] = TQString::number(m_margin->left()); - opts["kde-margin-bottom"] = TQString::number(m_margin->bottom()); - opts["kde-margin-right"] = TQString::number(m_margin->right()); - } - else - { - opts.remove("kde-margin-top"); - opts.remove("kde-margin-left"); - opts.remove("kde-margin-bottom"); - opts.remove("kde-margin-right"); - } -} diff --git a/kdeprint/kpmarginpage.h b/kdeprint/kpmarginpage.h deleted file mode 100644 index 4d52686fd..000000000 --- a/kdeprint/kpmarginpage.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPMARGINPAGE_H -#define KPMARGINPAGE_H - -#include "kprintdialogpage.h" - -class DrMain; -class MarginWidget; -class KPrinter; - -class KPMarginPage : public KPrintDialogPage -{ -public: - KPMarginPage(KPrinter *prt, DrMain *driver, TQWidget *parent = 0, const char *name = 0); - ~KPMarginPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected: - void initPageSize(const TQString&, bool); - -private: - MarginWidget *m_margin; - KPrinter *m_printer; - bool m_usedriver; -}; - -#endif diff --git a/kdeprint/kpposterpage.cpp b/kdeprint/kpposterpage.cpp deleted file mode 100644 index d82e5b572..000000000 --- a/kdeprint/kpposterpage.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpposterpage.h" -#include "posterpreview.h" -#include "kprinter.h" -#include "kmfactory.h" -#include "util.h" - -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqtooltip.h> -#include <tqlineedit.h> -#include <tqwhatsthis.h> -#include <kpushbutton.h> -#include <klocale.h> -#include <knuminput.h> -#include <kiconloader.h> - -KPPosterPage::KPPosterPage( TQWidget *parent, const char *name ) - : KPrintDialogPage( parent, name ) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThis5_PosterPage = i18n( " <qt> " - " 5. " - " </qt>" ); - - TQString whatsThisEnablePosterPage = i18n( " <qt> " - " <b>Print Poster</b> (enabled or disabled). " - " <p>If you enable this option, you can print posters of different sizes " - " The printout will happen in the form <em>'tiles'</em> printed on smaller " - " paper sizes, which you can stitch together later. <em>If you enable this " - " option here, the <em>'Poster Printing' filter</em> will be auto-loaded in " - " the 'Filters' tab of this dialog. </p>" - " <p>This tab is only visible if the external <em>'poster'</em> utility is " - " discovered by KDEPrint on your system. [<em>'poster'</em> is a commandline " - " utility that enables you to convert PostScript files into tiled printouts " - " which allow for oversized appearance of the stitched-together tiles.] </p>" - " <p><b>Note:</b> The standard version of 'poster' will not work. Your system " - " must use a patched version of 'poster'. Ask your operating system vendor to " - " provide a patched version of 'poster' if he does not already. </p>" - " <p><b>Additional hint for power users:</b> A patched version of 'poster' is " - " available from the <a href=\"http://printing.kde.org/\">KDEPrint Website</a> " - " at <a href=\"http://printing.kde.org/downloads/\">http://printing.kde.org/downloads/</a>. " - " The direct link to the patched source tarball is " - " <a href=\"ftp://ftp.kde.org/pub/kde/printing/poster.tar.bz2\">ftp://ftp.kde.org/pub/kde/printing/poster.tar.bz2</a> " - " </p> " - " </qt>" ); - - TQString whatsThisTileSelectionPosterPage = i18n( " <qt> " - " <b>Tile Selection widget</b> " - " <p>This GUI element is <em>not only for viewing</em> your selections: it also " - " lets you interactively select the tile(s) you want to print. " - " </p>" - " <p><b>Hints</b> " - " <ul> " - " <li>Click any tile to select it for printing.</li> " - " <li>To select multiple tiles to be printed " - " at once, <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the " - " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) " - " <em>Be aware</em> that the order " - " of your clicking is also significant to the order of printing the different tiles. </li>" - " </ul> " - " <b>Note 1:</b> The order of your selection (and the order for printout of the tiles) " - " is indicated by the contents of the text field below, " - " labelled as <em>'Tile pages (to be printed):'</em><p>" - " <b>Note 2:</b> By default no tile is selected. Before you can print (a part " - " of) your poster, you must select at least one tile. </p> " - " </qt>" ); - - TQString whatsThisPostersizePosterPage = i18n( " <qt> " - " <b>Poster Size</b> " - " <p>Select the poster size you want from the dropdown list. </p> " - " Available sizes are all standard paper sizes up to " - " 'A0'. [A0 is the same size as 16 sheets of A4, or '84cm x 118.2cm'.] </p> " - " <p><b>Notice</b>, how the little preview window below changes with your change of poster " - " size. It indicates to you how many tiles need to be printed to make the poster, " - " given the selected paper size.</p> " - " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click " - " on its individual tiles to select them for printing. To select multiple tiles to be printed " - " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the " - " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order " - " of your clicking is significant to the order of printing the different tiles. The order of " - " your selection (and for the printed tiles) is indicated by the contents of the text field " - " labelled as <em>'Tile pages (to be printed):'</em><p>" - " <b>Note:</b> By default no tile is selected. Before you can print (a part " - " of) your poster, you must select at least one tile. </p> " - " </qt>" ); - - TQString whatsThisPrintsizePosterPage = i18n( " <qt> " - " <b>Paper Size</b> " - " <p>This field indicates the paper size the poster tiles will be printed on. " - " To select a different paper size for your poster tiles, go to the 'General' tab " - " of this dialog and select one from the dropdown list. </p> " - " Available sizes are most standard paper sizes supported by your printer. Your printer's " - " supported paper sizes are read from the printer driver info (as laid down in the <em>'PPD'</em>, " - " the printer description file). <em>Be aware that the 'Paper Size' selected may not be supported " - " by 'poster' (example: 'HalfLetter') while it may well be supported by your printer.</em> If " - " you hit that obstacle, simply use another, supported Paper Size, like 'A4' or 'Letter'. " - " <p><b>Notice</b>, how the little preview window below changes with your change of paper " - " size. It indicates how many tiles need to be printed to make up the poster, " - " given the selected paper and poster size.</p> " - " <p><b>Hint:</b> The little preview window below is not just a passive icon. You can click " - " on its individual tiles to select them for printing. To select multiple tiles to be printed " - " at once, you need to <em>'shift-click'</em> on the tiles ('shift-click' means: hold down the " - " [SHIFT]-key on your keyboard and click with the mouse while [SHIFT]-key is held.) The order " - " of your clicking is significant to the order of printing the different tiles. The order of " - " your selection (and for the printed tiles) is indicated by the contents of the text field " - " labelled as <em>'Tile pages (to be printed):'</em><p>" - " <b>Note:</b> By default no tile is selected. Before you can print (a part " - " of) your poster, you must select at least one tile. </p> " - " </qt>" ); - - TQString whatsThisCutmarginPosterPage = i18n( " <qt> " - " <b>Cut Margin selection</b> " - " <p>Slider and spinbox let you determine a <em>'cut margin'</em> which will be printed onto " - " each tile of your poster to help you cut the pieces as needed. </p>" - " <p><b>Notice</b>, how the little preview window above changes with your change of cut " - " margins. It indicates to you how much space the cut margins will take away from each tile. " - " <p><b>Be aware</b>, that your cut margins need to be equal to or greater than the margins your " - " printer uses. The printer's capabilities are described in the <em>'ImageableArea'</em> " - " keywords of its driver PPD file. </p> " - " </qt>" ); - - TQString whatsThisTileOrderSelectionPosterPage = i18n( " <qt> " - " <b>Order and number of tile pages to be printed</b> " - " <p>This field displays and sets the individual tiles to be printed, as well as the order " - " for their printout. </p> " - " You can file the field with 2 different methods: " - " <ul> " - " <li>Either use the interactive thumbnail preview above and '[SHIFT]-click' on the tiles. </li> " - " <li>Or edit this text field accordingly. </li> " - " </ul> " - " <p>When editing the field, you can use a '3-7' syntax instead of a '3,4,5,6,7' one. </p> " - " <p><b>Examples:</b></p> " - " <pre> " - " \"2,3,7,9,3\" " - " <br> " - " \"1-3,6,8-11\" " - " </qt>" ); - - setTitle( i18n( "Poster" ) ); - - m_postercheck = new TQCheckBox( i18n( "&Print poster" ), this ); - TQWhatsThis::add(m_postercheck, whatsThisEnablePosterPage); - TQWidget *dummy = new TQWidget( this ); - m_preview = new PosterPreview( dummy ); - TQWhatsThis::add(m_preview, whatsThisTileSelectionPosterPage); - m_postersize = new TQComboBox( dummy ); - TQWhatsThis::add(m_postersize, whatsThisPostersizePosterPage); - m_printsize = new TQComboBox( dummy ); - TQWhatsThis::add(m_printsize, whatsThisPrintsizePosterPage); - m_lockbtn = new KPushButton( dummy ); - //TQWhatsThis::add(m_lockbtn, whatsThis5_PosterPage); //FIXME ASK_MICHAEL: which pushbutton would that be? - m_mediasize = new TQLabel( dummy ); - TQWhatsThis::add(m_mediasize, whatsThisPrintsizePosterPage); - m_mediasize->setFrameStyle( TQFrame::Panel|TQFrame::Sunken ); - TQLabel *posterlab = new TQLabel( i18n( "Poste&r size:" ), dummy ); - TQWhatsThis::add(posterlab, whatsThisPostersizePosterPage); - TQLabel *medialab = new TQLabel( i18n( "Media size:" ), dummy ); - TQWhatsThis::add(medialab, whatsThisPrintsizePosterPage); - TQLabel *printlab = new TQLabel( i18n( "Pri&nt size:" ), dummy ); - TQWhatsThis::add(printlab, whatsThisPrintsizePosterPage); - posterlab->setBuddy( m_postersize ); - printlab->setBuddy( m_printsize ); - m_cutmargin = new KIntNumInput( 5, dummy ); - TQWhatsThis::add(m_cutmargin, whatsThisCutmarginPosterPage); - // xgettext:no-c-format - m_cutmargin->setLabel( i18n( "C&ut margin (% of media):" ) ); - m_cutmargin->setRange( 0, 100, 2, true ); // step width was too big, changed from 10 to 2 (-kp-) - m_selection = new TQLineEdit( dummy ); - TQWhatsThis::add(m_selection, whatsThisTileOrderSelectionPosterPage); - TQLabel *selectionlab = new TQLabel( i18n( "&Tile pages (to be printed):" ), dummy ); - TQWhatsThis::add(selectionlab, whatsThisTileOrderSelectionPosterPage); - selectionlab->setBuddy( m_selection ); - m_lockbtn->setToggleButton( true ); - m_lockbtn->setPixmap( SmallIcon( "encrypted" ) ); - m_lockbtn->setOn( true ); - m_lockbtn->setFixedSize( m_lockbtn->tqsizeHint() ); - TQToolTip::add( m_lockbtn, i18n( "Link/unlink poster and print size" ) ); - - for ( int i=0; i<KPrinter::NPageSize-1; i++ ) - { - m_postersize->insertItem( page_sizes[ i ].text ); - m_printsize->insertItem( page_sizes[ i ].text ); - } - m_postersize->setCurrentItem( findIndex( KPrinter::A3 ) ); - slotPosterSizeChanged( m_postersize->currentItem() ); - - connect( m_postercheck, TQT_SIGNAL( toggled( bool ) ), dummy, TQT_SLOT( setEnabled( bool ) ) ); - dummy->setEnabled( false ); - connect( m_postersize, TQT_SIGNAL( activated( int ) ), TQT_SLOT( slotPosterSizeChanged( int ) ) ); - connect( m_cutmargin, TQT_SIGNAL( valueChanged( int ) ), TQT_SLOT( slotMarginChanged( int ) ) ); - connect( m_lockbtn, TQT_SIGNAL( toggled( bool ) ), m_printsize, TQT_SLOT( setDisabled( bool ) ) ); - m_printsize->setEnabled( false ); - connect( m_lockbtn, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( slotLockToggled( bool ) ) ); - connect( m_selection, TQT_SIGNAL( textChanged( const TQString& ) ), m_preview, TQT_SLOT( setSelectedPages( const TQString& ) ) ); - connect( m_preview, TQT_SIGNAL( selectionChanged( const TQString& ) ), m_selection, TQT_SLOT( setText( const TQString& ) ) ); - - if ( KMFactory::self()->settings()->application != KPrinter::Dialog - && KMFactory::self()->settings()->application >= 0 ) - { - m_printsize->hide(); - m_lockbtn->hide(); - printlab->hide(); - } - - TQVBoxLayout *l0 = new TQVBoxLayout( this, 0, 10 ); - l0->addWidget( m_postercheck ); - l0->addWidget( dummy, 1 ); - TQGridLayout *l1 = new TQGridLayout( dummy, 8, 3, 0, 5 ); - l1->addWidget( posterlab, 0, 0 ); - l1->addWidget( m_postersize, 0, 1 ); - l1->addWidget( printlab, 1, 0 ); - l1->addWidget( m_printsize, 1, 1 ); - l1->addWidget( medialab, 2, 0 ); - l1->addWidget( m_mediasize, 2, 1 ); - l1->addMultiCellWidget( m_preview, 4, 4, 0, 2 ); - l1->addMultiCellWidget( m_cutmargin, 6, 6, 0, 2 ); - l1->addMultiCellWidget( m_lockbtn, 0, 1, 2, 2 ); - TQHBoxLayout *l2 = new TQHBoxLayout( 0, 0, 5 ); - l1->addMultiCellLayout( l2, 7, 7, 0, 2 ); - l2->addWidget( selectionlab ); - l2->addWidget( m_selection ); - l1->setColStretch( 1, 1 ); - l1->setRowStretch( 4, 1 ); - l1->addRowSpacing( 3, 10 ); - l1->addRowSpacing( 5, 10 ); -} - -KPPosterPage::~KPPosterPage() -{ -} - -void KPPosterPage::setOptions( const TQMap<TQString,TQString>& opts ) -{ - TQString ps = opts[ "PageSize" ]; - if ( ps.isEmpty() && !opts[ "kde-pagesize" ].isEmpty() ) - { - ps = pageSizeToPageName( ( KPrinter::PageSize )opts[ "kde-pagesize" ].toInt() ); - if ( ps.isEmpty() ) - ps = opts[ "_kde-poster-media" ]; - } - if ( ps.isEmpty() ) - m_mediasize->setText( i18n( "Unknown" ) ); - else - m_mediasize->setText( ps ); - m_preview->setMediaSize( ps ); - - if ( opts[ "_kde-filters" ].find( "poster" ) != -1 ) - { - m_postercheck->setChecked( true ); - ps = opts[ "_kde-poster-size" ]; - TQString prtsize = opts[ "kde-printsize" ]; - if ( !ps.isEmpty() ) - { - m_postersize->setCurrentItem( findIndex( pageNameToPageSize( ps ) ) ); - m_lockbtn->setOn( !prtsize.isEmpty() && - page_sizes[ m_postersize->currentItem() ].ID == prtsize.toInt() ); - if ( !m_lockbtn->isOn() ) - m_printsize->setCurrentItem( findIndex( prtsize.toInt() ) ); - slotPosterSizeChanged( m_postersize->currentItem() ); - } - if ( !opts[ "_kde-poster-cut" ].isEmpty() ) - m_cutmargin->setValue( opts[ "_kde-poster-cut" ].toInt() ); - m_selection->setText( opts[ "_kde-poster-select" ] ); - } - else - m_postercheck->setChecked( false ); -} - -void KPPosterPage::getOptions( TQMap<TQString,TQString>& opts, bool ) -{ - TQStringList o = TQStringList::split( ",", opts[ "_kde-filters" ], false ); - if ( !m_postercheck->isChecked() ) - { - o.remove( "poster" ); - opts[ "_kde-filters" ] = o.join( "," ); - opts.remove( "_kde-poster-media" ); - opts.remove( "_kde-poster-size" ); - opts.remove( "_kde-poster-cut" ); - opts.remove( "kde-printsize" ); - opts.remove( "_kde-poster-select" ); - } - else - { - if ( !o.contains( "poster" ) ) - o.append( "poster" ); - opts[ "_kde-filters" ] = o.join( "," ); - opts[ "_kde-poster-media" ] = m_mediasize->text(); - opts[ "_kde-poster-size" ] = pageSizeToPageName( ( KPrinter::PageSize )page_sizes[ m_postersize->currentItem() ].ID ); - opts[ "kde-printsize" ] = TQString::number( page_sizes[ m_printsize->currentItem() ].ID ); - opts[ "_kde-poster-cut" ] = TQString::number( m_cutmargin->value() ); - opts[ "_kde-poster-select" ] = m_selection->text().stripWhiteSpace(); - } -} - -bool KPPosterPage::isValid() -{ - return true; -} - -void KPPosterPage::slotPosterSizeChanged( int value ) -{ - int ID = page_sizes[ m_postersize->currentItem() ].ID; - m_preview->setPosterSize( ID ); - if ( m_lockbtn->isOn() ) - m_printsize->setCurrentItem( value ); -} - -void KPPosterPage::slotMarginChanged( int value ) -{ - m_preview->setCutMargin( value ); -} - -void KPPosterPage::slotLockToggled( bool on ) -{ - m_lockbtn->setPixmap( SmallIcon( on ? "encrypted" : "decrypted" ) ); - if ( on ) - m_printsize->setCurrentItem( m_postersize->currentItem() ); -} - -#include "kpposterpage.moc" diff --git a/kdeprint/kpposterpage.h b/kdeprint/kpposterpage.h deleted file mode 100644 index ce4858aa3..000000000 --- a/kdeprint/kpposterpage.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPPOSTERPAGE_H -#define KPPOSTERPAGE_H - -#include "kprintdialogpage.h" - -class TQComboBox; -class TQCheckBox; -class TQLabel; -class PosterPreview; -class KIntNumInput; -class TQPushButton; -class TQLineEdit; - -class KPPosterPage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPPosterPage( TQWidget *parent = 0, const char *name = 0 ); - ~KPPosterPage(); - - void setOptions( const TQMap<TQString,TQString>& opts ); - void getOptions( TQMap<TQString,TQString>& opts, bool incldef = false ); - bool isValid(); - -protected slots: - void slotPosterSizeChanged( int ); - void slotMarginChanged( int ); - void slotLockToggled( bool ); - -private: - TQComboBox *m_postersize; - TQComboBox *m_printsize; - PosterPreview *m_preview; - TQCheckBox *m_postercheck; - TQLabel *m_mediasize; - KIntNumInput *m_cutmargin; - TQPushButton *m_lockbtn; - TQLineEdit *m_selection; -}; - -#endif /* KPPOSTERPAGE_H */ diff --git a/kdeprint/kpqtpage.cpp b/kdeprint/kpqtpage.cpp deleted file mode 100644 index e2c28ebb1..000000000 --- a/kdeprint/kpqtpage.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 "kpqtpage.h" -#include "kprinter.h" -#include "kxmlcommand.h" -#include "driver.h" -#include "util.h" - -#include <tqcombobox.h> -#include <tqbuttongroup.h> -#include <tqradiobutton.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> - -#include <kiconloader.h> -#include <klocale.h> -#include <kdebug.h> - -#define ORIENT_PORTRAIT_ID 0 -#define ORIENT_LANDSCAPE_ID 1 - -#define COLORMODE_COLOR_ID 0 -#define COLORMODE_GRAYSCALE_ID 1 - -#define NUP_1 0 -#define NUP_2 1 -#define NUP_4 2 -#define NUP_OTHER 3 - -//***************************************************************************************************** - -KPQtPage::KPQtPage(TQWidget *parent, const char *name) -: KPrintDialogPage(parent,name) -{ - init(); -} - -KPQtPage::KPQtPage(DrMain *driver, TQWidget *parent, const char *name) -: KPrintDialogPage(0, (driver && driver->findOption("PageSize") ? driver : 0), parent, name) -{ - init(); -} - -KPQtPage::~KPQtPage() -{ -} - -void KPQtPage::init() -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisColorModeOtPageLabel = i18n( " <qt> " - " <b>Selection of color mode:</b> You can choose between 2 options: " - " <ul><li><b>Color</b> and</li> " - " <li><b>Grayscale</b></li></ul> " - " <b>Note:</b> This selection field may be grayed out and made inactive. " - " This happens if KDEPrint can not retrieve " - " enough information about your print file. In this case the embedded color- or grayscale information " - " of your printfile, and the default handling of the printer take precedence. " - " </qt>" ); - TQString whatsThisPageSizeOtPageLabel = i18n( " <qt> " - " <b>Selection of page size:</b> Select paper size to be printed on from " - " the drop-down menu. " - " <p>The exact list of choices depends on the printer driver (\"PPD\") you have installed. " - " </qt>" ); - TQString whatsThisPagesPerSheetOtPageLabel = i18n( " <qt> " - " <b>Selection of pages per sheet:</b> " - " You can choose to print more than one page onto each sheet of paper. " - " This is sometimes useful to save paper. " - " <p><b>Note 1:</b> the page images get scaled down accordingly to print 2 or 4 pages per sheet. " - " The page image does not get scaled if you print 1 page per sheet (the default setting.). " - " <p><b>Note 2:</b> If you select multiple pages per sheet here, the scaling and re-arranging is done " - " by your printing system. " - " <p><b>Note 3, regarding \"Other\":</b> You cannot really select <em>Other</em> as the number of " - " pages to print on one sheet.\"Other\" is checkmarked here for information purposes only. " - " <p>To select 8, 9, 16 or other numbers of " - " pages per sheet: " - " <ul> " - " <li> go to the tab headlined \"Filter\"</li>" - " <li> enable the <em>Multiple Pages per Sheet</em> filter </li>" - " <li> and configure it (bottom-most button on the right of the \"Filters\" tab). </li>" - " </ul>" - " </qt>" ); - TQString whatsThisOrientationOtPageLabel = i18n( " <qt> " - " <b>Selection of image orientation:</b> Orientation of the printed " - " pageimage on your paper is controlled by the radio buttons. By default, " - " the orientation is <em>Portrait</em> " - " <p>You can select 2 alternatives: " - " <ul> " - " <li> <b>Portrait.</b>.Portrait is the default setting. </li> " - " <li> <b>Landscape.</b> </li> " - " </ul> " - " The icon changes according to your selection." - " </qt>" ); - setTitle(i18n("Print Format")); - - // widget creation - m_pagesize = new TQComboBox(this); - TQWhatsThis::add(m_pagesize, whatsThisPageSizeOtPageLabel); - TQLabel *m_pagesizelabel = new TQLabel(i18n("Page s&ize:"), this); - m_pagesizelabel->tqsetAlignment(Qt::AlignVCenter|Qt::AlignRight); - m_pagesizelabel->setBuddy(m_pagesize); - m_orientbox = new TQButtonGroup(0, Qt::Vertical, i18n("Orientation"), this); - TQWhatsThis::add(m_orientbox, whatsThisOrientationOtPageLabel); - m_colorbox = new TQButtonGroup(0, Qt::Vertical, i18n("Color Mode"), this); - TQWhatsThis::add(m_colorbox, whatsThisColorModeOtPageLabel); - TQRadioButton *m_portrait = new TQRadioButton(i18n("&Portrait"), m_orientbox); - TQWhatsThis::add(m_portrait, whatsThisOrientationOtPageLabel); - - TQRadioButton *m_landscape = new TQRadioButton(i18n("&Landscape"), m_orientbox); - TQWhatsThis::add(m_landscape, whatsThisOrientationOtPageLabel); - - m_orientpix = new TQLabel(m_orientbox); - m_orientpix->tqsetAlignment(Qt::AlignCenter); - TQWhatsThis::add(m_orientpix, whatsThisOrientationOtPageLabel); - - TQRadioButton *m_color = new TQRadioButton(i18n("Colo&r"), m_colorbox); - TQWhatsThis::add(m_color, whatsThisColorModeOtPageLabel); - - TQRadioButton *m_grayscale = new TQRadioButton(i18n("&Grayscale"), m_colorbox); - m_colorpix = new TQLabel(m_colorbox); - m_colorpix->tqsetAlignment(Qt::AlignCenter); - TQWhatsThis::add(m_colorpix, whatsThisColorModeOtPageLabel); - - m_nupbox = new TQButtonGroup(0, Qt::Vertical, i18n("Pages per Sheet"), this); - // TQWhatsThis::add(m_nupbox, whatsThisPagesPerSheetOtPageLabel); - TQRadioButton *m_nup1 = new TQRadioButton("&1", m_nupbox); - TQWhatsThis::add(m_nup1, whatsThisPagesPerSheetOtPageLabel); - TQRadioButton *m_nup2 = new TQRadioButton("&2", m_nupbox); - TQWhatsThis::add(m_nup2, whatsThisPagesPerSheetOtPageLabel); - TQRadioButton *m_nup4 = new TQRadioButton("&4", m_nupbox); - TQWhatsThis::add(m_nup4, whatsThisPagesPerSheetOtPageLabel); - TQRadioButton *m_nupother = new TQRadioButton(i18n("Ot&her"), m_nupbox); - TQWhatsThis::add(m_nupother, whatsThisPagesPerSheetOtPageLabel); - - m_nuppix = new TQLabel(m_nupbox); - m_nuppix->tqsetAlignment(Qt::AlignCenter); - TQWhatsThis::add(m_nuppix, whatsThisPagesPerSheetOtPageLabel); - - // layout creation - TQGridLayout *lay0 = new TQGridLayout(this, 3, 2, 0, 10); - lay0->setRowStretch(1,1); - lay0->setRowStretch(2,1); - lay0->addWidget(m_pagesizelabel,0,0); - lay0->addWidget(m_pagesize,0,1); - lay0->addWidget(m_orientbox,1,0); - lay0->addWidget(m_colorbox,1,1); - lay0->addWidget(m_nupbox,2,0); - TQGridLayout *lay1 = new TQGridLayout(m_orientbox->tqlayout(), 2, 2, 10); - lay1->addWidget(m_portrait,0,0); - lay1->addWidget(m_landscape,1,0); - lay1->addMultiCellWidget(m_orientpix,0,1,1,1); - TQGridLayout *lay2 = new TQGridLayout(m_colorbox->tqlayout(), 2, 2, 10); - lay2->addWidget(m_color,0,0); - lay2->addWidget(m_grayscale,1,0); - lay2->addMultiCellWidget(m_colorpix,0,1,1,1); - TQGridLayout *lay3 = new TQGridLayout(m_nupbox->tqlayout(), 4, 2, 5); - lay3->addWidget(m_nup1,0,0); - lay3->addWidget(m_nup2,1,0); - lay3->addWidget(m_nup4,2,0); - lay3->addWidget(m_nupother,3,0); - lay3->addMultiCellWidget(m_nuppix,0,3,1,1); - - // initialization - m_portrait->setChecked(true); - slotOrientationChanged(0); - m_color->setChecked(true); - slotColorModeChanged(0); - m_nup1->setChecked(true); - slotNupChanged(0); - - if (!KXmlCommandManager::self()->checkCommand("psnup")) - m_nupbox->setEnabled(false); - if (KPrinter::applicationType() != KPrinter::Dialog - && KPrinter::applicationType() >= 0 ) - { - m_orientbox->setEnabled(false); - m_colorbox->setEnabled(false); - m_pagesize->setEnabled(driver()); - m_pagesizelabel->setEnabled(driver()); - } - - if (!driver()) - { - for (int i=0; i<KPrinter::NPageSize-1; i++) - m_pagesize->insertItem(i18n(page_sizes[i].text)); - // default page size to locale settings - m_pagesize->setCurrentItem(findIndex((KPrinter::PageSize)(KGlobal::locale()->pageSize()))); - } - else - { - DrListOption *lopt = static_cast<DrListOption*>(driver()->findOption("PageSize")); - TQPtrListIterator<DrBase> it(*(lopt->choices())); - for (; it.current(); ++it) - { - m_pagesize->insertItem(it.current()->get("text")); - if (it.current() == lopt->currentChoice()) - m_pagesize->setCurrentItem(m_pagesize->count()-1); - } - } - - // connections - connect(m_orientbox,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotOrientationChanged(int))); - connect(m_colorbox,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotColorModeChanged(int))); - connect(m_nupbox,TQT_SIGNAL(clicked(int)),TQT_SLOT(slotNupChanged(int))); -} - -void KPQtPage::slotOrientationChanged(int ID) -{ - m_orientpix->setPixmap(UserIcon((ID == ORIENT_PORTRAIT_ID ? "tdeprint_portrait" : "tdeprint_landscape"))); -} - -void KPQtPage::slotColorModeChanged(int ID) -{ - m_colorpix->setPixmap(UserIcon((ID == COLORMODE_COLOR_ID ? "tdeprint_color" : "tdeprint_grayscale"))); -} - -void KPQtPage::slotNupChanged(int ID) -{ - QString pixstr; - switch (ID) - { - case NUP_1: pixstr = "tdeprint_nup1"; break; - case NUP_2: pixstr = "tdeprint_nup2"; break; - case NUP_4: pixstr = "tdeprint_nup4"; break; - case NUP_OTHER: pixstr = "tdeprint_nupother"; break; - } - m_nuppix->setPixmap(UserIcon(pixstr)); -} - -void KPQtPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - int ID = (opts["kde-orientation"] == "Landscape" ? ORIENT_LANDSCAPE_ID : ORIENT_PORTRAIT_ID); - m_orientbox->setButton(ID); - slotOrientationChanged(ID); - ID = (opts["kde-colormode"] == "GrayScale" ? COLORMODE_GRAYSCALE_ID : COLORMODE_COLOR_ID); - m_colorbox->setButton(ID); - slotColorModeChanged(ID); - if (driver()) - { - QString val = opts["PageSize"]; - if (!val.isEmpty()) - { - DrListOption *opt = static_cast<DrListOption*>(driver()->findOption("PageSize")); - DrBase *ch = opt->findChoice(val); - if (ch) - m_pagesize->setCurrentItem(opt->choices()->findRef(ch)); - } - } - else if (!opts["kde-pagesize"].isEmpty()) - m_pagesize->setCurrentItem(findIndex(opts["kde-pagesize"].toInt())); - ID = NUP_1; - if (opts["_kde-filters"].find("psnup") != -1) - { - if (opts.contains("_kde-psnup-nup")) { - ID = opts["_kde-psnup-nup"].toInt(); - if (ID == 1 || ID == 2 || ID == 4) - { - if (ID == 4) ID = 3; - ID--; - } - else - { - ID = NUP_OTHER; - } - } - else - { - ID = NUP_1; - } - } - m_nupbox->setButton(ID); - slotNupChanged(ID); - - if ( m_orientbox->isEnabled() ) - m_orientbox->setDisabled( opts[ "kde-orientation-fixed" ] == "1" ); - if ( m_pagesize->isEnabled() ) - m_pagesize->setDisabled( opts[ "kde-pagesize-fixed" ] == "1" ); -} - -void KPQtPage::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - opts["kde-orientation"] = (m_orientbox->id(m_orientbox->selected()) == ORIENT_LANDSCAPE_ID ? "Landscape" : "Portrait"); - opts["kde-colormode"] = (m_colorbox->id(m_colorbox->selected()) == COLORMODE_GRAYSCALE_ID ? "GrayScale" : "Color"); - if (driver()) - { - DrListOption *opt = static_cast<DrListOption*>(driver()->findOption("PageSize")); - if (opt) - { - DrBase *ch = opt->choices()->tqat(m_pagesize->currentItem()); - if (ch && (incldef || ch->name() != opt->get("default"))) - { - opts["PageSize"] = ch->name(); - } - } - } - else - opts["kde-pagesize"] = TQString::number(page_sizes[m_pagesize->currentItem()].ID); - int ID = m_nupbox->id(m_nupbox->selected()); - TQString s = opts["_kde-filters"]; - if (ID == NUP_1) - { - opts.remove("_kde-psnup-nup"); - } - else if (ID != NUP_OTHER) - { - int nup(ID == NUP_2 ? 2 : 4); - if (s.find("psnup") == -1) - { - TQStringList fl = TQStringList::split(',', s, false); - KXmlCommandManager::self()->insertCommand(fl, "psnup"); - s = fl.join(","); - } - opts["_kde-psnup-nup"] = TQString::number(nup); - } - opts["_kde-filters"] = s; -} -#include "kpqtpage.moc" diff --git a/kdeprint/kpqtpage.h b/kdeprint/kpqtpage.h deleted file mode 100644 index 0ab4361f4..000000000 --- a/kdeprint/kpqtpage.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPQTPAGE_H -#define KPQTPAGE_H - -#include "kprintdialogpage.h" - -#include <kdelibs_export.h> - -class TQButtonGroup; -class TQComboBox; -class TQLabel; -class DrMain; - -class KDEPRINT_EXPORT KPQtPage : public KPrintDialogPage -{ - Q_OBJECT -public: - KPQtPage(TQWidget *parent = 0, const char *name = 0); - KPQtPage(DrMain *driver, TQWidget *parent = 0, const char *name = 0); - ~KPQtPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected slots: - void slotOrientationChanged(int); - void slotColorModeChanged(int); - void slotNupChanged(int); - -protected: - void init(); - -protected: - TQButtonGroup *m_orientbox, *m_colorbox, *m_nupbox; - TQComboBox *m_pagesize; - TQLabel *m_orientpix, *m_colorpix, *m_nuppix; -}; - -#endif diff --git a/kdeprint/kpreloadobject.cpp b/kdeprint/kpreloadobject.cpp deleted file mode 100644 index af9e299cd..000000000 --- a/kdeprint/kpreloadobject.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kpreloadobject.h" -#include "kmfactory.h" - -KPReloadObject::KPReloadObject(bool priority) -{ - KMFactory::self()->registerObject(this, priority); -} - -KPReloadObject::~KPReloadObject() -{ - if ( KMFactory::exists() ) - KMFactory::self()->unregisterObject(this); -} diff --git a/kdeprint/kpreloadobject.h b/kdeprint/kpreloadobject.h deleted file mode 100644 index 09bbe97d6..000000000 --- a/kdeprint/kpreloadobject.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPRELOADOBJECT_H -#define KPRELOADOBJECT_H - -#include <kdelibs_export.h> - -class KDEPRINT_EXPORT KPReloadObject -{ -friend class KMFactory; -public: - KPReloadObject(bool priority = false); - virtual ~KPReloadObject(); - -protected: - virtual void reload() = 0; - virtual void aboutToReload() {} - virtual void configChanged() {} -}; - -#endif diff --git a/kdeprint/kprintaction.cpp b/kdeprint/kprintaction.cpp deleted file mode 100644 index e275ed559..000000000 --- a/kdeprint/kprintaction.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kprintaction.h" - -#include <kprinter.h> -#include <tdeprint/kmmanager.h> -#include <kiconloader.h> -#include <kpopupmenu.h> -#include <klocale.h> - -class KPrintAction::KPrintActionPrivate -{ -public: - KPrintActionPrivate() - { - type = All; - parentWidget = 0; - } - - PrinterType type; - QStringList printers; - TQWidget *parentWidget; -}; - -KPrintAction::KPrintAction(const TQString& text, PrinterType type, TQWidget *parentWidget, TQObject *parent, const char *name) -: KActionMenu(text, parent, name) -{ - d = new KPrintActionPrivate(); - initialize(type, parentWidget); -} - -KPrintAction::KPrintAction(const TQString& text, const TQIconSet& icon, PrinterType type, TQWidget *parentWidget, TQObject *parent, const char *name) -: KActionMenu(text, icon, parent, name) -{ - d = new KPrintActionPrivate(); - initialize(type, parentWidget); -} - -KPrintAction::KPrintAction(const TQString& text, const TQString& icon, PrinterType type, TQWidget *parentWidget, TQObject *parent, const char *name) -: KActionMenu(text, icon, parent, name) -{ - d = new KPrintActionPrivate(); - initialize(type, parentWidget); -} - -KPrintAction::~KPrintAction() -{ - delete d; -} - -void KPrintAction::initialize(PrinterType type, TQWidget *parentWidget) -{ - connect(popupMenu(), TQT_SIGNAL(aboutToShow()), TQT_SLOT(slotAboutToShow())); - connect(popupMenu(), TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); - - d->type = type; - d->parentWidget = parentWidget; -} - -void KPrintAction::slotAboutToShow() -{ - popupMenu()->clear(); - d->printers.clear(); - TQPtrList<KMPrinter> *prts = KMManager::self()->printerList(); - if (prts && !prts->isEmpty()) - { - TQPtrListIterator<KMPrinter> it(*prts); - bool first(false); - int ID(0); - for (; it.current(); ++it) - { - if (d->type == All || (d->type == Specials && it.current()->isSpecial()) || (d->type == Regular && !it.current()->isSpecial())) - { - if (d->type == All && !first && it.current()->isSpecial()) - { - if (popupMenu()->count() > 0) - popupMenu()->insertSeparator(); - first = true; - } - popupMenu()->insertItem(SmallIconSet(it.current()->pixmap()), it.current()->name(), ID++); - d->printers.append(it.current()->name()); - } - } - } -} - -void KPrintAction::slotActivated(int ID) -{ - KPrinter printer(false); - KMPrinter *mprt = KMManager::self()->findPrinter(d->printers[ID]); - if (mprt && mprt->autoConfigure(&printer, d->parentWidget)) - { - // emit the signal - emit print(&printer); - } -} - -KPrintAction* KPrintAction::exportAll(TQWidget *parentWidget, TQObject *parent, const char *name) -{ - return new KPrintAction(i18n("&Export..."), All, parentWidget, parent, (name ? name : "export_all")); -} - -KPrintAction* KPrintAction::exportRegular(TQWidget *parentWidget, TQObject *parent, const char *name) -{ - return new KPrintAction(i18n("&Export..."), Regular, parentWidget, parent, (name ? name : "export_regular")); -} - -KPrintAction* KPrintAction::exportSpecial(TQWidget *parentWidget, TQObject *parent, const char *name) -{ - return new KPrintAction(i18n("&Export..."), Specials, parentWidget, parent, (name ? name : "export_special")); -} - -#include "kprintaction.moc" diff --git a/kdeprint/kprintaction.h b/kdeprint/kprintaction.h deleted file mode 100644 index f6ba35d34..000000000 --- a/kdeprint/kprintaction.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPRINTACTION_H -#define KPRINTACTION_H - -#include <kaction.h> - -class KPrinter; - -class KDEPRINT_EXPORT KPrintAction : public KActionMenu -{ - Q_OBJECT -public: - enum PrinterType { All, Regular, Specials }; - - KPrintAction(const TQString& text, PrinterType type = All, TQWidget *parentWidget = 0, TQObject *parent = 0, const char *name = 0); - KPrintAction(const TQString& text, const TQIconSet& icon, PrinterType type = All, TQWidget *parentWidget = 0, TQObject *parent = 0, const char *name = 0); - KPrintAction(const TQString& text, const TQString& icon, PrinterType type = All, TQWidget *parentWidget = 0, TQObject *parent = 0, const char *name = 0); - virtual ~KPrintAction(); - - static KPrintAction* exportAll(TQWidget *parentWidget = 0, TQObject *parent = 0, const char *name = 0); - static KPrintAction* exportRegular(TQWidget *parentWidget = 0, TQObject *parent = 0, const char *name = 0); - static KPrintAction* exportSpecial(TQWidget *parentWidget = 0, TQObject *parent = 0, const char *name = 0); - -signals: - void print(KPrinter*); - -protected slots: - void slotAboutToShow(); - void slotActivated(int); - -protected: - void initialize(PrinterType type, TQWidget *parentWidget); - -private: - class KPrintActionPrivate; - KPrintActionPrivate *d; -}; - -#endif diff --git a/kdeprint/kprintdialog.cpp b/kdeprint/kprintdialog.cpp deleted file mode 100644 index 5cb56819e..000000000 --- a/kdeprint/kprintdialog.cpp +++ /dev/null @@ -1,987 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -/* - * "WhatsThis" help items added by Kurt Pfeifle, August 2003, - * same copyright as above. - **/ - -#include "kprintdialog.h" -#include "kprinter.h" -#include "kprinterimpl.h" -#include "kmfactory.h" -#include "kmuimanager.h" -#include "kmmanager.h" -#include "kmprinter.h" -#include "kmvirtualmanager.h" -#include "kprintdialogpage.h" -#include "kprinterpropertydialog.h" -#include "plugincombobox.h" -#include "kpcopiespage.h" -#include "treecombobox.h" -#include "messagewindow.h" - -#include <tqgroupbox.h> -#include <tqcheckbox.h> -#include <kpushbutton.h> -#include <tqlabel.h> -#include <tqcombobox.h> -#include <tqtabwidget.h> -#include <tqvbox.h> -#include <tqlayout.h> -#include <tqregexp.h> -#include <kmessagebox.h> -#include <tqdir.h> -#include <tqtooltip.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <kiconloader.h> -#include <kfiledialog.h> -#include <kurlrequester.h> -#include <klineedit.h> -#include <kdebug.h> -#include <kglobal.h> -#include <kconfig.h> -#include <kguiitem.h> -#include <kstdguiitem.h> -#include <kapplication.h> -#include <kio/renamedlg.h> - -#include <time.h> - -#define SHOWHIDE(widget,on) if (on) widget->show(); else widget->hide(); - -class KPrintDialog::KPrintDialogPrivate -{ -public: - TQLabel *m_type, *m_state, *m_comment, *m_location, *m_cmdlabel, *m_filelabel; - KPushButton *m_properties, *m_default, *m_options, *m_ok, *m_extbtn; - TQPushButton *m_wizard, *m_filter; - TQCheckBox *m_preview; - TQLineEdit *m_cmd; - TreeComboBox *m_printers; - TQVBox *m_dummy; - PluginComboBox *m_plugin; - KURLRequester *m_file; - TQCheckBox *m_persistent; - bool m_reduced; - - TQPtrList<KPrintDialogPage> m_pages; - KPrinter *m_printer; - bool b_optionsEnabled; - bool b_propertiesEnabled; - bool b_systemEnabled; -}; - -KPrintDialog::KPrintDialog(TQWidget *parent, const char *name) -: KDialog(parent,name,true) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisLocationLabel = i18n( " <qt><b>Printer Location:</b> The <em>Location</em> may describe where the" - " selected printer is located. The Location description is created" - " by the administrator of the print system (or may be" - " left empty)." - " </qt>" ); - TQString whatsThisPrinterType = i18n( " <qt><b>Printer Type:</b> The <em>Type</em> indicates your printer type." - " </qt>" ); - TQString whatsThisPrinterState = i18n( " <qt><b>Printer State:</b> The <em>State</em> indicates the state of the" - " print queue on the print server (which could be your localhost). The" - " state may be 'Idle', 'Processing', 'Stopped', 'Paused' or similar." - " </qt>" ); - TQString whatsThisPrinterComment = i18n( " <qt><b>Printer Comment:</b> The <em>Comment</em> may describe the selected" - " printer. This comment is created by the administrator" - " of the print system (or may be left empty)." - " </qt>" ); - TQString whatsThisPrinterSelect = i18n( " <qt><b>Printer Selection Menu:</b> " - " <p>Use this combo box to select the printer to which you want to print." - " Initially (if you run KDEPrint for the first time), you may only find the " - " <em>KDE special printers</em> (which save" - " jobs to disk [as PostScript- or PDF-files], or deliver jobs via" - " email (as a PDF" - " attachment). If you are missing a real printer, you need to..." - " <ul>" - " <li>...either create a local printer with the help of the <em>KDE Add" - " Printer Wizard</em>. The Wizard is available for the CUPS and RLPR printing" - " systems (click button to the left of the <em>'Properties'</em> button),</li>" - " <li>...or try to connect to an existing remote" - " CUPS print server. You can connect by clicking the <em>'System Options'</em> button" - " below. A new dialog opens: click on the <em>'CUPS server'</em>" - " icon: Fill in the information required to use the remote" - " server. </li> " - " </ul>" - " <p><b>Note:</b> It may happen that you successfully connected to a remote CUPS " - " server and still do not get a printer list. If this happens: force KDEPrint to " - " re-load its configuration files." - " To reload the configuration files, either start kprinter again, or use the " - " switch the print system away from CUPS and back again once. The print system switch " - " can be made through a selection in the drop-down menu at bottom of this dialog when " - " fully expanded). </p> " - " </qt>" ); - TQString whatsThisPrintJobProperties = i18n( " <qt><b>Print Job Properties:</b> " - " <p>This button opens a dialog where you can make decisions" - " regarding all supported print job options." - " </qt>" ); - TQString whatsThisPrinterFilter = i18n( " <qt><b>Selective View on List of Printers:</b>" - " <p> This button reduces the list of visible printers" - " to a shorter, more convenient, pre-defined list.</p>" - " <p>This is particularly useful in enterprise environments" - " with lots of printers. The default is to show <b>all</b> printers.</p>" - " <p>To create a personal <em>'selective view list'</em>, click on the" - " <em>'System Options'</em> button at the bottom of this dialog." - " Then, in the new dialog, select <em>'Filter'</em> (left column in the" - " <em>KDE Print Configuration</em> dialog) and setup your selection..</p>" - " <p><b>Warning:</b> Clicking this button without prior creation of a personal " - " <em>'selective view list'</em> will make all printers dissappear from the " - " view. (To re-enable all printers, just click this button again.) </p> " - " </qt>" ); - TQString whatsThisAddPrinterWizard = i18n( "<qt><b>KDE Add Printer Wizard</b>" - " <p>This button starts the <em>KDE Add Printer Wizard</em>.</p>" - " <p>Use the Wizard (with <em>\"CUPS\"</em> or <em>\"RLPR\"</em>) to add locally" - " defined printers to your system. </p>" - " <p><b>Note:</b> The <em>KDE Add Printer Wizard</em> does <b>not</b> work, " - " and this button is disabled if you use " - " <em>\"Generic LPD</em>\", <em>\"LPRng\"</em>, or <em>\"Print Through " - " an External Program</em>\".) </p> " - " </qt>" ); - TQString whatsThisExternalPrintCommand = i18n( " <qt><b>External Print Command</b>" - " <p>Here you can enter any command that would also print for you in " - " a <em>konsole</em> window. </p>" - " <b>Example:</b> <pre>a2ps -P <printername> --medium=A3</pre>." - " </qt>" ); - TQString whatsThisOptions = i18n( " <qt><b>Additional Print Job Options</b>" - " <p>This button shows or hides additional printing options.</qt>" ); - TQString whatsThisSystemOptions = i18n( " <qt><b>System Options:</b> " - " <p>This button starts a new dialog where you can adjust various" - " settings of your printing system. Amongst them:" - " <ul><li> Should KDE" - " applications embed all fonts into the PostScript they" - " generate for printing?" - " <li> Should KDE use an external PostScript viewer" - " like <em>gv</em> for print page previews?" - " <li> Should KDEPrint use a local or a remote CUPS server?," - " </ul> and many more.... " - " </qt>" ); - - TQString whatsThisHelpButton = i18n( " <qt><b>Help:</b> This button takes you to the complete <em>KDEPrint" - " Manual</em>." - " </qt>" ); - - TQString whatsThisCancelButton = i18n( " <qt><b>Cancel:</b> This button cancels your print job and quits the" - " kprinter dialog." - " </qt>" ); - - TQString whatsThisPrintButton = i18n( " <qt><b>Print:</b> This button sends the job to the printing process." - " If you are sending non-PostScript files, you may be" - " asked if you want KDE to convert the files into PostScript," - " or if you want your print subsystem (like CUPS) to do this." - " </qt>" ); - - TQString whatsThisKeepDialogOpenCheckbox = i18n( " <qt><b>Keep Printing Dialog Open</b>" - "<p>If you enable this checkbox, the printing dialog" - " stays open after you hit the <em>Print</em> button.</p>" - " <p> This is" - " especially useful, if you need to test various" - " print settings (like color matching for an inkjet printer)" - " or if you want to send your job to multiple printers (one after" - " the other) to have it finished more quickly.</p>" - " </qt>" ); - - TQString whatsThisOutputFileLabel = i18n(" <qt><b>Output File Name and Path:</b> The \"Output file:\" shows " - " you where your file will be" - " saved if you decide to \"Print to File\" your job, using one of the" - " KDE <em>Special Printers</em> named \"Print to File (PostScript)\"" - " or \"Print to File (PDF)\". Choose a name and location that suits" - " your need by using the button and/or editing the line on the right." - " </qt>" ); - - TQString whatsThisOutputFileLineedit = i18n(" <qt><b>Output File Name and Path:</b> Edit this line to create a " - " path and filename that suits your needs." - " (Button and Lineedit field are only available if you \"Print to File\")" - " </qt>" ); - - TQString whatsThisOutputFileButton = i18n(" <qt><b>Browse Directories button:<b> This button calls " - " the \"File Open / Browsed Directories\" dialog to let you" - " choose a directory and file name where your \"Print-to-File\"" - " job should be saved." - " </qt>" ); - - TQString whatsThisAddFileButton = i18n( " <qt><b>Add File to Job</b>" - " <p>This button calls the \"File Open / Browse Directories\" dialog to allow you" - " to select a file for printing. Note, that " - " <ul><li>you can select ASCII or International Text, PDF," - " PostScript, JPEG, TIFF, PNG, GIF and many other graphical" - " formats." - " <li>you can select various files from different paths" - " and send them as one \"multi-file job\" to the printing" - " system." - " </ul>" - " </qt>" ); - - TQString whatsThisPreviewCheckBox = i18n(" <qt><b>Print Preview</b>" - " Enable this checkbox if you want to see a preview of" - " your printout. A preview lets you check if, for instance," - " your intended \"poster\" or \"pamphlet\" layout" - " looks like you expected, without wasting paper first. It" - " also lets you cancel the job if something looks wrong. " - " <p><b>Note:</b> The preview feature (and therefore this checkbox) " - " is only visible for printjobs created from inside KDE applications. " - " If you start kprinter from the commandline, or if you use kprinter " - " as a print command for non-KDE applications (like Acrobat Reader, " - " Firefox or OpenOffice), print preview is not available here. " - " </qt>" ); - - TQString whatsThisSetDefaultPrinter = i18n(" <qt><b>Set as Default Printer</b>" - " This button sets the current printer as the user's" - " default. " - " <p><b>Note:</b> (Button is only visible if the checkbox for " - " <em>System Options</em>" - " --> <em>General</em> --> <em>Miscellaneous</em>: <em>\"Defaults" - " to the last printer used in the application\"</em> is disabled.)" - " </qt>" ); - d = new KPrintDialogPrivate; - - d->m_pages.setAutoDelete(false); - d->m_printer = 0; - setCaption(i18n("Print")); - - // widget creation - TQGroupBox *m_pbox = new TQGroupBox(0,Qt::Vertical,i18n("Printer"), this); - d->m_type = new TQLabel(m_pbox); - TQWhatsThis::add(d->m_type, whatsThisPrinterType); - d->m_state = new TQLabel(m_pbox); - TQWhatsThis::add(d->m_state, whatsThisPrinterState); - d->m_comment = new TQLabel(m_pbox); - TQWhatsThis::add(d->m_comment, whatsThisPrinterComment); - d->m_location = new TQLabel(m_pbox); - TQWhatsThis::add(d->m_location, whatsThisLocationLabel); - - d->m_printers = new TreeComboBox(m_pbox); - TQWhatsThis::add(d->m_printers, whatsThisPrinterSelect); - d->m_printers->setMinimumHeight(25); - TQLabel *m_printerlabel = new TQLabel(i18n("&Name:"), m_pbox); - TQWhatsThis::add(m_printerlabel, whatsThisPrinterSelect); - TQLabel *m_statelabel = new TQLabel(i18n("Status", "State:"), m_pbox); - TQWhatsThis::add(m_statelabel, whatsThisPrinterState); - TQLabel *m_typelabel = new TQLabel(i18n("Type:"), m_pbox); - TQWhatsThis::add(m_typelabel, whatsThisPrinterType); - TQLabel *m_locationlabel = new TQLabel(i18n("Location:"), m_pbox); - TQWhatsThis::add(m_locationlabel, whatsThisLocationLabel); - TQLabel *m_commentlabel = new TQLabel(i18n("Comment:"), m_pbox); - TQWhatsThis::add(m_commentlabel, whatsThisPrinterComment); - m_printerlabel->setBuddy(d->m_printers); - d->m_properties = new KPushButton(KGuiItem(i18n("P&roperties"), "edit"), m_pbox); - TQWhatsThis::add( d->m_properties, whatsThisPrintJobProperties); - d->m_options = new KPushButton(KGuiItem(i18n("System Op&tions"), "tdeprint_configmgr"), this); - TQWhatsThis::add(d->m_options,whatsThisSystemOptions); - d->m_default = new KPushButton(KGuiItem(i18n("Set as &Default"), "tdeprint_defaultsoft"), m_pbox); - TQWhatsThis::add(d->m_default,whatsThisSetDefaultPrinter); - d->m_filter = new TQPushButton(m_pbox); - d->m_filter->setPixmap(SmallIcon("filter")); - d->m_filter->setMinimumSize(TQSize(d->m_printers->minimumHeight(),d->m_printers->minimumHeight())); - d->m_filter->setToggleButton(true); - d->m_filter->setOn(KMManager::self()->isFilterEnabled()); - TQToolTip::add(d->m_filter, i18n("Toggle selective view on printer list")); - TQWhatsThis::add(d->m_filter, whatsThisPrinterFilter); - d->m_wizard = new TQPushButton(m_pbox); - d->m_wizard->setPixmap(SmallIcon("wizard")); - d->m_wizard->setMinimumSize(TQSize(d->m_printers->minimumHeight(),d->m_printers->minimumHeight())); - TQToolTip::add(d->m_wizard, i18n("Add printer...")); - TQWhatsThis::add(d->m_wizard, whatsThisAddPrinterWizard); - d->m_ok = new KPushButton(KGuiItem(i18n("&Print"), "fileprint"), this); - TQWhatsThis::add( d->m_ok, whatsThisPrintButton); - d->m_ok->setDefault(true); - d->m_ok->setEnabled( false ); - TQPushButton *m_cancel = new KPushButton(KStdGuiItem::cancel(), this); - TQWhatsThis::add(m_cancel, whatsThisCancelButton); - d->m_preview = new TQCheckBox(i18n("Previe&w"), m_pbox); - TQWhatsThis::add(d->m_preview, whatsThisPreviewCheckBox); - d->m_filelabel = new TQLabel(i18n("O&utput file:"), m_pbox); - TQWhatsThis::add(d->m_filelabel,whatsThisOutputFileLabel); - d->m_file = new KURLRequester(TQDir::homeDirPath()+"/print.ps", m_pbox); - TQWhatsThis::add(d->m_file,whatsThisOutputFileLineedit); - d->m_file->setEnabled(false); - d->m_filelabel->setBuddy(d->m_file); - d->m_cmdlabel = new TQLabel(i18n("Print co&mmand:"), m_pbox); - TQWhatsThis::add( d->m_cmdlabel, whatsThisExternalPrintCommand); - - d->m_cmd = new TQLineEdit(m_pbox); - TQWhatsThis::add( d->m_cmd, whatsThisExternalPrintCommand); - d->m_cmdlabel->setBuddy(d->m_cmd); - d->m_dummy = new TQVBox(this); - d->m_plugin = new PluginComboBox(this); - d->m_extbtn = new KPushButton(this); - TQToolTip::add(d->m_extbtn, i18n("Show/hide advanced options")); - TQWhatsThis::add(d->m_extbtn, whatsThisOptions); - d->m_persistent = new TQCheckBox(i18n("&Keep this dialog open after printing"), this); - TQWhatsThis::add( d->m_persistent, whatsThisKeepDialogOpenCheckbox); - TQPushButton *m_help = new KPushButton(KStdGuiItem::help(), this); - TQWhatsThis::add( m_help, whatsThisHelpButton); - - TQWidget::setTabOrder( d->m_printers, d->m_filter ); - TQWidget::setTabOrder( d->m_filter, d->m_wizard ); - TQWidget::setTabOrder( d->m_wizard, d->m_properties ); - TQWidget::setTabOrder( d->m_properties, d->m_preview ); - TQWidget::setTabOrder( d->m_preview, d->m_file ); - TQWidget::setTabOrder( d->m_file, d->m_cmd ); - TQWidget::setTabOrder( d->m_plugin, d->m_persistent ); - TQWidget::setTabOrder( d->m_persistent, d->m_extbtn ); - TQWidget::setTabOrder( d->m_extbtn, d->m_options ); - TQWidget::setTabOrder( d->m_options, m_help ); - TQWidget::setTabOrder( m_help, d->m_ok ); - TQWidget::setTabOrder( d->m_ok, m_cancel ); - - // layout creation - TQVBoxLayout *l1 = new TQVBoxLayout(this, 10, 10); - l1->addWidget(m_pbox,0); - l1->addWidget(d->m_dummy,1); - l1->addWidget(d->m_plugin,0); - l1->addWidget(d->m_persistent); - TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 10); - l1->addLayout(l2); - l2->addWidget(d->m_extbtn,0); - l2->addWidget(d->m_options,0); - l2->addWidget(m_help,0); - l2->addStretch(1); - l2->addWidget(d->m_ok,0); - l2->addWidget(m_cancel,0); - TQGridLayout *l3 = new TQGridLayout(m_pbox->tqlayout(),3,3,7); - l3->setColStretch(1,1); - l3->setRowStretch(0,1); - TQGridLayout *l4 = new TQGridLayout(0, 5, 2, 0, 5); - l3->addMultiCellLayout(l4,0,0,0,1); - l4->addWidget(m_printerlabel,0,0); - l4->addWidget(m_statelabel,1,0); - l4->addWidget(m_typelabel,2,0); - l4->addWidget(m_locationlabel,3,0); - l4->addWidget(m_commentlabel,4,0); - TQHBoxLayout *ll4 = new TQHBoxLayout(0, 0, 3); - l4->addLayout(ll4,0,1); - ll4->addWidget(d->m_printers,1); - ll4->addWidget(d->m_filter,0); - ll4->addWidget(d->m_wizard,0); - //l4->addWidget(d->m_printers,0,1); - l4->addWidget(d->m_state,1,1); - l4->addWidget(d->m_type,2,1); - l4->addWidget(d->m_location,3,1); - l4->addWidget(d->m_comment,4,1); - l4->setColStretch(1,1); - TQVBoxLayout *l5 = new TQVBoxLayout(0, 0, 10); - l3->addLayout(l5,0,2); - l5->addWidget(d->m_properties,0); - l5->addWidget(d->m_default,0); - l5->addWidget(d->m_preview,0); - l5->addStretch(1); - //*** - l3->addWidget(d->m_filelabel,1,0); - l3->addWidget(d->m_file,1,1); - //*** - l3->addWidget(d->m_cmdlabel,2,0); - l3->addMultiCellWidget(d->m_cmd,2,2,1,2); - - // connections - connect(d->m_ok,TQT_SIGNAL(clicked()),TQT_SLOT(accept())); - connect(m_cancel,TQT_SIGNAL(clicked()),TQT_SLOT(reject())); - connect(d->m_properties,TQT_SIGNAL(clicked()),TQT_SLOT(slotProperties())); - connect(d->m_default,TQT_SIGNAL(clicked()),TQT_SLOT(slotSetDefault())); - connect(d->m_printers,TQT_SIGNAL(activated(int)),TQT_SLOT(slotPrinterSelected(int))); - connect(d->m_options,TQT_SIGNAL(clicked()),TQT_SLOT(slotOptions())); - connect(d->m_wizard,TQT_SIGNAL(clicked()),TQT_SLOT(slotWizard())); - connect(d->m_extbtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotExtensionClicked())); - connect(d->m_filter, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotToggleFilter(bool))); - connect(m_help, TQT_SIGNAL(clicked()), TQT_SLOT(slotHelp())); - connect(d->m_file, TQT_SIGNAL(urlSelected(const TQString&)), TQT_SLOT(slotOutputFileSelected(const TQString&))); - connect( d->m_file, TQT_SIGNAL( openFileDialog( KURLRequester* ) ), TQT_SLOT( slotOpenFileDialog() ) ); - connect( KMFactory::self()->manager(), TQT_SIGNAL( updatePossible( bool ) ), TQT_SLOT( slotUpdatePossible( bool ) ) ); - - d->b_optionsEnabled = kapp->authorize("print/options") && kapp->authorize("print/selection"); - d->b_propertiesEnabled = kapp->authorize("print/properties") && kapp->authorize("print/selection"); - d->b_systemEnabled = kapp->authorize("print/system") && kapp->authorize("print/selection"); - - if (!d->b_systemEnabled) - { - d->m_plugin->hide(); - } - - if (!d->b_optionsEnabled) - { - d->m_options->hide(); - } - - if (!d->b_propertiesEnabled) - { - d->m_properties->hide(); - d->m_wizard->hide(); - } - - if (!kapp->authorize("print/selection")) - { - d->m_extbtn->hide(); - m_pbox->hide(); - - expandDialog(true); - } - else - { - KConfig *config = KGlobal::config(); - config->setGroup("KPrinter Settings"); - expandDialog(!config->readBoolEntry("DialogReduced", (KMFactory::self()->settings()->application != KPrinter::StandAlone))); - } -} - -KPrintDialog::~KPrintDialog() -{ - KConfig *config = KGlobal::config(); - config->setGroup("KPrinter Settings"); - config->writeEntry("DialogReduced", d->m_reduced); - - delete d; -} - -void KPrintDialog::setFlags(int f) -{ - SHOWHIDE(d->m_properties, (f & KMUiManager::Properties) && d->b_propertiesEnabled) - d->m_default->hide(); - SHOWHIDE(d->m_default, ((f & KMUiManager::Default) && !KMFactory::self()->printConfig("General")->readBoolEntry("UseLast", true))) - SHOWHIDE(d->m_preview, (f & KMUiManager::Preview)) - bool on = (f & KMUiManager::OutputToFile); - SHOWHIDE(d->m_filelabel, on) - SHOWHIDE(d->m_file, on) - on = (f & KMUiManager::PrintCommand); - SHOWHIDE(d->m_cmdlabel, on) - SHOWHIDE(d->m_cmd, on) - SHOWHIDE(d->m_persistent, (f & KMUiManager::Persistent)) - - // also update "wizard" button - KMManager *mgr = KMFactory::self()->manager(); - d->m_wizard->setEnabled((mgr->hasManagement() && (mgr->printerOperationMask() & KMManager::PrinterCreation))); -} - -void KPrintDialog::setDialogPages(TQPtrList<KPrintDialogPage> *pages) -{ - if (!pages) return; - if (pages->count() + d->m_pages.count() == 1) - { - // only one page, reparent the page to d->m_dummy and remove any - // TQTabWidget child if any. - if (pages->count() > 0) - d->m_pages.append(pages->take(0)); - d->m_pages.first()->reparent(d->m_dummy, TQPoint(0,0)); - d->m_pages.first()->show(); - delete d->m_dummy->child("TabWidget", TQTABWIDGET_OBJECT_NAME_STRING); - } - else - { - // more than one page. - TQTabWidget *tabs = static_cast<TQTabWidget*>(TQT_TQWIDGET(d->m_dummy->child("TabWidget", TQTABWIDGET_OBJECT_NAME_STRING))); - if (!tabs) - { - // TQTabWidget doesn't exist. Create it and reparent all - // already existing pages. - tabs = new TQTabWidget(d->m_dummy, "TabWidget"); - tabs->setMargin(10); - for (d->m_pages.first(); d->m_pages.current(); d->m_pages.next()) - { - tabs->addTab(d->m_pages.current(), d->m_pages.current()->title()); - } - } - while (pages->count() > 0) - { - KPrintDialogPage *page = pages->take(0); - d->m_pages.append(page); - tabs->addTab(page, page->title()); - } - tabs->show(); - } - d->m_extbtn->setEnabled(d->m_pages.count() > 0); -} - -KPrintDialog* KPrintDialog::printerDialog(KPrinter *printer, TQWidget *parent, const TQString& caption, bool forceExpand) -{ - if (printer) - { - KPrintDialog *dlg = new KPrintDialog(parent); - // needs to set the printer before setting up the - // print dialog as some additional pages may need it. - // Real initialization comes after. - dlg->d->m_printer = printer; - KMFactory::self()->uiManager()->setupPrintDialog(dlg); - dlg->init(); - if (!caption.isEmpty()) - dlg->setCaption(caption); - if (forceExpand) - { - // we force the dialog to be expanded: - // - expand the dialog - // - hide the show/hide button - dlg->expandDialog(true); - dlg->d->m_extbtn->hide(); - } - return dlg; - } - return NULL; -} - -void KPrintDialog::initialize(KPrinter *printer) -{ - d->m_printer = printer; - - // first retrieve printer list and update combo box (get default or last used printer also) - TQPtrList<KMPrinter> *plist = KMFactory::self()->manager()->printerList(); - if (!KMManager::self()->errorMsg().isEmpty()) - { - KMessageBox::error(parentWidget(), - "<qt><nobr>"+ - i18n("An error occurred while retrieving the printer list:") - +"</nobr><br><br>"+KMManager::self()->errorMsg()+"</qt>"); - } - - if (plist) - { - QString oldP = d->m_printers->currentText(); - d->m_printers->clear(); - TQPtrListIterator<KMPrinter> it(*plist); - int defsoft(-1), defhard(-1), defsearch(-1); - bool sep(false); - for (;it.current();++it) - { - // skip invalid printers - if ( !it.current()->isValid() ) - continue; - - if (!sep && it.current()->isSpecial()) - { - sep = true; - d->m_printers->insertItem(TQPixmap(), TQString::tqfromLatin1("--------")); - } - d->m_printers->insertItem(SmallIcon(it.current()->pixmap(),0,(it.current()->isValid() ? (int)KIcon::DefaultState : (int)KIcon::LockOverlay)),it.current()->name(),false/*sep*/); - if (it.current()->isSoftDefault()) - defsoft = d->m_printers->count()-1; - if (it.current()->isHardDefault()) - defhard = d->m_printers->count()-1; - if (!oldP.isEmpty() && oldP == it.current()->name()) - defsearch = d->m_printers->count()-1; - else if (defsearch == -1 && it.current()->name() == printer->searchName()) - defsearch = d->m_printers->count()-1; - } - int defindex = (defsearch != -1 ? defsearch : (defsoft != -1 ? defsoft : QMAX(defhard,0))); - d->m_printers->setCurrentItem(defindex); - //slotPrinterSelected(defindex); - } - - // Initialize output filename - if (!d->m_printer->outputFileName().isEmpty()) - d->m_file->setURL( d->m_printer->outputFileName() ); - else if (!d->m_printer->docFileName().isEmpty()) - d->m_file->setURL( d->m_printer->docDirectory()+"/"+d->m_printer->docFileName()+".ps" ); - - if ( d->m_printers->count() > 0 ) - slotPrinterSelected( d->m_printers->currentItem() ); - - // update with KPrinter options - if (d->m_printer->option("kde-preview") == "1" || d->m_printer->previewOnly()) - d->m_preview->setChecked(true); - d->m_preview->setEnabled(!d->m_printer->previewOnly()); - d->m_cmd->setText(d->m_printer->option("kde-printcommand")); - TQPtrListIterator<KPrintDialogPage> it(d->m_pages); - for (;it.current();++it) - it.current()->setOptions(d->m_printer->options()); -} - -void KPrintDialog::slotPrinterSelected(int index) -{ - bool ok(false); - d->m_location->setText(TQString::null); - d->m_state->setText(TQString::null); - d->m_comment->setText(TQString::null); - d->m_type->setText(TQString::null); - if (index >= 0 && index < d->m_printers->count()) - { - KMManager *mgr = KMFactory::self()->manager(); - KMPrinter *p = mgr->findPrinter(d->m_printers->text(index)); - if (p) - { - if (!p->isSpecial()) mgr->completePrinterShort(p); - d->m_location->setText(p->location()); - d->m_comment->setText(p->driverInfo()); - d->m_type->setText(p->description()); - d->m_state->setText(p->stateString()); - ok = p->isValid(); - enableSpecial(p->isSpecial()); - enableOutputFile(p->option("kde-special-file") == "1"); - setOutputFileExtension(p->option("kde-special-extension")); - } - else - enableOutputFile( ok ); - } - d->m_properties->setEnabled(ok); - d->m_ok->setEnabled(ok); -} - -void KPrintDialog::slotProperties() -{ - if (!d->m_printer) return; - - KMPrinter *prt = KMFactory::self()->manager()->findPrinter(d->m_printers->currentText()); - if (prt) - KPrinterPropertyDialog::setupPrinter(prt, this); -} - -void KPrintDialog::slotSetDefault() -{ - KMPrinter *p = KMFactory::self()->manager()->findPrinter(d->m_printers->currentText()); - if (p) - KMFactory::self()->virtualManager()->setDefault(p); -} - -void KPrintDialog::done(int result) -{ - if (result == Accepted && d->m_printer) - { - TQMap<TQString,TQString> opts; - KMPrinter *prt(0); - - // get options from global pages - TQString msg; - TQPtrListIterator<KPrintDialogPage> it(d->m_pages); - for (;it.current();++it) - if (it.current()->isEnabled()) - { - if (it.current()->isValid(msg)) - it.current()->getOptions(opts); - else - { - KMessageBox::error(this, msg.prepend("<qt>").append("</qt>")); - return; - } - } - - // add options from the dialog itself - // TODO: ADD PRINTER CHECK MECHANISM !!! - prt = KMFactory::self()->manager()->findPrinter(d->m_printers->currentText()); - if (prt->isSpecial() && prt->option("kde-special-file") == "1") - { - if (!checkOutputFile()) return; - d->m_printer->setOutputToFile(true); - /* be sure to decode the output filename */ - d->m_printer->setOutputFileName( KURL::decode_string( d->m_file->url() ) ); - } - else - d->m_printer->setOutputToFile(false); - d->m_printer->setPrinterName(prt->printerName()); - d->m_printer->setSearchName(prt->name()); - opts["kde-printcommand"] = d->m_cmd->text(); - opts["kde-preview"] = (d->m_preview->isChecked() ? "1" : "0"); - opts["kde-isspecial"] = (prt->isSpecial() ? "1" : "0"); - opts["kde-special-command"] = prt->option("kde-special-command"); - - // merge options with KMPrinter object options - TQMap<TQString,TQString> popts = (prt->isEdited() ? prt->editedOptions() : prt->defaultOptions()); - for (TQMap<TQString,TQString>::ConstIterator it=popts.begin(); it!=popts.end(); ++it) - opts[it.key()] = it.data(); - - // update KPrinter object - d->m_printer->setOptions(opts); - - emit printRequested(d->m_printer); - // close dialog if not persistent - if (!d->m_persistent->isChecked() || !d->m_persistent->isVisible()) - KDialog::done(result); - } - else - KDialog::done(result); -} - -bool KPrintDialog::checkOutputFile() -{ - bool value(false); - if (d->m_file->url().isEmpty()) - KMessageBox::error(this,i18n("The output filename is empty.")); - else - { - KURL url( d->m_file->url() ); - if ( !url.isLocalFile() ) - return true; - - bool anotherCheck; - do - { - anotherCheck = false; - TQFileInfo f(url.path()); - if (f.exists()) - { - if (f.isWritable()) - { - //value = (KMessageBox::warningYesNo(this,i18n("File \"%1\" already exists. Overwrite?").arg(f.absFilePath())) == KMessageBox::Yes); - time_t mtimeDest = f.lastModified().toTime_t(); - KIO::RenameDlg dlg( this, i18n( "Print" ), TQString::null, d->m_file->url(), - KIO::M_OVERWRITE, ( time_t ) -1, f.size(), ( time_t ) -1, f.created().toTime_t() , mtimeDest+1, mtimeDest, true ); - int result = dlg.exec(); - switch ( result ) - { - case KIO::R_OVERWRITE: - value = true; - break; - default: - case KIO::R_CANCEL: - value = false; - break; - case KIO::R_RENAME: - url = dlg.newDestURL(); - d->m_file->setURL( url.path() ); - value = true; - anotherCheck = true; - break; - } - } - else - KMessageBox::error(this,i18n("You don't have write permissions to this file.")); - } - else - { - TQFileInfo d( f.dirPath( true ) ); - if ( !d.exists() ) - KMessageBox::error( this, i18n( "The output directory does not exist." ) ); - else if ( !d.isWritable() ) - KMessageBox::error(this,i18n("You don't have write permissions in that directory.")); - else - value = true; - } - } while( anotherCheck ); - } - return value; -} - -void KPrintDialog::slotOptions() -{ - if (KMManager::self()->invokeOptionsDialog(this)) - init(); -} - -void KPrintDialog::enableOutputFile(bool on) -{ - d->m_filelabel->setEnabled(on); - d->m_file->setEnabled(on); -} - -void KPrintDialog::enableSpecial(bool on) -{ - d->m_default->setDisabled(on); - d->m_cmdlabel->setDisabled(on); - d->m_cmd->setDisabled(on); - KPCopiesPage *copypage = (KPCopiesPage*)child("CopiesPage","KPCopiesPage"); - if (copypage) - copypage->initialize(!on); - // disable/enable all other pages (if needed) - for (d->m_pages.first(); d->m_pages.current(); d->m_pages.next()) - if (d->m_pages.current()->onlyRealPrinters()) - d->m_pages.current()->setEnabled(!on); -} - -void KPrintDialog::setOutputFileExtension(const TQString& ext) -{ - if (!ext.isEmpty()) - { - KURL url( d->m_file->url() ); - TQString f( url.fileName() ); - int p = f.findRev( '.' ); - // change "file.ext"; don't change "file", "file." or ".file" but do change ".file.ext" - if ( p > 0 && p != int (f.length () - 1) ) - { - url.setFileName( f.left( p ) + "." + ext ); - d->m_file->setURL( KURL::decode_string( url.url() ) ); - } - } -} - -void KPrintDialog::slotWizard() -{ - int result = KMFactory::self()->manager()->addPrinterWizard(this); - if (result == -1) - KMessageBox::error(this, KMFactory::self()->manager()->errorMsg().prepend("<qt>").append("</qt>")); - else if (result == 1) - initialize(d->m_printer); -} - -void KPrintDialog::reload() -{ - // remove printer dependent pages (usually from plugin) - TQTabWidget *tabs = static_cast<TQTabWidget*>(TQT_TQWIDGET(d->m_dummy->child("TabWidget", TQTABWIDGET_OBJECT_NAME_STRING))); - for (uint i=0; i<d->m_pages.count(); i++) - if (d->m_pages.tqat(i)->onlyRealPrinters()) - { - KPrintDialogPage *page = d->m_pages.take(i--); - if (tabs) - tabs->removePage(page); - delete page; - } - // reload printer dependent pages from plugin - TQPtrList<KPrintDialogPage> pages; - pages.setAutoDelete(false); - KMFactory::self()->uiManager()->setupPrintDialogPages(&pages); - // add those pages to the dialog - setDialogPages(&pages); - if (!d->m_reduced) - d->m_dummy->show(); - // other initializations - setFlags(KMFactory::self()->uiManager()->dialogFlags()); - connect( KMFactory::self()->manager(), TQT_SIGNAL( updatePossible( bool ) ), TQT_SLOT( slotUpdatePossible( bool ) ) ); - init(); -} - -void KPrintDialog::configChanged() -{ - // simply update the printer list: do it all the time - // as changing settings may influence the way printer - // are listed. - init(); - - // update the GUI - setFlags(KMFactory::self()->uiManager()->dialogFlags()); -} - -void KPrintDialog::expandDialog(bool on) -{ - QSize sz(size()); - bool needResize(isVisible()); - - if (on) - { - sz.setHeight(sz.height()+d->m_dummy->tqminimumSize().height()+d->m_plugin->tqminimumSize().height()+2*layout()->spacing()); - if (isVisible() || !d->m_dummy->isVisible() || !d->m_plugin->isVisible()) - { - d->m_dummy->show(); - if (d->b_systemEnabled) - d->m_plugin->show(); - } - d->m_extbtn->setIconSet(SmallIconSet("up")); - d->m_extbtn->setText(i18n("&Options <<")); - d->m_reduced = false; - } - else - { - sz.setHeight(sz.height()-d->m_dummy->height()-d->m_plugin->height()-2*layout()->spacing()); - if (!isVisible() || d->m_dummy->isVisible() || d->m_plugin->isVisible()) - { - d->m_dummy->hide(); - if (d->b_systemEnabled) - d->m_plugin->hide(); - } - d->m_extbtn->setIconSet(SmallIconSet("down")); - d->m_extbtn->setText(i18n("&Options >>")); - d->m_reduced = true; - } - - if (needResize) - { - layout()->activate(); - resize(sz); - } -} - -void KPrintDialog::slotExtensionClicked() -{ - // As all pages are children of d->m_dummy, I simply have to hide/show it - expandDialog(!(d->m_dummy->isVisible())); -} - -KPrinter* KPrintDialog::printer() const -{ - return d->m_printer; -} - -void KPrintDialog::slotToggleFilter(bool on) -{ - KMManager::self()->enableFilter(on); - initialize(d->m_printer); -} - -void KPrintDialog::slotHelp() -{ - kapp->invokeHelp(TQString::null, "tdeprint"); -} - -void KPrintDialog::slotOutputFileSelected(const TQString& txt) -{ - d->m_file->setURL( txt ); -} - -void KPrintDialog::init() -{ - d->m_ok->setEnabled( false ); - MessageWindow::remove( this ); - MessageWindow::add( this, i18n( "Initializing printing system..." ), 500 ); - KMFactory::self()->manager()->checkUpdatePossible(); -} - -void KPrintDialog::slotUpdatePossible( bool flag ) -{ - MessageWindow::remove( this ); - if ( !flag ) - KMessageBox::error(parentWidget(), - "<qt><nobr>"+ - i18n("An error occurred while retrieving the printer list:") - +"</nobr><br><br>"+KMManager::self()->errorMsg()+"</qt>"); - initialize( d->m_printer ); -} - -void KPrintDialog::enableDialogPage( int index, bool flag ) -{ - if ( index < 0 || index >= ( int )d->m_pages.count() ) - { - kdWarning() << "KPrintDialog: page index out of bound" << endl; - return; - } - - if ( d->m_pages.count() > 1 ) - { - TQTabWidget *tabs = static_cast<TQTabWidget*>(TQT_TQWIDGET(d->m_dummy->child("TabWidget", TQTABWIDGET_OBJECT_NAME_STRING))); - tabs->setTabEnabled( d->m_pages.tqat( index ), flag ); - } - else - d->m_pages.tqat( 0 )->setEnabled( flag ); -} - -void KPrintDialog::slotOpenFileDialog() -{ - KFileDialog *dialog = d->m_file->fileDialog(); - - dialog->setCaption(i18n("Print to File")); - dialog->setMode(d->m_file->fileDialog()->mode() & ~KFile::LocalOnly); - dialog->setOperationMode( KFileDialog::Saving ); - - KMPrinter *prt = KMFactory::self()->manager()->findPrinter(d->m_printers->currentText()); - if (prt) - { - QString mimetype(prt->option("kde-special-mimetype")); - QString ext(prt->option("kde-special-extension")); - - if (!mimetype.isEmpty()) - { - TQStringList filter; - filter << mimetype; - filter << "all/allfiles"; - dialog->setMimeFilter (filter, mimetype); - } - else if (!ext.isEmpty()) - dialog->setFilter ("*." + ext + "\n*|" + i18n ("All Files")); - } -} - -#include "kprintdialog.moc" diff --git a/kdeprint/kprintdialog.h b/kdeprint/kprintdialog.h deleted file mode 100644 index 77484ca58..000000000 --- a/kdeprint/kprintdialog.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPRINTDIALOG_H -#define KPRINTDIALOG_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <kdialog.h> -#include <tqptrlist.h> -#include <tdeprint/kpreloadobject.h> - -class KPrinter; -class KPrintDialogPage; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KPrintDialog : public KDialog, public KPReloadObject -{ - Q_OBJECT -public: - KPrintDialog(TQWidget *parent = 0, const char *name = 0); - ~KPrintDialog(); - - void setFlags(int f); - void setDialogPages(TQPtrList<KPrintDialogPage> *pages); - void enableDialogPage( int index, bool flag = true ); - KPrinter* printer() const; - - static KPrintDialog* printerDialog(KPrinter*, TQWidget*, const TQString& caption = TQString::null, bool forceExpand = false); - -signals: - void printRequested(KPrinter*); - -protected slots: - void slotPrinterSelected(int); - void slotProperties(); - void slotSetDefault(); - void slotOptions(); - virtual void done(int); - void slotWizard(); - void slotExtensionClicked(); - void slotToggleFilter(bool); - void slotHelp(); - void slotOutputFileSelected(const TQString&); - void slotUpdatePossible( bool ); - void slotOpenFileDialog(); - -protected: - bool checkOutputFile(); - void enableSpecial(bool on); - void enableOutputFile(bool on); - void setOutputFileExtension(const TQString&); - void reload(); - void configChanged(); - void expandDialog(bool on = true); - void initialize( KPrinter* ); - void init(); - -protected: - class KPrintDialogPrivate; - KPrintDialogPrivate *d; -}; - -#endif diff --git a/kdeprint/kprintdialogpage.cpp b/kdeprint/kprintdialogpage.cpp deleted file mode 100644 index 58861019a..000000000 --- a/kdeprint/kprintdialogpage.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 "kprintdialogpage.h" - -KPrintDialogPage::KPrintDialogPage(TQWidget *parent, const char *name) -: TQWidget(parent,name), m_printer(0), m_driver(0), m_ID(0), m_onlyreal(false) -{ -} - -KPrintDialogPage::KPrintDialogPage(KMPrinter *pr, DrMain *dr, TQWidget *parent, const char *name) -: TQWidget(parent,name), m_printer(pr), m_driver(dr), m_ID(0), m_onlyreal(false) -{ -} - -KPrintDialogPage::~KPrintDialogPage() -{ -} - -void KPrintDialogPage::setOptions(const TQMap<TQString,TQString>&) -{ -} - -void KPrintDialogPage::getOptions(TQMap<TQString,TQString>&, bool) -{ -} - -bool KPrintDialogPage::isValid(TQString&) -{ - return true; -} -#include "kprintdialogpage.moc" diff --git a/kdeprint/kprintdialogpage.h b/kdeprint/kprintdialogpage.h deleted file mode 100644 index d9b44b6ea..000000000 --- a/kdeprint/kprintdialogpage.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KPRINTDIALOGPAGE_H -#define KPRINTDIALOGPAGE_H - -#include <tqwidget.h> -#include <tqmap.h> - -#include <kdelibs_export.h> - -class KMPrinter; -class DrMain; - -/** - * This class is intended to be used as base class for customized print dialog page. One of - * the feature of the KDE print framework is to allow to customize the print dialog to - * add some application specific print options. This is done by subclassing KPrintDialogPage - * and reimplementing the 3 virtual functions getOptions, setOptions and - * isValid(). The print options will be stored in the KPrinter object, and will be - * accessible via KPrinter::option(). The option name should follow the form - * "kde-appname-optionname" for internal reasons. - * - * \code - * #include <tdeprint/kprintdialogpage.h> - * - * class MyDialogPage : public KPrintDialogPage - * { - * public: - * MyDialogPage( TQWidget *parent = 0, const char *name = 0 ); - * - * //reimplement virtual functions - * void getOptions( TQMap<TQString,TQString>& opts, bool incldef = false ); - * void setOptions( const TQMap<TQString,TQString>& opts ); - * bool isValid( TQString& msg ); - * - * private: - * TQComboBox *m_fontcombo; - * }; - * - * MyDialogPage::MyDialogPage( TQWidget *parent, const char *name ) - * : KPrintDialogPage( parent, name ) - * { - * setTitle( i18n( "My Page" ) ); - * } - * - * void MyDialogPage::getOptions( TQMap<TQString,TQString>& opts, bool incldef ) - * { - * if ( incldef || m_fontcombo->currentText() != mydefaultvalue ) - * opts[ "kde-myapp-fontname" ] = m_fontcombo->currentText(); - * } - * - * void MyDialogPage::setOptions( const TQMap<TQString,TQString>& opts ) - * { - * TQString fntname = opts[ "kde-myapp-fontname" ]; - * m_fontcombo->setEditText( fntname ); - * } - * - * bool MyDialogPage::isValid( TQString& msg) - * { - * if ( m_fontcombo->currentText().isEmpty() ) - * { - * msg = i18n( "Font name cannot be empty." ); - * return false; - * } - * return true; - * } - * \endcode - * - * @short Base class for customized print dialog pages. - * @see KPrinter - */ -class KDEPRINT_EXPORT KPrintDialogPage : public TQWidget -{ - Q_OBJECT -public: - /** - * Standard constructor. - */ - KPrintDialogPage(TQWidget *parent = 0, const char *name = 0); - /** - * Modified constructor. For internal use only. - */ - KPrintDialogPage(KMPrinter *pr, DrMain *dr = 0, TQWidget *parent = 0, const char *name = 0); - /** - * Destructor - */ - virtual ~KPrintDialogPage(); - - /** - * This function is called to fill the structure @p opts with the selected options from this dialog - * page. If @p incldef is true, include also options with default values, otherwise discard them. - * Reimplement this function in subclasses. - * @param opts the option set to fill - * @param incldef if true, include also options with default values - * @see setOptions() - */ - virtual void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - /** - * This function is called to update the current page with the options contained in @p opts. - * Reimplement it in subclasses. - * @param opts the structure containing the options to update the page - */ - virtual void setOptions(const TQMap<TQString,TQString>& opts); - /** - * Returns true if options selected in the page are valid (no conflict), false otherwise. - * When returning false, @p msg should contain an error message explaining what is wrong - * in the selected options. - * @param msg should contain an error message when returning false - * @returns valid status - */ - virtual bool isValid(TQString& msg); - /** - * Get the ID of the page. Not used yet. - * @returns the page ID - * @see setId() - */ - int id() const { return m_ID; } - /** - * Set the ID of the page. Not used yet. - * @param ID the ID number - * @see id() - */ - void setId(int ID) { m_ID = ID; } - /** - * Get the page title. - * @returns the page title - * @see setTitle() - */ - QString title() const { return m_title; } - /** - * Set the page title. This title will be used as tab name for this page in the print - * dialog. - * @param txt the page title - * @see title() - */ - void setTitle(const TQString& txt) { m_title = txt; } - /** - * Tell wether or not the page should be disable if a non real printer (special - * printer) is selected in the print dialog. Returns false by default. Application - * specific pages usually corresponds to printer-independent options, so the - * page should be kept enabled whatever the selected printer. The default value - * is then correct and your application doesn't to change anything. - * @returns true if the page should be disabled for non real printers - * @see setOnlyRealPrinters() - */ - bool onlyRealPrinters() const { return m_onlyreal; } - /** - * Change the page state when a non real printer is selected in the print dialog. - * Usually, the default value (false) is OK in most cases and you don't need to - * call this function explicitly. - * @param on if true, then the page will be disabled if a non real printer is selected - * @see onlyRealPrinters() - */ - void setOnlyRealPrinters(bool on = true) { m_onlyreal = on; } - /** - * For internal use only. - */ - DrMain* driver() { return m_driver; } - /** - * For internal use only - */ - KMPrinter* printer() { return m_printer; } - -protected: - KMPrinter *m_printer; - DrMain *m_driver; - int m_ID; - QString m_title; - bool m_onlyreal; -}; - -#endif diff --git a/kdeprint/kprinter.cpp b/kdeprint/kprinter.cpp deleted file mode 100644 index 67d276990..000000000 --- a/kdeprint/kprinter.cpp +++ /dev/null @@ -1,1045 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kprinter.h" -#include "kprinterimpl.h" -#include "kprintdialog.h" -#include "kprintpreview.h" -#include "kmfactory.h" -#include "kmuimanager.h" -#include "kmmanager.h" -#include "driver.h" - -#include <tqpaintdevicemetrics.h> -#include <tqfile.h> -#include <tqtl.h> -#include <tqdir.h> -#include <tqguardedptr.h> -#include <kapplication.h> -#include <kstandarddirs.h> -#include <kglobal.h> -#include <kconfig.h> -#include <krun.h> -#include <knotifyclient.h> -#include <kdebug.h> -#include <klocale.h> -#include <kprocess.h> -#include <klibloader.h> -#include <kmessagebox.h> - -static void dumpOptions(const TQMap<TQString,TQString>& opts); -static void reportError(KPrinter*); - -//************************************************************************************** -// KPrinterWrapper class -//************************************************************************************** - -class KPrinterWrapper : public TQPrinter -{ -friend class KPrinter; -public: - KPrinterWrapper(KPrinter*, PrinterMode m = ScreenResolution); - ~KPrinterWrapper(); -protected: - virtual bool cmd(int, TQPainter*, TQPDevCmdParam*); - virtual int metric(int) const; - int qprinterMetric(int) const; -private: - KPrinter *m_printer; -}; - -KPrinterWrapper::KPrinterWrapper(KPrinter *prt, TQPrinter::PrinterMode m) -: TQPrinter(m), m_printer(prt) -{ -} - -KPrinterWrapper::~KPrinterWrapper() -{ -} - -bool KPrinterWrapper::cmd(int c, TQPainter *painter, TQPDevCmdParam *p) -{ - return TQPrinter::cmd(c,painter,p); -} - -int KPrinterWrapper::metric(int m) const -{ - return m_printer->metric(m); -} - -int KPrinterWrapper::qprinterMetric(int m) const -{ - return TQPrinter::metric(m); -} - -//************************************************************************************** -// KPrinterPrivate class -//************************************************************************************** - -class KPrinterPrivate -{ -public: - TQGuardedPtr<KPrinterImpl> m_impl; - bool m_restore; - bool m_previewonly; - WId m_parentId; - QString m_docfilename; - TQString m_docdirectory; - KPrinterWrapper *m_wrapper; - TQMap<TQString,TQString> m_options; - QString m_tmpbuffer; - QString m_printername; - QString m_searchname; - QString m_errormsg; - bool m_ready; - int m_pagenumber; - DrPageSize *m_pagesize; - bool m_useprinterres; - int m_defaultres; -}; - -//************************************************************************************** -// KPrinter class -//************************************************************************************** - -KPrinter::KPrinter(bool restore, TQPrinter::PrinterMode m) -: TQPaintDevice(TQInternal::Printer|TQInternal::ExternalDevice) -{ - init(restore, m); -} - -KPrinter::~KPrinter() -{ - // delete Wrapper object - delete d->m_wrapper; - - // save current options - if (d->m_restore) - saveSettings(); - - // delete private data (along any data allocated internally) - delete d->m_pagesize; - delete d; -} - -void KPrinter::init(bool restore, TQPrinter::PrinterMode m) -{ - // Private data initialization - d = new KPrinterPrivate; - d->m_impl = KMFactory::self()->printerImplementation(); - d->m_restore = restore; - d->m_previewonly = false; - d->m_parentId = 0; - d->m_pagesize = 0; - - // initialize TQPrinter wrapper - d->m_wrapper = new KPrinterWrapper(this, m); - - // other initialization - d->m_tmpbuffer = d->m_impl->tempFile(); - d->m_ready = false; - d->m_defaultres = d->m_wrapper->resolution(); - d->m_useprinterres = false; - - // reload options from implementation (static object) - if (d->m_restore) - loadSettings(); -} - -void KPrinter::loadSettings() -{ - d->m_options = d->m_impl->loadOptions(); - - // load the last printer used in the current process (if any) - // and remove the corresponding entry in the option map, as it - // is not needed anymore - setSearchName(option("kde-searchname")); - d->m_options.remove("kde-searchname"); - - KConfig *conf = KGlobal::config(), *pconf = KMFactory::self()->printConfig(); - conf->setGroup("KPrinter Settings"); - pconf->setGroup("General"); - - // load latest used printer from config file, if required in the options - if (searchName().isEmpty() && pconf->readBoolEntry("UseLast", true)) - setSearchName(conf->readEntry("Printer")); - - // latest used print command - setOption("kde-printcommand",conf->readPathEntry("PrintCommand")); - - // latest used document directory - setDocDirectory( conf->readPathEntry( "DocDirectory" ) ); - setDocFileName( "print" ); -} - -void KPrinter::saveSettings() -{ - if (d->m_impl) - { - setOption("kde-searchname", searchName()); - d->m_impl->saveOptions(d->m_options); - } - - // save latest used printer to config file - KConfig *conf = KGlobal::config(); - conf->setGroup("KPrinter Settings"); - conf->writeEntry("Printer",searchName()); - // latest used print command - conf->writePathEntry("PrintCommand",option("kde-printcommand")); - - // latest used document directory - if ( d->m_docdirectory.isEmpty() ) - { - KURL url( outputFileName() ); - if ( url.isValid() ) - conf->writePathEntry( "DocDirectory", url.directory() ); - } - else - conf->writePathEntry( "DocDirectory", d->m_docdirectory ); -} - -bool KPrinter::setup(TQWidget *parent, const TQString& caption, bool forceExpand) -{ - if (!kapp->authorize("print/dialog")) - { - autoConfigure(TQString::null, parent); - return true; // Just print it - } - - if (parent) - d->m_parentId = parent->winId(); - - KPrintDialog *dlg = KPrintDialog::printerDialog(this, parent, caption, forceExpand); - bool state = false; - if (dlg) - { - state = dlg->exec(); - delete dlg; - } - return state; -} - -void KPrinter::addStandardPage(int p) -{ - KMFactory::self()->settings()->standardDialogPages |= p; -} - -void KPrinter::removeStandardPage(int p) -{ - KMFactory::self()->settings()->standardDialogPages &= (~p); -} - -void KPrinter::addDialogPage(KPrintDialogPage *page) -{ - KMFactory::self()->uiManager()->addPrintDialogPage(page); -} - -void KPrinter::setPageSelection(PageSelectionType t) -{ - KMFactory::self()->settings()->pageSelection = t; -} - -KPrinter::PageSelectionType KPrinter::pageSelection() -{ - return (PageSelectionType)KMFactory::self()->settings()->pageSelection; -} - -void KPrinter::setApplicationType(ApplicationType t) -{ - KMFactory::self()->settings()->application = t; -} - -KPrinter::ApplicationType KPrinter::applicationType() -{ - return (ApplicationType)KMFactory::self()->settings()->application; -} - -bool KPrinter::cmd(int c, TQPainter *painter, TQPDevCmdParam *p) -{ - bool value(true); - if (c == TQPaintDevice::PdcBegin) - { - d->m_impl->statusMessage(i18n("Initialization..."), this); - d->m_pagenumber = 1; - preparePrinting(); - d->m_impl->statusMessage(i18n("Generating print data: page %1").arg(d->m_pagenumber), this); - } - value = d->m_wrapper->cmd(c,painter,p); - if (c == TQPaintDevice::PdcEnd) - { - // this call should take care of everything (preview, output-to-file, filtering, ...) - value = value && printFiles(TQStringList(d->m_wrapper->outputFileName()),true); - // reset "ready" state - finishPrinting(); - } - return value; -} - -void KPrinter::translateQtOptions() -{ - d->m_wrapper->setCreator(creator()); - d->m_wrapper->setDocName(docName()); - d->m_wrapper->setFullPage(fullPage()); - d->m_wrapper->setColorMode((TQPrinter::ColorMode)colorMode()); - d->m_wrapper->setOrientation((TQPrinter::Orientation)orientation()); - if ( !option( "kde-printsize" ).isEmpty() ) - d->m_wrapper->setPageSize( ( TQPrinter::PageSize )option( "kde-printsize" ).toInt() ); - else - d->m_wrapper->setPageSize((TQPrinter::PageSize)pageSize()); - d->m_wrapper->setOutputToFile(true); - d->m_wrapper->setOutputFileName(d->m_tmpbuffer); - d->m_wrapper->setNumCopies(option("kde-qtcopies").isEmpty() ? 1 : option("kde-qtcopies").toInt()); - if (!option("kde-margin-top").isEmpty()) - { - /** - * Scale margings as the margin widget always stores values - * in dot units ( 1/72th in ), to be resolution independent - * when specified by the user ( who usually specifies margins - * in metric units ). - */ - int res = resolution(); - d->m_wrapper->setMargins( - ( int )( ( option("kde-margin-top").toFloat() * res + 71 ) / 72 ), - ( int )( ( option("kde-margin-left").toFloat() * res + 71 ) / 72 ), - ( int )( ( option("kde-margin-bottom").toFloat() * res + 71 ) / 72 ), - ( int )( ( option("kde-margin-right").toFloat() * res + 71 ) / 72 ) ); - } - else if ( d->m_pagesize != NULL ) - { - int res = resolution(); - DrPageSize *ps = d->m_pagesize; - int top = ( int )( ps->topMargin() * res + 71 ) / 72; - int left = ( int )( ps->leftMargin() * res + 71 ) / 72; - int bottom = ( int )( ps->bottomMargin() * res + 71 ) / 72; - int right = ( int )( ps->rightMargin() * res + 71 ) / 72; - if ( !fullPage() ) - { - // Printers can often print very close to the edges (PPD files say ImageArea==PaperDimension). - // But that doesn't mean it looks good. Apps which use setFullPage(false) assume that - // KPrinter will give them reasonable margins, so let's QMAX with defaults from Qt in that case. - // Keep this in sync with KPMarginPage::initPageSize - unsigned int it, il, ib, ir; - d->m_wrapper->margins( &it, &il, &ib, &ir ); - top = QMAX( top, (int)it ); - left = QMAX( left, (int)il ); - bottom = QMAX( bottom, (int)ib ); - right = QMAX( right, (int)ir ); - } - d->m_wrapper->setMargins( top, left, bottom, right ); - } - /*else - { - int res = d->m_wrapper->resolution(); - d->m_wrapper->setMargins( res/3, res/2, res/3, res/2 ); - }*/ - // for special printers, copies are handled by Qt - if (option("kde-isspecial") == "1") - d->m_wrapper->setNumCopies(numCopies()); -} - -bool KPrinter::printFiles(const TQStringList& l, bool flag, bool startviewer) -{ - TQStringList files(l); - bool status(true); - - // First apply possible filters, and update "remove" flag if filters has - // been applied (result == 0, means nothing happened). - int fresult = d->m_impl->filterFiles(this, files, flag); - if (fresult == -1) - { - reportError(this); - status = false; - } - else if (fresult == 1) - flag = true; - - if (status) - { - // Automatic conversion to format supported by print system - fresult = d->m_impl->autoConvertFiles(this, files, flag); - if (fresult == -1) - { - reportError(this); - status = false; - } - else if (fresult == 1) - flag = true; - } - - // Continue if status is OK (filtering succeeded) and no output-to-file - if (status && files.count() > 0) - { - // Show preview if needed (only possible for a single file !), and stop - // if the user requested it. Force preview if preview-only mode has been set: it - // then use by default the first file in the list. - if (((files.count() != 1 || option("kde-preview") != "1") && !d->m_previewonly) || doPreview(files[0])) - { - // check if printing has been prepared (it may be not prepared if the KPrinter object is not - // use as a TQPaintDevice object) - preparePrinting(); - - if (!d->m_impl->printFiles(this, files, flag)) - { - reportError(this); - status = false; - } - else - { - if (/* !outputToFile() && */ startviewer && !TQFile::exists("/etc/xdg/autostart/system-config-printer-applet-kde.desktop") ) - { - TQStringList args; - args << "-d"; - args << printerName(); - args << "--noshow"; - kapp->tdeinitExec("kjobviewer", args); - } - } - } - else if (flag) - // situation: only one file, it has been previewed and printing has been canceled, then - // we should remove the file ourself - { - TQFile::remove(files[0]); - } - } - finishPrinting(); - return status; -} - -bool KPrinter::doPreview(const TQString& file) -{ - d->m_impl->statusMessage(i18n("Previewing..."), this); - d->m_impl->statusMessage(TQString::null, this); - return KPrintPreview::preview(file, d->m_previewonly, d->m_parentId); -} - -void KPrinter::preparePrinting() -{ - // check if already prepared (-> do nothing) - if (d->m_ready) return; - - // re-initialize error - setErrorMessage(TQString::null); - - // re-initialize margins and page size (by default, use Qt mechanism) - setRealPageSize(NULL); - - // print-system-specific setup, only if not printing to file - if (option("kde-isspecial") != "1") - d->m_impl->preparePrinting(this); - - // set the correct resolution, if needed (or reset it) - int res = option( "kde-resolution" ).toInt(); - if ( d->m_useprinterres && res > 0 ) - d->m_wrapper->setResolution( res ); - else - d->m_wrapper->setResolution( d->m_defaultres ); - - // standard Qt settings - translateQtOptions(); - - d->m_ready = true; -dumpOptions(d->m_options); -} - -void KPrinter::finishPrinting() -{ - d->m_ready = false; - // close the status window - d->m_impl->statusMessage(TQString::null, this); -} - -TQValueList<int> KPrinter::pageList() const -{ - TQValueList<int> list; - int mp(minPage()), MP(maxPage()); - if (mp > 0 && MP > 0 && MP >= mp) - { // do something only if bounds specified - if (option("kde-current") == "1") - { // print only current page - int pp = currentPage(); - if (pp >= mp && pp <= MP) list.append(pp); - } - else - { - // process range specification - if (!option("kde-range").isEmpty()) - { - TQStringList ranges = TQStringList::split(',',option("kde-range"),false); - for (TQStringList::ConstIterator it=ranges.begin();it!=ranges.end();++it) - { - int p = (*it).find('-'); - bool ok; - if (p == -1) - { - int pp = (*it).toInt(&ok); - if (ok && pp >= mp && pp <= MP) - list.append(pp); - } - else - { - int p1(0), p2(0); - p1 = (*it).left(p).toInt(&ok); - if (ok) p2 = (*it).right((*it).length()-p-1).toInt(&ok); - if (ok && p1 <= p2) - { - // clip to min/max - p1 = QMAX(mp,p1); - p2 = QMIN(MP,p2); - for (int i=p1;i<=p2;i++) - list.append(i); - } - } - } - } - else - { // add all pages between min and max - for (int i=mp;i<=MP;i++) list.append(i); - } - - // revert the list if needed - if (pageOrder() == LastPageFirst) - { - for (uint i=0;i<(list.count()/2);i++) - tqSwap(list[i],list[list.count()-1-i]); - } - - // select page set if needed - if (pageSet() != AllPages) - { - bool keepEven = (pageSet() == EvenPages); - for (TQValueList<int>::Iterator it=list.begin();it!=list.end();) - if ((((*it) % 2) != 0 && keepEven) || - (((*it) % 2) == 0 && !keepEven)) it = list.remove(it); - else ++it; - } - } - } - return list; -} - -//************************************************************************************** -// TQPrinter interface -//************************************************************************************** - -int KPrinter::numCopies() const -{ - bool ok; - int p = option("kde-copies").toInt(&ok); - return (ok ? p : 1); -} - -TQSize KPrinter::margins() const -{ - return d->m_wrapper->margins(); -} - -void KPrinter::margins( uint *top, uint *left, uint *bottom, uint *right ) const -{ - d->m_wrapper->margins( top, left, bottom, right ); -} - -int KPrinter::metric(int m) const -{ - if (d->m_pagesize == NULL || !option( "kde-printsize" ).isEmpty()) - return d->m_wrapper->qprinterMetric(m); - - int val(0); - bool land = (orientation() == KPrinter::Landscape); - uint res(d->m_wrapper->resolution()), top = res/2, left = res/2, bottom = res/3, right = res/2; - margins( &top, &left, &bottom, &right ); - switch ( m ) - { - case TQPaintDeviceMetrics::PdmWidth: - val = (land ? ( int )d->m_pagesize->pageHeight() : ( int )d->m_pagesize->pageWidth()); - if ( res != 72 ) - val = (val * res + 36) / 72; - if ( !fullPage() ) - val -= ( left + right ); - break; - case TQPaintDeviceMetrics::PdmHeight: - val = (land ? ( int )d->m_pagesize->pageWidth() : ( int )d->m_pagesize->pageHeight()); - if ( res != 72 ) - val = (val * res + 36) / 72; - if ( !fullPage() ) - val -= ( top + bottom ); - break; - case TQPaintDeviceMetrics::PdmWidthMM: - val = metric( TQPaintDeviceMetrics::PdmWidth ); - val = (val * 254 + 5*res) / (10*res); // +360 to get the right rounding - break; - case TQPaintDeviceMetrics::PdmHeightMM: - val = metric( TQPaintDeviceMetrics::PdmHeight ); - val = (val * 254 + 5*res) / (10*res); - break; - default: - val = d->m_wrapper->qprinterMetric(m); - break; - } - return val; -} - -void KPrinter::setOrientation(Orientation o) -{ - KMFactory::self()->settings()->orientation = o; - setOption("kde-orientation",(o == Landscape ? "Landscape" : "Portrait")); - d->m_impl->broadcastOption("kde-orientation",(o == Landscape ? "Landscape" : "Portrait")); - d->m_impl->broadcastOption( "kde-orientation-fixed", "1" ); -} - -void KPrinter::setOption( const TQString& key, const TQString& value, bool broadcast ) -{ - setOption( key, value ); - if ( broadcast ) - d->m_impl->broadcastOption( key, value ); -} - -void KPrinter::setPageSize(PageSize s) -{ - KMFactory::self()->settings()->pageSize = s; - setOption("kde-pagesize",TQString::number((int)s),true); - d->m_impl->broadcastOption( "kde-pagesize-fixed", "1" ); -} - -void KPrinter::setOptions(const TQMap<TQString,TQString>& opts) -{ // This functions remove all options except those with "kde-..." - // which correspond to externally-sets options (use the value - // from "opts" if specified - TQMap<TQString,TQString> tmpset = d->m_options; - d->m_options = opts; - // remove some problematic options that may not be overwritten (ugly hack). - // Default values will be used instead, except if the dialog has set new ones. - tmpset.remove("kde-pagesize"); - tmpset.remove( "kde-printsize" ); - tmpset.remove("kde-orientation"); - tmpset.remove("kde-colormode"); - tmpset.remove("kde-margin-top"); - tmpset.remove("kde-margin-left"); - tmpset.remove("kde-margin-bottom"); - tmpset.remove("kde-margin-right"); - tmpset.remove( "kde-resolution" ); - tmpset.remove( "kde-fonts" ); - for (TQMap<TQString,TQString>::ConstIterator it=tmpset.begin();it!=tmpset.end();++it) - if (it.key().left(4) == "kde-" && !(d->m_options.contains(it.key()))) - d->m_options[it.key()] = it.data(); -} - -void KPrinter::initOptions(const TQMap<TQString,TQString>& opts) -{ // This function can be used to initialize the KPrinter object just after - // creation to set some options. Non global options will be propagated to - // all listed printers (non-global => start with "kde-...") - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - setOption(it.key(), it.data()); - if (it.key().left(4) != "kde-") - d->m_impl->broadcastOption(it.key(),it.data()); - } -} - -void KPrinter::reload() -{ - d->m_impl = KMFactory::self()->printerImplementation(); - int global = KMFactory::self()->settings()->orientation; - if (global != -1) setOrientation((KPrinter::Orientation)global); - global = KMFactory::self()->settings()->pageSize; - if (global != -1) setPageSize((KPrinter::PageSize)global); - //initOptions(d->m_options); -} - -bool KPrinter::autoConfigure(const TQString& prname, TQWidget *parent) -{ - KMManager *mgr = KMManager::self(); - KMPrinter *mprt(0); - - mgr->printerList(false); - if (prname.isEmpty()) - mprt = mgr->defaultPrinter(); - else - mprt = mgr->findPrinter(prname); - - if (mprt) - return mprt->autoConfigure(this, parent); - else - return false; -} - -//************************************************************************************** -// Util functions -//************************************************************************************** - -void reportError(KPrinter *p) -{ - if (!KNotifyClient::event(0,"printerror",i18n("<p><nobr>A print error occurred. Error message received from system:</nobr></p><br>%1").arg(p->errorMessage()))) - kdDebug(500) << "could not send notify event" << endl; -} - -KPrinter::PageSize pageNameToPageSize(const TQString& _name) -{ - TQString name = _name.upper(); - if (name == "LETTER") return KPrinter::Letter; - else if (name == "LEGAL") return KPrinter::Legal; - else if (name == "A4") return KPrinter::A4; - else if (name == "A3") return KPrinter::A3; - else if (name == "EXECUTIVE") return KPrinter::Executive; - else if (name == "LEDGER") return KPrinter::Ledger; - else if (name == "TABLOID") return KPrinter::Tabloid; - else if (name == "FOLIO") return KPrinter::Folio; - else if (name == "A5") return KPrinter::A5; - else if (name == "A6") return KPrinter::A6; - else if (name == "A7") return KPrinter::A7; - else if (name == "A8") return KPrinter::A8; - else if (name == "A9") return KPrinter::A9; - else if (name == "A2") return KPrinter::A2; - else if (name == "A1") return KPrinter::A1; - else if (name == "A0") return KPrinter::A0; - else if (name == "B0" || name == "B0ISO") return KPrinter::B0; - else if (name == "B1" || name == "B1ISO") return KPrinter::B1; - else if (name == "B2" || name == "B2ISO") return KPrinter::B2; - else if (name == "B3" || name == "B3ISO") return KPrinter::B3; - else if (name == "B4" || name == "B4ISO") return KPrinter::B4; - else if (name == "B5" || name == "B5ISO") return KPrinter::B5; - else if (name == "B6" || name == "B6ISO") return KPrinter::B6; - else if (name == "B7" || name == "B7ISO") return KPrinter::B7; - else if (name == "B8" || name == "B8ISO") return KPrinter::B8; - else if (name == "B9" || name == "B9ISO") return KPrinter::B9; - else if (name == "B10" || name == "B10ISO") return KPrinter::B10; - else if (name == "C5" || name == "C5E" || name == "ENVC5") return KPrinter::C5E; - else if (name == "DL" || name == "DLE" || name == "ENVDL") return KPrinter::DLE; - else if (name == "COMM10" || name == "COM10" || name == "ENV10") return KPrinter::Comm10E; - else return KPrinter::A4; -} - -const char* pageSizeToPageName(KPrinter::PageSize s) -{ - switch(s) - { - case KPrinter::Letter: return "Letter"; - case KPrinter::Legal: return "Legal"; - case KPrinter::A4: return "A4"; - case KPrinter::A3: return "A3"; - case KPrinter::Executive: return "Executive"; - case KPrinter::Ledger: return "Ledger"; - case KPrinter::Tabloid: return "Tabloid"; - case KPrinter::Folio: return "Folio"; - case KPrinter::A5: return "A5"; - case KPrinter::A6: return "A6"; - case KPrinter::A7: return "A7"; - case KPrinter::A8: return "A8"; - case KPrinter::A9: return "A9"; - case KPrinter::A2: return "A2"; - case KPrinter::A1: return "A1"; - case KPrinter::A0: return "A0"; - case KPrinter::B0: return "B0"; - case KPrinter::B1: return "B1"; - case KPrinter::B2: return "B2"; - case KPrinter::B3: return "B3"; - case KPrinter::B4: return "B4"; - case KPrinter::B5: return "B5"; - case KPrinter::B6: return "B6"; - case KPrinter::B7: return "B7"; - case KPrinter::B8: return "B8"; - case KPrinter::B9: return "B9"; - case KPrinter::B10: return "B10"; - case KPrinter::C5E: return "C5"; - case KPrinter::DLE: return "DL"; - case KPrinter::Comm10E: return "Comm10"; - default: return "A4"; - } -} - -// FIXME: remove for 4.0 -TQSize rangeToSize( const TQString& ) -{ - kdWarning( 500 ) << "rangeToSize(TQString) is obsolete, do not use (no effect)" << endl; - return TQSize(); -} - -static void dumpOptions(const TQMap<TQString,TQString>& opts) -{ - kdDebug(500) << "********************" << endl; - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - kdDebug(500) << it.key() << " = " << it.data() << endl; -} - -KPrinterImpl* KPrinter::implementation() const -{ return d->m_impl; } - -const TQString& KPrinter::option(const TQString& key) const -{ return ((const KPrinterPrivate*)(d))->m_options[key]; } - -void KPrinter::setOption(const TQString& key, const TQString& value) -{ d->m_options[key] = value; } - -TQString KPrinter::docName() const -{ return option("kde-docname"); } - -void KPrinter::setDocName(const TQString& d) -{ setOption("kde-docname",d); } - -TQString KPrinter::creator() const -{ return option("kde-creator"); } - -void KPrinter::setCreator(const TQString& d) -{ setOption("kde-creator",d); } - -bool KPrinter::fullPage() const -{ return (option("kde-fullpage") == "1"); } - -void KPrinter::setFullPage(bool on) -{ setOption("kde-fullpage",(on ? "1" : "0")); } - -KPrinter::ColorMode KPrinter::colorMode() const -{ return (KPrinter::ColorMode)(option("kde-colormode") == "GrayScale" ? GrayScale : Color); } - -void KPrinter::setColorMode(ColorMode m) -{ setOption("kde-colormode",(m == Color ? "Color" : "GrayScale")); } - -void KPrinter::setNumCopies(int n) -{ setOption("kde-copies",TQString::number(n)); } - -KPrinter::Orientation KPrinter::orientation() const -{ return (option("kde-orientation") == "Landscape" ? Landscape : Portrait); } - -KPrinter::PageOrder KPrinter::pageOrder() const -{ return (option("kde-pageorder") == "Reverse" ? LastPageFirst : FirstPageFirst); } - -void KPrinter::setPageOrder(PageOrder o) -{ setOption("kde-pageorder",(o == LastPageFirst ? "Reverse" : "Forward")); } - -KPrinter::CollateType KPrinter::collate() const -{ return (option("kde-collate") == "Collate" ? Collate : Uncollate); } - -void KPrinter::setCollate(CollateType c) -{ setOption("kde-collate",(c == Collate ? "Collate" : "Uncollate")); } - -int KPrinter::minPage() const -{ return (option("kde-minpage").isEmpty() ? 0 : option("kde-minpage").toInt()); } - -int KPrinter::maxPage() const -{ return (option("kde-maxpage").isEmpty() ? 0 : option("kde-maxpage").toInt()); } - -void KPrinter::setMinMax(int m, int M) -{ setOption("kde-minpage",TQString::number(m)); setOption("kde-maxpage",TQString::number(M)); } - -int KPrinter::fromPage() const -{ return (option("kde-frompage").isEmpty() ? 0 : option("kde-frompage").toInt()); } - -int KPrinter::toPage() const -{ return (option("kde-topage").isEmpty() ? 0 : option("kde-topage").toInt()); } - -void KPrinter::setFromTo(int m, int M) -{ setOption("kde-frompage",TQString::number(m)); setOption("kde-topage",TQString::number(M)); setOption("kde-range",(m>0 && M>0 ? TQString("%1-%2").arg(m).arg(M) : TQString::tqfromLatin1(""))); } - -// if no page size defined, use the localized one -KPrinter::PageSize KPrinter::pageSize() const -{ return (option("kde-pagesize").isEmpty() ? (PageSize)KGlobal::locale()->pageSize() : (PageSize)option("kde-pagesize").toInt()); } - -KPrinter::PageSetType KPrinter::pageSet() const -{ return (option("kde-pageset").isEmpty() ? AllPages : (PageSetType)(option("kde-pageset").toInt())); } - -int KPrinter::currentPage() const -{ return (option("kde-currentpage").isEmpty() ? 0 : option("kde-currentpage").toInt()); } - -void KPrinter::setCurrentPage(int p) -{ setOption("kde-currentpage",TQString::number(p)); } - -TQString KPrinter::printerName() const -{ return d->m_printername; } - -void KPrinter::setPrinterName(const TQString& s) -{ d->m_printername = s; } - -TQString KPrinter::printProgram() const -{ return (option("kde-isspecial") == "1" ? option("kde-special-command") : TQString::null); } - -void KPrinter::setPrintProgram(const TQString& prg) -{ - if (prg.isNull()) - { - setOption("kde-isspecial", "0"); - d->m_options.remove("kde-special-command"); - } - else - { - TQString s(prg); - if (s.find("%in") == -1) - s.append(" %in"); - setOutputToFile( s.find( "%out" ) != -1 ); - setOption("kde-isspecial", "1"); - setOption("kde-special-command", s); - } -} - -TQString KPrinter::printerSelectionOption() const -{ return TQString::tqfromLatin1(""); } - -void KPrinter::setPrinterSelectionOption(const TQString&) -{} - -const TQMap<TQString,TQString>& KPrinter::options() const -{ return d->m_options; } - -TQString KPrinter::searchName() const -{ return d->m_searchname; } - -void KPrinter::setSearchName(const TQString& s) -{ d->m_searchname = s; } - -bool KPrinter::newPage() -{ - d->m_pagenumber++; - d->m_impl->statusMessage(i18n("Generating print data: page %1").arg(d->m_pagenumber), this); - return d->m_wrapper->newPage(); -} - -TQString KPrinter::outputFileName() const -{ return option("kde-outputfilename"); } - -void KPrinter::setOutputFileName(const TQString& f) -{ setOption("kde-outputfilename",f); setOutputToFile(!f.isEmpty()); } - -bool KPrinter::outputToFile() const -{ return (option("kde-outputtofile") == "1" || (option("kde-isspecial") == "1" && option("kde-special-command").isEmpty())); } - -void KPrinter::setOutputToFile(bool on) -{ - setOption("kde-outputtofile",(on ? "1" : "0")); - if (on) - { - setOption("kde-special-command",TQString::null); - setOption("kde-isspecial","1"); - } -} - -bool KPrinter::abort() -{ return d->m_wrapper->abort(); } - -bool KPrinter::aborted() const -{ return d->m_wrapper->aborted(); } - -void KPrinter::setMargins(TQSize m) -{ - setMargins( m.height(), m.width(), m.height(), m.width() ); -} - -void KPrinter::setMargins( uint top, uint left, uint bottom, uint right ) -{ - d->m_wrapper->setMargins( top, left, bottom, right ); - setOption( "kde-margin-top", TQString::number( top ), true ); - setOption( "kde-margin-left", TQString::number( left ), true ); - setOption( "kde-margin-bottom", TQString::number( bottom ), true ); - setOption( "kde-margin-right", TQString::number( right ), true ); -} - -// FIXME: remove for 4.0 -TQSize KPrinter::realPageSize() const -{ - kdWarning( 500 ) << "KPrinter::realPageSize() is obsolete, do not use" << endl; - if ( d->m_pagesize ) - return d->m_pagesize->pageSize(); - else - return TQSize(); -} - -void KPrinter::setRealPageSize(DrPageSize *p) -{ - if ( p ) - { - kdDebug( 500 ) << "Page size: width =" << p->pageWidth() << endl; - kdDebug( 500 ) << "Page size: height =" << p->pageHeight() << endl; - kdDebug( 500 ) << "Page size: left =" << p->leftMargin() << endl; - kdDebug( 500 ) << "Page size: top =" << p->topMargin() << endl; - kdDebug( 500 ) << "Page size: right =" << p->rightMargin() << endl; - kdDebug( 500 ) << "Page size: bottom =" << p->bottomMargin() << endl; - } - else - kdDebug( 500 ) << "Resetting page size" << endl; - - /* we copy the page size structure internally - * as the original object is owned by the driver - * that control its destrution */ - delete d->m_pagesize; - d->m_pagesize = 0; - if ( p ) - d->m_pagesize = new DrPageSize( *p ); -} - -// FIXME: remove for 4.0 -void KPrinter::setRealPageSize( TQSize ) -{ - kdWarning( 500 ) << "KPrinter::setRealPageSize(TQSize) is obsolete, do not use (no effect)" << endl; -} - -// FIXME: remove for 4.0 -void KPrinter::setRealDrawableArea( const TQRect& ) -{ - kdWarning( 500 ) << "KPrinter::setRealDrawableArea(TQRect) is obsolete, do not use (no effect)" << endl; -} - -// FIXME: remove for 4.0 -TQRect KPrinter::realDrawableArea() const -{ - kdWarning( 500 ) << "KPrinter::realDrawableArea() is obsolete, do not use" << endl; - if ( d->m_pagesize ) - return d->m_pagesize->pageRect(); - else - return TQRect(); -} - -TQString KPrinter::errorMessage() const -{ return d->m_errormsg; } - -void KPrinter::setErrorMessage(const TQString& msg) -{ d->m_errormsg = msg; } - -/* we're using a builtin member to store this state because we don't - * want to keep it from object to object. So there's no need to use - * the TQMap structure to store this - */ -void KPrinter::setPreviewOnly(bool on) -{ d->m_previewonly = on; } - -bool KPrinter::previewOnly() const -{ return d->m_previewonly; } - -void KPrinter::setDocFileName(const TQString& s) -{ d->m_docfilename = s; } - -TQString KPrinter::docFileName() const -{ return d->m_docfilename; } - -void KPrinter::setDocDirectory( const TQString& s ) -{ d->m_docdirectory = s; } - -TQString KPrinter::docDirectory() const -{ return ( d->m_docdirectory.isEmpty() ? TQDir::homeDirPath() : d->m_docdirectory ); } - -void KPrinter::setResolution(int dpi) -{ - d->m_wrapper->setResolution(dpi); - d->m_defaultres = dpi; -} - -int KPrinter::resolution() const -{ return d->m_wrapper->resolution(); } - -void KPrinter::setUsePrinterResolution( bool on ) -{ d->m_useprinterres = on; } diff --git a/kdeprint/kprinter.h b/kdeprint/kprinter.h deleted file mode 100644 index 4910c23ef..000000000 --- a/kdeprint/kprinter.h +++ /dev/null @@ -1,780 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KPRINTER_H -#define KPRINTER_H - -#include <tqpaintdevice.h> -#include <tqprinter.h> -#include <tqmap.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqvaluelist.h> -#include <kdemacros.h> -#include <kdelibs_export.h> - -#include <tdeprint/kpreloadobject.h> - -class KPrinterImpl; -class KPrintDialogPage; -class KPrinterPrivate; -class DrPageSize; - -/** - * This class is the main interface to access the KDE print framework. It allows KDE - * applications to easily access the print system, through an interface that is compatible - * with TQPrinter. So that the porting of an existing application should be as easy as - * replacing any occurrence of TQPrinter by KPrinter. However applications that explicitly - * used the TQPrintDialog class must be changed to the standard KPrinter way of accessing - * the print dialog. - * - * Basically, a KDE application will use the KPrinter object as a paint device, and will draw - * on it using TQPainter. In a standard application, the use of the KPrinter class will - * look like this: - * \code - * #include <kprinter.h> - * #include <tqpainter.h> - * - * void MyClass::doPrint() - * { - * KPrinter printer; - * - * // do some printer initialization - * printer.setFullPage( true ); - * - * // initialize the printer using the print dialog - * if ( printer.setup( this ) ) - * { - * // create a painter to paint on the printer object - * TQPainter painter; - * - * // start painting - * painter.begin( &printer ); - * <do something> - * // stop painting, this will automatically send the print data to the printer - * painter.end(); - * } - * } - * \endcode - * - * The KPrinter interface also allows some more advanced possibilities, like the customization - * of the print dialog to integrate application specific print options. This is done by subclassing - * KPrintDialogPage and adding the page using addDialogPage(). - * - * When compiling an application that uses KPrinter, you must link to -ltdeprint, which when - * using the standard KDE build framework can be done by adding $(LIB_KDEPRINT) to _LDADD. - * - * @short The central interface class to access the KDE print system. - * @author Michael Goffioul - * @see TQPrinter, KPrintDialogPage - */ -class KDEPRINT_EXPORT KPrinter : public TQPaintDevice, public KPReloadObject -{ -friend class KPrinterWrapper; -friend class KPrinterImpl; -public: - // Print global settings (set via static functions) - /** - * Defines the standard pages available for the print dialog: - * @li @p CopiesPage: page and copies selection (included by default) - * @li @p FilesPage: file selection (only used by kprinter utility) - * @li @p Custom: unused - * - * @see addStandardPage(), removeStandardPage() - */ - enum StandardPageType { CopiesPage = 0x01, FilesPage = 0x02, Custom = 0x10 }; - /** - * Defines whether the application can perform page selection itself or not. - * Some print systems (like CUPS) can do page selection, in this case the - * page selection will be enabled in the print dialog, otherwise it will be - * disabled. However some applications (word processor) can do page selection - * themselves, then it will be enabled in the print dialog, whatever the - * print system used. But such an application has to tell tdeprint about its - * feature: - * @li @p ApplicationSide: the application will do page selection - * @li @p SystemSide: page selection will be left to the print system, if available (default) - * - * @see setPageSelection(), pageSelection() - */ - enum PageSelectionType { ApplicationSide = 0x01, SystemSide = 0x02 }; - /** - * Defines the type of the application, this affects the GUI of the print dialog: - * @li @p Dialog: print dialog used in an application (default) - * @li @p StandAlone: print dialog used as a standalone widget - * @li @p StandAlonePersistent: print dialog used as standalone widget, but persistent (do not use) - * - * @internal - * @see setApplicationType(), applicationType() - */ - enum ApplicationType { Dialog = 0x00, StandAlone = 0x01, StandAlonePersistent = 0x02 }; - - // TQPrinter extension - /** - * Defines the page set to print: - * @li @p AllPages: all pages - * @li @p OddPages: only odd pages - * @li @p EvenPages: only even pages - * - * @see pageSet() - */ - enum PageSetType { AllPages = 0x00, OddPages = 0x01, EvenPages = 0x02 }; - /** - * Defines the collate property of the printer (if supported by the print system): - * @li @p Collate: copies collated (1-2-3-..., 1-2-3-...) - * @li @p Uncollate: copies uncollated (1-1-..., 2-2-..., 3-3-...) - * - * @see setCollate(), collate() - */ - enum CollateType { Collate = 0x00, Uncollate = 0x01 }; - - // from TQPrinter class - /** - * Defines the color mode of the printer - * @see TQPrinter::ColorMode - */ - enum ColorMode { GrayScale = TQPrinter::GrayScale, Color = TQPrinter::Color }; - /** - * Defines the orientation of the paper - * @see TQPrinter::Orientation - */ - enum Orientation { Portrait = TQPrinter::Portrait, Landscape = TQPrinter::Landscape }; - /** - * Defines the page order of the print job - * @see TQPrinter::PageOrder - */ - enum PageOrder { FirstPageFirst = TQPrinter::FirstPageFirst, LastPageFirst = TQPrinter::LastPageFirst }; - /** - * Defines the paper size to use - * @see TQPrinter::PageSize - */ - enum PageSize - { - A4 = TQPrinter::A4, - B5 = TQPrinter::B5, - Letter = TQPrinter::Letter, - Legal = TQPrinter::Legal, - Executive = TQPrinter::Executive, - A0 = TQPrinter::A0, - A1 = TQPrinter::A1, - A2 = TQPrinter::A2, - A3 = TQPrinter::A3, - A5 = TQPrinter::A5, - A6 = TQPrinter::A6, - A7 = TQPrinter::A7, - A8 = TQPrinter::A8, - A9 = TQPrinter::A9, - B0 = TQPrinter::B0, - B1 = TQPrinter::B1, - B10 = TQPrinter::B10, - B2 = TQPrinter::B2, - B3 = TQPrinter::B3, - B4 = TQPrinter::B4, - B6 = TQPrinter::B6, - B7 = TQPrinter::B7, - B8 = TQPrinter::B8, - B9 = TQPrinter::B9, - C5E = TQPrinter::C5E, - Comm10E = TQPrinter::Comm10E, - DLE = TQPrinter::DLE, - Folio = TQPrinter::Folio, - Ledger = TQPrinter::Ledger, - Tabloid = TQPrinter::Tabloid, - NPageSize = TQPrinter::NPageSize - }; - - // constructors / destructor - /** - * Constructor. This also restores/saves the state from a previous KPrinter object created within - * the same application run, if @p restore is true. Setting @p restore to false may - * be useful if you want an independent/clean KPrinter object. - * @param restore if true, options will be restored/saved between successive KPrinter objects - * @param m the mode to establish the KPrinter in (see TQPrinter::PrinterMode) - */ - KPrinter(bool restore = true, TQPrinter::PrinterMode m = TQPrinter::ScreenResolution ); - /** - * Destructor. This also saves the current KPrinter state for future printing. - */ - ~KPrinter(); - - // TQPrinter interface (+ some extensions) - /** - * See TQPrinter::newPage(). - */ - bool newPage(); - /** - * See TQPrinter::abort(). - */ - bool abort(); - /** - * See TQPrinter::aborted(.) - */ - bool aborted() const; - /** - * See TQPrinter::outputToFile(). - */ - bool outputToFile() const; - /** - * See TQPrinter::setOutputToFile(). - */ - void setOutputToFile(bool); - /** - * See TQPrinter::outputFileName(). - */ - TQString outputFileName() const; - /** - * See TQPrinter::setOutputFileName(). - */ - void setOutputFileName(const TQString&); - /** - * See TQPrinter::docName(). - */ - TQString docName() const; - /** - * See TQPrinter::setDocName(). - */ - void setDocName(const TQString&); - /** - * See TQPrinter::creator(). - */ - TQString creator() const; - /** - * See TQPrinter::setCreator(). - */ - void setCreator(const TQString&); - /** - * See TQPrinter::fullPage(). - */ - bool fullPage() const; - /** - * See TQPrinter::setFullPage(). - */ - void setFullPage(bool); - /** - * See TQPrinter::colorMode(). - */ - ColorMode colorMode() const; - /** - * See TQPrinter::setColorMode(). - */ - void setColorMode(ColorMode); - /** - * See TQPrinter::numCopies(). - */ - int numCopies() const; - /** - * See TQPrinter::setNumCopies(). - */ - void setNumCopies(int n); - /** - * See TQPrinter::orientation(). - */ - Orientation orientation() const; - /** - * See TQPrinter::setOrientation(). - */ - void setOrientation(Orientation); - /** - * See TQPrinter::pageOrder(). - */ - PageOrder pageOrder() const; - /** - * See TQPrinter::setPageOrder(). - */ - void setPageOrder(PageOrder); - /** - * Returns the collate status of the current KPrinter. - */ - CollateType collate() const; - /** - * Sets the collate status for the current KPrinter to @p type. - */ - void setCollate(CollateType type); - /** - * See TQPrinter::minPage(). - */ - int minPage() const; - /** - * See TQPrinter::maxPage(). - */ - int maxPage() const; - /** - * See TQPrinter::setMinMax(). - */ - void setMinMax(int, int); - /** - * Returns the first page to be printed. - * @deprecated Applications - * should use pageList() instead, which takes into account all options: collate, - * page order, ranges, page set, ... - * - * @see pageList() - */ - int fromPage() const KDE_DEPRECATED; - /** - * Returns the last page to be printed. - * @deprecated Applications - * should use pageList() instead, which takes into account all options: collate, - * page order, ranges, page set, ... - * - * @see pageList() - */ - int toPage() const; - /** - * Sets the first and last page to be printed. See TQPrinter::setFromTo(). - */ - void setFromTo(int, int); - /** - * See TQPrinter::pageSize(). - */ - PageSize pageSize() const; - /** - * See TQPrinter::setPageSize(). - */ - void setPageSize(PageSize); - /** - * See TQPrinter::printerName(). - */ - TQString printerName() const; - /** - * See TQPrinter::setPrinterName(). - */ - void setPrinterName(const TQString&); - /** - * Returns the print program as set by setPrintProgram() or by the print dialog - * if a special printer has been selected. - * @return the print command line - * @see setPrintProgram() - */ - TQString printProgram() const; - /** - * Sets the command line to use when printing. This function is useful - * when using a KPrinter object without the print dialog, to control what - * to print and how to do it. The command line may contain the following - * tags: - * @li %in : the input file to the print program. It is required and automatically - * appended at the end of the command line if not present. - * @li %out : the output file. Use this tag in conjunction with setOutputToFile() - * and setOutputFileName() - * @li %psl : the page size in lower case. This may be useful with some - * programs like gs. - * \code - * void createPNGOutputFile(const TQString& filename) - * { - * // use a clean KPrinter object - * KPrinter prt(false); - * - * prt.setOutputToFile( true ); - * prt.setOutputFileName( filename ); - * prt.setPrintProgram( "gs -sDEVICE=png256 -sPAPERSIZE=%psl -sOutputFile=%out %in" ); - * - * TQPainter painter( &prt ); - * doPaint( &painter ); - * } - * \endcode - * @param cmd the print command line (containing at least the @p %in tag) - * @see printProgram() - */ - void setPrintProgram(const TQString& cmd); - /** - * See TQPrinter::printerSelectionOption(). Unused. - */ - TQString printerSelectionOption() const; - /** - * See TQPrinter::setPrinterSelectionOption(). Unused - */ - void setPrinterSelectionOption(const TQString&); - /** - * Returns the current page number. - * @see setCurrentPage() - */ - int currentPage() const; - /** - * Sets the current page number. This page number will be used if the user - * selected "current page" in the print dialog. This option will only be - * enabled if the application does page selection itself and the application - * has called setCurrentPage() before opening the print dialog: - * \code - * MyClass::MyClass() - * { - * // declares my application able to do page selection - * KPrinter::setPageSelection( KPrinter::ApplicationSide ); - * } - * - * void MyClass::doPrint() - * { - * KPrinter printer; - * - * printer.setCurrentPage( mycurrentpage ); - * if ( printer.setup( this ) ) - * { - * TQValueList<int> pages = printer.pageList(); - * // print the pages - * ... - * } - * } - * \endcode - * @param p the current page number (starting from 1) - */ - void setCurrentPage(int p = 0); - /** - * Returns the page set of the current KPrinter object. - */ - PageSetType pageSet() const; - /** - * Sets up the KPrinter object using the print dialog, returns true if the user clicked OK. - * @param parent the parent widget to use for the print dialog - * @param caption the caption to use in the print dialog - * @param forceExpand force the expansion of the dialog (the show/hide button will be hidden) - * @returns boolean value corresponding to the button clicked by the user - */ - bool setup(TQWidget *parent = 0, const TQString& caption = TQString::null, bool forceExpand = false); - /** - * See TQPrinter::margins(). - */ - TQSize margins() const; - /** - * Not used yet. - */ - void setMargins(TQSize m); - /** - * Returns the page size in dot unit ( 1 dot = 1/72th in ). This method is intended for - * internal use, if you want to access actual page size, use a TQPaintDeviceMetrics object - * instead. Note that the size returned by this method does not take resolution into - * account, and that it can returns invalid size if no page metric was found in the printer - * driver. DO NOT USE, WILL BE REMOVED. - * @see setRealPageSize - * @obsolete - */ - TQSize realPageSize() const; - /** - * DO NOT USE, WILL BE REMOVED. - * @obsolete - */ - void setRealPageSize( TQSize p ); - /** - * DO NOT USE, WILL BE REMOVED. - * @obsolete - */ - void setRealDrawableArea( const TQRect& r ); - /** - * DO NOT USE, WILL BE REMOVED. - * @obsolete - */ - TQRect realDrawableArea() const; - - void margins( uint *top, uint *left, uint *bottom, uint *right ) const; - void setMargins( uint top, uint left, uint bottom, uint right ); - - /** - * Returns the page list to be printed, correpsonding to the options selected by the user. This - * takes into account collate, page order, page set, ranges, ... This is useful when the - * application does page selection itself. - * @see setCurrentPage() - */ - TQValueList<int> pageList() const; - /** - * Sets the KPrinter object to preview mode if @p on is true. In this mode, nothing will be - * printed but only a preview dialog will be popped up with the single "Close" action. Using - * this mode, any application can easily implement a preview action: - * \code - * void MyClass:doPreview() - * { - * // use a "clean" KPrinter object (independent from previous print jobs), - * // this is not necessary, it depends on the application - * KPrinter prt( false ); - * prt.setPreviewOnly( true ); - * - * TQPainter painter( &prt ); - * doPrint( &painter ); - * } - * \endcode - * @param on the preview-only state - * @see previewOnly() - */ - void setPreviewOnly(bool on); - /** - * Returns the preview-only state for this KPrinter object. - * @see setPreviewOnly() - */ - bool previewOnly() const; - /** - * Set the resolution of the current KPrinter object. The resolution is given in DPI. This - * resolution mainly affects the accuracy for object positionning on the paint device, and - * does not influence the real resolution that will be used by the printer (this should be - * set in the driver settings). The resolution is usually defined in the constructor. - * @param dpi the resolution in DPI - * @see KPrinter(), resolution() - */ - void setResolution(int dpi); - /** - * Resturns the resolution of the current KPrinter object. The resolution is given in DPI. - * @returns resolution in DPI - * @see setResolution(), KPrinter() - */ - int resolution() const; - - /** - * Define the KPrinter object to use the actual printer resolution. Under some print systems - * (CUPS, Foomatic, PostScript printers), it is possible to know the actual resolution that - * is used by the printer, as selected by the user in the driver settings. If @p on is true, - * this KPrinter object will use the actual printer resolution if it is able to extract it. - * If nothing can be found, the default resolution will be the one defined by the PrinterMode - * argument used in the KPrinter constructor, or set explicitly by setResolution(). - * @param on true if the KPrinter object should use the actual printer resolution - * @see resolution(), setResolution() - */ - void setUsePrinterResolution( bool on ); - - /** - * For internal use only. - */ - KPrinterImpl* implementation() const; - /** - * Prints the files given in argument. This will first filter the files accorsing to the filtering - * options selected by the user in the print dialog, then send the filtered files to the printer - * with the print options selected. This function is called automatically when calling - * TQPainter::end() for a painter object constructed on KPrinter. In normal use, you don't need - * this use this function explicitly. - */ - bool printFiles(const TQStringList& files, bool removeafter = false, bool startviewer = true); - - /** - * Adds a customized page to the print dialog. The pages will appear in a tab widget in the - * bottom half of the dialog, along with the standard "Copies" page. The page must be created - * and added each time you want open a print dialog with setup(). If you correctly - * reimplemented KPrintDialogPage::setOptions(), the settings will be restored from call - * to call, you don't have to worry about state saving/restoration. - * @param _page the page to add - * @see KPrintDialogPage::setOptions() - */ - static void addDialogPage(KPrintDialogPage* _page); - /** - * Sets the page selection mode of the application. If needed, call this method somewhere at - * the beginning of your code. The default value is @p SystemSide. - * @param _mode the mode for the application - * @see pageSelection() - */ - static void setPageSelection(PageSelectionType _mode); - /** - * Returns the page selection mode of the current application. - * @returns the page selection mode - * @see setPageSelection() - */ - static PageSelectionType pageSelection(); - /** - * Sets the application type concerning the print dialog. You probably don't want to use it. - * For internal use only. - * @param type the type for this application - * @see applicationType() - */ - static void setApplicationType(ApplicationType type); - /** - * Returns the application type concerning the print dialog. For internal use only. - * @returns the type for the current application - * @see setApplicationType() - */ - static ApplicationType applicationType(); - /** - * Adds a standard page to the print dialog. This is not useful yet as there's only one - * standard page defines @p CopiesPage. - * @param p the page identifier - * @see StandardPageType - */ - static void addStandardPage(int p); - /** - * Removes a standard page from the print dialog. If your application doesn't want a - * standard page in the dialog, simply call this method with the correct identifier. - * By default, the print dialog includes the @p CopiesPage page. - * @param p the page identifier - * @see StandardPageType - */ - static void removeStandardPage(int p); - /** - * Starts the add printer wizard. This utility function allows any application for - * adding a printer using the KDEPrint powerful wizard. - * @param parent the parent widget for the wizard - * @returns 1: success, 0: cancel, -1: error - */ - //static int addPrinterWizard(TQWidget *parent = 0); - - /** - * The KPrinter object stores all its settings in an internal TQMap structure on - * TQString. This allows to store any property. This method allows an application to access - * any print option from the KPrinter object, using the option name. For example if your - * application add a customized page to the print dialog, this page will saves its settings - * into the KPrinter object using this TQMap<TQString,TQString> structure. After showing the - * print dialog, your application can then access these options using this method. The - * custom option name should follow the form "kde-appname-optionname". - * \code - * void MyClass::doPrint() - * { - * KPrinter prt; - * - * // add my custom page - * prt.addDialogPage( new MyDialogPage() ); - * - * // open print dialog - * if ( prt.setup( this ) ) - * { - * TQString fntname = prt.option( "kde-myapp-fontname" ); - * ... - * do_something; - * ... - * } - * } - * \endcode - * @param key the option name (key) - * @returns the option value correponding to the key, or TQString::null - * @see KPrintDialogPage, setOption, options(), setOptions() - */ - const TQString& option(const TQString& key) const; - /** - * Adds or modifies an option in the KPrinter object. You probably don't need to use this function - * explicitly. This will be done implicitely for example when reimplementing - * KPrintDialogPage::getOptions(). - * @param key the option name - * @param value the option value - * @see option(), KPrintDialogPage - */ - void setOption(const TQString& key, const TQString& value); - /** - * Returns the complete set of print options from the KPrinter object. For internal use. - * @returns the option set as a TQMap object - */ - const TQMap<TQString,TQString>& options() const; - /** - * Sets the option set in one operation. This method has some side effects like merging - * the internal map with the one given in argument, but only for option in the form - * "kde-...". For internal use only. - * @param opts the option set to be merged in the KPrinter object - */ - void setOptions(const TQMap<TQString,TQString>& opts); - /** - * For internal use only. Does a similar job as setOption(), except that all possible - * internal printers are initialized with the option if it has the form "kde-...". - * @param opts the option set - * @see setOptions() - */ - void initOptions(const TQMap<TQString,TQString>& opts); - - /** - * Returns the search name of the printer selected by the user. Each printer is identified by - * a unique name. This method is mainly used for state restoration. For internal use. - * @returns the unique printer search name - * @see setSearchName - */ - TQString searchName() const; - /** - * Sets the search name of the KPrinter object. For internal use. - * @param n the unique printer search name - * @see searchName() - */ - void setSearchName(const TQString& n); - /** - * Returns the last error message issued by the print system. Unimplemented yet. - * @returns the last error message - */ - TQString errorMessage() const; - /** - * Sets the last error message. For internal use. - * @param msg the error message - */ - void setErrorMessage(const TQString& msg); - /** - * Configure the KPrinter object to be used with the printer named - * @p prname. After the call, the KPrinter object can be used without - * the need to call the print dialog. If @p prname is empty, then the - * KPrinter object is configured for the default printer. If @p prname - * corresponds to a pseudo-printer which needs an output file, a file - * dialog will be used. In that case, providing a parent widget for - * that dialog in @p parent may be useful. - * @param prname the name of the printer for which the KPrinter object - * has to be configured - * @param parent a parent widget, used a parent for a file dialog - * @returns boolean flag: if false, the KPrinter has not been correctly - * set up, and the application shouldn't use it to print. This may - * happen if the printer named @p prname has not been found or if the - * user clicked "Cancel" in the file dialog. - * @see setup() - */ - bool autoConfigure(const TQString& prname = TQString::null, TQWidget *parent = 0); - /** - * Set the default document filename. This filename will be used as the - * default basename for the output file, instead of the default "print". - * For example, by using setDocFileName("my_document"), the default - * output file will be $HOME/my_document.ps. - * @param filename the default document basename to use - * @see docFileName() - */ - void setDocFileName(const TQString& filename); - /** - * Get the default document filename, that is the default basename used for - * the output file. - * @returns the default document basename - * @see setDocFileName() - */ - TQString docFileName() const; - /** - * Set the default document directory. This directory will be used as - * the default location for any output file. If not set, $HOME directory - * is used instead. - * @param dir the new default output directory - * @see docDirectory() - */ - void setDocDirectory( const TQString& dir ); - /** - * Get the default document directory, that is the directory used for - * any output file. By default, it is the $HOME directory. - * @returns the default output directory - * @see setDocDirectory - */ - TQString docDirectory() const; - -protected: - virtual bool cmd(int, TQPainter*, TQPDevCmdParam*); - virtual int metric(int) const; - void translateQtOptions(); - void loadSettings(); - void saveSettings(); - void preparePrinting(); - void finishPrinting(); - void reload(); - void init(bool restore = true, TQPrinter::PrinterMode m = TQPrinter::ScreenResolution); - bool doPreview(const TQString& file); - void setRealPageSize(DrPageSize* p); - void setOption( const TQString& key, const TQString& value, bool broadcast ); - -protected: - KPrinterPrivate *d; -}; - -//************************************************************************************** - -// Utility functions - -KDEPRINT_EXPORT KPrinter::PageSize pageNameToPageSize(const TQString& name); -KDEPRINT_EXPORT const char* pageSizeToPageName(KPrinter::PageSize s); -/** - * DO NOT USE, WILL BE REMOVED. - * @obsolete - */ -TQSize rangeToSize( const TQString& ); - -#endif diff --git a/kdeprint/kprinterimpl.cpp b/kdeprint/kprinterimpl.cpp deleted file mode 100644 index 166ae7207..000000000 --- a/kdeprint/kprinterimpl.cpp +++ /dev/null @@ -1,606 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 "kprinterimpl.h" -#include "kprinter.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmuimanager.h" -#include "kxmlcommand.h" -#include "kmspecialmanager.h" -#include "kmthreadjob.h" -#include "kmprinter.h" -#include "driver.h" - -#include <tqfile.h> -#include <tqregexp.h> -#include <kinputdialog.h> -#include <klocale.h> -#include <dcopclient.h> -#include <kapplication.h> -#include <kstandarddirs.h> -#include <kdatastream.h> -#include <kdebug.h> -#include <kmimemagic.h> -#include <kmessagebox.h> -#include <kprocess.h> -#include <kconfig.h> - -#include <stdlib.h> - -void dumpOptions(const TQMap<TQString,TQString>&); -void initEditPrinter(KMPrinter *p) -{ - if (!p->isEdited()) - { - p->setEditedOptions(p->defaultOptions()); - p->setEdited(true); - } -} - -//**************************************************************************************** - -KPrinterImpl::KPrinterImpl(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - loadAppOptions(); -} - -KPrinterImpl::~KPrinterImpl() -{ -} - -void KPrinterImpl::preparePrinting(KPrinter *printer) -{ - // page size -> try to find page size and margins from driver file - // use "PageSize" as option name to find the wanted page size. It's - // up to the driver loader to use that option name. - KMManager *mgr = KMFactory::self()->manager(); - DrMain *driver = mgr->loadPrinterDriver(mgr->findPrinter(printer->printerName()), false); - if (driver) - { - // Find the page size: - // 1) print option - // 2) default driver option - QString psname = printer->option("PageSize"); - if (psname.isEmpty()) - { - DrListOption *opt = (DrListOption*)driver->findOption("PageSize"); - if (opt) psname = opt->get("default"); - } - if (!psname.isEmpty()) - { - printer->setOption("kde-pagesize",TQString::number((int)pageNameToPageSize(psname))); - DrPageSize *ps = driver->findPageSize(psname); - if (ps) - { - printer->setRealPageSize( ps ); - } - } - - // Find the numerical resolution - // 1) print option (Resolution) - // 2) default driver option (Resolution) - // 3) default printer resolution - // The resolution must have the format: XXXdpi or XXXxYYYdpi. In the second - // case the YYY value is used as resolution. - TQString res = printer->option( "Resolution" ); - if ( res.isEmpty() ) - { - DrBase *opt = driver->findOption( "Resolution" ); - if ( opt ) - res = opt->get( "default" ); - if ( res.isEmpty() ) - res = driver->get( "resolution" ); - } - if ( !res.isEmpty() ) - { - TQRegExp re( "(\\d+)(?:x(\\d+))?dpi" ); - if ( re.search( res ) != -1 ) - { - if ( !re.cap( 2 ).isEmpty() ) - printer->setOption( "kde-resolution", re.cap( 2 ) ); - else - printer->setOption( "kde-resolution", re.cap( 1 ) ); - } - } - - // Find the supported fonts - TQString fonts = driver->get( "fonts" ); - if ( !fonts.isEmpty() ) - printer->setOption( "kde-fonts", fonts ); - - delete driver; - } - -} - -bool KPrinterImpl::setupCommand(TQString&, KPrinter*) -{ - return false; -} - -bool KPrinterImpl::printFiles(KPrinter *p, const TQStringList& f, bool flag) -{ - TQString cmd; - if (p->option("kde-isspecial") == "1") - { - if (p->option("kde-special-command").isEmpty() && p->outputToFile()) - { - KURL url( p->outputFileName() ); - if ( !url.isLocalFile() ) - { - cmd = ( flag ? "mv" : "cp" ) + ( " %in $out{" + p->outputFileName() + "}" ); - } - else - { - if (f.count() > 1) - { - p->setErrorMessage(i18n("Cannot copy multiple files into one file.")); - return false; - } - else - { - KProcess proc; - proc << (flag?"mv":"cp") << f[0] << p->outputFileName(); - if (!proc.start(KProcess::Block) || !proc.normalExit() || proc.exitStatus() != 0) - { - p->setErrorMessage(i18n("Cannot save print file to %1. Check that you have write access to it.").arg(p->outputFileName())); - return false; - } - } - return true; - } - } - else if (!setupSpecialCommand(cmd,p,f)) - return false; - } - else if (!setupCommand(cmd,p)) - return false; - return startPrinting(cmd,p,f,flag); -} - -void KPrinterImpl::broadcastOption(const TQString& key, const TQString& value) -{ - // force printer listing if not done yet (or reload needed) - TQPtrList<KMPrinter> *printers = KMFactory::self()->manager()->printerListComplete(false); - if (printers) - { - TQPtrListIterator<KMPrinter> it(*printers); - for (;it.current();++it) - { - initEditPrinter(it.current()); - it.current()->setEditedOption(key,value); - } - } -} - -int KPrinterImpl::dcopPrint(const TQString& cmd, const TQStringList& files, bool removeflag) -{ - kdDebug(500) << "tdeprint: print command: " << cmd << endl; - - int result = 0; - DCOPClient *dclient = kapp->dcopClient(); - if (!dclient || (!dclient->isAttached() && !dclient->attach())) - { - return result; - } - - TQByteArray data, replyData; - TQCString replyType; - TQDataStream arg( data, IO_WriteOnly ); - arg << cmd; - arg << files; - arg << removeflag; - if (dclient->call( "kded", "tdeprintd", "print(TQString,TQStringList,bool)", data, replyType, replyData )) - { - if (replyType == "int") - { - TQDataStream _reply_stream( replyData, IO_ReadOnly ); - _reply_stream >> result; - } - } - return result; -} - -void KPrinterImpl::statusMessage(const TQString& msg, KPrinter *printer) -{ - kdDebug(500) << "tdeprint: status message: " << msg << endl; - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("General"); - if (!conf->readBoolEntry("ShowStatusMsg", true)) - return; - - TQString message(msg); - if (printer && !msg.isEmpty()) - message.prepend(i18n("Printing document: %1").arg(printer->docName())+"\n"); - - DCOPClient *dclient = kapp->dcopClient(); - if (!dclient || (!dclient->isAttached() && !dclient->attach())) - { - return; - } - - TQByteArray data; - TQDataStream arg( data, IO_WriteOnly ); - arg << message; - arg << (int)getpid(); - arg << kapp->caption(); - dclient->send( "kded", "tdeprintd", "statusMessage(TQString,int,TQString)", data ); -} - -bool KPrinterImpl::startPrinting(const TQString& cmd, KPrinter *printer, const TQStringList& files, bool flag) -{ - statusMessage(i18n("Sending print data to printer: %1").arg(printer->printerName()), printer); - - TQString command(cmd), filestr; - TQStringList printfiles; - if (command.find("%in") == -1) command.append(" %in"); - - for (TQStringList::ConstIterator it=files.begin(); it!=files.end(); ++it) - if (TQFile::exists(*it)) - { - // quote filenames - filestr.append(quote(*it)).append(" "); - printfiles.append(*it); - } - else - kdDebug(500) << "File not found: " << (*it) << endl; - - if (printfiles.count() > 0) - { - command.replace("%in",filestr); - int pid = dcopPrint(command,files,flag); - if (pid > 0) - { - if (printer) - KMThreadJob::createJob(pid,printer->printerName(),printer->docName(),getenv("USER"),0); - return true; - } - else - { - TQString msg = i18n("Unable to start child print process. "); - if (pid == 0) - msg += i18n("The KDE print server (<b>tdeprintd</b>) could not be contacted. Check that this server is running."); - else - msg += i18n("1 is the command that <files> is given to", "Check the command syntax:\n%1 <files>").arg(cmd); - printer->setErrorMessage(msg); - return false; - } - } - //else - //{ - printer->setErrorMessage(i18n("No valid file was found for printing. Operation aborted.")); - return false; - //} -} - -TQString KPrinterImpl::tempFile() -{ - TQString f; - // be sure the file doesn't exist - do f = locateLocal("tmp","tdeprint_") + KApplication::randomString(8); while (TQFile::exists(f)); - return f; -} - -int KPrinterImpl::filterFiles(KPrinter *printer, TQStringList& files, bool flag) -{ - TQStringList flist = TQStringList::split(',',printer->option("_kde-filters"),false); - TQMap<TQString,TQString> opts = printer->options(); - - // generic page selection mechanism (using psselect filter) - // do it only if: - // - using system-side page selection - // - special printer or regular printer without page selection support in current plugin - // - one of the page selection option has been selected to non default value - // Action -> add the psselect filter to the filter chain. - if (printer->pageSelection() == KPrinter::SystemSide && - (printer->option("kde-isspecial") == "1" || !(KMFactory::self()->uiManager()->pluginPageCap() & KMUiManager::PSSelect)) && - (printer->pageOrder() == KPrinter::LastPageFirst || - !printer->option("kde-range").isEmpty() || - printer->pageSet() != KPrinter::AllPages)) - { - if (flist.findIndex("psselect") == -1) - { - int index = KXmlCommandManager::self()->insertCommand(flist, "psselect", false); - if (index == -1 || !KXmlCommandManager::self()->checkCommand("psselect")) - { - printer->setErrorMessage(i18n("<p>Unable to perform the requested page selection. The filter <b>psselect</b> " - "cannot be inserted in the current filter chain. See <b>Filter</b> tab in the " - "printer properties dialog for further information.</p>")); - return -1; - } - } - if (printer->pageOrder() == KPrinter::LastPageFirst) - opts["_kde-psselect-order"] = "r"; - if (!printer->option("kde-range").isEmpty()) - opts["_kde-psselect-range"] = printer->option("kde-range"); - if (printer->pageSet() != KPrinter::AllPages) - opts["_kde-psselect-set"] = (printer->pageSet() == KPrinter::OddPages ? "-o" : "-e"); - } - - return doFilterFiles(printer, files, flist, opts, flag); -} - -int KPrinterImpl::doFilterFiles(KPrinter *printer, TQStringList& files, const TQStringList& flist, const TQMap<TQString,TQString>& opts, bool flag) -{ - // nothing to do - if (flist.count() == 0) - return 0; - - TQString filtercmd; - TQStringList inputMimeTypes; - for (uint i=0;i<flist.count();i++) - { - KXmlCommand *filter = KXmlCommandManager::self()->loadCommand(flist[i]); - if (!filter) - { - printer->setErrorMessage(i18n("<p>Could not load filter description for <b>%1</b>.</p>").arg(flist[i])); - return -1; // Error - } - if (i == 0) - inputMimeTypes = filter->inputMimeTypes(); - - TQString subcmd = filter->buildCommand(opts,(i>0),(i<(flist.count()-1))); - delete filter; - if (!subcmd.isEmpty()) - { - filtercmd.append(subcmd); - if (i < flist.count()-1) - filtercmd.append("| "); - } - else - { - printer->setErrorMessage(i18n("<p>Error while reading filter description for <b>%1</b>. Empty command line received.</p>").arg(flist[i])); - return -1; - } - } - kdDebug(500) << "tdeprint: filter command: " << filtercmd << endl; - - TQString rin("%in"), rout("%out"), rpsl("%psl"), rpsu("%psu"); - TQString ps = pageSizeToPageName( printer->option( "kde-printsize" ).isEmpty() ? printer->pageSize() : ( KPrinter::PageSize )printer->option( "kde-printsize" ).toInt() ); - for (TQStringList::Iterator it=files.begin(); it!=files.end(); ++it) - { - TQString mime = KMimeMagic::self()->findFileType(*it)->mimeType(); - if (inputMimeTypes.find(mime) == inputMimeTypes.end()) - { - if (KMessageBox::warningContinueCancel(0, - "<p>" + i18n("The MIME type %1 is not supported as input of the filter chain " - "(this may happen with non-CUPS spoolers when performing page selection " - "on a non-PostScript file). Do you want KDE to convert the file to a supported " - "format?</p>").arg(mime), - TQString::null, i18n("Convert")) == KMessageBox::Continue) - { - TQStringList ff; - int done(0); - - ff << *it; - while (done == 0) - { - bool ok(false); - TQString targetMime = KInputDialog::getItem( - i18n("Select MIME Type"), - i18n("Select the target format for the conversion:"), - inputMimeTypes, 0, false, &ok); - if (!ok) - { - printer->setErrorMessage(i18n("Operation aborted.")); - return -1; - } - TQStringList filters = KXmlCommandManager::self()->autoConvert(mime, targetMime); - if (filters.count() == 0) - { - KMessageBox::error(0, i18n("No appropriate filter found. Select another target format.")); - } - else - { - int result = doFilterFiles(printer, ff, filters, TQMap<TQString,TQString>(), flag); - if (result == 1) - { - *it = ff[0]; - done = 1; - } - else - { - KMessageBox::error(0, - i18n("<qt>Operation failed with message:<br>%1<br>Select another target format.</qt>").arg(printer->errorMessage())); - } - } - } - } - else - { - printer->setErrorMessage(i18n("Operation aborted.")); - return -1; - } - } - - TQString tmpfile = tempFile(); - TQString cmd(filtercmd); - cmd.replace(rout,quote(tmpfile)); - cmd.replace(rpsl,ps.lower()); - cmd.replace(rpsu,ps); - cmd.replace(rin,quote(*it)); // Replace as last, filename could contain "%psl" - statusMessage(i18n("Filtering print data"), printer); - int status = system(TQFile::encodeName(cmd)); - if (status < 0 || WEXITSTATUS(status) == 127) - { - printer->setErrorMessage(i18n("Error while filtering. Command was: <b>%1</b>.").arg(filtercmd)); - return -1; - } - if (flag) TQFile::remove(*it); - *it = tmpfile; - } - return 1; -} - -int KPrinterImpl::autoConvertFiles(KPrinter *printer, TQStringList& files, bool flag) -{ - TQString primaryMimeType = "application/postscript"; - TQStringList mimeTypes( primaryMimeType ); - if ( printer->option( "kde-isspecial" ) == "1" ) - { - if ( !printer->option( "kde-special-command" ).isEmpty() ) - { - KXmlCommand *cmd = KXmlCommandManager::self()->loadCommand( printer->option( "kde-special-command" ), true ); - if ( cmd ) - { - mimeTypes = cmd->inputMimeTypes(); - // FIXME: the XML command description should now contain a primiary - // mime type as well. This is a temporary-only solution. - primaryMimeType = mimeTypes[ 0 ]; - } - } - } - else - { - KMFactory::PluginInfo info = KMFactory::self()->pluginInfo(KMFactory::self()->printSystem()); - mimeTypes = info.mimeTypes; - primaryMimeType = info.primaryMimeType; - } - KMFactory::PluginInfo info = KMFactory::self()->pluginInfo(KMFactory::self()->printSystem()); - int status(0), result; - for (TQStringList::Iterator it=files.begin(); it!=files.end(); ) - { - TQString mime = KMimeMagic::self()->findFileType(*it)->mimeType(); - if ( mime == "application/x-zerosize" ) - { - // special case of empty file - KMessageBox::information( NULL, - i18n( "<qt>The print file is empty and will be ignored:<p>%1</p></qt>" ).arg( *it ), - TQString::null, "emptyFileNotPrinted" ); - if ( flag ) - TQFile::remove( *it ); - it = files.remove( it ); - continue; - } - else if (mimeTypes.findIndex(mime) == -1) - { - if ((result=KMessageBox::warningYesNoCancel(NULL, - i18n("<qt>The file format <em> %1 </em> is not directly supported by the current print system. You " - "now have 3 options: " - "<ul> " - "<li> KDE can attempt to convert this file automatically to a supported format. " - "(Select <em>Convert</em>) </li>" - "<li> You can try to send the file to the printer without any conversion. " - "(Select <em>Keep</em>) </li>" - "<li> You can cancel the printjob. " - "(Select <em>Cancel</em>) </li>" - "</ul> " - "Do you want KDE to attempt and convert this file to %2?</qt>").arg(mime).arg(primaryMimeType), - TQString::null, - i18n("Convert"), - i18n("Keep"), - TQString::tqfromLatin1("tdeprintAutoConvert"))) == KMessageBox::Yes) - { - // find the filter chain - TQStringList flist = KXmlCommandManager::self()->autoConvert(mime, primaryMimeType); - if (flist.count() == 0) - { - KMessageBox::error(NULL, - i18n("<qt>No appropriate filter was found to convert the file format %1 into %2.<br>" - "<ul>" - "<li>Go to <i>System Options -> Commands</i> to look through the list of " - "possible filters. Each filter executes an external program.</li>" - "<li> See if the required external program is available.on your " - "system.</li>" - "</ul>" - "</qt>").arg(mime).arg(primaryMimeType), - i18n("Print")); - if (flag) - TQFile::remove(*it); - it = files.remove(it); - continue; - } - TQStringList l(*it); - switch (doFilterFiles(printer, l, flist, TQMap<TQString,TQString>(), flag)) - { - case -1: - return -1; - case 0: - break; - case 1: - status = 1; - *it = l[0]; - break; - } - } - else if (result == KMessageBox::Cancel) - { - files.clear(); - return 0; - } - } - ++it; - } - return status; -} - -bool KPrinterImpl::setupSpecialCommand(TQString& cmd, KPrinter *p, const TQStringList&) -{ - TQString s(p->option("kde-special-command")); - if (s.isEmpty()) - { - p->setErrorMessage("Empty command."); - return false; - } - - s = KMFactory::self()->specialManager()->setupCommand(s, p->options()); - - TQString ps = pageSizeToPageName( p->option( "kde-printsize" ).isEmpty() ? p->pageSize() : ( KPrinter::PageSize )p->option( "kde-printsize" ).toInt() ); - s.replace("%psl", ps.lower()); - s.replace("%psu", ps); - s.replace("%out", "$out{" + p->outputFileName() + "}"); // Replace as last - cmd = s; - return true; -} - -TQString KPrinterImpl::quote(const TQString& s) -{ return KProcess::quote(s); } - -void KPrinterImpl::saveOptions(const TQMap<TQString,TQString>& opts) -{ - m_options = opts; - saveAppOptions(); -} - -void KPrinterImpl::loadAppOptions() -{ - KConfig *conf = KGlobal::config(); - conf->setGroup("KPrinter Settings"); - TQStringList opts = conf->readListEntry("ApplicationOptions"); - for (uint i=0; i<opts.count(); i+=2) - if (opts[i].startsWith("app-")) - m_options[opts[i]] = opts[i+1]; -} - -void KPrinterImpl::saveAppOptions() -{ - TQStringList optlist; - for (TQMap<TQString,TQString>::ConstIterator it=m_options.begin(); it!=m_options.end(); ++it) - if (it.key().startsWith("app-")) - optlist << it.key() << it.data(); - - KConfig *conf = KGlobal::config(); - conf->setGroup("KPrinter Settings"); - conf->writeEntry("ApplicationOptions", optlist); -} - -#include "kprinterimpl.moc" diff --git a/kdeprint/kprinterimpl.h b/kdeprint/kprinterimpl.h deleted file mode 100644 index 618d9a429..000000000 --- a/kdeprint/kprinterimpl.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KPRINTERIMPL_H -#define KPRINTERIMPL_H - -#include <tqobject.h> -#include <tqstringlist.h> -#include <tqmap.h> -#include <tqptrlist.h> - -#include <kdelibs_export.h> - -class KPrinter; -class KMPrinter; - -class KDEPRINT_EXPORT KPrinterImpl : public TQObject -{ - Q_OBJECT -public: - KPrinterImpl(TQObject *parent = 0, const char *name = 0); - virtual ~KPrinterImpl(); - - virtual bool setupCommand(TQString& cmd, KPrinter*); - virtual void preparePrinting(KPrinter*); - virtual void broadcastOption(const TQString& key, const TQString& value); - - bool printFiles(KPrinter*, const TQStringList&, bool removeflag = false); - // result: - // -1 -> error - // 0 -> nothing happened - // 1 -> files filterd - int filterFiles(KPrinter*, TQStringList&, bool removeflag = false); - int autoConvertFiles(KPrinter*, TQStringList&, bool removeflag = false); - void saveOptions(const TQMap<TQString,TQString>& opts); - const TQMap<TQString,TQString>& loadOptions() const { return m_options; } - TQString tempFile(); - TQString quote(const TQString&); - void statusMessage(const TQString&, KPrinter* = 0); - -protected: - bool startPrinting(const TQString& cmd, KPrinter *printer, const TQStringList& files, bool removeflag = false); - int dcopPrint(const TQString& cmd, const TQStringList& files, bool removeflag = false); - bool setupSpecialCommand(TQString&, KPrinter*, const TQStringList&); - int doFilterFiles(KPrinter* pr, TQStringList& files, const TQStringList& flist, const TQMap<TQString,TQString>& opts, bool removeflag = false); - void loadAppOptions(); - void saveAppOptions(); - -protected: - TQMap<TQString,TQString> m_options; // use to save current options -}; - -#endif diff --git a/kdeprint/kprinterpropertydialog.cpp b/kdeprint/kprinterpropertydialog.cpp deleted file mode 100644 index 1128a7d3a..000000000 --- a/kdeprint/kprinterpropertydialog.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kprinterpropertydialog.h" -#include "kprintdialogpage.h" -#include "kmfactory.h" -#include "kmuimanager.h" -#include "kmvirtualmanager.h" -#include "kmprinter.h" -#include "driver.h" - -#include <kmessagebox.h> -#include <tqtabwidget.h> -#include <klocale.h> -#include <kpushbutton.h> -#include <kguiitem.h> - -KPrinterPropertyDialog::KPrinterPropertyDialog(KMPrinter *p, TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, TQString::null, KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::User1, KDialogBase::Ok, false, KStdGuiItem::save()), - m_printer(p), m_driver(0), m_current(0) -{ - m_pages.setAutoDelete(false); - - // set a margin - m_tw = new TQTabWidget(this); - m_tw->setMargin(10); - connect(m_tw,TQT_SIGNAL(currentChanged(TQWidget*)),TQT_SLOT(slotCurrentChanged(TQWidget*))); - setMainWidget(m_tw); - - if (m_printer) - m_options = (m_printer->isEdited() ? m_printer->editedOptions() : m_printer->defaultOptions()); -} - -KPrinterPropertyDialog::~KPrinterPropertyDialog() -{ - delete m_driver; -} - -void KPrinterPropertyDialog::slotCurrentChanged(TQWidget *w) -{ - if (m_current) m_current->getOptions(m_options,true); - m_current = (KPrintDialogPage*)w; - if (m_current) m_current->setOptions(m_options); -} - -void KPrinterPropertyDialog::addPage(KPrintDialogPage *page) -{ - m_tw->addTab(page,page->title()); - m_pages.append(page); -} - -bool KPrinterPropertyDialog::synchronize() -{ - if (m_current) m_current->getOptions(m_options,true); - TQString msg; - TQPtrListIterator<KPrintDialogPage> it(m_pages); - for (;it.current();++it) - { - it.current()->setOptions(m_options); - if (!it.current()->isValid(msg)) - { - KMessageBox::error(this, msg.prepend("<qt>").append("</qt>"), i18n("Printer Configuration")); - return false; - } - } - return true; -} - -void KPrinterPropertyDialog::setOptions(const TQMap<TQString,TQString>& opts) -{ - // merge the 2 options sets - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - m_options[it.key()] = it.data(); - // update all existing pages - TQPtrListIterator<KPrintDialogPage> it(m_pages); - for (; it.current(); ++it) - it.current()->setOptions(m_options); -} - -void KPrinterPropertyDialog::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - collectOptions(opts, incldef); -} - -void KPrinterPropertyDialog::collectOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - TQPtrListIterator<KPrintDialogPage> it(m_pages); - for (;it.current();++it) - it.current()->getOptions(opts,incldef); -} - -void KPrinterPropertyDialog::slotOk() -{ - if (!synchronize()) - return; - KDialogBase::slotOk(); -} - -void KPrinterPropertyDialog::slotUser1() -{ - if (m_printer && synchronize()) - { - TQMap<TQString,TQString> opts; - collectOptions(opts, false); - m_printer->setDefaultOptions(opts); - m_printer->setEditedOptions(TQMap<TQString,TQString>()); - m_printer->setEdited(false); - KMFactory::self()->virtualManager()->triggerSave(); - } -} - -void KPrinterPropertyDialog::enableSaveButton(bool state) -{ - showButton(KDialogBase::User1, state); -} - -void KPrinterPropertyDialog::setupPrinter(KMPrinter *pr, TQWidget *parent) -{ - KPrinterPropertyDialog dlg(pr,parent,"PropertyDialog"); - KMFactory::self()->uiManager()->setupPropertyDialog(&dlg); - if (dlg.m_pages.count() == 0) - KMessageBox::information(parent,i18n("No configurable options for that printer."),i18n("Printer Configuration")); - else if (dlg.exec()) - { - TQMap<TQString,TQString> opts; - dlg.collectOptions(opts, false); - pr->setEditedOptions(opts); - pr->setEdited(true); - } -} -#include "kprinterpropertydialog.moc" diff --git a/kdeprint/kprinterpropertydialog.h b/kdeprint/kprinterpropertydialog.h deleted file mode 100644 index 98a37d8bd..000000000 --- a/kdeprint/kprinterpropertydialog.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KPRINTERPROPERTYDIALOG_H -#define KPRINTERPROPERTYDIALOG_H - -#include <kdialogbase.h> -#include <tqptrlist.h> -#include <tqmap.h> - -class KMPrinter; -class KPrintDialogPage; -class DrMain; -class TQTabWidget; - -class KDEPRINT_EXPORT KPrinterPropertyDialog : public KDialogBase -{ - Q_OBJECT -public: - KPrinterPropertyDialog(KMPrinter *printer, TQWidget *parent = 0, const char *name = 0); - ~KPrinterPropertyDialog(); - - KMPrinter* printer() { return m_printer; } - DrMain* driver() { return m_driver; } - void setDriver(DrMain* d) { if (!m_driver) m_driver = d; } - void addPage(KPrintDialogPage*); - void setOptions(const TQMap<TQString,TQString>&); - void getOptions(TQMap<TQString,TQString>&, bool = false); - void enableSaveButton(bool); - - static void setupPrinter(KMPrinter *printer, TQWidget *parent); - -protected: - bool synchronize(); - void collectOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected slots: - void slotCurrentChanged(TQWidget*); - void slotUser1(); - void slotOk(); - -protected: - KMPrinter *m_printer; - DrMain *m_driver; - TQPtrList<KPrintDialogPage> m_pages; - KPrintDialogPage *m_current; - TQMap<TQString,TQString> m_options; - TQTabWidget *m_tw; - TQPushButton *m_save; -}; - -#endif diff --git a/kdeprint/kprintpreview.cpp b/kdeprint/kprintpreview.cpp deleted file mode 100644 index 235472d1f..000000000 --- a/kdeprint/kprintpreview.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 "kprintpreview.h" -#include "kmfactory.h" - -#include <tqfile.h> -#include <tqlayout.h> -#include <tqvbox.h> - -#include <kparts/part.h> -#include <kaccel.h> -#include <kaction.h> -#include <klibloader.h> -#include <ktrader.h> -#include <kuserprofile.h> -#include <krun.h> -#include <kapplication.h> -#include <kstandarddirs.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <kdebug.h> -#include <kconfig.h> -#include <ktoolbar.h> -#include <kmimetype.h> - -KPreviewProc::KPreviewProc() -: KProcess() -{ - m_bOk = false; - connect(this, TQT_SIGNAL(processExited(KProcess*)), TQT_SLOT(slotProcessExited(KProcess*))); -} - -KPreviewProc::~KPreviewProc() -{ -} - -bool KPreviewProc::startPreview() -{ - if (start()) - { - kapp->enter_loop(); - return m_bOk; - } - else - return false; -} - -void KPreviewProc::slotProcessExited(KProcess* proc) -{ - kapp->exit_loop(); - if ( proc->normalExit() && proc->exitStatus() == 0 ) - m_bOk = true; - else - kdDebug(500) << "KPreviewProc::slotProcessExited: normalExit=" << proc->normalExit() - << " exitStatus=" << proc->exitStatus() << endl; -} - -//******************************************************************************************* - -class KPrintPreview::KPrintPreviewPrivate -{ -public: - KPrintPreviewPrivate(KPrintPreview *dlg) : gvpart_(0) - { - mainwidget_ = new TQWidget(dlg, "MainWidget"); - toolbar_ = new KToolBar(mainwidget_, "PreviewToolBar", true); - actions_ = new KActionCollection(dlg); - accel_ = new KAccel(dlg); - previewonly_ = false; - } - ~KPrintPreviewPrivate() - { - if (gvpart_) delete gvpart_; - } - void plugAction(KAction *act) - { - act->plug(toolbar_); - act->plugAccel(accel_); - } - - KParts::ReadOnlyPart *gvpart_; - KToolBar *toolbar_; - KActionCollection *actions_; - TQWidget *mainwidget_; - KAccel *accel_; - bool previewonly_; -}; - -static KLibFactory* componentFactory() -{ - kdDebug(500) << "tdeprint: querying trader for 'application/postscript' service" << endl; - KLibFactory *factory(0); - factory = KLibLoader::self()->factory("libkghostviewpart"); - if( factory ) - return factory; - KTrader::OfferList offers = KTrader::self()->query(TQString::tqfromLatin1("application/postscript"), TQString::tqfromLatin1("KParts/ReadOnlyPart"), TQString::null, TQString::null); - for (KTrader::OfferList::ConstIterator it = offers.begin(); it != offers.end(); ++it) - { - KService::Ptr service = *it; - factory = KLibLoader::self()->factory(TQFile::encodeName(service->library())); - if (factory) - break; - } - if (!factory) - { - // nothing has been found, try to load directly the KGhostview part - factory = KLibLoader::self()->factory("libkghostviewpart"); - } - return factory; -} - -static bool continuePrint(const TQString& msg_, TQWidget *parent, bool previewOnly) -{ - QString msg(msg_); - if (previewOnly) - { - KMessageBox::error(parent, msg); - return false; - } - else - { - msg.append(" ").append(i18n("Do you want to continue printing anyway?")); - return (KMessageBox::warningContinueCancel(parent, msg, TQString::null, KGuiItem(i18n("Print"),"fileprint")) == KMessageBox::Continue); - } -} - -//******************************************************************************************* - -KPrintPreview::KPrintPreview(TQWidget *parent, bool previewOnly) -: KDialogBase(parent, "PreviewDlg", true, i18n("Print Preview"), 0) -{ - kdDebug(500) << "tdeprint: creating preview dialog" << endl; - d = new KPrintPreviewPrivate(this); - d->previewonly_ = previewOnly; - - // create main view and actions - setMainWidget(d->mainwidget_); - if (previewOnly) - KStdAction::close(TQT_TQOBJECT(this), TQT_SLOT(reject()), d->actions_, "close_print"); - else - { - new KAction(i18n("Print"), "fileprint", Qt::Key_Return, TQT_TQOBJECT(this), TQT_SLOT(accept()), d->actions_, "continue_print"); - new KAction(i18n("Cancel"), "stop", Qt::Key_Escape, TQT_TQOBJECT(this), TQT_SLOT(reject()), d->actions_, "stop_print"); - } - -} - -KPrintPreview::~KPrintPreview() -{ - delete d; -} - -void KPrintPreview::initView(KLibFactory *factory) -{ - // load the component - d->gvpart_ = (KParts::ReadOnlyPart*)factory->create(TQT_TQOBJECT(d->mainwidget_), "gvpart", "KParts::ReadOnlyPart"); - - // populate the toolbar - if (d->previewonly_) - d->plugAction(d->actions_->action("close_print")); - else - { - d->plugAction(d->actions_->action("continue_print")); - d->plugAction(d->actions_->action("stop_print")); - } - if (d->gvpart_) - { - TQDomNodeList l = d->gvpart_->domDocument().elementsByTagName( "ToolBar" ); - if ( l.length() > 0 ) - { - d->toolbar_->insertLineSeparator(); - TQDomNodeList acts = l.item( 0 ).toElement().elementsByTagName( "Action" ); - for ( uint i=0; i<acts.length(); i++ ) - { - TQDomElement a = acts.item( i ).toElement(); - if ( a.attribute( "name" ) == "goToPage" ) - continue; - KAction *act = d->gvpart_->action( a ); - if ( act != 0 ) - d->plugAction( act ); - } - } - /* - KAction *act; - d->toolbar_->insertLineSeparator(); - if ((act = d->gvpart_->action("zoomIn")) != 0) - d->plugAction(act); - if ((act = d->gvpart_->action("zoomOut")) != 0) - d->plugAction(act); - d->toolbar_->insertSeparator(); - if ((act = d->gvpart_->action("prevPage")) != 0) - d->plugAction(act); - if ((act = d->gvpart_->action("nextPage")) != 0) - d->plugAction(act); - */ - } - d->toolbar_->setIconText(KToolBar::IconTextRight); - d->toolbar_->setBarPos(KToolBar::Top); - d->toolbar_->setMovingEnabled(false); - //d->adjustSize(); - - // construct the layout - TQVBoxLayout *l0 = new TQVBoxLayout(d->mainwidget_, 0, 0); - l0->addWidget(d->toolbar_, AlignTop); - if (d->gvpart_) - l0->addWidget(d->gvpart_->widget()); - - resize(855, 500); - setCaption(i18n("Print Preview")); -} - -void KPrintPreview::openFile(const TQString& file) -{ - d->gvpart_->openURL(KURL(file)); -} - -bool KPrintPreview::isValid() const -{ - return (d->gvpart_ != 0); -} - -bool KPrintPreview::preview(const TQString& file, bool previewOnly, WId parentId) -{ - KMimeType::Ptr mime = KMimeType::findByPath( file ); - bool isPS = ( mime->name() == "application/postscript" ); - if ( !isPS ) - kdDebug( 500 ) << "Previewing a non PostScript file, built-in preview disabled" << endl; - - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("General"); - KLibFactory *factory(0); - bool externalPreview = conf->readBoolEntry("ExternalPreview", false); - TQWidget *parentW = TQT_TQWIDGET(TQWidget::find(parentId)); - TQString exe; - if (!externalPreview && isPS && (factory = componentFactory()) != 0) - { - KPrintPreview dlg(parentW, previewOnly); - dlg.initView(factory); - - if (dlg.isValid()) - { - dlg.openFile(file); - return dlg.exec(); - } - else - { - // do nothing at that point: try to use the other way around by - // using an external PS viewer if possible - } - } - - // Either the PS viewer component was not found, or an external - // preview program has been specified - KPreviewProc proc; - if (externalPreview && isPS ) - { - exe = conf->readPathEntry("PreviewCommand", "gv"); - if (KStandardDirs::findExe(exe).isEmpty()) - { - QString msg = i18n("The preview program %1 cannot be found. " - "Check that the program is correctly installed and " - "located in a directory included in your PATH " - "environment variable.").arg(exe); - return continuePrint(msg, parentW, previewOnly); - } - proc << exe << file; - } - else - { - KService::Ptr serv = KServiceTypeProfile::preferredService( mime->name(), TQString::null ); - if ( serv ) - { - KURL url; - url.setPath( file ); - TQStringList args = KRun::processDesktopExec( *serv, url, false ); - proc << args; - exe = serv->name(); - } - else - { - // in that case, the PS viewer component could not be loaded and no service - // could be found to view PS - TQString msg; - if ( isPS ) - msg = i18n("Preview failed: neither the internal KDE PostScript " - "viewer (KGhostView) nor any other external PostScript " - "viewer could be found."); - else - msg = i18n( "Preview failed: KDE could not find any application " - "to preview files of type %1." ).arg( mime->name() ); - - return continuePrint(msg, parentW, previewOnly); - } - } - - // start the preview process - if (!proc.startPreview()) - { - QString msg = i18n("Preview failed: unable to start program %1.").arg(exe); - return continuePrint(msg, parentW, previewOnly); - } - else if (!previewOnly) - { - return (KMessageBox::questionYesNo(parentW, i18n("Do you want to continue printing?"), TQString::null, KGuiItem(i18n("Print"),"fileprint"), KStdGuiItem::cancel(), "continuePrinting") == KMessageBox::Yes); - } - else - return false; -} - -#include "kprintpreview.moc" diff --git a/kdeprint/kprintpreview.h b/kdeprint/kprintpreview.h deleted file mode 100644 index 5fd581fe7..000000000 --- a/kdeprint/kprintpreview.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 KPRINTPREVIEW_H -#define KPRINTPREVIEW_H - -#include <kdialogbase.h> -#include <tqstring.h> -#include <kprocess.h> - -class KLibFactory; - -class KPrintPreview : public KDialogBase -{ - Q_OBJECT -public: - KPrintPreview(TQWidget *parent = 0, bool previewOnly = false); - ~KPrintPreview(); - - void openFile(const TQString& file); - bool isValid() const; - - static bool preview(const TQString& file, bool previewOnly = false, WId parentId = 0); - -private: - void initView(KLibFactory*); - -private: - class KPrintPreviewPrivate; - KPrintPreviewPrivate *d; -}; - -class KPreviewProc : public KProcess -{ - Q_OBJECT -public: - KPreviewProc(); - virtual ~KPreviewProc(); - - bool startPreview(); - -protected slots: - void slotProcessExited(KProcess*); -private: - bool m_bOk; -}; - -#endif diff --git a/kdeprint/kprintpreviewui.rc b/kdeprint/kprintpreviewui.rc deleted file mode 100644 index 21b144bca..000000000 --- a/kdeprint/kprintpreviewui.rc +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="KGVShell" version="1"> -<MenuBar> -<Menu name="file" noMerge="1"><text>&File</text> - <Action name="continue_print"/> - <Action name="stop_print"/> - <Action name="close_print"/> - <Separator /> - <Merge/> -</Menu> -<Menu name="view" noMerge="1"><text>&View</text> -</Menu> -<Menu name="pagemarks"><text>&PageMarks</text> - <Merge/> -</Menu> -<Menu name="settings" noMerge="1"><text>&Settings</text> - <Merge/> -</Menu> -</MenuBar> -<ToolBar name="Preview-Toolbar" position="top" iconText="icontextright"> - <Action name="continue_print"/> - <Action name="stop_print"/> - <Action name="close_print"/> -</ToolBar> -<ToolBar name="mainToolBar" position="left"> -</ToolBar> -</kpartgui> diff --git a/kdeprint/kprintprocess.cpp b/kdeprint/kprintprocess.cpp deleted file mode 100644 index fb1df2840..000000000 --- a/kdeprint/kprintprocess.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kprintprocess.h" -#include <kapplication.h> -#include <klocale.h> -#include <tqfile.h> - -KPrintProcess::KPrintProcess() -: KShellProcess() -{ - // redirect everything to a single buffer - connect(this,TQT_SIGNAL(receivedStdout(KProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(KProcess*,char*,int))); - connect(this,TQT_SIGNAL(receivedStderr(KProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(KProcess*,char*,int))); - connect( this, TQT_SIGNAL( processExited( KProcess* ) ), TQT_SLOT( slotExited( KProcess* ) ) ); - m_state = None; -} - -KPrintProcess::~KPrintProcess() -{ - if ( !m_tempoutput.isEmpty() ) - TQFile::remove( m_tempoutput ); - if ( m_tempfiles.size() > 0 ) - for ( TQStringList::ConstIterator it=m_tempfiles.begin(); it!=m_tempfiles.end(); ++it ) - TQFile::remove( *it ); -} - -TQString KPrintProcess::errorMessage() const -{ - return m_buffer; -} - -bool KPrintProcess::print() -{ - m_buffer = TQString(); - m_state = Printing; - return start(NotifyOnExit,All); -} - -void KPrintProcess::slotReceivedStderr(KProcess *proc, char *buf, int len) -{ - if (proc == this) - { - TQCString str = TQCString(buf,len).stripWhiteSpace(); - m_buffer.append(str.append("\n")); - } -} - -void KPrintProcess::slotExited( KProcess* ) -{ - switch ( m_state ) - { - case Printing: - if ( !m_output.isEmpty() ) - { - clearArguments(); - *this << "kfmclient" << "copy" << m_tempoutput << m_output; - m_state = Finishing; - m_buffer = i18n( "File transfer failed." ); - if ( start( NotifyOnExit ) ) - return; - } - case Finishing: - if ( !normalExit() ) - emit printError( this, i18n( "Abnormal process termination (<b>%1</b>)." ).arg( m_command ) ); - else if ( exitStatus() != 0 ) - emit printError( this, i18n( "<b>%1</b>: execution failed with message:<p>%2</p>" ).arg( m_command ).arg( m_buffer ) ); - else - emit printTerminated( this ); - break; - default: - emit printError( this, "Internal error, printing terminated in unexpected state. " - "Report bug at <a href=\"http://bugs.kde.org\">http://bugs.kde.org</a>." ); - break; - } -} - -#include "kprintprocess.moc" diff --git a/kdeprint/kprintprocess.h b/kdeprint/kprintprocess.h deleted file mode 100644 index 976b35afe..000000000 --- a/kdeprint/kprintprocess.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KPRINTPROCESS_H -#define KPRINTPROCESS_H - -#include <kprocess.h> -#include <tqstringlist.h> - -class KPrintProcess : public KShellProcess -{ - Q_OBJECT -public: - KPrintProcess(); - ~KPrintProcess(); - - bool print(); - TQString errorMessage() const; - - void setOutput( const TQString& output ); - const TQString& output() const; - void setTempOutput( const TQString& output ); - const TQString& tempOutput() const; - void setTempFiles( const TQStringList& files ); - const TQStringList& tempFiles() const; - void setCommand( const TQString& cmd ); - const TQString& command() const; - - enum State { None = 0, Printing, Finishing }; - int state() const; - -signals: - void printTerminated( KPrintProcess* ); - void printError( KPrintProcess*, const TQString& ); - -protected slots: - void slotReceivedStderr(KProcess*, char*, int); - void slotExited( KProcess* ); - -private: - QString m_buffer; - TQStringList m_tempfiles; - TQString m_output, m_tempoutput, m_command; - int m_state; -}; - -inline const TQString& KPrintProcess::output() const -{ return m_output; } - -inline const TQString& KPrintProcess::tempOutput() const -{ return m_tempoutput; } - -inline const TQStringList& KPrintProcess::tempFiles() const -{ return m_tempfiles; } - -inline const TQString& KPrintProcess::command() const -{ return m_command; } - -inline void KPrintProcess::setOutput( const TQString& s ) -{ m_output = s; } - -inline void KPrintProcess::setTempOutput( const TQString& s ) -{ m_tempoutput = s; } - -inline void KPrintProcess::setTempFiles( const TQStringList& l ) -{ m_tempfiles = l; } - -inline void KPrintProcess::setCommand( const TQString& c ) -{ m_command = c; } - -inline int KPrintProcess::state() const -{ return m_state; } - -#endif diff --git a/kdeprint/kxmlcommand.cpp b/kdeprint/kxmlcommand.cpp deleted file mode 100644 index 81dc5d3d5..000000000 --- a/kdeprint/kxmlcommand.cpp +++ /dev/null @@ -1,830 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kxmlcommand.h" -#include "driver.h" -#include "kmfactory.h" -#include "tdeprintcheck.h" -#include "driverview.h" - -#include <tqfile.h> -#include <tqregexp.h> -#include <tqdir.h> -#include <tqinputdialog.h> -#include <tqmap.h> -#include <tqvaluelist.h> -#include <kstandarddirs.h> -#include <klocale.h> -#include <ksimpleconfig.h> -#include <kdialogbase.h> -#include <kdebug.h> -#include <kprocess.h> -#include <klibloader.h> -#include <kmessagebox.h> - -static void setOptionText(DrBase *opt, const TQString& s) -{ - if (s.isEmpty()) - opt->set("text", opt->name()); - else - opt->set("text", i18n(s.utf8())); -} - -class KXmlCommand::KXmlCommandPrivate -{ -public: - TQString m_name; - TQString m_command; - DrMain *m_driver; - struct - { - TQString m_format[2]; // 0 -> file, 1 -> pipe - } m_io[2]; // 0 -> input, 1 -> output - TQString m_description; - TQString m_outputMime; - TQStringList m_inputMime; - TQStringList m_requirements; - bool m_loaded[2]; // 0 -> Desktop, 1 -> XML - TQString m_comment; -}; - -KXmlCommand::KXmlCommand(const TQString& xmlId) -: TQObject(KXmlCommandManager::self(), "XmlCommand") -{ - init(); - d->m_name = xmlId; -} - -KXmlCommand::~KXmlCommand() -{ - //kdDebug(500) << "deleting driver" << endl; - delete d->m_driver; - //kdDebug(500) << "deleting private data" << endl; - delete d; - //kdDebug(500) << "finished" << endl; -} - -void KXmlCommand::init() -{ - d = new KXmlCommandPrivate; - d->m_driver = 0; - d->m_loaded[0] = d->m_loaded[1] = false; -} - -TQString KXmlCommand::name() const -{ return d->m_name; } - -void KXmlCommand::setName(const TQString& s) -{ d->m_name = s; } - -TQString KXmlCommand::command() -{ - check(true); - return d->m_command; -} - -void KXmlCommand::setCommand(const TQString& s) -{ - d->m_command = s; -} - -DrMain* KXmlCommand::driver() -{ - check(true); - return d->m_driver; -} - -DrMain* KXmlCommand::takeDriver() -{ - check(true); - DrMain *dr = d->m_driver; - d->m_driver = 0; - d->m_loaded[1] = false; - return dr; -} - -void KXmlCommand::setDriver(DrMain *driver) -{ - delete d->m_driver; - d->m_driver = driver; -} - -TQString KXmlCommand::io(bool io_input, bool io_pipe) -{ - check(true); - return d->m_io[(io_input?0:1)].m_format[(io_pipe?1:0)]; -} - -void KXmlCommand::setIo(const TQString& s, bool io_input, bool io_pipe) -{ - d->m_io[(io_input?0:1)].m_format[(io_pipe?1:0)] = s; -} - -TQString KXmlCommand::description() -{ - check(); - return d->m_description; -} - -void KXmlCommand::setDescription(const TQString& s) -{ - d->m_description = s; -} - -TQString KXmlCommand::mimeType() -{ - check(); - return d->m_outputMime; -} - -void KXmlCommand::setMimeType(const TQString& s) -{ - d->m_outputMime = s; -} - -bool KXmlCommand::acceptMimeType(const TQString& s) -{ - check(); - return (d->m_inputMime.find(s) != d->m_inputMime.end()); -} - -TQStringList KXmlCommand::inputMimeTypes() -{ - check(); - return d->m_inputMime; -} - -void KXmlCommand::setInputMimeTypes(const TQStringList& l) -{ - d->m_inputMime = l; -} - -TQStringList KXmlCommand::requirements() -{ - check(); - return d->m_requirements; -} - -void KXmlCommand::setRequirements(const TQStringList& l) -{ - d->m_requirements = l; -} - -TQString KXmlCommand::comment() -{ - check(); - return d->m_comment; -} - -void KXmlCommand::setComment( const TQString& s ) -{ - d->m_comment = s; -} - -bool KXmlCommand::isValid() -{ - return (!locate("data", "tdeprint/filters/"+name()+".desktop").isEmpty()); -} - -void KXmlCommand::check(bool use_xml) -{ - if (!d->m_loaded[0]) - { - loadDesktop(); - d->m_loaded[0] = true; - } - if (use_xml && !d->m_loaded[1]) - { - loadXml(); - d->m_loaded[1] = true; - } -} - -void KXmlCommand::loadDesktop() -{ - KSimpleConfig conf(locate("data", "tdeprint/filters/"+name()+".desktop")); - conf.setGroup("KDE Print Filter Entry"); - d->m_description = conf.readEntry("Comment"); - d->m_outputMime = conf.readEntry("MimeTypeOut"); - d->m_inputMime = conf.readListEntry("MimeTypeIn"); - d->m_requirements = conf.readListEntry("Require"); - d->m_comment = conf.readEntry( "Description" ); -} - -void KXmlCommand::saveDesktop() -{ - KSimpleConfig conf(locateLocal("data", "tdeprint/filters/"+name()+".desktop")); - conf.setGroup("KDE Print Filter Entry"); - conf.writeEntry("Comment", d->m_description); - conf.writeEntry("MimeTypeIn", d->m_inputMime); - conf.writeEntry("MimeTypeOut", d->m_outputMime); - conf.writeEntry("Require", d->m_requirements); - conf.writeEntry( "Description", d->m_comment ); -} - -void KXmlCommand::loadXml() -{ - TQFile f(locate("data", "tdeprint/filters/"+name()+".xml")); - TQDomDocument doc; - if (f.open(IO_ReadOnly) && doc.setContent(&f) && doc.documentElement().tagName() == "kprintfilter") - { - TQDomElement e, docElem = doc.documentElement(); - d->m_name = docElem.attribute("name"); - - // command - e = docElem.namedItem("filtercommand").toElement(); - if (!e.isNull()) - d->m_command = e.attribute("data"); - - // arguments - e = docElem.namedItem("filterargs").toElement(); - if (!e.isNull()) - { - d->m_driver = new DrMain; - d->m_driver->setName(d->m_name); - parseGroup(e, d->m_driver); - setOptionText(d->m_driver, d->m_description); - } - - // input/output - e = docElem.namedItem("filterinput").toElement(); - if (!e.isNull()) - parseIO(e, 0); - e = docElem.namedItem("filteroutput").toElement(); - if (!e.isNull()) - parseIO(e, 1); - } -} - -void KXmlCommand::parseIO(const TQDomElement& e, int n) -{ - TQDomElement elem = e.firstChild().toElement(); - while (!elem.isNull()) - { - if (elem.tagName() == "filterarg") - { - int format = (elem.attribute("name") == "file" ? 0 : 1); - d->m_io[n].m_format[format] = elem.attribute("format"); - } - elem = elem.nextSibling().toElement(); - } -} - -DrGroup* KXmlCommand::parseGroup(const TQDomElement& e, DrGroup *grp) -{ - if (!grp) - grp = new DrGroup; - grp->setName(e.attribute("name")); - setOptionText(grp, e.attribute("description")); - - TQDomElement elem = e.firstChild().toElement(); - while (!elem.isNull()) - { - if (elem.tagName() == "filterarg") - { - DrBase *opt = parseArgument(elem); - if (opt) - grp->addOption(opt); - } - else if (elem.tagName() == "filtergroup") - { - DrGroup *group = parseGroup(elem, 0); - if (group) - grp->addGroup(group); - } - elem = elem.nextSibling().toElement(); - } - - return grp; -} - -DrBase* KXmlCommand::parseArgument(const TQDomElement& e) -{ - DrBase *opt(0); - TQString type = e.attribute("type"); - - if (type == "int" || type == "float") - { - if (type == "int") - opt = new DrIntegerOption; - else - opt = new DrFloatOption; - opt->set("minval", e.attribute("min")); - opt->set("maxval", e.attribute("max")); - } - else if (type == "string") - opt = new DrStringOption; - else if (type == "list" || type == "bool") - { - if (type == "list") - opt = new DrListOption; - else - opt = new DrBooleanOption; - DrListOption *lopt = static_cast<DrListOption*>(opt); - TQDomElement elem = e.firstChild().toElement(); - while (!elem.isNull()) - { - if (elem.tagName() == "value") - { - DrBase *choice = new DrBase; - choice->setName(elem.attribute("name")); - setOptionText(choice, elem.attribute("description")); - lopt->addChoice(choice); - } - elem = elem.nextSibling().toElement(); - } - } - else - return 0; - - opt->setName("_kde-" + d->m_name + "-" + e.attribute("name")); - setOptionText(opt, e.attribute("description")); - opt->set("format", e.attribute("format")); - opt->set("default", e.attribute("default")); - opt->set( "persistent", e.attribute( "persistent" ) ); - opt->setValueText(opt->get("default")); - - return opt; -} - -TQString KXmlCommand::buildCommand(const TQMap<TQString,TQString>& opts, bool pipein, bool pipeout) -{ - check(true); - - TQString str, cmd = d->m_command; - TQString re( "%value" ), quotedRe( "'%value'" ); - - if (d->m_driver) - { - TQMap<TQString,TQString> fopts; - - d->m_driver->setOptions(opts); - d->m_driver->getOptions(fopts, false); - for (TQMap<TQString,TQString>::ConstIterator it=fopts.begin(); it!=fopts.end(); ++it) - { - DrBase *dopt = d->m_driver->findOption(it.key()); - if (dopt) - { - TQString format = dopt->get("format"); - TQString value = dopt->valueText(); - if ( format.find( quotedRe ) != -1 ) - { - if ( ( value.right( 1 ) == "'" && value.left( 1 ) == "'" ) || - ( value.right( 1 ) == "\"" && value.left( 1 ) == "\"" ) ) - format.replace( quotedRe, value ); - else - format.replace( re, value ); - } - else - { - format.replace( re, KProcess::quote( dopt->valueText() ) ); - } - str.append(format).append(" "); - } - } - cmd.replace("%filterargs", str); - } - - cmd.replace("%filterinput", d->m_io[0].m_format[(pipein?1:0)]); - cmd.replace("%filteroutput", d->m_io[1].m_format[(pipeout?1:0)]); - - return cmd; -} - -void KXmlCommand::setOptions(const TQMap<TQString,TQString>& opts) -{ - if (opts.count() == 0) - return; - // force loading the driver if needed - if (driver()) - d->m_driver->setOptions(opts); -} - -void KXmlCommand::getOptions(TQMap<TQString,TQString>& opts, bool incldef) -{ - // force loading the driver - if (driver()) - d->m_driver->getOptions(opts, incldef); -} - -void KXmlCommand::saveXml() -{ - TQFile f(locateLocal("data", "tdeprint/filters/"+name()+".xml")); - if (!f.open(IO_WriteOnly)) - return; - - TQDomDocument doc("kprintfilter"); - TQDomElement root = doc.createElement("kprintfilter"), elem; - - root.setAttribute("name", d->m_name); - doc.appendChild(root); - - // command - elem = doc.createElement("filtercommand"); - elem.setAttribute("data", d->m_command); - root.appendChild(elem); - - // options - if (d->m_driver) - { - elem = createGroup(doc, d->m_driver); - elem.setTagName("filterargs"); - root.appendChild(elem); - } - - // IO - if (!(elem=createIO(doc, 0, "filterinput")).isNull()) - root.appendChild(elem); - if (!(elem=createIO(doc, 1, "filteroutput")).isNull()) - root.appendChild(elem); - - // save to file (and close it) - TQTextStream t(&f); - t << doc.toString(); - f.close(); -} - -TQDomElement KXmlCommand::createIO(TQDomDocument& doc, int n, const TQString& tag) -{ - TQDomElement elem = doc.createElement(tag); - if (d->m_command.find("%"+tag) != -1) - { - for (int i=0; i<2; i++) - { - TQDomElement io = doc.createElement("filterarg"); - io.setAttribute("name", (i ? "pipe" : "file")); - io.setAttribute("format", d->m_io[n].m_format[i]); - elem.appendChild(io); - } - } - - return elem; -} - -TQDomElement KXmlCommand::createGroup(TQDomDocument& doc, DrGroup *group) -{ - TQDomElement elem = doc.createElement("filtergroup"); - elem.setAttribute("name", group->name()); - elem.setAttribute("description", group->get("text")); - - TQPtrListIterator<DrGroup> git(group->groups()); - for (; git.current(); ++git) - elem.appendChild(createGroup(doc, git.current())); - - TQPtrListIterator<DrBase> oit(group->options()); - for (; oit.current(); ++oit) - elem.appendChild(createElement(doc, oit.current())); - - return elem; -} - -TQDomElement KXmlCommand::createElement(TQDomDocument& doc, DrBase *opt) -{ - TQDomElement elem = doc.createElement("filterarg"); - TQString elemName = opt->name(); - if (elemName.startsWith("_kde-")) - elemName.replace(0, name().length()+6, ""); - elem.setAttribute("name", elemName); - elem.setAttribute("format", opt->get("format")); - elem.setAttribute("description", opt->get("text")); - elem.setAttribute("default", opt->get("default")); - elem.setAttribute( "persistent", opt->get( "persistent" ) == "1" ? "1" : "0"); - - switch (opt->type()) - { - case DrBase::String: - elem.setAttribute("type", "string"); - break; - case DrBase::Integer: - case DrBase::Float: - elem.setAttribute("type", (opt->type() == DrBase::Integer ? "int" : "float")); - elem.setAttribute("min", opt->get("minval")); - elem.setAttribute("max", opt->get("maxval")); - break; - case DrBase::Boolean: - case DrBase::List: - elem.setAttribute("type", (opt->type() == DrBase::List ? "list" : "bool")); - { - TQPtrListIterator<DrBase> it(*(static_cast<DrListOption*>(opt)->choices())); - for (; it.current(); ++it) - { - TQDomElement chElem = doc.createElement("value"); - chElem.setAttribute("name", it.current()->name()); - chElem.setAttribute("description", it.current()->get("text")); - elem.appendChild(chElem); - } - } - break; - default: - break; - } - - return elem; -} - -//--------------------------------------------------------------------------------------------------- - -class KXmlCommandManager::KXmlCommandManagerPrivate -{ -public: - TQStringList m_cmdlist; - TQMap<TQString, TQValueList<KXmlCommand*> > m_mimemap; - TQMap<TQString, KXmlCommand*> m_cmdmap; -}; - -KXmlCommandManager* KXmlCommandManager::m_self = 0; - -KXmlCommandManager* KXmlCommandManager::self() -{ - if (!m_self) - { - m_self = new KXmlCommandManager; - Q_CHECK_PTR(m_self); - } - return m_self; -} - -KXmlCommandManager::KXmlCommandManager() -: TQObject(KMFactory::self(), "XmlCommandManager") -{ - d = new KXmlCommandManagerPrivate; -} - -KXmlCommandManager::~KXmlCommandManager() -{ - cleanUp(); - delete d; -} - -KXmlCommand* KXmlCommandManager::loadCommand(const TQString& xmlId, bool check) -{ - if (check) - { - TQString desktopFile = locate("data", "tdeprint/filters/"+xmlId+".desktop"); - if (desktopFile.isEmpty()) - return 0; - } - return new KXmlCommand(xmlId); -} - -void KXmlCommandManager::saveCommand(KXmlCommand *xmlCmd) -{ - xmlCmd->saveDesktop(); - xmlCmd->saveXml(); - - cleanUp(); -} - -void KXmlCommandManager::cleanUp() -{ - for (TQMap<TQString, KXmlCommand*>::ConstIterator it=d->m_cmdmap.begin(); it!=d->m_cmdmap.end(); ++it) - delete (*it); - d->m_cmdmap.clear(); - d->m_mimemap.clear(); - d->m_cmdlist.clear(); -} - -void KXmlCommandManager::preload() -{ - if (d->m_cmdmap.count() == 0) - { - commandList(); - for (TQStringList::Iterator it=d->m_cmdlist.begin(); it!=d->m_cmdlist.end(); ++it) - { - KXmlCommand *xmlCmd = loadCommand(*it); - if (!xmlCmd) continue; // Error! - - TQStringList inputMime = xmlCmd->inputMimeTypes(); - for (TQStringList::ConstIterator mime=inputMime.begin(); mime!=inputMime.end(); ++mime) - { - d->m_mimemap[*mime].append(xmlCmd); - d->m_cmdmap[*it] = xmlCmd; - } - } - } -} - -TQStringList KXmlCommandManager::commandList() -{ - if (d->m_cmdlist.isEmpty()) - { - TQStringList dirs = KGlobal::dirs()->findDirs("data", "tdeprint/filters/"); - - for (TQStringList::ConstIterator it=dirs.begin(); it!=dirs.end(); ++it) - { - TQStringList list = TQDir(*it).entryList("*.desktop", TQDir::Files, TQDir::Unsorted); - for (TQStringList::ConstIterator it2=list.begin(); it2!=list.end(); ++it2) - { - TQString cmdName = (*it2).left((*it2).length()-8); - if (d->m_cmdlist.find(cmdName) == d->m_cmdlist.end()) - d->m_cmdlist.append(cmdName); - } - } - - d->m_cmdlist.sort(); - } - - return d->m_cmdlist; -} - -TQStringList KXmlCommandManager::commandListWithDescription() -{ - preload(); - TQStringList l; - for (TQMap<TQString,KXmlCommand*>::ConstIterator it=d->m_cmdmap.begin(); it!=d->m_cmdmap.end(); ++it) - l << (*it)->name() << (*it)->description(); - - return l; -} - -TQString KXmlCommandManager::selectCommand(TQWidget *parent) -{ - KLibrary *lib = KLibLoader::self()->library( "libtdeprint_management_module" ); - if ( !lib ) - { - KMessageBox::error( parent, i18n( "Unable to load KDE print management library: %1" ).arg( KLibLoader::self()->lastErrorMessage() ) ); - return TQString::null; - } - else - { - TQString ( *func )( TQWidget* ) = ( TQString( * )( TQWidget* ) )lib->symbol( "select_command" ); - if ( !func ) - { - KMessageBox::error( parent, i18n( "Unable to find wizard object in management library." ) ); - return TQString::null; - } - else - return func( parent ); - } -} - -KXmlCommand* KXmlCommandManager::command(const TQString& xmlId) const -{ - return (d->m_cmdmap.contains(xmlId) ? d->m_cmdmap[xmlId] : 0); -} - -int KXmlCommandManager::insertCommand(TQStringList& list, const TQString& filtername, bool defaultToStart) -{ - preload(); - - int pos(0); - KXmlCommand *f1 = command(filtername), *f2 = 0; - if (f1 && f1->inputMimeTypes().count() > 0) - { - TQString mimetype = f1->inputMimeTypes()[0]; - for (TQStringList::Iterator it=list.begin(); it!=list.end(); ++it, pos++) - { - f2 = command(*it); - if (!f2) - return -1; // Shouldn't happen - - if (f2->acceptMimeType(f1->mimeType()) && f1->acceptMimeType(mimetype)) - { - list.insert(it, filtername); - break; - } - else - { - mimetype = f2->mimeType(); - f2 = 0; - } - } - if (pos == (int)(list.count())) - { - if (list.count() == 0 || f1->acceptMimeType(mimetype)) - list.append(filtername); - else if (defaultToStart) - { - pos = 0; - list.prepend(filtername); - } - else - pos = -1; - } - } - return pos; -} - -TQStringList KXmlCommandManager::autoConvert(const TQString& mimesrc, const TQString& mimedest) -{ - TQStringList chain; - uint score(0); - - preload(); - - if (d->m_mimemap.contains(mimesrc)) - { - const TQValueList<KXmlCommand*> l = d->m_mimemap[mimesrc]; - for (TQValueList<KXmlCommand*>::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - // check filter availability - if (!KdeprintChecker::check((*it)->requirements())) - continue; - - // direct filter: shortest path => return immediately - if ((*it)->mimeType() == mimedest) - { - chain = TQStringList((*it)->name()); - break; - } - // non direct filter: find the shortest way between - // its output and mimedest (do not consider cyling filters) - else if ((*it)->mimeType() != mimesrc) - { - TQStringList subchain = autoConvert((*it)->mimeType(), mimedest); - // If chain length is 0, then there's no possible filter between those 2 - // mime types. Just discard it. If the subchain contains also the current - // considered filter, then discard it: it denotes of a cycle in filter - // chain. - if (subchain.count() > 0 && subchain.findIndex((*it)->name()) == -1) - { - subchain.prepend((*it)->name()); - if (subchain.count() < score || score == 0) - { - chain = subchain; - score = subchain.count(); - } - } - } - } - } - // At this point, either we have the shortest path, or empty - // list if nothing could be found - return chain; -} - -bool KXmlCommandManager::checkCommand(const TQString& xmlId, int inputCheck, int outputCheck, TQString *msg) -{ - KXmlCommand *xmlCmd = command(xmlId); - TQString errmsg; - bool needDestroy(false); - //kdDebug(500) << "checking command: " << xmlId << " (" << (xmlCmd != NULL) << ")" << endl; - if (!xmlCmd) - { - xmlCmd = loadCommand(xmlId, true); - needDestroy = (xmlCmd != 0); - } - - bool status(true); - if (xmlCmd) - { - status = (xmlCmd->isValid() && KdeprintChecker::check(xmlCmd->requirements())); - if (!status) - errmsg = i18n("One of the command object's requirements is not met."); - } - TQString cmd = (xmlCmd ? xmlCmd->command() : xmlId); - if (status && !cmd.isEmpty() && (inputCheck > None || outputCheck > None)) - { - if (inputCheck > None && (cmd.find("%in") == -1 || inputCheck == Advanced) && cmd.find("%filterinput") == -1) - { - status = false; - errmsg = i18n("The command does not contain the required tag %1.").arg(inputCheck == Advanced ? "%filterinput" : "{%in,%filterinput}"); - } - if (status && outputCheck > None && (cmd.find("%out") == -1 || outputCheck == Advanced) && cmd.find("filteroutput") == -1) - { - status = false; - errmsg = i18n("The command does not contain the required tag %1.").arg(outputCheck == Advanced ? "%filteroutput" : "{%out,%filteroutput}"); - } - } - - if (needDestroy) - delete xmlCmd; - - if (msg) - *msg = errmsg; - - return status; -} - -bool KXmlCommandManager::configure(KXmlCommand *xmlCmd, TQWidget *parent) -{ - if (xmlCmd->driver()) - { - KDialogBase dlg(parent, 0, true, xmlCmd->description(), KDialogBase::Ok); - DriverView view(&dlg); - - dlg.setMainWidget(&view); - view.setDriver(xmlCmd->driver()); - dlg.resize(350,400); - dlg.exec(); - - return true; - } - return false; -} diff --git a/kdeprint/kxmlcommand.h b/kdeprint/kxmlcommand.h deleted file mode 100644 index a0ba90c56..000000000 --- a/kdeprint/kxmlcommand.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KXMLCOMMAND_H -#define KXMLCOMMAND_H - -#include <tqdom.h> -#include <tqmap.h> -#include <tqobject.h> - -#include <kdelibs_export.h> - -class DrMain; -class DrGroup; -class DrBase; - -class KDEPRINT_EXPORT KXmlCommand : public TQObject -{ - friend class KXmlCommandManager; - -public: - ~KXmlCommand(); - - TQString name() const; - void setName(const TQString&); - TQString command(); - void setCommand(const TQString&); - DrMain* driver(); - DrMain* takeDriver(); - void setDriver(DrMain*); - TQString io(bool io_input = true, bool io_pipe = false); - void setIo(const TQString&, bool io_input = true, bool io_pipe = false); - TQString description(); - void setDescription(const TQString&); - TQString mimeType(); - void setMimeType(const TQString&); - bool acceptMimeType(const TQString&); - TQStringList inputMimeTypes(); - void setInputMimeTypes(const TQStringList&); - TQStringList requirements(); - void setRequirements(const TQStringList&); - TQString comment(); - void setComment( const TQString& ); - bool isValid(); - - TQString buildCommand(const TQMap<TQString,TQString>& opts, bool pipein = true, bool pipeout = true); - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -protected: - void init(); - void loadXml(); - void saveXml(); - void loadDesktop(); - void saveDesktop(); - void check(bool use_xml = false); - DrGroup* parseGroup(const TQDomElement& e, DrGroup *grp = 0); - DrBase* parseArgument(const TQDomElement& e); - void parseIO(const TQDomElement& e, int n); - TQDomElement createIO(TQDomDocument&, int, const TQString&); - TQDomElement createGroup(TQDomDocument&, DrGroup*); - TQDomElement createElement(TQDomDocument&, DrBase*); - - // use protected constructor to only allow the manager to - // create KXmlCommand object. - KXmlCommand(const TQString& xmlId = TQString::null); - -private: - class KXmlCommandPrivate; - KXmlCommandPrivate *d; -}; - -class KDEPRINT_EXPORT KXmlCommandManager : public TQObject -{ -public: - enum IO_CheckType { None = 0, Basic, Advanced }; - - KXmlCommandManager(); - ~KXmlCommandManager(); - - KXmlCommand* loadCommand(const TQString& xmlId, bool check = false); - void saveCommand(KXmlCommand *xmlCmd); - TQStringList commandList(); - TQStringList commandListWithDescription(); - TQString selectCommand(TQWidget *parent = 0); - - TQStringList autoConvert(const TQString& mimesrc, const TQString& mimedest); - int insertCommand(TQStringList& list, const TQString& filtername, bool defaultToStart = true); - bool checkCommand(const TQString&, int inputCheck = Advanced, int outputCheck = Advanced, TQString *msg = 0); - bool configure(KXmlCommand*, TQWidget *parent = 0); - void cleanUp(); - - static KXmlCommandManager* self(); - -protected: - void preload(); - KXmlCommand* command(const TQString&) const; - -private: - class KXmlCommandManagerPrivate; - KXmlCommandManagerPrivate *d; - static KXmlCommandManager *m_self; -}; - -#endif diff --git a/kdeprint/lpd/Makefile.am b/kdeprint/lpd/Makefile.am deleted file mode 100644 index 5c6559a27..000000000 --- a/kdeprint/lpd/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/tdeprint -I$(top_srcdir)/tdeprint/management $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_lpd.la - -tdeprint_lpd_la_SOURCES = kmlpdfactory.cpp kmlpdmanager.cpp klpdprinterimpl.cpp kmlpduimanager.cpp \ - lpdtools.cpp gschecker.cpp -tdeprint_lpd_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_lpd_la_LIBADD = $(top_builddir)/tdeprint/management/libtdeprint_management.la -tdeprint_lpd_la_METASOURCES = AUTO - -noinst_HEADERS = kmlpdfactory.h kmlpdmanager.h klpdprinterimpl.h kmlpduimanager.h lpdtools.h gschecker.h - -bin_PROGRAMS = make_driver_db_lpd -make_driver_db_lpd_SOURCES = make_driver_db_lpd.c -make_driver_db_lpd_LDADD = $(top_builddir)/tdecore/libtdefakes.la - -entry_DATA = lpd.print -entrydir = $(kde_datadir)/tdeprint/plugins diff --git a/kdeprint/lpd/gschecker.cpp b/kdeprint/lpd/gschecker.cpp deleted file mode 100644 index 9fe6e290b..000000000 --- a/kdeprint/lpd/gschecker.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "gschecker.h" -#include "kpipeprocess.h" - -#include <tqfile.h> -#include <tqtextstream.h> - -GsChecker::GsChecker(TQObject *parent, const char *name) -: TQObject(parent,name) -{ -} - -bool GsChecker::checkGsDriver(const TQString& name) -{ - if (m_driverlist.count() == 0) - loadDriverList(); - return m_driverlist.contains(name); -} - -void GsChecker::loadDriverList() -{ - KPipeProcess proc; - if (proc.open("gs -h",IO_ReadOnly)) - { - QTextStream t(&proc); - QString buffer, line; - bool ok(false); - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (ok) - { - if (line.find(':') != -1) - break; - else - buffer.append(line).append(" "); - } - else if (line.startsWith(TQString::tqfromLatin1("Available devices:"))) - ok = true; - } - m_driverlist = TQStringList::split(' ',buffer,false); - } -} diff --git a/kdeprint/lpd/gschecker.h b/kdeprint/lpd/gschecker.h deleted file mode 100644 index c3c23a5be..000000000 --- a/kdeprint/lpd/gschecker.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 GSCHECKER_H -#define GSCHECKER_H - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqobject.h> - -class GsChecker : public TQObject -{ -public: - GsChecker(TQObject *parent = 0, const char *name = 0); - bool checkGsDriver(const TQString& name); - -protected: - void loadDriverList(); - -private: - QStringList m_driverlist; -}; - -#endif diff --git a/kdeprint/lpd/klpdprinterimpl.cpp b/kdeprint/lpd/klpdprinterimpl.cpp deleted file mode 100644 index 59f04e74c..000000000 --- a/kdeprint/lpd/klpdprinterimpl.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "klpdprinterimpl.h" -#include "kprinter.h" - -#include <tqfile.h> -#include <kstandarddirs.h> -#include <klocale.h> - -KLpdPrinterImpl::KLpdPrinterImpl(TQObject *parent, const char *name) -: KPrinterImpl(parent,name) -{ -} - -KLpdPrinterImpl::~KLpdPrinterImpl() -{ -} - -TQString KLpdPrinterImpl::executable() -{ - return KStandardDirs::findExe("lpr"); -} - -bool KLpdPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - QString exestr = executable(); - if (exestr.isEmpty()) - { - printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("lpr")); - return false; - } - cmd = TQString::tqfromLatin1("%1 -P %2 '-#%3'").arg(exestr).arg(quote(printer->printerName())).arg(printer->numCopies()); - return true; -} diff --git a/kdeprint/lpd/klpdprinterimpl.h b/kdeprint/lpd/klpdprinterimpl.h deleted file mode 100644 index a757d0c8c..000000000 --- a/kdeprint/lpd/klpdprinterimpl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KLPDPRINTERIMPL_H -#define KLPDPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KLpdPrinterImpl : public KPrinterImpl -{ -public: - KLpdPrinterImpl(TQObject *parent = 0, const char *name = 0); - ~KLpdPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); - -protected: - TQString executable(); -}; - -#endif diff --git a/kdeprint/lpd/kmlpdfactory.cpp b/kdeprint/lpd/kmlpdfactory.cpp deleted file mode 100644 index 05ee61bd5..000000000 --- a/kdeprint/lpd/kmlpdfactory.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpdfactory.h" -#include "kmlpdmanager.h" -#include "kmlpduimanager.h" -#include "klpdprinterimpl.h" - -extern "C" -{ - void* init_tdeprint_lpd() - { - return new KLpdFactory; - } -}; - -KLpdFactory::KLpdFactory(TQObject *parent, const char *name) -: KLibFactory(parent,name) -{ -} - -KLpdFactory::~KLpdFactory() -{ -} - -TQObject* KLpdFactory::createObject(TQObject *parent, const char *name, const char *classname, const TQStringList&) -{ - if (strcmp(classname,"KMManager") == 0) - return new KMLpdManager(parent,name); - else if (strcmp(classname,"KMUiManager") == 0) - return new KMLpdUiManager(parent,name); - else if (strcmp(classname,"KPrinterImpl") == 0) - return new KLpdPrinterImpl(parent,name); - else - return NULL; -} diff --git a/kdeprint/lpd/kmlpdfactory.h b/kdeprint/lpd/kmlpdfactory.h deleted file mode 100644 index ffc05af71..000000000 --- a/kdeprint/lpd/kmlpdfactory.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPDFACTORY_H -#define KMLPDFACTORY_H - -#include <klibloader.h> - -class KLpdFactory : public KLibFactory -{ -public: - KLpdFactory(TQObject *parent = 0, const char *name = 0); - virtual ~KLpdFactory(); - -protected: - TQObject* createObject(TQObject *parent = 0, const char *name = 0, const char *className = TQOBJECT_OBJECT_NAME_STRING, const TQStringList& args = TQStringList()); -}; - -#endif diff --git a/kdeprint/lpd/kmlpdmanager.cpp b/kdeprint/lpd/kmlpdmanager.cpp deleted file mode 100644 index a5612ad58..000000000 --- a/kdeprint/lpd/kmlpdmanager.cpp +++ /dev/null @@ -1,651 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpdmanager.h" -#include "kmprinter.h" -#include "kmdbentry.h" -#include "driver.h" -#include "kmfactory.h" -#include "lpdtools.h" -#include "gschecker.h" -#include "kpipeprocess.h" - -#include <tqfile.h> -#include <tqfileinfo.h> -#include <tqtextstream.h> -#include <tqmap.h> -#include <tqregexp.h> - -#include <klocale.h> -#include <kstandarddirs.h> -#include <kconfig.h> -#include <kprocess.h> - -#include <pwd.h> -#include <unistd.h> -#include <stdlib.h> -#include <sys/stat.h> - -// only there to allow testing on my system. Should be removed -// when everything has proven to be working and stable -QString lpdprefix = ""; -TQString ptPrinterType(KMPrinter*); - -//************************************************************************************************ - -KMLpdManager::KMLpdManager(TQObject *parent, const char *name) -: KMManager(parent,name) -{ - m_entries.setAutoDelete(true); - m_ptentries.setAutoDelete(true); - setHasManagement(getuid() == 0); - setPrinterOperationMask(KMManager::PrinterCreation|KMManager::PrinterConfigure|KMManager::PrinterRemoval|KMManager::PrinterEnabling); - m_gschecker = new GsChecker(this,"GsChecker"); -} - -KMLpdManager::~KMLpdManager() -{ -} - -TQString KMLpdManager::driverDbCreationProgram() -{ - return TQString::tqfromLatin1("make_driver_db_lpd"); -} - -TQString KMLpdManager::driverDirectory() -{ - return TQString::tqfromLatin1("/usr/lib/rhs/rhs-printfilters"); -} - -bool KMLpdManager::completePrinter(KMPrinter *printer) -{ - return completePrinterShort(printer); -} - -bool KMLpdManager::completePrinterShort(KMPrinter *printer) -{ - PrintcapEntry *entry = m_entries.find(printer->name()); - if (entry) - { - QString type(entry->comment(2)), driver(entry->comment(7)), lp(entry->arg("lp")); - printer->setDescription(i18n("Local printer queue (%1)").arg(type.isEmpty() ? i18n("Unknown type of local printer queue", "Unknown") : type)); - printer->setLocation(i18n("<Not available>")); - printer->setDriverInfo(driver.isEmpty() ? i18n("Unknown Driver", "Unknown") : driver); - // device - KURL url; - if (!entry->arg("rm").isEmpty()) - { - url = TQString::tqfromLatin1("lpd://%1/%2").arg(entry->arg("rm")).arg(entry->arg("rp")); - printer->setDescription(i18n("Remote LPD queue %1@%2").arg(entry->arg("rp")).arg(entry->arg("rm"))); - } - else if (!lp.isEmpty() && lp != "/dev/null") - url = TQString::tqfromLatin1("parallel:%1").arg(lp); - else if (TQFile::exists(entry->arg("sd")+"/.config")) - { - TQMap<TQString,TQString> map = loadPrinttoolCfgFile(entry->arg("sd")+"/.config"); - if (type == "SMB") - { - QStringList l = TQStringList::split('\\',map["share"],false); - if (map["workgroup"].isEmpty()) - url = TQString::tqfromLatin1("smb://%1/%2").arg(l[0]).arg(l[1]); - else - url = TQString::tqfromLatin1("smb://%1/%2/%3").arg(map["workgroup"]).arg(l[0]).arg(l[1]); - url.setUser(map["user"]); - url.setPass(map["password"]); - } - else if (type == "DIRECT") - url = TQString::tqfromLatin1("socket://%1:%2").arg(map["printer_ip"]).arg(map["port"]); - else if (type == "NCP") - { - url = TQString::tqfromLatin1("ncp://%1/%2").arg(map["server"]).arg(map["queue"]); - url.setUser(map["user"]); - url.setPass(map["password"]); - } - } - printer->setDevice(url); - return true; - } - else return false; -} - -bool KMLpdManager::createPrinter(KMPrinter *printer) -{ - // 1) create the printcap entry - PrintcapEntry *ent = findPrintcapEntry(printer->printerName()); - if (!ent) - { - ent = new PrintcapEntry(); - ent->m_name = printer->printerName(); - } - else - { - if (!printer->driver() && printer->option("kde-driver") != "raw") - printer->setDriver(loadPrinterDriver(printer,true)); - // remove it from current entries - ent = m_entries.take(ent->m_name); - ent->m_args.clear(); - } - // Standard options - if (printer->device().protocol() == "lpd") - { - // remote lpd queue - ent->m_args["rm"] = printer->device().host(); - ent->m_args["rp"] = printer->device().path().replace("/",TQString::tqfromLatin1("")); - ent->m_args["lpd_bounce"] = "true"; - ent->m_comment = TQString::tqfromLatin1("##PRINTTOOL3## REMOTE"); - } - ent->m_args["mx"] = (printer->option("mx").isEmpty() ? "#0" : printer->option("mx")); - ent->m_args["sh"] = TQString::null; - // create spool directory (if necessary) and update PrintcapEntry object - if (!createSpooldir(ent)) - { - setErrorMsg(i18n("Unable to create spool directory %1 for printer %2.").arg(ent->arg("sd")).arg(ent->m_name)); - delete ent; - return false; - } - if (!printer->driver() || printer->driver()->get("drtype") == "printtool") - if (!createPrinttoolEntry(printer,ent)) - { - setErrorMsg(i18n("Unable to save information for printer <b>%1</b>.").arg(printer->printerName())); - delete ent; - return false; - } - - // 2) write the printcap file - m_entries.insert(ent->m_name,ent); - if (!writePrinters()) - return false; - - // 3) save the printer driver (if any) - if (printer->driver()) - { - if (!savePrinterDriver(printer,printer->driver())) - { - m_entries.remove(ent->m_name); - writePrinters(); - return false; - } - } - - // 4) change permissions of spool directory - TQCString cmd = "chmod -R o-rwx,g+rwX "; - cmd += TQFile::encodeName(KProcess::quote(ent->arg("sd"))); - cmd += "&& chown -R lp.lp "; - cmd += TQFile::encodeName(KProcess::quote(ent->arg("sd"))); - if (system(cmd.data()) != 0) - { - setErrorMsg(i18n("Unable to set correct permissions on spool directory %1 for printer <b>%2</b>.").arg(ent->arg("sd")).arg(ent->m_name)); - return false; - } - - return true; -} - -bool KMLpdManager::removePrinter(KMPrinter *printer) -{ - PrintcapEntry *ent = findPrintcapEntry(printer->printerName()); - if (ent) - { - ent = m_entries.take(printer->printerName()); - if (!writePrinters()) - { - m_entries.insert(ent->m_name,ent); - return false; - } - TQCString cmd = "rm -rf "; - cmd += TQFile::encodeName(KProcess::quote(ent->arg("sd"))); - system(cmd.data()); - delete ent; - return true; - } - else - return false; -} - -bool KMLpdManager::enablePrinter(KMPrinter *printer, bool state) -{ - KPipeProcess proc; - QString cmd = programName(0); - cmd += " "; - cmd += state ? "up" : "down"; - cmd += " "; - cmd += KProcess::quote(printer->printerName()); - if (proc.open(cmd)) - { - QTextStream t(&proc); - QString buffer; - while (!t.eof()) - buffer.append(t.readLine()); - if (buffer.startsWith("?Privilege")) - { - setErrorMsg(i18n("Permission denied: you must be root.")); - return false; - } - return true; - } - else - { - setErrorMsg(i18n("Unable to execute command \"%1\".").arg(cmd)); - return false; - } -} - -bool KMLpdManager::enablePrinter(KMPrinter *printer) -{ - return enablePrinter(printer,true); -} - -bool KMLpdManager::disablePrinter(KMPrinter *printer) -{ - return enablePrinter(printer,false); -} - -void KMLpdManager::listPrinters() -{ - m_entries.clear(); - loadPrintcapFile(TQString::tqfromLatin1("%1/etc/printcap").arg(lpdprefix)); - - TQDictIterator<PrintcapEntry> it(m_entries); - for (;it.current();++it) - { - KMPrinter *printer = it.current()->createPrinter(); - addPrinter(printer); - } - - checkStatus(); -} - -TQString KMLpdManager::programName(int f) -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("LPD"); - switch (f) - { - case 0: return conf->readPathEntry("LpdCommand","/usr/sbin/lpc"); - case 1: return conf->readPathEntry("LpdQueue","lpq"); - case 2: return conf->readPathEntry("LpdRemove","lprm"); - } - return TQString::null; -} - -void KMLpdManager::checkStatus() -{ - KPipeProcess proc; - QString cmd = programName(0) + " status all"; - if (proc.open(cmd)) - { - QTextStream t(&proc); - QString line; - KMPrinter *printer(0); - int p(-1); - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) - continue; - if ((p=line.find(':')) != -1) - printer = findPrinter(line.left(p)); - else if (line.startsWith("printing") && printer) - printer->setState(line.find("enabled") != -1 ? KMPrinter::Idle : KMPrinter::Stopped); - else if (line.find("entries") != -1 && printer) - if (!line.startsWith("no") && printer->state() == KMPrinter::Idle) - printer->setState(KMPrinter::Processing); - } - } -} - -bool KMLpdManager::writePrinters() -{ - if (!writePrintcapFile(TQString::tqfromLatin1("%1/etc/printcap").arg(lpdprefix))) - { - setErrorMsg(i18n("Unable to write printcap file.")); - return false; - } - return true; -} - -void KMLpdManager::loadPrintcapFile(const TQString& filename) -{ - QFile f(filename); - if (f.exists() && f.open(IO_ReadOnly)) - { - QTextStream t(&f); - QString line, comment; - PrintcapEntry *entry; - while (!t.eof()) - { - line = getPrintcapLine(t,&comment); - if (line.isEmpty()) - continue; - entry = new PrintcapEntry; - if (entry->readLine(line)) - { - m_entries.insert(entry->m_name,entry); - entry->m_comment = comment; - } - else - { - delete entry; - break; - } - } - } -} - -bool KMLpdManager::writePrintcapFile(const TQString& filename) -{ - QFile f(filename); - if (f.open(IO_WriteOnly)) - { - QTextStream t(&f); - t << "# File generated by KDE print (LPD plugin).\n#Don't edit by hand." << endl << endl; - TQDictIterator<PrintcapEntry> it(m_entries); - for (;it.current();++it) - it.current()->writeEntry(t); - return true; - } - return false; -} - -PrinttoolEntry* KMLpdManager::findPrinttoolEntry(const TQString& name) -{ - if (m_ptentries.count() == 0) - loadPrinttoolDb(driverDirectory()+"/printerdb"); - PrinttoolEntry *ent = m_ptentries.find(name); - if (!ent) - setErrorMsg(i18n("Couldn't find driver <b>%1</b> in printtool database.").arg(name)); - return ent; -} - -void KMLpdManager::loadPrinttoolDb(const TQString& filename) -{ - QFile f(filename); - if (f.exists() && f.open(IO_ReadOnly)) - { - QTextStream t(&f); - PrinttoolEntry *entry = new PrinttoolEntry; - while (entry->readEntry(t)) - { - m_ptentries.insert(entry->m_name,entry); - entry = new PrinttoolEntry; - } - delete entry; - } -} - -DrMain* KMLpdManager::loadDbDriver(KMDBEntry *entry) -{ - QString ptdbfilename = driverDirectory() + "/printerdb"; - if (entry->file == ptdbfilename) - { - PrinttoolEntry *ptentry = findPrinttoolEntry(entry->modelname); - if (ptentry) - { - DrMain *dr = ptentry->createDriver(); - return dr; - } - } - return NULL; -} - -PrintcapEntry* KMLpdManager::findPrintcapEntry(const TQString& name) -{ - PrintcapEntry *ent = m_entries.find(name); - if (!ent) - setErrorMsg(i18n("Couldn't find printer <b>%1</b> in printcap file.").arg(name)); - return ent; -} - -DrMain* KMLpdManager::loadPrinterDriver(KMPrinter *printer, bool config) -{ - PrintcapEntry *entry = findPrintcapEntry(printer->name()); - if (!entry) - return NULL; - - // check for printtool driver (only for configuration) - QString sd = entry->arg("sd"), dr(entry->comment(7)); - if (TQFile::exists(sd+"/postscript.cfg") && config && !dr.isEmpty()) - { - TQMap<TQString,TQString> map = loadPrinttoolCfgFile(sd+"/postscript.cfg"); - PrinttoolEntry *ptentry = findPrinttoolEntry(dr); - if (!ptentry) - return NULL; - DrMain *dr = ptentry->createDriver(); - dr->setOptions(map); - map = loadPrinttoolCfgFile(sd+"/general.cfg"); - dr->setOptions(map); - map = loadPrinttoolCfgFile(sd+"/textonly.cfg"); - dr->setOptions(map); - return dr; - } - - // default - if (entry->m_comment.startsWith("##PRINTTOOL3##")) - setErrorMsg(i18n("No driver found (raw printer)")); - else - setErrorMsg(i18n("Printer type not recognized.")); - return NULL; -} - -bool KMLpdManager::checkGsDriver(const TQString& gsdriver) -{ - if (gsdriver == "ppa" || gsdriver == "POSTSCRIPT" || gsdriver == "TEXT") - return true; - else if (!m_gschecker->checkGsDriver(gsdriver)) - { - setErrorMsg(i18n("The driver device <b>%1</b> is not compiled in your GhostScript distribution. Check your installation or use another driver.").arg(gsdriver)); - return false; - } - return true; -} - -TQMap<TQString,TQString> KMLpdManager::loadPrinttoolCfgFile(const TQString& filename) -{ - QFile f(filename); - TQMap<TQString,TQString> map; - if (f.exists() && f.open(IO_ReadOnly)) - { - QTextStream t(&f); - QString line, name, val; - int p(-1); - while (!t.eof()) - { - line = getPrintcapLine(t); - if (line.isEmpty()) - break; - if (line.startsWith("export ")) - line.replace(0,7,""); - if ((p=line.find('=')) != -1) - { - name = line.left(p); - val = line.right(line.length()-p-1); - val.replace("\"",""); - val.replace("'",""); - if (!name.isEmpty() && !val.isEmpty()) - map[name] = val; - } - } - } - return map; -} - -bool KMLpdManager::savePrinttoolCfgFile(const TQString& templatefile, const TQString& dirname, const TQMap<TQString,TQString>& options) -{ - // defines input and output file - QString fname = TQFileInfo(templatefile).fileName(); - fname.replace(TQRegExp("\\.in$"),TQString::tqfromLatin1("")); - QFile fin(templatefile); - QFile fout(dirname + "/" + fname); - if (fin.exists() && fin.open(IO_ReadOnly) && fout.open(IO_WriteOnly)) - { - QTextStream tin(&fin), tout(&fout); - QString line, name; - int p(-1); - while (!tin.eof()) - { - line = tin.readLine().stripWhiteSpace(); - if (line.isEmpty() || line[0] == '#') - { - tout << line << endl; - continue; - } - if (line.startsWith("export ")) - { - tout << "export "; - line.replace(0,7,TQString::tqfromLatin1("")); - } - if ((p=line.find('=')) != -1) - { - name = line.left(p); - tout << name << '=' << options[name] << endl; - } - } - return true; - } - else return false; -} - -bool KMLpdManager::savePrinterDriver(KMPrinter *printer, DrMain *driver) -{ - // To be able to save a printer driver, a printcap entry MUST exist. - // We can then retrieve the spool directory from it. - QString spooldir; - PrintcapEntry *ent = findPrintcapEntry(printer->printerName()); - if (!ent) - return false; - spooldir = ent->arg("sd"); - - if (driver->get("drtype") == "printtool" && !spooldir.isEmpty()) - { - TQMap<TQString,TQString> options; - driver->getOptions(options,true); - // add some standard options - options["DESIRED_TO"] = "ps"; - options["PRINTER_TYPE"] = ent->comment(2); // get type from printcap entry (works in anycases) - options["PS_SEND_EOF"] = "NO"; - if (!checkGsDriver(options["GSDEVICE"])) - return false; - QString resol(options["RESOLUTION"]), color(options["COLOR"]); - // update entry comment to make printtool happy and save printcap file - ent->m_comment = TQString::tqfromLatin1("##PRINTTOOL3## %1 %2 %3 %4 {} {%5} %6 {}").arg(options["PRINTER_TYPE"]).arg(options["GSDEVICE"]).arg((resol.isEmpty() ? TQString::tqfromLatin1("NAxNA") : resol)).arg(options["PAPERSIZE"]).arg(driver->name()).arg((color.isEmpty() ? TQString::tqfromLatin1("Default") : color.right(color.length()-15))); - ent->m_args["if"] = spooldir+TQString::tqfromLatin1("/filter"); - if (!writePrinters()) - return false; - // write various driver files using templates - TQCString cmd = "cp "; - cmd += TQFile::encodeName(KProcess::quote(driverDirectory()+"/master-filter")); - cmd += " "; - cmd += TQFile::encodeName(KProcess::quote(spooldir + "/filter")); - if (system(cmd.data()) == 0 && - savePrinttoolCfgFile(driverDirectory()+"/general.cfg.in",spooldir,options) && - savePrinttoolCfgFile(driverDirectory()+"/postscript.cfg.in",spooldir,options) && - savePrinttoolCfgFile(driverDirectory()+"/textonly.cfg.in",spooldir,options)) - return true; - setErrorMsg(i18n("Unable to write driver associated files in spool directory.")); - } - return false; -} - -bool KMLpdManager::createPrinttoolEntry(KMPrinter *printer, PrintcapEntry *entry) -{ - KURL dev(printer->device()); - QString prot = dev.protocol(), sd(entry->arg("sd")); - entry->m_comment = TQString::tqfromLatin1("##PRINTTOOL3## %1").arg(ptPrinterType(printer)); - if (prot == "smb" || prot == "ncp" || prot == "socket") - { - entry->m_args["af"] = sd+TQString::tqfromLatin1("/acct"); - QFile f(sd+TQString::tqfromLatin1("/.config")); - if (f.open(IO_WriteOnly)) - { - QTextStream t(&f); - if (prot == "socket") - { - t << "printer_ip=" << dev.host() << endl; - t << "port=" << dev.port() << endl; - entry->m_args["if"] = driverDirectory()+TQString::tqfromLatin1("/directprint"); - } - else if (prot == "smb") - { - QStringList l = TQStringList::split('/',dev.path(),false); - if (l.count() == 2) - { - t << "share='\\\\" << l[0] << '\\' << l[1] << '\'' << endl; - } - else if (l.count() == 1) - { - t << "share='\\\\" << dev.host() << '\\' << l[0] << '\'' << endl; - } - t << "hostip=" << endl; - t << "user='" << dev.user() << '\'' << endl; - t << "password='" << dev.pass() << '\'' << endl; - t << "workgroup='" << (l.count() == 2 ? dev.host() : TQString::tqfromLatin1("")) << '\'' << endl; - entry->m_args["if"] = driverDirectory()+TQString::tqfromLatin1("/smbprint"); - } - else if (prot == "ncp") - { - t << "server=" << dev.host() << endl; - t << "queue=" << dev.path().replace("/",TQString::tqfromLatin1("")) << endl; - t << "user=" << dev.user() << endl; - t << "password=" << dev.pass() << endl; - entry->m_args["if"] = driverDirectory()+TQString::tqfromLatin1("/ncpprint"); - } - } - else return false; - entry->m_args["lp"] = TQString::tqfromLatin1("/dev/null"); - } - else if (prot != "lpd") - entry->m_args["lp"] = dev.path(); - return true; -} - -bool KMLpdManager::createSpooldir(PrintcapEntry *entry) -{ - // first check if it has a "sd" defined - if (entry->arg("sd").isEmpty()) - entry->m_args["sd"] = TQString::tqfromLatin1("/var/spool/lpd/")+entry->m_name; - QString sd = entry->arg("sd"); - if (!KStandardDirs::exists(sd)) - { - if (!KStandardDirs::makeDir(sd,0750)) - return false; - struct passwd *lp_pw = getpwnam("lp"); - if (lp_pw && chown(TQFile::encodeName(sd),lp_pw->pw_uid,lp_pw->pw_gid) != 0) - return false; - } - return true; -} - -bool KMLpdManager::validateDbDriver(KMDBEntry *entry) -{ - PrinttoolEntry *ptentry = findPrinttoolEntry(entry->modelname); - return (ptentry && checkGsDriver(ptentry->m_gsdriver)); -} - -//************************************************************************************************ - -TQString ptPrinterType(KMPrinter *p) -{ - QString type, prot = p->device().protocol(); - if (prot == "lpd") type = "REMOTE"; - else if (prot == "smb") type = "SMB"; - else if (prot == "ncp") type = "NCP"; - else if (prot == "socket") type = "DIRECT"; - else type = "LOCAL"; - return type; -} diff --git a/kdeprint/lpd/kmlpdmanager.h b/kdeprint/lpd/kmlpdmanager.h deleted file mode 100644 index 3c2291017..000000000 --- a/kdeprint/lpd/kmlpdmanager.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPDMANAGER_H -#define KMLPDMANAGER_H - -#include "kmmanager.h" -#include <tqdict.h> - -class PrintcapEntry; -class PrinttoolEntry; -class GsChecker; - -class KMLpdManager : public KMManager -{ -public: - KMLpdManager(TQObject *parent = 0, const char *name = 0); - ~KMLpdManager(); - - bool completePrinterShort(KMPrinter*); - bool completePrinter(KMPrinter*); - bool createPrinter(KMPrinter*); - bool removePrinter(KMPrinter*); - bool enablePrinter(KMPrinter*); - bool disablePrinter(KMPrinter*); - - // Driver DB functions - TQString driverDbCreationProgram(); - TQString driverDirectory(); - - // Driver loading functions - DrMain* loadDbDriver(KMDBEntry*); - DrMain* loadPrinterDriver(KMPrinter *p, bool config = false); - bool savePrinterDriver(KMPrinter*, DrMain*); - bool validateDbDriver(KMDBEntry*); - -protected: - void listPrinters(); - bool writePrinters(); - void loadPrintcapFile(const TQString& filename); - bool writePrintcapFile(const TQString& filename); - void loadPrinttoolDb(const TQString& filename); - TQMap<TQString,TQString> loadPrinttoolCfgFile(const TQString& filename); - bool savePrinttoolCfgFile(const TQString& templatefile, const TQString& dirname, const TQMap<TQString,TQString>& options); - bool checkGsDriver(const TQString& gsdriver); - bool createSpooldir(PrintcapEntry*); - bool createPrinttoolEntry(KMPrinter*, PrintcapEntry*); - PrintcapEntry* findPrintcapEntry(const TQString& name); - PrinttoolEntry* findPrinttoolEntry(const TQString& name); - TQString programName(int); - void checkStatus(); - bool enablePrinter(KMPrinter*, bool); - -private: - TQDict<PrintcapEntry> m_entries; - TQDict<PrinttoolEntry> m_ptentries; - GsChecker *m_gschecker; -}; - -#endif diff --git a/kdeprint/lpd/kmlpduimanager.cpp b/kdeprint/lpd/kmlpduimanager.cpp deleted file mode 100644 index fad3fcd58..000000000 --- a/kdeprint/lpd/kmlpduimanager.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpduimanager.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmwizard.h" -#include "kmwbackend.h" -#include "kmpropertypage.h" -#include "kmpropbackend.h" -#include "kmpropdriver.h" - -#include <tqfile.h> -#include <klocale.h> - -KMLpdUiManager::KMLpdUiManager(TQObject *parent, const char *name) -: KMUiManager(parent,name) -{ -} - -KMLpdUiManager::~KMLpdUiManager() -{ -} - -void KMLpdUiManager::setupWizard(KMWizard *wizard) -{ - KMWBackend *backend = wizard->backendPage(); - backend->addBackend(KMWizard::Local,i18n("Local printer (parallel, serial, USB)"),true); - backend->addBackend(KMWizard::LPD,i18n("Remote LPD queue"),true); - backend->addBackend(KMWizard::SMB,i18n("SMB shared printer (Windows)"),false,KMWizard::Password); - backend->addBackend(KMWizard::TCP,i18n("Network printer (TCP)"),false); - backend->addBackend(KMWizard::File,i18n("File printer (print to file)"),true); - - KMManager *mgr = KMFactory::self()->manager(); - if (TQFile::exists(mgr->driverDirectory()+"/smbprint")) backend->enableBackend(KMWizard::SMB,true); - if (TQFile::exists(mgr->driverDirectory()+"/directprint")) backend->enableBackend(KMWizard::TCP,true); - if (TQFile::exists(mgr->driverDirectory()+"/ncpprint")) backend->enableBackend(KMWizard::Custom+1,true); -} - -void KMLpdUiManager::setupPropertyPages(KMPropertyPage *p) -{ - p->addPropPage(new KMPropBackend(p, "Backend")); - p->addPropPage(new KMPropDriver(p, "Driver")); -} diff --git a/kdeprint/lpd/kmlpduimanager.h b/kdeprint/lpd/kmlpduimanager.h deleted file mode 100644 index 7aca6ed1d..000000000 --- a/kdeprint/lpd/kmlpduimanager.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPDUIMANAGER_H -#define KMLPDUIMANAGER_H - -#include "kmuimanager.h" - -class KMLpdUiManager : public KMUiManager -{ -public: - KMLpdUiManager(TQObject *parent = 0, const char *name = 0); - ~KMLpdUiManager(); - - void setupWizard(KMWizard*); - void setupPropertyPages(KMPropertyPage*); -}; - -#endif diff --git a/kdeprint/lpd/lpd.print b/kdeprint/lpd/lpd.print deleted file mode 100644 index 019d5b9c8..000000000 --- a/kdeprint/lpd/lpd.print +++ /dev/null @@ -1,87 +0,0 @@ -[KDE Print Entry] -PrintSystem=lpd -Comment=LPR (Standard BSD print system) -Comment[af]= Lpr (Standaard Bsd druk stelsel) -Comment[ar]=LPR (نظام طباعة BSD المعياري) -Comment[az]=LPR (Standard BSD çap sistemi) -Comment[be]=LPR (Ð—Ð²Ñ‹Ñ‡Ð°Ð¹Ð½Ð°Ñ ÑÑ–ÑÑ‚Ñма друку BSD) -Comment[bn]=à¦à¦²-পি-আর (সà§à¦Ÿà§à¦¯à¦¾à¦£à§à¦¡à¦¾à¦°à§à¦¡ বি-à¦à¦¸-ডি মà§à¦¦à§à¦°à¦£ বà§à¦¯à¦¬à¦¸à§à¦¥à¦¾) -Comment[br]=LPR (Reizhiad moulañ reoliek evit BSD) -Comment[bs]=LPR (standardni BSD sistem Å¡tampe) -Comment[ca]=LPR (sistema d'impressió estàndard de BSD) -Comment[cs]=LPR (Standardní tiskový systém na BSD) -Comment[csb]=LPR (sztandardowô systema drëkù BSD) -Comment[cy]=LPR (Cysawd argraffu cyffredinol BSD) -Comment[da]=LPR (Standard BSD-udskriftssystem) -Comment[de]=LPR (standardmäßiges BSD-Drucksystem) -Comment[el]=LPR (Τυπικό BSD σÏστημα εκτÏπωσης) -Comment[eo]=LPR (Normala BSD-pressistemo) -Comment[es]=LPR (sistema de impresión estándar de BSD) -Comment[et]=LPR (standardne BSD trükkimise süsteem) -Comment[eu]=LPR (BSDren inprimatze-sistema estandarra) -Comment[fa]=LPR (سیستم چاپ BSD استاندارد) -Comment[fi]=LPR (standardi BSD-tulostusjärjestelmä) -Comment[fr]=LPR (système d'impression BSD standard) -Comment[fy]=LPR (standert BSD-ôfdruksysteem) -Comment[ga]=LPR (Gnáthchóras priontála BSD) -Comment[gl]=LPR (Sistema de Impresión Estándar de BSD) -Comment[he]=מערכת ההדפסה הסטנדרטית של LPR) BSD) -Comment[hi]=LPR (मानक BSD छपाई पदà¥à¤§à¤¤à¥à¤¤à¤¿) -Comment[hr]=LPR (standardni BSD sustav za ispis) -Comment[hsb]=LPR (Standardny ćišćenski system za BSD) -Comment[hu]=LPR (BSD-típusú nyomtatórendszer) -Comment[id]=LPR (sistem pencetakan standar BSD) -Comment[is]= LPR (Venjulega BSD prentkerfið) -Comment[it]=LPR (sistema di stampa standard di BSD) -Comment[ja]=LPR (標準 BSD å°åˆ·ã‚·ã‚¹ãƒ†ãƒ ) -Comment[ka]=LPR (სტáƒáƒœáƒ“áƒáƒ áƒ¢áƒ£áƒšáƒ˜ BSD ბეჭდვის სისტემáƒ) -Comment[kk]=LPR (BSD жүйеÑіндегі Ñтандартты баÑып шығаруы) -Comment[km]=LPR (ប្រពáŸáž“្ធ​បោះពុម្ព BSD ážáŸ’នាážâ€‹áž‚ំរូ) -Comment[ko]=LPR (표준 BSD ì¸ì‡„ 시스템) -Comment[lb]=LPR (Standard-Drécksystem vu BSD) -Comment[lt]=LPR (StandartinÄ— BSD spausdinimo sistema) -Comment[lv]=LPR (Standarta BSD drukas sistÄ“ma) -Comment[mk]=LPR (Стандардниот BSD ÑиÑтем за печатење) -Comment[mn]=LPR (Стандарт BSD-Ð¥ÑвлÑÑ… ÑиÑтем) -Comment[ms]=LPR (Sistem cetak piawai BSD) -Comment[mt]=LPR (sistema tal-ipprintjar standard BSD) -Comment[nb]=LPR (Standard BSD skriversystem) -Comment[nds]=LPR (Dat Standard-Drucksysteem vun BSD) -Comment[ne]=LPR (मानक BSD मà¥à¤¦à¥à¤°à¤£ पà¥à¤°à¤£à¤¾à¤²à¥€) -Comment[nl]=LPR (standaard BSD-afdruksysteem) -Comment[nn]=LPR (vanleg BSD-utskriftssystem) -Comment[nso]=LPR (System yeo e lekanetsego ya kgatiso ya BSD) -Comment[pa]=LPR (ਮਿਆਰੀ BSD ਪà©à¨°à¨¿à©°à¨Ÿ ਸਿਸਟਮ) -Comment[pl]=LPR (standardowy system druku BSD) -Comment[pt]=LPR (o sistema de impressão do BSD) -Comment[pt_BR]=LPR (Sistema padrão de Impressão do BSD) -Comment[ro]=LPR (Sistemul de tipărire standard BSD) -Comment[ru]=LPR (ÑÑ‚Ð°Ð½Ð´Ð°Ñ€Ñ‚Ð½Ð°Ñ ÑиÑтема печати BSD) -Comment[rw]=LPR (Sisitemu yo gucapa BSD isanzwe) -Comment[se]=LPR (Standárda BSD Äálihanvuogádat) -Comment[sk]=LPR (Å tandardný tlaÄový systém BSD) -Comment[sl]=LPR (obiÄajni tiskalniÅ¡ki sistem iz BSD) -Comment[sq]=LPR (BSD Sistem Standard Shtypi -Comment[sr]=LPR (Ñтандардни BSD ÑиÑтем за штампање) -Comment[sr@Latn]=LPR (standardni BSD sistem za Å¡tampanje) -Comment[ss]=LPR (Umhini wekushicelela welizinga le BSD) -Comment[sv]=LPR (Standardskrivarsystem för BSD) -Comment[ta]=LPR (நிலையான BSD அசà¯à®šà¯ அமைபà¯à®ªà¯) -Comment[te]=ఎలౠపి ఆరౠ(సాధరణ బి ఎసౠడి à°ªà±à°°à°šà±à°°à°£ à°µà±à°¯à°µà°¸à±à°¥) -Comment[tg]=LPR (ÑиÑтемаи чопи Ñтандартии BSD) -Comment[th]=LPR (ระบบà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œà¸¡à¸²à¸•à¸£à¸à¸²à¸™à¸‚อง BSD) -Comment[tr]=LPR (Standart BSD yazdırma sistemi) -Comment[tt]=LPR (BSD'nıñ töp bastıru sisteme) -Comment[uk]=LPR (типова ÑиÑтема друку BSD) -Comment[uz]=LPR (BSD'ning andoza bosib chiqarish tizimi) -Comment[uz@cyrillic]=LPR (BSD'нинг андоза боÑиб чиқариш тизими) -Comment[ven]=LPR (maitele a u phirintha a zwino fana zwa BCD) -Comment[vi]=LPR (hệ thống in BSD chuẩn) -Comment[wa]=LPR (Sistinme d' imprimaedje BSD standÃ¥rd) -Comment[xh]=LPR (Indlela esezantsi yoshicilelo lwe BSD) -Comment[zh_CN]=LPR (标准 BSD 打å°ç³»ç»Ÿ) -Comment[zh_HK]=LPR (標準 BSD 列å°ç³»çµ±) -Comment[zh_TW]=LPR (標準 BSD 列å°ç³»çµ±) -Comment[zu]=LPR (Isistimu yokushicelela evamile ye-BSD) -DetectUris=service:/printer,config:/printcap -DetectPrecedence=5 diff --git a/kdeprint/lpd/lpdtools.cpp b/kdeprint/lpd/lpdtools.cpp deleted file mode 100644 index 610e8ead5..000000000 --- a/kdeprint/lpd/lpdtools.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "lpdtools.h" -#include "driver.h" -#include "kmprinter.h" - -#include <tqfile.h> -#include <klocale.h> - -static const char *pt_pagesize[] = { - "ledger", I18N_NOOP("Ledger"), - "legal", I18N_NOOP("US Legal"), - "letter", I18N_NOOP("US Letter"), - "a4", I18N_NOOP("A4"), - "a3", I18N_NOOP("A3"), - "b4", I18N_NOOP("B4"), - "b5", I18N_NOOP("B5"), - 0 -}; -static int pt_nup[] = { 1, 2, 4, 8, -1 }; -static const char *pt_bool[] = { - "YES", I18N_NOOP("Enabled"), - "NO", I18N_NOOP("Disabled"), - 0 -}; - -void setupBooleanOption(DrBooleanOption *opt) -{ - int i(0); - while (pt_bool[i]) - { - DrBase *ch = new DrBase(); - ch->setName(pt_bool[i++]); - ch->set("text",pt_bool[i++]); - opt->addChoice(ch); - } -} - -TQString nextWord(const TQString& s, int& pos) -{ - int p1(pos), p2(0); - while (s[p1].isSpace() && p1 < (int)s.length()) p1++; - if (s[p1] == '{') - { - p1++; - p2 = s.find('}',p1); - } - else - { - p2 = p1; - while (!s[p2].isSpace() && p2 < (int)s.length()) p2++; - } - pos = (p2+1); - return s.mid(p1,p2-p1); -} - -//************************************************************************************************ - -bool PrintcapEntry::readLine(const TQString& line) -{ - QStringList l = TQStringList::split(':',line,false); - if (l.count() > 0) - { - m_name = l[0]; - int p(-1); - // discard aliases - if ((p=m_name.find('|')) != -1) - m_name = m_name.left(p); - m_args.clear(); - for (uint i=1; i<l.count(); i++) - { - int p = l[i].find('='); - if (p == -1) p = 2; - QString key = l[i].left(p); - QString value = l[i].right(l[i].length()-(l[i][p] == '=' ? p+1 : p)); - m_args[key] = value; - } - return true; - } - return false; -} - -void PrintcapEntry::writeEntry(TQTextStream& t) -{ - if (m_comment.isEmpty()) t << "# Entry for printer " << m_name << endl; - else t << m_comment << endl; - t << m_name << ":"; - for (TQMap<TQString,TQString>::ConstIterator it=m_args.begin(); it!=m_args.end(); ++it) - { - t << "\\\n\t:" << it.key(); - if (!it.data().isEmpty()) - t << ((*it)[0] == '#' ? "" : "=") << *it; - t << ":"; - } - t << endl << endl; -} - -TQString PrintcapEntry::comment(int index) -{ - QString w; - if (m_comment.startsWith("##PRINTTOOL3##")) - { - int p(0); - for (int i=0;i<index;i++) - w = nextWord(m_comment,p); - } - return w; -} - -KMPrinter* PrintcapEntry::createPrinter() -{ - KMPrinter *printer = new KMPrinter(); - printer->setName(m_name); - printer->setPrinterName(m_name); - printer->setInstanceName(TQString::null); - printer->setState(KMPrinter::Idle); - printer->setType(KMPrinter::Printer); - return printer; -} - -//************************************************************************************************ - -TQStringList splitPrinttoolLine(const TQString& line) -{ - QStringList l; - int p = line.find(':'); - if (p != -1) - { - l.append(line.left(p)); - p = line.find('{',p); - if (p == -1) - l.append(line.right(line.length()-l[0].length()-1).stripWhiteSpace()); - else - { - while (p != -1) - { - int q = line.find('}',p); - if (q != -1) - { - l.append(line.mid(p+1,q-p-1)); - p = line.find('{',q); - } - else break; - } - } - } - return l; -} - -bool PrinttoolEntry::readEntry(TQTextStream& t) -{ - QString line; - QStringList args; - - m_resolutions.setAutoDelete(true); - m_depths.setAutoDelete(true); - m_resolutions.clear(); - m_depths.clear(); - while (!t.eof()) - { - line = getPrintcapLine(t); - if (line.isEmpty()) - break; - if (line == "EndEntry") - return !m_name.isEmpty(); - QStringList l = splitPrinttoolLine(line); - if (l.count() > 1) - { - if (l[0] == "StartEntry") m_name = l[1]; - else if (l[0] == "GSDriver") m_gsdriver = l[1]; - else if (l[0] == "About") m_about = l[1]; - else if (l[0] == "Description") m_description = l[1]; - else if (l[0] == "Resolution" && l.count() > 2) - { - Resolution *resol = new Resolution; - bool ok(false); - resol->xdpi = l[1].toInt(&ok); - if (ok) resol->ydpi = l[2].toInt(&ok); - if (l.count() > 3) - resol->comment = l[3]; - if (ok) m_resolutions.append(resol); - else delete resol; - } - else if (l[0] == "BitsPerPixel" && l.count() > 1) - { - BitsPerPixel *dpth = new BitsPerPixel; - dpth->bpp = l[1]; - if (l.count() > 2) - dpth->comment = l[2]; - m_depths.append(dpth); - } - } - } - return false; -} - -DrMain* PrinttoolEntry::createDriver() -{ - // create driver - DrMain *dr = new DrMain(); - dr->setName(m_name); - dr->set("description",m_description); - dr->set("text",m_description); - dr->set("drtype","printtool"); - - DrGroup *gr(0); - DrListOption *lopt(0); - DrStringOption *sopt(0); - DrBooleanOption *bopt(0); - DrBase *ch(0); - - if (m_gsdriver != "TEXT") - { - // create GS group - gr = new DrGroup(); - gr->set("text",i18n("GhostScript settings")); - dr->addGroup(gr); - - // Pseudo option to have access to GS driver - lopt = new DrListOption(); - lopt->setName("GSDEVICE"); - lopt->set("text",i18n("Driver")); - lopt->set("default",m_gsdriver); - gr->addOption(lopt); - ch = new DrBase(); - ch->setName(m_gsdriver); - ch->set("text",m_gsdriver); - lopt->addChoice(ch); - lopt->setValueText(m_gsdriver); - - - // Resolutions - if (m_resolutions.count() > 0) - { - lopt = new DrListOption(); - lopt->setName("RESOLUTION"); - lopt->set("text",i18n("Resolution")); - gr->addOption(lopt); - TQPtrListIterator<Resolution> it(m_resolutions); - for (int i=0;it.current();++it,i++) - { - ch = new DrBase; - ch->setName(TQString::tqfromLatin1("%1x%2").arg(it.current()->xdpi).arg(it.current()->ydpi)); - if (it.current()->comment.isEmpty()) - ch->set("text",TQString::tqfromLatin1("%1x%2 DPI").arg(it.current()->xdpi).arg(it.current()->ydpi)); - else - ch->set("text",TQString::tqfromLatin1("%2x%3 DPI (%1)").arg(it.current()->comment).arg(it.current()->xdpi).arg(it.current()->ydpi)); - lopt->addChoice(ch); - } - QString defval = lopt->choices()->first()->name(); - lopt->set("default",defval); - lopt->setValueText(defval); - } - - // BitsPerPixels - if (m_depths.count() > 0) - { - lopt = new DrListOption(); - lopt->setName("COLOR"); - lopt->set("text",i18n("Color depth")); - gr->addOption(lopt); - TQPtrListIterator<BitsPerPixel> it(m_depths); - for (int i=0;it.current();++it,i++) - { - ch = new DrBase; - if (m_gsdriver != "uniprint") - ch->setName(TQString::tqfromLatin1("-dBitsPerPixel=%1").arg(it.current()->bpp)); - else - ch->setName(it.current()->bpp); - if (it.current()->comment.isEmpty()) - ch->set("text",it.current()->bpp); - else - ch->set("text",TQString::tqfromLatin1("%1 - %2").arg(it.current()->bpp).arg(it.current()->comment)); - lopt->addChoice(ch); - } - QString defval = lopt->choices()->first()->name(); - lopt->set("default",defval); - lopt->setValueText(defval); - } - - // additional GS options - sopt = new DrStringOption; - sopt->setName("EXTRA_GS_OPTIONS"); - sopt->set("text",i18n("Additional GS options")); - gr->addOption(sopt); - } - - // General group - gr = new DrGroup(); - gr->set("text",i18n("General")); - dr->addGroup(gr); - - // Page size - lopt = new DrListOption(); - lopt->setName("PAPERSIZE"); - lopt->set("text",i18n("Page size")); - lopt->set("default","letter"); - gr->addOption(lopt); - int i(0); - while (pt_pagesize[i]) - { - ch = new DrBase(); - ch->setName(pt_pagesize[i++]); - ch->set("text",i18n(pt_pagesize[i++])); - lopt->addChoice(ch); - } - lopt->setValueText("letter"); - - // Nup - lopt = new DrListOption(); - lopt->setName("NUP"); - lopt->set("text",i18n("Pages per sheet")); - lopt->set("default","1"); - gr->addOption(lopt); - i = 0; - while (pt_nup[i] != -1) - { - ch = new DrBase(); - ch->setName(TQString::number(pt_nup[i++])); - ch->set("text",ch->name()); - lopt->addChoice(ch); - } - lopt->setValueText("1"); - - // Margins - sopt = new DrStringOption(); - sopt->setName("RTLFTMAR"); - sopt->set("text",i18n("Left/right margin (1/72 in)")); - sopt->setValueText("18"); - gr->addOption(sopt); - sopt = new DrStringOption(); - sopt->setName("TOPBOTMAR"); - sopt->set("text",i18n("Top/bottom margin (1/72 in)")); - sopt->setValueText("18"); - gr->addOption(sopt); - - // Text group - gr = new DrGroup(); - gr->set("text",i18n("Text options")); - dr->addGroup(gr); - - // Send EOF - bopt = new DrBooleanOption(); - bopt->setName("TEXT_SEND_EOF"); - bopt->set("text",i18n("Send EOF after job to eject page")); - gr->addOption(bopt); - setupBooleanOption(bopt); - bopt->setValueText("NO"); - - // Fix stair-stepping - bopt = new DrBooleanOption(); - bopt->setName("CRLFTRANS"); - bopt->set("text",i18n("Fix stair-stepping text")); - gr->addOption(bopt); - setupBooleanOption(bopt); - bopt->choices()->first()->setName("1"); - bopt->choices()->last()->setName("0"); - bopt->setValueText("0"); - - if (m_gsdriver != "POSTSCRIPT") - { - // Fast text printing - bopt = new DrBooleanOption(); - bopt->setName("ASCII_TO_PS"); - bopt->set("text",i18n("Fast text printing (non-PS printers only)")); - gr->addOption(bopt); - setupBooleanOption(bopt); - bopt->choices()->first()->setName("NO"); - bopt->choices()->last()->setName("YES"); - bopt->setValueText("NO"); - } - - return dr; -} - -//************************************************************************************************ - -TQString getPrintcapLine(TQTextStream& t, TQString *lastcomment) -{ - QString line, buffer, comm; - while (!t.eof()) - { - buffer = t.readLine().stripWhiteSpace(); - if (buffer.isEmpty() || buffer[0] == '#') - { - comm = buffer; - continue; - } - line.append(buffer); - if (line.right(1) == "\\") - { - line.truncate(line.length()-1); - line = line.stripWhiteSpace(); - } - else break; - } - if (lastcomment) - *lastcomment = comm; - return line; -} diff --git a/kdeprint/lpd/lpdtools.h b/kdeprint/lpd/lpdtools.h deleted file mode 100644 index 692dd0fa2..000000000 --- a/kdeprint/lpd/lpdtools.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 LPDTOOLS_H -#define LPDTOOLS_H - -#include <tqstring.h> -#include <tqmap.h> -#include <tqptrlist.h> -#include <tqtextstream.h> - -class KMLpdManager; -class DrMain; -class KMPrinter; - -class PrintcapEntry -{ -friend class KMLpdManager; -public: - bool readLine(const TQString& line); - void writeEntry(TQTextStream&); - KMPrinter* createPrinter(); - TQString arg(const TQString& key) const { return m_args[key]; } - TQString comment(int i); -private: - QString m_name; - QString m_comment; - TQMap<TQString,TQString> m_args; -}; - -//***************************************************************************************************** - -struct Resolution -{ - int xdpi, ydpi; - QString comment; -}; - -struct BitsPerPixel -{ - QString bpp; - QString comment; -}; - -class PrinttoolEntry -{ -friend class KMLpdManager; -public: - bool readEntry(TQTextStream& t); - DrMain* createDriver(); -private: - QString m_name, m_gsdriver, m_description, m_about; - TQPtrList<Resolution> m_resolutions; - TQPtrList<BitsPerPixel> m_depths; -}; - -//***************************************************************************************************** - -TQString getPrintcapLine(TQTextStream& t, TQString *lastcomment = NULL); - -#endif // LPDTOOLS_H diff --git a/kdeprint/lpd/make_driver_db_lpd.c b/kdeprint/lpd/make_driver_db_lpd.c deleted file mode 100644 index 02aced962..000000000 --- a/kdeprint/lpd/make_driver_db_lpd.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include <config.h> - -#define BUFFER_SIZE 1024 - -int parseRhsPrinterDb(const char *filename, FILE *out); - -int main(int argc, char *argv[]) -{ - FILE *out; - - if (argc != 3) - { - fprintf(stderr,"usage: make_driver_db_lpd <dbdirectory> <dbfilename>\n"); - exit(-1); - } - out = fopen(argv[2],"w"); - if (out == NULL) - { - fprintf(stderr,"Unable to open DB file: %s\n",argv[2]); - exit(-1); - } - /* first parse RHS driver DB */ - if (!parseRhsPrinterDb("/usr/lib/rhs/rhs-printfilters/printerdb",out)) - fprintf(stderr,"Unable to parse RHS DB file\n"); - return 0; -} - -char* skipSpaces(char *c) -{ - char *cc = c; - while (cc && *cc && isspace(*cc)) cc++; - return cc; -} - -int parseRhsPrinterDb(const char *filename, FILE *out) -{ - FILE *in; - char buffer[BUFFER_SIZE], *c; - - in = fopen(filename,"r"); - if (in == NULL) - return 0; - while (fgets(buffer,BUFFER_SIZE,in)) - { - c = skipSpaces(buffer); /* skip leading white spaces */ - if (c == NULL || *c == '#') /* empty line or comment line */ - continue; - if (strncmp(c,"StartEntry:",11) == 0) /* start a new entry */ - { - fprintf(out,"\n"); - fprintf(out,"FILE=%s\n",filename); - c = skipSpaces(c+11); - if (c) - fprintf(out,"MODELNAME=%s",c); - } - else if (strncmp(c,"Description:",12) == 0) - { - char *c1, *c2; - c1 = strchr(c+12,'{'); - c2 = strchr(c+12,'}'); - if (c1 && c2) - { - char model[BUFFER_SIZE], manuf[BUFFER_SIZE]; - char *c3; - - *c2 = 0; - c1++; - c3 = strchr(c1,' '); - if (c3) - { - *c3 = 0; - c3++; - strlcpy(manuf,c1, sizeof(manuf)); - strlcpy(model,c3, sizeof(model)); - } - else - { - strlcpy(model,c1, sizeof(model)); - strlcpy(manuf,"PrintTool (RH)", sizeof(manuf)); - } - fprintf(out,"MANUFACTURER=%s\n",manuf); - fprintf(out,"MODEL=%s\n",model); - fprintf(out,"DESCRIPTION=%s %s\n",manuf,model); - } - } - } - return 1; -} diff --git a/kdeprint/lpdunix/CMakeLists.txt b/kdeprint/lpdunix/CMakeLists.txt deleted file mode 100644 index 5b30cf46c..000000000 --- a/kdeprint/lpdunix/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/tdeprint -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES lpdunix.print DESTINATION ${DATA_INSTALL_DIR}/tdeprint/plugins ) - - -#### tdeprint_lpdunix ########################### - -set( target tdeprint_lpdunix ) - -set( ${target}_SRCS - kmlpdunixfactory.cpp kmlpdunixmanager.cpp - klpdunixprinterimpl.cpp kmlpdunixuimanager.cpp -) - -tde_add_kpart( ${target} - SOURCES ${${target}_SRCS} - LINK tdeprint-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) diff --git a/kdeprint/lpdunix/Makefile.am b/kdeprint/lpdunix/Makefile.am deleted file mode 100644 index 019ead755..000000000 --- a/kdeprint/lpdunix/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/tdeprint $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_lpdunix.la - -tdeprint_lpdunix_la_SOURCES = kmlpdunixfactory.cpp kmlpdunixmanager.cpp klpdunixprinterimpl.cpp kmlpdunixuimanager.cpp -tdeprint_lpdunix_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_lpdunix_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEPRINT) -tdeprint_lpdunix_la_METASOURCES = AUTO - -noinst_HEADERS = kmlpdunixmanager.h klpdunixprinterimpl.h kmlpdunixuimanager.h - -entry_DATA = lpdunix.print -entrydir = $(kde_datadir)/tdeprint/plugins diff --git a/kdeprint/lpdunix/klpdunixprinterimpl.cpp b/kdeprint/lpdunix/klpdunixprinterimpl.cpp deleted file mode 100644 index 9ba97efae..000000000 --- a/kdeprint/lpdunix/klpdunixprinterimpl.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "klpdunixprinterimpl.h" -#include "kprinter.h" - -#include <tqfile.h> -#include <kstandarddirs.h> -#include <klocale.h> -#include <kmacroexpander.h> - -KLpdUnixPrinterImpl::KLpdUnixPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ -} - -KLpdUnixPrinterImpl::~KLpdUnixPrinterImpl() -{ -} - -void KLpdUnixPrinterImpl::initLpPrint(TQString& cmd, KPrinter *printer) -{ - cmd += TQString::tqfromLatin1(" -d %1 -n%2").arg(quote(printer->printerName())).arg(printer->numCopies()); -} - -void KLpdUnixPrinterImpl::initLprPrint(TQString& cmd, KPrinter *printer) -{ - cmd += TQString::tqfromLatin1(" -P %1 '-#%2'").arg(quote(printer->printerName())).arg(printer->numCopies()); -} - -// look for executable, starting with "lpr" -TQString KLpdUnixPrinterImpl::executable() -{ - QString exe = KStandardDirs::findExe("lpr"); - if (exe.isEmpty()) - exe = KStandardDirs::findExe("lp"); - return exe; -} - -bool KLpdUnixPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - TQString exe = printer->option( "kde-printcommand" ); - if ( exe.isEmpty() || exe == "<automatic>" ) - { - exe = executable(); - if (!exe.isEmpty()) - { - cmd = exe; - if (exe.right(3) == "lpr") - initLprPrint(cmd,printer); - else - initLpPrint(cmd,printer); - return true; - } - else - printer->setErrorMessage(i18n("No valid print executable was found in your path. Check your installation.")); - return false; - } - else - { - TQMap<TQString,TQString> map; - map.insert( "printer", printer->printerName() ); - map.insert( "copies", TQString::number( printer->numCopies() ) ); - cmd = KMacroExpander::expandMacrosShellQuote( exe, map ); - return true; - } -} diff --git a/kdeprint/lpdunix/klpdunixprinterimpl.h b/kdeprint/lpdunix/klpdunixprinterimpl.h deleted file mode 100644 index bbbda4104..000000000 --- a/kdeprint/lpdunix/klpdunixprinterimpl.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KLPDUNIXPRINTERIMPL_H -#define KLPDUNIXPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KProcess; - -class KLpdUnixPrinterImpl : public KPrinterImpl -{ -public: - KLpdUnixPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KLpdUnixPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); - -protected: - void initLpPrint(TQString&, KPrinter*); - void initLprPrint(TQString&, KPrinter*); - TQString executable(); -}; - -#endif diff --git a/kdeprint/lpdunix/kmlpdunixfactory.cpp b/kdeprint/lpdunix/kmlpdunixfactory.cpp deleted file mode 100644 index 70925a65c..000000000 --- a/kdeprint/lpdunix/kmlpdunixfactory.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpdunixmanager.h" -#include "kmlpdunixuimanager.h" -#include "klpdunixprinterimpl.h" - -#include <kgenericfactory.h> - -typedef K_TYPELIST_3( KMLpdUnixManager, KLpdUnixPrinterImpl, KMLpdUnixUiManager ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_lpdunix, KGenericFactory< Products > ) - - diff --git a/kdeprint/lpdunix/kmlpdunixmanager.cpp b/kdeprint/lpdunix/kmlpdunixmanager.cpp deleted file mode 100644 index afcd83b2a..000000000 --- a/kdeprint/lpdunix/kmlpdunixmanager.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpdunixmanager.h" -#include "kmfactory.h" -#include "kmprinter.h" - -#include <tqfile.h> -#include <tqdir.h> -#include <tqfileinfo.h> -#include <tqtextstream.h> -#include <tqregexp.h> -#include <klocale.h> -#include <kstandarddirs.h> -#include <kdebug.h> - -#include <stdlib.h> - -/***************** - * Utility class * - *****************/ -class KTextBuffer -{ -public: - KTextBuffer(TQIODevice *dev) : m_stream(dev) {} - bool eof() const { return (m_stream.eof() && m_linebuf.isEmpty()); } - TQString readLine(); - void unreadLine(const TQString& l) { m_linebuf = l; } -private: - TQTextStream m_stream; - TQString m_linebuf; -}; - -TQString KTextBuffer::readLine() -{ - TQString line; - if (!m_linebuf.isEmpty()) - { - line = m_linebuf; - m_linebuf = TQString::null; - } - else - line = m_stream.readLine(); - return line; -} - -/***************************** - * Various parsing functions * - *****************************/ - -// Extract a line from a KTextBuffer: -// '#' -> comments -// '\' -> line continue -// ':' or '|' -> line continue (LPRng) -// -// New entry is detected by a line which have first character different from -// '#', '|', ':'. The line is then put back in the IODevice. -TQString readLine(KTextBuffer& t) -{ - TQString line, buffer; - bool lineContinue(false); - - while (!t.eof()) - { - buffer = t.readLine().stripWhiteSpace(); - if (buffer.isEmpty() || buffer[0] == '#') - continue; - if (buffer[0] == '|' || buffer[0] == ':' || lineContinue || line.isEmpty()) - { - line.append(buffer); - if (line.right(1) == "\\") - { - line.truncate(line.length()-1); - line = line.stripWhiteSpace(); - lineContinue = true; - } - else - lineContinue = false; - } - else - { - t.unreadLine(buffer); - break; - } - } - return line; -} - -// extact an entry (printcap-like) -TQMap<TQString,TQString> readEntry(KTextBuffer& t) -{ - TQString line = readLine(t); - TQMap<TQString,TQString> entry; - - if (!line.isEmpty()) - { - TQStringList l = TQStringList::split(':',line,false); - if (l.count() > 0) - { - int p(-1); - if ((p=l[0].find('|')) != -1) - entry["printer-name"] = l[0].left(p); // only keep first name (discard aliases - else - entry["printer-name"] = l[0]; - for (uint i=1; i<l.count(); i++) - if ((p=l[i].find('=')) != -1) - entry[l[i].left(p).stripWhiteSpace()] = l[i].right(l[i].length()-p-1).stripWhiteSpace(); - else - entry[l[i].stripWhiteSpace()] = TQString::null; - } - } - return entry; -} - -// create basic printer from entry -KMPrinter* createPrinter(const TQMap<TQString,TQString>& entry) -{ - KMPrinter *printer = new KMPrinter(); - printer->setName(entry["printer-name"]); - printer->setPrinterName(entry["printer-name"]); - printer->setType(KMPrinter::Printer); - printer->setState(KMPrinter::Idle); - return printer; -} -KMPrinter* createPrinter(const TQString& prname) -{ - TQMap<TQString,TQString> map; - map["printer-name"] = prname; - return createPrinter(map); -} - -// this function support LPRng piping feature, it defaults to -// /etc/printcap in any other cases (basic support) -TQString getPrintcapFileName() -{ - // check if LPRng system - TQString printcap("/etc/printcap"); - TQFile f("/etc/lpd.conf"); - if (f.exists() && f.open(IO_ReadOnly)) - { - kdDebug() << "/etc/lpd.conf found: probably LPRng system" << endl; - TQTextStream t(&f); - TQString line; - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("printcap_path=")) - { - kdDebug() << "printcap_path entry found: " << line << endl; - TQString pcentry = line.mid(14).stripWhiteSpace(); - kdDebug() << "printcap_path value: " << pcentry << endl; - if (pcentry[0] == '|') - { // printcap through pipe - printcap = locateLocal("tmp","printcap"); - TQString cmd = TQString::tqfromLatin1("echo \"all\" | %1 > %2").arg(pcentry.mid(1)).arg(printcap); - kdDebug() << "printcap obtained through pipe" << endl << "executing: " << cmd << endl; - ::system(cmd.local8Bit()); - } - break; - } - } - } - kdDebug() << "printcap file returned: " << printcap << endl; - return printcap; -} - -// "/etc/printcap" file parsing (Linux/LPR) -void KMLpdUnixManager::parseEtcPrintcap() -{ - TQFile f(getPrintcapFileName()); - if (f.exists() && f.open(IO_ReadOnly)) - { - KTextBuffer t(TQT_TQIODEVICE(&f)); - TQMap<TQString,TQString> entry; - - while (!t.eof()) - { - entry = readEntry(t); - if (entry.isEmpty() || !entry.contains("printer-name") || entry.contains("server")) - continue; - if (entry["printer-name"] == "all") - { - if (entry.contains("all")) - { - // find separator - int p = entry["all"].find(TQRegExp("[^a-zA-Z0-9_\\s-]")); - if (p != -1) - { - TQChar c = entry["all"][p]; - TQStringList prs = TQStringList::split(c,entry["all"],false); - for (TQStringList::ConstIterator it=prs.begin(); it!=prs.end(); ++it) - { - KMPrinter *printer = ::createPrinter(*it); - printer->setDescription(i18n("Description unavailable")); - addPrinter(printer); - } - } - } - } - else - { - KMPrinter *printer = ::createPrinter(entry); - if (entry.contains("rm")) - printer->setDescription(i18n("Remote printer queue on %1").arg(entry["rm"])); - else - printer->setDescription(i18n("Local printer")); - addPrinter(printer); - } - } - } -} - -// helper function for NIS support in Solaris-2.6 (use "ypcat printers.conf.byname") -TQString getEtcPrintersConfName() -{ - TQString printersconf("/etc/printers.conf"); - if (!TQFile::exists(printersconf) && !KStandardDirs::findExe( "ypcat" ).isEmpty()) - { - // standard file not found, try NIS - printersconf = locateLocal("tmp","printers.conf"); - TQString cmd = TQString::tqfromLatin1("ypcat printers.conf.byname > %1").arg(printersconf); - kdDebug() << "printers.conf obtained from NIS server: " << cmd << endl; - ::system(TQFile::encodeName(cmd)); - } - return printersconf; -} - -// "/etc/printers.conf" file parsing (Solaris 2.6) -void KMLpdUnixManager::parseEtcPrintersConf() -{ - TQFile f(getEtcPrintersConfName()); - if (f.exists() && f.open(IO_ReadOnly)) - { - KTextBuffer t(TQT_TQIODEVICE(&f)); - TQMap<TQString,TQString> entry; - TQString default_printer; - - while (!t.eof()) - { - entry = readEntry(t); - if (entry.isEmpty() || !entry.contains("printer-name")) - continue; - TQString prname = entry["printer-name"]; - if (prname == "_default") - { - if (entry.contains("use")) - default_printer = entry["use"]; - } - else if (prname != "_all") - { - KMPrinter *printer = ::createPrinter(entry); - if (entry.contains("bsdaddr")) - { - TQStringList l = TQStringList::split(',',entry["bsdaddr"],false); - printer->setDescription(i18n("Remote printer queue on %1").arg(l[0])); - } - else - printer->setDescription(i18n("Local printer")); - addPrinter(printer); - } - } - - if (!default_printer.isEmpty()) - setSoftDefault(findPrinter(default_printer)); - } -} - -// "/etc/lp/printers/" directory parsing (Solaris non-2.6) -void KMLpdUnixManager::parseEtcLpPrinters() -{ - TQDir d("/etc/lp/printers"); - const TQFileInfoList *prlist = d.entryInfoList(TQDir::Dirs); - if (!prlist) - return; - - TQFileInfoListIterator it(*prlist); - for (;it.current();++it) - { - if (it.current()->fileName() == "." || it.current()->fileName() == "..") - continue; - TQFile f(it.current()->absFilePath() + "/configuration"); - if (f.exists() && f.open(IO_ReadOnly)) - { - KTextBuffer t(TQT_TQIODEVICE(&f)); - TQString line, remote; - while (!t.eof()) - { - line = readLine(t); - if (line.isEmpty()) continue; - if (line.startsWith("Remote:")) - { - TQStringList l = TQStringList::split(':',line,false); - if (l.count() > 1) remote = l[1]; - } - } - KMPrinter *printer = new KMPrinter; - printer->setName(it.current()->fileName()); - printer->setPrinterName(it.current()->fileName()); - printer->setType(KMPrinter::Printer); - printer->setState(KMPrinter::Idle); - if (!remote.isEmpty()) - printer->setDescription(i18n("Remote printer queue on %1").arg(remote)); - else - printer->setDescription(i18n("Local printer")); - addPrinter(printer); - } - } -} - -// "/etc/lp/member/" directory parsing (HP-UX) -void KMLpdUnixManager::parseEtcLpMember() -{ - TQDir d("/etc/lp/member"); - const TQFileInfoList *prlist = d.entryInfoList(TQDir::Files); - if (!prlist) - return; - - TQFileInfoListIterator it(*prlist); - for (;it.current();++it) - { - KMPrinter *printer = new KMPrinter; - printer->setName(it.current()->fileName()); - printer->setPrinterName(it.current()->fileName()); - printer->setType(KMPrinter::Printer); - printer->setState(KMPrinter::Idle); - printer->setDescription(i18n("Local printer")); - addPrinter(printer); - } -} - -// "/usr/spool/lp/interfaces/" directory parsing (IRIX 6.x) -void KMLpdUnixManager::parseSpoolInterface() -{ - TQDir d("/usr/spool/interfaces/lp"); - const TQFileInfoList *prlist = d.entryInfoList(TQDir::Files); - if (!prlist) - return; - - TQFileInfoListIterator it(*prlist); - for (;it.current();++it) - { - TQFile f(it.current()->absFilePath()); - if (f.exists() && f.open(IO_ReadOnly)) - { - KTextBuffer t(TQT_TQIODEVICE(&f)); - TQString line, remote; - - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("HOSTNAME")) - { - TQStringList l = TQStringList::split('=',line,false); - if (l.count() > 1) remote = l[1]; - } - } - - KMPrinter *printer = new KMPrinter; - printer->setName(it.current()->fileName()); - printer->setPrinterName(it.current()->fileName()); - printer->setType(KMPrinter::Printer); - printer->setState(KMPrinter::Idle); - if (!remote.isEmpty()) - printer->setDescription(i18n("Remote printer queue on %1").arg(remote)); - else - printer->setDescription(i18n("Local printer")); - addPrinter(printer); - } - } -} - -//********************************************************************************************************* - -KMLpdUnixManager::KMLpdUnixManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - m_loaded = false; -} - -void KMLpdUnixManager::listPrinters() -{ - // load only once, if already loaded, just keep them (remove discard flag) - if (!m_loaded) - { - parseEtcPrintcap(); - parseEtcPrintersConf(); - parseEtcLpPrinters(); - parseEtcLpMember(); - parseSpoolInterface(); - m_loaded = true; - } - else - discardAllPrinters(false); -} diff --git a/kdeprint/lpdunix/kmlpdunixmanager.h b/kdeprint/lpdunix/kmlpdunixmanager.h deleted file mode 100644 index 8716f8351..000000000 --- a/kdeprint/lpdunix/kmlpdunixmanager.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPDUNIXMANAGER_H -#define KMLPDUNIXMANAGER_H - -#include "kmmanager.h" - -class KMLpdUnixManager : public KMManager -{ -public: - KMLpdUnixManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - -protected: - void listPrinters(); - void parseEtcPrintcap(); - void parseEtcPrintersConf(); - void parseEtcLpPrinters(); - void parseEtcLpMember(); - void parseSpoolInterface(); - -private: - bool m_loaded; -}; - -#endif diff --git a/kdeprint/lpdunix/kmlpdunixuimanager.cpp b/kdeprint/lpdunix/kmlpdunixuimanager.cpp deleted file mode 100644 index 686dfecbb..000000000 --- a/kdeprint/lpdunix/kmlpdunixuimanager.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpdunixuimanager.h" -#include "kpqtpage.h" -#include "kprinterpropertydialog.h" - -#include <klocale.h> - -KMLpdUnixUiManager::KMLpdUnixUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMUiManager(parent,name) -{ - m_printdialogflags |= KMUiManager::PrintCommand; -} - -KMLpdUnixUiManager::~KMLpdUnixUiManager() -{ -} - -int KMLpdUnixUiManager::pluginPageCap() -{ - return KMUiManager::pluginPageCap(); - //return KMUiManager::NoAutoCollate; -} - -void KMLpdUnixUiManager::setupPrinterPropertyDialog( KPrinterPropertyDialog *dlg ) -{ - dlg->addPage( new KPQtPage( dlg, "QtPage" ) ); -} diff --git a/kdeprint/lpdunix/kmlpdunixuimanager.h b/kdeprint/lpdunix/kmlpdunixuimanager.h deleted file mode 100644 index 6e9e0d2ef..000000000 --- a/kdeprint/lpdunix/kmlpdunixuimanager.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPDUNIXUIMANAGER_H -#define KMLPDUNIXUIMANAGER_H - -#include "kmuimanager.h" - -class KMLpdUnixUiManager : public KMUiManager -{ -public: - KMLpdUnixUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMLpdUnixUiManager(); - - int pluginPageCap(); - void setupPrinterPropertyDialog( KPrinterPropertyDialog* ); -}; - -#endif diff --git a/kdeprint/lpdunix/lpdunix.print b/kdeprint/lpdunix/lpdunix.print deleted file mode 100644 index 8ef71a28d..000000000 --- a/kdeprint/lpdunix/lpdunix.print +++ /dev/null @@ -1,83 +0,0 @@ -[KDE Print Entry] -PrintSystem=lpdunix -Comment=Generic UNIX LPD Print System (default) -Comment[af]=Generies Unix Lpd Druk Stelsel (verstek) -Comment[ar]=نظام طباعة LPD العام ليونيكس (اÙتراضي) -Comment[az]=Ãœmumi UNIX LPD Sistemi (ön qurÄŸulu) -Comment[be]=Ð—Ð²Ñ‹Ñ‡Ð°Ð¹Ð½Ð°Ñ ÑÑ–ÑÑ‚Ñма друку UNIX LPD (прадвызначана) -Comment[bn]= সাধারণ ইউনিকà§à¦¸ à¦à¦²-পি-ডি মà§à¦¦à§à¦°à¦£ বà§à¦¯à¦¬à¦¸à§à¦¥à¦¾ (ডিফলà§à¦Ÿ) -Comment[bs]=GeneriÄki UNIX LPD sistem Å¡tampe (default) -Comment[ca]=Sistema d'impressió genèric LPD de Unix (predeterminat) -Comment[cs]=Obecný UNIXový tiskový systém LPD (implicitní) -Comment[csb]=Pierwòsznô uniksowô systema drëkù LPD (domëslny) -Comment[cy]=Cysawd Argraffu LPD Unix Cyffredinol (rhagosodiad) -Comment[da]=Generisk UNIX LPD-udskriftssystem (standard) -Comment[de]=UNIX-LPD-Drucksystem (Voreinstellung) -Comment[el]=Γενικό σÏστημα εκτÏπωσης UNIX LPD (Ï€ÏοκαθοÏισμένο) -Comment[eo]=Äœenerala Uniksa LPD-pressistemo (apriora) -Comment[es]=Sistema de impresión genérico LPD de Unix (predeterminado) -Comment[et]=Tavaline UNIX-i LPD trükkimise süsteem (vaikimisi) -Comment[eu]=UNIX LPD inprimatze-sistema generikoa (lehenetsia) -Comment[fa]=سیستم چاپUNIX LPD عمومی )پیش‌Ùرض( -Comment[fi]=Yleinen UNIX LPD-tulostusjärjestelmä (oletus) -Comment[fr]=Système d'impression LPD Unix générique (par défaut) -Comment[fy]=Algemiene UNIX LPD-ôfdruksysteem (standert) -Comment[ga]=Córas priontála cineálach LPD UNIX (réamhshocrú) -Comment[gl]=Sistema UNIX Xenérico de Impresión LPD (por omisión) -Comment[he]=מערכת ההדפסה הכללית של יוניקס LPD (ברירת מחדל) -Comment[hi]=जेनरिक UNIX LPD छपाई पदà¥à¤§à¤¤à¥à¤¤à¤¿ (ङिफालà¥à¤Ÿ) -Comment[hr]=GeneriÄki UNIX LPD sustav za ispis (zadani) -Comment[hu]=LPD (standard UNIX nyomtatási rendszer) -Comment[id]=Sistem Pencetakan UNIX Generik LPD (bawaan) -Comment[is]=Almennt UNIX LPD prentkerfi (sjálfgefið) -Comment[it]=Sistema di stampa UNIX LPD generico (predefinito) -Comment[ja]=一般的㪠UNIX LPD å°åˆ·ã‚·ã‚¹ãƒ†ãƒ  (標準) -Comment[ka]=UNIX LPD ბეჭდვის სისტემრ(ნáƒáƒ’ულისხმები) -Comment[kk]=UNIX жүйеÑіндегі әдетті LPD баÑып шғаруы -Comment[km]=ប្រពáŸáž“្ធ​បោះពុម្ព Generic UNIX LPD (លំនាំដើម) -Comment[ko]=보통 유닉스 LPD ì¸ì‡„ 시스템 (기본) -Comment[lb]=Allgemengt UNIX-LPD-Drécksystem (Virastellung) -Comment[lt]=Bendra UNIX LPD spausdinimo sistema (numatyta) -Comment[lv]=VispÄrÄ“ja UNIX LPD drukas sistÄ“ma (noklusÄ“ta) -Comment[mk]=Општ UNIX LPD ÑиÑтем за печатење (Ñтандардно) -Comment[mn]=UNIX-LPD-Ð¥ÑвлÑÑ… ÑиÑтем (Стандарт) -Comment[ms]=Sistem Cetak UNIX LPD Generik (default) -Comment[mt]=Sistema Ä¡enerika tal-ipprintjar Unix LPD (standard) -Comment[nb]=Vanlig UNIX LPD skriversystem (standard) -Comment[nds]=Dat normale LPD-Drucksysteem vun UNIX (Standard) -Comment[ne]=जेनेरिक UNIX LPD मà¥à¤¦à¥à¤°à¤£ पà¥à¤°à¤£à¤¾à¤²à¥€ (पूरà¥à¤µà¤¨à¤¿à¤°à¥à¤§à¤¾à¤°à¤¿à¤¤) -Comment[nl]=Generiek UNIX LPD-afdruksysteem (standaard) -Comment[nn]=Generelt UNIX LPD-utskriftssystem (standard) -Comment[nso]=System ya Kgatiso ya LPD ya UNIX ya Kakaretso (thuso ya tshoganetso) -Comment[pa]=ਆਮ UNIX LPD ਪà©à¨°à¨¿à©°à¨Ÿ ਸਿਸਟਮ(ਮੂਲ) -Comment[pl]=Pierwotny uniksowy system druku LPD (domyÅ›lny) -Comment[pt]=O sistema de impressão genérico do UNIX LPD (por omissão) -Comment[pt_BR]= LPD - Sistema Genérico do UNIX de Impressão (padrão) -Comment[ro]=Sistem generic de tipărire UNIX LPD (implicit) -Comment[ru]=СиÑтема печати UNIX LPD (по умолчанию) -Comment[rw]=Sisitemu yo Gucapa ya UNIX LPD Rusange (Mburabuzi) -Comment[se]=OppalaÅ¡ UNIX LPD Äálihanvuogádat (standárda) -Comment[sk]=Generický tlaÄový systém UNIX LPD (Å¡tandardné) -Comment[sl]=SploÅ¡ni tiskalniÅ¡ki sistem LDP za Unix (privzeto) -Comment[sq]=Sitemi Gjenrik Shtypi nga UNI LPD (e parazgjedhur) -Comment[sr]=Генерички UNIX LPD ÑиÑтем за штампање (предефиниÑано) -Comment[sr@Latn]=GeneriÄki UNIX LPD sistem za Å¡tampanje (predefinisano) -Comment[ss]=Umshini wekushicelela lobanti weLPD ku KDE (kwehluleka) -Comment[sv]=Generellt Unix LPD-skrivarsystem (standard) -Comment[ta]=பொத௠யà¯à®©à®¿à®•à¯à®¸à¯ LPD அசà¯à®šà¯à®¤à¯ தொகà¯à®¤à®¿ (à®®à¯à®©à¯ இரà¯à®¨à¯à®¤) -Comment[te]=సాధారణ à°¯à±à°¨à°¿à°•à±à°¸à± ఎలౠపి à°¡à°¿ à°ªà±à°°à°šà±à°°à°£ à°µà±à°¯à°µà°¸à±à°¥ (à°…à°ªà±à°°à°®à±‡à°¯à°‚) -Comment[tg]=СиÑтемаи чопи UNIX LPD (пешфарзӣ) -Comment[th]=ระบบà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œ LPD ของยูนิà¸à¸‹à¹Œ (ค่าปริยาย) -Comment[tr]=Genel UNIX LPD Yazdırma Sistemi (öntanımlı) -Comment[tt]=UNIX LPD Bastıru Sisteme (töp) -Comment[uk]=Загальна ÑиÑтема друку UNIX - LPD (типова) -Comment[uz]=Oddiy UNIX LPD bosib chiqarish tizimi (andoza) -Comment[uz@cyrillic]=Оддий UNIX LPD боÑиб чиқариш тизими (андоза) -Comment[ven]=Maitele au phirintha a UNIX (default) -Comment[vi]=Hệ thống in LPD UNIX giống loài (mặc định) -Comment[wa]=Sistinme d' imprimaedje djenerike LPD po UNIX (prémetou) -Comment[xh]=Indlela Yoshicilelo Ngokubanzi ye UNIX LPD (edaliweyo) -Comment[zh_CN]=通用 UNIX LPD 打å°ç³»ç»Ÿ(默认) -Comment[zh_HK]=通用 UNIX LPD 列å°ç³»çµ± (é è¨­) -Comment[zh_TW]=通用 UNIX LPD 列å°ç³»çµ±(é è¨­) -Comment[zu]=Isistimu Yokushicilela ye-UNIX LPD Kawonke wonke (yokwendalo) diff --git a/kdeprint/lpr/CMakeLists.txt b/kdeprint/lpr/CMakeLists.txt deleted file mode 100644 index c893411b1..000000000 --- a/kdeprint/lpr/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/tdeprint - ${CMAKE_SOURCE_DIR}/tdeprint/management -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - printcapentry.h lprhandler.h lprsettings.h - DESTINATION ${INCLUDE_INSTALL_DIR}/tdeprint/lpr ) - - -##### other data ################################ - -install( FILES lpr.print DESTINATION ${DATA_INSTALL_DIR}/tdeprint/plugins ) -install( FILES apsdriver1 apsdriver2 lprngtooldriver1 DESTINATION ${DATA_INSTALL_DIR}/tdeprint ) - - -#### tdeprint_lpr ############################### - -set( target tdeprint_lpr ) - -set( ${target}_SRCS - printcapreader.cpp lprhandler.cpp matichandler.cpp - klprfactory.cpp kmlprmanager.cpp kmlpruimanager.cpp - lpchelper.cpp lpqhelper.cpp kmlprjobmanager.cpp - matichelper.cpp klprprinterimpl.cpp printcapentry.cpp - lprsettings.cpp kmconfiglpr.cpp apshandler.cpp - lprngtoolhandler.cpp editentrydialog.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint_management-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) - - -#### make_driver_db_lpr ######################### - -set( target make_driver_db_lpr ) - -set( ${target}_SRCS - make_driver_db_lpr.c -) - -tde_add_executable( ${target} - SOURCES ${${target}_SRCS} - LINK driverparse-static tdefakes-shared ${DL_LIBRARIES} - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/kdeprint/lpr/Makefile.am b/kdeprint/lpr/Makefile.am deleted file mode 100644 index a9039888f..000000000 --- a/kdeprint/lpr/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/tdeprint -I$(top_srcdir)/tdeprint/management $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_lpr.la - -tdeprint_lpr_la_SOURCES = printcapreader.cpp lprhandler.cpp \ - matichandler.cpp klprfactory.cpp kmlprmanager.cpp \ - kmlpruimanager.cpp lpchelper.cpp lpqhelper.cpp \ - kmlprjobmanager.cpp matichelper.cpp \ - klprprinterimpl.cpp printcapentry.cpp \ - lprsettings.cpp kmconfiglpr.cpp apshandler.cpp \ - lprngtoolhandler.cpp \ - editentrydialog.cpp -tdeprint_lpr_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_lpr_la_LIBADD = $(top_builddir)/tdeprint/management/libtdeprint_management.la \ - $(LIB_QT) $(LIB_KDEPRINT) $(LIB_KDEUI) $(LIB_KDECORE) -tdeprint_lpr_la_METASOURCES = AUTO - -noinst_HEADERS = printcapreader.h \ - matichandler.h kmlprmanager.h \ - kmlpruimanager.h lpchelper.h lpqhelper.h \ - kmlprjobmanager.h matichelper.h klprprinterimpl.h \ - kmconfiglpr.h apshandler.h \ - lprngtoolhandler.h \ - editentrydialog.h - -tdeprintlpr_HEADERS = printcapentry.h lprhandler.h lprsettings.h -tdeprintlprdir = $(includedir)/tdeprint/lpr - -bin_PROGRAMS = make_driver_db_lpr -make_driver_db_lpr_SOURCES = make_driver_db_lpr.c -make_driver_db_lpr_LDFLAGS = $(all_libraries) -make_driver_db_lpr_LDADD = $(top_builddir)/tdecore/libtdefakes.la ../libdriverparse.a $(LIBDL) - -entry_DATA = lpr.print -entrydir = $(kde_datadir)/tdeprint/plugins - -miscdata_DATA = apsdriver1 apsdriver2 lprngtooldriver1 -miscdatadir = $(kde_datadir)/tdeprint diff --git a/kdeprint/lpr/apsdriver1 b/kdeprint/lpr/apsdriver1 deleted file mode 100644 index fa6bbde0e..000000000 --- a/kdeprint/lpr/apsdriver1 +++ /dev/null @@ -1,84 +0,0 @@ -GROUP|general|General -OPTION|PAPERSIZE|Page Size -CHOICE|a3|A3 -CHOICE|a4|A4 -CHOICE|legal|US Legal -CHOICE|letter|US Letter -CHOICE|ledger|Ledger -CHOICE|tabloid|Tabloid -DEFAULT|a4 -OPTION|COLOR|Color Mode -CHOICE|full|Color -CHOICE|gray|Grayscale -CHOICE|mono|Monochrome -DEFAULT|full -OPTION|QUALITY|Print Quality -CHOICE|draft|Draft -CHOICE|low|Low -CHOICE|medium|Medium -CHOICE|high|High -CHOICE|photo|Photo -DEFAULT|medium -OPTION|RESOLUTION|Print Resolution -CHOICE|150x150|150 DPI -CHOICE|180x180|180 DPI -CHOICE|300x300|300 DPI -CHOICE|360x180|360x180 DPI -CHOICE|360x360|360 DPI -CHOICE|600x600|600 DPI -CHOICE|720x720|720 DPI -CHOICE|1200x1200|1200 DPI -DEFAULT|300x300 -OPTION|METHOD|Print Method -CHOICE|auto|Automatic file conversion -CHOICE|ascii|Treat everything as text -CHOICE|raw|Pass-through mode -DEFAULT|auto -ENDGROUP| -GROUP|advanced|Advanced Settings -GROUP|paper|Paper Settings -OPTION|MEDIA|paper Type -CHOICE|plain|Plain paper -CHOICE|coated|Coated (InkJet) paper -CHOICE|glossy|Glossy paper -CHOICE|premium|Premium (Photo) paper -CHOICE|trans|Transparencies -CHOICE|(empty)|Default printer setting -DEFAULT|(empty) -OPTION|PAPERTRAY|Input Slot -CHOICE|tray0|Tray 0 -CHOICE|tray1|Tray 1 -CHOICE|tray2|Tray 2 -CHOICE|tray3|Tray 3 -CHOICE|tray4|Tray 4 -CHOICE|tray5|Tray 5 -CHOICE|(empty)|Default printer setting -DEFAULT|(empty) -OPTION|DUPLEX|Duplex Printing|BOOLEAN -CHOICE|true|Enabled -CHOICE|false|Disabled -DEFAULT|false -OPTION|BINDING|Paper Binding Edge -CHOICE|short|Short edge -CHOICE|long|Long edge -CHOICE|(empty)|Default printer setting -DEFAULT|(empty) -ENDGROUP| -GROUP|text|File Conversion Settings -OPTION|ASCII_HEADER|Text Header|BOOLEAN -CHOICE|true|Enabled -CHOICE|false|Disabled -DEFAULT|false -OPTION|ASCII_BORDER|Text Border|BOOLEAN -CHOICE|true|Enabled -CHOICE|false|Disabled -DEFAULT|false -OPTION|PRINT_DVI|DVI file converter|STRING -ENDGROUP| -GROUP|gs|Ghostscript Settings -OPTION|GS_FEATURES|Ghostscript options|STRING -OPTION|PS_INIT|Initialisation file|STRING -OPTION|PS_EXIT|Cleanup file|STRING -OPTION|POST_FILTER_OPTS|Post-Ghostscript filter options|STRING -ENDGROUP| -ENDGROUP| diff --git a/kdeprint/lpr/apsdriver2 b/kdeprint/lpr/apsdriver2 deleted file mode 100644 index 69d355f6c..000000000 --- a/kdeprint/lpr/apsdriver2 +++ /dev/null @@ -1,83 +0,0 @@ -GROUP|general|General -OPTION|PageSize|Page Size -CHOICE|a3|A3 -CHOICE|a4|A4 -CHOICE|legal|US Legal -CHOICE|letter|US Letter -CHOICE|ledger|Ledger -CHOICE|tabloid|Tabloid -DEFAULT|a4 -OPTION|MEDIA|Paper Type -CHOICE|plain|Plain paper -CHOICE|coated|Coated (InkJet) paper -CHOICE|glossy|Glossy paper -CHOICE|premium|Premium (Photo) paper -CHOICE|trans|Transparencies -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|PAPERTRAY|Input Tray -CHOICE|tray0|Tray 0 -CHOICE|tray1|Tray 1 -CHOICE|tray2|Tray 2 -CHOICE|tray3|Tray 3 -CHOICE|tray4|Tray 4 -CHOICE|tray5|Tray 5 -CHOICE|(empty)|Default setting -DEFAULT|(empty) -ENDGROUP| -GROUP|others|Others -OPTION|COLOR|Color Mode -CHOICE|color|Color -CHOICE|gray|Grayscale -CHOICE|mono|Monochrome -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|DUPLEX|Duplex Printing -CHOICE|duplex|Enabled -CHOICE|simplex|Disabled -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|BINDING|Paper Binding Edge -CHOICE|shortbind|Short edge -CHOICE|longbind|Long edge -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|QUALITY|Printing Quality -CHOICE|draft|Draft -CHOICE|low|Low -CHOICE|medium|Medium -CHOICE|high|High -CHOICE|photo|Photo -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|PS_NUP|Pages per Sheet -CHOICE|1pps|1 -CHOICE|2pps|2 -CHOICE|4pps|4 -CHOICE|8pps|8 -DEFAULT|1pps -OPTION|SWEEP|Communication Type -CHOICE|uni|Unidirectional -CHOICE|bi|Bidirectional -CHOICE|(empty)|Default setting -DEFAULT|(empty) -ENDGROUP| -GROUP|text|Text Printing -OPTION|ASCII_FILTER|Text Converter -CHOICE|a2ps|a2ps -CHOICE|mpage|mpage -CHOICE|enscript|enscript -CHOICE|recode|recode -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|ASCII_HEADER|Header -CHOICE|header|Enabled -CHOICE|noheader|Disabled -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|ASCII_BORDER|Border -CHOICE|border|Enabled -CHOICE|noborder|Disabled -CHOICE|(empty)|Default setting -DEFAULT|(empty) -ENDGROUP| diff --git a/kdeprint/lpr/apshandler.cpp b/kdeprint/lpr/apshandler.cpp deleted file mode 100644 index d4107d7c7..000000000 --- a/kdeprint/lpr/apshandler.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "apshandler.h" -#include "driver.h" -#include "printcapentry.h" -#include "kmprinter.h" -#include "lprsettings.h" -#include "kmmanager.h" -#include "util.h" -#include "kprinter.h" - -#include <tqfile.h> -#include <tqdir.h> -#include <tqtextstream.h> -#include <tqvaluestack.h> -#include <kstandarddirs.h> -#include <klocale.h> -#include <kdebug.h> - -#include <sys/types.h> -#include <sys/stat.h> - -ApsHandler::ApsHandler(KMManager *mgr) -: LprHandler("apsfilter", mgr) -{ - m_counter = 1; -} - -bool ApsHandler::validate(PrintcapEntry *entry) -{ - return (entry->field("if").right(9) == "apsfilter"); -} - -KMPrinter* ApsHandler::createPrinter(PrintcapEntry *entry) -{ - entry->comment = TQString::tqfromLatin1("# APS%1_BEGIN:printer%2").arg(m_counter).arg(m_counter); - entry->postcomment = TQString::tqfromLatin1("# APS%1_END - don't delete this").arg(m_counter); - m_counter++; - return LprHandler::createPrinter(entry); -} - -bool ApsHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool shortmode) -{ - if (LprHandler::completePrinter(prt, entry, shortmode)) - { - if (!shortmode) - { - TQMap<TQString,TQString> opts = loadResources(entry); - if (opts.contains("PRINTER")) - { - prt->setDescription(i18n("APS Driver (%1)").arg(opts["PRINTER"])); - prt->setDriverInfo(prt->description()); - } - } - if (prt->device().isEmpty()) - { - TQString prot; - TQString smbname(sysconfDir() + "/" + prt->printerName() + "/smbclient.conf"); - TQString ncpname(sysconfDir() + "/" + prt->printerName() + "/netware.conf"); - if (TQFile::exists(smbname)) - { - TQMap<TQString,TQString> opts = loadVarFile(smbname); - if (opts.count() == 0) - prt->setDevice("smb://<unknown>/<unknown>"); - else - { - prt->setDevice(buildSmbURI( - opts[ "SMB_WORKGROUP" ], - opts[ "SMB_SERVER" ], - opts[ "SMB_PRINTER" ], - opts[ "SMB_USER" ], - opts[ "SMB_PASSWD" ] ) ); - } - prot = "smb"; - } - else if (TQFile::exists(ncpname)) - { - TQMap<TQString,TQString> opts = loadVarFile(ncpname); - if (opts.count() == 0) - prt->setDevice("ncp://<unknown>/<unknown>"); - else - { - TQString uri = buildSmbURI( - TQString::null, - opts[ "NCP_SERVER" ], - opts[ "NCP_PRINTER" ], - opts[ "NCP_USER" ], - opts[ "NCP_PASSWD" ] ); - uri.replace( 0, 3, "ncp" ); - prt->setDevice(uri); - } - prot = "ncp"; - } - if (!prt->device().isEmpty()) - prt->setLocation(i18n("Network printer (%1)").arg(prot)); - } - return true; - } - return false; -} - -TQString ApsHandler::sysconfDir() -{ - return TQFile::encodeName("/etc/apsfilter"); -} - -TQString ApsHandler::shareDir() -{ - return driverDirectory(); -} - -TQString ApsHandler::driverDirInternal() -{ - return locateDir("apsfilter/setup", "/usr/share:/usr/local/share:/opt/share"); -} - -TQMap<TQString,TQString> ApsHandler::loadResources(PrintcapEntry *entry) -{ - return loadVarFile(sysconfDir() + "/" + (entry ? entry->name : TQString::null) + "/apsfilterrc"); -} - -TQMap<TQString,TQString> ApsHandler::loadVarFile(const TQString& filename) -{ - TQMap<TQString,TQString> opts; - TQFile f(filename); - if (f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - int p(-1); - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty() || line[0] == '#' || (p = line.find('=')) == -1) - continue; - TQString variable = line.left(p).stripWhiteSpace(); - TQString value = line.mid(p+1).stripWhiteSpace(); - if (!value.isEmpty() && value[0] == '\'') - value = value.mid(1, value.length()-2); - opts[variable] = value; - } - } - return opts; -} - -DrMain* ApsHandler::loadDriver(KMPrinter *prt, PrintcapEntry *entry, bool config) -{ - DrMain *driver = loadApsDriver(config); - if (driver /* && config */ ) // Load resources in all case, to get the correct page size - { - TQMap<TQString,TQString> opts = loadResources(entry); - if ( !config && opts.contains( "PAPERSIZE" ) ) - { - // this is needed to keep applications informed - // about the current selected page size - opts[ "PageSize" ] = opts[ "PAPERSIZE" ]; - - // default page size needs to be set to the actual - // value of the printer driver, otherwise it's blocked - // to A4 - DrBase *opt = driver->findOption( "PageSize" ); - if ( opt ) - opt->set( "default", opts[ "PageSize" ] ); - } - driver->setOptions(opts); - driver->set("gsdriver", opts["PRINTER"]); - } - return driver; -} - -DrMain* ApsHandler::loadDbDriver(const TQString& s) -{ - int p = s.find('/'); - DrMain *driver = loadApsDriver(true); - if (driver) - driver->set("gsdriver", s.mid(p+1)); - return driver; -} - -DrMain* ApsHandler::loadApsDriver(bool config) -{ - DrMain *driver = loadToolDriver(locate("data", (config ? "tdeprint/apsdriver1" : "tdeprint/apsdriver2"))); - if (driver) - driver->set("text", "APS Common Driver"); - return driver; -} - -void ApsHandler::reset() -{ - m_counter = 1; -} - -PrintcapEntry* ApsHandler::createEntry(KMPrinter *prt) -{ - TQString prot = prt->deviceProtocol(); - if (prot != "parallel" && prot != "lpd" && prot != "smb" && prot != "ncp") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - TQString path = sysconfDir() + "/" + prt->printerName(); - if (!KStandardDirs::makeDir(path, 0755)) - { - manager()->setErrorMsg(i18n("Unable to create directory %1.").arg(path)); - return NULL; - } - if (prot == "smb" || prot == "ncp") - { - // either "smb" or "ncp" - TQFile::remove(path + "/smbclient.conf"); - TQFile::remove(path + "/netware.conf"); - TQFile f; - if (prot == "smb") - { - f.setName(path + "/smbclient.conf"); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - TQString work, server, printer, user, passwd; - if ( splitSmbURI( prt->device(), work, server, printer, user, passwd ) ) - { - if (work.isEmpty()) - { - manager()->setErrorMsg(i18n("Missing element: %1.").arg("Workgroup")); - return NULL; - } - t << "SMB_SERVER='" << server << "'" << endl; - t << "SMB_PRINTER='" << printer << "'" << endl; - t << "SMB_IP=''" << endl; - t << "SMB_WORKGROUP='" << work << "'" << endl; - t << "SMB_BUFFER=1400" << endl; - t << "SMB_FLAGS='-N'" << endl; - if (!user.isEmpty()) - { - t << "SMB_USER='" << user << "'" << endl; - t << "SMB_PASSWD='" << passwd << "'" << endl; - } - } - else - { - manager()->setErrorMsg( i18n( "Invalid printer backend specification: %1" ).arg( prt->device() ) ); - return NULL; - } - } - else - { - manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); - return NULL; - } - } - else - { - f.setName(path + "/netware.conf"); - if (f.open(IO_WriteOnly)) - { - TQString work, server, printer, user, passwd; - TQString uri = prt->device(); - uri.replace( 0, 3, "smb" ); - if ( splitSmbURI( uri, work, server, printer, user, passwd ) ) - { - TQTextStream t(&f); - t << "NCP_SERVER='" << server << "'" << endl; - t << "NCP_PRINTER='" << printer << "'" << endl; - if (!user.isEmpty()) - { - t << "NCP_USER='" << user << "'" << endl; - t << "NCP_PASSWD='" << passwd << "'" << endl; - } - } - else - { - manager()->setErrorMsg( i18n( "Invalid printer backend specification: %1" ).arg( prt->device() ) ); - return NULL; - } - } - else - { - manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); - return NULL; - } - } - // change file permissions - ::chmod(TQFile::encodeName(f.name()).data(), S_IRUSR|S_IWUSR); - } - PrintcapEntry *entry = LprHandler::createEntry(prt); - if (!entry) - { - entry = new PrintcapEntry; - entry->addField("lp", Field::String, "/dev/null"); - } - TQString sd = LprSettings::self()->baseSpoolDir() + "/" + prt->printerName(); - entry->addField("af", Field::String, sd + "/acct"); - entry->addField("lf", Field::String, sd + "/log"); - entry->addField("if", Field::String, sysconfDir() + "/basedir/bin/apsfilter"); - entry->comment = TQString::tqfromLatin1("# APS%1_BEGIN:printer%2").arg(m_counter).arg(m_counter); - entry->postcomment = TQString::tqfromLatin1("# APS%1_END").arg(m_counter); - m_counter++; - return entry; -} - -bool ApsHandler::savePrinterDriver(KMPrinter *prt, PrintcapEntry *entry, DrMain *driver, bool*) -{ - if (driver->get("gsdriver").isEmpty()) - { - manager()->setErrorMsg(i18n("The APS driver is not defined.")); - return false; - } - TQFile f(sysconfDir() + "/" + prt->printerName() + "/apsfilterrc"); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - t << "# File generated by KDEPrint" << endl; - t << "PRINTER='" << driver->get("gsdriver") << "'" << endl; - TQValueStack<DrGroup*> stack; - stack.push(driver); - while (stack.count() > 0) - { - DrGroup *grp = stack.pop(); - TQPtrListIterator<DrGroup> git(grp->groups()); - for (; git.current(); ++git) - stack.push(git.current()); - TQPtrListIterator<DrBase> oit(grp->options()); - TQString value; - for (; oit.current(); ++oit) - { - value = oit.current()->valueText(); - switch (oit.current()->type()) - { - case DrBase::Boolean: - if (value == "true") - t << oit.current()->name() << "='" << value << "'" << endl; - break; - case DrBase::List: - if (value != "(empty)") - t << oit.current()->name() << "='" << value << "'" << endl; - break; - case DrBase::String: - if (!value.isEmpty()) - t << oit.current()->name() << "='" << value << "'" << endl; - break; - default: - break; - } - } - } - return true; - } - else - { - manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); - return false; - } -} - -bool ApsHandler::removePrinter(KMPrinter*, PrintcapEntry *entry) -{ - TQString path(sysconfDir() + "/" + entry->name); - TQFile::remove(path + "/smbclient.conf"); - TQFile::remove(path + "/netware.conf"); - TQFile::remove(path + "/apsfilterrc"); - if (!TQDir(path).rmdir(path)) - { - manager()->setErrorMsg(i18n("Unable to remove directory %1.").arg(path)); - return false; - } - return true; -} - -TQString ApsHandler::printOptions(KPrinter *printer) -{ - TQString optstr; - TQMap<TQString,TQString> opts = printer->options(); - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key().startsWith( "app-" )) - continue; - optstr.append((*it)).append(":"); - } - if (!optstr.isEmpty()) - { - optstr = optstr.left(optstr.length()-1); - if (LprSettings::self()->mode() == LprSettings::LPR) - optstr.prepend("-C '").append("'"); - else - optstr.prepend("-Z '").append("'"); - } - return optstr; -} diff --git a/kdeprint/lpr/apshandler.h b/kdeprint/lpr/apshandler.h deleted file mode 100644 index db213d194..000000000 --- a/kdeprint/lpr/apshandler.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 APSHANDLER_H -#define APSHANDLER_H - -#include "lprhandler.h" - -#include <tqmap.h> - -class ApsHandler : public LprHandler -{ -public: - ApsHandler(KMManager*); - - bool validate(PrintcapEntry*); - KMPrinter* createPrinter(PrintcapEntry*); - bool completePrinter(KMPrinter*, PrintcapEntry*, bool = true); - DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - DrMain* loadDbDriver(const TQString&); - void reset(); - PrintcapEntry* createEntry(KMPrinter*); - bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - bool removePrinter(KMPrinter*, PrintcapEntry*); - TQString printOptions(KPrinter*); - -protected: - TQString driverDirInternal(); - -private: - TQMap<TQString,TQString> loadResources(PrintcapEntry*); - TQMap<TQString,TQString> loadVarFile(const TQString&); - TQString sysconfDir(); - TQString shareDir(); - DrMain* loadApsDriver(bool = false); - -private: - int m_counter; -}; - -#endif diff --git a/kdeprint/lpr/editentrydialog.cpp b/kdeprint/lpr/editentrydialog.cpp deleted file mode 100644 index 6c4ecc30c..000000000 --- a/kdeprint/lpr/editentrydialog.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "editentrydialog.h" - -#include <tqlineedit.h> -#include <tqcheckbox.h> -#include <tqspinbox.h> -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqheader.h> -#include <klistview.h> -#include <tqlayout.h> -#include <tqwidgetstack.h> -#include <klocale.h> -#include <kiconloader.h> - -EditEntryDialog::EditEntryDialog(PrintcapEntry *entry, TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, TQString::null, Ok|Cancel) -{ - TQWidget *w = new TQWidget(this); - setMainWidget(w); - - TQLabel *lab0 = new TQLabel(i18n("Aliases:"), w); - m_aliases = new TQLineEdit(w); - m_view = new KListView(w); - m_view->addColumn(""); - m_view->header()->hide(); - m_type = new TQComboBox(w); - m_type->insertItem(i18n("String")); - m_type->insertItem(i18n("Number")); - m_type->insertItem(i18n("Boolean")); - m_stack = new TQWidgetStack(w); - m_boolean = new TQCheckBox(i18n("Enabled"), m_stack); - m_string = new TQLineEdit(m_stack); - m_number = new TQSpinBox(0, 9999, 1, m_stack); - m_stack->addWidget(m_string, 0); - m_stack->addWidget(m_boolean, 2); - m_stack->addWidget(m_number, 1); - m_name = new TQLineEdit(w); - - TQVBoxLayout *l0 = new TQVBoxLayout(w, 0, 10); - TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 10); - TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 5); - l0->addLayout(l1); - l1->addWidget(lab0); - l1->addWidget(m_aliases); - l0->addWidget(m_view); - l0->addLayout(l2); - l2->addWidget(m_name, 0); - l2->addWidget(m_type, 0); - l2->addWidget(m_stack, 1); - - if (entry) - { - setCaption(i18n("Printcap Entry: %1").arg(entry->name)); - m_fields = entry->fields; - m_aliases->setText(entry->aliases.join("|")); - TQListViewItem *root = new TQListViewItem(m_view, entry->name), *item = 0; - root->setSelectable(false); - root->setOpen(true); - root->setPixmap(0, SmallIcon("fileprint")); - for (TQMap<TQString,Field>::ConstIterator it=m_fields.begin(); it!=m_fields.end(); ++it) - item = new TQListViewItem(root, item, (*it).toString(), it.key()); - } - - m_block = true; - enableButton(Ok, false); - slotItemSelected(NULL); - slotTypeChanged(0); - m_block = false; - - connect(m_view, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotItemSelected(TQListViewItem*))); - connect(m_string, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_boolean, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotChanged())); - connect(m_number, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotChanged())); - connect(m_type, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged(int))); - connect(m_name, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - - resize(500,400); -} - -Field EditEntryDialog::createField() -{ - Field f; - f.name = m_name->text(); - f.type = (Field::Type)(m_type->currentItem()); - switch (f.type) - { - case Field::String: f.value = m_string->text(); break; - case Field::Integer: f.value = m_number->cleanText(); break; - case Field::Boolean: f.value = (m_boolean->isChecked() ? "1" : "0"); break; - } - return f; -} - -void EditEntryDialog::slotChanged() -{ - if (!m_block && m_view->currentItem()) - { - Field f = createField(); - if (f.name != m_current) - m_fields.remove(m_current); - m_fields[f.name] = f; - m_view->currentItem()->setText(0, f.toString()); - } -} - -void EditEntryDialog::slotItemSelected(TQListViewItem *item) -{ - m_stack->setEnabled(item); - m_name->setEnabled(item); - m_type->setEnabled(item); - if (item) - { - m_block = true; - m_current = item->text(1); - Field f = m_fields[m_current]; - m_name->setText(f.name); - m_type->setCurrentItem(f.type); - slotTypeChanged(f.type); - m_string->setText(f.value); - m_number->setValue(f.value.toInt()); - m_boolean->setChecked(f.value.toInt() == 1); - m_block = false; - } -} - -void EditEntryDialog::fillEntry(PrintcapEntry *entry) -{ - entry->aliases = TQStringList::split('|', m_aliases->text(), false); - entry->fields = m_fields; -} - -void EditEntryDialog::slotTypeChanged(int ID) -{ - m_stack->raiseWidget(ID); - slotChanged(); -} - -#include "editentrydialog.moc" diff --git a/kdeprint/lpr/editentrydialog.h b/kdeprint/lpr/editentrydialog.h deleted file mode 100644 index f4359dd89..000000000 --- a/kdeprint/lpr/editentrydialog.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 EDITENTRYDIALOG_H -#define EDITENTRYDIALOG_H - -#include <kdialogbase.h> -#include "printcapentry.h" - -class TQLineEdit; -class TQCheckBox; -class TQSpinBox; -class TQComboBox; -class TQListView; -class TQListviewItem; -class TQWidgetStack; - -class EditEntryDialog : public KDialogBase -{ - Q_OBJECT -public: - EditEntryDialog(PrintcapEntry *entry, TQWidget *parent = 0, const char *name = 0); - - void fillEntry(PrintcapEntry *entry); - -protected slots: - void slotItemSelected(TQListViewItem*); - void slotChanged(); - void slotTypeChanged(int); - -protected: - Field createField(); - -private: - TQMap<TQString,Field> m_fields; - TQLineEdit *m_name, *m_string, *m_aliases; - TQCheckBox *m_boolean; - TQComboBox *m_type; - TQSpinBox *m_number; - TQListView *m_view; - TQWidgetStack *m_stack; - TQString m_current; - bool m_block; -}; - -#endif diff --git a/kdeprint/lpr/klprfactory.cpp b/kdeprint/lpr/klprfactory.cpp deleted file mode 100644 index 4764dfc6a..000000000 --- a/kdeprint/lpr/klprfactory.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlprmanager.h" -#include "kmlpruimanager.h" -#include "kmlprjobmanager.h" -#include "klprprinterimpl.h" - -#include <kgenericfactory.h> - -typedef K_TYPELIST_4( KMLprManager, KMLprUiManager, KMLprJobManager, KLprPrinterImpl ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_lpr, KGenericFactory< Products > ) - diff --git a/kdeprint/lpr/klprprinterimpl.cpp b/kdeprint/lpr/klprprinterimpl.cpp deleted file mode 100644 index 70356f23c..000000000 --- a/kdeprint/lpr/klprprinterimpl.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "klprprinterimpl.h" -#include "kprinter.h" -#include "kmlprmanager.h" - -#include <kstandarddirs.h> -#include <tqfile.h> -#include <stdlib.h> - -KLprPrinterImpl::KLprPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ - m_exepath = KStandardDirs::findExe("lpr"); -} - -KLprPrinterImpl::~KLprPrinterImpl() -{ -} - -bool KLprPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - // check printer object - if (!printer || m_exepath.isEmpty()) - return false; - - cmd = TQString::tqfromLatin1("%1 -P %1 '-#%1'").arg(m_exepath).arg(quote(printer->printerName())).arg( printer->numCopies() ); - QString opts = static_cast<KMLprManager*>(KMManager::self())->printOptions(printer); - if (!opts.isEmpty()) - cmd += (" " + opts); - return true; -} - -void KLprPrinterImpl::broadcastOption(const TQString& key, const TQString& value) -{ - KPrinterImpl::broadcastOption(key,value); - if (key == "kde-pagesize") - { - QString pagename = TQString::tqfromLatin1(pageSizeToPageName((KPrinter::PageSize)value.toInt())); - KPrinterImpl::broadcastOption("PageSize",pagename); - } -} diff --git a/kdeprint/lpr/klprprinterimpl.h b/kdeprint/lpr/klprprinterimpl.h deleted file mode 100644 index 508173f1d..000000000 --- a/kdeprint/lpr/klprprinterimpl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KLPRPRINTERIMPL_H -#define KLPRPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KLprPrinterImpl : public KPrinterImpl -{ -public: - KLprPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KLprPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); - void broadcastOption(const TQString& key, const TQString& value); - -private: - QString m_exepath; -}; - -#endif diff --git a/kdeprint/lpr/kmconfiglpr.cpp b/kdeprint/lpr/kmconfiglpr.cpp deleted file mode 100644 index f43a8da2d..000000000 --- a/kdeprint/lpr/kmconfiglpr.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfiglpr.h" -#include "lprsettings.h" - -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqgroupbox.h> -#include <klocale.h> -#include <kconfig.h> - -KMConfigLpr::KMConfigLpr(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Spooler")); - setPageHeader(i18n("Spooler Settings")); - setPagePixmap("gear"); - - TQGroupBox *m_modebox = new TQGroupBox(1, Qt::Vertical, i18n("Spooler"), this); - - m_mode = new TQComboBox(m_modebox); - m_mode->insertItem("LPR (BSD compatible)"); - m_mode->insertItem("LPRng"); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 5, 10); - l0->addWidget(m_modebox); - l0->addStretch(1); -} - -void KMConfigLpr::loadConfig(KConfig*) -{ - m_mode->setCurrentItem(LprSettings::self()->mode()); -} - -void KMConfigLpr::saveConfig(KConfig *conf) -{ - LprSettings::self()->setMode((LprSettings::Mode)(m_mode->currentItem())); - - TQString modestr; - switch (m_mode->currentItem()) - { - default: - case 0: modestr = "LPR"; break; - case 1: modestr = "LPRng"; break; - } - conf->setGroup("LPR"); - conf->writeEntry("Mode", modestr); -} diff --git a/kdeprint/lpr/kmconfiglpr.h b/kdeprint/lpr/kmconfiglpr.h deleted file mode 100644 index 7f3d50857..000000000 --- a/kdeprint/lpr/kmconfiglpr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGLPR_H -#define KMCONFIGLPR_H - -#include "kmconfigpage.h" - -class TQComboBox; - -class KMConfigLpr : public KMConfigPage -{ -public: - KMConfigLpr(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - TQComboBox *m_mode; -}; - -#endif diff --git a/kdeprint/lpr/kmlprjobmanager.cpp b/kdeprint/lpr/kmlprjobmanager.cpp deleted file mode 100644 index 851663664..000000000 --- a/kdeprint/lpr/kmlprjobmanager.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlprjobmanager.h" -#include "kmlprmanager.h" -#include "lpqhelper.h" -#include "lpchelper.h" -#include "kmjob.h" -#include "lprsettings.h" - -#include <tqptrlist.h> -#include <klocale.h> - -KMLprJobManager::KMLprJobManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMJobManager(parent, name) -{ - m_lpqhelper = new LpqHelper(this, "LpqHelper"); -} - -bool KMLprJobManager::listJobs(const TQString& prname, JobType, int limit) -{ - TQPtrList<KMJob> jobList; - jobList.setAutoDelete(false); - m_lpqhelper->listJobs(jobList, prname, limit); - TQPtrListIterator<KMJob> it(jobList); - for (; it.current(); ++it) - addJob(it.current()); - return false; -} - -LpcHelper* KMLprJobManager::lpcHelper() -{ - return static_cast<KMLprManager*>(KMManager::self())->lpcHelper(); -} - -int KMLprJobManager::actions() -{ - if (LprSettings::self()->mode() == LprSettings::LPR) - return KMJob::Remove; - else - // some additional actions to be added here - return (KMJob::Remove | KMJob::Hold | KMJob::Resume); -} - -bool KMLprJobManager::sendCommandSystemJob(const TQPtrList<KMJob>& jobs, int action, const TQString& arg) -{ - TQString msg; - TQPtrListIterator<KMJob> it(jobs); - bool status(true); - LpcHelper *helper = lpcHelper(); - - for (; it.current() && status; ++it) - { - switch (action) - { - case KMJob::Remove: - status = helper->removeJob(it.current(), msg); - break; - case KMJob::Hold: - status = helper->changeJobState(it.current(), KMJob::Held, msg); - break; - case KMJob::Resume: - status = helper->changeJobState(it.current(), KMJob::Queued, msg); - break; - default: - status = false; - msg = i18n("Unsupported operation."); - break; - } - } - if (!status && !msg.isEmpty()) - KMManager::self()->setErrorMsg(msg); - return status; -} diff --git a/kdeprint/lpr/kmlprjobmanager.h b/kdeprint/lpr/kmlprjobmanager.h deleted file mode 100644 index d9a8eae3f..000000000 --- a/kdeprint/lpr/kmlprjobmanager.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPRJOBMANAGER_H -#define KMLPRJOBMANAGER_H - -#include "kmjobmanager.h" - -class LpqHelper; -class LpcHelper; - -class KMLprJobManager : public KMJobManager -{ -public: - KMLprJobManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - - int actions(); - -protected: - bool listJobs(const TQString&, JobType, int = 0); - LpcHelper* lpcHelper(); - bool sendCommandSystemJob(const TQPtrList<KMJob>&, int, const TQString& = TQString::null); - -private: - LpqHelper *m_lpqhelper; -}; - -#endif diff --git a/kdeprint/lpr/kmlprmanager.cpp b/kdeprint/lpr/kmlprmanager.cpp deleted file mode 100644 index cf4dbbb94..000000000 --- a/kdeprint/lpr/kmlprmanager.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlprmanager.h" -#include "printcapreader.h" -#include "printcapentry.h" -#include "lpchelper.h" -#include "matichandler.h" -#include "apshandler.h" -#include "lprngtoolhandler.h" -#include "lprsettings.h" -#include "driver.h" -#include "editentrydialog.h" - -#include <tqfileinfo.h> -#include <tqptrlist.h> -#include <klocale.h> -#include <kstandarddirs.h> -#include <kdebug.h> -#include <kprinter.h> -#include <kprocess.h> -#include <kaction.h> -#include <kmessagebox.h> -#include <klibloader.h> - -#include <stdlib.h> -#include <unistd.h> - -KMLprManager::KMLprManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - m_handlers.setAutoDelete(true); - m_handlerlist.setAutoDelete(false); - m_entries.setAutoDelete(true); - - m_lpchelper = new LpcHelper(this); - m_currentprinter = 0; - - setHasManagement(getuid() == 0); - setPrinterOperationMask( - KMManager::PrinterEnabling | - KMManager::PrinterConfigure | - KMManager::PrinterTesting | - KMManager::PrinterCreation | - KMManager::PrinterRemoval | - KMManager::PrinterTesting - ); - - initHandlers(); -} - -void KMLprManager::listPrinters() -{ - TQFileInfo fi(LprSettings::self()->printcapFile()); - - if (m_lpchelper) - m_lpchelper->updateStates(); - - // update only if needed - if (!m_updtime.isValid() || m_updtime < fi.lastModified()) - { - // cleanup previous entries - m_entries.clear(); - // notify handlers - TQPtrListIterator<LprHandler> hit(m_handlerlist); - for (; hit.current(); ++hit) - hit.current()->reset(); - - // try to open the printcap file and parse it - PrintcapReader reader; - TQFile f(fi.absFilePath()); - PrintcapEntry *entry; - if (f.exists() && f.open(IO_ReadOnly)) - { - reader.setPrintcapFile(&f); - while ((entry = reader.nextEntry()) != NULL) - { - TQPtrListIterator<LprHandler> it(m_handlerlist); - for (; it.current(); ++it) - if (it.current()->validate(entry)) - { - KMPrinter *prt = it.current()->createPrinter(entry); - checkPrinterState(prt); - prt->setOption("kde-lpr-handler", it.current()->name()); - addPrinter(prt); - break; - } - m_entries.insert(entry->name, entry); - } - } - - // save update time - m_updtime = fi.lastModified(); - } - else - { - TQPtrListIterator<KMPrinter> it(m_printers); - for (; it.current(); ++it) - if (!it.current()->isSpecial()) - { - it.current()->setDiscarded(false); - checkPrinterState(it.current()); - } - } -} - -void KMLprManager::insertHandler(LprHandler *handler) -{ - m_handlers.insert(handler->name(), handler); - m_handlerlist.append(handler); - kdDebug() << "Handler: " << handler->name() << endl; -} - -void KMLprManager::initHandlers() -{ - m_handlers.clear(); - m_handlerlist.clear(); - - insertHandler(new MaticHandler(this)); - insertHandler(new ApsHandler(this)); - insertHandler(new LPRngToolHandler(this)); - - // now load external handlers - TQStringList l = KGlobal::dirs()->findAllResources("data", "tdeprint/lpr/*.la"); - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - KLibrary *library = KLibLoader::self()->library(TQFile::encodeName(*it)); - if (library) - { - kdDebug() << "loading external handler from " << *it << endl; - LprHandler*(*func)(KMManager*) = (LprHandler*(*)(KMManager*))(library->symbol("create_handler")); - if (func) - insertHandler(func(this)); - else - kdDebug() << "couldn't find the symbol 'create_handler'" << endl; - } - } - - // default handler - insertHandler(new LprHandler("default", this)); -} - -LprHandler* KMLprManager::findHandler(KMPrinter *prt) -{ - TQString handlerstr(prt->option("kde-lpr-handler")); - LprHandler *handler(0); - if (handlerstr.isEmpty() || (handler = m_handlers.find(handlerstr)) == NULL) - { - return NULL; - } - return handler; -} - -PrintcapEntry* KMLprManager::findEntry(KMPrinter *prt) -{ - PrintcapEntry *entry = m_entries.find(prt->printerName()); - if (!entry) - { - return NULL; - } - return entry; -} - -bool KMLprManager::completePrinter(KMPrinter *prt) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - return handler->completePrinter(prt, entry, false); - return false; -} - -bool KMLprManager::completePrinterShort(KMPrinter *prt) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (!handler || !entry) - return false; - - return handler->completePrinter(prt, entry, true); -} - -void KMLprManager::checkPrinterState(KMPrinter *prt) -{ - if (m_lpchelper) - { - KMPrinter::PrinterState st = m_lpchelper->state(prt); - prt->setState(st); - prt->setAcceptJobs(!(st & KMPrinter::Rejecting)); - } - else - { - prt->setState(KMPrinter::Idle); - prt->setAcceptJobs(true); - } -} - -DrMain* KMLprManager::loadPrinterDriver(KMPrinter *prt, bool config) -{ - if (!prt) - return NULL; - - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - { - DrMain *driver = handler->loadDriver(prt, entry, config); - if (driver) - driver->set("handler", handler->name()); - return driver; - } - return NULL; -} - -DrMain* KMLprManager::loadFileDriver(const TQString& filename) -{ - int p = filename.find('/'); - TQString handler_str = (p != -1 ? filename.left(p) : TQString::tqfromLatin1("default")); - LprHandler *handler = m_handlers.find(handler_str); - if (handler) - { - DrMain *driver = handler->loadDbDriver(filename); - if (driver) - driver->set("handler", handler->name()); - return driver; - } - return NULL; -} - -bool KMLprManager::enablePrinter(KMPrinter *prt, bool state) -{ - TQString msg; - if (!m_lpchelper->enable(prt, state, msg)) - { - setErrorMsg(msg); - return false; - } - return true; -} - -bool KMLprManager::startPrinter(KMPrinter *prt, bool state) -{ - TQString msg; - if (!m_lpchelper->start(prt, state, msg)) - { - setErrorMsg(msg); - return false; - } - return true; -} - -bool KMLprManager::savePrinterDriver(KMPrinter *prt, DrMain *driver) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - { - bool mustSave(false); - if (handler->savePrinterDriver(prt, entry, driver, &mustSave)) - { - if (mustSave) - return savePrintcapFile(); - return true; - } - } - return false; -} - -bool KMLprManager::savePrintcapFile() -{ - if (!LprSettings::self()->isLocalPrintcap()) - { - setErrorMsg(i18n("The printcap file is a remote file (NIS). It cannot be written.")); - return false; - } - TQFile f(LprSettings::self()->printcapFile()); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - TQDictIterator<PrintcapEntry> it(m_entries); - for (; it.current(); ++it) - { - it.current()->writeEntry(t); - } - return true; - } - else - { - setErrorMsg(i18n("Unable to save printcap file. Check that " - "you have write permissions for that file.")); - return false; - } -} - -bool KMLprManager::createPrinter(KMPrinter *prt) -{ - // remove existing printcap entry - PrintcapEntry *oldEntry = m_entries.find(prt->printerName()); - - // look for the handler and re-create entry - LprHandler *handler(0); - // To look for the handler, either we base ourselves - // on the driver (1: new printer, 2: modifying driver) - // or we use the handler of the existing printer - // (modifying something else, handler stays the same) - if (prt->driver()) - handler = m_handlers.find(prt->driver()->get("handler")); - else if (oldEntry) - handler = findHandler(prt); - else - handler = m_handlers.find("default"); - if (!handler) - { - setErrorMsg(i18n("Internal error: no handler defined.")); - return false; - } - prt->setOption("kde-lpr-handler", handler->name()); - - // we reload the driver if the printer object doesn't have one - // and there's an old entry (sometimes needed to keep the backend - // like in Foomatic) - if (!prt->driver() && oldEntry) - prt->setDriver(handler->loadDriver(prt, oldEntry, true)); - - TQString sd = LprSettings::self()->baseSpoolDir(); - if (sd.isEmpty()) - { - setErrorMsg(i18n("Couldn't determine spool directory. See options dialog.")); - return false; - } - sd.append("/").append(prt->printerName()); - if (!KStandardDirs::makeDir(sd, 0755)) - { - setErrorMsg(i18n("Unable to create the spool directory %1. Check that you " - "have the required permissions for that operation.").arg(sd)); - return false; - } - PrintcapEntry *entry = handler->createEntry(prt); - if (!entry) - return false; // error should be set in the handler - // old entry can be removed now - m_entries.remove(prt->printerName()); - entry->name = prt->printerName(); - entry->addField("sh", Field::Boolean); - entry->addField("mx", Field::Integer, "0"); - entry->addField("sd", Field::String, sd); - if (!prt->option("kde-aliases").isEmpty()) - entry->aliases += TQStringList::split("|", prt->option("kde-aliases"), false); - - // insert the new entry and save printcap file - m_entries.insert(prt->printerName(), entry); - bool result = savePrintcapFile(); - if (result) - { - if (prt->driver()) - { - result = handler->savePrinterDriver(prt, entry, prt->driver()); - } - - // in case of LPRng, we need to tell the daemon about new printer - if (LprSettings::self()->mode() == LprSettings::LPRng) - { - TQString msg; - if (!m_lpchelper->restart(msg)) - { - setErrorMsg(i18n("The printer has been created but the print daemon " - "could not be restarted. %1").arg(msg)); - return false; - } - } - } - return result; -} - -bool KMLprManager::removePrinter(KMPrinter *prt) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - { - if (handler->removePrinter(prt, entry)) - { - TQString sd = entry->field("sd"); - // first try to save the printcap file, and if - // successful, remove the spool directory - m_entries.take(prt->printerName()); - bool status = savePrintcapFile(); - if (status) - { - // printcap file saved, entry can be deleted now - delete entry; - status = (::system(TQFile::encodeName("rm -rf " + KProcess::quote(sd))) == 0); - if (!status) - setErrorMsg(i18n("Unable to remove spool directory %1. " - "Check that you have write permissions " - "for that directory.").arg(sd)); - return status; - } - else - // push back the non-removed entry - m_entries.insert(prt->printerName(), entry); - } - } - return false; -} - -TQString KMLprManager::driverDbCreationProgram() -{ - return TQString::tqfromLatin1("make_driver_db_lpr"); -} - -TQString KMLprManager::driverDirectory() -{ - TQPtrListIterator<LprHandler> it(m_handlerlist); - TQString dbDirs; - for (; it.current(); ++it) - { - TQString dir = it.current()->driverDirectory(); - if (!dir.isEmpty()) - dbDirs.append(dir).append(":"); - } - if (!dbDirs.isEmpty()) - dbDirs.truncate(dbDirs.length()-1); - return dbDirs; -} - -TQString KMLprManager::printOptions(KPrinter *prt) -{ - KMPrinter *mprt = findPrinter(prt->printerName()); - TQString opts; - if (mprt) - { - LprHandler *handler = findHandler(mprt); - if (handler) - return handler->printOptions(prt); - } - return TQString::null; -} - -void KMLprManager::createPluginActions(KActionCollection *coll) -{ - KAction *act = new KAction(i18n("&Edit printcap Entry..."), "tdeprint_report", 0, this, TQT_SLOT(slotEditPrintcap()), coll, "plugin_editprintcap"); - act->setGroup("plugin"); -} - -void KMLprManager::validatePluginActions(KActionCollection *coll, KMPrinter *prt) -{ - m_currentprinter = prt; - // FIXME: disabled until completion - coll->action("plugin_editprintcap")->setEnabled(0 && hasManagement() && prt && !prt->isSpecial()); -} - -void KMLprManager::slotEditPrintcap() -{ - if (!m_currentprinter || - KMessageBox::warningContinueCancel(NULL, - i18n("Editing a printcap entry manually should only be " - "done by confirmed system administrator. This may " - "prevent your printer from working. Do you want to " - "continue?"), TQString::null, KStdGuiItem::cont(), - "editPrintcap") == KMessageBox::Cancel) - return; - - PrintcapEntry *entry = findEntry(m_currentprinter); - EditEntryDialog dlg(entry, NULL); - if (dlg.exec()) - { - } -} - -TQString KMLprManager::stateInformation() -{ - return i18n("Spooler type: %1").arg(LprSettings::self()->mode() == LprSettings::LPR ? "LPR (BSD compatible)" : "LPRng"); -} - -#include "kmlprmanager.moc" diff --git a/kdeprint/lpr/kmlprmanager.h b/kdeprint/lpr/kmlprmanager.h deleted file mode 100644 index 34d38340f..000000000 --- a/kdeprint/lpr/kmlprmanager.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLRMANAGER_H -#define KMLRMANAGER_H - -#include "kmmanager.h" - -#include <tqdict.h> -#include <tqptrlist.h> -#include <tqdatetime.h> -#include <kurl.h> - -class LprHandler; -class PrintcapEntry; -class LpcHelper; -class KPrinter; - -class KMLprManager : public KMManager -{ - Q_OBJECT -public: - KMLprManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - - bool completePrinter(KMPrinter*); - bool completePrinterShort(KMPrinter*); - bool enablePrinter(KMPrinter*, bool); - bool startPrinter(KMPrinter*, bool); - bool savePrinterDriver(KMPrinter*, DrMain*); - DrMain* loadPrinterDriver(KMPrinter*, bool = false); - DrMain* loadFileDriver(const TQString&); - bool createPrinter(KMPrinter*); - bool removePrinter(KMPrinter*); - - TQString driverDbCreationProgram(); - TQString driverDirectory(); - - LpcHelper* lpcHelper() { return m_lpchelper; } - TQString printOptions(KPrinter*); - - void createPluginActions(KActionCollection*); - void validatePluginActions(KActionCollection*, KMPrinter*); - TQString stateInformation(); - -protected slots: - void slotEditPrintcap(); - -protected: - void listPrinters(); - void initHandlers(); - void insertHandler(LprHandler*); - PrintcapEntry* findEntry(KMPrinter*); - LprHandler* findHandler(KMPrinter*); - void checkPrinterState(KMPrinter*); - bool savePrintcapFile(); - -private: - TQDict<LprHandler> m_handlers; - TQPtrList<LprHandler> m_handlerlist; - TQDict<PrintcapEntry> m_entries; - TQDateTime m_updtime; - LpcHelper *m_lpchelper; - KMPrinter *m_currentprinter; -}; - -#endif diff --git a/kdeprint/lpr/kmlpruimanager.cpp b/kdeprint/lpr/kmlpruimanager.cpp deleted file mode 100644 index 655309e0c..000000000 --- a/kdeprint/lpr/kmlpruimanager.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlpruimanager.h" -#include "kmpropertypage.h" -#include "kprinterpropertydialog.h" -#include "kpqtpage.h" -#include "kmconfigdialog.h" - -#include "kmpropdriver.h" -#include "kmpropbackend.h" -#include "kmwizard.h" -#include "kmwbackend.h" -#include "kmconfiglpr.h" - -#include <klocale.h> - -KMLprUiManager::KMLprUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMUiManager(parent,name) -{ -} - -KMLprUiManager::~KMLprUiManager() -{ -} - -void KMLprUiManager::setupPropertyPages(KMPropertyPage *pages) -{ - pages->addPropPage(new KMPropBackend(pages, "Backend")); - pages->addPropPage(new KMPropDriver(pages, "Driver")); -} - -void KMLprUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg) -{ - dlg->addPage(new KPQtPage(dlg->driver(), dlg, "QtPage")); -} - -void KMLprUiManager::setupWizard(KMWizard *wizard) -{ - KMWBackend *backend = wizard->backendPage(); - - backend->addBackend(KMWizard::Local, true); - backend->addBackend(KMWizard::LPD, true); - backend->addBackend(KMWizard::TCP, true); - backend->addBackend(KMWizard::SMB, true, KMWizard::Password); -} - -void KMLprUiManager::setupConfigDialog(KMConfigDialog *dlg) -{ - dlg->addConfigPage(new KMConfigLpr(dlg)); -} diff --git a/kdeprint/lpr/kmlpruimanager.h b/kdeprint/lpr/kmlpruimanager.h deleted file mode 100644 index 561f93500..000000000 --- a/kdeprint/lpr/kmlpruimanager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLPRUIMANAGER_H -#define KMLPRUIMANAGER_H - -#include "kmuimanager.h" - -class KMLprUiManager : public KMUiManager -{ -public: - KMLprUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMLprUiManager(); - - void setupPropertyPages(KMPropertyPage*); - void setupPrinterPropertyDialog(KPrinterPropertyDialog*); - void setupWizard(KMWizard*); - void setupConfigDialog(KMConfigDialog*); -}; - -#endif diff --git a/kdeprint/lpr/lpchelper.cpp b/kdeprint/lpr/lpchelper.cpp deleted file mode 100644 index c921a803c..000000000 --- a/kdeprint/lpr/lpchelper.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "lpchelper.h" -#include "kpipeprocess.h" -#include "kmjob.h" -#include "lprsettings.h" - -#include <kstandarddirs.h> -#include <tqtextstream.h> -#include <tqregexp.h> -#include <kdebug.h> -#include <klocale.h> -#include <kprocess.h> -#include <stdlib.h> - -static TQString execute(const TQString& cmd) -{ - KPipeProcess proc; - TQString output; - if (proc.open(cmd)) - { - TQTextStream t(&proc); - while (!t.atEnd()) - output.append(t.readLine()).append("\n"); - proc.close(); - } - return output; -} - -LpcHelper::LpcHelper(TQObject *parent, const char *name) -: TQObject(parent, name) -{ - // look for the "lpc" executable. Use the PATH variable and - // add some specific dirs. - TQString PATH = getenv("PATH"); - PATH.append(":/usr/sbin:/usr/local/sbin:/sbin:/opt/sbin:/opt/local/sbin"); - m_exepath = KStandardDirs::findExe("lpc", PATH); - m_checkpcpath = KStandardDirs::findExe("checkpc", PATH); - m_lprmpath = KStandardDirs::findExe("lprm"); -} - -LpcHelper::~LpcHelper() -{ -} - -KMPrinter::PrinterState LpcHelper::state(const TQString& prname) const -{ - if (m_state.contains(prname)) - return m_state[prname]; - return KMPrinter::Unknown; -} - -KMPrinter::PrinterState LpcHelper::state(KMPrinter *prt) const -{ - return state(prt->printerName()); -} - -void LpcHelper::parseStatusLPR(TQTextStream &t) -{ - TQString printer, line; - int p(-1); - - while (!t.atEnd()) - { - line = t.readLine(); - if (line.isEmpty()) - continue; - else if (!line[0].isSpace() && (p = line.find(':')) != -1) - { - printer = line.left(p); - m_state[printer] = KMPrinter::Idle; - } - else if (line.find("printing is disabled") != -1) - { - if (!printer.isEmpty()) - m_state[printer] = KMPrinter::PrinterState((KMPrinter::Stopped) | (m_state[printer] & ~KMPrinter::StateMask)); - } - else if (line.find("queuing is disabled") != -1) - { - if (!printer.isEmpty()) - m_state[printer] = KMPrinter::PrinterState((KMPrinter::Rejecting) | (m_state[printer] & KMPrinter::StateMask)); - } - else if (line.find("entries") != -1) - { - if (!printer.isEmpty() && - (m_state[printer] & KMPrinter::StateMask) != KMPrinter::Stopped && - line.find("no entries") == -1) - m_state[printer] = KMPrinter::PrinterState((m_state[printer] & ~KMPrinter::StateMask) | KMPrinter::Processing); - } - } -} - -void LpcHelper::parseStatusLPRng(TQTextStream& t) -{ - TQStringList l; - int p(-1); - TQString printer; - - while (!t.atEnd()) - if (t.readLine().stripWhiteSpace().startsWith("Printer")) - break; - while (!t.atEnd()) - { - l = TQStringList::split(TQRegExp("\\s"), t.readLine(), false); - if (l.count() < 4) - continue; - p = l[0].find('@'); - if (p == 0) - printer = l[0]; - else - printer = l[0].left(p); - int st(0); - if (l[1] == "disabled") - st = KMPrinter::Stopped; - else if (l[3] != "0") - st = KMPrinter::Processing; - else - st = KMPrinter::Idle; - if (l[2] == "disabled") - st |= KMPrinter::Rejecting; - m_state[printer] = KMPrinter::PrinterState(st); - } -} - -void LpcHelper::updateStates() -{ - KPipeProcess proc; - - m_state.clear(); - if (!m_exepath.isEmpty() && proc.open(m_exepath + " status all")) - { - TQTextStream t(&proc); - - switch (LprSettings::self()->mode()) - { - default: - case LprSettings::LPR: - parseStatusLPR(t); - break; - case LprSettings::LPRng: - parseStatusLPRng(t); - break; - } - proc.close(); - } - -} - -bool LpcHelper::enable(KMPrinter *prt, bool state, TQString& msg) -{ - int st = m_state[prt->printerName()] & KMPrinter::StateMask; - if (changeState(prt->printerName(), (state ? "enable" : "disable"), msg)) - { - m_state[prt->printerName()] = KMPrinter::PrinterState((state ? KMPrinter::Rejecting : 0) | st); - return true; - } - return false; -} - -bool LpcHelper::start(KMPrinter *prt, bool state, TQString& msg) -{ - int rej = m_state[prt->printerName()] & ~KMPrinter::StateMask; - if (changeState(prt->printerName(), (state ? "start" : "stop"), msg)) - { - m_state[prt->printerName()] = KMPrinter::PrinterState((state ? KMPrinter::Idle : KMPrinter::Stopped) | rej); - return true; - } - return false; -} - -// status -// 0 : success -// -1 : permission denied -// -2 : unknown printer -// 1 : unknown error -int LpcHelper::parseStateChangeLPR(const TQString& result, const TQString& printer) -{ - if (result.startsWith(printer + ":")) - return 0; - else if (result.startsWith("?Privileged")) - return -1; - else if (result.startsWith("unknown")) - return -2; - else - return 1; -} - -static TQString lprngAnswer(const TQString& result, const TQString& printer) -{ - int p, q; - - p = result.find("\n" + printer); - if (p != -1) - { - q = result.find(':', p)+2; - p = result.find('\n', q); - TQString answer = result.mid(q, p-q).stripWhiteSpace(); - return answer; - } - return TQString::null; -} - -int LpcHelper::parseStateChangeLPRng(const TQString& result, const TQString& printer) -{ - TQString answer = lprngAnswer(result, printer); - if (answer == "no") - return -1; - else if (answer == "disabled" || answer == "enabled" || answer == "started" || answer == "stopped") - return 0; - else - return 1; -} - -bool LpcHelper::changeState(const TQString& printer, const TQString& op, TQString& msg) -{ - if (m_exepath.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg("lpc"); - return false; - } - TQString result = execute(m_exepath + " " + op + " " + KProcess::quote(printer)); - int status; - - switch (LprSettings::self()->mode()) - { - default: - case LprSettings::LPR: - status = parseStateChangeLPR(result, printer); - break; - case LprSettings::LPRng: - status = parseStateChangeLPRng(result, printer); - break; - } - switch (status) - { - case 0: - break; - case -1: - msg = i18n("Permission denied."); - break; - case -2: - msg = i18n("Printer %1 does not exist.").arg(printer); - break; - default: - case 1: - msg = i18n("Unknown error: %1").arg(result.replace(TQRegExp("\\n"), " ")); - break; - } - return (status == 0); -} - -bool LpcHelper::removeJob(KMJob *job, TQString& msg) -{ - if (m_lprmpath.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg("lprm"); - return false; - } - TQString result = execute(m_lprmpath + " -P " + KProcess::quote(job->printer()) + " " + TQString::number(job->id())); - if (result.find("dequeued") != -1) - return true; - else if (result.find("Permission denied") != -1 || result.find("no permissions") != -1) - msg = i18n("Permission denied."); - else - msg = i18n("Execution of lprm failed: %1").arg(result); - return false; -} - -// LPRng only -bool LpcHelper::changeJobState(KMJob *job, int state, TQString& msg) -{ - if (m_lprmpath.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg("lpc"); - return false; - } - TQString result = execute(m_exepath + (state == KMJob::Held ? " hold " : " release ") + KProcess::quote(job->printer()) + " " + TQString::number(job->id())); - TQString answer = lprngAnswer(result, job->printer()); - if (answer == "no") - { - msg = i18n("Permission denied."); - return false; - } - else - return true; -} - -bool LpcHelper::restart(TQString& msg) -{ - TQString s; - if (m_exepath.isEmpty()) - s = "lpc"; - else if (m_checkpcpath.isEmpty()) - s = "checkpc"; - if (!s.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg(s); - return false; - } - ::system(TQFile::encodeName(m_exepath + " reread")); - ::system(TQFile::encodeName(m_checkpcpath + " -f")); - return true; -} diff --git a/kdeprint/lpr/lpchelper.h b/kdeprint/lpr/lpchelper.h deleted file mode 100644 index b1e20f089..000000000 --- a/kdeprint/lpr/lpchelper.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 LPCHELPER_H -#define LPCHELPER_H - -#include <tqobject.h> -#include <tqmap.h> -#include <tqtextstream.h> -#include "kmprinter.h" - -class KMJob; - -class LpcHelper : public TQObject -{ -public: - LpcHelper(TQObject *parent = 0, const char *name = 0); - ~LpcHelper(); - - KMPrinter::PrinterState state(const TQString&) const; - KMPrinter::PrinterState state(KMPrinter*) const; - void updateStates(); - - bool enable(KMPrinter*, bool, TQString&); - bool start(KMPrinter*, bool, TQString&); - bool removeJob(KMJob*, TQString&); - bool changeJobState(KMJob*, int, TQString&); - - bool restart(TQString&); - -protected: - bool changeState(const TQString&, const TQString&, TQString&); - void parseStatusLPR(TQTextStream&); - void parseStatusLPRng(TQTextStream&); - int parseStateChangeLPR(const TQString&, const TQString&); - int parseStateChangeLPRng(const TQString&, const TQString&); - -private: - TQMap<TQString, KMPrinter::PrinterState> m_state; - TQString m_exepath, m_lprmpath, m_checkpcpath; -}; - -#endif diff --git a/kdeprint/lpr/lpqhelper.cpp b/kdeprint/lpr/lpqhelper.cpp deleted file mode 100644 index 30348f591..000000000 --- a/kdeprint/lpr/lpqhelper.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "lpqhelper.h" -#include "kmjob.h" -#include "kpipeprocess.h" -#include "lprsettings.h" - -#include <kstandarddirs.h> -#include <kprocess.h> -#include <kdebug.h> - -LpqHelper::LpqHelper(TQObject *parent, const char *name) -: TQObject(parent, name) -{ - m_exepath = KStandardDirs::findExe("lpq"); -} - -LpqHelper::~LpqHelper() -{ -} - -KMJob* LpqHelper::parseLineLpr(const TQString& line) -{ - TQString rank = line.left(7); - if (!rank[0].isDigit() && rank != "active") - return NULL; - KMJob *job = new KMJob; - job->setState((rank[0].isDigit() ? KMJob::Queued : KMJob::Printing)); - job->setOwner(line.mid(7, 11).stripWhiteSpace()); - job->setId(line.mid(18, 5).toInt()); - job->setName(line.mid(23, 38).stripWhiteSpace()); - int p = line.find(' ', 61); - if (p != -1) - { - job->setSize(line.mid(61, p-61).toInt() / 1000); - } - return job; -} - -KMJob* LpqHelper::parseLineLPRng(const TQString& line) -{ - TQString rank = line.left(7).stripWhiteSpace(); - if (!rank[0].isDigit() && rank != "active" && rank != "hold") - return NULL; - KMJob *job = new KMJob; - job->setState((rank[0].isDigit() ? KMJob::Queued : (rank == "hold" ? KMJob::Held : KMJob::Printing))); - int p = line.find('@', 7), q = line.find(' ', 7); - job->setOwner(line.mid(7, TQMIN(p,q)-7)); - while (line[q].isSpace()) - q++; - q++; - while (line[q].isSpace()) - q++; - p = line.find(' ', q); - job->setId(line.mid(q, p-q).toInt()); - while (line[p].isSpace()) - p++; - q = p+25; - while (line[q].isDigit()) - q--; - job->setName(line.mid(p, q-p).stripWhiteSpace()); - job->setSize(line.mid(q+1, p+26-q).toInt() / 1000); - return job; -} - -void LpqHelper::listJobs(TQPtrList<KMJob>& jobs, const TQString& prname, int limit) -{ - KPipeProcess proc; - if (!m_exepath.isEmpty() && proc.open(m_exepath + " -P " + KProcess::quote(prname))) - { - TQTextStream t(&proc); - TQString line; - bool lprng = (LprSettings::self()->mode() == LprSettings::LPRng); - int count = 0; - - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("Rank")) - break; - } - while (!t.atEnd()) - { - line = t.readLine(); - if ( limit > 0 && count >= limit ) - continue; - KMJob *job = (lprng ? parseLineLPRng(line) : parseLineLpr(line)); - if (job) - { - job->setPrinter(prname); - job->setUri("lpd://"+prname+"/"+TQString::number(job->id())); - jobs.append(job); - count++; - } - else - break; - } - proc.close(); - } -} diff --git a/kdeprint/lpr/lpqhelper.h b/kdeprint/lpr/lpqhelper.h deleted file mode 100644 index 2c38566c5..000000000 --- a/kdeprint/lpr/lpqhelper.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 LPQHELPER_H -#define LPQHELPER_H - -#include <tqobject.h> -#include <tqptrlist.h> - -class KMJob; - -class LpqHelper : public TQObject -{ -public: - LpqHelper(TQObject *parent = 0, const char *name = 0); - ~LpqHelper(); - - void listJobs(TQPtrList<KMJob>& jobs, const TQString& prname, int limit = 0); - -protected: - KMJob* parseLineLpr(const TQString&); - KMJob* parseLineLPRng(const TQString&); - -private: - TQString m_exepath; -}; - -#endif diff --git a/kdeprint/lpr/lpr.print b/kdeprint/lpr/lpr.print deleted file mode 100644 index e8cd8a3d7..000000000 --- a/kdeprint/lpr/lpr.print +++ /dev/null @@ -1,86 +0,0 @@ -[KDE Print Entry] -PrintSystem=lpr -Comment=LPR/LPRng Print System -Comment[af]= lpr /Lprng Druk Stelsel -Comment[ar]=نظام طباعة LPR/LPRng -Comment[az]=LPR/LPRng Çap Sistemi -Comment[be]=СіÑÑ‚Ñма друку LPR/LPRng -Comment[bn]=à¦à¦²-পি-আর/à¦à¦²-পি-আর-à¦à¦¨-জি মà§à¦¦à§à¦°à¦£ বà§à¦¯à¦¬à¦¸à§à¦¥à¦¾ -Comment[br]=Reizhiad moulañ LPR/LPRng -Comment[bs]=LPR/LPRng sistem Å¡tampe -Comment[ca]=Sistema d'impressió LPR/LPRng -Comment[cs]=Tiskový systém LPR/LPRng -Comment[csb]=Systema drëkù LPR/LPRng -Comment[cy]=Cysawd Argraffu LPR/LPRng -Comment[da]=LPR/LPRng-udskriftssystem -Comment[de]=LPR/LPRng-Drucksystem -Comment[el]=LPR/LPRng σÏστημα εκτÏπωσης -Comment[eo]=LPR/LPRng-presosistemo -Comment[es]=Sistema de impresión LPR/LPRNg -Comment[et]=LPR/LPRng trükkimise süsteem -Comment[eu]=LPR/LPRng inprimatze-sistema -Comment[fa]=سیستم چاپ LPR/LPRng -Comment[fi]=LPR/LPRng-tulostusjärjestelmä -Comment[fr]=Système d'impression LPR / LPRng -Comment[fy]=LPR-/LPRNG-ôfdruksysteem -Comment[ga]=Córas Priontála LPR/LPRng -Comment[gl]=Sistema de Impresión LPR/LPRng -Comment[he]=מערכת ההדפסה LPR/LPRng -Comment[hi]=LPR/LPRng छपाई पदà¥à¤§à¤¤à¥à¤¤à¤¿ -Comment[hr]=LPR/LPRng sustav za ispis -Comment[hu]=LPR/LPRng -Comment[id]=Sistem Pencetakan LPR/LPRng -Comment[is]=LPR/LPRng prentkerfið -Comment[it]=Sistema di stampa LPR/LPRng -Comment[ja]=LPR/LPRng å°åˆ·ã‚·ã‚¹ãƒ†ãƒ  -Comment[ka]=LPR/LPRng ბეჭდვის სისტემრ-Comment[kk]=LPR/LPRng баÑып шығару жүйеÑÑ– -Comment[km]=ប្រពáŸáž“្ធ​បោះពុម្ព LPR/LPRng -Comment[ko]=LPR/LPRng ì¸ì‡„ 시스템 -Comment[lb]=LPR/LPRng-Drécksystem -Comment[lt]=LPR/LPRng spausdinimo sistema -Comment[lv]=LPR/LPRng drukas sistÄ“ma -Comment[mk]=LPR/LPRng ÑиÑтемот за печатење -Comment[mn]=LPR/LPRng-Ð¥ÑвлÑÑ… ÑиÑтем -Comment[ms]=Sistem Cetak LPR/LPRng -Comment[mt]=Sistema tal-ipprintjar LPR/LPRng -Comment[nb]=Utskriftssystemet LPR/LPRng -Comment[nds]=Dat Drucksysteem LPR/LPRng -Comment[ne]=LPR/LPRng मà¥à¤¦à¥à¤°à¤£ पà¥à¤°à¤£à¤¾à¤²à¥€ -Comment[nl]=LPR-/LPRNG-afdruksysteem -Comment[nn]=Utskriftssystemet LPR/LPRng -Comment[nso]=System ya Kgatiso ya LPR/LPRng -Comment[pa]=LPR/LPRng ਪà©à¨°à¨¿à©°à¨Ÿà¨° ਸਿਸਟਮ -Comment[pl]=System druku LPR/LPRng -Comment[pt]=O sistema de impressão LPR/LPRng -Comment[pt_BR]=Sistema de Impressão LPR/LPRng -Comment[ro]=Sistem de tipărire LPR/LPRng -Comment[ru]=СиÑтема печати LPR/LPRng -Comment[rw]=Sisitemu yo Gucapa LPR/LPRng -Comment[se]=LPR/LPRng Äálihanvuogádat -Comment[sk]=TlaÄový systém LPR/LPRng -Comment[sl]=TiskalniÅ¡ki sistem za LPR/LPRng -Comment[sq]=Sistem Shtypi për LPR/LPRng -Comment[sr]=LPR/LPRng ÑиÑтем за штампање -Comment[sr@Latn]=LPR/LPRng sistem za Å¡tampanje -Comment[ss]=LPR/LPRng umhini wekushivelela -Comment[sv]=LPR/LPRNG-skrivarsystem -Comment[ta]=LPR/LPRng அசà¯à®šà¯à®¤à¯ தொகà¯à®¤à®¿ -Comment[te]=ఎలౠపి ఆరà±/ఎలౠపి ఆరౠఎనౠజి à°ªà±à°°à°šà±à°°à°£ à°µà±à°¯à°µà°¸à±à°¥ -Comment[tg]=СиÑтемаи чопи LPR/LPRng -Comment[th]=ระบบà¸à¸²à¸£à¸žà¸´à¸¡à¸žà¹Œ LPR/LPRng -Comment[tr]=LPR/LPRng Yazdırma Sistemi -Comment[tt]=LPR/LPRng Bastıru Sisteme -Comment[uk]=СиÑтема друку LPR/LPRng -Comment[uz]=LPR/LPRng bosib chiqarish tizimi -Comment[uz@cyrillic]=LPR/LPRng боÑиб чиқариш тизими -Comment[ven]=LPR/Maitele au phirintha a LPRng -Comment[vi]=Hệ thống in LPR/LPRng -Comment[wa]=Sistinme d' imprimaedje LPR/LPRng -Comment[xh]=LPR/LPRng Indlela Yokushicilela -Comment[zh_CN]=LPR/LPRng 打å°ç³»ç»Ÿ -Comment[zh_HK]=LPR/LPRng 列å°ç³»çµ± -Comment[zh_TW]=LPR/LPRng 列å°ç³»çµ± -Comment[zu]=Isistimu Yokushicilela ye-LPR/LRng -DetectUris=service:/printer -DetectPrecedence=0 diff --git a/kdeprint/lpr/lprhandler.cpp b/kdeprint/lpr/lprhandler.cpp deleted file mode 100644 index fcb838bb9..000000000 --- a/kdeprint/lpr/lprhandler.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "lprhandler.h" -#include "kmprinter.h" -#include "printcapentry.h" -#include "kmmanager.h" -#include "lprsettings.h" -#include "driver.h" - -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqvaluestack.h> -#include <klocale.h> - -#include <unistd.h> - -LprHandler::LprHandler(const TQString& name, KMManager *mgr) -: m_name(name), m_manager(mgr) -{ -} - -LprHandler::~LprHandler() -{ -} - -bool LprHandler::validate(PrintcapEntry*) -{ - return true; -} - -KMPrinter* LprHandler::createPrinter(PrintcapEntry *entry) -{ - KMPrinter *prt = new KMPrinter; - prt->setPrinterName(entry->name); - prt->setName(entry->name); - prt->setType(KMPrinter::Printer); - return prt; -} - -bool LprHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool) -{ - prt->setDescription(i18n("Unknown (unrecognized entry)")); - TQString val = entry->field("lp"); - KURL uri; - if (!val.isEmpty() && val != "/dev/null") - { - int p = val.find('@'); - if (p != -1) - { - prt->setLocation(i18n("Remote queue (%1) on %2").arg(val.left(p)).arg(val.mid(p+1))); - uri.setProtocol("lpd"); - uri.setHost(val.mid(p+1)); - uri.setPath("/" + val.left(p)); - } - else if ((p = val.find('%')) != -1) - { - prt->setLocation(i18n("Network printer (%1)").arg("socket")); - uri.setProtocol("socket"); - uri.setHost(val.left(p)); - uri.setPort(val.mid(p+1).toInt()); - } - else - { - prt->setLocation(i18n("Local printer on %1").arg(val)); - uri.setProtocol("parallel"); - uri.setPath(val); - } - } - else if (!(val = entry->field("rp")).isEmpty()) - { - TQString rm = entry->has("rm") ? - entry->field("rm") : - LprSettings::self()->defaultRemoteHost(); - prt->setLocation(i18n("Remote queue (%1) on %2").arg(val).arg(rm)); - uri.setProtocol("lpd"); - uri.setHost(rm); - uri.setPath("/" + val); - } - else - prt->setLocation(i18n("Unknown (unrecognized entry)")); - prt->setDevice(uri.url()); - return true; -} - -DrMain* LprHandler::loadDriver(KMPrinter*, PrintcapEntry*, bool) -{ - manager()->setErrorMsg(i18n("Unrecognized entry.")); - return NULL; -} - -bool LprHandler::savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool*) -{ - manager()->setErrorMsg(i18n("Unrecognized entry.")); - return false; -} - -DrMain* LprHandler::loadDbDriver(const TQString&) -{ - manager()->setErrorMsg(i18n("Unrecognized entry.")); - return NULL; -} - -PrintcapEntry* LprHandler::createEntry(KMPrinter *prt) -{ - // this default handler only supports local parallel and remote lpd URIs - KURL uri ( prt->device() ); - TQString prot = uri.protocol(); - if (!prot.isEmpty() && prot != "parallel" && prot != "file" && prot != "lpd" && prot != "socket") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - PrintcapEntry *entry = new PrintcapEntry; - entry->comment = "# Default handler"; - if (prot == "lpd") - { - entry->addField("rm", Field::String, uri.host()); - TQString rp = uri.path(); - if (rp[0] == '/') - rp = rp.mid(1); - entry->addField("rp", Field::String, rp); - // force this entry to null (otherwise it seems it's redirected - // to /dev/lp0 by default) - entry->addField("lp", Field::String, TQString::null); - } - else if ( prot == "socket" ) - { - TQString lp = uri.host(); - if ( uri.port() == 0 ) - lp.append( "%9100" ); - else - lp.append( "%" ).append( TQString::number( uri.port() ) ); - entry->addField("lp", Field::String, lp); - } - else - { - entry->addField("lp", Field::String, uri.path()); - } - return entry; -} - -bool LprHandler::removePrinter(KMPrinter*, PrintcapEntry*) -{ - return true; -} - -TQString LprHandler::printOptions(KPrinter*) -{ - return TQString::null; -} - -void LprHandler::reset() -{ -} - -DrMain* LprHandler::loadToolDriver(const TQString& filename) -{ - TQFile f(filename); - if (f.open(IO_ReadOnly)) - { - DrMain *driver = new DrMain; - TQValueStack<DrGroup*> groups; - TQTextStream t(&f); - TQStringList l; - DrListOption *lopt(0); - DrBase *opt(0); - - groups.push(driver); - driver->set("text", "Tool Driver"); - while (!t.atEnd()) - { - l = TQStringList::split('|', t.readLine().stripWhiteSpace(), false); - if (l.count() == 0) - continue; - if (l[0] == "GROUP") - { - DrGroup *grp = new DrGroup; - grp->setName(l[1]); - grp->set("text", l[2]); - groups.top()->addGroup(grp); - groups.push(grp); - } - else if (l[0] == "ENDGROUP") - { - groups.pop(); - } - else if (l[0] == "OPTION") - { - opt = 0; - lopt = 0; - if (l.count() > 3) - { - if (l[3] == "STRING") - opt = new DrStringOption; - else if (l[3] == "BOOLEAN") - { - lopt = new DrBooleanOption; - opt = lopt; - } - } - else - { - lopt = new DrListOption; - opt = lopt; - } - if (opt) - { - opt->setName(l[1]); - opt->set("text", l[2]); - groups.top()->addOption(opt); - } - } - else if (l[0] == "CHOICE" && lopt) - { - DrBase *ch = new DrBase; - ch->setName(l[1]); - ch->set("text", l[2]); - lopt->addChoice(ch); - } - else if (l[0] == "DEFAULT" && opt) - { - opt->setValueText(l[1]); - opt->set("default", l[1]); - } - } - return driver; - } - return NULL; -} - -TQString LprHandler::driverDirectory() -{ - if (m_cacheddriverdir.isEmpty()) - m_cacheddriverdir = driverDirInternal(); - return m_cacheddriverdir; -} - -TQString LprHandler::driverDirInternal() -{ - return TQString::null; -} - -TQString LprHandler::locateDir(const TQString& dirname, const TQString& paths) -{ - TQStringList pathlist = TQStringList::split(':', paths, false); - for (TQStringList::ConstIterator it=pathlist.begin(); it!=pathlist.end(); ++it) - { - TQString testpath = *it + "/" + dirname; - if (::access(TQFile::encodeName(testpath), F_OK) == 0) - return testpath; - } - return TQString::null; -} diff --git a/kdeprint/lpr/lprhandler.h b/kdeprint/lpr/lprhandler.h deleted file mode 100644 index e0e66e146..000000000 --- a/kdeprint/lpr/lprhandler.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 LPRHANDLER_H -#define LPRHANDLER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqstring.h> - -class PrintcapEntry; -class KMPrinter; -class DrMain; -class KMManager; -class KPrinter; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class LprHandler -{ -public: - LprHandler(const TQString& name, KMManager *mgr = 0); - virtual ~LprHandler(); - - virtual bool validate(PrintcapEntry*); - virtual KMPrinter* createPrinter(PrintcapEntry*); - virtual bool completePrinter(KMPrinter*, PrintcapEntry*, bool shortmode = true); - virtual DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - virtual DrMain* loadDbDriver(const TQString&); - virtual bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - virtual PrintcapEntry* createEntry(KMPrinter*); - virtual bool removePrinter(KMPrinter*, PrintcapEntry*); - virtual TQString printOptions(KPrinter*); - virtual void reset(); - - TQString name() const; - KMManager* manager() const; - TQString driverDirectory(); - -protected: - DrMain* loadToolDriver(const TQString&); - TQString locateDir(const TQString& dirname, const TQString& paths); - TQString cachedDriverDir() const; - void setCachedDriverDir(const TQString&); - virtual TQString driverDirInternal(); - -protected: - TQString m_name; - KMManager *m_manager; - TQString m_cacheddriverdir; -}; - -inline TQString LprHandler::name() const -{ return m_name; } - -inline KMManager* LprHandler::manager() const -{ return m_manager; } - -inline TQString LprHandler::cachedDriverDir() const -{ return m_cacheddriverdir; } - -inline void LprHandler::setCachedDriverDir(const TQString& s) -{ m_cacheddriverdir = s; } - -#endif diff --git a/kdeprint/lpr/lprngtooldriver1 b/kdeprint/lpr/lprngtooldriver1 deleted file mode 100644 index 11636403c..000000000 --- a/kdeprint/lpr/lprngtooldriver1 +++ /dev/null @@ -1,85 +0,0 @@ -GROUP|general|General -OPTION|PageSize|Page Size -CHOICE|letter|US Letter -CHOICE|legal|US Legal -CHOICE|ledger|Ledger -CHOICE|11x17|11x17 -CHOICE|tabloid|Tabloid -CHOICE|oversize|Oversize -CHOICE|executive|Executive -CHOICE|envelope|Envelope -CHOICE|a0|A0 -CHOICE|a1|A1 -CHOICE|a2|A2 -CHOICE|a3|A3 -CHOICE|a4|A4 -DEFAULT|a4 -OPTION|MediaType|Media Type -CHOICE|bond|Bond paper -CHOICE|cardstock|Card stock -CHOICE|color|Color paper -CHOICE|glossy|Glossy paper -CHOICE|heavy|Heavy paper -CHOICE|labels|Labels -CHOICE|letterhead|Letter head -CHOICE|plain|Plain paper -CHOICE|preprinted|Preprinted paper -CHOICE|prepunched|Prepunched paper -CHOICE|recycle|Recycled paper -CHOICE|transparency|Transparencies -CHOICE|default|Default setting -DEFAULT|default -OPTION|InputSlot|Input Slot -CHOICE|manual|Manual tray -CHOICE|inupper|Upper tray -CHOICE|inmiddle|Middle tray -CHOICE|inlower|Lower tray -CHOICE|inlarge|Large tray -CHOICE|inright|Right tray -CHOICE|intray1|Tray 1 -CHOICE|intray2|Tray 2 -CHOICE|intray3|Tray 3 -CHOICE|intray4|Tray 4 -CHOICE|intray5|Tray 5 -CHOICE|intray6|Tray 6 -CHOICE|intray7|Tray 7 -CHOICE|intray8|Tray 8 -CHOICE|intray9|Tray 9 -CHOICE|intray10|Tray 10 -CHOICE|inlargecapacity|Large capacity tray -CHOICE|inhighcapacity|High capacity tray -CHOICE|default|Default setting -DEFAULT|default -OPTION|OutputBin|Output Tray -CHOICE|outupper|Upper tray -CHOICE|outlower|Lower tray -CHOICE|outbin2|Tray 2 -CHOICE|outbin3|Tray 3 -CHOICE|outbin4|Tray 4 -CHOICE|outbin5|Tray 5 -CHOICE|outbin6|Tray 6 -CHOICE|outbin7|Tray 7 -CHOICE|outbin8|Tray 8 -CHOICE|outbin9|Tray 9 -CHOICE|default|Default setting -DEFAULT|default -ENDGROUP -GROUP|others|Others -OPTION|Duplex|Duplex -CHOICE|simplex|Simplex -CHOICE|duplex|Duplex -CHOICE|duplexshort|Duplex (short edge) -CHOICE|tumble|Tumble -CHOICE|default|Default setting -DEFAULT|default -OPTION|Resolution|Printing Resolution -CHOICE|300|300 DPI -CHOICE|600|600 DPI -CHOICE|1200|1200 DPI -CHOICE|default|Default setting -DEFAULT|default -ENDGROUP -GROUP|advanced|Advanced Settings -OPTION|filter|Filter options (comma sepatared)|STRING -OPTION|lpr|LPR options (comma separated)|STRING -ENDGROUP diff --git a/kdeprint/lpr/lprngtoolhandler.cpp b/kdeprint/lpr/lprngtoolhandler.cpp deleted file mode 100644 index 1d76cf2f5..000000000 --- a/kdeprint/lpr/lprngtoolhandler.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "lprngtoolhandler.h" -#include "printcapentry.h" -#include "kmprinter.h" -#include "util.h" -#include "lprsettings.h" -#include "driver.h" -#include "kmmanager.h" -#include "kprinter.h" - -#include <tqfile.h> -#include <tqtextstream.h> -#include <klocale.h> -#include <kdebug.h> -#include <kstandarddirs.h> - -LPRngToolHandler::LPRngToolHandler(KMManager *mgr) -: LprHandler("lprngtool", mgr) -{ -} - -bool LPRngToolHandler::validate(PrintcapEntry *entry) -{ - if (entry->comment.startsWith("##LPRNGTOOL##") && - entry->comment.find("UNKNOWN") == -1) - return true; - return false; -} - -bool LPRngToolHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool shortmode) -{ - TQString str, lp; - - // look for type in comment - TQStringList l = TQStringList::split(' ', entry->comment, false); - lp = entry->field("lp"); - if (l.count() < 1) - return false; - - if (l[1] == "DEVICE" || l[1] == "SOCKET" || l[1] == "QUEUE") - LprHandler::completePrinter(prt, entry, shortmode); - else if (l[1] == "SMB") - { - TQMap<TQString,TQString> opts = parseXferOptions(entry->field("xfer_options")); - TQString user, pass; - loadAuthFile(LprSettings::self()->baseSpoolDir() + "/" + entry->name + "/" + opts["authfile"], user, pass); - TQString uri = buildSmbURI( - opts[ "workgroup" ], - opts[ "host" ], - opts[ "printer" ], - user, - pass ); - prt->setDevice( uri ); - prt->setLocation(i18n("Network printer (%1)").arg("smb")); - } - - // look for comment - if (!(str=entry->field("cm")).isEmpty()) - prt->setDescription(str); - - // driver - //if (!shortmode) - //{ - if (!(str=entry->field("ifhp")).isEmpty()) - { - TQString model; - int p = str.find("model"); - if (p != -1) - { - p = str.find('=', p); - if (p != -1) - { - p++; - int q = str.find(',', p); - if (q == -1) - model = str.mid(p); - else - model = str.mid(p, q-p); - } - } - prt->setDriverInfo(i18n("IFHP Driver (%1)").arg((model.isEmpty() ? i18n("unknown") : model))); - prt->setOption("driverID", model); - } - //} - return true; -} - -TQMap<TQString,TQString> LPRngToolHandler::parseXferOptions(const TQString& str) -{ - uint p(0), q; - TQMap<TQString,TQString> opts; - TQString key, val; - - while (p < str.length()) - { - key = val = TQString::null; - // skip spaces - while (p < str.length() && str[p].isSpace()) - p++; - q = p; - while (q < str.length() && str[q] != '=') - q++; - key = str.mid(p, q-p); - p = q+2; - while (p < str.length() && str[p] != '"') - p++; - val = str.mid(q+2, p-q-2); - if (!key.isEmpty()) - opts[key] = val; - p++; - } - return opts; -} - -void LPRngToolHandler::loadAuthFile(const TQString& filename, TQString& user, TQString& pass) -{ - TQFile f(filename); - if (f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) - continue; - int p = line.find('='); - if (p != -1) - { - TQString key = line.left(p); - if (key == "username") - user = line.mid(p+1); - else if (key == "password") - pass = line.mid(p+1); - } - } - } -} - -DrMain* LPRngToolHandler::loadDriver(KMPrinter *prt, PrintcapEntry *entry, bool config) -{ - if (entry->field("lprngtooloptions").isEmpty()) - { - manager()->setErrorMsg(i18n("No driver defined for that printer. It might be a raw printer.")); - return NULL; - } - - DrMain* driver = loadToolDriver(locate("data", "tdeprint/lprngtooldriver1")); - if (driver) - { - TQString model = prt->option("driverID"); - driver->set("text", i18n("LPRngTool Common Driver (%1)").arg((model.isEmpty() ? i18n("unknown") : model))); - if (!model.isEmpty()) - driver->set("driverID", model); - TQMap<TQString,TQString> opts = parseZOptions(entry->field("prefix_z")); - opts["lpr"] = entry->field("lpr"); - driver->setOptions(opts); - // if not configuring, don't show the "lpr" options - if (!config) - driver->removeOptionGlobally("lpr"); - } - return driver; -} - -DrMain* LPRngToolHandler::loadDbDriver(const TQString& s) -{ - int p = s.find('/'); - DrMain* driver = loadToolDriver(locate("data", "tdeprint/lprngtooldriver1")); - if (driver) - driver->set("driverID", s.mid(p+1)); - return driver; -} - -TQValueList< TQPair<TQString,TQStringList> > LPRngToolHandler::loadChoiceDict(const TQString& filename) -{ - TQFile f(filename); - TQValueList< TQPair<TQString,TQStringList> > dict; - if (f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line, key; - TQStringList l; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("OPTION")) - { - if (l.count() > 0 && !key.isEmpty()) - dict << TQPair<TQString,TQStringList>(key, l); - l.clear(); - key = TQString::null; - if (line.contains('|') == 2 || line.right(7) == "BOOLEAN") - { - int p = line.find('|', 7); - key = line.mid(7, p-7); - } - } - else if (line.startsWith("CHOICE")) - { - int p = line.find('|', 7); - l << line.mid(7, p-7); - } - } - } - return dict; -} - -TQMap<TQString,TQString> LPRngToolHandler::parseZOptions(const TQString& optstr) -{ - TQMap<TQString,TQString> opts; - TQStringList l = TQStringList::split(',', optstr, false); - if (l.count() == 0) - return opts; - - if (m_dict.count() == 0) - m_dict = loadChoiceDict(locate("data", "tdeprint/lprngtooldriver1")); - - TQString unknown; - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - bool found(false); - for (TQValueList< TQPair<TQString,TQStringList> >::ConstIterator p=m_dict.begin(); p!=m_dict.end() && !found; ++p) - { - if ((*p).second.find(*it) != (*p).second.end()) - { - opts[(*p).first] = (*it); - found = true; - } - } - if (!found) - { - unknown.append(*it).append(','); - } - } - if (!unknown.isEmpty()) - { - unknown.truncate(unknown.length()-1); - opts["filter"] = unknown; - } - return opts; -} - -TQString LPRngToolHandler::filterDir() -{ - return driverDirectory(); -} - -TQString LPRngToolHandler::driverDirInternal() -{ - return locateDir("filters", "/usr/lib:/usr/local/lib:/opt/lib:/usr/libexec:/usr/local/libexec:/opt/libexec"); -} - -PrintcapEntry* LPRngToolHandler::createEntry(KMPrinter *prt) -{ - TQString prot = prt->deviceProtocol(); - if (prot != "parallel" && prot != "lpd" && prot != "smb" && prot != "socket") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - PrintcapEntry *entry = new PrintcapEntry; - entry->addField("cm", Field::String, prt->description()); - TQString lp, comment("##LPRNGTOOL## "); - if (prot == "parallel") - { - comment.append("DEVICE "); - lp = prt->device().mid( 9 ); - entry->addField("rw@", Field::Boolean); - } - else if (prot == "socket") - { - comment.append("SOCKET "); - KURL url( prt->device() ); - lp = url.host(); - if (url.port() == 0) - lp.append("%9100"); - else - lp.append("%").append(TQString::number(url.port())); - } - else if (prot == "lpd") - { - comment.append("QUEUE "); - KURL url( prt->device() ); - lp = url.path().mid(1) + "@" + url.host(); - } - else if (prot == "smb") - { - comment.append("SMB "); - lp = "| " + filterDir() + "/smbprint"; - TQString work, server, printer, user, passwd; - if ( splitSmbURI( prt->device(), work, server, printer, user, passwd ) ) - { - entry->addField("xfer_options", Field::String, TQString::tqfromLatin1("authfile=\"auth\" crlf=\"0\" hostip=\"\" host=\"%1\" printer=\"%2\" remote_mode=\"SMB\" share=\"//%3/%4\" workgroup=\"%5\"").arg(server).arg(printer).arg(server).arg(printer).arg(work)); - TQFile authfile(LprSettings::self()->baseSpoolDir() + "/" + prt->printerName() + "/auth"); - if (authfile.open(IO_WriteOnly)) - { - TQTextStream t(&authfile); - t << "username=" << user << endl; - t << "password=" << passwd << endl; - authfile.close(); - } - } - else - { - manager()->setErrorMsg( i18n( "Invalid printer backend specification: %1" ).arg( prt->device() ) ); - delete entry; - return NULL; - } - } - - if (prt->driver()) - { - DrMain *driver = prt->driver(); - comment.append("filtertype=IFHP ifhp_options=status@,sync@,pagecount@,waitend@ printerdb_entry="); - comment.append(driver->get("driverID")); - entry->addField("ifhp", Field::String, TQString::tqfromLatin1("model=%1,status@,sync@,pagecount@,waitend@").arg(driver->get("driverID"))); - entry->addField("lprngtooloptions", Field::String, TQString::tqfromLatin1("FILTERTYPE=\"IFHP\" IFHP_OPTIONS=\"status@,sync@,pagecount@,waitend@\" PRINTERDB_ENTRY=\"%1\"").arg(driver->get("driverID"))); - TQMap<TQString,TQString> opts; - TQString optstr; - driver->getOptions(opts, false); - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - if (it.key() != "lpr") - optstr.append(*it).append(","); - if (!optstr.isEmpty()) - { - optstr.truncate(optstr.length()-1); - entry->addField("prefix_z", Field::String, optstr); - } - if (!opts["lpr"].isEmpty()) - entry->addField("lpr", Field::String, opts["lpr"]); - } - - entry->addField("lp", Field::String, lp); - entry->comment = comment; - - return entry; -} - -bool LPRngToolHandler::savePrinterDriver(KMPrinter*, PrintcapEntry *entry, DrMain *driver, bool *mustSave) -{ - // save options in the "prefix_z" field and tell the manager to save the printcap file - TQMap<TQString,TQString> opts; - TQString optstr; - driver->getOptions(opts, false); - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - if (it.key() != "lpr") - optstr.append(*it).append(","); - if (!optstr.isEmpty()) - optstr.truncate(optstr.length()-1); - // save options in any case, otherwise nothing will happen whn - // options are reset to their default value - entry->addField("prefix_z", Field::String, optstr); - entry->addField("lpr", Field::String, opts["lpr"]); - if (mustSave) - *mustSave = true; - return true; -} - -TQString LPRngToolHandler::printOptions(KPrinter *printer) -{ - TQString optstr; - TQMap<TQString,TQString> opts = printer->options(); - for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key() == "lpr" || it.key().startsWith( "app-" )) - continue; - optstr.append(*it).append(","); - } - if (!optstr.isEmpty()) - { - optstr.truncate(optstr.length()-1); - optstr.prepend("-Z '").append("'"); - } - return optstr; -} diff --git a/kdeprint/lpr/lprngtoolhandler.h b/kdeprint/lpr/lprngtoolhandler.h deleted file mode 100644 index 49641ca3a..000000000 --- a/kdeprint/lpr/lprngtoolhandler.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 LPRNGTOOLHANDLER_H -#define LPRNGTOOLHANDLER_H - -#include "lprhandler.h" -#include <tqmap.h> -#include <tqstringlist.h> -#include <tqpair.h> - -class LPRngToolHandler : public LprHandler -{ -public: - LPRngToolHandler(KMManager *mgr = 0); - - bool validate(PrintcapEntry*); - bool completePrinter(KMPrinter*, PrintcapEntry*, bool = true); - DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - DrMain* loadDbDriver(const TQString&); - PrintcapEntry* createEntry(KMPrinter*); - bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - TQString printOptions(KPrinter*); - -protected: - TQMap<TQString,TQString> parseXferOptions(const TQString&); - void loadAuthFile(const TQString&, TQString&, TQString&); - TQValueList< TQPair<TQString,TQStringList> > loadChoiceDict(const TQString&); - TQMap<TQString,TQString> parseZOptions(const TQString&); - TQString filterDir(); - TQString driverDirInternal(); - - -private: - TQValueList< TQPair<TQString,TQStringList> > m_dict; -}; - -#endif diff --git a/kdeprint/lpr/lprsettings.cpp b/kdeprint/lpr/lprsettings.cpp deleted file mode 100644 index 0c1cec2a9..000000000 --- a/kdeprint/lpr/lprsettings.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001,2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "lprsettings.h" -#include "kmmanager.h" -#include "kmfactory.h" - -#include <kconfig.h> -#include <tqfile.h> -#include <tqtextstream.h> - -#define LPDCONF "/etc/lpd.conf" -#define PRINTCAP "/etc/printcap" - -LprSettings* LprSettings::m_self = 0; - -LprSettings::LprSettings(TQObject *parent, const char *name) -: TQObject(parent, name), KPReloadObject(true) -{ - init(); -} - -LprSettings::~LprSettings() -{ - m_self = 0; -} - -LprSettings* LprSettings::self() -{ - if (!m_self) - { - m_self = new LprSettings(KMManager::self(), "LprSettings"); - } - return m_self; -} - -void LprSettings::init() -{ - // LPR/LPRng mode - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("LPR"); - TQString modestr = conf->readEntry("Mode"); - if (modestr == "LPRng") - m_mode = LPRng; - else if (modestr == "LPR") - m_mode = LPR; - else - { - // try to guess - if (TQFile::exists(LPDCONF)) - m_mode = LPRng; - else - m_mode = LPR; - } - - // Printcap file - m_printcapfile = TQString(); - m_local = true; - - // Spool directory - m_spooldir = "/var/spool/lpd"; -} - -TQString LprSettings::printcapFile() -{ - if (m_printcapfile.isEmpty()) - { - // default value - m_printcapfile = PRINTCAP; - if (m_mode == LPRng) - { - // look into /etc/lpd/conf file - TQFile cf(LPDCONF); - if (cf.open(IO_ReadOnly)) - { - TQTextStream t(&cf); - TQString line; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("printcap_path")) - { - TQString filename = line.mid(14).stripWhiteSpace(); - if (filename[0] != '|') - m_printcapfile = filename; - else - { - // should download the printcap file - // and set m_local to false - } - } - } - } - } - } - return m_printcapfile; -} - -TQString LprSettings::defaultRemoteHost() -{ - if (m_defaultremotehost.isEmpty()) - { - m_defaultremotehost = "localhost"; - TQFile cf(LPDCONF); - if (cf.open(IO_ReadOnly)) - { - TQTextStream t(&cf); - TQString line; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("default_remote_host")) - { - TQString hostname = line.mid(20).stripWhiteSpace(); - m_defaultremotehost = hostname; - } - } - } - } - return m_defaultremotehost; -} - -void LprSettings::reload() -{ -} - -void LprSettings::configChanged() -{ - init(); -} diff --git a/kdeprint/lpr/lprsettings.h b/kdeprint/lpr/lprsettings.h deleted file mode 100644 index 01abbeeb3..000000000 --- a/kdeprint/lpr/lprsettings.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001,2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 LPRSETTINGS_H -#define LPRSETTINGS_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqobject.h> -#include <tdeprint/kpreloadobject.h> - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class LprSettings : public TQObject, public KPReloadObject -{ -public: - LprSettings(TQObject *parent = 0, const char *name = 0); - ~LprSettings(); - - static LprSettings* self(); - - enum Mode { LPR, LPRng }; - Mode mode() const { return m_mode; } - void setMode(Mode m) { m_mode = m; } - TQString printcapFile(); - TQString defaultRemoteHost(); - bool isLocalPrintcap() { return m_local; } - TQString baseSpoolDir() { return m_spooldir; } - -protected: - void init(); - void reload(); - void configChanged(); - -private: - static LprSettings* m_self; - Mode m_mode; - QString m_printcapfile; - bool m_local; - QString m_spooldir; - TQString m_defaultremotehost; -}; - -#endif diff --git a/kdeprint/lpr/make_driver_db_lpr.c b/kdeprint/lpr/make_driver_db_lpr.c deleted file mode 100644 index fabbcb2fe..000000000 --- a/kdeprint/lpr/make_driver_db_lpr.c +++ /dev/null @@ -1,192 +0,0 @@ -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> -#include <stdlib.h> -#include <unistd.h> -#include <ctype.h> - -#include "driverparse.h" - -void simplifyModel(const char *modelname) -{ - char *g; - - if ((g=strchr(modelname, ',')) != NULL) - *g = 0; - else if ((g=strchr(modelname, '(')) != NULL || (g=strchr(modelname, '{')) != NULL) - { - if (g != modelname) - { - if (isspace(*(g-1))) - g--; - *g = 0; - } - } -} - -int parseApsFile(const char *filename, FILE *output) -{ - FILE *apsfile; - char buf[256], modelname[256]; - char *c, *d; - - apsfile = fopen(filename, "r"); - if (apsfile == NULL) - return 0; - while (fgets(buf, 255, apsfile) != NULL) - { - if ((c = strchr(buf, '\n')) != NULL) - *c = 0; - if (strlen(buf) == 0 || buf[0] == '#' || (c = strchr(buf, '|')) == NULL) - continue; - *c = 0; - fprintf(output, "FILE=apsfilter/%s\n", c+1); - d = strchr(buf, ' '); - if (d) - { - *d = 0; - strlcpy(modelname, d+1, 255); - simplifyModel(modelname); - fprintf(output, "MANUFACTURER=%s\n", buf); - fprintf(output, "MODELNAME=%s\n", modelname); - fprintf(output, "MODEL=%s\n", modelname); - fprintf(output, "DESCRIPTION=%s %s (APSFilter + %s)\n", buf, d+1, c+1); - } - else - { - strlcpy(modelname, buf, 255); - simplifyModel(modelname); - fprintf(output, "MANUFACTURER=Unknown\n"); - fprintf(output, "MODELNAME=%s\n", modelname); - fprintf(output, "MODEL=%s\n", modelname); - fprintf(output, "DESCRIPTION=%s (APSFilter + %s)\n", buf, c+1); - } - fprintf(output, "\n"); - } - fclose(apsfile); - return 1; -} - -void initAps(const char *base) -{ - char drFile[256]; - DIR *apsdir; - struct dirent *d; - int gsversion = 0; - - if (strstr(base, "apsfilter") == NULL) - return; - - apsdir = opendir(base); - if (apsdir == NULL) - return; - while ((d = readdir(apsdir)) != NULL) - { - if (strncmp(d->d_name, "printer-", 8) != 0) - continue; - if (isdigit(d->d_name[8])) - { - if (gsversion) - continue; - gsversion = 1; - } - snprintf(drFile, 256, "apsfilter:%s/%s", base, d->d_name); - addFile(drFile); - } - closedir(apsdir); -} - -char* nextWord(char *c) -{ - char *d = c; - while (*d && isspace(*d)) - d++; - return d; -} - -int parseIfhpFile(const char *filename, FILE *output) -{ - char buf[1024]; - FILE *in; - char model[32], desc[256]; - - in = fopen(filename, "r"); - if (in == NULL) - return 0; - while (fgets(buf, 1023, in)) - { - char *c; - if ((c = strchr(buf, '\n')) != NULL) - *c = 0; - c = buf; - while (*c && isspace(*c)) - c++; - if (*c == '#') - continue; - if (strncmp(c, "IfhpModel:", 10) == 0) - strlcpy(model, nextWord(c+11), 31); - else if (strncmp(c, "Description:", 12) == 0) - strlcpy(desc, nextWord(c+13), 255); - else if (strncmp(c, "EndEntry", 8) == 0) - { - char *d = desc, *e, make[32] = {0}; - int first_time = 1; - do - { - e = strchr(d, ','); - if (e) - *e = 0; - if (first_time) - { - char *f = strchr(d, ' '); - if (f) - strlcpy(make, d, f-d); - first_time = 0; - } - if (strstr(d, "Family") == NULL) - { - char modelname[256] = {0}; - - strlcpy(modelname, d, 255); - simplifyModel(modelname); - fprintf(output, "FILE=lprngtool/%s\n", model); - fprintf(output, "MANUFACTURER=%s\n", make); - fprintf(output, "MODEL=%s\n", modelname); - fprintf(output, "MODELNAME=%s\n", modelname); - fprintf(output, "DESCRIPTION=%s (IFHP + %s)\n", d, model); - fprintf(output, "\n"); - } - if (e) - { - d = e+1; - while (*d && isspace(*d)) - d++; - } - } while (e); - } - } - fclose(in); - return 1; -} - -void initIfhp(const char *base) -{ - char path[256]; - - snprintf(path, 255, "lprngtool:%s/printerdb", base); - if (access(path+10, R_OK) == 0) - { - addFile(path); - } -} - -int main(int argc, char **argv) -{ - initFoomatic(); - registerHandler("apsfilter:", initAps, parseApsFile); - registerHandler("lprngtool:", initIfhp, parseIfhpFile); - return execute(argc, argv); -} diff --git a/kdeprint/lpr/matichandler.cpp b/kdeprint/lpr/matichandler.cpp deleted file mode 100644 index ef2f1584b..000000000 --- a/kdeprint/lpr/matichandler.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "matichandler.h" -#include "printcapentry.h" -#include "kmprinter.h" -#include "matichelper.h" -#include "driver.h" -#include "kpipeprocess.h" -#include "kmmanager.h" -#include "kprinter.h" -#include "lprsettings.h" -#include "util.h" -#include "foomatic2loader.h" - -#include <klocale.h> -#include <kstandarddirs.h> -#include <kapplication.h> -#include <kdebug.h> -#include <kprocess.h> -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqregexp.h> - -#include <stdlib.h> -#include <sys/wait.h> - -MaticHandler::MaticHandler(KMManager *mgr) -: LprHandler("foomatic", mgr) -{ - TQString PATH = getenv("PATH"); - PATH.append(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - m_exematicpath = KStandardDirs::findExe("lpdomatic", PATH); - m_ncpath = KStandardDirs::findExe("nc"); - m_smbpath = KStandardDirs::findExe("smbclient"); - m_rlprpath = KStandardDirs::findExe("rlpr"); -} - -bool MaticHandler::validate(PrintcapEntry *entry) -{ - if (entry) - return (entry->field("if").right(9) == "lpdomatic"); - return false; -} - -KMPrinter* MaticHandler::createPrinter(PrintcapEntry *entry) -{ - if (entry && validate(entry)) - { - KMPrinter *prt = new KMPrinter; - prt->setName(entry->name); - prt->setPrinterName(entry->name); - prt->setType(KMPrinter::Printer); - //if (entry->field("lp") == "/dev/null" || entry->field("lp").isEmpty()) - // prt->addType(KMPrinter::Remote); - return prt; - } - return NULL; -} - -bool MaticHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool shortmode) -{ - TQString val = entry->field("lp"); - if (val == "/dev/null" || val.isEmpty()) - { - prt->setLocation(i18n("Network printer")); - } - else - { - prt->setLocation(i18n("Local printer on %1").arg(val)); - KURL url(val); - if (val.find("usb") != -1) - url.setProtocol("usb"); - else - url.setProtocol("parallel"); - prt->setDevice(url.url()); - } - prt->setDescription(entry->aliases.join(", ")); - - if (!shortmode) - { - Foomatic2Loader loader; - if ( loader.readFromFile( maticFile( entry ) ) ) - { - TQString postpipe = loader.data()[ "POSTPIPE" ].toString(); - if (!postpipe.isEmpty()) - { - KURL url ( parsePostpipe(postpipe) ); - if (!url.isEmpty()) - { - TQString ds = TQString::tqfromLatin1("%1 (%2)").arg(prt->location()).arg(url.protocol()); - prt->setDevice(url.url()); - prt->setLocation(ds); - } - } - - TQMap<TQString,TQVariant> m = loader.data()[ "VAR" ].toMap(); - if ( !m.isEmpty() ) - { - prt->setManufacturer(m["make"].toString()); - prt->setModel(m["model"].toString()); - prt->setDriverInfo(TQString::tqfromLatin1("%1 %2 (%3)").arg(prt->manufacturer()).arg(prt->model()).arg(m["driver"].toString())); - } - } - } - - return true; -} - -TQString MaticHandler::parsePostpipe(const TQString& s) -{ - TQString url; - int p = s.findRev('|'); - TQStringList args = TQStringList::split(" ", s.right(s.length()-p-1)); - - if (args.count() != 0) - { - // socket printer - if (args[0].right(3) == "/nc") - { - url = "socket://" + args[ 1 ]; - if ( args.count() > 2 ) - url += ":" + args[ 2 ]; - else - url += ":9100"; - } - // smb printer - else if (args[0].right(10) == "/smbclient") - { - TQStringList host_components = TQStringList::split(TQRegExp("/|\\\\\""), args[1], false); - TQString workgrp, user, pass; - for (uint i=2; i<args.count(); i++) - { - if (args[i] == "-U") - user = args[++i]; - else if (args[i] == "-W") - workgrp = args[++i]; - else if (args[i][0] != '-' && i == 2) - pass = args[i]; - } - url = buildSmbURI( workgrp, host_components[ 0 ], host_components[ 1 ], user, pass ); - } - // remote printer - else if (args[0].right(5) == "/rlpr") - { - uint i=1; - while (i < args.count()) - { - if (args[i].left(2) != "-P") - i++; - else - { - TQString host = (args[i].length() == 2 ? args[i+1] : args[i].right(args[i].length()-2)); - int p = host.find("\\@"); - if (p != -1) - { - url = "lpd://" + host.right(host.length()-p-2) + "/" + host.left(p); - } - break; - } - } - } - } - - return url; -} - -TQString MaticHandler::createPostpipe(const TQString& _url) -{ - KURL url( _url ); - TQString prot = url.protocol(); - TQString str; - if (prot == "socket") - { - str += ("| " + m_ncpath); - str += (" " + url.host()); - if (url.port() != 0) - str += (" " + TQString::number(url.port())); - } - else if (prot == "lpd") - { - str += ("| " + m_rlprpath + " -q -h"); - TQString h = url.host(), p = url.path().mid(1); - str += (" -P " + p + "\\@" + h); - } - else if (prot == "smb") - { - TQString work, server, printer, user, passwd; - if ( splitSmbURI( _url, work, server, printer, user, passwd ) ) - { - str += ("| (\\n echo \\\"print -\\\"\\n cat \\n) | " + m_smbpath); - str += (" \\\"//" + server + "/" + printer + "\\\""); - if (!passwd.isEmpty()) - str += (" " + passwd); - if (!user.isEmpty()) - str += (" -U " + user); - if (!work.isEmpty()) - str += (" -W " + work); - str += " -N -P"; - } - } - return str; -} - -DrMain* MaticHandler::loadDriver(KMPrinter*, PrintcapEntry *entry, bool) -{ - // we need to use a copy of the driver, as the driver - // is not self-contained. If the printer is removed (when - // changing printer name), the template would be also removed - TQString origfilename = maticFile(entry); - TQString filename = locateLocal("tmp", "foomatic_" + kapp->randomString(8)); - ::system(TQFile::encodeName("cp " + KProcess::quote(origfilename) + " " + KProcess::quote(filename))); - DrMain *driver = Foomatic2Loader::loadDriver(filename); - if (driver) - { - driver->set("template", filename); - driver->set("temporary", "true"); - return driver; - } - else - return NULL; -} - -DrMain* MaticHandler::loadDbDriver(const TQString& path) -{ - TQStringList comps = TQStringList::split('/', path, false); - if (comps.count() < 3 || comps[0] != "foomatic") - { - manager()->setErrorMsg(i18n("Internal error.")); - return NULL; - } - - TQString tmpFile = locateLocal("tmp", "foomatic_" + kapp->randomString(8)); - TQString PATH = getenv("PATH") + TQString::tqfromLatin1(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - TQString exe = KStandardDirs::findExe("foomatic-datafile", PATH); - if (exe.isEmpty()) - { - manager()->setErrorMsg(i18n("Unable to find the executable foomatic-datafile " - "in your PATH. Check that Foomatic is correctly installed.")); - return NULL; - } - - KPipeProcess in; - TQFile out(tmpFile); - TQString cmd = KProcess::quote(exe); - cmd += " -t lpd -d "; - cmd += KProcess::quote(comps[2]); - cmd += " -p "; - cmd += KProcess::quote(comps[1]); - if (in.open(cmd) && out.open(IO_WriteOnly)) - { - TQTextStream tin(&in), tout(&out); - TQString line; - while (!tin.atEnd()) - { - line = tin.readLine(); - tout << line << endl; - } - in.close(); - out.close(); - - DrMain *driver = Foomatic2Loader::loadDriver(tmpFile); - if (driver) - { - driver->set("template", tmpFile); - driver->set("temporary", tmpFile); - return driver; - } - } - manager()->setErrorMsg(i18n("Unable to create the Foomatic driver [%1,%2]. " - "Either that driver does not exist, or you don't have " - "the required permissions to perform that operation.").arg(comps[1]).arg(comps[2])); - return NULL; -} - -bool MaticHandler::savePrinterDriver(KMPrinter *prt, PrintcapEntry *entry, DrMain *driver, bool*) -{ - TQFile tmpFile(locateLocal("tmp", "foomatic_" + kapp->randomString(8))); - TQFile inFile(driver->get("template")); - TQString outFile = maticFile(entry); - bool result(false); - TQString postpipe = createPostpipe(prt->device()); - - if (inFile.open(IO_ReadOnly) && tmpFile.open(IO_WriteOnly)) - { - TQTextStream tin(&inFile), tout(&tmpFile); - TQString line, optname; - int p(-1), q(-1); - if (!postpipe.isEmpty()) - tout << "$postpipe = \"" << postpipe << "\";" << endl; - while (!tin.atEnd()) - { - line = tin.readLine(); - if (line.stripWhiteSpace().startsWith("$postpipe")) - continue; - else if ((p = line.find("'name'")) != -1) - { - p = line.find('\'', p+6)+1; - q = line.find('\'', p); - optname = line.mid(p, q-p); - } - else if ((p = line.find("'default'")) != -1) - { - DrBase *opt = driver->findOption(optname); - if (opt) - { - tout << line.left(p+9) << " => '" << opt->valueText() << "'," << endl; - continue; - } - } - tout << line << endl; - } - inFile.close(); - tmpFile.close(); - - TQString cmd = "mv " + KProcess::quote(tmpFile.name()) + " " + KProcess::quote(outFile); - int status = ::system(TQFile::encodeName(cmd).data()); - TQFile::remove(tmpFile.name()); - result = (status != -1 && WEXITSTATUS(status) == 0); - } - - if (!result) - manager()->setErrorMsg(i18n("You probably don't have the required permissions " - "to perform that operation.")); - TQFile::remove(tmpFile.name()); - if (!result || entry->field("ppdfile").isEmpty()) - return result; - else - return savePpdFile(driver, entry->field("ppdfile")); -} - -bool MaticHandler::savePpdFile(DrMain *driver, const TQString& filename) -{ - TQString mdriver(driver->get("matic_driver")), mprinter(driver->get("matic_printer")); - if (mdriver.isEmpty() || mprinter.isEmpty()) - return true; - - TQString PATH = getenv("PATH") + TQString::tqfromLatin1(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - TQString exe = KStandardDirs::findExe("foomatic-datafile", PATH); - if (exe.isEmpty()) - { - manager()->setErrorMsg(i18n("Unable to find the executable foomatic-datafile " - "in your PATH. Check that Foomatic is correctly installed.")); - return false; - } - - KPipeProcess in; - TQFile out(filename); - if (in.open(exe + " -t cups -d " + mdriver + " -p " + mprinter) && out.open(IO_WriteOnly)) - { - TQTextStream tin(&in), tout(&out); - TQString line, optname; - TQRegExp re("^\\*Default(\\w+):"), foo("'name'\\s+=>\\s+'(\\w+)'"), foo2("'\\w+'\\s*,\\s*$"); - while (!tin.atEnd()) - { - line = tin.readLine(); - if (line.startsWith("*% COMDATA #")) - { - if (line.find("'default'") != -1) - { - DrBase *opt = (optname.isEmpty() ? NULL : driver->findOption(optname)); - if (opt) - { - line.replace(foo2, "'"+opt->valueText()+"',"); - } - } - else if (foo.search(line) != -1) - optname = foo.cap(1); - } - else if (re.search(line) != -1) - { - DrBase *opt = driver->findOption(re.cap(1)); - if (opt) - { - TQString val = opt->valueText(); - if (opt->type() == DrBase::Boolean) - val = (val == "1" ? "True" : "False"); - tout << "*Default" << opt->name() << ": " << val << endl; - continue; - } - } - tout << line << endl; - } - in.close(); - out.close(); - - return true; - } - manager()->setErrorMsg(i18n("Unable to create the Foomatic driver [%1,%2]. " - "Either that driver does not exist, or you don't have " - "the required permissions to perform that operation.").arg(mdriver).arg(mprinter)); - - return false; -} - -PrintcapEntry* MaticHandler::createEntry(KMPrinter *prt) -{ - KURL url( prt->device() ); - TQString prot = url.protocol(); - if ((prot != "lpd" || m_rlprpath.isEmpty()) && - (prot != "socket" || m_ncpath.isEmpty()) && - (prot != "smb" || m_smbpath.isEmpty()) && - prot != "parallel") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - if (m_exematicpath.isEmpty()) - { - manager()->setErrorMsg(i18n("Unable to find executable lpdomatic. " - "Check that Foomatic is correctly installed " - "and that lpdomatic is installed in a standard " - "location.")); - return NULL; - } - PrintcapEntry *entry = new PrintcapEntry; - entry->addField("lf", Field::String, "/var/log/lp-errs"); - entry->addField("lp", Field::String, (prot != "parallel" ? "/dev/null" : url.path())); - entry->addField("if", Field::String, m_exematicpath); - if (LprSettings::self()->mode() == LprSettings::LPRng) - { - entry->addField("filter_options", Field::String, " --lprng $Z /etc/foomatic/lpd/"+prt->printerName()+".lom"); - entry->addField("force_localhost", Field::Boolean); - entry->addField("ppdfile", Field::String, "/etc/foomatic/"+prt->printerName()+".ppd"); - } - else - entry->addField("af", Field::String, "/etc/foomatic/lpd/"+prt->printerName()+".lom"); - if (!prt->description().isEmpty()) - entry->aliases << prt->description(); - return entry; -} - -bool MaticHandler::removePrinter(KMPrinter *prt, PrintcapEntry *entry) -{ - // remove Foomatic driver - TQString af = entry->field("af"); - if (af.isEmpty()) - return true; - if (!TQFile::remove(af)) - { - manager()->setErrorMsg(i18n("Unable to remove driver file %1.").arg(af)); - return false; - } - return true; -} - -TQString MaticHandler::printOptions(KPrinter *printer) -{ - TQMap<TQString,TQString> opts = printer->options(); - TQString str; - for (TQMap<TQString,TQString>::Iterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key().startsWith( "app-" )) - continue; - str += (" " + it.key() + "=" + (*it)); - } - if (!str.isEmpty()) - str.prepend("-J '").append("'"); - return str; -} - -TQString MaticHandler::driverDirInternal() -{ - return locateDir("foomatic/db/source", "/usr/share:/usr/local/share:/opt/share"); -} diff --git a/kdeprint/lpr/matichandler.h b/kdeprint/lpr/matichandler.h deleted file mode 100644 index e30eee39e..000000000 --- a/kdeprint/lpr/matichandler.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 MATICHANDLER_H -#define MATICHANDLER_H - -#include "lprhandler.h" - -#include <kurl.h> - -class MaticBlock; - -class MaticHandler : public LprHandler -{ -public: - MaticHandler(KMManager *mgr = 0); - - bool validate(PrintcapEntry*); - KMPrinter* createPrinter(PrintcapEntry*); - bool completePrinter(KMPrinter*, PrintcapEntry*, bool = true); - DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - DrMain* loadDbDriver(const TQString&); - bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - PrintcapEntry* createEntry(KMPrinter*); - bool removePrinter(KMPrinter*, PrintcapEntry*); - TQString printOptions(KPrinter*); - -protected: - TQString driverDirInternal(); - -private: - TQString parsePostpipe(const TQString&); - TQString createPostpipe(const TQString&); - bool savePpdFile(DrMain*, const TQString&); - -private: - TQString m_exematicpath; - TQString m_ncpath, m_smbpath, m_rlprpath; -}; - -#endif diff --git a/kdeprint/lpr/matichelper.cpp b/kdeprint/lpr/matichelper.cpp deleted file mode 100644 index ec0041b7c..000000000 --- a/kdeprint/lpr/matichelper.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "matichelper.h" -#include "printcapentry.h" -#include "driver.h" - -TQString maticFile(PrintcapEntry *entry) -{ - TQString s(entry->field("af")); - if (s.isEmpty()) - { - s = entry->field("filter_options"); - if (!s.isEmpty()) - { - int p = s.findRev(' '); - if (p != -1) - s = s.mid(p+1); - } - } - return s; -} diff --git a/kdeprint/lpr/matichelper.h b/kdeprint/lpr/matichelper.h deleted file mode 100644 index 5a2b64fe3..000000000 --- a/kdeprint/lpr/matichelper.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 MATICHELPER_H -#define MATICHELPER_H - -#include <tqstring.h> - -class PrintcapEntry; - -TQString maticFile(PrintcapEntry*); - -#endif diff --git a/kdeprint/lpr/printcapentry.cpp b/kdeprint/lpr/printcapentry.cpp deleted file mode 100644 index 9c83537e4..000000000 --- a/kdeprint/lpr/printcapentry.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001,2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "printcapentry.h" - -TQString Field::toString() const -{ - TQString s = name; - switch (type) - { - case String: - s += ("=" + value); - break; - case Integer: - s += ("#" + value); - break; - case Boolean: - if (!value.toInt()) - s += "@"; - break; - } - return s; -} - -bool PrintcapEntry::writeEntry(TQTextStream& t) -{ - t << comment << endl; - t << name; - if (aliases.count() > 0) - t << '|' << aliases.join("|"); - t << ':'; - for (TQMap<TQString,Field>::ConstIterator it=fields.begin(); it!=fields.end(); ++it) - { - t << '\\' << endl << " :"; - t << (*it).name; - switch ((*it).type) - { - case Field::String: - t << '=' << (*it).value << ':'; - break; - case Field::Integer: - t << '#' << (*it).value << ':'; - break; - case Field::Boolean: - t << ':'; - break; - default: - t << endl << endl; - return false; - } - } - t << endl; - if (!postcomment.isEmpty()) - t << postcomment << endl; - t << endl; - return true; -} - -void PrintcapEntry::addField(const TQString& name, Field::Type type, const TQString& value) -{ - Field f; - f.name = name; - f.type = type; - f.value = value; - fields[name] = f; -} diff --git a/kdeprint/lpr/printcapentry.h b/kdeprint/lpr/printcapentry.h deleted file mode 100644 index f8ba99197..000000000 --- a/kdeprint/lpr/printcapentry.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 PRINTCAPENTRY_H -#define PRINTCAPENTRY_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqstring.h> -#include <tqmap.h> -#include <tqstringlist.h> -#include <tqtextstream.h> - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class Field -{ -public: - enum Type { String, Integer, Boolean }; - Field() : type(String) {} - Field(const Field &f) : type(f.type), name(f.name), value(f.value) {} - Field& operator= (const Field& f) - { - type = f.type; - name = f.name; - value = f.value; - return (*this); - } - TQString toString() const; - - Type type; - TQString name; - TQString value; -}; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class PrintcapEntry -{ -public: - TQString name; - TQStringList aliases; - TQString comment; - TQMap<TQString,Field> fields; - TQString postcomment; - - bool has(const TQString& f) const { return fields.contains(f); } - TQString field(const TQString& f) const { return fields[f].value; } - bool writeEntry(TQTextStream&); - void addField(const TQString& name, Field::Type type = Field::Boolean, const TQString& value = TQString::null); -}; - -#endif diff --git a/kdeprint/lpr/printcapreader.cpp b/kdeprint/lpr/printcapreader.cpp deleted file mode 100644 index 00016c14f..000000000 --- a/kdeprint/lpr/printcapreader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "printcapreader.h" -#include "printcapentry.h" - -#include <tqfile.h> -#include <kdebug.h> - -void PrintcapReader::setPrintcapFile(TQFile *f) -{ - if (f->isOpen()) - { - m_stream.setDevice(TQT_TQIODEVICE(f)); - m_buffer = TQString::null; - } -} - -bool PrintcapReader::nextLine(TQString& line) -{ - if (m_stream.atEnd() && m_buffer.isEmpty()) - return false; - else if (!m_buffer.isEmpty()) - { - line = m_buffer; - m_buffer = TQString::null; - } - else - line = m_stream.readLine().stripWhiteSpace(); - // strip any '\' at the end - if (line[line.length()-1] == '\\') - line = line.left(line.length()-1).stripWhiteSpace(); - return true; -} - -void PrintcapReader::unputLine(const TQString& s) -{ - m_buffer = s; -} - -PrintcapEntry* PrintcapReader::nextEntry() -{ - if (!m_stream.tqdevice()) - return NULL; - - TQString line, comment, name, fields, buf; - // skip comments, keep last one - while (1) - { - if (!nextLine(line)) - return NULL; - else if (line.isEmpty()) - continue; - else if (line[0] == '#') - comment = line; - else - { - buf = line; - break; - } - } - - // look for the complete entry - while (1) - { - // we found the entry if we reached the end of file or - // found an empty line - if (!nextLine(line) || line.isEmpty()) - break; - // just skip comments - else if (line[0] == '#') - continue; - // lines starting with ':' or '|' are appended - else if (line[0] == ':' || line[0] == '|') - buf += line; - // otherwise it's another entry, put it back in the - // buffer - else - { - unputLine(line); - break; - } - } - - // now parse the entry - kdDebug() << "COMMENT: " << comment << endl; - kdDebug() << "LINE: " << buf << endl; - int p = buf.find(':'); - if (p == -1) - name = buf; - else - { - name = buf.left(p); - fields = buf.right(buf.length()-p-1); - } - - // construct the printcap entry - if (!name.isEmpty()) - { - PrintcapEntry *entry = new PrintcapEntry; - TQStringList l = TQStringList::split('|', name, false); - entry->name = l[0]; - entry->comment = comment; - // kdDebug() << "Printer: " << entry->name << endl; - // kdDebug() << "Aliases:" << endl; - for (uint i=1; i<l.count(); i++) - { - entry->aliases << l[i]; - // kdDebug() << " " << l[i] << endl; - } - if (!fields.isEmpty()) - { - // kdDebug() << "Fields:" << endl; - // kdDebug() << "(" << fields << ")" << endl; - l = TQStringList::split(':', fields, false); - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - Field f; - int p = (*it).find('='); - if (p == -1) - { - p = (*it).find('#'); - if (p == -1) - { - f.type = Field::Boolean; - p = (*it).find('@'); - if (p == -1) - { - f.name = (*it); - f.value = "1"; - } - else - { - f.name = (*it).left(p); - f.value = "0"; - } - } - else - { - f.type = Field::Integer; - f.name = (*it).left(p); - f.value = (*it).mid(p+1); - } - } - else - { - f.type = Field::String; - f.name = (*it).left(p); - f.value = (*it).mid(p+1); - if (f.value.startsWith("\"")) - f.value = f.value.mid(1, f.value.length()-2); - } - entry->fields[f.name] = f; - } - } - // kdDebug() << endl; - return entry; - } - return NULL; -} diff --git a/kdeprint/lpr/printcapreader.h b/kdeprint/lpr/printcapreader.h deleted file mode 100644 index 2236e5068..000000000 --- a/kdeprint/lpr/printcapreader.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 PRINTCAPREADER_H -#define PRINTCAPREADER_H - -#include <tqstring.h> -#include <tqtextstream.h> - -class TQFile; -class PrintcapEntry; - -class PrintcapReader -{ -public: - void setPrintcapFile(TQFile*); - PrintcapEntry* nextEntry(); - -private: - TQString m_buffer; - TQTextStream m_stream; - - bool nextLine(TQString&); - void unputLine(const TQString&); -}; - -#endif diff --git a/kdeprint/management/CMakeLists.txt b/kdeprint/management/CMakeLists.txt deleted file mode 100644 index 0e12299e6..000000000 --- a/kdeprint/management/CMakeLists.txt +++ /dev/null @@ -1,111 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdefx - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile - ${CMAKE_SOURCE_DIR}/tdeprint -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - kmmainview.h kmjobviewer.h kmprinterpage.h - kiconselectaction.h kmtimer.h - DESTINATION ${INCLUDE_INSTALL_DIR}/tdeprint ) - - -##### other data ################################ - -install( FILES - tileup.png tiledown.png side.png - DESTINATION ${DATA_INSTALL_DIR}/tdeprint ) - - -#### tdeprint_management ######################## - -set( target tdeprint_management ) - -set( ${target}_SRCS - kmdbcreator.cpp kmdriverdb.cpp kmdriverdbwidget.cpp - kmiconview.cpp kminfopage.cpp kmmainview.cpp kmpages.cpp - kmprinterview.cpp kmjobviewer.cpp jobitem.cpp kmpropwidget.cpp - kmpropcontainer.cpp kmpropertypage.cpp kmpropgeneral.cpp - cjanuswidget.cpp kmpropmembers.cpp kmpropbackend.cpp - kmpropdriver.cpp kmlistview.cpp kminstancepage.cpp - kmtimer.cpp kmwizard.cpp kmwizardpage.cpp kmwinfopage.cpp - kmwpassword.cpp kmwsocketutil.cpp kmwbackend.cpp - kmwsocket.cpp kmwdriver.cpp kmwdriverselect.cpp - kmwdrivertest.cpp kmwinfobase.cpp kmwname.cpp kmwend.cpp - kmwclass.cpp kmwlpd.cpp kmwfile.cpp kmdriverdialog.cpp - kmwsmb.cpp smbview.cpp kmconfigdialog.cpp kmconfigpage.cpp - kmconfiggeneral.cpp kmspecialprinterdlg.cpp kmwlocal.cpp - kiconselectaction.cpp kmconfigpreview.cpp sidepixmap.cpp - pluginaction.cpp kxmlcommanddlg.cpp kxmlcommandselector.cpp - kmconfigcommand.cpp kmconfigfilter.cpp kmconfigfonts.cpp - kmconfigjobs.cpp networkscanner.cpp -) - -tde_add_library( ${target} SHARED AUTOMOC - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - LINK tdeprint-shared - DESTINATION ${LIB_INSTALL_DIR} -) - - -#### libtdeprint_management_module ############## - -set( target libtdeprint_management_module ) - -set( ${target}_SRCS - tdeprint_management_module.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint_management-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) - - -#### kaddprinterwizard ########################## - -set( target kaddprinterwizard ) - -set( ${target}_SRCS - kaddprinterwizard.cpp -) - -tde_add_tdeinit_executable( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint-shared -) diff --git a/kdeprint/management/Makefile.am b/kdeprint/management/Makefile.am deleted file mode 100644 index 34f8de935..000000000 --- a/kdeprint/management/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -INCLUDES= -I$(top_srcdir)/tdefx -I$(top_srcdir)/tdeprint -I$(top_builddir)/tdeprint -I$(top_srcdir)/kio -I$(top_srcdir)/kfile -I$(top_srcdir) $(all_includes) - -lib_LTLIBRARIES = libtdeprint_management.la -kde_module_LTLIBRARIES = libtdeprint_management_module.la -tdeinit_LTLIBRARIES = kaddprinterwizard.la -bin_PROGRAMS = - -kaddprinterwizard_la_SOURCES = kaddprinterwizard.cpp -kaddprinterwizard_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEPRINT) $(LIB_KDEUI) -kaddprinterwizard_la_LDFLAGS = -module -avoid-version $(all_libraries) $(KDE_RPATH) - -libtdeprint_management_la_SOURCES = \ - kmdbcreator.cpp kmdriverdb.cpp kmdriverdbwidget.cpp \ - kmiconview.cpp kminfopage.cpp kmmainview.cpp \ - kmpages.cpp kmprinterview.cpp kmjobviewer.cpp \ - jobitem.cpp kmpropwidget.cpp kmpropcontainer.cpp kmpropertypage.cpp \ - kmpropgeneral.cpp cjanuswidget.cpp kmpropmembers.cpp kmpropbackend.cpp kmpropdriver.cpp \ - kmlistview.cpp kminstancepage.cpp kmtimer.cpp \ - kmwizard.cpp kmwizardpage.cpp kmwinfopage.cpp kmwpassword.cpp kmwsocketutil.cpp \ - kmwbackend.cpp kmwsocket.cpp kmwdriver.cpp kmwdriverselect.cpp kmwdrivertest.cpp \ - kmwinfobase.cpp kmwname.cpp kmwend.cpp kmwclass.cpp kmwlpd.cpp kmwfile.cpp kmdriverdialog.cpp \ - kmwsmb.cpp smbview.cpp kmconfigdialog.cpp kmconfigpage.cpp kmconfiggeneral.cpp kmspecialprinterdlg.cpp \ - kmwlocal.cpp kiconselectaction.cpp kmconfigpreview.cpp sidepixmap.cpp \ - pluginaction.cpp kxmlcommanddlg.cpp kxmlcommandselector.cpp kmconfigcommand.cpp \ - kmconfigfilter.cpp kmconfigfonts.cpp kmconfigjobs.cpp networkscanner.cpp -libtdeprint_management_la_LDFLAGS = $(all_libraries) -version-info 6:0:2 -no-undefined -libtdeprint_management_la_LIBADD = ../libtdeprint.la $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KFILE) -libtdeprint_management_la_METASOURCES = AUTO - -libtdeprint_management_module_la_SOURCES = tdeprint_management_module.cpp -libtdeprint_management_module_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined -libtdeprint_management_module_la_LIBADD = libtdeprint_management.la $(LIB_QT) $(LIB_KDEUI) $(LIB_KDECORE) - -tdeprint_HEADERS = kmmainview.h kmjobviewer.h kmprinterpage.h kiconselectaction.h kmtimer.h -tdeprintdir = $(includedir)/tdeprint - -noinst_HEADERS = kmdbcreator.h kmdriverdb.h kmdriverdbwidget.h kmiconview.h \ - kminfopage.h kmmainview.h kmpages.h \ - kmprinterpage.h kmprinterview.h kmjobviewer.h jobitem.h kmpropwidget.h kmpropcontainer.h \ - kmpropertypage.h kmpropgeneral.h cjanuswidget.h kmpropmembers.h kmpropbackend.h kmpropdriver.h \ - kmlistview.h kminstancepage.h kmwizard.h kmwizardpage.h kmwinfopage.h kmwpassword.h kmwsocketutil.h \ - kmwbackend.h kmwsocket.h kmwdriver.h kmwdriverselect.h kmwdrivertest.h kmwinfobase.h kmwname.h kmwend.h \ - kmwclass.h kmwlpd.h kmwfile.h kmdriverdialog.h kmwsmb.h smbview.h kmconfigdialog.h kmconfigpage.h \ - kmconfiggeneral.h kmspecialprinterdlg.h kmwlocal.h kmconfigpreview.h sidepixmap.h \ - pluginaction.h kxmlcommanddlg.h kxmlcommandselector.h kmconfigcommand.h \ - kmconfigfilter.h kmconfigfonts.h kmconfigjobs.h networkscanner.h - -dataicon_DATA = tileup.png tiledown.png side.png -dataicondir = $(kde_datadir)/tdeprint - diff --git a/kdeprint/management/cjanuswidget.cpp b/kdeprint/management/cjanuswidget.cpp deleted file mode 100644 index af04ee170..000000000 --- a/kdeprint/management/cjanuswidget.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "cjanuswidget.h" - -#include <tqwidgetstack.h> -#include <tqlabel.h> -#include <tqpainter.h> -#include <klistbox.h> -#include <tqlayout.h> -#include <kseparator.h> - -class CJanusWidget::CPage -{ -public: - TQWidget *m_widget; - TQString m_text; - TQString m_header; - TQPixmap m_pixmap; - CListBoxItem *m_item; -}; - -//*********************************************************************************** - -class CJanusWidget::CListBoxItem : public TQListBoxItem -{ -public: - CListBoxItem(TQListBox *lb, TQListBoxItem *after, const TQPixmap& pix, const TQString& text); - int height(const TQListBox*) const; - int width(const TQListBox*) const; - -protected: - void paint(TQPainter*); - -private: - TQPixmap m_pix; -}; - -CJanusWidget::CListBoxItem::CListBoxItem(TQListBox *lb, TQListBoxItem *after, const TQPixmap& pix, const TQString& text) -: TQListBoxItem(lb, after), m_pix(pix) -{ - setText(text); -} - -int CJanusWidget::CListBoxItem::height(const TQListBox *lb) const -{ - return (m_pix.height() + lb->fontMetrics().lineSpacing() + 12); -} - -int CJanusWidget::CListBoxItem::width(const TQListBox *lb) const -{ - int w = TQMAX(lb->fontMetrics().width(text()),m_pix.width()); - return (w + 10); -} - -void CJanusWidget::CListBoxItem::paint(TQPainter *p) -{ - int w1 = (listBox()->contentsWidth()-m_pix.width())/2; - - p->drawPixmap(w1,5,m_pix); - p->drawText(0,7+m_pix.height(),listBox()->contentsWidth(),p->fontMetrics().lineSpacing(),Qt::AlignHCenter,text()); -} - -//*********************************************************************************** - -class CJanusWidget::CListBox : public KListBox -{ -public: - CListBox(TQWidget *parent = 0, const char *name = 0); - ~CListBox(); - - void computeWidth(); - -protected: - virtual bool eventFilter(TQObject*, TQEvent*); -}; - -CJanusWidget::CListBox::CListBox(TQWidget *parent, const char *name) -: KListBox(parent,name) -{ - verticalScrollBar()->installEventFilter(this); -} - -CJanusWidget::CListBox::~CListBox() -{ -} - -bool CJanusWidget::CListBox::eventFilter(TQObject *o, TQEvent *e) -{ - if (e->type() == TQEvent::Show || e->type() == TQEvent::Hide) - computeWidth(); - return KListBox::eventFilter(o,e); -} - -void CJanusWidget::CListBox::computeWidth() -{ - TQListBoxItem *item = firstItem(); - int w(40); - while (item) - { - w = TQMAX(w,item->width(this)); - item = item->next(); - } - if (verticalScrollBar()->isVisible()) - w += verticalScrollBar()->tqsizeHint().width(); - w += (frameWidth()*2); - setFixedWidth(w); -} - -//*********************************************************************************** - -CJanusWidget::CJanusWidget(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_pages.setAutoDelete(true); - - m_stack = new TQWidgetStack(this); - m_header = new TQLabel(this); - TQFont f(m_header->font()); - f.setBold(true); - m_header->setFont(f); - - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - sep->setFixedHeight(5); - - m_iconlist = new CListBox(this); - f = m_iconlist->font(); - f.setBold(true); - m_iconlist->setFont(f); - connect(m_iconlist,TQT_SIGNAL(selectionChanged(TQListBoxItem*)),TQT_SLOT(slotSelected(TQListBoxItem*))); - - m_empty = new TQWidget(this, "Empty"); - m_stack->addWidget(m_empty,0); - - TQHBoxLayout *main_ = new TQHBoxLayout(this, 0, 10); - TQVBoxLayout *sub_ = new TQVBoxLayout(0, 0, 5); - main_->addWidget(m_iconlist,0); - main_->addLayout(sub_,1); - sub_->addWidget(m_header,0); - sub_->addWidget(sep,0); - sub_->addWidget(m_stack,1); -} - -CJanusWidget::~CJanusWidget() -{ -} - -void CJanusWidget::addPage(TQWidget *w, const TQString& text, const TQString& header, const TQPixmap& pix) -{ - CPage *page = new CPage(); - m_pages.append(page); - page->m_widget = w; - page->m_text = text; - page->m_header = header; - page->m_pixmap = pix; - page->m_item = new CListBoxItem(m_iconlist,findPrevItem(page),pix,text); - m_iconlist->computeWidth(); - m_stack->addWidget(w,m_pages.count()); - - if (m_iconlist->count() == 1) - m_iconlist->setSelected(page->m_item,true); -} - -void CJanusWidget::enablePage(TQWidget *w) -{ - CPage *page = findPage(w); - if (page && !page->m_item) - { - page->m_item = new CListBoxItem(m_iconlist,findPrevItem(page),page->m_pixmap,page->m_text); - m_iconlist->computeWidth(); - if (m_iconlist->count() == 1) - m_iconlist->setSelected(page->m_item,true); - } -} - -void CJanusWidget::disablePage(TQWidget *w) -{ - CPage *page = findPage(w); - if (page && page->m_item) - { - bool needReselect(m_iconlist->isSelected(page->m_item)); - delete page->m_item; - page->m_item = 0; - m_iconlist->computeWidth(); - if (needReselect) - if (m_iconlist->count() > 0) - m_iconlist->setSelected(m_iconlist->firstItem(),true); - else - slotSelected(0); - } -} - -void CJanusWidget::slotSelected(TQListBoxItem *item) -{ - CPage *page = findPage(item); - if (page) - { - m_stack->raiseWidget(page->m_widget); - m_header->setText(page->m_header); - } - else - { - m_header->setText(""); - m_stack->raiseWidget(m_empty); - } -} - -CJanusWidget::CPage* CJanusWidget::findPage(TQWidget *w) -{ - TQPtrListIterator<CPage> it(m_pages); - for (;it.current();++it) - if (it.current()->m_widget == w) - return it.current(); - return 0; -} - -CJanusWidget::CPage* CJanusWidget::findPage(TQListBoxItem *i) -{ - TQPtrListIterator<CPage> it(m_pages); - for (;it.current();++it) - if (it.current()->m_item == i) - return it.current(); - return 0; -} - -TQListBoxItem* CJanusWidget::findPrevItem(CPage *p) -{ - if (m_pages.findRef(p) == -1) - m_pages.last(); - else - m_pages.prev(); - for (;m_pages.current();m_pages.prev()) - if (m_pages.current()->m_item) - return m_pages.current()->m_item; - return 0; -} - -void CJanusWidget::clearPages() -{ - TQPtrListIterator<CPage> it(m_pages); - for (;it.current(); ++it) - { - delete it.current()->m_widget; - delete it.current()->m_item; - } - m_pages.clear(); -} - -#include "cjanuswidget.moc" diff --git a/kdeprint/management/cjanuswidget.h b/kdeprint/management/cjanuswidget.h deleted file mode 100644 index d33be1499..000000000 --- a/kdeprint/management/cjanuswidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 CJANUSWIDGET_H -#define CJANUSWIDGET_H - -#include <tqwidget.h> -#include <tqpixmap.h> -#include <tqptrlist.h> - -class TQWidgetStack; -class TQLabel; -class TQListBoxItem; - -class CJanusWidget : public TQWidget -{ - Q_OBJECT -public: - CJanusWidget(TQWidget *parent, const char *name); - ~CJanusWidget(); - - void addPage(TQWidget *w, const TQString& text, const TQString& header, const TQPixmap& pix); - void enablePage(TQWidget *w); - void disablePage(TQWidget *w); - void clearPages(); - -protected slots: - void slotSelected(TQListBoxItem*); - -public: - class CPage; - class CListBox; - class CListBoxItem; - -private: - CPage* findPage(TQWidget *w); - CPage* findPage(TQListBoxItem *i); - TQListBoxItem* findPrevItem(CPage*); - -private: - TQPtrList<CPage> m_pages; - CListBox *m_iconlist; - TQLabel *m_header; - TQWidgetStack *m_stack; - TQWidget *m_empty; -}; - -#endif diff --git a/kdeprint/management/jobitem.cpp b/kdeprint/management/jobitem.cpp deleted file mode 100644 index a9ce2fe85..000000000 --- a/kdeprint/management/jobitem.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "jobitem.h" -#include "kmjob.h" - -#include <kiconloader.h> - -JobItem::JobItem(TQListView *parent, KMJob *job) -: TQListViewItem(parent) -{ - m_job = new KMJob; - init(job); -} - -JobItem::~JobItem() -{ - delete m_job; -} - -void JobItem::init(KMJob *job) -{ - m_job->copy(job ? *job : KMJob()); - - setPixmap(0,SmallIcon(m_job->pixmap())); - setText(0,TQString::number(m_job->id())); - //setText(6,m_job->printer()); - setText(2,m_job->name()); - setText(1,m_job->owner()); - setText(3,m_job->stateString()); - setText(4,TQString::number(m_job->size())); - setText(5,TQString::number(m_job->processedPages())); - m_ID = m_job->id(); - m_uri = m_job->uri(); - - // additional attributes - for (int i=0; i<m_job->attributeCount(); i++) - setText(6+i, m_job->attribute(i)); - - widthChanged(); -} - -int JobItem::compare(TQListViewItem *item, int col, bool asc) const -{ - switch (col) - { - case 0: - case 4: - case 5: - { - int i1(this->text(col).toInt()), i2(item->text(col).toInt()); - return (i1 < i2 ? -1 : (i1 > i2 ? 1 : 0)); - break; - } - default: - return TQListViewItem::compare(item, col, asc); - } -} diff --git a/kdeprint/management/jobitem.h b/kdeprint/management/jobitem.h deleted file mode 100644 index 580a1b84f..000000000 --- a/kdeprint/management/jobitem.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 JOBITEM_H -#define JOBITEM_H - -#include <tqlistview.h> -#include "kmobject.h" - -class KMJob; - -class JobItem : public TQListViewItem, public KMObject -{ -public: - JobItem(TQListView *parent, KMJob *job = 0); - ~JobItem(); - void init(KMJob *job); - int compare(TQListViewItem*, int, bool) const; - - int jobID() const; - TQString jobUri() const; - KMJob* job() const; - -private: - KMJob *m_job; - int m_ID; - QString m_uri; -}; - -inline int JobItem::jobID() const -{ return m_ID; } - -inline KMJob* JobItem::job() const -{ return m_job; } - -inline TQString JobItem::jobUri() const -{ return m_uri; } - -#endif diff --git a/kdeprint/management/kaddprinterwizard.cpp b/kdeprint/management/kaddprinterwizard.cpp deleted file mode 100644 index 65d355a8f..000000000 --- a/kdeprint/management/kaddprinterwizard.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "kmmanager.h" -#include <kcmdlineargs.h> -#include <kapplication.h> -#include <kmessagebox.h> -#include <klocale.h> -#include <kglobal.h> - -static KCmdLineOptions options[] = -{ - { "kdeconfig", I18N_NOOP("Configure KDE Print"), 0 }, - { "serverconfig", I18N_NOOP("Configure print server"), 0 }, - KCmdLineLastOption -}; - -extern "C" KDE_EXPORT int kdemain(int argc, char *argv[]) -{ - KCmdLineArgs::init(argc, argv, "kaddprinterwizard", - I18N_NOOP("Start the add printer wizard"), - "0.1"); - KCmdLineArgs::addCmdLineOptions(options); - - KGlobal::locale()->setMainCatalogue("kdelibs"); - - KApplication app; - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - bool doConfig = args->isSet("kdeconfig"); - bool doSrvConfig = args->isSet("serverconfig"); - - if (doConfig) - KMManager::self()->invokeOptionsDialog(); - else if (doSrvConfig) - KMManager::self()->configureServer(); - else if (KMManager::self()->addPrinterWizard() == -1) - { - KMessageBox::error(0, KMManager::self()->errorMsg().prepend("<qt>").append("</qt>")); - } - - return 0; -} diff --git a/kdeprint/management/kdeprint_management_module.cpp b/kdeprint/management/kdeprint_management_module.cpp deleted file mode 100644 index 8d4027f75..000000000 --- a/kdeprint/management/kdeprint_management_module.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * Copyright (C) 2004 Dominique Devriese <devriese@kde.org> - * - * 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 "kxmlcommandselector.h" -#include "kmconfigdialog.h" -#include "kmwizard.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmprinter.h" -#include "kmmainview.h" - -#include <kmessagebox.h> -#include <kdialogbase.h> -#include <klocale.h> - -extern "C" -{ - KDEPRINT_EXPORT int add_printer_wizard(TQWidget *parent) - { - return tdeprint_management_add_printer_wizard( parent ); - } - - KDEPRINT_EXPORT bool config_dialog(TQWidget *parent) - { - KMConfigDialog dlg(parent); - return dlg.exec(); - } - - KDEPRINT_EXPORT TQString select_command( TQWidget* parent ) - { - KDialogBase dlg( parent, 0, true, i18n( "Select Command" ), KDialogBase::Ok|KDialogBase::Cancel ); - KXmlCommandSelector *xmlSel = new KXmlCommandSelector( false, &dlg, "CommandSelector", &dlg ); - dlg.setMainWidget( xmlSel ); - if ( dlg.exec() ) - return xmlSel->command(); - return TQString::null; - } -} - diff --git a/kdeprint/management/kiconselectaction.cpp b/kdeprint/management/kiconselectaction.cpp deleted file mode 100644 index 8bf4d5a10..000000000 --- a/kdeprint/management/kiconselectaction.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kiconselectaction.h" - -#include <tqpopupmenu.h> -#include <kiconloader.h> -#include <kdebug.h> -#include <ktoolbar.h> -#include <ktoolbarbutton.h> - -class KIconSelectActionPrivate -{ -public: - KIconSelectActionPrivate() - { - m_menu = 0; - } - TQStringList m_iconlst; - TQPopupMenu* m_menu; -}; - -KIconSelectAction::KIconSelectAction(const TQString& text, int accel, TQObject* parent, const char* name) -: KSelectAction(text, accel, parent, name) -{ - d = new KIconSelectActionPrivate; -} - -KIconSelectAction::~KIconSelectAction() -{ - delete d; -} - -void KIconSelectAction::updateIcons() -{ - if (d->m_menu) - { - TQStringList lst = items(); - for (uint id=0; id<lst.count(); ++id) - d->m_menu->changeItem(id, SmallIconSet(d->m_iconlst[id]), lst[id]); - } -} - -void KIconSelectAction::createPopupMenu() -{ - if (!d->m_menu) - { - d->m_menu = popupMenu(); - updateIcons(); - } -} - -void KIconSelectAction::setItems(const TQStringList& lst, const TQStringList& iconlst) -{ - KSelectAction::setItems(lst); - d->m_iconlst = iconlst; - updateIcons(); -} - -int KIconSelectAction::plug(TQWidget* widget, int index) -{ - int value(-1); - if (widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) - { - createPopupMenu(); - value = KSelectAction::plug(widget, index); - } - else if (widget->inherits("KToolBar")) - { - KToolBar* bar = static_cast<KToolBar*>(widget); - int id = KAction::getToolButtonID(); - // To have a correct layout in the toolbar, a non - // empty icon has to be used. Use "unknown" by default. - TQString iconName = (currentItem() != -1 ? d->m_iconlst[currentItem()] : "unknown"); - - createPopupMenu(); - bar->insertButton(iconName, id, true, plainText(), index); - bar->getButton(id)->setPopup(d->m_menu, true); - bar->setItemEnabled(id, isEnabled()); - addContainer(bar, id); - connect(bar, TQT_SIGNAL(destroyed()), TQT_SLOT(slotDestroyed())); - - value = containerCount()-1; - } - return value; -} - -void KIconSelectAction::updateCurrentItem(int id) -{ - TQWidget* w = container(id); - if (w->inherits("KToolBar")) - static_cast<KToolBar*>(w)->getButton(itemId(id))->setIcon(d->m_iconlst[currentItem()]); - else - KSelectAction::updateCurrentItem(id); -} - -void KIconSelectAction::setCurrentItem(int index) -{ - KSelectAction::setCurrentItem(index); -} - -#include "kiconselectaction.moc" diff --git a/kdeprint/management/kiconselectaction.h b/kdeprint/management/kiconselectaction.h deleted file mode 100644 index 84bef60d2..000000000 --- a/kdeprint/management/kiconselectaction.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KICONSELECTACTION_H -#define KICONSELECTACTION_H - -#include <kaction.h> - -class KIconSelectActionPrivate; - -class KIconSelectAction : public KSelectAction -{ - Q_OBJECT -public: - KIconSelectAction(const TQString& text, int accel = 0, TQObject* parent = 0, const char* name = 0); - virtual ~KIconSelectAction(); - - virtual int plug(TQWidget* widget, int index = -1); - -public slots: - virtual void setItems(const TQStringList& lst, const TQStringList& iconlst); - virtual void setCurrentItem(int index); - -protected: - void createPopupMenu(); - void updateIcons(); - virtual void updateCurrentItem(int id); - -private: - KIconSelectActionPrivate* d; -}; - -#endif diff --git a/kdeprint/management/kmconfigcommand.cpp b/kdeprint/management/kmconfigcommand.cpp deleted file mode 100644 index 32fb7db11..000000000 --- a/kdeprint/management/kmconfigcommand.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigcommand.h" -#include "kxmlcommandselector.h" - -#include <tqlabel.h> -#include <tqgroupbox.h> -#include <tqlayout.h> - -#include <klocale.h> -#include <kdialog.h> - -KMConfigCommand::KMConfigCommand(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Commands")); - setPageHeader(i18n("Command Settings")); - setPagePixmap("exec"); - - TQGroupBox *gb = new TQGroupBox(0, Qt::Horizontal, i18n("Edit/Create Commands"), this); - TQLabel *lab = new TQLabel(i18n( - "<p>Command objects perform a conversion from input to output.<br>" - "They are used as the basis to build both print filters " - "and special printers. They are described by a command string, a " - "set of options, a set of requirements and associated mime types. " - "Here you can create new command objects and edit existing ones. All " - "changes will only be effective for you."), gb); - KXmlCommandSelector *sel = new KXmlCommandSelector(false, gb); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - l0->addWidget(gb); - l0->addStretch(1); - TQVBoxLayout *l2 = new TQVBoxLayout(TQT_TQLAYOUT(gb->layout()), KDialog::spacingHint()); - l2->addWidget(lab); - l2->addWidget(sel); -} diff --git a/kdeprint/management/kmconfigcommand.h b/kdeprint/management/kmconfigcommand.h deleted file mode 100644 index 203e6fd3a..000000000 --- a/kdeprint/management/kmconfigcommand.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGCOMMAND_H -#define KMCONFIGCOMMAND_H - -#include "kmconfigpage.h" - -class KMConfigCommand : public KMConfigPage -{ -public: - KMConfigCommand(TQWidget *parent = 0, const char *name = 0); -}; - -#endif diff --git a/kdeprint/management/kmconfigdialog.cpp b/kdeprint/management/kmconfigdialog.cpp deleted file mode 100644 index 3bd89a751..000000000 --- a/kdeprint/management/kmconfigdialog.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigdialog.h" -#include "kmconfigpage.h" -#include "kmfactory.h" -#include "kmuimanager.h" - -#include "kmconfiggeneral.h" -#include "kmconfigpreview.h" -#include "kmconfigcommand.h" -#include "kmconfigfilter.h" -#include "kmconfigfonts.h" -#include "kmconfigjobs.h" - -#include <tqlayout.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kconfig.h> - -KMConfigDialog::KMConfigDialog(TQWidget *parent, const char *name) -: KDialogBase(IconList,i18n("KDE Print Configuration"),Ok|Cancel,Ok,parent,name,true,true) -{ - m_pages.setAutoDelete(false); - addConfigPage(new KMConfigGeneral(this)); - addConfigPage(new KMConfigPreview(this)); - addConfigPage(new KMConfigFonts(this)); - addConfigPage(new KMConfigCommand(this)); - addConfigPage(new KMConfigFilter(this)); - addConfigPage(new KMConfigJobs(this)); - KMFactory::self()->uiManager()->setupConfigDialog(this); - - // initialize pages - KConfig *conf = KMFactory::self()->printConfig(); - TQPtrListIterator<KMConfigPage> it(m_pages); - for (;it.current();++it) - it.current()->loadConfig(conf); - - // resize dialog - resize(450,400); -} - -void KMConfigDialog::addConfigPage(KMConfigPage *page) -{ - if (page) - { - TQPixmap icon = KGlobal::instance()->iconLoader()->loadIcon( - page->pagePixmap(), - KIcon::NoGroup, - KIcon::SizeMedium - ); - - TQFrame *frame = addPage(page->pageName(),page->pageHeader(),icon); - page->reparent(frame,TQPoint(0,0)); - TQVBoxLayout *lay = new TQVBoxLayout(frame, 0, 0); - lay->addWidget(page); - m_pages.append(page); - } -} - -void KMConfigDialog::slotOk() -{ - // save configuration - KConfig *conf = KMFactory::self()->printConfig(); - TQPtrListIterator<KMConfigPage> it(m_pages); - for (;it.current();++it) - it.current()->saveConfig(conf); - KMFactory::self()->saveConfig(); - - // close the dialog - KDialogBase::slotOk(); -} -#include "kmconfigdialog.moc" diff --git a/kdeprint/management/kmconfigdialog.h b/kdeprint/management/kmconfigdialog.h deleted file mode 100644 index de04bc154..000000000 --- a/kdeprint/management/kmconfigdialog.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGDIALOG_H -#define KMCONFIGDIALOG_H - -#include <kdialogbase.h> -#include <tqptrlist.h> - -#include "kmconfigpage.h" - -class KDEPRINT_EXPORT KMConfigDialog : public KDialogBase -{ - Q_OBJECT -public: - KMConfigDialog(TQWidget *parent = 0, const char *name = 0); - - void addConfigPage(KMConfigPage*); - -protected slots: - void slotOk(); - -private: - TQPtrList<KMConfigPage> m_pages; -}; - -#endif diff --git a/kdeprint/management/kmconfigfilter.cpp b/kdeprint/management/kmconfigfilter.cpp deleted file mode 100644 index 29d5107e0..000000000 --- a/kdeprint/management/kmconfigfilter.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigfilter.h" -#include "kmmanager.h" -#include "kmfactory.h" - -#include <tqgroupbox.h> -#include <tqlineedit.h> -#include <tqtoolbutton.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqapplication.h> - -#include <klocale.h> -#include <kconfig.h> -#include <kiconloader.h> -#include <klistbox.h> -#include <kdialog.h> - -KMConfigFilter::KMConfigFilter(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Filter")); - setPageHeader(i18n("Printer Filtering Settings")); - setPagePixmap("filter"); - - TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("Printer Filter"), this); - - m_list1 = new KListBox(box); - m_list1->setSelectionMode(KListBox::Extended); - m_list2 = new KListBox(box); - m_list2->setSelectionMode(KListBox::Extended); - m_add = new TQToolButton( box ); - m_add->setIconSet(TQApplication::reverseLayout() ? SmallIconSet( "back" ) : SmallIconSet( "forward" )); - m_remove = new TQToolButton( box ); - m_remove->setIconSet(TQApplication::reverseLayout() ? SmallIconSet( "forward" ) : SmallIconSet( "back" )); - m_locationre = new TQLineEdit(box); - TQLabel *lab = new TQLabel(box); - lab->setText(i18n("The printer filtering allows you to view only a specific set of " - "printers instead of all of them. This may be useful when there are a " - "lot of printers available but you only use a few ones. Select the " - "printers you want to see from the list on the left or enter a <b>Location</b> " - "filter (ex: Group_1*). Both are cumulative and ignored if empty.")); - lab->setTextFormat(TQt::RichText); - TQLabel *lab1 = new TQLabel(i18n("Location filter:"), box); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - l0->addWidget(box, 1); - TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint()); - l1->addWidget(lab); - TQGridLayout *l2 = new TQGridLayout(0, 4, 3, 0, KDialog::spacingHint()); - l1->addLayout(TQT_TQLAYOUT(l2)); - l2->setRowStretch(0, 1); - l2->setRowStretch(3, 1); - l2->setColStretch(0, 1); - l2->setColStretch(2, 1); - l2->addMultiCellWidget(m_list1, 0, 3, 0, 0); - l2->addMultiCellWidget(m_list2, 0, 3, 2, 2); - l2->addWidget(m_add, 1, 1); - l2->addWidget(m_remove, 2, 1); - TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint()); - l1->addLayout(l3, 0); - l3->addWidget(lab1, 0); - l3->addWidget(m_locationre, 1); - - connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddClicked())); - connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveClicked())); - connect(m_list1, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged())); - connect(m_list2, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged())); - m_add->setEnabled(false); - m_remove->setEnabled(false); -} - -void KMConfigFilter::loadConfig(KConfig *conf) -{ - conf->setGroup("Filter"); - TQStringList m_plist = conf->readListEntry("Printers"); - TQPtrListIterator<KMPrinter> it(*(KMManager::self()->printerListComplete(false))); - for (; it.current(); ++it) - { - if (!it.current()->isSpecial() && !it.current()->isVirtual()) - { - KListBox *lb = (m_plist.find(it.current()->printerName()) == m_plist.end() ? m_list1 : m_list2); - lb->insertItem(SmallIcon(it.current()->pixmap()), it.current()->printerName()); - } - } - m_list1->sort(); - m_list2->sort(); - m_locationre->setText(conf->readEntry("LocationRe")); -} - -void KMConfigFilter::saveConfig(KConfig *conf) -{ - conf->setGroup("Filter"); - TQStringList plist; - for (uint i=0; i<m_list2->count(); i++) - plist << m_list2->text(i); - conf->writeEntry("Printers", plist); - conf->writeEntry("LocationRe", m_locationre->text()); -} - -void KMConfigFilter::transfer(KListBox *from, KListBox *to) -{ - for (uint i=0; i<from->count();) - { - if (from->isSelected(i)) - { - to->insertItem(*(from->pixmap(i)), from->text(i)); - from->removeItem(i); - } - else - i++; - } - to->sort(); -} - -void KMConfigFilter::slotAddClicked() -{ - transfer(m_list1, m_list2); -} - -void KMConfigFilter::slotRemoveClicked() -{ - transfer(m_list2, m_list1); -} - -void KMConfigFilter::slotSelectionChanged() -{ - const KListBox *lb = static_cast<const KListBox*>(sender()); - if (!lb) - return; - TQToolButton *pb = (lb == m_list1 ? m_add : m_remove); - for (uint i=0; i<lb->count(); i++) - if (lb->isSelected(i)) - { - pb->setEnabled(true); - return; - } - pb->setEnabled(false); -} - -#include "kmconfigfilter.moc" diff --git a/kdeprint/management/kmconfigfilter.h b/kdeprint/management/kmconfigfilter.h deleted file mode 100644 index 9571f0d54..000000000 --- a/kdeprint/management/kmconfigfilter.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGFILTER_H -#define KMCONFIGFILTER_H - -#include "kmconfigpage.h" - -class KListBox; -class TQToolButton; -class TQLineEdit; - -class KMConfigFilter : public KMConfigPage -{ - Q_OBJECT -public: - KMConfigFilter(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -protected slots: - void slotSelectionChanged(); - void slotAddClicked(); - void slotRemoveClicked(); - -protected: - void transfer(KListBox *from, KListBox *to); - -private: - KListBox *m_list1, *m_list2; - TQToolButton *m_add, *m_remove; - TQLineEdit *m_locationre; -}; - -#endif diff --git a/kdeprint/management/kmconfigfonts.cpp b/kdeprint/management/kmconfigfonts.cpp deleted file mode 100644 index 183d0b621..000000000 --- a/kdeprint/management/kmconfigfonts.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigfonts.h" - -#include <tqgroupbox.h> -#include <kpushbutton.h> -#include <tqlayout.h> -#include <tqheader.h> -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqsettings.h> -#include <tqwhatsthis.h> - -#include <klocale.h> -#include <kconfig.h> -#include <kiconloader.h> -#include <kurlrequester.h> -#include <kfile.h> -#include <klistview.h> -#include <kdialog.h> - -KMConfigFonts::KMConfigFonts(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Fonts")); - setPageHeader(i18n("Font Settings")); - setPagePixmap("fonts"); - - TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("Fonts Embedding"), this); - TQGroupBox *box2 = new TQGroupBox(0, Qt::Vertical, i18n("Fonts Path"), this); - - m_embedfonts = new TQCheckBox(i18n("&Embed fonts in PostScript data when printing"), box); - m_fontpath = new KListView(box2); - m_fontpath->addColumn(""); - m_fontpath->header()->setStretchEnabled(true, 0); - m_fontpath->header()->hide(); - m_fontpath->setSorting(-1); - m_addpath = new KURLRequester(box2); - m_addpath->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly); - m_up = new KPushButton(KGuiItem(i18n("&Up"), "up"), box2); - m_down = new KPushButton(KGuiItem(i18n("&Down"), "down"), box2); - m_add = new KPushButton(KGuiItem(i18n("&Add"), "add"), box2); - m_remove = new KPushButton(KGuiItem(i18n("&Remove"), "editdelete"), box2); - TQLabel *lab0 = new TQLabel(i18n("Additional director&y:"), box2); - lab0->setBuddy(m_addpath); - - TQVBoxLayout *l0 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint()); - l0->addWidget(m_embedfonts); - TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box2->layout()), KDialog::spacingHint()); - l1->addWidget(m_fontpath); - TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, KDialog::spacingHint()); - l1->addLayout(l2); - l2->addWidget(m_up); - l2->addWidget(m_down); - l2->addWidget(m_remove); - l1->addSpacing(10); - l1->addWidget(lab0); - l1->addWidget(m_addpath); - TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint()); - l1->addLayout(l3); - l3->addStretch(1); - l3->addWidget(m_add); - TQVBoxLayout *l4 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - l4->addWidget(box); - l4->addWidget(box2); - - TQWhatsThis::add(m_embedfonts, - i18n("These options will automatically put fonts in the PostScript file " - "which are not present on the printer. Font embedding usually produces better print results " - "(closer to what you see on the screen), but larger print data as well.")); - TQWhatsThis::add(m_fontpath, - i18n("When using font embedding you can select additional directories where " - "KDE should search for embeddable font files. By default, the X server " - "font path is used, so adding those directories is not needed. The default " - "search path should be sufficient in most cases.")); - - connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemove())); - connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAdd())); - connect(m_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotUp())); - connect(m_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotDown())); - connect(m_fontpath, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelected())); - connect(m_addpath, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotTextChanged(const TQString&))); - m_add->setEnabled(false); - m_remove->setEnabled(false); - m_up->setEnabled(false); - m_down->setEnabled(false); -} - -void KMConfigFonts::loadConfig(KConfig *) -{ - TQSettings settings; - m_embedfonts->setChecked(settings.readBoolEntry("/qt/embedFonts", true)); - TQStringList paths = settings.readListEntry("/qt/fontPath", ':'); - TQListViewItem *item(0); - for (TQStringList::ConstIterator it=paths.begin(); it!=paths.end(); ++it) - item = new TQListViewItem(m_fontpath, item, *it); -} - -void KMConfigFonts::saveConfig(KConfig *) -{ - TQSettings settings; - settings.writeEntry("/qt/embedFonts", m_embedfonts->isChecked()); - TQStringList l; - TQListViewItem *item = m_fontpath->firstChild(); - while (item) - { - l << item->text(0); - item = item->nextSibling(); - } - settings.writeEntry("/qt/fontPath", l, ':'); -} - -void KMConfigFonts::slotSelected() -{ - TQListViewItem *item = m_fontpath->selectedItem(); - m_remove->setEnabled(item); - m_up->setEnabled(item && item->itemAbove()); - m_down->setEnabled(item && item->itemBelow()); -} - -void KMConfigFonts::slotAdd() -{ - if (m_addpath->url().isEmpty()) - return; - TQListViewItem *lastItem(m_fontpath->firstChild()); - while (lastItem && lastItem->nextSibling()) - lastItem = lastItem->nextSibling(); - TQListViewItem *item = new TQListViewItem(m_fontpath, lastItem, m_addpath->url()); - m_fontpath->setSelected(item, true); -} - -void KMConfigFonts::slotRemove() -{ - delete m_fontpath->selectedItem(); - if (m_fontpath->currentItem()) - m_fontpath->setSelected(m_fontpath->currentItem(), true); - slotSelected(); -} - -void KMConfigFonts::slotUp() -{ - TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0; - if (!citem || !citem->itemAbove()) - return; - nitem = new TQListViewItem(m_fontpath, citem->itemAbove()->itemAbove(), citem->text(0)); - delete citem; - m_fontpath->setSelected(nitem, true); -} - -void KMConfigFonts::slotDown() -{ - TQListViewItem *citem = m_fontpath->selectedItem(), *nitem = 0; - if (!citem || !citem->itemBelow()) - return; - nitem = new TQListViewItem(m_fontpath, citem->itemBelow(), citem->text(0)); - delete citem; - m_fontpath->setSelected(nitem, true); -} - -void KMConfigFonts::slotTextChanged(const TQString& t) -{ - m_add->setEnabled(!t.isEmpty()); -} - -#include "kmconfigfonts.moc" diff --git a/kdeprint/management/kmconfigfonts.h b/kdeprint/management/kmconfigfonts.h deleted file mode 100644 index a93a26d75..000000000 --- a/kdeprint/management/kmconfigfonts.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGFONTS_H -#define KMCONFIGFONTS_H - -#include "kmconfigpage.h" - -class KListView; -class KURLRequester; -class TQPushButton; -class TQCheckBox; - -class KMConfigFonts : public KMConfigPage -{ - Q_OBJECT -public: - KMConfigFonts(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -protected slots: - void slotUp(); - void slotDown(); - void slotRemove(); - void slotAdd(); - void slotSelected(); - void slotTextChanged(const TQString&); - -private: - TQCheckBox *m_embedfonts; - KListView *m_fontpath; - KURLRequester *m_addpath; - TQPushButton *m_up, *m_down, *m_add, *m_remove; -}; - -#endif diff --git a/kdeprint/management/kmconfiggeneral.cpp b/kdeprint/management/kmconfiggeneral.cpp deleted file mode 100644 index 40d187c3c..000000000 --- a/kdeprint/management/kmconfiggeneral.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfiggeneral.h" - -#include <tqlayout.h> -#include <tqgroupbox.h> -#include <tqcheckbox.h> -#include <tqlabel.h> -#include <tqwhatsthis.h> - -#include <kpushbutton.h> -#include <klocale.h> -#include <kurlrequester.h> -#include <krun.h> -#include <kmimemagic.h> -#include <kconfig.h> -#include <knuminput.h> -#include <kmessagebox.h> -#include <kcursor.h> -#include <klineedit.h> -#include <kguiitem.h> -#include <kdialog.h> - -KMConfigGeneral::KMConfigGeneral(TQWidget *parent) -: KMConfigPage(parent,"ConfigTimer") -{ - setPageName(i18n("General")); - setPageHeader(i18n("General Settings")); - setPagePixmap("fileprint"); - - TQGroupBox *m_timerbox = new TQGroupBox(0, Qt::Vertical, i18n("Refresh Interval"), this); - m_timer = new KIntNumInput(m_timerbox,"Timer"); - m_timer->setRange(0,30); - m_timer->setSuffix( i18n( " sec" ) ); - m_timer->setSpecialValueText(i18n("Disabled")); - TQWhatsThis::add(m_timer, i18n("This time setting controls the refresh rate of various " - "<b>KDE Print</b> components like the print manager " - "and the job viewer.")); - - TQGroupBox *m_testpagebox = new TQGroupBox(0, Qt::Vertical, i18n("Test Page"), this); - m_defaulttestpage = new TQCheckBox(i18n("&Specify personal test page"), m_testpagebox, "TestPageCheck"); - m_testpage = new KURLRequester(m_testpagebox,"TestPage"); - m_preview = new KPushButton(KGuiItem(i18n("Preview..."), "filefind"), m_testpagebox); - connect(m_defaulttestpage,TQT_SIGNAL(toggled(bool)),m_testpage,TQT_SLOT(setEnabled(bool))); - connect(m_defaulttestpage,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(setEnabledPreviewButton(bool))); - connect(m_preview,TQT_SIGNAL(clicked()),TQT_SLOT(slotTestPagePreview())); - connect(m_testpage->lineEdit(),TQT_SIGNAL(textChanged ( const TQString & )),this,TQT_SLOT(testPageChanged(const TQString & ))); - m_testpage->setDisabled(true); - m_preview->setDisabled(true); - m_defaulttestpage->setCursor(KCursor::handCursor()); - - TQGroupBox *m_statusbox = new TQGroupBox(0, Qt::Vertical, i18n("Miscellaneous"), this); - m_statusmsg = new TQCheckBox(i18n("Sho&w printing status message box"), m_statusbox); - m_uselast = new TQCheckBox(i18n("De&faults to the last printer used in the application"), m_statusbox); - - //layout - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - lay0->addWidget(m_timerbox); - lay0->addWidget(m_testpagebox); - lay0->addWidget(m_statusbox); - lay0->addStretch(1); - TQVBoxLayout *lay1 = new TQVBoxLayout(TQT_TQLAYOUT(m_timerbox->layout()), - KDialog::spacingHint()); - lay1->addWidget(m_timer); - TQVBoxLayout *lay2 = new TQVBoxLayout(TQT_TQLAYOUT(m_testpagebox->layout()), - KDialog::spacingHint()); - TQHBoxLayout *lay3 = new TQHBoxLayout(0, 0, 0); - lay2->addWidget(m_defaulttestpage); - lay2->addWidget(m_testpage); - lay2->addLayout(lay3); - lay3->addStretch(1); - lay3->addWidget(m_preview); - TQVBoxLayout *lay4 = new TQVBoxLayout(TQT_TQLAYOUT(m_statusbox->layout()), - KDialog::spacingHint()); - lay4->addWidget(m_statusmsg); - lay4->addWidget(m_uselast); - m_preview->setEnabled( !m_testpage->url().isEmpty()); -} - -void KMConfigGeneral::testPageChanged(const TQString &test ) -{ - m_preview->setEnabled( !test.isEmpty()); -} - -void KMConfigGeneral::setEnabledPreviewButton(bool b) -{ - m_preview->setEnabled(!m_testpage->url().isEmpty() && b); -} - -void KMConfigGeneral::loadConfig(KConfig *conf) -{ - conf->setGroup("General"); - m_timer->setValue(conf->readNumEntry("TimerDelay",5)); - TQString tpage = conf->readPathEntry("TestPage"); - if (!tpage.isEmpty()) - { - m_defaulttestpage->setChecked(true); - m_testpage->setURL(tpage); - } - m_statusmsg->setChecked(conf->readBoolEntry("ShowStatusMsg", true)); - m_uselast->setChecked(conf->readBoolEntry("UseLast", true)); -} - -void KMConfigGeneral::saveConfig(KConfig *conf) -{ - conf->setGroup("General"); - conf->writeEntry("TimerDelay",m_timer->value()); - conf->writePathEntry("TestPage",(m_defaulttestpage->isChecked() ? m_testpage->url() : TQString::null)); - if (m_defaulttestpage->isChecked() && KMimeMagic::self()->findFileType(m_testpage->url())->mimeType() != "application/postscript") - KMessageBox::sorry(this, i18n("The selected test page is not a PostScript file. You may not " - "be able to test your printer anymore.")); - conf->writeEntry("ShowStatusMsg", m_statusmsg->isChecked()); - conf->writeEntry("UseLast", m_uselast->isChecked()); -} - -void KMConfigGeneral::slotTestPagePreview() -{ - TQString tpage = m_testpage->url(); - if (tpage.isEmpty()) - KMessageBox::error(this, i18n("Empty file name.")); - else - KRun::runURL(KURL( tpage ), KMimeMagic::self()->findFileType(tpage)->mimeType()); -} - -#include "kmconfiggeneral.moc" diff --git a/kdeprint/management/kmconfiggeneral.h b/kdeprint/management/kmconfiggeneral.h deleted file mode 100644 index 8fc6fa5ab..000000000 --- a/kdeprint/management/kmconfiggeneral.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGGENERAL_H -#define KMCONFIGGENERAL_H - -#include "kmconfigpage.h" - -class KIntNumInput; -class KURLRequester; -class TQCheckBox; -class TQPushButton; -class KMConfigGeneral : public KMConfigPage -{ - Q_OBJECT -public: - KMConfigGeneral(TQWidget *parent = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -protected slots: - void slotTestPagePreview(); - void testPageChanged(const TQString & ); - void setEnabledPreviewButton(bool b); -private: - KIntNumInput *m_timer; - KURLRequester *m_testpage; - TQCheckBox *m_defaulttestpage; - TQPushButton *m_preview; - TQCheckBox *m_statusmsg, *m_uselast; -}; - -#endif diff --git a/kdeprint/management/kmconfigjobs.cpp b/kdeprint/management/kmconfigjobs.cpp deleted file mode 100644 index 1088e1b3a..000000000 --- a/kdeprint/management/kmconfigjobs.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigjobs.h" - -#include <tqgroupbox.h> -#include <tqlayout.h> - -#include <knuminput.h> -#include <klocale.h> -#include <kconfig.h> -#include <kdialog.h> - -KMConfigJobs::KMConfigJobs(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Jobs")); - setPageHeader(i18n("Print Job Settings")); - setPagePixmap("exec"); - - TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("Jobs Shown"), this); - - m_limit = new KIntNumInput(box); - m_limit->setRange(0, 9999, 1, true); - m_limit->setSpecialValueText(i18n("Unlimited")); - m_limit->setLabel(i18n("Maximum number of jobs shown:")); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - l0->addWidget(box, 0); - l0->addStretch(1); - TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint()); - l1->addWidget(m_limit); -} - -void KMConfigJobs::loadConfig(KConfig *conf) -{ - conf->setGroup("Jobs"); - m_limit->setValue(conf->readNumEntry("Limit", 0)); -} - -void KMConfigJobs::saveConfig(KConfig *conf) -{ - conf->setGroup("Jobs"); - conf->writeEntry("Limit", m_limit->value()); -} - -#include "kmconfigjobs.moc" diff --git a/kdeprint/management/kmconfigjobs.h b/kdeprint/management/kmconfigjobs.h deleted file mode 100644 index 34be5b1ef..000000000 --- a/kdeprint/management/kmconfigjobs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGJOBS_H -#define KMCONFIGJOBS_H - -#include "kmconfigpage.h" - -class KIntNumInput; - -class KMConfigJobs : public KMConfigPage -{ - Q_OBJECT -public: - KMConfigJobs(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - KIntNumInput *m_limit; -}; - -#endif diff --git a/kdeprint/management/kmconfigpage.cpp b/kdeprint/management/kmconfigpage.cpp deleted file mode 100644 index fb967e05d..000000000 --- a/kdeprint/management/kmconfigpage.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigpage.h" - -KMConfigPage::KMConfigPage(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_name = "Name"; - m_header = "Header"; -} - -void KMConfigPage::loadConfig(KConfig*) -{ -} - -void KMConfigPage::saveConfig(KConfig*) -{ -} -#include "kmconfigpage.moc" diff --git a/kdeprint/management/kmconfigpage.h b/kdeprint/management/kmconfigpage.h deleted file mode 100644 index d56fbde8b..000000000 --- a/kdeprint/management/kmconfigpage.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGPAGE_H -#define KMCONFIGPAGE_H - -#include <tqwidget.h> - -#include <kdelibs_export.h> - -class KConfig; - -class KDEPRINT_EXPORT KMConfigPage : public TQWidget -{ - Q_OBJECT -public: - KMConfigPage(TQWidget *parent = 0, const char *name = 0); - - virtual void loadConfig(KConfig*); - virtual void saveConfig(KConfig*); - - TQString pageName() const { return m_name; } - TQString pageHeader() const { return m_header; } - TQString pagePixmap() const { return m_pixmap; } - -protected: - void setPageName(const TQString& s) { m_name = s; } - void setPageHeader(const TQString& s) { m_header = s; } - void setPagePixmap(const TQString& s) { m_pixmap = s; } - -protected: - QString m_name; - QString m_header; - QString m_pixmap; -}; - -#endif diff --git a/kdeprint/management/kmconfigpreview.cpp b/kdeprint/management/kmconfigpreview.cpp deleted file mode 100644 index cd777ec7a..000000000 --- a/kdeprint/management/kmconfigpreview.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigpreview.h" - -#include <tqcheckbox.h> -#include <tqlayout.h> -#include <tqgroupbox.h> -#include <tqlabel.h> - -#include <klocale.h> -#include <kurlrequester.h> -#include <kconfig.h> -#include <kdialog.h> - -KMConfigPreview::KMConfigPreview(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Preview")); - setPageHeader(i18n("Preview Settings")); - setPagePixmap("filefind"); - - TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("Preview Program"), this); - - m_useext = new TQCheckBox(i18n("&Use external preview program"), box); - m_program = new KURLRequester(box); - TQLabel *lab = new TQLabel(box); - lab->setText(i18n("You can use an external preview program (PS viewer) instead of the " - "KDE built-in preview system. Note that if the KDE default PS viewer " - "(KGhostView) cannot be found, KDE tries automatically to find another " - "external PostScript viewer")); - lab->setTextFormat(TQt::RichText); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - l0->addWidget(box); - l0->addStretch(1); - TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint()); - l1->addWidget(lab); - l1->addWidget(m_useext); - l1->addWidget(m_program); - - connect(m_useext, TQT_SIGNAL(toggled(bool)), m_program, TQT_SLOT(setEnabled(bool))); - m_program->setEnabled(false); -} - -void KMConfigPreview::loadConfig(KConfig *conf) -{ - conf->setGroup("General"); - m_useext->setChecked(conf->readBoolEntry("ExternalPreview", false)); - m_program->setURL(conf->readPathEntry("PreviewCommand", "gv")); -} - -void KMConfigPreview::saveConfig(KConfig *conf) -{ - conf->setGroup("General"); - conf->writeEntry("ExternalPreview", m_useext->isChecked()); - conf->writePathEntry("PreviewCommand", m_program->url()); -} diff --git a/kdeprint/management/kmconfigpreview.h b/kdeprint/management/kmconfigpreview.h deleted file mode 100644 index a9c826c98..000000000 --- a/kdeprint/management/kmconfigpreview.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGPREVIEW_H -#define KMCONFIGPREVIEW_H - -#include "kmconfigpage.h" - -class TQCheckBox; -class KURLRequester; - -class KMConfigPreview : public KMConfigPage -{ -public: - KMConfigPreview(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - TQCheckBox *m_useext; - KURLRequester *m_program; -}; - -#endif diff --git a/kdeprint/management/kmdbcreator.cpp b/kdeprint/management/kmdbcreator.cpp deleted file mode 100644 index 1a89d0a8e..000000000 --- a/kdeprint/management/kmdbcreator.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmdbcreator.h" -#include "kmfactory.h" -#include "kmmanager.h" - -#include <tqprogressdialog.h> -#include <tqfileinfo.h> -#include <tqdir.h> -#include <klocale.h> -#include <kapplication.h> -#include <kstandarddirs.h> -#include <kdebug.h> - -KMDBCreator::KMDBCreator(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - m_dlg = 0; - m_status = true; - - connect(&m_proc,TQT_SIGNAL(receivedStdout(KProcess*,char*,int)),TQT_SLOT(slotReceivedStdout(KProcess*,char*,int))); - connect(&m_proc,TQT_SIGNAL(receivedStderr(KProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(KProcess*,char*,int))); - connect(&m_proc,TQT_SIGNAL(processExited(KProcess*)),TQT_SLOT(slotProcessExited(KProcess*))); -} - -KMDBCreator::~KMDBCreator() -{ - if (m_proc.isRunning()) - m_proc.kill(); - // do not delete the progress dialog anymore: it's persistent and owned by - // it's parent. It will be destroyed along with its parent. -} - -bool KMDBCreator::checkDriverDB(const TQString& dirname, const TQDateTime& d) -{ - // don't block GUI - kapp->processEvents(); - - // first check current directory - TQFileInfo dfi(dirname); - if (dfi.lastModified() > d) - return false; - - // then check most recent file in current directory - TQDir dir(dirname); - const TQFileInfoList *list = dir.entryInfoList(TQDir::Files,TQDir::Time); - if (list && list->count() > 0 && list->getFirst()->lastModified() > d) - return false; - - // then loop into subdirs - TQStringList slist = dir.entryList(TQDir::Dirs,TQDir::Time); - for (TQStringList::ConstIterator it=slist.begin(); it!=slist.end(); ++it) - if ((*it) != "." && (*it) != ".." && !checkDriverDB(dir.absFilePath(*it),d)) - return false; - - // everything is OK - return true; -} - -bool KMDBCreator::createDriverDB(const TQString& dirname, const TQString& filename, TQWidget *parent) -{ - bool started(true); - - // initialize status - m_status = false; - m_firstflag = true; - - // start the child process - m_proc.clearArguments(); - TQString exestr = KMFactory::self()->manager()->driverDbCreationProgram(); - m_proc << exestr << dirname << filename; - kdDebug() << "executing : " << exestr << " " << dirname << " " << filename << endl; - TQString msg; - if (exestr.isEmpty()) - msg = i18n("No executable defined for the creation of the " - "driver database. This operation is not implemented."); - else if (KStandardDirs::findExe(exestr).isEmpty()) - msg = i18n("The executable %1 could not be found in your " - "PATH. Check that this program exists and is " - "accessible in your PATH variable.").arg(exestr); - else if (!m_proc.start(KProcess::NotifyOnExit, KProcess::AllOutput)) - msg = i18n("Unable to start the creation of the driver " - "database. The execution of %1 failed.").arg(exestr); - if (!msg.isEmpty()) - { - KMManager::self()->setErrorMsg(msg); - started = false; - } - - // Create the dialog if the process is running and if needed - if (started) - { - if (!m_dlg) - { - m_dlg = new TQProgressDialog(parent->tqtopLevelWidget(),"progress-dialog",true); - m_dlg->setLabelText(i18n("Please wait while KDE rebuilds a driver database.")); - m_dlg->setCaption(i18n("Driver Database")); - connect(m_dlg,TQT_SIGNAL(canceled()),TQT_SLOT(slotCancelled())); - } - m_dlg->setMinimumDuration(0); // always show the dialog - m_dlg->setProgress(0); // to force showing - } - else - // be sure to emit this signal otherwise the DB widget won't never be notified - emit dbCreated(); - - return started; -} - -void KMDBCreator::slotReceivedStdout(KProcess*, char *buf, int len) -{ - // save buffer - TQString str( TQCString(buf, len) ); - - // get the number, cut the string at the first '\n' otherwise - // the toInt() will return 0. If that occurs for the first number, - // then the number of steps will be also 0. - bool ok; - int p = str.find('\n'); - int n = str.mid(0, p).toInt(&ok); - - // process the number received - if (ok && m_dlg) - { - if (m_firstflag) - { - m_dlg->setTotalSteps(n); - m_firstflag = false; - } - else - { - m_dlg->setProgress(n); - } - } -} - -void KMDBCreator::slotReceivedStderr(KProcess*, char*, int) -{ - // just discard it for the moment -} - -void KMDBCreator::slotProcessExited(KProcess*) -{ - // delete the progress dialog - if (m_dlg) - { - m_dlg->reset(); - } - - // set exit status - m_status = (m_proc.normalExit() && m_proc.exitStatus() == 0); - if (!m_status) - { - KMFactory::self()->manager()->setErrorMsg(i18n("Error while creating driver database: abnormal child-process termination.")); - // remove the incomplete driver DB file so that, it will be - // reconstructed on next check - TQFile::remove(m_proc.args()[2]); - } - //else - emit dbCreated(); -} - -void KMDBCreator::slotCancelled() -{ - if (m_proc.isRunning()) - m_proc.kill(); - else - emit dbCreated(); -} -#include "kmdbcreator.moc" diff --git a/kdeprint/management/kmdbcreator.h b/kdeprint/management/kmdbcreator.h deleted file mode 100644 index 319d270c0..000000000 --- a/kdeprint/management/kmdbcreator.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMDBCREATOR_H -#define KMDBCREATOR_H - -#include <tqobject.h> -#include <tqstring.h> -#include <tqdatetime.h> -#include <kprocess.h> - -class TQWidget; -class TQProgressDialog; - -class KMDBCreator : public TQObject -{ - Q_OBJECT -public: - KMDBCreator(TQObject *parent = 0, const char *name = 0); - ~KMDBCreator(); - - bool checkDriverDB(const TQString& dirname, const TQDateTime& d); - bool createDriverDB(const TQString& dirname, const TQString& filename, TQWidget *parent = 0); - bool status() const { return m_status; } - -protected slots: - void slotReceivedStdout(KProcess *p, char *bufm, int len); - void slotReceivedStderr(KProcess *p, char *bufm, int len); - void slotProcessExited(KProcess *p); - void slotCancelled(); - -signals: - void dbCreated(); - -private: - KProcess m_proc; - TQProgressDialog *m_dlg; - bool m_status; - bool m_firstflag; -}; - -#endif diff --git a/kdeprint/management/kmdriverdb.cpp b/kdeprint/management/kmdriverdb.cpp deleted file mode 100644 index 6fbab45ec..000000000 --- a/kdeprint/management/kmdriverdb.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmdriverdb.h" -#include "kmdbentry.h" -#include "kmdbcreator.h" -#include "kmmanager.h" -#include "kmfactory.h" -#include <kdebug.h> - -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqfileinfo.h> -#include <kstandarddirs.h> -#include <kapplication.h> -#include <kmessagebox.h> - -KMDriverDB* KMDriverDB::m_self = 0; - -KMDriverDB* KMDriverDB::self() -{ - if (!m_self) - { - m_self = new KMDriverDB(); - Q_CHECK_PTR(m_self); - } - return m_self; -} - -KMDriverDB::KMDriverDB(TQObject *parent, const char *name) -: TQObject(parent,name) -{ - m_creator = new KMDBCreator(this,"db-creator"); - connect(m_creator,TQT_SIGNAL(dbCreated()),TQT_SLOT(slotDbCreated())); - - m_entries.setAutoDelete(true); - m_pnpentries.setAutoDelete(true); -} - -KMDriverDB::~KMDriverDB() -{ -} - -TQString KMDriverDB::dbFile() -{ - // this calls insure missing directories creation - TQString filename = locateLocal("data",TQString::tqfromLatin1("tdeprint/printerdb_%1.txt").arg(KMFactory::self()->printSystem())); - return filename; -} - -void KMDriverDB::init(TQWidget *parent) -{ - TQFileInfo dbfi(dbFile()); - TQString dirname = KMFactory::self()->manager()->driverDirectory(); - TQStringList dbDirs = TQStringList::split(':', dirname, false); - bool createflag(false); - - for (TQStringList::ConstIterator it=dbDirs.begin(); it!=dbDirs.end() && !createflag; ++it) - if (!(*it).startsWith("module:") && !m_creator->checkDriverDB(*it, dbfi.lastModified())) - createflag = true; - - if (createflag) - { - // starts DB creation and wait for creator signal - if (!m_creator->createDriverDB(dirname,dbfi.absFilePath(),parent)) - KMessageBox::error(parent, KMFactory::self()->manager()->errorMsg().prepend("<qt>").append("</qt>")); - } - else if (m_entries.count() == 0) - { - // call directly the slot as the DB won't be re-created - // this will (re)load the driver DB - slotDbCreated(); - } - else - // no need to refresh, and already loaded, just emit signal - emit dbLoaded(false); -} - -void KMDriverDB::slotDbCreated() -{ - // DB should be created, check creator status - if (m_creator->status()) - { - // OK, load DB and emit signal - loadDbFile(); - emit dbLoaded(true); - } - else - // error while creating DB, notify the DB widget - emit error(KMManager::self()->errorMsg()); - // be sure to emit this signal to notify the DB widget - //emit dbLoaded(true); -} - -KMDBEntryList* KMDriverDB::findEntry(const TQString& manu, const TQString& model) -{ - TQDict<KMDBEntryList> *models = m_entries.find(manu); - if (models) - return models->find(model); - return 0; -} - -KMDBEntryList* KMDriverDB::findPnpEntry(const TQString& manu, const TQString& model) -{ - TQDict<KMDBEntryList> *models = m_pnpentries.find(manu); - if (models) - return models->find(model); - return 0; -} - -TQDict<KMDBEntryList>* KMDriverDB::findModels(const TQString& manu) -{ - return m_entries.find(manu); -} - -void KMDriverDB::insertEntry(KMDBEntry *entry) -{ - // first check entry - if (!entry->validate()) - { - kdDebug() << "Incorrect entry, skipping...(" << entry->file << ")" << endl; - delete entry; - return; - } - - // insert it in normal entries - TQDict<KMDBEntryList> *models = m_entries.find(entry->manufacturer); - if (!models) - { - models = new TQDict<KMDBEntryList>(17,false); - models->setAutoDelete(true); - m_entries.insert(entry->manufacturer,models); - } - KMDBEntryList *list = models->find(entry->model); - if (!list) - { - list = new KMDBEntryList; - list->setAutoDelete(true); - models->insert(entry->model,list); - } - list->append(entry); - - if (!entry->pnpmanufacturer.isEmpty() && !entry->pnpmodel.isEmpty()) - { - // insert it in PNP entries - models = m_pnpentries.find(entry->manufacturer); - if (!models) - { - models = new TQDict<KMDBEntryList>(17,false); - models->setAutoDelete(true); - m_pnpentries.insert(entry->manufacturer,models); - } - list = models->find(entry->model); - if (!list) - { - list = new KMDBEntryList; - list->setAutoDelete(true); - models->insert(entry->model,list); - } - list->append(entry); - } - - // don't block GUI - kapp->processEvents(); -} - -/* - Driver DB file format: - FILE=<path> - MANUFACTURER=<string> - MODEL=<string> - PNPMANUFACTURER=<string> - PNPMODEL=<string> - DESCRIPTION=<string> -*/ - -void KMDriverDB::loadDbFile() -{ - // first clear everything - m_entries.clear(); - m_pnpentries.clear(); - - TQFile f(dbFile()); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - TQStringList words; - KMDBEntry *entry(0); - - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) - continue; - int p = line.find('='); - if (p == -1) - continue; - words.clear(); - words << line.left(p) << line.mid(p+1); - if (words[0] == "FILE") - { - if (entry) insertEntry(entry); - entry = new KMDBEntry; - entry->file = words[1]; - } - else if (words[0] == "MANUFACTURER" && entry) - entry->manufacturer = words[1].upper(); - else if (words[0] == "MODEL" && entry) - entry->model = words[1]; - else if (words[0] == "MODELNAME" && entry) - entry->modelname = words[1]; - else if (words[0] == "PNPMANUFACTURER" && entry) - entry->pnpmanufacturer = words[1].upper(); - else if (words[0] == "PNPMODEL" && entry) - entry->pnpmodel = words[1]; - else if (words[0] == "DESCRIPTION" && entry) - entry->description = words[1]; - else if (words[0] == "RECOMMANDED" && entry && words[1].lower() == "yes") - entry->recommended = true; - else if (words[0] == "DRIVERCOMMENT" && entry) - entry->drivercomment = ("<qt>"+words[1].replace("<", "<").replace(">", ">")+"</qt>"); - } - if (entry) - insertEntry(entry); - } -} -#include "kmdriverdb.moc" diff --git a/kdeprint/management/kmdriverdb.h b/kdeprint/management/kmdriverdb.h deleted file mode 100644 index c5af6d53e..000000000 --- a/kdeprint/management/kmdriverdb.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMDRIVERDB_H -#define KMDRIVERDB_H - -#include <tqobject.h> -#include <tqptrlist.h> -#include <tqdict.h> -#include <tqstring.h> - -#include "kmdbentry.h" - -class KMDBCreator; - -class KMDriverDB : public TQObject -{ - Q_OBJECT -public: - static KMDriverDB* self(); - - KMDriverDB(TQObject *parent = 0, const char *name = 0); - ~KMDriverDB(); - - void init(TQWidget *parent = 0); - KMDBEntryList* findEntry(const TQString& manu, const TQString& model); - KMDBEntryList* findPnpEntry(const TQString& manu, const TQString& model); - TQDict<KMDBEntryList>* findModels(const TQString& manu); - const TQDict< TQDict<KMDBEntryList> >& manufacturers() const { return m_entries; } - -protected: - void loadDbFile(); - void insertEntry(KMDBEntry *entry); - TQString dbFile(); - -protected slots: - void slotDbCreated(); - -signals: - void dbLoaded(bool reloaded); - void error(const TQString&); - -private: - KMDBCreator *m_creator; - TQDict< TQDict<KMDBEntryList> > m_entries; - TQDict< TQDict<KMDBEntryList> > m_pnpentries; - - static KMDriverDB *m_self; -}; - -#endif diff --git a/kdeprint/management/kmdriverdbwidget.cpp b/kdeprint/management/kmdriverdbwidget.cpp deleted file mode 100644 index e9c490206..000000000 --- a/kdeprint/management/kmdriverdbwidget.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmdriverdbwidget.h" -#include "kmdriverdb.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "driver.h" - -#include <klistbox.h> -#include <kpushbutton.h> -#include <tqcheckbox.h> -#include <kcursor.h> -#include <tqapplication.h> -#include <kmessagebox.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqstrlist.h> - -#include <klocale.h> -#include <kcursor.h> -#include <kfiledialog.h> -#include <kguiitem.h> -#include <kio/netaccess.h> - -KMDriverDbWidget::KMDriverDbWidget(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_external = TQString::null; - m_valid = false; - - // build widget - m_manu = new KListBox(this); - m_model = new KListBox(this); - m_postscript = new TQCheckBox(i18n("&PostScript printer"),this); - m_raw = new TQCheckBox(i18n("&Raw printer (no driver needed)"),this); - m_postscript->setCursor(KCursor::handCursor()); - m_raw->setCursor(KCursor::handCursor()); - m_other = new KPushButton(KGuiItem(i18n("&Other..."), "fileopen"), this); - TQLabel *l1 = new TQLabel(i18n("&Manufacturer:"), this); - TQLabel *l2 = new TQLabel(i18n("Mo&del:"), this); - l1->setBuddy(m_manu); - l2->setBuddy(m_model); - - // build layout - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); - TQGridLayout *sub1_ = new TQGridLayout(0, 2, 3, 0, 0); - TQHBoxLayout *sub2_ = new TQHBoxLayout(0, 0, 10); - main_->addLayout(TQT_TQLAYOUT(sub1_)); - main_->addLayout(sub2_); - main_->addWidget(m_raw); - sub1_->addWidget(l1,0,0); - sub1_->addWidget(l2,0,2); - sub1_->addWidget(m_manu,1,0); - sub1_->addWidget(m_model,1,2); - sub1_->addColSpacing(1,20); - sub2_->addWidget(m_postscript,1); - sub2_->addWidget(m_other,0); - - // build connections - connect(KMDriverDB::self(),TQT_SIGNAL(dbLoaded(bool)),TQT_SLOT(slotDbLoaded(bool))); - connect(KMDriverDB::self(), TQT_SIGNAL(error(const TQString&)), TQT_SLOT(slotError(const TQString&))); - connect(m_manu,TQT_SIGNAL(highlighted(const TQString&)),TQT_SLOT(slotManufacturerSelected(const TQString&))); - connect(m_raw,TQT_SIGNAL(toggled(bool)),m_manu,TQT_SLOT(setDisabled(bool))); - connect(m_raw,TQT_SIGNAL(toggled(bool)),m_model,TQT_SLOT(setDisabled(bool))); - connect(m_raw,TQT_SIGNAL(toggled(bool)),m_other,TQT_SLOT(setDisabled(bool))); - connect(m_raw,TQT_SIGNAL(toggled(bool)),m_postscript,TQT_SLOT(setDisabled(bool))); - connect(m_postscript,TQT_SIGNAL(toggled(bool)),m_manu,TQT_SLOT(setDisabled(bool))); - connect(m_postscript,TQT_SIGNAL(toggled(bool)),m_model,TQT_SLOT(setDisabled(bool))); - connect(m_postscript,TQT_SIGNAL(toggled(bool)),m_other,TQT_SLOT(setDisabled(bool))); - connect(m_postscript,TQT_SIGNAL(toggled(bool)),m_raw,TQT_SLOT(setDisabled(bool))); - connect(m_postscript,TQT_SIGNAL(toggled(bool)),TQT_SLOT(slotPostscriptToggled(bool))); - connect(m_other,TQT_SIGNAL(clicked()),TQT_SLOT(slotOtherClicked())); -} - -KMDriverDbWidget::~KMDriverDbWidget() -{ -} - -void KMDriverDbWidget::setDriver(const TQString& manu, const TQString& model) -{ - TQListBoxItem *item = m_manu->findItem(manu); - TQString model_(model); - if (item) - { - m_manu->setCurrentItem(item); - item = m_model->findItem(model_); - if (!item) - // try by stripping the manufacturer name from - // the beginning of the model string. This is - // often the case with PPD files - item = m_model->findItem(model_.replace(0,manu.length()+1,TQString::tqfromLatin1(""))); - if (item) - m_model->setCurrentItem(item); - } -} - -void KMDriverDbWidget::setHaveRaw(bool on) -{ - if (on) - m_raw->show(); - else - m_raw->hide(); -} - -void KMDriverDbWidget::setHaveOther(bool on) -{ - if (on) - m_other->show(); - else - m_other->hide(); -} - -TQString KMDriverDbWidget::manufacturer() -{ - return m_manu->currentText(); -} - -TQString KMDriverDbWidget::model() -{ - return m_model->currentText(); -} - -KMDBEntryList* KMDriverDbWidget::drivers() -{ - return KMDriverDB::self()->findEntry(manufacturer(),model()); -} - -bool KMDriverDbWidget::isRaw() -{ - return m_raw->isChecked(); -} - -void KMDriverDbWidget::init() -{ - if (!m_valid) - { - TQApplication::setOverrideCursor(KCursor::waitCursor()); - m_manu->clear(); - m_model->clear(); - m_manu->insertItem(i18n("Loading...")); - KMDriverDB::self()->init(this); - } -} - -void KMDriverDbWidget::slotDbLoaded(bool reloaded) -{ - TQApplication::restoreOverrideCursor(); - m_valid = true; - if (reloaded || m_manu->count() == 0 || (m_manu->count() == 1 && m_manu->text(0) == i18n("Loading..."))) - { // do something only if DB reloaded - m_manu->clear(); - m_model->clear(); - TQDictIterator< TQDict<KMDBEntryList> > it(KMDriverDB::self()->manufacturers()); - for (;it.current();++it) - m_manu->insertItem(it.currentKey()); - m_manu->sort(); - m_manu->setCurrentItem(0); - } -} - -void KMDriverDbWidget::slotError(const TQString& msg) -{ - TQApplication::restoreOverrideCursor(); - m_valid = false; - m_manu->clear(); - KMessageBox::error(this, "<qt>"+msg+"</qt>"); -} - -void KMDriverDbWidget::slotManufacturerSelected(const TQString& name) -{ - m_model->clear(); - TQDict<KMDBEntryList> *models = KMDriverDB::self()->findModels(name); - if (models) - { - TQStrIList ilist(true); - TQDictIterator<KMDBEntryList> it(*models); - for (;it.current();++it) - ilist.append(it.currentKey().latin1()); - ilist.sort(); - m_model->insertStrList(&ilist); - m_model->setCurrentItem(0); - } -} - -void KMDriverDbWidget::slotPostscriptToggled(bool on) -{ - if (on) - { - TQListBoxItem *item = m_manu->findItem("GENERIC"); - if (item) - { - m_manu->setCurrentItem(item); - item = m_model->findItem( "POSTSCRIPT PRINTER" ); - if ( item ) - { - m_model->setCurrentItem( item ); - return; - } - } - KMessageBox::error(this,i18n("Unable to find the PostScript driver.")); - m_postscript->setChecked(false); - } -} - -void KMDriverDbWidget::slotOtherClicked() -{ - if (m_external.isEmpty()) - { - KFileDialog dlg( TQString::null, TQString::null, this, 0, true ); - KURL url; - - dlg.setMode( KFile::File ); - dlg.setCaption( i18n( "Select Driver" ) ); - if ( dlg.exec() ) - url = dlg.selectedURL(); - - if ( !url.isEmpty() ) - { - TQString filename; - if ( KIO::NetAccess::download( url, filename, this ) ) - { - DrMain *driver = KMFactory::self()->manager()->loadFileDriver(filename); - if (driver) - { - m_external = filename; - disconnect(m_manu,TQT_SIGNAL(highlighted(const TQString&)),this,TQT_SLOT(slotManufacturerSelected(const TQString&))); - m_manu->clear(); - m_model->clear(); - TQString s = driver->get("manufacturer"); - m_manu->insertItem((s.isEmpty() ? i18n("<Unknown>") : s)); - s = driver->get("model"); - m_model->insertItem((s.isEmpty() ? i18n("<Unknown>") : s)); - m_manu->setCurrentItem(0); - m_model->setCurrentItem(0); - m_other->setText(i18n("Database")); - m_desc = driver->get("description"); - delete driver; - } - else - { - KIO::NetAccess::removeTempFile( filename ); - KMessageBox::error(this,"<qt>"+i18n("Wrong driver format.")+"<p>"+KMManager::self()->errorMsg()+"</p></qt>"); - } - } - } - } - else - { - m_external = TQString::null; - connect(m_manu,TQT_SIGNAL(highlighted(const TQString&)),this,TQT_SLOT(slotManufacturerSelected(const TQString&))); - m_other->setText(i18n("Other")); - m_desc = TQString::null; - slotDbLoaded(true); - } -} -#include "kmdriverdbwidget.moc" diff --git a/kdeprint/management/kmdriverdbwidget.h b/kdeprint/management/kmdriverdbwidget.h deleted file mode 100644 index 05b50536d..000000000 --- a/kdeprint/management/kmdriverdbwidget.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMDRIVERDBWIDGET_H -#define KMDRIVERDBWIDGET_H - -#include <tqwidget.h> -#include "kmdbentry.h" - -class TQListBox; -class TQCheckBox; -class TQPushButton; - -class KMDriverDbWidget : public TQWidget -{ - Q_OBJECT -public: - KMDriverDbWidget(TQWidget *parent = 0, const char *name = 0); - ~KMDriverDbWidget(); - - void init(); - void setHaveRaw(bool on); - void setHaveOther(bool on); - void setDriver(const TQString& manu, const TQString& model); - - TQString manufacturer(); - TQString model(); - TQString description() { return m_desc; } - KMDBEntryList* drivers(); - TQString driverFile(); - bool isRaw(); - bool isExternal(); - -protected slots: - void slotDbLoaded(bool reloaded); - void slotManufacturerSelected(const TQString& name); - void slotPostscriptToggled(bool); - void slotOtherClicked(); - void slotError(const TQString&); - -private: - TQListBox *m_manu; - TQListBox *m_model; - TQCheckBox *m_postscript; - TQCheckBox *m_raw; - TQPushButton *m_other; - TQString m_external; - TQString m_desc; - bool m_valid; -}; - -inline TQString KMDriverDbWidget::driverFile() -{ return m_external; } - -inline bool KMDriverDbWidget::isExternal() -{ return !(m_external.isEmpty()); } - -#endif diff --git a/kdeprint/management/kmdriverdialog.cpp b/kdeprint/management/kmdriverdialog.cpp deleted file mode 100644 index ef37e333c..000000000 --- a/kdeprint/management/kmdriverdialog.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmdriverdialog.h" -#include "driverview.h" - -#include <klocale.h> -#include <kmessagebox.h> - -KMDriverDialog::KMDriverDialog(TQWidget *parent, const char *name) -: KDialogBase(KDialogBase::Swallow,i18n("Configure"),KDialogBase::Ok|KDialogBase::Cancel,KDialogBase::Ok,parent,name,true,false) -{ - m_view = new DriverView(0); - setMainWidget(m_view); - - resize(400,450); -} - -KMDriverDialog::~KMDriverDialog() -{ -} - -void KMDriverDialog::setDriver(DrMain *d) -{ - m_view->setDriver(d); -} - -void KMDriverDialog::slotOk() -{ - if (m_view->hasConflict()) - { - KMessageBox::error(this, "<qt>"+i18n("Some options are in conflict. You must resolve those conflicts " - "before continuing.")+"</qt>"); - return; - } - KDialogBase::slotOk(); -} - -#include "kmdriverdialog.moc" diff --git a/kdeprint/management/kmdriverdialog.h b/kdeprint/management/kmdriverdialog.h deleted file mode 100644 index 8b7b01c45..000000000 --- a/kdeprint/management/kmdriverdialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMDRIVERDIALOG_H -#define KMDRIVERDIALOG_H - -#include <kdialogbase.h> - -class DriverView; -class DrMain; - -class KMDriverDialog : public KDialogBase -{ - Q_OBJECT -public: - KMDriverDialog(TQWidget *parent = 0, const char *name = 0); - ~KMDriverDialog(); - - void setDriver(DrMain*); - -protected slots: - void slotOk(); - -private: - DriverView *m_view; -}; - -#endif diff --git a/kdeprint/management/kmiconview.cpp b/kdeprint/management/kmiconview.cpp deleted file mode 100644 index 1fa5a6da9..000000000 --- a/kdeprint/management/kmiconview.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmiconview.h" -#include "kmprinter.h" - -#include <tqpainter.h> -#include <kiconloader.h> -#include <kdebug.h> - -KMIconViewItem::KMIconViewItem(TQIconView *parent, KMPrinter *p) -: TQIconViewItem(parent) -{ - m_state = 0; - m_mode = parent->itemTextPos(); - m_pixmap = TQString(); - m_isclass = false; - updatePrinter(p, m_mode); -} - -void KMIconViewItem::paintItem(TQPainter *p, const TQColorGroup& cg) -{ - if (m_state != 0) - { - QFont f(p->font()); - if (m_state & 0x1) f.setBold(true); - if (m_state & 0x2) f.setItalic(true); - p->setFont(f); - } - TQIconViewItem::paintItem(p,cg); -} - -void KMIconViewItem::calcRect(const TQString&) -{ - QRect ir(rect()), pr, tr; - - // pixmap rect - pr.setWidth(pixmap()->width()); - pr.setHeight(pixmap()->height()); - - // text rect - QFont f(iconView()->font()); - if (m_state & 0x1) f.setBold(true); - if (m_state & 0x2) f.setItalic(true); - QFontMetrics fm(f); - if (m_mode == TQIconView::Bottom) - tr = fm.boundingRect(0, 0, iconView()->maxItemWidth(), 0xFFFFFF, AlignHCenter|AlignTop|WordBreak|BreakAnywhere, text()+"X"); - else - tr = fm.boundingRect(0, 0, 0xFFFFFF, 0xFFFFFF, AlignLeft|AlignTop, text()+"X"); - - // item rect - if (m_mode == TQIconView::Bottom) - { - ir.setHeight(pr.height() + tr.height() + 15); - ir.setWidth(QMAX(pr.width(), tr.width()) + 10); - pr = TQRect((ir.width()-pr.width())/2, 5, pr.width(), pr.height()); - tr = TQRect((ir.width()-tr.width())/2, 10+pr.height(), tr.width(), tr.height()); - } - else - { - ir.setHeight(QMAX(pr.height(), tr.height()) + 4); - ir.setWidth(pr.width() + tr.width() + 6); - pr = TQRect(2, (ir.height()-pr.height())/2, pr.width(), pr.height()); - tr = TQRect(4+pr.width(), (ir.height()-tr.height())/2, tr.width(), tr.height()); - } - - // set rects - setItemRect(ir); - setTextRect(tr); - setPixmapRect(pr); -} - -void KMIconViewItem::updatePrinter(KMPrinter *p, int mode) -{ - bool update(false); - int oldstate = m_state; - if (p) - { - m_state = ((p->isHardDefault() ? 0x1 : 0x0) | (p->ownSoftDefault() ? 0x2 : 0x0) | (p->isValid() ? 0x4 : 0x0)); - update = (oldstate != m_state); - if (p->name() != text() || update) - { - setText(TQString::null); - setText(p->name()); - } - setKey(TQString::tqfromLatin1("%1_%2").arg((p->isSpecial() ? "special" : (p->isClass(false) ? "class" : "printer"))).arg(p->name())); - m_isclass = p->isClass(false); - } - if (mode != m_mode || ((oldstate&0x4) != (m_state&0x4)) || (p && p->pixmap() != m_pixmap)) - { - int iconstate = (m_state&0x4 ? (int)KIcon::DefaultState : (int)KIcon::LockOverlay); - if (p) - m_pixmap = p->pixmap(); - m_mode = mode; - if (m_mode == TQIconView::Bottom) - setPixmap(DesktopIcon(m_pixmap, 0, iconstate)); - else - setPixmap(SmallIcon(m_pixmap, 0, iconstate)); - } - //if (update) - // tqrepaint(); - setDiscarded(false); -} - -KMIconView::KMIconView(TQWidget *parent, const char *name) -: KIconView(parent,name) -{ - setMode(KIconView::Select); - setSelectionMode(TQIconView::Single); - setItemsMovable(false); - setResizeMode(TQIconView::Adjust); - - m_items.setAutoDelete(false); - setViewMode(KMIconView::Big); - - connect(this,TQT_SIGNAL(contextMenuRequested(TQIconViewItem*,const TQPoint&)),TQT_SLOT(slotRightButtonClicked(TQIconViewItem*,const TQPoint&))); - connect(this,TQT_SIGNAL(selectionChanged()),TQT_SLOT(slotSelectionChanged())); -} - -KMIconView::~KMIconView() -{ -} - -KMIconViewItem* KMIconView::findItem(KMPrinter *p) -{ - if (p) - { - TQPtrListIterator<KMIconViewItem> it(m_items); - for (;it.current();++it) - if (it.current()->text() == p->name() - && it.current()->isClass() == p->isClass()) - return it.current(); - } - return 0; -} - -void KMIconView::setPrinterList(TQPtrList<KMPrinter> *list) -{ - bool changed(false); - - TQPtrListIterator<KMIconViewItem> it(m_items); - for (;it.current();++it) - it.current()->setDiscarded(true); - - if (list) - { - TQPtrListIterator<KMPrinter> it(*list); - KMIconViewItem *item(0); - for (;it.current();++it) - { - // only keep real printers (no instances) - if (!it.current()->instanceName().isEmpty()) - continue; - item = findItem(it.current()); - if (!item) - { - item = new KMIconViewItem(this,it.current()); - m_items.append(item); - changed = true; - } - else - item->updatePrinter(it.current(), itemTextPos()); - } - } - - for (uint i=0; i<m_items.count(); i++) - if (m_items.tqat(i)->isDiscarded()) - { - delete m_items.take(i); - i--; - changed = true; - } - - if (changed) sort(); - emit selectionChanged(); -} - -void KMIconView::setViewMode(ViewMode m) -{ - m_mode = m; - bool big = (m == KMIconView::Big); - int mode = (big ? TQIconView::Bottom : TQIconView::Right); - - TQPtrListIterator<KMIconViewItem> it(m_items); - for (;it.current();++it) - it.current()->updatePrinter(0, mode); - - setArrangement((big ? TQIconView::LeftToRight : TQIconView::TopToBottom)); - setItemTextPos((TQIconView::ItemTextPos)mode); - //setGridX((big ? 60 : -1)); - setWordWrapIconText(true); -} - -void KMIconView::slotRightButtonClicked(TQIconViewItem *item, const TQPoint& p) -{ - emit rightButtonClicked(item ? item->text() : TQString::null, p); -} - -void KMIconView::slotSelectionChanged() -{ - KMIconViewItem *item = static_cast<KMIconViewItem*>(currentItem()); - emit printerSelected((item && !item->isDiscarded() && item->isSelected() ? item->text() : TQString::null)); -} - -void KMIconView::setPrinter(const TQString& prname) -{ - TQPtrListIterator<KMIconViewItem> it(m_items); - for (; it.current(); ++it) - if (it.current()->text() == prname) - { - setSelected(it.current(), true); - break; - } -} - -void KMIconView::setPrinter(KMPrinter *p) -{ - setPrinter(p ? p->name() : TQString::null); -} - -#include "kmiconview.moc" diff --git a/kdeprint/management/kmiconview.h b/kdeprint/management/kmiconview.h deleted file mode 100644 index 1fd6fbbda..000000000 --- a/kdeprint/management/kmiconview.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMICONVIEW_H -#define KMICONVIEW_H - -#include <kiconview.h> -#include <tqptrlist.h> - -#include "kmobject.h" - -class KMPrinter; - -class KMIconViewItem : public TQIconViewItem, public KMObject -{ -public: - KMIconViewItem(TQIconView *parent, KMPrinter *p); - void updatePrinter(KMPrinter *printer = 0, int mode = TQIconView::Bottom); - bool isClass() const { return m_isclass; } - -protected: - virtual void paintItem(TQPainter*, const TQColorGroup&); - virtual void calcRect(const TQString& text_ = TQString::null); - -private: - int m_mode; - QString m_pixmap; - char m_state; - bool m_isclass; -}; - -class KMIconView : public KIconView -{ - Q_OBJECT -public: - enum ViewMode { Big, Small }; - - KMIconView(TQWidget *parent = 0, const char *name = 0); - ~KMIconView(); - - void setPrinterList(TQPtrList<KMPrinter> *list); - void setPrinter(const TQString&); - void setPrinter(KMPrinter*); - void setViewMode(ViewMode); - -signals: - void rightButtonClicked(const TQString&, const TQPoint&); - void printerSelected(const TQString&); - -protected slots: - void slotRightButtonClicked(TQIconViewItem*, const TQPoint&); - void slotSelectionChanged(); - -private: - KMIconViewItem* findItem(KMPrinter *p); - -private: - TQPtrList<KMIconViewItem> m_items; - ViewMode m_mode; -}; - -#endif diff --git a/kdeprint/management/kminfopage.cpp b/kdeprint/management/kminfopage.cpp deleted file mode 100644 index ad43f1ccb..000000000 --- a/kdeprint/management/kminfopage.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kminfopage.h" -#include "kmprinter.h" - -#include <tqpixmap.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kseparator.h> - -KMInfoPage::KMInfoPage(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_title = new TQLabel(this); - m_titlepixmap = new TQLabel(this); - m_titlepixmap->tqsetAlignment(Qt::AlignCenter); - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - m_type = new TQLabel(this); - m_description = new TQLabel(this); - m_state = new TQLabel(this); - m_location = new TQLabel(this); - m_model = new TQLabel(this); - m_uri = new TQLabel(this); - m_device = new TQLabel(this); - TQLabel *m_loclabel = new TQLabel(i18n("Physical Location", "Location:"), this); - m_loclabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - TQLabel *m_desclabel = new TQLabel(i18n("Description:"), this); - m_desclabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - TQLabel *m_typelabel = new TQLabel(i18n("Type:"), this); - m_typelabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - TQLabel *m_statelabel = new TQLabel(i18n("Status", "State:"), this); - m_statelabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - TQLabel *m_urilabel = new TQLabel(i18n("URI:"), this); - m_urilabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - m_devlabel = new TQLabel(i18n("Device:"), this); - m_devlabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - TQLabel *m_modellabel = new TQLabel(i18n("Model:"), this); - m_modellabel->tqsetAlignment(Qt::AlignRight|Qt::AlignVCenter); - - TQGridLayout *lay0 = new TQGridLayout(this, 11, 2, 0, 5); - TQHBoxLayout *lay1 = new TQHBoxLayout(0, 0, 10); - lay0->addRowSpacing(7,20); - lay0->setRowStretch(7,0); - lay0->setRowStretch(10,1); - lay0->setColStretch(1,1); - lay0->addMultiCellLayout(lay1, 0, 0, 0, 1); - lay0->addMultiCellWidget(sep, 1, 1, 0, 1); - lay0->addWidget(m_typelabel, 2, 0); - lay0->addWidget(m_statelabel, 3, 0); - lay0->addWidget(m_loclabel, 4, 0); - lay0->addWidget(m_desclabel, 5, 0); - lay0->addWidget(m_urilabel, 6, 0); - lay0->addWidget(m_devlabel, 8, 0); - lay0->addWidget(m_modellabel, 9, 0); - lay0->addWidget(m_type, 2, 1); - lay0->addWidget(m_state, 3, 1); - lay0->addWidget(m_location, 4, 1); - lay0->addWidget(m_description, 5, 1); - lay0->addWidget(m_uri, 6, 1); - lay0->addWidget(m_device, 8, 1); - lay0->addWidget(m_model, 9, 1); - lay1->addWidget(m_title, 1); - lay1->addWidget(m_titlepixmap, 0); -} - -KMInfoPage::~KMInfoPage() -{ -} - -void KMInfoPage::setPrinter(KMPrinter *p) -{ - // change "Device" label if it's a real class (not true for implicit classes) - if (p && p->isClass(false)) m_devlabel->setText(i18n("Members:")); - else m_devlabel->setText(i18n("Device:")); - - // clear everything if p == 0 - if (!p) - { - m_title->setText(TQString::null); - m_titlepixmap->setPixmap(TQPixmap()); - m_type->setText(TQString::null); - m_state->setText(TQString::null); - m_location->setText(TQString::null); - m_description->setText(TQString::null); - m_uri->setText(TQString::null); - m_device->setText(TQString::null); - m_model->setText(TQString::null); - } - else - { - m_title->setText(TQString::tqfromLatin1("<b>%1</b>").arg(p->name())); - m_titlepixmap->setPixmap(SmallIcon(p->pixmap())); - if (p->isImplicit()) m_type->setText(i18n("Implicit class")); - else if (p->isClass(false)) - if (p->isRemote()) m_type->setText(i18n("Remote class")); - else m_type->setText(i18n("Local class")); - else if (p->isPrinter()) - if (p->isRemote()) m_type->setText(i18n("Remote printer")); - else m_type->setText(i18n("Local printer")); - else if (p->isSpecial()) - m_type->setText(i18n("Special (pseudo) printer")); - else m_type->setText(i18n("Unknown class of printer", "Unknown")); - m_state->setText(p->stateString()); - m_location->setText(p->location()); - m_description->setText(p->description()); - m_uri->setText(p->uri().prettyURL()); - if (p->isClass(false)) - { - QString s; - for (TQStringList::ConstIterator it=p->members().begin(); it!=p->members().end(); ++it) - s.append(KURL(*it).prettyURL() + ", "); - s.truncate(s.length()-2); - m_device->setText(s); - } - else - { - // double decoding in case printer name contains - // annoying chars like '#' - KURL dev(p->device()); - m_device->setText(KURL::decode_string(dev.prettyURL())); - } - m_model->setText(p->driverInfo()); - } -} diff --git a/kdeprint/management/kminfopage.h b/kdeprint/management/kminfopage.h deleted file mode 100644 index 591fdbfe8..000000000 --- a/kdeprint/management/kminfopage.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMINFOPAGE_H -#define KMINFOPAGE_H - -#include "kmprinterpage.h" -#include <tqwidget.h> - -class TQLabel; - -class KMInfoPage : public TQWidget, public KMPrinterPage -{ -public: - KMInfoPage(TQWidget *parent = 0, const char *name = 0); - ~KMInfoPage(); - - void setPrinter(KMPrinter *p); - -protected: - TQLabel *m_title, *m_titlepixmap; - TQLabel *m_location, *m_description, *m_uri, *m_model, *m_type, *m_state, *m_device; - TQLabel *m_devlabel; -}; - -#endif diff --git a/kdeprint/management/kminstancepage.cpp b/kdeprint/management/kminstancepage.cpp deleted file mode 100644 index 25c037516..000000000 --- a/kdeprint/management/kminstancepage.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kminstancepage.h" -#include "kmprinter.h" -#include "kmfactory.h" -#include "kmvirtualmanager.h" -#include "kmmanager.h" -#include "kprinterpropertydialog.h" -#include "kprinter.h" -#include "kmtimer.h" - -#include <tqlayout.h> -#include <tqregexp.h> -#include <tqwhatsthis.h> -#include <tqpushbutton.h> -#include <kmessagebox.h> -#include <kinputdialog.h> -#include <klistbox.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kstandarddirs.h> -#include <kdebug.h> - -KMInstancePage::KMInstancePage(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_view = new KListBox(this); - m_printer = 0; - - initActions(); - - TQHBoxLayout *main_ = new TQHBoxLayout(this, 0, 0); - main_->addWidget(m_view); - TQVBoxLayout *sub_ = new TQVBoxLayout(0, 0, 0); - main_->addLayout(sub_); - for (TQValueList<TQButton*>::Iterator it=m_buttons.begin(); it!=m_buttons.end(); ++it) - if (*it) - sub_->addWidget(*it); - else - sub_->addSpacing(10); - sub_->addStretch(1); - - TQWhatsThis::add(this, - i18n("Define/Edit here instances for the current selected " - "printer. An instance is a combination of a real " - "(physical) printer and a set of predefined options. " - "For a single InkJet printer, you could define different " - "print formats like <i>DraftQuality</i>, <i>PhotoQuality</i> " - "or <i>TwoSided</i>. Those instances appear as normal " - "printers in the print dialog and allow you to quickly " - "select the print format you want.")); -} - -KMInstancePage::~KMInstancePage() -{ -} - -void KMInstancePage::addButton(const TQString& txt, const TQString& pixmap, const char *receiver) -{ - TQPushButton *btn = new TQPushButton(this, 0L); - btn->setText(txt); - btn->setIconSet(BarIconSet(pixmap)); - btn->setFlat(true); - connect(btn, TQT_SIGNAL(clicked()), receiver); - m_buttons.append(btn); -} - -void KMInstancePage::initActions() -{ - addButton(i18n("New..."), "filenew", TQT_SLOT(slotNew())); - addButton(i18n("Copy..."), "editcopy", TQT_SLOT(slotCopy())); - addButton(i18n("Remove"), "edittrash", TQT_SLOT(slotRemove())); - m_buttons.append(0); - addButton(i18n("Set as Default"), "exec", TQT_SLOT(slotDefault())); - addButton(i18n("Settings"), "configure", TQT_SLOT(slotSettings())); - m_buttons.append(0); - addButton(i18n("Test..."), "fileprint", TQT_SLOT(slotTest())); -} - -void KMInstancePage::setPrinter(KMPrinter *p) -{ - TQString oldText = m_view->currentText(); - - m_view->clear(); - m_printer = p; - //bool ok = (p && !p->isSpecial()); - bool ok = (p != 0); - if (ok) - { - TQPtrList<KMPrinter> list; - KMFactory::self()->virtualManager()->virtualList(list,p->name()); - TQPtrListIterator<KMPrinter> it(list); - for (;it.current();++it) - { - TQStringList pair = TQStringList::split('/',it.current()->name(),false); - m_view->insertItem(SmallIcon((it.current()->isSoftDefault() ? "exec" : "fileprint")),(pair.count() > 1 ? pair[1] : i18n("(Default)"))); - } - m_view->sort(); - } - - for (TQValueList<TQButton*>::ConstIterator it=m_buttons.begin(); it!=m_buttons.end(); ++it) - if (*it) - (*it)->setEnabled(ok); - - //iif (!oldText.isEmpty()) - //{ - TQListBoxItem *item = m_view->findItem(oldText); - if (!item) - item = m_view->findItem(i18n("(Default)")); - if (item) - m_view->setSelected(item,true); - //} -} - -void KMInstancePage::slotNew() -{ - KMTimer::self()->hold(); - - bool ok(false); - TQString name = KInputDialog::getText(i18n("Instance Name"),i18n("Enter name for new instance (leave untouched for default):"), - i18n("(Default)"),&ok,this); - if (ok) - { - if (name.find(TQRegExp("[/\\s]")) != -1) - KMessageBox::error(this, i18n("Instance name must not contain any spaces or slashes.")); - else - { - if (name == i18n("(Default)")) - name = TQString(); - KMFactory::self()->virtualManager()->create(m_printer,name); - setPrinter(m_printer); - } - } - - KMTimer::self()->release(); -} - -void KMInstancePage::slotRemove() -{ - KMTimer::self()->hold(); - bool reload(false); - - TQString src = m_view->currentText(); - TQString msg = (src != i18n("(Default)") ? i18n("Do you really want to remove instance %1?") : i18n("You can't remove the default instance. However all settings of %1 will be discarded. Continue?")); - if (!src.isEmpty() && KMessageBox::warningContinueCancel(this,msg.arg(src),TQString(),KStdGuiItem::del()) == KMessageBox::Continue) - { - if (src == i18n("(Default)")) - src = TQString(); - reload = KMFactory::self()->virtualManager()->isDefault(m_printer,src); - KMFactory::self()->virtualManager()->remove(m_printer,src); - setPrinter(m_printer); - } - - KMTimer::self()->release(reload); -} - -void KMInstancePage::slotCopy() -{ - KMTimer::self()->hold(); - - TQString src = m_view->currentText(); - if (!src.isEmpty()) - { - bool ok(false); - TQString name = KInputDialog::getText(i18n("Instance Name"),i18n("Enter name for new instance (leave untouched for default):"), - i18n("(Default)"),&ok,this); - if (ok) - { - if (name.find(TQRegExp("[/\\s]")) != -1) - KMessageBox::error(this, i18n("Instance name must not contain any spaces or slashes.")); - else - { - if (src == i18n("(Default)")) - src = TQString(); - if (name == i18n("(Default)")) - name = TQString(); - KMFactory::self()->virtualManager()->copy(m_printer,src,name); - setPrinter(m_printer); - } - } - } - - KMTimer::self()->release(); -} - -void KMInstancePage::slotSettings() -{ - KMTimer::self()->hold(); - - TQString src = m_view->currentText(); - if (!src.isEmpty()) - { - if (src == i18n("(Default)")) src = TQString(); - KMPrinter *pr = KMFactory::self()->virtualManager()->findInstance(m_printer,src); - if ( !pr ) - KMessageBox::error( this, i18n( "Unable to find instance %1." ).arg( m_view->currentText() ) ); - else if ( !pr->isSpecial() && !KMFactory::self()->manager()->completePrinterShort( pr ) ) - KMessageBox::error( this, i18n( "Unable to retrieve printer information. Message from printing system: %1." ).arg( KMFactory::self()->manager()->errorMsg() ) ); - else - { - int oldAppType = KMFactory::self()->settings()->application; - KMFactory::self()->settings()->application = -1; - KPrinterPropertyDialog::setupPrinter(pr, this); - KMFactory::self()->settings()->application = oldAppType; - if (pr->isEdited()) - { // printer edited, need to save changes - pr->setDefaultOptions(pr->editedOptions()); - pr->setEditedOptions(TQMap<TQString,TQString>()); - pr->setEdited(false); - KMFactory::self()->virtualManager()->triggerSave(); - } - } - } - else - KMessageBox::error( this, i18n( "The instance name is empty. Please select an instance." ) ); - - KMTimer::self()->release(); -} - -void KMInstancePage::slotDefault() -{ - KMTimer::self()->hold(); - - TQString src = m_view->currentText(); - if (!src.isEmpty()) - { - if (src == i18n("(Default)")) - src = TQString(); - KMFactory::self()->virtualManager()->setAsDefault(m_printer,src); - setPrinter(m_printer); - } - - KMTimer::self()->release(true); -} - -void KMInstancePage::slotTest() -{ - KMTimer::self()->hold(); - - TQString src = m_view->currentText(); - if (!src.isEmpty()) - { - if (src == i18n("(Default)")) - src = TQString(); - KMPrinter *mpr = KMFactory::self()->virtualManager()->findInstance(m_printer,src); - if (!mpr) - KMessageBox::error(this,i18n("Internal error: printer not found.")); - else if (KMessageBox::warningContinueCancel(this, i18n("You are about to print a test page on %1. Do you want to continue?").arg(mpr->printerName()), TQString(), i18n("Print Test Page"), "printTestPage") == KMessageBox::Continue) - { - if (!KMFactory::self()->virtualManager()->testInstance(mpr)) - KMessageBox::error(this, i18n("Unable to send test page to %1.").arg(mpr->printerName())); - else - KMessageBox::information(this,i18n("Test page successfully sent to printer %1.").arg(mpr->printerName())); - } - } - - KMTimer::self()->release(false); -} -#include "kminstancepage.moc" diff --git a/kdeprint/management/kminstancepage.h b/kdeprint/management/kminstancepage.h deleted file mode 100644 index 7a3075d73..000000000 --- a/kdeprint/management/kminstancepage.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMINSTANCEPAGE_H -#define KMINSTANCEPAGE_H - -#include "kmprinterpage.h" -#include <tqvaluelist.h> -#include <tqwidget.h> - -class KListBox; -class KMPrinter; -class TQButton; - -class KMInstancePage : public TQWidget, public KMPrinterPage -{ - Q_OBJECT -public: - KMInstancePage(TQWidget *parent = 0, const char *name = 0); - ~KMInstancePage(); - - void setPrinter(KMPrinter*); - -protected slots: - void slotNew(); - void slotCopy(); - void slotRemove(); - void slotDefault(); - void slotTest(); - void slotSettings(); - -protected: - void initActions(); - void addButton(const TQString& text, const TQString& pixmap, const char *receiver); - -private: - KListBox *m_view; - TQValueList<TQButton*> m_buttons; - KMPrinter *m_printer; -}; - -#endif diff --git a/kdeprint/management/kmjobviewer.cpp b/kdeprint/management/kmjobviewer.cpp deleted file mode 100644 index 7f168faed..000000000 --- a/kdeprint/management/kmjobviewer.cpp +++ /dev/null @@ -1,742 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmjobviewer.h" -#include "kmjobmanager.h" -#include "kmfactory.h" -#include "kmjob.h" -#include "kmprinter.h" -#include "kmmanager.h" -#include "kmuimanager.h" -#include "jobitem.h" -#include "kmtimer.h" -#include "kmconfigjobs.h" -#include "kmconfigpage.h" -#include "kprinter.h" - -#include <klistview.h> -#include <kstatusbar.h> -#include <tqpopupmenu.h> -#include <kmessagebox.h> -#include <klocale.h> -#include <kpopupmenu.h> -#include <kaction.h> -#include <kstdaction.h> -#include <kiconloader.h> -#include <kapplication.h> -#include <kcursor.h> -#include <kmenubar.h> -#include <kdebug.h> -#include <kwin.h> -#include <kio/netaccess.h> -#include <tqtimer.h> -#include <tqlayout.h> -#include <stdlib.h> -#include <tqlineedit.h> -#include <kdialogbase.h> -#include <tqcheckbox.h> -#include <kurldrag.h> -#include <kconfig.h> - -#undef m_manager -#define m_manager KMFactory::self()->jobManager() - -class KJobListView : public KListView -{ -public: - KJobListView( TQWidget *parent = 0, const char *name = 0 ); - -protected: - bool acceptDrag( TQDropEvent* ) const; -}; - -KJobListView::KJobListView( TQWidget *parent, const char *name ) - : KListView( parent, name ) -{ - setAcceptDrops( true ); - setDropVisualizer( false ); -} - -bool KJobListView::acceptDrag( TQDropEvent *e ) const -{ - if ( KURLDrag::canDecode( e ) ) - return true; - else - return KListView::acceptDrag( e ); -} - -KMJobViewer::KMJobViewer(TQWidget *parent, const char *name) -: KMainWindow(parent,name) -{ - m_view = 0; - m_pop = 0; - m_jobs.setAutoDelete(false); - m_items.setAutoDelete(false); - m_printers.setAutoDelete(false); - m_type = KMJobManager::ActiveJobs; - m_stickybox = 0; - m_standalone = ( parent == NULL ); - - setToolBarsMovable(false); - init(); - - if (m_standalone) - { - setCaption(i18n("No Printer")); - KConfig *conf = KMFactory::self()->printConfig(); - TQSize defSize( 550, 250 ); - conf->setGroup( "Jobs" ); - resize( conf->readSizeEntry( "Size", &defSize ) ); - } -} - -KMJobViewer::~KMJobViewer() -{ - if (m_standalone) - { - kdDebug( 500 ) << "Destroying stand-alone job viewer window" << endl; - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup( "Jobs" ); - conf->writeEntry( "Size", size() ); - emit viewerDestroyed(this); - } - removeFromManager(); -} - -void KMJobViewer::setPrinter(KMPrinter *p) -{ - setPrinter((p ? p->printerName() : TQString::null)); -} - -void KMJobViewer::setPrinter(const TQString& prname) -{ - // We need to trigger a refresh even if the printer - // has not changed, some jobs may have been canceled - // outside tdeprint. We can't return simply if - // prname == m_prname. - if (m_prname != prname) - { - removeFromManager(); - m_prname = prname; - addToManager(); - m_view->setAcceptDrops( prname != i18n( "All Printers" ) ); - } - triggerRefresh(); -} - -void KMJobViewer::updateCaption() -{ - if (!m_standalone) - return; - - TQString pixname("fileprint"); - if (!m_prname.isEmpty()) - { - setCaption(i18n("Print Jobs for %1").arg(m_prname)); - KMPrinter *prt = KMManager::self()->findPrinter(m_prname); - if (prt) - pixname = prt->pixmap(); - } - else - { - setCaption(i18n("No Printer")); - } - KWin::setIcons(winId(), DesktopIcon(pixname), SmallIcon(pixname)); -} - -void KMJobViewer::updateStatusBar() -{ - if (!m_standalone) - return; - - int limit = m_manager->limit(); - if (limit == 0) - statusBar()->changeItem(i18n("Max.: %1").arg(i18n("Unlimited")), 0); - else - statusBar()->changeItem(i18n("Max.: %1").arg(limit), 0); -} - -void KMJobViewer::addToManager() -{ - if (m_prname == i18n("All Printers")) - { - loadPrinters(); - TQPtrListIterator<KMPrinter> it(m_printers); - for (; it.current(); ++it) - m_manager->addPrinter(it.current()->printerName(), (KMJobManager::JobType)m_type, it.current()->isSpecial()); - } - else if (!m_prname.isEmpty()) - { - KMPrinter *prt = KMManager::self()->findPrinter( m_prname ); - bool isSpecial = ( prt ? prt->isSpecial() : false ); - m_manager->addPrinter(m_prname, (KMJobManager::JobType)m_type, isSpecial); - } -} - -void KMJobViewer::removeFromManager() -{ - if (m_prname == i18n("All Printers")) - { - TQPtrListIterator<KMPrinter> it(m_printers); - for (; it.current(); ++it) - m_manager->removePrinter(it.current()->printerName(), (KMJobManager::JobType)m_type); - } - else if (!m_prname.isEmpty()) - { - m_manager->removePrinter(m_prname, (KMJobManager::JobType)m_type); - } -} - -void KMJobViewer::refresh(bool reload) -{ - m_jobs.clear(); - TQPtrListIterator<KMJob> it(m_manager->jobList(reload)); - bool all = (m_prname == i18n("All Printers")), active = (m_type == KMJobManager::ActiveJobs); - for (; it.current(); ++it) - if ((all || it.current()->printer() == m_prname) - && ((it.current()->state() >= KMJob::Cancelled && !active) - || (it.current()->state() < KMJob::Cancelled && active)) - && (m_username.isEmpty() || m_username == it.current()->owner())) - m_jobs.append(it.current()); - updateJobs(); - - - // update the caption and icon (doesn't do anything if it has a parent widget) - updateCaption(); - - updateStatusBar(); - - // do it last as this signal can cause this view to be destroyed. No - // code can be executed safely after that - emit jobsShown(this, (m_jobs.count() != 0)); -} - -void KMJobViewer::init() -{ - if (!m_view) - { - m_view = new KJobListView(this); - m_view->addColumn(i18n("Job ID")); - m_view->addColumn(i18n("Owner")); - m_view->addColumn(i18n("Name"), 150); - m_view->addColumn(i18n("Status", "State")); - m_view->addColumn(i18n("Size (KB)")); - m_view->addColumn(i18n("Page(s)")); - m_view->setColumnAlignment(5,Qt::AlignRight|Qt::AlignVCenter); - connect( m_view, TQT_SIGNAL( dropped( TQDropEvent*, TQListViewItem* ) ), TQT_SLOT( slotDropped( TQDropEvent*, TQListViewItem* ) ) ); - //m_view->addColumn(i18n("Printer")); - //m_view->setColumnAlignment(6,Qt::AlignRight|Qt::AlignVCenter); - KMFactory::self()->uiManager()->setupJobViewer(m_view); - m_view->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - m_view->setLineWidth(1); - m_view->setSorting(0); - m_view->setAllColumnsShowFocus(true); - m_view->setSelectionMode(TQListView::Extended); - connect(m_view,TQT_SIGNAL(selectionChanged()),TQT_SLOT(slotSelectionChanged())); - connect(m_view,TQT_SIGNAL(rightButtonPressed(TQListViewItem*,const TQPoint&,int)),TQT_SLOT(slotRightClicked(TQListViewItem*,const TQPoint&,int))); - setCentralWidget(m_view); - } - - initActions(); -} - -void KMJobViewer::initActions() -{ - // job actions - KAction *hact = new KAction(i18n("&Hold"),"stop",0,TQT_TQOBJECT(this),TQT_SLOT(slotHold()),actionCollection(),"job_hold"); - KAction *ract = new KAction(i18n("&Resume"),"run",0,TQT_TQOBJECT(this),TQT_SLOT(slotResume()),actionCollection(),"job_resume"); - KAction *dact = new KAction(i18n("Remo&ve"),"edittrash",Qt::Key_Delete,TQT_TQOBJECT(this),TQT_SLOT(slotRemove()),actionCollection(),"job_remove"); - KAction *sact = new KAction(i18n("Res&tart"),"redo",0,TQT_TQOBJECT(this),TQT_SLOT(slotRestart()),actionCollection(),"job_restart"); - KActionMenu *mact = new KActionMenu(i18n("&Move to Printer"),"fileprint",actionCollection(),"job_move"); - mact->setDelayed(false); - connect(mact->popupMenu(),TQT_SIGNAL(activated(int)),TQT_SLOT(slotMove(int))); - connect(mact->popupMenu(),TQT_SIGNAL(aboutToShow()),KMTimer::self(),TQT_SLOT(hold())); - connect(mact->popupMenu(),TQT_SIGNAL(aboutToHide()),KMTimer::self(),TQT_SLOT(release())); - connect(mact->popupMenu(),TQT_SIGNAL(aboutToShow()),TQT_SLOT(slotShowMoveMenu())); - KToggleAction *tact = new KToggleAction(i18n("&Toggle Completed Jobs"),"history",0,actionCollection(),"view_completed"); - tact->setEnabled(m_manager->actions() & KMJob::ShowCompleted); - connect(tact,TQT_SIGNAL(toggled(bool)),TQT_SLOT(slotShowCompleted(bool))); - KToggleAction *uact = new KToggleAction(i18n("Show Only User Jobs"), "personal", 0, actionCollection(), "view_user_jobs"); - uact->setCheckedState(KGuiItem(i18n("Hide Only User Jobs"),"personal")); - connect(uact, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotUserOnly(bool))); - m_userfield = new TQLineEdit(0); - m_userfield->setText(getenv("USER")); - connect(m_userfield, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotUserChanged())); - connect(uact, TQT_SIGNAL(toggled(bool)), m_userfield, TQT_SLOT(setEnabled(bool))); - m_userfield->setEnabled(false); - m_userfield->tqsetSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed)); - KWidgetAction *ufact = new KWidgetAction(m_userfield, i18n("User Name"), 0, 0, 0, actionCollection(), "view_username"); - - if (!m_pop) - { - m_pop = new TQPopupMenu(this); - connect(m_pop,TQT_SIGNAL(aboutToShow()),KMTimer::self(),TQT_SLOT(hold())); - connect(m_pop,TQT_SIGNAL(aboutToHide()),KMTimer::self(),TQT_SLOT(release())); - hact->plug(m_pop); - ract->plug(m_pop); - m_pop->insertSeparator(); - dact->plug(m_pop); - mact->plug(m_pop); - m_pop->insertSeparator(); - sact->plug(m_pop); - } - - // Filter actions - KActionMenu *fact = new KActionMenu(i18n("&Select Printer"), "tdeprint_printer", actionCollection(), "filter_modify"); - fact->setDelayed(false); - connect(fact->popupMenu(),TQT_SIGNAL(activated(int)),TQT_SLOT(slotPrinterSelected(int))); - connect(fact->popupMenu(),TQT_SIGNAL(aboutToShow()),KMTimer::self(),TQT_SLOT(hold())); - connect(fact->popupMenu(),TQT_SIGNAL(aboutToHide()),KMTimer::self(),TQT_SLOT(release())); - connect(fact->popupMenu(),TQT_SIGNAL(aboutToShow()),TQT_SLOT(slotShowPrinterMenu())); - - if (!m_standalone) - { - KToolBar *toolbar = toolBar(); - hact->plug(toolbar); - ract->plug(toolbar); - toolbar->insertSeparator(); - dact->plug(toolbar); - mact->plug(toolbar); - toolbar->insertSeparator(); - sact->plug(toolbar); - toolbar->insertSeparator(); - tact->plug(toolbar); - uact->plug(toolbar); - ufact->plug(toolbar); - } - else - {// stand-alone application - KStdAction::quit(TQT_TQOBJECT(kapp),TQT_SLOT(quit()),actionCollection()); - KStdAction::close(TQT_TQOBJECT(this),TQT_SLOT(slotClose()),actionCollection()); - KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(slotConfigure()), actionCollection()); - - // refresh action - new KAction(i18n("Refresh"),"reload",0,TQT_TQOBJECT(this),TQT_SLOT(slotRefresh()),actionCollection(),"refresh"); - - // create status bar - KStatusBar *statusbar = statusBar(); - m_stickybox = new TQCheckBox( i18n( "Keep window permanent" ), statusbar ); - statusbar->addWidget( m_stickybox, 1, false ); - statusbar->insertItem(" " + i18n("Max.: %1").arg(i18n("Unlimited"))+ " ", 0, 0, true); - statusbar->setItemFixed(0); - updateStatusBar(); - - createGUI(); - } - - loadPluginActions(); - slotSelectionChanged(); -} - -void KMJobViewer::buildPrinterMenu(TQPopupMenu *menu, bool use_all, bool use_specials) -{ - loadPrinters(); - menu->clear(); - - TQPtrListIterator<KMPrinter> it(m_printers); - int i(0); - if (use_all) - { - menu->insertItem(SmallIcon("fileprint"), i18n("All Printers"), i++); - menu->insertSeparator(); - } - for (; it.current(); ++it, i++) - { - if ( !it.current()->instanceName().isEmpty() || - ( it.current()->isSpecial() && !use_specials ) ) - continue; - menu->insertItem(SmallIcon(it.current()->pixmap()), it.current()->printerName(), i); - } -} - -void KMJobViewer::slotShowMoveMenu() -{ - TQPopupMenu *menu = static_cast<KActionMenu*>(actionCollection()->action("job_move"))->popupMenu(); - buildPrinterMenu(menu, false, false); -} - -void KMJobViewer::slotShowPrinterMenu() -{ - TQPopupMenu *menu = static_cast<KActionMenu*>(actionCollection()->action("filter_modify"))->popupMenu(); - buildPrinterMenu(menu, true, true); -} - -void KMJobViewer::updateJobs() -{ - TQPtrListIterator<JobItem> jit(m_items); - for (;jit.current();++jit) - jit.current()->setDiscarded(true); - - TQPtrListIterator<KMJob> it(m_jobs); - for (;it.current();++it) - { - KMJob *j(it.current()); - JobItem *item = findItem(j->uri()); - if (item) - { - item->setDiscarded(false); - item->init(j); - } - else - m_items.append(new JobItem(m_view,j)); - } - - for (uint i=0; i<m_items.count(); i++) - if (m_items.tqat(i)->isDiscarded()) - { - delete m_items.take(i); - i--; - } - - slotSelectionChanged(); -} - -JobItem* KMJobViewer::findItem(const TQString& uri) -{ - TQPtrListIterator<JobItem> it(m_items); - for (;it.current();++it) - if (it.current()->jobUri() == uri) return it.current(); - return 0; -} - -void KMJobViewer::slotSelectionChanged() -{ - int acts = m_manager->actions(); - int state(-1); - int thread(0); - bool completed(true), remote(false); - - TQPtrListIterator<JobItem> it(m_items); - TQPtrList<KMJob> joblist; - - joblist.setAutoDelete(false); - for (;it.current();++it) - { - if (it.current()->isSelected()) - { - // check if threaded job. "thread" value will be: - // 0 -> no jobs - // 1 -> only thread jobs - // 2 -> only system jobs - // 3 -> thread and system jobs - if (it.current()->job()->type() == KMJob::Threaded) thread |= 0x1; - else thread |= 0x2; - - if (state == -1) state = it.current()->job()->state(); - else if (state != 0 && state != it.current()->job()->state()) state = 0; - - completed = (completed && it.current()->job()->isCompleted()); - joblist.append(it.current()->job()); - if (it.current()->job()->isRemote()) - remote = true; - } - } - if (thread != 2) - joblist.clear(); - - actionCollection()->action("job_remove")->setEnabled((thread == 1) || (/*!remote &&*/ !completed && (state >= 0) && (acts & KMJob::Remove))); - actionCollection()->action("job_hold")->setEnabled(/*!remote &&*/ !completed && (thread == 2) && (state > 0) && (state != KMJob::Held) && (acts & KMJob::Hold)); - actionCollection()->action("job_resume")->setEnabled(/*!remote &&*/ !completed && (thread == 2) && (state > 0) && (state == KMJob::Held) && (acts & KMJob::Resume)); - actionCollection()->action("job_move")->setEnabled(!remote && !completed && (thread == 2) && (state >= 0) && (acts & KMJob::Move)); - actionCollection()->action("job_restart")->setEnabled(!remote && (thread == 2) && (state >= 0) && (completed) && (acts & KMJob::Restart)); - - m_manager->validatePluginActions(actionCollection(), joblist); -} - -void KMJobViewer::jobSelection(TQPtrList<KMJob>& l) -{ - l.setAutoDelete(false); - TQPtrListIterator<JobItem> it(m_items); - for (;it.current();++it) - if (it.current()->isSelected()) - l.append(it.current()->job()); -} - -void KMJobViewer::send(int cmd, const TQString& name, const TQString& arg) -{ - KMTimer::self()->hold(); - - TQPtrList<KMJob> l; - jobSelection(l); - if (!m_manager->sendCommand(l,cmd,arg)) - { - KMessageBox::error(this,"<qt>"+i18n("Unable to perform action \"%1\" on selected jobs. Error received from manager:").arg(name)+"<p>"+KMManager::self()->errorMsg()+"</p></qt>"); - // error reported, clean it - KMManager::self()->setErrorMsg(TQString::null); - } - - triggerRefresh(); - - KMTimer::self()->release(); -} - -void KMJobViewer::slotHold() -{ - send(KMJob::Hold,i18n("Hold")); -} - -void KMJobViewer::slotResume() -{ - send(KMJob::Resume,i18n("Resume")); -} - -void KMJobViewer::slotRemove() -{ - send(KMJob::Remove,i18n("Remove")); -} - -void KMJobViewer::slotRestart() -{ - send(KMJob::Restart,i18n("Restart")); -} - -void KMJobViewer::slotMove(int prID) -{ - if (prID >= 0 && prID < (int)(m_printers.count())) - { - KMPrinter *p = m_printers.tqat(prID); - send(KMJob::Move,i18n("Move to %1").arg(p->printerName()),p->printerName()); - } -} - -void KMJobViewer::slotRightClicked(TQListViewItem*,const TQPoint& p,int) -{ - if (m_pop) m_pop->popup(p); -} - -void KMJobViewer::loadPrinters() -{ - m_printers.clear(); - - // retrieve printer list without reloading it (faster) - TQPtrListIterator<KMPrinter> it(*(KMFactory::self()->manager()->printerList(false))); - for (;it.current();++it) - { - // keep only real printers (no instance, no implicit) and special printers - if ((it.current()->isPrinter() || it.current()->isClass(false) || - ( it.current()->isSpecial() && it.current()->isValid() ) ) - && (it.current()->name() == it.current()->printerName())) - m_printers.append(it.current()); - } -} - -void KMJobViewer::slotPrinterSelected(int prID) -{ - if (prID >= 0 && prID < (int)(m_printers.count()+1)) - { - TQString prname = (prID == 0 ? i18n("All Printers") : m_printers.tqat(prID-1)->printerName()); - emit printerChanged(this, prname); - } -} - -void KMJobViewer::slotRefresh() -{ - triggerRefresh(); -} - -void KMJobViewer::triggerRefresh() -{ - // parent widget -> embedded in KControl and needs - // to update itself. Otherwise, it's standalone - // kjobviewer and we need to synchronize all possible - // opened windows -> do the job on higher level. - if (!m_standalone) - refresh(true); - else - emit refreshClicked(); -} - -void KMJobViewer::slotShowCompleted(bool on) -{ - removeFromManager(); - m_type = (on ? KMJobManager::CompletedJobs : KMJobManager::ActiveJobs); - addToManager(); - triggerRefresh(); -} - -void KMJobViewer::slotClose() -{ - delete this; -} - -void KMJobViewer::loadPluginActions() -{ - int mpopindex(7), toolbarindex(!m_standalone?7:8), menuindex(7); - TQMenuData *menu(0); - - if (m_standalone) - { - // standalone window, insert actions into main menubar - KAction *act = actionCollection()->action("job_restart"); - for (int i=0;i<act->containerCount();i++) - { - if (menuBar()->findItem(act->itemId(i), &menu)) - { - menuindex = mpopindex = menu->indexOf(act->itemId(i))+1; - break; - } - } - } - - TQValueList<KAction*> acts = m_manager->createPluginActions(actionCollection()); - for (TQValueListIterator<KAction*> it=acts.begin(); it!=acts.end(); ++it) - { - // connect the action to this - connect((*it), TQT_SIGNAL(activated(int)), TQT_SLOT(pluginActionActivated(int))); - - // should add it to the toolbar and menubar - (*it)->plug(toolBar(), toolbarindex++); - if (m_pop) - (*it)->plug(m_pop, mpopindex++); - if (menu) - (*it)->plug(static_cast<TQPopupMenu*>(menu), menuindex++); - } -} - -void KMJobViewer::removePluginActions() -{ - TQValueList<KAction*> acts = actionCollection()->actions("plugin"); - for (TQValueListIterator<KAction*> it=acts.begin(); it!=acts.end(); ++it) - { - (*it)->unplugAll(); - delete (*it); - } -} - -/* -void KMJobViewer::aboutToReload() -{ - if (m_view) - { - m_view->clear(); - m_items.clear(); - } - m_jobs.clear(); -} -*/ - -void KMJobViewer::reload() -{ - removePluginActions(); - loadPluginActions(); - // re-add the current printer to the job manager: the job - // manager has been destroyed, so the new one doesn't know - // which printer it has to list - addToManager(); - // no refresh needed: view has been cleared before reloading - // and the actual refresh will be triggered either by the KControl - // module, or by KJobViewerApp using timer. - - // reload the columns needed: remove the old one - for (int c=m_view->columns()-1; c>5; c--) - m_view->removeColumn(c); - KMFactory::self()->uiManager()->setupJobViewer(m_view); - - // update the "History" action state - actionCollection()->action("view_completed")->setEnabled(m_manager->actions() & KMJob::ShowCompleted); - static_cast<KToggleAction*>(actionCollection()->action("view_completed"))->setChecked(false); -} - -void KMJobViewer::closeEvent(TQCloseEvent *e) -{ - if (m_standalone && !kapp->sessionSaving()) - { - hide(); - e->ignore(); - } - else - e->accept(); -} - -void KMJobViewer::pluginActionActivated(int ID) -{ - KMTimer::self()->hold(); - - TQPtrList<KMJob> joblist; - jobSelection(joblist); - if (!m_manager->doPluginAction(ID, joblist)) - KMessageBox::error(this, "<qt>"+i18n("Operation failed.")+"<p>"+KMManager::self()->errorMsg()+"</p></qt>"); - - triggerRefresh(); - KMTimer::self()->release(); -} - -void KMJobViewer::slotUserOnly(bool on) -{ - m_username = (on ? m_userfield->text() : TQString::null); - refresh(false); -} - -void KMJobViewer::slotUserChanged() -{ - if (m_userfield->isEnabled()) - { - m_username = m_userfield->text(); - refresh(false); - } -} - -void KMJobViewer::slotConfigure() -{ - KMTimer::self()->hold(); - - KDialogBase dlg(this, 0, true, i18n("Print Job Settings"), KDialogBase::Ok|KDialogBase::Cancel); - KMConfigJobs *w = new KMConfigJobs(&dlg); - dlg.setMainWidget(w); - dlg.resize(300, 10); - KConfig *conf = KMFactory::self()->printConfig(); - w->loadConfig(conf); - if (dlg.exec()) - { - w->saveConfig(conf); - updateStatusBar(); - refresh(true); - } - - KMTimer::self()->release(); -} - -bool KMJobViewer::isSticky() const -{ - return ( m_stickybox ? m_stickybox->isChecked() : false ); -} - -void KMJobViewer::slotDropped( TQDropEvent *e, TQListViewItem* ) -{ - TQStringList files; - TQString target; - - KURL::List uris; - KURLDrag::decode( e, uris ); - for ( KURL::List::ConstIterator it = uris.begin(); - it != uris.end(); ++it) - { - if ( KIO::NetAccess::download( *it, target, 0 ) ) - files << target; - } - - if ( files.count() > 0 ) - { - KPrinter prt; - if ( prt.autoConfigure( m_prname, this ) ) - prt.printFiles( files, false, false ); - } -} - -#include "kmjobviewer.moc" diff --git a/kdeprint/management/kmjobviewer.h b/kdeprint/management/kmjobviewer.h deleted file mode 100644 index 650fe4b15..000000000 --- a/kdeprint/management/kmjobviewer.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMJOBVIEWER_H -#define KMJOBVIEWER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <kmainwindow.h> -#include "kmprinterpage.h" -#include "kpreloadobject.h" - -class KMJobManager; -class KMJob; -class KListView; -class JobItem; -class TQPopupMenu; -class TQListViewItem; -class KMPrinter; -class TQTimer; -class TQLineEdit; -class TQCheckBox; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMJobViewer : public KMainWindow, public KMPrinterPage, public KPReloadObject -{ - Q_OBJECT -public: - KMJobViewer(TQWidget *parent = 0, const char *name = 0); - ~KMJobViewer(); - - void setPrinter(const TQString& prname); - void setPrinter(KMPrinter *p); - void refresh(bool reload = false); - TQString printer() const; - bool isSticky() const; - -signals: - void jobsShown(KMJobViewer*, bool hasJobs); - void refreshClicked(); - void printerChanged(KMJobViewer*, const TQString& prname); - void viewerDestroyed(KMJobViewer*); - -public slots: - void pluginActionActivated(int); - -protected slots: - void slotSelectionChanged(); - void slotHold(); - void slotResume(); - void slotRemove(); - void slotRestart(); - void slotRightClicked(TQListViewItem*,const TQPoint&,int); - void slotMove(int prID); - void slotPrinterSelected(int); - void slotShowCompleted(bool); - void slotRefresh(); - void slotClose(); - void slotShowMoveMenu(); - void slotShowPrinterMenu(); - void slotUserOnly(bool); - void slotUserChanged(); - void slotConfigure(); - void slotDropped( TQDropEvent*, TQListViewItem* ); - -protected: - void init(); - void updateJobs(); - void initActions(); - JobItem* findItem(const TQString& uri); - void jobSelection(TQPtrList<KMJob>& l); - void send(int cmd, const TQString& name, const TQString& arg = TQString::null); - void loadPrinters(); - void loadPluginActions(); - void removePluginActions(); - void reload(); - //void aboutToReload(); - void closeEvent(TQCloseEvent*); - void triggerRefresh(); - void addToManager(); - void removeFromManager(); - void buildPrinterMenu(TQPopupMenu *menu, bool use_all = false, bool use_specials = false); - void updateCaption(); - void updateStatusBar(); - -private: - KListView *m_view; - TQPtrList<KMJob> m_jobs; - TQPtrList<JobItem> m_items; - TQPopupMenu *m_pop; - TQPtrList<KMPrinter> m_printers; - TQString m_prname; - int m_type; - TQString m_username; - TQLineEdit *m_userfield; - TQCheckBox *m_stickybox; - bool m_standalone; -}; - -inline TQString KMJobViewer::printer() const -{ return m_prname; } - -#endif diff --git a/kdeprint/management/kmlistview.cpp b/kdeprint/management/kmlistview.cpp deleted file mode 100644 index 72d6872cb..000000000 --- a/kdeprint/management/kmlistview.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmlistview.h" -#include "kmprinter.h" -#include "kmobject.h" - -#include <tqheader.h> -#include <tqpainter.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kcursor.h> - -class KMListViewItem : public TQListViewItem, public KMObject -{ -public: - KMListViewItem(TQListView *parent, const TQString& txt); - KMListViewItem(TQListViewItem *parent, const TQString& txt); - KMListViewItem(TQListViewItem *parent, KMPrinter *p); - - virtual void paintCell(TQPainter*, const TQColorGroup&, int, int, int); - void updatePrinter(KMPrinter *p); - bool isClass() const { return m_isclass; } - -protected: - void init(KMPrinter *p = 0); - -private: - int m_state; - bool m_isclass; -}; - -KMListViewItem::KMListViewItem(TQListView *parent, const TQString& txt) -: TQListViewItem(parent,txt) -{ - init(); -} - -KMListViewItem::KMListViewItem(TQListViewItem *parent, const TQString& txt) -: TQListViewItem(parent,txt) -{ - init(); -} - -KMListViewItem::KMListViewItem(TQListViewItem *parent, KMPrinter *p) -: TQListViewItem(parent) -{ - init(p); -} - -void KMListViewItem::init(KMPrinter *p) -{ - m_state = 0; - if (p) - updatePrinter(p); - setSelectable(depth() == 2); -} - -void KMListViewItem::updatePrinter(KMPrinter *p) -{ - bool update(false); - if (p) - { - int oldstate = m_state; - int st(p->isValid() ? (int)KIcon::DefaultState : (int)KIcon::LockOverlay); - m_state = ((p->isHardDefault() ? 0x1 : 0x0) | (p->ownSoftDefault() ? 0x2 : 0x0) | (p->isValid() ? 0x4 : 0x0)); - update = (oldstate != m_state); - QString name = (p->isVirtual() ? p->instanceName() : p->name()); - if (name != text(0)) - setText(0, name); - setPixmap(0, SmallIcon(p->pixmap(), 0, st)); - m_isclass = p->isClass(); - } - setDiscarded(false); - if (update) - tqrepaint(); -} - -void KMListViewItem::paintCell(TQPainter *p, const TQColorGroup& cg, int c, int w, int a) -{ - if (m_state != 0) - { - QFont f(p->font()); - if (m_state & 0x1) f.setBold(true); - if (m_state & 0x2) f.setItalic(true); - p->setFont(f); - } - TQListViewItem::paintCell(p,cg,c,w,a); -} - -//************************************************************************************************ - -KMListView::KMListView(TQWidget *parent, const char *name) -: TQListView(parent,name) -{ - m_items.setAutoDelete(false); - - addColumn(""); - header()->hide(); - setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - setLineWidth(1); - setSorting(0); - - connect(this,TQT_SIGNAL(contextMenuRequested(TQListViewItem*,const TQPoint&,int)),TQT_SLOT(slotRightButtonClicked(TQListViewItem*,const TQPoint&,int))); - connect(this,TQT_SIGNAL(selectionChanged()),TQT_SLOT(slotSelectionChanged())); - connect(this,TQT_SIGNAL(onItem(TQListViewItem*)),TQT_SLOT(slotOnItem(TQListViewItem*))); - connect(this,TQT_SIGNAL(onViewport()),TQT_SLOT(slotOnViewport())); - - m_root = new KMListViewItem(this,i18n("Print System")); - m_root->setPixmap(0,SmallIcon("tdeprint_printer")); - m_root->setOpen(true); - m_classes = new KMListViewItem(m_root,i18n("Classes")); - m_classes->setPixmap(0,SmallIcon("package")); - m_classes->setOpen(true); - m_printers = new KMListViewItem(m_root,i18n("Printers")); - m_printers->setPixmap(0,SmallIcon("package")); - m_printers->setOpen(true); - m_specials = new KMListViewItem(m_root,i18n("Specials")); - m_specials->setPixmap(0,SmallIcon("package")); - m_specials->setOpen(true); - - sort(); -} - -KMListView::~KMListView() -{ -} - -void KMListView::slotRightButtonClicked(TQListViewItem *item, const TQPoint& p, int) -{ - emit rightButtonClicked(item && item->depth() == 2 ? item->text(0) : TQString::null, p); -} - -KMListViewItem* KMListView::findItem(KMPrinter *p) -{ - if (p) - { - TQPtrListIterator<KMListViewItem> it(m_items); - bool isVirtual(p->isVirtual()), isClass(p->isClass()); - for (;it.current();++it) - if (isVirtual) - { - if (it.current()->depth() == 3 && it.current()->text(0) == p->instanceName() - && it.current()->parent()->text(0) == p->printerName()) - return it.current(); - } - else - { - if (it.current()->isClass() == isClass && it.current()->text(0) == p->name()) - return it.current(); - } - } - return 0; -} - -KMListViewItem* KMListView::findItem(const TQString& prname) -{ - TQPtrListIterator<KMListViewItem> it(m_items); - for (; it.current(); ++it) - if (it.current()->depth() == 2 && it.current()->text(0) == prname) - return it.current(); - return 0; -} - -void KMListView::setPrinterList(TQPtrList<KMPrinter> *list) -{ - bool changed(false); - - TQPtrListIterator<KMListViewItem> it(m_items); - for (;it.current();++it) - it.current()->setDiscarded(true); - - if (list) - { - TQPtrListIterator<KMPrinter> it(*list); - KMListViewItem *item (0); - for (;it.current();++it) - { - item = findItem(it.current()); - if (!item) - { - if (it.current()->isVirtual()) - { - KMListViewItem *pItem = findItem(it.current()->printerName()); - if (!pItem) - continue; - item = new KMListViewItem(pItem, it.current()); - pItem->setOpen(true); - } - else - item = new KMListViewItem((it.current()->isSpecial() ? m_specials : (it.current()->isClass(false) ? m_classes : m_printers)),it.current()); - m_items.append(item); - changed = true; - } - else - item->updatePrinter(it.current()); - } - } - - TQPtrList<KMListViewItem> deleteList; - deleteList.setAutoDelete(true); - for (uint i=0; i<m_items.count(); i++) - if (m_items.tqat(i)->isDiscarded()) - { - // instance items are put in front of the list - // so that they are destroyed first - KMListViewItem *item = m_items.take(i); - if (item->depth() == 2) - deleteList.append(item); - else - deleteList.prepend(item); - i--; - changed = true; - } - deleteList.clear(); - - if (changed) sort(); - emit selectionChanged(); -} - -void KMListView::slotSelectionChanged() -{ - KMListViewItem *item = static_cast<KMListViewItem*>(currentItem()); - emit printerSelected((item && !item->isDiscarded() && item->depth() == 2 ? item->text(0) : TQString::null)); -} - -void KMListView::setPrinter(const TQString& prname) -{ - TQPtrListIterator<KMListViewItem> it(m_items); - for (;it.current();++it) - if (it.current()->text(0) == prname) - { - setSelected(it.current(),true); - break; - } -} - -void KMListView::setPrinter(KMPrinter *p) -{ - setPrinter(p ? p->name() : TQString::null); -} - -void KMListView::slotOnItem(TQListViewItem *) -{ - setCursor(KCursor::handCursor()); -} - -void KMListView::slotOnViewport() -{ - setCursor(KCursor::arrowCursor()); -} -#include "kmlistview.moc" diff --git a/kdeprint/management/kmlistview.h b/kdeprint/management/kmlistview.h deleted file mode 100644 index 20ddc5731..000000000 --- a/kdeprint/management/kmlistview.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMLISTVIEW_H -#define KMLISTVIEW_H - -#include <tqlistview.h> -#include <tqptrlist.h> - -class KMListViewItem; -class KMPrinter; - -class KMListView : public TQListView -{ - Q_OBJECT -public: - KMListView(TQWidget *parent = 0, const char *name = 0); - ~KMListView(); - - void setPrinterList(TQPtrList<KMPrinter> *list); - void setPrinter(const TQString&); - void setPrinter(KMPrinter*); - -signals: - void rightButtonClicked(const TQString&, const TQPoint&); - void printerSelected(const TQString&); - -protected slots: - void slotRightButtonClicked(TQListViewItem*, const TQPoint&, int); - void slotSelectionChanged(); - void slotOnItem(TQListViewItem*); - void slotOnViewport(); - -protected: - KMListViewItem* findItem(KMPrinter*); - KMListViewItem* findItem(const TQString&); - -private: - TQPtrList<KMListViewItem> m_items; - KMListViewItem *m_root, *m_classes, *m_printers, *m_specials; -}; - -#endif diff --git a/kdeprint/management/kmmainview.cpp b/kdeprint/management/kmmainview.cpp deleted file mode 100644 index f5f905af3..000000000 --- a/kdeprint/management/kmmainview.cpp +++ /dev/null @@ -1,920 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmmainview.h" -#include "kmtimer.h" -#include "kmprinterview.h" -#include "kmpages.h" -#include "kmmanager.h" -#include "kmuimanager.h" -#include "kmfactory.h" -#include "kmvirtualmanager.h" -#include "kmprinter.h" -#include "driver.h" -#include "kmdriverdialog.h" -#include "kmwizard.h" -#include "kmconfigdialog.h" -#include "kmspecialprinterdlg.h" -#include "plugincombobox.h" -#include "kiconselectaction.h" -#include "messagewindow.h" - -#include <tqdockarea.h> -#include <kmenubar.h> -#include <tqtimer.h> -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqpopupmenu.h> -#include <kmessagebox.h> -#include <kaction.h> -#include <klocale.h> -#include <kconfig.h> -#include <ktoolbar.h> -#include <ktoolbarbutton.h> -#include <kdebug.h> -#include <kpopupmenu.h> -#include <klibloader.h> -#include <kdialogbase.h> -#include <ksimpleconfig.h> -#include <kstandarddirs.h> -#include <kapplication.h> -#include <kprocess.h> - -#undef m_manager -#define m_manager KMFactory::self()->manager() - -int tdeprint_management_add_printer_wizard( TQWidget* parent ) -{ - KMWizard dlg(parent); - int flag(0); - if (dlg.exec()) - { - flag = 1; - // check if the printer already exists, and ask confirmation if needed. - if (KMFactory::self()->manager()->findPrinter(dlg.printer()->name()) != 0) - if (KMessageBox::warningContinueCancel(parent,i18n("The printer %1 already exists. Continuing will overwrite existing printer. Do you want to continue?").arg(dlg.printer()->name())) == KMessageBox::Cancel) - flag = 0; - // try to add printer only if flag is true. - if (flag && !KMFactory::self()->manager()->createPrinter(dlg.printer())) - flag = -1; - } - return flag; -} - -KMMainView::KMMainView(TQWidget *parent, const char *name, KActionCollection *coll) -: TQWidget(parent, name) -{ - m_current = 0; - m_first = true; - - // create widgets - m_printerview = new KMPrinterView(this, "PrinterView"); - m_printerpages = new KMPages(this, "PrinterPages"); - m_pop = new TQPopupMenu(this); - m_toolbar = new KToolBar(this, "ToolBar"); - m_toolbar->setMovingEnabled(false); - m_plugin = new PluginComboBox(this, "Plugin"); - /* - m_menubar = new KMenuBar( this ); - static_cast<KMenuBar*>( m_menubar )->setTopLevelMenu( false ); - */ - m_menubar = new KToolBar( this, "MenuBar", false, false ); - m_menubar->setIconText( KToolBar::IconTextRight ); - m_menubar->setMovingEnabled( false ); - - // layout - TQVBoxLayout *m_layout = new TQVBoxLayout(this, 0, 0); - m_layout->addWidget(m_toolbar); - m_layout->addWidget( m_menubar ); - m_boxlayout = new TQBoxLayout(TQBoxLayout::TopToBottom, 0, 0); - m_layout->addLayout(m_boxlayout); - m_boxlayout->addWidget(m_printerview); - m_boxlayout->addWidget(m_printerpages); - m_layout->addSpacing(5); - m_layout->addWidget(m_plugin, 0); - - // connections - connect(KMTimer::self(),TQT_SIGNAL(timeout()),TQT_SLOT(slotTimer())); - connect(m_printerview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SLOT(slotPrinterSelected(const TQString&))); - connect(m_printerview,TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)),TQT_SLOT(slotRightButtonClicked(const TQString&,const TQPoint&))); - connect(m_pop,TQT_SIGNAL(aboutToShow()),KMTimer::self(),TQT_SLOT(hold())); - connect(m_pop,TQT_SIGNAL(aboutToHide()),KMTimer::self(),TQT_SLOT(release())); - connect( m_manager, TQT_SIGNAL( updatePossible( bool ) ), TQT_SLOT( slotUpdatePossible( bool ) ) ); - - // actions - if (coll) - m_actions = coll; - else - m_actions = new KActionCollection(this); - initActions(); - - // first update - restoreSettings(); - loadParameters(); - - // delay first update until KMManager is ready - reset( i18n( "Initializing manager..." ), true, true ); -} - -KMMainView::~KMMainView() -{ - saveSettings(); - //KMFactory::release(); -} - -void KMMainView::loadParameters() -{ -} - -void KMMainView::restoreSettings() -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("General"); - setViewType((KMPrinterView::ViewType)conf->readNumEntry("ViewType",KMPrinterView::Icons)); - setOrientation(conf->readNumEntry("Orientation", Qt::Vertical)); - bool view = conf->readBoolEntry("ViewToolBar",false); - slotToggleToolBar(view); - ((KToggleAction*)m_actions->action("view_toolbar"))->setChecked(view); - view = conf->readBoolEntry( "ViewMenuBar", true ); - slotToggleMenuBar( view ); - static_cast<KToggleAction*>( m_actions->action( "view_menubar" ) )->setChecked( view ); - view = conf->readBoolEntry("ViewPrinterInfos",true); - slotShowPrinterInfos(view); - ((KToggleAction*)m_actions->action("view_printerinfos"))->setChecked(view); -} - -void KMMainView::saveSettings() -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("General"); - conf->writeEntry("ViewType",(int)m_printerview->viewType()); - conf->writeEntry("Orientation",(int)orientation()); - conf->writeEntry("ViewToolBar",((KToggleAction*)m_actions->action("view_toolbar"))->isChecked()); - conf->writeEntry("ViewMenuBar",static_cast<KToggleAction*>( m_actions->action("view_menubar") )->isChecked()); - conf->writeEntry("ViewPrinterInfos",((KToggleAction*)m_actions->action("view_printerinfos"))->isChecked()); - conf->sync(); -} - -void KMMainView::initActions() -{ - KIconSelectAction *vact = new KIconSelectAction(i18n("&View"),0,m_actions,"view_change"); - TQStringList iconlst; - iconlst << "view_icon" << "view_detailed" << "view_tree"; - vact->setItems(TQStringList::split(',',i18n("&Icons,&List,&Tree"),false), iconlst); - vact->setCurrentItem(0); - connect(vact,TQT_SIGNAL(activated(int)),TQT_SLOT(slotChangeView(int))); - - KActionMenu *stateAct = new KActionMenu(i18n("Start/Stop Printer"), "tdeprint_printstate", m_actions, "printer_state_change"); - stateAct->setDelayed(false); - stateAct->insert(new KAction(i18n("&Start Printer"),"tdeprint_enableprinter",0,TQT_TQOBJECT(this),TQT_SLOT(slotChangePrinterState()),m_actions,"printer_start")); - stateAct->insert(new KAction(i18n("Sto&p Printer"),"tdeprint_stopprinter",0,TQT_TQOBJECT(this),TQT_SLOT(slotChangePrinterState()),m_actions,"printer_stop")); - - stateAct = new KActionMenu(i18n("Enable/Disable Job Spooling"), "tdeprint_queuestate", m_actions, "printer_spool_change"); - stateAct->setDelayed(false); - stateAct->insert(new KAction(i18n("&Enable Job Spooling"),"tdeprint_enableprinter",0,TQT_TQOBJECT(this),TQT_SLOT(slotChangePrinterState()),m_actions,"printer_enable")); - stateAct->insert(new KAction(i18n("&Disable Job Spooling"),"tdeprint_stopprinter",0,TQT_TQOBJECT(this),TQT_SLOT(slotChangePrinterState()),m_actions,"printer_disable")); - - new KAction(i18n("&Remove"),"edittrash",0,TQT_TQOBJECT(this),TQT_SLOT(slotRemove()),m_actions,"printer_remove"); - new KAction(i18n("&Configure..."),"configure",0,TQT_TQOBJECT(this),TQT_SLOT(slotConfigure()),m_actions,"printer_configure"); - new KAction(i18n("Add &Printer/Class..."),"tdeprint_addprinter",0,TQT_TQOBJECT(this),TQT_SLOT(slotAdd()),m_actions,"printer_add"); - new KAction(i18n("Add &Special (pseudo) Printer..."),"tdeprint_addpseudo",0,TQT_TQOBJECT(this),TQT_SLOT(slotAddSpecial()),m_actions,"printer_add_special"); - new KAction(i18n("Set as &Local Default"),"tdeprint_defaulthard",0,TQT_TQOBJECT(this),TQT_SLOT(slotHardDefault()),m_actions,"printer_hard_default"); - new KAction(i18n("Set as &User Default"),"tdeprint_defaultsoft",0,TQT_TQOBJECT(this),TQT_SLOT(slotSoftDefault()),m_actions,"printer_soft_default"); - new KAction(i18n("&Test Printer..."),"tdeprint_testprinter",0,TQT_TQOBJECT(this),TQT_SLOT(slotTest()),m_actions,"printer_test"); - new KAction(i18n("Configure &Manager..."),"tdeprint_configmgr",0,TQT_TQOBJECT(this),TQT_SLOT(slotManagerConfigure()),m_actions,"manager_configure"); - new KAction(i18n("Initialize Manager/&View"),"reload",0,TQT_TQOBJECT(this),TQT_SLOT(slotInit()),m_actions,"view_refresh"); - - KIconSelectAction *dact = new KIconSelectAction(i18n("&Orientation"),0,m_actions,"orientation_change"); - iconlst.clear(); - iconlst << "view_top_bottom" << "view_left_right"; - dact->setItems(TQStringList::split(',',i18n("&Vertical,&Horizontal"),false), iconlst); - dact->setCurrentItem(0); - connect(dact,TQT_SIGNAL(activated(int)),TQT_SLOT(slotChangeDirection(int))); - - new KAction(i18n("R&estart Server"),"tdeprint_restartsrv",0,TQT_TQOBJECT(this),TQT_SLOT(slotServerRestart()),m_actions,"server_restart"); - new KAction(i18n("Configure &Server..."),"tdeprint_configsrv",0,TQT_TQOBJECT(this),TQT_SLOT(slotServerConfigure()),m_actions,"server_configure"); - new KAction(i18n("Configure Server Access..."),"tdeprint_configsrv",0,TQT_TQOBJECT(this),TQT_SLOT(slotServerAccessConfigure()),m_actions,"server_access_configure"); - - KToggleAction *tact = new KToggleAction(i18n("Show &Toolbar"),0,m_actions,"view_toolbar"); - tact->setCheckedState(i18n("Hide &Toolbar")); - connect(tact,TQT_SIGNAL(toggled(bool)),TQT_SLOT(slotToggleToolBar(bool))); - tact = new KToggleAction( i18n( "Show Me&nu Toolbar" ), 0, m_actions, "view_menubar" ); - tact->setCheckedState(i18n("Hide Me&nu Toolbar")); - connect( tact, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( slotToggleMenuBar( bool ) ) ); - tact = new KToggleAction(i18n("Show Pr&inter Details"),"tdeprint_printer_infos", 0,m_actions,"view_printerinfos"); - tact->setCheckedState(KGuiItem(i18n("Hide Pr&inter Details"),"tdeprint_printer_infos")); - tact->setChecked(true); - connect(tact,TQT_SIGNAL(toggled(bool)),TQT_SLOT(slotShowPrinterInfos(bool))); - - tact = new KToggleAction(i18n("Toggle Printer &Filtering"), "filter", 0, m_actions, "view_pfilter"); - tact->setChecked(KMManager::self()->isFilterEnabled()); - connect(tact, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotToggleFilter(bool))); - - new KAction( i18n( "%1 &Handbook" ).arg( "KDEPrint" ), "contents", 0, TQT_TQOBJECT(this), TQT_SLOT( slotHelp() ), m_actions, "invoke_help" ); - new KAction( i18n( "%1 &Web Site" ).arg( "KDEPrint" ), "network", 0, TQT_TQOBJECT(this), TQT_SLOT( slotHelp() ), m_actions, "invoke_web" ); - - KActionMenu *mact = new KActionMenu(i18n("Pri&nter Tools"), "package_utilities", m_actions, "printer_tool"); - mact->setDelayed(false); - connect(mact->popupMenu(), TQT_SIGNAL(activated(int)), TQT_SLOT(slotToolSelected(int))); - TQStringList files = KGlobal::dirs()->findAllResources("data", "tdeprint/tools/*.desktop"); - for (TQStringList::ConstIterator it=files.begin(); it!=files.end(); ++it) - { - KSimpleConfig conf(*it); - conf.setGroup("Desktop Entry"); - mact->popupMenu()->insertItem(conf.readEntry("Name", "Unnamed"), mact->popupMenu()->count()); - m_toollist << conf.readEntry("X-KDE-Library"); - } - - // add actions to the toolbar - m_actions->action("printer_add")->plug(m_toolbar); - m_actions->action("printer_add_special")->plug(m_toolbar); - m_toolbar->insertLineSeparator(); - m_actions->action("printer_state_change")->plug(m_toolbar); - m_actions->action("printer_spool_change")->plug(m_toolbar); - m_toolbar->insertSeparator(); - m_actions->action("printer_hard_default")->plug(m_toolbar); - m_actions->action("printer_soft_default")->plug(m_toolbar); - m_actions->action("printer_remove")->plug(m_toolbar); - m_toolbar->insertSeparator(); - m_actions->action("printer_configure")->plug(m_toolbar); - m_actions->action("printer_test")->plug(m_toolbar); - m_actions->action("printer_tool")->plug(m_toolbar); - m_pactionsindex = m_toolbar->insertSeparator(); - m_toolbar->insertLineSeparator(); - m_actions->action("server_restart")->plug(m_toolbar); - m_actions->action("server_configure")->plug(m_toolbar); - m_toolbar->insertLineSeparator(); - m_actions->action("manager_configure")->plug(m_toolbar); - m_actions->action("view_refresh")->plug(m_toolbar); - m_toolbar->insertLineSeparator(); - m_actions->action("view_printerinfos")->plug(m_toolbar); - m_actions->action("view_change")->plug(m_toolbar); - m_actions->action("orientation_change")->plug(m_toolbar); - m_actions->action("view_pfilter")->plug(m_toolbar); - - // add actions to the menu bar - TQPopupMenu *menu = new TQPopupMenu( this ); - m_actions->action( "printer_add" )->plug( menu ); - m_actions->action( "printer_add_special" )->plug( menu ); - //m_menubar->insertItem( i18n( "Add" ), menu ); - m_menubar->insertButton( "wizard", 0, true, i18n( "Add" ) ); - m_menubar->getButton( 0 )->setPopup( menu, true ); - menu = new TQPopupMenu( this ); - m_actions->action("printer_state_change")->plug( menu ); - m_actions->action("printer_spool_change")->plug( menu ); - menu->insertSeparator(); - m_actions->action("printer_hard_default")->plug( menu ); - m_actions->action("printer_soft_default")->plug( menu ); - m_actions->action("printer_remove")->plug( menu ); - menu->insertSeparator(); - m_actions->action("printer_configure")->plug( menu ); - m_actions->action("printer_test")->plug( menu ); - m_actions->action("printer_tool")->plug( menu ); - menu->insertSeparator(); - //m_menubar->insertItem( i18n( "Printer" ), menu ); - m_menubar->insertButton( "printer1", 1, true, i18n( "Printer" ) ); - m_menubar->getButton( 1 )->setPopup( menu, true ); - menu = new TQPopupMenu( this ); - m_actions->action("server_restart")->plug( menu ); - m_actions->action("server_configure")->plug( menu ); - //m_menubar->insertItem( i18n( "Server" ), menu ); - m_menubar->insertButton( "misc", 2, true, i18n( "Print Server" ) ); - m_menubar->getButton( 2 )->setPopup( menu, true ); - menu = new TQPopupMenu( this ); - m_actions->action("manager_configure")->plug( menu ); - m_actions->action("view_refresh")->plug( menu ); - //m_menubar->insertItem( i18n( "Manager" ), menu ); - m_menubar->insertButton( "tdeprint_configmgr", 3, true, i18n( "Print Manager" ) ); - m_menubar->getButton( 3 )->setPopup( menu, true ); - menu = new TQPopupMenu( this ); - m_actions->action("view_printerinfos")->plug( menu ); - m_actions->action("view_change")->plug( menu ); - m_actions->action("orientation_change")->plug( menu ); - m_actions->action( "view_toolbar" )->plug ( menu ); - m_actions->action( "view_menubar" )->plug ( menu ); - menu->insertSeparator(); - m_actions->action("view_pfilter")->plug( menu ); - //m_menubar->insertItem( i18n( "View" ), menu ); - m_menubar->insertButton( "view_remove", 4, true, i18n( "View" ) ); - m_menubar->getButton( 4 )->setPopup( menu, true ); - //m_menubar->setMinimumHeight( m_menubar->heightForWidth( 1000 ) ); - menu = new TQPopupMenu( this ); - m_actions->action( "invoke_help" )->plug( menu ); - m_actions->action( "invoke_web" )->plug( menu ); - m_menubar->insertButton( "help", 5, true, i18n( "Documentation" ) ); - m_menubar->getButton( 5 )->setPopup( menu, true ); - - loadPluginActions(); - slotPrinterSelected(TQString::null); -} - -void KMMainView::slotRefresh() -{ - // TODO: remove me -} - -void KMMainView::slotTimer() -{ - kdDebug() << "KMMainView::slotTimer" << endl; - TQPtrList<KMPrinter> *printerlist = m_manager->printerList(); - bool ok = m_manager->errorMsg().isEmpty(); - m_printerview->setPrinterList(printerlist); - if ( m_first ) - { - if ( !ok ) - showErrorMsg(i18n("An error occurred while retrieving the printer list.")); - else - { - /* try to select the most appropriate printer: - * - soft default owner printer - * - hard default printer - * - first printer - */ - TQPtrListIterator<KMPrinter> it( *printerlist ); - KMPrinter *p1 = 0, *p2 = 0, *p3 = 0; - while ( it.current() ) - { - if ( !it.current()->isVirtual() ) - { - if ( it.current()->ownSoftDefault() ) - { - p1 = it.current(); - break; - } - else if ( it.current()->isHardDefault() ) - p2 = it.current(); - else if ( !p3 ) - p3 = it.current(); - } - ++it; - } - if ( p1 || p2 || p3 ) - m_printerview->setPrinter( p1 ? p1 : ( p2 ? p2 : p3 ) ); - } - m_first = false; - } -} - -void KMMainView::slotPrinterSelected(const TQString& prname) -{ - KMPrinter *p = KMManager::self()->findPrinter(prname); - m_current = p; - if (p && !p->isSpecial()) - KMFactory::self()->manager()->completePrinter(p); - m_printerpages->setPrinter(p); - - // update actions state (only if toolbar enabled, workaround for toolbar - // problem). - //if (m_toolbar->isEnabled()) - //{ - int mask = (m_manager->hasManagement() ? m_manager->printerOperationMask() : 0); - bool sp = !(p && p->isSpecial()); -// m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && p->isLocal() && !p->isImplicit())); - m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && !p->isImplicit())); - m_actions->action("printer_configure")->setEnabled(!sp || ((mask & KMManager::PrinterConfigure) && p && !p->isClass(true) /*&& p->isLocal()*/)); - m_actions->action("printer_hard_default")->setEnabled((sp && (mask & KMManager::PrinterDefault) && p && !p->isClass(true) && !p->isHardDefault() && p->isLocal())); - m_actions->action("printer_soft_default")->setEnabled((p && !p->isSoftDefault())); - m_actions->action("printer_test")->setEnabled((sp && (mask & KMManager::PrinterTesting) && p && !p->isClass(true))); - bool stmask = (sp && (mask & KMManager::PrinterEnabling) && p); - m_actions->action("printer_state_change")->setEnabled(stmask && p->isLocal()); - m_actions->action("printer_spool_change")->setEnabled(stmask); - m_actions->action("printer_start")->setEnabled((stmask && p->state() == KMPrinter::Stopped)); - m_actions->action("printer_stop")->setEnabled((stmask && p->state() != KMPrinter::Stopped)); - m_actions->action("printer_enable")->setEnabled((stmask && !p->acceptJobs())); - m_actions->action("printer_disable")->setEnabled((stmask && p->acceptJobs())); - - m_actions->action("printer_add")->setEnabled((mask & KMManager::PrinterCreation)); - mask = m_manager->serverOperationMask(); - m_actions->action("server_restart")->setEnabled((mask & KMManager::ServerRestarting)); - m_actions->action("server_configure")->setEnabled((mask & KMManager::ServerConfigure)); - - KMFactory::self()->manager()->validatePluginActions(m_actions, p); - //} - m_actions->action("printer_tool")->setEnabled(p && !p->isClass(true) && !p->isRemote() && !p->isSpecial()); -} - -void KMMainView::setViewType(int ID) -{ - ((KSelectAction*)m_actions->action("view_change"))->setCurrentItem(ID); - slotChangeView(ID); -} - -int KMMainView::viewType() const -{ return m_printerview->viewType(); } - -void KMMainView::slotChangeView(int ID) -{ - kdDebug() << "KMMainView::slotChangeView" << endl; - if (ID >= KMPrinterView::Icons && ID <= KMPrinterView::Tree) - m_printerview->setViewType((KMPrinterView::ViewType)ID); -} - -void KMMainView::slotRightButtonClicked(const TQString& prname, const TQPoint& p) -{ - KMPrinter *printer = KMManager::self()->findPrinter(prname); - // construct popup menu - m_pop->clear(); - if (printer) - { - m_current = printer; - if (!printer->isSpecial()) - { - if (printer->isLocal()) - m_actions->action((printer->state() == KMPrinter::Stopped ? "printer_start" : "printer_stop"))->plug(m_pop); - m_actions->action((printer->acceptJobs() ? "printer_disable" : "printer_enable"))->plug(m_pop); - m_pop->insertSeparator(); - } - if (!printer->isSoftDefault()) m_actions->action("printer_soft_default")->plug(m_pop); - if (printer->isLocal() && !printer->isImplicit()) - { - if (!printer->isHardDefault()) m_actions->action("printer_hard_default")->plug(m_pop); - m_actions->action("printer_remove")->plug(m_pop); - m_pop->insertSeparator(); - if (!printer->isClass(true)) - { - m_actions->action("printer_configure")->plug(m_pop); - m_actions->action("printer_test")->plug(m_pop); - m_actions->action("printer_tool")->plug(m_pop); - m_pop->insertSeparator(); - } - } - else - { - m_actions->action("printer_remove")->plug(m_pop); - m_pop->insertSeparator(); - if (!printer->isClass(true)) - { - m_actions->action("printer_configure")->plug(m_pop); - m_actions->action("printer_test")->plug(m_pop); - } - m_pop->insertSeparator(); - } - if (!printer->isSpecial()) - { - TQValueList<KAction*> pactions = m_actions->actions("plugin"); - for (TQValueList<KAction*>::Iterator it=pactions.begin(); it!=pactions.end(); ++it) - (*it)->plug(m_pop); - if (pactions.count() > 0) - m_pop->insertSeparator(); - } - } - else - { - m_actions->action("printer_add")->plug(m_pop); - m_actions->action("printer_add_special")->plug(m_pop); - m_pop->insertSeparator(); - m_actions->action("server_restart")->plug(m_pop); - m_actions->action("server_configure")->plug(m_pop); - m_pop->insertSeparator(); - m_actions->action("manager_configure")->plug(m_pop); - m_actions->action("view_refresh")->plug(m_pop); - m_pop->insertSeparator(); - } - m_actions->action("view_printerinfos")->plug(m_pop); - m_actions->action("view_change")->plug(m_pop); - m_actions->action("orientation_change")->plug(m_pop); - m_actions->action("view_toolbar")->plug(m_pop); - m_actions->action("view_menubar")->plug(m_pop); - m_pop->insertSeparator(); - m_actions->action("view_pfilter")->plug(m_pop); - - // pop the menu - m_pop->popup(p); -} - -void KMMainView::slotChangePrinterState() -{ - TQString opname = TQT_TQOBJECT_CONST(sender())->name(); - if (m_current && opname.startsWith("printer_")) - { - opname = opname.mid(8); - KMTimer::self()->hold(); - bool result(false); - if (opname == "enable") - result = m_manager->enablePrinter(m_current, true); - else if (opname == "disable") - result = m_manager->enablePrinter(m_current, false); - else if (opname == "start") - result = m_manager->startPrinter(m_current, true); - else if (opname == "stop") - result = m_manager->startPrinter(m_current, false); - if (!result) - showErrorMsg(i18n("Unable to modify the state of printer %1.").arg(m_current->printerName())); - KMTimer::self()->release(result); - } -} - -void KMMainView::slotRemove() -{ - if (m_current) - { - KMTimer::self()->hold(); - bool result(false); - if (KMessageBox::warningYesNo(this,i18n("Do you really want to remove %1?").arg(m_current->printerName())) == KMessageBox::Yes) - if (m_current->isSpecial()) - { - if (!(result=m_manager->removeSpecialPrinter(m_current))) - showErrorMsg(i18n("Unable to remove special printer %1.").arg(m_current->printerName())); - } - else if (!(result=m_manager->removePrinter(m_current))) - showErrorMsg(i18n("Unable to remove printer %1.").arg(m_current->printerName())); - KMTimer::self()->release(result); - } -} - -void KMMainView::slotConfigure() -{ - if (m_current) - { - KMTimer::self()->hold(); - bool needRefresh(false); - if (m_current->isSpecial()) - { - KMSpecialPrinterDlg dlg(this); - dlg.setPrinter(m_current); - if (dlg.exec()) - { - KMPrinter *prt = dlg.printer(); - if (prt->name() != m_current->name()) - m_manager->removeSpecialPrinter(m_current); - m_manager->createSpecialPrinter(prt); - needRefresh = true; - } - } - else - { - DrMain *driver = m_manager->loadPrinterDriver(m_current, true); - if (driver) - { - KMDriverDialog dlg(this); - dlg.setCaption(i18n("Configure %1").arg(m_current->printerName())); - dlg.setDriver(driver); - // disable OK button for remote printer (read-only dialog) - if (m_current->isRemote()) - dlg.enableButtonOK(false); - if (dlg.exec()) - if (!m_manager->savePrinterDriver(m_current,driver)) - showErrorMsg(i18n("Unable to modify settings of printer %1.").arg(m_current->printerName())); - delete driver; - } - else - showErrorMsg(i18n("Unable to load a valid driver for printer %1.").arg(m_current->printerName())); - } - KMTimer::self()->release(needRefresh); - } -} - -void KMMainView::slotAdd() -{ - KMTimer::self()->hold(); - - int result(0); - if ((result=tdeprint_management_add_printer_wizard(this)) == -1) - showErrorMsg(i18n("Unable to create printer.")); - - KMTimer::self()->release((result == 1)); -} - -void KMMainView::slotHardDefault() -{ - if (m_current) - { - KMTimer::self()->hold(); - bool result = m_manager->setDefaultPrinter(m_current); - if (!result) - showErrorMsg(i18n("Unable to define printer %1 as default.").arg(m_current->printerName())); - KMTimer::self()->release(result); - } -} - -void KMMainView::slotSoftDefault() -{ - if (m_current) - { - KMTimer::self()->hold(); - KMFactory::self()->virtualManager()->setAsDefault(m_current,TQString::null); - KMTimer::self()->release(true); - } -} - -void KMMainView::setOrientation(int o) -{ - int ID = (o == Qt::Horizontal ? 1 : 0); - ((KSelectAction*)m_actions->action("orientation_change"))->setCurrentItem(ID); - slotChangeDirection(ID); -} - -int KMMainView::orientation() const -{ return (m_boxlayout->direction() == TQBoxLayout::LeftToRight ? Qt::Horizontal : Qt::Vertical); } - -void KMMainView::slotChangeDirection(int d) -{ - m_boxlayout->setDirection(d == 1 ? TQBoxLayout::LeftToRight : TQBoxLayout::TopToBottom); -} - -void KMMainView::slotTest() -{ - if (m_current) - { - KMTimer::self()->hold(); - if (KMessageBox::warningContinueCancel(this, i18n("You are about to print a test page on %1. Do you want to continue?").arg(m_current->printerName()), TQString::null, i18n("Print Test Page"), "printTestPage") == KMessageBox::Continue) - { - if (KMFactory::self()->manager()->testPrinter(m_current)) - KMessageBox::information(this,i18n("Test page successfully sent to printer %1.").arg(m_current->printerName())); - else - showErrorMsg(i18n("Unable to test printer %1.").arg(m_current->printerName())); - } - KMTimer::self()->release(true); - } -} - -void KMMainView::showErrorMsg(const TQString& msg, bool usemgr) -{ - TQString s(msg); - if (usemgr) - { - s.prepend("<p>"); - s.append(" "); - s += i18n("Error message received from manager:</p><p>%1</p>"); - if (m_manager->errorMsg().isEmpty()) - s = s.arg(i18n("Internal error (no error message).")); - else - s = s.arg(m_manager->errorMsg()); - // clean up error message - m_manager->setErrorMsg(TQString::null); - } - s.prepend("<qt>").append("</qt>"); - KMTimer::self()->hold(); - KMessageBox::error(this,s); - KMTimer::self()->release(); -} - -void KMMainView::slotServerRestart() -{ - KMTimer::self()->hold(); - bool result = m_manager->restartServer(); - if (!result) - { - showErrorMsg(i18n("Unable to restart print server.")); - KMTimer::self()->release( false ); - } - else - { - reset( i18n( "Restarting server..." ), false, false ); - } -} - -void KMMainView::slotServerConfigure() -{ - KMTimer::self()->hold(); - bool result = m_manager->configureServer(this); - if (!result) - { - showErrorMsg(i18n("Unable to configure print server.")); - KMTimer::self()->release( false ); - } - else - { - reset( i18n( "Configuring server..." ), false, false ); - } -} - -void KMMainView::slotServerConfigureAccess() -{ - KProcess *proc = new KProcess; - *proc << "/usr/bin/system-config-printer-kde"; - proc->start(KProcess::DontCare); -} - -void KMMainView::slotToggleToolBar(bool on) -{ - if (on) m_toolbar->show(); - else m_toolbar->hide(); -} - -void KMMainView::slotToggleMenuBar( bool on ) -{ - if ( on ) - m_menubar->show(); - else - m_menubar->hide(); -} - -void KMMainView::slotManagerConfigure() -{ - KMTimer::self()->hold(); - KMConfigDialog dlg(this,"ConfigDialog"); - if ( dlg.exec() ) - { - loadParameters(); - } - /* when "OK": - * => the config file is saved - * => triggering a DCOP signal - * => configChanged() called - * hence no need to refresh, just release the timer - */ - KMTimer::self()->release( false ); -} - -void KMMainView::slotAddSpecial() -{ - KMTimer::self()->hold(); - KMSpecialPrinterDlg dlg(this); - if (dlg.exec()) - { - KMPrinter *prt = dlg.printer(); - m_manager->createSpecialPrinter(prt); - } - KMTimer::self()->release(true); -} - -void KMMainView::slotShowPrinterInfos(bool on) -{ - if (on) - m_printerpages->show(); - else - m_printerpages->hide(); - m_actions->action("orientation_change")->setEnabled(on); -} - -void KMMainView::enableToolbar(bool on) -{ - KToggleAction *act = (KToggleAction*)m_actions->action("view_toolbar"); - m_toolbar->setEnabled(on); - act->setEnabled(on); - if (on && act->isChecked()) - m_toolbar->show(); - else - m_toolbar->hide(); -} - -KAction* KMMainView::action(const char *name) -{ - return m_actions->action(name); -} - -/* -void KMMainView::aboutToReload() -{ - m_printerview->setPrinterList(0); -} -*/ - -void KMMainView::reload() -{ - removePluginActions(); - loadPluginActions(); - - // redo the connection as the old manager object has been removed - connect( m_manager, TQT_SIGNAL( updatePossible( bool ) ), TQT_SLOT( slotUpdatePossible( bool ) ) ); - - // We must delay the refresh such that all objects has been - // correctly reloaded (otherwise, crash in KMJobViewer). - reset( i18n( "Initializing manager..." ), true, true ); -} - -void KMMainView::showPrinterInfos(bool on) -{ - static_cast<KToggleAction*>(m_actions->action("view_printerinfos"))->setChecked(on); - slotShowPrinterInfos(on); -} - -bool KMMainView::printerInfosShown() const -{ - return (static_cast<KToggleAction*>(m_actions->action("view_printerinfos"))->isChecked()); -} - -void KMMainView::loadPluginActions() -{ - KMFactory::self()->manager()->createPluginActions(m_actions); - TQValueList<KAction*> pactions = m_actions->actions("plugin"); - int index = m_pactionsindex; - //TQPopupMenu *menu = m_menubar->findItem( m_menubar->idAt( 1 ) )->popup(); - TQPopupMenu *menu = m_menubar->getButton( 1 )->popup(); - for (TQValueList<KAction*>::Iterator it=pactions.begin(); it!=pactions.end(); ++it) - { - (*it)->plug(m_toolbar, index++); - ( *it )->plug( menu ); - } -} - -void KMMainView::removePluginActions() -{ - TQValueList<KAction*> pactions = m_actions->actions("plugin"); - for (TQValueList<KAction*>::Iterator it=pactions.begin(); it!=pactions.end(); ++it) - { - (*it)->unplugAll(); - delete (*it); - } -} - -void KMMainView::slotToolSelected(int ID) -{ - KMTimer::self()->hold(); - - TQString libname = m_toollist[ID]; - libname.prepend("tdeprint_tool_"); - if (m_current && !m_current->device().isEmpty() && !libname.isEmpty()) - { - KLibFactory *factory = KLibLoader::self()->factory(libname.local8Bit()); - if (factory) - { - TQStringList args; - args << m_current->device() << m_current->printerName(); - KDialogBase *dlg = static_cast<KDialogBase*>(TQT_TQWIDGET(factory->create(TQT_TQOBJECT(this), "Tool", 0, args))); - if (dlg) - dlg->exec(); - delete dlg; - } - } - else - KMessageBox::error(this, - i18n("Unable to start printer tool. Possible reasons are: " - "no printer selected, the selected printer doesn't have " - "any local device defined (printer port), or the tool library " - "could not be found.")); - - KMTimer::self()->release(); -} - -void KMMainView::slotToggleFilter(bool on) -{ - KMTimer::self()->hold(); - KMManager::self()->enableFilter(on); - KMTimer::self()->release(true); -} - -void KMMainView::configChanged() -{ - reset( i18n( "Initializing manager..." ), false, true ); -} - -void KMMainView::slotUpdatePossible( bool flag ) -{ - destroyMessageWindow(); - if ( !flag ) - showErrorMsg( i18n( "Unable to retrieve the printer list." ) ); - KMTimer::self()->release( true ); -} - -void KMMainView::createMessageWindow( const TQString& txt, int delay ) -{ - destroyMessageWindow(); - MessageWindow::add( m_printerview, txt, delay ); -} - -void KMMainView::destroyMessageWindow() -{ - MessageWindow::remove( m_printerview ); -} - -void KMMainView::slotInit() -{ - reset( i18n( "Initializing manager..." ), true, true ); -} - -void KMMainView::reset( const TQString& msg, bool useDelay, bool holdTimer ) -{ - if ( holdTimer ) - KMTimer::self()->hold(); - m_printerview->setPrinterList( 0 ); - if ( !msg.isEmpty() ) - createMessageWindow( msg, ( useDelay ? 500 : 0 ) ); - m_first = true; - m_manager->checkUpdatePossible(); -} - -void KMMainView::slotHelp() -{ - TQString s = TQT_TQOBJECT_CONST(sender())->name(); - if ( s == "invoke_help" ) - kapp->invokeHelp( TQString::null, "tdeprint" ); - else if ( s == "invoke_web" ) - { - TQStringList args; - args << "exec" << "http://printing.kde.org"; - kapp->tdeinitExec( "kfmclient", args ); - } - else - kdDebug( 500 ) << "Unknown help invokator: " << s << endl; -} - -#include "kmmainview.moc" diff --git a/kdeprint/management/kmmainview.h b/kdeprint/management/kmmainview.h deleted file mode 100644 index 0d05692d9..000000000 --- a/kdeprint/management/kmmainview.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMMAINVIEW_H -#define KMMAINVIEW_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqwidget.h> -#include <tdeprint/kpreloadobject.h> -#include <kmainwindow.h> - -class KMManager; -class KMPrinterView; -class KMPrinter; -class KMPages; -class KActionCollection; -class TQPopupMenu; -class TQTimer; -class TQSplitter; -class KToolBar; -class KAction; -class PluginComboBox; -class TQBoxLayout; -class MessageWindow; -class TQMenuBar; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMMainView : public TQWidget, public KPReloadObject -{ - Q_OBJECT -public: - KMMainView(TQWidget *parent = 0, const char *name = 0, KActionCollection *coll = 0); - ~KMMainView(); - - void setOrientation(int); - int orientation() const; - void setViewType(int); - int viewType() const; - void enableToolbar(bool on = true); - KAction* action(const char *name); - void showPrinterInfos(bool on); - bool printerInfosShown() const; - -public slots: - void slotTimer(); - void slotShowPrinterInfos(bool); - void slotChangePrinterState(); - void slotRemove(); - void slotConfigure(); - void slotAdd(); - void slotHardDefault(); - void slotSoftDefault(); - void slotTest(); - void slotServerRestart(); - void slotServerConfigure(); - void slotServerConfigureAccess(); - void slotManagerConfigure(); - void slotAddSpecial(); - void slotRefresh(); - void slotToolSelected(int); - void slotToggleFilter(bool); - void slotHelp(); - -protected slots: - void slotPrinterSelected(const TQString&); - void slotRightButtonClicked(const TQString&, const TQPoint&); - void slotToggleToolBar(bool); - void slotToggleMenuBar(bool); - void slotChangeView(int); - void slotChangeDirection(int); - void slotUpdatePossible( bool ); - void slotInit(); - -protected: - void initActions(); - void showErrorMsg(const TQString& msg, bool usemgr = true); - void restoreSettings(); - void saveSettings(); - void loadParameters(); - void reload(); - void configChanged(); - //void aboutToReload(); - void loadPluginActions(); - void removePluginActions(); - void createMessageWindow( const TQString&, int delay = 500 ); - void destroyMessageWindow(); - void reset( const TQString& msg = TQString::null, bool useDelay = true, bool holdTimer = true ); - -private: - KMPrinterView *m_printerview; - KMPages *m_printerpages; - TQPopupMenu *m_pop; - KActionCollection *m_actions; - KMPrinter *m_current; - KToolBar *m_toolbar; - PluginComboBox *m_plugin; - int m_pactionsindex; - TQStringList m_toollist; - bool m_first; - TQBoxLayout *m_boxlayout; - class KMainWindowPrivate; - KMainWindowPrivate *d; - KToolBar *m_menubar; -}; - -KDEPRINT_EXPORT int tdeprint_management_add_printer_wizard( TQWidget* parent ); - -#endif diff --git a/kdeprint/management/kmpages.cpp b/kdeprint/management/kmpages.cpp deleted file mode 100644 index 4f0f1f4f7..000000000 --- a/kdeprint/management/kmpages.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpages.h" -#include "kminfopage.h" -#include "kmjobviewer.h" -#include "kmpropertypage.h" -#include "kminstancepage.h" - -#include <klocale.h> -#include <kiconloader.h> -#include <kdialog.h> - -KMPages::KMPages(TQWidget *parent, const char *name) -: TQTabWidget(parent,name) -{ - m_pages.setAutoDelete(false); - initialize(); -} - -KMPages::~KMPages() -{ -} - -void KMPages::setPrinter(KMPrinter *p) -{ - TQPtrListIterator<KMPrinterPage> it(m_pages); - for (int i=0;it.current();++it,i++) - it.current()->setPrinter(p); -} - -void KMPages::initialize() -{ - setMargin(KDialog::marginHint()); - - // Info page - KMInfoPage *infopage = new KMInfoPage(this, "InfoPage"); - addTab(infopage, SmallIcon("help"), i18n("Information")); - m_pages.append(infopage); - - // Job page - KMJobViewer *jobviewer = new KMJobViewer(this, "JobViewer"); - addTab(jobviewer, SmallIcon("folder"), i18n("Jobs")); - m_pages.append(jobviewer); - - // Property page - KMPropertyPage *proppage = new KMPropertyPage(this, "Property"); - addTab(proppage, SmallIcon("configure"), i18n("Properties")); - m_pages.append(proppage); - - // Instance page - KMInstancePage *instpage = new KMInstancePage(this, "Instance"); - addTab(instpage, SmallIcon("fileprint"), i18n("Instances")); - m_pages.append(instpage); - - // initialize pages - setPrinter(0); -} diff --git a/kdeprint/management/kmpages.h b/kdeprint/management/kmpages.h deleted file mode 100644 index 761c8d22d..000000000 --- a/kdeprint/management/kmpages.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPAGES_H -#define KMPAGES_H - -#include <tqtabwidget.h> -#include <tqptrlist.h> - -class KMPrinter; -class KMPrinterPage; - -class KMPages : public TQTabWidget -{ -public: - KMPages(TQWidget *parent = 0, const char *name = 0); - ~KMPages(); - - void setPrinter(KMPrinter *p); - -protected: - void initialize(); - -private: - TQPtrList<KMPrinterPage> m_pages; -}; - -#endif diff --git a/kdeprint/management/kmprinterpage.h b/kdeprint/management/kmprinterpage.h deleted file mode 100644 index 25e5b1c12..000000000 --- a/kdeprint/management/kmprinterpage.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPRINTERPAGE_H -#define KMPRINTERPAGE_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -class KMPrinter; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KMPrinterPage -{ -public: - virtual void setPrinter(KMPrinter*) = 0; -}; - -#endif diff --git a/kdeprint/management/kmprinterview.cpp b/kdeprint/management/kmprinterview.cpp deleted file mode 100644 index 19264a946..000000000 --- a/kdeprint/management/kmprinterview.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmprinterview.h" -#include "kmprinter.h" -#include "kmiconview.h" -#include "kmlistview.h" -#include "kmtimer.h" -#include "kmmanager.h" - -#include <tqlayout.h> -#include <tqpopupmenu.h> -#include <kaction.h> -#include <klocale.h> - -KMPrinterView::KMPrinterView(TQWidget *parent, const char *name) -: TQWidgetStack(parent,name), m_type(KMPrinterView::Icons) -{ - m_iconview = new KMIconView(this); - addWidget(m_iconview,0); - m_listview = new KMListView(this); - addWidget(m_listview,1); - m_current = TQString(); - m_listset = false; - - connect(m_iconview,TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)),TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&))); - connect(m_listview,TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&)),TQT_SIGNAL(rightButtonClicked(const TQString&,const TQPoint&))); - connect(m_iconview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SIGNAL(printerSelected(const TQString&))); - connect(m_listview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SIGNAL(printerSelected(const TQString&))); - connect(m_iconview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SLOT(slotPrinterSelected(const TQString&))); - connect(m_listview,TQT_SIGNAL(printerSelected(const TQString&)),TQT_SLOT(slotPrinterSelected(const TQString&))); - - setViewType(m_type); - tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding ) ); -} - -KMPrinterView::~KMPrinterView() -{ -} - -void KMPrinterView::setPrinterList(TQPtrList<KMPrinter> *list) -{ - if (m_type != KMPrinterView::Tree || list == 0) - m_iconview->setPrinterList(list); - if (m_type == KMPrinterView::Tree || list == 0) - m_listview->setPrinterList(list); - m_listset = ( list != 0 ); -} - -void KMPrinterView::setPrinter( KMPrinter *p ) -{ - if ( m_type == KMPrinterView::Tree ) - m_listview->setPrinter( p ); - else - m_iconview->setPrinter( p ); -} - -void KMPrinterView::setViewType(ViewType t) -{ - m_type = t; - switch (m_type) - { - case KMPrinterView::Icons: - m_iconview->setViewMode(KMIconView::Big); - break; - case KMPrinterView::List: - m_iconview->setViewMode(KMIconView::Small); - break; - default: - break; - } - QString oldcurrent = m_current; - if ( m_listset ) - setPrinterList(KMManager::self()->printerList(false)); - if (m_type == KMPrinterView::Tree) - { - raiseWidget(m_listview); - m_listview->setPrinter(oldcurrent); - } - else - { - raiseWidget(m_iconview); - m_iconview->setPrinter(oldcurrent); - } -} - -void KMPrinterView::slotPrinterSelected(const TQString& p) -{ - m_current = p; -} - -TQSize KMPrinterView::tqminimumSizeHint() const -{ - return TQWidgetStack::tqminimumSizeHint(); -} - -#include "kmprinterview.moc" diff --git a/kdeprint/management/kmprinterview.h b/kdeprint/management/kmprinterview.h deleted file mode 100644 index ba1bd38b1..000000000 --- a/kdeprint/management/kmprinterview.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPRINTERVIEW_H -#define KMPRINTERVIEW_H - -#include <tqwidgetstack.h> -#include <tqptrlist.h> - -class KMIconView; -class KMListView; -class KMPrinter; -class TQIconViewItem; - -class KMPrinterView : public TQWidgetStack -{ - Q_OBJECT -public: - enum ViewType { Icons = 0, List, Tree }; - - KMPrinterView(TQWidget *parent = 0, const char *name = 0); - ~KMPrinterView(); - - void setPrinterList(TQPtrList<KMPrinter> *list); - void setPrinter( KMPrinter* ); - void setViewType(ViewType t); - ViewType viewType() const { return m_type; } - - TQSize tqminimumSizeHint() const; - -signals: - void printerSelected(const TQString&); - void rightButtonClicked(const TQString&, const TQPoint&); - -protected slots: - void slotPrinterSelected(const TQString&); - -private: - KMIconView *m_iconview; - KMListView *m_listview; - ViewType m_type; - QString m_current; - bool m_listset; -}; - -#endif diff --git a/kdeprint/management/kmpropbackend.cpp b/kdeprint/management/kmpropbackend.cpp deleted file mode 100644 index 98004d2ed..000000000 --- a/kdeprint/management/kmpropbackend.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropbackend.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropBackend::KMPropBackend(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_uri = new TQLabel("",this); - m_type = new TQLabel("",this); - - TQLabel *l1 = new TQLabel(i18n("Printer type:"), this); - TQLabel *l2 = new TQLabel(i18n("URI:"), this); - - // layout - TQGridLayout *main_ = new TQGridLayout(this, 3, 2, 10, 7); - main_->setColStretch(0,0); - main_->setColStretch(1,1); - main_->setRowStretch(2,1); - main_->addWidget(l1,0,0); - main_->addWidget(l2,1,0); - main_->addWidget(m_type,0,1); - main_->addWidget(m_uri,1,1); - - m_pixmap = "connect_established"; - m_title = i18n("Interface"); - m_header = i18n("Interface Settings"); -} - -KMPropBackend::~KMPropBackend() -{ -} - -void KMPropBackend::setPrinter(KMPrinter *p) -{ - if (p && p->isPrinter()) - { - m_uri->setText(KURL(p->device()).prettyURL()); - TQString prot = p->deviceProtocol(); - if (prot == "ipp" || prot == "http") m_type->setText(i18n("IPP Printer")); - else if (prot == "usb") m_type->setText(i18n("Local USB Printer")); - else if (prot == "parallel") m_type->setText(i18n("Local Parallel Printer")); - else if (prot == "serial") m_type->setText(i18n("Local Serial Printer")); - else if (prot == "socket") m_type->setText(i18n("Network Printer (socket)")); - else if (prot == "smb") m_type->setText(i18n("SMB printers (Windows)")); - else if (prot == "lpd") m_type->setText(i18n("Remote LPD queue")); - else if (prot == "file") m_type->setText(i18n("File printer")); - else if (prot == "fax") m_type->setText(i18n("Serial Fax/Modem printer")); - else m_type->setText(i18n("Unknown Protocol", "Unknown")); - emit enable(true); - emit enableChange(p->isLocal()); - } - else - { - emit enable(false); - m_type->setText(""); - m_uri->setText(""); - } -} - -void KMPropBackend::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Backend,KMWizard::Driver,false); -} diff --git a/kdeprint/management/kmpropbackend.h b/kdeprint/management/kmpropbackend.h deleted file mode 100644 index 01249d348..000000000 --- a/kdeprint/management/kmpropbackend.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPBACKEND_H -#define KMPROPBACKEND_H - -#include "kmpropwidget.h" - -#include <kdelibs_export.h> - -class TQLabel; - -class KDEPRINT_EXPORT KMPropBackend : public KMPropWidget -{ -public: - KMPropBackend(TQWidget *parent = 0, const char *name = 0); - ~KMPropBackend(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQLabel *m_type; - TQLabel *m_uri; -}; - -#endif diff --git a/kdeprint/management/kmpropcontainer.cpp b/kdeprint/management/kmpropcontainer.cpp deleted file mode 100644 index 9c7808199..000000000 --- a/kdeprint/management/kmpropcontainer.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropcontainer.h" -#include "kmpropwidget.h" - -#include <kpushbutton.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kseparator.h> -#include <kguiitem.h> - -KMPropContainer::KMPropContainer(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - sep->setFixedHeight(5); - - m_button = new KPushButton(KGuiItem(i18n("Change..."), "edit"), this); - m_widget = 0; - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); - TQHBoxLayout *btn_ = new TQHBoxLayout(0, 0, 0); - main_->addWidget(sep,0); - main_->addLayout(btn_,0); - btn_->addStretch(1); - btn_->addWidget(m_button); -} - -KMPropContainer::~KMPropContainer() -{ -} - -void KMPropContainer::setWidget(KMPropWidget *w) -{ - if (!m_widget) - { - m_widget = w; - m_widget->reparent(this,TQPoint(0,0)); - connect(m_button,TQT_SIGNAL(clicked()),m_widget,TQT_SLOT(slotChange())); - connect(m_widget,TQT_SIGNAL(enable(bool)),TQT_SIGNAL(enable(bool))); - connect(m_widget,TQT_SIGNAL(enableChange(bool)),TQT_SLOT(slotEnableChange(bool))); - TQVBoxLayout *lay = dynamic_cast<TQVBoxLayout*>(layout()); - if (lay) - { - lay->insertWidget(0,m_widget,1); - } - } -} - -void KMPropContainer::setPrinter(KMPrinter *p) -{ - if (m_widget) - m_widget->setPrinterBase(p); -} - -void KMPropContainer::slotEnableChange(bool on) -{ - m_button->setEnabled(on && (m_widget ? m_widget->canChange() : true)); -} -#include "kmpropcontainer.moc" diff --git a/kdeprint/management/kmpropcontainer.h b/kdeprint/management/kmpropcontainer.h deleted file mode 100644 index d191dfeb6..000000000 --- a/kdeprint/management/kmpropcontainer.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPCONTAINER_H -#define KMPROPCONTAINER_H - -#include <tqwidget.h> - -class KMPropWidget; -class TQPushButton; -class KMPrinter; - -class KMPropContainer : public TQWidget -{ - Q_OBJECT -public: - KMPropContainer(TQWidget *parent = 0, const char *name = 0); - ~KMPropContainer(); - - void setWidget(KMPropWidget*); - void setPrinter(KMPrinter*); - -signals: - void enable(bool); - -protected slots: - void slotEnableChange(bool); - -private: - KMPropWidget *m_widget; - TQPushButton *m_button; -}; - -#endif diff --git a/kdeprint/management/kmpropdriver.cpp b/kdeprint/management/kmpropdriver.cpp deleted file mode 100644 index 55daf0ed5..000000000 --- a/kdeprint/management/kmpropdriver.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropdriver.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropDriver::KMPropDriver(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_manufacturer = new TQLabel("",this); - m_model = new TQLabel("",this); - m_driverinfo = new TQLabel("",this); - m_driverinfo->setTextFormat(TQt::RichText); - - TQLabel *l1 = new TQLabel(i18n("Manufacturer:"), this); - TQLabel *l2 = new TQLabel(i18n("Printer model:"), this); - TQLabel *l3 = new TQLabel(i18n("Driver info:"), this); - - // layout - TQGridLayout *main_ = new TQGridLayout(this, 4, 2, 10, 7); - main_->setColStretch(0,0); - main_->setColStretch(1,1); - main_->setRowStretch(3,1); - main_->addWidget(l1,0,0); - main_->addWidget(l2,1,0); - main_->addWidget(l3,2,0,Qt::AlignTop|Qt::AlignLeft); - main_->addWidget(m_manufacturer,0,1); - main_->addWidget(m_model,1,1); - main_->addWidget(m_driverinfo,2,1); - - m_pixmap = "gear"; - m_title = i18n("Driver"); - m_header = i18n("Driver Settings"); -} - -KMPropDriver::~KMPropDriver() -{ -} - -void KMPropDriver::setPrinter(KMPrinter *p) -{ - if (p && p->isPrinter()) - { - m_manufacturer->setText(p->manufacturer()); - m_model->setText(p->model()); - m_driverinfo->setText(p->driverInfo()); - emit enable(true); - emit enableChange(p->isLocal()); - } - else - { - emit enable(false); - m_manufacturer->setText(""); - m_model->setText(""); - m_driverinfo->setText(""); - } -} - -void KMPropDriver::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Driver,KMWizard::DriverTest,true); -} diff --git a/kdeprint/management/kmpropdriver.h b/kdeprint/management/kmpropdriver.h deleted file mode 100644 index 247431762..000000000 --- a/kdeprint/management/kmpropdriver.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPDRIVER_H -#define KMPROPDRIVER_H - -#include "kmpropwidget.h" - -#include <kdelibs_export.h> - -class TQLabel; - -class KDEPRINT_EXPORT KMPropDriver : public KMPropWidget -{ -public: - KMPropDriver(TQWidget *parent = 0, const char *name = 0); - ~KMPropDriver(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQLabel *m_manufacturer; - TQLabel *m_model; - TQLabel *m_driverinfo; -}; - -#endif diff --git a/kdeprint/management/kmpropertypage.cpp b/kdeprint/management/kmpropertypage.cpp deleted file mode 100644 index e0526ad5a..000000000 --- a/kdeprint/management/kmpropertypage.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropertypage.h" -#include "kmpropwidget.h" -#include "kmpropcontainer.h" -#include "kmprinter.h" -#include "kmfactory.h" -#include "kmuimanager.h" - -#include "kmpropgeneral.h" - -#include <tqvbox.h> -#include <kiconloader.h> - -KMPropertyPage::KMPropertyPage(TQWidget *parent, const char *name) -: CJanusWidget(parent,name) -{ - m_widgets.setAutoDelete(false); - - initialize(); -} - -KMPropertyPage::~KMPropertyPage() -{ -} - -void KMPropertyPage::setPrinter(KMPrinter *p) -{ - TQPtrListIterator<KMPropWidget> it(m_widgets); - for (;it.current();++it) - it.current()->setPrinterBase(p); -} - -void KMPropertyPage::addPropPage(KMPropWidget *w) -{ - if (w) - { - m_widgets.append(w); - KMPropContainer *ctn = new KMPropContainer(this,"Container"); - ctn->setWidget(w); - connect(ctn,TQT_SIGNAL(enable(bool)),TQT_SLOT(slotEnable(bool))); - - TQPixmap icon = KGlobal::instance()->iconLoader()->loadIcon( - w->pixmap(), - KIcon::NoGroup, - KIcon::SizeMedium - ); - addPage(ctn,w->title(),w->header(),icon); - } -} - -void KMPropertyPage::slotEnable(bool on) -{ - TQWidget *w = (TQWidget*)(sender()); - if (on) - enablePage(w); - else - disablePage(w); -} - -void KMPropertyPage::initialize() -{ - // add General page - addPropPage(new KMPropGeneral(this, "General")); - // add plugin specific pages - KMFactory::self()->uiManager()->setupPropertyPages(this); -} - -void KMPropertyPage::reload() -{ - clearPages(); - m_widgets.clear(); - initialize(); - setPrinter(0); -} - -#include "kmpropertypage.moc" diff --git a/kdeprint/management/kmpropertypage.h b/kdeprint/management/kmpropertypage.h deleted file mode 100644 index d13338750..000000000 --- a/kdeprint/management/kmpropertypage.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPERTYPAGE_H -#define KMPROPERTYPAGE_H - -#include "cjanuswidget.h" -#include "kmprinterpage.h" -#include <tdeprint/kpreloadobject.h> -#include <kdelibs_export.h> -#include <tqptrlist.h> - -class KMPropWidget; -class KMPrinter; - -class KDEPRINT_EXPORT KMPropertyPage : public CJanusWidget, public KMPrinterPage, public KPReloadObject -{ - Q_OBJECT -public: - KMPropertyPage(TQWidget *parent = 0, const char *name = 0); - ~KMPropertyPage(); - - void addPropPage(KMPropWidget*); - void setPrinter(KMPrinter*); - -protected slots: - void slotEnable(bool); - void initialize(); - -protected: - void reload(); - -private: - TQPtrList<KMPropWidget> m_widgets; -}; - -#endif diff --git a/kdeprint/management/kmpropgeneral.cpp b/kdeprint/management/kmpropgeneral.cpp deleted file mode 100644 index c55603da9..000000000 --- a/kdeprint/management/kmpropgeneral.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropgeneral.h" -#include "kmprinter.h" -#include "kmwizard.h" -#include "kmfactory.h" -#include "kmmanager.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropGeneral::KMPropGeneral(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_name = new TQLabel("",this); - m_location = new TQLabel("",this); - m_description = new TQLabel("",this); - - TQLabel *l1 = new TQLabel(i18n("Printer name:"), this); - TQLabel *l2 = new TQLabel(i18n("Physical Location", "Location:"), this); - TQLabel *l3 = new TQLabel(i18n("Description:"), this); - - // layout - TQGridLayout *main_ = new TQGridLayout(this, 4, 2, 10, 7); - main_->setColStretch(0,0); - main_->setColStretch(1,1); - main_->setRowStretch(3,1); - main_->addWidget(l1,0,0); - main_->addWidget(l2,1,0); - main_->addWidget(l3,2,0); - main_->addWidget(m_name,0,1); - main_->addWidget(m_location,1,1); - main_->addWidget(m_description,2,1); - - m_pixmap = "contents"; - m_title = i18n("General"); - m_header = i18n("General Settings"); -} - -KMPropGeneral::~KMPropGeneral() -{ -} - -void KMPropGeneral::setPrinter(KMPrinter *p) -{ - if (p) - { - m_name->setText(p->name()); - m_location->setText(p->location()); - m_description->setText(p->description()); - emit enableChange(!(p->isSpecial() || p->isRemote() || p->isImplicit())); - } - else - { - emit enableChange(false); - m_name->setText(""); - m_location->setText(""); - m_description->setText(""); - } -} - -void KMPropGeneral::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Name,KMWizard::Name,true); -} diff --git a/kdeprint/management/kmpropgeneral.h b/kdeprint/management/kmpropgeneral.h deleted file mode 100644 index c4e403b86..000000000 --- a/kdeprint/management/kmpropgeneral.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPGENERAL_H -#define KMPROPGENERAL_H - -#include "kmpropwidget.h" - -class TQLabel; - -class KMPropGeneral : public KMPropWidget -{ -public: - KMPropGeneral(TQWidget *parent = 0, const char *name = 0); - ~KMPropGeneral(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQLabel *m_name; - TQLabel *m_location; - TQLabel *m_description; -}; - -#endif diff --git a/kdeprint/management/kmpropmembers.cpp b/kdeprint/management/kmpropmembers.cpp deleted file mode 100644 index 4efbcf547..000000000 --- a/kdeprint/management/kmpropmembers.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropmembers.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqtextview.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropMembers::KMPropMembers(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_members = new TQTextView(this); - m_members->setPaper(tqcolorGroup().background()); - m_members->setFrameStyle(TQFrame::NoFrame); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 10, 0); - main_->addWidget(m_members); - - m_pixmap = "tdeprint_printer_class"; - m_title = i18n("Members"); - m_header = i18n("Class Members"); -} - -KMPropMembers::~KMPropMembers() -{ -} - -void KMPropMembers::setPrinter(KMPrinter *p) -{ - if (p && ((p->isClass(false) && p->isLocal()) || p->isImplicit())) - { - TQStringList l = p->members(); - TQString txt("<ul>"); - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - txt.append("<li>" + (*it) + "</li>"); - txt.append("</ul>"); - m_members->setText(txt); - emit enable(true); - emit enableChange(!p->isImplicit()); - } - else - { - emit enable(false); - m_members->setText(""); - } -} - -void KMPropMembers::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Class,KMWizard::Class,true); -} diff --git a/kdeprint/management/kmpropmembers.h b/kdeprint/management/kmpropmembers.h deleted file mode 100644 index 90330681e..000000000 --- a/kdeprint/management/kmpropmembers.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPMEMBERS_H -#define KMPROPMEMBERS_H - -#include "kmpropwidget.h" - -class TQTextView; - -class KDEPRINT_EXPORT KMPropMembers : public KMPropWidget -{ -public: - KMPropMembers(TQWidget *parent = 0, const char *name = 0); - ~KMPropMembers(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQTextView *m_members; -}; - -#endif diff --git a/kdeprint/management/kmpropwidget.cpp b/kdeprint/management/kmpropwidget.cpp deleted file mode 100644 index ae8b03cbf..000000000 --- a/kdeprint/management/kmpropwidget.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmpropwidget.h" -#include "kmwizard.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmtimer.h" - -#include <kmessagebox.h> -#include <klocale.h> - -KMPropWidget::KMPropWidget(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_pixmap = "folder"; - m_title = m_header = "Title"; - m_printer = 0; - m_canchange = ((KMFactory::self()->manager()->printerOperationMask() & KMManager::PrinterCreation) && KMFactory::self()->manager()->hasManagement()); - - connect(this,TQT_SIGNAL(enable(bool)),this,TQT_SIGNAL(enableChange(bool))); -} - -KMPropWidget::~KMPropWidget() -{ -} - -void KMPropWidget::slotChange() -{ - KMTimer::self()->hold(); - int value = requestChange(); - if (value == -1) - { - KMessageBox::error(this, i18n("<qt>Unable to change printer properties. Error received from manager:<p>%1</p></qt>").arg(KMManager::self()->errorMsg())); - KMManager::self()->setErrorMsg(TQString::null); - } - KMTimer::self()->release((value == 1)); -} - -void KMPropWidget::setPrinterBase(KMPrinter *p) -{ - m_printer = p; - setPrinter(p); -} - -void KMPropWidget::setPrinter(KMPrinter*) -{ -} - -void KMPropWidget::configureWizard(KMWizard*) -{ -} - -// return status: -// -1 : error -// 0 : nothing to be done (canceled) -// 1 : success -int KMPropWidget::requestChange() -{ - if (m_printer) - { - KMWizard dlg(this); - configureWizard(&dlg); - dlg.setPrinter(m_printer); - if (dlg.exec()) - return (KMFactory::self()->manager()->modifyPrinter(m_printer,dlg.printer()) ? 1 : -1); - } - return 0; -} -#include "kmpropwidget.moc" diff --git a/kdeprint/management/kmpropwidget.h b/kdeprint/management/kmpropwidget.h deleted file mode 100644 index 83148bc72..000000000 --- a/kdeprint/management/kmpropwidget.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPWIDGET_H -#define KMPROPWIDGET_H - -#include <tqwidget.h> - -#include <kdelibs_export.h> - -class KMPrinter; -class KMWizard; - -class KDEPRINT_EXPORT KMPropWidget : public TQWidget -{ - Q_OBJECT -public: - KMPropWidget(TQWidget *parent = 0, const char *name = 0); - virtual ~KMPropWidget(); - - virtual void setPrinter(KMPrinter*); - void setPrinterBase(KMPrinter*); - TQString pixmap() const { return m_pixmap; } - TQString title() const { return m_title; } - TQString header() const { return m_header; } - bool canChange() const { return m_canchange; } - -signals: - void enable(bool); - void enableChange(bool); - -public slots: - void slotChange(); - -protected: - virtual int requestChange(); - virtual void configureWizard(KMWizard*); - -protected: - QString m_pixmap; - QString m_title; - QString m_header; - KMPrinter *m_printer; - bool m_canchange; -}; - -#endif diff --git a/kdeprint/management/kmspecialprinterdlg.cpp b/kdeprint/management/kmspecialprinterdlg.cpp deleted file mode 100644 index 6569f3f83..000000000 --- a/kdeprint/management/kmspecialprinterdlg.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmspecialprinterdlg.h" -#include "kmprinter.h" -#include "tdeprintcheck.h" -#include "kmfactory.h" -#include "kmspecialmanager.h" -#include "kxmlcommandselector.h" -#include "kxmlcommand.h" -#include "driver.h" - -#include <tqpushbutton.h> -#include <tqlineedit.h> -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwhatsthis.h> -#include <tqgroupbox.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <kicondialog.h> -#include <kfiledialog.h> -#include <kseparator.h> - -KMSpecialPrinterDlg::KMSpecialPrinterDlg(TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok) -{ - setCaption(i18n("Add Special Printer")); - - TQWidget *dummy = new TQWidget(this); - setMainWidget(dummy); - - // widget creation - m_name = new TQLineEdit(dummy); - connect(m_name, TQT_SIGNAL(textChanged ( const TQString & )),this,TQT_SLOT(slotTextChanged(const TQString & ))); - m_description = new TQLineEdit(dummy); - m_location = new TQLineEdit(dummy); - TQLabel *m_namelabel = new TQLabel(i18n("&Name:"), dummy); - TQLabel *m_desclabel = new TQLabel(i18n("&Description:"), dummy); - TQLabel *m_loclabel = new TQLabel(i18n("&Location:"), dummy); - m_namelabel->setBuddy(m_name); - m_desclabel->setBuddy(m_description); - m_loclabel->setBuddy(m_location); - - KSeparator* sep = new KSeparator( KSeparator::HLine, dummy); - - sep->setFixedHeight(10); - TQGroupBox *m_gb = new TQGroupBox(1, Qt::Horizontal, i18n("Command &Settings"), dummy); - m_command = new KXmlCommandSelector(true, m_gb, "CommandSelector", this); - - TQGroupBox *m_outfile_gb = new TQGroupBox( 0, Qt::Horizontal, i18n( "Outp&ut File" ), dummy ); - - m_usefile = new TQCheckBox( i18n("&Enable output file"), m_outfile_gb); - - m_mimetype = new TQComboBox(m_outfile_gb); - KMimeType::List list = KMimeType::allMimeTypes(); - for (TQValueList<KMimeType::Ptr>::ConstIterator it=list.begin(); it!=list.end(); ++it) - { - TQString mimetype = (*it)->name(); - m_mimelist << mimetype; - } - m_mimelist.sort(); - m_mimetype->insertStringList(m_mimelist); - - TQLabel *m_mimetypelabel = new TQLabel(i18n("&Format:"), m_outfile_gb); - m_mimetypelabel->setBuddy (m_mimetype); - - m_extension = new TQLineEdit(m_outfile_gb); - - TQLabel *m_extensionlabel = new TQLabel(i18n("Filename e&xtension:"), m_outfile_gb); - m_extensionlabel->setBuddy(m_extension); - - m_icon = new KIconButton(dummy); - m_icon->setIcon("fileprint"); - m_icon->setFixedSize(TQSize(48,48)); - - connect( m_usefile, TQT_SIGNAL( toggled( bool ) ), m_mimetype, TQT_SLOT( setEnabled( bool ) ) ); - connect( m_usefile, TQT_SIGNAL( toggled( bool ) ), m_extension, TQT_SLOT( setEnabled( bool ) ) ); - connect( m_usefile, TQT_SIGNAL( toggled( bool ) ), m_mimetypelabel, TQT_SLOT( setEnabled( bool ) ) ); - connect( m_usefile, TQT_SIGNAL( toggled( bool ) ), m_extensionlabel, TQT_SLOT( setEnabled( bool ) ) ); - m_mimetypelabel->setEnabled( false ); - m_mimetype->setEnabled( false ); - m_extensionlabel->setEnabled( false ); - m_extension->setEnabled( false ); - - TQWhatsThis::add(m_usefile, - i18n("<p>The command will use an output file. If checked, make sure the " - "command contains an output tag.</p>")); - TQWhatsThis::add(m_command, - i18n("<p>The command to execute when printing on this special printer. Either enter " - "the command to execute directly, or associate/create a command object with/for " - "this special printer. The command object is the preferred method as it provides " - "support for advanced settings like mime type checking, configurable options and " - "requirement list (the plain command is only provided for backward compatibility). " - "When using a plain command, the following tags are recognized:</p>" - "<ul><li><b>%in</b>: the input file (required).</li>" - "<li><b>%out</b>: the output file (required if using an output file).</li>" - "<li><b>%psl</b>: the paper size in lower case.</li>" - "<li><b>%psu</b>: the paper size with the first letter in upper case.</li></ul>")); - TQString mimetypeWhatsThis = i18n("<p>The default mimetype for the output file (e.g. application/postscript).</p>"); - TQWhatsThis::add(m_mimetypelabel, mimetypeWhatsThis); - TQWhatsThis::add(m_mimetype, mimetypeWhatsThis); - TQString extensionWhatsThis = i18n("<p>The default extension for the output file (e.g. ps, pdf, ps.gz).</p>"); - TQWhatsThis::add(m_extensionlabel, extensionWhatsThis); - TQWhatsThis::add(m_extension, extensionWhatsThis); - - // layout creation - TQVBoxLayout *l0 = new TQVBoxLayout(dummy, 0, 10); - TQGridLayout *l1 = new TQGridLayout(0, 3, 3, 0, 5); - l0->addLayout(TQT_TQLAYOUT(l1)); - l1->setColStretch(2,1); - l1->addColSpacing(0,60); - l1->addMultiCellWidget(m_icon, 0, 2, 0, 0, Qt::AlignCenter); - l1->addWidget(m_namelabel, 0, 1); - l1->addWidget(m_desclabel, 1, 1); - l1->addWidget(m_loclabel, 2, 1); - l1->addWidget(m_name, 0, 2); - l1->addWidget(m_description, 1, 2); - l1->addWidget(m_location, 2, 2); - l0->addWidget(sep); - l0->addWidget(m_gb); - l0->addWidget(m_outfile_gb); - TQGridLayout *l6 = new TQGridLayout(m_outfile_gb->tqlayout(), 3, 2, 10); - l6->addMultiCellWidget( m_usefile, 0, 0, 0, 1 ); - l6->addWidget(m_mimetypelabel, 1, 0); - l6->addWidget(m_mimetype, 1, 1); - l6->addWidget(m_extensionlabel, 2, 0); - l6->addWidget(m_extension, 2, 1); - - enableButton(Ok, !m_name->text().isEmpty()); - - // resize dialog - resize(400,100); -} - -void KMSpecialPrinterDlg::slotTextChanged(const TQString & ) -{ - enableButton(Ok, !m_name->text().isEmpty()); -} - -void KMSpecialPrinterDlg::slotOk() -{ - if (!checkSettings()) - return; - KDialogBase::slotOk(); -} - -bool KMSpecialPrinterDlg::checkSettings() -{ - TQString msg; - if (m_name->text().isEmpty()) - msg = i18n("You must provide a non-empty name."); - else - KXmlCommandManager::self()->checkCommand(m_command->command(), - KXmlCommandManager::Basic, - (m_usefile->isChecked() ? KXmlCommandManager::Basic : KXmlCommandManager::None), - &msg); - - if (!msg.isEmpty()) - KMessageBox::error(this, i18n("Invalid settings. %1.").arg(msg)); - - return (msg.isEmpty()); -} - -void KMSpecialPrinterDlg::setPrinter(KMPrinter *printer) -{ - if (printer && printer->isSpecial()) - { - m_command->setCommand(printer->option("kde-special-command")); - m_usefile->setChecked(printer->option("kde-special-file") == "1"); - int index = m_mimelist.findIndex(printer->option("kde-special-mimetype")); - m_mimetype->setCurrentItem(index == -1 ? 0 : index); - m_extension->setText(printer->option("kde-special-extension")); - m_name->setText(printer->name()); - m_description->setText(printer->description()); - m_location->setText(printer->location()); - m_icon->setIcon(printer->pixmap()); - - setCaption(i18n("Configuring %1").arg(printer->name())); - } -} - -KMPrinter* KMSpecialPrinterDlg::printer() -{ - KMPrinter *printer = new KMPrinter(); - printer->setName(m_name->text()); - printer->setPrinterName(m_name->text()); - printer->setPixmap(m_icon->icon()); - printer->setDescription(m_description->text()); - printer->setLocation(m_location->text()); - printer->setOption("kde-special-command",m_command->command()); - printer->setOption("kde-special-file",(m_usefile->isChecked() ? "1" : "0")); - if (m_usefile->isChecked ()) - { - if (m_mimetype->currentText() != "all/all") - printer->setOption("kde-special-mimetype", m_mimetype->currentText()); - printer->setOption("kde-special-extension",m_extension->text()); - } - printer->setType(KMPrinter::Special); - printer->setState(KMPrinter::Idle); - return printer; -} - -#include "kmspecialprinterdlg.moc" diff --git a/kdeprint/management/kmspecialprinterdlg.h b/kdeprint/management/kmspecialprinterdlg.h deleted file mode 100644 index bc7497a05..000000000 --- a/kdeprint/management/kmspecialprinterdlg.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMSPECIALPRINTERDLG_H -#define KMSPECIALPRINTERDLG_H - -#include <kdialogbase.h> - -class KMPrinter; -class TQLineEdit; -class TQCheckBox; -class TQComboBox; -class KIconButton; -class KXmlCommandSelector; - -class KMSpecialPrinterDlg : public KDialogBase -{ - Q_OBJECT -public: - KMSpecialPrinterDlg(TQWidget *parent = 0, const char *name = 0); - - void setPrinter(KMPrinter*); - KMPrinter* printer(); - -protected: - bool checkSettings(); - -protected slots: - void slotOk(); - void slotTextChanged(const TQString &); - -private: - TQLineEdit *m_name, *m_description, *m_location, *m_extension; - TQComboBox *m_mimetype; - TQCheckBox *m_usefile; - TQStringList m_mimelist; - KIconButton *m_icon; - KXmlCommandSelector *m_command; -}; - -#endif diff --git a/kdeprint/management/kmtimer.cpp b/kdeprint/management/kmtimer.cpp deleted file mode 100644 index 1525dd875..000000000 --- a/kdeprint/management/kmtimer.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmtimer.h" -#include "kmfactory.h" - -#include <kconfig.h> - -KMTimer* KMTimer::m_self = 0; - -KMTimer* KMTimer::self() -{ - if (!m_self) - { - m_self = new KMTimer(KMFactory::self(), "InternalTimer"); - Q_CHECK_PTR(m_self); - } - return m_self; -} - -KMTimer::KMTimer(TQObject *parent, const char *name) -: TQTimer(parent, name), m_count(0) -{ - connect(this, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout())); -} - -KMTimer::~KMTimer() -{ - m_self = 0; -} - -void KMTimer::hold() -{ - if ((m_count++) == 0) - stop(); -} - -void KMTimer::release() -{ - releaseTimer(false); -} - -void KMTimer::release(bool do_emit) -{ - releaseTimer(do_emit); -} - -void KMTimer::releaseTimer(bool do_emit) -{ - m_count = QMAX(0, m_count-1); - if (m_count == 0) - { - if (do_emit) - emit timeout(); - startTimer(); - } -} - -void KMTimer::delay(int t) -{ - startTimer(t); -} - -void KMTimer::slotTimeout() -{ - startTimer(); -} - -void KMTimer::startTimer(int t) -{ - if (t == -1) - { - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("General"); - t = conf->readNumEntry("TimerDelay", 5) * 1000; - } - start(t, true); -} - -#include "kmtimer.moc" diff --git a/kdeprint/management/kmtimer.h b/kdeprint/management/kmtimer.h deleted file mode 100644 index eb40e7957..000000000 --- a/kdeprint/management/kmtimer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMTIMER_H -#define KMTIMER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include <tqtimer.h> -#include <kdelibs_export.h> - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class KDEPRINT_EXPORT KMTimer : public TQTimer -{ - Q_OBJECT -public: - void delay(int t); - ~KMTimer(); - -public slots: - void hold(); - void release(); - void release(bool do_emit); - - static KMTimer* self(); - -private slots: - void slotTimeout(); - -private: - static KMTimer *m_self; - int m_count; - KMTimer(TQObject *parent = 0, const char *name = 0); - void releaseTimer(bool do_emit = false); - void startTimer(int delay = -1); -}; - -#endif diff --git a/kdeprint/management/kmwbackend.cpp b/kdeprint/management/kmwbackend.cpp deleted file mode 100644 index e39b52f8d..000000000 --- a/kdeprint/management/kmwbackend.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwbackend.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqlayout.h> -#include <tqregexp.h> -#include <tqbuttongroup.h> -#include <tqradiobutton.h> -#include <tqwhatsthis.h> - -#include <kcursor.h> -#include <klocale.h> -#include <kseparator.h> -#include <kdialog.h> -#include <kdebug.h> - -class KRadioButton : public TQRadioButton -{ -public: - KRadioButton(const TQString& txt, TQWidget *parent = 0, const char *name = 0); -}; - -KRadioButton::KRadioButton(const TQString& txt, TQWidget *parent, const char *name) -: TQRadioButton(txt,parent,name) -{ - setCursor(KCursor::handCursor()); -} - -//******************************************************************************************************** - -KMWBackend::KMWBackend(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Backend; - m_title = i18n("Backend Selection"); - - m_buttons = new TQButtonGroup(this); - m_buttons->hide(); - - m_layout = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - m_layout->addStretch(1); - m_count = 0; -} - -bool KMWBackend::isValid(TQString& msg) -{ - if (!m_buttons->selected()) - { - msg = i18n("You must select a backend."); - return false; - } - return true; -} - -void KMWBackend::initPrinter(KMPrinter *p) -{ - TQString s = p->option("kde-backend"); - int ID(-1); - - if (!s.isEmpty()) - ID = s.toInt(); - else - { - s = p->deviceProtocol(); - // extract protocol - if (s == "parallel" || s == "serial" || s == "usb") ID = KMWizard::Local; - else if (s == "smb") ID = KMWizard::SMB; - else if (s == "ipp" || s == "http") ID = KMWizard::IPP; - else if (s == "lpd") ID = KMWizard::LPD; - else if (s == "socket") ID = KMWizard::TCP; - else if (s == "file") ID = KMWizard::File; - else if (p->members().count() > 0) ID = KMWizard::Class; - } - - if (m_buttons->find(ID)) - m_buttons->setButton(ID); -} - -void KMWBackend::updatePrinter(KMPrinter *p) -{ - int ID = m_buttons->id(m_buttons->selected()); - if (ID == KMWizard::Class) p->setType(KMPrinter::Class); - else p->setType(KMPrinter::Printer); - p->setOption("kde-backend",TQString::number(ID)); - TQString s = m_buttons->selected()->text(); - s.replace(TQRegExp("&(?=\\w)"), TQString::tqfromLatin1("")); - p->setOption("kde-backend-description",s); - setNextPage((m_map.contains(ID) ? m_map[ID] : KMWizard::Error)); -} - -void KMWBackend::addBackend( int ID, bool on, int nextpage ) -{ - switch ( ID ) - { - case KMWizard::Local: - addBackend( ID, i18n("&Local printer (parallel, serial, USB)"), on, - i18n( "<qt><p>Locally-connected printer</p>" - "<p>Use this for a printer connected " - "to the computer via a parallel, serial or USB port.</p></qt>" ), - nextpage ); - break; - case KMWizard::SMB: - addBackend( ID, i18n("&SMB shared printer (Windows)"), on, - i18n( "<qt><p>Shared Windows printer</p>" - "<p>Use this for a printer installed " - "on a Windows server and shared on the network using the SMB " - "protocol (samba).</p></qt>" ), - nextpage ); - break; - case KMWizard::LPD: - addBackend( ID, i18n("&Remote LPD queue"), on, - i18n( "<qt><p>Print queue on a remote LPD server</p>" - "<p>Use this for a print queue " - "existing on a remote machine running a LPD print server.</p></qt>" ), - nextpage ); - break; - case KMWizard::TCP: - addBackend( ID, i18n("Ne&twork printer (TCP)"), on, - i18n( "<qt><p>Network TCP printer</p>" - "<p>Use this for a network-enabled printer " - "using TCP (usually on port 9100) as communication protocol. Most " - "network printers can use this mode.</p></qt>" ), - nextpage ); - break; - case -1: - addBackend( ID, TQString::null, on, TQString::null, nextpage ); - break; - default: - kdError( 500 ) << "Non standard wizard page ID: " << ID << endl; - } -} - -void KMWBackend::addBackend(int ID, const TQString& txt, bool on, const TQString& whatsThis, int nextpage) -{ - if (ID == -1) - { - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - m_layout->insertWidget(m_count, sep); - } - else - { - KRadioButton *btn = new KRadioButton(txt, this); - btn->setEnabled(on); - if ( !whatsThis.isEmpty() ) - TQWhatsThis::add( btn, whatsThis ); - m_buttons->insert(btn, ID); - m_map[ID] = (nextpage == -1 ? ID : nextpage); // use nextpage if specified, default to ID - m_layout->insertWidget(m_count, btn); - } - m_count++; -} - -void KMWBackend::enableBackend(int ID, bool on) -{ - TQButton *btn = static_cast<TQButton*>(m_buttons->find(ID)); - if (btn) - btn->setEnabled(on); -} diff --git a/kdeprint/management/kmwbackend.h b/kdeprint/management/kmwbackend.h deleted file mode 100644 index 223123b4f..000000000 --- a/kdeprint/management/kmwbackend.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWBACKEND_H -#define KMWBACKEND_H - -#include "kmwizardpage.h" -#include <kdelibs_export.h> -#include <tqmap.h> - -class TQButtonGroup; -class TQVBoxLayout; - -class KDEPRINT_EXPORT KMWBackend : public KMWizardPage -{ -public: - KMWBackend(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - - void addBackend(int ID, const TQString& txt, bool on = true, const TQString& whatsThis = TQString::null, int nextpage = -1); - void addBackend(int ID = -1, bool on = true, int nextpage = -1); - void enableBackend(int ID, bool on = true); - -private: - TQButtonGroup *m_buttons; - TQVBoxLayout *m_layout; - // keep a map between button ID and the real next page to switch to. This enables - // to have different backends switching to the same page (like backends requiring - // a password). If the next page is not given when adding the backend, the ID is - // used by default. - TQMap<int,int> m_map; - int m_count; -}; - -#endif diff --git a/kdeprint/management/kmwclass.cpp b/kdeprint/management/kmwclass.cpp deleted file mode 100644 index a87388a6f..000000000 --- a/kdeprint/management/kmwclass.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwclass.h" -#include "kmwizard.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmprinter.h" - -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqtoolbutton.h> -#include <klistbox.h> -#include <klocale.h> -#include <kiconloader.h> - -KMWClass::KMWClass(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Class; - m_title = i18n("Class Composition"); - m_nextpage = KMWizard::Name; - - m_list1 = new KListBox(this); - m_list1->setSelectionMode(TQListBox::Extended); - m_list2 = new KListBox(this); - m_list2->setSelectionMode(TQListBox::Extended); - - TQToolButton *add = new TQToolButton(this); - TQToolButton *remove = new TQToolButton(this); - add->setIconSet(BarIcon("forward")); - remove->setIconSet(BarIcon("back")); - connect(add,TQT_SIGNAL(clicked()),TQT_SLOT(slotAdd())); - connect(remove,TQT_SIGNAL(clicked()),TQT_SLOT(slotRemove())); - - TQLabel *l1 = new TQLabel(i18n("Available printers:"), this); - TQLabel *l2 = new TQLabel(i18n("Class printers:"), this); - - TQHBoxLayout *lay1 = new TQHBoxLayout(this, 0, 15); - TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 20); - TQVBoxLayout *lay3 = new TQVBoxLayout(0, 0, 0), *lay4 = new TQVBoxLayout(0, 0, 0); - lay1->addLayout(lay3, 1); - lay1->addLayout(lay2, 0); - lay1->addLayout(lay4, 1); - lay3->addWidget(l1, 0); - lay3->addWidget(m_list1, 1); - lay2->addStretch(1); - lay2->addWidget(add, 0); - lay2->addWidget(remove, 0); - lay2->addStretch(1); - lay4->addWidget(l2, 0); - lay4->addWidget(m_list2, 1); -} - -KMWClass::~KMWClass() -{ -} - -bool KMWClass::isValid(TQString& msg) -{ - if (m_list2->count() == 0) - { - msg = i18n("You must select at least one printer."); - return false; - } - return true; -} - -void KMWClass::initPrinter(KMPrinter *p) -{ - TQStringList members = p->members(); - KMManager *mgr = KMFactory::self()->manager(); - - // first load available printers - TQPtrList<KMPrinter> *list = mgr->printerList(false); - m_list1->clear(); - if (list) - { - TQPtrListIterator<KMPrinter> it(*list); - for (;it.current();++it) - if (it.current()->instanceName().isEmpty() && !it.current()->isClass(true) && !it.current()->isSpecial() && !members.contains(it.current()->name())) - m_list1->insertItem(SmallIcon(it.current()->pixmap()), it.current()->name()); - m_list1->sort(); - } - - // set class printers - m_list2->clear(); - for (TQStringList::ConstIterator it=members.begin(); it!=members.end(); ++it) - { - KMPrinter *pr = mgr->findPrinter(*it); - if (pr) m_list2->insertItem(SmallIcon(pr->pixmap()), *it); - } - m_list2->sort(); -} - -void KMWClass::updatePrinter(KMPrinter *p) -{ - TQStringList members; - for (uint i=0; i<m_list2->count(); i++) - members.append(m_list2->item(i)->text()); - p->setMembers(members); -} - -void KMWClass::slotAdd() -{ - for (uint i=0;i<m_list1->count();i++) - if (m_list1->isSelected(i)) - { - m_list2->insertItem(*(m_list1->pixmap(i)), m_list1->text(i)); - m_list1->removeItem(i--); - } - m_list2->sort(); -} - -void KMWClass::slotRemove() -{ - for (uint i=0;i<m_list2->count();i++) - if (m_list2->isSelected(i)) - { - m_list1->insertItem(*(m_list2->pixmap(i)), m_list2->text(i)); - m_list2->removeItem(i--); - } - m_list1->sort(); -} -#include "kmwclass.moc" diff --git a/kdeprint/management/kmwclass.h b/kdeprint/management/kmwclass.h deleted file mode 100644 index c9b63befb..000000000 --- a/kdeprint/management/kmwclass.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWCLASS_H -#define KMWCLASS_H - -#include "kmwizardpage.h" - -class KListBox; - -class KMWClass : public KMWizardPage -{ - Q_OBJECT -public: - KMWClass(TQWidget *parent = 0, const char *name = 0); - ~KMWClass(); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -protected slots: - void slotAdd(); - void slotRemove(); - -private: - KListBox *m_list1, *m_list2; -}; - -#endif diff --git a/kdeprint/management/kmwdriver.cpp b/kdeprint/management/kmwdriver.cpp deleted file mode 100644 index 58793c192..000000000 --- a/kdeprint/management/kmwdriver.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwdriver.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "kmdriverdbwidget.h" -#include "kmdriverdb.h" - -#include <tqlayout.h> -#include <klocale.h> - -KMWDriver::KMWDriver(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Driver; - m_title = i18n("Printer Model Selection"); - m_nextpage = KMWizard::DriverTest; - - m_widget = new KMDriverDbWidget(this); - - TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 0); - lay1->addWidget(m_widget); -} - -void KMWDriver::initPrinter(KMPrinter *p) -{ - m_widget->init(); - if (p) - { - TQString autoDetect = p->option( "kde-autodetect" ); - if ( !autoDetect.isEmpty() ) - { - // use auto-detection info instead: split the string - // into make/model pair at the first space character - int p = autoDetect.find( ' ' ); - if ( p != -1 ) - { - TQString manu = autoDetect.left( p ), model = autoDetect.mid( p+1 ); - KMDBEntryList *l = KMDriverDB::self()->findPnpEntry( manu, model ); - if ( l && l->count() > 0 ) - { - m_widget->setDriver( l->getFirst()->manufacturer, l->getFirst()->model ); - return; - } - } - } - m_widget->setDriver(p->manufacturer(),p->model()); - } -} - -void KMWDriver::updatePrinter(KMPrinter *p) -{ - if (p) - { - p->setManufacturer(TQString::null); - p->setModel(TQString::null); - p->setDbEntry(0); - p->setDriverInfo(TQString::null); - p->setOption("kde-driver",TQString::null); - setNextPage(KMWizard::DriverTest); - if (m_widget->isRaw()) - { - p->setDriverInfo(i18n("Raw printer")); - p->setOption("kde-driver","raw"); - } - else - { - p->setManufacturer(m_widget->manufacturer()); - p->setModel(m_widget->model()); - if (m_widget->isExternal()) - { - p->setDriverInfo(m_widget->description()); - p->setOption("kde-driver",m_widget->driverFile()); - } - else - { - KMDBEntryList *drvs = m_widget->drivers(); - if (drvs->count() == 1) - { - p->setDbEntry(drvs->getFirst()); - p->setDriverInfo(drvs->getFirst()->description); - } - else - setNextPage(KMWizard::DriverSelect); - } - } - } -} - -bool KMWDriver::isValid(TQString& msg) -{ - if (m_widget->isRaw() || m_widget->isExternal() || m_widget->drivers()) - return true; - else - { - msg = i18n("Internal error: unable to locate the driver."); - return false; - } -} diff --git a/kdeprint/management/kmwdriver.h b/kdeprint/management/kmwdriver.h deleted file mode 100644 index 9eef02069..000000000 --- a/kdeprint/management/kmwdriver.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWDRIVER_H -#define KMWDRIVER_H - -#include "kmwizardpage.h" - -class KMDriverDbWidget; - -class KMWDriver : public KMWizardPage -{ -public: - KMWDriver(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - void initPrinter(KMPrinter*); - -private: - KMDriverDbWidget *m_widget; -}; - -#endif diff --git a/kdeprint/management/kmwdriverselect.cpp b/kdeprint/management/kmwdriverselect.cpp deleted file mode 100644 index e3d253660..000000000 --- a/kdeprint/management/kmwdriverselect.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwdriverselect.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "kmdbentry.h" -#include "kmdriverdb.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <kpushbutton.h> -#include <klistbox.h> -#include <klocale.h> -#include <kmessagebox.h> - -KMWDriverSelect::KMWDriverSelect(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::DriverSelect; - m_title = i18n("Driver Selection"); - m_nextpage = KMWizard::DriverTest; - m_entries = NULL; - - m_list = new KListBox(this); - TQLabel *l1 = new TQLabel(this); - l1->setText(i18n("<p>Several drivers have been detected for this model. Select the driver " - "you want to use. You will have the opportunity to test it as well as to " - "change it if necessary.</p>")); - m_drivercomment = new KPushButton(i18n("Driver Information"), this); - connect(m_drivercomment, TQT_SIGNAL(clicked()), TQT_SLOT(slotDriverComment())); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); - main_->addWidget(l1,0); - main_->addWidget(m_list,1); - TQHBoxLayout *lay0 = new TQHBoxLayout(0, 0, 0); - main_->addLayout(lay0,0); - lay0->addStretch(1); - lay0->addWidget(m_drivercomment); -} - -bool KMWDriverSelect::isValid(TQString& msg) -{ - if (m_list->currentItem() == -1) - { - msg = i18n("You must select a driver."); - return false; - } - return true; -} - -void KMWDriverSelect::initPrinter(KMPrinter *p) -{ - m_entries = KMDriverDB::self()->findEntry(p->manufacturer(),p->model()); - m_list->clear(); - if (m_entries) - { - KMDBEntryListIterator it(*m_entries); - int recomm(0); - for (;it.current();++it) - { - TQString s(it.current()->description); - if (it.current()->recommended) - { - recomm = m_list->count(); - s.append(i18n(" [recommended]")); - } - m_list->insertItem(s); - } - if (m_entries->count() > 0) - m_list->setSelected(recomm, true); - } -} - -void KMWDriverSelect::updatePrinter(KMPrinter *p) -{ - int index = m_list->currentItem(); - if (m_entries && index >= 0 && index < (int)(m_entries->count())) - { - KMDBEntry *entry = m_entries->tqat(index); - p->setDbEntry(entry); - p->setDriverInfo(entry->description); - } - else - { - p->setDbEntry(0); - p->setDriverInfo(TQString::null); - } -} - -void KMWDriverSelect::slotDriverComment() -{ - int index = m_list->currentItem(); - if (m_entries && index >=0 && index < (int)(m_entries->count()) && !m_entries->tqat(index)->drivercomment.isEmpty()) - KMessageBox::information(this, m_entries->tqat(index)->drivercomment, TQString::null, TQString::null, KMessageBox::AllowLink); - else - KMessageBox::error(this, i18n("No information about the selected driver.")); -} - -#include "kmwdriverselect.moc" diff --git a/kdeprint/management/kmwdriverselect.h b/kdeprint/management/kmwdriverselect.h deleted file mode 100644 index 464a78239..000000000 --- a/kdeprint/management/kmwdriverselect.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWDRIVERSELECT_H -#define KMWDRIVERSELECT_H - -#include "kmwizardpage.h" -#include "kmdbentry.h" - -class KListBox; -class TQPushButton; - -class KMWDriverSelect : public KMWizardPage -{ - Q_OBJECT -public: - KMWDriverSelect(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -protected slots: - void slotDriverComment(); - -private: - KListBox *m_list; - KMDBEntryList *m_entries; - TQPushButton *m_drivercomment; -}; - -#endif diff --git a/kdeprint/management/kmwdrivertest.cpp b/kdeprint/management/kmwdrivertest.cpp deleted file mode 100644 index 545d3b94d..000000000 --- a/kdeprint/management/kmwdrivertest.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwdrivertest.h" -#include "kmprinter.h" -#include "kmwizard.h" -#include "driver.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmdriverdialog.h" - -#include <tqlabel.h> -#include <kpushbutton.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kapplication.h> -#include <kmessagebox.h> -#include <kguiitem.h> -#include <kio/netaccess.h> - -KMWDriverTest::KMWDriverTest(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::DriverTest; - m_title = i18n("Printer Test"); - m_nextpage = KMWizard::Name; - m_needsinitonback = true; - m_driver = 0; - m_printer = 0; - - m_manufacturer = new TQLabel(this); - m_model = new TQLabel(this); - m_driverinfo = new TQLabel(this); - m_driverinfo->setTextFormat(TQt::RichText); - TQLabel *l1 = new TQLabel(i18n("<b>Manufacturer:</b>"), this); - TQLabel *l2 = new TQLabel(i18n("<b>Model:</b>"), this); - TQLabel *l3 = new TQLabel(i18n("<b>Description:</b>"), this); - - m_test = new KPushButton(KGuiItem(i18n("&Test"), "tdeprint_testprinter"), this); - m_settings = new KPushButton(KGuiItem(i18n("&Settings"), "configure"), this); - - TQLabel *l0 = new TQLabel(this); - l0->setText(i18n("<p>Now you can test the printer before finishing installation. " - "Use the <b>Settings</b> button to configure the printer driver and " - "the <b>Test</b> button to test your configuration. Use the <b>Back</b> " - "button to change the driver (your current configuration will be discarded).</p>")); - - TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 15); - TQGridLayout *lay2 = new TQGridLayout(0, 3, 3, 0, 0); - TQHBoxLayout *lay3 = new TQHBoxLayout(0, 0, 10); - lay1->addWidget(l0,0); - lay1->addLayout(TQT_TQLAYOUT(lay2),0); - lay1->addLayout(lay3,0); - lay1->addStretch(1); - lay2->setColStretch(2,1); - lay2->addColSpacing(1,10); - lay2->addWidget(l1,0,0); - lay2->addWidget(l2,1,0); - lay2->addWidget(l3,2,0,Qt::AlignLeft|Qt::AlignTop); - lay2->addWidget(m_manufacturer,0,2); - lay2->addWidget(m_model,1,2); - lay2->addWidget(m_driverinfo,2,2); - lay3->addWidget(m_test,0); - lay3->addWidget(m_settings,0); - lay3->addStretch(1); - - connect(m_test,TQT_SIGNAL(clicked()),TQT_SLOT(slotTest())); - connect(m_settings,TQT_SIGNAL(clicked()),TQT_SLOT(slotSettings())); -} - -KMWDriverTest::~KMWDriverTest() -{ - delete m_driver; -} - -void KMWDriverTest::initPrinter(KMPrinter *p) -{ - m_manufacturer->setText(p->manufacturer()); - m_model->setText(p->model()); - m_driverinfo->setText(p->driverInfo()); - m_printer = p; - - delete m_driver; - m_driver = 0; - - TQString drfile = p->option("kde-driver"); - bool checkDriver(true); - if (!drfile.isEmpty() && drfile != "raw") - { - m_driver = KMFactory::self()->manager()->loadFileDriver(drfile); - /* remove the temp file if it has been downloaded */ - KIO::NetAccess::removeTempFile( drfile ); - } - else if (p->dbEntry() != NULL) - m_driver = KMFactory::self()->manager()->loadDbDriver(p->dbEntry()); - else - checkDriver = false; - - if (checkDriver && !m_driver) - { - KMessageBox::error(this, i18n("<qt>Unable to load the requested driver:<p>%1</p></qt>").arg(KMManager::self()->errorMsg())); - KMManager::self()->setErrorMsg(TQString::null); - } - m_settings->setEnabled((m_driver != 0)); -} - -void KMWDriverTest::updatePrinter(KMPrinter *p) -{ - // Give the DrMain structure to the driver and don't care about it anymore. - // It will be destroyed either when giving another structure, or when the - // printer object will be destroyed. - p->setDriver(m_driver); - m_driver = 0; -} - -void KMWDriverTest::slotTest() -{ - if (!m_printer) return; - - TQString name = "tmpprinter_"+KApplication::randomString(8); - // save printer name (can be non empty when modifying a printer) - TQString oldname = m_printer->name(); - - m_printer->setName(name); - m_printer->setPrinterName(name); - m_printer->setDriver(m_driver); - if (KMFactory::self()->manager()->createPrinter(m_printer)) - { - if (KMFactory::self()->manager()->testPrinter(m_printer)) - KMessageBox::information(this,"<qt>"+i18n("Test page successfully sent to printer. Wait until printing is complete, then click the OK button.")); - else - KMessageBox::error(this,"<qt>"+i18n("Unable to test printer: ")+KMFactory::self()->manager()->errorMsg()+"</qt>"); - if (!KMFactory::self()->manager()->removePrinter(m_printer)) - KMessageBox::error(this,i18n("Unable to remove temporary printer.")); - } - else - KMessageBox::error(this,i18n("Unable to create temporary printer.")); - - // restoring old name - m_printer->setName(oldname); - m_printer->setPrinterName(oldname); - - m_driver = m_printer->takeDriver(); -} - -void KMWDriverTest::slotSettings() -{ - if (m_driver) - { - KMDriverDialog dlg(this); - dlg.setDriver(m_driver); - dlg.showButtonCancel(false); // only OK button - dlg.exec(); - } -} -#include "kmwdrivertest.moc" diff --git a/kdeprint/management/kmwdrivertest.h b/kdeprint/management/kmwdrivertest.h deleted file mode 100644 index 5c1aefaee..000000000 --- a/kdeprint/management/kmwdrivertest.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWDRIVERTEST_H -#define KMWDRIVERTEST_H - -#include "kmwizardpage.h" - -class TQLabel; -class TQPushButton; -class DrMain; - -class KMWDriverTest : public KMWizardPage -{ - Q_OBJECT -public: - KMWDriverTest(TQWidget *parent = 0, const char *name = 0); - ~KMWDriverTest(); - - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -protected slots: - void slotTest(); - void slotSettings(); - -private: - TQLabel *m_manufacturer; - TQLabel *m_model; - TQLabel *m_driverinfo; - TQPushButton *m_test; - TQPushButton *m_settings; - DrMain *m_driver; - KMPrinter *m_printer; -}; - -#endif diff --git a/kdeprint/management/kmwend.cpp b/kdeprint/management/kmwend.cpp deleted file mode 100644 index 54294fb13..000000000 --- a/kdeprint/management/kmwend.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwend.h" -#include "kmprinter.h" -#include "kmwizard.h" -#include "util.h" - -#include <tqtextview.h> -#include <klocale.h> -#include <tqlayout.h> - -KMWEnd::KMWEnd(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::End; - m_title = i18n("Confirmation"); - m_nextpage = KMWizard::Error; - - m_view = new TQTextView(this); - - TQVBoxLayout *lay = new TQVBoxLayout(this, 0, 0); - lay->addWidget(m_view,1); -} - -void KMWEnd::initPrinter(KMPrinter *p) -{ - TQString txt; - TQString s(TQString::tqfromLatin1("<li><u>%1</u>: %2</li>")); - int ID = p->option("kde-backend").toInt(); - - // general information - txt.append(TQString::tqfromLatin1("<b>%1</b><ul type=circle>").arg(i18n("General"))); - txt.append(s.arg(i18n("Type")).arg(p->option("kde-backend-description"))); - txt.append(s.arg(i18n("Name")).arg(p->name())); - txt.append(s.arg(i18n("Location")).arg(p->location())); - txt.append(s.arg(i18n("Description")).arg(p->description())); - txt.append("</ul><br>"); - - if (ID == KMWizard::Class) - { - // class members - txt.append(TQString::tqfromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Members"))); - TQStringList m(p->members()); - TQString s1(TQString::tqfromLatin1("<li>%1</li>")); - for (TQStringList::ConstIterator it=m.begin(); it!=m.end(); ++it) - txt.append(s1.arg(*it)); - txt.append("</ul><br>"); - } - else - { - // backend information - txt.append(TQString::tqfromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Backend"))); - KURL url ( p->device() ); - switch (ID) - { - case KMWizard::Local: - txt.append(s.arg(i18n("Device")).arg(url.path())); - break; - case KMWizard::TCP: - txt.append(s.arg(i18n("Printer IP")).arg(url.host())); - txt.append(s.arg(i18n("Port")).arg(url.port())); - break; - case KMWizard::LPD: - txt.append(s.arg(i18n("Host")).arg(url.host())); - txt.append(s.arg(i18n("Queue")).arg(url.path().right(url.path().length()-1))); - break; - case KMWizard::File: - txt.append(s.arg(i18n("File")).arg(url.path())); - break; - case KMWizard::IPP: - txt.append(s.arg(i18n("Host")).arg(url.host())); - txt.append(s.arg(i18n("Port")).arg(url.port())); - txt.append(s.arg(i18n("Printer")).arg(url.path().right(url.path().length()-1))); - if (url.hasUser()) txt.append(s.arg(i18n("Account")).arg(url.user())); - break; - default: - // double decoding in case the printer name contains chars like '#' that are - // not decoded by "prettyURL". - txt.append(s.arg(i18n("URI")).arg(KURL( p->device()).prettyURL())); - break; - } - txt.append("</ul><br>"); - - if (p->option("kde-driver") == "raw" || p->driver()) - { - // driver information - txt.append(TQString::tqfromLatin1("<b>%1</b><ul type=circle>").arg(i18n("Driver"))); - if (p->option("kde-driver") == "raw") - txt.append(s.arg(i18n("Type")).arg(i18n("Raw printer"))); - else - { - txt.append(s.arg(i18n("Type")).arg((p->dbEntry() ? i18n("DB driver") : i18n("External driver")))); - txt.append(s.arg(i18n("Manufacturer")).arg(p->manufacturer())); - txt.append(s.arg(i18n("Model")).arg(p->model())); - txt.append(s.arg(i18n("Description")).arg(p->driverInfo())); - } - txt.append("</ul><br>"); - } - } - - m_view->setText(txt); -} diff --git a/kdeprint/management/kmwend.h b/kdeprint/management/kmwend.h deleted file mode 100644 index 626eedf96..000000000 --- a/kdeprint/management/kmwend.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWEND_H -#define KMWEND_H - -#include "kmwizardpage.h" - -class TQTextView; - -class KMWEnd : public KMWizardPage -{ -public: - KMWEnd(TQWidget *parent = 0, const char *name = 0); - - void initPrinter(KMPrinter*); - -private: - TQTextView *m_view; -}; - -#endif diff --git a/kdeprint/management/kmwfile.cpp b/kdeprint/management/kmwfile.cpp deleted file mode 100644 index 32da27c03..000000000 --- a/kdeprint/management/kmwfile.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwfile.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqlabel.h> -#include <tqlayout.h> - -#include <kurlrequester.h> -#include <klocale.h> -#include <kfiledialog.h> - -KMWFile::KMWFile(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::File; - m_title = i18n("File Selection"); - m_nextpage = KMWizard::Driver; - - m_url = new KURLRequester(this); - m_url->setMode((KFile::Mode)(KFile::File|KFile::LocalOnly)); - TQLabel *l1 = new TQLabel(this); - l1->setText(i18n("<p>The printing will be redirected to a file. Enter here the path " - "of the file you want to use for redirection. Use an absolute path or " - "the browse button for graphical selection.</p>")); - TQLabel *l2 = new TQLabel(i18n("Print to file:"), this); - - TQVBoxLayout *lay1 = new TQVBoxLayout(this, 0, 30); - TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 5); - lay1->addWidget(l1); - lay1->addLayout(lay2); - lay1->addStretch(1); - lay2->addWidget(l2); - lay2->addWidget(m_url); -} - -bool KMWFile::isValid(TQString& msg) -{ - TQFileInfo fi(m_url->url()); - if (fi.fileName().isEmpty()) - { - msg = i18n("Empty file name."); - return false; - } - - if (!fi.dir().exists()) - { - msg = i18n("Directory does not exist."); - return false; - } - - return true; -} - -void KMWFile::updatePrinter(KMPrinter *p) -{ - TQString dev = TQString::tqfromLatin1("file:%1").arg(m_url->url()); - p->setDevice(dev); -} diff --git a/kdeprint/management/kmwfile.h b/kdeprint/management/kmwfile.h deleted file mode 100644 index 40e2e2171..000000000 --- a/kdeprint/management/kmwfile.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWFILE_H -#define KMWFILE_H - -#include "kmwizardpage.h" - -class KURLRequester; - -class KMWFile : public KMWizardPage -{ -public: - KMWFile(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - -private: - KURLRequester *m_url; -}; - -#endif diff --git a/kdeprint/management/kmwinfobase.cpp b/kdeprint/management/kmwinfobase.cpp deleted file mode 100644 index 993576334..000000000 --- a/kdeprint/management/kmwinfobase.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwinfobase.h" - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqlayout.h> - -KMWInfoBase::KMWInfoBase(int n, TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_labels.setAutoDelete(false); - m_edits.setAutoDelete(false); - - m_nlines = n; - TQGridLayout *lay1 = new TQGridLayout(this, m_nlines+3, 2, 0, 10); - lay1->addRowSpacing(1,10); - lay1->setRowStretch(m_nlines+2,1); - lay1->setColStretch(1,1); - - m_info = new TQLabel(this); - m_info->setTextFormat(TQt::RichText); - lay1->addMultiCellWidget(m_info,0,0,0,1); - - for (int i=0;i<m_nlines;i++) - { - m_labels.append(new TQLabel(this)); - m_edits.append(new TQLineEdit(this)); - lay1->addWidget(m_labels.last(),i+2,0); - lay1->addWidget(m_edits.last(),i+2,1); - } -} - -void KMWInfoBase::setInfo(const TQString& s) -{ - m_info->setText(s); -} - -void KMWInfoBase::setLabel(int i, const TQString& s) -{ - if (i >= 0 && i < m_nlines) - m_labels.tqat(i)->setText(s); -} - -void KMWInfoBase::setText(int i, const TQString& s) -{ - if (i >= 0 && i < m_nlines) - m_edits.tqat(i)->setText(s); -} - -TQString KMWInfoBase::text(int i) -{ - if (i >= 0 && i < m_nlines) - return m_edits.tqat(i)->text(); - return TQString::null; -} - -void KMWInfoBase::setCurrent(int i) -{ - if (i >= 0 && i < m_nlines) - { - m_edits.tqat(i)->selectAll(); - m_edits.tqat(i)->setFocus(); - } -} - -TQLineEdit* KMWInfoBase::lineEdit( int i ) -{ - if ( i >= 0 && i < m_nlines ) - return m_edits.tqat( i ); - else - return NULL; -} diff --git a/kdeprint/management/kmwinfobase.h b/kdeprint/management/kmwinfobase.h deleted file mode 100644 index 9a2b6464e..000000000 --- a/kdeprint/management/kmwinfobase.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWINFOBASE_H -#define KMWINFOBASE_H - -#include "kmwizardpage.h" -#include <tqptrlist.h> - -class TQLabel; -class TQLineEdit; - -class KDEPRINT_EXPORT KMWInfoBase : public KMWizardPage -{ -public: - KMWInfoBase(int n = 1, TQWidget *parent = 0, const char *name = 0); - - void setInfo(const TQString&); - void setLabel(int, const TQString&); - void setText(int, const TQString&); - void setCurrent(int); - - TQString text(int); - -protected: - TQLineEdit* lineEdit( int ); - -private: - TQPtrList<TQLabel> m_labels; - TQPtrList<TQLineEdit> m_edits; - TQLabel *m_info; - int m_nlines; -}; - -#endif diff --git a/kdeprint/management/kmwinfopage.cpp b/kdeprint/management/kmwinfopage.cpp deleted file mode 100644 index 1e9652e93..000000000 --- a/kdeprint/management/kmwinfopage.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwinfopage.h" -#include "kmwizard.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kactivelabel.h> - -KMWInfoPage::KMWInfoPage(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Start; - m_title = i18n("Introduction"); - m_nextpage = KMWizard::Backend; - - //TQLabel *m_label = new TQLabel(this); - KActiveLabel *m_label = new KActiveLabel(this); - m_label->setText(i18n("<p>Welcome,</p><br>" - "<p>This wizard will help to install a new printer on your computer. " - "It will guide you through the various steps of the process of installing " - "and configuring a printer for your printing system. At each step, you " - "can always go back using the <b>Back</b> button.</p><br>" - "<p>We hope you'll enjoy this tool!</p><br>" - "<p align=right><a href=\"http://printing.kde.org\"><i>" - "The KDE printing team</i></a>.</p>")); - - TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 0); - main_->addWidget(m_label); -} diff --git a/kdeprint/management/kmwinfopage.h b/kdeprint/management/kmwinfopage.h deleted file mode 100644 index 346d29401..000000000 --- a/kdeprint/management/kmwinfopage.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWINFOPAGE_H -#define KMWINFOPAGE_H - -#include "kmwizardpage.h" - -class KMWInfoPage : public KMWizardPage -{ -public: - KMWInfoPage(TQWidget *parent = 0, const char *name = 0); -}; - -#endif diff --git a/kdeprint/management/kmwizard.cpp b/kdeprint/management/kmwizard.cpp deleted file mode 100644 index 5dc915572..000000000 --- a/kdeprint/management/kmwizard.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwizard.h" -#include "kmwizardpage.h" -#include "kmprinter.h" -#include "kmfactory.h" -#include "kmuimanager.h" - -#include <kpushbutton.h> -#include <tqlabel.h> -#include <tqwidgetstack.h> -#include <kmessagebox.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kdebug.h> -#include <kseparator.h> -#include <kapplication.h> -#include <kstdguiitem.h> - -#include "kmwinfopage.h" -#include "kmwpassword.h" -#include "kmwbackend.h" -#include "kmwsocket.h" -#include "kmwdriver.h" -#include "kmwdriverselect.h" -#include "kmwdrivertest.h" -#include "kmwname.h" -#include "kmwend.h" -#include "kmwclass.h" -#include "kmwlpd.h" -#include "kmwfile.h" -#include "kmwsmb.h" -#include "kmwlocal.h" -#include "sidepixmap.h" - -KMWizard::KMWizard(TQWidget *parent, const char *name) -: TQDialog(parent,name,true) -{ - m_start = KMWizard::Start; - m_end = KMWizard::End; - m_inclusive = true; - m_printer = new KMPrinter(); - - m_pagepool.setAutoDelete(false); - - m_stack = new TQWidgetStack(this); - m_next = new KPushButton(i18n("&Next >"), this); - m_next->setDefault(true); - m_prev = new KPushButton(i18n("< &Back"), this); - TQPushButton *m_cancel = new KPushButton(KStdGuiItem::cancel(), this); - m_title = new TQLabel(this); - TQFont f(m_title->font()); - f.setBold(true); - m_title->setFont(f); - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - sep->setFixedHeight(5); - KSeparator* sep2 = new KSeparator( KSeparator::HLine, this); - TQPushButton *m_help = new KPushButton(KStdGuiItem::help(), this); - - connect(m_cancel,TQT_SIGNAL(clicked()),TQT_SLOT(reject())); - connect(m_next,TQT_SIGNAL(clicked()),TQT_SLOT(slotNext())); - connect(m_prev,TQT_SIGNAL(clicked()),TQT_SLOT(slotPrev())); - connect(m_help, TQT_SIGNAL(clicked()), TQT_SLOT(slotHelp())); - - m_side = new SidePixmap(this); - if (!m_side->isValid()) - { - delete m_side; - m_side = 0; - } - - // layout - TQVBoxLayout *main0_ = new TQVBoxLayout(this, 10, 10); - TQVBoxLayout *main_ = new TQVBoxLayout(0, 0, 0); - TQHBoxLayout *main1_ = new TQHBoxLayout(0, 0, 10); - TQHBoxLayout *btn_ = new TQHBoxLayout(0, 0, 10); - main0_->addLayout(main1_); - if (m_side) - main1_->addWidget(m_side); - main1_->addLayout(main_); - main_->addWidget(m_title); - main_->addWidget(sep); - main_->addSpacing(10); - main_->addWidget(m_stack,1); - main0_->addWidget(sep2); - main0_->addLayout(btn_); - btn_->addWidget(m_help); - btn_->addStretch(1); - btn_->addWidget(m_prev); - btn_->addWidget(m_next); - btn_->addWidget(m_cancel); - - // create standard pages - addPage(new KMWInfoPage(this)); - m_backend = new KMWBackend(this); - addPage(m_backend); - addPage(new KMWPassword(this)); - addPage(new KMWSocket(this)); - addPage(new KMWDriver(this)); - addPage(new KMWDriverSelect(this)); - addPage(new KMWDriverTest(this)); - addPage(new KMWName(this)); - addPage(new KMWEnd(this)); - addPage(new KMWClass(this)); - addPage(new KMWLpd(this)); - addPage(new KMWFile(this)); - addPage(new KMWSmb(this)); - addPage(new KMWLocal(this)); - - // add other pages - KMFactory::self()->uiManager()->setupWizard(this); - - setCurrentPage(m_start,false); - setCaption(i18n("Add Printer Wizard")); - resize(400,350); -} - -KMWizard::~KMWizard() -{ - delete m_printer; -} - -void KMWizard::addPage(KMWizardPage *page) -{ - m_stack->addWidget(page,page->id()); - m_pagepool.insert(page->id(),page); -} - -void KMWizard::setPrinter(KMPrinter *p) -{ - if (p) - { - m_printer->copy(*p); - KMWizardPage *page = (KMWizardPage*)m_stack->visibleWidget(); - if (page) - page->initPrinter(m_printer); - } -} - -void KMWizard::configure(int start, int end, bool inclusive) -{ - m_start = start; - m_end = end; - m_inclusive = inclusive; - m_pagestack.clear(); - - // disable class if not starting from beginning - m_backend->enableBackend(KMWizard::Class,(m_start == KMWizard::Start)); - setCaption((m_start == KMWizard::Start ? i18n("Add Printer Wizard") : i18n("Modify Printer"))); - - if (m_side) - { - if (start == KMWizard::Start && end == KMWizard::End) - m_side->show(); - else - m_side->hide(); - } - - setCurrentPage(m_start,false); -} - -void KMWizard::setNextPage(int page, int next) -{ - KMWizardPage *p = m_pagepool.find(page); - if (p) - p->setNextPage(next); -} - -void KMWizard::setCurrentPage(int ID, bool back) -{ - KMWizardPage *page = m_pagepool.find(ID); - if (!page) - { - KMessageBox::error(this,i18n("Unable to find the requested page."),i18n("Add Printer Wizard")); - return; - } - - // add current page to stack (only if going backward) - if (!back) m_pagestack.push(ID); - - // raise page + initialize - m_stack->raiseWidget(page); - m_title->setText(page->title()); - if (!back || page->needsInitOnBack()) page->initPrinter(m_printer); - - // update buttons - if (ID == m_start) m_prev->setEnabled(false); - else m_prev->setEnabled(true); - if ((m_inclusive && ID == m_end) || (!m_inclusive && page->nextPage() == m_end)) - m_next->setText(i18n("&Finish")); - else - m_next->setText(i18n("&Next >")); -} - -void KMWizard::slotPrev() -{ - // current page is on top of stack -> pop it and retrieve new top of stack - m_pagestack.pop(); - int ID = m_pagestack.top(); - setCurrentPage(ID,true); -} - -void KMWizard::slotNext() -{ - KMWizardPage *page = (KMWizardPage*)m_stack->visibleWidget(); - if (page) - { - TQString msg; - if (!page->isValid(msg)) - { - if (!msg.isEmpty()) - KMessageBox::error(this,msg.prepend("<qt>").append("</qt>"),page->title()); - } - else - { - page->updatePrinter(m_printer); - if (m_next->text() == i18n("&Finish")) - accept(); - else - { - int ID = page->nextPage(); - setCurrentPage(ID,false); - } - } - } -} - -void KMWizard::slotHelp() -{ - kapp->invokeHelp(TQString::null, "tdeprint"); -} - -void KMWizard::enableWizard() -{ - m_next->setEnabled( true ); - m_prev->setEnabled( m_pagestack.top() != m_start ); -} - -void KMWizard::disableWizard() -{ - m_next->setEnabled( false ); - m_prev->setEnabled( false ); -} - -#include "kmwizard.moc" diff --git a/kdeprint/management/kmwizard.h b/kdeprint/management/kmwizard.h deleted file mode 100644 index 5a2dcb6ea..000000000 --- a/kdeprint/management/kmwizard.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWIZARD_H -#define KMWIZARD_H - -#include <tqdialog.h> -#include <tqintdict.h> -#include <tqvaluestack.h> - -#include <kdelibs_export.h> - -class TQWidgetStack; -class TQLabel; -class TQPushButton; -class KMWizardPage; -class KMPrinter; -class KMWBackend; -class SidePixmap; - -class KDEPRINT_EXPORT KMWizard : public TQDialog -{ - Q_OBJECT -public: - enum PageType { - Start = 0, - End, - Error, - Backend, - Driver, - File, - SMB, - TCP, - Local, - LPD, - IPP, - IPPSelect, - Class, - Password, - DriverTest, - DriverSelect, - Name, - Banners, - Custom = 100 - }; - - KMWizard(TQWidget *parent = 0, const char *name = 0); - ~KMWizard(); - - void configure(int start, int end, bool inclusive = true); - void setCurrentPage(int ID, bool back = false); - void setPrinter(KMPrinter*); - KMPrinter* printer() { return m_printer; } - void addPage(KMWizardPage*); - KMWBackend* backendPage() { return m_backend; } - void setNextPage(int page, int next); - -public slots: - void enableWizard(); - void disableWizard(); - -protected slots: - void slotNext(); - void slotPrev(); - void slotHelp(); - -private: - TQIntDict<KMWizardPage> m_pagepool; - TQValueStack<int> m_pagestack; - - TQWidgetStack *m_stack; - TQLabel *m_title; - TQPushButton *m_next, *m_prev; - int m_start, m_end; - bool m_inclusive; - KMPrinter *m_printer; - - // backend page - KMWBackend *m_backend; - - // side pixmap - SidePixmap *m_side; -}; - -#endif diff --git a/kdeprint/management/kmwizardpage.cpp b/kdeprint/management/kmwizardpage.cpp deleted file mode 100644 index 10149d0f9..000000000 --- a/kdeprint/management/kmwizardpage.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwizardpage.h" -#include "kmwizard.h" - -KMWizardPage::KMWizardPage(TQWidget *parent, const char *name) -: TQWidget(parent,name) -{ - m_ID = KMWizard::Error; - m_title = "KMWizardPage"; - m_nextpage = KMWizard::Error; - m_needsinitonback = false; -} - -KMWizardPage::~KMWizardPage() -{ -} - -bool KMWizardPage::isValid(TQString&) -{ - return true; -} - -void KMWizardPage::initPrinter(KMPrinter*) -{ -} - -void KMWizardPage::updatePrinter(KMPrinter*) -{ -} -#include "kmwizardpage.moc" diff --git a/kdeprint/management/kmwizardpage.h b/kdeprint/management/kmwizardpage.h deleted file mode 100644 index 61fe938b7..000000000 --- a/kdeprint/management/kmwizardpage.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWIZARDPAGE_H -#define KMWIZARDPAGE_H - -#include <tqwidget.h> - -#include <kdelibs_export.h> - -class KMPrinter; - -class KDEPRINT_EXPORT KMWizardPage : public TQWidget -{ - Q_OBJECT -public: - KMWizardPage(TQWidget *parent = 0, const char *name = 0); - virtual ~KMWizardPage(); - - int id() const { return m_ID; } - const TQString& title() const { return m_title; } - int nextPage() const { return m_nextpage; } - void setNextPage(int p) { m_nextpage = p; } - virtual bool isValid(TQString&); - virtual void initPrinter(KMPrinter*); - virtual void updatePrinter(KMPrinter*); - bool needsInitOnBack() { return m_needsinitonback; } - -protected: - QString m_title; - int m_ID; - int m_nextpage; - bool m_needsinitonback; -}; - -#endif diff --git a/kdeprint/management/kmwlocal.cpp b/kdeprint/management/kmwlocal.cpp deleted file mode 100644 index 7b56b2deb..000000000 --- a/kdeprint/management/kmwlocal.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwlocal.h" -#include "kmwizard.h" -#include "kmprinter.h" -#include "kmfactory.h" -#include "kmmanager.h" - -#include <klocale.h> -#include <tqlayout.h> -#include <tqlineedit.h> -#include <tqlabel.h> -#include <tqheader.h> -#include <klistview.h> -#include <kmessagebox.h> -#include <kiconloader.h> - -KMWLocal::KMWLocal(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_title = i18n("Local Port Selection"); - m_ID = KMWizard::Local; - m_nextpage = KMWizard::Driver; - m_initialized = false; - m_block = false; - - m_ports = new KListView(this); - m_ports->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - m_ports->setLineWidth(1); - m_ports->header()->hide(); - m_ports->addColumn(""); - m_ports->setSorting(-1); - TQListViewItem *root = new TQListViewItem(m_ports, i18n("Local System")); - root->setPixmap(0, SmallIcon("tdeprint_computer")); - root->setOpen(true); - connect(m_ports, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotPortSelected(TQListViewItem*))); - TQLabel *l1 = new TQLabel(i18n("URI:"), this); - m_localuri = new TQLineEdit(this); - connect( m_localuri, TQT_SIGNAL( textChanged( const TQString& ) ), TQT_SLOT( slotTextChanged( const TQString& ) ) ); - m_parents[0] = new TQListViewItem(root, i18n("Parallel")); - m_parents[1] = new TQListViewItem(root, m_parents[0], i18n("Serial")); - m_parents[2] = new TQListViewItem(root, m_parents[1], i18n("USB")); - m_parents[3] = new TQListViewItem(root, m_parents[2], i18n("Others")); - for (int i=0;i<4;i++) - m_parents[i]->setPixmap(0, SmallIcon("input_devices_settings")); - TQLabel *l2 = new TQLabel(i18n("<p>Select a valid detected port, or enter directly the corresponding URI in the bottom edit field.</p>"), this); - - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, 10); - TQHBoxLayout *lay1 = new TQHBoxLayout(0, 0, 10); - lay0->addWidget(l2, 0); - lay0->addWidget(m_ports, 1); - lay0->addLayout(lay1, 0); - lay1->addWidget(l1, 0); - lay1->addWidget(m_localuri, 1); -} - -bool KMWLocal::isValid(TQString& msg) -{ - if (m_localuri->text().isEmpty()) - { - msg = i18n("The URI is empty","Empty URI."); - return false; - } - else if (m_uris.findIndex(m_localuri->text()) == -1) - { - if (KMessageBox::warningContinueCancel(this, i18n("The local URI doesn't correspond to a detected port. Continue?")) == KMessageBox::Cancel) - { - msg = i18n("Select a valid port."); - return false; - } - } - return true; -} - -void KMWLocal::slotPortSelected(TQListViewItem *item) -{ - if ( m_block ) - return; - - TQString uri; - if (!item || item->depth() <= 1 || item->depth() > 3) - uri = TQString::null; - else if (item->depth() == 3) - uri = item->parent()->text( 1 ); - else - uri = item->text( 1 ); - m_block = true; - m_localuri->setText( uri ); - m_block = false; -} - -void KMWLocal::updatePrinter(KMPrinter *printer) -{ - TQListViewItem *item = m_ports->selectedItem(); - if ( item && item->depth() == 3 ) - printer->setOption( "kde-autodetect", item->text( 0 ) ); - printer->setDevice(m_localuri->text()); -} - -void KMWLocal::initPrinter(KMPrinter *printer) -{ - if (!m_initialized) - initialize(); - - if (printer) - { - m_localuri->setText(printer->device()); - } -} - -TQListViewItem* KMWLocal::lookForItem( const TQString& uri ) -{ - for ( int i=0; i<4; i++ ) - { - TQListViewItem *item = m_parents[ i ]->firstChild(); - while ( item ) - if ( item->text( 1 ) == uri ) - if ( item->firstChild() ) - return item->firstChild(); - else - return item; - else - item = item->nextSibling(); - } - return 0; -} - -void KMWLocal::slotTextChanged( const TQString& txt ) -{ - if ( m_block ) - return; - - TQListViewItem *item = lookForItem( txt ); - if ( item ) - { - m_block = true; - m_ports->setSelected( item, true ); - m_block = false; - } - else - m_ports->clearSelection(); -} - -void KMWLocal::initialize() -{ - TQStringList list = KMFactory::self()->manager()->detectLocalPrinters(); - if (list.isEmpty() || (list.count() % 4) != 0) - { - KMessageBox::error(this, i18n("Unable to detect local ports.")); - return; - } - TQListViewItem *last[4] = {0, 0, 0, 0}; - for (TQStringList::Iterator it=list.begin(); it!=list.end(); ++it) - { - TQString cl = *it; - ++it; - - TQString uri = *it; - int p = uri.find( ':' ); - TQString desc = *(++it), prot = ( p != -1 ? uri.left( p ) : TQString::null ); - TQString printer = *(++it); - int index(-1); - if (desc.isEmpty()) - desc = uri; - if (prot == "parallel" || prot == "file") - index = 0; - else if (prot == "serial") - index = 1; - else if (prot == "usb") - index = 2; - else if (cl == "direct") - index = 3; - else - continue; - last[index] = new TQListViewItem(m_parents[index], last[index], desc, uri); - last[index]->setPixmap(0, SmallIcon("blockdevice")); - m_parents[index]->setOpen(true); - m_uris << uri; - if (!printer.isEmpty()) - { - TQListViewItem *pItem = new TQListViewItem(last[index], printer); - last[index]->setOpen(true); - pItem->setPixmap(0, SmallIcon("tdeprint_printer")); - } - } - m_initialized = true; -} - -#include "kmwlocal.moc" diff --git a/kdeprint/management/kmwlocal.h b/kdeprint/management/kmwlocal.h deleted file mode 100644 index 681d94e51..000000000 --- a/kdeprint/management/kmwlocal.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWLOCAL_H -#define KMWLOCAL_H - -#include "kmwizardpage.h" - -#include <tqstringlist.h> - -class TQLineEdit; -class KListView; -class TQListViewItem; - -class KMWLocal : public KMWizardPage -{ - Q_OBJECT -public: - KMWLocal(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - void initPrinter(KMPrinter*); - -protected slots: - void slotPortSelected(TQListViewItem*); - void slotTextChanged( const TQString& ); - -protected: - void initialize(); - TQListViewItem* lookForItem( const TQString& ); - -protected: - KListView *m_ports; - TQLineEdit *m_localuri; - TQStringList m_uris; - TQListViewItem *m_parents[4]; - bool m_initialized; - bool m_block; -}; - -#endif diff --git a/kdeprint/management/kmwlpd.cpp b/kdeprint/management/kmwlpd.cpp deleted file mode 100644 index cce4c7b5a..000000000 --- a/kdeprint/management/kmwlpd.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwlpd.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <kurl.h> -#include <klocale.h> -#include <tqlabel.h> -#include <kdebug.h> -#include <tqlineedit.h> -#include <kmessagebox.h> -#include <kextsock.h> - -static bool checkLpdQueue(const char *host, const char *queue); - -//******************************************************************************************************** - -KMWLpd::KMWLpd(TQWidget *parent, const char *name) -: KMWInfoBase(2,parent,name) -{ - m_ID = KMWizard::LPD; - m_title = i18n("LPD Queue Information"); - m_nextpage = KMWizard::Driver; - - setInfo(i18n("<p>Enter the information concerning the remote LPD queue; " - "this wizard will check it before continuing.</p>")); - setLabel(0,i18n("Host:")); - setLabel(1,i18n("Queue:")); -} - -bool KMWLpd::isValid(TQString& msg) -{ - if (text(0).isEmpty() || text(1).isEmpty()) - { - msg = i18n("Some information is missing."); - return false; - } - - // check LPD queue - if (!checkLpdQueue(text(0).latin1(),text(1).latin1())) - { - if (KMessageBox::warningContinueCancel(this, i18n("Cannot find queue %1 on server %2; do you want to continue anyway?").arg(text(1)).arg(text(0))) == KMessageBox::Cancel) - return false; - } - return true; -} - -void KMWLpd::updatePrinter(KMPrinter *p) -{ - QString dev = TQString::tqfromLatin1("lpd://%1/%2").arg(text(0)).arg(text(1)); - p->setDevice(dev); -} - -//******************************************************************************************************* - -bool checkLpdQueue(const char *host, const char *queue) -{ - KExtendedSocket sock(host, "printer", KExtendedSocket::streamSocket); - sock.setBlockingMode(true); - if (sock.connect() != 0) - return false; - - char res[64] = {0}; - snprintf(res,64,"%c%s\n",(char)4,queue); - if (sock.tqwriteBlock(res, strlen(res)) != (TQ_LONG)(strlen(res))) - return false; - - char buf[1024] = {0}; - int n, tot(1); - while ((n = sock.tqreadBlock(res, 63)) > 0) - { - res[n] = 0; - tot += n; - if (tot >= 1024) - break; - else - strcat(buf, res); - } - sock.close(); - if (strlen(buf) == 0 || strstr(buf, "unknown printer") != NULL) - return false; - return true; -} diff --git a/kdeprint/management/kmwlpd.h b/kdeprint/management/kmwlpd.h deleted file mode 100644 index 674cdff44..000000000 --- a/kdeprint/management/kmwlpd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWLPD_H -#define KMWLPD_H - -#include "kmwinfobase.h" - -class KMWLpd : public KMWInfoBase -{ -public: - KMWLpd(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); -}; - -#endif diff --git a/kdeprint/management/kmwname.cpp b/kdeprint/management/kmwname.cpp deleted file mode 100644 index fe567f7bb..000000000 --- a/kdeprint/management/kmwname.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwname.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <tqregexp.h> - -KMWName::KMWName(TQWidget *parent, const char *name) -: KMWInfoBase(3,parent,name) -{ - m_ID = KMWizard::Name; - m_title = i18n("General Information"); - m_nextpage = KMWizard::End; - - setInfo(i18n("<p>Enter the information concerning your printer or class. <b>Name</b> is mandatory, " - "<b>Location</b> and <b>Description</b> are not (they may even not be used on some systems).</p>")); - setLabel(0,i18n("Name:")); - setLabel(1,i18n("Location:")); - setLabel(2,i18n("Description:")); -} - -bool KMWName::isValid(TQString& msg) -{ - if (text(0).isEmpty()) - { - msg = i18n("You must supply at least a name."); - return false; - } - else if (text(0).find(TQRegExp("\\s")) != -1) - { - QString conv = text(0); - conv.replace(TQRegExp("\\s"), ""); - int result = KMessageBox::warningYesNoCancel(this, - i18n("It is usually not a good idea to include spaces " - "in printer name: it may prevent your printer from " - "working correctly. The wizard can strip all spaces " - "from the string you entered, resulting in %1; " - "what do you want to do?").arg(conv), - TQString::null, - i18n("Strip"), i18n("Keep")); - switch (result) - { - case KMessageBox::Yes: - setText(0, conv); - case KMessageBox::No: - return true; - default: - return false; - } - } - return true; -} - -void KMWName::initPrinter(KMPrinter *p) -{ - setText(0,p->printerName()); - setText(1,p->location()); - setText(2,p->description()); - if (text(2).isEmpty()) - if (p->option("kde-driver") == "raw") - setText(2,i18n("Raw printer")); - else - setText(2,p->manufacturer() + " " + p->model()); - - setCurrent(0); -} - -void KMWName::updatePrinter(KMPrinter *p) -{ - p->setPrinterName(text(0)); - p->setName(text(0)); - p->setLocation(text(1)); - p->setDescription(text(2)); -} diff --git a/kdeprint/management/kmwname.h b/kdeprint/management/kmwname.h deleted file mode 100644 index f933d59ed..000000000 --- a/kdeprint/management/kmwname.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWNAME_H -#define KMWNAME_H - -#include "kmwinfobase.h" - -class KMWName : public KMWInfoBase -{ -public: - KMWName(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); -}; - -#endif diff --git a/kdeprint/management/kmwpassword.cpp b/kdeprint/management/kmwpassword.cpp deleted file mode 100644 index 40dc105d5..000000000 --- a/kdeprint/management/kmwpassword.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwpassword.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqvbuttongroup.h> -#include <tqradiobutton.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kcursor.h> - -#include <stdlib.h> - -KMWPassword::KMWPassword(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_title = i18n("User Identification"); - m_ID = KMWizard::Password; - m_nextpage = KMWizard::SMB; - - // create widgets - TQLabel *infotext_ = new TQLabel(this); - infotext_->setText(i18n("<p>This backend may require a login/password to work properly. " - "Select the type of access to use and fill in the login and password entries if needed.</p>")); - m_login = new TQLineEdit(this); - m_login->setText(TQString::fromLocal8Bit(getenv("USER"))); - m_password = new TQLineEdit(this); - m_password->setEchoMode(TQLineEdit::Password); - TQLabel *loginlabel_ = new TQLabel(i18n("&Login:"),this); - TQLabel *passwdlabel_ = new TQLabel(i18n("&Password:"),this); - m_btngroup = new TQVButtonGroup( this ); - m_btngroup->setFrameStyle( TQFrame::NoFrame ); - TQRadioButton *btn1 = new TQRadioButton( i18n( "&Anonymous (no login/password)" ), m_btngroup ); - TQRadioButton *btn2 = new TQRadioButton( i18n( "&Guest account (login=\"guest\")" ), m_btngroup ); - TQRadioButton *btn3 = new TQRadioButton( i18n( "Nor&mal account" ), m_btngroup ); - btn1->setCursor( KCursor::handCursor() ); - btn2->setCursor( KCursor::handCursor() ); - btn3->setCursor( KCursor::handCursor() ); - m_btngroup->setButton( 0 ); - - loginlabel_->setBuddy(m_login); - passwdlabel_->setBuddy(m_password); - - m_login->setEnabled(false); - m_password->setEnabled(false); - connect(btn3,TQT_SIGNAL(toggled(bool)),m_login,TQT_SLOT(setEnabled(bool))); - connect(btn3,TQT_SIGNAL(toggled(bool)),m_password,TQT_SLOT(setEnabled(bool))); - - // layout - TQVBoxLayout *main_ = new TQVBoxLayout( this, 0, 0 ); - main_->addWidget( infotext_ ); - main_->addSpacing( 10 ); - main_->addWidget( m_btngroup ); - TQGridLayout *l1 = new TQGridLayout( 0, 2, 3 ); - main_->addLayout( TQT_TQLAYOUT(l1) ); - main_->addStretch( 1 ); - l1->setColSpacing( 0, 35 ); - l1->setColStretch( 2, 1 ); - l1->addWidget( loginlabel_, 0, 1 ); - l1->addWidget( passwdlabel_, 1, 1 ); - l1->addWidget( m_login, 0, 2 ); - l1->addWidget( m_password, 1, 2 ); -} - -bool KMWPassword::isValid(TQString& msg) -{ - if ( !m_btngroup->selected() ) - msg = i18n( "Select one option" ); - else if (m_btngroup->selectedId() == 2 && m_login->text().isEmpty()) - msg = i18n("User name is empty."); - else - return true; - return false; -} - -void KMWPassword::initPrinter( KMPrinter* p ) -{ - /* guest account only for SMB backend */ - if ( p->option( "kde-backend" ).toInt() != KMWizard::SMB ) - { - int ID = m_btngroup->selectedId(); - m_btngroup->find( 1 )->hide(); - if ( ID == 1 ) - m_btngroup->setButton( 0 ); - } - else - m_btngroup->find( 1 )->show(); -} - -void KMWPassword::updatePrinter(KMPrinter *p) -{ - TQString s = p->option("kde-backend"); - if (!s.isEmpty()) - setNextPage(s.toInt()); - else - setNextPage(KMWizard::Error); - switch ( m_btngroup->selectedId() ) - { - case 0: - p->setOption( "kde-login", TQString::null ); - p->setOption( "kde-password", TQString::null ); - break; - case 1: - p->setOption( "kde-login", TQString::tqfromLatin1( "guest" ) ); - p->setOption( "kde-password", TQString::null ); - break; - case 2: - p->setOption( "kde-login", m_login->text() ); - p->setOption( "kde-password", m_password->text() ); - break; - } -} - diff --git a/kdeprint/management/kmwpassword.h b/kdeprint/management/kmwpassword.h deleted file mode 100644 index a7dfb062a..000000000 --- a/kdeprint/management/kmwpassword.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWPASSWORD_H -#define KMWPASSWORD_H - -#include "kmwizardpage.h" - -class TQLineEdit; -class TQButtonGroup; - -class KMWPassword : public KMWizardPage -{ -public: - KMWPassword(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void initPrinter( KMPrinter* ); - void updatePrinter(KMPrinter*); - -private: - TQLineEdit *m_login; - TQLineEdit *m_password; - TQButtonGroup *m_btngroup; -}; - -#endif diff --git a/kdeprint/management/kmwsmb.cpp b/kdeprint/management/kmwsmb.cpp deleted file mode 100644 index e76240cf8..000000000 --- a/kdeprint/management/kmwsmb.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwsmb.h" -#include "kmwizard.h" -#include "smbview.h" -#include "kmprinter.h" -#include "util.h" - -#include <klocale.h> -#include <kpushbutton.h> -#include <tqlayout.h> -#include <tqlineedit.h> -#include <tqlabel.h> - -KMWSmb::KMWSmb(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_title = i18n("SMB Printer Settings"); - m_ID = KMWizard::SMB; - m_nextpage = KMWizard::Driver; - - m_view = new SmbView(this,"SmbView"); - m_loginlabel = new TQLabel( this ); - TQPushButton *m_scan = new KPushButton(KGuiItem(i18n("Scan"), "viewmag"), this); - TQPushButton *m_abort = new KPushButton(KGuiItem(i18n("Abort"), "stop"), this); - m_abort->setEnabled(false); - TQLabel *m_worklabel = new TQLabel(i18n("Workgroup:"), this); - TQLabel *m_serverlabel = new TQLabel(i18n("Server:"), this); - TQLabel *m_printerlabel = new TQLabel(i18n("Printer:"), this); - m_work = new TQLineEdit(this); - m_server = new TQLineEdit(this); - m_printer = new TQLineEdit(this); - - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, 10); - TQGridLayout *lay1 = new TQGridLayout(0, 3, 2, 0, 10); - TQHBoxLayout *lay3 = new TQHBoxLayout(0, 0, 10); - lay0->addLayout(TQT_TQLAYOUT(lay1),0); - lay0->addWidget(m_view,1); - lay0->addLayout(lay3,0); - lay0->addSpacing(10); - lay1->setColStretch(1,1); - lay1->addWidget(m_worklabel,0,0); - lay1->addWidget(m_serverlabel,1,0); - lay1->addWidget(m_printerlabel,2,0); - lay1->addWidget(m_work,0,1); - lay1->addWidget(m_server,1,1); - lay1->addWidget(m_printer,2,1); - lay3->addWidget( m_loginlabel ); - lay3->addStretch(1); - lay3->addWidget(m_scan); - lay3->addWidget(m_abort); - - connect(m_scan,TQT_SIGNAL(clicked()),TQT_SLOT(slotScan())); - connect(m_abort,TQT_SIGNAL(clicked()),TQT_SLOT(slotAbort())); - connect(m_view,TQT_SIGNAL(printerSelected(const TQString&,const TQString&,const TQString&)),TQT_SLOT(slotPrinterSelected(const TQString&,const TQString&,const TQString&))); - connect(m_view,TQT_SIGNAL(running(bool)),m_abort,TQT_SLOT(setEnabled(bool))); -} - -bool KMWSmb::isValid(TQString& msg) -{ - if (m_server->text().isEmpty()) - msg = i18n("Empty server name."); - else if (m_printer->text().isEmpty()) - msg = i18n("Empty printer name."); - else - return true; - return false; -} - -void KMWSmb::updatePrinter(KMPrinter *printer) -{ - TQString uri = buildSmbURI( m_work->text(), m_server->text(), m_printer->text(), printer->option( "kde-login" ), printer->option( "kde-password" ) ); - printer->setDevice( uri ); -} - -void KMWSmb::initPrinter(KMPrinter *printer) -{ - if (printer) - { - TQString login = printer->option( "kde-login" ); - m_view->setLoginInfos(login,printer->option("kde-password")); - m_loginlabel->setText( i18n( "Login: %1" ).arg( login.isEmpty() ? i18n( "<anonymous>" ) : login ) ); - } -} - -void KMWSmb::slotScan() -{ - m_view->init(); -} - -void KMWSmb::slotAbort() -{ - m_view->abort(); -} - -void KMWSmb::slotPrinterSelected(const TQString& work, const TQString& server, const TQString& printer) -{ - m_work->setText(work); - m_server->setText(server); - m_printer->setText(printer); -} -#include "kmwsmb.moc" diff --git a/kdeprint/management/kmwsmb.h b/kdeprint/management/kmwsmb.h deleted file mode 100644 index 695379a79..000000000 --- a/kdeprint/management/kmwsmb.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWSMB_H -#define KMWSMB_H - -#include "kmwizardpage.h" - -class SmbView; -class TQLineEdit; -class TQLabel; - -class KMWSmb : public KMWizardPage -{ - Q_OBJECT -public: - KMWSmb(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - void initPrinter(KMPrinter*); - -protected slots: - void slotScan(); - void slotAbort(); - void slotPrinterSelected(const TQString& work, const TQString& server, const TQString& printer); - -protected: - SmbView *m_view; - TQLineEdit *m_work, *m_server, *m_printer; - TQLabel *m_loginlabel; -}; - -#endif diff --git a/kdeprint/management/kmwsocket.cpp b/kdeprint/management/kmwsocket.cpp deleted file mode 100644 index 98aad76a5..000000000 --- a/kdeprint/management/kmwsocket.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwsocket.h" -#include "networkscanner.h" -#include "kmwizard.h" -#include "kmprinter.h" - -#include <klistview.h> -#include <tqheader.h> -#include <tqlineedit.h> -#include <tqlabel.h> -#include <kmessagebox.h> -#include <tqlayout.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kseparator.h> - -KMWSocket::KMWSocket(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_title = i18n("Network Printer Information"); - m_ID = KMWizard::TCP; - m_nextpage = KMWizard::Driver; - - m_list = new KListView(this); - m_list->addColumn(""); - m_list->header()->hide(); - m_list->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - m_list->setLineWidth(1); - - TQLabel *l1 = new TQLabel(i18n("&Printer address:"),this); - TQLabel *l2 = new TQLabel(i18n("P&ort:"),this); - - m_printer = new TQLineEdit(this); - m_port = new TQLineEdit(this); - m_port->setText(TQString("9100")); - - l1->setBuddy(m_printer); - l2->setBuddy(m_port); - - m_scanner = new NetworkScanner( 9100, this ); - - KSeparator* sep = new KSeparator( KSeparator::HLine, this); - sep->setFixedHeight(40); - - connect(m_list,TQT_SIGNAL(selectionChanged(TQListViewItem*)),TQT_SLOT(slotPrinterSelected(TQListViewItem*))); - connect( m_scanner, TQT_SIGNAL( scanStarted() ), TQT_SLOT( slotScanStarted() ) ); - connect( m_scanner, TQT_SIGNAL( scanFinished() ), TQT_SLOT( slotScanFinished() ) ); - connect( m_scanner, TQT_SIGNAL( scanStarted() ), parent, TQT_SLOT( disableWizard() ) ); - connect( m_scanner, TQT_SIGNAL( scanFinished() ), parent, TQT_SLOT( enableWizard() ) ); - - // layout - TQHBoxLayout *lay3 = new TQHBoxLayout(this, 0, 10); - TQVBoxLayout *lay2 = new TQVBoxLayout(0, 0, 0); - - lay3->addWidget(m_list,1); - lay3->addLayout(lay2,1); - lay2->addWidget(l1); - lay2->addWidget(m_printer); - lay2->addSpacing(10); - lay2->addWidget(l2); - lay2->addWidget(m_port); - lay2->addWidget(sep); - lay2->addWidget( m_scanner ); - lay2->addStretch(1); -} - -KMWSocket::~KMWSocket() -{ -} - -void KMWSocket::updatePrinter(KMPrinter *p) -{ - TQString dev = TQString::tqfromLatin1("socket://%1:%2").arg(m_printer->text()).arg(m_port->text()); - p->setDevice(dev); -} - -bool KMWSocket::isValid(TQString& msg) -{ - if (m_printer->text().isEmpty()) - { - msg = i18n("You must enter a printer address."); - return false; - } - TQString port(m_port->text()); - int p(9100); - if (!port.isEmpty()) - { - bool ok; - p = port.toInt(&ok); - if (!ok) - { - msg = i18n("Wrong port number."); - return false; - } - } - - if (!m_scanner->checkPrinter(m_printer->text(),p)) - { - msg = i18n("No printer found at this address/port."); - return false; - } - return true; -} - -void KMWSocket::slotScanStarted() -{ - m_list->clear(); -} - -void KMWSocket::slotScanFinished() -{ - const TQPtrList<NetworkScanner::SocketInfo> *list = m_scanner->printerList(); - TQPtrListIterator<NetworkScanner::SocketInfo> it(*list); - for (;it.current();++it) - { - TQString name; - if (it.current()->Name.isEmpty()) - name = i18n("Unknown host - 1 is the IP", "<Unknown> (%1)").arg(it.current()->IP); - else - name = it.current()->Name; - TQListViewItem *item = new TQListViewItem(m_list,name,it.current()->IP,TQString::number(it.current()->Port)); - item->setPixmap(0,SmallIcon("tdeprint_printer")); - } -} - -void KMWSocket::slotPrinterSelected(TQListViewItem *item) -{ - if (!item) return; - m_printer->setText(item->text(1)); - m_port->setText(item->text(2)); -} - -#include "kmwsocket.moc" diff --git a/kdeprint/management/kmwsocket.h b/kdeprint/management/kmwsocket.h deleted file mode 100644 index 687b52fd4..000000000 --- a/kdeprint/management/kmwsocket.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWSOCKET_H -#define KMWSOCKET_H - -#include "kmwizardpage.h" - -class KListView; -class TQListViewItem; -class TQLineEdit; -class NetworkScanner; - -class KMWSocket : public KMWizardPage -{ - Q_OBJECT -public: - KMWSocket(TQWidget *parent = 0, const char *name = 0); - ~KMWSocket(); - - bool isValid(TQString&); - void updatePrinter(KMPrinter*); - -protected slots: - void slotPrinterSelected(TQListViewItem*); - void slotScanStarted(); - void slotScanFinished(); - -private: - KListView *m_list; - NetworkScanner *m_scanner; - TQLineEdit *m_printer, *m_port; -}; - -#endif diff --git a/kdeprint/management/kmwsocketutil.cpp b/kdeprint/management/kmwsocketutil.cpp deleted file mode 100644 index e6d06bae2..000000000 --- a/kdeprint/management/kmwsocketutil.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * - * 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 "kmwsocketutil.h" - -#include <tqprogressbar.h> -#include <tqlineedit.h> -#include <tqlabel.h> -#include <tqcombobox.h> -#include <tqpushbutton.h> -#include <kmessagebox.h> -#include <tqlayout.h> -#include <tqregexp.h> -#include <knumvalidator.h> - -#include <kapplication.h> -#include <klocale.h> -#include <kextsock.h> -#include <kdebug.h> - -#include <unistd.h> - -TQString localRootIP(); - -//---------------------------------------------------------------------------------------- - -SocketConfig::SocketConfig(KMWSocketUtil *util, TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, TQString::null, Ok|Cancel, Ok, true) -{ - TQWidget *dummy = new TQWidget(this); - setMainWidget(dummy); - KIntValidator *val = new KIntValidator( this ); - TQLabel *masklabel = new TQLabel(i18n("&Subnetwork:"),dummy); - TQLabel *portlabel = new TQLabel(i18n("&Port:"),dummy); - TQLabel *toutlabel = new TQLabel(i18n("&Timeout (ms):"),dummy); - TQLineEdit *mm = new TQLineEdit(dummy); - mm->setText(TQString::tqfromLatin1(".[0-255]")); - mm->setReadOnly(true); - mm->setFixedWidth(fontMetrics().width(mm->text())+10); - - mask_ = new TQLineEdit(dummy); - mask_->tqsetAlignment(Qt::AlignRight); - port_ = new TQComboBox(true,dummy); - if ( port_->lineEdit() ) - port_->lineEdit()->setValidator( val ); - tout_ = new TQLineEdit(dummy); - tout_->setValidator( val ); - - masklabel->setBuddy(mask_); - portlabel->setBuddy(port_); - toutlabel->setBuddy(tout_); - - mask_->setText(util->root_); - port_->insertItem("631"); - port_->insertItem("9100"); - port_->insertItem("9101"); - port_->insertItem("9102"); - port_->setEditText(TQString::number(util->port_)); - tout_->setText(TQString::number(util->timeout_)); - - TQGridLayout *main_ = new TQGridLayout(dummy, 3, 2, 0, 10); - TQHBoxLayout *lay1 = new TQHBoxLayout(0, 0, 5); - main_->addWidget(masklabel, 0, 0); - main_->addWidget(portlabel, 1, 0); - main_->addWidget(toutlabel, 2, 0); - main_->addLayout(lay1, 0, 1); - main_->addWidget(port_, 1, 1); - main_->addWidget(tout_, 2, 1); - lay1->addWidget(mask_,1); - lay1->addWidget(mm,0); - - resize(250,130); - setCaption(i18n("Scan Configuration")); -} - -SocketConfig::~SocketConfig() -{ -} - -void SocketConfig::slotOk() -{ - TQString msg; - TQRegExp re("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"); - if (!re.exactMatch(mask_->text())) - msg = i18n("Wrong subnetwork specification."); - else - { - for (int i=1; i<=3; i++) - if (re.cap(i).toInt() >= 255) - { - msg = i18n("Wrong subnetwork specification."); - break; - } - } - - bool ok(false); - int v = tout_->text().toInt(&ok); - if (!ok || v <= 0) - msg = i18n("Wrong timeout specification."); - v = port_->currentText().toInt(&ok); - if (!ok || v <= 0) - msg = i18n("Wrong port specification."); - if (!msg.isEmpty()) - { - KMessageBox::error(this,msg); - return; - } - - KDialogBase::slotOk(); -} - -//---------------------------------------------------------------------------------------- - -KMWSocketUtil::KMWSocketUtil() -{ - printerlist_.setAutoDelete(true); - root_ = localRootIP(); - port_ = 9100; - timeout_ = 50; -} - -bool KMWSocketUtil::checkPrinter(const TQString& IPstr, int port, TQString* hostname) -{ - KExtendedSocket sock(IPstr, port, KExtendedSocket::inetSocket|KExtendedSocket::streamSocket); - bool result(false); - sock.setTimeout(0, timeout_ * 1000); - if (sock.connect() == 0) - { - if (hostname) - { - TQString portname; - KExtendedSocket::resolve((KSocketAddress*)(sock.peerAddress()), *hostname, portname); - } - result = true; - } - sock.close(); - return result; -} - -bool KMWSocketUtil::scanNetwork(TQProgressBar *bar) -{ - printerlist_.setAutoDelete(true); - printerlist_.clear(); - int n(256); - if (bar) - bar->setTotalSteps(n); - for (int i=0; i<n; i++) - { - TQString IPstr = root_ + "." + TQString::number(i); - TQString hostname; - if (checkPrinter(IPstr, port_, &hostname)) - { // we found a printer at this address, create SocketInfo entry in printer list - SocketInfo *info = new SocketInfo; - info->IP = IPstr; - info->Port = port_; - info->Name = hostname; - printerlist_.append(info); - } - if (bar) - { - bar->setProgress(i); - kapp->flushX(); - } - } - return true; -} - -void KMWSocketUtil::configureScan(TQWidget *parent) -{ - SocketConfig *dlg = new SocketConfig(this,parent); - if (dlg->exec()) - { - root_ = dlg->mask_->text(); - port_ = dlg->port_->currentText().toInt(); - timeout_ = dlg->tout_->text().toInt(); - } - delete dlg; -} - -//---------------------------------------------------------------------------------------- - -TQString localRootIP() -{ - char buf[256]; - buf[0] = '\0'; - if (!gethostname(buf, sizeof(buf))) - buf[sizeof(buf)-1] = '\0'; - TQPtrList<KAddressInfo> infos = KExtendedSocket::lookup(buf, TQString::null); - infos.setAutoDelete(true); - if (infos.count() > 0) - { - TQString IPstr = infos.first()->address()->nodeName(); - int p = IPstr.findRev('.'); - IPstr.truncate(p); - return IPstr; - } - return TQString::null; -} - -#include "kmwsocketutil.moc" diff --git a/kdeprint/management/kmwsocketutil.h b/kdeprint/management/kmwsocketutil.h deleted file mode 100644 index dfb9f490e..000000000 --- a/kdeprint/management/kmwsocketutil.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWSOCKETUTIL_H -#define KMWSOCKETUTIL_H - -#include <tqstring.h> -#include <tqptrlist.h> -#include <kdialogbase.h> - -struct SocketInfo -{ - QString IP; - QString Name; - int Port; -}; - -class TQProgressBar; -class TQLineEdit; -class TQComboBox; -class KMWSocketUtil; - -class SocketConfig : public KDialogBase -{ - friend class KMWSocketUtil; - Q_OBJECT -public: - SocketConfig(KMWSocketUtil *util, TQWidget *parent = 0, const char *name = 0); - ~SocketConfig(); - -protected slots: - void slotOk(); - -private: - TQLineEdit *mask_, *tout_; - TQComboBox *port_; -}; - -class KMWSocketUtil -{ - friend class SocketConfig; - -public: - KMWSocketUtil(); - - bool checkPrinter(const TQString& host, int port, TQString* hostname = 0); - - const TQPtrList<SocketInfo>* printerList() { return &printerlist_; } - bool scanNetwork(TQProgressBar *bar = 0); - void configureScan(TQWidget *parent = 0); - void setDefaultPort(int p) { port_ = p; } - -private: - TQPtrList<SocketInfo> printerlist_; - TQString root_; - int port_; - int timeout_; // in milliseconds -}; - -#endif diff --git a/kdeprint/management/kxmlcommanddlg.cpp b/kdeprint/management/kxmlcommanddlg.cpp deleted file mode 100644 index 3b42b71d7..000000000 --- a/kdeprint/management/kxmlcommanddlg.cpp +++ /dev/null @@ -1,1059 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kxmlcommanddlg.h" -#include "driver.h" -#include "kxmlcommand.h" - -#include <tqlayout.h> -#include <tqheader.h> -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqcombobox.h> -#include <tqgroupbox.h> -#include <tqwidgetstack.h> -#include <tqtoolbutton.h> -#include <kpushbutton.h> -#include <tqtooltip.h> -#include <tqcheckbox.h> -#include <ktextedit.h> -#include <tqregexp.h> -#include <tqwhatsthis.h> -#include <tqapplication.h> - -#include <klistview.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kdialogbase.h> -#include <kseparator.h> -#include <klistbox.h> -#include <kmimetype.h> -#include <kmessagebox.h> -#include <kapplication.h> -#include <kdebug.h> -#include <kguiitem.h> - -TQString generateId(const TQMap<TQString, DrBase*>& map) -{ - int index(-1); - while (map.contains(TQString::tqfromLatin1("item%1").arg(++index))) ; - return TQString::tqfromLatin1("item%1").arg(index); -} - -TQListViewItem* findPrev(TQListViewItem *item) -{ - TQListViewItem *prev = item->itemAbove(); - while (prev && prev->depth() > item->depth()) - prev = prev->itemAbove(); - if (prev && prev->depth() == item->depth()) - return prev; - else - return 0; -} - -TQListViewItem* findNext(TQListViewItem *item) -{ - TQListViewItem *next = item->itemBelow(); - while (next && next->depth() > item->depth()) - next = next->itemBelow(); - if (next && next->depth() == item->depth()) - return next; - else - return 0; -} - -KXmlCommandAdvancedDlg::KXmlCommandAdvancedDlg(TQWidget *parent, const char *name) -: TQWidget(parent, name) -{ - m_xmlcmd = 0; - - m_command = new TQLineEdit(this); - m_view = new KListView(this); - m_view->addColumn(""); - m_view->header()->hide(); - m_view->setSorting(-1); - m_apply = new TQToolButton(this); - m_apply->setIconSet( TQApplication::reverseLayout()? SmallIconSet( "forward" ) : SmallIconSet("back")); - m_addgrp = new TQToolButton(this); - m_addgrp->setIconSet(SmallIconSet("folder")); - m_addopt = new TQToolButton(this); - m_addopt->setIconSet(SmallIconSet("document")); - m_delopt = new TQToolButton(this); - m_delopt->setIconSet(SmallIconSet("editdelete")); - m_up = new TQToolButton(this); - m_up->setIconSet(SmallIconSet("up")); - m_down = new TQToolButton(this); - m_down->setIconSet(SmallIconSet("down")); - m_dummy = new TQWidget(this); - m_desc = new TQLineEdit(m_dummy); - m_name = new TQLineEdit(m_dummy); - m_type = new TQComboBox(m_dummy); - m_type->insertItem(i18n("String")); - m_type->insertItem(i18n("Integer")); - m_type->insertItem(i18n("Float")); - m_type->insertItem(i18n("List")); - m_type->insertItem(i18n("Boolean")); - m_format = new TQLineEdit(m_dummy); - m_default = new TQLineEdit(m_dummy); - TQLabel *m_namelab = new TQLabel(i18n("&Name:"), m_dummy); - TQLabel *m_desclab = new TQLabel(i18n("&Description:"), m_dummy); - TQLabel *m_formatlab = new TQLabel(i18n("&Format:"), m_dummy); - TQLabel *m_typelab = new TQLabel(i18n("&Type:"), m_dummy); - TQLabel *m_defaultlab = new TQLabel(i18n("Default &value:"), m_dummy); - TQLabel *m_commandlab = new TQLabel(i18n("Co&mmand:"), this); - m_namelab->setBuddy(m_name); - m_desclab->setBuddy(m_desc); - m_formatlab->setBuddy(m_format); - m_typelab->setBuddy(m_type); - m_defaultlab->setBuddy(m_default); - m_commandlab->setBuddy(m_command); - m_persistent = new TQCheckBox( i18n( "&Persistent option" ), m_dummy ); - - TQGroupBox *gb = new TQGroupBox(0, Qt::Horizontal, i18n("Va&lues"), m_dummy); - m_stack = new TQWidgetStack(gb); - TQWidget *w1 = new TQWidget(m_stack), *w2 = new TQWidget(m_stack), *w3 = new TQWidget(m_stack); - m_stack->addWidget(w1, 1); - m_stack->addWidget(w2, 2); - m_stack->addWidget(w3, 3); - m_edit1 = new TQLineEdit(w1); - m_edit2 = new TQLineEdit(w1); - TQLabel *m_editlab1 = new TQLabel(i18n("Minimum v&alue:"), w1); - TQLabel *m_editlab2 = new TQLabel(i18n("Ma&ximum value:"), w1); - m_editlab1->setBuddy(m_edit1); - m_editlab2->setBuddy(m_edit2); - m_values = new KListView(w2); - m_values->addColumn(i18n("Name")); - m_values->addColumn(i18n("Description")); - m_values->setAllColumnsShowFocus(true); - m_values->setSorting(-1); - m_values->setMaximumHeight(110); - m_addval = new TQToolButton(w2); - m_addval->setIconSet(SmallIconSet("editcopy")); - m_delval = new TQToolButton(w2); - m_delval->setIconSet(SmallIconSet("editdelete")); - TQToolTip::add(m_addval, i18n("Add value")); - TQToolTip::add(m_delval, i18n("Delete value")); - - TQToolTip::add(m_apply, i18n("Apply changes")); - TQToolTip::add(m_addgrp, i18n("Add group")); - TQToolTip::add(m_addopt, i18n("Add option")); - TQToolTip::add(m_delopt, i18n("Delete item")); - TQToolTip::add(m_up, i18n("Move up")); - TQToolTip::add(m_down, i18n("Move down")); - - KSeparator *sep1 = new KSeparator(KSeparator::HLine, m_dummy); - - TQGroupBox *gb_input = new TQGroupBox(0, Qt::Horizontal, i18n("&Input From"), this); - TQGroupBox *gb_output = new TQGroupBox(0, Qt::Horizontal, i18n("O&utput To"), this); - TQLabel *m_inputfilelab = new TQLabel(i18n("File:"), gb_input); - TQLabel *m_inputpipelab = new TQLabel(i18n("Pipe:"), gb_input); - TQLabel *m_outputfilelab = new TQLabel(i18n("File:"), gb_output); - TQLabel *m_outputpipelab = new TQLabel(i18n("Pipe:"), gb_output); - m_inputfile = new TQLineEdit(gb_input); - m_inputpipe = new TQLineEdit(gb_input); - m_outputfile = new TQLineEdit(gb_output); - m_outputpipe = new TQLineEdit(gb_output); - - m_comment = new KTextEdit( this ); - m_comment->setTextFormat(TQt::RichText ); - m_comment->setReadOnly(true); - TQLabel *m_commentlab = new TQLabel( i18n( "Comment:" ), this ); - - TQVBoxLayout *l2 = new TQVBoxLayout(this, 0, KDialog::spacingHint()); - TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint()); - TQVBoxLayout *l7 = new TQVBoxLayout(0, 0, 0); - l2->addLayout(l3, 0); - l3->addWidget(m_commandlab); - l3->addWidget(m_command); - TQHBoxLayout *l0 = new TQHBoxLayout(0, 0, KDialog::spacingHint()); - TQGridLayout *l10 = new TQGridLayout(0, 2, 2, 0, KDialog::spacingHint()); - l2->addLayout(l0, 1); - l0->addLayout(TQT_TQLAYOUT(l10)); - l10->addMultiCellWidget(m_view, 0, 0, 0, 1); - l10->addWidget(gb_input, 1, 0); - l10->addWidget(gb_output, 1, 1); - l10->setRowStretch(0, 1); - l0->addLayout(l7); - l7->addWidget(m_apply); - l7->addSpacing(5); - l7->addWidget(m_addgrp); - l7->addWidget(m_addopt); - l7->addWidget(m_delopt); - l7->addSpacing(5); - l7->addWidget(m_up); - l7->addWidget(m_down); - l7->addStretch(1); - l0->addWidget(m_dummy, 1); - TQGridLayout *l1 = new TQGridLayout(m_dummy, 9, 2, 0, KDialog::spacingHint()); - l1->addWidget(m_desclab, 0, 0, Qt::AlignRight|Qt::AlignVCenter); - l1->addWidget(m_desc, 0, 1); - l1->addMultiCellWidget(sep1, 1, 1, 0, 1); - l1->addWidget(m_namelab, 2, 0, Qt::AlignRight|Qt::AlignVCenter); - l1->addWidget(m_name, 2, 1); - l1->addWidget(m_typelab, 3, 0, Qt::AlignRight|Qt::AlignVCenter); - l1->addWidget(m_type, 3, 1); - l1->addWidget(m_formatlab, 4, 0, Qt::AlignRight|Qt::AlignVCenter); - l1->addWidget(m_format, 4, 1); - l1->addWidget(m_defaultlab, 5, 0, Qt::AlignRight|Qt::AlignVCenter); - l1->addWidget(m_default, 5, 1); - l1->addWidget( m_persistent, 6, 1 ); - l1->addMultiCellWidget(gb, 7, 7, 0, 1); - l1->setRowStretch(8, 1); - - TQHBoxLayout *l4 = new TQHBoxLayout(w2, 0, KDialog::spacingHint()); - l4->addWidget(m_values); - TQVBoxLayout *l6 = new TQVBoxLayout(0, 0, 0); - l4->addLayout(l6); - l6->addWidget(m_addval); - l6->addWidget(m_delval); - l6->addStretch(1); - TQGridLayout *l5 = new TQGridLayout(w1, 3, 2, 0, KDialog::spacingHint()); - l5->setRowStretch(2, 1); - l5->addWidget(m_editlab1, 0, 0, Qt::AlignRight|Qt::AlignVCenter); - l5->addWidget(m_editlab2, 1, 0, Qt::AlignRight|Qt::AlignVCenter); - l5->addWidget(m_edit1, 0, 1); - l5->addWidget(m_edit2, 1, 1); - - TQGridLayout *l8 = new TQGridLayout(gb_input->tqlayout(), 2, 2, - KDialog::spacingHint()); - TQGridLayout *l9 = new TQGridLayout(gb_output->tqlayout(), 2, 2, - KDialog::spacingHint()); - l8->addWidget(m_inputfilelab, 0, 0); - l8->addWidget(m_inputpipelab, 1, 0); - l8->addWidget(m_inputfile, 0, 1); - l8->addWidget(m_inputpipe, 1, 1); - l9->addWidget(m_outputfilelab, 0, 0); - l9->addWidget(m_outputpipelab, 1, 0); - l9->addWidget(m_outputfile, 0, 1); - l9->addWidget(m_outputpipe, 1, 1); - - TQVBoxLayout *l11 = new TQVBoxLayout(TQT_TQLAYOUT(gb->tqlayout())); - l11->addWidget(m_stack); - - TQVBoxLayout *l12 = new TQVBoxLayout( 0, 0, 0 ); - l2->addSpacing( 10 ); - l2->addLayout( l12 ); - l12->addWidget( m_commentlab ); - l12->addWidget( m_comment ); - - connect(m_view, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotSelectionChanged(TQListViewItem*))); - connect(m_values, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotValueSelected(TQListViewItem*))); - connect(m_type, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged(int))); - connect(m_addval, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddValue())); - connect(m_delval, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveValue())); - connect(m_apply, TQT_SIGNAL(clicked()), TQT_SLOT(slotApplyChanges())); - connect(m_addgrp, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddGroup())); - connect(m_addopt, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddOption())); - connect(m_delopt, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveItem())); - connect(m_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotMoveUp())); - connect(m_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotMoveDown())); - connect(m_command, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotCommandChanged(const TQString&))); - connect(m_view, TQT_SIGNAL(itemRenamed(TQListViewItem*,int)), TQT_SLOT(slotOptionRenamed(TQListViewItem*,int))); - connect(m_desc, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_name, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_format, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_default, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_edit1, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_edit2, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_type, TQT_SIGNAL(activated(int)), TQT_SLOT(slotChanged())); - connect(m_addval, TQT_SIGNAL(clicked()), TQT_SLOT(slotChanged())); - connect(m_delval, TQT_SIGNAL(clicked()), TQT_SLOT(slotChanged())); - connect( m_persistent, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotChanged() ) ); - m_dummy->setEnabled(false); - viewItem(0); - - /** - * Add some short help for the normal (non expert) user - */ - TQWhatsThis::add( m_name, i18n( - "An identification string. Use only alphanumeric characters except spaces. " - "The string <b>__root__</b> is reserved for internal use." ) ); - TQWhatsThis::add( m_namelab, TQWhatsThis::textFor( m_name ) ); - TQWhatsThis::add( m_desc, i18n( - "A description string. This string is shown in the interface, and should " - "be explicit enough about the role of the corresponding option." ) ); - TQWhatsThis::add( m_desclab, TQWhatsThis::textFor( m_desc ) ); - TQWhatsThis::add( m_type, i18n( - "The type of the option. This determines how the option is presented " - "graphically to the user." ) ); - TQWhatsThis::add( m_typelab, TQWhatsThis::textFor( m_type ) ); - TQWhatsThis::add( m_format, i18n( - "The format of the option. This determines how the option is formatted " - "for inclusion in the global command line. The tag <b>%value</b> can be used " - "to represent the user selection. This tag will be replaced at run-time by a " - "string representation of the option value." ) ); - TQWhatsThis::add( m_formatlab, TQWhatsThis::textFor( m_format ) ); - TQWhatsThis::add( m_default, i18n( - "The default value of the option. For non persistent options, nothing is " - "added to the command line if the option has that default value. If this " - "value does not correspond to the actual default value of the underlying " - "utility, make the option persistent to avoid unwanted effects." ) ); - TQWhatsThis::add( m_defaultlab, TQWhatsThis::textFor( m_default ) ); - TQWhatsThis::add( m_persistent, i18n( - "Make the option persistent. A persistent option is always written to the " - "command line, whatever its value. This is useful when the chosen default " - "value does not match with the actual default value of the underlying utility." ) ); - TQWhatsThis::add( m_command, i18n( - "The full command line to execute the associated underlying utility. This " - "command line is based on a mechanism of tags that are replaced at run-time. " - "The supported tags are:<ul>" - "<li><b>%filterargs</b>: command options</li>" - "<li><b>%filterinput</b>: input specification</li>" - "<li><b>%filteroutput</b>: output specification</li>" - "<li><b>%psu</b>: the page size in upper case</li>" - "<li><b>%psl</b>: the page size in lower case</li></ul>" ) ); - TQWhatsThis::add( m_commandlab, TQWhatsThis::textFor( m_command ) ); - TQWhatsThis::add( m_inputfile, i18n( - "Input specification when the underlying utility reads input data from a file. Use " - "the tag <b>%in</b> to represent the input filename." ) ); - TQWhatsThis::add( m_inputfilelab, TQWhatsThis::textFor( m_inputfile ) ); - TQWhatsThis::add( m_outputfile, i18n( - "Output specification when the underlying utility writes output data to a file. Use " - "the tag <b>%out</b> to represent the output filename." ) ); - TQWhatsThis::add( m_outputfilelab, TQWhatsThis::textFor( m_outputfile ) ); - TQWhatsThis::add( m_inputpipe, i18n( - "Input specification when the underlying utility reads input data from its " - "standard input." ) ); - TQWhatsThis::add( m_inputpipelab, TQWhatsThis::textFor( m_inputpipe ) ); - TQWhatsThis::add( m_outputpipe, i18n( - "Output specification when the underlying utility writes output data to its " - "standard output." ) ); - TQWhatsThis::add( m_outputpipelab, TQWhatsThis::textFor( m_outputpipe ) ); - TQWhatsThis::add( m_comment, i18n( - "A comment about the underlying utility, which can be viewed by the user " - "from the interface. This comment string supports basic HTML tags like " - "<a>, <b> or <i>." ) ); - TQWhatsThis::add( m_commentlab, TQWhatsThis::textFor( m_comment ) ); - - resize(660, 200); -} - -KXmlCommandAdvancedDlg::~KXmlCommandAdvancedDlg() -{ - if (m_opts.count() > 0) - { - kdDebug() << "KXmlCommandAdvancedDlg: " << m_opts.count() << " items remaining" << endl; - for (TQMap<TQString,DrBase*>::ConstIterator it=m_opts.begin(); it!=m_opts.end(); ++it) - { - //kdDebug() << "Item: name=" << (*it)->name() << endl; - delete (*it); - } - } -} - -void KXmlCommandAdvancedDlg::setCommand(KXmlCommand *xmlcmd) -{ - m_xmlcmd = xmlcmd; - if (m_xmlcmd) - parseXmlCommand(m_xmlcmd); -} - -void KXmlCommandAdvancedDlg::parseXmlCommand(KXmlCommand *xmlcmd) -{ - m_view->clear(); - TQListViewItem *root = new TQListViewItem(m_view, xmlcmd->name(), xmlcmd->name()); - DrMain *driver = xmlcmd->driver(); - - root->setPixmap(0, SmallIcon("fileprint")); - root->setOpen(true); - if (driver) - { - DrMain *clone = driver->cloneDriver(); - if (!clone->get("text").isEmpty()) - root->setText(0, clone->get("text")); - root->setText(1, "__root__"); - clone->setName("__root__"); - m_opts["__root__"] = clone; - parseGroupItem(clone, root); - clone->flatten(); - } - m_command->setText(xmlcmd->command()); - m_inputfile->setText(xmlcmd->io(true, false)); - m_inputpipe->setText(xmlcmd->io(true, true)); - m_outputfile->setText(xmlcmd->io(false, false)); - m_outputpipe->setText(xmlcmd->io(false, true)); - m_comment->setText( xmlcmd->comment() ); - - viewItem(0); -} - -void KXmlCommandAdvancedDlg::parseGroupItem(DrGroup *grp, TQListViewItem *parent) -{ - TQListViewItem *item(0); - - TQPtrListIterator<DrGroup> git(grp->groups()); - for (; git.current(); ++git) - { - TQString namestr = git.current()->name(); - if (namestr.isEmpty()) - { - namestr = "group_"+kapp->randomString(4); - } - git.current()->setName(namestr); - item = new TQListViewItem(parent, item, git.current()->get("text"), git.current()->name()); - item->setPixmap(0, SmallIcon("folder")); - item->setOpen(true); - item->setRenameEnabled(0, true); - parseGroupItem(git.current(), item); - m_opts[namestr] = git.current(); - } - - TQPtrListIterator<DrBase> oit(grp->options()); - for (; oit.current(); ++oit) - { - TQString namestr = oit.current()->name().mid(m_xmlcmd->name().length()+6); - if (namestr.isEmpty()) - { - namestr = "option_"+kapp->randomString(4); - } - oit.current()->setName(namestr); - item = new TQListViewItem(parent, item, oit.current()->get("text"), namestr); - item->setPixmap(0, SmallIcon("document")); - item->setRenameEnabled(0, true); - m_opts[namestr] = oit.current(); - } -} - -void KXmlCommandAdvancedDlg::slotSelectionChanged(TQListViewItem *item) -{ - if (item && item->depth() == 0) - item = 0; - viewItem(item); -} - -void KXmlCommandAdvancedDlg::viewItem(TQListViewItem *item) -{ - m_dummy->setEnabled((item != 0)); - m_name->setText(""); - m_desc->setText(""); - m_format->setText(""); - m_default->setText(""); - m_values->clear(); - m_edit1->setText(""); - m_edit2->setText(""); - m_persistent->setChecked( false ); - int typeId(-1); - if (item) - { - m_name->setText(item->text(1)); - m_desc->setText(item->text(0)); - - DrBase *opt = (m_opts.contains(item->text(1)) ? m_opts[item->text(1)] : 0); - if (opt) - { - bool isgroup = (opt->type() < DrBase::String); - if (!isgroup) - { - m_type->setCurrentItem(opt->type() - DrBase::String); - typeId = m_type->currentItem(); - m_format->setText(opt->get("format")); - m_default->setText(opt->get("default")); - } - m_type->setEnabled(!isgroup); - m_default->setEnabled(!isgroup); - m_format->setEnabled(!isgroup); - m_stack->setEnabled(!isgroup); - - switch (opt->type()) - { - case DrBase::Float: - case DrBase::Integer: - m_edit1->setText(opt->get("minval")); - m_edit2->setText(opt->get("maxval")); - break; - case DrBase::Boolean: - case DrBase::List: - { - TQPtrListIterator<DrBase> it(*(static_cast<DrListOption*>(opt)->choices())); - TQListViewItem *item(0); - for (; it.current(); ++it) - { - item = new TQListViewItem(m_values, item, it.current()->name(), it.current()->get("text")); - item->setRenameEnabled(0, true); - item->setRenameEnabled(1, true); - } - break; - } - default: - break; - } - - m_addgrp->setEnabled(isgroup); - m_addopt->setEnabled(isgroup); - - TQListViewItem *prevItem = findPrev(item), *nextItem = findNext(item); - DrBase *prevOpt = (prevItem && m_opts.contains(prevItem->text(1)) ? m_opts[prevItem->text(1)] : 0); - DrBase *nextOpt = (nextItem && m_opts.contains(nextItem->text(1)) ? m_opts[nextItem->text(1)] : 0); - m_up->setEnabled(prevOpt && !(prevOpt->type() < DrBase::String && opt->type() >= DrBase::String)); - m_down->setEnabled(nextOpt && !(isgroup && nextOpt->type() >= DrBase::String)); - - m_persistent->setChecked( opt->get( "persistent" ) == "1" ); - } - - m_delopt->setEnabled(true); - m_dummy->setEnabled(opt); - } - else - { - m_delopt->setEnabled(false); - m_addopt->setEnabled(m_view->currentItem() && m_view->isEnabled()); - m_addgrp->setEnabled(m_view->currentItem() && m_view->isEnabled()); - m_up->setEnabled(false); - m_down->setEnabled(false); - } - slotTypeChanged(typeId); - m_apply->setEnabled(false); -} - -void KXmlCommandAdvancedDlg::slotTypeChanged(int ID) -{ - int wId(3); - ID += DrBase::String; - switch (ID) - { - case DrBase::Float: - case DrBase::Integer: - wId = 1; - break; - case DrBase::Boolean: - case DrBase::List: - wId = 2; - slotValueSelected(m_values->currentItem()); - break; - } - m_stack->raiseWidget(wId); -} - -void KXmlCommandAdvancedDlg::slotAddValue() -{ - TQListViewItem *item = new TQListViewItem(m_values, m_values->lastItem(), i18n("Name"), i18n("Description")); - item->setRenameEnabled(0, true); - item->setRenameEnabled(1, true); - m_values->ensureItemVisible(item); - slotValueSelected(item); - item->startRename(0); -} - -void KXmlCommandAdvancedDlg::slotRemoveValue() -{ - TQListViewItem *item = m_values->currentItem(); - if (item) - delete item; - slotValueSelected(m_values->currentItem()); -} - -void KXmlCommandAdvancedDlg::slotApplyChanges() -{ - TQListViewItem *item = m_view->currentItem(); - if (item) - { - if (m_name->text().isEmpty() || m_name->text() == "__root__") - { - KMessageBox::error(this, i18n("Invalid identification name. Empty strings and \"__root__\" are not allowed.")); - return; - } - - m_apply->setEnabled(false); - - DrBase *opt = (m_opts.contains(item->text(1)) ? m_opts[item->text(1)] : 0); - m_opts.remove(item->text(1)); - delete opt; - - // update tree item - item->setText(0, m_desc->text()); - item->setText(1, m_name->text()); - - // recreate option - if (m_type->isEnabled()) - { - int type = m_type->currentItem() + DrBase::String; - switch (type) - { - case DrBase::Integer: - case DrBase::Float: - if (type == DrBase::Integer) - opt = new DrIntegerOption; - else - opt = new DrFloatOption; - opt->set("minval", m_edit1->text()); - opt->set("maxval", m_edit2->text()); - break; - case DrBase::List: - case DrBase::Boolean: - { - if (type == DrBase::List) - opt = new DrListOption; - else - opt = new DrBooleanOption; - DrListOption *lopt = static_cast<DrListOption*>(opt); - TQListViewItem *item = m_values->firstChild(); - while (item) - { - DrBase *choice = new DrBase; - choice->setName(item->text(0)); - choice->set("text", item->text(1)); - lopt->addChoice(choice); - item = item->nextSibling(); - } - break; - } - case DrBase::String: - opt = new DrStringOption; - break; - - } - opt->set("format", m_format->text()); - opt->set("default", m_default->text()); - opt->setValueText(opt->get("default")); - } - else - opt = new DrGroup; - - opt->setName((m_name->text().isEmpty() ? generateId(m_opts) : m_name->text())); - opt->set("text", m_desc->text()); - opt->set( "persistent", m_persistent->isChecked() ? "1" : "0" ); - - m_opts[opt->name()] = opt; - } -} - -void KXmlCommandAdvancedDlg::slotChanged() -{ - m_apply->setEnabled(true); -} - -void KXmlCommandAdvancedDlg::slotAddGroup() -{ - if (m_view->currentItem()) - { - TQString ID = generateId(m_opts); - - DrGroup *grp = new DrGroup; - grp->setName(ID); - grp->set("text", i18n("New Group")); - m_opts[ID] = grp; - - TQListViewItem *item = new TQListViewItem(m_view->currentItem(), i18n("New Group"), ID); - item->setRenameEnabled(0, true); - item->setPixmap(0, SmallIcon("folder")); - m_view->ensureItemVisible(item); - item->startRename(0); - } -} - -void KXmlCommandAdvancedDlg::slotAddOption() -{ - if (m_view->currentItem()) - { - TQString ID = generateId(m_opts); - - DrBase *opt = new DrStringOption; - opt->setName(ID); - opt->set("text", i18n("New Option")); - m_opts[ID] = opt; - - TQListViewItem *item = new TQListViewItem(m_view->currentItem(), i18n("New Option"), ID); - item->setRenameEnabled(0, true); - item->setPixmap(0, SmallIcon("document")); - m_view->ensureItemVisible(item); - item->startRename(0); - } -} - -void KXmlCommandAdvancedDlg::slotRemoveItem() -{ - TQListViewItem *item = m_view->currentItem(); - if (item) - { - TQListViewItem *newCurrent(item->nextSibling()); - if (!newCurrent) - newCurrent = item->parent(); - removeItem(item); - delete item; - m_view->setSelected(newCurrent, true); - } -} - -void KXmlCommandAdvancedDlg::removeItem(TQListViewItem *item) -{ - delete m_opts[item->text(1)]; - m_opts.remove(item->text(1)); - TQListViewItem *child = item->firstChild(); - while (child && item) - { - removeItem(child); - if ( item ) - item = item->nextSibling(); - } -} - -void KXmlCommandAdvancedDlg::slotMoveUp() -{ - TQListViewItem *item = m_view->currentItem(), *prev = 0; - if (item && (prev=findPrev(item))) - { - TQListViewItem *after(0); - if ((after=findPrev(prev)) != 0) - item->moveItem(after); - else - { - TQListViewItem *parent = item->parent(); - parent->takeItem(item); - parent->insertItem(item); - } - m_view->setSelected(item, true); - slotSelectionChanged(item); - } -} - -void KXmlCommandAdvancedDlg::slotMoveDown() -{ - TQListViewItem *item = m_view->currentItem(), *next = 0; - if (item && (next=findNext(item))) - { - item->moveItem(next); - m_view->setSelected(item, true); - slotSelectionChanged(item); - } -} - -void KXmlCommandAdvancedDlg::slotCommandChanged(const TQString& cmd) -{ - m_inputfile->parentWidget()->setEnabled(cmd.find("%filterinput") != -1); - m_outputfile->parentWidget()->setEnabled(cmd.find("%filteroutput") != -1); - m_view->setEnabled(cmd.find("%filterargs") != -1); - m_name->parentWidget()->setEnabled(m_view->isEnabled()); - slotSelectionChanged((m_view->isEnabled() ? m_view->currentItem() : 0)); - m_view->setOpen(m_view->firstChild(), m_view->isEnabled()); -} - -void KXmlCommandAdvancedDlg::slotValueSelected(TQListViewItem *item) -{ - m_addval->setEnabled(m_type->currentItem() != 4 || m_values->childCount() < 2); - m_delval->setEnabled(item != 0); -} - -void KXmlCommandAdvancedDlg::slotOptionRenamed(TQListViewItem *item, int) -{ - if (item && m_opts.contains(item->text(1))) - { - DrBase *opt = m_opts[item->text(1)]; - opt->set("text", item->text(0)); - slotSelectionChanged(item); - } -} - -void KXmlCommandAdvancedDlg::recreateGroup(TQListViewItem *item, DrGroup *grp) -{ - if (!item) - return; - - TQListViewItem *child = item->firstChild(); - while (child) - { - DrBase *opt = (m_opts.contains(child->text(1)) ? m_opts[child->text(1)] : 0); - if (opt) - { - if (opt->type() == DrBase::Group) - { - DrGroup *childGroup = static_cast<DrGroup*>(opt); - recreateGroup(child, childGroup); - grp->addGroup(childGroup); - } - else - { - opt->setName("_kde-"+m_xmlcmd->name()+"-"+opt->name()); - grp->addOption(opt); - } - m_opts.remove(child->text(1)); - } - child = child->nextSibling(); - } -} - -bool KXmlCommandAdvancedDlg::editCommand(KXmlCommand *xmlcmd, TQWidget *parent) -{ - if (!xmlcmd) - return false; - - KDialogBase dlg(parent, 0, true, i18n("Command Edit for %1").arg(xmlcmd->name()), KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false); - KXmlCommandAdvancedDlg *xmldlg = new KXmlCommandAdvancedDlg(&dlg); - dlg.setMainWidget(xmldlg); - //dlg.enableButton(KDialogBase::Ok, false); - xmldlg->setCommand(xmlcmd); - if (dlg.exec()) - { - xmlcmd->setCommand(xmldlg->m_command->text()); - xmlcmd->setIo(xmldlg->m_inputfile->text(), true, false); - xmlcmd->setIo(xmldlg->m_inputpipe->text(), true, true); - xmlcmd->setIo(xmldlg->m_outputfile->text(), false, false); - xmlcmd->setIo(xmldlg->m_outputpipe->text(), false, true); - xmlcmd->setComment( xmldlg->m_comment->text().replace( TQRegExp( "\n" ), " " ) ); - - // need to recreate the driver tree structure - DrMain *driver = (xmldlg->m_opts.contains("__root__") ? static_cast<DrMain*>(xmldlg->m_opts["__root__"]) : 0); - if (!driver && xmldlg->m_opts.count() > 0) - { - kdDebug() << "KXmlCommandAdvancedDlg: driver structure not found, creating one" << endl; - driver = new DrMain; - driver->setName(xmlcmd->name()); - } - xmldlg->recreateGroup(xmldlg->m_view->firstChild(), driver); - xmldlg->m_opts.remove("__root__"); - xmlcmd->setDriver(driver); - - // remaining options will be removed in destructor - - return true; - } - return false; -} - -//----------------------------------------------------------------------------------------------------- - -KXmlCommandDlg::KXmlCommandDlg(TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, TQString::null, Ok|Cancel|Details, Ok, true) -{ - setButtonText(Details, i18n("&Mime Type Settings")); - m_cmd = 0; - - TQWidget *dummy = new TQWidget(this, "TopDetail"); - TQWidget *topmain = new TQWidget(this, "TopMain"); - - TQGroupBox *m_gb1 = new TQGroupBox(0, Qt::Horizontal, i18n("Supported &Input Formats"), dummy); - TQGroupBox *m_gb2 = new TQGroupBox(0, Qt::Horizontal, i18n("Requirements"), topmain); - - m_description = new TQLineEdit(topmain); - m_idname = new TQLabel(topmain); - m_requirements = new KListView(m_gb2); - m_requirements->addColumn(""); - m_requirements->header()->hide(); - m_addreq = new TQToolButton(m_gb2); - m_addreq->setIconSet(SmallIconSet("filenew")); - m_removereq = new TQToolButton(m_gb2); - m_removereq->setIconSet(SmallIconSet("editdelete")); - TQPushButton *m_edit = new KPushButton(KGuiItem(i18n("&Edit Command..."), "edit"), topmain); - m_mimetype = new TQComboBox(dummy); - m_availablemime = new KListBox(m_gb1); - m_selectedmime = new KListBox(m_gb1); - m_addmime = new TQToolButton(m_gb1); - m_addmime->setIconSet(TQApplication::reverseLayout()? SmallIconSet("forward") : SmallIconSet("back")); - m_removemime = new TQToolButton(m_gb1); - m_removemime->setIconSet(TQApplication::reverseLayout()? SmallIconSet("back" ) : SmallIconSet("forward")); - m_gb2->setMinimumWidth(380); - m_gb1->setMinimumHeight(180); - m_requirements->setMaximumHeight(80); - m_removereq->setEnabled(false); - m_addmime->setEnabled(false); - m_removemime->setEnabled(false); - - TQLabel *m_desclab = new TQLabel(i18n("&Description:"), topmain); - m_desclab->setBuddy(m_description); - TQLabel *m_mimetypelab = new TQLabel(i18n("Output &format:"), dummy); - m_mimetypelab->setBuddy(m_mimetype); - TQLabel *m_idnamelab = new TQLabel(i18n("ID name:"), topmain); - - TQFont f(m_idname->font()); - f.setBold(true); - m_idname->setFont(f); - - KSeparator *sep1 = new KSeparator(TQFrame::HLine, dummy); - - TQVBoxLayout *l0 = new TQVBoxLayout(topmain, 0, 10); - TQGridLayout *l5 = new TQGridLayout(0, 2, 2, 0, 5); - l0->addLayout(TQT_TQLAYOUT(l5)); - l5->addWidget(m_idnamelab, 0, 0); - l5->addWidget(m_idname, 0, 1); - l5->addWidget(m_desclab, 1, 0); - l5->addWidget(m_description, 1, 1); - l0->addWidget(m_gb2); - TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, 0); - l0->addLayout(l3); - l3->addWidget(m_edit); - l3->addStretch(1); - - TQVBoxLayout *l7 = new TQVBoxLayout(dummy, 0, 10); - TQHBoxLayout *l6 = new TQHBoxLayout(0, 0, 5); - l7->addWidget(sep1); - l7->addLayout(l6); - l6->addWidget(m_mimetypelab, 0); - l6->addWidget(m_mimetype, 1); - l7->addWidget(m_gb1); - TQGridLayout *l2 = new TQGridLayout(TQT_TQLAYOUT(m_gb1->tqlayout()), 4, 3, 10); - l2->addMultiCellWidget(m_availablemime, 0, 3, 2, 2); - l2->addMultiCellWidget(m_selectedmime, 0, 3, 0, 0); - l2->addWidget(m_addmime, 1, 1); - l2->addWidget(m_removemime, 2, 1); - l2->setRowStretch(0, 1); - l2->setRowStretch(3, 1); - TQHBoxLayout *l4 = new TQHBoxLayout(TQT_TQLAYOUT(m_gb2->tqlayout()), 10); - l4->addWidget(m_requirements); - TQVBoxLayout *l8 = new TQVBoxLayout(0, 0, 0); - l4->addLayout(l8); - l8->addWidget(m_addreq); - l8->addWidget(m_removereq); - l8->addStretch(1); - - connect(m_addmime, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddMime())); - connect(m_removemime, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveMime())); - connect(m_edit, TQT_SIGNAL(clicked()), TQT_SLOT(slotEditCommand())); - connect(m_requirements, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotReqSelected(TQListViewItem*))); - connect(m_availablemime, TQT_SIGNAL(selectionChanged(TQListBoxItem*)), TQT_SLOT(slotAvailableSelected(TQListBoxItem*))); - connect(m_selectedmime, TQT_SIGNAL(selectionChanged(TQListBoxItem*)), TQT_SLOT(slotSelectedSelected(TQListBoxItem*))); - connect(m_addreq, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddReq())); - connect(m_removereq, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemoveReq())); - - KMimeType::List list = KMimeType::allMimeTypes(); - for (TQValueList<KMimeType::Ptr>::ConstIterator it=list.begin(); it!=list.end(); ++it) - { - TQString mimetype = (*it)->name(); - m_mimelist << mimetype; - } - - m_mimelist.sort(); - m_mimetype->insertStringList(m_mimelist); - m_availablemime->insertStringList(m_mimelist); - - setMainWidget(topmain); - setDetailsWidget(dummy); -} - -void KXmlCommandDlg::setCommand(KXmlCommand *xmlCmd) -{ - setCaption(i18n("Command Edit for %1").arg(xmlCmd->name())); - - m_cmd = xmlCmd; - m_description->setText(i18n(xmlCmd->description().utf8())); - m_idname->setText(xmlCmd->name()); - - m_requirements->clear(); - TQStringList list = xmlCmd->requirements(); - TQListViewItem *item(0); - for (TQStringList::ConstIterator it=list.begin(); it!=list.end(); ++it) - { - item = new TQListViewItem(m_requirements, item, *it); - item->setRenameEnabled(0, true); - } - - int index = m_mimelist.findIndex(xmlCmd->mimeType()); - if (index != -1) - m_mimetype->setCurrentItem(index); - else - m_mimetype->setCurrentItem(0); - - list = xmlCmd->inputMimeTypes(); - m_selectedmime->clear(); - m_availablemime->clear(); - m_availablemime->insertStringList(m_mimelist); - for (TQStringList::ConstIterator it=list.begin(); it!=list.end(); ++it) - { - m_selectedmime->insertItem(*it); - delete m_availablemime->findItem(*it, TQt::ExactMatch); - } -} - -void KXmlCommandDlg::slotOk() -{ - if (m_cmd) - { - m_cmd->setMimeType((m_mimetype->currentText() == "all/all" ? TQString::null : m_mimetype->currentText())); - m_cmd->setDescription(m_description->text()); - TQStringList l; - TQListViewItem *item = m_requirements->firstChild(); - while (item) - { - l << item->text(0); - item = item->nextSibling(); - } - m_cmd->setRequirements(l); - l.clear(); - for (uint i=0; i<m_selectedmime->count(); i++) - l << m_selectedmime->text(i); - m_cmd->setInputMimeTypes(l); - } - KDialogBase::slotOk(); -} - -bool KXmlCommandDlg::editCommand(KXmlCommand *xmlCmd, TQWidget *parent) -{ - if (!xmlCmd) - return false; - - KXmlCommandDlg xmldlg(parent, 0); - xmldlg.setCommand(xmlCmd); - - return (xmldlg.exec() == Accepted); -} - -void KXmlCommandDlg::slotAddMime() -{ - int index = m_availablemime->currentItem(); - if (index != -1) - { - m_selectedmime->insertItem(m_availablemime->currentText()); - m_availablemime->removeItem(index); - m_selectedmime->sort(); - } -} - -void KXmlCommandDlg::slotRemoveMime() -{ - int index = m_selectedmime->currentItem(); - if (index != -1) - { - m_availablemime->insertItem(m_selectedmime->currentText()); - m_selectedmime->removeItem(index); - m_availablemime->sort(); - } -} - -void KXmlCommandDlg::slotEditCommand() -{ - KXmlCommandAdvancedDlg::editCommand(m_cmd, parentWidget()); -} - -void KXmlCommandDlg::slotAddReq() -{ - TQListViewItem *item = new TQListViewItem(m_requirements, m_requirements->lastItem(), i18n("exec:/")); - item->setRenameEnabled(0, true); - m_requirements->ensureItemVisible(item); - item->startRename(0); -} - -void KXmlCommandDlg::slotRemoveReq() -{ - delete m_requirements->currentItem(); -} - -void KXmlCommandDlg::slotReqSelected(TQListViewItem *item) -{ - m_removereq->setEnabled(item); -} - -void KXmlCommandDlg::slotAvailableSelected(TQListBoxItem *item) -{ - m_addmime->setEnabled(item); -} - -void KXmlCommandDlg::slotSelectedSelected(TQListBoxItem *item) -{ - m_removemime->setEnabled(item); -} - -#include "kxmlcommanddlg.moc" diff --git a/kdeprint/management/kxmlcommanddlg.h b/kdeprint/management/kxmlcommanddlg.h deleted file mode 100644 index 88e590325..000000000 --- a/kdeprint/management/kxmlcommanddlg.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KXMLCOMMANDDLG_H -#define KXMLCOMMANDDLG_H - -#include <tqwidget.h> -#include <tqmap.h> -#include <tqstringlist.h> -#include <kdialogbase.h> - -class KListView; -class TQListViewItem; -class TQLineEdit; -class TQComboBox; -class TQWidgetStack; -class TQToolButton; -class KListBox; -class TQListBoxItem; -class TQTextEdit; -class TQCheckBox; - -class DrGroup; -class DrBase; -class KXmlCommand; - -class KXmlCommandAdvancedDlg : public TQWidget -{ - Q_OBJECT -public: - KXmlCommandAdvancedDlg(TQWidget *parent = 0, const char *name = 0); - ~KXmlCommandAdvancedDlg(); - - void setCommand(KXmlCommand*); - static bool editCommand(KXmlCommand *xmlcmd, TQWidget *parent = 0); - -protected: - void parseGroupItem(DrGroup*, TQListViewItem*); - void parseXmlCommand(KXmlCommand*); - void viewItem(TQListViewItem*); - void removeItem(TQListViewItem*); - void recreateGroup(TQListViewItem*, DrGroup*); - -protected slots: - void slotSelectionChanged(TQListViewItem*); - void slotTypeChanged(int); - void slotAddValue(); - void slotRemoveValue(); - void slotApplyChanges(); - void slotAddGroup(); - void slotAddOption(); - void slotRemoveItem(); - void slotMoveUp(); - void slotMoveDown(); - void slotCommandChanged(const TQString&); - void slotValueSelected(TQListViewItem*); - void slotOptionRenamed(TQListViewItem*, int); - void slotChanged(); - -private: - KListView *m_view; - TQLineEdit *m_name, *m_desc, *m_format, *m_default, *m_command; - TQComboBox *m_type; - TQWidget *m_dummy; - KListView *m_values; - TQLineEdit *m_edit1, *m_edit2; - TQWidgetStack *m_stack; - TQToolButton *m_apply, *m_addgrp, *m_addopt, *m_delopt, *m_up, *m_down; - TQLineEdit *m_inputfile, *m_inputpipe, *m_outputfile, *m_outputpipe; - TQToolButton *m_addval, *m_delval; - TQTextEdit *m_comment; - TQCheckBox *m_persistent; - - KXmlCommand *m_xmlcmd; - TQMap<TQString, DrBase*> m_opts; -}; - -class KXmlCommandDlg : public KDialogBase -{ - Q_OBJECT -public: - KXmlCommandDlg(TQWidget *parent = 0, const char *name = 0); - - void setCommand(KXmlCommand*); - static bool editCommand(KXmlCommand*, TQWidget *parent = 0); - -protected slots: - void slotAddMime(); - void slotRemoveMime(); - void slotEditCommand(); - void slotAddReq(); - void slotRemoveReq(); - void slotReqSelected(TQListViewItem*); - void slotAvailableSelected(TQListBoxItem*); - void slotSelectedSelected(TQListBoxItem*); - void slotOk(); - -private: - TQLineEdit *m_description; - TQLabel *m_idname; - TQComboBox *m_mimetype; - KListBox *m_availablemime, *m_selectedmime; - TQToolButton *m_addmime, *m_removemime; - KListView *m_requirements; - TQToolButton *m_removereq, *m_addreq; - - TQStringList m_mimelist; - KXmlCommand *m_cmd; -}; - -#endif diff --git a/kdeprint/management/kxmlcommandselector.cpp b/kdeprint/management/kxmlcommandselector.cpp deleted file mode 100644 index dfefe0a8b..000000000 --- a/kdeprint/management/kxmlcommandselector.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kxmlcommandselector.h" -#include "kxmlcommand.h" -#include "kxmlcommanddlg.h" -#include "tdeprintcheck.h" - -#include <tqcombobox.h> -#include <kpushbutton.h> -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqlayout.h> -#include <tqtooltip.h> -#include <tqlineedit.h> -#include <kinputdialog.h> -#include <klocale.h> -#include <kiconloader.h> -#include <kmessagebox.h> -#include <kfiledialog.h> -#include <kseparator.h> -#include <kguiitem.h> -#include <kactivelabel.h> -#include <kdatetbl.h> -#include <kdialogbase.h> - -KXmlCommandSelector::KXmlCommandSelector(bool canBeNull, TQWidget *parent, const char *name, KDialogBase *dlg) -: TQWidget(parent, name) -{ - m_cmd = new TQComboBox(this); - connect(m_cmd, TQT_SIGNAL(activated(int)), TQT_SLOT(slotCommandSelected(int))); - TQPushButton *m_add = new KPushButton(this); - TQPushButton *m_edit = new KPushButton(this); - m_add->setPixmap(SmallIcon("filenew")); - m_edit->setPixmap(SmallIcon("configure")); - connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddCommand())); - connect(m_edit, TQT_SIGNAL(clicked()), TQT_SLOT(slotEditCommand())); - TQToolTip::add(m_add, i18n("New command")); - TQToolTip::add(m_edit, i18n("Edit command")); - m_shortinfo = new TQLabel(this); - m_helpbtn = new KPushButton( this ); - m_helpbtn->setIconSet( SmallIconSet( "help" ) ); - connect( m_helpbtn, TQT_SIGNAL( clicked() ), TQT_SLOT( slotHelpCommand() ) ); - TQToolTip::add( m_helpbtn, i18n( "Information" ) ); - m_helpbtn->setEnabled( false ); - - m_line = 0; - m_usefilter = 0; - TQPushButton *m_browse = 0; - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 10); - - if (canBeNull) - { - m_line = new TQLineEdit(this); - m_browse = new KPushButton(KGuiItem(i18n("&Browse..."), "fileopen"), this); - m_usefilter = new TQCheckBox(i18n("Use co&mmand:"), this); - connect(m_browse, TQT_SIGNAL(clicked()), TQT_SLOT(slotBrowse())); - connect(m_usefilter, TQT_SIGNAL(toggled(bool)), m_line, TQT_SLOT(setDisabled(bool))); - connect(m_usefilter, TQT_SIGNAL(toggled(bool)), m_browse, TQT_SLOT(setDisabled(bool))); - connect(m_usefilter, TQT_SIGNAL(toggled(bool)), m_cmd, TQT_SLOT(setEnabled(bool))); - connect(m_usefilter, TQT_SIGNAL(toggled(bool)), m_add, TQT_SLOT(setEnabled(bool))); - connect(m_usefilter, TQT_SIGNAL(toggled(bool)), m_edit, TQT_SLOT(setEnabled(bool))); - connect(m_usefilter, TQT_SIGNAL(toggled(bool)), m_shortinfo, TQT_SLOT(setEnabled(bool))); - connect( m_usefilter, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( slotXmlCommandToggled( bool ) ) ); - m_usefilter->setChecked(true); - m_usefilter->setChecked(false); - //setFocusProxy(m_line); - setTabOrder(m_usefilter, m_cmd); - setTabOrder(m_cmd, m_add); - setTabOrder(m_add, m_edit); - - TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 10); - l0->addLayout(l1); - l1->addWidget(m_line); - l1->addWidget(m_browse); - - KSeparator *sep = new KSeparator(Qt::Horizontal, this); - l0->addWidget(sep); - } - else - setFocusProxy(m_cmd); - - TQGridLayout *l2 = new TQGridLayout(0, 2, (m_usefilter?3:2), 0, 5); - int c(0); - l0->addLayout(TQT_TQLAYOUT(l2)); - if (m_usefilter) - { - l2->addWidget(m_usefilter, 0, c++); - } - l2->addWidget(m_cmd, 0, c); - TQHBoxLayout *l4 = new TQHBoxLayout( 0, 0, 5 ); - l2->addLayout( l4, 1, c ); - l4->addWidget( m_helpbtn, 0 ); - l4->addWidget( m_shortinfo, 1 ); - TQHBoxLayout *l3 = new TQHBoxLayout(0, 0, 0); - l2->addLayout(l3, 0, c+1); - l3->addWidget(m_add); - l3->addWidget(m_edit); - - if ( dlg ) - connect( this, TQT_SIGNAL( commandValid( bool ) ), dlg, TQT_SLOT( enableButtonOK( bool ) ) ); - - loadCommands(); -} - -void KXmlCommandSelector::loadCommands() -{ - TQString thisCmd = (m_cmd->currentItem() != -1 ? m_cmdlist[m_cmd->currentItem()] : TQString::null); - - m_cmd->clear(); - m_cmdlist.clear(); - - TQStringList list = KXmlCommandManager::self()->commandListWithDescription(); - TQStringList desclist; - for (TQStringList::Iterator it=list.begin(); it!=list.end(); ++it) - { - m_cmdlist << (*it); - ++it; - desclist << (*it); - } - m_cmd->insertStringList(desclist); - - int index = m_cmdlist.findIndex(thisCmd); - if (index != -1) - m_cmd->setCurrentItem(index); - if (m_cmd->currentItem() != -1 && m_cmd->isEnabled()) - slotCommandSelected(m_cmd->currentItem()); -} - -TQString KXmlCommandSelector::command() const -{ - TQString cmd; - if (m_line && !m_usefilter->isChecked()) - cmd = m_line->text(); - else - cmd = m_cmdlist[m_cmd->currentItem()]; - return cmd; -} - -void KXmlCommandSelector::setCommand(const TQString& cmd) -{ - int index = m_cmdlist.findIndex(cmd); - - if (m_usefilter) - m_usefilter->setChecked(index != -1); - if (m_line) - m_line->setText((index == -1 ? cmd : TQString::null)); - if (index != -1) - m_cmd->setCurrentItem(index); - if (m_cmd->currentItem() != -1 && m_cmd->isEnabled()) - slotCommandSelected(m_cmd->currentItem()); -} - -void KXmlCommandSelector::slotAddCommand() -{ - bool ok(false); - TQString cmdId = KInputDialog::getText(i18n("Command Name"), i18n("Enter an identification name for the new command:"), TQString::null, &ok, this); - if (ok) - { - bool added(true); - - if (m_cmdlist.findIndex(cmdId) != -1) - { - if (KMessageBox::warningContinueCancel( - this, - i18n("A command named %1 already exists. Do you want " - "to continue and edit the existing one?").arg(cmdId), - TQString::null, - KStdGuiItem::cont()) == KMessageBox::Cancel) - { - return; - } - else - added = false; - } - - KXmlCommand *xmlCmd = KXmlCommandManager::self()->loadCommand(cmdId); - if (KXmlCommandDlg::editCommand(xmlCmd, this)) - KXmlCommandManager::self()->saveCommand(xmlCmd); - - if (added) - loadCommands(); - } -} - -void KXmlCommandSelector::slotEditCommand() -{ - TQString xmlId = m_cmdlist[m_cmd->currentItem()]; - KXmlCommand *xmlCmd = KXmlCommandManager::self()->loadCommand(xmlId); - if (xmlCmd) - { - if (KXmlCommandDlg::editCommand(xmlCmd, this)) - { - // force to load the driver if not already done - xmlCmd->driver(); - KXmlCommandManager::self()->saveCommand(xmlCmd); - } - m_cmd->changeItem(xmlCmd->description(), m_cmd->currentItem()); - delete xmlCmd; - slotCommandSelected(m_cmd->currentItem()); - } - else - KMessageBox::error(this, i18n("Internal error. The XML driver for the command %1 could not be found.").arg(xmlId)); -} - -void KXmlCommandSelector::slotBrowse() -{ - TQString filename = KFileDialog::getOpenFileName(TQString::null, TQString::null, this); - if (!filename.isEmpty() && m_line) - m_line->setText(filename); -} - -void KXmlCommandSelector::slotCommandSelected(int ID) -{ - KXmlCommand *xmlCmd = KXmlCommandManager::self()->loadCommand(m_cmdlist[ID], true); - if (xmlCmd) - { - TQString msg; - if ( xmlCmd->isValid() && KdeprintChecker::check( xmlCmd->requirements() ) ) - { - msg = TQString::fromLocal8Bit("(ID = %1, %2 = ").arg(xmlCmd->name()).arg(i18n("output")); - if (KXmlCommandManager::self()->checkCommand(xmlCmd->name(), KXmlCommandManager::None, KXmlCommandManager::Basic)) - { - if (xmlCmd->mimeType() == "all/all") - msg.append(i18n("undefined")); - else - msg.append(xmlCmd->mimeType()); - } - else - msg.append(i18n("not allowed")); - msg.append(")"); - emit commandValid( true ); - } - else - { - msg = "<font color=\"red\">" + i18n( "(Unavailable: requirements not satisfied)" ) + "</font>"; - emit commandValid( false ); - } - m_shortinfo->setText(msg); - m_help = xmlCmd->comment(); - m_helpbtn->setEnabled( !m_help.isEmpty() ); - } - delete xmlCmd; -} - -void KXmlCommandSelector::slotXmlCommandToggled( bool on ) -{ - if ( on ) - slotCommandSelected( m_cmd->currentItem() ); - else - { - emit commandValid( true ); - m_shortinfo->setText( TQString::null ); - } -} - -void KXmlCommandSelector::slotHelpCommand() -{ - KPopupFrame *pop = new KPopupFrame( m_helpbtn ); - KActiveLabel *lab = new KActiveLabel( m_help, pop ); - lab->resize( lab->tqsizeHint() ); - pop->setMainWidget( lab ); - pop->exec( m_helpbtn->mapToGlobal( TQPoint( m_helpbtn->width(), 0 ) ) ); - pop->close( 0 ); - delete pop; -} - -#include "kxmlcommandselector.moc" diff --git a/kdeprint/management/kxmlcommandselector.h b/kdeprint/management/kxmlcommandselector.h deleted file mode 100644 index 0efc299f9..000000000 --- a/kdeprint/management/kxmlcommandselector.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KXMLCOMMANDSELECTOR_H -#define KXMLCOMMANDSELECTOR_H - -#include <tqwidget.h> -#include <tqstringlist.h> - -#include <kdelibs_export.h> - -class TQComboBox; -class TQLineEdit; -class TQCheckBox; -class TQLabel; -class TQPushButton; -class KDialogBase; - -class KDEPRINT_EXPORT KXmlCommandSelector : public TQWidget -{ - Q_OBJECT -public: - KXmlCommandSelector(bool canBeNull = true, TQWidget *parent = 0, const char *name = 0, KDialogBase *dlg = 0); - - void setCommand(const TQString&); - TQString command() const; - -protected: - void loadCommands(); - -protected slots: - void slotAddCommand(); - void slotEditCommand(); - void slotBrowse(); - void slotCommandSelected(int); - void slotHelpCommand(); - void slotXmlCommandToggled( bool ); - -signals: - void commandValid( bool ); - -private: - TQComboBox *m_cmd; - TQLineEdit *m_line; - TQCheckBox *m_usefilter; - TQStringList m_cmdlist; - TQLabel *m_shortinfo; - TQPushButton *m_helpbtn; - TQString m_help; -}; - -#endif diff --git a/kdeprint/management/networkscanner.cpp b/kdeprint/management/networkscanner.cpp deleted file mode 100644 index a52e66018..000000000 --- a/kdeprint/management/networkscanner.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -#define USE_QSOCKET - -#include "networkscanner.h" - -#include <tqprogressbar.h> -#include <kpushbutton.h> -#include <tqlayout.h> -#include <tqtimer.h> -#include <tqlabel.h> -#include <tqcombobox.h> -#include <tqlineedit.h> -#include <tqregexp.h> -#include <tqsocket.h> -#include <klocale.h> -#include <kextendedsocket.h> -#include <kmessagebox.h> -#include <knumvalidator.h> -#include <kdebug.h> -#include <unistd.h> - -class NetworkScanner::NetworkScannerPrivate -{ -public: - int port; - TQString prefixaddress; - int currentaddress; - int timeout; - bool scanning; - TQPtrList<NetworkScanner::SocketInfo> printers; - - TQProgressBar *bar; - KPushButton *scan, *settings; - TQLabel *subnetlab; - TQTimer *timer; -#ifdef USE_QSOCKET - TQSocket *socket; -#else - KExtendedSocket *socket; -#endif - - NetworkScannerPrivate( int portvalue ) : port( portvalue ) - { - prefixaddress = localPrefix(); - currentaddress = 1; - timeout = 50; - scanning = false; - printers.setAutoDelete( true ); - } - TQString localPrefix(); - TQString scanString(); -}; - -TQString NetworkScanner::NetworkScannerPrivate::localPrefix() -{ - char buf[256]; - buf[0] = '\0'; - if (!gethostname(buf, sizeof(buf))) - buf[sizeof(buf)-1] = '\0'; - TQPtrList<KAddressInfo> infos = KExtendedSocket::lookup(buf, TQString::null); - infos.setAutoDelete(true); - if (infos.count() > 0) - { - TQString IPstr = infos.first()->address()->nodeName(); - int p = IPstr.findRev('.'); - IPstr.truncate(p); - return IPstr; - } - return TQString::null; -} - -TQString NetworkScanner::NetworkScannerPrivate::scanString() -{ - TQString s = prefixaddress + ".*"; - if ( port != -1 ) - s.append( ":" ).append( TQString::number( port ) ); - return s; -} - -NetworkScanner::NetworkScanner( int port, TQWidget *parent, const char *name ) - : TQWidget( parent, name ) -{ - d = new NetworkScannerPrivate( port ); - d->bar = new TQProgressBar( 256, this ); - d->settings = new KPushButton( KGuiItem( i18n( "&Settings" ), "configure" ), this ); - d->scan = new KPushButton( KGuiItem( i18n( "Sc&an" ), "viewmag" ), this ); - d->timer = new TQTimer( this ); -#ifdef USE_QSOCKET - d->socket = new TQSocket( TQT_TQOBJECT(this) ); -#else - d->socket = new KExtendedSocket(); -#endif - TQLabel *label = new TQLabel( i18n( "Network scan:" ), this ); - d->subnetlab = new TQLabel( i18n( "Subnet: %1" ).arg( d->scanString() ), this ); - - TQGridLayout *l0 = new TQGridLayout( this, 4, 2, 0, 10 ); - l0->addMultiCellWidget( label, 0, 0, 0, 1 ); - l0->addMultiCellWidget( d->bar, 1, 1, 0, 1 ); - l0->addMultiCellWidget( d->subnetlab, 2, 2, 0, 1 ); - l0->addWidget( d->settings, 3, 0 ); - l0->addWidget( d->scan, 3, 1 ); - - connect( d->timer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotTimeout() ) ); - connect( d->settings, TQT_SIGNAL( clicked() ), TQT_SLOT( slotSettingsClicked() ) ); - connect( d->scan, TQT_SIGNAL( clicked() ), TQT_SLOT( slotScanClicked() ) ); -#ifdef USE_QSOCKET - connect( d->socket, TQT_SIGNAL( connected() ), TQT_SLOT( slotConnectionSuccess() ) ); - connect( d->socket, TQT_SIGNAL( error( int ) ), TQT_SLOT( slotConnectionFailed( int ) ) ); -#else - connect( d->socket, TQT_SIGNAL( connectionSuccess() ), TQT_SLOT( slotConnectionSuccess() ) ); - connect( d->socket, TQT_SIGNAL( connectionFailed( int ) ), TQT_SLOT( slotConnectionFailed( int ) ) ); -#endif -} - -NetworkScanner::~NetworkScanner() -{ -#ifndef USE_QSOCKET - delete d->socket; -#endif - delete d; -} - -void NetworkScanner::start() -{ - if ( d->scanning ) - return; - - d->printers.clear(); - emit scanStarted(); - d->settings->setEnabled( false ); - d->scan->setGuiItem( KGuiItem( i18n( "&Abort" ), "stop" ) ); - d->currentaddress = -1; - d->scanning = true; - next(); -} - -void NetworkScanner::slotScanClicked() -{ - if ( !d->scanning ) - { - if ( d->localPrefix() == d->prefixaddress || - KMessageBox::warningContinueCancel( this->parentWidget(), - i18n( "You are about to scan a subnet (%1.*) that does not " - "correspond to the current subnet of this computer (%2.*). Do you want " - "to scan the specified subnet anyway?" ).arg( d->prefixaddress ).arg( d->localPrefix() ), - TQString::null, KGuiItem( i18n( "&Scan" ), "viewmag" ), "askForScan" ) == KMessageBox::Continue ) - start(); - } - else - { -#ifdef USE_QSOCKET - d->socket->close(); -#else - d->socket->cancelAsyncConnect(); -#endif - finish(); - } -} - -void NetworkScanner::finish() -{ - if ( !d->scanning ) - return; - - d->settings->setEnabled( true ); - d->scan->setGuiItem( KGuiItem( i18n( "Sc&an" ), "viewmag" ) ); - d->bar->reset(); - d->scanning = false; - emit scanFinished(); -} - -void NetworkScanner::slotSettingsClicked() -{ - NetworkScannerConfig dlg( this ); - dlg.exec(); -} - -void NetworkScanner::slotNext() -{ - if ( !d->scanning ) - return; - - d->timer->stop(); -#ifdef USE_QSOCKET - d->socket->connectToHost( d->prefixaddress + "." + TQString::number( d->currentaddress ), d->port ); - kdDebug() << "Address: " << d->socket->peerName() << ", Port: " << d->socket->peerPort() << endl; -#else - d->socket->setAddress( d->prefixaddress + "." + TQString::number( d->currentaddress ), d->port ); - d->socket->startAsyncLookup(); - kdDebug() << "Address: " << d->socket->host() << ", Port: " << d->socket->port() << endl; -#endif - d->timer->start( d->timeout, true ); -} - -void NetworkScanner::next() -{ - //kdDebug() << "Next" << endl; - d->currentaddress++; - if ( d->currentaddress >= 256 ) - finish(); - else - { - d->bar->setProgress( d->currentaddress ); - TQTimer::singleShot( 0, this, TQT_SLOT( slotNext() ) ); - } -} - -void NetworkScanner::slotTimeout() -{ - kdDebug() << "Timeout" << endl; - if ( !d->scanning ) - return; - -#ifdef USE_QSOCKET - d->socket->close(); -#else - d->socket->cancelAsyncConnect(); -#endif - next(); -} - -void NetworkScanner::slotConnectionSuccess() -{ - kdDebug() << "Success" << endl; -#ifdef USE_QSOCKET - KSocketAddress *addr = KExtendedSocket::peerAddress( d->socket->socket() ); -#else - KSocketAddress *addr = const_cast<KSocketAddress*>( d->socket->peerAddress() ); -#endif - kdDebug() << "Connection success: " << ( addr ? addr->pretty() : TQString( "ERROR" ) ) << endl; - kdDebug() << "Socket: " << d->socket->socket() << endl; - if ( addr ) - { - SocketInfo *info = new SocketInfo; -#ifdef USE_QSOCKET - info->IP = d->socket->peerName(); -#else - info->IP = d->socket->host(); -#endif - info->Port = d->port; - TQString portname; - KExtendedSocket::resolve( addr, info->Name, portname ); - d->printers.append( info ); - d->socket->close(); - delete addr; - } - else - kdDebug() << "Unconnected socket, skipping" << endl; - next(); -} - -void NetworkScanner::slotConnectionFailed( int ) -{ - kdDebug() << "Failure" << endl; - next(); -} - -const TQPtrList<NetworkScanner::SocketInfo>* NetworkScanner::printerList() -{ - return &( d->printers ); -} - -int NetworkScanner::timeout() const -{ - return d->timeout; -} - -void NetworkScanner::setTimeout( int to ) -{ - d->timeout = to; -} - -TQString NetworkScanner::subnet() const -{ - return d->prefixaddress; -} - -void NetworkScanner::setSubnet( const TQString& sn ) -{ - d->prefixaddress = sn; - d->subnetlab->setText( i18n( "Subnet: %1" ).arg( d->scanString() ) ); -} - -int NetworkScanner::port() const -{ - return d->port; -} - -void NetworkScanner::setPort( int p ) -{ - d->port = p; - d->subnetlab->setText( i18n( "Subnet: %1" ).arg( d->scanString() ) ); -} - -bool NetworkScanner::checkPrinter( const TQString& host, int port ) -{ - // try first to find it in the SocketInfo list - TQPtrListIterator<NetworkScanner::SocketInfo> it( d->printers ); - for ( ; it.current(); ++it ) - { - if ( port == it.current()->Port && ( host == it.current()->IP || - host == it.current()->Name ) ) - return true; - } - - // not found in SocketInfo list, try to establish connection - KExtendedSocket extsock( host, port ); - extsock.setBlockingMode( false ); - extsock.setTimeout( 0, d->timeout * 1000 ); - return ( extsock.connect() == 0 ); -} - -NetworkScannerConfig::NetworkScannerConfig(NetworkScanner *scanner, const char *name) - : KDialogBase(scanner, name, true, TQString::null, Ok|Cancel, Ok, true) -{ - scanner_ = scanner; - TQWidget *dummy = new TQWidget(this); - setMainWidget(dummy); - KIntValidator *val = new KIntValidator( this ); - TQLabel *masklabel = new TQLabel(i18n("&Subnetwork:"),dummy); - TQLabel *portlabel = new TQLabel(i18n("&Port:"),dummy); - TQLabel *toutlabel = new TQLabel(i18n("&Timeout (ms):"),dummy); - TQLineEdit *mm = new TQLineEdit(dummy); - mm->setText(TQString::tqfromLatin1(".[0-255]")); - mm->setReadOnly(true); - mm->setFixedWidth(fontMetrics().width(mm->text())+10); - - mask_ = new TQLineEdit(dummy); - mask_->tqsetAlignment(Qt::AlignRight); - port_ = new TQComboBox(true,dummy); - if ( port_->lineEdit() ) - port_->lineEdit()->setValidator( val ); - tout_ = new TQLineEdit(dummy); - tout_->setValidator( val ); - - masklabel->setBuddy(mask_); - portlabel->setBuddy(port_); - toutlabel->setBuddy(tout_); - - mask_->setText(scanner_->subnet()); - port_->insertItem("631"); - port_->insertItem("9100"); - port_->insertItem("9101"); - port_->insertItem("9102"); - port_->setEditText(TQString::number(scanner_->port())); - tout_->setText(TQString::number(scanner_->timeout())); - - TQGridLayout *main_ = new TQGridLayout(dummy, 3, 2, 0, 10); - TQHBoxLayout *lay1 = new TQHBoxLayout(0, 0, 5); - main_->addWidget(masklabel, 0, 0); - main_->addWidget(portlabel, 1, 0); - main_->addWidget(toutlabel, 2, 0); - main_->addLayout(lay1, 0, 1); - main_->addWidget(port_, 1, 1); - main_->addWidget(tout_, 2, 1); - lay1->addWidget(mask_,1); - lay1->addWidget(mm,0); - - resize(250,130); - setCaption(i18n("Scan Configuration")); -} - -NetworkScannerConfig::~NetworkScannerConfig() -{ -} - -void NetworkScannerConfig::slotOk() -{ - TQString msg; - TQRegExp re("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"); - if (!re.exactMatch(mask_->text())) - msg = i18n("Wrong subnetwork specification."); - else - { - for (int i=1; i<=3; i++) - if (re.cap(i).toInt() >= 255) - { - msg = i18n("Wrong subnetwork specification."); - break; - } - } - - bool ok(false); - int v = tout_->text().toInt(&ok); - if (!ok || v <= 0) - msg = i18n("Wrong timeout specification."); - v = port_->currentText().toInt(&ok); - if (!ok || v <= 0) - msg = i18n("Wrong port specification."); - if (!msg.isEmpty()) - { - KMessageBox::error(this,msg); - return; - } - - scanner_->setTimeout( tout_->text().toInt() ); - scanner_->setSubnet( mask_->text() ); - scanner_->setPort( port_->currentText().toInt() ); - - KDialogBase::slotOk(); -} - -#include "networkscanner.moc" diff --git a/kdeprint/management/networkscanner.h b/kdeprint/management/networkscanner.h deleted file mode 100644 index 3d56bb03e..000000000 --- a/kdeprint/management/networkscanner.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 NETWORKSCANNER_H -#define NETWORKSCANNER_H - -#include <tqwidget.h> -#include <kdialogbase.h> -#include <tqptrlist.h> - - -class KDEPRINT_EXPORT NetworkScanner : public TQWidget -{ - Q_OBJECT - -public: - NetworkScanner( int port = 9100, TQWidget *parent = 0, const char *name = 0 ); - ~NetworkScanner(); - - struct SocketInfo - { - TQString IP; - TQString Name; - int Port; - }; - - const TQPtrList<NetworkScanner::SocketInfo>* printerList(); - - int timeout() const; - void setTimeout( int to ); - TQString subnet() const; - void setSubnet( const TQString& ); - int port() const; - void setPort( int ); - bool checkPrinter( const TQString&, int ); - -signals: - void scanStarted(); - void scanFinished(); - -protected slots: - void slotConnectionSuccess(); - void slotConnectionFailed( int ); - void slotTimeout(); - void slotScanClicked(); - void slotSettingsClicked(); - void slotNext(); - -protected: - void next(); - void finish(); - void start(); - -private: - class NetworkScannerPrivate; - NetworkScannerPrivate *d; -}; - -class TQLineEdit; -class TQComboBox; - -class NetworkScannerConfig : public KDialogBase -{ - Q_OBJECT - -public: - NetworkScannerConfig(NetworkScanner *scanner, const char *name = 0); - ~NetworkScannerConfig(); - -protected slots: - void slotOk(); - -private: - TQLineEdit *mask_, *tout_; - TQComboBox *port_; - NetworkScanner *scanner_; -}; - -#endif diff --git a/kdeprint/management/pluginaction.cpp b/kdeprint/management/pluginaction.cpp deleted file mode 100644 index 0aa3c10a3..000000000 --- a/kdeprint/management/pluginaction.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "pluginaction.h" - -// automatically connect to "pluginActionActived(int)" in the receiver. -PluginAction::PluginAction(int ID, const TQString& txt, const TQString& icon, int accel, TQObject *parent, const char *name) -: KAction(txt, icon, accel, parent, name), m_id(ID) -{ - connect(this, TQT_SIGNAL(activated()), TQT_SLOT(slotActivated())); -} - -void PluginAction::slotActivated() -{ - emit activated(m_id); -} - -#include "pluginaction.moc" diff --git a/kdeprint/management/pluginaction.h b/kdeprint/management/pluginaction.h deleted file mode 100644 index fb355b597..000000000 --- a/kdeprint/management/pluginaction.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 PLUGINACTION_H -#define PLUGINACTION_H - -#include <kaction.h> - -class KDEPRINT_EXPORT PluginAction : public KAction -{ - Q_OBJECT - -public: - PluginAction(int ID, const TQString& txt, const TQString& icon, int accel, TQObject *parent = 0, const char *name = 0); - -signals: - void activated(int); - -protected slots: - void slotActivated(); - -private: - int m_id; -}; - -#endif diff --git a/kdeprint/management/side.png b/kdeprint/management/side.png deleted file mode 100644 index f7e978d27..000000000 Binary files a/kdeprint/management/side.png and /dev/null differ diff --git a/kdeprint/management/sidepixmap.cpp b/kdeprint/management/sidepixmap.cpp deleted file mode 100644 index 8824dd5fc..000000000 --- a/kdeprint/management/sidepixmap.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "sidepixmap.h" - -#include <tqpainter.h> -#include <kstandarddirs.h> - -SidePixmap::SidePixmap(TQWidget *parent, const char *name) -: TQFrame(parent, name) -{ - setLineWidth(1); - setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - - m_side.load(locate("data", "tdeprint/side.png")); - m_tileup.load(locate("data", "tdeprint/tileup.png")); - m_tiledown.load(locate("data", "tdeprint/tiledown.png")); - - tqsetSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Minimum)); -} - -bool SidePixmap::isValid() -{ - return (!m_side.isNull() && !m_tileup.isNull() && !m_tiledown.isNull() - && (m_side.width() == m_tileup.width()) - && (m_side.width() == m_tiledown.width())); -} - -TQSize SidePixmap::tqsizeHint() const -{ - return (TQSize(m_side.width()+lineWidth(), 300+lineWidth())); -} - -void SidePixmap::drawContents(TQPainter *p) -{ - QRect r = contentsRect(); - if (r.height() <= m_side.height()) - { - // case where the main pixmap is enough, just center it - int yoffset = (m_side.height()-r.height())/2; - p->drawPixmap(r.left(), r.top(), m_side, 0, yoffset, r.width(), r.height()); - } - else - { - // we need to add tiled pixmap. Make sure we have a multiple - // of 3 in the space above to simplifu tiling. - int hh = (((r.height()-m_side.height())/2)/3)*3; - if (hh > 0) - p->drawTiledPixmap(r.left(), r.top(), r.width(), hh, m_tileup); - p->drawPixmap(r.left(), r.top()+hh, m_side); - p->drawTiledPixmap(r.left(), r.top()+m_side.height()+hh, r.width(), r.height()-m_side.height()-hh, m_tiledown); - } -} diff --git a/kdeprint/management/sidepixmap.h b/kdeprint/management/sidepixmap.h deleted file mode 100644 index a9730883e..000000000 --- a/kdeprint/management/sidepixmap.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 SIDEPIXMAP_H -#define SIDEPIXMAP_H - -#include <tqframe.h> -#include <tqpixmap.h> - -#include <kdelibs_export.h> - -class KDEPRINT_EXPORT SidePixmap : public TQFrame -{ -public: - SidePixmap(TQWidget *parent = 0, const char *name = 0); - TQSize tqsizeHint() const; - bool isValid(); - -protected: - void drawContents(TQPainter*); - -private: - QPixmap m_side, m_tileup, m_tiledown; -}; - -#endif diff --git a/kdeprint/management/smbview.cpp b/kdeprint/management/smbview.cpp deleted file mode 100644 index fde3a3451..000000000 --- a/kdeprint/management/smbview.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "smbview.h" - -#include <kprocess.h> -#include <ktempfile.h> -#include <tqheader.h> -#include <tqapplication.h> - -#include <kiconloader.h> -#include <klocale.h> -#include <kdebug.h> -#include <kmessagebox.h> -#include <kcursor.h> - -#include <tqfile.h> -#include <tqtextstream.h> -#include <cstdlib> - - -//********************************************************************************************* - -SmbView::SmbView(TQWidget *parent, const char *name) -: KListView(parent,name) -{ - addColumn(i18n("Printer")); - addColumn(i18n("Comment")); - setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - setLineWidth(1); - setAllColumnsShowFocus(true); - setRootIsDecorated(true); - - m_state = Idle; - m_current = 0; - m_proc = new KProcess(); - m_proc->setUseShell(true); - m_passwdFile = 0; - connect(m_proc,TQT_SIGNAL(processExited(KProcess*)),TQT_SLOT(slotProcessExited(KProcess*))); - connect(m_proc,TQT_SIGNAL(receivedStdout(KProcess*,char*,int)),TQT_SLOT(slotReceivedStdout(KProcess*,char*,int))); - connect(this,TQT_SIGNAL(selectionChanged(TQListViewItem*)),TQT_SLOT(slotSelectionChanged(TQListViewItem*))); -} - -SmbView::~SmbView() -{ - delete m_proc; - delete m_passwdFile; -} - -void SmbView::setLoginInfos(const TQString& login, const TQString& password) -{ - m_login = login; - m_password = password; - - // We can't pass the password via the command line or the environment - // because the command line is publically accessible on most OSes and - // the environment is publically accessible on some OSes. - // Therefor we write the password to a file and pass that file to - // smbclient with the -A option - delete m_passwdFile; - m_passwdFile = new KTempFile; - m_passwdFile->setAutoDelete(true); - - TQTextStream *passwdFile = m_passwdFile->textStream(); - if (!passwdFile) return; // Error - (*passwdFile) << "username = " << m_login << endl; - (*passwdFile) << "password = " << m_password << endl; - // (*passwdFile) << "domain = " << ???? << endl; - - m_passwdFile->close(); -} - -void SmbView::startProcess(int state) -{ - m_buffer = TQString::null; - m_state = state; - TQApplication::setOverrideCursor(KCursor::waitCursor()); - m_proc->start(KProcess::NotifyOnExit,KProcess::Stdout); - emit running(true); -} - -void SmbView::endProcess() -{ - switch (m_state) - { - case GroupListing: - processGroups(); - break; - case ServerListing: - processServers(); - break; - case ShareListing: - processShares(); - break; - default: - break; - } - m_state = Idle; - TQApplication::restoreOverrideCursor(); - emit running(false); - // clean up for future usage - m_proc->clearArguments(); -} - -void SmbView::slotProcessExited(KProcess*) -{ - endProcess(); -} - -void SmbView::slotReceivedStdout(KProcess*, char *buf, int len) -{ - m_buffer.append(TQString::fromLocal8Bit(buf,len)); -} - -void SmbView::init() -{ - // Open Samba configuration file and check if a WINS server is defined - m_wins_server = TQString::null; - TQString wins_keyword("wins server"); - TQFile smb_conf ("/etc/samba/smb.conf"); - if (smb_conf.exists () && smb_conf.open (IO_ReadOnly)) - { - TQTextStream smb_stream (&smb_conf); - while (!smb_stream.atEnd ()) - { - TQString smb_line = smb_stream.readLine (); - if (smb_line.contains (wins_keyword, FALSE) > 0) - { - TQString key = smb_line.section ('=', 0, 0); - key = key.stripWhiteSpace(); - if (key.lower() == wins_keyword) - { - continue; - } - m_wins_server = smb_line.section ('=', 1, 1); - // take only the first declared WINS server - m_wins_server = m_wins_server.section(',', 0, 0); - m_wins_server = m_wins_server.stripWhiteSpace (); - m_wins_server = m_wins_server.section(' ', 0, 0); - // strip any server tag (see man smb.conf(5)) - if (m_wins_server.section(':', 1, 1) != NULL) - { - m_wins_server = m_wins_server.section(':', 1, 1); - } - break; - } - } - smb_conf.close (); - } - m_wins_server = m_wins_server.isEmpty ()? " " : " -U " + m_wins_server + " "; - TQString cmd ("nmblookup" + m_wins_server + - "-M -- - | grep '<01>' | awk '{print $1}' | xargs nmblookup -A | grep '<1d>'"); - *m_proc << cmd; - startProcess(GroupListing); -} - -void SmbView::setOpen(TQListViewItem *item, bool on) -{ - if (on && item->childCount() == 0) - { - if (item->depth() == 0) - { // opening group - m_current = item; - *m_proc << "nmblookup"+m_wins_server+"-M "; - *m_proc << KProcess::quote(item->text(0)); - *m_proc << " -S"; - startProcess(ServerListing); - } - else if (item->depth() == 1) - { // opening server - char *krb5ccname = getenv ("KRB5CCNAME"); - m_current = item; - if (krb5ccname) - { - *m_proc << "smbclient -k -N -L "; - } - else - { - *m_proc << "smbclient -N -L "; - } - *m_proc << KProcess::quote (item->text (0)); - *m_proc << " -W "; - *m_proc << KProcess::quote (item->parent ()-> - text (0)); - if (!krb5ccname) - { - *m_proc << " -A "; - *m_proc << KProcess:: - quote (m_passwdFile->name ()); - } - startProcess(ShareListing); - } - } - TQListView::setOpen(item,on); -} - -void SmbView::processGroups() -{ - TQStringList grps = TQStringList::split('\n',m_buffer,false); - clear(); - for (TQStringList::ConstIterator it=grps.begin(); it!=grps.end(); ++it) - { - int p = (*it).find("<1d>"); - if (p == -1) - continue; - TQListViewItem *item = new TQListViewItem(this,(*it).left(p).stripWhiteSpace()); - item->setExpandable(true); - item->setPixmap(0,SmallIcon("network")); - } -} - -void SmbView::processServers() -{ - TQStringList lines = TQStringList::split('\n',m_buffer,true); - TQString line; - uint index(0); - while (index < lines.count()) - { - line = lines[index++].stripWhiteSpace(); - if (line.isEmpty()) - break; - TQStringList words = TQStringList::split(' ',line,false); - if (words[1] != "<00>" || words[3] == "<GROUP>") - continue; - TQListViewItem *item = new TQListViewItem(m_current,words[0]); - item->setExpandable(true); - item->setPixmap(0,SmallIcon("tdeprint_computer")); - } -} - -void SmbView::processShares() -{ - TQStringList lines = TQStringList::split('\n',m_buffer,true); - TQString line; - uint index(0); - for (;index < lines.count();index++) - if (lines[index].stripWhiteSpace().startsWith("Sharename")) - break; - index += 2; - while (index < lines.count()) - { - line = lines[index++].stripWhiteSpace(); - if (line.isEmpty()) - break; - else if ( line.startsWith( "Error returning" ) ) - { - KMessageBox::error( this, line ); - break; - } - TQString typestr(line.mid(15, 10).stripWhiteSpace()); - //TQStringList words = TQStringList::split(' ',line,false); - //if (words[1] == "Printer") - if (typestr == "Printer") - { - TQString comm(line.mid(25).stripWhiteSpace()), sharen(line.mid(0, 15).stripWhiteSpace()); - //for (uint i=2; i<words.count(); i++) - // comm += (words[i]+" "); - //TQListViewItem *item = new TQListViewItem(m_current,words[0],comm); - TQListViewItem *item = new TQListViewItem(m_current,sharen,comm); - item->setPixmap(0,SmallIcon("tdeprint_printer")); - } - } -} - -void SmbView::slotSelectionChanged(TQListViewItem *item) -{ - if (item && item->depth() == 2) - emit printerSelected(item->parent()->parent()->text(0),item->parent()->text(0),item->text(0)); -} - -void SmbView::abort() -{ - if (m_proc->isRunning()) - m_proc->kill(); -} -#include "smbview.moc" diff --git a/kdeprint/management/smbview.h b/kdeprint/management/smbview.h deleted file mode 100644 index aea1d920d..000000000 --- a/kdeprint/management/smbview.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 SMBVIEW_H -#define SMBVIEW_H - -#include <klistview.h> - -class KProcess; -class KTempFile; - -class SmbView : public KListView -{ - Q_OBJECT -public: - SmbView(TQWidget *parent = 0, const char *name = 0); - ~SmbView(); - - void setLoginInfos(const TQString& login, const TQString& password); - void setOpen(TQListViewItem*, bool); - void init(); - void abort(); - -signals: - void printerSelected(const TQString& work, const TQString& server, const TQString& printer); - void running(bool); - -protected: - void startProcess(int); - void endProcess(); - void processGroups(); - void processServers(); - void processShares(); - -protected slots: - void slotReceivedStdout(KProcess*, char*, int); - void slotProcessExited(KProcess*); - void slotSelectionChanged(TQListViewItem*); - -private: - enum State { GroupListing, ServerListing, ShareListing, Idle }; - int m_state; - TQListViewItem *m_current; - KProcess *m_proc; - TQString m_buffer; - TQString m_login, m_password; - KTempFile *m_passwdFile; - TQString m_wins_server; -}; - -#endif diff --git a/kdeprint/management/tiledown.png b/kdeprint/management/tiledown.png deleted file mode 100644 index 71af44b99..000000000 Binary files a/kdeprint/management/tiledown.png and /dev/null differ diff --git a/kdeprint/management/tileup.png b/kdeprint/management/tileup.png deleted file mode 100644 index cf63939a3..000000000 Binary files a/kdeprint/management/tileup.png and /dev/null differ diff --git a/kdeprint/marginpreview.cpp b/kdeprint/marginpreview.cpp deleted file mode 100644 index 2a5e21e59..000000000 --- a/kdeprint/marginpreview.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "marginpreview.h" - -#include <klocale.h> -#include <kdebug.h> -#include <tqpainter.h> -#include <kcursor.h> - -#define A4_WIDTH 595 -#define A4_HEIGHT 842 -#define A4_TOP 36 -#define A4_BOTTOM 806 -#define A4_LEFT 18 -#define A4_RIGHT 577 - -#define SCALE(d,z) ((int)(float(d)*z+0.5)) -#define UNSCALE(d,z) ((int)(float(d)/z+0.5)) - -static void draw3DPage(TQPainter *p, TQRect r) -{ - // draw white page - p->fillRect(r,Qt::white); - // draw 3D border - p->setPen(Qt::black); - p->moveTo(r.left(),r.bottom()); - p->lineTo(r.right(),r.bottom()); - p->lineTo(r.right(),r.top()); - p->setPen(Qt::darkGray); - p->lineTo(r.left(),r.top()); - p->lineTo(r.left(),r.bottom()); - p->setPen(Qt::gray); - p->moveTo(r.left()+1,r.bottom()-1); - p->lineTo(r.right()-1,r.bottom()-1); - p->lineTo(r.right()-1,r.top()+1); -} - -MarginPreview::MarginPreview(TQWidget *parent, const char *name) - : TQWidget(parent,name) -{ - width_ = A4_WIDTH; - height_ = A4_HEIGHT; - top_ = A4_TOP; - bottom_ = A4_BOTTOM; - left_ = A4_LEFT; - right_ = A4_RIGHT; - nopreview_ = false; - - box_ = rect(); - zoom_ = 1.0; - state_ = Fixed; - oldpos_ = -1; - symetric_ = false; - - setMouseTracking(true); -} - -MarginPreview::~MarginPreview() -{ -} - -void MarginPreview::setPageSize(float w, float h) -{ - setNoPreview(w <= 0 && h <= 0); - // do not change relative margins when changing page size !! - float old_b(height_-bottom_), old_r(width_-right_); - width_ = w; - height_ = h; - resizeEvent(NULL); - setMargins(top_,old_b,left_,old_r); - update(); -} - -void MarginPreview::setMargins(float t, float b, float l, float r) -{ - top_ = t; - left_ = l; - bottom_ = height_-b; - right_ = width_-r; - update(); -} - -void MarginPreview::setSymetric(bool on) -{ - symetric_ = on; -} - -void MarginPreview::resizeEvent(TQResizeEvent *) -{ - if (width_/height_ > float(width())/height()) - { - zoom_ = float(width()-3)/width_; - box_.setLeft(1); - box_.setRight(width()-3); - int m = (height()-3-SCALE(height_,zoom_))/2; - box_.setTop(m+1); - box_.setBottom(height()-m-3); - } - else - { - zoom_ = float(height()-3)/height_; - box_.setTop(1); - box_.setBottom(height()-3); - int m = (width()-3-SCALE(width_,zoom_))/2; - box_.setLeft(m+1); - box_.setRight(width()-m-3); - } -} - -void MarginPreview::paintEvent(TQPaintEvent *) -{ - TQPainter p(this); - - TQRect pagebox(TQPoint(box_.left()-1,box_.top()-1),TQPoint(box_.right()+2,box_.bottom()+2)); - - if (nopreview_) - { - p.drawText(pagebox,AlignCenter,i18n("No preview available")); - } - else - { - draw3DPage(&p,pagebox); - - // draw margins - p.setPen(DotLine); - int m = box_.left()+SCALE(left_,zoom_); - margbox_.setLeft(m+1); - p.drawLine(m,box_.top(),m,box_.bottom()); - m = box_.left()+SCALE(right_,zoom_); - margbox_.setRight(m-1); - p.drawLine(m,box_.top(),m,box_.bottom()); - m = box_.top()+SCALE(top_,zoom_); - margbox_.setTop(m+1); - p.drawLine(box_.left(),m,box_.right(),m); - m = box_.top()+SCALE(bottom_,zoom_); - margbox_.setBottom(m-1); - p.drawLine(box_.left(),m,box_.right(),m); - - // fill useful area - p.fillRect(margbox_,TQColor(220,220,220)); - } -} - -void MarginPreview::setNoPreview(bool on) -{ - nopreview_ = on; - update(); -} - -// 0: nothing -// 1: top -// 2: bottom -// 3: left -// 4: right -int MarginPreview::locateMouse(const TQPoint& p) -{ - int tol = 2; - if (p.x() <= margbox_.left()+tol && p.x() >= margbox_.left()-tol) - return LMoving; - else if (p.x() <= margbox_.right()+tol && p.x() >= margbox_.right()-tol) - return RMoving; - else if (p.y() <= margbox_.top()+tol && p.y() >= margbox_.top()-tol) - return TMoving; - else if (p.y() <= margbox_.bottom()+tol && p.y() >= margbox_.bottom()-tol) - return BMoving; - else - return 0; -} - -void MarginPreview::mouseMoveEvent(TQMouseEvent *e) -{ - if (nopreview_ || state_ == Fixed) - return; - int pos = locateMouse(e->pos()); - if (state_ == None && e->button() == Qt::NoButton) - { - switch (pos) - { - case 1: - case 2: - setCursor(KCursor::sizeVerCursor()); - break; - case 3: - case 4: - setCursor(KCursor::sizeHorCursor()); - break; - default: - setCursor(KCursor::arrowCursor()); - break; - } - } - else if (state_ > None) - { - int newpos = -1; - switch (state_) - { - case TMoving: - newpos = TQMIN(TQMAX(e->pos().y(), box_.top()), (symetric_ ? (box_.top()+box_.bottom())/2 : margbox_.bottom()+1)); - break; - case BMoving: - newpos = TQMIN(TQMAX(e->pos().y(), (symetric_? (box_.top()+box_.bottom()+1)/2 : margbox_.top()-1)), box_.bottom()); - break; - case LMoving: - newpos = TQMIN(TQMAX(e->pos().x(), box_.left()), (symetric_ ? (box_.left()+box_.right())/2 : margbox_.right()+1)); - break; - case RMoving: - newpos = TQMIN(TQMAX(e->pos().x(), (symetric_ ? (box_.left()+box_.right()+1)/2 : margbox_.left()-1)), box_.right()); - break; - } - if (newpos != oldpos_) - { - TQPainter p(this); - p.setRasterOp(TQt::XorROP); - p.setPen(gray); - for (int i=0; i<2; i++, oldpos_ = newpos) - { - if (oldpos_ >= 0) - drawTempLine(&p); - } - } - } -} - -void MarginPreview::drawTempLine(TQPainter *p) -{ - if (state_ >= LMoving) - { - p->drawLine(oldpos_, box_.top(), oldpos_, box_.bottom()); - if (symetric_) - { - int mirror = box_.left()+box_.right()-oldpos_; - p->drawLine(mirror, box_.top(), mirror, box_.bottom()); - } - } - else - { - p->drawLine(box_.left(), oldpos_, box_.right(), oldpos_); - if (symetric_) - { - int mirror = box_.top()+box_.bottom()-oldpos_; - p->drawLine(box_.left(), mirror, box_.right(), mirror); - } - } -} - -void MarginPreview::mousePressEvent(TQMouseEvent *e) -{ - if (e->button() != Qt::LeftButton || state_ != None) - return; - int mpos = locateMouse(e->pos()); - if (mpos) - { - state_ = mpos; - } -} - -void MarginPreview::mouseReleaseEvent(TQMouseEvent *e) -{ - if (state_ > None) - { - TQPainter p(this); - p.setRasterOp(TQt::XorROP); - p.setPen(gray); - if (oldpos_ >= 0) - { - drawTempLine(&p); - if (e) - { - float val = 0; - int st(state_); - if (symetric_ && (st == BMoving || st == RMoving)) - st--; - switch (st) - { - case TMoving: - val = top_ = UNSCALE(oldpos_-box_.top(), zoom_); - if (symetric_) - bottom_ = height_-top_; - break; - case BMoving: - bottom_ = UNSCALE(oldpos_-box_.top(), zoom_); - val = UNSCALE(box_.bottom()-oldpos_, zoom_); - break; - case LMoving: - val = left_ = UNSCALE(oldpos_-box_.left(), zoom_); - if (symetric_) - right_ = width_-left_; - break; - case RMoving: - right_ = UNSCALE(oldpos_-box_.left(), zoom_); - val = UNSCALE(box_.right()-oldpos_, zoom_); - break; - } - update(); - emit marginChanged(st, val); - } - } - state_ = 0; - oldpos_ = -1; - } -} - -void MarginPreview::enableRubberBand(bool on) -{ - if (on && state_ == Fixed) - state_ = None; - else if (!on && state_ > Fixed) - { - mouseReleaseEvent(NULL); - state_ = Fixed; - } -} - -#include "marginpreview.moc" diff --git a/kdeprint/marginpreview.h b/kdeprint/marginpreview.h deleted file mode 100644 index e0ed3e775..000000000 --- a/kdeprint/marginpreview.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 MARGINPREVIEW_H -#define MARGINPREVIEW_H - -#include <tqwidget.h> - -class MarginPreview : public TQWidget -{ - Q_OBJECT - -public: - MarginPreview(TQWidget *parent = 0, const char *name = 0); - ~MarginPreview(); - // note : unit -> points (1/72th in) - void setPageSize(float w, float h); - void setMargins(float t, float b, float l, float r); - void setNoPreview(bool on); - void setSymetric(bool on); - enum StateType { Fixed = -1, None = 0, TMoving, BMoving, LMoving, RMoving }; - -public slots: - void enableRubberBand(bool on); - -signals: - void marginChanged(int type, float value); - -protected: - void paintEvent(TQPaintEvent *); - void resizeEvent(TQResizeEvent *); - void mouseMoveEvent(TQMouseEvent *); - void mousePressEvent(TQMouseEvent *); - void mouseReleaseEvent(TQMouseEvent *); - int locateMouse(const TQPoint& p); - void drawTempLine(TQPainter*); - -private: - float width_, height_; - float top_, bottom_, left_, right_; - TQRect box_, margbox_; - float zoom_; - bool nopreview_; - int state_; - int oldpos_; - bool symetric_; -}; - -#endif diff --git a/kdeprint/marginvaluewidget.cpp b/kdeprint/marginvaluewidget.cpp deleted file mode 100644 index e4f1365c6..000000000 --- a/kdeprint/marginvaluewidget.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "marginvaluewidget.h" - -#include <math.h> - -MarginValueWidget::MarginValueWidget(KNumInput *below, double value, TQWidget *parent, const char *name) -: KDoubleNumInput(below, value, parent, name) -{ - m_mode = Pixels; - m_block = false; - setPrecision(0); - m_dpi = 72.0; - m_margin = ( float )value; - setMode(m_mode); - setRange(0, 999, 1, false); - connect(this, TQT_SIGNAL(valueChanged(double)), TQT_SLOT(slotValueChanged(double))); -} - -float MarginValueWidget::margin() -{ - // Force synchronization - m_margin = toPixel(value(), m_mode); - return m_margin; -} - -void MarginValueWidget::setMargin(float m) -{ - m_margin = m; - double v = toValue(m, m_mode); - m_block = true; - setValue(v); - m_block = false; - emit marginChanged( m_margin ); -} - -float MarginValueWidget::toPixel(double value, int mode) -{ - switch (mode) - { - default: - case Pixels: return (float)value; - case IN: return (float)(value * m_dpi); - case CM: return (float)(value * m_dpi / 2.54); - case MM: return (float)(value * m_dpi / 25.4); - } -} - -double MarginValueWidget::toValue(float pix, int mode) -{ - switch (mode) - { - default: - case Pixels: - return (double)pix; - case IN: - return (double(pix) / m_dpi); - case CM: - return (double(pix) * 2.54 / m_dpi); - case MM: - return ( double( pix ) * 25.4 / m_dpi ); - } -} - -void MarginValueWidget::slotValueChanged(double v) -{ - if (!m_block) - { - m_margin = toPixel( v, m_mode ); - emit marginChanged(margin()); - } -} - -void MarginValueWidget::setMode(int m) -{ - if (m != m_mode) - { - m_block = true; - m_mode = m; - double v = toValue(m_margin, m); - if (m == Pixels) - { - setPrecision(0); - setRange(0.0, 999.0, 1.0, false); - } - else - { - setPrecision(3); - setRange(0.0, 999.0, 0.01, false); - } - setValue(v); - m_block = false; - } -} - -void MarginValueWidget::setResolution(int dpi) -{ - m_dpi = dpi; - m_block = true; - setMargin(m_margin); - m_block = false; -} - -int MarginValueWidget::resolution() const -{ - return (int)(m_dpi+0.5); -} - -#include "marginvaluewidget.moc" diff --git a/kdeprint/marginvaluewidget.h b/kdeprint/marginvaluewidget.h deleted file mode 100644 index 97f1409c1..000000000 --- a/kdeprint/marginvaluewidget.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 MARGINVALUEWIDGET_H -#define MARGINVALUEWIDGET_H - -#include <knuminput.h> - -class MarginValueWidget : public KDoubleNumInput -{ - Q_OBJECT -public: - enum Mode { Pixels = 0, IN, CM, MM }; - MarginValueWidget(KNumInput *below, double value = 18.0, TQWidget *parent = 0, const char *name = 0); - - float margin(); - int resolution() const; - void setResolution(int dpi); - -public slots: - void setMode(int); - void setMargin(float); - -signals: - void marginChanged(float); - -protected slots: - void slotValueChanged(double); - -protected: - float toPixel(double value, int mode); - double toValue(float pix, int mode); - -private: - int m_mode; - double m_dpi; - bool m_block; - float m_margin; -}; - -#endif diff --git a/kdeprint/marginwidget.cpp b/kdeprint/marginwidget.cpp deleted file mode 100644 index 53790a112..000000000 --- a/kdeprint/marginwidget.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "marginwidget.h" -#include "marginpreview.h" -#include "marginvaluewidget.h" -#include "kprinter.h" - -#include <tqcombobox.h> -#include <tqcheckbox.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqwhatsthis.h> -#include <klocale.h> -#include <kglobal.h> - -MarginWidget::MarginWidget(TQWidget *parent, const char* name, bool allowMetricUnit) -: TQWidget(parent, name), m_default(4, 0), m_pagesize( 2 ) -{ - //WhatsThis strings.... (added by pfeifle@kde.org) - TQString whatsThisTopMarginWidget = i18n( " <qt> " - " <p><b>Top Margin</b></p>. " - " <p>This spinbox/text edit field lets you control the top margin of your printout if the printing " - " application does not define its margins internally. </p> " - " <p>The setting works for instance for ASCII text file printing, or for printing from KMail and " - " and Konqueror.. </p>" - " <p><b>Note:</b></p>This margin setting is not intended for KOffice or OpenOffice.org printing, " - " because these applications (or rather their users) are expected to do it by themselves. " - " It also does not work for PostScript or PDF file, which in most cases have their margins hardcoded " - " internally.</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-top=... # use values from \"0\" or higher. \"72\" is equal to 1 inch. " - " </pre>" - " </p> " - " </qt>" ); - - TQString whatsThisBottomMarginWidget = i18n( " <qt> " - " <p><b>Bottom Margin</b></p>. " - " <p>This spinbox/text edit field lets you control the bottom margin of your printout if the printing " - " application does not define its margins internally. </p> " - " <p>The setting works for instance for ASCII text file printing, or for printing from KMail and " - " and Konqueror. </p>" - " <p><b>Note:</b></p>This margin setting is not intended for KOffice or OpenOffice.org printing, " - " because these applications (or rather their users) are expected to do it by themselves. " - " It also does not work for PostScript or PDF file, which in most cases have their margins hardcoded " - " internally.</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-bottom=... # use values from \"0\" or higher. \"72\" is equal to 1 inch. " - " </pre>" - " </qt>" ); - - TQString whatsThisLeftMarginWidget = i18n( " <qt> " - " <p><b>Left Margin</b></p>. " - " <p>This spinbox/text edit field lets you control the left margin of your printout if the printing " - " application does not define its margins internally. </p> " - " <p>The setting works for instance for ASCII text file printing, or for printing from KMail and " - " and Konqueror. </p>" - " <p><b>Note:</b></p>This margin setting is not intended for KOffice or OpenOffice.org printing, " - " because these applications (or rather their users) are expected to do it by themselves. " - " It also does not work for PostScript or PDF file, which in most cases have their margins hardcoded " - " internally.</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-left=... # use values from \"0\" or higher. \"72\" is equal to 1 inch. " - " </pre>" - " </qt>" ); - - TQString whatsThisRightMarginWidget = i18n( " <qt> " - " <p><b>Right Margin</b></p>. " - " <p>This spinbox/text edit field lets you control the right margin of your printout if the printing " - " application does not define its margins internally. </p> " - " <p>The setting works for instance for ASCII text file printing, or for printing from KMail and " - " and Konqueror. </p>" - " <p><b>Note:</b></p>This margin setting is not intended for KOffice or OpenOffice.org printing, " - " because these applications (or rather their users) are expected to do it by themselves. " - " It also does not work for PostScript or PDF file, which in most cases have their margins hardcoded " - " internally.</p> " - " <br> " - " <hr> " - " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " - " with the CUPS commandline job option parameter:</em> " - " <pre>" - " -o page-right=... # use values from \"0\" or higher. \"72\" is equal to 1 inch. " - " </pre>" - " </qt>" ); - - TQString whatsThisMeasurementUnitMarginWidget = i18n( " <qt> " - " <p><b>Change Measurement Unit<b></p>. " - " <p>You can change the units of measurement for the page" - " margins here. Select from Millimeter, Centimeter, Inch or Pixels (1 pixel == 1/72 inch). " - " </p> " - " </qt>" ); - - TQString whatsThisCheckboxMarginWidget = i18n( " <qt> " - " <p><b>Custom Margins Checkbox</b></p>. " - " <p>Enable this checkbox if you want to modify the margins of your printouts " - " <p>You can change margin settings in 4 ways: " - " <ul> " - " <li>Edit the text fields. </li> " - " <li>Click spinbox arrows. </li> " - " <li>Scroll wheel of wheelmouses. </li> " - " <li>Drag margins in preview frame with mouse. </li> " - " </ul> " - " <b>Note:</b> The margin setting does not work if you load such files directly into " - " kprinter, which have their print margins hardcoded internally, like as most " - " PDF or PostScript files. It works for all ASCII text files however. It also may not " - " work with non-KDE applications which fail to " - " fully utilize the KDEPrint framework, such as OpenOffice.org. </p> " - " </qt>" ); - - TQString whatsThisDragAndPreviewMarginWidget = i18n( " <qt> " - " <p><b>\"Drag-your-Margins\" </p>. " - " <p>Use your mouse to drag and set each margin on this little preview window. </p> " - " </qt>" ); - - m_symetric = m_block = false; - m_pagesize[ 0 ] = 595; - m_pagesize[ 1 ] = 842; - m_landscape = false; - - m_custom = new TQCheckBox(i18n("&Use custom margins"), this); - TQWhatsThis::add(m_custom, whatsThisCheckboxMarginWidget); - m_top = new MarginValueWidget(0, 0.0, this); - TQWhatsThis::add(m_top, whatsThisTopMarginWidget); - m_bottom = new MarginValueWidget(m_top, 0.0, this); - TQWhatsThis::add(m_bottom, whatsThisBottomMarginWidget); - m_left = new MarginValueWidget(m_bottom, 0.0, this); - TQWhatsThis::add(m_left, whatsThisLeftMarginWidget); - m_right = new MarginValueWidget(m_left, 0.0, this); - TQWhatsThis::add(m_right, whatsThisRightMarginWidget); - m_top->setLabel(i18n("&Top:"), Qt::AlignLeft|Qt::AlignVCenter); - m_bottom->setLabel(i18n("&Bottom:"), Qt::AlignLeft|Qt::AlignVCenter); - m_left->setLabel(i18n("Le&ft:"), Qt::AlignLeft|Qt::AlignVCenter); - m_right->setLabel(i18n("&Right:"), Qt::AlignLeft|Qt::AlignVCenter); - m_units = new TQComboBox(this); - TQWhatsThis::add(m_units, whatsThisMeasurementUnitMarginWidget); - m_units->insertItem(i18n("Pixels (1/72nd in)")); - if ( allowMetricUnit ) - { - m_units->insertItem(i18n("Inches (in)")); - m_units->insertItem(i18n("Centimeters (cm)")); - m_units->insertItem( i18n( "Millimeters (mm)" ) ); - } - m_units->setCurrentItem(0); - connect(m_units, TQT_SIGNAL(activated(int)), m_top, TQT_SLOT(setMode(int))); - connect(m_units, TQT_SIGNAL(activated(int)), m_bottom, TQT_SLOT(setMode(int))); - connect(m_units, TQT_SIGNAL(activated(int)), m_left, TQT_SLOT(setMode(int))); - connect(m_units, TQT_SIGNAL(activated(int)), m_right, TQT_SLOT(setMode(int))); - m_preview = new MarginPreview(this); - TQWhatsThis::add(m_preview, whatsThisDragAndPreviewMarginWidget); - m_preview->setMinimumSize(60, 80); - m_preview->setPageSize(m_pagesize[ 0 ], m_pagesize[ 1 ]); - connect(m_preview, TQT_SIGNAL(marginChanged(int,float)), TQT_SLOT(slotMarginPreviewChanged(int,float))); - connect(m_top, TQT_SIGNAL(marginChanged(float)), TQT_SLOT(slotMarginValueChanged())); - connect(m_bottom, TQT_SIGNAL(marginChanged(float)), TQT_SLOT(slotMarginValueChanged())); - connect(m_left, TQT_SIGNAL(marginChanged(float)), TQT_SLOT(slotMarginValueChanged())); - connect(m_right, TQT_SIGNAL(marginChanged(float)), TQT_SLOT(slotMarginValueChanged())); - slotMarginValueChanged(); - connect(m_custom, TQT_SIGNAL(toggled(bool)), m_top, TQT_SLOT(setEnabled(bool))); - connect(m_custom, TQT_SIGNAL(toggled(bool)), m_left, TQT_SLOT(setEnabled(bool))); - //connect(m_custom, TQT_SIGNAL(toggled(bool)), m_units, TQT_SLOT(setEnabled(bool))); - connect(m_custom, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotCustomMarginsToggled(bool))); - connect(m_custom, TQT_SIGNAL(toggled(bool)), m_preview, TQT_SLOT(enableRubberBand(bool))); - m_top->setEnabled(false); - m_bottom->setEnabled(false); - m_left->setEnabled(false); - m_right->setEnabled(false); - //m_units->setEnabled(false); - - TQGridLayout *l3 = new TQGridLayout(this, 7, 2, 0, 10); - l3->addWidget(m_custom, 0, 0); - l3->addWidget(m_top, 1, 0); - l3->addWidget(m_bottom, 2, 0); - l3->addWidget(m_left, 3, 0); - l3->addWidget(m_right, 4, 0); - l3->addRowSpacing(5, 10); - l3->addWidget(m_units, 6, 0); - l3->addMultiCellWidget(m_preview, 0, 6, 1, 1); - - if ( allowMetricUnit ) - { - int mode = (KGlobal::locale()->measureSystem() == KLocale::Metric ? 2 : 1); - m_top->setMode(mode); - m_bottom->setMode(mode); - m_left->setMode(mode); - m_right->setMode(mode); - m_units->setCurrentItem(mode); - } -} - -MarginWidget::~MarginWidget() -{ -} - -void MarginWidget::slotCustomMarginsToggled(bool b) -{ - m_bottom->setEnabled(b && !m_symetric); - m_right->setEnabled(b && !m_symetric); - if (!b) - resetDefault(); -} - -void MarginWidget::setSymetricMargins(bool on) -{ - if (on == m_symetric) - return; - - m_symetric = on; - m_bottom->setEnabled(on && m_custom->isChecked()); - m_right->setEnabled(on && m_custom->isChecked()); - if (on) - { - connect(m_top, TQT_SIGNAL(marginChanged(float)), m_bottom, TQT_SLOT(setMargin(float))); - connect(m_left, TQT_SIGNAL(marginChanged(float)), m_right, TQT_SLOT(setMargin(float))); - m_bottom->setMargin(m_top->margin()); - m_right->setMargin(m_left->margin()); - } - else - { - disconnect(m_top, 0, m_bottom, 0); - disconnect(m_left, 0, m_right, 0); - } - m_preview->setSymetric(on); -} - -void MarginWidget::slotMarginValueChanged() -{ - if (m_block) - return; - m_preview->setMargins(m_top->margin(), m_bottom->margin(), m_left->margin(), m_right->margin()); -} - -void MarginWidget::slotMarginPreviewChanged(int type, float value) -{ - m_block = true; - switch (type) - { - case MarginPreview::TMoving: - m_top->setMargin(value); - break; - case MarginPreview::BMoving: - m_bottom->setMargin(value); - break; - case MarginPreview::LMoving: - m_left->setMargin(value); - break; - case MarginPreview::RMoving: - m_right->setMargin(value); - break; - } - m_block = false; -} - -void MarginWidget::setPageSize(float w, float h) -{ - // takes care of the orientation and the resolution - int dpi = m_top->resolution(); - m_pagesize[ 0 ] = w; - m_pagesize[ 1 ] = h; - if (m_landscape) - m_preview->setPageSize((m_pagesize[ 1 ]*dpi)/72, (m_pagesize[ 0 ]*dpi)/72); - else - m_preview->setPageSize((m_pagesize[ 0 ]*dpi)/72, (m_pagesize[ 1 ]*dpi)/72); -} - -float MarginWidget::top() const -{ - return m_top->margin(); -} - -float MarginWidget::bottom() const -{ - return m_bottom->margin(); -} - -float MarginWidget::left() const -{ - return m_left->margin(); -} - -float MarginWidget::right() const -{ - return m_right->margin(); -} - -void MarginWidget::setTop(float value) -{ - m_top->setMargin(value); -} - -void MarginWidget::setBottom(float value) -{ - m_bottom->setMargin(value); -} - -void MarginWidget::setLeft(float value) -{ - m_left->setMargin(value); -} - -void MarginWidget::setRight(float value) -{ - m_right->setMargin(value); -} - -void MarginWidget::setResolution(int dpi) -{ - m_top->setResolution(dpi); - m_bottom->setResolution(dpi); - m_left->setResolution(dpi); - m_right->setResolution(dpi); -} - -void MarginWidget::setDefaultMargins(float t, float b, float l, float r) -{ - int dpi = m_top->resolution(); - m_default[0] = (t*dpi)/72; - m_default[1] = (b*dpi)/72; - m_default[2] = (l*dpi)/72; - m_default[3] = (r*dpi)/72; - if (!m_custom->isChecked()) - resetDefault(); -} - -void MarginWidget::resetDefault() -{ - m_top->setMargin(m_landscape ? m_default[2] : m_default[0]); - m_bottom->setMargin(m_landscape ? m_default[3] : m_default[1]); - m_left->setMargin(m_landscape ? m_default[1] : m_default[2]); - m_right->setMargin(m_landscape ? m_default[0] : m_default[3]); -} - -void MarginWidget::setCustomEnabled(bool on) -{ - m_custom->setChecked(on); -} - -bool MarginWidget::isCustomEnabled() const -{ - return m_custom->isChecked(); -} - -void MarginWidget::setOrientation(int orient) -{ - m_landscape = (orient == KPrinter::Landscape); - setPageSize(m_pagesize[ 0 ], m_pagesize[ 1 ]); -} - -#include "marginwidget.moc" diff --git a/kdeprint/marginwidget.h b/kdeprint/marginwidget.h deleted file mode 100644 index bca3a2c00..000000000 --- a/kdeprint/marginwidget.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 MARGINWIDGET_H -#define MARGINWIDGET_H - -#include <tqwidget.h> -#include <tqvaluevector.h> - -#include <kdelibs_export.h> - -class MarginValueWidget; -class MarginPreview; -class TQCheckBox; -class TQComboBox; - -class KDEPRINT_EXPORT MarginWidget : public TQWidget -{ - Q_OBJECT -public: - MarginWidget(TQWidget *parent = 0, const char *name = 0, bool allowMetricUnit = true); - ~MarginWidget(); - - void setSymetricMargins(bool on); - void setPageSize(float w, float h); - void setOrientation(int orient); - float top() const; - void setTop(float val); - float bottom() const; - void setBottom(float val); - float left() const; - void setLeft(float val); - float right() const; - void setRight(float val); - void setResolution(int dpi); - void setDefaultMargins(float t, float b, float l, float r); - void setCustomEnabled(bool on); - bool isCustomEnabled() const; - -protected slots: - void slotMarginValueChanged(); - void slotMarginPreviewChanged(int, float); - void slotCustomMarginsToggled(bool); - -protected: - void resetDefault(); - -private: - MarginValueWidget *m_top, *m_bottom, *m_left, *m_right; - MarginPreview *m_preview; - TQComboBox *m_units; - TQCheckBox *m_custom; - bool m_symetric, m_block; - TQValueVector<float> m_default; - TQValueVector<float> m_pagesize; - bool m_landscape; -}; - -#endif diff --git a/kdeprint/messagewindow.cpp b/kdeprint/messagewindow.cpp deleted file mode 100644 index 32ce8db9b..000000000 --- a/kdeprint/messagewindow.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "messagewindow.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqtimer.h> -#include <tqpixmap.h> -#include <tqhbox.h> -#include <kiconloader.h> -#include <kapplication.h> -#include <kdebug.h> - -TQPtrDict<MessageWindow> MessageWindow::m_windows; - -MessageWindow::MessageWindow( const TQString& txt, int delay, TQWidget *parent, const char *name ) - : TQWidget( parent, name, (WFlags)(WStyle_Customize|WStyle_NoBorder|WShowModal|WType_Dialog|WDestructiveClose) ) -{ - TQHBox *box = new TQHBox( this ); - box->setFrameStyle( TQFrame::Panel|TQFrame::Raised ); - box->setLineWidth( 1 ); - box->setSpacing( 10 ); - box->setMargin( 5 ); - TQLabel *pix = new TQLabel( box ); - pix->setPixmap( DesktopIcon( "tdeprint_printer" ) ); - m_text = new TQLabel( txt, box ); - - TQHBoxLayout *l0 = new TQHBoxLayout( this, 0, 0 ); - l0->addWidget( box ); - - m_windows.insert( parent, this ); - - if ( delay == 0 ) - slotTimer(); - else - TQTimer::singleShot( delay, this, TQT_SLOT( slotTimer() ) ); -} - -MessageWindow::~MessageWindow() -{ - m_windows.remove( parentWidget() ); -} - -void MessageWindow::slotTimer() -{ - TQSize psz = parentWidget()->size(), sz = tqsizeHint(); - move( parentWidget()->mapToGlobal( TQPoint( (psz.width()-sz.width())/2, (psz.height()-sz.height())/2 ) ) ); - if ( !isVisible() ) - { - show(); - kapp->processEvents(); - } -} - -TQString MessageWindow::text() const -{ - return m_text->text(); -} - -void MessageWindow::setText( const TQString& txt ) -{ - m_text->setText( txt ); -} - -void MessageWindow::add( TQWidget *parent, const TQString& txt, int delay ) -{ - if ( !parent ) - kdWarning( 500 ) << "Cannot add a message window to a null parent" << endl; - else - { - MessageWindow *w = m_windows.find( parent ); - if ( w ) - w->setText( txt ); - else - new MessageWindow( txt, delay, parent, "MessageWindow" ); - } -} - -void MessageWindow::remove( TQWidget *parent ) -{ - if ( parent ) - delete m_windows.find( parent ); -} - -void MessageWindow::change( TQWidget *parent, const TQString& txt ) -{ - if ( parent ) - { - MessageWindow *w = m_windows.find( parent ); - if ( w ) - w->setText( txt ); - else - kdWarning( 500 ) << "MessageWindow::change, no message window found" << endl; - } -} - -void MessageWindow::removeAll() -{ - TQPtrDictIterator<MessageWindow> it( m_windows ); - while ( it.current() ) - delete it.current(); -} - -#include "messagewindow.moc" diff --git a/kdeprint/messagewindow.h b/kdeprint/messagewindow.h deleted file mode 100644 index 44e211808..000000000 --- a/kdeprint/messagewindow.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 MESSAGEWINDOW_H -#define MESSAGEWINDOW_H - -#include <tqwidget.h> -#include <tqptrdict.h> - -#include <kdelibs_export.h> - -class TQLabel; - -class KDEPRINT_EXPORT MessageWindow : public TQWidget -{ - Q_OBJECT - -public: - ~MessageWindow(); - - static void add( TQWidget *parent, const TQString& txt, int delay = 500 ); - static void change( TQWidget *parent, const TQString& txt ); - static void remove( TQWidget *parent ); - static void removeAll(); - -protected slots: - void slotTimer(); - -protected: - MessageWindow( const TQString& txt, int delay = 500, TQWidget *parent = 0, const char *name = 0 ); - void setText( const TQString& txt ); - TQString text() const; - -private: - TQLabel *m_text; - static TQPtrDict<MessageWindow> m_windows; -}; - -#endif diff --git a/kdeprint/pics/CMakeLists.txt b/kdeprint/pics/CMakeLists.txt deleted file mode 100644 index 5363b16ef..000000000 --- a/kdeprint/pics/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -##### other data ################################ - -install( FILES - tdeprint_collate.png tdeprint_collate_reverse.png - tdeprint_color.png tdeprint_duplex_none.png - tdeprint_duplex_long.png tdeprint_duplex_short.png - tdeprint_grayscale.png tdeprint_landscape.png - tdeprint_nup1.png tdeprint_nup2.png tdeprint_nup4.png - tdeprint_portrait.png tdeprint_revlandscape.png - tdeprint_revportrait.png tdeprint_uncollate.png - tdeprint_uncollate_reverse.png tdeprint_nupother.png - tdeprint_prettyprint.png - DESTINATION ${DATA_INSTALL_DIR}/tdeprint/pics ) - -tde_install_icons( - tdeprint_job tdeprint_job_error tdeprint_job_process - tdeprint_job_stopped tdeprint_printer tdeprint_printer_class - tdeprint_printer_class_stopped tdeprint_printer_defect - tdeprint_printer_remote tdeprint_printer_remote_stopped - tdeprint_printer_stopped tdeprint_printer_remote_process - tdeprint_printer_process tdeprint_printer_class_process - tdeprint_computer tdeprint_printer_infos history - tdeprint_printer_users filterstop tdeprint_job_completed - tdeprint_job_cancelled package_utilities tdeprint_enableprinter - tdeprint_stopprinter tdeprint_addprinter tdeprint_addpseudo - tdeprint_configmgr tdeprint_configsrv tdeprint_defaulthard - tdeprint_defaultsoft tdeprint_report tdeprint_testprinter - tdeprint_uploadsmb tdeprint_restartsrv tdeprint_inklevel - tdeprint_printstate tdeprint_queuestate - DESTINATION ${DATA_INSTALL_DIR}/tdeprint/icons ) diff --git a/kdeprint/pics/Makefile.am b/kdeprint/pics/Makefile.am deleted file mode 100644 index a46f6530d..000000000 --- a/kdeprint/pics/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -icondata_DATA = tdeprint_collate.png \ - tdeprint_collate_reverse.png \ - tdeprint_color.png \ - tdeprint_duplex_none.png \ - tdeprint_duplex_long.png \ - tdeprint_duplex_short.png \ - tdeprint_grayscale.png \ - tdeprint_landscape.png \ - tdeprint_nup1.png \ - tdeprint_nup2.png \ - tdeprint_nup4.png \ - tdeprint_portrait.png \ - tdeprint_revlandscape.png \ - tdeprint_revportrait.png \ - tdeprint_uncollate.png \ - tdeprint_uncollate_reverse.png \ - tdeprint_nupother.png \ - tdeprint_prettyprint.png -icondatadir = $(kde_datadir)/tdeprint/pics - -stdicon_ICON = tdeprint_job tdeprint_job_error tdeprint_job_process tdeprint_job_stopped tdeprint_printer tdeprint_printer_class tdeprint_printer_class_stopped tdeprint_printer_defect tdeprint_printer_remote tdeprint_printer_remote_stopped tdeprint_printer_stopped tdeprint_printer_remote_process tdeprint_printer_process tdeprint_printer_class_process tdeprint_computer tdeprint_printer_infos history tdeprint_printer_users filterstop tdeprint_job_completed tdeprint_job_cancelled package_utilities tdeprint_enableprinter tdeprint_stopprinter tdeprint_addprinter tdeprint_addpseudo tdeprint_configmgr tdeprint_configsrv tdeprint_defaulthard tdeprint_defaultsoft tdeprint_report tdeprint_testprinter tdeprint_uploadsmb tdeprint_restartsrv tdeprint_inklevel tdeprint_printstate tdeprint_queuestate -stdicondir = $(kde_datadir)/tdeprint/icons diff --git a/kdeprint/pics/cr16-action-filterstop.png b/kdeprint/pics/cr16-action-filterstop.png deleted file mode 100644 index 8e49c18b1..000000000 Binary files a/kdeprint/pics/cr16-action-filterstop.png and /dev/null differ diff --git a/kdeprint/pics/cr16-action-kdeprint_restartsrv.png b/kdeprint/pics/cr16-action-kdeprint_restartsrv.png deleted file mode 100644 index 5d8f28cba..000000000 Binary files a/kdeprint/pics/cr16-action-kdeprint_restartsrv.png and /dev/null differ diff --git a/kdeprint/pics/cr16-action-kdeprint_uploadsmb.png b/kdeprint/pics/cr16-action-kdeprint_uploadsmb.png deleted file mode 100644 index c6d68fb09..000000000 Binary files a/kdeprint/pics/cr16-action-kdeprint_uploadsmb.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_computer.png b/kdeprint/pics/cr16-app-kdeprint_computer.png deleted file mode 100644 index 85a078c13..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_computer.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_job.png b/kdeprint/pics/cr16-app-kdeprint_job.png deleted file mode 100644 index 665a4e31b..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_job.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_job_cancelled.png b/kdeprint/pics/cr16-app-kdeprint_job_cancelled.png deleted file mode 100644 index 40e351f1c..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_job_cancelled.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_job_completed.png b/kdeprint/pics/cr16-app-kdeprint_job_completed.png deleted file mode 100644 index 246cf944f..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_job_completed.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_job_error.png b/kdeprint/pics/cr16-app-kdeprint_job_error.png deleted file mode 100644 index a07deb1cc..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_job_error.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_job_process.png b/kdeprint/pics/cr16-app-kdeprint_job_process.png deleted file mode 100644 index 4b4d8504c..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_job_process.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_job_stopped.png b/kdeprint/pics/cr16-app-kdeprint_job_stopped.png deleted file mode 100644 index bf3b64c1d..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_job_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer.png b/kdeprint/pics/cr16-app-kdeprint_printer.png deleted file mode 100644 index a1bb6b822..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_class.png b/kdeprint/pics/cr16-app-kdeprint_printer_class.png deleted file mode 100644 index 14fbd65d7..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_class.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_class_process.png b/kdeprint/pics/cr16-app-kdeprint_printer_class_process.png deleted file mode 100644 index 191682af2..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_class_process.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_class_stopped.png b/kdeprint/pics/cr16-app-kdeprint_printer_class_stopped.png deleted file mode 100644 index 100947a1a..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_class_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_defect.png b/kdeprint/pics/cr16-app-kdeprint_printer_defect.png deleted file mode 100644 index 971e713cd..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_defect.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_process.png b/kdeprint/pics/cr16-app-kdeprint_printer_process.png deleted file mode 100644 index edc4857cb..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_process.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_remote.png b/kdeprint/pics/cr16-app-kdeprint_printer_remote.png deleted file mode 100644 index cb1e27533..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_remote.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_remote_process.png b/kdeprint/pics/cr16-app-kdeprint_printer_remote_process.png deleted file mode 100644 index a0a6f708b..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_remote_process.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_remote_stopped.png b/kdeprint/pics/cr16-app-kdeprint_printer_remote_stopped.png deleted file mode 100644 index db04564f1..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_remote_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr16-app-kdeprint_printer_stopped.png b/kdeprint/pics/cr16-app-kdeprint_printer_stopped.png deleted file mode 100644 index 68e707ec8..000000000 Binary files a/kdeprint/pics/cr16-app-kdeprint_printer_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-history.png b/kdeprint/pics/cr22-action-history.png deleted file mode 100644 index ea6454004..000000000 Binary files a/kdeprint/pics/cr22-action-history.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_addprinter.png b/kdeprint/pics/cr22-action-kdeprint_addprinter.png deleted file mode 100644 index 05eb81a03..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_addprinter.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_addpseudo.png b/kdeprint/pics/cr22-action-kdeprint_addpseudo.png deleted file mode 100644 index fc5bbbb8e..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_addpseudo.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_configmgr.png b/kdeprint/pics/cr22-action-kdeprint_configmgr.png deleted file mode 100644 index 99765c81b..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_configmgr.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_configsrv.png b/kdeprint/pics/cr22-action-kdeprint_configsrv.png deleted file mode 100644 index 17fb0ec1c..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_configsrv.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_defaulthard.png b/kdeprint/pics/cr22-action-kdeprint_defaulthard.png deleted file mode 100644 index 3762942a1..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_defaulthard.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_defaultsoft.png b/kdeprint/pics/cr22-action-kdeprint_defaultsoft.png deleted file mode 100644 index eecca9239..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_defaultsoft.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_enableprinter.png b/kdeprint/pics/cr22-action-kdeprint_enableprinter.png deleted file mode 100644 index 31c064ba9..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_enableprinter.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_printer.png b/kdeprint/pics/cr22-action-kdeprint_printer.png deleted file mode 100644 index ae63e0ce4..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_printer.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_printer_infos.png b/kdeprint/pics/cr22-action-kdeprint_printer_infos.png deleted file mode 100644 index 6643cde36..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_printer_infos.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_printstate.png b/kdeprint/pics/cr22-action-kdeprint_printstate.png deleted file mode 100644 index 23d5c0876..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_printstate.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_queuestate.png b/kdeprint/pics/cr22-action-kdeprint_queuestate.png deleted file mode 100644 index 8c2e1c0b5..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_queuestate.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_report.png b/kdeprint/pics/cr22-action-kdeprint_report.png deleted file mode 100644 index c06f3cf5d..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_report.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_restartsrv.png b/kdeprint/pics/cr22-action-kdeprint_restartsrv.png deleted file mode 100644 index 9e4c1ad8e..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_restartsrv.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_stopprinter.png b/kdeprint/pics/cr22-action-kdeprint_stopprinter.png deleted file mode 100644 index 73b27d9fd..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_stopprinter.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_testprinter.png b/kdeprint/pics/cr22-action-kdeprint_testprinter.png deleted file mode 100644 index 6aba9c1b3..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_testprinter.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-kdeprint_uploadsmb.png b/kdeprint/pics/cr22-action-kdeprint_uploadsmb.png deleted file mode 100644 index f7daf4407..000000000 Binary files a/kdeprint/pics/cr22-action-kdeprint_uploadsmb.png and /dev/null differ diff --git a/kdeprint/pics/cr22-action-package_utilities.png b/kdeprint/pics/cr22-action-package_utilities.png deleted file mode 100644 index eb5333f1f..000000000 Binary files a/kdeprint/pics/cr22-action-package_utilities.png and /dev/null differ diff --git a/kdeprint/pics/cr22-app-kdeprint_printer.png b/kdeprint/pics/cr22-app-kdeprint_printer.png deleted file mode 100644 index e2ebb0c6e..000000000 Binary files a/kdeprint/pics/cr22-app-kdeprint_printer.png and /dev/null differ diff --git a/kdeprint/pics/cr32-action-kdeprint_inklevel.png b/kdeprint/pics/cr32-action-kdeprint_inklevel.png deleted file mode 100644 index 269f3c602..000000000 Binary files a/kdeprint/pics/cr32-action-kdeprint_inklevel.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer.png b/kdeprint/pics/cr32-app-kdeprint_printer.png deleted file mode 100644 index 61d164598..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_class.png b/kdeprint/pics/cr32-app-kdeprint_printer_class.png deleted file mode 100644 index ff28edb25..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_class.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_class_process.png b/kdeprint/pics/cr32-app-kdeprint_printer_class_process.png deleted file mode 100644 index 5ddf47ce3..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_class_process.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_class_stopped.png b/kdeprint/pics/cr32-app-kdeprint_printer_class_stopped.png deleted file mode 100644 index 0f8841bbd..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_class_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_defect.png b/kdeprint/pics/cr32-app-kdeprint_printer_defect.png deleted file mode 100644 index 5efd22227..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_defect.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_process.png b/kdeprint/pics/cr32-app-kdeprint_printer_process.png deleted file mode 100644 index ced236bb6..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_process.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_remote.png b/kdeprint/pics/cr32-app-kdeprint_printer_remote.png deleted file mode 100644 index 13af62943..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_remote.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_remote_process.png b/kdeprint/pics/cr32-app-kdeprint_printer_remote_process.png deleted file mode 100644 index 5fde48e73..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_remote_process.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_remote_stopped.png b/kdeprint/pics/cr32-app-kdeprint_printer_remote_stopped.png deleted file mode 100644 index 0f5f31c63..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_remote_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_stopped.png b/kdeprint/pics/cr32-app-kdeprint_printer_stopped.png deleted file mode 100644 index 79c84f090..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_stopped.png and /dev/null differ diff --git a/kdeprint/pics/cr32-app-kdeprint_printer_users.png b/kdeprint/pics/cr32-app-kdeprint_printer_users.png deleted file mode 100644 index a2fb7da65..000000000 Binary files a/kdeprint/pics/cr32-app-kdeprint_printer_users.png and /dev/null differ diff --git a/kdeprint/pics/cr48-app-kdeprint_printer.png b/kdeprint/pics/cr48-app-kdeprint_printer.png deleted file mode 100644 index 786015d78..000000000 Binary files a/kdeprint/pics/cr48-app-kdeprint_printer.png and /dev/null differ diff --git a/kdeprint/pics/cr48-app-kdeprint_printer_class.png b/kdeprint/pics/cr48-app-kdeprint_printer_class.png deleted file mode 100644 index 7f43f8e7f..000000000 Binary files a/kdeprint/pics/cr48-app-kdeprint_printer_class.png and /dev/null differ diff --git a/kdeprint/pics/cr64-app-kdeprint_printer.png b/kdeprint/pics/cr64-app-kdeprint_printer.png deleted file mode 100644 index 561ca9fd5..000000000 Binary files a/kdeprint/pics/cr64-app-kdeprint_printer.png and /dev/null differ diff --git a/kdeprint/pics/cr64-app-kdeprint_printer_class.png b/kdeprint/pics/cr64-app-kdeprint_printer_class.png deleted file mode 100644 index 53a67d3dc..000000000 Binary files a/kdeprint/pics/cr64-app-kdeprint_printer_class.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_collate.png b/kdeprint/pics/kdeprint_collate.png deleted file mode 100644 index 726e44c29..000000000 Binary files a/kdeprint/pics/kdeprint_collate.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_collate_reverse.png b/kdeprint/pics/kdeprint_collate_reverse.png deleted file mode 100644 index a6cbf2446..000000000 Binary files a/kdeprint/pics/kdeprint_collate_reverse.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_color.png b/kdeprint/pics/kdeprint_color.png deleted file mode 100644 index 40de5f355..000000000 Binary files a/kdeprint/pics/kdeprint_color.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_dupl_none.png b/kdeprint/pics/kdeprint_dupl_none.png deleted file mode 100644 index 1dc449046..000000000 Binary files a/kdeprint/pics/kdeprint_dupl_none.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_duplex_long.png b/kdeprint/pics/kdeprint_duplex_long.png deleted file mode 100644 index 1f269fcd4..000000000 Binary files a/kdeprint/pics/kdeprint_duplex_long.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_duplex_none.png b/kdeprint/pics/kdeprint_duplex_none.png deleted file mode 100644 index f4b6b16ec..000000000 Binary files a/kdeprint/pics/kdeprint_duplex_none.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_duplex_short.png b/kdeprint/pics/kdeprint_duplex_short.png deleted file mode 100644 index 5bf40a9c2..000000000 Binary files a/kdeprint/pics/kdeprint_duplex_short.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_grayscale.png b/kdeprint/pics/kdeprint_grayscale.png deleted file mode 100644 index 68ac097fb..000000000 Binary files a/kdeprint/pics/kdeprint_grayscale.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_landscape.png b/kdeprint/pics/kdeprint_landscape.png deleted file mode 100644 index c61d8c44b..000000000 Binary files a/kdeprint/pics/kdeprint_landscape.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_nup1.png b/kdeprint/pics/kdeprint_nup1.png deleted file mode 100644 index 2604b67e2..000000000 Binary files a/kdeprint/pics/kdeprint_nup1.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_nup2.png b/kdeprint/pics/kdeprint_nup2.png deleted file mode 100644 index ac297c192..000000000 Binary files a/kdeprint/pics/kdeprint_nup2.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_nup4.png b/kdeprint/pics/kdeprint_nup4.png deleted file mode 100644 index d74ea0abe..000000000 Binary files a/kdeprint/pics/kdeprint_nup4.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_nupother.png b/kdeprint/pics/kdeprint_nupother.png deleted file mode 100644 index 5bfbf3245..000000000 Binary files a/kdeprint/pics/kdeprint_nupother.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_opt_duplex.png b/kdeprint/pics/kdeprint_opt_duplex.png deleted file mode 100644 index e2a44ecae..000000000 Binary files a/kdeprint/pics/kdeprint_opt_duplex.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_pagesize.png b/kdeprint/pics/kdeprint_pagesize.png deleted file mode 100644 index 54962b742..000000000 Binary files a/kdeprint/pics/kdeprint_pagesize.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_portrait.png b/kdeprint/pics/kdeprint_portrait.png deleted file mode 100644 index 8bf1f9646..000000000 Binary files a/kdeprint/pics/kdeprint_portrait.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_prettyprint.png b/kdeprint/pics/kdeprint_prettyprint.png deleted file mode 100644 index 9e6f0fbb0..000000000 Binary files a/kdeprint/pics/kdeprint_prettyprint.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_revlandscape.png b/kdeprint/pics/kdeprint_revlandscape.png deleted file mode 100644 index 1d602302a..000000000 Binary files a/kdeprint/pics/kdeprint_revlandscape.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_revportrait.png b/kdeprint/pics/kdeprint_revportrait.png deleted file mode 100644 index 81ea9d675..000000000 Binary files a/kdeprint/pics/kdeprint_revportrait.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_uncollate.png b/kdeprint/pics/kdeprint_uncollate.png deleted file mode 100644 index 9ce59a380..000000000 Binary files a/kdeprint/pics/kdeprint_uncollate.png and /dev/null differ diff --git a/kdeprint/pics/kdeprint_uncollate_reverse.png b/kdeprint/pics/kdeprint_uncollate_reverse.png deleted file mode 100644 index afe0336cb..000000000 Binary files a/kdeprint/pics/kdeprint_uncollate_reverse.png and /dev/null differ diff --git a/kdeprint/pics/processsign.png b/kdeprint/pics/processsign.png deleted file mode 100644 index 4cb885345..000000000 Binary files a/kdeprint/pics/processsign.png and /dev/null differ diff --git a/kdeprint/pics/stopsign.png b/kdeprint/pics/stopsign.png deleted file mode 100644 index 6b990a2f7..000000000 Binary files a/kdeprint/pics/stopsign.png and /dev/null differ diff --git a/kdeprint/plugincombobox.cpp b/kdeprint/plugincombobox.cpp deleted file mode 100644 index e9a41ddeb..000000000 --- a/kdeprint/plugincombobox.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "plugincombobox.h" -#include "kmfactory.h" -#include "kmmanager.h" - -#include <tqcombobox.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> -#include <tqwhatsthis.h> - -PluginComboBox::PluginComboBox(TQWidget *parent, const char *name) -:TQWidget(parent, name) -{ - TQString whatsThisCurrentPrintsystem = i18n(" <qt><b>Print Subsystem Selection</b>" - " <p>This combo box shows (and lets you select)" - " a print subsystem to be used by KDEPrint. (This print" - " subsystem must, of course, be installed inside your" - " Operating System.) KDEPrint usually auto-detects the" - " correct print subsystem by itself upon first startup." - " Most Linux distributions have \"CUPS\", the <em>Common" - " UNIX Printing System</em>." - " </qt>" ); - - m_combo = new TQComboBox(this, "PluginCombo"); - TQWhatsThis::add(m_combo, whatsThisCurrentPrintsystem); - TQLabel *m_label = new TQLabel(i18n("Print s&ystem currently used:"), this); - TQWhatsThis::add(m_label, whatsThisCurrentPrintsystem); - m_label->tqsetAlignment(AlignVCenter|AlignRight); - m_label->setBuddy(m_combo); - m_plugininfo = new TQLabel("Plugin information", this); - TQGridLayout *l0 = new TQGridLayout(this, 2, 2, 0, 5); - l0->setColStretch(0, 1); - l0->addWidget(m_label, 0, 0); - l0->addWidget(m_combo, 0, 1); - l0->addWidget(m_plugininfo, 1, 1); - - TQValueList<KMFactory::PluginInfo> list = KMFactory::self()->pluginList(); - TQString currentPlugin = KMFactory::self()->printSystem(); - for (TQValueList<KMFactory::PluginInfo>::ConstIterator it=list.begin(); it!=list.end(); ++it) - { - m_combo->insertItem((*it).comment); - if ((*it).name == currentPlugin) - m_combo->setCurrentItem(m_combo->count()-1); - m_pluginlist.append((*it).name); - } - - connect(m_combo, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); - configChanged(); -} - -void PluginComboBox::slotActivated(int index) -{ - TQString plugin = m_pluginlist[index]; - if (!plugin.isEmpty()) - { - // the factory will notify all registered objects of the change - KMFactory::self()->reload(plugin, true); - } -} - -void PluginComboBox::reload() -{ - TQString syst = KMFactory::self()->printSystem(); - int index(-1); - if ((index=m_pluginlist.findIndex(syst)) != -1) - m_combo->setCurrentItem(index); - configChanged(); -} - -void PluginComboBox::configChanged() -{ - TQString whatsThisCurrentConnection = i18n(" <qt><b>Current Connection</b>" - " <p>This line shows which CUPS server your PC is" - " currently connected to for printing and retrieving" - " printer info. To switch to a different CUPS server," - " click \"System Options\", then select \"Cups server\"" - " and fill in the required info." - " </qt>" ); - - m_plugininfo->setText(KMManager::self()->stateInformation()); - TQWhatsThis::add(m_plugininfo, whatsThisCurrentConnection); - -} - -#include "plugincombobox.moc" diff --git a/kdeprint/plugincombobox.h b/kdeprint/plugincombobox.h deleted file mode 100644 index 668407e14..000000000 --- a/kdeprint/plugincombobox.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 PLUGINCOMBOBOX_H -#define PLUGINCOMBOBOX_H - -#include <tqwidget.h> -#include <tqstringlist.h> - -#include "kpreloadobject.h" - -class TQComboBox; -class TQLabel; - -class KDEPRINT_EXPORT PluginComboBox : public TQWidget, public KPReloadObject -{ - Q_OBJECT -public: - PluginComboBox(TQWidget *parent = 0, const char *name = 0); - -protected slots: - void slotActivated(int); - -protected: - void reload(); - void configChanged(); - -private: - TQComboBox *m_combo; - TQLabel *m_plugininfo; - TQStringList m_pluginlist; -}; - -#endif diff --git a/kdeprint/posterpreview.cpp b/kdeprint/posterpreview.cpp deleted file mode 100644 index 7e8542c22..000000000 --- a/kdeprint/posterpreview.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 "posterpreview.h" - -#include <kprocess.h> -#include <tqpainter.h> -#include <tqsimplerichtext.h> -#include <tqtimer.h> -#include <tqpixmap.h> -#include <kprinter.h> -#include <klocale.h> -#include <kcursor.h> -#include <kglobalsettings.h> - -PosterPreview::PosterPreview( TQWidget *parent, const char *name ) - : TQFrame( parent, name ) -{ - m_postersize = m_mediasize = "A4"; - m_cutmargin = 5; - init(); -} - -PosterPreview::PosterPreview( const TQString& postersize, const TQString& mediasize, TQWidget *parent, const char *name ) - : TQFrame( parent, name ) -{ - m_postersize = postersize; - m_mediasize = mediasize; - m_cutmargin = 5; - init(); -} - -PosterPreview::~PosterPreview() -{ - delete m_process; -} - -void PosterPreview::init() -{ - m_process = new KProcess; - connect( m_process, TQT_SIGNAL( receivedStderr( KProcess*, char*, int ) ), TQT_SLOT( slotProcessStderr( KProcess*, char*, int ) ) ); - connect( m_process, TQT_SIGNAL( processExited( KProcess* ) ), TQT_SLOT( slotProcessExited( KProcess* ) ) ); - - m_cols = m_rows = m_pw = m_ph = m_mw = m_mh = 0; - m_dirty = false; - setDirty(); - setMouseTracking( true ); - setBackgroundMode( TQt::NoBackground ); -} - -void PosterPreview::parseBuffer() -{ - int rotate; - float pw, ph, mw, mh; - float x1, x2, y1, y2; - sscanf( m_buffer.ascii(), "%d %d %d %g %g %g %g %g %g %g %g", &m_rows, &m_cols, &rotate, - &pw, &ph, &mw, &mh, &x1, &y1, &x2, &y2 ); - m_pw = ( int )( rotate ? ph : pw ); - m_ph = ( int )( rotate ? pw : ph ); - m_mw = ( int )( rotate ? mh : mw ); - m_mh = ( int )( rotate ? mw : mh ); - m_posterbb.setCoords( ( int )x1, ( int )y1, ( int )x2, ( int )y2 ); -} - -void PosterPreview::setDirty() -{ - if ( !m_dirty ) - { - m_dirty = true; - TQTimer::singleShot( 1, this, TQT_SLOT( updatePoster() ) ); - } -} - -void PosterPreview::updatePoster() -{ - m_buffer = ""; - m_process->clearArguments(); - *m_process << "poster" << "-F" << "-m" + m_mediasize << "-p" + m_postersize - << "-c" + TQString::number( m_cutmargin ) + "%"; - if ( !m_process->start( KProcess::NotifyOnExit, KProcess::Stderr ) ) - { - m_rows = m_cols = 0; - m_dirty = false; - update(); - } -} - -void PosterPreview::drawContents( TQPainter *painter ) -{ - TQPixmap pix( width(), height() ); - TQPainter *p = new TQPainter( &pix ); - - p->fillRect( 0, 0, width(), height(), tqcolorGroup().background() ); - - if ( isEnabled() ) - { - if ( m_rows <= 0 || m_cols <= 0 || m_pw <= 0 || m_ph <= 0 ) - { - TQString txt = i18n( "Poster preview not available. Either the <b>poster</b> " - "executable is not properly installed, or you don't have " - "the required version; available at http://printing.kde.org/downloads/." ); - TQSimpleRichText richtext( ( m_buffer.isEmpty() ? txt : m_buffer.prepend( "<pre>" ).append( "</pre>" ) ), p->font() ); - richtext.adjustSize(); - int x = ( width()-richtext.widthUsed() )/2, y = ( height()-richtext.height() )/2; - x = QMAX( x, 0 ); - y = QMAX( y, 0 ); - richtext.draw( p, x, y, TQRect( x, y, richtext.widthUsed(), richtext.height() ), tqcolorGroup() ); - m_boundingrect = TQRect(); - } - else - { - int totalx = m_cols*m_pw, totaly = m_rows*m_ph; - float scale = QMIN( float( width()-1 )/totalx, float( height()-1 )/totaly ); - p->translate( 0, height()-1 ); - p->scale( scale, -scale ); - int x = ( int )( width()/scale-totalx )/2, y = ( int )( height()/scale-totaly )/2; - p->translate( x, y ); - m_boundingrect = p->xForm( TQRect( 0, 0, totalx, totaly ) ); - - x = y = 0; - int px = m_posterbb.x(), py = m_posterbb.y(), pw = m_posterbb.width(), ph = m_posterbb.height(); - for ( int i=0; i<m_rows; i++, y+=m_ph, x=0 ) - { - for ( int j=0; j<m_cols; j++, x+=m_pw ) - { - bool selected = ( m_selectedpages.find( i*m_cols+j+1 ) != m_selectedpages.end() ); - p->fillRect( x+1, y+1, m_pw-2, m_ph-2, ( selected ? KGlobalSettings::highlightColor() : white ) ); - p->drawRect( x, y, m_pw, m_ph ); - if ( pw > 0 && ph > 0 ) - p->fillRect( x+m_mw+px, y+m_mh+py, QMIN( pw, m_pw-2*m_mw-px ), QMIN( ph, m_ph-2*m_mh-py ), - ( selected ? TQColor(KGlobalSettings::highlightColor().dark( 160 )) : lightGray ) ); - p->setPen( Qt::DotLine ); - p->drawRect( x+m_mw, y+m_mh, m_pw-2*m_mw, m_ph-2*m_mh ); - p->setPen( Qt::SolidLine ); - - pw -= m_pw-2*m_mw-px; - px = 0; - } - - px = m_posterbb.x(); - ph -= m_ph-2*m_mh-py; - py = 0; - pw = m_posterbb.width(); - } - } - } - - delete p; - painter->drawPixmap( 0, 0, pix ); -} - -void PosterPreview::mouseMoveEvent( TQMouseEvent *e ) -{ - if ( m_boundingrect.isValid() ) - { - if ( m_boundingrect.contains( e->pos() ) ) - setCursor( KCursor::handCursor() ); - else - setCursor( KCursor::arrowCursor() ); - } -} - -void PosterPreview::mousePressEvent( TQMouseEvent *e ) -{ - if ( e->button() == Qt::LeftButton && m_boundingrect.isValid() ) - { - if ( m_boundingrect.contains( e->pos() ) ) - { - int c, r; - c = ( e->pos().x()-m_boundingrect.x() )/( m_boundingrect.width()/m_cols ) + 1; - r = m_rows - ( e->pos().y()-m_boundingrect.y() )/( m_boundingrect.height()/m_rows ); - int pagenum = ( r-1 )*m_cols+c; - - if ( m_selectedpages.find( pagenum ) == m_selectedpages.end() || - !( e->state() & TQt::ShiftButton ) ) - { - if ( !( e->state() & TQt::ShiftButton ) ) - m_selectedpages.clear(); - m_selectedpages.append( pagenum ); - update(); - emitSelectedPages(); - } - } - else if ( m_selectedpages.count() > 0 ) - { - m_selectedpages.clear(); - update(); - emitSelectedPages(); - } - } -} - -void PosterPreview::slotProcessStderr( KProcess*, char *buf, int len ) -{ - m_buffer.append( TQCString( buf, len ) ); -} - -void PosterPreview::slotProcessExited( KProcess* ) -{ - if ( m_process->normalExit() && m_process->exitStatus() == 0 ) - parseBuffer(); - else - m_rows = m_cols = 0; - - m_dirty = false; - update(); -} - -void PosterPreview::setPosterSize( int s ) -{ - setPosterSize( pageSizeToPageName( KPrinter::PageSize( s ) ) ); -} - -void PosterPreview::setPosterSize( const TQString& s ) -{ - if ( m_postersize != s ) - { - m_selectedpages.clear(); - m_postersize = s; - setDirty(); - emitSelectedPages(); - } -} - -void PosterPreview::setMediaSize( int s ) -{ - setMediaSize( pageSizeToPageName( ( KPrinter::PageSize )s ) ); -} - -void PosterPreview::setMediaSize( const TQString& s ) -{ - if ( m_mediasize != s ) - { - m_selectedpages.clear(); - m_mediasize = s; - setDirty(); - emitSelectedPages(); - } -} - -void PosterPreview::setCutMargin( int value ) -{ - m_cutmargin = value; - setDirty(); -} - -void PosterPreview::setSelectedPages( const TQString& s ) -{ - TQStringList l = TQStringList::split( ",", s, false ); - m_selectedpages.clear(); - for ( TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it ) - { - int p; - if ( ( p = ( *it ).find( '-' ) ) == -1 ) - m_selectedpages.append( ( *it ).toInt() ); - else - { - int p1 = ( *it ).left( p ).toInt(), p2 = ( *it ).mid( p+1 ).toInt(); - for ( int i=p1; i<=p2; i++ ) - m_selectedpages.append( i ); - } - } - update(); -} - -void PosterPreview::emitSelectedPages() -{ - TQString s; - if ( m_selectedpages.count() > 0 ) - { - for ( TQValueList<int>::ConstIterator it=m_selectedpages.begin(); it!=m_selectedpages.end(); ++it ) - s.append( TQString::number( *it ) + "," ); - s.truncate( s.length()-1 ); - } - emit selectionChanged( s ); -} - -#include "posterpreview.moc" diff --git a/kdeprint/posterpreview.h b/kdeprint/posterpreview.h deleted file mode 100644 index d0c362a04..000000000 --- a/kdeprint/posterpreview.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2002 Michael Goffioul <tdeprint@swing.be> - * - * 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 POSTERPREVIEW_H -#define POSTERPREVIEW_H - -#include <tqframe.h> -#include <tqvaluelist.h> - -class KProcess; - -class PosterPreview : public TQFrame -{ - Q_OBJECT -public: - PosterPreview( TQWidget *parent = 0, const char *name = 0 ); - PosterPreview( const TQString& postersize, const TQString& mediasize, TQWidget *parent = 0, const char *name = 0 ); - ~PosterPreview(); - -public slots: - void setPosterSize( int ); - void setPosterSize( const TQString& ); - void setMediaSize( int ); - void setMediaSize( const TQString& ); - void setCutMargin( int ); - void updatePoster(); - void setSelectedPages( const TQString& ); - -signals: - void selectionChanged( const TQString& ); - -protected: - void parseBuffer(); - void drawContents( TQPainter* ); - void init(); - void setDirty(); - void mouseMoveEvent( TQMouseEvent* ); - void mousePressEvent( TQMouseEvent* ); - void emitSelectedPages(); - -protected slots: - void slotProcessStderr( KProcess*, char*, int ); - void slotProcessExited( KProcess* ); - -private: - int m_rows, m_cols; - int m_pw, m_ph; // page size - int m_mw, m_mh; // cur margins - TQRect m_posterbb; // poster bounding box (without any margin) - KProcess *m_process; - TQString m_buffer; - TQString m_postersize, m_mediasize; - int m_cutmargin; - bool m_dirty; - TQRect m_boundingrect; - TQValueList<int> m_selectedpages; -}; - -#endif /* POSTERPREVIEW_H */ diff --git a/kdeprint/ppdloader.cpp b/kdeprint/ppdloader.cpp deleted file mode 100644 index 2e2250dd2..000000000 --- a/kdeprint/ppdloader.cpp +++ /dev/null @@ -1,531 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 "ppdloader.h" -#include "foomatic2loader.h" -#include "driver.h" - -#include <kfilterdev.h> -#include <kdebug.h> -#include <klocale.h> -#include <tqfile.h> -#include <math.h> - -void tdeprint_ppdscanner_init( TQIODevice* ); -void tdeprint_ppdscanner_terminate( bool deleteIt = true ); -int tdeprint_ppdscanner_numberoflines(); - -static TQString processLocaleString( const TQString& s ) -{ - TQString res; - uint pos = 0; - while ( pos < s.length() ) - { - TQChar c = s[ pos++ ]; - if ( c == '<' ) - { - bool flag = false; - uint hc = 0; - while ( pos < s.length() ) - { - TQChar cc = s[ pos++ ]; - uint _hc = 0; - if ( cc == '>' ) - break; - else if ( cc.isDigit() ) - _hc = cc.digitValue(); - else - _hc = cc.lower().latin1() - 'a' + 10; - if ( flag ) - { - hc |= _hc; - res.append( TQChar( hc ) ); - hc = 0; - } - else - hc = ( _hc << 4 ); - flag = !flag; - } - } - else - { - res.append( c ); - } - } - return res; -} - -static TQValueList<float> splitNumberString( const TQString& _s ) -{ - TQString s = _s.simplifyWhiteSpace(); - TQValueList<float> l; - int p1 = 1, p2 = 0; - while ( true ) - { - p2 = s.find( ' ', p1 ); - if ( p2 != -1 ) - { - l.append( s.mid( p1, p2-p1 ).toFloat() ); - p1 = p2+1; - } - else - { - // ignore the final quote - l.append( s.mid( p1, s.length() - p1 - 1 ).toFloat() ); - break; - } - } - return l; -} - -struct PS_private -{ - TQString name; - struct - { - float width, height; - } size; - struct - { - float left, bottom, right, top; - } area; -}; - -PPDLoader::PPDLoader() -{ - m_option = 0; - m_ps.setAutoDelete( true ); -} - -PPDLoader::~PPDLoader() -{ -} - -DrMain* PPDLoader::readFromFile( const TQString& filename ) -{ - // Initialization - m_groups.clear(); - m_option = NULL; - m_fonts.clear(); - // Open driver file - TQIODevice *d = KFilterDev::deviceForFile( filename ); - if ( d && d->open( IO_ReadOnly ) ) - { - DrMain *driver = new DrMain; - bool result = true; - - m_groups.push( driver ); - tdeprint_ppdscanner_init( d ); - if ( tdeprint_ppdparse( this ) != 0 ) - result = false; - tdeprint_ppdscanner_terminate( true ); - - if ( result ) - { - if ( m_groups.size() > 1 ) - kdWarning( 500 ) << "PPD syntax error, GROUP specification not correctly closed" << endl; - if ( driver->has( "foodata" ) ) - { - Foomatic2Loader loader; - if ( loader.readFromBuffer( driver->get( "foodata" ) ) ) - { - driver = loader.modifyDriver( driver ); - } - else - kdWarning( 500 ) << "PPD syntax error, Foomatic data read failed" << endl; - } - processPageSizes( driver ); - if ( !m_fonts.isEmpty() ) - driver->set( "fonts", m_fonts.join( "," ) ); - return driver; - } - else - kdWarning( 500 ) << "PPD syntax error, PPD parse failed" << endl; - delete driver; - m_ps.clear(); - } - else - kdWarning( 500 ) << "PPD read error, unable to open device for file " << filename << endl; - return 0; -} - -DrMain* PPDLoader::loadDriver( const TQString& filename, TQString* msg ) -{ - PPDLoader loader; - DrMain *driver = loader.readFromFile( filename ); - if ( !driver && msg ) - *msg = filename + i18n( "(line %1): " ).arg( tdeprint_ppdscanner_numberoflines() ) + loader.errorMsg(); - return driver; -} - -bool PPDLoader::openUi( const TQString& name, const TQString& desc, const TQString& type ) -{ - if ( m_option ) - { - qWarning( "PPD syntax error, UI specification not correctly closed" ); - endUi( m_option->name() ); - } - - if ( type == "PickOne" || type == "PickMany" ) - m_option = new DrListOption; - else if ( type == "Boolean" ) - m_option = new DrBooleanOption; - else - return false; - if ( name[ 0 ] == '*' ) - m_option->setName( name.mid( 1 ) ); - else - m_option->setName( name ); - if ( desc.isEmpty() ) - m_option->set( "text", m_option->name() ); - else - m_option->set( "text", processLocaleString( desc ) ); - return true; -} - -bool PPDLoader::endUi( const TQString& name ) -{ - if ( m_option && ( m_option->name() == name || m_option->name() == name.mid( 1 ) ) ) - { - if ( m_option->name() == "PageRegion" ) - delete m_option; - else - { - TQString defval = m_option->get( "default" ); - DrGroup *grp = 0; - if ( !defval.isEmpty() ) - m_option->setValueText( defval ); - if ( m_groups.size() == 1 ) - { - // we don't have any group defined, create the - // most adapted one. - grp = findOrCreateGroupForOption( m_option->name() ); - } - else - grp = m_groups.top(); - grp->addOption( m_option ); - if ( grp->get( "text" ).contains( "install", false ) ) - m_option->set( "fixed", "1" ); - } - m_option = 0; - return true; - } - return false; -} - -bool PPDLoader::openGroup( const TQString& name, const TQString& desc ) -{ - DrGroup *grp = new DrGroup; - grp->setName( name ); - if ( desc.isEmpty() ) - grp->set( "text", name ); - else - grp->set( "text", processLocaleString( desc ) ); - m_groups.top()->addGroup( grp ); - m_groups.push( grp ); - return true; -} - -bool PPDLoader::endGroup( const TQString& name ) -{ - if ( m_groups.size() > 1 && m_groups.top()->name() == name ) - { - m_groups.pop(); - return true; - } - return false; -} - -bool PPDLoader::putStatement( const TQString& keyword, const TQString& name, const TQString& desc, const TQStringList& values ) -{ - if ( m_option ) - { - if ( !name.isEmpty() && m_option->name() == keyword ) - { - if ( m_option->type() >= DrBase::List ) - { - DrBase *ch = new DrBase; - ch->setName( name ); - if ( desc.isEmpty() ) - ch->set( "text", name ); - else - ch->set( "text", processLocaleString( desc ) ); - static_cast<DrListOption*>( m_option )->addChoice( ch ); - } - else - { - TQString fv = m_option->get( "fixedvals" ); - if ( fv.isEmpty() ) - fv = name; - else - fv.append( "|" + name ); - m_option->set( "fixedvals", fv ); - } - } - else if ( keyword == "FoomaticRIPOption" && name == m_option->name() - && values.size() > 1 ) - { - TQString type = values[ 0 ]; - if ( type == "float" || type == "int" ) - { - DrBase *opt = 0; - if ( type == "float" ) - opt = new DrFloatOption; - else - opt = new DrIntegerOption; - opt->setName( m_option->name() ); - opt->set( "text", m_option->get( "text" ) ); - opt->set( "default", m_option->get( "default" ) ); - if ( m_option->type() == DrBase::List ) - { - TQStringList vals; - TQPtrListIterator<DrBase> it( *( static_cast<DrListOption*>( m_option )->choices() ) ); - for ( ; it.current(); ++it ) - vals.append( it.current()->name() ); - opt->set( "fixedvals", vals.join( "|" ) ); - } - delete m_option; - m_option = opt; - } - // FIXME: support other option types - } - else if ( keyword == "FoomaticRIPOptionRange" && name == m_option->name() - && values.size() >= 2 && ( m_option->type() == DrBase::Float || m_option->type() == DrBase::Integer ) ) - { - m_option->set( "minval", values[ 0 ] ); - m_option->set( "maxval", values[ 1 ] ); - } - } - else if ( keyword == "Font" && m_groups.size() > 0 ) - { - m_fonts << name; - } - return true; -} - -bool PPDLoader::putStatement2( const TQString& keyword, const TQString& value ) -{ - if ( !m_option && m_groups.size() == 1 ) - { - DrGroup *driver = m_groups.top(); - if ( keyword == "NickName" ) - { - driver->set( "text", value ); - driver->set( "description", value ); - } - else if ( keyword == "Manufacturer" ) - driver->set( "manufacturer", value ); - else if ( keyword == "ShortNickName" ) - driver->set( "model", value ); - else if ( keyword == "ColorDevice" ) - driver->set( "colordevice", value == "True" ? "1" : "0" ); - } - return true; -} - -bool PPDLoader::putDefault( const TQString& keyword, const TQString& value ) -{ - if ( keyword == "Resolution" && m_groups.size() > 0 ) - { - // Store default resolution as it could be fed back - // to the application. And default resolution can - // occur outside a OpenUI/CloseUI pair. - m_groups[ 0 ]->set( "resolution", value ); - } - - if ( m_option && m_option->name() == keyword ) - { - m_option->set( "default", value ); - return true; - } - else - return false; -} - -bool PPDLoader::putConstraint( const TQString& opt1, const TQString& opt2, const TQString& ch1, const TQString& ch2 ) -{ - if ( !m_option && m_groups.size() == 1 ) - { - DrMain *driver = static_cast<DrMain*>( m_groups.top() ); - driver->addConstraint( new DrConstraint( opt1, opt2, ch1, ch2 ) ); - } - return true; -} - -bool PPDLoader::putFooData( const TQString& data ) -{ - if ( !m_option && m_groups.size() == 1 ) - { - m_groups.top()->set( "foodata", m_groups.top()->get( "foodata" ) + data + "\n" ); - } - return true; -} - -bool PPDLoader::putFooProcessedData( const TQVariant& var ) -{ - TQMap<TQString,TQVariant>::ConstIterator it = var.mapFind( "args_byname" ); - if ( it != var.mapEnd() ) - { - TQVariant opts = it.data(); - for ( it = opts.mapBegin(); it != opts.mapEnd(); ++it ) - { - TQMap<TQString,TQVariant> opt = it.data().toMap(); - TQString type = opt[ "type" ].toString(); - if ( type == "float" || type == "int" ) - { - DrBase *o; - if ( type == "float" ) - o = new DrFloatOption; - else - o = new DrIntegerOption; - o->setName( opt[ "name" ].toString() ); - o->set( "text", opt[ "comment" ].toString() ); - o->set( "minval", opt[ "min" ].toString() ); - o->set( "maxval", opt[ "max" ].toString() ); - o->set( "default", opt[ "default" ].toString() ); - o->setValueText( o->get( "default" ) ); - - DrGroup *grp = 0; - DrBase *old = m_groups.top()->findOption( o->name(), &grp ); - if ( old ) - { - if ( old->type() == DrBase::List ) - { - TQStringList vals; - TQPtrListIterator<DrBase> it( *( static_cast<DrListOption*>( old )->choices() ) ); - for ( ; it.current(); ++it ) - vals.append( it.current()->name() ); - o->set( "fixedvals", vals.join( "|" ) ); - } - grp->removeOption( o->name() ); - grp->addOption( o ); - } - else - { - qWarning( "Option %s not found in original PPD file", o->name().latin1() ); - delete o; - } - } - } - } - return true; -} - -bool PPDLoader::putPaperDimension( const TQString& name, const TQString& s ) -{ - TQValueList<float> l = splitNumberString( s ); - - PS_private *ps = m_ps.find( name ); - if ( !ps ) - { - ps = new PS_private; - ps->name = name; - m_ps.insert( name, ps ); - } - ps->size.width = l[ 0 ]; - ps->size.height = l[ 1 ]; - - return true; -} - -bool PPDLoader::putImageableArea( const TQString& name, const TQString& s ) -{ - TQValueList<float> l = splitNumberString( s ); - - PS_private *ps = m_ps.find( name ); - if ( !ps ) - { - ps = new PS_private; - ps->name = name; - m_ps.insert( name, ps ); - } - ps->area.left = l[ 0 ]; - ps->area.bottom = l[ 1 ]; - ps->area.right = l[ 2 ]; - ps->area.top = l[ 3 ]; - - return true; -} - -DrGroup* PPDLoader::findOrCreateGroupForOption( const TQString& optname ) -{ - TQString grpname; - if ( optname == "PageSize" || - optname == "InputSlot" || - optname == "ManualFeed" || - optname == "MediaType" || - optname == "MediaColor" || - optname == "MediaWeight" ) - grpname = "General"; - else if ( optname.startsWith( "stp" ) || - optname == "Cyan" || - optname == "Yellow" || - optname == "Magenta" || - optname == "Density" || - optname == "Contrast" ) - grpname = "Adjustments"; - else if ( optname.startsWith( "JCL" ) ) - grpname = "JCL"; - else - grpname = "Others"; - - DrGroup *grp = 0; - for ( TQPtrListIterator<DrGroup> it( m_groups[ 0 ]->groups() ); it.current(); ++it ) - if ( it.current()->name() == grpname ) - { - grp = it.current(); - break; - } - if ( !grp ) - { - grp = new DrGroup; - grp->setName( grpname ); - grp->set( "text", grpname ); - m_groups[ 0 ]->addGroup( grp ); - } - return grp; -} - -void PPDLoader::processPageSizes( DrMain *driver ) -{ - TQDictIterator<PS_private> it( m_ps ); - for ( ; it.current(); ++it ) - { - //qDebug( "ADDING PAGESIZE: %16s, Size = ( %.2f, %.2f ), Area = ( %.2f, %.2f, %.2f, %.2f )", it.current()->name.latin1(), - // it.current()->size.width, it.current()->size.height, - // it.current()->area.left, it.current()->area.bottom, - // it.current()->area.right, it.current()->area.top ); - driver->addPageSize( new DrPageSize( it.current()->name, - ( int )it.current()->size.width, ( int )it.current()->size.height, - ( int )it.current()->area.left, ( int )it.current()->area.bottom, - ( int )ceil( it.current()->size.width - it.current()->area.right ), - ( int )ceil( it.current()->size.height - it.current()->area.top ) ) ); - } - m_ps.clear(); -} - -void PPDLoader::setErrorMsg( const TQString& msg ) -{ - m_errormsg = msg; -} - -TQString PPDLoader::errorMsg() const -{ - return m_errormsg; -} diff --git a/kdeprint/ppdloader.h b/kdeprint/ppdloader.h deleted file mode 100644 index c4eb9fbb5..000000000 --- a/kdeprint/ppdloader.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 PPDLOADER_H -#define PPDLOADER_H - -#include <tqvaluestack.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqvariant.h> -#include <tqdict.h> - -#include <kdelibs_export.h> - -class DrGroup; -class DrBase; -class DrMain; -struct PS_private; - -class KDEPRINT_EXPORT PPDLoader -{ -public: - PPDLoader(); - ~PPDLoader(); - - DrMain* readFromFile( const TQString& filename ); - - bool openUi( const TQString& name, const TQString& desc, const TQString& type ); - bool endUi( const TQString& name ); - bool openGroup( const TQString& name, const TQString& desc ); - bool endGroup( const TQString& name ); - bool putStatement( const TQString& keyword, const TQString& name, const TQString& desc, const TQStringList& values ); - bool putStatement2( const TQString& keyword, const TQString& value ); - bool putDefault( const TQString& keyword, const TQString& value ); - bool putConstraint( const TQString& opt1, const TQString& opt2, const TQString& ch1, const TQString& ch2 ); - bool putFooData( const TQString& data ); - bool putFooProcessedData( const TQVariant& var ); - bool putPaperDimension( const TQString& name, const TQString& s ); - bool putImageableArea( const TQString& name, const TQString& s ); - - void setErrorMsg( const TQString& msg ); - TQString errorMsg() const; - - static DrMain* loadDriver( const TQString& filename, TQString* msg = NULL ); - -private: - TQValueStack<DrGroup*> m_groups; - DrBase* m_option; - TQDict<PS_private> m_ps; - TQStringList m_fonts; - TQString m_errormsg; - - friend int tdeprint_ppdparse(void*); - DrGroup* findOrCreateGroupForOption( const TQString& ); - void processPageSizes( DrMain* ); -}; - -#endif /* PPDLOADER_H */ diff --git a/kdeprint/ppdparser.cpp b/kdeprint/ppdparser.cpp deleted file mode 100644 index 21f3fb77e..000000000 --- a/kdeprint/ppdparser.cpp +++ /dev/null @@ -1,1456 +0,0 @@ -/* A Bison parser, made by GNU Bison 1.875. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* If NAME_PREFIX is specified substitute the variables and functions - names. */ -#define yyparse tdeprint_ppdparse -#define yylex tdeprint_ppdlex -#define yyerror tdeprint_ppderror -#define yylval tdeprint_ppdlval -#define yychar tdeprint_ppdchar -#define yydebug tdeprint_ppddebug -#define yynerrs tdeprint_ppdnerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TRANSLATION = 258, - OPENUI = 259, - CLOSEUI = 260, - OPENGROUP = 261, - CLOSEGROUP = 262, - DEFAULT = 263, - KEYWORD = 264, - OPTION = 265, - STRINGPART = 266, - QUOTED = 267, - CONSTRAINT = 268, - PAPERDIM = 269, - IMGAREA = 270, - FOODATA = 271, - COMMENT = 272 - }; -#endif -#define TRANSLATION 258 -#define OPENUI 259 -#define CLOSEUI 260 -#define OPENGROUP 261 -#define CLOSEGROUP 262 -#define DEFAULT 263 -#define KEYWORD 264 -#define OPTION 265 -#define STRINGPART 266 -#define QUOTED 267 -#define CONSTRAINT 268 -#define PAPERDIM 269 -#define IMGAREA 270 -#define FOODATA 271 -#define COMMENT 272 - - - - -/* Copy the first part of user declarations. */ -#line 1 "./ppdparser.y" - -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -#define YYSTYPE TQStringList -#define YYPARSE_PARAM ppdloader -#define YYDEBUG 1 -#define YYERROR_VERBOSE 1 -#include <stdlib.h> -#include <tqstringlist.h> - -#include "ppdloader.h" - -#define builder static_cast<PPDLoader*>( ppdloader ) - -int tdeprint_ppdlex(); -#define tdeprint_ppderror(msg) static_cast<PPDLoader*>( ppdloader )->setErrorMsg( msg ) - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 164 "./ppdparser.cpp" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 33 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 99 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 20 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 12 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 41 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 86 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 272 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 18, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 19, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned char yyprhs[] = -{ - 0, 0, 3, 5, 8, 10, 13, 16, 18, 20, - 24, 28, 33, 40, 45, 52, 57, 64, 68, 71, - 75, 81, 85, 91, 98, 104, 110, 115, 119, 124, - 131, 137, 141, 147, 149, 151, 153, 155, 157, 159, - 161, 163 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 21, 0, -1, 31, -1, 21, 31, -1, 11, -1, - 22, 11, -1, 22, 12, -1, 22, -1, 12, -1, - 12, 18, 3, -1, 22, 18, 3, -1, 14, 10, - 19, 12, -1, 14, 10, 18, 3, 19, 12, -1, - 15, 10, 19, 12, -1, 15, 10, 18, 3, 19, - 12, -1, 4, 10, 19, 22, -1, 4, 10, 18, - 3, 19, 22, -1, 5, 19, 22, -1, 5, 22, - -1, 6, 19, 22, -1, 6, 19, 22, 18, 3, - -1, 7, 19, 22, -1, 7, 19, 22, 18, 3, - -1, 13, 19, 9, 10, 9, 10, -1, 13, 19, - 9, 10, 9, -1, 13, 19, 9, 9, 10, -1, - 13, 19, 9, 9, -1, 9, 19, 23, -1, 9, - 10, 19, 23, -1, 9, 10, 18, 3, 19, 23, - -1, 9, 10, 18, 19, 23, -1, 8, 19, 22, - -1, 8, 19, 22, 18, 3, -1, 26, -1, 27, - -1, 28, -1, 29, -1, 24, -1, 25, -1, 30, - -1, 17, -1, 16, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned char yyrline[] = -{ - 0, 54, 54, 55, 58, 59, 60, 63, 64, 65, - 66, 69, 70, 73, 74, 77, 78, 81, 82, 85, - 86, 89, 90, 93, 94, 95, 96, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "TRANSLATION", "OPENUI", "CLOSEUI", - "OPENGROUP", "CLOSEGROUP", "DEFAULT", "KEYWORD", "OPTION", "STRINGPART", - "QUOTED", "CONSTRAINT", "PAPERDIM", "IMGAREA", "FOODATA", "COMMENT", - "'/'", "':'", "$accept", "ppdfile", "string", "value", "paperdim", - "imgarea", "openui", "endui", "opengroup", "endgroup", "constraint", - "ppdelement", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 47, 58 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 20, 21, 21, 22, 22, 22, 23, 23, 23, - 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, - 28, 29, 29, 30, 30, 30, 30, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 2, 1, 2, 2, 1, 1, 3, - 3, 4, 6, 4, 6, 4, 6, 3, 2, 3, - 5, 3, 5, 6, 5, 5, 4, 3, 4, 6, - 5, 3, 5, 1, 1, 1, 1, 1, 1, 1, - 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 41, 40, 0, 37, 38, 33, 34, 35, 36, 39, - 2, 0, 4, 0, 18, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 3, 0, 0, 17, 5, 6, - 19, 21, 31, 0, 0, 8, 7, 27, 0, 0, - 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, - 28, 0, 0, 26, 0, 0, 11, 0, 13, 0, - 20, 22, 32, 0, 30, 9, 10, 25, 24, 0, - 0, 16, 29, 23, 12, 14 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = -{ - -1, 12, 46, 47, 13, 14, 15, 16, 17, 18, - 19, 20 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -44 -static const yysigned_char yypact[] = -{ - 45, 1, -6, -15, -13, 3, -7, 10, 5, 7, - -44, -44, 31, -44, -44, -44, -44, -44, -44, -44, - -44, -9, -44, 32, 16, 32, 32, 32, 14, 30, - 48, 37, 50, -44, -44, 68, 32, 16, -44, -44, - -4, 8, 52, -1, 30, 57, 54, -44, 64, 73, - 65, 75, 67, 61, 16, 78, 79, 80, 66, 30, - -44, 81, 83, 77, 82, 69, -44, 70, -44, 32, - -44, -44, -44, 30, -44, -44, -44, -44, 84, 85, - 86, 16, -44, -44, -44, -44 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = -{ - -44, -44, -2, -43, -44, -44, -44, -44, -44, -44, - -44, 87 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const unsigned char yytable[] = -{ - 24, 60, 58, 28, 25, 22, 26, 38, 39, 35, - 36, 21, 29, 23, 55, 31, 74, 32, 59, 38, - 39, 37, 27, 40, 41, 42, 56, 38, 39, 30, - 82, 33, 43, 44, 54, 1, 2, 3, 4, 5, - 6, 22, 45, 22, 7, 8, 9, 10, 11, 1, - 2, 3, 4, 5, 6, 49, 50, 48, 7, 8, - 9, 10, 11, 38, 39, 38, 39, 81, 51, 52, - 57, 53, 62, 63, 64, 61, 65, 66, 67, 68, - 69, 70, 71, 72, 75, 73, 76, 77, 79, 80, - 0, 78, 0, 0, 83, 0, 0, 84, 85, 34 -}; - -static const yysigned_char yycheck[] = -{ - 2, 44, 3, 10, 19, 11, 19, 11, 12, 18, - 19, 10, 19, 19, 18, 10, 59, 10, 19, 11, - 12, 23, 19, 25, 26, 27, 18, 11, 12, 19, - 73, 0, 18, 19, 36, 4, 5, 6, 7, 8, - 9, 11, 12, 11, 13, 14, 15, 16, 17, 4, - 5, 6, 7, 8, 9, 18, 19, 9, 13, 14, - 15, 16, 17, 11, 12, 11, 12, 69, 18, 19, - 18, 3, 18, 9, 10, 18, 3, 12, 3, 12, - 19, 3, 3, 3, 3, 19, 3, 10, 19, 19, - -1, 9, -1, -1, 10, -1, -1, 12, 12, 12 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 4, 5, 6, 7, 8, 9, 13, 14, 15, - 16, 17, 21, 24, 25, 26, 27, 28, 29, 30, - 31, 10, 11, 19, 22, 19, 19, 19, 10, 19, - 19, 10, 10, 0, 31, 18, 19, 22, 11, 12, - 22, 22, 22, 18, 19, 12, 22, 23, 9, 18, - 19, 18, 19, 3, 22, 18, 18, 18, 3, 19, - 23, 18, 18, 9, 10, 3, 12, 3, 12, 19, - 3, 3, 3, 19, 23, 3, 3, 10, 9, 19, - 19, 22, 23, 10, 12, 12 -}; - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up");\ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short *bottom, short *top) -#else -static void -yy_stack_print (bottom, top) - short *bottom; - short *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylineno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylineno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 4: -#line 58 "./ppdparser.y" - { yyval = yyvsp[0]; ;} - break; - - case 5: -#line 59 "./ppdparser.y" - { yyvsp[-1] += yyvsp[0]; yyval = yyvsp[-1]; ;} - break; - - case 6: -#line 60 "./ppdparser.y" - { yyvsp[-1] += yyvsp[0]; yyval = yyvsp[-1]; ;} - break; - - case 7: -#line 63 "./ppdparser.y" - { yyval = yyvsp[0]; ;} - break; - - case 8: -#line 64 "./ppdparser.y" - { yyval = yyvsp[0][0].mid(1,yyvsp[0][0].length()-2); ;} - break; - - case 9: -#line 65 "./ppdparser.y" - { yyval = yyvsp[-2][0].mid(1,yyvsp[-2][0].length()-2); ;} - break; - - case 10: -#line 66 "./ppdparser.y" - { yyval = yyvsp[-2]; ;} - break; - - case 11: -#line 69 "./ppdparser.y" - { builder->putPaperDimension(yyvsp[-2][0], yyvsp[0][0]); ;} - break; - - case 12: -#line 70 "./ppdparser.y" - { builder->putPaperDimension(yyvsp[-4][0], yyvsp[0][0]); ;} - break; - - case 13: -#line 73 "./ppdparser.y" - { builder->putImageableArea(yyvsp[-2][0], yyvsp[0][0]); ;} - break; - - case 14: -#line 74 "./ppdparser.y" - { builder->putImageableArea(yyvsp[-4][0], yyvsp[0][0]); ;} - break; - - case 15: -#line 77 "./ppdparser.y" - { builder->openUi(yyvsp[-2][0], TQString::null, yyvsp[0][0]); ;} - break; - - case 16: -#line 78 "./ppdparser.y" - { builder->openUi(yyvsp[-4][0], yyvsp[-2][0], yyvsp[0][0]); ;} - break; - - case 17: -#line 81 "./ppdparser.y" - { builder->endUi(yyvsp[0][0]); ;} - break; - - case 18: -#line 82 "./ppdparser.y" - { builder->endUi(yyvsp[0][0]); ;} - break; - - case 19: -#line 85 "./ppdparser.y" - { builder->openGroup(yyvsp[0].join(" "), TQString::null); ;} - break; - - case 20: -#line 86 "./ppdparser.y" - { builder->openGroup(yyvsp[-2].join(" "), yyvsp[0][0]); ;} - break; - - case 21: -#line 89 "./ppdparser.y" - { builder->endGroup(yyvsp[0].join(" ")); ;} - break; - - case 22: -#line 90 "./ppdparser.y" - { builder->endGroup(yyvsp[-2].join(" ")); ;} - break; - - case 23: -#line 93 "./ppdparser.y" - { builder->putConstraint(yyvsp[-3][0], yyvsp[-1][0], yyvsp[-2][0], yyvsp[0][0]); ;} - break; - - case 24: -#line 94 "./ppdparser.y" - { builder->putConstraint(yyvsp[-2][0], yyvsp[0][0], yyvsp[-1][0], TQString::null); ;} - break; - - case 25: -#line 95 "./ppdparser.y" - { builder->putConstraint(yyvsp[-2][0], yyvsp[-1][0], TQString::null, yyvsp[0][0]); ;} - break; - - case 26: -#line 96 "./ppdparser.y" - { builder->putConstraint(yyvsp[-1][0], yyvsp[0][0], TQString::null, TQString::null); ;} - break; - - case 27: -#line 99 "./ppdparser.y" - { builder->putStatement2(yyvsp[-2][0], yyvsp[0][0]); ;} - break; - - case 28: -#line 100 "./ppdparser.y" - { builder->putStatement(yyvsp[-3][0], yyvsp[-2][0], TQString::null, yyvsp[0]); ;} - break; - - case 29: -#line 101 "./ppdparser.y" - { builder->putStatement(yyvsp[-5][0], yyvsp[-4][0], yyvsp[-2][0], yyvsp[0]); ;} - break; - - case 30: -#line 102 "./ppdparser.y" - { builder->putStatement(yyvsp[-4][0], yyvsp[-3][0], TQString::null, yyvsp[-1]); ;} - break; - - case 31: -#line 103 "./ppdparser.y" - { builder->putDefault(yyvsp[-2][0], yyvsp[0][0]); ;} - break; - - case 32: -#line 104 "./ppdparser.y" - { builder->putDefault(yyvsp[-4][0], yyvsp[-2][0]); ;} - break; - - case 41: -#line 113 "./ppdparser.y" - { builder->putFooData(yyvsp[0][0]); ;} - break; - - - } - -/* Line 999 of yacc.c. */ -#line 1258 "./ppdparser.cpp" - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - char *yymsg; - int yyx, yycount; - - yycount = 0; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("syntax error, unexpected ") + 1; - yysize += yystrlen (yytname[yytype]); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); - yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* Return failure if at end of input. */ - if (yychar == YYEOF) - { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyss < yyssp) - { - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - YYPOPSTACK; - } - YYABORT; - } - - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; - - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -#line 116 "./ppdparser.y" - - -#undef builder - diff --git a/kdeprint/ppdparser.cpp.h b/kdeprint/ppdparser.cpp.h deleted file mode 100644 index 182bebd34..000000000 --- a/kdeprint/ppdparser.cpp.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef ppdparser_cpp_h -#define ppdparser_cpp_h -/* A Bison parser, made by GNU Bison 1.875. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TRANSLATION = 258, - OPENUI = 259, - CLOSEUI = 260, - OPENGROUP = 261, - CLOSEGROUP = 262, - DEFAULT = 263, - KEYWORD = 264, - OPTION = 265, - STRINGPART = 266, - QUOTED = 267, - CONSTRAINT = 268, - PAPERDIM = 269, - IMGAREA = 270, - FOODATA = 271, - COMMENT = 272 - }; -#endif -#define TRANSLATION 258 -#define OPENUI 259 -#define CLOSEUI 260 -#define OPENGROUP 261 -#define CLOSEGROUP 262 -#define DEFAULT 263 -#define KEYWORD 264 -#define OPTION 265 -#define STRINGPART 266 -#define QUOTED 267 -#define CONSTRAINT 268 -#define PAPERDIM 269 -#define IMGAREA 270 -#define FOODATA 271 -#define COMMENT 272 - - - - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE tdeprint_ppdlval; - - - -#endif diff --git a/kdeprint/ppdparser.y b/kdeprint/ppdparser.y deleted file mode 100644 index f750d9316..000000000 --- a/kdeprint/ppdparser.y +++ /dev/null @@ -1,118 +0,0 @@ -%{ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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. - **/ - -#define YYSTYPE TQStringList -#define YYPARSE_PARAM ppdloader -#define YYDEBUG 1 -#define YYERROR_VERBOSE 1 -#include <stdlib.h> -#include <qstringlist.h> - -#include "ppdloader.h" - -#define builder static_cast<PPDLoader*>( ppdloader ) - -int tdeprint_ppdlex(); -#define tdeprint_ppderror(msg) static_cast<PPDLoader*>( ppdloader )->setErrorMsg( msg ) -%} - -%token TRANSLATION -%token OPENUI -%token CLOSEUI -%token OPENGROUP -%token CLOSEGROUP -%token DEFAULT -%token KEYWORD -%token OPTION -%token STRINGPART -%token QUOTED -%token CONSTRAINT -%token PAPERDIM -%token IMGAREA -%token FOODATA -%token COMMENT - -%% - -ppdfile: ppdelement - | ppdfile ppdelement -; - -string: STRINGPART { $$ = $1; } - | string STRINGPART { $1 += $2; $$ = $1; } - | string QUOTED { $1 += $2; $$ = $1; } -; - -value: string { $$ = $1; } - | QUOTED { $$ = $1[0].mid(1,$1[0].length()-2); } - | QUOTED '/' TRANSLATION { $$ = $1[0].mid(1,$1[0].length()-2); } - | string '/' TRANSLATION { $$ = $1; } -; - -paperdim: PAPERDIM OPTION ':' QUOTED { builder->putPaperDimension($2[0], $4[0]); } - | PAPERDIM OPTION '/' TRANSLATION ':' QUOTED { builder->putPaperDimension($2[0], $6[0]); } -; - -imgarea: IMGAREA OPTION ':' QUOTED { builder->putImageableArea($2[0], $4[0]); } - | IMGAREA OPTION '/' TRANSLATION ':' QUOTED { builder->putImageableArea($2[0], $6[0]); } -; - -openui: OPENUI OPTION ':' string { builder->openUi($2[0], QString::null, $4[0]); } - | OPENUI OPTION '/' TRANSLATION ':' string { builder->openUi($2[0], $4[0], $6[0]); } -; - -endui: CLOSEUI ':' string { builder->endUi($3[0]); } - | CLOSEUI string { builder->endUi($2[0]); } -; - -opengroup: OPENGROUP ':' string { builder->openGroup($3.join(" "), QString::null); } - | OPENGROUP ':' string '/' TRANSLATION { builder->openGroup($3.join(" "), $5[0]); } -; - -endgroup: CLOSEGROUP ':' string { builder->endGroup($3.join(" ")); } - | CLOSEGROUP ':' string '/' TRANSLATION { builder->endGroup($3.join(" ")); } -; - -constraint: CONSTRAINT ':' KEYWORD OPTION KEYWORD OPTION { builder->putConstraint($3[0], $5[0], $4[0], $6[0]); } - | CONSTRAINT ':' KEYWORD OPTION KEYWORD { builder->putConstraint($3[0], $5[0], $4[0], QString::null); } - | CONSTRAINT ':' KEYWORD KEYWORD OPTION { builder->putConstraint($3[0], $4[0], QString::null, $5[0]); } - | CONSTRAINT ':' KEYWORD KEYWORD { builder->putConstraint($3[0], $4[0], QString::null, QString::null); } -; - -ppdelement: KEYWORD ':' value { builder->putStatement2($1[0], $3[0]); } - | KEYWORD OPTION ':' value { builder->putStatement($1[0], $2[0], QString::null, $4); } - | KEYWORD OPTION '/' TRANSLATION ':' value { builder->putStatement($1[0], $2[0], $4[0], $6); } - | KEYWORD OPTION '/' ':' value { builder->putStatement($1[0], $2[0], QString::null, $4); } - | DEFAULT ':' string { builder->putDefault($1[0], $3[0]); } - | DEFAULT ':' string '/' TRANSLATION { builder->putDefault($1[0], $3[0]); } - | openui - | endui - | opengroup - | endgroup - | paperdim - | imgarea - | constraint - | COMMENT - | FOODATA { builder->putFooData($1[0]); } -; - -%% - -#undef builder diff --git a/kdeprint/ppdscanner.cpp b/kdeprint/ppdscanner.cpp deleted file mode 100644 index 50611aaa1..000000000 --- a/kdeprint/ppdscanner.cpp +++ /dev/null @@ -1,1914 +0,0 @@ -#define yy_create_buffer tdeprint_ppd_create_buffer -#define yy_delete_buffer tdeprint_ppd_delete_buffer -#define yy_scan_buffer tdeprint_ppd_scan_buffer -#define yy_scan_string tdeprint_ppd_scan_string -#define yy_scan_bytes tdeprint_ppd_scan_bytes -#define yy_flex_debug tdeprint_ppd_flex_debug -#define yy_init_buffer tdeprint_ppd_init_buffer -#define yy_flush_buffer tdeprint_ppd_flush_buffer -#define yy_load_buffer_state tdeprint_ppd_load_buffer_state -#define yy_switch_to_buffer tdeprint_ppd_switch_to_buffer -#define yyin tdeprint_ppdin -#define yyleng tdeprint_ppdleng -#define yylex tdeprint_ppdlex -#define yyout tdeprint_ppdout -#define yyrestart tdeprint_ppdrestart -#define yytext tdeprint_ppdtext - -#line 19 "./ppdscanner.cpp" -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include <stdio.h> -#include <unistd.h> - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - - -#define yywrap() 1 -#define YY_SKIP_YYWRAP -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 37 -#define YY_END_OF_BUFFER 38 -static yyconst short int yy_accept[172] = - { 0, - 0, 0, 0, 0, 0, 0, 21, 21, 29, 29, - 0, 0, 38, 36, 35, 36, 19, 17, 20, 18, - 27, 25, 25, 26, 28, 21, 23, 22, 29, 30, - 34, 33, 36, 31, 16, 15, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 17, 25, 0, 25, 24, - 21, 29, 33, 32, 15, 15, 15, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 24, 15, 16, 16, - 13, 16, 16, 16, 16, 16, 16, 15, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, - - 16, 16, 16, 16, 16, 16, 16, 2, 16, 16, - 15, 16, 4, 16, 16, 16, 16, 16, 16, 2, - 16, 16, 15, 16, 4, 8, 8, 16, 16, 16, - 16, 16, 16, 16, 15, 16, 7, 16, 16, 1, - 16, 5, 16, 16, 15, 6, 16, 3, 16, 16, - 16, 15, 16, 16, 16, 16, 15, 14, 16, 16, - 16, 16, 12, 16, 16, 9, 16, 11, 16, 10, - 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 4, 5, 6, 4, 7, 4, 4, 4, - 4, 8, 4, 4, 4, 4, 9, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 11, 4, 4, - 4, 4, 4, 4, 12, 10, 13, 14, 15, 10, - 16, 10, 17, 18, 10, 19, 20, 21, 22, 23, - 10, 10, 10, 24, 25, 10, 10, 10, 10, 10, - 4, 4, 4, 4, 4, 4, 26, 27, 10, 28, - - 29, 30, 31, 10, 32, 10, 10, 33, 34, 35, - 36, 37, 10, 38, 39, 40, 41, 10, 10, 10, - 10, 10, 4, 4, 4, 4, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[42] = - { 0, - 1, 2, 3, 4, 4, 4, 4, 5, 1, 4, - 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4 - } ; - -static yyconst short int yy_base[194] = - { 0, - 0, 1, 3, 14, 17, 28, 25, 30, 300, 299, - 41, 45, 300, 303, 303, 50, 303, 0, 303, 303, - 303, 0, 75, 303, 303, 0, 303, 303, 0, 303, - 303, 0, 0, 303, 0, 78, 266, 269, 262, 262, - 282, 258, 256, 266, 274, 0, 0, 285, 89, 0, - 0, 0, 0, 0, 0, 276, 92, 252, 257, 258, - 259, 265, 248, 253, 244, 267, 303, 257, 239, 251, - 0, 245, 38, 250, 239, 244, 236, 251, 241, 228, - 239, 234, 229, 248, 45, 226, 228, 248, 58, 228, - 234, 223, 229, 244, 218, 238, 240, 214, 240, 213, - - 233, 209, 221, 208, 211, 209, 208, 100, 211, 202, - 217, 204, 105, 231, 205, 208, 211, 200, 193, 110, - 199, 194, 219, 189, 115, 0, 0, 200, 203, 210, - 187, 188, 195, 197, 219, 184, 0, 208, 202, 0, - 178, 0, 182, 184, 191, 0, 147, 0, 141, 135, - 67, 97, 68, 70, 56, 45, 80, 303, 43, 34, - 26, 20, 0, 23, 20, 0, 5, 0, 1, 0, - 303, 123, 129, 135, 141, 147, 153, 156, 159, 161, - 166, 172, 177, 6, 3, 183, 189, 195, 198, 200, - 202, 204, 209 - - } ; - -static yyconst short int yy_def[194] = - { 0, - 172, 172, 173, 173, 174, 174, 175, 175, 176, 176, - 177, 177, 171, 171, 171, 178, 171, 179, 171, 171, - 171, 180, 181, 171, 171, 182, 171, 171, 183, 171, - 171, 184, 185, 171, 178, 186, 178, 178, 178, 178, - 178, 178, 178, 178, 178, 179, 180, 187, 181, 180, - 182, 183, 184, 185, 188, 188, 186, 178, 178, 178, - 178, 178, 178, 178, 178, 178, 171, 188, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 188, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 188, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 178, 188, 178, - - 178, 178, 178, 178, 178, 178, 178, 189, 178, 178, - 188, 178, 190, 191, 178, 178, 178, 178, 178, 189, - 178, 178, 188, 178, 190, 191, 192, 178, 178, 178, - 178, 178, 178, 178, 188, 178, 192, 178, 178, 178, - 178, 178, 178, 178, 188, 178, 178, 178, 178, 178, - 178, 193, 178, 178, 178, 178, 193, 171, 178, 178, - 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, - 0, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171 - - } ; - -static yyconst short int yy_nxt[345] = - { 0, - 171, 15, 15, 14, 17, 14, 54, 16, 16, 53, - 171, 19, 171, 20, 14, 17, 14, 14, 21, 14, - 171, 23, 19, 171, 20, 24, 27, 25, 14, 21, - 14, 27, 23, 171, 171, 28, 24, 171, 25, 170, - 28, 14, 31, 14, 169, 14, 31, 14, 33, 14, - 82, 34, 33, 14, 168, 34, 36, 167, 166, 83, - 95, 165, 37, 38, 39, 164, 40, 41, 163, 96, - 42, 43, 44, 100, 45, 48, 48, 48, 55, 50, - 56, 158, 101, 48, 162, 48, 55, 161, 55, 48, - 48, 48, 55, 50, 55, 160, 159, 48, 158, 48, - - 55, 156, 55, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 14, 14, 14, 14, 14, 14, 18, - 18, 18, 18, 18, 18, 22, 22, 22, 22, 22, - 22, 26, 26, 26, 26, 26, 26, 29, 29, 29, - 29, 29, 29, 32, 32, 32, 32, 32, 32, 35, - 35, 46, 46, 46, 47, 47, 49, 49, 49, 49, - 49, 49, 51, 155, 51, 51, 51, 52, 154, 52, - 52, 52, 52, 57, 153, 57, 57, 57, 57, 48, - 48, 48, 48, 48, 48, 55, 152, 55, 55, 55, - - 55, 120, 120, 125, 125, 126, 126, 137, 137, 157, - 157, 157, 157, 157, 157, 151, 150, 149, 148, 147, - 146, 145, 144, 143, 142, 141, 140, 139, 138, 136, - 135, 134, 133, 132, 131, 130, 129, 128, 127, 124, - 123, 122, 121, 119, 118, 117, 116, 115, 114, 113, - 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, - 102, 99, 98, 97, 94, 93, 92, 91, 90, 89, - 88, 87, 86, 85, 84, 81, 80, 79, 78, 77, - 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, - 66, 65, 64, 63, 62, 61, 60, 59, 58, 171, - - 30, 30, 13, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171 - } ; - -static yyconst short int yy_chk[345] = - { 0, - 0, 1, 2, 3, 3, 3, 185, 1, 2, 184, - 0, 3, 0, 3, 4, 4, 4, 5, 5, 5, - 0, 5, 4, 0, 4, 5, 7, 5, 6, 6, - 6, 8, 6, 0, 0, 7, 6, 0, 6, 169, - 8, 11, 11, 11, 167, 12, 12, 12, 11, 11, - 73, 11, 12, 12, 165, 12, 16, 164, 162, 73, - 85, 161, 16, 16, 16, 160, 16, 16, 159, 85, - 16, 16, 16, 89, 16, 23, 23, 23, 36, 23, - 36, 157, 89, 23, 156, 23, 36, 155, 36, 49, - 49, 49, 57, 49, 57, 154, 153, 49, 152, 49, - - 57, 151, 57, 108, 108, 108, 108, 108, 113, 113, - 113, 113, 113, 120, 120, 120, 120, 120, 125, 125, - 125, 125, 125, 172, 172, 172, 172, 172, 172, 173, - 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, - 174, 175, 175, 175, 175, 175, 175, 176, 176, 176, - 176, 176, 176, 177, 177, 177, 177, 177, 177, 178, - 178, 179, 179, 179, 180, 180, 181, 181, 181, 181, - 181, 181, 182, 150, 182, 182, 182, 183, 149, 183, - 183, 183, 183, 186, 147, 186, 186, 186, 186, 187, - 187, 187, 187, 187, 187, 188, 145, 188, 188, 188, - - 188, 189, 189, 190, 190, 191, 191, 192, 192, 193, - 193, 193, 193, 193, 193, 144, 143, 141, 139, 138, - 136, 135, 134, 133, 132, 131, 130, 129, 128, 124, - 123, 122, 121, 119, 118, 117, 116, 115, 114, 112, - 111, 110, 109, 107, 106, 105, 104, 103, 102, 101, - 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, - 90, 88, 87, 86, 84, 83, 82, 81, 80, 79, - 78, 77, 76, 75, 74, 72, 70, 69, 68, 66, - 65, 64, 63, 62, 61, 60, 59, 58, 56, 48, - 45, 44, 43, 42, 41, 40, 39, 38, 37, 13, - - 10, 9, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "./ppdscanner.l" -#define INITIAL 0 -#line 2 "./ppdscanner.l" -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 <tqstringlist.h> -#include <tqiodevice.h> -#define YYSTYPE TQStringList -#include "ppdparser.cpp.h" - -#define yylval tdeprint_ppdlval - -TQIODevice *tdeprint_ppdscanner_device = NULL; -#define YY_INPUT(buf,result,max_size) \ - { \ - if (tdeprint_ppdscanner_device) \ - { \ - result = tdeprint_ppdscanner_device->readBlock(buf,max_size); \ - if (result < 0) \ - result = 0; \ - } \ - else \ - result = 0; \ - } -int tdeprint_ppdscanner_lno = 0; - -#if 0 -#define QDEBUG0(s) qDebug(s) -#define QDEBUG1(s,a) qDebug(s,a) -#else -#define QDEBUG0(s) -#define QDEBUG1(s,a) -#endif -#define option 1 -#define value 2 -#define translation_1 3 -#define translation_2 4 -#define constr 5 - -#line 576 "./ppdscanner.cpp" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 59 "./ppdscanner.l" - - - /** - * Initial state - */ -#line 733 "./ppdscanner.cpp" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 172 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 303 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -#line 65 "./ppdscanner.l" -case 2: -YY_RULE_SETUP -#line 65 "./ppdscanner.l" -{ QDEBUG0("Open UI"); BEGIN(option); return OPENUI; } - YY_BREAK -case 3: -#line 67 "./ppdscanner.l" -case 4: -YY_RULE_SETUP -#line 67 "./ppdscanner.l" -{ QDEBUG0("Close UI"); BEGIN(value); return CLOSEUI; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 68 "./ppdscanner.l" -{ QDEBUG0("Open group"); BEGIN(option); return OPENGROUP; } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 69 "./ppdscanner.l" -{ QDEBUG0("Close group"); BEGIN(option); return CLOSEGROUP; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 70 "./ppdscanner.l" -{ yylval = yytext+9; BEGIN(option); return DEFAULT; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 71 "./ppdscanner.l" -{ yylval = yytext+8; BEGIN(option); return DEFAULT; } - YY_BREAK -case 9: -#line 73 "./ppdscanner.l" -case 10: -YY_RULE_SETUP -#line 73 "./ppdscanner.l" -{ BEGIN(constr); return CONSTRAINT; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 74 "./ppdscanner.l" -{ BEGIN(option); return PAPERDIM; } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 75 "./ppdscanner.l" -{ BEGIN(option); return IMGAREA; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 76 "./ppdscanner.l" -{ /* eat up */ } - YY_BREAK -case 14: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 78 "./ppdscanner.l" -{ yylval = yytext+12; return FOODATA; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 79 "./ppdscanner.l" -{ QDEBUG0("Comment"); return COMMENT; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 80 "./ppdscanner.l" -{ yylval = yytext+1; QDEBUG1("Main keyword: %s",yytext+1); BEGIN(option); return KEYWORD; } - YY_BREAK -/** - * Option state - */ -case 17: -YY_RULE_SETUP -#line 85 "./ppdscanner.l" -{ yylval = yytext; QDEBUG1("Option: %s",yytext); return OPTION; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 86 "./ppdscanner.l" -{ BEGIN(value); return ':'; } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 87 "./ppdscanner.l" -{ tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 88 "./ppdscanner.l" -{ BEGIN(translation_1); return '/'; } - YY_BREAK -/** - * Translation state (1: without colon) - */ -case 21: -YY_RULE_SETUP -#line 93 "./ppdscanner.l" -{ yylval = yytext; QDEBUG1("Translation: %s",yytext); return TRANSLATION; } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 94 "./ppdscanner.l" -{ BEGIN(value); return ':'; } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 95 "./ppdscanner.l" -{ tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - YY_BREAK -/** - * Value state - */ -case 24: -YY_RULE_SETUP -#line 100 "./ppdscanner.l" -{ yylval = yytext; tdeprint_ppdscanner_lno += yylval[0].contains('\n'); QDEBUG1("Quoted value: %s",yytext); return QUOTED; } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 101 "./ppdscanner.l" -{ yylval = yytext; QDEBUG1("String part: %s",yytext); return STRINGPART; } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 102 "./ppdscanner.l" -{ BEGIN(translation_2); return '/'; } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 103 "./ppdscanner.l" -{ tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 104 "./ppdscanner.l" -{ /* stay in the same state */ return ':'; } - YY_BREAK -/** - * Translation state (2: with colon) - */ -case 29: -YY_RULE_SETUP -#line 109 "./ppdscanner.l" -{ yylval = yytext; QDEBUG1("Translation: %s",yytext); return TRANSLATION; } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 110 "./ppdscanner.l" -{ tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - YY_BREAK -/** - * Constraint state - */ -case 31: -YY_RULE_SETUP -#line 115 "./ppdscanner.l" -{ return ':'; } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 116 "./ppdscanner.l" -{ yylval = yytext+1; QDEBUG1("Constraint keyword: %s",yytext); return KEYWORD; } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 117 "./ppdscanner.l" -{ yylval = yytext; QDEBUG1("Constraint option: %s",yytext); return OPTION; } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 118 "./ppdscanner.l" -{ tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 120 "./ppdscanner.l" -{ tdeprint_ppdscanner_lno++; /* eat up */ } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 121 "./ppdscanner.l" -{ /* eat up */ } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 123 "./ppdscanner.l" -ECHO; - YY_BREAK -#line 1010 "./ppdscanner.cpp" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(option): -case YY_STATE_EOF(value): -case YY_STATE_EOF(translation_1): -case YY_STATE_EOF(translation_2): -case YY_STATE_EOF(constr): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 172 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 172 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 171); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 123 "./ppdscanner.l" - - -void tdeprint_ppdscanner_init(TQIODevice *d) -{ - tdeprint_ppdscanner_device = d; - tdeprint_ppdscanner_lno = 1; -} - -void tdeprint_ppdscanner_terminate( bool deleteIt ) -{ - if (deleteIt) - delete tdeprint_ppdscanner_device; - tdeprint_ppdscanner_device = NULL; -} - -int tdeprint_ppdscanner_numberoflines() -{ - return tdeprint_ppdscanner_lno; -} diff --git a/kdeprint/ppdscanner.l b/kdeprint/ppdscanner.l deleted file mode 100644 index ba60ee2f6..000000000 --- a/kdeprint/ppdscanner.l +++ /dev/null @@ -1,141 +0,0 @@ -%{ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001-2003 Michael Goffioul <tdeprint@swing.be> - * - * 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 <qstringlist.h> -#include <qiodevice.h> -#define YYSTYPE TQStringList -#include "ppdparser.cpp.h" - -#define yylval tdeprint_ppdlval - -QIODevice *tdeprint_ppdscanner_device = NULL; -#define YY_INPUT(buf,result,max_size) \ - { \ - if (tdeprint_ppdscanner_device) \ - { \ - result = tdeprint_ppdscanner_device->readBlock(buf,max_size); \ - if (result < 0) \ - result = 0; \ - } \ - else \ - result = 0; \ - } -int tdeprint_ppdscanner_lno = 0; - -#if 0 -#define QDEBUG0(s) qDebug(s) -#define QDEBUG1(s,a) qDebug(s,a) -#else -#define QDEBUG0(s) -#define QDEBUG1(s,a) -#endif -%} - -%x option value translation_1 translation_2 constr -%option noyywrap - -WORD [^:/\x00-\x20\x7F-\xFF]+ -WORD2 [^:/\x00-\x20\x7F-\xFF\*]+ -WORD3 [^:/\x00-\x20\x7F-\xFF][^:/\x00-\x1F\x7F-\xFF]* -L [[:alnum:]] - -%% - - /** - * Initial state - */ -\*"JCLOpenUI" | -\*"OpenUI"{L}* { QDEBUG0("Open UI"); BEGIN(option); return OPENUI; } -\*"JCLCloseUI" | -\*"CloseUI"{L}* { QDEBUG0("Close UI"); BEGIN(value); return CLOSEUI; } -\*"OpenGroup" { QDEBUG0("Open group"); BEGIN(option); return OPENGROUP; } -\*"CloseGroup" { QDEBUG0("Close group"); BEGIN(option); return CLOSEGROUP; } -\*"Default"\*{WORD} { yylval = yytext+9; BEGIN(option); return DEFAULT; } -\*"Default"{WORD} { yylval = yytext+8; BEGIN(option); return DEFAULT; } -\*"UIConstraints" | -\*"NonUIConstraints" { BEGIN(constr); return CONSTRAINT; } -\*"PaperDimension" { BEGIN(option); return PAPERDIM; } -\*"ImageableArea" { BEGIN(option); return IMGAREA; } -\*"End" { /* eat up */ } - -"*% COMDATA #".*$ { yylval = yytext+12; return FOODATA; } -\*%.* { QDEBUG0("Comment"); return COMMENT; } -\*{WORD} { yylval = yytext+1; QDEBUG1("Main keyword: %s",yytext+1); BEGIN(option); return KEYWORD; } - - /** - * Option state - */ -<option>{WORD3} { yylval = yytext; QDEBUG1("Option: %s",yytext); return OPTION; } -<option>":" { BEGIN(value); return ':'; } -<option>"\n" { tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } -<option>"/" { BEGIN(translation_1); return '/'; } - - /** - * Translation state (1: without colon) - */ -<translation_1>[^\n:]* { yylval = yytext; QDEBUG1("Translation: %s",yytext); return TRANSLATION; } -<translation_1>":" { BEGIN(value); return ':'; } -<translation_1>"\n" { tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - - /** - * Value state - */ -<value>\"[^\"]*\" { yylval = yytext; tdeprint_ppdscanner_lno += yylval[0].contains('\n'); QDEBUG1("Quoted value: %s",yytext); return QUOTED; } -<value>{WORD} { yylval = yytext; QDEBUG1("String part: %s",yytext); return STRINGPART; } -<value>"/" { BEGIN(translation_2); return '/'; } -<value>"\n" { tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } -<value>":" { /* stay in the same state */ return ':'; } - - /** - * Translation state (2: with colon) - */ -<translation_2>[^\n]* { yylval = yytext; QDEBUG1("Translation: %s",yytext); return TRANSLATION; } -<translation_2>"\n" { tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - - /** - * Constraint state - */ -<constr>":" { return ':'; } -<constr>\*{WORD2} { yylval = yytext+1; QDEBUG1("Constraint keyword: %s",yytext); return KEYWORD; } -<constr>{WORD2} { yylval = yytext; QDEBUG1("Constraint option: %s",yytext); return OPTION; } -<constr>"\n" { tdeprint_ppdscanner_lno++; BEGIN(INITIAL); } - -"\n" { tdeprint_ppdscanner_lno++; /* eat up */ } -<*>. { /* eat up */ } - -%% - -void tdeprint_ppdscanner_init(QIODevice *d) -{ - tdeprint_ppdscanner_device = d; - tdeprint_ppdscanner_lno = 1; -} - -void tdeprint_ppdscanner_terminate( bool deleteIt ) -{ - if (deleteIt) - delete tdeprint_ppdscanner_device; - tdeprint_ppdscanner_device = NULL; -} - -int tdeprint_ppdscanner_numberoflines() -{ - return tdeprint_ppdscanner_lno; -} diff --git a/kdeprint/printerfilter.cpp b/kdeprint/printerfilter.cpp deleted file mode 100644 index e0161a50a..000000000 --- a/kdeprint/printerfilter.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "printerfilter.h" -#include "kmprinter.h" -#include "kmfactory.h" - -#include <kconfig.h> -#include <kglobal.h> -#include <kdebug.h> - -PrinterFilter::PrinterFilter(TQObject *parent, const char *name) -: TQObject(parent, name) -{ - m_locationRe.setWildcard(true); - update(); -} - -PrinterFilter::~PrinterFilter() -{ -} - -void PrinterFilter::update() -{ - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("Filter"); - m_locationRe.setPattern(conf->readEntry("LocationRe")); - m_printers = conf->readListEntry("Printers"); - // filter enable state is saved on a per application basis, - // so this option is retrieve from the application config file - conf = KGlobal::config(); - conf->setGroup("KPrinter Settings"); - m_enabled = conf->readBoolEntry("FilterEnabled", false); -} - -void PrinterFilter::setEnabled(bool on) -{ - m_enabled = on; - KConfig *conf = KGlobal::config(); - conf->setGroup("KPrinter Settings"); - conf->writeEntry("FilterEnabled", m_enabled); -} - -bool PrinterFilter::filter(KMPrinter *prt) -{ - if (m_enabled) - { - if ((!m_locationRe.isEmpty() && m_locationRe.exactMatch(prt->location())) || - m_printers.find(prt->printerName()) != m_printers.end()) - return true; - else - return false; - } - return true; -} diff --git a/kdeprint/printerfilter.h b/kdeprint/printerfilter.h deleted file mode 100644 index 603565ebb..000000000 --- a/kdeprint/printerfilter.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 PRINTERFILTER_H -#define PRINTERFILTER_H - -#include <tqobject.h> -#include <tqregexp.h> -#include <tqstringlist.h> - -class KMPrinter; - -class PrinterFilter : TQObject -{ -public: - PrinterFilter(TQObject *parent = 0, const char *name = 0); - ~PrinterFilter(); - - bool filter(KMPrinter*); - void update(); - void setEnabled(bool on); - bool isEnabled() const; - -private: - TQRegExp m_locationRe; - TQStringList m_printers; - bool m_enabled; -}; - -inline bool PrinterFilter::isEnabled() const -{ return m_enabled; } - -#endif diff --git a/kdeprint/rlpr/CMakeLists.txt b/kdeprint/rlpr/CMakeLists.txt deleted file mode 100644 index f8468a0dc..000000000 --- a/kdeprint/rlpr/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/tdeprint - ${CMAKE_SOURCE_DIR}/tdeprint/management -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES rlpr.print DESTINATION ${DATA_INSTALL_DIR}/tdeprint/plugins ) - - -##### tdeprint_rlpr ############################# - -set( target tdeprint_rlpr ) - -set( ${target}_SRCS - kmrlprfactory.cpp kmrlprmanager.cpp krlprprinterimpl.cpp - kmrlpruimanager.cpp kmwrlpr.cpp kmproprlpr.cpp - kmproxywidget.cpp kmconfigproxy.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint_management-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) diff --git a/kdeprint/rlpr/Makefile.am b/kdeprint/rlpr/Makefile.am deleted file mode 100644 index 1946fed94..000000000 --- a/kdeprint/rlpr/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/tdeprint -I$(top_srcdir)/tdeprint/management $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_rlpr.la - -tdeprint_rlpr_la_SOURCES = kmrlprfactory.cpp kmrlprmanager.cpp krlprprinterimpl.cpp kmrlpruimanager.cpp \ - kmwrlpr.cpp kmproprlpr.cpp kmproxywidget.cpp kmconfigproxy.cpp -tdeprint_rlpr_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_rlpr_la_LIBADD = $(top_builddir)/tdeprint/management/libtdeprint_management.la $(LIB_QT) $(LIB_KDEPRINT) $(LIB_KDECORE) $(LIB_KDEUI) -tdeprint_rlpr_la_METASOURCES = AUTO - -noinst_HEADERS = kmrlprmanager.h krlprprinterimpl.h kmrlpruimanager.h kmwrlpr.h kmproprlpr.h \ - kmproxywidget.h kmconfigproxy.h - -entry_DATA = rlpr.print -entrydir = $(kde_datadir)/tdeprint/plugins diff --git a/kdeprint/rlpr/kmconfigproxy.cpp b/kdeprint/rlpr/kmconfigproxy.cpp deleted file mode 100644 index 0f8ca3743..000000000 --- a/kdeprint/rlpr/kmconfigproxy.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmconfigproxy.h" -#include "kmproxywidget.h" - -#include <tqlayout.h> -#include <klocale.h> - -KMConfigProxy::KMConfigProxy(TQWidget *parent) -: KMConfigPage(parent,"Proxy") -{ - setPageName(i18n("Proxy")); - setPageHeader(i18n("RLPR Proxy Server Settings")); - setPagePixmap("proxy"); - - m_widget = new KMProxyWidget(this); - TQVBoxLayout *lay0 = new TQVBoxLayout(this, 5, 0); - lay0->addWidget(m_widget); - lay0->addStretch(1); -} - -void KMConfigProxy::loadConfig(KConfig *conf) -{ - m_widget->loadConfig(conf); -} - -void KMConfigProxy::saveConfig(KConfig *conf) -{ - m_widget->saveConfig(conf); -} diff --git a/kdeprint/rlpr/kmconfigproxy.h b/kdeprint/rlpr/kmconfigproxy.h deleted file mode 100644 index 6f3b7ef42..000000000 --- a/kdeprint/rlpr/kmconfigproxy.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMCONFIGPROXY_H -#define KMCONFIGPROXY_H - -#include "kmconfigpage.h" - -class KMProxyWidget; -class KConfig; - -class KMConfigProxy : public KMConfigPage -{ -public: - KMConfigProxy(TQWidget *parent = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - KMProxyWidget *m_widget; -}; - -#endif diff --git a/kdeprint/rlpr/kmproprlpr.cpp b/kdeprint/rlpr/kmproprlpr.cpp deleted file mode 100644 index 62fe97827..000000000 --- a/kdeprint/rlpr/kmproprlpr.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmproprlpr.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqlabel.h> -#include <tqlayout.h> -#include <klocale.h> - -KMPropRlpr::KMPropRlpr(TQWidget *parent, const char *name) -: KMPropWidget(parent,name) -{ - m_host = new TQLabel("",this); - m_queue = new TQLabel("",this); - - TQLabel *l1 = new TQLabel(i18n("Host:"), this); - TQLabel *l2 = new TQLabel(i18n("Queue:"), this); - - // layout - TQGridLayout *main_ = new TQGridLayout(this, 3, 2, 10, 7); - main_->setColStretch(0,0); - main_->setColStretch(1,1); - main_->setRowStretch(2,1); - main_->addWidget(l1,0,0); - main_->addWidget(l2,1,0); - main_->addWidget(m_host,0,1); - main_->addWidget(m_queue,1,1); - - m_pixmap = "connect_established"; - m_title = i18n("Queue"); - m_header = i18n("Remote LPD Queue Settings"); -} - -KMPropRlpr::~KMPropRlpr() -{ -} - -void KMPropRlpr::setPrinter(KMPrinter *p) -{ - if (p && !p->isSpecial()) - { - m_host->setText(p->option("host")); - m_queue->setText(p->option("queue")); - emit enable(true); - } - else - { - emit enable(false); - m_host->setText(""); - m_queue->setText(""); - } -} - -void KMPropRlpr::configureWizard(KMWizard *w) -{ - w->configure(KMWizard::Custom+1,KMWizard::Custom+1,true); -} diff --git a/kdeprint/rlpr/kmproprlpr.h b/kdeprint/rlpr/kmproprlpr.h deleted file mode 100644 index cdf9aef7b..000000000 --- a/kdeprint/rlpr/kmproprlpr.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROPRLPR_H -#define KMPROPRLPR_H - -#include "kmpropwidget.h" - -class TQLabel; - -class KMPropRlpr : public KMPropWidget -{ -public: - KMPropRlpr(TQWidget *parent = 0, const char *name = 0); - ~KMPropRlpr(); - - void setPrinter(KMPrinter*); - -protected: - void configureWizard(KMWizard*); - -private: - TQLabel *m_host; - TQLabel *m_queue; -}; - -#endif diff --git a/kdeprint/rlpr/kmproxywidget.cpp b/kdeprint/rlpr/kmproxywidget.cpp deleted file mode 100644 index 94ad60340..000000000 --- a/kdeprint/rlpr/kmproxywidget.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmproxywidget.h" - -#include <tqlineedit.h> -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqlayout.h> -#include <tqvalidator.h> -#include <klocale.h> -#include <kconfig.h> -#include <kcursor.h> - -KMProxyWidget::KMProxyWidget(TQWidget *parent, const char *name) -: TQGroupBox(0, Qt::Vertical, i18n("Proxy Settings"), parent, name) -{ - TQLabel *m_hostlabel = new TQLabel(i18n("&Host:"), this); - TQLabel *m_portlabel = new TQLabel(i18n("&Port:"), this); - m_useproxy = new TQCheckBox(i18n("&Use proxy server"), this); - m_useproxy->setCursor(KCursor::handCursor()); - m_proxyhost = new TQLineEdit(this); - m_proxyport = new TQLineEdit(this); - m_proxyport->setValidator(new TQIntValidator(TQT_TQOBJECT(m_proxyport))); - m_hostlabel->setBuddy(m_proxyhost); - m_portlabel->setBuddy(m_proxyport); - - connect(m_useproxy,TQT_SIGNAL(toggled(bool)),m_proxyhost,TQT_SLOT(setEnabled(bool))); - connect(m_useproxy,TQT_SIGNAL(toggled(bool)),m_proxyport,TQT_SLOT(setEnabled(bool))); - m_proxyhost->setEnabled(false); - m_proxyport->setEnabled(false); - - TQGridLayout *lay0 = new TQGridLayout(tqlayout(), 3, 2, 10); - lay0->setColStretch(1,1); - lay0->addMultiCellWidget(m_useproxy,0,0,0,1); - lay0->addWidget(m_hostlabel,1,0); - lay0->addWidget(m_portlabel,2,0); - lay0->addWidget(m_proxyhost,1,1); - lay0->addWidget(m_proxyport,2,1); -} - -void KMProxyWidget::loadConfig(KConfig *conf) -{ - conf->setGroup("RLPR"); - m_proxyhost->setText(conf->readEntry("ProxyHost",TQString::null)); - m_proxyport->setText(conf->readEntry("ProxyPort",TQString::null)); - m_useproxy->setChecked(!m_proxyhost->text().isEmpty()); -} - -void KMProxyWidget::saveConfig(KConfig *conf) -{ - conf->setGroup("RLPR"); - conf->writeEntry("ProxyHost",(m_useproxy->isChecked() ? m_proxyhost->text() : TQString::null)); - conf->writeEntry("ProxyPort",(m_useproxy->isChecked() ? m_proxyport->text() : TQString::null)); -} diff --git a/kdeprint/rlpr/kmproxywidget.h b/kdeprint/rlpr/kmproxywidget.h deleted file mode 100644 index 0c1a5079b..000000000 --- a/kdeprint/rlpr/kmproxywidget.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMPROXYWIDGET_H -#define KMPROXYWIDGET_H - -#include <tqgroupbox.h> - -class KConfig; -class TQLineEdit; -class TQCheckBox; - -class KMProxyWidget : public TQGroupBox -{ -public: - KMProxyWidget(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - TQLineEdit *m_proxyhost; - TQLineEdit *m_proxyport; - TQCheckBox *m_useproxy; -}; - -#endif diff --git a/kdeprint/rlpr/kmrlprfactory.cpp b/kdeprint/rlpr/kmrlprfactory.cpp deleted file mode 100644 index f5cabe6bd..000000000 --- a/kdeprint/rlpr/kmrlprfactory.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmrlprmanager.h" -#include "kmrlpruimanager.h" -#include "krlprprinterimpl.h" - -#include <kgenericfactory.h> - -typedef K_TYPELIST_3( KMRlprManager, KMRlprUiManager, KRlprPrinterImpl ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_rlpr, KGenericFactory< Products > ) - diff --git a/kdeprint/rlpr/kmrlprmanager.cpp b/kdeprint/rlpr/kmrlprmanager.cpp deleted file mode 100644 index 64f6acde1..000000000 --- a/kdeprint/rlpr/kmrlprmanager.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmrlprmanager.h" -#include "kmprinter.h" - -#include <tqfile.h> -#include <tqfileinfo.h> -#include <tqtextstream.h> -#include <tqmap.h> - -#include <kstandarddirs.h> -#include <klocale.h> - -KMRlprManager::KMRlprManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - setHasManagement(true); - setPrinterOperationMask(KMManager::PrinterCreation|KMManager::PrinterRemoval|KMManager::PrinterTesting); -} - -KMRlprManager::~KMRlprManager() -{ -} - -bool KMRlprManager::createPrinter(KMPrinter *p) -{ - if (p->name().isEmpty()) - setErrorMsg(i18n("Empty printer name.")); - else if (p->option("host").isEmpty()) - setErrorMsg(i18n("Empty host name.")); - else if (p->option("queue").isEmpty()) - setErrorMsg(i18n("Empty queue name.")); - else - { - KMPrinter *pr = new KMPrinter(*p); - addPrinter(pr); - savePrinters(); - return true; - } - return false; -} - -bool KMRlprManager::removePrinter(KMPrinter *p) -{ - if (m_printers.findRef(p) == -1) - setErrorMsg(i18n("Printer not found.")); - else - { - m_printers.removeRef(p); - savePrinters(); - return true; - } - return false; -} - -bool KMRlprManager::testPrinter(KMPrinter *) -{ - setErrorMsg(i18n("Not implemented yet.")); - return false; -} - -void KMRlprManager::listPrinters() -{ - TQFileInfo pfi(printerFile()); - if (pfi.exists() && (!m_checktime.isValid() || m_checktime < pfi.lastModified())) - { - loadPrintersConf(pfi.absFilePath()); - m_checktime = pfi.lastModified(); - } - else - discardAllPrinters(false); -} - -void KMRlprManager::loadPrintersConf(const TQString& filename) -{ - TQFile f(filename); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty() || line[0] == '#') - continue; - TQStringList w = TQStringList::split('\t',line,true); - if (w.count() < 3) - continue; - - KMPrinter *printer = new KMPrinter; - printer->setName(w[0]); - printer->setPrinterName(w[0]); - printer->setType(KMPrinter::Printer); - printer->setOption("host",w[1]); - printer->setOption("queue",w[2]); - if (w.count() > 3) - { - printer->setDescription(w[3]); - if (w.count() > 4) printer->setLocation(w[4]); - } - printer->setState(KMPrinter::Idle); - printer->setDevice(TQString::tqfromLatin1("lpd://%1/%2").arg(w[1]).arg(w[2])); - - addPrinter(printer); - } - } -} - -void KMRlprManager::savePrinters() -{ - savePrintersConf(printerFile()); -} - -void KMRlprManager::savePrintersConf(const TQString& filename) -{ - TQFile f(filename); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - t << "# File generated by KDE print system. Don't edit by hand." << endl; - TQPtrListIterator<KMPrinter> it(m_printers); - for (;it.current();++it) - { - if (!it.current()->name().isEmpty() && it.current()->instanceName().isEmpty()) - { - TQString host = it.current()->option("host"); - TQString queue = it.current()->option("queue"); - if (!host.isEmpty() && !queue.isEmpty()) - { - t << it.current()->name() << '\t' << host << '\t' << queue; - t << '\t' << it.current()->description() << '\t' << it.current()->location() << endl; - } - } - } - } -} - -TQString KMRlprManager::printerFile() -{ - return locateLocal("data","tdeprint/printers.conf"); -} diff --git a/kdeprint/rlpr/kmrlprmanager.h b/kdeprint/rlpr/kmrlprmanager.h deleted file mode 100644 index 57af7f99f..000000000 --- a/kdeprint/rlpr/kmrlprmanager.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMRLPRMANAGER_H -#define KMRLPRMANAGER_H - -#include "kmmanager.h" -#include <tqdict.h> -#include <tqdatetime.h> - -class KMRlprManager : public KMManager -{ -public: - KMRlprManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMRlprManager(); - - bool createPrinter(KMPrinter*); - bool removePrinter(KMPrinter*); - bool testPrinter(KMPrinter*); - -protected: - void listPrinters(); - void savePrinters(); - void loadPrintersConf(const TQString& filename); - void savePrintersConf(const TQString& filename); - TQString printerFile(); - -private: - TQDateTime m_checktime; -}; - -#endif diff --git a/kdeprint/rlpr/kmrlpruimanager.cpp b/kdeprint/rlpr/kmrlpruimanager.cpp deleted file mode 100644 index 9bae2cdc4..000000000 --- a/kdeprint/rlpr/kmrlpruimanager.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmrlpruimanager.h" -#include "kmpropertypage.h" -#include "kmwizard.h" -#include "kmconfigdialog.h" - -#include "kmwrlpr.h" -#include "kmproprlpr.h" -#include "kmconfigproxy.h" - -#include <klocale.h> - -KMRlprUiManager::KMRlprUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMUiManager(parent,name) -{ -} - -KMRlprUiManager::~KMRlprUiManager() -{ -} - -void KMRlprUiManager::setupPropertyPages(KMPropertyPage *pages) -{ - pages->addPropPage(new KMPropRlpr(pages,"RlprPage")); -} - -void KMRlprUiManager::setupWizard(KMWizard *wizard) -{ - wizard->setNextPage(KMWizard::Start,KMWizard::Custom+1); - // add page - wizard->addPage(new KMWRlpr(wizard,"Rlpr")); -} - -void KMRlprUiManager::setupConfigDialog(KMConfigDialog *dlg) -{ - dlg->addConfigPage(new KMConfigProxy(dlg)); -} diff --git a/kdeprint/rlpr/kmrlpruimanager.h b/kdeprint/rlpr/kmrlpruimanager.h deleted file mode 100644 index e2bc5de73..000000000 --- a/kdeprint/rlpr/kmrlpruimanager.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMRLPRUIMANAGER_H -#define KMRLPRUIMANAGER_H - -#include "kmuimanager.h" - -class KMRlprUiManager : public KMUiManager -{ -public: - KMRlprUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMRlprUiManager(); - - void setupPropertyPages(KMPropertyPage*); - void setupWizard(KMWizard*); - void setupConfigDialog(KMConfigDialog*); -}; - -#endif diff --git a/kdeprint/rlpr/kmwrlpr.cpp b/kdeprint/rlpr/kmwrlpr.cpp deleted file mode 100644 index 70defc27b..000000000 --- a/kdeprint/rlpr/kmwrlpr.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "kmwrlpr.h" -#include "kmprinter.h" -#include "kmwizard.h" - -#include <tqdir.h> -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqlineedit.h> -#include <tqheader.h> -#include <klistview.h> -#include <klocale.h> -#include <kiconloader.h> - -static TQListViewItem* rlpr_findChild(TQListViewItem *c, const TQString& txt) -{ - TQListViewItem *item(c); - while (item) - if (item->text(0) == txt) return item; - else item = item->nextSibling(); - return NULL; -} - -//***************************************************************************************************** - -KMWRlpr::KMWRlpr(TQWidget *parent, const char *name) -: KMWizardPage(parent,name) -{ - m_ID = KMWizard::Custom+1; - m_title = i18n("Remote LPD Queue Settings"); - m_nextpage = KMWizard::Name; - - m_view = new KListView(this); - m_view->setFrameStyle(TQFrame::WinPanel|TQFrame::Sunken); - m_view->setLineWidth(1); - m_view->addColumn(TQString::tqfromLatin1("")); - m_view->header()->hide(); - m_view->setRootIsDecorated(true); - m_view->setSorting(0); - m_host = new TQLineEdit(this); - m_queue = new TQLineEdit(this); - TQLabel *m_hostlabel = new TQLabel(i18n("Host:"), this); - TQLabel *m_queuelabel = new TQLabel(i18n("Queue:"), this); - m_hostlabel->setBuddy(m_host); - m_queuelabel->setBuddy(m_queue); - connect(m_view,TQT_SIGNAL(selectionChanged(TQListViewItem*)),TQT_SLOT(slotPrinterSelected(TQListViewItem*))); - - TQHBoxLayout *lay0 = new TQHBoxLayout(this, 0, 10); - TQVBoxLayout *lay1 = new TQVBoxLayout(0, 0, 5); - lay0->addWidget(m_view,1); - lay0->addLayout(lay1,1); - lay1->addWidget(m_hostlabel); - lay1->addWidget(m_host); - lay1->addSpacing(20); - lay1->addWidget(m_queuelabel); - lay1->addWidget(m_queue); - lay1->addStretch(1); - - initialize(); -} - -bool KMWRlpr::isValid(TQString& msg) -{ - if (m_host->text().isEmpty()) - msg = i18n("Empty host name."); - else if (m_queue->text().isEmpty()) - msg = i18n("Empty queue name."); - else - return true; - return false; -} - -void KMWRlpr::initPrinter(KMPrinter *p) -{ - m_host->setText(p->option("host")); - m_queue->setText(p->option("queue")); - TQListViewItem *item = rlpr_findChild(m_view->firstChild(),m_host->text()); - if (item) - { - item = rlpr_findChild(item->firstChild(),m_queue->text()); - if (item) - { - item->parent()->setOpen(true); - m_view->setCurrentItem(item); - m_view->ensureItemVisible(item); - } - } -} - -void KMWRlpr::updatePrinter(KMPrinter *p) -{ - TQString uri = TQString::tqfromLatin1("lpd://%1/%2").arg(m_host->text()).arg(m_queue->text()); - p->setDevice(uri); - p->setOption("host",m_host->text()); - p->setOption("queue",m_queue->text()); - p->setOption("kde-backend-description",i18n("Remote LPD queue")); - // setting default name and description, but only if the "name()" is empty - // which is the case on first pass when adding a printer. This prevents from - // bad side-effects when simply modifying an existing printer. - if (p->name().isEmpty()) - { - p->setName(m_queue->text()); - p->setPrinterName(p->name()); - p->setDescription(i18n("Remote queue %1 on %2").arg(m_queue->text()).arg(m_host->text())); - } -} - -void KMWRlpr::initialize() -{ - m_view->clear(); - TQFile f(TQDir::homeDirPath()+"/.rlprrc"); - if (!f.exists()) f.setName("/etc/rlprrc"); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line, host; - int p(-1); - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) - continue; - if ((p=line.find(':')) != -1) - { - host = line.left(p).stripWhiteSpace(); - TQListViewItem *hitem = new TQListViewItem(m_view,host); - hitem->setPixmap(0,SmallIcon("tdeprint_computer")); - TQStringList prs = TQStringList::split(' ',line.right(line.length()-p-1),false); - for (TQStringList::ConstIterator it=prs.begin(); it!=prs.end(); ++it) - { - TQListViewItem *pitem = new TQListViewItem(hitem,*it); - pitem->setPixmap(0,SmallIcon("tdeprint_printer")); - } - } - } - f.close(); - } - - // parse printcap file for local printers - f.setName("/etc/printcap"); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line, buffer; - TQListViewItem *hitem(m_view->firstChild()); - while (hitem) if (hitem->text(0) == "localhost") break; else hitem = hitem->nextSibling(); - while (!t.eof()) - { - buffer = TQString::null; - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty() || line[0] == '#') - continue; - buffer.append(line); - if (buffer.right(1) == "\\") - buffer = buffer.left(buffer.length()-1).stripWhiteSpace(); - else - break; - } - if (buffer.isEmpty()) - continue; - int p = buffer.find(':'); - if (p != -1) - { - TQString name = buffer.left(p); - if (!hitem) - { - hitem = new TQListViewItem(m_view,"localhost"); - hitem->setPixmap(0,SmallIcon("tdeprint_computer")); - } - TQListViewItem *pitem = new TQListViewItem(hitem,name); - pitem->setPixmap(0,SmallIcon("tdeprint_printer")); - } - } - } - - if (m_view->childCount() == 0) - new TQListViewItem(m_view,i18n("No Predefined Printers")); -} - -void KMWRlpr::slotPrinterSelected(TQListViewItem *item) -{ - if (item && item->depth() == 1) - { - m_host->setText(item->parent()->text(0)); - m_queue->setText(item->text(0)); - } -} -#include "kmwrlpr.moc" diff --git a/kdeprint/rlpr/kmwrlpr.h b/kdeprint/rlpr/kmwrlpr.h deleted file mode 100644 index 7c1aa74f2..000000000 --- a/kdeprint/rlpr/kmwrlpr.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KMWRLPR_H -#define KMWRLPR_H - -#include "kmwizardpage.h" - -class KListView; -class TQLineEdit; -class TQListViewItem; - -class KMWRlpr : public KMWizardPage -{ - Q_OBJECT -public: - KMWRlpr(TQWidget *parent = 0, const char *name = 0); - - bool isValid(TQString&); - void initPrinter(KMPrinter*); - void updatePrinter(KMPrinter*); - -protected slots: - void slotPrinterSelected(TQListViewItem*); - -protected: - void initialize(); - -private: - KListView *m_view; - TQLineEdit *m_host, *m_queue; -}; - -#endif diff --git a/kdeprint/rlpr/krlprprinterimpl.cpp b/kdeprint/rlpr/krlprprinterimpl.cpp deleted file mode 100644 index a6b0e5986..000000000 --- a/kdeprint/rlpr/krlprprinterimpl.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "krlprprinterimpl.h" -#include "kprinter.h" -#include "kmfactory.h" -#include "kmmanager.h" -#include "kmprinter.h" - -#include <tqfile.h> -#include <kstandarddirs.h> -#include <kconfig.h> -#include <klocale.h> - -KRlprPrinterImpl::KRlprPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ -} - -KRlprPrinterImpl::~KRlprPrinterImpl() -{ -} - -bool KRlprPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - // retrieve the KMPrinter object, to get host and queue name - KMPrinter *rpr = KMFactory::self()->manager()->findPrinter(printer->printerName()); - if (!rpr) - return false; - - QString host(rpr->option("host")), queue(rpr->option("queue")); - if (!host.isEmpty() && !queue.isEmpty()) - { - QString exestr = KStandardDirs::findExe("rlpr"); - if (exestr.isEmpty()) - { - printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("rlpr")); - return false; - } - - cmd = TQString::tqfromLatin1("%1 -H %2 -P %3 -\\#%4").arg(exestr).arg(quote(host)).arg(quote(queue)).arg(printer->numCopies()); - - // proxy settings - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("RLPR"); - QString host = conf->readEntry("ProxyHost",TQString::null), port = conf->readEntry("ProxyPort",TQString::null); - if (!host.isEmpty()) - { - cmd.append(" -X ").append(quote(host)); - if (!port.isEmpty()) cmd.append(" --port=").append(port); - } - - return true; - } - else - { - printer->setErrorMessage(i18n("The printer is incompletely defined. Try to reinstall it.")); - return false; - } -} diff --git a/kdeprint/rlpr/krlprprinterimpl.h b/kdeprint/rlpr/krlprprinterimpl.h deleted file mode 100644 index 7af98df0c..000000000 --- a/kdeprint/rlpr/krlprprinterimpl.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 KRLPRPRINTERIMPL_H -#define KRLPRPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KProcess; - -class KRlprPrinterImpl : public KPrinterImpl -{ -public: - KRlprPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KRlprPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); -}; - -#endif diff --git a/kdeprint/rlpr/rlpr.print b/kdeprint/rlpr/rlpr.print deleted file mode 100644 index 25f16ee63..000000000 --- a/kdeprint/rlpr/rlpr.print +++ /dev/null @@ -1,84 +0,0 @@ -[KDE Print Entry] -PrintSystem=rlpr -Comment=RLPR Environment (Remote LPD servers) -Comment[af]=Rlpr Omgewing (Afgeleë Lpd bedieners) -Comment[ar]=بيئة RLPR (خادمات LPR عن بعد) -Comment[az]=RLPR Mühiti (Uzaq LPD vericilÉ™ri) -Comment[be]=ÐÑÑроддзе RLPR (Ð°Ð´Ð´Ð°Ð»ÐµÐ½Ñ‹Ñ Ñерверы LPD) -Comment[bs]=RLPR okolina (udaljeni LPD serveri) -Comment[ca]=Entorn RLPR (servidors LPD remots) -Comment[cs]=ProstÅ™edí RLPR (Vzdálené LPD servery) -Comment[csb]=Ã’krãże RLPR (daleczi serwerë LPD) -Comment[cy]=Amgylchedd RLPR (Gweinyddion LPD pell) -Comment[da]=RLPR-miljø (fjerne LPD-servere) -Comment[de]=RLPR-Umgebung (LPD-Server auf Fremdrechner) -Comment[el]=ΠεÏιβάλλον RLPR (ΑπομακÏυσμένοι εξυπηÏετητές LPD) -Comment[eo]=RLPR-medio (Foraj LPD-servoj) -Comment[es]=Entorno RLPR (servidores LPD remotos) -Comment[et]=RLPR keskkond (LPD võrguserverid) -Comment[eu]=RLPR ingurunea (urruneko LPD zerbitzariak) -Comment[fa]=محیط RLPR )کارسازهای LPD دور( -Comment[fi]=RLPR-tulostus (LPD-palvelin) -Comment[fr]=Environnement RLPR (serveurs LPD distants) -Comment[fy]=RLPR-fermidden (LPD-tsjinners op ôfstân) -Comment[ga]=Timpeallach RLPR (Cianfhreastalaithe LPD) -Comment[gl]=Entorno RLPR (Servidores Remotos LPD) -Comment[he]=סביבת RLPR (שרתי LPD מרוחקי×) -Comment[hi]=RLPR वातावरण (रिमोट LPD सरà¥à¤µà¤°à¥à¤¸) -Comment[hr]=RLPR okruženje (udaljeni LPD poslužitelji) -Comment[hu]=RLPR (távoli LPD-kiszolgálón keresztül) -Comment[id]=Lingkungan RLPR (Server LPD remote) -Comment[is]=RLPR umhverfi (fjarlægir LPD þjónar) -Comment[it]=Ambiente RLPR (server LPD remoti) -Comment[ja]=RLPR 環境 (リモート LPD サーãƒ) -Comment[ka]=RLPR გáƒáƒ áƒ”მრ(დáƒáƒ¨áƒáƒ áƒ”ბული LPD სერვერები) -Comment[kk]=RLPR ортаÑÑ‹ (Желідегі LPD Ñерверлері) -Comment[km]=បរិស្ážáž¶áž“ RLPR (ម៉ាស៊ីន​បម្រើ LPD ពី​ចម្ងាយ) -Comment[ko]=RLPR 환경 (ì›ê²©ì§€ LPD 서버) -Comment[lb]=RLPR mfeld(LPD-ServeËren op anere Computeren) -Comment[lt]=RLPR aplinka (nutolÄ™ LPD serveriai) -Comment[lv]=RLPR vide (AttÄlinÄti LPD serveri) -Comment[mk]=RLPR околина (оддалечени LPD Ñервери) -Comment[mn]=RLPR-орчин (алÑын LPD-Сервер) -Comment[ms]=Persekitaran RLPR (Pelayan LPD jauh) -Comment[mt]=Ambjent RLPR (servers LPD remoti) -Comment[nb]=RLPR-miljø (LPD-tjenere over nettverk) -Comment[nds]=RLPR-Ãœmgeven (LPD-Servers op anner Reekners) -Comment[ne]=RLPR परिवेश (टाढाको LPD सरà¥à¤­à¤°) -Comment[nl]=RLPR-omgeving (LPD-servers op afstand) -Comment[nn]=RLPR-miljø (LPD-tenarar over nettverk) -Comment[nso]=Tikologo ya RLPR (Baabi remote ba LPD) -Comment[pa]=RLPR ਵਾਤਾਵਰਣ(ਰਿਮੋਟ LPD ਸਰਵਰ) -Comment[pl]=Åšrodowisko RLPR (zdalne serwery LPD) -Comment[pt]=O ambiente RLPR (servidores remotos de LPD) -Comment[pt_BR]= Ambiente RLPR (Servidores LPD Remotos) -Comment[ro]=Mediu RLPR (Servere LPD distante) -Comment[ru]=Среда RLPR (Ñетевые принт-Ñерверы LPD) -Comment[rw]=Ibikikije RLPR (Amaseriveri LPD ya Kure) -Comment[se]=RLPR-biras (LPD-gáiddusbálvvát) -Comment[sk]=Prostredie RLPR (Vzdialené LPD servery) -Comment[sl]=Okolje RLPR (oddaljeni strežniki LPD) -Comment[sq]=Ambienti RLPR (Shërbyesit e Largët LPD) -Comment[sr]=RLPR окружење (удаљени LPD Ñервери) -Comment[sr@Latn]=RLPR okruženje (udaljeni LPD serveri) -Comment[ss]=Siminhlalo se RLPR (Susa tigcini teLPD) -Comment[sv]=RLPR-miljö (LPD-fjärrservrar) -Comment[ta]=RLPR சூழல௠(சேயà¯à®®à¯ˆ LPD சேவகனà¯à®•à®³à¯) -Comment[te]=ఆరౠఎలౠపి ఆరౠపరà±à°¯à°¾à°µà°°à°£à°‚ (à°¸à±à°¦à±‚à°° అలౠపి à°¡à°¿ సెరà±à°µà°°à±à°²à±) -Comment[tg]=Муҳити RLPR (Ñерверҳои чопи шабақавии LPD) -Comment[th]=สภาพà¹à¸§à¸”ล้อม RLPR (เซอร์เวอร์ LPD ระยะไà¸à¸¥) -Comment[tr]=RLPR Ortamı (Uzak LPD Sunucuları) -Comment[tt]=RLPR EÅŸläw Tiräse (Çittäge LPD serverläre) -Comment[uk]=ÐžÑ‚Ð¾Ñ‡ÐµÐ½Ð½Ñ RLPR (віддалені Ñервери LPD) -Comment[uz]=RLPR muhiti (masofadagi LPD serverlar) -Comment[uz@cyrillic]=RLPR муҳити (маÑофадаги LPD Ñерверлар) -Comment[ven]=Vhupo ha RLPR (dzisiva dza LPD) -Comment[vi]=Môi trÆ°á»ng RLPR (máy phục vụ LPD từ xa) -Comment[wa]=Evironmint d' imprimaedje RLPR (sierveus LPD Ã¥ lon) -Comment[xh]=RLPR Imeko-bume ye RLPR (Abancedisi be LPD ababeka kude) -Comment[zh_CN]=RLPR 环境(远程 LPD æœåŠ¡å™¨) -Comment[zh_HK]=RLPR 環境 (é ç«¯ LPD 伺æœå™¨) -Comment[zh_TW]=RLPR 環境(é ç«¯ LPD 伺æœå™¨) -Comment[zu]=Ezendalo ze-RLPR (abalekeleli abakude be-LPD) -DetectUris=exec:/rlpr -DetectPrecedence=0 diff --git a/kdeprint/signal_proc.c b/kdeprint/signal_proc.c deleted file mode 100644 index 8ff30e56e..000000000 --- a/kdeprint/signal_proc.c +++ /dev/null @@ -1,136 +0,0 @@ -#include <stdio.h> -#include <sys/types.h> -#include <dirent.h> -#include <errno.h> - -void commandFromPid(int pid, char *name) -{ - char buf[256], c; - FILE *f; - int i; - - name[0] = 0; - snprintf(buf, 256, "/proc/%d/stat", pid); - f = fopen(buf, "r"); - if (f == NULL) - return; - while ((c = fgetc(f)) != '(') ; - i = 0; - while ((c = fgetc(f)) != ')') - name[i++] = c; - name[i] = 0; -} - -int findPid(const char *progname) -{ - char name[256]; - DIR *dir; - int pid = -1; - struct dirent *ds; - - dir = opendir("/proc"); - if (dir == NULL) - return -1; - while ((ds = readdir(dir)) !=NULL ) - { - pid = -1; - pid = atoi(ds->d_name); - if (pid != -1) - { - commandFromPid(pid, name); - if (strcmp(progname, name) == 0) - return pid; - } - } - - return -1; -} - -void usage() -{ - printf("usage: signal_proc [ -s signal_number ] [ -l ] -p <progname>\n"); -} - -int main(int argc, char **argv) -{ - int pid = -1; - char progname[128] = {0}; - int signal_number = -1, i, list_only = 0; - - for (i = 1; i < argc; i++) - { - if (argv[i][0] != '-') - { - usage(); - return(-1); - } - - switch (argv[i][1]) - { - case 'p': - strncpy(progname, argv[++i], 128); - progname[127]='\0'; - break; - case 's': - signal_number = atoi(argv[++i]); - break; - case 'l': - list_only = 1; - break; - default: - usage(); - return -1; - } - } - - if (progname[0] == 0) - { - usage(); - return -1; - } - - pid = findPid(progname); - if (pid == -1) - { - fprintf(stderr, "no such program: %s\n", progname); - return -1; - } - if (list_only) - { - fprintf(stdout, "PID: %d\n", pid); - return 0; - } - - if (signal_number != -1) - { - int result; - - result = kill(pid, signal_number); - if (result == -1) - { - if (errno == EPERM) - { - char buf[256]; - - fprintf(stderr, "operation not authorized, switching to root\n"); - snprintf(buf, 256, "kill -%d %d", signal_number, pid); - if (execlp("tdesu", "tdesu", "-c", buf, (void *)0) == -1) - { - fprintf(stderr, "operation failed: %s\n", strerror(errno)); - return -1; - } - } - else - { - fprintf(stderr, "operation failed (invalid signal or no such process)\n"); - return -1; - } - } - } - else - { - fprintf(stderr, "only signal sending is currently supported\n"); - return -1; - } - return 0; -} diff --git a/kdeprint/specials.desktop b/kdeprint/specials.desktop deleted file mode 100644 index 72c648c4c..000000000 --- a/kdeprint/specials.desktop +++ /dev/null @@ -1,1196 +0,0 @@ -[General] -Number=5 - -[Printer 0] -Name=Print to File (PostScript) -Name[af]=Druk na Lêer (Postscript) -Name[ar]=اطبع ÙÙŠ مل٠(بوست سكريبت) -Name[az]=Fayla Çap Et (PostScript) -Name[be]=Стварыць файл PostScript -Name[bg]=Ð—Ð°Ð¿Ð¸Ñ ÐºÐ°Ñ‚Ð¾ PostScript файл -Name[bn]=ফাইল হিসেবে ছাপাও (পোসà§à¦Ÿà¦¸à§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ) -Name[br]=Moulañ en ur restr (PostScript) -Name[bs]=Å tampaj u datoteku (PostScript) -Name[ca]=Imprimeix al fitxer (PostScript) -Name[cs]=Tisk do souboru (PostScript) -Name[csb]=Wëdrëk do lopka (PostScript) -Name[cy]=Argraffu i Ffeil (PostScript) -Name[da]=Udskriv til fil (PostScript) -Name[de]=In Datei drucken (PostScript) -Name[el]=ΕκτÏπωση σε αÏχείο (PostScript) -Name[eo]=Presu al dosiero (Postskripto) -Name[es]=Imprimir en archivo (PostScript) -Name[et]=Faili trükkimine (Postscript) -Name[eu]=Inprimatu fitxategian (PostScript) -Name[fa]=چاپ در پرونده)پست‌اسکریپت( -Name[fi]=Tulosta PostScript-tiedostoon -Name[fr]=Imprimer dans un fichier (PostScript) -Name[fy]=Nei triem printsje (PostScript) -Name[ga]=Priontáil go Comhad (PostScript) -Name[gl]=Imprimir a un ficheiro (PostScript) -Name[he]=הדפס לקובץ (PostScript) -Name[hi]=फ़ाइल मे छापें (PostScript) -Name[hr]=Ispis u PostScript -Name[hu]=Nyomtatás fájlba (PostScript) -Name[id]=Cetak ke Berkas (PostScript) -Name[is]=Prenta í skrá (Postscript) -Name[it]=Stampa su file (PostScript) -Name[ja]=ファイルã«å‡ºåŠ› (PostScript) -Name[ka]=ბეჭდვრფáƒáƒ˜áƒšáƒ¨áƒ˜ (PostScript) -Name[kk]=Файлға баÑып шығару (PostScript) -Name[km]=បោះពុម្ព​ទៅ​ឯកសារ (PostScript) -Name[ko]=(í¬ìŠ¤íŠ¸ìŠ¤í¬ë¦½íŠ¸) 파ì¼ë¡œ ì°ê¸° -Name[lb]=An Datei drécken (PostScript) -Name[lt]=Spausdinti į bylÄ… (PostScript) -Name[lv]=DrukÄt failÄ (PostScript) -Name[mk]=Печати во датотека (PostScript) -Name[mn]=Файл руу Ñ…ÑвлÑÑ… (PostScript) -Name[ms]= Cetak ke Fail (PostScript) -Name[mt]=Printja Ä¡o fajl (PostScript) -Name[nb]=Skriv til fil (PostScript) -Name[nds]=Datei utgeven (PostScript) -Name[ne]=फाइलमा मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ (पोसà¥à¤Ÿà¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ) -Name[nl]=Naar bestand afdrukken (PostScript) -Name[nn]=Skriv til fil (PostScript) -Name[nso]=Gatisetsa go Faele (PostScript) -Name[pa]=ਫਾਇਲ ਵਿੱਚ ਛਾਪਣ ਲਈ (ਪੋਸਟ-ਸਕà©à¨°à¨¿à¨ªà¨Ÿ) -Name[pl]=Wydruk do pliku (PostScript) -Name[pt]=Imprimir para um Ficheiro (PostScript) -Name[pt_BR]=Imprimir para Arquivo (PostScript) -Name[ro]=Tipărire în fiÅŸier (PostScript) -Name[ru]=Печать в файл (PostScript) -Name[rw]=Gucapa ku idosiye (IyandikaNyuma) -Name[se]=Čálit fiilii (PostScript) -Name[sk]=TlaÄiÅ¥ do súboru (PostScript) -Name[sl]=Tiskanje v datoteko (postscript) -Name[sq]=Shtyp në skedë (PostScript) -Name[sr]=Штампање у фајл (PostScript) -Name[sr@Latn]=Å tampanje u fajl (PostScript) -Name[ss]=Shicilela kuya fayilini (PostScript) -Name[sv]=Skriv ut till fil (Postscript) -Name[ta]=கோபà¯à®ªà¯à®•à¯à®•à¯ அசà¯à®šà®¿à®Ÿà¯ (PostScript) -Name[te]=దసà±à°¤à±à°°à°‚ లొ à°ªà±à°°à°šà±à°°à°¿à°‚à°šà± (పొసà±à°Ÿà± à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà±) -Name[tg]=Чоп намудан ба файл (PostScript) -Name[th]=พิมพ์เป็นà¹à¸Ÿà¹‰à¸¡ (โพสต์สคริปต์) -Name[tr]=Dosyaya Yazdır (PostScript) -Name[tt]=Biremgä Bastır (PostScript) -Name[uk]=Друк у файл (PostScript) -Name[uz]=PostScript-fayli sifatida saqlash -Name[uz@cyrillic]=PostScript-файли Ñифатида Ñақлаш -Name[ven]=Phirinthani kha faela (Bammbiri la poso) -Name[vi]=In vào tập tin (PostScript) -Name[wa]=Imprimer en on fitchî (PostScript) -Name[xh]=Shicilela Kwifayile (PostScript) -Name[zh_CN]=打å°åˆ°æ–‡ä»¶(PostScript) -Name[zh_HK]=列å°åˆ°æª”案 (PostScript) -Name[zh_TW]=列å°åˆ°æª”案(PostScript) -Name[zu]=Shicilela Efayeleni (PostScript) -Description=Write PostScript file -Description[af]=Skryf Postscript lêer -Description[ar]=كتابة مل٠بوست سكريبت -Description[az]=PostScript fayl yaz -Description[be]=ЗапіÑваць данні Ñž файл PostScript -Description[bg]=Ð—Ð°Ð¿Ð¸Ñ ÐºÐ°Ñ‚Ð¾ PostScript файл -Description[bn]=পোসà§à¦Ÿà¦¸à§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ ফাইল লেখা হবে -Description[br]=Moulañ en ur restr PostScript -Description[bs]=PiÅ¡i u PostScript datoteku -Description[ca]=Escriure en un fitxer PostScript -Description[cs]=Zapisuje do PostScriptového souboru -Description[csb]=Zapiszë lopk PostScript -Description[cy]=Ysgrifennwch ffeil PostScript -Description[da]=Skriv PostScript-fil -Description[de]=Eine PostScript-Datei schreiben -Description[el]=ΕγγÏαφή αÏχείου PostScript -Description[eo]=Skribas Postskripto-dosieron -Description[es]=Escribir archivo PostScript -Description[et]=PS-faili kirjutamine -Description[eu]=Idatzi PostScript fitxategia -Description[fa]=نوشتن پروندۀ پست‌اسکریپت -Description[fi]=Kirjoita PostScript-tiedosto -Description[fr]=Imprimer dans un fichier PostScript -Description[fy]=Skriuw PostScript-triem -Description[ga]=Scríobh comhad PostScript -Description[gl]=Escreber ficheiro Postscript -Description[he]=כתוב קובץ PostScript -Description[hi]=पोसà¥à¤Ÿà¤¸à¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ फ़ाइल लिखें -Description[hr]=Ispis u PostScript datoteku -Description[hu]=PostScript fájlba írás -Description[id]=Tulis Berkas PostScript -Description[is]=Skrifa PostScript skrá -Description[it]=Scrive file PostScript -Description[ja]=PostScript ファイルã®ä½œæˆ -Description[ka]=ჩáƒáƒ¬áƒ”რრPostScript ფáƒáƒ˜áƒšáƒ¨áƒ˜ -Description[kk]=PostScript файлды жазу -Description[km]=ឯកសារ Write PostScript -Description[ko]=í¬ìŠ¤íŠ¸ìŠ¤í¬ë¦½íŠ¸ 파ì¼ë¡œ ì”니다 -Description[lb]=PostScript-Datei schreiwen -Description[lt]=RaÅ¡yti Postscript bylÄ… -Description[lv]=RakstÄ«t PostScript failÄ -Description[mk]=Запиши PostScript датотека -Description[mn]=PostScript-файл бичих -Description[ms]=Tulis fail PostScript -Description[mt]=Ikteb fajl PostScript -Description[nb]=Skriv PostScript-fil -Description[nds]=Druckopgaav as PostScript-Datei utgeven -Description[ne]=पोषà¥à¤Ÿà¤¸à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ फाइल लेखà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ -Description[nl]=Schrijf PostScript-bestand -Description[nn]=Skriv PostScript-fil -Description[nso]=Ngwala faele ya PostScript -Description[pa]=ਪੋਸਟ-ਸਕà©à¨°à¨¿à¨ªà¨Ÿ ਫਾਇਲ ਲਿਖੋ -Description[pl]=Zapisz plik PostScriptu -Description[pt]=Escrever ficheiro PostScript -Description[pt_BR]=Salva como Arquivo PostScript -Description[ro]=Scrie fiÅŸier PostScript -Description[ru]=ЗапиÑÑŒ файла PostScript -Description[rw]=Kwandika Idosiye Iyandikanyuma -Description[se]=Čále PostScript fiilla -Description[sk]=ZapísaÅ¥ súbor PostScript -Description[sl]=Izdela postscriptno datoteko -Description[sq]=Shkruaj një Skedë PostScript -Description[sr]=ЗапиÑује PostScript фајл -Description[sr@Latn]=Zapisuje PostScript fajl -Description[ss]=Bhala lifayela le PostScript -Description[sv]=Skriv Postscript-fil -Description[ta]=போஸà¯à®Ÿà¯à®¸à¯à®•à®¿à®°à®¿à®ªà¯à®Ÿà¯ கோபà¯à®ªà¯ எழà¯à®¤à¯ -Description[te]=పొసà±à°Ÿà± à°¸à±à°•à±à°°à°¿à°ªà±à°Ÿà± దసà±à°¤à±à°°à°‚ నౠవà±à°°à°¾à°¯à±à°Ÿ -Description[tg]=Сабти файли PostScript -Description[th]=เขียนà¹à¸Ÿà¹‰à¸¡à¹‚พสต์สคริปต์ -Description[tr]=PostScript dosyasına yaz -Description[tt]=PostScript birem yazdıru -Description[uk]=ЗапиÑати файл PostScript -Description[uz]=PostScript-fayli sifatida saqlash -Description[uz@cyrillic]=PostScript-файли Ñифатида Ñақлаш -Description[ven]=Nwalani faela ya bammbiri la poso -Description[vi]=Ghi tập tin PostScript -Description[wa]=Fé on fitchî PostScript -Description[xh]=Bhala ifayile ye PostScript -Description[zh_CN]=写入 PostScript 文件 -Description[zh_HK]=å¯«æˆ PostScript 檔案 -Description[zh_TW]=å¯«æˆ PostScript 檔案 -Description[zu]=Bhala ifayile le-PosrtScript -Comment=Local file -Comment[af]=Plaaslike lêer -Comment[ar]=مل٠محلي -Comment[az]=Lokal faylı -Comment[be]=ÐœÑÑцовы файл -Comment[bg]=Локален файл -Comment[bn]=সà§à¦¥à¦¾à¦¨à§€à§Ÿ ফাইল -Comment[br]=Restr lec'hel -Comment[bs]=Lokalna datoteka -Comment[ca]=Fitxer local -Comment[cs]=Lokální soubor -Comment[csb]=Môlowi lopk -Comment[cy]=Ffeil lleol -Comment[da]=Lokal fil -Comment[de]=Lokale Datei -Comment[el]=Τοπικό αÏχείο -Comment[eo]=Loka dosiero -Comment[es]=Archivo local -Comment[et]=Kohalik fail -Comment[eu]=Fitxategi lokala -Comment[fa]=پروندۀ محلی -Comment[fi]=Paikallinen tiedosto -Comment[fr]=Fichier local -Comment[fy]=Lokaal triem -Comment[ga]=Comhad logánta -Comment[gl]=Ficheiro local -Comment[he]=קובץ מקומי -Comment[hi]=सà¥à¤¥à¤¾à¤¨à¥€à¤¯ फ़ाइल -Comment[hr]=Lokalna datoteka -Comment[hu]=Helyi fájl -Comment[id]=Berkas Lokal -Comment[is]=Staðvær skrá -Comment[it]=File locale -Comment[ja]=ローカルファイル -Comment[ka]=ლáƒáƒ™áƒáƒšáƒ£áƒ áƒ˜ ფáƒáƒ˜áƒšáƒ˜ -Comment[kk]=Жергілікті файл -Comment[km]=ឯកសារ​មូលដ្ឋាន -Comment[ko]=울 안 íŒŒì¼ -Comment[lb]=Lokal Datei -Comment[lt]=VietinÄ— byla -Comment[lv]=LokÄls fails -Comment[mk]=Локална датотека -Comment[mn]=локал файл -Comment[ms]=Fail setempat -Comment[mt]=Fajl lokali -Comment[nb]=Lokal fil -Comment[nds]=Lokale Datei -Comment[ne]=सà¥à¤¥à¤¾à¤¨à¥€à¤¯ फाइल -Comment[nl]=Lokaal bestand -Comment[nn]=Lokal fil -Comment[nso]=Faele ya selegae -Comment[pa]=ਲੋਕਲ ਫਾਇਲ -Comment[pl]=Plik lokalny -Comment[pt]=Ficheiro local -Comment[pt_BR]=Arquivo Local -Comment[ro]=FiÅŸier local -Comment[ru]=Локальный файл -Comment[rw]=Idosiye ya hafi -Comment[se]=BáikkálaÅ¡ fiila -Comment[sk]=Lokálny súbor -Comment[sl]=Krajevna datoteka -Comment[sq]=Skedë Lokale -Comment[sr]=Локални фајл -Comment[sr@Latn]=Lokalni fajl -Comment[ss]=Lifayela langekhatsi -Comment[sv]=Lokal fil -Comment[ta]=உளà¯à®³à®®à¯ˆà®•à¯ கோபà¯à®ªà¯ -Comment[te]=à°¸à±à°¥à°¾à°¨à°¿à°• దసà±à°¤à±à°°à°‚ -Comment[tg]=Файли маҳаллӣ -Comment[th]=à¹à¸Ÿà¹‰à¸¡à¸ à¸²à¸¢à¹ƒà¸™à¸£à¸°à¸šà¸š -Comment[tr]=Yerel dosya -Comment[tt]=Cirle birem -Comment[uk]=Локальний файл -Comment[uz]=Lokal fayl -Comment[uz@cyrillic]=Локал файл -Comment[ven]=Faela ya henefhano -Comment[vi]=Tập tin cục bá»™ -Comment[wa]=Fitchî locÃ¥l -Comment[xh]=Ifayile yobulali -Comment[zh_CN]=本地文件 -Comment[zh_HK]=本地檔案 -Comment[zh_TW]=本地檔案 -Comment[zu]=Ifayela laseduze -Icon=filesave -Command= -File=1 -Extension=ps -Mimetype=application/postscript - -[Printer 1] -Name=Print to File (PDF) -Name[af]=Druk na Lêer (Pdf) -Name[ar]=اطبع ÙÙŠ مل٠(PDF) -Name[az]=Fayla Çap Et (PDF) -Name[be]=Ствараць файл PDF -Name[bg]=Ð—Ð°Ð¿Ð¸Ñ ÐºÐ°Ñ‚Ð¾ PDF файл -Name[bn]=ফাইল হিসেবে ছাপাও (পি-ডি-à¦à¦«) -Name[br]=Moulañ en ur restr (PDF) -Name[bs]=Å tampaj u datoteku (PDF) -Name[ca]=Imprimeix al fitxer (PDF) -Name[cs]=Tisk do souboru (PDF) -Name[csb]=Wëdrëk do lopka (PDF) -Name[cy]=Argraffu i Ffeil (PDF) -Name[da]=Udskriv til fil (PDF) -Name[de]=In Datei drucken (PDF) -Name[el]=ΕκτÏπωση σε αÏχείο (PDF) -Name[eo]=Presu al dosiero (PDF) -Name[es]=Imprimir en archivo (PDF) -Name[et]=Faili trükkimine (PDF) -Name[eu]=Inprimatu fitxategian (PDF) -Name[fa]=چاپ در پرونده )PDF( -Name[fi]=Tulosta PDF-tiedostoon -Name[fr]=Imprimer dans un fichier (PDF) -Name[fy]=Nei triem printsje (PDF) -Name[ga]=Priontáil go Comhad (PDF) -Name[gl]=Imprimir a un ficheiro (PDF) -Name[he]=הדפס לקובץ (PDF) -Name[hi]=फ़ाइल मे छापें (PDF) -Name[hr]=Ispis u PDF -Name[hu]=Nyomtatás fájlba (PDF) -Name[id]=Cetak ke Berkas (PDF) -Name[is]=Prenta í skrá (PDF/Acrobat) -Name[it]=Stampa su file (PDF) -Name[ja]=ファイルã«å‡ºåŠ› (PDF) -Name[ka]=ბეჭდვრფáƒáƒ˜áƒšáƒ¨áƒ˜ (PDF) -Name[kk]=Файлға баÑып шығару (PDF) -Name[km]=បោះពុម្ព​ទៅ​ឯកសារ (PDF) -Name[ko]=(PDF) 파ì¼ë¡œ ì°ê¸° -Name[lb]=An Datei drécken (PDF) -Name[lt]=Spausdinti į bylÄ… (PDF) -Name[lv]=DrukÄt failÄ (PDF) -Name[mk]=Печати во датотека (PDF) -Name[mn]=Файл руу Ñ…ÑвлÑÑ… (PDF/Acrobat) -Name[ms]= Cetak ke Fail(PDF) -Name[mt]=Printja Ä¡o fajl (PDF) -Name[nb]=Skriv til fil (PDF/Acrobat) -Name[nds]=Datei utgeven (PDF) -Name[ne]=फाइलमा मà¥à¤¦à¥à¤°à¤£ गरà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ (PDF) -Name[nl]=Naar bestand afdrukken (PDF) -Name[nn]=Skriv til fil (PDF/Acrobat) -Name[nso]=Gatisetsa go Faele (PDF) -Name[pa]=ਫਾਇਲ਼ ਵਿੱਚ ਛਾਪਣਾ(PDF) -Name[pl]=Wydruk do pliku (PDF) -Name[pt]=Imprimir para um Ficheiro (PDF) -Name[pt_BR]=Imprimir para Arquivo (PDF) -Name[ro]=Tipărire în fiÅŸier (PDF) -Name[ru]=Печать в файл (PDF) -Name[rw]=Gucapa ku Idosiye (PDF) -Name[se]=Čálit fiilii (PDF) -Name[sk]=TlaÄiÅ¥ do súboru (PDF) -Name[sl]=Tiskanje v datoteko (PDF) -Name[sq]=Shtyp në skedë (PDF) -Name[sr]=Штампање у фајл (PDF) -Name[sr@Latn]=Å tampanje u fajl (PDF) -Name[ss]=shicilela kuya efayelini (PDF) -Name[sv]=Skriv ut till fil (PDF) -Name[ta]=கோபà¯à®ªà¯à®•à¯à®•à¯ அசà¯à®šà®¿à®Ÿà¯ (PDF) -Name[te]=దసà±à°¤à±à°°à°‚ లొ à°ªà±à°°à°šà±à°°à°¿à°‚à°šà± (పిడిఎఫà±) -Name[tg]=Чоп намудан ба файл (PDF) -Name[th]=พิมพ์เป็นà¹à¸Ÿà¹‰à¸¡ (PDF) -Name[tr]=Dosyaya Yazdır (PDF) -Name[tt]=Biremgä Bastır (PDF) -Name[uk]=Друк у файл (PDF) -Name[uz]=PDF-fayli sifatida saqlash -Name[uz@cyrillic]=PDF-файли Ñифатида Ñақлаш -Name[ven]=Phirinthani ni kone u faela (PDF) -Name[vi]=In vào tập tin (PDF) -Name[wa]=Imprimer en on fitchî (PDF) -Name[xh]=Shicilela Kwifayile (PDF) -Name[zh_CN]=打å°åˆ°æ–‡ä»¶(PDF) -Name[zh_HK]=列å°åˆ°æ–‡ä»¶ (PDF) -Name[zh_TW]=列å°åˆ°æ–‡ä»¶(PDF) -Name[zu]=Shicilela Efayeleni (PDF) -Description=Write PDF/Acrobat file -Description[af]=Skryf Pdf/Acrobat lêer -Description[ar]=كتابة مل٠PDF/أكروبات -Description[az]=PDF/Acrobat fayl yaz -Description[be]=ЗапіÑваць данні Ñž файл PDF/Acrobat -Description[bg]=Ð—Ð°Ð¿Ð¸Ñ ÐºÐ°Ñ‚Ð¾ PDF/Acrobat файл -Description[bn]=পি-ডি-à¦à¦«/অà§à¦¯à¦¾à¦•à§à¦°à§‹à¦¬à§à¦¯à¦¾à¦Ÿ ফাইল লেখা হবে -Description[br]=Moulañ en ur restr PDF/Acrobat -Description[bs]=PiÅ¡i u PDF/Acrobat datoteku -Description[ca]=Escriure en un fitxer PDF/Acrobat -Description[cs]=Zapisuje do PDF souboru -Description[csb]=Zapiszë lopk PDF/Acrobat -Description[cy]=Ysgrifennwch ffeil PDF/Acrobat -Description[da]=Skriv PDF-fil -Description[de]=Eine PDF-Datei (Acrobat-Format) schreiben -Description[el]=ΕγγÏαφή αÏχείου PDF/Acrobat -Description[eo]=Skribas PDF/Akrobato-dosieron -Description[es]=Escribir archivo PDF/Acrobat -Description[et]=PDF/Acrobat-faili kirjutamine -Description[eu]=Idatzi PDF/Acrobat fitxategia -Description[fa]=نوشتن PDF/پروندۀ آکروبات -Description[fi]=Kirjoita PDF/Acrobat-tiedosto -Description[fr]=Imprime dans un fichier PDF / Acrobat -Description[fy]=Skriuw PDF/Acrobat-triem -Description[ga]=Scríobh comhad PDF/Acrobat -Description[gl]=Escreber ficheiro PDF/Acrobat -Description[he]=כתוב קובץ PDF/Acrobat -Description[hi]=पीडीà¤à¤«/à¤à¤•à¥à¤°à¥‹à¤¬à¥‡à¤Ÿ फ़ाइल लिखें -Description[hr]=Ispis u PDF/Acrobat datoteku -Description[hu]=PDF/Acrobat fájlba írás -Description[id]=Tulis Berkas PDF/Acrobat -Description[is]=Skrifa PDF/Acrobat skrá -Description[it]=Scrive file PDF/Acrobat -Description[ja]=PDF/Acrobat ファイルã®ä½œæˆ -Description[ka]=ჩáƒáƒ¬áƒ”რრPDF/Acrobat ფáƒáƒ˜áƒšáƒ¨áƒ˜ -Description[kk]=PDF/Acrobat файлды жазу -Description[km]=ឯកសារ Write PDF/Acrobat -Description[ko]=PDF/ì•„í¬ë¡œë±ƒ 파ì¼ë¡œ ì”니다 -Description[lb]=PDF/Acrobat-Datei schreiwen -Description[lt]=RaÅ¡yti PDF/Acrobat bylÄ… -Description[lv]=RakstÄ«t PDF/Acrobat failÄ -Description[mk]=Запиши PDF/Acrobat датотека -Description[mn]=PDF-файл (Acrobat-Format) бичих -Description[ms]=Tulis fail PDF/Acrobat -Description[mt]=Ikteb fajl PDF/Acrobat -Description[nb]=Skriv PDF/Acrobat-fil -Description[nds]=Druckopgaav as PDF- / Acrobat-Datei utgeven -Description[ne]=PDF/याकà¥à¤°à¥‹à¤¬à¥à¤¯à¤¾à¤Ÿ फाइलमा लेखà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ -Description[nl]=Schrijf PDF/Acrobat-bestand -Description[nn]=Skriv PDF/Acrobat-fil -Description[nso]=Ngwala faele ya PDF/Acrobat -Description[pa]=PDF/Acrobat ਫਾਇਲ ਲਿਖੋ -Description[pl]=Zapisz plik PDF/Acrobat -Description[pt]=Escrever ficheiro PDF/Acrobat -Description[pt_BR]=Salva como Arquivo PDF/Acrobat -Description[ro]=Scrie fiÅŸier PDF/Acrobat -Description[ru]=ЗапиÑÑŒ файла PDF/Acrobat -Description[rw]=Kwandika Idosiye PDF/Acrobat -Description[se]=Čále PDF/Acrobat fiilla -Description[sk]=ZapísaÅ¥ súbor PDF/Acrobat -Description[sl]=Izdela datoteko v PDF/Acrobat -Description[sq]=Shkruaj një Skedë PDF/Acrobat -Description[sr]=ЗапиÑује PDF/Acrobat фајл -Description[sr@Latn]=Zapisuje PDF/Acrobat fajl -Description[ss]=Bhala i-PDF/lifayela le Acrobat -Description[sv]=Skriv PDF/Acrobat-fil -Description[ta]=PDF/Acrobat கோபà¯à®ªà¯ எழà¯à®¤à¯ -Description[te]=పిడిఎఫà±/à°à°•à±à°°à±Šà°¬à±‡à°Ÿà± దసà±à°¤à±à°°à°‚ నౠవà±à°°à°¾à°¯à±à°Ÿ -Description[tg]=Сабти файли PDF/Acrobat -Description[th]=เขียนà¹à¸Ÿà¹‰à¸¡ PDF/Acrobat -Description[tr]=PDF/Acrobat dosyasına yaz -Description[tt]=PDF/Acrobat biremen yazdıru -Description[uk]=ЗапиÑати файл PDF/Acrobat -Description[uz]=PDF/Acrobat-fayli sifatida saqlash -Description[uz@cyrillic]=PDF/Acrobat-файли Ñифатида Ñақлаш -Description[ven]=Nwalani PDF/faela ya Acrobat -Description[vi]=Ghi tập tin PDF/Acrobat -Description[wa]=Fé on fitchî PDF/Acrobat -Description[xh]=Bhala PDF/Ifayile ye Acrobat -Description[zh_CN]=写入 PDF/Acrobat 文件 -Description[zh_HK]=å¯«æˆ PDF/Acrobat 檔案 -Description[zh_TW]=å¯«æˆ PDF/Acrobat 檔案 -Description[zu]=Bhala ifayela le-IPDF/Acrobat -Comment=Local file -Comment[af]=Plaaslike lêer -Comment[ar]=مل٠محلي -Comment[az]=Lokal faylı -Comment[be]=ÐœÑÑцовы файл -Comment[bg]=Локален файл -Comment[bn]=সà§à¦¥à¦¾à¦¨à§€à§Ÿ ফাইল -Comment[br]=Restr lec'hel -Comment[bs]=Lokalna datoteka -Comment[ca]=Fitxer local -Comment[cs]=Lokální soubor -Comment[csb]=Môlowi lopk -Comment[cy]=Ffeil lleol -Comment[da]=Lokal fil -Comment[de]=Lokale Datei -Comment[el]=Τοπικό αÏχείο -Comment[eo]=Loka dosiero -Comment[es]=Archivo local -Comment[et]=Kohalik fail -Comment[eu]=Fitxategi lokala -Comment[fa]=پروندۀ محلی -Comment[fi]=Paikallinen tiedosto -Comment[fr]=Fichier local -Comment[fy]=Lokaal triem -Comment[ga]=Comhad logánta -Comment[gl]=Ficheiro local -Comment[he]=קובץ מקומי -Comment[hi]=सà¥à¤¥à¤¾à¤¨à¥€à¤¯ फ़ाइल -Comment[hr]=Lokalna datoteka -Comment[hu]=Helyi fájl -Comment[id]=Berkas Lokal -Comment[is]=Staðvær skrá -Comment[it]=File locale -Comment[ja]=ローカルファイル -Comment[ka]=ლáƒáƒ™áƒáƒšáƒ£áƒ áƒ˜ ფáƒáƒ˜áƒšáƒ˜ -Comment[kk]=Жергілікті файл -Comment[km]=ឯកសារ​មូលដ្ឋាន -Comment[ko]=울 안 íŒŒì¼ -Comment[lb]=Lokal Datei -Comment[lt]=VietinÄ— byla -Comment[lv]=LokÄls fails -Comment[mk]=Локална датотека -Comment[mn]=локал файл -Comment[ms]=Fail setempat -Comment[mt]=Fajl lokali -Comment[nb]=Lokal fil -Comment[nds]=Lokale Datei -Comment[ne]=सà¥à¤¥à¤¾à¤¨à¥€à¤¯ फाइल -Comment[nl]=Lokaal bestand -Comment[nn]=Lokal fil -Comment[nso]=Faele ya selegae -Comment[pa]=ਲੋਕਲ ਫਾਇਲ -Comment[pl]=Plik lokalny -Comment[pt]=Ficheiro local -Comment[pt_BR]=Arquivo Local -Comment[ro]=FiÅŸier local -Comment[ru]=Локальный файл -Comment[rw]=Idosiye ya hafi -Comment[se]=BáikkálaÅ¡ fiila -Comment[sk]=Lokálny súbor -Comment[sl]=Krajevna datoteka -Comment[sq]=Skedë Lokale -Comment[sr]=Локални фајл -Comment[sr@Latn]=Lokalni fajl -Comment[ss]=Lifayela langekhatsi -Comment[sv]=Lokal fil -Comment[ta]=உளà¯à®³à®®à¯ˆà®•à¯ கோபà¯à®ªà¯ -Comment[te]=à°¸à±à°¥à°¾à°¨à°¿à°• దసà±à°¤à±à°°à°‚ -Comment[tg]=Файли маҳаллӣ -Comment[th]=à¹à¸Ÿà¹‰à¸¡à¸ à¸²à¸¢à¹ƒà¸™à¸£à¸°à¸šà¸š -Comment[tr]=Yerel dosya -Comment[tt]=Cirle birem -Comment[uk]=Локальний файл -Comment[uz]=Lokal fayl -Comment[uz@cyrillic]=Локал файл -Comment[ven]=Faela ya henefhano -Comment[vi]=Tập tin cục bá»™ -Comment[wa]=Fitchî locÃ¥l -Comment[xh]=Ifayile yobulali -Comment[zh_CN]=本地文件 -Comment[zh_HK]=本地檔案 -Comment[zh_TW]=本地檔案 -Comment[zu]=Ifayela laseduze -Icon=acroread -Command=ps2pdf -File=1 -Extension=pdf -Mimetype=application/pdf -Require=exec:/ps2pdf - -[Printer 2] -Name=Send to Fax -Name[af]=Stuur na Faks -Name[ar]=أرسل الى الÙاكس -Name[az]=Faksa GöndÉ™r -Name[bg]=Изпращане към Ñ„Ð°ÐºÑ -Name[bn]=ফà§à¦¯à¦¾à¦•à§à¦¸à§‡ পাঠাও -Name[br]=Kas d'ar faks -Name[bs]=Å alji na fax -Name[ca]=Envia al Fax -Name[cs]=Poslat na fax -Name[csb]=Wësli na faks -Name[cy]=Anfon i Ffacs -Name[da]=Send til fax -Name[de]=An Fax weiterleiten -Name[el]=Αποστολή σε φαξ -Name[eo]=Sendu al fakso -Name[es]=Enviar a fax -Name[et]=Faksile saatmine -Name[eu]=Bidali faxez -Name[fa]=ارسال به دورنگار -Name[fi]=Lähetä faksille -Name[fr]=Envoyer au fax -Name[fy]=Nei faks ferstjoere -Name[ga]=Seol go Facs -Name[gl]=Enviar por Fax -Name[he]=שלח בפקס -Name[hi]=फ़ैकà¥à¤¸ करें -Name[hr]=Slanje faksom -Name[hu]=Elküldés faxként -Name[id]=Kirim sebagai Faks -Name[is]=Senda á faxið -Name[it]=Invia al fax -Name[ja]=ファクスã¸é€ä¿¡ -Name[ka]=ფáƒáƒ¥áƒ¡áƒ˜áƒ— გáƒáƒ’ზáƒáƒ•áƒœáƒ -Name[kk]=ФакÑпен жіберу -Name[km]=បញ្ជូន​ទៅ​ទូរសារ -Name[ko]=팩스로 보내기 -Name[lb]=Un e Fax schécken -Name[lt]=Siųsti į faksÄ… -Name[lv]=SÅ«tÄ«t uz Faksu -Name[mk]=Прати на Ñ„Ð°ÐºÑ -Name[mn]=Ð¤Ð°ÐºÑ Ñ€ÑƒÑƒ гаргах -Name[ms]=Kirim ke Faks -Name[mt]=Ibgħat bħala fax -Name[nb]=Send til faks -Name[nds]=Fax sennen -Name[ne]=फà¥à¤¯à¤¾à¤•à¥à¤¸à¤®à¤¾ पठाउनà¥à¤¹à¥‹à¤¸à¥ -Name[nl]=Naar fax verzenden -Name[nn]=Send til faks -Name[nso]=Romela go Fax -Name[pa]=ਫੈਕਸ ਤੇ ਭੇਜੋ -Name[pl]=WyÅ›lij na faks -Name[pt]=Enviar por Fax -Name[pt_BR]=Enviar para o Fax -Name[ro]=Trimite prin FAX -Name[ru]=Отправить по факÑу -Name[rw]=Kohereza kuri Fagisi -Name[se]=Sádde fáksii -Name[sk]=PoslaÅ¥ na fax -Name[sl]=PoÅ¡lji faks -Name[sq]=Dërgo me Faks -Name[sr]=Слање факÑом -Name[sr@Latn]=Slanje faksom -Name[ss]=Tfumela ku Fax -Name[sv]=Skicka till fax -Name[ta]=தொலைநகலிகà¯à®•à¯ அனà¯à®ªà¯à®ªà¯ -Name[te]=ఫేకà±à°¸à±à°•à± పంపà±à°Ÿ -Name[tg]=ФириÑтодан ба Ñ„Ð°ÐºÑ -Name[th]=ส่งเป็นโทรสาร -Name[tr]=Faksa Yolla -Name[tt]=Faks aÅŸa Cibär -Name[uk]=ВідіÑлати на Ñ„Ð°ÐºÑ -Name[uz]=Faksga joÊ»natish -Name[uz@cyrillic]=ФакÑга жўнатиш -Name[ven]=Rumela kha fekisi -Name[vi]=Gởi tá»›i fax -Name[wa]=Evoyî so on facs -Name[xh]=Thumela kwi Fax -Name[zh_CN]=å‘é€è‡³ä¼ çœŸ -Name[zh_HK]=發é€è‡³å‚³çœŸ -Name[zh_TW]=發é€è‡³å‚³çœŸ -Name[zu]=Thumela kwi-fax -Description=Send to external fax system -Description[af]=Stuur na eksterne faks stelsel -Description[ar]=ارسال الى جهاز الÙاكس الخارجي -Description[az]=Xarici faks sisteminÉ™ yolla -Description[bg]=Изпращане към външна Ñ„Ð°ÐºÑ ÑиÑтема -Description[bn]=বহিঃসà§à¦¥ ফà§à¦¯à¦¾à¦•à§à¦¸ বà§à¦¯à¦¬à¦¸à§à¦¥à¦¾à§Ÿ পাঠাও -Description[bs]=Å alji na vanjski fax sistem -Description[ca]=Envia al sistema de fax extern -Description[cs]=Odesílá do externího faxového systému -Description[csb]=Wësli do bùtnowegò faksa -Description[cy]=Anfon i gysawd ffacs allanol -Description[da]=Send til eksternt fax-system -Description[de]=An externes Faxsystem weiterleiten -Description[el]=Αποστολή σε εξωτεÏικό σÏστημα φαξ -Description[eo]=Sendas al ekstera faksosistemo -Description[es]=Enviar a sistema de fax externo -Description[et]=Välisele faksisüsteemile saatmine -Description[eu]=Bidali kanpoko fax-sistemara -Description[fa]=ارسال به سیستم دورنگار خارجی -Description[fi]=Lähetä faksille -Description[fr]=Envoyer à un système de fax externe -Description[fy]=Nei in ekstern faxsysteem stjoere -Description[ga]=Seol go córas facs eachtrach -Description[gl]=Enviar a un sistema de fax externo -Description[he]=שלח למערכת פקס חיצונית -Description[hi]=बाहरी फेकà¥à¤¸ पà¥à¤°à¤£à¤¾à¤²à¥€ को भेजें -Description[hr]=Slanje u vanjski sustav za faks -Description[hu]=KülsÅ‘ faxgépre küldés -Description[id]=Kirim ke sistem faks eksternal -Description[is]=Senda á utanaðkomandi fax kerfi -Description[it]=Invia ad un sistema di fax esterno -Description[ja]=外部ファクスシステムã«é€ä¿¡ -Description[ka]=გáƒáƒ’ზáƒáƒ•áƒœáƒ გáƒáƒ áƒ” ფáƒáƒ¥áƒ¡áƒ˜áƒ— -Description[kk]=Сыртқы факÑпен жіберу -Description[km]=បញ្ជូនទៅ​ប្រពáŸáž“្ធ​ទូរសារ​ážáž¶áž„​ក្រៅ -Description[ko]=ë°”ê¹¥ì— ìžˆëŠ” 팩스 시스템으로 보냅니다 -Description[lb]=Un en externt Fax-System schécken -Description[lt]=Siųsti į iÅ¡orinÄ™ fakso sistemÄ… -Description[lv]=SÅ«tÄ«t uz ÄrÄ“jo faksa sistÄ“mu -Description[mk]=ИÑпрати на надворешен факÑ-ÑиÑтем -Description[mn]=Гадаад факÑын ÑиÑтем Ñ€Ò¯Ò¯ илгÑÑÑ… -Description[ms]=Kirim ke sistem faks luaran -Description[mt]=Ibgħat lis-sistema esterna tal-fax -Description[nb]=Send til eksternt telefaks-system -Description[nds]=Na'n extern Faxsysteem schicken -Description[ne]=बाहà¥à¤¯ फà¥à¤¯à¤¾à¤•à¥à¤¸ पà¥à¤°à¤£à¤¾à¤²à¥€à¤®à¤¾ पठाउनà¥à¤¹à¥‹à¤¸à¥ -Description[nl]=Naar een extern faxsysteem sturen -Description[nn]=Send til eksternt faks-system -Description[nso]=Romela go system ya kantle ya fax -Description[pa]=ਬਾਹਰੀ ਫੈਕਸ ਸਿਸਟਮ ਨੂੰ ਭੇਜੋ -Description[pl]=WyÅ›lij do zewnÄ™trznego faksu -Description[pt]=Enviar para um programa de fax -Description[pt_BR]=Enviar a um sistema de fax externo -Description[ro]=Trimite către un sistem de FAX extern -Description[ru]=Отправка на внешний Ñ„Ð°ÐºÑ -Description[rw]=Kohereza kuri sisitemu ya fagisi y'inyuma -Description[se]=Sádde olggoldas fáksavuogádahkii -Description[sk]=PoslaÅ¥ do externého faxového systému -Description[sl]=PoÅ¡lje faks v zunanji faksirni sistem -Description[sq]=Dërgo te ndonjë faks i jashtëm -Description[sr]=Пошаљи на Ñпољни Ñ„Ð°ÐºÑ ÑиÑтем -Description[sr@Latn]=PoÅ¡alji na spoljni faks sistem -Description[ss]=Tfumela kumshini we fax wangaphandle -Description[sv]=Skicka till externt faxsystem -Description[ta]=வெளித௠தொலைநகலிகà¯à®•à¯ அனà¯à®ªà¯à®ªà¯ -Description[te]=బయటి ఫేకà±à°¸à± వవసà±à°¥à°•à± పంపà±à°Ÿ -Description[tg]=Ба ÑиÑтемаи факÑи зоҳирӣ фириÑтодан -Description[th]=ส่งไปยังระบบโทรสารภายนอภ-Description[tr]=Dış faks sistemine yolla -Description[tt]=Tışqı faks sistemenä cibärü -Description[uk]=ВідіÑлати на зовнішню ÑиÑтему факÑу -Description[uz]=Tashqi faksga joÊ»natish -Description[uz@cyrillic]=Ташқи факÑга жўнатиш -Description[ven]=Rumelani kha sisitemu ya maitele a nnda a fekisi -Description[vi]=Gởi tá»›i hệ thống Ä‘iện thÆ° bên ngoài. -Description[wa]=Evoyî so on dfoûtrin sistinme di facs -Description[xh]=Thumela kwindlela engaphandle ye fax -Description[zh_CN]=å‘至外部传真系统 -Description[zh_HK]=發é€åˆ°å¤–部傳真系統 -Description[zh_TW]=發é€åˆ°å¤–部傳真系統 -Description[zu]=Thumela kwisistimu yangaphandle ye-fax -Comment=External -Comment[af]=Eksterne -Comment[ar]=خارجي -Comment[az]=Xarici -Comment[be]=Ð’Ð¾Ð½ÐºÐ°Ð²Ð°Ñ -Comment[bg]=Външен файл -Comment[bn]=বহিঃসà§à¦¥ -Comment[br]=Diavaez -Comment[bs]=Vanjski -Comment[ca]=Extern -Comment[cs]=Externí -Comment[csb]=Bùtnowi -Comment[cy]=Allanol -Comment[da]=Ekstern -Comment[de]=Extern -Comment[el]=ΕξωτεÏικό -Comment[eo]=Ekstera -Comment[es]=Externo -Comment[et]=Väline -Comment[eu]=Kanpokoa -Comment[fa]=خارجی -Comment[fi]=Ulkoinen -Comment[fr]=Externe -Comment[fy]=Ekstern -Comment[ga]=Eachtrach -Comment[gl]=Externo -Comment[he]=חיצוני -Comment[hi]=बाहरी -Comment[hr]=Vanjsko -Comment[hu]=KülsÅ‘ -Comment[id]=Eksternal -Comment[is]=Utanaðkomandi -Comment[it]=Esterno -Comment[ja]=外部 -Comment[ka]=გáƒáƒ áƒ” -Comment[kk]=Сыртқы -Comment[km]=ážáž¶áž„​ក្រៅ -Comment[ko]=바깥 -Comment[lb]=Extern -Comment[lt]=IÅ¡orinÄ— -Comment[lv]=Ä€rÄ“js -Comment[mk]=Ðадворешно -Comment[mn]=Гадаад -Comment[ms]=Luaran -Comment[mt]=Estern -Comment[nb]=Ekstern -Comment[nds]=Extern -Comment[ne]=बाहà¥à¤¯ -Comment[nl]=Extern -Comment[nn]=Ekstern -Comment[nso]=Ya kantle -Comment[pa]=ਬਾਹਰੀ -Comment[pl]=ZewnÄ™trzny -Comment[pt]=Externo -Comment[pt_BR]=Externo -Comment[ro]=Extern -Comment[ru]=Внешний -Comment[rw]=Inyuma -Comment[se]=Olggoldas -Comment[sk]=Externý -Comment[sl]=Zunanji -Comment[sq]=I Jashtëm -Comment[sr]=Спољни -Comment[sr@Latn]=Spoljni -Comment[ss]=Kwangaphandle -Comment[sv]=Extern -Comment[ta]=வெளி -Comment[te]=బయటి -Comment[tg]=Берунӣ -Comment[th]=ภายนอภ-Comment[tr]=Dış -Comment[tt]=Tışqı -Comment[uk]=Зовнішній -Comment[uz]=Tashqi -Comment[uz@cyrillic]=Ташқи -Comment[ven]=Zwangannda -Comment[vi]=Bên ngoài -Comment[wa]=Difoûtrin -Comment[xh]=Ngaphandle -Comment[zh_CN]=外部 -Comment[zh_HK]=外部 -Comment[zh_TW]=外部 -Comment[zu]=Ngaphandle -Icon=tdeprintfax -Command=tdeprintfax %in -File=0 -Extension= -Require=exec:/tdeprintfax - -[Printer 3] -Command=ps2pdf -sPAPERSIZE=%psl %in %out && kmailservice 'mailto:?attachment=file:%out' && sleep 15 && rm -f %out -Comment=Attachment for KMail Composer -Comment[af]=Aanhegsel vir Kpos Saamsteller -Comment[ar]=مرÙقات كاتب KMail -Comment[az]=Kmail Yazıçısına Ä°liÅŸdirilmiÅŸ -Comment[be]=ДалучÑнне KMail -Comment[bg]=Прикачен файл в KMail -Comment[bn]=কে-মেইল কমà§à¦ªà§‹à¦¸à¦¾à¦°-à¦à¦° জনà§à¦¯ অà§à¦¯à¦¾à¦Ÿà¦¾à¦šà¦®à§‡à¦¨à§à¦Ÿ -Comment[br]=Stagadenn evit aozer KMail -Comment[bs]=Attachment za KMail Composer -Comment[ca]=Adjunt per a l'editor del KMail -Comment[cs]=Příloha pro editor KMailu -Comment[csb]=Przëdôwk dlô KMail -Comment[cy]=Atodiad i Gyfansoddwr KMail -Comment[da]=Bilag til KMail Brevskriver -Comment[de]=Anhang des KMail-Editors -Comment[el]=Συνημμένο για το συνθέτη του KMail -Comment[eo]=Kunsendaĵo por retpoÅta mesaÄredaktilo -Comment[es]=Adjunto para el editor de KMail -Comment[et]=KMaili kirjale kaasamine -Comment[eu]=KMail Composer-entzako eranskina -Comment[fa]=پیوست برای مؤل٠KMail -Comment[fi]=Sähköpostiliite KMailille -Comment[fr]=Pièce jointe du logiciel de messagerie électronique KMail -Comment[fy]=Taheakke foar nije berjochten yn KMail -Comment[ga]=Iatán le haghaidh Cumadóra KMail -Comment[gl]=Adxunto para o Editor de KMail -Comment[he]=קובץ מצורף בכתבן של KMail -Comment[hi]=के-मेल कमà¥à¤ªà¥‹à¤œà¤° के लिठअटेचमेनà¥à¤Ÿ -Comment[hr]=Privitak za KMail Composer -Comment[hu]=Csatolás a KMail szerkesztÅ‘programhoz -Comment[id]=Lampiran untuk Penyusun KMail -Comment[is]=Viðhengi við KMail póst -Comment[it]=Allegato per il compositore di KMail -Comment[ja]=KMail メールã®æ·»ä»˜ç‰© -Comment[ka]=KMail-ის ჩáƒáƒœáƒáƒ áƒ—ი -Comment[kk]=KMail бағдарламаÑÑ‹ үшін тіркеме -Comment[km]=ឯកសារ​ភ្ជាប់​របស់​កម្មវិធី​ážáŸ‚áž„ KMail -Comment[ko]=KDE 편지용 편집기로 ë§ë¶™ì—¬ 보냅니다 -Comment[lb]=Unhang fir KMail-Verfaasser -Comment[lt]=KMail raÅ¡yklÄ—s priesaga -Comment[lv]=Pielikums priekÅ¡ KMail -Comment[mk]=Додаток за ÑоÑтавувачот во KMail -Comment[mn]=KMail-боловÑруулагчийн хавÑрага -Comment[ms]=Kepilan untuk Penggubah KMail -Comment[mt]=Abbinament għall-kompożitur KMail -Comment[nb]=Vedlegg for e-postredigering i KMail -Comment[nds]=Bilaag för den KMail-Editor -Comment[ne]=KMail रचनाकारका लागि सङà¥à¤²à¤—à¥à¤¨à¤¤à¤¾ -Comment[nl]=Bijlage voor KMail Opsteller -Comment[nn]=Vedlegg for e-postredigering i KMail -Comment[nso]=Kgwathiso ya Mohlagisi wa KPoso -Comment[pa]=ਕੇਮੇਲ ਪੱਤਰ-ਨਿਰਮਾਤਾ ਲਈ ਨੱਥੀ -Comment[pl]=ZaÅ‚Ä…cznik KMaila -Comment[pt]=Anexo para o programa KMail -Comment[pt_BR]=Anexo para o Kmail -Comment[ro]=AtaÅŸament pentru KMail -Comment[ru]=Вложение Ð´Ð»Ñ KMail -Comment[rw]=Umugereka wa KUbutumwa Muhanga -Comment[se]=KMail Composer mielddus -Comment[sk]=Príloha pre composer KMailu -Comment[sl]=Pripeta datoteka za sestavljalnik Kmail -Comment[sq]=Ngjitësh Skedarësh për KMail Composer -Comment[sr]=Прилог за KMail-ов ÑаÑтављач -Comment[sr@Latn]=Prilog za KMail-ov sastavljaÄ -Comment[ss]=Lokunanyatsiliseliwe kwesisunguli se Kmail -Comment[sv]=Bilaga till Kmails e-posteditor -Comment[ta]=KMail உரà¯à®µà®¾à®•à¯à®•à®¿à®•à¯à®•à®¾à®© இணைபà¯à®ªà¯ -Comment[te]=కెతపాలా కంపొజరౠకౠఅనà±à°¬à°‚ధం -Comment[tg]=МуÑтаҳкам Кардани барои БаÑтакор KПочтаи Электрони -Comment[th]=à¸à¸²à¸£à¹à¸™à¸šà¹à¸Ÿà¹‰à¸¡à¸ªà¸³à¸«à¸£à¸±à¸šà¹€à¸„รื่องมือเขียนจดหมาย KMail -Comment[tr]=KMaıl için ek -Comment[tt]=KMail öçen qıstırma -Comment[uk]=Ð”Ð¾Ð»ÑƒÑ‡ÐµÐ½Ð½Ñ Ð´Ð»Ñ Ñ€ÐµÐ´Ð°ÐºÑ‚Ð¾Ñ€Ð° KMail -Comment[uz]=KMail uchun ilova -Comment[uz@cyrillic]=KMail учун илова -Comment[ven]=U tangana na mubveledzi wa meili wa K -Comment[vi]=Äính kèm cho Bá»™ soạn thảo KMail -Comment[xh]=Ufakelo Lomqhambi we KMail -Comment[zh_CN]=KMail 编写器的附件 -Comment[zh_HK]=當作 KMail 郵件編輯器的附件 -Comment[zh_TW]=當作 KMail 郵件編輯器的附件 -Comment[zu]=Ukunamathisela Komsunguli we-KMail -Description=Creates PDF/Acrobat file as attachment for KMail -Description[af]=Skep Pdf/Acrobat lêer as aanhegsel vir Kpos -Description[ar]=توليد مل٠PDF/أكروبات كملحق لرسالة عن طريق KMail -Description[az]=KmailÉ™ iliÅŸdirmÉ™k üçün PDF/Acrobat faylı yaradır -Description[be]=Стварае файл PDF/Acrobat Ñ– далучае Ñго да ліÑта KMail -Description[bg]=Създаване на прикрепен PDF файл в KMail -Description[bn]=ফাইল -Description[bs]=Pravi PDF/Acrobat dokument kao attachment za KMail -Description[ca]=Crea un fitxer PDF/Acrobat com a adjunt per al KMail -Description[cs]=Vytvoří PDF/Acrobat soubor jako přílohu pro KMail -Description[csb]=Ùsôdzô lopk PDF/Acrobat jakno przëdôwk dlô KMaila -Description[cy]=Creu ffeil PDF/Acrobat fel atodiad i KMail -Description[da]=Opretter PDF-fil som bilag for KMail -Description[de]=Eine PDF-Datei (Acrobat-Format) als Anhang für KMail erstellen -Description[el]=ΔημιουÏγεί αÏχεία PDF/Acrobat και τα επισυνάπτει στο KMail -Description[eo]=Kreas PDF/Akrobato-dosieron kiel kunsendaĵo de PoÅtilo -Description[es]=Crear archivo PDF/Acrobat como adjunto para KMail -Description[et]=Tekitab PDF/Acrobat-faili ja kaasab selle KMaili kirjale -Description[eu]=PDF/Acrobat fitxategiak sortzen ditu KMail-en eranskin gisa -Description[fa]=PDF/پروندۀ آکروبات را به‌ عنوان پیوست برای KMail ایجاد می‌کند -Description[fi]=Luo PDF/Acrobat-tiedoston sähköpostiliitteenä KMailille -Description[fr]=Crée un fichier PDF en tant que pièce jointe pour KMail -Description[fy]=Kreëart PDF/Acrobat-triem as taheakke foar KMail -Description[ga]=Cruthaíonn comhad PDF/Acrobat mar iatán do KMail -Description[gl]=Cria un ficheiro PDF/Acrobat como ficheiro adxunto para KMail -Description[he]=יוצר קובץ PDF/Acrobat בתור מצורף של KMail -Description[hi]=के-मेल के लिठपीडीà¤à¤«/à¤à¤•à¥à¤°à¥‹à¤¬à¥‡à¤Ÿ फ़ाइल का अटेचमेनà¥à¤Ÿ बनाà¤à¤‚ -Description[hr]=Izrada PDF/Acrobat datoteke kao privitak za KMail -Description[hu]=PDF/Acrobat fájl létrehozása KMail csatolásként -Description[id]=Buat berkas PDF/Acrobat sebagai lampiran untuk KMail -Description[is]=Býr til PDF/Acrobat skrá sem viðhengi fyrir KMail -Description[it]=Crea un file di allegato PDF/Acrobat per KMail -Description[ja]=PDF/Acrobat ファイルを KMail ã®æ·»ä»˜ç‰©ã¨ã—ã¦ä½œæˆ -Description[ka]=PDF/Acrobat ფáƒáƒ˜áƒšáƒ˜áƒ¡ შექმნრKMail-ის ჩáƒáƒœáƒáƒ áƒ—áƒáƒ“ -Description[kk]=PDF/Acrobat файлды KMail бағдарламаға тіркеме ретінде шығару -Description[km]=បង្កើážâ€‹áž¯áž€ážŸáž¶ážš PDF/Acrobat ជា​ឯកសារ​ភ្ជាប់​សម្រាប់ KMail -Description[ko]=KDE íŽ¸ì§€ì— ë§ë¶™ì¼ PDF/ì–´í¬ë¡œë±ƒ 파ì¼ë¡œ 만듭니다 -Description[lb]=Erstellt eng PDF/Acrobat-Datei als Unhang fir de KMail -Description[lt]=RaÅ¡yti PDF/Acrobat bylÄ… kaip priesagÄ… KMail programai -Description[lv]=Izveido PDF/AkrobÄta failu kÄ pielikumu KPastam -Description[mk]=Создава PDF/Acrobat датотека како додаток за KMail -Description[mn]=PDF-файл (Acrobat-Format) KMail-н хувьд хавÑрагаар Ò¯Ò¯ÑгÑÑ… -Description[ms]=Cipta fail PDF/Acrobat sebagai kepilan untuk KMail -Description[mt]=Joħloq fajl PDF/Acrobat bħala abbinament għall-KMail -Description[nb]=Lager PDF/Acrobat-fil som vedlegg til KMail -Description[nds]=Stellt niege PDF/Acrobat-Datei as Bilaag för KMail op -Description[ne]=KMail का लागि संलगà¥à¤° फाइलको रूपमा PDF/याकà¥à¤°à¥‹à¤¬à¥à¤¯à¤¾à¤Ÿ फाइल सिरà¥à¤œà¤¨à¤¾ गरà¥à¤› -Description[nl]=Creëert PDF/Acrobat-bestand als bijlage voor KMail -Description[nn]=Lagar PDF/Acrobat-fil som vedlegg i KMail -Description[nso]=E hlagisa faele ya PDF/Acrobat bjale ka kgwathiso go KPoso -Description[pa]=ਕੇਮੇਲ ਲਈ PDF/à¨à¨•à¨°à©‹à¨¬à©ˆà¨Ÿ ਫਾਇਲ ਨੂੰ ਨੱਥੀ ਕਰੋ -Description[pl]=Tworzy plik PDF/Acrobata jako zaÅ‚Ä…cznik do wiadomoÅ›ci KMaila -Description[pt]=Cria um ficheiro PDF/Acrobat como anexo para o KMail -Description[pt_BR]=Cria arquivos PDF/Acrobat como anexos para o Kmail -Description[ro]=Creează fiÅŸier PDF/Acrobat ca ataÅŸament pentru KMail -Description[ru]=ЗапиÑÑŒ файла PDF/Acrobat как Ð²Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð´Ð»Ñ KMail -Description[rw]=Irema idosiye PDF/Acrobat nk'umugereka wa KUbutumwa -Description[se]=Ráhkada PDF/Acrobat-fiilla KMail'ii mielddusin -Description[sk]=Vytvorí súbor PDF/Acrobat ako prílohu pre KMail -Description[sl]=Izdela datoteko v PDF/Acrobat kot prilogo za Kmail -Description[sq]=Krijon PDF/Acrobat skedën si ngjitëse për programin KMail -Description[sr]=Прави PDF/Acrobat фајл као прилог за KMail -Description[sr@Latn]=Pravi PDF/Acrobat fajl kao prilog za KMail -Description[ss]=Calisa lifayela lePDF/Acrobat njengelokunanyatsiselwe ku- KMail -Description[sv]=Skapar PDF/Acrobat-fil som en bilaga till Kmail -Description[ta]=கேஅஞà¯à®šà®²à¯ இணைபà¯à®ªà®¾à®•, PDF/Acrobat கோபà¯à®ªà®¿à®©à¯ˆ உரà¯à®µà®¾à®•à¯à®•à¯à®®à¯ -Description[te]=పిడిఎఫౠదసà±à°¤à±à°°à°‚నౠకెతపాలా à°•à± à°…à°¨à±à°¬à°‚ధంగా à°¸à±à°°à±à°·à±à°Ÿà°¿à°¸à±à°¤à±à°‚ది -Description[tg]=PDF Эҷод Кардан/Файли Acrobat ҳамчун МуÑтаҳкам барои KПочтаи Электрони -Description[th]=สร้างà¹à¸Ÿà¹‰à¸¡ PDF/Acrobat เป็นà¹à¸Ÿà¹‰à¸¡à¹à¸™à¸šà¸ªà¸³à¸«à¸£à¸±à¸šà¹‚ปรà¹à¸à¸£à¸¡ KMail -Description[tr]=KMail için, ek ÅŸeklinde, PDF/Acrobat dosyası oluÅŸturur. -Description[tt]=PDF/Acrobat biremen yasap, KMail'ÄŸa qıstırma itep birä -Description[uk]=Створює файл PDF/Acrobat Ñк Ð´Ð¾Ð»ÑƒÑ‡ÐµÐ½Ð½Ñ Ð´Ð»Ñ KMail -Description[uz]=KMail uchun ilova sifatida PDF/Acrobat-faylini yaratadi -Description[uz@cyrillic]=KMail учун илова Ñифатида PDF/Acrobat-файлини Ñратади -Description[ven]=Itani PDF/Faela ya Acrobat sa vhutumani ha meili ya K -Description[vi]=Tạo tập tin PDF/Acrobat dạng đính kèm thÆ° KMail -Description[wa]=Fé des fitchîs PDF/Acrobat come atatchmints po KMail -Description[xh]=Yenza PDF/Ifayile yomenzi womthambo njengofakelelo lwe KMail -Description[zh_CN]=创建 PDF/Acrobat 文件作为 KMail 附件 -Description[zh_HK]=建立 PDF/Acrobat 文件作為 KMail 附件 -Description[zh_TW]=建立 PDF/Acrobat 文件作為 KMail 附件 -Description[zu]=Idala ifayela le-PDF/Acrobat libe njengokunamathisela kwe-KMail -Extension=pdf -Mimetype=application/pdf -File=1 -Icon=kmail -Name=Mail PDF File -Name[af]=Pos PDF Lêer -Name[ar]=مل٠PDF للإرسال -Name[bg]=Изпращане като PDF файл по е-поща -Name[bn]=পি-ডি-à¦à¦« ফাইল মেইল করো -Name[br]=Postelañ ur restr PDF -Name[bs]=PoÅ¡alji PDF dokument na mail -Name[ca]=Envia fitxer PDF per correu -Name[cs]=Odeslat PDF soubor emailem -Name[csb]=Wësli e-mailã lopk PDF -Name[da]=Send PDF-fil som e-mail -Name[de]=PDF-Datei versenden -Name[el]=Αποστολή αÏχείου PDF μέσω mail -Name[eo]=Sendu PDF-dosieron -Name[es]=Enviar archivo PDF por correo -Name[et]=PDF-faili kirjaga saatmine -Name[eu]=Bidali PDF fitxategia -Name[fa]=پروندۀ نامۀ PDF -Name[fi]=Lähetä PDF-tiedosto sähköpostilla -Name[fr]=Pièce jointe PDF -Name[fy]=Ferstjoer PDF triem -Name[ga]=Seol Comhad PDF -Name[gl]=Enviar por correo-e un ficheiro PDF -Name[he]=שלח קובץ PDF בדו×ר -Name[hi]=पीडीà¤à¤«à¤¼ फ़ाइल मेल करें -Name[hr]=PDF poÅ¡alji poÅ¡tom -Name[hu]=PDF-fájl elküldése levélben -Name[id]=Kirim Berkas PDF -Name[is]=Senda PDF skrá í pósti -Name[it]=Spedisci file PDF -Name[ja]=PDF ファイルをメール -Name[ka]=PDF ფáƒáƒ˜áƒšáƒ˜áƒ¡ გáƒáƒ’ზáƒáƒ•áƒœáƒ -Name[kk]=PDF файлды жіберу -Name[km]=ផ្ញើ Mail PDF -Name[lb]=PDF-Datei mailen -Name[lt]=PaÅ¡to PDF byla -Name[lv]=SÅ«tÄ«t PDF failu -Name[mk]=PDF по е-пошта -Name[ms]=Mel fail PDF -Name[nb]=Send PDF-fil -Name[nds]=PDF-Datei mit Nettpost schicken -Name[ne]=पतà¥à¤° PDF फाइल -Name[nl]=PDF-bestand e-mailen -Name[nn]=Send PDF-fil -Name[pa]=PDF ਫਾਇਲ ਮੇਲ ਕਰੋ -Name[pl]=WyÅ›lij plik PDF e-mailem -Name[pt]=Enviar PDF por E-mail -Name[pt_BR]=Enviar por E-Mail Arquivo PDF -Name[ro]=Trimite prin mail ca PDF -Name[ru]=Отправить файл PDF -Name[rw]=Kohereza Ubutumwa bw'Idosiye PDF -Name[se]=Sádde PDF-fiilla -Name[sk]=PoslaÅ¥ súbor PDF -Name[sl]=PoÅ¡lji datoteko PDF po poÅ¡ti -Name[sr]=Слање PDF фајла поштом -Name[sr@Latn]=Slanje PDF fajla poÅ¡tom -Name[sv]=Skicka PDF-fil -Name[ta]=PDF கோபà¯à®ªà¯ˆ அஞà¯à®šà®²à¯ அனà¯à®ªà¯à®ªà¯ -Name[te]=పిFఇఎఫౠదసà±à°¤à±à°° తపాలా -Name[tg]=Файли почтавии PDF -Name[th]=ส่งà¹à¸Ÿà¹‰à¸¡ PDF ทางจดหมาย -Name[tr]=PDF Dosyasını Postala -Name[tt]=PDF Birem Cibärü -Name[uk]=ВідÑÐ¸Ð»Ð°Ð½Ð½Ñ Ñ„Ð°Ð¹Ð»Ð° PDF поштою -Name[uz]=PDF-fayli sifatida xat orqali joÊ»natish -Name[uz@cyrillic]=PDF-файли Ñифатида хат орқали жўнатиш -Name[vi]=Gởi tập tin PDF trong thÆ° -Name[zh_CN]=邮寄 PDF 文件 -Name[zh_HK]=郵寄 PDF 文件 -Name[zh_TW]=郵寄 PDF 文件 -Require=exec:/ps2pdf,exec:/kmail - -[Printer 4] -Command=ksendfax %in -Comment=KSendFax -Comment[bg]=Външна програма KSendFax -Comment[cy]=KAnfonFfacs -Comment[eo]=SendFaksilo -Comment[hi]=के-सेंड-फ़ैकà¥à¤¸ -Comment[is]=KsendFax -Comment[ko]=K팩스보내기 -Comment[nso]=KFax ya Thomelo -Comment[sv]=Ksendfax -Comment[ta]=கேஃபாகà¯à®¸à®©à¯à®ªà¯à®ªà¯ -Comment[te]=కెసెండౠఫేకà±à°¸à± -Comment[tg]=KÐ¤Ð°ÐºÑ Ð¤Ð¸Ñ€Ð¸Ñтодан -Comment[th]=ส่งโทรสาร K -Comment[uz]=Faks joÊ»natish -Comment[uz@cyrillic]=Ð¤Ð°ÐºÑ Ð¶ÑžÐ½Ð°Ñ‚Ð¸Ñˆ -Comment[ven]=K i rumela Fekisi -Description=Use ksendfax to fax the current document -Description[af]=Gebruik ksendfax om die huidige dokument te faks -Description[ar]=استخدم ksendfax ﻹرسال المستند الحالي بالÙاكس -Description[az]=Hazırkı sÉ™nÉ™di fakslamaq üçün ksendfax vasitÉ™sini iÅŸlÉ™din -Description[bg]=Изпращане на документа по Ñ„Ð°ÐºÑ -Description[bn]=বরà§à¦¤à¦®à¦¾à¦¨à§‡ নথীটি ksendfax বà§à¦¯à¦¬à¦¹à¦¾à¦° করে ফà§à¦¯à¦¾à¦•à§à¦¸ করো -Description[br]=Implij ksendfax da gas an teul red -Description[bs]=Koristite ksendfax za slanje trenutnog dokumenta na fax -Description[ca]=Empra el ksendfax per a enviar per fax l'actual document -Description[cs]=Použít ksendfax k odfaxování souÄasného dokumentu -Description[csb]=Programa do wësëłaniô faksã biéżnegò dokùmentu -Description[cy]=Defnyddion kanfonffacs i ffacsio'r ddogfen gyfredol -Description[da]=Brug ksendfax til at faxe dette dokument -Description[de]=KSendFax zum Faxen des Dokuments verwenden -Description[el]=ΧÏήση του ksendfax για την αποστολή με φαξ του Ï„Ïέχοντος εγγÏάφου -Description[eo]=Uzu ksendfax por faksi la nunan dokumenton -Description[es]=Use ksendfax para enviar un fax del documento actual -Description[et]=Ksendfax'i kasutamine aktiivse dokumendi faksimiseks -Description[eu]=Erabili ksendfax uneko dokumentua faxez bidaltzeko -Description[fa]=از KSendFax برای دورنگاری سند جاری استÙاده کنید -Description[fi]=Käytä kdendfax-ohjelmaa faksataksesi asiakirja -Description[fr]=Utiliser KSendfax pour faxer le document actuel -Description[fy]=Brûk KSendfax foar it faksen fan it dokumint dat ûnder hannen is -Description[ga]=Úsáid ksendfax chun an cháipéis reatha a sheoladh mar fhacs -Description[gl]=Empregue ksendfax para enviar por fax o documento actual -Description[he]=השתמש ב־ksendfax כדי לשלוח ×ת המסמך הנוכחי בפקס -Description[hi]=मौज़ूदा दसà¥à¤¤à¤¾à¤µà¥‡à¤œà¤¼ को फेकà¥à¤¸ करने के लिठके-सेंड-फेकà¥à¤¸ का ईसà¥à¤¤à¤®à¤¾à¤² करें -Description[hr]=Slanje trenutnog dokumenta pomoću ksendfax -Description[hu]=A KSendFax használata az aktuális dokumentum elfaxolásához -Description[id]=Gunakan ksendfax untuk mengirim dokumen sekarang sebagai faks -Description[is]=Nota ksendfax til að senda skjal á faxtæki -Description[it]=Usa ksendfax per inviare come fax il documento corrente -Description[ja]=ksendfax ã¯ç¾åœ¨ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’ファクスã™ã‚‹ã®ã«ä½¿ã„ã¾ã™ -Description[ka]=დáƒáƒ™áƒ£áƒ›áƒ”ნტის ფáƒáƒ¥áƒ¡áƒ˜áƒ— გáƒáƒ¡áƒáƒ’ზáƒáƒ•áƒœáƒáƒ“ ksendfax-ის გáƒáƒ›áƒáƒ§áƒ”ნებრ-Description[kk]=ksendfax утилитаÑÑ‹ құжатты факÑпен жіберу үшін -Description[km]=ប្រើ ksendfax ដើម្បី​ផ្ញើ​ឯកសារ​បច្ចុប្បន្ន​ážáž¶áž˜â€‹ážšáž™áŸˆâ€‹áž‘ូរសារ -Description[ko]=현재 문서를 팩스로 보내기 위해 ksendfax를 ì”니다 -Description[lb]=Benotzt de ksendfax fir dat aktuellt Dokument ze faxen -Description[lt]=Naudoja ksendfax esamam dokumentui siųsti faksu -Description[lv]=Izmanto ksendfax, lai nosÅ«tÄ«tu dokumentu pa faksu -Description[mk]=ИÑпраќање на тековниот документ по Ñ„Ð°ÐºÑ Ñо ksendfax -Description[mn]=Ð­Ð½Ñ Ð±Ð°Ñ€Ð¸Ð¼Ñ‚Ñ‹Ð³ факÑдахдаа ksendfax-г Ñ…ÑÑ€ÑÐ³Ð»Ñ -Description[ms]=Guna ksendfax untuk faks dokumen sekarang -Description[mt]=Uża ksendfax biex tiffaksja d-dokument kurrenti -Description[nb]=Bruk ksendfax for Ã¥ fakse det aktive dokumentet -Description[nds]=Dat aktuelle Dokment mit ksendfax as Fax schicken -Description[ne]=हालको कागजात फà¥à¤¯à¤¾à¤•à¥à¤¸ गरà¥à¤¨ ksendfax पà¥à¤°à¤¯à¥‹à¤— गरà¥à¤¨à¥à¤¹à¥‹à¤¸à¥ -Description[nl]=Gebruik KSendFax voor het faxen van het huidige document -Description[nn]=Bruk ksendfax til Ã¥ faksa dokument -Description[nso]=Somisa ksendfax go faxa tokomane ya bjale -Description[pa]=ਮੌਜੂਦਾ ਦਸਤਾਵੇਜ਼ ਨੂੰ ਫੈਕਸ ਕਰਨ ਲਈ ksendfax ਵਰਤੋਂ -Description[pl]=Program do wysÅ‚ania faksem bieżącego dokumentu -Description[pt]=Use o ksendfax para enviar o documento actual por fax -Description[pt_BR]=Use o ksendfax para enviar por fax o documento atual -Description[ro]=Utilizează ksendfax pentru a trimite prin FAX documentul curent -Description[ru]=ИÑпользование ksendfax Ð´Ð»Ñ Ð¾Ñ‚Ð¿Ñ€Ð°Ð²ÐºÐ¸ документа по факÑу -Description[rw]=Gukoresha Kkoherezafagisi kuri fagisi inyandiko igezweho -Description[se]=Geavat ksendfax dálá dokumentta fáksemii -Description[sk]=Použite ksendfax pre odfaxovanie aktuálneho dokumentu -Description[sl]=Uporabite kdsendfax za faksiranje trenutnega dokumenta -Description[sq]=Përdor ksendfax për ta dërguar dokumentin aktual me faks -Description[sr]=КориÑтите ksendfax да пошаљте текући документ на Ñ„Ð°ÐºÑ -Description[sr@Latn]=Koristite ksendfax da poÅ¡aljte tekući dokument na faks -Description[ss]=Sebentisa i-ksendfax kutfumela ngefax kwelidokhumente lanyalo -Description[sv]=Använd Ksendfax för att faxa aktuellt dokument -Description[ta]=கேஃபாகà¯à®¸à¯à®…னà¯à®ªà¯à®ªà¯ மூலம௠நடபà¯à®ªà¯ ஆவணதà¯à®¤à¯ˆ தொலைநகலிட௠-Description[te]=à°ªà±à°°à°¸à±à°¤à±à°¤ పతà±à°°à°¾à°¨à±à°¨à°¿ కెసెండౠఫేకà±à°¸à± à°¦à±à°µà°¾à°°à°¾ ఫేకà±à°¸à± పంపించà±à°Ÿà°•à± వాడండి -Description[tg]=kÑ„Ð°ÐºÑ Ñ„Ð¸Ñ€Ð¸Ñтодан иÑтифода кардан барои ин ки хуҷҷати шоранда Ñ„Ð°ÐºÑ ÐºÐ°Ñ€Ð´Ð°Ð½ -Description[th]=ใช้ ksendfax เพื่อส่่งเอà¸à¸ªà¸²à¸£à¸›à¸±à¸ˆà¸ˆà¸¸à¸šà¸±à¸™à¸—างโทรสาร -Description[tr]=Güncel belgeyi fakslamak için ksendfaz kullan -Description[tt]=Biredäge istälekne fakslaw öçen ksendfax qullanu -Description[uk]=ВикориÑтовує ksendfax Ð´Ð»Ñ Ð²Ñ–Ð´ÑÐ¸Ð»Ð°Ð½Ð½Ñ Ð¿Ð¾Ñ‚Ð¾Ñ‡Ð½Ð¾Ð³Ð¾ документу на Ñ„Ð°ÐºÑ -Description[uz]=Joriy hujjatni faks bilan joÊ»natish uchun ksendfax'dan foydalaning -Description[uz@cyrillic]=Жорий ҳужжатни Ñ„Ð°ÐºÑ Ð±Ð¸Ð»Ð°Ð½ жўнатиш учун ksendfax'дан фойдаланинг -Description[ven]=Shumisani fekisi yau rumele kha k u fekisa manwalwa a zwino -Description[vi]=Sá»­ dụng ksendfax để gởi tài liệu hiện có qua máy Ä‘iện thÆ°. -Description[wa]=Eploye ksendfax po-z evoyî pa facs li documint do moumint -Description[xh]=Sebenzisa i ksendfax ukuthumela i fax yoxwebhu lwangoku -Description[zh_CN]=使用 ksendfax å‘é€å½“å‰æ–‡æ¡£ -Description[zh_HK]=使用 ksendfax 將目å‰æ–‡ä»¶å‚³çœŸå‡ºåŽ» -Description[zh_TW]=使用 ksendfax 將目å‰æ–‡ä»¶å‚³çœŸå‡ºåŽ» -Description[zu]=Sebenzisa i-ksendfax ukuthumela i-fax yohlu lwamafayela amanje -Extension= -File=0 -Icon=tdeprintfax -Name=Advanced Faxing Tool (ksendfax) -Name[af]=Gevorderde Faks Program (ksendfax) -Name[ar]=أداة إرسال Ùاكس متقدمة (ksendfax) -Name[az]=TÉ™kmilləşmiÅŸ Faks VasitÉ™si (ksendfax) -Name[bg]=Разширена Ñ„Ð°ÐºÑ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð° (ksendfax) -Name[bn]=উনà§à¦¨à¦¤ ফà§à¦¯à¦¾à¦•à§à¦¸ বà§à¦¯à¦¬à¦¸à§à¦¥à¦¾ (ksendfax) -Name[br]=Ostilh faks barek (ksendfax) -Name[bs]=Napredni alat za slanje faxova (ksendfax) -Name[ca]=Eina avançada per a enviar per fax (ksendfax) -Name[cs]=PokroÄilý faxovací nástroj (ksendfax) -Name[csb]=Awansowóné faksowanié (ksendfax) -Name[cy]=Erfyn Ffacsio Uwch (ksendfax) -Name[da]=Avanceret fax-værktøj (ksendfax) -Name[de]=Erweitertes Faxprogramm (ksendfax) -Name[el]=ΠÏοχωÏημένο εÏγαλείο αποστολής φαξ (ksendfax) -Name[eo]=Pliluksa Faksilo (ksendfax) -Name[es]=Herramienta avanzada de envío de faxes (ksendfax) -Name[et]=Võimas faksimise rakendus (ksendfax) -Name[eu]=Faxaren tresna aurreratua (ksendfax) -Name[fa]=ابزار دورنگار پیشرÙته)KSendFax( -Name[fi]=Edistynyt faksaustyökalu (ksendfax) -Name[fr]=Outil de fax avancé (KSendfax) -Name[fy]=Avansearre faksprogramma (ksendfax) -Name[ga]=Uirlis Fhacsála (ksendfax) -Name[gl]=Ferramenta Avanzada de Fax (ksendfax) -Name[he]=כלי ×ž×ª×§×“× ×œ×©×œ×™×—×ª ×¤×§×¡×™× (ksendfax) -Name[hi]=उनà¥à¤¨à¤¤ फेकà¥à¤¸ साधन (ksendfax) -Name[hr]=Napredni alat za slanje faksa (ksendfax) -Name[hu]=Faxolási segédprogram (KSendFax) -Name[id]=Perangkat Bantu Faks Lanjutan (ksendfax) -Name[is]=Þróað faxtól (ksendfax) -Name[it]=Strumento avanzato per i fax (ksendfax) -Name[ja]=高機能ファクスツール (ksendfax) -Name[ka]=ფáƒáƒ¥áƒ¡áƒ˜áƒ¡ გáƒáƒ’ზáƒáƒ•áƒœáƒ˜áƒ¡ სპეციáƒáƒšáƒ£áƒ áƒ˜ პრáƒáƒ’რáƒáƒ›áƒ (ksendfax) -Name[kk]=ФакÑпен жіберу утилитаÑÑ‹ (ksendfax) -Name[km]=ឧបករណáŸâ€‹áž•áŸ’ញើ​ទូរសារ​កម្រិážâ€‹ážáŸ’ពស់ (ksendfax) -Name[ko]=고급 팩스 ë„구 (ksendfax) -Name[lb]=Erweiderte Faxprogramm (ksendfax) -Name[lt]=SudÄ—tingesnis faksų siuntimo įrankis (ksendfax) -Name[lv]=PaplaÅ¡inÄts faksa rÄ«ks (ksendfax) -Name[mk]=Ðапредна алатка за факÑови (ksendfax) -Name[mn]=ДÑвшилтÑÑ‚ Ñ„Ð°ÐºÑ Ñ…ÑÑ€ÑгÑÑл (ksendfax) -Name[ms]=Alatan Faks Termaju (ksendfax) -Name[mt]=Għodda avvanzata għall-fax (ksendfax) -Name[nb]=Avansert faxverktøy (ksendfax) -Name[nds]=Verwiedert Fax-Warktüüch (ksendfax) -Name[ne]=उनà¥à¤¨à¤¤ फà¥à¤¯à¤¾à¤•à¥à¤¸ उपकरण (ksendfax) -Name[nl]=Geavanceerd faxprogramma (ksendfax) -Name[nn]=Avansert faksverktøy (ksendfax) -Name[nso]=Sebereka sago Faxa seo se Beetswegopele (kromelafax) -Name[pa]=ਤਕਨੀਕੀ ਫੈਕਸ ਸੰਦ (ksendfax) -Name[pl]=Zaawansowane faksowanie (ksendfax) -Name[pt]=Ferramenta Avançada de Fax (ksendfax) -Name[pt_BR]=Ferramenta Avançada de Fax (ksendfax) -Name[ro]=Utilitar de FAX avansat (ksendfax) -Name[ru]=Утилита отправки факÑов (ksendfax) -Name[rw]=Igikoresho cyo Kohereza fagisi Gihanitse (kkoherezafagisi) -Name[se]=Nana buorre fáksareaidu (ksendfax) -Name[sk]=PokroÄilý nástroj pre faxy (ksendfax) -Name[sl]=Napredno orodje za faksiranje (ksendfax) -Name[sq]=Vegël e Avancuar Për Dërgesa me Faks (ksendfax) -Name[sr]=Ðапредни алат за Ñлање факÑова (ksendfax) -Name[sr@Latn]=Napredni alat za slanje faksova (ksendfax) -Name[ss]=Lithulusi lekufexa lelisembili (ksendfax) -Name[sv]=Avancerat faxverktyg (Ksendfax) -Name[ta]=மேமà¯à®ªà®Ÿà¯à®Ÿ தொலைநகலிக௠கரà¯à®µà®¿ (ksendfax) -Name[te]=ఆధà±à°¨à°¿à°• ఫేకà±à°¸à± పనిమà±à°Ÿà±à°Ÿà± (కెసెండౠఫేకà±à°¸à±) -Name[tg]=ФакÑи ÐÑбоби Пешгард (k Ñ„Ð°ÐºÑ Ñ„Ð¸Ñ€Ð¸Ñтодан) -Name[th]=เครื่องมือขั้นสูงในà¸à¸²à¸£à¸ªà¹ˆà¸‡à¹‚ทรสาร (ksendfax) -Name[tr]=GeliÅŸmiÅŸ Faks Aracı (ksendfax) -Name[tt]=Faks Cibärü Qoralı (ksendfax) -Name[uk]=Потужний заÑіб відÑÐ¸Ð»Ð°Ð½Ð½Ñ Ñ„Ð°ÐºÑів (ksendfax) -Name[uz]=Faks joÊ»natish uchun kengaytirilgan vosita (ksendfax) -Name[uz@cyrillic]=Ð¤Ð°ÐºÑ Ð¶ÑžÐ½Ð°Ñ‚Ð¸Ñˆ учун кенгайтирилган воÑита (ksendfax) -Name[ven]=Tshishumiswa tsha fekisi ya khwinesa (ksendfax) -Name[vi]=Công cụ Fax Cấp cao (ksendfax) -Name[xh]=Isixhobo se Fax Esibhekisa phambili (ksendfax) -Name[zh_CN]=高级传真工具(ksendfax) -Name[zh_HK]=進階傳真工具 (ksendfax) -Name[zh_TW]=高階傳真工具 (ksendfax) -Name[zu]=Ithuluz Lezinga eliphezulu lokuthumela i-fax (ksendfax) -Require=exec:/ksendfax diff --git a/kdeprint/testprint.ps b/kdeprint/testprint.ps deleted file mode 100644 index bcebfcb21..000000000 --- a/kdeprint/testprint.ps +++ /dev/null @@ -1,522 +0,0 @@ -%!PS-Adobe-3.0 -%%BoundingBox: 0 0 612 792 -%%Pages: 1 -%%LanguageLevel: 1 -%%DocumentData: Clean7Bit -%%DocumentSuppliedResources: procset testprint/1.0 -%%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman -%%Creator: Michael Sweet, Easy Software Products -%%CreationDate: May 11, 1999 -%%Title: Test Page -%%EndComments -%%BeginProlog -%%BeginResource procset testprint 1.1 0 -% -% PostScript test page for the Common UNIX Printing System ("CUPS"). -% -% Copyright 1993-2001 Easy Software Products -% -% These coded instructions, statements, and computer programs are the -% property of Easy Software Products and are protected by Federal -% copyright law. Distribution and use rights are outlined in the file -% "LICENSE.txt" which should have been included with this file. If this -% file is missing or damaged please contact Easy Software Products -% at: -% -% Attn: CUPS Licensing Information -% Easy Software Products -% 44141 Airport View Drive, Suite 204 -% Hollywood, Maryland 20636-3111 USA -% -% Voice: (301) 373-9603 -% EMail: cups-info@cups.org -% WWW: http://www.cups.org -% -/OCTANT { % Draw a color wheel OCTANT... - % (name) radius r g b OCTANT - - % Loop through 100 shades... - 0 0.010101 0.98 { - % Set the color... - 3 index 1 eq % R == 1? - 3 index 1 eq % G == 1? - 3 index 1 eq % B == 1? - and and { - 0 index 4 index mul % R * val - 1 index 4 index mul % G * val - 2 index 4 index mul % B * val - } { - 0 index 4 index mul % R * val - 1 index neg 1 add add % + (1 - val) - 1 index 4 index mul % G * val - 2 index neg 1 add add % + (1 - val) - 2 index 4 index mul % B * val - 3 index neg 1 add add % + (1 - val) - } ifelse - setrgbcolor - - % Draw a polygon... - dup 5 index mul dup 0 % x1, y1 - moveto - 0.707106781 mul dup lineto % x2, y2 - - 0.010101 add 4 index mul dup % x3 - 0.707106781 mul dup lineto % x3, y3 - 0 lineto % x4, y4 - closepath - fill - } for - - % Draw a line around the polygons... - pop pop pop dup - 0 setgray - 0 0 moveto - dup 0 lineto - 0.707106781 mul dup lineto - closepath - stroke - - % Draw the label... - 0 exch dup -9 div exch % text offset = 0, -radius/9 - dup 0.923879532 mul % x = radius * cos(22.5) - exch 0.382683432 mul % y = radius * cos(22.5) - moveto % position label - gsave - 22.5 rotate % rotate label - rmoveto % offset label - show % show label - grestore -} bind def -/CENTER { % Draw centered text - % (name) CENTER - - dup stringwidth pop % Get the width of the string - 0.5 mul neg 0 rmoveto % Shift left 1/2 of the distance - show % Show the string -} bind def -/RIGHT { % Draw right-justified text - % (name) RIGHT - - dup stringwidth pop % Get the width of the string - neg 0 rmoveto % Shift left the entire distance - show % Show the string -} bind def -/NUMBER { % Draw a number - % power n NUMBER - - 1 index 1 eq { % power == 1? - round cvi exch pop % Convert "n" to integer - } { - 1 index mul round exch div % Truncate extra decimal places - } ifelse - 100 string cvs show % Convert to a string and show it... -} bind def -/CUPSLOGO { % Draw the CUPS logo - % height CUPSLOGO - % Start with a big C... - /Helvetica findfont 1 index scalefont setfont - 0 setgray - 0 0 moveto - (C) show - - % Then "UNIX Printing System" much smaller... - /Helvetica-Bold findfont 1 index 9 div scalefont setfont - 0.25 mul - dup dup 2.0 mul moveto - (UNIX) show - dup dup 1.6 mul moveto - (Printing) show - dup 1.2 mul moveto - (System) show -} bind def -/ESPLOGO { % Draw the ESP logo - % height ESPLOGO - % Compute the size of the logo... - 0 0 - 2 index 1.5 mul 3 index - - % Do the "metallic" fill from 10% black to 40% black... - 1 -0.001 0 { - dup % loopval - -0.15 mul % loopval * -0.15 - 0.9 add % 0.9 - loopval * 0.15 - setgray % set gray shade - - 0 % x - 1 index neg % loopval - 1 add % 1 - loopval - 3 index % height - mul % height * (1 - loopval) - moveto % starting point - - dup % loopval - 3 index % width - mul % loopval * width - 2 index % height - lineto % Next point - - 0 % x - 2 index % height - lineto % Next point - - closepath - fill - - dup % loopval - 0.15 mul % loopval * 0.15 - 0.6 add % 0.6 + loopval * 0.15 - setgray - - dup % loopval - neg 1 add % 1 - loopval - 3 index % width - mul % (1 - loopval) * width - 0 % y - moveto % Starting point - - 2 index % width - exch % loopval - 2 index % height - mul % loopval * height - lineto % Next point - - 1 index % width - 0 % y - lineto % Next point - - closepath - fill - } for - - 0 setgray rectstroke - - /Helvetica-BoldOblique findfont 1 index 3 div scalefont setfont - dup 40 div - - dup 4 mul 1 index 25 mul moveto (E) show - dup 10 mul 1 index 15 mul moveto (S) show - dup 16 mul 1 index 5 mul moveto (P) show - - /Helvetica-BoldOblique findfont 2 index 5 div scalefont setfont - dup 14 mul 1 index 29 mul moveto (asy) show - dup 20 mul 1 index 19 mul moveto (oftware) show - dup 26 mul 1 index 9 mul moveto (roducts) show - - pop -} bind def -%%EndResource -%%EndProlog -%%Page: 1 1 -gsave - - % Determine the imageable area and device resolution... - initclip newpath clippath pathbbox % Get bounding rectangle - 72 div /pageTop exch def % Get top margin in inches - 72 div /pageRight exch def % Get right margin in inches - 72 div /pageBottom exch def % Get bottom margin in inches - 72 div /pageLeft exch def % Get left margin in inches - - 4 setlinewidth % Draw wide lines - 0 setgray closepath stroke % Draw a clipping rectangle - 1 setlinewidth % Draw normal lines - - /pageWidth pageRight pageLeft sub def % pageWidth = pageRight - pageLeft - /pageHeight pageTop pageBottom sub def% pageHeight = pageTop - pageBottom - - 72 72 dtransform % Get device resolution per inch - /yResolution exch abs def % yResolution = abs(yres) - /xResolution exch abs def % xResolution = abs(xres) - - % Figure out the sizes of things... - /wheelSize % size of wheels - pageWidth pageHeight lt - { pageWidth 9 mul } - { pageHeight 7 mul } - ifelse def - - % Create fonts... - /bigFont /Helvetica-Bold findfont % bigFont = Helvetica-Bold - pageHeight 3 mul scalefont def % size = pageHeight * 3 (nominally 33) - - /mediumFont /Helvetica findfont % mediumFont = Helvetica - pageHeight 1.5 mul scalefont def % size = pageHeight * 1.5 (nominally 16.5) - - /smallFont /Times-Roman findfont % smallFont = Times-Roman - pageHeight scalefont def % size = pageHeight (nominally 11) - - % Offset page to account for lower-left margin... - pageLeft 72 mul - pageBottom 72 mul - translate - - % Draw the color wheel... - mediumFont setfont % Font - 0 setgray % Color - - gsave - % Position the wheel on the left side... - pageWidth 18 mul % x = pageWidth * 1/4 * 72 - pageHeight 54 mul % y = pageHeight * 3/4 * 72 - translate - - % Size the wheel... - wheelSize - - % Draw the colors... - dup (C) exch 0 1 1 OCTANT 45 rotate - dup (M) exch 1 0 1 OCTANT 45 rotate - dup (Y) exch 1 1 0 OCTANT 45 rotate - dup (K) exch 0 0 0 OCTANT 45 rotate - dup (R) exch 1 0 0 OCTANT 45 rotate - dup (G) exch 0 1 0 OCTANT 45 rotate - dup (B) exch 0 0 1 OCTANT 45 rotate - (W) exch 1 1 1 OCTANT 45 rotate - grestore - - % Label the color wheel... - pageWidth 18 mul % x = pageWidth * 1/4 * 72 - pageHeight 44 mul % y = pageHeight * 19/32 * 72 - moveto % Position the text - (Color Wheel) CENTER % Show the text centered - - % Draw radial lines... - gsave - 0 setlinewidth % 1 pixel lines - - % Position the lines on the left side... - pageWidth 54 mul % x = pageWidth * 3/4 * 72 - pageHeight 54 mul % y = pageHeight * 3/4 * 72 - translate - - % Size the wheel... - wheelSize - - % Loop at 1 degree increments - 0 1 359 { - pop % Discard angle - not used - 0 0 moveto % Start line at the center - dup 0 lineto % Draw to the radius - 1 rotate % Rotate 1 degree - } for - - pop % Discard radius - not needed anymore - stroke % Draw lines... - - grestore - - % Label the lines... - pageWidth 54 mul % x = pageWidth * 3/4 * 72 - pageHeight 44 mul % y = pageHeight * 19/32 * 72 - moveto % Position the text - (1 Degree Radial Lines) CENTER % Show the text centered - - % Imageable area... - pageHeight 15 mul % Height of imageable area - - pageWidth 4.5 mul % x = pageWidth * 1/16 * 72 - pageHeight 35.5 mul % y = pageHeight * 1/2 * 72 - 2 index sub % y -= height - pageWidth 28 mul % width = pageWidth * 1/4 * 72 - 3 index % height - 0.5 setgray rectfill % Draw a shadow - - pageWidth 4 mul % x = pageWidth * 1/16 * 72 - pageHeight 36 mul % y = pageHeight * 1/2 * 72 - 2 index sub % y -= height - pageWidth 28 mul % width = pageWidth * 3/8 * 72 - 3 index % height - 4 copy 1 setgray rectfill % Clear the box to white - 0 setgray rectstroke % Draw a black box around it... - - pop % Discard height - - % Label the imageable area... - pageWidth 4 mul % x = pageWidth * 1/16 * 72 - pageHeight 37 mul % y = pageHeight * 1/2 * 72 - moveto % Position the text - mediumFont setfont % Font - (Imageable Area) show % Show the text - - smallFont setfont % Font - pageWidth 14 mul % x = pageWidth * 3/16 * 72 - pageHeight 36 mul % y = pageWidth * 1/2 * 72 - pageHeight -2 mul add % y -= 2 * smallFont height - - % Page Size inches - 2 copy moveto % Move to x & y - (Page Size: ) RIGHT % Label - 100 pageWidth NUMBER % pageWidth - (x) show % "x" - 100 pageHeight NUMBER % pageHeight - (in) show % "in" - - % Page Size millimeters - pageHeight sub % Move down... - - 2 copy moveto % Move to x & y - 10 pageWidth 25.4 mul NUMBER % pageWidth - (x) show % "x" - 10 pageHeight 25.4 mul NUMBER % pageHeight - (mm) show % "mm" - - % Lower-left inches - pageHeight 2 mul sub % Move down... - - 2 copy moveto % Move to x & y - (Lower-Left: ) RIGHT % Label - 100 pageLeft NUMBER % pageLeft - (x) show % "x" - 100 pageBottom NUMBER % pageBottom - (in) show % "in" - - % Lower-left millimeters - pageHeight sub % Move down... - - 2 copy moveto % Move to x & y - 10 pageLeft 25.4 mul NUMBER % pageLeft - (x) show % "x" - 10 pageBottom 25.4 mul NUMBER % pageBottom - (mm) show % "mm" - - % Upper-right inches - pageHeight 2 mul sub % Move down... - - 2 copy moveto % Move to x & y - (Upper-Right: ) RIGHT % Label - 100 pageRight NUMBER % pageRight - (x) show % "x" - 100 pageTop NUMBER % pageTop - (in) show % "in" - - % Upper-right millimeters - pageHeight sub % Move down... - - 2 copy moveto % Move to x & y - 10 pageRight 25.4 mul NUMBER % pageRight - (x) show % "x" - 10 pageTop 25.4 mul NUMBER % pageTop - (mm) show % "mm" - - % Resolution dots-per-inch - pageHeight 2 mul sub % Move down... - - 2 copy moveto % Move to x & y - (Resolution: ) RIGHT % Label - 1 xResolution NUMBER % xResolution - (x) show % "x" - 1 yResolution NUMBER % yResolution - (dpi) show % "dpi" - - % Resolution dots-per-meter - pageHeight sub % Move down... - - moveto % Move to x & y - 1 xResolution 39.27 mul NUMBER % xResolution - (x) show % "x" - 1 yResolution 39.27 mul NUMBER % yResolution - (dpm) show % "dpm" - - % Interpreter Information... - pageHeight 15 mul % Height of interpreter information - - pageWidth 40.5 mul % x = pageWidth * 9/16 * 72 - pageHeight 35.5 mul % y = pageHeight * 1/2 * 72 - 2 index sub % y -= height - pageWidth 28 mul % width = pageWidth * 1/4 * 72 - 3 index % height - 0.5 setgray rectfill % Draw a shadow - - pageWidth 40 mul % x = pageWidth * 9/16 * 72 - pageHeight 36 mul % y = pageHeight * 1/2 * 72 - 2 index sub % y -= height - pageWidth 28 mul % width = pageWidth * 3/8 * 72 - 3 index % height - 4 copy 1 setgray rectfill % Clear the box to white - 0 setgray rectstroke % Draw a black box around it... - - pop % Discard height - - % Label the interpreter info... - pageWidth 40 mul % x = pageWidth * 9/16 * 72 - pageHeight 37 mul % y = pageHeight * 1/2 * 72 - moveto % Position the text - mediumFont setfont % Font - (Interpreter Information) show % Show the text - - smallFont setfont % Font - pageWidth 49 mul % x = pageWidth * 11/16 * 72 - pageHeight 36 mul % y = pageWidth * 1/2 * 72 - pageHeight 2 mul sub % y -= 2 * smallFont height - - % Language level - 2 copy moveto % Move to x & y - (PostScript: ) RIGHT % Label - (Level ) show % "Level " - 1 languagelevel NUMBER % Language level - - % Version - pageHeight 2 mul sub % Move down... - 2 copy moveto % Move to x & y - (Version: ) RIGHT % Label - version show % Version - ( \() show % " (" - 1 revision NUMBER % Revision - (\)) show % ")" - - % Product - pageHeight 2 mul sub % Move down... - 2 copy moveto % Move to x & y - (Product: ) RIGHT % Label - product show % Product name - - % Serial Number - pageHeight 2 mul sub % Move down... - 2 copy moveto % Move to x & y - (Serial #: ) RIGHT % Label - 1 serialnumber NUMBER % S/N - - % Draw the label at the top... - pageWidth 36 mul % Center of page - pageHeight 68 mul % Top of page (15/16ths) - 2 copy moveto % Position text - bigFont setfont % Font - (Printer Test Page) CENTER % Show text centered - - % Draw the copyright notice at the bottom... - pageWidth 36 mul % Center of page - pageHeight 10 mul % Bottom of page - 2 copy moveto % Position text - (Printed Using CUPS v1.1.x) CENTER % Show text centered - - pageHeight 2 mul sub % Move down... - 2 copy moveto % Position text - smallFont setfont % Font - (Copyright 1993-2001 Easy Software Products, All Rights Reserved.) CENTER - pageHeight sub % Move down... - 2 copy moveto % Position text - (CUPS, and the CUPS logo are the trademark property of) CENTER - pageHeight sub % Move down... - 2 copy moveto % Position text - (Easy Software Products, 44141 Airport View Drive, Suite 204,) CENTER - pageHeight sub % Move down... - 2 copy moveto % Position text - (Hollywood, Maryland, 20636-3111, USA.) CENTER - - % Then the CUPS logo.... - gsave - pageWidth 4 mul - pageHeight 4 mul - translate - pageWidth 9 mul CUPSLOGO - grestore - - % And the ESP logo.... - gsave - pageWidth 59 mul - pageHeight 4 mul - translate - pageWidth 6 mul ESPLOGO - grestore -% Show the page... -grestore -showpage -% -% End of "$Id$". -% -%%EOF diff --git a/kdeprint/tests/Makefile.am b/kdeprint/tests/Makefile.am deleted file mode 100644 index 53021a6e2..000000000 --- a/kdeprint/tests/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -INCLUDES = -I$(top_srcdir)/tdeprint -I$(top_srcdir) $(all_includes) - -check_PROGRAMS = helpviewer drawdemo - -helpviewer_SOURCES = helpwindow.cpp main.cpp richpage.cpp -helpviewer_METASOURCES = helpwindow.moc -helpviewer_LDADD = $(top_builddir)/tdeprint/libtdeprint.la -helpviewer_LDFLAGS = $(all_libraries) - -drawdemo_SOURCES = drawdemo.cpp -drawdemo_METASOURCES = drawdemo.moc -drawdemo_LDADD = $(top_builddir)/tdeprint/libtdeprint.la -drawdemo_LDFLAGS = $(all_libraries) - -EXTRA_DIST = home.xpm back.xpm forward.xpm diff --git a/kdeprint/tests/back.xpm b/kdeprint/tests/back.xpm deleted file mode 100644 index ac57ecd0b..000000000 --- a/kdeprint/tests/back.xpm +++ /dev/null @@ -1,105 +0,0 @@ -/* XPM */ -static char * back_xpm[] = { -"16 16 86 1", -" c None", -". c #3269D2", -"+ c #326CD7", -"@ c #3472E5", -"# c #5183E0", -"$ c #5B88DC", -"% c #3472E4", -"& c #326BD4", -"* c #3368CA", -"= c #326AD3", -"- c #4980E6", -"; c #A8C2F5", -"> c #E4EBF8", -", c #F2F5FB", -"' c #EBF0FA", -") c #B9CCF0", -"! c #5789E4", -"~ c #3269CE", -"{ c #326AD2", -"] c #6494EC", -"^ c #D4E0F4", -"/ c #E1E9F8", -"( c #ABC1EC", -"_ c #DCE6F6", -": c #799FE5", -"< c #3269CF", -"[ c #C4D4F1", -"} c #CDDAF4", -"| c #FFFFFF", -"1 c #CBD9F3", -"2 c #5A8AE3", -"3 c #3467C4", -"4 c #90B1EC", -"5 c #B8CCEE", -"6 c #EDF2FA", -"7 c #B7CAEE", -"8 c #97B3E4", -"9 c #3873E0", -"0 c #A1BAE9", -"a c #A3BCEA", -"b c #E7EEF9", -"c c #95B1E6", -"d c #4987F8", -"e c #3B80FF", -"f c #3471E3", -"g c #4A7FE2", -"h c #8CACE5", -"i c #CEDFFF", -"j c #3676EB", -"k c #447CE5", -"l c #6E99E8", -"m c #B9CEF4", -"n c #3C81FF", -"o c #3776EB", -"p c #3C66B6", -"q c #3572E4", -"r c #4686FC", -"s c #D0E0FE", -"t c #9DC0FF", -"u c #6DA1FF", -"v c #4083FF", -"w c #4887FC", -"x c #4888FC", -"y c #D1E1FE", -"z c #6CA0FF", -"A c #4083FE", -"B c #4486FC", -"C c #4687FC", -"D c #4A80E4", -"E c #6696EE", -"F c #D8E4FA", -"G c #3766BE", -"H c #346ACC", -"I c #6C94E0", -"J c #7EA3E6", -"K c #DEE7F8", -"L c #3469CB", -"M c #356ACC", -"N c #658EDB", -"O c #8DACE7", -"P c #8EADE8", -"Q c #3569CA", -"R c #3E71CF", -"S c #5E88D5", -"T c #6E95DC", -"U c #3E70CF", -" ", -" .+@#$%&* ", -" =-;>,,')!~ ", -" {]^//((//_:~ ", -" <-[}}(||(}}123 ", -" &455(||655578= ", -" 90a(||baaacdef ", -" gh(||||||||iej ", -" klm|||||||||nop", -" qrrs||ittttuv% ", -" &wxxy||znABCw= ", -" *DEEEF||EEEEDG ", -" HIJJJKKJJJIL ", -" MNOPPPPONQ ", -" 3RSTTSUG ", -" p "}; diff --git a/kdeprint/tests/drawdemo.cpp b/kdeprint/tests/drawdemo.cpp deleted file mode 100644 index 20fc3d12e..000000000 --- a/kdeprint/tests/drawdemo.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** $Id$ -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of an example program for Qt. This example -** program may be used, distributed and modified without limitation. -** -*****************************************************************************/ - -#include <tqwidget.h> -#include <tqpainter.h> -#include <kprinter.h> -#include <tqpushbutton.h> -#include <tqradiobutton.h> -#include <tqbuttongroup.h> -#include <kapplication.h> -#include <tqapplication.h> -#include <math.h> - - -// -// This function draws a color wheel. -// The coordinate system x=(0..500), y=(0..500) spans the paint device. -// - -void drawColorWheel( TQPainter *p ) -{ - TQFont f( "times", 18, TQFont::Bold ); - p->setFont( f ); - p->setPen( Qt::black ); - p->setWindow( 0, 0, 500, 500 ); // defines coordinate system - - for ( int i=0; i<36; i++ ) { // draws 36 rotated rectangles - - TQWMatrix matrix; - matrix.translate( 250.0F, 250.0F ); // move to center - matrix.shear( 0.0F, 0.3F ); // twist it - matrix.rotate( (float)i*10 ); // rotate 0,10,20,.. degrees - p->setWorldMatrix( matrix ); // use this world matrix - - TQColor c; - c.setHsv( i*10, 255, 255 ); // rainbow effect - p->setBrush( c ); // solid fill with color c - p->drawRect( 70, -10, 80, 10 ); // draw the rectangle - - TQString n; - n.sprintf( "H=%d", i*10 ); - p->drawText( 80+70+5, 0, n ); // draw the hue number - } -} - - -// -// This function draws a few lines of text using different fonts. -// - -void drawFonts( TQPainter *p ) -{ - static const char *fonts[] = { "Helvetica", "Courier", "Times", 0 }; - static int sizes[] = { 10, 12, 18, 24, 36, 0 }; - int f = 0; - int y = 0; - while ( fonts[f] ) { - int s = 0; - while ( sizes[s] ) { - TQFont font( fonts[f], sizes[s] ); - p->setFont( font ); - TQFontMetrics fm = p->fontMetrics(); - y += fm.ascent(); - p->drawText( 10, y, "Quartz Glyph Job Vex'd Cwm Finks" ); - y += fm.descent(); - s++; - } - f++; - } -} - - -// -// This function draws some tqshapes -// - -void drawShapes( TQPainter *p ) -{ - TQBrush b1( Qt::blue ); - TQBrush b2( Qt::green, Qt::Dense6Pattern ); // green 12% fill - TQBrush b3( Qt::NoBrush ); // void brush - TQBrush b4( Qt::CrossPattern ); // black cross pattern - - p->setPen( Qt::red ); - p->setBrush( b1 ); - p->drawRect( 10, 10, 200, 100 ); - p->setBrush( b2 ); - p->drawRoundRect( 10, 150, 200, 100, 20, 20 ); - p->setBrush( b3 ); - p->drawEllipse( 250, 10, 200, 100 ); - p->setBrush( b4 ); - p->drawPie( 250, 150, 200, 100, 45*16, 90*16 ); -} - - -typedef void (*draw_func)(TQPainter*); - -struct DrawThing { - draw_func f; - const char *name; -}; - -// -// You can add your draw function here. -// Leave the zeros at the end of the array! -// - -DrawThing ourDrawFunctions[] = { - { drawColorWheel, "Draw color wheel" }, - { drawFonts, "Draw fonts" }, - { drawShapes, "Draw tqshapes" }, - { 0, 0 } }; - - -#include "drawdemo.h" - -// -// Construct the DrawView with buttons. -// - -DrawView::DrawView() -{ - setCaption( "Qt Draw Demo Application" ); - setBackgroundColor( white ); - - // Create a button group to contain all buttons - bgroup = new TQButtonGroup( this ); - bgroup->resize( 200, 200 ); - connect( bgroup, TQT_SIGNAL(clicked(int)), TQT_SLOT(updateIt(int)) ); - - // Calculate the size for the radio buttons - int maxwidth = 80; - int i; - const char *n; - TQFontMetrics fm = bgroup->fontMetrics(); - for ( i=0; (n=ourDrawFunctions[i].name) != 0; i++ ) { - int w = fm.width( n ); - maxwidth = QMAX(w,maxwidth); - } - maxwidth = maxwidth + 20; // add 20 pixels - - for ( i=0; (n=ourDrawFunctions[i].name) != 0; i++ ) { - TQRadioButton *rb = new TQRadioButton( n, bgroup ); - rb->setGeometry( 10, i*30+10, maxwidth, 30 ); - if ( i == 0 ) - rb->setChecked( true ); - } - - drawindex = 0; // draw first thing - maxindex = i; - - maxwidth += 40; // now size of bgroup - - printer = new KPrinter; - - // Create and setup the print button - print = new TQPushButton( "Print...", bgroup ); - print->resize( 80, 30 ); - print->move( maxwidth/2 - print->width()/2, maxindex*30+20 ); - connect( print, TQT_SIGNAL(clicked()), TQT_SLOT(printIt()) ); - - bgroup->resize( maxwidth, print->y()+print->height()+10 ); - - resize( 640,300 ); -} - -// -// Clean up -// -DrawView::~DrawView() -{ -#ifndef QT_NO_PRINTER - delete printer; -#endif -} - -// -// Called when a radio button is clicked. -// - -void DrawView::updateIt( int index ) -{ - if ( index < maxindex ) { - drawindex = index; - update(); - } -} - -// -// Calls the drawing function as specified by the radio buttons. -// - -void DrawView::drawIt( TQPainter *p ) -{ - (*ourDrawFunctions[drawindex].f)(p); -} - -// -// Called when the print button is clicked. -// - -void DrawView::printIt() -{ -#ifndef QT_NO_PRINTER - if ( printer->setup( this ) ) { - TQPainter paint( printer ); - drawIt( &paint ); - } -#endif -} - -// -// Called when the widget needs to be updated. -// - -void DrawView::paintEvent( TQPaintEvent * ) -{ - TQPainter paint( this ); - drawIt( &paint ); -} - -// -// Called when the widget has been resized. -// Moves the button group to the upper right corner -// of the widget. - -void DrawView::resizeEvent( TQResizeEvent * ) -{ - bgroup->move( width()-bgroup->width(), 0 ); -} - - -// -// Create and display our widget. -// - -#include "drawdemo.moc" - -int main( int argc, char **argv ) -{ - KApplication app( argc, argv, "drawdemo" ); - DrawView draw; - app.setMainWidget( &draw ); - draw.show(); - return app.exec(); -} diff --git a/kdeprint/tests/drawdemo.h b/kdeprint/tests/drawdemo.h deleted file mode 100644 index 963da64db..000000000 --- a/kdeprint/tests/drawdemo.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DRAWDEMO_H -#define DRAWDEMO_H - -// -// DrawView has installable draw routines, just add a function pointer -// and a text in the table above. -// - -class DrawView : public TQWidget -{ - Q_OBJECT -public: - DrawView(); - ~DrawView(); -public slots: - void updateIt( int ); - void printIt(); -protected: - void drawIt( TQPainter * ); - void paintEvent( TQPaintEvent * ); - void resizeEvent( TQResizeEvent * ); -private: - KPrinter *printer; - TQButtonGroup *bgroup; - QPushButton *print; - int drawindex; - int maxindex; -}; - -#endif diff --git a/kdeprint/tests/forward.xpm b/kdeprint/tests/forward.xpm deleted file mode 100644 index 7eadb1474..000000000 --- a/kdeprint/tests/forward.xpm +++ /dev/null @@ -1,110 +0,0 @@ -/* XPM */ -static char * forward_xpm[] = { -"16 16 91 1", -" c None", -". c #3269D2", -"+ c #326CD7", -"@ c #3472E5", -"# c #5183E0", -"$ c #5B88DC", -"% c #3472E4", -"& c #326BD4", -"* c #3368CA", -"= c #326AD3", -"- c #4980E6", -"; c #A8C2F5", -"> c #E4EBF8", -", c #F2F5FB", -"' c #EBF0FA", -") c #B9CCF0", -"! c #5789E4", -"~ c #3269CE", -"{ c #326AD2", -"] c #6494EC", -"^ c #D4E0F4", -"/ c #E1E9F8", -"( c #AAC4F4", -"_ c #DCE6F6", -": c #799FE5", -"< c #3269CF", -"[ c #C4D4F1", -"} c #CDDAF4", -"| c #FFFFFF", -"1 c #A5C1F4", -"2 c #CBD9F3", -"3 c #5A8AE3", -"4 c #3467C4", -"5 c #90B1EC", -"6 c #B8CCEE", -"7 c #ECF1FA", -"8 c #A0BDF2", -"9 c #B7CAEE", -"0 c #97B3E4", -"a c #3873E0", -"b c #A1BAE9", -"c c #94B2EB", -"d c #85A9EC", -"e c #D8E4FA", -"f c #95B4EF", -"g c #4987F8", -"h c #3B80FF", -"i c #3471E3", -"j c #4A7FE2", -"k c #8CACE5", -"l c #6CA0FF", -"m c #3676EB", -"n c #447CE5", -"o c #6E99E8", -"p c #9EC0FF", -"q c #3C81FF", -"r c #3776EB", -"s c #3C66B6", -"t c #3572E4", -"u c #4686FC", -"v c #73A4FD", -"w c #A0C2FE", -"x c #A0C2FF", -"y c #CEE0FF", -"z c #3D82FF", -"A c #4083FF", -"B c #4887FC", -"C c #4888FC", -"D c #4084FF", -"E c #6DA0FF", -"F c #D2E2FE", -"G c #4486FC", -"H c #4687FC", -"I c #4A80E4", -"J c #6696EE", -"K c #DAE6FA", -"L c #3766BE", -"M c #346ACC", -"N c #6C94E0", -"O c #7EA3E6", -"P c #E0E9F9", -"Q c #3469CB", -"R c #356ACC", -"S c #658EDB", -"T c #8DACE7", -"U c #8EADE8", -"V c #3569CA", -"W c #3E71CF", -"X c #5E88D5", -"Y c #6E95DC", -"Z c #3E70CF", -" ", -" .+@#$%&* ", -" =-;>,,')!~ ", -" {]^//((//_:~ ", -" <-[}}}||1}}234 ", -" &566667||8690= ", -" abcdddde||fghi ", -" jke||||||||lhm ", -" no|||||||||pqrs", -" tuvwxxpy||yzA% ", -" &BCCCDE||FGHB= ", -" *IJJJJ||KJJJIL ", -" MNOOOPPOOONQ ", -" RSTUUUUTSV ", -" 4WXYYXZL ", -" s "}; diff --git a/kdeprint/tests/helpwindow.cpp b/kdeprint/tests/helpwindow.cpp deleted file mode 100644 index bee755d20..000000000 --- a/kdeprint/tests/helpwindow.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/**************************************************************************** -** $Id$ -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of an example program for Qt. This example -** program may be used, distributed and modified without limitation. -** -*****************************************************************************/ - -#include "helpwindow.h" -#include "richpage.h" -#include <tqstatusbar.h> -#include <tqpixmap.h> -#include <tqpopupmenu.h> -#include <kmenubar.h> -#include <ktoolbar.h> -#include <kstatusbar.h> -#include <tqtoolbutton.h> -#include <tqiconset.h> -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqstylesheet.h> -#include <tqmessagebox.h> -#include <tqfiledialog.h> -#include <tqapplication.h> -#include <tqcombobox.h> -#include <tqevent.h> -#include <tqlineedit.h> -#include <tqobjectlist.h> -#include <tqfileinfo.h> -#include <tqdatastream.h> -#include <kprinter.h> -#include <tqsimplerichtext.h> -#include <tqpainter.h> -#include <tqpaintdevicemetrics.h> - -#include <ctype.h> - -HelpWindow::HelpWindow( const TQString& home_, const TQString& _path, - TQWidget* parent, const char *name ) - : KMainWindow( parent, name, WDestructiveClose ), - pathCombo( 0 ), selectedURL() -{ - readHistory(); - readBookmarks(); - - browser = new TQTextBrowser( this ); - browser->mimeSourceFactory()->setFilePath( _path ); - browser->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); - connect( browser, TQT_SIGNAL( textChanged() ), - this, TQT_SLOT( textChanged() ) ); - - setCentralWidget( browser ); - - if ( !home_.isEmpty() ) - browser->setSource( home_ ); - - connect( browser, TQT_SIGNAL( highlighted( const TQString&) ), - statusBar(), TQT_SLOT( message( const TQString&)) ); - - resize( 640,700 ); - - TQPopupMenu* file = new TQPopupMenu( this ); - file->insertItem( "&New Window", this, TQT_SLOT( newWindow() ), ALT | Key_N ); - file->insertItem( "&Open File", this, TQT_SLOT( openFile() ), ALT | Key_O ); - file->insertItem( "&Print", this, TQT_SLOT( print() ), ALT | Key_P ); - file->insertSeparator(); - file->insertItem( "&Close", this, TQT_SLOT( close() ), ALT | Key_Q ); - file->insertItem( "E&xit", tqApp, TQT_SLOT( closeAllWindows() ), ALT | Key_X ); - - // The same three icons are used twice each. - TQIconSet icon_back( TQPixmap("back.xpm") ); - TQIconSet icon_forward( TQPixmap("forward.xpm") ); - TQIconSet icon_home( TQPixmap("home.xpm") ); - - TQPopupMenu* go = new TQPopupMenu( this ); - backwardId = go->insertItem( icon_back, - "&Backward", browser, TQT_SLOT( backward() ), - ALT | Key_Left ); - forwardId = go->insertItem( icon_forward, - "&Forward", browser, TQT_SLOT( forward() ), - ALT | Key_Right ); - go->insertItem( icon_home, "&Home", browser, TQT_SLOT( home() ) ); - - TQPopupMenu* help = new TQPopupMenu( this ); - help->insertItem( "&About ...", this, TQT_SLOT( about() ) ); - help->insertItem( "About &Qt ...", this, TQT_SLOT( aboutQt() ) ); - - hist = new TQPopupMenu( this ); - TQStringList::Iterator it = history.begin(); - for ( ; it != history.end(); ++it ) - mHistory[ hist->insertItem( *it ) ] = *it; - connect( hist, TQT_SIGNAL( activated( int ) ), - this, TQT_SLOT( histChosen( int ) ) ); - - bookm = new TQPopupMenu( this ); - bookm->insertItem( tr( "Add Bookmark" ), this, TQT_SLOT( addBookmark() ) ); - bookm->insertSeparator(); - - TQStringList::Iterator it2 = bookmarks.begin(); - for ( ; it2 != bookmarks.end(); ++it2 ) - mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; - connect( bookm, TQT_SIGNAL( activated( int ) ), - this, TQT_SLOT( bookmChosen( int ) ) ); - - menuBar()->insertItem( tr("&File"), file ); - menuBar()->insertItem( tr("&Go"), go ); - menuBar()->insertItem( tr( "History" ), hist ); - menuBar()->insertItem( tr( "Bookmarks" ), bookm ); - menuBar()->insertSeparator(); - menuBar()->insertItem( tr("&Help"), help ); - - menuBar()->setItemEnabled( forwardId, false); - menuBar()->setItemEnabled( backwardId, false); - connect( browser, TQT_SIGNAL( backwardAvailable( bool ) ), - this, TQT_SLOT( setBackwardAvailable( bool ) ) ); - connect( browser, TQT_SIGNAL( forwardAvailable( bool ) ), - this, TQT_SLOT( setForwardAvailable( bool ) ) ); - - - TQToolBar* toolbar = new TQToolBar( this ); - addToolBar( toolbar, "Toolbar"); - TQToolButton* button; - - button = new TQToolButton( icon_back, tr("Backward"), "", browser, TQT_SLOT(backward()), toolbar ); - connect( browser, TQT_SIGNAL( backwardAvailable(bool) ), button, TQT_SLOT( setEnabled(bool) ) ); - button->setEnabled( false ); - button = new TQToolButton( icon_forward, tr("Forward"), "", browser, TQT_SLOT(forward()), toolbar ); - connect( browser, TQT_SIGNAL( forwardAvailable(bool) ), button, TQT_SLOT( setEnabled(bool) ) ); - button->setEnabled( false ); - button = new TQToolButton( icon_home, tr("Home"), "", browser, TQT_SLOT(home()), toolbar ); - - toolbar->addSeparator(); - - pathCombo = new TQComboBox( true, toolbar ); - connect( pathCombo, TQT_SIGNAL( activated( const TQString & ) ), - this, TQT_SLOT( pathSelected( const TQString & ) ) ); - toolbar->setStretchableWidget( pathCombo ); - setRightJustification( true ); - setDockEnabled( DockLeft, false ); - setDockEnabled( DockRight, false ); - - pathCombo->insertItem( home_ ); - - browser->setFocus(); -} - - -void HelpWindow::setBackwardAvailable( bool b) -{ - menuBar()->setItemEnabled( backwardId, b); -} - -void HelpWindow::setForwardAvailable( bool b) -{ - menuBar()->setItemEnabled( forwardId, b); -} - - -void HelpWindow::textChanged() -{ - if ( browser->documentTitle().isNull() ) - setCaption( browser->context() ); - else - setCaption( browser->documentTitle() ) ; - - selectedURL = caption(); - if ( !selectedURL.isEmpty() && pathCombo ) { - bool exists = false; - int i; - for ( i = 0; i < pathCombo->count(); ++i ) { - if ( pathCombo->text( i ) == selectedURL ) { - exists = true; - break; - } - } - if ( !exists ) { - pathCombo->insertItem( selectedURL, 0 ); - pathCombo->setCurrentItem( 0 ); - mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; - } else - pathCombo->setCurrentItem( i ); - selectedURL = TQString::null; - } -} - -HelpWindow::~HelpWindow() -{ - history.clear(); - TQMap<int, TQString>::Iterator it = mHistory.begin(); - for ( ; it != mHistory.end(); ++it ) - history.append( *it ); - - TQFile f( TQDir::currentDirPath() + "/.history" ); - f.open( IO_WriteOnly ); - TQDataStream s( &f ); - s << history; - f.close(); - - bookmarks.clear(); - TQMap<int, TQString>::Iterator it2 = mBookmarks.begin(); - for ( ; it2 != mBookmarks.end(); ++it2 ) - bookmarks.append( *it2 ); - - TQFile f2( TQDir::currentDirPath() + "/.bookmarks" ); - f2.open( IO_WriteOnly ); - TQDataStream s2( &f2 ); - s2 << bookmarks; - f2.close(); -} - -void HelpWindow::about() -{ - TQMessageBox::about( this, "HelpViewer Example", - "<p>This example implements a simple HTML help viewer " - "using Qt's rich text capabilities</p>" - "<p>It's just about 100 lines of C++ code, so don't expect too much :-)</p>" - ); -} - - -void HelpWindow::aboutQt() -{ - TQMessageBox::aboutQt( this, "QBrowser" ); -} - -void HelpWindow::openFile() -{ -#ifndef QT_NO_FILEDIALOG - TQString fn = TQFileDialog::getOpenFileName( TQString::null, TQString::null, this ); - if ( !fn.isEmpty() ) - browser->setSource( fn ); -#endif -} - -void HelpWindow::newWindow() -{ - ( new HelpWindow(browser->source(), "qbrowser") )->show(); -} - -#define KDE_PRINT -void HelpWindow::print() -{ -#ifdef KDE_PRINT - KPrinter printer; -#else - TQPrinter printer; -#endif - printer.setFullPage(true); - printer.setDocName("Help Viewer"); - printer.setDocFileName("my_document"); -#ifdef KDE_PRINT - printer.addDialogPage(new RichPage()); - printer.addStandardPage(KPrinter::FilesPage); -#endif - if ( printer.setup(this) ) { - TQPainter p( &printer ); - TQPaintDeviceMetrics metrics(p.device()); - int dpix = metrics.logicalDpiX(); - int dpiy = metrics.logicalDpiY(); -#ifdef KDE_PRINT - const int margin = printer.option("app-rich-margin").toInt(); // pt -#else - const int margin = 72; // pt -#endif - TQRect body(margin*dpix/72, margin*dpiy/72, - metrics.width()-margin*dpix/72*2, - metrics.height()-margin*dpiy/72*2 ); -#ifdef KDE_PRINT - TQFont font(printer.option("app-rich-fontname"), printer.option("app-rich-fontsize").toInt()); -#else - TQFont font("times",10); -#endif - TQSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(), - browser->mimeSourceFactory(), body.height() ); - richText.setWidth( &p, body.width() ); - TQRect view( body ); - int page = 1; - do { - richText.draw( &p, body.left(), body.top(), view, tqcolorGroup() ); - view.moveBy( 0, body.height() ); - p.translate( 0 , -body.height() ); - p.setFont( font ); - p.drawText( view.right() - p.fontMetrics().width( TQString::number(page) ), - view.bottom() + p.fontMetrics().ascent() + 5, TQString::number(page) ); - if ( view.top() >= richText.height() ) - break; - printer.newPage(); - page++; - } while (true); - } -} - -void HelpWindow::pathSelected( const TQString &_path ) -{ - browser->setSource( _path ); - TQMap<int, TQString>::Iterator it = mHistory.begin(); - bool exists = false; - for ( ; it != mHistory.end(); ++it ) { - if ( *it == _path ) { - exists = true; - break; - } - } - if ( !exists ) - mHistory[ hist->insertItem( _path ) ] = _path; -} - -void HelpWindow::readHistory() -{ - if ( TQFile::exists( TQDir::currentDirPath() + "/.history" ) ) { - TQFile f( TQDir::currentDirPath() + "/.history" ); - f.open( IO_ReadOnly ); - TQDataStream s( &f ); - s >> history; - f.close(); - while ( history.count() > 20 ) - history.remove( history.begin() ); - } -} - -void HelpWindow::readBookmarks() -{ - if ( TQFile::exists( TQDir::currentDirPath() + "/.bookmarks" ) ) { - TQFile f( TQDir::currentDirPath() + "/.bookmarks" ); - f.open( IO_ReadOnly ); - TQDataStream s( &f ); - s >> bookmarks; - f.close(); - } -} - -void HelpWindow::histChosen( int i ) -{ - if ( mHistory.contains( i ) ) - browser->setSource( mHistory[ i ] ); -} - -void HelpWindow::bookmChosen( int i ) -{ - if ( mBookmarks.contains( i ) ) - browser->setSource( mBookmarks[ i ] ); -} - -void HelpWindow::addBookmark() -{ - mBookmarks[ bookm->insertItem( caption() ) ] = caption(); -} - -#include "helpwindow.moc" diff --git a/kdeprint/tests/helpwindow.h b/kdeprint/tests/helpwindow.h deleted file mode 100644 index c444b8144..000000000 --- a/kdeprint/tests/helpwindow.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** $Id$ -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of an example program for Qt. This example -** program may be used, distributed and modified without limitation. -** -*****************************************************************************/ - -#ifndef HELPWINDOW_H -#define HELPWINDOW_H - -#include <kmainwindow.h> -#include <tqtextbrowser.h> -#include <tqstringlist.h> -#include <tqmap.h> -#include <tqdir.h> - -class TQComboBox; -class TQPopupMenu; - -class HelpWindow : public KMainWindow -{ - Q_OBJECT -public: - HelpWindow( const TQString& home_, const TQString& path, TQWidget* parent = 0, const char *name=0 ); - ~HelpWindow(); - -private slots: - void setBackwardAvailable( bool ); - void setForwardAvailable( bool ); - - void textChanged(); - void about(); - void aboutQt(); - void openFile(); - void newWindow(); - void print(); - - void pathSelected( const TQString & ); - void histChosen( int ); - void bookmChosen( int ); - void addBookmark(); - -private: - void readHistory(); - void readBookmarks(); - - TQTextBrowser* browser; - TQComboBox *pathCombo; - int backwardId, forwardId; - TQString selectedURL; - TQStringList history, bookmarks; - TQMap<int, TQString> mHistory, mBookmarks; - TQPopupMenu *hist, *bookm; - -}; - - - - - -#endif - diff --git a/kdeprint/tests/home.xpm b/kdeprint/tests/home.xpm deleted file mode 100644 index 1cb22447f..000000000 --- a/kdeprint/tests/home.xpm +++ /dev/null @@ -1,119 +0,0 @@ -/* XPM */ -static char * home_xpm[] = { -"16 16 100 2", -" c None", -". c #3269D2", -"+ c #326CD7", -"@ c #3472E5", -"# c #5183E0", -"$ c #5B88DC", -"% c #3472E4", -"& c #326BD4", -"* c #3368CA", -"= c #326AD3", -"- c #4980E6", -"; c #A8C2F5", -"> c #E4EBF8", -", c #F2F5FB", -"' c #EBF0FA", -") c #B9CCF0", -"! c #5789E4", -"~ c #3269CE", -"{ c #326AD2", -"] c #6494EC", -"^ c #D4E0F4", -"/ c #E1E9F8", -"( c #A3BCEA", -"_ c #DCE6F6", -": c #799FE5", -"< c #3269CF", -"[ c #C4D4F1", -"} c #CDDAF4", -"| c #FDFDFE", -"1 c #DDE6F7", -"2 c #CBD9F3", -"3 c #5A8AE3", -"4 c #3467C4", -"5 c #90B1EC", -"6 c #B8CCEE", -"7 c #D5E1F5", -"8 c #FFFFFF", -"9 c #FBFCFE", -"0 c #CEDCF3", -"a c #B7CAEE", -"b c #97B3E4", -"c c #3873E0", -"d c #A1BAE9", -"e c #C9D8F2", -"f c #FCFDFE", -"g c #B5C8ED", -"h c #4987F8", -"i c #3B80FF", -"j c #3471E3", -"k c #4A7FE2", -"l c #8CACE5", -"m c #8FADE6", -"n c #BFD0F0", -"o c #FAFCFE", -"p c #79A9FF", -"q c #3676EB", -"r c #447CE5", -"s c #6E99E8", -"t c #9BB8EF", -"u c #F5F9FF", -"v c #6098FF", -"w c #3776EB", -"x c #3C66B6", -"y c #3572E4", -"z c #4686FC", -"A c #4E8BFC", -"B c #5D95FC", -"C c #C2D7FE", -"D c #9DC0FF", -"E c #AAC8FF", -"F c #5591FF", -"G c #4586FF", -"H c #4887FC", -"I c #4888FC", -"J c #BAD2FD", -"K c #3C81FF", -"L c #A1C2FD", -"M c #4687FC", -"N c #4A80E4", -"O c #6696EE", -"P c #C6D7F8", -"Q c #B2CAF6", -"R c #3766BE", -"S c #346ACC", -"T c #6C94E0", -"U c #7EA3E6", -"V c #B0C7EF", -"W c #CEDCF5", -"X c #C0D2F2", -"Y c #A6BFED", -"Z c #3469CB", -"` c #356ACC", -" . c #658EDB", -".. c #8DACE7", -"+. c #8EADE8", -"@. c #3569CA", -"#. c #3E71CF", -"$. c #5E88D5", -"%. c #6E95DC", -"&. c #3E70CF", -" ", -" . + @ # $ % & * ", -" = - ; > , , ' ) ! ~ ", -" { ] ^ / / ( ( ( / _ : ~ ", -" < - [ } } ( / | 1 ( } 2 3 4 ", -" & 5 6 6 ( 7 | 8 9 0 ( a b = ", -" c d ( ( e | 8 8 8 f g h i j ", -" k l m n 8 8 8 8 8 8 o p i q ", -" r s t f 8 8 8 8 8 8 8 u v w x ", -" y z A B C 8 8 D D 8 E F G % ", -" & H I I J 8 8 K K 8 L M H = ", -" * N O O P 8 8 O O 8 Q O N R ", -" S T U V W X U U W Y T Z ", -" ` ...+.+.+.+... .@. ", -" 4 #.$.%.%.$.&.R ", -" x "}; diff --git a/kdeprint/tests/main.cpp b/kdeprint/tests/main.cpp deleted file mode 100644 index a1dc6b5e0..000000000 --- a/kdeprint/tests/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** $Id$ -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of an example program for Qt. This example -** program may be used, distributed and modified without limitation. -** -*****************************************************************************/ - -#include "helpwindow.h" -#include <kapplication.h> -#include <tqwindowsstyle.h> -#include <tqstylesheet.h> -#include <stdlib.h> - - -int main( int argc, char ** argv ) -{ - KApplication a(argc, argv, "helpviewer"); - - TQString home; - if (argc > 1) - home = argv[1]; - else - home = TQString(getenv("QTDIR")) + "/doc/html/index.html"; - - - HelpWindow *help = new HelpWindow(home, ".", 0, "help viewer"); - - if ( TQApplication::desktop()->width() > 400 - && TQApplication::desktop()->height() > 500 ) - help->show(); - else - help->showMaximized(); - - TQObject::connect( &a, TQT_SIGNAL(lastWindowClosed()), - &a, TQT_SLOT(quit()) ); - - return a.exec(); -} diff --git a/kdeprint/tests/richpage.cpp b/kdeprint/tests/richpage.cpp deleted file mode 100644 index 30da712de..000000000 --- a/kdeprint/tests/richpage.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "richpage.h" - -#include <tqlabel.h> -#include <tqspinbox.h> -#include <tqcombobox.h> -#include <tqfontdatabase.h> -#include <tqlayout.h> - -RichPage::RichPage(TQWidget *parent, const char *name) -: KPrintDialogPage(parent,name) -{ - m_title = "Rich Text Options"; - - margin_ = new TQSpinBox(this); - margin_->setRange(1,999); - margin_->setValue(72); - - fontsize_ = new TQSpinBox(this); - fontsize_->setRange(4,100); - fontsize_->setValue(10); - - fontname_ = new TQComboBox(this); - QFontDatabase db; - QStringList fonts = db.families(); - fontname_->insertStringList(fonts); - fontname_->setCurrentItem(fonts.findIndex(TQString::tqfromLatin1("times"))); - if (fontname_->currentItem() < 0) fontname_->setCurrentItem(0); - - QLabel *l1 = new TQLabel("Margin:",this); - QLabel *l2 = new TQLabel("Font name:",this); - QLabel *l3 = new TQLabel("Font size:",this); - - QHBoxLayout *s1 = new TQHBoxLayout(0, 0, 10); - QHBoxLayout *s2 = new TQHBoxLayout(0, 0, 10); - QVBoxLayout *main_ = new TQVBoxLayout(this, 10, 10); - - main_->addLayout(s1,0); - main_->addSpacing(20); - main_->addLayout(s2,0); - main_->addStretch(1); - - s1->addWidget(l1,0); - s1->addWidget(margin_,0); - s1->addStretch(1); - - s2->addWidget(l2,0); - s2->addWidget(fontname_,0); - s2->addSpacing(20); - s2->addWidget(l3,0); - s2->addWidget(fontsize_,0); - s2->addStretch(1); -} - -RichPage::~RichPage() -{ -} - -void RichPage::setOptions(const TQMap<TQString,TQString>& opts) -{ - QString value; - - value = opts["app-rich-margin"]; - if (!value.isEmpty()) - margin_->setValue(value.toInt()); - - value = opts["app-rich-fontname"]; - if (!value.isEmpty()) - for (int i=0;i<fontname_->count();i++) - if (fontname_->text(i) == value) - { - fontname_->setCurrentItem(i); - break; - } - - value = opts["app-rich-fontsize"]; - if (!value.isEmpty()) - fontsize_->setValue(value.toInt()); -} - -void RichPage::getOptions(TQMap<TQString,TQString>& opts, bool) -{ - opts["app-rich-margin"] = margin_->text(); - opts["app-rich-fontname"] = fontname_->currentText(); - opts["app-rich-fontsize"] = fontsize_->text(); -} diff --git a/kdeprint/tests/richpage.h b/kdeprint/tests/richpage.h deleted file mode 100644 index 33e4304e7..000000000 --- a/kdeprint/tests/richpage.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RICHPAGE_H -#define RICHPAGE_H - -#include <kprintdialogpage.h> - -class TQSpinBox; -class TQComboBox; - -class RichPage : public KPrintDialogPage -{ -public: - RichPage(TQWidget *parent = 0, const char *name = 0); - ~RichPage(); - - void setOptions(const TQMap<TQString,TQString>& opts); - void getOptions(TQMap<TQString,TQString>& opts, bool incldef = false); - -private: - QSpinBox *margin_; - QComboBox *fontname_; - QSpinBox *fontsize_; -}; - -#endif diff --git a/kdeprint/tools/CMakeLists.txt b/kdeprint/tools/CMakeLists.txt deleted file mode 100644 index 4c2682eee..000000000 --- a/kdeprint/tools/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_subdirectory( escputil ) diff --git a/kdeprint/tools/Makefile.am b/kdeprint/tools/Makefile.am deleted file mode 100644 index d2ca2be71..000000000 --- a/kdeprint/tools/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = escputil diff --git a/kdeprint/tools/escputil/CMakeLists.txt b/kdeprint/tools/escputil/CMakeLists.txt deleted file mode 100644 index 3494d3cfb..000000000 --- a/kdeprint/tools/escputil/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES escputil.desktop DESTINATION ${DATA_INSTALL_DIR}/tdeprint/tools ) - - -##### tdeprint_tool_escputil #################### - -set( target tdeprint_tool_escputil ) - -set( ${target}_SRCS - escpwidget.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeui-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) diff --git a/kdeprint/tools/escputil/Makefile.am b/kdeprint/tools/escputil/Makefile.am deleted file mode 100644 index ac7620ef1..000000000 --- a/kdeprint/tools/escputil/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -INCLUDES = $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_tool_escputil.la -tdeprint_tool_escputil_la_SOURCES = escpwidget.cpp -tdeprint_tool_escputil_la_METASOURCES = AUTO -tdeprint_tool_escputil_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_tool_escputil_la_LIBADD = $(LIB_KDEUI) $(LIB_QT) $(LIB_KDECORE) - -noinst_HEADERS = escpwidget.h - -service_DATA = escputil.desktop -servicedir = $(kde_datadir)/tdeprint/tools diff --git a/kdeprint/tools/escputil/escputil.desktop b/kdeprint/tools/escputil/escputil.desktop deleted file mode 100644 index 40a5c88f3..000000000 --- a/kdeprint/tools/escputil/escputil.desktop +++ /dev/null @@ -1,29 +0,0 @@ -[Desktop Entry] -Name=EPSON InkJet -Name[af]=Epson Inkstraal -Name[bg]=МаÑтиленоÑтруен принтер EPSON InkJet -Name[bn]=à¦à¦ªà¦¸à¦¨ ইঙà§à¦•à¦œà§‡à¦Ÿ -Name[de]=Epson InkJet -Name[eo]=Epson-Inkĵet-ilo -Name[fa]=چاپگر جوهراÙشان EPSON -Name[fr]=Imprimante jet d'encre Epson -Name[ga]=Scairdphrintéir EPSON -Name[hi]=à¤à¤ªà¥à¤¸à¤¨ इंकजेट -Name[is]=EPSON bleksprautuprentari -Name[ja]=EPSON インクジェット -Name[ko]=ì—¡ì† ìž‰í¬ì ¯ -Name[mn]=Epson InkJet -Name[ms]=InkJet EPSON -Name[nb]=EPSON-blekkskriver -Name[nds]=EPSON Inkjet -Name[ne]=EPSON इनà¥à¤•à¤œà¥‡à¤Ÿ -Name[nn]=EPSON-blekkskrivar -Name[nso]=InkJetEPSON -Name[pt]=Jacto de Tinta da EPSON -Name[ta]=EPSON இஙà¯à®•à¯à®œà¯†à®Ÿà¯ -Name[te]=à°Žà°ªà±à°¸à°¨à± ఇంకౠజెటౠ-Name[zh_HK]=EPSON 噴墨å°è¡¨æ©Ÿ -Name[zh_TW]=EPSON 噴墨å°è¡¨æ©Ÿ -Type=Service - -X-KDE-Library=escputil diff --git a/kdeprint/tools/escputil/escpwidget.cpp b/kdeprint/tools/escputil/escpwidget.cpp deleted file mode 100644 index 3000b0788..000000000 --- a/kdeprint/tools/escputil/escpwidget.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "escpwidget.h" - -#include <tqpushbutton.h> -#include <tqlayout.h> -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqaccel.h> -#include <kdemacros.h> -#include <klocale.h> -#include <kmessagebox.h> -#include <kstandarddirs.h> -#include <kiconloader.h> -#include <kdialogbase.h> -#include <klibloader.h> -#include <kseparator.h> -#include <kdebug.h> - -class EscpFactory : public KLibFactory -{ -public: - EscpFactory(TQObject *parent = 0, const char *name = 0) : KLibFactory(parent, name) {} -protected: - TQObject* createObject(TQObject *parent = 0, const char *name = 0, const char * className = TQOBJECT_OBJECT_NAME_STRING, const TQStringList& args = TQStringList()) - { - Q_UNUSED(className); - KDialogBase *dlg = new KDialogBase(TQT_TQWIDGET(parent), name, true, i18n("EPSON InkJet Printer Utilities"), KDialogBase::Close); - EscpWidget *w = new EscpWidget(dlg); - if (args.count() > 0) - w->setDevice(args[0]); - if (args.count() > 1) - w->setPrinterName(args[1]); - dlg->setMainWidget(w); - return TQT_TQOBJECT(dlg); - } -}; - -extern "C" -{ - void* init_tdeprint_tool_escputil() KDE_EXPORT; - void* init_tdeprint_tool_escputil() - { - return new EscpFactory; - } -} - -EscpWidget::EscpWidget(TQWidget *parent, const char *name) -: TQWidget(parent, name) -{ - m_hasoutput = false; - - connect(&m_proc, TQT_SIGNAL(processExited(KProcess*)), TQT_SLOT(slotProcessExited(KProcess*))); - connect(&m_proc, TQT_SIGNAL(receivedStdout(KProcess*,char*,int)), TQT_SLOT(slotReceivedStdout(KProcess*,char*,int))); - connect(&m_proc, TQT_SIGNAL(receivedStderr(KProcess*,char*,int)), TQT_SLOT(slotReceivedStderr(KProcess*,char*,int))); - - TQPushButton *cleanbtn = new TQPushButton(this, "-c"); - cleanbtn->setPixmap(DesktopIcon("exec")); - TQPushButton *nozzlebtn = new TQPushButton(this, "-n"); - nozzlebtn->setPixmap(DesktopIcon("exec")); - TQPushButton *alignbtn = new TQPushButton(this, "-a"); - alignbtn->setPixmap(DesktopIcon("exec")); - TQPushButton *inkbtn = new TQPushButton(this, "-i"); - inkbtn->setPixmap(DesktopIcon("tdeprint_inklevel")); - TQPushButton *identbtn = new TQPushButton(this, "-d"); - identbtn->setPixmap(DesktopIcon("exec")); - - TQFont f(font()); - f.setBold(true); - m_printer = new TQLabel(this); - m_printer->setFont(f); - m_device = new TQLabel(this); - m_device->setFont(f); - m_useraw = new TQCheckBox(i18n("&Use direct connection (might need root permissions)"), this); - - connect(cleanbtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotButtonClicked())); - connect(nozzlebtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotButtonClicked())); - connect(alignbtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotButtonClicked())); - connect(inkbtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotButtonClicked())); - connect(identbtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotButtonClicked())); - - TQLabel *printerlab = new TQLabel(i18n("Printer:"), this); - printerlab->tqsetAlignment(AlignRight|AlignVCenter); - TQLabel *devicelab = new TQLabel(i18n("Device:"), this); - devicelab->tqsetAlignment(AlignRight|AlignVCenter); - TQLabel *cleanlab = new TQLabel(i18n("Clea&n print head"), this); - TQLabel *nozzlelab = new TQLabel(i18n("&Print a nozzle test pattern"), this); - TQLabel *alignlab = new TQLabel(i18n("&Align print head"), this); - TQLabel *inklab = new TQLabel(i18n("&Ink level"), this); - TQLabel *identlab = new TQLabel(i18n("P&rinter identification"), this); - - cleanlab->tqsetAlignment(AlignLeft|AlignVCenter|ShowPrefix); - nozzlelab->tqsetAlignment(AlignLeft|AlignVCenter|ShowPrefix); - alignlab->tqsetAlignment(AlignLeft|AlignVCenter|ShowPrefix); - inklab->tqsetAlignment(AlignLeft|AlignVCenter|ShowPrefix); - identlab->tqsetAlignment(AlignLeft|AlignVCenter|ShowPrefix); - - cleanbtn->setAccel(TQAccel::shortcutKey(cleanlab->text())); - nozzlebtn->setAccel(TQAccel::shortcutKey(nozzlelab->text())); - alignbtn->setAccel(TQAccel::shortcutKey(alignlab->text())); - inkbtn->setAccel(TQAccel::shortcutKey(inklab->text())); - identbtn->setAccel(TQAccel::shortcutKey(identlab->text())); - - KSeparator *sep = new KSeparator(this); - sep->setFixedHeight(10); - - TQGridLayout *l0 = new TQGridLayout(this, 8, 2, 10, 10); - TQGridLayout *l1 = new TQGridLayout(0, 2, 2, 0, 5); - l0->addMultiCellLayout(l1, 0, 0, 0, 1); - l1->addWidget(printerlab, 0, 0); - l1->addWidget(devicelab, 1, 0); - l1->addWidget(m_printer, 0, 1); - l1->addWidget(m_device, 1, 1); - l1->setColStretch(1, 1); - l0->addMultiCellWidget(sep, 1, 1, 0, 1); - l0->addWidget(cleanbtn, 2, 0); - l0->addWidget(nozzlebtn, 3, 0); - l0->addWidget(alignbtn, 4, 0); - l0->addWidget(inkbtn, 5, 0); - l0->addWidget(identbtn, 6, 0); - l0->addWidget(cleanlab, 2, 1); - l0->addWidget(nozzlelab, 3, 1); - l0->addWidget(alignlab, 4, 1); - l0->addWidget(inklab, 5, 1); - l0->addWidget(identlab, 6, 1); - l0->addMultiCellWidget(m_useraw, 7, 7, 0, 1); - l0->setColStretch(1, 1); -} - -void EscpWidget::startCommand(const TQString& arg) -{ - bool useUSB(false); - - if (m_deviceURL.isEmpty()) - { - KMessageBox::error(this, i18n("Internal error: no device set.")); - return; - } - else - { - TQString protocol = m_deviceURL.protocol(); - if (protocol == "usb") - useUSB = true; - else if (protocol != "file" && protocol != "parallel" && protocol != "serial" && !protocol.isEmpty()) - { - KMessageBox::error(this, - i18n("Unsupported connection type: %1").arg(protocol)); - return; - } - } - - if (m_proc.isRunning()) - { - KMessageBox::error(this, i18n("An escputil process is still running. " - "You must wait until its completion before continuing.")); - return; - } - - TQString exestr = KStandardDirs::findExe("escputil"); - if (exestr.isEmpty()) - { - KMessageBox::error(this, i18n("The executable escputil cannot be found in your " - "PATH environment variable. Make sure gimp-print is " - "installed and that escputil is in your PATH.")); - return; - } - - m_proc.clearArguments(); - m_proc << exestr; - if (m_useraw->isChecked() || arg == "-i") - m_proc << "-r" << m_deviceURL.path(); - else - m_proc << "-P" << m_printer->text(); - if (useUSB) - m_proc << "-u"; - - m_proc << arg << "-q"; - m_errorbuffer = m_outbuffer = TQString::null; - m_hasoutput = ( arg == "-i" || arg == "-d" ); - for ( TQValueList<TQCString>::ConstIterator it=m_proc.args().begin(); it!=m_proc.args().end(); ++it ) - kdDebug() << "ARG: " << *it << endl; - if (m_proc.start(KProcess::NotifyOnExit, KProcess::AllOutput)) - setEnabled(false); - else - { - KMessageBox::error(this, - i18n("Internal error: unable to start escputil process.")); - return; - } -} - -void EscpWidget::slotProcessExited(KProcess*) -{ - setEnabled(true); - if (!m_proc.normalExit() || m_proc.exitStatus() != 0) - { - TQString msg1 = "<qt>"+i18n("Operation terminated with errors.")+"</qt>"; - TQString msg2; - if (!m_outbuffer.isEmpty()) - msg2 += "<p><b><u>"+i18n("Output")+"</u></b></p><p>"+m_outbuffer+"</p>"; - if (!m_errorbuffer.isEmpty()) - msg2 += "<p><b><u>"+i18n("Error")+"</u></b></p><p>"+m_errorbuffer+"</p>"; - if (!msg2.isEmpty()) - KMessageBox::detailedError(this, msg1, msg2); - else - KMessageBox::error(this, msg1); - } - else if ( !m_outbuffer.isEmpty() && m_hasoutput ) - { - KMessageBox::information( this, m_outbuffer ); - } - m_hasoutput = false; -} - -void EscpWidget::slotReceivedStdout(KProcess*, char *buf, int len) -{ - TQString bufstr = TQCString(buf, len); - m_outbuffer.append(bufstr); -} - -void EscpWidget::slotReceivedStderr(KProcess*, char *buf, int len) -{ - TQString bufstr = TQCString(buf, len); - m_errorbuffer.append(bufstr); -} - -void EscpWidget::slotButtonClicked() -{ - TQString arg = TQT_TQOBJECT_CONST(sender())->name(); - startCommand(arg); -} - -void EscpWidget::setPrinterName(const TQString& p) -{ - m_printer->setText(p); -} - -void EscpWidget::setDevice(const TQString& dev) -{ - m_deviceURL = dev; - m_device->setText(dev); -} - -#include "escpwidget.moc" diff --git a/kdeprint/tools/escputil/escpwidget.h b/kdeprint/tools/escputil/escpwidget.h deleted file mode 100644 index 7e3ba55e8..000000000 --- a/kdeprint/tools/escputil/escpwidget.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 ESCPWIDGET_H -#define ESCPWIDGET_H - -#include <tqwidget.h> -#include <kprocess.h> -#include <kurl.h> - -class TQLabel; -class TQCheckBox; - -class EscpWidget : public TQWidget -{ - Q_OBJECT - -public: - EscpWidget(TQWidget *parent = 0, const char *name = 0); - void setDevice(const TQString&); - void setPrinterName(const TQString&); - -protected slots: - void slotReceivedStdout(KProcess*, char*, int); - void slotReceivedStderr(KProcess*, char*, int); - void slotProcessExited(KProcess*); - void slotButtonClicked(); - -protected: - void startCommand(const TQString& arg); - -private: - KProcess m_proc; - KURL m_deviceURL; - TQString m_errorbuffer, m_outbuffer; - TQLabel *m_printer, *m_device; - TQCheckBox *m_useraw; - bool m_hasoutput; -}; - -#endif diff --git a/kdeprint/treecombobox.cpp b/kdeprint/treecombobox.cpp deleted file mode 100644 index 7a2adc8ef..000000000 --- a/kdeprint/treecombobox.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "treecombobox.h" - -#include <tqpainter.h> - -TreeListBoxItem::TreeListBoxItem(TQListBox *lb, const TQPixmap& pix, const TQString& txt, bool oneBlock) - : TQListBoxPixmap(pix, txt) -{ - if (oneBlock) - m_path = TQStringList(txt); - else - m_path = TQStringList::split('/', text(), false); - m_depth = m_path.count()-1; - m_child = m_next = m_parent = 0; - - // insert into QListBox - if (m_depth == 0) - { - TreeListBoxItem *item = static_cast<TreeListBoxItem*>(lb->item(0)); - while (item && item->m_next) - item = item->m_next; - lb->insertItem(this); - if (item) - item->m_next = this; - } - else - { - TQString parentStr = txt.left(txt.length()-m_path[m_depth].length()-1); - TreeListBoxItem *parentItem = static_cast<TreeListBoxItem*>(lb->findItem(parentStr, TQt::ExactMatch)); - if (!parentItem) - { - // parent not found, add parent first into QListBox - parentItem = new TreeListBoxItem(lb, TQPixmap(), parentStr); - } - // search last "child" of the parent item, to put the new one - // at the end - TreeListBoxItem *childItem = static_cast<TreeListBoxItem*>(parentItem), *prevItem = 0; - while (childItem->next()) - { - TreeListBoxItem *nextItem = static_cast<TreeListBoxItem*>(childItem->next()); - if (nextItem->m_depth >= m_depth) - { - childItem = nextItem; - if (childItem->m_depth == m_depth) - prevItem = childItem; - } - else - break; - } - // eventually insert item - lb->insertItem(this, childItem); - m_parent = parentItem; - if (prevItem) - prevItem->m_next = this; - else - parentItem->m_child = this; - } -} - -int TreeListBoxItem::width(const TQListBox *lb) const -{ - int w = m_depth * stepSize() + 2; - if (pixmap()) - w += (pixmap()->width() + 2); - if (!m_path[m_depth].isEmpty()) - w += (lb->fontMetrics().width(m_path[m_depth]) + 2); - return QMAX(w, TQListBoxPixmap::width(lb)); -} - -void TreeListBoxItem::paint(TQPainter *p) -{ - if(!static_cast<TreeListBox*>(listBox())->m_painting) - { - TQListBoxPixmap::paint(p); - return; - } - - const QPixmap *pix = pixmap(); - QRect r = p->viewport(); - int h = height(listBox()); - int xo = (m_depth * stepSize() + 2); - int yo = (pix ? (h-pix->height())/2 : 0); - - if (m_depth > 0) - { - QPen oldPen = p->pen(); - p->setPen(listBox()->tqcolorGroup().mid()); - - TreeListBoxItem *item = this; - int s = xo-stepSize()/2; - p->drawLine(s, r.top(), s, h/2); - p->drawLine(s, h/2, s+stepSize()/2-2, h/2); - while (item->m_parent) - { - if (item->m_next) - p->drawLine(s, r.top(), s, h); - item = item->m_parent; - s -= stepSize(); - } - - p->setPen(oldPen); - } - if (pix) - { - p->drawPixmap(xo, yo, *pix); - xo += (pix->width() + 2); - } - p->drawText(xo, 0, r.width()-xo, height(listBox()), Qt::AlignLeft, m_path[m_depth]); -} - -//----------------------------------------------------------------------------------------- - -TreeListBox::TreeListBox(TQWidget *parent, const char *name) - : TQListBox(parent, name) -{ - m_painting = false; -} - -void TreeListBox::paintCell(TQPainter *p, int row, int col) -{ - m_painting = true; - TQListBox::paintCell(p, row, col); - m_painting = false; -} - -//----------------------------------------------------------------------------------------- - -TreeComboBox::TreeComboBox(TQWidget *parent, const char *name) - : TQComboBox(parent, name) -{ - m_listbox = new TreeListBox(this); - setListBox(m_listbox); -} - -void TreeComboBox::insertItem(const TQPixmap& pix, const TQString& txt, bool oneBlock) -{ - new TreeListBoxItem(m_listbox, pix, txt, oneBlock); -} diff --git a/kdeprint/treecombobox.h b/kdeprint/treecombobox.h deleted file mode 100644 index 6026b99f1..000000000 --- a/kdeprint/treecombobox.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 TREECOMBOBOX_H -#define TREECOMBOBOX_H - -#include <tqlistbox.h> -#include <tqcombobox.h> -#include <tqstringlist.h> - -/** - * Class that represents a single object in the tree - */ -class TreeListBoxItem : public TQListBoxPixmap -{ -public: - TreeListBoxItem(TQListBox *lb, const TQPixmap& pix, const TQString& txt, bool oneBlock = false); - - virtual int width(const TQListBox *lb) const; - -protected: - virtual void paint(TQPainter *p); - int stepSize() const { return 16; } - -private: - TQStringList m_path; - int m_depth; - TreeListBoxItem *m_child, *m_next, *m_parent; -}; - -/** - * Class for the listbox shown on popup - */ -class TreeListBox : public TQListBox -{ - friend class TreeListBoxItem; -public: - TreeListBox(TQWidget *parent = 0, const char *name = 0); - -protected: - virtual void paintCell(TQPainter *p, int row, int col); - -private: - bool m_painting; -}; - -/** - * Main class. - */ -class TreeComboBox : public TQComboBox -{ -public: - TreeComboBox(TQWidget *parent = 0, const char *name = 0); - void insertItem(const TQPixmap& pix, const TQString& txt, bool oneBlock = false); - -private: - TQListBox *m_listbox; -}; - -#endif diff --git a/kdeprint/util.cpp b/kdeprint/util.cpp deleted file mode 100644 index b4025a087..000000000 --- a/kdeprint/util.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 "util.h" -#include <tqstringlist.h> - -void urlToSmb(const KURL& url, TQString& work, TQString& server, TQString& printer) -{ - if (url.protocol() != "smb") - return; - QString h = url.host(); - QStringList l = TQStringList::split('/', url.path(), false); - if (l.count() > 1) - { - work = h; - server = l[0]; - printer = l[1]; - } - else - { - work = TQString::null; - server = h; - printer = l[0]; - } -} - -KURL smbToUrl(const TQString& s) -{ - // allow to handle non-encoded chars in login/password - KURL url; - int p = s.find('@'); - if (p == -1) - { - // assumes url starts with "smb://". Use encoding in - // case the printer name contains chars like '#'. - url = KURL("smb://" + KURL::encode_string(s.mid(6))); - } - else - { - // assumes URL starts with "smb://" - TQString username = s.mid(6, p-6); - url = KURL("smb://" + KURL::encode_string(s.mid(p+1))); - int q = username.find(':'); - if (q == -1) - url.setUser(username); - else - { - url.setUser(username.left(q)); - url.setPass(username.mid(q+1)); - } - } - return url; -} - -int findIndex(int ID) -{ - for (int i=0; i<KPrinter::NPageSize-1; i++) - if (page_sizes[i].ID == ID) - return i; - return 4; -} - -TQString buildSmbURI( const TQString& work, const TQString& server, const TQString& printer, const TQString& user, const TQString& passwd ) -{ - TQString uri = server + "/" + printer; - if ( !work.isEmpty() ) - uri.prepend( work + "/" ); - if ( !user.isEmpty() ) - { - uri.prepend( "@" ); - if ( !passwd.isEmpty() ) - uri.prepend( ":" + passwd ); - uri.prepend( user ); - } - uri.prepend( "smb://" ); - return uri; -} - -bool splitSmbURI( const TQString& uri, TQString& work, TQString& server, TQString& printer, TQString& user, TQString& passwd ) -{ - int p( 0 ); - if ( !uri.startsWith( "smb://" ) ) - return false; - p = 6; - - int p1 = uri.find( '/', p ); - if ( p1 != -1 ) - { - int p2 = uri.find( '@', p ); - if ( p2 != -1 && p2 < p1 ) - { - // Got a user - int p3 = uri.find( ':', p ); - if ( p3 != -1 && p3 < p2 ) - { - // Got a password - user = uri.mid( p, p3-p ); - passwd = uri.mid( p3+1, p2-p3-1 ); - } - else - user = uri.mid( p, p2-p ); - } - else - p2 = p-1; - TQStringList l = TQStringList::split( '/', uri.mid( p2+1 ), false ); - switch ( l.count() ) - { - case 3: - work = l[ 0 ]; - server = l[ 1 ]; - printer = l[ 2 ]; - break; - case 2: - server = l[ 0 ]; - printer = l[ 1 ]; - break; - default: - return false; - } - return true; - } - return false; -} diff --git a/kdeprint/util.h b/kdeprint/util.h deleted file mode 100644 index db4ad1cd6..000000000 --- a/kdeprint/util.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> - * - * 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 UTIL_H -#define UTIL_H - -#include "kprinter.h" -#include <tqstring.h> -#include <kurl.h> -#include <klocale.h> - -KURL smbToUrl(const TQString& work, const TQString& server, const TQString& printer); -void urlToSmb(const KURL& url, TQString& work, TQString& server, TQString& printer); -// those 2 are only workarounds when the login/password may contain -// strange characters ('@', '/'). In this case, those chars are not encoded -// as other SMB tools (smbspool) doesn't seem to support encoding. This -// utilities allow to continue working KURL class (and encoding) within -// KDEPrint, but without encoding outside KDEPrint (shoudl fix bug #38733) -KDEPRINT_EXPORT TQString buildSmbURI( const TQString& work, const TQString& server, const TQString& printer, const TQString& user, const TQString& passwd ); -KDEPRINT_EXPORT bool splitSmbURI( const TQString& uri, TQString& work, TQString& server, TQString& printer, TQString& user, TQString& passwd ); - -static const struct pagesizestruct -{ - const char* text; - int ID; -} page_sizes[] = -{ - { "A0", KPrinter::A0 }, - { "A1", KPrinter::A1 }, - { "A2", KPrinter::A2 }, - { "A3", KPrinter::A3 }, - { "A4", KPrinter::A4 }, - { "A5", KPrinter::A5 }, - { "A6", KPrinter::A6 }, - { "A7", KPrinter::A7 }, - { "A8", KPrinter::A8 }, - { "A9", KPrinter::A9 }, - { "B1", KPrinter::B1 }, - { "B10", KPrinter::B10 }, - { "B2", KPrinter::B2 }, - { "B3", KPrinter::B3 }, - { "B4", KPrinter::B4 }, - { "B5", KPrinter::B5 }, - { "B6", KPrinter::B6 }, - { "B7", KPrinter::B7 }, - { "B8", KPrinter::B8 }, - { "B9", KPrinter::B9 }, - { I18N_NOOP("Envelope C5"), KPrinter::C5E }, - { I18N_NOOP("Envelope DL"), KPrinter::DLE }, - { I18N_NOOP("Envelope US #10"), KPrinter::Comm10E }, - { I18N_NOOP("Executive"), KPrinter::Executive }, - { I18N_NOOP("Folio"), KPrinter::Folio }, - { I18N_NOOP("Ledger"), KPrinter::Ledger }, - { I18N_NOOP("Tabloid"), KPrinter::Tabloid }, - { I18N_NOOP("US Legal"), KPrinter::Legal }, - { I18N_NOOP("US Letter"), KPrinter::Letter } -}; -int findIndex(int ID); - -#endif diff --git a/kdesu/CMakeLists.txt b/kdesu/CMakeLists.txt deleted file mode 100644 index 97ede6b97..000000000 --- a/kdesu/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - defaults.h client.h process.h tdesu_pty.h - kcookie.h su.h ssh.h stub.h - DESTINATION ${INCLUDE_INSTALL_DIR}/tdesu ) - - -##### libtdesu ################################## - -set( target tdesu ) - -set( ${target}_SRCS - client.cpp process.cpp kcookie.cpp - su.cpp ssh.cpp stub.cpp tdesu_pty.cpp -) - -tde_add_library( ${target} SHARED - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - LINK tdecore-shared ${LIB_UTIL} - DESTINATION ${LIB_INSTALL_DIR} -) - -tde_install_symlink( tdesu_pty.h ${INCLUDE_INSTALL_DIR}/tdesu/pty.h ) - - -##### tdesu_stub ################################ - -tde_add_executable( tdesu_stub - SOURCES tdesu_stub.c - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/kdesu/Mainpage.dox b/kdesu/Mainpage.dox deleted file mode 100644 index c39881397..000000000 --- a/kdesu/Mainpage.dox +++ /dev/null @@ -1,21 +0,0 @@ -/** @mainpage Console-mode authentication - -libtdesu provides functionality for building GUI front ends for -(password asking) console mode programs. For example, tdesu and -kdessh use it to interface with su and ssh respectively. - -@authors -Geert Jansen \<jansen@kde.org\> - -@maintainers -Adriaan de Groot \<groot@kde.org\> - -@licenses -@lgpl - - -*/ - -// DOXYGEN_REFERENCES = tdecore -// DOXYGEN_SET_PROJECT_NAME = Trinitysu -// vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/kdesu/Makefile.am b/kdesu/Makefile.am deleted file mode 100644 index 847a21ee1..000000000 --- a/kdesu/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -## Makefile.am for libtdesu - -INCLUDES = -I$(top_srcdir)/kio/ $(all_includes) - -lib_LTLIBRARIES = libtdesu.la -libtdesu_la_SOURCES = client.cpp process.cpp kcookie.cpp su.cpp ssh.cpp stub.cpp tdesu_pty.cpp -libtdesu_la_LDFLAGS = -version-info 6:0:2 -no-undefined $(all_libraries) -libtdesu_la_LIBADD = $(LIB_KDECORE) $(LIB_QT) $(top_builddir)/dcop/libDCOP.la -libtdesu_la_NMCHECK = $(srcdir)/libtdesu.nmcheck -libtdesu_la_NMCHECKWEAK = $(srcdir)/libtdesu_weak.nmcheck $(top_srcdir)/tdecore/libtdecore_weak.nmcheck \ - $(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/tdecore/libqt-mt_weak.nmcheck - -tdesudir = $(includedir)/tdesu -tdesu_HEADERS = defaults.h client.h process.h tdesu_pty.h kcookie.h su.h ssh.h stub.h - -install-data-hook: - $(mkinstalldirs) $(DESTDIR)$(tdesudir) - -rm -f $(DESTDIR)$(tdesudir)/pty.h - ln -s tdesu_pty.h $(DESTDIR)$(tdesudir)/pty.h - -uninstall-local: - -rm -f $(DESTDIR)$(tdesudir)/pty.h - -bin_PROGRAMS = tdesu_stub -tdesu_stub_SOURCES = tdesu_stub.c -tdesu_stub_LDFLAGS = $(all_libraries) -tdesu_stub_LDADD = - -include $(top_srcdir)/admin/Doxyfile.am - diff --git a/kdesu/README b/kdesu/README deleted file mode 100644 index c81f5c23b..000000000 --- a/kdesu/README +++ /dev/null @@ -1,13 +0,0 @@ -Maintainer: Adriaan de Groot <groot@kde.org> -Maintainer: tdesu was maintained by Alan Eldridge until his - death in 2003. - -README for libtdesu. - -Libtdesu provides functionality for building GUI front ends for -(password asking) console mode programs. For example, tdesu and -kdessh use it to interface with su and ssh respectively. - -libtdesu is Copyright (c) 1999,2000 Geert Jansen <jansen@kde.org> - -Distributed under the GNU Library General Public License, version 2. diff --git a/kdesu/client.cpp b/kdesu/client.cpp deleted file mode 100644 index 18accc313..000000000 --- a/kdesu/client.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * client.cpp: A client for tdesud. - */ - -#include <config.h> -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <pwd.h> -#include <errno.h> -#include <string.h> - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/stat.h> - -#include <tqglobal.h> -#include <tqcstring.h> -#include <tqfile.h> -#include <tqregexp.h> - -#include <kdebug.h> -#include <kstandarddirs.h> -#include <kapplication.h> -#include <kde_file.h> - -#include "client.h" - -class KDEsuClient::KDEsuClientPrivate { -public: - TQString daemon; -}; - -#ifndef SUN_LEN -#define SUN_LEN(ptr) ((socklen_t) (((struct sockaddr_un *) 0)->sun_path) \ - + strlen ((ptr)->sun_path)) -#endif - -KDEsuClient::KDEsuClient() -{ - sockfd = -1; -#ifdef Q_WS_X11 - TQCString display(getenv("DISPLAY")); - if (display.isEmpty()) - { - kdWarning(900) << k_lineinfo << "$DISPLAY is not set\n"; - return; - } - - // strip the screen number from the display - display.replace(TQRegExp("\\.[0-9]+$"), ""); -#else - TQCString display("QWS"); -#endif - - sock = TQFile::encodeName(locateLocal("socket", TQString("tdesud_%1").arg(display.data()))); - d = new KDEsuClientPrivate; - connect(); -} - - -KDEsuClient::~KDEsuClient() -{ - delete d; - if (sockfd >= 0) - close(sockfd); -} - -int KDEsuClient::connect() -{ - if (sockfd >= 0) - close(sockfd); - if (access(sock, R_OK|W_OK)) - { - sockfd = -1; - return -1; - } - - sockfd = socket(PF_UNIX, SOCK_STREAM, 0); - if (sockfd < 0) - { - kdWarning(900) << k_lineinfo << "socket(): " << perror << "\n"; - return -1; - } - struct sockaddr_un addr; - addr.sun_family = AF_UNIX; - strcpy(addr.sun_path, sock); - - if (::connect(sockfd, (struct sockaddr *) &addr, SUN_LEN(&addr)) < 0) - { - kdWarning(900) << k_lineinfo << "connect():" << perror << endl; - close(sockfd); sockfd = -1; - return -1; - } - -#if !defined(SO_PEERCRED) || !defined(HAVE_STRUCT_UCRED) -# if defined(HAVE_GETPEEREID) - uid_t euid; - gid_t egid; - // Security: if socket exists, we must own it - if (getpeereid(sockfd, &euid, &egid) == 0) - { - if (euid != getuid()) - { - kdWarning(900) << "socket not owned by me! socket uid = " << euid << endl; - close(sockfd); sockfd = -1; - return -1; - } - } -# else -# ifdef __GNUC__ -# warning "Using sloppy security checks" -# endif - // We check the owner of the socket after we have connected. - // If the socket was somehow not ours an attacker will be able - // to delete it after we connect but shouldn't be able to - // create a socket that is owned by us. - KDE_struct_stat s; - if (KDE_lstat(sock, &s)!=0) - { - kdWarning(900) << "stat failed (" << sock << ")" << endl; - close(sockfd); sockfd = -1; - return -1; - } - if (s.st_uid != getuid()) - { - kdWarning(900) << "socket not owned by me! socket uid = " << s.st_uid << endl; - close(sockfd); sockfd = -1; - return -1; - } - if (!S_ISSOCK(s.st_mode)) - { - kdWarning(900) << "socket is not a socket (" << sock << ")" << endl; - close(sockfd); sockfd = -1; - return -1; - } -# endif -#else - struct ucred cred; - socklen_t siz = sizeof(cred); - - // Security: if socket exists, we must own it - if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cred, &siz) == 0) - { - if (cred.uid != getuid()) - { - kdWarning(900) << "socket not owned by me! socket uid = " << cred.uid << endl; - close(sockfd); sockfd = -1; - return -1; - } - } -#endif - - return 0; -} - -TQCString KDEsuClient::escape(const TQCString &str) -{ - TQCString copy = str; - int n = 0; - while ((n = copy.find("\\", n)) != -1) - { - copy.insert(n, '\\'); - n += 2; - } - n = 0; - while ((n = copy.find("\"", n)) != -1) - { - copy.insert(n, '\\'); - n += 2; - } - copy.prepend("\""); - copy.append("\""); - return copy; -} - -int KDEsuClient::command(const TQCString &cmd, TQCString *result) -{ - if (sockfd < 0) - return -1; - - if (send(sockfd, cmd, cmd.length(), 0) != (int) cmd.length()) - return -1; - - char buf[1024]; - int nbytes = recv(sockfd, buf, 1023, 0); - if (nbytes <= 0) - { - kdWarning(900) << k_lineinfo << "no reply from daemon\n"; - return -1; - } - buf[nbytes] = '\000'; - - TQCString reply = buf; - if (reply.left(2) != "OK") - return -1; - - if (result) - *result = reply.mid(3, reply.length()-4); - return 0; -} - -int KDEsuClient::setPass(const char *pass, int timeout) -{ - TQCString cmd = "PASS "; - cmd += escape(pass); - cmd += " "; - cmd += TQCString().setNum(timeout); - cmd += "\n"; - return command(cmd); -} - -int KDEsuClient::exec(const TQCString &prog, const TQCString &user, const TQCString &options, const QCStringList &env) -{ - TQCString cmd; - cmd = "EXEC "; - cmd += escape(prog); - cmd += " "; - cmd += escape(user); - if (!options.isEmpty() || !env.isEmpty()) - { - cmd += " "; - cmd += escape(options); - for(QCStringList::ConstIterator it = env.begin(); - it != env.end(); ++it) - { - cmd += " "; - cmd += escape(*it); - } - } - cmd += "\n"; - return command(cmd); -} - -int KDEsuClient::setHost(const TQCString &host) -{ - TQCString cmd = "HOST "; - cmd += escape(host); - cmd += "\n"; - return command(cmd); -} - -int KDEsuClient::setPriority(int prio) -{ - TQCString cmd; - cmd.sprintf("PRIO %d\n", prio); - return command(cmd); -} - -int KDEsuClient::setScheduler(int sched) -{ - TQCString cmd; - cmd.sprintf("SCHD %d\n", sched); - return command(cmd); -} - -int KDEsuClient::delCommand(const TQCString &key, const TQCString &user) -{ - TQCString cmd = "DEL "; - cmd += escape(key); - cmd += " "; - cmd += escape(user); - cmd += "\n"; - return command(cmd); -} -int KDEsuClient::setVar(const TQCString &key, const TQCString &value, int timeout, - const TQCString &group) -{ - TQCString cmd = "SET "; - cmd += escape(key); - cmd += " "; - cmd += escape(value); - cmd += " "; - cmd += escape(group); - cmd += " "; - cmd += TQCString().setNum(timeout); - cmd += "\n"; - return command(cmd); -} - -TQCString KDEsuClient::getVar(const TQCString &key) -{ - TQCString cmd = "GET "; - cmd += escape(key); - cmd += "\n"; - TQCString reply; - command(cmd, &reply); - return reply; -} - -TQValueList<TQCString> KDEsuClient::getKeys(const TQCString &group) -{ - TQCString cmd = "GETK "; - cmd += escape(group); - cmd += "\n"; - TQCString reply; - command(cmd, &reply); - int index=0, pos; - TQValueList<TQCString> list; - if( !reply.isEmpty() ) - { - // kdDebug(900) << "Found a matching entry: " << reply << endl; - while (1) - { - pos = reply.find( '\007', index ); - if( pos == -1 ) - { - if( index == 0 ) - list.append( reply ); - else - list.append( reply.mid(index) ); - break; - } - else - { - list.append( reply.mid(index, pos-index) ); - } - index = pos+1; - } - } - return list; -} - -bool KDEsuClient::findGroup(const TQCString &group) -{ - TQCString cmd = "CHKG "; - cmd += escape(group); - cmd += "\n"; - if( command(cmd) == -1 ) - return false; - return true; -} - -int KDEsuClient::delVar(const TQCString &key) -{ - TQCString cmd = "DELV "; - cmd += escape(key); - cmd += "\n"; - return command(cmd); -} - -int KDEsuClient::delGroup(const TQCString &group) -{ - TQCString cmd = "DELG "; - cmd += escape(group); - cmd += "\n"; - return command(cmd); -} - -int KDEsuClient::delVars(const TQCString &special_key) -{ - TQCString cmd = "DELS "; - cmd += escape(special_key); - cmd += "\n"; - return command(cmd); -} - -int KDEsuClient::ping() -{ - return command("PING\n"); -} - -int KDEsuClient::exitCode() -{ - TQCString result; - if (command("EXIT\n", &result) != 0) - return -1; - - return result.toLong(); -} - -int KDEsuClient::stopServer() -{ - return command("STOP\n"); -} - -static TQString findDaemon() -{ - TQString daemon = locate("bin", "tdesud"); - if (daemon.isEmpty()) // if not in KDEDIRS, rely on PATH - daemon = KStandardDirs::findExe("tdesud"); - - if (daemon.isEmpty()) - { - kdWarning(900) << k_lineinfo << "daemon not found\n"; - } - return daemon; -} - -bool KDEsuClient::isServerSGID() -{ - if (d->daemon.isEmpty()) - d->daemon = findDaemon(); - if (d->daemon.isEmpty()) - return false; - - KDE_struct_stat sbuf; - if (KDE_stat(TQFile::encodeName(d->daemon), &sbuf) < 0) - { - kdWarning(900) << k_lineinfo << "stat(): " << perror << "\n"; - return false; - } - return (sbuf.st_mode & S_ISGID); -} - -int KDEsuClient::startServer() -{ - if (d->daemon.isEmpty()) - d->daemon = findDaemon(); - if (d->daemon.isEmpty()) - return -1; - - if (!isServerSGID()) { - kdWarning(900) << k_lineinfo << "tdesud not setgid!\n"; - } - - // tdesud only forks to the background after it is accepting - // connections. - // We start it via tdeinit to make sure that it doesn't inherit - // any fd's from the parent process. - int ret = kapp->tdeinitExecWait(d->daemon); - connect(); - return ret; -} diff --git a/kdesu/client.h b/kdesu/client.h deleted file mode 100644 index 420d5dadd..000000000 --- a/kdesu/client.h +++ /dev/null @@ -1,207 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * client.h: client to access tdesud. - */ - -#ifndef __KDE_su_Client_h_Included__ -#define __KDE_su_Client_h_Included__ - -#include <tqglobal.h> -#include <kdelibs_export.h> - -#ifdef Q_OS_UNIX - -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> - -#include <tqcstring.h> -#include <tqvaluelist.h> - -typedef TQValueList<TQCString> QCStringList; - -/** - * A client class to access tdesud, the KDE su daemon. Kdesud can assist in - * password caching in two ways: - * - * @li For high security passwords, like for su and ssh, it executes the - * password requesting command for you. It feeds the password to the - * command, without ever returning it to you, the user. The daemon should - * be installed setgid nogroup, in order to be able to act as an inaccessible, - * trusted 3rd party. - * See exec, setPass, delCommand. - * - * @li For lower security passwords, like web and ftp passwords, it can act - * as a persistent storage for string variables. These variables are - * returned to the user, and the daemon doesn't need to be setgid nogroup - * for this. - * See setVar, delVar, delGroup. - */ - -class KDESU_EXPORT KDEsuClient { -public: - KDEsuClient(); - ~KDEsuClient(); - - /** - * Lets tdesud execute a command. If the daemon does not have a password - * for this command, this will fail and you need to call setPass(). - * - * @param command The command to execute. - * @param user The user to run the command as. - * @param options Extra options. - * @param env Extra environment variables. - * @return Zero on success, -1 on failure. - */ - int exec(const TQCString &command, const TQCString &user, const TQCString &options=0, const QCStringList &env=QCStringList()); - - /** - * Wait for the last command to exit and return the exit code. - * @return Exit code of last command, -1 on failure. - */ - int exitCode(); - - /** - * Set root's password, lasts one session. - * - * @param pass Root's password. - * @param timeout The time that a password will live. - * @return Zero on success, -1 on failure. - */ - int setPass(const char *pass, int timeout); - - /** - * Set the target host (optional). - */ - int setHost(const TQCString &host); - - /** - * Set the desired priority (optional), see StubProcess. - */ - int setPriority(int priority); - - /** - * Set the desired scheduler (optional), see StubProcess. - */ - int setScheduler(int scheduler); - - /** - * Remove a password for a user/command. - * @param command The command. - * @param user The user. - * @return zero on success, -1 on an error - */ - int delCommand(const TQCString &command, const TQCString &user); - - /** - * Set a persistent variable. - * @param key The name of the variable. - * @param value Its value. - * @param timeout The timeout in seconds for this key. Zero means - * no timeout. - * @param group Make the key part of a group. See delGroup. - * @return zero on success, -1 on failure. - */ - int setVar(const TQCString &key, const TQCString &value, int timeout=0, const TQCString &group=0); - - /** - * Get a persistent variable. - * @param key The name of the variable. - * @return Its value. - */ - TQCString getVar(const TQCString &key); - - /** - * Gets all the keys that are membes of the given group. - * @param group the group name of the variables. - * @return a list of the keys in the group. - */ - TQValueList<TQCString> getKeys(const TQCString &group); - - /** - * Returns true if the specified group exists is - * cached. - * - * @param group the group key - * @return true if the group is found - */ - bool findGroup(const TQCString &group); - - /** - * Delete a persistent variable. - * @param key The name of the variable. - * @return zero on success, -1 on failure. - */ - int delVar(const TQCString &key); - - /** - * Delete all persistent variables with the given key. - * - * A specicalized variant of delVar(TQCString) that removes all - * subsets of the cached varaibles given by @p key. In order for all - * cached variables related to this key to be deleted properly, the - * value given to the @p group argument when the setVar function - * was called, must be a subset of the argument given here and the key - * - * @note Simply supplying the group key here WILL not necessarily - * work. If you only have a group key, then use delGroup instead. - * - * @param special_key the name of the variable. - * @return zero on success, -1 on failure. - */ - int delVars(const TQCString &special_key); - - /** - * Delete all persistent variables in a group. - * - * @param group the group name. See setVar. - * @return - */ - int delGroup(const TQCString &group); - - /** - * Ping tdesud. This can be used for diagnostics. - * @return Zero on success, -1 on failure - */ - int ping(); - - /** - * Stop the daemon. - */ - int stopServer(); - - /** - * Try to start up tdesud - */ - int startServer(); - - /** - * Returns true if the server is safe (installed setgid), false otherwise. - */ - bool isServerSGID(); - -private: - int connect(); - - int sockfd; - TQCString sock; - - int command(const TQCString &cmd, TQCString *result=0L); - TQCString escape(const TQCString &str); - - class KDEsuClientPrivate; - KDEsuClientPrivate *d; -}; - -#endif //Q_OS_UNIX - -#endif //__KDE_su_Client_h_Included__ diff --git a/kdesu/configure.in.in b/kdesu/configure.in.in deleted file mode 100644 index 5f398b720..000000000 --- a/kdesu/configure.in.in +++ /dev/null @@ -1,93 +0,0 @@ -dnl Check for su -AC_PATH_PROG(path_su, "su", "no") -if test "$path_su" = "no"; then - AC_MSG_WARN(su was not found) -else - AC_DEFINE_UNQUOTED(__PATH_SU, "$path_su", [path to su]) -fi - -dnl Check for sudo -AC_PATH_PROG(path_sudo, "sudo", "no") -if test "$path_sudo" = "no"; then - AC_MSG_WARN(sudo was not found) -else - AC_DEFINE_UNQUOTED(__PATH_SUDO, "$path_sudo", [path to sudo]) -fi - -AC_ARG_WITH(sudo-tdesu-backend, - AC_HELP_STRING([--with-sudo-tdesu-backend], - [use sudo as backend for tdesu (default is su)]), -[ - if test x$withval = xyes; then - use_tdesu_backend="sudo" - else - use_tdesu_backend="su" - fi -], - use_tdesu_backend="su" -) - -if test x$use_tdesu_backend = xsudo -a x$path_sudo = xno; then - AC_MSG_ERROR(sudo was chosen as tdesu backend, but was not found in path.) -fi - -AC_DEFINE_UNQUOTED(DEFAULT_SUPER_USER_COMMAND, "$use_tdesu_backend", [Use su or sudo]) - -dnl Check for POSIX.1b scheduling -AC_MSG_CHECKING([POSIX.1b scheduling]) -AC_TRY_LINK([ - #include <sched.h> -], -[ - sched_getscheduler(0); -], -have_rtsched="yes", have_rtsched="no") -if test "$have_rtsched" = "yes"; then - AC_DEFINE(POSIX1B_SCHEDULING, 1, [Define if you have POSIX.1b scheduling]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -dnl Check for initgroups() -AC_CHECK_FUNCS(initgroups) - -dnl openpty stuff -AC_CHECK_HEADERS(libutil.h util.h pty.h) -AC_CHECK_LIB(util, openpty, [AC_DEFINE_UNQUOTED(HAVE_OPENPTY, 1, [Define if you have openpty in -lutil])]) -AC_CHECK_FUNCS(openpty initgroups setgroups getgroups grantpt setpriority getpt unlockpt ptsname) - -AH_VERBATIM(_OPENPTY, -[ -/* - * Steven Schultz <sms at to.gd-es.com> tells us : - * BSD/OS 4.2 doesn't have a prototype for openpty in its system header files - */ -#ifdef __bsdi__ -__BEGIN_DECLS -int openpty(int *, int *, char *, struct termios *, struct winsize *); -__END_DECLS -#endif -]) - -dnl irix pty stuff -AC_CHECK_FUNCS(_getpty) - -AC_MSG_CHECKING([for struct ucred]) -AC_CACHE_VAL(kde_cv_have_struct_ucred, -[ - AC_TRY_COMPILE( - [ - #include <sys/socket.h> - ], - [ - struct ucred cred; - ], kde_cv_have_struct_ucred=yes, - kde_cv_have_struct_ucred=no) -]) - -AC_MSG_RESULT($kde_cv_have_struct_ucred) -if test "$kde_cv_have_struct_ucred" = yes; then - AC_DEFINE(HAVE_STRUCT_UCRED,1, [Define if struct ucred is present from sys/socket.h]) -fi -AC_CHECK_FUNCS(getpeereid) diff --git a/kdesu/defaults.h b/kdesu/defaults.h deleted file mode 100644 index 4649b2b16..000000000 --- a/kdesu/defaults.h +++ /dev/null @@ -1,21 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __Defaults_h_included__ -#define __Defaults_h_included__ - -/*const int defTimeout = 120*60;*/ -const int defTimeout = 120*60; -const int defEchoMode = 0; -const int defKeep = true; - -#endif diff --git a/kdesu/kcookie.cpp b/kdesu/kcookie.cpp deleted file mode 100644 index 99b34ec4e..000000000 --- a/kdesu/kcookie.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * kcookie.cpp: KDE authentication cookies. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <signal.h> - -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqglobal.h> -#include <tqfile.h> - -#include <dcopclient.h> - -#include <kdebug.h> -#include <kprocess.h> -#include "kcookie.h" - - -KCookie::KCookie() -{ -#ifdef Q_WS_X11 - getXCookie(); -#endif - setDcopTransport("local"); -} - -void KCookie::setDcopTransport(const TQCString &dcopTransport) -{ - m_dcopTransport = dcopTransport; - m_bHaveDCOPCookies = false; - m_bHaveICECookies = false; - m_DCOPSrv = ""; - m_DCOPAuth = ""; - m_ICEAuth = ""; -} - -QCStringList KCookie::split(const TQCString &line, char ch) -{ - QCStringList result; - - int i=0, pos; - while ((pos = line.find(ch, i)) != -1) - { - result += line.mid(i, pos-i); - i = pos+1; - } - if (i < (int) line.length()) - result += line.mid(i); - return result; -} - -void KCookie::blockSigChild() -{ - sigset_t sset; - sigemptyset(&sset); - sigaddset(&sset, SIGCHLD); - sigprocmask(SIG_BLOCK, &sset, 0L); -} - -void KCookie::unblockSigChild() -{ - sigset_t sset; - sigemptyset(&sset); - sigaddset(&sset, SIGCHLD); - sigprocmask(SIG_UNBLOCK, &sset, 0L); -} - -void KCookie::getXCookie() -{ - char buf[1024]; - FILE *f; - -#ifdef Q_WS_X11 - m_Display = getenv("DISPLAY"); -#else - m_Display = getenv("QWS_DISPLAY"); -#endif - if (m_Display.isEmpty()) - { - kdError(900) << k_lineinfo << "$DISPLAY is not set.\n"; - return; - } -#ifdef Q_WS_X11 // No need to mess with X Auth stuff - TQCString disp = m_Display; - if (!memcmp(disp.data(), "localhost:", 10)) - disp.remove(0, 9); - - TQString cmd = "xauth list "+KProcess::quote(disp); - blockSigChild(); // pclose uses waitpid() - if (!(f = popen(TQFile::encodeName(cmd), "r"))) - { - kdError(900) << k_lineinfo << "popen(): " << perror << "\n"; - unblockSigChild(); - return; - } - TQCString output = fgets(buf, 1024, f); - if (pclose(f) < 0) - { - kdError(900) << k_lineinfo << "Could not run xauth.\n"; - unblockSigChild(); - return; - } - unblockSigChild(); - output = output.simplifyWhiteSpace(); - if (output.isEmpty()) - { - kdWarning(900) << "No X authentication info set for display " << - m_Display << endl; return; - } - QCStringList lst = split(output, ' '); - if (lst.count() != 3) - { - kdError(900) << k_lineinfo << "parse error.\n"; - return; - } - m_DisplayAuth = (lst[1] + ' ' + lst[2]); -#endif -} - -void KCookie::getICECookie() -{ - FILE *f; - char buf[1024]; - - TQCString dcopsrv = getenv("DCOPSERVER"); - if (dcopsrv.isEmpty()) - { - TQCString dcopFile = DCOPClient::dcopServerFile(); - if (!(f = fopen(dcopFile, "r"))) - { - kdWarning(900) << k_lineinfo << "Cannot open " << dcopFile << ".\n"; - return; - } - dcopsrv = fgets(buf, 1024, f); - dcopsrv = dcopsrv.stripWhiteSpace(); - fclose(f); - } - QCStringList dcopServerList = split(dcopsrv, ','); - if (dcopServerList.isEmpty()) - { - kdError(900) << k_lineinfo << "No DCOP servers found.\n"; - return; - } - - QCStringList::Iterator it; - for (it=dcopServerList.begin(); it != dcopServerList.end(); ++it) - { - if (strncmp((*it).data(), m_dcopTransport.data(), m_dcopTransport.length()) != 0) - continue; - m_DCOPSrv = *it; - TQCString cmd = DCOPClient::iceauthPath()+" list netid="+TQFile::encodeName(KProcess::quote(m_DCOPSrv)); - blockSigChild(); - if (!(f = popen(cmd, "r"))) - { - kdError(900) << k_lineinfo << "popen(): " << perror << "\n"; - unblockSigChild(); - break; - } - QCStringList output; - while (fgets(buf, 1024, f)) - output += buf; - if (pclose(f) < 0) - { - kdError(900) << k_lineinfo << "Could not run iceauth.\n"; - unblockSigChild(); - break; - } - unblockSigChild(); - QCStringList::Iterator it2; - for (it2=output.begin(); it2!=output.end(); ++it2) - { - QCStringList lst = split((*it2).simplifyWhiteSpace(), ' '); - if (lst.count() != 5) - { - kdError(900) << "parse error.\n"; - break; - } - if (lst[0] == "DCOP") - m_DCOPAuth = (lst[3] + ' ' + lst[4]); - else if (lst[0] == "ICE") - m_ICEAuth = (lst[3] + ' ' + lst[4]); - else - kdError(900) << k_lineinfo << "unknown protocol: " << lst[0] << "\n"; - } - break; - } - m_bHaveDCOPCookies = true; - m_bHaveICECookies = true; -} - -TQCString KCookie::dcopServer() -{ - if (!m_bHaveDCOPCookies) - getICECookie(); - return m_DCOPSrv; -} - -TQCString KCookie::dcopAuth() -{ - if (!m_bHaveDCOPCookies) - getICECookie(); - return m_DCOPAuth; -} - -TQCString KCookie::iceAuth() -{ - if (!m_bHaveICECookies) - getICECookie(); - return m_ICEAuth; -} diff --git a/kdesu/kcookie.h b/kdesu/kcookie.h deleted file mode 100644 index 713922011..000000000 --- a/kdesu/kcookie.h +++ /dev/null @@ -1,90 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __KCookie_h_Included__ -#define __KCookie_h_Included__ - -#include <tqcstring.h> -#include <tqvaluelist.h> - -typedef TQValueList<TQCString> QCStringList; - - -/** - * Utility class to access the authentication tokens needed to run a KDE - * program (X11 and DCOP cookies). - */ - -class KDESU_EXPORT KCookie -{ -public: - KCookie(); - - /** - * Returns the X11 display. - */ - TQCString display() { return m_Display; } - -#ifdef Q_WS_X11 - /** - * Returns the X11 magic cookie, if available. - */ - TQCString displayAuth() { return m_DisplayAuth; } -#endif - - /** - * Select the DCOP transport to look for. Default: "local" - */ - void setDcopTransport(const TQCString &dcopTransport); - - /** - * Returns the netid where the dcopserver is running - */ - TQCString dcopServer(); - - /** - * Returns a list of magic cookies for DCOP protocol authentication. - * The order is the same as in dcopServer(). - */ - TQCString dcopAuth(); - - /** - * Returns a list of magic cookies for the ICE protocol. - */ - TQCString iceAuth(); - -private: - void getXCookie(); - void getICECookie(); - QCStringList split(const TQCString &line, char ch); - - void blockSigChild(); - void unblockSigChild(); - - bool m_bHaveDCOPCookies; - bool m_bHaveICECookies; - - TQCString m_Display; -#ifdef Q_WS_X11 - TQCString m_DisplayAuth; -#endif - TQCString m_DCOPSrv; - TQCString m_DCOPAuth; - TQCString m_ICEAuth; - TQCString m_dcopTransport; - - class KCookiePrivate; - KCookiePrivate *d; -}; - - -#endif // __KCookie_h_Included__ diff --git a/kdesu/kdesu_pty.cpp b/kdesu/kdesu_pty.cpp deleted file mode 100644 index d3392ec5e..000000000 --- a/kdesu/kdesu_pty.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This file contains code from TEShell.C of the KDE konsole. - * Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * pty.cpp: Access to PTY's on different systems a la UNIX98. - */ - - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE /* Needed for getpt, ptsname in glibc 2.1.x systems */ -#endif - -#include <config.h> - -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <errno.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <sys/ioctl.h> -#if defined(__osf__) || defined(__CYGWIN__) -#include <pty.h> -#endif - -#include <tqglobal.h> -#include <tqcstring.h> - -#include <kdebug.h> -#include <kstandarddirs.h> -#include "tdesu_pty.h" - -// stdlib.h is meant to declare the prototypes but doesn't :( -#ifndef __THROW -#define __THROW -#endif - -#ifdef HAVE_GRANTPT -extern "C" int grantpt(int fd) __THROW; -#endif - -#ifdef HAVE_PTSNAME -extern "C" char * ptsname(int fd) __THROW; -#endif - -#ifdef HAVE_UNLOCKPT -extern "C" int unlockpt(int fd) __THROW; -#endif - -#ifdef HAVE__GETPTY -extern "C" char *_getpty(int *, int, mode_t, int); -#endif - -#ifdef HAVE_PTY_H - #include <pty.h> -#endif - -#include <termios.h> - -#ifdef HAVE_LIBUTIL_H - #include <libutil.h> -#elif defined(HAVE_UTIL_H) - #include <util.h> -#endif - -PTY::PTY() -{ - ptyfd = -1; -} - -PTY::~PTY() -{ - if (ptyfd >= 0) - close(ptyfd); -} - - -// Opens a pty master and returns its filedescriptor. - -int PTY::getpt() -{ - -#if defined(HAVE_GETPT) && defined(HAVE_PTSNAME) - - // 1: UNIX98: preferred way - ptyfd = ::getpt(); - ttyname = ::ptsname(ptyfd); - return ptyfd; - -#elif defined(HAVE_OPENPTY) - // 2: BSD interface - // More preferred than the linux hacks - char name[30]; - int master_fd, slave_fd; - if (openpty(&master_fd, &slave_fd, name, 0L, 0L) != -1) { - ttyname = name; - name[5]='p'; - ptyname = name; - close(slave_fd); // We don't need this yet // Yes, we do. - ptyfd = master_fd; - return ptyfd; - } - ptyfd = -1; - kdDebug(900) << k_lineinfo << "Opening pty failed.\n"; - return -1; - -#elif defined(HAVE__GETPTY) - // 3: Irix interface - int master_fd; - ttyname = _getpty(&master_fd,O_RDWR,0600,0); - if (ttyname) - ptyfd = master_fd; - else{ - ptyfd = -1; - kdDebug(900) << k_lineinfo << "Opening pty failed.error" << errno << '\n'; - } - return ptyfd; - -#else - - // 4: Open terminal device directly - // 4.1: Try /dev/ptmx first. (Linux w/ Unix98 PTYs, Solaris) - - ptyfd = open("/dev/ptmx", O_RDWR); - if (ptyfd >= 0) { - ptyname = "/dev/ptmx"; -#ifdef HAVE_PTSNAME - ttyname = ::ptsname(ptyfd); - return ptyfd; -#elif defined (TIOCGPTN) - int ptyno; - if (ioctl(ptyfd, TIOCGPTN, &ptyno) == 0) { - ttyname.sprintf("/dev/pts/%d", ptyno); - return ptyfd; - } -#endif - close(ptyfd); - } - - // 4.2: Try /dev/pty[p-e][0-f] (Linux w/o UNIX98 PTY's) - - for (const char *c1 = "pqrstuvwxyzabcde"; *c1 != '\0'; c1++) - { - for (const char *c2 = "0123456789abcdef"; *c2 != '\0'; c2++) - { - ptyname.sprintf("/dev/pty%c%c", *c1, *c2); - ttyname.sprintf("/dev/tty%c%c", *c1, *c2); - if (access(ptyname, F_OK) < 0) - goto linux_out; - ptyfd = open(ptyname, O_RDWR); - if (ptyfd >= 0) - return ptyfd; - } - } -linux_out: - - // 4.3: Try /dev/pty%d (SCO, Unixware) - - for (int i=0; i<256; i++) - { - ptyname.sprintf("/dev/ptyp%d", i); - ttyname.sprintf("/dev/ttyp%d", i); - if (access(ptyname, F_OK) < 0) - break; - ptyfd = open(ptyname, O_RDWR); - if (ptyfd >= 0) - return ptyfd; - } - - - // Other systems ?? - ptyfd = -1; - kdDebug(900) << k_lineinfo << "Unknown system or all methods failed.\n"; - return -1; - -#endif // HAVE_GETPT && HAVE_PTSNAME - -} - - -int PTY::grantpt() -{ - if (ptyfd < 0) - return -1; - -#ifdef HAVE_GRANTPT - - return ::grantpt(ptyfd); - -#elif defined(HAVE_OPENPTY) - - // the BSD openpty() interface chowns the devices properly for us, - // no need to do this at all - return 0; - -#else - - // konsole_grantpty only does /dev/pty?? - if (ptyname.left(8) != "/dev/pty") - return 0; - - // Use konsole_grantpty: - if (KStandardDirs::findExe("konsole_grantpty").isEmpty()) - { - kdError(900) << k_lineinfo << "konsole_grantpty not found.\n"; - return -1; - } - - // As defined in konsole_grantpty.c - const int pty_fileno = 3; - - pid_t pid; - if ((pid = fork()) == -1) - { - kdError(900) << k_lineinfo << "fork(): " << perror << "\n"; - return -1; - } - - if (pid) - { - // Parent: wait for child - int ret; - waitpid(pid, &ret, 0); - if (WIFEXITED(ret) && !WEXITSTATUS(ret)) - return 0; - kdError(900) << k_lineinfo << "konsole_grantpty returned with error: " - << WEXITSTATUS(ret) << "\n"; - return -1; - } else - { - // Child: exec konsole_grantpty - if (ptyfd != pty_fileno && dup2(ptyfd, pty_fileno) < 0) - _exit(1); - execlp("konsole_grantpty", "konsole_grantpty", "--grant", (void *)0); - kdError(900) << k_lineinfo << "exec(): " << perror << "\n"; - _exit(1); - } - - // shut up, gcc - return 0; - -#endif // HAVE_GRANTPT -} - - -/** - * Unlock the pty. This allows connections on the slave side. - */ - -int PTY::unlockpt() -{ - if (ptyfd < 0) - return -1; - -#ifdef HAVE_UNLOCKPT - - // (Linux w/ glibc 2.1, Solaris, ...) - - return ::unlockpt(ptyfd); - -#elif defined(TIOCSPTLCK) - - // Unlock pty (Linux w/ UNIX98 PTY's & glibc 2.0) - int flag = 0; - return ioctl(ptyfd, TIOCSPTLCK, &flag); - -#else - - // Other systems (Linux w/o UNIX98 PTY's, ...) - return 0; - -#endif - -} - - -/** - * Return the slave side name. - */ - -TQCString PTY::ptsname() -{ - if (ptyfd < 0) - return 0; - - return ttyname; -} - diff --git a/kdesu/kdesu_pty.h b/kdesu/kdesu_pty.h deleted file mode 100644 index 1dab49dcb..000000000 --- a/kdesu/kdesu_pty.h +++ /dev/null @@ -1,71 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - - -/** - * PTY compatibility routines. This class tries to emulate a UNIX98 PTY API - * on various platforms. - */ -#ifndef __PTY_h_Included__ -#define __PTY_h_Included__ - -#include <tqcstring.h> - -#include <kdelibs_export.h> - -class KDESU_EXPORT PTY { - -public: - /** - * Construct a PTY object. - */ - PTY(); - - /** - * Destructs the object. The PTY is closed if it is still open. - */ - ~PTY(); - - /** - * Allocate a pty. - * @return A filedescriptor to the master side. - */ - int getpt(); - - /** - * Grant access to the slave side. - * @return Zero if succesfull, < 0 otherwise. - */ - int grantpt(); - - /** - * Unlock the slave side. - * @return Zero if successful, < 0 otherwise. - */ - int unlockpt(); - - /** - * Get the slave name. - * @return The slave name. - */ - TQCString ptsname(); - -private: - - int ptyfd; - TQCString ptyname, ttyname; - - class PTYPrivate; - PTYPrivate *d; -}; - -#endif // __PTY_h_Included__ diff --git a/kdesu/kdesu_stub.c b/kdesu/kdesu_stub.c deleted file mode 100644 index 5e1f09c24..000000000 --- a/kdesu/kdesu_stub.c +++ /dev/null @@ -1,432 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * tdesu_stub.c: KDE su executes this stub through su or ssh. This stub in turn - * executes the target program. Before that, startup parameters - * are sent through stdin. - * - * - * Available parameters: - * - * Parameter Description Format (csl = comma separated list) - * - * - tdesu_stub Header "ok" | "stop" - * - display X11 display string - * - display_auth X11 authentication "type cookie" pair - * - dcopserver KDE dcopserver csl of netids - * - dcop_auth DCOP authentication csl of "type cookie" pairs for DCOP - * - ice_auth ICE authentication csl of "type cookie" pairs for ICE - * - command Command to run string - * - path PATH env. var string - * - build_sycoca Rebuild sycoca? "yes" | "no" - * - user Target user string - * - priority Process priority 0 <= int <= 100 - * - scheduler Process scheduler "fifo" | "normal" - * - app_startup_id DESKTOP_STARTUP_ID string - * - environment Additional envvars strings, last one is empty - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> -#include <pwd.h> -#include <termios.h> -#include <signal.h> - -#ifdef HAVE_INITGROUPS -#include <grp.h> -#endif - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/resource.h> - -#ifdef POSIX1B_SCHEDULING -#include <sched.h> -#endif - -/** - * Params sent by the peer. - */ - -struct param_struct -{ - const char *name; - char *value; -}; - -struct param_struct params[] = -{ - { "tdesu_stub", 0L }, - { "display", 0L }, - { "display_auth", 0L }, - { "dcopserver", 0L }, - { "dcop_auth", 0L }, - { "ice_auth", 0L }, - { "command", 0L }, - { "path", 0L }, - { "xwindows_only", 0L }, - { "user", 0L }, - { "priority", 0L }, - { "scheduler", 0L }, -/* obsoleted by app_startup_id { "app_start_pid", 0L } */ - { "app_startup_id", 0L } -}; - -#define P_HEADER 0 -#define P_DISPLAY 1 -#define P_DISPLAY_AUTH 2 -#define P_DCOPSERVER 3 -#define P_DCOP_AUTH 4 -#define P_ICE_AUTH 5 -#define P_COMMAND 6 -#define P_PATH 7 -#define P_XWIN_ONLY 8 -#define P_USER 9 -#define P_PRIORITY 10 -#define P_SCHEDULER 11 -#define P_APP_STARTUP_ID 12 -#define P_LAST 13 - -/* Prototypes */ -char *xmalloc(size_t); -char *xrealloc(char *ptr, int size); -int xsetenv(const char *name, const char *value); -char *xstrdup(char *src); -char **xstrsep(char *str); - -/** - * Safe malloc functions. - */ -char *xmalloc(size_t size) -{ - char *ptr = malloc(size); - if (ptr) return ptr; - perror("malloc()"); - exit(1); -} - - -char *xrealloc(char *ptr, int size) -{ - ptr = realloc(ptr, size); - if (ptr) return ptr; - perror("realloc()"); - exit(1); -} - - -/** - * Solaris does not have a setenv()... - */ -int xsetenv(const char *name, const char *value) -{ - char *s = malloc(strlen(name)+strlen(value)+2); - if (!s) return -1; - strcpy(s, name); - strcat(s, "="); - strcat(s, value); - return putenv(s); /* yes: no free()! */ -} - -/** - * Safe strdup and strip newline - */ -char *xstrdup(char *src) -{ - int len = strlen(src); - char *dst = xmalloc(len+1); - strcpy(dst, src); - if (dst[len-1] == '\n') - dst[len-1] = '\000'; - return dst; -} - -/** - * Split comma separated list. - */ -char **xstrsep(char *str) -{ - int i = 0, size = 10; - char **list = (char **) xmalloc(size * sizeof(char *)); - char *ptr = str, *nptr; - while ((nptr = strchr(ptr, ',')) != 0L) - { - if (i > size-2) - list = realloc(list, (size *= 2) * sizeof(char *)); - *nptr = '\000'; - list[i++] = ptr; - ptr = nptr+1; - } - if (*ptr != '\000') - list[i++] = ptr; - list[i] = 0L; - return list; -} - -#define BUFSIZE 8192 - -/** - * The main program - */ - -int main() -{ - char buf[BUFSIZE+1]; -#ifndef QWS - char xauthority[200]; -#endif - char iceauthority[200]; - char **host, **auth; - int i/*, res, sycoca*/, prio; - pid_t pid; - FILE *fout; - struct passwd *pw; - const char* tdesu_lc_all; - - /* Get startup parameters. */ - - for (i=0; i<P_LAST; i++) - { - printf("%s\n", params[i].name); - fflush(stdout); - if (fgets(buf, BUFSIZE, stdin) == 0L) - { - printf("end\n"); fflush(stdout); - perror("tdesu_stub: fgets()"); - exit(1); - } - params[i].value = xstrdup(buf); - /* Installation check? */ - if ((i == 0) && !strcmp(params[i].value, "stop")) - { - printf("end\n"); - exit(0); - } - } - printf("environment\n"); - fflush(stdout); - for(;;) - { - char* tmp; - if (fgets(buf, BUFSIZE, stdin) == 0L) - { - printf("end\n"); fflush(stdout); - perror("tdesu_stub: fgets()"); - exit(1); - } - tmp = xstrdup( buf ); - if( tmp[ 0 ] == '\0' ) /* terminator */ - break; - putenv( xstrdup( buf )); - } - - printf("end\n"); - fflush(stdout); - - xsetenv("PATH", params[P_PATH].value); - xsetenv("DESKTOP_STARTUP_ID", params[P_APP_STARTUP_ID].value); - - tdesu_lc_all = getenv( "KDESU_LC_ALL" ); - if( tdesu_lc_all != NULL ) - xsetenv("LC_ALL",tdesu_lc_all); - else - unsetenv("LC_ALL"); - - /* Do we need to change uid? */ - - pw = getpwnam(params[P_USER].value); - if (pw == 0L) - { - printf("tdesu_stub: user %s does not exist!\n", params[P_USER].value); - exit(1); - } - xsetenv("HOME", pw->pw_dir); - - /* Set scheduling/priority */ - - prio = atoi(params[P_PRIORITY].value); - if (!strcmp(params[P_SCHEDULER].value, "realtime")) - { -#ifdef POSIX1B_SCHEDULING - struct sched_param sched; - int min = sched_get_priority_min(SCHED_FIFO); - int max = sched_get_priority_max(SCHED_FIFO); - sched.sched_priority = min + (int) (((double) prio) * (max - min) / 100 + 0.5); - sched_setscheduler(0, SCHED_FIFO, &sched); -#else - printf("tdesu_stub: realtime scheduling not supported\n"); -#endif - } else - { -#ifdef HAVE_SETPRIORITY - int val = 20 - (int) (((double) prio) * 40 / 100 + 0.5); - setpriority(PRIO_PROCESS, getpid(), val); -#endif - } - - /* Drop privileges (this is permanent) */ - - if (getuid() != pw->pw_uid) - { - if (setgid(pw->pw_gid) == -1) - { - perror("tdesu_stub: setgid()"); - exit(1); - } -#ifdef HAVE_INITGROUPS - if (initgroups(pw->pw_name, pw->pw_gid) == -1) - { - perror("tdesu_stub: initgroups()"); - exit(1); - } -#endif - if (setuid(pw->pw_uid) == -1) - { - perror("tdesu_stub: setuid()"); - exit(1); - } - xsetenv("HOME", pw->pw_dir); - } - - /* Handle display */ - - if (strcmp(params[P_DISPLAY].value, "no")) - { -#ifndef QWS - xsetenv("DISPLAY", params[P_DISPLAY].value); - if (params[P_DISPLAY_AUTH].value[0]) - { - int fd2; - /* - ** save umask and set to 077, so we create those files only - ** readable for root. (if someone else could read them, we - ** are in deep shit). - */ - int oldumask = umask(077); - const char *disp = params[P_DISPLAY].value; - if (strncmp(disp, "localhost:", 10) == 0) - disp += 9; - - strcpy(xauthority, "/tmp/xauth.XXXXXXXXXX"); - fd2 = mkstemp(xauthority); - umask(oldumask); - - if (fd2 == -1) { - perror("tdesu_stub: mkstemp()"); - exit(1); - } else - close(fd2); - xsetenv("XAUTHORITY", xauthority); - - fout = popen("xauth >/dev/null 2>&1","w"); - if (fout == NULL) - { - perror("tdesu_stub: popen(xauth)"); - exit(1); - } - fprintf(fout, "add %s %s\n", disp, - params[P_DISPLAY_AUTH].value); - pclose(fout); - } -#else - xsetenv("DISPLAY", params[P_DISPLAY].value); -#endif - } - - - /* Handle DCOP */ - - if (strcmp(params[P_DCOPSERVER].value, "no")) - { - xsetenv("DCOPSERVER", params[P_DCOPSERVER].value); - host = xstrsep(params[P_DCOPSERVER].value); - auth = xstrsep(params[P_ICE_AUTH].value); - if (host[0]) - { - int fd; - int oldumask = umask(077); - - strcpy(iceauthority, "/tmp/iceauth.XXXXXXXXXX"); - fd = mkstemp(iceauthority); - umask(oldumask); - if (fd == -1) { - perror("tdesu_stub: mkstemp()"); - exit(1); - } else - close(fd); - xsetenv("ICEAUTHORITY", iceauthority); - - fout = popen("iceauth >/dev/null 2>&1", "w"); - if (!fout) { - perror("tdesu_stub: popen iceauth"); - exit(1); - } - for (i=0; host[i]; i++) - fprintf(fout, "add ICE \"\" %s %s\n", host[i], auth[i]); - auth = xstrsep(params[P_DCOP_AUTH].value); - for (i=0; host[i]; i++) - fprintf(fout, "add DCOP \"\" %s %s\n", host[i], auth[i]); - pclose(fout); - } - } - - /* Rebuild the sycoca and start tdeinit? */ - - if (strcmp(params[P_XWIN_ONLY].value, "no")) - { - system("tdeinit --suicide"); - } - - /* Execute the command */ - - pid = fork(); - if (pid == -1) - { - perror("tdesu_stub: fork()"); - exit(1); - } - if (pid) - { - /* Parent: wait for child, delete tempfiles and return. */ - int ret, state, xit = 1; - while (1) - { - ret = waitpid(pid, &state, 0); - if (ret == -1) - { - if (errno == EINTR) - continue; - if (errno != ECHILD) - perror("tdesu_stub: waitpid()"); - break; - } - if (WIFEXITED(state)) - xit = WEXITSTATUS(state); - } - -#ifndef QWS - unlink(xauthority); -#endif - unlink(iceauthority); - exit(xit); - } else - { - setsid(); - /* Child: exec command. */ - sprintf(buf, "%s", params[P_COMMAND].value); - execl("/bin/sh", "sh", "-c", buf, (void *)0); - perror("tdesu_stub: exec()"); - _exit(1); - } -} diff --git a/kdesu/libkdesu.nmcheck b/kdesu/libkdesu.nmcheck deleted file mode 100644 index 8e4827481..000000000 --- a/kdesu/libkdesu.nmcheck +++ /dev/null @@ -1,10 +0,0 @@ -# KDE namespace check file - -# tdesu classes -SshProcess:* -PTY::* -SuProcess::* -StubProcess::* -PtyProcess::* -KCookie::* -KDEsuClient::* diff --git a/kdesu/libkdesu_weak.nmcheck b/kdesu/libkdesu_weak.nmcheck deleted file mode 100644 index 6fa8e9176..000000000 --- a/kdesu/libkdesu_weak.nmcheck +++ /dev/null @@ -1,2 +0,0 @@ -# KDE namespace check file - diff --git a/kdesu/process.cpp b/kdesu/process.cpp deleted file mode 100644 index d52308f63..000000000 --- a/kdesu/process.cpp +++ /dev/null @@ -1,626 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This file contains code from TEShell.C of the KDE konsole. - * Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * process.cpp: Functionality to build a front end to password asking - * terminal programs. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <signal.h> -#include <errno.h> -#include <string.h> -#include <termios.h> -#include <signal.h> - -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/ioctl.h> - -#if defined(__SVR4) && defined(sun) -#include <stropts.h> -#include <sys/stream.h> -#endif - -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> // Needed on some systems. -#endif - -#include <tqglobal.h> -#include <tqcstring.h> -#include <tqfile.h> - -#include <kconfig.h> -#include <kdebug.h> -#include <kstandarddirs.h> - -#include "process.h" -#include "tdesu_pty.h" -#include "kcookie.h" - -int PtyProcess::waitMS(int fd,int ms) -{ - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 1000*ms; - - fd_set fds; - FD_ZERO(&fds); - FD_SET(fd,&fds); - return select(fd+1, &fds, 0L, 0L, &tv); -} - -/* -** Basic check for the existence of @p pid. -** Returns true iff @p pid is an extant process. -*/ -bool PtyProcess::checkPid(pid_t pid) -{ - KConfig* config = KGlobal::config(); - config->setGroup("super-user-command"); - TQString superUserCommand = config->readEntry("super-user-command", DEFAULT_SUPER_USER_COMMAND); - //sudo does not accept signals from user so we except it - if (superUserCommand == "sudo") { - return true; - } else { - return kill(pid,0) == 0; - } -} - -/* -** Check process exit status for process @p pid. -** On error (no child, no exit), return Error (-1). -** If child @p pid has exited, return its exit status, -** (which may be zero). -** If child @p has not exited, return NotExited (-2). -*/ - -int PtyProcess::checkPidExited(pid_t pid) -{ - int state, ret; - ret = waitpid(pid, &state, WNOHANG); - - if (ret < 0) - { - kdError(900) << k_lineinfo << "waitpid(): " << perror << "\n"; - return Error; - } - if (ret == pid) - { - if (WIFEXITED(state)) - return WEXITSTATUS(state); - return Killed; - } - - return NotExited; -} - - -class PtyProcess::PtyProcessPrivate -{ -public: - QCStringList env; -}; - - -PtyProcess::PtyProcess() -{ - m_bTerminal = false; - m_bErase = false; - m_pPTY = 0L; - d = new PtyProcessPrivate; -} - - -int PtyProcess::init() -{ - delete m_pPTY; - m_pPTY = new PTY(); - m_Fd = m_pPTY->getpt(); - if (m_Fd < 0) - return -1; - if ((m_pPTY->grantpt() < 0) || (m_pPTY->unlockpt() < 0)) - { - kdError(900) << k_lineinfo << "Master setup failed.\n"; - m_Fd = -1; - return -1; - } - m_TTY = m_pPTY->ptsname(); - m_Inbuf.resize(0); - return 0; -} - - -PtyProcess::~PtyProcess() -{ - delete m_pPTY; - delete d; -} - -/** Set additinal environment variables. */ -void PtyProcess::setEnvironment( const QCStringList &env ) -{ - d->env = env; -} - -const QCStringList& PtyProcess::environment() const -{ - return d->env; -} - -/* - * Read one line of input. The terminal is in canonical mode, so you always - * read a line at at time, but it's possible to receive multiple lines in - * one time. - */ - -TQCString PtyProcess::readLine(bool block) -{ - int pos; - TQCString ret; - - if (!m_Inbuf.isEmpty()) - { - pos = m_Inbuf.find('\n'); - if (pos == -1) - { - ret = m_Inbuf; - m_Inbuf.resize(0); - } else - { - ret = m_Inbuf.left(pos); - m_Inbuf = m_Inbuf.mid(pos+1); - } - return ret; - } - - int flags = fcntl(m_Fd, F_GETFL); - if (flags < 0) - { - kdError(900) << k_lineinfo << "fcntl(F_GETFL): " << perror << "\n"; - return ret; - } - int oflags = flags; - if (block) - flags &= ~O_NONBLOCK; - else - flags |= O_NONBLOCK; - - if ((flags != oflags) && (fcntl(m_Fd, F_SETFL, flags) < 0)) - { - // We get an error here when the child process has closed - // the file descriptor already. - return ret; - } - - int nbytes; - char buf[256]; - while (1) - { - nbytes = read(m_Fd, buf, 255); - if (nbytes == -1) - { - if (errno == EINTR) - continue; - else break; - } - if (nbytes == 0) - break; // eof - - buf[nbytes] = '\000'; - m_Inbuf += buf; - - pos = m_Inbuf.find('\n'); - if (pos == -1) - { - ret = m_Inbuf; - m_Inbuf.resize(0); - } else - { - ret = m_Inbuf.left(pos); - m_Inbuf = m_Inbuf.mid(pos+1); - } - break; - } - - return ret; -} - -TQCString PtyProcess::readAll(bool block) -{ - TQCString ret; - - if (!m_Inbuf.isEmpty()) - { - // if there is still something in the buffer, we need not block. - // we should still try to read any further output, from the fd, though. - block = false; - ret = m_Inbuf; - m_Inbuf.resize(0); - } - - int flags = fcntl(m_Fd, F_GETFL); - if (flags < 0) - { - kdError(900) << k_lineinfo << "fcntl(F_GETFL): " << perror << "\n"; - return ret; - } - int oflags = flags; - if (block) - flags &= ~O_NONBLOCK; - else - flags |= O_NONBLOCK; - - if ((flags != oflags) && (fcntl(m_Fd, F_SETFL, flags) < 0)) - { - // We get an error here when the child process has closed - // the file descriptor already. - return ret; - } - - int nbytes; - char buf[256]; - while (1) - { - nbytes = read(m_Fd, buf, 255); - if (nbytes == -1) - { - if (errno == EINTR) - continue; - else break; - } - if (nbytes == 0) - break; // eof - - buf[nbytes] = '\000'; - ret += buf; - break; - } - - return ret; -} - - -void PtyProcess::writeLine(const TQCString &line, bool addnl) -{ - if (!line.isEmpty()) - write(m_Fd, line, line.length()); - if (addnl) - write(m_Fd, "\n", 1); -} - - -void PtyProcess::unreadLine(const TQCString &line, bool addnl) -{ - TQCString tmp = line; - if (addnl) - tmp += '\n'; - if (!tmp.isEmpty()) - m_Inbuf.prepend(tmp); -} - -/* - * Fork and execute the command. This returns in the parent. - */ - -int PtyProcess::exec(const TQCString &command, const QCStringList &args) -{ - kdDebug(900) << k_lineinfo << "Running `" << command << "'\n"; - - if (init() < 0) - return -1; - - // Open the pty slave before forking. See SetupTTY() - int slave = open(m_TTY, O_RDWR); - if (slave < 0) - { - kdError(900) << k_lineinfo << "Could not open slave pty.\n"; - return -1; - } - - if ((m_Pid = fork()) == -1) - { - kdError(900) << k_lineinfo << "fork(): " << perror << "\n"; - return -1; - } - - // Parent - if (m_Pid) - { - close(slave); - return 0; - } - - // Child - if (SetupTTY(slave) < 0) - _exit(1); - - for(QCStringList::ConstIterator it = d->env.begin(); - it != d->env.end(); it++) - { - putenv(const_cast<TQCString&>(*it).data()); - } - unsetenv("TDE_FULL_SESSION"); - - // set temporarily LC_ALL to C, for su (to be able to parse "Password:") - const char* old_lc_all = getenv( "LC_ALL" ); - if( old_lc_all != NULL ) - setenv( "KDESU_LC_ALL", old_lc_all, 1 ); - else - unsetenv( "KDESU_LC_ALL" ); - setenv("LC_ALL", "C", 1); - - // From now on, terminal output goes through the tty. - - TQCString path; - if (command.contains('/')) - path = command; - else - { - TQString file = KStandardDirs::findExe(command); - if (file.isEmpty()) - { - kdError(900) << k_lineinfo << command << " not found\n"; - _exit(1); - } - path = TQFile::encodeName(file); - } - - const char **argp = (const char **)malloc((args.count()+2)*sizeof(char *)); - int i = 0; - argp[i++] = path; - for (QCStringList::ConstIterator it=args.begin(); it!=args.end(); ++it) - argp[i++] = *it; - - argp[i] = 0L; - - execv(path, (char * const *)argp); - kdError(900) << k_lineinfo << "execv(\"" << path << "\"): " << perror << "\n"; - _exit(1); - return -1; // Shut up compiler. Never reached. -} - - -/* - * Wait until the terminal is set into no echo mode. At least one su - * (RH6 w/ Linux-PAM patches) sets noecho mode AFTER writing the Password: - * prompt, using TCSAFLUSH. This flushes the terminal I/O queues, possibly - * taking the password with it. So we wait until no echo mode is set - * before writing the password. - * Note that this is done on the slave fd. While Linux allows tcgetattr() on - * the master side, Solaris doesn't. - */ - -int PtyProcess::WaitSlave() -{ - int slave = open(m_TTY, O_RDWR); - if (slave < 0) - { - kdError(900) << k_lineinfo << "Could not open slave tty.\n"; - return -1; - } - - kdDebug(900) << k_lineinfo << "Child pid " << m_Pid << endl; - - struct termios tio; - while (1) - { - if (!checkPid(m_Pid)) - { - close(slave); - return -1; - } - if (tcgetattr(slave, &tio) < 0) - { - kdError(900) << k_lineinfo << "tcgetattr(): " << perror << "\n"; - close(slave); - return -1; - } - if (tio.c_lflag & ECHO) - { - kdDebug(900) << k_lineinfo << "Echo mode still on.\n"; - waitMS(slave,100); - continue; - } - break; - } - close(slave); - return 0; -} - - -int PtyProcess::enableLocalEcho(bool enable) -{ - int slave = open(m_TTY, O_RDWR); - if (slave < 0) - { - kdError(900) << k_lineinfo << "Could not open slave tty.\n"; - return -1; - } - struct termios tio; - if (tcgetattr(slave, &tio) < 0) - { - kdError(900) << k_lineinfo << "tcgetattr(): " << perror << "\n"; - close(slave); return -1; - } - if (enable) - tio.c_lflag |= ECHO; - else - tio.c_lflag &= ~ECHO; - if (tcsetattr(slave, TCSANOW, &tio) < 0) - { - kdError(900) << k_lineinfo << "tcsetattr(): " << perror << "\n"; - close(slave); return -1; - } - close(slave); - return 0; -} - - -/* - * Copy output to stdout until the child process exists, or a line of output - * matches `m_Exit'. - * We have to use waitpid() to test for exit. Merely waiting for EOF on the - * pty does not work, because the target process may have children still - * attached to the terminal. - */ - -int PtyProcess::waitForChild() -{ - int retval = 1; - - fd_set fds; - FD_ZERO(&fds); - - while (1) - { - FD_SET(m_Fd, &fds); - int ret = select(m_Fd+1, &fds, 0L, 0L, 0L); - if (ret == -1) - { - if (errno != EINTR) - { - kdError(900) << k_lineinfo << "select(): " << perror << "\n"; - return -1; - } - ret = 0; - } - - if (ret) - { - TQCString output = readAll(false); - bool lineStart = true; - while (!output.isNull()) - { - if (!m_Exit.isEmpty()) - { - // match exit string only at line starts - int pos = output.find(m_Exit.data()); - if ((pos >= 0) && ((pos == 0 && lineStart) || (output.at (pos - 1) == '\n'))) - { - kill(m_Pid, SIGTERM); - } - } - if (m_bTerminal) - { - fputs(output, stdout); - fflush(stdout); - } - lineStart = output.tqat( output.length() - 1 ) == '\n'; - output = readAll(false); - } - } - - ret = checkPidExited(m_Pid); - if (ret == Error) - { - if (errno == ECHILD) retval = 0; - else retval = 1; - break; - } - else if (ret == Killed) - { - retval = 0; - break; - } - else if (ret == NotExited) - { - // keep checking - } - else - { - retval = ret; - break; - } - } - return retval; -} - -/* - * SetupTTY: Creates a new session. The filedescriptor "fd" should be - * connected to the tty. It is closed after the tty is reopened to make it - * our controlling terminal. This way the tty is always opened at least once - * so we'll never get EIO when reading from it. - */ - -int PtyProcess::SetupTTY(int fd) -{ - // Reset signal handlers - for (int sig = 1; sig < NSIG; sig++) - signal(sig, SIG_DFL); - signal(SIGHUP, SIG_IGN); - - // Close all file handles - struct rlimit rlp; - getrlimit(RLIMIT_NOFILE, &rlp); - for (int i = 0; i < (int)rlp.rlim_cur; i++) - if (i != fd) close(i); - - // Create a new session. - setsid(); - - // Open slave. This will make it our controlling terminal - int slave = open(m_TTY, O_RDWR); - if (slave < 0) - { - kdError(900) << k_lineinfo << "Could not open slave side: " << perror << "\n"; - return -1; - } - close(fd); - -#if defined(__SVR4) && defined(sun) - - // Solaris STREAMS environment. - // Push these modules to make the stream look like a terminal. - ioctl(slave, I_PUSH, "ptem"); - ioctl(slave, I_PUSH, "ldterm"); - -#endif - -#ifdef TIOCSCTTY - ioctl(slave, TIOCSCTTY, NULL); -#endif - - // Connect stdin, stdout and stderr - dup2(slave, 0); dup2(slave, 1); dup2(slave, 2); - if (slave > 2) - close(slave); - - // Disable OPOST processing. Otherwise, '\n' are (on Linux at least) - // translated to '\r\n'. - struct termios tio; - if (tcgetattr(0, &tio) < 0) - { - kdError(900) << k_lineinfo << "tcgetattr(): " << perror << "\n"; - return -1; - } - tio.c_oflag &= ~OPOST; - if (tcsetattr(0, TCSANOW, &tio) < 0) - { - kdError(900) << k_lineinfo << "tcsetattr(): " << perror << "\n"; - return -1; - } - - return 0; -} - -void PtyProcess::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } diff --git a/kdesu/process.h b/kdesu/process.h deleted file mode 100644 index ec3af9a62..000000000 --- a/kdesu/process.h +++ /dev/null @@ -1,188 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __Process_h_Included__ -#define __Process_h_Included__ - -#include <sys/types.h> - -#include <tqcstring.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqvaluelist.h> - -#include <kdelibs_export.h> - -class PTY; -typedef TQValueList<TQCString> QCStringList; - -/** - * Synchronous communication with tty programs. - * - * PtyProcess provides synchronous communication with tty based programs. - * The communications channel used is a pseudo tty (as opposed to a pipe) - * This means that programs which require a terminal will work. - */ - -class KDESU_EXPORT PtyProcess -{ -public: - PtyProcess(); - virtual ~PtyProcess(); - - /** - * Forks off and execute a command. The command's standard in and output - * are connected to the pseudo tty. They are accessible with readLine - * and writeLine. - * @param command The command to execute. - * @param args The arguments to the command. - */ - int exec(const TQCString &command, const QCStringList &args); - - /** - * Reads a line from the program's standard out. Depending on the @em block - * parameter, this call blocks until a single, full line is read. - * @param block Block until a full line is read? - * @return The output string. - */ - TQCString readLine(bool block=true); - /** - * Read all available output from the program's standard out. - * @param block If no output is in the buffer, should the function block - * @return The output. - */ - TQCString readAll(bool block=true); - - /** - * Writes a line of text to the program's standard in. - * @param line The text to write. - * @param addNewline Adds a '\n' to the line. - */ - void writeLine(const TQCString &line, bool addNewline=true); - - /** - * Puts back a line of input. - * @param line The line to put back. - * @param addNewline Adds a '\n' to the line. - */ - void unreadLine(const TQCString &line, bool addNewline=true); - - /** - * Sets the exit string. If a line of program output matches this, - * waitForChild() will terminate the program and return. - */ - void setExitString(const TQCString &exit) { m_Exit = exit; } - - /** - * Waits for the child to exit. See also setExitString. - */ - int waitForChild(); - - /** - * Waits until the pty has cleared the ECHO flag. This is useful - * when programs write a password prompt before they disable ECHO. - * Disabling it might flush any input that was written. - */ - int WaitSlave(); - - /** - * Enables/disables local echo on the pseudo tty. - */ - int enableLocalEcho(bool enable=true); - - /** - * Enables/disables terminal output. Relevant only to some subclasses. - */ - void setTerminal(bool terminal) { m_bTerminal = terminal; } - - /** - * Overwrites the password as soon as it is used. Relevant only to - * some subclasses. - */ - void setErase(bool erase) { m_bErase = erase; } - - /** - * Set additinal environment variables. - */ - void setEnvironment( const QCStringList &env ); - - /** - * Returns the filedescriptor of the process. - */ - int fd() {return m_Fd;} - - /** - * Returns the pid of the process. - */ - int pid() {return m_Pid;} - -public: /* static */ - /* - ** This is a collection of static functions that can be - ** used for process control inside tdesu. I'd suggest - ** against using this publicly. There are probably - ** nicer Qt based ways to do what you want. - */ - - /** - ** Wait @p ms miliseconds (ie. 1/10th of a second is 100ms), - ** using @p fd as a filedescriptor to wait on. Returns - ** select(2)'s result, which is -1 on error, 0 on timeout, - ** or positive if there is data on one of the selected fd's. - ** - ** @p ms must be in the range 0..999 (ie. the maximum wait - ** duration is 999ms, almost one second). - */ - static int waitMS(int fd,int ms); - - - /** - ** Basic check for the existence of @p pid. - ** Returns true iff @p pid is an extant process, - ** (one you could kill - see man kill(2) for signal 0). - */ - static bool checkPid(pid_t pid); - - /** - ** Check process exit status for process @p pid. - ** On error (no child, no exit), return -1. - ** If child @p pid has exited, return its exit status, - ** (which may be zero). - ** If child @p has not exited, return -2. - */ - enum checkPidStatus { Error=-1, NotExited=-2, Killed=-3 } ; - static int checkPidExited(pid_t pid); - - -protected: - const QCStringList& environment() const; - - bool m_bErase, m_bTerminal; - int m_Pid, m_Fd; - TQCString m_Command, m_Exit; - -private: - int init(); - int SetupTTY(int fd); - - PTY *m_pPTY; - TQCString m_Inbuf, m_TTY; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class PtyProcessPrivate; - PtyProcessPrivate *d; -}; - - -#endif diff --git a/kdesu/ssh.cpp b/kdesu/ssh.cpp deleted file mode 100644 index f45b38e7e..000000000 --- a/kdesu/ssh.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 -* -* $Id$ -* -* This file is part of the KDE project, module tdesu. -* Copyright (C) 2000 Geert Jansen <jansen@kde.org> -* -* This is free software; you can use this library under the GNU Library -* General Public License, version 2. See the file "COPYING.LIB" for the -* exact licensing terms. -* -* ssh.cpp: Execute a program on a remote machine using ssh. -*/ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <signal.h> -#include <errno.h> -#include <string.h> -#include <ctype.h> -#include <signal.h> -#include <time.h> - -#include <sys/types.h> -#include <sys/stat.h> - -#include <tqglobal.h> -#include <tqcstring.h> - -#include <kdebug.h> -#include <klocale.h> -#include <kstandarddirs.h> - -#include "ssh.h" -#include "kcookie.h" - - -SshProcess::SshProcess(const TQCString &host, const TQCString &user, const TQCString &command) -{ - m_Host = host; - m_User = user; - m_Command = command; - m_Stub = "tdesu_stub"; - srand(time(0L)); -} - - -SshProcess::~SshProcess() -{ -} - - -void SshProcess::setStub(const TQCString &stub) -{ - m_Stub = stub; -} - - -int SshProcess::checkInstall(const char *password) -{ - return exec(password, 1); -} - - -int SshProcess::checkNeedPassword() -{ - return exec(0L, 2); -} - - -int SshProcess::exec(const char *password, int check) -{ - if (check) - setTerminal(true); - - QCStringList args; - args += "-l"; args += m_User; - args += "-o"; args += "StrictHostKeyChecking=no"; - args += m_Host; args += m_Stub; - - if (StubProcess::exec("ssh", args) < 0) - { - return check ? SshNotFound : -1; - } - - int ret = ConverseSsh(password, check); - if (ret < 0) - { - if (!check) - kdError(900) << k_lineinfo << "Conversation with ssh failed\n"; - return ret; - } - if (check == 2) - { - if (ret == 1) - { - kill(m_Pid, SIGTERM); - waitForChild(); - } - return ret; - } - - if (m_bErase && password) - { - char *ptr = const_cast<char *>(password); - const uint plen = strlen(password); - for (unsigned i=0; i < plen; i++) - ptr[i] = '\000'; - } - - ret = ConverseStub(check); - if (ret < 0) - { - if (!check) - kdError(900) << k_lineinfo << "Converstation with tdesu_stub failed\n"; - return ret; - } - else if (ret == 1) - { - kill(m_Pid, SIGTERM); - waitForChild(); - ret = SshIncorrectPassword; - } - - if (check == 1) - { - waitForChild(); - return 0; - } - - setExitString("Waiting for forwarded connections to terminate"); - ret = waitForChild(); - return ret; -} - -/* -* Create a port forwarding for DCOP. For the remote port, we take a pseudo -* random number between 10k and 50k. This is not ok, of course, but I see -* no other way. There is, afaik, no security issue involved here. If the port -* happens to be occupied, ssh will refuse to start. -* -* 14/SEP/2000: DCOP forwarding is not used anymore. -*/ - -TQCString SshProcess::dcopForward() -{ - TQCString result; - - setDcopTransport("tcp"); - - TQCString srv = StubProcess::dcopServer(); - if (srv.isEmpty()) - return result; - - int i = srv.find('/'); - if (i == -1) - return result; - if (srv.left(i) != "tcp") - return result; - int j = srv.find(':', ++i); - if (j == -1) - return result; - TQCString host = srv.mid(i, j-i); - bool ok; - int port = srv.mid(++j).toInt(&ok); - if (!ok) - return result; - - m_dcopPort = 10000 + (int) ((40000.0 * rand()) / (1.0 + RAND_MAX)); - result.sprintf("%d:%s:%d", m_dcopPort, host.data(), port); - return result; -} - - -/* -* Conversation with ssh. -* If check is 0, this waits for either a "Password: " prompt, -* or the header of the stub. If a prompt is received, the password is -* written back. Used for running a command. -* If check is 1, operation is the same as 0 except that if a stub header is -* received, the stub is stopped with the "stop" command. This is used for -* checking a password. -* If check is 2, operation is the same as 1, except that no password is -* written. The prompt is saved to m_Prompt. Used for checking the need for -* a password. -*/ - -int SshProcess::ConverseSsh(const char *password, int check) -{ - unsigned i, j, colon; - - TQCString line; - int state = 0; - - while (state < 2) - { - line = readLine(); - const uint len = line.length(); - if (line.isNull()) - return -1; - - switch (state) { - case 0: - // Check for "tdesu_stub" header. - if (line == "tdesu_stub") - { - unreadLine(line); - return 0; - } - - // Match "Password: " with the regex ^[^:]+:[\w]*$. - for (i=0,j=0,colon=0; i<len; i++) - { - if (line[i] == ':') - { - j = i; colon++; - continue; - } - if (!isspace(line[i])) - j++; - } - if ((colon == 1) && (line[j] == ':')) - { - if (check == 2) - { - m_Prompt = line; - return SshNeedsPassword; - } - WaitSlave(); - write(m_Fd, password, strlen(password)); - write(m_Fd, "\n", 1); - state++; - break; - } - - // Warning/error message. - m_Error += line; m_Error += "\n"; - if (m_bTerminal) - fprintf(stderr, "ssh: %s\n", line.data()); - break; - - case 1: - if (line.isEmpty()) - { - state++; - break; - } - return -1; - } - } - return 0; -} - - -// Display redirection is handled by ssh natively. -TQCString SshProcess::display() -{ - return "no"; -} - - -TQCString SshProcess::displayAuth() -{ - return "no"; -} - - -// Return the remote end of the forwarded connection. -TQCString SshProcess::dcopServer() -{ - return TQCString().sprintf("tcp/localhost:%d", m_dcopPort); -} - -void SshProcess::virtual_hook( int id, void* data ) -{ StubProcess::virtual_hook( id, data ); } diff --git a/kdesu/ssh.h b/kdesu/ssh.h deleted file mode 100644 index c84c56d02..000000000 --- a/kdesu/ssh.h +++ /dev/null @@ -1,90 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __SSH_h_Included__ -#define __SSH_h_Included__ - -#include <tqcstring.h> - -#include "stub.h" - -#include <kdelibs_export.h> - -/** - * Executes a remote command, using ssh. - */ - -class KDESU_EXPORT SshProcess: public StubProcess -{ -public: - SshProcess(const TQCString &host=0, const TQCString &user=0, const TQCString &command=0); - ~SshProcess(); - - enum Errors { SshNotFound=1, SshNeedsPassword, SshIncorrectPassword }; - - /** - * Sets the target host. - */ - void setHost(const TQCString &host) { m_Host = host; } - - /** - * Sets the localtion of the remote stub. - */ - void setStub(const TQCString &stub); - - /** - * Checks if the current user\@host needs a password. - * @return The prompt for the password if a password is required. A null - * string otherwise. - * - * @todo The return doc is so obviously wrong that the C code needs to be checked. - */ - int checkNeedPassword(); - - /** - * Checks if the stub is installed and if the password is correct. - * @return Zero if everything is correct, nonzero otherwise. - */ - int checkInstall(const char *password); - - /** - * Executes the command. - */ - int exec(const char *password, int check=0); - - TQCString prompt() { return m_Prompt; } - TQCString error() { return m_Error; } - -protected: - virtual TQCString display(); - virtual TQCString displayAuth(); - virtual TQCString dcopServer(); - -private: - TQCString dcopForward(); - int ConverseSsh(const char *password, int check); - - int m_dcopPort; - int m_dcopSrv; - TQCString m_Prompt; - TQCString m_Host; - TQCString m_Error; - TQCString m_Stub; - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class SshProcessPrivate; - SshProcessPrivate *d; -}; - -#endif diff --git a/kdesu/stub.cpp b/kdesu/stub.cpp deleted file mode 100644 index 7f083d71b..000000000 --- a/kdesu/stub.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - * - * stub.cpp: Conversation with tdesu_stub. - */ - -#include <config.h> -#include <stdlib.h> -#include <unistd.h> - -#include <tqglobal.h> -#include <tqcstring.h> -#include <kdatastream.h> - -#include <kapplication.h> -#include <kdebug.h> -#include <dcopclient.h> - -#include "stub.h" -#include "kcookie.h" - - -StubProcess::StubProcess() -{ - m_User = "root"; - m_Scheduler = SchedNormal; - m_Priority = 50; - m_pCookie = new KCookie; - m_bXOnly = true; - m_bDCOPForwarding = false; -} - - -StubProcess::~StubProcess() -{ - delete m_pCookie; -} - - -void StubProcess::setPriority(int prio) -{ - if (prio > 100) - m_Priority = 100; - else if (prio < 0) - m_Priority = 0; - else - m_Priority = prio; -} - - -TQCString StubProcess::commaSeparatedList(QCStringList lst) -{ - if (lst.count() == 0) - return TQCString(""); - - QCStringList::Iterator it = lst.begin(); - TQCString str = *it; - for (it++; it!=lst.end(); it++) - { - str += ','; - str += *it; - } - return str; -} - -/* - * Conversation with tdesu_stub. This is how we pass the authentication - * tokens (X11, DCOP) and other stuff to tdesu_stub. - * return values: -1 = error, 0 = ok, 1 = kill me - */ - -int StubProcess::ConverseStub(int check) -{ - TQCString line, tmp; - while (1) - { - line = readLine(); - if (line.isNull()) - return -1; - - if (line == "tdesu_stub") - { - // This makes parsing a lot easier. - enableLocalEcho(false); - if (check) writeLine("stop"); - else writeLine("ok"); - } else if (line == "display") { - writeLine(display()); - } else if (line == "display_auth") { -#ifdef Q_WS_X11 - writeLine(displayAuth()); -#else - writeLine(""); -#endif - } else if (line == "dcopserver") { - if (m_bDCOPForwarding) - writeLine(dcopServer()); - else - writeLine("no"); - } else if (line == "dcop_auth") { - if (m_bDCOPForwarding) - writeLine(dcopAuth()); - else - writeLine("no"); - } else if (line == "ice_auth") { - if (m_bDCOPForwarding) - writeLine(iceAuth()); - else - writeLine("no"); - } else if (line == "command") { - writeLine(m_Command); - } else if (line == "path") { - TQCString path = getenv("PATH"); - if (!path.isEmpty() && path[0] == ':') - path = path.mid(1); - if (m_User == "root") - if (!path.isEmpty()) - path = "/sbin:/bin:/usr/sbin:/usr/bin:" + path; - else - path = "/sbin:/bin:/usr/sbin:/usr/bin"; - writeLine(path); - } else if (line == "user") { - writeLine(m_User); - } else if (line == "priority") { - tmp.setNum(m_Priority); - writeLine(tmp); - } else if (line == "scheduler") { - if (m_Scheduler == SchedRealtime) writeLine("realtime"); - else writeLine("normal"); - } else if (line == "xwindows_only") { - if (m_bXOnly) writeLine("no"); - else writeLine("yes"); - } else if (line == "app_startup_id") { - QCStringList env = environment(); - TQCString tmp; - for( QCStringList::ConstIterator it = env.begin(); - it != env.end(); - ++it ) - { - if( (*it).find( "DESKTOP_STARTUP_ID=" ) == 0 ) - tmp = (*it).mid( strlen( "DESKTOP_STARTUP_ID=" )); - } - if( tmp.isEmpty()) - tmp = "0"; - writeLine(tmp); - } else if (line == "app_start_pid") { // obsolete - tmp.setNum(getpid()); - writeLine(tmp); - } else if (line == "environment") { // additional env vars - QCStringList env = environment(); - for( QCStringList::ConstIterator it = env.begin(); - it != env.end(); - ++it ) - writeLine( *it ); - writeLine( "" ); - } else if (line == "end") { - return 0; - } else - { - kdWarning(900) << k_lineinfo << "Unknown request: -->" << line - << "<--\n"; - return 1; - } - } - - return 0; -} - - -void StubProcess::notifyTaskbar(const TQString &) -{ - kdWarning(900) << "Obsolete StubProcess::notifyTaskbar() called!" << endl; -} - -void StubProcess::virtual_hook( int id, void* data ) -{ PtyProcess::virtual_hook( id, data ); } diff --git a/kdesu/stub.h b/kdesu/stub.h deleted file mode 100644 index 8bfc70a7f..000000000 --- a/kdesu/stub.h +++ /dev/null @@ -1,139 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __Stub_h_Included__ -#define __Stub_h_Included__ - -#include <tqcstring.h> -#include <tqvaluelist.h> - -#include "process.h" -#include "kcookie.h" - -#include <kdelibs_export.h> - -typedef TQValueList<TQCString> QCStringList; - -/** - * Chat with tdesu_stub. - * - * StubProcess extends PtyProcess with functionality to chat with tdesu_stub. - */ - -class KDESU_EXPORT StubProcess: public PtyProcess -{ -public: - StubProcess(); - ~StubProcess(); - - /** - * Specify dcop transport - */ - void setDcopTransport(const TQCString &dcopTransport) - { m_pCookie->setDcopTransport(dcopTransport); } - - /** - * Set the command. - */ - void setCommand(const TQCString &command) { m_Command = command; } - - /** - * Set the target user. - */ - void setUser(const TQCString &user) { m_User = user; } - - /** - * Set to "X only mode": Sycoca is not built and tdeinit is not launched. - */ - void setXOnly(bool xonly) { m_bXOnly = xonly; } - - /** - * Enable DCOP forwarding. - */ - void setDCOPForwarding(bool dcopForwarding) { m_bDCOPForwarding = dcopForwarding; } - - /** - * Set the priority of the process. The priority value must be between 0 - * and 100, 0 being the lowest priority. This value is mapped to the - * scheduler and system dependant priority range of the OS. - */ - void setPriority(int prio); - - /** - * Different schedulers. SchedNormal is the normal Unix timesharing - * scheduler, while SchedRealtime is a POSIX.1b realtime scheduler. - */ - enum Scheduler { SchedNormal, SchedRealtime }; - - /** - * Set the scheduler type. - */ - void setScheduler(int sched) { m_Scheduler = sched; } - -protected: - - /** - * Exchange all parameters with tdesu_stub. - */ - int ConverseStub(int check); - - /** - * Notify the taskbar that a new application has been started. - * @obsolete - */ - // KDE4 remove - void notifyTaskbar(const TQString &suffix); - - /** - * This virtual function can be overloaded when special behavior is - * desired. By default, it returns the value returned by KCookie. - */ - virtual TQCString display() { return m_pCookie->display(); } -#ifdef Q_WS_X11 - /** - * See display. - */ - virtual TQCString displayAuth() { return m_pCookie->displayAuth(); } -#endif - /** - * See display. - */ - virtual TQCString dcopServer() { return m_pCookie->dcopServer(); } - /** - * See display. - */ - virtual TQCString dcopAuth() { return m_pCookie->dcopAuth(); } - /** - * See display. - */ - virtual TQCString iceAuth() { return m_pCookie->iceAuth(); } - - bool m_bXOnly; - bool m_bDCOPForwarding; - int m_Priority; - int m_Scheduler; - TQCString m_dcopTransport; - TQCString m_Command; - TQCString m_User; - KCookie *m_pCookie; - -private: - TQCString commaSeparatedList(QCStringList); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class StubProcessPrivate; - StubProcessPrivate *d; -}; - -#endif // __Stub_h_Included__ diff --git a/kdesu/su.cpp b/kdesu/su.cpp deleted file mode 100644 index 0739c29c3..000000000 --- a/kdesu/su.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 -* -* $Id$ -* -* This file is part of the KDE project, module tdesu. -* Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> -* -* Sudo support added by Jonathan Riddell <jriddell@ ubuntu.com> -* Copyright (C) 2005 Canonical Ltd -* -* This is free software; you can use this library under the GNU Library -* General Public License, version 2. See the file "COPYING.LIB" for the -* exact licensing terms. -* -* su.cpp: Execute a program as another user with "class SuProcess". -*/ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include <ctype.h> -#include <signal.h> - -#include <sys/types.h> -#include <sys/stat.h> - -#include <tqglobal.h> -#include <tqcstring.h> -#include <tqfile.h> - -#include <kconfig.h> -#include <kdebug.h> -#include <klocale.h> -#include <kstandarddirs.h> - -#include "su.h" -#include "kcookie.h" - - -#ifndef __PATH_SU -#define __PATH_SU "false" -#endif - -#ifndef __PATH_SUDO -#define __PATH_SUDO "false" -#endif - -SuProcess::SuProcess(const TQCString &user, const TQCString &command) -{ - m_User = user; - m_Command = command; - - KConfig* config = KGlobal::config(); - config->setGroup("super-user-command"); - superUserCommand = config->readEntry("super-user-command", DEFAULT_SUPER_USER_COMMAND); - if ( superUserCommand != "sudo" && superUserCommand != "su" ) { - kdWarning() << "unknown super user command" << endl; - superUserCommand = "su"; - } -} - - -SuProcess::~SuProcess() -{ -} - -int SuProcess::checkInstall(const char *password) -{ - return exec(password, Install); -} - -int SuProcess::checkNeedPassword() -{ - return exec(0L, NeedPassword); -} - -/* -* Execute a command with su(1). -*/ - -int SuProcess::exec(const char *password, int check) -{ - if (check) - setTerminal(true); - - // since user may change after constructor (due to setUser()) - // we need to override sudo with su for non-root here - if (m_User != "root") { - superUserCommand = "su"; - } - - QCStringList args; - if (superUserCommand == "sudo") { - args += "-u"; - } - -#ifdef Q_OS_DARWIN - args += "-c"; - args += "staff"; -#endif - - if ((m_Scheduler != SchedNormal) || (m_Priority > 50)) - args += "root"; - else - args += m_User; - - if (superUserCommand == "su") { - args += "-c"; - } - args += TQCString(__KDE_BINDIR) + "/tdesu_stub"; -#ifndef Q_OS_DARWIN - args += "-"; -#endif - - /// TQCString command = __PATH_SU; - /// if (::access(__PATH_SU, X_OK) != 0) - TQCString command; - if (superUserCommand == "sudo") { - command = __PATH_SUDO; - } else { - command = __PATH_SU; - } - - if (::access(command, X_OK) != 0) - { - /// command = TQFile::encodeName(KGlobal::dirs()->findExe("su")); - command = TQFile::encodeName( KGlobal::dirs()->findExe(superUserCommand.ascii()) ); - if (command.isEmpty()) - return check ? SuNotFound : -1; - } - - // kdDebug(900) << k_lineinfo << "Call StubProcess::exec()" << endl; - if (StubProcess::exec(command, args) < 0) - { - return check ? SuNotFound : -1; - } - // kdDebug(900) << k_lineinfo << "Done StubProcess::exec()" << endl; - - SuErrors ret = (SuErrors) ConverseSU(password); - // kdDebug(900) << k_lineinfo << "Conversation returned " << ret << endl; - - if (ret == error) - { - if (!check) - kdError(900) << k_lineinfo << "Conversation with " << superUserCommand << " failed\n"; - return ret; - } - if (check == NeedPassword) - { - if (ret == killme) - { - /// if (kill(m_Pid, SIGKILL) < 0) - /// { - /// ret=error; - /// } - if ( superUserCommand == "sudo" ) { - // sudo can not be killed, just return - return ret; - } - if (kill(m_Pid, SIGKILL) < 0) { - kdDebug() << k_funcinfo << "kill < 0" << endl; - //FIXME SIGKILL doesn't work for sudo, - //why is this different from su? - ret=error; - } - else - { - int iret = waitForChild(); - if (iret < 0) ret=error; - else /* nothing */ {} ; - } - } - return ret; - } - - if (m_bErase && password) - { - char *ptr = const_cast<char *>(password); - const uint plen = strlen(password); - for (unsigned i=0; i < plen; i++) - ptr[i] = '\000'; - } - - if (ret == notauthorized) - { - kill(m_Pid, SIGKILL); - if (superUserCommand != "sudo") { - waitForChild(); - } - return SuIncorrectPassword; - } - - int iret = ConverseStub(check); - if (iret < 0) - { - if (!check) - kdError(900) << k_lineinfo << "Converstation with tdesu_stub failed\n"; - return iret; - } - else if (iret == 1) - { - kill(m_Pid, SIGKILL); - waitForChild(); - return SuIncorrectPassword; - } - - if (check == Install) - { - waitForChild(); - return 0; - } - - iret = waitForChild(); - return iret; -} - -/* -* Conversation with su: feed the password. -* Return values: -1 = error, 0 = ok, 1 = kill me, 2 not authorized -*/ - -int SuProcess::ConverseSU(const char *password) -{ - enum { WaitForPrompt, CheckStar, HandleStub } state = WaitForPrompt; - int colon; - unsigned i, j; - // kdDebug(900) << k_lineinfo << "ConverseSU starting." << endl; - - TQCString line; - while (true) - { - line = readLine(); - if (line.isNull()) - return ( state == HandleStub ? notauthorized : error); - kdDebug(900) << k_lineinfo << "Read line <" << line << ">" << endl; - - switch (state) - { - ////////////////////////////////////////////////////////////////////////// - case WaitForPrompt: - { - // In case no password is needed. - if (line == "tdesu_stub") - { - unreadLine(line); - return ok; - } - - while(waitMS(m_Fd,100)>0) - { - // There is more output available, so the previous line - // couldn't have been a password prompt (the definition - // of prompt being that there's a line of output followed - // by a colon, and then the process waits). - TQCString more = readLine(); - if (more.isEmpty()) - break; - - line = more; - kdDebug(900) << k_lineinfo << "Read line <" << more << ">" << endl; - } - - // Match "Password: " with the regex ^[^:]+:[\w]*$. - const uint len = line.length(); - for (i=0,j=0,colon=0; i<len; i++) - { - if (line[i] == ':') - { - j = i; colon++; - continue; - } - if (!isspace(line[i])) - j++; - } - if ((colon == 1) && (line[j] == ':')) - { - if (password == 0L) - return killme; - if (!checkPid(m_Pid)) - { - kdError(900) << superUserCommand << " has exited while waiting for pwd." << endl; - return error; - } - if ((WaitSlave() == 0) && checkPid(m_Pid)) - { - write(m_Fd, password, strlen(password)); - write(m_Fd, "\n", 1); - state=CheckStar; - } - else - { - return error; - } - } - break; - } - ////////////////////////////////////////////////////////////////////////// - case CheckStar: - { - TQCString s = line.stripWhiteSpace(); - if (s.isEmpty()) - { - state=HandleStub; - break; - } - const uint len = line.length(); - for (i=0; i< len; i++) - { - if (s[i] != '*') - return error; - } - state=HandleStub; - break; - } - ////////////////////////////////////////////////////////////////////////// - case HandleStub: - // Read till we get "tdesu_stub" - if (line == "tdesu_stub") - { - unreadLine(line); - return ok; - } else if (superUserCommand == "sudo") { - // sudo gives a "sorry" line so reaches here - // with the wrong password - return notauthorized; - } - break; - ////////////////////////////////////////////////////////////////////////// - } // end switch - } // end while (true) - return ok; -} - -void SuProcess::virtual_hook( int id, void* data ) -{ StubProcess::virtual_hook( id, data ); } - - diff --git a/kdesu/su.h b/kdesu/su.h deleted file mode 100644 index dcb67a14c..000000000 --- a/kdesu/su.h +++ /dev/null @@ -1,63 +0,0 @@ -/* vi: ts=8 sts=4 sw=4 - * - * $Id$ - * - * This file is part of the KDE project, module tdesu. - * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> - * - * This is free software; you can use this library under the GNU Library - * General Public License, version 2. See the file "COPYING.LIB" for the - * exact licensing terms. - */ - -#ifndef __SU_h_Included__ -#define __SU_h_Included__ - -#include <tqcstring.h> - -#include <kdelibs_export.h> - -#include "stub.h" - -/** - * Executes a command under elevated privileges, using su. - */ - -class KDESU_EXPORT SuProcess: public StubProcess -{ -public: - SuProcess(const TQCString &user=0, const TQCString &command=0); - ~SuProcess(); - - enum Errors { SuNotFound=1, SuNotAllowed, SuIncorrectPassword }; - - /** - * Executes the command. This will wait for the command to finish. - */ - enum checkMode { NoCheck=0, Install=1, NeedPassword=2 } ; - int exec(const char *password, int check=NoCheck); - - /** - * Checks if the stub is installed and the password is correct. - * @return Zero if everything is correct, nonzero otherwise. - */ - int checkInstall(const char *password); - - /** - * Checks if a password is needed. - */ - int checkNeedPassword(); - -private: - enum SuErrors { error=-1, ok=0, killme=1, notauthorized=2 } ; - int ConverseSU(const char *password); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class SuProcessPrivate; - SuProcessPrivate *d; - TQString superUserCommand; -}; - -#endif diff --git a/kdeui/AUTHORS b/kdeui/AUTHORS deleted file mode 100644 index 9e7ce9592..000000000 --- a/kdeui/AUTHORS +++ /dev/null @@ -1,97 +0,0 @@ -Dawit Alemayehu <adawit@earthlink.net> -KLineEdit, KComboBox - -Espen Sand <espen@kde.org>: -KDialogBase, KAboutDialog (based on work by Mirko), KHelpMenu, KTextBrowser -and various adjustments here and there. - -Daniel M. Duley <mosfet@kde.org> -Maintainer of KPixmapEffect, KStyle, KThemeStyle, and KThemeBase - as well as -general misc coding here and there. - -Matthias Kalle Dalheimer <kalle@kde.org>: -classes KApplication, KConfig, KTextStream, KColorSet, -automake, autoconf, maintenance - -Richard Moore <moorer@cs.man.ac.uk>: -KLedLamp class, KNewPanner class. - -Martynas Kunigelis <algikun@santaka.ktu.lt>: -KProgress class - -Steffen Hansen <stefh@dit.ou.dk>: -KURL class - -Torben Weis <weis@stud.uni-frankfurt.de> -DnD stuff, KSocket and KServerSocket classes, KPixmap - -Alexander Sanda <alex@darkstar.ping.at> -Read and write numerical config entries, KPanner, KTabControl, -KPopupMenu, KMessageBox, KEdit widgets. - -Martin Jones <mjones@powerup.com.au> -Bugfixes in KPixmap and KURL, KColorDialog, KSelector -KColorButton - -Keith Brown <kbrown@pdq.net> -KTreeList class - -Bernd Johannes Wuebben <wuebben@math.cornell.edu> -KFontDialog class - -Tim D. Gilman <tdgilman@best.com> -KDatePicker, KDateTable class - -Nicolas Hadacek <hadacek@kde.org> -Key configuration classes, bug fixes - -Christoph Neerfeld <Christoph.Neerfeld@mail.bonn.netsurf.de> -KIconLoader class - -Sven Radej <sven.radej@iname.com> -KLineEdit, KCombo, KToolbar, KStatusBar - -Rainer Bawidamann <Rainer.Bawidamann@wohnheim.uni-ulm.de> -Rubberbanding in KTreeList - -Andre Fornacon <afo@fh-zwickau.de> -KSpinBox - -Michael Wiedmann <mw@miwie.in-berlin.de> -KRestrictedLine, KIntegerLine - -Matthias Ettrich <ettrich@kde.org> -KWMModuleApplication, tearing/docking of ktoolbar and kmenubar, heavy -modifications to kbutton - -Stephan Kulow <coolo@kde.org> -first versions of KTopLevelWidget and KToolBar, heavy modifications to -automake and autoconf - -Joerg Habenicht <j.habenicht@europemail.com> -KLed class - -Thomas Tanghus <tanghus@earthling.net> -Classes KNotebook and KWizard - -Jorge Monteiro <jomo@casema.net> -KContainerLayout class - -Kurt Granroth <granroth@kde.org> -KURLLabel class - -Jörg Habenicht <habenich@kbs.uni-hannover.de> -KRuler class - -Rene Beutler <rbeutler@iiic.ethz.ch> -Widget Identifying System - -Maxim Judin <novaprint@mtu-net.ru> -created the Dockwidget class set - -Falk Brettschneider <gigafalk@yahoo.com> -contributes for the Dockwidget class set - -Holger Freyther <freyther@yahoo.com> -KDialogBase, KGuiItem, KStdGuiItem, KAction, -added KMessageBox::questionYesNoCancel( ) diff --git a/kdeui/CMakeLists.txt b/kdeui/CMakeLists.txt deleted file mode 100644 index 284a37409..000000000 --- a/kdeui/CMakeLists.txt +++ /dev/null @@ -1,168 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -if( BUILD_KDEUI_TESTS ) - add_subdirectory( tests ) -endif( BUILD_KDEUI_TESTS ) - -add_subdirectory( about ) -add_subdirectory( kdetrayproxy ) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdefx - ${CMAKE_SOURCE_DIR}/kio - ${CMAKE_SOURCE_DIR}/kio/kio - ${CMAKE_SOURCE_DIR}/kio/kfile - ${FREETYPE_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - kprogressbox.h kprogress.h kcolordlg.h - kcolordialog.h kselect.h - kdatepik.h kdatepicker.h kdatetbl.h kfontdialog.h kpopupmenu.h - kfontrequester.h ktabctl.h kstatusbar.h - kmainwindow.h kmainwindowiface.h ktoolbar.h kmenubar.h - knuminput.h kseparator.h klineedit.h - krestrictedline.h kcolorbutton.h kcolorbtn.h - ksystemtray.h kdockwindow.h kbuttonbox.h - keditcl.h kled.h keditlistbox.h - kwizard.h kkeydialog.h kkeybutton.h - kurllabel.h kruler.h kcursor.h - klineeditdlg.h kinputdialog.h kactivelabel.h - kcharselect.h kcolordrag.h qxembed.h - knumvalidator.h kdialog.h kdialogbase.h - kjanuswidget.h kaboutdialog.h - kauthicon.h kmessagebox.h ksharedpixmap.h - kdualcolorbtn.h kdualcolorbutton.h ktoolbarbutton.h - ktoolbarradiogroup.h ktextbrowser.h - kaction.h kactioncollection.h kactionclasses.h khelpmenu.h kswitchlanguagedialog.h - kcmodule.h kcmenumngr.h kpanelmenu.h kpanelappmenu.h - kactionshortcutlist.h kstdaction.h kcombobox.h - kiconview.h klistview.h klistbox.h kbugreport.h kpassdlg.h - kxmlguiclient.h kxmlgui.h kxmlguibuilder.h kxmlguifactory.h - kpixmapio.h kwordwrap.h - kedittoolbar.h kdockwidget.h kanimwidget.h - krootpixmap.h kaboutkde.h kaboutapplication.h - kpanelapplet.h kpushbutton.h kdcopactionproxy.h kcolorcombo.h - kpanelextension.h kcompletionbox.h ksqueezedtextlabel.h - kcommand.h kwindowlistmenu.h kfontcombo.h kaccelgen.h ktip.h - kdatewidget.h karrowbutton.h kguiitem.h kstdguiitem.h - kstringvalidator.h kwindowinfo.h - ktextedit.h kpassivepopup.h - kdatetimewidget.h ktimewidget.h ktimezonewidget.h kscrollview.h - kspell.h ksconfig.h kspelldlg.h ksyntaxhighlighter.h - ktabbar.h ktabwidget.h ksplashscreen.h kconfigdialog.h - kactionselector.h klanguagebutton.h klistviewsearchline.h - kpixmapregionselectorwidget.h kpixmapregionselectordialog.h - kiconviewsearchline.h ktoolbarlabelaction.h kshortcutdialog.h - DESTINATION ${INCLUDE_INSTALL_DIR} ) - - -##### other data ################################ - -install( FILES - aboutkde.png ktip-bulb.png ktip-background.png - DESTINATION ${DATA_INSTALL_DIR}/tdeui/pics ) - -install( FILES - ui_standards.rc - DESTINATION ${CONFIG_INSTALL_DIR}/ui ) - -install( PROGRAMS - preparetips - DESTINATION ${BIN_INSTALL_DIR} ) - - -##### libtdeui ################################## - -set( target tdeui ) - -set( ${target}_SRCS - qxembed.cpp ksharedpixmap.cpp kpixmapio.cpp - kpopupmenu.cpp ktoolbar.cpp kaction.cpp kstdaction.cpp - kactioncollection.cpp kactionclasses.cpp - kurllabel.cpp kmenubar.cpp kinputdialog.cpp - knuminput.cpp klineedit.cpp klistview.cpp kprogress.cpp - kprogressbox.cpp kcolordialog.cpp kselect.cpp kdatepicker.cpp - kdatetbl.cpp kfontrequester.cpp kfontdialog.cpp ktabctl.cpp - kstatusbar.cpp kmainwindow.cpp - keditlistbox.cpp kscrollview.cpp - kseparator.cpp krestrictedline.cpp - kcolorbutton.cpp ksystemtray.cpp - kbuttonbox.cpp keditcl1.cpp keditcl2.cpp kled.cpp - kshortcutdialog_simple.ui kshortcutdialog_advanced.ui - kshortcutdialog.cpp kkeybutton.cpp kkeydialog.cpp - kruler.cpp kcursor.cpp klineeditdlg.cpp - kcharselect.cpp kcolordrag.cpp - knumvalidator.cpp kdialog.cpp kdialogbase.cpp - kjanuswidget.cpp kaboutdialog.cpp - kauthicon.cpp kmessagebox.cpp kdualcolorbutton.cpp - ktoolbarradiogroup.cpp ktoolbarbutton.cpp - ktextbrowser.cpp khelpmenu.cpp kswitchlanguagedialog.cpp - kcmenumngr.cpp kpanelmenu.cpp - kiconview.cpp klistbox.cpp kwordwrap.cpp kbugreport.cpp - kcombobox.cpp kpassdlg.cpp kxmlguiclient.cpp kxmlguifactory.cpp - kxmlguifactory_p.cpp kxmlguibuilder.cpp kedittoolbar.cpp - kpanelappmenu.cpp kdockwidget.cpp kdockwidget_private.cpp - kanimwidget.cpp krootpixmap.cpp kaboutkde.cpp - kaboutapplication.cpp kpanelapplet.cpp kdcopactionproxy.cpp - kcolorcombo.cpp kpushbutton.cpp kpanelextension.cpp - kcompletionbox.cpp ksqueezedtextlabel.cpp kcmodule.cpp - kcommand.cpp kwindowlistmenu.cpp kfontcombo.cpp ktip.cpp - kdatewidget.cpp karrowbutton.cpp kmainwindowiface.cpp - kmainwindowiface.skel kguiitem.cpp kstdguiitem.cpp - kstringvalidator.cpp kactivelabel.cpp - kwindowinfo.cpp ktextedit.cpp kwizard.cpp kpassivepopup.cpp - ktoolbarhandler.cpp kdatetimewidget.cpp ktimewidget.cpp ktimezonewidget.cpp - ksconfig.cpp kspelldlg.cpp - kspell.cpp ksyntaxhighlighter.cpp ktabbar.cpp ktabwidget.cpp - ksplashscreen.cpp kspellui.ui kconfigdialog.cpp - kactionselector.cpp klanguagebutton.cpp klistviewsearchline.cpp - kpixmapregionselectorwidget.cpp kpixmapregionselectordialog.cpp - kwhatsthismanager.cpp kiconviewsearchline.cpp - ktoolbarlabelaction.cpp -) - -tde_add_library( ${target} SHARED AUTOMOC - SOURCES ${${target}_SRCS} - VERSION 4.2.0 - LINK tdecore-shared ${FREETYPE_LIBRARIES} ${FONTCONFIG_LIBRARIES} - DEPENDENCIES dcopidl - DESTINATION ${LIB_INSTALL_DIR} -) - - -##### libkspell ################################# - -set( target kspell ) - -configure_file( ${CMAKE_SOURCE_DIR}/cmake/modules/template_dummy_cpp.cmake dummy.cpp COPYONLY ) - -tde_add_library( ${target} SHARED - SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp - LINK ${TQT_LIBRARIES} - VERSION 4.2.0 - DESTINATION ${LIB_INSTALL_DIR} -) diff --git a/kdeui/MAINTAINERS b/kdeui/MAINTAINERS deleted file mode 100644 index 16942949f..000000000 --- a/kdeui/MAINTAINERS +++ /dev/null @@ -1,97 +0,0 @@ -Here are the code maintainers for each part of this library. Any problems or -suggested patches for a class should be directed to the responsible person for -that class. - -When adding yourself as a maintainer, don't be afraid to reorder the files to a -more logical grouping. - -kaboutapplication.cpp -kaboutdialog.cpp -kaboutkde.cpp -kaction.cpp Holger Freyther <freyther@kde.org>, Martijn Klingens <klingens@kde.org> -kanimwidget.cpp Waldo Bastian <bastian@kde.org> -karrowbutton.cpp Frerich Raabe <raabe@kde.org> -kauthicon.cpp -kbugreport.cpp -kbuttonbox.cpp -kcharselect.cpp -kcmenumngr.cpp -kcmodule.cpp -kcolorbutton.cpp -kcolorcombo.cpp -kcolordialog.cpp Waldo Bastian <bastian@kde.org> -kcolordrag.cpp -kcombobox.cpp Dawit Alemayehu <adawit@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org> -kcommand.cpp Werner Trobin <trobin@kde.org> -kcompletionbox.cpp Carsten Pfeiffer <pfeiffer@kde.org> -kcursor.cpp Carsten Pfeiffer <pfeiffer@kde.org> -kdatepicker.cpp -kdatetbl.cpp -kdatetimewidget.cpp Hans Petter Bieker <bieker@kde.org> -kdatewidget.cpp Waldo Bastian <bastian@kde.org> -kdcopactionproxy.cpp -kdialog.cpp -kdialogbase.cpp Waldo Bastian <bastian@kde.org> -kdockwidget.cpp Joseph Wenninger <jowenn@kde.org> -kdockwidget_private.cpp Joseph Wenninger <jowenn@kde.org> -kdualcolorbutton.cpp -keditcl1.cpp Waldo Bastian <bastian@kde.org> -keditcl2.cpp Waldo Bastian <bastian@kde.org> -keditlistbox.cpp -kedittoolbar.cpp -kfontcombo.cpp -kfontdialog.cpp -kguiitem.cpp Holger Freyther <freyther@kde.org>, Martijn Klingens <klingens@kde.org> -khelpmenu.cpp -kiconview.cpp -kjanuswidget.cpp Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu> -kkeybutton.cpp Ellis Whitehead <ellis@kde.org> -kkeydialog.cpp Ellis Whitehead <ellis@kde.org> -kled.cpp -klineedit.cpp Dawit Alemayehu <adawit@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org> -klineeditdlg.cpp -klistbox.cpp -klistview.cpp -kmainwindow.cpp -kmainwindowiface.cpp -kmenubar.cpp -kmessagebox.cpp Waldo Bastian <bastian@kde.org> -knuminput.cpp Dirk Mueller <mueller@kde.org> -knumvalidator.cpp -kpanelapplet.cpp -kpanelappmenu.cpp -kpanelextension.cpp -kpanelmenu.cpp -kpassdlg.cpp Waldo Bastian <bastian@kde.org> -kpixmapio.cpp -kpopupmenu.cpp Holger Freyther <freyther@kde.org> -kprogress.cpp -kpushbutton.cpp Carsten Pfeiffer <pfeiffer@kde.org>, Martijn Klingens <klingens@kde.org> -krestrictedline.cpp -krootpixmap.cpp -kruler.cpp -kselect.cpp -kseparator.cpp Waldo Bastian <bastian@kde.org> -ksharedpixmap.cpp -kshortcutdialog.cpp Ellis Whitehead <ellis@kde.org> -ksqueezedtextlabel.cpp -kstatusbar.cpp -kstdaction.cpp -kstdguiitem.cpp Holger Freyther <freyther@kde.org>, Martijn Klingens <klingens@kde.org> -kstringvalidator.cpp Marc Mutz <mutz@kde.org> -ksystemtray.cpp -ktabctl.cpp -ktextbrowser.cpp -ktimewidget Hans Petter Bieker <bieker@kde.org> -ktip.cpp -ktoolbar.cpp Waldo Bastian <bastian@kde.org> -ktoolbarbutton.cpp Waldo Bastian <bastian@kde.org> -ktoolbarradiogroup.cpp -kurllabel.cpp -kwindowlistmenu.cpp -kwizard.cpp -kwordwrap.cpp David Faure <faure@kde.org> -kxmlguibuilder.cpp -kxmlguiclient.cpp -kxmlguifactory.cpp -qxembed.cpp diff --git a/kdeui/Mainpage.dox b/kdeui/Mainpage.dox deleted file mode 100644 index 778c962f1..000000000 --- a/kdeui/Mainpage.dox +++ /dev/null @@ -1,43 +0,0 @@ -/* - A dummy source file for documenting the library. - Sirtaj Singh Kang <taj@kde.org> - $Id$ - Distributed under the LGPL. -*/ - -/** -* @mainpage The Trinity User Interface library -* -* This library provides standard user interface elements for use in -* Trinity applications. If your Trinity application has a GUI, you will almost -* certainly link to libtdeui. -* -* Most applications with single or multiple toplevel widgets -* should use the KMainWindow class in this library, which -* automatically provides features like session management and simplified -* toolbar/menubar/statusbar creation. -* -* A spell-checker library is also provided. -* KSpell offers easy access to International ISpell or ASpell -* (at the user's option) as well as a spell-checker GUI -* ("Add", "Replace", etc.). -* -* You can use KSpell to -* automatically spell-check an ASCII file as well as to implement -* online spell-checking and to spell-check proprietary format and -* marked up (e.g. HTML, TeX) documents. The relevant methods for -* these three procedures are check(), checkWord(), and -* checkList(), respectively. -* -* KSpellConfig holds configuration information about KSpell as well -* as acting as an options-setting dialog. -* -* KSpell usually works asynchronously. If you do not need that, you should -* simply use KSpell::modalCheck(). It won't return until the -* passed string is processed or the spell checking canceled. -* During modal spell checking your GUI is still repainted, but the user may -* only interact with the KSpell dialog. -* -* @see KSpell, KSpellConfig -*/ - diff --git a/kdeui/Makefile.am b/kdeui/Makefile.am deleted file mode 100644 index 4752cdb95..000000000 --- a/kdeui/Makefile.am +++ /dev/null @@ -1,171 +0,0 @@ - -# This file is part of the KDE libraries -# Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) -# (C) 1997 Stephan Kulow (coolo@kde.org) - -# 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 General Public License -# along with this library; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -SUBDIRS = . tests about kdetrayproxy - -INCLUDES= -I/usr/include/freetype2/ -I$(top_srcdir)/tdefx -I$(top_srcdir)/interfaces $(all_includes) - -# For the future: examine if condensing the tons of *_LDFLAGS variables -# into $(all_libraries) isn't better -AM_LDFLAGS = $(LDFLAGS_AS_NEEDED) $(LDFLAGS_NEW_DTAGS) - -lib_LTLIBRARIES = libtdeui.la libkspell.la -libtdeui_la_LDFLAGS = $(KDE_MT_LDFLAGS) -no-undefined -version-info 6:0:2 -libtdeui_la_LIBADD = ../tdecore/libtdecore.la $(LIB_QT) $(top_builddir)/dcop/libDCOP.la $(LIB_X11) $(top_builddir)/tdefx/libtdefx.la $(LIB_XEXT) - -libkspell_la_LDFLAGS = $(KDE_MT_LDFLAGS) -version-info 6:0:2 -no-undefined -libkspell_la_SOURCES = dummy.cpp - -picsdir = $(kde_datadir)/tdeui/pics -pics_DATA = aboutkde.png ktip-bulb.png ktip-background.png - -include_HEADERS = kprogressbox.h kprogress.h kcolordlg.h \ - kcolordialog.h kselect.h \ - kdatepik.h kdatepicker.h kdatetbl.h kfontdialog.h kpopupmenu.h \ - kfontrequester.h ktabctl.h kstatusbar.h \ - kmainwindow.h kmainwindowiface.h ktoolbar.h kmenubar.h \ - knuminput.h kseparator.h klineedit.h \ - krestrictedline.h kcolorbutton.h kcolorbtn.h \ - ksystemtray.h kdockwindow.h kbuttonbox.h \ - keditcl.h kled.h keditlistbox.h \ - kwizard.h kkeydialog.h kkeybutton.h \ - kurllabel.h kruler.h kcursor.h \ - klineeditdlg.h kinputdialog.h kactivelabel.h \ - kcharselect.h kcolordrag.h qxembed.h \ - knumvalidator.h kdialog.h kdialogbase.h \ - kjanuswidget.h kaboutdialog.h \ - kauthicon.h kmessagebox.h ksharedpixmap.h \ - kdualcolorbtn.h kdualcolorbutton.h ktoolbarbutton.h \ - ktoolbarradiogroup.h ktextbrowser.h \ - kaction.h kactioncollection.h kactionclasses.h khelpmenu.h kswitchlanguagedialog.h \ - kcmodule.h kcmenumngr.h kpanelmenu.h kpanelappmenu.h \ - kactionshortcutlist.h kstdaction.h kcombobox.h \ - kiconview.h klistview.h klistbox.h kbugreport.h kpassdlg.h \ - kxmlguiclient.h kxmlgui.h kxmlguibuilder.h kxmlguifactory.h \ - kpixmapio.h kwordwrap.h \ - kedittoolbar.h kdockwidget.h kanimwidget.h \ - krootpixmap.h kaboutkde.h kaboutapplication.h \ - kpanelapplet.h kpushbutton.h kdcopactionproxy.h kcolorcombo.h \ - kpanelextension.h kcompletionbox.h ksqueezedtextlabel.h \ - kcommand.h kwindowlistmenu.h kfontcombo.h kaccelgen.h ktip.h \ - kdatewidget.h karrowbutton.h kguiitem.h kstdguiitem.h \ - kstringvalidator.h kwindowinfo.h \ - ktextedit.h kpassivepopup.h \ - kdatetimewidget.h ktimewidget.h ktimezonewidget.h kscrollview.h \ - kspell.h ksconfig.h kspelldlg.h ksyntaxhighlighter.h \ - ktabbar.h ktabwidget.h ksplashscreen.h kconfigdialog.h \ - kactionselector.h klanguagebutton.h klistviewsearchline.h \ - kpixmapregionselectorwidget.h kpixmapregionselectordialog.h \ - kiconviewsearchline.h ktoolbarlabelaction.h kshortcutdialog.h - -# the order of the sources isn't randomly (at least not completely). -# the order is predictated by the use of X11 header files -# the files on the first line need to occur first when compiling -# with --enable-final since they use X defines that get undefined -# in ksharedpixmap.cpp -libtdeui_la_SOURCES = \ - qxembed.cpp ksharedpixmap.cpp kpixmapio.cpp \ - kpopupmenu.cpp ktoolbar.cpp kaction.cpp kstdaction.cpp \ - kactioncollection.cpp kactionclasses.cpp \ - kurllabel.cpp kmenubar.cpp kinputdialog.cpp \ - knuminput.cpp klineedit.cpp klistview.cpp kprogress.cpp \ - kprogressbox.cpp kcolordialog.cpp kselect.cpp kdatepicker.cpp \ - kdatetbl.cpp kfontrequester.cpp kfontdialog.cpp ktabctl.cpp \ - kstatusbar.cpp kmainwindow.cpp \ - keditlistbox.cpp kscrollview.cpp \ - kseparator.cpp krestrictedline.cpp \ - kcolorbutton.cpp ksystemtray.cpp \ - kbuttonbox.cpp keditcl1.cpp keditcl2.cpp kled.cpp \ - kshortcutdialog_simple.ui kshortcutdialog_advanced.ui \ - kshortcutdialog.cpp kkeybutton.cpp kkeydialog.cpp \ - kruler.cpp kcursor.cpp klineeditdlg.cpp \ - kcharselect.cpp kcolordrag.cpp \ - knumvalidator.cpp kdialog.cpp kdialogbase.cpp \ - kjanuswidget.cpp kaboutdialog.cpp \ - kauthicon.cpp kmessagebox.cpp kdualcolorbutton.cpp \ - ktoolbarradiogroup.cpp ktoolbarbutton.cpp \ - ktextbrowser.cpp khelpmenu.cpp kswitchlanguagedialog.cpp \ - kcmenumngr.cpp kpanelmenu.cpp \ - kiconview.cpp klistbox.cpp kwordwrap.cpp kbugreport.cpp \ - kcombobox.cpp kpassdlg.cpp kxmlguiclient.cpp kxmlguifactory.cpp \ - kxmlguifactory_p.cpp kxmlguibuilder.cpp kedittoolbar.cpp \ - kpanelappmenu.cpp kdockwidget.cpp kdockwidget_private.cpp \ - kanimwidget.cpp krootpixmap.cpp kaboutkde.cpp \ - kaboutapplication.cpp kpanelapplet.cpp kdcopactionproxy.cpp \ - kcolorcombo.cpp kpushbutton.cpp kpanelextension.cpp \ - kcompletionbox.cpp ksqueezedtextlabel.cpp kcmodule.cpp \ - kcommand.cpp kwindowlistmenu.cpp kfontcombo.cpp ktip.cpp \ - kdatewidget.cpp karrowbutton.cpp kmainwindowiface.cpp \ - kmainwindowiface.skel kguiitem.cpp kstdguiitem.cpp \ - kstringvalidator.cpp kactivelabel.cpp \ - kwindowinfo.cpp ktextedit.cpp kwizard.cpp kpassivepopup.cpp \ - ktoolbarhandler.cpp kdatetimewidget.cpp ktimewidget.cpp ktimezonewidget.cpp \ - ksconfig.cpp kspelldlg.cpp \ - kspell.cpp ksyntaxhighlighter.cpp ktabbar.cpp ktabwidget.cpp \ - ksplashscreen.cpp kspellui.ui kconfigdialog.cpp \ - kactionselector.cpp klanguagebutton.cpp klistviewsearchline.cpp \ - kpixmapregionselectorwidget.cpp kpixmapregionselectordialog.cpp \ - kwhatsthismanager.cpp kiconviewsearchline.cpp \ - ktoolbarlabelaction.cpp - -noinst_HEADERS = kdockwidget_private.h kdockwidget_p.h klistviewlineedit.h \ - kdialogbase_priv.h kaboutdialog_private.h kcursor_private.h \ - kdepackages.h kxmlguifactory_p.h \ - kstdaction_p.h kwhatsthismanager_p.h - -scripts_SCRIPTS = preparetips -scriptsdir = $(kde_bindir) - -libtdeui_la_METASOURCES = AUTO -libtdeui_la_NMCHECK = $(srcdir)/libtdeui.nmcheck -libtdeui_la_NMCHECKWEAK = $(srcdir)/libtdeui_weak.nmcheck $(top_srcdir)/tdecore/libtdecore_weak.nmcheck \ - $(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/tdecore/libqt-mt_weak.nmcheck - -rcdir = $(kde_confdir)/ui -rc_DATA = ui_standards.rc - -EXTRA_DIST = CHANGES.kdatepicker USERS.kdatepicker kpixmapio-perf.png dcolorreset.xpm kpartgui.dtd dcolorarrow.xbm colors Mainpage.dox - -.PHONY: kdepackages - -kdepackages: - -rm $(srcdir)/kdepackages.h - curl "http://bugsold.kde.org/xml.cgi?data=versiontable" > tmp_download - echo "// DO NOT EDIT - EDIT bugs/Maintainers instead" > $(srcdir)/kdepackages.h - echo "const char * const packages[] = {" >> $(srcdir)/kdepackages.h - cat tmp_download | egrep "product|component" | grep -v "</product>" | \ - sed -e "s,<product name=\"\([^\"]*\)\">,product=\"\1\"; component=\"general\",; \ - s#<component>\([^<]*\)</component>#component=\"\1\"#" > tmp_download2 - (while read i; do eval $$i; echo "\"$$product/$$component\","; done) < tmp_download2 | \ - sed -e "s,/general\",/00general\"," | LC_ALL=C sort -u | \ - grep -v 'valgrind/' | sed -e "s,/00general\",\"," >> $(srcdir)/kdepackages.h - echo "0 };" >> $(srcdir)/kdepackages.h - rm tmp_download2 tmp_download - -dummy.cpp: - echo "#ifdef _AIX" >dummy.cpp - echo "namespace {" >> dummy.cpp - echo "void *not_empty_file;" >>dummy.cpp - echo "}" >> dummy.cpp - echo "#endif" >> dummy.cpp - -DOXYGEN_REFERENCES = tdecore tdefx dcop kio kutils -DOXYGEN_SET_INTERNAL_DOCS = YES -include ../admin/Doxyfile.am diff --git a/kdeui/README.kspell b/kdeui/README.kspell deleted file mode 100644 index 9ae1afe84..000000000 --- a/kdeui/README.kspell +++ /dev/null @@ -1,17 +0,0 @@ -KSpell, by David Sweet ----------------------- -KSpell provides an interface to ASpell and International ISpell 3.1. You -should use it like a UI widget to provide spellchecking in your application. -See kspell.h and http://www.chaos.umd.edu/~dsweet/KDE/KSpell for -documentation. - -Settings --------- -A configuration dialog/widget is also provided. This class (KSpellConfig) acts -not only as a widget allowing the user to set KSpell preferences, but also -as a data abstraction class allowing you to get and set the preferences from -within your program. You can pass an instance of KSpellConfig to KSpell -and the spellchecker will run with the appropriate preference settings. The -preferences, when saved (see kspelldlg.h) are saved globally. If needed, -you can read them with KSpellDlg and set and use application-specific -spellchecking settings. diff --git a/kdeui/TODO.kspell b/kdeui/TODO.kspell deleted file mode 100644 index 99c9df408..000000000 --- a/kdeui/TODO.kspell +++ /dev/null @@ -1,34 +0,0 @@ -from Daniel Naber, 2002-02-17: - -- there's the pspell library that offers an API to ispell and aspell, - it would make our code much simpler. It's not asynchronous by itself, - but maybe that can be added in KSpell. - -- add an option to ignore HTML/XML markup (-h). It's currently not - possible (i.e. it doesn't work) because we feed the text into ispell - line by line and it gets confused if tags are spread over more - than one line. - -from Wolfram Diestel: - -- add more charsets - need support from users of this charsets -- rewrite the all the stuff to make it more asynchronous: - o one process should send data - o one process should read data - synchronization is done only by counting empty output lines from ispell - -old todo from David Sweet -------------------------- - -properly handle capitalization on "Replace All" (in parseOneResponse()) - -ensure that KSpell is reusable with the same replace/ignore lists - for multiple spellchecks in a single editing session - -allow saving of ignore/replace lists for multiple spellchecks of a - given document across multiple sessions - -add a "move()" function to move the dialog box (calling app should use this - in response to a misspelled() signal to move the d.b. out of the way - of the misspelled word) - This is done, but it doesn't work on the first call -- any ideas? diff --git a/kdeui/TODO.xmlgui b/kdeui/TODO.xmlgui deleted file mode 100644 index 3c3d4f8a4..000000000 --- a/kdeui/TODO.xmlgui +++ /dev/null @@ -1,91 +0,0 @@ -Bug with toolbars: a->saveState(); delete a; b->saveState(); delete b; -will store wrong positions (index, offset and newline). -When removing an xmlgui-client involves destroying toolbars, we need to save the -whole set of toolbar positions of the mainwindow, into the xmlgui-client. - -Data structure: -struct KToolBarPos { - short int index; - short int offset; - bool newLine; -}; -typedef QValueVector<KToolBarPos> KToolBarPosList; - -API: -KToolBarPosList KMainWindow::toolBarPositionList() const; - -The remaining problem is to know when to call it: -* when we know in advance that we'll be able to remove toolbars? - (when creating the client we could remember if we created a toolbar and store - that bit of information, to re-use it when removing the client again) -* when removing the first toolbar (of a given client); then we need -to differentiate between first and following toolbars -* always, if fast enough? With tons of plugins that might not be a good idea. - -========== More long term - -Problems: -* No ui_standards.rc merging for parts -* Confusing tag names (MergeLocal vs DefineGroup) for similar features -* Two different merging codes (DOM-tree merging for ui_standards, xmlguifactory merging -between xmlguiclients). - -Solution: -* Get rid of the custom DOM-tree merging code from kxmlguiclient (for ui_standards.rc), -use the existing merging code from kxmlguifactory instead -* MergeLocal and DefineGroup are renamed MergeGroup, and append= becomes equivalent to group=. -* Action is renamed MergeAction, and uses a new kind of place holder -(one that matches actions by name during merging) -So ui_standards.rc needs to be turned into <MergeAction>s and <MergeGroup>s only. -* This also means that it will be possible to have only merge tags (and custom items -like separators and tearoffhandle etc.) in a container, in which case it should -not appear in the GUI. For that, ContainerNode must be improved so that it supports -having no real GUI container attached to it. -Big problem here. This means not building a container until we find that it -really has an action (and the other way round: deleting a container when -removing its last action, as we do, but still keeping a ContainerNode around...) -(A ContainerNode is destroyed when its owner guiclient is removed from the factory, -no change here). - -* A new XMLGUIClient provides the ui_standards.rc XML. It has the same instance -as the mainwindow's guiclient. It provides no actions. No problems, since it -only has <Merge*> tags. - -But that new xmlguiclient will 'own' the containers, so KEditToolbar will -give wrong information. - -=====> -This means the following KEditToolbar improvement is necessary: -(it's an almost unrelated and necessary change there anyway, usability-wise) - -It would use merging, to present a merged view of the toolbars -When the user inserts an action to a toolbar, we know which client the action -belongs to, so we know which XML file to modify. -BUT if the user adds actions in non-contiguous positions, we need to -create <DefineGroup name="client1_tmp1"> groups, so that the merging actually does -what the user asked for (!!) - -This allows to get rid of the "toolbar <client>" combobox stuff, and just have -a list of toolbars there. - -Implementation: it can do this by providing its own KXMLGUIBuilder, to a -new factory. The guiclients would be wrapped in a KXMLGUIClientProxy, -which would forward the action() and domElement() calls - because a client -can be in only one factory at a time. - -This custom builder needs to know about action plugging too, we don't really want -to call KAction::plug here. So this would be 'virtualized' (new virtual, in a new -interface to keep BC, that by default calls plug, but does something else in -kedittoolbar's builder). - - -====== - -Additional benefits: -* Any XML file can use the new <MergeAction> feature to modify the way a -child client (e.g. a part) is getting merged, without adding group attributes -to the child client (useful for a binary-only one, e.g.) - --- -David Faure <faure@kde.org> -Simon Hausmann <hausmann@kde.org> diff --git a/kdeui/about/CMakeLists.txt b/kdeui/about/CMakeLists.txt deleted file mode 100644 index 7330005e2..000000000 --- a/kdeui/about/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -##### other data ################################ - -install( FILES - bar-bottom-left.png bar-top-right.png bar-bottom-middle.png bottom-left.png - box-middle-left.png top-left.png bar-bottom-right.png bottom-middle.png - box-middle-right.png top-middle.png bar-middle-left.png bottom-right.png - box-top-left.png bar-middle-right.png box-bottom-left.png box-top-middle.png - bar-top-left.png box-bottom-middle.png box-top-right.png bar-top-middle.png - box-bottom-right.png kde_infopage.css kde_infopage_rtl.css - DESTINATION ${DATA_INSTALL_DIR}/tdeui/about ) diff --git a/kdeui/about/Makefile.am b/kdeui/about/Makefile.am deleted file mode 100644 index 478bb71e0..000000000 --- a/kdeui/about/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ - -kde_infopage_datadir = $(kde_datadir)/tdeui/about -kde_infopage_data_DATA = \ - bar-bottom-left.png bar-top-right.png bar-bottom-middle.png bottom-left.png \ - box-middle-left.png top-left.png bar-bottom-right.png bottom-middle.png \ - box-middle-right.png top-middle.png bar-middle-left.png bottom-right.png \ - box-top-left.png bar-middle-right.png box-bottom-left.png box-top-middle.png \ - bar-top-left.png box-bottom-middle.png box-top-right.png bar-top-middle.png \ - box-bottom-right.png kde_infopage.css kde_infopage_rtl.css diff --git a/kdeui/about/bar-bottom-left.png b/kdeui/about/bar-bottom-left.png deleted file mode 100644 index 30a323592..000000000 Binary files a/kdeui/about/bar-bottom-left.png and /dev/null differ diff --git a/kdeui/about/bar-bottom-middle.png b/kdeui/about/bar-bottom-middle.png deleted file mode 100644 index b2ebbbed5..000000000 Binary files a/kdeui/about/bar-bottom-middle.png and /dev/null differ diff --git a/kdeui/about/bar-bottom-right.png b/kdeui/about/bar-bottom-right.png deleted file mode 100644 index e664e1511..000000000 Binary files a/kdeui/about/bar-bottom-right.png and /dev/null differ diff --git a/kdeui/about/bar-middle-left.png b/kdeui/about/bar-middle-left.png deleted file mode 100644 index 72fda9ec2..000000000 Binary files a/kdeui/about/bar-middle-left.png and /dev/null differ diff --git a/kdeui/about/bar-middle-right.png b/kdeui/about/bar-middle-right.png deleted file mode 100644 index eb8d3201c..000000000 Binary files a/kdeui/about/bar-middle-right.png and /dev/null differ diff --git a/kdeui/about/bar-top-left.png b/kdeui/about/bar-top-left.png deleted file mode 100644 index b05fd216c..000000000 Binary files a/kdeui/about/bar-top-left.png and /dev/null differ diff --git a/kdeui/about/bar-top-middle.png b/kdeui/about/bar-top-middle.png deleted file mode 100644 index 387f81017..000000000 Binary files a/kdeui/about/bar-top-middle.png and /dev/null differ diff --git a/kdeui/about/bar-top-right.png b/kdeui/about/bar-top-right.png deleted file mode 100644 index a552ff91d..000000000 Binary files a/kdeui/about/bar-top-right.png and /dev/null differ diff --git a/kdeui/about/bottom-left.png b/kdeui/about/bottom-left.png deleted file mode 100644 index 78c9fece3..000000000 Binary files a/kdeui/about/bottom-left.png and /dev/null differ diff --git a/kdeui/about/bottom-middle.png b/kdeui/about/bottom-middle.png deleted file mode 100644 index 41e52dd8a..000000000 Binary files a/kdeui/about/bottom-middle.png and /dev/null differ diff --git a/kdeui/about/bottom-right.png b/kdeui/about/bottom-right.png deleted file mode 100644 index ef81b04a8..000000000 Binary files a/kdeui/about/bottom-right.png and /dev/null differ diff --git a/kdeui/about/box-bottom-left.png b/kdeui/about/box-bottom-left.png deleted file mode 100644 index 49b1be6d9..000000000 Binary files a/kdeui/about/box-bottom-left.png and /dev/null differ diff --git a/kdeui/about/box-bottom-middle.png b/kdeui/about/box-bottom-middle.png deleted file mode 100644 index fd09ebb66..000000000 Binary files a/kdeui/about/box-bottom-middle.png and /dev/null differ diff --git a/kdeui/about/box-bottom-right.png b/kdeui/about/box-bottom-right.png deleted file mode 100644 index 4013c8ff4..000000000 Binary files a/kdeui/about/box-bottom-right.png and /dev/null differ diff --git a/kdeui/about/box-middle-left.png b/kdeui/about/box-middle-left.png deleted file mode 100644 index 1cd801a45..000000000 Binary files a/kdeui/about/box-middle-left.png and /dev/null differ diff --git a/kdeui/about/box-middle-right.png b/kdeui/about/box-middle-right.png deleted file mode 100644 index 54c5b0391..000000000 Binary files a/kdeui/about/box-middle-right.png and /dev/null differ diff --git a/kdeui/about/box-top-left.png b/kdeui/about/box-top-left.png deleted file mode 100644 index 29f91c129..000000000 Binary files a/kdeui/about/box-top-left.png and /dev/null differ diff --git a/kdeui/about/box-top-middle.png b/kdeui/about/box-top-middle.png deleted file mode 100644 index 5ea907597..000000000 Binary files a/kdeui/about/box-top-middle.png and /dev/null differ diff --git a/kdeui/about/box-top-right.png b/kdeui/about/box-top-right.png deleted file mode 100644 index f86163176..000000000 Binary files a/kdeui/about/box-top-right.png and /dev/null differ diff --git a/kdeui/about/kde_infopage.css b/kdeui/about/kde_infopage.css deleted file mode 100644 index 69085675e..000000000 --- a/kdeui/about/kde_infopage.css +++ /dev/null @@ -1,239 +0,0 @@ - -/* - * text styles - */ - -img {margin: 0px; padding: 0px} -body {margin: 0px; padding: 0px; background-color: #418ade;} -.bar_text a {color: #008;} - -#subtext { - font-size: 10pt; - font-style: italic; -} - -#nextlink { - margin-bottom: 0px; - text-align: right; - font-size: 10pt; -} - -/* - * the header - */ - -#header { - background-image: url(top-middle.png); - width: 100%; - height: 131px; -} - -#headerL { - position: absolute; - background-image: url(top-left.png); - left: 0px; - height: 131px; - width: 147px; - z-index: 1; -} - -#headerR { - position: absolute; - right: 0px; -} - -/* title and tagline are part of the header diff */ -#title { - position: absolute; - top: 63px; - right: 100px; - margin-top: -1em; - text-align: right; - font-size: xx-large; - font-weight: bold; - text-shadow: #fff 0px 0px 5px; - color: #444; - z-index: 5; -} - -#tagline { - position: absolute; - top: 70px; - right: 100px; - text-align: right; - font-size: large; - font-weight: bold; - text-shadow: #fff 0px 0px 5px; - color: #444; - z-index: 5; -} - -/* - * the nav bar - */ - -#bar { - width: 100%; - background-color: #5babe5; - padding-top: 0.5ex; - border-bottom: 1px solid black; - padding-bottom: 0.5ex; -} - -#barCenter { - text-align: center; - color: #282828; - font-weight: bold; - font-size: small; -} - -#barCenter a.selected, #barCenter a.selected:hover { - color: #282828; - text-decoration: none; - text-shadow: #fff 0px 0px 5px; -} - - -#barCenter li a:link, #barCenter li a:visited, #barCenter li a:active { - color: #282828; - text-decoration: none; - text-shadow: none; -} - -#barCenter li a:hover { - color: #282828; - text-decoration: none; - text-shadow: #fff 0px 0px 6px; -} - -#barCenter ul { - margin: 0; - padding: 0; -} - -#barCenter li { - display: inline; -} - -#barCenter li:not(:first-child):before { /* Aren't css3 selectors great? */ - content: " · "; -} - -/* - * the main box - */ - -#box { - width: 90%; - margin-left: 5%; - margin-right: 5%; - margin-top: 10px; - margin-bottom: 10px; -} - -#boxT { - width: 100%; - height: 22px; -} - -#boxTL { - width: 25px; - height: 22px; - float: left; - background-image: url(box-top-left.png); -} - -#boxTR { - width: 25px; - height: 22px; - float: right; - background-image: url(box-top-right.png); -} - -#boxTC { - height: 22px; - margin-left: 25px; - margin-right: 25px; - background-image: url(box-top-middle.png); - background-repeat: repeat-x; -} - -#boxL { - background-image: url(box-middle-left.png); - background-repeat: repeat-y; - background-position: left; - padding-left: 20px; -} - -#boxCenter { - background-color: #dfe7f3; - background-position: center; - text-align: left; -} - -#boxR { - background-image: url(box-middle-right.png); - background-repeat: repeat-y; - background-position: right; - padding-right: 20px; -} - -#boxB { - width: 100%; - height: 22px; -} - -#boxBL { - width: 25px; - height: 22px; - float: left; - background-image: url(box-bottom-left.png); -} - -#boxBR { - width: 25px; - height: 22px; - float: right; - background-image: url(box-bottom-right.png); -} - -#boxBC { - height: 22px; - margin-left: 25px; - margin-right: 25px; - background-image: url(box-bottom-middle.png); - background-repeat: repeat-x; -} - -/* - * the footer - */ - -#footer { - position: fixed; - background-image: url(bottom-middle.png); - width: 100%; - height: 100px; - z-index: -2; - bottom:0; -} - -#footerL { - position: fixed; - background-image: url(bottom-left.png); - left: 0px; - width: 155px; - height: 100px; - z-index: -2; -} - -#footerR { - position: fixed; - background-image: url(bottom-right.png); - right: 0px; - width: 429px; - height: 100px; - z-index: -1; -} - -/* vim:set sw=2 et nocindent smartindent: */ diff --git a/kdeui/about/kde_infopage_rtl.css b/kdeui/about/kde_infopage_rtl.css deleted file mode 100644 index 003330196..000000000 --- a/kdeui/about/kde_infopage_rtl.css +++ /dev/null @@ -1,11 +0,0 @@ -body {direction: rtl} - -#boxCenter { - text-align: right; -} - -#nextlink { - text-align: left; -} - -/* vim:set sw=2 et nocindent smartindent: */ diff --git a/kdeui/about/top-left.png b/kdeui/about/top-left.png deleted file mode 100644 index c97114a7f..000000000 Binary files a/kdeui/about/top-left.png and /dev/null differ diff --git a/kdeui/about/top-middle.png b/kdeui/about/top-middle.png deleted file mode 100644 index bb3fe7428..000000000 Binary files a/kdeui/about/top-middle.png and /dev/null differ diff --git a/kdeui/about/usage-example.html b/kdeui/about/usage-example.html deleted file mode 100644 index fd78d8cfb..000000000 --- a/kdeui/about/usage-example.html +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> - <meta name="generator" content= - "HTML Tidy for Linux/x86 (vers 1st August 2004), see www.w3.org" /> - - <style type="text/css"> - /*<![CDATA[*/ - @import "%1"; /* kde_infopage.css */ - %1 /* maybe @import "kde_infopage_rtl.css"; */ -/* CHANGE ME or REMOVE ME */ @import "MY_CSS_FILE.css"; - /*]]>*/ - </style> - - <title>%1 - - - -