This is part of datamodel for any binary blobs.
More...
#include <binaryfilemodel.h>
|
| BinaryFileModel (MController *aMController, const MModelProtocolInterface &aModel) |
|
| ~BinaryFileModel () |
|
Hash | publishBinaryFile (const Profile &aPublishingProfile, const QString &aFileName, const QString &aDescription, const QString &aMimeType, const QString &aOwner, const QString &aLicense, const QByteArray &aContents, bool aIsCompressed, bool aNoEncryption=false, const QList< Hash > *aBinaryRecipientList=NULL) |
|
BinaryFile * | binaryFileByFingerPrint (const Hash &aFingerPrint) |
|
bool | binaryFileDataByFingerPrint (const Hash &aFingerPrint, const Hash &aPresumedSender, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, bool *aIsBinaryFilePrivate) |
|
bool | publishedBinaryFileReceived (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode) |
|
bool | sentBinaryFileReceived (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const Hash &aFromNode) |
|
bool | binaryFileDataForPublish (const Hash &aFingerPrint, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, bool *aIsBinaryFilePrivate, bool *iIsBinaryFileCompressed) |
|
bool | binaryFileDataForSend (const Hash &aFingerPrint, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, bool *aIsBinaryFilePrivate, bool *aIsBinaryFileCompressed, quint32 *aTimeOfPublish) |
|
void | fillBucket (QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode) |
|
| ModelBase (QString aDataTableName, unsigned aMaxRowsToKeep) |
|
| ~ModelBase () |
|
bool | setTimeLastReference (const Hash &aObjectFingerPrint, quint32 aTimeWhenLastReferenced) |
|
unsigned | getMaxRowsToKeep () |
|
void | setMaxRowsToKeep (unsigned aRows) |
|
void | truncateDataTableToMaxRows (void) |
|
void | updateDbTableRowCount () |
|
|
bool | doFindBinaryFileForPublishOrSend (const Hash &aFingerPrint, QByteArray &aResultingBinaryFileData, QByteArray &aResultingSignature, QByteArray &aPublicKeyOfPublisher, bool *aIsBinaryFilePrivate, bool *aIsBinaryFileCompressed, quint32 *aTimeOfPublish) |
|
bool | doHandleReceivedFile (const Hash &aFingerPrint, const QByteArray &aContent, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const QByteArray &aKeyOfPublisher, const unsigned char aFlags, const quint32 aTimeStamp, const bool aWasPublish, const Hash &aFromNode) |
|
This is part of datamodel for any binary blobs.
Initially this is for "shared files" profile-functionality but this practically lets you share any octet-stream over DHT.
◆ BinaryFileModel()
◆ ~BinaryFileModel()
BinaryFileModel::~BinaryFileModel |
( |
| ) |
|
◆ binaryFileByFingerPrint()
BinaryFile* BinaryFileModel::binaryFileByFingerPrint |
( |
const Hash & |
aFingerPrint | ) |
|
Gets a file. Caller is supposed to delete the returned object. Note that returned data contains metadata only, for actual content use method and because signature is calculated over metadata+content, this method does not yet check for signature -> it is checked when data is retrieved.
- Parameters
-
aFingerPrint | file serial number (hash) |
- Returns
- file or NULL
◆ binaryFileDataByFingerPrint()
bool BinaryFileModel::binaryFileDataByFingerPrint |
( |
const Hash & |
aFingerPrint, |
|
|
const Hash & |
aPresumedSender, |
|
|
QByteArray & |
aResultingBinaryFileData, |
|
|
QByteArray & |
aResultingSignature, |
|
|
bool * |
aIsBinaryFilePrivate |
|
) |
| |
Method for getting file contents. Returned contents are un-encrypted already when returned by this method, and un-compressed. And signature is checked. Need to think a strategy around situation where we have a file but we don't have public key of its publisher ; in this case we just have no clue about origins of the file and this is possible situation too.
- Parameters
-
aFingerPrint | binary blob serial number |
aPresumedSender | is fingerprint of the file sender from file metadata -> file content verification against this key must succeed. |
aResultingBinaryFileData | will contain profile data |
aResultingSignature | will contain profile signature |
aIsBinaryFilePrivate | will be set to true if aResultingBinaryFileData is encrypted. |
- Returns
- true if file was found
◆ binaryFileDataForPublish()
bool BinaryFileModel::binaryFileDataForPublish |
( |
const Hash & |
aFingerPrint, |
|
|
QByteArray & |
aResultingBinaryFileData, |
|
|
QByteArray & |
aResultingSignature, |
|
|
QByteArray & |
aPublicKeyOfPublisher, |
|
|
bool * |
aIsBinaryFilePrivate, |
|
|
bool * |
iIsBinaryFileCompressed |
|
) |
| |
method that returns unaltered binary file metadata+data in single bytearray for purpose of publishing to other node
- Returns
- true if content was found
◆ binaryFileDataForSend()
bool BinaryFileModel::binaryFileDataForSend |
( |
const Hash & |
aFingerPrint, |
|
|
QByteArray & |
aResultingBinaryFileData, |
|
|
QByteArray & |
aResultingSignature, |
|
|
QByteArray & |
aPublicKeyOfPublisher, |
|
|
bool * |
aIsBinaryFilePrivate, |
|
|
bool * |
aIsBinaryFileCompressed, |
|
|
quint32 * |
aTimeOfPublish |
|
) |
| |
method that returns unaltered binary file metadata+data in single bytearray for purpose of sending to other node
- Returns
- true if content was found
◆ contentReceived
void BinaryFileModel::contentReceived |
( |
const Hash & |
aHashOfContent, |
|
|
const ProtocolItemType |
aTypeOfReceivdContent |
|
) |
| |
|
signal |
◆ doFindBinaryFileForPublishOrSend()
bool BinaryFileModel::doFindBinaryFileForPublishOrSend |
( |
const Hash & |
aFingerPrint, |
|
|
QByteArray & |
aResultingBinaryFileData, |
|
|
QByteArray & |
aResultingSignature, |
|
|
QByteArray & |
aPublicKeyOfPublisher, |
|
|
bool * |
aIsBinaryFilePrivate, |
|
|
bool * |
aIsBinaryFileCompressed, |
|
|
quint32 * |
aTimeOfPublish |
|
) |
| |
|
private |
◆ doHandleReceivedFile()
bool BinaryFileModel::doHandleReceivedFile |
( |
const Hash & |
aFingerPrint, |
|
|
const QByteArray & |
aContent, |
|
|
const QByteArray & |
aSignature, |
|
|
const QList< quint32 > & |
aBangPath, |
|
|
const QByteArray & |
aKeyOfPublisher, |
|
|
const unsigned char |
aFlags, |
|
|
const quint32 |
aTimeStamp, |
|
|
const bool |
aWasPublish, |
|
|
const Hash & |
aFromNode |
|
) |
| |
|
private |
workhorse of methods publishedBinaryFileReceived and sentBinaryFileReceived
◆ error
◆ fillBucket()
void BinaryFileModel::fillBucket |
( |
QList< SendQueueItem > & |
aSendQueue, |
|
|
const Hash & |
aStartOfBucket, |
|
|
const Hash & |
aEndOfBucket, |
|
|
quint32 |
aLastMutualConnectTime, |
|
|
const Hash & |
aForNode |
|
) |
| |
Method for filling connected peers send queue with items that we have and that belong to said peers bucket.
- Parameters
-
aSendQueue | is send-queue of the connection that serves particular node |
aStartOfBucket | is hash where bucket of that peer starts. In practice it is the hash of the node itself. |
aEndOfBucket | is hash where bucket of that peer ends. That in turn depends on network size, or number of active nodes in the network. See method NodeModel::bucketEndHash for details. |
aLastMutualConnectTime | time when node was last in contact. In practice we'll fill the bucket items published after this time. |
aForNode | fingerprint of the node that asks for the bucket fill ; reason for this is the recvd_from column for preventing immediately re-sending content sent from a peer |
◆ publishBinaryFile()
Hash BinaryFileModel::publishBinaryFile |
( |
const Profile & |
aPublishingProfile, |
|
|
const QString & |
aFileName, |
|
|
const QString & |
aDescription, |
|
|
const QString & |
aMimeType, |
|
|
const QString & |
aOwner, |
|
|
const QString & |
aLicense, |
|
|
const QByteArray & |
aContents, |
|
|
bool |
aIsCompressed, |
|
|
bool |
aNoEncryption = false , |
|
|
const QList< Hash > * |
aBinaryRecipientList = NULL |
|
) |
| |
sends a file to selected nodes in network for others to retrieve.
Don't forget to re-publish the profile after successful completion of file publish as list of files is part of the profile itself.
- Parameters
-
aPublishingProfile | is the publishing profile ; it is used to sign the content and its privacy-settings are used decide if file content will be encrypted or not. |
aFileName | is string telling original file-system file name |
aDescription | is free text describing the content |
aMimeType | is mime type, like application/octet-stream or image/gif |
aOwner | who owns the file (content) |
aLicense | string for specifying usage permission, something like "public domain" or "creative commons share-alike" |
aContents | is the meat being thrown |
aIsCompressed | indicates if aContent should be uncompressed before use. |
aNoEncryption | If false then privateness of aPublishingProfile is used to decide if content gets encrypted during publish. If true then content will always go out without encryption. Use-case for this is attachment of public posting where everybody needs to be able to read, also when poster has private profile. |
aBinaryRecipientList | Is list of fingerprints of profiles whose keys will be used to encrypt the content. If these keys are given, then normal "readers of publishing
profile" recipient-key-list method is not used. Use-case for this parameter is attachment of a private message; there is dual recipient (sender and receiver) and that's it. |
- Returns
- Fingerprint of the published file or KNullHash if things went bad.
◆ publishedBinaryFileReceived()
bool BinaryFileModel::publishedBinaryFileReceived |
( |
const Hash & |
aFingerPrint, |
|
|
const QByteArray & |
aContent, |
|
|
const QByteArray & |
aSignature, |
|
|
const QList< quint32 > & |
aBangPath, |
|
|
const QByteArray & |
aKeyOfPublisher, |
|
|
const unsigned char |
aFlags, |
|
|
const quint32 |
aTimeStamp, |
|
|
const Hash & |
aFromNode |
|
) |
| |
called by protocol parser when a file is received due to publish
- Parameters
-
aFingerPrint | is the profile Hash received from protocol header |
aContent | is actual file data |
aSignature | is digital signature of the aContent |
aBangPath | is list of low-order bits of hashes of nodes where this content has been. This is for preventing sending content back to nodes where it has already been. |
aKeyOfPublisher | is the key that was used to sign the file. that is transferred outside file just because the recipient might not have the key beforehand ; if she does, the existing key will be used in verifying process. |
aFlags | possible flags telling about encyption and compression |
aTimeStamp | timestamp of file (if encrypted, it must be carried outside..) |
aFromNode | hash of the node that sent the file. low-order bits of the hash will be stored along with the content, serving as bang-path of length 1. |
- Returns
- true on success
◆ sentBinaryFileReceived()
bool BinaryFileModel::sentBinaryFileReceived |
( |
const Hash & |
aFingerPrint, |
|
|
const QByteArray & |
aContent, |
|
|
const QByteArray & |
aSignature, |
|
|
const QByteArray & |
aKeyOfPublisher, |
|
|
const unsigned char |
aFlags, |
|
|
const quint32 |
aTimeStamp, |
|
|
const Hash & |
aFromNode |
|
) |
| |
called by protocol parser when a file is received due to send
- Parameters
-
aFingerPrint | is the profile Hash received from protocol header |
aContent | is actual file data |
aSignature | is digital signature of the aContent |
aKeyOfPublisher | is the key that was used to sign the file. that is transferred outside file just because the recipient might not have the key beforehand ; if she does, the existing key will be used in verifying process. |
aFlags | possible flags telling about encyption and compression |
aTimeStamp | timestamp of file (if encrypted, it must be carried outside..) |
aFromNode | fingerprint of the node that sent the content |
- Returns
- true on success
◆ iController
◆ iModel
The documentation for this class was generated from the following file: