[ekiga] Added a memory of what presence to publish in the opal code -- and cleaned the debug output



commit 0dc028601b089306577723f99dae8ea83feea605
Author: Snark <jpuydt gnome org>
Date:   Thu Apr 14 15:18:51 2011 +0200

    Added a memory of what presence to publish in the opal code -- and cleaned the debug output

 lib/engine/components/opal/opal-account.cpp |   58 ++++++++++-----------------
 lib/engine/components/opal/opal-account.h   |    2 +
 2 files changed, 23 insertions(+), 37 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index ab1d4cc..b3214c7 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -296,11 +296,13 @@ void Opal::Account::enable ()
   endpoint->subscribe (*this);
   if (presentity) {
 
-    std::cout << "opening presentity for " << get_aor () << std::endl;
     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 ();
 	 iter != watched_uris.end (); ++iter)
       presentity->SubscribeToPresence (PString (*iter));
+    presentity->SetLocalPresence (personal_state, presence_status);
   }
 
   updated ();
@@ -315,11 +317,8 @@ void Opal::Account::disable ()
   boost::shared_ptr<Sip::EndPoint> endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
   endpoint->unsubscribe (*this);
 
-  if (presentity) {
-
-    std::cout << "closing presentity for " << get_aor () << std::endl;
+  if (presentity)
     presentity->Close ();
-  }
 
   updated ();
   trigger_saving ();
@@ -499,50 +498,38 @@ Opal::Account::on_consult (const std::string url)
 void
 Opal::Account::publish (const Ekiga::PersonalDetails& details)
 {
-  if (presentity) {
+  std::string presence = details.get_presence ();
 
-    std::string presence = details.get_presence ();
-    OpalPresenceInfo::State personal_state = OpalPresenceInfo::Unavailable;
+  // FIXME: complete!
+  if (presence == "online")
+    personal_state = OpalPresenceInfo::Available;
+  if (presence == "away")
+    personal_state = OpalPresenceInfo::Away;
+  if (presence == "dnd")
+    personal_state = OpalPresenceInfo::Busy;
 
-    // FIXME: complete!
-    if (presence == "online")
-      personal_state = OpalPresenceInfo::Available;
-    if (presence == "away")
-      personal_state = OpalPresenceInfo::Away;
-    if (presence == "dnd")
-      personal_state = OpalPresenceInfo::Busy;
+  presence_status = details.get_status ();
 
+  PTRACE (3, "Ekiga tries to publish presence");
 
-    std::cout << "internal presence: " << presence << std::endl;
-    std::cout << "calling SetLocalPresence for " << get_aor ()
-	      << " with presence " << personal_state
-	      << " and status \"" << details.get_status () << "\""
-	      << std::endl;
-    presentity->SetLocalPresence (personal_state, details.get_status ());
-  }
+  if (presentity)
+    presentity->SetLocalPresence (personal_state, presence_status);
 }
 
 void
 Opal::Account::fetch (const std::string uri)
 {
   watched_uris.insert (uri);
-  if (presentity) {
-
-    std::cout << "subscribing to presence of " <<  uri << " for " << get_aor () << std::endl;
+  if (presentity)
     presentity->SubscribeToPresence (PString (uri));
-  }
 }
 
 void
 Opal::Account::unfetch (const std::string uri)
 {
   watched_uris.erase (uri);
-  if (presentity) {
-
-
-    std::cout << "unsubscribing to presence of " <<  uri << " for " << get_aor () << std::endl;
+  if (presentity)
     presentity->UnsubscribeFromPresence (PString (uri));
-  }
 }
 
 void
@@ -645,10 +632,7 @@ Opal::Account::setup_presentity ()
     presentity->GetAttributes().Set(SIP_Presentity::AuthNameKey, username);
     presentity->GetAttributes().Set(SIP_Presentity::AuthPasswordKey, password);
     presentity->GetAttributes().Set(SIP_Presentity::SubProtocolKey, "Agent");
-    //    presentity->GetAttributes().Set(SIP_Presentity::DefaultPresenceServerKey, host);
-    std::cout << "got presentity for " << url << std::endl;
-  } else
-    std::cout << "NULL presentity for " << url << std::endl;
+  }
 }
 
 void
@@ -658,6 +642,8 @@ Opal::Account::OnPresenceChange (OpalPresentity& /*presentity*/,
   std::string new_presence = "unknown";
   std::string new_status = "";
 
+  PTRACE (4, "Ekiga's OnPresenceChange callback is triggered");
+
   SIPURL sip_uri = SIPURL (info.m_entity);
   sip_uri.Sanitise (SIPURL::ExternalURI);
   std::string uri = sip_uri.AsString ();
@@ -756,8 +742,6 @@ Opal::Account::OnPresenceChange (OpalPresentity& /*presentity*/,
     break;
   }
 
-  std::cout << "OnPresenceChange called about " << uri << " with " << info.m_state << " and note: " << info.m_note <<  std::endl;
-
   if (!info.m_note.IsEmpty ())
     new_status = (const char*) info.m_note; // casting a PString to a std::string isn't straightforward
 
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index ac08827..7725e7f 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -198,6 +198,8 @@ private:
     PDECLARE_PresenceChangeNotifier (Account, OnPresenceChange);
 
     std::set<std::string> watched_uris; // FIXME: that is wrong... the opal code should do that!
+    OpalPresenceInfo::State personal_state; // FIXME: shouldn't the opal code do that too?
+    std::string presence_status; // FIXME: shouldn't the opal code do that too?
     void presence_status_in_main (std::string uri,
 				  std::string presence,
 				  std::string status);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]