* @revision 03 * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Share Alike 3.0 Germany * @homepage http://oss.tiggerswelt.net/oscar/ * @copyright Copyright © 2009 tiggersWelt.net */ require_once ("oscar/snac/helper/tlv.php"); class Oscar_SNAC_ICBM_Message extends Oscar_SNAC_Helper_TLV { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0006; public $Cookie = ""; public $Channel = 0; public $Username = ""; // {{{ getTLVClasses /** * Retrive a list of prefered TLV-Types for this SNAC * * @access protected * @return array */ protected function getTLVClasses () { return array ( "Oscar_TLV_Message", "Oscar_TLV_Message_RequestACK", "Oscar_TLV_Message_Auto", "Oscar_TLV_Message_Store", "Oscar_TLV_Message_Bart", "Oscar_TLV_Message_ID", "Oscar_TLV_Message_Params", "Oscar_TLV_Message_Sendtime", "Oscar_TLV_Rendezvous", "Oscar_TLV_Events_Supported", ); } // }}} // {{{ parse /** * @access public * @return void * @todo Learn a lot more about this! */ public function parse () { // Get non-TLV-Info from input $this->Cookie = substr ($this->Data, 0, 8); $this->Channel = Oscar_Common::str2int16 ($this->Data, 8); $this->Username = Oscar_Common::string08 ($this->Data, 9); // Truncate this data $this->Data = substr ($this->Data, 10 + $Length); // Parse remaining TLVs parent::parse (); } // }}} // {{{ generate /** * Generate a new message * * @access public * @return string */ public function generate () { if ($this->Cookie == "") $this->Cookie = substr (time (), 0, 8); $this->Prepend = $this->Cookie . Oscar_Common::int16tostr ($this->Channel) . Oscar_Common::toString08 ($this->Username); return parent::generate (); } // }}} // {{{ setMessage /** * Set Message of this packet * * @param string $Message * * @access public * @return void */ public function setMessage ($Message, $Encoding = null) { // Set new Channel $this->Channel = 0x01; if (!is_object ($TLV = parent::findTLV ("Oscar_TLV_Message"))) self::addTLV (new Oscar_TLV_Message ($this->Parent, $Message, $Encoding)); else $TLV->setMessage ($Message, $Encoding); } // }}} // {{{ setReceiver /** * Set Receiver of this message * * @param string $To Receiver of this message * * @access public * @return void */ public function setReceiver ($To) { $this->Username = $To; } // }}} } ?>