Quellcode durchsuchen

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

master
hristoterezov vor 7 Jahren
Ursprung
Commit
60decf7692

+ 5
- 5
android/app/build.gradle Datei anzeigen

@@ -1,6 +1,6 @@
1 1
 apply plugin: 'com.android.application'
2 2
 
3
-def dropboxAppID = ""
3
+def dropboxAppKey = ""
4 4
 
5 5
 android {
6 6
     compileSdkVersion rootProject.ext.compileSdkVersion
@@ -30,12 +30,12 @@ android {
30 30
 
31 31
     buildTypes {
32 32
         debug {
33
-            resValue("string", "dropbox_app_key", "${dropboxAppID}")
33
+            resValue("string", "dropbox_app_key", "${dropboxAppKey}")
34 34
             minifyEnabled true
35 35
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
36 36
         }
37 37
         release {
38
-            resValue("string", "dropbox_app_key", "${dropboxAppID}")
38
+            resValue("string", "dropbox_app_key", "${dropboxAppKey}")
39 39
             minifyEnabled true
40 40
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.pro'
41 41
         }
@@ -46,13 +46,13 @@ android {
46 46
         targetCompatibility JavaVersion.VERSION_1_8
47 47
     }
48 48
 
49
-    if (dropboxAppID) {
49
+    if (dropboxAppKey) {
50 50
         def dropboxActivity = """<activity
51 51
             android:name="com.dropbox.core.android.AuthActivity"
52 52
             android:configChanges="orientation|keyboard"
53 53
             android:launchMode="singleTask">
54 54
           <intent-filter>
55
-            <data android:scheme="db-${dropboxAppID}" />
55
+            <data android:scheme="db-${dropboxAppKey}" />
56 56
             <action android:name="android.intent.action.VIEW" />
57 57
             <category android:name="android.intent.category.BROWSABLE" />
58 58
             <category android:name="android.intent.category.DEFAULT" />

+ 76
- 73
android/sdk/src/main/java/org/jitsi/meet/sdk/dropbox/Dropbox.java Datei anzeigen

@@ -1,12 +1,10 @@
1 1
 package org.jitsi.meet.sdk.dropbox;
2 2
 
3
-import android.app.Activity;
4 3
 import android.content.Context;
5 4
 import android.content.pm.ApplicationInfo;
6 5
 import android.content.pm.PackageInfo;
7 6
 import android.content.pm.PackageManager;
8 7
 import android.text.TextUtils;
9
-import android.util.Log;
10 8
 
11 9
 import com.dropbox.core.DbxException;
12 10
 import com.dropbox.core.DbxRequestConfig;
@@ -22,7 +20,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
22 20
 import com.dropbox.core.android.Auth;
23 21
 import com.facebook.react.bridge.ReactMethod;
24 22
 import com.facebook.react.bridge.WritableMap;
25
-import org.jitsi.meet.sdk.R;
26 23
 
27 24
 import java.util.HashMap;
28 25
 import java.util.Map;
@@ -30,26 +27,28 @@ import java.util.Map;
30 27
 /**
31 28
  * Implements the react-native module for the dropbox integration.
32 29
  */
33
-public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEventListener {
30
+public class Dropbox
31
+        extends ReactContextBaseJavaModule
32
+        implements LifecycleEventListener {
33
+    private String appKey;
34 34
 
35
-    private Promise promise = null;
36 35
     private String clientId;
37
-    private String appID;
38
-    private boolean isEnabled = false;
36
+
37
+    private final boolean isEnabled;
38
+
39
+    private Promise promise;
39 40
 
40 41
     public Dropbox(ReactApplicationContext reactContext) {
41 42
         super(reactContext);
42
-        reactContext.addLifecycleEventListener(this);
43
+
44
+        appKey
45
+            = reactContext.getString(
46
+                org.jitsi.meet.sdk.R.string.dropbox_app_key);
47
+        isEnabled = !TextUtils.isEmpty(appKey);
48
+
43 49
         clientId = generateClientId();
44
-        appID = reactContext.getString(R.string.dropbox_app_key);
45
-        if (!TextUtils.isEmpty(appID)) {
46
-            isEnabled = true;
47
-        }
48
-    }
49 50
 
50
-    @Override
51
-    public String getName() {
52
-        return "Dropbox";
51
+        reactContext.addLifecycleEventListener(this);
53 52
     }
54 53
 
55 54
     /**
@@ -59,22 +58,54 @@ public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEven
59 58
      */
60 59
     @ReactMethod
61 60
     public void authorize(final Promise promise) {
62
-        if (!isEnabled) {
63
-            promise.reject(new Exception("Dropbox integration isn't configured."));
64
-            return;
61
+        if (isEnabled) {
62
+            Auth.startOAuth2Authentication(this.getCurrentActivity(), appKey);
63
+            this.promise = promise;
64
+        } else {
65
+            promise.reject(
66
+                new Exception("Dropbox integration isn't configured."));
67
+        }
68
+    }
69
+
70
+    /**
71
+     * Generate a client identifier for the dropbox sdk.
72
+     *
73
+     * @returns a client identifier for the dropbox sdk.
74
+     * @see {https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/DbxRequestConfig.html#getClientIdentifier--}
75
+     */
76
+    private String generateClientId() {
77
+        Context context = getReactApplicationContext();
78
+        PackageManager packageManager = context.getPackageManager();
79
+        ApplicationInfo applicationInfo = null;
80
+        PackageInfo packageInfo = null;
81
+
82
+        try {
83
+            String packageName = context.getPackageName();
84
+
85
+            applicationInfo = packageManager.getApplicationInfo(packageName, 0);
86
+            packageInfo = packageManager.getPackageInfo(packageName, 0);
87
+        } catch (PackageManager.NameNotFoundException e) {
65 88
         }
66
-        Auth.startOAuth2Authentication(this.getCurrentActivity(), appID);
67
-        this.promise = promise;
89
+
90
+        String applicationLabel
91
+            = applicationInfo == null
92
+                ? "JitsiMeet"
93
+                : packageManager.getApplicationLabel(applicationInfo).toString()
94
+                    .replaceAll("\\s", "");
95
+        String version = packageInfo == null ? "dev" : packageInfo.versionName;
96
+
97
+        return applicationLabel + "/" + version;
68 98
     }
69 99
 
70 100
     @Override
71 101
     public Map<String, Object> getConstants() {
72
-        final Map<String, Object> constants = new HashMap<>();
102
+        Map<String, Object> constants = new HashMap<>();
103
+
73 104
         constants.put("ENABLED", isEnabled);
105
+
74 106
         return constants;
75 107
     }
76 108
 
77
-
78 109
     /**
79 110
      * Resolves the current user dropbox display name.
80 111
      *
@@ -83,18 +114,24 @@ public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEven
83 114
      */
84 115
     @ReactMethod
85 116
     public void getDisplayName(final String token, final Promise promise) {
86
-        DbxRequestConfig config
87
-            = DbxRequestConfig.newBuilder(clientId).build();
117
+        DbxRequestConfig config = DbxRequestConfig.newBuilder(clientId).build();
88 118
         DbxClientV2 client = new DbxClientV2(config, token);
119
+
89 120
         // Get current account info
90 121
         try {
91 122
             FullAccount account = client.users().getCurrentAccount();
123
+
92 124
             promise.resolve(account.getName().getDisplayName());
93 125
         } catch (DbxException e) {
94 126
             promise.reject(e);
95 127
         }
96 128
     }
97 129
 
130
+    @Override
131
+    public String getName() {
132
+        return "Dropbox";
133
+    }
134
+
98 135
     /**
99 136
      * Resolves the current user space usage.
100 137
      *
@@ -103,79 +140,45 @@ public class Dropbox extends ReactContextBaseJavaModule implements LifecycleEven
103 140
      */
104 141
     @ReactMethod
105 142
     public void getSpaceUsage(final String token, final Promise promise) {
106
-        DbxRequestConfig config
107
-            = DbxRequestConfig.newBuilder(clientId).build();
143
+        DbxRequestConfig config = DbxRequestConfig.newBuilder(clientId).build();
108 144
         DbxClientV2 client = new DbxClientV2(config, token);
145
+
109 146
         try {
110 147
             SpaceUsage spaceUsage = client.users().getSpaceUsage();
111 148
             WritableMap map = Arguments.createMap();
149
+
112 150
             map.putString("used", String.valueOf(spaceUsage.getUsed()));
151
+
113 152
             SpaceAllocation allocation = spaceUsage.getAllocation();
114 153
             long allocated = 0;
115
-            if(allocation.isIndividual()) {
154
+
155
+            if (allocation.isIndividual()) {
116 156
                 allocated += allocation.getIndividualValue().getAllocated();
117 157
             }
118
-
119
-            if(allocation.isTeam()) {
158
+            if (allocation.isTeam()) {
120 159
                 allocated += allocation.getTeamValue().getAllocated();
121 160
             }
122 161
             map.putString("allocated", String.valueOf(allocated));
162
+
123 163
             promise.resolve(map);
124 164
         } catch (DbxException e) {
125 165
             promise.reject(e);
126 166
         }
127 167
     }
128 168
 
129
-    /**
130
-     * Generate a client identifier for the dropbox sdk.
131
-     *
132
-     * @returns a client identifier for the dropbox sdk.
133
-     * @see {https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/DbxRequestConfig.html#getClientIdentifier--}
134
-     */
135
-    private String generateClientId() {
136
-        Context context = getReactApplicationContext();
137
-        PackageManager packageManager = context.getPackageManager();
138
-        ApplicationInfo applicationInfo = null;
139
-        PackageInfo packageInfo = null;
140
-
141
-        try {
142
-            String packageName = context.getPackageName();
143
-
144
-            applicationInfo
145
-                    = packageManager.getApplicationInfo(packageName, 0);
146
-            packageInfo = packageManager.getPackageInfo(packageName, 0);
147
-        } catch (PackageManager.NameNotFoundException e) {
148
-        }
149
-
150
-        String applicationLabel
151
-            = applicationInfo == null
152
-                ? "JitsiMeet"
153
-                    : packageManager.getApplicationLabel(applicationInfo)
154
-                        .toString().replaceAll("\\s", "");
155
-        String version = packageInfo == null ? "dev" : packageInfo.versionName;
169
+    @Override
170
+    public void onHostDestroy() {}
156 171
 
157
-       return applicationLabel + "/" + version;
158
-    }
172
+    @Override
173
+    public void onHostPause() {}
159 174
 
160 175
     @Override
161 176
     public void onHostResume() {
162
-        final String token = Auth.getOAuth2Token();
163
-        if (token == null)
164
-            return;
177
+        String token = Auth.getOAuth2Token();
165 178
 
166
-        if (this.promise != null) {
179
+        if (token != null && this.promise != null) {
167 180
             this.promise.resolve(token);
168 181
             this.promise = null;
169 182
         }
170 183
     }
171
-
172
-    @Override
173
-    public void onHostPause() {
174
-
175
-    }
176
-
177
-    @Override
178
-    public void onHostDestroy() {
179
-
180
-    }
181 184
 }

+ 1
- 1
config.js Datei anzeigen

@@ -173,7 +173,7 @@ var config = {
173 173
     // fileRecordingsEnabled: false,
174 174
     // Enable the dropbox integration.
175 175
     // dropbox: {
176
-    //     clientId: '<APP_ID>' // Specify your app ID here.
176
+    //     appKey: '<APP_KEY>' // Specify your app key here.
177 177
     // },
178 178
 
179 179
     // Whether to enable live streaming or not.

+ 1
- 1
react/features/dropbox/actions.js Datei anzeigen

@@ -18,7 +18,7 @@ export function authorizeDropbox() {
18 18
         const redirectURI = `${locationURL.origin
19 19
             + getLocationContextRoot(locationURL)}static/oauth.html`;
20 20
 
21
-        _authorizeDropbox(dropbox.clientId, redirectURI)
21
+        _authorizeDropbox(dropbox.appKey, redirectURI)
22 22
             .then(
23 23
                 token => dispatch(updateDropboxToken(token)));
24 24
     };

+ 3
- 3
react/features/dropbox/functions.any.js Datei anzeigen

@@ -25,15 +25,15 @@ type DropboxUserData = {
25 25
  * Fetches information about the user's dropbox account.
26 26
  *
27 27
  * @param {string} token - The dropbox access token.
28
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
28
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
29 29
  * @returns {Promise<DropboxUserData|undefined>}
30 30
  */
31 31
 export function getDropboxData(
32 32
         token: string,
33
-        clientId: string
33
+        appKey: string
34 34
 ): Promise<?DropboxUserData> {
35 35
     return Promise.all(
36
-        [ getDisplayName(token, clientId), getSpaceUsage(token, clientId) ]
36
+        [ getDisplayName(token, appKey), getSpaceUsage(token, appKey) ]
37 37
     ).then(([ userName, space ]) => {
38 38
         const { allocated, used } = space;
39 39
 

+ 12
- 13
react/features/dropbox/functions.native.js Datei anzeigen

@@ -4,6 +4,18 @@ import { NativeModules } from 'react-native';
4 4
 
5 5
 const { Dropbox } = NativeModules;
6 6
 
7
+/**
8
+ * Action to authorize the Jitsi Recording app in dropbox.
9
+ *
10
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
11
+ * @param {string} redirectURI - The return URL.
12
+ * @returns {Promise<string>} - The promise will be resolved with the dropbox
13
+ * access token or rejected with an error.
14
+ */
15
+export function _authorizeDropbox(): Promise<string> {
16
+    return Dropbox.authorize();
17
+}
18
+
7 19
 /**
8 20
  * Returns the display name for the current dropbox account.
9 21
  *
@@ -28,19 +40,6 @@ export function getSpaceUsage(token: string) {
28 40
     return Dropbox.getSpaceUsage(token);
29 41
 }
30 42
 
31
-
32
-/**
33
- * Action to authorize the Jitsi Recording app in dropbox.
34
- *
35
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
36
- * @param {string} redirectURI - The return URL.
37
- * @returns {Promise<string>} - The promise will be resolved with the dropbox
38
- * access token or rejected with an error.
39
- */
40
-export function _authorizeDropbox(): Promise<string> {
41
-    return Dropbox.authorize();
42
-}
43
-
44 43
 /**
45 44
  * Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
46 45
  * otherwise.

+ 47
- 48
react/features/dropbox/functions.web.js Datei anzeigen

@@ -2,54 +2,11 @@
2 2
 
3 3
 import { Dropbox } from 'dropbox';
4 4
 
5
+import { parseURLParams } from '../base/config';
5 6
 import {
6 7
     getJitsiMeetGlobalNS,
7 8
     parseStandardURIString
8 9
 } from '../base/util';
9
-import { parseURLParams } from '../base/config';
10
-
11
-/**
12
- * Returns the display name for the current dropbox account.
13
- *
14
- * @param {string} token - The dropbox access token.
15
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
16
- * @returns {Promise<string>}
17
- */
18
-export function getDisplayName(token: string, clientId: string) {
19
-    const dropboxAPI = new Dropbox({
20
-        accessToken: token,
21
-        clientId
22
-    });
23
-
24
-    return (
25
-        dropboxAPI.usersGetCurrentAccount()
26
-            .then(account => account.name.display_name));
27
-}
28
-
29
-/**
30
- * Returns information about the space usage for the current dropbox account.
31
- *
32
- * @param {string} token - The dropbox access token.
33
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
34
- * @returns {Promise<Object>}
35
- */
36
-export function getSpaceUsage(token: string, clientId: string) {
37
-    const dropboxAPI = new Dropbox({
38
-        accessToken: token,
39
-        clientId
40
-    });
41
-
42
-    return dropboxAPI.usersGetSpaceUsage().then(space => {
43
-        const { allocation, used } = space;
44
-        const { allocated } = allocation;
45
-
46
-        return {
47
-            used,
48
-            allocated
49
-        };
50
-    });
51
-}
52
-
53 10
 
54 11
 /**
55 12
  * Executes the oauth flow.
@@ -79,15 +36,15 @@ function authorize(authUrl: string): Promise<string> {
79 36
 /**
80 37
  * Action to authorize the Jitsi Recording app in dropbox.
81 38
  *
82
- * @param {string} clientId - The Jitsi Recorder dropbox app ID.
39
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
83 40
  * @param {string} redirectURI - The return URL.
84 41
  * @returns {Promise<string>}
85 42
  */
86 43
 export function _authorizeDropbox(
87
-        clientId: string,
44
+        appKey: string,
88 45
         redirectURI: string
89 46
 ): Promise<string> {
90
-    const dropboxAPI = new Dropbox({ clientId });
47
+    const dropboxAPI = new Dropbox({ clientId: appKey });
91 48
     const url = dropboxAPI.getAuthenticationUrl(redirectURI);
92 49
 
93 50
     return authorize(url).then(returnUrl => {
@@ -98,6 +55,48 @@ export function _authorizeDropbox(
98 55
     });
99 56
 }
100 57
 
58
+/**
59
+ * Returns the display name for the current dropbox account.
60
+ *
61
+ * @param {string} token - The dropbox access token.
62
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
63
+ * @returns {Promise<string>}
64
+ */
65
+export function getDisplayName(token: string, appKey: string) {
66
+    const dropboxAPI = new Dropbox({
67
+        accessToken: token,
68
+        clientId: appKey
69
+    });
70
+
71
+    return (
72
+        dropboxAPI.usersGetCurrentAccount()
73
+            .then(account => account.name.display_name));
74
+}
75
+
76
+/**
77
+ * Returns information about the space usage for the current dropbox account.
78
+ *
79
+ * @param {string} token - The dropbox access token.
80
+ * @param {string} appKey - The Jitsi Recorder dropbox app key.
81
+ * @returns {Promise<Object>}
82
+ */
83
+export function getSpaceUsage(token: string, appKey: string) {
84
+    const dropboxAPI = new Dropbox({
85
+        accessToken: token,
86
+        clientId: appKey
87
+    });
88
+
89
+    return dropboxAPI.usersGetSpaceUsage().then(space => {
90
+        const { allocation, used } = space;
91
+        const { allocated } = allocation;
92
+
93
+        return {
94
+            allocated,
95
+            used
96
+        };
97
+    });
98
+}
99
+
101 100
 /**
102 101
  * Returns <tt>true</tt> if the dropbox features is enabled and <tt>false</tt>
103 102
  * otherwise.
@@ -108,5 +107,5 @@ export function _authorizeDropbox(
108 107
 export function isEnabled(state: Object) {
109 108
     const { dropbox = {} } = state['features/base/config'];
110 109
 
111
-    return typeof dropbox.clientId === 'string';
110
+    return typeof dropbox.appKey === 'string';
112 111
 }

+ 6
- 6
react/features/recording/components/Recording/StartRecordingDialog.js Datei anzeigen

@@ -21,9 +21,9 @@ type Props = {
21 21
     _conference: Object,
22 22
 
23 23
     /**
24
-     * The client id for the dropbox authentication.
24
+     * The app key for the dropbox authentication.
25 25
      */
26
-    _clientId: string,
26
+    _appKey: string,
27 27
 
28 28
     /**
29 29
      * The dropbox access token.
@@ -117,7 +117,7 @@ class StartRecordingDialog extends Component<Props, State> {
117 117
      * @returns {void}
118 118
      */
119 119
     _onTokenUpdated() {
120
-        const { _clientId, _token } = this.props;
120
+        const { _appKey, _token } = this.props;
121 121
 
122 122
         if (typeof _token === 'undefined') {
123 123
             this.setState({
@@ -129,7 +129,7 @@ class StartRecordingDialog extends Component<Props, State> {
129 129
                 isTokenValid: false,
130 130
                 isValidating: true
131 131
             });
132
-            getDropboxData(_token, _clientId).then(data => {
132
+            getDropboxData(_token, _appKey).then(data => {
133 133
                 if (typeof data === 'undefined') {
134 134
                     this.setState({
135 135
                         isTokenValid: false,
@@ -216,7 +216,7 @@ class StartRecordingDialog extends Component<Props, State> {
216 216
  * @param {Object} state - The Redux state.
217 217
  * @private
218 218
  * @returns {{
219
- *     _clientId: string,
219
+ *     _appKey: string,
220 220
  *     _conference: JitsiConference,
221 221
  *     _token: string
222 222
  * }}
@@ -225,7 +225,7 @@ function mapStateToProps(state: Object) {
225 225
     const { dropbox = {} } = state['features/base/config'];
226 226
 
227 227
     return {
228
-        _clientId: dropbox.clientId,
228
+        _appKey: dropbox.appKey,
229 229
         _conference: state['features/base/conference'].conference,
230 230
         _token: state['features/dropbox'].token
231 231
     };

Laden…
Abbrechen
Speichern