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

Expose share by mail #735

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -26,6 +26,13 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
import com.owncloud.android.lib.resources.status.E2EVersion;
Expand All @@ -36,13 +43,6 @@

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

/**
* Class to test GetRemoteCapabilitiesOperation
*/
Expand Down Expand Up @@ -123,6 +123,25 @@ public void testGetRemoteCapabilitiesOperationEtagWithNextcloudClient() {
checkCapability(capability, nextcloudClient.getUserId());
}

@Test
public void testFilesSharing() {
// get capabilities
RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
assertTrue(result.isSuccess());
assertTrue(result.getData() != null && result.getData().size() == 1);

OCCapability capability = (OCCapability) result.getData().get(0);

// share by mail
if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_23)) {
assertTrue(capability.getFilesSharingByMail().isTrue());
assertTrue(capability.getFilesSharingByMailSendPasswordByMail().isTrue());
} else {
assertTrue("Value is:" + capability.getFilesSharingByMail(), capability.getFilesSharingByMail().isTrue());
assertTrue(capability.getFilesSharingByMailSendPasswordByMail().isUnknown());
}
}

private void checkCapability(OCCapability capability, String userId) {
assertTrue(capability.getActivity().isTrue());
assertTrue(capability.getFilesSharingApiEnabled().isTrue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class GetCapabilitiesRemoteOperation extends RemoteOperation {
private static final String NODE_CORE = "core";

private static final String NODE_FILES_SHARING = "files_sharing";
private static final String NODE_SHARE_BY_MAIL = "sharebymail";
private static final String NODE_PUBLIC = "public";
private static final String NODE_PASSWORD = "password";
private static final String NODE_ASK_FOR_OPTIONAL_PASSWORD = "askForOptionalPassword";
Expand All @@ -89,6 +90,8 @@ public class GetCapabilitiesRemoteOperation extends RemoteOperation {

private static final String PROPERTY_POLLINTERVAL = "pollinterval";

private static final String PROPERTY_SEND_PASSWORD_BY_MAIL = "send_password_by_mail";

private static final String PROPERTY_MAJOR = "major";
private static final String PROPERTY_MINOR = "minor";
private static final String PROPERTY_MICRO = "micro";
Expand Down Expand Up @@ -422,6 +425,23 @@ private OCCapability parseResponse(String response) throws JSONException {
capability.setFilesSharingFederationIncoming(CapabilityBooleanType.fromBooleanValue(
respFederation.getBoolean(PROPERTY_INCOMING)));
}

if (respFilesSharing.has(NODE_SHARE_BY_MAIL)) {
JSONObject respByMail = respFilesSharing.getJSONObject(NODE_SHARE_BY_MAIL);
capability.setFilesSharingByMail(CapabilityBooleanType.fromBooleanValue(
respByMail.getBoolean(PROPERTY_ENABLED)));
if (respByMail.has(PROPERTY_SEND_PASSWORD_BY_MAIL)) {
capability.setFilesSharingByMailSendPasswordByMail(
CapabilityBooleanType.fromBooleanValue(
respByMail.getBoolean(PROPERTY_SEND_PASSWORD_BY_MAIL)));
} else {
capability.setFilesSharingByMailSendPasswordByMail(CapabilityBooleanType.UNKNOWN);
}
} else {
capability.setFilesSharingByMail(CapabilityBooleanType.UNKNOWN);
capability.setFilesSharingByMailSendPasswordByMail(CapabilityBooleanType.UNKNOWN);
}

Log_OC.d(TAG, "*** Added " + NODE_FILES_SHARING);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class OCCapability {
var filesSharingResharing = CapabilityBooleanType.UNKNOWN
var filesSharingFederationOutgoing = CapabilityBooleanType.UNKNOWN
var filesSharingFederationIncoming = CapabilityBooleanType.UNKNOWN
var filesSharingByMail = CapabilityBooleanType.UNKNOWN
var filesSharingByMailSendPasswordByMail = CapabilityBooleanType.UNKNOWN

// Files
var filesBigFileChunking = CapabilityBooleanType.UNKNOWN
Expand Down
Loading