diff --git a/src/gui/guiframework.cpp b/src/gui/guiframework.cpp index 06baf09a9608340adbd8cb2899cfa53a9c5f48bd..19f122b96bfa752550e3e556f6430680344085b5 100644 --- a/src/gui/guiframework.cpp +++ b/src/gui/guiframework.cpp @@ -216,11 +216,17 @@ GuiFramework::getZeroconf(const std::string& sequenceId) } bool -GuiFramework::attachZeroconfEvents(const std::string& sequenceId, Observer& observer) +GuiFramework::attachZeroconfEvents(const std::string& sequenceId, Pattern::Observer& observer) { return Manager::instance().attachZeroconfEvents(sequenceId, observer); } +bool +GuiFramework::detachZeroconfEvents(Pattern::Observer& observer) +{ + return Manager::instance().detachZeroconfEvents(observer); +} + bool GuiFramework::getCallStatus(const std::string& sequenceId) { diff --git a/src/gui/guiframework.h b/src/gui/guiframework.h index 725b40c7cc741c701197602702752f2e3cad1698..2693a8b9379f211f82880b9497da6ee46bfaef4a 100644 --- a/src/gui/guiframework.h +++ b/src/gui/guiframework.h @@ -25,6 +25,7 @@ #include <string> #include "server/argtokenizer.h" +#include "../observer.h" class GuiFramework { public: @@ -81,7 +82,8 @@ public: // config bool getZeroconf(const std::string& sequenceId); - bool attachZeroconfEvents(const std::string& sequenceId, Observer& observer); + bool attachZeroconfEvents(const std::string& sequenceId, Pattern::Observer& observer); + bool detachZeroconfEvents(Pattern::Observer& observer); bool getCallStatus(const std::string& sequenceId); bool getConfigAll(const std::string& sequenceId); bool getConfig(const std::string& section, const std::string& name, TokenList& arg); diff --git a/src/gui/server/requestconfig.cpp b/src/gui/server/requestconfig.cpp index 358a7e35be8324eb6979b651b28ff87b661593bd..d9fc2da89ed39e49bc4bcfe385e9ed2d98b40503 100644 --- a/src/gui/server/requestconfig.cpp +++ b/src/gui/server/requestconfig.cpp @@ -42,7 +42,7 @@ ResponseMessage RequestZeroconfEvent::execute() { if (GUIServer::instance().attachZeroconfEvents(_sequenceId, *this)) { - return message("200", "OK"); + return message("000", "Zeroconf Events are running"); } else { return message("501","Zeroconf not enabled or activated"); } @@ -50,13 +50,14 @@ RequestZeroconfEvent::execute() RequestZeroconfEvent::~RequestZeroconfEvent() { - GUIServer::instance.removeZeroconfEvents(*this); + GUIServer::instance().detachZeroconfEvents(*this); } -ResponseMessage +void RequestZeroconfEvent::update() { - return message("100", "New Zeroconf events - Not Implemented"); + TokenList tk; tk.push_back("New Zeroconf events - Not Implemented"); + GUIServer::instance().sendMessage("100", _sequenceId, tk); } ResponseMessage diff --git a/src/gui/server/requestconfig.h b/src/gui/server/requestconfig.h index 5a5a577d7f00be167438d007843975079f96d93e..f2d05a1c8d4a71b455873a4fc9d8c098982d86c0 100644 --- a/src/gui/server/requestconfig.h +++ b/src/gui/server/requestconfig.h @@ -41,6 +41,7 @@ public: RequestZeroconfEvent(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList) {} ~RequestZeroconfEvent(); ResponseMessage execute(); + void update(); }; diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index c8c8424150e81392e53fdfc45d4aa92427ecb7dd..3f628de698c84cd4db6ba3822b0e6b4e1fab67f9 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1340,8 +1340,10 @@ ManagerImpl::detachZeroconfEvents(Pattern::Observer& observer) { bool returnValue = false; #ifdef USE_ZEROCONF - _DNSService->detach(observer); - returnValue = true; + if (_DNSService) { + _DNSService->detach(observer); + returnValue = true; + } #endif return returnValue; } diff --git a/src/managerimpl.h b/src/managerimpl.h index 853b9d720f1ada70c46b7d2c70a989f4cafa6802..4cb2a5052ae503eca0ba364ddd5451bbd49f9869 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -192,7 +192,7 @@ public: // configuration function requests bool getZeroconf(const std::string& sequenceId); bool attachZeroconfEvents(const std::string& sequenceId, Pattern::Observer& observer); - bool removeZeroconfEvents(Pattern::Observer& observer); + bool detachZeroconfEvents(Pattern::Observer& observer); bool getCallStatus(const std::string& sequenceId); bool getConfigAll(const std::string& sequenceId); bool getConfig(const std::string& section, const std::string& name, TokenList& arg); diff --git a/src/observer.cpp b/src/observer.cpp index 717a4ca2f5a9c5a179fd8102249a8e37c2116cf7..022c3316a50dfc2c2c4636c56e6325e2c3347cb9 100644 --- a/src/observer.cpp +++ b/src/observer.cpp @@ -43,7 +43,9 @@ Subject::notify() { std::list<Observer*>::iterator iter = _observers.begin(); while( iter != _observers.end()) { - (*iter)->update(); + if (*iter) { + (*iter)->update(); + } iter++; } }