I am back trying to fix my problem with LocalFolders extension after my
sidetrip with ImportExportTools NG.
The extension simply allows users to create extra LocalFolders in
addition to the default.
Note the following problem occurs in 60 - 68 and maybe even prior.
In summary, creating the account following what "createLocalAccount" does
results in unusable subfolders and empty native directories. I am sure
my limited experience with messages and folders internals makes me believe
there is some configuration/flag I am missing. After much experimentation
I have a workable hack that certainly seems unnecessary.
Basically I have to remove the empty directories and create empty
mbox files matching the desired subfolder. After that they are usable.
I have reviewed the Thunderbird source code extensively in this area
and have not been able to identify what I am missing.
Thanks
Christopher
Step by step example:
New "Local Folder", Test3 :
- After createAccount & createIncomingServer (local folder account)
var accountmanager =
Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
var srv = accountmanager.createIncomingServer("nobody", nom,
"none");
var filespec =
Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
filespec.initWithPath(chemin);
srv.prettyName = nom;
srv.localPath = filespec;
eu.philoux.localfolder.LocalFolderTrace("before create account");
var account = accountmanager.createAccount();
account.incomingServer = srv;
- Note "Trash" & "Unsent Messages" directories
- Directories are empty
- No "Trash" & "Unsent Messages" mbox exist
- At this point one cannot copy or move messages into these
subfolders, fail silently
Directory of C:\Dev\Thunderbird\Extensions
XUL\localfolder-tb-master\xpi\Test3
07/21/2019 12:47 AM <DIR> .
07/21/2019 12:47 AM <DIR> ..
07/21/2019 12:47 AM 198 filterlog.html
07/21/2019 12:46 AM <DIR> Trash
07/21/2019 12:46 AM 1,123 Trash.msf
07/21/2019 12:46 AM <DIR> Unsent Messages
07/21/2019 12:46 AM 1,123 Unsent Messages.msf
After fixupSubfolder for Trash & Unsent Messages (my hack):
- Empty directories removed with nsIFile.remove
- Empty "Trash" & "Unsent Messages" files created with nsIFile.create
- Both subfolders can receive messages now
Directory of C:\Dev\Thunderbird\Extensions
XUL\localfolder-tb-master\xpi\Test3
07/21/2019 12:50 AM <DIR> .
07/21/2019 12:50 AM <DIR> ..
07/21/2019 12:47 AM 198 filterlog.html
07/21/2019 12:50 AM 0 Trash
07/21/2019 12:46 AM 1,123 Trash.msf
07/21/2019 12:50 AM 0 Unsent Messages
07/21/2019 12:46 AM 1,123 Unsent Messages.msf
- Creating new subfolders programmatically either with popup folder
command "New Folder"
succeeds, but creates empty folders and cannot receive messages
- The createSubfolder for "Drafts" changes the problem slightly
- Using the fixupSubfolder WITHOUT removing the empty folder fixes the
problem
- When just the nsIFile.create is used it removes the empty folder
...
srv.rootMsgFolder.createSubfolder("Drafts", msgWindow);
folderChild = srv.rootMsgFolder.getChildNamed("Drafts");
eu.philoux.localfolder.LocalFolderTrace("created subfolder: "+
folderChild.name );
folderChild.flags = (Ci.nsMsgFolderFlags.Mail |
Ci.nsMsgFolderFlags.Drafts);
eu.philoux.localfolder.LocalFolderTrace("set flags on
subfolder: " );
eu.philoux.localfolder.fixupSubfolder(chemin, "Drafts", false);
...
eu.philoux.localfolder.fixupSubfolder = function (parentName,
folderName, removeFileFolder) {
eu.philoux.localfolder.LocalFolderTrace(fixupSubfolder: ${folderName} - remove file folder: ${removeFileFolder}
);
var filespec =
Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
var rf = ${parentName}\\${folderName}
filespec.initWithPath(parentName);
filespec.append(folderName);
if (removeFileFolder) {
eu.philoux.localfolder.LocalFolderTrace(removing file folder: ${rf}
);
filespec.remove(true);
}
filespec.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
eu.philoux.localfolder.LocalFolderTrace(fixupSubfolder done
);
}
After Drafts edition/fixup:
Directory of C:\Dev\Thunderbird\Extensions
XUL\localfolder-tb-master\xpi\Test3
07/21/2019 01:02 AM <DIR> . var accountmanager =
Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
var srv = accountmanager.createIncomingServer("nobody", nom,
"none");
var filespec =
Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
filespec.initWithPath(chemin);
srv.prettyName = nom;
srv.localPath = filespec;
eu.philoux.localfolder.LocalFolderTrace("before create account");
var account = accountmanager.createAccount();
account.incomingServer = srv;
07/21/2019 01:02 AM <DIR> ..
07/21/2019 01:02 AM 0 Drafts
07/21/2019 01:02 AM 1,123 Drafts.msf
07/21/2019 01:02 AM 198 filterlog.html
07/21/2019 01:02 AM 0 Trash
07/21/2019 01:02 AM 1,123 Trash.msf
07/21/2019 01:02 AM 0 Unsent Messages
07/21/2019 01:02 AM 1,123 Unsent Messages.msf
Using "New Folder" command same problem - unusable "subfolder":
Directory of C:\Dev\Thunderbird\Extensions
XUL\localfolder-tb-master\xpi\Test3
07/21/2019 01:16 AM <DIR> .
07/21/2019 01:16 AM <DIR> ..
07/21/2019 01:02 AM 0 Drafts
07/21/2019 01:16 AM 1,609 Drafts.msf
07/21/2019 01:02 AM 198 filterlog.html
07/21/2019 01:16 AM <DIR> subfolder
07/21/2019 01:16 AM 1,123 subfolder.msf
07/21/2019 01:02 AM 0 Trash
07/21/2019 01:16 AM 1,544 Trash.msf
07/21/2019 01:02 AM 0 Unsent Messages
07/21/2019 01:16 AM 1,604 Unsent Messages.msf
Fix is basically the same , but had to add a folder listener to call
fixupSubfolder, no folder removal necessary: