├── .github └── workflows │ └── build.yml ├── .gitignore ├── CHANGELOG ├── INSTALL.md ├── LICENSE ├── Makefile.am ├── README.md ├── TROUBLESHOOTING.md ├── build.sh ├── configure.ac ├── docs ├── DYMO_SDK_for_Linux.rtf ├── Makefile.am ├── SAMPLES ├── TestImage.png ├── longtest.txt ├── test.ps ├── test.txt └── testprint.ps ├── dymo-cups-drivers.spec ├── install-sh ├── missing ├── mkinstalldirs ├── ppd ├── Makefile.am ├── lm400.ppd ├── lm450.ppd ├── lmmls.ppd ├── lmpc.ppd ├── lmpc2.ppd ├── lmpnp.ppd ├── lmwpnp.ppd ├── lp350.ppd ├── lw300.ppd ├── lw310.ppd ├── lw315.ppd ├── lw320.ppd ├── lw330.ppd ├── lw330t.ppd ├── lw400.ppd ├── lw400t.ppd ├── lw450.ppd ├── lw450dl.ppd ├── lw450dt.ppd ├── lw450t.ppd ├── lw450tt.ppd ├── lw4xl.ppd ├── lw550.ppd ├── lw550p.ppd ├── lw550t.ppd ├── lw550tp.ppd ├── lw5xl.ppd ├── lw5xlp.ppd ├── lwduol.ppd ├── lwduot.ppd ├── lwduot2.ppd ├── lwtt.ppd ├── lww.ppd └── se450.ppd ├── samples ├── Makefile.am ├── custom_paper │ ├── CairoUtils.h │ ├── CustomPaper.cpp │ └── Makefile.am ├── custom_paper_tape │ ├── CairoUtils.h │ ├── CustomPaperTape.cpp │ └── Makefile.am ├── paper_bounds │ ├── CairoUtils.h │ ├── Makefile.am │ └── PaperBounds.cpp ├── paper_list │ ├── Makefile.am │ └── PaperList.cpp └── test_label │ ├── CairoUtils.h │ ├── Makefile.am │ ├── TestLabel.cpp │ ├── barcode.png │ ├── photo.png │ └── tel.png ├── src ├── Makefile.am ├── common │ ├── CommonTypedefs.h │ ├── CupsFilter.h │ ├── CupsPrintEnvironment.cpp │ ├── CupsPrintEnvironment.h │ ├── DummyLanguageMonitor.cpp │ ├── DummyLanguageMonitor.h │ ├── ErrorDiffusionHalftoning.cpp │ ├── ErrorDiffusionHalftoning.h │ ├── Halftoning.cpp │ ├── Halftoning.h │ ├── NonLinearLaplacianHalftoning.cpp │ ├── NonLinearLaplacianHalftoning.h │ ├── PrinterDriver.h │ └── tests │ │ ├── MOCK_PrintEnvironment.cpp │ │ ├── MOCK_PrintEnvironment.h │ │ ├── Makefile.am │ │ ├── TestCommon.cpp │ │ ├── TestCommon.h │ │ ├── TestErrorDiffusionHalftoning.cpp │ │ ├── TestErrorDiffusionHalftoning.h │ │ ├── TestNLLHalftoning.cpp │ │ ├── TestNLLHalftoning.h │ │ └── testsMain.cpp ├── lm │ ├── CupsFilterLabelManager.cpp │ ├── CupsFilterLabelManager.h │ ├── LabelManagerDriver.cpp │ ├── LabelManagerDriver.h │ ├── LabelManagerLanguageMonitor.cpp │ ├── LabelManagerLanguageMonitor.h │ ├── Makefile.am │ ├── raster2dymolm.cpp │ └── tests │ │ ├── Makefile.am │ │ ├── TestLabelManagerDriver.cpp │ │ ├── TestLabelManagerDriver.h │ │ ├── TestLabelManagerFilter.cpp │ │ └── TestLabelManagerFilter.h └── lw │ ├── CupsFilterLabelWriter.cpp │ ├── CupsFilterLabelWriter.h │ ├── LabelWriterDriver.cpp │ ├── LabelWriterDriver.h │ ├── LabelWriterLanguageMonitor.cpp │ ├── LabelWriterLanguageMonitor.h │ ├── Makefile.am │ ├── raster2dymolw.cpp │ └── tests │ ├── MOCK_LWLMPrintEnvironment.cpp │ ├── MOCK_LWLMPrintEnvironment.h │ ├── Makefile.am │ ├── TestLabelWriterDriver.cpp │ ├── TestLabelWriterDriver.h │ ├── TestLabelWriterFilter.cpp │ ├── TestLabelWriterFilter.h │ ├── TestLabelWriterLanguageMonitor.cpp │ └── TestLabelWriterLanguageMonitor.h └── src_v2 ├── Makefile.am ├── common ├── CommonTypedefs.h ├── CupsFilter.h ├── CupsPrintEnvironment.cpp ├── CupsPrintEnvironment.h ├── CupsUtils.cpp ├── CupsUtils.h ├── DummyLanguageMonitor.h ├── ErrorDiffusionHalftoning.h ├── Halftoning.h ├── NonLinearLaplacianHalftoning.cpp ├── NonLinearLaplacianHalftoning.h ├── PrinterDriver.h └── tests │ ├── MOCK_PrintEnvironment.cpp │ ├── MOCK_PrintEnvironment.h │ ├── Makefile.am │ ├── TestCommon.cpp │ ├── TestCommon.h │ ├── TestErrorDiffusionHalftoning.cpp │ ├── TestErrorDiffusionHalftoning.h │ ├── TestNLLHalftoning.cpp │ ├── TestNLLHalftoning.h │ └── testsMain.cpp ├── lm ├── LabelManagerDriver.h ├── LabelManagerDriverInitializer.cpp ├── LabelManagerDriverInitializer.h ├── LabelManagerDriverV2.cpp ├── LabelManagerDriverV2.h ├── LabelManagerLanguageMonitor.h ├── LabelManagerLanguageMonitorV2.cpp ├── LabelManagerLanguageMonitorV2.h ├── Makefile.am ├── raster2dymolm.cpp └── tests │ ├── Makefile.am │ ├── TestLabelManagerDriver.cpp │ ├── TestLabelManagerDriver.h │ ├── TestLabelManagerFilter.cpp │ └── TestLabelManagerFilter.h └── lw ├── LabelWriterDriver.h ├── LabelWriterDriverInitializer.cpp ├── LabelWriterDriverInitializer.h ├── LabelWriterDriverV2.cpp ├── LabelWriterDriverV2.h ├── LabelWriterLanguageMonitor.h ├── LabelWriterLanguageMonitorV2.cpp ├── LabelWriterLanguageMonitorV2.h ├── Makefile.am ├── raster2dymolw.cpp └── tests ├── MOCK_LWLMPrintEnvironment.cpp ├── MOCK_LWLMPrintEnvironment.h ├── Makefile.am ├── TestLabelWriterDriver.cpp ├── TestLabelWriterDriver.h ├── TestLabelWriterFilter.cpp ├── TestLabelWriterFilter.h ├── TestLabelWriterLanguageMonitor.cpp └── TestLabelWriterLanguageMonitor.h /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | 2 | name: build 3 | 4 | on: 5 | push: 6 | paths: 7 | - '!.**' 8 | - '!**' 9 | - '.github/workflows/build.yml' 10 | - '**.h' 11 | - '**.c' 12 | - '**.cpp' 13 | - '**.ac' 14 | - 'Makefile**' 15 | 16 | # Allows you to run this workflow manually from the Actions tab 17 | workflow_dispatch: 18 | 19 | jobs: 20 | build-image: 21 | name: Compile 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v2 25 | with: 26 | submodules: true 27 | 28 | - name: Install build dependencies 29 | run: | 30 | sudo apt-get update 31 | sudo apt-get install -q -y --no-install-recommends libcups2-dev libcupsimage2-dev libboost-dev 32 | 33 | - name: Build 34 | run: | 35 | cd ${{ github.workspace }} 36 | autoscan 37 | aclocal 38 | autoconf 39 | autoheader 40 | touch NEWS AUTHORS README ChangeLog 41 | automake --add-missing 42 | automake 43 | ./configure 44 | make 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Temporary 3 | *.log 4 | *.bck 5 | *.bak 6 | *.tmp 7 | .*.swp 8 | *~ 9 | 10 | # IDE 11 | .vscode 12 | .project 13 | .cproject 14 | .settings 15 | .metadata 16 | 17 | # Generated by GNU Autoconf 18 | AUTHORS 19 | ChangeLog 20 | COPYING 21 | INSTALL 22 | NEWS 23 | README 24 | autom4te.cache 25 | aclocal.m4 26 | .deps 27 | .dirstamp 28 | Makefile.in 29 | Makefile 30 | config.h.in 31 | config.h 32 | config.log 33 | config.status 34 | configure.scan 35 | configure 36 | compile 37 | depcomp 38 | test-driver 39 | 40 | # Compilation artifacts 41 | *.o 42 | *.a 43 | *.elf 44 | *.bin 45 | *.so 46 | *.lo 47 | raster2dymolm 48 | raster2dymolw 49 | raster2dymolm_v2 50 | raster2dymolw_v2 51 | stamp-h1 52 | stamp-h2 53 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 1.3.0 - added DYMO LabelWriter SE450 support 2 | 1.2.0 - added 450 series support 3 | 1.1.0 - added LabelWriter 4XL support; required CUPS 1.2 4 | 1.0.3 - fixed compilation problems with gcc 4.3 5 | 1.0.2 - added more debug messages 6 | 1.0.0 - initial revision -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | 2 | # How to build 3 | 4 | Requirements: 5 | - GNU Autotools 6 | - GNU C and C++ compilers 7 | - CUPS header files (cups/cups.h, cups/raster.h) 8 | - CUPS libraries (libcups, libcupsimage) 9 | - Boost libraries (libboost-dev) 10 | 11 | To compile the sources run the following commands: 12 | ```sh 13 | autoscan 14 | aclocal 15 | autoconf 16 | autoheader 17 | # Workaround for complaints about missing files: 18 | touch NEWS AUTHORS README ChangeLog 19 | automake --add-missing 20 | automake 21 | ./configure 22 | make 23 | ``` 24 | 25 | On Linux systems you can alternatively type: 26 | ```sh 27 | ./build.sh 28 | ``` 29 | 30 | To install the compiled binaries and data files use this command (this will require root privileges): 31 | ```sh 32 | make install 33 | ``` 34 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4760 2008-06-19 22:21:35Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | SUBDIRS = src src_v2 ppd docs samples 21 | EXTRA_DIST = dymo-cups-drivers.spec LICENSE 22 | 23 | # 24 | # $Id: Makefile.am 4760 2008-06-19 22:21:35Z vbuzuev $ 25 | # 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Dymo CUPS printer driver 3 | 4 | This repository is derived from the official Dymo CUPS printer driver for Linux by Vladimir Buzuev. 5 | 6 | 7 | ## Usage 8 | 9 | With this driver, Dymo label printers are usable like any other printer via CUPS. 10 | 11 | Example using lpr: 12 | 13 | * print very long text on a tape: 14 | ```sh 15 | lpr -o landscape -o PageSize=24_mm__1___Label__Auto_ docs/test.txt 16 | ``` 17 | 18 | * set printing options specific to the LabelWriter driver 19 | ```sh 20 | lpr -o PageSize=30252_Address -o PrintQuality=Graphics -o PrintDensity=Light docs/test.txt 21 | ``` 22 | 23 | * set printing options specific to the LabelManager driver 24 | ```sh 25 | lpr -o PageSize=Address_Label -o CutOptions=ChainMarks -o LabelAlignment=Right -o TapeColor=1 26 | ``` 27 | 28 | 29 | ## Supported devices 30 | 31 | * DYMO LabelMANAGER 400 32 | * DYMO LabelMANAGER 450 33 | * DYMO LabelMANAGER PC 34 | * DYMO LabelMANAGER PC II 35 | * DYMO LabelManager PnP* 36 | * DYMO LabelManager Wireless PnP 37 | * Note: `usb_modeswitch` required when connected via USB (`usb_storage` kernel module loaded) 38 | * DYMO LabelPOINT 350 39 | * DYMO LabelWriter 300 40 | * DYMO LabelWriter 310 41 | * DYMO LabelWriter 315 42 | * DYMO LabelWriter 320 43 | * DYMO LabelWriter 330 44 | * DYMO LabelWriter 330 Tubo 45 | * DYMO LabelWriter 400 46 | * DYMO LabelWriter 400 Turbo 47 | * DYMO LabelWriter 450 48 | * DYMO LabelWriter 450 DUO Label 49 | * DYMO LabelWriter 450 DUO Tape 50 | * DYMO LabelWriter 450 Turbo 51 | * DYMO LabelWriter 450 Twin Turbo 52 | * DYMO LabelWriter 4XL 53 | * DYMO LabelWriter DUO Label 54 | * DYMO LabelWriter DUO Tape 55 | * DYMO LabelWriter DUO Tape 128 56 | * DYMO LabelWriter SE450 57 | * DYMO LabelWriter Twin Turbo 58 | -------------------------------------------------------------------------------- /TROUBLESHOOTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Troubleshooting 3 | 4 | 5 | ## "configure: error: Can't find cups library" 6 | 7 | The CUPS development libraries are missing. 8 | 9 | ~~~sh 10 | $ sudo apt install libcups2-dev 11 | ~~~ 12 | 13 | 14 | ## "boost/...: No such file or directory" 15 | 16 | ~~~sh 17 | $ sudo apt install libboost-dev 18 | ~~~ 19 | 20 | 21 | ## "CUPS modeldir is not existed..." 22 | 23 | This may occur, when CUPS is installed in a different path, than expected. 24 | `configure` tries to determine where CUPS is installed using the `cups-config` utility. 25 | If the latter is not found, default values are used. 26 | Default directories for CUPS are '/usr/share/cups' and '/usr/lib/cups'. 27 | 28 | This behaviour can be changed using environment variables, e.g. 29 | 30 | ~~~sh 31 | $ cups_datadir='/usr/local/share/cups' cups_serverbindir='/usr/local/lib/cups' ./configure 32 | ~~~ 33 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit on any error 4 | set -e 5 | 6 | autoscan 7 | 8 | aclocal 9 | autoconf 10 | 11 | autoheader 12 | # a workaround 13 | touch NEWS AUTHORS INSTALL README ChangeLog 14 | automake --add-missing 15 | automake 16 | rm NEWS AUTHORS INSTALL README ChangeLog 17 | 18 | ./configure 19 | 20 | make 21 | 22 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # $Id: CupsPrintEnvironment.cpp 1216 2006-12-18 16:51:12Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | AC_PREREQ(2.59) 21 | AC_INIT(dymo-cups-drivers, 1.4.0.5, vbuzuev@dymo.com) 22 | AM_INIT_AUTOMAKE([subdir-objects]) 23 | AC_CONFIG_SRCDIR([src/lw/CupsFilterLabelWriter.h]) 24 | AC_CONFIG_HEADER([config.h]) 25 | 26 | # get cups dirs 27 | # if there is cups-config utility - use it 28 | # otherwise if there are user supplyed values - use it 29 | # otherwise - use default values 30 | cupsdatadir=$BUILDROOT$cups_datadir 31 | cupsserverbindir=$BUILDROOT$cups_serverbindir 32 | cups_cflags="" 33 | 34 | if test x"$cupsdatadir" = x; then 35 | cupsdatadir=$BUILDROOT/usr/share/cups 36 | fi 37 | 38 | if test x"$cupsserverbindir" = x; then 39 | cupsserverbindir=$BUILDROOT/usr/lib/cups 40 | fi 41 | 42 | #check for cups-config 43 | cupsc="" 44 | AC_PATH_PROG(cupsc, cups-config) 45 | if test x"$cupsc" != x; then 46 | cupsdatadir=$BUILDROOT`cups-config --datadir` 47 | cupsserverbindir=$BUILDROOT`cups-config --serverbin` 48 | cups_cflags=`cups-config --cflags` 49 | fi 50 | 51 | cupsmodeldir=${cupsdatadir}/model 52 | cupsfilterdir=${cupsserverbindir}/filter 53 | 54 | #check that cups dirs are corrects 55 | #if test ! -d $cupsmodeldir; then 56 | # AC_ERROR([CUPS model dir '$cupsmodeldir' is not existed. Check your params for CUPS dirs]) 57 | #fi 58 | 59 | #if test ! -d $cupsfilterdir; then 60 | # AC_ERROR([CUPS filter dir '$cupsfilterdir' is not existed. Check your params for CUPS dirs]) 61 | #fi 62 | 63 | AC_SUBST(cupsmodeldir) 64 | AC_SUBST(cupsfilterdir) 65 | 66 | 67 | AC_ARG_ENABLE([samples], 68 | [ --enable-samples Build with samples], 69 | [case "${enableval}" in 70 | yes) samples=true ;; 71 | no) samples=false ;; 72 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-samples]) ;; 73 | esac], 74 | [samples=false]) 75 | 76 | AM_CONDITIONAL([SAMPLES], [test x$samples = xtrue]) 77 | 78 | #samplesdir=samples 79 | #AC_SUBST(samplesdir) 80 | 81 | # check for proper CUPS version - 1.1 for now 82 | #cups_version=`cups-config --api-version` 83 | #if test x"$cups_version" = x1.0; then 84 | # AC_ERROR(CUPS version 1.1 is required) 85 | #fi 86 | 87 | AC_SUBST(cups_cflags) 88 | 89 | warning_flags="-Wall -Wno-unknown-pragmas" 90 | debug_flags="" 91 | optimization_flags="-O2" 92 | CXXFLAGS="${optimization_flags} ${warning_flags} ${debug_flags} ${cups_cflags}" 93 | 94 | 95 | AC_CHECK_LIB(cups, cupsMarkOptions, , AC_ERROR([Can't find cups library])) 96 | AC_CHECK_LIB(cupsimage, cupsRasterReadHeader, , AC_ERROR([Can't find cupsimage library])) 97 | AC_CHECK_HEADERS([cups/cups.h cups/raster.h],, AC_ERROR([Can't find cups headers])) 98 | 99 | AC_CHECK_LIB(pthread, pthread_create,, AC_ERROR([Can't find pthread library])) 100 | AC_CHECK_HEADERS([pthread.h],, AC_ERROR([Can't find pthread headers])) 101 | 102 | #CUPS_LIBS=`cups-config --image --libs` 103 | #CUPS_LIBS="-lcups -lcupsimage" 104 | CUPS_LIBS="" 105 | AC_SUBST(CUPS_LIBS) 106 | 107 | # Checks for programs. 108 | AC_PROG_CXX 109 | AC_PROG_CC 110 | 111 | # Checks for libraries. 112 | 113 | # Checks for header files. 114 | AC_HEADER_STDC 115 | AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) 116 | 117 | # Checks for typedefs, structures, and compiler characteristics. 118 | AC_HEADER_STDBOOL 119 | AC_C_CONST 120 | AC_C_INLINE 121 | AC_TYPE_SIZE_T 122 | 123 | # Checks for library functions. 124 | AC_CHECK_FUNCS([memset strcasecmp]) 125 | 126 | AC_CONFIG_FILES([Makefile src/Makefile src/common/tests/Makefile src/lm/Makefile src/lm/tests/Makefile src/lw/Makefile src/lw/tests/Makefile src_v2/Makefile src_v2/common/tests/Makefile src_v2/lm/Makefile src_v2/lm/tests/Makefile src_v2/lw/Makefile src_v2/lw/tests/Makefile ppd/Makefile docs/Makefile samples/Makefile samples/paper_list/Makefile samples/paper_bounds/Makefile samples/test_label/Makefile samples/custom_paper/Makefile samples/custom_paper_tape/Makefile]) 127 | AC_OUTPUT 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | EXTRA_DIST = SAMPLES TestImage.png longtest.txt test.ps test.txt testprint.ps DYMO_SDK_for_Linux.rtf 21 | 22 | # 23 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 24 | # 25 | -------------------------------------------------------------------------------- /docs/SAMPLES: -------------------------------------------------------------------------------- 1 | This file contains sample commands could be used to print different file types. 2 | It also includes example how to set printing options supported by the drivers. 3 | 4 | Note, all commands use default printer as a destination printer. 5 | To use other then the default printer, add "-P " option to the commands. 6 | 7 | 8 | Sample commands for LabelWriter: 9 | 10 | 1. printing PostScript file 11 | lpr -o landscape -o PageSize=w167h288 test.ps 12 | 13 | 2. printing image file 14 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintQuality=Graphics TestImage.png 15 | 16 | 3. printing text file 17 | lpr -o PageSize=w167h288 -o PrintQuality=Text test.txt 18 | 19 | 4. printing on "continuous" paper 20 | lpr -o PageSize=w154h7680 -o PrintQuality=Text test.txt 21 | 22 | 5. printing on specific roll on Twin Turbo 23 | lpr -o PageSize=w167h288 -o InputSlot=Right test.txt 24 | lpr -o PageSize=w167h288 -o InputSlot=Left test.txt 25 | lpr -o PageSize=w167h288 -o InputSlot=Auto test.txt 26 | 27 | 6. using different quality 28 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintQuality=Graphics TestImage.png 29 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintQuality=Text TestImage.png 30 | 31 | 7. using different darkness 32 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintDensity=Light TestImage.png 33 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintDensity=Medium TestImage.png 34 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintDensity=Normal TestImage.png 35 | lpr -o ppi=300 -o PageSize=w167h288 -o PrintDensity=Dark TestImage.png 36 | 37 | Sample commands for LabelMANAGER: 38 | 39 | 1. printing PostScript file 40 | lpr -o landscape -o PageSize=w68h252 test.ps 41 | 42 | 2. printing text file 43 | lpr -o landscape -o PageSize=w68h252 test.txt 44 | 45 | 3. printing aligned labels 46 | lpr -o landscape -o PageSize=w68h252 -o LabelAlignment=Left test.txt 47 | lpr -o landscape -o PageSize=w68h252 -o LabelAlignment=Right test.txt 48 | lpr -o landscape -o PageSize=w68h252 -o LabelAlignment=Center test.txt 49 | 50 | 4. printing on "auto" paper - does not print empty lines at the end of the label 51 | lpr -o landscape -o Pagesize=w68h4000 longtest.txt 52 | lpr -o landscape -o Pagesize=w68h252 longtest.txt 53 | 54 | 5. using different cutting options 55 | lpr -o landscape -o Pagesize=w68h252 -o CutOptions=ChainMarks longtest.txt 56 | 57 | 6. using different tape color 58 | lpr -o landscape -o PageSize=w68h252 -o TapeColor=0 test.txt 59 | lpr -o landscape -o PageSize=w68h252 -o TapeColor=1 test.txt 60 | lpr -o landscape -o PageSize=w68h252 -o TapeColor=12 test.txt 61 | 62 | 7. printing in continuous mode - leader/trailer is not used 63 | lpr -o landscape -o Pagesize=w68h252 -o ContinuousPaper=0 longtest.txt 64 | lpr -o landscape -o Pagesize=w68h252 -o ContinuousPaper=1 longtest.txt 65 | lpr -o landscape -o Pagesize=w68h252 -o ContinuousPaper=1 -o CutOptions=ChainMarks longtest.txt 66 | 67 | -------------------------------------------------------------------------------- /docs/TestImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthiasbock/dymo-cups-drivers/eb2ad031114f4aaaf9b8d576d9596b1a9585c434/docs/TestImage.png -------------------------------------------------------------------------------- /docs/longtest.txt: -------------------------------------------------------------------------------- 1 | Printer Long Test Page 2 | Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! -------------------------------------------------------------------------------- /docs/test.ps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-3.0 2 | %%BoundingBox: 0 0 612 792 3 | %%Pages: 1 4 | %%LanguageLevel: 1 5 | %%DocumentData: Clean7Bit 6 | %%DocumentSuppliedResources: procset testprint/1.1 7 | %%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman 8 | %%Title: Test Page 9 | %%EndComments 10 | %%BeginProlog 11 | %%BeginResource procset testprint 1.1 0 12 | /CENTER { 13 | dup stringwidth pop 14 | 0.5 mul neg 0 rmoveto 15 | show 16 | }bind def 17 | %%EndResource 18 | %%EndProlog 19 | %%Page: 1 1 20 | gsave 21 | 22 | initclip newpath clippath pathbbox 23 | 72 div /pageTop exch def 24 | 72 div /pageRight exch def 25 | 72 div /pageBottom exch def 26 | 72 div /pageLeft exch def 27 | 28 | 4 setlinewidth 29 | 0 setgray closepath stroke 30 | 1 setlinewidth 31 | 32 | /pageWidth pageRight pageLeft sub def 33 | /pageHeight pageTop pageBottom sub def 34 | 35 | /bigFont /Helvetica-Bold findfont 36 | 18 scalefont def 37 | 38 | pageLeft 72 mul 39 | pageBottom 72 mul 40 | translate 41 | 42 | 0 setgray 43 | 44 | pageWidth 36 mul 45 | pageHeight 72 mul 18 sub 46 | 2 copy moveto 47 | bigFont setfont 48 | (Printer Test Page) CENTER 49 | 50 | pageWidth 36 mul 51 | pageHeight 36 mul 18 sub 52 | 2 copy moveto 53 | bigFont setfont 54 | (Hello, World!) CENTER 55 | 56 | grestore 57 | showpage 58 | %%EOF 59 | -------------------------------------------------------------------------------- /docs/test.txt: -------------------------------------------------------------------------------- 1 | Printer Test Page 2 | Hello, World! -------------------------------------------------------------------------------- /dymo-cups-drivers.spec: -------------------------------------------------------------------------------- 1 | # $Id: dymo-cups-drivers.spec 4913 2008-07-10 22:17:43Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | Summary: DYMO LabelWriter Drivers for CUPS 21 | Name: dymo-cups-drivers 22 | Version: 1.0.1 23 | Release: 0 24 | License: GPL 25 | Group: System Environment/Libraries 26 | Source: dymo-cups-drivers-%{version}.tar.gz 27 | Url: http://www.dymo.com 28 | Packager: Anonymous 29 | Vendor: DYMO 30 | 31 | # Use buildroot so as not to disturb the version already installed 32 | BuildRoot: /var/tmp/%{name}-root 33 | 34 | # Dependencies... 35 | #Requires: cups, cups-devel 36 | 37 | 38 | %description 39 | DYMO LabelWriter and DYMO LabelMANAGER series drivers for CUPS 40 | 41 | %prep 42 | %setup 43 | 44 | %build 45 | CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_OPT_FLAGS" BUILDROOT=$RPM_BUILD_ROOT ./configure 46 | 47 | # If we got this far, all prerequisite libraries must be here. 48 | make 49 | 50 | %install 51 | # Make sure the RPM_BUILD_ROOT directory exists. 52 | rm -rf $RPM_BUILD_ROOT 53 | 54 | make BUILDROOT=$RPM_BUILD_ROOT install 55 | 56 | %post 57 | 58 | %preun 59 | 60 | %clean 61 | rm -rf $RPM_BUILD_ROOT 62 | 63 | %files 64 | %defattr(-,root,root) 65 | 66 | %dir /usr/lib/cups 67 | /usr/lib/cups/* 68 | %dir /usr/share/cups 69 | /usr/share/cups/* 70 | 71 | 72 | # 73 | # End of "$Id: dymo-cups-drivers.spec 4913 2008-07-10 22:17:43Z vbuzuev $". 74 | # 75 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /ppd/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 15958 2011-09-02 14:37:33Z pineichen $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | 21 | dist_cupsmodel_DATA = \ 22 | lm400.ppd \ 23 | lm450.ppd \ 24 | lmpc.ppd \ 25 | lmpc2.ppd \ 26 | lmpnp.ppd \ 27 | lmwpnp.ppd \ 28 | lp350.ppd \ 29 | lw300.ppd \ 30 | lw310.ppd \ 31 | lw315.ppd \ 32 | lw320.ppd \ 33 | lw330.ppd \ 34 | lw330t.ppd \ 35 | lw400.ppd \ 36 | lw400t.ppd \ 37 | lwduol.ppd \ 38 | lwduot.ppd \ 39 | lwduot2.ppd \ 40 | lwtt.ppd \ 41 | lw4xl.ppd \ 42 | lw450.ppd \ 43 | lw450t.ppd \ 44 | lw450tt.ppd \ 45 | lw450dl.ppd \ 46 | lw450dt.ppd \ 47 | se450.ppd \ 48 | lmmls.ppd \ 49 | lw550.ppd \ 50 | lw550p.ppd \ 51 | lw550t.ppd \ 52 | lw550tp.ppd \ 53 | lw5xl.ppd \ 54 | lw5xlp.ppd \ 55 | lww.ppd 56 | 57 | tests = testppd 58 | check_PROGRAMS = testppd 59 | 60 | testppd_SOURCES= 61 | 62 | testppd$(EXEEXT): 63 | cupstestppd $(dist_cupsmodel_DATA) 64 | -------------------------------------------------------------------------------- /samples/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 8487 2009-05-22 22:03:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | SUBDIRS = paper_bounds paper_list test_label custom_paper custom_paper_tape 21 | 22 | # 23 | # $Id: Makefile.am 8487 2009-05-22 22:03:27Z vbuzuev $ 24 | # 25 | -------------------------------------------------------------------------------- /samples/custom_paper/CairoUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAIRO_UTILS__ 2 | #define __CAIRO_UTILS__ 3 | 4 | #include 5 | 6 | 7 | class CairoSurfacePtr 8 | { 9 | public: 10 | CairoSurfacePtr(cairo_surface_t* ptr): ptr_(ptr) {} 11 | ~CairoSurfacePtr() { cairo_surface_destroy(ptr_); } 12 | 13 | cairo_surface_t* operator*() { return ptr_; } 14 | operator cairo_surface_t* () { return ptr_; } 15 | private: 16 | cairo_surface_t* ptr_; 17 | 18 | }; 19 | 20 | class CairoPtr 21 | { 22 | public: 23 | CairoPtr(cairo_t* ptr): ptr_(ptr) {} 24 | ~CairoPtr() { cairo_destroy(ptr_); } 25 | 26 | cairo_t* operator*() { return ptr_; } 27 | operator cairo_t* () { return ptr_; } 28 | 29 | private: 30 | cairo_t* ptr_; 31 | 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /samples/custom_paper/CustomPaper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "CairoUtils.h" 9 | 10 | using namespace std; 11 | 12 | 13 | 14 | class Error: public exception 15 | { 16 | public: 17 | Error(const string& Message): exception(), Message_(Message) {} 18 | virtual ~Error() throw() {} 19 | virtual const char* what() const throw() { return Message_.c_str(); } 20 | private: 21 | string Message_; 22 | }; 23 | 24 | 25 | static int 26 | GetPrinterResolution(ppd_group_t* group, int num_groups) 27 | { 28 | for (int i = 0; i < num_groups; ++i) 29 | { 30 | ppd_group_t g = group[i]; 31 | for (int j = 0; j < g.num_options; ++j) 32 | { 33 | ppd_option_t o = g.options[j]; 34 | 35 | if (!strcmp(o.keyword, "Resolution")) 36 | { 37 | ppd_choice_t c = o.choices[0]; 38 | 39 | return atoi(c.choice); 40 | } 41 | } 42 | } 43 | 44 | return 0; 45 | } 46 | 47 | void 48 | CreateBoundsImage(int Width, int Height, const string& Text, string& FileName) 49 | { 50 | FileName = "test.png"; 51 | 52 | CairoSurfacePtr Surface(cairo_image_surface_create(CAIRO_FORMAT_RGB24, Width, Height)); 53 | if (!*Surface) 54 | throw Error("Unable to create cairo surface"); 55 | 56 | 57 | CairoPtr c(cairo_create(Surface)); 58 | if (!*c) 59 | throw Error("Unable to create cairo_t"); 60 | 61 | //setup Cairo 62 | cairo_set_antialias(c, CAIRO_ANTIALIAS_NONE); 63 | 64 | 65 | // clear image 66 | cairo_set_source_rgb(c, 1, 1, 1); 67 | cairo_paint(c); 68 | 69 | // draw rect 70 | cairo_set_source_rgb(c, 0, 0, 0); 71 | cairo_set_line_width(c, 3); 72 | cairo_rectangle(c, 3, 3, Width - 6, Height - 6); 73 | cairo_move_to(c, 3, 3); 74 | cairo_line_to(c, Width - 3, Height - 3); 75 | cairo_move_to(c, 3, Height - 3); 76 | cairo_line_to(c, Width - 3, 3); 77 | cairo_stroke(c); 78 | 79 | 80 | // draw text 81 | cairo_select_font_face(c, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); 82 | cairo_set_source_rgb(c, 0, 0, 0); 83 | cairo_set_line_width(c, 1); 84 | 85 | cairo_text_extents_t te; 86 | for(int FontSize = 100; ;FontSize -= 10) 87 | { 88 | cairo_set_font_size(c, FontSize); 89 | 90 | cairo_text_extents(c, Text.c_str(), &te); 91 | 92 | if (Width > te.width) 93 | break; 94 | } 95 | 96 | //cairo_move_to(c, 10, 10); 97 | //cairo_show_text(c, "Hello"); 98 | cairo_move_to(c, (Width - te.width) / 2, (Height + te.height) / 2); 99 | cairo_text_path(c, Text.c_str()); 100 | 101 | cairo_stroke(c); 102 | 103 | // save to file 104 | if (cairo_surface_write_to_png(Surface, FileName.c_str()) != CAIRO_STATUS_SUCCESS) 105 | throw Error("Unable to write to PNG file"); 106 | } 107 | 108 | int main(int argc, char** argv) 109 | { 110 | try 111 | { 112 | if (argc < 2) 113 | throw Error("Usage: customPaper "); 114 | 115 | 116 | const char* ppdFileName = cupsGetPPD(argv[1]); 117 | if (!ppdFileName) 118 | throw Error(string("Unknown printer '") + argv[1] + "'"); 119 | 120 | ppd_file_t* ppd = ppdOpenFile(ppdFileName); 121 | if (!ppd) 122 | throw Error(string("Unable to open ppd file '") + ppdFileName + "'"); 123 | 124 | 125 | int Resolution = GetPrinterResolution(ppd->groups, ppd->num_groups); 126 | 127 | // custom paper definition 128 | // use Address paper size in points 129 | float CustomPaperPrintableWidth = 71.76; 130 | float CustomPaperPrintableHeight = 231.12; 131 | 132 | int Width = int(CustomPaperPrintableWidth * Resolution / 72); 133 | int Height = int(CustomPaperPrintableHeight * Resolution / 72); 134 | bool Landscape = false; 135 | 136 | string FileName; 137 | if (Height > Width) 138 | { 139 | Landscape = true; 140 | int t = Width; 141 | Width = Height; 142 | Height = t; 143 | } 144 | CreateBoundsImage(Width, Height, "Custom paper", FileName); 145 | 146 | int num_options = 0; 147 | cups_option_t* options = NULL; 148 | 149 | // PageSize value for custom paper 150 | char PageSizeValue[250]; 151 | sprintf(PageSizeValue, "Custom.%fx%f", CustomPaperPrintableWidth, CustomPaperPrintableHeight); 152 | 153 | 154 | num_options = cupsAddOption("PageSize", PageSizeValue, num_options, &options); 155 | num_options = cupsAddOption("scaling", "100", num_options, &options); 156 | if (Landscape) 157 | num_options = cupsAddOption("landscape", "yes", num_options, &options); 158 | 159 | 160 | cupsPrintFile(argv[1], FileName.c_str(), "Test print with Cairo", num_options, options); 161 | cupsFreeOptions(num_options, options); 162 | 163 | 164 | ppdClose(ppd); 165 | 166 | return 0; 167 | } 168 | catch(std::exception& e) 169 | { 170 | fputs(e.what(), stderr); 171 | fputs("\n", stderr); 172 | return 1; 173 | } 174 | } 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /samples/custom_paper/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 7203 2009-02-13 22:45:17Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | EXTRA_PROGRAMS = CustomPaper 21 | 22 | CustomPaper_SOURCES = \ 23 | CustomPaper.cpp \ 24 | CairoUtils.h 25 | 26 | CustomPaper_LDADD = $(CUPS_LIBS) -lcairo 27 | 28 | AM_CPPFLAGS = -I/usr/include/cairo 29 | 30 | if SAMPLES 31 | SAMPLE_PROGS = CustomPaper 32 | else 33 | SAMPLE_PROGS = 34 | endif 35 | 36 | noinst_PROGRAMS = $(SAMPLE_PROGS) 37 | 38 | 39 | 40 | # 41 | # End of $Id: Makefile.am 7203 2009-02-13 22:45:17Z vbuzuev $ 42 | # 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /samples/custom_paper_tape/CairoUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAIRO_UTILS__ 2 | #define __CAIRO_UTILS__ 3 | 4 | #include 5 | 6 | 7 | class CairoSurfacePtr 8 | { 9 | public: 10 | CairoSurfacePtr(cairo_surface_t* ptr): ptr_(ptr) {} 11 | ~CairoSurfacePtr() { cairo_surface_destroy(ptr_); } 12 | 13 | cairo_surface_t* operator*() { return ptr_; } 14 | operator cairo_surface_t* () { return ptr_; } 15 | private: 16 | cairo_surface_t* ptr_; 17 | 18 | }; 19 | 20 | class CairoPtr 21 | { 22 | public: 23 | CairoPtr(cairo_t* ptr): ptr_(ptr) {} 24 | ~CairoPtr() { cairo_destroy(ptr_); } 25 | 26 | cairo_t* operator*() { return ptr_; } 27 | operator cairo_t* () { return ptr_; } 28 | 29 | private: 30 | cairo_t* ptr_; 31 | 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /samples/custom_paper_tape/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 7203 2009-02-13 22:45:17Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | EXTRA_PROGRAMS = CustomPaperTape 21 | 22 | CustomPaperTape_SOURCES = \ 23 | CustomPaperTape.cpp \ 24 | CairoUtils.h 25 | 26 | CustomPaperTape_LDADD = $(CUPS_LIBS) -lcairo 27 | 28 | AM_CPPFLAGS = -I/usr/include/cairo 29 | 30 | if SAMPLES 31 | SAMPLE_PROGS = CustomPaperTape 32 | else 33 | SAMPLE_PROGS = 34 | endif 35 | 36 | noinst_PROGRAMS = $(SAMPLE_PROGS) 37 | 38 | 39 | 40 | # 41 | # End of $Id: Makefile.am 7203 2009-02-13 22:45:17Z vbuzuev $ 42 | # 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /samples/paper_bounds/CairoUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAIRO_UTILS__ 2 | #define __CAIRO_UTILS__ 3 | 4 | #include 5 | 6 | 7 | class CairoSurfacePtr 8 | { 9 | public: 10 | CairoSurfacePtr(cairo_surface_t* ptr): ptr_(ptr) {} 11 | ~CairoSurfacePtr() { cairo_surface_destroy(ptr_); } 12 | 13 | cairo_surface_t* operator*() { return ptr_; } 14 | operator cairo_surface_t* () { return ptr_; } 15 | private: 16 | cairo_surface_t* ptr_; 17 | 18 | }; 19 | 20 | class CairoPtr 21 | { 22 | public: 23 | CairoPtr(cairo_t* ptr): ptr_(ptr) {} 24 | ~CairoPtr() { cairo_destroy(ptr_); } 25 | 26 | cairo_t* operator*() { return ptr_; } 27 | operator cairo_t* () { return ptr_; } 28 | 29 | private: 30 | cairo_t* ptr_; 31 | 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /samples/paper_bounds/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4763 2008-06-19 22:24:56Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | EXTRA_PROGRAMS = PaperBounds 21 | 22 | PaperBounds_SOURCES = \ 23 | PaperBounds.cpp \ 24 | CairoUtils.h 25 | 26 | PaperBounds_LDADD = $(CUPS_LIBS) -lcairo 27 | 28 | AM_CPPFLAGS = -I/usr/include/cairo 29 | 30 | if SAMPLES 31 | SAMPLE_PROGS = PaperBounds 32 | else 33 | SAMPLE_PROGS = 34 | endif 35 | 36 | noinst_PROGRAMS = $(SAMPLE_PROGS) 37 | 38 | 39 | 40 | # 41 | # End of $Id: Makefile.am 4763 2008-06-19 22:24:56Z vbuzuev $ 42 | # 43 | -------------------------------------------------------------------------------- /samples/paper_list/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4763 2008-06-19 22:24:56Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | #samples_PROGRAMS = paperlist 21 | #PROGRAMS = paperlist 22 | 23 | EXTRA_PROGRAMS = PaperList 24 | 25 | PaperList_SOURCES = \ 26 | PaperList.cpp 27 | 28 | PaperList_LDADD = $(CUPS_LIBS) 29 | 30 | if SAMPLES 31 | SAMPLE_PROGS = PaperList 32 | else 33 | SAMPLE_PROGS = 34 | endif 35 | 36 | noinst_PROGRAMS = $(SAMPLE_PROGS) 37 | 38 | 39 | 40 | # 41 | # End of $Id: Makefile.am 4763 2008-06-19 22:24:56Z vbuzuev $ 42 | # 43 | -------------------------------------------------------------------------------- /samples/paper_list/PaperList.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | map gPaperNames; 10 | typedef pair str_pair; 11 | 12 | static void 13 | FindPapersOptions(ppd_option_t& o) 14 | { 15 | // cout << "Option " << o.keyword << endl; 16 | if (!strcmp(o.keyword, "PageSize")) 17 | { 18 | for (int i = 0; i < o.num_choices; ++i) 19 | { 20 | ppd_choice_t& c = o.choices[i]; 21 | 22 | gPaperNames.insert(str_pair(c.choice, c.text)); 23 | // cout << c.choice << " " << c.text << endl; 24 | } 25 | } 26 | } 27 | 28 | static void 29 | FindPapersGroup(ppd_group_t& g) 30 | { 31 | // cout << g.name << " " << g.text << " " << g.num_options << endl; 32 | 33 | for (int i = 0; i < g.num_options; ++i) 34 | FindPapersOptions(g.options[i]); 35 | } 36 | 37 | static void 38 | FindPapers(ppd_group_t* group, int num_groups) 39 | { 40 | for (int i = 0; i < num_groups; ++i) 41 | FindPapersGroup(group[i]); 42 | } 43 | 44 | int main(int argc, char** argv) 45 | { 46 | if (argc < 2) 47 | { 48 | cerr << "Usage: paperlist " << endl; 49 | return 1; 50 | } 51 | 52 | 53 | const char* ppdFileName = cupsGetPPD(argv[1]); 54 | if (!ppdFileName) 55 | { 56 | cerr << "Unknown printer '" << argv[1] << "'" << endl; 57 | return 2; 58 | } 59 | 60 | ppd_file_t* ppd = ppdOpenFile(ppdFileName); 61 | if (!ppd) 62 | { 63 | cerr << "unable to open ppd file '" << ppdFileName << "'" << endl; 64 | return 3; 65 | } 66 | 67 | FindPapers(ppd->groups, ppd->num_groups); 68 | 69 | 70 | cout << setw(30) << setiosflags(ios_base::left) << "Paper Name" << resetiosflags(ios_base::left) 71 | << setw(10) << "Width" 72 | << setw(10) << "Height" 73 | << setw(10) << "Left" 74 | << setw(10) << "Bottom" 75 | << setw(10) << "Right" 76 | << setw(10) << "Top" 77 | << endl; 78 | 79 | cout << setw(30) << setiosflags(ios_base::left) << "----- ----" << resetiosflags(ios_base::left) 80 | << setw(10) << "-----" 81 | << setw(10) << "------" 82 | << setw(10) << "----" 83 | << setw(10) << "---" 84 | << setw(10) << "-----" 85 | << setw(10) << "------" 86 | << endl; 87 | 88 | 89 | for (int i = 0; i < ppd->num_sizes; ++i) 90 | { 91 | ppd_size_t size = ppd->sizes[i]; 92 | 93 | cout << setw(30) << setiosflags(ios_base::left) << gPaperNames[size.name] << setprecision(2) << setiosflags(ios_base::fixed) << resetiosflags(ios_base::left) 94 | << setw(10) << size.width 95 | << setw(10) << size.length 96 | << setw(10) << size.left 97 | << setw(10) << size.bottom 98 | << setw(10) << size.right 99 | << setw(10) << size.top 100 | << endl; 101 | 102 | } 103 | 104 | 105 | ppdClose(ppd); 106 | 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /samples/test_label/CairoUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAIRO_UTILS__ 2 | #define __CAIRO_UTILS__ 3 | 4 | #include 5 | 6 | 7 | class CairoSurfacePtr 8 | { 9 | public: 10 | CairoSurfacePtr(cairo_surface_t* ptr): ptr_(ptr) {} 11 | ~CairoSurfacePtr() { cairo_surface_destroy(ptr_); } 12 | 13 | cairo_surface_t* operator*() { return ptr_; } 14 | operator cairo_surface_t* () { return ptr_; } 15 | private: 16 | cairo_surface_t* ptr_; 17 | 18 | }; 19 | 20 | class CairoPtr 21 | { 22 | public: 23 | CairoPtr(cairo_t* ptr): ptr_(ptr) {} 24 | ~CairoPtr() { cairo_destroy(ptr_); } 25 | 26 | cairo_t* operator*() { return ptr_; } 27 | operator cairo_t* () { return ptr_; } 28 | 29 | private: 30 | cairo_t* ptr_; 31 | 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /samples/test_label/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4763 2008-06-19 22:24:56Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | EXTRA_PROGRAMS = TestLabel 21 | 22 | TestLabel_SOURCES = \ 23 | TestLabel.cpp \ 24 | CairoUtils.h 25 | 26 | TestLabel_LDADD = $(CUPS_LIBS) -lcairo 27 | 28 | EXTRA_DIST = tel.png photo.png barcode.png 29 | 30 | AM_CPPFLAGS = -I/usr/include/cairo 31 | 32 | if SAMPLES 33 | SAMPLE_PROGS = TestLabel 34 | else 35 | SAMPLE_PROGS = 36 | endif 37 | 38 | noinst_PROGRAMS = $(SAMPLE_PROGS) 39 | 40 | 41 | 42 | # 43 | # End of $Id: Makefile.am 4763 2008-06-19 22:24:56Z vbuzuev $ 44 | # 45 | -------------------------------------------------------------------------------- /samples/test_label/barcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthiasbock/dymo-cups-drivers/eb2ad031114f4aaaf9b8d576d9596b1a9585c434/samples/test_label/barcode.png -------------------------------------------------------------------------------- /samples/test_label/photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthiasbock/dymo-cups-drivers/eb2ad031114f4aaaf9b8d576d9596b1a9585c434/samples/test_label/photo.png -------------------------------------------------------------------------------- /samples/test_label/tel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthiasbock/dymo-cups-drivers/eb2ad031114f4aaaf9b8d576d9596b1a9585c434/samples/test_label/tel.png -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | SUBDIRS = lw lm common/tests 21 | 22 | # 23 | # End of $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 24 | # 25 | -------------------------------------------------------------------------------- /src/common/CommonTypedefs.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: CommonTypedefs.h 14976 2011-04-26 15:24:48Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | 22 | #ifndef haf1c6298_a459_4417_83c1_ed084705400a 23 | #define haf1c6298_a459_4417_83c1_ed084705400a 24 | 25 | #include 26 | 27 | //namespace dymo 28 | namespace DymoPrinterDriver 29 | { 30 | 31 | typedef unsigned char byte; 32 | typedef unsigned int dword; 33 | typedef std::vector buffer_t; 34 | 35 | } // namespace 36 | 37 | 38 | #endif 39 | 40 | /* 41 | * End of "$Id: CommonTypedefs.h 14976 2011-04-26 15:24:48Z aleksandr $". 42 | */ 43 | -------------------------------------------------------------------------------- /src/common/CupsPrintEnvironment.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: CupsPrintEnvironment.h 14901 2011-04-06 10:46:22Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h952b1c81_8931_433a_8479_7ae6d8e85a86 22 | #define h952b1c81_8931_433a_8479_7ae6d8e85a86 23 | 24 | #include 25 | #include 26 | #include "PrinterDriver.h" 27 | 28 | namespace DymoPrinterDriver 29 | { 30 | 31 | // this is environment for a driver 32 | // this env will be forward output to LM also 33 | class CCupsPrintEnvironmentForDriver: public IPrintEnvironment 34 | { 35 | public: 36 | CCupsPrintEnvironmentForDriver(ILanguageMonitor& LanguageMonitor); 37 | virtual ~CCupsPrintEnvironmentForDriver(); 38 | virtual void WriteData(const buffer_t& DataBuffer); 39 | virtual void ReadData(buffer_t& DataBuffer); 40 | virtual job_status_t GetJobStatus(); 41 | virtual void SetJobStatus(job_status_t JobStatus); 42 | 43 | private: 44 | FILE* PRNFile_; 45 | ILanguageMonitor& LanguageMonitor_; 46 | }; 47 | 48 | // this is environment for a language monitor 49 | // it simple output it is data to CUPS file descriptor 50 | class CCupsPrintEnvironmentForLM: public IPrintEnvironment 51 | { 52 | public: 53 | CCupsPrintEnvironmentForLM(); 54 | virtual ~CCupsPrintEnvironmentForLM(); 55 | virtual void WriteData(const buffer_t& DataBuffer); 56 | virtual void ReadData(buffer_t& DataBuffer); 57 | virtual job_status_t GetJobStatus(); 58 | virtual void SetJobStatus(job_status_t JobStatus); 59 | 60 | private: 61 | FILE* PRNFile_; 62 | IPrintEnvironment::job_status_t JobStatus_; 63 | }; 64 | 65 | }; 66 | 67 | #endif 68 | 69 | /* 70 | * End of "$Id: CupsPrintEnvironment.h 14901 2011-04-06 10:46:22Z aleksandr $". 71 | */ 72 | -------------------------------------------------------------------------------- /src/common/DummyLanguageMonitor.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: DummyLanguageMonitor.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | 22 | #include "DummyLanguageMonitor.h" 23 | 24 | 25 | namespace DymoPrinterDriver 26 | { 27 | 28 | 29 | CDummyLanguageMonitor::CDummyLanguageMonitor(IPrintEnvironment& Environment): 30 | Environment_(Environment) 31 | { 32 | } 33 | 34 | CDummyLanguageMonitor::~CDummyLanguageMonitor() 35 | { 36 | } 37 | 38 | void 39 | CDummyLanguageMonitor::StartDoc() 40 | { 41 | } 42 | 43 | void 44 | CDummyLanguageMonitor::EndDoc() 45 | { 46 | } 47 | 48 | void 49 | CDummyLanguageMonitor::StartPage() 50 | { 51 | } 52 | 53 | void 54 | CDummyLanguageMonitor::EndPage() 55 | { 56 | } 57 | 58 | 59 | 60 | void 61 | CDummyLanguageMonitor::ProcessData(const buffer_t& Data) 62 | { 63 | } 64 | 65 | 66 | }; // namespace 67 | 68 | 69 | /* 70 | * End of "$Id: DummyLanguageMonitor.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 71 | */ 72 | -------------------------------------------------------------------------------- /src/common/DummyLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: DummyLanguageMonitor.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h4fe065b4_5177_4f82_ba6f_1a3b42b475ef 22 | #define h4fe065b4_5177_4f82_ba6f_1a3b42b475ef 23 | 24 | #include "PrinterDriver.h" 25 | 26 | namespace DymoPrinterDriver 27 | { 28 | 29 | 30 | class CDummyLanguageMonitor: public ILanguageMonitor 31 | { 32 | public: 33 | CDummyLanguageMonitor(IPrintEnvironment& Environment); 34 | virtual ~CDummyLanguageMonitor(); 35 | 36 | virtual void StartDoc(); 37 | virtual void EndDoc(); 38 | 39 | virtual void StartPage(); 40 | virtual void EndPage(); 41 | 42 | virtual void ProcessData(const buffer_t& Data); 43 | 44 | protected: 45 | private: 46 | IPrintEnvironment& Environment_; 47 | }; 48 | 49 | 50 | }; //namespace 51 | 52 | #endif 53 | 54 | /* 55 | * End of "$Id: DummyLanguageMonitor.h 4759 2008-06-19 19:02:27Z vbuzuev $". 56 | */ 57 | -------------------------------------------------------------------------------- /src/common/ErrorDiffusionHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: ErrorDiffusionHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | 22 | #ifndef h70F89562_C051_4c11_80E4_E5BE22A3C400 23 | #define h70F89562_C051_4c11_80E4_E5BE22A3C400 24 | 25 | #include "Halftoning.h" 26 | 27 | //namespace dymo 28 | namespace DymoPrinterDriver 29 | { 30 | 31 | class CErrorDiffusionHalftoning: public CHalftoneFilter 32 | { 33 | public: 34 | CErrorDiffusionHalftoning(image_t InputImageType, image_t OutputImageType, bool UsePrinterColorSpace = true); 35 | virtual ~CErrorDiffusionHalftoning(); 36 | 37 | virtual bool IsProcessLineSupported(); 38 | 39 | virtual void ProcessLine(const buffer_t& InputLine, buffer_t& OutputLine); 40 | virtual void ProcessImage(const void* ImageData, size_t ImageWidth, size_t ImageHeight, size_t LineDelta, std::vector& OutputImage); 41 | virtual void ProcessImage(const std::vector& InputImage, std::vector& OutputImage); 42 | 43 | protected: 44 | size_t GetImageWidth(); 45 | 46 | private: 47 | 48 | size_t ImageWidth_; // image width in pixels 49 | std::vector Errors_; // errors buffer 50 | std::vector GrayLine_; // current line in gray scale color 51 | bool UsePrinterColorSpace_; // if true then use 1 as black, 0 - as white; otherwise 0 is black 1 - white 52 | }; 53 | 54 | }; // namespace 55 | 56 | #endif 57 | 58 | /* 59 | * End of "$Id: ErrorDiffusionHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $". 60 | */ 61 | -------------------------------------------------------------------------------- /src/common/Halftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: Halftoning.h 15960 2011-09-02 14:42:28Z pineichen $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | 22 | #ifndef h4D098F6A_47C6_4e9d_BD74_2DC6034F8EEF 23 | #define h4D098F6A_47C6_4e9d_BD74_2DC6034F8EEF 24 | 25 | #include 26 | #include "CommonTypedefs.h" 27 | 28 | //namespace dymo 29 | namespace DymoPrinterDriver 30 | { 31 | 32 | class CHalftoneFilter 33 | { 34 | public: 35 | // image format 36 | typedef enum 37 | { 38 | itBW, // Black and White 39 | itXRGB, // four bytes per pixel, 8 bits per color, msb is not used (default on MacOSX) 40 | itRGB, // three bytes per pixel, 8 bits per color (default on CUPS) 41 | } image_t; 42 | 43 | typedef std::vector image_buffer_t; 44 | 45 | CHalftoneFilter(image_t InputImageType, image_t OutputImageType); 46 | virtual ~CHalftoneFilter(); 47 | 48 | 49 | // line-by-line interface 50 | virtual bool IsProcessLineSupported() = 0; 51 | virtual void ProcessLine(const buffer_t& InputLine, buffer_t& OutputLine) = 0; 52 | 53 | // full-image-at-once interface 54 | virtual void ProcessImage(const void* ImageData, size_t ImageWidth, size_t ImageHeight, size_t LineDelta, std::vector& OutputImage) = 0; 55 | virtual void ProcessImage(const image_buffer_t& InputImage, image_buffer_t& OutputImage) = 0; 56 | 57 | image_t GetInputImageType(); 58 | image_t GetOutputImageType(); 59 | 60 | // convert RGB value to Gray Scale 61 | byte RGBToGrayScale(byte R, byte G, byte B); 62 | 63 | // pixelValue (0 - white, 1 - black) 64 | void SetPixelBW(buffer_t& buf, int pixelNo, int pixelValue); 65 | 66 | // based on inputImageType extract color component of current pixel 67 | void ExtractRGB(const buffer_t& InputLine, int PixelNo, byte& R, byte& G, byte& B); 68 | // same as previous but return colors as packed integer value 69 | int ExtractRGB(const buffer_t& InputLine, int PixelNo); 70 | 71 | // return imageWidth based on inputImageType and input line data 72 | size_t CalcImageWidth(const buffer_t& InputLine); 73 | // return buffer size needed to store an input line based on inputImageType 74 | size_t CalcBufferSize(size_t ImageWidth); 75 | // calc output buffer size 76 | size_t CalcOutputBufferSize(size_t ImageWidth); 77 | 78 | private: 79 | image_t InputImageType_; 80 | image_t OutputImageType_; 81 | }; 82 | 83 | 84 | class EHalftoneError 85 | { 86 | public: 87 | typedef enum 88 | { 89 | heUnsupportedImageType = 1, 90 | } error_t; 91 | 92 | EHalftoneError(error_t ErrorCode); 93 | 94 | error_t GetErrorCode(); 95 | 96 | private: 97 | error_t ErrorCode_; 98 | }; 99 | 100 | } 101 | 102 | #endif 103 | 104 | /* 105 | * End of "$Id: Halftoning.h 15960 2011-09-02 14:42:28Z pineichen $". 106 | */ 107 | -------------------------------------------------------------------------------- /src/common/NonLinearLaplacianHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: NonLinearLaplacianHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | 22 | #ifndef heebf43e9_0acf_490a_8385_1a339afa4da1 23 | #define heebf43e9_0acf_490a_8385_1a339afa4da1 24 | 25 | #include "Halftoning.h" 26 | 27 | //namespace dymo 28 | namespace DymoPrinterDriver 29 | { 30 | 31 | class CNLLHalftoning: public CHalftoneFilter 32 | { 33 | public: 34 | CNLLHalftoning(int Threshold, image_t InputImageType, image_t OutputImageType); 35 | virtual ~CNLLHalftoning(); 36 | 37 | virtual bool IsProcessLineSupported(); 38 | virtual void ProcessLine(const buffer_t& InputLine, buffer_t& OutputLine); 39 | virtual void ProcessImage(const void* ImageData, size_t ImageWidth, size_t ImageHeight, size_t LineDelta, std::vector& OutputImage); 40 | virtual void ProcessImage(const image_buffer_t& InputImage, image_buffer_t& OutputImage); 41 | 42 | int GetThreshold(); 43 | protected: 44 | private: 45 | int Threshold_; // constant used to separate a block to classes using NLL 46 | 47 | size_t ImageWidth_; 48 | size_t ImageHeight_; 49 | 50 | // split image to 18-pixels block be diagonal 51 | // return true if diagonal contains at least one Block inside image, so next diagonal should be processes 52 | // on output (x1, y1) is coodrs of pixel #1 of topmost block in the diagonal 53 | bool ProcessDiagonal( 54 | const std::vector& InputImage, std::vector& OutputImage, size_t& x1, size_t& y1); 55 | 56 | }; 57 | 58 | }; // namespace 59 | 60 | #endif 61 | 62 | /* 63 | * End of "$Id: NonLinearLaplacianHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $". 64 | */ 65 | -------------------------------------------------------------------------------- /src/common/PrinterDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: PrinterDriver.h 14976 2011-04-26 15:24:48Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h6125e012_f7b5_4377_aa47_e2cdad351cc6 22 | #define h6125e012_f7b5_4377_aa47_e2cdad351cc6 23 | 24 | #include "CommonTypedefs.h" 25 | 26 | //using namespace dymo; 27 | 28 | namespace DymoPrinterDriver 29 | { 30 | 31 | /** 32 | Generic interface to the driver. 33 | */ 34 | class IPrinterDriver 35 | { 36 | public: 37 | virtual void StartDoc() = 0; 38 | virtual void EndDoc() = 0; 39 | 40 | virtual void StartPage() = 0; 41 | virtual void EndPage() = 0; 42 | 43 | virtual void ProcessRasterLine(const buffer_t& LineBuffer) = 0; 44 | 45 | virtual ~IPrinterDriver() {} 46 | }; 47 | 48 | /** 49 | Provides interface to the environment could be used by IPrinterDriver 50 | */ 51 | class IPrintEnvironment 52 | { 53 | public: 54 | typedef enum 55 | { 56 | jsOK, 57 | jsPaperOut, 58 | jsError, 59 | jsDeleted, 60 | jsPaperSizeError, 61 | jsPaperSizeUndefinedError, 62 | jsHeadOverheat, 63 | jsSlotStatusError, 64 | jsBusy 65 | } job_status_t; 66 | 67 | virtual void WriteData(const buffer_t& DataBuffer) = 0; 68 | virtual void ReadData(buffer_t& DataBuffer) = 0; 69 | 70 | virtual job_status_t GetJobStatus() = 0; 71 | virtual void SetJobStatus(job_status_t JobStatus) = 0; 72 | 73 | virtual ~IPrintEnvironment() {} 74 | }; 75 | 76 | /** 77 | * Interface to monitor sending printer data 78 | * 79 | */ 80 | class ILanguageMonitor 81 | { 82 | public: 83 | virtual void StartDoc() = 0; 84 | virtual void EndDoc() = 0; 85 | 86 | virtual void StartPage() = 0; 87 | virtual void EndPage() = 0; 88 | 89 | virtual void ProcessData(const buffer_t& Data) = 0; 90 | 91 | virtual ~ILanguageMonitor() {} 92 | }; 93 | 94 | 95 | }; //namespace 96 | 97 | #endif 98 | 99 | /* 100 | * End of "$Id: PrinterDriver.h 14976 2011-04-26 15:24:48Z aleksandr $". 101 | */ 102 | -------------------------------------------------------------------------------- /src/common/tests/MOCK_PrintEnvironment.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_PrintEnvironment.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include "MOCK_PrintEnvironment.h" 22 | 23 | void 24 | MockPrintEnvironment::WriteData(const buffer_t& Data) 25 | { 26 | Data_.insert(Data_.end(), Data.begin(), Data.end()); 27 | } 28 | 29 | void 30 | MockPrintEnvironment::ReadData(buffer_t& Data) 31 | { 32 | Data.clear(); 33 | } 34 | 35 | IPrintEnvironment::job_status_t 36 | MockPrintEnvironment::GetJobStatus() 37 | { 38 | return jsOK; 39 | } 40 | 41 | void 42 | MockPrintEnvironment::SetJobStatus(job_status_t JobStatus) 43 | { 44 | } 45 | 46 | const buffer_t& 47 | MockPrintEnvironment::GetData() 48 | { 49 | return Data_; 50 | } 51 | 52 | void 53 | MockPrintEnvironment::ClearData() 54 | { 55 | Data_.clear(); 56 | } 57 | 58 | /* 59 | * End of "$Id: MOCK_PrintEnvironment.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 60 | */ 61 | -------------------------------------------------------------------------------- /src/common/tests/MOCK_PrintEnvironment.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_PrintEnvironment.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef c002c15c_0f9e_4cc5_b38a_b5928c2348b1 22 | #define c002c15c_0f9e_4cc5_b38a_b5928c2348b1 23 | 24 | #include "../PrinterDriver.h" 25 | 26 | using namespace DymoPrinterDriver; 27 | 28 | class MockPrintEnvironment: public IPrintEnvironment 29 | { 30 | public: 31 | virtual ~MockPrintEnvironment() {} 32 | virtual void WriteData(const buffer_t& Data); 33 | virtual void ReadData(buffer_t& Data); 34 | 35 | virtual job_status_t GetJobStatus(); 36 | virtual void SetJobStatus(job_status_t JobStatus); 37 | 38 | const buffer_t& GetData(); 39 | 40 | void ClearData(); 41 | private: 42 | buffer_t Data_; 43 | }; 44 | 45 | #endif 46 | 47 | /* 48 | * End of "$Id: MOCK_PrintEnvironment.h 4759 2008-06-19 19:02:27Z vbuzuev $". 49 | */ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/common/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | TESTS = tests 21 | 22 | check_PROGRAMS = tests 23 | 24 | tests_SOURCES = \ 25 | testsMain.cpp \ 26 | TestCommon.cpp \ 27 | TestCommon.h \ 28 | ../Halftoning.cpp \ 29 | ../Halftoning.h \ 30 | ../ErrorDiffusionHalftoning.cpp \ 31 | ../ErrorDiffusionHalftoning.h \ 32 | TestErrorDiffusionHalftoning.cpp \ 33 | TestErrorDiffusionHalftoning.h \ 34 | ../NonLinearLaplacianHalftoning.cpp \ 35 | ../NonLinearLaplacianHalftoning.h \ 36 | TestNLLHalftoning.cpp \ 37 | TestNLLHalftoning.h 38 | 39 | tests_LDADD = $(CUPS_LIBS) -lcppunit -ldl 40 | 41 | AM_CPPFLAGS = -I.. -I. 42 | 43 | # 44 | # End of $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 45 | # 46 | -------------------------------------------------------------------------------- /src/common/tests/TestCommon.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestCommon.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include 22 | #include "TestCommon.h" 23 | 24 | ostream& 25 | operator<<(ostream& s, const buffer_t& b) 26 | { 27 | ios::fmtflags f = s.flags(ios::hex); 28 | for (buffer_t::const_iterator it = b.begin(); it < b.end(); ++it) 29 | s << int(*it) << " "; 30 | 31 | s.flags(f); 32 | 33 | return s; 34 | } 35 | 36 | /* 37 | * End of "$Id: TestCommon.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 38 | */ 39 | -------------------------------------------------------------------------------- /src/common/tests/TestCommon.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestCommon.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h0ec9edba_c55d_43ab_ba47_ad936cbb8d74 22 | #define h0ec9edba_c55d_43ab_ba47_ad936cbb8d74 23 | 24 | 25 | #include "../PrinterDriver.h" 26 | #include 27 | 28 | using namespace std; 29 | using namespace DymoPrinterDriver; 30 | 31 | ostream& 32 | operator<<(ostream& s, const buffer_t& b); 33 | 34 | #endif 35 | 36 | /* 37 | * End of "$Id: TestCommon.h 4759 2008-06-19 19:02:27Z vbuzuev $". 38 | */ 39 | -------------------------------------------------------------------------------- /src/common/tests/TestErrorDiffusionHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestErrorDiffusionHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef hd5e4ea9d_d3c3_4d2e_8235_830809f13fbf 22 | #define hd5e4ea9d_d3c3_4d2e_8235_830809f13fbf 23 | 24 | #include 25 | #include "../ErrorDiffusionHalftoning.h" 26 | 27 | class ErrorDiffusionTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(ErrorDiffusionTest); 30 | 31 | CPPUNIT_TEST(testBlack); 32 | CPPUNIT_TEST(testWhite); 33 | CPPUNIT_TEST(testRed); 34 | CPPUNIT_TEST(testGreen); 35 | CPPUNIT_TEST(testBlue); 36 | 37 | 38 | CPPUNIT_TEST_SUITE_END(); 39 | 40 | public: 41 | void setUp(); 42 | void tearDown(); 43 | 44 | void testBlack(); 45 | void testWhite(); 46 | void testRed(); 47 | void testGreen(); 48 | void testBlue(); 49 | }; 50 | 51 | #endif 52 | 53 | 54 | /* 55 | * End of "$Id: TestErrorDiffusionHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $". 56 | */ 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/common/tests/TestNLLHalftoning.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestNLLHalftoning.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include "TestNLLHalftoning.h" 22 | #include "TestCommon.h" 23 | #include 24 | 25 | using namespace std; 26 | using namespace DymoPrinterDriver; 27 | 28 | // Registers the fixture into the 'registry' 29 | CPPUNIT_TEST_SUITE_REGISTRATION(NonLinearLaplacianTest); 30 | 31 | void 32 | NonLinearLaplacianTest::setUp() 33 | { 34 | } 35 | 36 | 37 | void 38 | NonLinearLaplacianTest::tearDown() 39 | { 40 | } 41 | 42 | 43 | void 44 | NonLinearLaplacianTest::testBlock() 45 | { 46 | // 8x10 pixels wide, 24bits per pixel 47 | byte pInputImage[] = 48 | { 49 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 50 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 51 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 52 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 53 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 54 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 55 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 56 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 57 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 58 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 59 | }; 60 | byte OutputData[] = 61 | { 62 | 0x00, 0, 63 | 0x38, 0, 64 | 0x38, 0, 65 | 0x38, 0, 66 | 0x38, 0, 67 | 0x38, 0, 68 | 0x38, 0, 69 | 0x38, 0, 70 | 0x00, 0, 71 | 0x00, 0, 72 | }; 73 | 74 | buffer_t OutputLine; 75 | CNLLHalftoning H(0, CHalftoneFilter::itRGB, CHalftoneFilter::itBW); 76 | 77 | CHalftoneFilter::image_buffer_t InputImage; 78 | for (size_t i = 0; i < 10; ++i) 79 | { 80 | buffer_t line(pInputImage + i * 8 * 3, pInputImage + (i + 1) * 8 * 3); 81 | InputImage.push_back(line); 82 | } 83 | 84 | CHalftoneFilter::image_buffer_t OutputImage; 85 | H.ProcessImage(InputImage, OutputImage); 86 | 87 | buffer_t Output; 88 | for (size_t i = 0; i < OutputImage.size(); ++i) 89 | Output.insert(Output.end(), OutputImage[i].begin(), OutputImage[i].end()); 90 | 91 | CPPUNIT_ASSERT_EQUAL( 92 | buffer_t(OutputData, OutputData + sizeof(OutputData)), 93 | Output); 94 | } 95 | 96 | /* 97 | * End of "$Id: TestNLLHalftoning.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 98 | */ 99 | -------------------------------------------------------------------------------- /src/common/tests/TestNLLHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestNLLHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h93317978_9c29_4c43_9de5_263975cb8c69 22 | #define h93317978_9c29_4c43_9de5_263975cb8c69 23 | 24 | #include 25 | #include "../NonLinearLaplacianHalftoning.h" 26 | 27 | class NonLinearLaplacianTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(NonLinearLaplacianTest); 30 | 31 | CPPUNIT_TEST(testBlock); 32 | 33 | CPPUNIT_TEST_SUITE_END(); 34 | 35 | public: 36 | void setUp(); 37 | void tearDown(); 38 | 39 | void testBlock(); 40 | }; 41 | 42 | #endif 43 | 44 | 45 | /* 46 | * End of "$Id: TestNLLHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $". 47 | */ 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/common/tests/testsMain.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: testsMain.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | int main(int argc, char* argv[]) 27 | { 28 | // Get the top level suite from the registry 29 | CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); 30 | 31 | // Adds the test to the list of test to run 32 | 33 | CPPUNIT_NS::TextUi::TestRunner runner; 34 | 35 | runner.addTest(suite); 36 | 37 | 38 | 39 | // Change the default outputter to a compiler error format outputter 40 | 41 | runner.setOutputter( 42 | new CPPUNIT_NS::CompilerOutputter( 43 | &runner.result(), 44 | std::cerr )); 45 | 46 | // Run the test. 47 | 48 | bool wasSucessful = runner.run(); 49 | 50 | 51 | 52 | // Return error code 1 if the one of test failed. 53 | 54 | return wasSucessful ? 0 : 1; 55 | 56 | } 57 | 58 | /* 59 | * End of "$Id: testsMain.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 60 | */ 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/lm/CupsFilterLabelManager.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: CupsFilterLabelManager.h 14880 2011-03-31 16:29:05Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef he780684b_6efc_428d_bfdb_c5422b1ed982 22 | #define he780684b_6efc_428d_bfdb_c5422b1ed982 23 | 24 | #include 25 | #include 26 | #include "LabelManagerDriver.h" 27 | #include "LabelManagerLanguageMonitor.h" 28 | #include "DummyLanguageMonitor.h" 29 | 30 | namespace DymoPrinterDriver 31 | { 32 | 33 | class CDriverInitializerLabelManager 34 | { 35 | public: 36 | static void ProcessPPDOptions (CLabelManagerDriver& Driver, CDummyLanguageMonitor& LM, ppd_file_t* ppd); 37 | static void ProcessPageOptions(CLabelManagerDriver& Driver, CDummyLanguageMonitor& LM, cups_page_header2_t& PageHeader); 38 | }; 39 | 40 | class CDriverInitializerLabelManagerWithLM 41 | { 42 | public: 43 | static void ProcessPPDOptions (CLabelManagerDriver& Driver, CLabelManagerLanguageMonitor& LM, ppd_file_t* ppd); 44 | static void ProcessPageOptions(CLabelManagerDriver& Driver, CLabelManagerLanguageMonitor& LM, cups_page_header2_t& PageHeader); 45 | }; 46 | 47 | } 48 | 49 | #endif 50 | 51 | /* 52 | * End of "$Id: CupsFilterLabelManager.h 14880 2011-03-31 16:29:05Z aleksandr $". 53 | */ -------------------------------------------------------------------------------- /src/lm/LabelManagerLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef __LabelManagerLanguageMonitorH__ 22 | #define __LabelManagerLanguageMonitorH__ 23 | 24 | #include "PrinterDriver.h" 25 | #include "LabelManagerDriver.h" 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | /** 30 | LanguageMonitor for LabelManager printers 31 | Supported features are: 32 | */ 33 | class CLabelManagerLanguageMonitor: public ILanguageMonitor 34 | { 35 | public: 36 | enum status_bits 37 | { 38 | CASSETTE_SIZET0_BIT = 0x01, 39 | CASSETTE_SIZET1_BIT = 0x02, 40 | CASSETTE_SIZE_BITS = (CASSETTE_SIZET0_BIT | CASSETTE_SIZET1_BIT), 41 | GENERAL_ERROR_BIT = 0x04, 42 | HEAD_OVERHEAT_BIT = 0x08, 43 | SLOT_STATUS_BIT = 0x10, 44 | BUSY_BIT = 0x20, 45 | CASSETTE_PRESENT_BIT= 0x40, 46 | AUTO_CUTTER_BIT = 0x80, 47 | NO_POWER_BIT = 0x80, 48 | INCORRECT_SIZE_BIT = 0xFF 49 | }; 50 | 51 | CLabelManagerLanguageMonitor(IPrintEnvironment& Environment, bool UseSleep = true, size_t ReadStatusTimeout = 10); 52 | virtual ~CLabelManagerLanguageMonitor(); 53 | 54 | virtual void StartDoc(); 55 | virtual void EndDoc(); 56 | 57 | virtual void StartPage(); 58 | virtual void EndPage(); 59 | 60 | virtual void ProcessData(const buffer_t& Data); 61 | 62 | void SetDeviceName(const std::string& Value); 63 | void SetTapeWidth(CLabelManagerDriver::tape_width_t Value); 64 | 65 | protected: 66 | private: 67 | // check if printer is locally connected, i.e. to usb port 68 | bool IsLocal(); 69 | 70 | // checks status 71 | void CheckStatus(); 72 | 73 | // Read status byte from the printer 74 | // return true if status has been read, false otherwise 75 | bool ReadStatus(buffer_t& Status); 76 | 77 | // update job status based on status read from the printer 78 | void SetJobStatus(byte Status); 79 | bool CheckTapeSize(buffer_t Status); 80 | 81 | IPrintEnvironment& Environment_; 82 | bool IsFirstPage_; 83 | buffer_t PageData_; 84 | 85 | std::string DeviceName_; 86 | CLabelManagerDriver::tape_width_t TapeWidth_; 87 | 88 | bool UseSleep_; // for test purpose only 89 | bool LastReadStatusResult_; 90 | 91 | size_t ReadStatusTimeout_; 92 | }; 93 | 94 | 95 | }; //namespace 96 | 97 | #endif 98 | 99 | /* 100 | * End of "$Id$". 101 | */ 102 | -------------------------------------------------------------------------------- /src/lm/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 15967 2011-09-02 14:54:28Z pineichen $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | SUBDIRS = tests 21 | 22 | AM_CPPFLAGS = -I../common 23 | 24 | cupsfilter_PROGRAMS = raster2dymolm 25 | 26 | raster2dymolm_SOURCES = \ 27 | raster2dymolm.cpp \ 28 | LabelManagerDriver.cpp \ 29 | LabelManagerDriver.h \ 30 | CupsFilterLabelManager.cpp \ 31 | CupsFilterLabelManager.h \ 32 | LabelManagerLanguageMonitor.cpp \ 33 | LabelManagerLanguageMonitor.h \ 34 | ../common/CupsPrintEnvironment.cpp \ 35 | ../common/CupsPrintEnvironment.h \ 36 | ../common/CupsFilter.h \ 37 | ../common/PrinterDriver.h \ 38 | ../common/Halftoning.h \ 39 | ../common/Halftoning.cpp \ 40 | ../common/ErrorDiffusionHalftoning.h \ 41 | ../common/ErrorDiffusionHalftoning.cpp \ 42 | ../common/NonLinearLaplacianHalftoning.h \ 43 | ../common/NonLinearLaplacianHalftoning.cpp \ 44 | ../common/DummyLanguageMonitor.cpp \ 45 | ../common/DummyLanguageMonitor.h 46 | 47 | raster2dymolm_LDADD = $(CUPS_LIBS) 48 | 49 | # 50 | # End of $Id: Makefile.am 15967 2011-09-02 14:54:28Z pineichen $ 51 | # 52 | -------------------------------------------------------------------------------- /src/lm/raster2dymolm.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: raster2dymolm.cpp 14880 2011-03-31 16:29:05Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "LabelManagerDriver.h" 31 | #include "LabelManagerLanguageMonitor.h" 32 | #include "DummyLanguageMonitor.h" 33 | #include "CupsPrintEnvironment.h" 34 | #include "CupsFilter.h" 35 | #include "CupsFilterLabelManager.h" 36 | 37 | using namespace DymoPrinterDriver; 38 | 39 | static bool 40 | IsBackchannelSupported() 41 | { 42 | return true; 43 | } 44 | 45 | int 46 | main(int argc, char* argv[]) 47 | { 48 | fputs("DEBUG: starting (raster2dymolm)\n", stderr); 49 | 50 | if (IsBackchannelSupported()) 51 | { 52 | CCupsFilter Filter; 53 | return Filter.Run(argc, argv); 54 | } 55 | else 56 | { 57 | CCupsFilter Filter; 58 | return Filter.Run(argc, argv); 59 | } 60 | } 61 | 62 | /* 63 | * End of "$Id: raster2dymolm.cpp 14880 2011-03-31 16:29:05Z aleksandr $". 64 | */ 65 | -------------------------------------------------------------------------------- /src/lm/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 15968 2011-09-02 14:56:33Z pineichen $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | TESTS = tests 21 | 22 | check_PROGRAMS = tests 23 | 24 | tests_SOURCES = \ 25 | ../../common/tests/testsMain.cpp \ 26 | ../../common/tests/MOCK_PrintEnvironment.cpp \ 27 | ../../common/tests/MOCK_PrintEnvironment.h \ 28 | ../../common/tests/TestCommon.cpp \ 29 | ../../common/tests/TestCommon.h \ 30 | ../../common/DummyLanguageMonitor.cpp \ 31 | ../../common/DummyLanguageMonitor.h \ 32 | ../LabelManagerDriver.cpp \ 33 | ../CupsFilterLabelManager.cpp \ 34 | ../CupsFilterLabelManager.h \ 35 | ../LabelManagerLanguageMonitor.cpp \ 36 | ../LabelManagerLanguageMonitor.h \ 37 | TestLabelManagerDriver.cpp \ 38 | TestLabelManagerDriver.h \ 39 | TestLabelManagerFilter.cpp \ 40 | TestLabelManagerFilter.h 41 | 42 | tests_LDADD = $(CUPS_LIBS) -lcppunit -ldl 43 | 44 | AM_CPPFLAGS = -I../../common -I../../common/tests 45 | 46 | # 47 | # End of $Id: Makefile.am 15968 2011-09-02 14:56:33Z pineichen $ 48 | # 49 | -------------------------------------------------------------------------------- /src/lm/tests/TestLabelManagerDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelManagerDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h89cd8614_1576_42a1_a747_8ce1ccab21c3 22 | #define h89cd8614_1576_42a1_a747_8ce1ccab21c3 23 | 24 | #include 25 | #include "../LabelManagerDriver.h" 26 | 27 | class LabelManagerDriverTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(LabelManagerDriverTest); 30 | 31 | //CPPUNIT_TEST(testPrologEpilogCommand); 32 | CPPUNIT_TEST(testEmptyLines); 33 | CPPUNIT_TEST(testEmptyLinesAtEnd); 34 | CPPUNIT_TEST(testDotTab); 35 | CPPUNIT_TEST(testCutAndChainMarks); 36 | CPPUNIT_TEST(testAlignment); 37 | CPPUNIT_TEST(testMinPageLength); 38 | CPPUNIT_TEST(testReverseData); 39 | CPPUNIT_TEST(testContinuousPaper); 40 | CPPUNIT_TEST(testAutoPaper); 41 | CPPUNIT_TEST(testShiftData); 42 | CPPUNIT_TEST(testMaxPrintableWidth); 43 | CPPUNIT_TEST(testTapeAlignmentOffset); 44 | 45 | 46 | CPPUNIT_TEST_SUITE_END(); 47 | 48 | public: 49 | void setUp(); 50 | void tearDown(); 51 | 52 | //void testPrologEpilogCommand(); 53 | void testEmptyLines(); 54 | void testEmptyLinesAtEnd(); 55 | void testDotTab(); 56 | void testCutAndChainMarks(); 57 | void testAlignment(); 58 | void testMinPageLength(); 59 | void testReverseData(); 60 | void testContinuousPaper(); 61 | void testAutoPaper(); 62 | void testShiftData(); 63 | void testMaxPrintableWidth(); 64 | void testTapeAlignmentOffset(); 65 | 66 | }; 67 | 68 | #endif 69 | 70 | /* 71 | * End of "$Id: TestLabelManagerDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $". 72 | */ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/lm/tests/TestLabelManagerFilter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelManagerFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h51475713_0568_480f_b711_ddf8f09a3e15 22 | #define h51475713_0568_480f_b711_ddf8f09a3e15 23 | 24 | #include 25 | #include "MOCK_PrintEnvironment.h" 26 | #include "../LabelManagerDriver.h" 27 | #include "DummyLanguageMonitor.h" 28 | #include 29 | 30 | class LabelManagerFilterTest: public CPPUNIT_NS::TestFixture 31 | { 32 | CPPUNIT_TEST_SUITE(LabelManagerFilterTest); 33 | 34 | CPPUNIT_TEST(testAlignment); 35 | CPPUNIT_TEST(testCutOptions); 36 | CPPUNIT_TEST(testContinuousPaper); 37 | CPPUNIT_TEST(testTapeColor); 38 | CPPUNIT_TEST(testDeviceSettings); 39 | 40 | 41 | CPPUNIT_TEST_SUITE_END(); 42 | 43 | public: 44 | LabelManagerFilterTest(); 45 | 46 | void setUp(); 47 | void tearDown(); 48 | 49 | void testAlignment(); 50 | void testCutOptions(); 51 | void testContinuousPaper(); 52 | void testTapeColor(); 53 | void testDeviceSettings(); 54 | 55 | private: 56 | typedef std::vector ppd_names_t; 57 | typedef std::vector::iterator ppd_names_it; 58 | 59 | typedef std::map ppds_t; 60 | typedef std::map::iterator ppds_it; 61 | 62 | std::vector PPDNames_; 63 | ppds_t ppds_; 64 | MockPrintEnvironment Env_; 65 | CLabelManagerDriver* Driver_; 66 | CDummyLanguageMonitor* LM_; 67 | 68 | }; 69 | 70 | #endif 71 | 72 | 73 | /* 74 | * End of "$Id: TestLabelManagerFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $". 75 | */ 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/lw/CupsFilterLabelWriter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: CupsFilterLabelWriter.h 7049 2009-02-06 23:24:54Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef hd8574b83_b264_47b2_8d33_a46ae75691d2 22 | #define hd8574b83_b264_47b2_8d33_a46ae75691d2 23 | 24 | #include 25 | #include 26 | #include 27 | #include "LabelWriterDriver.h" 28 | #include "LabelWriterLanguageMonitor.h" 29 | #include "DummyLanguageMonitor.h" 30 | 31 | namespace DymoPrinterDriver 32 | { 33 | 34 | class CDriverInitializerLabelWriter 35 | { 36 | public: 37 | static void ProcessPPDOptions (CLabelWriterDriver& Driver, CDummyLanguageMonitor& LM, ppd_file_t* ppd); 38 | static void ProcessPageOptions(CLabelWriterDriver& Driver, CDummyLanguageMonitor& LM, cups_page_header2_t& PageHeader); 39 | }; 40 | 41 | class CDriverInitializerLabelWriterTwinTurbo 42 | { 43 | public: 44 | static void ProcessPPDOptions (CLabelWriterDriverTwinTurbo& Driver, CDummyLanguageMonitor& LM, ppd_file_t* ppd); 45 | static void ProcessPageOptions(CLabelWriterDriverTwinTurbo& Driver, CDummyLanguageMonitor& LM, cups_page_header2_t& PageHeader); 46 | }; 47 | 48 | class CDriverInitializerLabelWriterWithLM 49 | { 50 | public: 51 | static void ProcessPPDOptions (CLabelWriterDriver& Driver, CLabelWriterLanguageMonitor& LM, ppd_file_t* ppd); 52 | static void ProcessPageOptions(CLabelWriterDriver& Driver, CLabelWriterLanguageMonitor& LM, cups_page_header2_t& PageHeader); 53 | }; 54 | 55 | 56 | class CDriverInitializerLabelWriterTwinTurboWithLM 57 | { 58 | public: 59 | static void ProcessPPDOptions (CLabelWriterDriverTwinTurbo& Driver, CLabelWriterLanguageMonitor& LM, ppd_file_t* ppd); 60 | static void ProcessPageOptions(CLabelWriterDriverTwinTurbo& Driver, CLabelWriterLanguageMonitor& LM, cups_page_header2_t& PageHeader); 61 | }; 62 | 63 | } 64 | 65 | #endif 66 | 67 | /* 68 | * End of "$Id: CupsFilterLabelWriter.h 7049 2009-02-06 23:24:54Z vbuzuev $". 69 | */ 70 | -------------------------------------------------------------------------------- /src/lw/LabelWriterLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: LabelWriterLanguageMonitor.h 15006 2011-04-28 15:25:02Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h6d0799cd_6eab_4e0d_9c2b_acb6fbb54d11 22 | #define h6d0799cd_6eab_4e0d_9c2b_acb6fbb54d11 23 | 24 | #include "PrinterDriver.h" 25 | #include "LabelWriterDriver.h" 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | 30 | 31 | /** 32 | LanguageMonitor for LabelWriter printers 33 | Supported features are: reprinting last page on end of roll 34 | */ 35 | class CLabelWriterLanguageMonitor: public ILanguageMonitor 36 | { 37 | public: 38 | enum status_bits 39 | { 40 | TOF_BIT = 0x02, 41 | ROLL_CHANGED_BIT = 0x08, 42 | PAPER_OUT_BIT = 0x20, 43 | PAPER_FEED_BIT = 0x40, 44 | ERROR_BIT = 0x80, 45 | }; 46 | 47 | CLabelWriterLanguageMonitor(IPrintEnvironment& Environment, bool UseSleep = true, size_t ReadStatusTimeout = 10); 48 | virtual ~CLabelWriterLanguageMonitor(); 49 | 50 | virtual void StartDoc(); 51 | virtual void EndDoc(); 52 | 53 | virtual void StartPage(); 54 | virtual void EndPage(); 55 | 56 | virtual void ProcessData(const buffer_t& Data); 57 | 58 | // some values used by driver is also interesting for the language monitor 59 | void SetPaperType(CLabelWriterDriver::paper_type_t Value); 60 | void SetRoll(CLabelWriterDriverTwinTurbo::roll_t Value); 61 | 62 | 63 | protected: 64 | private: 65 | // check if printer is locally connected, i.e. to usb port 66 | bool IsLocal(); 67 | 68 | // send reset command to reset from probably nonproper finished previous job 69 | void ResetPrinter(); 70 | 71 | // send ESC q as first command to synchronize roll used by drivers and the device 72 | // it is needed to properly read status byte from the active roll 73 | void SynchronizeRoll(); 74 | 75 | // checks status and reprint label if needed 76 | void CheckStatusAndReprint(); 77 | 78 | // Read status byte from the printer 79 | // return true if status has been read, false otherwise 80 | bool ReadStatus(byte& Status); 81 | 82 | // request status while the status become OK 83 | // return true on success, false - otherwise 84 | bool PollUntilPaperIn(); 85 | 86 | // update job status based on status read from the printer 87 | void SetJobStatus(byte Status); 88 | 89 | // reprint cached label 90 | void ReprintLabel(); 91 | 92 | IPrintEnvironment& Environment_; 93 | 94 | CLabelWriterDriver::paper_type_t PaperType_; 95 | CLabelWriterDriverTwinTurbo::roll_t Roll_; 96 | bool RollUsed_; 97 | bool IsFirstPage_; 98 | 99 | buffer_t PageData_; 100 | 101 | bool UseSleep_; // for test purpose only 102 | byte LastStatus_; 103 | bool LastReadStatusResult_; 104 | 105 | size_t ReadStatusTimeout_; 106 | }; 107 | 108 | 109 | }; //namespace 110 | 111 | #endif 112 | 113 | /* 114 | * End of "$Id: LabelWriterLanguageMonitor.h 15006 2011-04-28 15:25:02Z aleksandr $". 115 | */ 116 | -------------------------------------------------------------------------------- /src/lw/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | SUBDIRS = tests 21 | 22 | cupsfilter_PROGRAMS = raster2dymolw 23 | 24 | raster2dymolw_SOURCES = \ 25 | raster2dymolw.cpp \ 26 | LabelWriterDriver.cpp \ 27 | LabelWriterDriver.h \ 28 | LabelWriterLanguageMonitor.cpp \ 29 | LabelWriterLanguageMonitor.h \ 30 | CupsFilterLabelWriter.cpp \ 31 | CupsFilterLabelWriter.h \ 32 | ../common/CupsPrintEnvironment.cpp \ 33 | ../common/CupsPrintEnvironment.h \ 34 | ../common/CupsFilter.h \ 35 | ../common/CommonTypedefs.h \ 36 | ../common/PrinterDriver.h \ 37 | ../common/Halftoning.h \ 38 | ../common/Halftoning.cpp \ 39 | ../common/ErrorDiffusionHalftoning.h \ 40 | ../common/ErrorDiffusionHalftoning.cpp \ 41 | ../common/NonLinearLaplacianHalftoning.h \ 42 | ../common/NonLinearLaplacianHalftoning.cpp \ 43 | ../common/DummyLanguageMonitor.cpp \ 44 | ../common/DummyLanguageMonitor.h 45 | 46 | raster2dymolw_LDADD = $(CUPS_LIBS) 47 | 48 | AM_CPPFLAGS = -I../common 49 | 50 | # 51 | # End of $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 52 | # 53 | -------------------------------------------------------------------------------- /src/lw/raster2dymolw.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: raster2dymolw.cpp 15043 2011-05-05 17:38:38Z aleksandr $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | //#include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "LabelWriterDriver.h" 34 | #include "LabelWriterLanguageMonitor.h" 35 | #include "DummyLanguageMonitor.h" 36 | #include "CupsPrintEnvironment.h" 37 | #include "CupsFilter.h" 38 | #include "CupsFilterLabelWriter.h" 39 | 40 | using namespace DymoPrinterDriver; 41 | 42 | 43 | //#define CUPS_12 1 44 | static bool 45 | IsBackchannelSupported() 46 | { 47 | return true; 48 | 49 | // if the backend channel is supported the fd is 3 50 | //struct stat stat; 51 | 52 | //return fstat(3, &stat) == 0; 53 | } 54 | 55 | int 56 | main(int argc, char* argv[]) 57 | { 58 | fputs("DEBUG: starting (raster2dymolw)\n", stderr); 59 | 60 | ppd_file_t* ppd = ppdOpenFile(getenv("PPD")); 61 | if (!ppd) 62 | { 63 | perror("WARNING: Unable to open ppd file, use default settings - "); 64 | 65 | if (IsBackchannelSupported()) 66 | { 67 | CCupsFilter Filter; 68 | return Filter.Run(argc, argv); 69 | } 70 | else 71 | { 72 | CCupsFilter Filter; 73 | return Filter.Run(argc, argv); 74 | } 75 | } 76 | else 77 | { 78 | if (!strcasecmp(ppd->modelname, "DYMO LabelWriter Twin Turbo") 79 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter 450 Twin Turbo")) 80 | { 81 | if (IsBackchannelSupported()) 82 | { 83 | CCupsFilter Filter; 84 | return Filter.Run(argc, argv); 85 | } 86 | else 87 | { 88 | CCupsFilter Filter; 89 | return Filter.Run(argc, argv); 90 | } 91 | } 92 | else if (!strcasecmp(ppd->modelname, "DYMO LabelWriter 400") 93 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter 400 Turbo") 94 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter DUO Label") 95 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter 4XL") 96 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter 450") 97 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter 450 Turbo") 98 | || !strcasecmp(ppd->modelname, "DYMO LabelWriter 450 DUO Label")) 99 | { 100 | if (IsBackchannelSupported()) 101 | { 102 | CCupsFilter Filter; 103 | return Filter.Run(argc, argv); 104 | } 105 | else 106 | { 107 | CCupsFilter Filter; 108 | return Filter.Run(argc, argv); 109 | } 110 | } 111 | else 112 | { 113 | if (IsBackchannelSupported()) 114 | { 115 | CCupsFilter Filter; 116 | return Filter.Run(argc, argv); 117 | } 118 | else 119 | { 120 | CCupsFilter Filter; 121 | return Filter.Run(argc, argv); 122 | } 123 | } 124 | } 125 | } 126 | 127 | /* 128 | * End of "$Id: raster2dymolw.cpp 15043 2011-05-05 17:38:38Z aleksandr $". 129 | */ 130 | -------------------------------------------------------------------------------- /src/lw/tests/MOCK_LWLMPrintEnvironment.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_LWLMPrintEnvironment.cpp 15962 2011-09-02 14:45:00Z pineichen $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include "MOCK_LWLMPrintEnvironment.h" 22 | #include "../LabelWriterDriver.h" 23 | #include 24 | 25 | static const byte TOF_BIT = 0x02; 26 | static const byte ROLL_CHANGED_BIT = 0x08; 27 | static const byte PAPER_OUT_BIT = 0x20; 28 | static const byte PAPER_FEED_BIT = 0x40; 29 | static const byte ERROR_BIT = 0x80; 30 | 31 | 32 | MockLWLMPrintEnvironment::MockLWLMPrintEnvironment(): Mode_() 33 | { 34 | Mode_.push_back(mtTOF); 35 | } 36 | 37 | void 38 | MockLWLMPrintEnvironment::WriteData(const buffer_t& Data) 39 | { 40 | // printf("MockLWLMPrintEnvironment::WriteData()"); 41 | 42 | // don't store request status requests 43 | if (Data != CLabelWriterDriver::GetRequestStatusCommand()) 44 | MockPrintEnvironment::WriteData(Data); 45 | } 46 | 47 | void 48 | MockLWLMPrintEnvironment::ReadData(buffer_t& Data) 49 | { 50 | //printf("MockLWLMPrintEnvironment::ReadData()"); 51 | 52 | Data.clear(); 53 | 54 | mode_t Mode = mtTOF; 55 | 56 | if (Mode_.size() > 1) 57 | { 58 | Mode = Mode_.back(); 59 | Mode_.pop_back(); 60 | } 61 | else 62 | Mode = Mode_.back(); 63 | 64 | switch (Mode) 65 | { 66 | case mtTOF: 67 | Data.push_back(TOF_BIT); 68 | break; 69 | case mtPaperOut: 70 | Data.push_back(ERROR_BIT | PAPER_OUT_BIT); 71 | break; 72 | case mtRollChanged: 73 | Data.push_back(TOF_BIT | ROLL_CHANGED_BIT); 74 | break; 75 | case mtNotTOF: 76 | Data.push_back(0); 77 | break; 78 | case mtFailed: 79 | break; 80 | default: 81 | assert(0); 82 | } 83 | } 84 | 85 | IPrintEnvironment::job_status_t 86 | MockLWLMPrintEnvironment::GetJobStatus() 87 | { 88 | return jsOK; 89 | } 90 | 91 | 92 | void 93 | MockLWLMPrintEnvironment::SetJobStatus(job_status_t JobStatus) 94 | { 95 | switch (JobStatus) 96 | { 97 | case jsOK: 98 | //fprintf(stderr, "INFO: continue printing.\n"); 99 | break; 100 | case jsPaperOut: 101 | //fprintf(stderr, "INFO: paper out.\n"); 102 | break; 103 | case jsError: 104 | //fprintf(stderr, "INFO: printing error.\n"); 105 | break; 106 | default: 107 | assert(0); 108 | } 109 | } 110 | 111 | 112 | void 113 | MockLWLMPrintEnvironment::SetMode(mode_t Mode) 114 | { 115 | Mode_.clear(); 116 | Mode_.push_back(Mode); 117 | } 118 | 119 | void 120 | MockLWLMPrintEnvironment::PushMode(mode_t Mode, size_t Count) 121 | { 122 | for (size_t i = 0; i < Count; ++i) 123 | Mode_.push_back(Mode); 124 | } 125 | 126 | 127 | /* 128 | * End of "$Id: MOCK_LWLMPrintEnvironment.cpp 15962 2011-09-02 14:45:00Z pineichen $". 129 | */ 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/lw/tests/MOCK_LWLMPrintEnvironment.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_LWLMPrintEnvironment.h 15961 2011-09-02 14:44:07Z pineichen $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef hc8e31bb3_01a5_4422_84b8_64c017e18521 22 | #define hc8e31bb3_01a5_4422_84b8_64c017e18521 23 | 24 | #include 25 | #include "../PrinterDriver.h" 26 | #include "MOCK_PrintEnvironment.h" 27 | 28 | using namespace DymoPrinterDriver; 29 | 30 | 31 | /** 32 | Special environment to enulate responces from the LabelWriter 33 | Used to test language monitor 34 | */ 35 | class MockLWLMPrintEnvironment: public MockPrintEnvironment 36 | { 37 | public: 38 | typedef enum 39 | { 40 | mtTOF, // return TOF 41 | mtPaperOut, // return paper out 42 | mtNotTOF, // not TOF but ether not ERROR 43 | mtFailed, // unable to read status 44 | mtRollChanged 45 | 46 | }mode_t; 47 | 48 | MockLWLMPrintEnvironment(); 49 | virtual ~MockLWLMPrintEnvironment() {} 50 | virtual void WriteData(const buffer_t& Data); 51 | virtual void ReadData(buffer_t& Data); 52 | virtual job_status_t GetJobStatus(); 53 | virtual void SetJobStatus(job_status_t JobStatus); 54 | 55 | ////////////////////////////////////////////////////// 56 | // functions to control what is returned by requests 57 | 58 | // return Mode alwayes 59 | void SetMode(mode_t Mode); 60 | 61 | // push mode that will be returned next call to ReadData() 62 | void PushMode(mode_t Mode, size_t Count = 1); 63 | 64 | private: 65 | std::vector Mode_; 66 | }; 67 | 68 | #endif 69 | 70 | /* 71 | * End of "$Id: MOCK_LWLMPrintEnvironment.h 15961 2011-09-02 14:44:07Z pineichen $". 72 | */ 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/lw/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | 20 | TESTS = tests 21 | 22 | check_PROGRAMS = tests 23 | 24 | tests_SOURCES = \ 25 | ../../common/tests/testsMain.cpp \ 26 | ../../common/tests/MOCK_PrintEnvironment.cpp \ 27 | ../../common/tests/MOCK_PrintEnvironment.h \ 28 | ../../common/tests/TestCommon.cpp \ 29 | ../../common/tests/TestCommon.h \ 30 | ../../common/DummyLanguageMonitor.cpp \ 31 | ../../common/DummyLanguageMonitor.h \ 32 | ../LabelWriterLanguageMonitor.cpp \ 33 | ../LabelWriterLanguageMonitor.h \ 34 | ../LabelWriterDriver.cpp \ 35 | ../CupsFilterLabelWriter.cpp \ 36 | ../CupsFilterLabelWriter.h \ 37 | TestLabelWriterDriver.cpp \ 38 | TestLabelWriterDriver.h \ 39 | TestLabelWriterFilter.cpp \ 40 | TestLabelWriterFilter.h \ 41 | TestLabelWriterLanguageMonitor.cpp \ 42 | TestLabelWriterLanguageMonitor.h \ 43 | MOCK_LWLMPrintEnvironment.cpp \ 44 | MOCK_LWLMPrintEnvironment.h 45 | 46 | 47 | tests_LDADD = $(CUPS_LIBS) -lcppunit -ldl 48 | 49 | AM_CPPFLAGS = -I../../common -I../../common/tests 50 | 51 | # 52 | # End of $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 53 | # 54 | -------------------------------------------------------------------------------- /src/lw/tests/TestLabelWriterDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h32c7cec0_3fa1_46d1_af3b_834205cd3ce8 22 | #define h32c7cec0_3fa1_46d1_af3b_834205cd3ce8 23 | 24 | #include 25 | #include "../LabelWriterDriver.h" 26 | 27 | class LabelWriterDriverTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(LabelWriterDriverTest); 30 | 31 | CPPUNIT_TEST(testPrologEpilogCommand); 32 | CPPUNIT_TEST(testCompression); 33 | CPPUNIT_TEST(testEmptyLines); 34 | CPPUNIT_TEST(testDotTab); 35 | CPPUNIT_TEST(testContinuousPaper); 36 | CPPUNIT_TEST(test400EndPageEndDoc); 37 | CPPUNIT_TEST(testTwinTurboRoll); 38 | 39 | 40 | CPPUNIT_TEST_SUITE_END(); 41 | 42 | public: 43 | void setUp(); 44 | void tearDown(); 45 | 46 | void testPrologEpilogCommand(); 47 | void testCompression(); 48 | void testEmptyLines(); 49 | void testDotTab(); 50 | void testContinuousPaper(); 51 | 52 | void test400EndPageEndDoc(); 53 | void testTwinTurboRoll(); 54 | 55 | }; 56 | 57 | #endif 58 | 59 | 60 | /* 61 | * End of "$Id: TestLabelWriterDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $". 62 | */ 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/lw/tests/TestLabelWriterFilter.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterFilter.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #include "TestCommon.h" 22 | #include "TestLabelWriterFilter.h" 23 | #include "MOCK_PrintEnvironment.h" 24 | #include "../LabelWriterDriver.h" 25 | #include "../CupsFilterLabelWriter.h" 26 | 27 | #include 28 | 29 | using namespace std; 30 | using namespace DymoPrinterDriver; 31 | 32 | // Registers the fixture into the 'registry' 33 | CPPUNIT_TEST_SUITE_REGISTRATION(LabelWriterFilterTest); 34 | 35 | void 36 | LabelWriterFilterTest::setUp() 37 | { 38 | ppd_ = ppdOpenFile("../../../ppd/lwtt.ppd"); 39 | CPPUNIT_ASSERT(ppd_ != NULL); 40 | 41 | ppdMarkDefaults(ppd_); 42 | 43 | Driver_ = new CLabelWriterDriverTwinTurbo(Env_); 44 | LM_ = new CDummyLanguageMonitor(Env_); 45 | } 46 | 47 | 48 | void 49 | LabelWriterFilterTest::tearDown() 50 | { 51 | ppdClose(ppd_); 52 | delete Driver_; 53 | delete LM_; 54 | } 55 | 56 | void 57 | LabelWriterFilterTest::testDensity() 58 | { 59 | ppdMarkOption(ppd_, "DymoPrintDensity", "Light"); 60 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 61 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdLow, Driver_->GetDensity()); 62 | 63 | ppdMarkOption(ppd_, "DymoPrintDensity", "Medium"); 64 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 65 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdMedium, Driver_->GetDensity()); 66 | 67 | ppdMarkOption(ppd_, "DymoPrintDensity", "Normal"); 68 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 69 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdNormal, Driver_->GetDensity()); 70 | 71 | ppdMarkOption(ppd_, "DymoPrintDensity", "Dark"); 72 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 73 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdHigh, Driver_->GetDensity()); 74 | } 75 | 76 | void 77 | LabelWriterFilterTest::testQuality() 78 | { 79 | ppdMarkOption(ppd_, "DymoPrintQuality", "Text"); 80 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 81 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pqText, Driver_->GetQuality()); 82 | 83 | ppdMarkOption(ppd_, "DymoPrintQuality", "Graphics"); 84 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 85 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pqBarcodeAndGraphics, Driver_->GetQuality()); 86 | } 87 | 88 | void 89 | LabelWriterFilterTest::testRoll() 90 | { 91 | ppdMarkOption(ppd_, "InputSlot", "Auto"); 92 | CDriverInitializerLabelWriterTwinTurbo::ProcessPPDOptions(*Driver_, *LM_, ppd_); 93 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriverTwinTurbo::rtAuto, Driver_->GetRoll()); 94 | 95 | ppdMarkOption(ppd_, "InputSlot", "Left"); 96 | CDriverInitializerLabelWriterTwinTurbo::ProcessPPDOptions(*Driver_, *LM_, ppd_); 97 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriverTwinTurbo::rtLeft, Driver_->GetRoll()); 98 | 99 | ppdMarkOption(ppd_, "InputSlot", "Right"); 100 | CDriverInitializerLabelWriterTwinTurbo::ProcessPPDOptions(*Driver_, *LM_, ppd_); 101 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriverTwinTurbo::rtRight, Driver_->GetRoll()); 102 | } 103 | 104 | /* 105 | * End of "$Id: TestLabelWriterFilter.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 106 | */ 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/lw/tests/TestLabelWriterFilter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef hdc29f4ef_802f_478b_97c1_e61ddf654005 22 | #define hdc29f4ef_802f_478b_97c1_e61ddf654005 23 | 24 | #include 25 | #include "MOCK_PrintEnvironment.h" 26 | #include "../LabelWriterDriver.h" 27 | #include "../DummyLanguageMonitor.h" 28 | 29 | #include 30 | 31 | class LabelWriterFilterTest: public CPPUNIT_NS::TestFixture 32 | { 33 | CPPUNIT_TEST_SUITE(LabelWriterFilterTest); 34 | 35 | CPPUNIT_TEST(testDensity); 36 | CPPUNIT_TEST(testQuality); 37 | CPPUNIT_TEST(testRoll); 38 | 39 | 40 | CPPUNIT_TEST_SUITE_END(); 41 | 42 | public: 43 | void setUp(); 44 | void tearDown(); 45 | 46 | void testDensity(); 47 | void testQuality(); 48 | void testRoll(); 49 | 50 | private: 51 | ppd_file_t* ppd_; 52 | MockPrintEnvironment Env_; 53 | CLabelWriterDriverTwinTurbo* Driver_; 54 | CDummyLanguageMonitor* LM_; 55 | 56 | }; 57 | 58 | #endif 59 | 60 | /* 61 | * End of "$Id: TestLabelWriterFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $". 62 | */ 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/lw/tests/TestLabelWriterLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterLanguageMonitor.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | #ifndef h017d33d9_70fc_470f_a55d_19c2eb5f0263 22 | #define h017d33d9_70fc_470f_a55d_19c2eb5f0263 23 | 24 | #include 25 | #include "../LabelWriterDriver.h" 26 | 27 | class LabelWriterLMTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(LabelWriterLMTest); 30 | 31 | CPPUNIT_TEST(testGoodJob); 32 | CPPUNIT_TEST(testPaperOut); 33 | CPPUNIT_TEST(testPaperOutAfterReprint); 34 | CPPUNIT_TEST(testRollSynchronize); 35 | CPPUNIT_TEST(testResetPrinter); 36 | CPPUNIT_TEST(testPollForPaperIn); 37 | CPPUNIT_TEST(testOneGoodPageOneNot); 38 | CPPUNIT_TEST(testStatusReadFailed); 39 | CPPUNIT_TEST(testContinuousPaper); 40 | CPPUNIT_TEST(testRollChangedBit); 41 | 42 | CPPUNIT_TEST_SUITE_END(); 43 | 44 | public: 45 | void setUp(); 46 | void tearDown(); 47 | 48 | // test a job when there is no any problems 49 | void testGoodJob(); 50 | void testPaperOut(); 51 | void testPaperOutAfterReprint(); // reprint a page twice 52 | void testRollSynchronize(); 53 | void testResetPrinter(); 54 | void testPollForPaperIn(); // test waiting for inserting paper 55 | void testOneGoodPageOneNot(); 56 | void testStatusReadFailed(); 57 | void testContinuousPaper(); 58 | void testRollChangedBit(); 59 | 60 | }; 61 | 62 | #endif 63 | 64 | /* 65 | * End of "$Id: TestLabelWriterLanguageMonitor.h 4759 2008-06-19 19:02:27Z vbuzuev $". 66 | */ 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src_v2/Makefile.am: -------------------------------------------------------------------------------- 1 | # DYMO LabelWriter Drivers 2 | # Copyright (C) 2008 Sanford L.P. 3 | 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | SUBDIRS = lw lm common/tests 19 | -------------------------------------------------------------------------------- /src_v2/common/CommonTypedefs.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: CommonTypedefs.h 40126 2016-02-11 17:13:57Z pineichen $ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef COMMON_TYPE_DEF_H 22 | #define COMMON_TYPE_DEF_H 23 | 24 | #include 25 | 26 | namespace DymoPrinterDriver 27 | { 28 | 29 | typedef unsigned char byte; 30 | typedef unsigned int dword; 31 | typedef std::vector buffer_t; 32 | 33 | } // namespace 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src_v2/common/CupsPrintEnvironment.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "PrinterDriver.h" 22 | 23 | namespace DymoPrinterDriver 24 | { 25 | 26 | class CCupsPrintEnvironmentForDriver: public IPrintEnvironment 27 | { 28 | public: 29 | CCupsPrintEnvironmentForDriver(ILanguageMonitor& LanguageMonitor); 30 | virtual ~CCupsPrintEnvironmentForDriver(); 31 | virtual bool WriteData(const buffer_t& DataBuffer); 32 | virtual bool ReadData(buffer_t& DataBuffer); 33 | virtual job_status_t GetJobStatus() { return jsOK; } 34 | virtual void SetJobStatus(job_status_t JobStatus) {} 35 | 36 | private: 37 | FILE* PRNFile_; 38 | ILanguageMonitor& LanguageMonitor_; 39 | }; 40 | 41 | class CCupsPrintEnvironmentForLM: public IPrintEnvironment 42 | { 43 | public: 44 | CCupsPrintEnvironmentForLM(); 45 | virtual ~CCupsPrintEnvironmentForLM(); 46 | virtual bool WriteData(const buffer_t& DataBuffer); 47 | virtual bool ReadData(buffer_t& DataBuffer); 48 | virtual job_status_t GetJobStatus(); 49 | virtual void SetJobStatus(job_status_t JobStatus); 50 | 51 | private: 52 | IPrintEnvironment::job_status_t JobStatus_; 53 | bool isBluetooth_; 54 | bool isBonjour_; 55 | double timeout_; 56 | }; 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /src_v2/common/CupsUtils.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "CupsUtils.h" 22 | 23 | namespace DymoPrinterDriver 24 | { 25 | 26 | const char* CCupsUtils::GetCupsOption(const char* name, int num_options, cups_option_t* options, const char* value) 27 | { 28 | const char* option = cupsGetOption(name, num_options, options); 29 | 30 | if(!option) 31 | return value; 32 | 33 | return option; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src_v2/common/CupsUtils.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include 22 | 23 | namespace DymoPrinterDriver 24 | { 25 | class CCupsUtils 26 | { 27 | public: 28 | static const char* GetCupsOption(const char* name, int num_options, cups_option_t* options, const char* value = NULL); 29 | }; 30 | }; -------------------------------------------------------------------------------- /src_v2/common/DummyLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: DummyLanguageMonitor.h 40126 2016-02-11 17:13:57Z pineichen $ 3 | 4 | // DYMO Language Monitor 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef DUMMY_LANGUAGE_MONITOR_H 22 | #define DUMMY_LANGUAGE_MONITOR_H 23 | 24 | #include "PrinterDriver.h" 25 | 26 | namespace DymoPrinterDriver 27 | { 28 | 29 | class CDummyLanguageMonitor : public ILanguageMonitor 30 | { 31 | public: 32 | CDummyLanguageMonitor(IPrintEnvironment& Environment) : _environment(Environment) {} 33 | virtual ~CDummyLanguageMonitor() {} 34 | 35 | virtual void StartDoc() {} 36 | virtual void EndDoc() {} 37 | 38 | virtual void StartPage() {} 39 | virtual void EndPage() {} 40 | 41 | virtual void ProcessData(const buffer_t& Data) {} 42 | 43 | private: 44 | IPrintEnvironment& _environment; 45 | }; 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src_v2/common/NonLinearLaplacianHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: $ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef NONLINEARLAPLACIANHALFTONING_H 22 | #define NONLINEARLAPLACIANHALFTONING_H 23 | 24 | #include "Halftoning.h" 25 | 26 | //namespace dymo 27 | namespace DymoPrinterDriver 28 | { 29 | 30 | class CNLLHalftoning: public CHalftoneFilter 31 | { 32 | public: 33 | CNLLHalftoning(int Threshold, image_t InputImageType, image_t OutputImageType); 34 | virtual ~CNLLHalftoning(); 35 | 36 | virtual bool IsProcessLineSupported(); 37 | virtual void ProcessLine(const buffer_t& InputLine, buffer_t& OutputLine); 38 | virtual void ProcessImage(const void* ImageData, size_t ImageWidth, size_t ImageHeight, size_t LineDelta, std::vector& OutputImage); 39 | virtual void ProcessImage(const image_buffer_t& InputImage, image_buffer_t& OutputImage); 40 | 41 | int GetThreshold(); 42 | 43 | private: 44 | int _threshold; // constant used to separate a block to classes using NLL 45 | 46 | size_t _imageWidth; 47 | size_t _imageHeight; 48 | 49 | // split image to 18-pixels block be diagonal 50 | // return true if diagonal contains at least one Block inside image, so next diagonal should be processes 51 | // on output (x1, y1) is coodrs of pixel #1 of topmost block in the diagonal 52 | bool ProcessDiagonal(const std::vector& InputImage, std::vector& OutputImage, size_t& x1, size_t& y1); 53 | }; 54 | 55 | }; 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /src_v2/common/PrinterDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: PrinterDriver.h 43548 2017-05-26 10:32:18Z aleksandr $ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef PRINTER_DRIVER_H 22 | #define PRINTER_DRIVER_H 23 | 24 | #include "CommonTypedefs.h" 25 | 26 | namespace DymoPrinterDriver 27 | { 28 | 29 | const byte ESC = 0x1b; 30 | 31 | // Generic interface to the driver 32 | class IPrinterDriver 33 | { 34 | public: 35 | typedef enum 36 | { 37 | ptRegular = 0, 38 | ptContinuous = 1 39 | } paper_type_t; 40 | 41 | virtual ~IPrinterDriver() {} 42 | 43 | virtual void StartDoc() = 0; 44 | virtual void EndDoc() = 0; 45 | 46 | virtual void StartPage() = 0; 47 | virtual void EndPage() = 0; 48 | 49 | virtual void ProcessRasterLine(const buffer_t& LineBuffer) = 0; 50 | }; 51 | 52 | // Interface to monitor sending printer data 53 | class ILanguageMonitor 54 | { 55 | public: 56 | virtual ~ILanguageMonitor() {} 57 | 58 | virtual void StartDoc() = 0; 59 | virtual void EndDoc() = 0; 60 | 61 | virtual void StartPage() = 0; 62 | virtual void EndPage() = 0; 63 | 64 | virtual void ProcessData(const buffer_t& Data) = 0; 65 | }; 66 | 67 | // Provides interface to the environment 68 | class IPrintEnvironment 69 | { 70 | public: 71 | typedef enum 72 | { 73 | jsOK, 74 | jsPaperOut, 75 | jsError, 76 | jsDeleted, 77 | jsPaperSizeError, 78 | jsPaperSizeUndefinedError, 79 | jsHeadOverheat, 80 | jsSlotStatusError, 81 | jsCounterfeitError, 82 | jsBusy 83 | } job_status_t; 84 | 85 | virtual ~IPrintEnvironment() {} 86 | 87 | virtual bool WriteData(const buffer_t& DataBuffer) = 0; 88 | virtual bool ReadData(buffer_t& DataBuffer) = 0; 89 | 90 | virtual job_status_t GetJobStatus() = 0; 91 | virtual void SetJobStatus(job_status_t JobStatus) = 0; 92 | }; 93 | 94 | }; // namespace 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src_v2/common/tests/MOCK_PrintEnvironment.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_PrintEnvironment.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "MOCK_PrintEnvironment.h" 22 | 23 | void 24 | MockPrintEnvironment::WriteData(const buffer_t& Data) 25 | { 26 | Data_.insert(Data_.end(), Data.begin(), Data.end()); 27 | } 28 | 29 | void 30 | MockPrintEnvironment::ReadData(buffer_t& Data) 31 | { 32 | Data.clear(); 33 | } 34 | 35 | IPrintEnvironment::job_status_t 36 | MockPrintEnvironment::GetJobStatus() 37 | { 38 | return jsOK; 39 | } 40 | 41 | void 42 | MockPrintEnvironment::SetJobStatus(job_status_t JobStatus) 43 | { 44 | } 45 | 46 | const buffer_t& 47 | MockPrintEnvironment::GetData() 48 | { 49 | return Data_; 50 | } 51 | 52 | void 53 | MockPrintEnvironment::ClearData() 54 | { 55 | Data_.clear(); 56 | } 57 | 58 | /* 59 | * End of "$Id: MOCK_PrintEnvironment.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 60 | */ 61 | -------------------------------------------------------------------------------- /src_v2/common/tests/MOCK_PrintEnvironment.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_PrintEnvironment.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef c002c15c_0f9e_4cc5_b38a_b5928c2348b1 22 | #define c002c15c_0f9e_4cc5_b38a_b5928c2348b1 23 | 24 | #include "../PrinterDriver.h" 25 | 26 | using namespace DymoPrinterDriver; 27 | 28 | class MockPrintEnvironment: public IPrintEnvironment 29 | { 30 | public: 31 | virtual ~MockPrintEnvironment() {} 32 | virtual void WriteData(const buffer_t& Data); 33 | virtual void ReadData(buffer_t& Data); 34 | 35 | virtual job_status_t GetJobStatus(); 36 | virtual void SetJobStatus(job_status_t JobStatus); 37 | 38 | const buffer_t& GetData(); 39 | 40 | void ClearData(); 41 | private: 42 | buffer_t Data_; 43 | }; 44 | 45 | #endif 46 | 47 | /* 48 | * End of "$Id: MOCK_PrintEnvironment.h 4759 2008-06-19 19:02:27Z vbuzuev $". 49 | */ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src_v2/common/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | TESTS = tests 21 | 22 | check_PROGRAMS = tests 23 | 24 | tests_SOURCES = \ 25 | testsMain.cpp \ 26 | TestCommon.cpp \ 27 | TestCommon.h \ 28 | ../Halftoning.cpp \ 29 | ../Halftoning.h \ 30 | ../ErrorDiffusionHalftoning.cpp \ 31 | ../ErrorDiffusionHalftoning.h \ 32 | TestErrorDiffusionHalftoning.cpp \ 33 | TestErrorDiffusionHalftoning.h \ 34 | ../NonLinearLaplacianHalftoning.cpp \ 35 | ../NonLinearLaplacianHalftoning.h \ 36 | TestNLLHalftoning.cpp \ 37 | TestNLLHalftoning.h 38 | 39 | tests_LDADD = $(CUPS_LIBS) -lcppunit -ldl 40 | 41 | AM_CPPFLAGS = -I.. -I. 42 | 43 | # 44 | # End of $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 45 | # 46 | -------------------------------------------------------------------------------- /src_v2/common/tests/TestCommon.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestCommon.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include 22 | #include "TestCommon.h" 23 | 24 | ostream& 25 | operator<<(ostream& s, const buffer_t& b) 26 | { 27 | ios::fmtflags f = s.flags(ios::hex); 28 | for (buffer_t::const_iterator it = b.begin(); it < b.end(); ++it) 29 | s << int(*it) << " "; 30 | 31 | s.flags(f); 32 | 33 | return s; 34 | } 35 | 36 | /* 37 | * End of "$Id: TestCommon.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 38 | */ 39 | -------------------------------------------------------------------------------- /src_v2/common/tests/TestCommon.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestCommon.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef h0ec9edba_c55d_43ab_ba47_ad936cbb8d74 22 | #define h0ec9edba_c55d_43ab_ba47_ad936cbb8d74 23 | 24 | 25 | #include "../PrinterDriver.h" 26 | #include 27 | 28 | using namespace std; 29 | using namespace DymoPrinterDriver; 30 | 31 | ostream& 32 | operator<<(ostream& s, const buffer_t& b); 33 | 34 | #endif 35 | 36 | /* 37 | * End of "$Id: TestCommon.h 4759 2008-06-19 19:02:27Z vbuzuev $". 38 | */ 39 | -------------------------------------------------------------------------------- /src_v2/common/tests/TestErrorDiffusionHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestErrorDiffusionHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef hd5e4ea9d_d3c3_4d2e_8235_830809f13fbf 22 | #define hd5e4ea9d_d3c3_4d2e_8235_830809f13fbf 23 | 24 | #include 25 | #include "../ErrorDiffusionHalftoning.h" 26 | 27 | class ErrorDiffusionTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(ErrorDiffusionTest); 30 | 31 | CPPUNIT_TEST(testBlack); 32 | CPPUNIT_TEST(testWhite); 33 | CPPUNIT_TEST(testRed); 34 | CPPUNIT_TEST(testGreen); 35 | CPPUNIT_TEST(testBlue); 36 | 37 | 38 | CPPUNIT_TEST_SUITE_END(); 39 | 40 | public: 41 | void setUp(); 42 | void tearDown(); 43 | 44 | void testBlack(); 45 | void testWhite(); 46 | void testRed(); 47 | void testGreen(); 48 | void testBlue(); 49 | }; 50 | 51 | #endif 52 | 53 | 54 | /* 55 | * End of "$Id: TestErrorDiffusionHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $". 56 | */ 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src_v2/common/tests/TestNLLHalftoning.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestNLLHalftoning.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "TestNLLHalftoning.h" 22 | #include "TestCommon.h" 23 | #include 24 | 25 | using namespace std; 26 | using namespace DymoPrinterDriver; 27 | 28 | // Registers the fixture into the 'registry' 29 | CPPUNIT_TEST_SUITE_REGISTRATION(NonLinearLaplacianTest); 30 | 31 | void 32 | NonLinearLaplacianTest::setUp() 33 | { 34 | } 35 | 36 | 37 | void 38 | NonLinearLaplacianTest::tearDown() 39 | { 40 | } 41 | 42 | 43 | void 44 | NonLinearLaplacianTest::testBlock() 45 | { 46 | // 8x10 pixels wide, 24bits per pixel 47 | byte pInputImage[] = 48 | { 49 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 50 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 51 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 52 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 53 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 54 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 55 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 56 | 255,255,255, 255,255,255, 0,0,0, 0,0,0, 0,0,0, 255,255,255, 255,255,255, 255,255,255, 57 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 58 | 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 255,255,255, 59 | }; 60 | byte OutputData[] = 61 | { 62 | 0x00, 0, 63 | 0x38, 0, 64 | 0x38, 0, 65 | 0x38, 0, 66 | 0x38, 0, 67 | 0x38, 0, 68 | 0x38, 0, 69 | 0x38, 0, 70 | 0x00, 0, 71 | 0x00, 0, 72 | }; 73 | 74 | buffer_t OutputLine; 75 | CNLLHalftoning H(0, CHalftoneFilter::itRGB, CHalftoneFilter::itBW); 76 | 77 | CHalftoneFilter::image_buffer_t InputImage; 78 | for (size_t i = 0; i < 10; ++i) 79 | { 80 | buffer_t line(pInputImage + i * 8 * 3, pInputImage + (i + 1) * 8 * 3); 81 | InputImage.push_back(line); 82 | } 83 | 84 | CHalftoneFilter::image_buffer_t OutputImage; 85 | H.ProcessImage(InputImage, OutputImage); 86 | 87 | buffer_t Output; 88 | for (size_t i = 0; i < OutputImage.size(); ++i) 89 | Output.insert(Output.end(), OutputImage[i].begin(), OutputImage[i].end()); 90 | 91 | CPPUNIT_ASSERT_EQUAL( 92 | buffer_t(OutputData, OutputData + sizeof(OutputData)), 93 | Output); 94 | } 95 | 96 | /* 97 | * End of "$Id: TestNLLHalftoning.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 98 | */ 99 | -------------------------------------------------------------------------------- /src_v2/common/tests/TestNLLHalftoning.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestNLLHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef h93317978_9c29_4c43_9de5_263975cb8c69 22 | #define h93317978_9c29_4c43_9de5_263975cb8c69 23 | 24 | #include 25 | #include "../NonLinearLaplacianHalftoning.h" 26 | 27 | class NonLinearLaplacianTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(NonLinearLaplacianTest); 30 | 31 | CPPUNIT_TEST(testBlock); 32 | 33 | CPPUNIT_TEST_SUITE_END(); 34 | 35 | public: 36 | void setUp(); 37 | void tearDown(); 38 | 39 | void testBlock(); 40 | }; 41 | 42 | #endif 43 | 44 | 45 | /* 46 | * End of "$Id: TestNLLHalftoning.h 4759 2008-06-19 19:02:27Z vbuzuev $". 47 | */ 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src_v2/common/tests/testsMain.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: testsMain.cpp 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | int main(int argc, char* argv[]) 27 | { 28 | // Get the top level suite from the registry 29 | CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); 30 | 31 | // Adds the test to the list of test to run 32 | 33 | CPPUNIT_NS::TextUi::TestRunner runner; 34 | 35 | runner.addTest(suite); 36 | 37 | 38 | 39 | // Change the default outputter to a compiler error format outputter 40 | 41 | runner.setOutputter( 42 | new CPPUNIT_NS::CompilerOutputter( 43 | &runner.result(), 44 | std::cerr )); 45 | 46 | // Run the test. 47 | 48 | bool wasSucessful = runner.run(); 49 | 50 | 51 | 52 | // Return error code 1 if the one of test failed. 53 | 54 | return wasSucessful ? 0 : 1; 55 | 56 | } 57 | 58 | /* 59 | * End of "$Id: testsMain.cpp 4759 2008-06-19 19:02:27Z vbuzuev $". 60 | */ 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src_v2/lm/LabelManagerDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: LabelManagerDriver.h 40392 2016-03-11 14:27:15Z pineichen $ 3 | 4 | // DYMO LabelManager Driver 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef LABEL_MANAGER_DRIVER_H 22 | #define LABEL_MANAGER_DRIVER_H 23 | 24 | #include "PrinterDriver.h" 25 | #include 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | // Driver for the printers supported LabelManager command set 30 | class ILabelManagerDriver : virtual public IPrinterDriver 31 | { 32 | public: 33 | typedef enum 34 | { 35 | tw6mm = 0, 36 | tw9mm, 37 | tw12mm, 38 | tw19mm, 39 | tw24mm 40 | } tape_width_t; 41 | 42 | typedef enum 43 | { 44 | coCut = 0, 45 | coChainMarks, 46 | coDoNothing 47 | } cut_t; 48 | 49 | typedef enum 50 | { 51 | alCenter = 0, 52 | alLeft, 53 | alRight 54 | } alignment_t; 55 | 56 | virtual ~ILabelManagerDriver() {} 57 | 58 | virtual void StartDoc() = 0; 59 | virtual void EndDoc() = 0; 60 | 61 | virtual void StartPage() = 0; 62 | virtual void EndPage() = 0; 63 | 64 | virtual void ProcessRasterLine(const buffer_t& LineBuffer) = 0; 65 | 66 | protected: 67 | // helper function 68 | virtual void SetStartPrintJob(const dword dwJobID) = 0; 69 | virtual void SetEndPrintJob() = 0; 70 | virtual void SetFormFeed() = 0; 71 | virtual void SetShortFormFeed() = 0; 72 | 73 | virtual void SetCutCommand() = 0; 74 | virtual void SetCutterMark() = 0; 75 | }; 76 | 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src_v2/lm/LabelManagerDriverInitializer.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "LabelManagerDriverInitializer.h" 22 | #include "CupsUtils.h" 23 | 24 | namespace DymoPrinterDriver 25 | { 26 | 27 | void CLabelManagerDriverInitializer::ProcessCupsOptions(CLabelManagerDriverV2& Driver, int num_options, cups_option_t* options) 28 | { 29 | const char* option = CCupsUtils::GetCupsOption("DymoCutOptions", num_options, options, "Cut"); 30 | 31 | Driver.SetDeviceName(CCupsUtils::GetCupsOption("printer-make-and-model", num_options, options)); 32 | 33 | if(strcasecmp(option, "Cut") == 0) 34 | Driver.SetCutOption(ILabelManagerDriver::coCut); 35 | else if(strcasecmp(option, "ChainMarks") == 0) 36 | Driver.SetCutOption(ILabelManagerDriver::coChainMarks); 37 | else 38 | fprintf(stderr, "WARNING: Unknown DymoCutOptions option value = %s\n", option); 39 | 40 | option = CCupsUtils::GetCupsOption("DymoLabelAlignment", num_options, options, "Center"); 41 | 42 | if(strcasecmp(option, "Center") == 0) 43 | Driver.SetAlignment(ILabelManagerDriver::alCenter); 44 | else if(strcasecmp(option, "Left") == 0) 45 | Driver.SetAlignment(ILabelManagerDriver::alLeft); 46 | else if(strcasecmp(option, "Right") == 0) 47 | Driver.SetAlignment(ILabelManagerDriver::alRight); 48 | else 49 | fprintf(stderr, "WARNING: Unknown DymoLabelAlignment option value = %s\n", option); 50 | 51 | option = CCupsUtils::GetCupsOption("DymoContinuousPaper", num_options, options, "0"); 52 | 53 | if(strcasecmp(option, "0") == 0) 54 | Driver.SetPaperType(IPrinterDriver::ptRegular); 55 | else if(strcasecmp(option, "1") == 0) 56 | Driver.SetPaperType(IPrinterDriver::ptContinuous); 57 | else 58 | fprintf(stderr, "WARNING: Unknown DymoContinuousPaper option value = %s\n", option); 59 | 60 | option = CCupsUtils::GetCupsOption("DymoPrintChainMarksAtDocEnd", num_options, options, "0"); 61 | 62 | if(strcasecmp(option, "0") == 0) 63 | Driver.SetPrintChainMarksAtDocEnd(false); 64 | else if(strcasecmp(option, "1") == 0) 65 | Driver.SetPrintChainMarksAtDocEnd(true); 66 | else 67 | fprintf(stderr, "WARNING: Unknown DymoPrintChainMarksAtDocEnd option value = %s\n", option); 68 | } 69 | 70 | void CLabelManagerDriverInitializer::ProcessPageOptions(CLabelManagerDriverV2& Driver, cups_page_header2_t& PageHeader) 71 | { 72 | ILabelManagerDriver::tape_width_t TapeWidth = ILabelManagerDriver::tape_width_t(PageHeader.cupsMediaType & 0xff); 73 | 74 | fprintf(stderr, "TEST: ProcessPageOptions device name = %s\n", Driver.GetDeviceName().c_str()); 75 | 76 | if(strcasecmp(Driver.GetDeviceName().c_str(), "DYMO MobileLabeler") == 0) 77 | { 78 | if(TapeWidth == ILabelManagerDriver::tw6mm) 79 | Driver.SetTapeAlignmentOffset(1); 80 | else if (TapeWidth == ILabelManagerDriver::tw9mm) 81 | Driver.SetTapeAlignmentOffset(0); 82 | else if (TapeWidth == ILabelManagerDriver::tw12mm) 83 | Driver.SetTapeAlignmentOffset(2); //5 84 | else if (TapeWidth == ILabelManagerDriver::tw19mm) 85 | Driver.SetTapeAlignmentOffset(-1); 86 | else if (TapeWidth == ILabelManagerDriver::tw24mm) 87 | Driver.SetTapeAlignmentOffset(-1); 88 | } 89 | } 90 | 91 | void CLabelManagerDriverInitializerWithLM::ProcessCupsOptions(CLabelManagerDriverV2& Driver, CLabelManagerLanguageMonitorV2& LM, int num_options, cups_option_t* options) 92 | { 93 | CLabelManagerDriverInitializer::ProcessCupsOptions(Driver, num_options, options); 94 | 95 | LM.SetDeviceName(CCupsUtils::GetCupsOption("printer-make-and-model", num_options, options)); 96 | } 97 | 98 | void CLabelManagerDriverInitializerWithLM::ProcessPageOptions(CLabelManagerDriverV2& Driver, CLabelManagerLanguageMonitorV2& LM, cups_page_header2_t& PageHeader) 99 | { 100 | CLabelManagerDriverInitializer::ProcessPageOptions(Driver, PageHeader); 101 | 102 | LM.SetTapeWidth(ILabelManagerDriver::tape_width_t(PageHeader.cupsMediaType & 0xff)); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src_v2/lm/LabelManagerDriverInitializer.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include 22 | #include 23 | #include "LabelManagerDriverV2.h" 24 | #include "LabelManagerLanguageMonitorV2.h" 25 | #include "DummyLanguageMonitor.h" 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | 30 | class CLabelManagerDriverInitializer 31 | { 32 | public: 33 | static void ProcessCupsOptions(CLabelManagerDriverV2& Driver, int num_options, cups_option_t* options); 34 | static void ProcessPageOptions(CLabelManagerDriverV2& Driver, cups_page_header2_t& PageHeader); 35 | }; 36 | 37 | class CLabelManagerDriverInitializerWithLM 38 | { 39 | public: 40 | static void ProcessCupsOptions(CLabelManagerDriverV2& Driver, CLabelManagerLanguageMonitorV2& LM, int num_options, cups_option_t* options); 41 | static void ProcessPageOptions(CLabelManagerDriverV2& Driver, CLabelManagerLanguageMonitorV2& LM, cups_page_header2_t& PageHeader); 42 | }; 43 | 44 | } -------------------------------------------------------------------------------- /src_v2/lm/LabelManagerLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO LabelManager LanguageMonitor 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef LABEL_MANAGER_LANGUAGE_MONITOR_H 22 | #define LABEL_MANAGER_LANGUAGE_MONITOR_H 23 | 24 | #include "PrinterDriver.h" 25 | #include 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | // LanguageMonitor for the printers supported LabelManager command set 30 | class ILabelManagerLanguageMonitor: virtual public ILanguageMonitor 31 | { 32 | public: 33 | virtual ~ILabelManagerLanguageMonitor() {} 34 | 35 | virtual void StartDoc() = 0; 36 | virtual void EndDoc() = 0; 37 | 38 | virtual void StartPage() = 0; 39 | virtual void EndPage() = 0; 40 | 41 | virtual void ProcessData(const buffer_t& Data) = 0; 42 | }; 43 | 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src_v2/lm/LabelManagerLanguageMonitorV2.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO LabelManager LanguageMonitor V2 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef LABEL_MANAGER_LANGUAGE_MONITOR_V2_H 22 | #define LABEL_MANAGER_LANGUAGE_MONITOR_V2_H 23 | 24 | #include "LabelManagerDriver.h" 25 | #include "LabelManagerLanguageMonitor.h" 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | // LanguageMonitor for the printers supported LabelManager v2 command set 30 | class CLabelManagerLanguageMonitorV2 : public ILabelManagerLanguageMonitor 31 | { 32 | public: 33 | CLabelManagerLanguageMonitorV2(IPrintEnvironment& Environment); 34 | virtual ~CLabelManagerLanguageMonitorV2() {} 35 | 36 | virtual void StartDoc(); 37 | virtual void EndDoc(); 38 | 39 | virtual void StartPage(); 40 | virtual void EndPage(); 41 | 42 | virtual void ProcessData(const buffer_t& Data); 43 | 44 | void CheckStatus(); 45 | bool ReadStatus(buffer_t& status, byte lock); 46 | 47 | bool CheckBusy(buffer_t& status); 48 | bool CheckGeneralError(buffer_t& status); 49 | bool CheckCassetteError(buffer_t& status); 50 | bool CheckPaperOut(buffer_t& status); 51 | bool CheckSlotError(buffer_t& status); 52 | bool CheckHeadOverheat(buffer_t& status); 53 | bool CheckPaperSizeError(buffer_t& status); 54 | bool CheckOutOfMedia(buffer_t& status); 55 | bool CheckTimeout(time_t beginTime); 56 | bool CheckOK(buffer_t& status); 57 | 58 | void ReprintPage(); 59 | 60 | // Device Name 61 | void SetDeviceName(const std::string& value) { _deviceName = value; } 62 | const std::string& GetDeviceName() const { return _deviceName; } 63 | 64 | // Tape Width 65 | void SetTapeWidth(const ILabelManagerDriver::tape_width_t& value) { _tapeWidth = value; } 66 | const ILabelManagerDriver::tape_width_t& GetTapeWidth() const { return _tapeWidth; } 67 | 68 | private: 69 | IPrintEnvironment& _printEnvironment; 70 | int _readStatusTimeout; 71 | bool _isFirstPage; 72 | 73 | buffer_t _pageData; 74 | 75 | // device params 76 | std::string _deviceName; 77 | ILabelManagerDriver::tape_width_t _tapeWidth; 78 | 79 | int GetTapeWidthFromMediaType(dword mediaType); 80 | }; 81 | 82 | } 83 | 84 | #endif -------------------------------------------------------------------------------- /src_v2/lm/Makefile.am: -------------------------------------------------------------------------------- 1 | # DYMO LabelWriter Drivers 2 | # Copyright (C) 2008 Sanford L.P. 3 | 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | SUBDIRS = tests 19 | 20 | cupsfilter_PROGRAMS = raster2dymolm_v2 21 | 22 | raster2dymolm_v2_SOURCES = \ 23 | raster2dymolm.cpp \ 24 | LabelManagerDriver.h \ 25 | LabelManagerDriverV2.cpp \ 26 | LabelManagerDriverV2.h \ 27 | LabelManagerDriverInitializer.cpp \ 28 | LabelManagerDriverInitializer.h \ 29 | LabelManagerLanguageMonitor.h \ 30 | LabelManagerLanguageMonitorV2.cpp \ 31 | LabelManagerLanguageMonitorV2.h \ 32 | ../common/CupsPrintEnvironment.cpp \ 33 | ../common/CupsPrintEnvironment.h \ 34 | ../common/CupsFilter.h \ 35 | ../common/CupsUtils.cpp \ 36 | ../common/CupsUtils.h \ 37 | ../common/CommonTypedefs.h \ 38 | ../common/PrinterDriver.h \ 39 | ../common/Halftoning.h \ 40 | ../common/ErrorDiffusionHalftoning.h \ 41 | ../common/NonLinearLaplacianHalftoning.h \ 42 | ../common/NonLinearLaplacianHalftoning.cpp \ 43 | ../common/DummyLanguageMonitor.h 44 | 45 | raster2dymolm_v2_LDADD = $(CUPS_LIBS) 46 | 47 | AM_CPPFLAGS = -I../common -std=c++14 48 | -------------------------------------------------------------------------------- /src_v2/lm/raster2dymolm.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "LabelManagerDriverV2.h" 22 | #include "LabelManagerDriverInitializer.h" 23 | #include "LabelManagerLanguageMonitorV2.h" 24 | #include "CupsFilter.h" 25 | 26 | using namespace DymoPrinterDriver; 27 | 28 | int main(int argc, char * argv[]) 29 | { 30 | CCupsFilter Filter; 31 | 32 | return Filter.Run(argc, argv); 33 | } 34 | -------------------------------------------------------------------------------- /src_v2/lm/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 15968 2011-09-02 14:56:33Z pineichen $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | TESTS = tests 21 | 22 | check_PROGRAMS = tests 23 | 24 | tests_SOURCES = \ 25 | ../../common/tests/testsMain.cpp \ 26 | ../../common/tests/MOCK_PrintEnvironment.cpp \ 27 | ../../common/tests/MOCK_PrintEnvironment.h \ 28 | ../../common/tests/TestCommon.cpp \ 29 | ../../common/tests/TestCommon.h \ 30 | ../../common/DummyLanguageMonitor.cpp \ 31 | ../../common/DummyLanguageMonitor.h \ 32 | ../LabelManagerDriver.cpp \ 33 | ../CupsFilterLabelManager.cpp \ 34 | ../CupsFilterLabelManager.h \ 35 | ../LabelManagerLanguageMonitor.cpp \ 36 | ../LabelManagerLanguageMonitor.h \ 37 | TestLabelManagerDriver.cpp \ 38 | TestLabelManagerDriver.h \ 39 | TestLabelManagerFilter.cpp \ 40 | TestLabelManagerFilter.h 41 | 42 | tests_LDADD = $(CUPS_LIBS) -lcppunit -ldl 43 | 44 | AM_CPPFLAGS = -I../../common -I../../common/tests 45 | 46 | # 47 | # End of $Id: Makefile.am 15968 2011-09-02 14:56:33Z pineichen $ 48 | # 49 | -------------------------------------------------------------------------------- /src_v2/lm/tests/TestLabelManagerDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelManagerDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef h89cd8614_1576_42a1_a747_8ce1ccab21c3 22 | #define h89cd8614_1576_42a1_a747_8ce1ccab21c3 23 | 24 | #include 25 | #include "../LabelManagerDriver.h" 26 | 27 | class LabelManagerDriverTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(LabelManagerDriverTest); 30 | 31 | //CPPUNIT_TEST(testPrologEpilogCommand); 32 | CPPUNIT_TEST(testEmptyLines); 33 | CPPUNIT_TEST(testEmptyLinesAtEnd); 34 | CPPUNIT_TEST(testDotTab); 35 | CPPUNIT_TEST(testCutAndChainMarks); 36 | CPPUNIT_TEST(testAlignment); 37 | CPPUNIT_TEST(testMinPageLength); 38 | CPPUNIT_TEST(testReverseData); 39 | CPPUNIT_TEST(testContinuousPaper); 40 | CPPUNIT_TEST(testAutoPaper); 41 | CPPUNIT_TEST(testShiftData); 42 | CPPUNIT_TEST(testMaxPrintableWidth); 43 | CPPUNIT_TEST(testTapeAlignmentOffset); 44 | 45 | 46 | CPPUNIT_TEST_SUITE_END(); 47 | 48 | public: 49 | void setUp(); 50 | void tearDown(); 51 | 52 | //void testPrologEpilogCommand(); 53 | void testEmptyLines(); 54 | void testEmptyLinesAtEnd(); 55 | void testDotTab(); 56 | void testCutAndChainMarks(); 57 | void testAlignment(); 58 | void testMinPageLength(); 59 | void testReverseData(); 60 | void testContinuousPaper(); 61 | void testAutoPaper(); 62 | void testShiftData(); 63 | void testMaxPrintableWidth(); 64 | void testTapeAlignmentOffset(); 65 | 66 | }; 67 | 68 | #endif 69 | 70 | /* 71 | * End of "$Id: TestLabelManagerDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $". 72 | */ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src_v2/lm/tests/TestLabelManagerFilter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelManagerFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef h51475713_0568_480f_b711_ddf8f09a3e15 22 | #define h51475713_0568_480f_b711_ddf8f09a3e15 23 | 24 | #include 25 | #include "MOCK_PrintEnvironment.h" 26 | #include "../LabelManagerDriver.h" 27 | #include "DummyLanguageMonitor.h" 28 | #include 29 | 30 | class LabelManagerFilterTest: public CPPUNIT_NS::TestFixture 31 | { 32 | CPPUNIT_TEST_SUITE(LabelManagerFilterTest); 33 | 34 | CPPUNIT_TEST(testAlignment); 35 | CPPUNIT_TEST(testCutOptions); 36 | CPPUNIT_TEST(testContinuousPaper); 37 | CPPUNIT_TEST(testTapeColor); 38 | CPPUNIT_TEST(testDeviceSettings); 39 | 40 | 41 | CPPUNIT_TEST_SUITE_END(); 42 | 43 | public: 44 | LabelManagerFilterTest(); 45 | 46 | void setUp(); 47 | void tearDown(); 48 | 49 | void testAlignment(); 50 | void testCutOptions(); 51 | void testContinuousPaper(); 52 | void testTapeColor(); 53 | void testDeviceSettings(); 54 | 55 | private: 56 | typedef std::vector ppd_names_t; 57 | typedef std::vector::iterator ppd_names_it; 58 | 59 | typedef std::map ppds_t; 60 | typedef std::map::iterator ppds_it; 61 | 62 | std::vector PPDNames_; 63 | ppds_t ppds_; 64 | MockPrintEnvironment Env_; 65 | CLabelManagerDriver* Driver_; 66 | CDummyLanguageMonitor* LM_; 67 | 68 | }; 69 | 70 | #endif 71 | 72 | 73 | /* 74 | * End of "$Id: TestLabelManagerFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $". 75 | */ 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src_v2/lw/LabelWriterDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO LabelWriter Driver 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef LABEL_WRITER_DRIVER_H 22 | #define LABEL_WRITER_DRIVER_H 23 | 24 | #include "PrinterDriver.h" 25 | #include 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | // Driver for the printers supported LabelWriter command set 30 | class ILabelWriterDriver : virtual public IPrinterDriver 31 | { 32 | public: 33 | typedef enum 34 | { 35 | pdLow = 0, 36 | pdMedium, 37 | pdNormal, 38 | pdHigh 39 | } density_t; 40 | 41 | typedef enum 42 | { 43 | pqText = 0, 44 | pqBarcodeAndGraphics 45 | } quality_t; 46 | 47 | typedef enum 48 | { 49 | mtDefault = 0, 50 | mtDurable 51 | } media_type_t; 52 | 53 | typedef enum 54 | { 55 | psNormal = 0, 56 | psHigh 57 | } speed_t; 58 | 59 | virtual ~ILabelWriterDriver() {} 60 | 61 | virtual void StartDoc() = 0; 62 | virtual void EndDoc() = 0; 63 | 64 | virtual void StartPage() = 0; 65 | virtual void EndPage() = 0; 66 | 67 | virtual void ProcessRasterLine(const buffer_t& LineBuffer) = 0; 68 | 69 | protected: 70 | // helper function 71 | virtual void SetStartPrintJob(const dword dwJobID) = 0; 72 | virtual void SetEndPrintJob() = 0; 73 | virtual void SetFormFeed() = 0; 74 | virtual void SetShortFormFeed() = 0; 75 | }; 76 | 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src_v2/lw/LabelWriterDriverInitializer.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "LabelWriterDriverInitializer.h" 22 | #include "CupsUtils.h" 23 | 24 | namespace DymoPrinterDriver 25 | { 26 | 27 | bool IsLW5xxPrinter(std::string deviceName) 28 | { 29 | /* 30 | DYMO LabelWriter 550 31 | DYMO LabelWriter 550 Turbo 32 | DYMO LabelWriter 5XL 33 | DYMO LabelWriter 550 Pro 34 | DYMO LabelWriter 550 Twin Pro 35 | DYMO LabelWriter 5XL Pro 36 | */ 37 | 38 | return deviceName.rfind("DYMO LabelWriter 550", 0) == 0 || deviceName.rfind("DYMO LabelWriter 5XL", 0) == 0; 39 | } 40 | 41 | void CLabelWriterDriverInitializer::ProcessCupsOptions(CLabelWriterDriverV2& Driver, int num_options, cups_option_t* options) 42 | { 43 | const char* option = CCupsUtils::GetCupsOption("DymoPrintQuality", num_options, options, "Text"); 44 | 45 | Driver.SetDeviceName(CCupsUtils::GetCupsOption("printer-make-and-model", num_options, options)); 46 | 47 | if(strcasecmp(option, "Text") == 0) 48 | Driver.SetQuality(ILabelWriterDriver::pqText); 49 | else if(strcasecmp(option, "Graphics") == 0) 50 | Driver.SetQuality(ILabelWriterDriver::pqBarcodeAndGraphics); 51 | else 52 | fprintf(stderr, "WARNING: Unknown DymoPrintQuality option value = %s\n", option); 53 | 54 | option = CCupsUtils::GetCupsOption("DymoPrintDensity", num_options, options, "Normal"); 55 | 56 | if(strcasecmp(option, "Light") == 0) 57 | Driver.SetDensity(ILabelWriterDriver::pdLow); 58 | else if(strcasecmp(option, "Medium") == 0) 59 | Driver.SetDensity(ILabelWriterDriver::pdMedium); 60 | else if(strcasecmp(option, "Normal") == 0) 61 | Driver.SetDensity(ILabelWriterDriver::pdNormal); 62 | else if(strcasecmp(option, "Dark") == 0) 63 | Driver.SetDensity(ILabelWriterDriver::pdHigh); 64 | else 65 | fprintf(stderr, "WARNING: Unknown DymoPrintDensity option value = %s\n", option); 66 | 67 | if(IsLW5xxPrinter(Driver.GetDeviceName())) 68 | { 69 | option = CCupsUtils::GetCupsOption("DymoPrintSpeed", num_options, options, "Normal"); 70 | 71 | if(strcasecmp(option, "Normal") == 0) 72 | Driver.SetSpeed(ILabelWriterDriver::psNormal); 73 | else if(strcasecmp(option, "High") == 0) 74 | Driver.SetSpeed(ILabelWriterDriver::psHigh); 75 | else 76 | fprintf(stderr, "WARNING: Unknown DymoPrintSpeed option value = %s\n", option); 77 | 78 | Driver.SetSupportHighSpeed(true); 79 | } 80 | 81 | option = CCupsUtils::GetCupsOption("DymoMediaType", num_options, options, "Default"); 82 | 83 | if(strcasecmp(option, "Default") == 0) 84 | Driver.SetMediaType(ILabelWriterDriver::mtDefault); 85 | else if(strcasecmp(option, "Durable") == 0) 86 | Driver.SetMediaType(ILabelWriterDriver::mtDurable); 87 | else 88 | fprintf(stderr, "WARNING: Unknown DymoMediaType option value = %s\n", option); 89 | } 90 | 91 | void CLabelWriterDriverInitializer::ProcessPageOptions(CLabelWriterDriverV2& Driver, cups_page_header2_t& PageHeader) 92 | { 93 | if((PageHeader.cupsMediaType == int(IPrinterDriver::ptRegular)) || (PageHeader.cupsMediaType == int(IPrinterDriver::ptContinuous))) 94 | Driver.SetPaperType(IPrinterDriver::paper_type_t(PageHeader.cupsMediaType)); 95 | else 96 | Driver.SetPaperType(IPrinterDriver::ptRegular); 97 | } 98 | 99 | void CLabelWriterDriverInitializerWithLM::ProcessCupsOptions(CLabelWriterDriverV2& Driver, CLabelWriterLanguageMonitorV2& LM, int num_options, cups_option_t* options) 100 | { 101 | CLabelWriterDriverInitializer::ProcessCupsOptions(Driver, num_options, options); 102 | 103 | LM.SetDeviceName(CCupsUtils::GetCupsOption("printer-make-and-model", num_options, options)); 104 | } 105 | 106 | void CLabelWriterDriverInitializerWithLM::ProcessPageOptions(CLabelWriterDriverV2& Driver, CLabelWriterLanguageMonitorV2& LM, cups_page_header2_t& PageHeader) 107 | { 108 | CLabelWriterDriverInitializer::ProcessPageOptions(Driver, PageHeader); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src_v2/lw/LabelWriterDriverInitializer.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include 22 | #include 23 | #include "LabelWriterDriverV2.h" 24 | #include "LabelWriterLanguageMonitorV2.h" 25 | #include "DummyLanguageMonitor.h" 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | 30 | bool IsLW5xxPrinter(std::string deviceName); 31 | 32 | class CLabelWriterDriverInitializer 33 | { 34 | public: 35 | static void ProcessCupsOptions(CLabelWriterDriverV2& Driver, int num_options, cups_option_t* options); 36 | static void ProcessPageOptions(CLabelWriterDriverV2& Driver, cups_page_header2_t& PageHeader); 37 | }; 38 | 39 | class CLabelWriterDriverInitializerWithLM 40 | { 41 | public: 42 | static void ProcessCupsOptions(CLabelWriterDriverV2& Driver, CLabelWriterLanguageMonitorV2& LM, int num_options, cups_option_t* options); 43 | static void ProcessPageOptions(CLabelWriterDriverV2& Driver, CLabelWriterLanguageMonitorV2& LM, cups_page_header2_t& PageHeader); 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src_v2/lw/LabelWriterLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO LabelWriter LanguageMonitor 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef LABEL_WRITER_LANGUAGE_MONITOR_H 22 | #define LABEL_WRITER_LANGUAGE_MONITOR_H 23 | 24 | #include "PrinterDriver.h" 25 | #include 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | // LanguageMonitor for the printers supported LabelWriter command set 30 | class ILabelWriterLanguageMonitor: virtual public ILanguageMonitor 31 | { 32 | public: 33 | virtual ~ILabelWriterLanguageMonitor() {} 34 | 35 | virtual void StartDoc() = 0; 36 | virtual void EndDoc() = 0; 37 | 38 | virtual void StartPage() = 0; 39 | virtual void EndPage() = 0; 40 | 41 | virtual void ProcessData(const buffer_t& Data) = 0; 42 | }; 43 | 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src_v2/lw/LabelWriterLanguageMonitorV2.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO LabelWriter LanguageMonitor V2 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef LABEL_WRITER_LANGUAGE_MONITOR_V2_H 22 | #define LABEL_WRITER_LANGUAGE_MONITOR_V2_H 23 | 24 | #include "LabelWriterDriver.h" 25 | #include "LabelWriterLanguageMonitor.h" 26 | 27 | namespace DymoPrinterDriver 28 | { 29 | // LanguageMonitor for the printers supported LabelWriter v2 command set 30 | class CLabelWriterLanguageMonitorV2 : public ILabelWriterLanguageMonitor 31 | { 32 | public: 33 | typedef enum 34 | { 35 | sOK, 36 | sReprint, 37 | sError 38 | } status_t; 39 | 40 | typedef enum 41 | { 42 | lsPresent, 43 | lsAbsentOK, 44 | lsAbsentCanccel 45 | } label_status_t; 46 | 47 | typedef enum 48 | { 49 | phsOK, 50 | phsOverheated 51 | } print_head_status_t; 52 | 53 | typedef enum 54 | { 55 | phvsOK, 56 | phvsLow 57 | } print_head_voltage_status_t; 58 | 59 | CLabelWriterLanguageMonitorV2(IPrintEnvironment& Environment); 60 | virtual ~CLabelWriterLanguageMonitorV2() {} 61 | 62 | virtual void StartDoc(); 63 | virtual void EndDoc(); 64 | 65 | virtual void StartPage(); 66 | virtual void EndPage(); 67 | 68 | virtual void ProcessData(const buffer_t& Data); 69 | 70 | void CheckStatus(bool lock = false); 71 | void CheckStatusV2(); 72 | bool ReadStatus(buffer_t& status, byte lock, time_t beginTime); 73 | bool ReadStatusV2(buffer_t& status, time_t beginTime); 74 | 75 | bool CheckLock(buffer_t& status); 76 | bool CheckCancelPrinting(buffer_t& status); 77 | label_status_t CheckLabel(buffer_t& status, label_status_t prevStatus); 78 | print_head_status_t CheckPrintHead(buffer_t& status, print_head_status_t prevStatus); 79 | print_head_voltage_status_t CheckPrintHeadVoltage(buffer_t& status, print_head_voltage_status_t prevStatus); 80 | 81 | bool CheckBusy(buffer_t& status); 82 | bool CheckGeneralError(buffer_t& status); 83 | bool CheckCassetteError(buffer_t& status); 84 | bool CheckPaperOut(buffer_t& status); 85 | bool CheckHeadOverheat(buffer_t& status); 86 | bool CheckTimeout(time_t beginTime); 87 | 88 | void SendEndJob(); 89 | void SendShortFormFeed(); 90 | void ReprintPages(); 91 | 92 | // Device Name 93 | void SetDeviceName(const std::string& value) { _deviceName = value; } 94 | const std::string& GetDeviceName() const { return _deviceName; } 95 | 96 | private: 97 | IPrintEnvironment& _printEnvironment; 98 | int _readStatusTimeout; 99 | bool _isFirstPage; 100 | bool _isPendingReadStatus; 101 | 102 | buffer_t _previousPageData; 103 | buffer_t _currentPageData; 104 | 105 | // device params 106 | std::string _deviceName; 107 | }; 108 | 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /src_v2/lw/Makefile.am: -------------------------------------------------------------------------------- 1 | # DYMO LabelWriter Drivers 2 | # Copyright (C) 2008 Sanford L.P. 3 | 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either version 2 7 | # of the License, or (at your option) any later version. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | 18 | SUBDIRS = tests 19 | 20 | cupsfilter_PROGRAMS = raster2dymolw_v2 21 | 22 | raster2dymolw_v2_SOURCES = \ 23 | raster2dymolw.cpp \ 24 | LabelWriterDriver.h \ 25 | LabelWriterDriverV2.cpp \ 26 | LabelWriterDriverV2.h \ 27 | LabelWriterDriverInitializer.h \ 28 | LabelWriterDriverInitializer.cpp \ 29 | LabelWriterLanguageMonitor.h \ 30 | LabelWriterLanguageMonitorV2.cpp \ 31 | LabelWriterLanguageMonitorV2.h \ 32 | ../common/CupsPrintEnvironment.cpp \ 33 | ../common/CupsPrintEnvironment.h \ 34 | ../common/CupsFilter.h \ 35 | ../common/CupsUtils.cpp \ 36 | ../common/CupsUtils.h \ 37 | ../common/CommonTypedefs.h \ 38 | ../common/PrinterDriver.h \ 39 | ../common/Halftoning.h \ 40 | ../common/ErrorDiffusionHalftoning.h \ 41 | ../common/NonLinearLaplacianHalftoning.h \ 42 | ../common/NonLinearLaplacianHalftoning.cpp \ 43 | ../common/DummyLanguageMonitor.h 44 | 45 | raster2dymolw_v2_LDADD = $(CUPS_LIBS) 46 | 47 | AM_CPPFLAGS = -I../common -std=c++14 -------------------------------------------------------------------------------- /src_v2/lw/raster2dymolw.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id$ 3 | 4 | // DYMO Printer Drivers 5 | // Copyright (C) 2016 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include 22 | 23 | #include "LabelWriterDriverV2.h" 24 | #include "LabelWriterDriverInitializer.h" 25 | #include "LabelWriterLanguageMonitorV2.h" 26 | #include "CupsFilter.h" 27 | 28 | using namespace DymoPrinterDriver; 29 | 30 | CCupsFilter gFilter; 31 | 32 | int main(int argc, char * argv[]) 33 | { 34 | // Filters and backends may also receive SIGPIPE when an upstream or downstream filter/backend exits 35 | // with a non-zero status. Developers should generally ignore SIGPIPE 36 | signal(SIGPIPE, SIG_IGN); 37 | 38 | auto signal_handler = [](int sig_num) { 39 | // make sure to unlock synchronization mutex in case process is abnormally terminated 40 | fprintf(stderr, "Received signal %d, aborting\n", sig_num); 41 | gFilter.Abort(); 42 | }; 43 | 44 | struct sigaction sa; 45 | sa.sa_handler = signal_handler; 46 | sa.sa_flags = SA_RESTART; 47 | 48 | sigemptyset(&sa.sa_mask); 49 | sigaddset(&sa.sa_mask, SIGHUP); 50 | sigaddset(&sa.sa_mask, SIGINT); 51 | sigaddset(&sa.sa_mask, SIGQUIT); 52 | sigaddset(&sa.sa_mask, SIGILL); 53 | sigaddset(&sa.sa_mask, SIGABRT); 54 | sigaddset(&sa.sa_mask, SIGSEGV); 55 | sigaddset(&sa.sa_mask, SIGTERM); 56 | sigaddset(&sa.sa_mask, SIGTSTP); 57 | 58 | sigaction(SIGHUP, &sa, NULL); 59 | sigaction(SIGINT, &sa, NULL); 60 | sigaction(SIGQUIT, &sa, NULL); 61 | sigaction(SIGILL, &sa, NULL); 62 | sigaction(SIGABRT, &sa, NULL); 63 | sigaction(SIGSEGV, &sa, NULL); 64 | sigaction(SIGTERM, &sa, NULL); 65 | sigaction(SIGTSTP, &sa, NULL); 66 | 67 | return gFilter.Run(argc, argv); 68 | } 69 | -------------------------------------------------------------------------------- /src_v2/lw/tests/MOCK_LWLMPrintEnvironment.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_LWLMPrintEnvironment.cpp 15962 2011-09-02 14:45:00Z pineichen $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "MOCK_LWLMPrintEnvironment.h" 22 | #include "../LabelWriterDriver.h" 23 | #include 24 | 25 | static const byte TOF_BIT = 0x02; 26 | static const byte ROLL_CHANGED_BIT = 0x08; 27 | static const byte PAPER_OUT_BIT = 0x20; 28 | static const byte PAPER_FEED_BIT = 0x40; 29 | static const byte ERROR_BIT = 0x80; 30 | 31 | 32 | MockLWLMPrintEnvironment::MockLWLMPrintEnvironment(): Mode_() 33 | { 34 | Mode_.push_back(mtTOF); 35 | } 36 | 37 | void 38 | MockLWLMPrintEnvironment::WriteData(const buffer_t& Data) 39 | { 40 | // printf("MockLWLMPrintEnvironment::WriteData()"); 41 | 42 | // don't store request status requests 43 | if (Data != CLabelWriterDriver::GetRequestStatusCommand()) 44 | MockPrintEnvironment::WriteData(Data); 45 | } 46 | 47 | void 48 | MockLWLMPrintEnvironment::ReadData(buffer_t& Data) 49 | { 50 | //printf("MockLWLMPrintEnvironment::ReadData()"); 51 | 52 | Data.clear(); 53 | 54 | mode_t Mode = mtTOF; 55 | 56 | if (Mode_.size() > 1) 57 | { 58 | Mode = Mode_.back(); 59 | Mode_.pop_back(); 60 | } 61 | else 62 | Mode = Mode_.back(); 63 | 64 | switch (Mode) 65 | { 66 | case mtTOF: 67 | Data.push_back(TOF_BIT); 68 | break; 69 | case mtPaperOut: 70 | Data.push_back(ERROR_BIT | PAPER_OUT_BIT); 71 | break; 72 | case mtRollChanged: 73 | Data.push_back(TOF_BIT | ROLL_CHANGED_BIT); 74 | break; 75 | case mtNotTOF: 76 | Data.push_back(0); 77 | break; 78 | case mtFailed: 79 | break; 80 | default: 81 | assert(0); 82 | } 83 | } 84 | 85 | IPrintEnvironment::job_status_t 86 | MockLWLMPrintEnvironment::GetJobStatus() 87 | { 88 | return jsOK; 89 | } 90 | 91 | 92 | void 93 | MockLWLMPrintEnvironment::SetJobStatus(job_status_t JobStatus) 94 | { 95 | switch (JobStatus) 96 | { 97 | case jsOK: 98 | //fprintf(stderr, "INFO: continue printing.\n"); 99 | break; 100 | case jsPaperOut: 101 | //fprintf(stderr, "INFO: paper out.\n"); 102 | break; 103 | case jsError: 104 | //fprintf(stderr, "INFO: printing error.\n"); 105 | break; 106 | default: 107 | assert(0); 108 | } 109 | } 110 | 111 | 112 | void 113 | MockLWLMPrintEnvironment::SetMode(mode_t Mode) 114 | { 115 | Mode_.clear(); 116 | Mode_.push_back(Mode); 117 | } 118 | 119 | void 120 | MockLWLMPrintEnvironment::PushMode(mode_t Mode, size_t Count) 121 | { 122 | for (size_t i = 0; i < Count; ++i) 123 | Mode_.push_back(Mode); 124 | } 125 | 126 | 127 | /* 128 | * End of "$Id: MOCK_LWLMPrintEnvironment.cpp 15962 2011-09-02 14:45:00Z pineichen $". 129 | */ 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /src_v2/lw/tests/MOCK_LWLMPrintEnvironment.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: MOCK_LWLMPrintEnvironment.h 15961 2011-09-02 14:44:07Z pineichen $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef hc8e31bb3_01a5_4422_84b8_64c017e18521 22 | #define hc8e31bb3_01a5_4422_84b8_64c017e18521 23 | 24 | #include 25 | #include "../PrinterDriver.h" 26 | #include "MOCK_PrintEnvironment.h" 27 | 28 | using namespace DymoPrinterDriver; 29 | 30 | 31 | /** 32 | Special environment to enulate responces from the LabelWriter 33 | Used to test language monitor 34 | */ 35 | class MockLWLMPrintEnvironment: public MockPrintEnvironment 36 | { 37 | public: 38 | typedef enum 39 | { 40 | mtTOF, // return TOF 41 | mtPaperOut, // return paper out 42 | mtNotTOF, // not TOF but ether not ERROR 43 | mtFailed, // unable to read status 44 | mtRollChanged 45 | 46 | }mode_t; 47 | 48 | MockLWLMPrintEnvironment(); 49 | virtual ~MockLWLMPrintEnvironment() {} 50 | virtual void WriteData(const buffer_t& Data); 51 | virtual void ReadData(buffer_t& Data); 52 | virtual job_status_t GetJobStatus(); 53 | virtual void SetJobStatus(job_status_t JobStatus); 54 | 55 | ////////////////////////////////////////////////////// 56 | // functions to control what is returned by requests 57 | 58 | // return Mode alwayes 59 | void SetMode(mode_t Mode); 60 | 61 | // push mode that will be returned next call to ReadData() 62 | void PushMode(mode_t Mode, size_t Count = 1); 63 | 64 | private: 65 | std::vector Mode_; 66 | }; 67 | 68 | #endif 69 | 70 | /* 71 | * End of "$Id: MOCK_LWLMPrintEnvironment.h 15961 2011-09-02 14:44:07Z pineichen $". 72 | */ 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src_v2/lw/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 2 | 3 | # DYMO LabelWriter Drivers 4 | # Copyright (C) 2008 Sanford L.P. 5 | 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | 20 | TESTS = tests 21 | 22 | check_PROGRAMS = tests 23 | 24 | tests_SOURCES = \ 25 | ../../common/tests/testsMain.cpp \ 26 | ../../common/tests/MOCK_PrintEnvironment.cpp \ 27 | ../../common/tests/MOCK_PrintEnvironment.h \ 28 | ../../common/tests/TestCommon.cpp \ 29 | ../../common/tests/TestCommon.h \ 30 | ../../common/DummyLanguageMonitor.cpp \ 31 | ../../common/DummyLanguageMonitor.h \ 32 | ../LabelWriterLanguageMonitor.cpp \ 33 | ../LabelWriterLanguageMonitor.h \ 34 | ../LabelWriterDriver.cpp \ 35 | ../CupsFilterLabelWriter.cpp \ 36 | ../CupsFilterLabelWriter.h \ 37 | TestLabelWriterDriver.cpp \ 38 | TestLabelWriterDriver.h \ 39 | TestLabelWriterFilter.cpp \ 40 | TestLabelWriterFilter.h \ 41 | TestLabelWriterLanguageMonitor.cpp \ 42 | TestLabelWriterLanguageMonitor.h \ 43 | MOCK_LWLMPrintEnvironment.cpp \ 44 | MOCK_LWLMPrintEnvironment.h 45 | 46 | 47 | tests_LDADD = $(CUPS_LIBS) -lcppunit -ldl 48 | 49 | AM_CPPFLAGS = -I../../common -I../../common/tests 50 | 51 | # 52 | # End of $Id: Makefile.am 4759 2008-06-19 19:02:27Z vbuzuev $ 53 | # 54 | -------------------------------------------------------------------------------- /src_v2/lw/tests/TestLabelWriterDriver.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef h32c7cec0_3fa1_46d1_af3b_834205cd3ce8 22 | #define h32c7cec0_3fa1_46d1_af3b_834205cd3ce8 23 | 24 | #include 25 | #include "../LabelWriterDriver.h" 26 | 27 | class LabelWriterDriverTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(LabelWriterDriverTest); 30 | 31 | CPPUNIT_TEST(testPrologEpilogCommand); 32 | CPPUNIT_TEST(testCompression); 33 | CPPUNIT_TEST(testEmptyLines); 34 | CPPUNIT_TEST(testDotTab); 35 | CPPUNIT_TEST(testContinuousPaper); 36 | CPPUNIT_TEST(test400EndPageEndDoc); 37 | CPPUNIT_TEST(testTwinTurboRoll); 38 | 39 | 40 | CPPUNIT_TEST_SUITE_END(); 41 | 42 | public: 43 | void setUp(); 44 | void tearDown(); 45 | 46 | void testPrologEpilogCommand(); 47 | void testCompression(); 48 | void testEmptyLines(); 49 | void testDotTab(); 50 | void testContinuousPaper(); 51 | 52 | void test400EndPageEndDoc(); 53 | void testTwinTurboRoll(); 54 | 55 | }; 56 | 57 | #endif 58 | 59 | 60 | /* 61 | * End of "$Id: TestLabelWriterDriver.h 4759 2008-06-19 19:02:27Z vbuzuev $". 62 | */ 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src_v2/lw/tests/TestLabelWriterFilter.cpp: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterFilter.cpp 17858 2012-04-23 18:20:41Z pineichen $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #include "TestCommon.h" 22 | #include "TestLabelWriterFilter.h" 23 | #include "MOCK_PrintEnvironment.h" 24 | #include "../LabelWriterDriver.h" 25 | #include "../CupsFilterLabelWriter.h" 26 | 27 | #include 28 | 29 | using namespace std; 30 | using namespace DymoPrinterDriver; 31 | 32 | // Registers the fixture into the 'registry' 33 | CPPUNIT_TEST_SUITE_REGISTRATION(LabelWriterFilterTest); 34 | 35 | void 36 | LabelWriterFilterTest::setUp() 37 | { 38 | ppd_ = ppdOpenFile("../../../ppd/Linux/lwtt.ppd"); 39 | CPPUNIT_ASSERT(ppd_ != NULL); 40 | 41 | ppdMarkDefaults(ppd_); 42 | 43 | Driver_ = new CLabelWriterDriverTwinTurbo(Env_); 44 | LM_ = new CDummyLanguageMonitor(Env_); 45 | } 46 | 47 | 48 | void 49 | LabelWriterFilterTest::tearDown() 50 | { 51 | ppdClose(ppd_); 52 | delete Driver_; 53 | delete LM_; 54 | } 55 | 56 | void 57 | LabelWriterFilterTest::testDensity() 58 | { 59 | ppdMarkOption(ppd_, "DymoPrintDensity", "Light"); 60 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 61 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdLow, Driver_->GetDensity()); 62 | 63 | ppdMarkOption(ppd_, "DymoPrintDensity", "Medium"); 64 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 65 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdMedium, Driver_->GetDensity()); 66 | 67 | ppdMarkOption(ppd_, "DymoPrintDensity", "Normal"); 68 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 69 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdNormal, Driver_->GetDensity()); 70 | 71 | ppdMarkOption(ppd_, "DymoPrintDensity", "Dark"); 72 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 73 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pdHigh, Driver_->GetDensity()); 74 | } 75 | 76 | void 77 | LabelWriterFilterTest::testQuality() 78 | { 79 | ppdMarkOption(ppd_, "DymoPrintQuality", "Text"); 80 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 81 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pqText, Driver_->GetQuality()); 82 | 83 | ppdMarkOption(ppd_, "DymoPrintQuality", "Graphics"); 84 | CDriverInitializerLabelWriter::ProcessPPDOptions(*Driver_, *LM_, ppd_); 85 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriver::pqBarcodeAndGraphics, Driver_->GetQuality()); 86 | } 87 | 88 | void 89 | LabelWriterFilterTest::testRoll() 90 | { 91 | ppdMarkOption(ppd_, "InputSlot", "Auto"); 92 | CDriverInitializerLabelWriterTwinTurbo::ProcessPPDOptions(*Driver_, *LM_, ppd_); 93 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriverTwinTurbo::rtAuto, Driver_->GetRoll()); 94 | 95 | ppdMarkOption(ppd_, "InputSlot", "Left"); 96 | CDriverInitializerLabelWriterTwinTurbo::ProcessPPDOptions(*Driver_, *LM_, ppd_); 97 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriverTwinTurbo::rtLeft, Driver_->GetRoll()); 98 | 99 | ppdMarkOption(ppd_, "InputSlot", "Right"); 100 | CDriverInitializerLabelWriterTwinTurbo::ProcessPPDOptions(*Driver_, *LM_, ppd_); 101 | CPPUNIT_ASSERT_EQUAL(CLabelWriterDriverTwinTurbo::rtRight, Driver_->GetRoll()); 102 | } 103 | 104 | /* 105 | * End of "$Id: TestLabelWriterFilter.cpp 17858 2012-04-23 18:20:41Z pineichen $". 106 | */ 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src_v2/lw/tests/TestLabelWriterFilter.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef hdc29f4ef_802f_478b_97c1_e61ddf654005 22 | #define hdc29f4ef_802f_478b_97c1_e61ddf654005 23 | 24 | #include 25 | #include "MOCK_PrintEnvironment.h" 26 | #include "../LabelWriterDriver.h" 27 | #include "../DummyLanguageMonitor.h" 28 | 29 | #include 30 | 31 | class LabelWriterFilterTest: public CPPUNIT_NS::TestFixture 32 | { 33 | CPPUNIT_TEST_SUITE(LabelWriterFilterTest); 34 | 35 | CPPUNIT_TEST(testDensity); 36 | CPPUNIT_TEST(testQuality); 37 | CPPUNIT_TEST(testRoll); 38 | 39 | 40 | CPPUNIT_TEST_SUITE_END(); 41 | 42 | public: 43 | void setUp(); 44 | void tearDown(); 45 | 46 | void testDensity(); 47 | void testQuality(); 48 | void testRoll(); 49 | 50 | private: 51 | ppd_file_t* ppd_; 52 | MockPrintEnvironment Env_; 53 | CLabelWriterDriverTwinTurbo* Driver_; 54 | CDummyLanguageMonitor* LM_; 55 | 56 | }; 57 | 58 | #endif 59 | 60 | /* 61 | * End of "$Id: TestLabelWriterFilter.h 4759 2008-06-19 19:02:27Z vbuzuev $". 62 | */ 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src_v2/lw/tests/TestLabelWriterLanguageMonitor.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // $Id: TestLabelWriterLanguageMonitor.h 4759 2008-06-19 19:02:27Z vbuzuev $ 3 | 4 | // DYMO LabelWriter Drivers 5 | // Copyright (C) 2008 Sanford L.P. 6 | 7 | // This program is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU General Public License 9 | // as published by the Free Software Foundation; either version 2 10 | // of the License, or (at your option) any later version. 11 | 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | #ifndef h017d33d9_70fc_470f_a55d_19c2eb5f0263 22 | #define h017d33d9_70fc_470f_a55d_19c2eb5f0263 23 | 24 | #include 25 | #include "../LabelWriterDriver.h" 26 | 27 | class LabelWriterLMTest: public CPPUNIT_NS::TestFixture 28 | { 29 | CPPUNIT_TEST_SUITE(LabelWriterLMTest); 30 | 31 | CPPUNIT_TEST(testGoodJob); 32 | CPPUNIT_TEST(testPaperOut); 33 | CPPUNIT_TEST(testPaperOutAfterReprint); 34 | CPPUNIT_TEST(testRollSynchronize); 35 | CPPUNIT_TEST(testResetPrinter); 36 | CPPUNIT_TEST(testPollForPaperIn); 37 | CPPUNIT_TEST(testOneGoodPageOneNot); 38 | CPPUNIT_TEST(testStatusReadFailed); 39 | CPPUNIT_TEST(testContinuousPaper); 40 | CPPUNIT_TEST(testRollChangedBit); 41 | 42 | CPPUNIT_TEST_SUITE_END(); 43 | 44 | public: 45 | void setUp(); 46 | void tearDown(); 47 | 48 | // test a job when there is no any problems 49 | void testGoodJob(); 50 | void testPaperOut(); 51 | void testPaperOutAfterReprint(); // reprint a page twice 52 | void testRollSynchronize(); 53 | void testResetPrinter(); 54 | void testPollForPaperIn(); // test waiting for inserting paper 55 | void testOneGoodPageOneNot(); 56 | void testStatusReadFailed(); 57 | void testContinuousPaper(); 58 | void testRollChangedBit(); 59 | 60 | }; 61 | 62 | #endif 63 | 64 | /* 65 | * End of "$Id: TestLabelWriterLanguageMonitor.h 4759 2008-06-19 19:02:27Z vbuzuev $". 66 | */ 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | --------------------------------------------------------------------------------