#! /bin/sh
#
# Brother Print filter
# Copyright (C) 2005-2006 Brother. Industries, Ltd.

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307  USA
#

if [ "$1" = '-e' ]; then
  lpadmin -x QL-570
  rm -f /usr/share/cups/model/brql570.ppd
  rm -f /usr/lib/cups/backend/brusb_ql570
#rm -f /usr/lib/cups/backend/brserial_ql570
  rm -f /usr/lib64/cups/backend/brusb_ql570
#rm -f /usr/lib64/cups/backend/brserial_ql570
  rm -f /usr/lib64/cups/filter/
  rm -f /usr/local/Brother/PTouch/ql570/cupswrapper/brcupsconfpt1
if [  -e /etc/init.d/cups ]; then
   /etc/init.d/cups restart
elif [  -e /etc/init.d/cupsys ]; then
   /etc/init.d/cupsys restart
fi
#  /etc/init.d/cups restart
  exit 0
fi
if [ "$1" = "-r" ]; then
  lpadmin -x QL-570
if [  -e /etc/init.d/cups ]; then
   /etc/init.d/cups restart
elif [  -e /etc/init.d/cupsys ]; then
   /etc/init.d/cupsys restart
fi
#  /etc/init.d/cups restart
  exit 0
fi
if [ "$1" = "help" ] || [ "$1" = "-h" ]; then
  echo   'option -h : help'
  echo   '       -i : install'
  echo   '       -e : uninstall'
  echo   '       -r : remove printer'
  exit 0
fi
#mkdir -p /usr/local/Brother/PTouch/ql570/filter
#mkdir -p /usr/lib/cups/filter

if [ -e "/usr/local/Brother/PTouch/ql570/lpd/filterql570" ]; then
  :
else
  echo "ERROR : Brother LPD filter is not installed."
fi
#satyam comments
if [ -f /etc/debian_version ] ; then 
if [  -d /usr/share/cups/model ]; then
rm -f /usr/share/cups/model/brql570.ppd
ppd_file_name=/usr/share/cups/model/brql570.ppd
fi
if [  -d /usr/share/ppd ]; then
rm -f /usr/share/ppd/brql570.ppd
ppd_file_name1=/usr/share/ppd/brql570.ppd
fi
else 
rm -f /usr/share/cups/model/brql570.ppd
ppd_file_name=/usr/share/cups/model/brql570.ppd
ppd_file_name1=/usr/share/cups/model/brql570.ppd
fi
#satyam comments
cat <<ENDOFPPDFILE | tee $ppd_file_name >> $ppd_file_name1
*PPD-Adobe: "4.3"

*%================================================
*%	Copyright(C) 2005-2006 Brother Industries, Ltd.
*%	"Brother QL-570 CUPS"
*%================================================

*%==== General Information Keywords ========================
*FormatVersion: "4.3"
*FileVersion: "1.00"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PCFileName: "QL-570.PPD"
*Manufacturer: "Brother"
*Product: "(QL-570)"
*1284DeviceID: "MFG: Brother;MDL: QL-570"
*cupsVersion: 1.1
*cupsManualCopies: False
*cupsFilter: "application/vnd.cups-postscript 0 brlpdwrapperql570"
*cupsModelNumber: 1
*ModelName: "Brother QL-570"
*ShortNickName: "Brother QL-570"
*NickName: "Brother QL-570 CUPS v1.1"
*%APDialogExtension: "/Library/Printers/Brother/PDEs/BRPtouchQuality.plugin"
*%APPrinterIconPath: "/Library/Printers/Brother/Icons/BRPTQL.icns"
*PSVersion: "(3010.106) 3"

*%==== Basic Device Capabilities =============
*LanguageLevel: "3"
*ColorDevice: False
*DefaultColorSpace: Gray
*FileSystem: False
*Throughput: "12"
*LandscapeOrientation: Plus90
*VariablePaperSize: False
*TTRasterizer: Type42
*FreeVM: "1700000"

*%DefaultOutputOrder: Reverse

*%==== Media Selection ======================
*OpenGroup: Media

*OpenUI *PageSize/Media Size: PickOne
*OrderDependency: 11 AnySetup *PageSize
*DefaultPageSize: 29x90
*PageSize 17x54/17mm x 54mm:						"          "
*PageSize 17x87/17mm x 87mm:						"          "
*PageSize 23x23/23mm x 23mm:						"          "
*PageSize 29x90/29mm x 90mm:						"          "
*PageSize 38x90/38mm x 90mm:						"          "
*PageSize 39x48/39mm x 48mm:						"          "
*PageSize 52x29/52mm x 29mm:						"          "
*PageSize 62x29/62mm x 29mm:						"          "
*PageSize 62x100/62mm x 100mm:						"          "
*PageSize 12Dia/12mm Dia:						"          "
*PageSize 24Dia/24mm Dia:						"          "
*PageSize 58Dia/58mm Dia:						"          "
*PageSize 12X1/12mm:					"          "
*PageSize 29X1/29mm:					"          "
*PageSize 38X1/38mm:					"          "
*PageSize 50X1/50mm:					"          "
*PageSize 54X1/54mm:					"          "
*PageSize 62X1/62mm:					"          "
*PageSize 12X2/12mm x 2:				"          "
*PageSize 29X2/29mm x 2:				"          "
*PageSize 38X2/38mm x 2:				"          "
*PageSize 50X2/50mm x 2:				"          "
*PageSize 54X2/54mm x 2:				"          "
*PageSize 62X2/62mm x 2:				"          "
*PageSize 12X3/12mm x 3:				"          "
*PageSize 29X3/29mm x 3:				"          "
*PageSize 38X3/38mm x 3:				"          "
*PageSize 50X3/50mm x 3:				"          "
*PageSize 54X3/54mm x 3:				"          "
*PageSize 62X3/62mm x 3:				"          "
*PageSize 12X4/12mm x 4:				"          "
*PageSize 29X4/29mm x 4:				"          "
*PageSize 38X4/38mm x 4:				"          "
*PageSize 50X4/50mm x 4:				"          "
*PageSize 54X4/54mm x 4:				"          "
*PageSize 62X4/62mm x 4:				"          "
*CloseUI: *PageSize

*OpenUI *PageRegion: PickOne
*OrderDependency: 12 AnySetup *PageRegion
*DefaultPageRegion: 29x90
*PageRegion 17x54/17mm x 54mm:					"          "
*PageRegion 17x87/17mm x 87mm:					"          "
*PageRegion 23x23/23mm x 23mm:					"          "
*PageRegion 29x90/29mm x 90mm:					"          "
*PageRegion 38x90/38mm x 90mm:					"          "
*PageRegion 39x48/39mm x 48mm:					"          "
*PageRegion 52x29/52mm x 29mm:					"          "
*PageRegion 62x29/62mm x 29mm:					"          "
*PageRegion 62x100/62mm x 100mm:				"          "
*PageRegion 12Dia/12mm Dia:					"          "
*PageRegion 24Dia/24mm Dia:					"          "
*PageRegion 58Dia/58mm Dia:					"          "
*PageRegion 12X1/12mm:				"          "
*PageRegion 29X1/29mm:				"          "
*PageRegion 38X1/38mm:				"          "
*PageRegion 50X1/50mm:				"          "
*PageRegion 54X1/54mm:				"          "
*PageRegion 62X1/62mm:				"          "
*PageRegion 12X2/12mm x 2:				"          "
*PageRegion 29X2/29mm x 2:				"          "
*PageRegion 38X2/38mm x 2:				"          "
*PageRegion 50X2/50mm x 2:				"          "
*PageRegion 54X2/54mm x 2:				"          "
*PageRegion 62X2/62mm x 2:				"          "
*PageRegion 12X3/12mm x 3:				"          "
*PageRegion 29X3/29mm x 3:				"          "
*PageRegion 38X3/38mm x 3:				"          "
*PageRegion 50X3/50mm x 3:				"          "
*PageRegion 54X3/54mm x 3:				"          "
*PageRegion 62X3/62mm x 3:				"          "
*PageRegion 12X4/12mm x 4:				"          "
*PageRegion 29X4/29mm x 4:				"          "
*PageRegion 38X4/38mm x 4:				"          "
*PageRegion 50X4/50mm x 4:				"          "
*PageRegion 54X4/54mm x 4:				"          "
*PageRegion 62X4/62mm x 4:				"          "
*CloseUI: *PageRegion

*DefaultImageableArea: 29x90
*ImageableArea 17x54/17mm x 54mm:					"4.32 8.4 43.92 144.24"
*ImageableArea 17x87/17mm x 87mm:					"4.32 8.4 43.92 237.84"
*ImageableArea 23x23/23mm x 23mm:					"4.32 8.4 60.96 56.88"
*ImageableArea 29x90/29mm x 90mm:					"4.32 8.4 77.76 246.24"
*ImageableArea 38x90/38mm x 90mm:					"4.32 8.4 103.44 246.24"
*ImageableArea 39x48/39mm x 48mm:                  			"4.32 8.4 106.32 127.20"
*ImageableArea 52x29/52mm x 29mm:					"4.32 8.4 143.04 73.44"
*ImageableArea 62x29/62mm x 29mm:					"4.32 8.4 171.36 73.44"
*ImageableArea 62x100/62mm x 100mm:					"4.32 8.4 171.36 274.56"
*ImageableArea 12Dia/12mm Dia:						"5.76 5.76 28.32 28.32"
*ImageableArea 24Dia/24mm Dia:						"5.76 5.76 62.4 62.4"
*ImageableArea 58Dia/58mm Dia:						"8.4  8.4 156.72 156.72"
*ImageableArea 12X1/12mm:				"4.32 8.4 29.76 275.06"
*ImageableArea 29X1/29mm:				"4.32 8.4 77.76 275.06"
*ImageableArea 38X1/38mm:				"4.32 8.4 103.44 275.04"
*ImageableArea 50X1/50mm:				"4.32 8.4 137.28 274.8"
*ImageableArea 54X1/54mm:				"5.76 8.4 147.36 275.04"
*ImageableArea 62X1/62mm:				"4.32 8.4 171.36 274.06"
*ImageableArea 12X2/12mm x 2:				"4.32 8.4 55.20 275.06"
*ImageableArea 29X2/29mm x 2:				"4.32 8.4 151.20 275.06"
*ImageableArea 38X2/38mm x 2:				"4.32 8.4 202.56 275.04"
*ImageableArea 50X2/50mm x 2:				"4.32 8.4 270.24 274.8"
*ImageableArea 54X2/54mm x 2:				"5.76 8.4 288.96 275.04"
*ImageableArea 62X2/62mm x 2:				"4.32 8.4 338.40 275.06"
*ImageableArea 12X3/12mm x 3:				"4.32 8.4 80.64 275.06"
*ImageableArea 29X3/29mm x 3:				"4.32 8.4 224.64 275.06"
*ImageableArea 38X3/38mm x 3:				"4.32 8.4 301.68 275.04"
*ImageableArea 50X3/50mm x 3:				"4.32 8.4 403.2 274.8"
*ImageableArea 54X3/54mm x 3:				"5.76 8.4 430.56 275.04"
*ImageableArea 62X3/62mm x 3:				"4.32 8.4 505.44 275.06"
*ImageableArea 12X4/12mm x 4:				"4.32 8.4 106.80 275.06"
*ImageableArea 29X4/29mm x 4:				"4.32 8.4 298.08 275.06"
*ImageableArea 38X4/38mm x 4:				"4.32 8.4 400.80 275.04"
*ImageableArea 50X4/50mm x 4:				"4.32 8.4 536.16 274.8"
*ImageableArea 54X4/54mm x 4:				"5.76 8.4 572.16 275.04"
*ImageableArea 62X4/62mm x 4:				"4.32 8.4 672.48 275.06"

*%==== Information About Media Sizes ========
*DefaultPaperDimension: 29x90
*PaperDimension 17x54/17mm x 54mm:					"48.24 152.64"
*PaperDimension 17x87/17mm x 87mm:					"48.24 246.24"
*PaperDimension 23x23/23mm x 23mm:					"65.28   65.28"
*PaperDimension 29x90/29mm x 90mm:					"82.08 254.64"
*PaperDimension 38x90/38mm x 90mm:					"107.76 254.64"
*PaperDimension 39x48/39mm x 48mm:                			"110.64 135.60"
*PaperDimension 52x29/52mm x 29mm:					"147.36 81.84"
*PaperDimension 62x29/62mm x 29mm:					"175.68 81.84"
*PaperDimension 62x100/62mm x 100mm:					"175.68 282.96"
*PaperDimension 12Dia/12mm Dia:						"34.08 34.08"
*PaperDimension 24Dia/24mm Dia:						"68.16 68.16"
*PaperDimension 58Dia/58mm Dia:						"165.12 165.12"
*PaperDimension 12X1/12mm:		"34.08 283.46"
*PaperDimension 29X1/29mm:		"82.08 283.46"
*PaperDimension 38X1/38mm:		"107.76 283.44"
*PaperDimension 50X1/50mm:		"141.6 283.44"
*PaperDimension 54X1/54mm:		"153.12 283.44"
*PaperDimension 62X1/62mm:		"175.68 282.46"
*PaperDimension 12X2/12mm x 2:		"59.52 283.46"
*PaperDimension 29X2/29mm x 2:		"155.52 283.46"
*PaperDimension 38X2/38mm x 2:		"206.88 283.44"
*PaperDimension 50X2/50mm x 2:		"274.56 283.44"
*PaperDimension 54X2/54mm x 2:		"294.72 283.44"
*PaperDimension 62X2/62mm x 2:		"342.72 283.46"
*PaperDimension 12X3/12mm x 3:		"84.96 283.46"
*PaperDimension 29X3/29mm x 3:		"228.96 283.46"
*PaperDimension 38X3/38mm x 3:		"306.00 283.44"
*PaperDimension 50X3/50mm x 3:		"407.52 283.44"
*PaperDimension 54X3/54mm x 3:		"436.32 283.44"
*PaperDimension 62X3/62mm x 3:		"509.76 283.46"
*PaperDimension 12X4/12mm x 4:		"110.40 283.46"
*PaperDimension 29X4/29mm x 4:		"302.40 283.46"
*PaperDimension 38X4/38mm x 4:		"405.12 283.44"
*PaperDimension 50X4/50mm x 4:		"540.48 283.44"
*PaperDimension 54X4/54mm x 4:		"577.92 283.44"
*PaperDimension 62X4/62mm x 4:		"676.80 283.46"


*OpenUI *BrMargin/Feed(invalid for Die-Cut tape): PickOne
*OrderDependency: 23 AnySetup  *BrMargin
*DefaultBrMargin: 3
*BrMargin 3/3 mm: ""
*BrMargin 4/4 mm: ""
*BrMargin 5/5 mm: ""
*BrMargin 6/6 mm: ""
*BrMargin 7/7 mm: ""
*BrMargin 8/8 mm: ""
*BrMargin 9/9 mm: ""
*BrMargin 10/10 mm: ""
*BrMargin 11/11 mm: ""
*BrMargin 12/12 mm: ""
*BrMargin 13/13 mm: ""
*BrMargin 14/14 mm: ""
*BrMargin 15/15 mm: ""
*BrMargin 16/16 mm: ""
*BrMargin 17/17 mm: ""
*BrMargin 18/18 mm: ""
*BrMargin 19/19 mm: ""
*BrMargin 20/20 mm: ""
*BrMargin 21/21 mm: ""
*BrMargin 22/22 mm: ""
*BrMargin 23/23 mm: ""
*BrMargin 24/24 mm: ""
*BrMargin 25/25 mm: ""
*BrMargin 26/26 mm: ""
*BrMargin 27/27 mm: ""
*BrMargin 28/28 mm: ""
*BrMargin 29/29 mm: ""
*BrMargin 30/30 mm: ""
*CloseUI: *BrMargin

*CloseGroup: Media

*%satyam added for QL570
*OpenUI *BrCutLabel/Cut every: PickOne
*OrderDependency: 23 AnySetup  *BrCutLabel
*DefaultBrCutLabel: 1
*BrCutLabel 0/OFF: ""
*BrCutLabel 1/1 label: ""
*BrCutLabel 2/2 labels: ""
*BrCutLabel 3/3 labels: ""
*BrCutLabel 4/4 labels: ""
*BrCutLabel 5/5 labels: ""
*BrCutLabel 6/6 labels: ""
*BrCutLabel 7/7 labels: ""
*BrCutLabel 8/8 labels: ""
*BrCutLabel 9/9 labels: ""
*BrCutLabel 10/10 labels: ""
*BrCutLabel 11/11 labels: ""
*BrCutLabel 12/12 labels: ""
*BrCutLabel 13/13 labels: ""
*BrCutLabel 14/14 labels: ""
*BrCutLabel 15/15 labels: ""
*BrCutLabel 16/16 labels: ""
*BrCutLabel 17/17 labels: ""
*BrCutLabel 18/18 labels: ""
*BrCutLabel 19/19 labels: ""
*BrCutLabel 20/20 labels: ""
*BrCutLabel 21/21 labels: ""
*BrCutLabel 22/22 labels: ""
*BrCutLabel 23/23 labels: ""
*BrCutLabel 24/24 labels: ""
*BrCutLabel 25/25 labels: ""
*BrCutLabel 26/26 labels: ""
*BrCutLabel 27/27 labels: ""
*BrCutLabel 28/28 labels: ""
*BrCutLabel 29/29 labels: ""
*BrCutLabel 30/30 labels: ""
*CloseUI: *BrCutLabel



*% Satyam added cut at end for QL570
*OpenUI *BrCutAtEnd/Cut at end: PickOne
*OrderDependency: 21 AnySetup  *BrCutAtEnd
*DefaultBrCutAtEnd: ON
*BrCutAtEnd OFF/OFF: ""
*BrCutAtEnd ON/ON: ""
*CloseUI: *BrCutAtEnd

*OpenUI *BrMirror/Mirror Printing: PickOne
*OrderDependency: 21 AnySetup  *BrMirror
*DefaultBrMirror: OFF
*BrMirror OFF/OFF: ""
*BrMirror ON/ON: ""
*CloseUI: *BrMirror


*OpenUI *BrPriority/Quality: PickOne
*OrderDependency: 22 AnySetup  *BrPriority
*DefaultBrPriority: BrSpeed
*BrPriority BrSpeed/Give priority to print speed: ""
*BrPriority BrQuality/Give priority to print quality: ""
*CloseUI: *BrPriority



*%==== Custom Page Sizes ====================
*%NonUIOrderDependency: 40 AnySetup *CustomPageSize
*%VariablePaperSize: True
*%LeadingEdge Short: ""
*%DefaultLeadingEdge: Short
*%MaxMediaWidth: "612"
*%MaxMediaHeight: "1008"
*%HWMargins: 12 12 12 12
*%CustomPageSize True: "
*%	<</BRCustomPageSize true>> setpagedevice
*%	pop pop pop
*%	<< /PageSize [ 5 -2 roll ] /ImagingBBox null >>
*%	setpagedevice
*%"
*%End
*%ParamCustomPageSize Width: 1 points 284 612
*%ParamCustomPageSize Height: 2 points 595 1008
*%ParamCustomPageSize WidthOffset: 3 points 0 0
*%ParamCustomPageSize HeightOffset: 4 points 0 0
*%ParamCustomPageSize Orientation: 5 int 0 3

*%=== Paper Feed================================
*%OpenUI *InputSlot: PickOne
*%OrderDependency: 13 AnySetup *InputSlot
*%DefaultInputSlot: AutoSelect
*%InputSlot AutoSelect/Auto Select: 	"          "
*%InputSlot Tray1/Tray1: 		"          "
*%InputSlot Manual/Manual: 		"          "
*%CloseUI: *InputSlot

*%==== Resolution Features =================================
*OpenUI *Resolution/Resolution: PickOne
*OrderDependency: 14 AnySetup *Resolution
*DefaultResolution: Normal
*Resolution	Normal/Normal(300 * 300dpi): 	"          "
*CloseUI: *Resolution

*%=== Media Type ================================
*%OpenUI *MediaType/Media Type: PickOne
*%OrderDependency: 17 AnySetup *MediaType
*%DefaultMediaType: Plain
*%MediaType Plain/Plain Paper: "          "
*%MediaType Thin/Thin Paper: "          "
*%MediaType Thick/Thick Paper: "          "
*%MediaType Thicker/Thicker Paper: "          "
*%MediaType Transparencies/Transparencies: "          "
*%MediaType Recycled/Recycled Paper: "          "
*%CloseUI: *MediaType

*%#S1


*OpenUI *BrHalftonePattern/Halftone: PickOne
*OrderDependency: 24 AnySetup  *BrHalftonePattern
*DefaultBrHalftonePattern: BrErrorDiffusion
*BrHalftonePattern BrBinary/Binary: ""
*BrHalftonePattern BrDither/Dither: ""
*BrHalftonePattern BrErrorDiffusion/Error Diffusion: ""
*CloseUI: *BrHalftonePattern

*OpenUI *BrBrightness/Brightness: PickOne
*OrderDependency: 25 AnySetup  *BrBrightness
*DefaultBrBrightness: 0
*BrBrightness 50/50: ""
*BrBrightness 49/49: ""
*BrBrightness 48/48: ""
*BrBrightness 47/47: ""
*BrBrightness 46/46: ""
*BrBrightness 45/45: ""
*BrBrightness 44/44: ""
*BrBrightness 43/43: ""
*BrBrightness 42/42: ""
*BrBrightness 41/41: ""
*BrBrightness 40/40: ""
*BrBrightness 39/39: ""
*BrBrightness 38/38: ""
*BrBrightness 37/37: ""
*BrBrightness 36/36: ""
*BrBrightness 35/35: ""
*BrBrightness 34/34: ""
*BrBrightness 33/33: ""
*BrBrightness 32/32: ""
*BrBrightness 31/31: ""
*BrBrightness 30/30: ""
*BrBrightness 29/29: ""
*BrBrightness 28/28: ""
*BrBrightness 27/27: ""
*BrBrightness 26/26: ""
*BrBrightness 25/25: ""
*BrBrightness 24/24: ""
*BrBrightness 23/23: ""
*BrBrightness 22/22: ""
*BrBrightness 21/21: ""
*BrBrightness 20/20: ""
*BrBrightness 19/19: ""
*BrBrightness 18/18: ""
*BrBrightness 17/17: ""
*BrBrightness 16/16: ""
*BrBrightness 15/15: ""
*BrBrightness 14/14: ""
*BrBrightness 13/13: ""
*BrBrightness 12/12: ""
*BrBrightness 11/11: ""
*BrBrightness 10/10: ""
*BrBrightness 9/9: ""
*BrBrightness 8/8: ""
*BrBrightness 7/7: ""
*BrBrightness 6/6: ""
*BrBrightness 5/5: ""
*BrBrightness 4/4: ""
*BrBrightness 3/3: ""
*BrBrightness 2/2: ""
*BrBrightness 1/1: ""
*BrBrightness 0/0: ""
*BrBrightness -1/-1: ""
*BrBrightness -2/-2: ""
*BrBrightness -3/-3: ""
*BrBrightness -4/-4: ""
*BrBrightness -5/-5: ""
*BrBrightness -6/-6: ""
*BrBrightness -7/-7: ""
*BrBrightness -8/-8: ""
*BrBrightness -9/-9: ""
*BrBrightness -10/-10: ""
*BrBrightness -11/-11: ""
*BrBrightness -12/-12: ""
*BrBrightness -13/-13: ""
*BrBrightness -14/-14: ""
*BrBrightness -15/-15: ""
*BrBrightness -16/-16: ""
*BrBrightness -17/-17: ""
*BrBrightness -18/-18: ""
*BrBrightness -19/-19: ""
*BrBrightness -20/-20: ""
*BrBrightness -21/-21: ""
*BrBrightness -22/-22: ""
*BrBrightness -23/-23: ""
*BrBrightness -24/-24: ""
*BrBrightness -25/-25: ""
*BrBrightness -26/-26: ""
*BrBrightness -27/-27: ""
*BrBrightness -28/-28: ""
*BrBrightness -29/-29: ""
*BrBrightness -30/-30: ""
*BrBrightness -31/-31: ""
*BrBrightness -32/-32: ""
*BrBrightness -33/-33: ""
*BrBrightness -34/-34: ""
*BrBrightness -35/-35: ""
*BrBrightness -36/-36: ""
*BrBrightness -37/-37: ""
*BrBrightness -38/-38: ""
*BrBrightness -39/-39: ""
*BrBrightness -40/-40: ""
*BrBrightness -41/-41: ""
*BrBrightness -42/-42: ""
*BrBrightness -43/-43: ""
*BrBrightness -44/-44: ""
*BrBrightness -45/-45: ""
*BrBrightness -46/-46: ""
*BrBrightness -47/-47: ""
*BrBrightness -48/-48: ""
*BrBrightness -49/-49: ""
*BrBrightness -50/-50: ""
*CloseUI: *BrBrightness

*OpenUI *BrContrast/Contrast: PickOne
*OrderDependency: 26 AnySetup  *BrContrast
*DefaultBrContrast: 0
*BrContrast 50/50: ""
*BrContrast 49/49: ""
*BrContrast 48/48: ""
*BrContrast 47/47: ""
*BrContrast 46/46: ""
*BrContrast 45/45: ""
*BrContrast 44/44: ""
*BrContrast 43/43: ""
*BrContrast 42/42: ""
*BrContrast 41/41: ""
*BrContrast 40/40: ""
*BrContrast 39/39: ""
*BrContrast 38/38: ""
*BrContrast 37/37: ""
*BrContrast 36/36: ""
*BrContrast 35/35: ""
*BrContrast 34/34: ""
*BrContrast 33/33: ""
*BrContrast 32/32: ""
*BrContrast 31/31: ""
*BrContrast 30/30: ""
*BrContrast 29/29: ""
*BrContrast 28/28: ""
*BrContrast 27/27: ""
*BrContrast 26/26: ""
*BrContrast 25/25: ""
*BrContrast 24/24: ""
*BrContrast 23/23: ""
*BrContrast 22/22: ""
*BrContrast 21/21: ""
*BrContrast 20/20: ""
*BrContrast 19/19: ""
*BrContrast 18/18: ""
*BrContrast 17/17: ""
*BrContrast 16/16: ""
*BrContrast 15/15: ""
*BrContrast 14/14: ""
*BrContrast 13/13: ""
*BrContrast 12/12: ""
*BrContrast 11/11: ""
*BrContrast 10/10: ""
*BrContrast 9/9: ""
*BrContrast 8/8: ""
*BrContrast 7/7: ""
*BrContrast 6/6: ""
*BrContrast 5/5: ""
*BrContrast 4/4: ""
*BrContrast 3/3: ""
*BrContrast 2/2: ""
*BrContrast 1/1: ""
*BrContrast 0/0: ""
*BrContrast -1/-1: ""
*BrContrast -2/-2: ""
*BrContrast -3/-3: ""
*BrContrast -4/-4: ""
*BrContrast -5/-5: ""
*BrContrast -6/-6: ""
*BrContrast -7/-7: ""
*BrContrast -8/-8: ""
*BrContrast -9/-9: ""
*BrContrast -10/-10: ""
*BrContrast -11/-11: ""
*BrContrast -12/-12: ""
*BrContrast -13/-13: ""
*BrContrast -14/-14: ""
*BrContrast -15/-15: ""
*BrContrast -16/-16: ""
*BrContrast -17/-17: ""
*BrContrast -18/-18: ""
*BrContrast -19/-19: ""
*BrContrast -20/-20: ""
*BrContrast -21/-21: ""
*BrContrast -22/-22: ""
*BrContrast -23/-23: ""
*BrContrast -24/-24: ""
*BrContrast -25/-25: ""
*BrContrast -26/-26: ""
*BrContrast -27/-27: ""
*BrContrast -28/-28: ""
*BrContrast -29/-29: ""
*BrContrast -30/-30: ""
*BrContrast -31/-31: ""
*BrContrast -32/-32: ""
*BrContrast -33/-33: ""
*BrContrast -34/-34: ""
*BrContrast -35/-35: ""
*BrContrast -36/-36: ""
*BrContrast -37/-37: ""
*BrContrast -38/-38: ""
*BrContrast -39/-39: ""
*BrContrast -40/-40: ""
*BrContrast -41/-41: ""
*BrContrast -42/-42: ""
*BrContrast -43/-43: ""
*BrContrast -44/-44: ""
*BrContrast -45/-45: ""
*BrContrast -46/-46: ""
*BrContrast -47/-47: ""
*BrContrast -48/-48: ""
*BrContrast -49/-49: ""
*BrContrast -50/-50: ""
*CloseUI: *BrContrast


*DefaultFont: Courier
*Font AvantGarde-Book: Standard "(001.006S)" Standard ROM
*Font AvantGarde-BookOblique: Standard "(001.006S)" Standard ROM
*Font AvantGarde-Demi: Standard "(001.007S)" Standard ROM
*Font AvantGarde-DemiOblique: Standard "(001.007S)" Standard ROM
*Font Bookman-Demi: Standard "(001.004S)" Standard ROM
*Font Bookman-DemiItalic: Standard "(001.004S)" Standard ROM
*Font Bookman-Light: Standard "(001.004S)" Standard ROM
*Font Bookman-LightItalic: Standard "(001.004S)" Standard ROM
*Font Courier: Standard "(002.004S)" Standard ROM
*Font Courier-Bold: Standard "(002.004S)" Standard ROM
*Font Courier-BoldOblique: Standard "(002.004S)" Standard ROM
*Font Courier-Oblique: Standard "(002.004S)" Standard ROM
*Font Helvetica: Standard "(001.006S)" Standard ROM
*Font Helvetica-Bold: Standard "(001.007S)" Standard ROM
*Font Helvetica-BoldOblique: Standard "(001.007S)" Standard ROM
*Font Helvetica-Narrow: Standard "(001.006S)" Standard ROM
*Font Helvetica-Narrow-Bold: Standard "(001.007S)" Standard ROM
*Font Helvetica-Narrow-BoldOblique: Standard "(001.007S)" Standard ROM
*Font Helvetica-Narrow-Oblique: Standard "(001.006S)" Standard ROM
*Font Helvetica-Oblique: Standard "(001.006S)" Standard ROM
*Font NewCenturySchlbk-Bold: Standard "(001.009S)" Standard ROM
*Font NewCenturySchlbk-BoldItalic: Standard "(001.007S)" Standard ROM
*Font NewCenturySchlbk-Italic: Standard "(001.006S)" Standard ROM
*Font NewCenturySchlbk-Roman: Standard "(001.007S)" Standard ROM
*Font Palatino-Bold: Standard "(001.005S)" Standard ROM
*Font Palatino-BoldItalic: Standard "(001.005S)" Standard ROM
*Font Palatino-Italic: Standard "(001.005S)" Standard ROM
*Font Palatino-Roman: Standard "(001.005S)" Standard ROM
*Font Times-Bold: Standard "(001.007S)" Standard ROM
*Font Times-BoldItalic: Standard "(001.009S)" Standard ROM
*Font Times-Italic: Standard "(001.007S)" Standard ROM
*Font Times-Roman: Standard "(001.007S)" Standard ROM
*Font ZapfChancery-MediumItalic: Standard "(001.007S)" Standard ROM
*Font ZapfDingbats: Special "(001.004S)" Special ROM
*Font Symbol: Special "(001.007S)" Special ROM
*Font Alaska: Standard "(001.005)" Standard ROM
*Font AlaskaExtrabold: Standard "(001.005)" Standard ROM
*Font AntiqueOakland: Standard "(001.005)" Standard ROM
*Font AntiqueOakland-Bold: Standard "(001.005)" Standard ROM
*Font AntiqueOakland-Oblique: Standard "(001.005)" Standard ROM
*Font ClevelandCondensed: Standard "(001.005)" Standard ROM
*Font Connecticut: Standard "(001.005)" Standard ROM
*Font Guatemala-Antique: Standard "(001.005)" Standard ROM
*Font Guatemala-Bold: Standard "(001.005)" Standard ROM
*Font Guatemala-Italic: Standard "(001.005)" Standard ROM
*Font Guatemala-BoldItalic: Standard "(001.005)" Standard ROM

*Font LetterGothic: Standard "(001.005)" Standard ROM
*Font LetterGothic-Bold: Standard "(001.005)" Standard ROM
*Font LetterGothic-Oblique: Standard "(001.005)" Standard ROM
*Font Maryland: Standard "(001.005)" Standard ROM
*Font Oklahoma: Standard "(001.005)" Standard ROM
*Font Oklahoma-Bold: Standard "(001.005)" Standard ROM
*Font Oklahoma-Oblique: Standard "(001.005)" Standard ROM
*Font Oklahoma-BoldOblique: Standard "(001.005)" Standard ROM
*Font Utah: Standard "(001.005)" Standard ROM
*Font Utah-Bold: Standard "(001.005)" Standard ROM
*Font Utah-Oblique: Standard "(001.005)" Standard ROM
*Font Utah-BoldOblique: Standard "(001.005)" Standard ROM
*Font UtahCondensed: Standard "(001.005)" Standard ROM
*Font UtahCondensed-Bold: Standard "(001.005)" Standard ROM
*Font UtahCondensed-Oblique: Standard "(001.004)" Standard ROM
*Font UtahCondensed-BoldOblique: Standard "(001.005)" Standard ROM
*Font BermudaScript: Standard "(001.005)" Standard ROM
*Font Germany: Standard "(001.005)" Standard ROM
*Font SanDiego: Standard "(001.005)" Standard ROM
*Font US-Roman: Standard "(001.005)" Standard ROM


ENDOFPPDFILE

brotherlpdwrapper=/usr/lib/cups/filter/brlpdwrapperql570
brotherlpdwrapper64=/usr/lib64/cups/filter/brlpdwrapperql570
#brotherlpdwrapper=/usr/lib/cups/backend/brusb_ql570
#brotherlpdwrapper64=/usr/lib64/cups/backend/brusb_ql570

rm -f  $brotherlpdwrapper
#echo 'rm -f /usr/lib/cups/filter/brlpdwrapperql570'


cat <<!ENDOFWFILTER! >$brotherlpdwrapper
#! /bin/sh
#
# Brother Print filter  >>  /usr/lib/cups/backend/brusb_ql570
# Copyright (C) 2006 Brother. Industries, Ltd.
#                                    Ver1.10

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307  USA
#

LOGFILE="/dev/null"
LOGLEVEL="1"
LOGCLEVEL="7"
DEBUG=0
NUPENABLE=1
LOG_LATESTONLY=1
errorcode=0

if [ \$DEBUG != 0 ]; then
    LOGFILE=/tmp/br_cupsfilter_debug_log
fi

PPDC=\`printenv | grep "PPD="\`
PPDC=\`echo \$PPDC | sed -e 's/PPD=//'\`

if [ "\$PPDC" = "" ]; then
    PPDC="/usr/share/cups/model/brql570.ppd"
fi


if [ \$LOGFILE != "/dev/null" ]; then
  if [ \$LOG_LATESTONLY == "1" ]; then
    rm -f \$LOGFILE
    date                                                           >\$LOGFILE
  else
    if [ -e \$LOGFILE ]; then
	    date                                                        >>\$LOGFILE
    else
	    date                                                        >\$LOGFILE
    fi
  fi
    echo "arg0 = \$0"                                           >>\$LOGFILE
    echo "arg1 = \$1"                                           >>\$LOGFILE
    echo "arg2 = \$2"                                           >>\$LOGFILE
    echo "arg3 = \$3"                                           >>\$LOGFILE
    echo "arg4 = \$4"                                           >>\$LOGFILE
    echo "arg5 = \$5"                                           >>\$LOGFILE
    echo "arg6 = \$6"                                           >>\$LOGFILE
    echo "PPD  = \$PPD"                                         >>\$LOGFILE
fi

INPUT_TEMP_PS=\`mktemp /tmp/br_input_ps.XXXXXX\`

nup="cat"
if [ "`echo \$5 | grep 'Nup='`" != '' ] && [ \$NUPENABLE != 0 ]; then

	if   [ "`echo \$5 | grep 'Nup=64'`" != '' ]; then
		nup="psnup -64"
	elif [ "`echo \$5 | grep 'Nup=32'`" != '' ]; then
		nup="psnup -32"
	elif [ "`echo \$5 | grep 'Nup=25'`" != '' ]; then
		nup="psnup -25"
	elif [ "`echo \$5 | grep 'Nup=16'`" != '' ]; then
		nup="psnup -16"
	elif [ "`echo \$5 | grep 'Nup=8'`" != '' ]; then
		nup="psnup -8"
	elif [ "`echo \$5 | grep 'Nup=6'`" != '' ]; then
		nup="psnup -6"
	elif [ "`echo \$5 | grep 'Nup=4'`" != '' ]; then
		nup="psnup -4"
	elif [ "`echo \$5 | grep 'Nup=2'`" != '' ]; then
		nup="psnup -2"
	elif [ "`echo \$5 | grep 'Nup=1'`" != '' ]; then
		nup="cat"
	fi
	echo   "NUP=\$nup"                                      >>\$LOGFILE
   if [ -e /usr/bin/psnup ]; then
       if [ \$# -ge 7 ]; then
	       cat \$6  | \$nup > \$INPUT_TEMP_PS
       else
	       cat       | \$nup > \$INPUT_TEMP_PS
       fi
   else
       if [ \$# -ge 7 ]; then
	       cp \$6  \$INPUT_TEMP_PS
       else
	       cat    > \$INPUT_TEMP_PS
       fi
   fi
else
   if [ \$# -ge 7 ]; then
      cp \$6  \$INPUT_TEMP_PS
   else
      cat    > \$INPUT_TEMP_PS
   fi
fi
if [ -e "/usr/local/Brother/PTouch/ql570/lpd/filterql570" ]; then
       :
else
    echo "ERROR: /usr/local/Brother/PTouch/ql570/lpd/filterql570 does not exist"   >>\$LOGFILE
    errorcode=30
    exit
fi

CUPSOPTION=\`echo "\$5 Copies=\$4" | sed -e 's/PageSize/media/' -e 's/BrMargin/Feed/' -e 's/BrCutAtEnd/CutAtEnd/' -e 's/BrCutLabel/CutLabel/' -e 's/BrMirror/MirrorPrint/' -e 's/BrPriority/Priority/' -e 's/BrQuality/QUALITY/' -e 's/BrSpeed/SPEED/' -e 's/BrHalftonePattern/Halftone/' -e 's/BrErrorDiffusion/ERROR/' -e 's/BrBinary/BINARY/' -e 's/BrDither/DITHER/' -e 's/BrBrightness/Brightness/' -e 's/BrContrast/Contrast/' -e 's/multiple-document-handling/Collate/' -e 's/separate-documents-collated-copies/ON/' -e 's/separate-documents-uncollated-copies/OFF/'\`




BRURI=\`printenv | grep DEVICE_URI=\`
BRURI=\`echo \$BRURI | grep "brserial"\`
PORT="USB"
if [ "\$BRURI" != "" ]; then
	PORT="SERIAL"
fi

if [ -e "/usr/local/Brother/PTouch/ql570/cupswrapper/brcupsconfpt1" ]; then
  if [ \$DEBUG = 0 ]; then
     /usr/local/Brother/PTouch/ql570/cupswrapper/brcupsconfpt1  ql570  \$PPDC 0 "\$CUPSOPTION" >> /dev/null
  else
     /usr/local/Brother/PTouch/ql570/cupswrapper/brcupsconfpt1  ql570  \$PPDC \$LOGCLEVEL "\$CUPSOPTION" >>\$LOGFILE
  fi
fi

if [ \$DEBUG -lt 10 ]; then
    cat    \$INPUT_TEMP_PS | /usr/local/Brother/PTouch/ql570/lpd/filterql570 "\$\$" "CUPS" "\$PORT"

    if [ \$LOGLEVEL -gt 2 ];  then
	   if [ \$LOGFILE != "/dev/null" ]; then
	     echo ""                                                >>\$LOGFILE
	     echo "    ------PostScript Data-------"                >>\$LOGFILE
	     cat    \$INPUT_TEMP_PS                                  >>\$LOGFILE
	   fi
    fi
fi
rm -f  \$INPUT_TEMP_PS

exit $errorcode

!ENDOFWFILTER!

chmod a+x $brotherlpdwrapper
if [ -e /usr/lib64/cups/backend ]; then
   cp $brotherlpdwrapper  $brotherlpdwrapper64
fi

chmod a+w /usr/local/Brother/PTouch/ql570/inf/brql570rc
chmod a+w /usr/local/Brother/PTouch/ql570/inf
if [ -e /etc/init.d/lpd ]; then
   /etc/init.d/lpd stop
fi
if [  -e /etc/init.d/lprng ]; then
   /etc/init.d/lprng stop
fi

cp -f /usr/local/Brother/PTouch/ql570/lpd/brusb_ql_lpr /usr/lib/cups/backend/brusb_ql570
#cp -f /usr/local/Brother/PTouch/ql570/lpd/brserial_ql570 /usr/lib/cups/backend/brserial_ql570
#chmod 00777 /usr/lib/cups/backend/brusb_ql570
#chmod 00777 /usr/lib/cups/backend/brserial_ql570

if [  -e /etc/init.d/cups ]; then
   /etc/init.d/cups restart
elif [  -e /etc/init.d/cupsys ]; then
   /etc/init.d/cupsys restart
fi

sleep 2s

lpadmin -p QL-570 -E -v brusb_ql570:/dev/usb -m brql570.ppd
#satyam comments
if [ -f /etc/debian_version ] ; then
sudo rm -rf /var/lib/dpkg/info/ql570cupswrapper*
fi
#satyam comments

exit 0

