From: Chuck Hagenbuch Date: Sun, 30 May 2010 16:19:59 +0000 (-0400) Subject: Fix Horde_Scribe to use the thrift_root directory X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dc00d255ccffd03d4144024f8319b975e395f673;p=horde.git Fix Horde_Scribe to use the thrift_root directory --- diff --git a/framework/Scribe/lib/Horde/Thrift/packages/scribe/scribe_types.php b/framework/Scribe/lib/Horde/Thrift/packages/scribe/scribe_types.php deleted file mode 100644 index 186ceb854..000000000 --- a/framework/Scribe/lib/Horde/Thrift/packages/scribe/scribe_types.php +++ /dev/null @@ -1,117 +0,0 @@ - 0, - 'TRY_LATER' => 1, -); - -final class ResultCode { - const OK = 0; - const TRY_LATER = 1; - static public $__names = array( - 0 => 'OK', - 1 => 'TRY_LATER', - ); -} - -class LogEntry { - static $_TSPEC; - - public $category = null; - public $message = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 1 => array( - 'var' => 'category', - 'type' => TType::STRING, - ), - 2 => array( - 'var' => 'message', - 'type' => TType::STRING, - ), - ); - } - if (is_array($vals)) { - if (isset($vals['category'])) { - $this->category = $vals['category']; - } - if (isset($vals['message'])) { - $this->message = $vals['message']; - } - } - } - - public function getName() { - return 'LogEntry'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 1: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->category); - } else { - $xfer += $input->skip($ftype); - } - break; - case 2: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->message); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('LogEntry'); - if ($this->category !== null) { - $xfer += $output->writeFieldBegin('category', TType::STRING, 1); - $xfer += $output->writeString($this->category); - $xfer += $output->writeFieldEnd(); - } - if ($this->message !== null) { - $xfer += $output->writeFieldBegin('message', TType::STRING, 2); - $xfer += $output->writeString($this->message); - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - -?> diff --git a/framework/Scribe/lib/Horde/Thrift/scribe.php b/framework/Scribe/lib/Horde/Thrift/scribe.php deleted file mode 100644 index f66003e3d..000000000 --- a/framework/Scribe/lib/Horde/Thrift/scribe.php +++ /dev/null @@ -1,285 +0,0 @@ -send_Log($messages); - return $this->recv_Log(); - } - - public function send_Log($messages) - { - $args = new scribe_Log_args(); - $args->messages = $messages; - $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary'); - if ($bin_accel) - { - thrift_protocol_write_binary($this->output_, 'Log', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); - } - else - { - $this->output_->writeMessageBegin('Log', TMessageType::CALL, $this->seqid_); - $args->write($this->output_); - $this->output_->writeMessageEnd(); - $this->output_->getTransport()->flush(); - } - } - - public function recv_Log() - { - $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary'); - if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, 'scribe_Log_result', $this->input_->isStrictRead()); - else - { - $rseqid = 0; - $fname = null; - $mtype = 0; - - $this->input_->readMessageBegin($fname, $mtype, $rseqid); - if ($mtype == TMessageType::EXCEPTION) { - $x = new TApplicationException(); - $x->read($this->input_); - $this->input_->readMessageEnd(); - throw $x; - } - $result = new scribe_Log_result(); - $result->read($this->input_); - $this->input_->readMessageEnd(); - } - if ($result->success !== null) { - return $result->success; - } - throw new Exception("Log failed: unknown result"); - } - -} - -// HELPER FUNCTIONS AND STRUCTURES - -class scribe_Log_args { - static $_TSPEC; - - public $messages = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 1 => array( - 'var' => 'messages', - 'type' => TType::LST, - 'etype' => TType::STRUCT, - 'elem' => array( - 'type' => TType::STRUCT, - 'class' => 'LogEntry', - ), - ), - ); - } - if (is_array($vals)) { - if (isset($vals['messages'])) { - $this->messages = $vals['messages']; - } - } - } - - public function getName() { - return 'scribe_Log_args'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 1: - if ($ftype == TType::LST) { - $this->messages = array(); - $_size0 = 0; - $_etype3 = 0; - $xfer += $input->readListBegin($_etype3, $_size0); - for ($_i4 = 0; $_i4 < $_size0; ++$_i4) - { - $elem5 = null; - $elem5 = new LogEntry(); - $xfer += $elem5->read($input); - $this->messages []= $elem5; - } - $xfer += $input->readListEnd(); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('scribe_Log_args'); - if ($this->messages !== null) { - if (!is_array($this->messages)) { - throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); - } - $xfer += $output->writeFieldBegin('messages', TType::LST, 1); - { - $output->writeListBegin(TType::STRUCT, count($this->messages)); - { - foreach ($this->messages as $iter6) - { - $xfer += $iter6->write($output); - } - } - $output->writeListEnd(); - } - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - -class scribe_Log_result { - static $_TSPEC; - - public $success = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 0 => array( - 'var' => 'success', - 'type' => TType::I32, - ), - ); - } - if (is_array($vals)) { - if (isset($vals['success'])) { - $this->success = $vals['success']; - } - } - } - - public function getName() { - return 'scribe_Log_result'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 0: - if ($ftype == TType::I32) { - $xfer += $input->readI32($this->success); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('scribe_Log_result'); - if ($this->success !== null) { - $xfer += $output->writeFieldBegin('success', TType::I32, 0); - $xfer += $output->writeI32($this->success); - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - -class scribeProcessor extends FacebookServiceProcessor { - public function __construct($handler) { - parent::__construct($handler); - } - - public function process($input, $output) { - $rseqid = 0; - $fname = null; - $mtype = 0; - - $input->readMessageBegin($fname, $mtype, $rseqid); - $methodname = 'process_'.$fname; - if (!method_exists($this, $methodname)) { - $input->skip(TType::STRUCT); - $input->readMessageEnd(); - $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD); - $output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid); - $x->write($output); - $output->writeMessageEnd(); - $output->getTransport()->flush(); - return; - } - $this->$methodname($rseqid, $input, $output); - return true; - } - - protected function process_Log($seqid, $input, $output) { - $args = new scribe_Log_args(); - $args->read($input); - $input->readMessageEnd(); - $result = new scribe_Log_result(); - $result->success = $this->handler_->Log($args->messages); - $output->writeMessageBegin('Log', TMessageType::REPLY, $seqid); - $result->write($output); - $output->getTransport()->flush(); - } -} -?> diff --git a/framework/Scribe/lib/Horde/Thrift/thrift_root/packages/scribe/scribe_types.php b/framework/Scribe/lib/Horde/Thrift/thrift_root/packages/scribe/scribe_types.php new file mode 100644 index 000000000..186ceb854 --- /dev/null +++ b/framework/Scribe/lib/Horde/Thrift/thrift_root/packages/scribe/scribe_types.php @@ -0,0 +1,117 @@ + 0, + 'TRY_LATER' => 1, +); + +final class ResultCode { + const OK = 0; + const TRY_LATER = 1; + static public $__names = array( + 0 => 'OK', + 1 => 'TRY_LATER', + ); +} + +class LogEntry { + static $_TSPEC; + + public $category = null; + public $message = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'category', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'message', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['category'])) { + $this->category = $vals['category']; + } + if (isset($vals['message'])) { + $this->message = $vals['message']; + } + } + } + + public function getName() { + return 'LogEntry'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->category); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->message); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('LogEntry'); + if ($this->category !== null) { + $xfer += $output->writeFieldBegin('category', TType::STRING, 1); + $xfer += $output->writeString($this->category); + $xfer += $output->writeFieldEnd(); + } + if ($this->message !== null) { + $xfer += $output->writeFieldBegin('message', TType::STRING, 2); + $xfer += $output->writeString($this->message); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +?> diff --git a/framework/Scribe/lib/Horde/Thrift/thrift_root/scribe.php b/framework/Scribe/lib/Horde/Thrift/thrift_root/scribe.php new file mode 100644 index 000000000..f66003e3d --- /dev/null +++ b/framework/Scribe/lib/Horde/Thrift/thrift_root/scribe.php @@ -0,0 +1,285 @@ +send_Log($messages); + return $this->recv_Log(); + } + + public function send_Log($messages) + { + $args = new scribe_Log_args(); + $args->messages = $messages; + $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'Log', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('Log', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_Log() + { + $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, 'scribe_Log_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new scribe_Log_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new Exception("Log failed: unknown result"); + } + +} + +// HELPER FUNCTIONS AND STRUCTURES + +class scribe_Log_args { + static $_TSPEC; + + public $messages = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'messages', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => 'LogEntry', + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['messages'])) { + $this->messages = $vals['messages']; + } + } + } + + public function getName() { + return 'scribe_Log_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::LST) { + $this->messages = array(); + $_size0 = 0; + $_etype3 = 0; + $xfer += $input->readListBegin($_etype3, $_size0); + for ($_i4 = 0; $_i4 < $_size0; ++$_i4) + { + $elem5 = null; + $elem5 = new LogEntry(); + $xfer += $elem5->read($input); + $this->messages []= $elem5; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('scribe_Log_args'); + if ($this->messages !== null) { + if (!is_array($this->messages)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('messages', TType::LST, 1); + { + $output->writeListBegin(TType::STRUCT, count($this->messages)); + { + foreach ($this->messages as $iter6) + { + $xfer += $iter6->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class scribe_Log_result { + static $_TSPEC; + + public $success = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::I32, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + } + } + + public function getName() { + return 'scribe_Log_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->success); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('scribe_Log_result'); + if ($this->success !== null) { + $xfer += $output->writeFieldBegin('success', TType::I32, 0); + $xfer += $output->writeI32($this->success); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class scribeProcessor extends FacebookServiceProcessor { + public function __construct($handler) { + parent::__construct($handler); + } + + public function process($input, $output) { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $input->readMessageBegin($fname, $mtype, $rseqid); + $methodname = 'process_'.$fname; + if (!method_exists($this, $methodname)) { + $input->skip(TType::STRUCT); + $input->readMessageEnd(); + $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD); + $output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid); + $x->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + return; + } + $this->$methodname($rseqid, $input, $output); + return true; + } + + protected function process_Log($seqid, $input, $output) { + $args = new scribe_Log_args(); + $args->read($input); + $input->readMessageEnd(); + $result = new scribe_Log_result(); + $result->success = $this->handler_->Log($args->messages); + $output->writeMessageBegin('Log', TMessageType::REPLY, $seqid); + $result->write($output); + $output->getTransport()->flush(); + } +} +?> diff --git a/framework/Scribe/package.xml b/framework/Scribe/package.xml index c1c737470..55826ff50 100644 --- a/framework/Scribe/package.xml +++ b/framework/Scribe/package.xml @@ -39,12 +39,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - + + + + + + + + @@ -63,8 +65,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - + +