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/
50 class AimPlugin extends ImPlugin
53 public $password = null;
54 public $publicFeed = array();
56 public $transport = 'aim';
58 function getDisplayName()
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');
100 include_once $dir . '/'.strtolower($cls).'.php';
103 include_once $dir . '/'. $cls .'.php';
110 function onStartImDaemonIoManagers(&$classes)
112 parent::onStartImDaemonIoManagers(&$classes);
113 $classes[] = new AimManager($this); // handles sending/receiving
117 function microiduri($screenname)
119 return 'aim:' . $screenname;
122 function sendMessage($screenname, $body)
124 $this->fake_aim->sendIm($screenname, $body);
125 $this->enqueueOutgoingRaw($this->fake_aim->would_be_sent);
130 * Accept a queued input message.
132 * @return true if processing completed, false if message should be reprocessed
134 function receiveRawMessage($message)
136 $info=Aim::getMessageInfo($message);
137 $from = $info['from'];
138 $user = $this->getUser($from);
139 $notice_text = $info['message'];
141 $this->handleIncoming($from, $notice_text);
146 function initialize(){
147 if(!isset($this->user)){
148 throw new Exception("must specify a user");
150 if(!isset($this->password)){
151 throw new Exception("must specify a password");
154 $this->fake_aim = new Fake_Aim($this->user,$this->password,4);
158 function onPluginVersion(&$versions)
160 $versions[] = array('name' => 'AIM',
161 'version' => STATUSNET_VERSION,
162 'author' => 'Craig Andrews',
163 'homepage' => 'http://status.net/wiki/Plugin:AIM',
165 _m('The AIM plugin allows users to send and receive notices over the AIM network.'));