summaryrefslogtreecommitdiffstats
path: root/tdeprint
diff options
context:
space:
mode:
Diffstat (limited to 'tdeprint')
-rw-r--r--tdeprint/CMakeLists.txt124
-rw-r--r--tdeprint/ChangeLog619
-rw-r--r--tdeprint/Makefile.am114
-rw-r--r--tdeprint/TODO75
-rw-r--r--tdeprint/TODO.cups12293
-rw-r--r--tdeprint/configure.in.in99
-rw-r--r--tdeprint/cups/CMakeLists.txt97
-rw-r--r--tdeprint/cups/Makefile.am49
-rw-r--r--tdeprint/cups/configure.in.in18
-rw-r--r--tdeprint/cups/cups.print68
-rw-r--r--tdeprint/cups/cupsaddsmb2.cpp476
-rw-r--r--tdeprint/cups/cupsaddsmb2.h77
-rw-r--r--tdeprint/cups/cupsdconf2/CMakeLists.txt54
-rw-r--r--tdeprint/cups/cupsdconf2/Makefile.am35
-rw-r--r--tdeprint/cups/cupsdconf2/addressdialog.cpp89
-rw-r--r--tdeprint/cups/cupsdconf2/addressdialog.h42
-rw-r--r--tdeprint/cups/cupsdconf2/browsedialog.cpp150
-rw-r--r--tdeprint/cups/cupsdconf2/browsedialog.h49
-rw-r--r--tdeprint/cups/cupsdconf2/cups-util.c557
-rw-r--r--tdeprint/cups/cupsdconf2/cups-util.h26
-rw-r--r--tdeprint/cups/cupsdconf2/cups_logo.pngbin0 -> 1487 bytes
-rw-r--r--tdeprint/cups/cupsdconf2/cupsd.conf.template977
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp210
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdbrowsingpage.h55
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdcomment.cpp136
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdcomment.h55
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdcomment.pl61
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdconf.cpp884
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdconf.h181
-rw-r--r--tdeprint/cups/cupsdconf2/cupsddialog.cpp356
-rw-r--r--tdeprint/cups/cupsdconf2/cupsddialog.h58
-rw-r--r--tdeprint/cups/cupsdconf2/cupsddirpage.cpp109
-rw-r--r--tdeprint/cups/cupsdconf2/cupsddirpage.h47
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdfilterpage.cpp94
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdfilterpage.h45
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdjobspage.cpp123
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdjobspage.h47
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdlogpage.cpp111
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdlogpage.h44
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp159
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdnetworkpage.h55
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdpage.cpp32
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdpage.h54
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp168
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdsecuritypage.h56
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdserverpage.cpp181
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdserverpage.h49
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdsplash.cpp73
-rw-r--r--tdeprint/cups/cupsdconf2/cupsdsplash.h35
-rw-r--r--tdeprint/cups/cupsdconf2/editlist.cpp124
-rw-r--r--tdeprint/cups/cupsdconf2/editlist.h60
-rw-r--r--tdeprint/cups/cupsdconf2/kde_logo.pngbin0 -> 15177 bytes
-rw-r--r--tdeprint/cups/cupsdconf2/locationdialog.cpp222
-rw-r--r--tdeprint/cups/cupsdconf2/locationdialog.h58
-rw-r--r--tdeprint/cups/cupsdconf2/main.cpp48
-rw-r--r--tdeprint/cups/cupsdconf2/portdialog.cpp118
-rw-r--r--tdeprint/cups/cupsdconf2/portdialog.h46
-rw-r--r--tdeprint/cups/cupsdconf2/qdirlineedit.cpp73
-rw-r--r--tdeprint/cups/cupsdconf2/qdirlineedit.h49
-rw-r--r--tdeprint/cups/cupsdconf2/qdirmultilineedit.cpp109
-rw-r--r--tdeprint/cups/cupsdconf2/qdirmultilineedit.h53
-rw-r--r--tdeprint/cups/cupsdconf2/sizewidget.cpp83
-rw-r--r--tdeprint/cups/cupsdconf2/sizewidget.h43
-rw-r--r--tdeprint/cups/cupsdoprint.c257
-rw-r--r--tdeprint/cups/cupsinfos.cpp166
-rw-r--r--tdeprint/cups/cupsinfos.h88
-rw-r--r--tdeprint/cups/image.cpp295
-rw-r--r--tdeprint/cups/imageposition.cpp153
-rw-r--r--tdeprint/cups/imageposition.h58
-rw-r--r--tdeprint/cups/imagepreview.cpp78
-rw-r--r--tdeprint/cups/imagepreview.h49
-rw-r--r--tdeprint/cups/ippreportdlg.cpp96
-rw-r--r--tdeprint/cups/ippreportdlg.h42
-rw-r--r--tdeprint/cups/ipprequest.cpp544
-rw-r--r--tdeprint/cups/ipprequest.h196
-rw-r--r--tdeprint/cups/kcupsprinterimpl.cpp159
-rw-r--r--tdeprint/cups/kcupsprinterimpl.h36
-rw-r--r--tdeprint/cups/kmconfigcups.cpp51
-rw-r--r--tdeprint/cups/kmconfigcups.h39
-rw-r--r--tdeprint/cups/kmconfigcupsdir.cpp67
-rw-r--r--tdeprint/cups/kmconfigcupsdir.h41
-rw-r--r--tdeprint/cups/kmcupsconfigwidget.cpp159
-rw-r--r--tdeprint/cups/kmcupsconfigwidget.h43
-rw-r--r--tdeprint/cups/kmcupsfactory.cpp30
-rw-r--r--tdeprint/cups/kmcupsjobmanager.cpp452
-rw-r--r--tdeprint/cups/kmcupsjobmanager.h53
-rw-r--r--tdeprint/cups/kmcupsmanager.cpp1077
-rw-r--r--tdeprint/cups/kmcupsmanager.h106
-rw-r--r--tdeprint/cups/kmcupsuimanager.cpp219
-rw-r--r--tdeprint/cups/kmcupsuimanager.h40
-rw-r--r--tdeprint/cups/kmpropbanners.cpp81
-rw-r--r--tdeprint/cups/kmpropbanners.h43
-rw-r--r--tdeprint/cups/kmpropquota.cpp96
-rw-r--r--tdeprint/cups/kmpropquota.h44
-rw-r--r--tdeprint/cups/kmpropusers.cpp90
-rw-r--r--tdeprint/cups/kmpropusers.h42
-rw-r--r--tdeprint/cups/kmwbanners.cpp145
-rw-r--r--tdeprint/cups/kmwbanners.h43
-rw-r--r--tdeprint/cups/kmwfax.cpp81
-rw-r--r--tdeprint/cups/kmwfax.h39
-rw-r--r--tdeprint/cups/kmwipp.cpp86
-rw-r--r--tdeprint/cups/kmwipp.h34
-rw-r--r--tdeprint/cups/kmwippprinter.cpp227
-rw-r--r--tdeprint/cups/kmwippprinter.h56
-rw-r--r--tdeprint/cups/kmwippselect.cpp108
-rw-r--r--tdeprint/cups/kmwippselect.h40
-rw-r--r--tdeprint/cups/kmwother.cpp125
-rw-r--r--tdeprint/cups/kmwother.h46
-rw-r--r--tdeprint/cups/kmwquota.cpp171
-rw-r--r--tdeprint/cups/kmwquota.h46
-rw-r--r--tdeprint/cups/kmwusers.cpp96
-rw-r--r--tdeprint/cups/kmwusers.h43
-rw-r--r--tdeprint/cups/kphpgl2page.cpp169
-rw-r--r--tdeprint/cups/kphpgl2page.h42
-rw-r--r--tdeprint/cups/kpimagepage.cpp503
-rw-r--r--tdeprint/cups/kpimagepage.h56
-rw-r--r--tdeprint/cups/kpschedulepage.cpp282
-rw-r--r--tdeprint/cups/kpschedulepage.h52
-rw-r--r--tdeprint/cups/kptagspage.cpp164
-rw-r--r--tdeprint/cups/kptagspage.h44
-rw-r--r--tdeprint/cups/kptextpage.cpp375
-rw-r--r--tdeprint/cups/kptextpage.h57
-rw-r--r--tdeprint/cups/make_driver_db_cups.c149
-rw-r--r--tdeprint/cups/postscript.ppd.gzbin0 -> 2317 bytes
-rw-r--r--tdeprint/cups/preview-mini.pngbin0 -> 1809 bytes
-rw-r--r--tdeprint/cups/preview.pngbin0 -> 12738 bytes
-rw-r--r--tdeprint/driver.cpp714
-rw-r--r--tdeprint/driver.h383
-rw-r--r--tdeprint/driveritem.cpp151
-rw-r--r--tdeprint/driveritem.h47
-rw-r--r--tdeprint/driverparse.c434
-rw-r--r--tdeprint/driverparse.h30
-rw-r--r--tdeprint/driverview.cpp157
-rw-r--r--tdeprint/driverview.h62
-rw-r--r--tdeprint/droptionview.cpp358
-rw-r--r--tdeprint/droptionview.h136
-rw-r--r--tdeprint/ext/CMakeLists.txt50
-rw-r--r--tdeprint/ext/Makefile.am15
-rw-r--r--tdeprint/ext/ext.print84
-rw-r--r--tdeprint/ext/kextprinterimpl.cpp52
-rw-r--r--tdeprint/ext/kextprinterimpl.h35
-rw-r--r--tdeprint/ext/kmextfactory.cpp28
-rw-r--r--tdeprint/ext/kmextmanager.cpp49
-rw-r--r--tdeprint/ext/kmextmanager.h40
-rw-r--r--tdeprint/ext/kmextuimanager.cpp44
-rw-r--r--tdeprint/ext/kmextuimanager.h35
-rw-r--r--tdeprint/filters/CMakeLists.txt23
-rw-r--r--tdeprint/filters/Makefile.am14
-rw-r--r--tdeprint/filters/enscript.desktop104
-rw-r--r--tdeprint/filters/enscript.xml38
-rwxr-xr-xtdeprint/filters/imagetops69
-rw-r--r--tdeprint/filters/imagetops.desktop107
-rw-r--r--tdeprint/filters/imagetops.xml25
-rw-r--r--tdeprint/filters/pdf2ps.desktop40
-rw-r--r--tdeprint/filters/pdf2ps.xml152
-rw-r--r--tdeprint/filters/pdfwrite.desktop102
-rw-r--r--tdeprint/filters/pdfwrite.xml14
-rw-r--r--tdeprint/filters/poster.desktop163
-rw-r--r--tdeprint/filters/poster.xml82
-rw-r--r--tdeprint/filters/ps2pdf.desktop92
-rw-r--r--tdeprint/filters/ps2pdf.xml152
-rw-r--r--tdeprint/filters/psbook.desktop93
-rw-r--r--tdeprint/filters/psbook.xml14
-rw-r--r--tdeprint/filters/psbook1.desktop94
-rw-r--r--tdeprint/filters/psbook1.xml14
-rw-r--r--tdeprint/filters/psbook2.desktop95
-rw-r--r--tdeprint/filters/psbook2.xml14
-rw-r--r--tdeprint/filters/psnup.desktop89
-rw-r--r--tdeprint/filters/psnup.xml32
-rw-r--r--tdeprint/filters/psresize.desktop99
-rw-r--r--tdeprint/filters/psresize.xml24
-rw-r--r--tdeprint/filters/psselect.desktop97
-rw-r--r--tdeprint/filters/psselect.xml24
-rw-r--r--tdeprint/foomatic/Makefile.am20
-rw-r--r--tdeprint/foomatic/foomatic.print17
-rw-r--r--tdeprint/foomatic/kfoomaticprinterimpl.cpp53
-rw-r--r--tdeprint/foomatic/kfoomaticprinterimpl.h37
-rw-r--r--tdeprint/foomatic/kmfoomaticfactory.cpp27
-rw-r--r--tdeprint/foomatic/kmfoomaticmanager.cpp197
-rw-r--r--tdeprint/foomatic/kmfoomaticmanager.h42
-rw-r--r--tdeprint/foomatic/make_driver_db_foomatic.c192
-rw-r--r--tdeprint/foomatic2loader.cpp302
-rw-r--r--tdeprint/foomatic2loader.h57
-rw-r--r--tdeprint/fooparser.cpp1005
-rw-r--r--tdeprint/fooparser.cpp.h15
-rw-r--r--tdeprint/fooparser.y70
-rw-r--r--tdeprint/fooscanner.cpp1707
-rw-r--r--tdeprint/fooscanner.l83
-rw-r--r--tdeprint/kfilelist.cpp326
-rw-r--r--tdeprint/kfilelist.h62
-rw-r--r--tdeprint/kmdbentry.cpp62
-rw-r--r--tdeprint/kmdbentry.h52
-rw-r--r--tdeprint/kmfactory.cpp453
-rw-r--r--tdeprint/kmfactory.h129
-rw-r--r--tdeprint/kmjob.cpp136
-rw-r--r--tdeprint/kmjob.h130
-rw-r--r--tdeprint/kmjobmanager.cpp257
-rw-r--r--tdeprint/kmjobmanager.h109
-rw-r--r--tdeprint/kmmanager.cpp556
-rw-r--r--tdeprint/kmmanager.h183
-rw-r--r--tdeprint/kmobject.h56
-rw-r--r--tdeprint/kmprinter.cpp224
-rw-r--r--tdeprint/kmprinter.h236
-rw-r--r--tdeprint/kmspecialmanager.cpp228
-rw-r--r--tdeprint/kmspecialmanager.h52
-rw-r--r--tdeprint/kmthreadjob.cpp170
-rw-r--r--tdeprint/kmthreadjob.h53
-rw-r--r--tdeprint/kmuimanager.cpp201
-rw-r--r--tdeprint/kmuimanager.h94
-rw-r--r--tdeprint/kmvirtualmanager.cpp371
-rw-r--r--tdeprint/kmvirtualmanager.h75
-rw-r--r--tdeprint/kpcopiespage.cpp349
-rw-r--r--tdeprint/kpcopiespage.h64
-rw-r--r--tdeprint/kpdriverpage.cpp63
-rw-r--r--tdeprint/kpdriverpage.h41
-rw-r--r--tdeprint/kpfileselectpage.cpp65
-rw-r--r--tdeprint/kpfileselectpage.h40
-rw-r--r--tdeprint/kpfilterpage.cpp416
-rw-r--r--tdeprint/kpfilterpage.h68
-rw-r--r--tdeprint/kpgeneralpage.cpp736
-rw-r--r--tdeprint/kpgeneralpage.h57
-rw-r--r--tdeprint/kpipeprocess.cpp60
-rw-r--r--tdeprint/kpipeprocess.h41
-rw-r--r--tdeprint/kpmarginpage.cpp163
-rw-r--r--tdeprint/kpmarginpage.h47
-rw-r--r--tdeprint/kpposterpage.cpp341
-rw-r--r--tdeprint/kpposterpage.h60
-rw-r--r--tdeprint/kpqtpage.cpp336
-rw-r--r--tdeprint/kpqtpage.h57
-rw-r--r--tdeprint/kpreloadobject.cpp32
-rw-r--r--tdeprint/kpreloadobject.h38
-rw-r--r--tdeprint/kprintaction.cpp130
-rw-r--r--tdeprint/kprintaction.h57
-rw-r--r--tdeprint/kprintdialog.cpp987
-rw-r--r--tdeprint/kprintdialog.h88
-rw-r--r--tdeprint/kprintdialogpage.cpp49
-rw-r--r--tdeprint/kprintdialogpage.h190
-rw-r--r--tdeprint/kprinter.cpp1045
-rw-r--r--tdeprint/kprinter.h780
-rw-r--r--tdeprint/kprinterimpl.cpp606
-rw-r--r--tdeprint/kprinterimpl.h70
-rw-r--r--tdeprint/kprinterpropertydialog.cpp147
-rw-r--r--tdeprint/kprinterpropertydialog.h69
-rw-r--r--tdeprint/kprintpreview.cpp328
-rw-r--r--tdeprint/kprintpreview.h65
-rw-r--r--tdeprint/kprintpreviewui.rc27
-rw-r--r--tdeprint/kprintprocess.cpp94
-rw-r--r--tdeprint/kprintprocess.h90
-rw-r--r--tdeprint/kxmlcommand.cpp830
-rw-r--r--tdeprint/kxmlcommand.h121
-rw-r--r--tdeprint/lpd/Makefile.am18
-rw-r--r--tdeprint/lpd/gschecker.cpp61
-rw-r--r--tdeprint/lpd/gschecker.h40
-rw-r--r--tdeprint/lpd/klpdprinterimpl.cpp51
-rw-r--r--tdeprint/lpd/klpdprinterimpl.h37
-rw-r--r--tdeprint/lpd/kmlpdfactory.cpp52
-rw-r--r--tdeprint/lpd/kmlpdfactory.h35
-rw-r--r--tdeprint/lpd/kmlpdmanager.cpp651
-rw-r--r--tdeprint/lpd/kmlpdmanager.h76
-rw-r--r--tdeprint/lpd/kmlpduimanager.cpp60
-rw-r--r--tdeprint/lpd/kmlpduimanager.h35
-rw-r--r--tdeprint/lpd/lpd.print87
-rw-r--r--tdeprint/lpd/lpdtools.cpp417
-rw-r--r--tdeprint/lpd/lpdtools.h76
-rw-r--r--tdeprint/lpd/make_driver_db_lpd.c112
-rw-r--r--tdeprint/lpdunix/CMakeLists.txt52
-rw-r--r--tdeprint/lpdunix/Makefile.am15
-rw-r--r--tdeprint/lpdunix/klpdunixprinterimpl.cpp83
-rw-r--r--tdeprint/lpdunix/klpdunixprinterimpl.h41
-rw-r--r--tdeprint/lpdunix/kmlpdunixfactory.cpp29
-rw-r--r--tdeprint/lpdunix/kmlpdunixmanager.cpp410
-rw-r--r--tdeprint/lpdunix/kmlpdunixmanager.h42
-rw-r--r--tdeprint/lpdunix/kmlpdunixuimanager.cpp45
-rw-r--r--tdeprint/lpdunix/kmlpdunixuimanager.h35
-rw-r--r--tdeprint/lpdunix/lpdunix.print83
-rw-r--r--tdeprint/lpr/CMakeLists.txt80
-rw-r--r--tdeprint/lpr/Makefile.am40
-rw-r--r--tdeprint/lpr/apsdriver184
-rw-r--r--tdeprint/lpr/apsdriver283
-rw-r--r--tdeprint/lpr/apshandler.cpp405
-rw-r--r--tdeprint/lpr/apshandler.h57
-rw-r--r--tdeprint/lpr/editentrydialog.cpp157
-rw-r--r--tdeprint/lpr/editentrydialog.h62
-rw-r--r--tdeprint/lpr/klprfactory.cpp29
-rw-r--r--tdeprint/lpr/klprprinterimpl.cpp59
-rw-r--r--tdeprint/lpr/klprprinterimpl.h38
-rw-r--r--tdeprint/lpr/kmconfiglpr.cpp66
-rw-r--r--tdeprint/lpr/kmconfiglpr.h39
-rw-r--r--tdeprint/lpr/kmlprjobmanager.cpp90
-rw-r--r--tdeprint/lpr/kmlprjobmanager.h44
-rw-r--r--tdeprint/lpr/kmlprmanager.cpp492
-rw-r--r--tdeprint/lpr/kmlprmanager.h82
-rw-r--r--tdeprint/lpr/kmlpruimanager.cpp67
-rw-r--r--tdeprint/lpr/kmlpruimanager.h37
-rw-r--r--tdeprint/lpr/lpchelper.cpp320
-rw-r--r--tdeprint/lpr/lpchelper.h59
-rw-r--r--tdeprint/lpr/lpqhelper.cpp117
-rw-r--r--tdeprint/lpr/lpqhelper.h44
-rw-r--r--tdeprint/lpr/lpr.print86
-rw-r--r--tdeprint/lpr/lprhandler.cpp270
-rw-r--r--tdeprint/lpr/lprhandler.h88
-rw-r--r--tdeprint/lpr/lprngtooldriver185
-rw-r--r--tdeprint/lpr/lprngtoolhandler.cpp393
-rw-r--r--tdeprint/lpr/lprngtoolhandler.h54
-rw-r--r--tdeprint/lpr/lprsettings.cpp146
-rw-r--r--tdeprint/lpr/lprsettings.h67
-rw-r--r--tdeprint/lpr/make_driver_db_lpr.c192
-rw-r--r--tdeprint/lpr/matichandler.cpp481
-rw-r--r--tdeprint/lpr/matichandler.h57
-rw-r--r--tdeprint/lpr/matichelper.cpp38
-rw-r--r--tdeprint/lpr/matichelper.h29
-rw-r--r--tdeprint/lpr/printcapentry.cpp82
-rw-r--r--tdeprint/lpr/printcapentry.h81
-rw-r--r--tdeprint/lpr/printcapreader.cpp176
-rw-r--r--tdeprint/lpr/printcapreader.h43
-rw-r--r--tdeprint/management/CMakeLists.txt111
-rw-r--r--tdeprint/management/Makefile.am52
-rw-r--r--tdeprint/management/cjanuswidget.cpp265
-rw-r--r--tdeprint/management/cjanuswidget.h64
-rw-r--r--tdeprint/management/jobitem.cpp74
-rw-r--r--tdeprint/management/jobitem.h55
-rw-r--r--tdeprint/management/kaddprinterwizard.cpp39
-rw-r--r--tdeprint/management/kiconselectaction.cpp118
-rw-r--r--tdeprint/management/kiconselectaction.h49
-rw-r--r--tdeprint/management/kmconfigcommand.cpp53
-rw-r--r--tdeprint/management/kmconfigcommand.h31
-rw-r--r--tdeprint/management/kmconfigdialog.cpp89
-rw-r--r--tdeprint/management/kmconfigdialog.h43
-rw-r--r--tdeprint/management/kmconfigfilter.cpp159
-rw-r--r--tdeprint/management/kmconfigfilter.h52
-rw-r--r--tdeprint/management/kmconfigfonts.cpp182
-rw-r--r--tdeprint/management/kmconfigfonts.h54
-rw-r--r--tdeprint/management/kmconfiggeneral.cpp142
-rw-r--r--tdeprint/management/kmconfiggeneral.h50
-rw-r--r--tdeprint/management/kmconfigjobs.cpp63
-rw-r--r--tdeprint/management/kmconfigjobs.h40
-rw-r--r--tdeprint/management/kmconfigpage.cpp36
-rw-r--r--tdeprint/management/kmconfigpage.h53
-rw-r--r--tdeprint/management/kmconfigpreview.cpp74
-rw-r--r--tdeprint/management/kmconfigpreview.h41
-rw-r--r--tdeprint/management/kmdbcreator.cpp187
-rw-r--r--tdeprint/management/kmdbcreator.h58
-rw-r--r--tdeprint/management/kmdriverdb.cpp244
-rw-r--r--tdeprint/management/kmdriverdb.h67
-rw-r--r--tdeprint/management/kmdriverdbwidget.cpp273
-rw-r--r--tdeprint/management/kmdriverdbwidget.h74
-rw-r--r--tdeprint/management/kmdriverdialog.cpp55
-rw-r--r--tdeprint/management/kmdriverdialog.h44
-rw-r--r--tdeprint/management/kmiconview.cpp237
-rw-r--r--tdeprint/management/kmiconview.h78
-rw-r--r--tdeprint/management/kminfopage.cpp143
-rw-r--r--tdeprint/management/kminfopage.h42
-rw-r--r--tdeprint/management/kminstancepage.cpp276
-rw-r--r--tdeprint/management/kminstancepage.h58
-rw-r--r--tdeprint/management/kmjobviewer.cpp742
-rw-r--r--tdeprint/management/kmjobviewer.h127
-rw-r--r--tdeprint/management/kmlistview.cpp268
-rw-r--r--tdeprint/management/kmlistview.h59
-rw-r--r--tdeprint/management/kmmainview.cpp920
-rw-r--r--tdeprint/management/kmmainview.h133
-rw-r--r--tdeprint/management/kmpages.cpp74
-rw-r--r--tdeprint/management/kmpages.h44
-rw-r--r--tdeprint/management/kmprinterpage.h42
-rw-r--r--tdeprint/management/kmprinterview.cpp113
-rw-r--r--tdeprint/management/kmprinterview.h62
-rw-r--r--tdeprint/management/kmpropbackend.cpp86
-rw-r--r--tdeprint/management/kmpropbackend.h45
-rw-r--r--tdeprint/management/kmpropcontainer.cpp77
-rw-r--r--tdeprint/management/kmpropcontainer.h50
-rw-r--r--tdeprint/management/kmpropdriver.cpp83
-rw-r--r--tdeprint/management/kmpropdriver.h46
-rw-r--r--tdeprint/management/kmpropertypage.cpp94
-rw-r--r--tdeprint/management/kmpropertypage.h53
-rw-r--r--tdeprint/management/kmpropgeneral.cpp83
-rw-r--r--tdeprint/management/kmpropgeneral.h44
-rw-r--r--tdeprint/management/kmpropmembers.cpp70
-rw-r--r--tdeprint/management/kmpropmembers.h42
-rw-r--r--tdeprint/management/kmpropwidget.cpp86
-rw-r--r--tdeprint/management/kmpropwidget.h63
-rw-r--r--tdeprint/management/kmspecialprinterdlg.cpp222
-rw-r--r--tdeprint/management/kmspecialprinterdlg.h57
-rw-r--r--tdeprint/management/kmtimer.cpp96
-rw-r--r--tdeprint/management/kmtimer.h62
-rw-r--r--tdeprint/management/kmwbackend.cpp177
-rw-r--r--tdeprint/management/kmwbackend.h54
-rw-r--r--tdeprint/management/kmwclass.cpp141
-rw-r--r--tdeprint/management/kmwclass.h46
-rw-r--r--tdeprint/management/kmwdriver.cpp116
-rw-r--r--tdeprint/management/kmwdriver.h40
-rw-r--r--tdeprint/management/kmwdriverselect.cpp116
-rw-r--r--tdeprint/management/kmwdriverselect.h48
-rw-r--r--tdeprint/management/kmwdrivertest.cpp172
-rw-r--r--tdeprint/management/kmwdrivertest.h53
-rw-r--r--tdeprint/management/kmwend.cpp119
-rw-r--r--tdeprint/management/kmwend.h38
-rw-r--r--tdeprint/management/kmwfile.cpp77
-rw-r--r--tdeprint/management/kmwfile.h39
-rw-r--r--tdeprint/management/kmwinfobase.cpp90
-rw-r--r--tdeprint/management/kmwinfobase.h51
-rw-r--r--tdeprint/management/kmwinfopage.cpp48
-rw-r--r--tdeprint/management/kmwinfopage.h31
-rw-r--r--tdeprint/management/kmwizard.cpp262
-rw-r--r--tdeprint/management/kmwizard.h101
-rw-r--r--tdeprint/management/kmwizardpage.cpp48
-rw-r--r--tdeprint/management/kmwizardpage.h52
-rw-r--r--tdeprint/management/kmwlocal.cpp206
-rw-r--r--tdeprint/management/kmwlocal.h58
-rw-r--r--tdeprint/management/kmwlpd.cpp102
-rw-r--r--tdeprint/management/kmwlpd.h34
-rw-r--r--tdeprint/management/kmwname.cpp96
-rw-r--r--tdeprint/management/kmwname.h35
-rw-r--r--tdeprint/management/kmwpassword.cpp133
-rw-r--r--tdeprint/management/kmwpassword.h43
-rw-r--r--tdeprint/management/kmwsmb.cpp119
-rw-r--r--tdeprint/management/kmwsmb.h50
-rw-r--r--tdeprint/management/kmwsocket.cpp151
-rw-r--r--tdeprint/management/kmwsocket.h51
-rw-r--r--tdeprint/management/kmwsocketutil.cpp219
-rw-r--r--tdeprint/management/kmwsocketutil.h76
-rw-r--r--tdeprint/management/kxmlcommanddlg.cpp1059
-rw-r--r--tdeprint/management/kxmlcommanddlg.h127
-rw-r--r--tdeprint/management/kxmlcommandselector.cpp285
-rw-r--r--tdeprint/management/kxmlcommandselector.h68
-rw-r--r--tdeprint/management/networkscanner.cpp421
-rw-r--r--tdeprint/management/networkscanner.h95
-rw-r--r--tdeprint/management/pluginaction.cpp34
-rw-r--r--tdeprint/management/pluginaction.h42
-rw-r--r--tdeprint/management/side.pngbin0 -> 50353 bytes
-rw-r--r--tdeprint/management/sidepixmap.cpp69
-rw-r--r--tdeprint/management/sidepixmap.h42
-rw-r--r--tdeprint/management/smbview.cpp292
-rw-r--r--tdeprint/management/smbview.h67
-rw-r--r--tdeprint/management/tdeprint_management_module.cpp56
-rw-r--r--tdeprint/management/tiledown.pngbin0 -> 323 bytes
-rw-r--r--tdeprint/management/tileup.pngbin0 -> 241 bytes
-rw-r--r--tdeprint/marginpreview.cpp331
-rw-r--r--tdeprint/marginpreview.h65
-rw-r--r--tdeprint/marginvaluewidget.cpp126
-rw-r--r--tdeprint/marginvaluewidget.h57
-rw-r--r--tdeprint/marginwidget.cpp376
-rw-r--r--tdeprint/marginwidget.h75
-rw-r--r--tdeprint/messagewindow.cpp121
-rw-r--r--tdeprint/messagewindow.h55
-rw-r--r--tdeprint/pics/CMakeLists.txt41
-rw-r--r--tdeprint/pics/Makefile.am22
-rw-r--r--tdeprint/pics/cr16-action-filterstop.pngbin0 -> 740 bytes
-rw-r--r--tdeprint/pics/cr16-action-tdeprint_restartsrv.pngbin0 -> 941 bytes
-rw-r--r--tdeprint/pics/cr16-action-tdeprint_uploadsmb.pngbin0 -> 985 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_computer.pngbin0 -> 913 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_job.pngbin0 -> 474 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_job_cancelled.pngbin0 -> 652 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_job_completed.pngbin0 -> 634 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_job_error.pngbin0 -> 646 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_job_process.pngbin0 -> 729 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_job_stopped.pngbin0 -> 651 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer.pngbin0 -> 668 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_class.pngbin0 -> 769 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_class_process.pngbin0 -> 871 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_class_stopped.pngbin0 -> 888 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_defect.pngbin0 -> 847 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_process.pngbin0 -> 770 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_remote.pngbin0 -> 692 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_remote_process.pngbin0 -> 804 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_remote_stopped.pngbin0 -> 838 bytes
-rw-r--r--tdeprint/pics/cr16-app-tdeprint_printer_stopped.pngbin0 -> 827 bytes
-rw-r--r--tdeprint/pics/cr22-action-history.pngbin0 -> 1515 bytes
-rw-r--r--tdeprint/pics/cr22-action-package_utilities.pngbin0 -> 1430 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_addprinter.pngbin0 -> 1218 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_addpseudo.pngbin0 -> 1261 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_configmgr.pngbin0 -> 974 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_configsrv.pngbin0 -> 1356 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_defaulthard.pngbin0 -> 1239 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_defaultsoft.pngbin0 -> 1317 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_enableprinter.pngbin0 -> 769 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_printer.pngbin0 -> 1001 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_printer_infos.pngbin0 -> 1244 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_printstate.pngbin0 -> 1029 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_queuestate.pngbin0 -> 1339 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_report.pngbin0 -> 818 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_restartsrv.pngbin0 -> 1455 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_stopprinter.pngbin0 -> 1330 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_testprinter.pngbin0 -> 1021 bytes
-rw-r--r--tdeprint/pics/cr22-action-tdeprint_uploadsmb.pngbin0 -> 1566 bytes
-rw-r--r--tdeprint/pics/cr22-app-tdeprint_printer.pngbin0 -> 1001 bytes
-rw-r--r--tdeprint/pics/cr32-action-tdeprint_inklevel.pngbin0 -> 2209 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer.pngbin0 -> 1331 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_class.pngbin0 -> 1803 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_class_process.pngbin0 -> 1955 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_class_stopped.pngbin0 -> 2232 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_defect.pngbin0 -> 1960 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_process.pngbin0 -> 1558 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_remote.pngbin0 -> 1398 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_remote_process.pngbin0 -> 1595 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_remote_stopped.pngbin0 -> 1924 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_stopped.pngbin0 -> 1915 bytes
-rw-r--r--tdeprint/pics/cr32-app-tdeprint_printer_users.pngbin0 -> 1939 bytes
-rw-r--r--tdeprint/pics/cr48-app-tdeprint_printer.pngbin0 -> 2140 bytes
-rw-r--r--tdeprint/pics/cr48-app-tdeprint_printer_class.pngbin0 -> 2931 bytes
-rw-r--r--tdeprint/pics/cr64-app-tdeprint_printer.pngbin0 -> 2940 bytes
-rw-r--r--tdeprint/pics/cr64-app-tdeprint_printer_class.pngbin0 -> 3930 bytes
-rw-r--r--tdeprint/pics/processsign.pngbin0 -> 423 bytes
-rw-r--r--tdeprint/pics/stopsign.pngbin0 -> 890 bytes
-rw-r--r--tdeprint/pics/tdeprint_collate.pngbin0 -> 1846 bytes
-rw-r--r--tdeprint/pics/tdeprint_collate_reverse.pngbin0 -> 1807 bytes
-rw-r--r--tdeprint/pics/tdeprint_color.pngbin0 -> 2503 bytes
-rw-r--r--tdeprint/pics/tdeprint_dupl_none.pngbin0 -> 680 bytes
-rw-r--r--tdeprint/pics/tdeprint_duplex_long.pngbin0 -> 249 bytes
-rw-r--r--tdeprint/pics/tdeprint_duplex_none.pngbin0 -> 231 bytes
-rw-r--r--tdeprint/pics/tdeprint_duplex_short.pngbin0 -> 267 bytes
-rw-r--r--tdeprint/pics/tdeprint_grayscale.pngbin0 -> 1121 bytes
-rw-r--r--tdeprint/pics/tdeprint_landscape.pngbin0 -> 884 bytes
-rw-r--r--tdeprint/pics/tdeprint_nup1.pngbin0 -> 320 bytes
-rw-r--r--tdeprint/pics/tdeprint_nup2.pngbin0 -> 317 bytes
-rw-r--r--tdeprint/pics/tdeprint_nup4.pngbin0 -> 322 bytes
-rw-r--r--tdeprint/pics/tdeprint_nupother.pngbin0 -> 406 bytes
-rw-r--r--tdeprint/pics/tdeprint_opt_duplex.pngbin0 -> 1111 bytes
-rw-r--r--tdeprint/pics/tdeprint_pagesize.pngbin0 -> 289 bytes
-rw-r--r--tdeprint/pics/tdeprint_portrait.pngbin0 -> 891 bytes
-rw-r--r--tdeprint/pics/tdeprint_prettyprint.pngbin0 -> 335 bytes
-rw-r--r--tdeprint/pics/tdeprint_revlandscape.pngbin0 -> 891 bytes
-rw-r--r--tdeprint/pics/tdeprint_revportrait.pngbin0 -> 895 bytes
-rw-r--r--tdeprint/pics/tdeprint_uncollate.pngbin0 -> 2003 bytes
-rw-r--r--tdeprint/pics/tdeprint_uncollate_reverse.pngbin0 -> 2034 bytes
-rw-r--r--tdeprint/plugincombobox.cpp104
-rw-r--r--tdeprint/plugincombobox.h50
-rw-r--r--tdeprint/posterpreview.cpp294
-rw-r--r--tdeprint/posterpreview.h75
-rw-r--r--tdeprint/ppdloader.cpp531
-rw-r--r--tdeprint/ppdloader.h74
-rw-r--r--tdeprint/ppdparser.cpp1456
-rw-r--r--tdeprint/ppdparser.cpp.h81
-rw-r--r--tdeprint/ppdparser.y118
-rw-r--r--tdeprint/ppdscanner.cpp1914
-rw-r--r--tdeprint/ppdscanner.l141
-rw-r--r--tdeprint/printerfilter.cpp71
-rw-r--r--tdeprint/printerfilter.h49
-rw-r--r--tdeprint/rlpr/CMakeLists.txt54
-rw-r--r--tdeprint/rlpr/Makefile.am17
-rw-r--r--tdeprint/rlpr/kmconfigproxy.cpp47
-rw-r--r--tdeprint/rlpr/kmconfigproxy.h40
-rw-r--r--tdeprint/rlpr/kmproprlpr.cpp75
-rw-r--r--tdeprint/rlpr/kmproprlpr.h43
-rw-r--r--tdeprint/rlpr/kmproxywidget.cpp71
-rw-r--r--tdeprint/rlpr/kmproxywidget.h43
-rw-r--r--tdeprint/rlpr/kmrlprfactory.cpp28
-rw-r--r--tdeprint/rlpr/kmrlprmanager.cpp158
-rw-r--r--tdeprint/rlpr/kmrlprmanager.h48
-rw-r--r--tdeprint/rlpr/kmrlpruimanager.cpp55
-rw-r--r--tdeprint/rlpr/kmrlpruimanager.h36
-rw-r--r--tdeprint/rlpr/kmwrlpr.cpp210
-rw-r--r--tdeprint/rlpr/kmwrlpr.h50
-rw-r--r--tdeprint/rlpr/krlprprinterimpl.cpp76
-rw-r--r--tdeprint/rlpr/krlprprinterimpl.h36
-rw-r--r--tdeprint/rlpr/rlpr.print84
-rw-r--r--tdeprint/signal_proc.c136
-rw-r--r--tdeprint/specials.desktop1196
-rw-r--r--tdeprint/tdeprintcheck.cpp134
-rw-r--r--tdeprint/tdeprintcheck.h41
-rw-r--r--tdeprint/tdeprintd.cpp315
-rw-r--r--tdeprint/tdeprintd.desktop162
-rw-r--r--tdeprint/tdeprintd.h66
-rw-r--r--tdeprint/tdeprintrc7
-rw-r--r--tdeprint/tdeprintrc.upd6
-rw-r--r--tdeprint/testprint.ps522
-rw-r--r--tdeprint/tests/Makefile.am15
-rw-r--r--tdeprint/tests/back.xpm105
-rw-r--r--tdeprint/tests/drawdemo.cpp253
-rw-r--r--tdeprint/tests/drawdemo.h30
-rw-r--r--tdeprint/tests/forward.xpm110
-rw-r--r--tdeprint/tests/helpwindow.cpp351
-rw-r--r--tdeprint/tests/helpwindow.h65
-rw-r--r--tdeprint/tests/home.xpm119
-rw-r--r--tdeprint/tests/main.cpp41
-rw-r--r--tdeprint/tests/richpage.cpp85
-rw-r--r--tdeprint/tests/richpage.h24
-rw-r--r--tdeprint/tools/CMakeLists.txt12
-rw-r--r--tdeprint/tools/Makefile.am1
-rw-r--r--tdeprint/tools/escputil/CMakeLists.txt42
-rw-r--r--tdeprint/tools/escputil/Makefile.am12
-rw-r--r--tdeprint/tools/escputil/escputil.desktop29
-rw-r--r--tdeprint/tools/escputil/escpwidget.cpp261
-rw-r--r--tdeprint/tools/escputil/escpwidget.h57
-rw-r--r--tdeprint/treecombobox.cpp156
-rw-r--r--tdeprint/treecombobox.h76
-rw-r--r--tdeprint/util.cpp139
-rw-r--r--tdeprint/util.h76
586 files changed, 71898 insertions, 0 deletions
diff --git a/tdeprint/CMakeLists.txt b/tdeprint/CMakeLists.txt
new file mode 100644
index 000000000..bdbacc0bb
--- /dev/null
+++ b/tdeprint/CMakeLists.txt
@@ -0,0 +1,124 @@
+#################################################
+#
+# (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/tdeprint/ChangeLog b/tdeprint/ChangeLog
new file mode 100644
index 000000000..5ce11bd36
--- /dev/null
+++ b/tdeprint/ChangeLog
@@ -0,0 +1,619 @@
+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/tdeprint/Makefile.am b/tdeprint/Makefile.am
new file mode 100644
index 000000000..fecf25c64
--- /dev/null
+++ b/tdeprint/Makefile.am
@@ -0,0 +1,114 @@
+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/tdeprint/TODO b/tdeprint/TODO
new file mode 100644
index 000000000..7c67dccdb
--- /dev/null
+++ b/tdeprint/TODO
@@ -0,0 +1,75 @@
+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/tdeprint/TODO.cups12 b/tdeprint/TODO.cups12
new file mode 100644
index 000000000..436f7d0b0
--- /dev/null
+++ b/tdeprint/TODO.cups12
@@ -0,0 +1,293 @@
+
+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/tdeprint/configure.in.in b/tdeprint/configure.in.in
new file mode 100644
index 000000000..3165cc4c4
--- /dev/null
+++ b/tdeprint/configure.in.in
@@ -0,0 +1,99 @@
+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/tdeprint/cups/CMakeLists.txt b/tdeprint/cups/CMakeLists.txt
new file mode 100644
index 000000000..2166cc08f
--- /dev/null
+++ b/tdeprint/cups/CMakeLists.txt
@@ -0,0 +1,97 @@
+#################################################
+#
+# (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/tdeprint/cups/Makefile.am b/tdeprint/cups/Makefile.am
new file mode 100644
index 000000000..6f3d7edec
--- /dev/null
+++ b/tdeprint/cups/Makefile.am
@@ -0,0 +1,49 @@
+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/tdeprint/cups/configure.in.in b/tdeprint/cups/configure.in.in
new file mode 100644
index 000000000..b37ba67a1
--- /dev/null
+++ b/tdeprint/cups/configure.in.in
@@ -0,0 +1,18 @@
+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/tdeprint/cups/cups.print b/tdeprint/cups/cups.print
new file mode 100644
index 000000000..03b2474ee
--- /dev/null
+++ b/tdeprint/cups/cups.print
@@ -0,0 +1,68 @@
+[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/tdeprint/cups/cupsaddsmb2.cpp b/tdeprint/cups/cupsaddsmb2.cpp
new file mode 100644
index 000000000..ca40a10a7
--- /dev/null
+++ b/tdeprint/cups/cupsaddsmb2.cpp
@@ -0,0 +1,476 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsaddsmb2.h b/tdeprint/cups/cupsaddsmb2.h
new file mode 100644
index 000000000..84166f53c
--- /dev/null
+++ b/tdeprint/cups/cupsaddsmb2.h
@@ -0,0 +1,77 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/CMakeLists.txt b/tdeprint/cups/cupsdconf2/CMakeLists.txt
new file mode 100644
index 000000000..ceee1bc47
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/CMakeLists.txt
@@ -0,0 +1,54 @@
+#################################################
+#
+# (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/tdeprint/cups/cupsdconf2/Makefile.am b/tdeprint/cups/cupsdconf2/Makefile.am
new file mode 100644
index 000000000..434af6a3c
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/Makefile.am
@@ -0,0 +1,35 @@
+#$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/tdeprint/cups/cupsdconf2/addressdialog.cpp b/tdeprint/cups/cupsdconf2/addressdialog.cpp
new file mode 100644
index 000000000..fab6a6fba
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/addressdialog.cpp
@@ -0,0 +1,89 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/addressdialog.h b/tdeprint/cups/cupsdconf2/addressdialog.h
new file mode 100644
index 000000000..7fdb6fb6f
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/addressdialog.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/browsedialog.cpp b/tdeprint/cups/cupsdconf2/browsedialog.cpp
new file mode 100644
index 000000000..b337eb883
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/browsedialog.cpp
@@ -0,0 +1,150 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/browsedialog.h b/tdeprint/cups/cupsdconf2/browsedialog.h
new file mode 100644
index 000000000..8db12bc34
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/browsedialog.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cups-util.c b/tdeprint/cups/cupsdconf2/cups-util.c
new file mode 100644
index 000000000..eadd6b629
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cups-util.c
@@ -0,0 +1,557 @@
+#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/tdeprint/cups/cupsdconf2/cups-util.h b/tdeprint/cups/cupsdconf2/cups-util.h
new file mode 100644
index 000000000..9c23c0c5e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cups-util.h
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cups_logo.png b/tdeprint/cups/cupsdconf2/cups_logo.png
new file mode 100644
index 000000000..e6f9b5919
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cups_logo.png
Binary files differ
diff --git a/tdeprint/cups/cupsdconf2/cupsd.conf.template b/tdeprint/cups/cupsdconf2/cupsd.conf.template
new file mode 100644
index 000000000..08d4b9425
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsd.conf.template
@@ -0,0 +1,977 @@
+%%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 &quot;any&quot; 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/tdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp b/tdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp
new file mode 100644
index 000000000..4b056cdb0
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdbrowsingpage.cpp
@@ -0,0 +1,210 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdbrowsingpage.h b/tdeprint/cups/cupsdconf2/cupsdbrowsingpage.h
new file mode 100644
index 000000000..bdbff1844
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdbrowsingpage.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdcomment.cpp b/tdeprint/cups/cupsdconf2/cupsdcomment.cpp
new file mode 100644
index 000000000..d17c8bd0c
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdcomment.cpp
@@ -0,0 +1,136 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdcomment.h b/tdeprint/cups/cupsdconf2/cupsdcomment.h
new file mode 100644
index 000000000..35f9e0515
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdcomment.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdcomment.pl b/tdeprint/cups/cupsdconf2/cupsdcomment.pl
new file mode 100644
index 000000000..b3da5ee7e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdcomment.pl
@@ -0,0 +1,61 @@
+#!/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/tdeprint/cups/cupsdconf2/cupsdconf.cpp b/tdeprint/cups/cupsdconf2/cupsdconf.cpp
new file mode 100644
index 000000000..0cd041d48
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdconf.cpp
@@ -0,0 +1,884 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdconf.h b/tdeprint/cups/cupsdconf2/cupsdconf.h
new file mode 100644
index 000000000..70b4f591b
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdconf.h
@@ -0,0 +1,181 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsddialog.cpp b/tdeprint/cups/cupsdconf2/cupsddialog.cpp
new file mode 100644
index 000000000..e6338eb8c
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsddialog.cpp
@@ -0,0 +1,356 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsddialog.h b/tdeprint/cups/cupsdconf2/cupsddialog.h
new file mode 100644
index 000000000..85eee172e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsddialog.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsddirpage.cpp b/tdeprint/cups/cupsdconf2/cupsddirpage.cpp
new file mode 100644
index 000000000..268465a76
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsddirpage.cpp
@@ -0,0 +1,109 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsddirpage.h b/tdeprint/cups/cupsdconf2/cupsddirpage.h
new file mode 100644
index 000000000..571c79f21
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsddirpage.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdfilterpage.cpp b/tdeprint/cups/cupsdconf2/cupsdfilterpage.cpp
new file mode 100644
index 000000000..79c8a9401
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdfilterpage.cpp
@@ -0,0 +1,94 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdfilterpage.h b/tdeprint/cups/cupsdconf2/cupsdfilterpage.h
new file mode 100644
index 000000000..18fc5d405
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdfilterpage.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdjobspage.cpp b/tdeprint/cups/cupsdconf2/cupsdjobspage.cpp
new file mode 100644
index 000000000..f12f82f1e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdjobspage.cpp
@@ -0,0 +1,123 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdjobspage.h b/tdeprint/cups/cupsdconf2/cupsdjobspage.h
new file mode 100644
index 000000000..abbbd140d
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdjobspage.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdlogpage.cpp b/tdeprint/cups/cupsdconf2/cupsdlogpage.cpp
new file mode 100644
index 000000000..61a89f933
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdlogpage.cpp
@@ -0,0 +1,111 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdlogpage.h b/tdeprint/cups/cupsdconf2/cupsdlogpage.h
new file mode 100644
index 000000000..618f612be
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdlogpage.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp b/tdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp
new file mode 100644
index 000000000..9edca5868
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdnetworkpage.cpp
@@ -0,0 +1,159 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdnetworkpage.h b/tdeprint/cups/cupsdconf2/cupsdnetworkpage.h
new file mode 100644
index 000000000..be46c280f
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdnetworkpage.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdpage.cpp b/tdeprint/cups/cupsdconf2/cupsdpage.cpp
new file mode 100644
index 000000000..68bdde7a6
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdpage.cpp
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdpage.h b/tdeprint/cups/cupsdconf2/cupsdpage.h
new file mode 100644
index 000000000..aadbd54b9
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdpage.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp b/tdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp
new file mode 100644
index 000000000..092e1a7e5
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdsecuritypage.cpp
@@ -0,0 +1,168 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdsecuritypage.h b/tdeprint/cups/cupsdconf2/cupsdsecuritypage.h
new file mode 100644
index 000000000..5e97c1cf8
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdsecuritypage.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdserverpage.cpp b/tdeprint/cups/cupsdconf2/cupsdserverpage.cpp
new file mode 100644
index 000000000..cfd731430
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdserverpage.cpp
@@ -0,0 +1,181 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdserverpage.h b/tdeprint/cups/cupsdconf2/cupsdserverpage.h
new file mode 100644
index 000000000..f1f9eed2f
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdserverpage.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdsplash.cpp b/tdeprint/cups/cupsdconf2/cupsdsplash.cpp
new file mode 100644
index 000000000..c26b65fd7
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdsplash.cpp
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/cupsdsplash.h b/tdeprint/cups/cupsdconf2/cupsdsplash.h
new file mode 100644
index 000000000..f484958d4
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/cupsdsplash.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/editlist.cpp b/tdeprint/cups/cupsdconf2/editlist.cpp
new file mode 100644
index 000000000..754c9659e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/editlist.cpp
@@ -0,0 +1,124 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/editlist.h b/tdeprint/cups/cupsdconf2/editlist.h
new file mode 100644
index 000000000..a0fc7ee0a
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/editlist.h
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/kde_logo.png b/tdeprint/cups/cupsdconf2/kde_logo.png
new file mode 100644
index 000000000..6ba204607
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/kde_logo.png
Binary files differ
diff --git a/tdeprint/cups/cupsdconf2/locationdialog.cpp b/tdeprint/cups/cupsdconf2/locationdialog.cpp
new file mode 100644
index 000000000..7e1858cc7
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/locationdialog.cpp
@@ -0,0 +1,222 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/locationdialog.h b/tdeprint/cups/cupsdconf2/locationdialog.h
new file mode 100644
index 000000000..f0c182f42
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/locationdialog.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/main.cpp b/tdeprint/cups/cupsdconf2/main.cpp
new file mode 100644
index 000000000..f3c317afd
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/main.cpp
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/portdialog.cpp b/tdeprint/cups/cupsdconf2/portdialog.cpp
new file mode 100644
index 000000000..18cade9fc
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/portdialog.cpp
@@ -0,0 +1,118 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/portdialog.h b/tdeprint/cups/cupsdconf2/portdialog.h
new file mode 100644
index 000000000..42dd7037b
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/portdialog.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/qdirlineedit.cpp b/tdeprint/cups/cupsdconf2/qdirlineedit.cpp
new file mode 100644
index 000000000..7cf0ea74e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/qdirlineedit.cpp
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/qdirlineedit.h b/tdeprint/cups/cupsdconf2/qdirlineedit.h
new file mode 100644
index 000000000..d852897c3
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/qdirlineedit.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsdconf2/qdirmultilineedit.cpp b/tdeprint/cups/cupsdconf2/qdirmultilineedit.cpp
new file mode 100644
index 000000000..e677da988
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/qdirmultilineedit.cpp
@@ -0,0 +1,109 @@
+/*
+ * 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/tdeprint/cups/cupsdconf2/qdirmultilineedit.h b/tdeprint/cups/cupsdconf2/qdirmultilineedit.h
new file mode 100644
index 000000000..c3765362e
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/qdirmultilineedit.h
@@ -0,0 +1,53 @@
+/*
+ * 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/tdeprint/cups/cupsdconf2/sizewidget.cpp b/tdeprint/cups/cupsdconf2/sizewidget.cpp
new file mode 100644
index 000000000..742702e48
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/sizewidget.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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/tdeprint/cups/cupsdconf2/sizewidget.h b/tdeprint/cups/cupsdconf2/sizewidget.h
new file mode 100644
index 000000000..000fb22bc
--- /dev/null
+++ b/tdeprint/cups/cupsdconf2/sizewidget.h
@@ -0,0 +1,43 @@
+/*
+ * 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/tdeprint/cups/cupsdoprint.c b/tdeprint/cups/cupsdoprint.c
new file mode 100644
index 000000000..a12a2adf8
--- /dev/null
+++ b/tdeprint/cups/cupsdoprint.c
@@ -0,0 +1,257 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsinfos.cpp b/tdeprint/cups/cupsinfos.cpp
new file mode 100644
index 000000000..1fae8e0db
--- /dev/null
+++ b/tdeprint/cups/cupsinfos.cpp
@@ -0,0 +1,166 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/cupsinfos.h b/tdeprint/cups/cupsinfos.h
new file mode 100644
index 000000000..5f74d3636
--- /dev/null
+++ b/tdeprint/cups/cupsinfos.h
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/image.cpp b/tdeprint/cups/image.cpp
new file mode 100644
index 000000000..ce56bb4b9
--- /dev/null
+++ b/tdeprint/cups/image.cpp
@@ -0,0 +1,295 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/imageposition.cpp b/tdeprint/cups/imageposition.cpp
new file mode 100644
index 000000000..70a84ba7f
--- /dev/null
+++ b/tdeprint/cups/imageposition.cpp
@@ -0,0 +1,153 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/imageposition.h b/tdeprint/cups/imageposition.h
new file mode 100644
index 000000000..6d6645365
--- /dev/null
+++ b/tdeprint/cups/imageposition.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/imagepreview.cpp b/tdeprint/cups/imagepreview.cpp
new file mode 100644
index 000000000..2290f6a96
--- /dev/null
+++ b/tdeprint/cups/imagepreview.cpp
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/imagepreview.h b/tdeprint/cups/imagepreview.h
new file mode 100644
index 000000000..12a57ddb3
--- /dev/null
+++ b/tdeprint/cups/imagepreview.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/ippreportdlg.cpp b/tdeprint/cups/ippreportdlg.cpp
new file mode 100644
index 000000000..5fa54e11e
--- /dev/null
+++ b/tdeprint/cups/ippreportdlg.cpp
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/ippreportdlg.h b/tdeprint/cups/ippreportdlg.h
new file mode 100644
index 000000000..e61ccd7b7
--- /dev/null
+++ b/tdeprint/cups/ippreportdlg.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/ipprequest.cpp b/tdeprint/cups/ipprequest.cpp
new file mode 100644
index 000000000..16cbe3308
--- /dev/null
+++ b/tdeprint/cups/ipprequest.cpp
@@ -0,0 +1,544 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/ipprequest.h b/tdeprint/cups/ipprequest.h
new file mode 100644
index 000000000..ba8b2f081
--- /dev/null
+++ b/tdeprint/cups/ipprequest.h
@@ -0,0 +1,196 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kcupsprinterimpl.cpp b/tdeprint/cups/kcupsprinterimpl.cpp
new file mode 100644
index 000000000..e016e9954
--- /dev/null
+++ b/tdeprint/cups/kcupsprinterimpl.cpp
@@ -0,0 +1,159 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kcupsprinterimpl.h b/tdeprint/cups/kcupsprinterimpl.h
new file mode 100644
index 000000000..b86db8aac
--- /dev/null
+++ b/tdeprint/cups/kcupsprinterimpl.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmconfigcups.cpp b/tdeprint/cups/kmconfigcups.cpp
new file mode 100644
index 000000000..7e03dae01
--- /dev/null
+++ b/tdeprint/cups/kmconfigcups.cpp
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmconfigcups.h b/tdeprint/cups/kmconfigcups.h
new file mode 100644
index 000000000..c0f1ab2ba
--- /dev/null
+++ b/tdeprint/cups/kmconfigcups.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmconfigcupsdir.cpp b/tdeprint/cups/kmconfigcupsdir.cpp
new file mode 100644
index 000000000..fbec34f2a
--- /dev/null
+++ b/tdeprint/cups/kmconfigcupsdir.cpp
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmconfigcupsdir.h b/tdeprint/cups/kmconfigcupsdir.h
new file mode 100644
index 000000000..352388c99
--- /dev/null
+++ b/tdeprint/cups/kmconfigcupsdir.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsconfigwidget.cpp b/tdeprint/cups/kmcupsconfigwidget.cpp
new file mode 100644
index 000000000..482680bd6
--- /dev/null
+++ b/tdeprint/cups/kmcupsconfigwidget.cpp
@@ -0,0 +1,159 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsconfigwidget.h b/tdeprint/cups/kmcupsconfigwidget.h
new file mode 100644
index 000000000..7eee42d80
--- /dev/null
+++ b/tdeprint/cups/kmcupsconfigwidget.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsfactory.cpp b/tdeprint/cups/kmcupsfactory.cpp
new file mode 100644
index 000000000..47384eab6
--- /dev/null
+++ b/tdeprint/cups/kmcupsfactory.cpp
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsjobmanager.cpp b/tdeprint/cups/kmcupsjobmanager.cpp
new file mode 100644
index 000000000..58de0818a
--- /dev/null
+++ b/tdeprint/cups/kmcupsjobmanager.cpp
@@ -0,0 +1,452 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsjobmanager.h b/tdeprint/cups/kmcupsjobmanager.h
new file mode 100644
index 000000000..7e8a75a53
--- /dev/null
+++ b/tdeprint/cups/kmcupsjobmanager.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsmanager.cpp b/tdeprint/cups/kmcupsmanager.cpp
new file mode 100644
index 000000000..8db6bdc6d
--- /dev/null
+++ b/tdeprint/cups/kmcupsmanager.cpp
@@ -0,0 +1,1077 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsmanager.h b/tdeprint/cups/kmcupsmanager.h
new file mode 100644
index 000000000..d574bb686
--- /dev/null
+++ b/tdeprint/cups/kmcupsmanager.h
@@ -0,0 +1,106 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsuimanager.cpp b/tdeprint/cups/kmcupsuimanager.cpp
new file mode 100644
index 000000000..c3dfcb1ac
--- /dev/null
+++ b/tdeprint/cups/kmcupsuimanager.cpp
@@ -0,0 +1,219 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmcupsuimanager.h b/tdeprint/cups/kmcupsuimanager.h
new file mode 100644
index 000000000..6ad0f574f
--- /dev/null
+++ b/tdeprint/cups/kmcupsuimanager.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmpropbanners.cpp b/tdeprint/cups/kmpropbanners.cpp
new file mode 100644
index 000000000..22098cdff
--- /dev/null
+++ b/tdeprint/cups/kmpropbanners.cpp
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmpropbanners.h b/tdeprint/cups/kmpropbanners.h
new file mode 100644
index 000000000..770419dc5
--- /dev/null
+++ b/tdeprint/cups/kmpropbanners.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmpropquota.cpp b/tdeprint/cups/kmpropquota.cpp
new file mode 100644
index 000000000..9df6cbcb2
--- /dev/null
+++ b/tdeprint/cups/kmpropquota.cpp
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmpropquota.h b/tdeprint/cups/kmpropquota.h
new file mode 100644
index 000000000..8ebeb323b
--- /dev/null
+++ b/tdeprint/cups/kmpropquota.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmpropusers.cpp b/tdeprint/cups/kmpropusers.cpp
new file mode 100644
index 000000000..65a9e4dbd
--- /dev/null
+++ b/tdeprint/cups/kmpropusers.cpp
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmpropusers.h b/tdeprint/cups/kmpropusers.h
new file mode 100644
index 000000000..35e935adb
--- /dev/null
+++ b/tdeprint/cups/kmpropusers.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwbanners.cpp b/tdeprint/cups/kmwbanners.cpp
new file mode 100644
index 000000000..c221f69d7
--- /dev/null
+++ b/tdeprint/cups/kmwbanners.cpp
@@ -0,0 +1,145 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwbanners.h b/tdeprint/cups/kmwbanners.h
new file mode 100644
index 000000000..6f8650848
--- /dev/null
+++ b/tdeprint/cups/kmwbanners.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwfax.cpp b/tdeprint/cups/kmwfax.cpp
new file mode 100644
index 000000000..352081f6c
--- /dev/null
+++ b/tdeprint/cups/kmwfax.cpp
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwfax.h b/tdeprint/cups/kmwfax.h
new file mode 100644
index 000000000..1a822165e
--- /dev/null
+++ b/tdeprint/cups/kmwfax.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwipp.cpp b/tdeprint/cups/kmwipp.cpp
new file mode 100644
index 000000000..119da629a
--- /dev/null
+++ b/tdeprint/cups/kmwipp.cpp
@@ -0,0 +1,86 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwipp.h b/tdeprint/cups/kmwipp.h
new file mode 100644
index 000000000..33d02629b
--- /dev/null
+++ b/tdeprint/cups/kmwipp.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwippprinter.cpp b/tdeprint/cups/kmwippprinter.cpp
new file mode 100644
index 000000000..0a0c7b672
--- /dev/null
+++ b/tdeprint/cups/kmwippprinter.cpp
@@ -0,0 +1,227 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwippprinter.h b/tdeprint/cups/kmwippprinter.h
new file mode 100644
index 000000000..5d9d33f7a
--- /dev/null
+++ b/tdeprint/cups/kmwippprinter.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwippselect.cpp b/tdeprint/cups/kmwippselect.cpp
new file mode 100644
index 000000000..5c9cad356
--- /dev/null
+++ b/tdeprint/cups/kmwippselect.cpp
@@ -0,0 +1,108 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwippselect.h b/tdeprint/cups/kmwippselect.h
new file mode 100644
index 000000000..8d1711e8c
--- /dev/null
+++ b/tdeprint/cups/kmwippselect.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwother.cpp b/tdeprint/cups/kmwother.cpp
new file mode 100644
index 000000000..596f61990
--- /dev/null
+++ b/tdeprint/cups/kmwother.cpp
@@ -0,0 +1,125 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwother.h b/tdeprint/cups/kmwother.h
new file mode 100644
index 000000000..eba5ac2b1
--- /dev/null
+++ b/tdeprint/cups/kmwother.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwquota.cpp b/tdeprint/cups/kmwquota.cpp
new file mode 100644
index 000000000..67245fb20
--- /dev/null
+++ b/tdeprint/cups/kmwquota.cpp
@@ -0,0 +1,171 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwquota.h b/tdeprint/cups/kmwquota.h
new file mode 100644
index 000000000..d8895c80d
--- /dev/null
+++ b/tdeprint/cups/kmwquota.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwusers.cpp b/tdeprint/cups/kmwusers.cpp
new file mode 100644
index 000000000..714f6f4d4
--- /dev/null
+++ b/tdeprint/cups/kmwusers.cpp
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kmwusers.h b/tdeprint/cups/kmwusers.h
new file mode 100644
index 000000000..cae8844a6
--- /dev/null
+++ b/tdeprint/cups/kmwusers.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kphpgl2page.cpp b/tdeprint/cups/kphpgl2page.cpp
new file mode 100644
index 000000000..080cdf453
--- /dev/null
+++ b/tdeprint/cups/kphpgl2page.cpp
@@ -0,0 +1,169 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kphpgl2page.h b/tdeprint/cups/kphpgl2page.h
new file mode 100644
index 000000000..397efb1a8
--- /dev/null
+++ b/tdeprint/cups/kphpgl2page.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kpimagepage.cpp b/tdeprint/cups/kpimagepage.cpp
new file mode 100644
index 000000000..d3e438389
--- /dev/null
+++ b/tdeprint/cups/kpimagepage.cpp
@@ -0,0 +1,503 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kpimagepage.h b/tdeprint/cups/kpimagepage.h
new file mode 100644
index 000000000..1a6bc6e44
--- /dev/null
+++ b/tdeprint/cups/kpimagepage.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kpschedulepage.cpp b/tdeprint/cups/kpschedulepage.cpp
new file mode 100644
index 000000000..4d8bab4d1
--- /dev/null
+++ b/tdeprint/cups/kpschedulepage.cpp
@@ -0,0 +1,282 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kpschedulepage.h b/tdeprint/cups/kpschedulepage.h
new file mode 100644
index 000000000..4be11fab9
--- /dev/null
+++ b/tdeprint/cups/kpschedulepage.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kptagspage.cpp b/tdeprint/cups/kptagspage.cpp
new file mode 100644
index 000000000..d91a8b427
--- /dev/null
+++ b/tdeprint/cups/kptagspage.cpp
@@ -0,0 +1,164 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kptagspage.h b/tdeprint/cups/kptagspage.h
new file mode 100644
index 000000000..ac99072ec
--- /dev/null
+++ b/tdeprint/cups/kptagspage.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kptextpage.cpp b/tdeprint/cups/kptextpage.cpp
new file mode 100644
index 000000000..0bee387c6
--- /dev/null
+++ b/tdeprint/cups/kptextpage.cpp
@@ -0,0 +1,375 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/kptextpage.h b/tdeprint/cups/kptextpage.h
new file mode 100644
index 000000000..504e2d5c2
--- /dev/null
+++ b/tdeprint/cups/kptextpage.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/cups/make_driver_db_cups.c b/tdeprint/cups/make_driver_db_cups.c
new file mode 100644
index 000000000..b39dda8de
--- /dev/null
+++ b/tdeprint/cups/make_driver_db_cups.c
@@ -0,0 +1,149 @@
+#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/tdeprint/cups/postscript.ppd.gz b/tdeprint/cups/postscript.ppd.gz
new file mode 100644
index 000000000..92fd6862c
--- /dev/null
+++ b/tdeprint/cups/postscript.ppd.gz
Binary files differ
diff --git a/tdeprint/cups/preview-mini.png b/tdeprint/cups/preview-mini.png
new file mode 100644
index 000000000..7212eaf51
--- /dev/null
+++ b/tdeprint/cups/preview-mini.png
Binary files differ
diff --git a/tdeprint/cups/preview.png b/tdeprint/cups/preview.png
new file mode 100644
index 000000000..8e436dbd1
--- /dev/null
+++ b/tdeprint/cups/preview.png
Binary files differ
diff --git a/tdeprint/driver.cpp b/tdeprint/driver.cpp
new file mode 100644
index 000000000..072f125c6
--- /dev/null
+++ b/tdeprint/driver.cpp
@@ -0,0 +1,714 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/driver.h b/tdeprint/driver.h
new file mode 100644
index 000000000..7064e5335
--- /dev/null
+++ b/tdeprint/driver.h
@@ -0,0 +1,383 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/driveritem.cpp b/tdeprint/driveritem.cpp
new file mode 100644
index 000000000..b6531fef2
--- /dev/null
+++ b/tdeprint/driveritem.cpp
@@ -0,0 +1,151 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/driveritem.h b/tdeprint/driveritem.h
new file mode 100644
index 000000000..506cbe34d
--- /dev/null
+++ b/tdeprint/driveritem.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/driverparse.c b/tdeprint/driverparse.c
new file mode 100644
index 000000000..2b7a93d60
--- /dev/null
+++ b/tdeprint/driverparse.c
@@ -0,0 +1,434 @@
+#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, "&lt;h3&gt;Printer note&lt;/h3&gt;%s", comment2);
+ }
+ if (comment[0])
+ fprintf(output, "&lt;h3&gt;General driver note&lt;/h3&gt;%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/tdeprint/driverparse.h b/tdeprint/driverparse.h
new file mode 100644
index 000000000..775c81187
--- /dev/null
+++ b/tdeprint/driverparse.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/driverview.cpp b/tdeprint/driverview.cpp
new file mode 100644
index 000000000..f7feabb06
--- /dev/null
+++ b/tdeprint/driverview.cpp
@@ -0,0 +1,157 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/driverview.h b/tdeprint/driverview.h
new file mode 100644
index 000000000..4ec06c5fa
--- /dev/null
+++ b/tdeprint/driverview.h
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/droptionview.cpp b/tdeprint/droptionview.cpp
new file mode 100644
index 000000000..2ba4d1799
--- /dev/null
+++ b/tdeprint/droptionview.cpp
@@ -0,0 +1,358 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/droptionview.h b/tdeprint/droptionview.h
new file mode 100644
index 000000000..70f60a814
--- /dev/null
+++ b/tdeprint/droptionview.h
@@ -0,0 +1,136 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/CMakeLists.txt b/tdeprint/ext/CMakeLists.txt
new file mode 100644
index 000000000..9f4b2d629
--- /dev/null
+++ b/tdeprint/ext/CMakeLists.txt
@@ -0,0 +1,50 @@
+#################################################
+#
+# (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/tdeprint/ext/Makefile.am b/tdeprint/ext/Makefile.am
new file mode 100644
index 000000000..66e547c9d
--- /dev/null
+++ b/tdeprint/ext/Makefile.am
@@ -0,0 +1,15 @@
+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/tdeprint/ext/ext.print b/tdeprint/ext/ext.print
new file mode 100644
index 000000000..ce300e5ae
--- /dev/null
+++ b/tdeprint/ext/ext.print
@@ -0,0 +1,84 @@
+[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/tdeprint/ext/kextprinterimpl.cpp b/tdeprint/ext/kextprinterimpl.cpp
new file mode 100644
index 000000000..c976f54e0
--- /dev/null
+++ b/tdeprint/ext/kextprinterimpl.cpp
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/kextprinterimpl.h b/tdeprint/ext/kextprinterimpl.h
new file mode 100644
index 000000000..169e06bf4
--- /dev/null
+++ b/tdeprint/ext/kextprinterimpl.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/kmextfactory.cpp b/tdeprint/ext/kmextfactory.cpp
new file mode 100644
index 000000000..de8c58dfe
--- /dev/null
+++ b/tdeprint/ext/kmextfactory.cpp
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/kmextmanager.cpp b/tdeprint/ext/kmextmanager.cpp
new file mode 100644
index 000000000..598dd6648
--- /dev/null
+++ b/tdeprint/ext/kmextmanager.cpp
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/kmextmanager.h b/tdeprint/ext/kmextmanager.h
new file mode 100644
index 000000000..c7faab6cf
--- /dev/null
+++ b/tdeprint/ext/kmextmanager.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/kmextuimanager.cpp b/tdeprint/ext/kmextuimanager.cpp
new file mode 100644
index 000000000..2fa200848
--- /dev/null
+++ b/tdeprint/ext/kmextuimanager.cpp
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/ext/kmextuimanager.h b/tdeprint/ext/kmextuimanager.h
new file mode 100644
index 000000000..bca161c60
--- /dev/null
+++ b/tdeprint/ext/kmextuimanager.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/filters/CMakeLists.txt b/tdeprint/filters/CMakeLists.txt
new file mode 100644
index 000000000..2d36e16bb
--- /dev/null
+++ b/tdeprint/filters/CMakeLists.txt
@@ -0,0 +1,23 @@
+#################################################
+#
+# (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/tdeprint/filters/Makefile.am b/tdeprint/filters/Makefile.am
new file mode 100644
index 000000000..f9c9f9120
--- /dev/null
+++ b/tdeprint/filters/Makefile.am
@@ -0,0 +1,14 @@
+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/tdeprint/filters/enscript.desktop b/tdeprint/filters/enscript.desktop
new file mode 100644
index 000000000..1750977e5
--- /dev/null
+++ b/tdeprint/filters/enscript.desktop
@@ -0,0 +1,104 @@
+[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/tdeprint/filters/enscript.xml b/tdeprint/filters/enscript.xml
new file mode 100644
index 000000000..edf43716a
--- /dev/null
+++ b/tdeprint/filters/enscript.xml
@@ -0,0 +1,38 @@
+<?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/tdeprint/filters/imagetops b/tdeprint/filters/imagetops
new file mode 100755
index 000000000..634a2caf5
--- /dev/null
+++ b/tdeprint/filters/imagetops
@@ -0,0 +1,69 @@
+#!/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/tdeprint/filters/imagetops.desktop b/tdeprint/filters/imagetops.desktop
new file mode 100644
index 000000000..5d23f414a
--- /dev/null
+++ b/tdeprint/filters/imagetops.desktop
@@ -0,0 +1,107 @@
+[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/tdeprint/filters/imagetops.xml b/tdeprint/filters/imagetops.xml
new file mode 100644
index 000000000..aba7f883a
--- /dev/null
+++ b/tdeprint/filters/imagetops.xml
@@ -0,0 +1,25 @@
+<?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/tdeprint/filters/pdf2ps.desktop b/tdeprint/filters/pdf2ps.desktop
new file mode 100644
index 000000000..2f97c7289
--- /dev/null
+++ b/tdeprint/filters/pdf2ps.desktop
@@ -0,0 +1,40 @@
+[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/tdeprint/filters/pdf2ps.xml b/tdeprint/filters/pdf2ps.xml
new file mode 100644
index 000000000..0afa52e8e
--- /dev/null
+++ b/tdeprint/filters/pdf2ps.xml
@@ -0,0 +1,152 @@
+<!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/tdeprint/filters/pdfwrite.desktop b/tdeprint/filters/pdfwrite.desktop
new file mode 100644
index 000000000..f42e2cf84
--- /dev/null
+++ b/tdeprint/filters/pdfwrite.desktop
@@ -0,0 +1,102 @@
+[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/tdeprint/filters/pdfwrite.xml b/tdeprint/filters/pdfwrite.xml
new file mode 100644
index 000000000..9ba166138
--- /dev/null
+++ b/tdeprint/filters/pdfwrite.xml
@@ -0,0 +1,14 @@
+<?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/tdeprint/filters/poster.desktop b/tdeprint/filters/poster.desktop
new file mode 100644
index 000000000..843290fab
--- /dev/null
+++ b/tdeprint/filters/poster.desktop
@@ -0,0 +1,163 @@
+[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/tdeprint/filters/poster.xml b/tdeprint/filters/poster.xml
new file mode 100644
index 000000000..a56b60db2
--- /dev/null
+++ b/tdeprint/filters/poster.xml
@@ -0,0 +1,82 @@
+<!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/tdeprint/filters/ps2pdf.desktop b/tdeprint/filters/ps2pdf.desktop
new file mode 100644
index 000000000..841795040
--- /dev/null
+++ b/tdeprint/filters/ps2pdf.desktop
@@ -0,0 +1,92 @@
+[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/tdeprint/filters/ps2pdf.xml b/tdeprint/filters/ps2pdf.xml
new file mode 100644
index 000000000..15b1005b6
--- /dev/null
+++ b/tdeprint/filters/ps2pdf.xml
@@ -0,0 +1,152 @@
+<!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/tdeprint/filters/psbook.desktop b/tdeprint/filters/psbook.desktop
new file mode 100644
index 000000000..c574fd9bb
--- /dev/null
+++ b/tdeprint/filters/psbook.desktop
@@ -0,0 +1,93 @@
+[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/tdeprint/filters/psbook.xml b/tdeprint/filters/psbook.xml
new file mode 100644
index 000000000..11c4132da
--- /dev/null
+++ b/tdeprint/filters/psbook.xml
@@ -0,0 +1,14 @@
+<?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/tdeprint/filters/psbook1.desktop b/tdeprint/filters/psbook1.desktop
new file mode 100644
index 000000000..445b18e29
--- /dev/null
+++ b/tdeprint/filters/psbook1.desktop
@@ -0,0 +1,94 @@
+[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/tdeprint/filters/psbook1.xml b/tdeprint/filters/psbook1.xml
new file mode 100644
index 000000000..4e5b84aa8
--- /dev/null
+++ b/tdeprint/filters/psbook1.xml
@@ -0,0 +1,14 @@
+<?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/tdeprint/filters/psbook2.desktop b/tdeprint/filters/psbook2.desktop
new file mode 100644
index 000000000..1cadd42eb
--- /dev/null
+++ b/tdeprint/filters/psbook2.desktop
@@ -0,0 +1,95 @@
+[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/tdeprint/filters/psbook2.xml b/tdeprint/filters/psbook2.xml
new file mode 100644
index 000000000..5aa8df006
--- /dev/null
+++ b/tdeprint/filters/psbook2.xml
@@ -0,0 +1,14 @@
+<?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/tdeprint/filters/psnup.desktop b/tdeprint/filters/psnup.desktop
new file mode 100644
index 000000000..19aafa627
--- /dev/null
+++ b/tdeprint/filters/psnup.desktop
@@ -0,0 +1,89 @@
+[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/tdeprint/filters/psnup.xml b/tdeprint/filters/psnup.xml
new file mode 100644
index 000000000..54b71531f
--- /dev/null
+++ b/tdeprint/filters/psnup.xml
@@ -0,0 +1,32 @@
+<?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/tdeprint/filters/psresize.desktop b/tdeprint/filters/psresize.desktop
new file mode 100644
index 000000000..2c90c5ad6
--- /dev/null
+++ b/tdeprint/filters/psresize.desktop
@@ -0,0 +1,99 @@
+[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/tdeprint/filters/psresize.xml b/tdeprint/filters/psresize.xml
new file mode 100644
index 000000000..6efc99eed
--- /dev/null
+++ b/tdeprint/filters/psresize.xml
@@ -0,0 +1,24 @@
+<?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/tdeprint/filters/psselect.desktop b/tdeprint/filters/psselect.desktop
new file mode 100644
index 000000000..e44191356
--- /dev/null
+++ b/tdeprint/filters/psselect.desktop
@@ -0,0 +1,97 @@
+[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/tdeprint/filters/psselect.xml b/tdeprint/filters/psselect.xml
new file mode 100644
index 000000000..d125c4089
--- /dev/null
+++ b/tdeprint/filters/psselect.xml
@@ -0,0 +1,24 @@
+<?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/tdeprint/foomatic/Makefile.am b/tdeprint/foomatic/Makefile.am
new file mode 100644
index 000000000..7a57fd40e
--- /dev/null
+++ b/tdeprint/foomatic/Makefile.am
@@ -0,0 +1,20 @@
+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/tdeprint/foomatic/foomatic.print b/tdeprint/foomatic/foomatic.print
new file mode 100644
index 000000000..0ead9632c
--- /dev/null
+++ b/tdeprint/foomatic/foomatic.print
@@ -0,0 +1,17 @@
+[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/tdeprint/foomatic/kfoomaticprinterimpl.cpp b/tdeprint/foomatic/kfoomaticprinterimpl.cpp
new file mode 100644
index 000000000..d47a5e134
--- /dev/null
+++ b/tdeprint/foomatic/kfoomaticprinterimpl.cpp
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/foomatic/kfoomaticprinterimpl.h b/tdeprint/foomatic/kfoomaticprinterimpl.h
new file mode 100644
index 000000000..9d4a27155
--- /dev/null
+++ b/tdeprint/foomatic/kfoomaticprinterimpl.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/foomatic/kmfoomaticfactory.cpp b/tdeprint/foomatic/kmfoomaticfactory.cpp
new file mode 100644
index 000000000..660e5faff
--- /dev/null
+++ b/tdeprint/foomatic/kmfoomaticfactory.cpp
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/foomatic/kmfoomaticmanager.cpp b/tdeprint/foomatic/kmfoomaticmanager.cpp
new file mode 100644
index 000000000..53049852b
--- /dev/null
+++ b/tdeprint/foomatic/kmfoomaticmanager.cpp
@@ -0,0 +1,197 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/foomatic/kmfoomaticmanager.h b/tdeprint/foomatic/kmfoomaticmanager.h
new file mode 100644
index 000000000..f3796904a
--- /dev/null
+++ b/tdeprint/foomatic/kmfoomaticmanager.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/foomatic/make_driver_db_foomatic.c b/tdeprint/foomatic/make_driver_db_foomatic.c
new file mode 100644
index 000000000..986a24447
--- /dev/null
+++ b/tdeprint/foomatic/make_driver_db_foomatic.c
@@ -0,0 +1,192 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/foomatic2loader.cpp b/tdeprint/foomatic2loader.cpp
new file mode 100644
index 000000000..6add13378
--- /dev/null
+++ b/tdeprint/foomatic2loader.cpp
@@ -0,0 +1,302 @@
+/*
+ * 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/tdeprint/foomatic2loader.h b/tdeprint/foomatic2loader.h
new file mode 100644
index 000000000..19cfc9d9d
--- /dev/null
+++ b/tdeprint/foomatic2loader.h
@@ -0,0 +1,57 @@
+/*
+ * 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/tdeprint/fooparser.cpp b/tdeprint/fooparser.cpp
new file mode 100644
index 000000000..e919616ab
--- /dev/null
+++ b/tdeprint/fooparser.cpp
@@ -0,0 +1,1005 @@
+
+/* 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/tdeprint/fooparser.cpp.h b/tdeprint/fooparser.cpp.h
new file mode 100644
index 000000000..dd694b5de
--- /dev/null
+++ b/tdeprint/fooparser.cpp.h
@@ -0,0 +1,15 @@
+#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/tdeprint/fooparser.y b/tdeprint/fooparser.y
new file mode 100644
index 000000000..20626ce59
--- /dev/null
+++ b/tdeprint/fooparser.y
@@ -0,0 +1,70 @@
+%{
+/*
+ * 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/tdeprint/fooscanner.cpp b/tdeprint/fooscanner.cpp
new file mode 100644
index 000000000..3cdd4feb6
--- /dev/null
+++ b/tdeprint/fooscanner.cpp
@@ -0,0 +1,1707 @@
+#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/tdeprint/fooscanner.l b/tdeprint/fooscanner.l
new file mode 100644
index 000000000..ddd5bb974
--- /dev/null
+++ b/tdeprint/fooscanner.l
@@ -0,0 +1,83 @@
+%{
+/*
+ * 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/tdeprint/kfilelist.cpp b/tdeprint/kfilelist.cpp
new file mode 100644
index 000000000..1f67851c6
--- /dev/null
+++ b/tdeprint/kfilelist.cpp
@@ -0,0 +1,326 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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>&lt;STDIN&gt;</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/tdeprint/kfilelist.h b/tdeprint/kfilelist.h
new file mode 100644
index 000000000..03b7977d8
--- /dev/null
+++ b/tdeprint/kfilelist.h
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmdbentry.cpp b/tdeprint/kmdbentry.cpp
new file mode 100644
index 000000000..34a0b60b4
--- /dev/null
+++ b/tdeprint/kmdbentry.cpp
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmdbentry.h b/tdeprint/kmdbentry.h
new file mode 100644
index 000000000..cccec92b6
--- /dev/null
+++ b/tdeprint/kmdbentry.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmfactory.cpp b/tdeprint/kmfactory.cpp
new file mode 100644
index 000000000..3206d3cee
--- /dev/null
+++ b/tdeprint/kmfactory.cpp
@@ -0,0 +1,453 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmfactory.h b/tdeprint/kmfactory.h
new file mode 100644
index 000000000..168385f6e
--- /dev/null
+++ b/tdeprint/kmfactory.h
@@ -0,0 +1,129 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmjob.cpp b/tdeprint/kmjob.cpp
new file mode 100644
index 000000000..ce7e95993
--- /dev/null
+++ b/tdeprint/kmjob.cpp
@@ -0,0 +1,136 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmjob.h b/tdeprint/kmjob.h
new file mode 100644
index 000000000..d8fed5e8d
--- /dev/null
+++ b/tdeprint/kmjob.h
@@ -0,0 +1,130 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmjobmanager.cpp b/tdeprint/kmjobmanager.cpp
new file mode 100644
index 000000000..918c14ff2
--- /dev/null
+++ b/tdeprint/kmjobmanager.cpp
@@ -0,0 +1,257 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmjobmanager.h b/tdeprint/kmjobmanager.h
new file mode 100644
index 000000000..89cabaa7c
--- /dev/null
+++ b/tdeprint/kmjobmanager.h
@@ -0,0 +1,109 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmmanager.cpp b/tdeprint/kmmanager.cpp
new file mode 100644
index 000000000..01ca0dc77
--- /dev/null
+++ b/tdeprint/kmmanager.cpp
@@ -0,0 +1,556 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmmanager.h b/tdeprint/kmmanager.h
new file mode 100644
index 000000000..df78adcd3
--- /dev/null
+++ b/tdeprint/kmmanager.h
@@ -0,0 +1,183 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmobject.h b/tdeprint/kmobject.h
new file mode 100644
index 000000000..5b9358c49
--- /dev/null
+++ b/tdeprint/kmobject.h
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmprinter.cpp b/tdeprint/kmprinter.cpp
new file mode 100644
index 000000000..b18116ef8
--- /dev/null
+++ b/tdeprint/kmprinter.cpp
@@ -0,0 +1,224 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmprinter.h b/tdeprint/kmprinter.h
new file mode 100644
index 000000000..c6c2995e9
--- /dev/null
+++ b/tdeprint/kmprinter.h
@@ -0,0 +1,236 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmspecialmanager.cpp b/tdeprint/kmspecialmanager.cpp
new file mode 100644
index 000000000..6da7f4ed7
--- /dev/null
+++ b/tdeprint/kmspecialmanager.cpp
@@ -0,0 +1,228 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmspecialmanager.h b/tdeprint/kmspecialmanager.h
new file mode 100644
index 000000000..b42aea1df
--- /dev/null
+++ b/tdeprint/kmspecialmanager.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmthreadjob.cpp b/tdeprint/kmthreadjob.cpp
new file mode 100644
index 000000000..fcee4877f
--- /dev/null
+++ b/tdeprint/kmthreadjob.cpp
@@ -0,0 +1,170 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmthreadjob.h b/tdeprint/kmthreadjob.h
new file mode 100644
index 000000000..5bded6274
--- /dev/null
+++ b/tdeprint/kmthreadjob.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmuimanager.cpp b/tdeprint/kmuimanager.cpp
new file mode 100644
index 000000000..962653dd2
--- /dev/null
+++ b/tdeprint/kmuimanager.cpp
@@ -0,0 +1,201 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmuimanager.h b/tdeprint/kmuimanager.h
new file mode 100644
index 000000000..248ad4ed7
--- /dev/null
+++ b/tdeprint/kmuimanager.h
@@ -0,0 +1,94 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmvirtualmanager.cpp b/tdeprint/kmvirtualmanager.cpp
new file mode 100644
index 000000000..78757decd
--- /dev/null
+++ b/tdeprint/kmvirtualmanager.cpp
@@ -0,0 +1,371 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kmvirtualmanager.h b/tdeprint/kmvirtualmanager.h
new file mode 100644
index 000000000..1b7ab4867
--- /dev/null
+++ b/tdeprint/kmvirtualmanager.h
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpcopiespage.cpp b/tdeprint/kpcopiespage.cpp
new file mode 100644
index 000000000..bc0e03e0d
--- /dev/null
+++ b/tdeprint/kpcopiespage.cpp
@@ -0,0 +1,349 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpcopiespage.h b/tdeprint/kpcopiespage.h
new file mode 100644
index 000000000..1e1532ce9
--- /dev/null
+++ b/tdeprint/kpcopiespage.h
@@ -0,0 +1,64 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpdriverpage.cpp b/tdeprint/kpdriverpage.cpp
new file mode 100644
index 000000000..18cfeb207
--- /dev/null
+++ b/tdeprint/kpdriverpage.cpp
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpdriverpage.h b/tdeprint/kpdriverpage.h
new file mode 100644
index 000000000..5c3936e49
--- /dev/null
+++ b/tdeprint/kpdriverpage.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpfileselectpage.cpp b/tdeprint/kpfileselectpage.cpp
new file mode 100644
index 000000000..f3131717a
--- /dev/null
+++ b/tdeprint/kpfileselectpage.cpp
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpfileselectpage.h b/tdeprint/kpfileselectpage.h
new file mode 100644
index 000000000..11ed378ff
--- /dev/null
+++ b/tdeprint/kpfileselectpage.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpfilterpage.cpp b/tdeprint/kpfilterpage.cpp
new file mode 100644
index 000000000..b321b3141
--- /dev/null
+++ b/tdeprint/kpfilterpage.cpp
@@ -0,0 +1,416 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpfilterpage.h b/tdeprint/kpfilterpage.h
new file mode 100644
index 000000000..72065b3f1
--- /dev/null
+++ b/tdeprint/kpfilterpage.h
@@ -0,0 +1,68 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpgeneralpage.cpp b/tdeprint/kpgeneralpage.cpp
new file mode 100644
index 000000000..98ab5d4a6
--- /dev/null
+++ b/tdeprint/kpgeneralpage.cpp
@@ -0,0 +1,736 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpgeneralpage.h b/tdeprint/kpgeneralpage.h
new file mode 100644
index 000000000..2a211ab04
--- /dev/null
+++ b/tdeprint/kpgeneralpage.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpipeprocess.cpp b/tdeprint/kpipeprocess.cpp
new file mode 100644
index 000000000..daf3c2900
--- /dev/null
+++ b/tdeprint/kpipeprocess.cpp
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpipeprocess.h b/tdeprint/kpipeprocess.h
new file mode 100644
index 000000000..0ead3da78
--- /dev/null
+++ b/tdeprint/kpipeprocess.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpmarginpage.cpp b/tdeprint/kpmarginpage.cpp
new file mode 100644
index 000000000..554679ee7
--- /dev/null
+++ b/tdeprint/kpmarginpage.cpp
@@ -0,0 +1,163 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpmarginpage.h b/tdeprint/kpmarginpage.h
new file mode 100644
index 000000000..4d52686fd
--- /dev/null
+++ b/tdeprint/kpmarginpage.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpposterpage.cpp b/tdeprint/kpposterpage.cpp
new file mode 100644
index 000000000..d82e5b572
--- /dev/null
+++ b/tdeprint/kpposterpage.cpp
@@ -0,0 +1,341 @@
+/*
+ * 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/tdeprint/kpposterpage.h b/tdeprint/kpposterpage.h
new file mode 100644
index 000000000..ce4858aa3
--- /dev/null
+++ b/tdeprint/kpposterpage.h
@@ -0,0 +1,60 @@
+/*
+ * 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/tdeprint/kpqtpage.cpp b/tdeprint/kpqtpage.cpp
new file mode 100644
index 000000000..e2c28ebb1
--- /dev/null
+++ b/tdeprint/kpqtpage.cpp
@@ -0,0 +1,336 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpqtpage.h b/tdeprint/kpqtpage.h
new file mode 100644
index 000000000..0ab4361f4
--- /dev/null
+++ b/tdeprint/kpqtpage.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpreloadobject.cpp b/tdeprint/kpreloadobject.cpp
new file mode 100644
index 000000000..af9e299cd
--- /dev/null
+++ b/tdeprint/kpreloadobject.cpp
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kpreloadobject.h b/tdeprint/kpreloadobject.h
new file mode 100644
index 000000000..09bbe97d6
--- /dev/null
+++ b/tdeprint/kpreloadobject.h
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintaction.cpp b/tdeprint/kprintaction.cpp
new file mode 100644
index 000000000..e275ed559
--- /dev/null
+++ b/tdeprint/kprintaction.cpp
@@ -0,0 +1,130 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintaction.h b/tdeprint/kprintaction.h
new file mode 100644
index 000000000..f6ba35d34
--- /dev/null
+++ b/tdeprint/kprintaction.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintdialog.cpp b/tdeprint/kprintdialog.cpp
new file mode 100644
index 000000000..5cb56819e
--- /dev/null
+++ b/tdeprint/kprintdialog.cpp
@@ -0,0 +1,987 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; 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 &lt;printername&gt; --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/tdeprint/kprintdialog.h b/tdeprint/kprintdialog.h
new file mode 100644
index 000000000..77484ca58
--- /dev/null
+++ b/tdeprint/kprintdialog.h
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintdialogpage.cpp b/tdeprint/kprintdialogpage.cpp
new file mode 100644
index 000000000..58861019a
--- /dev/null
+++ b/tdeprint/kprintdialogpage.cpp
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintdialogpage.h b/tdeprint/kprintdialogpage.h
new file mode 100644
index 000000000..d9b44b6ea
--- /dev/null
+++ b/tdeprint/kprintdialogpage.h
@@ -0,0 +1,190 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprinter.cpp b/tdeprint/kprinter.cpp
new file mode 100644
index 000000000..67d276990
--- /dev/null
+++ b/tdeprint/kprinter.cpp
@@ -0,0 +1,1045 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprinter.h b/tdeprint/kprinter.h
new file mode 100644
index 000000000..4910c23ef
--- /dev/null
+++ b/tdeprint/kprinter.h
@@ -0,0 +1,780 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprinterimpl.cpp b/tdeprint/kprinterimpl.cpp
new file mode 100644
index 000000000..166ae7207
--- /dev/null
+++ b/tdeprint/kprinterimpl.cpp
@@ -0,0 +1,606 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprinterimpl.h b/tdeprint/kprinterimpl.h
new file mode 100644
index 000000000..618d9a429
--- /dev/null
+++ b/tdeprint/kprinterimpl.h
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprinterpropertydialog.cpp b/tdeprint/kprinterpropertydialog.cpp
new file mode 100644
index 000000000..1128a7d3a
--- /dev/null
+++ b/tdeprint/kprinterpropertydialog.cpp
@@ -0,0 +1,147 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprinterpropertydialog.h b/tdeprint/kprinterpropertydialog.h
new file mode 100644
index 000000000..98a37d8bd
--- /dev/null
+++ b/tdeprint/kprinterpropertydialog.h
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintpreview.cpp b/tdeprint/kprintpreview.cpp
new file mode 100644
index 000000000..235472d1f
--- /dev/null
+++ b/tdeprint/kprintpreview.cpp
@@ -0,0 +1,328 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintpreview.h b/tdeprint/kprintpreview.h
new file mode 100644
index 000000000..5fd581fe7
--- /dev/null
+++ b/tdeprint/kprintpreview.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintpreviewui.rc b/tdeprint/kprintpreviewui.rc
new file mode 100644
index 000000000..21b144bca
--- /dev/null
+++ b/tdeprint/kprintpreviewui.rc
@@ -0,0 +1,27 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="KGVShell" version="1">
+<MenuBar>
+<Menu name="file" noMerge="1"><text>&amp;File</text>
+ <Action name="continue_print"/>
+ <Action name="stop_print"/>
+ <Action name="close_print"/>
+ <Separator />
+ <Merge/>
+</Menu>
+<Menu name="view" noMerge="1"><text>&amp;View</text>
+</Menu>
+<Menu name="pagemarks"><text>&amp;PageMarks</text>
+ <Merge/>
+</Menu>
+<Menu name="settings" noMerge="1"><text>&amp;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/tdeprint/kprintprocess.cpp b/tdeprint/kprintprocess.cpp
new file mode 100644
index 000000000..fb1df2840
--- /dev/null
+++ b/tdeprint/kprintprocess.cpp
@@ -0,0 +1,94 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kprintprocess.h b/tdeprint/kprintprocess.h
new file mode 100644
index 000000000..976b35afe
--- /dev/null
+++ b/tdeprint/kprintprocess.h
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kxmlcommand.cpp b/tdeprint/kxmlcommand.cpp
new file mode 100644
index 000000000..81dc5d3d5
--- /dev/null
+++ b/tdeprint/kxmlcommand.cpp
@@ -0,0 +1,830 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/kxmlcommand.h b/tdeprint/kxmlcommand.h
new file mode 100644
index 000000000..a0ba90c56
--- /dev/null
+++ b/tdeprint/kxmlcommand.h
@@ -0,0 +1,121 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/Makefile.am b/tdeprint/lpd/Makefile.am
new file mode 100644
index 000000000..5c6559a27
--- /dev/null
+++ b/tdeprint/lpd/Makefile.am
@@ -0,0 +1,18 @@
+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/tdeprint/lpd/gschecker.cpp b/tdeprint/lpd/gschecker.cpp
new file mode 100644
index 000000000..9fe6e290b
--- /dev/null
+++ b/tdeprint/lpd/gschecker.cpp
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/gschecker.h b/tdeprint/lpd/gschecker.h
new file mode 100644
index 000000000..c3c23a5be
--- /dev/null
+++ b/tdeprint/lpd/gschecker.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/klpdprinterimpl.cpp b/tdeprint/lpd/klpdprinterimpl.cpp
new file mode 100644
index 000000000..59f04e74c
--- /dev/null
+++ b/tdeprint/lpd/klpdprinterimpl.cpp
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/klpdprinterimpl.h b/tdeprint/lpd/klpdprinterimpl.h
new file mode 100644
index 000000000..a757d0c8c
--- /dev/null
+++ b/tdeprint/lpd/klpdprinterimpl.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/kmlpdfactory.cpp b/tdeprint/lpd/kmlpdfactory.cpp
new file mode 100644
index 000000000..05ee61bd5
--- /dev/null
+++ b/tdeprint/lpd/kmlpdfactory.cpp
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/kmlpdfactory.h b/tdeprint/lpd/kmlpdfactory.h
new file mode 100644
index 000000000..ffc05af71
--- /dev/null
+++ b/tdeprint/lpd/kmlpdfactory.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/kmlpdmanager.cpp b/tdeprint/lpd/kmlpdmanager.cpp
new file mode 100644
index 000000000..a5612ad58
--- /dev/null
+++ b/tdeprint/lpd/kmlpdmanager.cpp
@@ -0,0 +1,651 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/kmlpdmanager.h b/tdeprint/lpd/kmlpdmanager.h
new file mode 100644
index 000000000..3c2291017
--- /dev/null
+++ b/tdeprint/lpd/kmlpdmanager.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/kmlpduimanager.cpp b/tdeprint/lpd/kmlpduimanager.cpp
new file mode 100644
index 000000000..fad3fcd58
--- /dev/null
+++ b/tdeprint/lpd/kmlpduimanager.cpp
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/kmlpduimanager.h b/tdeprint/lpd/kmlpduimanager.h
new file mode 100644
index 000000000..7aca6ed1d
--- /dev/null
+++ b/tdeprint/lpd/kmlpduimanager.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/lpd.print b/tdeprint/lpd/lpd.print
new file mode 100644
index 000000000..019d5b9c8
--- /dev/null
+++ b/tdeprint/lpd/lpd.print
@@ -0,0 +1,87 @@
+[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/tdeprint/lpd/lpdtools.cpp b/tdeprint/lpd/lpdtools.cpp
new file mode 100644
index 000000000..610e8ead5
--- /dev/null
+++ b/tdeprint/lpd/lpdtools.cpp
@@ -0,0 +1,417 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/lpdtools.h b/tdeprint/lpd/lpdtools.h
new file mode 100644
index 000000000..692dd0fa2
--- /dev/null
+++ b/tdeprint/lpd/lpdtools.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpd/make_driver_db_lpd.c b/tdeprint/lpd/make_driver_db_lpd.c
new file mode 100644
index 000000000..02aced962
--- /dev/null
+++ b/tdeprint/lpd/make_driver_db_lpd.c
@@ -0,0 +1,112 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/CMakeLists.txt b/tdeprint/lpdunix/CMakeLists.txt
new file mode 100644
index 000000000..5b30cf46c
--- /dev/null
+++ b/tdeprint/lpdunix/CMakeLists.txt
@@ -0,0 +1,52 @@
+#################################################
+#
+# (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/tdeprint/lpdunix/Makefile.am b/tdeprint/lpdunix/Makefile.am
new file mode 100644
index 000000000..019ead755
--- /dev/null
+++ b/tdeprint/lpdunix/Makefile.am
@@ -0,0 +1,15 @@
+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/tdeprint/lpdunix/klpdunixprinterimpl.cpp b/tdeprint/lpdunix/klpdunixprinterimpl.cpp
new file mode 100644
index 000000000..9ba97efae
--- /dev/null
+++ b/tdeprint/lpdunix/klpdunixprinterimpl.cpp
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/klpdunixprinterimpl.h b/tdeprint/lpdunix/klpdunixprinterimpl.h
new file mode 100644
index 000000000..bbbda4104
--- /dev/null
+++ b/tdeprint/lpdunix/klpdunixprinterimpl.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/kmlpdunixfactory.cpp b/tdeprint/lpdunix/kmlpdunixfactory.cpp
new file mode 100644
index 000000000..70925a65c
--- /dev/null
+++ b/tdeprint/lpdunix/kmlpdunixfactory.cpp
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/kmlpdunixmanager.cpp b/tdeprint/lpdunix/kmlpdunixmanager.cpp
new file mode 100644
index 000000000..afcd83b2a
--- /dev/null
+++ b/tdeprint/lpdunix/kmlpdunixmanager.cpp
@@ -0,0 +1,410 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/kmlpdunixmanager.h b/tdeprint/lpdunix/kmlpdunixmanager.h
new file mode 100644
index 000000000..8716f8351
--- /dev/null
+++ b/tdeprint/lpdunix/kmlpdunixmanager.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/kmlpdunixuimanager.cpp b/tdeprint/lpdunix/kmlpdunixuimanager.cpp
new file mode 100644
index 000000000..686dfecbb
--- /dev/null
+++ b/tdeprint/lpdunix/kmlpdunixuimanager.cpp
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/kmlpdunixuimanager.h b/tdeprint/lpdunix/kmlpdunixuimanager.h
new file mode 100644
index 000000000..6e9e0d2ef
--- /dev/null
+++ b/tdeprint/lpdunix/kmlpdunixuimanager.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpdunix/lpdunix.print b/tdeprint/lpdunix/lpdunix.print
new file mode 100644
index 000000000..8ef71a28d
--- /dev/null
+++ b/tdeprint/lpdunix/lpdunix.print
@@ -0,0 +1,83 @@
+[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/tdeprint/lpr/CMakeLists.txt b/tdeprint/lpr/CMakeLists.txt
new file mode 100644
index 000000000..c893411b1
--- /dev/null
+++ b/tdeprint/lpr/CMakeLists.txt
@@ -0,0 +1,80 @@
+#################################################
+#
+# (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/tdeprint/lpr/Makefile.am b/tdeprint/lpr/Makefile.am
new file mode 100644
index 000000000..a9039888f
--- /dev/null
+++ b/tdeprint/lpr/Makefile.am
@@ -0,0 +1,40 @@
+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/tdeprint/lpr/apsdriver1 b/tdeprint/lpr/apsdriver1
new file mode 100644
index 000000000..fa6bbde0e
--- /dev/null
+++ b/tdeprint/lpr/apsdriver1
@@ -0,0 +1,84 @@
+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/tdeprint/lpr/apsdriver2 b/tdeprint/lpr/apsdriver2
new file mode 100644
index 000000000..69d355f6c
--- /dev/null
+++ b/tdeprint/lpr/apsdriver2
@@ -0,0 +1,83 @@
+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/tdeprint/lpr/apshandler.cpp b/tdeprint/lpr/apshandler.cpp
new file mode 100644
index 000000000..d4107d7c7
--- /dev/null
+++ b/tdeprint/lpr/apshandler.cpp
@@ -0,0 +1,405 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/apshandler.h b/tdeprint/lpr/apshandler.h
new file mode 100644
index 000000000..db213d194
--- /dev/null
+++ b/tdeprint/lpr/apshandler.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/editentrydialog.cpp b/tdeprint/lpr/editentrydialog.cpp
new file mode 100644
index 000000000..6c4ecc30c
--- /dev/null
+++ b/tdeprint/lpr/editentrydialog.cpp
@@ -0,0 +1,157 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/editentrydialog.h b/tdeprint/lpr/editentrydialog.h
new file mode 100644
index 000000000..f4359dd89
--- /dev/null
+++ b/tdeprint/lpr/editentrydialog.h
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/klprfactory.cpp b/tdeprint/lpr/klprfactory.cpp
new file mode 100644
index 000000000..4764dfc6a
--- /dev/null
+++ b/tdeprint/lpr/klprfactory.cpp
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/klprprinterimpl.cpp b/tdeprint/lpr/klprprinterimpl.cpp
new file mode 100644
index 000000000..70356f23c
--- /dev/null
+++ b/tdeprint/lpr/klprprinterimpl.cpp
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/klprprinterimpl.h b/tdeprint/lpr/klprprinterimpl.h
new file mode 100644
index 000000000..508173f1d
--- /dev/null
+++ b/tdeprint/lpr/klprprinterimpl.h
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmconfiglpr.cpp b/tdeprint/lpr/kmconfiglpr.cpp
new file mode 100644
index 000000000..f43a8da2d
--- /dev/null
+++ b/tdeprint/lpr/kmconfiglpr.cpp
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmconfiglpr.h b/tdeprint/lpr/kmconfiglpr.h
new file mode 100644
index 000000000..7f3d50857
--- /dev/null
+++ b/tdeprint/lpr/kmconfiglpr.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmlprjobmanager.cpp b/tdeprint/lpr/kmlprjobmanager.cpp
new file mode 100644
index 000000000..851663664
--- /dev/null
+++ b/tdeprint/lpr/kmlprjobmanager.cpp
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmlprjobmanager.h b/tdeprint/lpr/kmlprjobmanager.h
new file mode 100644
index 000000000..d9a8eae3f
--- /dev/null
+++ b/tdeprint/lpr/kmlprjobmanager.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmlprmanager.cpp b/tdeprint/lpr/kmlprmanager.cpp
new file mode 100644
index 000000000..cf4dbbb94
--- /dev/null
+++ b/tdeprint/lpr/kmlprmanager.cpp
@@ -0,0 +1,492 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmlprmanager.h b/tdeprint/lpr/kmlprmanager.h
new file mode 100644
index 000000000..34d38340f
--- /dev/null
+++ b/tdeprint/lpr/kmlprmanager.h
@@ -0,0 +1,82 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmlpruimanager.cpp b/tdeprint/lpr/kmlpruimanager.cpp
new file mode 100644
index 000000000..655309e0c
--- /dev/null
+++ b/tdeprint/lpr/kmlpruimanager.cpp
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/kmlpruimanager.h b/tdeprint/lpr/kmlpruimanager.h
new file mode 100644
index 000000000..561f93500
--- /dev/null
+++ b/tdeprint/lpr/kmlpruimanager.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lpchelper.cpp b/tdeprint/lpr/lpchelper.cpp
new file mode 100644
index 000000000..c921a803c
--- /dev/null
+++ b/tdeprint/lpr/lpchelper.cpp
@@ -0,0 +1,320 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lpchelper.h b/tdeprint/lpr/lpchelper.h
new file mode 100644
index 000000000..b1e20f089
--- /dev/null
+++ b/tdeprint/lpr/lpchelper.h
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lpqhelper.cpp b/tdeprint/lpr/lpqhelper.cpp
new file mode 100644
index 000000000..30348f591
--- /dev/null
+++ b/tdeprint/lpr/lpqhelper.cpp
@@ -0,0 +1,117 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lpqhelper.h b/tdeprint/lpr/lpqhelper.h
new file mode 100644
index 000000000..2c38566c5
--- /dev/null
+++ b/tdeprint/lpr/lpqhelper.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lpr.print b/tdeprint/lpr/lpr.print
new file mode 100644
index 000000000..e8cd8a3d7
--- /dev/null
+++ b/tdeprint/lpr/lpr.print
@@ -0,0 +1,86 @@
+[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/tdeprint/lpr/lprhandler.cpp b/tdeprint/lpr/lprhandler.cpp
new file mode 100644
index 000000000..fcb838bb9
--- /dev/null
+++ b/tdeprint/lpr/lprhandler.cpp
@@ -0,0 +1,270 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lprhandler.h b/tdeprint/lpr/lprhandler.h
new file mode 100644
index 000000000..e0e66e146
--- /dev/null
+++ b/tdeprint/lpr/lprhandler.h
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lprngtooldriver1 b/tdeprint/lpr/lprngtooldriver1
new file mode 100644
index 000000000..11636403c
--- /dev/null
+++ b/tdeprint/lpr/lprngtooldriver1
@@ -0,0 +1,85 @@
+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/tdeprint/lpr/lprngtoolhandler.cpp b/tdeprint/lpr/lprngtoolhandler.cpp
new file mode 100644
index 000000000..1d76cf2f5
--- /dev/null
+++ b/tdeprint/lpr/lprngtoolhandler.cpp
@@ -0,0 +1,393 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lprngtoolhandler.h b/tdeprint/lpr/lprngtoolhandler.h
new file mode 100644
index 000000000..49641ca3a
--- /dev/null
+++ b/tdeprint/lpr/lprngtoolhandler.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/lprsettings.cpp b/tdeprint/lpr/lprsettings.cpp
new file mode 100644
index 000000000..0c1cec2a9
--- /dev/null
+++ b/tdeprint/lpr/lprsettings.cpp
@@ -0,0 +1,146 @@
+/*
+ * 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/tdeprint/lpr/lprsettings.h b/tdeprint/lpr/lprsettings.h
new file mode 100644
index 000000000..01abbeeb3
--- /dev/null
+++ b/tdeprint/lpr/lprsettings.h
@@ -0,0 +1,67 @@
+/*
+ * 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/tdeprint/lpr/make_driver_db_lpr.c b/tdeprint/lpr/make_driver_db_lpr.c
new file mode 100644
index 000000000..fabbcb2fe
--- /dev/null
+++ b/tdeprint/lpr/make_driver_db_lpr.c
@@ -0,0 +1,192 @@
+#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/tdeprint/lpr/matichandler.cpp b/tdeprint/lpr/matichandler.cpp
new file mode 100644
index 000000000..ef2f1584b
--- /dev/null
+++ b/tdeprint/lpr/matichandler.cpp
@@ -0,0 +1,481 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/matichandler.h b/tdeprint/lpr/matichandler.h
new file mode 100644
index 000000000..e30eee39e
--- /dev/null
+++ b/tdeprint/lpr/matichandler.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/matichelper.cpp b/tdeprint/lpr/matichelper.cpp
new file mode 100644
index 000000000..ec0041b7c
--- /dev/null
+++ b/tdeprint/lpr/matichelper.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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/tdeprint/lpr/matichelper.h b/tdeprint/lpr/matichelper.h
new file mode 100644
index 000000000..5a2b64fe3
--- /dev/null
+++ b/tdeprint/lpr/matichelper.h
@@ -0,0 +1,29 @@
+/*
+ * 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/tdeprint/lpr/printcapentry.cpp b/tdeprint/lpr/printcapentry.cpp
new file mode 100644
index 000000000..9c83537e4
--- /dev/null
+++ b/tdeprint/lpr/printcapentry.cpp
@@ -0,0 +1,82 @@
+/*
+ * 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/tdeprint/lpr/printcapentry.h b/tdeprint/lpr/printcapentry.h
new file mode 100644
index 000000000..f8ba99197
--- /dev/null
+++ b/tdeprint/lpr/printcapentry.h
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/printcapreader.cpp b/tdeprint/lpr/printcapreader.cpp
new file mode 100644
index 000000000..00016c14f
--- /dev/null
+++ b/tdeprint/lpr/printcapreader.cpp
@@ -0,0 +1,176 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/lpr/printcapreader.h b/tdeprint/lpr/printcapreader.h
new file mode 100644
index 000000000..2236e5068
--- /dev/null
+++ b/tdeprint/lpr/printcapreader.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/CMakeLists.txt b/tdeprint/management/CMakeLists.txt
new file mode 100644
index 000000000..0e12299e6
--- /dev/null
+++ b/tdeprint/management/CMakeLists.txt
@@ -0,0 +1,111 @@
+#################################################
+#
+# (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/tdeprint/management/Makefile.am b/tdeprint/management/Makefile.am
new file mode 100644
index 000000000..34f8de935
--- /dev/null
+++ b/tdeprint/management/Makefile.am
@@ -0,0 +1,52 @@
+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/tdeprint/management/cjanuswidget.cpp b/tdeprint/management/cjanuswidget.cpp
new file mode 100644
index 000000000..af04ee170
--- /dev/null
+++ b/tdeprint/management/cjanuswidget.cpp
@@ -0,0 +1,265 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/cjanuswidget.h b/tdeprint/management/cjanuswidget.h
new file mode 100644
index 000000000..d33be1499
--- /dev/null
+++ b/tdeprint/management/cjanuswidget.h
@@ -0,0 +1,64 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/jobitem.cpp b/tdeprint/management/jobitem.cpp
new file mode 100644
index 000000000..a9ce2fe85
--- /dev/null
+++ b/tdeprint/management/jobitem.cpp
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/jobitem.h b/tdeprint/management/jobitem.h
new file mode 100644
index 000000000..580a1b84f
--- /dev/null
+++ b/tdeprint/management/jobitem.h
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kaddprinterwizard.cpp b/tdeprint/management/kaddprinterwizard.cpp
new file mode 100644
index 000000000..65d355a8f
--- /dev/null
+++ b/tdeprint/management/kaddprinterwizard.cpp
@@ -0,0 +1,39 @@
+#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/tdeprint/management/kiconselectaction.cpp b/tdeprint/management/kiconselectaction.cpp
new file mode 100644
index 000000000..8bf4d5a10
--- /dev/null
+++ b/tdeprint/management/kiconselectaction.cpp
@@ -0,0 +1,118 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kiconselectaction.h b/tdeprint/management/kiconselectaction.h
new file mode 100644
index 000000000..84bef60d2
--- /dev/null
+++ b/tdeprint/management/kiconselectaction.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigcommand.cpp b/tdeprint/management/kmconfigcommand.cpp
new file mode 100644
index 000000000..32fb7db11
--- /dev/null
+++ b/tdeprint/management/kmconfigcommand.cpp
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigcommand.h b/tdeprint/management/kmconfigcommand.h
new file mode 100644
index 000000000..203e6fd3a
--- /dev/null
+++ b/tdeprint/management/kmconfigcommand.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigdialog.cpp b/tdeprint/management/kmconfigdialog.cpp
new file mode 100644
index 000000000..3bd89a751
--- /dev/null
+++ b/tdeprint/management/kmconfigdialog.cpp
@@ -0,0 +1,89 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigdialog.h b/tdeprint/management/kmconfigdialog.h
new file mode 100644
index 000000000..de04bc154
--- /dev/null
+++ b/tdeprint/management/kmconfigdialog.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigfilter.cpp b/tdeprint/management/kmconfigfilter.cpp
new file mode 100644
index 000000000..29d5107e0
--- /dev/null
+++ b/tdeprint/management/kmconfigfilter.cpp
@@ -0,0 +1,159 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigfilter.h b/tdeprint/management/kmconfigfilter.h
new file mode 100644
index 000000000..9571f0d54
--- /dev/null
+++ b/tdeprint/management/kmconfigfilter.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigfonts.cpp b/tdeprint/management/kmconfigfonts.cpp
new file mode 100644
index 000000000..183d0b621
--- /dev/null
+++ b/tdeprint/management/kmconfigfonts.cpp
@@ -0,0 +1,182 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigfonts.h b/tdeprint/management/kmconfigfonts.h
new file mode 100644
index 000000000..a93a26d75
--- /dev/null
+++ b/tdeprint/management/kmconfigfonts.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfiggeneral.cpp b/tdeprint/management/kmconfiggeneral.cpp
new file mode 100644
index 000000000..40d187c3c
--- /dev/null
+++ b/tdeprint/management/kmconfiggeneral.cpp
@@ -0,0 +1,142 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfiggeneral.h b/tdeprint/management/kmconfiggeneral.h
new file mode 100644
index 000000000..8fc6fa5ab
--- /dev/null
+++ b/tdeprint/management/kmconfiggeneral.h
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigjobs.cpp b/tdeprint/management/kmconfigjobs.cpp
new file mode 100644
index 000000000..1088e1b3a
--- /dev/null
+++ b/tdeprint/management/kmconfigjobs.cpp
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigjobs.h b/tdeprint/management/kmconfigjobs.h
new file mode 100644
index 000000000..34be5b1ef
--- /dev/null
+++ b/tdeprint/management/kmconfigjobs.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigpage.cpp b/tdeprint/management/kmconfigpage.cpp
new file mode 100644
index 000000000..fb967e05d
--- /dev/null
+++ b/tdeprint/management/kmconfigpage.cpp
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigpage.h b/tdeprint/management/kmconfigpage.h
new file mode 100644
index 000000000..d56fbde8b
--- /dev/null
+++ b/tdeprint/management/kmconfigpage.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigpreview.cpp b/tdeprint/management/kmconfigpreview.cpp
new file mode 100644
index 000000000..cd777ec7a
--- /dev/null
+++ b/tdeprint/management/kmconfigpreview.cpp
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmconfigpreview.h b/tdeprint/management/kmconfigpreview.h
new file mode 100644
index 000000000..a9c826c98
--- /dev/null
+++ b/tdeprint/management/kmconfigpreview.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdbcreator.cpp b/tdeprint/management/kmdbcreator.cpp
new file mode 100644
index 000000000..1a89d0a8e
--- /dev/null
+++ b/tdeprint/management/kmdbcreator.cpp
@@ -0,0 +1,187 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdbcreator.h b/tdeprint/management/kmdbcreator.h
new file mode 100644
index 000000000..319d270c0
--- /dev/null
+++ b/tdeprint/management/kmdbcreator.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdriverdb.cpp b/tdeprint/management/kmdriverdb.cpp
new file mode 100644
index 000000000..6fbab45ec
--- /dev/null
+++ b/tdeprint/management/kmdriverdb.cpp
@@ -0,0 +1,244 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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("&lt;", "<").replace("&gt;", ">")+"</qt>");
+ }
+ if (entry)
+ insertEntry(entry);
+ }
+}
+#include "kmdriverdb.moc"
diff --git a/tdeprint/management/kmdriverdb.h b/tdeprint/management/kmdriverdb.h
new file mode 100644
index 000000000..c5af6d53e
--- /dev/null
+++ b/tdeprint/management/kmdriverdb.h
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdriverdbwidget.cpp b/tdeprint/management/kmdriverdbwidget.cpp
new file mode 100644
index 000000000..e9c490206
--- /dev/null
+++ b/tdeprint/management/kmdriverdbwidget.cpp
@@ -0,0 +1,273 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdriverdbwidget.h b/tdeprint/management/kmdriverdbwidget.h
new file mode 100644
index 000000000..05b50536d
--- /dev/null
+++ b/tdeprint/management/kmdriverdbwidget.h
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdriverdialog.cpp b/tdeprint/management/kmdriverdialog.cpp
new file mode 100644
index 000000000..ef37e333c
--- /dev/null
+++ b/tdeprint/management/kmdriverdialog.cpp
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmdriverdialog.h b/tdeprint/management/kmdriverdialog.h
new file mode 100644
index 000000000..8b7b01c45
--- /dev/null
+++ b/tdeprint/management/kmdriverdialog.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmiconview.cpp b/tdeprint/management/kmiconview.cpp
new file mode 100644
index 000000000..1fa5a6da9
--- /dev/null
+++ b/tdeprint/management/kmiconview.cpp
@@ -0,0 +1,237 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmiconview.h b/tdeprint/management/kmiconview.h
new file mode 100644
index 000000000..1fd6fbbda
--- /dev/null
+++ b/tdeprint/management/kmiconview.h
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kminfopage.cpp b/tdeprint/management/kminfopage.cpp
new file mode 100644
index 000000000..ad43f1ccb
--- /dev/null
+++ b/tdeprint/management/kminfopage.cpp
@@ -0,0 +1,143 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kminfopage.h b/tdeprint/management/kminfopage.h
new file mode 100644
index 000000000..591fdbfe8
--- /dev/null
+++ b/tdeprint/management/kminfopage.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kminstancepage.cpp b/tdeprint/management/kminstancepage.cpp
new file mode 100644
index 000000000..25c037516
--- /dev/null
+++ b/tdeprint/management/kminstancepage.cpp
@@ -0,0 +1,276 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kminstancepage.h b/tdeprint/management/kminstancepage.h
new file mode 100644
index 000000000..7a3075d73
--- /dev/null
+++ b/tdeprint/management/kminstancepage.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmjobviewer.cpp b/tdeprint/management/kmjobviewer.cpp
new file mode 100644
index 000000000..7f168faed
--- /dev/null
+++ b/tdeprint/management/kmjobviewer.cpp
@@ -0,0 +1,742 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmjobviewer.h b/tdeprint/management/kmjobviewer.h
new file mode 100644
index 000000000..650fe4b15
--- /dev/null
+++ b/tdeprint/management/kmjobviewer.h
@@ -0,0 +1,127 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmlistview.cpp b/tdeprint/management/kmlistview.cpp
new file mode 100644
index 000000000..72d6872cb
--- /dev/null
+++ b/tdeprint/management/kmlistview.cpp
@@ -0,0 +1,268 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmlistview.h b/tdeprint/management/kmlistview.h
new file mode 100644
index 000000000..20ddc5731
--- /dev/null
+++ b/tdeprint/management/kmlistview.h
@@ -0,0 +1,59 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmmainview.cpp b/tdeprint/management/kmmainview.cpp
new file mode 100644
index 000000000..f5f905af3
--- /dev/null
+++ b/tdeprint/management/kmmainview.cpp
@@ -0,0 +1,920 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmmainview.h b/tdeprint/management/kmmainview.h
new file mode 100644
index 000000000..0d05692d9
--- /dev/null
+++ b/tdeprint/management/kmmainview.h
@@ -0,0 +1,133 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpages.cpp b/tdeprint/management/kmpages.cpp
new file mode 100644
index 000000000..4f0f1f4f7
--- /dev/null
+++ b/tdeprint/management/kmpages.cpp
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpages.h b/tdeprint/management/kmpages.h
new file mode 100644
index 000000000..761c8d22d
--- /dev/null
+++ b/tdeprint/management/kmpages.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmprinterpage.h b/tdeprint/management/kmprinterpage.h
new file mode 100644
index 000000000..25e5b1c12
--- /dev/null
+++ b/tdeprint/management/kmprinterpage.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmprinterview.cpp b/tdeprint/management/kmprinterview.cpp
new file mode 100644
index 000000000..19264a946
--- /dev/null
+++ b/tdeprint/management/kmprinterview.cpp
@@ -0,0 +1,113 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmprinterview.h b/tdeprint/management/kmprinterview.h
new file mode 100644
index 000000000..ba1bd38b1
--- /dev/null
+++ b/tdeprint/management/kmprinterview.h
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropbackend.cpp b/tdeprint/management/kmpropbackend.cpp
new file mode 100644
index 000000000..98004d2ed
--- /dev/null
+++ b/tdeprint/management/kmpropbackend.cpp
@@ -0,0 +1,86 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropbackend.h b/tdeprint/management/kmpropbackend.h
new file mode 100644
index 000000000..01249d348
--- /dev/null
+++ b/tdeprint/management/kmpropbackend.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropcontainer.cpp b/tdeprint/management/kmpropcontainer.cpp
new file mode 100644
index 000000000..9c7808199
--- /dev/null
+++ b/tdeprint/management/kmpropcontainer.cpp
@@ -0,0 +1,77 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropcontainer.h b/tdeprint/management/kmpropcontainer.h
new file mode 100644
index 000000000..d191dfeb6
--- /dev/null
+++ b/tdeprint/management/kmpropcontainer.h
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropdriver.cpp b/tdeprint/management/kmpropdriver.cpp
new file mode 100644
index 000000000..55daf0ed5
--- /dev/null
+++ b/tdeprint/management/kmpropdriver.cpp
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropdriver.h b/tdeprint/management/kmpropdriver.h
new file mode 100644
index 000000000..247431762
--- /dev/null
+++ b/tdeprint/management/kmpropdriver.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropertypage.cpp b/tdeprint/management/kmpropertypage.cpp
new file mode 100644
index 000000000..e0526ad5a
--- /dev/null
+++ b/tdeprint/management/kmpropertypage.cpp
@@ -0,0 +1,94 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropertypage.h b/tdeprint/management/kmpropertypage.h
new file mode 100644
index 000000000..d13338750
--- /dev/null
+++ b/tdeprint/management/kmpropertypage.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropgeneral.cpp b/tdeprint/management/kmpropgeneral.cpp
new file mode 100644
index 000000000..c55603da9
--- /dev/null
+++ b/tdeprint/management/kmpropgeneral.cpp
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropgeneral.h b/tdeprint/management/kmpropgeneral.h
new file mode 100644
index 000000000..c4e403b86
--- /dev/null
+++ b/tdeprint/management/kmpropgeneral.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropmembers.cpp b/tdeprint/management/kmpropmembers.cpp
new file mode 100644
index 000000000..4efbcf547
--- /dev/null
+++ b/tdeprint/management/kmpropmembers.cpp
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropmembers.h b/tdeprint/management/kmpropmembers.h
new file mode 100644
index 000000000..90330681e
--- /dev/null
+++ b/tdeprint/management/kmpropmembers.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropwidget.cpp b/tdeprint/management/kmpropwidget.cpp
new file mode 100644
index 000000000..ae8b03cbf
--- /dev/null
+++ b/tdeprint/management/kmpropwidget.cpp
@@ -0,0 +1,86 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmpropwidget.h b/tdeprint/management/kmpropwidget.h
new file mode 100644
index 000000000..83148bc72
--- /dev/null
+++ b/tdeprint/management/kmpropwidget.h
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmspecialprinterdlg.cpp b/tdeprint/management/kmspecialprinterdlg.cpp
new file mode 100644
index 000000000..6569f3f83
--- /dev/null
+++ b/tdeprint/management/kmspecialprinterdlg.cpp
@@ -0,0 +1,222 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmspecialprinterdlg.h b/tdeprint/management/kmspecialprinterdlg.h
new file mode 100644
index 000000000..bc7497a05
--- /dev/null
+++ b/tdeprint/management/kmspecialprinterdlg.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmtimer.cpp b/tdeprint/management/kmtimer.cpp
new file mode 100644
index 000000000..1525dd875
--- /dev/null
+++ b/tdeprint/management/kmtimer.cpp
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmtimer.h b/tdeprint/management/kmtimer.h
new file mode 100644
index 000000000..eb40e7957
--- /dev/null
+++ b/tdeprint/management/kmtimer.h
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwbackend.cpp b/tdeprint/management/kmwbackend.cpp
new file mode 100644
index 000000000..e39b52f8d
--- /dev/null
+++ b/tdeprint/management/kmwbackend.cpp
@@ -0,0 +1,177 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwbackend.h b/tdeprint/management/kmwbackend.h
new file mode 100644
index 000000000..223123b4f
--- /dev/null
+++ b/tdeprint/management/kmwbackend.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwclass.cpp b/tdeprint/management/kmwclass.cpp
new file mode 100644
index 000000000..a87388a6f
--- /dev/null
+++ b/tdeprint/management/kmwclass.cpp
@@ -0,0 +1,141 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwclass.h b/tdeprint/management/kmwclass.h
new file mode 100644
index 000000000..c9b63befb
--- /dev/null
+++ b/tdeprint/management/kmwclass.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwdriver.cpp b/tdeprint/management/kmwdriver.cpp
new file mode 100644
index 000000000..58793c192
--- /dev/null
+++ b/tdeprint/management/kmwdriver.cpp
@@ -0,0 +1,116 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwdriver.h b/tdeprint/management/kmwdriver.h
new file mode 100644
index 000000000..9eef02069
--- /dev/null
+++ b/tdeprint/management/kmwdriver.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwdriverselect.cpp b/tdeprint/management/kmwdriverselect.cpp
new file mode 100644
index 000000000..e3d253660
--- /dev/null
+++ b/tdeprint/management/kmwdriverselect.cpp
@@ -0,0 +1,116 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwdriverselect.h b/tdeprint/management/kmwdriverselect.h
new file mode 100644
index 000000000..464a78239
--- /dev/null
+++ b/tdeprint/management/kmwdriverselect.h
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwdrivertest.cpp b/tdeprint/management/kmwdrivertest.cpp
new file mode 100644
index 000000000..545d3b94d
--- /dev/null
+++ b/tdeprint/management/kmwdrivertest.cpp
@@ -0,0 +1,172 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwdrivertest.h b/tdeprint/management/kmwdrivertest.h
new file mode 100644
index 000000000..5c1aefaee
--- /dev/null
+++ b/tdeprint/management/kmwdrivertest.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwend.cpp b/tdeprint/management/kmwend.cpp
new file mode 100644
index 000000000..54294fb13
--- /dev/null
+++ b/tdeprint/management/kmwend.cpp
@@ -0,0 +1,119 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwend.h b/tdeprint/management/kmwend.h
new file mode 100644
index 000000000..626eedf96
--- /dev/null
+++ b/tdeprint/management/kmwend.h
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwfile.cpp b/tdeprint/management/kmwfile.cpp
new file mode 100644
index 000000000..32da27c03
--- /dev/null
+++ b/tdeprint/management/kmwfile.cpp
@@ -0,0 +1,77 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwfile.h b/tdeprint/management/kmwfile.h
new file mode 100644
index 000000000..40e2e2171
--- /dev/null
+++ b/tdeprint/management/kmwfile.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwinfobase.cpp b/tdeprint/management/kmwinfobase.cpp
new file mode 100644
index 000000000..993576334
--- /dev/null
+++ b/tdeprint/management/kmwinfobase.cpp
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwinfobase.h b/tdeprint/management/kmwinfobase.h
new file mode 100644
index 000000000..9a2b6464e
--- /dev/null
+++ b/tdeprint/management/kmwinfobase.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwinfopage.cpp b/tdeprint/management/kmwinfopage.cpp
new file mode 100644
index 000000000..1e9652e93
--- /dev/null
+++ b/tdeprint/management/kmwinfopage.cpp
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwinfopage.h b/tdeprint/management/kmwinfopage.h
new file mode 100644
index 000000000..346d29401
--- /dev/null
+++ b/tdeprint/management/kmwinfopage.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwizard.cpp b/tdeprint/management/kmwizard.cpp
new file mode 100644
index 000000000..5dc915572
--- /dev/null
+++ b/tdeprint/management/kmwizard.cpp
@@ -0,0 +1,262 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwizard.h b/tdeprint/management/kmwizard.h
new file mode 100644
index 000000000..5a2dcb6ea
--- /dev/null
+++ b/tdeprint/management/kmwizard.h
@@ -0,0 +1,101 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwizardpage.cpp b/tdeprint/management/kmwizardpage.cpp
new file mode 100644
index 000000000..10149d0f9
--- /dev/null
+++ b/tdeprint/management/kmwizardpage.cpp
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwizardpage.h b/tdeprint/management/kmwizardpage.h
new file mode 100644
index 000000000..61fe938b7
--- /dev/null
+++ b/tdeprint/management/kmwizardpage.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwlocal.cpp b/tdeprint/management/kmwlocal.cpp
new file mode 100644
index 000000000..7b56b2deb
--- /dev/null
+++ b/tdeprint/management/kmwlocal.cpp
@@ -0,0 +1,206 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwlocal.h b/tdeprint/management/kmwlocal.h
new file mode 100644
index 000000000..681d94e51
--- /dev/null
+++ b/tdeprint/management/kmwlocal.h
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwlpd.cpp b/tdeprint/management/kmwlpd.cpp
new file mode 100644
index 000000000..cce4c7b5a
--- /dev/null
+++ b/tdeprint/management/kmwlpd.cpp
@@ -0,0 +1,102 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwlpd.h b/tdeprint/management/kmwlpd.h
new file mode 100644
index 000000000..674cdff44
--- /dev/null
+++ b/tdeprint/management/kmwlpd.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwname.cpp b/tdeprint/management/kmwname.cpp
new file mode 100644
index 000000000..fe567f7bb
--- /dev/null
+++ b/tdeprint/management/kmwname.cpp
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwname.h b/tdeprint/management/kmwname.h
new file mode 100644
index 000000000..f933d59ed
--- /dev/null
+++ b/tdeprint/management/kmwname.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwpassword.cpp b/tdeprint/management/kmwpassword.cpp
new file mode 100644
index 000000000..40dc105d5
--- /dev/null
+++ b/tdeprint/management/kmwpassword.cpp
@@ -0,0 +1,133 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwpassword.h b/tdeprint/management/kmwpassword.h
new file mode 100644
index 000000000..a7dfb062a
--- /dev/null
+++ b/tdeprint/management/kmwpassword.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwsmb.cpp b/tdeprint/management/kmwsmb.cpp
new file mode 100644
index 000000000..e76240cf8
--- /dev/null
+++ b/tdeprint/management/kmwsmb.cpp
@@ -0,0 +1,119 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwsmb.h b/tdeprint/management/kmwsmb.h
new file mode 100644
index 000000000..695379a79
--- /dev/null
+++ b/tdeprint/management/kmwsmb.h
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwsocket.cpp b/tdeprint/management/kmwsocket.cpp
new file mode 100644
index 000000000..98aad76a5
--- /dev/null
+++ b/tdeprint/management/kmwsocket.cpp
@@ -0,0 +1,151 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwsocket.h b/tdeprint/management/kmwsocket.h
new file mode 100644
index 000000000..687b52fd4
--- /dev/null
+++ b/tdeprint/management/kmwsocket.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwsocketutil.cpp b/tdeprint/management/kmwsocketutil.cpp
new file mode 100644
index 000000000..e6d06bae2
--- /dev/null
+++ b/tdeprint/management/kmwsocketutil.cpp
@@ -0,0 +1,219 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kmwsocketutil.h b/tdeprint/management/kmwsocketutil.h
new file mode 100644
index 000000000..dfb9f490e
--- /dev/null
+++ b/tdeprint/management/kmwsocketutil.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kxmlcommanddlg.cpp b/tdeprint/management/kxmlcommanddlg.cpp
new file mode 100644
index 000000000..3b42b71d7
--- /dev/null
+++ b/tdeprint/management/kxmlcommanddlg.cpp
@@ -0,0 +1,1059 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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 "
+ "&lt;a&gt;, &lt;b&gt; or &lt;i&gt;." ) );
+ 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/tdeprint/management/kxmlcommanddlg.h b/tdeprint/management/kxmlcommanddlg.h
new file mode 100644
index 000000000..88e590325
--- /dev/null
+++ b/tdeprint/management/kxmlcommanddlg.h
@@ -0,0 +1,127 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kxmlcommandselector.cpp b/tdeprint/management/kxmlcommandselector.cpp
new file mode 100644
index 000000000..dfefe0a8b
--- /dev/null
+++ b/tdeprint/management/kxmlcommandselector.cpp
@@ -0,0 +1,285 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/kxmlcommandselector.h b/tdeprint/management/kxmlcommandselector.h
new file mode 100644
index 000000000..0efc299f9
--- /dev/null
+++ b/tdeprint/management/kxmlcommandselector.h
@@ -0,0 +1,68 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/networkscanner.cpp b/tdeprint/management/networkscanner.cpp
new file mode 100644
index 000000000..a52e66018
--- /dev/null
+++ b/tdeprint/management/networkscanner.cpp
@@ -0,0 +1,421 @@
+/*
+ * 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/tdeprint/management/networkscanner.h b/tdeprint/management/networkscanner.h
new file mode 100644
index 000000000..3d56bb03e
--- /dev/null
+++ b/tdeprint/management/networkscanner.h
@@ -0,0 +1,95 @@
+/*
+ * 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/tdeprint/management/pluginaction.cpp b/tdeprint/management/pluginaction.cpp
new file mode 100644
index 000000000..0aa3c10a3
--- /dev/null
+++ b/tdeprint/management/pluginaction.cpp
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/pluginaction.h b/tdeprint/management/pluginaction.h
new file mode 100644
index 000000000..fb355b597
--- /dev/null
+++ b/tdeprint/management/pluginaction.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/side.png b/tdeprint/management/side.png
new file mode 100644
index 000000000..f7e978d27
--- /dev/null
+++ b/tdeprint/management/side.png
Binary files differ
diff --git a/tdeprint/management/sidepixmap.cpp b/tdeprint/management/sidepixmap.cpp
new file mode 100644
index 000000000..8824dd5fc
--- /dev/null
+++ b/tdeprint/management/sidepixmap.cpp
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/sidepixmap.h b/tdeprint/management/sidepixmap.h
new file mode 100644
index 000000000..a9730883e
--- /dev/null
+++ b/tdeprint/management/sidepixmap.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/smbview.cpp b/tdeprint/management/smbview.cpp
new file mode 100644
index 000000000..fde3a3451
--- /dev/null
+++ b/tdeprint/management/smbview.cpp
@@ -0,0 +1,292 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/smbview.h b/tdeprint/management/smbview.h
new file mode 100644
index 000000000..aea1d920d
--- /dev/null
+++ b/tdeprint/management/smbview.h
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/management/tdeprint_management_module.cpp b/tdeprint/management/tdeprint_management_module.cpp
new file mode 100644
index 000000000..8d4027f75
--- /dev/null
+++ b/tdeprint/management/tdeprint_management_module.cpp
@@ -0,0 +1,56 @@
+/*
+ * 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/tdeprint/management/tiledown.png b/tdeprint/management/tiledown.png
new file mode 100644
index 000000000..71af44b99
--- /dev/null
+++ b/tdeprint/management/tiledown.png
Binary files differ
diff --git a/tdeprint/management/tileup.png b/tdeprint/management/tileup.png
new file mode 100644
index 000000000..cf63939a3
--- /dev/null
+++ b/tdeprint/management/tileup.png
Binary files differ
diff --git a/tdeprint/marginpreview.cpp b/tdeprint/marginpreview.cpp
new file mode 100644
index 000000000..2a5e21e59
--- /dev/null
+++ b/tdeprint/marginpreview.cpp
@@ -0,0 +1,331 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/marginpreview.h b/tdeprint/marginpreview.h
new file mode 100644
index 000000000..e0ed3e775
--- /dev/null
+++ b/tdeprint/marginpreview.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/marginvaluewidget.cpp b/tdeprint/marginvaluewidget.cpp
new file mode 100644
index 000000000..e4f1365c6
--- /dev/null
+++ b/tdeprint/marginvaluewidget.cpp
@@ -0,0 +1,126 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/marginvaluewidget.h b/tdeprint/marginvaluewidget.h
new file mode 100644
index 000000000..97f1409c1
--- /dev/null
+++ b/tdeprint/marginvaluewidget.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/marginwidget.cpp b/tdeprint/marginwidget.cpp
new file mode 100644
index 000000000..53790a112
--- /dev/null
+++ b/tdeprint/marginwidget.cpp
@@ -0,0 +1,376 @@
+/*
+ * 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/tdeprint/marginwidget.h b/tdeprint/marginwidget.h
new file mode 100644
index 000000000..bca3a2c00
--- /dev/null
+++ b/tdeprint/marginwidget.h
@@ -0,0 +1,75 @@
+/*
+ * 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/tdeprint/messagewindow.cpp b/tdeprint/messagewindow.cpp
new file mode 100644
index 000000000..32ce8db9b
--- /dev/null
+++ b/tdeprint/messagewindow.cpp
@@ -0,0 +1,121 @@
+/*
+ * 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/tdeprint/messagewindow.h b/tdeprint/messagewindow.h
new file mode 100644
index 000000000..44e211808
--- /dev/null
+++ b/tdeprint/messagewindow.h
@@ -0,0 +1,55 @@
+/*
+ * 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/tdeprint/pics/CMakeLists.txt b/tdeprint/pics/CMakeLists.txt
new file mode 100644
index 000000000..5363b16ef
--- /dev/null
+++ b/tdeprint/pics/CMakeLists.txt
@@ -0,0 +1,41 @@
+#################################################
+#
+# (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/tdeprint/pics/Makefile.am b/tdeprint/pics/Makefile.am
new file mode 100644
index 000000000..a46f6530d
--- /dev/null
+++ b/tdeprint/pics/Makefile.am
@@ -0,0 +1,22 @@
+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/tdeprint/pics/cr16-action-filterstop.png b/tdeprint/pics/cr16-action-filterstop.png
new file mode 100644
index 000000000..8e49c18b1
--- /dev/null
+++ b/tdeprint/pics/cr16-action-filterstop.png
Binary files differ
diff --git a/tdeprint/pics/cr16-action-tdeprint_restartsrv.png b/tdeprint/pics/cr16-action-tdeprint_restartsrv.png
new file mode 100644
index 000000000..5d8f28cba
--- /dev/null
+++ b/tdeprint/pics/cr16-action-tdeprint_restartsrv.png
Binary files differ
diff --git a/tdeprint/pics/cr16-action-tdeprint_uploadsmb.png b/tdeprint/pics/cr16-action-tdeprint_uploadsmb.png
new file mode 100644
index 000000000..c6d68fb09
--- /dev/null
+++ b/tdeprint/pics/cr16-action-tdeprint_uploadsmb.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_computer.png b/tdeprint/pics/cr16-app-tdeprint_computer.png
new file mode 100644
index 000000000..85a078c13
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_computer.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_job.png b/tdeprint/pics/cr16-app-tdeprint_job.png
new file mode 100644
index 000000000..665a4e31b
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_job.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_job_cancelled.png b/tdeprint/pics/cr16-app-tdeprint_job_cancelled.png
new file mode 100644
index 000000000..40e351f1c
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_job_cancelled.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_job_completed.png b/tdeprint/pics/cr16-app-tdeprint_job_completed.png
new file mode 100644
index 000000000..246cf944f
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_job_completed.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_job_error.png b/tdeprint/pics/cr16-app-tdeprint_job_error.png
new file mode 100644
index 000000000..a07deb1cc
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_job_error.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_job_process.png b/tdeprint/pics/cr16-app-tdeprint_job_process.png
new file mode 100644
index 000000000..4b4d8504c
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_job_process.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_job_stopped.png b/tdeprint/pics/cr16-app-tdeprint_job_stopped.png
new file mode 100644
index 000000000..bf3b64c1d
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_job_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer.png b/tdeprint/pics/cr16-app-tdeprint_printer.png
new file mode 100644
index 000000000..a1bb6b822
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_class.png b/tdeprint/pics/cr16-app-tdeprint_printer_class.png
new file mode 100644
index 000000000..14fbd65d7
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_class.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_class_process.png b/tdeprint/pics/cr16-app-tdeprint_printer_class_process.png
new file mode 100644
index 000000000..191682af2
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_class_process.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_class_stopped.png b/tdeprint/pics/cr16-app-tdeprint_printer_class_stopped.png
new file mode 100644
index 000000000..100947a1a
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_class_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_defect.png b/tdeprint/pics/cr16-app-tdeprint_printer_defect.png
new file mode 100644
index 000000000..971e713cd
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_defect.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_process.png b/tdeprint/pics/cr16-app-tdeprint_printer_process.png
new file mode 100644
index 000000000..edc4857cb
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_process.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_remote.png b/tdeprint/pics/cr16-app-tdeprint_printer_remote.png
new file mode 100644
index 000000000..cb1e27533
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_remote.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_remote_process.png b/tdeprint/pics/cr16-app-tdeprint_printer_remote_process.png
new file mode 100644
index 000000000..a0a6f708b
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_remote_process.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_remote_stopped.png b/tdeprint/pics/cr16-app-tdeprint_printer_remote_stopped.png
new file mode 100644
index 000000000..db04564f1
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_remote_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr16-app-tdeprint_printer_stopped.png b/tdeprint/pics/cr16-app-tdeprint_printer_stopped.png
new file mode 100644
index 000000000..68e707ec8
--- /dev/null
+++ b/tdeprint/pics/cr16-app-tdeprint_printer_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-history.png b/tdeprint/pics/cr22-action-history.png
new file mode 100644
index 000000000..ea6454004
--- /dev/null
+++ b/tdeprint/pics/cr22-action-history.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-package_utilities.png b/tdeprint/pics/cr22-action-package_utilities.png
new file mode 100644
index 000000000..eb5333f1f
--- /dev/null
+++ b/tdeprint/pics/cr22-action-package_utilities.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_addprinter.png b/tdeprint/pics/cr22-action-tdeprint_addprinter.png
new file mode 100644
index 000000000..05eb81a03
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_addprinter.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_addpseudo.png b/tdeprint/pics/cr22-action-tdeprint_addpseudo.png
new file mode 100644
index 000000000..fc5bbbb8e
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_addpseudo.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_configmgr.png b/tdeprint/pics/cr22-action-tdeprint_configmgr.png
new file mode 100644
index 000000000..99765c81b
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_configmgr.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_configsrv.png b/tdeprint/pics/cr22-action-tdeprint_configsrv.png
new file mode 100644
index 000000000..17fb0ec1c
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_configsrv.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_defaulthard.png b/tdeprint/pics/cr22-action-tdeprint_defaulthard.png
new file mode 100644
index 000000000..3762942a1
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_defaulthard.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_defaultsoft.png b/tdeprint/pics/cr22-action-tdeprint_defaultsoft.png
new file mode 100644
index 000000000..eecca9239
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_defaultsoft.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_enableprinter.png b/tdeprint/pics/cr22-action-tdeprint_enableprinter.png
new file mode 100644
index 000000000..31c064ba9
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_enableprinter.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_printer.png b/tdeprint/pics/cr22-action-tdeprint_printer.png
new file mode 100644
index 000000000..ae63e0ce4
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_printer.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_printer_infos.png b/tdeprint/pics/cr22-action-tdeprint_printer_infos.png
new file mode 100644
index 000000000..6643cde36
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_printer_infos.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_printstate.png b/tdeprint/pics/cr22-action-tdeprint_printstate.png
new file mode 100644
index 000000000..23d5c0876
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_printstate.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_queuestate.png b/tdeprint/pics/cr22-action-tdeprint_queuestate.png
new file mode 100644
index 000000000..8c2e1c0b5
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_queuestate.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_report.png b/tdeprint/pics/cr22-action-tdeprint_report.png
new file mode 100644
index 000000000..c06f3cf5d
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_report.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_restartsrv.png b/tdeprint/pics/cr22-action-tdeprint_restartsrv.png
new file mode 100644
index 000000000..9e4c1ad8e
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_restartsrv.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_stopprinter.png b/tdeprint/pics/cr22-action-tdeprint_stopprinter.png
new file mode 100644
index 000000000..73b27d9fd
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_stopprinter.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_testprinter.png b/tdeprint/pics/cr22-action-tdeprint_testprinter.png
new file mode 100644
index 000000000..6aba9c1b3
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_testprinter.png
Binary files differ
diff --git a/tdeprint/pics/cr22-action-tdeprint_uploadsmb.png b/tdeprint/pics/cr22-action-tdeprint_uploadsmb.png
new file mode 100644
index 000000000..f7daf4407
--- /dev/null
+++ b/tdeprint/pics/cr22-action-tdeprint_uploadsmb.png
Binary files differ
diff --git a/tdeprint/pics/cr22-app-tdeprint_printer.png b/tdeprint/pics/cr22-app-tdeprint_printer.png
new file mode 100644
index 000000000..e2ebb0c6e
--- /dev/null
+++ b/tdeprint/pics/cr22-app-tdeprint_printer.png
Binary files differ
diff --git a/tdeprint/pics/cr32-action-tdeprint_inklevel.png b/tdeprint/pics/cr32-action-tdeprint_inklevel.png
new file mode 100644
index 000000000..269f3c602
--- /dev/null
+++ b/tdeprint/pics/cr32-action-tdeprint_inklevel.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer.png b/tdeprint/pics/cr32-app-tdeprint_printer.png
new file mode 100644
index 000000000..61d164598
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_class.png b/tdeprint/pics/cr32-app-tdeprint_printer_class.png
new file mode 100644
index 000000000..ff28edb25
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_class.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_class_process.png b/tdeprint/pics/cr32-app-tdeprint_printer_class_process.png
new file mode 100644
index 000000000..5ddf47ce3
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_class_process.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_class_stopped.png b/tdeprint/pics/cr32-app-tdeprint_printer_class_stopped.png
new file mode 100644
index 000000000..0f8841bbd
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_class_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_defect.png b/tdeprint/pics/cr32-app-tdeprint_printer_defect.png
new file mode 100644
index 000000000..5efd22227
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_defect.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_process.png b/tdeprint/pics/cr32-app-tdeprint_printer_process.png
new file mode 100644
index 000000000..ced236bb6
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_process.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_remote.png b/tdeprint/pics/cr32-app-tdeprint_printer_remote.png
new file mode 100644
index 000000000..13af62943
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_remote.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_remote_process.png b/tdeprint/pics/cr32-app-tdeprint_printer_remote_process.png
new file mode 100644
index 000000000..5fde48e73
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_remote_process.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_remote_stopped.png b/tdeprint/pics/cr32-app-tdeprint_printer_remote_stopped.png
new file mode 100644
index 000000000..0f5f31c63
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_remote_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_stopped.png b/tdeprint/pics/cr32-app-tdeprint_printer_stopped.png
new file mode 100644
index 000000000..79c84f090
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_stopped.png
Binary files differ
diff --git a/tdeprint/pics/cr32-app-tdeprint_printer_users.png b/tdeprint/pics/cr32-app-tdeprint_printer_users.png
new file mode 100644
index 000000000..a2fb7da65
--- /dev/null
+++ b/tdeprint/pics/cr32-app-tdeprint_printer_users.png
Binary files differ
diff --git a/tdeprint/pics/cr48-app-tdeprint_printer.png b/tdeprint/pics/cr48-app-tdeprint_printer.png
new file mode 100644
index 000000000..786015d78
--- /dev/null
+++ b/tdeprint/pics/cr48-app-tdeprint_printer.png
Binary files differ
diff --git a/tdeprint/pics/cr48-app-tdeprint_printer_class.png b/tdeprint/pics/cr48-app-tdeprint_printer_class.png
new file mode 100644
index 000000000..7f43f8e7f
--- /dev/null
+++ b/tdeprint/pics/cr48-app-tdeprint_printer_class.png
Binary files differ
diff --git a/tdeprint/pics/cr64-app-tdeprint_printer.png b/tdeprint/pics/cr64-app-tdeprint_printer.png
new file mode 100644
index 000000000..561ca9fd5
--- /dev/null
+++ b/tdeprint/pics/cr64-app-tdeprint_printer.png
Binary files differ
diff --git a/tdeprint/pics/cr64-app-tdeprint_printer_class.png b/tdeprint/pics/cr64-app-tdeprint_printer_class.png
new file mode 100644
index 000000000..53a67d3dc
--- /dev/null
+++ b/tdeprint/pics/cr64-app-tdeprint_printer_class.png
Binary files differ
diff --git a/tdeprint/pics/processsign.png b/tdeprint/pics/processsign.png
new file mode 100644
index 000000000..4cb885345
--- /dev/null
+++ b/tdeprint/pics/processsign.png
Binary files differ
diff --git a/tdeprint/pics/stopsign.png b/tdeprint/pics/stopsign.png
new file mode 100644
index 000000000..6b990a2f7
--- /dev/null
+++ b/tdeprint/pics/stopsign.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_collate.png b/tdeprint/pics/tdeprint_collate.png
new file mode 100644
index 000000000..726e44c29
--- /dev/null
+++ b/tdeprint/pics/tdeprint_collate.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_collate_reverse.png b/tdeprint/pics/tdeprint_collate_reverse.png
new file mode 100644
index 000000000..a6cbf2446
--- /dev/null
+++ b/tdeprint/pics/tdeprint_collate_reverse.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_color.png b/tdeprint/pics/tdeprint_color.png
new file mode 100644
index 000000000..40de5f355
--- /dev/null
+++ b/tdeprint/pics/tdeprint_color.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_dupl_none.png b/tdeprint/pics/tdeprint_dupl_none.png
new file mode 100644
index 000000000..1dc449046
--- /dev/null
+++ b/tdeprint/pics/tdeprint_dupl_none.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_duplex_long.png b/tdeprint/pics/tdeprint_duplex_long.png
new file mode 100644
index 000000000..1f269fcd4
--- /dev/null
+++ b/tdeprint/pics/tdeprint_duplex_long.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_duplex_none.png b/tdeprint/pics/tdeprint_duplex_none.png
new file mode 100644
index 000000000..f4b6b16ec
--- /dev/null
+++ b/tdeprint/pics/tdeprint_duplex_none.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_duplex_short.png b/tdeprint/pics/tdeprint_duplex_short.png
new file mode 100644
index 000000000..5bf40a9c2
--- /dev/null
+++ b/tdeprint/pics/tdeprint_duplex_short.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_grayscale.png b/tdeprint/pics/tdeprint_grayscale.png
new file mode 100644
index 000000000..68ac097fb
--- /dev/null
+++ b/tdeprint/pics/tdeprint_grayscale.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_landscape.png b/tdeprint/pics/tdeprint_landscape.png
new file mode 100644
index 000000000..c61d8c44b
--- /dev/null
+++ b/tdeprint/pics/tdeprint_landscape.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_nup1.png b/tdeprint/pics/tdeprint_nup1.png
new file mode 100644
index 000000000..2604b67e2
--- /dev/null
+++ b/tdeprint/pics/tdeprint_nup1.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_nup2.png b/tdeprint/pics/tdeprint_nup2.png
new file mode 100644
index 000000000..ac297c192
--- /dev/null
+++ b/tdeprint/pics/tdeprint_nup2.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_nup4.png b/tdeprint/pics/tdeprint_nup4.png
new file mode 100644
index 000000000..d74ea0abe
--- /dev/null
+++ b/tdeprint/pics/tdeprint_nup4.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_nupother.png b/tdeprint/pics/tdeprint_nupother.png
new file mode 100644
index 000000000..5bfbf3245
--- /dev/null
+++ b/tdeprint/pics/tdeprint_nupother.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_opt_duplex.png b/tdeprint/pics/tdeprint_opt_duplex.png
new file mode 100644
index 000000000..e2a44ecae
--- /dev/null
+++ b/tdeprint/pics/tdeprint_opt_duplex.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_pagesize.png b/tdeprint/pics/tdeprint_pagesize.png
new file mode 100644
index 000000000..54962b742
--- /dev/null
+++ b/tdeprint/pics/tdeprint_pagesize.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_portrait.png b/tdeprint/pics/tdeprint_portrait.png
new file mode 100644
index 000000000..8bf1f9646
--- /dev/null
+++ b/tdeprint/pics/tdeprint_portrait.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_prettyprint.png b/tdeprint/pics/tdeprint_prettyprint.png
new file mode 100644
index 000000000..9e6f0fbb0
--- /dev/null
+++ b/tdeprint/pics/tdeprint_prettyprint.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_revlandscape.png b/tdeprint/pics/tdeprint_revlandscape.png
new file mode 100644
index 000000000..1d602302a
--- /dev/null
+++ b/tdeprint/pics/tdeprint_revlandscape.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_revportrait.png b/tdeprint/pics/tdeprint_revportrait.png
new file mode 100644
index 000000000..81ea9d675
--- /dev/null
+++ b/tdeprint/pics/tdeprint_revportrait.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_uncollate.png b/tdeprint/pics/tdeprint_uncollate.png
new file mode 100644
index 000000000..9ce59a380
--- /dev/null
+++ b/tdeprint/pics/tdeprint_uncollate.png
Binary files differ
diff --git a/tdeprint/pics/tdeprint_uncollate_reverse.png b/tdeprint/pics/tdeprint_uncollate_reverse.png
new file mode 100644
index 000000000..afe0336cb
--- /dev/null
+++ b/tdeprint/pics/tdeprint_uncollate_reverse.png
Binary files differ
diff --git a/tdeprint/plugincombobox.cpp b/tdeprint/plugincombobox.cpp
new file mode 100644
index 000000000..e9a41ddeb
--- /dev/null
+++ b/tdeprint/plugincombobox.cpp
@@ -0,0 +1,104 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/plugincombobox.h b/tdeprint/plugincombobox.h
new file mode 100644
index 000000000..668407e14
--- /dev/null
+++ b/tdeprint/plugincombobox.h
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/posterpreview.cpp b/tdeprint/posterpreview.cpp
new file mode 100644
index 000000000..7e8542c22
--- /dev/null
+++ b/tdeprint/posterpreview.cpp
@@ -0,0 +1,294 @@
+/*
+ * 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/tdeprint/posterpreview.h b/tdeprint/posterpreview.h
new file mode 100644
index 000000000..d0c362a04
--- /dev/null
+++ b/tdeprint/posterpreview.h
@@ -0,0 +1,75 @@
+/*
+ * 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/tdeprint/ppdloader.cpp b/tdeprint/ppdloader.cpp
new file mode 100644
index 000000000..2e2250dd2
--- /dev/null
+++ b/tdeprint/ppdloader.cpp
@@ -0,0 +1,531 @@
+/*
+ * 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/tdeprint/ppdloader.h b/tdeprint/ppdloader.h
new file mode 100644
index 000000000..c4eb9fbb5
--- /dev/null
+++ b/tdeprint/ppdloader.h
@@ -0,0 +1,74 @@
+/*
+ * 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/tdeprint/ppdparser.cpp b/tdeprint/ppdparser.cpp
new file mode 100644
index 000000000..21f3fb77e
--- /dev/null
+++ b/tdeprint/ppdparser.cpp
@@ -0,0 +1,1456 @@
+/* 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/tdeprint/ppdparser.cpp.h b/tdeprint/ppdparser.cpp.h
new file mode 100644
index 000000000..182bebd34
--- /dev/null
+++ b/tdeprint/ppdparser.cpp.h
@@ -0,0 +1,81 @@
+#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/tdeprint/ppdparser.y b/tdeprint/ppdparser.y
new file mode 100644
index 000000000..f750d9316
--- /dev/null
+++ b/tdeprint/ppdparser.y
@@ -0,0 +1,118 @@
+%{
+/*
+ * 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/tdeprint/ppdscanner.cpp b/tdeprint/ppdscanner.cpp
new file mode 100644
index 000000000..50611aaa1
--- /dev/null
+++ b/tdeprint/ppdscanner.cpp
@@ -0,0 +1,1914 @@
+#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/tdeprint/ppdscanner.l b/tdeprint/ppdscanner.l
new file mode 100644
index 000000000..ba60ee2f6
--- /dev/null
+++ b/tdeprint/ppdscanner.l
@@ -0,0 +1,141 @@
+%{
+/*
+ * 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/tdeprint/printerfilter.cpp b/tdeprint/printerfilter.cpp
new file mode 100644
index 000000000..e0161a50a
--- /dev/null
+++ b/tdeprint/printerfilter.cpp
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/printerfilter.h b/tdeprint/printerfilter.h
new file mode 100644
index 000000000..603565ebb
--- /dev/null
+++ b/tdeprint/printerfilter.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/CMakeLists.txt b/tdeprint/rlpr/CMakeLists.txt
new file mode 100644
index 000000000..f8468a0dc
--- /dev/null
+++ b/tdeprint/rlpr/CMakeLists.txt
@@ -0,0 +1,54 @@
+#################################################
+#
+# (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/tdeprint/rlpr/Makefile.am b/tdeprint/rlpr/Makefile.am
new file mode 100644
index 000000000..1946fed94
--- /dev/null
+++ b/tdeprint/rlpr/Makefile.am
@@ -0,0 +1,17 @@
+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/tdeprint/rlpr/kmconfigproxy.cpp b/tdeprint/rlpr/kmconfigproxy.cpp
new file mode 100644
index 000000000..0f8ca3743
--- /dev/null
+++ b/tdeprint/rlpr/kmconfigproxy.cpp
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmconfigproxy.h b/tdeprint/rlpr/kmconfigproxy.h
new file mode 100644
index 000000000..6f3b7ef42
--- /dev/null
+++ b/tdeprint/rlpr/kmconfigproxy.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmproprlpr.cpp b/tdeprint/rlpr/kmproprlpr.cpp
new file mode 100644
index 000000000..62fe97827
--- /dev/null
+++ b/tdeprint/rlpr/kmproprlpr.cpp
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmproprlpr.h b/tdeprint/rlpr/kmproprlpr.h
new file mode 100644
index 000000000..cdf9aef7b
--- /dev/null
+++ b/tdeprint/rlpr/kmproprlpr.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmproxywidget.cpp b/tdeprint/rlpr/kmproxywidget.cpp
new file mode 100644
index 000000000..94ad60340
--- /dev/null
+++ b/tdeprint/rlpr/kmproxywidget.cpp
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmproxywidget.h b/tdeprint/rlpr/kmproxywidget.h
new file mode 100644
index 000000000..0c1a5079b
--- /dev/null
+++ b/tdeprint/rlpr/kmproxywidget.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmrlprfactory.cpp b/tdeprint/rlpr/kmrlprfactory.cpp
new file mode 100644
index 000000000..f5cabe6bd
--- /dev/null
+++ b/tdeprint/rlpr/kmrlprfactory.cpp
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmrlprmanager.cpp b/tdeprint/rlpr/kmrlprmanager.cpp
new file mode 100644
index 000000000..64f6acde1
--- /dev/null
+++ b/tdeprint/rlpr/kmrlprmanager.cpp
@@ -0,0 +1,158 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmrlprmanager.h b/tdeprint/rlpr/kmrlprmanager.h
new file mode 100644
index 000000000..57af7f99f
--- /dev/null
+++ b/tdeprint/rlpr/kmrlprmanager.h
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmrlpruimanager.cpp b/tdeprint/rlpr/kmrlpruimanager.cpp
new file mode 100644
index 000000000..9bae2cdc4
--- /dev/null
+++ b/tdeprint/rlpr/kmrlpruimanager.cpp
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmrlpruimanager.h b/tdeprint/rlpr/kmrlpruimanager.h
new file mode 100644
index 000000000..e2bc5de73
--- /dev/null
+++ b/tdeprint/rlpr/kmrlpruimanager.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmwrlpr.cpp b/tdeprint/rlpr/kmwrlpr.cpp
new file mode 100644
index 000000000..70defc27b
--- /dev/null
+++ b/tdeprint/rlpr/kmwrlpr.cpp
@@ -0,0 +1,210 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/kmwrlpr.h b/tdeprint/rlpr/kmwrlpr.h
new file mode 100644
index 000000000..7c1aa74f2
--- /dev/null
+++ b/tdeprint/rlpr/kmwrlpr.h
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/krlprprinterimpl.cpp b/tdeprint/rlpr/krlprprinterimpl.cpp
new file mode 100644
index 000000000..a6b0e5986
--- /dev/null
+++ b/tdeprint/rlpr/krlprprinterimpl.cpp
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/krlprprinterimpl.h b/tdeprint/rlpr/krlprprinterimpl.h
new file mode 100644
index 000000000..7af98df0c
--- /dev/null
+++ b/tdeprint/rlpr/krlprprinterimpl.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/rlpr/rlpr.print b/tdeprint/rlpr/rlpr.print
new file mode 100644
index 000000000..25f16ee63
--- /dev/null
+++ b/tdeprint/rlpr/rlpr.print
@@ -0,0 +1,84 @@
+[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/tdeprint/signal_proc.c b/tdeprint/signal_proc.c
new file mode 100644
index 000000000..8ff30e56e
--- /dev/null
+++ b/tdeprint/signal_proc.c
@@ -0,0 +1,136 @@
+#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/tdeprint/specials.desktop b/tdeprint/specials.desktop
new file mode 100644
index 000000000..72c648c4c
--- /dev/null
+++ b/tdeprint/specials.desktop
@@ -0,0 +1,1196 @@
+[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/tdeprint/tdeprintcheck.cpp b/tdeprint/tdeprintcheck.cpp
new file mode 100644
index 000000000..1ace082a4
--- /dev/null
+++ b/tdeprint/tdeprintcheck.cpp
@@ -0,0 +1,134 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; 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/tdeprint/tdeprintcheck.h b/tdeprint/tdeprintcheck.h
new file mode 100644
index 000000000..ae1264a97
--- /dev/null
+++ b/tdeprint/tdeprintcheck.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/tdeprintd.cpp b/tdeprint/tdeprintd.cpp
new file mode 100644
index 000000000..d6237b2b2
--- /dev/null
+++ b/tdeprint/tdeprintd.cpp
@@ -0,0 +1,315 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/tdeprintd.desktop b/tdeprint/tdeprintd.desktop
new file mode 100644
index 000000000..45cf8ece4
--- /dev/null
+++ b/tdeprint/tdeprintd.desktop
@@ -0,0 +1,162 @@
+[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/tdeprint/tdeprintd.h b/tdeprint/tdeprintd.h
new file mode 100644
index 000000000..597ffbc5b
--- /dev/null
+++ b/tdeprint/tdeprintd.h
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/tdeprintrc b/tdeprint/tdeprintrc
new file mode 100644
index 000000000..7e34d8e9e
--- /dev/null
+++ b/tdeprint/tdeprintrc
@@ -0,0 +1,7 @@
+[General]
+PrintSystem=cups
+Orientation=1
+ViewType=1
+ViewToolBar=false
+ViewMenuBar=true
+ViewPrinterInfos=true
diff --git a/tdeprint/tdeprintrc.upd b/tdeprint/tdeprintrc.upd
new file mode 100644
index 000000000..faf6abab8
--- /dev/null
+++ b/tdeprint/tdeprintrc.upd
@@ -0,0 +1,6 @@
+Id=kde-3.1-toolbar
+File=tdeprintrc
+Group=General
+Options=copy
+Key=ViewToolBar,ViewMenuBar
+RemoveKey=ViewToolBar
diff --git a/tdeprint/testprint.ps b/tdeprint/testprint.ps
new file mode 100644
index 000000000..bcebfcb21
--- /dev/null
+++ b/tdeprint/testprint.ps
@@ -0,0 +1,522 @@
+%!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/tdeprint/tests/Makefile.am b/tdeprint/tests/Makefile.am
new file mode 100644
index 000000000..53021a6e2
--- /dev/null
+++ b/tdeprint/tests/Makefile.am
@@ -0,0 +1,15 @@
+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/tdeprint/tests/back.xpm b/tdeprint/tests/back.xpm
new file mode 100644
index 000000000..ac57ecd0b
--- /dev/null
+++ b/tdeprint/tests/back.xpm
@@ -0,0 +1,105 @@
+/* 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/tdeprint/tests/drawdemo.cpp b/tdeprint/tests/drawdemo.cpp
new file mode 100644
index 000000000..20fc3d12e
--- /dev/null
+++ b/tdeprint/tests/drawdemo.cpp
@@ -0,0 +1,253 @@
+/****************************************************************************
+** $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/tdeprint/tests/drawdemo.h b/tdeprint/tests/drawdemo.h
new file mode 100644
index 000000000..963da64db
--- /dev/null
+++ b/tdeprint/tests/drawdemo.h
@@ -0,0 +1,30 @@
+#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/tdeprint/tests/forward.xpm b/tdeprint/tests/forward.xpm
new file mode 100644
index 000000000..7eadb1474
--- /dev/null
+++ b/tdeprint/tests/forward.xpm
@@ -0,0 +1,110 @@
+/* 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/tdeprint/tests/helpwindow.cpp b/tdeprint/tests/helpwindow.cpp
new file mode 100644
index 000000000..bee755d20
--- /dev/null
+++ b/tdeprint/tests/helpwindow.cpp
@@ -0,0 +1,351 @@
+/****************************************************************************
+** $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/tdeprint/tests/helpwindow.h b/tdeprint/tests/helpwindow.h
new file mode 100644
index 000000000..c444b8144
--- /dev/null
+++ b/tdeprint/tests/helpwindow.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+** $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/tdeprint/tests/home.xpm b/tdeprint/tests/home.xpm
new file mode 100644
index 000000000..1cb22447f
--- /dev/null
+++ b/tdeprint/tests/home.xpm
@@ -0,0 +1,119 @@
+/* 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/tdeprint/tests/main.cpp b/tdeprint/tests/main.cpp
new file mode 100644
index 000000000..a1dc6b5e0
--- /dev/null
+++ b/tdeprint/tests/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+** $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/tdeprint/tests/richpage.cpp b/tdeprint/tests/richpage.cpp
new file mode 100644
index 000000000..30da712de
--- /dev/null
+++ b/tdeprint/tests/richpage.cpp
@@ -0,0 +1,85 @@
+#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/tdeprint/tests/richpage.h b/tdeprint/tests/richpage.h
new file mode 100644
index 000000000..33e4304e7
--- /dev/null
+++ b/tdeprint/tests/richpage.h
@@ -0,0 +1,24 @@
+#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/tdeprint/tools/CMakeLists.txt b/tdeprint/tools/CMakeLists.txt
new file mode 100644
index 000000000..4c2682eee
--- /dev/null
+++ b/tdeprint/tools/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (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/tdeprint/tools/Makefile.am b/tdeprint/tools/Makefile.am
new file mode 100644
index 000000000..d2ca2be71
--- /dev/null
+++ b/tdeprint/tools/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = escputil
diff --git a/tdeprint/tools/escputil/CMakeLists.txt b/tdeprint/tools/escputil/CMakeLists.txt
new file mode 100644
index 000000000..3494d3cfb
--- /dev/null
+++ b/tdeprint/tools/escputil/CMakeLists.txt
@@ -0,0 +1,42 @@
+#################################################
+#
+# (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/tdeprint/tools/escputil/Makefile.am b/tdeprint/tools/escputil/Makefile.am
new file mode 100644
index 000000000..ac7620ef1
--- /dev/null
+++ b/tdeprint/tools/escputil/Makefile.am
@@ -0,0 +1,12 @@
+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/tdeprint/tools/escputil/escputil.desktop b/tdeprint/tools/escputil/escputil.desktop
new file mode 100644
index 000000000..40a5c88f3
--- /dev/null
+++ b/tdeprint/tools/escputil/escputil.desktop
@@ -0,0 +1,29 @@
+[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/tdeprint/tools/escputil/escpwidget.cpp b/tdeprint/tools/escputil/escpwidget.cpp
new file mode 100644
index 000000000..3000b0788
--- /dev/null
+++ b/tdeprint/tools/escputil/escpwidget.cpp
@@ -0,0 +1,261 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/tools/escputil/escpwidget.h b/tdeprint/tools/escputil/escpwidget.h
new file mode 100644
index 000000000..7e3ba55e8
--- /dev/null
+++ b/tdeprint/tools/escputil/escpwidget.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/treecombobox.cpp b/tdeprint/treecombobox.cpp
new file mode 100644
index 000000000..7a2adc8ef
--- /dev/null
+++ b/tdeprint/treecombobox.cpp
@@ -0,0 +1,156 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/treecombobox.h b/tdeprint/treecombobox.h
new file mode 100644
index 000000000..6026b99f1
--- /dev/null
+++ b/tdeprint/treecombobox.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/util.cpp b/tdeprint/util.cpp
new file mode 100644
index 000000000..b4025a087
--- /dev/null
+++ b/tdeprint/util.cpp
@@ -0,0 +1,139 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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/tdeprint/util.h b/tdeprint/util.h
new file mode 100644
index 000000000..db4ad1cd6
--- /dev/null
+++ b/tdeprint/util.h
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see 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