"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-6444/ios/sdk/src/JitsiMeetConferenceOptions.m" (8 Aug 2022, 4351 Bytes) of package /linux/misc/jitsi-meet-6444.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 @implementation JitsiMeetConferenceOptionsBuilder {
   23     NSMutableDictionary *_featureFlags;
   24     NSMutableDictionary *_config;
   25 }
   26 
   27 - (instancetype)init {
   28     if (self = [super init]) {
   29         _serverURL = nil;
   30         _room = nil;
   31         _token = nil;
   32 
   33         _config = [[NSMutableDictionary alloc] init];
   34         _featureFlags = [[NSMutableDictionary alloc] init];
   35 
   36         _userInfo = nil;
   37     }
   38     
   39     return self;
   40 }
   41 
   42 - (void)setFeatureFlag:(NSString *)flag withBoolean:(BOOL)value {
   43     [self setFeatureFlag:flag withValue:[NSNumber numberWithBool:value]];
   44 }
   45 
   46 - (void)setFeatureFlag:(NSString *)flag withValue:(id)value {
   47     _featureFlags[flag] = value;
   48 }
   49 
   50 - (void)setAudioOnly:(BOOL)audioOnly {
   51     [self setConfigOverride:@"startAudioOnly" withBoolean:audioOnly];
   52 }
   53 
   54 - (void)setAudioMuted:(BOOL)audioMuted {
   55     [self setConfigOverride:@"startWithAudioMuted" withBoolean:audioMuted];
   56 }
   57 
   58 - (void)setVideoMuted:(BOOL)videoMuted {
   59     [self setConfigOverride:@"startWithVideoMuted" withBoolean:videoMuted];
   60 }
   61 
   62 - (void)setCallHandle:(NSString *_Nonnull)callHandle {
   63     [self setConfigOverride:@"callHandle" withValue:callHandle];
   64 }
   65 
   66 - (void)setCallUUID:(NSUUID *_Nonnull)callUUID {
   67     [self setConfigOverride:@"callUUID" withValue:[callUUID UUIDString]];
   68 }
   69 
   70 - (void)setSubject:(NSString *_Nonnull)subject {
   71     [self setConfigOverride:@"subject" withValue:subject];
   72 }
   73 
   74 - (void)setConfigOverride:(NSString *_Nonnull)config withBoolean:(BOOL)value {
   75     [self setConfigOverride:config withValue:[NSNumber numberWithBool:value]];
   76 }
   77 
   78 - (void)setConfigOverride:(NSString *_Nonnull)config withDictionary:(NSDictionary*)dictionary {
   79     _config[config] = dictionary;
   80 }
   81 
   82 - (void)setConfigOverride:(NSString *_Nonnull)config withArray:( NSArray * _Nonnull)array {
   83     _config[config] = array;
   84 }
   85 
   86 - (void)setConfigOverride:(NSString *_Nonnull)config withValue:(id _Nonnull)value {
   87     _config[config] = value;
   88 }
   89 
   90 @end
   91 
   92 @implementation JitsiMeetConferenceOptions {
   93     NSDictionary *_featureFlags;
   94     NSDictionary *_config;
   95 }
   96 
   97 #pragma mark - Internal initializer
   98 
   99 - (instancetype)initWithBuilder:(JitsiMeetConferenceOptionsBuilder *)builder {
  100     if (self = [super init]) {
  101         _serverURL = builder.serverURL;
  102         _room = builder.room;
  103         _token = builder.token;
  104 
  105         _config = builder.config;
  106 
  107         _featureFlags = [NSDictionary dictionaryWithDictionary:builder.featureFlags];
  108 
  109         _userInfo = builder.userInfo;
  110     }
  111 
  112     return self;
  113 }
  114 
  115 #pragma mark - API
  116 
  117 + (instancetype)fromBuilder:(void (^)(JitsiMeetConferenceOptionsBuilder *))initBlock {
  118     JitsiMeetConferenceOptionsBuilder *builder = [[JitsiMeetConferenceOptionsBuilder alloc] init];
  119     initBlock(builder);
  120     return [[JitsiMeetConferenceOptions alloc] initWithBuilder:builder];
  121 }
  122 
  123 #pragma mark - Private API
  124 
  125 - (NSDictionary *)asProps {
  126     NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
  127 
  128     props[@"flags"] = [NSMutableDictionary dictionaryWithDictionary:_featureFlags];
  129 
  130     NSMutableDictionary *urlProps = [[NSMutableDictionary alloc] init];
  131 
  132     // The room is fully qualified.
  133     if (_room != nil && [_room containsString:@"://"]) {
  134         urlProps[@"url"] = _room;
  135     } else {
  136         if (_serverURL != nil) {
  137             urlProps[@"serverURL"] = [_serverURL absoluteString];
  138         }
  139 
  140         if (_room != nil) {
  141             urlProps[@"room"] = _room;
  142         }
  143     }
  144 
  145     if (_token != nil) {
  146         urlProps[@"jwt"] = _token;
  147     }
  148 
  149     if (_userInfo != nil) {
  150         props[@"userInfo"] = [self.userInfo asDict];
  151     }
  152 
  153     urlProps[@"config"] = _config;
  154     props[@"url"] = urlProps;
  155 
  156     return props;
  157 }
  158 
  159 @end