-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98cd676
commit cc21252
Showing
73 changed files
with
832 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*GRB* | ||
Gerbera - https://gerbera.io/ | ||
cds_container.cc - this file is part of Gerbera. | ||
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> | ||
Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, | ||
Leonhard Wimmer <leo@mediatomb.cc> | ||
Copyright (C) 2016-2022 Gerbera Contributors | ||
Gerbera is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 | ||
as published by the Free Software Foundation. | ||
Gerbera is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Gerbera. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/// \file cds_container.cc | ||
|
||
#include "cds_container.h" // API | ||
|
||
#include "util/grb_time.h" | ||
|
||
CdsContainer::CdsContainer() | ||
{ | ||
objectType = OBJECT_TYPE_CONTAINER; | ||
upnpClass = UPNP_CLASS_CONTAINER; | ||
mtime = currentTime(); | ||
} | ||
|
||
void CdsContainer::copyTo(const std::shared_ptr<CdsObject>& obj) | ||
{ | ||
CdsObject::copyTo(obj); | ||
if (!obj->isContainer()) | ||
return; | ||
auto cont = std::static_pointer_cast<CdsContainer>(obj); | ||
cont->setUpdateID(updateID); | ||
} | ||
bool CdsContainer::equals(const std::shared_ptr<CdsObject>& obj, bool exactly) const | ||
{ | ||
auto cont = std::static_pointer_cast<CdsContainer>(obj); | ||
return CdsObject::equals(obj, exactly) && isSearchable() == cont->isSearchable(); | ||
} | ||
|
||
/* | ||
void CdsContainer::validate() const | ||
{ | ||
CdsObject::validate(); | ||
/// \todo well.. we have to know if a container is a real directory or just a virtual container in the database | ||
if (!fs::is_directory(this->location, true)) | ||
throw_std_runtime_error("validation failed"); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*GRB* | ||
Gerbera - https://gerbera.io/ | ||
cds_container.h - this file is part of Gerbera. | ||
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> | ||
Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, | ||
Leonhard Wimmer <leo@mediatomb.cc> | ||
Copyright (C) 2016-2022 Gerbera Contributors | ||
Gerbera is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 | ||
as published by the Free Software Foundation. | ||
Gerbera is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Gerbera. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/// \file cds_container.h | ||
/// \brief Definition for the CdsContainer class. | ||
#ifndef __CDS_CONTAINER_H__ | ||
#define __CDS_CONTAINER_H__ | ||
|
||
#include "cds_objects.h" | ||
|
||
/// \brief A container in the content directory. | ||
class CdsContainer final : public CdsObject { | ||
protected: | ||
/// \brief container update id. | ||
int updateID {}; | ||
|
||
/// \brief childCount attribute | ||
int childCount { -1 }; | ||
|
||
/// \brief whether this container is an autoscan start point. | ||
int autoscanType { OBJECT_AUTOSCAN_NONE }; | ||
|
||
public: | ||
/// \brief Constructor, initializes default values for the flags and sets the object type. | ||
CdsContainer(); | ||
explicit CdsContainer(const std::string& title, const std::string& upnpClass = UPNP_CLASS_CONTAINER) | ||
{ | ||
this->title = title; | ||
this->upnpClass = upnpClass; | ||
} | ||
|
||
bool isContainer() const override { return true; } | ||
|
||
/// \brief Set the searchable flag. | ||
void setSearchable(bool searchable) { changeFlag(OBJECT_FLAG_SEARCHABLE, searchable); } | ||
|
||
/// \brief Query searchable flag. | ||
int isSearchable() const { return getFlag(OBJECT_FLAG_SEARCHABLE); } | ||
|
||
/// \brief Set the container update ID value. | ||
void setUpdateID(int updateID) { this->updateID = updateID; } | ||
|
||
/// \brief Query container update ID value. | ||
int getUpdateID() const { return updateID; } | ||
|
||
/// \brief Set container childCount attribute. | ||
void setChildCount(int childCount) { this->childCount = childCount; } | ||
|
||
/// \brief Retrieve number of children | ||
int getChildCount() const { return childCount; } | ||
|
||
/// \brief returns whether this container is an autoscan start point. | ||
int getAutoscanType() const { return autoscanType; } | ||
|
||
/// \brief sets whether this container is an autoscan start point. | ||
void setAutoscanType(int type) { autoscanType = type; } | ||
|
||
/// \brief Copies all object properties to another object. | ||
/// \param obj target object (clone) | ||
void copyTo(const std::shared_ptr<CdsObject>& obj) override; | ||
|
||
/// \brief Checks if current object is equal to obj. | ||
/// | ||
/// See description for CdsObject::equals() for details. | ||
bool equals(const std::shared_ptr<CdsObject>& obj, bool exactly = false) const override; | ||
/* | ||
/// \brief Checks if the minimum required parameters for the object have been set and are valid. | ||
void validate() const override; | ||
*/ | ||
}; | ||
|
||
#endif // __CDS_CONTAINER_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/*GRB* | ||
Gerbera - https://gerbera.io/ | ||
cds_item.cc - this file is part of Gerbera. | ||
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> | ||
Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>, | ||
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>, | ||
Leonhard Wimmer <leo@mediatomb.cc> | ||
Copyright (C) 2016-2022 Gerbera Contributors | ||
Gerbera is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 | ||
as published by the Free Software Foundation. | ||
Gerbera is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Gerbera. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/// \file cds_item.cc | ||
|
||
#include "cds_item.h" // API | ||
|
||
#include <array> | ||
#include <numeric> | ||
|
||
#include "util/grb_time.h" | ||
#include "util/upnp_clients.h" | ||
|
||
CdsItem::CdsItem() | ||
{ | ||
objectType = OBJECT_TYPE_ITEM; | ||
upnpClass = "object.item"; | ||
mtime = currentTime(); | ||
} | ||
|
||
void CdsItem::copyTo(const std::shared_ptr<CdsObject>& obj) | ||
{ | ||
CdsObject::copyTo(obj); | ||
if (!obj->isItem()) | ||
return; | ||
auto item = std::static_pointer_cast<CdsItem>(obj); | ||
// item->setDescription(description); | ||
item->setMimeType(mimeType); | ||
item->setTrackNumber(trackNumber); | ||
item->setPartNumber(partNumber); | ||
item->setServiceID(serviceID); | ||
if (playStatus) | ||
item->setPlayStatus(playStatus->clone()); | ||
} | ||
|
||
bool CdsItem::equals(const std::shared_ptr<CdsObject>& obj, bool exactly) const | ||
{ | ||
auto item = std::static_pointer_cast<CdsItem>(obj); | ||
if (!CdsObject::equals(obj, exactly)) | ||
return false; | ||
return (mimeType == item->getMimeType() && partNumber == item->getPartNumber() && trackNumber == item->getTrackNumber() && serviceID == item->getServiceID()); | ||
} | ||
|
||
void CdsItem::validate() const | ||
{ | ||
CdsObject::validate(); | ||
// log_info("mime: [{}] loc [{}]", this->mimeType.c_str(), this->location.c_str()); | ||
if (this->mimeType.empty()) | ||
throw_std_runtime_error("Item validation failed: missing mimetype"); | ||
|
||
if (this->location.empty()) | ||
throw_std_runtime_error("Item validation failed: missing location"); | ||
|
||
if (isExternalItem()) | ||
return; | ||
|
||
std::error_code ec; | ||
if (!isRegularFile(location, ec)) | ||
throw_std_runtime_error("Item validation failed: file {} not found", location.c_str()); | ||
} | ||
|
||
//--------- | ||
|
||
CdsItemExternalURL::CdsItemExternalURL() | ||
{ | ||
objectType |= OBJECT_TYPE_ITEM_EXTERNAL_URL; | ||
|
||
upnpClass = UPNP_CLASS_ITEM; | ||
} | ||
|
||
void CdsItemExternalURL::validate() const | ||
{ | ||
CdsItem::validate(); | ||
if (this->mimeType.empty()) | ||
throw_std_runtime_error("URL Item validation failed: missing mimetype"); | ||
|
||
if (this->location.empty()) | ||
throw_std_runtime_error("URL Item validation failed: missing URL"); | ||
} |
Oops, something went wrong.