* @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_Incoming_Message extends Oscar_SNAC_Helper_TLV { /* About this class */ const SNAC_FAMILY = 0x0004; const SNAC_SERVICE = 0x0007; public $Cookie = ""; public $Channel = 0; public $Username = ""; public $WarnLevel = 0; // {{{ getTLVClasses /** * Retrive a list of prefered TLV-Types for this SNAC * * @access protected * @return array */ protected function getTLVClasses () { return Oscar_SNAC_ICBM_Message::getTLVClasses (); } // }}} // {{{ 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->Data = substr ($this->Data, 10); // Parse NickInfo-Block parent::parseBuddyInfo (); // Parse remaining TLVs parent::parse (); // Insert the message in our parent and update userdata if (is_object ($Parent = self::getOSCAR ())) { $Handled = false; // Check if there is an extension registered for this message if ($this->Channel == 0x0002) { $Data = null; $Capa = null; $Capas = $Parent->getCapabilities (); // Try to find a TLV-Data-Packet foreach ($this->TLVs as $TLV) if ($TLV instanceof Oscar_TLV_Rendezvous) { $Data = $TLV; break; } // Try to find a matching capability if (is_object ($Data) && (count ($Capas) > 0)) foreach ($Capas as $sCapa) if ($sCapa->matchGUID ($Data->Service)) { $Capa = $sCapa; break; } if ($Handled = is_object ($Capa)) $Capa->handle ($this, $Data); } // Insert message as normal message if not handled elsewhere if (!$Handled) $Parent->receiveMessage ($this->Username, $this->getMessage (), $this->getEncoding ()); } } // }}} // {{{ generate /** * Generate a new message * * @access public * @return string */ public function generate () { $this->Prepend = $this->Cookie . Oscar_Common::int16tostr ($this->Channel) . Oscar_Common::int8tostr (strlen ($this->Username)) . $this->Username . Oscar_Common::int16tostr ($this->WarnLevel) . Oscar_Common::int16tostr (count ($this->TLVs)); return parent::generate (); } // }}} // {{{ getMessage /** * Retrive content of this message * * @access public * @return string */ public function getMessage () { if (is_object ($TLV = self::findTLV ("Oscar_TLV_Message"))) return $TLV->getMessage (); } // }}} // {{{ getEncoding /** * Retrive encoding of this message * * @access public * @return string */ public function getEncoding () { if (is_object ($TLV = self::findTLV ("Oscar_TLV_Message"))) return $TLV->getEncoding (); } // }}} } ?>