Index: /trunk/mobile/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/mobile/setup/phpgw_pt-br.lang	(revision 4277)
+++ /trunk/mobile/setup/phpgw_pt-br.lang	(revision 5037)
@@ -1,4 +1,5 @@
 attachment	mobile	pt-br	Anexo
 Add Recipient	mobile	pt-br	Adicionar Destinatário
+At %1, %2 hours, %3 wrote:	mobile	pt-br	Em %1 às %2 horas, %3 escreveu:
 more attachment	mobile	pt-br	mais anexo
 cancel	mobile	pt-br	Cancelar
@@ -64,4 +65,5 @@
 This message don't have attachment(s)	mobile	pt-br	Este e-mail não possui anexo(s)
 This message has the follow attachments:	mobile	pt-br	Esta mensagem possui anexo:
+Tips	mobile	pt-br	Dicas
 Catalog	mobile	pt-br	Catálogo
 Phone	mobile	pt-br	Telefone
@@ -108,4 +110,5 @@
 No matches found	mobile	pt-br	Contato não localizado
 The message was moved to trash	mobile	pt-br	A mensagem foi movida para a lixeira.
+The messages were deleted	mobile	pt-br	As mensagens foram apagadas.
 The messages were moved to trash	mobile	pt-br	As mensagens foram movidas para a lixeira.
 The messages were marked as seen	mobile	pt-br	As mensagens foram marcadas como lidas.
Index: /trunk/mobile/inc/class.ui_mobilemail.inc.php
===================================================================
--- /trunk/mobile/inc/class.ui_mobilemail.inc.php	(revision 4354)
+++ /trunk/mobile/inc/class.ui_mobilemail.inc.php	(revision 5037)
@@ -689,4 +689,5 @@
 		function new_msg($params)
 		{
+			$flagImportant = intval($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']);
 			$this->template->set_file(array('new_msg_t' => 'new_msg.tpl'));
 			$this->template->set_block('new_msg_t', 'page');
@@ -702,4 +703,5 @@
 			$this->template->set_var('lang_cc', lang("cc"));
 			$this->template->set_var('lang_subject', lang("Subject"));
+			$this->template->set_var('visible_important', ( ($flagImportant == 1 ) ? "block" : "none" ) );
 			$this->template->set_var('lang_mark_as_important', lang("mark as important"));
 			$this->template->set_var('lang_read_confirmation', lang("read confirmation"));
@@ -708,5 +710,6 @@
 			$this->template->set_var("show_check_add_history","none");
 			
-			if(isset($params["error_message"])) {
+			if(isset($params["error_message"]))
+			{
 				$this->template->set_var('input_to', $_POST['input_to']);
 				$this->template->set_var('input_cc', $_POST['input_cc']);
@@ -723,7 +726,11 @@
 				
 				$GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]);
-			} else {
-				if (isset($params['msg_number'])) $msg = $this->imap_functions->get_info_msg(array('msg_number' => $params['msg_number'], 'msg_folder' => $params['msg_folder'] ) );
-				
+			}
+			else
+			{
+				if (isset($params['msg_number']) )
+				{
+					$msg = $this->imap_functions->get_info_msg(array('msg_number' => $params['msg_number'], 'msg_folder' => $params['msg_folder'] ) );
+				}
 				
 				if($params['type']=="clk")
@@ -790,5 +797,6 @@
 						$this->template->set_var("show_forward_attachment","block");
 						$this->template->set_block("new_msg_t","forward_attach_block");
-						foreach($msg['attachments'] as $forward_attach) {
+						foreach($msg['attachments'] as $forward_attach)
+						{
 							$value = rawurlencode(serialize(array(0=>$msg['msg_folder'],
 										   1=>$msg['msg_number'],
@@ -802,5 +810,6 @@
 					}
 				}
-				else if($params['type']=="use_draft"){
+				else if($params['type']=="use_draft")
+				{
 					$this->template->set_var('input_to', $msg['toaddress2']);
 					$this->template->set_var('input_cc', $msg['cc']);
@@ -918,7 +927,16 @@
 			if($isImportant) $mail->isImportant();
 			//add history
-			if($addHistory && $msgNumber) {
+			if($addHistory && $msgNumber)
+			{
 				$msg = $this->imap_functions->get_info_msg(array('msg_number' => $msgNumber ) );
-				$mail->Body .= "<br />".$msg['body']."<br />";
+				
+				$_name	= ( isset($msg['from']['name']) ) ? $msg['from']['name'] : "";
+				$_email	= ( isset($msg['from']['email']) ) ? " ".$msg['from']['email']." " : "";
+				
+				$history_msg  = "<br/><br/><br/>";
+				$history_msg .= lang('At %1, %2 hours, %3 wrote:', $msg['msg_day'], $msg['msg_hour'],"\"".$_name."\"".$_email );
+				$history_msg .= "<br/>";
+				
+				$mail->Body .= "<br/>". $history_msg . $msg['body']."<br/>";
 			}
 			//read confirmation
@@ -974,13 +992,29 @@
 				header("Location: index.php?menuaction=mobile.ui_mobilemail.index&error_message=".lang("please select one e-mail"));
 			} else {
-				$params_messages = array(
-					'msgs_number' => isset($params['msgs'])?implode(",",$params['msgs']):$params['msg_number'],
-					'folder' => $this->folders[$this->current_folder]['folder_name'],
-					'new_folder_name' => 'Trash',
-					'new_folder' => 'INBOX/Trash'
-				);
+				$msg = "";
+
+				if($params["msg_folder"] == "INBOX/Trash") {
+					$params_messages = array(
+						'msgs_number' => isset($params['msgs'])?implode(",",$params['msgs']):$params['msg_number'],
+						'folder' => 'INBOX/Trash'
+					);
 				
-				$this->imap_functions->move_messages($params_messages);
-				header("Location: index.php?menuaction=mobile.ui_mobilemail.index&success_message=".lang("The messages were moved to trash").'&ignore_trace_url=true');				
+					$this->imap_functions->delete_msgs($params_messages);
+				
+					$msg = lang("The messages were deleted");
+				} else {
+					$params_messages = array(
+						'msgs_number' => isset($params['msgs'])?implode(",",$params['msgs']):$params['msg_number'],
+						'folder' => $this->folders[$this->current_folder]['folder_name'],
+						'new_folder_name' => 'Trash',
+						'new_folder' => 'INBOX/Trash'
+					);
+
+					$this->imap_functions->move_messages($params_messages);
+				
+					$msg = lang("The messages were moved to trash");
+				}
+
+				header("Location: index.php?menuaction=mobile.ui_mobilemail.index&success_message=".$msg.'&ignore_trace_url=true');
 			}
 		}
Index: /trunk/mobile/inc/class.ui_mobilecc.inc.php
===================================================================
--- /trunk/mobile/inc/class.ui_mobilecc.inc.php	(revision 4277)
+++ /trunk/mobile/inc/class.ui_mobilecc.inc.php	(revision 5037)
@@ -65,24 +65,26 @@
 		public function change_max_results($params) {
 			$this->page_info['actual_max_contacts'] = $params['results'];
+			$this->save_session();
 			$this->contacts_list();
+		}
+		
+		public function change_letter($params)
+		{
+			if( $params['letter'] )
+			{
+				$this->page_info['actual_letter'] = $params['letter'];
+			}
+			$this->page_info['actual_max_contacts'] = 10;
 			$this->save_session();
-		}
-		
-		public function change_letter($params) {
-			$this->page_info['actual_letter'] = $params['letter'];
+			$this->contacts_list($params);
+		}
+		
+		public function change_catalog($params)
+		{
+			$this->page_info['actual_catalog'] = $params['catalog'];
+			$this->page_info['actual_letter'] = 'a';
 			$this->page_info['actual_max_contacts'] = 10;
-			$this->contacts_list();
 			$this->save_session();
-		}
-		
-		public function change_catalog($params) {
-
-			if( $params['catalog'] ) $this->page_info['actual_catalog'] = $params['catalog'];
-			$this->page_info['actual_max_contacts'] = 10;
-			$this->page_info['actual_letter'] = 'a';
-			
 			$this->contacts_list($params);
-			
-			$this->save_session();
 		}
 		
@@ -96,6 +98,6 @@
 			$this->set_page_info_to_default();
 			$this->page_info['request_from'] = $params['request_from']; //Para escolher contato vindo de outro modulo, mudo apenas o request_from
+			$this->save_session();
 			$this->contacts_list();
-			$this->save_session();
 		}
 		
@@ -108,6 +110,6 @@
 		public function init_cc($params) {
 			$this->set_page_info_to_default();
+			$this->save_session();
 			$this->contacts_list($params);
-			$this->save_session();
 		}
 		
@@ -242,5 +244,6 @@
 		 */
 		
-		function delete_contacts($params) {
+		function delete_contacts($params)
+		{
 			$this->bo->set_catalog($params['catalog']);
 
@@ -369,7 +372,9 @@
 		 * @return $contact
 		 */
-		function contact_view($params) {
-
-			if ( empty($params['id']) || empty($params['catalog']) ){
+		function contact_view($params)
+		{
+
+			if ( empty($params['id']) || empty($params['catalog']) )
+			{
 				header('Location: ../mobile/index.php?menuaction=mobile.ui_mobilecc.init_cc');
 			}
@@ -633,5 +638,6 @@
 				$view = true;
 
-				if ( !isset($params['erro'])){
+				if ( !isset($params['erro']))
+				{
 					$this->bo->set_catalog($params['catalog']);
 					$result = $this->bo->bo->get_single_entry($params['id'], array("given_names"=>true,"names_ordered"=>true,"alias"=>true,"family_names"=>true,"companies"=>true,"relations"=>true,"connections"=>true));
@@ -727,5 +733,4 @@
 					$data['connections']['default_phone']['connection_value'] = $params['phone'];
 				}
-	
 				$this->bo->set_catalog($params['catalog']);
 				$contact_id = $this->bo->bo->quick_add($data);
@@ -761,5 +766,4 @@
 			else
 			{
-
 				$this->bo->set_catalog($params['catalog']);
 				$types = $this->bo->bo->get_all_connections_types();
@@ -850,8 +854,4 @@
 			
 		}
-
-		
 	}
-	
-	
 ?>
Index: /trunk/mobile/index.php
===================================================================
--- /trunk/mobile/index.php	(revision 4277)
+++ /trunk/mobile/index.php	(revision 5037)
@@ -8,5 +8,10 @@
 	//$fwConstruct = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $proxies[0] : $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 	$fwConstruct = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $proxies[0] : $_SERVER['HTTP_HOST'];	
-	$REQUEST_URI = substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], "/mobile/" ) + 8 );
+	$REQUEST_URI = substr( $_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], "/mobile/"+1));
+	if( strpos( $_SERVER['REQUEST_URI'], "/mobile/" ) !== false )
+	{
+		$REQUEST_URI = substr($_SERVER['REQUEST_URI'], 0, strpos( $_SERVER['REQUEST_URI'], "/mobile/"));
+	}
+	
 	$fwConstruct .= $REQUEST_URI;
 	
@@ -21,7 +26,7 @@
 	    	$aux = 'https://';
 	    }
-		
-	    Header('Location: ' . $aux . $fwConstruct . "login.php");
-		exit;
+	  
+	    Header('Location: ' . $aux . $fwConstruct . "/login.php");
+	  	exit;
 	}
 
@@ -29,5 +34,5 @@
 	{
 		if ($_SERVER['HTTPS'] != 'on') {
-   			Header('Location: https://' . $fwConstruct . '/' . $_SERVER['REQUEST_URI']);
+   			Header('Location: https://' . $fwConstruct . $_SERVER['REQUEST_URI']);
 			exit;
 		}
Index: /trunk/mobile/login.php
===================================================================
--- /trunk/mobile/login.php	(revision 4277)
+++ /trunk/mobile/login.php	(revision 5037)
@@ -158,5 +158,5 @@
 			$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
 			
-			if($_POST['save_login'] == 'yes')
+			if($_POST['save_login'] === 'on')
 			{
 				// Time to keep values into cookies
@@ -165,10 +165,13 @@
 				$GLOBALS['phpgw']->session->phpgw_setcookie('pem', base64_encode($passwd), $ttl);			// pem = password
 			}
-			start_prefered_app();
-		}
-	}
-	elseif ($_GET['lang'])
-	{
-		$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $_GET['lang'];
+			
+			if( isset($GLOBALS['sessionid']) )
+			{
+				if( $_GET['cd'] != 10 && $_GET['cd'] != 1 && $_GET['cd'] !== 'logout_mobile' && $_GET['cd'] != 66 )
+				{
+					start_prefered_app();
+				}
+			}
+		}
 	}
 	elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id)
Index: /trunk/mobile/templates/default/new_msg.tpl
===================================================================
--- /trunk/mobile/templates/default/new_msg.tpl	(revision 4277)
+++ /trunk/mobile/templates/default/new_msg.tpl	(revision 5037)
@@ -61,5 +61,5 @@
 	<div id="corpo_mensagem" class="limpar_div" style="background:#EFF8FB; display:table; width:100%" >
 		<div id="text_area"><textarea id="body" wrap="virtual" name="body" cols="5" rows="5">{body_value}</textarea></div>
-		<div class="limpar_div">&nbsp;<input type="checkbox" name="check_important" {check_important} />{lang_mark_as_important}</div>
+		<div class="limpar_div" style="display:{visible_important} !important;">&nbsp;<input type="checkbox" name="check_important" {check_important} />{lang_mark_as_important}</div>
 		<div class="limpar_div">&nbsp;<input type="checkbox" name="check_read_confirmation" {check_read_confirmation} />{lang_read_confirmation}</div>
 		<div class="limpar_div" style="display:{show_check_add_history}">&nbsp;<input type="checkbox" name="check_add_history" {check_add_history} />{lang_add_history}</div>
Index: /trunk/mobile/templates/default/login.tpl
===================================================================
--- /trunk/mobile/templates/default/login.tpl	(revision 4277)
+++ /trunk/mobile/templates/default/login.tpl	(revision 5037)
@@ -7,5 +7,6 @@
 		<meta content="text/html;width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0; charset=utf-8;" http-equiv="Content-Type" name="viewport" /> 
 		<meta name="format-detection" content="telephone=no" />
-		<link href="templates/css/mobile.css" type="text/css" rel="StyleSheet" />
+		<!-- link href="templates/css/mobile.css" type="text/css" rel="StyleSheet" /-->
+		<link type="text/css" rel="stylesheet" href="templates/css/login.css">
 		<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
 		<link rel="apple-touch-icon" href="./templates/default/images/favicon.png" />
