Skip to content

Commit

Permalink
Fix Windows Phone and UWP compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
javiergm1983 committed Jun 17, 2019
1 parent 54bf12c commit 3dc732c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 13 deletions.
15 changes: 9 additions & 6 deletions bindings/wp8/MegaSDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ MegaSDK::MegaSDK(String^ appKey, String^ userAgent, MRandomNumberProvider ^rando
unsigned char randomData[REQUIRED_ENTROPY];
if (randomProvider != nullptr)
randomProvider->GenerateRandomBlock(::Platform::ArrayReference<unsigned char>(randomData, REQUIRED_ENTROPY));
MegaApi::addEntropy((char *)randomData, REQUIRED_ENTROPY);


std::string utf8appKey;
if(appKey != nullptr)
MegaApi::utf16ToUtf8(appKey->Data(), appKey->Length(), &utf8appKey);
Expand All @@ -61,6 +60,8 @@ MegaSDK::MegaSDK(String^ appKey, String^ userAgent, MRandomNumberProvider ^rando
megaApi = new MegaApi((appKey != nullptr) ? utf8appKey.c_str() : NULL,
(const char *)NULL, (userAgent != nullptr) ? utf8userAgent.c_str() : NULL);

megaApi->addEntropy((char *)randomData, REQUIRED_ENTROPY);

InitializeCriticalSectionEx(&listenerMutex, 0, 0);
InitializeCriticalSectionEx(&loggerMutex, 0, 0);
}
Expand All @@ -75,8 +76,7 @@ MegaSDK::MegaSDK(String^ appKey, String^ userAgent, String^ basePath, MRandomNum
unsigned char randomData[REQUIRED_ENTROPY];
if (randomProvider != nullptr)
randomProvider->GenerateRandomBlock(::Platform::ArrayReference<unsigned char>(randomData, REQUIRED_ENTROPY));
MegaApi::addEntropy((char *)randomData, REQUIRED_ENTROPY);


std::string utf8appKey;
if (appKey != nullptr)
MegaApi::utf16ToUtf8(appKey->Data(), appKey->Length(), &utf8appKey);
Expand All @@ -93,6 +93,8 @@ MegaSDK::MegaSDK(String^ appKey, String^ userAgent, String^ basePath, MRandomNum
(basePath != nullptr) ? utf8basePath.c_str() : NULL,
(userAgent != nullptr) ? utf8userAgent.c_str() : NULL);

megaApi->addEntropy((char *)randomData, REQUIRED_ENTROPY);

InitializeCriticalSectionEx(&listenerMutex, 0, 0);
InitializeCriticalSectionEx(&loggerMutex, 0, 0);
}
Expand All @@ -107,8 +109,7 @@ MegaSDK::MegaSDK(String^ appKey, String^ userAgent, String^ basePath, MRandomNum
unsigned char randomData[REQUIRED_ENTROPY];
if (randomProvider != nullptr)
randomProvider->GenerateRandomBlock(::Platform::ArrayReference<unsigned char>(randomData, REQUIRED_ENTROPY));
MegaApi::addEntropy((char *)randomData, REQUIRED_ENTROPY);


std::string utf8appKey;
if (appKey != nullptr)
MegaApi::utf16ToUtf8(appKey->Data(), appKey->Length(), &utf8appKey);
Expand All @@ -130,6 +131,8 @@ MegaSDK::MegaSDK(String^ appKey, String^ userAgent, String^ basePath, MRandomNum
(basePath != nullptr) ? utf8basePath.c_str() : NULL,
(userAgent != nullptr) ? utf8userAgent.c_str() : NULL);

megaApi->addEntropy((char *)randomData, REQUIRED_ENTROPY);

InitializeCriticalSectionEx(&listenerMutex, 0, 0);
InitializeCriticalSectionEx(&loggerMutex, 0, 0);
}
Expand Down
6 changes: 4 additions & 2 deletions bindings/wp8/vs2013/mega.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
<ClInclude Include="..\..\..\include\mega\share.h" />
<ClInclude Include="..\..\..\include\mega\sharenodekeys.h" />
<ClInclude Include="..\..\..\include\mega\sync.h" />
<ClInclude Include="..\..\..\include\mega\testhooks.h" />
<ClInclude Include="..\..\..\include\mega\thread.h" />
<ClInclude Include="..\..\..\include\mega\thread\cppthread.h" />
<ClInclude Include="..\..\..\include\mega\transfer.h" />
Expand Down Expand Up @@ -462,11 +463,13 @@
<ClCompile Include="..\..\..\src\pendingcontactrequest.cpp" />
<ClCompile Include="..\..\..\src\proxy.cpp" />
<ClCompile Include="..\..\..\src\pubkeyaction.cpp" />
<ClCompile Include="..\..\..\src\raid.cpp" />
<ClCompile Include="..\..\..\src\request.cpp" />
<ClCompile Include="..\..\..\src\serialize64.cpp" />
<ClCompile Include="..\..\..\src\share.cpp" />
<ClCompile Include="..\..\..\src\sharenodekeys.cpp" />
<ClCompile Include="..\..\..\src\sync.cpp" />
<ClCompile Include="..\..\..\src\testhooks.cpp" />
<ClCompile Include="..\..\..\src\thread\cppthread.cpp" />
<ClCompile Include="..\..\..\src\transfer.cpp" />
<ClCompile Include="..\..\..\src\transferslot.cpp" />
Expand All @@ -477,7 +480,6 @@
<ClCompile Include="..\..\..\src\waiterbase.cpp" />
<ClCompile Include="..\..\..\src\win32\fs.cpp" />
<ClCompile Include="..\..\..\src\win32\waiter.cpp" />
<ClCompile Include="..\..\..\src\win32\raid.cpp" />
<ClCompile Include="..\DelegateMGfxProcessor.cpp" />
<ClCompile Include="..\DelegateMGlobalListener.cpp" />
<ClCompile Include="..\DelegateMListener.cpp" />
Expand Down Expand Up @@ -518,4 +520,4 @@
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
14 changes: 10 additions & 4 deletions bindings/wp8/vs2013/mega.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@
<ClInclude Include="..\MUserAlertList.h">
<Filter>Bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\mega\testhooks.h">
<Filter>SDK\Header</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\attrmap.cpp">
Expand Down Expand Up @@ -524,9 +527,6 @@
<ClCompile Include="..\..\..\src\mega_zxcvbn.cpp">
<Filter>SDK\Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\raid.cpp">
<Filter>SDK\Source</Filter>
</ClCompile>
<ClCompile Include="..\MAchievementsDetails.cpp">
<Filter>Bindings</Filter>
</ClCompile>
Expand All @@ -545,5 +545,11 @@
<ClCompile Include="..\MUserAlertList.cpp">
<Filter>Bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\raid.cpp">
<Filter>SDK\Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\testhooks.cpp">
<Filter>SDK\Source</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>
2 changes: 2 additions & 0 deletions bindings/wp8/vs2015/mega.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<ClInclude Include="..\..\..\include\mega\share.h" />
<ClInclude Include="..\..\..\include\mega\sharenodekeys.h" />
<ClInclude Include="..\..\..\include\mega\sync.h" />
<ClInclude Include="..\..\..\include\mega\testhooks.h" />
<ClInclude Include="..\..\..\include\mega\thread.h" />
<ClInclude Include="..\..\..\include\mega\thread\cppthread.h" />
<ClInclude Include="..\..\..\include\mega\transfer.h" />
Expand Down Expand Up @@ -162,6 +163,7 @@
<ClCompile Include="..\..\..\src\sharenodekeys.cpp" />
<ClCompile Include="..\..\..\src\raid.cpp" />
<ClCompile Include="..\..\..\src\sync.cpp" />
<ClCompile Include="..\..\..\src\testhooks.cpp" />
<ClCompile Include="..\..\..\src\thread\cppthread.cpp" />
<ClCompile Include="..\..\..\src\transfer.cpp" />
<ClCompile Include="..\..\..\src\transferslot.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions bindings/wp8/vs2015/mega.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@
<ClInclude Include="..\MUserAlertList.h">
<Filter>Bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\mega\testhooks.h">
<Filter>SDK\Header</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\DelegateMGfxProcessor.cpp">
Expand Down Expand Up @@ -555,5 +558,8 @@
<ClCompile Include="..\MUserAlertList.cpp">
<Filter>Bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\testhooks.cpp">
<Filter>SDK\Source</Filter>
</ClCompile>
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions include/mega/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
#include "types.h"
#include "mega/logging.h"

// Needed for Windows Phone (MSVS 2013 - C++ version 9.8)
#if defined(_WIN32) && _MSC_VER <= 1800 && __cplusplus < 201103L && !defined(_TIMESPEC_DEFINED) && ! __struct_timespec_defined
struct timespec
{
long long tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
# define __struct_timespec_defined 1
#endif

namespace mega {
// convert 2...8 character ID to int64 integer (endian agnostic)
#define MAKENAMEID2(a, b) (nameid)(((a) << 8) + (b))
Expand Down
8 changes: 8 additions & 0 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@
* Public License, see http://www.gnu.org/copyleft/gpl.txt for details.
*/

#if defined(WINDOWS_PHONE) && !defined(__STDC_LIMIT_MACROS)
#define __STDC_LIMIT_MACROS
#endif

#include "mega/logging.h"
#include <time.h>
#include <assert.h>

#if defined(WINDOWS_PHONE)
#include <stdint.h>
#endif

namespace mega {

// static member initialization
Expand Down
2 changes: 1 addition & 1 deletion src/raid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace mega
{

constexpr unsigned RAID_ACTIVE_CHANNEL_FAIL_THRESHOLD = 5;
const unsigned RAID_ACTIVE_CHANNEL_FAIL_THRESHOLD = 5;

struct FaultyServers
{
Expand Down

0 comments on commit 3dc732c

Please sign in to comment.