Use new API in SipService

Still some issues about static/virtual declarations of methods for
Callback and ConfigurationCallback generated files.
diff --git a/sflphone-android/src/org/sflphone/model/SecureSipCall.java b/sflphone-android/src/org/sflphone/model/SecureSipCall.java
index 58c04bb..df0163e 100644
--- a/sflphone-android/src/org/sflphone/model/SecureSipCall.java
+++ b/sflphone-android/src/org/sflphone/model/SecureSipCall.java
@@ -110,7 +110,7 @@
         }
     };
 
-    public void sasConfirmedByZrtpLayer(boolean verified) {
+    public void sasConfirmedByZrtpLayer(int verified) {
         // Not used
     }
 
diff --git a/sflphone-android/src/org/sflphone/service/CallManagerCallBack.java b/sflphone-android/src/org/sflphone/service/CallManagerCallBack.java
index df5dc38..77677fc 100644
--- a/sflphone-android/src/org/sflphone/service/CallManagerCallBack.java
+++ b/sflphone-android/src/org/sflphone/service/CallManagerCallBack.java
@@ -3,13 +3,11 @@
 import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
-import org.sflphone.account.AccountDetailSrtp;
 import org.sflphone.client.CallActivity;
 import org.sflphone.model.*;
 import org.sflphone.utils.SwigNativeConverter;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.Map;
 
 public class CallManagerCallBack extends Callback {
@@ -39,7 +37,7 @@
     }
 
     @Override
-    public void on_call_state_changed(String callID, String newState) {
+    public void callOnStateChange(String callID, String newState) {
         Log.d(TAG, "on_call_state_changed : (" + callID + ", " + newState + ")");
 
         Conference toUpdate = mService.findConference(callID);
@@ -79,7 +77,7 @@
         } else if (newState.equals("FAILURE")) {
             toUpdate.setCallState(callID, SipCall.state.CALL_STATE_FAILURE);
             mService.getConferences().remove(toUpdate.getId());
-            mService.getCallManagerJNI().hangUp(callID);
+            SFLPhoneservice.sflph_call_hang_up(callID);
         } else if (newState.equals("HOLD")) {
             toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HOLD);
         } else if (newState.equals("UNHOLD")) {
@@ -91,12 +89,12 @@
 
 
     @Override
-    public void on_incoming_call(String accountID, String callID, String from) {
+    public void callOnIncomingCall(String accountID, String callID, String from) {
         Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")");
 
         try {
-            StringMap details = mService.getConfigurationManagerJNI().getAccountDetails(accountID);
-            VectMap credentials = mService.getConfigurationManagerJNI().getCredentials(accountID);
+            StringMap details = SFLPhoneservice.sflph_config_get_account_details(accountID);
+            VectMap credentials = SFLPhoneservice.sflph_config_get_credentials(accountID);
             Account acc = new Account(accountID, SwigNativeConverter.convertAccountToNative(details), SwigNativeConverter.convertCredentialsToNative(credentials));
 
             Bundle args = new Bundle();
@@ -137,26 +135,20 @@
     }
 
     @Override
-    public void on_transfer_state_changed(String result) {
-        Log.w(TAG, "TRANSFER STATE CHANGED:" + result);
-    }
-
-    @Override
-    public void on_conference_created(final String confID) {
+    public void callOnConferenceCreated(final String confID) {
         Log.w(TAG, "CONFERENCE CREATED:" + confID);
         Intent intent = new Intent(CONF_CREATED);
         Conference created = new Conference(confID);
 
-        StringVect all_participants = mService.getCallManagerJNI().getParticipantList(confID);
+        StringVect all_participants = SFLPhoneservice.sflph_call_get_participant_list(confID);
         Log.w(TAG, "all_participants:" + all_participants.size());
         for (int i = 0; i < all_participants.size(); ++i) {
             if (mService.getConferences().get(all_participants.get(i)) != null) {
                 created.addParticipant(mService.getConferences().get(all_participants.get(i)).getCallById(all_participants.get(i)));
                 mService.getConferences().remove(all_participants.get(i));
             } else {
-                Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator();
-                while (it.hasNext()) {
-                    Conference tmp = it.next().getValue();
+                for (Map.Entry<String, Conference> stringConferenceEntry : mService.getConferences().entrySet()) {
+                    Conference tmp = stringConferenceEntry.getValue();
                     for (SipCall c : tmp.getParticipants()) {
                         if (c.getCallId().contentEquals(all_participants.get(i))) {
                             created.addParticipant(c);
@@ -173,7 +165,7 @@
     }
 
     @Override
-    public void on_incoming_message(String ID, String from, String msg) {
+    public void callOnIncomingMessage(String ID, String from, String msg) {
         Log.w(TAG, "on_incoming_message:" + msg);
         Intent intent = new Intent(INCOMING_TEXT);
         intent.putExtra("CallID", ID);
@@ -184,9 +176,8 @@
             mService.getConferences().get(ID).addSipMessage(new SipMessage(true, msg));
             intent.putExtra("conference", mService.getConferences().get(ID));
         } else {
-            Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator();
-            while (it.hasNext()) {
-                Conference tmp = it.next().getValue();
+            for (Map.Entry<String, Conference> stringConferenceEntry : mService.getConferences().entrySet()) {
+                Conference tmp = stringConferenceEntry.getValue();
                 for (SipCall c : tmp.getParticipants()) {
                     if (c.getCallId().contentEquals(ID)) {
                         mService.getConferences().get(tmp.getId()).addSipMessage(new SipMessage(true, msg));
@@ -200,7 +191,7 @@
     }
 
     @Override
-    public void on_conference_removed(String confID) {
+    public void callOnConferenceRemove(String confID) {
         Log.i(TAG, "on_conference_removed:");
         Intent intent = new Intent(CONF_REMOVED);
         intent.putExtra("confID", confID);
@@ -216,7 +207,7 @@
     }
 
     @Override
-    public void on_conference_state_changed(String confID, String state) {
+    public void callOnConferenceChanged(String confID, String state) {
         Log.i(TAG, "on_conference_state_changed:");
         Intent intent = new Intent(CONF_CHANGED);
         intent.putExtra("confID", confID);
@@ -229,13 +220,13 @@
         Conference toModify = mService.getConferences().get(confID);
         toModify.setCallState(confID, state);
 
-        ArrayList<String> newParticipants = SwigNativeConverter.convertSwigToNative(mService.getCallManagerJNI().getParticipantList(intent.getStringExtra("confID")));
+        ArrayList<String> newParticipants = SwigNativeConverter.convertSwigToNative(SFLPhoneservice.sflph_call_get_participant_list(intent.getStringExtra("confID")));
 
         if (toModify.getParticipants().size() < newParticipants.size()) {
             // We need to add the new participant to the conf
-            for (int i = 0; i < newParticipants.size(); ++i) {
-                if (toModify.getCallById(newParticipants.get(i)) == null) {
-                    mService.addCallToConference(toModify.getId(), newParticipants.get(i));
+            for (String newParticipant : newParticipants) {
+                if (toModify.getCallById(newParticipant) == null) {
+                    mService.addCallToConference(toModify.getId(), newParticipant);
                 }
             }
         } else if (toModify.getParticipants().size() > newParticipants.size()) {
@@ -252,15 +243,15 @@
     }
 
     @Override
-    public void on_record_playback_filepath(String id, String filename) {
-        Intent intent = new Intent(RECORD_STATE_CHANGED);
+    public void callOnRecordPlaybackFilepath(String id, String filename) {
+        Intent intent = new Intent();
         intent.putExtra("callID", id);
         intent.putExtra("file", filename);
         mService.sendBroadcast(intent);
     }
 
     @Override
-    public void on_secure_sdes_on(String callID) {
+    public void callOnSecureSdesOn(String callID) {
         Log.i(TAG, "on_secure_sdes_on");
         SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
         call.setInitialized();
@@ -268,7 +259,7 @@
     }
 
     @Override
-    public void on_secure_sdes_off(String callID) {
+    public void callOnSecureSdesOff(String callID) {
         Log.i(TAG, "on_secure_sdes_off");
         SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
         call.setInitialized();
@@ -276,7 +267,7 @@
     }
 
     @Override
-    public void on_secure_zrtp_on(String callID, String cipher) {
+    public void callOnSecureZrtpOn(String callID, String cipher) {
         Log.i(TAG, "on_secure_zrtp_on");
         Intent intent = new Intent(ZRTP_ON);
         SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
@@ -288,7 +279,7 @@
     }
 
     @Override
-    public void on_secure_zrtp_off(String callID) {
+    public void callOnSecureZrtpOff(String callID) {
         Log.i(TAG, "on_secure_zrtp_off");
         Intent intent = new Intent(ZRTP_OFF);
         intent.putExtra("callID", callID);
@@ -304,7 +295,7 @@
     }
 
     @Override
-    public void on_show_sas(String callID, String sas, boolean verified) {
+    public void callOnShowSas(String callID, String sas, int verified) {
         Log.i(TAG, "on_show_sas:" + sas);
         Intent intent = new Intent(DISPLAY_SAS);
         SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
@@ -319,7 +310,7 @@
     }
 
     @Override
-    public void on_zrtp_not_supported(String callID) {
+    public void callOnZrtpNotSuppOther(String callID) {
         Log.i(TAG, "on_zrtp_not_supported");
         Intent intent = new Intent(ZRTP_NOT_SUPPORTED);
         SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
@@ -331,7 +322,7 @@
     }
 
     @Override
-    public void on_zrtp_negociation_failed(String callID, String reason, String severity) {
+    public void callOnZrtpNegotiationFail(String callID, String reason, String severity) {
         Log.i(TAG, "on_zrtp_negociation_failed");
         Intent intent = new Intent(ZRTP_NEGOTIATION_FAILED);
         SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
@@ -343,7 +334,7 @@
     }
 
     @Override
-    public void on_rtcp_report_received(String callID, IntegerMap stats) {
+    public void callOnRtcpReceiveReport(String callID, IntegerMap stats) {
         Log.i(TAG, "on_rtcp_report_received");
         Intent intent = new Intent(RTCP_REPORT_RECEIVED);
         mService.sendBroadcast(intent);
diff --git a/sflphone-android/src/org/sflphone/service/ConfigurationManagerCallback.java b/sflphone-android/src/org/sflphone/service/ConfigurationManagerCallback.java
index 77c157c..e3370ea 100644
--- a/sflphone-android/src/org/sflphone/service/ConfigurationManagerCallback.java
+++ b/sflphone-android/src/org/sflphone/service/ConfigurationManagerCallback.java
@@ -23,10 +23,12 @@
 package org.sflphone.service;
 
 import android.content.Intent;
+import android.util.Log;
 
 public class ConfigurationManagerCallback extends ConfigurationCallback {
 
     private  SipService mService;
+    private static final String TAG = "ConfigurationManagerCallback";
 
     static public final String ACCOUNTS_CHANGED = "accounts-changed";
     static public final String ACCOUNT_STATE_CHANGED = "account-state-changed";
@@ -36,12 +38,24 @@
     }
 
     @Override
-    public void on_accounts_changed() {
-        sendAccountsChangedMessage();
+    public void configOnVolumeChange(String device, int value) {
+        super.configOnVolumeChange(device, value);
     }
 
     @Override
-    public void on_account_state_changed(String accoundID, int state) {
+    public void configOnAccountsChange() {
+        super.configOnAccountsChange();
+        Intent intent = new Intent(ACCOUNTS_CHANGED);
+        mService.sendBroadcast(intent);
+    }
+
+    @Override
+    public void configOnStunStatusFail(String account_id) {
+        Log.d(TAG, "configOnStunStatusFail : (" + account_id);
+    }
+
+    @Override
+    public void configOnRegistrationStateChange(String accoundID, int state) {
         String strState = "";
         switch (state){
         case 0:
@@ -77,15 +91,20 @@
         }
         
 
-        sendAccountsStateChangedMessage(accoundID, strState, 0);
-    }
-    
-    @Override
-    public void on_account_state_changed_with_code(String accoundID, String state, int code) {
-//        sendAccountsStateChangedMessage(accoundID, state, code);
+        sendAccountStateChangedMessage(accoundID, strState, 0);
     }
 
-    private void sendAccountsStateChangedMessage(String accoundID, String state, int code) {
+    @Override
+    public void configOnSipRegistrationStateChange(String account_id, String state, int code) {
+        Log.d(TAG, "configOnSipRegistrationStateChange : (" + account_id);
+    }
+
+    @Override
+    public void configOnError(int alert) {
+        Log.d(TAG, "configOnError : (" + alert);
+    }
+
+    private void sendAccountStateChangedMessage(String accoundID, String state, int code) {
         Intent intent = new Intent(ACCOUNT_STATE_CHANGED);
         intent.putExtra("Account", accoundID);
         intent.putExtra("state", state);
@@ -93,12 +112,7 @@
         mService.sendBroadcast(intent);
     }
 
-    private void sendAccountsChangedMessage() {
-        Intent intent = new Intent(ACCOUNTS_CHANGED);
-        mService.sendBroadcast(intent);
-    }
-
-    public IntVect get_hardware_audio_format(){
+    public IntVect configGetHardwareAudioFormat(){
         IntVect result = new IntVect();
 
         OpenSlParams audioParams = OpenSlParams.createInstance(mService);
diff --git a/sflphone-android/src/org/sflphone/service/ISipService.aidl b/sflphone-android/src/org/sflphone/service/ISipService.aidl
index 5cab757..1ec5664 100644
--- a/sflphone-android/src/org/sflphone/service/ISipService.aidl
+++ b/sflphone-android/src/org/sflphone/service/ISipService.aidl
@@ -27,7 +27,6 @@
     void setAudioPlugin(in String callID);
     String getCurrentAudioOutputPlugin();
     List getAudioCodecList(in String accountID);
-    String getCurrentAudioCodecName(in String callID);
     void setActiveCodecList(in List codecs, in String accountID);
     Map getRingtoneList();
 
diff --git a/sflphone-android/src/org/sflphone/service/SipService.java b/sflphone-android/src/org/sflphone/service/SipService.java
index ebc46cc..75ecae2 100644
--- a/sflphone-android/src/org/sflphone/service/SipService.java
+++ b/sflphone-android/src/org/sflphone/service/SipService.java
@@ -24,30 +24,18 @@
  */
 package org.sflphone.service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.sflphone.account.AccountDetailSrtp;
+import android.app.Service;
+import android.content.Intent;
+import android.os.*;
+import android.util.Log;
 import org.sflphone.history.HistoryManager;
 import org.sflphone.model.*;
 import org.sflphone.utils.MediaManager;
 import org.sflphone.utils.SipNotifications;
 import org.sflphone.utils.SwigNativeConverter;
 
-import android.app.Service;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.IBinder;
-import android.os.Looper;
-import android.os.Message;
-import android.os.RemoteException;
-import android.util.Log;
+import java.util.*;
+import java.util.Map.Entry;
 
 public class SipService extends Service {
 
@@ -55,12 +43,6 @@
     private SipServiceExecutor mExecutor;
     private static HandlerThread executorThread;
 
-    private CallManager callManagerJNI;
-    private ManagerImpl managerImpl;
-    private CallManagerCallBack callManagerCallBack;
-
-    private ConfigurationManager configurationManagerJNI;
-    private ConfigurationManagerCallback configurationManagerCallback;
     private boolean isPjSipStackStarted = false;
 
     protected SipNotifications mNotificationManager;
@@ -73,14 +55,6 @@
         return mConferences;
     }
 
-    public CallManager getCallManagerJNI() {
-        return callManagerJNI;
-    }
-
-    public ConfigurationManager getConfigurationManagerJNI() {
-        return configurationManagerJNI;
-    }
-
     public void addCallToConference(String confId, String callId) {
         if(mConferences.get(callId) != null){
             // We add a simple call to a conference
@@ -89,9 +63,8 @@
             mConferences.remove(callId);
         } else {
             Log.i(TAG, "addCallToConference");
-            Iterator<Map.Entry<String, Conference>> it = mConferences.entrySet().iterator();
-            while (it.hasNext()) {
-                Conference tmp = it.next().getValue();
+            for (Entry<String, Conference> stringConferenceEntry : mConferences.entrySet()) {
+                Conference tmp = stringConferenceEntry.getValue();
                 for (SipCall c : tmp.getParticipants()) {
                     if (c.getCallId().contentEquals(callId)) {
                         mConferences.get(confId).addParticipant(c);
@@ -188,12 +161,11 @@
             return getConferences().get(callID).getCallById(callID);
         } else {
             // Check if call is in a conference
-            Iterator<Map.Entry<String, Conference>> it = getConferences().entrySet().iterator();
-            while (it.hasNext()) {
-                Conference tmp = it.next().getValue();
+            for (Entry<String, Conference> stringConferenceEntry : getConferences().entrySet()) {
+                Conference tmp = stringConferenceEntry.getValue();
                 SipCall c = tmp.getCallById(callID);
-                if(c != null)
-                     return c;
+                if (c != null)
+                    return c;
             }
         }
         return null;
@@ -232,10 +204,8 @@
     }
 
     private void stopDaemon() {
-        if (managerImpl != null) {
-            managerImpl.finish();
-            isPjSipStackStarted = false;
-        }
+        SFLPhoneservice.sflph_fini();
+        isPjSipStackStarted = false;
     }
 
     private void startPjSipStack() throws SameThreadException {
@@ -259,11 +229,8 @@
         }
 
         Log.i(TAG, "PjSIPStack started");
-        managerImpl = SFLPhoneservice.instance();
 
-        callManagerJNI = new CallManager();
-        configurationManagerJNI = new ConfigurationManager();
-        managerImpl.init("");
+        SFLPhoneservice.init(new ConfigurationCallback(), new CallManagerCallBack(this));
 
         Log.i(TAG, "->startPjSipStack");
     }
@@ -359,7 +326,7 @@
                     }
                     mConferences.put(toAdd.getId(), toAdd);
                     mMediaManager.obtainAudioFocus(false);
-                    callManagerJNI.placeCall(call.getAccount().getAccountID(), call.getCallId(), call.getmContact().getPhones().get(0).getNumber());
+                    SFLPhoneservice.sflph_call_place(call.getAccount().getAccountID(), call.getCallId(), call.getmContact().getPhones().get(0).getNumber());
                 }
             });
         }
@@ -371,7 +338,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.refuse() thread running...");
-                    callManagerJNI.refuse(callID);
+                    SFLPhoneservice.sflph_call_refuse(callID);
                 }
             });
         }
@@ -383,7 +350,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.accept() thread running...");
-                    callManagerJNI.accept(callID);
+                    SFLPhoneservice.sflph_call_accept(callID);
                     mMediaManager.RouteToInternalSpeaker();
                 }
             });
@@ -397,7 +364,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.hangUp() thread running...");
-                    callManagerJNI.hangUp(callID);
+                    SFLPhoneservice.sflph_call_hang_up(callID);
                     removeCall(callID);
                     if(mConferences.size() == 0) {
                         Log.i(TAG, "No more calls!");
@@ -413,7 +380,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.hold() thread running...");
-                    callManagerJNI.hold(callID);
+                    SFLPhoneservice.sflph_call_hold(callID);
                 }
             });
         }
@@ -424,7 +391,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.unhold() thread running...");
-                    callManagerJNI.unhold(callID);
+                    SFLPhoneservice.sflph_call_unhold(callID);
                 }
             });
         }
@@ -441,7 +408,7 @@
                 @Override
                 protected StringMap doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getCallDetails() thread running...");
-                    return callManagerJNI.getCallDetails(id);
+                    return SFLPhoneservice.sflph_call_get_call_details(id);
                 }
             }
 
@@ -452,9 +419,7 @@
             }
             StringMap swigmap = (StringMap) runInstance.getVal();
 
-            HashMap<String, String> nativemap = SwigNativeConverter.convertCallDetailsToNative(swigmap);
-
-            return nativemap;
+            return SwigNativeConverter.convertCallDetailsToNative(swigmap);
 
         }
 
@@ -464,7 +429,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.setAudioPlugin() thread running...");
-                    configurationManagerJNI.setAudioPlugin(audioPlugin);
+                    SFLPhoneservice.sflph_config_set_audio_plugin(audioPlugin);
                 }
             });
         }
@@ -475,11 +440,9 @@
                 @Override
                 protected String doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getCurrentAudioOutputPlugin() thread running...");
-                    return configurationManagerJNI.getCurrentAudioOutputPlugin();
+                    return SFLPhoneservice.sflph_config_get_current_audio_output_plugin();
                 }
             }
-            ;
-
             CurrentAudioPlugin runInstance = new CurrentAudioPlugin();
             getExecutor().execute(runInstance);
             while (!runInstance.isDone()) {
@@ -494,7 +457,7 @@
                 @Override
                 protected StringVect doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getAccountList() thread running...");
-                    return configurationManagerJNI.getAccountList();
+                    return SFLPhoneservice.sflph_config_get_account_list();
                 }
             }
             AccountList runInstance = new AccountList();
@@ -517,7 +480,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.setAccountsOrder() thread running...");
-                    configurationManagerJNI.setAccountsOrder(order);
+                    SFLPhoneservice.sflph_config_set_accounts_order(order);
                 }
             });
         }
@@ -534,7 +497,7 @@
                 @Override
                 protected StringMap doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getAccountDetails() thread running...");
-                    return configurationManagerJNI.getAccountDetails(id);
+                    return SFLPhoneservice.sflph_config_get_account_details(id);
                 }
             }
 
@@ -545,9 +508,7 @@
             }
             StringMap swigmap = (StringMap) runInstance.getVal();
 
-            HashMap<String, String> nativemap = SwigNativeConverter.convertAccountToNative(swigmap);
-
-            return nativemap;
+            return SwigNativeConverter.convertAccountToNative(swigmap);
         }
 
         @SuppressWarnings("unchecked")
@@ -562,7 +523,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
 
-                    configurationManagerJNI.setAccountDetails(accountId, swigmap);
+                    SFLPhoneservice.sflph_config_set_account_details(accountId, swigmap);
                     Log.i(TAG, "SipService.setAccountDetails() thread running...");
                 }
 
@@ -576,7 +537,7 @@
                 @Override
                 protected StringMap doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getAccountTemplate() thread running...");
-                    return configurationManagerJNI.getAccountTemplate();
+                    return SFLPhoneservice.sflph_config_get_account_template();
                 }
             }
 
@@ -606,7 +567,7 @@
                 @Override
                 protected String doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.addAccount() thread running...");
-                    return configurationManagerJNI.addAccount(map);
+                    return SFLPhoneservice.sflph_config_add_account(map);
                 }
             }
 
@@ -616,9 +577,8 @@
             getExecutor().execute(runInstance);
             while (!runInstance.isDone()) {
             }
-            String accountId = (String) runInstance.getVal();
 
-            return accountId;
+            return (String) runInstance.getVal();
         }
 
         @Override
@@ -627,7 +587,7 @@
                 @Override
                 protected void doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.setAccountDetails() thread running...");
-                    configurationManagerJNI.removeAccount(accountId);
+                    SFLPhoneservice.sflph_config_remove_account(accountId);
                 }
             });
         }
@@ -642,7 +602,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.transfer() thread running...");
-                    if (callManagerJNI.transfer(callID, to)) {
+                    if (SFLPhoneservice.sflph_call_transfer(callID, to)) {
                         Bundle bundle = new Bundle();
                         bundle.putString("CallID", callID);
                         bundle.putString("State", "HUNGUP");
@@ -662,7 +622,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.attendedTransfer() thread running...");
-                    if (callManagerJNI.attendedTransfer(transferID, targetID)) {
+                    if (SFLPhoneservice.sflph_call_attended_transfer(transferID, targetID)) {
                         Log.i(TAG, "OK");
                     } else
                         Log.i(TAG, "NOT OK");
@@ -681,7 +641,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.createConference() thread running...");
-                    callManagerJNI.removeConference(confID);
+                    SFLPhoneservice.sflph_call_remove_conference(confID);
                 }
             });
 
@@ -693,7 +653,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.joinParticipant() thread running...");
-                    callManagerJNI.joinParticipant(sel_callID, drag_callID);
+                    SFLPhoneservice.sflph_call_join_participant(sel_callID, drag_callID);
                     // Generate a CONF_CREATED callback
                 }
             });
@@ -706,7 +666,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.addParticipant() thread running...");
-                    callManagerJNI.addParticipant(call.getCallId(), confID);
+                    SFLPhoneservice.sflph_call_add_participant(call.getCallId(), confID);
                     mConferences.get(confID).getParticipants().add(call);
                 }
             });
@@ -719,7 +679,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.addMainParticipant() thread running...");
-                    callManagerJNI.addMainParticipant(confID);
+                    SFLPhoneservice.sflph_call_add_main_participant(confID);
                 }
             });
 
@@ -743,7 +703,7 @@
                             Log.i(TAG, "Call found and put in current_calls");
                         }
                     }
-                    callManagerJNI.detachParticipant(callID);
+                    SFLPhoneservice.sflph_call_detach_participant(callID);
                 }
             });
 
@@ -755,7 +715,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.joinConference() thread running...");
-                    callManagerJNI.joinConference(sel_confID, drag_confID);
+                    SFLPhoneservice.sflph_call_join_conference(sel_confID, drag_confID);
                 }
             });
 
@@ -768,7 +728,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.joinConference() thread running...");
-                    callManagerJNI.hangUpConference(confID);
+                    SFLPhoneservice.sflph_call_hang_up_conference(confID);
                 }
             });
 
@@ -780,7 +740,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.holdConference() thread running...");
-                    callManagerJNI.holdConference(confID);
+                    SFLPhoneservice.sflph_call_hold_conference(confID);
                 }
             });
 
@@ -792,7 +752,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.unholdConference() thread running...");
-                    callManagerJNI.unholdConference(confID);
+                    SFLPhoneservice.sflph_call_unhold_conference(confID);
                 }
             });
 
@@ -805,7 +765,7 @@
                 @Override
                 protected Boolean doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.isRecording() thread running...");
-                    return callManagerJNI.isConferenceParticipant(callID);
+                    return SFLPhoneservice.sflph_call_is_conference_participant(callID);
                 }
             }
 
@@ -849,7 +809,7 @@
                 @Override
                 protected StringVect doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getParticipantList() thread running...");
-                    return callManagerJNI.getParticipantList(confID);
+                    return SFLPhoneservice.sflph_call_get_participant_list(confID);
                 }
             }
             ;
@@ -880,10 +840,9 @@
                 @Override
                 protected StringMap doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getConferenceDetails() thread running...");
-                    return callManagerJNI.getConferenceDetails(callID);
+                    return SFLPhoneservice.sflph_call_get_conference_details(callID);
                 }
             }
-            ;
             ConfDetails runInstance = new ConfDetails();
             getExecutor().execute(runInstance);
             while (!runInstance.isDone()) {
@@ -901,7 +860,7 @@
                 @Override
                 protected String doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getRecordPath() thread running...");
-                    return configurationManagerJNI.getRecordPath();
+                    return SFLPhoneservice.sflph_config_get_record_path();
                 }
             }
 
@@ -910,9 +869,8 @@
             while (!runInstance.isDone()) {
                 // Log.w(TAG, "Waiting for getRecordPath");
             }
-            String path = (String) runInstance.getVal();
 
-            return path;
+            return (String) runInstance.getVal();
         }
 
         @Override
@@ -923,14 +881,12 @@
                 @Override
                 protected Boolean doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.toggleRecordingCall() thread running...");
-                    boolean result = callManagerJNI.toggleRecording(id);
+                    boolean result = SFLPhoneservice.sflph_call_toggle_recording(id);
 
                     if (getConferences().containsKey(id)) {
                         getConferences().get(id).setRecording(result);
                     } else {
-                        Iterator<Conference> it = getConferences().values().iterator();
-                        while (it.hasNext()) {
-                            Conference c = it.next();
+                        for (Conference c : getConferences().values()) {
                             if (c.getCallById(id) != null)
                                 c.getCallById(id).setRecording(result);
                         }
@@ -954,7 +910,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.setRecordingCall() thread running...");
-                    callManagerJNI.startRecordedFilePlayback(filepath);
+                    SFLPhoneservice.sflph_call_play_recorded_file(filepath);
                 }
             });
             return false;
@@ -966,7 +922,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.stopRecordedFilePlayback() thread running...");
-                    callManagerJNI.stopRecordedFilePlayback(filepath);
+                    SFLPhoneservice.sflph_call_stop_recorded_file(filepath);
                 }
             });
         }
@@ -977,7 +933,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.setRecordPath() " + path + " thread running...");
-                    configurationManagerJNI.setRecordPath(path);
+                    SFLPhoneservice.sflph_config_set_record_path(path);
                 }
             });
         }
@@ -988,7 +944,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.sendTextMessage() thread running...");
-                    callManagerJNI.sendTextMessage(callID, message.comment);
+                    SFLPhoneservice.sflph_call_send_text_message(callID, message.comment);
                     if (getConferences().get(callID) != null)
                         getConferences().get(callID).addSipMessage(message);
                 }
@@ -1005,13 +961,13 @@
                     Log.i(TAG, "SipService.getAudioCodecList() thread running...");
                     ArrayList<Codec> results = new ArrayList<Codec>();
 
-                    IntVect active_payloads = configurationManagerJNI.getActiveAudioCodecList(accountID);
+                    IntVect active_payloads = SFLPhoneservice.sflph_config_get_active_audio_codec_list(accountID);
                     for (int i = 0; i < active_payloads.size(); ++i) {
 
-                        results.add(new Codec(active_payloads.get(i), configurationManagerJNI.getAudioCodecDetails(active_payloads.get(i)), true));
+                        results.add(new Codec(active_payloads.get(i), SFLPhoneservice.sflph_config_get_audio_codec_details(active_payloads.get(i)), true));
 
                     }
-                    IntVect payloads = configurationManagerJNI.getAudioCodecList();
+                    IntVect payloads = SFLPhoneservice.sflph_config_get_audio_codec_list();
 
                     for (int i = 0; i < payloads.size(); ++i) {
                         boolean isActive = false;
@@ -1023,7 +979,7 @@
                         if (isActive)
                             continue;
                         else
-                            results.add(new Codec(payloads.get(i), configurationManagerJNI.getAudioCodecDetails(payloads.get(i)), false));
+                            results.add(new Codec(payloads.get(i), SFLPhoneservice.sflph_config_get_audio_codec_details(payloads.get(i)), false));
 
                     }
 
@@ -1035,8 +991,7 @@
             getExecutor().execute(runInstance);
             while (!runInstance.isDone()) {
             }
-            ArrayList<Codec> codecs = (ArrayList<Codec>) runInstance.getVal();
-            return codecs;
+            return (ArrayList<Codec>) runInstance.getVal();
         }
 
         @Override
@@ -1046,7 +1001,7 @@
                 @Override
                 protected StringMap doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getRingtoneList() thread running...");
-                    return configurationManagerJNI.getRingtoneList();
+                    return SFLPhoneservice.sflph_config_get_ringtone_list();
                 }
             }
 
@@ -1070,7 +1025,7 @@
                 @Override
                 protected Boolean doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.isCaptureMuted() thread running...");
-                    return configurationManagerJNI.checkForPrivateKey(pemPath);
+                    return SFLPhoneservice.sflph_config_check_for_private_key(pemPath);
                 }
             }
 
@@ -1089,7 +1044,7 @@
                 @Override
                 protected Boolean doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.isCaptureMuted() thread running...");
-                    return configurationManagerJNI.checkCertificateValidity(pemPath,pemPath);
+                    return SFLPhoneservice.sflph_config_check_certificate_validity(pemPath, pemPath);
                 }
             }
 
@@ -1108,7 +1063,7 @@
                 @Override
                 protected Boolean doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.isCaptureMuted() thread running...");
-                    return configurationManagerJNI.checkHostnameCertificate(host, port);
+                    return SFLPhoneservice.sflph_config_check_hostname_certificate(host, port);
                 }
             }
 
@@ -1127,10 +1082,10 @@
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.setActiveAudioCodecList() thread running...");
                     StringVect list = new StringVect();
-                    for (int i = 0; i < codecs.size(); ++i) {
-                        list.add((String) codecs.get(i));
+                    for (Object codec : codecs) {
+                        list.add((String) codec);
                     }
-                    configurationManagerJNI.setActiveAudioCodecList(list, accountID);
+                    SFLPhoneservice.sflph_config_set_active_audio_codec_list(list, accountID);
                 }
             });
         }
@@ -1157,7 +1112,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.playDtmf() thread running...");
-                    callManagerJNI.playDTMF(key);
+                    SFLPhoneservice.sflph_call_play_dtmf(key);
                 }
             });
         }
@@ -1173,17 +1128,12 @@
         }
 
         @Override
-        public String getCurrentAudioCodecName(String callID) throws RemoteException {
-            return callManagerJNI.getCurrentAudioCodecName(callID);
-        }
-
-        @Override
         public void setMuted(final boolean mute) throws RemoteException {
             getExecutor().execute(new SipRunnable() {
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.setMuted() thread running...");
-                    configurationManagerJNI.muteCapture(mute);
+                    SFLPhoneservice.sflph_config_mute_capture(mute);
                 }
             });
         }
@@ -1195,7 +1145,7 @@
                 @Override
                 protected Boolean doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.isCaptureMuted() thread running...");
-                    return configurationManagerJNI.isCaptureMuted();
+                    return SFLPhoneservice.sflph_config_is_capture_muted();
                 }
             }
 
@@ -1215,7 +1165,7 @@
                     Log.i(TAG, "SipService.confirmSAS() thread running...");
                     SecureSipCall call = (SecureSipCall) getCallById(callID);
                     call.setSASConfirmed(true);
-                    callManagerJNI.setSASVerified(callID);
+                    SFLPhoneservice.sflph_call_set_sas_verified(callID);
                 }
             });
         }
@@ -1228,9 +1178,8 @@
                 @Override
                 protected List doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getCredentials() thread running...");
-                    StringVect map = configurationManagerJNI.getSupportedTlsMethod();
-                    ArrayList<String> result = SwigNativeConverter.convertSwigToNative(map);
-                    return result;
+                    StringVect map = SFLPhoneservice.sflph_config_get_supported_tls_method();
+                    return SwigNativeConverter.convertSwigToNative(map);
                 }
             }
 
@@ -1248,9 +1197,8 @@
                 @Override
                 protected List doRun() throws SameThreadException {
                     Log.i(TAG, "SipService.getCredentials() thread running...");
-                    VectMap map = configurationManagerJNI.getCredentials(accountID);
-                    ArrayList<HashMap<String, String>> result = SwigNativeConverter.convertCredentialsToNative(map);
-                    return result;
+                    VectMap map = SFLPhoneservice.sflph_config_get_credentials(accountID);
+                    return SwigNativeConverter.convertCredentialsToNative(map);
                 }
             }
 
@@ -1268,7 +1216,7 @@
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.setCredentials() thread running...");
                     ArrayList<HashMap<String, String>> list = (ArrayList<HashMap<String, String>>) creds;
-                    configurationManagerJNI.setCredentials(accountID, SwigNativeConverter.convertFromNativeToSwig(creds));
+                    SFLPhoneservice.sflph_config_set_credentials(accountID, SwigNativeConverter.convertFromNativeToSwig(creds));
                 }
             });
         }
@@ -1279,7 +1227,7 @@
                 @Override
                 protected void doRun() throws SameThreadException, RemoteException {
                     Log.i(TAG, "SipService.registerAllAccounts() thread running...");
-                    configurationManagerJNI.registerAllAccounts();
+                    SFLPhoneservice.sflph_config_register_all_accounts();
                 }
             });
         }