Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

public sharing: ask for password #294

Merged
merged 1 commit into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
private static final String NODE_FILES_SHARING = "files_sharing";
private static final String NODE_PUBLIC = "public";
private static final String NODE_PASSWORD = "password";
private static final String NODE_ASK_FOR_OPTIONAL_PASSWORD = "askForOptionalPassword";
private static final String NODE_FILES_DROP = "upload_files_drop";
private static final String NODE_EXPIRE_DATE = "expire_date";
private static final String NODE_USER = "user";
Expand Down Expand Up @@ -220,9 +221,21 @@ protected RemoteOperationResult run(OwnCloudClient client) {
capability.setFilesSharingPublicEnabled(CapabilityBooleanType.fromBooleanValue(
respPublic.getBoolean(PROPERTY_ENABLED)));
if(respPublic.has(NODE_PASSWORD)) {
JSONObject passwordJson = respPublic.getJSONObject(NODE_PASSWORD);

capability.setFilesSharingPublicPasswordEnforced(
CapabilityBooleanType.fromBooleanValue(
respPublic.getJSONObject(NODE_PASSWORD).getBoolean(PROPERTY_ENFORCED)));
passwordJson.getBoolean(PROPERTY_ENFORCED)));

if (passwordJson.has(NODE_ASK_FOR_OPTIONAL_PASSWORD)) {
capability.setFilesSharingPublicAskForOptionalPassword(
CapabilityBooleanType.fromBooleanValue(
passwordJson.getBoolean(NODE_ASK_FOR_OPTIONAL_PASSWORD))
);
} else {
capability.setFilesSharingPublicAskForOptionalPassword(
CapabilityBooleanType.FALSE);
}
}
if(respPublic.has(NODE_FILES_DROP)) {
capability.setFilesFileDrop(
Expand Down Expand Up @@ -373,15 +386,11 @@ protected RemoteOperationResult run(OwnCloudClient client) {
JSONObject provider = (JSONObject) providers.get(i);

String id = provider.getString("id");

switch (id) {
case "files":
capability.setFullNextSearchFiles(CapabilityBooleanType.TRUE);
Log_OC.d(TAG, "full next search: file provider enabled");
break;
default:
// do nothing
break;

// do nothing
if ("files".equals(id)) {
capability.setFullNextSearchFiles(CapabilityBooleanType.TRUE);
Log_OC.d(TAG, "full next search: file provider enabled");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class OCCapability {
private CapabilityBooleanType filesSharingApiEnabled;
private CapabilityBooleanType filesSharingPublicEnabled;
private CapabilityBooleanType filesSharingPublicPasswordEnforced;
private CapabilityBooleanType filesSharingPublicAskForOptionalPassword;
private CapabilityBooleanType filesSharingPublicExpireDateEnabled;
private int filesSharingPublicExpireDateDays;
private CapabilityBooleanType filesSharingPublicExpireDateEnforced;
Expand Down Expand Up @@ -126,6 +127,7 @@ public OCCapability() {
filesSharingApiEnabled = CapabilityBooleanType.UNKNOWN;
filesSharingPublicEnabled = CapabilityBooleanType.UNKNOWN;
filesSharingPublicPasswordEnforced = CapabilityBooleanType.UNKNOWN;
filesSharingPublicAskForOptionalPassword = CapabilityBooleanType.UNKNOWN;
filesSharingPublicExpireDateEnabled = CapabilityBooleanType.UNKNOWN;
filesSharingPublicExpireDateDays = 0;
filesSharingPublicExpireDateEnforced = CapabilityBooleanType.UNKNOWN;
Expand Down