GingerCal 1.3: month view, Galician interface, Nginx Proxy Manager bridge option
This commit is contained in:
1 parent
f44ecf4871
commit
42c3d6da91
39 files changed
+1409
-220
No files matched your search
+15
-22
@@ -109,41 +109,34 @@ public class Dav {
|
||||
continue;
|
||||
}
|
||||
if (r.code == 401) {
|
||||
throw new DavException(401, "Login refused (401). Check the user name and use a "
|
||||
+ "Nextcloud app password (Settings > Security > Devices & sessions).");
|
||||
throw new DavException(401, L.t("Login refused (401). Check the user name and use a Nextcloud app password (Settings > Security > Devices & sessions)."));
|
||||
}
|
||||
if (r.code == 403 && body != null && method.equals("PUT")) {
|
||||
throw new DavException(403, "Not allowed to write to this calendar (403). It may be read-only/shared.");
|
||||
throw new DavException(403, L.t("Not allowed to write to this calendar (403). It may be read-only/shared."));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
throw new DavException(DavException.REDIRECT, "Too many redirects from the server.");
|
||||
throw new DavException(DavException.REDIRECT, L.t("Too many redirects from the server."));
|
||||
}
|
||||
|
||||
static void checkRedirect(String from, String to, List<String> visited, int code) throws DavException {
|
||||
String a = originKey(from), b = originKey(to);
|
||||
if (a.startsWith("http:") && b.startsWith("https:")) {
|
||||
throw new DavException(DavException.REDIRECT, "The server redirected http:// to "
|
||||
+ origin(to) + " (Nextcloud forces HTTPS / HSTS). Android 2.3 can't follow that: "
|
||||
+ "use the legacy-TLS bridge address instead (see README, 'Forced HTTPS / HSTS').");
|
||||
throw new DavException(DavException.REDIRECT, L.f("The server redirected http:// to %s (Nextcloud forces HTTPS / HSTS). Android 2.3 can't follow that: use the legacy-TLS bridge address instead (see README, 'Forced HTTPS / HSTS').", origin(to)));
|
||||
}
|
||||
if (!a.equals(b)) {
|
||||
throw new DavException(DavException.REDIRECT, "The server redirected to " + origin(to)
|
||||
+ ", not the address set in the app. Nextcloud is sending its public URL; check the "
|
||||
+ "bridge's proxy_redirect line (README, 'Forced HTTPS / HSTS').");
|
||||
throw new DavException(DavException.REDIRECT, L.f("The server redirected to %s, not the address set in the app. Nextcloud is sending its public URL; check the bridge's proxy_redirect line (README, 'Forced HTTPS / HSTS').", origin(to)));
|
||||
}
|
||||
if (visited.contains(to)) {
|
||||
throw new DavException(DavException.REDIRECT, "Redirect loop (HTTP " + code + " back to the same "
|
||||
+ "address). Nextcloud forces HTTPS but the bridge reaches it over plain HTTP: switch the "
|
||||
+ "bridge to proxy_pass https:// (README, 'Forced HTTPS / HSTS').");
|
||||
throw new DavException(DavException.REDIRECT, L.f("Redirect loop (HTTP %d back to the same address). Nextcloud forces HTTPS but the bridge reaches it over plain HTTP: switch the bridge to proxy_pass https:// (README, 'Forced HTTPS / HSTS').", code));
|
||||
}
|
||||
}
|
||||
|
||||
List<Response> multistatus(String method, String target, String depth, String body) throws IOException {
|
||||
Http.Resp r = send(method, target, depth, body, null);
|
||||
if (r.code != 207) {
|
||||
throw new DavException(r.code, method + " " + URI.create(target).getPath() + " failed: HTTP " + r.code
|
||||
+ (r.code == 404 ? " (not found)" : r.code == 405 ? " (not a WebDAV URL?)" : ""));
|
||||
throw new DavException(r.code, L.f("%s %s failed: HTTP %d%s", method, URI.create(target).getPath(), r.code,
|
||||
r.code == 404 ? L.t(" (not found)") : r.code == 405 ? L.t(" (not a WebDAV URL?)") : ""));
|
||||
}
|
||||
Node ms = Xml.parse(r.body);
|
||||
List<Response> out = new ArrayList<Response>();
|
||||
@@ -206,7 +199,7 @@ public class Dav {
|
||||
}
|
||||
}
|
||||
if (principal == null) {
|
||||
throw last != null ? last : new DavException(0, "Server did not report a CalDAV principal");
|
||||
throw last != null ? last : new DavException(0, L.t("Server did not report a CalDAV principal"));
|
||||
}
|
||||
List<Response> rs = multistatus("PROPFIND", principal, "0", propfind("<c:calendar-home-set/>"));
|
||||
for (Response r : rs) {
|
||||
@@ -326,7 +319,7 @@ public class Dav {
|
||||
/** GET a single object. Returns {ics, etag}. */
|
||||
public String[] get(String href) throws IOException {
|
||||
Http.Resp r = send("GET", href, null, null, null);
|
||||
if (r.code != 200) throw new DavException(r.code, "Could not load event: HTTP " + r.code);
|
||||
if (r.code != 200) throw new DavException(r.code, L.f("Could not load event: HTTP %d", r.code));
|
||||
return new String[] {r.body, r.etag};
|
||||
}
|
||||
|
||||
@@ -334,25 +327,25 @@ public class Dav {
|
||||
String href = abs(calHref.endsWith("/") ? calHref : calHref + "/", uid + ".ics");
|
||||
Http.Resp r = send("PUT", href, null, ics, new String[] {"If-None-Match", "*"});
|
||||
if (r.code != 201 && r.code != 204 && r.code != 200) {
|
||||
throw new DavException(r.code, "Saving failed: HTTP " + r.code);
|
||||
throw new DavException(r.code, L.f("Saving failed: HTTP %d", r.code));
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String href, String etag, String ics) throws IOException {
|
||||
String[] h = etag == null || etag.length() == 0 ? null : new String[] {"If-Match", etag};
|
||||
Http.Resp r = send("PUT", href, null, ics, h);
|
||||
if (r.code == 412) throw new DavException(412, "Event was changed on the server meanwhile. Sync and try again.");
|
||||
if (r.code == 412) throw new DavException(412, L.t("Event was changed on the server meanwhile. Sync and try again."));
|
||||
if (r.code != 201 && r.code != 204 && r.code != 200) {
|
||||
throw new DavException(r.code, "Saving failed: HTTP " + r.code);
|
||||
throw new DavException(r.code, L.f("Saving failed: HTTP %d", r.code));
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String href, String etag) throws IOException {
|
||||
String[] h = etag == null || etag.length() == 0 ? null : new String[] {"If-Match", etag};
|
||||
Http.Resp r = send("DELETE", href, null, null, h);
|
||||
if (r.code == 412) throw new DavException(412, "Event was changed on the server meanwhile. Sync and try again.");
|
||||
if (r.code == 412) throw new DavException(412, L.t("Event was changed on the server meanwhile. Sync and try again."));
|
||||
if (r.code != 204 && r.code != 200 && r.code != 404) {
|
||||
throw new DavException(r.code, "Delete failed: HTTP " + r.code);
|
||||
throw new DavException(r.code, L.f("Delete failed: HTTP %d", r.code));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user