Browse Source

Used the shared posix networking code for Android where the target SDK supports it

tags/2021-05-28
jules 7 years ago
parent
commit
2666842fa5
10 changed files with 23 additions and 18 deletions
  1. +2
    -2
      examples/DemoRunner/Builds/Android/app/CMakeLists.txt
  2. +1
    -1
      examples/DemoRunner/Builds/VisualStudio2013/DemoRunner_App.vcxproj
  3. +2
    -2
      examples/DemoRunner/Builds/VisualStudio2013/DemoRunner_App.vcxproj.filters
  4. +1
    -1
      examples/DemoRunner/Builds/VisualStudio2015/DemoRunner_App.vcxproj
  5. +2
    -2
      examples/DemoRunner/Builds/VisualStudio2015/DemoRunner_App.vcxproj.filters
  6. +1
    -1
      examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj
  7. +2
    -2
      examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj.filters
  8. +4
    -2
      modules/juce_core/juce_core.cpp
  9. +8
    -5
      modules/juce_core/native/juce_android_Network.cpp
  10. +0
    -0
      modules/juce_core/native/juce_posix_IPAddress.h

+ 2
- 2
examples/DemoRunner/Builds/Android/app/CMakeLists.txt View File

@@ -720,12 +720,12 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_core/native/juce_linux_Threads.cpp"
"../../../../../modules/juce_core/native/juce_mac_ClangBugWorkaround.h"
"../../../../../modules/juce_core/native/juce_mac_Files.mm"
"../../../../../modules/juce_core/native/juce_mac_linux_IPAddress.h"
"../../../../../modules/juce_core/native/juce_mac_Network.mm"
"../../../../../modules/juce_core/native/juce_mac_Strings.mm"
"../../../../../modules/juce_core/native/juce_mac_SystemStats.mm"
"../../../../../modules/juce_core/native/juce_mac_Threads.mm"
"../../../../../modules/juce_core/native/juce_osx_ObjCHelpers.h"
"../../../../../modules/juce_core/native/juce_posix_IPAddress.h"
"../../../../../modules/juce_core/native/juce_posix_NamedPipe.cpp"
"../../../../../modules/juce_core/native/juce_posix_SharedCode.h"
"../../../../../modules/juce_core/native/juce_win32_ComSmartPtr.h"
@@ -2288,12 +2288,12 @@ set_source_files_properties("../../../../../modules/juce_core/native/juce_linux_
set_source_files_properties("../../../../../modules/juce_core/native/juce_linux_Threads.cpp" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_ClangBugWorkaround.h" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_Files.mm" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_linux_IPAddress.h" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_Network.mm" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_Strings.mm" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_SystemStats.mm" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_mac_Threads.mm" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_osx_ObjCHelpers.h" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_posix_IPAddress.h" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_posix_NamedPipe.cpp" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_posix_SharedCode.h" PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties("../../../../../modules/juce_core/native/juce_win32_ComSmartPtr.h" PROPERTIES HEADER_FILE_ONLY TRUE)


+ 1
- 1
examples/DemoRunner/Builds/VisualStudio2013/DemoRunner_App.vcxproj View File

@@ -2579,8 +2579,8 @@
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_android_JNIHelpers.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_BasicNativeHeaders.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_ClangBugWorkaround.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_linux_IPAddress.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_IPAddress.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_SharedCode.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_win32_ComSmartPtr.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\network\juce_IPAddress.h"/>


+ 2
- 2
examples/DemoRunner/Builds/VisualStudio2013/DemoRunner_App.vcxproj.filters View File

@@ -3918,10 +3918,10 @@
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_ClangBugWorkaround.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_linux_IPAddress.h">
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h">
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_IPAddress.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_SharedCode.h">


+ 1
- 1
examples/DemoRunner/Builds/VisualStudio2015/DemoRunner_App.vcxproj View File

@@ -2579,8 +2579,8 @@
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_android_JNIHelpers.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_BasicNativeHeaders.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_ClangBugWorkaround.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_linux_IPAddress.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_IPAddress.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_SharedCode.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_win32_ComSmartPtr.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\network\juce_IPAddress.h"/>


+ 2
- 2
examples/DemoRunner/Builds/VisualStudio2015/DemoRunner_App.vcxproj.filters View File

@@ -3918,10 +3918,10 @@
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_ClangBugWorkaround.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_linux_IPAddress.h">
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h">
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_IPAddress.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_SharedCode.h">


+ 1
- 1
examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj View File

@@ -2581,8 +2581,8 @@
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_android_JNIHelpers.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_BasicNativeHeaders.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_ClangBugWorkaround.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_linux_IPAddress.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_IPAddress.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_SharedCode.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_win32_ComSmartPtr.h"/>
<ClInclude Include="..\..\..\..\modules\juce_core\network\juce_IPAddress.h"/>


+ 2
- 2
examples/DemoRunner/Builds/VisualStudio2017/DemoRunner_App.vcxproj.filters View File

@@ -3918,10 +3918,10 @@
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_ClangBugWorkaround.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_mac_linux_IPAddress.h">
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_osx_ObjCHelpers.h">
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_IPAddress.h">
<Filter>JUCE Modules\juce_core\native</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_core\native\juce_posix_SharedCode.h">


+ 4
- 2
modules/juce_core/juce_core.cpp View File

@@ -105,6 +105,7 @@
#endif
#if JUCE_ANDROID
#include <ifaddrs.h>
#include <android/log.h>
#endif
@@ -186,12 +187,14 @@
#if ! JUCE_WINDOWS
#include "native/juce_posix_SharedCode.h"
#include "native/juce_posix_NamedPipe.cpp"
#if ! JUCE_ANDROID || __ANDROID_API__ >= 24
#include "native/juce_posix_IPAddress.h"
#endif
#endif
//==============================================================================
#if JUCE_MAC || JUCE_IOS
#include "native/juce_mac_Files.mm"
#include "native/juce_mac_linux_IPAddress.h"
#include "native/juce_mac_Network.mm"
#include "native/juce_mac_Strings.mm"
#include "native/juce_mac_SystemStats.mm"
@@ -209,7 +212,6 @@
#elif JUCE_LINUX
#include "native/juce_linux_CommonFile.cpp"
#include "native/juce_linux_Files.cpp"
#include "native/juce_mac_linux_IPAddress.h"
#include "native/juce_linux_Network.cpp"
#if JUCE_USE_CURL
#include "native/juce_curl_Network.cpp"


+ 8
- 5
modules/juce_core/native/juce_android_Network.cpp View File

@@ -342,6 +342,8 @@ URL::DownloadTask* URL::downloadToFile (const File& targetLocation, String extra
}
//==============================================================================
#if __ANDROID_API__ < 24 // Android support for getifadds was added in Android 7.0 (API 24) so the posix implementation does not apply
static IPAddress makeAddress (const sockaddr_in *addr_in)
{
if (addr_in->sin_addr.s_addr == INADDR_NONE)
@@ -382,15 +384,15 @@ static Array<InterfaceInfo> findIPAddresses (int dummySocket)
if (item.ifr_addr.sa_family == AF_INET)
{
InterfaceInfo i;
i.interfaceAddress = makeAddress ((const sockaddr_in*) &item.ifr_addr);
InterfaceInfo info;
info.interfaceAddress = makeAddress ((const sockaddr_in*) &item.ifr_addr);
if (! i.interfaceAddress.isNull())
if (! info.interfaceAddress.isNull())
{
if (ioctl (dummySocket, SIOCGIFBRDADDR, &item) == 0)
i.broadcastAddress = makeAddress ((const sockaddr_in*) &item.ifr_broadaddr);
info.broadcastAddress = makeAddress ((const sockaddr_in*) &item.ifr_broadaddr);
result.add (i);
result.add (info);
}
}
else if (item.ifr_addr.sa_family == AF_INET6)
@@ -429,5 +431,6 @@ IPAddress IPAddress::getInterfaceBroadcastAddress (const IPAddress& address)
return {};
}
#endif
} // namespace juce

modules/juce_core/native/juce_mac_linux_IPAddress.h → modules/juce_core/native/juce_posix_IPAddress.h View File


Loading…
Cancel
Save