"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-6444/ios/sdk/src/JitsiMeetView.m" (8 Aug 2022, 4894 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 @ 2018-present 8x8, Inc.
    3  * Copyright @ 2017-2018 Atlassian Pty Ltd
    4  *
    5  * Licensed under the Apache License, Version 2.0 (the "License");
    6  * you may not use this file except in compliance with the License.
    7  * You may obtain a copy of the License at
    8  *
    9  *     http://www.apache.org/licenses/LICENSE-2.0
   10  *
   11  * Unless required by applicable law or agreed to in writing, software
   12  * distributed under the License is distributed on an "AS IS" BASIS,
   13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14  * See the License for the specific language governing permissions and
   15  * limitations under the License.
   16  */
   17 
   18 #include <mach/mach_time.h>
   19 
   20 #import "ExternalAPI.h"
   21 #import "JitsiMeet+Private.h"
   22 #import "JitsiMeetConferenceOptions+Private.h"
   23 #import "JitsiMeetView.h"
   24 #import "JitsiMeetViewController.h"
   25 #import "ReactUtils.h"
   26 #import "RNRootView.h"
   27 
   28 @interface JitsiMeetView ()
   29 
   30 @property (nonatomic, strong) JitsiMeetViewController *jitsiMeetViewController;
   31 @property (nonatomic, strong) UINavigationController *navController;
   32 @property (nonatomic, readonly) BOOL isPiPEnabled;
   33 
   34 @end
   35 
   36 @implementation JitsiMeetView
   37 
   38 @dynamic isPiPEnabled;
   39 
   40 #pragma mark Initializers
   41 
   42 - (instancetype)init {
   43     self = [super init];
   44     if (self) {
   45         [self initWithXXX];
   46     }
   47 
   48     return self;
   49 }
   50 
   51 - (instancetype)initWithCoder:(NSCoder *)coder {
   52     self = [super initWithCoder:coder];
   53     if (self) {
   54         [self initWithXXX];
   55     }
   56 
   57     return self;
   58 }
   59 
   60 - (instancetype)initWithFrame:(CGRect)frame {
   61     self = [super initWithFrame:frame];
   62     if (self) {
   63         [self initWithXXX];
   64     }
   65 
   66     return self;
   67 }
   68 
   69 - (void)dealloc {
   70     [[NSNotificationCenter defaultCenter] removeObserver:self];
   71 }
   72 
   73 /**
   74  * Internal initialization:
   75  *
   76  * - sets the background color
   77  * - initializes the external API scope
   78  */
   79 - (void)initWithXXX {
   80     self.jitsiMeetViewController = [[JitsiMeetViewController alloc] init];
   81     self.jitsiMeetViewController.view.frame = [self bounds];
   82     [self addSubview:self.jitsiMeetViewController.view];
   83     
   84     [self registerObservers];
   85 }
   86 
   87 #pragma mark API
   88 
   89 - (void)join:(JitsiMeetConferenceOptions *)options {
   90     [self.jitsiMeetViewController join:options withPiP:self.isPiPEnabled];
   91 }
   92 
   93 - (void)leave {
   94     [self.jitsiMeetViewController leave];
   95 }
   96 
   97 - (void)hangUp {
   98     [self.jitsiMeetViewController hangUp];
   99 }
  100 
  101 - (void)setAudioMuted:(BOOL)muted {
  102     [self.jitsiMeetViewController setAudioMuted:muted];
  103 }
  104 
  105 - (void)sendEndpointTextMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to {
  106     [self.jitsiMeetViewController sendEndpointTextMessage:message :to];
  107 }
  108 
  109 - (void)toggleScreenShare:(BOOL)enabled {
  110     [self.jitsiMeetViewController toggleScreenShare:enabled];
  111 }
  112 
  113 - (void)retrieveParticipantsInfo:(void (^ _Nonnull)(NSArray * _Nullable))completionHandler {
  114     [self.jitsiMeetViewController retrieveParticipantsInfo:completionHandler];
  115 }
  116 
  117 - (void)openChat:(NSString*)to  {
  118     [self.jitsiMeetViewController openChat:to];
  119 }
  120 
  121 - (void)closeChat  {
  122     [self.jitsiMeetViewController closeChat];
  123 }
  124 
  125 - (void)sendChatMessage:(NSString * _Nonnull)message :(NSString * _Nullable)to {
  126     [self.jitsiMeetViewController sendChatMessage:message :to];
  127 }
  128 
  129 - (void)setVideoMuted:(BOOL)muted {
  130     [self.jitsiMeetViewController setVideoMuted:muted];
  131 }
  132 
  133 - (void)setClosedCaptionsEnabled:(BOOL)enabled {
  134     ExternalAPI *externalAPI = [[JitsiMeet sharedInstance] getExternalAPI];
  135     [externalAPI sendSetClosedCaptionsEnabled:enabled];
  136 }
  137 
  138 #pragma mark Private
  139 
  140 - (BOOL)isPiPEnabled {
  141     return self.delegate && [self.delegate respondsToSelector:@selector(enterPictureInPicture:)];
  142 }
  143 
  144 - (void)registerObservers {
  145     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSendEventNotification:) name:sendEventNotificationName object:nil];
  146 }
  147 
  148 - (void)handleSendEventNotification:(NSNotification *)notification {
  149     NSString *eventName = notification.userInfo[@"name"];
  150     NSString *eventData = notification.userInfo[@"data"];
  151     
  152     SEL sel = NSSelectorFromString([self methodNameFromEventName:eventName]);
  153 
  154     if (sel && [self.delegate respondsToSelector:sel]) {
  155         [self.delegate performSelector:sel withObject:eventData];
  156     }
  157 }
  158 
  159 /**
  160  * Converts a specific event name i.e. redux action type description to a
  161  * method name.
  162  *
  163  * @param eventName The event name to convert to a method name.
  164  * @return A method name constructed from the specified `eventName`.
  165  */
  166 - (NSString *)methodNameFromEventName:(NSString *)eventName {
  167    NSMutableString *methodName
  168        = [NSMutableString stringWithCapacity:eventName.length];
  169 
  170    for (NSString *c in [eventName componentsSeparatedByString:@"_"]) {
  171        if (c.length) {
  172            [methodName appendString:
  173                methodName.length ? c.capitalizedString : c.lowercaseString];
  174        }
  175    }
  176    [methodName appendString:@":"];
  177 
  178    return methodName;
  179 }
  180 
  181 @end