Skip to content

Commit

Permalink
Fixed xmlns attribute placing
Browse files Browse the repository at this point in the history
  • Loading branch information
shirioko committed Mar 23, 2014
1 parent cc93f10 commit 6d9f98c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/php/WhatsAppEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,10 @@ function fireMessageReceivedServer(
$phone,
$from,
$msgid,
$type,
$time
$type
) {
$callbackEvent = function(WhatsAppEventListener $listener) use ($phone, $from, $msgid, $type, $time) {
$listener->onMessageReceivedServer($phone, $from, $msgid, $type, $time);
$callbackEvent = function(WhatsAppEventListener $listener) use ($phone, $from, $msgid, $type) {
$listener->onMessageReceivedServer($phone, $from, $msgid, $type);
};
$this->fireCallback($callbackEvent);
}
Expand Down
3 changes: 1 addition & 2 deletions src/php/events/WhatsAppEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ function onMessageReceivedServer(
$phone, // The user phone number including the country code.
$from, // The sender JID.
$msgid, // The message id.
$type, // The message type.
$time // The unix time when send message notification.
$type // The message type.
);

function onPing(
Expand Down
3 changes: 1 addition & 2 deletions src/php/events/WhatsAppEventListenerProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ function onMessageReceivedServer(
$phone,
$from,
$msgid,
$type,
$time
$type
) {
$this->handleEvent(__FUNCTION__, func_get_args());
}
Expand Down
23 changes: 11 additions & 12 deletions src/php/whatsprot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,15 @@ protected function processInboundDataNode(ProtocolNode $node, $autoReceipt = tru
$node->getChild(0)->getTag()
);
}
elseif($node->getTag() == '' && $node->getAttribute("class") == "message")
{
$this->eventManager()->fireMessageReceivedServer(
$this->phoneNumber,
$node->getAttribute('from'),
$node->getAttribute('id'),
$node->getAttribute('class')
);
}
if ($node->getTag() == "message") {
array_push($this->messageQueue, $node);

Expand Down Expand Up @@ -1978,15 +1987,6 @@ protected function processInboundDataNode(ProtocolNode $node, $autoReceipt = tru
$this->sendMessageReceived($node);
}
}
if ($node->getChild('x') != null) {
$this->eventManager()->fireMessageReceivedServer(
$this->phoneNumber,
$node->getAttribute('from'),
$node->getAttribute('id'),
$node->getAttribute('type'),
$node->getAttribute('t')
);
}
if ($node->getChild('received') != null) {
$this->eventManager()->fireMessageReceivedClient(
$this->phoneNumber,
Expand Down Expand Up @@ -2796,9 +2796,7 @@ protected function sendSetPicture($jid, $filepath)
$data = fread($fp, filesize($filepath));
if ($data) {
//this is where the fun starts
$hash = array();
$hash["xmlns"] = "w:profile:picture";
$picture = new ProtocolNode("picture", $hash, null, $data);
$picture = new ProtocolNode("picture", null, null, $data);

$icon = createIconGD($filepath, 96, true);
$thumb = new ProtocolNode("picture", array("type" => "preview"), null, $icon);
Expand All @@ -2808,6 +2806,7 @@ protected function sendSetPicture($jid, $filepath)
$hash["id"] = $nodeID;
$hash["to"] = $this->getJID($jid);
$hash["type"] = "set";
$hash["xmlns"] = "w:profile:picture";
$node = new ProtocolNode("iq", $hash, array($picture, $thumb), null);

$this->sendNode($node);
Expand Down

0 comments on commit 6d9f98c

Please sign in to comment.