Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4474216c authored by David Luhmer's avatar David Luhmer
Browse files

add getter/setter to access NextcloudRequest / add support to disable follow-redirects

parent 075451e9
Loading
Loading
Loading
Loading
+69 −10
Original line number Diff line number Diff line
@@ -26,16 +26,17 @@ import java.util.Map;

public class NextcloudRequest implements Serializable {

    private static final long serialVersionUID = 215521212534237L; //assign a long value

    public String method;
    public Map<String, List<String>> header = new HashMap<>();
    public Map<String, String> parameter = new HashMap<>();
    public String requestBody;
    public String url;
    public String token;
    public String packageName;
    public String accountName;
    private static final long serialVersionUID = 215521212534238L; //assign a long value

    private String method;
    private Map<String, List<String>> header = new HashMap<>();
    private Map<String, String> parameter = new HashMap<>();
    private String requestBody;
    private String url;
    private String token;
    private String packageName;
    private String accountName;
    private boolean followRedirects = false;

    private NextcloudRequest() { }

@@ -89,6 +90,64 @@ public class NextcloudRequest implements Serializable {
            ncr.accountName = accountName;
            return this;
        }

        /**
         * Default: true
         * @param followRedirects
         * @return
         */
        public Builder setFollowRedirects(boolean followRedirects) {
            ncr.followRedirects = followRedirects;
            return this;
        }
    }

    public String getMethod() {
        return this.method;
    }

    public Map<String, List<String>> getHeader() {
        return this.header;
    }

    public Map<String, String> getParameter() {
        return this.parameter;
    }

    public String getRequestBody() {
        return this.requestBody;
    }

    public String getUrl() {
        return this.url;
    }

    public String getToken() {
        return this.token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getPackageName() {
        return this.packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getAccountName() {
        return this.accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public boolean getFollowRedirects() {
        return this.followRedirects;
    }

    public boolean validateToken(String token) {
+2 −2
Original line number Diff line number Diff line
@@ -264,8 +264,8 @@ public class NextcloudAPI {
     */
    private ParcelFileDescriptor performAidlNetworkRequest(NextcloudRequest request) throws IOException, RemoteException {
        // Log.d(TAG, request.url);
        request.accountName = getAccountName();
        request.token = getAccountToken();
        request.setAccountName(getAccountName());
        request.setToken(getAccountToken());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);