This event is fired when custom encryption is used and data block must be decrypted.
TSolFSCryptDataEvent = procedure( Sender : TObject; Key : Pointer; KeyLength : LongWord; Data : Pointer; DataSize : LongWord; ObjectID : LongWord; PageIndex : LongWord; var Result : LongInt) of object;
typedef Error (__stdcall *SolFSCryptDataFunc)( LongWord UserData, void * Key, unsigned long KeyLength, void * Data, unsigned long DataSize, unsigned long ObjectID, unsigned long PageIndex);
typedef void (__closure *TSolFSCryptDataEvent)( System::TObject* Sender, void * Key, unsigned long KeyLength, void * Data, unsigned long DataSize, unsigned long ObjectID, unsigned long PageIndex, unsigned long & Result);
public __delegate void SolFSCryptDataEvent( SolFSStorage* Sender, unsigned char key __gc, unsigned char data __gc, unsigned long objectID, unsigned long pageIndex, Int32 __gc &result);
The buffer with the decrypted data.
The event is fired when custom encryption is used and the data block must be decrypted. Data to decrypt is put to Data parameter. The size of the data is always multiple to 32.
The password specified for file or storage encryption is passed in Key parameter. When setting the password for the file or storage, you can use the key itself (and decrypt using this key) or specify the identifier of the decryption key. In the latter case this identifier is passed via Key parameter.
The event handler should put the result of decryption to the buffer pointed by Data parameter (i.e. the same buffer, which contains the encrypted data). This means that the size of the decrypted data block must not exceed the size of the encrypted data block.
The callback/event handler must be set before the storage is opened.
You need to implement ISolFSEncryptionEvents interface in your code and pass the object, that implements the events, to one of SolFSStorage constructors that accept storageEvents parameter.
ERROR REPORTING: In Java you can't return more than one parameter, so the natural way is to throw an exception. You can throw any exception, and this exception will be passed back to the code, which called one of CBFS Storage functions. So if you use callback mechanism and throw exception from within event handlers, be sure to wrap each call to CBFS Storage methods with try/catch.