Commit c8f9b3ed authored by Travis Reitter's avatar Travis Reitter
Browse files

Split utility functions into an internal library.

This lets us avoid stuffing them into unrelated public libraries.
parent 9ca70640
......@@ -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) \
......
......@@ -1481,7 +1481,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore
_("Roles are not writeable on this contact."));
}
if (Folks.PersonaStore.equal_sets<RoleFieldDetails> (roles, persona.roles))
if (Folks.Internal.equal_sets<RoleFieldDetails> (roles, persona.roles))
return;
yield this._set_contact_roles (persona.contact, roles);
......
......@@ -938,7 +938,7 @@ public class Edsf.Persona : Folks.Persona,
new_roles.add (role_fd);
}
if (!Folks.PersonaStore.equal_sets<RoleFieldDetails> (new_roles, this._roles))
if (!Folks.Internal.equal_sets<RoleFieldDetails> (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<EmailFieldDetails> (new_email_addresses,
if (!Folks.Internal.equal_sets<EmailFieldDetails> (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<NoteFieldDetails> (new_notes, this._notes))
if (!Folks.Internal.equal_sets<NoteFieldDetails> (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<PhoneFieldDetails> (new_phone_numbers,
if (!Folks.Internal.equal_sets<PhoneFieldDetails> (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<PostalAddressFieldDetails> (
if (!Folks.Internal.equal_sets<PostalAddressFieldDetails> (
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<string> (new_local_ids, this.local_ids))
if (!Folks.Internal.equal_sets<string> (new_local_ids, this.local_ids))
{
this._local_ids = new_local_ids;
this._local_ids_ro = this._local_ids.read_only_view;
......
......@@ -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
......
......@@ -403,8 +403,7 @@ public class Tpf.Persona : Folks.Persona,
{
var tpf_store = this.store as Tpf.PersonaStore;
if (Folks.PersonaStore.equal_sets<PhoneFieldDetails> (phone_numbers,
this._phone_numbers))
if (Folks.Internal.equal_sets<T> (details, member_set))
{
return;
}
......@@ -615,7 +614,7 @@ public class Tpf.Persona : Folks.Persona,
this.notify_property ("full-name");
}
if (!Folks.PersonaStore.equal_sets<PhoneFieldDetails> (new_phone_numbers,
if (!Folks.Internal.equal_sets<PhoneFieldDetails> (new_phone_numbers,
this._phone_numbers))
{
this._phone_numbers = new_phone_numbers;
......
......@@ -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 \
......
/*
* 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 <http://www.gnu.org/licenses/>.
*
* Authors:
* Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
*/
using Gee;
namespace Folks.Internal
{
public static bool equal_sets<G> (Set<G> a, Set<G> b)
{
if (a.size != b.size)
return false;
foreach (var a_elem in a)
{
if (!b.contains (a_elem))
return false;
}
return true;
}
}
......@@ -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<G> (Set<G> a, Set<G> b)
{
if (a.size != b.size)
return false;
foreach (var a_elem in a)
{
if (!b.contains (a_elem))
return false;
}
return true;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment