Index: sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/messages_controller.js
===================================================================
--- sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/messages_controller.js	(revision 4201)
+++ sandbox/expressoMail1_2/MailArchiver/2.2/expressoMail1_2/js/messages_controller.js	(revision 4666)
@@ -7,12 +7,24 @@
 	}
 /**
- * Retorna os cabeçalhos das mensagens a serem desenhadas na caixa de email.
+ * Retorna os cabeï¿œalhos das mensagens a serem desenhadas na caixa de email.
  */
-	messages_proxy.prototype.messages_list = function(folder,msg_range_begin,emails_per_page,sort_box_type,search_box_type,sort_box_reverse,preview_msg_subject,preview_msg_tip,call_back) {
+	messages_proxy.prototype.messages_list = function(folder,msg_range_begin,emails_per_page,sort_box_type,search_box_type,sort_box_reverse,preview_msg_subject,preview_msg_tip,call_back,tree_name) {
 		if(this.is_local_folder(folder)) {
-			var real_folder = folder.substr(6);		
-			var msgs = expresso_local_messages.get_local_range_msgs(real_folder,msg_range_begin,preferences.max_email_per_page,sort_box_type,sort_box_reverse,search_box_type,preferences.preview_msg_subject,preferences.preview_msg_tip);
-			eval('call_back(msgs)');
-			draw_tree_local_folders();
+                        //MAILARCHIVER
+			var baseFolder = folder.substr(6);
+			//var msgs = expresso_local_messages.get_local_range_msgs(real_folder,msg_range_begin,preferences.max_email_per_page,sort_box_type,sort_box_reverse,search_box_type,preferences.preview_msg_subject,preferences.preview_msg_tip);
+			//eval('call_back(msgs)');
+			//draw_tree_local_folders();
+                        //expresso_mail_archive.drawFolderTree(baseFolder);
+                        
+                        //expresso_mail_archive.getFoldersList('FAKEFULL-UPDATE-TREE',baseFolder);
+                        //window.alert('OLD tree name = ' + expresso_mail_archive.drawdata.treeName);
+                        //window.alert('baseFolder em messages_list = ' + baseFolder);
+                        var drawinginfo = {treeObject: tree_name, treeName: tree_name, folderName: baseFolder};
+                        expresso_mail_archive.drawdata = drawinginfo;
+                        //expresso_mail_archive.getFoldersList(baseFolder);
+                        //tree_folders.getNodeById(expresso_mail_archive.currentfolder).open();
+                        //window.alert('tree_name := ' + tree_name + '\nbaseFolder := ' + baseFolder);
+                        //eval(tree_name.getNodeById('local_' + baseFolder).open());
 		}else {
 			cExecute ("$this.imap_functions.get_range_msgs2&folder="+folder+"&msg_range_begin="+msg_range_begin+"&msg_range_end="+emails_per_page+"&sort_box_type="+sort_box_type+ "&search_box_type="+ search_box_type +"&sort_box_reverse="+sort_box_reverse+"", call_back);
@@ -118,8 +130,10 @@
 				return false;
 			}
-			var temp = expresso_local_messages.rename_folder(folder, ttree.FOLDER.substr(6));
-			if (!temp) 
-				alert(get_lang("cannot rename folder. try other folder name"));
-			ttreeBox.update_folder();
+                        expresso_mail_archive.drawdata.treeName = ttreeBox;
+                        expresso_mail_archive.renameFolder(ttree.FOLDER.substr(6), folder);
+			//var temp = expresso_local_messages.rename_folder(folder, ttree.FOLDER.substr(6));
+			//if (!temp) 
+                        //alert(get_lang("cannot rename folder. try other folder name"));
+			//ttreeBox.update_folder();
 		}
 		else {
@@ -135,5 +149,5 @@
 		}
 		if (this.is_local_folder(ttree.FOLDER)) {
-			folder = prompt(get_lang('Enter the name of the new folder:'), "");
+                        folder = prompt(get_lang('Enter the name of the new folder:'), "");
 
                         if(folder == null)
@@ -148,12 +162,18 @@
 			    alert(get_lang("cannot create folder. try other folder name"));
 			    return false;
-			}
-			if(ttree.FOLDER=="local_root")
-				var temp = expresso_local_messages.create_folder(folder);
-			else
-				var temp = expresso_local_messages.create_folder(ttree.FOLDER.substr(6)+"/"+folder);
-			if (!temp) 
-				alert(get_lang("cannot create folder. try other folder name"));
-			ttreeBox.update_folder(true);
+			}                      
+
+                        expresso_mail_archive.drawdata.folderName = ttreeBox;
+                        
+			if(ttree.FOLDER=="local_root"){
+				//var temp = expresso_local_messages.create_folder(folder);
+                               
+                               expresso_mail_archive.createFolder(ttree.FOLDER.substr(6), folder);
+                        }
+			else{
+                                //var temp = expresso_local_messages.create_folder(ttree.FOLDER.substr(6)+"/"+folder);
+                               expresso_mail_archive.createFolder(ttree.FOLDER.substr(6), folder);			
+                        }
+			
 		}
 		else			
@@ -172,5 +192,5 @@
 				return false;
 			}
-			if (ttree.FOLDER == 'local_Inbox' || (preferences.auto_create_local == '1' && (ttree.FOLDER == 'local_Sent' || ttree.FOLDER == 'local_Drafts' || ttree.FOLDER == 'local_Trash'))) {
+			/*if (ttree.FOLDER == 'local_Inbox' || (preferences.auto_create_local == '1' && (ttree.FOLDER == 'local_Sent' || ttree.FOLDER == 'local_Drafts' || ttree.FOLDER == 'local_Trash'))) {
 				alert(get_lang("It's not possible delete the folder: ")  + lang_folder(ttree.FOLDER.substr(6)) + '.');
 				return false;
@@ -182,9 +202,12 @@
 			else {
 				new_caption = ttree.FOLDER.substr(6);
-			}
+			}*/
+                        
+                        //new_caption = ttree.FOLDER.substr(6);                        
+                        var new_caption = document.getElementById('llocal_' + ttree.FOLDER.substr(6) + 'folders_tree').firstChild.nodeValue;
 			var string_confirm = get_lang("Do you wish to exclude the folder ") + new_caption + "?";
 
 			if (confirm(string_confirm)) {
-				var flag = expresso_local_messages.remove_folder(ttree.FOLDER.substr(6));
+				/*var flag = expresso_local_messages.remove_folder(ttree.FOLDER.substr(6));
 				if (flag) {
 					write_msg(get_lang("The folder %1 was successfully removed", new_caption));
@@ -194,5 +217,8 @@
 				else 
 					alert(get_lang("Delete your sub-folders first"));
-				
+                                */
+                               expresso_mail_archive.drawdata.folderName = new_caption;
+                               expresso_mail_archive.deleteFolder(ttree.FOLDER.substr(6));
+
 			}
 		}
@@ -204,5 +230,5 @@
 		if (! folder || folder == 'null')
 			folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder());
-		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas não locais...
+		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas nï¿œo locais...
 			if (folder == new_folder){
 				write_msg(get_lang('The origin folder and the destination folder are the same.'));
@@ -233,5 +259,5 @@
 			}
 			else {
-                //Por Bruno Costa (bruno.vieira-costa@serpro.gov.br) permite o desarquivamento de menssagens chamando a função unarchive_msgs quando uma msg é movida de uma pasta local para uma pasta remota.
+                //Por Bruno Costa (bruno.vieira-costa@serpro.gov.br) permite o desarquivamento de menssagens chamando a funï¿œï¿œo unarchive_msgs quando uma msg ï¿œ movida de uma pasta local para uma pasta remota.
 
 				expresso_local_messages.unarchive_msgs(folder,new_folder,msgs_number);
@@ -248,5 +274,5 @@
 		
 		
-		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas não locais...
+		if ((this.is_local_folder(folder)) && (this.is_local_folder(new_folder))) { //Move entre pastas nï¿œo locais...
 			if (folder == new_folder){
 				write_msg(get_lang('The origin folder and the destination folder are the same.'));
@@ -330,5 +356,5 @@
 
 
-		if(ttree.FOLDER == "local_root"){return false;}   //Usuario não selecionou uma pasta local e esta no comeÃ§o dos nÃ³s
+		if(ttree.FOLDER == "local_root"){return false;}   //Usuario nï¿œo selecionou uma pasta local e esta no comeÃ§o dos nÃ³s
 		var nm_bx = ttree.FOLDER.split(cyrus_delimiter);
 
