From 214850e492efd75f8664bbfb98c6dd6bf161aeb6 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 3 May 2007 14:12:30 +0000 Subject: [darcs-to-svn @ Remove EmpathySession and move all programs into src/] svn path=/trunk/; revision=28 --- libempathy/Makefile.am | 1 - libempathy/empathy-contact-list.c | 1 - libempathy/empathy-contact-manager.c | 12 ++++++-- libempathy/empathy-session.c | 56 ------------------------------------ libempathy/empathy-session.h | 38 ------------------------ libempathy/empathy-tp-chat.c | 26 +++++++++-------- libempathy/gossip-utils.c | 8 ++++-- 7 files changed, 29 insertions(+), 113 deletions(-) delete mode 100644 libempathy/empathy-session.c delete mode 100644 libempathy/empathy-session.h (limited to 'libempathy') diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index 30d40c595..c681aa83f 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -24,7 +24,6 @@ libempathy_la_SOURCES = \ gossip-debug.c gossip-debug.h \ gossip-utils.c gossip-utils.h \ gossip-message.c gossip-message.h \ - empathy-session.c empathy-session.h \ empathy-contact-list.c empathy-contact-list.h \ empathy-contact-manager.c empathy-contact-manager.h \ empathy-tp-chat.c empathy-tp-chat.h \ diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 9ed83df70..c3d3171d4 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -34,7 +34,6 @@ #include #include "empathy-contact-list.h" -#include "empathy-session.h" #include "gossip-debug.h" #include "gossip-telepathy-group.h" diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index cf5a81fe2..50ed576b5 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -28,7 +28,6 @@ #include #include "empathy-contact-manager.h" -#include "empathy-session.h" #include "gossip-utils.h" #include "gossip-debug.h" @@ -175,7 +174,16 @@ contact_manager_finalize (GObject *object) EmpathyContactManager * empathy_contact_manager_new (void) { - return g_object_new (EMPATHY_TYPE_CONTACT_MANAGER, NULL); + static EmpathyContactManager *manager = NULL; + + if (!manager) { + manager = g_object_new (EMPATHY_TYPE_CONTACT_MANAGER, NULL); + g_object_add_weak_pointer (G_OBJECT (manager), (gpointer) &manager); + } else { + g_object_ref (manager); + } + + return manager; } void diff --git a/libempathy/empathy-session.c b/libempathy/empathy-session.c deleted file mode 100644 index 86ac1e180..000000000 --- a/libempathy/empathy-session.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Xavier Claessens - */ - -#include - -#include - -#include - -#include - -#include "empathy-session.h" -#include "gossip-debug.h" - -#define DEBUG_DOMAIN "Session" - -static EmpathyContactManager *contact_manager = NULL; - -void -empathy_session_finalize (void) -{ - if (contact_manager) { - g_object_unref (contact_manager); - contact_manager = NULL; - } -} - -EmpathyContactManager * -empathy_session_get_contact_manager (void) -{ - if (!contact_manager) { - contact_manager = empathy_contact_manager_new (); - } - - return contact_manager; -} - diff --git a/libempathy/empathy-session.h b/libempathy/empathy-session.h deleted file mode 100644 index af843a5e0..000000000 --- a/libempathy/empathy-session.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007 Collabora Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Xavier Claessens - */ - -#ifndef __EMPATHY_SESSION_H__ -#define __EMPATHY_SESSION_H__ - -#include - -#include -#include "empathy-contact-manager.h" - -G_BEGIN_DECLS - -void empathy_session_finalize (void); -EmpathyContactManager *empathy_session_get_contact_manager (void); - -G_END_DECLS - -#endif /* __EMPATHY_MISSION_CONTROL_H__ */ diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index f72655eca..25639dd14 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -30,7 +30,6 @@ #include "empathy-tp-chat.h" #include "empathy-contact-manager.h" #include "empathy-contact-list.h" -#include "empathy-session.h" #include "empathy-marshal.h" #include "gossip-debug.h" #include "gossip-time.h" @@ -41,14 +40,15 @@ #define DEBUG_DOMAIN "TpChat" struct _EmpathyTpChatPriv { - EmpathyContactList *list; - McAccount *account; - gchar *id; - MissionControl *mc; - - TpChan *tp_chan; - DBusGProxy *text_iface; - DBusGProxy *chat_state_iface; + EmpathyContactList *list; + EmpathyContactManager *manager; + McAccount *account; + gchar *id; + MissionControl *mc; + + TpChan *tp_chan; + DBusGProxy *text_iface; + DBusGProxy *chat_state_iface; }; static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass); @@ -162,6 +162,9 @@ tp_chat_finalize (GObject *object) g_object_unref (priv->tp_chan); } + if (priv->manager) { + g_object_unref (priv->manager); + } if (priv->list) { g_object_unref (priv->list); } @@ -182,7 +185,6 @@ empathy_tp_chat_new (McAccount *account, { EmpathyTpChatPriv *priv; EmpathyTpChat *chat; - EmpathyContactManager *manager; g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL); @@ -190,8 +192,8 @@ empathy_tp_chat_new (McAccount *account, chat = g_object_new (EMPATHY_TYPE_TP_CHAT, NULL); priv = GET_PRIV (chat); - manager = empathy_session_get_contact_manager (); - priv->list = empathy_contact_manager_get_list (manager, account); + priv->manager = empathy_contact_manager_new (); + priv->list = empathy_contact_manager_get_list (priv->manager, account); priv->tp_chan = g_object_ref (tp_chan); priv->account = g_object_ref (account); priv->mc = mission_control_new (tp_get_bus ()); diff --git a/libempathy/gossip-utils.c b/libempathy/gossip-utils.c index 3dc4afd48..668898712 100644 --- a/libempathy/gossip-utils.c +++ b/libempathy/gossip-utils.c @@ -38,7 +38,6 @@ #include "gossip-debug.h" #include "gossip-utils.h" #include "gossip-paths.h" -#include "empathy-session.h" #include "empathy-contact-manager.h" #define DEBUG_DOMAIN "Utils" @@ -437,12 +436,15 @@ gossip_get_own_contact_from_contact (GossipContact *contact) { EmpathyContactManager *manager; McAccount *account; + GossipContact *own_contact; g_return_val_if_fail (GOSSIP_IS_CONTACT (contact), NULL); - manager = empathy_session_get_contact_manager (); + manager = empathy_contact_manager_new (); account = gossip_contact_get_account (contact); + own_contact = empathy_contact_manager_get_own (manager, account); + g_object_unref (manager); - return empathy_contact_manager_get_own (manager, account); + return own_contact; } -- cgit v1.2.3