Copy android related files in jni/

Remove more VLC occurences

Refs #52673
diff --git a/Makefile b/Makefile
index 8d05653..c453178 100644
--- a/Makefile
+++ b/Makefile
@@ -7,9 +7,9 @@
 SRC=sflphone-android
 JAVA_SOURCES=$(SRC)/src/org/sflphone/*.java
 JNI_SOURCES=$(SRC)/jni/*.c $(SRC)/jni/*.h
-LIBVLCJNI=$(SRC)/obj/local/$(ARCH)/libsflphone.so \
 
-LIBVLCJNI_H=$(SRC)/jni/libvlcjni.h
+LIBSFLPHONEJNI=$(SRC)/obj/local/$(ARCH)/libsflphone.so
+LIBSFLPHONEJNI_H=$(SRC)/sflphone/daemon/src/sflphone.h
 
 ifneq ($(V),)
 ANT_OPTS += -v
@@ -30,7 +30,7 @@
 NDK_DEBUG=1
 endif
 
-$(SFLPHONE_APK): $(LIBVLCJNI) $(JAVA_SOURCES)
+$(SFLPHONE_APK): $(LIBSFLPHONEJNI) $(JAVA_SOURCES)
 	@echo
 	@echo "=== Building $@ for $(ARCH) ==="
 	@echo
@@ -42,10 +42,10 @@
 
 SFLPHONE_MODULES=`./find_modules.sh $(SFLPHONE_BUILD_DIR)`
 
-$(LIBVLCJNI_H):
+$(LIBSFLPHONEJNI_H):
 	$(VERBOSE)if [ -z "$(SFLPHONE_BUILD_DIR)" ]; then echo "SFLPHONE_BUILD_DIR not defined" ; exit 1; fi
 	$(GEN)modules="$(SFLPHONE_MODULES)" ; \
-	if [ -z "$$modules" ]; then echo "No VLC modules found in $(SFLPHONE_BUILD_DIR)/modules"; exit 1; fi; \
+	if [ -z "$$modules" ]; then echo "No SFLPHONE modules found in $(SFLPHONE_BUILD_DIR)/modules"; exit 1; fi; \
 	DEFINITION=""; \
 	BUILTINS="const void *vlc_static_modules[] = {\n"; \
 	for file in $$modules; do \
@@ -57,11 +57,11 @@
 	printf "/* Autogenerated from the list of modules */\n $$DEFINITION\n $$BUILTINS\n" > $@
 
 
-$(LIBVLCJNI): $(JNI_SOURCES) $(LIBVLCJNI_H)
+$(LIBSFLPHONEJNI): $(JNI_SOURCES) $(LIBSFLPHONEJNI_H)
 	@if [ -z "$(SFLPHONE_BUILD_DIR)" ]; then echo "SFLPHONE_BUILD_DIR not defined" ; exit 1; fi
 	@if [ -z "$(ANDROID_NDK)" ]; then echo "ANDROID_NDK not defined" ; exit 1; fi
 	@echo
-	@echo "=== Building libvlcjni ==="
+	@echo "=== Building libsflphonejni ==="
 	@echo
 	$(VERBOSE)if [ -z "$(SFLPHONE_SRC_DIR)" ] ; then SFLPHONE_SRC_DIR=./vlc; fi ; \
 	if [ -z "$(SFLPHONE_CONTRIB)" ] ; then SFLPHONE_CONTRIB="$$SFLPHONE_SRC_DIR/contrib/$(TARGET_TUPLE)"; fi ; \
@@ -90,7 +90,7 @@
 	rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin .sdk vlc-sdk/ vlc-sdk.7z
 
 jniclean: lightclean
-	rm -f $(LIBVLCJNI) $(LIBVLCJNI_H)
+	rm -f $(LIBSFLPHONEJNI) $(LIBSFLPHONEJNI_H)
 
 distclean: clean jniclean
 
diff --git a/configure.sh b/configure.sh
index 548ab15..0beeccf 100755
--- a/configure.sh
+++ b/configure.sh
@@ -14,7 +14,7 @@
 # folder.
 ANDROID_API=android-9
 
-VLC_SOURCEDIR=..
+SFLPHONE_SOURCEDIR=sflphone/daemon
 
 CFLAGS="-g -O2 -fstrict-aliasing -funsafe-math-optimizations"
 if [ -n "$HAVE_ARM" ]; then
diff --git a/sflphone-android/jni/JavaJNI2CJNI_Load.py b/sflphone-android/jni/JavaJNI2CJNI_Load.py
new file mode 100755
index 0000000..941f066
--- /dev/null
+++ b/sflphone-android/jni/JavaJNI2CJNI_Load.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python
+import getopt, sys
+import re
+from string import Template
+
+def type_to_signature(itype):
+	if len(itype) > 2:
+		if itype[-2:] == '[]':
+			return "[%s" % type_to_signature(itype[:-2])
+	if itype == "int":
+		return "I"
+	if itype == "long":
+		return "J"
+	if itype == "void":
+		return "V"
+	if itype == "boolean":
+		return "Z"
+	if itype == "byte":
+		return "B"
+	if itype == "char":
+		return "C"
+	if itype == "short":
+		return "S"
+	if itype == "float":
+		return "F"
+	if itype == "double":
+		return "D"
+	if itype == "String":
+		return "Ljava/lang/String;"
+	if itype == "Object":
+		return "Ljava/lang/Object;"
+	return "Lorg/sflphone/service/%s;" % itype
+
+def parse_java_file(input_stream, package, module):
+	outputs = []
+	package_prefix = "Java_%s_%sJNI" % (package.replace(".", "_"), module)
+	for line in input_stream:
+		definition = re.match(r'.*public final static native ([^\( ]*) ([^\)]*)\(([^)]*)\).*',line)
+		if definition is not None:
+			retour = definition.group(1)
+			name = definition.group(2)
+			args = definition.group(3)
+			args_sigs = []
+			args_frags = args.split(',')
+			for args_frag in args_frags:
+				argf = re.match(r'(\b)?([^ ]+) .*', args_frag.strip())
+				if argf is not None:
+					args_sigs.append(type_to_signature(argf.group(2)))
+			sig = "(%s)%s" % (''.join(args_sigs), type_to_signature(retour))
+			outputs.append("{\"%s\", \"%s\", (void*)& %s_%s}" % (name, sig, package_prefix, name.replace('_', '_1')))
+	return outputs
+
+def render_to_template(defs, template_string):
+	template = Template(template_string)
+	return template.substitute(defs= ",\r\n".join(defs) )
+
+
+if __name__ == "__main__":
+	try:
+		opts, args = getopt.getopt(sys.argv[1:], "i:o:t:m:p:", ["input=", "output=", "template=", "module=", "package="])
+	except getopt.GetoptError, err:
+		# print help information and exit:
+		print str(err) # will print something like "option -a not recognized"
+		sys.exit(2)
+	input_stream = None
+	output_file = None
+	template_string = None
+	package = ""
+	module = ""
+	for o, a in opts:
+		if o in ("-i", "--input"):
+			input_stream = open(a)
+		if o in ("-o", "--output"):
+			output_file = open(a, "w")
+		if o in ("-t", "--template"):
+			template_string = open(a).read()
+		if o in ("-m", "--module"):
+			module = a
+		if o in ("-p", "--package"):
+			package = a
+
+	defs = parse_java_file(input_stream, package, module)
+	output_file.write(render_to_template(defs, template_string))
+	output_file.close()
+	input_stream.close()
diff --git a/sflphone-android/jni/callmanager.i b/sflphone-android/jni/callmanager.i
new file mode 100644
index 0000000..a1d168f
--- /dev/null
+++ b/sflphone-android/jni/callmanager.i
@@ -0,0 +1,403 @@
+/*
+ *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
+ *  Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
+ *          Alexandre Lision <alexnadre.L@savoirfairelinux.com>
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+%header %{
+
+#include "client/callmanager.h"
+
+
+typedef struct callmanager_callback
+{
+    void (*on_new_call_created)(const std::string& accountID,
+                                const std::string& callID,
+                                const std::string& to);
+
+    void (*on_call_state_changed)(const std::string& callID,
+                                  const std::string& state);
+
+    void (*on_incoming_call)(const std::string& accountID,
+                             const std::string& callID,
+                             const std::string& from);
+
+    void (*on_transfer_state_changed) (const std::string& result);
+
+    void (*on_conference_created) (const std::string& confID);
+
+    void (*on_conference_removed) (const std::string& confID);
+
+    void (*on_conference_state_changed) (const std::string& confID,
+                                          const std::string& state);
+
+    void (*on_incoming_message) (const std::string& ID,
+                                    const std::string& from,
+                                    const std::string& msg);
+
+    void (*on_record_playback_filepath) (const std::string& id,
+                                         const std::string& filename);
+
+    void (*on_recording_state_changed) (const std::string& callID,
+                                        const bool& state);
+
+    void (*newPresSubClientNotification) (const std::string& uri,
+											const std::string& basic,
+											const std::string& note);
+
+	void (*newPresSubServerRequest) (const std::string& remote);
+
+    void (*on_secure_sdes_on) (const std::string& callID);
+
+    void (*on_secure_sdes_off) (const std::string& callID);
+
+    void (*on_secure_zrtp_on) (const std::string& callID,
+                                const std::string& cipher);
+
+    void (*on_secure_zrtp_off) (const std::string& callID);
+
+    void (*on_show_sas) (const std::string& callID,
+                        const std::string& sas,
+                        const bool& verified);
+
+    void (*on_zrtp_not_supported) (const std::string& callID);
+
+    void (*on_zrtp_negociation_failed) (const std::string& callID,
+                                                const std::string& reason,
+                                                const std::string& severity);
+
+    void (*on_rtcp_report_received) (const std::string& callID,
+                                    const std::map<std::string, int>& stats);
+
+} callmanager_callback_t;
+
+
+class Callback {
+public:
+    virtual ~Callback() {}
+
+    virtual void on_new_call_created(const std::string& arg1,
+                                     const std::string& arg2,
+                                     const std::string& arg3) {}
+
+    virtual void on_call_state_changed(const std::string& arg1,
+                                       const std::string& arg2) {}
+
+    virtual void on_incoming_call(const std::string& arg1,
+                                  const std::string& arg2,
+                                  const std::string& arg3) {}
+
+    virtual void on_transfer_state_changed (const std::string& arg1) {}
+
+    virtual void on_conference_created (const std::string& arg1) {}
+
+    virtual void on_conference_removed (const std::string& arg1) {}
+
+    virtual void on_conference_state_changed (const std::string& arg1,
+                                            const std::string& arg2) {}
+
+    virtual void on_incoming_message(const std::string& ID,
+                                    const std::string& from,
+                                    const std::string& msg) {}
+
+    virtual void on_record_playback_filepath(const std::string& id,
+                                              const std::string& filename) {}
+
+    virtual void on_recording_state_changed(const std::string& callID,
+                                        const bool& state) {}
+
+    virtual void newPresSubClientNotification(const std::string& uri,
+                                                const std::string& basic,
+                                                const std::string& note) {}
+
+    virtual void newPresSubServerRequest(const std::string& remote) {}
+
+    virtual void on_secure_sdes_on(const std::string& callID) {}
+
+    virtual void on_secure_sdes_off(const std::string& callID) {}
+
+    virtual void on_secure_zrtp_on(const std::string& callID,
+                                const std::string& cipher) {}
+
+    virtual void on_secure_zrtp_off(const std::string& callID) {}
+
+    virtual void on_show_sas(const std::string& callID,
+                        const std::string& sas,
+                        const bool& verified) {}
+
+    virtual void on_zrtp_not_supported(const std::string& callID) {}
+
+    virtual void on_zrtp_negociation_failed(const std::string& callID,
+                                                const std::string& reason,
+                                                const std::string& severity) {}
+
+    virtual void on_rtcp_report_received (const std::string& callID,
+                                    const std::map<std::string, int>& stats) {}
+};
+
+
+static Callback* registeredCallbackObject = NULL;
+
+void on_new_call_created_wrapper (const std::string& accountID,
+                                  const std::string& callID,
+                                  const std::string& to) {
+    registeredCallbackObject->on_new_call_created(accountID, callID, to);
+}
+
+void on_call_state_changed_wrapper(const std::string& callID,
+                           const std::string& state) {
+    registeredCallbackObject->on_call_state_changed(callID, state);
+}
+
+void on_incoming_call_wrapper (const std::string& accountID,
+                               const std::string& callID,
+                               const std::string& from) {
+    registeredCallbackObject->on_incoming_call(accountID, callID, from);
+}
+
+void on_transfer_state_changed_wrapper (const std::string& result) {
+    registeredCallbackObject->on_transfer_state_changed(result);
+}
+
+void on_conference_created_wrapper (const std::string& confID) {
+    registeredCallbackObject->on_conference_created(confID);
+}
+
+void on_conference_removed_wrapper (const std::string& confID) {
+    registeredCallbackObject->on_conference_removed(confID);
+}
+
+void on_conference_state_changed_wrapper (const std::string& confID,
+                                          const std::string& state) {
+    registeredCallbackObject->on_conference_state_changed(confID, state);
+}
+
+void on_incoming_message_wrapper(const std::string& ID, const std::string& from, const std::string& msg) {
+    registeredCallbackObject->on_incoming_message(ID, from, msg);
+}
+
+void on_record_playback_filepath_wrapper(const std::string& id, const std::string& filename) {
+    registeredCallbackObject->on_record_playback_filepath(id, filename);
+}
+
+void on_recording_state_changed_wrapper(const std::string& callID, const bool& state) {
+    registeredCallbackObject->on_recording_state_changed(callID, state);
+}
+
+void on_newPresSubClientNotification_wrapper(const std::string& uri, const std::string& basic, const std::string& note) {
+    registeredCallbackObject->newPresSubClientNotification(uri, basic, note);
+}
+
+void on_newPresSubServerRequest_wrapper(const std::string& remote) {
+    registeredCallbackObject->newPresSubServerRequest(remote);
+}
+
+void on_secure_sdes_on_wrapper(const std::string& callID){
+    registeredCallbackObject->on_secure_sdes_on(callID);
+}
+
+void on_secure_sdes_off_wrapper(const std::string& callID) {
+    registeredCallbackObject->on_secure_sdes_off(callID);
+}
+
+void on_secure_zrtp_on_wrapper(const std::string& callID,const std::string& cipher){
+    registeredCallbackObject->on_secure_zrtp_on(callID, cipher);
+}
+
+void on_secure_zrtp_off_wrapper(const std::string& callID){
+    registeredCallbackObject->on_secure_zrtp_off(callID);
+}
+
+void on_show_sas_wrapper(const std::string& callID, const std::string& sas, const bool& verified){
+    registeredCallbackObject->on_show_sas(callID, sas, verified);
+}
+
+void on_zrtp_not_supported_wrapper(const std::string& callID){
+    registeredCallbackObject->on_zrtp_not_supported(callID);
+}
+
+void on_zrtp_negociation_failed_wrapper(const std::string& callID, const std::string& reason, const std::string& severity){
+    registeredCallbackObject->on_zrtp_negociation_failed(callID, reason, severity);
+}
+
+void on_rtcp_report_received_wrapper (const std::string& callID, const std::map<std::string, int>& stats){
+    registeredCallbackObject->on_rtcp_report_received(callID, stats);
+}
+
+static struct callmanager_callback wrapper_callback_struct = {
+    &on_new_call_created_wrapper,
+    &on_call_state_changed_wrapper,
+    &on_incoming_call_wrapper,
+    &on_transfer_state_changed_wrapper,
+    &on_conference_created_wrapper,
+    &on_conference_removed_wrapper,
+    &on_conference_state_changed_wrapper,
+    &on_incoming_message_wrapper,
+    &on_record_playback_filepath_wrapper,
+    &on_recording_state_changed_wrapper,
+    &on_newPresSubClientNotification_wrapper,
+    &on_newPresSubServerRequest_wrapper,
+    &on_secure_sdes_on_wrapper,
+    &on_secure_sdes_off_wrapper,
+    &on_secure_zrtp_on_wrapper,
+    &on_secure_zrtp_off_wrapper,
+    &on_show_sas_wrapper,
+    &on_zrtp_not_supported_wrapper,
+    &on_zrtp_negociation_failed_wrapper,
+    &on_rtcp_report_received_wrapper
+};
+
+void setCallbackObject(Callback* callback) {
+    registeredCallbackObject = callback;
+}
+
+%}
+
+%feature("director") Callback;
+
+class CallManager {
+public:
+    bool placeCall(const std::string& accountID, const std::string& callID, const std::string& to);
+
+    bool refuse(const std::string& callID);
+    bool accept(const std::string& callID);
+    bool hangUp(const std::string& callID);
+    bool hold(const std::string& callID);
+    bool unhold(const std::string& callID);
+    bool transfer(const std::string& callID, const std::string& to);
+    bool attendedTransfer(const std::string& transferID, const std::string& targetID);
+    std::map< std::string, std::string > getCallDetails(const std::string& callID);
+    std::vector< std::string > getCallList();
+
+    /* Conference related methods */
+    void removeConference(const std::string& conference_id);
+    bool joinParticipant(const std::string& sel_callID, const std::string& drag_callID);
+    void createConfFromParticipantList(const std::vector< std::string >& participants);
+    bool isConferenceParticipant(const std::string& call_id);
+    bool addParticipant(const std::string& callID, const std::string& confID);
+    bool addMainParticipant(const std::string& confID);
+    bool detachParticipant(const std::string& callID);
+    bool joinConference(const std::string& sel_confID, const std::string& drag_confID);
+    bool hangUpConference(const std::string& confID);
+    bool holdConference(const std::string& confID);
+    bool unholdConference(const std::string& confID);
+    std::vector<std::string> getConferenceList();
+    std::vector<std::string> getParticipantList(const std::string& confID);
+    std::string getConferenceId(const std::string& callID);
+    std::map<std::string, std::string> getConferenceDetails(const std::string& callID);
+
+    /* File Playback methods */
+    bool startRecordedFilePlayback(const std::string& filepath);
+    void stopRecordedFilePlayback(const std::string& filepath);
+
+    /* General audio methods */
+    bool toggleRecording(const std::string& callID);
+    void recordPlaybackSeek(const double& value);
+    bool getIsRecording(const std::string& callID);
+    std::string getCurrentAudioCodecName(const std::string& callID);
+    void playDTMF(const std::string& key);
+    void startTone(const int32_t& start, const int32_t& type);
+
+    /* Security related methods */
+    void setSASVerified(const std::string& callID);
+    void resetSASVerified(const std::string& callID);
+    void setConfirmGoClear(const std::string& callID);
+    void requestGoClear(const std::string& callID);
+    void acceptEnrollment(const std::string& callID, const bool& accepted);
+
+    /* Instant messaging */
+    void sendTextMessage(const std::string& callID, const std::string& message);
+};
+
+class Callback {
+public:
+    virtual ~Callback();
+
+    virtual void on_new_call_created(const std::string& arg1,
+                                     const std::string& arg2,
+                                     const std::string& arg3);
+
+    virtual void on_call_state_changed(const std::string& arg1,
+                                       const std::string& arg2);
+
+    virtual void on_incoming_call(const std::string& arg1,
+                                  const std::string& arg2,
+                                  const std::string& arg3);
+
+    virtual void on_transfer_state_changed(const std::string& arg1);
+
+    virtual void on_conference_created(const std::string& arg1);
+
+    virtual void on_conference_removed(const std::string& arg1);
+
+    virtual void on_conference_state_changed(const std::string& arg1,
+                                              const std::string& arg2);
+
+    virtual void on_incoming_message(const std::string& ID,
+                                    const std::string& from,
+                                    const std::string& msg);
+
+    virtual void on_record_playback_filepath(const std::string& id,
+                                            const std::string& filename);
+
+    virtual void on_recording_state_changed(const std::string& callID,
+                                            const bool& state);
+
+    virtual void newPresSubClientNotification(const std::string& uri,
+                                            const std::string& basic,
+                                            const std::string& note);
+
+    virtual void newPresSubServerRequest(const std::string& remote);
+
+    virtual void on_secure_sdes_on(const std::string& callID);
+
+    virtual void on_secure_sdes_off(const std::string& callID);
+
+    virtual void on_secure_zrtp_on(const std::string& callID,
+                                const std::string& cipher);
+
+    virtual void on_secure_zrtp_off(const std::string& callID);
+
+    virtual void on_show_sas(const std::string& callID,
+                        const std::string& sas,
+                        const bool& verified);
+
+    virtual void on_zrtp_not_supported(const std::string& callID);
+
+    virtual void on_zrtp_negociation_failed(const std::string& callID,
+                                                const std::string& reason,
+                                                const std::string& severity);
+
+    virtual void on_rtcp_report_received (const std::string& callID,
+                                    const std::map<std::string, int>& stats);
+};
+
+static Callback* registeredCallbackObject = NULL;
+
+void setCallbackObject(Callback* callback) {
+    registeredCallbackObject = callback;
+}
diff --git a/sflphone-android/jni/callmanager_jni.cpp b/sflphone-android/jni/callmanager_jni.cpp
new file mode 100644
index 0000000..4adbad1
--- /dev/null
+++ b/sflphone-android/jni/callmanager_jni.cpp
@@ -0,0 +1,152 @@
+/*
+ *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
+ *  Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
+ *  Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
+ *  Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+#include "client/callmanager.h"
+#include "jni_callbacks.h"
+
+CallManager::CallManager()
+{}
+
+void CallManager::callStateChanged(const std::string& callID, const std::string& state)
+{
+    on_call_state_changed_wrapper(callID, state);
+}
+
+void CallManager::transferFailed()
+{
+
+}
+
+void CallManager::transferSucceeded()
+{
+
+}
+
+void CallManager::recordPlaybackStopped(const std::string& path)
+{
+
+}
+
+void CallManager::voiceMailNotify(const std::string& callID, const int32_t& nd_msg)
+{
+
+}
+
+void CallManager::incomingMessage(const std::string& ID, const std::string& from, const std::string& msg)
+{
+    on_incoming_message_wrapper(ID, from, msg);
+}
+
+void CallManager::incomingCall(const std::string& accountID, const std::string& callID, const std::string& from)
+{
+    on_incoming_call_wrapper(accountID, callID, from);
+}
+
+void CallManager::recordPlaybackFilepath(const std::string& id, const std::string& filename)
+{
+    on_record_playback_filepath_wrapper(id, filename);
+}
+
+void CallManager::conferenceCreated(const std::string& confID)
+{
+    on_conference_created_wrapper(confID);
+}
+
+void CallManager::conferenceChanged(const std::string& confID,const std::string& state)
+{
+    on_conference_state_changed_wrapper(confID, state);
+}
+
+void CallManager::conferenceRemoved(const std::string& confID)
+{
+    on_conference_removed_wrapper(confID);
+}
+
+void CallManager::newCallCreated(const std::string& accountID, const std::string& callID, const std::string& to)
+{
+    on_new_call_created_wrapper(accountID, callID, to);
+}
+
+void CallManager::sipCallStateChanged(const std::string& accoundID, const std::string& state, const int32_t& code)
+{
+
+}
+
+void CallManager::recordingStateChanged(const std::string& callID, const bool& state)
+{
+    on_recording_state_changed_wrapper(callID, state);
+}
+
+void CallManager::updatePlaybackScale(const std::string&, const int32_t&, const int32_t&)
+{
+
+}
+
+void CallManager::secureSdesOn(std::string const& callID)
+{
+    on_secure_sdes_on_wrapper(callID);
+}
+
+void CallManager::secureSdesOff(std::string const& callID)
+{
+    on_secure_sdes_off_wrapper(callID);
+}
+
+void CallManager::secureZrtpOn(const std::string& callID, const std::string& cipher)
+{
+    on_secure_zrtp_on_wrapper(callID, cipher);
+}
+
+void CallManager::secureZrtpOff(const std::string& callID)
+{
+    on_secure_zrtp_off_wrapper(callID);
+}
+
+void CallManager::showSAS(const std::string& callID, const std::string& sas, const bool& verified)
+{
+    on_show_sas_wrapper(callID, sas, verified);
+}
+
+void CallManager::zrtpNotSuppOther(const std::string& callID)
+{
+    on_zrtp_not_supported_wrapper(callID);
+}
+
+void CallManager::zrtpNegotiationFailed(const std::string& callID, const std::string& reason, const std::string& severity)
+{
+    on_zrtp_negociation_failed_wrapper(callID, reason, severity);
+}
+
+void CallManager::onRtcpReportReceived(const std::string& callID, const std::map<std::string, int>& stats)
+{
+    on_rtcp_report_received_wrapper(callID, stats);
+}
diff --git a/sflphone-android/jni/configurationmanager.i b/sflphone-android/jni/configurationmanager.i
new file mode 100644
index 0000000..329ab0c
--- /dev/null
+++ b/sflphone-android/jni/configurationmanager.i
@@ -0,0 +1,184 @@
+/*
+ *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
+ *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+%header %{
+#include "client/configurationmanager.h"
+
+typedef struct configurationmanager_callback
+{
+    void (*on_accounts_changed)(void);
+    void (*on_account_state_changed)(const std::string& accountID, const int32_t& state);
+    void (*on_account_state_changed_with_code)(const std::string& accountID, const std::string& state, const int32_t& code);
+    std::vector<int32_t> (*get_hardware_audio_format)(void);
+} configurationmanager_callback_t;
+
+
+class ConfigurationCallback {
+public:
+    virtual ~ConfigurationCallback() {}
+    virtual void on_accounts_changed(void) {}
+    virtual void on_account_state_changed(const std::string& accountID, const int32_t& state) {}
+    virtual void on_account_state_changed_with_code(const std::string& accountID, const std::string& state, const int32_t& code) {}
+    virtual std::vector<int32_t> get_hardware_audio_format(void) {}
+};
+
+static ConfigurationCallback *registeredConfigurationCallbackObject = NULL;
+
+void on_accounts_changed_wrapper (void) {
+    registeredConfigurationCallbackObject->on_accounts_changed();
+}
+
+void on_account_state_changed_wrapper (const std::string& accountID, const int32_t& state) {
+    registeredConfigurationCallbackObject->on_account_state_changed(accountID, state);
+}
+
+void on_account_state_changed_with_code_wrapper (const std::string& accountID, const std::string& state, const int32_t& code) {
+    registeredConfigurationCallbackObject->on_account_state_changed_with_code(accountID, state, code);
+}
+
+std::vector<int32_t> get_hardware_audio_format_wrapper(void) {
+    return registeredConfigurationCallbackObject->get_hardware_audio_format();
+}
+
+static struct configurationmanager_callback wrapper_configurationcallback_struct = {
+    &on_accounts_changed_wrapper,
+    &on_account_state_changed_wrapper,
+    &on_account_state_changed_with_code_wrapper,
+    &get_hardware_audio_format_wrapper
+};
+
+void setConfigurationCallbackObject(ConfigurationCallback *callback) {
+    registeredConfigurationCallbackObject = callback;
+}
+
+%}
+
+%feature("director") ConfigurationCallback;
+
+class ConfigurationManager {
+public:
+    std::map< std::string, std::string > getAccountDetails(const std::string& accountID);
+    void setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details);
+    std::map<std::string, std::string> getAccountTemplate();
+    std::string addAccount(const std::map< std::string, std::string >& details);
+    void removeAccount(const std::string& accountID);
+    std::vector< std::string > getAccountList();
+    void sendRegister(const std::string& accountID, const bool& enable);
+    void registerAllAccounts(void);
+
+    std::map< std::string, std::string > getTlsSettingsDefault();
+
+    std::vector< int32_t > getAudioCodecList();
+    std::vector< std::string > getSupportedTlsMethod();
+    std::vector< std::string > getAudioCodecDetails(const int32_t& payload);
+    std::vector< int32_t > getActiveAudioCodecList(const std::string& accountID);
+
+    void setActiveAudioCodecList(const std::vector< std::string >& list, const std::string& accountID);
+
+    std::vector< std::string > getAudioPluginList();
+    void setAudioPlugin(const std::string& audioPlugin);
+    std::vector< std::string > getAudioOutputDeviceList();
+    void setAudioOutputDevice(const int32_t& index);
+    void setAudioInputDevice(const int32_t& index);
+    void setAudioRingtoneDevice(const int32_t& index);
+    std::vector< std::string > getAudioInputDeviceList();
+    std::vector< std::string > getCurrentAudioDevicesIndex();
+    int32_t getAudioInputDeviceIndex(const std::string& name);
+    int32_t getAudioOutputDeviceIndex(const std::string& name);
+    std::string getCurrentAudioOutputPlugin();
+    bool getNoiseSuppressState();
+    void setNoiseSuppressState(const bool& state);
+    bool isAgcEnabled();
+    void setAgcState(const bool& state);
+    bool isDtmfMuted();
+    void muteDtmf(const bool& mute);
+    bool isCaptureMuted();
+    void muteCapture(const bool& mute);
+    bool isPlaybackMuted();
+    void mutePlayback(const bool& mute);
+    void setVolume(const std::string& device, const double& value);
+    double getVolume(const std::string& device);
+
+    std::map<std::string, std::string> getRingtoneList();
+
+    std::string getAudioManager();
+    bool setAudioManager(const std::string& api);
+
+    int32_t isIax2Enabled();
+    std::string getRecordPath();
+    void setRecordPath(const std::string& recPath);
+    bool getIsAlwaysRecording();
+    void setIsAlwaysRecording(const bool& rec);
+
+    void setHistoryLimit(const int32_t& days);
+    int32_t getHistoryLimit();
+    void clearHistory();
+
+    void setAccountsOrder(const std::string& order);
+
+    std::map<std::string, std::string> getHookSettings();
+    void setHookSettings(const std::map<std::string, std::string>& settings);
+
+    std::vector<std::map<std::string, std::string> > getHistory();
+
+    std::map<std::string, std::string> getTlsSettings();
+    void setTlsSettings(const std::map< std::string, std::string >& details);
+    std::map< std::string, std::string > getIp2IpDetails();
+
+    std::vector< std::map< std::string, std::string > > getCredentials(const std::string& accountID);
+    void setCredentials(const std::string& accountID, const std::vector< std::map< std::string, std::string > >& details);
+
+    std::string getAddrFromInterfaceName(const std::string& interface);
+
+    std::vector<std::string> getAllIpInterface();
+    std::vector<std::string> getAllIpInterfaceByName();
+
+    std::map<std::string, std::string> getShortcuts();
+    void setShortcuts(const std::map<std::string, std::string> &shortcutsMap);
+
+    bool checkForPrivateKey(const std::string& pemPath);
+    bool checkCertificateValidity(const std::string& caPath, const std::string& pemPath);
+    bool checkHostnameCertificate(const  std::string& host, const std::string& port);
+
+};
+
+class ConfigurationCallback {
+public:
+    virtual ~ConfigurationCallback();
+    virtual void on_accounts_changed(void);
+    virtual void on_account_state_changed(const std::string& accountID, const int32_t& state);
+    virtual void on_account_state_changed_with_code(const std::string& accountID, const std::string& state, const int32_t& code);
+    virtual std::vector<int32_t> get_hardware_audio_format(void);
+};
+
+static ConfigurationCallback *registeredConfigurationCallbackObject = NULL;
+
+void setConfigurationCallbackObject(ConfigurationCallback *callback) {
+    registeredConfigurationCallbackObject = callback;
+}
diff --git a/sflphone-android/jni/configurationmanager_jni.cpp b/sflphone-android/jni/configurationmanager_jni.cpp
new file mode 100644
index 0000000..5a9ab95
--- /dev/null
+++ b/sflphone-android/jni/configurationmanager_jni.cpp
@@ -0,0 +1,80 @@
+/*
+ *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
+ *  Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
+ *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
+ *  Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
+ *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+#include "client/configurationmanager.h"
+#include "jni_callbacks.h"
+
+ConfigurationManager::ConfigurationManager() {}
+
+void ConfigurationManager::accountsChanged()
+{
+    on_accounts_changed_wrapper();
+}
+
+void ConfigurationManager::historyChanged()
+{
+
+}
+
+void ConfigurationManager::stunStatusFailure(const std::string& accountID)
+{
+
+}
+
+void ConfigurationManager::volumeChanged(const std::string&, const int&)
+{
+}
+
+void ConfigurationManager::registrationStateChanged(const std::string& accountID, int const& state)
+{
+    on_account_state_changed_wrapper(accountID, state);
+}
+
+void ConfigurationManager::sipRegistrationStateChanged(const std::string& accountID, const std::string& state, const int32_t& code)
+{
+    on_account_state_changed_with_code_wrapper(accountID, state, code);
+}
+
+void ConfigurationManager::errorAlert(const int & /*alert*/)
+{
+}
+
+std::vector< int32_t > ConfigurationManager::getHardwareAudioFormat()
+{
+    return get_hardware_audio_format_wrapper();
+}
+
+std::vector<std::string> ConfigurationManager::getSupportedAudioManagers()
+{
+    return {"opensl"};
+}
diff --git a/sflphone-android/jni/jni-xml2cpp.py b/sflphone-android/jni/jni-xml2cpp.py
new file mode 100755
index 0000000..067f488
--- /dev/null
+++ b/sflphone-android/jni/jni-xml2cpp.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python
+
+#
+# PACKAGE DEPENDENCIES: python python-lxml
+#
+
+#import easy to use xml parser called minidom:
+from lxml import etree
+#from copy import deepcopy
+from lxml import objectify
+import re, sys, getopt
+
+def rreplace(s, old, new, occurrence):
+    li = s.rsplit(old, occurrence)
+    return new.join(li)
+
+def usage():
+    print "jni-xml2cpp.py --file <file> | -i <file>"
+
+# main
+inputfile = "./dbus/callmanager-introspec.xml"
+outputfile = "./dbus/callmanager-jni.h"
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hi:o:", ["help", "input=", "output="])
+except getopt.GetoptError, err:
+    usage()
+    print str(err)
+    #print opts
+    sys.exit(2)
+
+for opt, arg in opts:
+    if opt in ("-h", "--help"):
+        usage()
+        sys.exit(0)
+    elif opt in ("-i", "--input"):
+        inputfile = arg
+    elif opt in ("-o", "--output"):
+        outputfile = arg
+    else:
+        print "error: argument not recognized"
+        sys.exit(3)
+
+print "inputfile = %s" % (inputfile)
+print "outputfile = %s" % (outputfile)
+source = "".join(args)
+
+# lxml.objectify
+# FIXME relative path
+cm_obj_tree = objectify.parse(inputfile)
+cm_obj_root = cm_obj_tree.getroot()
+# http://www.skymind.com/~ocrow/python_string/
+# method 4: list of strings
+prototype = []
+# iteration on methods
+for meth in cm_obj_root.interface.iter(tag="method"):
+# iteration on arguments
+    prototype.append(meth.get("name"))
+    prototype.append("(")
+    for argum in meth.iter(tag="arg"):
+        name = argum.get("name")
+        typ = argum.get("type")
+# FIXME
+        if typ == 's':
+            prototype.append("string %s, " % (name))
+        elif typ == 'i':
+            prototype.append("int %s, " % (name))
+        elif typ == 'd':
+            prototype.append("unsigned int %s, " % (name))
+        elif typ == 'as':
+            prototype.append("std::vector< std::string > &%s, " % (name))
+        else:
+            prototype.append("void %s, " % (name))
+    prototype.append(");\n")
+
+# starting from the end of string,
+# replace the first and 1-only comma by nothing
+#rreplace(prototype[tostring(), ',', '', 1)
+
+p = re.compile(", \);")
+prototypes = p.sub(");", ''.join(prototype))
+
+# FIXME relative path
+outfile = open(outputfile, "w")
+outfile.write(prototypes)
+outfile.close()
diff --git a/sflphone-android/jni/jni_callbacks.h b/sflphone-android/jni/jni_callbacks.h
new file mode 100644
index 0000000..acc6539
--- /dev/null
+++ b/sflphone-android/jni/jni_callbacks.h
@@ -0,0 +1,39 @@
+
+
+
+
+extern struct callmanager_callback wrapper_callback_struct;
+void on_new_call_created_wrapper (const std::string& accountID,
+                                         const std::string& callID,
+                                         const std::string& to);
+void on_call_state_changed_wrapper(const std::string& callID,
+                                          const std::string& to);
+void on_incoming_call_wrapper (const std::string& accountID,
+                                      const std::string& callID,
+                                      const std::string& from);
+void on_transfer_state_changed_wrapper (const std::string& result);
+
+void on_conference_created_wrapper (const std::string& confID);
+void on_conference_removed_wrapper (const std::string& confID);
+void on_conference_state_changed_wrapper(const std::string& confID,const std::string& state);
+void on_incoming_message_wrapper(const std::string& ID, const std::string& from, const std::string& msg);
+void on_newPresSubClientNotification_wrapper(const std::string& uri, const std::string& basic, const std::string& note);
+void on_newPresSubServerRequest_wrapper(const std::string& remote);
+
+void on_secure_sdes_on_wrapper(const std::string& callID);
+void on_secure_sdes_off_wrapper(const std::string& callID);
+void on_secure_zrtp_on_wrapper(const std::string& callID,const std::string& cipher);
+void on_secure_zrtp_off_wrapper(const std::string& callID);
+void on_show_sas_wrapper(const std::string& callID, const std::string& sas, const bool& verified);
+void on_zrtp_not_supported_wrapper(const std::string& callID);
+void on_zrtp_negociation_failed_wrapper(const std::string& callID, const std::string& reason, const std::string& severity);
+void on_rtcp_report_received_wrapper(const std::string& callID, const std::map<std::basic_string<char>, int>& stats);
+
+extern struct configurationmanager_callback wrapper_configurationcallback_struct;
+extern void on_accounts_changed_wrapper ();
+extern void on_account_state_changed_wrapper (const std::string& accoundID, int const& state);
+extern void on_account_state_changed_with_code_wrapper (const std::string& accoundID, const std::string& state, const int32_t& code);
+extern std::vector<int> get_hardware_audio_format_wrapper();
+
+void on_record_playback_filepath_wrapper(const std::string& id, const std::string& filename);
+void on_recording_state_changed_wrapper(const std::string& callID, const bool& state);
diff --git a/sflphone-android/jni/jni_interface.i b/sflphone-android/jni/jni_interface.i
new file mode 100644
index 0000000..0021f97
--- /dev/null
+++ b/sflphone-android/jni/jni_interface.i
@@ -0,0 +1,92 @@
+/*
+ *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
+ *  Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+/* File : jni_interface.i */
+%module (directors="1") SFLPhoneservice
+
+#define SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON
+%include "typemaps.i"
+%include "std_string.i" /* std::string typemaps */
+%include "enums.swg"
+%include "arrays_java.i";
+%include "carrays.i";
+%include "std_map.i";
+%include "std_vector.i";
+%include "stdint.i";
+
+/* void* shall be handled as byte arrays */
+%typemap(jni) void * "void *"
+%typemap(jtype) void * "byte[]"
+%typemap(jstype) void * "byte[]"
+%typemap(javain) void * "$javainput"
+%typemap(in) void * %{
+	$1 = $input;
+%}
+%typemap(javadirectorin) void * "$jniinput"
+%typemap(out) void * %{
+	$result = $1;
+%}
+%typemap(javaout) void * {
+	return $jnicall;
+}
+
+namespace std {
+    %template(StringMap) map<string, string>;
+    %template(StringVect) vector<string>;
+    %template(VectMap) vector< map<string,string> >;
+    %template(IntegerMap) map<string,int>;
+    %template(IntVect) vector<int32_t>;
+}
+
+/* not parsed by SWIG but needed by generated C files */
+%header %{
+
+#include <logger.h>
+
+%}
+
+%inline %{
+/* some functions that need to be declared in *_wrap.cpp
+ * that are not declared elsewhere in the c++ code
+ */
+%}
+
+/* parsed by SWIG to generate all the glue */
+/* %include "../managerimpl.h" */
+/* %include <client/callmanager.h> */
+
+//%constant struct callmanager_callback* WRAPPER_CALLBACK_STRUCT = &wrapper_callback_struct;
+
+%include "managerimpl.i"
+%include "callmanager.i"
+%include "configurationmanager.i"
+
+#ifndef SWIG
+/* some bad declarations */
+#endif
diff --git a/sflphone-android/jni/managerimpl.i b/sflphone-android/jni/managerimpl.i
new file mode 100644
index 0000000..357d416
--- /dev/null
+++ b/sflphone-android/jni/managerimpl.i
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
+ *  Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+/* %nodefaultctor ManagerImpl;
+%nodefaultdtor ManagerImpl; */
+%header %{
+#include <managerimpl.h>
+namespace Manager {
+extern ManagerImpl& instance();
+}
+%}
+
+class ManagerImpl {
+public:
+    void init(const std::string &config_file);
+    void setPath(const std::string &path);
+    void pollEvents();
+    void finish();
+};
+
+//%rename(Manager_instance) Manager::instance;
+
+namespace Manager {
+
+ManagerImpl& Manager::instance()
+{
+    // Meyers singleton
+    static ManagerImpl instance_;
+    return instance_;
+}
+
+}
diff --git a/sflphone-android/jni/presencemanager_jni.cpp b/sflphone-android/jni/presencemanager_jni.cpp
new file mode 100644
index 0000000..9a0b197
--- /dev/null
+++ b/sflphone-android/jni/presencemanager_jni.cpp
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (C) 2013 Savoir-Faire Linux Inc.
+ *  Author: Patrick Keroulas <patrick.keroulas@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *  Additional permission under GNU GPL version 3 section 7:
+ *
+ *  If you modify this program, or any covered work, by linking or
+ *  combining it with the OpenSSL project's OpenSSL library (or a
+ *  modified version of that library), containing parts covered by the
+ *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
+ *  grants you additional permission to convey the resulting work.
+ *  Corresponding Source for a non-source form of such a combination
+ *  shall include the source code for the parts of OpenSSL used as well
+ *  as that of the covered work.
+ */
+
+#include "client/presencemanager.h"
+
+PresenceManager::PresenceManager()
+{}
+
+void
+PresenceManager::newBuddyNotification(const std::string& accountID, const std::string& buddyUri,
+                              const bool& status, const std::string& lineStatus)
+{}
+
+void
+PresenceManager::subscriptionStateChanged(const std::string& accountID, const std::string& buddyUri,
+                              const bool& state)
+{}
+
+void
+PresenceManager::newServerSubscriptionRequest(const std::string& remote)
+{}
+
+void
+PresenceManager::serverError(const std::string& accountID, const std::string& error, const std::string& msg)
+{}
diff --git a/sflphone-android/jni/sflphoneservice.c.template b/sflphone-android/jni/sflphoneservice.c.template
new file mode 100644
index 0000000..f409e3f
--- /dev/null
+++ b/sflphone-android/jni/sflphoneservice.c.template
@@ -0,0 +1,73 @@
+#include "logger.h"
+
+JavaVM *gJavaVM;
+const char *ksflphoneservicePath = "org/sflphone/service/SFLPhoneserviceJNI";
+
+void deinitClassHelper(JNIEnv *env, jobject obj) {
+	INFO("deinitClassHelper");
+
+	/* delete cached object instances */
+    env->DeleteGlobalRef(obj);
+	INFO("deinitClassHelper: object %x deleted", obj);
+}
+
+JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
+	JNIEnv *env;
+	jclass clazz;
+	jint r;
+
+    INFO("JNI_OnLoad");
+
+	//Assume it is c++
+	r = vm->GetEnv ((void **) &env, JNI_VERSION_1_6);
+    if (r != JNI_OK) {
+		ERROR("JNI_OnLoad: failed to get the environment using GetEnv()");
+        return -1;
+    }
+	INFO("JNI_Onload: GetEnv %p", env);
+
+	clazz = env->FindClass (ksflphoneservicePath);
+	if (!clazz) {
+        ERROR("JNI_Onload: whoops, %s class not found!", ksflphoneservicePath);
+	}
+	gJavaVM = vm;
+	INFO("JNI_Onload: JavaVM %p", gJavaVM);
+
+	/* put instances of class object we need into cache */
+    //initClassHelper(env, kManagerPath, &gManagerObject);
+
+	JNINativeMethod methods[] = {
+
+	$defs
+
+	};
+
+	r = env->RegisterNatives (clazz, methods, (int) (sizeof(methods) / sizeof(methods[0])));
+	return JNI_VERSION_1_6;
+}
+
+void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
+    JNIEnv* env;
+	jclass clazz;
+
+	INFO("JNI_OnUnLoad");
+
+	/* get env */
+    if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
+		ERROR("JNI_OnUnLoad: failed to get the environment using GetEnv()");
+        return;
+    }
+	INFO("JNI_OnUnLoad: GetEnv %p", env);
+
+    /* Get jclass with env->FindClass */
+	clazz = env->FindClass(ksflphoneservicePath);
+	if (!clazz) {
+        ERROR("JNI_OnUnLoad: whoops, %s class not found!", ksflphoneservicePath);
+	}
+
+	/* remove instances of class object we need into cache */
+    //deinitClassHelper(env, gManagerObject);
+
+	env->UnregisterNatives(clazz);
+	INFO("JNI_OnUnLoad: Native functions unregistered");
+}
diff --git a/sflphone-android/make-swig.sh b/sflphone-android/make-swig.sh
index 1410dc0..dbaf206 100755
--- a/sflphone-android/make-swig.sh
+++ b/sflphone-android/make-swig.sh
@@ -83,9 +83,6 @@
     exit 3
 fi
 
-
-
-
 # FIXME
 echo "Generating callmanager_wrap.cpp..."