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

[CHIP] Updates for Xcode13.2 beta 1 #13884

Merged
merged 9 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
142 changes: 142 additions & 0 deletions src/Chip/ChipCompat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// ChipCompat.cs
//
// Authors:
// Rachel Kang <[email protected]>
//com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//com

// Copyright (C) Microsoft Corporation. All rights reserved.
//

using System;
using System.Threading.Tasks;
using Foundation;
using CoreFoundation;
using ObjCRuntime;

#nullable enable

#if !NET
namespace Chip {

#if !MONOMAC
public partial class ChipReadAttributeResult { }
#endif // !MONOMAC

[Obsolete ("This class is removed.")]
[Register ("CHIPError", SkipRegistration = true)]
public class ChipError : NSObject {

public override IntPtr ClassHandle => throw new InvalidOperationException (Constants.RemovedFromChip);

protected ChipError (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromChip);
protected ChipError (IntPtr handle) => throw new InvalidOperationException (Constants.RemovedFromChip);

public virtual int ConvertToChipErrorCode (NSError errorCode) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual NSError? Create (int errorCode) => throw new InvalidOperationException (Constants.RemovedFromChip);

} /* class ChipError */

#if !MONOMAC
[Obsolete ("This class is removed, use 'ChipContentLauncher' instead.")]
[Register ("CHIPContentLaunch", SkipRegistration = true)]
public class ChipContentLaunch : NSObject {

public override IntPtr ClassHandle => throw new InvalidOperationException (Constants.RemovedFromChip);

protected ChipContentLaunch (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromChip);
protected ChipContentLaunch (IntPtr handle) => throw new InvalidOperationException (Constants.RemovedFromChip);
public ChipContentLaunch (ChipDevice device, byte endpoint, DispatchQueue queue) => throw new InvalidOperationException (Constants.RemovedFromChip);

public virtual void LaunchContent (byte autoPlay, string data, ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> LaunchContentAsync (byte autoPlay, string data) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual void LaunchUrl (string contentUrl, string displayString, ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> LaunchUrlAsync (string contentUrl, string displayString) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual void ReadAttributeAcceptsHeaderList (ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> ReadAttributeAcceptsHeaderListAsync () => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual void ReadAttributeSupportedStreamingTypes (ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> ReadAttributeSupportedStreamingTypesAsync () => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual void ReadAttributeClusterRevision (ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> ReadAttributeClusterRevisionAsync () => throw new InvalidOperationException (Constants.RemovedFromChip);

} /* class ChipContentLaunch */
#endif // !MONOMAC

#if !MONOMAC
[Obsolete ("This class is removed.")]
[Register ("CHIPTrustedRootCertificates", SkipRegistration = true)]
public class ChipTrustedRootCertificates : NSObject
{
public override IntPtr ClassHandle => throw new InvalidOperationException (Constants.RemovedFromChip);

protected ChipTrustedRootCertificates (NSObjectFlag t) => throw new InvalidOperationException (Constants.RemovedFromChip);
protected ChipTrustedRootCertificates (IntPtr handle) => throw new InvalidOperationException (Constants.RemovedFromChip);
public ChipTrustedRootCertificates (ChipDevice device, byte endpoint, DispatchQueue queue) => throw new InvalidOperationException (Constants.RemovedFromChip);

public virtual void AddTrustedRootCertificate (NSData rootCertificate, ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> AddTrustedRootCertificateAsync (NSData rootCertificate) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual void RemoveTrustedRootCertificate (NSData trustedRootIdentifier, ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> RemoveTrustedRootCertificateAsync (NSData trustedRootIdentifier) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual void ReadAttributeClusterRevision (ChipResponseHandler responseHandler) => throw new InvalidOperationException (Constants.RemovedFromChip);
public virtual Task<ChipReadAttributeResult> ReadAttributeClusterRevisionAsync () => throw new InvalidOperationException (Constants.RemovedFromChip);

}
#endif // !MONOMAC

public partial class ChipWindowCovering {

#if !MONOMAC
static bool CheckSystemVersion ()
{
#if NET || IOS || __MACCATALYST__ || TVOS
return SystemVersion.CheckiOS (15, 2);
#elif WATCH
return SystemVersion.CheckwatchOS (8, 3);
#else
#error Unknown platform
#endif
}
#endif

#if !MONOMAC
public virtual void GoToLiftValue (ushort liftValue, ChipResponseHandler responseHandler)
{
if (CheckSystemVersion ())
_OldGoToLiftValue (liftValue, responseHandler);
else
_NewGoToLiftValue (liftValue, responseHandler);
}
#endif

#if !MONOMAC
public virtual Task<ChipReadAttributeResult> GoToLiftValueAsync (ushort liftValue)
{
if (CheckSystemVersion ())
return _OldGoToLiftValueAsync (liftValue);
else
return _NewGoToLiftValueAsync (liftValue);
}
#endif

#if !MONOMAC
public virtual void GoToTiltValue (ushort tiltValue, ChipResponseHandler responseHandler)
{
if (CheckSystemVersion ())
_OldGoToTiltValue (tiltValue, responseHandler);
else
_NewGoToTiltValue (tiltValue, responseHandler);
}
#endif

#if !MONOMAC
public virtual Task<ChipReadAttributeResult> GoToTiltValueAsync (ushort tiltValue)
{
if (CheckSystemVersion ())
return _OldGoToTiltValueAsync (tiltValue);
else
return _NewGoToTiltValueAsync (tiltValue);
}
#endif

}
}
#endif // !NET
27 changes: 27 additions & 0 deletions src/Chip/ChipKeypair.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// ChipKeypair.cs
//
// Authors:
// Rachel Kang <[email protected]>
//com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//com

// Copyright (C) Microsoft Corporation. All rights reserved.
//

using System;
using Security;

#nullable enable

namespace Chip {
public partial class ChipKeypair {

#if !NET
[Mac (12,1), Watch (8,3), TV (15,2), iOS (15,2), MacCatalyst (15,2)]
#endif
static public SecKey? GetPubKey ()
{
var key = GetPubKeyRef ();
return key == IntPtr.Zero ? null : new SecKey (key, true);
}
}
}
2 changes: 2 additions & 0 deletions src/ObjCRuntime/ObsoleteConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ partial class Constants {

internal const string UnavailableOnThisPlatform = "This type is not available on this Platform.";

internal const string RemovedFromChip = "This API has been removed from the 'CHIP' framework.";

}
}
Loading