123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/phptoclib');
- class AimPlugin extends ImPlugin
- {
- public $user = null;
- public $password = null;
- public $publicFeed = array();
- public $transport = 'aim';
- function getDisplayName()
- {
-
- return _m('AIM');
- }
- function normalize($screenname)
- {
- $screenname = str_replace(" ","", $screenname);
- return strtolower($screenname);
- }
- function daemonScreenname()
- {
- return $this->user;
- }
- function validate($screenname)
- {
- if(preg_match('/^[a-z]\w{2,15}$/i', $screenname)) {
- return true;
- }else{
- return false;
- }
- }
-
- function onAutoload($cls)
- {
- $dir = dirname(__FILE__);
- switch ($cls)
- {
- case 'Aim':
- require_once(INSTALLDIR.'/plugins/Aim/extlib/phptoclib/aimclassw.php');
- return false;
- }
- return parent::onAutoload($cls);
- }
- function onStartImDaemonIoManagers(&$classes)
- {
- parent::onStartImDaemonIoManagers($classes);
- $classes[] = new AimManager($this);
- return true;
- }
- function microiduri($screenname)
- {
- return 'aim:' . $screenname;
- }
- function sendMessage($screenname, $body)
- {
- $this->fake_aim->sendIm($screenname, $body);
- $this->enqueueOutgoingRaw($this->fake_aim->would_be_sent);
- return true;
- }
-
- function receiveRawMessage($message)
- {
- $info=Aim::getMessageInfo($message);
- $from = $info['from'];
- $user = $this->getUser($from);
- $notice_text = $info['message'];
- $this->handleIncoming($from, $notice_text);
- return true;
- }
- function initialize(){
- if(!isset($this->user)){
-
- throw new Exception(_m('Must specify a user.'));
- }
- if(!isset($this->password)){
-
- throw new Exception(_m('Must specify a password.'));
- }
- $this->fake_aim = new Fake_Aim($this->user,$this->password,4);
- return true;
- }
- function onPluginVersion(&$versions)
- {
- $versions[] = array('name' => 'AIM',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Craig Andrews',
- 'homepage' => 'http://status.net/wiki/Plugin:AIM',
- 'rawdescription' =>
-
- _m('The AIM plugin allows users to send and receive notices over the AIM network.'));
- return true;
- }
- }
|