From ffd3e2906854ff985974be070b224beb38f4fae9 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 04 Jun 2010 05:16:30 -0400
Subject: [PATCH] - Some fixes for BADCHARSET handling in SORT/THREAD/SEARCH response

---
 program/include/rcube_imap_generic.php |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index d159b90..461beec 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -611,14 +611,21 @@
 		    $host = $this->prefs['ssl_mode'] . '://' . $host;
 	    }
 
-	    $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, 10);
+        // Connect
+        if ($this->prefs['timeout'] > 0)
+	        $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr, $this->prefs['timeout']);
+	    else
+	        $this->fp = @fsockopen($host, $this->prefs['port'], $errno, $errstr);
+
 	    if (!$this->fp) {
     		$this->error    = sprintf("Could not connect to %s:%d: %s", $host, $this->prefs['port'], $errstr);
     		$this->errornum = -2;
 		    return false;
 	    }
 
-	    stream_set_timeout($this->fp, 10);
+        if ($this->prefs['timeout'] > 0)
+	        stream_set_timeout($this->fp, $this->prefs['timeout']);
+
 	    $line = trim(fgets($this->fp, 8192));
 
 	    if ($this->prefs['debug_mode'] && $line) {
@@ -841,7 +848,6 @@
 	    } while (!$this->startsWith($line, 's ', true, true));
 
 	    $result_code = $this->parseResult($line);
-
 	    if ($result_code != 0) {
             $this->error = "Sort: $line";
             return false;

--
Gitblit v1.9.1