wok annotate amule/stuff/libupnp1.8.patch @ rev 23381

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