Skip to content

Commit

Permalink
Add SteamRemoteStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
trdwll committed Dec 13, 2020
1 parent 9177578 commit 8c5c97e
Show file tree
Hide file tree
Showing 4 changed files with 452 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ISteamNetworkingSockets | :x: |
ISteamNetworkingUtils | :x: |
ISteamParties | :heavy_check_mark: |
ISteamRemotePlay | :heavy_check_mark: |
ISteamRemoteStorage | :x: |
ISteamRemoteStorage | :heavy_check_mark: | [1] (5)
ISteamScreenshots | :x: |
ISteamUGC | :x: |
ISteamUser | :heavy_check_mark: |
Expand Down
86 changes: 86 additions & 0 deletions Source/SteamBridge/Private/Core/SteamRemoteStorage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2020 Russ 'trdwll' Treadwell <trdwll.com>. All Rights Reserved.

#include "Core/SteamRemoteStorage.h"

#include "SteamBridgeUtils.h"

USteamRemoteStorage::USteamRemoteStorage()
{
OnRemoteStorageDownloadUGCResultCallback.Register(this, &USteamRemoteStorage::OnRemoteStorageDownloadUGCResult);
OnRemoteStorageFileReadAsyncCompleteCallback.Register(this, &USteamRemoteStorage::OnRemoteStorageFileReadAsyncComplete);
OnRemoteStorageFileShareResultCallback.Register(this, &USteamRemoteStorage::OnRemoteStorageFileShareResult);
OnRemoteStorageFileWriteAsyncCompleteCallback.Register(this, &USteamRemoteStorage::OnRemoteStorageFileWriteAsyncComplete);
OnRemoteStoragePublishedFileSubscribedCallback.Register(this, &USteamRemoteStorage::OnRemoteStoragePublishedFileSubscribed);
OnRemoteStoragePublishedFileUnsubscribedCallback.Register(this, &USteamRemoteStorage::OnRemoteStoragePublishedFileUnsubscribed);
OnRemoteStorageSubscribePublishedFileResultCallback.Register(this, &USteamRemoteStorage::OnRemoteStorageSubscribePublishedFileResult);
OnRemoteStorageUnsubscribePublishedFileResultCallback.Register(this, &USteamRemoteStorage::OnRemoteStorageUnsubscribePublishedFileResult);
}

USteamRemoteStorage::~USteamRemoteStorage()
{
OnRemoteStorageDownloadUGCResultCallback.Unregister();
OnRemoteStorageFileReadAsyncCompleteCallback.Unregister();
OnRemoteStorageFileShareResultCallback.Unregister();
OnRemoteStorageFileWriteAsyncCompleteCallback.Unregister();
OnRemoteStoragePublishedFileSubscribedCallback.Unregister();
OnRemoteStoragePublishedFileUnsubscribedCallback.Unregister();
OnRemoteStorageSubscribePublishedFileResultCallback.Unregister();
OnRemoteStorageUnsubscribePublishedFileResultCallback.Unregister();
}

int32 USteamRemoteStorage::FileRead(const FString& FileName, TArray<uint8>& Data, int32 DataToRead) const
{
Data.SetNum(DataToRead);
int32 result = SteamRemoteStorage()->FileRead(TCHAR_TO_UTF8(*FileName), Data.GetData(), Data.Num());
Data.SetNum(result);
return result;
}

bool USteamRemoteStorage::GetQuota(int64& TotalBytes, int64& AvailableBytes) const
{
uint64 TmpTotal, TmpAvailable;
bool bResult = SteamRemoteStorage()->GetQuota(&TmpTotal, &TmpAvailable);
TotalBytes = TmpTotal;
AvailableBytes = TmpAvailable;
return bResult;
}

void USteamRemoteStorage::OnRemoteStorageDownloadUGCResult(RemoteStorageDownloadUGCResult_t* pParam)
{
m_OnRemoteStorageDownloadUGCResult.Broadcast((ESteamResult)pParam->m_eResult, pParam->m_hFile, pParam->m_nAppID, pParam->m_nSizeInBytes, UTF8_TO_TCHAR(pParam->m_pchFileName), pParam->m_ulSteamIDOwner);
}

void USteamRemoteStorage::OnRemoteStorageFileReadAsyncComplete(RemoteStorageFileReadAsyncComplete_t* pParam)
{
m_OnRemoteStorageFileReadAsyncComplete.Broadcast(pParam->m_hFileReadAsync, (ESteamResult)pParam->m_eResult, pParam->m_nOffset, pParam->m_cubRead);
}

void USteamRemoteStorage::OnRemoteStorageFileShareResult(RemoteStorageFileShareResult_t* pParam)
{
m_OnRemoteStorageFileShareResult.Broadcast((ESteamResult)pParam->m_eResult, pParam->m_hFile, UTF8_TO_TCHAR(pParam->m_rgchFilename));
}

void USteamRemoteStorage::OnRemoteStorageFileWriteAsyncComplete(RemoteStorageFileWriteAsyncComplete_t* pParam)
{
m_OnRemoteStorageFileWriteAsyncComplete.Broadcast((ESteamResult)pParam->m_eResult);
}

void USteamRemoteStorage::OnRemoteStoragePublishedFileSubscribed(RemoteStoragePublishedFileSubscribed_t* pParam)
{
m_OnRemoteStoragePublishedFileSubscribed.Broadcast(pParam->m_nPublishedFileId, pParam->m_nAppID);
}

void USteamRemoteStorage::OnRemoteStoragePublishedFileUnsubscribed(RemoteStoragePublishedFileUnsubscribed_t* pParam)
{
m_OnRemoteStoragePublishedFileUnsubscribed.Broadcast(pParam->m_nPublishedFileId, pParam->m_nAppID);
}

void USteamRemoteStorage::OnRemoteStorageSubscribePublishedFileResult(RemoteStorageSubscribePublishedFileResult_t* pParam)
{
m_OnRemoteStorageSubscribePublishedFileResult.Broadcast((ESteamResult)pParam->m_eResult, pParam->m_nPublishedFileId);
}

void USteamRemoteStorage::OnRemoteStorageUnsubscribePublishedFileResult(RemoteStorageUnsubscribePublishedFileResult_t* pParam)
{
m_OnRemoteStorageUnsubscribePublishedFileResult.Broadcast((ESteamResult)pParam->m_eResult, pParam->m_nPublishedFileId);
}
Loading

0 comments on commit 8c5c97e

Please sign in to comment.