summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLPermissionConstants.h
blob: 03b89867a6e54ff712d3f1456b3df03c1e878a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
//  SDLPermissionsConstants.h
//  SmartDeviceLink-iOS
//
//  Created by Joel Fischer on 11/18/15.
//  Copyright © 2015 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "NSNumber+NumberType.h"

NS_ASSUME_NONNULL_BEGIN

typedef NSString *SDLPermissionRPCName;
typedef NSUUID *SDLPermissionObserverIdentifier;

/**
 *  A permission group type which will be used to tell the system what type of changes you want to be notified about for the group.
 */
typedef NS_ENUM(NSUInteger, SDLPermissionGroupType) {
    /**
     *  Be notified when all of the RPC in the group are allowed, or, when they all stop being allowed in some sense, that is, when they were all allowed, and now they are not.
     */
    SDLPermissionGroupTypeAllAllowed,
    /**
     *  Be notified when any change in availability occurs among the group.
     */
    SDLPermissionGroupTypeAny
};

/**
 *  The status of the group of RPCs permissions.
 */
typedef NS_ENUM(NSUInteger, SDLPermissionGroupStatus) {
    /**
     *  Every RPC in the group is currently allowed.
     */
    SDLPermissionGroupStatusAllowed,
    /**
     *  Every RPC in the group is currently disallowed.
     */
    SDLPermissionGroupStatusDisallowed,
    /**
     *  Some RPCs in the group are allowed and some disallowed.
     */
    SDLPermissionGroupStatusMixed,
    /**
     *  The current status of the group is unknown.
     */
    SDLPermissionGroupStatusUnknown
};

/**
 *  The PermissionObserver is a block that is passed in to some methods that will be stored and called when specified permissions change.
 *
 *  @param change  A dictionary of permission changes containing <key(String): RPC Name, object(BOOL): YES if the RPC is allowed, NO if it is not allowed>
 *  @param status       The change made to all of the RPCs in the changedDict. Allowed, if all RPCs are now allowed, Disallowed if all RPCs are now disallowed, or Mixed if some are allowed, and some are disallowed
 */
typedef void (^SDLPermissionsChangedHandler)(NSDictionary<SDLPermissionRPCName, NSNumber<SDLBool> *> *_Nonnull change, SDLPermissionGroupStatus status);

NS_ASSUME_NONNULL_END