Update lib with github.com/mfly/php-ipp

This commit is contained in:
frederic34 2014-12-28 11:29:53 +01:00
parent 3bf63ed0a9
commit 310be3d3b6
5 changed files with 4365 additions and 3903 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
/* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/CupsPrintIPP.php,v 1.1 2008/06/21 00:30:56 harding Exp $ /* @(#) $Header: /sources/phpprintipp/phpprintipp/php_classes/CupsPrintIPP.php,v 1.1 2008/06/21 00:30:56 harding Exp $
* *
* Class PrintIPP - Send extended IPP requests. * Class PrintIPP - Send extended IPP requests.
@ -26,7 +26,6 @@
*/ */
/* /*
This class is intended to implement Internet Printing Protocol on client side. This class is intended to implement Internet Printing Protocol on client side.
References needed to debug / add functionnalities: References needed to debug / add functionnalities:
@ -39,29 +38,26 @@
require_once("ExtendedPrintIPP.php"); require_once("ExtendedPrintIPP.php");
class CupsPrintIPP extends ExtendedPrintIPP { class CupsPrintIPP extends ExtendedPrintIPP
{
// {{{ variables declaration
public $printers_attributes; public $printers_attributes;
public $defaults_attributes; public $defaults_attributes;
// }}} protected $parsed;
protected $output;
// {{{ constructor public function __construct()
public function __construct() { {
parent::__construct(); parent::__construct();
self::_initTags(); self::_initTags();
} }
// }}}
// //
// OPERATIONS // OPERATIONS
// //
public function cupsGetDefaults($attributes=array("all"))
// {{{ cupsGetDefaults ($attributes="all") {
public function cupsGetDefaults($attributes=array("all")) { //The CUPS-Get-Default operation returns the default printer URI and attributes
//The CUPS-Get-Default operation returns the default printer URI and attributes
$this->jobs = array_merge($this->jobs,array("")); $this->jobs = array_merge($this->jobs,array(""));
$this->jobs_uri = array_merge($this->jobs_uri,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array(""));
@ -69,25 +65,35 @@ class CupsPrintIPP extends ExtendedPrintIPP {
unset($this->printer_attributes); unset($this->printer_attributes);
if (!isset($this->setup->charset)) if (!isset($this->setup->charset))
self::setCharset('us-ascii'); {
self::setCharset();
}
if (!isset($this->setup->language)) if (!isset($this->setup->language))
{
self::setLanguage('en'); self::setLanguage('en');
}
self::_setOperationId(); self::_setOperationId();
for($i = 0 ; $i < count($attributes) ; $i++) for($i = 0 ; $i < count($attributes) ; $i++)
{
if ($i == 0) if ($i == 0)
{
$this->meta->attributes = chr(0x44) // Keyword $this->meta->attributes = chr(0x44) // Keyword
. self::_giveMeStringLength('requested-attributes') . self::_giveMeStringLength('requested-attributes')
. 'requested-attributes' . 'requested-attributes'
. self::_giveMeStringLength($attributes[0]) . self::_giveMeStringLength($attributes[0])
. $attributes[0]; . $attributes[0];
}
else else
{
$this->meta->attributes .= chr(0x44) // Keyword $this->meta->attributes .= chr(0x44) // Keyword
. chr(0x0).chr(0x0) // zero-length name . chr(0x0).chr(0x0) // zero-length name
. self::_giveMeStringLength($attributes[$i]) . self::_giveMeStringLength($attributes[$i])
. $attributes[$i]; . $attributes[$i];
}
}
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
. chr(0x40). chr(0x01) // operation: cups vendor extension: get defaults . chr(0x40). chr(0x01) // operation: cups vendor extension: get defaults
@ -105,45 +111,55 @@ class CupsPrintIPP extends ExtendedPrintIPP {
$post_values = array( "Content-Type" => "application/ipp", $post_values = array( "Content-Type" => "application/ipp",
"Data" => $this->output); "Data" => $this->output);
if (self::_sendHttp ($post_values,'/')) { if (self::_sendHttp ($post_values,'/'))
{
if(self::_parseServerOutput()) if(self::_parseServerOutput())
{
self::_parsePrinterAttributes(); self::_parsePrinterAttributes();
} }
}
$this->attributes = &$this->printer_attributes; $this->attributes = &$this->printer_attributes;
if (isset($this->printer_attributes->printer_type)) { if (isset($this->printer_attributes->printer_type))
{
$printer_type = $this->printer_attributes->printer_type->_value0; $printer_type = $this->printer_attributes->printer_type->_value0;
$table = self::_interpretPrinterType($printer_type); $table = self::_interpretPrinterType($printer_type);
for($i = 0 ; $i < count($table) ; $i++ ) { for($i = 0 ; $i < count($table) ; $i++ )
{
$index = '_value'.$i; $index = '_value'.$i;
$this->printer_attributes->printer_type->$index = $table[$i]; $this->printer_attributes->printer_type->$index = $table[$i];
} }
} }
if (isset($this->serveroutput) && isset($this->serveroutput->status)) { if (isset($this->serveroutput) && isset($this->serveroutput->status))
{
$this->status = array_merge($this->status,array($this->serveroutput->status)); $this->status = array_merge($this->status,array($this->serveroutput->status));
if ($this->serveroutput->status == "successfull-ok") if ($this->serveroutput->status == "successfull-ok")
{
self::_errorLog("getting defaults: ".$this->serveroutput->status,3); self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
}
else else
{
self::_errorLog("getting defaults: ".$this->serveroutput->status,1); self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
}
return $this->serveroutput->status; return $this->serveroutput->status;
}
} else { else
{
$this->status = array_merge($this->status,array("OPERATION FAILED")); $this->status = array_merge($this->status,array("OPERATION FAILED"));
self::_errorLog("getting defaults : OPERATION FAILED",1); self::_errorLog("getting defaults : OPERATION FAILED",1);
} }
return false; return false;
} }
// }}}
// {{{ cupsAcceptJobs ($printer_uri)
public function cupsAcceptJobs($printer_uri) { public function cupsAcceptJobs($printer_uri)
{
//The CUPS-Get-Default operation returns the default printer URI and attributes //The CUPS-Get-Default operation returns the default printer URI and attributes
$this->jobs = array_merge($this->jobs,array("")); $this->jobs = array_merge($this->jobs,array(""));
@ -152,14 +168,18 @@ class CupsPrintIPP extends ExtendedPrintIPP {
unset($this->printer_attributes); unset($this->printer_attributes);
if (!isset($this->setup->charset)) if (!isset($this->setup->charset))
self::setCharset('us-ascii'); {
self::setCharset();
}
if (!isset($this->setup->language)) if (!isset($this->setup->language))
{
self::setLanguage('en'); self::setLanguage('en');
}
self::_setOperationId(); self::_setOperationId();
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
. chr(0x40). chr(0x08) // operation: cups vendor extension: Accept-Jobs . chr(0x40). chr(0x08) // operation: cups vendor extension: Accept-Jobs
. $this->meta->operation_id // request-id . $this->meta->operation_id // request-id
. chr(0x01) // start operation-attributes | operation-attributes-tag . chr(0x01) // start operation-attributes | operation-attributes-tag
@ -179,32 +199,41 @@ class CupsPrintIPP extends ExtendedPrintIPP {
$post_values = array( "Content-Type" => "application/ipp", $post_values = array( "Content-Type" => "application/ipp",
"Data" => $this->output); "Data" => $this->output);
if (self::_sendHttp ($post_values,'/admin/')) { if (self::_sendHttp ($post_values,'/admin/'))
{
if(self::_parseServerOutput()) if(self::_parseServerOutput())
{
self::_parseAttributes(); self::_parseAttributes();
} }
}
if (isset($this->serveroutput) && isset($this->serveroutput->status)) { if (isset($this->serveroutput) && isset($this->serveroutput->status))
{
$this->status = array_merge($this->status,array($this->serveroutput->status)); $this->status = array_merge($this->status,array($this->serveroutput->status));
if ($this->serveroutput->status == "successfull-ok") if ($this->serveroutput->status == "successfull-ok")
{
self::_errorLog("getting defaults: ".$this->serveroutput->status,3); self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
}
else else
{
self::_errorLog("getting defaults: ".$this->serveroutput->status,1); self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
}
return $this->serveroutput->status; return $this->serveroutput->status;
}
} else { else
{
$this->status = array_merge($this->status,array("OPERATION FAILED")); $this->status = array_merge($this->status,array("OPERATION FAILED"));
self::_errorLog("getting defaults : OPERATION FAILED",1); self::_errorLog("getting defaults : OPERATION FAILED",1);
} }
return false; return false;
} }
// }}}
// {{{ cupsRejectJobs ($printer_uri,$printer_state_message=false)
public function cupsRejectJobs($printer_uri,$printer_state_message) { public function cupsRejectJobs($printer_uri,$printer_state_message)
{
//The CUPS-Get-Default operation returns the default printer URI and attributes //The CUPS-Get-Default operation returns the default printer URI and attributes
$this->jobs = array_merge($this->jobs,array("")); $this->jobs = array_merge($this->jobs,array(""));
@ -213,21 +242,27 @@ class CupsPrintIPP extends ExtendedPrintIPP {
unset($this->attributes); unset($this->attributes);
if (!isset($this->setup->charset)) if (!isset($this->setup->charset))
self::setCharset('us-ascii'); {
self::setCharset();
}
if (!isset($this->setup->language)) if (!isset($this->setup->language))
{
self::setLanguage('en'); self::setLanguage('en');
}
self::_setOperationId(); self::_setOperationId();
$message = ""; $message = "";
if ($printer_state_message) if ($printer_state_message)
{
$message = chr(0x04) // start printer-attributes $message = chr(0x04) // start printer-attributes
. chr(0x41) // textWithoutLanguage . chr(0x41) // textWithoutLanguage
. self::_giveMeStringLength("printer-state-message") . self::_giveMeStringLength("printer-state-message")
. "printer-state-message" . "printer-state-message"
. self::_giveMeStringLength($printer_state_message) . self::_giveMeStringLength($printer_state_message)
. $printer_state_message; . $printer_state_message;
}
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
. chr(0x40). chr(0x09) // operation: cups vendor extension: Reject-Jobs . chr(0x40). chr(0x09) // operation: cups vendor extension: Reject-Jobs
@ -250,79 +285,101 @@ class CupsPrintIPP extends ExtendedPrintIPP {
$post_values = array( "Content-Type" => "application/ipp", $post_values = array( "Content-Type" => "application/ipp",
"Data" => $this->output); "Data" => $this->output);
if (self::_sendHttp ($post_values,'/admin/')) { if (self::_sendHttp ($post_values,'/admin/'))
{
if(self::_parseServerOutput()) if(self::_parseServerOutput())
{
self::_parseAttributes(); self::_parseAttributes();
} }
}
if (isset($this->serveroutput) && isset($this->serveroutput->status)) { if (isset($this->serveroutput) && isset($this->serveroutput->status))
{
$this->status = array_merge($this->status,array($this->serveroutput->status)); $this->status = array_merge($this->status,array($this->serveroutput->status));
if ($this->serveroutput->status == "successfull-ok") if ($this->serveroutput->status == "successfull-ok")
{
self::_errorLog("getting defaults: ".$this->serveroutput->status,3); self::_errorLog("getting defaults: ".$this->serveroutput->status,3);
}
else else
{
self::_errorLog("getting defaults: ".$this->serveroutput->status,1); self::_errorLog("getting defaults: ".$this->serveroutput->status,1);
}
return $this->serveroutput->status; return $this->serveroutput->status;
}
} else { else
{
$this->status = array_merge($this->status,array("OPERATION FAILED")); $this->status = array_merge($this->status,array("OPERATION FAILED"));
self::_errorLog("getting defaults : OPERATION FAILED",1); self::_errorLog("getting defaults : OPERATION FAILED",1);
} }
return false; return false;
} }
// }}}
// {{{ getPrinters()
public function getPrinters($printer_location=false,$printer_info=false,$attributes=array()) {
public function getPrinters($printer_location=false,$printer_info=false,$attributes=array())
{
if (count($attributes) == 0) if (count($attributes) == 0)
true; {
$attributes=array('printer-uri-supported','printer-location','printer-info','printer-type','color-supported'); true;
}
$attributes=array('printer-uri-supported', 'printer-location', 'printer-info', 'printer-type', 'color-supported', 'printer-name');
$this->jobs = array_merge($this->jobs,array("")); $this->jobs = array_merge($this->jobs,array(""));
$this->jobs_uri = array_merge($this->jobs_uri,array("")); $this->jobs_uri = array_merge($this->jobs_uri,array(""));
unset ($this->printers_attributes); unset ($this->printers_attributes);
if (!isset($this->setup->charset)) if (!isset($this->setup->charset))
self::setCharset('us-ascii'); {
self::setCharset();
}
if (!isset($this->setup->language)) if (!isset($this->setup->language))
{
self::setLanguage('en-us'); self::setLanguage('en-us');
}
self::_setOperationId(); self::_setOperationId();
$this->meta->attributes=''; $this->meta->attributes='';
if ($printer_location) if ($printer_location)
{
$this->meta->attributes .= chr(0x41) // textWithoutLanguage $this->meta->attributes .= chr(0x41) // textWithoutLanguage
. self::_giveMeStringLength('printer-location') . self::_giveMeStringLength('printer-location')
. 'printer-location' . 'printer-location'
. self::_giveMeStringLength($printer_location) . self::_giveMeStringLength($printer_location)
. $printer_location; . $printer_location;
}
if ($printer_info) if ($printer_info)
{
$this->meta->attributes .= chr(0x41) // textWithoutLanguage $this->meta->attributes .= chr(0x41) // textWithoutLanguage
. self::_giveMeStringLength('printer-info') . self::_giveMeStringLength('printer-info')
. 'printer-info' . 'printer-info'
. self::_giveMeStringLength($printer_info) . self::_giveMeStringLength($printer_info)
. $printer_info; . $printer_info;
}
for($i = 0 ; $i < count($attributes) ; $i++) for($i = 0 ; $i < count($attributes) ; $i++)
{
if ($i == 0) if ($i == 0)
{
$this->meta->attributes .= chr(0x44) // Keyword $this->meta->attributes .= chr(0x44) // Keyword
. self::_giveMeStringLength('requested-attributes') . self::_giveMeStringLength('requested-attributes')
. 'requested-attributes' . 'requested-attributes'
. self::_giveMeStringLength($attributes[0]) . self::_giveMeStringLength($attributes[0])
. $attributes[0]; . $attributes[0];
}
else else
{
$this->meta->attributes .= chr(0x44) // Keyword $this->meta->attributes .= chr(0x44) // Keyword
. chr(0x0).chr(0x0) // zero-length name . chr(0x0).chr(0x0) // zero-length name
. self::_giveMeStringLength($attributes[$i]) . self::_giveMeStringLength($attributes[$i])
. $attributes[$i]; . $attributes[$i];
}
}
$this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1 $this->stringjob = chr(0x01) . chr(0x01) // IPP version 1.1
. chr(0x40). chr(0x02) // operation: cups vendor extension: get printers . chr(0x40). chr(0x02) // operation: cups vendor extension: get printers
@ -338,67 +395,78 @@ class CupsPrintIPP extends ExtendedPrintIPP {
$post_values = array( "Content-Type" => "application/ipp", $post_values = array( "Content-Type" => "application/ipp",
"Data" => $this->output); "Data" => $this->output);
if (self::_sendHttp ($post_values,'/')) { if (self::_sendHttp ($post_values,'/'))
{
if(self::_parseServerOutput()) if(self::_parseServerOutput())
{
$this->_getAvailablePrinters(); $this->_getAvailablePrinters();
} }
}
if (isset($this->serveroutput) && isset($this->serveroutput->status)) { if (isset($this->serveroutput) && isset($this->serveroutput->status))
{
$this->status = array_merge($this->status,array($this->serveroutput->status)); $this->status = array_merge($this->status,array($this->serveroutput->status));
if ($this->serveroutput->status == "successfull-ok") if ($this->serveroutput->status == "successfull-ok")
{
self::_errorLog("getting printers: ".$this->serveroutput->status,3); self::_errorLog("getting printers: ".$this->serveroutput->status,3);
}
else else
{
self::_errorLog("getting printers: ".$this->serveroutput->status,1); self::_errorLog("getting printers: ".$this->serveroutput->status,1);
}
return $this->serveroutput->status; return $this->serveroutput->status;
}
} else { else
{
$this->status = array_merge($this->status,array("OPERATION FAILED")); $this->status = array_merge($this->status,array("OPERATION FAILED"));
self::_errorLog("getting printers : OPERATION FAILED",1); self::_errorLog("getting printers : OPERATION FAILED",1);
} }
return false; return false;
} }
// }}}
// {{{ cupsGetPrinters ()
public function cupsGetPrinters () { public function cupsGetPrinters ()
// alias for getPrinters(); {
// alias for getPrinters();
self::getPrinters(); self::getPrinters();
} }
// }}}
// {{{ getPrinterAttributes()
public function getPrinterAttributes() { public function getPrinterAttributes()
// complete informations from parent with Cups-specific stuff {
// complete informations from parent with Cups-specific stuff
if(!$result = parent::getPrinterAttributes()) if(!$result = parent::getPrinterAttributes())
{
return FALSE; return FALSE;
}
if(!isset($this->printer_attributes)) if(!isset($this->printer_attributes))
{
return FALSE; return FALSE;
}
if (isset ($this->printer_attributes->printer_type)) { if (isset ($this->printer_attributes->printer_type))
{
$printer_type = $this->printer_attributes->printer_type->_value0; $printer_type = $this->printer_attributes->printer_type->_value0;
$table = self::_interpretPrinterType($printer_type); $table = self::_interpretPrinterType($printer_type);
for($i = 0 ; $i < count($table) ; $i++ ) { for($i = 0 ; $i < count($table) ; $i++ )
{
$index = '_value'.$i; $index = '_value'.$i;
$this->printer_attributes->printer_type->$index = $table[$i]; $this->printer_attributes->printer_type->$index = $table[$i];
}
} }
}
return $result; return $result;
} }
// }}}
// //
// SETUP // SETUP
// //
protected function _initTags ()
// {{{ _initTags () {
protected function _initTags () {
// override parent with specific cups attributes // override parent with specific cups attributes
$operation_tags = array (); $operation_tags = array ();
@ -434,21 +502,19 @@ class CupsPrintIPP extends ExtendedPrintIPP {
); );
$this->job_tags = array_merge ($this->job_tags, $job_tags); $this->job_tags = array_merge ($this->job_tags, $job_tags);
} }
// }}}
//
// REQUEST BUILDING
//
// {{{ _enumBuild ($tag,$value)
protected function _enumBuild ($tag,$value) {
//
// REQUEST BUILDING
//
protected function _enumBuild ($tag,$value)
{
$value_built = parent::_enumBuild($tag,$value); $value_built = parent::_enumBuild($tag,$value);
switch ($tag)
switch ($tag) { {
case "cpi": case "cpi":
switch ($value) { switch ($value)
{
case '10': case '10':
$value_built = chr(10); $value_built = chr(10);
break; break;
@ -463,7 +529,8 @@ class CupsPrintIPP extends ExtendedPrintIPP {
} }
break; break;
case "lpi": case "lpi":
switch ($value) { switch ($value)
{
case '6': case '6':
$value_built = chr(6); $value_built = chr(6);
break; break;
@ -479,39 +546,42 @@ class CupsPrintIPP extends ExtendedPrintIPP {
$prepend = ''; $prepend = '';
while ((strlen($value_built) + strlen($prepend)) < 4) while ((strlen($value_built) + strlen($prepend)) < 4)
$prepend .= chr(0); $prepend .= chr(0);
return $prepend.$value_built; return $prepend.$value_built;
} }
// }}}
//
// RESPONSE PARSING
//
// {{{ _getAvailablePrinters ()
private function _getAvailablePrinters () {
//
// RESPONSE PARSING
//
private function _getAvailablePrinters ()
{
$this->available_printers = array(); $this->available_printers = array();
$this->printer_map = array();
$k = 0; $k = 0;
$this->printers_attributes = new stdClass(); $this->printers_attributes = new \stdClass();
for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++) for ($i = 0 ; (array_key_exists($i,$this->serveroutput->response)) ; $i ++)
if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes") { {
if (($this->serveroutput->response[$i]['attributes']) == "printer-attributes")
{
$phpname = "_printer".$k; $phpname = "_printer".$k;
$this->printers_attributes->$phpname = new stdClass(); $this->printers_attributes->$phpname = new \stdClass();
for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++) { for ($j = 0 ; array_key_exists($j,$this->serveroutput->response[$i]) ; $j++)
{
$value = $this->serveroutput->response[$i][$j]['value']; $value = $this->serveroutput->response[$i][$j]['value'];
$name = str_replace("-","_",$this->serveroutput->response[$i][$j]['name']); $name = str_replace("-","_",$this->serveroutput->response[$i][$j]['name']);
switch ($name) { switch ($name)
{
case "printer_uri_supported": case "printer_uri_supported":
$this->available_printers = array_merge($this->available_printers,array($value)); $this->available_printers = array_merge($this->available_printers,array($value));
break; break;
case "printer_type": case "printer_type":
$table = self::_interpretPrinterType($value); $table = self::_interpretPrinterType($value);
$this->printers_attributes->$phpname->$name = new stdClass(); $this->printers_attributes->$phpname->$name = new \stdClass();
for($l = 0 ; $l < count($table) ; $l++ ) { for($l = 0 ; $l < count($table) ; $l++ )
{
$index = '_value'.$l; $index = '_value'.$l;
$this->printers_attributes->$phpname->$name->$index = $table[$l]; $this->printers_attributes->$phpname->$name->$index = $table[$l];
} }
@ -519,20 +589,23 @@ class CupsPrintIPP extends ExtendedPrintIPP {
break; break;
case '': case '':
break; break;
case 'printer_name':
$this->printer_map[$value] = $k;
break;
default: default:
$this->printers_attributes->$phpname->$name = $value; $this->printers_attributes->$phpname->$name = $value;
break; break;
}
} }
$k ++;
} }
$k ++;
}
}
} }
// }}}
// {{{ _getEnumVendorExtensions protected function _getEnumVendorExtensions ($value_parsed)
protected function _getEnumVendorExtensions ($value_parsed) { {
switch ($value_parsed) { switch ($value_parsed)
{
case 0x4002: case 0x4002:
$value = 'Get-Availables-Printers'; $value = 'Get-Availables-Printers';
break; break;
@ -541,110 +614,152 @@ class CupsPrintIPP extends ExtendedPrintIPP {
break; break;
} }
if (isset($value)) if (isset($value))
return ($value); {
return ($value);
}
return sprintf('Unknown: 0x%x',$value_parsed); return sprintf('Unknown: 0x%x',$value_parsed);
} }
// }}}
// {{{ _interpretPrinterType($type)
private function _interpretPrinterType($value) { private function _interpretPrinterType($value)
{
$value_parsed = 0; $value_parsed = 0;
for ($i = strlen($value) ; $i > 0 ; $i --) for ($i = strlen($value) ; $i > 0 ; $i --)
{
$value_parsed += pow(256,($i - 1)) * ord($value[strlen($value) - $i]); $value_parsed += pow(256,($i - 1)) * ord($value[strlen($value) - $i]);
}
$type[0] = $type[1] = $type[2] = $type[3] = $type[4] = $type[5] = ''; $type[0] = $type[1] = $type[2] = $type[3] = $type[4] = $type[5] = '';
$type[6] = $type[7] = $type[8] = $type[9] = $type[10] = ''; $type[6] = $type[7] = $type[8] = $type[9] = $type[10] = '';
$type[11] = $type[12] = $type[13] = $type[14] = $type[15] = ''; $type[11] = $type[12] = $type[13] = $type[14] = $type[15] = '';
$type[16] = $type[17] = $type[18] = $type[19] = ''; $type[16] = $type[17] = $type[18] = $type[19] = '';
if ($value_parsed %2 == 1) { if ($value_parsed %2 == 1)
{
$type[0] = 'printer-class'; $type[0] = 'printer-class';
$value_parsed -= 1; $value_parsed -= 1;
} }
if ($value_parsed %4 == 2 ) {
if ($value_parsed %4 == 2 )
{
$type[1] = 'remote-destination'; $type[1] = 'remote-destination';
$value_parsed -= 2; $value_parsed -= 2;
} }
if ($value_parsed %8 == 4 ) {
if ($value_parsed %8 == 4 )
{
$type[2] = 'print-black'; $type[2] = 'print-black';
$value_parsed -= 4; $value_parsed -= 4;
} }
if ($value_parsed %16 == 8 ) {
if ($value_parsed %16 == 8 )
{
$type[3] = 'print-color'; $type[3] = 'print-color';
$value_parsed -= 8; $value_parsed -= 8;
} }
if ($value_parsed %32 == 16) {
if ($value_parsed %32 == 16)
{
$type[4] = 'hardware-print-on-both-sides'; $type[4] = 'hardware-print-on-both-sides';
$value_parsed -= 16; $value_parsed -= 16;
} }
if ($value_parsed %64 == 32) {
if ($value_parsed %64 == 32)
{
$type[5] = 'hardware-staple-output'; $type[5] = 'hardware-staple-output';
$value_parsed -= 32; $value_parsed -= 32;
} }
if ($value_parsed %128 == 64) {
if ($value_parsed %128 == 64)
{
$type[6] = 'hardware-fast-copies'; $type[6] = 'hardware-fast-copies';
$value_parsed -= 64; $value_parsed -= 64;
} }
if ($value_parsed %256 == 128) {
if ($value_parsed %256 == 128)
{
$type[7] = 'hardware-fast-copy-collation'; $type[7] = 'hardware-fast-copy-collation';
$value_parsed -= 128; $value_parsed -= 128;
} }
if ($value_parsed %512 == 256) {
if ($value_parsed %512 == 256)
{
$type[8] = 'punch-output'; $type[8] = 'punch-output';
$value_parsed -= 256; $value_parsed -= 256;
} }
if ($value_parsed %1024 == 512) {
if ($value_parsed %1024 == 512)
{
$type[9] = 'cover-output'; $type[9] = 'cover-output';
$value_parsed -= 512; $value_parsed -= 512;
} }
if ($value_parsed %2048 == 1024) {
if ($value_parsed %2048 == 1024)
{
$type[10] = 'bind-output'; $type[10] = 'bind-output';
$value_parsed -= 1024; $value_parsed -= 1024;
} }
if ($value_parsed %4096 == 2048) {
if ($value_parsed %4096 == 2048)
{
$type[11] = 'sort-output'; $type[11] = 'sort-output';
$value_parsed -= 2048; $value_parsed -= 2048;
} }
if ($value_parsed %8192 == 4096) {
if ($value_parsed %8192 == 4096)
{
$type[12] = 'handle-media-up-to-US-Legal-A4'; $type[12] = 'handle-media-up-to-US-Legal-A4';
$value_parsed -= 4096; $value_parsed -= 4096;
} }
if ($value_parsed %16384 == 8192) {
if ($value_parsed %16384 == 8192)
{
$type[13] = 'handle-media-between-US-Legal-A4-and-ISO_C-A2'; $type[13] = 'handle-media-between-US-Legal-A4-and-ISO_C-A2';
$value_parsed -= 8192; $value_parsed -= 8192;
} }
if ($value_parsed %32768 == 16384) {
if ($value_parsed %32768 == 16384)
{
$type[14] = 'handle-media-larger-than-ISO_C-A2'; $type[14] = 'handle-media-larger-than-ISO_C-A2';
$value_parsed -= 16384; $value_parsed -= 16384;
} }
if ($value_parsed %65536 == 32768) {
if ($value_parsed %65536 == 32768)
{
$type[15] = 'handle-user-defined-media-sizes'; $type[15] = 'handle-user-defined-media-sizes';
$value_parsed -= 32768; $value_parsed -= 32768;
} }
if ($value_parsed %131072 == 65536) {
if ($value_parsed %131072 == 65536)
{
$type[16] = 'implicit-server-generated-class'; $type[16] = 'implicit-server-generated-class';
$value_parsed -= 65536; $value_parsed -= 65536;
} }
if ($value_parsed %262144 == 131072) {
if ($value_parsed %262144 == 131072)
{
$type[17] = 'network-default-printer'; $type[17] = 'network-default-printer';
$value_parsed -= 131072; $value_parsed -= 131072;
} }
if ($value_parsed %524288 == 262144) {
if ($value_parsed %524288 == 262144)
{
$type[18] = 'fax-device'; $type[18] = 'fax-device';
$value_parsed -= 262144; $value_parsed -= 262144;
} }
return $type;
return $type;
} }
// }}}
// {{{ _interpretEnum()
protected function _interpretEnum($attribute_name,$value) {
protected function _interpretEnum($attribute_name,$value)
{
$value_parsed = self::_interpretInteger($value); $value_parsed = self::_interpretInteger($value);
switch ($attribute_name) { switch ($attribute_name)
{
case 'cpi': case 'cpi':
case 'lpi': case 'lpi':
$value = $value_parsed; $value = $value_parsed;
@ -652,20 +767,8 @@ class CupsPrintIPP extends ExtendedPrintIPP {
default: default:
$value = parent::_interpretEnum($attribute_name,$value); $value = parent::_interpretEnum($attribute_name,$value);
break; break;
} }
return $value;
return $value;
} }
// }}} }
};
/*
* Local variables:
* mode: php
* tab-width: 4
* c-basic-offset: 4
* End:
*/
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff