CupsPrintIPP.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. <?php
  2. /* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/CupsPrintIPP.php,v 1.1 2008/06/21 00:30:56 harding Exp $
  3. *
  4. * Class PrintIPP - Send extended IPP requests.
  5. *
  6. * Copyright (C) 2005-2006 Thomas HARDING
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Library General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Library General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Library General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * mailto:thomas.harding@laposte.net
  23. * Thomas Harding, 56 rue de la bourie rouge, 45 000 ORLEANS -- FRANCE
  24. *
  25. */
  26. /*
  27. This class is intended to implement Internet Printing Protocol on client side.
  28. References needed to debug / add functionnalities:
  29. - RFC 2910
  30. - RFC 2911
  31. - RFC 3382
  32. - ...
  33. - CUPS-IPP-1.1
  34. */
  35. require_once("ExtendedPrintIPP.php");
  36. class CupsPrintIPP extends ExtendedPrintIPP
  37. {
  38. public $printers_attributes;
  39. public $defaults_attributes;
  40. protected $parsed;
  41. protected $output;
  42. public function __construct()
  43. {
  44. parent::__construct();
  45. self::_initTags();
  46. }
  47. //
  48. // OPERATIONS
  49. //
  50. public function cupsGetDefaults($attributes=array("all"))
  51. {
  52. //The CUPS-Get-Default operation returns the default printer URI and attributes
  53. $this->jobs = array_merge($this->jobs,array(""));
  54. $this->jobs_uri = array_merge($this->jobs_uri,array(""));
  55. $this->parsed = array();
  56. unset($this->printer_attributes);
  57. if (!isset($this->setup->charset))
  58. {
  59. self::setCharset();
  60. }
  61. if (!isset($this->setup->language))
  62. {
  63. self::setLanguage('en');
  64. }
  65. self::_setOperationId();
  66. for($i = 0 ; $i < count($attributes) ; $i++)
  67. {
  68. if ($i == 0)
  69. {
  70. $this->meta->attributes = chr(0x44) // Keyword
  71. . self::_giveMeStringLength('requested-attributes')
  72. . 'requested-attributes'
  73. . self::_giveMeStringLength($attributes[0])
  74. . $attributes[0];
  75. }
  76. else
  77. {
  78. $this->meta->attributes .= chr(0x44) // Keyword
  79. . chr(0x0).chr(0x0) // zero-length name
  80. . self::_giveMeStringLength($attributes[$i])
  81. . $attributes[$i];
  82. }
  83. }
  84. $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
  85. . chr(0x40). chr(0x01) // operation: cups vendor extension: get defaults
  86. . $this->meta->operation_id // request-id
  87. . chr(0x01) // start operation-attributes | operation-attributes-tag
  88. . $this->meta->charset
  89. . $this->meta->language
  90. . $this->meta->attributes
  91. . chr(0x03); // end operations attribute
  92. $this->output = $this->stringjob;
  93. self::_putDebug("Request: ".$this->output);
  94. $post_values = array( "Content-Type" => "application/ipp",
  95. "Data" => $this->output);
  96. if (self::_sendHttp ($post_values,'/'))
  97. {
  98. if(self::_parseServerOutput())
  99. {
  100. self::_parsePrinterAttributes();
  101. }
  102. }
  103. $this->attributes = &$this->printer_attributes;
  104. if (isset($this->printer_attributes->printer_type))
  105. {
  106. $printer_type = $this->printer_attributes->printer_type->_value0;
  107. $table = self::_interpretPrinterType($printer_type);
  108. for($i = 0 ; $i < count($table) ; $i++ )
  109. {
  110. $index = '_value'.$i;
  111. $this->printer_attributes->printer_type->$index = $table[$i];
  112. }
  113. }
  114. if (isset($this->serveroutput) && isset($this->serveroutput->status))
  115. {
  116. $this->status = array_merge($this->status,array($this->serveroutput->status));
  117. if ($this->serveroutput->status == "successfull-ok")
  118. {
  119. self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
  120. }
  121. else
  122. {
  123. self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
  124. }
  125. return $this->serveroutput->status;
  126. }
  127. else
  128. {
  129. $this->status = array_merge($this->status,array("OPERATION FAILED"));
  130. self::_errorLog("getting defaults : OPERATION FAILED",1);
  131. }
  132. return false;
  133. }
  134. public function cupsAcceptJobs($printer_uri)
  135. {
  136. //The CUPS-Get-Default operation returns the default printer URI and attributes
  137. $this->jobs = array_merge($this->jobs,array(""));
  138. $this->jobs_uri = array_merge($this->jobs_uri,array(""));
  139. $this->parsed = array();
  140. unset($this->printer_attributes);
  141. if (!isset($this->setup->charset))
  142. {
  143. self::setCharset();
  144. }
  145. if (!isset($this->setup->language))
  146. {
  147. self::setLanguage('en');
  148. }
  149. self::_setOperationId();
  150. $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
  151. . chr(0x40). chr(0x08) // operation: cups vendor extension: Accept-Jobs
  152. . $this->meta->operation_id // request-id
  153. . chr(0x01) // start operation-attributes | operation-attributes-tag
  154. . $this->meta->charset
  155. . $this->meta->language
  156. . chr(0x45) // uri
  157. . self::_giveMeStringLength('printer-uri')
  158. . 'printer-uri'
  159. . self::_giveMeStringLength($printer_uri)
  160. . $printer_uri
  161. . chr(0x03); // end operations attribute
  162. $this->output = $this->stringjob;
  163. self::_putDebug("Request: ".$this->output);
  164. $post_values = array( "Content-Type" => "application/ipp",
  165. "Data" => $this->output);
  166. if (self::_sendHttp ($post_values,'/admin/'))
  167. {
  168. if(self::_parseServerOutput())
  169. {
  170. self::_parseAttributes();
  171. }
  172. }
  173. if (isset($this->serveroutput) && isset($this->serveroutput->status))
  174. {
  175. $this->status = array_merge($this->status,array($this->serveroutput->status));
  176. if ($this->serveroutput->status == "successfull-ok")
  177. {
  178. self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
  179. }
  180. else
  181. {
  182. self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
  183. }
  184. return $this->serveroutput->status;
  185. }
  186. else
  187. {
  188. $this->status = array_merge($this->status,array("OPERATION FAILED"));
  189. self::_errorLog("getting defaults : OPERATION FAILED",1);
  190. }
  191. return false;
  192. }
  193. public function cupsRejectJobs($printer_uri,$printer_state_message)
  194. {
  195. //The CUPS-Get-Default operation returns the default printer URI and attributes
  196. $this->jobs = array_merge($this->jobs,array(""));
  197. $this->jobs_uri = array_merge($this->jobs_uri,array(""));
  198. $this->parsed = array();
  199. unset($this->attributes);
  200. if (!isset($this->setup->charset))
  201. {
  202. self::setCharset();
  203. }
  204. if (!isset($this->setup->language))
  205. {
  206. self::setLanguage('en');
  207. }
  208. self::_setOperationId();
  209. $message = "";
  210. if ($printer_state_message)
  211. {
  212. $message = chr(0x04) // start printer-attributes
  213. . chr(0x41) // textWithoutLanguage
  214. . self::_giveMeStringLength("printer-state-message")
  215. . "printer-state-message"
  216. . self::_giveMeStringLength($printer_state_message)
  217. . $printer_state_message;
  218. }
  219. $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
  220. . chr(0x40). chr(0x09) // operation: cups vendor extension: Reject-Jobs
  221. . $this->meta->operation_id // request-id
  222. . chr(0x01) // start operation-attributes | operation-attributes-tag
  223. . $this->meta->charset
  224. . $this->meta->language
  225. . chr(0x45) // uri
  226. . self::_giveMeStringLength('printer-uri')
  227. . 'printer-uri'
  228. . self::_giveMeStringLength($printer_uri)
  229. . $printer_uri
  230. . $message
  231. . chr(0x03); // end operations attribute
  232. $this->output = $this->stringjob;
  233. self::_putDebug("Request: ".$this->output);
  234. $post_values = array( "Content-Type" => "application/ipp",
  235. "Data" => $this->output);
  236. if (self::_sendHttp ($post_values,'/admin/'))
  237. {
  238. if(self::_parseServerOutput())
  239. {
  240. self::_parseAttributes();
  241. }
  242. }
  243. if (isset($this->serveroutput) && isset($this->serveroutput->status))
  244. {
  245. $this->status = array_merge($this->status,array($this->serveroutput->status));
  246. if ($this->serveroutput->status == "successfull-ok")
  247. {
  248. self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
  249. }
  250. else
  251. {
  252. self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
  253. }
  254. return $this->serveroutput->status;
  255. }
  256. else
  257. {
  258. $this->status = array_merge($this->status,array("OPERATION FAILED"));
  259. self::_errorLog("getting defaults : OPERATION FAILED",1);
  260. }
  261. return false;
  262. }
  263. public function getPrinters($printer_location=false,$printer_info=false,$attributes=array())
  264. {
  265. if (count($attributes) == 0)
  266. {
  267. true;
  268. }
  269. $attributes=array('printer-uri-supported', 'printer-location', 'printer-info', 'printer-type', 'color-supported', 'printer-name');
  270. $this->jobs = array_merge($this->jobs,array(""));
  271. $this->jobs_uri = array_merge($this->jobs_uri,array(""));
  272. unset ($this->printers_attributes);
  273. if (!isset($this->setup->charset))
  274. {
  275. self::setCharset();
  276. }
  277. if (!isset($this->setup->language))
  278. {
  279. self::setLanguage('en-us');
  280. }
  281. self::_setOperationId();
  282. $this->meta->attributes='';
  283. if ($printer_location)
  284. {
  285. $this->meta->attributes .= chr(0x41) // textWithoutLanguage
  286. . self::_giveMeStringLength('printer-location')
  287. . 'printer-location'
  288. . self::_giveMeStringLength($printer_location)
  289. . $printer_location;
  290. }
  291. if ($printer_info)
  292. {
  293. $this->meta->attributes .= chr(0x41) // textWithoutLanguage
  294. . self::_giveMeStringLength('printer-info')
  295. . 'printer-info'
  296. . self::_giveMeStringLength($printer_info)
  297. . $printer_info;
  298. }
  299. for($i = 0 ; $i < count($attributes) ; $i++)
  300. {
  301. if ($i == 0)
  302. {
  303. $this->meta->attributes .= chr(0x44) // Keyword
  304. . self::_giveMeStringLength('requested-attributes')
  305. . 'requested-attributes'
  306. . self::_giveMeStringLength($attributes[0])
  307. . $attributes[0];
  308. }
  309. else
  310. {
  311. $this->meta->attributes .= chr(0x44) // Keyword
  312. . chr(0x0).chr(0x0) // zero-length name
  313. . self::_giveMeStringLength($attributes[$i])
  314. . $attributes[$i];
  315. }
  316. }
  317. $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
  318. . chr(0x40). chr(0x02) // operation: cups vendor extension: get printers
  319. . $this->meta->operation_id // request-id
  320. . chr(0x01) // start operation-attributes | operation-attributes-tag
  321. . $this->meta->charset
  322. . $this->meta->language
  323. . $this->meta->attributes
  324. . chr(0x03); // end operations attribute
  325. $this->output = $this->stringjob;
  326. $post_values = array( "Content-Type" => "application/ipp",
  327. "Data" => $this->output);
  328. if (self::_sendHttp ($post_values,'/'))
  329. {
  330. if(self::_parseServerOutput())
  331. {
  332. $this->_getAvailablePrinters();
  333. }
  334. }
  335. if (isset($this->serveroutput) && isset($this->serveroutput->status))
  336. {
  337. $this->status = array_merge($this->status,array($this->serveroutput->status));
  338. if ($this->serveroutput->status == "successfull-ok")
  339. {
  340. self::_errorLog("getting printers: ".$this->serveroutput->status,3);
  341. }
  342. else
  343. {
  344. self::_errorLog("getting printers: ".$this->serveroutput->status,1);
  345. }
  346. return $this->serveroutput->status;
  347. }
  348. else
  349. {
  350. $this->status = array_merge($this->status,array("OPERATION FAILED"));
  351. self::_errorLog("getting printers : OPERATION FAILED",1);
  352. }
  353. return false;
  354. }
  355. public function cupsGetPrinters ()
  356. {
  357. // alias for getPrinters();
  358. self::getPrinters();
  359. }
  360. public function getPrinterAttributes()
  361. {
  362. // complete informations from parent with Cups-specific stuff
  363. if(!$result = parent::getPrinterAttributes())
  364. {
  365. return FALSE;
  366. }
  367. if(!isset($this->printer_attributes))
  368. {
  369. return FALSE;
  370. }
  371. if (isset ($this->printer_attributes->printer_type))
  372. {
  373. $printer_type = $this->printer_attributes->printer_type->_value0;
  374. $table = self::_interpretPrinterType($printer_type);
  375. for($i = 0 ; $i < count($table) ; $i++ )
  376. {
  377. $index = '_value'.$i;
  378. $this->printer_attributes->printer_type->$index = $table[$i];
  379. }
  380. }
  381. return $result;
  382. }
  383. //
  384. // SETUP
  385. //
  386. protected function _initTags ()
  387. {
  388. // override parent with specific cups attributes
  389. $operation_tags = array ();
  390. $this->operation_tags = array_merge ($this->operation_tags, $operation_tags);
  391. $job_tags = array ( "job-billing" => array("tag" => "textWithoutLanguage"),
  392. "blackplot" => array("tag" => "boolean"),
  393. "brightness" => array("tag" => "integer"),
  394. "columns" => array("tag" => "integer"),
  395. "cpi" => array("tag" => "enum"),
  396. "fitplot" => array("tag" => "boolean"),
  397. "gamma" => array("tag" => "integer"),
  398. "hue" => array("tag" => "integer"),
  399. "lpi" => array("tag" => "enum"),
  400. "mirror" => array("tag","boolean"),
  401. "natural-scaling" => array("tag" => "integer"),
  402. "number-up-layout" => array("tag" => "keyword"),
  403. "page-border" => array("tag" => "keyword"),
  404. "page-bottom" => array("tag" => "integer"),
  405. "page-label" => array("tag" => "textWithoutLanguage"),
  406. "page-left" => array("tag" => "integer"),
  407. "page-right" => array("tag" => "integer"),
  408. "page-set" => array("tag" => "keyword"),
  409. "page-top" => array("tag" => "integer"),
  410. "penwidth" => array("tag" => "integer"),
  411. "position" => array("tag" => "keyword"),
  412. "ppi" => array("tag" => "integer"),
  413. "prettyprint" => array("tag","boolean"),
  414. "saturation" => array("tag" => "integer"),
  415. "scaling" => array("tag" => "integer"),
  416. "wrap" => array("tag","boolean"),
  417. );
  418. $this->job_tags = array_merge ($this->job_tags, $job_tags);
  419. }
  420. //
  421. // REQUEST BUILDING
  422. //
  423. protected function _enumBuild ($tag,$value)
  424. {
  425. $value_built = parent::_enumBuild($tag,$value);
  426. switch ($tag)
  427. {
  428. case "cpi":
  429. switch ($value)
  430. {
  431. case '10':
  432. $value_built = chr(10);
  433. break;
  434. case '12':
  435. $value_built = chr(12);
  436. break;
  437. case '17':
  438. $value_built = chr(17);
  439. break;
  440. default:
  441. $value_built = chr(10);
  442. }
  443. break;
  444. case "lpi":
  445. switch ($value)
  446. {
  447. case '6':
  448. $value_built = chr(6);
  449. break;
  450. case '8':
  451. $value_built = chr(8);
  452. break;
  453. default:
  454. $value_built = chr(6);
  455. }
  456. break;
  457. }
  458. $prepend = '';
  459. while ((strlen($value_built) + strlen($prepend)) < 4)
  460. $prepend .= chr(0);
  461. return $prepend.$value_built;
  462. }
  463. //
  464. // RESPONSE PARSING
  465. //
  466. private function _getAvailablePrinters ()
  467. {
  468. $this->available_printers = array();
  469. $this->printer_map = array();
  470. $k = 0;
  471. $this->printers_attributes = new \stdClass();
  472. for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++)
  473. {
  474. if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes")
  475. {
  476. $phpname = "_printer".$k;
  477. $this->printers_attributes->$phpname = new \stdClass();
  478. for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++)
  479. {
  480. $value = $this->serveroutput->response[$i][$j]['value'];
  481. $name = str_replace("-","_",$this->serveroutput->response[$i][$j]['name']);
  482. switch ($name)
  483. {
  484. case "printer_uri_supported":
  485. $this->available_printers = array_merge($this->available_printers,array($value));
  486. break;
  487. case "printer_type":
  488. $table = self::_interpretPrinterType($value);
  489. $this->printers_attributes->$phpname->$name = new \stdClass();
  490. for($l = 0 ; $l < count($table) ; $l++ )
  491. {
  492. $index = '_value'.$l;
  493. $this->printers_attributes->$phpname->$name->$index = $table[$l];
  494. }
  495. break;
  496. case '':
  497. break;
  498. case 'printer_name':
  499. $this->printer_map[$value] = $k;
  500. break;
  501. default:
  502. $this->printers_attributes->$phpname->$name = $value;
  503. break;
  504. }
  505. }
  506. $k ++;
  507. }
  508. }
  509. }
  510. protected function _getEnumVendorExtensions ($value_parsed)
  511. {
  512. switch ($value_parsed)
  513. {
  514. case 0x4002:
  515. $value = 'Get-Availables-Printers';
  516. break;
  517. default:
  518. $value = sprintf('Unknown(Cups extension for operations): 0x%x',$value_parsed);
  519. break;
  520. }
  521. if (isset($value))
  522. {
  523. return ($value);
  524. }
  525. return sprintf('Unknown: 0x%x',$value_parsed);
  526. }
  527. private function _interpretPrinterType($value)
  528. {
  529. $value_parsed = 0;
  530. for ($i = strlen($value) ; $i > 0 ; $i --)
  531. {
  532. $value_parsed += pow(256,($i - 1)) * ord($value[strlen($value) - $i]);
  533. }
  534. $type[0] = $type[1] = $type[2] = $type[3] = $type[4] = $type[5] = '';
  535. $type[6] = $type[7] = $type[8] = $type[9] = $type[10] = '';
  536. $type[11] = $type[12] = $type[13] = $type[14] = $type[15] = '';
  537. $type[16] = $type[17] = $type[18] = $type[19] = '';
  538. if ($value_parsed %2 == 1)
  539. {
  540. $type[0] = 'printer-class';
  541. $value_parsed -= 1;
  542. }
  543. if ($value_parsed %4 == 2 )
  544. {
  545. $type[1] = 'remote-destination';
  546. $value_parsed -= 2;
  547. }
  548. if ($value_parsed %8 == 4 )
  549. {
  550. $type[2] = 'print-black';
  551. $value_parsed -= 4;
  552. }
  553. if ($value_parsed %16 == 8 )
  554. {
  555. $type[3] = 'print-color';
  556. $value_parsed -= 8;
  557. }
  558. if ($value_parsed %32 == 16)
  559. {
  560. $type[4] = 'hardware-print-on-both-sides';
  561. $value_parsed -= 16;
  562. }
  563. if ($value_parsed %64 == 32)
  564. {
  565. $type[5] = 'hardware-staple-output';
  566. $value_parsed -= 32;
  567. }
  568. if ($value_parsed %128 == 64)
  569. {
  570. $type[6] = 'hardware-fast-copies';
  571. $value_parsed -= 64;
  572. }
  573. if ($value_parsed %256 == 128)
  574. {
  575. $type[7] = 'hardware-fast-copy-collation';
  576. $value_parsed -= 128;
  577. }
  578. if ($value_parsed %512 == 256)
  579. {
  580. $type[8] = 'punch-output';
  581. $value_parsed -= 256;
  582. }
  583. if ($value_parsed %1024 == 512)
  584. {
  585. $type[9] = 'cover-output';
  586. $value_parsed -= 512;
  587. }
  588. if ($value_parsed %2048 == 1024)
  589. {
  590. $type[10] = 'bind-output';
  591. $value_parsed -= 1024;
  592. }
  593. if ($value_parsed %4096 == 2048)
  594. {
  595. $type[11] = 'sort-output';
  596. $value_parsed -= 2048;
  597. }
  598. if ($value_parsed %8192 == 4096)
  599. {
  600. $type[12] = 'handle-media-up-to-US-Legal-A4';
  601. $value_parsed -= 4096;
  602. }
  603. if ($value_parsed %16384 == 8192)
  604. {
  605. $type[13] = 'handle-media-between-US-Legal-A4-and-ISO_C-A2';
  606. $value_parsed -= 8192;
  607. }
  608. if ($value_parsed %32768 == 16384)
  609. {
  610. $type[14] = 'handle-media-larger-than-ISO_C-A2';
  611. $value_parsed -= 16384;
  612. }
  613. if ($value_parsed %65536 == 32768)
  614. {
  615. $type[15] = 'handle-user-defined-media-sizes';
  616. $value_parsed -= 32768;
  617. }
  618. if ($value_parsed %131072 == 65536)
  619. {
  620. $type[16] = 'implicit-server-generated-class';
  621. $value_parsed -= 65536;
  622. }
  623. if ($value_parsed %262144 == 131072)
  624. {
  625. $type[17] = 'network-default-printer';
  626. $value_parsed -= 131072;
  627. }
  628. if ($value_parsed %524288 == 262144)
  629. {
  630. $type[18] = 'fax-device';
  631. $value_parsed -= 262144;
  632. }
  633. return $type;
  634. }
  635. protected function _interpretEnum($attribute_name,$value)
  636. {
  637. $value_parsed = self::_interpretInteger($value);
  638. switch ($attribute_name)
  639. {
  640. case 'cpi':
  641. case 'lpi':
  642. $value = $value_parsed;
  643. break;
  644. default:
  645. $value = parent::_interpretEnum($attribute_name,$value);
  646. break;
  647. }
  648. return $value;
  649. }
  650. }