mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Added accounts and identities to debug info
This commit is contained in:
parent
6fbdac338a
commit
b7f1b10f36
1 changed files with 53 additions and 4 deletions
|
@ -63,6 +63,9 @@ import com.sun.mail.imap.IMAPStore;
|
|||
import com.sun.mail.util.FolderClosedIOException;
|
||||
import com.sun.mail.util.MailConnectException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
|
@ -424,10 +427,11 @@ public class Helper {
|
|||
db.message().setMessageContent(draft.id, true, HtmlHelper.getPreview(body), null);
|
||||
|
||||
attachSettings(context, draft.id, 1);
|
||||
attachNetworkInfo(context, draft.id, 2);
|
||||
attachLog(context, draft.id, 3);
|
||||
attachOperations(context, draft.id, 4);
|
||||
attachLogcat(context, draft.id, 5);
|
||||
attachAccounts(context, draft.id, 2);
|
||||
attachNetworkInfo(context, draft.id, 3);
|
||||
attachLog(context, draft.id, 4);
|
||||
attachOperations(context, draft.id, 5);
|
||||
attachLogcat(context, draft.id, 6);
|
||||
|
||||
EntityOperation.queue(context, db, draft, EntityOperation.ADD);
|
||||
|
||||
|
@ -528,6 +532,51 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
private static void attachAccounts(Context context, long id, int sequence) throws IOException {
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
EntityAttachment attachment = new EntityAttachment();
|
||||
attachment.message = id;
|
||||
attachment.sequence = sequence;
|
||||
attachment.name = "accounts.txt";
|
||||
attachment.type = "text/plain";
|
||||
attachment.size = null;
|
||||
attachment.progress = 0;
|
||||
attachment.id = db.attachment().insertAttachment(attachment);
|
||||
|
||||
File file = attachment.getFile(context);
|
||||
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
|
||||
long size = 0;
|
||||
|
||||
List<EntityAccount> accounts = db.account().getAccounts();
|
||||
for (EntityAccount account : accounts)
|
||||
try {
|
||||
JSONObject jaccount = account.toJSON();
|
||||
jaccount.remove("user");
|
||||
jaccount.remove("password");
|
||||
size += write(os, "==========\r\n");
|
||||
size += write(os, jaccount.toString(2) + "\r\n");
|
||||
|
||||
List<EntityIdentity> identities = db.identity().getIdentities(account.id);
|
||||
for (EntityIdentity identity : identities)
|
||||
try {
|
||||
JSONObject jidentity = identity.toJSON();
|
||||
jidentity.remove("user");
|
||||
jidentity.remove("password");
|
||||
size += write(os, "----------\r\n");
|
||||
size += write(os, jidentity.toString(2) + "\r\n");
|
||||
} catch (JSONException ex) {
|
||||
size += write(os, ex.toString() + "\r\n");
|
||||
}
|
||||
} catch (JSONException ex) {
|
||||
size += write(os, ex.toString() + "\r\n");
|
||||
}
|
||||
|
||||
db.attachment().setDownloaded(attachment.id, size);
|
||||
}
|
||||
}
|
||||
|
||||
private static void attachNetworkInfo(Context context, long id, int sequence) throws IOException {
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
|
|
Loading…
Reference in a new issue