From: Brion Vibber Date: Mon, 22 Mar 2010 20:56:16 +0000 (-0700) Subject: Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 1.0.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e89908f26140c217e01b2f8f755712f38f3935f3;p=quix0rs-gnu-social.git Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 1.0.x Conflicts: lib/channel.php scripts/imdaemon.php --- e89908f26140c217e01b2f8f755712f38f3935f3 diff --cc classes/User.php index 15ec4ad946,8ad2ec63d5..1ba940a696 --- a/classes/User.php +++ b/classes/User.php @@@ -82,8 -91,9 +86,9 @@@ class User extends Memcached_DataObjec function updateKeys(&$orig) { + $this->_connect(); $parts = array(); - foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) { + foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) { if (strcmp($this->$k, $orig->$k) != 0) { $parts[] = $k . ' = ' . $this->_quote($this->$k); } diff --cc lib/channel.php index 05437b4e9e,689bca0be9..e83960ac54 --- a/lib/channel.php +++ b/lib/channel.php @@@ -47,6 -47,82 +47,25 @@@ class Channe } } + class CLIChannel extends Channel + { + function source() + { + return 'cli'; + } + + function output($user, $text) + { + $site = common_config('site', 'name'); + print "[{$user->nickname}@{$site}] $text\n"; + } + + function error($user, $text) + { + $this->output($user, $text); + } + } + -class XMPPChannel extends Channel -{ - - var $conn = null; - - function source() - { - return 'xmpp'; - } - - function __construct($conn) - { - $this->conn = $conn; - } - - function on($user) - { - return $this->set_notify($user, 1); - } - - function off($user) - { - return $this->set_notify($user, 0); - } - - function output($user, $text) - { - $text = '['.common_config('site', 'name') . '] ' . $text; - jabber_send_message($user->jabber, $text); - } - - function error($user, $text) - { - $text = '['.common_config('site', 'name') . '] ' . $text; - jabber_send_message($user->jabber, $text); - } - - function set_notify(&$user, $notify) - { - $orig = clone($user); - $user->jabbernotify = $notify; - $result = $user->update($orig); - if (!$result) { - $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - common_log(LOG_ERR, - 'Could not set notify flag to ' . $notify . - ' for user ' . common_log_objstring($user) . - ': ' . $last_error->message); - return false; - } else { - common_log(LOG_INFO, - 'User ' . $user->nickname . ' set notify flag to ' . $notify); - return true; - } - } -} - class WebChannel extends Channel { var $out = null; diff --cc lib/command.php index 5be9cd6e85,f7421269d0..c2116828c0 --- a/lib/command.php +++ b/lib/command.php @@@ -607,9 -650,9 +650,9 @@@ class OffCommand extends Comman parent::__construct($user); $this->other = $other; } - function execute($channel) + function handle($channel) { - if ($other) { + if ($this->other) { $channel->error($this->user, _("Command not yet implemented.")); } else { if ($channel->off($this->user)) { @@@ -630,9 -673,9 +673,9 @@@ class OnCommand extends Comman $this->other = $other; } - function execute($channel) + function handle($channel) { - if ($other) { + if ($this->other) { $channel->error($this->user, _("Command not yet implemented.")); } else { if ($channel->on($this->user)) { diff --cc lib/statusnet.php index afb8f5af02,eba9ab9b8e..776cfb579b --- a/lib/statusnet.php +++ b/lib/statusnet.php @@@ -339,13 -339,10 +339,9 @@@ class StatusNe } // Backwards compatibility - if (array_key_exists('memcached', $config)) { if ($config['memcached']['enabled']) { - if(class_exists('Memcached')) { - addPlugin('Memcached', array('servers' => $config['memcached']['server'])); - } else { - addPlugin('Memcache', array('servers' => $config['memcached']['server'])); - } + addPlugin('Memcache', array('servers' => $config['memcached']['server'])); } if (!empty($config['memcached']['base'])) { diff --cc scripts/imdaemon.php index 4a2c942234,0000000000..0ce74667c5 mode 100755,000000..100755 --- a/scripts/imdaemon.php +++ b/scripts/imdaemon.php @@@ -1,101 -1,0 +1,118 @@@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'fi::a'; +$longoptions = array('id::', 'foreground', 'all'); + +$helptext = <<allsites = $allsites; + } + + function runThread() + { + common_log(LOG_INFO, 'Waiting to listen to IM connections and queues'); + - $master = new ImMaster($this->get_id()); ++ $master = new ImMaster($this->get_id(), $this->processManager()); + $master->init($this->allsites); + $master->service(); + + common_log(LOG_INFO, 'terminating normally'); + + return $master->respawn ? self::EXIT_RESTART : self::EXIT_SHUTDOWN; + } + +} + +class ImMaster extends IoMaster +{ ++ protected $processManager; ++ ++ function __construct($id, $processManager) ++ { ++ parent::__construct($id); ++ $this->processManager = $processManager; ++ } ++ + /** + * Initialize IoManagers for the currently configured site + * which are appropriate to this instance. + */ + function initManagers() + { + $classes = array(); + if (Event::handle('StartImDaemonIoManagers', array(&$classes))) { + $qm = QueueManager::get(); + $qm->setActiveGroup('im'); + $classes[] = $qm; ++ $classes[] = $this->processManager; + } + Event::handle('EndImDaemonIoManagers', array(&$classes)); + foreach ($classes as $class) { + $this->instantiate($class); + } + } +} + ++if (version_compare(PHP_VERSION, '5.2.6', '<')) { ++ $arch = php_uname('m'); ++ if ($arch == 'x86_64' || $arch == 'amd64') { ++ print "Aborting daemon - 64-bit PHP prior to 5.2.6 has known bugs in stream_select; you are running " . PHP_VERSION . " on $arch.\n"; ++ exit(1); ++ } ++} ++ +if (have_option('i', 'id')) { + $id = get_option_value('i', 'id'); +} else if (count($args) > 0) { + $id = $args[0]; +} else { + $id = null; +} + +$foreground = have_option('f', 'foreground'); +$all = have_option('a') || have_option('--all'); + +$daemon = new ImDaemon($id, !$foreground, 1, $all); + +$daemon->runOnce();