Added validate regexp and a few more comments

This commit is contained in:
Luke Fitzgerald 2010-06-16 00:04:59 +01:00
parent 27e8cfd360
commit d41298950b
2 changed files with 21 additions and 11 deletions

View File

@ -58,7 +58,7 @@ class MsnPlugin extends ImPlugin {
* *
* @return string Name of service * @return string Name of service
*/ */
function getDisplayName() { public function getDisplayName() {
return _m('MSN'); return _m('MSN');
} }
@ -68,7 +68,7 @@ class MsnPlugin extends ImPlugin {
* @param string $screenname screenname to normalize * @param string $screenname screenname to normalize
* @return string an equivalent screenname in normalized form * @return string an equivalent screenname in normalized form
*/ */
function normalize($screenname) { public function normalize($screenname) {
$screenname = str_replace(" ","", $screenname); $screenname = str_replace(" ","", $screenname);
return strtolower($screenname); return strtolower($screenname);
} }
@ -78,7 +78,7 @@ class MsnPlugin extends ImPlugin {
* *
* @return string Screenname * @return string Screenname
*/ */
function daemon_screenname() { public function daemon_screenname() {
return $this->user; return $this->user;
} }
@ -86,20 +86,21 @@ class MsnPlugin extends ImPlugin {
* Validate (ensure the validity of) a screenname * Validate (ensure the validity of) a screenname
* *
* @param string $screenname screenname to validate * @param string $screenname screenname to validate
*
* @return boolean * @return boolean
*/ */
function validate($screenname) { public function validate($screenname) {
//TODO Correct this for MSN screennames // RFC 2822 (simplified) regexp
//if(preg_match('/^[a-z]\w{2,15}$/i', $screenname)) { if(preg_match('/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i', $screenname)) {
return true; return true;
} else {
return false;
}
} }
/** /**
* Load related modules when needed * Load related modules when needed
* *
* @param string $cls Name of the class to be loaded * @param string $cls Name of the class to be loaded
*
* @return boolean hook value; true means continue processing, false means stop. * @return boolean hook value; true means continue processing, false means stop.
*/ */
public function onAutoload($cls) { public function onAutoload($cls) {
@ -159,7 +160,7 @@ class MsnPlugin extends ImPlugin {
/** /**
* Initialize plugin * Initialize plugin
* *
* @return void * @return boolean
*/ */
public function initialize() { public function initialize() {
if (!isset($this->user)) { if (!isset($this->user)) {
@ -175,7 +176,13 @@ class MsnPlugin extends ImPlugin {
return true; return true;
} }
function onPluginVersion(&$versions) { /**
* Get plugin information
*
* @param array $versions array to insert information into
* @return void
*/
public function onPluginVersion(&$versions) {
$versions[] = array( $versions[] = array(
'name' => 'MSN', 'name' => 'MSN',
'version' => STATUSNET_VERSION, 'version' => STATUSNET_VERSION,

View File

@ -146,6 +146,7 @@ class MsnManager extends ImManager {
* Passes it back to the queuing system * Passes it back to the queuing system
* *
* @param array $data Data * @param array $data Data
* @return void
*/ */
private function handle_msn_message($data) { private function handle_msn_message($data) {
$this->plugin->enqueue_incoming_raw($data); $this->plugin->enqueue_incoming_raw($data);
@ -156,6 +157,7 @@ class MsnManager extends ImManager {
* Called by callback to log failure during connect * Called by callback to log failure during connect
* *
* @param void $data Not used (there to keep callback happy) * @param void $data Not used (there to keep callback happy)
* @return void
*/ */
function handle_connect_failed($data) { function handle_connect_failed($data) {
common_log(LOG_NOTICE, 'MSN connect failed, retrying'); common_log(LOG_NOTICE, 'MSN connect failed, retrying');
@ -165,6 +167,7 @@ class MsnManager extends ImManager {
* Called by callback to log reconnection * Called by callback to log reconnection
* *
* @param void $data Not used (there to keep callback happy) * @param void $data Not used (there to keep callback happy)
* @return void
*/ */
function handle_reconnect($data) { function handle_reconnect($data) {
common_log(LOG_NOTICE, 'MSN reconnecting'); common_log(LOG_NOTICE, 'MSN reconnecting');