From 5d308865d0783d0cd70f7453c77980835ac5648e Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Wed, 21 Mar 2018 14:16:02 +0100 Subject: update android-sdk. Now it is possible to compile with clang Change-Id: I156aa48dd90467a2a7540eec11839c0111b13bd2 Signed-off-by: Angelo Mantellini --- HttpServer/.gitignore | 9 + HttpServer/app/.gitignore | 1 + HttpServer/app/CMakeLists.txt | 85 ++++++++ HttpServer/app/build.gradle | 79 +++++++ HttpServer/app/cmake/Modules/FindCCNX_Common.cmake | 52 +++++ HttpServer/app/cmake/Modules/FindCCNX_Portal.cmake | 53 +++++ .../app/cmake/Modules/FindCCNX_Transport_Rta.cmake | 63 ++++++ HttpServer/app/cmake/Modules/FindCURL.cmake | 69 ++++++ HttpServer/app/cmake/Modules/FindHttpServer.cmake | 39 ++++ HttpServer/app/cmake/Modules/FindJsoncpp.cmake | 47 ++++ HttpServer/app/cmake/Modules/FindLibEvent.cmake | 47 ++++ HttpServer/app/cmake/Modules/FindLibicnet.cmake | 39 ++++ HttpServer/app/cmake/Modules/FindLibparc.cmake | 52 +++++ HttpServer/app/cmake/Modules/FindLongBow.cmake | 58 +++++ HttpServer/app/cmake/Modules/FindUncrustify.cmake | 8 + HttpServer/app/cmake/Modules/detectCacheSize.cmake | 21 ++ HttpServer/app/cmake/Modules/version.cmake | 15 ++ HttpServer/app/cmake/get_version.sh | 20 ++ HttpServer/app/httpserver.keystore | Bin 0 -> 2257 bytes HttpServer/app/proguard-rules.pro | 21 ++ .../hicnhttpserver/ExampleInstrumentedTest.java | 41 ++++ HttpServer/app/src/main/AndroidManifest.xml | 33 +++ HttpServer/app/src/main/cpp/httpServerWrap.cpp | 236 +++++++++++++++++++++ HttpServer/app/src/main/ic_launcher-web.png | Bin 0 -> 15044 bytes .../com/httpserver/HttpServerActivity.java | 187 ++++++++++++++++ .../httpserver/com/service/HttpServerService.java | 156 ++++++++++++++ .../httpserver/com/supportlibrary/HttpServer.java | 46 ++++ .../java/icn/httpserver/com/utility/Constants.java | 28 +++ .../com/utility/ResourcesEnumerator.java | 34 +++ .../res/drawable-v24/ic_launcher_foreground.xml | 34 +++ .../main/res/drawable/ic_launcher_background.xml | 170 +++++++++++++++ .../src/main/res/layout/activity_http_server.xml | 207 ++++++++++++++++++ .../app/src/main/res/layout/popup_message.xml | 44 ++++ .../src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../res/mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 1408 bytes .../res/mipmap-hdpi/ic_launcher_foreground.png | Bin 0 -> 1626 bytes .../src/main/res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 3195 bytes .../app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 879 bytes .../res/mipmap-mdpi/ic_launcher_foreground.png | Bin 0 -> 1022 bytes .../src/main/res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 1903 bytes .../app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 2006 bytes .../res/mipmap-xhdpi/ic_launcher_foreground.png | Bin 0 -> 2247 bytes .../main/res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 4725 bytes .../app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 3300 bytes .../res/mipmap-xxhdpi/ic_launcher_foreground.png | Bin 0 -> 3568 bytes .../main/res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 7656 bytes .../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 4719 bytes .../res/mipmap-xxxhdpi/ic_launcher_foreground.png | Bin 0 -> 4874 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 11172 bytes HttpServer/app/src/main/res/values/colors.xml | 6 + .../src/main/res/values/ic_launcher_background.xml | 4 + HttpServer/app/src/main/res/values/strings.xml | 3 + HttpServer/app/src/main/res/values/styles.xml | 11 + .../com/hicnhttpserver/ExampleUnitTest.java | 32 +++ HttpServer/build.gradle | 28 +++ HttpServer/gradle.properties | 17 ++ HttpServer/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + HttpServer/gradlew | 160 ++++++++++++++ HttpServer/gradlew.bat | 90 ++++++++ HttpServer/settings.gradle | 1 + 62 files changed, 2362 insertions(+) create mode 100644 HttpServer/.gitignore create mode 100644 HttpServer/app/.gitignore create mode 100644 HttpServer/app/CMakeLists.txt create mode 100644 HttpServer/app/build.gradle create mode 100644 HttpServer/app/cmake/Modules/FindCCNX_Common.cmake create mode 100644 HttpServer/app/cmake/Modules/FindCCNX_Portal.cmake create mode 100644 HttpServer/app/cmake/Modules/FindCCNX_Transport_Rta.cmake create mode 100644 HttpServer/app/cmake/Modules/FindCURL.cmake create mode 100644 HttpServer/app/cmake/Modules/FindHttpServer.cmake create mode 100644 HttpServer/app/cmake/Modules/FindJsoncpp.cmake create mode 100644 HttpServer/app/cmake/Modules/FindLibEvent.cmake create mode 100644 HttpServer/app/cmake/Modules/FindLibicnet.cmake create mode 100644 HttpServer/app/cmake/Modules/FindLibparc.cmake create mode 100644 HttpServer/app/cmake/Modules/FindLongBow.cmake create mode 100644 HttpServer/app/cmake/Modules/FindUncrustify.cmake create mode 100644 HttpServer/app/cmake/Modules/detectCacheSize.cmake create mode 100644 HttpServer/app/cmake/Modules/version.cmake create mode 100755 HttpServer/app/cmake/get_version.sh create mode 100644 HttpServer/app/httpserver.keystore create mode 100644 HttpServer/app/proguard-rules.pro create mode 100644 HttpServer/app/src/androidTest/java/icn/httpserver/com/hicnhttpserver/ExampleInstrumentedTest.java create mode 100644 HttpServer/app/src/main/AndroidManifest.xml create mode 100644 HttpServer/app/src/main/cpp/httpServerWrap.cpp create mode 100644 HttpServer/app/src/main/ic_launcher-web.png create mode 100644 HttpServer/app/src/main/java/icn/httpserver/com/httpserver/HttpServerActivity.java create mode 100644 HttpServer/app/src/main/java/icn/httpserver/com/service/HttpServerService.java create mode 100644 HttpServer/app/src/main/java/icn/httpserver/com/supportlibrary/HttpServer.java create mode 100644 HttpServer/app/src/main/java/icn/httpserver/com/utility/Constants.java create mode 100644 HttpServer/app/src/main/java/icn/httpserver/com/utility/ResourcesEnumerator.java create mode 100644 HttpServer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 HttpServer/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 HttpServer/app/src/main/res/layout/activity_http_server.xml create mode 100644 HttpServer/app/src/main/res/layout/popup_message.xml create mode 100644 HttpServer/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 HttpServer/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 HttpServer/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 HttpServer/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png create mode 100644 HttpServer/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 HttpServer/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 HttpServer/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png create mode 100644 HttpServer/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 HttpServer/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 HttpServer/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png create mode 100644 HttpServer/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 HttpServer/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 HttpServer/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png create mode 100644 HttpServer/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 HttpServer/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 HttpServer/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png create mode 100644 HttpServer/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 HttpServer/app/src/main/res/values/colors.xml create mode 100644 HttpServer/app/src/main/res/values/ic_launcher_background.xml create mode 100644 HttpServer/app/src/main/res/values/strings.xml create mode 100644 HttpServer/app/src/main/res/values/styles.xml create mode 100644 HttpServer/app/src/test/java/icn/httpserver/com/hicnhttpserver/ExampleUnitTest.java create mode 100644 HttpServer/build.gradle create mode 100644 HttpServer/gradle.properties create mode 100644 HttpServer/gradle/wrapper/gradle-wrapper.jar create mode 100644 HttpServer/gradle/wrapper/gradle-wrapper.properties create mode 100755 HttpServer/gradlew create mode 100644 HttpServer/gradlew.bat create mode 100644 HttpServer/settings.gradle (limited to 'HttpServer') diff --git a/HttpServer/.gitignore b/HttpServer/.gitignore new file mode 100644 index 00000000..39fb081a --- /dev/null +++ b/HttpServer/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/HttpServer/app/.gitignore b/HttpServer/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/HttpServer/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/HttpServer/app/CMakeLists.txt b/HttpServer/app/CMakeLists.txt new file mode 100644 index 00000000..e58fedb6 --- /dev/null +++ b/HttpServer/app/CMakeLists.txt @@ -0,0 +1,85 @@ +# For more information about using CMake with Android Studio, read the +# documentation: https://d.android.com/studio/projects/add-native-code.html + +# Sets the minimum version of CMake required to build the native library. + +cmake_minimum_required(VERSION 3.4.1) + +# Creates and names a library, sets it as either STATIC +# or SHARED, and provides the relative paths to its source code. +# You can define multiple libraries, and CMake builds them for you. +# Gradle automatically packages shared libraries with your APK. +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set(CMAKE_FIND_ROOT_PATH "$ENV{DISTILLERY_ROOT_DIR}/usr_${CMAKE_SYSTEM_PROCESSOR};${CMAKE_FIND_ROOT_PATH}") + +find_package(Boost 1.53.0 COMPONENTS regex system filesystem REQUIRED) +include_directories(SYSTEM ${Boost_INCLUDE_DIR}) + +find_package ( OpenSSL REQUIRED ) + +find_package( LibEvent REQUIRED ) +include_directories(${LIBEVENT_INCLUDE_DIRS}) + +find_package( LongBow REQUIRED ) +include_directories(${LONGBOW_INCLUDE_DIRS}) + +find_package( Libparc REQUIRED ) +include_directories(${LIBPARC_INCLUDE_DIRS}) + +find_package( CCNX_Common REQUIRED ) +include_directories(${CCNX_COMMON_INCLUDE_DIRS}) + +find_package( CCNX_Transport_Rta REQUIRED ) +include_directories(${CCNX_TRANSPORT_RTA_INCLUDE_DIRS}) + +find_package( CCNX_Portal REQUIRED ) +include_directories(${CCNX_PORTAL_INCLUDE_DIRS}) + +find_package ( Threads REQUIRED ) + +find_package ( OpenSSL REQUIRED ) +find_package( Doxygen ) + +find_package(Jsoncpp REQUIRED) +include_directories(${JSONCPP_INCLUDE_DIRS}) + + +find_package(Libicnet REQUIRED) +include_directories(${LIBICNET_INCLUDE_DIRS}) + +find_package(CURL REQUIRED) + +find_package( HttpServer REQUIRED) +include_directories(${LIB_HTTP_SERVER_INCLUDE_DIRS}) + +add_library( # Sets the name of the library. + httpServerWrap + + # Sets the library as a shared library. + SHARED + + # Provides a relative path to your source file(s). + src/main/cpp/httpServerWrap.cpp ) + +# Searches for a specified prebuilt library and stores the path as a +# variable. Because CMake includes system libraries in the search path by +# default, you only need to specify the name of the public NDK library +# you want to add. CMake verifies that the library exists before +# completing its build. +find_library( # Sets the name of the path variable. + log-lib + + # Specifies the name of the NDK library that + # you want CMake to locate. + log ) +# Specifies libraries CMake should link to your target library. You +# can link multiple libraries, such as libraries you define in this +# build script, prebuilt third-party libraries, or system libraries. + +target_link_libraries( # Specifies the target library. + httpServerWrap + + # Links the target library to the log library + # included in the NDK. + ${log-lib} ${LIB_HTTP_SERVER_LIBRARIES} ${CURL_LIBRARIES} ${ANDROID_LIBRARIES} ${LIBICNET_LIBRARIES} ${LIBZF_LOG_LIBRARIES} ${Boost_LIBRARIES} ${JSONCPP_LIBRARIES} ${CCNX_PORTAL_LIBRARIES} ${CCNX_TRANSPORT_RTA_LIBRARIES} ${CCNX_COMMON_LIBRARIES} ${LIBPARC_LIBRARIES} ${LONGBOW_LIBRARIES} ${LIBEVENT_LIBRARIES} ${OPENSSL_LIBRARIES}) \ No newline at end of file diff --git a/HttpServer/app/build.gradle b/HttpServer/app/build.gradle new file mode 100644 index 00000000..4b30fccc --- /dev/null +++ b/HttpServer/app/build.gradle @@ -0,0 +1,79 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "icn.httpserver.com.httpserver" + minSdkVersion 24 + targetSdkVersion 26 + versionCode 2 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + externalNativeBuild { + cmake { + cppFlags "-std=c++11 -frtti -fexceptions -lz" + } + } + ndk { + // Specifies the ABI configurations of your native + // libraries Gradle should build and package with your APK. + abiFilters 'armeabi-v7a', 'x86' + } + } + + signingConfigs { + release { + storeFile file("httpserver.keystore") + storePassword "httpserver" + keyAlias "httpserver" + keyPassword "httpserver" + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + } + } + + android.applicationVariants.all { variant -> + variant.outputs.all { output -> + def outputFile = output.outputFile + outputFile + if (outputFile != null && outputFile.name.endsWith('.apk')) { + project.ext { + appName = 'httpserver'} + def fileName = outputFile.name.replace("app", + "$project.ext.appName") + outputFileName = fileName + + } + + } + } + + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } + buildToolsVersion '26.0.2' + dexOptions { + incremental true + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' +} diff --git a/HttpServer/app/cmake/Modules/FindCCNX_Common.cmake b/HttpServer/app/cmake/Modules/FindCCNX_Common.cmake new file mode 100644 index 00000000..da5a4119 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindCCNX_Common.cmake @@ -0,0 +1,52 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# CCNX_COMMON_FOUND: True if Libparc was found +# CCNX_COMMON_LIBRARY: The Libparc library +# CCNX_COMMON_LIBRARIES: The Libparc library and dependencies +# CCNX_COMMON_INCLUDE_DIR: The Libparc include dir +# + +set(CCNX_COMMON_SEARCH_PATH_LIST + ${CCNX_COMMON_HOME} + $ENV{CCNX_COMMON_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(CCNX_COMMON_INCLUDE_DIR ccnx/common/libccnxCommon_About.h + HINTS ${CCNX_COMMON_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libccnx-common includes") + +find_library(CCNX_COMMON_LIBRARY NAMES ccnx_common + HINTS ${CCNX_COMMON_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-common libraries") + +set(CCNX_COMMON_LIBRARIES ${CCNX_COMMON_LIBRARY}) +set(CCNX_COMMON_INCLUDE_DIRS ${CCNX_COMMON_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCNX_Common DEFAULT_MSG CCNX_COMMON_LIBRARY CCNX_COMMON_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindCCNX_Portal.cmake b/HttpServer/app/cmake/Modules/FindCCNX_Portal.cmake new file mode 100644 index 00000000..d7aa9066 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindCCNX_Portal.cmake @@ -0,0 +1,53 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################## +# +# Find the Libccnx-transport libraries and includes +# This module sets: +# CCNX_PORTAL_FOUND: True if Libparc was found +# CCNX_PORTAL_LIBRARY: The Libparc library +# CCNX_PORTAL_LIBRARIES: The Libparc library and dependencies +# CCNX_PORTAL_INCLUDE_DIR: The Libparc include dir +# + +set(CCNX_PORTAL_SEARCH_PATH_LIST + ${CCNX_PORTAL_HOME} + $ENV{CCNX_PORTAL_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(CCNX_PORTAL_INCLUDE_DIR ccnx/api/ccnx_Portal/ccnxPortal_About.h + HINTS ${CCNX_PORTAL_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libccnx-portal includes") + +find_library(CCNX_PORTAL_LIBRARY NAMES ccnx_api_portal + HINTS ${CCNX_PORTAL_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-portal libraries") + +set(CCNX_PORTAL_LIBRARIES ${CCNX_PORTAL_LIBRARY}) + +set(CCNX_PORTAL_INCLUDE_DIRS ${CCNX_PORTAL_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCNX_Portal DEFAULT_MSG CCNX_PORTAL_LIBRARY CCNX_PORTAL_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindCCNX_Transport_Rta.cmake b/HttpServer/app/cmake/Modules/FindCCNX_Transport_Rta.cmake new file mode 100644 index 00000000..bc0b0428 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindCCNX_Transport_Rta.cmake @@ -0,0 +1,63 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################## +# +# Find the Libccnx-transport libraries and includes +# This module sets: +# CCNX_TRANSPORT_RTA_FOUND: True if Libparc was found +# CCNX_TRANSPORT_RTA_LIBRARY: The Libparc library +# CCNX_TRANSPORT_RTA_LIBRARIES: The Libparc library and dependencies +# CCNX_TRANSPORT_RTA_INCLUDE_DIR: The Libparc include dir +# + +set(CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST + ${CCNX_TRANSPORT_RTA_HOME} + $ENV{CCNX_TRANSPORT_RTA_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(CCNX_TRANSPORT_RTA_INCLUDE_DIR ccnx/transport/librta_About.h + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libccnx-transport-rta includes") + +find_library(CCNX_TRANSPORT_RTA_LIBRARY NAMES ccnx_transport_rta + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-transport-rta libraries") + +find_library(CCNX_API_NOTIFY_LIBRARY NAMES ccnx_api_notify + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-transport-rta libraries") + +find_library(CCNX_API_CONTROL_LIBRARY NAMES ccnx_api_control + HINTS ${CCNX_TRANSPORT_RTA_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libccnx-transport-rta libraries") + +set(CCNX_TRANSPORT_RTA_LIBRARIES ${CCNX_TRANSPORT_RTA_LIBRARY} ${CCNX_API_CONTROL_LIBRARY} ${CCNX_API_NOTIFY_LIBRARY}) + +set(CCNX_TRANSPORT_RTA_INCLUDE_DIRS ${CCNX_TRANSPORT_RTA_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCNX_Transport_Api DEFAULT_MSG CCNX_TRANSPORT_RTA_LIBRARY CCNX_TRANSPORT_RTA_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindCURL.cmake b/HttpServer/app/cmake/Modules/FindCURL.cmake new file mode 100644 index 00000000..239b0e50 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindCURL.cmake @@ -0,0 +1,69 @@ +#.rst: +# FindCURL +# -------- +# +# Find curl +# +# Find the native CURL headers and libraries. +# +# :: +# +# CURL_INCLUDE_DIRS - where to find curl_/curl_.h, etc. +# CURL_LIBRARIES - List of libraries when using curl. +# CURL_FOUND - True if curl found. +# CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8) + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# Copyright 2012 Rolf Eike Beer +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Look for the header file. +find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) +mark_as_advanced(CURL_INCLUDE_DIR) + +# Look for the library (sorted from most current/relevant entry to least). +find_library(CURL_LIBRARY NAMES + curl + # Windows MSVC prebuilts: + curllib + libcurl_imp + curllib_static + # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): + libcurl + ) +mark_as_advanced(CURL_LIBRARY) + +if(CURL_INCLUDE_DIR) + foreach(_curl_version_header curlver.h curl.h) + if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") + file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") + + string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}") + unset(curl_version_str) + break() + endif() + endforeach() +endif() + +# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL + REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR + VERSION_VAR CURL_VERSION_STRING) + +if(CURL_FOUND) + set(CURL_LIBRARIES ${CURL_LIBRARY}) + set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) +endif() diff --git a/HttpServer/app/cmake/Modules/FindHttpServer.cmake b/HttpServer/app/cmake/Modules/FindHttpServer.cmake new file mode 100644 index 00000000..263353fa --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindHttpServer.cmake @@ -0,0 +1,39 @@ +######################################## +# +# Find the HttpServer libraries and includes +# This module sets: +# LIB_HTTP_SERVER_FOUND: True if lib_http_server was found +# LIB_HTTP_SERVER_LIBRARY: The lib_http_server library +# LIB_HTTP_SERVER_LIBRARIES: The lib_http_server library and dependencies +# LIB_HTTP_SERVER_INCLUDE_DIR: The lib_http_server include dir +# + +set(LIBICN_HTTP_SERVER_SEARCH_PATH_LIST + ${HTTP_SERVER_HOME} + $ENV{HTTP_SERVER_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/http-server + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIB_HTTP_SERVER_INCLUDE_DIR http-server/http_server.h + HINTS ${LIBICN_HTTP_SERVER_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the http-server includes") + +find_library(LIB_HTTP_SERVER_LIBRARY NAMES httpserver + HINTS ${LIB_HTTP_SERVER_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the http-server libraries") + +set(LIB_HTTP_SERVER_LIBRARIES ${LIB_HTTP_SERVER_LIBRARY}) +set(LIB_HTTP_SERVER_INCLUDE_DIRS ${LIB_HTTP_SERVER_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(lib_http_server DEFAULT_MSG LIB_HTTP_SERVER_LIBRARY LIB_HTTP_SERVER_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindJsoncpp.cmake b/HttpServer/app/cmake/Modules/FindJsoncpp.cmake new file mode 100644 index 00000000..acde7b95 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindJsoncpp.cmake @@ -0,0 +1,47 @@ +# Find jsoncpp +# +# Find the jsoncpp includes and library +# +# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH +# +# This module defines +# JSONCPP_INCLUDE_DIRS, where to find header, etc. +# JSONCPP_LIBRARIES, the libraries needed to use jsoncpp. +# JSONCPP_FOUND, If false, do not try to use jsoncpp. +# JSONCPP_INCLUDE_PREFIX, include prefix for jsoncpp + +# only look in default directories +find_path( + JSONCPP_INCLUDE_DIR + NAMES jsoncpp/json/json.h json/json.h + DOC "jsoncpp include dir" +) + +find_library( + JSONCPP_LIBRARY + NAMES jsoncpp + DOC "jsoncpp library" +) + +set(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR}) +set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY}) + +# find JSONCPP_INCLUDE_PREFIX +find_path( + JSONCPP_INCLUDE_PREFIX + NAMES json.h + PATH_SUFFIXES jsoncpp/json json +) + +if (${JSONCPP_INCLUDE_PREFIX} MATCHES "jsoncpp") + set(JSONCPP_INCLUDE_PREFIX "jsoncpp/json") +else() + set(JSONCPP_INCLUDE_PREFIX "json") +endif() + +# handle the QUIETLY and REQUIRED arguments and set JSONCPP_FOUND to TRUE +# if all listed variables are TRUE, hide their existence from configuration view +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(jsoncpp DEFAULT_MSG + JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY) +mark_as_advanced (JSONCPP_INCLUDE_DIR JSONCPP_LIBRARY) \ No newline at end of file diff --git a/HttpServer/app/cmake/Modules/FindLibEvent.cmake b/HttpServer/app/cmake/Modules/FindLibEvent.cmake new file mode 100644 index 00000000..2d1ca4fe --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindLibEvent.cmake @@ -0,0 +1,47 @@ +######################################## +# +# Find the LibEvent libraries and includes +# This module sets: +# LIBEVENT_FOUND: True if LibEvent was found +# LIBEVENT_LIBRARY: The LibEvent library +# LIBEVENT_LIBRARIES: The LibEvent library and dependencies +# LIBEVENT_INCLUDE_DIR: The LibEvent include dir +# +# This module will look for the libraries in various locations +# See the LIBEVENT_SEARCH_PATH_LIST for a full list. +# +# The caller can hint at locations using the following variables: +# +# LIBEVENT_HOME (passed as -D to cmake) +# CCNX_DEPENDENCIES (in environment) +# LIBEVENT_HOME (in environment) +# CCNX_HOME (in environment) +# + +set(LIBEVENT_SEARCH_PATH_LIST + ${LIBEVENT_HOME} + $ENV{CCNX_DEPENDENCIES} + $ENV{LIBEVENT_HOME} + $ENV{CCNX_HOME} + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIBEVENT_INCLUDE_DIR event2/event.h + HINTS ${LIBEVENT_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LibEvent includes" ) + +find_library(LIBEVENT_LIBRARY NAMES event + HINTS ${LIBEVENT_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LibEvent libraries" ) + +set(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARY}) +set(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibEvent DEFAULT_MSG LIBEVENT_LIBRARY LIBEVENT_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindLibicnet.cmake b/HttpServer/app/cmake/Modules/FindLibicnet.cmake new file mode 100644 index 00000000..bfb81ef7 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindLibicnet.cmake @@ -0,0 +1,39 @@ +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# LIBICNET_FOUND: True if Libconsumer-producer was found +# LIBICNETR_LIBRARY: The Libconsumer-producer library +# LIBICNET_LIBRARIES: The Libconsumer-producer library and dependencies +# LIBICNET_INCLUDE_DIR: The Libconsumer-producer include dir +# + +set(LIBICNET_SEARCH_PATH_LIST + ${LIBICNET_HOME} + $ENV{LIBICNETHOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIBICNET_INCLUDE_DIR icnet/icnet_ccnx_common.h + HINTS ${LIBICNET_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the libicnet includes") + +find_library(LIBICNET_LIBRARY NAMES icnet + HINTS ${LIBICNET_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the libicnet libraries") + +set(LIBICNET_LIBRARIES ${LIBICNET_LIBRARY}) +set(LIBICNET_INCLUDE_DIRS ${LIBICNET_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libicnet DEFAULT_MSG LIBICNET_LIBRARY LIBICNET_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindLibparc.cmake b/HttpServer/app/cmake/Modules/FindLibparc.cmake new file mode 100644 index 00000000..da8b3af7 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindLibparc.cmake @@ -0,0 +1,52 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# LIBPARC_FOUND: True if Libparc was found +# LIBPARC_LIBRARY: The Libparc library +# LIBPARC_LIBRARIES: The Libparc library and dependencies +# LIBPARC_INCLUDE_DIR: The Libparc include dir +# + +set(LIBPARC_SEARCH_PATH_LIST + ${LIBPARC_HOME} + $ENV{LIBPARC_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LIBPARC_INCLUDE_DIR parc/libparc_About.h + HINTS ${LIBPARC_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libparc includes") + +find_library(LIBPARC_LIBRARY NAMES parc + HINTS ${LIBPARC_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libparc libraries") + +set(LIBPARC_LIBRARIES ${LIBPARC_LIBRARY}) +set(LIBPARC_INCLUDE_DIRS ${LIBPARC_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libparc DEFAULT_MSG LIBPARC_LIBRARY LIBPARC_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindLongBow.cmake b/HttpServer/app/cmake/Modules/FindLongBow.cmake new file mode 100644 index 00000000..28d0b3b1 --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindLongBow.cmake @@ -0,0 +1,58 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +######################################## +# +# Find the LongBow libraries and includes +# This module sets: +# LONGBOW_FOUND: True if LongBow was found +# LONGBOW_LIBRARY: The LongBow library +# LONGBOW_LIBRARIES: The LongBow library and dependencies +# LONGBOW_INCLUDE_DIR: The LongBow include dir +# + +set(LONGBOW_SEARCH_PATH_LIST + ${LONGBOW_HOME} + $ENV{LONGBOW_HOME} + $ENV{CCNX_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccnx + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LONGBOW_INCLUDE_DIR LongBow/longBow_About.h + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LongBow includes") + +find_library(LONGBOW_LIBRARY NAMES longbow + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LongBow libraries") + +find_library(LONGBOW_REPORT_LIBRARY NAMES longbow-textplain longbow-ansiterm + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LongBow report libraries") + +set(LONGBOW_LIBRARIES ${LONGBOW_LIBRARY} ${LONGBOW_REPORT_LIBRARY}) +set(LONGBOW_INCLUDE_DIRS ${LONGBOW_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LongBow DEFAULT_MSG LONGBOW_LIBRARY LONGBOW_INCLUDE_DIR) diff --git a/HttpServer/app/cmake/Modules/FindUncrustify.cmake b/HttpServer/app/cmake/Modules/FindUncrustify.cmake new file mode 100644 index 00000000..e53f65fe --- /dev/null +++ b/HttpServer/app/cmake/Modules/FindUncrustify.cmake @@ -0,0 +1,8 @@ +# Find uncrustify program +# +find_program( UNCRUSTIFY_BIN uncrustify + PATHS + $ENV{UNCRUSTIFY_HOME} + ) + +message( "-- UNCRUSTIFY found in ${UNCRUSTIFY_BIN}" ) diff --git a/HttpServer/app/cmake/Modules/detectCacheSize.cmake b/HttpServer/app/cmake/Modules/detectCacheSize.cmake new file mode 100644 index 00000000..469d2627 --- /dev/null +++ b/HttpServer/app/cmake/Modules/detectCacheSize.cmake @@ -0,0 +1,21 @@ +# Detect the cache size +# +# XXX: TODO: This is a bug when cross compiling. We are detecting the local +# Cache Line size and not the target cache line size. We should provide some +# way to define this + +set(LEVEL1_DCACHE_LINESIZE 32) + +if( APPLE ) + execute_process(COMMAND sysctl -n hw.cachelinesize + OUTPUT_VARIABLE LEVEL1_DCACHE_LINESIZE + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif( APPLE ) + +if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) + execute_process(COMMAND getconf LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE LEVEL1_DCACHE_LINESIZE + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +message("-- Cache line size: ${LEVEL1_DCACHE_LINESIZE}") diff --git a/HttpServer/app/cmake/Modules/version.cmake b/HttpServer/app/cmake/Modules/version.cmake new file mode 100644 index 00000000..74831674 --- /dev/null +++ b/HttpServer/app/cmake/Modules/version.cmake @@ -0,0 +1,15 @@ +# +# Get a version to pass on the command line +# +execute_process(COMMAND ${PROJECT_SOURCE_DIR}/cmake/get_version.sh ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE RELEASE_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + +execute_process(COMMAND date -u +%Y-%m-%dT%H:%M:%SZ + OUTPUT_VARIABLE ISO_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +MESSAGE( STATUS "Configuring version ${RELEASE_VERSION}" ) + +add_definitions("-DRELEASE_VERSION=\"${RELEASE_VERSION}\"") + diff --git a/HttpServer/app/cmake/get_version.sh b/HttpServer/app/cmake/get_version.sh new file mode 100755 index 00000000..34c6ddb2 --- /dev/null +++ b/HttpServer/app/cmake/get_version.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +DATE_VERSION=`date "+%Y%m%d"` + +if [ ! -d $1 ]; then + echo 0.$DATE_VERSION + exit +fi + +if [ -f $1/BASE_VERSION ]; then + BASE_VERSION=`cat $1/BASE_VERSION`. +fi + +GIT=`which git` + +if test -x $GIT -a -f $1/.git/config; then + GIT_VERSION=.`git -C $1 rev-parse HEAD | cut -c 1-8` +fi + +echo $BASE_VERSION$DATE_VERSION$GIT_VERSION diff --git a/HttpServer/app/httpserver.keystore b/HttpServer/app/httpserver.keystore new file mode 100644 index 00000000..d277cc53 Binary files /dev/null and b/HttpServer/app/httpserver.keystore differ diff --git a/HttpServer/app/proguard-rules.pro b/HttpServer/app/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/HttpServer/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/HttpServer/app/src/androidTest/java/icn/httpserver/com/hicnhttpserver/ExampleInstrumentedTest.java b/HttpServer/app/src/androidTest/java/icn/httpserver/com/hicnhttpserver/ExampleInstrumentedTest.java new file mode 100644 index 00000000..91fb35e9 --- /dev/null +++ b/HttpServer/app/src/androidTest/java/icn/httpserver/com/hicnhttpserver/ExampleInstrumentedTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.httpserver.com.hicnhttpserver; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("hicn.cisco.com.hicnhttpserver", appContext.getPackageName()); + } +} diff --git a/HttpServer/app/src/main/AndroidManifest.xml b/HttpServer/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..1831bbc3 --- /dev/null +++ b/HttpServer/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HttpServer/app/src/main/cpp/httpServerWrap.cpp b/HttpServer/app/src/main/cpp/httpServerWrap.cpp new file mode 100644 index 00000000..d554fe58 --- /dev/null +++ b/HttpServer/app/src/main/cpp/httpServerWrap.cpp @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static bool _isRunning = false; +icn_httpserver::HttpServer *server; + +void default_resource_send(const icn_httpserver::HttpServer &server, + std::shared_ptr response, + std::shared_ptr ifs, + std::shared_ptr> buffer, + std::size_t bytes_to_read) { + std::streamsize read_length; + + if ((read_length = ifs->read(&(*buffer)[0], buffer->size()).gcount()) > 0) { + response->write(&(*buffer)[0], read_length); + + if (bytes_to_read <= static_cast(buffer->size())) { + return; + } + + std::size_t to_read = bytes_to_read - read_length; + server.send(response, + [&server, response, ifs, buffer, to_read](const boost::system::error_code &ec) { + if (!ec) { + default_resource_send(server, response, ifs, buffer, to_read); + } else { + __android_log_print(ANDROID_LOG_ERROR, "HttpServer", + "Connection interrupted"); + } + }); + } +} + +extern "C" +JNIEXPORT void JNICALL +Java_icn_httpserver_com_supportlibrary_HttpServer_start(JNIEnv *env, jobject instance, + jstring rootFolderString, + jstring tcpListenPortString, + jstring webServerPrefixString, + jstring proxyAddressString, + jstring iCNproxyAddressString) { + std::string root_folder = ""; + int port = 8080; + std::string webserver_prefix = ""; + std::string proxy_address = ""; + std::string icn_proxy_address = ""; + if (rootFolderString) { + const char *rootFolderChar = env->GetStringUTFChars(rootFolderString, JNI_FALSE); + root_folder.append(rootFolderChar); + env->ReleaseStringUTFChars(rootFolderString, rootFolderChar); + } + + if (tcpListenPortString) { + const char *tcpListenPortChar = env->GetStringUTFChars(tcpListenPortString, JNI_FALSE); + port = atoi(tcpListenPortChar); + env->ReleaseStringUTFChars(tcpListenPortString, tcpListenPortChar); + } + if (webServerPrefixString) { + const char *webServerPrefixChar = env->GetStringUTFChars(webServerPrefixString, JNI_FALSE); + webserver_prefix.append(webServerPrefixChar); + env->ReleaseStringUTFChars(webServerPrefixString, webServerPrefixChar); + } + if (proxyAddressString) { + const char *proxyAddressChar = env->GetStringUTFChars(proxyAddressString, JNI_FALSE); + proxy_address.append(proxyAddressChar); + env->ReleaseStringUTFChars(proxyAddressString, proxyAddressChar); + } + + if (iCNproxyAddressString) { + const char *iCNproxyAddressChar = env->GetStringUTFChars(iCNproxyAddressString, JNI_FALSE); + icn_proxy_address.append(iCNproxyAddressChar); + env->ReleaseStringUTFChars(iCNproxyAddressString, iCNproxyAddressChar); + } + boost::asio::io_service io_service; + server = new icn_httpserver::HttpServer(port, webserver_prefix, 50, 50, 300, + io_service); + _isRunning = true; + server->resource["^/info$"]["GET"] = [](std::shared_ptr response, + std::shared_ptr request) { + std::stringstream content_stream; + content_stream << "

This webserver is able to reply to HTTP over TCP/ICN

"; + content_stream << request->getMethod() << " " << request->getPath() << " HTTP/" + << request->getHttp_version() << "
"; + for (auto &header: request->getHeader()) { + content_stream << header.first << ": " << header.second << "
"; + } + + content_stream.seekp(0, std::ios::end); + + *response << "HTTP/1.1 200 OK\r\nContent-Length: " << content_stream.tellp() << "\r\n\r\n" + << content_stream.rdbuf(); + }; + + + server->default_resource["GET"] = [&root_folder, &proxy_address, &icn_proxy_address]( + std::shared_ptr response, + std::shared_ptr + request) { + const auto web_root_path = boost::filesystem::canonical(root_folder); + + boost::filesystem::path path = web_root_path; + path /= request->getPath(); + + if (path.extension().string() == ".mpd") { + response->setResponseLifetime(std::chrono::milliseconds(3000)); + } + + icn_httpserver::SocketRequest *socket_request = dynamic_cast(request.get()); + + if (boost::filesystem::exists(path)) { + path = boost::filesystem::canonical(path); + + if (std::distance(web_root_path.begin(), web_root_path.end()) <= + std::distance(path.begin(), path.end()) && + std::equal(web_root_path.begin(), web_root_path.end(), path.begin())) { + if (boost::filesystem::is_directory(path)) { + path /= "index.html"; + } // default path + + if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path)) { + auto ifs = std::make_shared(); + ifs->open(path.string(), std::ifstream::in | std::ios::binary); + if (*ifs) { + std::streamsize buffer_size = 15 * 1024 * 1024; + auto buffer = std::make_shared >(buffer_size); + + ifs->seekg(0, std::ios::end); + auto length = ifs->tellg(); + ifs->seekg(0, std::ios::beg); + + response->setResponseLength(length); + *response << "HTTP/1.0 200 OK\r\nContent-Length: " << length << "\r\n\r\n"; + + if (path.extension().string() == ".mpd") { + response->setResponseLifetime(std::chrono::milliseconds(1000)); + } + default_resource_send(*server, response, ifs, buffer, length); + + return; + + } + } + } + } + + std::string proxy = ""; + HTTPClient *client = nullptr; + + if (proxy_address.empty() && !icn_proxy_address.empty()) { + proxy = icn_proxy_address; + client = new HTTPClientIcn(20); + } else if (!proxy_address.empty() && icn_proxy_address.empty()) { + proxy = proxy_address; + client = new HTTPClientTcp; + } else if (!proxy_address.empty() && !icn_proxy_address.empty()) { + if (socket_request) { + proxy = icn_proxy_address; + client = new HTTPClientIcn(20); + } else { + proxy = proxy_address; + client = new HTTPClientTcp; + } + } + + if (!proxy.empty()) { + std::stringstream ss; + if (strncmp("http://", proxy.c_str(), 7) != 0) { + if (strncmp("https://", proxy.c_str(), 8) != 0) { + ss << "https://"; + } else { + ss << "http://"; + } + } + ss << proxy; + ss << request->getPath(); + std::cout << ss.str() << std::endl; + client->download(ss.str(), *response); + + delete client; + if (response->size() == 0) { + *response << "HTTP/1.1 504 Gateway Timeout\r\n\r\n"; + } + + return; + } + + std::string content = "Could not open path " + request->getPath(); + + *response << "HTTP/1.1 404 Not found\r\nContent-Length: " << content.length() << "\r\n\r\n" + << content; + }; + + __android_log_print(ANDROID_LOG_INFO, "HttpServer", "HttpServer Starting"); + server->start(); + +} + +extern "C" +JNIEXPORT void JNICALL +Java_icn_httpserver_com_supportlibrary_HttpServer_stop(JNIEnv *env, jobject instance) { + server->stop(); + _isRunning = false; + __android_log_print(ANDROID_LOG_INFO, "HttpServer", "HttpServer Stopped"); + +} + +extern "C" +JNIEXPORT jboolean JNICALL +Java_icn_httpserver_com_supportlibrary_HttpServer_isRunning(JNIEnv *env, jobject instance) { + __android_log_print(ANDROID_LOG_INFO, "HttpServer", "Is Running? %s", _isRunning ? "true" : "false"); + return _isRunning; + +} \ No newline at end of file diff --git a/HttpServer/app/src/main/ic_launcher-web.png b/HttpServer/app/src/main/ic_launcher-web.png new file mode 100644 index 00000000..1206ee9c Binary files /dev/null and b/HttpServer/app/src/main/ic_launcher-web.png differ diff --git a/HttpServer/app/src/main/java/icn/httpserver/com/httpserver/HttpServerActivity.java b/HttpServer/app/src/main/java/icn/httpserver/com/httpserver/HttpServerActivity.java new file mode 100644 index 00000000..78ef8ff2 --- /dev/null +++ b/HttpServer/app/src/main/java/icn/httpserver/com/httpserver/HttpServerActivity.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.httpserver.com.httpserver; + +import android.Manifest; +import android.app.Dialog; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.net.Uri; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.Switch; + +import icn.httpserver.com.service.HttpServerService; +import icn.httpserver.com.supportlibrary.HttpServer; +import icn.httpserver.com.utility.Constants; +import icn.httpserver.com.utility.ResourcesEnumerator; + +public class HttpServerActivity extends AppCompatActivity { + private EditText rootFolderEditText; + private EditText tcpListenPortEditText; + private EditText webServerPrefixEditText; + private EditText proxyAddressEditText; + private EditText iCNproxyAddressEditText; + private Switch httpServerSwitch; + private Button yesButtonDialog; + private Button noButtonDialog; + + + private SharedPreferences sharedPreferences; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_http_server); + checkEnabledPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); + checkEnabledPermission(Manifest.permission.READ_EXTERNAL_STORAGE); + if (!checkMetis(Constants.METIS_ID)) { + final Dialog dialog = new Dialog(this); + dialog.setContentView(R.layout.popup_message); + yesButtonDialog = (Button) dialog.findViewById(R.id.yesButtonDialog); + noButtonDialog = (Button) dialog.findViewById(R.id.noButtonDialog); + yesButtonDialog.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.METIS_ID))); + } catch (android.content.ActivityNotFoundException anfe) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + Constants.METIS_ID))); + } + dialog.hide(); + } + }); + noButtonDialog.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dialog.hide(); + } + }); + dialog.show(); + + } + init(); + } + + + private void checkEnabledPermission(String permission) { + if (ContextCompat.checkSelfPermission(this, + permission) + != PackageManager.PERMISSION_GRANTED) { + if (ActivityCompat.shouldShowRequestPermissionRationale(this, + permission)) { + } else { + ActivityCompat.requestPermissions(this, + new String[]{permission}, + 1); + } + } + } + + private boolean checkMetis(String uri) { + PackageManager pm = getPackageManager(); + try { + pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); + return true; + } catch (PackageManager.NameNotFoundException e) { + return false; + } + } + + private void init() { + sharedPreferences = getSharedPreferences(Constants.HTTP_SERVER_PREFERENCES, MODE_PRIVATE); + rootFolderEditText = (EditText) findViewById(R.id.rootFolderEditText); + rootFolderEditText.setText(sharedPreferences.getString(ResourcesEnumerator.ROOT_FOLDER.key(), Constants.DEFAULT_ROOT_FOLDER)); + tcpListenPortEditText = (EditText) findViewById(R.id.tcpListenPortEditText); + tcpListenPortEditText.setText(sharedPreferences.getString(ResourcesEnumerator.TCP_LISTEN_PORT.key(), Constants.DEFAULT_TCP_LISTEN_PORT)); + webServerPrefixEditText = (EditText) findViewById(R.id.webServerPrefixEditText); + webServerPrefixEditText.setText(sharedPreferences.getString(ResourcesEnumerator.WEBSERVER_PREFIX.key(), Constants.DEFAULT_WEBSERVER_PREFIX)); + proxyAddressEditText = (EditText) findViewById(R.id.proxyAddressEditText); + proxyAddressEditText.setText(sharedPreferences.getString(ResourcesEnumerator.PROXY_ADDRESS.key(), Constants.DEFAULT_PROXY_ADDRESS)); + iCNproxyAddressEditText = (EditText) findViewById(R.id.iCNproxyAddressEditText); + iCNproxyAddressEditText.setText(sharedPreferences.getString(ResourcesEnumerator.ICN_PROXY_ADDRESS.key(), Constants.DEFAULT_ICN_PROXY_ADDRESS)); + httpServerSwitch = (Switch) findViewById(R.id.httpServerSwitch); + if (HttpServer.getInstance().isRunning()) { + httpServerSwitch.setChecked(true); + rootFolderEditText.setEnabled(false); + tcpListenPortEditText.setEnabled(false); + webServerPrefixEditText.setEnabled(false); + proxyAddressEditText.setEnabled(false); + iCNproxyAddressEditText.setEnabled(false); + } + + httpServerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + Log.v("Switch State=", "" + isChecked); + if (isChecked) { + httpServerSwitch.setText(Constants.ENABLED); + SharedPreferences.Editor sharedPreferencesEditor = getSharedPreferences(Constants.HTTP_SERVER_PREFERENCES, MODE_PRIVATE).edit(); + sharedPreferencesEditor.putString(ResourcesEnumerator.ROOT_FOLDER.key(), rootFolderEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.TCP_LISTEN_PORT.key(), tcpListenPortEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.WEBSERVER_PREFIX.key(), webServerPrefixEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.PROXY_ADDRESS.key(), proxyAddressEditText.getText().toString()); + sharedPreferencesEditor.putString(ResourcesEnumerator.ICN_PROXY_ADDRESS.key(), iCNproxyAddressEditText.getText().toString()); + sharedPreferencesEditor.commit(); + rootFolderEditText.setEnabled(false); + tcpListenPortEditText.setEnabled(false); + webServerPrefixEditText.setEnabled(false); + proxyAddressEditText.setEnabled(false); + iCNproxyAddressEditText.setEnabled(false); + startHttpServer(); + + } else { + httpServerSwitch.setText(Constants.DISABLED); + rootFolderEditText.setEnabled(true); + tcpListenPortEditText.setEnabled(true); + webServerPrefixEditText.setEnabled(true); + proxyAddressEditText.setEnabled(true); + iCNproxyAddressEditText.setEnabled(true); + stopHttpServer(); + } + } + + }); + + + } + + private void startHttpServer() { + Intent intent = new Intent(this, HttpServerService.class); + startService(intent); + } + + private void stopHttpServer() { + Intent intent = new Intent(this, HttpServerService.class); + stopService(intent); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + } + +} diff --git a/HttpServer/app/src/main/java/icn/httpserver/com/service/HttpServerService.java b/HttpServer/app/src/main/java/icn/httpserver/com/service/HttpServerService.java new file mode 100644 index 00000000..977993ee --- /dev/null +++ b/HttpServer/app/src/main/java/icn/httpserver/com/service/HttpServerService.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.httpserver.com.service; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Build; +import android.os.IBinder; +import android.util.Log; + +import java.io.File; + +import icn.httpserver.com.httpserver.HttpServerActivity; +import icn.httpserver.com.supportlibrary.HttpServer; +import icn.httpserver.com.utility.Constants; +import icn.httpserver.com.utility.ResourcesEnumerator; + +/** + * Created by angelomantellini on 12/11/17. + */ + + +public class HttpServerService extends Service { + private final static String TAG = "HttpServerService"; + + private static Thread sHttpServerThread = null; + + public HttpServerService() { + } + + private String rootFolderString; + private String tcpListenPortString; + private String webServerPrefixString; + private String proxyAddressString; + private String iCNproxyAddressString; + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + + HttpServer httpServer = HttpServer.getInstance(); + if (!httpServer.isRunning()) { + Log.d(TAG, "Starting Http Server"); + SharedPreferences sharedPreferences = getSharedPreferences(Constants.HTTP_SERVER_PREFERENCES, MODE_PRIVATE); + String rootFolderString = sharedPreferences.getString(ResourcesEnumerator.ROOT_FOLDER.key(), + null); + String tcpListenPortString = sharedPreferences.getString(ResourcesEnumerator.TCP_LISTEN_PORT.key(), null); + String webServerPrefixString = sharedPreferences.getString(ResourcesEnumerator.WEBSERVER_PREFIX.key(), null); + String proxyAddressString = sharedPreferences.getString(ResourcesEnumerator.PROXY_ADDRESS.key(), null); + String iCNproxyAddressString = sharedPreferences.getString(ResourcesEnumerator.ICN_PROXY_ADDRESS.key(), null); + File folder = new File(rootFolderString); + if (!folder.exists()) { + folder.mkdirs(); + } + + + startHttpServer(intent, rootFolderString, tcpListenPortString, webServerPrefixString, proxyAddressString, iCNproxyAddressString); + + + } else { + Log.d(TAG, "Http Server is already running."); + } + return Service.START_STICKY; + } + + + @Override + public void onDestroy() { + HttpServer httpServer = HttpServer.getInstance(); + Log.d(TAG, "Destroying HttpServer"); + if (httpServer.isRunning()) { + httpServer.stop(); + stopForeground(true); + } + super.onDestroy(); + } + + protected Runnable mHttpServerRunner = new Runnable() { + + //private String path; + @Override + public void run() { + HttpServer httpServer = HttpServer.getInstance(); + httpServer.start(rootFolderString, tcpListenPortString, webServerPrefixString, proxyAddressString, iCNproxyAddressString); + } + + + }; + + private void startHttpServer(Intent intent, String rootFolderString, String tcpListenPortString, String webServerPrefixString, String proxyAddressString, String iCNproxyAddressString) { + String NOTIFICATION_CHANNEL_ID = "12345"; + Notification.Builder notificationBuilder = null; + if (Build.VERSION.SDK_INT >= 26) { + notificationBuilder = new Notification.Builder(this, NOTIFICATION_CHANNEL_ID); + } else { + notificationBuilder = new Notification.Builder(this); + } + Intent notificationIntent = new Intent(this, HttpServerActivity.class); + PendingIntent activity = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); + + notificationBuilder.setContentTitle("HttpServer").setContentText("HttpServer").setOngoing(true).setContentIntent(activity); + Notification notification = notificationBuilder.build(); + + if (Build.VERSION.SDK_INT >= 26) { + NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "HttpServer", NotificationManager.IMPORTANCE_DEFAULT); + channel.setDescription("HttpServer"); + NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.createNotificationChannel(channel); + + } + + startForeground(Constants.FOREGROUND_SERVICE, notification); + + + HttpServer httpServer = HttpServer.getInstance(); + if (!httpServer.isRunning()) { + this.rootFolderString = rootFolderString; + this.tcpListenPortString = tcpListenPortString; + this.webServerPrefixString = webServerPrefixString; + this.proxyAddressString = proxyAddressString; + this.iCNproxyAddressString = iCNproxyAddressString; + sHttpServerThread = new Thread(mHttpServerRunner, "HttpServerRunner"); + sHttpServerThread.start(); + } + + + Log.e(TAG, "HttpServer Started"); + + } + + +} diff --git a/HttpServer/app/src/main/java/icn/httpserver/com/supportlibrary/HttpServer.java b/HttpServer/app/src/main/java/icn/httpserver/com/supportlibrary/HttpServer.java new file mode 100644 index 00000000..5b5356db --- /dev/null +++ b/HttpServer/app/src/main/java/icn/httpserver/com/supportlibrary/HttpServer.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package icn.httpserver.com.supportlibrary; + +public class HttpServer { + + private static HttpServer sInstance = null; + + static { + System.loadLibrary("httpServerWrap"); + + } + + public static HttpServer getInstance() { + if (sInstance == null) { + sInstance = new HttpServer(); + } + return sInstance; + } + + private HttpServer() { + + } + + + public native boolean isRunning(); + + public native void start(String rootFolderString, + String tcpListenPortString, + String webServerPrefixString, + String proxyAddressString, + String iCNproxyAddressString); + public native void stop(); +} diff --git a/HttpServer/app/src/main/java/icn/httpserver/com/utility/Constants.java b/HttpServer/app/src/main/java/icn/httpserver/com/utility/Constants.java new file mode 100644 index 00000000..d44bcbfd --- /dev/null +++ b/HttpServer/app/src/main/java/icn/httpserver/com/utility/Constants.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package icn.httpserver.com.utility; + +public class Constants { + public static final String DEFAULT_ROOT_FOLDER = "/sdcard/HttpServer"; + public static final String DEFAULT_TCP_LISTEN_PORT = "8080"; + public static final String DEFAULT_WEBSERVER_PREFIX = "http://android-webserver"; + public static final String DEFAULT_PROXY_ADDRESS = "http://localhost/proxy"; + public static final String DEFAULT_ICN_PROXY_ADDRESS = "http://systemx-cicn.enst.fr"; + public static final String METIS_ID = "icn.forwarder.com.icnforwarderandroid"; + public static final String ENABLED = "Enabled"; + public static final String DISABLED = "Disabled"; + public static final String HTTP_SERVER_PREFERENCES = "httpServerPreferences"; + public static final int FOREGROUND_SERVICE = 101; +} diff --git a/HttpServer/app/src/main/java/icn/httpserver/com/utility/ResourcesEnumerator.java b/HttpServer/app/src/main/java/icn/httpserver/com/utility/ResourcesEnumerator.java new file mode 100644 index 00000000..8efb10d3 --- /dev/null +++ b/HttpServer/app/src/main/java/icn/httpserver/com/utility/ResourcesEnumerator.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package icn.httpserver.com.utility; + +public enum ResourcesEnumerator { + ROOT_FOLDER("rootFolder"), + TCP_LISTEN_PORT("tcpListenPort"), + WEBSERVER_PREFIX("webServerPRefix"), + PROXY_ADDRESS("proxyAddress"), + ICN_PROXY_ADDRESS("iCNproxyAddress"); + + private String key; + + ResourcesEnumerator(String key) { + this.key = key; + } + + public String key() { + return key; + } +} diff --git a/HttpServer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/HttpServer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..c7bd21db --- /dev/null +++ b/HttpServer/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/HttpServer/app/src/main/res/drawable/ic_launcher_background.xml b/HttpServer/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..d5fccc53 --- /dev/null +++ b/HttpServer/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HttpServer/app/src/main/res/layout/activity_http_server.xml b/HttpServer/app/src/main/res/layout/activity_http_server.xml new file mode 100644 index 00000000..e4a7614a --- /dev/null +++ b/HttpServer/app/src/main/res/layout/activity_http_server.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HttpServer/app/src/main/res/layout/popup_message.xml b/HttpServer/app/src/main/res/layout/popup_message.xml new file mode 100644 index 00000000..a2631820 --- /dev/null +++ b/HttpServer/app/src/main/res/layout/popup_message.xml @@ -0,0 +1,44 @@ + + + + + + + + +