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



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

Log:
Better RL::List

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

Modified: trunk/lib/engine/components/resource-list/rl-heap.cpp
==============================================================================
--- trunk/lib/engine/components/resource-list/rl-heap.cpp	(original)
+++ trunk/lib/engine/components/resource-list/rl-heap.cpp	Thu Oct 16 12:34:13 2008
@@ -316,7 +316,6 @@
 	list->entry_added.connect (sigc::mem_fun (this, &RL::Heap::on_entry_added));
 	list->entry_updated.connect (sigc::mem_fun (this, &RL::Heap::on_entry_updated));
 	list->entry_removed.connect (sigc::mem_fun (this, &RL::Heap::on_entry_removed));
-	list->publish ();
 	lists.push_back (list);
 	pos++;
 	continue;

Modified: trunk/lib/engine/components/resource-list/rl-list.cpp
==============================================================================
--- trunk/lib/engine/components/resource-list/rl-list.cpp	(original)
+++ trunk/lib/engine/components/resource-list/rl-list.cpp	Thu Oct 16 12:34:13 2008
@@ -61,14 +61,15 @@
   void push_status (const std::string uri_,
 		    const std::string status);
 
-  void publish ();
-
   std::string compute_path () const;
 
   void flush ();
 
   void refresh ();
 
+  void on_xcap_answer (XCAP::Core::ResultType result,
+		       std::string value);
+
   void parse ();
 
   /* data for itself */
@@ -130,12 +131,6 @@
   return impl->flush ();
 }
 
-void
-RL::List::publish ()
-{
-  return impl->publish ();
-}
-
 bool
 RL::List::has_name (const std::string name) const
 {
@@ -184,7 +179,6 @@
     }
     position_name = raw;
     g_free (raw);
-
   }
 
   display_name = position_name; // will be set to better when we get the data
@@ -206,6 +200,7 @@
   } else {
 
     path = path_;
+    refresh ();
   }
 }
 
@@ -244,45 +239,45 @@
       conn_iter->disconnect ();
   }
   entries.clear ();
+
+  if (doc != NULL)
+    xmlFreeDoc (doc);
+  doc = NULL;
+  node = NULL;
+  name_node = NULL;
 }
 
 void
-RL::ListImpl::publish ()
+RL::ListImpl::refresh ()
 {
-  std::list<gmref_ptr<List> >::const_iterator list_iter = lists.begin ();
-  std::list<std::pair<gmref_ptr<Entry>, std::list<sigc::connection> > >::const_iterator entry_iter = entries.begin ();
-
-  for (std::list<ChildType>::const_iterator iter = ordering.begin ();
-       iter != ordering.end ();
-       ++iter) {
-
-    switch (*iter) {
-
-    case LIST:
-      (*list_iter)->publish ();
-      ++list_iter;
-      break;
-
-    case ENTRY:
-      entry_added.emit (entry_iter->first);
-      ++entry_iter;
-      break;
+  flush ();
 
-    default:
-      break;// nothing
-    }
-  }
+  gmref_ptr<XCAP::Core> xcap = core.get ("xcap-core");
+  xcap->read (path, sigc::mem_fun (this, &RL::ListImpl::on_xcap_answer));
 }
 
 void
-RL::ListImpl::refresh ()
+RL::ListImpl::on_xcap_answer (XCAP::Core::ResultType result,
+			      std::string value)
 {
-  flush ();
+  if (result != XCAP::Core::SUCCESS) {
+
+    // FIXME: how to properly tell the user?
 
-  /* FIXME:
-   * - fetch the document
-   * - call parse
-   */
+  } else {
+
+    doc = xmlRecoverMemory (value.c_str (), value.length ());
+    node = xmlDocGetRootElement (doc);
+    if (node == NULL
+	|| node->name == NULL
+	|| !xmlStrEqual (BAD_CAST "list", node->name)) {
+
+      // FIXME : how to properly tell the user?
+    } else {
+
+      parse ();
+    }
+  }
 }
 
 void

Modified: trunk/lib/engine/components/resource-list/rl-list.h
==============================================================================
--- trunk/lib/engine/components/resource-list/rl-list.h	(original)
+++ trunk/lib/engine/components/resource-list/rl-list.h	Thu Oct 16 12:34:13 2008
@@ -79,13 +79,6 @@
     /* this method orders the list to get rid of all its children */
     void flush ();
 
-    /* this method makes the list publish what it has
-     * (it needs a method to be done, because we fetch on creation,
-     *  which means the owner may not have had the time to connect to
-     *  our signals yet)
-     */
-    void publish ();
-
   private:
 
     ListImpl *impl;



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