Starboard Module Reference: user.h

Defines a user management API. This module defines functions only for managing signed-in users. Platforms that do not have users must still implement this API, always reporting a single user that is current and signed in.
These APIs are NOT expected to be thread-safe, so either call them from a single thread, or perform proper synchronization around all calls.

Enums

SbUserPropertyId

A set of string properties that can be queried on a user.

Values

  • kSbUserPropertyAvatarUrl - The URL to the avatar for a user. Avatars are not provided on all platforms.
  • kSbUserPropertyHomeDirectory - The path to a user's home directory, if supported on this platform.
  • kSbUserPropertyUserName - The username of a user, which may be the same as the User ID, or it may befriendlier.
  • kSbUserPropertyUserId - A unique user ID of a user.

Structs

SbUserApplicationTokenResults

Information about an application-specific authorization token.

Members

Members
size_t
token_buffer_size
The size of the buffer pointed to by token_buffer. Call SbUserMaxAuthenticationTokenSizeInBytes() to get an appropriate size. token_buffer_size must be set to a value greater than zero.
bool
has_expiry
If true, expiry will be set. If false, the token never expires.
SbTime
expiry
The absolute time that this token expires. It is valid to use the value of expiry only if has_expiry is true.

SbUserPrivate

Private structure representing a device user.

Functions

SbUserGetCurrent

Description

Gets the current primary user, if one exists. This is the user that is determined, in a platform-specific way, to be the primary user controlling the application. For example, the determination might be made because that user launched the app, though it should be made using whatever criteria are appropriate for the platform.
It is expected that there will be a unique SbUser per signed-in user, and that the referenced objects will persist for the lifetime of the app.

Declaration and definitions

SB_EXPORT SbUser SbUserGetCurrent();

#include "starboard/user.h"

SbUser SbUserGetCurrent() {
  return kSbUserInvalid;
}

SbUserGetProperty

Description

Retrieves the value of property_id for user and places it in out_value. The function returns:

  • true if the property value is retrieved successfully
  • false if user is invalid; if property_id isn't recognized, supported, or set for user; or if value_size is too small.

Declaration and definitions

SB_EXPORT bool SbUserGetProperty(SbUser user,
                                 SbUserPropertyId property_id,
                                 char* out_value,
                                 int value_size);

#include "starboard/user.h"

int SbUserGetPropertySize(SbUser /*user*/, SbUserPropertyId /*property_id*/) {
  return 0;
}

bool SbUserGetProperty(SbUser /*user*/,
                       SbUserPropertyId /*property_id*/,
                       char* /*out_value*/,
                       int /*value_size*/) {
  return false;
}

Parameters

Parameters
SbUser
user
The user for which property size data is being retrieved.
SbUserPropertyId
property_id
The property for which the data is requested.
char*
out_value
The retrieved property value.
int
value_size
The size of the retrieved property value.

SbUserGetPropertySize

Description

Returns the size of the value of property_id for user, INCLUDING the terminating null character. The function returns 0 if user is invalid or if property_id is not recognized, supported, or set for the user.

Declaration

SB_EXPORT int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id);

Parameters

Parameters
SbUser
user
The user for which property size data is being retrieved.
SbUserPropertyId
property_id
The property for which the data is requested.

SbUserGetSignedIn

Description

Gets a list of up to users_size signed-in users and places the results in out_users. The return value identifies the actual number of signed-in users, which may be greater or less than users_size.
It is expected that there will be a unique SbUser per signed-in user and that the referenced objects will persist for the lifetime of the app.

Declaration and definitions

SB_EXPORT int SbUserGetSignedIn(SbUser* out_users, int users_size);

#include "starboard/user.h"

int SbUserGetSignedIn(SbUser* /*out_users*/, int /*users_size*/) {
  return 0;
}

Parameters

Parameters
SbUser*
out_users
Handles for the retrieved users.
int
users_size
The maximum number of signed-in users to retrieve.

SbUserIsValid

Description

Returns whether the given user handle is valid.

Declaration

static SB_C_INLINE bool SbUserIsValid(SbUser user) {
  return user != kSbUserInvalid;
}

Parameters

Parameters
SbUser
user