Index: /branches/2.2.0.1/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /branches/2.2.0.1/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 4025)
+++ /branches/2.2.0.1/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 4044)
@@ -100,69 +100,58 @@
 	function get_range_msgs2($params)
 	{ 
-		$folder = $params['folder'];
-		$msg_range_begin = $params['msg_range_begin'];
-		$msg_range_end = $params['msg_range_end'];
-		$sort_box_type = $params['sort_box_type'];
-		$sort_box_reverse = $params['sort_box_reverse'];
-		$search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false;
-
-		if(!$this->mbox || !is_resource($this->mbox))
+		// Free others requests
+                session_write_close();
+
+                $folder 			= $params['folder'];
+                $msg_range_begin	= $params['msg_range_begin'];
+                $msg_range_end		= $params['msg_range_end'];
+                $sort_box_type		= $params['sort_box_type'];
+                $sort_box_reverse	= $params['sort_box_reverse'];
+                $search_box_type	= $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false;
+
+                if( !$this->mbox || !is_resource( $this->mbox ) )
 			$this->mbox = $this->open_mbox($folder);
-		
-		$return = array();
-		
-		 if(!$search_box_type || $search_box_type=="UNSEEN" || $search_box_type=="SEEN") {
-			$msgs_info = imap_mailboxmsginfo($this->mbox);
-
-			$return['tot_unseen'] = $search_box_type == "SEEN" ? 0 : $msgs_info->Unread;
-
-			$sort_array_msg = $this-> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse,$msg_range_begin,$msg_range_end);
-
-			$num_msgs = ($search_box_type=="UNSEEN") ? $msgs_info->Unread : (($search_box_type=="SEEN") ? ($msgs_info->Nmsgs - $msgs_info->Unread) : $msgs_info->Nmsgs);
-
+
+                // Correção para caixas acentuadas;
+		$name_folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");
+
+        $return = array();
+        //Para enviar o offset entre o timezone definido pelo usuário e GMT
+        $return['offsetToGMT'] = $this->functions->CalculateDateOffset();
+
+        $msgs_info   = imap_status( $this->mbox,"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$name_folder ,SA_ALL );
+        $num_msgs    = $msgs_info->messages; //imap_num_msg($this->mbox);
+
+        $sort_array_msg    = $this->get_msgs( $folder, $sort_box_type, $search_box_type, $sort_box_reverse, $msg_range_begin, $msg_range_end );
+
+		// Total Msg Unseen
+       	$return['tot_unseen']	= $msgs_info->unseen;
+
+		// Total Msg
+        $return['num_msgs']		= $msgs_info->messages;
+
+        if( is_array($sort_array_msg) )
+        {
 			$i = 0;
-			if(is_array($sort_array_msg)){
-				foreach($sort_array_msg as $msg_number => $value)
-				{
-					$temp = $this->get_info_head_msg($msg_number);
-					if(!$temp)
-						return false;
-
-					$return[$i] = $temp;
-					$i++;
-				}
-			}
-			$return['num_msgs'] =  $num_msgs;
-		}
-		else {
-			$num_msgs = imap_num_msg($this->mbox);
-			$sort_array_msg = $this-> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse,$msg_range_begin,$num_msgs);
-
-
-			$return['tot_unseen'] = 0;
-			$i = 0;
-
-			if(is_array($sort_array_msg)){
-				foreach($sort_array_msg as $msg_number => $value)
-				{
-					$temp = $this->get_info_head_msg($msg_number);
-					if(!$temp)
-						return false;
-
-					if($temp['Unseen'] == 'U' || $temp['Recent'] == 'N'){
-						$return['tot_unseen']++;
-					}
-				
-					if($i <= ($msg_range_end-$msg_range_begin))
-						$return[$i] = $temp;
-					$i++;
-				}
-			}
-                        $return['num_msgs'] = count($sort_array_msg)+($msg_range_begin-1);
-                }
-                        return $return;
-	}
-
-	function get_info_head_msg($msg_number) {
+
+            foreach($sort_array_msg as $msg_number => $value)
+            {
+                $temp = $this->get_info_head_msg($msg_number);
+
+                if(!$temp)
+                    return false;
+
+                if($i <= ($msg_range_end-$msg_range_begin))
+                    $return[$i] = $temp;
+
+                $i++;
+            }
+        }
+
+        return $return;
+    }
+
+	function get_info_head_msg($msg_number)
+	{
 		$head_array = array();
 		include_once("class.imap_attachment.inc.php");
