From e422daebaf305a9d8a5988c6a2c8caa1ad34063a Mon Sep 17 00:00:00 2001 From: rjongbloed Date: Sun, 19 Aug 2007 02:05:00 +0000 Subject: [PATCH] Made sure deregister from previous regisrar when changed in options dialog. --- samples/openphone/main.cxx | 41 ++++++++++++++++++++++++++--------------- samples/openphone/main.h | 4 ++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/samples/openphone/main.cxx b/samples/openphone/main.cxx index 3b055115..828bf435 100644 --- a/samples/openphone/main.cxx +++ b/samples/openphone/main.cxx @@ -25,6 +25,9 @@ * Contributor(s): * * $Log$ + * Revision 1.26 2007/08/19 02:05:00 rjongbloed + * Made sure deregister from previous regisrar when changed in options dialog. + * * Revision 1.25 2007/07/27 01:42:10 rjongbloed * Added cut, copy, paste and most important DELETE of speed dials. * @@ -528,8 +531,6 @@ MyManager::~MyManager() { LogWindow.SetFrame(NULL); - ClearAllCalls(); - // Must do this before we destroy the manager or a crash will result if (potsEP != NULL) potsEP->RemoveAllLines(); @@ -1078,6 +1079,9 @@ void MyManager::OnClose(wxCloseEvent& /*event*/) config->Write(MainFrameWidthKey, w); config->Write(MainFrameHeightKey, h); + ClearAllCalls(); + StopRegistrar(); + Destroy(); } @@ -1810,20 +1814,26 @@ bool MyManager::StartGatekeeper() bool MyManager::StartRegistrar() { - if (m_registrarUsed) { - if (!sipEP->Register(m_registrarName, m_registrarUser, m_registrarUser, m_registrarPassword)) - return false; + if (sipEP == NULL || !m_registrarUsed) + return false; - LogWindow << "SIP registration started for " << m_registrarUser << '@' << m_registrarName << endl; - } - else { - PString aor = m_registrarUser + '@' + m_registrarName; - if (sipEP->IsRegistered(aor)) { - LogWindow << "SIP registration ended for " << aor << endl; - sipEP->Unregister(aor); - } - } - return true; + BOOL ok = sipEP->Register(m_registrarName, m_registrarUser, m_registrarUser, m_registrarPassword); + LogWindow << "SIP registration " << (ok ? "start" : "fail") << "ed for " << m_registrarUser << '@' << m_registrarName << endl; + return ok; +} + + +bool MyManager::StopRegistrar() +{ + if (sipEP == NULL) + return false; + + PString aor = m_registrarUser + '@' + m_registrarName; + if (!sipEP->IsRegistered(aor)) + return false; + + LogWindow << "SIP registration ended for " << aor << endl; + return sipEP->Unregister(aor); } @@ -2407,6 +2417,7 @@ bool OptionsDialog::TransferDataFromWindow() m_manager.m_registrarName != m_RegistrarName || m_manager.m_registrarUser != m_RegistrarUsername || m_manager.m_registrarPassword != m_RegistrarPassword) { + m_manager.StopRegistrar(); SAVE_FIELD(RegistrarUsed, m_manager.m_registrarUsed =); SAVE_FIELD(RegistrarName, m_manager.m_registrarName =); SAVE_FIELD(RegistrarUsername, m_manager.m_registrarUser =); diff --git a/samples/openphone/main.h b/samples/openphone/main.h index 9cafc79d..f2fc84f9 100644 --- a/samples/openphone/main.h +++ b/samples/openphone/main.h @@ -25,6 +25,9 @@ * Contributor(s): ______________________________________. * * $Log$ + * Revision 1.44 2007/08/19 02:05:01 rjongbloed + * Made sure deregister from previous regisrar when changed in options dialog. + * * Revision 1.43 2007/08/03 01:00:47 rjongbloed * Fixed compile on DevStudio 2003 * @@ -711,6 +714,7 @@ class MyManager : public wxFrame, public OpalManager PwxString m_registrarUser; PwxString m_registrarPassword; bool StartRegistrar(); + bool StopRegistrar(); #endif #if P_EXPAT -- 2.11.4.GIT