Exemple #1
0
 public static function ping($jaxl, $to, $from, $callback)
 {
     if ($jaxl->auth) {
         $payload = "<ping xmlns='urn:xmpp:ping'/>";
         return XMPPSend::iq($jaxl, 'get', $payload, $to, $from, $callback);
     }
 }
Exemple #2
0
 public static function submitSearchRequest($jaxl, $field, $callback)
 {
     $payload = '<query xmlns="' . self::$ns . '">';
     $payload .= $field;
     $payload .= '</query>';
     return XMPPSend::iq($jaxl, 'set', false, false, $callback);
 }
Exemple #3
0
 public static function handshake($id, $jaxl)
 {
     $pass = JAXLPlugin::execute('jaxl_pre_handshake');
     $hash = strtolower(sha1($id . $pass));
     $xml = '<handshake>' . $hash . '</handshake>';
     XMPPSend::xml($xml, $jaxl);
 }
Exemple #4
0
 public static function getXML($jaxl, $xml, $callback)
 {
     $payload = '<query xmlns="' . self::$ns . '">';
     $payload .= $xml;
     $payload .= '</query>';
     return XMPPSend::iq($jaxl, 'get', $payload, false, false, $callback);
 }
Exemple #5
0
 public static function register($jaxl, $from, $to, $callback, $fields)
 {
     $payload = '<query xmlns="' . self::$ns . '">';
     foreach ($fields as $field => $value) {
         $payload .= '<' . $field . '>' . $value . '</' . $field . '>';
     }
     $payload .= '</query>';
     return XMPPSend::iq($jaxl, 'set', $payload, $to, $from, $callback);
 }
Exemple #6
0
 public static function handleIq($payload, $jaxl)
 {
     if ($payload['time'] == self::$ns) {
         $entityTime = '<time xmlns="' . self::$ns . '">';
         $entityTime .= '<tzo>' . date('P') . '</tzo>';
         $entityTime .= '<utc>' . date('Y-m-d') . 'T' . date('H:i:s') . 'Z</utc>';
         $entityTime .= '</time>';
         return XMPPSend::iq('result', $entityTime, $payload['from'], $payload['to'], false, $jaxl);
     }
 }
Exemple #7
0
 public static function handleMessage($payloads, $jaxl)
 {
     foreach ($payloads as $payload) {
         if ($payload['request'] == self::$ns) {
             $child = array();
             $child['payload'] = '<received xmlns="' . self::$ns . '" id="' . $payload['id'] . '"/>';
             XMPPSend::message($jaxl, $payload['from'], $payload['to'], $child, false, false);
         }
     }
     return $payloads;
 }
Exemple #8
0
 public static function getIq($arr)
 {
     if (isset($arr['queryXmlns']) && $arr['queryXmlns'] == self::$ns) {
         $payload = '';
         $payload .= '<query xmlns="' . self::$ns . '" seconds="0">';
         $payload .= '</query>';
         return XMPPSend::iq('result', $payload, $arr['from'], $arr['to'], FALSE, $arr['id']);
     } else {
         return $arr;
     }
 }
Exemple #9
0
 public static function invite($toJid, $fromJid, $roomJid, $roomPass = false, $reason = false, $jaxl)
 {
     $child = array();
     $child['payload'] = '';
     $child['payload'] .= '<x xmlns="' . self::$ns . '"';
     $child['payload'] .= ' jid="' . $roomJid . '"';
     if ($roomPass) {
         $child['payload'] .= ' password="******"';
     }
     if ($reason) {
         $child['payload'] .= ' reason="' . $reason . '"';
     }
     $child['payload'] .= '/>';
     XMPPSend::message($toJid, $fromJid, $child, 'chat', $jaxl, false);
 }
Exemple #10
0
 public static function updateAffiliation($jaxl, $to, $from, $node, $jid, $affiliation)
 {
     if (!is_array($jid) && !is_array($affiliation)) {
         $jid[] = $jid;
         $affiliation[] = $affiliation;
     }
     $payload = '';
     $payload .= '<pubsub xmlns="' . self::$ns . '">';
     $payload .= '<affiliations node="' . $node . '">';
     foreach ($jid as $k => $v) {
         $payload .= '<affiliation jid="' . $jid[$k] . '" affiliation="' . $affiliation[$k] . '"/>';
     }
     $payload .= '</affiliations>';
     $payload .= '</pubsub>';
     return XMPPSend::iq($jaxl, 'set', $payload, $to, $from, $callback);
 }
Exemple #11
0
 public static function success($arr, $jaxl)
 {
     if ($arr['xmlns'] == "urn:ietf:params:xml:ns:xmpp-sasl") {
         if ($jaxl->mode == "cgi") {
             JAXL0206::restartStream($jaxl);
         } else {
             XMPPSend::startStream($jaxl);
         }
     }
 }
Exemple #12
0
 public static function transferFile($payload, $jaxl)
 {
     if (!isset(self::$id[$payload['id']])) {
         return $payload;
     }
     // iq id buffered for file transfer, transmit data
     $fp = fopen(self::$id[$payload['id']]['file'], 'r');
     fseek($fp, self::$id[$payload['id']]['seq'] * self::$id[$payload['id']]['block-size']);
     $data = fread($fp, self::$id[$payload['id']]['block-size']);
     fclose($fp);
     if (self::$id[$payload['id']]['seq'] == -1) {
         $jaxl->log("[[JAXL0047]] File transfer complete for siId " . self::$id[$payload['id']]['siId']);
         $jaxl->executePlugin('jaxl_post_file_transfer', self::$id[$payload['id']]);
         unset(self::$id[$payload['id']]);
         return;
     } else {
         if (strlen($data) == 0) {
             $jaxl->log("[[JAXL0047]] File transfer closed for siId " . self::$id[$payload['id']]['siId']);
             $xml = '<close xmlns="' . self::$ns . '" sid="' . self::$id[$payload['id']]['siId'] . '"/>';
             $id = XMPPSend::iq($jaxl, 'set', $xml, self::$id[$payload['id']]['to'], false, array('JAXL0047', 'transferFile'));
             self::$id[$id] = self::$id[$payload['id']];
             self::$id[$id]['seq'] = -1;
             unset(self::$id[$payload['id']]);
             return $id;
         } else {
             $jaxl->log("[[JAXL0047]] Transfering file data for seq " . self::$id[$payload['id']]['seq'] . " for siId " . self::$id[$payload['id']]['siId']);
             $xml = '<data xmlns="' . self::$ns . '" seq="' . self::$id[$payload['id']]['seq'] . '" sid="' . self::$id[$payload['id']]['siId'] . '">';
             $xml .= base64_encode($data);
             $xml .= '</data>';
             $id = XMPPSend::iq($jaxl, 'set', $xml, self::$id[$payload['id']]['to'], false, array('JAXL0047', 'transferFile'));
             self::$id[$id] = self::$id[$payload['id']];
             self::$id[$id]['seq'] = self::$id[$id]['seq'] + 1;
             unset(self::$id[$payload['id']]);
             return $id;
         }
     }
 }
Exemple #13
0
 /**
  * Send an XMPP iq stanza
  *
  * @param string $type Type of iq stanza to send
  * @param string $payload (Optional) XML string to be transmitted
  * @param string $to (Optional) JID to whom this iq stanza should be send
  * @param string $from (Optional) JID from whom this presence stanza should originate
  * @param string|array $callback (Optional) Callback method which will handle "result" type stanza rcved
  * @param integer $id (Optional) Add an id attribute to transmitted stanza (auto-generated if not provided)
  */
 function sendIQ($type, $payload = false, $to = false, $from = false, $callback = false, $id = false)
 {
     return XMPPSend::iq($this, $type, $payload, $to, $from, $callback, $id);
 }
Exemple #14
0
 public static function activateS5B($streamHost, $sid, $tJid, $jaxl)
 {
     $xml = '<query xmlns="' . self::$ns . '" sid="' . $sid . '">';
     $xml .= '<activate>' . $tJid . '</activate>';
     $xml .= '</query>';
     return XMPPSend::iq($jaxl, 'set', $xml, $streamHost, false, array('JAXL0065', 'transferFile'));
 }
Exemple #15
0
 public static function executeCommand($to, $from, $node, $callback, $jaxl)
 {
     $payload = '<command xmlns="' . self::$ns . '" node="' . $node . '" action="execute"/>';
     return XMPPSend::iq('set', $payload, $to, $from, $callback, $jaxl);
 }
Exemple #16
0
 /**
  * Perform pre-choosen auth type for the Jaxl instance
  */
 function doAuth($mechanism)
 {
     return XMPPSend::startAuth($this);
 }
Exemple #17
0
 public static function ping($jaxl)
 {
     $xml = '';
     $xml .= '<body rid="' . ++$jaxl->bosh['rid'] . '"';
     $xml .= ' sid="' . $jaxl->bosh['sid'] . '"';
     $xml .= ' xmlns="http://jabber.org/protocol/httpbind"/>';
     $_SESSION['auth'] = true;
     XMPPSend::xml($xml, $jaxl);
 }
Exemple #18
0
 public static function setDefaultList($jaxl, $list, $callback)
 {
     $payload = '<query xmlns="' . self::$ns . '">';
     if ($list) {
         $payload .= '<default name="' . $list . '"/>';
     } else {
         $payload .= '<default/>';
     }
     $payload .= '</query>';
     return XMPPSend::iq($jaxl, 'set', false, false, $callback);
 }
Exemple #19
0
 public static function unblockAll($jaxl, $callback)
 {
     $payload = '<unblock xmlns="' . self::$ns . '"/>';
     return XMPPSend::iq($jaxl, 'set', $payload, false, false, $callback);
 }
Exemple #20
0
 public static function removeAdminPrivileges($jaxl, $fromJid, $toJid, $roomJid, $reason = false, $callback = false)
 {
     $payload = '<query xmlns="' . self::$ns . '#admin">';
     $payload .= '<item affiliation="member" jid="' . $toJid . '">';
     if ($reason) {
         $payload .= '<reason>' . $reason . '</reason>';
     }
     $payload .= '</item>';
     $payload .= '</query>';
     return XMPPSend::iq($jaxl, "set", $payload, $roomJid, $fromJid, $callback);
 }
Exemple #21
0
 protected static function submitForm($to, $from, $payload, $node, $sid, $jaxl)
 {
     $payload = '<command xmlns="http://jabber.org/protocol/commands" node="' . $node . '" sessionid="' . $sid . '">' . $payload . '</command>';
     return XMPPSend::iq('set', $payload, $to, $from, array('JAXL0133', 'handleForm'), $jaxl);
 }
Exemple #22
0
 public static function accept($jaxl, $to, $id, $payload)
 {
     $payload = '<si xmlns="' . self::$ns . '">' . $payload . '</si>';
     return XMPPSend::iq($jaxl, 'result', $payload, $to, false, false, $id);
 }
 /**
  * Bind connected Jaxl instance to a resource
  */
 function startBind()
 {
     return XMPPSend::startBind($this, array('XMPPGet', 'postBind'));
 }
Exemple #24
0
 public static function getVersion($jaxl, $fromJid, $toJid, $callback)
 {
     $payload = '<query xmlns="' . self::$ns . '">';
     return XMPPSend::iq($jaxl, 'get', $payload, $fromJid, $toJid, $callback);
 }
Exemple #25
0
 public static function ping($to, $from, $callback, $jaxl)
 {
     $payload = "<ping xmlns='urn:xmpp:ping'/>";
     return XMPPSend::iq('get', $payload, $to, $from, $callback, $jaxl);
 }
Exemple #26
0
 public static function sendInfoMessage($jaxl, $to, $payload, $sid, $initiator, $callback)
 {
     $xml = self::getJingleElement($payload, 'session-info', $sid, $initiator);
     return XMPPSend::iq($jaxl, 'set', $xml, $to, false, $callback);
 }
Exemple #27
0
 public static function handleIq($payload, $jaxl)
 {
     if ($payload['queryXmlns'] == self::$ns['info']) {
         $xml = '<query xmlns="' . $payload['queryXmlns'] . '"';
         if (isset($payload['queryNode'])) {
             $xml .= ' node="' . $payload['queryNode'] . '"';
         }
         $xml .= '>';
         $xml .= '<identity xml:lang="' . $jaxl->lang . '"';
         $xml .= ' name="' . $jaxl->getName() . '"';
         $xml .= ' category="' . $jaxl->category . '"';
         $xml .= ' type="' . $jaxl->type . '"/>';
         foreach ($jaxl->features as $feature) {
             $xml .= '<feature var="' . $feature . '"/>';
         }
         $xml .= '</query>';
         XMPPSend::iq($jaxl, 'result', $xml, $payload['from'], $payload['to'], false, $payload['id']);
     } else {
         if ($payload['queryXmlns'] == self::$ns['items']) {
         }
     }
     return $payload;
 }
Exemple #28
0
 function sendPresence($to, $from, $child, $type)
 {
     XMPPSend::presence($to, $from, $child, $type, $this);
 }
Exemple #29
0
 public static function getVCard($jaxl, $to, $from, $callback)
 {
     $payload = '<vCard xmlns="' . self::$ns . '"/>';
     return XMPPSend::iq($jaxl, 'get', $payload, $to, $from, $callback);
 }
Exemple #30
0
 function startBind()
 {
     $payload = '';
     $payload .= '<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">';
     $payload .= '<resource>' . $this->resource . '</resource>';
     $payload .= '</bind>';
     return XMPPSend::iq("set", $payload, false, false, array('XMPPGet', 'postBind'), $this);
 }