Updated FAQ

pull/212/head
M66B 2 years ago
parent 632e045c7c
commit ae377e1e8f

@ -2789,6 +2789,8 @@ This means that messages with multiple labels will be shown multiple times as we
A lot of knowledge and experience is required to successfully develop an app for a specific platform, A lot of knowledge and experience is required to successfully develop an app for a specific platform,
which is why I develop apps for Android only. which is why I develop apps for Android only.
You can install FairEmail on recent Windows versions, though, see [here](#user-content-faq185), and also on ChromeOS via the Play Store.
<br /> <br />
<a name="faq76"></a> <a name="faq76"></a>

@ -66,17 +66,14 @@ public class CloudSync {
if (responses.size() == 1) if (responses.size() == 1)
return responses.get(0); return responses.get(0);
else { else {
int count = 0;
JSONArray jall = new JSONArray(); JSONArray jall = new JSONArray();
for (JSONObject response : responses) { for (JSONObject response : responses) {
JSONArray jitems = response.getJSONArray("items"); JSONArray jitems = response.getJSONArray("items");
for (int i = 0; i < jitems.length(); i++) for (int i = 0; i < jitems.length(); i++)
jall.put(jitems.getJSONObject(i)); jall.put(jitems.getJSONObject(i));
count += response.optInt("count", 0);
} }
JSONObject jresponse = responses.get(0); JSONObject jresponse = responses.get(0);
jresponse.put("items", jall); jresponse.put("items", jall);
jresponse.put("count", count);
return jresponse; return jresponse;
} }
} }
@ -114,7 +111,7 @@ public class CloudSync {
JSONArray jitems = jrequest.getJSONArray("items"); JSONArray jitems = jrequest.getJSONArray("items");
for (int i = 0; i < jitems.length(); i++) { for (int i = 0; i < jitems.length(); i++) {
JSONObject jitem = jitems.getJSONObject(i); JSONObject jitem = jitems.getJSONObject(i);
int revision = jitem.getInt("rev"); long revision = jitem.getLong("rev");
String k = jitem.getString("key"); String k = jitem.getString("key");
jitem.put("key", transform(k, key.second, null, true)); jitem.put("key", transform(k, key.second, null, true));
@ -181,7 +178,7 @@ public class CloudSync {
JSONArray jitems = jresponse.getJSONArray("items"); JSONArray jitems = jresponse.getJSONArray("items");
for (int i = 0; i < jitems.length(); i++) { for (int i = 0; i < jitems.length(); i++) {
JSONObject jitem = jitems.getJSONObject(i); JSONObject jitem = jitems.getJSONObject(i);
int revision = jitem.getInt("rev"); long revision = jitem.getLong("rev");
String ekey = jitem.getString("key"); String ekey = jitem.getString("key");
String k = transform(ekey, key.second, null, false); String k = transform(ekey, key.second, null, false);
@ -219,10 +216,10 @@ public class CloudSync {
Arrays.copyOfRange(encoded, half, half + half)); Arrays.copyOfRange(encoded, half, half + half));
} }
private static byte[] getAd(String key, int revision) throws NoSuchAlgorithmException { private static byte[] getAd(String key, long revision) throws NoSuchAlgorithmException {
byte[] k = MessageDigest.getInstance("SHA256").digest(key.getBytes()); byte[] k = MessageDigest.getInstance("SHA256").digest(key.getBytes());
byte[] ad = ByteBuffer.allocate(4 + 8) byte[] ad = ByteBuffer.allocate(8 + 8)
.putInt(revision) .putLong(revision)
.put(Arrays.copyOfRange(k, 0, 8)) .put(Arrays.copyOfRange(k, 0, 8))
.array(); .array();
return ad; return ad;

@ -1540,7 +1540,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
if ("sync".equals(command)) { if ("sync".equals(command)) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int sync_status = prefs.getInt("sync_status", 0); long sync_status = prefs.getLong("sync_status", new Date().getTime());
JSONObject jsyncstatus = new JSONObject(); JSONObject jsyncstatus = new JSONObject();
jsyncstatus.put("key", "sync.status"); jsyncstatus.put("key", "sync.status");
@ -1579,7 +1579,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
JSONObject jitem = new JSONObject(); JSONObject jitem = new JSONObject();
jitem.put("key", "identity." + identity.uuid); jitem.put("key", "identity." + identity.uuid);
jitem.put("val", identity.toJSON().toString()); jitem.put("val", identity.toJSON().toString());
jitem.put("rev", 1); jitem.put("rev", 1L);
jupload.put(jitem); jupload.put(jitem);
} }
@ -1590,7 +1590,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
JSONObject jitem = new JSONObject(); JSONObject jitem = new JSONObject();
jitem.put("key", "account." + account.uuid); jitem.put("key", "account." + account.uuid);
jitem.put("val", jaccountdata.toString()); jitem.put("val", jaccountdata.toString());
jitem.put("rev", 1); jitem.put("rev", 1L);
jupload.put(jitem); jupload.put(jitem);
} }
@ -1602,18 +1602,18 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
jsyncstatus.put("key", "sync.status"); jsyncstatus.put("key", "sync.status");
jsyncstatus.put("val", jstatus.toString()); jsyncstatus.put("val", jstatus.toString());
jsyncstatus.put("rev", 1); jsyncstatus.put("rev", 1L);
jupload.put(jsyncstatus); jupload.put(jsyncstatus);
jrequest.put("items", jupload); jrequest.put("items", jupload);
CloudSync.perform(context, user, password, "write", jrequest); CloudSync.perform(context, user, password, "write", jrequest);
prefs.edit().putInt("sync_status", 1).apply(); prefs.edit().putLong("sync_status", 1L).apply();
return null; return null;
} else if (jitems.length() == 1) { } else if (jitems.length() == 1) {
JSONObject jitem = jitems.getJSONObject(0); JSONObject jitem = jitems.getJSONObject(0);
int rev = jitem.getInt("rev"); long rev = jitem.getLong("rev");
Log.i("Cloud status revision=" + rev + "/" + sync_status); Log.i("Cloud status revision=" + rev + "/" + sync_status);
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG)
@ -1650,7 +1650,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
for (int i = 0; i < jitems.length(); i++) { for (int i = 0; i < jitems.length(); i++) {
JSONObject jaccount = jitems.getJSONObject(i); JSONObject jaccount = jitems.getJSONObject(i);
String value = jaccount.getString("val"); String value = jaccount.getString("val");
int revision = jaccount.getInt("rev"); long revision = jaccount.getLong("rev");
JSONObject jaccountdata = new JSONObject(value); JSONObject jaccountdata = new JSONObject(value);
EntityAccount raccount = EntityAccount.fromJSON(jaccountdata.getJSONObject("account")); EntityAccount raccount = EntityAccount.fromJSON(jaccountdata.getJSONObject("account"));
@ -1682,7 +1682,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
for (int i = 0; i < jitems.length(); i++) { for (int i = 0; i < jitems.length(); i++) {
JSONObject jaccount = jitems.getJSONObject(i); JSONObject jaccount = jitems.getJSONObject(i);
String value = jaccount.getString("val"); String value = jaccount.getString("val");
int revision = jaccount.getInt("rev"); long revision = jaccount.getLong("rev");
EntityIdentity ridentity = EntityIdentity.fromJSON(new JSONObject(value)); EntityIdentity ridentity = EntityIdentity.fromJSON(new JSONObject(value));
EntityIdentity lidentity = db.identity().getIdentityByUUID(ridentity.uuid); EntityIdentity lidentity = db.identity().getIdentityByUUID(ridentity.uuid);
Log.i("Cloud identity " + ridentity.uuid + "=" + (lidentity == null ? "insert" : "update") + Log.i("Cloud identity " + ridentity.uuid + "=" + (lidentity == null ? "insert" : "update") +
@ -1692,7 +1692,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
} }
} }
prefs.edit().putInt("sync_status", rev).apply(); prefs.edit().putLong("sync_status", rev).apply();
} else } else
throw new IllegalArgumentException("Expected one status item"); throw new IllegalArgumentException("Expected one status item");
} else } else

Loading…
Cancel
Save