1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2003-2007 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
22 from __future__ import division
29 import urllib # TODO: Replace with urllib2 (urllib is deprecated in Python 3.0)
34 from base.codes import *
35 from base import device, utils, codes, dime
38 from soapfax import SOAPFaxSendThread
39 from soapfax import SOAPFaxDevice
42 # **************************************************************************** #
43 class LEDMSOAPFaxDevice(SOAPFaxDevice):
46 def __init__(self, device_uri=None, printer_name=None,
48 fax_type=FAX_TYPE_NONE,
51 SOAPFaxDevice.__init__(self, device_uri,
56 #LEDM Specific functions
57 def put(self, url, post):
58 data = """PUT %s HTTP/1.1\r
59 Connection: Keep-alive\r
60 User-agent: hplip/2.0\r
64 %s""" % (url, self.http_host, len(post), post)
66 self.writeEWS_LEDM(data)
67 response = cStringIO.StringIO()
69 while self.readEWS_LEDM(4096, response, timeout=5):
72 response = response.getvalue()
73 log.log_data(response)
76 match = http_result_pat.match(response)
77 if match is None: return HTTP_OK
79 code = int(match.group(1))
80 except (ValueError, TypeError):
83 return code == HTTP_OK
86 def setPhoneNum(self, num):
87 xml = setPhoneNumXML %(num)
88 log.debug("SetPhoneNum:xml Value:%s" %xml)
89 return self.put("/DevMgmt/FaxConfigDyn.xml", xml)
92 def getPhoneNum(self):
93 return self.readAttributeFromXml_EWS("/DevMgmt/FaxConfigDyn.xml",'faxcfgdyn:faxconfigdyn-faxcfgdyn:systemsettings-dd:phonenumber')
95 phone_num = property(getPhoneNum, setPhoneNum)
98 def setStationName(self, name):
99 xml = setStationNameXML %(name)
100 return self.put("/DevMgmt/FaxConfigDyn.xml", xml)
103 def getStationName(self):
104 return self.readAttributeFromXml_EWS("/DevMgmt/FaxConfigDyn.xml",'faxcfgdyn:faxconfigdyn-faxcfgdyn:systemsettings-dd:companyname')
106 station_name = property(getStationName, setStationName)