Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JitsiMeetConferenceOptions.m 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. @implementation JitsiMeetConferenceOptionsBuilder {
  19. NSNumber *_audioOnly;
  20. NSNumber *_audioMuted;
  21. NSNumber *_videoMuted;
  22. NSNumber *_welcomePageEnabled;
  23. }
  24. @dynamic audioOnly;
  25. @dynamic audioMuted;
  26. @dynamic videoMuted;
  27. @dynamic welcomePageEnabled;
  28. - (instancetype)init {
  29. if (self = [super init]) {
  30. _serverURL = nil;
  31. _room = nil;
  32. _token = nil;
  33. _colorScheme = nil;
  34. _audioOnly = nil;
  35. _audioMuted = nil;
  36. _videoMuted = nil;
  37. _welcomePageEnabled = nil;
  38. }
  39. return self;
  40. }
  41. #pragma mark - Dynamic properties
  42. - (void)setAudioOnly:(BOOL)audioOnly {
  43. _audioOnly = [NSNumber numberWithBool:audioOnly];
  44. }
  45. - (BOOL)audioOnly {
  46. return _audioOnly && [_audioOnly boolValue];
  47. }
  48. - (void)setAudioMuted:(BOOL)audioMuted {
  49. _audioMuted = [NSNumber numberWithBool:audioMuted];
  50. }
  51. - (BOOL)audioMuted {
  52. return _audioMuted && [_audioMuted boolValue];
  53. }
  54. - (void)setVideoMuted:(BOOL)videoMuted {
  55. _videoMuted = [NSNumber numberWithBool:videoMuted];
  56. }
  57. - (BOOL)videoMuted {
  58. return _videoMuted && [_videoMuted boolValue];
  59. }
  60. - (void)setWelcomePageEnabled:(BOOL)welcomePageEnabled {
  61. _welcomePageEnabled = [NSNumber numberWithBool:welcomePageEnabled];
  62. }
  63. - (BOOL)welcomePageEnabled {
  64. return _welcomePageEnabled && [_welcomePageEnabled boolValue];
  65. }
  66. #pragma mark - Private API
  67. - (NSNumber *)getAudioOnly {
  68. return _audioOnly;
  69. }
  70. - (NSNumber *)getAudioMuted {
  71. return _audioMuted;
  72. }
  73. - (NSNumber *)getVideoMuted {
  74. return _videoMuted;
  75. }
  76. - (NSNumber *)getWelcomePageEnabled {
  77. return _welcomePageEnabled;
  78. }
  79. @end
  80. @implementation JitsiMeetConferenceOptions {
  81. NSNumber *_audioOnly;
  82. NSNumber *_audioMuted;
  83. NSNumber *_videoMuted;
  84. NSNumber *_welcomePageEnabled;
  85. }
  86. @dynamic audioOnly;
  87. @dynamic audioMuted;
  88. @dynamic videoMuted;
  89. @dynamic welcomePageEnabled;
  90. #pragma mark - Dynamic properties
  91. - (BOOL)audioOnly {
  92. return _audioOnly && [_audioOnly boolValue];
  93. }
  94. - (BOOL)audioMuted {
  95. return _audioMuted && [_audioMuted boolValue];
  96. }
  97. - (BOOL)videoMuted {
  98. return _videoMuted && [_videoMuted boolValue];
  99. }
  100. - (BOOL)welcomePageEnabled {
  101. return _welcomePageEnabled && [_welcomePageEnabled boolValue];
  102. }
  103. #pragma mark - Internal initializer
  104. - (instancetype)initWithBuilder:(JitsiMeetConferenceOptionsBuilder *)builder {
  105. if (self = [super init]) {
  106. _serverURL = builder.serverURL;
  107. _room = builder.room;
  108. _token = builder.token;
  109. _colorScheme = builder.colorScheme;
  110. _audioOnly = [builder getAudioOnly];
  111. _audioMuted = [builder getAudioMuted];
  112. _videoMuted = [builder getVideoMuted];
  113. _welcomePageEnabled = [builder getWelcomePageEnabled];
  114. }
  115. return self;
  116. }
  117. #pragma mark - API
  118. + (instancetype)fromBuilder:(void (^)(JitsiMeetConferenceOptionsBuilder *))initBlock {
  119. JitsiMeetConferenceOptionsBuilder *builder = [[JitsiMeetConferenceOptionsBuilder alloc] init];
  120. initBlock(builder);
  121. return [[JitsiMeetConferenceOptions alloc] initWithBuilder:builder];
  122. }
  123. #pragma mark - Private API
  124. - (NSDictionary *)asProps {
  125. NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
  126. if (_colorScheme != nil) {
  127. props[@"colorScheme"] = self.colorScheme;
  128. }
  129. if (_welcomePageEnabled != nil) {
  130. props[@"welcomePageEnabled"] = @(self.welcomePageEnabled);
  131. }
  132. NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
  133. if (_audioOnly != nil) {
  134. config[@"startAudioOnly"] = @(self.audioOnly);
  135. }
  136. if (_audioMuted != nil) {
  137. config[@"startWithAudioMuted"] = @(self.audioMuted);
  138. }
  139. if (_videoMuted != nil) {
  140. config[@"startWithVideoMuted"] = @(self.videoMuted);
  141. }
  142. NSMutableDictionary *urlProps = [[NSMutableDictionary alloc] init];
  143. // The room is fully qualified.
  144. if (_room != nil && [_room containsString:@"://"]) {
  145. urlProps[@"url"] = _room;
  146. } else {
  147. if (_serverURL != nil) {
  148. urlProps[@"serverURL"] = [_serverURL absoluteString];
  149. }
  150. if (_room != nil) {
  151. urlProps[@"room"] = _room;
  152. }
  153. }
  154. if (_token != nil) {
  155. urlProps[@"jwt"] = _token;
  156. }
  157. urlProps[@"config"] = config;
  158. props[@"url"] = urlProps;
  159. return props;
  160. }
  161. @end