Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PushToTalk] Add new framework for Xcode 14 bet4. #15645

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,7 @@ IOS_FRAMEWORKS = \
Photos \
PhotosUI \
PushKit \
PushToTalk \
QuickLook \
QuickLookThumbnailing \
ReplayKit \
Expand Down
249 changes: 249 additions & 0 deletions src/pushtotalk.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
//
// PushToTalk C# bindings
//
// Authors:
// Manuel de la Pena Saenz <mandel@microsoft.com>
//
// Copyright 2022 Microsoft Corporation All rights reserved.
//

using System;

using AVFoundation;
using CoreFoundation;
using Foundation;
using ObjCRuntime;
using UIKit;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace PushToTalk {

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTChannelJoinReason : long {
DeveloperRequest = 0,
ChannelRestoration = 1,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTChannelLeaveReason : long {
Unknown = 0,
UserRequest = 1,
DeveloperRequest = 2,
SystemPolicy = 3,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTChannelTransmitRequestSource : long {
Unknown = 0,
UserRequest = 1,
DeveloperRequest = 2,
HandsfreeButton = 3,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTServiceStatus : long {
Ready,
Connecting,
Unavailable,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum PTTransmissionMode : long {
FullDuplex,
HalfDuplex,
ListenOnly,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
[ErrorDomain ("PTInstantiationErrorDomain")]
public enum PTInstantiationError : long
{
Unknown = 0,
InvalidPlatform = 1,
MissingBackgroundMode = 2,
MissingPushServerEnvironment = 3,
MissingEntitlement = 4,
InstantiationAlreadyInProgress = 5,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Native]
[ErrorDomain ("PTChannelErrorDomain")]
public enum PTChannelError : long
{
Unknown = 0,
ChannelNotFound = 1,
ChannelLimitReached = 2,
CallActive = 3,
TransmissionInProgress = 4,
TransmissionNotFound = 5,
AppNotForeground = 6,
DeviceManagementRestriction = 7,
ScreenTimeRestriction = 8,
TransmissionNotAllowed = 9,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTParticipant
{
[Export ("name")]
string Name { get; }

[NullAllowed, Export ("image", ArgumentSemantic.Copy)]
UIImage Image { get; }

[Export ("initWithName:image:")]
[DesignatedInitializer]
NativeHandle Constructor (string name, [NullAllowed] UIImage image);
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTPushResult
{
[Static]
[Export ("leaveChannelPushResult")]
PTPushResult LeaveChannelPushResult { get; }

[Static]
[Export ("pushResultForActiveRemoteParticipant:")]
PTPushResult Create (PTParticipant participant);
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTChannelDescriptor
{
[Export ("initWithName:image:")]
[DesignatedInitializer]
NativeHandle Constructor (string name, [NullAllowed] UIImage image);

[Export ("name")]
string Name { get; }

[NullAllowed, Export ("image", ArgumentSemantic.Copy)]
UIImage Image { get; }
}

interface IPTChannelManagerDelegate {}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Protocol]
[BaseType (typeof (NSObject))]
interface PTChannelManagerDelegate
{
[Abstract]
[Export ("channelManager:didJoinChannelWithUUID:reason:")]
void DidJoinChannel (PTChannelManager channelManager, NSUuid channelUuid, PTChannelJoinReason reason);

[Abstract]
[Export ("channelManager:didLeaveChannelWithUUID:reason:")]
void DidLeaveChannel (PTChannelManager channelManager, NSUuid channelUuid, PTChannelLeaveReason reason);

[Abstract]
[Export ("channelManager:channelUUID:didBeginTransmittingFromSource:")]
void DidBeginTransmitting (PTChannelManager channelManager, NSUuid channelUuid, PTChannelTransmitRequestSource source);

[Abstract]
[Export ("channelManager:channelUUID:didEndTransmittingFromSource:")]
void DidEndTransmitting (PTChannelManager channelManager, NSUuid channelUuid, PTChannelTransmitRequestSource source);

[Abstract]
[Export ("channelManager:receivedEphemeralPushToken:")]
void ReceivedEphemeralPushToken (PTChannelManager channelManager, NSData pushToken);

[Abstract]
[Export ("incomingPushResultForChannelManager:channelUUID:pushPayload:")]
PTPushResult IncomingPushResult (PTChannelManager channelManager, NSUuid channelUuid, NSDictionary<NSString, NSObject> pushPayload);

[NoMac]
[Abstract]
[Export ("channelManager:didActivateAudioSession:")]
void DidActivateAudioSession (PTChannelManager channelManager, AVAudioSession audioSession);

[NoMac]
[Abstract]
[Export ("channelManager:didDeactivateAudioSession:")]
void DidDeactivateAudioSession (PTChannelManager channelManager, AVAudioSession audioSession);

[Export ("channelManager:failedToJoinChannelWithUUID:error:")]
void FailedToJoinChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);

[Export ("channelManager:failedToLeaveChannelWithUUID:error:")]
void FailedToLeaveChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);

[Export ("channelManager:failedToBeginTransmittingInChannelWithUUID:error:")]
void FailedToBeginTransmittingInChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);

[Export ("channelManager:failedToStopTransmittingInChannelWithUUID:error:")]
void failedToStopTransmittingInChannel (PTChannelManager channelManager, NSUuid channelUuid, NSError error);
}

interface IPTChannelRestorationDelegate {}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Protocol]
[BaseType (typeof (NSObject))]
interface PTChannelRestorationDelegate
{
[Abstract]
[Export ("channelDescriptorForRestoredChannelUUID:")]
PTChannelDescriptor Create (NSUuid channelUUID);
dalexsoto marked this conversation as resolved.
Show resolved Hide resolved
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface PTChannelManager
{
[Async]
[Static]
[Export ("channelManagerWithDelegate:restorationDelegate:completionHandler:")]
void Create (IPTChannelManagerDelegate @delegate, IPTChannelRestorationDelegate restorationDelegate, Action<PTChannelManager, NSError> completionHandler);

[NullAllowed, Export ("activeChannelUUID", ArgumentSemantic.Strong)]
NSUuid ActiveChannelUuid { get; }

[Export ("requestJoinChannelWithUUID:descriptor:")]
void RequestJoinChannel (NSUuid channelUuid, PTChannelDescriptor descriptor);

[Export ("requestBeginTransmittingWithChannelUUID:")]
void RequestBeginTransmitting (NSUuid channelUuid);

[Export ("stopTransmittingWithChannelUUID:")]
void StopTransmitting (NSUuid channelUuid);

[Export ("leaveChannelWithUUID:")]
void LeaveChannel (NSUuid channelUuid);

[Async]
[Export ("setChannelDescriptor:forChannelUUID:completionHandler:")]
void SetChannelDescriptor (PTChannelDescriptor channelDescriptor, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);

[Async]
[Export ("setActiveRemoteParticipant:forChannelUUID:completionHandler:")]
void SetActiveRemoteParticipant ([NullAllowed] PTParticipant participant, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);

[Async]
[Export ("setServiceStatus:forChannelUUID:completionHandler:")]
void SetServiceStatus (PTServiceStatus status, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);

[Async]
[Export ("setTransmissionMode:forChannelUUID:completionHandler:")]
void SetTransmissionMode (PTTransmissionMode transmissionMode, NSUuid channelUuid, [NullAllowed] Action<NSError> completionHandler);
}

}
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiClassPtrTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected override bool Skip (Type type)
case "Phase": // missing in the sim
case "ShazamKit": // missing in the sim
case "ThreadNetwork": // missing in the sim
case "PushToTalk": // missing in the sim
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiCtorInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected override bool Skip (Type type)
break;
case "DeviceCheck": // Only available on device
case "MLCompute": // Only available on device
case "PushToTalk":
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected override bool Skip (Type type)
case "MediaSetup":
case "Phase":
case "ThreadNetwork":
case "PushToTalk":
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
Expand Down
1 change: 1 addition & 0 deletions tests/introspection/iOS/iOSApiSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected override bool Skip (Type type)
return true;
break;
#endif // HAS_WATCHCONNECTIVITY
case "PushToTalk":
case "ShazamKit":
// ShazamKit is not fully supported in the simulator
if (TestRuntime.IsSimulatorOrDesktop)
Expand Down
1 change: 1 addition & 0 deletions tests/mtouch/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ public void MT4134 ()
new { Framework = "CoreLocationUI", Version = "15.0" },
new { Framework = "Chip", Version = "15.0" },
new { Framework = "ThreadNetwork", Version = "15.0" },
new { Framework = "PushToTalk", Version = "16.0" },
};
foreach (var framework in invalidFrameworks)
mtouch.AssertError (4134, $"Your application is using the '{framework.Framework}' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS {framework.Version}, while you're building with the iOS {mtouch.Sdk} SDK.) Please select a newer SDK in your app's iOS Build options.");
Expand Down
33 changes: 0 additions & 33 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-PushToTalk.todo

This file was deleted.

33 changes: 0 additions & 33 deletions tests/xtro-sharpie/iOS-PushToTalk.todo

This file was deleted.

2 changes: 2 additions & 0 deletions tools/common/Frameworks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ public static Frameworks CreateiOSFrameworks (bool is_simulator_build)
{ "ShazamKit", "ShazamKit", new Version (15,0), NotAvailableInSimulator},
{ "ThreadNetwork", "ThreadNetwork", new Version (15,0), NotAvailableInSimulator},

{ "PushToTalk", "PushToTalk", new Version (16,0), NotAvailableInSimulator},

// the above MUST be kept in sync with simlauncher
// see tools/mtouch/Makefile
// please also keep it sorted to ease comparison
Expand Down