Exemplo n.º 1
0
 public static function fromIQStanza(Stanza &$stanza)
 {
     return new self($stanza->tag()->getChild('query/x'));
 }
Exemplo n.º 2
0
 private function handleIQ(Stanza $stanza)
 {
     // XEP-0050 command execution
     if (!is_null($command = $stanza->tag()->getChild('command'))) {
         isset($this->commands[$node = $command->getAttribute('node')]) && is_callable($this->commands[$node][1]) ? call_user_func($this->commands[$node][1], $stanza) : $stanza->reply()->serviceUnavailable();
     }
     if (!is_null($query = $stanza->tag()->getChild('query')) && $query->getAttribute('node') == 'http://jabber.org/protocol/commands') {
         return $stanza->reply()->myCommands($this->commands);
     }
     if ($stanza->to() == $this->component_name) {
         return $this->handleComponentIQ($stanza);
     }
     if ($query_type = $stanza->queryType()) {
         if (is_callable(@$this->handlers['iq/query'][$query_type])) {
             return call_user_func($this->handlers['iq/query'][$query_type], $stanza);
         } else {
             $this->log("no IQ query handler for query xmlns = {$query_type}", PHP_COMPONENT_MESSAGE_WARNING, true);
             if ($stanza->type() != 'error') {
                 return $stanza->reply()->serviceUnavailable();
             }
         }
     }
     if ($stanza->tag()->hasChild('vCard')) {
         return is_callable(@$this->handlers['iq/vCard']) ? call_user_func($this->handlers['iq/vCard'], $stanza) : $stanza->reply()->vCardServiceUnavailable();
     }
     foreach (array('open', 'close', 'data', 'si') as $k => $v) {
         if ($stanza->tag()->hasChild($v)) {
             return is_callable(@$this->handlers["iq/{$v}"]) ? call_user_func($this->handlers["iq/{$v}"], $stanza) : $stanza->reply()->serviceUnavailable();
         }
     }
 }