Browse Source

Removed poll support

main
M66B 6 years ago
parent
commit
8cbcc864e3
7 changed files with 56 additions and 63 deletions
  1. +3
    -0
      FAQ.md
  2. +1
    -1
      app/src/main/java/eu/faircode/email/EntityAccount.java
  3. +9
    -7
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  4. +31
    -37
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java
  5. +7
    -13
      app/src/main/res/layout/fragment_account.xml
  6. +1
    -1
      app/src/main/res/values/strings.xml
  7. +4
    -4
      app/src/main/res/xml/providers.xml

+ 3
- 0
FAQ.md View File

@ -45,6 +45,9 @@ Valid security certificates are officially signed (not self signed) and have mat
Without [IMAP IDLE](https://en.wikipedia.org/wiki/IMAP_IDLE) emails need to be periodically fetched,
which is a waste of battery power and internet bandwidth and will delay notification of new emails.
Since the goal of FairEmail is to offer safe and fast email, providers without IMAP IDLE are not supported.
You should consider this a problem of the provider, not of the app.
Almost all email providers offer IMAP IDLE, with as notable exception Yahoo!
<a name="FAQ6"></a>
**(6) How can I login to Gmail / G suite?**


+ 1
- 1
app/src/main/java/eu/faircode/email/EntityAccount.java View File

@ -51,7 +51,7 @@ public class EntityAccount {
@NonNull
public Boolean store_sent; // obsolete
@NonNull
public Integer poll_interval;
public Integer poll_interval; // NOOP interval
public Long seen_until;
public String state;
public String error;


+ 9
- 7
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -94,7 +94,6 @@ public class FragmentAccount extends FragmentEx {
private EditText etInterval;
private Button btnCheck;
private ProgressBar pbCheck;
private TextView tvIdle;
private Spinner spDrafts;
private Spinner spSent;
private Spinner spAll;
@ -105,6 +104,7 @@ public class FragmentAccount extends FragmentEx {
private ImageButton ibDelete;
private ProgressBar pbWait;
private Group grpInstructions;
private Group grpInterval;
private Group grpFolders;
private long id = -1;
@ -140,7 +140,6 @@ public class FragmentAccount extends FragmentEx {
etInterval = view.findViewById(R.id.etInterval);
btnCheck = view.findViewById(R.id.btnCheck);
pbCheck = view.findViewById(R.id.pbCheck);
tvIdle = view.findViewById(R.id.tvIdle);
spDrafts = view.findViewById(R.id.spDrafts);
spSent = view.findViewById(R.id.spSent);
spAll = view.findViewById(R.id.spAll);
@ -151,6 +150,7 @@ public class FragmentAccount extends FragmentEx {
ibDelete = view.findViewById(R.id.ibDelete);
pbWait = view.findViewById(R.id.pbWait);
grpInstructions = view.findViewById(R.id.grpInstructions);
grpInterval = view.findViewById(R.id.grpInterval);
grpFolders = view.findViewById(R.id.grpFolders);
// Wire controls
@ -282,11 +282,12 @@ public class FragmentAccount extends FragmentEx {
istore = (IMAPStore) isession.getStore("imaps");
istore.connect(host, Integer.parseInt(port), user, password);
if (!istore.hasCapability("IDLE"))
throw new MessagingException(getContext().getString(R.string.title_no_idle));
if (!istore.hasCapability("UIDPLUS"))
throw new MessagingException(getContext().getString(R.string.title_no_uidplus));
args.putBoolean("idle", istore.hasCapability("IDLE"));
for (Folder ifolder : istore.getDefaultFolder().list("*")) {
String type = null;
@ -352,8 +353,6 @@ public class FragmentAccount extends FragmentEx {
// Refreshed token
tilPassword.getEditText().setText(args.getString("password"));
tvIdle.setVisibility(args.getBoolean("idle") ? View.GONE : View.VISIBLE);
final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
@ -672,11 +671,12 @@ public class FragmentAccount extends FragmentEx {
tilPassword.setPasswordVisibilityToggleEnabled(id < 0);
tvLink.setMovementMethod(LinkMovementMethod.getInstance());
btnAuthorize.setEnabled(false);
grpInstructions.setVisibility(View.GONE);
grpInterval.setVisibility(View.GONE);
btnCheck.setEnabled(false);
pbCheck.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE);
pbSave.setVisibility(View.GONE);
tvIdle.setVisibility(View.GONE);
grpFolders.setVisibility(View.GONE);
ibDelete.setVisibility(View.GONE);
@ -755,6 +755,8 @@ public class FragmentAccount extends FragmentEx {
cbPrimary.setEnabled(cbSynchronize.isChecked());
grpInterval.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
btnCheck.setVisibility(cbSynchronize.isChecked() ? View.VISIBLE : View.GONE);
btnSave.setVisibility(cbSynchronize.isChecked() ? View.GONE : View.VISIBLE);


+ 31
- 37
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -459,7 +459,6 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderState(folder.id, null);
db.account().setAccountState(account.id, "connecting");
istore.connect(account.host, account.port, account.user, account.password);
boolean hasIdle = istore.hasCapability("IDLE");
backoff = CONNECT_BACKOFF_START;
db.account().setAccountState(account.id, "connected");
@ -583,18 +582,15 @@ public class ServiceSynchronize extends LifecycleService {
try {
Thread.sleep(account.poll_interval * 60 * 1000L);
if (istore.hasCapability("IDLE")) {
Log.i(Helper.TAG, folder.name + " request NOOP");
ifolder.doCommand(new IMAPFolder.ProtocolCommand() {
public Object doCommand(IMAPProtocol p) throws ProtocolException {
Log.i(Helper.TAG, ifolder.getName() + " start NOOP");
p.simpleCommand("NOOP", null);
Log.i(Helper.TAG, ifolder.getName() + " end NOOP");
return null;
}
});
} else
synchronizeMessages(account, folder, ifolder, state);
Log.i(Helper.TAG, folder.name + " request NOOP");
ifolder.doCommand(new IMAPFolder.ProtocolCommand() {
public Object doCommand(IMAPProtocol p) throws ProtocolException {
Log.i(Helper.TAG, ifolder.getName() + " start NOOP");
p.simpleCommand("NOOP", null);
Log.i(Helper.TAG, ifolder.getName() + " end NOOP");
return null;
}
});
} catch (InterruptedException ex) {
Log.w(Helper.TAG, folder.name + " noop " + ex.toString());
@ -618,34 +614,32 @@ public class ServiceSynchronize extends LifecycleService {
noops.add(noop);
// Receive folder events
if (hasIdle) {
Thread idle = new Thread(new Runnable() {
@Override
public void run() {
try {
Log.i(Helper.TAG, folder.name + " start idle");
while (state.running && ifolder.isOpen()) {
Log.i(Helper.TAG, folder.name + " do idle");
ifolder.idle(false);
Log.i(Helper.TAG, folder.name + " done idle");
}
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(account.name, folder.name, ex);
Thread idle = new Thread(new Runnable() {
@Override
public void run() {
try {
Log.i(Helper.TAG, folder.name + " start idle");
while (state.running && ifolder.isOpen()) {
Log.i(Helper.TAG, folder.name + " do idle");
ifolder.idle(false);
Log.i(Helper.TAG, folder.name + " done idle");
}
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(account.name, folder.name, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
synchronized (state) {
state.notifyAll();
}
} finally {
Log.i(Helper.TAG, folder.name + " end idle");
synchronized (state) {
state.notifyAll();
}
} finally {
Log.i(Helper.TAG, folder.name + " end idle");
}
}, "sync.idle." + folder.id);
idle.start();
idlers.add(idle);
}
}
}, "sync.idle." + folder.id);
idle.start();
idlers.add(idle);
}
BroadcastReceiver processFolder = new BroadcastReceiver() {


+ 7
- 13
app/src/main/res/layout/fragment_account.xml View File

@ -258,18 +258,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/etInterval" />
<TextView
android:id="@+id/tvIdle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:minWidth="100dp"
android:text="@string/title_no_idle"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnCheck" />
<TextView
android:id="@+id/tvDrafts"
android:layout_width="wrap_content"
@ -288,7 +276,7 @@
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tvDrafts"
app:layout_constraintTop_toBottomOf="@id/tvIdle" />
app:layout_constraintTop_toBottomOf="@id/btnCheck" />
<TextView
android:id="@+id/tvSent"
@ -403,6 +391,12 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpInterval"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvInterval,etInterval" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpInstructions"
android:layout_width="0dp"


+ 1
- 1
app/src/main/res/values/strings.xml View File

@ -92,7 +92,7 @@
<string name="title_authorize">Select account</string>
<string name="title_instructions">Instructions</string>
<string name="title_store_sent">Store sent messages (enable if needed only)</string>
<string name="title_interval">Poll/keep-alive interval (minutes)</string>
<string name="title_interval">Keep-alive interval (minutes)</string>
<string name="title_synchronize_account">Synchronize (receive messages)</string>
<string name="title_synchronize_identity">Synchronize (send messages)</string>
<string name="title_primary_account">Primary (default account)</string>


+ 4
- 4
app/src/main/res/xml/providers.xml View File

@ -36,7 +36,7 @@
starttls="false" />
</provider>
<!-- no IMAP IDLE -->
<provider
<!--provider
name="Yahoo!"
link="https://help.yahoo.com/kb/SLN4075.html">
<imap
@ -46,7 +46,7 @@
host="smtp.mail.yahoo.com"
port="465"
starttls="false" />
</provider>
</provider-->
<provider
name="Posteo.de"
link="https://posteo.de/en/help/how-do-i-set-up-posteo-in-an-email-client-pop3-imap-and-smtp">
@ -81,7 +81,7 @@
starttls="false" />
</provider>
<!-- no IMAP IDLE -->
<provider
<!--provider
name="SFR.fr"
link="https://assistance.sfr.fr/service-et-accessoire/sfr-mail/serveurs-messagerie-sfr.html">
<imap
@ -91,7 +91,7 @@
host="smtp.sfr.fr"
port="465"
starttls="false" />
</provider>
</provider-->
<provider
name="infomaniak"
link="https://www.infomaniak.com/fr/support/faq/1075/configurer-une-adresse-email-configuration-logiciel-de-messagerie-parametres-courrier">


Loading…
Cancel
Save