biosprivacyservice.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //! EBiosPrivacyPermission represents possible privacy permissions
  2. /*!
  3. See individual values for platform support and meaning.
  4. */
  5. enum EBiosPrivacyPermission
  6. {
  7. COMMUNICATE_VOICE, //!< Xbox: represents CommunicateUsingVoice permissions, see Xbox Docs.
  8. COMMUNICATE_TEXT, //!< Xbox: represents CommunicateUsingText permissions, see Xbox Docs.
  9. VIEW_PROFILE, //!< Xbox: represents ViewTargetProfile permissions, see Xbox Docs.
  10. VIEW_PRESENCE, //!< Xbox: represents ViewTargetPresence permissions, see Xbox Docs.
  11. };
  12. //! EBiosPrivacyPrivilege represents possible privacy privileges
  13. /*!
  14. See individual values for platform support and meaning.
  15. */
  16. enum EBiosPrivacyPrivilege
  17. {
  18. COMMUNICATE_VOICE, //!< Xbox: represents XPRIVILEGE_COMMUNICATION_VOICE_INGAME privilege, see Xbox Docs.
  19. COMMUNICATE_TEXT, //!< Xbox: represents XPRIVILEGE_COMMUNICATIONS privilege, see Xbox Docs.
  20. MULTIPLAYER_GAMEPLAY, //!< Xbox: represents XPRIVILEGE_MULTIPLAYER_SESSIONS privilege, see Xbox Docs.
  21. MULTIPLAYER_LOBBY, //!< Xbox: represents XPRIVILEGE_MULTIPLAYER_PARTIES privilege, see Xbox Docs.
  22. };
  23. //! BiosPrivacyPermissionResult represents the per permission result of the GetPermissionsAsync reqeust.
  24. class BiosPrivacyPermissionResult
  25. {
  26. EBiosPrivacyPermission m_Permission; //!< The reqeusted permission.
  27. bool m_IsAllowed; //!< Result.
  28. static bool Compare( BiosPrivacyPermissionResult a, BiosPrivacyPermissionResult b )
  29. {
  30. return ( a.m_Permission == b.m_Permission && a.m_IsAllowed == b.m_IsAllowed );
  31. }
  32. };
  33. typedef array<ref BiosPrivacyPermissionResult> BiosPrivacyPermissionResultArray;
  34. //! BiosPrivacyUidResult represents the per user result of the GetPermissionsAsync request.
  35. class BiosPrivacyUidResult
  36. {
  37. string m_Uid; //!< Uid of the target user.
  38. ref BiosPrivacyPermissionResultArray m_Results; //!< Array of permission results for this target user.
  39. };
  40. typedef array<ref BiosPrivacyUidResult> BiosPrivacyUidResultArray;
  41. //! BiosPrivacyService is used to query privacy permissions for a target user/s.
  42. class BiosPrivacyService
  43. {
  44. //! Query for privacy permissions
  45. /*!
  46. The async result is returned in the OnPermissions callback.
  47. Expected errors:
  48. BAD_PARAMETER - if atleast one of the permissions is not supported on the current platform,
  49. or atleast one of the input arrays is NULL.
  50. @param uid_list list of target user Uid's for which to query privacy permissions.
  51. @param permission_list list of requested permissions for each target user.
  52. @return EBiosError indicating if the async operation is pending.
  53. */
  54. proto native EBiosError GetPermissionsAsync(array<string> uid_list, array<EBiosPrivacyPermission> permission_list);
  55. //! Query for privileges
  56. /*!
  57. The async result is returned in the OnPrivilege callback.
  58. Expected errors:
  59. BAD_PARAMETER - if atleast one of the privileges is not supported on the current platform,
  60. PURCHASE_REQUIRED,
  61. BANNED,
  62. NOT_ALLOWED - the privilege is granted,
  63. @param privilege the requested privilege.
  64. @param tryResolution Xbox: show system GUI with error msg and attempts to resolve it if possible.
  65. @return EBiosError indicating if the async operation is pending.
  66. */
  67. proto native EBiosError GetPrivilegeAsync(EBiosPrivacyPrivilege privilege, bool try_resolution);
  68. //! Async callback for GetPermissionsAsync
  69. /*!
  70. @param result_list list of results for each requested user. NULL if failed.
  71. @param error error indicating success or fail of the async operation.
  72. */
  73. void OnPermissions(BiosPrivacyUidResultArray result_list, EBiosError error)
  74. {
  75. if (result_list == null)
  76. {
  77. Print("biapi privacy error: " + error);
  78. return;
  79. }
  80. OnlineServices.OnPermissionsAsync( result_list, error );
  81. }
  82. //! Async callback for GetPrivilegeAsync
  83. /*!
  84. @param privilege the requested privilege.
  85. @param error error indicating success or fail of the async operation.
  86. */
  87. void OnPrivilege(EBiosPrivacyPrivilege privilege, EBiosError error)
  88. {
  89. switch ( privilege )
  90. {
  91. case EBiosPrivacyPrivilege.MULTIPLAYER_GAMEPLAY:
  92. {
  93. OnlineServices.OnLoadMPPrivilege( error );
  94. break;
  95. }
  96. case EBiosPrivacyPrivilege.COMMUNICATE_VOICE:
  97. {
  98. OnlineServices.OnLoadVoicePrivilege( error );
  99. break;
  100. }
  101. }
  102. }
  103. };