You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Invite.m 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright @ 2018-present Atlassian Pty Ltd
  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 "Invite+Private.h"
  17. #import "InviteController+Private.h"
  18. #import "JitsiMeetView+Private.h"
  19. // The events emitted/supported by the Invite react-native module:
  20. //
  21. // XXX The event names are ridiculous on purpose. Even though iOS makes it look
  22. // like it emits within the bounderies of a react-native module ony, it actually
  23. // also emits through DeviceEventEmitter. (Of course, Android emits only through
  24. // DeviceEventEmitter.)
  25. static NSString * const InviteEmitterEvent
  26. = @"org.jitsi.meet:features/invite#invite";
  27. static NSString * const PerformQueryEmitterEvent
  28. = @"org.jitsi.meet:features/invite#performQuery";
  29. @implementation Invite
  30. RCT_EXPORT_MODULE();
  31. - (NSArray<NSString *> *)supportedEvents {
  32. return @[
  33. InviteEmitterEvent,
  34. PerformQueryEmitterEvent
  35. ];
  36. }
  37. /**
  38. * Calls the corresponding JitsiMeetView's delegate to request that the native
  39. * invite search be presented.
  40. *
  41. * @param scope
  42. */
  43. RCT_EXPORT_METHOD(beginAddPeople:(NSString *)externalAPIScope) {
  44. JitsiMeetView *view = [JitsiMeetView viewForExternalAPIScope:externalAPIScope];
  45. InviteController *controller = view.inviteController;
  46. [controller beginAddPeople];
  47. }
  48. RCT_EXPORT_METHOD(inviteSettled:(NSString *)externalAPIScope
  49. addPeopleControllerScope:(NSString *)addPeopleControllerScope
  50. failedInvitees:(NSArray *)failedInvitees) {
  51. JitsiMeetView *view = [JitsiMeetView viewForExternalAPIScope:externalAPIScope];
  52. InviteController *controller = view.inviteController;
  53. [controller inviteSettled:addPeopleControllerScope failedInvitees:failedInvitees];
  54. }
  55. RCT_EXPORT_METHOD(receivedResults:(NSString *)externalAPIScope
  56. addPeopleControllerScope:(NSString *)addPeopleControllerScope
  57. query:(NSString *)query
  58. results:(NSArray *)results) {
  59. JitsiMeetView *view = [JitsiMeetView viewForExternalAPIScope:externalAPIScope];
  60. InviteController *controller = view.inviteController;
  61. [controller receivedResults:addPeopleControllerScope query:query results:results];
  62. }
  63. - (void) invite:(NSArray<NSDictionary *> * _Nonnull)invitees
  64. externalAPIScope:(NSString * _Nonnull)externalAPIScope
  65. addPeopleControllerScope:(NSString * _Nonnull) addPeopleControllerScope {
  66. [self sendEventWithName:InviteEmitterEvent
  67. body:@{ @"addPeopleControllerScope": addPeopleControllerScope,
  68. @"externalAPIScope": externalAPIScope,
  69. @"invitees": invitees }];
  70. }
  71. - (void) performQuery:(NSString * _Nonnull)query
  72. externalAPIScope:(NSString * _Nonnull)externalAPIScope
  73. addPeopleControllerScope:(NSString * _Nonnull) addPeopleControllerScope {
  74. [self sendEventWithName:PerformQueryEmitterEvent
  75. body:@{ @"addPeopleControllerScope": addPeopleControllerScope,
  76. @"externalAPIScope": externalAPIScope,
  77. @"query": query }];
  78. }
  79. @end