"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7315/ios/sdk/src/JitsiMeet.m" (2 Jun 2023, 8310 Bytes) of package /linux/misc/jitsi-meet-7315.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. See also the last Fossies "Diffs" side-by-side code changes report for "JitsiMeet.m": jitsi-meet_8319_vs_jitsi-meet_8615.

    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 <Intents/Intents.h>
   18 
   19 #import "Orientation.h"
   20 
   21 #import "JitsiMeet+Private.h"
   22 #import "JitsiMeetConferenceOptions+Private.h"
   23 #import "JitsiMeetView+Private.h"
   24 #import "RCTBridgeWrapper.h"
   25 #import "ReactUtils.h"
   26 #import "RNSplashScreen.h"
   27 #import "ScheenshareEventEmiter.h"
   28 
   29 #import <react-native-webrtc/WebRTCModuleOptions.h>
   30 
   31 #if !defined(JITSI_MEET_SDK_LITE)
   32 #import <RNGoogleSignin/RNGoogleSignin.h>
   33 #import "Dropbox.h"
   34 #endif
   35 
   36 @implementation JitsiMeet {
   37     RCTBridgeWrapper *_bridgeWrapper;
   38     NSDictionary *_launchOptions;
   39     ScheenshareEventEmiter *_screenshareEventEmiter;
   40 }
   41 
   42 #pragma mak - This class is a singleton
   43 
   44 + (instancetype)sharedInstance {
   45     static JitsiMeet *sharedInstance = nil;
   46     static dispatch_once_t onceToken;
   47 
   48     dispatch_once(&onceToken, ^{
   49         sharedInstance = [[self alloc] init];
   50     });
   51 
   52     return sharedInstance;
   53 }
   54 
   55 - (instancetype)init {
   56     if (self = [super init]) {
   57 #if 0
   58         // Initialize WebRTC options.
   59         WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
   60         options.loggingSeverity = RTCLoggingSeverityInfo;
   61 #endif
   62 
   63         // Initialize the one and only bridge for interfacing with React Native.
   64         _bridgeWrapper = [[RCTBridgeWrapper alloc] init];
   65         
   66         // Initialize the listener for handling start/stop screensharing notifications.
   67         _screenshareEventEmiter = [[ScheenshareEventEmiter alloc] init];
   68 
   69         // Register a fatal error handler for React.
   70         registerReactFatalErrorHandler();
   71 
   72         // Register a log handler for React.
   73         registerReactLogHandler();
   74     }
   75 
   76     return self;
   77 }
   78 
   79 #pragma mark - Methods that the App delegate must call
   80 
   81 -             (BOOL)application:(UIApplication *)application
   82   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   83 
   84     _launchOptions = [launchOptions copy];
   85 
   86 #if !defined(JITSI_MEET_SDK_LITE)
   87     [Dropbox setAppKey];
   88 #endif
   89 
   90     return YES;
   91 }
   92 
   93 -    (BOOL)application:(UIApplication *)application
   94   continueUserActivity:(NSUserActivity *)userActivity
   95     restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *))restorationHandler {
   96 
   97     JitsiMeetConferenceOptions *options = [self optionsFromUserActivity:userActivity];
   98     if (options) {
   99         [JitsiMeetView updateProps:[options asProps]];
  100         return true;
  101     }
  102 
  103     return false;
  104 }
  105 
  106 - (BOOL)application:(UIApplication *)app
  107             openURL:(NSURL *)url
  108             options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  109 
  110 #if !defined(JITSI_MEET_SDK_LITE)
  111     if ([Dropbox application:app openURL:url options:options]) {
  112         return YES;
  113     }
  114 
  115     if ([RNGoogleSignin application:app
  116                             openURL:url
  117                             options:options]) {
  118         return YES;
  119     }
  120 #endif
  121 
  122     if (_customUrlScheme == nil || ![_customUrlScheme isEqualToString:url.scheme]) {
  123         return NO;
  124     }
  125 
  126     JitsiMeetConferenceOptions *conferenceOptions = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
  127         builder.room = [url absoluteString];
  128     }];
  129     [JitsiMeetView updateProps:[conferenceOptions asProps]];
  130 
  131     return true;
  132 }
  133 
  134 - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
  135     return [Orientation getOrientation];
  136 }
  137 
  138 #pragma mark - Utility methods
  139 
  140 - (void)instantiateReactNativeBridge {
  141     if (_bridgeWrapper != nil) {
  142         return;
  143     };
  144     
  145     _bridgeWrapper = [[RCTBridgeWrapper alloc] init];
  146 }
  147 
  148 - (void)destroyReactNativeBridge {
  149     [_bridgeWrapper invalidate];
  150     _bridgeWrapper = nil;
  151 }
  152 
  153 - (JitsiMeetConferenceOptions *)getInitialConferenceOptions {
  154     if (_launchOptions[UIApplicationLaunchOptionsURLKey]) {
  155         NSURL *url = _launchOptions[UIApplicationLaunchOptionsURLKey];
  156         return [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
  157             builder.room = [url absoluteString];
  158         }];
  159     } else {
  160         NSDictionary *userActivityDictionary
  161             = _launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
  162         NSUserActivity *userActivity
  163             = [userActivityDictionary objectForKey:@"UIApplicationLaunchOptionsUserActivityKey"];
  164         if (userActivity != nil) {
  165             return [self optionsFromUserActivity:userActivity];
  166         }
  167     }
  168 
  169     return nil;
  170 }
  171 
  172 - (BOOL)isCrashReportingDisabled {
  173     NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"jitsi-default-preferences"];
  174     return [userDefaults stringForKey:@"isCrashReportingDisabled"];
  175 }
  176 
  177 - (JitsiMeetConferenceOptions *)optionsFromUserActivity:(NSUserActivity *)userActivity {
  178     NSString *activityType = userActivity.activityType;
  179 
  180     if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
  181         // App was started by opening a URL in the browser
  182         NSURL *url = userActivity.webpageURL;
  183         if ([_universalLinkDomains containsObject:url.host]) {
  184             return [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
  185                 builder.room = [url absoluteString];
  186             }];
  187         }
  188     } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
  189                || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
  190         // App was started by a CallKit Intent
  191         INIntent *intent = userActivity.interaction.intent;
  192         NSArray<INPerson *> *contacts;
  193         NSString *url;
  194         BOOL audioOnly = NO;
  195 
  196         if ([intent isKindOfClass:[INStartAudioCallIntent class]]) {
  197             contacts = ((INStartAudioCallIntent *) intent).contacts;
  198             audioOnly = YES;
  199         } else if ([intent isKindOfClass:[INStartVideoCallIntent class]]) {
  200             contacts = ((INStartVideoCallIntent *) intent).contacts;
  201         }
  202 
  203         if (contacts && (url = contacts.firstObject.personHandle.value)) {
  204             return [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
  205                 builder.audioOnly = audioOnly;
  206                 builder.room = url;
  207             }];
  208         }
  209     } else if (self.conferenceActivityType && [activityType isEqualToString:self.conferenceActivityType]) {
  210         // App was started by continuing a registered NSUserActivity (SiriKit, Handoff, ...)
  211         NSString *url;
  212 
  213         if ((url = userActivity.userInfo[@"url"])) {
  214             return [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
  215                 builder.room = url;
  216             }];
  217         }
  218     }
  219 
  220     return nil;
  221 }
  222 
  223 - (void)showSplashScreen:(UIView*)rootView {
  224     [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];
  225 }
  226 
  227 #pragma mark - Property getter / setters
  228 
  229 - (NSArray<NSString *> *)universalLinkDomains {
  230     return _universalLinkDomains ? _universalLinkDomains : @[];
  231 }
  232 
  233 - (void)setDefaultConferenceOptions:(JitsiMeetConferenceOptions *)defaultConferenceOptions {
  234     if (defaultConferenceOptions != nil && _defaultConferenceOptions.room != nil) {
  235         @throw [NSException exceptionWithName:@"RuntimeError"
  236                                        reason:@"'room' must be null in the default conference options"
  237                                      userInfo:nil];
  238     }
  239     _defaultConferenceOptions = defaultConferenceOptions;
  240 }
  241 
  242 #pragma mark - Private API methods
  243 
  244 - (NSDictionary *)getDefaultProps {
  245     return _defaultConferenceOptions == nil ? @{} : [_defaultConferenceOptions asProps];
  246 }
  247 
  248 - (RCTBridge *)getReactBridge {
  249     return _bridgeWrapper.bridge;
  250 }
  251 
  252 - (ExternalAPI *)getExternalAPI {
  253     return [_bridgeWrapper.bridge moduleForClass:ExternalAPI.class];
  254 }
  255 
  256 @end