Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Invite.m 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. /**
  32. * Make sure all methods in this module are invoked on the main/UI thread.
  33. */
  34. - (dispatch_queue_t)methodQueue {
  35. return dispatch_get_main_queue();
  36. }
  37. - (NSArray<NSString *> *)supportedEvents {
  38. return @[
  39. InviteEmitterEvent,
  40. PerformQueryEmitterEvent
  41. ];
  42. }
  43. /**
  44. * Initiates the process to add people. This involves calling a delegate method
  45. * in the JMInviteControllerDelegate so the native host application can start
  46. * the query process.
  47. *
  48. * @param externalAPIScope - Scope identifying the JitsiMeetView where the
  49. * calling JS code is being executed.
  50. */
  51. RCT_EXPORT_METHOD(beginAddPeople:(NSString *)externalAPIScope) {
  52. JitsiMeetView *view
  53. = [JitsiMeetView viewForExternalAPIScope:externalAPIScope];
  54. JMInviteController *inviteController = view.inviteController;
  55. [inviteController beginAddPeople];
  56. }
  57. /**
  58. * Indicates the the invite process has settled / finished.
  59. *
  60. * @param externalAPIScope - Scope identifying the JitsiMeetView where the
  61. * calling JS code is being executed.
  62. * @param addPeopleControllerScope - Scope identifying the JMAddPeopleController
  63. * wich was settled.
  64. * @param failedInvitees - Array with the invitees which were not invited due
  65. * to a failure.
  66. */
  67. RCT_EXPORT_METHOD(inviteSettled:(NSString *)externalAPIScope
  68. addPeopleControllerScope:(NSString *)addPeopleControllerScope
  69. failedInvitees:(NSArray *)failedInvitees) {
  70. JitsiMeetView *view
  71. = [JitsiMeetView viewForExternalAPIScope:externalAPIScope];
  72. JMInviteController *inviteController = view.inviteController;
  73. [inviteController inviteSettled:addPeopleControllerScope
  74. failedInvitees:failedInvitees];
  75. }
  76. /**
  77. * Process results received for the given query. This involves calling a
  78. * delegate method in JMAddPeopleControllerDelegate so the native host
  79. * application is made aware of the query results.
  80. *
  81. * @param externalAPIScope - Scope identifying the JitsiMeetView where the
  82. * calling JS code is being executed.
  83. * @param addPeopleControllerScope - Scope identifying the JMAddPeopleController
  84. * for which the results were received.
  85. * @param query - The actual query for which the results were received.
  86. * @param results - The query results.
  87. */
  88. RCT_EXPORT_METHOD(receivedResults:(NSString *)externalAPIScope
  89. addPeopleControllerScope:(NSString *)addPeopleControllerScope
  90. query:(NSString *)query
  91. results:(NSArray *)results) {
  92. JitsiMeetView *view
  93. = [JitsiMeetView viewForExternalAPIScope:externalAPIScope];
  94. JMInviteController *inviteController = view.inviteController;
  95. [inviteController receivedResults:addPeopleControllerScope
  96. query:query
  97. results:results];
  98. }
  99. - (void) invite:(NSArray<NSDictionary *> * _Nonnull)invitees
  100. externalAPIScope:(NSString * _Nonnull)externalAPIScope
  101. addPeopleControllerScope:(NSString * _Nonnull) addPeopleControllerScope {
  102. [self sendEventWithName:InviteEmitterEvent
  103. body:@{ @"addPeopleControllerScope": addPeopleControllerScope,
  104. @"externalAPIScope": externalAPIScope,
  105. @"invitees": invitees }];
  106. }
  107. - (void) performQuery:(NSString * _Nonnull)query
  108. externalAPIScope:(NSString * _Nonnull)externalAPIScope
  109. addPeopleControllerScope:(NSString * _Nonnull) addPeopleControllerScope {
  110. [self sendEventWithName:PerformQueryEmitterEvent
  111. body:@{ @"addPeopleControllerScope": addPeopleControllerScope,
  112. @"externalAPIScope": externalAPIScope,
  113. @"query": query }];
  114. }
  115. @end