mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-02 10:35:15 -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::error_condition ftServer::dirDetailsToLink(
|
||||||
std::string& link, std::uintptr_t handle, bool fragSneak,
|
std::string& link,
|
||||||
const std::string& baseUrl )
|
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 =
|
std::unique_ptr<RsFileTree> tFileTree =
|
||||||
RsFileTree::fromDirDetails(tDirDet, false);
|
RsFileTree::fromDirDetails(dirDetails, false);
|
||||||
|
if(!tFileTree) return std::errc::invalid_argument;
|
||||||
|
|
||||||
link = tFileTree->toBase64();
|
link = tFileTree->toBase64();
|
||||||
|
|
||||||
if(!baseUrl.empty())
|
if(!baseUrl.empty())
|
||||||
@ -2234,7 +2232,7 @@ std::error_condition ftServer::exportFilesLink(
|
|||||||
RsUrl tUrl(baseUrl);
|
RsUrl tUrl(baseUrl);
|
||||||
tUrl.setQueryKV(FILES_URL_COUNT_FIELD,
|
tUrl.setQueryKV(FILES_URL_COUNT_FIELD,
|
||||||
std::to_string(tFileTree->mTotalFiles) )
|
std::to_string(tFileTree->mTotalFiles) )
|
||||||
.setQueryKV(FILES_URL_NAME_FIELD, tDirDet.name)
|
.setQueryKV(FILES_URL_NAME_FIELD, dirDetails.name)
|
||||||
.setQueryKV( FILES_URL_SIZE_FIELD,
|
.setQueryKV( FILES_URL_SIZE_FIELD,
|
||||||
std::to_string(tFileTree->mTotalSize) );
|
std::to_string(tFileTree->mTotalSize) );
|
||||||
if(fragSneak)
|
if(fragSneak)
|
||||||
@ -2247,6 +2245,34 @@ std::error_condition ftServer::exportFilesLink(
|
|||||||
return std::error_condition();
|
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(
|
std::error_condition ftServer::parseFilesLink(
|
||||||
const std::string& link, RsFileTree& collection )
|
const std::string& link, RsFileTree& collection )
|
||||||
{
|
{
|
||||||
|
@ -224,11 +224,18 @@ public:
|
|||||||
virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ;
|
virtual TurtleSearchRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) ;
|
||||||
|
|
||||||
/// @see RsFiles
|
/// @see RsFiles
|
||||||
std::error_condition exportFilesLink(
|
std::error_condition exportCollectionLink(
|
||||||
std::string& link, std::uintptr_t handle, bool fragSneak = false,
|
std::string& link, std::uintptr_t handle, bool fragSneak = false,
|
||||||
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL
|
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL
|
||||||
) override;
|
) 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
|
/// @see RsFiles
|
||||||
std::error_condition parseFilesLink(
|
std::error_condition parseFilesLink(
|
||||||
const std::string& link, RsFileTree& collection ) override;
|
const std::string& link, RsFileTree& collection ) override;
|
||||||
@ -383,11 +390,11 @@ protected:
|
|||||||
bool findEncryptedHash(const RsPeerId& virtual_peer_id, RsFileHash& encrypted_hash);
|
bool findEncryptedHash(const RsPeerId& virtual_peer_id, RsFileHash& encrypted_hash);
|
||||||
|
|
||||||
bool checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash);
|
bool checkUploadLimit(const RsPeerId& pid,const RsFileHash& hash);
|
||||||
private:
|
|
||||||
|
|
||||||
/**** INTERNAL FUNCTIONS ***/
|
std::error_condition dirDetailsToLink(
|
||||||
//virtual int reScanDirs();
|
std::string& link,
|
||||||
//virtual int check_dBUpdate();
|
const DirDetails& dirDetails, bool fragSneak,
|
||||||
|
const std::string& baseUrl );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -912,10 +912,10 @@ public:
|
|||||||
static const std::string FILES_URL_SIZE_FIELD;
|
static const std::string FILES_URL_SIZE_FIELD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get link to a forum
|
* @brief Export link to a collection of files
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
* @param[out] link storage for the generated link
|
* @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
|
* @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
|
* 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
|
* http[s] link to pass around a disguised file link a misconfigured host
|
||||||
@ -929,10 +929,26 @@ public:
|
|||||||
* plain base64 format.
|
* plain base64 format.
|
||||||
* @return error information if some error occurred, 0/SUCCESS otherwise
|
* @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,
|
std::string& link, std::uintptr_t handle, bool fragSneak = false,
|
||||||
const std::string& baseUrl = RsFiles::DEFAULT_FILES_BASE_URL ) = 0;
|
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
|
* @brief Parse RetroShare files link
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user