Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(dropbox): Consistency for the naming around the app key.

hristoterezov60decf769284
diff --git a/android/app/build.gradle b/android/app/build.gradle
index a70b657d6f..261bfb5e9c 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -1,6 +1,6 @@
apply plugin: 'com.android.application'
-def dropboxAppID = ""
+def dropboxAppKey = ""
android {
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -30,12 +30,12 @@ android {
buildTypes {
debug {
- resValue("string", "dropbox_app_key", "${dropboxAppID}")
+ resValue("string", "dropbox_app_key", "${dropboxAppKey}")
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
}
release {
- resValue("string", "dropbox_app_key", "${dropboxAppID}")
+ resValue("string", "dropbox_app_key", "${dropboxAppKey}")
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.pro'
}
@@ -46,13 +46,13 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
- if (dropboxAppID) {
+ if (dropboxAppKey) {
def dropboxActivity = """<activity
android:name="com.dropbox.core.android.AuthActivity"
android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<intent-filter>
- <data android:scheme="db-${dropboxAppID}" />
+ <data android:scheme="db-${dropboxAppKey}" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/dropbox/Dropbox.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/dropbox/Dropbox.java
index 10c25db8e3..e2c558218b 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/dropbox/Dropbox.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/dropbox/Dropbox.java
@@ -1,12 +1,10 @@
package org.jitsi.meet.sdk.dropbox;
-import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
-import android.util.Log;
import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
@@ -22,7 +20,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.dropbox.core.android.Auth;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
-import org.jitsi.meet.sdk.R;
import java.util.HashMap;
import java.util.Map;
@@ -30,26 +27,28 @@ import java.util.Map;
/**
* Implements the react-native module for the dropbox integration.
*/
-public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEventListener {
+public class Dropbox
+ extends ReactContextBaseJavaModule
+ implements LifecycleEventListener {
+ private String appKey;
- private Promise promise = null;
private String clientId;
- private String appID;
- private boolean isEnabled = false;
+
+ private final boolean isEnabled;
+
+ private Promise promise;
public Dropbox(ReactApplicationContext reactContext) {
super(reactContext);
- reactContext.addLifecycleEventListener(this);
+
+ appKey
+ = reactContext.getString(
+ org.jitsi.meet.sdk.R.string.dropbox_app_key);
+ isEnabled = !TextUtils.isEmpty(appKey);
+
clientId = generateClientId();
- appID = reactContext.getString(R.string.dropbox_app_key);
- if (!TextUtils.isEmpty(appID)) {
- isEnabled = true;
- }
- }
- @Override
- public String getName() {
- return "Dropbox";
+ reactContext.addLifecycleEventListener(this);
}
/**
@@ -59,22 +58,54 @@ public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEven
*/
@ReactMethod
public void authorize(final Promise promise) {
- if (!isEnabled) {
- promise.reject(new Exception("Dropbox integration isn't configured."));
- return;
+ if (isEnabled) {
+ Auth.startOAuth2Authentication(this.getCurrentActivity(), appKey);
+ this.promise = promise;
+ } else {
+ promise.reject(
+ new Exception("Dropbox integration isn't configured."));
+ }
+ }
+
+ /**
+ * Generate a client identifier for the dropbox sdk.
+ *
+ * @returns a client identifier for the dropbox sdk.
+ * @see {https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/DbxRequestConfig.html#getClientIdentifier--}
+ */
+ private String generateClientId() {
+ Context context = getReactApplicationContext();
+ PackageManager packageManager = context.getPackageManager();
+ ApplicationInfo applicationInfo = null;
+ PackageInfo packageInfo = null;
+
+ try {
+ String packageName = context.getPackageName();
+
+ applicationInfo = packageManager.getApplicationInfo(packageName, 0);
+ packageInfo = packageManager.getPackageInfo(packageName, 0);
+ } catch (PackageManager.NameNotFoundException e) {
}
- Auth.startOAuth2Authentication(this.getCurrentActivity(), appID);
- this.promise = promise;
+
+ String applicationLabel
+ = applicationInfo == null
+ ? "JitsiMeet"
+ : packageManager.getApplicationLabel(applicationInfo).toString()
+ .replaceAll("\\s", "");
+ String version = packageInfo == null ? "dev" : packageInfo.versionName;
+
+ return applicationLabel + "/" + version;
}
@Override
public Map<String, Object> getConstants() {
- final Map<String, Object> constants = new HashMap<>();
+ Map<String, Object> constants = new HashMap<>();
+
constants.put("ENABLED", isEnabled);
+
return constants;
}
-
/**
* Resolves the current user dropbox display name.
*
@@ -83,18 +114,24 @@ public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEven
*/
@ReactMethod
public void getDisplayName(final String token, final Promise promise) {
- DbxRequestConfig config
- = DbxRequestConfig.newBuilder(clientId).build();
+ DbxRequestConfig config = DbxRequestConfig.newBuilder(clientId).build();
DbxClientV2 client = new DbxClientV2(config, token);
+
// Get current account info
try {
FullAccount account = client.users().getCurrentAccount();
+
promise.resolve(account.getName().getDisplayName());
} catch (DbxException e) {
promise.reject(e);
}
}
+ @Override
+ public String getName() {
+ return "Dropbox";
+ }
+
/**
* Resolves the current user space usage.
*
@@ -103,79 +140,45 @@ public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEven
*/
@ReactMethod
public void getSpaceUsage(final String token, final Promise promise) {
- DbxRequestConfig config
- = DbxRequestConfig.newBuilder(clientId).build();
+ DbxRequestConfig config = DbxRequestConfig.newBuilder(clientId).build();
DbxClientV2 client = new DbxClientV2(config, token);
+
try {
SpaceUsage spaceUsage = client.users().getSpaceUsage();
WritableMap map = Arguments.createMap();
+
map.putString("used", String.valueOf(spaceUsage.getUsed()));
+
SpaceAllocation allocation = spaceUsage.getAllocation();
long allocated = 0;
- if(allocation.isIndividual()) {
+
+ if (allocation.isIndividual()) {
allocated += allocation.getIndividualValue().getAllocated();
}
-
- if(allocation.isTeam()) {
+ if (allocation.isTeam()) {
allocated += allocation.getTeamValue().getAllocated();
}
map.putString("allocated", String.valueOf(allocated));
+
promise.resolve(map);
} catch (DbxException e) {
promise.reject(e);
}
}
- /**
- * Generate a client identifier for the dropbox sdk.
- *
- * @returns a client identifier for the dropbox sdk.
- * @see {https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/DbxRequestConfig.html#getClientIdentifier--}
- */
- private String generateClientId() {
- Context context = getReactApplicationContext();
- PackageManager packageManager = context.getPackageManager();
- ApplicationInfo applicationInfo = null;
- PackageInfo packageInfo = null;
-
- try {
- String packageName = context.getPackageName();
-
- applicationInfo
- = packageManager.getApplicationInfo(packageName, 0);
- packageInfo = packageManager.getPackageInfo(packageName, 0);
- } catch (PackageManager.NameNotFoundException e) {
- }
-
- String applicationLabel
- = applicationInfo == null
- ? "JitsiMeet"
- : packageManager.getApplicationLabel(applicationInfo)
- .toString().replaceAll("\\s", "");
- String version = packageInfo == null ? "dev" : packageInfo.versionName;
+ @Override
+ public void onHostDestroy() {}
- return applicationLabel + "/" + version;
- }
+ @Override
+ public void onHostPause() {}
@Override
public void onHostResume() {
- final String token = Auth.getOAuth2Token();
- if (token == null)
- return;
+ String token = Auth.getOAuth2Token();
- if (this.promise != null) {
+ if (token != null && this.promise != null) {
this.promise.resolve(token);
this.promise = null;
}
}
-
- @Override
- public void onHostPause() {
-
- }
-
- @Override
- public void onHostDestroy() {
-
- }
}
diff --git a/config.js b/config.js
index 90e43105c4..f816b18324 100644
--- a/config.js
+++ b/config.js
@@ -173,7 +173,7 @@ var config = {
// fileRecordingsEnabled: false,
// Enable the dropbox integration.
// dropbox: {
- // clientId: '<APP_ID>' // Specify your app ID here.
+ // appKey: '<APP_KEY>' // Specify your app key here.
// },
// Whether to enable live streaming or not.
diff --git a/react/features/dropbox/actions.js b/react/features/dropbox/actions.js
index edca7c8005..431db59a60 100644
--- a/react/features/dropbox/actions.js
+++ b/react/features/dropbox/actions.js
@@ -18,7 +18,7 @@ export function authorizeDropbox() {
const redirectURI = `${locationURL.origin
+ getLocationContextRoot(locationURL)}static/oauth.html`;
- _authorizeDropbox(dropbox.clientId, redirectURI)
+ _authorizeDropbox(dropbox.appKey, redirectURI)
.then(
token => dispatch(updateDropboxToken(token)));
};
diff --git a/react/features/dropbox/functions.any.js b/react/features/dropbox/functions.any.js
index 8d0f824ed5..388f31dab0 100644
--- a/react/features/dropbox/functions.any.js
+++ b/react/features/dropbox/functions.any.js
@@ -25,15 +25,15 @@ type DropboxUserData = {
* Fetches information about the user's dropbox account.
*
* @param {string} token - The dropbox access token.
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
* @returns {Promise<DropboxUserData|undefined>}
*/
export function getDropboxData(
token: string,
- clientId: string
+ appKey: string
): Promise<?DropboxUserData> {
return Promise.all(
- [ getDisplayName(token, clientId), getSpaceUsage(token, clientId) ]
+ [ getDisplayName(token, appKey), getSpaceUsage(token, appKey) ]
).then(([ userName, space ]) => {
const { allocated, used } = space;
diff --git a/react/features/dropbox/functions.native.js b/react/features/dropbox/functions.native.js
index 593d64ca89..ccfeecf988 100644
--- a/react/features/dropbox/functions.native.js
+++ b/react/features/dropbox/functions.native.js
@@ -4,6 +4,18 @@ import { NativeModules } from 'react-native';
const { Dropbox } = NativeModules;
+/**
+ * Action to authorize the Jitsi Recording app in dropbox.
+ *
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
+ * @param {string} redirectURI - The return URL.
+ * @returns {Promise<string>} - The promise will be resolved with the dropbox
+ * access token or rejected with an error.
+ */
+export function _authorizeDropbox(): Promise<string> {
+ return Dropbox.authorize();
+}
+
/**
* Returns the display name for the current dropbox account.
*
@@ -28,19 +40,6 @@ export function getSpaceUsage(token: string) {
return Dropbox.getSpaceUsage(token);
}
-
-/**
- * Action to authorize the Jitsi Recording app in dropbox.
- *
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
- * @param {string} redirectURI - The return URL.
- * @returns {Promise<string>} - The promise will be resolved with the dropbox
- * access token or rejected with an error.
- */
-export function _authorizeDropbox(): Promise<string> {
- return Dropbox.authorize();
-}
-
/**
* Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
* otherwise.
diff --git a/react/features/dropbox/functions.web.js b/react/features/dropbox/functions.web.js
index 07fbf87435..244060e7b7 100644
--- a/react/features/dropbox/functions.web.js
+++ b/react/features/dropbox/functions.web.js
@@ -2,54 +2,11 @@
import { Dropbox } from 'dropbox';
+import { parseURLParams } from '../base/config';
import {
getJitsiMeetGlobalNS,
parseStandardURIString
} from '../base/util';
-import { parseURLParams } from '../base/config';
-
-/**
- * Returns the display name for the current dropbox account.
- *
- * @param {string} token - The dropbox access token.
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
- * @returns {Promise<string>}
- */
-export function getDisplayName(token: string, clientId: string) {
- const dropboxAPI = new Dropbox({
- accessToken: token,
- clientId
- });
-
- return (
- dropboxAPI.usersGetCurrentAccount()
- .then(account => account.name.display_name));
-}
-
-/**
- * Returns information about the space usage for the current dropbox account.
- *
- * @param {string} token - The dropbox access token.
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
- * @returns {Promise<Object>}
- */
-export function getSpaceUsage(token: string, clientId: string) {
- const dropboxAPI = new Dropbox({
- accessToken: token,
- clientId
- });
-
- return dropboxAPI.usersGetSpaceUsage().then(space => {
- const { allocation, used } = space;
- const { allocated } = allocation;
-
- return {
- used,
- allocated
- };
- });
-}
-
/**
* Executes the oauth flow.
@@ -79,15 +36,15 @@ function authorize(authUrl: string): Promise<string> {
/**
* Action to authorize the Jitsi Recording app in dropbox.
*
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
* @param {string} redirectURI - The return URL.
* @returns {Promise<string>}
*/
export function _authorizeDropbox(
- clientId: string,
+ appKey: string,
redirectURI: string
): Promise<string> {
- const dropboxAPI = new Dropbox({ clientId });
+ const dropboxAPI = new Dropbox({ clientId: appKey });
const url = dropboxAPI.getAuthenticationUrl(redirectURI);
return authorize(url).then(returnUrl => {
@@ -98,6 +55,48 @@ export function _authorizeDropbox(
});
}
+/**
+ * Returns the display name for the current dropbox account.
+ *
+ * @param {string} token - The dropbox access token.
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
+ * @returns {Promise<string>}
+ */
+export function getDisplayName(token: string, appKey: string) {
+ const dropboxAPI = new Dropbox({
+ accessToken: token,
+ clientId: appKey
+ });
+
+ return (
+ dropboxAPI.usersGetCurrentAccount()
+ .then(account => account.name.display_name));
+}
+
+/**
+ * Returns information about the space usage for the current dropbox account.
+ *
+ * @param {string} token - The dropbox access token.
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
+ * @returns {Promise<Object>}
+ */
+export function getSpaceUsage(token: string, appKey: string) {
+ const dropboxAPI = new Dropbox({
+ accessToken: token,
+ clientId: appKey
+ });
+
+ return dropboxAPI.usersGetSpaceUsage().then(space => {
+ const { allocation, used } = space;
+ const { allocated } = allocation;
+
+ return {
+ allocated,
+ used
+ };
+ });
+}
+
/**
* Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
* otherwise.
@@ -108,5 +107,5 @@ export function _authorizeDropbox(
export function isEnabled(state: Object) {
const { dropbox = {} } = state['features/base/config'];
- return typeof dropbox.clientId === 'string';
+ return typeof dropbox.appKey === 'string';
}
diff --git a/react/features/recording/components/Recording/StartRecordingDialog.js b/react/features/recording/components/Recording/StartRecordingDialog.js
index 720497b4ee..3a3ce94406 100644
--- a/react/features/recording/components/Recording/StartRecordingDialog.js
+++ b/react/features/recording/components/Recording/StartRecordingDialog.js
@@ -21,9 +21,9 @@ type Props = {
_conference: Object,
/**
- * The client id for the dropbox authentication.
+ * The app key for the dropbox authentication.
*/
- _clientId: string,
+ _appKey: string,
/**
* The dropbox access token.
@@ -117,7 +117,7 @@ class StartRecordingDialog extends Component<Props, State> {
* @returns {void}
*/
_onTokenUpdated() {
- const { _clientId, _token } = this.props;
+ const { _appKey, _token } = this.props;
if (typeof _token === 'undefined') {
this.setState({
@@ -129,7 +129,7 @@ class StartRecordingDialog extends Component<Props, State> {
isTokenValid: false,
isValidating: true
});
- getDropboxData(_token, _clientId).then(data => {
+ getDropboxData(_token, _appKey).then(data => {
if (typeof data === 'undefined') {
this.setState({
isTokenValid: false,
@@ -216,7 +216,7 @@ class StartRecordingDialog extends Component<Props, State> {
* @param {Object} state - The Redux state.
* @private
* @returns {{
- * _clientId: string,
+ * _appKey: string,
* _conference: JitsiConference,
* _token: string
* }}
@@ -225,7 +225,7 @@ function mapStateToProps(state: Object) {
const { dropbox = {} } = state['features/base/config'];
return {
- _clientId: dropbox.clientId,
+ _appKey: dropbox.appKey,
_conference: state['features/base/conference'].conference,
_token: state['features/dropbox'].token
};