3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2009, StatusNet, Inc.
6 * Send and receive notices using the AIM network
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Craig Andrews <candrews@integralblue.com>
26 * @copyright 2009 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
32 // This check helps protect against security problems;
33 // your code file can't be executed directly from the web.
36 // We bundle the phptoclib library...
37 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/phptoclib');
44 * @author Craig Andrews <candrews@integralblue.com>
45 * @copyright 2009 StatusNet, Inc.
46 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
47 * @link http://status.net/
49 class AimPlugin extends ImPlugin
52 public $password = null;
53 public $publicFeed = array();
55 public $transport = 'aim';
57 function getDisplayName()
59 // TRANS: Display name.
63 function normalize($screenname)
65 $screenname = str_replace(" ","", $screenname);
66 return strtolower($screenname);
69 function daemonScreenname()
74 function validate($screenname)
76 if(preg_match('/^[a-z]\w{2,15}$/i', $screenname)) {
84 * Load related modules when needed
86 * @param string $cls Name of the class to be loaded
88 * @return boolean hook value; true means continue processing, false means stop.
90 function onAutoload($cls)
92 $dir = dirname(__FILE__);
97 require_once(INSTALLDIR.'/plugins/Aim/extlib/phptoclib/aimclassw.php');
101 return parent::onAutoload($cls);
104 function onStartImDaemonIoManagers(&$classes)
106 parent::onStartImDaemonIoManagers($classes);
107 $classes[] = new AimManager($this); // handles sending/receiving
111 function microiduri($screenname)
113 return 'aim:' . $screenname;
116 function sendMessage($screenname, $body)
118 $this->fake_aim->sendIm($screenname, $body);
119 $this->enqueueOutgoingRaw($this->fake_aim->would_be_sent);
124 * Accept a queued input message.
126 * @return true if processing completed, false if message should be reprocessed
128 function receiveRawMessage($message)
130 $info=Aim::getMessageInfo($message);
131 $from = $info['from'];
132 $user = $this->getUser($from);
133 $notice_text = $info['message'];
135 $this->handleIncoming($from, $notice_text);
140 function initialize(){
141 if(!isset($this->user)){
142 // TRANS: Exception thrown in AIM plugin when user has not been specified.
143 throw new Exception(_m('Must specify a user.'));
145 if(!isset($this->password)){
146 // TRANS: Exception thrown in AIM plugin when password has not been specified.
147 throw new Exception(_m('Must specify a password.'));
150 $this->fake_aim = new Fake_Aim($this->user,$this->password,4);
154 function onPluginVersion(array &$versions)
156 $versions[] = array('name' => 'AIM',
157 'version' => GNUSOCIAL_VERSION,
158 'author' => 'Craig Andrews',
159 'homepage' => 'http://status.net/wiki/Plugin:AIM',
161 // TRANS: Plugin description.
162 _m('The AIM plugin allows users to send and receive notices over the AIM network.'));