From 64cf13cdf7bf1fe570a1db8b06ee43fcfecd7865 Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Wed, 5 Oct 2005 20:13:56 +0000 Subject: [PATCH] Sending a response when there is a zeroconf request (100 not implemented) --- src/gui/guiframework.cpp | 8 +++++++- src/gui/guiframework.h | 4 +++- src/gui/server/requestconfig.cpp | 9 +++++---- src/gui/server/requestconfig.h | 1 + src/managerimpl.cpp | 6 ++++-- src/managerimpl.h | 2 +- src/observer.cpp | 4 +++- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/gui/guiframework.cpp b/src/gui/guiframework.cpp index 06baf09a96..19f122b96b 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 725b40c7cc..2693a8b937 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 358a7e35be..d9fc2da89e 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 5a5a577d7f..f2d05a1c8d 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 c8c8424150..3f628de698 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 853b9d720f..4cb2a5052a 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 717a4ca2f5..022c3316a5 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++; } } -- GitLab