[folks] Pin backends' names to global BACKEND_NAME to reduce magic strings.



commit cf95d8dcce95840188c510d0f1cfe78af7a44ecc
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Tue Jan 4 12:19:27 2011 -0800

    Pin backends' names to global BACKEND_NAME to reduce magic strings.
    
    Helps bgo#638609 - libfolks hard-codes backend names for debugging

 backends/key-file/Makefile.am                 |    5 ++++-
 backends/key-file/kf-backend.vala             |    4 +++-
 backends/key-file/kf-persona-store.vala       |    2 +-
 backends/telepathy/Makefile.am                |    4 +++-
 backends/telepathy/backend.mk                 |    1 +
 backends/telepathy/lib/Makefile.am            |    4 +++-
 backends/telepathy/lib/tpf-persona-store.vala |    5 +++--
 backends/telepathy/tp-backend.vala            |    4 +++-
 8 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/backends/key-file/Makefile.am b/backends/key-file/Makefile.am
index ab5dab8..b6e3370 100644
--- a/backends/key-file/Makefile.am
+++ b/backends/key-file/Makefile.am
@@ -1,8 +1,11 @@
+BACKEND_NAME = "key-file"
+
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/folks \
 	-include $(CONFIG_HEADER) \
 	-DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-	-DG_LOG_DOMAIN=\"key-file\" \
+	-DBACKEND_NAME=\"$(BACKEND_NAME)\" \
+	-DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
 	$(NULL)
 
 backenddir = $(BACKEND_DIR)/key-file
diff --git a/backends/key-file/kf-backend.vala b/backends/key-file/kf-backend.vala
index a2e720d..89c9932 100644
--- a/backends/key-file/kf-backend.vala
+++ b/backends/key-file/kf-backend.vala
@@ -22,6 +22,8 @@ using GLib;
 using Folks;
 using Folks.Backends.Kf;
 
+extern const string BACKEND_NAME;
+
 /**
  * A backend which loads { link Persona}s from a simple key file in
  * (XDG_DATA_HOME/folks/) and presents them through a single
@@ -49,7 +51,7 @@ public class Folks.Backends.Kf.Backend : Folks.Backend
   /**
    * { inheritDoc}
    */
-  public override string name { get { return "key-file"; } }
+  public override string name { get { return BACKEND_NAME; } }
 
   /**
    * { inheritDoc}
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index 16b3c79..a5ba6fd 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -41,7 +41,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
   /**
    * { inheritDoc}
    */
-  public override string type_id { get { return "key-file"; } }
+  public override string type_id { get { return BACKEND_NAME; } }
 
   /**
    * Whether this PersonaStore can add { link Folks.Persona}s.
diff --git a/backends/telepathy/Makefile.am b/backends/telepathy/Makefile.am
index c3f0793..0be83a6 100644
--- a/backends/telepathy/Makefile.am
+++ b/backends/telepathy/Makefile.am
@@ -5,7 +5,8 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/backends/telepathy/lib \
 	-include $(CONFIG_HEADER) \
 	-DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-	-DG_LOG_DOMAIN=\"telepathy\" \
+	-DBACKEND_NAME=\"$(BACKEND_NAME)\" \
+	-DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
 	$(NULL)
 
 VALAFLAGS += \
@@ -56,4 +57,5 @@ GITIGNOREFILES = \
 	libfolks_backend_telepathy_la_vala.stamp \
 	$(NULL)
 
+-include backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/telepathy/backend.mk b/backends/telepathy/backend.mk
new file mode 100644
index 0000000..26c695e
--- /dev/null
+++ b/backends/telepathy/backend.mk
@@ -0,0 +1 @@
+BACKEND_NAME = telepathy
diff --git a/backends/telepathy/lib/Makefile.am b/backends/telepathy/lib/Makefile.am
index 8db28c8..2d1f652 100644
--- a/backends/telepathy/lib/Makefile.am
+++ b/backends/telepathy/lib/Makefile.am
@@ -2,7 +2,8 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/folks \
 	-include $(CONFIG_HEADER) \
 	-DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-	-DG_LOG_DOMAIN=\"telepathy\" \
+	-DBACKEND_NAME=\"$(BACKEND_NAME)\" \
+	-DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
 	$(NULL)
 
 VAPIGENFLAGS += \
@@ -174,4 +175,5 @@ EXTRA_DIST = \
 # a Vala library during distcheck otherwise
 noinst_HEADERS = $(tp_lowlevel_headers)
 
+-include ../backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 116e5d8..0a95cd5 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -24,6 +24,8 @@ using Gee;
 using TelepathyGLib;
 using Folks;
 
+extern const string BACKEND_NAME;
+
 /**
  * A persona store which is associated with a single Telepathy account. It will
  * create { link Persona}s for each of the contacts in the published, stored or
@@ -88,7 +90,6 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       GLib.List<Persona>? added, GLib.List<Persona>? removed);
   internal signal void group_removed (string group, GLib.Error? error);
 
-
   /**
    * The Telepathy account this store is based upon.
    */
@@ -101,7 +102,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
    *
    * See { link Folks.PersonaStore.type_id}.
    */
-  public override string type_id { get { return "telepathy"; } }
+  public override string type_id { get { return BACKEND_NAME; } }
 
   /**
    * Whether this PersonaStore can add { link Folks.Persona}s.
diff --git a/backends/telepathy/tp-backend.vala b/backends/telepathy/tp-backend.vala
index 3595b23..35539b1 100644
--- a/backends/telepathy/tp-backend.vala
+++ b/backends/telepathy/tp-backend.vala
@@ -23,6 +23,8 @@ using TelepathyGLib;
 using Folks;
 using Folks.Backends.Tp;
 
+extern const string BACKEND_NAME;
+
 /**
  * A backend which connects to the Telepathy accounts service and creates a
  * { link PersonaStore} for each valid account known to Telepathy.
@@ -36,7 +38,7 @@ public class Folks.Backends.Tp.Backend : Folks.Backend
   /**
    * { inheritDoc}
    */
-  public override string name { get { return "telepathy"; } }
+  public override string name { get { return BACKEND_NAME; } }
 
   /**
    * { inheritDoc}



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