Changeset 2211 for pjproject/trunk/pjsip-apps/src/pocketpj/SettingsDlg.cpp
- Timestamp:
- Aug 13, 2008 1:56:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pocketpj/SettingsDlg.cpp
r2201 r2211 5 5 #include "PocketPJ.h" 6 6 #include "SettingsDlg.h" 7 #include <pjsua-lib/pjsua.h> 7 8 #include <atlbase.h> 8 9 … … 27 28 #define REG_ENABLE_EC _T("EnableEC") 28 29 #define REG_EC_TAIL _T("ECTail") 30 #define REG_ENABLE_VAD _T("EnableVAD") 31 #define REG_ENABLE_TCP _T("EnableTCP") 32 #define REG_CODEC_CNT _T("CodecCnt") 33 #define REG_CODEC_X _T("Codec%u") 34 #define REG_AUTO_ANSWER _T("AutoAnswer") 29 35 30 36 … … 33 39 CPocketPJSettings::CPocketPJSettings() 34 40 : m_UseStun(FALSE), m_UseIce(FALSE), m_UseSrtp(FALSE), m_UsePublish(FALSE), 35 m_EchoSuppress(TRUE), m_EcTail(200) 36 { 41 m_EchoSuppress(TRUE), m_EcTail(200), m_TCP(FALSE), m_VAD(FALSE), 42 m_AutoAnswer(FALSE) 43 { 44 /* Init codec list */ 45 #if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC 46 m_Codecs.Add(_T("GSM")); 47 #endif 48 #if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC 49 m_Codecs.Add(_T("PCMU")); 50 m_Codecs.Add(_T("PCMA")); 51 #endif 52 #if defined(PJMEDIA_HAS_SPEEX_CODEC) && PJMEDIA_HAS_SPEEX_CODEC 53 m_Codecs.Add(_T("Speex")); 54 #endif 37 55 } 38 56 … … 77 95 if (key.QueryValue(dwordVal, REG_USE_STUN) == ERROR_SUCCESS) { 78 96 m_UseStun = dwordVal != 0; 79 } else {80 m_UseStun = 0;81 97 } 82 98 83 99 if (key.QueryValue(dwordVal, REG_USE_ICE) == ERROR_SUCCESS) { 84 100 m_UseIce = dwordVal != 0; 85 } else {86 m_UseIce = 0;87 101 } 88 102 … … 90 104 if (key.QueryValue(dwordVal, REG_USE_SRTP) == ERROR_SUCCESS) { 91 105 m_UseSrtp = dwordVal != 0; 92 } else {93 m_UseSrtp = 0;94 106 } 95 107 … … 103 115 if (key.QueryValue(dwordVal, REG_ENABLE_EC) == ERROR_SUCCESS) { 104 116 m_EchoSuppress = dwordVal != 0; 105 } else {106 m_EchoSuppress = 1;107 117 } 108 118 … … 110 120 if (key.QueryValue(dwordVal, REG_EC_TAIL) == ERROR_SUCCESS) { 111 121 m_EcTail = dwordVal; 112 } else { 113 m_EcTail = 200; 122 } 123 124 cbData = sizeof(dwordVal); 125 if (key.QueryValue(dwordVal, REG_ENABLE_TCP) == ERROR_SUCCESS) { 126 m_TCP = dwordVal != 0; 127 } 128 129 cbData = sizeof(dwordVal); 130 if (key.QueryValue(dwordVal, REG_ENABLE_VAD) == ERROR_SUCCESS) { 131 m_VAD = dwordVal != 0; 132 } 133 134 cbData = sizeof(dwordVal); 135 if (key.QueryValue(dwordVal, REG_AUTO_ANSWER) == ERROR_SUCCESS) { 136 m_AutoAnswer = dwordVal != 0; 114 137 } 115 138 … … 130 153 if (key.QueryValue(textVal, entry, &cbData) == ERROR_SUCCESS) { 131 154 m_BuddyList.Add(textVal); 155 } 156 } 157 158 DWORD codecCount = 0; 159 cbData = sizeof(dwordVal); 160 if (key.QueryValue(codecCount, REG_CODEC_CNT) == ERROR_SUCCESS) { 161 162 m_Codecs.RemoveAll(); 163 164 for (i=0; i<codecCount; ++i) { 165 CString entry; 166 entry.Format(REG_CODEC_X, i); 167 168 cbData = sizeof(textVal); 169 if (key.QueryValue(textVal, entry, &cbData) == ERROR_SUCCESS) { 170 m_Codecs.Add(textVal); 171 } 132 172 } 133 173 } … … 158 198 key.SetValue(m_EcTail, REG_EC_TAIL); 159 199 200 key.SetValue(m_TCP, REG_ENABLE_TCP); 201 key.SetValue(m_VAD, REG_ENABLE_VAD); 202 key.SetValue(m_AutoAnswer, REG_AUTO_ANSWER); 203 160 204 key.SetValue(m_BuddyList.GetSize(), REG_BUDDY_CNT); 161 205 … … 165 209 entry.Format(REG_BUDDY_X, i); 166 210 key.SetValue(m_BuddyList.GetAt(i), entry); 211 } 212 213 DWORD N = m_Codecs.GetSize(); 214 key.SetValue(N, REG_CODEC_CNT); 215 for (i=0; i<m_Codecs.GetSize(); ++i) { 216 CString entry; 217 entry.Format(REG_CODEC_X, i); 218 key.SetValue(m_Codecs.GetAt(i), entry); 167 219 } 168 220 … … 190 242 m_EchoSuppress = FALSE; 191 243 m_EcTail = _T(""); 244 m_TCP = FALSE; 245 m_VAD = FALSE; 246 m_AutoAnswer = FALSE; 192 247 //}}AFX_DATA_INIT 193 248 … … 202 257 m_Dns = m_Cfg.m_DNS; 203 258 m_EchoSuppress = m_Cfg.m_EchoSuppress; 259 m_TCP = m_Cfg.m_TCP; 260 m_VAD = m_Cfg.m_VAD; 261 m_AutoAnswer= m_Cfg.m_AutoAnswer; 204 262 205 263 CString s; 206 264 s.Format(_T("%d"), m_Cfg.m_EcTail); 207 265 m_EcTail = s; 266 208 267 } 209 268 … … 213 272 CDialog::DoDataExchange(pDX); 214 273 //{{AFX_DATA_MAP(CSettingsDlg) 274 DDX_Control(pDX, IDC_CODECS, m_Codecs); 215 275 DDX_Text(pDX, IDC_DOMAIN, m_Domain); 216 276 DDX_Check(pDX, IDC_ICE, m_ICE); … … 224 284 DDX_Check(pDX, IDC_ECHO_SUPPRESS, m_EchoSuppress); 225 285 DDX_Text(pDX, IDC_EC_TAIL, m_EcTail); 286 DDX_Check(pDX, IDC_TCP, m_TCP); 287 DDX_Check(pDX, IDC_VAD, m_VAD); 288 DDX_Check(pDX, IDC_AA, m_AutoAnswer); 226 289 //}}AFX_DATA_MAP 290 291 292 if (m_Codecs.GetCount() == 0) { 293 int i; 294 for (i=0; i<m_Cfg.m_Codecs.GetSize(); ++i) { 295 m_Codecs.AddString(m_Cfg.m_Codecs.GetAt(i)); 296 } 297 m_Codecs.SetCurSel(0); 298 } 227 299 } 228 300 … … 232 304 ON_BN_CLICKED(IDC_STUN, OnStun) 233 305 ON_BN_CLICKED(IDC_ECHO_SUPPRESS, OnEchoSuppress) 306 ON_CBN_SELCHANGE(IDC_CODECS, OnSelchangeCodecs) 234 307 //}}AFX_MSG_MAP 235 308 END_MESSAGE_MAP() … … 242 315 int rc = CDialog::DoModal(); 243 316 244 if (rc == IDOK) {245 m_Cfg.m_Domain = m_Domain;246 m_Cfg.m_UseIce = m_ICE != 0;247 m_Cfg.m_Password = m_Passwd;248 m_Cfg.m_UsePublish = m_PUBLISH != 0;249 m_Cfg.m_UseSrtp = m_SRTP != 0;250 m_Cfg.m_UseStun = m_STUN != 0;251 m_Cfg.m_StunSrv = m_StunSrv;252 m_Cfg.m_User = m_User;253 m_Cfg.m_DNS = m_Dns;254 m_Cfg.m_EchoSuppress= m_EchoSuppress != 0;255 m_Cfg.m_EcTail = _ttoi(m_EcTail);256 }257 258 317 return rc; 259 318 } … … 266 325 { 267 326 } 327 328 void CSettingsDlg::OnSelchangeCodecs() 329 { 330 int cur = m_Codecs.GetCurSel(); 331 if (cur < 1) 332 return; 333 334 CString codec; 335 DWORD N; 336 337 m_Codecs.GetLBText(cur, codec); 338 N = m_Codecs.GetCount(); 339 m_Codecs.DeleteString(cur); 340 N = m_Codecs.GetCount(); 341 m_Codecs.InsertString(0, codec); 342 N = m_Codecs.GetCount(); 343 m_Codecs.SetCurSel(0); 344 } 345 346 347 void CSettingsDlg::OnOK() 348 { 349 UpdateData(TRUE); 350 351 m_Cfg.m_Domain = m_Domain; 352 m_Cfg.m_UseIce = m_ICE != 0; 353 m_Cfg.m_Password = m_Passwd; 354 m_Cfg.m_UsePublish = m_PUBLISH != 0; 355 m_Cfg.m_UseSrtp = m_SRTP != 0; 356 m_Cfg.m_UseStun = m_STUN != 0; 357 m_Cfg.m_StunSrv = m_StunSrv; 358 m_Cfg.m_User = m_User; 359 m_Cfg.m_DNS = m_Dns; 360 m_Cfg.m_EchoSuppress= m_EchoSuppress != 0; 361 m_Cfg.m_EcTail = _ttoi(m_EcTail); 362 m_Cfg.m_TCP = m_TCP != 0; 363 m_Cfg.m_VAD = m_VAD != 0; 364 m_Cfg.m_AutoAnswer = m_AutoAnswer != 0; 365 366 unsigned i; 367 m_Cfg.m_Codecs.RemoveAll(); 368 DWORD N = m_Codecs.GetCount(); 369 for (i=0; i<N; ++i) { 370 CString codec; 371 m_Codecs.GetLBText(i, codec); 372 m_Cfg.m_Codecs.Add(codec); 373 } 374 375 CDialog::OnOK(); 376 }
Note: See TracChangeset
for help on using the changeset viewer.