From c8f9b3ed9efb2256c5d9e87a27c807528e29139f Mon Sep 17 00:00:00 2001 From: Travis Reitter Date: Fri, 7 Oct 2011 11:26:30 -0700 Subject: [PATCH] Split utility functions into an internal library. This lets us avoid stuffing them into unrelated public libraries. --- backends/eds/lib/Makefile.am | 2 ++ backends/eds/lib/edsf-persona-store.vala | 2 +- backends/eds/lib/edsf-persona.vala | 12 +++++----- backends/telepathy/lib/Makefile.am | 2 ++ backends/telepathy/lib/tpf-persona.vala | 5 ++-- folks/Makefile.am | 41 +++++++++++++++++++++++++++++++- folks/internal.vala | 38 +++++++++++++++++++++++++++++ folks/persona-store.vala | 14 ----------- 8 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 folks/internal.vala diff --git a/backends/eds/lib/Makefile.am b/backends/eds/lib/Makefile.am index 2e52c43..1c4c02e 100644 --- a/backends/eds/lib/Makefile.am +++ b/backends/eds/lib/Makefile.am @@ -45,6 +45,7 @@ libfolks_eds_la_VALAFLAGS = \ --vapidir=. \ --vapidir=$(top_srcdir)/folks \ --pkg folks \ + --pkg folks-internal \ --pkg gee-1.0 \ --pkg gio-2.0 \ --pkg gobject-2.0 \ @@ -67,6 +68,7 @@ libfolks_eds_la_CFLAGS = \ libfolks_eds_la_LIBADD = \ $(top_builddir)/folks/libfolks.la \ + $(top_builddir)/folks/libfolks-internal.la \ $(EBOOK_LIBS) \ $(EDATASERVER_LIBS) \ $(GIO_LIBS) \ diff --git a/backends/eds/lib/edsf-persona-store.vala b/backends/eds/lib/edsf-persona-store.vala index cf0b363..6c1bca6 100644 --- a/backends/eds/lib/edsf-persona-store.vala +++ b/backends/eds/lib/edsf-persona-store.vala @@ -1481,7 +1481,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore _("Roles are not writeable on this contact.")); } - if (Folks.PersonaStore.equal_sets (roles, persona.roles)) + if (Folks.Internal.equal_sets (roles, persona.roles)) return; yield this._set_contact_roles (persona.contact, roles); diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala index 22cfc28..e2079d8 100644 --- a/backends/eds/lib/edsf-persona.vala +++ b/backends/eds/lib/edsf-persona.vala @@ -938,7 +938,7 @@ public class Edsf.Persona : Folks.Persona, new_roles.add (role_fd); } - if (!Folks.PersonaStore.equal_sets (new_roles, this._roles)) + if (!Folks.Internal.equal_sets (new_roles, this._roles)) { this._roles = new_roles; this._roles_ro = new_roles.read_only_view; @@ -1034,7 +1034,7 @@ public class Edsf.Persona : Folks.Persona, new_email_addresses.add (email_fd); } - if (!Folks.PersonaStore.equal_sets (new_email_addresses, + if (!Folks.Internal.equal_sets (new_email_addresses, this._email_addresses)) { this._email_addresses = new_email_addresses; @@ -1056,7 +1056,7 @@ public class Edsf.Persona : Folks.Persona, new_notes.add (note); } - if (!Folks.PersonaStore.equal_sets (new_notes, this._notes)) + if (!Folks.Internal.equal_sets (new_notes, this._notes)) { this._notes = new_notes; this._notes_ro = this._notes.read_only_view; @@ -1412,7 +1412,7 @@ public class Edsf.Persona : Folks.Persona, new_phone_numbers.add (phone_fd); } - if (!Folks.PersonaStore.equal_sets (new_phone_numbers, + if (!Folks.Internal.equal_sets (new_phone_numbers, this._phone_numbers)) { this._phone_numbers = new_phone_numbers; @@ -1496,7 +1496,7 @@ public class Edsf.Persona : Folks.Persona, new_postal_addresses.add (pa_fd); } - if (!Folks.PersonaStore.equal_sets ( + if (!Folks.Internal.equal_sets ( new_postal_addresses, this._postal_addresses)) { @@ -1526,7 +1526,7 @@ public class Edsf.Persona : Folks.Persona, /* Make sure it includes our local id */ new_local_ids.add (this.iid); - if (!Folks.PersonaStore.equal_sets (new_local_ids, this.local_ids)) + if (!Folks.Internal.equal_sets (new_local_ids, this.local_ids)) { this._local_ids = new_local_ids; this._local_ids_ro = this._local_ids.read_only_view; diff --git a/backends/telepathy/lib/Makefile.am b/backends/telepathy/lib/Makefile.am index 7129e3e..4523c7e 100644 --- a/backends/telepathy/lib/Makefile.am +++ b/backends/telepathy/lib/Makefile.am @@ -110,6 +110,7 @@ libfolks_telepathy_la_VALAFLAGS = \ --vapidir=. \ --vapidir=$(top_srcdir)/folks \ --pkg folks \ + --pkg folks-internal \ --pkg tp-lowlevel \ --pkg gobject-2.0 \ --pkg gio-2.0 \ @@ -133,6 +134,7 @@ libfolks_telepathy_la_LIBADD = \ $(GEE_LIBS) \ $(TP_GLIB_LIBS) \ $(top_builddir)/folks/libfolks.la \ + $(top_builddir)/folks/libfolks-internal.la \ $(NULL) # The quoting here is unnecessary but harmless, and has the useful side-effect diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala index c18ebec..546f58d 100644 --- a/backends/telepathy/lib/tpf-persona.vala +++ b/backends/telepathy/lib/tpf-persona.vala @@ -403,8 +403,7 @@ public class Tpf.Persona : Folks.Persona, { var tpf_store = this.store as Tpf.PersonaStore; - if (Folks.PersonaStore.equal_sets (phone_numbers, - this._phone_numbers)) + if (Folks.Internal.equal_sets (details, member_set)) { return; } @@ -615,7 +614,7 @@ public class Tpf.Persona : Folks.Persona, this.notify_property ("full-name"); } - if (!Folks.PersonaStore.equal_sets (new_phone_numbers, + if (!Folks.Internal.equal_sets (new_phone_numbers, this._phone_numbers)) { this._phone_numbers = new_phone_numbers; diff --git a/folks/Makefile.am b/folks/Makefile.am index 7799a45..fe23abc 100644 --- a/folks/Makefile.am +++ b/folks/Makefile.am @@ -8,9 +8,42 @@ AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"folks\" \ $(NULL) +noinst_LTLIBRARIES = libfolks-internal.la lib_LTLIBRARIES = libfolks.la -# Vala files to compile into libfolks.la +################################################## +# Internal library +################################################## +libfolks_internal_la_SOURCES = \ + internal.vala \ + $(NULL) + +libfolks_internal_la_VALAFLAGS = \ + $(ERROR_VALAFLAGS) \ + --library=folks-internal \ + --vapidir=. \ + --pkg gobject-2.0 \ + --pkg gee-1.0 \ + --vapi folks-internal.vapi \ + -H folks-internal.h \ + $(NULL) + +libfolks_internal_la_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GEE_CFLAGS) \ + $(NULL) + +libfolks_internal_la_LIBADD = \ + $(GLIB_LIBS) \ + $(GEE_LIBS) \ + $(NULL) + +################################################## +# Core library +################################################## + +libfolks_la_vala.stamp: libfolks-internal.la + libfolks_la_SOURCES = \ abstract-field-details.vala \ alias-details.vala \ @@ -54,6 +87,7 @@ libfolks_la_VALAFLAGS = \ --library=folks \ --vapidir=. \ --pkg build-conf \ + --pkg folks-internal \ --pkg gobject-2.0 \ --pkg gmodule-2.0 \ --pkg gio-2.0 \ @@ -79,6 +113,7 @@ libfolks_la_LIBADD = \ $(GMODULE_LIBS) \ $(GEE_LIBS) \ $(GCONF2_LIBS) \ + $(top_builddir)/folks/libfolks-internal.la \ $(NULL) # The quoting here is unnecessary but harmless, and has the useful side-effect @@ -90,6 +125,10 @@ libfolks_la_LDFLAGS = \ folksdir = $(includedir)/folks folks_HEADERS = folks.h +dist_noinst_DATA = \ + folks-internal.vapi \ + $(NULL) + vapidir = $(datadir)/vala/vapi dist_vapi_DATA = \ folks.vapi \ diff --git a/folks/internal.vala b/folks/internal.vala new file mode 100644 index 0000000..41cf7f2 --- /dev/null +++ b/folks/internal.vala @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 Collabora Ltd. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + * + * Authors: + * Raul Gutierrez Segales + */ + +using Gee; + +namespace Folks.Internal +{ + public static bool equal_sets (Set a, Set b) + { + if (a.size != b.size) + return false; + + foreach (var a_elem in a) + { + if (!b.contains (a_elem)) + return false; + } + + return true; + } +} diff --git a/folks/persona-store.vala b/folks/persona-store.vala index 9b464a0..aa533c1 100644 --- a/folks/persona-store.vala +++ b/folks/persona-store.vala @@ -658,18 +658,4 @@ public abstract class Folks.PersonaStore : Object * @since 0.6.3 */ public bool is_user_set_default { get; internal set; default = false; } - - public static bool equal_sets (Set a, Set b) - { - if (a.size != b.size) - return false; - - foreach (var a_elem in a) - { - if (!b.contains (a_elem)) - return false; - } - - return true; - } } -- 2.7.4