GOG GALAXY SDK Documentation
IStorage.h
Go to the documentation of this file.
1 #ifndef GALAXY_I_STORAGE_H
2 #define GALAXY_I_STORAGE_H
3 
9 #include "GalaxyID.h"
10 #include "IListenerRegistrar.h"
11 
12 namespace galaxy
13 {
14  namespace api
15  {
24  typedef uint64_t SharedFileID;
25 
29  class IFileShareListener : public GalaxyTypeAwareListener<FILE_SHARE>
30  {
31  public:
32 
39  virtual void OnFileShareSuccess(const char* fileName, SharedFileID sharedFileID) = 0;
40 
45  {
48  };
49 
56  virtual void OnFileShareFailure(const char* fileName, FailureReason failureReason) = 0;
57  };
58 
63 
67  class ISharedFileDownloadListener : public GalaxyTypeAwareListener<SHARED_FILE_DOWNLOAD>
68  {
69  public:
70 
77  virtual void OnSharedFileDownloadSuccess(SharedFileID sharedFileID, const char* fileName) = 0;
78 
83  {
86  };
87 
94  virtual void OnSharedFileDownloadFailure(SharedFileID sharedFileID, FailureReason failureReason) = 0;
95  };
96 
101 
105  class IStorage
106  {
107  public:
108 
109  virtual ~IStorage()
110  {
111  }
112 
126  virtual void FileWrite(const char* fileName, const void* data, uint32_t dataSize) = 0;
127 
136  virtual uint32_t FileRead(const char* fileName, void* data, uint32_t dataSize) = 0;
137 
143  virtual void FileDelete(const char* fileName) = 0;
144 
151  virtual bool FileExists(const char* fileName) = 0;
152 
159  virtual uint32_t GetFileSize(const char* fileName) = 0;
160 
167  virtual uint32_t GetFileTimestamp(const char* fileName) = 0;
168 
174  virtual uint32_t GetFileCount() = 0;
175 
182  virtual const char* GetFileNameByIndex(uint32_t index) = 0;
183 
191  virtual void GetFileNameCopyByIndex(uint32_t index, char* buffer, uint32_t bufferLength) = 0;
192 
201  virtual void FileShare(const char* fileName, IFileShareListener* const listener = NULL) = 0;
202 
211  virtual void DownloadSharedFile(SharedFileID sharedFileID, ISharedFileDownloadListener* const listener = NULL) = 0;
212 
221  virtual const char* GetSharedFileName(SharedFileID sharedFileID) = 0;
222 
232  virtual void GetSharedFileNameCopy(SharedFileID sharedFileID, char* buffer, uint32_t bufferLength) = 0;
233 
242  virtual uint32_t GetSharedFileSize(SharedFileID sharedFileID) = 0;
243 
252  virtual GalaxyID GetSharedFileOwner(SharedFileID sharedFileID) = 0;
253 
265  virtual uint32_t SharedFileRead(SharedFileID sharedFileID, void* data, uint32_t dataSize, uint32_t offset = 0) = 0;
266 
276  virtual void SharedFileClose(SharedFileID sharedFileID) = 0;
277 
283  virtual uint32_t GetDownloadedSharedFileCount() = 0;
284 
291  virtual SharedFileID GetDownloadedSharedFileByIndex(uint32_t index) = 0;
292  };
293 
295  }
296 }
297 
298 #endif
Contains GalaxyID, which is the class that represents the ID of an entity used by Galaxy Peer.
Contains data structures and interfaces related to callback listeners.
Represents the ID of an entity used by Galaxy Peer.
Definition: GalaxyID.h:30
The class that is inherited by all specific callback listeners and provides a static method that retu...
Definition: IListenerRegistrar.h:110
Listener for the event of sharing a file.
Definition: IStorage.h:30
FailureReason
The reason of a failure in sharing a file.
Definition: IStorage.h:45
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStorage.h:46
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStorage.h:47
virtual void OnFileShareSuccess(const char *fileName, SharedFileID sharedFileID)=0
Notification for the event of a success in sharing a file.
virtual void OnFileShareFailure(const char *fileName, FailureReason failureReason)=0
Notification for the event of a failure in sharing a file.
Listener for the event of downloading a shared file.
Definition: IStorage.h:68
FailureReason
The reason of a failure in downloading a shared file.
Definition: IStorage.h:83
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: IStorage.h:84
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: IStorage.h:85
virtual void OnSharedFileDownloadSuccess(SharedFileID sharedFileID, const char *fileName)=0
Notification for the event of a success in downloading a shared file.
virtual void OnSharedFileDownloadFailure(SharedFileID sharedFileID, FailureReason failureReason)=0
Notification for the event of a failure in downloading a shared file.
The interface for managing of cloud storage files.
Definition: IStorage.h:106
virtual void FileShare(const char *fileName, IFileShareListener *const listener=NULL)=0
Uploads the file for sharing.
virtual SharedFileID GetDownloadedSharedFileByIndex(uint32_t index)=0
Returns the ID of the open downloaded shared file.
virtual uint32_t GetFileCount()=0
Returns number of the files in the storage.
virtual void FileWrite(const char *fileName, const void *data, uint32_t dataSize)=0
Writes data into the file.
virtual bool FileExists(const char *fileName)=0
Returns if the file exists.
virtual void SharedFileClose(SharedFileID sharedFileID)=0
Closes downloaded shared file and frees the memory.
virtual void GetFileNameCopyByIndex(uint32_t index, char *buffer, uint32_t bufferLength)=0
Copies the name of the file to a buffer.
virtual void FileDelete(const char *fileName)=0
Deletes the file.
virtual GalaxyID GetSharedFileOwner(SharedFileID sharedFileID)=0
Gets the owner of downloaded shared file.
virtual uint32_t GetFileTimestamp(const char *fileName)=0
Returns the timestamp of the last file modification.
virtual void GetSharedFileNameCopy(SharedFileID sharedFileID, char *buffer, uint32_t bufferLength)=0
Copies the name of downloaded shared file to a buffer.
virtual const char * GetSharedFileName(SharedFileID sharedFileID)=0
Gets name of downloaded shared file.
virtual uint32_t GetFileSize(const char *fileName)=0
Returns the size of the file.
virtual void DownloadSharedFile(SharedFileID sharedFileID, ISharedFileDownloadListener *const listener=NULL)=0
Downloads previously shared file.
virtual const char * GetFileNameByIndex(uint32_t index)=0
Returns name of the file.
virtual uint32_t FileRead(const char *fileName, void *data, uint32_t dataSize)=0
Reads file content into the buffer.
virtual uint32_t GetDownloadedSharedFileCount()=0
Returns the number of open downloaded shared files.
virtual uint32_t GetSharedFileSize(SharedFileID sharedFileID)=0
Gets size of downloaded shared file.
virtual uint32_t SharedFileRead(SharedFileID sharedFileID, void *data, uint32_t dataSize, uint32_t offset=0)=0
Reads downloaded shared file content into the buffer.
The class that is inherited by the self-registering versions of all specific callback listeners.
Definition: IListenerRegistrar.h:204
uint64_t SharedFileID
ID of a shared file.
Definition: IStorage.h:24
SelfRegisteringListener< ISharedFileDownloadListener > GlobalSharedFileDownloadListener
Globally self-registering version of ISharedFileDownloadListener.
Definition: IStorage.h:100
SelfRegisteringListener< IFileShareListener > GlobalFileShareListener
Globally self-registering version of IFileShareListener.
Definition: IStorage.h:62