Index: /branches/2.2/mobile/setup/phpgw_pt-br.lang
===================================================================
--- /branches/2.2/mobile/setup/phpgw_pt-br.lang	(revision 3564)
+++ /branches/2.2/mobile/setup/phpgw_pt-br.lang	(revision 3571)
@@ -1,3 +1,5 @@
+attachment	mobile	pt-br	Anexo
 Add Recipient	mobile	pt-br	Adicionar Destinatário
+cancel	mobile	pt-br	Cancelar
 Calendar	mobile	pt-br	Agenda
 contact center	mobile	pt-br	Endereços
@@ -9,4 +11,6 @@
 download attachs	mobile	pt-br	Deseja baixar anexos em e-mails?
 Download	mobile	pt-br	Efetuar o download do anexo
+draft not save	mobile	pt-br	Rascunho não foi salvo
+draft saved	mobile	pt-br	Rascunho foi guardado com sucesso
 Drafts	mobile	pt-br	Rascunhos
 E-mail	mobile	pt-br	Caixa de Entrada
@@ -15,11 +19,17 @@
 Logout	mobile	pt-br	Sair
 To	mobile	pt-br	Para
+cc	mobile	pt-br	Com Cópia
 my mail	mobile	pt-br	Meus E-mails
+my contacts	mobile	pt-br	Meus Contatos
 my commitments	mobile	pt-br	Meus Compromissos
 my folders	mobile	pt-br	Minhas Pastas
 mark as read	mobile	pt-br	marcar como lido
+mark as important	mobile	pt-br	marcar como importante
+read confirmation	mobile	pt-br	receber confirmação de leitura
+add history	mobile	pt-br	adicionar histórico
 new mail	mobile	pt-br	Novo
+save draft	mobile	pt-br	Salvar rascunho
 Subject	mobile	pt-br	Assunto
-Send	mobile	pt-br	Enviar mensagem
+Send	mobile	pt-br	Enviar
 Reply	mobile	pt-br	Responder
 Reply to All	mobile	pt-br	Responder a Todos
@@ -46,4 +56,5 @@
 error	mobile	pt-br	Error: 
 Some addresses in the To field were not recognized. Please make sure that all addresses are properly formed	mobile	pt-br	Alguns endereços no campo "Para" não foram reconhecidos. Por favor certifique-se que todos endereços estão corretos
+Some addresses in the CC field were not recognized. Please make sure that all addresses are properly formed	mobile	pt-br	Alguns endereços no campo "Com Cópia" não foram reconhecidos. Por favor certifique-se que todos endereços estão corretos
 Empty folder	mobile	pt-br	Pasta vazia
 Accept	mobile	pt-br	Aceitar
@@ -97,3 +108,3 @@
 minutes ago	mobile	pt-br	minutos atrás
 minute ago	mobile	pt-br	minuto atrás
-New message	mobile	pt-br	Nova mensagem - 
+New message	mobile	pt-br	Nova mensagem
Index: /branches/2.2/mobile/inc/class.mobiletemplate.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.mobiletemplate.inc.php	(revision 3564)
+++ /branches/2.2/mobile/inc/class.mobiletemplate.inc.php	(revision 3571)
@@ -13,5 +13,7 @@
 			$this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
 			$this->template->set_file(Array('home_t' => 'template.tpl'));	
-			$this->template->set_block('home_t', 'mobile_home');			
+			$this->template->set_block('home_t', 'mobile_home');	
+			$this->template->set_block('home_t','success_message');
+			$this->template->set_block('home_t','error_message');		
 		}
 
@@ -25,4 +27,34 @@
 			$this->template->set_var("content", $pre_content.$content);
 		}
+		
+		/*
+		* @function set_msg
+	 	* @abstract Seta a mensagem de sucesso ou error a depender do tipo.
+	 	* @author Thiago Antonius
+	 	*/		
+		public function set_msg($msg, $type){
+			if(isset($msg) && trim($msg)!="") {
+				$this->template->set_var("message", $msg);
+				$this->template->parse("message_box", $type."_message", true);
+			}
+		}		
+		
+		/*
+		* @function set_success_msg
+	 	* @abstract Seta a mensagem de sucesso.
+	 	* @author Thiago Antonius
+	 	*/		
+		public function set_success_msg($msg){
+			$this->set_msg($msg, "success");
+		}
+
+			/*
+		* @function set_error_msg
+	 	* @abstract Seta a mensagem de erro
+	 	* @author Thiago Antonius
+	 	*/		
+		public function set_error_msg($msg){
+			$this->set_msg($msg, "error");
+		}		
 
 		/*
@@ -31,9 +63,9 @@
 	 	* @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
 	 	*/
-		public function print_page($class, $method){		
+		public function print_page($class, $method){
 			$this->print_header();
 			$this->print_navbar();
 			$filename = 'inc/class.'.$class.'.inc.php';
-			include_once($filename);	
+			include_once($filename);
 			$obj = new $class();		
 			$obj -> $method($_REQUEST);
Index: /branches/2.2/mobile/inc/class.ui_home.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.ui_home.inc.php	(revision 3567)
+++ /branches/2.2/mobile/inc/class.ui_home.inc.php	(revision 3571)
@@ -1,5 +1,5 @@
 <?php
     class ui_home {
-		var $imap_functions;    
+		var $imap_functions;
 		var $db;
 		var $bocalendar;
@@ -20,6 +20,6 @@
 		}
 		
-		function index($params) {			
-			$this->template->set_file(Array('home_index' => 'home_index.tpl'));
+		function index($params) {
+			$this->template->set_file(array('home_index' => 'home_index.tpl'));
 			$this->template->set_block('home_index','page');	
 			$this->template->set_block('home_index','folder_block');
@@ -34,4 +34,5 @@
 			$this->template->set_var('lang_my_folders', lang("my folders"));
 			$this->template->set_var('lang_my_commitments', lang("my commitments"));
+      $this->template->set_var('lang_my_contacts', lang("my contacts"));
 			$this->template->set_var('lang_new_mail', lang("new mail"));
 			$this->template->set_var('lang_mark_as_read', lang("mark as read"));
@@ -88,6 +89,7 @@
 				
 				$this->template->parse('commitments_box', 'commitment_block' ,True);
-			}			
+			}
 			
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg($params["success_message"]);
 			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page'));
 		}
@@ -109,5 +111,5 @@
 				$this->template->set_var('folder_total_msg', $this->imap_functions->get_num_msgs(array('folder' => $folder["folder_id"] ) ) );
 				
-				$this->template->parse($box_target, 'folder_block' ,True);
+				$this->template->parse($box_target, 'folder_block' ,true);
 			}
 		}
Index: /branches/2.2/mobile/inc/class.ui_mobilemail.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.ui_mobilemail.inc.php	(revision 3501)
+++ /branches/2.2/mobile/inc/class.ui_mobilemail.inc.php	(revision 3571)
@@ -30,10 +30,11 @@
 			'confirm_delete_msg'	=> True,
 			'init_schedule' => true,
-			'redirect' => true,
 			'add_recipients' => true,
 			'add_recipient' => true,
-			'list_folders' => true
+			'list_folders' => true,
+			'save_draft' => true
 		);
 
+		var $template;
 		var $folders; // Pastas imap
 		var $current_folder; // Pasta corrente
@@ -51,7 +52,7 @@
 		function ui_mobilemail()
 		{
-
 			$this-> load_session();						
-
+			$this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
+			
 			// Recupera atributos da classe gravados na sessão
 			$folders = $GLOBALS['phpgw']->session->appsession('mobilemail.folders','mobile');
@@ -100,9 +101,7 @@
 		function save_session()
 		{
-
 			$GLOBALS['phpgw']->session->appsession('mobilemail.folders','mobile',$this->folders);
 			$GLOBALS['phpgw']->session->appsession('mobilemail.current_folder','mobile',$this->current_folder);
 			$GLOBALS['phpgw']->session->appsession('mobilemail.current_page','mobile',$this->current_page);
-
 		}
 
@@ -161,47 +160,42 @@
 
 			// Carrega o template
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-			$p->set_file(
-				Array(
-					'view_msg_t' => 'view_msg.tpl'
-				)
-			);
-			$p->set_block('view_msg_t', 'mail_header');
-			$p->set_block('view_msg_t', 'mail_body');
-			$p->set_block('view_msg_t', 'mail_footer');
-			$p->set_block('view_msg_t', 'reply_msg');
-			$p->set_block('view_msg_t', 'attachment_list');
-			$p->set_block('view_msg_t', 'begin_anchor');
-			$p->set_block('view_msg_t', 'end_anchor');
+			$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');
 
 			// Define o cabeçalho do e-mail
-			$p->set_var('from_label', lang("From"));
-			$p->set_var('from', $msg['from']['full']);
-			$p->set_var('to_label', lang("To"));
-
-			$p->set_var('subject_label', lang("Subject"));
-			$p->set_var('subject', $msg['subject']);
-			$p->set_var('date_label', lang("Date"));
-			$p->set_var('date', $msg['fulldate']);
+			$this->template->set_var('from_label', 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('subject', $msg['subject']);
+			$this->template->set_var('date_label', lang("Date"));
+			$this->template->set_var('date', $msg['fulldate']);
 
 
 			// Mostra o corpo do e-mail
-			$p->set_var('body', strip_tags($msg['body'], $this->allowed_tags)); // Usa a função strip_tags() para filtrar
+			$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.
-			$p->set_var('link_text', lang("Return"));
-			$p->set_var('link', "index.php?menuaction=mobile.ui_mobilemail.mail_list");
-
-
-			$p->set_var('reply_all_text', lang("Reply to all"));
-			$p->set_var('forward_text', lang("Forward"));
-
-			$p->set_var('reply_text', lang("Reply"));
-			$p->set_var('Delete', lang("Delete"));
+			$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'];
-			$p->set_var('reply', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder");
-			$p->set_var('delete', "index.php?menuaction=mobile.ui_mobilemail.confirm_delete_msg&msg_number=$msg_number&msg_folder=$msg_folder");
-			$p->set_var('reply_all', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&reply_all=true");
-			$p->set_var('forward', "index.php?menuaction=mobile.ui_mobilemail.new_msg&msg_number=$msg_number&msg_folder=$msg_folder&forward=true");
+			$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");
 			if (!empty($msg['attachments']))
 			{
@@ -215,30 +209,30 @@
 									  lang('Download').":&nbsp;".$attach['name']."</a><br>";
 					}
-					$p->set_var('attachment_message', $attachs);
-				}
-				//$p->set_var('attachment_message', lang('This message have attachment(s)'));
+					$this->template->set_var('attachment_message', $attachs);
+				}
+				//$this->template->set_var('attachment_message', lang('This message have attachment(s)'));
 			}
 			else
 			{
-				$p->set_var('attachment_message', lang('This message don\'t have attachment(s)'));
-			}
-
-			$p->parse('view_msg_t', 'end_anchor');
-			$p->parse('view_msg_t', 'begin_anchor');
-			//$p->pfp('view_msg_t', 'mail_header');
-			/*$p->pfp('out', 'mail_header');
-			//$p->pfp('view_msg_t', 'mail_body');
-			$p->pfp('out', 'mail_body');
-			//$p->pfp('view_msg_t', 'attachment_list');
-			$p->pfp('out', 'attachment_list');
-			//$p->pfp('view_msg_t', 'mail_footer');
-			$p->pfp('out', 'reply_msg');
-			//$p->pfp('out', 'mail_footer');*/
-
-			//$p->pfp('view_msg_t', 'mail_header');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_header'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mail_body'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'attachment_list'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'reply_msg'));
+				$this->template->set_var('attachment_message', lang('This message don\'t have attachment(s)'));
+			}
+
+			$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'));
 		}
 
@@ -310,23 +304,18 @@
 		function print_folder_selection()
 		{
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-			$p->set_file(
-				Array(
-					'mobilemail_t' => 'mobilemail.tpl'
-				)
-			);
-			$p->set_block('mobilemail_t', 'inbox_folder_list');
-			$p->set_var('lang_folder', lang('Folder'));
+			$this->template->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
+			$this->template->set_block('mobilemail_t', 'inbox_folder_list');
+			$this->template->set_var('lang_folder', lang('Folder'));
 			$folder = str_replace("*","",lang($this->folders[$this->current_folder]['folder_name']));
 			if(!$this->current_folder == 0){
-				$p->set_var('lang_inbox', $folder.' :: <a title="'.lang('Inbox').'" href="index.php?menuaction=mobile.ui_mobilemail.mail_list&folder=0">'.lang('Inbox').'</a>');
+				$this->template->set_var('lang_inbox', $folder.' :: <a title="'.lang('Inbox').'" href="index.php?menuaction=mobile.ui_mobilemail.mail_list&folder=0">'.lang('Inbox').'</a>');
 			}else{
-				$p->set_var('lang_inbox', lang('Inbox'));
-			}
-			
-			//$p->set_var('folder_items', $folder_items);
-			$p->parse('mobilemail_t', 'inbox_folder_list');			
-			//$p->fpf('out', 'mobilemail_t');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mobilemail_t'));
+				$this->template->set_var('lang_inbox', lang('Inbox'));
+			}
+			
+			//$this->template->set_var('folder_items', $folder_items);
+			$this->template->parse('mobilemail_t', 'inbox_folder_list');			
+			//$this->template->fpf('out', 'mobilemail_t');
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'mobilemail_t'));
 
 		}
@@ -347,11 +336,6 @@
 
 				$option_selected = '';
-				$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-				$p->set_file(
-					Array(
-						'mobilemail_t' => 'mobilemail.tpl'
-					)
-				);
-				$p->set_block('mobilemail_t', 'folder_item');
+				$this->template->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
+				$this->template->set_block('mobilemail_t', 'folder_item');
 
 				if (is_numeric($i))
@@ -362,15 +346,15 @@
 					}
 
-					$p->set_var('option_selected', $option_selected);
-					$p->set_var('folder_id', $j['folder_id']);
-					$p->set_var('folder_name', $j['folder_id']); // Mudar... provavelmente usar preg_replace
+					$this->template->set_var('option_selected', $option_selected);
+					$this->template->set_var('folder_id', $j['folder_id']);
+					$this->template->set_var('folder_name', $j['folder_id']); // Mudar... provavelmente usar preg_replace
 													   			 // para substituir cpf pelo nome do usuário.
 
 					if ($j['folder_unseen'] > 0)
 					{
-						$p->set_var('folder_unseen', ' - ('.$j['folder_unseen'].')');
+						$this->template->set_var('folder_unseen', ' - ('.$j['folder_unseen'].')');
 					}
 
-					$folder_items .= $p->fp('mobile_t', 'folder_item');
+					$folder_items .= $this->template->fp('mobile_t', 'folder_item');
 				}
 
@@ -378,15 +362,10 @@
 
 			// Processa o select
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-			$p->set_file(
-				Array(
-					'mobilemail_t' => 'mobilemail.tpl'
-				)
-			);
-			$p->set_block('mobilemail_t', 'folder_list');
-			$p->set_var('folder_items', $folder_items);
-			$p->parse('mobilemail_t', 'folder_list');			
-			//$p->pfp('out', 'mobilemail_t');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'mobilemail_t'));
+			$this->template->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
+			$this->template->set_block('mobilemail_t', 'folder_list');
+			$this->template->set_var('folder_items', $folder_items);
+			$this->template->parse('mobilemail_t', 'folder_list');			
+			//$this->template->pfp('out', 'mobilemail_t');
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'mobilemail_t'));
 
 		}
@@ -409,7 +388,4 @@
 					isset($GLOBALS['phpgw_info']['user']['preferences']['mobile']['max_message_per_page'])?
 					$GLOBALS['phpgw_info']['user']['preferences']['mobile']['max_message_per_page']:10; 
-//		var $pages;
-//		var $actual_page;
-//		var $number_of_messages;
 
 			if (!isset($this->number_of_messages))
@@ -458,5 +434,6 @@
 			// Cria a lista de e-mails
 			$mail_rows = '';
-            $unread_msg_count = 0;
+      $unread_msg_count = 0;
+      
 			if ($this->number_of_messages != 0)
 			{
@@ -464,10 +441,6 @@
 				foreach ($messages as $index => $msg)
 				{
-					$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-					$p->set_file(
-						Array(
-							'mobilemail_t' => 'mobilemail.tpl'
-						)
-					);
+				  $p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
+					$p->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
 					$p->set_block('mobilemail_t', 'mail_row');
 					$p->set_block('mobilemail_t', 'end_strong');
@@ -499,12 +472,8 @@
 					}
 				}
-
+    
 				// Imprime a lista de e-mails
 				$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-				$p->set_file(
-					Array(
-						'mobilemail_t' => 'mobilemail.tpl'
-					)
-				);
+				$p->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
 				$p->set_block('mobilemail_t', 'mail_list');
 				$p->set_var('mail_rows', $mail_rows);
@@ -523,9 +492,5 @@
 				// Lista de e-mails vazia
 				$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-				$p->set_file(
-					Array(
-						'mobilemail_t' => 'mobilemail.tpl'
-					)
-				);
+				$p->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
 				$p->set_block('mobilemail_t', 'empty_list');
 				$p->set_var('empty_message', lang('Empty folder'));				
@@ -554,11 +519,6 @@
 				{
 
-					$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-					$p->set_file(
-						Array(
-							'mobilemail_t' => 'mobilemail.tpl'
-						)
-					);
-
+          $p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
+					$p->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
 					$p->set_block('mobilemail_t', 'space');
 					$p->set_block('mobilemail_t', 'begin_anchor');
@@ -595,9 +555,5 @@
 				// Geração dos links "anterior" e "próximo"
 				$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-				$p->set_file(
-					Array(
-						'mobilemail_t' => 'mobilemail.tpl'
-					)
-				);
+				$p->set_file(array('mobilemail_t' => 'mobilemail.tpl'));
 
 				//$p->set_block('mobilemail_t', 'space');
@@ -649,47 +605,22 @@
 		}
 
-		/*
-		 * @function new_msg()
-		 * @abstract Gera o formulário para criar novo e-mail.
-		 * @author Rommel de Brito Cysne <rommel.cysne@serpro.gov.br>
-		 
-		function new_msg()
-		{
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-			$p->set_file(
-				Array(
-					'new_msg_t' => 'new_msg.tpl'
-				)
-			);
-
-			$p->set_block('new_msg_t', 'msg_header');
-			$p->set_block('new_msg_t', 'text');
-			$p->set_block('new_msg_t', 'begin_form');
-			$p->set_block('new_msg_t', 'end_form');
-			$p->set_block('new_msg_t', 'hidden_area');
-
-			$p->set_var('to_label', lang("To"));
-			$p->set_var('to', "");
-			$p->set_var('to_mail', "");
-
-			$p->set_var('subject_label', lang("Subject"));
-			$p->set_var('subject', "");
-
-			$p->set_var('msg_number', $_GET['msg_number']);
-			$p->set_var('msg_folder', $_GET['msg_folder']);
-
-			$p->set_var('send_label', lang("Send"));
-
-			$p->set_var('form_action', "index.php?menuaction=mobile.ui_mobilemail.send_mail");
-
-			$p->pfp('out', 'begin_form');
-			$p->pfp('out', 'msg_header');
-			$p->pfp('out', 'text');
-			$p->pfp('out', 'hidden_area');
-			$p->pfp('out', 'end_form');
-
-		
-		}
-*/
+		function define_action_message($type) {
+			switch($type) {
+				case "clk":
+				case "cc_mob":
+					$this->template->set_var('action_msg', lang("New message"));
+					break;
+				case "reply_all":
+					$this->template->set_var('action_msg', lang("Reply All"));
+					break;
+				case "user_add":
+					$this->template->set_var('action_msg', lang("Add Recipient"));
+					break;
+				case "forward":
+					$this->template->set_var('action_msg', lang("Forward"));
+					break;						
+			}
+		}
+		
 		/*
 		 * @function new_msg()
@@ -697,152 +628,155 @@
 		 * @author Rommel de Brito Cysne <rommel.cysne@serpro.gov.br>
 		 */
-		
-		function new_msg()
-		{
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-			$p->set_file(
-				Array(
-					'new_msg_t' => 'new_msg.tpl'
-				)
-			);
-
-
-			if (isset($_GET['msg_number']))
-			{
-				$params = array(
-					'msg_number' => $_GET['msg_number'],
-				);
-
-				$msg_number = $_GET['msg_number'];
-			}
-		
-			if($params)
-			{
-				$msg = $this->imap_functions->get_info_msg($params);
-			}
-
-			$p->set_block('new_msg_t', 'msg_header');
-			$p->set_block('new_msg_t', 'text');
-			$p->set_block('new_msg_t', 'begin_form');
-			$p->set_block('new_msg_t', 'end_form');
-			$p->set_block('new_msg_t', 'hidden_area');
-
-			if($_GET['clk'])
-			{
-				$p->set_var('field_add_user', '<p>&nbsp;&nbsp;<input type="submit" name="action" value="'.lang("Add Recipient").'"></p>');
-				$p->set_var('to_label', lang("To"));
-				$p->set_var('to', "");
-				$p->set_var('to_mail', "");
-				$p->set_var('subject_label', lang("Subject"));
-				$p->set_var('subject', "");
-
-			}
-			else if($_GET['cc_mob'])
-			{
-
-				$p->set_var('to_label', lang("To"));
-				$p->set_var('to', $_GET['input_to']);
-				$p->set_var('to_mail', $_GET['input_to_mail']);
-
-				$p->set_var('subject_label', lang("Subject"));
-				$p->set_var('subject', "");
-
-				$p->set_var('msg_number', $_GET['msg_number']);
-				$p->set_var('msg_folder', $_GET['msg_folder']);
-
-				$p->set_var('read_only', 'readonly');
-			}
-			else if($_GET['reply_all']){
-				$reply_to_all = $msg['from']['full'];
-				$reply_to_all = $msg['toaddress2'] ? $reply_to_all.','.$msg['toaddress2']:$reply_to_all;
-				$reply_to_all = $msg['cc'] ? $reply_to_all.','.$msg['cc']:$reply_to_all;
-				$reply_to_all = $msg['bcc'] ? $reply_to_all.','.$msg['bcc']:$reply_to_all;
-				$names = implode(',<br/>',explode(',',$reply_to_all));
+		function new_msg($params)
+		{
+			$this->template->set_file(array('new_msg_t' => 'new_msg.tpl'));
+			$this->template->set_block('new_msg_t', 'page');
+			$this->template->set_block('new_msg_t', 'add_recipient_block');
+			$this->template->set_var('lang_back', lang("back"));
+			$this->template->set_var('lang_calendar', strtoupper(lang("Calendar")));
+			$this->template->set_var('lang_send', strtoupper(lang("Send")));
+			$this->template->set_var('lang_attachment', strtoupper(lang("attachment")));
+			$this->template->set_var('lang_cancel', strtoupper(lang("cancel")));
+			$this->template->set_var('lang_save_draft', strtoupper(lang("save draft")));
+			$this->template->set_var('type', $_GET['type']);
+			$this->template->set_var('lang_to', lang("To"));
+			$this->template->set_var('lang_cc', lang("cc"));
+			$this->template->set_var('lang_subject', lang("Subject"));
+			$this->template->set_var('lang_mark_as_important', lang("mark as important"));
+			$this->template->set_var('lang_read_confirmation', lang("read confirmation"));
+			$this->template->set_var('lang_add_history', lang("add history"));
+			
+			
+			$this->template->set_var('type', $_REQUEST['type']);
+			$this->template->parse('add_recipient_box', 'add_recipient_block', true);
+
+			$this->define_action_message($_REQUEST['type']);
+			
+			if(isset($params["error_message"])) {
+				$this->template->set_var('to', $_POST['input_to']);
+				$this->template->set_var('to_mail', $_POST['input_to_mail']);
+				$this->template->set_var('cc', $_POST['input_cc']);
+				$this->template->set_var('cc_mail', $_POST['input_cc_mail']);
+				$this->template->set_var('subject', $_POST['input_subject']);
+				$this->template->set_var('msg_number', $_POST['msg_number']);
+				$this->template->set_var('msg_folder', $_POST['msg_folder']);
+				$this->template->set_var('body_value', $_POST['body']);
+				$this->template->set_var('msg_folder', $_POST['folder']);
+				$this->template->set_var('msg_number', $_POST['reply_msg_number']);
+				$this->template->set_var('from', $_POST['reply_from']);
+				$this->template->set_var('check_important', ( ( $_POST['check_important'] ) ? "checked" : "" ) );
+				$this->template->set_var('check_read_confirmation', ( ( $_POST['check_read_confirmation'] )  ? "checked" : "" ) );
+				$this->template->set_var('check_add_history', ( ( $_POST['check_add_history'] )  ? "checked" : "" ) );
 				
-				$array_emails = explode(',',$reply_to_all);
-				$reply_to_all ='';
-				foreach ($array_emails as $index => $email){
-					$flag = preg_match('/&lt;(.*?)&gt;/',$email,$reply);
-					$reply_to_all .= $flag == 0 ? $email.', ':$reply[1].', ';
-				}
-								
-				$p->set_var('to_label', lang("To"));
-				$p->set_var('to', $reply_to_all);
-
-				$p->set_var('to_mail', $_GET['input_to_mail']);
-
-				$p->set_var('subject_label', lang("Subject"));
-				$p->set_var('subject', "Re:" . $msg['subject']);
-
-				$p->set_var('msg_number', $_GET['msg_number']);
-				$p->set_var('msg_folder', $_GET['msg_folder']);
-			}
-			else if($_GET['user_add']){
-				$p->set_var('to_label', lang("To"));
+				$GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]);
+			} else {
+				if (isset($_GET['msg_number'])) $msg = $this->imap_functions->get_info_msg(array('msg_number' => $_GET['msg_number'] ) );
 				
-				$listMail = implode(',',$_SESSION['mobile_mail']);
-				
-				$p->set_var('field_add_user', '<p>&nbsp;&nbsp;<input type="submit" name="action" value="'.lang("Add Recipient").'"></p>');
-				$p->set_var('to', $listMail);
-				$p->set_var('to_mail', $listMail);
-				$p->set_var('subject_label', lang("Subject"));
-				$p->set_var('subject', $_SESSION['subject_mail']);
-				$p->set_var('body_value', $_SESSION['body_mail']);				
-
-				$p->set_var('msg_number', $_GET['msg_number']);
-				$p->set_var('msg_folder', $_GET['msg_folder']);			
-		
-			}
-			else if($_GET['forward']){
-				$p->set_var('field_add_user', '<p>&nbsp;&nbsp;<input type="submit" name="action" value="'.lang("Add Recipient").'"></p>');
-				$p->set_var('from_label', lang("From"));
-				$p->set_var('from', $msg['toaddress2']);
-
-				$p->set_var('to_label', lang("To"));
-				$mail_to = $msg['from']['full'];
-
-				$p->set_var('subject_label', lang("Subject"));
-				$p->set_var('subject', "Enc:" . $msg['subject']);
-				$p->set_var('body_value', strip_tags($msg['body'])); // Usa a função strip_tags() para filtrar
-				// as tags que estão presentes no corpo do e-mail.
-				
-				$p->set_var('msg_number', $_GET['msg_number']);
-				$p->set_var('msg_folder', $_GET['msg_folder']);			
-		
-			}
-			else{
-				$p->set_var('from_label', lang("From"));
-				$p->set_var('from', $msg['toaddress2']);
-
-				$p->set_var('to_label', lang("To"));
-				$mail_to = $msg['from']['full'];
-				$p->set_var('to', $msg['from']['name']);
-				$p->set_var('to_mail', $msg['from']['email']);
-
-				$p->set_var('subject_label', lang("Subject"));
-				$p->set_var('subject', "Re:" . $msg['subject']);
-
-				$p->set_var('msg_number', $_GET['msg_number']);
-				$p->set_var('msg_folder', $_GET['msg_folder']);
-
-				$p->set_var('read_only', "readonly");
-			}
-			$_SESSION['mobile_mail'] = Array();	
-			$p->set_var('send_label', lang("Send"));
-			$p->set_var('form_action', "index.php?menuaction=mobile.ui_mobilemail.redirect");
-
-			/*$p->pfp('out', 'begin_form');
-			$p->pfp('out', 'msg_header');
-			$p->pfp('out', 'text');
-			$p->pfp('out', 'hidden_area');
-			$p->pfp('out', 'end_form');*/
-			
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'begin_form'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'msg_header'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'text'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'hidden_area'));
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out', 'end_form'));
-		}
-
+				if($_REQUEST['type']=="clk")
+				{
+					$this->template->set_var('to', "");
+					$this->template->set_var('to_mail', "");
+					$this->template->set_var('cc', "");
+					$this->template->set_var('cc_mail', "");
+					$this->template->set_var('subject', "");
+				}
+				else if($_REQUEST['type']=="cc_mob")
+				{
+					$this->template->set_var('to', $_GET['input_to']);
+					$this->template->set_var('to_mail', $_GET['input_to_mail']);
+					$this->template->set_var('cc', $_GET['input_cc']);
+					$this->template->set_var('cc_mail', $_GET['input_cc_mail']);
+					$this->template->set_var('subject', "");
+	
+					$this->template->set_var('msg_number', $_GET['msg_number']);
+					$this->template->set_var('msg_folder', $_GET['msg_folder']);
+	
+					$this->template->set_var('read_only', 'readonly');
+				}
+				else if($_REQUEST['type']=="reply_all"){
+					$reply_to_all = $msg['from']['full'];
+					$reply_to_all = $msg['toaddress2'] ? $reply_to_all.','.$msg['toaddress2']:$reply_to_all;
+					$reply_to_all = $msg['cc'] ? $reply_to_all.','.$msg['cc']:$reply_to_all;
+					$reply_to_all = $msg['bcc'] ? $reply_to_all.','.$msg['bcc']:$reply_to_all;
+					$names = implode(',<br/>',explode(',',$reply_to_all));
+					
+					$array_emails = explode(',',$reply_to_all);
+					$reply_to_all ='';
+					
+					foreach ($array_emails as $index => $email){
+						$flag = preg_match('/&lt;(.*?)&gt;/',$email,$reply);
+						$reply_to_all .= $flag == 0 ? $email.', ':$reply[1].', ';
+					}
+									
+					$this->template->set_var('to', $reply_to_all);
+					$this->template->set_var('to_mail', $_GET['input_to_mail']);
+					$this->template->set_var('subject', "Re:" . $msg['subject']);
+	
+					$this->template->set_var('msg_number', $_GET['msg_number']);
+					$this->template->set_var('msg_folder', $_GET['msg_folder']);
+				}
+				else if($_REQUEST['type']=="user_add"){
+					$listMail = implode(',',$_SESSION['mobile_mail']);
+					
+					$this->template->set_var('to', $listMail);
+					$this->template->set_var('to_mail', $listMail);
+					$this->template->set_var('subject', $_SESSION['subject_mail']);
+					$this->template->set_var('body_value', $_SESSION['body_mail']);
+	
+					$this->template->set_var('msg_number', $_GET['msg_number']);
+					$this->template->set_var('msg_folder', $_GET['msg_folder']);			
+				}
+				else if($_REQUEST['type']=="forward"){
+					$this->template->set_var('from', $msg['toaddress2']);
+	
+					$mail_to = $msg['from']['full'];
+	
+					$this->template->set_var('subject', "Enc:" . $msg['subject']);
+					$this->template->set_var('body_value', strip_tags($msg['body'])); // Usa a função strip_tags() para filtrar
+					// as tags que estão presentes no corpo do e-mail.
+					
+					$this->template->set_var('msg_number', $_GET['msg_number']);
+					$this->template->set_var('msg_folder', $_GET['msg_folder']);		
+				}
+				else{
+					$this->template->set_var('from', $msg['toaddress2']);
+	
+					$mail_to = $msg['from']['full'];
+					$this->template->set_var('to', $msg['from']['name']);
+					$this->template->set_var('to_mail', $msg['from']['email']);
+	
+					$this->template->set_var('subject', "Re:" . $msg['subject']);
+	
+					$this->template->set_var('msg_number', $_GET['msg_number']);
+					$this->template->set_var('msg_folder', $_GET['msg_folder']);
+	
+					$this->template->set_var('read_only', "readonly");
+				}				
+			}
+			
+			$_SESSION['mobile_mail'] = array();
+			
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out', 'page'));
+		}
+
+				/*
+		 * @function save_draft()
+		 * @abstract Função que salva o email como rascunho
+		 * @author Thiago Antonius
+		 */
+		function save_draft($params)
+		{
+			$params["folder"] = "INBOX/".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'];
+			$return = $this->imap_functions->save_msg($params);
+			if($return["has_error"]) {
+				$params["error_message"] = lang("draft not save")."<br>".lang("error") . $return["append"];
+				$this->new_msg( $params );
+			}else {
+				$ui_home = CreateObject('mobile.ui_home');
+				$params["success_message"] = lang("draft saved");
+				$ui_home->index( $params );
+			}				
+		}
+		
 		/*
 		 * @function send_mail()
@@ -858,11 +792,15 @@
 			$userName = $_POST['input_to']; //"User Someone";
 			$userMail = $_POST['input_to_mail']; //"user.someone@mail.com.br";
+			$ccUserName = $_POST['input_cc'];
+			$ccUserMail = $_POST['input_cc_mail'];			
 			$subject = $_POST['input_subject']; //"Mail Subject";
 			$body = $_POST['body']; //"Mail body. Any text.";
-
-			if($userMail == "")
-			{
-				$userMail = $userName;
-			}
+			$isImportant = $_POST['check_important'];
+			$addHistory = $_POST['check_add_history'];
+			$readConfirmation = $_POST['check_read_confirmation'];
+			$msgNumber = $_POST['reply_msg_number'];
+
+			if($userMail == "") $userMail = $userName;
+			if($ccUserMail == "") $ccUserMail = $ccUserName;
 
 			//Cria objeto
@@ -873,4 +811,9 @@
 				$error_msg = lang("Some addresses in the To field were not recognized. Please make sure that all addresses are properly formed");
 			}
+			
+			if(!$this->imap_functions->add_recipients("cc", $ccUserMail, &$mail))
+			{
+				$error_msg = lang("Some addresses in the CC field were not recognized. Please make sure that all addresses are properly formed");
+			}			
 
 			$mail->IsSMTP();
@@ -885,42 +828,27 @@
 			//Nome do remetente do email
 			$mail->SenderName = $mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];
-			//Endereço de destino do email, ou seja, pra onde a mensagem vai
-			//$mail->AddAddress("$userMail");
 			//Assunto da mensagem
 			$mail->Subject = $subject;
 			//Corpo da mensagem
 			$mail->Body .= "<br />$body<br />";
-
-			//Cria um objeto template
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
-			//Define o template para mensagens de retorno da funcao
-			$p->set_file(
-				Array(
-					'sent_msg_t' => 'sent_msg.tpl'
-				)
-			);
-
-			$p->set_block('sent_msg_t','retorno');
-			@header('Refresh: 1; url=./');
+			//Important message
+			if($isImportant) $mail->isImportant();
+			//add history
+			if($addHistory && $msgNumber) {
+				$msg = $this->imap_functions->get_info_msg(array('msg_number' => $msgNumber ) );
+				$mail->Body .= "<br />".$msg['body']."<br />";						
+			}
+			//read confirmation
+			if ($readConfirmation) $mail->ConfirmReadingTo = $_SESSION['phpgw_info']['expressomail']['user']['email'];
 
 			//Se o e-mail nao for enviado por qualquer motivo...
-			if(!$mail->Send())
-			{
-				//... é exibida a mensagem abaixo e o respectivo erro...
-				$p->set_var('msg', lang("Message not sent"));
-				$p->set_var('erro', lang("error") . $mail->ErrorInfo);
-
-			//... caso contrário...
+			if(!$mail->Send()) {
+				$params["error_message"] = lang("Message not sent")."<br>".lang("error") . $mail->ErrorInfo;
+				$this->new_msg( $params );
 			}else {
-				//... mostra mensagem de sucesso e link de retorno à lista de e-mail
-				$p->set_var('msg', lang("Message sent successfully"));
-				//$p->set_var('link_text', lang("Return"));
-				//$p->set_var('link', "mobilemail_index.php");
-
-			}
-
-			//$p->pfp('out','retorno');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','retorno'));
-
+				$ui_home = CreateObject('mobile.ui_home');
+				$params["success_message"] = lang("Message sent successfully");
+				$ui_home->index($params);
+			}
 		}
 
@@ -928,19 +856,14 @@
 		{					
 			//Cria um objeto template
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
 			//Define o template para mensagens de retorno da funcao
-			$p->set_file(
-				Array(
-					'delete_msg_t' => 'delete_msg.tpl'
-				)
-			);
-			$p->set_block('delete_msg_t','retorno');			
-			$p->set_var('lang_delete_msg', lang("Do you like to delete this message?"));				
-			$p->set_var('lang_yes', lang("Yes"));	
-			$p->set_var('lang_no', lang("No"));
-			$p->set_var('link_yes', 'index.php?menuaction=mobile.ui_mobilemail.delete_msg&msg_number='.$_GET['msg_number'].'&msg_folder='.$_GET['msg_folder']);
-			$p->set_var('link_no', 'index.php?menuaction=mobile.ui_mobilemail.show_msg&amp;msg_number='.$_GET['msg_number'].'&amp;msg_folder='.$_GET['msg_folder']);	
-			
-			$p->pfp('out','retorno');  
+			$this->template->set_file(array('delete_msg_t' => 'delete_msg.tpl'));
+			$this->template->set_block('delete_msg_t','retorno');			
+			$this->template->set_var('lang_delete_msg', lang("Do you like to delete this message?"));				
+			$this->template->set_var('lang_yes', lang("Yes"));	
+			$this->template->set_var('lang_no', lang("No"));
+			$this->template->set_var('link_yes', 'index.php?menuaction=mobile.ui_mobilemail.delete_msg&msg_number='.$_GET['msg_number'].'&msg_folder='.$_GET['msg_folder']);
+			$this->template->set_var('link_no', 'index.php?menuaction=mobile.ui_mobilemail.show_msg&amp;msg_number='.$_GET['msg_number'].'&amp;msg_folder='.$_GET['msg_folder']);	
+			
+			$this->template->pfp('out','retorno');  
 		}
 
@@ -959,16 +882,11 @@
 			$this->imap_functions->move_messages($params);
 			//Cria um objeto template
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
 			//Define o template para mensagens de retorno da funcao
-			$p->set_file(
-				Array(
-					'move_msg_t' => 'sent_msg.tpl'
-				)
-			);
-			$p->set_block('move_msg_t','retorno');
+			$this->template->set_file(array('move_msg_t' => 'sent_msg.tpl'));
+			$this->template->set_block('move_msg_t','retorno');
 			//@header('Refresh: 1; url=./ui_mobilemail.index?folder='.$this->current_folder);			
-			$p->set_var('msg', lang("The message was moved to trash"));				
-
-			$p->pfp('out','retorno');				   
+			$this->template->set_var('msg', lang("The message was moved to trash"));				
+
+			$this->template->pfp('out','retorno');				   
 		    
 		}
@@ -989,7 +907,7 @@
 		
 		function init_schedule() {
-			
 			if($_POST['input_to'] != '' && !is_null($_POST['input_to']))
 				array_push($_SESSION['mobile_mail'],$_POST['input_to']);			
+
 			$_SESSION['subject_mail'] = $_POST['input_subject'];
 			$_SESSION['body_mail'] = $_POST['body'];
@@ -1017,21 +935,8 @@
 		}
 		
-		function redirect() {
-				if($_POST[action] == lang("Send")){
-					$this->send_mail();
-				}else{
-					$this->init_schedule();
-				}
-		}
-		
 		function list_folders(){			
-			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
 			//Define o template para mensagens de retorno da funcao
-			$p->set_file(
-				Array(
-					'folders_t' => 'folders.tpl'
-				)
-			);
-			$p->set_block('folders_t','retorno');
+			$this->template->set_file(array('folders_t' => 'folders.tpl'));
+			$this->template->set_block('folders_t','retorno');
 			
 			$folders_list = '';
@@ -1055,6 +960,6 @@
 				}
 			}
-			$p->set_var('folders_list', $folders_list);
-			$p->pfp('out','retorno');				   
+			$this->template->set_var('folders_list', $folders_list);
+			$this->template->pfp('out','retorno');				   
 
 		}
Index: /branches/2.2/mobile/index.php
===================================================================
--- /branches/2.2/mobile/index.php	(revision 3268)
+++ /branches/2.2/mobile/index.php	(revision 3571)
@@ -11,12 +11,12 @@
 	{
 		//$location = 'Location: ' . $fwConstruct . 'login.php';
-                if ($_SERVER['HTTPS'] != 'on')
-                    {
-                        $aux = 'http://';
-                    }
-                else
-                    {
-                         $aux = 'https://';
-                    }
+    if ($_SERVER['HTTPS'] != 'on')
+    {
+        $aux = 'http://';
+    }
+    else
+    {
+			$aux = 'https://';
+    }
 		Header('Location: ' . $aux . $fwConstruct . '/mobile/login.php');
 		exit;
@@ -34,7 +34,7 @@
 	*/
 
-	if(isset($_GET['menuaction']))
+	if(isset($_REQUEST['menuaction']))
 	{
-		list($mobileapp,$class,$method) = explode('.',@$_GET['menuaction']);
+		list($mobileapp,$class,$method) = explode('.',@$_REQUEST['menuaction']);
 		if(! $mobileapp || ! $class || ! $method)
 		{
Index: /branches/2.2/mobile/login.php
===================================================================
--- /branches/2.2/mobile/login.php	(revision 3553)
+++ /branches/2.2/mobile/login.php	(revision 3571)
@@ -40,8 +40,8 @@
 	//verificando a mensagem erro ou sucesso
 	$cd = check_logoutcode($_GET['cd']);
-	$tmpl->set_var('cd', $cd);
+	$tmpl->set_var('message', $cd);
 	
 	if(trim($cd) != "")
-		$tmpl->parse('message_box', (($_GET['cd'] == 1) ? 'success_message' : 'error_message') ,True);
+		$tmpl->parse('message_box', (($_GET['cd'] == 1) ? 'success_message' : 'error_message') ,true);
 	
 	$tmpl->set_var('css',CreateObject("mobile.mobiletemplate")->get_mobile_css());
Index: /branches/2.2/mobile/templates/default/cc_main.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/cc_main.tpl	(revision 3460)
+++ /branches/2.2/mobile/templates/default/cc_main.tpl	(revision 3571)
@@ -55,5 +55,5 @@
 <form id="cc_form" name="cc_form" method="POST" action="{form_action}">
 	<tr bgcolor="{tr_color}">
-		<td><a href="{form_action}&input_to={row_nome}&input_to_mail={row_email}&cc_mob=1">{row_nome}</a></td>
+		<td><a href="{form_action}&input_to={row_nome}&input_to_mail={row_email}&type=cc_mob">{row_nome}</a></td>
 		<td align="center">{row_telefone}</td>
 		<td align="center">{row_mobile}</td>
Index: /branches/2.2/mobile/templates/default/new_msg.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/new_msg.tpl	(revision 3454)
+++ /branches/2.2/mobile/templates/default/new_msg.tpl	(revision 3571)
@@ -1,32 +1,45 @@
-<!-- BEGIN begin_form -->
-<h1>Novo email</h1>
-<hr />
-<form id="reply_form" method="POST" action="{form_action}">
-<!-- END begin_form -->
+<!-- BEGIN page -->
+<div class="menu-contexto">
+	<span><a href="javascript:history.back()">{lang_back}</a></span> <span class="titulo-secao">{action_msg}</span>
+</div>
 
-<!-- BEGIN msg_header -->
-<p><label for="input_to"><strong>{to_label}</strong>:</label> </p>
-<p><input type="text" size="30" id="input_to" name="input_to" value='{to}' "{read_only}" /></p>
-{field_add_user}
-<p><label for="input_subject"><strong>{subject_label}</strong>:</label> </p>
-<p><input type="text" size="30" id="input_subject" name="input_subject" value='{subject}' /></p>
-<!-- END msg_header -->
+<form method="POST" action="index.php?menuaction=mobile.ui_mobilemail.send_mail" id="mail_form">
+	<input type="hidden" id="input_to_mail" name="input_to_mail" value='{to_mail}' />
+	<input type="hidden" id="input_cc_mail" name="input_cc_mail" value='{cc_mail}' />
+	<input type="hidden" id="reply_from" name="reply_from" value='{from}' />
+	<input type="hidden" id="reply_msg_number" name="reply_msg_number" value='{msg_number}' />
+	<input type="hidden" id="folder" name="folder" value='{msg_folder}' />
+	<input type="hidden" name="type" value='{type}' />
+	
+	<div class="campos-correspondencia">
+		<div class="posiciona-esquerda">
+			<p><strong><label>{lang_to}</label></strong> <input id="input_to" name="input_to" value='{to}' "{read_only}"></p>
+			<p><strong><label>{lang_cc}</label></strong> <input id="input_cc" name="input_cc" value='{cc}' "{read_only}"></p>
+			<p><strong><label>{lang_subject}</label></strong> <input id="input_subject" name="input_subject" value='{subject}'></p>
+		</div>
+		
+		<div class="posiciona-esquerda">
+			{add_recipient_box}
+			<!--<p><button name="anexo" title="Anexar" class="btn-contexto">{lang_attachment}</button></p>-->
+		</div>
+	</div>
+				
+	<div id="corpo_mensagem">
+		<textarea id="body" wrap="virtual" name="body" cols="20" rows="10">{body_value}</textarea>
+		<p><input type="checkbox" name="check_important" {check_important} />{lang_mark_as_important}</p>
+		<p><input type="checkbox" name="check_read_confirmation" {check_read_confirmation} />{lang_read_confirmation}</p>
+		<p><input type="checkbox" name="check_add_history" {check_add_history} />{lang_add_history}</p>
+	</div>
+	
+	<div id="operacao_lista">
+		<a href="index.php?menuaction=mobile.ui_home.index"><button id="cancel" class="btn-generico" >{lang_cancel}</button></a>
+		<button id="save_draft" class="btn-generico" onclick="document.getElementById('mail_form').action='index.php?menuaction=mobile.ui_mobilemail.save_draft';document.getElementById('mail_form').submit()" >{lang_save_draft}</button></a>
+		<input type="submit" name="action" id="reply_send" value="{lang_send}" class="btn-generico"/>	
+	</div>
 
-<!-- BEGIN text -->
-<p><label for="body"><strong>Mensagem:</strong></label></p> 
-<p><textarea id="body" wrap="virtual" rows="8" name="body">{body_value}</textarea></p>
-<br />
-
-<p><input type="submit" name="action" id="reply_send" value="{send_label}" /></p>
-<!-- END text -->
-
-<!-- BEGIN hidden_area -->
-<p><input type="hidden" size="30" id="input_to_mail" name="input_to_mail" value='{to_mail}' /></p>
-<p><input type="hidden" size="30" id="reply_from" name="reply_from" value='{from}' /></p>
-<p><input type="hidden" size="30" id="reply_msg_number" name="reply_msg_number" value='{msg_number}' /></p>
-<p><input type="hidden" size="30" id="folder" name="folder" value='{msg_folder}' /></p>
-<!-- END hidden_area -->
-
-<!-- BEGIN end_form -->
 </form>
-<!-- END end_form -->
+<!-- END page -->
+<!-- BEGIN add_recipient_block -->
+<p><button name="action" title="Ver agenda" class="btn-contexto">{lang_calendar}</button></p>
+<p></p>
+<!-- END add_recipient_block -->
Index: /branches/2.2/mobile/templates/default/login.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/login.tpl	(revision 3564)
+++ /branches/2.2/mobile/templates/default/login.tpl	(revision 3571)
@@ -22,9 +22,7 @@
 					<input type="hidden" name="passwd_type" value="text">
 					<input type="hidden" name="account type" value="u">
-					<p><strong>{lang_username}:&nbsp</strong></p> 
-					<p><input name="login"></p>
+					<p><strong><label>{lang_username}:&nbsp</label></strong> <input name="login"></p>
 					<script>document.form_login.login.focus();</script>
-					<p><strong>{lang_password}:&nbsp</strong></p> 
-					<p><input name="passwd" type="password" autocomplete=off></p>
+					<p><strong><label>{lang_password}:&nbsp</label></strong> <input name="passwd" type="password" autocomplete=off></p>
 					<p><button name="submitit" class="btn-contexto">{lang_login}</button></p>
 				</form>
@@ -47,5 +45,5 @@
 <div class="bg-neutro">
 	<div class="aviso-positivo">
-		<strong>{cd}{lang_message}</strong>
+		<strong>{message}</strong>
 	</div>
 </div>
@@ -54,5 +52,5 @@
 <div class="bg-neutro">
 	<div class="aviso-negativo">
-		<strong>{cd}{lang_message}</strong>
+		<strong>{message}</strong>
 	</div>
 </div>
Index: /branches/2.2/mobile/templates/default/add_participants.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/add_participants.tpl	(revision 1499)
+++ /branches/2.2/mobile/templates/default/add_participants.tpl	(revision 3571)
@@ -71,5 +71,5 @@
 		<input type="hidden" id="input_subject" name="input_subject" value="" style="display: none;"/>
 		<input type="hidden" id="body" name="body" value="" style="display: none;"/>
-		<input type="hidden" id="cc_mob" name="cc_mob" value="1" style="display: none;"/>
+		<input type="hidden" id="type" name="type" value="cc_mob" style="display: none;"/>
 </form>	
 <!-- END row -->
Index: /branches/2.2/mobile/templates/default/template.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/template.tpl	(revision 3564)
+++ /branches/2.2/mobile/templates/default/template.tpl	(revision 3571)
@@ -15,4 +15,5 @@
 		</div>
 
+		{message_box}		
 		<!-- BEGIN mobile_home_content -->
 		{content}<br>{footer}
@@ -29,2 +30,16 @@
 		
 <!-- END mobile_home -->
+<!-- BEGIN success_message -->
+<div class="bg-neutro">
+	<div class="aviso-positivo">
+		<strong>{message}</strong>
+	</div>
+</div>
+<!-- END success_message -->
+<!-- BEGIN error_message -->
+<div class="bg-neutro">
+	<div class="aviso-negativo">
+		<strong>{message}</strong>
+	</div>
+</div>
+<!-- END error_message -->
Index: /branches/2.2/mobile/templates/default/add_recipients.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/add_recipients.tpl	(revision 1474)
+++ /branches/2.2/mobile/templates/default/add_recipients.tpl	(revision 3571)
@@ -62,9 +62,10 @@
 
 	</tr>
-		<input type="hidden" id="input_to" name="input_to" value="{row_nome}" style="display: none;"/>
-		<input type="hidden" id="input_to_mail" name="input_to_mail" value="{row_email}" style="display: none;"/>
-		<input type="hidden" id="input_subject" name="input_subject" value="" style="display: none;"/>
-		<input type="hidden" id="body" name="body" value="" style="display: none;"/>
-		<input type="hidden" id="cc_mob" name="cc_mob" value="1" style="display: none;"/>
+	
+	<input type="hidden" id="input_to" name="input_to" value="{row_nome}" style="display: none;"/>
+	<input type="hidden" id="input_to_mail" name="input_to_mail" value="{row_email}" style="display: none;"/>
+	<input type="hidden" id="input_subject" name="input_subject" value="" style="display: none;"/>
+	<input type="hidden" id="body" name="body" value="" style="display: none;"/>
+	<input type="hidden" id="type" name="type" value="cc_mob" style="display: none;"/>
 </form>	
 <!-- END row -->
Index: /branches/2.2/mobile/templates/default/home_index.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/home_index.tpl	(revision 3564)
+++ /branches/2.2/mobile/templates/default/home_index.tpl	(revision 3571)
@@ -1,20 +1,26 @@
 <!-- BEGIN page -->
-<div class="busca"> <input name="palavra_chave"> <button id="buscar" class="btn-generico" >{lang_search}</button></div>
-
-<div class="menu-contexto">
-	{lang_new_mail}:
-	<button name="email" class="btn-contexto">{lang_context_email}</button>
-	<button name="contato" class="btn-contexto">{lang_context_contact}</button>
-	<button name="compromisso" class="btn-contexto">{lang_context_commitment}</button>
-</div>
-
-<dl id="lista_miolo">
-	<dt><input type="checkbox" name="check_default_folders"></input>{lang_my_mail} | <span class="rotulo-complementar">Usados {quota_percent}% [{quota_used}/{quota_limit}]</span></dt>
-		{default_folders_box}
-	<dt><input type="checkbox" name="check_commitments">{lang_my_commitments}</dt>
-		{commitments_box}
-	<dt><input type="checkbox" name="check_personal_folders"><a href="index.php?menuaction=mobile.ui_home.index&expand_folders={expand_folders}">{lang_my_folders}</a></dt>
-		{personal_folders_box}
-</dl>
+<form method="post" action="index.php?menuaction=mobile.ui_home.search">
+	<div class="busca"> 
+		<input type="text" name="name" id="name" />
+		<input type="submit" id="buscar" class="btn-generico" value="{lang_search}" />
+	</div>
+	
+	<div class="menu-contexto">
+		{lang_new_mail}:
+		<a href="index.php?menuaction=mobile.ui_mobilemail.new_msg&type=clk" style="text-decoration:none;"><button name="email" class="btn-contexto">{lang_context_email}</button></a>
+		<button name="contato" class="btn-contexto">{lang_context_contact}</button>
+		<button name="compromisso" class="btn-contexto">{lang_context_commitment}</button>
+	</div>
+	
+	<dl id="lista_miolo">
+		<dt><input type="checkbox" name="default_folders"></input>{lang_my_mail} | <span class="rotulo-complementar">Usados {quota_percent}% [{quota_used}/{quota_limit}]</span></dt>
+			{default_folders_box}
+    <dt><input type="checkbox" name="personal_folders"><a href="index.php?menuaction=mobile.ui_home.index&expand_folders={expand_folders}">{lang_my_folders}</a></dt>
+      {personal_folders_box}			
+		<dt><input type="checkbox" name="calendar_search">{lang_my_commitments}</dt>
+			{commitments_box}
+    <dt><input type="checkbox" name="contacts_search">{lang_my_contacts}</dt>			
+	</dl>
+</form>
 
 <!-- END page -->
Index: /branches/2.2/mobile/templates/css/mobile.css
===================================================================
--- /branches/2.2/mobile/templates/css/mobile.css	(revision 3553)
+++ /branches/2.2/mobile/templates/css/mobile.css	(revision 3571)
@@ -39,5 +39,5 @@
 
 .busca{ padding-left: 5px; padding-top:5px; height:25px;; background-color:#E4E4E4}
-.busca input{height:10px;}
+.busca input{height:20px;}
 .par{background-color:#EEF7FA}
 .topo{background-color:#3E3E3D;}
@@ -47,5 +47,6 @@
 .nome-item{ float:left; width:160px;}
 .menu-contexto{ padding-top:3px; padding-left:5px; height:20px; font-size:60%; background-color:#3399CC; color:#FFFFFF;}
-.btn-contexto{ font-size:90%; border:none; background-color:#2B84AF; color:#FFFFFF;}
+.btn-contexto{ font-size:90%; background-color:#2B84AF; color:#FFFFFF; border:none;}
+.btn-generico, .btn-contexto{ height:18px; }
 .titulo_mensagem{ font-size:75%; font-weight:bold;}
 .titulo-sdt{ padding:2px 0px 0px 5px; height:20px; font-weight:bold; font-size: 80%; color:#3E3E3D; background-color:#CEE5EF;}
@@ -68,9 +69,11 @@
 .label-normal{font-style:italic;}
 
-.campos-entrada{ height:110px; font-size:70%; background-color:#CEE5EF;}
-.campos-correspondencia{ height:65px; font-size:70%; background-color:#CEE5EF;}
-.campos-correspondencia input, .campos-entrada input{height:9px;}
+.campos-entrada{ height:75px; font-size:70%; background-color:#CEE5EF;}
+.campos-correspondencia{ height:75px; font-size:70%; background-color:#CEE5EF;}
+.campos-correspondencia input{height:20px;}
+.campos-entrada input{height:10px;}
 .posiciona-esquerda{padding:5px 0px 0px 10px; float:left;}
-.posiciona-esquerda p{height:20px;}
+.posiciona-esquerda p{height:22px;}
+.posiciona-esquerda p label{float:left;width:75px;}
 
 .login{ background-color:#EEF7FA;}
Index: /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3566)
+++ /branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3571)
@@ -2824,6 +2824,8 @@
 		$return["subject"] = $subject;
 
-		if (!$return['append'])
+		if (!$return['append']) {
 			$return['append'] = imap_last_error();
+			$return['has_error'] = true;
+		}
 
 		return $return;
