From 75f29b17e7f908bb43494561cb2ac66d8cbaf91f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 13 Jul 2011 16:50:34 +0200 Subject: [PATCH] Expose internally a TpContact constructor --- telepathy-glib/Makefile.am | 1 + telepathy-glib/contact-internal.h | 32 ++++++++++++++++++++++++++++++++ telepathy-glib/contact.c | 19 +++++++++++++++---- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 telepathy-glib/contact-internal.h diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am index 987371f..d1a6a44 100644 --- a/telepathy-glib/Makefile.am +++ b/telepathy-glib/Makefile.am @@ -178,6 +178,7 @@ libtelepathy_glib_internal_la_SOURCES = \ connection-handles.c \ connection-manager.c \ contact.c \ + contact-internal.h \ contact-list-channel-internal.h \ contact-list-channel.c \ contact-search.c \ diff --git a/telepathy-glib/contact-internal.h b/telepathy-glib/contact-internal.h new file mode 100644 index 0000000..2f83c42 --- /dev/null +++ b/telepathy-glib/contact-internal.h @@ -0,0 +1,32 @@ +/* Object representing a Telepathy contact (internal) + * + * Copyright © 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __TP_CONTACT_INTERNAL_H__ +#define __TP_CONTACT_INTERNAL_H__ + +#include + +G_BEGIN_DECLS + +TpContact *_tp_contact_new (TpConnection *connection, TpHandle handle, + const gchar *identifier); + +G_END_DECLS + +#endif diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c index 22c5058..8d2bae4 100644 --- a/telepathy-glib/contact.c +++ b/telepathy-glib/contact.c @@ -31,6 +31,7 @@ #define DEBUG_FLAG TP_DEBUG_CONTACTS #include "telepathy-glib/connection-internal.h" +#include "telepathy-glib/contact-internal.h" #include "telepathy-glib/debug-internal.h" #include "telepathy-glib/util-internal.h" @@ -1337,6 +1338,19 @@ tp_contact_class_init (TpContactClass *klass) G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); } +TpContact * +_tp_contact_new (TpConnection *connection, + TpHandle handle, + const gchar *identifier) +{ + TpContact *self = TP_CONTACT (g_object_new (TP_TYPE_CONTACT, NULL)); + + self->priv->connection = g_object_ref (connection); + self->priv->handle = handle; + self->priv->identifier = g_strdup (identifier); + + return self; +} static TpContact * tp_contact_ensure (TpConnection *connection, @@ -1350,11 +1364,8 @@ tp_contact_ensure (TpConnection *connection, return g_object_ref (self); } - self = TP_CONTACT (g_object_new (TP_TYPE_CONTACT, NULL)); - - self->priv->handle = handle; + self = _tp_contact_new (connection, handle, NULL); _tp_connection_add_contact (connection, handle, self); - self->priv->connection = g_object_ref (connection); return self; } -- 1.7.4.1