[ekiga] Accounts/Contacts: Uniformised the way we add & edit.



commit 1a65fe46713bfba552e535401281f6f41191e2fc
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Nov 1 17:05:32 2015 +0100

    Accounts/Contacts: Uniformised the way we add & edit.
    
    When registering an Ekiga.net contact, we only ask for the username.
    There is no reason why we would ask for the full URI when adding or
    editing an Ekiga.net contact.
    
    Also use the term "Username" instead of "User". It is probably more
    intuitive.

 lib/engine/components/opal/opal-account.cpp    |   27 +++++++++++++---------
 lib/engine/components/opal/opal-bank.cpp       |    4 +-
 lib/engine/components/opal/opal-presentity.cpp |   29 ++++++++++++++++++-----
 lib/engine/components/opal/opal-presentity.h   |    2 +
 4 files changed, 42 insertions(+), 20 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 28a0085..b413a5c 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -222,12 +222,8 @@ Opal::Account::Account (Opal::Bank & _bank,
   }
 
   /* Actor stuff */
-
-  /* Translators: Example: Add ekiga.net Contact */
-  char *text = g_strdup_printf (_("A_dd %s Contact"), get_host ().c_str ());
-  add_action (Ekiga::ActionPtr (new Ekiga::Action ("add-contact", text,
+  add_action (Ekiga::ActionPtr (new Ekiga::Action ("add-contact", _("Add Contact"),
                                                    boost::bind (&Opal::Account::add_contact, this))));
-  g_free (text);
   add_action (Ekiga::ActionPtr (new Ekiga::Action ("edit-account", _("_Edit"),
                                                    boost::bind (&Opal::Account::edit, this))));
   add_action (Ekiga::ActionPtr (new Ekiga::Action ("remove-account", _("_Remove"),
@@ -704,7 +700,7 @@ Opal::Account::edit ()
   case Opal::Account::Ekiga:
     request->hidden ("name", get_name ());
     request->hidden ("host", get_host ());
-    request->text ("user", _("_User"), get_username (), _("jon"),
+    request->text ("user", _("_Username"), get_username (), _("jon"),
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->hidden ("authentication_user", get_authentication_username ());
     request->text ("password", _("_Password"), get_password (), _("1234"),
@@ -730,7 +726,7 @@ Opal::Account::edit ()
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->text ("host", _("_Gatekeeper"), get_host (), _("ekiga.net"),
                    Ekiga::FormVisitor::STANDARD, false, false);
-    request->text ("user", _("_User"), get_username (), _("jon"),
+    request->text ("user", _("_Username"), get_username (), _("jon"),
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->text ("password", _("_Password"), get_password (), _("1234"),
                    Ekiga::FormVisitor::PASSWORD, false, false);
@@ -743,7 +739,7 @@ Opal::Account::edit ()
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->text ("host", _("_Registrar"), get_host (), _("ekiga.net"),
                    Ekiga::FormVisitor::STANDARD, false, false);
-    request->text ("user", _("_User"), get_username (), _("jon"),
+    request->text ("user", _("_Username"), get_username (), _("jon"),
                    Ekiga::FormVisitor::STANDARD, false, false);
     /* Translators:
      * SIP knows two usernames: The name for the client ("User") and the name
@@ -892,8 +888,12 @@ Opal::Account::add_contact ()
   request->text ("name", _("_Name"), std::string (), _("John Doe"),
                  Ekiga::FormVisitor::STANDARD, false, false);
 
-  request->text ("uri", _("_URI"), "sip:", "sip:john doe ekiga net",
-                 Ekiga::FormVisitor::URI, false, false);
+  if (type == Opal::Account::Ekiga)
+    request->text ("user", _("_Username"), std::string (), _("jon"),
+                   Ekiga::FormVisitor::STANDARD, false, false);
+  else
+    request->text ("uri", _("_URI"), "sip:", "sip:john doe ekiga net",
+                   Ekiga::FormVisitor::URI, false, false);
 
   request->editable_list ("groups",
                           _("Groups"),
@@ -914,7 +914,12 @@ Opal::Account::on_add_contact_form_submitted (bool submitted,
   std::string uri;
   const std::list<std::string> groups = result.editable_list ("groups");
 
-  uri = result.text ("uri");
+  if (type == Opal::Account::Ekiga) {
+    uri = result.text ("user");
+    uri += "@ekiga.net";
+  }
+  else
+    uri = result.text ("uri");
   uri = canonize_uri (uri);
 
   if (!is_supported_uri (uri)) {
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index e9161e8..adf6585 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -202,7 +202,7 @@ Opal::Bank::new_account (Account::Type acc_type,
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->text ("host", _("_Gatekeeper"), std::string (), _("h323.ekiga.net"),
                    Ekiga::FormVisitor::STANDARD, false, false);
-    request->text ("user", _("_User"), username, _("jon"),
+    request->text ("user", _("_Username"), username, _("jon"),
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->hidden ("authentication_user", username);
     request->text ("password", _("_Password"), password, _("1234"),
@@ -217,7 +217,7 @@ Opal::Bank::new_account (Account::Type acc_type,
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->text ("host", _("_Registrar"), std::string (), _("ekiga.net"),
                    Ekiga::FormVisitor::STANDARD, false, false);
-    request->text ("user", _("_User"), username, _("jon"),
+    request->text ("user", _("_Username"), username, _("jon"),
                    Ekiga::FormVisitor::STANDARD, false, false);
     request->text ("authentication_user", _("_Login"), std::string (), _("jon.doe"),
                    Ekiga::FormVisitor::STANDARD, true, true);
diff --git a/lib/engine/components/opal/opal-presentity.cpp b/lib/engine/components/opal/opal-presentity.cpp
index b877c08..e9c3079 100644
--- a/lib/engine/components/opal/opal-presentity.cpp
+++ b/lib/engine/components/opal/opal-presentity.cpp
@@ -35,6 +35,7 @@
 #include <algorithm>
 #include <set>
 #include <glib/gi18n.h>
+#include <boost/algorithm/string.hpp>
 
 #include "form-request-simple.h"
 #include "robust-xml.h"
@@ -123,6 +124,8 @@ Opal::Presentity::Presentity (const Opal::Account & account_,
   node(node_),
   presence("unknown")
 {
+  if (get_uri ().find ("@ekiga.net"))
+    type = Opal::Presentity::Ekiga;
 }
 
 
@@ -282,11 +285,19 @@ Opal::Presentity::edit_presentity ()
                  _("John Doe"),
                  Ekiga::FormVisitor::STANDARD,
                  false, false);
-  request->text ("uri", _("URI"),
-                 get_uri (),
-                 _("sip:username ekiga net"),
-                 Ekiga::FormVisitor::URI,
-                 false, false);
+  if (type == Opal::Presentity::Ekiga) {
+    std::string user = get_uri ();
+    boost::replace_all (user, "sip:", "");
+    boost::replace_all (user, "@ekiga.net", "");
+    request->text ("user", _("_Username"), user, _("jon"),
+                   Ekiga::FormVisitor::STANDARD, false, false);
+  }
+  else
+    request->text ("uri", _("URI"),
+                   get_uri (),
+                   _("sip:username ekiga net"),
+                   Ekiga::FormVisitor::URI,
+                   false, false);
 
   request->editable_list ("groups", _("Groups"),
                         get_groups (), existing_groups ());
@@ -318,8 +329,12 @@ Opal::Presentity::edit_presentity_form_submitted (bool submitted,
     error = _("You did not provide a valid address");
     return false;
   }
-
-  new_uri = canonize_uri (new_uri);
+  if (type == Opal::Presentity::Ekiga) {
+    new_uri = result.text ("user");
+    new_uri += "@ekiga.net";
+  }
+  else
+    new_uri = canonize_uri (new_uri);
 
   for (xmlNodePtr child = node->children ;
        child != NULL ;
diff --git a/lib/engine/components/opal/opal-presentity.h b/lib/engine/components/opal/opal-presentity.h
index d29498e..d312fed 100644
--- a/lib/engine/components/opal/opal-presentity.h
+++ b/lib/engine/components/opal/opal-presentity.h
@@ -63,6 +63,7 @@ namespace Opal
       public Ekiga::DynamicObject<Presentity>
   {
   public:
+    typedef enum { SIP, Ekiga, DiamondCard, H323 } Type;
 
     /* build a node describing a valid presentity, which the caller
      * will then use to create a valid instance using the ctor */
@@ -142,6 +143,7 @@ namespace Opal
 
     std::string presence;
     std::string status;
+    Type type;
   };
 
   typedef boost::shared_ptr<Presentity> PresentityPtr;


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