[ekiga] Changed the way the OpalPresentity is managed and made better error output
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Changed the way the OpalPresentity is managed and made better error output
- Date: Fri, 14 Jan 2011 12:57:48 +0000 (UTC)
commit b90330eead725b063289d3f4cfb6485a3a9a125e
Author: Snark <jpuydt gnome org>
Date: Fri Jan 14 13:51:43 2011 +0100
Changed the way the OpalPresentity is managed and made better error output
Now we store it in a PSafePtr, mostly, and ask the call manager
to build it for us instead of trying to create it directly.
lib/engine/components/opal/opal-account.cpp | 54 ++++++++++++++++++--------
lib/engine/components/opal/opal-account.h | 4 +-
2 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 868d434..7fec461 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -42,10 +42,13 @@
#include <glib.h>
#include <glib/gi18n.h>
+
#include <ptlib.h>
-#include <opal/opal.h>
#include <ptclib/guid.h>
+#include <opal/opal.h>
+#include <sip/sippres.h>
+
#include "opal-account.h"
#include "form-request-simple.h"
#include "toolbox.h"
@@ -56,6 +59,8 @@
#include "sip-endpoint.h"
+#define SCHEME "sip:"
+
Opal::Account::Account (Ekiga::ServiceCore & _core,
const std::string & account)
: core (_core)
@@ -130,10 +135,7 @@ Opal::Account::Account (Ekiga::ServiceCore & _core,
limited = (name.find ("%limit") != std::string::npos);
-
- boost::shared_ptr<CallManager> manager = core.get<CallManager> ("opal-component");
- PURL url = PString (get_aor ());
- presentity = boost::shared_ptr<OpalPresentity> (OpalPresentity::Create (*manager, url));
+ setup_presentity ();
}
@@ -165,9 +167,7 @@ Opal::Account::Account (Ekiga::ServiceCore & _core,
timeout = _timeout;
type = t;
- boost::shared_ptr<CallManager> manager = core.get<CallManager> ("opal-component");
- PURL url = PString (get_aor ());
- presentity = boost::shared_ptr<OpalPresentity> (OpalPresentity::Create (*manager, url));
+ setup_presentity ();
if (enabled)
enable ();
@@ -294,8 +294,11 @@ void Opal::Account::enable ()
boost::shared_ptr<Sip::EndPoint> endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
endpoint->subscribe (*this);
- if (presentity)
+ if (presentity) {
+
+ std::cout << "opening presentity for " << get_aor () << std::endl;
presentity->Open ();
+ }
updated ();
trigger_saving ();
@@ -309,8 +312,11 @@ void Opal::Account::disable ()
boost::shared_ptr<Sip::EndPoint> endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
endpoint->unsubscribe (*this);
- if (presentity)
+ if (presentity) {
+
+ std::cout << "closing presentity for " << get_aor () << std::endl;
presentity->Close ();
+ }
updated ();
trigger_saving ();
@@ -491,8 +497,6 @@ Opal::Account::publish (const Ekiga::PersonalDetails& details)
{
if (presentity) {
- std::cout << __PRETTY_FUNCTION__ << ": ok" << std::endl;
-
std::string presence = details.get_presence ();
OpalPresenceInfo::State personal_state = OpalPresenceInfo::Unavailable;
@@ -500,8 +504,8 @@ Opal::Account::publish (const Ekiga::PersonalDetails& details)
if (presence == "online")
personal_state = OpalPresenceInfo::Available;
- if (presentity)
- presentity->SetLocalPresence (personal_state, details.get_status ());
+ std::cout << "calling SetLocalPresence for " << get_aor () << std::endl;
+ presentity->SetLocalPresence (personal_state, details.get_status ());
}
}
@@ -510,8 +514,7 @@ Opal::Account::fetch (const std::string uri)
{
if (presentity) {
- std::cout << __PRETTY_FUNCTION__ << " " << uri << std::endl;
-
+ std::cout << "subscribing to presence of " << uri << " for " << get_aor () << std::endl;
presentity->SubscribeToPresence (PString (uri));
}
}
@@ -521,8 +524,8 @@ Opal::Account::unfetch (const std::string uri)
{
if (presentity) {
- std::cout << __PRETTY_FUNCTION__ << " " << uri << std::endl;
+ std::cout << "unsubscribing to presence of " << uri << " for " << get_aor () << std::endl;
presentity->UnsubscribeFromPresence (PString (uri));
}
}
@@ -612,3 +615,20 @@ Opal::Account::get_type () const
{
return type;
}
+
+void
+Opal::Account::setup_presentity ()
+{
+ boost::shared_ptr<CallManager> manager = core.get<CallManager> ("opal-component");
+ PURL url = PString (get_aor ());
+ presentity = manager->AddPresentity (url);
+
+ if (presentity) {
+
+ presentity->GetAttributes().Set(SIP_Presentity::AuthNameKey, username);
+ presentity->GetAttributes().Set(SIP_Presentity::AuthPasswordKey, password);
+ presentity->GetAttributes().Set(SIP_Presentity::DefaultPresenceServerKey, host);
+ std::cout << "got presentity for " << url << std::endl;
+ } else
+ std::cout << "NULL presentity for " << url << std::endl;
+}
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 6e3e179..2fa8ac8 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -191,7 +191,9 @@ private:
std::string auth_username;
std::string password;
Type type;
- boost::shared_ptr<OpalPresentity> presentity;
+
+ PSafePtr<OpalPresentity> presentity;
+ void setup_presentity ();
Ekiga::ServiceCore & core;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]