* @revision 05 * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Share Alike 3.0 Germany * @homepage http://oss.tiggerswelt.net/xmpp * @copyright Copyright © 2009 tiggersWelt.net */ require_once ('phpEvents/socket/stream/xml/tag.php'); require_once ('tiggerXMPP/extension.php'); class tiggerXMPP_XEP_0092 extends tiggerXMPP_Extension { /* Our Namespace */ const XEP_NAMESPACE = 'jabber:iq:version'; /* Variables for XEP-0092 */ private $__XEP0092_Name = "tiggerXMP"; private $__XEP0092_Version = "0.1 Alpha"; private $__XEP0092_OS = PHP_OS; // {{{ getTags /** * Retrive a list of all tags we handle for a given namespace * * @param string $Namespace * * @access public * @return array **/ public function getTags ($NS = "") { return array ("query"); } // }}} // {{{ handle /** * Handle incoming packets for XEP 0092 * * @param object $Tag Incoming packet * * @access protected * @return object */ public function handle ($Tag) { $this->__debug (tiggerXMPP_Stream::DEBUG_DEBUG, "called.", __FUNCTION__, __LINE__, __CLASS__, __FILE__); $Resp = new phpEvents_Socket_Stream_XML_Tag ('query'); $Resp->setNamespace (self::XEP_NAMESPACE); $tagName = new phpEvents_Socket_Stream_XML_Tag ('name', $Resp, $this->__XEP0092_Name); $tagVersion = new phpEvents_Socket_Stream_XML_Tag ('version', $Resp, $this->__XEP0092_Version); $tagOS = new phpEvents_Socket_Stream_XML_Tag ('os', $Resp, $this->__XEP0092_OS); return $Resp; } // }}} // {{{ setVersion /** * Set Software-Version according to XEP-0092 * * @param string $Name Name of this software * @param string $Version Version of this software * @param string $OS Operating System currently running * * @access public * @return void */ public function setVersion ($Name, $Version, $OS) { $this->__XEP0092_Name = $Name; $this->__XEP0092_Version = $Version; $this->__XEP0092_OS = $OS; } // }}} // {{{ getVersion /** * Retrive Software-Version according to XEP-0092 * * @param string $JID (optional) Retrive versioning information from this JID * * @access public * @return object */ public function getVersion ($JID = null) { $Obj = new stdclass; if ($JID == null) { $Obj->Name = $this->__XEP0092_Name; $Obj->Version = $this->__XEP0092_Version; $Obj->OS = $this->__XEP0092_OS; } elseif (is_object ($P = $this->getParent ())) { $Resp = new phpEvents_Socket_Stream_XML_Tag ('iq'); $Resp->setOriginator ($P->getJID ()); $Resp->setDestination ($JID); $Resp->setAttribute ('id', $P->getUniqueID ()); $Resp->setAttribute ('type', 'get'); $tagQuery = new phpEvents_Socket_Stream_XML_Tag ('query', $Resp); $tagQuery->setNamespace (self::XEP_NAMESPACE); $P->sendXML ($Resp); $Resp = $P->waitBlock (array (), $Resp->getAttribute ('id')); if ($Resp->haveSubtags ('error')) return false; if (is_object ($tag = $Resp->getSubtagByName ('name'))) $Obj->Name = $tag->getValue (); if (is_object ($tag = $Resp->getSubtagByName ('version'))) $Obj->Version = $tag->getValue (); if (is_object ($tag = $Resp->getSubtagByName ('os'))) $Obj->OS = $tag->getValue (); } return $Obj; } // }}} } ?>