File size: 4,244 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//!	EBiosPrivacyPermission represents possible privacy permissions
/*!
	See individual values for platform support and meaning.
*/
enum EBiosPrivacyPermission
{
	COMMUNICATE_VOICE,		//!< Xbox: represents CommunicateUsingVoice permissions, see Xbox Docs.
	COMMUNICATE_TEXT,		//!< Xbox: represents CommunicateUsingText permissions, see Xbox Docs.
	VIEW_PROFILE,			//!< Xbox: represents ViewTargetProfile permissions, see Xbox Docs.
	VIEW_PRESENCE,			//!< Xbox: represents ViewTargetPresence permissions, see Xbox Docs.
};

//!	EBiosPrivacyPrivilege represents possible privacy privileges
/*!
	See individual values for platform support and meaning.
*/
enum EBiosPrivacyPrivilege
{
	COMMUNICATE_VOICE,		//!< Xbox: represents XPRIVILEGE_COMMUNICATION_VOICE_INGAME privilege, see Xbox Docs.
	COMMUNICATE_TEXT,		//!< Xbox: represents XPRIVILEGE_COMMUNICATIONS privilege, see Xbox Docs.
	MULTIPLAYER_GAMEPLAY,	//!< Xbox: represents XPRIVILEGE_MULTIPLAYER_SESSIONS privilege, see Xbox Docs.
	MULTIPLAYER_LOBBY,		//!< Xbox: represents XPRIVILEGE_MULTIPLAYER_PARTIES privilege, see Xbox Docs.
};

//! BiosPrivacyPermissionResult represents the per permission result of the GetPermissionsAsync reqeust.

class BiosPrivacyPermissionResult
{
	EBiosPrivacyPermission	m_Permission;	//!< The reqeusted permission.
	bool					m_IsAllowed;	//!< Result.
	
	static bool Compare( BiosPrivacyPermissionResult a, BiosPrivacyPermissionResult b )
	{
		return ( a.m_Permission == b.m_Permission && a.m_IsAllowed == b.m_IsAllowed );
	}
};


typedef array<ref BiosPrivacyPermissionResult> BiosPrivacyPermissionResultArray;

//! BiosPrivacyUidResult represents the per user result of the GetPermissionsAsync request.

class BiosPrivacyUidResult
{
	string									m_Uid;			//!< Uid of the target user.
	ref BiosPrivacyPermissionResultArray	m_Results;		//!< Array of permission results for this target user.
};

typedef array<ref BiosPrivacyUidResult> BiosPrivacyUidResultArray;

//! BiosPrivacyService is used to query privacy permissions for a target user/s.

class BiosPrivacyService
{
	//! Query for privacy permissions
	/*!
		The async result is returned in the OnPermissions callback.
		Expected errors:
			BAD_PARAMETER -	if atleast one of the permissions is not supported on the current platform, 
							or atleast one of the input arrays is NULL.
			
		@param uid_list list of target user Uid's for which to query privacy permissions.
		@param permission_list list of requested permissions for each target user.
		@return EBiosError indicating if the async operation is pending.
		
	*/
	proto native EBiosError GetPermissionsAsync(array<string> uid_list, array<EBiosPrivacyPermission> permission_list);

	//! Query for privileges
	/*!
		The async result is returned in the OnPrivilege callback.
		Expected errors:
			BAD_PARAMETER -	if atleast one of the privileges is not supported on the current platform, 
			PURCHASE_REQUIRED,
			BANNED,
			NOT_ALLOWED - the privilege is granted,
			
		@param privilege the requested privilege.
		@param tryResolution Xbox: show system GUI with error msg and attempts to resolve it if possible.
		@return EBiosError indicating if the async operation is pending.
		
	*/
	proto native EBiosError GetPrivilegeAsync(EBiosPrivacyPrivilege privilege, bool try_resolution);
	
	//! Async callback for GetPermissionsAsync
	/*!
		@param result_list list of results for each requested user. NULL if failed.
		@param error error indicating success or fail of the async operation.
	
	*/
	void OnPermissions(BiosPrivacyUidResultArray result_list, EBiosError error)
	{
		if (result_list == null)
		{
			Print("biapi privacy error: " + error);
			return;
		}
				
		OnlineServices.OnPermissionsAsync( result_list, error );
	}
	
	//! Async callback for GetPrivilegeAsync
	/*!
		@param privilege the requested privilege.
		@param error error indicating success or fail of the async operation.
	*/
	void OnPrivilege(EBiosPrivacyPrivilege privilege, EBiosError error)
	{
		switch ( privilege )
		{
			case EBiosPrivacyPrivilege.MULTIPLAYER_GAMEPLAY:
			{
				OnlineServices.OnLoadMPPrivilege( error );
				break;
			}
			case EBiosPrivacyPrivilege.COMMUNICATE_VOICE:
			{
				OnlineServices.OnLoadVoicePrivilege( error );
				break;
			}
		}
	}
};