diff options
author | Alasdair Campbell <alcoheca@gmail.com> | 2012-10-11 04:03:10 -0700 |
---|---|---|
committer | Alasdair Campbell <alcoheca@gmail.com> | 2012-10-11 04:03:10 -0700 |
commit | 59ca8732710dff84330672a0b3bcb826477b7c50 (patch) | |
tree | ce533877e5dd266258a23974e7755d2e9f693a31 /lib | |
parent | 70205b08fcae1fffbcb28d6eaa9c189262ea087e (diff) | |
parent | 7e139d57983add79a07b1ed369ee5525ad33ba28 (diff) |
Merge pull request #1582 from alcoheca/upnp-cache-notify
Upnp cache notify
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libUPnP/Platinum/Source/Core/PltService.cpp | 11 | ||||
-rw-r--r-- | lib/libUPnP/Platinum/Source/Core/PltService.h | 3 | ||||
-rw-r--r-- | lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp | 16 | ||||
-rw-r--r-- | lib/libUPnP/Platinum/Source/Core/PltStateVariable.h | 10 |
4 files changed, 34 insertions, 6 deletions
diff --git a/lib/libUPnP/Platinum/Source/Core/PltService.cpp b/lib/libUPnP/Platinum/Source/Core/PltService.cpp index 3280b150ab..62bdc49741 100644 --- a/lib/libUPnP/Platinum/Source/Core/PltService.cpp +++ b/lib/libUPnP/Platinum/Source/Core/PltService.cpp @@ -460,14 +460,14 @@ PLT_Service::IsSubscribable() | PLT_Service::SetStateVariable +---------------------------------------------------------------------*/ NPT_Result -PLT_Service::SetStateVariable(const char* name, const char* value) +PLT_Service::SetStateVariable(const char* name, const char* value, const bool clearonsend /*=false*/) { PLT_StateVariable* stateVariable = NULL; NPT_ContainerFind(m_StateVars, PLT_StateVariableNameFinder(name), stateVariable); if (stateVariable == NULL) return NPT_FAILURE; - return stateVariable->SetValue(value); + return stateVariable->SetValue(value, clearonsend); } /*---------------------------------------------------------------------- @@ -838,6 +838,13 @@ PLT_Service::NotifyChanged() delete sub; } + // some state variables must be cleared immediatly after sending + iter = vars_ready.GetFirstItem(); + while (iter) { + PLT_StateVariable* var = *iter; + var->OnSendCompleted(); + ++iter; + } return NPT_SUCCESS; } diff --git a/lib/libUPnP/Platinum/Source/Core/PltService.h b/lib/libUPnP/Platinum/Source/Core/PltService.h index c03a552f67..9bd4d1268f 100644 --- a/lib/libUPnP/Platinum/Source/Core/PltService.h +++ b/lib/libUPnP/Platinum/Source/Core/PltService.h @@ -216,8 +216,9 @@ public: when necessary. @param name state variable name @param value new State Variable value. + @param clearonsend whether the State Variable should clear immediatly in ::OnSendingCompleted */ - NPT_Result SetStateVariable(const char* name, const char* value); + NPT_Result SetStateVariable(const char* name, const char* value, const bool clearonsend = false); /** Certain state variables notifications must not be sent faster than a certain diff --git a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp index 229e3044dd..47aeb5a453 100644 --- a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp +++ b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp @@ -48,7 +48,8 @@ NPT_SET_LOCAL_LOGGER("platinum.core.statevariable") PLT_StateVariable::PLT_StateVariable(PLT_Service* service) : m_Service(service), m_AllowedValueRange(NULL), - m_IsSendingEventsIndirectly(true) + m_IsSendingEventsIndirectly(true), + m_ShouldClearOnSend(false) { } @@ -145,7 +146,7 @@ PLT_StateVariable::SetRate(NPT_TimeInterval rate) | PLT_StateVariable::SetValue +---------------------------------------------------------------------*/ NPT_Result -PLT_StateVariable::SetValue(const char* value) +PLT_StateVariable::SetValue(const char* value, const bool clearonsend /*=false*/) { if (value == NULL) { return NPT_FAILURE; @@ -159,6 +160,7 @@ PLT_StateVariable::SetValue(const char* value) } m_Value = value; + m_ShouldClearOnSend = clearonsend; m_Service->AddChanged(this); } @@ -183,6 +185,16 @@ PLT_StateVariable::IsReadyToPublish() } /*---------------------------------------------------------------------- +| PLT_StateVariable::OnSendCompleted ++---------------------------------------------------------------------*/ +void +PLT_StateVariable::OnSendCompleted() +{ + if(m_ShouldClearOnSend) + m_Value = m_DefaultValue; +} + +/*---------------------------------------------------------------------- | PLT_StateVariable::ValidateValue +---------------------------------------------------------------------*/ NPT_Result diff --git a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h index 46ec9e95a3..465e95cfeb 100644 --- a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h +++ b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h @@ -115,8 +115,9 @@ public: it is an allowed value. Once the value is validated, it is marked for eventing by calling the PLT_Service AddChanged function. @param value new state variable value. Can be a comma separated list of values. + @param clearonsend whether the statevariable should be cleared immediatly after sending */ - NPT_Result SetValue(const char* value); + NPT_Result SetValue(const char* value, const bool clearonsend = false); /** Validate the new value of the state variable. @@ -173,6 +174,12 @@ protected: bool IsReadyToPublish(); /** + * If this statevariable should clear after sending to all subscribers, clears the value without + * eventing the change + */ + void OnSendCompleted(); + + /** Serialize the state variable into xml. */ NPT_Result Serialize(NPT_XmlElementNode& node); @@ -189,6 +196,7 @@ protected: NPT_String m_DefaultValue; bool m_IsSendingEvents; bool m_IsSendingEventsIndirectly; + bool m_ShouldClearOnSend; NPT_TimeInterval m_Rate; NPT_TimeStamp m_LastEvent; NPT_Array<NPT_String*> m_AllowedValues; |