GOG GALAXY SDK Documentation
ICloudStorage.h
Go to the documentation of this file.
1 #ifndef GALAXY_I_CLOUDSTORAGE_H
2 #define GALAXY_I_CLOUDSTORAGE_H
3 
9 #include "IListenerRegistrar.h"
10 
11 namespace galaxy
12 {
13  namespace api
14  {
24  {
32  };
33 
37  class ICloudStorageGetFileListListener : public GalaxyTypeAwareListener<CLOUD_STORAGE_GET_FILE_LIST>
38  {
39  public:
40 
52  virtual void OnGetFileListSuccess(uint32_t fileCount, uint32_t quota, uint32_t quotaUsed) = 0;
53 
58  {
66  };
67 
73  virtual void OnGetFileListFailure(FailureReason failureReason) = 0;
74  };
75 
79  class ICloudStorageGetFileListener : public GalaxyTypeAwareListener<CLOUD_STORAGE_GET_FILE>
80  {
81  public:
82 
92  virtual void OnGetFileSuccess(
93  const char* container,
94  const char* name,
95  uint32_t fileSize,
96  SavegameType savegameType,
97  const char* savegameID
98  ) = 0;
99 
104  {
114  };
115 
123  virtual void OnGetFileFailure(const char* container, const char* name, FailureReason failureReason) = 0;
124  };
125 
129  class ICloudStoragePutFileListener : public GalaxyTypeAwareListener<CLOUD_STORAGE_PUT_FILE>
130  {
131  public:
132 
139  virtual void OnPutFileSuccess(const char* container, const char* name) = 0;
140 
145  {
154  };
155 
163  virtual void OnPutFileFailure(const char* container, const char* name, FailureReason failureReason) = 0;
164 
165  };
166 
170  class ICloudStorageDeleteFileListener : public GalaxyTypeAwareListener<CLOUD_STORAGE_DELETE_FILE>
171  {
172  public:
173 
180  virtual void OnDeleteFileSuccess(const char* container, const char* name) = 0;
181 
186  {
195  };
196 
203  virtual void OnDeleteFileFailure(const char* container, const char* name, FailureReason failureReason) = 0;
204  };
205 
210  {
211  public:
212 
213  virtual ~ICloudStorage() {}
214 
223  virtual void GetFileList(const char* container, ICloudStorageGetFileListListener* listener) = 0;
224 
233  virtual const char* GetFileNameByIndex(uint32_t index) const = 0;
234 
243  virtual uint32_t GetFileSizeByIndex(uint32_t index) const = 0;
244 
253  virtual uint32_t GetFileTimestampByIndex(uint32_t index) const = 0;
254 
263  virtual const char* GetFileHashByIndex(uint32_t index) const = 0;
264 
273  typedef int (*WriteFunc)(void* userParam, const char* data, int size);
274 
290  virtual void GetFile(const char* container, const char* name, void* userParam, WriteFunc writeFunc, ICloudStorageGetFileListener* listener) = 0;
291 
309  virtual void GetFile(const char* container, const char* name, void* dataBuffer, uint32_t bufferLength, ICloudStorageGetFileListener* listener) = 0;
310 
322  virtual void GetFileMetadata(const char* container, const char* name, ICloudStorageGetFileListener* listener) = 0;
323 
332  typedef int (*ReadFunc)(void* userParam, char* data, int size);
333 
338  {
340  UPLOADING
341  };
342 
353  typedef int (*RewindFunc)(void* userParam, ReadPhase phase);
354 
376  virtual void PutFile(
377  const char* container,
378  const char* name,
379  void* userParam,
380  ReadFunc readFunc,
381  RewindFunc rewindFunc,
383  SavegameType savegameType = SAVEGAME_TYPE_UNDEFINED,
384  uint32_t timeStamp = 0,
385  const char* hash = NULL
386  ) = 0;
387 
408  virtual void PutFile(
409  const char* container,
410  const char* name,
411  const void* buffer,
412  uint32_t bufferLength,
414  SavegameType savegameType = SAVEGAME_TYPE_UNDEFINED,
415  uint32_t timeStamp = 0,
416  const char* hash = NULL
417  ) = 0;
418 
422  static const uint32_t MIN_HASH_BUFFER_SIZE = 33;
423 
441  virtual void CalculateHash(
442  void* userParam,
443  ReadFunc readFunc,
444  RewindFunc rewindFunc,
445  char* hashBuffer,
446  uint32_t hashBufferSize
447  ) = 0;
448 
462  virtual void CalculateHash(
463  const void* buffer,
464  uint32_t bufferLength,
465  char* hashBuffer,
466  uint32_t hashBufferSize
467  ) = 0;
468 
482  virtual void DeleteFile(const char* container, const char* name, ICloudStorageDeleteFileListener* listener, const char* expectedHash = NULL) = 0;
483 
489  virtual void OpenSavegame() = 0;
490 
496  virtual void CloseSavegame() = 0;
497 
498  };
499 
501  }
502 }
503 #endif
Contains data structures and interfaces related to callback listeners.
The class that is inherited by all specific callback listeners and provides a static method that retu...
Definition: IListenerRegistrar.h:117
Listener for the event of deleting a file stored in cloud storage.
Definition: ICloudStorage.h:171
FailureReason
The reason of a failure in deleting a file.
Definition: ICloudStorage.h:186
@ FAILURE_REASON_NOT_FOUND
Container not found.
Definition: ICloudStorage.h:190
@ FAILURE_REASON_FORBIDDEN
No access to specified container.
Definition: ICloudStorage.h:189
@ FAILURE_REASON_UNAUTHORIZED
Authorization lost.
Definition: ICloudStorage.h:188
@ FAILURE_REASON_ABORTED
Request aborted.
Definition: ICloudStorage.h:192
@ FAILURE_REASON_CONFLICT
< Expected hash parameter doesn't match the hash in the container.
Definition: ICloudStorage.h:194
@ FAILURE_REASON_UNAVAILABLE
Service unavailable.
Definition: ICloudStorage.h:191
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: ICloudStorage.h:187
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: ICloudStorage.h:193
virtual void OnDeleteFileFailure(const char *container, const char *name, FailureReason failureReason)=0
Notification for the event of a failure in deleting a file.
virtual void OnDeleteFileSuccess(const char *container, const char *name)=0
Notification for the event of a success in deleting a file.
Listener for the event of downloading a list of files stored in cloud storage.
Definition: ICloudStorage.h:38
virtual void OnGetFileListSuccess(uint32_t fileCount, uint32_t quota, uint32_t quotaUsed)=0
Notification for the event of a success in downloading a list of files.
FailureReason
The reason of a failure in downloading a list of files.
Definition: ICloudStorage.h:58
@ FAILURE_REASON_NOT_FOUND
Container not found.
Definition: ICloudStorage.h:62
@ FAILURE_REASON_FORBIDDEN
No access to specified container.
Definition: ICloudStorage.h:61
@ FAILURE_REASON_UNAUTHORIZED
Authorization lost.
Definition: ICloudStorage.h:60
@ FAILURE_REASON_ABORTED
Request aborted.
Definition: ICloudStorage.h:64
@ FAILURE_REASON_UNAVAILABLE
Service unavailable.
Definition: ICloudStorage.h:63
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: ICloudStorage.h:59
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: ICloudStorage.h:65
virtual void OnGetFileListFailure(FailureReason failureReason)=0
Notification for the event of a failure in downloading a list of files.
Listener for the event of downloading a file stored in cloud storage.
Definition: ICloudStorage.h:80
virtual void OnGetFileSuccess(const char *container, const char *name, uint32_t fileSize, SavegameType savegameType, const char *savegameID)=0
Notification for the event of a success in downloading a file.
FailureReason
The reason of a failure in downloading a file.
Definition: ICloudStorage.h:104
@ FAILURE_REASON_BUFFER_TOO_SMALL
Buffer passed to ICloudStorage::GetFile() is too small to fit the file content.
Definition: ICloudStorage.h:112
@ FAILURE_REASON_NOT_FOUND
Container not found.
Definition: ICloudStorage.h:108
@ FAILURE_REASON_FORBIDDEN
No access to specified container.
Definition: ICloudStorage.h:107
@ FAILURE_REASON_UNAUTHORIZED
Authorization lost.
Definition: ICloudStorage.h:106
@ FAILURE_REASON_ABORTED
Request aborted.
Definition: ICloudStorage.h:110
@ FAILURE_REASON_UNAVAILABLE
Service unavailable.
Definition: ICloudStorage.h:109
@ FAILURE_REASON_WRITE_FUNC_ERROR
Function writeFunc passed to ICloudStorage::GetFile() returned an error.
Definition: ICloudStorage.h:113
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: ICloudStorage.h:105
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: ICloudStorage.h:111
virtual void OnGetFileFailure(const char *container, const char *name, FailureReason failureReason)=0
Notification for the event of a failure in downloading a file.
Listener for the event of uploading a local file to the cloud storage.
Definition: ICloudStorage.h:130
virtual void OnPutFileFailure(const char *container, const char *name, FailureReason failureReason)=0
Notification for the event of a failure in uploading a file.
FailureReason
The reason of a failure in uploading a file.
Definition: ICloudStorage.h:145
@ FAILURE_REASON_FORBIDDEN
No access to specified container.
Definition: ICloudStorage.h:148
@ FAILURE_REASON_UNAUTHORIZED
Authorization lost.
Definition: ICloudStorage.h:147
@ FAILURE_REASON_ABORTED
Request aborted.
Definition: ICloudStorage.h:150
@ FAILURE_REASON_UNAVAILABLE
Service unavailable.
Definition: ICloudStorage.h:149
@ FAILURE_REASON_QUOTA_EXCEEDED
Unable to upload the file because there is no free space on cloud storage.
Definition: ICloudStorage.h:153
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: ICloudStorage.h:146
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: ICloudStorage.h:151
@ FAILURE_REASON_READ_FUNC_ERROR
Function readFunc passed to ICloudStorage::PutFile() returned an error.
Definition: ICloudStorage.h:152
virtual void OnPutFileSuccess(const char *container, const char *name)=0
Notification for the event of a success in uploading a file.
The interface for cross-platform CloudStorage file management.
Definition: ICloudStorage.h:210
virtual void GetFileList(const char *container, ICloudStorageGetFileListListener *listener)=0
Function used to get a list of files stored in cloud storage.
virtual void PutFile(const char *container, const char *name, const void *buffer, uint32_t bufferLength, ICloudStoragePutFileListener *listener, SavegameType savegameType=SAVEGAME_TYPE_UNDEFINED, uint32_t timeStamp=0, const char *hash=NULL)=0
Upload a file to the cloud storage.
virtual const char * GetFileHashByIndex(uint32_t index) const =0
Function used to get a file hash from the retrieved list of files stored in cloud storage.
int(* WriteFunc)(void *userParam, const char *data, int size)
Function used to write the downloaded data.
Definition: ICloudStorage.h:273
virtual uint32_t GetFileSizeByIndex(uint32_t index) const =0
Function used to get a file size from the retrieved list of files stored in cloud storage.
virtual const char * GetFileNameByIndex(uint32_t index) const =0
Function used to get a file name from the retrieved list of files stored in cloud storage.
virtual void CloseSavegame()=0
Closes savegame.
int(* ReadFunc)(void *userParam, char *data, int size)
Function used to read the data to be uploaded.
Definition: ICloudStorage.h:332
virtual void PutFile(const char *container, const char *name, void *userParam, ReadFunc readFunc, RewindFunc rewindFunc, ICloudStoragePutFileListener *listener, SavegameType savegameType=SAVEGAME_TYPE_UNDEFINED, uint32_t timeStamp=0, const char *hash=NULL)=0
Upload a file to the cloud storage.
static const uint32_t MIN_HASH_BUFFER_SIZE
Minimum size of the hashBuffer in CalculateHash method.
Definition: ICloudStorage.h:422
virtual void OpenSavegame()=0
Starts new savegame.
ReadPhase
The phase of reading data to be uploaded.
Definition: ICloudStorage.h:338
@ UPLOADING
Uploading phase.
Definition: ICloudStorage.h:340
@ CHECKSUM_CALCULATING
Checksum calculating phase.
Definition: ICloudStorage.h:339
virtual void DeleteFile(const char *container, const char *name, ICloudStorageDeleteFileListener *listener, const char *expectedHash=NULL)=0
Delete a file from cloud storage.
virtual uint32_t GetFileTimestampByIndex(uint32_t index) const =0
Function used to get a file timestamp from the retrieved list of files stored in cloud storage.
virtual void CalculateHash(const void *buffer, uint32_t bufferLength, char *hashBuffer, uint32_t hashBufferSize)=0
Calculate hash for the specified object.
virtual void GetFileMetadata(const char *container, const char *name, ICloudStorageGetFileListener *listener)=0
Get a file metadata from cloud storage.
virtual void GetFile(const char *container, const char *name, void *dataBuffer, uint32_t bufferLength, ICloudStorageGetFileListener *listener)=0
Download a file from cloud storage.
int(* RewindFunc)(void *userParam, ReadPhase phase)
Function used to restart read data process.
Definition: ICloudStorage.h:353
virtual void CalculateHash(void *userParam, ReadFunc readFunc, RewindFunc rewindFunc, char *hashBuffer, uint32_t hashBufferSize)=0
Calculate hash for the specified object.
virtual void GetFile(const char *container, const char *name, void *userParam, WriteFunc writeFunc, ICloudStorageGetFileListener *listener)=0
Download a file from cloud storage.
SavegameType
The type of savegame.
Definition: ICloudStorage.h:24
@ SAVEGAME_TYPE_QUICK
Quick savegame.
Definition: ICloudStorage.h:27
@ SAVEGAME_TYPE_CHECKPOINT
Savegame at a certain in-game event, e.g. quest completion.
Definition: ICloudStorage.h:31
@ SAVEGAME_TYPE_ENDGAME_SAVE
Savegame at the end of the game.
Definition: ICloudStorage.h:30
@ SAVEGAME_TYPE_POINT_OF_NO_RETURN
Savegame at the point of no return.
Definition: ICloudStorage.h:29
@ SAVEGAME_TYPE_MANUAL
Manual savegame.
Definition: ICloudStorage.h:28
@ SAVEGAME_TYPE_UNDEFINED
Not defined savegame type.
Definition: ICloudStorage.h:25
@ SAVEGAME_TYPE_AUTO
Auto savegame, triggered automatically over time.
Definition: ICloudStorage.h:26