* @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_Auth_Login extends Oscar_SNAC_Helper_TLV { const SNAC_FAMILY = 0x0017; const SNAC_SERVICE = 0x0002; // {{{ __construct /** * Create a new login-SNAC * * @param object $Parent (optional) Our parent OSCAR-Instance * @param string $Username (optional) Which username * * @access friendly * @return void */ function __construct ($Parent = null, $Username = null, $Password = null, $Key = null) { // Inherit to our parent parent::__construct ($Parent); // Set username if ($Username !== null) $this->setUsername ($Username); if (($Password !== null) && ($Key !== null)) $this->setPassword ($Password, $Key); // Add some TLVs by default self::addTLV (new Oscar_TLV_Logon_Clientname ($Parent)); self::addTLV (new Oscar_TLV_Logon_Major ($Parent)); self::addTLV (new Oscar_TLV_Logon_Minor ($Parent)); self::addTLV (new Oscar_TLV_Logon_Point ($Parent)); self::addTLV (new Oscar_TLV_Logon_Build ($Parent)); /** * 0x4C * 0x16 0x010A * 0x14 0x00007537 * 0x0F 0x6465 * 0x0E 0x6465 * 0x94 0x00 **/ // Unimplemented, tough hacked # TODO: Implement this self::addTLV (new Oscar_TLV ($Parent, 0x4C, "")); self::addTLV (new Oscar_TLV ($Parent, 0x16, "\x01\x0A")); self::addTLV (new Oscar_TLV ($Parent, 0x14, "\x00\x00\x75\x37")); self::addTLV (new Oscar_TLV ($Parent, 0x0F, "de")); self::addTLV (new Oscar_TLV ($Parent, 0x0E, "de")); self::addTLV (new Oscar_TLV ($Parent, 0x94, "\x00")); } // }}} // {{{ getTLVClasses /** * Retrive a list of prefered TLV-Types for this SNAC * * @access protected * @return array */ protected function getTLVClasses () { return array ( "Oscar_TLV_Logon_Username", "Oscar_TLV_Logon_Password", "Oscar_TLV_Logon_Clientname", "Oscar_TLV_Logon_Major", "Oscar_TLV_Logon_Minor", "Oscar_TLV_Logon_Point", "Oscar_TLV_Logon_Build", ); } // }}} // {{{ setUsername /** * Set username for this SNAC * * @param string $Username * * @access public * @return void */ public function setUsername ($Username) { if (is_object ($TLV = self::findTLV ("Oscar_TLV_Logon_Username"))) $TLV->Value = $Username; else parent::addTLV (new Oscar_TLV_Logon_Username ($this->Parent, $Username)); } // }}} // {{{ setPassword /** * Set password for this SNAC * * @param string $Password * @param string $Key * * @access public * @return void */ public function setPassword ($Password, $Key) { if (is_object ($TLV = self::findTLV ("Oscar_TLV_Logon_Password"))) $TLV->setPassword ($Password, $Key); else parent::addTLV (new Oscar_TLV_Logon_Password ($this->Parent, $Password, $Key)); } // }}} } ?>