Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

JitsiMeetConferenceOptions.m 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. #import <React/RCTUtils.h>
  17. #import "JitsiMeetConferenceOptions+Private.h"
  18. #import "JitsiMeetUserInfo+Private.h"
  19. /**
  20. * Backwards compatibility: turn the boolean property into a feature flag.
  21. */
  22. static NSString *const WelcomePageEnabledFeatureFlag = @"welcomepage.enabled";
  23. @implementation JitsiMeetConferenceOptionsBuilder {
  24. NSNumber *_audioOnly;
  25. NSNumber *_audioMuted;
  26. NSNumber *_videoMuted;
  27. NSMutableDictionary *_featureFlags;
  28. }
  29. @dynamic audioOnly;
  30. @dynamic audioMuted;
  31. @dynamic videoMuted;
  32. @dynamic welcomePageEnabled;
  33. - (instancetype)init {
  34. if (self = [super init]) {
  35. _serverURL = nil;
  36. _room = nil;
  37. _subject = nil;
  38. _token = nil;
  39. _colorScheme = nil;
  40. _featureFlags = [[NSMutableDictionary alloc] init];
  41. _audioOnly = nil;
  42. _audioMuted = nil;
  43. _videoMuted = nil;
  44. _userInfo = nil;
  45. _callHandle = nil;
  46. _callUUID = nil;
  47. }
  48. return self;
  49. }
  50. - (void)setFeatureFlag:(NSString *)flag withBoolean:(BOOL)value {
  51. [self setFeatureFlag:flag withValue:[NSNumber numberWithBool:value]];
  52. }
  53. - (void)setFeatureFlag:(NSString *)flag withValue:(id)value {
  54. _featureFlags[flag] = value;
  55. }
  56. #pragma mark - Dynamic properties
  57. - (void)setAudioOnly:(BOOL)audioOnly {
  58. _audioOnly = [NSNumber numberWithBool:audioOnly];
  59. }
  60. - (BOOL)audioOnly {
  61. return _audioOnly && [_audioOnly boolValue];
  62. }
  63. - (void)setAudioMuted:(BOOL)audioMuted {
  64. _audioMuted = [NSNumber numberWithBool:audioMuted];
  65. }
  66. - (BOOL)audioMuted {
  67. return _audioMuted && [_audioMuted boolValue];
  68. }
  69. - (void)setVideoMuted:(BOOL)videoMuted {
  70. _videoMuted = [NSNumber numberWithBool:videoMuted];
  71. }
  72. - (BOOL)videoMuted {
  73. return _videoMuted && [_videoMuted boolValue];
  74. }
  75. - (void)setWelcomePageEnabled:(BOOL)welcomePageEnabled {
  76. [self setFeatureFlag:WelcomePageEnabledFeatureFlag
  77. withBoolean:welcomePageEnabled];
  78. }
  79. - (BOOL)welcomePageEnabled {
  80. NSNumber *n = _featureFlags[WelcomePageEnabledFeatureFlag];
  81. return n != nil ? [n boolValue] : NO;
  82. }
  83. #pragma mark - Private API
  84. - (NSNumber *)getAudioOnly {
  85. return _audioOnly;
  86. }
  87. - (NSNumber *)getAudioMuted {
  88. return _audioMuted;
  89. }
  90. - (NSNumber *)getVideoMuted {
  91. return _videoMuted;
  92. }
  93. @end
  94. @implementation JitsiMeetConferenceOptions {
  95. NSNumber *_audioOnly;
  96. NSNumber *_audioMuted;
  97. NSNumber *_videoMuted;
  98. NSDictionary *_featureFlags;
  99. }
  100. @dynamic audioOnly;
  101. @dynamic audioMuted;
  102. @dynamic videoMuted;
  103. @dynamic welcomePageEnabled;
  104. #pragma mark - Dynamic properties
  105. - (BOOL)audioOnly {
  106. return _audioOnly && [_audioOnly boolValue];
  107. }
  108. - (BOOL)audioMuted {
  109. return _audioMuted && [_audioMuted boolValue];
  110. }
  111. - (BOOL)videoMuted {
  112. return _videoMuted && [_videoMuted boolValue];
  113. }
  114. - (BOOL)welcomePageEnabled {
  115. NSNumber *n = _featureFlags[WelcomePageEnabledFeatureFlag];
  116. return n != nil ? [n boolValue] : NO;
  117. }
  118. #pragma mark - Internal initializer
  119. - (instancetype)initWithBuilder:(JitsiMeetConferenceOptionsBuilder *)builder {
  120. if (self = [super init]) {
  121. _serverURL = builder.serverURL;
  122. _room = builder.room;
  123. _subject = builder.subject;
  124. _token = builder.token;
  125. _colorScheme = builder.colorScheme;
  126. _audioOnly = [builder getAudioOnly];
  127. _audioMuted = [builder getAudioMuted];
  128. _videoMuted = [builder getVideoMuted];
  129. _featureFlags = [NSDictionary dictionaryWithDictionary:builder.featureFlags];
  130. _userInfo = builder.userInfo;
  131. _callHandle = builder.callHandle;
  132. _callUUID = builder.callUUID;
  133. }
  134. return self;
  135. }
  136. #pragma mark - API
  137. + (instancetype)fromBuilder:(void (^)(JitsiMeetConferenceOptionsBuilder *))initBlock {
  138. JitsiMeetConferenceOptionsBuilder *builder = [[JitsiMeetConferenceOptionsBuilder alloc] init];
  139. initBlock(builder);
  140. return [[JitsiMeetConferenceOptions alloc] initWithBuilder:builder];
  141. }
  142. #pragma mark - Private API
  143. - (NSDictionary *)asProps {
  144. NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
  145. props[@"flags"] = [NSMutableDictionary dictionaryWithDictionary:_featureFlags];
  146. if (_colorScheme != nil) {
  147. props[@"colorScheme"] = self.colorScheme;
  148. }
  149. NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
  150. if (_audioOnly != nil) {
  151. config[@"startAudioOnly"] = @(self.audioOnly);
  152. }
  153. if (_audioMuted != nil) {
  154. config[@"startWithAudioMuted"] = @(self.audioMuted);
  155. }
  156. if (_videoMuted != nil) {
  157. config[@"startWithVideoMuted"] = @(self.videoMuted);
  158. }
  159. if (_subject != nil) {
  160. config[@"subject"] = self.subject;
  161. }
  162. if (_callHandle != nil) {
  163. config[@"callHandle"] = self.callHandle;
  164. }
  165. if (_callUUID != nil) {
  166. config[@"callUUID"] = [self.callUUID UUIDString];
  167. }
  168. NSMutableDictionary *urlProps = [[NSMutableDictionary alloc] init];
  169. // The room is fully qualified.
  170. if (_room != nil && [_room containsString:@"://"]) {
  171. urlProps[@"url"] = _room;
  172. } else {
  173. if (_serverURL != nil) {
  174. urlProps[@"serverURL"] = [_serverURL absoluteString];
  175. }
  176. if (_room != nil) {
  177. urlProps[@"room"] = _room;
  178. }
  179. }
  180. if (_token != nil) {
  181. urlProps[@"jwt"] = _token;
  182. }
  183. if (_userInfo != nil) {
  184. props[@"userInfo"] = [self.userInfo asDict];
  185. }
  186. urlProps[@"config"] = config;
  187. props[@"url"] = urlProps;
  188. return props;
  189. }
  190. @end