mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-22 21:31:07 -05:00
Add API call to create links to extra files
This commit is contained in:
parent
55aab6c447
commit
1fd6e7e97a
@ -2217,16 +2217,14 @@ const noexcept
|
||||
}
|
||||
}
|
||||
|
||||
std::error_condition ftServer::exportFilesLink(
|
||||
std::string& link, std::uintptr_t handle, bool fragSneak,
|
||||
const std::string& baseUrl )
|
||||
std::error_condition ftServer::dirDetailsToLink(
|
||||
std::string& link,
|
||||
const DirDetails& dirDetails, bool fragSneak, const std::string& baseUrl )
|
||||
{
|
||||
DirDetails tDirDet;
|
||||
if(!requestDirDetails(tDirDet, handle))
|
||||
return RsFilesErrorNum::FILES_HANDLE_NOT_FOUND;
|
||||
|
||||
std::unique_ptr<RsFileTree> tFileTree =
|
||||
RsFileTree::fromDirDetails(tDirDet, false);
|
||||
RsFileTree::fromDirDetails(dirDetails, false);
|
||||
if(!tFileTree) return std::errc::invalid_argument;
|
||||
|
||||
link = tFileTree->toBase64();
|
||||
|
||||
if(!baseUrl.empty())
|
||||
@ -2234,7 +2232,7 @@ std::error_condition ftServer::exportFilesLink(
|
||||
RsUrl tUrl(baseUrl);
|
||||
tUrl.setQueryKV(FILES_URL_COUNT_FIELD,
|
||||
std::to_string(tFileTree->mTotalFiles) )
|
||||
.setQueryKV(FILES_URL_NAME_FIELD, tDirDet.name)
|
||||
.setQueryKV(FILES_URL_NAME_FIELD, dirDetails.name)
|
||||
.setQueryKV( FILES_URL_SIZE_FIELD,
|
||||
std::to_string(tFileTree->mTotalSize) );
|
||||
if(fragSneak)
|
||||
@ -2247,6 +2245,34 @@ std::error_condition ftServer::exportFilesLink(
|
||||
return std::error_condition();
|
||||
}
|
||||
|
||||
std::error_condition ftServer::exportCollectionLink(
|
||||
std::string& link, std::uintptr_t handle, bool fragSneak,
|
||||
const std::string& baseUrl )
|
||||
{
|
||||
DirDetails tDirDet;
|
||||
if(!requestDirDetails(tDirDet, handle))
|
||||
return RsFilesErrorNum::FILES_HANDLE_NOT_FOUND;
|
||||
|
||||
return dirDetailsToLink(link, tDirDet, fragSneak, baseUrl);
|
||||
}
|
||||
|
||||
/// @see RsFiles
|
||||
std::error_condition ftServer::exportFileLink(
|
||||
std::string& link, const RsFileHash& fileHash, uint64_t fileSize,
|
||||
const std::string& fileName, bool fragSneak, const std::string& baseUrl )
|
||||
{
|
||||
if(fileHash.isNull() || !fileSize || fileName.empty())
|
||||
return std::errc::invalid_argument;
|
||||
|
||||
DirDetails tDirDet;
|
||||
tDirDet.type = DIR_TYPE_FILE;
|
||||
tDirDet.name = fileName;
|
||||
tDirDet.hash = fileHash;
|
||||
tDirDet.count = fileSize;
|
||||
|
||||
return dirDetailsToLink(link, tDirDet, fragSneak, baseUrl);
|
||||
}
|
||||
|
||||
std::error_condition ftServer::parseFilesLink(
|
||||
const std::string& link, RsFileTree& collection )
|
||||
{
|
||||
|
@ -224,11 +224,18 @@ public:
|
||||
virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ;
|
||||
|
||||
/// @see RsFiles
|
||||
std::error_condition exportFilesLink(
|
||||
std::error_condition exportCollectionLink(
|
||||
std::string& link, std::uintptr_t handle, bool fragSneak = false,
|
||||
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL
|
||||
) override;
|
||||
|
||||
/// @see RsFiles
|
||||
std::error_condition exportFileLink(
|
||||
std::string& link, const RsFileHash& fileHash, uint64_t fileSize,
|
||||
const std::string& fileName, bool fragSneak = false,
|
||||
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL
|
||||
) override;
|
||||
|
||||
/// @see RsFiles
|
||||
std::error_condition parseFilesLink(
|
||||
const std::string& link, RsFileTree& collection ) override;
|
||||
@ -383,11 +390,11 @@ protected:
|
||||
bool findEncryptedHash(const RsPeerId& virtual_peer_id, RsFileHash& encrypted_hash);
|
||||
|
||||
bool checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash);
|
||||
private:
|
||||
|
||||
/**** INTERNAL FUNCTIONS ***/
|
||||
//virtual int reScanDirs();
|
||||
//virtual int check_dBUpdate();
|
||||
std::error_condition dirDetailsToLink(
|
||||
std::string& link,
|
||||
const DirDetails& dirDetails, bool fragSneak,
|
||||
const std::string& baseUrl );
|
||||
|
||||
private:
|
||||
|
||||
|
@ -912,10 +912,10 @@ public:
|
||||
static const std::string FILES_URL_SIZE_FIELD;
|
||||
|
||||
/**
|
||||
* @brief Get link to a forum
|
||||
* @brief Export link to a collection of files
|
||||
* @jsonapi{development}
|
||||
* @param[out] link storage for the generated link
|
||||
* @param[in] handle file/directory RetroShare handle
|
||||
* @param[in] handle directory RetroShare handle
|
||||
* @param[in] fragSneak when true the file data is sneaked into fragment
|
||||
* instead of FILES_URL_DATA_FIELD query field, this way if using an
|
||||
* http[s] link to pass around a disguised file link a misconfigured host
|
||||
@ -929,10 +929,26 @@ public:
|
||||
* plain base64 format.
|
||||
* @return error information if some error occurred, 0/SUCCESS otherwise
|
||||
*/
|
||||
virtual std::error_condition exportFilesLink(
|
||||
virtual std::error_condition exportCollectionLink(
|
||||
std::string& link, std::uintptr_t handle, bool fragSneak = false,
|
||||
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Export link to a file
|
||||
* @jsonapi{development}
|
||||
* @param[out] link @see exportCollectionLink
|
||||
* @param[in] fileHash hash of the file
|
||||
* @param[in] fileSize size of the file
|
||||
* @param[in] fileName name of the file
|
||||
* @param[in] fragSneak @see exportCollectionLink
|
||||
* @param[in] baseUrl @see exportCollectionLink
|
||||
* @return error @see exportCollectionLink
|
||||
*/
|
||||
virtual std::error_condition exportFileLink(
|
||||
std::string& link, const RsFileHash& fileHash, uint64_t fileSize,
|
||||
const std::string& fileName, bool fragSneak = false,
|
||||
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Parse RetroShare files link
|
||||
* @jsonapi{development}
|
||||
|
Loading…
Reference in New Issue
Block a user