[ekiga] The code now correctly publishes our presence&status



commit 62dfe35baad77f3b8e65e0d4d94c9af580fd4165
Author: Julien Puydt <jpuydt noether localdomain>
Date:   Tue Dec 2 21:51:24 2008 +0100

    The code now correctly publishes our presence&status

 .../components/loudmouth/loudmouth-account.cpp     |    7 ++++---
 .../components/loudmouth/loudmouth-account.h       |    4 +++-
 lib/engine/components/loudmouth/loudmouth-bank.cpp |    6 ++++--
 lib/engine/components/loudmouth/loudmouth-bank.h   |    4 +++-
 lib/engine/components/loudmouth/loudmouth-heap.cpp |   20 +++++++++++++++++++-
 lib/engine/components/loudmouth/loudmouth-heap.h   |   13 ++++++++++---
 lib/engine/components/loudmouth/loudmouth-main.cpp |    8 +++++---
 7 files changed, 48 insertions(+), 14 deletions(-)
---
diff --git a/lib/engine/components/loudmouth/loudmouth-account.cpp b/lib/engine/components/loudmouth/loudmouth-account.cpp
index 24f8cb5..b78c076 100644
--- a/lib/engine/components/loudmouth/loudmouth-account.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-account.cpp
@@ -64,13 +64,14 @@ on_authenticate_c (LmConnection* /*unused*/,
 
 /* and here is the C++ code : */
 
-LM::Account::Account (gmref_ptr<Cluster> cluster_,
+LM::Account::Account (gmref_ptr<Ekiga::PersonalDetails> details_,
+		      gmref_ptr<Cluster> cluster_,
 		      const std::string user_,
 		      const std::string password_,
 		      const std::string resource_,
 		      const std::string server_,
 		      unsigned port_):
-  cluster(cluster_), user(user_), password(password_), resource(resource_), server(server_), port(port_), connection(0)
+  details(details_), cluster(cluster_), user(user_), password(password_), resource(resource_), server(server_), port(port_), connection(0)
 {
   connection = lm_connection_new (NULL);
   lm_connection_set_disconnect_function (connection, (LmDisconnectFunction)on_disconnected_c,
@@ -145,7 +146,7 @@ LM::Account::on_authenticate (bool result)
 {
   if (result) {
 
-    heap = gmref_ptr<Heap> (new Heap (connection));
+    heap = gmref_ptr<Heap> (new Heap (details, connection));
     cluster->add_heap (heap);
   } else {
 
diff --git a/lib/engine/components/loudmouth/loudmouth-account.h b/lib/engine/components/loudmouth/loudmouth-account.h
index 8e9f26f..e466882 100644
--- a/lib/engine/components/loudmouth/loudmouth-account.h
+++ b/lib/engine/components/loudmouth/loudmouth-account.h
@@ -47,7 +47,8 @@ namespace LM
     public virtual GmRefCounted
   {
   public:
-    Account (gmref_ptr<Cluster> cluster_,
+    Account (gmref_ptr<Ekiga::PersonalDetails> details_,
+	     gmref_ptr<Cluster> cluster_,
 	     const std::string user_,
 	     const std::string password_,
 	     const std::string resource_,
@@ -67,6 +68,7 @@ namespace LM
 
   private:
 
+    gmref_ptr<Ekiga::PersonalDetails> details;
     gmref_ptr<Cluster> cluster;
 
     std::string user;
diff --git a/lib/engine/components/loudmouth/loudmouth-bank.cpp b/lib/engine/components/loudmouth/loudmouth-bank.cpp
index 7679c5a..06b9bb9 100644
--- a/lib/engine/components/loudmouth/loudmouth-bank.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-bank.cpp
@@ -37,9 +37,11 @@
 
 #include "loudmouth-bank.h"
 
-LM::Bank::Bank (gmref_ptr<Cluster> cluster_): cluster(cluster_)
+LM::Bank::Bank (gmref_ptr<Ekiga::PersonalDetails> details_,
+		gmref_ptr<Cluster> cluster_):
+  details(details_), cluster(cluster_)
 {
-  account = gmref_ptr<Account>(new Account (cluster, "premier", "premier", "ekiga", "localhost"));
+  account = gmref_ptr<Account>(new Account (details, cluster, "premier", "premier", "ekiga", "localhost"));
 }
 
 LM::Bank::~Bank ()
diff --git a/lib/engine/components/loudmouth/loudmouth-bank.h b/lib/engine/components/loudmouth/loudmouth-bank.h
index b73f2a3..fdaa26a 100644
--- a/lib/engine/components/loudmouth/loudmouth-bank.h
+++ b/lib/engine/components/loudmouth/loudmouth-bank.h
@@ -47,7 +47,8 @@ namespace LM
     public Ekiga::Service
   {
   public:
-    Bank (gmref_ptr<Cluster> cluster_);
+    Bank (gmref_ptr<Ekiga::PersonalDetails> details_,
+	  gmref_ptr<Cluster> cluster_);
 
     ~Bank ();
 
@@ -59,6 +60,7 @@ namespace LM
 
   private:
 
+    gmref_ptr<Ekiga::PersonalDetails> details;
     gmref_ptr<Cluster> cluster;
     gmref_ptr<Account> account;
   };
diff --git a/lib/engine/components/loudmouth/loudmouth-heap.cpp b/lib/engine/components/loudmouth/loudmouth-heap.cpp
index b388af5..8cd0a95 100644
--- a/lib/engine/components/loudmouth/loudmouth-heap.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-heap.cpp
@@ -59,8 +59,12 @@ presence_handler_c (LmMessageHandler* /*handler*/,
   return heap->presence_handler (message);
 }
 
-LM::Heap::Heap (LmConnection* connection_): connection(connection_)
+LM::Heap::Heap (gmref_ptr<Ekiga::PersonalDetails> details_,
+		LmConnection* connection_):
+  details(details_), connection(connection_)
 {
+  details->updated.connect (sigc::mem_fun (this, &LM::Heap::on_personal_details_updated));
+
   lm_connection_ref (connection);
 
   iq_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)iq_handler_c, this, NULL);
@@ -81,6 +85,8 @@ LM::Heap::Heap (LmConnection* connection_): connection(connection_)
     lm_connection_send (connection, presence_push, NULL);
     lm_message_unref (presence_push);
   }
+
+  on_personal_details_updated (); // fake, but if we start as dnd, we want it known
 }
 
 LM::Heap::~Heap ()
@@ -366,3 +372,15 @@ LM::Heap::find_item (const std::string jid)
 
   return result;
 }
+
+void
+LM::Heap::on_personal_details_updated ()
+{
+  LmMessage* message = lm_message_new (NULL, LM_MESSAGE_TYPE_PRESENCE);
+
+  lm_message_node_add_child (lm_message_get_node (message), "show", details->get_presence ().c_str ());
+  lm_message_node_add_child (lm_message_get_node (message), "status", details->get_status ().c_str ());
+
+  lm_connection_send (connection, message, NULL);
+  lm_message_unref (message);
+}
diff --git a/lib/engine/components/loudmouth/loudmouth-heap.h b/lib/engine/components/loudmouth/loudmouth-heap.h
index 2af1762..05e91b4 100644
--- a/lib/engine/components/loudmouth/loudmouth-heap.h
+++ b/lib/engine/components/loudmouth/loudmouth-heap.h
@@ -37,16 +37,19 @@
 #define __LOUDMOUTH_HEAP_H__
 
 #include "heap-impl.h"
+#include "personal-details.h"
 #include "loudmouth-presentity.h"
 
 namespace LM
 {
   class Heap:
-    public Ekiga::HeapImpl<Presentity>
+    public Ekiga::HeapImpl<Presentity>,
+    public sigc::trackable
   {
   public:
-    
-    Heap (LmConnection* connection_);
+
+    Heap (gmref_ptr<Ekiga::PersonalDetails> details_,
+	  LmConnection* connection_);
 
     ~Heap ();
 
@@ -67,6 +70,8 @@ namespace LM
 
   private:
 
+    gmref_ptr<Ekiga::PersonalDetails> details;
+
     LmConnection* connection;
 
     LmMessageHandler* iq_lm_handler;
@@ -84,6 +89,8 @@ namespace LM
 					Ekiga::Form& result);
 
     gmref_ptr<Presentity> find_item (const std::string jid);
+
+    void on_personal_details_updated ();
   };
 };
 
diff --git a/lib/engine/components/loudmouth/loudmouth-main.cpp b/lib/engine/components/loudmouth/loudmouth-main.cpp
index 509eacd..562ec0e 100644
--- a/lib/engine/components/loudmouth/loudmouth-main.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-main.cpp
@@ -38,6 +38,7 @@
 #include "loudmouth-main.h"
 
 #include "presence-core.h"
+#include "personal-details.h"
 
 #include "loudmouth-cluster.h"
 #include "loudmouth-bank.h"
@@ -49,11 +50,12 @@ loudmouth_init (Ekiga::ServiceCore &services,
 {
   bool result = false;
   gmref_ptr<Ekiga::PresenceCore> presence (services.get ("presence-core"));
+  gmref_ptr<Ekiga::PersonalDetails> details (services.get ("personal-details"));
 
-  if (presence) {
+  if (presence && details) {
 
-    gmref_ptr<LM::Cluster> cluster(new LM::Cluster);
-    gmref_ptr<LM::Bank> bank (new LM::Bank (cluster));
+    gmref_ptr<LM::Cluster> cluster(new LM::Cluster ());
+    gmref_ptr<LM::Bank> bank (new LM::Bank (details, cluster));
     services.add (bank);
     presence->add_cluster (cluster);
     result = true;



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