Skip to content

Commit

Permalink
Move some Matter.framework server APIs used only with concrete contro…
Browse files Browse the repository at this point in the history
…llers to the concrete controller class. (#35943)

These APIs are never used for XPC controllers, and the base class implementation
does not really make sense.
  • Loading branch information
bzbarsky-apple authored Oct 7, 2024
1 parent 4ec1716 commit b559f17
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 55 deletions.
37 changes: 0 additions & 37 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -691,43 +691,6 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID
});
}

- (NSArray<MTRAccessGrant *> *)accessGrantsForClusterPath:(MTRClusterPath *)clusterPath
{
assertChipStackLockedByCurrentThread();

for (MTRServerEndpoint * endpoint in _serverEndpoints) {
if ([clusterPath.endpoint isEqual:endpoint.endpointID]) {
return [endpoint matterAccessGrantsForCluster:clusterPath.cluster];
}
}

// Nothing matched, no grants.
return @[];
}

- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID
{
assertChipStackLockedByCurrentThread();

for (MTRServerEndpoint * endpoint in _serverEndpoints) {
for (MTRServerCluster * cluster in endpoint.serverClusters) {
if (![cluster.clusterID isEqual:clusterID]) {
continue;
}

for (MTRServerAttribute * attr in cluster.attributes) {
if (![attr.attributeID isEqual:attributeID]) {
continue;
}

return @(attr.requiredReadPrivilege);
}
}
}

return nil;
}

#ifdef DEBUG
+ (void)forceLocalhostAdvertisingOnly
{
Expand Down
18 changes: 18 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#import <Foundation/Foundation.h>

#import <Matter/MTRAccessGrant.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
#import <Matter/MTRDeviceControllerFactory.h>
Expand Down Expand Up @@ -131,6 +132,23 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)operationalInstanceAdded:(NSNumber *)nodeID;

/**
* Get the access grants that apply for the given cluster path.
*/
- (NSArray<MTRAccessGrant *> *)accessGrantsForClusterPath:(MTRClusterPath *)clusterPath;

/**
* Get the privilege level needed to read the given attribute. There's no
* endpoint provided because the expectation is that this information is the
* same for all cluster instances.
*
* Returns nil if we have no such attribute defined on any endpoint, otherwise
* one of MTRAccessControlEntry* constants wrapped in NSNumber.
*
* Only called on the Matter queue.
*/
- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID;

@end

NS_ASSUME_NONNULL_END
18 changes: 0 additions & 18 deletions src/darwin/Framework/CHIP/MTRDeviceController_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

#import <Foundation/Foundation.h>
#import <Matter/MTRAccessGrant.h>
#import <Matter/MTRBaseDevice.h> // for MTRClusterPath

#import "MTRDeviceConnectionBridge.h" // For MTRInternalDeviceConnectionCallback
Expand Down Expand Up @@ -210,23 +209,6 @@ NS_ASSUME_NONNULL_BEGIN
queue:(dispatch_queue_t)queue
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion;

/**
* Get the access grants that apply for the given cluster path.
*/
- (NSArray<MTRAccessGrant *> *)accessGrantsForClusterPath:(MTRClusterPath *)clusterPath;

/**
* Get the privilege level needed to read the given attribute. There's no
* endpoint provided because the expectation is that this information is the
* same for all cluster instances.
*
* Returns nil if we have no such attribute defined on any endpoint, otherwise
* one of MTRAccessControlEntry* constants wrapped in NSNumber.
*
* Only called on the Matter queue.
*/
- (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID;

#pragma mark - Device-specific data and SDK access
// DeviceController will act as a central repository for this opaque dictionary that MTRDevice manages
- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID;
Expand Down

0 comments on commit b559f17

Please sign in to comment.