Author: vetinari
Date: Fri Dec  7 01:12:15 2007
New Revision: 825

Modified:
   trunk/lib/Qpsmtpd/Plugin.pm
   trunk/lib/Qpsmtpd/SMTP.pm

Log:
Pluggable help, based on patch by Jose Luis Martinez

Modified: trunk/lib/Qpsmtpd/Plugin.pm
==============================================================================
--- trunk/lib/Qpsmtpd/Plugin.pm (original)
+++ trunk/lib/Qpsmtpd/Plugin.pm Fri Dec  7 01:12:15 2007
@@ -9,7 +9,7 @@
     rcpt_parse rcpt_pre rcpt mail_parse mail mail_pre 
     data data_post queue_pre queue queue_post
     quit reset_transaction disconnect post-connection
-    unrecognized_command deny ok received_line
+    unrecognized_command deny ok received_line help
 );
 our %hooks = map { $_ => 1 } @hooks;
 

Modified: trunk/lib/Qpsmtpd/SMTP.pm
==============================================================================
--- trunk/lib/Qpsmtpd/SMTP.pm   (original)
+++ trunk/lib/Qpsmtpd/SMTP.pm   Fri Dec  7 01:12:15 2007
@@ -474,12 +474,30 @@
 }
 
 sub help {
-  my $self = shift;
-  $self->respond(214, 
-          "This is qpsmtpd " . 
-          ($self->config('smtpgreeting') ? '' : $self->version),
-          "See http://smtpd.develooper.com/";,
-          'To report bugs or send comments, mail to <[EMAIL PROTECTED]>.');
+  my ($self, @args) = @_;
+  $self->run_hooks("help", @args);
+}
+
+sub help_respond {
+  my ($self, $rc, $msg, $args) = @_;
+
+  return 1 
+    if $rc == DONE;
+
+  if ($rc == DENY) {
+    $msg->[0] ||= "Syntax error, command not recognized";
+    $self->respond(500, @$msg);
+  }
+  else {
+    unless ($msg->[0]) {
+      @$msg = (
+        "This is qpsmtpd " . ($self->config('smtpgreeting') ? '' : 
$self->version),
+        "See http://smtpd.develooper.com/";,
+        'To report bugs or send comments, mail to <[EMAIL PROTECTED]>.');
+    }
+    $self->respond(214, @$msg);
+  }
+  return 1;
 }
 
 sub noop {

Reply via email to