Example #1
0
void FilelistApi::on(DirectoryListingManagerListener::ListingClosed, const DirectoryListingPtr& aList) noexcept {
    removeSubModule(aList->getUser()->getCID());

    if (!subscriptionActive("filelist_removed")) {
        return;
    }

    send("filelist_removed", {
        { "id", aList->getUser()->getCID().toBase32() }
    });
}
Example #2
0
json FilelistApi::serializeList(const DirectoryListingPtr& aList) noexcept {
    int64_t totalSize = -1;
    size_t totalFiles = -1;
    aList->getPartialListInfo(totalSize, totalFiles);

    return{
        { "id", aList->getUser()->getCID().toBase32() },
        { "user", Serializer::serializeHintedUser(aList->getHintedUser()) },
        { "state", FilelistInfo::serializeState(aList) },
        { "location", FilelistInfo::serializeLocation(aList) },
        { "partial", aList->getPartialList() },
        { "total_files", totalFiles },
        { "total_size", totalSize },
        { "read", aList->isRead() },
        { "share_profile", aList->getIsOwnList() ? Serializer::serializeShareProfileSimple(aList->getShareProfile()) : json() },
    };
}