wok-6.x view amule/stuff/libupnp1.8.patch @ rev 21350
amule: add debian libupnp1.8.patch
author | Richard Dunbar <mojo@slitaz.org> |
---|---|
date | Sat Apr 20 15:44:26 2019 -0400 (2019-04-20) |
parents | |
children |
line source
1 --- a/src/UPnPBase.cpp
2 +++ b/src/UPnPBase.cpp
3 @@ -29,22 +29,12 @@
5 #ifdef ENABLE_UPNP
7 -// check for broken Debian-hacked libUPnP
8 #include <upnp.h>
9 -#ifdef STRING_H // defined in UpnpString.h Yes, I would have liked UPNPSTRING_H much better.
10 -#define BROKEN_DEBIAN_LIBUPNP
11 -#endif
13 #include "UPnPBase.h"
15 #include <algorithm> // For transform()
17 -#ifdef BROKEN_DEBIAN_LIBUPNP
18 - #define GET_UPNP_STRING(a) UpnpString_get_String(a)
19 -#else
20 - #define GET_UPNP_STRING(a) (a)
21 -#endif
22 -
23 std::string stdEmptyString;
25 const char s_argument[] = "argument";
26 @@ -1127,7 +1117,7 @@ bool CUPnPControlPoint::PrivateDeletePor
29 // This function is static
30 -int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*Cookie*/)
31 +int CUPnPControlPoint::Callback(Upnp_EventType EventType, const void *Event, void * /*Cookie*/)
32 {
33 std::ostringstream msg;
34 std::ostringstream msg2;
35 @@ -1149,24 +1139,24 @@ int CUPnPControlPoint::Callback(Upnp_Eve
36 msg2<< "UPNP_DISCOVERY_SEARCH_RESULT: ";
37 // UPnP Discovery
38 upnpDiscovery:
39 - struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
40 + UpnpDiscovery *d_event = (UpnpDiscovery *)Event;
41 IXML_Document *doc = NULL;
42 int ret;
43 - if (d_event->ErrCode != UPNP_E_SUCCESS) {
44 - msg << UpnpGetErrorMessage(d_event->ErrCode) << ".";
45 + if (UpnpDiscovery_get_ErrCode(d_event) != UPNP_E_SUCCESS) {
46 + msg << UpnpGetErrorMessage(UpnpDiscovery_get_ErrCode(d_event)) << ".";
47 AddDebugLogLineC(logUPnP, msg);
48 }
49 // Get the XML tree device description in doc
50 - ret = UpnpDownloadXmlDoc(d_event->Location, &doc);
51 + ret = UpnpDownloadXmlDoc(UpnpDiscovery_get_Location_cstr(d_event), &doc);
52 if (ret != UPNP_E_SUCCESS) {
53 msg << "Error retrieving device description from " <<
54 - d_event->Location << ": " <<
55 + UpnpDiscovery_get_Location_cstr(d_event) << ": " <<
56 UpnpGetErrorMessage(ret) <<
57 "(" << ret << ").";
58 AddDebugLogLineC(logUPnP, msg);
59 } else {
60 msg2 << "Retrieving device description from " <<
61 - d_event->Location << ".";
62 + UpnpDiscovery_get_Location_cstr(d_event) << ".";
63 AddDebugLogLineN(logUPnP, msg2);
64 }
65 if (doc) {
66 @@ -1195,7 +1185,7 @@ upnpDiscovery:
67 }
68 // Add the root device to our list
69 upnpCP->AddRootDevice(rootDevice, urlBase,
70 - d_event->Location, d_event->Expires);
71 + UpnpDiscovery_get_Location_cstr(d_event), UpnpDiscovery_get_Expires(d_event));
72 }
73 // Free the XML doc tree
74 IXML::Document::Free(doc);
75 @@ -1216,28 +1206,28 @@ upnpDiscovery:
76 case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: {
77 //fprintf(stderr, "Callback: UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE\n");
78 // UPnP Device Removed
79 - struct Upnp_Discovery *dab_event = (struct Upnp_Discovery *)Event;
80 - if (dab_event->ErrCode != UPNP_E_SUCCESS) {
81 + UpnpDiscovery *dab_event = (UpnpDiscovery *)Event;
82 + if (UpnpDiscovery_get_ErrCode(dab_event) != UPNP_E_SUCCESS) {
83 msg << "error(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE): " <<
84 - UpnpGetErrorMessage(dab_event->ErrCode) <<
85 + UpnpGetErrorMessage(UpnpDiscovery_get_ErrCode(dab_event)) <<
86 ".";
87 AddDebugLogLineC(logUPnP, msg);
88 }
89 - std::string devType = dab_event->DeviceType;
90 + std::string devType = UpnpDiscovery_get_DeviceType_cstr(dab_event);
91 // Check for an InternetGatewayDevice and removes it from the list
92 std::transform(devType.begin(), devType.end(), devType.begin(), tolower);
93 if (stdStringIsEqualCI(devType, UPnP::Device::IGW)) {
94 - upnpCP->RemoveRootDevice(dab_event->DeviceId);
95 + upnpCP->RemoveRootDevice(UpnpDiscovery_get_DeviceID_cstr(dab_event));
96 }
97 break;
98 }
99 case UPNP_EVENT_RECEIVED: {
100 //fprintf(stderr, "Callback: UPNP_EVENT_RECEIVED\n");
101 // Event reveived
102 - struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
103 - const std::string Sid = e_event->Sid;
104 + UpnpEvent *e_event = (UpnpEvent *)Event;
105 + const std::string Sid = UpnpEvent_get_SID_cstr(e_event);
106 // Parses the event
107 - upnpCP->OnEventReceived(Sid, e_event->EventKey, e_event->ChangedVariables);
108 + upnpCP->OnEventReceived(Sid, UpnpEvent_get_EventKey(e_event), UpnpEvent_get_ChangedVariables(e_event));
109 break;
110 }
111 case UPNP_EVENT_SUBSCRIBE_COMPLETE:
112 @@ -1252,16 +1242,15 @@ upnpDiscovery:
113 //fprintf(stderr, "Callback: UPNP_EVENT_RENEWAL_COMPLETE\n");
114 msg << "error(UPNP_EVENT_RENEWAL_COMPLETE): ";
115 upnpEventRenewalComplete:
116 - struct Upnp_Event_Subscribe *es_event =
117 - (struct Upnp_Event_Subscribe *)Event;
118 - if (es_event->ErrCode != UPNP_E_SUCCESS) {
119 + UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
120 + if (UpnpEventSubscribe_get_ErrCode(es_event) != UPNP_E_SUCCESS) {
121 msg << "Error in Event Subscribe Callback";
122 UPnP::ProcessErrorMessage(
123 - msg.str(), es_event->ErrCode, NULL, NULL);
124 + msg.str(), UpnpEventSubscribe_get_ErrCode(es_event), NULL, NULL);
125 } else {
126 #if 0
127 TvCtrlPointHandleSubscribeUpdate(
128 - GET_UPNP_STRING(es_event->PublisherUrl),
129 + UpnpEventSubscribe_get_PublisherUrl_cstr(es_event),
130 es_event->Sid,
131 es_event->TimeOut );
132 #endif
133 @@ -1280,29 +1269,29 @@ upnpEventRenewalComplete:
134 msg << "error(UPNP_EVENT_SUBSCRIPTION_EXPIRED): ";
135 msg2 << "UPNP_EVENT_SUBSCRIPTION_EXPIRED: ";
136 upnpEventSubscriptionExpired:
137 - struct Upnp_Event_Subscribe *es_event =
138 - (struct Upnp_Event_Subscribe *)Event;
139 + UpnpEventSubscribe *es_event = (UpnpEventSubscribe *)Event;
140 Upnp_SID newSID;
141 memset(newSID, 0, sizeof(Upnp_SID));
142 int TimeOut = 1801;
143 int ret = UpnpSubscribe(
144 upnpCP->m_UPnPClientHandle,
145 - GET_UPNP_STRING(es_event->PublisherUrl),
146 +
147 + UpnpEventSubscribe_get_PublisherUrl_cstr(es_event),
148 &TimeOut,
149 newSID);
150 if (ret != UPNP_E_SUCCESS) {
151 msg << "Error Subscribing to EventURL";
152 UPnP::ProcessErrorMessage(
153 - msg.str(), es_event->ErrCode, NULL, NULL);
154 + msg.str(), UpnpEventSubscribe_get_ErrCode(es_event), NULL, NULL);
155 } else {
156 ServiceMap::iterator it =
157 - upnpCP->m_ServiceMap.find(GET_UPNP_STRING(es_event->PublisherUrl));
158 + upnpCP->m_ServiceMap.find(UpnpEventSubscribe_get_PublisherUrl_cstr(es_event));
159 if (it != upnpCP->m_ServiceMap.end()) {
160 CUPnPService &service = *(it->second);
161 service.SetTimeout(TimeOut);
162 service.SetSID(newSID);
163 msg2 << "Re-subscribed to EventURL '" <<
164 - GET_UPNP_STRING(es_event->PublisherUrl) <<
165 + UpnpEventSubscribe_get_PublisherUrl_cstr(es_event) <<
166 "' with SID == '" <<
167 newSID << "'.";
168 AddDebugLogLineC(logUPnP, msg2);
169 @@ -1321,17 +1310,16 @@ upnpEventSubscriptionExpired:
170 case UPNP_CONTROL_ACTION_COMPLETE: {
171 //fprintf(stderr, "Callback: UPNP_CONTROL_ACTION_COMPLETE\n");
172 // This is here if we choose to do this asynchronously
173 - struct Upnp_Action_Complete *a_event =
174 - (struct Upnp_Action_Complete *)Event;
175 - if (a_event->ErrCode != UPNP_E_SUCCESS) {
176 + UpnpActionComplete *a_event = (UpnpActionComplete *)Event;
177 + if (UpnpActionComplete_get_ErrCode(a_event) != UPNP_E_SUCCESS) {
178 UPnP::ProcessErrorMessage(
179 "UpnpSendActionAsync",
180 - a_event->ErrCode, NULL,
181 - a_event->ActionResult);
182 + UpnpActionComplete_get_ErrCode(a_event), NULL,
183 + UpnpActionComplete_get_ActionResult(a_event));
184 } else {
185 // Check the response document
186 UPnP::ProcessActionResponse(
187 - a_event->ActionResult,
188 + UpnpActionComplete_get_ActionResult(a_event),
189 "<UpnpSendActionAsync>");
190 }
191 /* No need for any processing here, just print out results.
192 @@ -1342,12 +1330,11 @@ upnpEventSubscriptionExpired:
193 case UPNP_CONTROL_GET_VAR_COMPLETE: {
194 //fprintf(stderr, "Callback: UPNP_CONTROL_GET_VAR_COMPLETE\n");
195 msg << "error(UPNP_CONTROL_GET_VAR_COMPLETE): ";
196 - struct Upnp_State_Var_Complete *sv_event =
197 - (struct Upnp_State_Var_Complete *)Event;
198 - if (sv_event->ErrCode != UPNP_E_SUCCESS) {
199 + UpnpStateVarComplete *sv_event = (UpnpStateVarComplete *)Event;
200 + if (UpnpStateVarComplete_get_ErrCode(sv_event) != UPNP_E_SUCCESS) {
201 msg << "m_UpnpGetServiceVarStatusAsync";
202 UPnP::ProcessErrorMessage(
203 - msg.str(), sv_event->ErrCode, NULL, NULL);
204 + msg.str(), UpnpStateVarComplete_get_ErrCode(sv_event), NULL, NULL);
205 } else {
206 #if 0
207 // Warning: The use of UpnpGetServiceVarStatus and
208 --- a/src/UPnPBase.h
209 +++ b/src/UPnPBase.h
210 @@ -490,9 +490,19 @@ public:
211 // Callback function
212 static int Callback(
213 Upnp_EventType EventType,
214 - void* Event,
215 + const void* Event,
216 void* Cookie);
218 +#if UPNP_VERSION < 10800
219 + /* in libupnp 1.6 Event is not const */
220 + static int Callback(
221 + Upnp_EventType EventType,
222 + void* Event,
223 + void* Cookie) {
224 + return Callback(EventType, (const void *)Event, Cookie);
225 + }
226 +#endif
227 +
228 private:
229 void OnEventReceived(
230 const std::string &Sid,
231 --- a/configure.in
232 +++ b/configure.in
233 @@ -220,7 +220,7 @@ MULE_ARG_ENABLE([upnp], [yes], [do not c
234 MULE_IF_ENABLED_ANY([monolithic, amule-daemon],, [MULE_ENABLEVAR([upnp])=no])
235 MULE_IF_ENABLED([upnp], [
236 LIBUPNP_CHECK(
237 - [1.6.6],
238 + [1.6.24],
239 [MULE_APPEND([LIBUPNP_CPPFLAGS], [-DENABLE_UPNP=1])],
240 [MULE_ENABLEVAR([upnp])=disabled
241 MULE_WARNING([UPnP code has been disabled because ${libupnp_error}.])]