├── droid-testapp ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── values │ │ └── strings.xml │ └── layout │ │ └── main.xml ├── jni │ ├── Application.mk │ ├── SSLInit.h │ ├── SSLInit.c │ ├── Android.mk │ ├── cmoss-tests.c │ └── cmoss-tests.cpp ├── .classpath ├── project.properties ├── .settings │ ├── org.eclipse.cdt.core.prefs │ └── org.eclipse.cdt.codan.core.prefs ├── AndroidManifest.xml ├── src │ └── org │ │ └── cmoss │ │ └── tests │ │ └── TestLibsActivity.java ├── proguard.cfg ├── .project └── .cproject ├── .gitignore └── README /droid-testapp/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsol/cmoss/develop/droid-testapp/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /droid-testapp/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsol/cmoss/develop/droid-testapp/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /droid-testapp/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdsol/cmoss/develop/droid-testapp/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /droid-testapp/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_PROJECT_PATH := $(call my-dir)/.. 2 | APP_STL := gnustl_static 3 | APP_MODULES := cmoss-tests 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .gitignore.* 3 | .DS_Store 4 | *.bak 5 | *.old 6 | 7 | bin/ 8 | tmp/ 9 | tmp.*/ 10 | log/ 11 | 12 | droid-testapp/bin 13 | droid-testapp/gen 14 | droid-testapp/libs 15 | droid-testapp/obj 16 | 17 | -------------------------------------------------------------------------------- /droid-testapp/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /droid-testapp/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Testing cURL... 5 | Testing expat... 6 | Testing yajl... 7 | Testing soci/sqlcipher... 8 | 9 | CMOSS - Tests 10 | 11 | -------------------------------------------------------------------------------- /droid-testapp/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-14 12 | -------------------------------------------------------------------------------- /droid-testapp/.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Tue Mar 27 22:09:49 EDT 2012 2 | eclipse.preferences.version=1 3 | environment/project/com.android.toolchain.gcc.1014137256/PATH/delimiter=\: 4 | environment/project/com.android.toolchain.gcc.1014137256/PATH/operation=replace 5 | environment/project/com.android.toolchain.gcc.1014137256/PATH/value=${NDK_PATH}\:${NDK_PATH}/platforms/android-14/arch-arm/usr/include\:/usr/bin\:/bin\:/usr/sbin\:/sbin 6 | environment/project/com.android.toolchain.gcc.1014137256/append=true 7 | environment/project/com.android.toolchain.gcc.1014137256/appendContributed=true 8 | -------------------------------------------------------------------------------- /droid-testapp/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /droid-testapp/src/org/cmoss/tests/TestLibsActivity.java: -------------------------------------------------------------------------------- 1 | package org.cmoss.tests; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | public class TestLibsActivity extends Activity 8 | { 9 | static 10 | { 11 | System.loadLibrary("log"); 12 | System.loadLibrary("cmoss-tests"); 13 | } 14 | 15 | private TextView tv1; 16 | 17 | @Override 18 | public void onCreate(Bundle savedInstanceState) 19 | { 20 | super.onCreate(savedInstanceState); 21 | super.setContentView(R.layout.main); 22 | 23 | initialize(this.getCacheDir().getAbsolutePath() + "/certs"); 24 | 25 | this.tv1 = (TextView) findViewById(R.id.text1); 26 | } 27 | 28 | @Override 29 | public void onStart() 30 | { 31 | super.onStart(); 32 | 33 | String result = curlTest(); 34 | tv1.setText(result); 35 | } 36 | 37 | @Override 38 | public void onDestroy() 39 | { 40 | super.onDestroy(); 41 | shutdown(); 42 | } 43 | 44 | public native void initialize(String path); 45 | public native void shutdown(); 46 | 47 | public native String curlTest(); 48 | } 49 | -------------------------------------------------------------------------------- /droid-testapp/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 18 | 19 | 24 | 25 | 30 | 31 | 36 | 37 | -------------------------------------------------------------------------------- /droid-testapp/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /droid-testapp/jni/SSLInit.h: -------------------------------------------------------------------------------- 1 | // The MIT License 2 | // 3 | // Copyright (c) 2011 Mevan Samaratunga 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // SSLInit.h : OpenSSL initialization. 24 | // 25 | 26 | #ifndef SSL_INIT_H_ 27 | #define SSL_INIT_H_ 28 | 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | void init_locks(); 35 | void kill_locks(); 36 | 37 | #ifdef __cplusplus 38 | } /* closing brace for extern "C" */ 39 | #endif 40 | 41 | 42 | #endif /* SSL_INIT_H_ */ 43 | -------------------------------------------------------------------------------- /droid-testapp/jni/SSLInit.c: -------------------------------------------------------------------------------- 1 | // The MIT License 2 | // 3 | // Copyright (c) 2011 Mevan Samaratunga 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // SSLInit.h : OpenSSL initialization, such as setting up call backs for thread 24 | // safety of GCrypt libraries. See: 25 | // 26 | // OpenSSL docs for this: 27 | // http://www.openssl.org/docs/crypto/threads.html 28 | // gcrypt docs for this: 29 | // http://gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html 30 | // 31 | 32 | #include "SSLInit.h" 33 | 34 | #include 35 | #include 36 | 37 | /* we have this global to let the callback get easy access to it */ 38 | static pthread_mutex_t *lockarray; 39 | 40 | static void lock_callback(int mode, int type, char* file, int line) { 41 | 42 | (void) file; 43 | (void) line; 44 | 45 | if (mode & CRYPTO_LOCK) { 46 | pthread_mutex_lock(&(lockarray[type])); 47 | } 48 | else { 49 | pthread_mutex_unlock(&(lockarray[type])); 50 | } 51 | } 52 | 53 | static unsigned long thread_id() 54 | { 55 | return (unsigned long) pthread_self(); 56 | } 57 | 58 | void init_locks() 59 | { 60 | lockarray = (pthread_mutex_t *) OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); 61 | 62 | int i; 63 | for (i = 0; i < CRYPTO_num_locks(); i++) { 64 | pthread_mutex_init(&(lockarray[i]), NULL); 65 | } 66 | 67 | CRYPTO_set_id_callback((unsigned long (*)()) thread_id); 68 | CRYPTO_set_locking_callback((void (*)()) lock_callback); 69 | } 70 | 71 | void kill_locks() 72 | { 73 | CRYPTO_set_locking_callback(NULL); 74 | 75 | int i; 76 | for (i = 0; i < CRYPTO_num_locks(); i++) 77 | pthread_mutex_destroy(&(lockarray[i])); 78 | 79 | OPENSSL_free(lockarray); 80 | } 81 | -------------------------------------------------------------------------------- /droid-testapp/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := minizip 6 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libminizip.a 7 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 8 | 9 | include $(PREBUILT_STATIC_LIBRARY) 10 | 11 | include $(CLEAR_VARS) 12 | 13 | LOCAL_MODULE := crypto 14 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libcrypto.a 15 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 16 | 17 | include $(PREBUILT_STATIC_LIBRARY) 18 | 19 | include $(CLEAR_VARS) 20 | 21 | LOCAL_MODULE := ssl 22 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libssl.a 23 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 24 | 25 | include $(PREBUILT_STATIC_LIBRARY) 26 | 27 | include $(CLEAR_VARS) 28 | 29 | LOCAL_MODULE := curl 30 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libcurl.a 31 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 32 | 33 | include $(PREBUILT_STATIC_LIBRARY) 34 | 35 | include $(CLEAR_VARS) 36 | 37 | LOCAL_MODULE := boost 38 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libboost.a 39 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 40 | 41 | include $(PREBUILT_STATIC_LIBRARY) 42 | 43 | include $(CLEAR_VARS) 44 | 45 | LOCAL_MODULE := pion-common 46 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libpion-common.a 47 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 48 | 49 | include $(PREBUILT_STATIC_LIBRARY) 50 | 51 | include $(CLEAR_VARS) 52 | 53 | LOCAL_MODULE := pion-net 54 | LOCAL_SRC_FILES := ../../bin/droid/lib/armv7/libpion-net.a 55 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../bin/droid/include 56 | 57 | include $(PREBUILT_STATIC_LIBRARY) 58 | 59 | include $(CLEAR_VARS) 60 | 61 | LOCAL_MODULE := cmoss-tests 62 | LOCAL_SRC_FILES := SSLInit.c cmoss-tests.cpp 63 | #LOCAL_SRC_FILES := cmoss-tests.c 64 | 65 | LOCAL_C_INCLUDES += ${NDK_ROOT}/platforms/android-14/arch-arm/usr/includes 66 | LOCAL_C_INCLUDES += ${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/include 67 | LOCAL_C_INCLUDES += ${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include 68 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../bin/droid/include 69 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../bin/certs 70 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../nadax/NadaxUtility/src/include 71 | 72 | LOCAL_CFLAGS += -DUNIX -DLOG_LEVEL_TRACE 73 | LOCAL_CPPFLAGS += -frtti -fexceptions 74 | 75 | LOCAL_LDFLAGS += ${NDK_ROOT}/platforms/android-14/arch-arm/usr/lib/crtbegin_so.o 76 | LOCAL_LDFLAGS += -Os -nostdlib -Wl,-rpath-link=${NDK_ROOT}/platforms/android-14/arch-arm/usr/lib 77 | LOCAL_LDLIBS += -lc -ldl -llog -lz 78 | 79 | #LOCAL_STATIC_LIBRARIES := curl ssl crypto minizip boost pion-common pion-net 80 | LOCAL_STATIC_LIBRARIES := curl ssl crypto minizip boost 81 | 82 | include $(BUILD_SHARED_LIBRARY) 83 | -------------------------------------------------------------------------------- /droid-testapp/jni/cmoss-tests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "log.h" 7 | #include "openssl_certs.h" 8 | 9 | #define BUFFER_SIZE 1024 10 | 11 | 12 | int curlDebugCallback(CURL* curl, curl_infotype infotype, char* text, size_t len, void* userdata) { 13 | 14 | TRACE("cURL: %s", text); 15 | return 0; 16 | } 17 | 18 | // **** JNI Implementations **** 19 | 20 | void Java_org_cmoss_tests_TestLibsActivity_initialize(JNIEnv* env, jobject thiz, jstring path) { 21 | 22 | const char* certPath = (*env)->GetStringUTFChars(env, path, 0); 23 | TRACE("Extracting certs to path '%s'...", certPath); 24 | 25 | int error = extractCerts(certPath); 26 | if (error) { 27 | TRACE("Error extracting certificates: %d", error); 28 | } 29 | 30 | curl_global_init(CURL_GLOBAL_ALL); 31 | 32 | TRACE("Done initializing CMOSS Tests."); 33 | } 34 | 35 | void Java_org_cmoss_tests_TestLibsActivity_shutdown(JNIEnv* env, jobject thiz) { 36 | 37 | curl_global_cleanup(); 38 | 39 | TRACE("Done shutting down CMOSS Tests."); 40 | } 41 | 42 | jstring Java_org_cmoss_tests_TestLibsActivity_curlTest(JNIEnv* env, jobject thiz) { 43 | 44 | char result[BUFFER_SIZE]; 45 | char error[CURL_ERROR_SIZE]; 46 | 47 | CURL* curl = curl_easy_init(); 48 | if (curl) { 49 | 50 | curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com"); 51 | // curl_easy_setopt(curl, CURLOPT_PROXY, "http.proxy.fmr.com"); 52 | // curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8000L); 53 | 54 | curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error); 55 | curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); 56 | curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback); 57 | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); 58 | 59 | #ifdef SKIP_PEER_VERIFICATION 60 | /* 61 | * If you want to connect to a site who isn't using a certificate that is 62 | * signed by one of the certs in the CA bundle you have, you can skip the 63 | * verification of the server's certificate. This makes the connection 64 | * A LOT LESS SECURE. 65 | * 66 | * If you have a CA cert for the server stored someplace else than in the 67 | * default bundle, then the CURLOPT_CAPATH option might come handy for 68 | * you. 69 | */ 70 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); 71 | #else 72 | curl_easy_setopt(curl, CURLOPT_CAPATH, __CACERTS_PATH); 73 | #endif 74 | 75 | #ifdef SKIP_HOSTNAME_VERFICATION 76 | /* 77 | * If the site you're connecting to uses a different host name that what 78 | * they have mentioned in their server certificate's commonName (or 79 | * subjectAltName) fields, libcurl will refuse to connect. You can skip 80 | * this check, but this will make the connection less secure. 81 | */ 82 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); 83 | #endif 84 | 85 | 86 | TRACE("Sending request..."); 87 | 88 | CURLcode res = curl_easy_perform(curl); 89 | if (res) { 90 | snprintf(result, BUFFER_SIZE, "cURL HTTP returned error: %s", error); 91 | TRACE("cURL HTTP returned error: %s", result); 92 | } else { 93 | snprintf(result, BUFFER_SIZE, "cURL HTTP request succeeded"); 94 | TRACE("cURL HTTP get succeeded."); 95 | } 96 | 97 | curl_easy_cleanup(curl); 98 | 99 | } else { 100 | 101 | snprintf(result, BUFFER_SIZE, "Error initializing cURL. A null handle was returned."); 102 | } 103 | 104 | return (*env)->NewStringUTF(env, result); 105 | } 106 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | The CMOSS scripts can be used to build the following C/C++ Open Source Software libraries for native development on iOS and Android. 2 | 3 | * minizip : http://www.winimage.com/zLibDll/minizip.html 4 | * icu : http://site.icu-project.org/ 5 | * c-ares : http://c-ares.haxx.se 6 | * bzip2 : http://bzip.org/ 7 | * libidn : http://www.gnu.org/software/libidn/ 8 | * GnuPG 1.4.x, Libgcrypt, Libgpg-error : http://www.gnupg.org/ 9 | * OpenSSL - http://http://www.openssl.org/ 10 | * libSSH2 - http://www.libssh2.org/ 11 | * cURL - http://curl.haxx.se/ - C HTTP API 12 | * expat - http://expat.sourceforge.net/ - XML event parser 13 | * tinyxml - http://www.grinninglizard.com/tinyxml/ - XML DOM based parser 14 | * yajl - http://lloyd.github.com/yajl/ - JSON parser 15 | * sqlcipher - http://sqlcipher.net/ - SQLite with encryption 16 | * boost - http://www.boost.org/ - C++ utilities 17 | * soci - http://soci.sourceforge.net/ - generic C++ database API 18 | * pion : http://pion.org/ - C++ HTTP API 19 | 20 | The android kernel already provides some of these shared libraries so check if they are available before including them in your NDK project. For example both openssl and icu are part of the Android distribution. 21 | 22 | To build armv6 binaries for iOS you need to use the 5.1 SDK or lower. The blog at http://blog.chpwn.com/post/31824877081 provides instructions on how to add the 5.1 SDK alongside the 6.0 SDK if you are using XCode 4.5. The scripts will automatically pick up the older SDK for armv6 builds. If the 5.1 SDK is not available then armv6 binaries will not be built. 23 | 24 | The scripts will download the source code from the internet and build them locally. So your build machine needs to be connected to the internet when building. Once the source code archives have been downloaded they will be saved in the [cmoss root path]/tmp folder and will not be downloaded again unless you delete them or change the version. The builds have been tested with the versions hard-coded in the script files. If you change these versions it is possible the build for that library may break. If you do find a new version that breaks a build please let me know so it can be fixed. 25 | 26 | There is an issue with the icu builds with the SDK that ship with versions before XCode 4.5. This results in the Android builds having to be rerun when the icu host build fails, but it fails the entire icu build for iOS. If you are on an older version of XCode please comment out the icu build step. 27 | 28 | To run iOS build: 29 | 30 | cd [cmoss root path]/build-ios 31 | ./build-all.sh [installed sdk version #] [proxy_host:proxy_port] 32 | 33 | (scripts were tested with SDK 6.0) 34 | 35 | To run Android build: 36 | 37 | cd [cmoss root path]/build-droid 38 | ./build-all.sh [path to Android NDK] [proxy_host:proxy_port] 39 | 40 | (scripts were tested with Android NDK r8d) 41 | 42 | These build scripts were tested on a Mac OS X 10 with the following Mac ports: 43 | 44 | cmake @2.8.4_0 (active) 45 | cppunit @1.12.1_0 (active) 46 | dos2unix @5.1.1_0 (active) 47 | expat @2.0.1_1 (active) 48 | gettext @0.18.1.1_2 (active) 49 | gperf @3.0.4_0 (active) 50 | libiconv @1.13.1_0 (active) 51 | libidn @1.20_0 (active) 52 | ncurses @5.8_0 53 | ncurses @5.8_1 (active) 54 | ncursesw @5.8_0 (active) 55 | openssl @1.0.0d_0 (active) 56 | wget @1.12_3+ssl (active) 57 | libtool @2.4.2 (active) 58 | zlib @1.2.5_0 (active) 59 | 60 | The Android scripts should work in a Linux environment but have not been tested. 61 | 62 | The builds do not run the unit tests that come with the libraries on each platform. If you run into linker issues with the libraries you will need to tweak the builds. Please let me know of any issues when using the libraries and fixes that need to be addressed. 63 | -------------------------------------------------------------------------------- /droid-testapp/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | droid-testapp 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | ?children? 14 | ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| 15 | 16 | 17 | ?name? 18 | 19 | 20 | 21 | org.eclipse.cdt.make.core.append_environment 22 | true 23 | 24 | 25 | org.eclipse.cdt.make.core.buildArguments 26 | NDK_DEBUG=1 27 | 28 | 29 | org.eclipse.cdt.make.core.buildCommand 30 | ndk-build 31 | 32 | 33 | org.eclipse.cdt.make.core.buildLocation 34 | ${workspace_loc:/droid-testapp}/jni 35 | 36 | 37 | org.eclipse.cdt.make.core.cleanBuildTarget 38 | clean 39 | 40 | 41 | org.eclipse.cdt.make.core.contents 42 | org.eclipse.cdt.make.core.activeConfigSettings 43 | 44 | 45 | org.eclipse.cdt.make.core.enableAutoBuild 46 | false 47 | 48 | 49 | org.eclipse.cdt.make.core.enableCleanBuild 50 | true 51 | 52 | 53 | org.eclipse.cdt.make.core.enableFullBuild 54 | true 55 | 56 | 57 | org.eclipse.cdt.make.core.fullBuildTarget 58 | V=1 59 | 60 | 61 | org.eclipse.cdt.make.core.stopOnError 62 | true 63 | 64 | 65 | org.eclipse.cdt.make.core.useDefaultBuildCmd 66 | false 67 | 68 | 69 | 70 | 71 | 72 | clean,full,incremental, 73 | 74 | 75 | ?name? 76 | 77 | 78 | 79 | 80 | 81 | com.android.ide.eclipse.adt.ResourceManagerBuilder 82 | 83 | 84 | 85 | 86 | com.android.ide.eclipse.adt.PreCompilerBuilder 87 | 88 | 89 | 90 | 91 | org.eclipse.jdt.core.javabuilder 92 | 93 | 94 | 95 | 96 | com.android.ide.eclipse.adt.ApkBuilder 97 | 98 | 99 | 100 | 101 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 102 | full,incremental, 103 | 104 | 105 | 106 | 107 | 108 | com.android.ide.eclipse.adt.AndroidNature 109 | org.eclipse.jdt.core.javanature 110 | org.eclipse.cdt.core.cnature 111 | org.eclipse.cdt.core.ccnature 112 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 113 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 114 | 115 | 116 | -------------------------------------------------------------------------------- /droid-testapp/jni/cmoss-tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "curl/curl.h" 31 | #include "boost/unordered_map.hpp" 32 | 33 | #include "openssl_certs.h" 34 | #include "log.h" 35 | 36 | #include "executor.h" 37 | #include "SSLInit.h" 38 | 39 | #define BUFFER_SIZE 1024 40 | 41 | 42 | Executor* executor = NULL; 43 | 44 | boost::unordered_map requestResult; 45 | boost::unordered_map responseData; 46 | 47 | 48 | // **** HTTP Data Get **** 49 | 50 | int curlDebugCallback(CURL* curl, curl_infotype infotype, char* text, size_t len, void* userdata) { 51 | 52 | TRACE("cURL: %s", text); 53 | return 0; 54 | } 55 | 56 | size_t respDataCallback(void* contents, size_t size, size_t nmemb, void* userdata) { 57 | 58 | char* buffer = (char *) contents; 59 | size_t len = size * nmemb; 60 | 61 | std::vector* data = (std::vector *) userdata; 62 | 63 | size_t newSize = data->size() + len; 64 | if (newSize >= data->capacity()) 65 | data->reserve((newSize / BUFFER_SIZE + 1) * BUFFER_SIZE); 66 | 67 | data->insert(data->end(), buffer, buffer + len); 68 | return len; 69 | } 70 | 71 | void getDataFromUrl(const char* url) { 72 | 73 | std::stringstream result; 74 | char error[CURL_ERROR_SIZE]; 75 | 76 | std::vector data; 77 | data.reserve(BUFFER_SIZE); 78 | 79 | bool success = false; 80 | 81 | CURL* curl = curl_easy_init(); 82 | if (curl) { 83 | 84 | curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error); 85 | curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); 86 | curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback); 87 | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); 88 | 89 | curl_easy_setopt(curl, CURLOPT_PROXY, "http.proxy.fmr.com"); 90 | curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8000L); 91 | 92 | #ifdef SKIP_PEER_VERIFICATION 93 | /* 94 | * If you want to connect to a site who isn't using a certificate that is 95 | * signed by one of the certs in the CA bundle you have, you can skip the 96 | * verification of the server's certificate. This makes the connection 97 | * A LOT LESS SECURE. 98 | * 99 | * If you have a CA cert for the server stored someplace else than in the 100 | * default bundle, then the CURLOPT_CAPATH option might come handy for 101 | * you. 102 | */ 103 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); 104 | #else 105 | curl_easy_setopt(curl, CURLOPT_CAPATH, __CACERTS_PATH); 106 | #endif 107 | 108 | #ifdef SKIP_HOSTNAME_VERFICATION 109 | /* 110 | * If the site you're connecting to uses a different host name that what 111 | * they have mentioned in their server certificate's commonName (or 112 | * subjectAltName) fields, libcurl will refuse to connect. You can skip 113 | * this check, but this will make the connection less secure. 114 | */ 115 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); 116 | #endif 117 | 118 | curl_easy_setopt(curl, CURLOPT_URL, url); 119 | curl_easy_setopt(curl, CURLOPT_USERAGENT, "cmoss-test-agent/1.0"); 120 | 121 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, respDataCallback); 122 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &data); 123 | 124 | TRACE("cURL initialized to perform HTTP get from '%s'...", url); 125 | 126 | CURLcode res = curl_easy_perform(curl); 127 | if (res) { 128 | result << "Error! - \""; 129 | result << error; 130 | result << '"'; 131 | TRACE("cURL HTTP returned error: %s", result.str().c_str()); 132 | } else { 133 | result << "Success!"; 134 | success = true; 135 | data.push_back(0); 136 | TRACE("cURL HTTP get succeeded."); 137 | } 138 | 139 | curl_easy_cleanup(curl); 140 | 141 | requestResult[url] = result.str(); 142 | 143 | if (success) { 144 | responseData[url] = std::string(&data[0], data.size()); 145 | TRACE("cURL HTTP get from '%s' returned:\n\t%s", url, responseData[url].c_str()); 146 | } else 147 | responseData[url] = ""; 148 | 149 | } else { 150 | 151 | ERROR("Error initializing cURL. A null handle was returned."); 152 | result << "cURL initialization error!"; 153 | } 154 | } 155 | 156 | 157 | // **** JNI Implementation **** 158 | 159 | extern "C" { 160 | 161 | void Java_org_cmoss_tests_TestLibsActivity_initialize(JNIEnv* env, jobject thiz, jstring path) { 162 | 163 | const char* certPath = env->GetStringUTFChars(path, 0); 164 | TRACE("Extracting certs to path '%s'...", certPath); 165 | 166 | int error = extractCerts(certPath); 167 | if (error) { 168 | TRACE("Error extracting certificates: %d", error); 169 | } 170 | 171 | init_locks(); 172 | curl_global_init(CURL_GLOBAL_ALL); 173 | 174 | executor = new Executor(2); 175 | 176 | TRACE("Done initializing CMOSS Tests."); 177 | } 178 | 179 | void Java_org_cmoss_tests_TestLibsActivity_shutdown(JNIEnv* env, jobject thiz) { 180 | 181 | curl_global_cleanup(); 182 | kill_locks(); 183 | 184 | delete executor; 185 | 186 | TRACE("Done shutting down CMOSS Tests."); 187 | } 188 | 189 | jstring Java_org_cmoss_tests_TestLibsActivity_curlTest(JNIEnv* env, jobject thiz) { 190 | 191 | executor->submit(boost::bind(getDataFromUrl, "https://www.google.com")); 192 | executor->submit(boost::bind(getDataFromUrl, "https://www.paypal.com/")); 193 | 194 | return env->NewStringUTF("Requests sent."); 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /droid-testapp/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | #Tue Mar 27 13:14:00 EDT 2012 2 | eclipse.preferences.version=1 3 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 4 | org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false} 5 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 6 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={} 7 | org.eclipse.cdt.codan.checkers.noreturn=Error 8 | org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false} 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 10 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 12 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 14 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={} 15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 16 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={} 17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 18 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false} 19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 20 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()} 21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 22 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 23 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 25 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 27 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=-Error 28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 29 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 31 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 33 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 35 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 37 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 39 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={} 41 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 43 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 45 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 47 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={} 49 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={} 51 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()} 53 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false} 55 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false} 57 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 59 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={macro\=>true} 61 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={macro\=>true} 63 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={macro\=>true,exceptions\=>("@(\#)","$Id")} 65 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 67 | -------------------------------------------------------------------------------- /droid-testapp/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 38 | 39 | 40 | 41 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | --------------------------------------------------------------------------------