add missing callbacks to steam_remote_storage

This commit is contained in:
a 2024-08-02 16:30:39 +03:00
parent c61294bdcd
commit 55e9ba41a9
3 changed files with 66 additions and 31 deletions

View File

@ -84,6 +84,7 @@ private:
class Ugc_Remote_Storage_Bridge *ugc_bridge{}; class Ugc_Remote_Storage_Bridge *ugc_bridge{};
class Local_Storage *local_storage{}; class Local_Storage *local_storage{};
class SteamCallResults *callback_results{}; class SteamCallResults *callback_results{};
class SteamCallBacks *callbacks{};
std::vector<struct Async_Read> async_reads{}; std::vector<struct Async_Read> async_reads{};
std::vector<struct Stream_Write> stream_writes{}; std::vector<struct Stream_Write> stream_writes{};
@ -94,7 +95,7 @@ private:
public: public:
Steam_Remote_Storage(class Settings *settings, class Ugc_Remote_Storage_Bridge *ugc_bridge, class Local_Storage *local_storage, class SteamCallResults *callback_results); Steam_Remote_Storage(class Settings *settings, class Ugc_Remote_Storage_Bridge *ugc_bridge, class Local_Storage *local_storage, class SteamCallResults *callback_results, class SteamCallBacks *callbacks);
// NOTE // NOTE
// //

View File

@ -100,7 +100,7 @@ Steam_Client::Steam_Client()
steam_user_stats = new Steam_User_Stats(settings_client, network, local_storage, callback_results_client, callbacks_client, run_every_runcb, steam_overlay); steam_user_stats = new Steam_User_Stats(settings_client, network, local_storage, callback_results_client, callbacks_client, run_every_runcb, steam_overlay);
steam_apps = new Steam_Apps(settings_client, callback_results_client, callbacks_client); steam_apps = new Steam_Apps(settings_client, callback_results_client, callbacks_client);
steam_networking = new Steam_Networking(settings_client, network, callbacks_client, run_every_runcb); steam_networking = new Steam_Networking(settings_client, network, callbacks_client, run_every_runcb);
steam_remote_storage = new Steam_Remote_Storage(settings_client, ugc_bridge, local_storage, callback_results_client); steam_remote_storage = new Steam_Remote_Storage(settings_client, ugc_bridge, local_storage, callback_results_client, callbacks_client);
steam_screenshots = new Steam_Screenshots(local_storage, callbacks_client); steam_screenshots = new Steam_Screenshots(local_storage, callbacks_client);
steam_http = new Steam_HTTP(settings_client, network, callback_results_client, callbacks_client); steam_http = new Steam_HTTP(settings_client, network, callback_results_client, callbacks_client);
steam_controller = new Steam_Controller(settings_client, callback_results_client, callbacks_client, run_every_runcb); steam_controller = new Steam_Controller(settings_client, callback_results_client, callbacks_client, run_every_runcb);

View File

@ -42,12 +42,13 @@ static void copy_file(const std::string &src_filepath, const std::string &dst_fi
} catch(...) {} } catch(...) {}
} }
Steam_Remote_Storage::Steam_Remote_Storage(class Settings *settings, class Ugc_Remote_Storage_Bridge *ugc_bridge, class Local_Storage *local_storage, class SteamCallResults *callback_results) Steam_Remote_Storage::Steam_Remote_Storage(class Settings *settings, class Ugc_Remote_Storage_Bridge *ugc_bridge, class Local_Storage *local_storage, class SteamCallResults *callback_results, class SteamCallBacks *callbacks)
{ {
this->settings = settings; this->settings = settings;
this->ugc_bridge = ugc_bridge; this->ugc_bridge = ugc_bridge;
this->local_storage = local_storage; this->local_storage = local_storage;
this->callback_results = callback_results; this->callback_results = callback_results;
this->callbacks = callbacks;
steam_cloud_enabled = true; steam_cloud_enabled = true;
} }
@ -100,7 +101,9 @@ SteamAPICall_t Steam_Remote_Storage::FileWriteAsync( const char *pchFile, const
RemoteStorageFileWriteAsyncComplete_t data; RemoteStorageFileWriteAsyncComplete_t data;
data.m_eResult = success ? k_EResultOK : k_EResultFail; data.m_eResult = success ? k_EResultOK : k_EResultFail;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.01); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.01);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.01);
return ret;
} }
@ -129,7 +132,9 @@ SteamAPICall_t Steam_Remote_Storage::FileReadAsync( const char *pchFile, uint32
a_read.size = size; a_read.size = size;
async_reads.push_back(a_read); async_reads.push_back(a_read);
callback_results->addCallResult(data.m_hFileReadAsync, data.k_iCallback, &data, sizeof(data), 0.0); callback_results->addCallResult(data.m_hFileReadAsync, data.k_iCallback, &data, sizeof(data), 0.0);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.0);
return data.m_hFileReadAsync; return data.m_hFileReadAsync;
} }
@ -160,7 +165,7 @@ bool Steam_Remote_Storage::FileReadAsyncComplete( SteamAPICall_t hReadCall, void
bool Steam_Remote_Storage::FileForget( const char *pchFile ) bool Steam_Remote_Storage::FileForget( const char *pchFile )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG("'%s'", pchFile);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchFile || !pchFile[0]) return false; if (!pchFile || !pchFile[0]) return false;
@ -169,7 +174,7 @@ bool Steam_Remote_Storage::FileForget( const char *pchFile )
bool Steam_Remote_Storage::FileDelete( const char *pchFile ) bool Steam_Remote_Storage::FileDelete( const char *pchFile )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG("'%s'", pchFile);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchFile || !pchFile[0]) return false; if (!pchFile || !pchFile[0]) return false;
@ -179,7 +184,7 @@ bool Steam_Remote_Storage::FileDelete( const char *pchFile )
STEAM_CALL_RESULT( RemoteStorageFileShareResult_t ) STEAM_CALL_RESULT( RemoteStorageFileShareResult_t )
SteamAPICall_t Steam_Remote_Storage::FileShare( const char *pchFile ) SteamAPICall_t Steam_Remote_Storage::FileShare( const char *pchFile )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG("'%s'", pchFile);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchFile || !pchFile[0]) return k_uAPICallInvalid; if (!pchFile || !pchFile[0]) return k_uAPICallInvalid;
@ -193,12 +198,14 @@ SteamAPICall_t Steam_Remote_Storage::FileShare( const char *pchFile )
data.m_eResult = k_EResultFileNotFound; data.m_eResult = k_EResultFileNotFound;
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
bool Steam_Remote_Storage::SetSyncPlatforms( const char *pchFile, ERemoteStoragePlatform eRemoteStoragePlatform ) bool Steam_Remote_Storage::SetSyncPlatforms( const char *pchFile, ERemoteStoragePlatform eRemoteStoragePlatform )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG("'%s' %i", pchFile, (int)eRemoteStoragePlatform);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchFile || !pchFile[0]) return false; if (!pchFile || !pchFile[0]) return false;
@ -209,13 +216,15 @@ bool Steam_Remote_Storage::SetSyncPlatforms( const char *pchFile, ERemoteStorage
// file operations that cause network IO // file operations that cause network IO
UGCFileWriteStreamHandle_t Steam_Remote_Storage::FileWriteStreamOpen( const char *pchFile ) UGCFileWriteStreamHandle_t Steam_Remote_Storage::FileWriteStreamOpen( const char *pchFile )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG("'%s'", pchFile);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchFile || !pchFile[0]) return k_UGCFileStreamHandleInvalid; if (!pchFile || !pchFile[0]) return k_UGCFileStreamHandleInvalid;
static UGCFileWriteStreamHandle_t handle; static UGCFileWriteStreamHandle_t handle = 0;
++handle; ++handle;
struct Stream_Write stream_write; if (!handle) handle = 1;
struct Stream_Write stream_write{};
stream_write.file_name = std::string(pchFile); stream_write.file_name = std::string(pchFile);
stream_write.write_stream_handle = handle; stream_write.write_stream_handle = handle;
stream_writes.push_back(stream_write); stream_writes.push_back(stream_write);
@ -411,14 +420,15 @@ SteamAPICall_t Steam_Remote_Storage::UGCDownload( UGCHandle_t hContent, uint32 u
RemoteStorageDownloadUGCResult_t data{}; RemoteStorageDownloadUGCResult_t data{};
data.m_hFile = hContent; data.m_hFile = hContent;
data.m_nAppID = settings->get_local_game_id().AppID();
if (shared_files.count(hContent)) { if (shared_files.count(hContent)) {
data.m_eResult = k_EResultOK; data.m_eResult = k_EResultOK;
data.m_nAppID = settings->get_local_game_id().AppID();
data.m_ulSteamIDOwner = settings->get_local_steam_id().ConvertToUint64(); data.m_ulSteamIDOwner = settings->get_local_steam_id().ConvertToUint64();
data.m_nSizeInBytes = local_storage->file_size(Local_Storage::remote_storage_folder, shared_files[hContent]); data.m_nSizeInBytes = local_storage->file_size(Local_Storage::remote_storage_folder, shared_files[hContent]);
shared_files[hContent].copy(data.m_pchFileName, sizeof(data.m_pchFileName) - 1); shared_files[hContent].copy(data.m_pchFileName, sizeof(data.m_pchFileName) - 1);
PRINT_DEBUG(" FileShare data.m_pchFileName = '%s'", data.m_pchFileName);
auto [ele_itr, _] = downloaded_files.insert_or_assign(hContent, Downloaded_File::DownloadSource::AfterFileShare); auto [ele_itr, _] = downloaded_files.insert_or_assign(hContent, Downloaded_File::DownloadSource::AfterFileShare);
auto &ele = ele_itr->second; auto &ele = ele_itr->second;
@ -434,24 +444,25 @@ SteamAPICall_t Steam_Remote_Storage::UGCDownload( UGCHandle_t hContent, uint32 u
: mod.previewFileSize; : mod.previewFileSize;
data.m_eResult = k_EResultOK; data.m_eResult = k_EResultOK;
data.m_nAppID = settings->get_local_game_id().AppID();
data.m_ulSteamIDOwner = mod.steamIDOwner; data.m_ulSteamIDOwner = mod.steamIDOwner;
data.m_nSizeInBytes = mod_size; data.m_nSizeInBytes = mod_size;
data.m_ulSteamIDOwner = mod.steamIDOwner; data.m_ulSteamIDOwner = mod.steamIDOwner;
mod_name.copy(data.m_pchFileName, sizeof(data.m_pchFileName) - 1); mod_name.copy(data.m_pchFileName, sizeof(data.m_pchFileName) - 1);
PRINT_DEBUG(" QueryUGCRequest data.m_pchFileName = '%s'", data.m_pchFileName);
auto [ele_itr, _] = downloaded_files.insert_or_assign(hContent, Downloaded_File::DownloadSource::AfterSendQueryUGCRequest); auto [ele_itr, _] = downloaded_files.insert_or_assign(hContent, Downloaded_File::DownloadSource::AfterSendQueryUGCRequest);
auto &ele = ele_itr->second; auto &ele = ele_itr->second;
ele.file = mod_name; ele.file = mod_name;
ele.total_size = mod_size; ele.total_size = mod_size;
ele.mod_query_info = query_res.value(); ele.mod_query_info = query_res.value();
} else { } else {
data.m_eResult = k_EResultFileNotFound; //TODO: not sure if this is the right result data.m_eResult = k_EResultFileNotFound; //TODO: not sure if this is the right result
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageDownloadUGCResult_t ) STEAM_CALL_RESULT( RemoteStorageDownloadUGCResult_t )
@ -790,12 +801,13 @@ SteamAPICall_t Steam_Remote_Storage::GetPublishedFileDetails( PublishedFileId_t
mod.tags.copy(data.m_rgchTags, sizeof(data.m_rgchTags) - 1); mod.tags.copy(data.m_rgchTags, sizeof(data.m_rgchTags) - 1);
mod.title.copy(data.m_rgchTitle, sizeof(data.m_rgchTitle) - 1); mod.title.copy(data.m_rgchTitle, sizeof(data.m_rgchTitle) - 1);
mod.workshopItemURL.copy(data.m_rgchURL, sizeof(data.m_rgchURL) - 1); mod.workshopItemURL.copy(data.m_rgchURL, sizeof(data.m_rgchURL) - 1);
} else { } else {
data.m_eResult = EResult::k_EResultFail; // TODO is this correct? data.m_eResult = EResult::k_EResultFail; // TODO is this correct?
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
// return 0; // return 0;
/* /*
@ -830,6 +842,7 @@ SteamAPICall_t Steam_Remote_Storage::EnumerateUserPublishedFiles( uint32 unStart
PRINT_DEBUG("TODO %u", unStartIndex); PRINT_DEBUG("TODO %u", unStartIndex);
// TODO is this implementation correct? // TODO is this implementation correct?
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
RemoteStorageEnumerateUserPublishedFilesResult_t data{}; RemoteStorageEnumerateUserPublishedFilesResult_t data{};
// collect all published mods by this user // collect all published mods by this user
@ -861,7 +874,9 @@ SteamAPICall_t Steam_Remote_Storage::EnumerateUserPublishedFiles( uint32 unStart
data.m_nResultsReturned = iterated; data.m_nResultsReturned = iterated;
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageSubscribePublishedFileResult_t ) STEAM_CALL_RESULT( RemoteStorageSubscribePublishedFileResult_t )
@ -882,7 +897,9 @@ SteamAPICall_t Steam_Remote_Storage::SubscribePublishedFile( PublishedFileId_t u
data.m_eResult = EResult::k_EResultFail; // TODO is this correct? data.m_eResult = EResult::k_EResultFail; // TODO is this correct?
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageEnumerateUserSubscribedFilesResult_t ) STEAM_CALL_RESULT( RemoteStorageEnumerateUserSubscribedFilesResult_t )
@ -914,7 +931,9 @@ SteamAPICall_t Steam_Remote_Storage::EnumerateUserSubscribedFiles( uint32 unStar
data.m_nResultsReturned = iterated; data.m_nResultsReturned = iterated;
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageUnsubscribePublishedFileResult_t ) STEAM_CALL_RESULT( RemoteStorageUnsubscribePublishedFileResult_t )
@ -935,7 +954,9 @@ SteamAPICall_t Steam_Remote_Storage::UnsubscribePublishedFile( PublishedFileId_t
data.m_eResult = k_EResultFail; data.m_eResult = k_EResultFail;
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
bool Steam_Remote_Storage::UpdatePublishedFileSetChangeDescription( PublishedFileUpdateHandle_t updateHandle, const char *pchChangeDescription ) bool Steam_Remote_Storage::UpdatePublishedFileSetChangeDescription( PublishedFileUpdateHandle_t updateHandle, const char *pchChangeDescription )
@ -967,7 +988,9 @@ SteamAPICall_t Steam_Remote_Storage::GetPublishedItemVoteDetails( PublishedFileI
data.m_eResult = EResult::k_EResultFail; // TODO is this correct? data.m_eResult = EResult::k_EResultFail; // TODO is this correct?
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageUpdateUserPublishedItemVoteResult_t ) STEAM_CALL_RESULT( RemoteStorageUpdateUserPublishedItemVoteResult_t )
@ -993,7 +1016,9 @@ SteamAPICall_t Steam_Remote_Storage::UpdateUserPublishedItemVote( PublishedFileI
data.m_eResult = EResult::k_EResultFail; // TODO is this correct? data.m_eResult = EResult::k_EResultFail; // TODO is this correct?
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageGetPublishedItemVoteDetailsResult_t ) STEAM_CALL_RESULT( RemoteStorageGetPublishedItemVoteDetailsResult_t )
@ -1022,22 +1047,26 @@ SteamAPICall_t Steam_Remote_Storage::GetUserPublishedItemVoteDetails( PublishedF
data.m_eResult = EResult::k_EResultFail; // TODO is this correct? data.m_eResult = EResult::k_EResultFail; // TODO is this correct?
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return 0; return ret;
} }
STEAM_CALL_RESULT( RemoteStorageEnumerateUserPublishedFilesResult_t ) STEAM_CALL_RESULT( RemoteStorageEnumerateUserPublishedFilesResult_t )
SteamAPICall_t Steam_Remote_Storage::EnumerateUserSharedWorkshopFiles( CSteamID steamId, uint32 unStartIndex, SteamParamStringArray_t *pRequiredTags, SteamParamStringArray_t *pExcludedTags ) SteamAPICall_t Steam_Remote_Storage::EnumerateUserSharedWorkshopFiles( CSteamID steamId, uint32 unStartIndex, SteamParamStringArray_t *pRequiredTags, SteamParamStringArray_t *pExcludedTags )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
RemoteStorageEnumerateUserPublishedFilesResult_t data{}; RemoteStorageEnumerateUserPublishedFilesResult_t data{};
data.m_eResult = k_EResultOK; data.m_eResult = k_EResultOK;
data.m_nResultsReturned = 0; data.m_nResultsReturned = 0;
data.m_nTotalResultCount = 0; data.m_nTotalResultCount = 0;
//data.m_rgPublishedFileId; //data.m_rgPublishedFileId;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
STEAM_CALL_RESULT( RemoteStorageEnumerateUserPublishedFilesResult_t ) STEAM_CALL_RESULT( RemoteStorageEnumerateUserPublishedFilesResult_t )
@ -1086,12 +1115,15 @@ SteamAPICall_t Steam_Remote_Storage::EnumeratePublishedWorkshopFiles( EWorkshopE
PRINT_DEBUG_TODO(); PRINT_DEBUG_TODO();
// TODO is this implementation correct? // TODO is this implementation correct?
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
RemoteStorageEnumerateWorkshopFilesResult_t data{}; RemoteStorageEnumerateWorkshopFilesResult_t data{};
data.m_eResult = EResult::k_EResultOK; data.m_eResult = EResult::k_EResultOK;
data.m_nResultsReturned = 0; data.m_nResultsReturned = 0;
data.m_nTotalResultCount = 0; data.m_nTotalResultCount = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
@ -1145,7 +1177,9 @@ SteamAPICall_t Steam_Remote_Storage::UGCDownloadToLocation( UGCHandle_t hContent
data.m_eResult = k_EResultFileNotFound; //TODO: not sure if this is the right result data.m_eResult = k_EResultFileNotFound; //TODO: not sure if this is the right result
} }
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
} }
// Cloud dynamic state change notification // Cloud dynamic state change notification