* @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 */ class Oscar_SNAC_Service_ClientOnline extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x0002; private $Groups = array (); // {{{ scanGroups /** * Scan ourself for supported service groups * * @access public * @return void */ public function scanGroups () { // Load all classes $Classes = get_declared_classes (); foreach ($Classes as $Class) { if (!is_subclass_of ($Class, "Oscar_SNAC") || !defined ($Group = $Class . "::SNAC_FAMILY")) continue; $GroupID = constant ($Group); if (!isset ($this->Groups [$GroupID])) $this->Groups [$GroupID] = array ( "ID" => $GroupID, "Version" => 0, "ToolID" => 0, "ToolVersion" => 0, ); if (defined ($ver = $Class . "::SNAC_VERSION")) $this->Groups [$GroupID]["Version"] = max ($this->Groups [$GroupID]["Version"], constant ($ver)); if (defined ($toolid = $Class . "::SNAC_VERSION")) $this->Groups [$GroupID]["ToolID"] = max ($this->Groups [$GroupID]["ToolID"], constant ($toolid)); if (defined ($toolver = $Class . "::SNAC_VERSION")) $this->Groups [$GroupID]["ToolVersion"] = max ($this->Groups [$GroupID]["ToolVersion"], constant ($toolver)); } foreach ($this->Groups as $ID=>$Group) if (($Group ["Version"] < 1) || ($Group ["ToolID"] < 1) || ($Group ["ToolVersion"] < 1)) unset ($this->Groups [$ID]); return $this->Groups; } // }}} // {{{ getGroups /** * Retrive list of supported service groups * * @access public * @return array */ public function getGroups () { if (count ($this->Groups) < 1) self::scanGroups (); return $this->Groups; } // }}} // {{{ parse /** * Parse an incoming packet * * @access public * @return void */ public function parse () { $this->Groups = array (); while (strlen ($this->Data) < 7) { $groupID = Oscar_Common::str2int16 ($this->Data, 0, true); $this->Groups [$groupID] = array ( "ID" => $groupID, "Version" => Oscar_Common::str2int16 ($this->Data, 0, true), "ToolID" => Oscar_Common::str2int16 ($this->Data, 0, true), "ToolVersion" => Oscar_Common::str2int16 ($this->Data, 0, true), ); } } // }}} // {{{ generate /** * Create string-representation of this class * * @access public * @return string */ public function generate () { $Groups = self::getGroups (); $this->Data = ""; foreach ($Groups as $Group) $this->Data .= Oscar_Common::int16tostr ($Group ["ID"]) . Oscar_Common::int16tostr ($Group ["Version"]) . Oscar_Common::int16tostr ($Group ["ToolID"]) . Oscar_Common::int16tostr ($Group ["ToolVersion"]); return parent::generate (); } // }}} } ?>