Index: trunk/mobile/setup/phpgw_pt-br.lang
===================================================================
--- trunk/mobile/setup/phpgw_pt-br.lang	(revision 5037)
+++ trunk/mobile/setup/phpgw_pt-br.lang	(revision 5303)
@@ -138,4 +138,5 @@
 short Saturday	mobile	pt-br	Sáb
 short Sunday	mobile	pt-br	Dom
+Spam	mobile	pt-br	Spam
 You have been successfully logged out	mobile	pt-br	Você desconectou do expresso com sucesso.
 now	mobile	pt-br	Agora
Index: trunk/mobile/inc/class.ui_mobilemail.inc.php
===================================================================
--- trunk/mobile/inc/class.ui_mobilemail.inc.php	(revision 5243)
+++ trunk/mobile/inc/class.ui_mobilemail.inc.php	(revision 5303)
@@ -14,7 +14,5 @@
 
 	include_once(PHPGW_INCLUDE_ROOT.'/expressoMail1_2/inc/class.imap_functions.inc.php');
-	
-	$_SESSION['rootPath'] = PHPGW_INCLUDE_ROOT;
-	
+
 	// Classe principal do Mini Mail
 	class ui_mobilemail{
@@ -336,14 +334,12 @@
 
 			// echo '<script> var array_lang = new Array();var use_spam_filter = \''.$current_config['expressoMail_use_spam_filter'].'\' </script>';
-
 			// End Set Anti-Spam options.
 		
 		    // Set Imap Folder names options
-		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']		: "Trash";
-		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	: "Drafts";
-		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']		: "Spam";
-		    $_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");		    
+		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']		: lang("Trash");
+		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	: lang("Drafts");
+		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']		: lang("Spam");
+		    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 		: lang("Sent");
+		
 		}
 
@@ -901,5 +897,5 @@
 			//Cria objeto
 			$mail = new PHPMailer();
-
+			
 			$db_functions = CreateObject('expressoMail1_2.db_functions');
 			
@@ -908,10 +904,10 @@
 			$ccaddress = implode(',',$db_functions->getAddrs(explode(',',$ccaddress)));
 			
-			if(!$this->imap_functions->add_recipients("to", $toaddress, &$mail, true))
+			if(!$this->imap_functions->add_recipients("to", $toaddress, &$mail))
 			{
 				$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", $ccaddress, &$mail, true))
+			if(!$this->imap_functions->add_recipients("cc", $ccaddress, &$mail))
 			{
 				$error_msg = lang("Some addresses in the CC field were not recognized. Please make sure that all addresses are properly formed");
@@ -997,32 +993,44 @@
 		function delete_msg($params)
 		{
-
-			if ( !isset($params['msgs']) && !isset($params['msg_number']) ) {
+			$boemailadmin		= CreateObject('emailadmin.bo');
+			$emailadmin_profile = $boemailadmin->getProfileList();
+			$email_server		= $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
+			
+			if ( !isset($params['msgs']) && !isset($params['msg_number']) )
+			{
 				header("Location: index.php?menuaction=mobile.ui_mobilemail.index&error_message=".lang("please select one e-mail"));
-			} else {
-				$msg = "";
-
-				if($params["msg_folder"] == "INBOX/Trash") {
+			}
+			else
+			{
+				$imapDefaultTrashFolder = ( isset($email_server['imapDefaultTrashFolder']) && trim($email_server['imapDefaultTrashFolder']) !== "" ) ? $email_server['imapDefaultTrashFolder'] : lang("Trash");
+				
+				$folderTrash = "INBOX".$this->imap_functions->imap_delimiter.$imapDefaultTrashFolder;
+
+				if( strtoupper($params["msg_folder"]) === strtoupper($folderTrash) )
+				{ 	
 					$params_messages = array(
-						'msgs_number' => isset($params['msgs'])?implode(",",$params['msgs']):$params['msg_number'],
-						'folder' => 'INBOX/Trash'
+												'msgs_number' => isset($params['msgs'])?implode(",",$params['msgs']):$params['msg_number'],
+                                                'folder' => $folderTrash
+	                                        );
+
+					$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' 	=> $imapDefaultTrashFolder,
+						'new_folder' 		=> $folderTrash
 					);
+					
+					$this->imap_functions->move_messages($params_messages);
+					
+					$msg = lang("The messages were moved to trash");
+				}
 				
-					$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/index.php
===================================================================
--- trunk/mobile/index.php	(revision 5037)
+++ trunk/mobile/index.php	(revision 5303)
@@ -67,4 +67,12 @@
 	include_once('../header.inc.php');
 	include_once('./mobile_header.inc.php');
+
+	if(	array_key_exists('expressoMail1_2',$GLOBALS['phpgw_info']['user']['apps']) === FALSE ||
+		array_key_exists('contactcenter',$GLOBALS['phpgw_info']['user']['apps']) === FALSE ||
+		array_key_exists('calendar',$GLOBALS['phpgw_info']['user']['apps']) === FALSE) {
+			$GLOBALS['phpgw']->session->phpgw_setcookie('lem', null);
+			$GLOBALS['phpgw']->session->phpgw_setcookie('pem', null);			
+			Header('Location: ' . $GLOBALS['phpgw']->link('/mobile/login.php?cd=97'));
+	}
 	
 	if($mobileapp == 'home')
Index: trunk/mobile/login.php
===================================================================
--- trunk/mobile/login.php	(revision 5043)
+++ trunk/mobile/login.php	(revision 5303)
@@ -39,4 +39,7 @@
 			case 6:
 				$_return = lang('Your password has expired, and you do not have access to change it');
+				break;
+			case 97:
+				$_return = lang('Access not permitted');
 				break;
 			case 98:
