[ekiga] Ekiga: Speedup startup in case of slow DNS queries.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Ekiga: Speedup startup in case of slow DNS queries.
- Date: Sun, 25 Mar 2012 12:23:15 +0000 (UTC)
commit d44bd943902edfa05c7879555d67dc485aa03b96
Author: Damien Sandras <dsandras beip be>
Date: Sun Mar 25 14:21:52 2012 +0200
Ekiga: Speedup startup in case of slow DNS queries.
The reason was that presentity->Open from OPAL was executed
synchroneously, leading to UI slow startup or freezes when the DNS is
slow to answer to SRV queries.
lib/engine/components/opal/h323-endpoint.cpp | 19 +++++++++++-----
lib/engine/components/opal/h323-endpoint.h | 5 ++-
lib/engine/components/opal/opal-account.cpp | 15 ++++++-------
lib/engine/components/opal/sip-endpoint.cpp | 30 +++++++++++++++++++-------
lib/engine/components/opal/sip-endpoint.h | 4 +-
5 files changed, 47 insertions(+), 26 deletions(-)
---
diff --git a/lib/engine/components/opal/h323-endpoint.cpp b/lib/engine/components/opal/h323-endpoint.cpp
index 9fe55fc..d8c23b4 100644
--- a/lib/engine/components/opal/h323-endpoint.cpp
+++ b/lib/engine/components/opal/h323-endpoint.cpp
@@ -53,22 +53,27 @@ namespace Opal {
public:
subscriber (const Opal::Account & _account,
- Opal::H323::EndPoint& _manager)
+ Opal::H323::EndPoint& _manager,
+ const PSafePtr<OpalPresentity> & _presentity)
: PThread (1000, AutoDeleteThread),
account (_account),
- manager (_manager)
+ manager (_manager),
+ presentity (_presentity)
{
this->Resume ();
};
void Main ()
{
+ if (presentity && !presentity->IsOpen ())
+ presentity->Open ();
manager.Register (account);
};
private:
const Opal::Account & account;
Opal::H323::EndPoint& manager;
+ const PSafePtr<OpalPresentity> & presentity;
};
};
};
@@ -249,24 +254,26 @@ Opal::H323::EndPoint::get_forward_uri () const
bool
-Opal::H323::EndPoint::subscribe (const Opal::Account & account)
+Opal::H323::EndPoint::subscribe (const Opal::Account & account,
+ const PSafePtr<OpalPresentity> & presentity)
{
if (account.get_protocol_name () != "H323" || account.is_enabled ())
return false;
- new subscriber (account, *this);
+ new subscriber (account, *this, presentity);
return true;
}
bool
-Opal::H323::EndPoint::unsubscribe (const Opal::Account & account)
+Opal::H323::EndPoint::unsubscribe (const Opal::Account & account,
+ const PSafePtr<OpalPresentity> & presentity)
{
if (account.get_protocol_name () != "H323" || !account.is_enabled ())
return false;
- new subscriber (account, *this);
+ new subscriber (account, *this, presentity);
return true;
}
diff --git a/lib/engine/components/opal/h323-endpoint.h b/lib/engine/components/opal/h323-endpoint.h
index e260def..ede8b6e 100644
--- a/lib/engine/components/opal/h323-endpoint.h
+++ b/lib/engine/components/opal/h323-endpoint.h
@@ -108,8 +108,9 @@ namespace Opal {
/* AccountSubscriber */
- bool subscribe (const Opal::Account & account);
- bool unsubscribe (const Opal::Account & account);
+ bool subscribe (const Opal::Account & account, const PSafePtr<OpalPresentity> & presentity);
+ bool unsubscribe (const Opal::Account & account, const PSafePtr<OpalPresentity> & presentity);
+
/* OPAL methods */
void Register (const Opal::Account & account);
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 7dcff43..1c8f184 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -184,7 +184,7 @@ Opal::Account::Account (Ekiga::ServiceCore & _core,
Opal::Account::~Account ()
{
if (state == Registered)
- endpoint->unsubscribe (*this);
+ endpoint->unsubscribe (*this, presentity);
}
@@ -302,10 +302,9 @@ void Opal::Account::enable ()
enabled = true;
status = _("Processing...");
- endpoint->subscribe (*this);
+ endpoint->subscribe (*this, presentity);
if (presentity) {
- presentity->Open ();
// FIXME : the following actions should probably be done by opal itself,
// remembering what ekiga asked...
for (std::set<std::string>::iterator iter = watched_uris.begin ();
@@ -331,11 +330,11 @@ void Opal::Account::disable ()
// the above change is needed because if we are already not
// registered (because a registration failed, for example), then the
// next action won't change the status.
- endpoint->unsubscribe (*this);
+ endpoint->unsubscribe (*this, presentity);
+ presentity->Close ();
if (presentity) {
- presentity->Close ();
// FIXME : the following actions should probably be done by opal itself,
// remembering what ekiga asked...
for (std::set<std::string>::iterator iter = watched_uris.begin ();
@@ -376,7 +375,7 @@ void Opal::Account::remove ()
enabled = false;
dead = true;
- endpoint->unsubscribe (*this);
+ endpoint->unsubscribe (*this, presentity);
trigger_saving ();
removed ();
@@ -636,13 +635,13 @@ Opal::Account::handle_registration_event (RegistrationState state_,
// FullyCompliant did not work, try next compat mode
compat_mode = SIPRegister::e_CannotRegisterMultipleContacts;
PTRACE (4, "Register failed in FullyCompliant mode, retrying in CannotRegisterMultipleContacts mode");
- endpoint->subscribe (*this);
+ endpoint->subscribe (*this, presentity);
break;
case SIPRegister::e_CannotRegisterMultipleContacts:
// CannotRegMC did not work, try next compat mode
compat_mode = SIPRegister::e_CannotRegisterPrivateContacts;
PTRACE (4, "Register failed in CannotRegisterMultipleContacts mode, retrying in CannotRegisterPrivateContacts mode");
- endpoint->subscribe (*this);
+ endpoint->subscribe (*this, presentity);
break;
case SIPRegister::e_CannotRegisterPrivateContacts:
// CannotRegPC did not work, stop registration with error
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index f7975e8..7d4fed2 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -71,7 +71,8 @@ namespace Opal {
unsigned _timeout,
std::string _aor,
Opal::Sip::EndPoint & _manager,
- bool _registering)
+ bool _registering,
+ const PSafePtr<OpalPresentity> & _presentity)
: PThread (1000, AutoDeleteThread),
username(_username),
host(_host),
@@ -82,7 +83,8 @@ namespace Opal {
timeout(_timeout),
aor(_aor),
manager (_manager),
- registering (_registering)
+ registering (_registering),
+ presentity (_presentity)
{
this->Resume ();
};
@@ -91,10 +93,15 @@ namespace Opal {
{
if (registering) {
+ if (presentity && !presentity->IsOpen ())
+ presentity->Open ();
manager.Register (username, host, authentication_username, password, is_enabled, compat_mode, timeout);
- } else {
-
+ }
+ else {
manager.Unregister (aor);
+
+ if (presentity && presentity->IsOpen ())
+ presentity->Close ();
}
};
@@ -109,6 +116,7 @@ namespace Opal {
std::string aor;
Opal::Sip::EndPoint & manager;
bool registering;
+ const PSafePtr<OpalPresentity> & presentity;
};
};
};
@@ -469,7 +477,8 @@ Opal::Sip::EndPoint::get_aor_domain (const std::string & aor)
bool
-Opal::Sip::EndPoint::subscribe (const Opal::Account & account)
+Opal::Sip::EndPoint::subscribe (const Opal::Account & account,
+ const PSafePtr<OpalPresentity> & presentity)
{
if (account.get_protocol_name () != "SIP")
return false;
@@ -482,13 +491,16 @@ Opal::Sip::EndPoint::subscribe (const Opal::Account & account)
account.get_compat_mode (),
account.get_timeout (),
account.get_aor (),
- *this, true);
+ *this,
+ true,
+ presentity);
return true;
}
bool
-Opal::Sip::EndPoint::unsubscribe (const Opal::Account & account)
+Opal::Sip::EndPoint::unsubscribe (const Opal::Account & account,
+ const PSafePtr<OpalPresentity> & presentity)
{
if (account.get_protocol_name () != "SIP")
return false;
@@ -501,7 +513,9 @@ Opal::Sip::EndPoint::unsubscribe (const Opal::Account & account)
account.get_compat_mode (),
account.get_timeout (),
account.get_aor (),
- *this, false);
+ *this,
+ false,
+ presentity);
return true;
}
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 93f5ad6..22d25d5 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -126,8 +126,8 @@ namespace Opal {
/* AccountSubscriber */
- bool subscribe (const Opal::Account & account);
- bool unsubscribe (const Opal::Account & account);
+ bool subscribe (const Opal::Account & account, const PSafePtr<OpalPresentity> & presentity);
+ bool unsubscribe (const Opal::Account & account, const PSafePtr<OpalPresentity> & presentity);
/* Helper */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]