[ekiga] Added a notion of "preferred contact" for local roster elements



commit 2429b9c867ac7fe7d66192b4a6b5394d4f54bed4
Author: Julien Puydt <jpuydt gnome org>
Date:   Thu Jul 2 14:38:07 2009 +0200

    Added a notion of "preferred contact" for local roster elements

 .../components/local-roster/local-presentity.cpp   |   35 ++++++++++++++++++++
 .../components/local-roster/local-presentity.h     |    7 ++++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/components/local-roster/local-presentity.cpp b/lib/engine/components/local-roster/local-presentity.cpp
index 93b998a..c3e7330 100644
--- a/lib/engine/components/local-roster/local-presentity.cpp
+++ b/lib/engine/components/local-roster/local-presentity.cpp
@@ -60,6 +60,20 @@ Local::Presentity::Presentity (Ekiga::ServiceCore &_core,
     xmlFree (xml_str);
   }
 
+  xml_str = xmlGetProp (node, (const xmlChar*)"preferred");
+  preferred = false;
+  if (xml_str != NULL) {
+
+    if (xmlStrEqual (xml_str, BAD_CAST "true")) {
+
+      preferred = true;
+    } else {
+
+      preferred = false;
+    }
+    xmlFree (xml_str);
+  }
+
   for (xmlNodePtr child = node->children ;
        child != NULL ;
        child = child->next) {
@@ -106,6 +120,7 @@ Local::Presentity::Presentity (Ekiga::ServiceCore &_core,
 {
   node = xmlNewNode (NULL, BAD_CAST "entry");
   xmlSetProp (node, BAD_CAST "uri", BAD_CAST uri.c_str ());
+  xmlSetProp (node, BAD_CAST "preferred", BAD_CAST "false");
   name_node = xmlNewChild (node, NULL,
 			   BAD_CAST "name",
 			   BAD_CAST robust_xmlEscape (node->doc,
@@ -224,6 +239,7 @@ Local::Presentity::edit_presentity ()
 			   "element of ekiga's internal roster"));
   request->text ("name", _("Name:"), name);
   request->text ("uri", _("Address:"), uri);
+  request->boolean ("preferred", _("Is a preferred contact"), preferred);
 
   request->editable_set ("groups", _("Choose groups:"),
 			 groups, all_groups);
@@ -242,6 +258,7 @@ Local::Presentity::edit_presentity_form_submitted (bool submitted,
   const std::string new_name = result.text ("name");
   const std::set<std::string> new_groups = result.editable_set ("groups");
   std::string new_uri = result.text ("uri");
+  bool new_preferred = result.boolean ("preferred");
   std::map<std::string, xmlNodePtr> future_group_nodes;
   size_t pos = new_uri.find_first_of (' ');
   if (pos != std::string::npos)
@@ -276,6 +293,18 @@ Local::Presentity::edit_presentity_form_submitted (bool submitted,
     }
   }
 
+  if (new_preferred != preferred) {
+
+    preferred = new_preferred;
+    if (preferred) {
+
+      xmlSetProp (node, BAD_CAST "preferred", BAD_CAST "true");
+    } else {
+
+      xmlSetProp (node, BAD_CAST "preferred", BAD_CAST "false");
+    }
+  }
+
   // the second loop looking for groups we weren't in but are now
   for (std::set<std::string>::const_iterator iter = new_groups.begin ();
        iter != new_groups.end ();
@@ -348,3 +377,9 @@ Local::Presentity::remove ()
   trigger_saving.emit ();
   removed.emit ();
 }
+
+bool
+Local::Presentity::is_preferred () const
+{
+  return preferred;
+}
diff --git a/lib/engine/components/local-roster/local-presentity.h b/lib/engine/components/local-roster/local-presentity.h
index 9a0ab58..758b173 100644
--- a/lib/engine/components/local-roster/local-presentity.h
+++ b/lib/engine/components/local-roster/local-presentity.h
@@ -134,6 +134,12 @@ namespace Local
     xmlNodePtr get_node () const;
 
 
+    /** Tells if the contact is in the preferred list
+     *
+     * @return: Whether the contact is preferred
+     */
+    bool is_preferred () const;
+
     /** Rename the given group, if this Presentity belongs to it
      *
      */
@@ -188,6 +194,7 @@ namespace Local
     std::string presence;
     std::string status;
     std::string avatar;
+    bool preferred;
 
     std::map<std::string, xmlNodePtr> group_nodes;
     std::set<std::string> groups;



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