Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / patches / 0008-platinum-allow-some-statevariables-to-reset-to-defau.patch
blob8841447ad7ce60e67b94182dfa6bc180e37648bc
1 From 73a60837afb1a0ddf03ac500665c28853d95dca8 Mon Sep 17 00:00:00 2001
2 From: Alasdair Campbell <alcoheca@gmail.com>
3 Date: Tue, 9 Oct 2012 10:14:39 +0100
4 Subject: [PATCH 08/24] platinum: allow some statevariables to reset to
5 default value after sending completed (needed for
6 ContainerUpdateIDs usage)
8 ---
9 lib/libUPnP/Platinum/Source/Core/PltService.cpp | 11 +++++++++--
10 lib/libUPnP/Platinum/Source/Core/PltService.h | 3 ++-
11 lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp | 16 ++++++++++++++--
12 lib/libUPnP/Platinum/Source/Core/PltStateVariable.h | 10 +++++++++-
13 4 files changed, 34 insertions(+), 6 deletions(-)
15 diff --git a/lib/libUPnP/Platinum/Source/Core/PltService.cpp b/lib/libUPnP/Platinum/Source/Core/PltService.cpp
16 index b1fec51..b86fb23 100644
17 --- a/lib/libUPnP/Platinum/Source/Core/PltService.cpp
18 +++ b/lib/libUPnP/Platinum/Source/Core/PltService.cpp
19 @@ -459,14 +459,14 @@ PLT_Service::IsSubscribable()
20 | PLT_Service::SetStateVariable
21 +---------------------------------------------------------------------*/
22 NPT_Result
23 -PLT_Service::SetStateVariable(const char* name, const char* value)
24 +PLT_Service::SetStateVariable(const char* name, const char* value, const bool clearonsend /*=false*/)
26 PLT_StateVariable* stateVariable = NULL;
27 NPT_ContainerFind(m_StateVars, PLT_StateVariableNameFinder(name), stateVariable);
28 if (stateVariable == NULL)
29 return NPT_FAILURE;
31 - return stateVariable->SetValue(value);
32 + return stateVariable->SetValue(value, clearonsend);
35 /*----------------------------------------------------------------------
36 @@ -835,6 +835,13 @@ PLT_Service::NotifyChanged()
37 m_Subscribers.Erase(sub_iter++);
40 + // some state variables must be cleared immediatly after sending
41 + iter = vars_ready.GetFirstItem();
42 + while (iter) {
43 + PLT_StateVariable* var = *iter;
44 + var->OnSendCompleted();
45 + ++iter;
46 + }
47 return NPT_SUCCESS;
50 diff --git a/lib/libUPnP/Platinum/Source/Core/PltService.h b/lib/libUPnP/Platinum/Source/Core/PltService.h
51 index 84959f2..0401ea2 100644
52 --- a/lib/libUPnP/Platinum/Source/Core/PltService.h
53 +++ b/lib/libUPnP/Platinum/Source/Core/PltService.h
54 @@ -216,8 +216,9 @@ public:
55 when necessary.
56 @param name state variable name
57 @param value new State Variable value.
58 + @param clearonsend whether the State Variable should clear immediatly in ::OnSendingCompleted
60 - NPT_Result SetStateVariable(const char* name, const char* value);
61 + NPT_Result SetStateVariable(const char* name, const char* value, const bool clearonsend = false);
63 /**
64 Certain state variables notifications must not be sent faster than a certain
65 diff --git a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp
66 index c3eb7cc..d38392e 100644
67 --- a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp
68 +++ b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.cpp
69 @@ -49,7 +49,8 @@ PLT_StateVariable::PLT_StateVariable(PLT_Service* service) :
70 m_Service(service),
71 m_AllowedValueRange(NULL),
72 m_IsSendingEvents(false),
73 - m_IsSendingEventsIndirectly(true)
74 + m_IsSendingEventsIndirectly(true),
75 + m_ShouldClearOnSend(false)
79 @@ -146,7 +147,7 @@ PLT_StateVariable::SetRate(NPT_TimeInterval rate)
80 | PLT_StateVariable::SetValue
81 +---------------------------------------------------------------------*/
82 NPT_Result
83 -PLT_StateVariable::SetValue(const char* value)
84 +PLT_StateVariable::SetValue(const char* value, const bool clearonsend /*=false*/)
86 if (value == NULL) {
87 return NPT_FAILURE;
88 @@ -160,6 +161,7 @@ PLT_StateVariable::SetValue(const char* value)
91 m_Value = value;
92 + m_ShouldClearOnSend = clearonsend;
93 m_Service->AddChanged(this);
96 @@ -184,6 +186,16 @@ PLT_StateVariable::IsReadyToPublish()
99 /*----------------------------------------------------------------------
100 +| PLT_StateVariable::OnSendCompleted
101 ++---------------------------------------------------------------------*/
102 +void
103 +PLT_StateVariable::OnSendCompleted()
105 + if(m_ShouldClearOnSend)
106 + m_Value = m_DefaultValue;
109 +/*----------------------------------------------------------------------
110 | PLT_StateVariable::ValidateValue
111 +---------------------------------------------------------------------*/
112 NPT_Result
113 diff --git a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h
114 index 46ec9e9..465e95c 100644
115 --- a/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h
116 +++ b/lib/libUPnP/Platinum/Source/Core/PltStateVariable.h
117 @@ -115,8 +115,9 @@ public:
118 it is an allowed value. Once the value is validated, it is marked for eventing by
119 calling the PLT_Service AddChanged function.
120 @param value new state variable value. Can be a comma separated list of values.
121 + @param clearonsend whether the statevariable should be cleared immediatly after sending
123 - NPT_Result SetValue(const char* value);
124 + NPT_Result SetValue(const char* value, const bool clearonsend = false);
127 Validate the new value of the state variable.
128 @@ -173,6 +174,12 @@ protected:
129 bool IsReadyToPublish();
132 + * If this statevariable should clear after sending to all subscribers, clears the value without
133 + * eventing the change
134 + */
135 + void OnSendCompleted();
137 + /**
138 Serialize the state variable into xml.
140 NPT_Result Serialize(NPT_XmlElementNode& node);
141 @@ -189,6 +196,7 @@ protected:
142 NPT_String m_DefaultValue;
143 bool m_IsSendingEvents;
144 bool m_IsSendingEventsIndirectly;
145 + bool m_ShouldClearOnSend;
146 NPT_TimeInterval m_Rate;
147 NPT_TimeStamp m_LastEvent;
148 NPT_Array<NPT_String*> m_AllowedValues;
150 1.7.11.msysgit.0