Browse Source

- Adding a patch to jaxl to handle incoming unknown request (iq)

- Implement Vcard handling
- Remove old file
TODO :
-Fix XML/JS error
pull/5/head
Jaussoin Timothée 15 years ago
parent
commit
29471b4a57
  1. 8
      lib/EventHandler.php
  2. 1
      lib/Jaxl/xep/jaxl.0054.php
  3. 1
      lib/Jaxl/xmpp/xmpp.get.php
  4. 43
      lib/XMPPConnect.php
  5. 55
      lib/widgets/Chat.php
  6. 18
      lib/widgets/Friends/Friends.php
  7. 1
      themes/movim/page.tpl

8
lib/EventHandler.php

@ -30,10 +30,10 @@ class EventHandler
$payload = ob_get_clean();
if(trim(rtrim($payload)) != "") {
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<movimcontainer>';
echo $payload;
echo '</movimcontainer>';
echo '<?xml version="1.0" encoding="UTF-8" ?>'
.'<movimcontainer>'
.$payload
.'</movimcontainer>';
}
}
}

1
lib/Jaxl/xep/jaxl.0054.php

@ -88,6 +88,7 @@
}
}
?>

1
lib/Jaxl/xmpp/xmpp.get.php

@ -195,6 +195,7 @@
}
public static function iq($arr, $jaxl) {
$jaxl->executePlugin('jaxl_get_iq', $arr);
switch($arr['type']) {
case 'get':
$jaxl->executePlugin('jaxl_get_iq_get', $arr);

43
lib/XMPPConnect.php

@ -80,17 +80,52 @@ class XMPPConnect
$this->jaxl->addPlugin('jaxl_post_auth_failure', array(&$this, 'postAuthFailure'));
//$this->jaxl->addPlugin('jaxl_post_disconnect', array(&$this, 'postDisconnect'));
$this->jaxl->addPlugin('jaxl_get_iq', array(&$this, 'handle'));
//$this->jaxl->addPlugin('jaxl_post_roster_update', array(&$this, 'postRosterUpdate'));
$this->jaxl->addPlugin('jaxl_get_auth_mech', array(&$this, 'postAuthMech'));
$this->jaxl->addPlugin('jaxl_get_message', array(&$this, 'getMessage'));
$this->jaxl->addPlugin('jaxl_get_presence', array(&$this, 'getPresence'));
$this->jaxl->addPlugin('jaxl_get_bosh_curl_error', array(&$this, 'boshCurlError'));
}
public function handle($payload) {
//if($payload['vCard'] == $this->jaxl->JAXL0053->$ns) {
$evt = new EventHandler();
$evt->runEvent('vcardreceived', $payload);
//}
/*ob_start();
var_dump($payload);
$tab_debug=ob_get_contents();
ob_end_clean();
$fichier=fopen(BASE_PATH."log/movim.log",'w');
fwrite($fichier,$tab_debug);
fclose($fichier);
*/
//$evt = new EventHandler();
//$evt->runEvent('all', $payload);
/*
$filename = BASE_PATH."log/movim.log";
$f = fopen($filename,"w");
//if(filesize($filename)>=0)
//$tmp = fread($f, filesize($filename));
fwrite($f, $payload);
fclose($f);*/
}
public function postRosterUpdate($payload) {
//var_dump($payload);
$evt = new EventHandler();
$evt->runEvent('rosterreceived', $payload);
}
public function postAuth($test, $test2) {
$f = fopen(BASE_PATH."log/movim.log","w");
/*$f = fopen(BASE_PATH."log/movim.log","w");
fwrite($f, "gna");
fclose($f);
fclose($f);*/
}
@ -125,7 +160,7 @@ class XMPPConnect
public function getVCard()
{
//$this->jaxl->JAXL0054('getVCard', false, $this->jaxl->jid, array(&$this, 'vcardReturn'));
$this->jaxl->JAXL0054('getVCard', false, $this->jaxl->jid, false);
}
public function vcardReturn($payload)
@ -216,7 +251,7 @@ class XMPPConnect
*/
public function getRosterList()
{
$this->jaxl->getRosterList(array(&$this, 'handlePayload'));
$this->jaxl->getRosterList();
}
/**

55
lib/widgets/Chat.php

@ -1,55 +0,0 @@
<?php
/**
* @file Chat.php
* This file is part of MOVIM.
*
* @brief A jabber chat widget.
*
* @author Guillaume Pasquet <etenil@etenilsrealm.nl>
*
* @version 1.0
* @date 20 October 2010
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
class Chat extends Widget
{
function WidgetLoad()
{
$this->registerEvent('incomechat', 'onIncomingChat');
$this->registerEvent('incomepresence', 'onIncomingPresence');
}
function onIncomingChat($event)
{
echo "onIncomingChat was called. Message: $event";
}
function onIncomingPresence($event)
{
echo "onIncomingPresence was called. Message: $event";
}
function build()
{
?>
<div id="chat">
<div id="chatMessages">
<p>Tagada: blah blah blah</p>
<p>Pouet: Gna gna gna!</p>
</div>
<input type="text" id="chatInput" />
<input type="button" id="chatSend" value="<?php echo t('Send');?>"/>
<input type="button" onclick="<?php $this->callAjax('ajaxStuff', 'APPEND', "'testzone'", '3');?>" value="Message" />
</div>
<?php
}
}
?>

18
lib/widgets/Friends/Friends.php

@ -32,10 +32,10 @@ class Friends extends Widget
function ajaxRefreshVcard()
{
echo date('Y-m-d H:i:s') . '<br />';
/*echo date('Y-m-d H:i:s') . '<br />';
echo "TOTO!!!!";
*/
$user = new User();
$xmpp = XMPPConnect::getInstance($user->getLogin());
$xmpp->getVCard(); // We send the vCard request
@ -51,7 +51,7 @@ class Friends extends Widget
<input type="button"
onclick="<?php $this->callAjax('ajaxRefreshVcard', 'FILL', "'testzone'");?>"
value="Refresh vcard" />
<div id='tinylist'>
<div id="tinylist">
<ul>
</ul>
</div>
@ -59,14 +59,18 @@ class Friends extends Widget
</div>
<?php
// We send a request to fetch the vcard straight away.
$user = new User();
$xmpp = XMPPConnect::getInstance($user->getLogin()); // We get the instance of the connexion
$xmpp->getVCard(); // We send the vCard request
//$user = new User();
//$xmpp = XMPPConnect::getInstance($user->getLogin()); // We get the instance of the connexion
//$xmpp->getVCard(); // We send the vCard request
}
function onVcardReceived($vcard)
{
$this->sendto('testzone', 'FILL', var_export($vcard, true));
//if(isset($vcard['vCardNickname'])) {
// $result = "nickname :". $vcard['vCardNickname'];
//$result = "reçu";
//}
//$this->sendto('testzone', 'FILL', $vcard2);
}
}

1
themes/movim/page.tpl

@ -14,7 +14,6 @@
<?php $this->menu();?>
</div>
<div id="content">
<input type="button" onclick="halt_poll()" value="Clear"/>
<?php $this->content();?>
<div id="footer">
© <a href="http://www.movim.eu">Movim</a> - 2010 | Under <a href="http://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License</a>

Loading…
Cancel
Save