Skip to content

Commit

Permalink
Merge pull request #294 from nextcloud/askForPassword
Browse files Browse the repository at this point in the history
public sharing: ask for password
  • Loading branch information
AndyScherzinger authored May 10, 2019
2 parents b15a976 + 3f803d7 commit 7b8b392
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
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

0 comments on commit 7b8b392

Please sign in to comment.