Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

JitsiMeetConferenceOptions.m 5.0KB

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