Merge branch 'development' into LTS_development

# Conflicts:
#	src/controller/controller_streams.cpp
This commit is contained in:
Thulinma 2017-05-09 13:27:07 +02:00
commit 4f1e653c44
4 changed files with 30 additions and 0 deletions

View file

@ -1294,6 +1294,20 @@ void JSON::Value::removeMember(const std::map<std::string, Value*>::iterator & i
objVal.erase(it);
}
void JSON::Value::removeNullMembers(){
bool again = true;
while (again){
again = false;
jsonForEach(*this, m){
if (m.key().size() && m->isNull()){
removeMember(m.key());
again = true;
break;
}
}
}
}
/// For object JSON::Value objects, returns true if the
/// given name is a member. Returns false otherwise.
bool JSON::Value::isMember(const std::string & name) const {

View file

@ -84,6 +84,7 @@ namespace JSON {
void removeMember(const std::string & name);
void removeMember(const std::deque<Value*>::iterator & it);
void removeMember(const std::map<std::string, Value*>::iterator & it);
void removeNullMembers();
bool isMember(const std::string & name) const;
bool isInt() const;
bool isString() const;

View file

@ -213,6 +213,9 @@ void Controller::handleUDPAPI(void * np){
/// Local-only helper function that checks for duplicate protocols and removes them
static void removeDuplicateProtocols(){
JSON::Value & P = Controller::Storage["config"]["protocols"];
jsonForEach(P, it){
it->removeNullMembers();
}
std::set<std::string> ignores;
ignores.insert("online");
bool reloop = true;

View file

@ -189,10 +189,21 @@ namespace Controller {
}
/*LTS-END*/
out[jit.key()] = (*jit);
out[jit.key()].removeNullMembers();
out[jit.key()]["name"] = jit.key();
Log("STRM", std::string("Updated stream ") + jit.key());
}
}else{
std::string checked = jit.key();
Util::sanitizeName(checked);
if (checked != jit.key() || !checked.size()){
if (!checked.size()){
FAIL_MSG("Invalid stream name '%s'", jit.key().c_str());
}else{
FAIL_MSG("Invalid stream name '%s'. Suggested alternative: '%s'", jit.key().c_str(), checked.c_str());
}
continue;
}
/*LTS-START*/
if(Triggers::shouldTrigger("STREAM_ADD")){
std::string payload = jit.key()+"\n"+jit->toString();
@ -202,6 +213,7 @@ namespace Controller {
}
/*LTS-END*/
out[jit.key()] = (*jit);
out[jit.key()].removeNullMembers();
out[jit.key()]["name"] = jit.key();
Log("STRM", std::string("New stream ") + jit.key());
}