Skip to content

Commit

Permalink
Start to support XEP-0231: Bits of Binary
Browse files Browse the repository at this point in the history
  • Loading branch information
edhelas committed Feb 21, 2016
1 parent 6e92332 commit 3a348d2
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Moxl/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ private function end($parser, $name)

$this->depth--;

if($this->raw != false) {
if($this->raw != false
&& $this->depth > $this->raw) {
$this->handler[0] .= '</'.$name.'>';
}

Expand Down
15 changes: 15 additions & 0 deletions src/Moxl/Stanza/BOB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Moxl\Stanza;

class BOB {
static function answer($to, $id, $cid, $type, $base64) {
$dom = new \DOMDocument('1.0', 'UTF-8');
$data = $dom->createElementNS('urn:xmpp:bob', 'data', $base64);
$data->setAttribute('cid', $cid);
$data->setAttribute('type', $type);
$data->setAttribute('max-age', '86400');

\Moxl\API::request(\Moxl\API::iqWrapper($data, $to, 'result', $id));
}
}
7 changes: 6 additions & 1 deletion src/Moxl/Stanza/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ static function maker(

if($html != false) {
$xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html');
$body = $dom->createElement('http://www.w3.org/1999/xhtml', 'body', $html);
$body = $dom->createElementNS('http://www.w3.org/1999/xhtml', 'body');

$dom2 = new \DOMDocument('1.0', 'UTF-8');
$dom2->loadXml('<root>'.$html.'</root>');
$bar = $dom2->documentElement->firstChild; // we want to import the bar tree
$body->appendChild($dom->importNode($bar, TRUE));

$xhtml->appendChild($body);
$root->appendChild($xhtml);
Expand Down
54 changes: 54 additions & 0 deletions src/Moxl/Xec/Action/BOB/Answer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Moxl\Xec\Action\BOB;

use Moxl\Xec\Action;
use Moxl\Stanza\BOB;

class Answer extends Action
{
private $_to;
private $_base64;
private $_cid;
private $_type;
private $_id;

public function request()
{
$this->store();
BOB::answer($this->_to, $this->_id, $this->_cid, $this->_type, $this->_base64);
}

public function setTo($to)
{
$this->_to = $to;
return $this;
}

public function setBase64($base64)
{
$this->_base64 = $base64;
return $this;
}

public function setCid($cid)
{
$this->_cid = $cid;
return $this;
}

public function setType($type)
{
$this->_type = $type;
return $this;
}

public function setId($id)
{
$this->_id = $id;
return $this;
}

public function handle($stanza, $parent = false) {
}
}
2 changes: 2 additions & 0 deletions src/Moxl/Xec/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ static public function searchPayload($hash, $s, $sparent = false) {
'fa9d41e26f664d9056618a4afe213861' => 'Post',

'9952d726429340d482ecac82c1496191' => 'BOB',

'4c9681f0e9aca8a5b65f86b8b80d490f' => 'DiscoInfo',
//'482069658b024085fbc4e311fb771fa6' => 'DiscoInfo',//?
Expand Down
15 changes: 15 additions & 0 deletions src/Moxl/Xec/Payload/BOB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Moxl\Xec\Payload;

class BOB extends Payload
{
public function handle($stanza, $parent = false) {
$from = (string)$parent->attributes()->from;
$cid = (string)$stanza->attributes()->cid;
$id = (string)$parent->attributes()->id;

$this->pack(array($from, $id, $cid));
$this->deliver();
}
}

0 comments on commit 3a348d2

Please sign in to comment.