1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2010 Hewlett-Packard Development Company, L.P.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 from base import device, codes
26 from soapfax import SOAPFaxDevice
27 from pmlfax import PMLFaxDevice
28 from marvellfax import MarvellFaxDevice
30 def FaxDevice(device_uri=None, printer_name=None,
32 fax_type=FAX_TYPE_NONE,
35 if fax_type == FAX_TYPE_NONE:
36 if device_uri is None and printer_name is not None:
37 printers = cups.getPrinters()
40 if p.name.lower() == printer_name.lower():
41 device_uri = p.device_uri
44 raise Error(ERROR_DEVICE_NOT_FOUND)
46 if device_uri is not None:
47 mq = device.queryModelByURI(device_uri)
48 fax_type = mq['fax-type']
50 log.debug("fax-type=%d" % fax_type)
52 if fax_type in (FAX_TYPE_BLACK_SEND_EARLY_OPEN, FAX_TYPE_BLACK_SEND_LATE_OPEN):
53 return PMLFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
55 elif fax_type == FAX_TYPE_SOAP:
56 return SOAPFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
58 elif fax_type == FAX_TYPE_LEDMSOAP:
59 return LEDMSOAPFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
61 elif fax_type == FAX_TYPE_MARVELL:
62 return MarvellFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
64 elif fax_type == FAX_TYPE_LEDM:
65 from ledmfax import LEDMFaxDevice
66 return LEDMFaxDevice(device_uri, printer_name, callback, fax_type, disable_dbus)
70 raise Error(ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATION)