Rise
The Vieneo Province
Loading...
Searching...
No Matches
isteamuser.h
Go to the documentation of this file.
1//====== Copyright (c) 1996-2008, Valve Corporation, All rights reserved. =======
2//
3// Purpose: interface to user account information in Steam
4//
5//=============================================================================
6
7#ifndef ISTEAMUSER_H
8#define ISTEAMUSER_H
9#ifdef _WIN32
10#pragma once
11#endif
12
13#include "steam_api_common.h"
14
15//-----------------------------------------------------------------------------
16// Purpose: Functions for accessing and manipulating a steam account
17// associated with one client instance
18//-----------------------------------------------------------------------------
20{
21public:
22 // returns the HSteamUser this interface represents
23 // this is only used internally by the API, and by a few select interfaces that support multi-user
25
26 // returns true if the Steam client current has a live connection to the Steam servers.
27 // If false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server is down/busy.
28 // The Steam client will automatically be trying to recreate the connection as often as possible.
29 virtual bool BLoggedOn() = 0;
30
31 // returns the CSteamID of the account currently logged into the Steam client
32 // a CSteamID is a unique identifier for an account, and used to differentiate users in all parts of the Steamworks API
33 virtual CSteamID GetSteamID() = 0;
34
35 // Multiplayer Authentication functions
36
37 // InitiateGameConnection() starts the state machine for authenticating the game client with the game server
38 // It is the client portion of a three-way handshake between the client, the game server, and the steam servers
39 //
40 // Parameters:
41 // void *pAuthBlob - a pointer to empty memory that will be filled in with the authentication token.
42 // int cbMaxAuthBlob - the number of bytes of allocated memory in pBlob. Should be at least 2048 bytes.
43 // CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client
44 // CGameID gameID - the ID of the current game. For games without mods, this is just CGameID( <appID> )
45 // uint32 unIPServer, uint16 usPortServer - the IP address of the game server
46 // bool bSecure - whether or not the client thinks that the game server is reporting itself as secure (i.e. VAC is running)
47 //
48 // return value - returns the number of bytes written to pBlob. If the return is 0, then the buffer passed in was too small, and the call has failed
49 // The contents of pBlob should then be sent to the game server, for it to use to complete the authentication process.
50 //
51 // DEPRECATED! This function will be removed from the SDK in an upcoming version.
52 // Please migrate to BeginAuthSession and related functions.
53 virtual int InitiateGameConnection_DEPRECATED( void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure ) = 0;
54
55 // notify of disconnect
56 // needs to occur when the game client leaves the specified game server, needs to match with the InitiateGameConnection() call
57 //
58 // DEPRECATED! This function will be removed from the SDK in an upcoming version.
59 // Please migrate to BeginAuthSession and related functions.
60 virtual void TerminateGameConnection_DEPRECATED( uint32 unIPServer, uint16 usPortServer ) = 0;
61
62 // Legacy functions
63
64 // used by only a few games to track usage events
65 virtual void TrackAppUsageEvent( CGameID gameID, int eAppUsageEvent, const char *pchExtraInfo = "" ) = 0;
66
67 // get the local storage folder for current Steam account to write application data, e.g. save games, configs etc.
68 // this will usually be something like "C:\Progam Files\Steam\userdata<SteamID><AppID>\local"
69 virtual bool GetUserDataFolder( char *pchBuffer, int cubBuffer ) = 0;
70
71 // Starts voice recording. Once started, use GetVoice() to get the data
72 virtual void StartVoiceRecording( ) = 0;
73
74 // Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for
75 // a little bit after this function is called. GetVoice() should continue to be called until it returns
76 // k_eVoiceResultNotRecording
77 virtual void StopVoiceRecording( ) = 0;
78
79 // Determine the size of captured audio data that is available from GetVoice.
80 // Most applications will only use compressed data and should ignore the other
81 // parameters, which exist primarily for backwards compatibility. See comments
82 // below for further explanation of "uncompressed" data.
83 virtual EVoiceResult GetAvailableVoice( uint32 *pcbCompressed, uint32 *pcbUncompressed_Deprecated = 0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated = 0 ) = 0;
84
85 // ---------------------------------------------------------------------------
86 // NOTE: "uncompressed" audio is a deprecated feature and should not be used
87 // by most applications. It is raw single-channel 16-bit PCM wave data which
88 // may have been run through preprocessing filters and/or had silence removed,
89 // so the uncompressed audio could have a shorter duration than you expect.
90 // There may be no data at all during long periods of silence. Also, fetching
91 // uncompressed audio will cause GetVoice to discard any leftover compressed
92 // audio, so you must fetch both types at once. Finally, GetAvailableVoice is
93 // not precisely accurate when the uncompressed size is requested. So if you
94 // really need to use uncompressed audio, you should call GetVoice frequently
95 // with two very large (20kb+) output buffers instead of trying to allocate
96 // perfectly-sized buffers. But most applications should ignore all of these
97 // details and simply leave the "uncompressed" parameters as NULL/zero.
98 // ---------------------------------------------------------------------------
99
100 // Read captured audio data from the microphone buffer. This should be called
101 // at least once per frame, and preferably every few milliseconds, to keep the
102 // microphone input delay as low as possible. Most applications will only use
103 // compressed data and should pass NULL/zero for the "uncompressed" parameters.
104 // Compressed data can be transmitted by your application and decoded into raw
105 // using the DecompressVoice function below.
106 virtual EVoiceResult GetVoice( bool bWantCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, bool bWantUncompressed_Deprecated = false, void *pUncompressedDestBuffer_Deprecated = 0, uint32 cbUncompressedDestBufferSize_Deprecated = 0, uint32 *nUncompressBytesWritten_Deprecated = 0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated = 0 ) = 0;
107
108 // Decodes the compressed voice data returned by GetVoice. The output data is
109 // raw single-channel 16-bit PCM audio. The decoder supports any sample rate
110 // from 11025 to 48000; see GetVoiceOptimalSampleRate() below for details.
111 // If the output buffer is not large enough, then *nBytesWritten will be set
112 // to the required buffer size, and k_EVoiceResultBufferTooSmall is returned.
113 // It is suggested to start with a 20kb buffer and reallocate as necessary.
114 virtual EVoiceResult DecompressVoice( const void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, uint32 nDesiredSampleRate ) = 0;
115
116 // This returns the native sample rate of the Steam voice decompressor; using
117 // this sample rate for DecompressVoice will perform the least CPU processing.
118 // However, the final audio quality will depend on how well the audio device
119 // (and/or your application's audio output SDK) deals with lower sample rates.
120 // You may find that you get the best audio output quality when you ignore
121 // this function and use the native sample rate of your audio output device,
122 // which is usually 48000 or 44100.
124
125 // Retrieve ticket to be sent to the entity who wishes to authenticate you.
126 // pcbTicket retrieves the length of the actual ticket.
127 // SteamNetworkingIdentity is an optional input parameter to hold the public IP address or SteamID of the entity you are connecting to
128 // if an IP address is passed Steam will only allow the ticket to be used by an entity with that IP address
129 // if a Steam ID is passed Steam will only allow the ticket to be used by that Steam ID
130 // not to be used for "ISteamUserAuth\AuthenticateUserTicket" - it will fail
131 virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket, const SteamNetworkingIdentity *pSteamNetworkingIdentity ) = 0;
132
133 // Request a ticket which will be used for webapi "ISteamUserAuth\AuthenticateUserTicket"
134 // pchIdentity is an optional input parameter to identify the service the ticket will be sent to
135 // the ticket will be returned in callback GetTicketForWebApiResponse_t
136 virtual HAuthTicket GetAuthTicketForWebApi( const char *pchIdentity ) = 0;
137
138 // Authenticate ticket from entity steamID to be sure it is valid and isnt reused
139 // Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )
140 virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0;
141
142 // Stop tracking started by BeginAuthSession - called when no longer playing game with this entity
143 virtual void EndAuthSession( CSteamID steamID ) = 0;
144
145 // Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to
146 virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0;
147
148 // After receiving a user's authentication data, and passing it to BeginAuthSession, use this function
149 // to determine if the user owns downloadable content specified by the provided AppID.
151
152 // returns true if this users looks like they are behind a NAT device. Only valid once the user has connected to steam
153 // (i.e a SteamServersConnected_t has been issued) and may not catch all forms of NAT.
154 virtual bool BIsBehindNAT() = 0;
155
156 // set data to be replicated to friends so that they can join your game
157 // CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client
158 // uint32 unIPServer, uint16 usPortServer - the IP address of the game server
159 virtual void AdvertiseGame( CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer ) = 0;
160
161 // Requests a ticket encrypted with an app specific shared key
162 // pDataToInclude, cbDataToInclude will be encrypted into the ticket
163 // ( This is asynchronous, you must wait for the ticket to be completed by the server )
165 virtual SteamAPICall_t RequestEncryptedAppTicket( void *pDataToInclude, int cbDataToInclude ) = 0;
166
167 // Retrieves a finished ticket.
168 // If no ticket is available, or your buffer is too small, returns false.
169 // Upon exit, *pcbTicket will be either the size of the ticket copied into your buffer
170 // (if true was returned), or the size needed (if false was returned). To determine the
171 // proper size of the ticket, you can pass pTicket=NULL and cbMaxTicket=0; if a ticket
172 // is available, *pcbTicket will contain the size needed, otherwise it will be zero.
173 virtual bool GetEncryptedAppTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0;
174
175 // Trading Card badges data access
176 // if you only have one set of cards, the series will be 1
177 // the user has can have two different badges for a series; the regular (max level 5) and the foil (max level 1)
178 virtual int GetGameBadgeLevel( int nSeries, bool bFoil ) = 0;
179
180 // gets the Steam Level of the user, as shown on their profile
181 virtual int GetPlayerSteamLevel() = 0;
182
183 // Requests a URL which authenticates an in-game browser for store check-out,
184 // and then redirects to the specified URL. As long as the in-game browser
185 // accepts and handles session cookies, Steam microtransaction checkout pages
186 // will automatically recognize the user instead of presenting a login page.
187 // The result of this API call will be a StoreAuthURLResponse_t callback.
188 // NOTE: The URL has a very short lifetime to prevent history-snooping attacks,
189 // so you should only call this API when you are about to launch the browser,
190 // or else immediately navigate to the result URL using a hidden browser window.
191 // NOTE 2: The resulting authorization cookie has an expiration time of one day,
192 // so it would be a good idea to request and visit a new auth URL every 12 hours.
194 virtual SteamAPICall_t RequestStoreAuthURL( const char *pchRedirectURL ) = 0;
195
196 // gets whether the users phone number is verified
197 virtual bool BIsPhoneVerified() = 0;
198
199 // gets whether the user has two factor enabled on their account
200 virtual bool BIsTwoFactorEnabled() = 0;
201
202 // gets whether the users phone number is identifying
203 virtual bool BIsPhoneIdentifying() = 0;
204
205 // gets whether the users phone number is awaiting (re)verification
207
210
211 // Retrieves anti indulgence / duration control for current user
214
215 // Advise steam china duration control system about the online state of the game.
216 // This will prevent offline gameplay time from counting against a user's
217 // playtime limits.
219
220};
221
222#define STEAMUSER_INTERFACE_VERSION "SteamUser023"
223
224// Global interface accessor
227
228// callbacks
229#if defined( VALVE_CALLBACK_PACK_SMALL )
230#pragma pack( push, 4 )
231#elif defined( VALVE_CALLBACK_PACK_LARGE )
232#pragma pack( push, 8 )
233#else
234#error steam_api_common.h should define VALVE_CALLBACK_PACK_xxx
235#endif
236
237
238//-----------------------------------------------------------------------------
239// Purpose: Called when an authenticated connection to the Steam back-end has been established.
240// This means the Steam client now has a working connection to the Steam servers.
241// Usually this will have occurred before the game has launched, and should
242// only be seen if the user has dropped connection due to a networking issue
243// or a Steam server update.
244//-----------------------------------------------------------------------------
249
250//-----------------------------------------------------------------------------
251// Purpose: called when a connection attempt has failed
252// this will occur periodically if the Steam client is not connected,
253// and has failed in it's retry to establish a connection
254//-----------------------------------------------------------------------------
261
262
263//-----------------------------------------------------------------------------
264// Purpose: called if the client has lost connection to the Steam servers
265// real-time services will be disabled until a matching SteamServersConnected_t has been posted
266//-----------------------------------------------------------------------------
272
273
274//-----------------------------------------------------------------------------
275// Purpose: Sent by the Steam server to the client telling it to disconnect from the specified game server,
276// which it may be in the process of or already connected to.
277// The game client should immediately disconnect upon receiving this message.
278// This can usually occur if the user doesn't have rights to play on the game server.
279//-----------------------------------------------------------------------------
290
291
292//-----------------------------------------------------------------------------
293// Purpose: called when the callback system for this client is in an error state (and has flushed pending callbacks)
294// When getting this message the client should disconnect from Steam, reset any stored Steam state and reconnect.
295// This usually occurs in the rare event the Steam client has some kind of fatal error.
296//-----------------------------------------------------------------------------
307
308
309//-----------------------------------------------------------------------------
310// Purpose: Signaled whenever licenses change
311//-----------------------------------------------------------------------------
313{
315};
316
317
318//-----------------------------------------------------------------------------
319// callback for BeginAuthSession
320//-----------------------------------------------------------------------------
328
329
330//-----------------------------------------------------------------------------
331// Purpose: called when a user has responded to a microtransaction authorization request
332//-----------------------------------------------------------------------------
334{
336
337 uint32 m_unAppID; // AppID for this microtransaction
338 uint64 m_ulOrderID; // OrderID provided for the microtransaction
339 uint8 m_bAuthorized; // if user authorized transaction
340};
341
342
343//-----------------------------------------------------------------------------
344// Purpose: Result from RequestEncryptedAppTicket
345//-----------------------------------------------------------------------------
352
353//-----------------------------------------------------------------------------
354// callback for GetAuthSessionTicket
355//-----------------------------------------------------------------------------
362
363//-----------------------------------------------------------------------------
364// Purpose: sent to your game in response to a steam://gamewebcallback/ command
365//-----------------------------------------------------------------------------
367{
369 char m_szURL[256];
370};
371
372//-----------------------------------------------------------------------------
373// Purpose: sent to your game in response to ISteamUser::RequestStoreAuthURL
374//-----------------------------------------------------------------------------
376{
378 char m_szURL[512];
379};
380
381
382//-----------------------------------------------------------------------------
383// Purpose: sent in response to ISteamUser::GetMarketEligibility
384//-----------------------------------------------------------------------------
386{
391
392 int m_cdaySteamGuardRequiredDays; // The number of days any user is required to have had Steam Guard before they can use the market
393 int m_cdayNewDeviceCooldown; // The number of days after initial device authorization a user must wait before using the market on that device
394};
395
396
397//-----------------------------------------------------------------------------
398// Purpose: sent for games with enabled anti indulgence / duration control, for
399// enabled users. Lets the game know whether the user can keep playing or
400// whether the game should exit, and returns info about remaining gameplay time.
401//
402// This callback is fired asynchronously in response to timers triggering.
403// It is also fired in response to calls to GetDurationControl().
404//-----------------------------------------------------------------------------
406{
408
409 EResult m_eResult; // result of call (always k_EResultOK for asynchronous timer-based notifications)
410 AppId_t m_appid; // appid generating playtime
411
412 bool m_bApplicable; // is duration control applicable to user + game combination
413 int32 m_csecsLast5h; // playtime since most recent 5 hour gap in playtime, only counting up to regulatory limit of playtime, in seconds
414
415 EDurationControlProgress m_progress; // recommended progress (either everything is fine, or please exit game)
416 EDurationControlNotification m_notification; // notification to show, if any (always k_EDurationControlNotification_None for API calls)
417
418 int32 m_csecsToday; // playtime on current calendar day
419 int32 m_csecsRemaining; // playtime remaining until the user hits a regulatory limit
420};
421
422
423//-----------------------------------------------------------------------------
424// callback for GetTicketForWebApi
425//-----------------------------------------------------------------------------
435
436
437#pragma pack( pop )
438
439#endif // ISTEAMUSER_H
virtual void AdvertiseGame(CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer)=0
virtual bool BSetDurationControlOnlineState(EDurationControlOnlineState eNewState)=0
virtual HSteamUser GetHSteamUser()=0
virtual SteamAPICall_t RequestEncryptedAppTicket(void *pDataToInclude, int cbDataToInclude)=0
virtual bool BIsPhoneVerified()=0
virtual bool BLoggedOn()=0
virtual EBeginAuthSessionResult BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID)=0
virtual bool GetEncryptedAppTicket(void *pTicket, int cbMaxTicket, uint32 *pcbTicket)=0
virtual void TrackAppUsageEvent(CGameID gameID, int eAppUsageEvent, const char *pchExtraInfo="")=0
virtual HAuthTicket GetAuthTicketForWebApi(const char *pchIdentity)=0
virtual CSteamID GetSteamID()=0
virtual void TerminateGameConnection_DEPRECATED(uint32 unIPServer, uint16 usPortServer)=0
virtual void CancelAuthTicket(HAuthTicket hAuthTicket)=0
virtual EVoiceResult GetVoice(bool bWantCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, bool bWantUncompressed_Deprecated=false, void *pUncompressedDestBuffer_Deprecated=0, uint32 cbUncompressedDestBufferSize_Deprecated=0, uint32 *nUncompressBytesWritten_Deprecated=0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated=0)=0
virtual SteamAPICall_t GetMarketEligibility()=0
virtual SteamAPICall_t GetDurationControl()=0
virtual int InitiateGameConnection_DEPRECATED(void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure)=0
virtual uint32 GetVoiceOptimalSampleRate()=0
virtual void StartVoiceRecording()=0
virtual bool BIsPhoneRequiringVerification()=0
virtual EVoiceResult GetAvailableVoice(uint32 *pcbCompressed, uint32 *pcbUncompressed_Deprecated=0, uint32 nUncompressedVoiceDesiredSampleRate_Deprecated=0)=0
virtual void StopVoiceRecording()=0
virtual SteamAPICall_t RequestStoreAuthURL(const char *pchRedirectURL)=0
virtual EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID)=0
virtual bool BIsTwoFactorEnabled()=0
virtual HAuthTicket GetAuthSessionTicket(void *pTicket, int cbMaxTicket, uint32 *pcbTicket, const SteamNetworkingIdentity *pSteamNetworkingIdentity)=0
virtual bool BIsBehindNAT()=0
virtual bool GetUserDataFolder(char *pchBuffer, int cubBuffer)=0
virtual void EndAuthSession(CSteamID steamID)=0
virtual EVoiceResult DecompressVoice(const void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, uint32 nDesiredSampleRate)=0
virtual int GetPlayerSteamLevel()=0
virtual bool BIsPhoneIdentifying()=0
virtual int GetGameBadgeLevel(int nSeries, bool bFoil)=0
#define STEAMUSER_INTERFACE_VERSION
Definition isteamuser.h:222
ISteamUser * SteamUser()
const char *typedef uint32(S_CALLTYPE *SteamAPI_CheckCallbackRegistered_t)(int iCallbackNum)
int32 HSteamUser
#define STEAM_DEFINE_USER_INTERFACE_ACCESSOR(type, name, version)
#define STEAM_CALL_RESULT(RESULT_TYPE)
@ k_iSteamUserCallbacks
EDurationControlNotification
EBeginAuthSessionResult
EAuthSessionResponse
EDurationControlProgress
EDurationControlOnlineState
uint32 HAuthTicket
EMarketNotAllowedReasonFlags
EUserHasLicenseForAppResult
uint32 AppId_t
Definition steamtypes.h:81
unsigned short uint16
Definition steamtypes.h:56
uint32 RTime32
Definition steamtypes.h:90
unsigned long long uint64
Definition steamtypes.h:60
int int32
Definition steamtypes.h:57
uint64 SteamAPICall_t
Definition steamtypes.h:93
unsigned char uint8
Definition steamtypes.h:11
EDurationControlNotification m_notification
Definition isteamuser.h:416
EDurationControlProgress m_progress
Definition isteamuser.h:415
char m_szURL[256]
Definition isteamuser.h:369
uint8 m_rgubTicket[k_nCubTicketMaxLength]
Definition isteamuser.h:433
static const int k_nCubTicketMaxLength
Definition isteamuser.h:432
uint8 m_eFailureType
Definition isteamuser.h:305
@ k_EFailureFlushedCallbackQueue
Definition isteamuser.h:302
EMarketNotAllowedReasonFlags m_eNotAllowedReason
Definition isteamuser.h:389
EAuthSessionResponse m_eAuthSessionResponse
Definition isteamuser.h:325