From 9870dac30de1b8d1bdeab57af3eeb7c89b21ef76 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 14 Apr 2012 02:35:52 -0400
Subject: [PATCH] - Make some methods public (#1488428)

---
 program/include/rcube_smtp.php |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/program/include/rcube_smtp.php b/program/include/rcube_smtp.php
index 5c2dd92..0923e3b 100644
--- a/program/include/rcube_smtp.php
+++ b/program/include/rcube_smtp.php
@@ -6,7 +6,10 @@
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
  | Copyright (C) 2005-2010, The Roundcube Dev Team                       |
- | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | Licensed under the GNU General Public License version 3 or            |
+ | any later version with exceptions for skins & plugins.                |
+ | See the README file for a full license statement.                     |
  |                                                                       |
  | PURPOSE:                                                              |
  |   Provide SMTP functionality using socket connections                 |
@@ -49,14 +52,14 @@
    */
   public function connect($host=null, $port=null, $user=null, $pass=null)
   {
-    $RCMAIL = rcmail::get_instance();
-  
+    $RCMAIL = rcube::get_instance();
+
     // disconnect/destroy $this->conn
     $this->disconnect();
-    
+
     // reset error/response var
     $this->error = $this->response = null;
-  
+
     // let plugins alter smtp connection config
     $CONFIG = $RCMAIL->plugins->exec_hook('smtp_connect', array(
       'smtp_server'    => $host ? $host : $RCMAIL->config->get('smtp_server'),
@@ -68,9 +71,10 @@
       'smtp_auth_type' => $RCMAIL->config->get('smtp_auth_type'),
       'smtp_helo_host' => $RCMAIL->config->get('smtp_helo_host'),
       'smtp_timeout'   => $RCMAIL->config->get('smtp_timeout'),
+      'smtp_auth_callbacks' => array(),
     ));
 
-    $smtp_host = rcube_parse_host($CONFIG['smtp_server']);
+    $smtp_host = rcmail::parse_host($CONFIG['smtp_server']);
     // when called from Installer it's possible to have empty $smtp_host here
     if (!$smtp_host) $smtp_host = 'localhost';
     $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25;
@@ -107,6 +111,14 @@
 
     if ($RCMAIL->config->get('smtp_debug'))
       $this->conn->setDebug(true, array($this, 'debug_handler'));
+
+    // register authentication methods
+    if (!empty($CONFIG['smtp_auth_callbacks']) && method_exists($this->conn, 'setAuthMethod')) {
+      foreach ($CONFIG['smtp_auth_callbacks'] as $callback) {
+        $this->conn->setAuthMethod($callback['name'], $callback['function'],
+          isset($callback['prepend']) ? $callback['prepend'] : true);
+      }
+    }
 
     // try to connect to server and exit on failure
     $result = $this->conn->connect($smtp_timeout);
@@ -326,7 +338,7 @@
    */
   public function debug_handler(&$smtp, $message)
   {
-    write_log('smtp', preg_replace('/\r\n$/', '', $message));
+    rcmail::write_log('smtp', preg_replace('/\r\n$/', '', $message));
   }
 
 
@@ -381,7 +393,7 @@
           $from = $addresses[0];
 
         // Reject envelope From: addresses with spaces.
-        if (strstr($from, ' '))
+        if (strpos($from, ' ') !== false)
           return false;
 
         $lines[] = $key . ': ' . $value;

--
Gitblit v1.9.1