[ekiga] Made it possible to edit a loudmouth account



commit b7865fbccab091f93398314fc42300fe085746b1
Author: Julien Puydt <jpuydt gnome org>
Date:   Thu Jun 11 16:08:17 2009 +0200

    Made it possible to edit a loudmouth account
    
    Still only in-memory : the changes are not effective from a run
    to another.

 .../components/loudmouth/loudmouth-account.cpp     |   55 ++++++++++++++++++++
 .../components/loudmouth/loudmouth-account.h       |    4 ++
 2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/components/loudmouth/loudmouth-account.cpp b/lib/engine/components/loudmouth/loudmouth-account.cpp
index 1210f05..c7ded6c 100644
--- a/lib/engine/components/loudmouth/loudmouth-account.cpp
+++ b/lib/engine/components/loudmouth/loudmouth-account.cpp
@@ -33,8 +33,11 @@
  *
  */
 
+#include <iostream>
 #include <glib/gi18n.h>
 
+#include "form-request-simple.h"
+
 #include "loudmouth-account.h"
 
 /* here come the C callbacks, which just push to C++ code */
@@ -267,6 +270,53 @@ LM::Account::get_node () const
   return node;
 }
 
+void
+LM::Account::edit ()
+{
+  Ekiga::FormRequestSimple request(sigc::mem_fun (this,
+						  &LM::Account::on_edit_form_submitted));
+
+  request.title (_("Edit account"));
+
+  request.instructions (_("Please update the following fields:"));
+
+  request.text ("name", _("Name:"), name);
+  request.text ("user", _("User:"), user);
+  request.text ("server", _("Server:"), server);
+  request.text ("resource", _("Resource:"), resource);
+  request.private_text ("password", _("Password:"), password);
+  request.boolean ("enabled", _("Enable account"), enable_on_startup);
+
+  if (!questions.handle_request (&request)) {
+
+    // FIXME: better error reporting
+#ifdef __GNUC__
+    std::cout << "Unhandled form request in "
+	      << __PRETTY_FUNCTION__ << std::endl;
+#endif
+  }
+}
+
+void
+LM::Account::on_edit_form_submitted (bool submitted,
+				     Ekiga::Form &result)
+{
+  if (!submitted)
+    return;
+
+  disable (); // don't stay connected!
+
+  name = result.text ("name");
+  user = result.text ("user");
+  server = result.text ("server");
+  resource = result.text ("resource");
+  password = result.private_text ("password");
+  enable_on_startup = result.boolean ("enabled");
+
+  if (enable_on_startup)
+    enable ();
+}
+
 bool
 LM::Account::populate_menu (Ekiga::MenuBuilder& builder)
 {
@@ -280,5 +330,10 @@ LM::Account::populate_menu (Ekiga::MenuBuilder& builder)
 			sigc::mem_fun (this, &LM::Account::enable));
   }
 
+  builder.add_separator ();
+
+  builder.add_action ("edit", _("Edit"),
+		      sigc::mem_fun (this, &LM::Account::edit));
+
   return true;
 }
diff --git a/lib/engine/components/loudmouth/loudmouth-account.h b/lib/engine/components/loudmouth/loudmouth-account.h
index fa11dd0..fb57258 100644
--- a/lib/engine/components/loudmouth/loudmouth-account.h
+++ b/lib/engine/components/loudmouth/loudmouth-account.h
@@ -80,6 +80,10 @@ namespace LM
 
   private:
 
+    void edit ();
+    void on_edit_form_submitted (bool submitted,
+				 Ekiga::Form &result);
+
     gmref_ptr<Ekiga::PersonalDetails> details;
     gmref_ptr<Dialect> dialect;
     gmref_ptr<Cluster> cluster;



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