ekiga r7230 - trunk/lib/engine/components/resource-list



Author: jpuydt
Date: Thu Oct 16 12:33:48 2008
New Revision: 7230
URL: http://svn.gnome.org/viewvc/ekiga?rev=7230&view=rev

Log:
Better RL::Entry

Modified:
   trunk/lib/engine/components/resource-list/rl-entry.cpp
   trunk/lib/engine/components/resource-list/rl-entry.h

Modified: trunk/lib/engine/components/resource-list/rl-entry.cpp
==============================================================================
--- trunk/lib/engine/components/resource-list/rl-entry.cpp	(original)
+++ trunk/lib/engine/components/resource-list/rl-entry.cpp	Thu Oct 16 12:33:48 2008
@@ -71,6 +71,7 @@
   } else {
 
     path = path_;
+    refresh ();
   }
 }
 
@@ -80,22 +81,20 @@
     xmlFreeDoc (doc);
 }
 
-bool
-RL::Entry::is_positional () const
-{
-  return get_uri ().empty ();
-}
-
 const std::string
 RL::Entry::get_uri () const
 {
   std::string result;
-  xmlChar* str = xmlGetProp (node, (const xmlChar*) "uri");
 
-  if (str != NULL) {
+  if (node != NULL) {
 
-    result = ((const char*)str);
-    xmlFree (str);
+    xmlChar* str = xmlGetProp (node, (const xmlChar*) "uri");
+
+    if (str != NULL) {
+
+      result = ((const char*)str);
+      xmlFree (str);
+    }
   }
 
   return result;
@@ -120,12 +119,18 @@
 RL::Entry::get_name () const
 {
   std::string result;
-  xmlChar* str = xmlNodeGetContent (name_node);
 
-  if (str != NULL) {
+  if (name_node != NULL) {
 
-    result = ((const char*)str);
-    xmlFree (str);
+    xmlChar* str = xmlNodeGetContent (name_node);
+    if (str != NULL) {
+
+      result = ((const char*)str);
+      xmlFree (str);
+    }
+  } else {
+
+    result = _("Unnamed");
   }
 
   return result;
@@ -152,8 +157,42 @@
 void
 RL::Entry::refresh ()
 {
-  /* FIXME: here we should fetch the document, then parse it */
-  std::cout << "Refreshing on " << path << std::endl;
+  if (doc != NULL)
+    xmlFreeDoc (doc);
+  doc = NULL;
+  node = NULL;
+  name_node = NULL;
+  presence = "unknown";
+  status = _("");
+  updated.emit ();
+
+  gmref_ptr<XCAP::Core> xcap = core.get ("xcap-core");
+  xcap->read (path, sigc::mem_fun (this, &RL::Entry::on_xcap_answer));
+}
+
+void
+RL::Entry::on_xcap_answer (XCAP::Core::ResultType result,
+			   std::string value)
+{
+  if (result != XCAP::Core::SUCCESS) {
+
+    set_status (value);
+
+  } else {
+
+    doc = xmlRecoverMemory (value.c_str (), value.length ());
+    node = xmlDocGetRootElement (doc);
+    if (node == NULL
+	|| node->name == NULL
+	|| !xmlStrEqual (BAD_CAST "entry", node->name)) {
+
+      set_status (_("Invalid server data"));
+    } else {
+
+      parse ();
+      updated.emit ();
+    }
+  }
 }
 
 void

Modified: trunk/lib/engine/components/resource-list/rl-entry.h
==============================================================================
--- trunk/lib/engine/components/resource-list/rl-entry.h	(original)
+++ trunk/lib/engine/components/resource-list/rl-entry.h	Thu Oct 16 12:33:48 2008
@@ -40,7 +40,7 @@
 
 #include "services.h"
 #include "presentity.h"
-#include "xcap-path.h"
+#include "xcap-core.h"
 
 #include <libxml/tree.h>
 
@@ -60,12 +60,7 @@
 
     ~Entry ();
 
-    /* the part of the interface which helps the list manage this element */
-
-    bool is_positional () const;
-
     /* needed so presence can be pushed into this presentity */
-
     const std::string get_uri () const;
 
     void set_presence (const std::string presence_);
@@ -106,6 +101,8 @@
     std::string status;
 
     void refresh ();
+    void on_xcap_answer (XCAP::Core::ResultType,
+			 std::string value);
     void parse ();
   };
 };



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