Pin backends' names to global BACKEND_NAME to reduce magic strings.
authorTravis Reitter <travis.reitter@collabora.co.uk>
Tue, 4 Jan 2011 20:19:27 +0000 (12:19 -0800)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Thu, 6 Jan 2011 23:43:29 +0000 (15:43 -0800)
Helps bgo#638609 - libfolks hard-codes backend names for debugging

backends/key-file/Makefile.am
backends/key-file/kf-backend.vala
backends/key-file/kf-persona-store.vala
backends/telepathy/Makefile.am
backends/telepathy/backend.mk [new file with mode: 0644]
backends/telepathy/lib/Makefile.am
backends/telepathy/lib/tpf-persona-store.vala
backends/telepathy/tp-backend.vala

index ab5dab8..b6e3370 100644 (file)
@@ -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
index a2e720d..89c9932 100644 (file)
@@ -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}
index 16b3c79..a5ba6fd 100644 (file)
@@ -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.
index c3f0793..0be83a6 100644 (file)
@@ -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 (file)
index 0000000..26c695e
--- /dev/null
@@ -0,0 +1 @@
+BACKEND_NAME = telepathy
index 8db28c8..2d1f652 100644 (file)
@@ -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
index 116e5d8..0a95cd5 100644 (file)
@@ -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.
index 3595b23..35539b1 100644 (file)
@@ -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}