Added raw fetch option

pull/212/head
M66B 3 years ago
parent 559baf7baf
commit 0a13ce40f0

File diff suppressed because it is too large Load Diff

@ -581,6 +581,7 @@ public class ActivityEML extends ActivityBase {
try (EmailService iservice = new EmailService(
context, account.getProtocol(), account.realm, account.encryption, account.insecure, account.unicode, true)) {
iservice.setPartialFetch(account.partial_fetch);
iservice.setRawFetch(account.raw_fetch);
iservice.setIgnoreBodyStructureSize(account.ignore_size);
iservice.connect(account);

@ -420,6 +420,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
context, account.getProtocol(), account.realm, account.encryption, account.insecure, account.unicode,
EmailService.PURPOSE_SEARCH, debug || BuildConfig.DEBUG);
state.iservice.setPartialFetch(account.partial_fetch);
state.iservice.setRawFetch(account.raw_fetch);
state.iservice.setIgnoreBodyStructureSize(account.ignore_size);
state.iservice.connect(account);

@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 263,
version = 264,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2703,6 +2703,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `identity` ADD COLUMN `last_modified` INTEGER");
createTriggers(db);
}
}).addMigrations(new Migration(263, 264) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `raw_fetch` INTEGER NOT NULL DEFAULT 0");
createTriggers(db);
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -89,6 +89,7 @@ public class EmailProvider implements Parcelable {
public int keepalive;
public boolean noop;
public boolean partial;
public boolean raw;
public boolean useip;
public boolean appPassword;
public String maxtls;
@ -247,6 +248,7 @@ public class EmailProvider implements Parcelable {
provider.keepalive = getAttributeIntValue(xml, "keepalive", 0);
provider.noop = getAttributeBooleanValue(xml, "noop", false);
provider.partial = getAttributeBooleanValue(xml, "partial", true);
provider.raw = getAttributeBooleanValue(xml, "raw", false);
provider.useip = getAttributeBooleanValue(xml, "useip", true);
provider.appPassword = getAttributeBooleanValue(xml, "appPassword", false);
provider.maxtls = xml.getAttributeValue(null, "maxtls");

@ -306,6 +306,10 @@ public class EmailService implements AutoCloseable {
properties.put("mail." + protocol + ".partialfetch", Boolean.toString(enabled));
}
void setRawFetch(boolean enabled) {
properties.put("fairemail.rawfetch", Boolean.toString(enabled));
}
void setIgnoreBodyStructureSize(boolean enabled) {
properties.put("mail." + protocol + ".ignorebodystructuresize", Boolean.toString(enabled));
}

@ -141,6 +141,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
@NonNull
public Boolean partial_fetch = true;
@NonNull
public Boolean raw_fetch = false;
@NonNull
public Boolean ignore_size = false;
@NonNull
public Boolean use_date = false; // Date header
@ -317,6 +319,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
json.put("poll_interval", poll_interval);
json.put("keep_alive_noop", keep_alive_noop);
json.put("partial_fetch", partial_fetch);
json.put("raw_fetch", raw_fetch);
json.put("ignore_size", ignore_size);
json.put("use_date", use_date);
json.put("use_received", use_received);
@ -410,6 +413,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
account.keep_alive_noop = json.optBoolean("keep_alive_noop");
account.partial_fetch = json.optBoolean("partial_fetch", true);
account.raw_fetch = json.optBoolean("raw_fetch", false);
account.ignore_size = json.optBoolean("ignore_size", false);
account.use_date = json.optBoolean("use_date", false);
account.use_received = json.optBoolean("use_received", false);
@ -470,6 +474,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
(!state || Objects.equals(a1.keep_alive_failed, other.keep_alive_failed)) &&
(!state || Objects.equals(a1.keep_alive_succeeded, other.keep_alive_succeeded)) &&
a1.partial_fetch == other.partial_fetch &&
a1.raw_fetch == other.raw_fetch &&
a1.ignore_size == other.ignore_size &&
a1.use_date == other.use_date &&
a1.use_received == other.use_received &&

@ -130,6 +130,7 @@ public class FragmentAccount extends FragmentBase {
private EditText etInterval;
private CheckBox cbNoop;
private CheckBox cbPartialFetch;
private CheckBox cbRawFetch;
private CheckBox cbIgnoreSize;
private RadioGroup rgDate;
private CheckBox cbUnicode;
@ -249,6 +250,7 @@ public class FragmentAccount extends FragmentBase {
etInterval = view.findViewById(R.id.etInterval);
cbNoop = view.findViewById(R.id.cbNoop);
cbPartialFetch = view.findViewById(R.id.cbPartialFetch);
cbRawFetch = view.findViewById(R.id.cbRawFetch);
cbIgnoreSize = view.findViewById(R.id.cbIgnoreSize);
rgDate = view.findViewById(R.id.rgDate);
cbUnicode = view.findViewById(R.id.cbUnicode);
@ -332,6 +334,7 @@ public class FragmentAccount extends FragmentBase {
etInterval.setText(provider.keepalive > 0 ? Integer.toString(provider.keepalive) : null);
cbNoop.setChecked(provider.noop);
cbPartialFetch.setChecked(provider.partial);
cbRawFetch.setChecked(provider.raw);
tvSentWarning.setVisibility(View.GONE);
grpFolders.setVisibility(View.GONE);
@ -937,6 +940,7 @@ public class FragmentAccount extends FragmentBase {
args.putString("interval", etInterval.getText().toString());
args.putBoolean("noop", cbNoop.isChecked());
args.putBoolean("partial_fetch", cbPartialFetch.isChecked());
args.putBoolean("raw_fetch", cbRawFetch.isChecked());
args.putBoolean("ignore_size", cbIgnoreSize.isChecked());
args.putBoolean("use_date", rgDate.getCheckedRadioButtonId() == R.id.radio_date_header);
args.putBoolean("use_received", rgDate.getCheckedRadioButtonId() == R.id.radio_received_header);
@ -1012,6 +1016,7 @@ public class FragmentAccount extends FragmentBase {
String interval = args.getString("interval");
boolean noop = args.getBoolean("noop");
boolean partial_fetch = args.getBoolean("partial_fetch");
boolean raw_fetch = args.getBoolean("raw_fetch");
boolean ignore_size = args.getBoolean("ignore_size");
boolean use_date = args.getBoolean("use_date");
boolean use_received = args.getBoolean("use_received");
@ -1122,6 +1127,8 @@ public class FragmentAccount extends FragmentBase {
return true;
if (!Objects.equals(account.partial_fetch, partial_fetch))
return true;
if (!Objects.equals(account.raw_fetch, raw_fetch))
return true;
if (!Objects.equals(account.ignore_size, ignore_size))
return true;
if (!Objects.equals(account.use_date, use_date))
@ -1272,6 +1279,7 @@ public class FragmentAccount extends FragmentBase {
account.poll_interval = Math.max(1, poll_interval);
account.keep_alive_noop = noop;
account.partial_fetch = partial_fetch;
account.raw_fetch = raw_fetch;
account.ignore_size = ignore_size;
account.use_date = use_date;
account.use_received = use_received;
@ -1648,6 +1656,7 @@ public class FragmentAccount extends FragmentBase {
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
cbNoop.setChecked(account == null ? true : account.keep_alive_noop);
cbPartialFetch.setChecked(account == null ? true : account.partial_fetch);
cbRawFetch.setChecked(account == null ? false : account.raw_fetch);
cbIgnoreSize.setChecked(account == null ? false : account.ignore_size);
cbUnicode.setChecked(account == null ? false : account.unicode);
cbUnmetered.setChecked(jcondition.optBoolean("unmetered"));

@ -889,6 +889,7 @@ public class FragmentOAuth extends FragmentBase {
account.keep_alive_noop = provider.noop;
account.partial_fetch = provider.partial;
account.raw_fetch = provider.raw;
if (pop)
account.max_messages = EntityAccount.DEFAULT_MAX_MESSAGES;

@ -551,6 +551,7 @@ public class FragmentQuickSetup extends FragmentBase {
account.keep_alive_noop = provider.noop;
account.partial_fetch = provider.partial;
account.raw_fetch = provider.raw;
account.created = new Date().getTime();
account.last_connected = account.created;

@ -4693,6 +4693,9 @@ public class MessageHelper {
try {
if (imessage instanceof IMAPMessage) {
if (Boolean.parseBoolean(imessage.getSession().getProperty("fairemail.rawfetch")))
throw new MessagingException("Unable to load BODYSTRUCTURE");
if (structure)
imessage.getContentType(); // force loadBODYSTRUCTURE
else {

@ -1562,6 +1562,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
final EmailService iservice = new EmailService(
this, account.getProtocol(), account.realm, account.encryption, account.insecure, account.unicode, debug);
iservice.setPartialFetch(account.partial_fetch);
iservice.setRawFetch(account.raw_fetch);
iservice.setIgnoreBodyStructureSize(account.ignore_size);
if (account.protocol != EntityAccount.TYPE_IMAP)
iservice.setLeaveOnServer(account.leave_on_server);

@ -49,6 +49,7 @@ public class TupleAccountState extends EntityAccount {
this.poll_interval.equals(other.poll_interval) &&
this.poll_exempted.equals(other.poll_exempted) &&
this.partial_fetch.equals(other.partial_fetch) &&
this.raw_fetch.equals(other.raw_fetch) &&
this.ignore_size.equals(other.ignore_size) &&
this.use_date.equals(other.use_date) &&
this.use_received.equals(other.use_received) &&

@ -681,6 +681,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPartialFetch" />
<CheckBox
android:id="@+id/cbRawFetch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_raw_fetch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPartialFetchRemark" />
<CheckBox
android:id="@+id/cbIgnoreSize"
android:layout_width="wrap_content"
@ -688,7 +697,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_ignore_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPartialFetchRemark" />
app:layout_constraintTop_toBottomOf="@id/cbRawFetch" />
<RadioGroup
android:id="@+id/rgDate"
@ -1161,7 +1170,7 @@
cbBrowse,tvBrowseHint,
cbAutoSeen,
tvInterval,etInterval,tvIntervalRemark,cbNoop,tvNoopRemark,
cbPartialFetch,tvPartialFetchRemark,cbIgnoreSize,rgDate,tvDateRemark,
cbPartialFetch,tvPartialFetchRemark,cbRawFetch,cbIgnoreSize,rgDate,tvDateRemark,
cbUnicode,cbUnmeteredOnly,cbVpnOnly" />
<androidx.constraintlayout.widget.Group

@ -1081,6 +1081,7 @@
<string name="title_keep_alive_interval">Keep-alive interval (minutes)</string>
<string name="title_keep_alive_noop">Restart IMAP IDLE periodically</string>
<string name="title_partial_fetch" translatable="false">Partial fetch</string>
<string name="title_raw_fetch" translatable="false">Raw fetch</string>
<string name="title_ignore_size" translatable="false">Ignore bodystructure size</string>
<string name="title_server_time">Use received time (server)</string>
<string name="title_received_header">Use \'Received\' header</string>

Loading…
Cancel
Save