"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-5187/ios/sdk/src/JitsiMeetConferenceOptions.m" (2 Aug 2021, 6094 Bytes) of package /linux/misc/jitsi-meet-5187.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Matlab source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

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