Support multiple personal name spaces

pull/206/head
M66B 3 years ago
parent 54daa402e4
commit 7adce05e43

@ -2029,11 +2029,26 @@ class Core {
// Get remote folders
long start = new Date().getTime();
List<Folder> ifolders = new ArrayList<>();
ifolders.addAll(Arrays.asList(defaultFolder.list("*")));
List<String> subscription = new ArrayList<>();
Folder[] personal;
try {
Folder[] isubscribed = defaultFolder.listSubscribed("*");
personal = istore.getPersonalNamespaces();
if (personal.length == 0)
throw new MessagingException("Empty personal namespaces");
} catch (MessagingException ex) {
Log.e(ex);
personal = new Folder[]{istore.getDefaultFolder()};
}
for (Folder namespace : personal) {
EntityLog.log(context, "Personal namespace=" + namespace.getFullName());
if (namespace.getSeparator() == separator) {
String pattern = namespace.getFullName() + "*";
ifolders.addAll(Arrays.asList(defaultFolder.list(pattern)));
try {
Folder[] isubscribed = defaultFolder.listSubscribed(pattern);
for (Folder ifolder : isubscribed) {
String fullName = ifolder.getFullName();
if (TextUtils.isEmpty(fullName)) {
@ -2053,13 +2068,16 @@ class Core {
*/
Log.e(account.name, ex);
}
} else
Log.e("Personal namespace separator=" + namespace.getSeparator() + " default=" + separator);
}
if (sync_shared_folders) {
// https://tools.ietf.org/html/rfc2342
Folder[] namespaces = istore.getSharedNamespaces();
EntityLog.log(context, "Namespaces=" + namespaces.length);
for (Folder namespace : namespaces) {
EntityLog.log(context, "Namespace=" + namespace.getFullName());
Folder[] shared = istore.getSharedNamespaces();
EntityLog.log(context, "Shared namespaces=" + shared.length);
for (Folder namespace : shared) {
EntityLog.log(context, "Shared namespace=" + namespace.getFullName());
if (namespace.getSeparator() == separator) {
try {
ifolders.addAll(Arrays.asList(namespace.list("*")));
@ -2082,7 +2100,7 @@ class Core {
Log.e(account.name, ex);
}
} else
Log.e("Namespace separator=" + namespace.getSeparator() + " default=" + separator);
Log.e("Shared namespace separator=" + namespace.getSeparator() + " default=" + separator);
}
}

Loading…
Cancel
Save