ソースを参照

rn: add SDK API to set user information

At the moment it includes:

- display name
- email
- avatar URL

This information is used *only* if no token was specified.
j8
Saúl Ibarra Corretgé 5年前
コミット
e33b334307

+ 1
- 0
android/app/src/main/java/org/jitsi/meet/MainActivity.java ファイルの表示

@@ -28,6 +28,7 @@ import android.view.KeyEvent;
28 28
 import org.jitsi.meet.sdk.JitsiMeet;
29 29
 import org.jitsi.meet.sdk.JitsiMeetActivity;
30 30
 import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
31
+import org.jitsi.meet.sdk.JitsiMeetUserInfo;
31 32
 
32 33
 import java.lang.reflect.Method;
33 34
 import java.net.MalformedURLException;

+ 20
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetConferenceOptions.java ファイルの表示

@@ -67,6 +67,11 @@ public class JitsiMeetConferenceOptions implements Parcelable {
67 67
     private Boolean audioOnly;
68 68
     private Boolean videoMuted;
69 69
 
70
+    /**
71
+     * USer information, to be used when no token is specified.
72
+     */
73
+    private JitsiMeetUserInfo userInfo;
74
+
70 75
     /**
71 76
      * Class used to build the immutable {@link JitsiMeetConferenceOptions} object.
72 77
      */
@@ -83,6 +88,8 @@ public class JitsiMeetConferenceOptions implements Parcelable {
83 88
         private Boolean audioOnly;
84 89
         private Boolean videoMuted;
85 90
 
91
+        private JitsiMeetUserInfo userInfo;
92
+
86 93
         public Builder() {
87 94
             featureFlags = new Bundle();
88 95
         }
@@ -208,6 +215,12 @@ public class JitsiMeetConferenceOptions implements Parcelable {
208 215
             return this;
209 216
         }
210 217
 
218
+        public Builder setUserInfo(JitsiMeetUserInfo userInfo) {
219
+            this.userInfo = userInfo;
220
+
221
+            return this;
222
+        }
223
+
211 224
         /**
212 225
          * Builds the immutable {@link JitsiMeetConferenceOptions} object with the configuration
213 226
          * that this {@link Builder} instance specified.
@@ -225,6 +238,7 @@ public class JitsiMeetConferenceOptions implements Parcelable {
225 238
             options.audioMuted = this.audioMuted;
226 239
             options.audioOnly = this.audioOnly;
227 240
             options.videoMuted = this.videoMuted;
241
+            options.userInfo = this.userInfo;
228 242
 
229 243
             return options;
230 244
         }
@@ -239,6 +253,7 @@ public class JitsiMeetConferenceOptions implements Parcelable {
239 253
         token = in.readString();
240 254
         colorScheme = in.readBundle();
241 255
         featureFlags = in.readBundle();
256
+        userInfo = new JitsiMeetUserInfo(in.readBundle());
242 257
         byte tmpAudioMuted = in.readByte();
243 258
         audioMuted = tmpAudioMuted == 0 ? null : tmpAudioMuted == 1;
244 259
         byte tmpAudioOnly = in.readByte();
@@ -294,6 +309,10 @@ public class JitsiMeetConferenceOptions implements Parcelable {
294 309
             urlProps.putString("jwt", token);
295 310
         }
296 311
 
312
+        if (token == null && userInfo != null) {
313
+            props.putBundle("userInfo", userInfo.asBundle());
314
+        }
315
+
297 316
         urlProps.putBundle("config", config);
298 317
         props.putBundle("url", urlProps);
299 318
 
@@ -322,6 +341,7 @@ public class JitsiMeetConferenceOptions implements Parcelable {
322 341
         dest.writeString(token);
323 342
         dest.writeBundle(colorScheme);
324 343
         dest.writeBundle(featureFlags);
344
+        dest.writeBundle(userInfo.asBundle());
325 345
         dest.writeByte((byte) (audioMuted == null ? 0 : audioMuted ? 1 : 2));
326 346
         dest.writeByte((byte) (audioOnly == null ? 0 : audioOnly ? 1 : 2));
327 347
         dest.writeByte((byte) (videoMuted == null ? 0 : videoMuted ? 1 : 2));

+ 107
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetUserInfo.java ファイルの表示

@@ -0,0 +1,107 @@
1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package org.jitsi.meet.sdk;
18
+
19
+import android.os.Bundle;
20
+
21
+import java.net.MalformedURLException;
22
+import java.net.URL;
23
+
24
+/**
25
+ * This class represents user information to be passed to {@link JitsiMeetConferenceOptions} for
26
+ * identifying a user.
27
+ */
28
+public class JitsiMeetUserInfo {
29
+    /**
30
+     * User's display name.
31
+     */
32
+    private String displayName;
33
+
34
+    /**
35
+     * User's email address.
36
+     */
37
+    private String email;
38
+
39
+    /**
40
+     * User's avatar URL.
41
+     */
42
+    private URL avatar;
43
+
44
+    public JitsiMeetUserInfo() {}
45
+
46
+    public JitsiMeetUserInfo(Bundle b) {
47
+        super();
48
+
49
+        if (b.containsKey("displayName")) {
50
+            displayName = b.getString("displayName");
51
+        }
52
+
53
+        if (b.containsKey("email")) {
54
+            email = b.getString("email");
55
+        }
56
+
57
+        if (b.containsKey("avatarURL")) {
58
+            String avatarURL = b.getString("avatarURL");
59
+            try {
60
+                avatar = new URL(avatarURL);
61
+            } catch (MalformedURLException e) {
62
+            }
63
+        }
64
+    }
65
+
66
+    public String getDisplayName() {
67
+        return displayName;
68
+    }
69
+
70
+    public void setDisplayName(String displayName) {
71
+        this.displayName = displayName;
72
+    }
73
+
74
+    public String getEmail() {
75
+        return email;
76
+    }
77
+
78
+    public void setEmail(String email) {
79
+        this.email = email;
80
+    }
81
+
82
+    public URL getAvatar() {
83
+        return avatar;
84
+    }
85
+
86
+    public void setAvatar(URL avatar) {
87
+        this.avatar = avatar;
88
+    }
89
+
90
+    Bundle asBundle() {
91
+        Bundle b = new Bundle();
92
+
93
+        if (displayName != null) {
94
+            b.putString("displayName", displayName);
95
+        }
96
+
97
+        if (email != null) {
98
+            b.putString("email", email);
99
+        }
100
+
101
+        if (avatar != null) {
102
+            b.putString("avatarURL", avatar.toString());
103
+        }
104
+
105
+        return b;
106
+    }
107
+}

+ 10
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj ファイルの表示

@@ -42,6 +42,8 @@
42 42
 		C69EFA0E209A0F660027712B /* JMCallKitListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0B209A0F660027712B /* JMCallKitListener.swift */; };
43 43
 		C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425E204EF76800E062DD /* DragGestureController.swift */; };
44 44
 		C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
45
+		DE762DB422AFDE76000DEBD6 /* JitsiMeetUserInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DE762DB322AFDE76000DEBD6 /* JitsiMeetUserInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
46
+		DE762DB622AFDE8D000DEBD6 /* JitsiMeetUserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = DE762DB522AFDE8D000DEBD6 /* JitsiMeetUserInfo.m */; };
45 47
 		DEAD3226220C497000E93636 /* JitsiMeetConferenceOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
46 48
 		DEAD3227220C497000E93636 /* JitsiMeetConferenceOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */; };
47 49
 		DEAFA779229EAD520033A7FA /* RNRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = DEAFA778229EAD520033A7FA /* RNRootView.m */; };
@@ -94,6 +96,9 @@
94 96
 		C6A3425E204EF76800E062DD /* DragGestureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragGestureController.swift; sourceTree = "<group>"; };
95 97
 		C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPViewCoordinator.swift; sourceTree = "<group>"; };
96 98
 		C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetView+Private.h"; sourceTree = "<group>"; };
99
+		DE762DB322AFDE76000DEBD6 /* JitsiMeetUserInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JitsiMeetUserInfo.h; sourceTree = "<group>"; };
100
+		DE762DB522AFDE8D000DEBD6 /* JitsiMeetUserInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiMeetUserInfo.m; sourceTree = "<group>"; };
101
+		DE762DB722AFE166000DEBD6 /* JitsiMeetUserInfo+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetUserInfo+Private.h"; sourceTree = "<group>"; };
97 102
 		DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JitsiMeetConferenceOptions.h; sourceTree = "<group>"; };
98 103
 		DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiMeetConferenceOptions.m; sourceTree = "<group>"; };
99 104
 		DEAD3228220C734300E93636 /* JitsiMeetConferenceOptions+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetConferenceOptions+Private.h"; sourceTree = "<group>"; };
@@ -174,6 +179,9 @@
174 179
 				DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */,
175 180
 				DEAD3228220C734300E93636 /* JitsiMeetConferenceOptions+Private.h */,
176 181
 				DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */,
182
+				DE762DB322AFDE76000DEBD6 /* JitsiMeetUserInfo.h */,
183
+				DE762DB722AFE166000DEBD6 /* JitsiMeetUserInfo+Private.h */,
184
+				DE762DB522AFDE8D000DEBD6 /* JitsiMeetUserInfo.m */,
177 185
 				0B412F161EDEC65D00B1A0A6 /* JitsiMeetView.h */,
178 186
 				0B412F171EDEC65D00B1A0A6 /* JitsiMeetView.m */,
179 187
 				DEAFA777229EAD3B0033A7FA /* RNRootView.h */,
@@ -259,6 +267,7 @@
259 267
 			isa = PBXHeadersBuildPhase;
260 268
 			buildActionMask = 2147483647;
261 269
 			files = (
270
+				DE762DB422AFDE76000DEBD6 /* JitsiMeetUserInfo.h in Headers */,
262 271
 				0B412F181EDEC65D00B1A0A6 /* JitsiMeetView.h in Headers */,
263 272
 				0B93EF7E1EC9DDCD0030D24D /* RCTBridgeWrapper.h in Headers */,
264 273
 				0B412F221EDEF6EA00B1A0A6 /* JitsiMeetViewDelegate.h in Headers */,
@@ -484,6 +493,7 @@
484 493
 				0BB9AD7B1F5EC8F4001C08DB /* CallKit.m in Sources */,
485 494
 				0BB9AD7D1F60356D001C08DB /* AppInfo.m in Sources */,
486 495
 				DEAFA779229EAD520033A7FA /* RNRootView.m in Sources */,
496
+				DE762DB622AFDE8D000DEBD6 /* JitsiMeetUserInfo.m in Sources */,
487 497
 				DEAD3227220C497000E93636 /* JitsiMeetConferenceOptions.m in Sources */,
488 498
 				0B93EF7F1EC9DDCD0030D24D /* RCTBridgeWrapper.m in Sources */,
489 499
 				0BA13D311EE83FF8007BEF7F /* ExternalAPI.m in Sources */,

+ 10
- 0
ios/sdk/src/JitsiMeetConferenceOptions.h ファイルの表示

@@ -16,6 +16,9 @@
16 16
 
17 17
 #import <Foundation/Foundation.h>
18 18
 
19
+#import "JitsiMeetUserInfo.h"
20
+
21
+
19 22
 @interface JitsiMeetConferenceOptionsBuilder : NSObject
20 23
 
21 24
 /**
@@ -60,6 +63,11 @@
60 63
  */
61 64
 @property (nonatomic) BOOL welcomePageEnabled;
62 65
 
66
+/**
67
+ * Information about the local user. It will be used in absence of a token.
68
+ */
69
+@property (nonatomic, nullable) JitsiMeetUserInfo *userInfo;
70
+
63 71
 - (void)setFeatureFlag:(NSString *_Nonnull)flag withBoolean:(BOOL)value;
64 72
 - (void)setFeatureFlag:(NSString *_Nonnull)flag withValue:(id _Nonnull)value;
65 73
 
@@ -82,6 +90,8 @@
82 90
 
83 91
 @property (nonatomic, readonly) BOOL welcomePageEnabled;
84 92
 
93
+@property (nonatomic, nullable) JitsiMeetUserInfo *userInfo;
94
+
85 95
 + (instancetype _Nonnull)fromBuilder:(void (^_Nonnull)(JitsiMeetConferenceOptionsBuilder *_Nonnull))initBlock;
86 96
 - (instancetype _Nonnull)init NS_UNAVAILABLE;
87 97
 

+ 9
- 0
ios/sdk/src/JitsiMeetConferenceOptions.m ファイルの表示

@@ -17,6 +17,7 @@
17 17
 #import <React/RCTUtils.h>
18 18
 
19 19
 #import "JitsiMeetConferenceOptions+Private.h"
20
+#import "JitsiMeetUserInfo+Private.h"
20 21
 
21 22
 /**
22 23
  * Backwards compatibility: turn the boolean property into a feature flag.
@@ -49,6 +50,8 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
49 50
         _audioOnly = nil;
50 51
         _audioMuted = nil;
51 52
         _videoMuted = nil;
53
+
54
+        _userInfo = nil;
52 55
     }
53 56
     
54 57
     return self;
@@ -163,6 +166,8 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
163 166
         _videoMuted = [builder getVideoMuted];
164 167
 
165 168
         _featureFlags = [NSDictionary dictionaryWithDictionary:builder.featureFlags];
169
+
170
+        _userInfo = builder.userInfo;
166 171
     }
167 172
 
168 173
     return self;
@@ -220,6 +225,10 @@ static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
220 225
         urlProps[@"jwt"] = _token;
221 226
     }
222 227
 
228
+    if (_token == nil && _userInfo != nil) {
229
+        props[@"userInfo"] = [self.userInfo asDict];
230
+    }
231
+
223 232
     urlProps[@"config"] = config;
224 233
     props[@"url"] = urlProps;
225 234
 

+ 23
- 0
ios/sdk/src/JitsiMeetUserInfo+Private.h ファイルの表示

@@ -0,0 +1,23 @@
1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import "JitsiMeetUserInfo.h"
18
+
19
+@interface JitsiMeetUserInfo ()
20
+
21
+- (NSMutableDictionary *)asDict;
22
+
23
+@end

+ 38
- 0
ios/sdk/src/JitsiMeetUserInfo.h ファイルの表示

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import <Foundation/Foundation.h>
18
+
19
+@interface JitsiMeetUserInfo : NSObject
20
+
21
+/**
22
+ * User display name.
23
+ */
24
+@property (nonatomic, copy, nullable) NSString *displayName;
25
+/**
26
+ * User e-mail.
27
+ */
28
+@property (nonatomic, copy, nullable) NSString *email;
29
+/**
30
+ * URL for the user avatar.
31
+ */
32
+@property (nonatomic, copy, nullable) NSURL *avatar;
33
+
34
+- (instancetype _Nullable)initWithDisplayName:(NSString *_Nullable)displayName
35
+                                     andEmail:(NSString *_Nullable)email
36
+                                    andAvatar:(NSURL *_Nullable) avatar;
37
+
38
+@end

+ 55
- 0
ios/sdk/src/JitsiMeetUserInfo.m ファイルの表示

@@ -0,0 +1,55 @@
1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import "JitsiMeetUserInfo+Private.h"
18
+
19
+@implementation JitsiMeetUserInfo
20
+
21
+- (instancetype)initWithDisplayName:(NSString *)displayName
22
+                           andEmail:(NSString *)email
23
+                          andAvatar:(NSURL *_Nullable) avatar {
24
+    self = [super init];
25
+    if (self) {
26
+        self.displayName = displayName;
27
+        self.email = email;
28
+        self.avatar = avatar;
29
+    }
30
+
31
+    return self;
32
+}
33
+
34
+- (NSDictionary *)asDict {
35
+    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
36
+
37
+    if (self.displayName != nil) {
38
+        dict[@"displayName"] = self.displayName;
39
+    }
40
+
41
+    if (self.email != nil) {
42
+        dict[@"email"] = self.email;
43
+    }
44
+
45
+    if (self.avatar != nil) {
46
+        NSString *avatarURL = [self.avatar absoluteString];
47
+        if (avatarURL != nil) {
48
+            dict[@"avatarURL"] = avatarURL;
49
+        }
50
+    }
51
+
52
+    return dict;
53
+}
54
+
55
+@end

+ 12
- 6
react/features/app/components/App.native.js ファイルの表示

@@ -13,6 +13,7 @@ import {
13 13
     AspectRatioDetector,
14 14
     ReducedUIDetector
15 15
 } from '../../base/responsive-ui';
16
+import { updateSettings } from '../../base/settings';
16 17
 import '../../google-api';
17 18
 import '../../mobile/audio-mode';
18 19
 import '../../mobile/background';
@@ -50,7 +51,12 @@ type Props = AbstractAppProps & {
50 51
     /**
51 52
      * An object with the feature flags.
52 53
      */
53
-    flags: Object
54
+    flags: Object,
55
+
56
+    /**
57
+     * An object with user information (display name, email, avatar URL).
58
+     */
59
+    userInfo: ?Object
54 60
 };
55 61
 
56 62
 /**
@@ -88,12 +94,12 @@ export class App extends AbstractApp {
88 94
         super.componentDidMount();
89 95
 
90 96
         this._init.then(() => {
91
-            // We set the color scheme early enough so then we avoid any
92
-            // unnecessary re-renders.
93
-            this.state.store.dispatch(setColorScheme(this.props.colorScheme));
97
+            // We set these early enough so then we avoid any unnecessary re-renders.
98
+            const { dispatch } = this.state.store;
94 99
 
95
-            // Ditto for feature flags.
96
-            this.state.store.dispatch(updateFlags(this.props.flags));
100
+            dispatch(setColorScheme(this.props.colorScheme));
101
+            dispatch(updateFlags(this.props.flags));
102
+            dispatch(updateSettings(this.props.userInfo || {}));
97 103
         });
98 104
     }
99 105
 

読み込み中…
キャンセル
保存