Skip to content

Commit

Permalink
Merge pull request #2005 from meganz/release/v3.7.0a
Browse files Browse the repository at this point in the history
Release/v3.7.0a
  • Loading branch information
sergiohs84 authored Jun 9, 2020
2 parents cd8dae2 + 610f41b commit e16d87a
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 8 deletions.
30 changes: 30 additions & 0 deletions bindings/ios/MEGASdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,36 @@ typedef NS_ENUM(NSInteger, AffiliateType) {
*/
- (BOOL)appleVoipPushEnabled;

/* This function creates a new session for the link so logging out in the web client won't log out
* the current session.
*
* The associated request type with this request is MEGARequestTypeGetSessionTransferUrl
* Valid data in the MEGARequest object received in onRequestFinish when the error code
* is MEGAErrorTypeApiOk:
* - [MEGARequest link] - URL to open the desired page with the same account
*
* @param url URL inside https://mega.nz/# that we want to open with the current session
*
* For example, if you want to open https://mega.nz/#pro, the parameter of this function should be "pro".
*
* @param delegate MEGARequestDelegate to track this request
*/
- (void)getSessionTransferURL:(NSString *)path delegate:(id<MEGARequestDelegate>)delegate;

/* This function creates a new session for the link so logging out in the web client won't log out
* the current session.
*
* The associated request type with this request is MEGARequestTypeGetSessionTransferUrl
* Valid data in the MEGARequest object received in onRequestFinish when the error code
* is MEGAErrorTypeApiOk:
* - [MEGARequest link] - URL to open the desired page with the same account
*
* @param url URL inside https://mega.nz/# that we want to open with the current session
*
* For example, if you want to open https://mega.nz/#pro, the parameter of this function should be "pro".
*/
- (void)getSessionTransferURL:(NSString *)path;

#pragma mark - Login Requests

/**
Expand Down
8 changes: 8 additions & 0 deletions bindings/ios/MEGASdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ - (BOOL)appleVoipPushEnabled {
return self.megaApi->appleVoipPushEnabled();
}

- (void)getSessionTransferURL:(NSString *)path delegate:(id<MEGARequestDelegate>)delegate {
self.megaApi->getSessionTransferURL(path.UTF8String, [self createDelegateMEGARequestListener:delegate singleListener:YES]);
}

- (void)getSessionTransferURL:(NSString *)path {
self.megaApi->getSessionTransferURL(path.UTF8String);
}

#pragma mark - Login Requests

- (BOOL)multiFactorAuthAvailable {
Expand Down
1 change: 1 addition & 0 deletions contrib/cmake/3rdparty_deps.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
zlib
cryptopp
cryptopp-staticcrt
libsodium
sqlite3
openssl
Expand Down
1 change: 1 addition & 0 deletions contrib/cmake/preferred-ports.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bzip2/1.0.6-4
c-ares/2019-5-2-1
cryptopp/8.2.0
cryptopp-staticcrt/8.2.0
curl/7.68.0
ffmpeg/4.2-3
gtest/2019-10-09
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Source: cryptopp-staticcrt
Version: 8.2.0
Homepage: https://github.com/weidai11/cryptopp
Description: Crypto++ is a free C++ class library of cryptographic schemes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8cf9fa2..86a756b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -336,9 +336,13 @@ if (MSVC)
if (CMAKE_SYSTEM_VERSION MATCHES "10\\.0.*")
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "_WIN32_WINNT=0x0A00")
endif ()
- list(APPEND CRYPTOPP_COMPILE_OPTIONS "/FI\"winapifamily.h\"")
+ list(APPEND CRYPTOPP_COMPILE_OPTIONS "/FIwinapifamily.h")
endif ()

+if(WINDOWS_STORE)
+ add_definitions(-DCRYPTOPP_DISABLE_NACL=1)
+endif()
+
# Enable PIC for all target machines except 32-bit i386 due to register pressures.
if (NOT CRYPTOPP_I386)
SET(CMAKE_POSITION_INDEPENDENT_CODE 1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/config.h b/config.h
index f06992a2..be6eda31 100644
--- a/config.h
+++ b/config.h
@@ -814,6 +814,7 @@ NAMESPACE_END
#endif

#ifdef CRYPTOPP_WIN32_AVAILABLE
+#include <winapifamily.h>
# if !defined(WINAPI_FAMILY)
# define THREAD_TIMER_AVAILABLE
# elif defined(WINAPI_FAMILY)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
include(vcpkg_common_functions)

# we are deliberately building a static-crt version for MEGAUpdater
set(VCPKG_CRT_LINKAGE "static")
vcpkg_check_linkage(ONLY_STATIC_CRT)

vcpkg_from_github(
OUT_SOURCE_PATH CMAKE_SOURCE_PATH
REPO noloader/cryptopp-cmake
REF 6d0666c457fbbf6f81819fd2b80f0cb5b6646593
SHA512 0341f14ce734afaee8bcc1db1716684f241499c692a5478c83a3df3fd2e5331cd04b2f4f51d43cce231ca1d9fbe76220639573c05ef06be0cf33081a1ef7ab30
HEAD_REF master
PATCHES
cmake.patch
staticcrt.patch
)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO weidai11/cryptopp
REF CRYPTOPP_8_2_0
SHA512 d2dcc107091d00800de243abdce8286ccd7fcc5707eebf88b97675456a021e62002e942b862db0465f72142951f631c0c1f0b2ba56028b96461780a17f2dfdf9
HEAD_REF master
PATCHES patch.patch
)

file(COPY ${CMAKE_SOURCE_PATH}/cryptopp-config.cmake DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_SOURCE_PATH}/CMakeLists.txt DESTINATION ${SOURCE_PATH})

# disable assembly on OSX to fix broken build
if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CRYPTOPP_DISABLE_ASM "ON")
else()
set(CRYPTOPP_DISABLE_ASM "OFF")
endif()


# Dynamic linking should be avoided for Crypto++ to reduce the attack surface,
# so generate a static lib for both dynamic and static vcpkg targets.
# See also:
# https://www.cryptopp.com/wiki/Visual_Studio#Dynamic_Runtime_Linking
# https://www.cryptopp.com/wiki/Visual_Studio#The_DLL

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DBUILD_SHARED=OFF
-DBUILD_STATIC=ON
-DBUILD_TESTING=OFF
-DBUILD_DOCUMENTATION=OFF
-DDISABLE_ASM=${CRYPTOPP_DISABLE_ASM}
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/cryptopp-staticcrt)

# There is no way to suppress installation of the headers and resource files in debug build.
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

# Handle copyright
file(COPY ${SOURCE_PATH}/License.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/cryptopp-staticcrt)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/cryptopp-staticcrt/License.txt ${CURRENT_PACKAGES_DIR}/share/cryptopp-staticcrt/copyright)
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d19bcd..6e28c24 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1026,13 +1026,19 @@ else ()
endif ()

if (BUILD_STATIC)
- add_library(cryptopp-static STATIC ${cryptopp_LIBRARY_SOURCES})
- cryptopp_target_compile_properties(cryptopp-static)
+ add_library(cryptopp-staticcrt STATIC ${cryptopp_LIBRARY_SOURCES})
+ cryptopp_target_compile_properties(cryptopp-staticcrt)
if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11")
- target_include_directories(cryptopp-static PUBLIC $<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>)
+ target_include_directories(cryptopp-staticcrt PUBLIC $<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>)
else ()
- set_target_properties(cryptopp-static PROPERTIES INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>")
+ set_target_properties(cryptopp-staticcrt PROPERTIES INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>")
endif ()
+ if (WIN32)
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MTd")
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} /MTd")
+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT")
+ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} /MT")
+ endif()
endif ()

if (BUILD_SHARED)
@@ -1050,7 +1056,7 @@ if (NOT MSVC)
set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR})

if (BUILD_STATIC)
- set_target_properties(cryptopp-static
+ set_target_properties(cryptopp-staticcrt
PROPERTIES
OUTPUT_NAME cryptopp)
endif ()
@@ -1066,7 +1072,7 @@ endif ()
# similar to how the crypto++ 'make' tool works.
# see https://github.com/noloader/cryptopp-cmake/issues/32
if (BUILD_STATIC)
- add_custom_target(static DEPENDS cryptopp-static)
+ add_custom_target(static DEPENDS cryptopp-staticcrt)
endif ()
if (BUILD_SHARED)
add_custom_target(shared DEPENDS cryptopp-shared)
@@ -1079,7 +1085,7 @@ endif ()

if (WIN32)
if (BUILD_STATIC)
- target_link_libraries(cryptopp-static ws2_32)
+ target_link_libraries(cryptopp-staticcrt ws2_32)
endif ()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared ws2_32)
@@ -1089,7 +1095,7 @@ endif ()
# This may need to be expanded to "Solaris"
if (CRYPTOPP_SOLARIS)
if (BUILD_STATIC)
- target_link_libraries(cryptopp-static nsl socket)
+ target_link_libraries(cryptopp-staticcrt nsl socket)
endif ()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared nsl socket)
@@ -1098,7 +1104,7 @@ endif ()

find_package(Threads)
if (BUILD_STATIC)
- target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT})
+ target_link_libraries(cryptopp-staticcrt ${CMAKE_THREAD_LIBS_INIT})
endif ()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT})
@@ -1111,7 +1117,7 @@ endif ()
enable_testing()
if (BUILD_TESTING)
add_executable(cryptest ${cryptopp_SOURCES_TEST})
- target_link_libraries(cryptest cryptopp-static)
+ target_link_libraries(cryptest cryptopp-staticcrt)

# Setting "cryptest" binary name to "cryptest.exe"
if (NOT (WIN32 OR CYGWIN))
@@ -1176,17 +1182,17 @@ endif ()

# Development package
if (BUILD_STATIC)
- export(TARGETS cryptopp-static FILE ${export_name}.cmake )
- install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ export(TARGETS cryptopp-staticcrt FILE ${export_name}.cmake )
+ install(TARGETS cryptopp-staticcrt EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif ()
-install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp)
+install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp-staticcrt)

# CMake Package
if (NOT CMAKE_VERSION VERSION_LESS 2.8.8)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR}.${cryptopp_VERSION_PATCH} COMPATIBILITY SameMajorVersion)
- install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp")
- install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp")
+ install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp-staticcrt")
+ install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp-staticcrt")
endif ()

# Tests
5 changes: 4 additions & 1 deletion include/mega/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,11 @@ class SimpleLogger
static OutputStreams getOutput(enum LogLevel ll);
#else

#ifdef WIN32
#ifdef WIN64
static thread_local std::array<char, LOGGER_CHUNKS_SIZE> mBuffer;
#elif WIN32
// Keep this as a normal class member on WIN32 until we abandon XP (Qt fonts appear with strikethrough on XP otherwise)
/*static thread_local*/ std::array<char, LOGGER_CHUNKS_SIZE> mBuffer;
#else
static __thread std::array<char, LOGGER_CHUNKS_SIZE> mBuffer;
#endif
Expand Down
8 changes: 8 additions & 0 deletions include/mega/megaclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ class MEGA_API MegaClient
// check the reason of being blocked
void whyamiblocked();

// stops querying for action packets due to the account being blocked (-16 on sc channel)
void block();

// resumes querying for action packets when the account is unblocked (if it was previously stopped due to being blocked)
void unblock();

// dump current session
int dumpsession(byte*, size_t);

Expand Down Expand Up @@ -803,6 +809,8 @@ class MEGA_API MegaClient
std::unique_ptr<HttpReq> pendingscUserAlerts;
BackoffTimer btsc;
bool stopsc = false;
bool mScStoppedDueToBlock = false;

bool pendingscTimedOut = false;


Expand Down
1 change: 1 addition & 0 deletions include/megaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10923,6 +10923,7 @@ class MegaApi
* is sent to MEGA servers.
*
* @note Event types are restricted to the following ranges:
* - MEGAcmd: [98900, 99000)
* - MEGAchat: [99000, 99150)
* - Android: [99200, 99300)
* - iOS: [99300, 99400)
Expand Down
12 changes: 11 additions & 1 deletion src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4737,7 +4737,14 @@ void CommandWhyAmIblocked::procresult()
{
if (client->json.isnumeric())
{
return client->app->whyamiblocked_result(int(client->json.getint()));
int response = int(client->json.getint());

if (!response) //unblocked
{
client->unblock();
}

return client->app->whyamiblocked_result(response);
}

client->json.storeobject();
Expand Down Expand Up @@ -5244,6 +5251,7 @@ CommandCopySession::CommandCopySession(MegaClient *client)
{
cmd("us");
arg("c", 1);
batchSeparately = true; // don't let any other commands that might get batched with it cause the whole batch to fail when blocked
tag = client->reqtag;
}

Expand Down Expand Up @@ -5623,6 +5631,8 @@ void CommandConfirmCancelLink::procresult()
CommandResendVerificationEmail::CommandResendVerificationEmail(MegaClient *client)
{
cmd("era");
batchSeparately = true; // don't let any other commands that might get batched with it cause the whole batch to fail

tag = client->reqtag;
}

Expand Down
6 changes: 4 additions & 2 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ long long SimpleLogger::maxPayloadLogSize = 10240;

#ifdef ENABLE_LOG_PERFORMANCE

#ifdef WIN32
thread_local std::array<char, LOGGER_CHUNKS_SIZE> SimpleLogger::mBuffer;
#ifdef WIN64
thread_local std::array<char, LOGGER_CHUNKS_SIZE> SimpleLogger::mBuffer;
#elif WIN32
//thread_local std::array<char, LOGGER_CHUNKS_SIZE> SimpleLogger::mBuffer;
#else
__thread std::array<char, LOGGER_CHUNKS_SIZE> SimpleLogger::mBuffer;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/megaapi_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20888,7 +20888,7 @@ void MegaApiImpl::sendPendingRequests()
int number = int(request->getNumber());
const char *text = request->getText();

if(number < 99000 || (number >= 99150 && (number < 99200 || number >= 99600)) || !text)
if(number < 98900 || (number >= 99150 && (number < 99200 || number >= 99600)) || !text)
{
e = API_EARGS;
break;
Expand Down
Loading

0 comments on commit e16d87a

Please sign in to comment.