Index: pjproject/trunk/pjsip-apps/src/pocketpj/SettingsDlg.cpp
===================================================================
--- pjproject/trunk/pjsip-apps/src/pocketpj/SettingsDlg.cpp	(revision 2201)
+++ pjproject/trunk/pjsip-apps/src/pocketpj/SettingsDlg.cpp	(revision 2211)
@@ -5,4 +5,5 @@
 #include "PocketPJ.h"
 #include "SettingsDlg.h"
+#include <pjsua-lib/pjsua.h>
 #include <atlbase.h>
 
@@ -27,4 +28,9 @@
 #define REG_ENABLE_EC	_T("EnableEC")
 #define REG_EC_TAIL	_T("ECTail")
+#define REG_ENABLE_VAD	_T("EnableVAD")
+#define REG_ENABLE_TCP	_T("EnableTCP")
+#define REG_CODEC_CNT	_T("CodecCnt")
+#define REG_CODEC_X	_T("Codec%u")
+#define REG_AUTO_ANSWER	_T("AutoAnswer")
 
 
@@ -33,6 +39,18 @@
 CPocketPJSettings::CPocketPJSettings()
 : m_UseStun(FALSE), m_UseIce(FALSE), m_UseSrtp(FALSE), m_UsePublish(FALSE),
-  m_EchoSuppress(TRUE), m_EcTail(200)
-{
+  m_EchoSuppress(TRUE), m_EcTail(200), m_TCP(FALSE), m_VAD(FALSE),
+  m_AutoAnswer(FALSE)
+{
+    /* Init codec list */
+#if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC
+    m_Codecs.Add(_T("GSM"));
+#endif
+#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC
+    m_Codecs.Add(_T("PCMU"));
+    m_Codecs.Add(_T("PCMA"));
+#endif
+#if defined(PJMEDIA_HAS_SPEEX_CODEC) && PJMEDIA_HAS_SPEEX_CODEC
+    m_Codecs.Add(_T("Speex"));
+#endif
 }
 
@@ -77,12 +95,8 @@
     if (key.QueryValue(dwordVal, REG_USE_STUN) == ERROR_SUCCESS) {
 	m_UseStun = dwordVal != 0;
-    } else {
-	m_UseStun = 0;
     }
 
     if (key.QueryValue(dwordVal, REG_USE_ICE) == ERROR_SUCCESS) {
 	m_UseIce = dwordVal != 0;
-    } else {
-	m_UseIce = 0;
     }
 
@@ -90,6 +104,4 @@
     if (key.QueryValue(dwordVal, REG_USE_SRTP) == ERROR_SUCCESS) {
 	m_UseSrtp = dwordVal != 0;
-    } else {
-	m_UseSrtp = 0;
     }
 
@@ -103,6 +115,4 @@
     if (key.QueryValue(dwordVal, REG_ENABLE_EC) == ERROR_SUCCESS) {
 	m_EchoSuppress = dwordVal != 0;
-    } else {
-	m_EchoSuppress = 1;
     }
 
@@ -110,6 +120,19 @@
     if (key.QueryValue(dwordVal, REG_EC_TAIL) == ERROR_SUCCESS) {
 	m_EcTail = dwordVal;
-    } else {
-	m_EcTail = 200;
+    }
+
+    cbData = sizeof(dwordVal);
+    if (key.QueryValue(dwordVal, REG_ENABLE_TCP) == ERROR_SUCCESS) {
+	m_TCP = dwordVal != 0;
+    }
+
+    cbData = sizeof(dwordVal);
+    if (key.QueryValue(dwordVal, REG_ENABLE_VAD) == ERROR_SUCCESS) {
+	m_VAD = dwordVal != 0;
+    }
+
+    cbData = sizeof(dwordVal);
+    if (key.QueryValue(dwordVal, REG_AUTO_ANSWER) == ERROR_SUCCESS) {
+	m_AutoAnswer = dwordVal != 0;
     }
 
@@ -130,4 +153,21 @@
 	if (key.QueryValue(textVal, entry, &cbData) == ERROR_SUCCESS) {
 	    m_BuddyList.Add(textVal);
+	}
+    }
+
+    DWORD codecCount = 0;
+    cbData = sizeof(dwordVal);
+    if (key.QueryValue(codecCount, REG_CODEC_CNT) == ERROR_SUCCESS) {
+
+	m_Codecs.RemoveAll();
+
+	for (i=0; i<codecCount; ++i) {
+	    CString entry;
+	    entry.Format(REG_CODEC_X, i);
+
+	    cbData = sizeof(textVal);
+	    if (key.QueryValue(textVal, entry, &cbData) == ERROR_SUCCESS) {
+		m_Codecs.Add(textVal);
+	    }
 	}
     }
@@ -158,4 +198,8 @@
     key.SetValue(m_EcTail, REG_EC_TAIL);
 
+    key.SetValue(m_TCP, REG_ENABLE_TCP);
+    key.SetValue(m_VAD, REG_ENABLE_VAD);
+    key.SetValue(m_AutoAnswer, REG_AUTO_ANSWER);
+
     key.SetValue(m_BuddyList.GetSize(), REG_BUDDY_CNT);
 
@@ -165,4 +209,12 @@
 	entry.Format(REG_BUDDY_X, i);
 	key.SetValue(m_BuddyList.GetAt(i), entry);
+    }
+
+    DWORD N = m_Codecs.GetSize();
+    key.SetValue(N, REG_CODEC_CNT);
+    for (i=0; i<m_Codecs.GetSize(); ++i) {
+	CString entry;
+	entry.Format(REG_CODEC_X, i);
+	key.SetValue(m_Codecs.GetAt(i), entry);
     }
 
@@ -190,4 +242,7 @@
 	m_EchoSuppress = FALSE;
 	m_EcTail = _T("");
+	m_TCP = FALSE;
+	m_VAD = FALSE;
+	m_AutoAnswer = FALSE;
 	//}}AFX_DATA_INIT
 
@@ -202,8 +257,12 @@
 	m_Dns	    = m_Cfg.m_DNS;
 	m_EchoSuppress = m_Cfg.m_EchoSuppress;
+	m_TCP	    = m_Cfg.m_TCP;
+	m_VAD	    = m_Cfg.m_VAD;
+	m_AutoAnswer= m_Cfg.m_AutoAnswer;
 
 	CString s;
 	s.Format(_T("%d"), m_Cfg.m_EcTail);
 	m_EcTail    = s;
+
 }
 
@@ -213,4 +272,5 @@
 	CDialog::DoDataExchange(pDX);
 	//{{AFX_DATA_MAP(CSettingsDlg)
+	DDX_Control(pDX, IDC_CODECS, m_Codecs);
 	DDX_Text(pDX, IDC_DOMAIN, m_Domain);
 	DDX_Check(pDX, IDC_ICE, m_ICE);
@@ -224,5 +284,17 @@
 	DDX_Check(pDX, IDC_ECHO_SUPPRESS, m_EchoSuppress);
 	DDX_Text(pDX, IDC_EC_TAIL, m_EcTail);
+	DDX_Check(pDX, IDC_TCP, m_TCP);
+	DDX_Check(pDX, IDC_VAD, m_VAD);
+	DDX_Check(pDX, IDC_AA, m_AutoAnswer);
 	//}}AFX_DATA_MAP
+
+	
+	if (m_Codecs.GetCount() == 0) {
+	    int i;
+	    for (i=0; i<m_Cfg.m_Codecs.GetSize(); ++i) {
+		m_Codecs.AddString(m_Cfg.m_Codecs.GetAt(i));
+	    }
+	    m_Codecs.SetCurSel(0);
+	}
 }
 
@@ -232,4 +304,5 @@
 	ON_BN_CLICKED(IDC_STUN, OnStun)
 	ON_BN_CLICKED(IDC_ECHO_SUPPRESS, OnEchoSuppress)
+	ON_CBN_SELCHANGE(IDC_CODECS, OnSelchangeCodecs)
 	//}}AFX_MSG_MAP
 END_MESSAGE_MAP()
@@ -242,18 +315,4 @@
     int rc = CDialog::DoModal();	
 
-    if (rc == IDOK) {
-	m_Cfg.m_Domain	    = m_Domain;
-	m_Cfg.m_UseIce	    = m_ICE != 0;
-	m_Cfg.m_Password    = m_Passwd;
-	m_Cfg.m_UsePublish  = m_PUBLISH != 0;
-	m_Cfg.m_UseSrtp	    = m_SRTP != 0;
-	m_Cfg.m_UseStun	    = m_STUN != 0;
-	m_Cfg.m_StunSrv	    = m_StunSrv;
-	m_Cfg.m_User	    = m_User;
-	m_Cfg.m_DNS	    = m_Dns;
-	m_Cfg.m_EchoSuppress= m_EchoSuppress != 0;
-	m_Cfg.m_EcTail	    = _ttoi(m_EcTail);
-    }
-
     return rc;
 }
@@ -266,2 +325,52 @@
 {
 }
+
+void CSettingsDlg::OnSelchangeCodecs() 
+{
+    int cur = m_Codecs.GetCurSel();
+    if (cur < 1)
+	return;
+
+    CString codec;
+    DWORD N;
+
+    m_Codecs.GetLBText(cur, codec);
+    N = m_Codecs.GetCount();
+    m_Codecs.DeleteString(cur);
+    N = m_Codecs.GetCount();
+    m_Codecs.InsertString(0, codec);
+    N = m_Codecs.GetCount();
+    m_Codecs.SetCurSel(0);
+}
+
+
+void CSettingsDlg::OnOK() 
+{
+    UpdateData(TRUE);
+
+    m_Cfg.m_Domain	= m_Domain;
+    m_Cfg.m_UseIce	= m_ICE != 0;
+    m_Cfg.m_Password	= m_Passwd;
+    m_Cfg.m_UsePublish	= m_PUBLISH != 0;
+    m_Cfg.m_UseSrtp	= m_SRTP != 0;
+    m_Cfg.m_UseStun	= m_STUN != 0;
+    m_Cfg.m_StunSrv	= m_StunSrv;
+    m_Cfg.m_User	= m_User;
+    m_Cfg.m_DNS		= m_Dns;
+    m_Cfg.m_EchoSuppress= m_EchoSuppress != 0;
+    m_Cfg.m_EcTail	= _ttoi(m_EcTail);
+    m_Cfg.m_TCP		= m_TCP != 0;
+    m_Cfg.m_VAD		= m_VAD != 0;
+    m_Cfg.m_AutoAnswer	= m_AutoAnswer != 0;
+
+    unsigned i;
+    m_Cfg.m_Codecs.RemoveAll();
+    DWORD N = m_Codecs.GetCount();
+    for (i=0; i<N; ++i) {
+	CString codec;
+	m_Codecs.GetLBText(i, codec);
+	m_Cfg.m_Codecs.Add(codec);
+    }
+
+    CDialog::OnOK();
+}
