* @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 */ /** * Remarks * ------- * You might part NickInfo structures through SNAC_TLV::parseBuddyInfo **/ /** * Subtypes in 0x0001 (undones only) * 0x0004 Request for new service * 0x0005 Redirect (for 0x0004 subtype) * 0x0009 Delete rate limits group * 0x000A Rate information changed / rate limit warning * 0x0010 * 0x0011 * 0x0012 * 0x0014 * 0x0015 * 0x0016 * 0x001F * 0x0020 * 0x0021 */ require_once ("oscar/snac.php"); require_once ("oscar/snac/helper/tlv.php"); require_once ("oscar/snac/helper/error.php"); require_once ("oscar/snac/service/clientonline.php"); require_once ("oscar/snac/service/hostonline.php"); require_once ("oscar/snac/service/clientgroups.php"); require_once ("oscar/snac/service/servergroups.php"); require_once ("oscar/snac/service/status.php"); class Oscar_SNAC_Service extends Oscar_SNAC { const SNAC_FAMILY = 0x0001; const SNAC_VERSION = 0x0004; const SNAC_TOOLID = 0x0110; const SNAC_TOOL_VERSION = 0x164F; } class Oscar_SNAC_Service_Error extends Oscar_SNAC_Helper_Error { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x0001; } class Oscar_SNAC_Service_MessageOfTheDay extends Oscar_SNAC_Helper_TLV { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x0013; /* Type of Message */ const TYPE_MDT_UPGRADE = 0x0001; const TYPE_ADV_UPGRADE = 0x0002; const TYPE_ANNOUNCEMENT = 0x0003; const TYPE_NOTICE = 0x0004; const TYPE_NEWS = 0x0006; public $Type = 0; // {{{ __constuct /** * Create such object * * @param object $Parent (optional) * * @access public * @return void */ public function __construct (&$Parent = null) { parent::__construct ($Parent); } // }}} // {{{ parse /** * Parse this object * * @access public * @return void * @todo Here may something be handled ;-) */ public function parse () { $this->Type = Oscar_Common::str2int16 ($this->Data, 0, true); parent::parse (); } // }}} // {{{ generate /** * Prepare for submission * * @access public * @return string */ public function generate () { $this->Data = Oscar_Common::int16tostr ($this->Type); $HaveMOTD = false; foreach ($this->TLVs as $TLV) { if ($TLV instanceof Oscar_TLV_MOTD) $HaveMOTD = true; $this->Data .= $TLV->generate (); } if (!$HaveMOTD) { $TLV = new Oscar_TLV_MOTD ($this->Parent); $this->Data .= $TLV->generate (); } return Oscar_SNAC::generate (); } // }}} // {{{ getMessage /** * Retrive Message of the day * * @access public * @return string */ public function getMessage () { if (is_array ($this->TLVs)) foreach ($this->TLVs as $TLV) if ($TLV instanceof OscarTLV_MOTD) return $TLV->getMessage (); } // }}} } class Oscar_SNAC_Service_Rate_Accept extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x0008; private $RateInfo = null; // {{{ __construct /** * Create a new Rate ACK Packet * * @param object $Parent (optional) * @param object $RateInfo (optional) * * @access public * @return void */ public function __construct (&$Parent = null, &$RateInfo = null) { parent::__construct ($Parent); self::setRateInfo ($RateInfo); } // }}} // {{{ setRateInfo /** * Set RateInfo-Packet to accept * * @param object $RateInfo * * @access public * @return void */ public function setRateInfo (&$RateInfo) { $this->RateInfo = $RateInfo; } // }}} // {{{ generate /** * Generate a RateInfo ACK * * @access public * @return string */ public function generate () { $this->Data = ""; if (is_object ($this->RateInfo) && is_array ($Rates = $this->RateInfo->getRates ())) foreach ($Rates as $Rate) $this->Data .= OSCAR_Common::int16tostr ($Rate ["ID"]); return parent::generate (); } // }}} } class Oscar_SNAC_Service_Server_Pause extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x000B; protected $Families = array (); // {{{ __construct /** * Create a new Pause-Packet * * @param object $Parent Parented OSCAR-Object * @param array $Families (optional) Families for this class * * @access public * @return void */ public function __construct (&$Parent, $Families = array ()) { $this->setFamilies ($Families); parent::__construct ($Parent); } // }}} // setFamilies /** * Set Families for this class * * @access public * @return void */ public function setFamilies ($Families) { $this->Families = $Families; } // }}} // {{{ parse /** * Handle incomming events * * @param bool $AutoSuspend (optional) Auto-Suspend parented FLAP (default) * * @access public * @return void */ public function parse ($AutoSuspend = true) { // Reset families $this->Families = array (); while ($this->Data != "") $this->Families [$Family = OSCAR_Common::str2int16 ($this->Data, 0, true)] = $Family; // Auto-Suspend parent if ($AutoSuspend && is_object ($OSCAR = self::getOSCAR ()) && is_object ($FLAP = $OSCAR->getFLAP ())) $FLAP->suspend ($this->Families); } // }}} // {{{ generate /** * Generate a string for submission * * @access public * @return string */ public function generate () { $this->Data = ""; foreach ($this->Families as $Family) $this->Data .= OSCAR_Common::int16tostr ($Family); return parent::generate (); } // }}} } class Oscar_SNAC_Service_Server_Pause_ACK extends Oscar_SNAC_Service_Server_Pause { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x000C; } class Oscar_SNAC_Service_Server_Resume extends Oscar_SNAC_Service_Server_Pause { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x000D; // {{{ parse /** * Handle incomming events * * @access public * @return void */ public function parse () { parent::parse (false); if (is_object ($OSCAR = self::getOSCAR ()) && is_object ($FLAP = $Parent->getFLAP ())) $FLAP->resume ($this->Families); } // }}} } class Oscar_SNAC_Service_Request_Own_Online_Info extends Oscar_SNAC { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x000E; } class Oscar_SNAC_Service_Online_Info extends Oscar_SNAC_Helper_TLV { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x000F; public $Nickname = ""; public $Warnlevel = 0; // {{{ parse /** * @access public * @return void * @todo Get this to work even better! */ public function parse () { parent::parseBuddyInfo (); } // }}} } class Oscar_SNAC_Service_Status_Info extends Oscar_SNAC_Helper_TLV { /* About this class */ const SNAC_FAMILY = 0x0001; const SNAC_SERVICE = 0x001E; // {{{ __construct /** * Constructor of this object * * @param object $Parent (optional) * @param enum $Status (optional) * * @access public * @return void */ public function __construct (&$Parent = null, $Status = null, $Message = null) { parent::__construct ($Parent); // Create Status-TLV if ($Status !== null) $this->TLVs [] = new Oscar_TLV_Status ($Parent, $Status); // Create Message-TLV if ($Message !== null) { $this->TLVs [] = $TLV = new Oscar_TLV_BartID ($Parent); # Little hack (fix this!) $Message = OSCAR_Common::int16tostr (strlen ($Message)) . $Message . OSCAR_Common::int16tostr (0x00); $TLV->addItem (Oscar_TLV_BartID::TYPE_STATUS_STR, Oscar_TLV_BartID::FLAG_DATA, $Message); } } // }}} // {{{ setStatus /** * Set Status on this record * * @param enum $Status * * @access public * @return void */ public function setStatus ($Status) { if (is_object ($TLV = self::findTLV (Oscar_TLV_Status::TYPE))) $TLV->Status = $Status; else self::addTLV (new Oscar_TLV_Status ($Parent, $Status)); } // }}} } ?>