diff options
author | Brion Vibber <brion@pobox.com> | 2010-04-30 14:41:54 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-04-30 15:29:05 -0700 |
commit | 5414396a2ee9f1401d69b60969e04a1941e24e21 (patch) | |
tree | 5b6f503f01d6d8e3eda4e9cf26ce1a74d28473c0 /plugins | |
parent | e3e90b4c27e27bbdd293767071dea3d7b5022046 (diff) |
IM cleanup on 1.0.x branch:
* Fake_XMPP back to Queued_XMPP, refactor how we use it and don't create objects and load classes until we need them.
* fix fatal error in IM settings while waiting for a Jabber confirmation.
* Caching fix for user_im_prefs
* fix for saving multiple transport settings
* some fixes for AIM & using normalized addresses for lookups
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Aim/AimPlugin.php | 9 | ||||
-rw-r--r-- | plugins/Aim/README | 2 | ||||
-rw-r--r-- | plugins/Xmpp/Queued_XMPP.php (renamed from plugins/Xmpp/Fake_XMPP.php) | 17 | ||||
-rw-r--r-- | plugins/Xmpp/XmppPlugin.php | 27 |
4 files changed, 36 insertions, 19 deletions
diff --git a/plugins/Aim/AimPlugin.php b/plugins/Aim/AimPlugin.php index 3855d1fb0..30da1dbc7 100644 --- a/plugins/Aim/AimPlugin.php +++ b/plugins/Aim/AimPlugin.php @@ -126,6 +126,11 @@ class AimPlugin extends ImPlugin return true; } + /** + * Accept a queued input message. + * + * @return true if processing completed, false if message should be reprocessed + */ function receive_raw_message($message) { $info=Aim::getMessageInfo($message); @@ -133,7 +138,9 @@ class AimPlugin extends ImPlugin $user = $this->get_user($from); $notice_text = $info['message']; - return $this->handle_incoming($from, $notice_text); + $this->handle_incoming($from, $notice_text); + + return true; } function initialize(){ diff --git a/plugins/Aim/README b/plugins/Aim/README index 046591738..7d486a036 100644 --- a/plugins/Aim/README +++ b/plugins/Aim/README @@ -6,7 +6,7 @@ add "addPlugin('aim', array('setting'=>'value', 'setting2'=>'value2', ...);" to the bottom of your config.php -The daemon included with this plugin must be running. It will be started by +scripts/imdaemon.php included with StatusNet must be running. It will be started by the plugin along with their other daemons when you run scripts/startdaemons.sh. See the StatusNet README for more about queuing and daemons. diff --git a/plugins/Xmpp/Fake_XMPP.php b/plugins/Xmpp/Queued_XMPP.php index 0f7cfd3b4..73eff2246 100644 --- a/plugins/Xmpp/Fake_XMPP.php +++ b/plugins/Xmpp/Queued_XMPP.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Instead of sending XMPP messages, retrieve the raw XML that would be sent + * Queue-mediated proxy class for outgoing XMPP messages. * * PHP version 5 * @@ -31,13 +31,17 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -class Fake_XMPP extends XMPPHP_XMPP +class Queued_XMPP extends XMPPHP_XMPP { - public $would_be_sent = null; + /** + * Reference to the XmppPlugin object we're hooked up to. + */ + public $plugin; /** * Constructor * + * @param XmppPlugin $plugin * @param string $host * @param integer $port * @param string $user @@ -47,8 +51,10 @@ class Fake_XMPP extends XMPPHP_XMPP * @param boolean $printlog * @param string $loglevel */ - public function __construct($host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null) + public function __construct($plugin, $host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null) { + $this->plugin = $plugin; + parent::__construct($host, $port, $user, $password, $resource, $server, $printlog, $loglevel); // We use $host to connect, but $server to build JIDs if specified. @@ -73,7 +79,7 @@ class Fake_XMPP extends XMPPHP_XMPP */ public function send($msg, $timeout=NULL) { - $this->would_be_sent = $msg; + $this->plugin->enqueue_outgoing_raw($msg); } //@{ @@ -110,5 +116,6 @@ class Fake_XMPP extends XMPPHP_XMPP throw new Exception("Can't read stream from fake XMPP."); } //@} + } diff --git a/plugins/Xmpp/XmppPlugin.php b/plugins/Xmpp/XmppPlugin.php index 03bf47fea..a2521536b 100644 --- a/plugins/Xmpp/XmppPlugin.php +++ b/plugins/Xmpp/XmppPlugin.php @@ -60,8 +60,6 @@ class XmppPlugin extends ImPlugin public $transport = 'xmpp'; - protected $fake_xmpp; - function getDisplayName(){ return _m('XMPP/Jabber/GTalk'); } @@ -292,7 +290,7 @@ class XmppPlugin extends ImPlugin require_once 'XMPP.php'; return false; case 'Sharing_XMPP': - case 'Fake_XMPP': + case 'Queued_XMPP': require_once $dir . '/'.$cls.'.php'; return false; case 'XmppManager': @@ -317,9 +315,7 @@ class XmppPlugin extends ImPlugin function send_message($screenname, $body) { - $this->fake_xmpp->message($screenname, $body, 'chat'); - $this->enqueue_outgoing_raw($this->fake_xmpp->would_be_sent); - return true; + $this->queuedConnection()->message($screenname, $body, 'chat'); } function send_notice($screenname, $notice) @@ -327,8 +323,7 @@ class XmppPlugin extends ImPlugin $msg = $this->format_notice($notice); $entry = $this->format_entry($notice); - $this->fake_xmpp->message($screenname, $msg, 'chat', null, $entry); - $this->enqueue_outgoing_raw($this->fake_xmpp->would_be_sent); + $this->queuedConnection()->message($screenname, $msg, 'chat', null, $entry); return true; } @@ -385,10 +380,19 @@ class XmppPlugin extends ImPlugin return true; } - return $this->handle_incoming($from, $pl['body']); + $this->handle_incoming($from, $pl['body']); + + return true; } - function initialize(){ + /** + * Build a queue-proxied XMPP interface object. Any outgoing messages + * will be run back through us for enqueing rather than sent directly. + * + * @return Queued_XMPP + * @throws Exception if server settings are invalid. + */ + function queuedConnection(){ if(!isset($this->server)){ throw new Exception("must specify a server"); } @@ -402,7 +406,7 @@ class XmppPlugin extends ImPlugin throw new Exception("must specify a password"); } - $this->fake_xmpp = new Fake_XMPP($this->host ? + return new Queued_XMPP($this, $this->host ? $this->host : $this->server, $this->port, @@ -415,7 +419,6 @@ class XmppPlugin extends ImPlugin $this->debug ? XMPPHP_Log::LEVEL_VERBOSE : null ); - return true; } function onPluginVersion(&$versions) |