diff --git a/.gitmodules b/.gitmodules index 3d6091fbe8..2fcaae8b28 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "tools/kothic"] path = tools/kothic url = git://github.com/mapsme/kothic.git +[submodule "3party/Alohalytics"] + path = 3party/Alohalytics + url = git@github.com:mapsme/Alohalytics.git diff --git a/3party/Alohalytics b/3party/Alohalytics new file mode 160000 index 0000000000..3ded80bf5d --- /dev/null +++ b/3party/Alohalytics @@ -0,0 +1 @@ +Subproject commit 3ded80bf5d94bfc20faaeeb6e40f1e7a25715bd9 diff --git a/3party/Alohalytics/.clang-format b/3party/Alohalytics/.clang-format deleted file mode 100644 index 2ad158197b..0000000000 --- a/3party/Alohalytics/.clang-format +++ /dev/null @@ -1,8 +0,0 @@ -BasedOnStyle: Google -ColumnLimit: 120 # Fits GitHub pull-request review width. -BinPackParameters: false # Allow either all method's parameters on one line or one parameter per line, no packing. - -Language: Cpp -# Force pointers to the type for C++. -DerivePointerAlignment: false -PointerAlignment: Middle diff --git a/3party/Alohalytics/.gitignore b/3party/Alohalytics/.gitignore deleted file mode 100644 index ff0e8dbd1b..0000000000 --- a/3party/Alohalytics/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -build -examples/.idea diff --git a/3party/Alohalytics/LICENSE b/3party/Alohalytics/LICENSE deleted file mode 100644 index 52f49a1805..0000000000 --- a/3party/Alohalytics/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Alexander Zolotarev from Minsk, Belarus - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/3party/Alohalytics/README.md b/3party/Alohalytics/README.md deleted file mode 100644 index 89029f581f..0000000000 --- a/3party/Alohalytics/README.md +++ /dev/null @@ -1,103 +0,0 @@ -Aloha, developer! - -Alohalytics statistics engine solves following problems: -- Track any event from iOS/Android/C++ code (e.g. events from Java and native C++ code will be collected perfectly). -- Track basic events like iOS/Android app installs/updates/launches. -- Track basic devices information including IDFA and Google Play Advertising IDs. -- Collect all events while device is offline. - -More features are coming soon! - -If you have any questions, please contact Alex Zolotarev from Minsk, Belarus. - -iOS -====== -Minimum supported iOS version is 5.1. - -If you target iOS 5.1, then add an optional 'AdSupport.framework' to your binary to access IDFA (for iOS 6+ you can add it as 'required'). - -If your app uses background fetch, you can use ```[Alohalytics forceUpload];``` from ```application:performFetchWithCompletionHandler``` in your app delegate to improve events delivery. - -App updates are detected by changing CURRENT_PROJECT_VERSION in CFBundleShortVersionString key in the plist file. - -Built-in logged events ------- -- $install -- $launch -- $update -- $iosDeviceIds -- $iosDeviceInfo -- $browserUserAgent -- $applicationDidBecomeActive -- $applicationWillResignActive -- $applicationWillEnterForeground -- $applicationDidEnterBackground -- $applicationWillTerminate - - -Android -====== -Minimum supported Android version is 2.3 (API level 9). - -Built-in logged events ------- -- $install -- $launch -- $update -- $androidIds -- $androidDeviceInfo -- $startSession -- $endSession -- $onStart -- $onStop - -Other platforms -====== -Mac OS X should work perfectly. Linux has (untested) HTTP transport support via curl. Windows does not have native HTTP transport support. -C++ core requires C++11 compiler support. - -nginx server setup example -====== -``` -http { - log_format alohalytics '$remote_addr [$time_local] "$request" $status $content_length "$http_user_agent" $content_type $http_content_encoding'; - server { - listen 8080; # <-- Change to actual server port. - server_name localhost; # <-- Change to actual server name. - # To hide nginx version. - server_tokens off; - - # Location starts with os version prefix to filter out some random web requests. - location ~ ^/(ios|android|mac)/(.+)/(.+) { - # Store for later use. - set $OS $1; - - # Most filtering can be easily done on nginx side: - # Our clients send only POST requests. - limit_except POST { deny all; } - # Content-Length should be valid, but it is checked anyway on FastCGI app's code side. - # Content-Type should be "application/alohalytics-binary-blob" - if ($content_type != "application/alohalytics-binary-blob") { - return 415; # Unsupported Media Type - } - # Content-Encoding should be "gzip" - if ($http_content_encoding != "gzip") { - return 400; # Bad Request - } - client_body_buffer_size 1M; - client_body_temp_path /tmp 2; # <-- Change to writable directory which can temporarily store large POST bodies (rare case). - client_max_body_size 100M; - - access_log /tmp/aloha-$OS-access.log alohalytics; # <-- Change to actual log directory. - # Unfortunately, error_log does not support variables. - error_log /tmp/aloha-error.log notice; # <-- Change to actual log directory. - - fastcgi_pass_request_headers on; - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_pass 127.0.0.1:8888; # <-- Change to actual FastCGI app address and port. - } - } -} - -``` diff --git a/3party/Alohalytics/alohalytics.pro b/3party/Alohalytics/alohalytics.pro deleted file mode 100644 index db52276e0f..0000000000 --- a/3party/Alohalytics/alohalytics.pro +++ /dev/null @@ -1,42 +0,0 @@ -TEMPLATE = app -CONFIG *= console c++11 -CONFIG -= app_bundle qt - -SOURCES += examples/cpp/example.cc \ - src/cpp/alohalytics.cc \ - -HEADERS += src/alohalytics.h \ - src/event_base.h \ - src/file_manager.h \ - src/gzip_wrapper.h \ - src/http_client.h \ - src/location.h \ - src/logger.h \ - src/messages_queue.h \ - -QMAKE_LFLAGS *= -lz - -macx-* { - HEADERS += src/alohalytics_objc.h - OBJECTIVE_SOURCES += src/apple/http_client_apple.mm \ - src/apple/alohalytics_objc.mm \ - - QMAKE_OBJECTIVE_CFLAGS *= -fobjc-arc - QMAKE_LFLAGS *= -framework Foundation -} - -macx-*|linux-* { - SOURCES += src/posix/file_manager_posix_impl.cc -} - -win* { - SOURCES += src/windows/file_manager_windows_impl.cc -} - -linux-* { - SOURCES += src/posix/http_client_curl.cc -} - -android-* { - SOURCES += src/android/jni/jni_alohalytics.cc -} diff --git a/3party/Alohalytics/examples/android/.gitignore b/3party/Alohalytics/examples/android/.gitignore deleted file mode 100644 index 79859d12a5..0000000000 --- a/3party/Alohalytics/examples/android/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.gradle -/local.properties -/.idea -.DS_Store -/build -*.iml diff --git a/3party/Alohalytics/examples/android/README.md b/3party/Alohalytics/examples/android/README.md deleted file mode 100644 index bb60798c29..0000000000 --- a/3party/Alohalytics/examples/android/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Create local.properties file here with paths to NDK and SDK: - -sdk.dir=/path/to/android/sdk -ndk.dir=/path/to/android/ndk diff --git a/3party/Alohalytics/examples/android/build.gradle b/3party/Alohalytics/examples/android/build.gradle deleted file mode 100644 index f58cb3b446..0000000000 --- a/3party/Alohalytics/examples/android/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:+' - } -} - -allprojects { - repositories { - jcenter() - } -} - -apply plugin: 'com.android.application' - -dependencies { - // This one is needed to get Google Play advertising ID if Google Play Services are available on the device. - compile 'com.google.android.gms:play-services-base:+' - compile 'com.google.android.gms:play-services-ads:+' -} - -android { - compileSdkVersion 23 - buildToolsVersion '23' - - defaultConfig { - applicationId 'org.alohalytics.demoapp' - minSdkVersion 9 - targetSdkVersion 23 - versionCode 1 - versionName '1.0' - - ndk { - moduleName 'alohalytics' - stl 'c++_static' - cFlags '-frtti -fexceptions' - ldLibs 'log', 'atomic', 'z' - } - } - - sourceSets.main { - java.srcDirs = ['src/main/java', '../../src/android/java'] - jni.srcDirs = ['../../src/cpp', '../../src/android/jni'] - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } -} diff --git a/3party/Alohalytics/examples/android/gradle.properties b/3party/Alohalytics/examples/android/gradle.properties deleted file mode 100644 index dfbe478748..0000000000 --- a/3party/Alohalytics/examples/android/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -android.useDeprecatedNdk=true diff --git a/3party/Alohalytics/examples/android/gradle/wrapper/gradle-wrapper.jar b/3party/Alohalytics/examples/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 085a1cdc27..0000000000 Binary files a/3party/Alohalytics/examples/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/3party/Alohalytics/examples/android/gradle/wrapper/gradle-wrapper.properties b/3party/Alohalytics/examples/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index cddb2c4647..0000000000 --- a/3party/Alohalytics/examples/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri May 22 17:48:54 MSK 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip diff --git a/3party/Alohalytics/examples/android/gradlew b/3party/Alohalytics/examples/android/gradlew deleted file mode 100755 index 91a7e269e1..0000000000 --- a/3party/Alohalytics/examples/android/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/3party/Alohalytics/examples/android/gradlew.bat b/3party/Alohalytics/examples/android/gradlew.bat deleted file mode 100644 index 8a0b282aa6..0000000000 --- a/3party/Alohalytics/examples/android/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/HttpTransportTest.java b/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/HttpTransportTest.java deleted file mode 100644 index 0c451e120c..0000000000 --- a/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/HttpTransportTest.java +++ /dev/null @@ -1,263 +0,0 @@ -/******************************************************************************* - The MIT License (MIT) - - Copyright (c) 2014 Alexander Zolotarev from Minsk, Belarus - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - *******************************************************************************/ - -package org.alohalytics.test; - -import android.test.InstrumentationTestCase; - -import org.alohalytics.HttpTransport; - -import java.io.File; -import java.io.FileNotFoundException; - -// Testing Fundamentals -@SuppressWarnings("ConstantConditions") -public class HttpTransportTest extends InstrumentationTestCase { - - static { - // For faster unit testing on the real-world servers. - HttpTransport.TIMEOUT_IN_MILLISECONDS = 3000; - } - - public static final String CACHE_DIR = "/data/data/org.alohalytics.demoapp/cache/"; - public static final String HTTPBIN_POST_URL = "http://httpbin.org/post"; - - @Override - protected void setUp() { - new File(CACHE_DIR).mkdirs(); - } - - private String getFullWritablePathForFile(String fileName) { - return CACHE_DIR + fileName; - } - - public void testGetIntoMemory() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/drip?numbytes=7"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - assertEquals(p.url, r.receivedUrl); - assertEquals("*******", new String(r.data)); - } - - public void testGetIntoFile() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/drip?numbytes=5"); - try { - p.outputFilePath = getFullWritablePathForFile("some_test_file_for_http_get"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - assertNull(r.data); - assertEquals("*****", Util.ReadFileAsUtf8String(p.outputFilePath)); - } finally { - (new File(p.outputFilePath)).delete(); - } - } - - public void testPostFromMemoryIntoMemory() throws Exception { - final String postBody = "Hello, World!"; - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setData(postBody.getBytes(), "application/octet-stream", "POST"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - final String receivedBody = new String(r.data); - // Server mirrors our content. - assertTrue(receivedBody, receivedBody.contains(postBody)); - } - - public void testPutFromMemoryIntoMemory() throws Exception { - final String putBody = "This is HTTP PUT request"; - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/put"); - p.setData(putBody.getBytes(), "application/octet-stream", "PUT"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - final String receivedBody = new String(r.data); - // Server mirrors our content. - assertTrue(receivedBody, receivedBody.contains(putBody)); - } - - public void testPostMissingContentType() throws Exception { - // here is missing p.contentType = "application/octet-stream"; - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setData("Hello, World!".getBytes(), null, "POST"); - boolean caughtException = false; - try { - final HttpTransport.Params r = HttpTransport.run(p); - assertFalse(true); - } catch (NullPointerException ex) { - caughtException = true; - } - assertTrue(caughtException); - } - - public void testPostFromInvalidFile() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setInputFilePath(getFullWritablePathForFile("this_file_should_not_exist"), "text/plain", "POST"); - boolean caughtException = false; - try { - final HttpTransport.Params r = HttpTransport.run(p); - assertFalse(true); - } catch (FileNotFoundException ex) { - caughtException = true; - } - assertTrue(caughtException); - } - - public void testPostFromFileIntoMemory() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setInputFilePath(getFullWritablePathForFile("some_input_test_file_for_http_post"), "text/plain", "POST"); - try { - // Use file name as a test string for the post body. - Util.WriteStringToFile(p.inputFilePath, p.inputFilePath); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - final String receivedBody = new String(p.data); - assertTrue(receivedBody, receivedBody.contains(p.inputFilePath)); - } finally { - (new File(p.inputFilePath)).delete(); - } - } - - public void testPostFromMemoryIntoFile() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setData(HTTPBIN_POST_URL.getBytes(), "text/plain", "POST"); - p.outputFilePath = getFullWritablePathForFile("some_output_test_file_for_http_post"); - try { - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - // TODO(AlexZ): Think about using data field in the future for error pages (404 etc) - //assertNull(r.data); - final String receivedBody = Util.ReadFileAsUtf8String(p.outputFilePath); - assertTrue(receivedBody, receivedBody.contains("\"data\": \"" + HTTPBIN_POST_URL + "\"")); - } finally { - (new File(p.outputFilePath)).delete(); - } - } - - public void testPostFromFileIntoFile() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setInputFilePath(getFullWritablePathForFile("some_complex_input_test_file_for_http_post"), "text/plain", "POST"); - p.outputFilePath = getFullWritablePathForFile("some_complex_output_test_file_for_http_post"); - final String postBodyToSend = "Aloha, this text should pass from one file to another. Mahalo!"; - try { - Util.WriteStringToFile(postBodyToSend, p.inputFilePath); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - final String receivedBody = Util.ReadFileAsUtf8String(p.outputFilePath); - assertTrue(receivedBody, receivedBody.contains(postBodyToSend)); - } finally { - (new File(p.inputFilePath)).delete(); - (new File(p.outputFilePath)).delete(); - } - } - - public void testErrorCodes() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/status/403"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(403, r.httpResponseCode); - } - - public void testHttps() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("https://httpbin.org/get?Aloha=Mahalo"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - assertEquals(r.url, r.receivedUrl); - final String receivedBody = new String(r.data); - assertTrue(receivedBody.contains("\"Aloha\": \"Mahalo\"")); - } - - public void testHttpRedirect302() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/redirect-to?url=http%3A%2F%2Falohalytics.org%2F"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(302, r.httpResponseCode); - assertEquals(r.receivedUrl, "http://alohalytics.org/"); - assertTrue(!r.url.equals(r.receivedUrl)); - } - - public void testUserAgent() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/user-agent"); - p.userAgent = "Aloha User Agent"; - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - final String receivedBody = new String(r.data); - assertTrue(receivedBody.contains(p.userAgent)); - } - - public void testHttpRedirect301() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://maps.me"); - final HttpTransport.Params r = HttpTransport.run(p); - // Client should not follow redirects automatically. - assertEquals(301, r.httpResponseCode); - assertEquals(r.receivedUrl, "http://maps.me/en/"); - assertTrue(!r.url.equals(r.receivedUrl)); - } - - public void testInvalidHost() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://very.bad.host"); - boolean caughtException = false; - try { - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(-1, r.httpResponseCode); - assertFalse(true); - } catch (java.net.UnknownHostException ex) { - caughtException = true; - } - assertTrue(caughtException); - } - - public void testPostFromEmptyFileIntoMemory() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params(HTTPBIN_POST_URL); - p.setInputFilePath(getFullWritablePathForFile("empty_input_test_file_for_http_post"), "text/plain", "POST"); - try { - Util.WriteStringToFile("", p.inputFilePath); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - final String receivedBody = new String(p.data); - assertTrue(receivedBody, receivedBody.contains("\"data\": \"\"")); - assertTrue(receivedBody, receivedBody.contains("\"form\": {}")); - } finally { - (new File(p.inputFilePath)).delete(); - } - } - - public void testResponseContentType() throws Exception { - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/get"); - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - assertEquals(p.url, r.receivedUrl); - assertEquals("application/json", r.contentType); - } - - public void testHttpBasicAuth() throws Exception { - final String user = "user"; - final String password = "password"; - final HttpTransport.Params p = new HttpTransport.Params("http://httpbin.org/basic-auth/" + user + "/" + password); - p.basicAuthUser = user; - p.basicAuthPassword = password; - final HttpTransport.Params r = HttpTransport.run(p); - assertEquals(200, r.httpResponseCode); - assertEquals(p.url, r.receivedUrl); - final String receivedBody = new String(r.data); - assertTrue(receivedBody, receivedBody.contains("\"authenticated\": true")); - } - -} diff --git a/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/Util.java b/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/Util.java deleted file mode 100644 index e5b90df1c2..0000000000 --- a/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/Util.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - The MIT License (MIT) - - Copyright (c) 2014 Alexander Zolotarev from Minsk, Belarus - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - *******************************************************************************/ - -package org.alohalytics.test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -public class Util { - - public static String ReadFileAsUtf8String(String filePath) throws IOException { - final File file = new File(filePath); - final long fileLength = file.length(); - if (fileLength > Integer.MAX_VALUE) { - throw new IOException(filePath + " size is too large: " + fileLength); - } - final byte[] buffer = new byte[(int) fileLength]; - final FileInputStream istream = new FileInputStream(file); - try { - if (fileLength != istream.read(buffer)) { - throw new IOException("Error while reading contents of " + filePath); - } - } finally { - istream.close(); - } - return new String(buffer, "UTF-8"); - } - - public static void WriteStringToFile(String toWrite, String filePath) throws IOException { - final FileOutputStream ostream = new FileOutputStream(filePath); - try { - ostream.write(toWrite.getBytes()); - } finally { - ostream.close(); - } - } -} diff --git a/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/UtilTest.java b/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/UtilTest.java deleted file mode 100644 index 85564f7990..0000000000 --- a/3party/Alohalytics/examples/android/src/androidTest/java/org/alohalytics/test/UtilTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - The MIT License (MIT) - - Copyright (c) 2014 Alexander Zolotarev from Minsk, Belarus - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - *******************************************************************************/ - -package org.alohalytics.test; - -import android.test.InstrumentationTestCase; - -import java.io.File; -import java.io.FileNotFoundException; - -public class UtilTest extends InstrumentationTestCase { - - @Override - protected void setUp() { - new File(org.alohalytics.test.HttpTransportTest.CACHE_DIR).mkdirs(); - } - - private String getFullWritablePathForFile(String fileName) { - return org.alohalytics.test.HttpTransportTest.CACHE_DIR + fileName; - } - - public void testReadAndWriteStringToFile() throws Exception { - final String testFileName = getFullWritablePathForFile("test_write_string_to_file"); - try { - Util.WriteStringToFile(testFileName, testFileName); - assertEquals(testFileName, Util.ReadFileAsUtf8String(testFileName)); - } finally { - new File(testFileName).delete(); - } - } - - public void testFailedWriteStringToFile() throws Exception { - final String invalidFileName = getFullWritablePathForFile("invalid?path\\with/slashes"); - boolean caughtException = false; - try { - Util.WriteStringToFile(invalidFileName, invalidFileName); - assertFalse(true); - } catch (FileNotFoundException ex) { - caughtException = true; - } finally { - new File(invalidFileName).delete(); - } - assertTrue(caughtException); - } - - public void testFailedReadFileAsString() throws Exception { - final String notExistingFileName = getFullWritablePathForFile("this_file_should_not_exist_for_the_test"); - boolean caughtException = false; - try { - final String s = Util.ReadFileAsUtf8String(notExistingFileName); - assertFalse(true); - } catch (FileNotFoundException ex) { - caughtException = true; - } - assertTrue(caughtException); - } - -} diff --git a/3party/Alohalytics/examples/android/src/main/AndroidManifest.xml b/3party/Alohalytics/examples/android/src/main/AndroidManifest.xml deleted file mode 100644 index 53c0659da8..0000000000 --- a/3party/Alohalytics/examples/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/3party/Alohalytics/examples/android/src/main/java/org/alohalytics/demoapp/MainActivity.java b/3party/Alohalytics/examples/android/src/main/java/org/alohalytics/demoapp/MainActivity.java deleted file mode 100644 index dc97c34108..0000000000 --- a/3party/Alohalytics/examples/android/src/main/java/org/alohalytics/demoapp/MainActivity.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - The MIT License (MIT) - - Copyright (c) 2014 Alexander Zolotarev from Minsk, Belarus - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - *******************************************************************************/ - -package org.alohalytics.demoapp; - -import android.app.Activity; -import android.content.pm.PackageManager; -import android.location.Location; -import android.location.LocationManager; -import android.os.Build; -import android.os.Bundle; -import android.view.KeyEvent; -import android.view.View; -import android.widget.TextView; - -import org.alohalytics.Statistics; - -import java.util.HashMap; - -public class MainActivity extends Activity { - - private static final String STATISTICS_SERVER_URL = "http://localhost:8080/"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - // Optionally enable debug mode for easier integration (but don't forget to remove it in production!). - Statistics.setDebugMode(true); - Statistics.setup(STATISTICS_SERVER_URL, this); - - // To handle Enter key for convenience testing on emulator - findViewById(R.id.eventNameEditor).setOnKeyListener(new View.OnKeyListener() { - public boolean onKey(View v, int keyCode, KeyEvent event) { - // If the event is a key-down event on the "enter" button - if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { - onSendButtonClicked(null); - return true; - } - return false; - } - }); - } - - @Override - protected void onStart() { - super.onStart(); - // onStart and onStop are needed for reliable session tracking/uploading. - Statistics.onStart(this); - } - - @Override - protected void onStop() { - super.onStop(); - // onStart and onStop are needed for reliable session tracking/uploading. - Statistics.onStop(this); - } - - @Override - protected void onResume() { - super.onResume(); - - // Very simple event. - Statistics.logEvent("simple_event"); - - // Event with parameter (key=value) - Statistics.logEvent("device_manufacturer", Build.MANUFACTURER); - - final HashMap kv = new HashMap<>(); - kv.put("brand", Build.BRAND); - kv.put("device", Build.DEVICE); - kv.put("model", Build.MODEL); - // Event with a key=value pairs. - Statistics.logEvent("device", kv); - - final String packageName = getPackageName(); - // Last version null value will be replaced below. - final String[] arr = {"package", packageName, "demo_null_value", null, "version", null}; - try { - arr[arr.length - 1] = getPackageManager().getPackageInfo(packageName, 0).versionName; - } catch (PackageManager.NameNotFoundException ex) { - ex.printStackTrace(); - } - // Event with a key=value pairs but passed as an array. - Statistics.logEvent("app", arr); - - // Event with location. - Location l = new Location(LocationManager.NETWORK_PROVIDER); - l.setTime(1423169916587L); - l.setAccuracy(0.3f); - l.setLatitude(-84.123456789); - l.setLongitude(177.123456789); - l.setAltitude(-11); - l.setSpeed(27.123456789f); - l.setBearing(0.123456789f); - Statistics.logEvent("location", new String[]{"key", "value"}, l); - - // Example event to track user activity. - Statistics.logEvent("$onResume", getLocalClassName()); - } - - @Override - protected void onPause() { - super.onPause(); - Statistics.logEvent("$onPause", getLocalClassName()); - } - - public void onSendButtonClicked(View v) { - final String eventValue = ((TextView) findViewById(R.id.eventNameEditor)).getText().toString(); - Statistics.logEvent("send_button_clicked", eventValue); - } -} diff --git a/3party/Alohalytics/examples/android/src/main/res/drawable-hdpi/ic_launcher.png b/3party/Alohalytics/examples/android/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 96a442e5b8..0000000000 Binary files a/3party/Alohalytics/examples/android/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/3party/Alohalytics/examples/android/src/main/res/drawable-mdpi/ic_launcher.png b/3party/Alohalytics/examples/android/src/main/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 359047dfa4..0000000000 Binary files a/3party/Alohalytics/examples/android/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/3party/Alohalytics/examples/android/src/main/res/drawable-xhdpi/ic_launcher.png b/3party/Alohalytics/examples/android/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 71c6d760f0..0000000000 Binary files a/3party/Alohalytics/examples/android/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/3party/Alohalytics/examples/android/src/main/res/drawable-xxhdpi/ic_launcher.png b/3party/Alohalytics/examples/android/src/main/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index 4df1894644..0000000000 Binary files a/3party/Alohalytics/examples/android/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/3party/Alohalytics/examples/android/src/main/res/layout/activity_main.xml b/3party/Alohalytics/examples/android/src/main/res/layout/activity_main.xml deleted file mode 100644 index 6eea4d88b9..0000000000 --- a/3party/Alohalytics/examples/android/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - -