Index: branches/2.2/mobile/inc/class.mobiletemplate.inc.php
===================================================================
--- branches/2.2/mobile/inc/class.mobiletemplate.inc.php	(revision 3571)
+++ branches/2.2/mobile/inc/class.mobiletemplate.inc.php	(revision 3576)
@@ -86,4 +86,5 @@
 
 			
+			$this-> template->set_var('lang_logout', lang('logout'));
 			$this-> template->set_var('lang_back', lang('Back'));
 			$this-> template->set_var('lang_home', lang('home'));
@@ -91,9 +92,10 @@
 			$this-> template->set_var('lang_contacts', lang('Contact Center'));
 			$this-> template->set_var('lang_calendar', lang('Calendar'));
+			$this-> template->set_var('href_logout', 'login.php?cd=1');
+			$this-> template->set_var('href_back', 'javascript:history.back()');
 			$this-> template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.contacts_list');
 			$this-> template->set_var('href_email', "index.php?menuaction=mobile.ui_mobilemail.change_folder&folder=0");
 			$this-> template->set_var('href_calendar', "index.php?menuaction=mobile.ui_mobilecalendar.index");
 			$this-> template->set_var('href_home', "index.php?menuaction=mobile.ui_home.index");
-
 		}
 
Index: branches/2.2/mobile/inc/class.ui_mobilemail.inc.php
===================================================================
--- branches/2.2/mobile/inc/class.ui_mobilemail.inc.php	(revision 3573)
+++ branches/2.2/mobile/inc/class.ui_mobilemail.inc.php	(revision 3576)
@@ -33,8 +33,10 @@
 			'add_recipient' => true,
 			'list_folders' => true,
-			'save_draft' => true
+			'save_draft' => true,
+			'mark_message_with_flag' => true
 		);
 
 		var $template;
+		var $common;
 		var $folders; // Pastas imap
 		var $current_folder; // Pasta corrente
@@ -54,4 +56,5 @@
 			$this-> load_session();						
 			$this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
+			$this->common	= CreateObject('mobile.common_functions');
 			
 			// Recupera atributos da classe gravados na sessão
@@ -126,7 +129,7 @@
 		 * @author Mário César Kolling <mario.kolling@serpro.gov.br>
 		 */
-		function change_folder()
-		{
-			$folder = $_GET['folder'];
+		function change_folder($params)
+		{
+			$folder = $params['folder'];
 			if (isset($folder))
 			{
@@ -134,8 +137,22 @@
 				$this->current_page = 1;
 			}
-			$this->mail_list();
+			
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]);
+			$this->mail_list($params);
 			$this->save_session();
 		}
-
+		
+		function mark_message_with_flag($params=array())
+		{
+			$return = $this->imap_functions->set_messages_flag($params);
+			
+			if($return)
+				header('Location: index.php?menuaction=menuaction=mobile.ui_mobilemail.change_folder&folder='.$this->current_folder);
+			else
+				header('Location: index.php?menuaction=menuaction=mobile.ui_mobilemail.show_msg&msg_number='.$params["msgs_to_set"].'&msg_folder='.$return["msg_folder"].'&error_message='.$return["msg"]);
+			
+			exit;
+		}
+		
 		/*
 		 * @function show_msg
@@ -144,58 +161,45 @@
 		 */
 		 // TODO: retirar msg_folder dos parâmentros necessários no GET e usar $this->current_folder
-		function show_msg()
-		{
-			$params = array();
-
-			//TODO: testar chamar sem parâmetros para determinar se ocorre algum problema
-			if (isset($_GET['msg_number']) && isset($_GET['msg_folder']))
-			{
-				$params = array(
-					'msg_number' => $_GET['msg_number'],
-					'msg_folder' => $_GET['msg_folder'],
-				);
-			}
-
+		function show_msg($params = array())
+		{
 			$msg = $this->imap_functions->get_info_msg($params);
 
 			// Carrega o template
-			$this->template->set_file(array('view_msg_t' => 'view_msg.tpl'));
-			$this->template->set_block('view_msg_t', 'mail_header');
-			$this->template->set_block('view_msg_t', 'mail_body');
-			$this->template->set_block('view_msg_t', 'mail_footer');
-			$this->template->set_block('view_msg_t', 'reply_msg');
-			$this->template->set_block('view_msg_t', 'attachment_list');
-			$this->template->set_block('view_msg_t', 'begin_anchor');
-			$this->template->set_block('view_msg_t', 'end_anchor');
+			$this->template->set_file(array('view_msg' => 'view_msg.tpl'));
+			$this->template->set_block('view_msg', 'page');
+			$this->template->set_block('view_msg', 'begin_anchor');
+			$this->template->set_block('view_msg', 'end_anchor');
+			$this->template->set_var('lang_back', lang("back"));
+			$this->template->set_var('lang_reading_message', lang("Reading Message"));
 
 			// Define o cabeçalho do e-mail
-			$this->template->set_var('from_label', lang("From"));
+			$this->template->set_var('lang_from', lang("From"));
 			$this->template->set_var('from', $msg['from']['full']);
-			$this->template->set_var('to_label', lang("To"));
-
-			$this->template->set_var('subject_label', lang("Subject"));
+			$this->template->set_var('lang_cc', lang("cc"));
+			$this->template->set_var('cc', $msg['cc']);
+			$this->template->set_var('size', $this->common->borkb($msg['Size']));
+
+			$this->template->set_var('lang_subject', lang("Subject"));
 			$this->template->set_var('subject', $msg['subject']);
-			$this->template->set_var('date_label', lang("Date"));
-			$this->template->set_var('date', $msg['fulldate']);
-
+			$this->template->set_var('date', $msg['msg_day']." ".$msg['msg_hour']);
 
 			// Mostra o corpo do e-mail
 			$this->template->set_var('body', strip_tags($msg['body'], $this->allowed_tags)); // Usa a função strip_tags() para filtrar
 				// as tags que estão presentes no corpo do e-mail.
-			$this->template->set_var('link_text', lang("Return"));
-			$this->template->set_var('link', "index.php?menuaction=mobile.ui_mobilemail.mail_list");
-
-
-			$this->template->set_var('reply_all_text', lang("Reply to all"));
-			$this->template->set_var('forward_text', lang("Forward"));
-
-			$this->template->set_var('reply_text', lang("Reply"));
-			$this->template->set_var('Delete', lang("Delete"));
-			$msg_number = $_GET['msg_number'];
-			$msg_folder = $_GET['msg_folder'];
-			$this->template->set_var('reply', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder");
-			$this->template->set_var('delete', "index.php?menuaction=mobile.ui_mobilemail.confirm_delete_msg&msg_number=$msg_number&msg_folder=$msg_folder");
-			$this->template->set_var('reply_all', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=reply_all");
-			$this->template->set_var('forward', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=forward");
+			$this->template->set_var('lang_link', lang("Return"));
+			$this->template->set_var('return_link', "index.php?menuaction=mobile.ui_mobilemail.mail_list");
+
+			$this->template->set_var('lang_reply_all', lang("Reply to all"));
+			$this->template->set_var('lang_forward', lang("Forward"));
+			$this->template->set_var('lang_mark_as_unread', lang("mark as unread"));
+			$this->template->set_var('lang_reply', lang("Reply"));
+			$this->template->set_var('lang_delete', lang("Delete"));
+			$msg_number = $params['msg_number'];
+			$msg_folder = $params['msg_folder'];
+			$this->template->set_var('mark_as_unread_link', "index.php?menuaction=mobile.ui_mobilemail.mark_message_with_flag&flag=unseen&msgs_to_set=$msg_number&msg_folder=$msg_folder");
+			$this->template->set_var('reply_link', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder");
+			$this->template->set_var('delete_link', "index.php?menuaction=mobile.ui_mobilemail.confirm_delete_msg&msg_number=$msg_number&msg_folder=$msg_folder");
+			$this->template->set_var('reply_all_link', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=reply_all");
+			$this->template->set_var('forward_link', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&type=forward");
 			if (!empty($msg['attachments']))
 			{
@@ -209,7 +213,6 @@
 									  lang('Download').":&nbsp;".$attach['name']."</a><br>";
 					}
-					$this->template->set_var('attachment_message', $attachs);
-				}
-				//$this->template->set_var('attachment_message', lang('This message have attachment(s)'));
+				}
+				$this->template->set_var('attachment_message', $attachs);
 			}
 			else
@@ -220,19 +223,7 @@
 			$this->template->parse('view_msg_t', 'end_anchor');
 			$this->template->parse('view_msg_t', 'begin_anchor');
-			//$this->template->pfp('view_msg_t', 'mail_header');
-			/*$this->template->pfp('out', 'mail_header');
-			//$this->template->pfp('view_msg_t', 'mail_body');
-			$this->template->pfp('out', 'mail_body');
-			//$this->template->pfp('view_msg_t', 'attachment_list');
-			$this->template->pfp('out', 'attachment_list');
-			//$this->template->pfp('view_msg_t', 'mail_footer');
-			$this->template->pfp('out', 'reply_msg');
-			//$this->template->pfp('out', 'mail_footer');*/
-
-			//$this->template->pfp('view_msg_t', 'mail_header');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'mail_header'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'mail_body'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'attachment_list'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'reply_msg'));
+			
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]);
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page'));
 		}
 
@@ -283,5 +274,5 @@
 		    $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_use_spam_filter'] = $current_config['expressoMail_use_spam_filter'];
 
-			echo '<script> var array_lang = new Array();var use_spam_filter = \''.$current_config['expressoMail_use_spam_filter'].'\' </script>';
+			// echo '<script> var array_lang = new Array();var use_spam_filter = \''.$current_config['expressoMail_use_spam_filter'].'\' </script>';
 
 			// End Set Anti-Spam options.
@@ -293,6 +284,5 @@
 		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 		: "Sent";
 
-			include("../expressoMail1_2/inc/load_lang.php");		    
-	
+			// include("../expressoMail1_2/inc/load_lang.php");		    
 		}
 
@@ -376,9 +366,9 @@
 		 * @author Mário César Kolling <mario.kolling@serpro.gov.br>
 		 */
-		function mail_list()
+		function mail_list($params)
 		{	
 		
-			if($_GET['folder']){
-				$this->current_folder = $_GET['folder'];
+			if($params['folder']){
+				$this->current_folder = $params['folder'];
 			}else{
 				$this->current_folder = 0;
@@ -391,8 +381,8 @@
 			if (!isset($this->number_of_messages))
 			{
-				$params = array(
+				$params_num_msg = array(
 					'folder' => $this->folders[$this->current_folder]['folder_id'],
 				);
-				$this->number_of_messages = $this->imap_functions->get_num_msgs($params);
+				$this->number_of_messages = $this->imap_functions->get_num_msgs($params_num_msg);
 			}
 
@@ -402,11 +392,11 @@
 			
 			if($_POST["searchEmail"]){
-				$params = array(
-					'filter' 			=> $_POST["searchEmail"]
+				$params_mobile_search = array(
+					'filter' 	=> $_POST["searchEmail"]
 					);
 
-				$messages = $this->imap_functions->mobile_search($params);
+				$messages = $this->imap_functions->mobile_search($params_mobile_search);
 			}else{
-				$params = array(
+				$params_get_range_msgs = array(
 					'folder' 			=> $this->folders[$this->current_folder]['folder_id'],
 					'msg_range_begin' 	=> $this->current_page * $this->messages_per_page - ($this->messages_per_page - 1),
@@ -416,9 +406,8 @@
 				);
 
-				$messages = $this->imap_functions->get_range_msgs2($params);
+				$messages = $this->imap_functions->get_range_msgs2($params_get_range_msgs);
 			}
 			$this->print_mails_list($messages);
 			$this->print_page_navigation($this->pages, $this->current_page);
-
 		}
 
