* @revision 03 * @license http://creativecommons.org/licenses/by-sa/2.0/de/ Creative Commons Attribution-Share Alike 2.0 Germany * @homepage http://oss.tiggerswelt.net/oscar/ * @copyright Copyright © 2008 tiggersWelt.net */ class Oscar_TLV_BartID extends Oscar_TLV { /* Type of this TLV */ const TYPE = 0x001D; /* Types */ const TYPE_BUDDY_ICON_SMALL = 0x0000; const TYPE_BUDDY_ICON = 0x0001; const TYPE_STATUS_STR = 0x0002; const TYPE_ARRIVE_SOUND = 0x0003; const TYPE_RICH_TEXT = 0x0004; const TYPE_SUPERBUDDY_ICON = 0x0005; const TYPE_RADIO_STATION = 0x0006; const TYPE_BUDDY_ICON_BIG = 0x000B; const TYPE_STATUS_STR_TOD = 0x000C; const TYPE_CURRENT_AV_TRACK = 0x000F; const TYPE_DEPART_SOUND = 0x0060; const TYPE_IM_CHROME = 0x0081; const TYPE_IM_SOUND = 0x0083; const TYPE_IM_CHROME_XML = 0x0088; const TYPE_IM_CHROME_IMMERS = 0x0089; const TYPE_EMOTICON_SET = 0x0400; const TYPE_ENCR_CERT_CHAIN = 0x0402; const TYPE_SIGN_CERT_CHAIN = 0x0403; const TYPE_GATEWAY_CERT = 0x0404; /* Flags */ const FLAG_CUSTOM = 0x01; const FLAG_DATA = 0x04; const FLAG_UNKNOWN = 0x40; const FLAG_REDIRECT = 0x80; public $Items = array (); // {{{ parse /** * Parse an incomming Message-TLV * * @access public * @return void */ public function parse () { while ($this->Data != "") { $Type = Oscar_Common::str2int16 ($this->Data, 0, true); $Flag = Oscar_Common::str2int8 ($this->Data, 0, true); $Data = Oscar_Common::string08 ($this->Data, 0, true); $this->Items [] = new Oscar_Bart_Item ($Type, $Flag, $Data); } } // }}} // {{{ generate /** * Generate this packet * * @access public * @return string */ public function generate () { $this->Data = ""; foreach ($this->Items as $Item) $this->Data .= Oscar_Common::int16tostr ($Item->Type) . Oscar_Common::int8tostr ($Item->Flag) . Oscar_Common::int8tostr (strlen ($Item->Data)) . $Item->Data; return parent::generate (); } // }}} public function addItem ($Type, $Flag, $Data) { $this->Items [] = new Oscar_Bart_Item ($Type, $Flag, $Data); } } class Oscar_Bart_Item { public $Type; public $Flag; public $Data; function __construct ($Type, $Flag, $Data) { // Handle Status-Strings # Little Hack: Status-Strings consists of an undocumented "StringTLV" # which is in fact an array of string16 (carried in a string08, # senseless!) if ($Type == Oscar_TLV_BartID::TYPE_STATUS_STR) { $Items = array (); while ($Data != "") $Items [] = Oscar_Common::string16 ($Data, 0, true); if (count ($Items) == 0) $Items [] = ""; $Data = utf8_encode (trim ($Items [0])); } elseif ($Flag == Oscar_TLV_BartID::FLAG_DATA) { $Len = Oscar_Common::str2int8 ($Data, 0, true); $xData = substr ($Data, 1, $Len - 1); $Data = ""; for ($i = 0; $i < strlen ($xData); $i++) if ($xData [$i] != "\x00") $Data .= $xData [$i]; } $this->Type = $Type; $this->Flag = $Flag; $this->Data = $Data; } } ?>