Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / patches / 0045-platinum-win10-uwp-fixes.patch
blob22034321a2f4f28ce0f3b585ee8e34f154ed2285
1 From 78d3d7f7abec5e0d76d7efa92b226b5236a7bbea Mon Sep 17 00:00:00 2001
2 From: Dale Stammen <dalestam@microsoft.com>
3 Date: Fri, 2 Jun 2017 16:34:58 +0300
4 Subject: [PATCH] [win10] uwp fixes libUPnP
6 ---
7 lib/libUPnP/Neptune/Source/Core/NptConfig.h | 13 ++++++++++
8 lib/libUPnP/Neptune/Source/Core/NptUtils.cpp | 30 ++++++++++++++++++++++
9 lib/libUPnP/Neptune/Source/Core/NptUtils.h | 7 +++++
10 .../Source/System/StdC/NptStdcEnvironment.cpp | 2 +-
11 .../System/Win32/NptWin32DynamicLibraries.cpp | 4 +++
12 .../Source/System/Win32/NptWin32MessageQueue.cpp | 3 ++-
13 .../Source/System/Win32/NptWin32MessageQueue.h | 3 +++
14 .../Neptune/Source/System/Win32/NptWin32Queue.cpp | 6 ++---
15 .../Source/System/Win32/NptWin32SerialPort.cpp | 2 ++
16 9 files changed, 65 insertions(+), 5 deletions(-)
18 diff --git a/lib/libUPnP/Neptune/Source/Core/NptConfig.h b/lib/libUPnP/Neptune/Source/Core/NptConfig.h
19 index d51f67f94e..130d5cc33b 100644
20 --- a/lib/libUPnP/Neptune/Source/Core/NptConfig.h
21 +++ b/lib/libUPnP/Neptune/Source/Core/NptConfig.h
22 @@ -60,6 +60,11 @@
23 #define NPT_CONFIG_HAVE_GETENV
24 #define NPT_CONFIG_HAVE_SETENV
25 #define NPT_CONFIG_HAVE_UNSETENV
26 +#if defined(TARGET_WINDOWS_STORE)
27 +#undef NPT_CONFIG_HAVE_GETENV
28 +#undef NPT_CONFIG_HAVE_SETENV
29 +#undef NPT_CONFIG_HAVE_UNSETENV
30 +#endif
31 #define NPT_CONFIG_HAVE_READDIR_R
32 #endif /* NPT_CONFIG_HAS_STD_C */
34 @@ -240,12 +245,20 @@ typedef long NPT_PointerLong;
35 #define NPT_strncpy(d,s,c) strncpy_s(d,c+1,s,c)
36 #define NPT_strcpy(d,s) strcpy_s(d,strlen(s)+1,s)
37 #undef NPT_CONFIG_HAVE_GETENV
38 +#ifdef TARGET_WINDOWS_STORE
39 +#undef NPT_CONFIG_HAVE_GETENV
40 +#undef NPT_CONFIG_HAVE_DUPENV_S
41 +#undef NPT_CONFIG_HAVE_SETENV
42 +#undef NPT_CONFIG_HAVE_UNSETENV
43 +#undef NPT_CONFIG_HAVE_PUTENV_S
44 +#else
45 #define NPT_CONFIG_HAVE_DUPENV_S
46 #define dupenv_s _dupenv_s
47 #undef NPT_CONFIG_HAVE_SETENV
48 #undef NPT_CONFIG_HAVE_UNSETENV
49 #define NPT_CONFIG_HAVE_PUTENV_S
50 #define putenv_s _putenv_s
51 +#endif
52 #else
53 #undef NPT_CONFIG_HAVE_GMTIME_R
54 #undef NPT_CONFIG_HAVE_LOCALTIME_R
55 diff --git a/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp b/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp
56 index a68a1afeaf..d98710dc12 100644
57 --- a/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp
58 +++ b/lib/libUPnP/Neptune/Source/Core/NptUtils.cpp
59 @@ -44,6 +44,12 @@
60 #include <limits.h>
61 #endif
63 +#ifdef TARGET_WINDOWS_STORE
64 +#ifndef WIN32_LEAN_AND_MEAN
65 +#define WIN32_LEAN_AND_MEAN 1
66 +#endif
67 +#include <windows.h>
68 +#endif
69 /*----------------------------------------------------------------------
70 | constants
71 +---------------------------------------------------------------------*/
72 @@ -925,3 +931,27 @@ NPT_ParseMimeParameters(const char* encoded,
73 return NPT_SUCCESS;
76 +#ifdef TARGET_WINDOWS_STORE
77 +std::wstring win32ConvertUtf8ToW(const std::string &text)
79 + if (text.empty())
80 + {
81 + return L"";
82 + }
84 + int bufSize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, NULL, 0);
85 + if (bufSize == 0)
86 + return L"";
87 + wchar_t *converted = new wchar_t[bufSize];
88 + if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, converted, bufSize) != bufSize)
89 + {
90 + delete[] converted;
91 + return L"";
92 + }
94 + std::wstring Wret(converted);
95 + delete[] converted;
97 + return Wret;
99 +#endif
100 diff --git a/lib/libUPnP/Neptune/Source/Core/NptUtils.h b/lib/libUPnP/Neptune/Source/Core/NptUtils.h
101 index 3a06d497f4..89b2e29812 100644
102 --- a/lib/libUPnP/Neptune/Source/Core/NptUtils.h
103 +++ b/lib/libUPnP/Neptune/Source/Core/NptUtils.h
104 @@ -54,6 +54,9 @@
105 #include <stdarg.h>
106 #endif
108 +#if defined(TARGET_WINDOWS_STORE)
109 +#include <string>
110 +#endif
111 /*----------------------------------------------------------------------
112 | macros
113 +---------------------------------------------------------------------*/
114 @@ -225,4 +228,8 @@ extern void NPT_SetMemory(void* dest, int c, NPT_Size size);
115 extern int NPT_MemoryEqual(const void* s1, const void* s2, unsigned long n);
116 #endif
118 +#if defined(TARGET_WINDOWS_STORE)
119 +std::wstring win32ConvertUtf8ToW(const std::string &text);
120 +#endif
122 #endif // _NPT_UTILS_H_
123 diff --git a/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp b/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp
124 index c9f9939d2b..f700b2212b 100644
125 --- a/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp
126 +++ b/lib/libUPnP/Neptune/Source/System/StdC/NptStdcEnvironment.cpp
127 @@ -22,7 +22,7 @@
128 NPT_Result
129 NPT_Environment::Get(const char* name, NPT_String& value)
131 - char* env;
132 + char* env = nullptr;
134 /* default value */
135 value.SetLength(0);
136 diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp
137 index caaf6d1903..371aaf5ab9 100644
138 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp
139 +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32DynamicLibraries.cpp
140 @@ -97,7 +97,11 @@ NPT_DynamicLibrary::Load(const char* name, NPT_Flags flags, NPT_DynamicLibrary*&
142 // load the lib
143 NPT_LOG_FINE_2("loading library %s, flags=%x", name, flags);
144 +#ifdef TARGET_WINDOWS_STORE
145 + HMODULE handle = LoadPackagedLibrary(NPT_WIN32_A2W(name), NULL);
146 +#else
147 HMODULE handle = LoadLibraryW(NPT_WIN32_A2W(name));
148 +#endif
149 if (handle == NULL) {
150 NPT_LOG_FINE("library not found");
151 return NPT_FAILURE;
152 diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp
153 index f415b851d5..d5ad0b953c 100644
154 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp
155 +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.cpp
156 @@ -11,7 +11,7 @@
157 | includes
158 +---------------------------------------------------------------------*/
159 #include "NptWin32MessageQueue.h"
161 +#ifndef TARGET_WINDOWS_STORE
162 /*----------------------------------------------------------------------
163 | platform adaptation
164 +---------------------------------------------------------------------*/
165 @@ -181,3 +181,4 @@ NPT_Win32WindowMessageQueue::HandleMessage(NPT_Message* message,
166 return result;
169 +#endif // ! TARGET_WINDOWS_STORE
170 diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h
171 index a5f846b016..1d84800586 100644
172 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h
173 +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32MessageQueue.h
174 @@ -10,6 +10,7 @@
175 #ifndef _NPT_WIN32_MESSAGE_QUEUE_
176 #define _NPT_WIN32_MESSAGE_QUEUE_
178 +#ifndef TARGET_WINDOWS_STORE
179 /*----------------------------------------------------------------------
180 | includes
181 +---------------------------------------------------------------------*/
182 @@ -45,5 +46,7 @@ private:
183 HINSTANCE m_hInstance;
186 +#endif // ! TARGET_WINDOWS_STORE
188 #endif // _NPT_WIN32_MESSAGE_QUEUE_
190 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32Queue.cpp
191 +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32Queue.cpp
192 @@ -24,7 +24,7 @@
193 #include "NptDebug.h"
194 #include "NptLogging.h"
196 -#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
197 +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || defined(TARGET_WINDOWS_STORE)
198 // for XBox, Windows 7 Desktop or earlier
199 #include "NptWin32Threads.h"
200 #elif WINAPI_FAMILY == WINAPI_FAMILY_APP
201 @@ -55,7 +55,7 @@ private:
202 // members
203 NPT_Cardinal m_MaxItems;
205 -#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
206 +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || defined(TARGET_WINDOWS_STORE)
207 // for XBox, Windows 7 Desktop or earlier
208 NPT_Win32CriticalSection m_Mutex;
209 NPT_Win32Event* m_CanPushCondition;
210 @@ -76,7 +76,7 @@ private:
211 NPT_Win32Queue::NPT_Win32Queue(NPT_Cardinal max_items) :
212 m_MaxItems(max_items)
214 -#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
215 +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || defined(TARGET_WINDOWS_STORE)
216 // for XBox, Windows 7 Desktop or earlier
217 m_CanPushCondition = new NPT_Win32Event(true, true);
218 m_CanPopCondition = new NPT_Win32Event(true, false);
219 diff --git a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp
220 index 9428648bd7..4dfc23a603 100644
221 --- a/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp
222 +++ b/lib/libUPnP/Neptune/Source/System/Win32/NptWin32SerialPort.cpp
223 @@ -17,6 +17,7 @@
224 #include "NptStrings.h"
225 #include "NptLogging.h"
227 +#ifndef TARGET_WINDOWS_STORE
228 /*----------------------------------------------------------------------
229 | NPT_Win32HandletWrapper
230 +---------------------------------------------------------------------*/
231 @@ -338,3 +339,4 @@ NPT_SerialPort::NPT_SerialPort(const char* name)
233 m_Delegate = new NPT_Win32SerialPort(name);
235 +#endif // ! TARGET_WINDOWS_STORE
237 2.13.2.windows.1