Index: /trunk/expressoMail1_2/inc/class.db_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 163)
+++ /trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 205)
@@ -158,5 +158,5 @@
 		return $stringDropDownContacts;	
 	}
-	
+	/*
 	function update_preferences($params){
 		
@@ -212,4 +212,16 @@
 		else
 			return "OK!";
+	}
+	*/
+	function update_preferences($params){
+		$string_serial = urldecode($params['prefe_string']);				
+		$string_serial = get_magic_quotes_gpc() ? $string_serial : addslashes($string_serial);
+		$query = "update phpgw_preferences set preference_value = '".$string_serial."' where preference_app = 'expressoMail'".
+				 " and preference_owner = '".$this->user_id."'";
+		
+		if (!$this->db->query($query))
+        	return $this->db->error;
+		else
+			return array("success" => true);
 	}
 	function getUserByEmail($params){	
Index: /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 197)
+++ /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 205)
@@ -150,8 +150,14 @@
 		$return = array();
 		$msg_number = $params['msg_number'];
-		$msg_folder = $params['msg_folder'];				
+		$msg_folder = $params['msg_folder'];
+		
 		if(!$this->mbox)
 			$this->mbox = $this->open_mbox($msg_folder);		
-		$header = imap_headerinfo($this->mbox, imap_msgno($this->mbox, $msg_number), 80, 255);
+		
+		$header = @imap_headerinfo($this->mbox, imap_msgno($this->mbox, $msg_number), 80, 255);
+		if (!$header) {
+			$return['status_get_msg_info'] = "false";
+			return $return;
+		}
 		$all_header = explode("\n", imap_fetchheader($this->mbox, $msg_number, FT_UID));
 		$return_get_body = $this->get_body_msg($msg_number, $msg_folder);
@@ -461,5 +467,5 @@
 		$params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen");				
 		$this->set_messages_flag($params);
-		$content = $this->process_embedded_images($msg,$msg_number,$content);
+		$content = $this->process_embedded_images($msg,$msg_number,$content, $msg_folder);
 		$content = $this->replace_special_characters($content);
 		$return['body'] = $content;
@@ -625,7 +631,6 @@
 	}
 	
-	function process_embedded_images($msg, $msgno,$body)
-	{
-		
+	function process_embedded_images($msg, $msgno, $body, $msg_folder)
+	{
 		if (count($msg->inline_id[$msgno]) > 0)
 		{
Index: /trunk/expressoMail1_2/inc/show_embedded_attach.php
===================================================================
--- /trunk/expressoMail1_2/inc/show_embedded_attach.php	(revision 27)
+++ /trunk/expressoMail1_2/inc/show_embedded_attach.php	(revision 205)
@@ -5,4 +5,5 @@
 	$imap_port 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
 	$msg_folder = $_GET['msg_folder'];
+	$msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true));
 	if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
 	{
@@ -13,13 +14,20 @@
 		$imap_options = '/notls/novalidate-cert';
 	}
-	$mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);
-
-	$msgno = $_GET['msg_num'];
-	$embedded_part = $_GET['msg_part'];
 	
-	$embedded_body = imap_fetchbody($mb, $msgno, $embedded_part, FT_UID);
+	if (is_array($_SESSION['phpgw_info']['expressomail']['email_server']))
+	{
+		$mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);
 	
-	header("Content-Type: image/jpeg");
-	header("Content-Disposition: inline");
-	echo imap_base64($embedded_body);
+		if ($mb)
+		{
+			$msgno = $_GET['msg_num'];
+			$embedded_part = $_GET['msg_part'];
+	
+			$embedded_body = imap_fetchbody($mb, $msgno, $embedded_part, FT_UID);
+	
+			header("Content-Type: image/jpeg");
+			header("Content-Disposition: inline");
+			echo imap_base64($embedded_body);
+		}
+	}
 ?>
Index: /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 176)
+++ /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 205)
@@ -27,4 +27,21 @@
 		@ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);				
 	}
+
+	//Teste jakjr retornando o DS
+	function ldapConnect2($refer = false){
+		$ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['ldap_server']['host']);
+		
+		if (!$ds)
+			return false;
+		
+		ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+		ldap_set_option($ds, LDAP_OPT_REFERRALS, $refer);
+		if ($refer)
+			ldap_set_rebind_proc($ds, ldapRebind);
+		@ldap_bind($ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']);
+		
+		return $ds;				
+	}
+
 
 	// usa o host e context do setup.
@@ -439,26 +456,34 @@
 	}
 
-	function getUserByEmail($params){	
+	function getUserByEmail($params)
+	{
+		$filter="(&(phpgwAccountType=u)(mail=" . $params['email'] . "))";
+		$ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
+		$justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile");
+
 		// Follow the referral
-		$email = $params['email'];
-		$this->ldapConnect(true);
-		if ($this->ds)
-		{
-			$filter="(&(phpgwAccountType=u)(mail=$email))";		
-			$justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile");
-			$sr=ldap_search($this->ds, $this->ldap_context, $filter, $justthese);
-			$entry = ldap_first_entry($this->ds, $sr);			
+		$ds = $this->ldapConnect2(true);
+		if ($ds)
+		{			
+			$sr=ldap_search($ds, $ldap_context, $filter, $justthese);
+			
+			if (!$sr)
+				return null;
+			
+			$entry = ldap_first_entry($ds, $sr);
+			
 			if($entry) {						
-				$obj =  array("cn" => @ldap_get_values($this->ds, $entry, "cn"),
-						  "email" => $email,
-						  "uid" => @ldap_get_values($this->ds, $entry, "uid"),
+				$obj =  array("cn" => ldap_get_values($ds, $entry, "cn"),
+						  "email" => $params['email'],
+						  "uid" => ldap_get_values($ds, $entry, "uid"),
 						  "type" => "global",
-						  "mobile" =>  @ldap_get_values($this->ds, $entry, "mobile"),
-						  "telefone" =>  @ldap_get_values($this->ds, $entry, "telephonenumber"));
-
-				$_SESSION['phpgw_info']['expressomail']['contact_photo'] = @ldap_get_values_len($this->ds, $entry, "jpegphoto");
-				ldap_close($this->ds);				
+						  "mobile" =>  @ldap_get_values($ds, $entry, "mobile"),
+						  "telefone" =>  @ldap_get_values($ds, $entry, "telephonenumber")
+					);
+
+				$_SESSION['phpgw_info']['expressomail']['contact_photo'] = ldap_get_values_len($ds, $entry, "jpegphoto");
+				ldap_close($ds);
 				return $obj;
-			}		
+			}
 		}
 		return null;
Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 197)
+++ /trunk/expressoMail1_2/index.php	(revision 205)
@@ -29,4 +29,5 @@
 	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = array(
 			'voip_enabled'						=> $voip_enabled,
+			'outoffice'							=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'],
 			'telephone_number'					=> $GLOBALS['phpgw_info']['user']['telephonenumber'],
 			'max_email_per_page' 				=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'],
