author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
378,366 |
09.03.2022 08:14:42
| 21,600 |
0acc68d7448844c8e94cd8aba4a29cadecc4bf70
|
OpenMP corrected detection
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/openmp/device.cpp",
"new_path": "src/occa/internal/modes/openmp/device.cpp",
"diff": "#include <occa/internal/core/kernel.hpp>\n+#include <occa/internal/utils/env.hpp>\n#include <occa/internal/io/output.hpp>\n#include <occa/internal/lang/modes/openmp.hpp>\n#include <occa/internal/modes/serial/device.hpp>\n@@ -60,10 +61,50 @@ namespace occa {\nocca::json allKernelProps = properties + kernelProps;\n- std::string compiler = allKernelProps[\"compiler\"];\n+ std::string compilerLanguage;\n+ compilerLanguage = \"cpp\";\n+ if (env::var(\"OCCA_COMPILER_LANGUAGE\").size()) {\n+ compilerLanguage = env::var(\"OCCA_COMPILER_LANGUAGE\");\n+ } else if (kernelProps.get<std::string>(\"compiler_language\").size()) {\n+ compilerLanguage = (std::string) kernelProps[\"compiler_language\"];\n+ }\n+\n+ const bool compilingOkl = kernelProps.get(\"okl/enabled\", true);\n+ const bool compilingCpp = compilingOkl || (lowercase(compilerLanguage) != \"c\");\n+ const int compilerLanguageFlag = (\n+ compilingCpp\n+ ? sys::language::CPP\n+ : sys::language::C\n+ );\n+\n+ std::string compiler;\n+ if (compilerLanguageFlag == sys::language::CPP && env::var(\"OCCA_CXX\").size()) {\n+ compiler = env::var(\"OCCA_CXX\");\n+ } else if (compilerLanguageFlag == sys::language::C && env::var(\"OCCA_CC\").size()) {\n+ compiler = env::var(\"OCCA_CC\");\n+ } else if (kernelProps.get<std::string>(\"compiler\").size()) {\n+ compiler = (std::string) kernelProps[\"compiler\"];\n+ } else if (compilerLanguageFlag == sys::language::CPP && env::var(\"CXX\").size()) {\n+ compiler = env::var(\"CXX\");\n+ } else if (compilerLanguageFlag == sys::language::C && env::var(\"CC\").size()) {\n+ compiler = env::var(\"CC\");\n+ } else if (compilerLanguageFlag == sys::language::CPP) {\n+#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n+ compiler = \"g++\";\n+#else\n+ compiler = \"cl.exe\";\n+#endif\n+ } else {\n+#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n+ compiler = \"gcc\";\n+#else\n+ compiler = \"cl.exe\";\n+#endif\n+ }\n+\nint vendor = allKernelProps[\"vendor\"];\n// Check if we need to re-compute the vendor\n- if (kernelProps.has(\"compiler\")) {\n+ if (compiler.size()) {\nvendor = sys::compilerVendor(compiler);\n}\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
OpenMP corrected detection (#555)
|
378,341 |
11.04.2022 16:12:48
| -7,200 |
afb6ff07479f5ad62335dfdd838613d18cd6ae29
|
Improve occa preprocessor error messages
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/loaders/typeLoader.cpp",
"new_path": "src/occa/internal/lang/loaders/typeLoader.cpp",
"diff": "@@ -69,11 +69,11 @@ namespace occa {\nsuccess = false;\n} else if (qualifier == union_) {\n// TODO: type = loadUnion();\n- token->printError(\"Enums are not supported yet\");\n+ token->printError(\"Unions are not supported yet\");\nsuccess = false;\n} else if (qualifier == class_) {\n// TODO: type = loadClass();\n- token->printError(\"Enums are not supported yet\");\n+ token->printError(\"Classes are not supported yet\");\nsuccess = false;\n}\nif (!success) {\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Improve occa preprocessor error messages (#572)
|
378,351 |
12.04.2022 11:10:40
| 18,000 |
9aad33380a287ee7d3a088041e24ec310fc3f05c
|
Change loop-bounds inequalities to strict inequalities for nested `@tile` loops.
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/builtins/attributes/tile.cpp",
"new_path": "src/occa/internal/lang/builtins/attributes/tile.cpp",
"diff": "@@ -271,11 +271,28 @@ namespace occa {\n);\nconst binaryOperator_t &checkOp = (const binaryOperator_t&) checkExpr.op;\n- expr check = (\n+ opType_t checkOpType = checkOp.opType;\n+\n+ expr check;\n+ if(checkOpType & (operatorType::lessThanEq\n+ | operatorType::greaterThanEq)) {\n+ const binaryOperator_t &innerOp = (\n+ (checkOpType & operatorType::lessThanEq)\n+ ? op::lessThan\n+ : op::greaterThan\n+ );\n+ check = (\n+ oklForSmnt.checkValueOnRight\n+ ? expr::binaryOpExpr(innerOp, iterator, bounds)\n+ : expr::binaryOpExpr(innerOp, bounds, iterator)\n+ );\n+ } else {\n+ check = (\noklForSmnt.checkValueOnRight\n? expr::binaryOpExpr(checkOp, iterator, bounds)\n: expr::binaryOpExpr(checkOp, bounds, iterator)\n);\n+ }\ninnerForSmnt.check = check.createStatement(&innerForSmnt);\n}\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Change loop-bounds inequalities to strict inequalities for nested `@tile` loops.
|
378,341 |
12.04.2022 18:39:42
| -7,200 |
eea8fe0c1ce58a5c86cbb41ed9e2a454d8a937ac
|
Fix unreachable statement that makes the PGI compiler unhappy
|
[
{
"change_type": "MODIFY",
"old_path": "src/types/primitive.cpp",
"new_path": "src/types/primitive.cpp",
"diff": "@@ -250,7 +250,7 @@ namespace occa {\ncase primitiveType::float_ : str = occa::toString(value.float_); break;\ncase primitiveType::double_ : str = occa::toString(value.double_); break;\ncase primitiveType::none :\n- default: return \"\"; break;\n+ default: return \"\";\n}\nif (type & (primitiveType::uint64_ |\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Fix unreachable statement that makes the PGI compiler unhappy (#575)
|
378,351 |
01.06.2022 16:55:59
| 18,000 |
82fd28df4966ed6b9d71e1c704ff660a6a67700e
|
Fix broken links for libocca webpage.
|
[
{
"change_type": "MODIFY",
"old_path": "docs/_navbar.md",
"new_path": "docs/_navbar.md",
"diff": "- [Home](/) \n-- [Guide](/guide/user-guide/introduction) \n+- [Guide](guide/user-guide/introduction.md) \n-- [API](/api/) \n+- [API](api/README.md) \n- Examples <span class=\"arrow\">▾</span>\n- [C++ Examples](https://github.com/libocca/occa/tree/main/examples/cpp)\n- [Python Example](https://mybinder.org/v2/gh/libocca/occa.py/0.4.1?filepath=notebooks%2FTutorial.ipynb)\n- About <span class=\"arrow\">▾</span>\n- - [History](/history)\n- - [Team](/team)\n- - [Gallery](/gallery)\n- - [Publications](/publications)\n+ - [History](history.md)\n+ - [Team](team.md)\n+ - [Gallery](gallery.md)\n+ - [Publications](publications.md)\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/examples/_sidebar.md",
"new_path": "docs/examples/_sidebar.md",
"diff": "-- [Examples](/examples/)\n- - [C++](/examples/cpp/)\n- - [C](/examples/c/)\n- - [Python](/examples/py/)\n+- [Examples](./README.md)\n+ - [C++](cpp/README.md)\n+ - [C](c/README.md)\n+ - [Python](py/README.md)\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/index.html",
"new_path": "docs/index.html",
"diff": "<link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic|Material+Icons\">\n<link rel=\"stylesheet\" href=\"//unpkg.com/vue-material@beta/dist/vue-material.min.css\">\n- <link rel=\"stylesheet\" href=\"//unpkg.com/docsify@4.7.1/lib/themes/vue.css\">\n+ <link rel=\"stylesheet\" href=\"//unpkg.com/docsify@4/lib/themes/vue.css\">\n<link rel=\"stylesheet\" href=\"//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css\">\n<link rel=\"stylesheet\" href=\"./assets/occa.css\">\n</head>\nalias: {\n'/.*/_navbar.md': '/_navbar.md',\n- '/guide/.*/_sidebar.md': '/guide/_sidebar.md',\n+ '/guide/(.*)/_sidebar.md': '/guide/_sidebar.md',\n'/examples/.*/_sidebar.md': '/examples/_sidebar.md',\n+ '/customization/(.*)': '/guide/customization/$1',\n+ '/customization/(.*)': '/guide/customization/$1',\n+ '/developer-zone/(.*)': '/guide/developer-zone/$1',\n+ '/occa/(.*)': '/guide/occa/$1',\n+ '/okl/(.*)': '/guide/okl/$1',\n+ '/user-guide/(.*)': '/guide/user-guide/$1',\n+ '/c/(.*)': '/examples/c/$1',\n+ '/cpp/(.*)': '/examples/cpp/$1',\n+ '/py/(.*)': '/examples/py/$1'\n},\nauto2top: true,\nwindow.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = vm.constructor;\n</script>\n- <script src=\"//unpkg.com/docsify@4.7.1/lib/docsify.min.js\"></script>\n- <script src=\"//unpkg.com/docsify@4.7.1/lib/plugins/ga.min.js\"></script>\n+ <script src=\"//unpkg.com/docsify@4/lib/docsify.min.js\"></script>\n+ <script src=\"//unpkg.com/docsify@4/lib/plugins/ga.min.js\"></script>\n<script src=\"//unpkg.com/prismjs@1.13.0/components/prism-bash.min.js\"></script>\n<script src=\"//unpkg.com/prismjs@1.13.0/components/prism-c.min.js\"></script>\n<script src=\"//unpkg.com/prismjs@1.13.0/components/prism-cpp.min.js\"></script>\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Fix broken links for libocca webpage.
|
378,351 |
01.06.2022 17:13:29
| 18,000 |
746680bafc3ab6b34003515c3e8ed4144878c9ed
|
Update instructions for support and feedback.
|
[
{
"change_type": "MODIFY",
"old_path": "docs/guide/_sidebar.md",
"new_path": "docs/guide/_sidebar.md",
"diff": "- **User Guide**\n- [Introduction](user-guide/introduction.md)\n- - [Python Setup](user-guide/python-setup.md)\n- [Command-Line Interface](user-guide/command-line-interface.md)\n- - [Need Help?](user-guide/need-help.md)\n+ - [Community](user-guide/community.md)\n- **OCCA**\n- [Introduction](occa/introduction.md)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "docs/guide/user-guide/community.md",
"diff": "+# Community\n+\n+## Support\n+\n+Need help? Checkout the [repository wiki](https://github.com/libocca/occa/wiki) or ask a question in the [Q&A discussions category](https://github.com/libocca/occa/discussions/categories/q-a).\n+\n+## Feedback\n+\n+User feedback is critical for improving our processes and practices. Whether you're a first time OCCA user or a veteran OCCA developer, we'd love to hear from you!\n+\n+To provide feedback, start a conversation in the [general](https://github.com/libocca/occa/discussions/categories/general) or [ideas](https://github.com/libocca/occa/discussions/categories/ideas) discussion categories.\n+\n+## Technical Advisory Forum\n+\n+Interested in helping to shape the future of OCCA? Consider participating in the [OCCA Technical Advisory Forum](https://github.com/libocca/occa-taf).\n+\n+The OCCA Technical Advisory Forum aims bring together OCCA users and developers to discuss technical aspects of the framework, plan for future development, and to ensure the maintenance and reliability of the codebase.\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "docs/guide/user-guide/need-help.md",
"new_path": null,
"diff": "-# Need Help?\n-\n-OCCA is still heavily in development, so lots of questions can come up from first-time programmers that might not be covered in these docs\n-\n-There is no better feedback than that of a first-time user, so feel free to reach out!\n-\n-?> Drop by our [Slack workspace](https://join.slack.com/t/libocca/shared_invite/zt-4jcnu451-qPpPWUzhm7YQKY_HMhIsIw) to chat or feel free to open a [Github Issue](https://github.com/libocca/occa/issues) to start a conversation!\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Update instructions for support and feedback.
|
378,351 |
01.06.2022 17:24:14
| 18,000 |
6289743eeb20436ed95d9d9994fbaeb76f393a1a
|
Update version string (doh!)
|
[
{
"change_type": "MODIFY",
"old_path": "include/occa/defines/occa.hpp",
"new_path": "include/occa/defines/occa.hpp",
"diff": "#include <occa/defines/compiledDefines.hpp>\n#define OCCA_MAJOR_VERSION 1\n-#define OCCA_MINOR_VERSION 2\n+#define OCCA_MINOR_VERSION 3\n#define OCCA_PATCH_VERSION 0\n-#define OCCA_VERSION 10200\n-#define OCCA_VERSION_STR \"1.2.0\"\n+#define OCCA_VERSION 10300\n+#define OCCA_VERSION_STR \"1.3.0\"\n#define OKL_MAJOR_VERSION 1\n#define OKL_MINOR_VERSION 0\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Update version string (doh!)
|
378,355 |
12.07.2022 09:43:51
| 18,000 |
7447dd6befa652c7685bf76f910e31770e6350d8
|
[SYS] Fix frequency units
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/utils/sys.cpp",
"new_path": "src/occa/internal/utils/sys.cpp",
"diff": "@@ -545,7 +545,7 @@ namespace occa {\nconst float frequency = parseFloat(\ngetSystemInfoField(systemInfo, \"CPU max MHz\")\n);\n- return (udim_t) (frequency * 1e3);\n+ return (udim_t) (frequency * 1e6);\n#elif (OCCA_OS == OCCA_MACOS_OS)\nconst float frequency = parseFloat(\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[SYS] Fix frequency units (#601)
|
378,341 |
03.06.2022 18:09:02
| -7,200 |
7602447fdb064aedb92f34d6dc44b1073792ee80
|
Fix cache write races when transformking OKL + Serial/OpenMP kernels
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/io/cache.cpp",
"new_path": "src/occa/internal/io/cache.cpp",
"diff": "@@ -79,9 +79,15 @@ namespace occa {\nstd::stringstream ss;\nss << header << '\\n'\n<< io::read(expFilename);\n- io::write(sourceFile, ss.str());\n+ io::stageFile(\n+ sourceFile,\n+ true,\n+ [&](const std::string &tempFilename) -> bool {\n+ io::write(tempFilename, ss.str());\n+ return true;\n+ }\n+ );\n}\n-\nreturn sourceFile;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/withLauncher.cpp",
"new_path": "src/occa/internal/lang/modes/withLauncher.cpp",
"diff": "@@ -24,7 +24,14 @@ namespace occa {\n}\nvoid withLauncher::writeLauncherSourceToFile(const std::string &filename) const {\n- launcherParser.writeToFile(filename);\n+ io::stageFile(\n+ filename,\n+ true,\n+ [&](const std::string &tempFilename) -> bool {\n+ launcherParser.writeToFile(tempFilename);\n+ return true;\n+ }\n+ );\n}\n//================================\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Fix cache write races when transformking OKL + Serial/OpenMP kernels (#594)
|
378,341 |
05.07.2022 19:36:54
| -7,200 |
5a9d31ed33caeaa7634efc015ae43da0d9c8267c
|
[CMake] Add MPIEXEC_PREFLAGS and MPIEXEC_POSTFLAGS to examples
This is recommended by CMake (https://cmake.org/cmake/help/latest/module/FindMPI.html#usage-of-mpiexec)
and allows some extra control for different MPI setups.
|
[
{
"change_type": "MODIFY",
"old_path": "examples/CMakeLists.txt",
"new_path": "examples/CMakeLists.txt",
"diff": "macro(add_test_with_mode_and_nranks exe mode device nranks)\nif (${nranks} GREATER 1)\n- add_test(NAME ${exe}-${mode} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nranks} ./${exe} --verbose --device \"${device}\")\n+ add_test(NAME ${exe}-${mode} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nranks} ${MPIEXEC_PREFLAGS} ./${exe} ${MPIEXEC_POSTFLAGS} --verbose --device \"${device}\")\nelse()\nadd_test(NAME ${exe}-${mode} COMMAND ./${exe} --verbose --device \"${device}\")\nendif()\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[CMake] Add MPIEXEC_PREFLAGS and MPIEXEC_POSTFLAGS to examples (#604)
This is recommended by CMake (https://cmake.org/cmake/help/latest/module/FindMPI.html#usage-of-mpiexec)
and allows some extra control for different MPI setups.
|
378,341 |
01.08.2022 18:43:37
| -7,200 |
ea25a893b31c0d09ecc74bbb0407e3929ef9fe32
|
[CMake/Make/bin] Remove vestigial MPI support
|
[
{
"change_type": "MODIFY",
"old_path": "Makefile",
"new_path": "Makefile",
"diff": "@@ -90,7 +90,6 @@ MAKE_COMPILED_DEFINES := $(shell cat \"$(OCCA_DIR)/scripts/build/compiledDefinesT\nsed \"s,@@OCCA_OS@@,$(OCCA_OS),g;\\\ns,@@OCCA_USING_VS@@,$(OCCA_USING_VS),g;\\\ns,@@OCCA_UNSAFE@@,$(OCCA_UNSAFE),g;\\\n- s,@@OCCA_MPI_ENABLED@@,$(OCCA_MPI_ENABLED),g; \\\ns,@@OCCA_OPENMP_ENABLED@@,$(OCCA_OPENMP_ENABLED),g;\\\ns,@@OCCA_CUDA_ENABLED@@,$(OCCA_CUDA_ENABLED),g;\\\ns,@@OCCA_HIP_ENABLED@@,$(OCCA_HIP_ENABLED),g;\\\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/guide/user-guide/command-line-interface.md",
"new_path": "docs/guide/user-guide/command-line-interface.md",
"diff": "@@ -90,7 +90,6 @@ Environment variables override compiled-time defines.\n- OCCA_HIP_ENABLED : 0\n- OCCA_OPENCL_ENABLED : 1\n- OCCA_METAL_ENABLED : 0\n- - OCCA_MPI_ENABLED : 0\nRun-Time Options:\n- OCCA_CXX : g++-8\n- OCCA_CXXFLAGS : -g\n"
},
{
"change_type": "MODIFY",
"old_path": "examples/CMakeLists.txt",
"new_path": "examples/CMakeLists.txt",
"diff": "-macro(add_test_with_mode_and_nranks exe mode device nranks)\n- if (${nranks} GREATER 1)\n- add_test(NAME ${exe}-${mode} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nranks} ${MPIEXEC_PREFLAGS} ./${exe} ${MPIEXEC_POSTFLAGS} --verbose --device \"${device}\")\n- else()\n+macro(add_test_with_mode exe mode device)\nadd_test(NAME ${exe}-${mode} COMMAND ./${exe} --verbose --device \"${device}\")\n- endif()\nset_property(TEST ${exe}-${mode} APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa)\nendmacro()\n-macro(add_test_with_modes_and_nranks exe nranks)\n- add_test_with_mode_and_nranks(${exe} serial \"{\\\"mode\\\": \\\"Serial\\\"}\" ${nranks})\n+macro(add_test_with_modes exe)\n+ add_test_with_mode(${exe} serial \"{\\\"mode\\\": \\\"Serial\\\"}\")\nif (OCCA_CUDA_ENABLED)\n- add_test_with_mode_and_nranks(${exe} cuda \"{\\\"mode\\\": \\\"CUDA\\\", \\\"device_id\\\": 0}\" ${nranks})\n+ add_test_with_mode(${exe} cuda \"{\\\"mode\\\": \\\"CUDA\\\", \\\"device_id\\\": 0}\")\nendif()\nif (OCCA_HIP_ENABLED)\n- add_test_with_mode_and_nranks(${exe} hip \"{\\\"mode\\\": \\\"HIP\\\", \\\"device_id\\\": 0}\" ${nranks})\n+ add_test_with_mode(${exe} hip \"{\\\"mode\\\": \\\"HIP\\\", \\\"device_id\\\": 0}\")\nendif()\nif (OCCA_METAL_ENABLED)\n- add_test_with_mode_and_nranks(${exe} metal \"{\\\"mode\\\": \\\"Metal\\\", \\\"device_id\\\": 0}\" ${nranks})\n+ add_test_with_mode(${exe} metal \"{\\\"mode\\\": \\\"Metal\\\", \\\"device_id\\\": 0}\")\nendif()\nif (OCCA_OPENCL_ENABLED)\n- add_test_with_mode_and_nranks(${exe} opencl \"{\\\"mode\\\": \\\"OpenCL\\\", \\\"platform_id\\\": 0, \\\"device_id\\\": 0}\" ${nranks})\n+ add_test_with_mode(${exe} opencl \"{\\\"mode\\\": \\\"OpenCL\\\", \\\"platform_id\\\": 0, \\\"device_id\\\": 0}\")\nendif()\nif (OCCA_DPCPP_ENABLED)\n- add_test_with_mode_and_nranks(${exe} dpcpp \"{\\\"mode\\\": \\\"dpcpp\\\", \\\"platform_id\\\": 0, \\\"device_id\\\": 0}\" ${nranks})\n+ add_test_with_mode(${exe} dpcpp \"{\\\"mode\\\": \\\"dpcpp\\\", \\\"platform_id\\\": 0, \\\"device_id\\\": 0}\")\nendif()\nif (OCCA_OPENMP_ENABLED)\n- add_test_with_mode_and_nranks(${exe} openmp \"{\\\"mode\\\": \\\"OpenMP\\\"}\" ${nranks})\n+ add_test_with_mode(${exe} openmp \"{\\\"mode\\\": \\\"OpenMP\\\"}\")\nendif()\nendmacro()\n-macro(add_mpi_test_with_modes exe)\n- add_test_with_modes_and_nranks(${exe} 2)\n-endmacro()\n-\n-macro(add_test_with_modes exe)\n- add_test_with_modes_and_nranks(${exe} 1)\n-endmacro()\n-\nmacro(add_test_without_mode exe)\nadd_test(NAME ${exe} COMMAND ${exe} --verbose)\nset_property(TEST ${exe} APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa)\n@@ -72,16 +60,6 @@ macro(compile_cpp_example_with_modes target file)\nendif()\nendmacro()\n-macro(compile_cpp_mpi_example_with_modes target file)\n- add_executable(examples_cpp_${target} ${file})\n- target_link_libraries(examples_cpp_${target} libocca)\n- target_include_directories(examples_cpp_${target} PRIVATE\n- $<BUILD_INTERFACE:${OCCA_SOURCE_DIR}/src>)\n- if (ENABLE_TESTS)\n- add_mpi_test_with_modes(examples_cpp_${target})\n- endif()\n-endmacro()\n-\nadd_subdirectory(c)\nadd_subdirectory(cpp)\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/build/Makefile",
"new_path": "scripts/build/Makefile",
"diff": "@@ -496,7 +496,6 @@ else\nendif\nOCCA_FORTRAN_ENABLED := $(fortranEnabled)\n-OCCA_MPI_ENABLED := $(mpiEnabled)\nOCCA_OPENMP_ENABLED := $(openmpEnabled)\nOCCA_CUDA_ENABLED := $(cudaEnabled)\nOCCA_HIP_ENABLED := $(hipEnabled)\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/build/compiledDefinesTemplate.hpp",
"new_path": "scripts/build/compiledDefinesTemplate.hpp",
"diff": "#define OCCA_USING_VS @@OCCA_USING_VS@@\n#define OCCA_UNSAFE @@OCCA_UNSAFE@@\n-#define OCCA_MPI_ENABLED @@OCCA_MPI_ENABLED@@\n#define OCCA_OPENMP_ENABLED @@OCCA_OPENMP_ENABLED@@\n#define OCCA_CUDA_ENABLED @@OCCA_CUDA_ENABLED@@\n#define OCCA_HIP_ENABLED @@OCCA_HIP_ENABLED@@\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/build/compiledDefinesTemplate.hpp.in",
"new_path": "scripts/build/compiledDefinesTemplate.hpp.in",
"diff": "#cmakedefine01 OCCA_USING_VS\n#cmakedefine01 OCCA_UNSAFE\n-#cmakedefine01 OCCA_MPI_ENABLED\n#cmakedefine01 OCCA_OPENMP_ENABLED\n#cmakedefine01 OCCA_OPENCL_ENABLED\n#cmakedefine01 OCCA_CUDA_ENABLED\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/bin/occa.cpp",
"new_path": "src/occa/internal/bin/occa.cpp",
"diff": "@@ -259,7 +259,6 @@ namespace occa {\n<< \" - OCCA_OPENCL_ENABLED : \" << envEcho(\"OCCA_OPENCL_ENABLED\", OCCA_OPENCL_ENABLED) << \"\\n\"\n<< \" - OCCA_DPCPP_ENABLED : \" << envEcho(\"OCCA_DPCPP_ENABLED\", OCCA_DPCPP_ENABLED) << \"\\n\"\n<< \" - OCCA_METAL_ENABLED : \" << envEcho(\"OCCA_METAL_ENABLED\", OCCA_METAL_ENABLED) << \"\\n\"\n- << \" - OCCA_MPI_ENABLED : \" << envEcho(\"OCCA_MPI_ENABLED\", OCCA_MPI_ENABLED) << \"\\n\"\n<< \" Run-Time Options:\\n\"\n<< \" - OCCA_CXX : \" << envEcho(\"OCCA_CXX\") << \"\\n\"\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[CMake/Make/bin] Remove vestigial MPI support (#611)
|
378,362 |
15.08.2022 22:06:32
| 25,200 |
b0e3385bf0dd74213ca358d64933e3b43601e213
|
Correction to OKL documentation on using multiple inner loops
|
[
{
"change_type": "MODIFY",
"old_path": "docs/guide/okl/loops-in-depth.md",
"new_path": "docs/guide/okl/loops-in-depth.md",
"diff": "@@ -32,7 +32,7 @@ Similar to outer loops, writing multiple inner loops is completely legal.\nfor (...; @outer) {\nfor (int i = 0; i < 10; ++i; @inner) {\n}\n- for (int i = 10; i < 20; ++i; @inner) {\n+ for (int i = 10; i < 10; ++i; @inner) {\n}\n}\n```\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Correction to OKL documentation on using multiple inner loops (#613)
|
378,351 |
16.08.2022 00:39:23
| 18,000 |
6b0d5f2eb4070e0d0c0b98562d949652d65157c5
|
Update loops-in-depth.md
|
[
{
"change_type": "MODIFY",
"old_path": "docs/guide/okl/loops-in-depth.md",
"new_path": "docs/guide/okl/loops-in-depth.md",
"diff": "@@ -32,7 +32,7 @@ Similar to outer loops, writing multiple inner loops is completely legal.\nfor (...; @outer) {\nfor (int i = 0; i < 10; ++i; @inner) {\n}\n- for (int i = 10; i < 10; ++i; @inner) {\n+ for (int i = 10; i < 20; ++i; @inner) {\n}\n}\n```\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Update loops-in-depth.md
|
378,351 |
16.08.2022 15:07:22
| 18,000 |
2e576e69e07627a516b568079e047965a9bd8d24
|
[bugfix] OKL for loop init statement
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/oklForStatement.cpp",
"new_path": "src/occa/internal/lang/modes/oklForStatement.cpp",
"diff": "@@ -52,7 +52,7 @@ namespace occa {\nif (!(0 < loop_range)) {\nvalid = false;\nif(printErrors_)\n- forSmnt_.printError(\"OKL for loop is empty or infinite!\");\n+ forSmnt_.printError(\"OKL for loop range is empty or infinite!\");\n}\n}\ndelete loop_range_node;\n@@ -75,27 +75,52 @@ namespace occa {\nbool oklForStatement::hasValidInit() {\nstatement_t &initSmnt = *(forSmnt.init);\n- // Check for declaration\n- if (initSmnt.type() != statementType::declaration) {\n- if (printErrors) {\n- initSmnt.printError(sourceStr() + \"Expected a declaration statement\");\n+ const auto init_statement_type = initSmnt.type();\n+\n+ if(statementType::empty == init_statement_type) {\n+ if(printErrors)\n+ initSmnt.printError(sourceStr()\n+ + \"OKL for loop init-statement cannot be be a null statement\");\n+ return false;\n}\n+\n+ if(statementType::declaration != init_statement_type) {\n+ if(printErrors)\n+ initSmnt.printError(sourceStr()\n+ + \"OKL for loop init-statement must be a simple declaration with initializer\");\nreturn false;\n}\n+\n// Can only have one declaration\ndeclarationStatement &declSmnt = (declarationStatement&) initSmnt;\n+\nif (declSmnt.declarations.size() > 1) {\nif (printErrors) {\ndeclSmnt.declarations[1].printError(\n- sourceStr() + \"Can only have 1 iterator variable\"\n+ sourceStr() + \"OKL for loops can only have 1 iterator variable\"\n);\n}\nreturn false;\n}\n+\n// Get iterator and value\nvariableDeclaration &decl = declSmnt.declarations[0];\niterator = &decl.variable();\n+ if(!(iterator->isNamed())) {\n+ if(printErrors)\n+ declSmnt.printError(sourceStr()\n+ + \"OKL for loop variable does not have a name.\");\n+ return false;\n+ }\n+\n+ if(!decl.hasValue()) {\n+ if(printErrors)\n+ decl.printError(sourceStr()\n+ + \"OKL for loop variable is not initialized.\");\n+ return false;\n+ }\ninitValue = decl.value;\n+\n// Valid types: {char, short, int, long}\nconst type_t *type = iterator->vartype.flatten().type;\nif (!type ||\n@@ -103,7 +128,7 @@ namespace occa {\n(*type != short_) &&\n(*type != int_))) {\nif (printErrors) {\n- iterator->printError(sourceStr() + \"Iterator variable needs to be of type\"\n+ iterator->printError(sourceStr() + \"OKL for loop iterator variable needs to be of type\"\n\" [char, short, int, long]\");\n}\nreturn false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/variable.cpp",
"new_path": "src/occa/internal/lang/variable.cpp",
"diff": "@@ -49,7 +49,7 @@ namespace occa {\n}\nbool variable_t::isNamed() const {\n- return source->value.size();\n+ return !(this->name().empty());\n}\nstd::string& variable_t::name() {\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/src/internal/lang/modes/okl.cpp",
"new_path": "tests/src/internal/lang/modes/okl.cpp",
"diff": "@@ -97,6 +97,9 @@ void testProperOKLLoops() {\nparseBadOKLSource(oStart + \"for (int o = 0; o < 2;; @outer) {\" + oMid + \"}\" + oEnd);\nparseBadOKLSource(oStart + \"for (int o = 0; o < 2; o *= 2; @outer) {\" + oMid + \"}\" + oEnd);\nparseBadOKLSource(oStart + \"for (int o = 0; o < 2; ++j; @outer) {\" + oMid + \"}\" + oEnd);\n+ parseBadOKLSource(oStart + \"for (int o; o < 2; ++o; @outer) {\" + oMid + \"}\" + oEnd);\n+ parseBadOKLSource(oStart + \"for (int; o < 2; ++o; @outer) {\" + oMid + \"}\" + oEnd);\n+ parseBadOKLSource(oStart + \"for ( ; o < 2; ++o; @outer) {\" + oMid + \"}\" + oEnd);\nparseBadOKLSource(iStart + \"for (i = 0;;; @inner) {}\" + iEnd);\nparseBadOKLSource(iStart + \"for (float i = 0;;; @inner) {}\" + iEnd);\n@@ -107,6 +110,9 @@ void testProperOKLLoops() {\nparseBadOKLSource(iStart + \"for (int i = 0; i < 2;; @inner) {}\" + iEnd);\nparseBadOKLSource(iStart + \"for (int i = 0; i < 2; i *= 2; @inner) {}\" + iEnd);\nparseBadOKLSource(iStart + \"for (int i = 0; i < 2; ++j; @inner) {}\" + iEnd);\n+ parseBadOKLSource(iStart + \"for (int i; i < 2; ++i; @inner) {}\" + iEnd);\n+ parseBadOKLSource(iStart + \"for (int; i < 2; ++i; @inner) {}\" + iEnd);\n+ parseBadOKLSource(iStart + \"for ( ; i < 2; ++i; @inner) {}\" + iEnd);\n// No double @outer + @inner\nparseBadOKLSource(\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[bugfix] OKL for loop init statement (#618)
|
378,341 |
15.08.2022 19:01:50
| -7,200 |
7c7b296eacc8fa6fea1c37f1a519f16b04afba02
|
[OKL] Extend allowed loop index types to include `size_t` and `ptrdiff_t`
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/oklForStatement.cpp",
"new_path": "src/occa/internal/lang/modes/oklForStatement.cpp",
"diff": "@@ -120,16 +120,17 @@ namespace occa {\nreturn false;\n}\ninitValue = decl.value;\n-\n- // Valid types: {char, short, int, long}\n+ // Valid types: {char, short, int, long, ptrdiff_t, size_t}\nconst type_t *type = iterator->vartype.flatten().type;\nif (!type ||\n((*type != char_) &&\n(*type != short_) &&\n- (*type != int_))) {\n+ (*type != int_) &&\n+ (*type != ptrdiff_t_) &&\n+ (*type != size_t_))) {\nif (printErrors) {\n- iterator->printError(sourceStr() + \"OKL for loop iterator variable needs to be of type\"\n- \" [char, short, int, long]\");\n+ iterator->printError(sourceStr() + \"Iterator variable needs to be of type\"\n+ \" [char, short, int, long, ptrdiff_t, size_t]\");\n}\nreturn false;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/src/loops/forLoop.cpp",
"new_path": "tests/src/loops/forLoop.cpp",
"diff": "@@ -52,7 +52,7 @@ void testOuterForLoops(occa::device device) {\n.outer(length)\n.run(OCCA_FUNCTION(scope, [=](const int outerIndex) -> void {\nOKL(\"@inner\");\n- for (int i = 0; i < 2; ++i) {\n+ for (long i = 0; i < 2; ++i) {\nconst int globalIndex = i + (2 * outerIndex);\noutput[globalIndex] = globalIndex;\n}\n@@ -86,7 +86,7 @@ void testOuterForLoops(occa::device device) {\n.outer(length, occa::range(length), indexArray)\n.run(OCCA_FUNCTION(scope, [=](const int3 outerIndex) -> void {\nOKL(\"@inner\");\n- for (int i = 0; i < 2; ++i) {\n+ for (size_t i = 0; i < 2; ++i) {\nconst int globalIndex = (\ni + (2 * (outerIndex.z + length * (outerIndex.y + length * outerIndex.x)))\n);\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[OKL] Extend allowed loop index types to include `size_t` and `ptrdiff_t` (#614)
|
378,351 |
16.08.2022 23:12:25
| 0 |
a04249dfc1c1a10f89b35370a5d18b63c6323898
|
Add Fortran to CI pipeline.
|
[
{
"change_type": "MODIFY",
"old_path": ".github/workflows/build.yml",
"new_path": ".github/workflows/build.yml",
"diff": "@@ -26,8 +26,10 @@ jobs:\nCC: gcc-9\nCXX: g++-9\nCXXFLAGS: -Wno-maybe-uninitialized -Wno-cpp\n+ FC: gfortran-9\nGCOV: gcov-9\nOCCA_COVERAGE: 1\n+ OCCA_FORTRAN_ENABLED: 1\nuseCMake: true\n- name: \"[Ubuntu] clang-11\"\n@@ -49,9 +51,10 @@ jobs:\nCC: icx\nCXX: icpx\nCXXFLAGS: -Wno-uninitialized\n- FC: ifx\n+ FC: ifort\nGCOV: gcov-9\nOCCA_COVERAGE: 1\n+ OCCA_FORTRAN_ENABLED: 1\nuseCMake: true\nuseoneAPI: true\n@@ -60,8 +63,10 @@ jobs:\nCC: gcc-9\nCXX: g++-9\nCXXFLAGS: -Wno-maybe-uninitialized\n+ FC: gfortran-9\nGCOV: gcov-9\nOCCA_COVERAGE: 1\n+ OCCA_FORTRAN_ENABLED: 1\n- name: \"[MacOS] clang\"\nos: macos-latest\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Add Fortran to CI pipeline.
|
378,341 |
18.08.2022 18:47:55
| -7,200 |
b3a6b2d45308d8734d6c45550f5b0de332b60b68
|
Show compiler output for kernel if verbose is true
This behaviour was changed for CUDA in the v1.3 release, but getting e.g.
information about register spilling is very useful.
Also implement similar behaviour for HIP and Metal.
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/cuda/device.cpp",
"new_path": "src/occa/internal/modes/cuda/device.cpp",
"diff": "@@ -319,6 +319,8 @@ namespace occa {\n<< \"Output:\\n\\n\"\n<< commandOutput << \"\\n\"\n);\n+ } else if (verbose) {\n+ io::stdout << \"Output:\\n\\n\" << commandOutput << \"\\n\";\n}\n//================================\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/hip/device.cpp",
"new_path": "src/occa/internal/modes/hip/device.cpp",
"diff": "@@ -310,6 +310,8 @@ namespace occa {\n<< \"Output:\\n\\n\"\n<< commandOutput << \"\\n\"\n);\n+ } else if (verbose) {\n+ io::stdout << \"Output:\\n\\n\" << commandOutput << \"\\n\";\n}\n//================================\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/metal/device.cpp",
"new_path": "src/occa/internal/modes/metal/device.cpp",
"diff": "@@ -176,6 +176,8 @@ namespace occa {\n<< \"Output:\\n\\n\"\n<< commandOutput << \"\\n\"\n);\n+ } else if (verbose) {\n+ io::stdout << \"Output:\\n\\n\" << commandOutput << \"\\n\";\n}\nreturn true;\n@@ -212,6 +214,8 @@ namespace occa {\n<< \"Output:\\n\\n\"\n<< commandOutput << \"\\n\"\n);\n+ } else if (verbose) {\n+ io::stdout << \"Output:\\n\\n\" << commandOutput << \"\\n\";\n}\n//================================\n}\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Show compiler output for kernel if verbose is true (#619)
This behaviour was changed for CUDA in the v1.3 release, but getting e.g.
information about register spilling is very useful.
Also implement similar behaviour for HIP and Metal.
|
378,355 |
03.10.2022 11:06:35
| 18,000 |
fc52c1056a2103c189e25dcfc8b414443135e1fa
|
[CUDA][HIP][DPC++] Fix an issue with double frees when OKL has multiple kernels
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/cuda/device.cpp",
"new_path": "src/occa/internal/modes/cuda/device.cpp",
"diff": "@@ -348,6 +348,7 @@ namespace occa {\nkernel &k = *(new kernel(this,\nkernelName,\nsourceFilename,\n+ cuModule,\nkernelProps));\nk.launcherKernel = buildLauncherKernel(kernelHash,\n@@ -377,7 +378,6 @@ namespace occa {\nkernel *cuKernel = new kernel(this,\nmetadata.name,\nsourceFilename,\n- cuModule,\ncuFunction,\nkernelProps);\ncuKernel->metadata = metadata;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/cuda/kernel.cpp",
"new_path": "src/occa/internal/modes/cuda/kernel.cpp",
"diff": "@@ -10,11 +10,21 @@ namespace occa {\nkernel::kernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n+ CUmodule cuModule_,\nconst occa::json &properties_) :\nocca::launchedModeKernel_t(modeDevice_, name_, sourceFilename_, properties_),\n- cuModule(NULL),\n+ cuModule(cuModule_),\ncuFunction(NULL) {}\n+ kernel::kernel(modeDevice_t *modeDevice_,\n+ const std::string &name_,\n+ const std::string &sourceFilename_,\n+ CUfunction cuFunction_,\n+ const occa::json &properties_) :\n+ occa::launchedModeKernel_t(modeDevice_, name_, sourceFilename_, properties_),\n+ cuModule(NULL),\n+ cuFunction(cuFunction_) {}\n+\nkernel::kernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/cuda/kernel.hpp",
"new_path": "src/occa/internal/modes/cuda/kernel.hpp",
"diff": "@@ -23,6 +23,13 @@ namespace occa {\nkernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n+ CUmodule cuModule_,\n+ const occa::json &properties_);\n+\n+ kernel(modeDevice_t *modeDevice_,\n+ const std::string &name_,\n+ const std::string &sourceFilename_,\n+ CUfunction cuFunction_,\nconst occa::json &properties_);\nkernel(modeDevice_t *modeDevice_,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/dpcpp/device.cpp",
"new_path": "src/occa/internal/modes/dpcpp/device.cpp",
"diff": "@@ -246,9 +246,12 @@ namespace occa\nlang::sourceMetadata_t &deviceMetadata,\nconst occa::json &kernelProps)\n{\n+ void *dl_handle = sys::dlopen(binaryFilename);\n+\ndpcpp::kernel &k = *(new dpcpp::kernel(this,\nkernelName,\nsourceFilename,\n+ dl_handle,\nkernelProps));\nk.launcherKernel = buildLauncherKernel(kernelHash,\n@@ -260,8 +263,6 @@ namespace occa\nkernelName,\ndeviceMetadata);\n- void *dl_handle = sys::dlopen(binaryFilename);\n-\nconst int launchedKernelsCount = (int)launchedKernelsMetadata.size();\nfor (int i = 0; i < launchedKernelsCount; ++i)\n{\n@@ -279,7 +280,6 @@ namespace occa\nkernel *dpcppKernel = new dpcpp::kernel(this,\nmetadata.name,\nsourceFilename,\n- dl_handle,\nkernel_function,\nkernelProps);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/dpcpp/kernel.cpp",
"new_path": "src/occa/internal/modes/dpcpp/kernel.cpp",
"diff": "@@ -14,13 +14,25 @@ namespace occa\nkernel::kernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n+ void *dlHandle_,\nconst occa::json &properties_)\n: occa::launchedModeKernel_t(modeDevice_, name_, sourceFilename_, properties_),\n- dlHandle{nullptr},\n+ dlHandle{dlHandle_},\nfunction{nullptr}\n{\n}\n+ kernel::kernel(modeDevice_t *modeDevice_,\n+ const std::string &name_,\n+ const std::string &sourceFilename_,\n+ functionPtr_t function_,\n+ const occa::json &properties_)\n+ : occa::launchedModeKernel_t(modeDevice_, name_, sourceFilename_, properties_),\n+ dlHandle(nullptr),\n+ function(function_)\n+ {\n+ }\n+\nkernel::kernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/dpcpp/kernel.hpp",
"new_path": "src/occa/internal/modes/dpcpp/kernel.hpp",
"diff": "@@ -24,6 +24,13 @@ namespace occa\nkernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n+ void* dlHandle_,\n+ const occa::json &properties_);\n+\n+ kernel(modeDevice_t *modeDevice_,\n+ const std::string &name_,\n+ const std::string &sourceFilename_,\n+ functionPtr_t function_,\nconst occa::json &properties_);\nkernel(modeDevice_t *modeDevice_,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/hip/device.cpp",
"new_path": "src/occa/internal/modes/hip/device.cpp",
"diff": "@@ -333,6 +333,7 @@ namespace occa {\nkernel &k = *(new kernel(this,\nkernelName,\nsourceFilename,\n+ hipModule,\nkernelProps));\nk.launcherKernel = buildLauncherKernel(kernelHash,\n@@ -360,7 +361,6 @@ namespace occa {\nkernel *hipKernel = new kernel(this,\nmetadata.name,\nsourceFilename,\n- hipModule,\nhipFunction,\nkernelProps);\nhipKernel->metadata = metadata;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/hip/kernel.cpp",
"new_path": "src/occa/internal/modes/hip/kernel.cpp",
"diff": "@@ -10,11 +10,21 @@ namespace occa {\nkernel::kernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n+ hipModule_t hipModule_,\nconst occa::json &properties_) :\nocca::launchedModeKernel_t(modeDevice_, name_, sourceFilename_, properties_),\n- hipModule(NULL),\n+ hipModule(hipModule_),\nhipFunction(NULL) {}\n+ kernel::kernel(modeDevice_t *modeDevice_,\n+ const std::string &name_,\n+ const std::string &sourceFilename_,\n+ hipFunction_t hipFunction_,\n+ const occa::json &properties_) :\n+ occa::launchedModeKernel_t(modeDevice_, name_, sourceFilename_, properties_),\n+ hipModule(NULL),\n+ hipFunction(hipFunction_) {}\n+\nkernel::kernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/hip/kernel.hpp",
"new_path": "src/occa/internal/modes/hip/kernel.hpp",
"diff": "@@ -21,6 +21,13 @@ namespace occa {\nkernel(modeDevice_t *modeDevice_,\nconst std::string &name_,\nconst std::string &sourceFilename_,\n+ hipModule_t hipModule_,\n+ const occa::json &properties_);\n+\n+ kernel(modeDevice_t *modeDevice_,\n+ const std::string &name_,\n+ const std::string &sourceFilename_,\n+ hipFunction_t hipFunction_,\nconst occa::json &properties_);\nkernel(modeDevice_t *modeDevice_,\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[CUDA][HIP][DPC++] Fix an issue with double frees when OKL has multiple kernels (#624)
|
378,355 |
03.10.2022 11:12:24
| 18,000 |
a789e9f46746a90cc9e78d9bfd3f0adc1901c792
|
[Serial] Add dynamic exclusive variable sizes
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/serial.cpp",
"new_path": "src/occa/internal/lang/modes/serial.cpp",
"diff": "#include <occa/internal/lang/modes/serial.hpp>\n#include <occa/internal/lang/modes/okl.hpp>\n+#include <occa/internal/lang/modes/oklForStatement.hpp>\n#include <occa/internal/lang/builtins/types.hpp>\n#include <occa/internal/lang/expr.hpp>\n@@ -133,7 +134,7 @@ namespace occa {\n(smnt->type() & statementType::declaration)\n&& ((declarationStatement*) smnt)->declaresVariable(var)\n) {\n- defineExclusiveVariableAsArray(var);\n+ defineExclusiveVariableAsArray((declarationStatement&) *smnt, var);\nreturn &varNode;\n}\n@@ -264,12 +265,122 @@ namespace occa {\n}\n}\n- void serialParser::defineExclusiveVariableAsArray(variable_t &var) {\n- // TODO: Dynamic array sizes\n- // Define the variable as a stack array\n+ int serialParser::getInnerLoopLevel(forStatement &forSmnt) {\n+ statement_t *smnt = forSmnt.up;\n+ int level = 0;\n+ while (smnt) {\n+ if ((smnt->type() & statementType::for_)\n+ && smnt->hasAttribute(\"inner\")) {\n+ ++level;\n+ }\n+ smnt = smnt->up;\n+ }\n+ return level;\n+ }\n+\n+ forStatement* serialParser::getInnerMostInnerLoop(forStatement &forSmnt) {\n+ int maxLevel = -1;\n+ forStatement *innerMostInnerLoop = NULL;\n+\n+ statementArray::from(forSmnt)\n+ .flatFilterByAttribute(\"inner\")\n+ .filterByStatementType(statementType::for_)\n+ .forEach([&](statement_t *smnt) {\n+ forStatement &innerSmnt = (forStatement&) *smnt;\n+ const int level = getInnerLoopLevel(innerSmnt);\n+ if (level > maxLevel) {\n+ maxLevel = level;\n+ innerMostInnerLoop = &innerSmnt;\n+ }\n+ });\n+\n+ return innerMostInnerLoop;\n+ }\n+\n+ void serialParser::defineExclusiveVariableAsArray(declarationStatement &declSmnt,\n+ variable_t &var) {\n+ // Find outer-most outer loop\n+ statement_t *smnt = declSmnt.up;\n+ forStatement *outerMostOuterLoop = NULL;\n+ while (smnt) {\n+ if (smnt->hasAttribute(\"outer\")) {\n+ outerMostOuterLoop = (forStatement*) smnt;\n+ }\n+ smnt = smnt->up;\n+ }\n+\n+ // Check if outer loop has max_inner_dims set\n+ bool maxInnerDimsKnown{false};\n+ int maxInnerDims[3] = {1,1,1};\n+ if (outerMostOuterLoop->hasAttribute(\"max_inner_dims\")) {\n+ maxInnerDimsKnown = true;\n+ attributeToken_t& attr = outerMostOuterLoop->attributes[\"max_inner_dims\"];\n+\n+ for(size_t i=0; i < attr.args.size(); ++i) {\n+ exprNode* expr = attr.args[i].expr;\n+ primitive value = expr->evaluate();\n+ maxInnerDims[i] = value;\n+ }\n+ }\n+\n+ //Check if inner dimensions are known at compile time\n+ bool innerDimsKnown{true};\n+ int knownInnerDims[3] = {1,1,1};\n+ forStatement *innerSmnt = getInnerMostInnerLoop(*outerMostOuterLoop);\n+ statementArray path = oklForStatement::getOklLoopPath(*innerSmnt);\n+\n+ int innerIndex;\n+ const int pathCount = (int) path.length();\n+ for (int i = 0; i < pathCount; ++i) {\n+ forStatement &pathSmnt = *((forStatement*) path[i]);\n+ oklForStatement oklForSmnt(pathSmnt);\n+\n+ if(pathSmnt.hasAttribute(\"inner\")) {\n+ innerIndex = oklForSmnt.oklLoopIndex();\n+ if(oklForSmnt.getIterationCount()->canEvaluate()) {\n+ knownInnerDims[innerIndex] = (int) oklForSmnt.getIterationCount()->evaluate();\n+ } else {\n+ std::string s = oklForSmnt.getIterationCount()->toString();\n+ if(s.find(\"_occa_tiled_\") != std::string::npos) {\n+ size_t tile_size = s.find_first_of(\"123456789\");\n+ OCCA_ERROR(\"@tile size is undefined!\",tile_size != std::string::npos);\n+ knownInnerDims[innerIndex] = std::stoi(s.substr(tile_size));\n+ } else {\n+ //loop bounds are unknown at compile time\n+ innerDimsKnown=false;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+ const int knownInnerDim = knownInnerDims[0]\n+ * knownInnerDims[1]\n+ * knownInnerDims[2];\n+ const int maxInnerDim = maxInnerDims[0]\n+ * maxInnerDims[1]\n+ * maxInnerDims[2];\n+\n+ if (innerDimsKnown & maxInnerDimsKnown) {\n+ if (knownInnerDim > maxInnerDim) {\n+ outerMostOuterLoop->printError(\"[@inner] loop dimensions larger then allowed by [@max_inner_dims]\");\n+ success=false;\n+ return;\n+ }\n+ }\n+\n+ // Determine how long the exclusive array should be\n+ int exclusiveArraySize = 1024;\n+ if (maxInnerDimsKnown) {\n+ exclusiveArraySize = maxInnerDim;\n+ }\n+ if (innerDimsKnown) {\n+ exclusiveArraySize = knownInnerDim;\n+ }\n+\n+ // Make exclusive variable declaration into an array\n// For example:\n// const int x\n- // -> const int x[256]\n+ // -> const int x[1024]\noperatorToken startToken(var.source->origin,\nop::bracketStart);\noperatorToken endToken(var.source->origin,\n@@ -280,7 +391,7 @@ namespace occa {\narray_t(startToken,\nendToken,\nnew primitiveNode(var.source,\n- 256))\n+ exclusiveArraySize))\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/serial.hpp",
"new_path": "src/occa/internal/lang/modes/serial.hpp",
"diff": "@@ -26,7 +26,12 @@ namespace occa {\nvoid setupExclusiveDeclaration(declarationStatement &declSmnt);\nvoid setupExclusiveIndices();\n- void defineExclusiveVariableAsArray(variable_t &var);\n+ int getInnerLoopLevel(forStatement &forSmnt);\n+\n+ forStatement* getInnerMostInnerLoop(forStatement &forSmnt);\n+\n+ void defineExclusiveVariableAsArray(declarationStatement &declSmnt,\n+ variable_t &var);\nexprNode* addExclusiveVariableArrayAccessor(statement_t &smnt,\nexprNode &expr,\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[Serial] Add dynamic exclusive variable sizes (#625)
|
378,355 |
17.10.2022 13:31:15
| 18,000 |
219dbf1b0cc715efae2722f2d712d66771c6a112
|
[OpenMP] Fix bug with cancelling hash
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/openmp/device.cpp",
"new_path": "src/occa/internal/modes/openmp/device.cpp",
"diff": "@@ -14,14 +14,14 @@ namespace occa {\nhash_t device::hash() const {\nreturn (\nserial::device::hash()\n- ^ occa::hash(\"openmp\")\n+ ^ occa::hash(\"openmp device::hash\")\n);\n}\nhash_t device::kernelHash(const occa::json &props) const {\nreturn (\nserial::device::kernelHash(props)\n- ^ occa::hash(\"openmp\")\n+ ^ occa::hash(\"openmp device::kernelHash\")\n);\n}\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[OpenMP] Fix bug with cancelling hash (#626)
|
378,351 |
07.11.2022 12:26:01
| 21,600 |
b6332e0c116965a396d26daa072df6075028edae
|
Removes call to `occa info` during build.
Calling `occa info` during the CMake build causes some CI pipelines to fail and issues when cross-compiling (e.g., on the login-node of an HPC system).
Users can manually call `occa info` from the command line during an interactive build to check that everything went as expected.
|
[
{
"change_type": "MODIFY",
"old_path": "bin/CMakeLists.txt",
"new_path": "bin/CMakeLists.txt",
"diff": "@@ -5,5 +5,3 @@ target_include_directories(occa PRIVATE\n$<BUILD_INTERFACE:${OCCA_SOURCE_DIR}/src>)\ninstall(TARGETS occa EXPORT occaExport DESTINATION bin)\n-\n-add_custom_command(TARGET occa POST_BUILD COMMAND occa info)\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Removes call to `occa info` during build.
Calling `occa info` during the CMake build causes some CI pipelines to fail and issues when cross-compiling (e.g., on the login-node of an HPC system).
Users can manually call `occa info` from the command line during an interactive build to check that everything went as expected.
|
378,351 |
07.11.2022 14:24:16
| 21,600 |
8608a2c868591494d73d6302b455bbbb07ed5186
|
Updates `actions/checkout` to version 3.
Older versions of `actions/checkout` used node12, which is now deprecated on GitHub. Version 3 onward use node16.
|
[
{
"change_type": "MODIFY",
"old_path": ".github/workflows/build.yml",
"new_path": ".github/workflows/build.yml",
"diff": "@@ -89,7 +89,7 @@ jobs:\nFORTRAN_EXAMPLES: ${{ matrix.OCCA_FORTRAN_ENABLED }}\nsteps:\n- - uses: actions/checkout@v2\n+ - uses: actions/checkout@v3\n- name: add oneAPI to apt\nif: ${{ matrix.useoneAPI }}\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Updates `actions/checkout` to version 3. (#631)
Older versions of `actions/checkout` used node12, which is now deprecated on GitHub. Version 3 onward use node16.
|
378,355 |
14.11.2022 09:57:02
| 21,600 |
9866ea5e318641e59c07bbcd354e235571a57bed
|
[MemPool] Fix a bug in reservation tracking in memory pools
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/core/memoryPool.hpp",
"new_path": "src/occa/internal/core/memoryPool.hpp",
"diff": "@@ -12,8 +12,9 @@ namespace occa {\npublic:\nstruct compare {\nbool operator()(const modeMemory_t* a, const modeMemory_t* b) const {\n- return (a->offset < b->offset) ||\n- (a->offset == b->offset && a->size < b->size);\n+ if (a->offset != b->offset) return (a->offset < b->offset);\n+ if (a->size != b->size) return (a->size < b->size);\n+ return (a < b);\n};\n};\ntypedef std::set<modeMemory_t*, compare> reservationSet;\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
[MemPool] Fix a bug in reservation tracking in memory pools (#634)
|
378,351 |
02.12.2022 13:51:43
| 21,600 |
d00dd31dc4365961b774e9c512ffdbd0daf41c30
|
Adds option to control barrier insertion via kernel properties.
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/withLauncher.cpp",
"new_path": "src/occa/internal/lang/modes/withLauncher.cpp",
"diff": "@@ -16,6 +16,7 @@ namespace occa {\nparser_t(settings_),\nlauncherParser(settings[\"launcher\"]) {\nlauncherParser.settings[\"okl/validate\"] = false;\n+ add_barriers = settings.get(\"okl/add_barriers\", true);\n}\n//---[ Public ]-------------------\n@@ -622,7 +623,7 @@ namespace occa {\n}\nbool withLauncher::usesBarriers() {\n- return true;\n+ return add_barriers;\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/lang/modes/withLauncher.hpp",
"new_path": "src/occa/internal/lang/modes/withLauncher.hpp",
"diff": "@@ -8,6 +8,8 @@ namespace occa {\nnamespace lang {\nnamespace okl {\nclass withLauncher : public parser_t {\n+ private:\n+ bool add_barriers{true};\npublic:\nserialParser launcherParser;\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Adds option to control barrier insertion via kernel properties. (#637)
|
378,351 |
16.12.2022 16:55:20
| 0 |
0d8fbfa7a817a4cd65c9f5ded52baca2fef692c1
|
Updates GitHub build workflow to be compatible with new runner images.
|
[
{
"change_type": "MODIFY",
"old_path": ".github/workflows/build.yml",
"new_path": ".github/workflows/build.yml",
"diff": "@@ -11,67 +11,53 @@ jobs:\nstrategy:\nmatrix:\ninclude:\n- - name: \"[Ubuntu] gcc-9\"\n- os: ubuntu-latest\n- CC: gcc-9\n- CXX: g++-9\n+ - name: \"[Ubuntu] gcc-12\"\n+ os: ubuntu-22.04\n+ CC: gcc-12\n+ CXX: g++-12\nCXXFLAGS: -Wno-maybe-uninitialized\n- FC: gfortran-9\n- GCOV: gcov-9\n+ FC: gfortran-12\n+ GCOV: gcov-12\nOCCA_COVERAGE: 1\nOCCA_FORTRAN_ENABLED: 1\n- - name: \"[Ubuntu] CMake + gcc-9\"\n- os: ubuntu-latest\n- CC: gcc-9\n- CXX: g++-9\n+ - name: \"[Ubuntu] CMake + gcc-12\"\n+ os: ubuntu-22.04\n+ CC: gcc-12\n+ CXX: g++-12\nCXXFLAGS: -Wno-maybe-uninitialized -Wno-cpp\n- FC: gfortran-9\n- GCOV: gcov-9\n- OCCA_COVERAGE: 1\n+ FC: gfortran-12\nOCCA_FORTRAN_ENABLED: 1\nuseCMake: true\n- - name: \"[Ubuntu] clang-11\"\n- os: ubuntu-latest\n- CC: clang-11\n- CXX: clang++-11\n+ - name: \"[Ubuntu] clang-14\"\n+ os: ubuntu-22.04\n+ CC: clang-14\n+ CXX: clang++-14\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n- - name: \"[Ubuntu] clang-10\"\n- os: ubuntu-latest\n- CC: clang-10\n- CXX: clang++-10\n+ - name: \"[Ubuntu] clang-12\"\n+ os: ubuntu-22.04\n+ CC: clang-12\n+ CXX: clang++-12\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n- name: \"[Ubuntu] CMake + Intel/LLVM\"\n- os: ubuntu-latest\n+ os: ubuntu-22.04\nCC: icx\nCXX: icpx\nCXXFLAGS: -Wno-uninitialized\n- FC: ifx\n- GCOV: gcov-9\n- OCCA_COVERAGE: 1\n+ OCCA_COVERAGE: 0\nuseCMake: true\nuseoneAPI: true\n- - name: \"[MacOS] gcc-9\"\n- os: macos-latest\n- CC: gcc-9\n- CXX: g++-9\n- CXXFLAGS: -Wno-maybe-uninitialized\n- GCOV: gcov-9\n- OCCA_COVERAGE: 1\n-\n- name: \"[MacOS] clang\"\n- os: macos-latest\n+ os: macos-12\nCC: clang\nCXX: clang++\nCXXFLAGS: -Wno-uninitialized\n- OCCA_COVERAGE: 0\n-\nruns-on: ${{ matrix.os }}\nname: ${{ matrix.name }}\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/build/Makefile",
"new_path": "scripts/build/Makefile",
"diff": "@@ -122,7 +122,7 @@ else\nendif\nifeq ($(OCCA_COVERAGE),1)\n- coverageFlags = --coverage -fno-inline -fno-inline-small-functions -fno-default-inline\n+ coverageFlags = --coverage\ncompilerFlags += $(coverageFlags)\ncCompilerFlags += $(coverageFlags)\nfCompilerFlags += $(coverageFlags)\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Updates GitHub build workflow to be compatible with new runner images.
|
378,351 |
19.12.2022 21:18:25
| 0 |
abff9735090109898cf3168ce9ee9295912a65e5
|
Updates DPCPP polyfill and function calls.
|
[
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/dpcpp/device.cpp",
"new_path": "src/occa/internal/modes/dpcpp/device.cpp",
"diff": "@@ -323,7 +323,7 @@ namespace occa\ndim device::maxInnerDims() const\n{\n- ::sycl::id<3> max_wi_sizes{dpcppDevice.get_info<::sycl::info::device::max_work_item_sizes>()};\n+ ::sycl::id<3> max_wi_sizes{dpcppDevice.get_info<::sycl::info::device::max_work_item_sizes<3>>()};\nreturn dim{max_wi_sizes[occa::dpcpp::x_index],\nmax_wi_sizes[occa::dpcpp::y_index],\nmax_wi_sizes[occa::dpcpp::z_index]};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/dpcpp/polyfill.hpp",
"new_path": "src/occa/internal/modes/dpcpp/polyfill.hpp",
"diff": "#include <sycl.hpp>\n#else\n#include <vector>\n-namespace sycl\n-{\n+namespace sycl {\n+\nclass device;\nclass platform;\ntemplate <std::size_t N>\n- struct id\n- {\n+struct id {\nstd::size_t values_[N];\n-\n- std::size_t operator[](int dimension) const\n- {\n- return values_[dimension];\n- }\n+ std::size_t operator[](int dimension) const {return values_[dimension];}\n};\ntemplate <std::size_t N>\n- struct range\n- {\n+struct range {\nstd::size_t values_[N];\n};\ntemplate <std::size_t N>\n- struct nd_range\n- {\n+struct nd_range {\nrange<N> global_range_;\nrange<N> local_range_;\n};\n- class exception : std::exception\n- {\n+class exception : std::exception {\npublic:\n- inline const char *what() const noexcept\n- {\n+ inline const char *what() const noexcept {\nreturn \"Error-DPC++ not enabled!\";\n}\n};\n- namespace info\n- {\n- enum class device\n- {\n- device_type,\n- max_compute_units,\n- global_mem_size,\n- local_mem_size,\n- platform,\n- name,\n- vendor,\n- version,\n- max_work_item_sizes,\n- max_work_group_size\n- };\n+namespace info {\n- enum class device_type\n- {\n+enum class device_type {\ncpu,\ngpu,\naccelerator,\nall = (cpu | gpu | accelerator)\n};\n- enum class platform\n- {\n- profile,\n- version,\n- name,\n- vendor\n- };\n-\n- enum class event_profiling\n- {\n+enum class event_profiling {\ncommand_submit,\ncommand_start,\ncommand_end\n};\n- template <typename T, T param>\n- class param_traits\n- {\n+namespace device {\n+\n+struct device_type {\n+ using return_type = info::device_type;\n};\n- template <>\n- class param_traits<device, device::max_compute_units>\n- {\n- public:\n+struct max_compute_units {\nusing return_type = uint32_t;\n};\n- template <>\n- class param_traits<device, device::global_mem_size>\n- {\n- public:\n+struct global_mem_size {\nusing return_type = uint64_t;\n};\n- template <>\n- class param_traits<device, device::local_mem_size>\n- {\n- public:\n+struct local_mem_size {\nusing return_type = uint64_t;\n};\n- template <>\n- class param_traits<device, device::name>\n- {\n- public:\n+struct name {\nusing return_type = std::string;\n};\n- template <>\n- class param_traits<device, device::vendor>\n- {\n- public:\n+struct vendor {\nusing return_type = std::string;\n};\n- template <>\n- class param_traits<device, device::version>\n- {\n- public:\n+struct version {\nusing return_type = std::string;\n};\n- template <>\n- class param_traits<device, device::max_work_item_sizes>\n- {\n- public:\n+template <int Dimensions = 3> struct max_work_item_sizes;\n+template<> struct max_work_item_sizes<3> {\nusing return_type = id<3>;\n};\n- template <>\n- class param_traits<device, device::max_work_group_size>\n- {\n- public:\n+struct max_work_group_size {\nusing return_type = std::size_t;\n};\n- template <>\n- class param_traits<device, device::device_type>\n- {\n- public:\n- using return_type = info::device_type;\n- };\n+} // namespace device\n- template <>\n- class param_traits<platform, platform::name>\n- {\n- public:\n+namespace platform {\n+\n+struct name {\nusing return_type = std::string;\n};\n- template <>\n- class param_traits<platform, platform::vendor>\n- {\n- public:\n+struct vendor {\nusing return_type = std::string;\n};\n- template <>\n- class param_traits<platform, platform::version>\n- {\n- public:\n+struct version {\nusing return_type = std::string;\n};\n- template <event_profiling I>\n- class param_traits<event_profiling, I>\n- {\n- public:\n- using return_type = uint64_t;\n- };\n+} // namespace platform\n} // namespace info\n- namespace property {\n- namespace queue {\n- class enable_profiling\n- {\n- };\n- }\n- }\nnamespace property {\nnamespace queue {\n- class in_order\n- {\n- };\n- }\n- }\n+\n+struct enable_profiling {};\n+struct in_order {};\n+\n+} // namespace queue\n+} // namespace property\nclass property_list {\npublic:\n- template <typename... propertyTN> property_list(propertyTN... props)\n- {\n+ template <typename... propertyTN>\n+ property_list(propertyTN... props) {\nthrow sycl::exception();\n}\n};\n- class device\n- {\n+class device {\npublic:\n- static std::vector<device> get_devices()\n- {\n+ static std::vector<device> get_devices() {\nthrow sycl::exception();\nreturn std::vector<device>();\n}\n- template <info::device I>\n- typename info::param_traits<info::device, I>::return_type get_info() const;\n+ template <typename T>\n+ typename T::return_type get_info() const;\n- bool is_cpu() const\n- {\n+ bool is_cpu() const {\nthrow sycl::exception();\nreturn false;\n}\n- bool is_gpu() const\n- {\n+ bool is_gpu() const {\nthrow sycl::exception();\nreturn false;\n}\n- bool is_accelerator() const\n- {\n- throw sycl::exception();\n- return false;\n- }\n-\n- bool is_host() const\n- {\n+ bool is_accelerator() const {\nthrow sycl::exception();\nreturn false;\n}\n@@ -245,218 +156,167 @@ namespace sycl\n};\ntemplate <>\n- inline info::param_traits<info::device, info::device::max_compute_units>::return_type\n- device::get_info<info::device::max_compute_units>() const\n- {\n+inline info::device::max_compute_units::return_type\n+device::get_info<info::device::max_compute_units>() const {\nthrow sycl::exception();\nreturn uint32_t(0);\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::global_mem_size>::return_type\n- device::get_info<info::device::global_mem_size>() const\n- {\n+inline info::device::global_mem_size::return_type\n+device::get_info<info::device::global_mem_size>() const {\nthrow sycl::exception();\nreturn uint64_t(0);\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::local_mem_size>::return_type\n- device::get_info<info::device::local_mem_size>() const\n- {\n+inline info::device::local_mem_size::return_type\n+device::get_info<info::device::local_mem_size>() const {\nthrow sycl::exception();\nreturn uint64_t(0);\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::name>::return_type\n- device::get_info<info::device::name>() const\n- {\n+inline info::device::name::return_type\n+device::get_info<info::device::name>() const {\nthrow sycl::exception();\nreturn \"Error--DPC++ not enabled!\";\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::vendor>::return_type\n- device::get_info<info::device::vendor>() const\n- {\n+inline info::device::vendor::return_type\n+device::get_info<info::device::vendor>() const {\nthrow sycl::exception();\nreturn \"Error--DPC++ not enabled!\";\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::version>::return_type\n- device::get_info<info::device::version>() const\n- {\n+inline info::device::version::return_type\n+device::get_info<info::device::version>() const {\nthrow sycl::exception();\nreturn \"Error--DPC++ not enabled!\";\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::device_type>::return_type\n- device::get_info<info::device::device_type>() const\n- {\n+inline info::device::device_type::return_type\n+device::get_info<info::device::device_type>() const {\nthrow sycl::exception();\nreturn info::device_type::all;\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::max_work_item_sizes>::return_type\n- device::get_info<info::device::max_work_item_sizes>() const\n- {\n+inline info::device::max_work_item_sizes<3>::return_type\n+device::get_info<info::device::max_work_item_sizes<3>>() const {\nthrow sycl::exception();\nreturn sycl::id<3>{0,0,0};\n}\ntemplate <>\n- inline info::param_traits<info::device, info::device::max_work_group_size>::return_type\n- device::get_info<info::device::max_work_group_size>() const\n- {\n+inline info::device::max_work_group_size::return_type\n+device::get_info<info::device::max_work_group_size>() const {\nthrow sycl::exception();\nreturn std::size_t(0);\n}\n- class platform\n- {\n+class platform {\npublic:\n- static std::vector<platform> get_platforms()\n- {\n+ static std::vector<platform> get_platforms() {\nthrow sycl::exception();\nreturn std::vector<platform>();\n}\n- std::vector<device> get_devices(info::device_type = info::device_type::all)\n- {\n+ std::vector<device> get_devices(info::device_type = info::device_type::all) {\nthrow sycl::exception();\nreturn std::vector<device>();\n}\n- template <info::platform I>\n- typename info::param_traits<info::platform, I>::return_type get_info() const;\n-\n- bool is_host() const\n- {\n- throw sycl::exception();\n- return false;\n- }\n+ template <typename T>\n+ typename T::return_type get_info() const;\n};\ntemplate <>\n- inline info::param_traits<info::platform, info::platform::name>::return_type\n- platform::get_info<info::platform::name>() const\n- {\n+inline info::platform::name::return_type\n+platform::get_info<info::platform::name>() const {\nthrow sycl::exception();\nreturn \"Error--DPC++ not enabled!\";\n}\ntemplate <>\n- inline info::param_traits<info::platform, info::platform::vendor>::return_type\n- platform::get_info<info::platform::vendor>() const\n- {\n+inline info::platform::vendor::return_type\n+platform::get_info<info::platform::vendor>() const {\nthrow sycl::exception();\nreturn \"Error--DPC++ not enabled!\";\n}\ntemplate <>\n- inline info::param_traits<info::platform, info::platform::version>::return_type\n- platform::get_info<info::platform::version>() const\n- {\n+inline info::platform::version::return_type\n+platform::get_info<info::platform::version>() const {\nthrow sycl::exception();\nreturn \"Error--DPC++ not enabled!\";\n}\n- inline platform device::get_platform() const\n- {\n+inline platform device::get_platform() const {\nthrow sycl::exception();\nreturn platform();\n}\n- class context\n- {\n+class context {\npublic:\ncontext() = default;\n- context(const device &syclDevice)\n- {\n- }\n+ context(const device &syclDevice){}\n};\n- class event\n- {\n+class event {\npublic:\n- void wait_and_throw()\n- {\n+ void wait_and_throw() {\nthrow sycl::exception();\n}\ntemplate <info::event_profiling I>\n- typename info::param_traits<info::event_profiling, I>::return_type get_profiling_info() const\n- {\n+ uint64_t get_profiling_info() const {\nthrow sycl::exception();\nreturn uint64_t(0);\n}\n};\n- // template <info::event_profiling I>\n- // inline info::param_traits<info::event_profiling, I>::return_type\n- // event::get_profiling_info() const\n- // {\n- // throw sycl::exception();\n- // return \"Error--DPC++ not enabled!\";\n- // }\n-\n-\n- class queue\n- {\n+class queue {\npublic:\nqueue(const context& syclContext,\nconst device &syclDevice,\n- const property_list &propList = {})\n- {\n+ const property_list &propList = {}) {\nthrow sycl::exception();\n}\n- void wait_and_throw()\n- {\n- throw sycl::exception();\n- }\n+ void wait_and_throw() {throw sycl::exception();}\n- sycl::event memcpy(void* dest,const void* src,size_t num_bytes)\n- {\n+ sycl::event memcpy(void* dest,const void* src,size_t num_bytes) {\nreturn sycl::event();\n}\n- sycl::event ext_oneapi_submit_barrier()\n- {\n- return sycl::event();\n- }\n+ sycl::event ext_oneapi_submit_barrier() { return sycl::event();}\n};\n-\ninline void* malloc_device(size_t num_bytes,\nconst device& syclDevice,\n- const context& syclContext)\n- {\n+ const context& syclContext) {\nthrow sycl::exception();\nreturn nullptr;\n}\ninline void* malloc_host(size_t num_bytes,\n- const context& syclContext)\n- {\n+ const context& syclContext) {\nthrow sycl::exception();\nreturn nullptr;\n}\ninline void* malloc_shared(size_t num_bytes,\nconst device& syclDevice,\n- const context& syclContext)\n- {\n+ const context& syclContext) {\nthrow sycl::exception();\nreturn nullptr;\n}\n- inline void free(void* ptr,context& syclContext)\n- {\n+inline void free(void* ptr,context& syclContext) {\nthrow sycl::exception();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/occa/internal/modes/dpcpp/registration.cpp",
"new_path": "src/occa/internal/modes/dpcpp/registration.cpp",
"diff": "@@ -46,10 +46,6 @@ namespace occa {\n{\ndevice_type_str = \"accelerator\";\n}\n- else if(d.is_host())\n- {\n- device_type_str = \"host\";\n- }\nelse\n{\ndevice_type_str = \"TYPE UNKNOWN\";\n"
}
] |
C++
|
MIT License
|
libocca/occa
|
Updates DPCPP polyfill and function calls.
|
675,373 |
03.01.2017 16:13:38
| -10,800 |
94b7c78b4136f755e92dda320694cd0e845b5013
|
Add test to listen network changes
|
[
{
"change_type": "MODIFY",
"old_path": "plugin.xml",
"new_path": "plugin.xml",
"diff": "<source-file src=\"src/android/java/io/jxcore/node/StreamCopyingThread.java\" target-dir=\"src/io/jxcore/node/\" />\n<source-file src=\"src/android/java/io/jxcore/node/TestHelper.java\" target-dir=\"src/io/jxcore/node/\" />\n<source-file src=\"src/android/java/io/jxcore/node/WifiLocker.java\" target-dir=\"src/io/jxcore/node/\" />\n+ <source-file src=\"src/android/java/io/jxcore/node/SurroundingStateObserver.java\" target-dir=\"src/io/jxcore/node/\" />\n<!-- ThaliPermissions -->\n<config-file target=\"config.xml\" parent=\"/*\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/ConnectionHelper.java",
"new_path": "src/android/java/io/jxcore/node/ConnectionHelper.java",
"diff": "@@ -50,6 +50,7 @@ public class ConnectionHelper\nprivate final ConnectionModel mConnectionModel;\nprivate final ConnectionManager mConnectionManager;\nprivate final DiscoveryManager mDiscoveryManager;\n+ private final SurroundingStateObserver surroundingStateObserver;\nprivate final DiscoveryManagerSettings mDiscoveryManagerSettings;\nprivate final ConnectivityMonitor mConnectivityMonitor;\nprivate final StartStopOperationHandler mStartStopOperationHandler;\n@@ -64,7 +65,7 @@ public class ConnectionHelper\n/**\n* Constructor.\n*/\n- public ConnectionHelper() {\n+ public ConnectionHelper(SurroundingStateObserver stateObserver) {\nmContext = jxcore.activity.getBaseContext();\nmThreadUncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() {\n@@ -78,6 +79,8 @@ public class ConnectionHelper\n}\n};\n+ surroundingStateObserver = stateObserver;\n+\nmConnectionModel = new ConnectionModel();\nmConnectionManager = new ConnectionManager(mContext, this, SERVICE_UUID, BLUETOOTH_NAME);\n@@ -98,7 +101,7 @@ public class ConnectionHelper\nLog.e(TAG, \"Constructor: Bluetooth LE discovery mode is not supported\");\n}\n- mConnectivityMonitor = new ConnectivityMonitor(mDiscoveryManager);\n+ mConnectivityMonitor = new ConnectivityMonitor(mDiscoveryManager, surroundingStateObserver);\nmStartStopOperationHandler = new StartStopOperationHandler(mConnectionManager, mDiscoveryManager);\n@@ -494,7 +497,7 @@ public class ConnectionHelper\n+ isDiscovering + \", is advertising: \" + isAdvertising);\nmStartStopOperationHandler.processCurrentOperationStatus();\n- JXcoreExtension.notifyDiscoveryAdvertisingStateUpdateNonTcp(isDiscovering, isAdvertising);\n+ surroundingStateObserver.notifyDiscoveryAdvertisingStateUpdateNonTcp(isDiscovering, isAdvertising);\nmNotifyDiscoveryAdvertisingStateUpdateNonTcp.cancel();\nmNotifyDiscoveryAdvertisingStateUpdateNonTcp = null;\n}\n@@ -513,7 +516,7 @@ public class ConnectionHelper\n+ \", device name: '\" + peerProperties.getDeviceName()\n+ \"', device address: '\" + peerProperties.getDeviceAddress() + \"'\");\n- JXcoreExtension.notifyPeerAvailabilityChanged(peerProperties, true);\n+ surroundingStateObserver.notifyPeerAvailabilityChanged(peerProperties, true);\n}\n/**\n@@ -527,7 +530,7 @@ public class ConnectionHelper\n+ \", device name: '\" + peerProperties.getDeviceName()\n+ \"', device address: '\" + peerProperties.getDeviceAddress() + \"'\");\n- JXcoreExtension.notifyPeerAvailabilityChanged(peerProperties, true);\n+ surroundingStateObserver.notifyPeerAvailabilityChanged(peerProperties, true);\n}\n/**\n@@ -543,7 +546,7 @@ public class ConnectionHelper\n// If we are still connected, the peer can't certainly be lost, add it back\nmDiscoveryManager.getPeerModel().addOrUpdateDiscoveredPeer(peerProperties);\n} else {\n- JXcoreExtension.notifyPeerAvailabilityChanged(peerProperties, false);\n+ surroundingStateObserver.notifyPeerAvailabilityChanged(peerProperties, false);\n}\n}\n@@ -748,7 +751,8 @@ public class ConnectionHelper\nif (!closed) {\nthrow new RuntimeException(\"Trying to close nonexistent incoming connection\");\n}\n- JXcoreExtension.notifyIncomingConnectionToPortNumberFailed(incomingSocketThread.getTcpPortNumber());\n+ surroundingStateObserver.notifyIncomingConnectionToPortNumberFailed(\n+ incomingSocketThread.getTcpPortNumber());\n}\n@Override\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/ConnectivityMonitor.java",
"new_path": "src/android/java/io/jxcore/node/ConnectivityMonitor.java",
"diff": "@@ -27,6 +27,7 @@ class ConnectivityMonitor implements BluetoothManager.BluetoothManagerListener {\nprivate final Activity mActivity = jxcore.activity;\nprivate final BluetoothManager mBluetoothManager;\nprivate final WifiDirectManager mWifiDirectManager;\n+ private final SurroundingStateObserver surroundingStateObserver;\nprivate WifiStateChangedAndConnectivityActionBroadcastReceiver mWifiStateChangedAndConnectivityActionBroadcastReceiver = null;\nprivate String mBssidName = null;\nprivate String mSsidName = null;\n@@ -38,7 +39,7 @@ class ConnectivityMonitor implements BluetoothManager.BluetoothManagerListener {\n/**\n* Constructor.\n*/\n- public ConnectivityMonitor(DiscoveryManager discoveryManager) {\n+ public ConnectivityMonitor(DiscoveryManager discoveryManager, SurroundingStateObserver stateObserver) {\nif (discoveryManager == null) {\nthrow new IllegalArgumentException(\"Discovery manager is null\");\n}\n@@ -47,6 +48,7 @@ class ConnectivityMonitor implements BluetoothManager.BluetoothManagerListener {\nmWifiDirectManager = discoveryManager.getWifiDirectManager();\nmIsBluetoothEnabled = mBluetoothManager.isBluetoothEnabled();\nmIsWifiEnabled = mWifiDirectManager.isWifiEnabled();\n+ surroundingStateObserver = stateObserver;\n}\n/**\n@@ -205,7 +207,7 @@ class ConnectivityMonitor implements BluetoothManager.BluetoothManagerListener {\n+ \"\\n - active network type is Wi-Fi: \" + mActiveNetworkTypeIsWifi);\nif (notificationNecessary) {\n- JXcoreExtension.notifyNetworkChanged(mIsBluetoothEnabled, mIsWifiEnabled, mBssidName, mSsidName);\n+ surroundingStateObserver.notifyNetworkChanged(mIsBluetoothEnabled, mIsWifiEnabled, mBssidName, mSsidName);\n}\n} else {\nLog.v(TAG, \"updateConnectivityInfo: No relevant state changes\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -29,7 +29,7 @@ import io.jxcore.node.jxcore.JXcoreCallback;\n* For the documentation, please see\n* https://github.com/thaliproject/Thali_CordovaPlugin/blob/vNext/thali/NextGeneration/thaliMobileNative.js\n*/\n-public class JXcoreExtension {\n+public class JXcoreExtension implements SurroundingStateObserver {\n// Common Thali methods and events\npublic static final String CALLBACK_VALUE_LISTENING_ON_PORT_NUMBER = \"listeningPort\";\n@@ -77,24 +77,33 @@ public class JXcoreExtension {\nprivate static final String TAG = JXcoreExtension.class.getName();\nprivate static final long INCOMING_CONNECTION_FAILED_NOTIFICATION_MIN_INTERVAL_IN_MILLISECONDS = 100;\n+ private static final String ERROR_PLATFORM_DOES_NOT_SUPPORT_MULTICONNECT = \"Platform does not support multiConnect\";\n+ private static final String ERROR_NOT_MULTICONNECT_PLATFORM = \"Not multiConnect platform\";\n+\nprivate static ConnectionHelper mConnectionHelper = null;\n- private static WifiLocker wifiLocker = new WifiLocker();\nprivate static long mLastTimeIncomingConnectionFailedNotificationWasFired = 0;\nprivate static boolean mNetworkChangedRegistered = false;\n+ private static class Holder {\n+ private static final JXcoreExtension INSTANCE = new JXcoreExtension();\n+ }\n- private static String ERROR_PLATFORM_DOES_NOT_SUPPORT_MULTICONNECT = \"Platform does not support multiConnect\";\n- private static String ERROR_NOT_MULTICONNECT_PLATFORM = \"Not multiConnect platform\";\n+ private JXcoreExtension() {\n+ }\n+ static SurroundingStateObserver getInstance() {\n+ return Holder.INSTANCE;\n+ }\npublic static void LoadExtensions() {\n+ getInstance();\nif (mConnectionHelper != null) {\nLog.e(TAG, \"LoadExtensions: A connection helper instance already exists - this indicates that this method was called twice - disposing of the previous instance\");\nmConnectionHelper.dispose();\nmConnectionHelper = null;\n}\n- mConnectionHelper = new ConnectionHelper();\n+ mConnectionHelper = new ConnectionHelper(getInstance());\nmConnectionHelper.listenToConnectivityEvents();\nfinal LifeCycleMonitor lifeCycleMonitor = new LifeCycleMonitor(new LifeCycleMonitor.LifeCycleMonitorListener() {\n@@ -530,7 +539,7 @@ public class JXcoreExtension {\n}\n- public static void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n+ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\nJSONObject jsonObject = new JSONObject();\nboolean jsonObjectCreated = false;\n@@ -561,8 +570,7 @@ public class JXcoreExtension {\n}\n}\n- public static void notifyDiscoveryAdvertisingStateUpdateNonTcp(\n- boolean isDiscoveryActive, boolean isAdvertisingActive) {\n+ public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\nJSONObject jsonObject = new JSONObject();\nboolean jsonObjectCreated = false;\n@@ -598,8 +606,8 @@ public class JXcoreExtension {\n* If non-null then this is the BSSID of the access point that Wi-Fi\n* is connected to.\n*/\n- public static synchronized void notifyNetworkChanged(\n- boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n+ public synchronized void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled,\n+ String bssidName, String ssidName) {\nif (!mNetworkChangedRegistered) {\nLog.d(TAG, \"notifyNetworkChanged: Not registered for event \\\"\"\n+ EVENT_NAME_NETWORK_CHANGED + \"\\\" and will not notify, in JS call method \\\"\"\n@@ -685,7 +693,7 @@ public class JXcoreExtension {\n*\n* @param portNumber The 127.0.0.1 port that the TCP/IP bridge tried to connect to.\n*/\n- public static void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n+ public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\nlong currentTime = new Date().getTime();\nif (currentTime > mLastTimeIncomingConnectionFailedNotificationWasFired\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/android/java/io/jxcore/node/SurroundingStateObserver.java",
"diff": "+package io.jxcore.node;\n+\n+import org.thaliproject.p2p.btconnectorlib.PeerProperties;\n+\n+/**\n+ * Created by evabishchevich on 1/3/17.\n+ */\n+\n+public interface SurroundingStateObserver {\n+\n+\n+ void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable);\n+\n+ void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive);\n+\n+ /**\n+ * @param isBluetoothEnabled If true, Bluetooth is enabled. False otherwise.\n+ * @param isWifiEnabled If true, Wi-Fi is enabled. False otherwise.\n+ * @param bssidName If null this value indicates that either wifiRadioOn is not 'on' or\n+ * that the Wi-Fi isn't currently connected to an access point.\n+ * If non-null then this is the BSSID of the access point that Wi-Fi\n+ * is connected to.\n+ */\n+ void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName);\n+\n+ /**\n+ * This event is guaranteed to be not sent more often than every 100 ms.\n+ *\n+ * @param portNumber The 127.0.0.1 port that the TCP/IP bridge tried to connect to.\n+ */\n+ void notifyIncomingConnectionToPortNumberFailed(int portNumber);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/test/com/test/thalitest/RegisterExecuteUT.java",
"new_path": "src/android/test/com/test/thalitest/RegisterExecuteUT.java",
"diff": "@@ -14,6 +14,7 @@ import java.util.Date;\nimport io.jxcore.node.ConnectionHelper;\nimport io.jxcore.node.ConnectionHelperTest;\n+import io.jxcore.node.SurroundingStateObserver;\nimport io.jxcore.node.jxcore;\npublic final class RegisterExecuteUT {\n@@ -24,8 +25,27 @@ public final class RegisterExecuteUT {\nstatic String TAG = \"RegisterExecuteUT\";\nprivate static void FireTestedMethod(String methodName) {\n- ConnectionHelperTest.mConnectionHelper = new ConnectionHelper();\n+ ConnectionHelperTest.mConnectionHelper = new ConnectionHelper(new SurroundingStateObserver() {\n+ @Override\n+ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n+\n+ }\n+\n+ @Override\n+ public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\n+\n+ }\n+ @Override\n+ public void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n+\n+ }\n+\n+ @Override\n+ public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n+\n+ }\n+ });\nswitch (methodName) {\ncase \"onPeerLost\":\nConnectionHelperTest.mConnectionHelper\n@@ -69,7 +89,6 @@ public final class RegisterExecuteUT {\njxcore.RegisterMethod(\"executeNativeTests\", new jxcore.JXcoreCallback() {\n@Override\npublic void Receiver(ArrayList<Object> params, String callbackId) {\n- ConnectionHelperTest.mConnectionHelper = new ConnectionHelper();\nString logtag = \"ExecuteNativeTests\";\nLog.d(logtag, \"Running unit tests\");\nResult resultTest = ThaliTestRunner.runTests();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/test/io/jxcore/node/ConnectionHelperTest.java",
"new_path": "src/android/test/io/jxcore/node/ConnectionHelperTest.java",
"diff": "@@ -54,7 +54,7 @@ public class ConnectionHelperTest {\nstatic StartStopOperationHandler mStartStopOperatonHandler;\nstatic boolean isBLESupported;\nprivate final static String TAG = ConnectionHelperTest.class.getName();\n- static ExecutorService mExecutor;\n+ private static ExecutorService mExecutor;\n@Rule\npublic TestRule watcher = new TestWatcher() {\n@@ -123,7 +123,27 @@ public class ConnectionHelperTest {\n@BeforeClass\npublic static void setUpBeforeClass() throws Exception {\n- mConnectionHelper = new ConnectionHelper();\n+ mConnectionHelper = new ConnectionHelper(new SurroundingStateObserver() {\n+ @Override\n+ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n+\n+ }\n+\n+ @Override\n+ public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\n+\n+ }\n+\n+ @Override\n+ public void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n+\n+ }\n+\n+ @Override\n+ public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n+\n+ }\n+ });\nisBLESupported = mConnectionHelper.getDiscoveryManager().isBleMultipleAdvertisementSupported();\nmStartStopOperatonHandler = getStartStopOperationHadler();\nmExecutor = Executors.newFixedThreadPool(5);\n@@ -695,4 +715,61 @@ public class ConnectionHelperTest {\nthrown.expect(UnsupportedOperationException.class);\nmConnectionHelper.onBluetoothMacAddressResolved(\"00:11:22:33:44:55\");\n}\n+\n+\n+ @Test()\n+ public void testListenToConnectivityChanges() {\n+ ConnectionHelper helper = null;\n+ try {\n+ TestSurroundingStateObserver stateObserver = new TestSurroundingStateObserver();\n+ helper = new ConnectionHelper(stateObserver);\n+ helper.listenToConnectivityEvents(); //hidden updateConnectivityInfo call\n+\n+ assertThat(\"Network changed should be called\", stateObserver.networkChangedCalled, is(true));\n+ stateObserver.resetState();\n+\n+ helper.getConnectivityMonitor().updateConnectivityInfo(false);\n+\n+ assertThat(\"Network changed should not be called\", stateObserver.networkChangedCalled, is(false));\n+\n+ stateObserver.resetState();\n+ helper.getConnectivityMonitor().updateConnectivityInfo(true);\n+\n+ assertThat(\"Network changed should be called\", stateObserver.networkChangedCalled, is(true));\n+ } finally {\n+ if (helper != null) {\n+ helper.dispose();\n+ }\n+ }\n+\n+ }\n+\n+ private static class TestSurroundingStateObserver implements SurroundingStateObserver {\n+\n+ private boolean networkChangedCalled = false;\n+\n+ @Override\n+ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n+\n+ }\n+\n+ @Override\n+ public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\n+\n+ }\n+\n+ @Override\n+ public void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n+ networkChangedCalled = true;\n+ }\n+\n+ @Override\n+ public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n+\n+ }\n+\n+ void resetState() {\n+ networkChangedCalled = false;\n+ }\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/test/io/jxcore/node/ConnectivityMonitorTest.java",
"new_path": "src/android/test/io/jxcore/node/ConnectivityMonitorTest.java",
"diff": "@@ -20,6 +20,7 @@ import org.junit.rules.TestWatcher;\nimport org.junit.runner.Description;\nimport org.thaliproject.p2p.btconnectorlib.internal.bluetooth.BluetoothManager;\nimport org.thaliproject.p2p.btconnectorlib.internal.wifi.WifiDirectManager;\n+import org.thaliproject.p2p.btconnectorlib.PeerProperties;\nimport java.lang.reflect.Field;\nimport java.util.concurrent.Callable;\n@@ -59,7 +60,27 @@ public class ConnectivityMonitorTest {\n@BeforeClass\npublic static void setUpBeforeClass() throws Exception {\n- mConnectionHelper = new ConnectionHelper();\n+ mConnectionHelper = new ConnectionHelper(new SurroundingStateObserver() {\n+ @Override\n+ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n+\n+ }\n+\n+ @Override\n+ public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\n+\n+ }\n+\n+ @Override\n+ public void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n+\n+ }\n+\n+ @Override\n+ public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n+\n+ }\n+ });\nmBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/test/io/jxcore/node/StartStopOperationHandlerTest.java",
"new_path": "src/android/test/io/jxcore/node/StartStopOperationHandlerTest.java",
"diff": "@@ -15,6 +15,7 @@ import org.junit.rules.TestWatcher;\nimport org.junit.runner.Description;\nimport org.thaliproject.p2p.btconnectorlib.ConnectionManager;\nimport org.thaliproject.p2p.btconnectorlib.DiscoveryManager;\n+import org.thaliproject.p2p.btconnectorlib.PeerProperties;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Method;\n@@ -102,7 +103,27 @@ public class StartStopOperationHandlerTest {\n@BeforeClass\npublic static void setUpBeforeClass() throws Exception {\n- mConnectionHelper = new ConnectionHelper();\n+ mConnectionHelper = new ConnectionHelper(new SurroundingStateObserver() {\n+ @Override\n+ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n+\n+ }\n+\n+ @Override\n+ public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\n+\n+ }\n+\n+ @Override\n+ public void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n+\n+ }\n+\n+ @Override\n+ public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n+\n+ }\n+ });\nisBLESupported =\nmConnectionHelper.getDiscoveryManager().isBleMultipleAdvertisementSupported();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add test to listen network changes
|
675,381 |
29.12.2016 18:27:18
| -10,800 |
2e8b0eba14d5fc92d7658e3f2e33494409e58fdf
|
Tests linting
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -248,7 +248,7 @@ test('#start subscribes to the WiFi infrastructure events and #stop ' +\nvar router = express.Router();\n- ThaliMobile.start(router, pskIdToSecret, ThaliMobile.networkTypes.WIFI)\n+ ThaliMobile.start(router, null, ThaliMobile.networkTypes.WIFI)\n.then(function () {\nvar wifiEventNames = wifiOnSpy.args.map(function (callArgs) {\nreturn callArgs[0];\n@@ -1424,8 +1424,7 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\npeer\n);\n- var connectionType =\n- ThaliMobileNativeWrapper.connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\n+ var connectionType = connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n@@ -1598,7 +1597,7 @@ test('network changes emitted correctly',\nfunction noNetworkChanged (t, toggle) {\nreturn new Promise(function (resolve) {\nvar isEmitted = false;\n- function networkChangedHandler (networkStatus) {\n+ function networkChangedHandler () {\nisEmitted = true;\n}\nThaliMobile.emitter.once('networkChanged', networkChangedHandler);\n@@ -1668,10 +1667,9 @@ test('calls correct starts when network changes',\n// return true || global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n},\nfunction (t) {\n- var isWifiEnabled = (\n+ var isWifiEnabled =\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n- global.NETWORK_TYPE === ThaliMobile.networkTypes.BOTH\n- );\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.BOTH;\nvar listeningSpy = null;\nvar advertisingSpy = null;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Tests linting
|
675,373 |
09.01.2017 13:01:30
| -10,800 |
84fcb1f694bcfc57402313c6a505e291dc20a170
|
Add documentation for state observer
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/SurroundingStateObserver.java",
"new_path": "src/android/java/io/jxcore/node/SurroundingStateObserver.java",
"diff": "@@ -8,9 +8,20 @@ import org.thaliproject.p2p.btconnectorlib.PeerProperties;\npublic interface SurroundingStateObserver {\n-\n+ /**\n+ * Notifies node layer about peer changes detected on native Android layer\n+ *\n+ * @param peerProperties Peer properties of new/updated/lost peer.\n+ * @param isAvailable If true, peer is available. False otherwise.\n+ */\nvoid notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable);\n+ /**\n+ * Notifies about discovery and/or advertising changes\n+ *\n+ * @param isDiscoveryActive We are currently discovering if true. False otherwise.\n+ * @param isAdvertisingActive We are currently advertising if true. False otherwise.\n+ */\nvoid notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive);\n/**\n@@ -20,6 +31,10 @@ public interface SurroundingStateObserver {\n* that the Wi-Fi isn't currently connected to an access point.\n* If non-null then this is the BSSID of the access point that Wi-Fi\n* is connected to.\n+ * @param ssidName If null this value indicates that either wifiRadioOn is not 'on' or\n+ * that the Wi-Fi isn't currently connected to an access point.\n+ * If non-null then this is the SSID of the access point that Wi-Fi\n+ * is connected to.\n*/\nvoid notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add documentation for state observer
|
675,375 |
10.01.2017 16:09:20
| -3,600 |
a470a85a59bb0bf9a5ab259850c0890e64dbe58d
|
Extended test and teadown timeouts, implement retry logic which is based on timer, because of possible race condition (see explanation in comments)
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -33,7 +33,11 @@ var test = tape({\nverifyCombinedResultSuccess(t, combinedResult);\nt.end();\n});\n- }\n+ },\n+ // Extend test and teardown timeouts. Sometimes it takes quite\n+ // long to establish bluetooth connection.\n+ testTimeout: 5 * 60 * 1000,\n+ teardownTimeout: 5 * 60 * 1000\n});\nvar testIdempotentFunction = function (t, functionName) {\n@@ -2228,8 +2232,8 @@ function setUpRouter() {\ntest('test for data corruption',\nfunction () {\n- // Bug 1594\n- return true;\n+ return global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI\n+ || !platform.isAndroid;\n},\nfunction (t) {\nvar router = setUpRouter();\n@@ -2237,26 +2241,57 @@ test('test for data corruption',\nvar peerIDToUUIDMap = {};\nvar areWeDone = false;\nvar promiseQueue = new PromiseQueue();\n+\n+ // This timer purpose is to manually restart ThaliMobile every 60 seconds.\n+ // Whole test timeout is set to 5 minutes, so there will be at most 4 restart attempts.\n+ // Timer is used because of possible race condition when stopping and starting\n+ // ThaliMobile every time error occurs, which led to test failure because exception was\n+ // thrown.\n+ var timer = setInterval(function() {\n+ logger.debug('Restarting test for data corruption');\n+\n+ ThaliMobile.stop().then(function() {\n+ runTestFunction();\n+ });\n+ }, 60 * 1000);\n+\n+ var runTestFunction = function () {\nt.participants.forEach(function (participant) {\nif (participant.uuid === tape.uuid) {\nreturn;\n}\nparticipantsState[participant.uuid] = participantState.notRunning;\n});\n+\nsetupDiscoveryAndFindPeers(t, router, function (peer, done) {\n+ testFunction(peer).then(function (result) {\n+ // Check if promise was resolved with true.\n+ if (result) {\n+ t.ok(true, 'Test for data corruption succeed');\n+ done();\n+ clearInterval(timer);\n+ }\n+ })\n+ });\n+ };\n+\n+ var testFunction = function (peer) {\n// Try to get data only from non-TCP peers so that the test\n// works the same way on desktop on CI where Wifi is blocked\n// between peers.\nif (peer.connectionType ===\nThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE) {\n- return;\n+ Promise.resolve(true);\n}\n+\nif (peerIDToUUIDMap[peer.peerIdentifier] &&\nparticipantsState[peerIDToUUIDMap[peer.peerIdentifier] ===\nparticipantState.finished]) {\n- return;\n+ Promise.resolve(true);\n}\n- promiseQueue.enqueue(function (resolve) {\n+ return promiseQueue.enqueue(function (resolve) {\n+ // To avoid multiple t.end() calls, just resolve here with null.\n+ // The areWeDone check will be called anyway in different section.\nif (areWeDone) {\nreturn resolve(null);\n}\n@@ -2281,9 +2316,10 @@ test('test for data corruption',\nuuid = responseBody;\npeerIDToUUIDMap[peer.peerIdentifier] = uuid;\nlogger.debug('Got uuid back from GET - ' + uuid);\n+\nif (participantsState[uuid] !== participantState.notRunning) {\nlogger.debug('Participant is already done - ' + uuid);\n- return false;\n+ return resolve(null);\n} else {\nlogger.debug('Participants state is ' + participantsState[uuid]);\n}\n@@ -2295,40 +2331,37 @@ test('test for data corruption',\n.then(function () {\nlogger.debug('Got back from parallel requests - ' + uuid);\nparticipantsState[uuid] = participantState.finished;\n- areWeDone = Object.getOwnPropertyNames(participantsState)\n- .every(\n- function (participant) {\n- return participantsState[participant] ===\n- participantState.finished;\n- });\n- if (areWeDone) {\n- t.ok(true, 'received all uuids');\n- done();\n- }\n- return false;\n});\n})\n.catch(function (error) {\nlogger.debug('Got an error on HTTP requests: ' + error);\n- return true;\n})\n- .then(function (isError) {\n+ .then(function () {\n+ areWeDone = Object.getOwnPropertyNames(participantsState)\n+ .every(\n+ function (participant) {\n+ return participantsState[participant] === participantState.finished\n+ });\n+\nif (areWeDone) {\n- return resolve(null);\n+ logger.debug('received all uuids');\n+\n+ return resolve(true);\n}\n+\nThaliMobileNativeWrapper._getServersManager()\n.terminateOutgoingConnection(peer.peerIdentifier, peer.portNumber);\n+\n// We have to give Android enough time to notice the killed connection\n// and recycle everything\nsetTimeout(function () {\n- if (isError) {\n- participantsState[uuid] = participantState.notRunning;\n- }\nreturn resolve(null);\n}, 1000);\n});\n});\n- });\n+ };\n+\n+ runTestFunction();\n}\n);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Extended test and teadown timeouts, implement retry logic which is based on timer, because of possible race condition (see explanation in comments)
|
675,383 |
11.01.2017 11:37:47
| -10,800 |
c3f654c8de81842e830b4afec1cd459e4211a788
|
Remove unnecessary getInstance call
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -97,7 +97,6 @@ public class JXcoreExtension implements SurroundingStateObserver {\n}\npublic static void LoadExtensions() {\n- getInstance();\nif (mConnectionHelper != null) {\nLog.e(TAG, \"LoadExtensions: A connection helper instance already exists - this indicates that this method was called twice - disposing of the previous instance\");\nmConnectionHelper.dispose();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Remove unnecessary getInstance call
|
675,375 |
13.01.2017 12:33:11
| -3,600 |
a7ebc487d47dd8873f9ce5056de478b0a24721ac
|
Put issues numbers in comments to track the bugs
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -34,8 +34,10 @@ var test = tape({\nt.end();\n});\n},\n- // Extend test and teardown timeouts. Sometimes it takes quite\n- // long to establish bluetooth connection.\n+\n+ // These time outs are excessive because of issues we are having\n+ // with Bluetooth, see #1569. When #1569 is fixed we will be able\n+ // to reduce these time outs to a reasonable level.\ntestTimeout: 5 * 60 * 1000,\nteardownTimeout: 5 * 60 * 1000\n});\n@@ -2247,6 +2249,7 @@ test('test for data corruption',\n// Timer is used because of possible race condition when stopping and starting\n// ThaliMobile every time error occurs, which led to test failure because exception was\n// thrown.\n+ // This issue is tracked in #1719.\nvar timer = setInterval(function() {\nlogger.debug('Restarting test for data corruption');\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Put issues numbers in comments to track the bugs
|
675,373 |
13.01.2017 18:22:20
| -10,800 |
ad481fb0bfe6c5a774ec673a63df618607758350
|
Fix onPeerLost test
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -92,7 +92,7 @@ public class JXcoreExtension implements SurroundingStateObserver {\nprivate JXcoreExtension() {\n}\n- static SurroundingStateObserver getInstance() {\n+ public static SurroundingStateObserver getInstance() {\nreturn Holder.INSTANCE;\n}\n@@ -547,7 +547,8 @@ public class JXcoreExtension implements SurroundingStateObserver {\njsonObject.put(EVENT_VALUE_PEER_ID, peerProperties.getId());\nInteger gen = peerProperties.getExtraInformation();\nif (!isAvailable) {\n- gen = (peerProperties.getExtraInformation() == 0) ? null : peerProperties.getExtraInformation();\n+ gen = (peerProperties.getExtraInformation() == PeerProperties.NO_EXTRA_INFORMATION) ?\n+ null : peerProperties.getExtraInformation();\n}\njsonObject.put(EVENT_VALUE_PEER_GENERATION, gen);\njsonObject.put(EVENT_VALUE_PEER_AVAILABLE, isAvailable);\n@@ -560,7 +561,6 @@ public class JXcoreExtension implements SurroundingStateObserver {\nJSONArray jsonArray = new JSONArray();\njsonArray.put(jsonObject);\nfinal String jsonArrayAsString = jsonArray.toString();\n-\njxcore.activity.runOnUiThread(new Runnable() {\n@Override\npublic void run() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/test/com/test/thalitest/RegisterExecuteUT.java",
"new_path": "src/android/test/com/test/thalitest/RegisterExecuteUT.java",
"diff": "@@ -7,14 +7,13 @@ import org.json.JSONObject;\nimport org.junit.runner.Result;\nimport org.junit.runner.notification.Failure;\nimport org.thaliproject.p2p.btconnectorlib.PeerProperties;\n-import java.lang.reflect.InvocationTargetException;\n-import java.lang.reflect.Method;\n+\nimport java.util.ArrayList;\nimport java.util.Date;\nimport io.jxcore.node.ConnectionHelper;\nimport io.jxcore.node.ConnectionHelperTest;\n-import io.jxcore.node.SurroundingStateObserver;\n+import io.jxcore.node.JXcoreExtension;\nimport io.jxcore.node.jxcore;\npublic final class RegisterExecuteUT {\n@@ -25,27 +24,7 @@ public final class RegisterExecuteUT {\nstatic String TAG = \"RegisterExecuteUT\";\nprivate static void FireTestedMethod(String methodName) {\n- ConnectionHelperTest.mConnectionHelper = new ConnectionHelper(new SurroundingStateObserver() {\n- @Override\n- public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\n-\n- }\n-\n- @Override\n- public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\n-\n- }\n-\n- @Override\n- public void notifyNetworkChanged(boolean isBluetoothEnabled, boolean isWifiEnabled, String bssidName, String ssidName) {\n-\n- }\n-\n- @Override\n- public void notifyIncomingConnectionToPortNumberFailed(int portNumber) {\n-\n- }\n- });\n+ ConnectionHelperTest.mConnectionHelper = new ConnectionHelper(JXcoreExtension.getInstance());\nswitch (methodName) {\ncase \"onPeerLost\":\nConnectionHelperTest.mConnectionHelper\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testNativeMethod.js",
"new_path": "test/www/jxcore/bv_tests/testNativeMethod.js",
"diff": "@@ -33,7 +33,7 @@ test('onPeerLost calls jxcore',\nt.equal(callbackPeer.peerIdentifier, '11:22:33:22:11:00',\n'check if callback was fired by onPeerLost');\n- t.equal(callbackPeer.generation, null, 'check if generation is null');\n+ t.ok(callbackPeer.generation == null, 'check if generation is null');\nt.notOk(callbackPeer.peerAvailable, 'check if peerAvailable is false');\nt.end();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix onPeerLost test
|
675,383 |
13.01.2017 20:43:07
| -10,800 |
fc039716029f4b27f6526fef0fd1f11ff0702e9a
|
Fix onPeerDiscovered test
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/test/com/test/thalitest/RegisterExecuteUT.java",
"new_path": "src/android/test/com/test/thalitest/RegisterExecuteUT.java",
"diff": "@@ -32,7 +32,7 @@ public final class RegisterExecuteUT {\nbreak;\ncase \"onPeerDiscovered\":\nConnectionHelperTest.mConnectionHelper\n- .onPeerDiscovered(new PeerProperties(\"33:44:55:44:33:22\"));\n+ .onPeerDiscovered(new PeerProperties(\"33:44:55:44:33:22\", 0));\nbreak;\ndefault:\nLog.e(TAG, \"Method called in FireTestedMethod doesn't exists!\");\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix onPeerDiscovered test
|
675,373 |
16.01.2017 13:35:53
| -10,800 |
a486bdc2327457fb7a6784632b1b157f1bbc2e3b
|
Always send null in generation when peer is not available
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -545,11 +545,8 @@ public class JXcoreExtension implements SurroundingStateObserver {\ntry {\njsonObject.put(EVENT_VALUE_PEER_ID, peerProperties.getId());\n- Integer gen = peerProperties.getExtraInformation();\n- if (!isAvailable) {\n- gen = (peerProperties.getExtraInformation() == PeerProperties.NO_EXTRA_INFORMATION) ?\n- null : peerProperties.getExtraInformation();\n- }\n+ Integer gen = (isAvailable && hasExtraInfo(peerProperties)) ?\n+ peerProperties.getExtraInformation() : null;\njsonObject.put(EVENT_VALUE_PEER_GENERATION, gen);\njsonObject.put(EVENT_VALUE_PEER_AVAILABLE, isAvailable);\njsonObjectCreated = true;\n@@ -570,6 +567,10 @@ public class JXcoreExtension implements SurroundingStateObserver {\n}\n}\n+ private boolean hasExtraInfo(PeerProperties peerProperties) {\n+ return peerProperties.getExtraInformation() != PeerProperties.NO_EXTRA_INFORMATION;\n+ }\n+\npublic void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\nJSONObject jsonObject = new JSONObject();\nboolean jsonObjectCreated = false;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Always send null in generation when peer is not available
|
675,381 |
17.01.2017 14:31:19
| -10,800 |
23852488fbab61dc78dbb2a949f94d1ee700adca
|
Refactor "calls correct starts" test
Remove platform dependent checks and add update comments
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -36,6 +36,7 @@ var test = tape({\n}\n});\n+\nvar testIdempotentFunction = function (t, functionName) {\nThaliMobile.start(express.Router())\n.then(function () {\n@@ -1661,13 +1662,14 @@ test('network changes not emitted in stopped state',\ntest('calls correct starts when network changes',\nfunction (t) {\n- var isWifiEnabled = (\n+ var isWifiEnabled =\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n- global.NETWORK_TYPE === ThaliMobile.networkTypes.BOTH\n- );\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.BOTH;\n- var listeningSpy = null;\n- var advertisingSpy = null;\n+ var listeningSpy =\n+ sinon.spy(ThaliMobile, '_startListeningForAdvertisements');\n+ var advertisingSpy =\n+ sinon.spy(ThaliMobile, '_startUpdateAdvertisingAndListening');\nThaliMobile.start(express.Router())\n.then(function () {\n@@ -1689,29 +1691,31 @@ test('calls correct starts when network changes',\n'Radio Turned Off', 'specific error expected');\n}\n- listeningSpy = sinon.spy(ThaliMobile,\n- '_startListeningForAdvertisements');\n- advertisingSpy = sinon.spy(ThaliMobile,\n- '_startUpdateAdvertisingAndListening');\n+ listeningSpy.reset();\n+ advertisingSpy.reset();\nreturn testUtils.ensureWifi(true);\n})\n.then(function () {\n- return ThaliMobile.getPromiseQueue()\n- .enqueue(function (resolve) {\n- // Android will provide 2 network changed events.\n- // Second event will provide bssid and ssid.\n- var callCount = platform._isRealAndroid? 2: 1;\n- t.equals(listeningSpy.callCount, callCount,\n- '_startListeningForAdvertisements should have been called');\n- t.equals(advertisingSpy.callCount, callCount,\n- '_startUpdateAdvertisingAndListening should have been called');\n-\n- ThaliMobile._startListeningForAdvertisements.restore();\n- ThaliMobile._startUpdateAdvertisingAndListening.restore();\n- t.end();\n+ return ThaliMobile.getPromiseQueue().enqueue(function (resolve) {\n+ // Real device can emit 2 network changed events: the first one with\n+ // wifi:on and without bssid, the second one with wifi:on and with\n+ // bssid and ssid. It may be implementation and environment dependant\n+ // but we can assume it was emitted at least once\n+ t.ok(listeningSpy.called, '_startListeningForAdvertisements should ' +\n+ 'have been called at least once');\n+ t.ok(advertisingSpy.called, '_startUpdateAdvertisingAndListening ' +\n+ 'should have been called at least once');\nresolve();\n});\n+ })\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\n+ listeningSpy.restore();\n+ advertisingSpy.restore();\n+ t.end();\n});\n}\n);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Refactor "calls correct starts" test
Remove platform dependent checks and add update comments
|
675,381 |
18.01.2017 18:47:36
| -10,800 |
4cc1998ecf53373efbd8f15163d03f7212f2c919
|
Rewrite some test in testThaliMobile.js. Cosmetic changes
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -12,6 +12,7 @@ var validations = require('thali/validations');\nvar sinon = require('sinon');\nvar uuid = require('uuid');\nvar nodessdp = require('node-ssdp');\n+var objectAssign = require('object-assign');\nvar randomstring = require('randomstring');\nvar logger = require('thali/ThaliLogger')('testThaliMobile');\nvar Promise = require('bluebird');\n@@ -174,11 +175,9 @@ test('#start should fail if called twice in a row', function (t) {\ntest('#stop should clear watchers and change peers', function (t) {\nvar somePeerIdentifier = 'urn:uuid:' + uuid.v4();\n- var connectionType =\n- platform.isAndroid ?\n- ThaliMobileNativeWrapper.connectionTypes.BLUETOOTH :\n- ThaliMobileNativeWrapper\n- .connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\n+ var connectionType = platform.isAndroid ?\n+ connectionTypes.BLUETOOTH :\n+ connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\nThaliMobile.start(express.Router(), new Buffer('foo'),\nThaliMobile.networkTypes.NATIVE)\n@@ -201,10 +200,9 @@ test('#stop should clear watchers and change peers', function (t) {\nreturn ThaliMobile.stop();\n})\n.then(function () {\n- Object.getOwnPropertyNames(ThaliMobileNativeWrapper.connectionTypes)\n+ Object.getOwnPropertyNames(connectionTypes)\n.forEach(function (connectionKey) {\n- var connectionType = ThaliMobileNativeWrapper\n- .connectionTypes[connectionKey];\n+ var connectionType = connectionTypes[connectionKey];\nt.equal(Object.getOwnPropertyNames(\nThaliMobile._peerAvailabilityWatchers[connectionType]).length,\n0, 'No watchers');\n@@ -516,13 +514,11 @@ test('peerAvailabilityChanged - peer added/removed to/from cache (native)',\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nvar cache = ThaliMobile._getPeerAvailabilities();\nvar nativePeers = cache[connectionType];\n@@ -573,13 +569,11 @@ test('peerAvailabilityChanged - peer added/removed to/from cache (wifi)',\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nvar cache = ThaliMobile._getPeerAvailabilities();\nvar wifiPeers = cache[connectionTypes.TCP_NATIVE];\n@@ -629,13 +623,11 @@ test('peerAvailabilityChanged - peer with the same id, conn type, host, port ' +\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nemitNativePeerAvailability(testPeers.nativePeer);\nemitWifiPeerAvailability(testPeers.wifiPeer);\n@@ -659,13 +651,11 @@ test('native available - new peer is cached',\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nvar cache = ThaliMobile._getPeerAvailabilities();\nvar nativePeers = cache[connectionType];\n@@ -715,13 +705,11 @@ test('native available - peer with same port and different generation is ' +\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nnativePeer.generation = 2;\nemitNativePeerAvailability(nativePeer);\n@@ -769,14 +757,12 @@ test('native available - peer with the same port and generation but with ' +\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nthaliConfig.UPDATE_WINDOWS_FOREGROUND_MS = originalUpdateWindow;\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nnativePeer.generation = 2;\nemitNativePeerAvailability(nativePeer);\n@@ -829,13 +815,11 @@ test('native available - peer with greater generation is cached (MPCF)',\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nnativePeer.generation = 2;\nemitNativePeerAvailability(nativePeer);\n@@ -846,54 +830,81 @@ test('native available - peer with same or older generation is ignored (MPCF)',\ntestUtils.skipOnAndroid,\nfunction (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n+ var nativePeer1 = objectAssign({}, nativePeer, { generation: 1 });\n+ var nativePeer2 = objectAssign({}, nativePeer, { generation: 2 });\n+ var nativePeer3 = objectAssign({}, nativePeer, { generation: 3 });\n+ var callCount = 0;\n+ var availabilityHandler = function (peerStatus) {\n+ callCount++;\n+ switch (callCount) {\n+ case 1: {\n+ t.equal(peerStatus.peerIdentifier, nativePeer.peerIdentifier,\n+ 'discovered correct peer');\n+ t.equal(peerStatus.generation, 2, 'got correct generation');\n- var availabilityHandler = sinon.spy();\n+ emitNativePeerAvailability(nativePeer1);\n+ setImmediate(function () {\n+ emitNativePeerAvailability(nativePeer3);\n+ });\n+ return;\n+ }\n+ case 2: {\n+ // peer with generation 1 should be ignored\n+ t.equal(peerStatus.peerIdentifier, nativePeer.peerIdentifier,\n+ 'discovered correct peer');\n+ t.equal(peerStatus.generation, 3, 'got correct generation');\n+\n+ setImmediate(end);\n+ return;\n+ }\n+ default: {\n+ t.fail('should not be called more than twice');\n+ return;\n+ }\n+ }\n+ };\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\nfunction end() {\n- var handlerPeer = availabilityHandler.lastCall.args[0];\n- t.equal(handlerPeer.peerIdentifier,\n- nativePeer.peerIdentifier, 'should be the same peer');\n- t.equal(availabilityHandler.calledOnce, true, 'should be called once');\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- nativePeer.generation = 2;\n- emitNativePeerAvailability(nativePeer);\n- // same generation should be ignored\n- emitNativePeerAvailability(nativePeer);\n-\n- // lower generation should be ignored\n- nativePeer.generation = 1;\n- emitNativePeerAvailability(nativePeer);\n-\n- end();\n+ ThaliMobile.start(express.Router()).then(function () {\n+ emitNativePeerAvailability(nativePeer2);\n+ });\n}\n);\ntest('native unavailable - new peer is ignored',\nfunction (t) {\n- var nativePeer = generateLowerLevelPeers().nativePeer;\n- nativePeer.peerAvailable = false;\n+ var nativePeer1 = generateLowerLevelPeers().nativePeer;\n+ var nativePeer2 = generateLowerLevelPeers().nativePeer;\n- var availabilityHandler = sinon.spy();\n-\n- ThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n+ nativePeer1.peerAvailable = false;\n+ nativePeer2.peerAvailable = true;\n- function end() {\n- t.equal(availabilityHandler.called, false, 'should not be called');\n+ // handler should be called only once with the second peer info\n+ var availabilityHandler = function (peerStatus) {\n+ t.equal(peerStatus.peerIdentifier, nativePeer2.peerIdentifier,\n+ 'discovered available peer');\n+ t.equal(peerStatus.peerAvailable, true, 'peer is available');\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n- }\n+ };\n- emitNativePeerAvailability(nativePeer);\n+ ThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- end();\n+ ThaliMobile.start(express.Router()).then(function () {\n+ emitNativePeerAvailability(nativePeer1);\n+ setImmediate(function () {\n+ emitNativePeerAvailability(nativePeer2);\n+ });\n+ });\n}\n);\n@@ -1041,13 +1052,11 @@ test('networkChanged - fires peerAvailabilityChanged event for wifi peers',\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\n// Add initial peers\nThaliMobile.start(express.Router()).then(function () {\n@@ -1134,13 +1143,11 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\n// Add initial peers\nThaliMobile.start(express.Router()).then(function () {\n@@ -1240,13 +1247,11 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\n// Add initial peers\nemitNativePeerAvailability(testPeers.nativePeer);\n@@ -1254,7 +1259,19 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\n);\ntest('multiconnect failure - new peer is ignored (MPCF)',\n- testUtils.skipOnAndroid,\n+ function () {\n+ // This test does not make sense because thaliMobile does not listen to the\n+ // failedNativeConnection event. ThaliMobileNativeWrapper handles connection\n+ // failures by emitting \"fake\" peerAvailabilityChanged events to trigger\n+ // retry in the higher layers.\n+ //\n+ // See https://github.com/thaliproject/Thali_CordovaPlugin/issues/1527#issuecomment-261677036\n+ // for more details. We currently use the logic described in the \"What we\n+ // shouldn't do\" section.\n+\n+ // return !platform.isIOS;\n+ return true;\n+ },\nfunction (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n@@ -1398,13 +1415,11 @@ test('newAddressPort field (TCP_NATIVE)', function (t) {\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nemitWifiPeerAvailability(wifiPeer);\n});\n@@ -1460,13 +1475,11 @@ test('newAddressPort field (BLUETOOTH)',\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n- // jshint latedef:false\nfunction end() {\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n}\n- // jshint latedef:true\nemitNativePeerAvailability(nativePeer);\n}\n@@ -1502,7 +1515,7 @@ test('newAddressPort after listenerRecreatedAfterFailure event (BLUETOOTH)',\ntest('#getPeerHostInfo - error when peer has not been discovered yet',\nfunction (t) {\n- var connectionType = ThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE;\n+ var connectionType = connectionTypes.TCP_NATIVE;\nThaliMobile.getPeerHostInfo('foo', connectionType)\n.then(function () {\nt.fail('should never be called');\n@@ -1539,7 +1552,7 @@ test('#getPeerHostInfo - returns discovered cached native peer (BLUETOOTH)',\npeer\n);\n- var connectionType = ThaliMobileNativeWrapper.connectionTypes.BLUETOOTH;\n+ var connectionType = connectionTypes.BLUETOOTH;\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n@@ -1581,9 +1594,7 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\npeer\n);\n- var connectionType =\n- ThaliMobileNativeWrapper.connectionTypes.\n- MULTI_PEER_CONNECTIVITY_FRAMEWORK;\n+ var connectionType = connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n@@ -1611,7 +1622,7 @@ test('#getPeerHostInfo - returns discovered cached wifi peer',\nvar thaliWifiInfrastructure = ThaliMobile._getThaliWifiInfrastructure();\nthaliWifiInfrastructure.emit('wifiPeerAvailabilityChanged', peer);\n- var connectionType = ThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE;\n+ var connectionType = connectionTypes.TCP_NATIVE;\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n@@ -1942,8 +1953,7 @@ function(t) {\n};\nvar cleanUpCalled = false;\n- // jshint latedef:false\n- function cleanUp() { // jshint latedef:true\n+ function cleanUp() {\nif (cleanUpCalled) {\nreturn;\n}\n@@ -2020,8 +2030,7 @@ function(t) {\n};\nvar cleanUpCalled = false;\n- // jshint latedef:false\n- function cleanUp() { // jshint latedef:true\n+ function cleanUp() {\nif (cleanUpCalled) {\nreturn;\n}\n@@ -2075,8 +2084,7 @@ test('If a peer is not available (and hence is not in the thaliMobile cache)' +\n};\nvar cleanUpCalled = false;\n- // jshint latedef:false\n- function cleanUp() { // jshint latedef:true\n+ function cleanUp() {\nif (cleanUpCalled) {\nreturn;\n}\n@@ -2148,7 +2156,7 @@ test('does not fire duplicate events after peer listener recreation',\nvar initialPort = 1234;\nvar recreatedPort = 1235;\nvar EVENT_NAME = 'nonTCPPeerAvailabilityChangedEvent';\n- var BLUETOOTH = ThaliMobileNativeWrapper.connectionTypes.BLUETOOTH;\n+ var BLUETOOTH = connectionTypes.BLUETOOTH;\nvar callCount = 0;\nThaliMobile.emitter.on('peerAvailabilityChanged', function listener(peer) {\n@@ -2357,8 +2365,7 @@ test('can get data from all participants',\n// Try to get data only from non-TCP peers so that the test\n// works the same way on desktop on CI where Wifi is blocked\n// between peers.\n- if (peer.connectionType ===\n- ThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE) {\n+ if (peer.connectionType === connectionTypes.TCP_NATIVE) {\nreturn;\n}\n@@ -2536,8 +2543,7 @@ test('test for data corruption',\n// Try to get data only from non-TCP peers so that the test\n// works the same way on desktop on CI where Wifi is blocked\n// between peers.\n- if (peer.connectionType ===\n- ThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE) {\n+ if (peer.connectionType === connectionTypes.TCP_NATIVE) {\nPromise.resolve(true);\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Rewrite some test in testThaliMobile.js. Cosmetic changes
|
675,381 |
18.01.2017 18:55:21
| -10,800 |
c45299ab0d22b2160c8bd35b359b6cabeba67491
|
disable android-only test on ios
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1830,6 +1830,10 @@ test('network changes not emitted in stopped state',\n});\ntest('calls correct starts when network changes',\n+ function () {\n+ // iOS does not support disabling/enabling radios\n+ return platform.isIOS;\n+ },\nfunction (t) {\nvar isWifiEnabled =\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
disable android-only test on ios
|
675,381 |
18.01.2017 20:27:06
| -10,800 |
0e54424c231040bbaeb9ead8025ec81fb208a137
|
Add logging for multiconnect
|
[
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -657,10 +657,14 @@ module.exports._multiConnect = function (peerIdentifier) {\nreturn gPromiseQueue.enqueue(function (resolve, reject) {\nvar originalSyncValue = String(multiConnectCounter);\nmultiConnectCounter++;\n+ logger.debug('Issuing multiConnect for %s', peerIdentifier);\nMobile('multiConnect')\n.callNative(peerIdentifier, originalSyncValue, function (error) {\nif (error) {\n+ logger.error(\n+ 'multiConnect for %s failed with %s', peerIdentifier, error\n+ );\nreturn reject(new Error(error));\n}\n@@ -1225,6 +1229,11 @@ module.exports._registerToNative = function () {\nregisterToNative('multiConnectResolved',\nfunction (syncValue, error, portNumber) {\n+ logger.debug('multiConnectResolved: %s', JSON.stringify({\n+ syncValue: syncValue,\n+ error: error,\n+ portNumber: portNumber,\n+ }));\nmodule.exports.emitter.emit(\n'_multiConnectResolved',\nsyncValue, error, portNumber);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add logging for multiconnect
|
675,381 |
18.01.2017 21:17:55
| -10,800 |
801caae7ae27cd843fb3236670b603648f0b900f
|
Improve multiconnect logging
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -363,8 +363,9 @@ test('Can shift large amounts of data', function (t) {\nvar client = null;\n// We're happy here if we make a connection to anyone\n- logger.info(connection);\n+ logger.info('Connection info: ' + JSON.stringify(connection));\nclient = net.connect(connection.listeningPort, function () {\n+ logger.info('Connected to the ' + connection.listeningPort);\nshiftData(client);\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "'use strict';\n-var util = require('util').format;\n+var format = require('util').format;\nvar platform = require('thali/NextGeneration/utils/platform');\nvar logger = require('../lib/testLogger')('thaliMobileNativeTestUtils');\n@@ -191,6 +191,10 @@ function iOSConnectToPeer(peer, quitSignal) {\n};\nmultiConnectEmitter.on('multiConnectResolved', multiConnectHandler);\n+ logger.debug(format(\n+ 'Issuing multiConnect for %s (syncValue: %s)',\n+ peer.peerIdentifier, originalSyncValue\n+ ));\nMobile('multiConnect')\n.callNative(peer.peerIdentifier, originalSyncValue, function (error) {\nlogger.debug('Got \\'multiConnect\\' callback');\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -657,7 +657,10 @@ module.exports._multiConnect = function (peerIdentifier) {\nreturn gPromiseQueue.enqueue(function (resolve, reject) {\nvar originalSyncValue = String(multiConnectCounter);\nmultiConnectCounter++;\n- logger.debug('Issuing multiConnect for %s', peerIdentifier);\n+ logger.debug(\n+ 'Issuing multiConnect for %s (syncValue: %s)',\n+ peerIdentifier, originalSyncValue\n+ );\nMobile('multiConnect')\n.callNative(peerIdentifier, originalSyncValue, function (error) {\n@@ -667,6 +670,7 @@ module.exports._multiConnect = function (peerIdentifier) {\n);\nreturn reject(new Error(error));\n}\n+ logger.debug('Got multiConnect callback');\nmodule.exports.emitter.on('_multiConnectResolved',\nfunction callback (syncValue, error, portNumber) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Improve multiconnect logging
|
675,373 |
21.01.2017 18:26:45
| -10,800 |
579949a5815932eea8e83fb3ffd58fc6793acb06
|
Add null sending in JSON between Android and Node
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -538,17 +538,16 @@ public class JXcoreExtension implements SurroundingStateObserver {\n});\n}\n-\npublic void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean isAvailable) {\nJSONObject jsonObject = new JSONObject();\nboolean jsonObjectCreated = false;\ntry {\n- jsonObject.put(EVENT_VALUE_PEER_ID, peerProperties.getId());\n+ putValueInJson(jsonObject, EVENT_VALUE_PEER_ID, peerProperties.getId());\nInteger gen = (isAvailable && hasExtraInfo(peerProperties)) ?\npeerProperties.getExtraInformation() : null;\n- jsonObject.put(EVENT_VALUE_PEER_GENERATION, gen);\n- jsonObject.put(EVENT_VALUE_PEER_AVAILABLE, isAvailable);\n+ putValueInJson(jsonObject, EVENT_VALUE_PEER_GENERATION, gen);\n+ putValueInJson(jsonObject, EVENT_VALUE_PEER_AVAILABLE, isAvailable);\njsonObjectCreated = true;\n} catch (JSONException e) {\nLog.e(TAG, \"notifyPeerAvailabilityChanged: Failed to populate the JSON object: \" + e.getMessage(), e);\n@@ -624,36 +623,9 @@ public class JXcoreExtension implements SurroundingStateObserver {\nfinal ConnectivityMonitor connectivityMonitor = mConnectionHelper.getConnectivityMonitor();\n- if (connectivityMonitor.isBleMultipleAdvertisementSupported() !=\n- BluetoothManager.FeatureSupportedStatus.NOT_SUPPORTED) {\n- if (isBluetoothEnabled) {\n- bluetoothLowEnergyRadioState = RadioState.ON;\n- } else {\n- bluetoothLowEnergyRadioState = RadioState.OFF;\n- }\n- } else {\n- bluetoothLowEnergyRadioState = RadioState.NOT_HERE;\n- }\n-\n- if (connectivityMonitor.isBluetoothSupported()) {\n- if (isBluetoothEnabled) {\n- bluetoothRadioState = RadioState.ON;\n- } else {\n- bluetoothRadioState = RadioState.OFF;\n- }\n- } else {\n- bluetoothRadioState = RadioState.NOT_HERE;\n- }\n-\n- if (connectivityMonitor.isWifiDirectSupported()) {\n- if (isWifiEnabled) {\n- wifiRadioState = RadioState.ON;\n- } else {\n- wifiRadioState = RadioState.OFF;\n- }\n- } else {\n- wifiRadioState = RadioState.NOT_HERE;\n- }\n+ bluetoothLowEnergyRadioState = getBleRadioState(connectivityMonitor, isBluetoothEnabled);\n+ bluetoothRadioState = getBluetoothRadioState(connectivityMonitor, isBluetoothEnabled);\n+ wifiRadioState = getWifiRadioState(connectivityMonitor, isWifiEnabled);\nLog.d(TAG, \"notifyNetworkChanged: BLE: \" + bluetoothLowEnergyRadioState\n+ \", Bluetooth: \" + bluetoothRadioState\n@@ -666,12 +638,18 @@ public class JXcoreExtension implements SurroundingStateObserver {\nboolean jsonObjectCreated = false;\ntry {\n- jsonObject.put(EVENT_VALUE_BLUETOOTH_LOW_ENERGY, radioStateEnumValueToString(bluetoothLowEnergyRadioState));\n- jsonObject.put(EVENT_VALUE_BLUETOOTH, radioStateEnumValueToString(bluetoothRadioState));\n- jsonObject.put(EVENT_VALUE_WIFI, radioStateEnumValueToString(wifiRadioState));\n- jsonObject.put(EVENT_VALUE_CELLULAR, radioStateEnumValueToString(cellularRadioState));\n- jsonObject.put(EVENT_VALUE_BSSID_NAME, bssidName);\n- jsonObject.put(EVENT_VALUE_SSID_NAME, ssidName);\n+ putValueInJson(jsonObject, EVENT_VALUE_BLUETOOTH_LOW_ENERGY,\n+ radioStateEnumValueToString(bluetoothLowEnergyRadioState));\n+ putValueInJson(jsonObject, EVENT_VALUE_BLUETOOTH,\n+ radioStateEnumValueToString(bluetoothRadioState));\n+ putValueInJson(jsonObject, EVENT_VALUE_WIFI,\n+ radioStateEnumValueToString(wifiRadioState));\n+ putValueInJson(jsonObject, EVENT_VALUE_CELLULAR,\n+ radioStateEnumValueToString(cellularRadioState));\n+ if (wifiRadioState != RadioState.NOT_HERE) {\n+ putValueInJson(jsonObject, EVENT_VALUE_BSSID_NAME, bssidName);\n+ putValueInJson(jsonObject, EVENT_VALUE_SSID_NAME, removeQuotes(ssidName));\n+ }\njsonObjectCreated = true;\n} catch (JSONException e) {\nLog.e(TAG, \"notifyNetworkChanged: Failed to populate the JSON object: \" + e.getMessage(), e);\n@@ -679,7 +657,6 @@ public class JXcoreExtension implements SurroundingStateObserver {\nif (jsonObjectCreated) {\nfinal String jsonObjectAsString = jsonObject.toString();\n-\njxcore.activity.runOnUiThread(new Runnable() {\n@Override\npublic void run() {\n@@ -689,6 +666,54 @@ public class JXcoreExtension implements SurroundingStateObserver {\n}\n}\n+ private void putValueInJson(JSONObject jsonObject, String key, Object value) throws JSONException {\n+ jsonObject.put(key, (value == null) ? JSONObject.NULL : value);\n+ }\n+\n+ private RadioState getBleRadioState(ConnectivityMonitor connectivityMonitor, boolean isBluetoothEnabled) {\n+ if (connectivityMonitor.isBleMultipleAdvertisementSupported() !=\n+ BluetoothManager.FeatureSupportedStatus.NOT_SUPPORTED) {\n+ if (isBluetoothEnabled) {\n+ return RadioState.ON;\n+ } else {\n+ return RadioState.OFF;\n+ }\n+ } else {\n+ return RadioState.NOT_HERE;\n+ }\n+ }\n+\n+ private RadioState getBluetoothRadioState(ConnectivityMonitor connectivityMonitor, boolean isBluetoothEnabled) {\n+ if (connectivityMonitor.isBluetoothSupported()) {\n+ if (isBluetoothEnabled) {\n+ return RadioState.ON;\n+ } else {\n+ return RadioState.OFF;\n+ }\n+ } else {\n+ return RadioState.NOT_HERE;\n+ }\n+ }\n+\n+ private RadioState getWifiRadioState(ConnectivityMonitor connectivityMonitor, boolean isWifiEnabled) {\n+ if (connectivityMonitor.isWifiDirectSupported()) {\n+ if (isWifiEnabled) {\n+ return RadioState.ON;\n+ } else {\n+ return RadioState.OFF;\n+ }\n+ } else {\n+ return RadioState.NOT_HERE;\n+ }\n+ }\n+\n+ private String removeQuotes(String strWithQuotes) {\n+ if (strWithQuotes != null && !strWithQuotes.isEmpty()) {\n+ return strWithQuotes.substring(1, strWithQuotes.length() - 1);\n+ }\n+ return strWithQuotes;\n+ }\n+\n/**\n* This event is guaranteed to be not sent more often than every 100 ms.\n*\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add null sending in JSON between Android and Node
|
675,373 |
23.01.2017 17:00:55
| -10,800 |
d0c19504dff0333dd6be82be7baef54fd1513242
|
Process primitive types in JSON the same way as reference types
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -573,15 +573,13 @@ public class JXcoreExtension implements SurroundingStateObserver {\npublic void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {\nJSONObject jsonObject = new JSONObject();\nboolean jsonObjectCreated = false;\n-\ntry {\n- jsonObject.put(EVENT_VALUE_DISCOVERY_ACTIVE, isDiscoveryActive);\n- jsonObject.put(EVENT_VALUE_ADVERTISING_ACTIVE, isAdvertisingActive);\n+ putValueInJson(jsonObject, EVENT_VALUE_DISCOVERY_ACTIVE, isDiscoveryActive);\n+ putValueInJson(jsonObject, EVENT_VALUE_ADVERTISING_ACTIVE, isAdvertisingActive);\njsonObjectCreated = true;\n} catch (JSONException e) {\nLog.e(TAG, \"notifyDiscoveryAdvertisingStateUpdateNonTcp: Failed to populate the JSON object: \" + e.getMessage(), e);\n}\n-\nif (jsonObjectCreated) {\nfinal String jsonObjectAsString = jsonObject.toString();\n@@ -726,14 +724,12 @@ public class JXcoreExtension implements SurroundingStateObserver {\n+ INCOMING_CONNECTION_FAILED_NOTIFICATION_MIN_INTERVAL_IN_MILLISECONDS) {\nJSONObject jsonObject = new JSONObject();\nboolean jsonObjectCreated = false;\n-\ntry {\n- jsonObject.put(EVENT_VALUE_PORT_NUMBER, portNumber);\n+ putValueInJson(jsonObject, EVENT_VALUE_PORT_NUMBER, portNumber);\njsonObjectCreated = true;\n} catch (JSONException e) {\nLog.e(TAG, \"notifyIncomingConnectionToPortNumberFailed: Failed to populate the JSON object: \" + e.getMessage(), e);\n}\n-\nif (jsonObjectCreated) {\nmLastTimeIncomingConnectionFailedNotificationWasFired = currentTime;\nfinal String jsonObjectAsString = jsonObject.toString();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Process primitive types in JSON the same way as reference types
|
675,381 |
24.01.2017 16:39:06
| -10,800 |
ae00b6189321206a3a08fd5c6193210960fa6add
|
Add docs, fix lint warnings
Add docs, fix lint warnings
Clean up thaliMobile.js and testThaliMobile.js
|
[
{
"change_type": "MODIFY",
"old_path": ".eslintrc",
"new_path": ".eslintrc",
"diff": "}\n],\n\"no-new\": 2,\n+ \"no-extra-semi\": 2,\n\"no-extra-parens\": 2,\n\"no-use-before-define\": [\n2,\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1364,7 +1364,7 @@ function (t) {\n});\n});\n-function checkPeerHostInfoProperties(t, peerHostInfo, peer) {\n+function validatePeerHostInfo (t, peerHostInfo) {\nvar expectedKeys = ['hostAddress', 'portNumber', 'suggestedTCPTimeout'];\nvar actualKeys = Object.keys(peerHostInfo);\nexpectedKeys.sort();\n@@ -1393,7 +1393,7 @@ test('#getPeerHostInfo - returns discovered cached native peer (BLUETOOTH)',\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n- checkPeerHostInfoProperties(t, peerHostInfo, peer);\n+ validatePeerHostInfo(t, peerHostInfo);\nt.equal(peerHostInfo.hostAddress, '127.0.0.1', 'the same hostAddress');\nt.equal(peerHostInfo.portNumber, peer.portNumber, 'the same portNumber');\nt.end();\n@@ -1435,7 +1435,7 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n- checkPeerHostInfoProperties(t, peerHostInfo, peer);\n+ validatePeerHostInfo(t, peerHostInfo);\nt.equal(peerHostInfo.hostAddress, '127.0.0.1', 'the same hostAddress');\nt.equal(peerHostInfo.portNumber, resolvedPortNumber, 'the same portNumber');\n})\n@@ -1463,7 +1463,7 @@ test('#getPeerHostInfo - returns discovered cached wifi peer',\nThaliMobile.getPeerHostInfo(peer.peerIdentifier, connectionType)\n.then(function (peerHostInfo) {\n- checkPeerHostInfoProperties(t, peerHostInfo, peer);\n+ validatePeerHostInfo(t, peerHostInfo);\nt.equal(peerHostInfo.hostAddress, peer.hostAddress,\n'the same hostAddress');\nt.equal(peerHostInfo.portNumber, peer.portNumber, 'the same portNumber');\n@@ -1563,7 +1563,8 @@ test('network changes emitted correctly',\n.then(function () {\nreturn new Promise(function (resolve) {\nfunction networkChangedHandler (networkStatus) {\n- // TODO Android can send event with 'wifi': 'off' and without 'bssidName' and 'ssidName'.\n+ // TODO Android can send event with 'wifi': 'off' and without\n+ // 'bssidName' and 'ssidName'.\n// t.equals(networkStatus.wifi, 'off', 'wifi should be off');\nt.ok(networkStatus.bssidName == null, 'bssid should be null');\nt.ok(networkStatus.ssidName == null, 'ssid should be null');\n@@ -1593,7 +1594,7 @@ test('network changes emitted correctly',\n// Phone is still trying to connect to wifi.\n// We are waiting for 'ssidName' and 'bssidName'.\n}\n- }\n+ };\nThaliMobile.emitter.on('networkChanged', networkChangedHandler);\ntestUtils.toggleWifi(true);\n})\n@@ -2153,20 +2154,20 @@ test('can get data from all participants',\nreturn testUtils.get(\npeerHostInfo.hostAddress, peerHostInfo.portNumber,\nuuidPath, pskIdentity, pskKey\n- ).catch(function (err) {\n+ ).catch(function () {\n// Ignore request failures. After peer listener recreating we are\n// getting new peerAvailabilityChanged event and retrying this request\nreturn null;\n});\n})\n- .then(function (responseBody) {\n- if (responseBody === null) {\n+ .then(function (uuid) {\n+ if (uuid === null) {\nreturn;\n}\n- if (remainingParticipants[responseBody] !== participantState.notRunning) {\n+ if (remainingParticipants[uuid] !== participantState.notRunning) {\nreturn Promise.resolve(true);\n}\n- remainingParticipants[responseBody] = participantState.finished;\n+ remainingParticipants[uuid] = participantState.finished;\nvar areWeDone = Object.getOwnPropertyNames(remainingParticipants)\n.every(\nfunction (participant) {\n@@ -2273,8 +2274,8 @@ function setUpRouter() {\ntest('test for data corruption',\nfunction () {\n- return global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI\n- || !platform.isAndroid;\n+ return global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n+ !platform.isAndroid;\n},\nfunction (t) {\nvar router = setUpRouter();\n@@ -2284,10 +2285,13 @@ test('test for data corruption',\nvar promiseQueue = new PromiseQueue();\n// This timer purpose is to manually restart ThaliMobile every 60 seconds.\n- // Whole test timeout is set to 5 minutes, so there will be at most 4 restart attempts.\n- // Timer is used because of possible race condition when stopping and starting\n- // ThaliMobile every time error occurs, which led to test failure because exception was\n- // thrown.\n+ // Whole test timeout is set to 5 minutes, so there will be at most 4\n+ // restart attempts.\n+ //\n+ // Timer is used because of possible race condition when stopping and\n+ // starting ThaliMobile every time error occurs, which led to test failure\n+ // because exception was thrown.\n+ //\n// This issue is tracked in #1719.\nvar timer = setInterval(function() {\nlogger.debug('Restarting test for data corruption');\n@@ -2297,7 +2301,7 @@ test('test for data corruption',\n});\n}, 60 * 1000);\n- var runTestFunction = function () {\n+ function runTestFunction () {\nt.participants.forEach(function (participant) {\nif (participant.uuid === tape.uuid) {\nreturn;\n@@ -2313,11 +2317,11 @@ test('test for data corruption',\ndone();\nclearInterval(timer);\n}\n- })\n});\n- };\n+ });\n+ }\n- var testFunction = function (peer) {\n+ function testFunction (peer) {\n// Try to get data only from non-TCP peers so that the test\n// works the same way on desktop on CI where Wifi is blocked\n// between peers.\n@@ -2382,7 +2386,8 @@ test('test for data corruption',\nareWeDone = Object.getOwnPropertyNames(participantsState)\n.every(\nfunction (participant) {\n- return participantsState[participant] === participantState.finished\n+ return participantsState[participant] ===\n+ participantState.finished;\n});\nif (areWeDone) {\n@@ -2391,24 +2396,29 @@ test('test for data corruption',\nreturn resolve(true);\n}\n- ThaliMobileNativeWrapper._getServersManager()\n- .terminateOutgoingConnection(peer.peerIdentifier, peer.portNumber);\n+ var serversManager = ThaliMobileNativeWrapper._getServersManager();\n+ serversManager.terminateOutgoingConnection(\n+ peer.peerIdentifier,\n+ peer.portNumber\n+ );\n- // We have to give Android enough time to notice the killed connection\n- // and recycle everything\n+ // We have to give Android enough time to notice the killed\n+ // connection and recycle everything\nsetTimeout(function () {\nreturn resolve(null);\n}, 1000);\n});\n});\n- };\n+ }\nrunTestFunction();\n}\n);\n-test('Discovered peer should be removed if no availability updates ' +\n- 'were received during availability timeout', function (t) {\n+test(\n+ 'Discovered peer should be removed if no availability updates ' +\n+ 'were received during availability timeout',\n+ function (t) {\nvar peerIdentifier = 'urn:uuid:' + uuid.v4();\nvar portNumber = 8080;\nvar generation = 50;\n@@ -2464,4 +2474,5 @@ test('Discovered peer should be removed if no availability updates ' +\n.catch(function (error) {\nfinalizeTest(error);\n});\n-});\n+ }\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobile.js",
"new_path": "thali/NextGeneration/thaliMobile.js",
"diff": "@@ -283,7 +283,16 @@ function startListeningForAdvertisements () {\n);\nreturn start();\n}\n-module.exports._startListeningForAdvertisements = startListeningForAdvertisements;\n+\n+/**\n+ * Exported for testing purposes\n+ * @private\n+ *\n+ * TODO: remove this export and instead check thaliWifiInfrastructure and\n+ * thaliMobileNativeWrapper start methods in tests\n+ */\n+module.exports._startListeningForAdvertisements =\n+ startListeningForAdvertisements;\n/**\n* This method calls the underlying startListeningForAdvertisements\n@@ -351,7 +360,16 @@ function startUpdateAdvertisingAndListening () {\n);\nreturn start();\n}\n-module.exports._startUpdateAdvertisingAndListening = startUpdateAdvertisingAndListening;\n+\n+/**\n+ * Exported for testing purposes\n+ * @private\n+ *\n+ * TODO: remove this export and instead check thaliWifiInfrastructure and\n+ * thaliMobileNativeWrapper start methods in tests\n+ */\n+module.exports._startUpdateAdvertisingAndListening =\n+ startUpdateAdvertisingAndListening;\n/**\n* This method calls the underlying startUpdateAdvertisingAndListening\n@@ -1438,7 +1456,8 @@ function handleNetworkChanged (networkChangedValue) {\n}\nif (thaliMobileStates.advertising) {\npromiseQueue.enqueueAtTop(function (resolve, reject) {\n- module.exports._startUpdateAdvertisingAndListening().then(resolve, reject);\n+ module.exports._startUpdateAdvertisingAndListening()\n+ .then(resolve, reject);\n}).then(function (combinedResult) {\ncheckErrors('startUpdateAdvertisingAndListening', combinedResult);\n});\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add docs, fix lint warnings (#1746)
Add docs, fix lint warnings
Clean up thaliMobile.js and testThaliMobile.js
|
675,379 |
26.10.2016 17:50:09
| -10,800 |
32bf52d1d86a30d31708011c48811dd59c4717da
|
Separate thread for NSStream events.
Improve handling events in VirtualSocket.swift.
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/project.pbxproj",
"new_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/project.pbxproj",
"diff": "1C6D71411DAF9BDB00802569 /* StringRandomTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AD347541D9FEED9006F1126 /* StringRandomTests.swift */; };\n1C6D71421DAFBBD100802569 /* TCPClientMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C148D151DA3B17500E0E1AC /* TCPClientMock.swift */; };\n1C6D71431DAFBBDC00802569 /* TCPServerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C148D131DA3B16C00E0E1AC /* TCPServerMock.swift */; };\n+ 1C8776E81DC0F2E0004CF9BD /* NSRunLoop+NSStreamEventsThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C8776E71DC0F2E0004CF9BD /* NSRunLoop+NSStreamEventsThread.swift */; };\n+ 1C8776EA1DC0F324004CF9BD /* NSStreamEventsThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C8776E91DC0F324004CF9BD /* NSStreamEventsThread.swift */; };\n+ 1C8776EB1DC0F324004CF9BD /* NSStreamEventsThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C8776E91DC0F324004CF9BD /* NSStreamEventsThread.swift */; };\n+ 1C8776EC1DC0F32A004CF9BD /* NSRunLoop+NSStreamEventsThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C8776E71DC0F2E0004CF9BD /* NSRunLoop+NSStreamEventsThread.swift */; };\n1CB9B4211D7063C700C59CCF /* BluetoothManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB9B4201D7063C700C59CCF /* BluetoothManager.h */; };\n1CD4C0AF1DA68E7B005FFC3B /* AdvertiserRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD4C0AE1DA68E7B005FFC3B /* AdvertiserRelay.swift */; };\n1CD4C0B01DA68E7B005FFC3B /* AdvertiserRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD4C0AE1DA68E7B005FFC3B /* AdvertiserRelay.swift */; };\n1C38DDD11D74153900418F15 /* BluetoothHardwareControlManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BluetoothHardwareControlManager.h; path = Utils/HardwareControl/Bluetooth/BluetoothHardwareControlManager.h; sourceTree = \"<group>\"; };\n1C38DDD21D74153900418F15 /* BluetoothHardwareControlManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BluetoothHardwareControlManager.m; path = Utils/HardwareControl/Bluetooth/BluetoothHardwareControlManager.m; sourceTree = \"<group>\"; };\n1C38DDD31D74153900418F15 /* BluetoothHardwareControlObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BluetoothHardwareControlObserver.h; path = Utils/HardwareControl/Bluetooth/BluetoothHardwareControlObserver.h; sourceTree = \"<group>\"; };\n+ 1C5E18BD1D780D5400518DB8 /* BluetoothHardwareControlObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BluetoothHardwareControlObserver.m; sourceTree = \"<group>\"; };\n+ 1C8776E71DC0F2E0004CF9BD /* NSRunLoop+NSStreamEventsThread.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = \"NSRunLoop+NSStreamEventsThread.swift\"; sourceTree = \"<group>\"; };\n+ 1C8776E91DC0F324004CF9BD /* NSStreamEventsThread.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSStreamEventsThread.swift; sourceTree = \"<group>\"; };\n1CB9B4201D7063C700C59CCF /* BluetoothManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BluetoothManager.h; path = Utils/HardwareControl/Bluetooth/PrivateAPI/BluetoothManager.h; sourceTree = \"<group>\"; };\n1CD4C0AE1DA68E7B005FFC3B /* AdvertiserRelay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvertiserRelay.swift; sourceTree = \"<group>\"; };\n1CD4C0B11DA68E86005FFC3B /* BrowserRelay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrowserRelay.swift; sourceTree = \"<group>\"; };\n3AD347511D9FB556006F1126 /* TCPClient.swift */,\n1CEBB3F91D997BF700B229C9 /* TCPListener.swift */,\n1CEBB3FC1D997CB200B229C9 /* VirtualSocket.swift */,\n+ 1C8776E91DC0F324004CF9BD /* NSStreamEventsThread.swift */,\n+ 1C8776E71DC0F2E0004CF9BD /* NSRunLoop+NSStreamEventsThread.swift */,\n);\npath = SocketConnection;\nsourceTree = \"<group>\";\nFAADDB5F680C576D4D34638B /* Advertiser.swift in Sources */,\n1CEBB3F21D997A8600B229C9 /* GCDAsyncSocket.m in Sources */,\nFAADD49592809F2012ED7B29 /* ApplicationStateNotificationsManager.swift in Sources */,\n+ 1C8776E81DC0F2E0004CF9BD /* NSRunLoop+NSStreamEventsThread.swift in Sources */,\n3AD347521D9FB556006F1126 /* TCPClient.swift in Sources */,\nFAADD7B9451F32511828885E /* Browser.swift in Sources */,\n1C148DDA1DA55D4900E0E1AC /* Dictionary+KeyForValue.swift in Sources */,\nFAADD5FE7712039E773BC6E5 /* AdvertiserManager.swift in Sources */,\nFAADDDA8FB9D6E557F49081B /* BrowserManager.swift in Sources */,\n3AD347561D9FEF78006F1126 /* String+Random.swift in Sources */,\n+ 1C8776EA1DC0F324004CF9BD /* NSStreamEventsThread.swift in Sources */,\nFAADD04D8930DF3297562D09 /* Session.swift in Sources */,\n1CD4C0B21DA68E86005FFC3B /* BrowserRelay.swift in Sources */,\nFAADD16070404F0C249AF956 /* VirtualSocketBuilder.swift in Sources */,\nCCA573131D4BA04B00FBEC41 /* TestRunner.swift in Sources */,\nD377C5021D6D9C1600916A7B /* VirtualSocketBuilder.swift in Sources */,\nFAADDA5FCF7F856DF4224B68 /* Advertiser.swift in Sources */,\n+ 1C8776EC1DC0F32A004CF9BD /* NSRunLoop+NSStreamEventsThread.swift in Sources */,\nFAADD705CAB9E45559605B8F /* Browser.swift in Sources */,\n1C38DDD51D74153900418F15 /* BluetoothHardwareControlManager.m in Sources */,\nFAADD430F6A5902FD5595B47 /* ApplicationStateNotificationsManager.swift in Sources */,\n1CEBB3FB1D997BF700B229C9 /* TCPListener.swift in Sources */,\n1C6D713C1DAF9BCB00802569 /* AdvertiserRelayTests.swift in Sources */,\nFAADD38EEA68209A678157F2 /* AdvertiserTests.swift in Sources */,\n+ 1C8776EB1DC0F324004CF9BD /* NSStreamEventsThread.swift in Sources */,\nFAADD2472EF20C245A535EB0 /* AdvertiserManagerTests.swift in Sources */,\n1CEBB4011D997CF500B229C9 /* PeerAvailability.swift in Sources */,\nFAADDC4F91EB0C57EF22ADEC /* VirtualSocketBuilderTests.swift in Sources */,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/NSRunLoop+NSStreamEventsThread.swift",
"diff": "+//\n+// Thali CordovaPlugin\n+// NSRunLoop+NSStreamEventsThread.swift\n+//\n+// Copyright (C) Microsoft. All rights reserved.\n+// Licensed under the MIT license.\n+// See LICENSE.txt file in the project root for full license information.\n+//\n+\n+import Foundation\n+\n+extension NSRunLoop {\n+\n+ class func myRunLoop() -> NSRunLoop {\n+ return NSStreamEventsThread.sharedInstance.runLoop\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/NSStreamEventsThread.swift",
"diff": "+//\n+// Thali CordovaPlugin\n+// NSStreamEventsThread.swift\n+//\n+// Copyright (C) Microsoft. All rights reserved.\n+// Licensed under the MIT license.\n+// See LICENSE.txt file in the project root for full license information.\n+//\n+\n+import Foundation\n+\n+class NSStreamEventsThread: NSThread {\n+\n+ private let _runLoopReadyGroup: dispatch_group_t\n+ private var _runLoop: NSRunLoop\n+ internal var runLoop: NSRunLoop {\n+ get {\n+ dispatch_group_wait(_runLoopReadyGroup, DISPATCH_TIME_FOREVER)\n+ return _runLoop\n+ }\n+ }\n+\n+ class var sharedInstance: NSStreamEventsThread {\n+\n+ struct Static {\n+\n+ static var instance: NSStreamEventsThread? = nil\n+ static var thread: NSStreamEventsThread? = nil\n+ static var onceToken: dispatch_once_t = 0\n+ }\n+\n+ dispatch_once(&Static.onceToken) {\n+ print(\"DIS\")\n+ Static.thread = NSStreamEventsThread()\n+ Static.thread?.name = \"com.THALI.SocketRocket.NetworkThread\"\n+ Static.thread?.start()\n+ }\n+\n+ return Static.thread!\n+ }\n+\n+ override init() {\n+ _runLoop = NSRunLoop()\n+ _runLoopReadyGroup = dispatch_group_create()\n+ dispatch_group_enter(_runLoopReadyGroup)\n+ }\n+\n+ override func main() {\n+ autoreleasepool {\n+ _runLoop = NSRunLoop.currentRunLoop()\n+ dispatch_group_leave(_runLoopReadyGroup)\n+\n+ // Prevent runloop from spinning\n+ var sourceCtx = CFRunLoopSourceContext(version: 0,\n+ info: nil,\n+ retain: nil,\n+ release: nil,\n+ copyDescription: nil,\n+ equal: nil,\n+ hash: nil,\n+ schedule: nil,\n+ cancel: nil,\n+ perform: nil)\n+\n+ let source = CFRunLoopSourceCreate(nil, 0, &sourceCtx)\n+ CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode)\n+\n+ while _runLoop.runMode(NSDefaultRunLoopMode, beforeDate: NSDate.distantFuture()) {}\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocket.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocket.swift",
"diff": "@@ -28,12 +28,18 @@ class VirtualSocket: NSObject {\nprivate var outputStreamOpened = false\nlet maxReadBufferLength = 1024\n- private var pendingDataToWrite: NSMutableData?\n+ let maxDataToWriteLength = 1024\n+\n+ private var bufferToWrite: Atomic<NSMutableData>\n+\n+ private let _workQueue: dispatch_queue_t\n// MARK: - Initialize\ninit(with inputStream: NSInputStream, outputStream: NSOutputStream) {\nself.inputStream = inputStream\nself.outputStream = outputStream\n+ bufferToWrite = Atomic(NSMutableData())\n+ _workQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL)\nsuper.init()\n}\n@@ -41,19 +47,17 @@ class VirtualSocket: NSObject {\nfunc openStreams() {\nif !opened {\nopened = true\n- let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)\n- dispatch_async(queue, {\n+\n+ dispatch_async(_workQueue, {\nself.inputStream.delegate = self\n- self.inputStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(),\n+ self.inputStream.scheduleInRunLoop(NSRunLoop.myRunLoop(),\nforMode: NSDefaultRunLoopMode)\nself.inputStream.open()\nself.outputStream.delegate = self\n- self.outputStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(),\n+ self.outputStream.scheduleInRunLoop(NSRunLoop.myRunLoop(),\nforMode: NSDefaultRunLoopMode)\nself.outputStream.open()\n-\n- NSRunLoop.currentRunLoop().runUntilDate(NSDate.distantFuture())\n})\n}\n}\n@@ -62,9 +66,13 @@ class VirtualSocket: NSObject {\nif opened {\nopened = false\n+ inputStream.delegate = nil\n+\ninputStream.close()\ninputStreamOpened = false\n+ outputStream.delegate = nil\n+\noutputStream.close()\noutputStreamOpened = false\n@@ -73,31 +81,38 @@ class VirtualSocket: NSObject {\n}\nfunc writeDataToOutputStream(data: NSData) {\n+ self.bufferToWrite.modify {\n+ $0.appendData(data)\n+ }\n- if !outputStream.hasSpaceAvailable {\n- pendingDataToWrite?.appendData(data)\n+ dispatch_async(_workQueue, {\n+ self.writePendingDataFromBuffer()\n+ })\n+ }\n+\n+ // MARK: - Private methods\n+ @objc private func writePendingDataFromBuffer() {\n+ let bufferLength = bufferToWrite.value.length\n+\n+ guard bufferLength > 0 else {\nreturn\n}\n- let dataLength = data.length\n- let buffer: [UInt8] = Array(\n- UnsafeBufferPointer(start: UnsafePointer<UInt8>(data.bytes),\n- count: dataLength)\n- )\n+ let dataToBeWrittenLength = min(bufferLength, maxDataToWriteLength)\n+\n+ var buffer = [UInt8](count: dataToBeWrittenLength, repeatedValue: 0)\n+ bufferToWrite.value.getBytes(&buffer, length: dataToBeWrittenLength)\n+\n+ let bytesWritten = outputStream.write(buffer, maxLength: dataToBeWrittenLength)\n- let bytesWritten = outputStream.write(buffer, maxLength: dataLength)\nif bytesWritten < 0 {\ncloseStreams()\n+ } else if bytesWritten > 0 {\n+ let writtenBytesRange = NSRange(location: 0, length: bytesWritten)\n+ bufferToWrite.modify {\n+ $0.replaceBytesInRange(writtenBytesRange, withBytes: nil, length: 0)\n}\n}\n-\n- func writePendingData() {\n- guard let dataToWrite = pendingDataToWrite else {\n- return\n- }\n-\n- pendingDataToWrite = nil\n- writeDataToOutputStream(dataToWrite)\n}\nprivate func readDataFromInputStream() {\n@@ -111,6 +126,10 @@ class VirtualSocket: NSObject {\ncloseStreams()\n}\n}\n+\n+ deinit {\n+ closeStreams()\n+ }\n}\n// MARK: - NSStreamDelegate - Handling stream events\n@@ -128,15 +147,21 @@ extension VirtualSocket: NSStreamDelegate {\n}\n}\n+ // MARK: - Private helpers\nprivate func handleEventOnInputStream(eventCode: NSStreamEvent) {\nswitch eventCode {\ncase NSStreamEvent.OpenCompleted:\ninputStreamOpened = true\ndidOpenStreamHandler()\ncase NSStreamEvent.HasBytesAvailable:\n- readDataFromInputStream()\n+ dispatch_async(_workQueue, {\n+ [weak self] in\n+ guard let strongSelf = self else { return }\n+\n+ strongSelf.readDataFromInputStream()\n+ })\ncase NSStreamEvent.HasSpaceAvailable:\n- closeStreams()\n+ break\ncase NSStreamEvent.ErrorOccurred:\ncloseStreams()\ncase NSStreamEvent.EndEncountered:\n@@ -152,9 +177,14 @@ extension VirtualSocket: NSStreamDelegate {\noutputStreamOpened = true\ndidOpenStreamHandler()\ncase NSStreamEvent.HasBytesAvailable:\n- readDataFromInputStream()\n+ break\ncase NSStreamEvent.HasSpaceAvailable:\n- writePendingData()\n+ dispatch_async(_workQueue, {\n+ [weak self] in\n+ guard let strongSelf = self else { return }\n+\n+ strongSelf.writePendingDataFromBuffer()\n+ })\ncase NSStreamEvent.ErrorOccurred:\ncloseStreams()\ncase NSStreamEvent.EndEncountered:\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Separate thread for NSStream events.
Improve handling events in VirtualSocket.swift.
|
675,379 |
27.10.2016 11:03:07
| -10,800 |
224f8f7b0ab89cc63a48b9161cb49b0aa9f32423
|
Small updates in code.
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/NSStreamEventsThread.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/NSStreamEventsThread.swift",
"diff": "@@ -11,11 +11,11 @@ import Foundation\nclass NSStreamEventsThread: NSThread {\n- private let _runLoopReadyGroup: dispatch_group_t\n+ private let runLoopReadyGroup: dispatch_group_t\nprivate var _runLoop: NSRunLoop\ninternal var runLoop: NSRunLoop {\nget {\n- dispatch_group_wait(_runLoopReadyGroup, DISPATCH_TIME_FOREVER)\n+ dispatch_group_wait(runLoopReadyGroup, DISPATCH_TIME_FOREVER)\nreturn _runLoop\n}\n}\n@@ -30,9 +30,8 @@ class NSStreamEventsThread: NSThread {\n}\ndispatch_once(&Static.onceToken) {\n- print(\"DIS\")\nStatic.thread = NSStreamEventsThread()\n- Static.thread?.name = \"com.THALI.SocketRocket.NetworkThread\"\n+ Static.thread?.name = \"com.thaliproject.NSStreamEventsThread\"\nStatic.thread?.start()\n}\n@@ -41,14 +40,14 @@ class NSStreamEventsThread: NSThread {\noverride init() {\n_runLoop = NSRunLoop()\n- _runLoopReadyGroup = dispatch_group_create()\n- dispatch_group_enter(_runLoopReadyGroup)\n+ runLoopReadyGroup = dispatch_group_create()\n+ dispatch_group_enter(runLoopReadyGroup)\n}\noverride func main() {\nautoreleasepool {\n_runLoop = NSRunLoop.currentRunLoop()\n- dispatch_group_leave(_runLoopReadyGroup)\n+ dispatch_group_leave(runLoopReadyGroup)\n// Prevent runloop from spinning\nvar sourceCtx = CFRunLoopSourceContext(version: 0,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocket.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocket.swift",
"diff": "@@ -32,14 +32,14 @@ class VirtualSocket: NSObject {\nprivate var bufferToWrite: Atomic<NSMutableData>\n- private let _workQueue: dispatch_queue_t\n+ private let workQueue: dispatch_queue_t\n// MARK: - Initialize\ninit(with inputStream: NSInputStream, outputStream: NSOutputStream) {\nself.inputStream = inputStream\nself.outputStream = outputStream\nbufferToWrite = Atomic(NSMutableData())\n- _workQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL)\n+ workQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL)\nsuper.init()\n}\n@@ -48,7 +48,6 @@ class VirtualSocket: NSObject {\nif !opened {\nopened = true\n- dispatch_async(_workQueue, {\nself.inputStream.delegate = self\nself.inputStream.scheduleInRunLoop(NSRunLoop.myRunLoop(),\nforMode: NSDefaultRunLoopMode)\n@@ -58,7 +57,6 @@ class VirtualSocket: NSObject {\nself.outputStream.scheduleInRunLoop(NSRunLoop.myRunLoop(),\nforMode: NSDefaultRunLoopMode)\nself.outputStream.open()\n- })\n}\n}\n@@ -85,7 +83,7 @@ class VirtualSocket: NSObject {\n$0.appendData(data)\n}\n- dispatch_async(_workQueue, {\n+ dispatch_async(workQueue, {\nself.writePendingDataFromBuffer()\n})\n}\n@@ -154,7 +152,7 @@ extension VirtualSocket: NSStreamDelegate {\ninputStreamOpened = true\ndidOpenStreamHandler()\ncase NSStreamEvent.HasBytesAvailable:\n- dispatch_async(_workQueue, {\n+ dispatch_async(workQueue, {\n[weak self] in\nguard let strongSelf = self else { return }\n@@ -179,7 +177,7 @@ extension VirtualSocket: NSStreamDelegate {\ncase NSStreamEvent.HasBytesAvailable:\nbreak\ncase NSStreamEvent.HasSpaceAvailable:\n- dispatch_async(_workQueue, {\n+ dispatch_async(workQueue, {\n[weak self] in\nguard let strongSelf = self else { return }\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Small updates in code.
|
675,381 |
27.01.2017 13:00:44
| -10,800 |
00c7de53d92ec12f9db1e76580c6785e2e557377
|
Fix missed review comments and linter warnings
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "@@ -201,11 +201,19 @@ var connectionTester = function(port, reversed) {\nreturn new Promise(function(resolve, reject) {\nvar connection = net.createConnection(port, function () {\nconnection.destroy();\n- reversed ? reject() : resolve();\n+ if (reversed) {\n+ reject(new Error('Unexpectedly successful connection'));\n+ } else {\n+ resolve();\n+ }\n});\nconnection.on('error', function (error) {\nconnection.destroy();\n- reversed ? resolve() : reject(error);\n+ if (reversed) {\n+ resolve();\n+ } else {\n+ reject(error);\n+ }\n});\n});\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/testUtils.js",
"new_path": "test/www/jxcore/lib/testUtils.js",
"diff": "@@ -61,7 +61,7 @@ function toggleWifi (value) {\n}\n});\n});\n-};\n+}\nmodule.exports.toggleWifi = toggleWifi;\nvar ThaliMobile;\n@@ -72,7 +72,10 @@ var ensureNetwork = function (type, toggle, value, customCheck) {\nvar valueString = value? 'on' : 'off';\nfunction check (networkStatus) {\n- return networkStatus[type] === valueString && (customCheck? customCheck(networkStatus) : true);\n+ return (\n+ networkStatus[type] === valueString &&\n+ (customCheck? customCheck(networkStatus) : true)\n+ );\n}\nreturn ThaliMobile.getNetworkStatus()\n@@ -117,7 +120,10 @@ var ensureNetwork = function (type, toggle, value, customCheck) {\nmodule.exports.ensureWifi = function (value) {\nreturn ensureNetwork('wifi', toggleWifi, value, function (networkStatus) {\n- var isConnected = networkStatus.bssidName != null && networkStatus.ssidName != null;\n+ var isConnected = (\n+ networkStatus.bssidName != null &&\n+ networkStatus.ssidName != null\n+ );\nreturn value === isConnected;\n});\n};\n@@ -218,13 +224,14 @@ module.exports.tmpDirectory = tmpDirectory;\n* device has the hardware capabilities required.\n* On Android, checks the BLE multiple advertisement feature and elsewhere\n* always resolves with true.\n+ * @returns {Promise<boolean>}\n*/\nmodule.exports.hasRequiredHardware = function () {\nif (!platform._isRealAndroid) {\nreturn Promise.resolve(true);\n}\n- return new Promise(function (resolve, reject) {\n+ return new Promise(function (resolve) {\nfunction checkBleMultipleAdvertisementSupport () {\nMobile('isBleMultipleAdvertisementSupported')\n.callNative(function (error, result) {\n@@ -279,7 +286,7 @@ module.exports.enableRequiredHardware = function () {\n.catch(function () {\nreturn false;\n});\n-}\n+};\nmodule.exports.returnsValidNetworkStatus = function () {\n// The require is here instead of top of file so that\n@@ -489,6 +496,10 @@ module.exports.getSamePeerWithRetry = function (path, pskIdentity, pskKey,\nvar getRequestPromise = null;\nvar cancelGetPortTimeout = null;\n+ var timeoutId = setTimeout(function () {\n+ exitCall(null, new Error('Timer expired'));\n+ }, MAX_TIME_TO_WAIT_IN_MILLISECONDS);\n+\nfunction exitCall(success, failure) {\nif (exitCalled) {\nreturn;\n@@ -506,10 +517,6 @@ module.exports.getSamePeerWithRetry = function (path, pskIdentity, pskKey,\n});\n}\n- var timeoutId = setTimeout(function () {\n- exitCall(null, new Error('Timer expired'));\n- }, MAX_TIME_TO_WAIT_IN_MILLISECONDS);\n-\nfunction tryAgain(portNumber) {\n++retryCount;\nlogger.warn('Retry count for getSamePeerWithRetry is ' + retryCount);\n@@ -561,7 +568,7 @@ module.exports.getSamePeerWithRetry = function (path, pskIdentity, pskKey,\n}\n});\n- };\n+ }\nfunction nonTCPAvailableHandler(record) {\n// Ignore peer unavailable events\n@@ -607,7 +614,7 @@ module.exports.validateCombinedResult = function (combinedResult) {\nvar MAX_FAILURE = 10;\nvar RETRY_DELAY = 10000;\n-var TEST_TIMEOUT = 5 * 60 * 1000\n+var TEST_TIMEOUT = 5 * 60 * 1000;\nfunction turnParticipantsIntoBufferArray (t, devicePublicKey) {\nvar publicKeys = [];\n@@ -749,7 +756,7 @@ module.exports.runTestOnAllParticipants = function (\nvar publicKey = notificationForUs.keyId;\nparticipantTask[publicKey].cancel();\nparticipantTask[publicKey] = createTask(notificationForUs);\n- }\n+ };\nthaliNotificationClient.on(\nthaliNotificationClient.Events.PeerAdvertisesDataForUs,\nnotificationHandler\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -343,7 +343,6 @@ function stop(resolve, reject) {\nif (platform.isAndroid) {\nreturn stopServersManager();\n}\n- return Promise.resolve();\n})\n.catch(function (err) {\nerrorDescriptions.stopServersManagerError = err;\n@@ -351,22 +350,24 @@ function stop(resolve, reject) {\n.then(function () {\nvar oldRouterServer = gRouterServer;\ngRouterServer = null;\n- return oldRouterServer ? oldRouterServer.closeAllPromise() :\n- Promise.resolve();\n+ if (oldRouterServer) {\n+ return oldRouterServer.closeAllPromise();\n+ }\n})\n.catch(function (err) {\nerrorDescriptions.stopRouterServerError = err;\n})\n.then(function () {\nif (Object.keys(errorDescriptions).length === 0) {\n- return resolve();\n+ return;\n}\nvar error = new Error('check errorDescriptions property');\nerror.errorDescriptions = errorDescriptions;\n- return reject(error);\n- });\n+ return Promise.reject(error);\n+ })\n+ .then(resolve, reject);\n}\nfunction stopNative() {\n@@ -554,7 +555,7 @@ module.exports.startUpdateAdvertisingAndListening = function () {\nreturn reject(new Error('Call Start!'));\n}\n- var port = (platform.isAndroid) ?\n+ var port = platform.isAndroid ?\ngServersManagerLocalPort :\ngRouterServerPort;\n@@ -1061,15 +1062,12 @@ function handlePeerAvailabilityChanged (peer) {\nmodule.exports._handlePeerAvailabilityChanged = handlePeerAvailabilityChanged;\nfunction getPeerPort(peer) {\n- if (gServersManager) {\n- return gServersManager.createPeerListener(peer.peerIdentifier,\n- peer.pleaseConnect);\n- } else {\n- return Promise.resolve(null);\n- }\n+ return gServersManager ?\n+ gServersManager.createPeerListener(peer.peerIdentifier) :\n+ Promise.resolve(null);\n}\n-var recreatePeer = function (peerIdentifier) {\n+function recreatePeer(peerIdentifier) {\nvar peerUnavailable = {\npeerIdentifier: peerIdentifier,\npeerAvailable: false,\n@@ -1090,7 +1088,7 @@ var recreatePeer = function (peerIdentifier) {\n};\nhandlePeerAvailabilityChanged(peerAvailable);\n-};\n+}\n/* eslint-disable max-len */\n/**\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix missed review comments and linter warnings
|
675,381 |
27.01.2017 13:00:44
| -10,800 |
403f811ea13ca4fb76e1084037a37139f4bdffae
|
Update from iOS_squid48_1611 branch.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "@@ -201,11 +201,19 @@ var connectionTester = function(port, reversed) {\nreturn new Promise(function(resolve, reject) {\nvar connection = net.createConnection(port, function () {\nconnection.destroy();\n- reversed ? reject() : resolve();\n+ if (reversed) {\n+ reject(new Error('Unexpectedly successful connection'));\n+ } else {\n+ resolve();\n+ }\n});\nconnection.on('error', function (error) {\nconnection.destroy();\n- reversed ? resolve() : reject(error);\n+ if (reversed) {\n+ resolve();\n+ } else {\n+ reject(error);\n+ }\n});\n});\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -343,7 +343,6 @@ function stop(resolve, reject) {\nif (platform.isAndroid) {\nreturn stopServersManager();\n}\n- return Promise.resolve();\n})\n.catch(function (err) {\nerrorDescriptions.stopServersManagerError = err;\n@@ -351,22 +350,24 @@ function stop(resolve, reject) {\n.then(function () {\nvar oldRouterServer = gRouterServer;\ngRouterServer = null;\n- return oldRouterServer ? oldRouterServer.closeAllPromise() :\n- Promise.resolve();\n+ if (oldRouterServer) {\n+ return oldRouterServer.closeAllPromise();\n+ }\n})\n.catch(function (err) {\nerrorDescriptions.stopRouterServerError = err;\n})\n.then(function () {\nif (Object.keys(errorDescriptions).length === 0) {\n- return resolve();\n+ return;\n}\nvar error = new Error('check errorDescriptions property');\nerror.errorDescriptions = errorDescriptions;\n- return reject(error);\n- });\n+ return Promise.reject(error);\n+ })\n+ .then(resolve, reject);\n}\nfunction stopNative() {\n@@ -554,7 +555,7 @@ module.exports.startUpdateAdvertisingAndListening = function () {\nreturn reject(new Error('Call Start!'));\n}\n- var port = (platform.isAndroid) ?\n+ var port = platform.isAndroid ?\ngServersManagerLocalPort :\ngRouterServerPort;\n@@ -1061,15 +1062,12 @@ function handlePeerAvailabilityChanged (peer) {\nmodule.exports._handlePeerAvailabilityChanged = handlePeerAvailabilityChanged;\nfunction getPeerPort(peer) {\n- if (gServersManager) {\n- return gServersManager.createPeerListener(peer.peerIdentifier,\n- peer.pleaseConnect);\n- } else {\n- return Promise.resolve(null);\n- }\n+ return gServersManager ?\n+ gServersManager.createPeerListener(peer.peerIdentifier) :\n+ Promise.resolve(null);\n}\n-var recreatePeer = function (peerIdentifier) {\n+function recreatePeer(peerIdentifier) {\nvar peerUnavailable = {\npeerIdentifier: peerIdentifier,\npeerAvailable: false,\n@@ -1090,7 +1088,7 @@ var recreatePeer = function (peerIdentifier) {\n};\nhandlePeerAvailabilityChanged(peerAvailable);\n-};\n+}\n/* eslint-disable max-len */\n/**\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update from iOS_squid48_1611 branch.
|
675,379 |
27.01.2017 15:35:42
| -10,800 |
fd1d69c897b7fea48bcb0ae9ff7ffe6a03a11c61
|
Temporary disable desktop tests.
|
[
{
"change_type": "MODIFY",
"old_path": "build.sh",
"new_path": "build.sh",
"diff": "@@ -59,13 +59,13 @@ fi\necho \"\"\necho \"run desktop tests\"\n-jx runTests.js --networkType WIFI\n-jx runTests.js --networkType NATIVE\n-jx runTests.js --networkType BOTH\n-jx npm run test-meta\n-jx runCoordinatedTests.js --networkType NATIVE\n-jx runCoordinatedTests.js --networkType WIFI\n-jx runCoordinatedTests.js --networkType BOTH\n+#jx runTests.js --networkType WIFI\n+#jx runTests.js --networkType NATIVE\n+#jx runTests.js --networkType BOTH\n+#jx npm run test-meta\n+#jx runCoordinatedTests.js --networkType NATIVE\n+#jx runCoordinatedTests.js --networkType WIFI\n+#jx runCoordinatedTests.js --networkType BOTH\necho \"end desktop tests\"\necho \"\"\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Temporary disable desktop tests.
|
675,381 |
26.01.2017 15:00:14
| -10,800 |
c52ce6d79d1ced9ada005967f9ef5edf3e0147d1
|
Disable android-only tests on iOS platform
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1552,8 +1552,12 @@ test('#disconnect delegates native peers to the native wrapper',\ntest('network changes emitted correctly',\nfunction () {\n- return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI ||\n- global.NETWORK_TYPE !== ThaliMobile.networkTypes.BOTH;\n+ return (\n+ // iOS does not support toggleWifi\n+ platform.isIOS ||\n+ global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI ||\n+ global.NETWORK_TYPE !== ThaliMobile.networkTypes.BOTH\n+ );\n},\nfunction (t) {\ntestUtils.ensureWifi(true)\n@@ -1632,8 +1636,12 @@ function noNetworkChanged (t, toggle) {\ntest('network changes not emitted in started state',\nfunction () {\n- return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI ||\n- global.NETWORK_TYPE !== ThaliMobile.networkTypes.BOTH;\n+ return (\n+ // iOS does not support toggleWifi\n+ platform.isIOS ||\n+ global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI ||\n+ global.NETWORK_TYPE !== ThaliMobile.networkTypes.BOTH\n+ );\n},\nfunction (t) {\ntestUtils.ensureWifi(true)\n@@ -1649,8 +1657,12 @@ test('network changes not emitted in started state',\ntest('network changes not emitted in stopped state',\nfunction () {\n- return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI ||\n- global.NETWORK_TYPE !== ThaliMobile.networkTypes.BOTH;\n+ return (\n+ // iOS does not support toggleWifi\n+ platform.isIOS ||\n+ global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI ||\n+ global.NETWORK_TYPE !== ThaliMobile.networkTypes.BOTH\n+ );\n},\nfunction (t) {\ntestUtils.ensureWifi(false)\n@@ -1668,6 +1680,10 @@ test('network changes not emitted in stopped state',\n});\ntest('calls correct starts when network changes',\n+ function () {\n+ // iOS does not support toggleWifi\n+ return platform.isIOS;\n+ },\nfunction (t) {\nvar isWifiEnabled =\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Disable android-only tests on iOS platform
|
675,381 |
27.01.2017 16:24:57
| -10,800 |
9efdf73a66ec81699debeaa58dd2e8337e2ce223
|
Update multiConnect invalid syncValue handling.
Update tests, update mobile mock, update spec
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"diff": "@@ -122,23 +122,14 @@ test('multiConnect properly fails on legal but non-existent peerID',\ntest('cannot call multiConnect with invalid syncValue',\nfunction (t) {\nvar connectReturned = false;\n- var invalidSyncValue = 123;\n- thaliMobileNativeTestUtils.multiConnectEmitter\n- .on('multiConnectResolved', function (syncValue, error, listeningPort) {\n- t.ok(connectReturned, 'Should only get called after multiConnect ' +\n- 'returned');\n- t.equal(invalidSyncValue, syncValue, 'SyncValue matches');\n- t.equal(error, 'Bad parameters', 'Got right error');\n- t.notOk(listeningPort, 'listeningPort is null');\n- t.end();\n- });\n+ var invalidSyncValue = /I am not a string/;\nMobile('startListeningForAdvertisements').callNative(function (err) {\nt.notOk(err, 'No error on starting');\nvar peerId = nodeUuid.v4();\nMobile('multiConnect').callNative(peerId, invalidSyncValue,\n- function (err) {\n- t.notOk(err, 'Got null as expected');\n- connectReturned = true;\n+ function (error) {\n+ t.equal(error, 'Bad parameters', 'Got right error');\n+ t.end();\n});\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/wifiBasedNativeMock.js",
"new_path": "test/www/jxcore/lib/wifiBasedNativeMock.js",
"diff": "@@ -760,14 +760,14 @@ MobileCallInstance.prototype.multiConnect =\nreturn callback('Platform does not support multiConnect');\n}\n- if (!uuidValidator(peerIdentifier)) {\n- callback(null);\n- return multiConnectResolvedCallbackHandler(syncValue, 'Illegal peerID');\n+ if (typeof syncValue !== 'string') {\n+ callback('Bad parameters');\n+ return;\n}\n- if (typeof syncValue !== 'string') {\n+ if (!uuidValidator(peerIdentifier)) {\ncallback(null);\n- return multiConnectResolvedCallbackHandler(syncValue, 'Bad parameters');\n+ return multiConnectResolvedCallbackHandler(syncValue, 'Illegal peerID');\n}\n// The immediate return just says we got the request.\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNative.js",
"new_path": "thali/NextGeneration/thaliMobileNative.js",
"diff": "* on the correlated {@link multiConnectResolved} callback for the result of\n* this particular method call.\n* @param {module:thaliMobileNative~ThaliMobileCallback} callback The err value\n- * MUST be null unless this is not a platform that supports multiconnect in\n- * which case an error object MUST be returned with the value \"Platform does not\n- * support multiConnect\". Other than the platform not supported error any other\n- * errors will be returned in the {@link multiConnectResolved} callback.\n+ * MUST be null unless native layer cannot parse and process passed parameters\n+ * in which case a \"Bad parameters\" error MUST be returned, or unless this is\n+ * not a platform that supports multiconnect in which case an error object MUST\n+ * be returned with the value \"Platform does not support multiConnect\". Any\n+ * other errors will be returned in the {@link multiConnectResolved} callback.\n*/\n/* eslint-enable max-len */\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update multiConnect invalid syncValue handling. (#1756)
Update tests, update mobile mock, update spec
|
675,377 |
30.01.2017 09:03:21
| -3,600 |
b3084c7d25ee85404b562363b63271eabed8e1c0
|
Set android build tools to 25.0.2
|
[
{
"change_type": "MODIFY",
"old_path": "thali/package.json",
"new_path": "thali/package.json",
"diff": "},\n\"androidConfig\": {\n\"minSdkVersion\": \"21\",\n- \"buildToolsVersion\": \"25.0.0\",\n+ \"buildToolsVersion\": \"25.0.2\",\n\"compileSdkVersion\": \"android-23\"\n},\n\"btconnectorlib2\": \"0.3.8-alpha\",\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Set android build tools to 25.0.2
|
675,373 |
31.01.2017 17:04:03
| -10,800 |
b3b02b33874060b0cb3cfe005afa95aaf404a7db
|
Add check if radio is on before starting the advertising and listening
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"new_path": "src/android/java/io/jxcore/node/JXcoreExtension.java",
"diff": "@@ -758,6 +758,9 @@ public class JXcoreExtension implements SurroundingStateObserver {\nfinal ArrayList<Object> args = new ArrayList<Object>();\nString errorString = null;\n+ if (!isRadioOn()) {\n+ errorString = \"Radio Turned Off\";\n+ } else {\nif (mConnectionHelper.getConnectivityMonitor().isBleMultipleAdvertisementSupported() !=\nBluetoothManager.FeatureSupportedStatus.NOT_SUPPORTED) {\nboolean succeededToStartOrWasAlreadyRunning =\n@@ -785,6 +788,7 @@ public class JXcoreExtension implements SurroundingStateObserver {\n} else {\nerrorString = \"No Native Non-TCP Support\";\n}\n+ }\nif (errorString != null) {\n// Failed straight away\n@@ -793,6 +797,10 @@ public class JXcoreExtension implements SurroundingStateObserver {\n}\n}\n+ private static boolean isRadioOn() {\n+ return mConnectionHelper.getConnectivityMonitor().isBluetoothEnabled();\n+ }\n+\n/**\n* Returns a string value matching the given RadioState enum value.\n*\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add check if radio is on before starting the advertising and listening
|
675,381 |
31.01.2017 11:15:03
| -10,800 |
ee4b025b4cef0b999412549a967a62cb046af58c
|
Update node-ssdp version
New version fixes callback invocation in the server's start method
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/package.json",
"new_path": "test/www/jxcore/package.json",
"diff": "\"minimist\": \"1.2.0\",\n\"multiplex\": \"6.7.0\",\n\"nock\": \"2.12.0\",\n- \"node-ssdp\": \"https://github.com/thaliproject/node-ssdp.git#caf1a75aa54fb47a9e51b72bf4c902c366536cbd\",\n+ \"node-ssdp\": \"https://github.com/thaliproject/node-ssdp.git#3a5909e201aee401f48965e378eb2ff0e2f9e027\",\n\"node-uuid\": \"1.4.7\",\n\"object-assign\": \"4.1.0\",\n\"pouchdb\": \"6.1.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/package.json",
"new_path": "thali/package.json",
"diff": "\"lie\": \"3.1.0\",\n\"long\": \"3.0.3\",\n\"multiplex\": \"6.7.0\",\n- \"node-ssdp\": \"https://github.com/thaliproject/node-ssdp.git#8feabedb80d054d354ea1fc6bd55045df65fd18f\",\n+ \"node-ssdp\": \"https://github.com/thaliproject/node-ssdp.git#3a5909e201aee401f48965e378eb2ff0e2f9e027\",\n\"object-assign\": \"4.1.0\",\n\"pouchdb-adapter-leveldb-core\": \"6.1.1\",\n\"request\": \"2.64.0\",\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update node-ssdp version
New version fixes callback invocation in the server's start method
|
675,381 |
31.01.2017 12:25:41
| -10,800 |
c83cb35bb6d6da387a7e0f332cdc3fd319505718
|
Implement radio errors in mock, fix tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "@@ -669,10 +669,23 @@ test('calls correct starts when network changes',\nreturn testUtils.ensureBluetooth(false);\n})\n.then(function () {\n- var listen =\n- thaliMobileNativeWrapper.startListeningForAdvertisements();\n- var advertise =\n- thaliMobileNativeWrapper.startUpdateAdvertisingAndListening();\n+ var validateStartResult = function (promise) {\n+ return promise\n+ .then(function () {\n+ t.fail('Should fail');\n+ })\n+ .catch(function (error) { // eslint-disable-line\n+ // TODO: enable when (if) #1767 is fixed\n+ // t.equals(error.message, 'Radio Turned Off',\n+ // 'specific error expected');\n+ });\n+ };\n+ var listen = validateStartResult(\n+ thaliMobileNativeWrapper.startListeningForAdvertisements()\n+ );\n+ var advertise = validateStartResult(\n+ thaliMobileNativeWrapper.startUpdateAdvertisingAndListening()\n+ );\nreturn Promise.all([ listen, advertise ]);\n})\n.then(function () {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/wifiBasedNativeMock.js",
"new_path": "test/www/jxcore/lib/wifiBasedNativeMock.js",
"diff": "@@ -278,6 +278,13 @@ MobileCallInstance.prototype.startListeningForAdvertisements =\nMobileCallInstance.prototype._startListeningForAdvertisements =\nfunction (callback) {\n+ var btOff =\n+ currentNetworkStatus.bluetooth !== 'on' ||\n+ currentNetworkStatus.bluetoothLowEnergy !== 'on';\n+ if (btOff) {\n+ callback('Radio Turned Off');\n+ return;\n+ }\nthis.thaliWifiInfrastructure.startListeningForAdvertisements()\n.then(function () {\nstartListeningForAdvertisementsIsActive = true;\n@@ -365,6 +372,13 @@ MobileCallInstance.prototype.startUpdateAdvertisingAndListening =\nMobileCallInstance.prototype._startUpdateAdvertisingAndListening =\nfunction (portNumber, callback) {\nvar self = this;\n+ var btOff =\n+ currentNetworkStatus.bluetooth !== 'on' ||\n+ currentNetworkStatus.bluetoothLowEnergy !== 'on';\n+ if (btOff) {\n+ callback('Radio Turned Off');\n+ return;\n+ }\nvar doStart = function () {\nself.thaliWifiInfrastructure.startUpdateAdvertisingAndListening()\n.then(function () {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Implement radio errors in mock, fix tests
|
675,381 |
30.01.2017 13:55:31
| -10,800 |
8cfecf071f7b01b92d4454f34a5cba1e6e643ecd
|
Restart ssdp server on bssid change
|
[
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -352,7 +352,6 @@ WifiAdvertiser.prototype.stop = function () {\n});\n};\n-\nWifiAdvertiser.prototype._errorStop = function (error) {\nthis._isAdvertising = false;\nthis.peer = null;\n@@ -645,18 +644,26 @@ inherits(ThaliWifiInfrastructure, EventEmitter);\nThaliWifiInfrastructure.prototype._handleNetworkChanges =\nfunction (networkStatus) {\n- var isWifiUnchanged = this._lastNetworkStatus &&\n- networkStatus.wifi === this._lastNetworkStatus.wifi;\n+ var isWifiChanged = this._lastNetworkStatus ?\n+ networkStatus.wifi !== this._lastNetworkStatus.wifi :\n+ true;\n+\n+ var isBssidChanged = this._lastNetworkStatus ?\n+ networkStatus.bssidName !== this._lastNetworkStatus.bssidName :\n+ true;\nthis._lastNetworkStatus = networkStatus;\n// If we are stopping or the wifi state hasn't changed,\n// we are not really interested.\n- if (!this._isStarted || isWifiUnchanged) {\n+ if (!this._isStarted || (!isWifiChanged && !isBssidChanged)) {\nreturn;\n}\nvar actionResults = [];\n+\n+ // Handle on -> off and off -> on changes\n+ if (isWifiChanged) {\nif (networkStatus.wifi === 'on') {\n// If the wifi state turned on, try to get into the target states\nif (this._isListening) {\n@@ -681,6 +688,18 @@ function (networkStatus) {\n)\n);\n}\n+ }\n+\n+ // Handle bssid only changes. We do not care about bssid when wifi was\n+ // entirely disabled, because node-ssdp server would be restarted anyway\n+ if (isBssidChanged && !isWifiChanged) {\n+ // Without restarting node-ssdp server just does not advertise messages\n+ // after disconnecting and then connecting again to the access point\n+ actionResults.push(\n+ muteRejection(this.advertiser.restartSSDPServer())\n+ );\n+ }\n+\nPromise.all(actionResults).then(function (results) {\nresults.forEach(function (result) {\nif (result) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Restart ssdp server on bssid change
|
675,381 |
01.02.2017 14:26:01
| -10,800 |
b2af177be45ba7ec65a37b62666c999e248fb9f2
|
Add SSDP server restart test
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"new_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"diff": "@@ -10,6 +10,11 @@ var ThaliMobile = require('thali/NextGeneration/thaliMobile');\nvar ThaliMobileNativeWrapper = require('thali/NextGeneration/thaliMobileNativeWrapper');\nvar ThaliWifiInfrastructure = require('thali/NextGeneration/thaliWifiInfrastructure');\n+var networkTypes = ThaliMobile.networkTypes;\n+\n+function pskIdToSecret () {\n+ return null;\n+}\nvar test = tape({\nsetup: function (t) {\n@@ -23,22 +28,17 @@ var test = tape({\ntest(\n'ssdp server should be restarted when wifi toggled',\nfunction () {\n- return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n+ return global.NETWORK_TYPE !== networkTypes.WIFI;\n},\nfunction (t) {\n- var pskId = 'I am an id';\n- var pskKey = new Buffer('I am a secret');\n-\n- function pskIdToSecret (id) {\n- return id === pskId ? pskKey : null;\n- };\n-\nfunction toggleWifi(value) {\nThaliMobileNativeWrapper.emitter.emit('networkChangedNonTCP', {\nwifi: value? 'on' : 'off',\nbluetooth: 'on',\nbluetoothLowEnergy: 'on',\n- cellular: 'on'\n+ cellular: 'on',\n+ bssidName: '00:00:00:00:00:00',\n+ ssidName: 'WiFi Network'\n});\n}\n@@ -84,3 +84,75 @@ test(\n});\n}\n);\n+\n+test(\n+ 'ssdp server should be restarted when bssid changed',\n+ function () {\n+ return global.NETWORK_TYPE !== networkTypes.WIFI;\n+ },\n+ function (t) {\n+ function changeBssid (value) {\n+ ThaliMobileNativeWrapper.emitter.emit('networkChangedNonTCP', {\n+ wifi: 'on',\n+ bluetooth: 'on',\n+ bluetoothLowEnergy: 'on',\n+ cellular: 'on',\n+ bssidName: value,\n+ ssidName: (value === null) ? null : 'WiFi Network'\n+ });\n+ }\n+\n+ var wifiInfrastructure = new ThaliWifiInfrastructure();\n+ var ssdpServer = wifiInfrastructure._getSSDPServer();\n+ var startStub = sinon.stub(ssdpServer, 'start', function (cb) {\n+ cb();\n+ });\n+ var stopStub = sinon.stub(ssdpServer, 'stop', function (cb) {\n+ cb();\n+ });\n+\n+ function testBssidChangeReaction (newBssid) {\n+ // reset call counts\n+ startStub.reset();\n+ stopStub.reset();\n+ return new Promise(function (resolve) {\n+ changeBssid(newBssid);\n+ setImmediate(function () {\n+ t.equal(stopStub.callCount, 1, 'start called once');\n+ t.equal(startStub.callCount, 1, 'start called once');\n+ resolve();\n+ });\n+ });\n+ }\n+\n+ wifiInfrastructure.start(express.Router(), pskIdToSecret)\n+ .then(function () {\n+ return wifiInfrastructure.startUpdateAdvertisingAndListening();\n+ })\n+ .then(function () {\n+ // bssid -> null\n+ return testBssidChangeReaction(null);\n+ })\n+ .then(function () {\n+ // null -> bssid\n+ return testBssidChangeReaction('00:00:00:00:00:00');\n+ })\n+ .then(function () {\n+ // bssid -> another bssid\n+ return testBssidChangeReaction('11:11:11:11:11:11');\n+ })\n+ .then(function () {\n+ return wifiInfrastructure.stop();\n+ })\n+ .catch(function (error) {\n+ t.fail('Test failed:' + error.message + '. ' + error.stack);\n+ })\n+ .then(function () {\n+ t.ok(!wifiInfrastructure._getCurrentState().started,\n+ 'should not be in started state');\n+ startStub.restore();\n+ stopStub.restore();\n+ t.end();\n+ });\n+ }\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -352,6 +352,11 @@ WifiAdvertiser.prototype.stop = function () {\n});\n};\n+/**\n+ * @private\n+ * @param {Error} error\n+ * @return {Promise}\n+ */\nWifiAdvertiser.prototype._errorStop = function (error) {\nthis._isAdvertising = false;\nthis.peer = null;\n@@ -360,6 +365,9 @@ WifiAdvertiser.prototype._errorStop = function (error) {\n});\n};\n+/**\n+ * @return {Promise}\n+ */\nWifiAdvertiser.prototype.restartSSDPServer = function () {\nvar self = this;\nreturn self._server.stopAsync().then(function () {\n@@ -441,6 +449,10 @@ WifiAdvertiser.prototype._setUpExpressApp = function (router, pskIdToSecret) {\n});\n};\n+/**\n+ * @private\n+ * @return {Promise}\n+ */\nWifiAdvertiser.prototype._destroyExpressApp = function () {\nvar self = this;\nvar promise;\n@@ -692,7 +704,7 @@ function (networkStatus) {\n// Handle bssid only changes. We do not care about bssid when wifi was\n// entirely disabled, because node-ssdp server would be restarted anyway\n- if (isBssidChanged && !isWifiChanged) {\n+ if (!isWifiChanged && isBssidChanged) {\n// Without restarting node-ssdp server just does not advertise messages\n// after disconnecting and then connecting again to the access point\nactionResults.push(\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add SSDP server restart test
|
675,373 |
01.02.2017 17:53:37
| -10,800 |
c47ddeba2199749151e0ec93aa315b772bdabd5b
|
Update jxcore to 0.3.1.9
|
[
{
"change_type": "MODIFY",
"old_path": "readme.md",
"new_path": "readme.md",
"diff": "@@ -317,14 +317,14 @@ Download [Xcode 6](https://developer.apple.com/xcode/), or later.\n### Install latest JXCore\n-The installation guide for JXCore 3.1.8 on Mac OS and Windows can be found [here](https://github.com/thaliproject/jxbuild/blob/master/distribute.md).\n+The installation guide for JXCore 3.1.9 on Mac OS and Windows can be found [here](https://github.com/thaliproject/jxbuild/blob/master/distribute.md).\n-The latest version of JXCore 3.1.8 only for Mac OS can be downloaded from [here](https://jxcore.blob.core.windows.net/jxcore-release/jxcore/0318/release/jx_osx64v8.zip)\n+The latest version of JXCore 3.1.9 only for Mac OS can be downloaded from [here](https://jxcore.blob.core.windows.net/jxcore-release/jxcore/0319/release/jx_osx64v8.zip)\nTo check the version of the current JXCore installation run:\n```\n$ jx -jxv\n-v 0.3.1.8\n+v 0.3.1.9\n```\n### Install Cordova\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/package.json",
"new_path": "thali/package.json",
"diff": "\"compileSdkVersion\": \"android-23\"\n},\n\"btconnectorlib2\": \"0.3.8-alpha\",\n- \"jxcore-cordova\": \"0.1.8\",\n- \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.8/release/io.jxcore.node.jx\"\n+ \"jxcore-cordova\": \"0.1.9\",\n+ \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.9/release/io.jxcore.node.jx\"\n},\n\"scripts\": {\n\"prepublish\": \"node install/prePublishThaliCordovaPlugin.js\",\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update jxcore to 0.3.1.9
|
675,381 |
02.02.2017 18:40:35
| -10,800 |
98b4517e1f555420433526f1da5f69c057d2e2ba
|
Do not restart ssdp client and server if they are stopped
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"new_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"diff": "@@ -104,12 +104,6 @@ test(\n}\n);\n-test(\n- 'ssdp server and client should be restarted when bssid changed',\n- function () {\n- return global.NETWORK_TYPE !== networkTypes.WIFI;\n- },\n- function (t) {\nfunction changeBssid (value) {\nThaliMobileNativeWrapper.emitter.emit('networkChangedNonTCP', {\nwifi: 'on',\n@@ -121,6 +115,12 @@ test(\n});\n}\n+test(\n+ 'ssdp server and client should be restarted when bssid changed',\n+ function () {\n+ return global.NETWORK_TYPE !== networkTypes.WIFI;\n+ },\n+ function (t) {\nvar wifiInfrastructure = new ThaliWifiInfrastructure();\nvar ssdpServer = wifiInfrastructure._getSSDPServer();\nvar ssdpClient = wifiInfrastructure._getSSDPClient();\n@@ -155,6 +155,64 @@ test(\n.then(function () {\nreturn wifiInfrastructure.startUpdateAdvertisingAndListening();\n})\n+ .then(function () {\n+ return wifiInfrastructure.startListeningForAdvertisements();\n+ })\n+ .then(function () {\n+ // bssid -> null\n+ return testBssidChangeReaction(null);\n+ })\n+ .then(function () {\n+ // null -> bssid\n+ return testBssidChangeReaction('00:00:00:00:00:00');\n+ })\n+ .then(function () {\n+ // bssid -> another bssid\n+ return testBssidChangeReaction('11:11:11:11:11:11');\n+ })\n+ .then(function () {\n+ return wifiInfrastructure.stop();\n+ })\n+ .catch(function (error) {\n+ t.fail('Test failed:' + error.message + '. ' + error.stack);\n+ })\n+ .then(function () {\n+ t.ok(!wifiInfrastructure._getCurrentState().started,\n+ 'should not be in started state');\n+ t.end();\n+ });\n+ }\n+);\n+\n+test(\n+ 'ssdp server and client should be restarted only when ' +\n+ 'advertising/listening is active',\n+ function () {\n+ return global.NETWORK_TYPE !== networkTypes.WIFI;\n+ },\n+ function (t) {\n+ var wifiInfrastructure = new ThaliWifiInfrastructure();\n+ var ssdpServer = wifiInfrastructure._getSSDPServer();\n+ var ssdpClient = wifiInfrastructure._getSSDPClient();\n+ var serverStartStub = sandbox.stub(ssdpServer, 'start', callArg);\n+ var serverStopStub = sandbox.stub(ssdpServer, 'stop', callArg);\n+ var clientStartStub = sandbox.stub(ssdpClient, 'start', callArg);\n+ var clientStopStub = sandbox.stub(ssdpClient, 'stop', callArg);\n+\n+ function testBssidChangeReaction (newBssid) {\n+ return new Promise(function (resolve) {\n+ changeBssid(newBssid);\n+ setImmediate(function () {\n+ t.equal(serverStartStub.callCount, 0, 'server start never called');\n+ t.equal(serverStopStub.callCount, 0, 'server stop never called');\n+ t.equal(clientStartStub.callCount, 0, 'client start never called');\n+ t.equal(clientStopStub.callCount, 0, 'client start never called');\n+ resolve();\n+ });\n+ });\n+ }\n+\n+ wifiInfrastructure.start(express.Router(), pskIdToSecret)\n.then(function () {\n// bssid -> null\nreturn testBssidChangeReaction(null);\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -202,6 +202,9 @@ WifiListener.prototype._errorStop = function (error) {\n*/\nWifiListener.prototype.restartSSDPClient = function () {\nvar self = this;\n+ if (!self._isListening) {\n+ return Promise.reject(new Error('Can\\'t restart stopped SSDP client'));\n+ }\nreturn self._client.stopAsync().then(function () {\nreturn self._client.startAsync();\n}).catch(function (error) {\n@@ -395,6 +398,9 @@ WifiAdvertiser.prototype._errorStop = function (error) {\n*/\nWifiAdvertiser.prototype.restartSSDPServer = function () {\nvar self = this;\n+ if (!self._isAdvertising) {\n+ return Promise.reject(new Error('Can\\'t restart stopped SSDP server'));\n+ }\nreturn self._server.stopAsync().then(function () {\nreturn self._server.startAsync();\n}).catch(function (error) {\n@@ -732,10 +738,12 @@ function (networkStatus) {\nif (!isWifiChanged && isBssidChanged) {\n// Without restarting node-ssdp server just does not advertise messages and\n// client does not receive them after connecting to another access point\n- actionResults.push(\n- muteRejection(this.advertiser.restartSSDPServer()),\n- muteRejection(this.listener.restartSSDPClient())\n- );\n+ if (this.advertiser.isAdvertising()) {\n+ actionResults.push(muteRejection(this.advertiser.restartSSDPServer()));\n+ }\n+ if (this.listener.isListening()) {\n+ actionResults.push(muteRejection(this.listener.restartSSDPClient()));\n+ }\n}\nPromise.all(actionResults).then(function (results) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Do not restart ssdp client and server if they are stopped
|
675,381 |
08.02.2017 16:08:55
| -10,800 |
31c49c3810e6f10213fbccd94e1231521730fa28
|
Update forever-agent to the newest version
Fixes and
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/package.json",
"new_path": "test/www/jxcore/package.json",
"diff": "\"concat-map\": \"0.0.1\",\n\"express\": \"4.13.3\",\n\"express-pouchdb\": \"1.0.6-thali\",\n- \"forever-agent\": \"https://github.com/thaliproject/forever-agent.git#f1078b5095dfe00ad0d80779eba75e563b54608b\",\n+ \"forever-agent\": \"https://github.com/thaliproject/forever-agent.git#f9a92c7a1b7ce4da849beca32b0ec2aeb855e0fd\",\n\"fs-extra-promise\": \"0.4.0\",\n\"inherits\": \"2.0.1\",\n\"is-property\": \"1.0.2\",\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/package.json",
"new_path": "thali/package.json",
"diff": "\"bluebird\": \"3.4.6\",\n\"body-parser\": \"1.13.3\",\n\"express\": \"4.13.3\",\n- \"forever-agent\": \"https://github.com/thaliproject/forever-agent.git#f1078b5095dfe00ad0d80779eba75e563b54608b\",\n+ \"forever-agent\": \"https://github.com/thaliproject/forever-agent.git#f9a92c7a1b7ce4da849beca32b0ec2aeb855e0fd\",\n\"ip\": \"1.0.1\",\n\"javascript-state-machine\": \"2.3.5\",\n\"lie\": \"3.1.0\",\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update forever-agent to the newest version (#1777)
Fixes #1771 and #1744
|
675,381 |
09.02.2017 14:19:27
| -10,800 |
29f0ec82551f4fb37b7a6bfc44ee97a2e408cd56
|
Add logging. Update waiting logic
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js",
"new_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js",
"diff": "@@ -53,6 +53,13 @@ var test = tape({\nteardownTimeout: 3 * 60 * 1000\n});\n+function log() {\n+ var prefix = new Date().toISOString().replace(/[TZ]/g, ' ') + 'TMC-DEBUG:';\n+ var args = Array.prototype.slice.call(arguments);\n+ args.unshift(prefix);\n+ return console.log.apply(console, args);\n+}\n+\n/**\n* Deterministically transforms a PouchDB doc to a string so we can compare\n* docs for equality.\n@@ -134,6 +141,13 @@ function waitForRemoteDocs(pouchDB, docsToFind) {\nerror = err;\ncomplete();\n});\n+\n+ var originalEmit = changesFeed.emit;\n+ changesFeed.emit = function () {\n+ var args = Array.prototype.slice.call(arguments);\n+ log('Changes feed emits:', args);\n+ return originalEmit.apply(this, args);\n+ };\n});\n}\n@@ -187,7 +201,17 @@ test('test write', function (t) {\n});\n});\n-test('test repeat write 1', function (t) {\n+function assignTestFields(i, target) {\n+ for (var j = 1; j <= i; j++) {\n+ target['test' + j] = true;\n+ }\n+ return target;\n+}\n+\n+function testRepeatWrite(i) {\n+ var name = 'test repeat write ' + i;\n+\n+ test(name, function (t) {\nvar partnerKeys = testUtils.turnParticipantsIntoBufferArray(\nt, publicKeyForLocalDevice\n);\n@@ -195,56 +219,27 @@ test('test repeat write 1', function (t) {\n// We are using an old db for each participant.\nvar pouchDB = new PouchDB(DB_NAME);\n- // We are getting our previous doc from a local db.\n- // It should consist of it's public key (base64 representation)\n- // and 1 test boolean.\n- var localDoc;\n- thaliManager.start(partnerKeys)\n- .then(function () {\n- return pouchDB.get(publicBase64KeyForLocalDevice);\n- })\n- .then(function (response) {\n- localDoc = response;\n- })\n- .then(function () {\n- // Lets update our doc with new boolean.\n- localDoc.test2 = true;\n- return pouchDB.put(localDoc)\n- .then(function (response) {\n- localDoc._rev = response.rev;\n- });\n- })\n- .then(function () {\n// Our partners should update its docs the same way.\nvar oldDocs = partnerKeys.map(function (partnerKey) {\n- return {\n+ return assignTestFields(i, {\n_id: partnerKey.toString('base64'),\n- test1: true\n- };\n});\n- var newDocs = partnerKeys.map(function (partnerKey) {\n- return {\n- _id: partnerKey.toString('base64'),\n- test1: true,\n- test2: true\n- };\n});\n- var docs = oldDocs.concat(newDocs);\n- docs.push(localDoc);\n- return waitForRemoteDocs(pouchDB, docs);\n- })\n- .then(function () {\n- t.end();\n+ var newDocs = partnerKeys.map(function (partnerKey) {\n+ return assignTestFields(i + 1, {\n+ _id: partnerKey.toString('base64')\n});\n});\n+ var docs = oldDocs.concat(newDocs);\n+ docs.push(assignTestFields(i + 1, {\n+ _id: publicBase64KeyForLocalDevice,\n+ }));\n+ docs.push(assignTestFields(i, {\n+ _id: publicBase64KeyForLocalDevice,\n+ }));\n-test('test repeat write 2', function (t) {\n- var partnerKeys = testUtils.turnParticipantsIntoBufferArray(\n- t, publicKeyForLocalDevice\n- );\n-\n- // We are using an old db for each participant.\n- var pouchDB = new PouchDB(DB_NAME);\n+ log('Create waiter for docs:', docs);\n+ var waiter = waitForRemoteDocs(pouchDB, docs);\n// We are getting our previous doc from a local db.\n// It should consist of it's public key (base64 representation)\n@@ -252,41 +247,48 @@ test('test repeat write 2', function (t) {\nvar localDoc;\nthaliManager.start(partnerKeys)\n.then(function () {\n+ t.pass('ThaliManager started');\nreturn pouchDB.get(publicBase64KeyForLocalDevice);\n})\n.then(function (response) {\n+ t.pass('Got response');\nlocalDoc = response;\n- })\n- .then(function () {\n+ log('LOCAL DOC:', localDoc);\n+\n// Lets update our doc with new boolean.\n- localDoc.test3 = true;\n+ assignTestFields(i + 1, localDoc);\n+ log('PUTTING UPDATED LOCAL DOC:', localDoc);\nreturn pouchDB.put(localDoc)\n.then(function (response) {\n+ log('PUT SUCCESS. RESPONSE:', response);\nlocalDoc._rev = response.rev;\n});\n})\n.then(function () {\n- // Our partners should update its docs the same way.\n- var oldDocs = partnerKeys.map(function (partnerKey) {\n- return {\n- _id: partnerKey.toString('base64'),\n- test1: true,\n- test2: true\n- };\n- });\n- var newDocs = partnerKeys.map(function (partnerKey) {\n- return {\n- _id: partnerKey.toString('base64'),\n- test1: true,\n- test2: true,\n- test3: true\n- };\n- });\n- var docs = oldDocs.concat(newDocs)\n- docs.push(localDoc);\n- return waitForRemoteDocs(pouchDB, docs);\n+ t.pass('Put updated doc');\n+ log('Waiting for docs');\n+ return waiter;\n+ })\n+ .then(function () {\n+ t.pass('Got all docs');\n+ })\n+ .catch(function (error) {\n+ t.fail('Got error: ' + error.message);\n+ log(error);\n})\n.then(function () {\nt.end();\n});\n});\n+}\n+\n+testRepeatWrite(1);\n+testRepeatWrite(2);\n+testRepeatWrite(3);\n+testRepeatWrite(4);\n+testRepeatWrite(5);\n+testRepeatWrite(6);\n+testRepeatWrite(7);\n+testRepeatWrite(8);\n+testRepeatWrite(9);\n+testRepeatWrite(10);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add logging. Update waiting logic
|
675,381 |
09.02.2017 14:52:04
| -10,800 |
78851432be7bd28c9dbb1cf42fb6ea21e198aaf9
|
Increase replication action idle period
|
[
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js",
"new_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js",
"diff": "@@ -84,7 +84,7 @@ ThaliReplicationPeerAction.ACTION_TYPE = 'ReplicationAction';\n* @readonly\n* @type {number}\n*/\n-ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = 3;\n+ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = 15;\n/**\n* The number of milliseconds to wait between updating `_Local/<peer ID>` on the\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Increase replication action idle period
|
675,381 |
09.02.2017 18:23:01
| -10,800 |
ea489f2c92549c5871049b24947158d1f571906f
|
Disable iOS native specific tests in WiFi mode
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1921,7 +1921,10 @@ test('calls correct starts when network changes',\ntest('We properly fire peer unavailable and then available when ' +\n'connection fails on Android',\n-testUtils.skipOnIOS,\n+function () {\n+ return !(platform.isAndroid &&\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.NATIVE);\n+},\nfunction(t) {\nvar somePeerIdentifier = uuid.v4();\n@@ -2013,7 +2016,10 @@ function(t) {\ntest('We properly fire peer unavailable and then available when ' +\n'connection fails on iOS',\n-testUtils.skipOnAndroid,\n+function () {\n+ return !(platform.isIOS &&\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.NATIVE);\n+},\nfunction(t) {\nvar somePeerIdentifier = uuid.v4();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Disable iOS native specific tests in WiFi mode
|
675,381 |
10.02.2017 13:05:07
| -10,800 |
7716eff6a935123a6f09a74136ebed8e038d206c
|
Disable PouchDB checkpoints plugin tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testPouchDBCheckpointPlugin.js",
"new_path": "test/www/jxcore/bv_tests/testPouchDBCheckpointPlugin.js",
"diff": "@@ -39,7 +39,13 @@ var Doc = function () {\nthis._id = prefix + '-' + Date.now();\n};\n-test('Call of onCheckpointReached handler on a single db change', function (t) {\n+test('Call of onCheckpointReached handler on a single db change',\n+function () {\n+ // TODO: checkpoints plugin has race conditions. See #1741 PR for the\n+ // incomplete solution\n+ return true;\n+},\n+function (t) {\ndb.onCheckpointReached(function () {\nt.end();\n});\n@@ -48,6 +54,11 @@ test('Call of onCheckpointReached handler on a single db change', function (t) {\n});\ntest('Call of multiple onCheckpointReached handlers on a single db change',\n+function () {\n+ // TODO: checkpoints plugin has race conditions. See #1741 PR for the\n+ // incomplete solution\n+ return true;\n+},\nfunction (t) {\nvar spy = sinon.spy();\nvar anotherSpy = sinon.spy();\n@@ -76,7 +87,13 @@ function (t) {\n});\ntest('Call of onCheckpointReached handler on multiple db changes ' +\n-'that are in the checkpoints plugin delay interval', function (t) {\n+'that are in the checkpoints plugin delay interval',\n+function () {\n+ // TODO: checkpoints plugin has race conditions. See #1741 PR for the\n+ // incomplete solution\n+ return true;\n+},\n+function (t) {\nvar ENSURE_DELAY = 1000;\nvar spy = sinon.spy();\n@@ -103,7 +120,13 @@ test('Call of onCheckpointReached handler on multiple db changes ' +\n});\ntest('Call of onCheckpointReached handler on multiple db changes ' +\n- 'that are out of the checkpoints plugin delay interval', function (t) {\n+'that are out of the checkpoints plugin delay interval',\n+function () {\n+ // TODO: checkpoints plugin has race conditions. See #1741 PR for the\n+ // incomplete solution\n+ return true;\n+},\n+function (t) {\nvar spy = sinon.spy();\nvar handler = function () {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Disable PouchDB checkpoints plugin tests
|
675,373 |
13.02.2017 11:31:10
| -10,800 |
2a9649bbcef57609375ecfc40e2b1406157ecf2a
|
Update jxcore to 0.3.1.10
|
[
{
"change_type": "MODIFY",
"old_path": "readme.md",
"new_path": "readme.md",
"diff": "@@ -317,14 +317,14 @@ Download [Xcode 6](https://developer.apple.com/xcode/), or later.\n### Install latest JXCore\n-The installation guide for JXCore 3.1.9 on Mac OS and Windows can be found [here](https://github.com/thaliproject/jxbuild/blob/master/distribute.md).\n+The installation guide for JXCore 3.1.10 on Mac OS and Windows can be found [here](https://github.com/thaliproject/jxbuild/blob/master/distribute.md).\n-The latest version of JXCore 3.1.9 only for Mac OS can be downloaded from [here](https://jxcore.blob.core.windows.net/jxcore-release/jxcore/0319/release/jx_osx64v8.zip)\n+The latest version of JXCore 3.1.10 only for Mac OS can be downloaded from [here](https://jxcore.blob.core.windows.net/jxcore-release/jxcore/03110/release/jx_osx64v8.zip)\nTo check the version of the current JXCore installation run:\n```\n$ jx -jxv\n-v 0.3.1.9\n+v 0.3.1.10\n```\n### Install Cordova\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/package.json",
"new_path": "thali/package.json",
"diff": "\"compileSdkVersion\": \"android-23\"\n},\n\"btconnectorlib2\": \"0.3.9\",\n- \"jxcore-cordova\": \"0.1.9\",\n- \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.9/release/io.jxcore.node.jx\"\n+ \"jxcore-cordova\": \"0.1.10\",\n+ \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.10/release/io.jxcore.node.jx\"\n},\n\"scripts\": {\n\"prepublish\": \"node install/prePublishThaliCordovaPlugin.js\",\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update jxcore to 0.3.1.10
|
675,381 |
13.02.2017 18:01:44
| -10,800 |
b75019cda7041fd2294906fc01e6f752a04ceb46
|
Fix race conditions. Code cleanup
Fix most of the race conditions by wrapping public methods into
`PromiseQueue#enqueue`.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -732,7 +732,7 @@ test('network changes are ignored while stopping', function (t) {\n})\n.then(function (networkStatus) {\nrealNetworkStatus = networkStatus;\n- wifiInfrastructure._isStarted = false;\n+ wifiInfrastructure.stop();\nspy = sinon.spy(wifiInfrastructure, 'startListeningForAdvertisements');\nThaliMobileNativeWrapper.emitter\n.emit('networkChangedNonTCP', wifiOffNetworkStatus);\n@@ -741,8 +741,7 @@ test('network changes are ignored while stopping', function (t) {\nreturn Promise.delay(0);\n}).then(function () {\nt.equals(spy.callCount, 0, 'should not be called');\n- wifiInfrastructure.startListeningForAdvertisements.restore();\n- wifiInfrastructure._isStarted = true;\n+ spy.restore();\nt.end();\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -19,6 +19,10 @@ var makeIntoCloseAllServer = require('./makeIntoCloseAllServer');\nvar PromiseQueue = require('./promiseQueue');\nvar USN = require('./utils/usn');\nvar platform = require('./utils/platform');\n+var common = require('./utils/common');\n+\n+var enqueued = common.enqueuedMethod;\n+var enqueuedAtTop = common.enqueuedAtTopMethod;\nvar muteRejection = (function () {\nfunction returnNull () { return null; }\n@@ -54,6 +58,9 @@ var muteRejection = (function () {\n* @class WifiListener\n*/\nfunction WifiListener() {\n+ EventEmitter.call(this);\n+\n+ this._promiseQueue = new PromiseQueue();\nthis._isListening = false;\nthis._filterMessageFn = null;\n@@ -89,6 +96,20 @@ WifiListener.prototype.setMessageFilter = function (filterFn) {\nthis._filterMessageFn = filterFn;\n};\n+/**\n+ * Function used to filter out SSDP messages that are not relevant for Thali.\n+ * @private\n+ * @param {Object} data SSDP message object\n+ * @return {boolean}\n+ */\n+WifiListener.prototype._shouldBeIgnored = function (data) {\n+ var isUnknownNt = (data.NT !== thaliConfig.SSDP_NT);\n+ var isFilteredMessage = this._filterMessageFn ?\n+ !this._filterMessageFn(data) :\n+ false;\n+ return (isUnknownNt || isFilteredMessage);\n+};\n+\n/**\n* @private\n* @param {Object} data\n@@ -131,76 +152,51 @@ WifiListener.prototype._handleMessage = function (data, available) {\nreturn true;\n};\n-/**\n- * Function used to filter out SSDP messages that are not relevant for Thali.\n- * @private\n- * @param {Object} data\n- * @return {boolean}\n- */\n-WifiListener.prototype._shouldBeIgnored = function (data) {\n- var isUnknownNt = (data.NT !== thaliConfig.SSDP_NT);\n- var isFilteredMessage = this._filterMessageFn ?\n- !this._filterMessageFn(data) :\n- false;\n- return (isUnknownNt || isFilteredMessage);\n-};\n-\n/**\n* @return {Promise}\n*/\n-WifiListener.prototype.start = function () {\n+WifiListener.prototype.start = enqueued(function () {\nvar self = this;\n+\nif (self._isListening) {\nreturn Promise.resolve();\n}\n- self._isListening = true;\nreturn self._client.startAsync()\n.then(function () {\n+ self._isListening = true;\nself._notifyStateChange();\nif (platform.isAndroid) {\nreturn thaliMobileNativeWrapper.lockAndroidWifiMulticast();\n}\n})\n.catch(function (error) {\n- self._errorStop(error);\n+ return self._errorStop(error);\n+ });\n});\n-};\n/**\n* @return {Promise}\n*/\n-WifiListener.prototype.stop = function () {\n+WifiListener.prototype.stop = enqueued(function () {\nvar self = this;\nif (!self._isListening) {\nreturn Promise.resolve();\n}\n- self._isListening = false;\nreturn self._client.stopAsync().then(function () {\n+ self._isListening = false;\nself._notifyStateChange();\nif (platform.isAndroid) {\nreturn thaliMobileNativeWrapper.unlockAndroidWifiMulticast();\n}\n});\n-};\n-\n-/**\n- * @private\n- * @param {Error} error\n- * @return {Promise}\n- */\n-WifiListener.prototype._errorStop = function (error) {\n- this._isListening = false;\n- return this._client.stopAsync().then(function () {\n- return Promise.reject(error);\n});\n-};\n/**\n* @return {Promise}\n*/\n-WifiListener.prototype.restartSSDPClient = function () {\n+WifiListener.prototype.restartSSDPClient = enqueuedAtTop(function () {\nvar self = this;\nif (!self._isListening) {\nreturn Promise.reject(new Error('Can\\'t restart stopped SSDP client'));\n@@ -210,6 +206,27 @@ WifiListener.prototype.restartSSDPClient = function () {\n}).catch(function (error) {\nreturn self._errorStop(error);\n});\n+});\n+\n+/**\n+ * Cleans everything after receiving error\n+ * @private\n+ * @param {Error} error Encountered error. Returned promise is rejected with\n+ * this value\n+ * @return {Promise<Error>}\n+ */\n+WifiListener.prototype._errorStop = function (error) {\n+ this._isListening = false;\n+ return this._client.stopAsync().then(function () {\n+ return thaliMobileNativeWrapper.unlockAndroidWifiMulticast()\n+ .catch(function () {\n+ // Ignore native errors during cleanup. We are more interested in the\n+ // original error\n+ return null;\n+ });\n+ }).then(function () {\n+ return Promise.reject(error);\n+ });\n};\n/**\n@@ -235,6 +252,7 @@ WifiListener.prototype.isListening = function () {\nfunction WifiAdvertiser () {\nEventEmitter.call(this);\n+ this._promiseQueue = new PromiseQueue();\nthis.peer = null;\n// Store previously used own peerIdentifiers so ssdp client can ignore some\n// delayed ssdp messages after our server has changed uuid part of usn\n@@ -304,12 +322,11 @@ WifiAdvertiser.prototype.isAdvertising = function () {\n* @param {module:thaliMobileNativeWrapper~pskIdToSecret} pskIdToSecret\n* @return {Promise}\n*/\n-WifiAdvertiser.prototype.start = function (router, pskIdToSecret) {\n+WifiAdvertiser.prototype.start = enqueued(function (router, pskIdToSecret) {\nvar self = this;\nif (self._isAdvertising) {\nreturn Promise.reject(new Error('Call Stop!'));\n}\n- self._isAdvertising = true;\nself._generateAdvertisingPeer();\nreturn self._setUpExpressApp(router, pskIdToSecret)\n@@ -317,12 +334,13 @@ WifiAdvertiser.prototype.start = function (router, pskIdToSecret) {\nreturn self._startPeerAdvertising(self.peer);\n})\n.then(function () {\n+ self._isAdvertising = true;\nself._notifyStateChange();\n})\n.catch(function (error) {\nreturn self._errorStop(error);\n});\n-};\n+});\n/**\n* @param {Object} peer\n@@ -339,7 +357,7 @@ WifiAdvertiser.prototype._startPeerAdvertising = function (peer) {\n/**\n* @return {Promise}\n*/\n-WifiAdvertiser.prototype.update = function () {\n+WifiAdvertiser.prototype.update = enqueued(function () {\nvar self = this;\nif (!self._isAdvertising) {\n@@ -356,26 +374,26 @@ WifiAdvertiser.prototype.update = function () {\n.catch(function (error) {\nreturn self._errorStop(error);\n});\n-};\n+});\n/**\n* @return {Promise}\n*/\n-WifiAdvertiser.prototype.stop = function () {\n+WifiAdvertiser.prototype.stop = enqueued(function () {\nvar self = this;\nif (!self._isAdvertising) {\nreturn Promise.resolve();\n}\n- self._isAdvertising = false;\nreturn self._server.stopAsync().then(function () {\n- self.peer = null;\nreturn self._destroyExpressApp();\n}).then(function () {\n+ self.peer = null;\n+ self._isAdvertising = false;\nself._notifyStateChange();\n});\n-};\n+});\n/**\n* @private\n@@ -396,7 +414,7 @@ WifiAdvertiser.prototype._errorStop = function (error) {\n/**\n* @return {Promise}\n*/\n-WifiAdvertiser.prototype.restartSSDPServer = function () {\n+WifiAdvertiser.prototype.restartSSDPServer = enqueuedAtTop(function () {\nvar self = this;\nif (!self._isAdvertising) {\nreturn Promise.reject(new Error('Can\\'t restart stopped SSDP server'));\n@@ -406,7 +424,7 @@ WifiAdvertiser.prototype.restartSSDPServer = function () {\n}).catch(function (error) {\nreturn self._errorStop(error);\n});\n-};\n+});\n/**\n* @private\n@@ -629,13 +647,15 @@ WifiAdvertiser.prototype.getAdvertisedPeerIdentifiers = function () {\n* @fires discoveryAdvertisingStateUpdateWifiEvent\n*/\nfunction ThaliWifiInfrastructure() {\n- // Represent target states (the state after promise queue is completed)\nthis._isStarted = false;\n- this._isAdvertising = false;\n- this._isListening = false;\n+ // Represent target states (the state after promise queue is completed)\n+ this._targetState = {\n+ started: false,\n+ advertising: false,\n+ listening: false\n+ };\nthis._promiseQueue = new PromiseQueue();\n-\nthis._lastNetworkStatus = null;\nvar advertiser = new WifiAdvertiser();\n@@ -656,7 +676,6 @@ function ThaliWifiInfrastructure() {\nThaliWifiInfrastructure.prototype._setUpEvents = function() {\nvar self = this;\n- var states = { advertising: false, listening: false };\n// bind networkChanged listener\nthis._networkChangedHandler = function (networkChangedValue) {\n@@ -665,18 +684,12 @@ ThaliWifiInfrastructure.prototype._setUpEvents = function() {\nvar emitStateUpdate = function () {\nself.emit('discoveryAdvertisingStateUpdateWifiEvent', {\n- discoveryActive: states.listening,\n- advertisingActive: states.advertising,\n+ discoveryActive: self.listener.isListening(),\n+ advertisingActive: self.advertiser.isAdvertising(),\n});\n};\n- self.advertiser.on('stateChange', function (newState) {\n- states.advertising = newState.advertising;\n- emitStateUpdate();\n- });\n- self.listener.on('stateChange', function (newState) {\n- states.listening = newState.listening;\n- emitStateUpdate();\n- });\n+ self.advertiser.on('stateChange', emitStateUpdate);\n+ self.listener.on('stateChange', emitStateUpdate);\nself.listener.on('wifiPeerAvailabilityChanged', function (peer) {\nself.emit('wifiPeerAvailabilityChanged', peer);\n@@ -699,7 +712,7 @@ function (networkStatus) {\n// If we are stopping or the wifi state hasn't changed,\n// we are not really interested.\n- if (!this._isStarted || (!isWifiChanged && !isBssidChanged)) {\n+ if (!this._targetState.started || (!isWifiChanged && !isBssidChanged)) {\nreturn;\n}\n@@ -709,12 +722,12 @@ function (networkStatus) {\nif (isWifiChanged) {\nif (networkStatus.wifi === 'on') {\n// If the wifi state turned on, try to get into the target states\n- if (this._isListening) {\n+ if (this._targetState.listening) {\nactionResults.push(\nmuteRejection(this.startListeningForAdvertisements())\n);\n}\n- if (this._isAdvertising) {\n+ if (this._targetState.advertising) {\nactionResults.push(\nmuteRejection(this.startUpdateAdvertisingAndListening())\n);\n@@ -756,46 +769,6 @@ function (networkStatus) {\n});\n};\n-ThaliWifiInfrastructure.prototype._getCurrentState = function () {\n- return {\n- started: this._isStarted,\n- listening: this.listener.isListening(),\n- advertising: this.advertiser.isAdvertising(),\n- };\n-};\n-\n-ThaliWifiInfrastructure.prototype._getTargetState = function () {\n- return {\n- started: this._isStarted,\n- listening: this._isListening,\n- advertising: this._isAdvertising,\n- };\n-};\n-\n-ThaliWifiInfrastructure.prototype._getCurrentPeer = function () {\n- return this.advertiser.peer;\n-};\n-\n-ThaliWifiInfrastructure.prototype._getSSDPServer = function () {\n- return this.advertiser._server;\n-};\n-\n-ThaliWifiInfrastructure.prototype._getSSDPClient = function () {\n- return this.listener._client;\n-};\n-\n-ThaliWifiInfrastructure.prototype._overrideAdvertisedPort = function (port) {\n- this.advertiser.advertisedPortOverride = port;\n-};\n-\n-ThaliWifiInfrastructure.prototype._restoreAdvertisedPort = function () {\n- this.advertiser.advertisedPortOverride = null;\n-};\n-\n-ThaliWifiInfrastructure.prototype._getOverridenAdvertisedPort = function () {\n- return this.advertiser.advertisedPortOverride;\n-};\n-\n/**\n* This method MUST be called before any other method here other than\n* registering for events on the emitter. This method only registers the router\n@@ -818,27 +791,31 @@ ThaliWifiInfrastructure.prototype._getOverridenAdvertisedPort = function () {\n* @returns {Promise<?Error>}\n*/\nThaliWifiInfrastructure.prototype.start = function (router, pskIdToSecret) {\n+ this._targetState.started = true;\n+ return this._enqueuedStart(router, pskIdToSecret);\n+};\n+\n+ThaliWifiInfrastructure.prototype._enqueuedStart =\n+enqueued(function (router, pskIdToSecret) {\nvar self = this;\nthaliMobileNativeWrapper.emitter\n.on('networkChangedNonTCP', self._networkChangedHandler);\n- if (this._isStarted) {\n+ if (self._isStarted) {\nreturn Promise.reject(new Error('Call Stop!'));\n}\n- this._isStarted = true;\n- return this._promiseQueue.enqueue(function (resolve, reject) {\n- thaliMobileNativeWrapper.getNonTCPNetworkStatus()\n+ return thaliMobileNativeWrapper\n+ .getNonTCPNetworkStatus()\n.then(function (networkStatus) {\nif (!self._lastNetworkStatus) {\nself._lastNetworkStatus = networkStatus;\n}\n+ self._isStarted = true;\nself._router = router;\nself._pskIdToSecret = pskIdToSecret;\n- })\n- .then(resolve, reject);\n});\n-};\n+});\n/**\n* This method will call all the stop methods and stop the TCP server hosting\n@@ -852,24 +829,25 @@ ThaliWifiInfrastructure.prototype.start = function (router, pskIdToSecret) {\n* @returns {Promise<?Error>}\n*/\nThaliWifiInfrastructure.prototype.stop = function () {\n- thaliMobileNativeWrapper.emitter\n- .removeListener('networkChangedNonTCP', this._networkChangedHandler);\n- this._lastNetworkStatus = null;\n+ this._targetState.started = false;\n+ this._targetState.advertising = false;\n+ this._targetState.listening = false;\n+ return this._enqueuedStop();\n+};\n- if (!this._isStarted) {\n- return Promise.resolve();\n- }\n- this._isStarted = false;\n- this._isAdvertising = false;\n- this._isListening = false;\n+ThaliWifiInfrastructure.prototype._enqueuedStop = enqueued(function () {\nvar self = this;\n- return this._promiseQueue.enqueue(function (resolve, reject) {\n- Promise.all([\n+ thaliMobileNativeWrapper.emitter\n+ .removeListener('networkChangedNonTCP', self._networkChangedHandler);\n+ self._lastNetworkStatus = null;\n+\n+ return Promise.all([\nself.advertiser.stop(),\nself.listener.stop()\n- ]).then(resolve, reject);\n+ ]).finally(function () {\n+ self._isStarted = false;\n+ });\n});\n-};\n/**\n* This will start the local Wi-Fi Infrastructure Mode discovery mechanism\n@@ -896,19 +874,20 @@ ThaliWifiInfrastructure.prototype.stop = function () {\n*/\nThaliWifiInfrastructure.prototype.startListeningForAdvertisements =\nfunction () {\n- var self = this;\n- self._isListening = true;\n- if (!self._isStarted) {\n+ this._targetState.listening = true;\n+ return this._enqueuedStartListeningForAdvertisements();\n+};\n+\n+ThaliWifiInfrastructure.prototype._enqueuedStartListeningForAdvertisements =\n+enqueued(function () {\n+ if (!this._isStarted) {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- return self._promiseQueue.enqueue(function (resolve, reject) {\n- if (self._lastNetworkStatus && self._lastNetworkStatus.wifi === 'off') {\n- self._rejectPerWifiState().then(resolve, reject);\n- return;\n+ if (this._lastNetworkStatus && this._lastNetworkStatus.wifi === 'off') {\n+ return this._rejectPerWifiState();\n}\n- self.listener.start().then(resolve, reject);\n+ return this.listener.start();\n});\n-};\n/**\n* This will stop the local Wi-Fi Infrastructure Mode discovery mechanism\n@@ -933,21 +912,17 @@ function () {\n*/\nThaliWifiInfrastructure.prototype.stopListeningForAdvertisements =\nfunction () {\n- this._isListening = false;\n+ this._targetState.listening = false;\n+ return this._enqueuedStopListeningForAdvertisements();\n+};\n- var listener = this.listener;\n- return this._promiseQueue.enqueue(function (resolve, reject) {\n- listener.stop().then(resolve, reject);\n+ThaliWifiInfrastructure.prototype._enqueuedStopListeningForAdvertisements =\n+enqueued(function () {\n+ return this.listener.stop();\n});\n-};\nThaliWifiInfrastructure.prototype._pauseListeningForAdvertisements =\n-function () {\n- var listener = this.listener;\n- return this._promiseQueue.enqueue(function (resolve, reject) {\n- listener.stop().then(resolve, reject);\n- });\n-};\n+ ThaliWifiInfrastructure.prototype._enqueuedStopListeningForAdvertisements;\n/**\n* This method will start advertising the peer's presence over the local Wi-Fi\n@@ -1014,27 +989,25 @@ function () {\n*/\nThaliWifiInfrastructure.prototype.startUpdateAdvertisingAndListening =\nfunction () {\n- var self = this;\n- var advertiser = self.advertiser;\n+ this._targetState.advertising = true;\n+ return this._enqueuedStartUpdateAdvertisingAndListening();\n+};\n- if (!self._isStarted) {\n+ThaliWifiInfrastructure.prototype._enqueuedStartUpdateAdvertisingAndListening =\n+enqueued(function () {\n+ if (!this._isStarted) {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- self._isAdvertising = true;\n-\n- return self._promiseQueue.enqueue(function (resolve, reject) {\n- if (self._lastNetworkStatus && self._lastNetworkStatus.wifi === 'off') {\n- self._rejectPerWifiState().then(resolve, reject);\n- return;\n+ if (this._lastNetworkStatus && this._lastNetworkStatus.wifi === 'off') {\n+ return this._rejectPerWifiState();\n}\n- var promise = advertiser.isAdvertising() ?\n- advertiser.update() :\n- advertiser.start(self._router, self._pskIdToSecret);\n- promise.then(resolve, reject);\n+ var advertiser = this.advertiser;\n+ return advertiser.isAdvertising() ?\n+ advertiser.update() :\n+ advertiser.start(this._router, this._pskIdToSecret);\n});\n-};\n/**\n* This method MUST stop advertising the peer's presence over the local Wi-Fi\n@@ -1051,20 +1024,17 @@ function () {\n* @returns {Promise<?Error>}\n*/\nThaliWifiInfrastructure.prototype.stopAdvertisingAndListening = function () {\n- this._isAdvertising = false;\n-\n- var advertiser = this.advertiser;\n- return this._promiseQueue.enqueue(function (resolve, reject) {\n- advertiser.stop().then(resolve, reject);\n- });\n+ this._targetState.advertising = false;\n+ return this._enqueuedStopAdvertisingAndListening();\n};\n-ThaliWifiInfrastructure.prototype._pauseAdvertisingAndListening = function () {\n- var advertiser = this.advertiser;\n- return this._promiseQueue.enqueue(function (resolve, reject) {\n- advertiser.stop().then(resolve, reject);\n+ThaliWifiInfrastructure.prototype._enqueuedStopAdvertisingAndListening =\n+enqueued(function () {\n+ return this.advertiser.stop();\n});\n-};\n+\n+ThaliWifiInfrastructure.prototype._pauseAdvertisingAndListening =\n+ ThaliWifiInfrastructure.prototype._enqueuedStopAdvertisingAndListening;\nThaliWifiInfrastructure.prototype._rejectPerWifiState = function () {\n@@ -1091,4 +1061,47 @@ ThaliWifiInfrastructure.prototype.getNetworkStatus = function () {\nreturn thaliMobileNativeWrapper.getNonTCPNetworkStatus();\n};\n+\n+// All the methods below are for testing\n+\n+ThaliWifiInfrastructure.prototype._getCurrentState = function () {\n+ return {\n+ started: this._isStarted,\n+ listening: this.listener.isListening(),\n+ advertising: this.advertiser.isAdvertising(),\n+ };\n+};\n+\n+ThaliWifiInfrastructure.prototype._getTargetState = function () {\n+ return {\n+ started: this._targetState.started,\n+ listening: this._targetState.listening,\n+ advertising: this._targetState.advertising,\n+ };\n+};\n+\n+ThaliWifiInfrastructure.prototype._getCurrentPeer = function () {\n+ return this.advertiser.peer;\n+};\n+\n+ThaliWifiInfrastructure.prototype._getSSDPServer = function () {\n+ return this.advertiser._server;\n+};\n+\n+ThaliWifiInfrastructure.prototype._getSSDPClient = function () {\n+ return this.listener._client;\n+};\n+\n+ThaliWifiInfrastructure.prototype._overrideAdvertisedPort = function (port) {\n+ this.advertiser.advertisedPortOverride = port;\n+};\n+\n+ThaliWifiInfrastructure.prototype._restoreAdvertisedPort = function () {\n+ this.advertiser.advertisedPortOverride = null;\n+};\n+\n+ThaliWifiInfrastructure.prototype._getOverridenAdvertisedPort = function () {\n+ return this.advertiser.advertisedPortOverride;\n+};\n+\nmodule.exports = ThaliWifiInfrastructure;\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/utils/common.js",
"new_path": "thali/NextGeneration/utils/common.js",
"diff": "'use strict';\n+var Promise = require('bluebird');\n+\n+/** @module utils/common */\n+\nmodule.exports.serializePouchError = function (err) {\nif (err) {\nreturn (err.status || '') + ' ' + (err.message || '');\n@@ -54,3 +58,60 @@ module.exports.makeAsync = function (fn) {\nsetImmediate(apply, this, arguments);\n};\n};\n+\n+/**\n+ * @private\n+ */\n+var enqueued = function (atTop, fn) {\n+ return function enqeuedMethod () {\n+ var self = this;\n+ var args = arguments;\n+ var method = atTop ? 'enqueueAtTop' : 'enqueue';\n+ return self._promiseQueue[method](function (resolve, reject) {\n+ var result = fn.apply(self, args);\n+ Promise.resolve(result).then(resolve, reject);\n+ });\n+ };\n+};\n+\n+/**\n+ * Wraps provided function into\n+ * {@link module:promiseQueue~PromiseQueue#enqueue}.\n+ *\n+ * It should be used only for methods and it expects that the class has\n+ * `_promiseQueue` property.\n+ *\n+ * Example:\n+ * ```\n+ * function WifiListener() {\n+ * this._promiseQueue = new PromiseQueue();\n+ * this._isStarted = false;\n+ * }\n+ *\n+ * WifiListener.prototype.start = enqueuedMethod(function () {\n+ * return this.performAsyncLogic().then(function () {\n+ * this._isStarted = true\n+ * }.bind(this));\n+ * });\n+ * ```\n+ *\n+ * @method\n+ * @static\n+ * @param {function} fn - function to wrap. MUST be either synchronous or return\n+ * a Promise\n+ * @returns {Promise}\n+ */\n+module.exports.enqueuedMethod = enqueued.bind(null, false);\n+\n+/**\n+ * The same as [enqueuedMethod]{@link module:utils/common.enqueuedMethod} but\n+ * uses [enqueueAtTop]{@link module:promiseQueue~PromiseQueue#enqueueAtTop}\n+ * instead.\n+ *\n+ * @method\n+ * @static\n+ * @param {function} fn - function to wrap. MUST be either synchronous or return\n+ * a Promise\n+ * @returns {Promise}\n+ */\n+module.exports.enqueuedAtTopMethod = enqueued.bind(null, true);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix race conditions. Code cleanup
Fix most of the race conditions by wrapping public methods into
`PromiseQueue#enqueue`.
|
675,373 |
15.02.2017 18:00:14
| -10,800 |
5403141246ec79c621da8f788a18c058e52908ae
|
Fix null pointer exception.
The initialization of the thread was moved before adding the thread to collection
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/ConnectionHelper.java",
"new_path": "src/android/java/io/jxcore/node/ConnectionHelper.java",
"diff": "@@ -674,12 +674,12 @@ public class ConnectionHelper\n}\nif (newOutgoingSocketThread != null) {\n- if (mConnectionModel.addConnectionThread(newOutgoingSocketThread)) {\n+ if (!mConnectionModel.contains(newOutgoingSocketThread)){\nlowerBleDiscoveryPowerAndStartResetTimer();\nnewOutgoingSocketThread.setUncaughtExceptionHandler(mThreadUncaughtExceptionHandler);\nnewOutgoingSocketThread.setPeerProperties(peerProperties);\n-\n+ mConnectionModel.addConnectionThread(newOutgoingSocketThread);\nnewOutgoingSocketThread.start();\nLog.i(TAG, \"onConnected: Outgoing socket thread, for peer \"\n@@ -689,6 +689,7 @@ public class ConnectionHelper\nConnectionManagerSettings.getInstance(mContext).setInsecureRfcommSocketPortNumber(\nConnectionManagerSettings.SYSTEM_DECIDED_INSECURE_RFCOMM_SOCKET_PORT);\n} else {\n+ Log.e(TAG, \"addConnectionThread: A matching thread for outgoing connection already exists\");\ntry {\nbluetoothSocket.close();\n} catch (IOException e) {\n@@ -786,18 +787,19 @@ public class ConnectionHelper\n}\nif (newIncomingSocketThread != null) {\n- if (mConnectionModel.addConnectionThread(newIncomingSocketThread)) {\n+ if (!mConnectionModel.contains(newIncomingSocketThread)){\nlowerBleDiscoveryPowerAndStartResetTimer();\nnewIncomingSocketThread.setUncaughtExceptionHandler(mThreadUncaughtExceptionHandler);\nnewIncomingSocketThread.setPeerProperties(peerProperties);\nnewIncomingSocketThread.setTcpPortNumber(mServerPortNumber);\n-\n+ mConnectionModel.addConnectionThread(newIncomingSocketThread);\nnewIncomingSocketThread.start();\nLog.i(TAG, \"onConnected: Incoming socket thread, for peer \"\n+ peerProperties + \", created successfully\");\n} else {\n+ Log.e(TAG, \"addConnectionThread: A matching thread for incoming connection already exists\");\ntry {\nbluetoothSocket.close();\n} catch (IOException e) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/ConnectionModel.java",
"new_path": "src/android/java/io/jxcore/node/ConnectionModel.java",
"diff": "@@ -13,9 +13,9 @@ import java.util.concurrent.CopyOnWriteArrayList;\n*/\npublic class ConnectionModel {\nprivate static final String TAG = ConnectionModel.class.getName();\n- private final CopyOnWriteArrayList<IncomingSocketThread> mIncomingSocketThreads = new CopyOnWriteArrayList<IncomingSocketThread>();\n- private final CopyOnWriteArrayList<OutgoingSocketThread> mOutgoingSocketThreads = new CopyOnWriteArrayList<OutgoingSocketThread>();\n- private final HashMap<String, JXcoreThaliCallback> mOutgoingConnectionCallbacks = new HashMap<String, JXcoreThaliCallback>();\n+ private final CopyOnWriteArrayList<IncomingSocketThread> mIncomingSocketThreads = new CopyOnWriteArrayList<>();\n+ private final CopyOnWriteArrayList<OutgoingSocketThread> mOutgoingSocketThreads = new CopyOnWriteArrayList<>();\n+ private final HashMap<String, JXcoreThaliCallback> mOutgoingConnectionCallbacks = new HashMap<>();\n/**\n* Constructor.\n@@ -147,12 +147,7 @@ public class ConnectionModel {\n* @return True, if the thread was successfully added to the collection. False otherwise.\n*/\npublic synchronized boolean addConnectionThread(IncomingSocketThread incomingSocketThread) {\n- if (!mIncomingSocketThreads.addIfAbsent(incomingSocketThread)) {\n- Log.e(TAG, \"addConnectionThread: A matching thread for incoming connection already exists\");\n- return false;\n- }\n-\n- return true;\n+ return mIncomingSocketThreads.add(incomingSocketThread);\n}\n/**\n@@ -162,12 +157,27 @@ public class ConnectionModel {\n* @return True, if the thread was successfully added to the collection. False otherwise.\n*/\npublic synchronized boolean addConnectionThread(OutgoingSocketThread outgoingSocketThread) {\n- if (!mOutgoingSocketThreads.addIfAbsent(outgoingSocketThread)) {\n- Log.e(TAG, \"addConnectionThread: A matching thread for outgoing connection already exists\");\n- return false;\n+ return mOutgoingSocketThreads.add(outgoingSocketThread);\n+ }\n+\n+ /**\n+ * Check that current collection contains the provided thread\n+ *\n+ * @param incomingSocketThread An incoming (connection) socket thread instance to add.\n+ * @return True, if the thread is already added to the collection. False otherwise.\n+ */\n+ public boolean contains(IncomingSocketThread incomingSocketThread) {\n+ return mIncomingSocketThreads.contains(incomingSocketThread);\n}\n- return true;\n+ /**\n+ * Check that current collection contains the provided thread\n+ *\n+ * @param outgoingSocketThread An outgoing (connection) socket thread instance to add.\n+ * @return True, if the thread is already added to the collection. False otherwise.\n+ */\n+ public boolean contains(OutgoingSocketThread outgoingSocketThread) {\n+ return mOutgoingSocketThreads.contains(outgoingSocketThread);\n}\n/**\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix null pointer exception.
The initialization of the thread was moved before adding the thread to collection
|
675,373 |
16.02.2017 13:52:18
| -10,800 |
457c3ab71a002cdad7aadd7628099513d1a7f1d7
|
Remove the extra synchronized word
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/ConnectionModel.java",
"new_path": "src/android/java/io/jxcore/node/ConnectionModel.java",
"diff": "@@ -146,7 +146,7 @@ public class ConnectionModel {\n* @param incomingSocketThread An incoming (connection) socket thread instance to add.\n* @return True, if the thread was successfully added to the collection. False otherwise.\n*/\n- public synchronized boolean addConnectionThread(IncomingSocketThread incomingSocketThread) {\n+ public boolean addConnectionThread(IncomingSocketThread incomingSocketThread) {\nreturn mIncomingSocketThreads.add(incomingSocketThread);\n}\n@@ -156,7 +156,7 @@ public class ConnectionModel {\n* @param outgoingSocketThread An outgoing (connection) socket thread instance to add.\n* @return True, if the thread was successfully added to the collection. False otherwise.\n*/\n- public synchronized boolean addConnectionThread(OutgoingSocketThread outgoingSocketThread) {\n+ public boolean addConnectionThread(OutgoingSocketThread outgoingSocketThread) {\nreturn mOutgoingSocketThreads.add(outgoingSocketThread);\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Remove the extra synchronized word
|
675,381 |
17.02.2017 17:49:54
| -10,800 |
d2f007e9ffa2ee60addbaa082799b3ba184b7baa
|
Fix null checks in tests
Android couldn't properly serialize null values before. But since it has
been already fixed I can update tests with proper null checks
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testNativeMethod.js",
"new_path": "test/www/jxcore/bv_tests/testNativeMethod.js",
"diff": "@@ -33,7 +33,7 @@ test('onPeerLost calls jxcore',\nt.equal(callbackPeer.peerIdentifier, '11:22:33:22:11:00',\n'check if callback was fired by onPeerLost');\n- t.ok(callbackPeer.generation == null, 'check if generation is null');\n+ t.ok(callbackPeer.generation === null, 'check if generation is null');\nt.notOk(callbackPeer.peerAvailable, 'check if peerAvailable is false');\nt.end();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1731,11 +1731,9 @@ test('network changes emitted correctly',\n.then(function () {\nreturn new Promise(function (resolve) {\nfunction networkChangedHandler (networkStatus) {\n- // TODO Android can send event with 'wifi': 'off' and without\n- // 'bssidName' and 'ssidName'.\n- // t.equals(networkStatus.wifi, 'off', 'wifi should be off');\n- t.ok(networkStatus.bssidName == null, 'bssid should be null');\n- t.ok(networkStatus.ssidName == null, 'ssid should be null');\n+ t.equals(networkStatus.wifi, 'off', 'wifi should be off');\n+ t.ok(networkStatus.bssidName === null, 'bssid should be null');\n+ t.ok(networkStatus.ssidName === null, 'ssid should be null');\nresolve();\n}\nThaliMobile.emitter.once('networkChanged', networkChangedHandler);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix null checks in tests
Android couldn't properly serialize null values before. But since it has
been already fixed I can update tests with proper null checks
|
675,373 |
20.02.2017 16:22:38
| -10,800 |
b9e18a996b1379969f473a54201e300ea39380a2
|
Rollback to java 1.6 version
|
[
{
"change_type": "MODIFY",
"old_path": "src/android/java/build-extras.gradle",
"new_path": "src/android/java/build-extras.gradle",
"diff": "ext.postBuildExtras = {\nandroid {\ncompileOptions {\n- sourceCompatibility JavaVersion.VERSION_1_7\n- targetCompatibility JavaVersion.VERSION_1_7\n+ sourceCompatibility JavaVersion.VERSION_1_6\n+ targetCompatibility JavaVersion.VERSION_1_6\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/android/java/io/jxcore/node/ConnectionModel.java",
"new_path": "src/android/java/io/jxcore/node/ConnectionModel.java",
"diff": "@@ -13,9 +13,9 @@ import java.util.concurrent.CopyOnWriteArrayList;\n*/\npublic class ConnectionModel {\nprivate static final String TAG = ConnectionModel.class.getName();\n- private final CopyOnWriteArrayList<IncomingSocketThread> mIncomingSocketThreads = new CopyOnWriteArrayList<>();\n- private final CopyOnWriteArrayList<OutgoingSocketThread> mOutgoingSocketThreads = new CopyOnWriteArrayList<>();\n- private final HashMap<String, JXcoreThaliCallback> mOutgoingConnectionCallbacks = new HashMap<>();\n+ private final CopyOnWriteArrayList<IncomingSocketThread> mIncomingSocketThreads = new CopyOnWriteArrayList<IncomingSocketThread>();\n+ private final CopyOnWriteArrayList<OutgoingSocketThread> mOutgoingSocketThreads = new CopyOnWriteArrayList<OutgoingSocketThread>();\n+ private final HashMap<String, JXcoreThaliCallback> mOutgoingConnectionCallbacks = new HashMap<String, JXcoreThaliCallback>();\n/**\n* Constructor.\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Rollback to java 1.6 version
|
675,381 |
17.02.2017 19:28:40
| -10,800 |
c182d5d330bb33c59f2f4ea1744ca6a0e0a2ff2d
|
"Fix" race conditions in ssdp restart tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"new_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"diff": "@@ -137,7 +137,8 @@ test(\nclientStopStub.reset();\nreturn new Promise(function (resolve) {\nchangeBssid(newBssid);\n- setImmediate(function () {\n+ // TODO: #1805\n+ setTimeout(function () {\nt.equal(serverStartStub.callCount, 1, 'server start called once');\nt.equal(serverStopStub.callCount, 1, 'server stop called once');\nt.equal(clientStartStub.callCount, 1, 'client start called once');\n@@ -147,7 +148,7 @@ test(\nt.ok(clientStopStub.calledBefore(clientStartStub),\n'client stop called before start');\nresolve();\n- });\n+ }, 200);\n});\n}\n@@ -202,13 +203,14 @@ test(\nfunction testBssidChangeReaction (newBssid) {\nreturn new Promise(function (resolve) {\nchangeBssid(newBssid);\n- setImmediate(function () {\n+ // TODO: #1805\n+ setTimeout(function () {\nt.equal(serverStartStub.callCount, 0, 'server start never called');\nt.equal(serverStopStub.callCount, 0, 'server stop never called');\nt.equal(clientStartStub.callCount, 0, 'client start never called');\nt.equal(clientStopStub.callCount, 0, 'client start never called');\nresolve();\n- });\n+ }, 200);\n});\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
"Fix" race conditions in ssdp restart tests
|
675,379 |
02.03.2017 12:59:25
| -10,800 |
7b828d4a548f66aabbd5a6f41c47724a7f705fae
|
Fixing build-time issues in ThaliCore.
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/AdvertiserManager.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/AdvertiserManager.swift",
"diff": "@@ -93,7 +93,7 @@ public final class AdvertiserManager {\nCalled when startUpdateAdvertisingAndListening fails.\n*/\npublic func startUpdateAdvertisingAndListening(onPort port: UInt16,\n- errorHandler: (Error) -> Void) {\n+ errorHandler: @escaping (Error) -> Void) {\nif let currentAdvertiser = currentAdvertiser {\ndisposeOfAdvertiserAfterTimeoutToFinishInvites(currentAdvertiser)\n}\n@@ -179,7 +179,9 @@ public final class AdvertiserManager {\nfileprivate func disposeOfAdvertiserAfterTimeoutToFinishInvites(\n_ advertiserToBeDisposedOf: Advertiser) {\n- let disposeTimeout = DispatchTime.now() + Double(Int64(self.disposeTimeout * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)\n+ let disposeTimeout =\n+ DispatchTime.now() +\n+ Double(Int64(self.disposeTimeout * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)\nDispatchQueue.main.asyncAfter(deadline: disposeTimeout) {\n[weak self,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/Browser.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/Browser.swift",
"diff": "@@ -144,8 +144,8 @@ final class Browser: NSObject {\n- returns: Session object that manages MCSession between peers\n*/\nfunc inviteToConnect(_ peer: Peer,\n- sessionConnected: () -> Void,\n- sessionNotConnected: () -> Void) throws -> Session {\n+ sessionConnected: @escaping () -> Void,\n+ sessionNotConnected: @escaping () -> Void) throws -> Session {\nlet mcSession = MCSession(peer: browser.myPeerID,\nsecurityIdentity: nil,\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/BrowserManager.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/BrowserManager.swift",
"diff": "@@ -90,7 +90,7 @@ public final class BrowserManager {\n- errorHandler:\nCalled when advertisement fails.\n*/\n- public func startListeningForAdvertisements(_ errorHandler: (Error) -> Void) {\n+ public func startListeningForAdvertisements(_ errorHandler: @escaping (Error) -> Void) {\nif currentBrowser != nil { return }\nlet browser = Browser(serviceType: serviceType,\n@@ -164,9 +164,7 @@ public final class BrowserManager {\nlet relay = strongSelf.activeRelays.value[peerIdentifier]\nrelay?.openRelay {\nport, error in\n- completion(syncValue: syncValue,\n- error: error,\n- port: port)\n+ completion(syncValue, error, port)\n}\n},\nsessionNotConnected: {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/BrowserRelay.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/BrowserRelay.swift",
"diff": "@@ -44,7 +44,7 @@ final class BrowserRelay {\ntcpListener.startListeningForConnections(on: anyAvailablePort,\nconnectionAccepted: didAcceptConnectionHandler) {\nport, error in\n- completion(port: port, error: error)\n+ completion(port, error)\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocket.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocket.swift",
"diff": "@@ -105,7 +105,7 @@ class VirtualSocket: NSObject {\nlet bytesReaded = self.inputStream.read(&buffer, maxLength: maxReadBufferLength)\nif bytesReaded >= 0 {\n- let data = Data(bytes: UnsafePointer<UInt8>(&buffer), count: bytesReaded)\n+ let data = Data(bytes: buffer, count: bytesReaded)\ndidReadDataFromStreamHandler?(self, data)\n} else {\ncloseStreams()\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocketBuilder.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/SocketConnection/VirtualSocketBuilder.swift",
"diff": "@@ -123,7 +123,9 @@ final class BrowserVirtualSocketBuilder: VirtualSocketBuilder {\nlet outputStream = try nonTCPsession.startOutputStream(with: streamName)\nself.outputStream = outputStream\n- let streamReceivedBackTimeout = DispatchTime.now() + Double(Int64(self.streamReceivedBackTimeout * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)\n+ let streamReceivedBackTimeout =\n+ DispatchTime.now() +\n+ Double(Int64(self.streamReceivedBackTimeout * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)\nDispatchQueue.main.asyncAfter(deadline: streamReceivedBackTimeout) {\n[weak self] in\nguard let strongSelf = self else { return }\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/AdvertiserRelayTests.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/AdvertiserRelayTests.swift",
"diff": "@@ -143,7 +143,7 @@ class AdvertiserRelayTests: XCTestCase {\n// Check if relay objectes are valid\nguard\nlet browserRelayInfo: (uuid: String, relay: BrowserRelay) =\n- browserManager.activeRelays.value.first,\n+ browserManager.activeRelays.value.first as! (uuid: String, relay: BrowserRelay)?,\nlet advertiserRelayInfo: (uuid: String, relay: AdvertiserRelay) =\nadvertiserManager.activeRelays.value.first as! (uuid: String, relay: AdvertiserRelay)?\nelse {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/BrowserRelayTests.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/BrowserRelayTests.swift",
"diff": "@@ -261,9 +261,9 @@ class BrowserRelayTests: XCTestCase {\n// Check if relay objectes are valid\nguard\nlet browserRelayInfo: (uuid: String, relay: BrowserRelay) =\n- browserManager.activeRelays.value.first,\n+ browserManager.activeRelays.value.first as! (uuid: String, relay: BrowserRelay)?,\nlet advertiserRelayInfo: (uuid: String, relay: AdvertiserRelay) =\n- advertiserManager.activeRelays.value.first\n+ advertiserManager.activeRelays.value.first as! (uuid: String, relay: AdvertiserRelay)?\nelse {\nreturn\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/Mocks/MCSessionMock.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/Mocks/MCSessionMock.swift",
"diff": "@@ -22,6 +22,6 @@ class MCSessionMock: MCSession {\nthrow NSError(domain: \"org.thaliproject.test\", code: 42, userInfo: nil)\n}\n- return OutputStream(toBuffer: nil, capacity: 0)\n+ return OutputStream(toBuffer: UnsafeMutablePointer.allocate(capacity: 0), capacity: 0)\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/RelayTests.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/RelayTests.swift",
"diff": "@@ -159,9 +159,9 @@ class RelayTests: XCTestCase {\n// Check if relay objectes are valid\nguard\nlet browserRelayInfo: (uuid: String, relay: BrowserRelay) =\n- browserManager.activeRelays.value.first,\n+ browserManager.activeRelays.value.first as! (uuid: String, relay: BrowserRelay)?,\nlet advertiserRelayInfo: (uuid: String, relay: AdvertiserRelay) =\n- advertiserManager.activeRelays.value.first\n+ advertiserManager.activeRelays.value.first as! (uuid: String, relay: AdvertiserRelay)?\nelse {\nreturn\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/SessionTests.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/SessionTests.swift",
"diff": "@@ -179,7 +179,7 @@ class SessionTests: XCTestCase {\ndidReceiveInputStreamHandlerInvoked?.fulfill()\n}\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet randomlyGeneratedStreamName = UUID().uuidString\n// When\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/TCPServerMock.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/TCPServerMock.swift",
"diff": "@@ -16,7 +16,10 @@ class TCPServerMock: NSObject {\nstatic fileprivate let delegateQueueName =\n\"org.thaliproject.TCPServerMock.GCDAsyncSocket.delegateQueue\"\n- fileprivate let delegateQueue = DispatchQueue(label: delegateQueueName, attributes: DispatchQueue.Attributes.concurrent)\n+ fileprivate let delegateQueue = DispatchQueue(\n+ label: delegateQueueName,\n+ attributes: DispatchQueue.Attributes.concurrent\n+ )\nfileprivate var didAcceptConnectionHandler: () -> Void\nfileprivate var didReadDataHandler: (GCDAsyncSocket, Data) -> Void\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/VirtualSocketBuilderTests.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/VirtualSocketBuilderTests.swift",
"diff": "@@ -51,7 +51,7 @@ class VirtualSocketBuilderTests: XCTestCase {\nvirtualSocketCreated.fulfill()\n}\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet emptyInputStream = InputStream(data: emptyData)\nlet randomlyGeneratedStreamName = UUID().uuidString\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/VirtualSocketTests.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/VirtualSocketTests.swift",
"diff": "@@ -46,7 +46,7 @@ class VirtualSocketTests: XCTestCase {\ndo {\nlet ouputStream = try nonTCPSession.startOutputStream(with: \"test\")\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet inputStream = InputStream(data: emptyData)\n// When\n@@ -64,7 +64,7 @@ class VirtualSocketTests: XCTestCase {\ndo {\nlet ouputStream = try nonTCPSession.startOutputStream(with: \"test\")\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet inputStream = InputStream(data: emptyData)\nlet virtualSocket = VirtualSocket(with: inputStream, outputStream: ouputStream)\n@@ -84,7 +84,7 @@ class VirtualSocketTests: XCTestCase {\ndo {\nlet ouputStream = try nonTCPSession.startOutputStream(with: \"test\")\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet inputStream = InputStream(data: emptyData)\nlet virtualSocket = VirtualSocket(with: inputStream, outputStream: ouputStream)\n@@ -107,7 +107,7 @@ class VirtualSocketTests: XCTestCase {\ndo {\nlet ouputStream = try nonTCPSession.startOutputStream(with: \"test\")\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet inputStream = InputStream(data: emptyData)\nlet virtualSocket = VirtualSocket(with: inputStream, outputStream: ouputStream)\n@@ -130,7 +130,7 @@ class VirtualSocketTests: XCTestCase {\ndo {\nlet ouputStream = try nonTCPSession.startOutputStream(with: \"test\")\n- let emptyData = Data(bytes: UnsafePointer<UInt8>(nil), count: 0)\n+ let emptyData = Data(bytes: [], count: 0)\nlet inputStream = InputStream(data: emptyData)\nlet virtualSocket = VirtualSocket(with: inputStream, outputStream: ouputStream)\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fixing build-time issues in ThaliCore.
|
675,379 |
02.03.2017 13:01:03
| -10,800 |
8ad10c79659d9b9d7c4c34aab5cdf7603d8344c6
|
Swift 3.0 migration for ThaliCore (ThaliCore module itself).
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/project.pbxproj",
"new_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/project.pbxproj",
"diff": "TargetAttributes = {\nCCA571BB1D4787A900FBEC41 = {\nCreatedOnToolsVersion = 7.3.1;\n+ LastSwiftMigration = 0820;\n};\nCCA571C51D4787A900FBEC41 = {\nCreatedOnToolsVersion = 7.3.1;\n+ LastSwiftMigration = 0820;\n};\nCCA572911D4A327E00FBEC41 = {\nCreatedOnToolsVersion = 7.3.1;\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nSKIP_INSTALL = YES;\nSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n+ SWIFT_VERSION = 3.0;\n};\nname = Debug;\n};\nPRODUCT_BUNDLE_IDENTIFIER = org.thali.ThaliCore;\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nSKIP_INSTALL = YES;\n+ SWIFT_VERSION = 3.0;\n};\nname = Release;\n};\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nSWIFT_OBJC_BRIDGING_HEADER = \"ThaliCoreTests/Bridging-Header.h\";\nSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n+ SWIFT_VERSION = 3.0;\n};\nname = Debug;\n};\nPRODUCT_BUNDLE_IDENTIFIER = org.thali.ThaliCoreTests;\nPRODUCT_NAME = \"$(TARGET_NAME)\";\nSWIFT_OBJC_BRIDGING_HEADER = \"ThaliCoreTests/Bridging-Header.h\";\n+ SWIFT_VERSION = 3.0;\n};\nname = Release;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/AdvertiserManager.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/AdvertiserManager.swift",
"diff": "@@ -124,7 +124,7 @@ public final class AdvertiserManager {\n})\nguard let newAdvertiser = advertiser else {\n- errorHandler(ThaliCoreError.ConnectionFailed as! Error)\n+ errorHandler(ThaliCoreError.ConnectionFailed as Error)\nreturn\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/BrowserManager.swift",
"new_path": "lib/ios/ThaliCore/ThaliCore/MultipeerConnectivity/BrowserManager.swift",
"diff": "@@ -98,7 +98,7 @@ public final class BrowserManager {\nlostPeer: handleLost)\nguard let newBrowser = browser else {\n- errorHandler(ThaliCoreError.ConnectionFailed as! Error)\n+ errorHandler(ThaliCoreError.ConnectionFailed as Error)\nreturn\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/TCPClientMock.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/TCPClientMock.swift",
"diff": "@@ -50,7 +50,7 @@ class TCPClientMock: NSObject {\ntcpClient.write(messageData!, withTimeout: -1, tag: 0)\n}\n- func sendRandomMessage(length: Int) {\n+ func sendRandomMessage(_ length: Int) {\nlet randomMessage = String.random(length: length) + \"/r/n\"\nlet messageData = randomMessage.data(using: String.Encoding.utf8)\ntcpClient.write(messageData!, withTimeout: -1, tag: 0)\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/TCPServerMock.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/SocketConnectionTests/TCPServerMock.swift",
"diff": "@@ -76,7 +76,7 @@ class TCPServerMock: NSObject {\n- length:\nLength of random message.\n*/\n- func sendRandomMessage(length: Int) {\n+ func sendRandomMessage(_ length: Int) {\nguard length > 0 else { return }\nlet randomMessage = String.random(length: length)\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCoreTests/Utils/String+Random.swift",
"new_path": "lib/ios/ThaliCore/ThaliCoreTests/Utils/String+Random.swift",
"diff": "@@ -22,7 +22,7 @@ extension String {\n- returns:\nRandomly generated string.\n*/\n- static func random(length: Int) -> String {\n+ static func random(_ length: Int) -> String {\nlet letters: String = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ\"\nvar randomString = \"\"\n@@ -63,7 +63,7 @@ extension String {\n// MARK: - Manipulating service type in Bonjour format\nextension String {\n- static func randomValidServiceType(length: Int) -> String {\n+ static func randomValidServiceType(_ length: Int) -> String {\nlet asciiLetters = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWXYZ\"\nlet digits = \"0123456789\"\nlet hyphen = \"-\"\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Swift 3.0 migration for ThaliCore (ThaliCore module itself).
|
675,381 |
02.03.2017 13:15:41
| -10,800 |
53ae008b37e26c49ca3f5e08d3159d52546b019c
|
Eslint: ignore valid long jsdoc lines
|
[
{
"change_type": "RENAME",
"old_path": ".eslintrc",
"new_path": ".eslintrc.js",
"diff": "-{\n+module.exports = {\n\"env\": {\n\"node\": true\n},\n2,\n{\n\"ignoreTrailingComments\": true,\n+ \"ignoreUrls\": true,\n\"ignoreStrings\": true,\n- \"ignoreUrls\": true\n+ \"ignorePattern\": getMaxLenPatterns()\n}\n],\n\"camelcase\": [\n\"single\"\n]\n}\n+};\n+\n+function getMaxLenPatterns() {\n+ var patterns = [\n+ // /**\n+ // * @param {type} identifier\n+ // */\n+ /^\\s+?\\* @(param|arg|argument|prop|property) \\{.+?\\} (\\[.+?\\]|[\\w\\d_\\.\\[\\]]+)$/,\n+\n+ // /**\n+ // * {@link location}\n+ // */\n+ /^\\s+?\\* \\{@link .+?\\}$/,\n+\n+ // /**\n+ // * @function functionName\n+ // * @function external:\"Mobile('realyLongMobileMethod')\".registerToNative\n+ // */\n+ /^\\s+?\\* @(function|func|method) \\S+$/,\n+\n+ // /**\n+ // * | cell1 | cell2 |\n+ // */\n+ /^\\s+?\\* \\|.*\\|$/\n+ ];\n+\n+ return patterns.map(re => `(${re.source})`).join('|');\n}\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/notification/thaliNotificationClient.js",
"new_path": "thali/NextGeneration/notification/thaliNotificationClient.js",
"diff": "@@ -46,7 +46,6 @@ function PeerAdvertisesDataForUs (keyId, pskIdentifyField,\nthis.peerId = peerId;\n}\n-/* eslint-disable max-len */\n/**\n* @classdesc Creates a class that can register to receive the {@link\n* module:thaliMobile.event:peerAvailabilityChanged} event. It will listen for\n@@ -70,7 +69,6 @@ function PeerAdvertisesDataForUs (keyId, pskIdentifyField,\n* @throws {Error} ecdhForLocalDevice cannot be null\n*/\nfunction ThaliNotificationClient(thaliPeerPoolInterface, ecdhForLocalDevice) {\n- /* eslint-enable max-len */\nEventEmitter.call(this);\nvar self = this;\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js",
"new_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js",
"diff": "@@ -14,7 +14,6 @@ var Utils = require('../utils/common.js');\n/** @module thaliReplicationPeerAction */\n-/* eslint-disable max-len */\n/**\n* @classdesc Manages replicating information with a peer we have discovered\n* via notifications.\n@@ -37,7 +36,6 @@ function ThaliReplicationPeerAction(peerAdvertisesDataForUs,\nPouchDB,\ndbName,\nourPublicKey) {\n-/* eslint-enable max-len */\nassert(ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS * 1000 -\nThaliReplicationPeerAction.PUSH_LAST_SYNC_UPDATE_MILLISECONDS >\n1000, 'Need at least a seconds worth of clearance to make sure ' +\n@@ -135,7 +133,6 @@ ThaliReplicationPeerAction.prototype._replicationTimer = function () {\nself._refreshTimerManager.start();\n};\n-/* eslint-disable max-len */\n/**\n* When start is called we will start a replication with the remote peer using\n* the settings specified below. We will need to create the URL using the\n@@ -179,13 +176,13 @@ ThaliReplicationPeerAction.prototype._replicationTimer = function () {\n* This is important for the thread pool to know. See the errors defined on\n* {@link module:thaliPeerAction~PeerAction.start}.\n*\n- * change - If we don't see any changes on the replication for {@link\n- * module:thaliReplicationPeerAction~ThaliReplicatonPeerAction.MAX_IDLE_PERIOD_SECONDS}\n+ * change - If we don't see any changes on the replication for\n+ * {@link module:thaliReplicationPeerAction~ThaliReplicatonPeerAction.MAX_IDLE_PERIOD_SECONDS}\n* seconds then we will end the replication. The output from this event also\n* provides us with the current last_seq we have synch'd from the remote peer.\n* Per http://thaliproject.org/ReplicationAcrossDiscoveryProtocol/ we need to\n- * update the remote `_Local/<peer ID>` document every {@link\n- * module:thaliReplicationPeerAction~ThaliReplicationPeerAction.PUSH_LAST_SYNC_UPDATE_MILLISECONDS}\n+ * update the remote `_Local/<peer ID>` document every\n+ * {@link module:thaliReplicationPeerAction~ThaliReplicationPeerAction.PUSH_LAST_SYNC_UPDATE_MILLISECONDS}\n*\n* Make sure to keep the cancel object returned by the replicate call. Well\n* need it for kill.\n@@ -196,7 +193,6 @@ ThaliReplicationPeerAction.prototype._replicationTimer = function () {\n* @returns {Promise<?Error>}\n*/\nThaliReplicationPeerAction.prototype.start = function (httpAgentPool) {\n-/* eslint-enable max-len */\nvar self = this;\nthis._completed = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNative.js",
"new_path": "thali/NextGeneration/thaliMobileNative.js",
"diff": "* layer will then relay to the remote peer.\n*/\n-/* eslint-disable max-len */\n/**\n* This is the callback used by {@link external:\"Mobile('connect')\".callNative}.\n*\n* they can do). Rather than fix it we are just sticking this odd behavior\n* into the spec. Sorry. :(\n*/\n-/* eslint-enable max-len */\n/**\n* @external \"Mobile('connect')\"\n*/\n-/* eslint-disable max-len */\n/**\n* On platforms that support `connect`, this method tells the native layer to\n* establish a non-TCP/IP connection to the identified peer and to then create a\n* error or the 127.0.0.1 port to connect to in order to get a connection to the\n* remote peer\n*/\n-/* eslint-enable max-len */\n/**\n* @external \"Mobile('multiConnect')\"\n* @public\n*/\n-/* eslint-disable max-len */\n/**\n* Platforms that support `multiConnect` are able to bridge from a non-TCP\n* transport to a native TCP listener that can accept arbitrary numbers of\n* be returned with the value \"Platform does not support multiConnect\". Any\n* other errors will be returned in the {@link multiConnectResolved} callback.\n*/\n-/* eslint-enable max-len */\n/**\n* @external \"Mobile('disconnect')\"\n* @external \"Mobile('multiConnectResolved')\"\n*/\n-/* eslint-disable max-len */\n/**\n* If the MCSession could not be formed then error MUST NOT be null and MUST\n* contain a description of the problem while port MUST be null. If the\n* @property {?string} error\n* @property {?number} listeningPort\n*/\n-/* eslint-enable max-len */\n/**\n* Every call to `multiConnect` MUST produced exactly one callback of this type.\n* @property {string} error\n*/\n-/* eslint-disable max-len */\n/**\n* Fires the multiConnectConnectionFailureCallback if a multiConnect connection\n* fails. This failure can include a failure induced by a call to `disconnect`.\n* @function external:\"Mobile(`multiConnectConnectionFailure`)\".registerToNative\n* @param {module:thaliMobileNative~multiConnectConnectionFailureCallback} callback\n*/\n-/* eslint-enable max-len */\n/**\n* This object defines peerAvailabilityChanged information about a single peer.\n* @external \"Mobile('discoveryAdvertisingStateUpdateNonTCP')\"\n*/\n-/* eslint-disable max-len */\n/**\n* This is the callback used by\n* {@link external:\"Mobile('discoveryAdvertisingStateUpdateNonTCP')\".registerToNative}\n* @callback discoveryAdvertisingStateUpdateNonTCPCallback\n* @property {module:thaliMobileNative~discoveryAdvertisingStateUpdate} discoveryAdvertisingStateUpdateValue\n*/\n-/* eslint-enable max-len */\n-/* eslint-disable max-len */\n/**\n* Please see the definition of\n* {@link module:thaliMobileNativeWrapper~discoveryAdvertisingStateUpdateNonTCPEvent}\n* @function external:\"Mobile('discoveryAdvertisingStateUpdateNonTCP')\".registerToNative\n* @param {module:thaliMobileNative~discoveryAdvertisingStateUpdateNonTCPCallback} callback\n*/\n-/* eslint-enable max-len */\n/* jshint -W098 */\n/**\n@@ -725,7 +711,6 @@ module.exports.radioState = {\n* @external \"Mobile('incomingConnectionToPortNumberFailed')\"\n*/\n-/* eslint-disable max-len */\n/**\n* This is the callback used by\n* {@link external:\"Mobile('incomingConnectionToPortNumberFailed')\".registerToNative}\n@@ -735,9 +720,7 @@ module.exports.radioState = {\n* @property {number} portNumber The 127.0.0.1 port that the TCP/IP bridge tried\n* to connect to.\n*/\n-/* eslint-enable max-len */\n-/* eslint-disable max-len */\n/**\n* Please see the definition of\n* {@link module:thaliMobileNativeWrapper.incomingConnectionToPortNumberFailed}.\n@@ -756,4 +739,3 @@ module.exports.radioState = {\n* @function external:\"Mobile('incomingConnectionToPortNumberFailed')\".registerToNative\n* @param {module:thaliMobileNative~incomingConnectionToPortNumberFailedCallback} callback\n*/\n-/* eslint-enable max-len */\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -425,7 +425,6 @@ module.exports.stop = function () {\nreturn gPromiseQueue.enqueue(stop);\n};\n-/* eslint-disable max-len */\n/**\n* This method instructs the native layer to discover what other devices are\n* within range using the platform's non-TCP P2P capabilities. When a device is\n@@ -450,7 +449,6 @@ module.exports.stop = function () {\n* @throws {Error}\n*/\nmodule.exports.startListeningForAdvertisements = function () {\n-/* eslint-enable max-len */\ntargetStates.listening = true;\nreturn gPromiseQueue.enqueue(function (resolve, reject) {\nif (!states.started) {\n@@ -496,7 +494,6 @@ module.exports.stopListeningForAdvertisements = function () {\n});\n};\n-/* eslint-disable max-len */\n/**\n* This method has two separate but related functions. It's first function is to\n* begin advertising the Thali peer's presence to other peers. The second\n@@ -564,7 +561,6 @@ module.exports.stopListeningForAdvertisements = function () {\n* @public\n* @returns {Promise<?Error>}\n*/\n-/* eslint-enable max-len */\nmodule.exports.startUpdateAdvertisingAndListening = function () {\ntargetStates.advertising = true;\nreturn gPromiseQueue.enqueue(function (resolve, reject) {\n@@ -987,7 +983,6 @@ module.exports.unlockAndroidWifiMulticast = function () {\n* always be null for `multiConnect`.\n*/\n-/* eslint-disable max-len */\n/**\n* This event MAY start firing as soon as either of the start methods is called.\n* Start listening for advertisements obviously looks for new peers but in some\n@@ -1012,7 +1007,7 @@ module.exports.unlockAndroidWifiMulticast = function () {\n* @type {Object}\n* @property {nonTCPPeerAvailabilityChanged} peer\n*/\n-/* eslint-enable max-len */\n+\nvar peerAvailabilityChangedQueue = new PromiseQueue();\nfunction handlePeerAvailabilityChanged (peer) {\nlogger.debug('Received peer availability changed event with ' +\n@@ -1142,7 +1137,6 @@ function recreatePeer(peerIdentifier) {\nhandlePeerAvailabilityChanged(peerAvailable);\n}\n-/* eslint-disable max-len */\n/**\n* This is used whenever discovery or advertising starts or stops. Since it's\n* possible for these to be stopped (in particular) due to events outside of\n@@ -1159,7 +1153,6 @@ function recreatePeer(peerIdentifier) {\n* @type {Object}\n* @property {module:thaliMobileNative~discoveryAdvertisingStateUpdate} discoveryAdvertisingStateUpdateValue\n*/\n-/* eslint-enable max-len */\n/**\n* Provides a notification when the network's state changes as well as when our\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -586,7 +586,6 @@ WifiAdvertiser.prototype.getAdvertisedPeerIdentifiers = function () {\n* to the peer\n*/\n-/* eslint-disable max-len */\n/**\n* For the definition of this event please see {@link\n* module:thaliMobileNativeWrapper~discoveryAdvertisingStateUpdateEvent}\n@@ -610,7 +609,6 @@ WifiAdvertiser.prototype.getAdvertisedPeerIdentifiers = function () {\n* @type {Object}\n* @property {module:thaliMobileNative~discoveryAdvertisingStateUpdate} discoveryAdvertisingStateUpdateValue\n*/\n-/* eslint-enable max-len */\n/**\n* [NOT IMPLEMENTED]\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Eslint: ignore valid long jsdoc lines (#1815)
|
675,379 |
02.03.2017 13:20:09
| -10,800 |
5ad9f4983d2b0a1cc38e60666743f0ef2be0bf3c
|
Update project to recommended settings.
Enable recommended warnings.
Turn on whole module optimization
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/project.pbxproj",
"new_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/project.pbxproj",
"diff": "isa = PBXProject;\nattributes = {\nLastSwiftUpdateCheck = 0730;\n- LastUpgradeCheck = 0730;\n+ LastUpgradeCheck = 0820;\nORGANIZATIONNAME = Thali;\nTargetAttributes = {\nCCA571BB1D4787A900FBEC41 = {\nCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\nCLANG_WARN_EMPTY_BODY = YES;\nCLANG_WARN_ENUM_CONVERSION = YES;\n+ CLANG_WARN_INFINITE_RECURSION = YES;\nCLANG_WARN_INT_CONVERSION = YES;\nCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n+ CLANG_WARN_SUSPICIOUS_MOVE = YES;\nCLANG_WARN_UNREACHABLE_CODE = YES;\nCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\nCODE_SIGNING_REQUIRED = NO;\nCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\nCLANG_WARN_EMPTY_BODY = YES;\nCLANG_WARN_ENUM_CONVERSION = YES;\n+ CLANG_WARN_INFINITE_RECURSION = YES;\nCLANG_WARN_INT_CONVERSION = YES;\nCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n+ CLANG_WARN_SUSPICIOUS_MOVE = YES;\nCLANG_WARN_UNREACHABLE_CODE = YES;\nCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\nCODE_SIGNING_REQUIRED = NO;\nIPHONEOS_DEPLOYMENT_TARGET = 8.0;\nMTL_ENABLE_DEBUG_INFO = NO;\nSDKROOT = iphoneos;\n+ SWIFT_OPTIMIZATION_LEVEL = \"-Owholemodule\";\nTARGETED_DEVICE_FAMILY = \"1,2\";\nVALIDATE_PRODUCT = YES;\nVERSIONING_SYSTEM = \"apple-generic\";\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/xcshareddata/xcschemes/ThaliCore.xcscheme",
"new_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/xcshareddata/xcschemes/ThaliCore.xcscheme",
"diff": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n- LastUpgradeVersion = \"0730\"\n+ LastUpgradeVersion = \"0820\"\nversion = \"1.3\">\n<BuildAction\nparallelizeBuildables = \"YES\"\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/xcshareddata/xcschemes/ThaliCoreCITests.xcscheme",
"new_path": "lib/ios/ThaliCore/ThaliCore.xcodeproj/xcshareddata/xcschemes/ThaliCoreCITests.xcscheme",
"diff": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n- LastUpgradeVersion = \"0730\"\n+ LastUpgradeVersion = \"0820\"\nversion = \"1.3\">\n<BuildAction\nparallelizeBuildables = \"YES\"\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update project to recommended settings.
Enable recommended warnings.
Turn on whole module optimization
|
675,379 |
02.03.2017 16:22:56
| -10,800 |
051bd1db4e6f0ede15f4e7cc8c21f5d9b1dea21e
|
Update AppContext.swift and AppContextTests.swift files to Swift 3.0.
|
[
{
"change_type": "MODIFY",
"old_path": "src/ios/AppContext.swift",
"new_path": "src/ios/AppContext.swift",
"diff": "@@ -11,20 +11,20 @@ import CoreBluetooth\nimport Foundation\nimport ThaliCore\n-func jsonValue(object: AnyObject) -> String {\n+func jsonValue(_ object: AnyObject) -> String {\nguard let data =\n- try? NSJSONSerialization.dataWithJSONObject(object,\n- options: NSJSONWritingOptions(rawValue:0))\n+ try? JSONSerialization.data(withJSONObject: object,\n+ options: JSONSerialization.WritingOptions(rawValue:0))\nelse {\nreturn \"\"\n}\n- return String(data: data, encoding: NSUTF8StringEncoding) ?? \"\"\n+ return String(data: data, encoding: String.Encoding.utf8) ?? \"\"\n}\n-func dictionaryValue(jsonText: String) -> [String : AnyObject]? {\n- if let data = jsonText.dataUsingEncoding(NSUTF8StringEncoding) {\n+func dictionaryValue(_ jsonText: String) -> [String : AnyObject]? {\n+ if let data = jsonText.data(using: String.Encoding.utf8) {\ndo {\n- return try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String : AnyObject]\n+ return try JSONSerialization.jsonObject(with: data, options: []) as? [String : AnyObject]\n} catch let error as NSError {\nprint(error)\n}\n@@ -51,7 +51,7 @@ enum NetworkStatusParameters: String {\ncase ssid = \"ssid\"\n}\n-@objc public enum AppContextError: Int, ErrorType, CustomStringConvertible {\n+@objc public enum AppContextError: Int, Error, CustomStringConvertible {\ncase badParameters\ncase unknownError\n@@ -87,9 +87,9 @@ public enum JSONKey: String {\nextension PeerAvailability {\nvar dictionaryValue: [String : AnyObject] {\n- return [JSONKey.peerIdentifier.rawValue : peerIdentifier,\n- JSONKey.peerAvailable.rawValue : available,\n- JSONKey.generation.rawValue : generation]\n+ return [JSONKey.peerIdentifier.rawValue : peerIdentifier as AnyObject,\n+ JSONKey.peerAvailable.rawValue : available as AnyObject,\n+ JSONKey.generation.rawValue : generation as AnyObject]\n}\n}\n@@ -100,7 +100,7 @@ extension PeerAvailability {\n- parameter peers: json with data about changed peers\n- parameter context: related AppContext\n*/\n- func context(context: AppContext, didChangePeerAvailability peersJSONString: String)\n+ func context(_ context: AppContext, didChangePeerAvailability peersJSONString: String)\n/**\nNotifies about network status changes\n@@ -108,7 +108,7 @@ extension PeerAvailability {\n- parameter status: json string with network availability status\n- parameter context: related AppContext\n*/\n- func context(context: AppContext, didChangeNetworkStatus statusJSONString: String)\n+ func context(_ context: AppContext, didChangeNetworkStatus statusJSONString: String)\n/**\nNotifies about peer advertisement update\n@@ -116,7 +116,7 @@ extension PeerAvailability {\n- parameter discoveryAdvertisingState: json with information about peer's state\n- parameter context: related AppContext\n*/\n- func context(context: AppContext,\n+ func context(_ context: AppContext,\ndidUpdateDiscoveryAdvertisingState discoveryAdvertisingStateJSONString: String)\n/**\n@@ -125,13 +125,13 @@ extension PeerAvailability {\n- parameter port: port failed to connect\n- parameter context: related AppContext\n*/\n- func context(context: AppContext, didFailIncomingConnectionToPort port: UInt16)\n+ func context(_ context: AppContext, didFailIncomingConnectionToPort port: UInt16)\n/**\ncallback for multiConnect function\n*/\n- func context(context: AppContext,\n+ func context(_ context: AppContext,\ndidResolveMultiConnectWithSyncValue value: String,\nerror: NSObject?,\nlisteningPort: NSObject?)\n@@ -140,7 +140,7 @@ extension PeerAvailability {\ncallback for multiConnect function\n*/\n- func context(context: AppContext, didFailMultiConnectConnectionWith paramsJSONString: String)\n+ func context(_ context: AppContext, didFailMultiConnectConnectionWith paramsJSONString: String)\n/**\nNotifies about entering background\n@@ -159,15 +159,15 @@ extension PeerAvailability {\n/// Interface for communication between native and cross-platform parts\n@objc public final class AppContext: NSObject {\n- private let disposeAdvertiserTimeout = 30.0\n- private let inputStreamReceiveTimeout = 5.0\n+ fileprivate let disposeAdvertiserTimeout = 30.0\n+ fileprivate let inputStreamReceiveTimeout = 5.0\n- private let serviceType: String\n- private let appNotificationsManager: ApplicationStateNotificationsManager\n+ fileprivate let serviceType: String\n+ fileprivate let appNotificationsManager: ApplicationStateNotificationsManager\n- private var networkChangedRegistered: Bool = false\n+ fileprivate var networkChangedRegistered: Bool = false\npublic weak var delegate: AppContextDelegate?\n- lazy private var browserManager: BrowserManager = {\n+ lazy fileprivate var browserManager: BrowserManager = {\n[unowned self] in\nreturn BrowserManager(serviceType: self.serviceType,\n@@ -179,13 +179,13 @@ extension PeerAvailability {\nstrongSelf.handleOnPeersAvailabilityChanged(peers)\n})\n}()\n- private let advertiserManager: AdvertiserManager\n+ fileprivate let advertiserManager: AdvertiserManager\n- private var bluetoothState = RadioState.unavailable\n- private var bluetoothLowEnergyState = RadioState.unavailable\n- private var bluetoothManager: CBCentralManager?\n+ fileprivate var bluetoothState = RadioState.unavailable\n+ fileprivate var bluetoothLowEnergyState = RadioState.unavailable\n+ fileprivate var bluetoothManager: CBCentralManager?\n- private func notifyOnDidUpdateNetworkStatus() {\n+ fileprivate func notifyOnDidUpdateNetworkStatus() {\nvar wifiState = RadioState.unavailable\nlet cellularState = RadioState.doNotCare\n@@ -215,15 +215,15 @@ extension PeerAvailability {\ndelegate?.context(self, didChangeNetworkStatus: jsonValue(networkStatus))\n}\n- private func handleWillEnterBackground() {\n+ fileprivate func handleWillEnterBackground() {\ndelegate?.appWillEnterBackground(with: self)\n}\n- private func handleDidEnterForeground() {\n+ fileprivate func handleDidEnterForeground() {\ndelegate?.appDidEnterForeground(with: self)\n}\n- private func handleOnPeersAvailabilityChanged(peers: [PeerAvailability]) {\n+ fileprivate func handleOnPeersAvailabilityChanged(_ peers: [PeerAvailability]) {\nlet mappedPeers = peers\n.filter {\n// We shouldn't notify JXcore when device discovers itself\n@@ -235,29 +235,29 @@ extension PeerAvailability {\nguard mappedPeers.count > 0 else {\nreturn\n}\n- delegate?.context(self, didChangePeerAvailability: jsonValue(mappedPeers))\n+ delegate?.context(self, didChangePeerAvailability: jsonValue(mappedPeers as AnyObject))\n}\n- private func updateListeningAdvertisingState() {\n+ fileprivate func updateListeningAdvertisingState() {\nlet newState = [\nJSONKey.discoveryActive.rawValue : browserManager.listening,\nJSONKey.advertisingActive.rawValue : advertiserManager.advertising\n]\n- delegate?.context(self, didUpdateDiscoveryAdvertisingState: jsonValue(newState))\n+ delegate?.context(self, didUpdateDiscoveryAdvertisingState: jsonValue(newState as AnyObject))\n}\n- private func handleMultiConnectResolved(withSyncValue value: String, port: UInt16?,\n- error: ErrorType?) {\n+ fileprivate func handleMultiConnectResolved(withSyncValue value: String, port: UInt16?,\n+ error: Error?) {\nlet errorValue = error != nil ? errorDescription(error!) : NSNull()\n- let listeningPort = port != nil ? NSNumber(unsignedShort: port!) : NSNull()\n+ let listeningPort = port != nil ? NSNumber(value: port! as UInt16) : NSNull()\ndelegate?.context(self,\ndidResolveMultiConnectWithSyncValue: value,\nerror: errorValue,\nlisteningPort: listeningPort)\n}\n- private func handleMultiConnectConnectionFailure(withIdentifier identifier: String,\n- error: ErrorType?) {\n+ fileprivate func handleMultiConnectConnectionFailure(withIdentifier identifier: String,\n+ error: Error?) {\nlet parameters = [\n\"peerIdentifier\" : identifier,\n\"error\" : error != nil ? errorDescription(error!) : NSNull()\n@@ -284,7 +284,7 @@ extension PeerAvailability {\nlet centralManagerDispatchQueue =\ndispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)\n#else\n- let centralManagerDispatchQueue: dispatch_queue_t? = nil\n+ let centralManagerDispatchQueue: DispatchQueue? = nil\n#endif\nbluetoothManager = CBCentralManager(delegate: self,\nqueue: centralManagerDispatchQueue,\n@@ -305,7 +305,7 @@ extension PeerAvailability {\n}\npublic func startUpdateAdvertisingAndListening(withParameters parameters: [AnyObject]) throws {\n- guard let port = (parameters.first as? NSNumber)?.unsignedShortValue else {\n+ guard let port = (parameters.first as? NSNumber)?.uint16Value else {\nthrow AppContextError.badParameters\n}\nadvertiserManager.startUpdateAdvertisingAndListening(onPort: port) { [weak self] error in\n@@ -320,13 +320,13 @@ extension PeerAvailability {\nself.updateListeningAdvertisingState()\n}\n- public func multiConnectToPeer(parameters: [AnyObject],\n+ public func multiConnectToPeer(_ parameters: [AnyObject],\nvalidationCompletionHandler: (NSError?) -> Void) {\nguard parameters.count >= 2 else {\nvalidationCompletionHandler(AppContextError.badParameters as NSError)\nreturn\n}\n- guard let identifierString = parameters[0] as? String, syncValue = parameters[1] as? String\n+ guard let identifierString = parameters[0] as? String, let syncValue = parameters[1] as? String\nelse {\nvalidationCompletionHandler(AppContextError.badParameters as NSError)\nreturn\n@@ -357,14 +357,14 @@ extension PeerAvailability {\nreturn\n}\n- public func killConnection(parameters: [AnyObject]) throws {\n+ public func killConnection(_ parameters: [AnyObject]) throws {\n}\npublic func getIOSVersion() -> String {\n- return NSProcessInfo().operatingSystemVersionString\n+ return ProcessInfo().operatingSystemVersionString\n}\n- public func didRegisterToNative(parameters: [AnyObject]) throws {\n+ public func didRegisterToNative(_ parameters: [AnyObject]) throws {\nguard let functionName = parameters.first as? String else {\nthrow AppContextError.badParameters\n}\n@@ -373,7 +373,7 @@ extension PeerAvailability {\n}\n}\n- public func disconnect(parameters: [AnyObject]) throws {\n+ public func disconnect(_ parameters: [AnyObject]) throws {\nguard let identifierString = parameters.first as? String else {\nthrow AppContextError.badParameters\n}\n@@ -382,7 +382,7 @@ extension PeerAvailability {\n}\n}\n- public func connect(parameters: [AnyObject]) -> String {\n+ public func connect(_ parameters: [AnyObject]) -> String {\nreturn jsonValue([JSONKey.err.rawValue : AppContextError.connectNotSupported.description])\n}\n@@ -399,9 +399,9 @@ extension PeerAvailability {\n// MARK: CBCentralManagerDelegate\nextension AppContext: CBCentralManagerDelegate {\n- public func centralManagerDidUpdateState(central: CBCentralManager) {\n+ public func centralManagerDidUpdateState(_ central: CBCentralManager) {\nswitch central.state {\n- case .PoweredOn:\n+ case .poweredOn:\nbluetoothState = .on\nbluetoothLowEnergyState = .on\n#if TEST\n@@ -410,7 +410,7 @@ extension AppContext: CBCentralManagerDelegate {\nobject: self\n)\n#endif\n- case .PoweredOff:\n+ case .poweredOff:\nbluetoothState = .off\nbluetoothLowEnergyState = .off\n#if TEST\n@@ -419,7 +419,7 @@ extension AppContext: CBCentralManagerDelegate {\nobject: self\n)\n#endif\n- case .Unsupported:\n+ case .unsupported:\nbluetoothState = .notHere\nbluetoothLowEnergyState = .notHere\ndefault:\n@@ -430,34 +430,34 @@ extension AppContext: CBCentralManagerDelegate {\n}\n/// Node functions names\n-@objc public class AppContextJSEvent: NSObject {\n- @objc public static let networkChanged: String = \"networkChanged\"\n- @objc public static let peerAvailabilityChanged: String = \"peerAvailabilityChanged\"\n- @objc public static let appEnteringBackground: String = \"appEnteringBackground\"\n- @objc public static let appEnteredForeground: String = \"appEnteredForeground\"\n- @objc public static let discoveryAdvertisingStateUpdateNonTCP: String =\n+@objc open class AppContextJSEvent: NSObject {\n+ @objc open static let networkChanged: String = \"networkChanged\"\n+ @objc open static let peerAvailabilityChanged: String = \"peerAvailabilityChanged\"\n+ @objc open static let appEnteringBackground: String = \"appEnteringBackground\"\n+ @objc open static let appEnteredForeground: String = \"appEnteredForeground\"\n+ @objc open static let discoveryAdvertisingStateUpdateNonTCP: String =\n\"discoveryAdvertisingStateUpdateNonTCP\"\n- @objc public static let incomingConnectionToPortNumberFailed: String =\n+ @objc open static let incomingConnectionToPortNumberFailed: String =\n\"incomingConnectionToPortNumberFailed\"\n- @objc public static let executeNativeTests: String = \"executeNativeTests\"\n- @objc public static let getOSVersion: String = \"getOSVersion\"\n- @objc public static let didRegisterToNative: String = \"didRegisterToNative\"\n- @objc public static let killConnections: String = \"killConnections\"\n- @objc public static let connect: String = \"connect\"\n- @objc public static let multiConnect: String = \"multiConnect\"\n- @objc public static let multiConnectResolved: String = \"multiConnectResolved\"\n- @objc public static let multiConnectConnectionFailure: String = \"multiConnectConnectionFailure\"\n- @objc public static let stopAdvertisingAndListening: String = \"stopAdvertisingAndListening\"\n- @objc public static let startUpdateAdvertisingAndListening: String =\n+ @objc open static let executeNativeTests: String = \"executeNativeTests\"\n+ @objc open static let getOSVersion: String = \"getOSVersion\"\n+ @objc open static let didRegisterToNative: String = \"didRegisterToNative\"\n+ @objc open static let killConnections: String = \"killConnections\"\n+ @objc open static let connect: String = \"connect\"\n+ @objc open static let multiConnect: String = \"multiConnect\"\n+ @objc open static let multiConnectResolved: String = \"multiConnectResolved\"\n+ @objc open static let multiConnectConnectionFailure: String = \"multiConnectConnectionFailure\"\n+ @objc open static let stopAdvertisingAndListening: String = \"stopAdvertisingAndListening\"\n+ @objc open static let startUpdateAdvertisingAndListening: String =\n\"startUpdateAdvertisingAndListening\"\n- @objc public static let stopListeningForAdvertisements: String =\n+ @objc open static let stopListeningForAdvertisements: String =\n\"stopListeningForAdvertisements\"\n- @objc public static let startListeningForAdvertisements: String =\n+ @objc open static let startListeningForAdvertisements: String =\n\"startListeningForAdvertisements\"\n- @objc public static let disconnect: String = \"disconnect\"\n+ @objc open static let disconnect: String = \"disconnect\"\n}\n-func errorDescription(error: ErrorType) -> String {\n+func errorDescription(_ error: Error) -> String {\nif let thaliCoreError = error as? ThaliCoreError {\nreturn thaliCoreError.rawValue\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/ios/Testing/AppContextTests.swift",
"new_path": "src/ios/Testing/AppContextTests.swift",
"diff": "@@ -14,14 +14,14 @@ import UIKit\n// MARK: - Random string generator\nextension String {\n- static func random(length length: Int) -> String {\n+ static func random(length: Int) -> String {\nlet letters: String = \"abcdefghkmnopqrstuvxyzABCDEFGHKLMNOPQRSTUXYZ\"\nvar randomString = \"\"\nlet lettersLength = UInt32(letters.characters.count)\nfor _ in 0..<length {\nlet rand = Int(arc4random_uniform(lettersLength))\n- let char = letters[letters.startIndex.advancedBy(rand)]\n+ let char = letters[letters.characters.index(letters.startIndex, offsetBy: rand)]\nrandomString.append(char)\n}\nreturn randomString\n@@ -37,7 +37,7 @@ struct Constants {\nstruct TimeForWhich {\n- static let bluetoothStateIsChanged: NSTimeInterval = 10\n+ static let bluetoothStateIsChanged: TimeInterval = 10\n}\nstruct NSNotificationName {\n@@ -91,20 +91,20 @@ class AppContextDelegateMock: NSObject, AppContextDelegate {\nlet peerAvailabilityChangedHandler: (String) -> Void\n- init(peerAvailabilityChangedHandler: (String) -> Void) {\n+ init(peerAvailabilityChangedHandler: @escaping (String) -> Void) {\nself.peerAvailabilityChangedHandler = peerAvailabilityChangedHandler\n}\n- @objc func context(context: AppContext,\n+ @objc func context(_ context: AppContext,\ndidResolveMultiConnectWithSyncValue value: String,\nerror: NSObject?,\nlisteningPort: NSObject?) {}\n- @objc func context(context: AppContext,\n+ @objc func context(_ context: AppContext,\ndidFailMultiConnectConnectionWith paramsJSONString: String) {}\n- @objc func context(context: AppContext, didChangePeerAvailability peers: String) {\n+ @objc func context(_ context: AppContext, didChangePeerAvailability peers: String) {\npeerAvailabilityChangedHandler(peers)\n}\n- @objc func context(context: AppContext, didChangeNetworkStatus status: String) {\n+ @objc func context(_ context: AppContext, didChangeNetworkStatus status: String) {\nnetworkStatusUpdated = true\nnetworkStatus = status\n@@ -149,11 +149,11 @@ class AppContextDelegateMock: NSObject, AppContextDelegate {\nXCTFail(\"Can not convert network status JSON string to dictionary\")\n}\n}\n- @objc func context(context: AppContext,\n+ @objc func context(_ context: AppContext,\ndidUpdateDiscoveryAdvertisingState discoveryAdvertisingState: String) {\nadvertisingListeningState = discoveryAdvertisingState\n}\n- @objc func context(context: AppContext, didFailIncomingConnectionToPort port: UInt16) {}\n+ @objc func context(_ context: AppContext, didFailIncomingConnectionToPort port: UInt16) {}\n@objc func appWillEnterBackground(with context: AppContext) {\nwillEnterBackground = true\n}\n@@ -170,7 +170,7 @@ class AppContextTests: XCTestCase {\nweak var expectationThatPrivateBluetoothStateIsChanged: XCTestExpectation?\nweak var expectationThatCoreBluetoothStateIsChanged: XCTestExpectation?\nweak var expectationThatBothBluetoothStatesAreChanged: XCTestExpectation?\n- var bluetoothChangingStateGroup: dispatch_group_t?\n+ var bluetoothChangingStateGroup: DispatchGroup?\noverride func setUp() {\nlet serviceType = String.random(length: 8)\n@@ -181,17 +181,17 @@ class AppContextTests: XCTestCase {\ncontext = nil\n}\n- private func jsonDictionaryFrom(string: String) -> [String : AnyObject]? {\n- guard let data = string.dataUsingEncoding(NSUTF8StringEncoding) else {\n+ fileprivate func jsonDictionaryFrom(_ string: String) -> [String : AnyObject]? {\n+ guard let data = string.data(using: String.Encoding.utf8) else {\nreturn nil\n}\n- return (try? NSJSONSerialization.JSONObjectWithData(data, options: [])) as?\n+ return (try? JSONSerialization.jsonObject(with: data, options: [])) as?\n[String : AnyObject]\n}\n// MARK: Tests\n- private func validateAdvertisingUpdate(jsonString: String, advertising: Bool, browsing: Bool) {\n+ fileprivate func validateAdvertisingUpdate(_ jsonString: String, advertising: Bool, browsing: Bool) {\nlet json = jsonDictionaryFrom(jsonString)\nlet listeningActive = (json?[JSONKey.discoveryActive.rawValue] as? Bool)\nlet advertisingActive = (json?[JSONKey.advertisingActive.rawValue] as? Bool)\n@@ -206,8 +206,8 @@ class AppContextTests: XCTestCase {\nXCTFail(\"unexpected peerAvailabilityChanged event\")\n})\ncontext.delegate = delegateMock\n- NSNotificationCenter.defaultCenter()\n- .postNotificationName(UIApplicationWillResignActiveNotification,\n+ NotificationCenter.default\n+ .post(name: NSNotification.Name.UIApplicationWillResignActive,\nobject: nil)\nXCTAssertTrue(delegateMock.willEnterBackground)\n}\n@@ -217,14 +217,14 @@ class AppContextTests: XCTestCase {\nXCTFail(\"unexpected peerAvailabilityChanged event\")\n})\ncontext.delegate = delegateMock\n- NSNotificationCenter.defaultCenter()\n- .postNotificationName(UIApplicationDidBecomeActiveNotification,\n+ NotificationCenter.default\n+ .post(name: NSNotification.Name.UIApplicationDidBecomeActive,\nobject: nil)\nXCTAssertTrue(delegateMock.didEnterForeground)\n}\nfunc testDidRegisterToNative() {\n- var error: ErrorType?\n+ var error: Error?\ndo {\ntry context.didRegisterToNative([\"test\", \"test\"])\n} catch let err {\n@@ -244,7 +244,7 @@ class AppContextTests: XCTestCase {\n}\nfunc testGetIOSVersion() {\n- XCTAssertEqual(NSProcessInfo().operatingSystemVersionString, context.getIOSVersion())\n+ XCTAssertEqual(ProcessInfo().operatingSystemVersionString, context.getIOSVersion())\n}\nfunc testThaliCoreErrors() {\n@@ -276,16 +276,16 @@ class AppContextTests: XCTestCase {\n}\nfunc testJsonValue() {\n- var jsonDict: [String : AnyObject] = [\"number\" : 4.2]\n+ var jsonDict: [String : AnyObject] = [\"number\" : 4.2 as AnyObject]\nvar jsonString = \"{\\\"number\\\":4.2}\"\nXCTAssertEqual(jsonValue(jsonDict), jsonString)\n- jsonDict = [\"string\" : \"42\"]\n+ jsonDict = [\"string\" : \"42\" as AnyObject]\njsonString = \"{\\\"string\\\":\\\"42\\\"}\"\nXCTAssertEqual(jsonValue(jsonDict), jsonString)\njsonDict = [\"null\" : NSNull()]\njsonString = \"{\\\"null\\\":null}\"\nXCTAssertEqual(jsonValue(jsonDict), jsonString)\n- jsonDict = [\"bool\" : true]\n+ jsonDict = [\"bool\" : true as AnyObject]\njsonString = \"{\\\"bool\\\":true}\"\nXCTAssertEqual(jsonValue(jsonDict), jsonString)\n}\n@@ -296,7 +296,7 @@ class AppContextTests: XCTestCase {\n})\ncontext.delegate = delegateMock\nlet port = 42\n- let _ = try? context.startUpdateAdvertisingAndListening(withParameters: [port])\n+ let _ = try? context.startUpdateAdvertisingAndListening(withParameters: [port as AnyObject])\nvalidateAdvertisingUpdate(delegateMock.advertisingListeningState, advertising: true,\nbrowsing: false)\n}\n@@ -314,7 +314,7 @@ class AppContextTests: XCTestCase {\nfunc testStartAdvertisingAndListeningInvokePeerAvailabilityChangedForDifferentContexts() {\ndo {\nlet foundPeerFromAnotherContextExpectation =\n- expectationWithDescription(\"found peer from another AppContext\")\n+ expectation(description: \"found peer from another AppContext\")\nlet delegateMock = AppContextDelegateMock {\n[weak foundPeerFromAnotherContextExpectation] peers in\nfoundPeerFromAnotherContextExpectation?.fulfill()\n@@ -326,10 +326,10 @@ class AppContextTests: XCTestCase {\nlet port = 42\ntry context1.startListeningForAdvertisements()\n- try context2.startUpdateAdvertisingAndListening(withParameters: [port])\n+ try context2.startUpdateAdvertisingAndListening(withParameters: [port as AnyObject])\n- let foundPeerTimeout: NSTimeInterval = 10\n- waitForExpectationsWithTimeout(foundPeerTimeout, handler: nil)\n+ let foundPeerTimeout: TimeInterval = 10\n+ waitForExpectations(timeout: foundPeerTimeout, handler: nil)\n} catch let error {\nXCTFail(\"unexpected error: \\(error)\")\n@@ -367,41 +367,41 @@ class AppContextTests: XCTestCase {\n}\n// MARK: Private helpers\n- @objc private func centralBluetoothManagerStateChanged(notification: NSNotification) {\n+ @objc fileprivate func centralBluetoothManagerStateChanged(_ notification: Notification) {\nif notification.name == Constants.NSNotificationName.centralBluetoothManagerDidChangeState {\nexpectationThatCoreBluetoothStateIsChanged?.fulfill()\nif let bluetoothChangingStateGroup = bluetoothChangingStateGroup {\n- dispatch_group_leave(bluetoothChangingStateGroup)\n+ bluetoothChangingStateGroup.leave()\n}\n}\n}\n- private func changeBluetoothState(to state: BluetoothHardwareState,\n- andWaitUntilChangesWithTimeout timeout: NSTimeInterval) {\n+ fileprivate func changeBluetoothState(to state: BluetoothHardwareState,\n+ andWaitUntilChangesWithTimeout timeout: TimeInterval) {\n- bluetoothChangingStateGroup = dispatch_group_create()\n+ bluetoothChangingStateGroup = DispatchGroup()\nexpectationThatBothBluetoothStatesAreChanged =\n- expectationWithDescription(\"Bluetooth is turned \\(state.rawValue)\")\n+ expectation(description: \"Bluetooth is turned \\(state.rawValue)\")\n// When we're switching bluetooth hardware, we're waiting for two async acknowledgements.\n// The first one is from private API, the second acknowledgement is from CoreBluetooth.\n// This is why we enter the same group twice\n- dispatch_group_enter(bluetoothChangingStateGroup!)\n- dispatch_group_enter(bluetoothChangingStateGroup!)\n+ bluetoothChangingStateGroup!.enter()\n+ bluetoothChangingStateGroup!.enter()\nstate == .on\n? BluetoothHardwareControlManager.sharedInstance().turnBluetoothOn()\n: BluetoothHardwareControlManager.sharedInstance().turnBluetoothOff()\n- dispatch_group_notify(\n- bluetoothChangingStateGroup!,\n- dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), {\n+ bluetoothChangingStateGroup!.notify(\n+ queue: DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background),\n+ execute: {\nself.privateAndPublicBluetoothStatesDidChanged()\n}\n)\n- waitForExpectationsWithTimeout(Constants.TimeForWhich.bluetoothStateIsChanged) {\n+ waitForExpectations(timeout: Constants.TimeForWhich.bluetoothStateIsChanged) {\nerror in\nXCTAssertNil(\nerror,\n@@ -413,7 +413,7 @@ class AppContextTests: XCTestCase {\nexpectationThatBothBluetoothStatesAreChanged = nil\n}\n- private func privateAndPublicBluetoothStatesDidChanged() {\n+ fileprivate func privateAndPublicBluetoothStatesDidChanged() {\nexpectationThatBothBluetoothStatesAreChanged?.fulfill()\n}\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update AppContext.swift and AppContextTests.swift files to Swift 3.0.
|
675,379 |
02.03.2017 17:46:30
| -10,800 |
fe848caf215660c34f8c730600f1256c2dceb4ac
|
Fixing critical SwiftLint issues.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/ios/Cartfile",
"diff": "+github \"thaliproject/thali-ios\" \"master\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/ios/AppContext.swift",
"new_path": "src/ios/AppContext.swift",
"diff": "//\n-// Thali CordovaPlugin\n// AppContext.swift\n+// Thali\n//\n// Copyright (C) Microsoft. All rights reserved.\n// Licensed under the MIT license.\n@@ -385,15 +385,6 @@ extension PeerAvailability {\npublic func connect(_ parameters: [AnyObject]) -> String {\nreturn jsonValue([JSONKey.err.rawValue : AppContextError.connectNotSupported.description])\n}\n-\n- #if TEST\n- func executeNativeTests() -> String {\n- let runner = TestRunner.`default`\n- runner.runTest()\n- return runner.resultDescription ?? \"\"\n- }\n- #endif\n-\n}\n// MARK: CBCentralManagerDelegate\n"
},
{
"change_type": "MODIFY",
"old_path": "src/ios/JXcoreExtension.m",
"new_path": "src/ios/JXcoreExtension.m",
"diff": "//\n-// Thali CordovaPlugin\n// JXcoreExtension.m\n+// Thali\n//\n// Copyright (C) Microsoft. All rights reserved.\n// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.\n#ifdef TEST\n- (void)defineExecuteNativeTests:(AppContext *)appContext {\n[JXcore addNativeBlock:^(NSArray *params, NSString *callbackId) {\n-#pragma clang diagnostic push\n-#pragma clang diagnostic ignored \"-Wundeclared-selector\"\n- if ([appContext respondsToSelector:@selector(executeNativeTests)]) {\n- NSString *result = [appContext performSelector:@selector(executeNativeTests)];\n-#pragma clang diagnostic pop\n+ id<TestRunnerProtocol> testRunner = (id<TestRunnerProtocol>)appContext;\n+\n+ if (testRunner != nil) {\n+ NSString *result = [testRunner runNativeTests];\n[JXcore callEventCallback:callbackId withJSON:result];\n- }\n- else {\n+ } else {\n[JXcore callEventCallback:callbackId withParams:@[@\"Method not available\"]];\n}\n} withName:[AppContextJSEvent executeNativeTests]];\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/ios/TestRunnerProtocol.swift",
"diff": "+//\n+// AppTestRunnerProtocol.swift\n+// Thali\n+//\n+// Copyright (C) Microsoft. All rights reserved.\n+// Licensed under the MIT license.\n+// See LICENSE.txt file in the project root for full license information.\n+//\n+\n+@objc\n+protocol TestRunnerProtocol {\n+\n+ func runNativeTests() -> String\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/ios/Testing/AppContext+TestRuner.swift",
"diff": "+//\n+// AppContext+TestRuner.swift\n+// Thali\n+//\n+// Copyright (C) Microsoft. All rights reserved.\n+// Licensed under the MIT license.\n+// See LICENSE.txt file in the project root for full license information.\n+//\n+\n+import Foundation\n+import SwiftXCTest\n+import ThaliCore\n+import ThaliCoreCITests\n+\n+extension AppContext: TestRunnerProtocol {\n+\n+ func runNativeTests() -> String {\n+ let rootTestSuite = XCTestSuite(name: \"All tests\")\n+\n+ let currentTestSuite = XCTestSuite(\n+ name: \"All tests\",\n+ testCases: [\n+ ThaliCore.allTestCases,\n+ [testCase(AppContextTests.allTests)]\n+ ].flatMap { $0 }\n+ )\n+\n+ rootTestSuite.addTest(currentTestSuite)\n+\n+ let runner = TestRunner(testSuite: rootTestSuite)\n+ runner.runTest()\n+ return runner.resultDescription ?? \"\"\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/ios/Testing/AppContextTests.swift",
"new_path": "src/ios/Testing/AppContextTests.swift",
"diff": "//\n-// Thali CordovaPlugin\n// AppContextTests.swift\n+// Thali\n//\n// Copyright (C) Microsoft. All rights reserved.\n// Licensed under the MIT license.\n// See LICENSE.txt file in the project root for full license information.\n//\n+import SwiftXCTest\nimport ThaliCore\n-import XCTest\n+import ThaliCoreCITests\nimport UIKit\n// MARK: - Random string generator\n@@ -165,6 +166,25 @@ class AppContextDelegateMock: NSObject, AppContextDelegate {\n// MARK: - Test cases\nclass AppContextTests: XCTestCase {\n+ static var allTests = {\n+ return [\n+ (\"test_willEnterBackground\", testWillEnterBackground),\n+ (\"test_didEnterForeground\", testDidEnterForeground),\n+ (\"test_didRegisterToNative\", testDidRegisterToNative),\n+ (\"test_getIOSVersion\", testGetIOSVersion),\n+ (\"test_thaliCoreErrors\", testThaliCoreErrors),\n+ (\"test_errorDescription\", testErrorDescription),\n+ (\"test_esonValue\", testJsonValue),\n+ (\"test_listeningAdvertisingUpdateOnStartAdvertising\", testListeningAdvertisingUpdateOnStartAdvertising),\n+ (\"test_listeningAdvertisingUpdateOnStartListening\", testListeningAdvertisingUpdateOnStartListening),\n+ (\"test_startAdvertisingAndListeningInvokePeerAvailabilityChangedForDifferentContexts\",\n+ testStartAdvertisingAndListeningInvokePeerAvailabilityChangedForDifferentContexts),\n+ (\"test_peerAvailabilityConversion\", testPeerAvailabilityConversion),\n+ (\"test_disconnectErrors\", testDisconnectErrors),\n+ (\"test_connectReturnValueCorrect\", testConnectReturnValueCorrect),\n+ ]\n+ }()\n+\nvar context: AppContext! = nil\nweak var expectationThatPrivateBluetoothStateIsChanged: XCTestExpectation?\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/install/ios/build-ci.xcconfig",
"new_path": "thali/install/ios/build-ci.xcconfig",
"diff": "//\nHEADER_SEARCH_PATHS = \"$(TARGET_BUILD_DIR)/usr/local/lib/include\" \"$(OBJROOT)/UninstalledProducts/include\" \"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include\" \"$(BUILT_PRODUCTS_DIR)\"\n-IPHONEOS_DEPLOYMENT_TARGET = 8.0\n+IPHONEOS_DEPLOYMENT_TARGET = 9.0\nOTHER_LDFLAGS = -ObjC\nTARGETED_DEVICE_FAMILY = 1,2\n+SWIFT_VERSION = 3.0\n// Type of signing identity used for codesigning, resolves to first match of given type.\n// \"iPhone Developer\": Development builds (default, local only; iOS Development certificate) or \"iPhone Distribution\": Distribution builds (Adhoc/In-House/AppStore; iOS Distribution certificate)\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/install/package.json",
"new_path": "thali/install/package.json",
"diff": "\"lie\": \"3.1.0\",\n\"request\": \"2.74.0\",\n\"unzip\": \"0.1.11\",\n- \"xcode\": \"0.8.9\"\n+ \"xcode\": \"https://github.com/alunny/node-xcode.git#4cca2f6225c391b63324e6eb53421560649d4f98\"\n},\n\"scripts\": {\n\"setupUnit\": \"./setUpTests.sh UnitTest_app.js\",\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/install/setUpTests.sh",
"new_path": "thali/install/setUpTests.sh",
"diff": "@@ -10,8 +10,6 @@ set -euo pipefail\ntrap 'log_error $LINENO' ERR\n-TEST_PROJECT_NAME=ThaliTest\n-\n# The first argument must be the name of the test file to make into the app.js\n# The second argument is optional and specifies a string with an IP address to\n# manually set the coordination server's address to.\n@@ -21,13 +19,15 @@ TEST_PROJECT_NAME=ThaliTest\ncd `dirname $0`\ncd ../..\nREPO_ROOT_DIR=$(pwd)\n-TEST_PROJECT_ROOT_DIR=${REPO_ROOT_DIR}/../${TEST_PROJECT_NAME}\n+PROJECT_NAME=${TEST_PROJECT_NAME:-ThaliTest}\n+PROJECT_ROOT_DIR=${REPO_ROOT_DIR}/../${PROJECT_NAME}\n+PROJECT_ID=${TEST_PROJECT_ID:-com.thaliproject.thalitest}\n# Prepares test project\nprepare_project()\n{\necho \"\"\n- echo \"start preparing ${TEST_PROJECT_NAME} Cordova project\"\n+ echo \"start preparing ${PROJECT_NAME} Cordova project\"\nIPADDRESS=${1:-}\nnpm install --no-optional --production --prefix $REPO_ROOT_DIR/thali/install\n@@ -37,34 +37,37 @@ prepare_project()\nnpm install --no-optional\nnode generateServerAddress.js $IPADDRESS\ncd $REPO_ROOT_DIR/..\n- cordova create $TEST_PROJECT_NAME com.test.thalitest $TEST_PROJECT_NAME\n- mkdir -p $TEST_PROJECT_NAME/thaliDontCheckIn/localdev\n+ cordova create $PROJECT_NAME $PROJECT_ID $PROJECT_NAME\n+ mkdir -p $PROJECT_ROOT_DIR/thaliDontCheckIn/localdev\nif is_minigw_platform; then\n# The thali package might be installed as link and there will\n# be troubles later on if this link is tried to be copied so\n# remove it here.\nrm -rf $REPO_ROOT_DIR/test/www/jxcore/node_modules/thali\n- cp -R $REPO_ROOT_DIR/test/www/ $TEST_PROJECT_NAME/\n+ cp -R $REPO_ROOT_DIR/test/www/ $PROJECT_ROOT_DIR/\nelse\n- rsync -a --no-links $REPO_ROOT_DIR/test/www/ $TEST_PROJECT_NAME/www\n+ rsync -a --no-links $REPO_ROOT_DIR/test/www/ $PROJECT_ROOT_DIR/www\nfi\n+ echo \"start installing SSDPReplacer\"\ncd $REPO_ROOT_DIR/thali/install/SSDPReplacer\nnpm install --no-optional\n- cd $REPO_ROOT_DIR/../$TEST_PROJECT_NAME\n+ cd $PROJECT_ROOT_DIR\ncordova plugin add $REPO_ROOT_DIR/thali/install/SSDPReplacer\n+ echo \"end installing SSDPReplacer\"\n+ echo \"\"\n- echo \"end preparing ${TEST_PROJECT_NAME} Cordova project\"\n+ echo \"end preparing ${PROJECT_NAME} Cordova project\"\necho \"\"\n}\ninstall_thali()\n{\necho \"\"\n- echo \"start installing Thali into ${TEST_PROJECT_NAME}\"\n+ echo \"start installing Thali into ${PROJECT_NAME}\"\n- cd $TEST_PROJECT_ROOT_DIR/www/jxcore\n+ cd $PROJECT_ROOT_DIR/www/jxcore\nnode installCustomPouchDB.js\njx install $REPO_ROOT_DIR/thali --save --no-optional\nfind . -name \"*.gz\" -delete\n@@ -99,9 +102,9 @@ install_thali()\nadd_android_platform()\n{\necho \"\"\n- echo \"start adding Android platform into ${TEST_PROJECT_NAME}\"\n+ echo \"start adding Android platform into ${PROJECT_NAME}\"\n- cd $TEST_PROJECT_ROOT_DIR\n+ cd $PROJECT_ROOT_DIR\ncordova platform add android\n@@ -115,13 +118,13 @@ add_android_platform()\nbuild_android()\n{\necho \"\"\n- echo \"start building ${TEST_PROJECT_NAME} Android app\"\n+ echo \"start building ${PROJECT_NAME} Android app\"\n- cd $TEST_PROJECT_ROOT_DIR\n+ cd $PROJECT_ROOT_DIR\ncordova build android --release --device\n- echo \"end building ${TEST_PROJECT_NAME} Android app\"\n+ echo \"end building ${PROJECT_NAME} Android app\"\necho \"\"\n}\n@@ -130,9 +133,9 @@ add_ios_platform_if_possible()\n{\nif is_darwin_platform; then\necho \"\"\n- echo \"start adding iOS platform into ${TEST_PROJECT_NAME}\"\n+ echo \"start adding iOS platform into ${PROJECT_NAME}\"\n- cd $TEST_PROJECT_ROOT_DIR\n+ cd $PROJECT_ROOT_DIR\ncordova platform add ios\n@@ -150,11 +153,13 @@ add_ios_platform_if_possible()\n# Builds iOS platform when we're running on macOS\nbuild_ios_if_possible()\n{\n+ local IOS_PROJECT_DIR=$PROJECT_ROOT_DIR/platforms/ios\n+\nif is_darwin_platform; then\necho \"\"\n- echo \"start building ${TEST_PROJECT_NAME} iOS app\"\n+ echo \"start building ${PROJECT_NAME} iOS app\"\n- cd $TEST_PROJECT_ROOT_DIR\n+ cd $PROJECT_ROOT_DIR\n# cordova really doesn't have any flexibility in making builds via CLAIM\n# they're using their xcconfig that doesn't work in our case\n@@ -172,26 +177,31 @@ build_ios_if_possible()\ncordova prepare ios --device\n- TEST_PROJECT_DIR=$TEST_PROJECT_ROOT_DIR/platforms/ios\n- TEST_PROJECT_PATH=$TEST_PROJECT_DIR/$TEST_PROJECT_NAME.xcodeproj\n-\n- echo \"\"\n- echo \"building project: ${TEST_PROJECT_PATH}\"\n+ # TODO: we need new cordova release to make it work\n+ # (\\\n+ # cd $IOS_PROJECT_DIR && \\\n+ # cordova build --device -d \\\n+ # --buildFlag=\"DEVELOPMENT_TEAM=${TEST_DEVELOPMENT_TEAM:-3648SALNRR}\" \\\n+ # --buildFlag=\"GCC_PREPROCESSOR_DEFINITIONS=DEBUG=1 TEST=1\" \\\n+ # --buildFlag=\"OTHER_SWIFT_FLAGS='-DTEST'\" \\\n+ # --buildFlag=\"SWIFT_VERSION='3.0'\"\n+ # )\n(\\\n- cd $TEST_PROJECT_DIR && \\\n+ cd $IOS_PROJECT_DIR && \\\nxcodebuild \\\n-xcconfig $REPO_ROOT_DIR/thali/install/ios/build-ci.xcconfig \\\n- -project $TEST_PROJECT_NAME.xcodeproj \\\n- -target $TEST_PROJECT_NAME \\\n+ -workspace $PROJECT_NAME.xcworkspace \\\n+ -scheme $PROJECT_NAME \\\n-configuration Debug \\\n- -destination 'platform=iOS' \\\n+ -sdk 'iphoneos' \\\nbuild \\\n- CONFIGURATION_BUILD_DIR=\"${TEST_PROJECT_DIR}/build/device\" \\\n- SHARED_PRECOMPS_DIR=\"${TEST_PROJECT_DIR}/build/sharedpch\" \\\n+ CONFIGURATION_BUILD_DIR=\"${IOS_PROJECT_DIR}/build/device\" \\\n+ SHARED_PRECOMPS_DIR=\"${IOS_PROJECT_DIR}/build/sharedpch\" \\\n+ DEVELOPMENT_TEAM=\"${TEST_DEVELOPMENT_TEAM:-3648SALNRR}\" \\\n)\n- echo \"end building ${TEST_PROJECT_NAME} iOS app\"\n+ echo \"end building ${PROJECT_NAME} iOS app\"\necho \"\"\nfi\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fixing critical SwiftLint issues.
|
675,378 |
03.03.2017 17:53:37
| -10,800 |
b04069281aa4bf21c6d59512e822dce0707aa72a
|
Fixing thaliWifiInfrastructure.startUpdateAdvertisingAndListening should not restart the SSDP server
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -826,3 +826,23 @@ function (t) {\n});\ntestUtils.toggleWifi(false);\n});\n+\n+test('SSDP server should not restart after Wifi Client changed generation',\n+ function (t) {\n+ var advertisingEndSpy =\n+ sinon.spy(wifiInfrastructure.advertiser, 'stop');\n+ wifiInfrastructure.startListeningForAdvertisements()\n+ .then(function () {\n+ return wifiInfrastructure.startUpdateAdvertisingAndListening();\n+ })\n+ .then(function () {\n+ t.equals(advertisingEndSpy.callCount, 0, 'SDDP server does not restart');\n+ })\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\n+ t.end();\n+ });\n+ }\n+);\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -364,16 +364,12 @@ WifiAdvertiser.prototype.update = enqueued(function () {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- // We need to restart the server so that a byebye is issued for the old USN\n- // and alive message for the new one.\n- return self._server.stopAsync()\n- .then(function () {\n+ // We need to change USN every time a WifiClient changed generation\nself.peer.generation++;\n- return self._startPeerAdvertising(self.peer);\n- })\n- .catch(function (error) {\n- return self._errorStop(error);\n- });\n+ var usn = USN.stringify(self.peer);\n+ self._server.setUSN(usn);\n+\n+ return Promise.resolve();\n});\n/**\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fixing thaliWifiInfrastructure.startUpdateAdvertisingAndListening should not restart the SSDP server
|
675,383 |
06.03.2017 13:19:11
| -10,800 |
d0ae79d916d713cc75ba9a0cfd14490a4755229f
|
Update jxcore version
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/validateBuildEnvironment.js",
"new_path": "thali/install/validateBuildEnvironment.js",
"diff": "@@ -21,7 +21,7 @@ const versions =\nbrew: '1.1.',\nruby: '2.3.0p0',\nwget: '1.18',\n- jxcore: '0.3.1.8',\n+ jxcore: '0.3.1.10',\nandroidHome: ' ',\nandroidBuildTools: thaliConfig.thaliInstall.androidConfig.buildToolsVersion,\nandroidPlatform: thaliConfig.thaliInstall.androidConfig.compileSdkVersion,\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update jxcore version
|
675,381 |
27.02.2017 21:38:59
| -10,800 |
5b8d96fb1a87ffd10bc59946804b7eadad40921b
|
Fix inconsistent ThaliPeerPool enqueue API
1. Makes all ThaliPeerPoolInterface implementations to always throw when
invalid action is being enqueued.
2. Updates thaliNotificationClient to use `try-catch` instead of
checking returned value
Fixes
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliPeerPoolDefault.js",
"new_path": "test/www/jxcore/bv_tests/testThaliPeerPoolDefault.js",
"diff": "@@ -216,9 +216,12 @@ test('#ThaliPeerPoolDefault - stop', function (t) {\nvar testAction3 = new TestPeerAction(\npeerIdentifier, connectionType, actionType, t\n);\n- var error = testThaliPeerPoolDefault.enqueue(testAction3);\n- t.equal(\n- error.message, ThaliPeerPoolDefault.ERRORS.ENQUEUE_WHEN_STOPPED,\n+\n+ t.throws(\n+ function () {\n+ testThaliPeerPoolDefault.enqueue(testAction3);\n+ },\n+ new RegExp(ThaliPeerPoolDefault.ERRORS.ENQUEUE_WHEN_STOPPED),\n'enqueue is not available when stopped'\n);\n@@ -241,5 +244,5 @@ test('#ThaliPeerPoolDefault - stop', function (t) {\n);\nt.end();\n- })\n+ });\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliPeerPoolOneAtATime.js",
"new_path": "test/www/jxcore/bv_tests/testThaliPeerPoolOneAtATime.js",
"diff": "@@ -24,7 +24,8 @@ var test = tape({\nsetup: function (t) {\nvar ProxyPool =\nproxyquire('thali/NextGeneration/thaliPeerPool/thaliPeerPoolOneAtATime',\n- { '../thaliMobileNativeWrapper': {\n+ {\n+ '../thaliMobileNativeWrapper': {\n_getServersManager: function () {\nreturn {\nterminateOutgoingConnection: function () {\n@@ -113,9 +114,13 @@ function didNotCall(t, connectionType, actionType, errMessagePrefix) {\nvar startSpy = sinon.spy(action, 'start');\nvar killSpy = sinon.spy(action, 'kill');\ntestThaliPeerPoolOneAtATime.start();\n- var enqueueResult = testThaliPeerPoolOneAtATime.enqueue(action);\n- t.ok(enqueueResult.message.indexOf(errMessagePrefix) ===\n- 0, 'Got right error');\n+ t.throws(\n+ function () {\n+ testThaliPeerPoolOneAtATime.enqueue(action);\n+ },\n+ new RegExp('^Error: ' + errMessagePrefix),\n+ 'Got right error'\n+ );\nt.notOk(startSpy.called, 'Start should not be called');\nt.ok(killSpy.called, 'Kill should have been called at least once');\nt.end();\n@@ -304,15 +309,16 @@ test('Replication goes first',\n}, function (t) {\nvar notificationAction = new TestPeerAction('notificationAction',\nconnectionTypes.BLUETOOTH, ThaliNotificationAction.ACTION_TYPE, t);\n- notificationAction.actionBeforeStartReturn = function () {\n- t.notOk(testThaliPeerPoolOneAtATime.enqueue(replicationAction), 'Null 3');\n- return Promise.resolve();\n- };\nvar replicationAction = new TestPeerAction('replicationAction',\nconnectionTypes.BLUETOOTH, ThaliReplicationAction.ACTION_TYPE, t);\nvar notificationAction2 = new TestPeerAction('notificationAction',\nconnectionTypes.BLUETOOTH, ThaliNotificationAction.ACTION_TYPE, t);\n+ notificationAction.actionBeforeStartReturn = function () {\n+ t.notOk(testThaliPeerPoolOneAtATime.enqueue(replicationAction), 'Null 3');\n+ return Promise.resolve();\n+ };\n+\ntestThaliPeerPoolOneAtATime.start();\nt.notOk(testThaliPeerPoolOneAtATime.enqueue(notificationAction), 'Null 1');\nt.notOk(testThaliPeerPoolOneAtATime.enqueue(notificationAction2, 'null 2'));\n@@ -429,8 +435,14 @@ test('wifi allows many parallel non-replication actions', function (t) {\n};\ntestThaliPeerPoolOneAtATime.start();\n- t.notOk(testThaliPeerPoolOneAtATime.enqueue(action1), 'First null');\n- t.notOk(testThaliPeerPoolOneAtATime.enqueue(action2), 'Second null');\n+\n+ t.doesNotThrow(function () {\n+ testThaliPeerPoolOneAtATime.enqueue(action1);\n+ }, 'First does not throw');\n+ t.doesNotThrow(function () {\n+ testThaliPeerPoolOneAtATime.enqueue(action2);\n+ }, 'Second does not throw');\n+\naction1.startPromise\n.then(function () {\nreturn action2.startPromise;\n@@ -514,8 +526,14 @@ test('wifi allows no more than 2 simultaneous replication actions for same ' +\n};\ntestThaliPeerPoolOneAtATime.start();\n- t.notOk(testThaliPeerPoolOneAtATime.enqueue(action1), 'First null');\n- t.notOk(testThaliPeerPoolOneAtATime.enqueue(action2), 'second null');\n- t.notOk(testThaliPeerPoolOneAtATime.enqueue(action3), 'third null');\n+ t.doesNotThrow(function () {\n+ testThaliPeerPoolOneAtATime.enqueue(action1);\n+ }, 'first ok');\n+ t.doesNotThrow(function () {\n+ testThaliPeerPoolOneAtATime.enqueue(action2);\n+ }, 'second ok');\n+ t.doesNotThrow(function () {\n+ testThaliPeerPoolOneAtATime.enqueue(action3);\n+ }, 'third ok');\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/notification/thaliNotificationClient.js",
"new_path": "thali/NextGeneration/notification/thaliNotificationClient.js",
"diff": "@@ -154,7 +154,6 @@ ThaliNotificationClient.prototype.start =\nthis._publicKeysToListen = [];\nthis._publicKeysToListenHashes = [];\n-\nthis._publicKeysToListen = publicKeysToListen;\npublicKeysToListen.forEach(function (pubKy) {\n@@ -162,7 +161,7 @@ ThaliNotificationClient.prototype.start =\nNotificationBeacons.createPublicKeyHash(pubKy));\n});\n- if (!this.peerDictionary) {\n+ if (!this._isStarted()) {\nThaliMobile.emitter.on('peerAvailabilityChanged',\nthis._boundListener);\n}\n@@ -178,7 +177,8 @@ ThaliNotificationClient.prototype.start =\n* @public\n*/\nThaliNotificationClient.prototype.stop = function () {\n- if (this.peerDictionary) {\n+ if (this._isStarted()) {\n+ assert(this.peerDictionary, 'peer dictionary exists');\nThaliMobile.emitter.removeListener('peerAvailabilityChanged',\nthis._boundListener);\n@@ -210,11 +210,7 @@ ThaliNotificationClient.prototype._peerAvailabilityChanged =\nfunction (peerStatus) {\nvar self = this;\n- if (!this.peerDictionary) {\n- logger.warn('no dictionary');\n- return;\n- }\n-\n+ assert(self.peerDictionary, 'peer dictionary exists');\nassert(peerStatus, 'peerStatus must not be null or undefined');\nassert(peerStatus.peerIdentifier, 'peerIdentifier must be set');\nassert(peerStatus.connectionType, 'connectionType must be set');\n@@ -238,6 +234,14 @@ ThaliNotificationClient.prototype._peerAvailabilityChanged =\n});\n};\n+/**\n+ * @private\n+ * @return {boolean}\n+ */\n+ThaliNotificationClient.prototype._isStarted = function () {\n+ return Boolean(this.peerDictionary);\n+};\n+\n/**\n* This function creates a new action and sets connection info into it.\n* Then it enqueues the action in the peer pool and adds the entry into\n@@ -264,13 +268,12 @@ ThaliNotificationClient.prototype._createNotificationAction =\npeerEntry.notificationAction = action;\n- var enqueueError = this._thaliPeerPoolInterface.enqueue(action);\n-\n- if (!enqueueError) {\n+ try {\n+ this._thaliPeerPoolInterface.enqueue(action);\nthis.peerDictionary.addUpdateEntry(peer, peerEntry);\n- } else {\n+ } catch (error) {\nlogger.warn('_createAndEnqueueAction: failed to enqueue an item: %s',\n- enqueueError.message);\n+ error.message);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault.js",
"new_path": "thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault.js",
"diff": "@@ -77,7 +77,7 @@ ThaliPeerPoolDefault.ERRORS.ENQUEUE_WHEN_STOPPED =\nThaliPeerPoolDefault.prototype.enqueue = function (peerAction) {\nif (this._stopped) {\npeerAction.kill();\n- return new Error(ThaliPeerPoolDefault.ERRORS.ENQUEUE_WHEN_STOPPED);\n+ throw new Error(ThaliPeerPoolDefault.ERRORS.ENQUEUE_WHEN_STOPPED);\n}\n// Right now we will just allow everything to run parallel.\n@@ -117,6 +117,7 @@ ThaliPeerPoolDefault.prototype.start = function () {\n* kill any actions that this pool has started that haven't already been\n* killed. It will also return errors if any further attempts are made\n* to enqueue.\n+ * @return {Promise}\n*/\nThaliPeerPoolDefault.prototype.stop = function () {\nthis._stopped = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliPeerPool/thaliPeerPoolOneAtATime.js",
"new_path": "thali/NextGeneration/thaliPeerPool/thaliPeerPoolOneAtATime.js",
"diff": "@@ -161,7 +161,7 @@ ThaliPeerPoolOneAtATime.prototype._bluetoothReplicationAction = null;\n* Runs the replication action and if it fails for a reason other than a\n* timeout and if the peer is still available (meaning the connection has not\n* been lost) then we will retry the replication.\n- * @param replicationAction\n+ * @param {module:thaliPeerAction~PeerAction} replicationAction\n* @returns {Promise.<null>}\n* @private\n*/\n@@ -235,7 +235,7 @@ ThaliPeerPoolOneAtATime.prototype._bluetoothEnqueue = function (peerAction) {\npeerAction.getActionType());\nlogger.error(error.message);\npeerAction.kill();\n- return error;\n+ throw error;\n}\nself._bluetoothSerialPromiseQueue.enqueue(function (resolve) {\n@@ -273,37 +273,32 @@ ThaliPeerPoolOneAtATime.prototype._bluetoothEnqueue = function (peerAction) {\nThaliPeerPoolOneAtATime.prototype.enqueue = function (peerAction) {\nif (this._stopped) {\npeerAction.kill();\n- return new Error(ThaliPeerPoolOneAtATime.ERRORS.ENQUEUE_WHEN_STOPPED);\n+ throw new Error(ThaliPeerPoolOneAtATime.ERRORS.ENQUEUE_WHEN_STOPPED);\n}\n- var result =\nThaliPeerPoolOneAtATime.super_.prototype.enqueue.apply(this, arguments);\n- if (result) {\n- return result;\n- }\n-\nswitch (peerAction.getConnectionType()) {\n// MPCF is here because right now master doesn't really know how to set\n// the mock type to anything but Android\ncase thaliMobileNativeWrapper.connectionTypes\n.MULTI_PEER_CONNECTIVITY_FRAMEWORK:\ncase thaliMobileNativeWrapper.connectionTypes.BLUETOOTH: {\n- result = this._bluetoothEnqueue(peerAction);\n+ this._bluetoothEnqueue(peerAction);\nbreak;\n}\ncase thaliMobileNativeWrapper.connectionTypes.TCP_NATIVE: {\n- result = this._wifiEnqueue(peerAction);\n+ this._wifiEnqueue(peerAction);\nbreak;\n}\ndefault: {\npeerAction.kill();\n- result = new Error('Got unrecognized connection type: ' +\n+ throw new Error('Got unrecognized connection type: ' +\npeerAction.getConnectionType());\nbreak;\n}\n}\n- return result instanceof Error ? result : null;\n+ return null;\n};\nThaliPeerPoolOneAtATime.prototype.start = function () {\n@@ -318,6 +313,7 @@ ThaliPeerPoolOneAtATime.prototype.start = function () {\n* kill any actions that this pool has started that haven't already been\n* killed. It will also return errors if any further attempts are made\n* to enqueue.\n+ * @return {Promise}\n*/\nThaliPeerPoolOneAtATime.prototype.stop = function () {\nlogger.debug('Stop was called');\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix inconsistent ThaliPeerPool enqueue API
1. Makes all ThaliPeerPoolInterface implementations to always throw when
invalid action is being enqueued.
2. Updates thaliNotificationClient to use `try-catch` instead of
checking returned value
Fixes #1813.
|
675,381 |
28.02.2017 16:14:57
| -10,800 |
8d951ef7ae1c0b7565895e9823e6378ad051efab
|
Add errors handling test for notification client
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js",
"diff": "@@ -446,6 +446,37 @@ test('Resolves an action locally', function (t) {\nnotificationClient._peerAvailabilityChanged(globals.TCPEvent);\n});\n+test('Ignores errors thrown by peerPool.enqueue', function (t) {\n+ var getPeerHostInfoStub = stubGetPeerHostInfo();\n+ var peerPool = {\n+ enqueue: function () {\n+ throw new Error('oops');\n+ }\n+ };\n+\n+ var notificationClient =\n+ new ThaliNotificationClient(peerPool,\n+ globals.sourceKeyExchangeObject, function () {});\n+\n+ notificationClient.start([]);\n+\n+ var TCPEvent = {\n+ peerIdentifier: 'id3212',\n+ peerAvailable: true,\n+ newAddressPort: true,\n+ generation: 0,\n+ connectionType: ThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE\n+ };\n+\n+ t.doesNotThrow(function () {\n+ notificationClient._peerAvailabilityChanged(TCPEvent);\n+ });\n+\n+ notificationClient.stop();\n+ getPeerHostInfoStub.restore();\n+ t.end();\n+});\n+\ntest('Resolves an action locally using ThaliPeerPoolDefault', function (t) {\n// Scenario:\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add errors handling test for notification client
|
675,381 |
02.03.2017 20:29:55
| -10,800 |
24a1dd69852805e6367b41134926d0c1003a508f
|
Improve actions enqueuing errors handling.
thaliNotificationClient and thaliPullReplicationFromNotification don't
ignore enqueue errors anymore, these errors are emitted with 'error'
event
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js",
"diff": "@@ -446,7 +446,12 @@ test('Resolves an action locally', function (t) {\nnotificationClient._peerAvailabilityChanged(globals.TCPEvent);\n});\n-test('Ignores errors thrown by peerPool.enqueue', function (t) {\n+test('Emits error event when peerPool.enqueue throws', function (t) {\n+\n+ // This test should get error event almost instantly. We don't need to wait\n+ // default several minutes timeout\n+ t.timeoutAfter(20);\n+\nvar getPeerHostInfoStub = stubGetPeerHostInfo();\nvar peerPool = {\nenqueue: function () {\n@@ -468,15 +473,18 @@ test('Ignores errors thrown by peerPool.enqueue', function (t) {\nconnectionType: ThaliMobileNativeWrapper.connectionTypes.TCP_NATIVE\n};\n- t.doesNotThrow(function () {\n- notificationClient._peerAvailabilityChanged(TCPEvent);\n- });\n-\n+ notificationClient.once('error', function (error) {\n+ t.equal(error.message, 'oops', 'Correct error');\nnotificationClient.stop();\ngetPeerHostInfoStub.restore();\nt.end();\n});\n+ // trigger error\n+ notificationClient._peerAvailabilityChanged(TCPEvent);\n+\n+});\n+\ntest('Resolves an action locally using ThaliPeerPoolDefault', function (t) {\n// Scenario:\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliPullReplicationFromNotification.js",
"new_path": "test/www/jxcore/bv_tests/testThaliPullReplicationFromNotification.js",
"diff": "@@ -53,10 +53,6 @@ var test = tape({\n});\ntest('Make sure peerDictionaryKey is reasonable', function (t) {\n- var thaliPullReplicationFromNotification =\n- new ThaliPullReplicationFromNotification(LevelDownPouchDB,\n- testUtils.getRandomPouchDBName(), {}, devicePublicPrivateKey);\n-\nvar key1 =\nThaliPullReplicationFromNotification._getPeerDictionaryKey({\nconnectionType: 'foo',\n@@ -242,6 +238,37 @@ test('Make sure stop works', function (t) {\n});\n});\n+test('Emits error event when peerPool.enqueue throws', function (t) {\n+ t.timeoutAfter(20);\n+\n+ var peerPool = {\n+ enqueue: function () {\n+ throw new Error('oops');\n+ }\n+ };\n+\n+ var thaliPullReplicationFromNotification =\n+ new ThaliPullReplicationFromNotification(\n+ LevelDownPouchDB,\n+ testUtils.getRandomPouchDBName(),\n+ peerPool,\n+ devicePublicPrivateKey\n+ );\n+\n+ thaliPullReplicationFromNotification.once('error', function (error) {\n+ t.equal(error.message, 'oops', 'Correct error');\n+ thaliPullReplicationFromNotification.stop();\n+ t.end();\n+ });\n+\n+ // simulate event receiving to trigger action enqueueing\n+ thaliPullReplicationFromNotification._peerAdvertisesDataForUsHandler({\n+ connectionType: 'x',\n+ keyId: 'y',\n+ portNumber: 9999\n+ });\n+});\n+\nfunction matchEntryInDictionary(t, thaliPullReplicationFromNotification, fakeAd,\nspyAction) {\nvar actionKey =\n@@ -333,8 +360,7 @@ test('Simple peer event', function (t) {\n}\ninherits(MockThaliReplicationPeerAction, ThaliReplicationPeerAction);\n- var ProxiesPullReplication = proxyquire.noCallThru()\n- .load(\n+ var ProxiesPullReplication = proxyquire.noCallThru().load(\n'thali/NextGeneration/replication/thaliPullReplicationFromNotification',\n{\n'./thaliReplicationPeerAction': MockThaliReplicationPeerAction\n@@ -364,8 +390,8 @@ test('Simple peer event', function (t) {\nlistener(fakeAd);\nvar firstAction = peerActions[0];\ncheckPeerCreation(t, 1,\n- thaliPullReplicationFromNotification, fakePool.enqueue.getCall(0), firstAction,\n- fakeAd, fakeDbName);\n+ thaliPullReplicationFromNotification, fakePool.enqueue.getCall(0),\n+ firstAction, fakeAd, fakeDbName);\n// Start second action just to make sure it gets added\nvar fakeAd2 = {\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/notification/thaliNotificationClient.js",
"new_path": "thali/NextGeneration/notification/thaliNotificationClient.js",
"diff": "@@ -272,8 +272,7 @@ ThaliNotificationClient.prototype._createNotificationAction =\nthis._thaliPeerPoolInterface.enqueue(action);\nthis.peerDictionary.addUpdateEntry(peer, peerEntry);\n} catch (error) {\n- logger.warn('_createAndEnqueueAction: failed to enqueue an item: %s',\n- error.message);\n+ this.emit('error', error);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/replication/thaliPullReplicationFromNotification.js",
"new_path": "thali/NextGeneration/replication/thaliPullReplicationFromNotification.js",
"diff": "'use strict';\n+var assert = require('assert');\n+var EventEmitter = require('events').EventEmitter;\n+var inherits = require('util').inherits;\n+\nvar ThaliNotificationClient = require('../notification/thaliNotificationClient');\nvar logger = require('../../ThaliLogger')('thaliPullReplicationFromNotification');\n-var assert = require('assert');\nvar PeerAction = require('../thaliPeerPool/thaliPeerAction');\nvar ThaliReplicationPeerAction = require('./thaliReplicationPeerAction');\n@@ -56,6 +59,8 @@ function ThaliPullReplicationFromNotification(PouchDB,\ndbName,\nthaliPeerPoolInterface,\necdhForLocalDevice) {\n+ EventEmitter.call(this);\n+\nassert(PouchDB, 'Must have PouchDB');\nassert(dbName, 'Must have dbName');\nassert(thaliPeerPoolInterface, 'Must have thaliPeerPoolInterface');\n@@ -73,6 +78,8 @@ function ThaliPullReplicationFromNotification(PouchDB,\nthis.state = ThaliPullReplicationFromNotification.STATES.CREATED;\n}\n+inherits(ThaliPullReplicationFromNotification, EventEmitter);\n+\n/**\n* This is a list of states for ThaliPullReplicationFromNotification.\n* @public\n@@ -137,10 +144,10 @@ ThaliPullReplicationFromNotification.prototype._peerAdvertisesDataForUsHandler =\nthis._peerDictionary[key] = newAction;\nthis._bindRemoveActionFromPeerDictionary(newAction, key);\n- var enqueueError = this._thaliPeerPoolInterface.enqueue(newAction);\n- if (enqueueError) {\n- logger.warn('_peerAdvertisesDataForUsHandler: failed to enqueue an item: %s',\n- enqueueError.message);\n+ try {\n+ this._thaliPeerPoolInterface.enqueue(newAction);\n+ } catch (error) {\n+ this.emit('error', error);\n}\n};\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Improve actions enqueuing errors handling.
thaliNotificationClient and thaliPullReplicationFromNotification don't
ignore enqueue errors anymore, these errors are emitted with 'error'
event
|
675,379 |
06.03.2017 15:13:15
| -10,800 |
4fcb1a955423f16a1c3909c7ff3f89b3a062bc86
|
Update thaliCoreProjectFolder in after_plugin_install.js hook.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/cordova-hooks/ios/after_plugin_install.js",
"new_path": "thali/install/cordova-hooks/ios/after_plugin_install.js",
"diff": "@@ -61,7 +61,7 @@ module.exports = function (context) {\n// We need to build ThaliCore.framework before embedding it into the project\nvar thaliCoreProjectFolder = path.join(\n- context.opts.plugin.dir, 'lib', 'ios', 'ThaliCore');\n+ context.opts.plugin.dir, 'lib', 'ios', 'Carthage', 'Checkouts', 'thali-ios');\nvar thaliCoreOutputFolder = path.join(\ncontext.opts.plugin.dir, 'lib', 'ios');\nvar testingInfrastructureDir = path.join(\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update thaliCoreProjectFolder in after_plugin_install.js hook.
|
675,378 |
06.03.2017 16:03:33
| -10,800 |
9a5471846a3571a0d6f349d550bd1f47b4009bc3
|
Remove addAvailabilityWatcherToPeerIfNotExist for peer type (Bluetooth)
|
[
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/mux/createNativeListener.js",
"new_path": "thali/NextGeneration/mux/createNativeListener.js",
"diff": "@@ -190,7 +190,6 @@ module.exports = function (self) {\n'<-> Mux - %d - error %s', localIncomingConnectionId, err);\n});\n- incoming.setTimeout(thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD);\nincoming.on('timeout', function () {\nlogger.debug('incoming - incoming Android TCP/IP client connection ' +\n'<-> Mux - %d - incoming socket timeout', localIncomingConnectionId);\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliConfig.js",
"new_path": "thali/NextGeneration/thaliConfig.js",
"diff": "@@ -34,7 +34,6 @@ module.exports = {\nSSDP_OWN_PEERS_HISTORY_SIZE: 10,\nPEER_AVAILABILITY_WATCHER_INTERVAL: 1000,\nTCP_PEER_UNAVAILABILITY_THRESHOLD: 5 * 500,\n- NON_TCP_PEER_UNAVAILABILITY_THRESHOLD: 1000 * 60 * 60 * 24 * 10, // TODO increase this timeout to 10 years when #1415 will be fixed.\nTCP_TIMEOUT_WIFI: 1000,\nTCP_TIMEOUT_BLUETOOTH: 5000,\nTCP_TIMEOUT_MPCF: 5000,\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobile.js",
"new_path": "thali/NextGeneration/thaliMobile.js",
"diff": "@@ -1186,9 +1186,7 @@ function watchForPeerAvailability (peer) {\nvar now = Date.now();\nvar unavailabilityThreshold =\n- connectionType === connectionTypes.TCP_NATIVE ?\n- thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD :\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD;\n+ thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n// If the time from the latest availability advertisement doesn't\n// exceed the threshold, no need to do anything.\n@@ -1208,9 +1206,7 @@ function addAvailabilityWatcherToPeerIfNotExist (peer) {\nvar connectionType = peer.connectionType;\nvar peerIdentifier = peer.peerIdentifier;\nvar unavailabilityThreshold =\n- connectionType === connectionTypes.TCP_NATIVE ?\n- thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD :\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD;\n+ thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n// No reason to check peer availability\n// more then once per unavailability threshold\n@@ -1260,8 +1256,10 @@ function changeCachedPeerUnavailable (peer) {\nfunction changeCachedPeerAvailable (peer) {\nvar cachedPeer = JSON.parse(JSON.stringify(peer));\npeerAvailabilities[peer.connectionType][peer.peerIdentifier] = cachedPeer;\n+ if (peer.connectionType === connectionTypes.TCP_NATIVE) {\naddAvailabilityWatcherToPeerIfNotExist(cachedPeer);\n}\n+}\nfunction changePeersUnavailable (connectionType) {\nObject.keys(peerAvailabilities[connectionType]).forEach(\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Remove addAvailabilityWatcherToPeerIfNotExist for peer type (Bluetooth)
|
675,378 |
06.03.2017 17:32:43
| -10,800 |
941266d0e3b57f79a78c73b8e0650272abe4c79c
|
Writing test ssdp client receives correct USN after we call startUpdateAdvertisingAndListening(), update according to the PR 1817
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -830,8 +830,11 @@ function (t) {\ntest('SSDP server should not restart after Wifi Client changed generation',\nfunction (t) {\nvar advertisingEndSpy =\n- sinon.spy(wifiInfrastructure.advertiser, 'stop');\n+ sinon.spy(wifiInfrastructure.advertiser._server, 'stop');\nwifiInfrastructure.startListeningForAdvertisements()\n+ .then(function () {\n+ return wifiInfrastructure.startUpdateAdvertisingAndListening();\n+ })\n.then(function () {\nreturn wifiInfrastructure.startUpdateAdvertisingAndListening();\n})\n@@ -846,3 +849,36 @@ test('SSDP server should not restart after Wifi Client changed generation',\n});\n}\n);\n+\n+test('SSDP client receives correct USN after #startUpdateAdvertisingAndListening called', function (t) {\n+ var testClient = new nodessdp.Client({\n+ ssdpIp: thaliConfig.SSDP_IP\n+ });\n+\n+ var ourUSN = null;\n+ var aliveCalled = false;\n+\n+ function finishTest() {\n+ testClient.stop();\n+ t.equals(aliveCalled, true, 'advertise-alive fired with expected usn');\n+ t.end();\n+ }\n+\n+ testClient.on('advertise-alive', function (data) {\n+ // Check for the Thali NT in case there is some other\n+ // SSDP traffic in the network.\n+ if (data.NT !== thaliConfig.SSDP_NT || data.USN !== ourUSN) {\n+ return;\n+ }\n+ aliveCalled = true;\n+ finishTest();\n+ });\n+\n+ testClient.start(function () {\n+ // This is the first call to the update function after which\n+ // some USN value should be advertised.\n+ wifiInfrastructure.startUpdateAdvertisingAndListening().then(function () {\n+ ourUSN = USN.stringify(wifiInfrastructure._getCurrentPeer());\n+ });\n+ });\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -331,7 +331,7 @@ WifiAdvertiser.prototype.start = enqueued(function (router, pskIdToSecret) {\nreturn self._setUpExpressApp(router, pskIdToSecret)\n.then(function () {\n- return self._startPeerAdvertising(self.peer);\n+ return self._setUSN(self.peer, true);\n})\n.then(function () {\nself._isAdvertising = true;\n@@ -348,10 +348,12 @@ WifiAdvertiser.prototype.start = enqueued(function (router, pskIdToSecret) {\n* @param {number} peer.generation\n* @return {Promise}\n*/\n-WifiAdvertiser.prototype._startPeerAdvertising = function (peer) {\n+WifiAdvertiser.prototype._setUSN = function (peer, startPeerAdvertising) {\nvar usn = USN.stringify(peer);\nthis._server.setUSN(usn);\n+ if (startPeerAdvertising) {\nreturn this._server.startAsync();\n+ }\n};\n/**\n@@ -366,8 +368,7 @@ WifiAdvertiser.prototype.update = enqueued(function () {\n// We need to change USN every time a WifiClient changed generation\nself.peer.generation++;\n- var usn = USN.stringify(self.peer);\n- self._server.setUSN(usn);\n+ self._setUSN(self.peer, false);\nreturn Promise.resolve();\n});\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Writing test ssdp client receives correct USN after we call startUpdateAdvertisingAndListening(), update according to the PR 1817
|
675,378 |
07.03.2017 15:54:49
| -10,800 |
9d3cf8c206b5afb8892233a2f3b57772cb846c78
|
Implement and update tests for
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -193,9 +193,11 @@ test('#stop should clear watchers and change peers', function (t) {\n});\n})\n.then(function () {\n+ if (connectionType !== connectionTypes.BLUETOOTH) {\nt.equal(Object.getOwnPropertyNames(\nThaliMobile._peerAvailabilityWatchers[connectionType]).length, 1,\n'Watchers have one entry for our connection type');\n+ }\nt.equal(Object.getOwnPropertyNames(\nThaliMobile._peerAvailabilities[connectionType]).length, 1,\n'Peer availabilities has one entry for our connection type');\n@@ -205,9 +207,11 @@ test('#stop should clear watchers and change peers', function (t) {\nObject.getOwnPropertyNames(connectionTypes)\n.forEach(function (connectionKey) {\nvar connectionType = connectionTypes[connectionKey];\n+ if (connectionType !== connectionTypes.BLUETOOTH) {\nt.equal(Object.getOwnPropertyNames(\nThaliMobile._peerAvailabilityWatchers[connectionType]).length,\n0, 'No watchers');\n+ }\nt.equal(Object.getOwnPropertyNames(\nThaliMobile._peerAvailabilities[connectionType]).length,\n0, 'No peers');\n@@ -428,56 +432,8 @@ test('wifi peer is marked unavailable if announcements stop',\n}\n);\n-test('native peer should be removed if no availability updates ' +\n-'were received during availability timeout',\n- function (t) {\n- var originalThreshold = thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD;\n- // Make the threshold a bit shorter so that the test doesn't\n- // have to wait for so long.\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD = 100;\n-\n- t.timeoutAfter(thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD * 3);\n-\n- var nativePeer = generateLowerLevelPeers().nativePeer;\n- var callCount = 0;\n-\n- var availabilityHandler = function (peerStatus) {\n- if (peerStatus.peerIdentifier !== nativePeer.peerIdentifier) {\n- return;\n- }\n- callCount++;\n-\n- switch (callCount) {\n- case 1:\n- t.equal(peerStatus.peerAvailable, true, 'peer is available');\n- break;\n- case 2:\n- t.equal(peerStatus.peerAvailable, false,\n- 'peer is not availabel because it was too silent');\n- // restore everything\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD = originalThreshold;\n- ThaliMobile.emitter\n- .removeListener('peerAvailabilityChanged', availabilityHandler);\n- t.end();\n- break;\n- }\n- };\n- ThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n-\n- ThaliMobile.start(express.Router()).then(function () {\n- emitNativePeerAvailability(nativePeer);\n- });\n- }\n-);\n-\ntest('peerAvailabilityChanged - peer added/removed to/from cache (native)',\nfunction (t) {\n- var timeout = Math.min(\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD / 2,\n- 30 * 1000\n- );\n- t.timeoutAfter(timeout);\n-\nvar nativePeer = generateLowerLevelPeers().nativePeer;\nvar callCount = 0;\nvar connectionType = getNativeConnectionType();\n@@ -1084,12 +1040,6 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\n// Expected result: fire peerAvailabilityChanged with native peer's id and\n// peerAvailable set to false\n- var timeout = Math.min(\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD / 2,\n- 30 * 1000\n- );\n- t.timeoutAfter(timeout);\n-\nvar testPeers = generateLowerLevelPeers();\nvar callCount = 0;\n@@ -1431,12 +1381,6 @@ test('newAddressPort field (BLUETOOTH)',\nreturn !platform.isAndroid;\n},\nfunction (t) {\n- var timeout = Math.min(\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD / 2,\n- 30 * 1000\n- );\n- t.timeoutAfter(timeout);\n-\nvar nativePeer = generateLowerLevelPeers().nativePeer;\nvar callCount = 0;\n@@ -2213,6 +2157,73 @@ test('does not fire duplicate events after peer listener recreation',\n}\n);\n+test(\n+ 'Discovered peer should be removed if no availability updates ' +\n+ 'were received during availability timeout',\n+ function () {\n+ return !platform.isAndroid ||\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.NATIVE;\n+ },\n+ function (t) {\n+ var peerIdentifier = 'urn:uuid:' + uuid.v4();\n+ var portNumber = 8080;\n+ var generation = 50;\n+\n+ var originalThreshold = thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n+ thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD = 500;\n+\n+ var finalizeTest = function (error) {\n+ thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD =\n+ originalThreshold;\n+ t.end(error);\n+ };\n+\n+ ThaliMobile.start(express.Router())\n+ .then(function () {\n+ var availabilityHandler = function (peer) {\n+ if (peer.peerIdentifier !== peerIdentifier) {\n+ return;\n+ }\n+\n+ ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n+ availabilityHandler);\n+\n+ var unavailabilityHandler = function (peer) {\n+ if (peer.peerIdentifier !== peerIdentifier) {\n+ return;\n+ }\n+\n+ t.notOk(peer.peerAvailable, 'Peer should not be available');\n+\n+ ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n+ unavailabilityHandler);\n+\n+ finalizeTest(null);\n+ };\n+\n+ ThaliMobile.emitter.on('peerAvailabilityChanged',\n+ unavailabilityHandler);\n+ };\n+\n+ ThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n+\n+ ThaliMobile._getThaliWifiInfrastructure().emit(\n+ 'wifiPeerAvailabilityChanged',\n+ {\n+ peerIdentifier: peerIdentifier,\n+ peerAvailable: true,\n+ generation: generation,\n+ portNumber: portNumber,\n+ hostAddress: '127.0.0.1'\n+ }\n+ );\n+ })\n+ .catch(function (error) {\n+ finalizeTest(error);\n+ });\n+ }\n+);\n+\nif (!tape.coordinated) {\nreturn;\n}\n@@ -2597,65 +2608,3 @@ test('test for data corruption',\nrunTestFunction();\n}\n);\n-\n-test(\n- 'Discovered peer should be removed if no availability updates ' +\n- 'were received during availability timeout',\n- function (t) {\n- var peerIdentifier = 'urn:uuid:' + uuid.v4();\n- var portNumber = 8080;\n- var generation = 50;\n-\n- var originalThreshold = thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD;\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD = 500;\n-\n- var finalizeTest = function (error) {\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD =\n- originalThreshold;\n- t.end(error);\n- };\n-\n- ThaliMobile.start(express.Router())\n- .then(function () {\n- var availabilityHandler = function (peer) {\n- if (peer.peerIdentifier !== peerIdentifier) {\n- return;\n- }\n-\n- ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n- availabilityHandler);\n-\n- var unavailabilityHandler = function (peer) {\n- if (peer.peerIdentifier !== peerIdentifier) {\n- return;\n- }\n-\n- t.notOk(peer.peerAvailable, 'Peer should not be available');\n-\n- ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n- unavailabilityHandler);\n-\n- finalizeTest(null);\n- };\n-\n- ThaliMobile.emitter.on('peerAvailabilityChanged',\n- unavailabilityHandler);\n- };\n-\n- ThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n-\n- ThaliMobileNativeWrapper.emitter.emit(\n- 'nonTCPPeerAvailabilityChangedEvent',\n- {\n- peerIdentifier: peerIdentifier,\n- peerAvailable: true,\n- generation: generation,\n- portNumber: portNumber\n- }\n- );\n- })\n- .catch(function (error) {\n- finalizeTest(error);\n- });\n- }\n-);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Implement and update tests for #1457
|
675,378 |
09.03.2017 15:13:20
| -10,800 |
c449fe45b1cca2ea9640735e773bbdca6d48e846
|
Update test for startUpdateAdvertisingAndListening does not send ssdp:byebye notifications
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -856,42 +856,52 @@ test('startUpdateAdvertisingAndListening does not send ssdp:byebye notifications\nssdpIp: thaliConfig.SSDP_IP\n});\n- var ourPeer = null;\n+ var peerIdentifier = null;\nvar aliveCalled = false;\nvar byeCalled = false;\n- var ourUSN = null;\n+ var currentUSN = null;\nvar updatedUSN = null;\nfunction finishTest() {\ntestClient.stop();\nt.equals(aliveCalled, true, 'advertise-alive fired');\nt.equals(byeCalled, false, 'advertise-bye not fired');\n- t.equals(ourPeer.peerIdentifier, updatedUSN.peerIdentifier, 'the same peer');\n+ t.ok(currentUSN.generation < updatedUSN.generation, 'generation must be increased');\nt.end();\n}\ntestClient.on('advertise-alive', function (data) {\n// Check for the Thali NT in case there is some other\n// SSDP traffic in the network.\n- if (data.NT !== thaliConfig.SSDP_NT || data.USN !== ourUSN) {\n+ if (data.NT !== thaliConfig.SSDP_NT) {\n+ return;\n+ }\n+\n+ var tempUSN = USN.tryParse(data.USN);\n+\n+ if (peerIdentifier !== tempUSN.peerIdentifier) {\nreturn;\n}\nif (aliveCalled) {\n- updatedUSN = USN.parse(data.USN);\n+ updatedUSN = tempUSN;\nfinishTest();\n- }\n+ } else {\n+ currentUSN = tempUSN;\naliveCalled = true;\n+ wifiInfrastructure.startUpdateAdvertisingAndListening();\n+ }\n+\n});\ntestClient.on('advertise-bye', function (data) {\n// Check for the Thali NT in case there is some other\n// SSDP traffic in the network.\n- if (data.NT !== thaliConfig.SSDP_NT || data.USN !== ourUSN) {\n+ if (data.NT !== thaliConfig.SSDP_NT) {\nreturn;\n}\n- byeCalled = true;\n+ byeCalled = true;\nfinishTest();\n});\n@@ -899,10 +909,7 @@ test('startUpdateAdvertisingAndListening does not send ssdp:byebye notifications\n// This is the first call to the update function after which\n// some USN value should be advertised.\nwifiInfrastructure.startUpdateAdvertisingAndListening().then(function () {\n- ourPeer = wifiInfrastructure._getCurrentPeer();\n- wifiInfrastructure.startUpdateAdvertisingAndListening().then(function () {\n- ourUSN = USN.stringify(wifiInfrastructure._getCurrentPeer());\n- });\n+ peerIdentifier = wifiInfrastructure._getCurrentPeer().peerIdentifier;\n})\n});\n});\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update test for startUpdateAdvertisingAndListening does not send ssdp:byebye notifications
|
675,379 |
09.03.2017 15:36:01
| -10,800 |
8d5282cec41582bc608978d36c719d6db5ac9c75
|
Update Cartfile.resolved.
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/Cartfile.resolved",
"new_path": "lib/ios/Cartfile.resolved",
"diff": "github \"robbiehanson/CocoaAsyncSocket\" \"7.6.0\"\n-github \"thaliproject/swift-corelibs-xctest\" \"4d2bb86a6767d696b1fcdad075d015bd74869f6f\"\n-github \"thaliproject/thali-ios\" \"8f74615dc4def62bb953d7bfb2228b3c7b17079d\"\n+github \"thaliproject/swift-corelibs-xctest\" \"9f415647a545b45d0fd349590788b160e1a67e49\"\n+github \"thaliproject/thali-ios\" \"a2e9248c945e8b95ef7cc0ce6c04d00590de924b\"\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update Cartfile.resolved.
|
675,371 |
06.03.2017 11:26:20
| -3,600 |
8c14202a8c5177a23a1d66d697218c7a939fb921
|
Update validateBuildEnvironment.js.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/validateBuildEnvironment.js",
"new_path": "thali/install/validateBuildEnvironment.js",
"diff": "@@ -33,7 +33,8 @@ const versions =\ncordova: '6.4.0',\njava: '1.8.0_102',\ngit: '2.10.0',\n- swiftlint: '0.13.0',\n+ swiftlint: '0.16.1',\n+ carthage: '0.20.0'\nsinopiaNode: ' ',\nsinopiaJxCore: ' '\n};\n@@ -205,6 +206,11 @@ const commandsAndResults =\nversionValidate:\n(result, version) => boolToPromise(version === result.trim())\n},\n+ carthage: {\n+ versionCheck: 'carthage version',\n+ versionValidate:\n+ (result, version) => boolToPromise(version === result.trim())\n+ },\nsinopiaNode: {\nversionCheck: 'npm get registry',\nversionValidate:\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update validateBuildEnvironment.js.
|
675,379 |
09.03.2017 15:56:56
| -10,800 |
75b1ce0c16dcdc8e6fcf8da2efd58af997aa3af4
|
Update Xcode version and jxcore version in validateBuildEnvironment.js.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/validateBuildEnvironment.js",
"new_path": "thali/install/validateBuildEnvironment.js",
"diff": "@@ -13,7 +13,7 @@ const assert = require('assert');\nconst versions =\n{\n- xcode: '7.3.1',\n+ xcode: '8.2.1',\nxcodeCommandLineTools: ' ',\nmacOS: '10.12.3',\nnode: '6.9.1',\n@@ -21,7 +21,7 @@ const versions =\nbrew: '1.1.',\nruby: '2.3.0p0',\nwget: '1.18',\n- jxcore: '0.3.1.8',\n+ jxcore: '0.3.1.10',\nandroidHome: ' ',\nandroidBuildTools: thaliConfig.thaliInstall.androidConfig.buildToolsVersion,\nandroidPlatform: thaliConfig.thaliInstall.androidConfig.compileSdkVersion,\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update Xcode version and jxcore version in validateBuildEnvironment.js.
|
675,378 |
10.03.2017 15:16:49
| -10,800 |
b7e0a27c69e229c62eb0dc6e329a362e27198c8a
|
Update test for pr
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -846,6 +846,7 @@ test('SSDP server should not restart after Wifi Client changed generation',\nt.fail(err);\n})\n.then(function () {\n+ advertisingEndSpy.restore();\nt.end();\n});\n}\n@@ -883,13 +884,13 @@ test('startUpdateAdvertisingAndListening does not send ssdp:byebye notifications\nreturn;\n}\n- if (aliveCalled) {\n- updatedUSN = tempUSN;\n- finishTest();\n- } else {\n+ if (!aliveCalled) {\ncurrentUSN = tempUSN;\naliveCalled = true;\nwifiInfrastructure.startUpdateAdvertisingAndListening();\n+ } else {\n+ updatedUSN = tempUSN;\n+ finishTest();\n}\n});\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update test for pr #1817
|
675,378 |
10.03.2017 17:31:31
| -10,800 |
c6dfe2c78ec56998fad6bdf3fb39031e609e3dac
|
Update peerAvailabilityWatchers, thaliMobile and ThaliWifiInfrastructure and test for it.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -314,74 +314,6 @@ test('can get the network status', function (t) {\n});\n});\n-test('wifi peer is marked unavailable if announcements stop',\n- function () {\n- return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n- },\n- function (t) {\n- // Store the original threshold so that it can be restored\n- // at the end of the test.\n- var originalThreshold = thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n- // Make the threshold a bit shorter so that the test doesn't\n- // have to wait for so long.\n- thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD =\n- thaliConfig.SSDP_ADVERTISEMENT_INTERVAL * 2;\n- var testPeerIdentifier = uuid.v4();\n- var testServerHostAddress = randomstring.generate({\n- charset: 'hex', // to get lowercase chars for the host address\n- length: 8\n- });\n- var testServerPort = 8080;\n- var testServer = new nodessdp.Server({\n- location: 'http://' + testServerHostAddress + ':' + testServerPort,\n- ssdpIp: thaliConfig.SSDP_IP,\n- udn: thaliConfig.SSDP_NT,\n- // Make the interval 10 times longer than expected\n- // to make sure we determine the peer is gone while\n- // waiting for the advertisement.\n- adInterval: thaliConfig.SSDP_ADVERTISEMENT_INTERVAL * 10\n- });\n- testServer.setUSN(USN.stringify({\n- peerIdentifier: testPeerIdentifier,\n- generation: 0\n- }));\n-\n- var spy = sinon.spy();\n- var availabilityChangedHandler = function (peer) {\n- if (peer.peerIdentifier !== testPeerIdentifier) {\n- return;\n- }\n-\n- // TODO Apply changes from #904 to tests\n- spy();\n- if (spy.calledOnce) {\n- t.equal(peer.peerAvailable, true, 'peer should be available');\n- } else if (spy.calledTwice) {\n- t.equal(peer.peerAvailable, false, 'peer should become unavailable');\n-\n- ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n- availabilityChangedHandler);\n- testServer.stop(function () {\n- thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD = originalThreshold;\n- t.end();\n- });\n- }\n- };\n- ThaliMobile.emitter.on('peerAvailabilityChanged',\n- availabilityChangedHandler);\n-\n- ThaliMobile.start(express.Router())\n- .then(function () {\n- return ThaliMobile.startListeningForAdvertisements();\n- })\n- .then(function () {\n- testServer.start(function () {\n- // Handler above should get called.\n- });\n- });\n- }\n-);\n-\ntest('peerAvailabilityChanged - peer added/removed to/from cache (native)',\nfunction (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n@@ -2107,6 +2039,46 @@ test('does not fire duplicate events after peer listener recreation',\n}\n);\n+test('#stop should change peers', function (t) {\n+ var somePeerIdentifier = 'urn:uuid:' + uuid.v4();\n+\n+ var connectionType = platform.isAndroid ?\n+ connectionTypes.BLUETOOTH :\n+ connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\n+\n+ ThaliMobile.start(express.Router(), new Buffer('foo'),\n+ ThaliMobile.networkTypes.NATIVE)\n+ .then(function () {\n+ return ThaliMobile.startListeningForAdvertisements();\n+ })\n+ .then(function () {\n+ return ThaliMobileNativeWrapper._handlePeerAvailabilityChanged({\n+ peerIdentifier: somePeerIdentifier,\n+ peerAvailable: true\n+ });\n+ })\n+ .then(function () {\n+ t.equal(Object.getOwnPropertyNames(\n+ ThaliMobile._peerAvailabilities[connectionType]).length, 1,\n+ 'Peer availabilities has one entry for our connection type');\n+ return ThaliMobile.stop();\n+ })\n+ .then(function () {\n+ Object.getOwnPropertyNames(connectionTypes)\n+ .forEach(function (connectionKey) {\n+ var connectionType = connectionTypes[connectionKey];\n+ t.equal(Object.getOwnPropertyNames(\n+ ThaliMobile._peerAvailabilities[connectionType]).length,\n+ 0, 'No peers');\n+ });\n+ t.end();\n+ })\n+ .catch(function (err) {\n+ t.fail('Failed out with ' + err);\n+ t.end();\n+ });\n+});\n+\nif (!tape.coordinated) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -782,6 +782,106 @@ test(\n}\n);\n+test('#stop should clear watchers', function (t) {\n+ var somePeerIdentifier = 'urn:uuid:' + uuid.v4();\n+\n+ wifiInfrastructure.startListeningForAdvertisements()\n+ .then(function () {\n+ wifiInfrastructure.listener.emit(\n+ 'wifiPeerAvailabilityChanged',\n+ {\n+ peerIdentifier: somePeerIdentifier,\n+ peerAvailable: true,\n+ generation: 20,\n+ portNumber: 8080,\n+ hostAddress: '127.0.0.1'\n+ }\n+ );\n+\n+ t.equal(Object.getOwnPropertyNames(\n+ wifiInfrastructure.peerAvailabilityWatchers).length, 1,\n+ 'Watchers have one entry for our connection type');\n+ return wifiInfrastructure.stop();\n+ })\n+ .then(function () {\n+ t.equal(Object.getOwnPropertyNames(\n+ wifiInfrastructure.peerAvailabilityWatchers).length,\n+ 0, 'No watchers');\n+ t.end();\n+ })\n+ .catch(function (err) {\n+ t.fail('Failed out with ' + err);\n+ t.end();\n+ });\n+});\n+\n+test('wifi peer is marked unavailable if announcements stop',\n+ function () {\n+ return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n+ },\n+ function (t) {\n+ // Store the original threshold so that it can be restored\n+ // at the end of the test.\n+ var originalThreshold = thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n+ // Make the threshold a bit shorter so that the test doesn't\n+ // have to wait for so long.\n+ thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD =\n+ thaliConfig.SSDP_ADVERTISEMENT_INTERVAL * 2;\n+ var testPeerIdentifier = uuid.v4();\n+ var testServerHostAddress = randomstring.generate({\n+ charset: 'hex', // to get lowercase chars for the host address\n+ length: 8\n+ });\n+ var testServerPort = 8080;\n+ var testServer = new nodessdp.Server({\n+ location: 'http://' + testServerHostAddress + ':' + testServerPort,\n+ ssdpIp: thaliConfig.SSDP_IP,\n+ udn: thaliConfig.SSDP_NT,\n+ // Make the interval 10 times longer than expected\n+ // to make sure we determine the peer is gone while\n+ // waiting for the advertisement.\n+ adInterval: thaliConfig.SSDP_ADVERTISEMENT_INTERVAL * 10\n+ });\n+ testServer.setUSN(USN.stringify({\n+ peerIdentifier: testPeerIdentifier,\n+ generation: 0\n+ }));\n+\n+ var spy = sinon.spy();\n+ var availabilityChangedHandler = function (peer) {\n+ if (peer.peerIdentifier !== testPeerIdentifier) {\n+ return;\n+ }\n+\n+ // TODO Apply changes from #904 to tests\n+ spy();\n+ if (spy.calledOnce) {\n+ t.equal(peer.peerAvailable, true, 'peer should be available');\n+ } else if (spy.calledTwice) {\n+ t.equal(peer.peerAvailable, false, 'peer should become unavailable');\n+\n+ ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n+ availabilityChangedHandler);\n+ testServer.stop(function () {\n+ thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD = originalThreshold;\n+ t.end();\n+ });\n+ }\n+ };\n+ ThaliMobile.emitter.on('peerAvailabilityChanged',\n+ availabilityChangedHandler);\n+\n+ ThaliMobile.start(express.Router())\n+ .then(function () {\n+ return ThaliMobile.startListeningForAdvertisements();\n+ })\n+ .then(function () {\n+ testServer.start(function () {\n+ // Handler above should get called.\n+ });\n+ });\n+ }\n+);\n// From here onwards, tests only work on mocked up desktop\n// environment where network changes can be simulated.\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobile.js",
"new_path": "thali/NextGeneration/thaliMobile.js",
"diff": "@@ -258,7 +258,6 @@ module.exports.isStarted = function () {\nmodule.exports.stop = function () {\nreturn promiseQueue.enqueue(function (resolve) {\nresetThaliMobileState();\n- //removeAllAvailabilityWatchersFromPeers();\nObject.getOwnPropertyNames(connectionTypes)\n.forEach(function (connectionKey) {\nvar connectionType = connectionTypes[connectionKey];\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -24,7 +24,6 @@ var enqueued = common.enqueuedMethod;\nvar enqueuedAtTop = common.enqueuedAtTopMethod;\nvar thaliMobileNativeWrapper = require('./thaliMobileNativeWrapper');\n-//var connectionTypes = thaliMobileNativeWrapper.connectionTypes;\nvar muteRejection = (function () {\nfunction returnNull () { return null; }\n@@ -793,7 +792,8 @@ function (peer) {\n};\n-ThaliWifiInfrastructure.prototype._watchForPeerAvailability = function (peer) {\n+ThaliWifiInfrastructure.prototype._watchForPeerAvailability =\n+function (peer) {\nvar peerIdentifier = peer.peerIdentifier;\nvar connectionType = peer.connectionType;\n@@ -809,7 +809,6 @@ ThaliWifiInfrastructure.prototype._watchForPeerAvailability = function (peer) {\nthis._removeAvailabilityWatcherFromPeerIfExists(peer);\nthis.emit('wifiPeerAvailabilityChanged', peer);\n- //emitPeerUnavailable(peerIdentifier, connectionType);\n};\n@@ -825,7 +824,8 @@ function (peer) {\nthaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\nthis.peerAvailabilityWatchers[peerIdentifier] =\n- setInterval((self._watchForPeerAvailability).bind(self), unavailabilityThreshold, peer);\n+ setInterval((self._watchForPeerAvailability).bind(self),\n+ unavailabilityThreshold, peer);\n};\nThaliWifiInfrastructure.prototype._removeAvailabilityWatcherFromPeerIfExists =\n@@ -834,43 +834,22 @@ ThaliWifiInfrastructure.prototype._removeAvailabilityWatcherFromPeerIfExists =\nreturn;\n}\n- //var connectionType = peer.connectionType;\nvar peerIdentifier = peer.peerIdentifier;\n- //var interval = this.peerAvailabilityWatchers[connectionType][peerIdentifier];\nvar interval = this.peerAvailabilityWatchers[peerIdentifier];\nclearInterval(interval);\n- //delete this.peerAvailabilityWatchers[connectionType][peerIdentifier];\ndelete this.peerAvailabilityWatchers[peerIdentifier];\n};\n-// ThaliWifiInfrastructure.prototype._removeAllAvailabilityWatchersFromPeersByConnectionType =\n-// function (connectionType) {\n-// var peersByConnectionType = this.peerAvailabilityWatchers[connectionType];\n-\n-// Object.keys(peersByConnectionType)\n-// .forEach(function (peerIdentifier) {\n-// var assumingPeer = {\n-// peerIdentifier: peerIdentifier,\n-// connectionType: connectionType\n-// };\n-\n-// removeAvailabilityWatcherFromPeerIfExists(assumingPeer);\n-// });\n-// };\nThaliWifiInfrastructure.prototype._removeAllAvailabilityWatchersFromPeers =\nfunction() {\nvar self = this;\n- //Object.keys(this.peerAvailabilityWatchers)\n- //.forEach(this._removeAllAvailabilityWatchersFromPeersByConnectionType);\n-\nObject.keys(this.peerAvailabilityWatchers)\n.forEach(function (peerIdentifier) {\nvar assumingPeer = {\n- peerIdentifier: peerIdentifier,\n- connectionType: connectionType\n+ peerIdentifier: peerIdentifier\n};\nself._removeAvailabilityWatcherFromPeerIfExists(assumingPeer);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update peerAvailabilityWatchers, thaliMobile and ThaliWifiInfrastructure and test for it.
|
675,378 |
13.03.2017 12:18:11
| -10,800 |
e9dd7bfd8578614dd30fea01cf68e0869addb376
|
Update tests for thaliWifiInfrastructure after updates peerAvailabilityWatchers structure.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js",
"diff": "@@ -816,9 +816,6 @@ test('#stop should clear watchers', function (t) {\n});\ntest('wifi peer is marked unavailable if announcements stop',\n- function () {\n- return global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n- },\nfunction (t) {\n// Store the original threshold so that it can be restored\n// at the end of the test.\n@@ -848,33 +845,32 @@ test('wifi peer is marked unavailable if announcements stop',\n}));\nvar spy = sinon.spy();\n+ var peerAvailable = false;\nvar availabilityChangedHandler = function (peer) {\nif (peer.peerIdentifier !== testPeerIdentifier) {\nreturn;\n}\n-\n- // TODO Apply changes from #904 to tests\nspy();\n+ peer.portNumber !== null && peer.hostAddress !== null ?\n+ peerAvailable = true :\n+ peerAvailable = false;\nif (spy.calledOnce) {\n- t.equal(peer.peerAvailable, true, 'peer should be available');\n+ t.equal(peerAvailable, true, 'peer should be available');\n+ testServer.stop();\n} else if (spy.calledTwice) {\n- t.equal(peer.peerAvailable, false, 'peer should become unavailable');\n+ t.equal(peerAvailable, false, 'peer should become unavailable');\n- ThaliMobile.emitter.removeListener('peerAvailabilityChanged',\n+ wifiInfrastructure.removeListener('wifiPeerAvailabilityChanged',\navailabilityChangedHandler);\n- testServer.stop(function () {\n+\nthaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD = originalThreshold;\nt.end();\n- });\n}\n};\n- ThaliMobile.emitter.on('peerAvailabilityChanged',\n+ wifiInfrastructure.on('wifiPeerAvailabilityChanged',\navailabilityChangedHandler);\n- ThaliMobile.start(express.Router())\n- .then(function () {\n- return ThaliMobile.startListeningForAdvertisements();\n- })\n+ wifiInfrastructure.startListeningForAdvertisements()\n.then(function () {\ntestServer.start(function () {\n// Handler above should get called.\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update tests for thaliWifiInfrastructure after updates peerAvailabilityWatchers structure.
|
675,381 |
13.03.2017 13:18:46
| -10,800 |
052ba7297bbc1e3186df444c8e31d9e668ed567a
|
Fix WiFi connection check
ThaliWifiInfrastructure did not check the case when WiFi is enabled but
device is not connected to any access point
|
[
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -682,6 +682,13 @@ ThaliWifiInfrastructure.prototype._setUpEvents = function() {\ninherits(ThaliWifiInfrastructure, EventEmitter);\n+ThaliWifiInfrastructure.prototype._isDisconnected = function () {\n+ var lastStatus = this._lastNetworkStatus;\n+ return lastStatus ?\n+ (lastStatus.wifi === 'off' || lastStatus.bssidName === null) :\n+ false;\n+};\n+\nThaliWifiInfrastructure.prototype._handleNetworkChanges =\nfunction (networkStatus) {\nvar lastStatus = this._lastNetworkStatus;\n@@ -878,7 +885,7 @@ enqueued(function () {\nif (!this._isStarted) {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- if (this._lastNetworkStatus && this._lastNetworkStatus.wifi === 'off') {\n+ if (this._isDisconnected()) {\nreturn this._rejectPerWifiState();\n}\nreturn this.listener.start();\n@@ -994,7 +1001,7 @@ enqueued(function () {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- if (this._lastNetworkStatus && this._lastNetworkStatus.wifi === 'off') {\n+ if (this._isDisconnected()) {\nreturn this._rejectPerWifiState();\n}\n@@ -1034,21 +1041,19 @@ ThaliWifiInfrastructure.prototype._pauseAdvertisingAndListening =\nThaliWifiInfrastructure.prototype._rejectPerWifiState = function () {\nvar errorMessage;\n- switch (this._lastNetworkStatus.wifi) {\n- case 'off': {\n+ var wifi = this._lastNetworkStatus.wifi;\n+ var bssidName = this._lastNetworkStatus.bssidName;\n+ if (wifi === 'off') {\nerrorMessage = 'Radio Turned Off';\n- break;\n- }\n- case 'notHere': {\n+ } else if (wifi === 'notHere') {\nerrorMessage = 'No Wifi radio';\n- break;\n- }\n- default: {\n- logger.warn('Got unexpected Wifi state: %s',\n- this.states.networkStatus.wifi);\n+ } else if (bssidName === null) {\n+ errorMessage = 'Not connected to WiFi access point';\n+ } else {\n+ logger.warn('Got unexpected Wifi state (wifi: %s, bssidName: %s)',\n+ JSON.stringify(wifi), JSON.stringify(bssidName));\nerrorMessage = 'Unspecified Error with Radio infrastructure';\n}\n- }\nreturn Promise.reject(new Error(errorMessage));\n};\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix WiFi connection check
ThaliWifiInfrastructure did not check the case when WiFi is enabled but
device is not connected to any access point
|
675,381 |
13.03.2017 15:42:13
| -10,800 |
79243628f9e032a040e434b67f89cbe143ce44cc
|
Update WiFi network change handling tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"new_path": "test/www/jxcore/bv_tests/testSSDPServer.js",
"diff": "@@ -115,43 +115,56 @@ function changeBssid (value) {\n});\n}\n-test(\n- 'ssdp server and client should be restarted when bssid changed',\n- function () {\n- return global.NETWORK_TYPE !== networkTypes.WIFI;\n- },\n- function (t) {\n- var wifiInfrastructure = new ThaliWifiInfrastructure();\n- var ssdpServer = wifiInfrastructure._getSSDPServer();\n- var ssdpClient = wifiInfrastructure._getSSDPClient();\n- var serverStartStub = sandbox.stub(ssdpServer, 'start', callArg);\n- var serverStopStub = sandbox.stub(ssdpServer, 'stop', callArg);\n- var clientStartStub = sandbox.stub(ssdpClient, 'start', callArg);\n- var clientStopStub = sandbox.stub(ssdpClient, 'stop', callArg);\n-\n- function testBssidChangeReaction (newBssid) {\n+function testBssidChangeReaction (context, newBssid, callCount) {\n+ var t = context.t;\n+ var stubs = context.stubs;\n// reset call counts\n- serverStartStub.reset();\n- serverStopStub.reset();\n- clientStartStub.reset();\n- clientStopStub.reset();\n+ stubs.serverStart.reset();\n+ stubs.serverStop.reset();\n+ stubs.clientStart.reset();\n+ stubs.clientStop.reset();\nreturn new Promise(function (resolve) {\nchangeBssid(newBssid);\n// TODO: #1805\nsetTimeout(function () {\n- t.equal(serverStartStub.callCount, 1, 'server start called once');\n- t.equal(serverStopStub.callCount, 1, 'server stop called once');\n- t.equal(clientStartStub.callCount, 1, 'client start called once');\n- t.equal(clientStopStub.callCount, 1, 'client start called once');\n- t.ok(serverStopStub.calledBefore(serverStartStub),\n+ t.equal(stubs.serverStart.callCount, callCount.start,\n+ 'server start called ' + callCount.start + ' times');\n+ t.equal(stubs.serverStop.callCount, callCount.stop,\n+ 'server stop called ' + callCount.stop + ' times');\n+ t.equal(stubs.clientStart.callCount, callCount.start,\n+ 'client start called ' + callCount.start + ' times');\n+ t.equal(stubs.clientStop.callCount, callCount.stop,\n+ 'client stop called ' + callCount.stop + ' times');\n+ if (callCount.start === 1 && callCount.stop === 1) {\n+ t.ok(stubs.serverStop.calledBefore(stubs.serverStart),\n'server stop called before start');\n- t.ok(clientStopStub.calledBefore(clientStartStub),\n+ t.ok(stubs.clientStop.calledBefore(stubs.clientStart),\n'client stop called before start');\n+ }\nresolve();\n}, 200);\n});\n}\n+\n+test(\n+ 'ssdp server and client should be restarted when bssid changed',\n+ function () {\n+ return global.NETWORK_TYPE !== networkTypes.WIFI;\n+ },\n+ function (t) {\n+ var wifiInfrastructure = new ThaliWifiInfrastructure();\n+ var ssdpServer = wifiInfrastructure._getSSDPServer();\n+ var ssdpClient = wifiInfrastructure._getSSDPClient();\n+ var stubs = {\n+ serverStart: sandbox.stub(ssdpServer, 'start', callArg),\n+ serverStop: sandbox.stub(ssdpServer, 'stop', callArg),\n+ clientStart: sandbox.stub(ssdpClient, 'start', callArg),\n+ clientStop: sandbox.stub(ssdpClient, 'stop', callArg)\n+ };\n+ var context = { t: t, stubs: stubs };\n+ var testBssid = testBssidChangeReaction.bind(null, context);\n+\nwifiInfrastructure.start(express.Router(), pskIdToSecret)\n.then(function () {\nreturn wifiInfrastructure.startUpdateAdvertisingAndListening();\n@@ -161,15 +174,18 @@ test(\n})\n.then(function () {\n// bssid -> null\n- return testBssidChangeReaction(null);\n+ var callCount = { stop: 1, start: 0 };\n+ return testBssid(null, callCount);\n})\n.then(function () {\n// null -> bssid\n- return testBssidChangeReaction('00:00:00:00:00:00');\n+ var callCount = { stop: 0, start: 1 };\n+ return testBssid('00:00:00:00:00:00', callCount);\n})\n.then(function () {\n// bssid -> another bssid\n- return testBssidChangeReaction('11:11:11:11:11:11');\n+ var callCount = { stop: 1, start: 1 };\n+ return testBssid('11:11:11:11:11:11', callCount);\n})\n.then(function () {\nreturn wifiInfrastructure.stop();\n@@ -195,37 +211,27 @@ test(\nvar wifiInfrastructure = new ThaliWifiInfrastructure();\nvar ssdpServer = wifiInfrastructure._getSSDPServer();\nvar ssdpClient = wifiInfrastructure._getSSDPClient();\n- var serverStartStub = sandbox.stub(ssdpServer, 'start', callArg);\n- var serverStopStub = sandbox.stub(ssdpServer, 'stop', callArg);\n- var clientStartStub = sandbox.stub(ssdpClient, 'start', callArg);\n- var clientStopStub = sandbox.stub(ssdpClient, 'stop', callArg);\n-\n- function testBssidChangeReaction (newBssid) {\n- return new Promise(function (resolve) {\n- changeBssid(newBssid);\n- // TODO: #1805\n- setTimeout(function () {\n- t.equal(serverStartStub.callCount, 0, 'server start never called');\n- t.equal(serverStopStub.callCount, 0, 'server stop never called');\n- t.equal(clientStartStub.callCount, 0, 'client start never called');\n- t.equal(clientStopStub.callCount, 0, 'client start never called');\n- resolve();\n- }, 200);\n- });\n- }\n+ var stubs = {\n+ serverStart: sandbox.stub(ssdpServer, 'start', callArg),\n+ serverStop: sandbox.stub(ssdpServer, 'stop', callArg),\n+ clientStart: sandbox.stub(ssdpClient, 'start', callArg),\n+ clientStop: sandbox.stub(ssdpClient, 'stop', callArg)\n+ };\n+ var context = { t: t, stubs: stubs };\n+ var testBssid = testBssidChangeReaction.bind(null, context);\nwifiInfrastructure.start(express.Router(), pskIdToSecret)\n.then(function () {\n// bssid -> null\n- return testBssidChangeReaction(null);\n+ return testBssid(null, { start: 0, stop: 0 });\n})\n.then(function () {\n// null -> bssid\n- return testBssidChangeReaction('00:00:00:00:00:00');\n+ return testBssid('00:00:00:00:00:00', { start: 0, stop: 0 });\n})\n.then(function () {\n// bssid -> another bssid\n- return testBssidChangeReaction('11:11:11:11:11:11');\n+ return testBssid('11:11:11:11:11:11', { start: 0, stop: 0 });\n})\n.then(function () {\nreturn wifiInfrastructure.stop();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update WiFi network change handling tests
|
675,381 |
13.03.2017 20:35:34
| -10,800 |
996b5ffe93eafd0274a61b5a1125400e78037e3c
|
WiFi network state handling refactoring
|
[
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"new_path": "thali/NextGeneration/thaliWifiInfrastructure.js",
"diff": "@@ -682,46 +682,33 @@ ThaliWifiInfrastructure.prototype._setUpEvents = function() {\ninherits(ThaliWifiInfrastructure, EventEmitter);\n-ThaliWifiInfrastructure.prototype._isDisconnected = function () {\n- var lastStatus = this._lastNetworkStatus;\n- return lastStatus ?\n- (lastStatus.wifi === 'off' || lastStatus.bssidName === null) :\n- false;\n+ThaliWifiInfrastructure.prototype._isConnected = function () {\n+ // We use this method only when thaliWifiInfrastructure is started\n+ assert(this._lastNetworkStatus, 'have latest network status');\n+ return this._lastNetworkStatus.bssidName !== null;\n};\nThaliWifiInfrastructure.prototype._handleNetworkChanges =\n-function (networkStatus) {\n- var lastStatus = this._lastNetworkStatus;\n+function (newStatus) {\n+ var oldStatus = this._lastNetworkStatus;\n+ this._lastNetworkStatus = newStatus;\n+\n+ // Check if this is a first call triggered by start method. In this case we\n+ // don't need to do anything.\n+ if (!oldStatus) {\n+ return;\n+ }\n/** true if device became connected to the WiFi access point */\n- var connectedToAP;\n+ var connectedToAP =\n+ (oldStatus.bssidName === null && newStatus.bssidName !== null);\n/** true if device is no longer connected to any WiFi access point */\n- var disconnectedFromAP;\n+ var disconnectedFromAP =\n+ (oldStatus.bssidName !== null && newStatus.bssidName === null);\n/** true if device moved from one WiFi access point to another access point */\n- var changedAP;\n-\n- if (lastStatus) {\n- connectedToAP =\n- (lastStatus.wifi === 'off' && networkStatus.wifi === 'on') ||\n- (lastStatus.bssidName === null && networkStatus.bssidName !== null);\n- disconnectedFromAP =\n- (lastStatus.wifi === 'on' && networkStatus.wifi === 'off') ||\n- (lastStatus.bssidName !== null && networkStatus.bssidName === null);\n- changedAP =\n+ var changedAP =\n!disconnectedFromAP && !connectedToAP &&\n- lastStatus.bssidName !== networkStatus.bssidName;\n- } else {\n- connectedToAP =\n- networkStatus.wifi === 'on' && networkStatus.bssidName !== null;\n- disconnectedFromAP =\n- networkStatus.wifi === 'off' || networkStatus.bssidName === null;\n- changedAP = false;\n- }\n-\n- assert((disconnectedFromAP && connectedToAP) === false,\n- 'either connected or disconnected');\n-\n- this._lastNetworkStatus = networkStatus;\n+ oldStatus.bssidName !== newStatus.bssidName;\n// If we are stopping or the wifi state hasn't changed,\n// we are not really interested.\n@@ -885,7 +872,7 @@ enqueued(function () {\nif (!this._isStarted) {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- if (this._isDisconnected()) {\n+ if (!this._isConnected()) {\nreturn this._rejectPerWifiState();\n}\nreturn this.listener.start();\n@@ -1001,7 +988,7 @@ enqueued(function () {\nreturn Promise.reject(new Error('Call Start!'));\n}\n- if (this._isDisconnected()) {\n+ if (!this._isConnected()) {\nreturn this._rejectPerWifiState();\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
WiFi network state handling refactoring
|
675,378 |
14.03.2017 16:49:03
| -10,800 |
0dae79c821876735480f950422102a8ff5657574
|
Update thaliMobile "discoveryDOS" event , implement tests.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -2213,6 +2213,69 @@ test('does not fire duplicate events after peer listener recreation',\n}\n);\n+test('If there are more then PERS_LIMIT peers presented ' +\n+ 'then `discoveryDOS` event should be emitted', function (t) {\n+ var PEERS_LIMIT = 1;\n+\n+ var CURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT =\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK];\n+\n+ var CURRENT_BLUETOOTH_PEERS_LIMIT =\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH];\n+\n+ var CURRENT_TCP_NATIVE_PEERS_LIMIT =\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE];\n+\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\n+ PEERS_LIMIT;\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\n+ PEERS_LIMIT;\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\n+ PEERS_LIMIT;\n+\n+ var peerIdentifier = 'urn:uuid:' + uuid.v4();\n+ var anotherPeerIdentifier = 'urn:uuid:' + uuid.v4();\n+\n+ function finishTest (connectionType) {\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\n+ CURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT;\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\n+ CURRENT_BLUETOOTH_PEERS_LIMIT;\n+ ThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\n+ CURRENT_TCP_NATIVE_PEERS_LIMIT;\n+ t.end();\n+ }\n+\n+ ThaliMobile.start(express.Router())\n+ .then(function () {\n+ ThaliMobile.emitter.on('discoveryDOS', function (info) {\n+ t.ok(info.limit, PEERS_LIMIT, 'DOS limit should be presented');\n+ t.ok(info.count, 2, 'Actual number off peers should be presented');\n+ finishTest();\n+ });\n+\n+ ThaliMobileNativeWrapper.emitter.emit(\n+ 'nonTCPPeerAvailabilityChangedEvent',\n+ {\n+ peerIdentifier: peerIdentifier,\n+ peerAvailable: true,\n+ generation: 0,\n+ portNumber: 8080\n+ }\n+ );\n+\n+ ThaliMobileNativeWrapper.emitter.emit(\n+ 'nonTCPPeerAvailabilityChangedEvent',\n+ {\n+ peerIdentifier: anotherPeerIdentifier,\n+ peerAvailable: true,\n+ generation: 1,\n+ portNumber: 8081\n+ }\n+ );\n+ });\n+});\n+\nif (!tape.coordinated) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobile.js",
"new_path": "thali/NextGeneration/thaliMobile.js",
"diff": "@@ -1059,7 +1059,6 @@ function handlePeer (peer) {\nreturn;\n}\n}\n-\nif (peer.peerAvailable) {\nchangeCachedPeerAvailable(peer);\n} else {\n@@ -1259,8 +1258,12 @@ function changeCachedPeerUnavailable (peer) {\nfunction changeCachedPeerAvailable (peer) {\nvar cachedPeer = JSON.parse(JSON.stringify(peer));\n- peerAvailabilities[peer.connectionType][peer.peerIdentifier] = cachedPeer;\n+ var peerIdentifier = peer.peerIdentifier;\n+ var connectionType = peer.connectionType;\n+ peerAvailabilities[connectionType][peerIdentifier] = cachedPeer;\n+\naddAvailabilityWatcherToPeerIfNotExist(cachedPeer);\n+ emitIfConnectionTypePeersLimitReached(connectionType);\n}\nfunction changePeersUnavailable (connectionType) {\n@@ -1484,3 +1487,46 @@ thaliWifiInfrastructure\n* @fires module:thaliMobile.event:discoveryDOS\n*/\nmodule.exports.emitter = new EventEmitter();\n+\n+var connectionTypePeersLimits = {};\n+connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\n+ thaliConfig.MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT;\n+connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\n+ thaliConfig.BLUETOOTH_PEERS_LIMIT;\n+connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\n+ thaliConfig.TCP_NATIVE_PEERS_LIMIT;\n+\n+module.exports.connectionTypePeersLimits = connectionTypePeersLimits;\n+\n+var emitIfConnectionTypePeersLimitReached = function (connectionType) {\n+ var connectionTypePeers = peerAvailabilities[connectionType];\n+ var connectionTypePeersCount = Object.keys(connectionTypePeers).length;\n+ var peersLimit = connectionTypePeersLimits[connectionType];\n+ if (connectionTypePeersCount > peersLimit) {\n+ module.exports.emitter\n+ .emit(connectionType + 'PeersLimitReached', {\n+ limit: peersLimit,\n+ count: connectionTypePeersCount\n+ });\n+ }\n+}\n+\n+var emitDiscoveryDOS = function (dosInfo) {\n+ module.exports.emitter.emit('discoveryDOS', dosInfo);\n+};\n+\n+Object.keys(connectionTypes)\n+ .forEach(function (key) {\n+ var connectionType = connectionTypes[key];\n+\n+ module.exports.emitter.on(connectionType + 'PeersLimitReached',\n+ function (info) {\n+ emitDiscoveryDOS({\n+ connectionType: connectionType,\n+ limit: info.limit,\n+ count: info.count\n+ });\n+ })\n+ });\n+\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -752,14 +752,20 @@ module.exports._terminateConnection = function (incomingConnectionId) {\n* a null result.\n*/\nmodule.exports._disconnect = function (peerIdentifier) {\n- return gPromiseQueue.enqueue(function (resolve, reject) {\n- Mobile('disconnect').callNative(peerIdentifier, function (errorMsg) {\n+ return gPromiseQueue\n+ .enqueue(function (resolve, reject) {\n+ if (platform.isAndroid) {\n+ return reject(new Error('Not multiConnect platform'));\n+ }\n+ if (platform.isIOS) {\n+ Mobile('disconnect')\n+ .callNative(function (errorMsg) {\nif (errorMsg) {\n- reject(new Error(errorMsg));\n- } else {\n- resolve();\n+ return reject(new Error(errorMsg));\n}\n+ resolve();\n});\n+ }\n});\n};\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update thaliMobile "discoveryDOS" event , implement tests.
|
675,379 |
14.03.2017 16:54:25
| -10,800 |
8432681c42750457e408109f7d482be610a6601f
|
Update iOS deployment target in build-ci.xcconfig from 9.0 to 10.0.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/ios/build-ci.xcconfig",
"new_path": "thali/install/ios/build-ci.xcconfig",
"diff": "//\nHEADER_SEARCH_PATHS = \"$(TARGET_BUILD_DIR)/usr/local/lib/include\" \"$(OBJROOT)/UninstalledProducts/include\" \"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include\" \"$(BUILT_PRODUCTS_DIR)\"\n-IPHONEOS_DEPLOYMENT_TARGET = 9.0\n+IPHONEOS_DEPLOYMENT_TARGET = 10.0\nOTHER_LDFLAGS = -ObjC\nTARGETED_DEVICE_FAMILY = 1,2\nSWIFT_VERSION = 3.0\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update iOS deployment target in build-ci.xcconfig from 9.0 to 10.0.
|
675,379 |
14.03.2017 16:55:11
| -10,800 |
13659c8267f1f6d2eba4c106e28ec79440642d71
|
Rename environment vars to avoid collisions.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/setUpTests.sh",
"new_path": "thali/install/setUpTests.sh",
"diff": "@@ -19,9 +19,9 @@ trap 'log_error $LINENO' ERR\ncd `dirname $0`\ncd ../..\nREPO_ROOT_DIR=$(pwd)\n-PROJECT_NAME=${TEST_PROJECT_NAME:-ThaliTest}\n+PROJECT_NAME=${THALI_TEST_PROJECT_NAME:-ThaliTest}\nPROJECT_ROOT_DIR=${REPO_ROOT_DIR}/../${PROJECT_NAME}\n-PROJECT_ID=${TEST_PROJECT_ID:-com.thaliproject.thalitest}\n+PROJECT_ID=${THALI_TEST_PROJECT_ID:-com.thaliproject.thalitest}\n# Prepares test project\nprepare_project()\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Rename environment vars to avoid collisions.
|
675,379 |
14.03.2017 17:14:36
| -10,800 |
88bc2ecd1c21276afad78a83d35dce43e76f76d1
|
Update nativeInstaller.js in order to support carthage.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/cordova-hooks/ios/after_plugin_install.js",
"new_path": "thali/install/cordova-hooks/ios/after_plugin_install.js",
"diff": "@@ -59,13 +59,12 @@ module.exports = function (context) {\n}\n// We need to build ThaliCore.framework before embedding it into the project\n-\n- var thaliCoreProjectFolder = path.join(\n- context.opts.plugin.dir, 'lib', 'ios', 'ThaliCore');\n- var thaliCoreOutputFolder = path.join(\n+ var iOSInfrastructureFolder = path.join(\ncontext.opts.plugin.dir, 'lib', 'ios');\n- var testingInfrastructureDir = path.join(\n+ var testingInfrastructureForlder = path.join(\ncontext.opts.plugin.dir, 'src', 'ios', 'Testing');\n+ var thaliCoreProjectFolder = path.join(\n+ context.opts.plugin.dir, 'lib', 'ios', 'Carthage', 'Checkouts', 'thali-ios');\n// We need to embded frameworks to the project here.\n// They need to be embedded binaries and cordova does not yet support that.\n@@ -85,5 +84,5 @@ module.exports = function (context) {\nprojectRoot, 'platforms', 'ios', cfg.name() + '.xcodeproj');\nreturn nativeInstaller.addFramework(projectPath, thaliCoreProjectFolder,\n- thaliCoreOutputFolder, isTestEnvironment, testingInfrastructureDir);\n+ iOSInfrastructureFolder, isTestEnvironment, testingInfrastructureForlder);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/install/ios/nativeInstaller.js",
"new_path": "thali/install/ios/nativeInstaller.js",
"diff": "@@ -111,7 +111,6 @@ function updateProjectFrameworks(\nif (buildWithTests) {\nconsole.log('Adding XCTest.framework');\nvar xcTestFrameworkPath = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework';\n- // var xcTestFrameworkPath =\n// '/Applications/Xcode.app/Contents/Developer/Platforms/\n// iPhoneSimulator.platform/Developer/Library/Frameworks/XCTest\n// .framework';\n@@ -144,6 +143,29 @@ function addFramework(\nprojectPath, frameworkProjectDir, frameworkOutputDir,\nbuildWithTests, testingInfrastructureDir) {\n+ checkoutThaliCoreViaCarthage(\n+ frameworkOutputDir, frameworkProjectDir, buildWithTests)\n+ .then(function () {\n+ console.log('Checkouting done!');\n+\n+ var checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\n+ var buildDir = path.join(frameworkOutputDir, 'Carthage', 'Build');\n+ console.log('checkout dir is ' + checkoutDir);\n+ console.log('build dir is ' + buildDir);\n+\n+ return biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests)\n+ })\n+ .then (function () {\n+ console.log('Building CocoaAsyncSocket done!');\n+\n+ var checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\n+ var buildDir = path.join(frameworkOutputDir, 'Carthage', 'Build');\n+ console.log('checkout dir is ' + checkoutDir);\n+ console.log('build dir is ' + buildDir);\n+\n+ return biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests)\n+ })\n+ .then (function () {\n// We need to build ThaliCore.framework before embedding it into the project\nreturn buildFramework(\nframeworkProjectDir, frameworkOutputDir, buildWithTests)\n@@ -180,8 +202,80 @@ function addFramework(\npbxProjectPath, xcodeProject.writeSync(), 'utf-8');\n});\n});\n+ })\n};\n+function checkoutThaliCoreViaCarthage(cartfileDir, outputDir, buildWithTests) {\n+ var changeDirCmd = 'cd ' + cartfileDir;\n+ var carthageCmd = 'carthage checkout';\n+ var checkoutCmd = changeDirCmd + ' && ' + carthageCmd;\n+\n+ console.log('Checkouting ThaliCore-iOS and its dependencies');\n+\n+ return exec(checkoutCmd, { maxBuffer: 10*1024*1024 } )\n+ .then(function () {\n+ return fs.ensureDir(outputDir);\n+ })\n+}\n+\n+function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\n+ var projectDir = 'CocoaAsyncSocket';\n+ var projectName = 'CocoaAsyncSocket';\n+ var projectScheme = 'iOS Framework';\n+\n+ var projectConfiguration = 'Release';\n+ var sdk = 'iphoneos';\n+ var projectPath = path.join(checkoutDir, projectDir, projectName + '.xcodeproj');\n+ var buildDir = path.join(buildDir, projectName);\n+\n+ var changeDirCmd = 'cd ' + checkoutDir + '/' + projectName;\n+ var buildCmd = 'set -o pipefail && ' +\n+ 'xcodebuild -project' +\n+ ' \\\"' + projectPath + '\\\"' +\n+ ' -scheme ' + '\\\"' + projectScheme + '\\\"' +\n+ ' -configuration ' + projectConfiguration +\n+ ' -sdk ' + sdk +\n+ ' ONLY_ACTIVE_ARCH=NO ' +\n+ ' BUILD_DIR=' + '\\\"' + buildDir + '\\\"' +\n+ ' clean build';\n+\n+ var changeDirAndBuildCmd = changeDirCmd + ' && ' + buildCmd;\n+\n+ return exec(changeDirAndBuildCmd, { maxBuffer: 10*1024*1024 } )\n+ .then(function () {\n+ return fs.ensureDir(buildDir);\n+ })\n+}\n+\n+function biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\n+ var projectDir = 'swift-corelibs-xctest';\n+ var projectName = 'XCTest'\n+ var projectScheme = 'SwiftXCTest-iOS';\n+\n+ var projectConfiguration = 'Release';\n+ var sdk = 'iphoneos';\n+ var projectPath = path.join(checkoutDir, projectDir, projectName + '.xcodeproj');\n+ var buildDir = path.join(buildDir, projectName);\n+\n+ var changeDirCmd = 'cd ' + checkoutDir + '/' + projectDir;\n+ var buildCmd = 'set -o pipefail && ' +\n+ 'xcodebuild -project' +\n+ ' \\\"' + projectPath + '\\\"' +\n+ ' -scheme ' + '\\\"' + projectScheme + '\\\"' +\n+ ' -configuration ' + projectConfiguration +\n+ ' -sdk ' + sdk +\n+ ' ONLY_ACTIVE_ARCH=NO ' +\n+ ' BUILD_DIR=' + '\\\"' + buildDir + '\\\"' +\n+ ' clean build';\n+\n+ var changeDirAndBuildCmd = changeDirCmd + ' && ' + buildCmd;\n+\n+ return exec(changeDirAndBuildCmd, { maxBuffer: 10*1024*1024 } )\n+ .then(function () {\n+ return fs.ensureDir(buildDir);\n+ })\n+}\n+\n/**\n* @param {string} projectDir Xcode project directory\n* @param {string} outputDir Framework output directory\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update nativeInstaller.js in order to support carthage.
|
675,379 |
14.03.2017 17:24:19
| -10,800 |
a606133f8590c42b2f22d3374e216a9aec941f7c
|
Update build dir for SwiftXCTest/CocoaAsyncSocket frameworks.
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/ios/nativeInstaller.js",
"new_path": "thali/install/ios/nativeInstaller.js",
"diff": "@@ -149,7 +149,7 @@ function addFramework(\nconsole.log('Checkouting done!');\nvar checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\n- var buildDir = path.join(frameworkOutputDir, 'Carthage', 'Build');\n+ var buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\nconsole.log('checkout dir is ' + checkoutDir);\nconsole.log('build dir is ' + buildDir);\n@@ -159,7 +159,7 @@ function addFramework(\nconsole.log('Building CocoaAsyncSocket done!');\nvar checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\n- var buildDir = path.join(frameworkOutputDir, 'Carthage', 'Build');\n+ var buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\nconsole.log('checkout dir is ' + checkoutDir);\nconsole.log('build dir is ' + buildDir);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update build dir for SwiftXCTest/CocoaAsyncSocket frameworks.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.