ekiga r6730 - in trunk/lib/engine: components/gmconf-personal-details framework



Author: jpuydt
Date: Sat Aug 30 07:02:12 2008
New Revision: 6730
URL: http://svn.gnome.org/viewvc/ekiga?rev=6730&view=rev

Log:
Cleaned the PersonalDetails code

Removed:
   trunk/lib/engine/framework/personal-details.cpp
Modified:
   trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details-main.cpp
   trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
   trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h
   trunk/lib/engine/framework/Makefile.am
   trunk/lib/engine/framework/personal-details.h

Modified: trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details-main.cpp
==============================================================================
--- trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details-main.cpp	(original)
+++ trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details-main.cpp	Sat Aug 30 07:02:12 2008
@@ -44,11 +44,19 @@
                               int * /*argc*/,
                               char ** /*argv*/[])
 {
-  Ekiga::PersonalDetails *personal_details = NULL;
+  bool result = false;
+  Ekiga::PersonalDetails* personal_details = NULL;
+  Gmconf::PersonalDetails* gmconf_details = NULL;
 
-  personal_details = new Gmconf::PersonalDetails ();
-  
-  core.add (*personal_details);
+  personal_details
+    = dynamic_cast<Ekiga::PersonalDetails*>(core.get ("personal-details"));
 
-  return true;
+  if (personal_details == NULL) {
+
+    gmconf_details = new Gmconf::PersonalDetails ();
+    core.add (*gmconf_details);
+    result = true;
+  }
+
+  return result;
 }

Modified: trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
==============================================================================
--- trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp	(original)
+++ trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp	Sat Aug 30 07:02:12 2008
@@ -39,65 +39,88 @@
 #include "gmconf.h"
 #include "gmconf-personal-details.h"
 
-using namespace Gmconf;
-
 static void
-display_name_changed_nt (gpointer /*id*/,
-                         GmConfEntry *entry,
-                         gpointer data)
-{
-  PersonalDetails *details = (PersonalDetails *) data;
-  const gchar *name = NULL;
-
-  if (gm_conf_entry_get_type (entry) == GM_CONF_STRING) {
-
-    name = gm_conf_entry_get_string (entry);
-    if (name != NULL)
-      details->set_display_name (name);
-  }
+something_changed_nt (G_GNUC_UNUSED gpointer id,
+		      G_GNUC_UNUSED GmConfEntry* entry,
+		      gpointer data)
+{
+  Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
+
+  details->something_changed ();
 }
 
-static void
-short_status_changed_nt (gpointer /*id*/,
-                         GmConfEntry *entry,
-                         gpointer data)
-{
-  PersonalDetails *details = (PersonalDetails *) data;
-  const gchar *status = NULL;
-
-  if (gm_conf_entry_get_type (entry) == GM_CONF_STRING) {
-
-    status = gm_conf_entry_get_string (entry);
-    if (status != NULL)
-      details->set_short_status (status);
-  }
+Gmconf::PersonalDetails::PersonalDetails ()
+{
+  gm_conf_notifier_add ("/apps/ekiga/general/personal_data/full_name",
+                        something_changed_nt, this);
+  gm_conf_notifier_add ("/apps/ekiga/general/personal_data/short_status",
+                        something_changed_nt, this);
+  gm_conf_notifier_add ("/apps/ekiga/general/personal_data/long_status",
+                        something_changed_nt, this);
 }
 
-static void
-long_status_changed_nt (gpointer /*id*/,
-                        GmConfEntry *entry,
-                        gpointer data)
+const std::string
+Gmconf::PersonalDetails::get_display_name () const
 {
-  PersonalDetails *details = (PersonalDetails *) data;
-  const gchar *status = NULL;
+  gchar* str = NULL;
 
-  if (gm_conf_entry_get_type (entry) == GM_CONF_STRING) {
+  str = gm_conf_get_string ("/apps/ekiga/general/personal_data/full_name");
 
-    status = gm_conf_entry_get_string (entry);
-    if (status != NULL)
-      details->set_long_status (status);
-  }
+  if (str != NULL)
+    return str;
+  else
+    return "";
 }
 
-PersonalDetails::PersonalDetails ()
+const std::string
+Gmconf::PersonalDetails::get_short_status () const
 {
-  gm_conf_notifier_add ("/apps/ekiga/general/personal_data/full_name",
-                        display_name_changed_nt, this);
-  gm_conf_notifier_add ("/apps/ekiga/general/personal_data/short_status",
-                        short_status_changed_nt, this);
-  gm_conf_notifier_add ("/apps/ekiga/general/personal_data/long_status",
-                        long_status_changed_nt, this);
-  gm_conf_notifier_trigger ("/apps/ekiga/general/personal_data/full_name");
-  gm_conf_notifier_trigger ("/apps/ekiga/general/personal_data/short_status");
-  gm_conf_notifier_trigger ("/apps/ekiga/general/personal_data/long_status");
+  gchar* str = NULL;
+
+  str = gm_conf_get_string ("/apps/ekiga/general/personal_data/short_status");
+
+  if (str != NULL)
+    return str;
+  else
+    return "";
+}
+
+const std::string
+Gmconf::PersonalDetails::get_long_status () const
+{
+  gchar* str = NULL;
+
+  str = gm_conf_get_string ("/apps/ekiga/general/personal_data/long_status");
+
+  if (str != NULL)
+    return str;
+  else
+    return "";
+}
+
+void
+Gmconf::PersonalDetails::set_display_name (const std::string display_name)
+{
+  gm_conf_set_string ("/apps/ekiga/general/personal_data/full_name",
+		      display_name.c_str ());
+}
+
+void
+Gmconf::PersonalDetails::set_short_status (const std::string short_status)
+{
+  gm_conf_set_string ("/apps/ekiga/general/personal_data/short_status",
+		      short_status.c_str ());
+}
+
+void
+Gmconf::PersonalDetails::set_long_status (const std::string long_status)
+{
+  gm_conf_set_string ("/apps/ekiga/general/personal_data/long_status",
+		      long_status.c_str ());
+}
+
+void
+Gmconf::PersonalDetails::something_changed ()
+{
+  updated.emit ();
 }

Modified: trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h
==============================================================================
--- trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h	(original)
+++ trunk/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h	Sat Aug 30 07:02:12 2008
@@ -41,14 +41,42 @@
 
 namespace Gmconf
 {
-  class PersonalDetails 
-    : public Ekiga::PersonalDetails
+  class PersonalDetails: public Ekiga::Service,
+			 public Ekiga::PersonalDetails
   {
   public:
 
     PersonalDetails ();
 
     virtual ~PersonalDetails () {};
+
+    /*** Service Implementation ***/
+  public:
+
+    const std::string get_name () const
+    { return "personal-details"; }
+
+    const std::string get_description () const
+    { return "\tPersonal details management object (using gmconf)"; }
+
+    /*** PersonalDetails Implementation ***/
+  public:
+
+    const std::string get_display_name () const;
+
+    const std::string get_short_status () const;
+
+    const std::string get_long_status () const;
+
+    void set_display_name (const std::string display_name);
+
+    void set_short_status (const std::string short_status);
+
+    void set_long_status (const std::string long_status);
+
+    /*** public but only to be called by C callbacks ***/
+  public:
+    void something_changed ();
   };
 };
 

Modified: trunk/lib/engine/framework/Makefile.am
==============================================================================
--- trunk/lib/engine/framework/Makefile.am	(original)
+++ trunk/lib/engine/framework/Makefile.am	Sat Aug 30 07:02:12 2008
@@ -37,7 +37,6 @@
 	$(framework_dir)/trigger.h \
 	$(framework_dir)/menu-xml.h \
 	$(framework_dir)/menu-xml.cpp \
-	$(framework_dir)/personal-details.h \
-	$(framework_dir)/personal-details.cpp
+	$(framework_dir)/personal-details.h
 
 libgmframework_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS) $(GLIB_LIBS) $(XML_LIBS)

Modified: trunk/lib/engine/framework/personal-details.h
==============================================================================
--- trunk/lib/engine/framework/personal-details.h	(original)
+++ trunk/lib/engine/framework/personal-details.h	Sat Aug 30 07:02:12 2008
@@ -43,49 +43,26 @@
 
 namespace Ekiga
 {
-  class PersonalDetails 
-    : public Service
+  class PersonalDetails
   {
   public:
-    PersonalDetails () { };
+    PersonalDetails () {}
 
     virtual ~PersonalDetails () {}
 
+    virtual const std::string get_display_name () const = 0;
 
-    /*** Service Implementation ***/
-  public:
-    /** Returns the name of the service.
-     * @return The service name.
-     */
-    const std::string get_name () const
-    { return "personal-details"; }
-
-    /** Returns the description of the service.
-     * @return The service description.
-     */
-    const std::string get_description () const
-    { return "\tPersonal details management object"; }
-
+    virtual const std::string get_short_status () const = 0;
 
-    /*** PersonalDetails API ***/
-    const std::string & get_display_name () const;
+    virtual const std::string get_long_status () const = 0;
 
-    const std::string & get_short_status () const;
+    virtual void set_display_name (const std::string display_name) = 0;
 
-    const std::string & get_long_status () const;
+    virtual void set_short_status (const std::string short_status) = 0;
 
-    void set_display_name (const std::string & display_name);
-
-    void set_short_status (const std::string & short_status);
-
-    void set_long_status (const std::string & long_status);
+    virtual void set_long_status (const std::string long_status) = 0;
 
     sigc::signal<void> updated;
-
-  private:
-    std::string display_name;
-    std::string short_status;
-    std::string long_status;
   };
 };
 



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