#13795: Initial commit for sflphone-android

includes: libexpat libyaml libdbus-c++ commoncpp ccrtp
          libdbus (from android-4.0.4 sources)

TODO:
- git ignores "/jni/sflphone", sflphone repo should be cloned.
- sflphone-android only needs daemon directory. Ideally it should be possible
to clone it without cloning the whole sflphone project.
into sfl-android (commit 6a0fa7a "#13961: Fix cipher handling" has been used here)
- add pjsip-android project as a git submodule
- sflphone-android needs pjsip android project. Ideally daemon git repository
should not embed pjsip. Instead pjsip should be clone from official repositories.

Considering this, structure should have three distincts git repos:

sflphone-android/.git
sflphone-android/jni/ccrtp-1.8.0-android
sflphone-android/jni/commoncpp2-1.8.1-android
sflphone-android/jni/dbus
sflphone-android/jni/libdbus-c++-0.9.0-android
sflphone-android/jni/libexpat
sflphone-android/jni/libyaml

sflphone-android/jni/sflphone-daemon/.git
sflphone-android/jni/sflphone-daemon/src/audio
sflphone-android/jni/sflphone-daemon/src/config
sflphone-android/jni/sflphone-daemon/src/dbus
sflphone-android/jni/sflphone-daemon/src/history
sflphone-android/jni/sflphone-daemon/src/hooks
sflphone-android/jni/sflphone-daemon/src/iax
sflphone-android/jni/sflphone-daemon/src/sip
sflphone-android/jni/sflphone-daemon/src/video

sflphone-android/jni/pjsip-android/.git

Signed-off-by: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
diff --git a/jni/dbus/test/data/auth/anonymous-client-successful.auth-script b/jni/dbus/test/data/auth/anonymous-client-successful.auth-script
new file mode 100644
index 0000000..9a1620b
--- /dev/null
+++ b/jni/dbus/test/data/auth/anonymous-client-successful.auth-script
@@ -0,0 +1,16 @@
+## this tests that a client can login anonymously
+
+CLIENT
+
+## Reject whatever mechanism the client picks first
+EXPECT_COMMAND AUTH
+SEND 'REJECTED DBUS_TEST_NONEXISTENT_MECH1 ANONYMOUS DBUS_TEST_NONEXISTENT_MECH2'
+
+## And this time we get ANONYMOUS
+
+EXPECT_COMMAND AUTH
+## of course real DBUS_COOKIE_SHA1 would not send this here...
+SEND 'OK 1234deadbeef'
+
+EXPECT_COMMAND BEGIN
+EXPECT_STATE AUTHENTICATED
diff --git a/jni/dbus/test/data/auth/anonymous-server-successful.auth-script b/jni/dbus/test/data/auth/anonymous-server-successful.auth-script
new file mode 100644
index 0000000..172ae9d
--- /dev/null
+++ b/jni/dbus/test/data/auth/anonymous-server-successful.auth-script
@@ -0,0 +1,13 @@
+## this tests the server side in a successful auth of type ANONYMOUS 
+
+SERVER
+## verify that prior to doing anything, we haven't authed as anyone
+EXPECT_HAVE_NO_CREDENTIALS
+SEND 'AUTH ANONYMOUS 442d42757320312e312e31'
+EXPECT_COMMAND OK
+EXPECT_STATE WAITING_FOR_INPUT
+SEND 'BEGIN'
+EXPECT_STATE AUTHENTICATED
+## verify that we are still anonymous
+EXPECT_HAVE_NO_CREDENTIALS
+
diff --git a/jni/dbus/test/data/auth/cancel.auth-script b/jni/dbus/test/data/auth/cancel.auth-script
new file mode 100644
index 0000000..f2c519a
--- /dev/null
+++ b/jni/dbus/test/data/auth/cancel.auth-script
@@ -0,0 +1,19 @@
+## this tests canceling EXTERNAL
+
+SERVER
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND OK
+EXPECT_STATE WAITING_FOR_INPUT
+SEND 'CANCEL'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+## now start over and see if it works
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND OK
+EXPECT_STATE WAITING_FOR_INPUT
+SEND 'BEGIN'
+EXPECT_STATE AUTHENTICATED
+
+
+
diff --git a/jni/dbus/test/data/auth/client-out-of-mechanisms.auth-script b/jni/dbus/test/data/auth/client-out-of-mechanisms.auth-script
new file mode 100644
index 0000000..ce6d3ad
--- /dev/null
+++ b/jni/dbus/test/data/auth/client-out-of-mechanisms.auth-script
@@ -0,0 +1,7 @@
+## this tests that tests that the client disconnects when it's out of
+## known mechanisms
+
+CLIENT
+EXPECT_COMMAND AUTH
+SEND 'REJECTED BONGO_MD5'
+EXPECT_STATE NEED_DISCONNECT
diff --git a/jni/dbus/test/data/auth/external-failed.auth-script b/jni/dbus/test/data/auth/external-failed.auth-script
new file mode 100644
index 0000000..7c4e900
--- /dev/null
+++ b/jni/dbus/test/data/auth/external-failed.auth-script
@@ -0,0 +1,11 @@
+## this tests that auth of type EXTERNAL without credentials will fail
+
+SERVER
+NO_CREDENTIALS
+## verify that prior to doing anything, we haven't authed as anyone
+EXPECT_HAVE_NO_CREDENTIALS
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+## verify that we still haven't authed as anyone
+EXPECT_HAVE_NO_CREDENTIALS
diff --git a/jni/dbus/test/data/auth/external-root.auth-script b/jni/dbus/test/data/auth/external-root.auth-script
new file mode 100644
index 0000000..b4c4b43
--- /dev/null
+++ b/jni/dbus/test/data/auth/external-root.auth-script
@@ -0,0 +1,11 @@
+## this tests we can auth EXTERNAL as ourselves, with root credentials
+UNIX_ONLY
+SERVER
+ROOT_CREDENTIALS
+## 30 is ASCII '0' in hex
+SEND 'AUTH EXTERNAL 30'
+EXPECT_COMMAND OK
+EXPECT_STATE WAITING_FOR_INPUT
+SEND 'BEGIN'
+EXPECT_STATE AUTHENTICATED
+
diff --git a/jni/dbus/test/data/auth/external-silly.auth-script b/jni/dbus/test/data/auth/external-silly.auth-script
new file mode 100644
index 0000000..4e18ee8
--- /dev/null
+++ b/jni/dbus/test/data/auth/external-silly.auth-script
@@ -0,0 +1,12 @@
+## this tests we can't auth if socket reports silly credentials but we ask for our own uid
+
+SERVER
+## verify that prior to doing anything, we haven't authed as anyone
+EXPECT_HAVE_NO_CREDENTIALS
+SILLY_CREDENTIALS
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+## verify that we still haven't authed as anyone
+EXPECT_HAVE_NO_CREDENTIALS
+
diff --git a/jni/dbus/test/data/auth/external-successful.auth-script b/jni/dbus/test/data/auth/external-successful.auth-script
new file mode 100644
index 0000000..222938c
--- /dev/null
+++ b/jni/dbus/test/data/auth/external-successful.auth-script
@@ -0,0 +1,12 @@
+## this tests a successful auth of type EXTERNAL
+
+SERVER
+## verify that prior to doing anything, we haven't authed as anyone
+EXPECT_HAVE_NO_CREDENTIALS
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND OK
+EXPECT_STATE WAITING_FOR_INPUT
+SEND 'BEGIN'
+EXPECT_STATE AUTHENTICATED
+## verify that we now have some credentials
+EXPECT_HAVE_SOME_CREDENTIALS
diff --git a/jni/dbus/test/data/auth/extra-bytes.auth-script b/jni/dbus/test/data/auth/extra-bytes.auth-script
new file mode 100644
index 0000000..cd1e01d
--- /dev/null
+++ b/jni/dbus/test/data/auth/extra-bytes.auth-script
@@ -0,0 +1,10 @@
+## this tests that we have the expected extra bytes at the end
+
+SERVER
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND OK
+EXPECT_STATE WAITING_FOR_INPUT
+SEND 'BEGIN\r\nHello'
+EXPECT_STATE AUTHENTICATED_WITH_UNUSED_BYTES
+EXPECT_UNUSED 'Hello\r\n'
+EXPECT_STATE AUTHENTICATED
diff --git a/jni/dbus/test/data/auth/fail-after-n-attempts.auth-script b/jni/dbus/test/data/auth/fail-after-n-attempts.auth-script
new file mode 100644
index 0000000..0ced386
--- /dev/null
+++ b/jni/dbus/test/data/auth/fail-after-n-attempts.auth-script
@@ -0,0 +1,34 @@
+## this tests that after retrying too often we fail
+
+SERVER
+NO_CREDENTIALS
+
+# 1
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 2
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 3
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 4
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 5
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 6
+SEND 'AUTH EXTERNAL USERID_HEX'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE NEED_DISCONNECT
diff --git a/jni/dbus/test/data/auth/fallback.auth-script b/jni/dbus/test/data/auth/fallback.auth-script
new file mode 100644
index 0000000..0d880c0
--- /dev/null
+++ b/jni/dbus/test/data/auth/fallback.auth-script
@@ -0,0 +1,17 @@
+## this tests that a client can fallback to a secondary auth mech 
+
+CLIENT
+
+## Will try EXTERNAL by default first without first calling AUTH alone.
+
+EXPECT_COMMAND AUTH
+SEND 'REJECTED EXTERNAL DBUS_COOKIE_SHA1 DBUS_TEST_NONEXISTENT_MECH'
+
+## And this time we get DBUS_COOKIE_SHA1
+
+EXPECT_COMMAND AUTH
+## of course real DBUS_COOKIE_SHA1 would not send this here...
+SEND 'OK 1234deadbeef'
+
+EXPECT_COMMAND BEGIN
+EXPECT_STATE AUTHENTICATED
diff --git a/jni/dbus/test/data/auth/invalid-command-client.auth-script b/jni/dbus/test/data/auth/invalid-command-client.auth-script
new file mode 100644
index 0000000..ac17e7b
--- /dev/null
+++ b/jni/dbus/test/data/auth/invalid-command-client.auth-script
@@ -0,0 +1,8 @@
+## this tests that receiving a nonexistent command is handled properly
+## by a client
+
+CLIENT
+EXPECT_COMMAND AUTH
+SEND 'NONEXISTENT_COMMAND foo bar baz blah blah'
+EXPECT_COMMAND ERROR
+EXPECT_STATE WAITING_FOR_INPUT
diff --git a/jni/dbus/test/data/auth/invalid-command.auth-script b/jni/dbus/test/data/auth/invalid-command.auth-script
new file mode 100644
index 0000000..c49cb8d
--- /dev/null
+++ b/jni/dbus/test/data/auth/invalid-command.auth-script
@@ -0,0 +1,7 @@
+## this tests that receiving a nonexistent command is handled properly
+## by a server
+
+SERVER
+SEND 'NONEXISTENT_COMMAND foo bar baz blah blah'
+EXPECT_COMMAND ERROR
+EXPECT_STATE WAITING_FOR_INPUT
diff --git a/jni/dbus/test/data/auth/invalid-hex-encoding.auth-script b/jni/dbus/test/data/auth/invalid-hex-encoding.auth-script
new file mode 100644
index 0000000..1f15c43
--- /dev/null
+++ b/jni/dbus/test/data/auth/invalid-hex-encoding.auth-script
@@ -0,0 +1,6 @@
+## this tests an invalid hex encoding followed by successful authentication
+
+SERVER
+SEND 'AUTH EXTERNAL willy'
+EXPECT_COMMAND ERROR
+EXPECT_STATE WAITING_FOR_INPUT
diff --git a/jni/dbus/test/data/auth/mechanisms.auth-script b/jni/dbus/test/data/auth/mechanisms.auth-script
new file mode 100644
index 0000000..be44791
--- /dev/null
+++ b/jni/dbus/test/data/auth/mechanisms.auth-script
@@ -0,0 +1,8 @@
+## this tests that the server sends a list of mechanisms
+## in response to blank AUTH
+
+SERVER
+SEND AUTH
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+