diff options
author | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2010-02-13 19:35:53 +0000 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2010-02-15 12:39:44 +1100 |
commit | 6798ce20c11c3e970db518d17e99f92b11f2c14c (patch) | |
tree | 58f26867680ecf5d812e10a012875c2e1b9f4c02 | |
parent | 1b041cd588e49fd710d5bfed94c6756592c1562b (diff) |
Removal of util.c module.
Use the normal approach to unreferencing objects.
Use g_str_equal instead of tpl_strequal (which was useless and now removed).
Removed any inclusion of util.h from headers files, and properly including
util.h in .c files
-rw-r--r-- | telepathy-logger/Makefile.am | 3 | ||||
-rw-r--r-- | telepathy-logger/channel-factory.c | 3 | ||||
-rw-r--r-- | telepathy-logger/channel-text.c | 14 | ||||
-rw-r--r-- | telepathy-logger/channel.c | 8 | ||||
-rw-r--r-- | telepathy-logger/channel.h | 2 | ||||
-rw-r--r-- | telepathy-logger/conf.c | 7 | ||||
-rw-r--r-- | telepathy-logger/contact.c | 7 | ||||
-rw-r--r-- | telepathy-logger/dbus-service.c | 8 | ||||
-rw-r--r-- | telepathy-logger/log-entry-text.c | 13 | ||||
-rw-r--r-- | telepathy-logger/log-entry.c | 26 | ||||
-rw-r--r-- | telepathy-logger/log-manager.c | 6 | ||||
-rw-r--r-- | telepathy-logger/log-store-empathy.c | 3 | ||||
-rw-r--r-- | telepathy-logger/log-store-factory.c | 4 | ||||
-rw-r--r-- | telepathy-logger/observer.c | 16 | ||||
-rw-r--r-- | telepathy-logger/util.c | 32 | ||||
-rw-r--r-- | telepathy-logger/util.h | 8 |
16 files changed, 78 insertions, 82 deletions
diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am index 91ef407cd..d1554a2a1 100644 --- a/telepathy-logger/Makefile.am +++ b/telepathy-logger/Makefile.am @@ -48,8 +48,7 @@ libtelepathy_logger_la_SOURCES = \ log-store.c \ log-store-empathy.c \ log-store-factory.c \ - observer.c \ - util.c + observer.c libtelepathy_logger_la_LIBADD = \ $(top_builddir)/extensions/libtpl-extensions.la diff --git a/telepathy-logger/channel-factory.c b/telepathy-logger/channel-factory.c index d9db53dc1..189ca32e6 100644 --- a/telepathy-logger/channel-factory.c +++ b/telepathy-logger/channel-factory.c @@ -25,6 +25,7 @@ #include <telepathy-glib/util.h> #include <telepathy-logger/channel-text.h> +#include <telepathy-logger/util.h> #define DEBUG_FLAG TPL_DEBUG_CHANNEL #include <telepathy-logger/debug.h> @@ -37,7 +38,7 @@ tpl_channel_factory_init (void) g_return_if_fail (channel_table == NULL); channel_table = g_hash_table_new_full (g_str_hash, - (GEqualFunc) tpl_strequal, g_free, NULL); + (GEqualFunc) g_str_equal, g_free, NULL); } diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c index d738bcffe..8684d86cf 100644 --- a/telepathy-logger/channel-text.c +++ b/telepathy-logger/channel-text.c @@ -246,10 +246,16 @@ tpl_channel_text_dispose (GObject *obj) { TplChannelTextPriv *priv = GET_PRIV (obj); - tpl_object_unref_if_not_null (priv->my_contact); - priv->my_contact = NULL; - tpl_object_unref_if_not_null (priv->remote_contact); - priv->remote_contact = NULL; + if (priv->my_contact != NULL) + { + g_object_unref (priv->my_contact); + priv->my_contact = NULL; + } + if (priv->remote_contact != NULL) + { + g_object_unref (priv->remote_contact); + priv->remote_contact = NULL; + } G_OBJECT_CLASS (tpl_channel_text_parent_class)->dispose (obj); } diff --git a/telepathy-logger/channel.c b/telepathy-logger/channel.c index 4a4ddeab4..6098f88d5 100644 --- a/telepathy-logger/channel.c +++ b/telepathy-logger/channel.c @@ -30,6 +30,7 @@ #include <telepathy-logger/action-chain.h> #include <telepathy-logger/channel-text.h> #include <telepathy-logger/observer.h> +#include <telepathy-logger/util.h> #define DEBUG_FLAG TPL_DEBUG_CHANNEL #include <telepathy-logger/debug.h> @@ -104,8 +105,11 @@ tpl_channel_dispose (GObject *obj) { TplChannelPriv *priv = GET_PRIV (obj); - tpl_object_unref_if_not_null (priv->account); - priv->account = NULL; + if (priv->account != NULL) + { + g_object_unref (priv->account); + priv->account = NULL; + } G_OBJECT_CLASS (tpl_channel_parent_class)->dispose (obj); } diff --git a/telepathy-logger/channel.h b/telepathy-logger/channel.h index 2df877d53..9bd934462 100644 --- a/telepathy-logger/channel.h +++ b/telepathy-logger/channel.h @@ -29,8 +29,6 @@ #include <telepathy-glib/connection.h> #include <telepathy-glib/channel.h> -#include <telepathy-logger/util.h> - G_BEGIN_DECLS #define TPL_TYPE_CHANNEL (tpl_channel_get_type ()) #define TPL_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPL_TYPE_CHANNEL, TplChannel)) diff --git a/telepathy-logger/conf.c b/telepathy-logger/conf.c index a4780562e..9d8cfad12 100644 --- a/telepathy-logger/conf.c +++ b/telepathy-logger/conf.c @@ -49,8 +49,11 @@ tpl_conf_finalize (GObject *obj) priv = GET_PRIV (obj); - tpl_object_unref_if_not_null (priv->client); - priv->client = NULL; + if (priv->client != NULL) + { + g_object_unref (priv->client); + priv->client = NULL; + } G_OBJECT_CLASS (tpl_conf_parent_class)->finalize (obj); } diff --git a/telepathy-logger/contact.c b/telepathy-logger/contact.c index e3574954e..340bdc139 100644 --- a/telepathy-logger/contact.c +++ b/telepathy-logger/contact.c @@ -80,8 +80,11 @@ tpl_contact_dispose (GObject *obj) TplContact *self = TPL_CONTACT (obj); TplContactPriv *priv = GET_PRIV (self); - tpl_object_unref_if_not_null (priv->contact); - priv->contact = NULL; + if (priv->contact != NULL) + { + g_object_unref (priv->contact); + priv->contact = NULL; + } G_OBJECT_CLASS (tpl_contact_parent_class)->dispose (obj); } diff --git a/telepathy-logger/dbus-service.c b/telepathy-logger/dbus-service.c index 0cd4e2c3b..fc94131bb 100644 --- a/telepathy-logger/dbus-service.c +++ b/telepathy-logger/dbus-service.c @@ -28,6 +28,7 @@ #include <telepathy-logger/log-entry-text.h> #include <telepathy-logger/log-manager.h> +#include <telepathy-logger/util.h> #include <extensions/extensions.h> @@ -197,8 +198,11 @@ tpl_dbus_service_get_recent_messages (TplSvcLogger *self, tpl_svc_logger_return_from_get_recent_messages (context, packed); out: - tpl_object_unref_if_not_null (account); - tpl_object_unref_if_not_null (tp_dbus); + if (account != NULL) + g_object_unref (account); + + if (tp_dbus != NULL) + g_object_unref (tp_dbus); } diff --git a/telepathy-logger/log-entry-text.c b/telepathy-logger/log-entry-text.c index 1cb249755..82540766d 100644 --- a/telepathy-logger/log-entry-text.c +++ b/telepathy-logger/log-entry-text.c @@ -56,8 +56,11 @@ tpl_log_entry_text_dispose (GObject * obj) TplLogEntryText *self = TPL_LOG_ENTRY_TEXT (obj); TplLogEntryTextPriv *priv = GET_PRIV (self); - tpl_object_unref_if_not_null (priv->tpl_text); - priv->tpl_text = NULL; + if (priv->tpl_text != NULL) + { + g_object_unref (priv->tpl_text); + priv->tpl_text = NULL; + } G_OBJECT_CLASS (tpl_log_entry_text_parent_class)->dispose (obj); } @@ -294,9 +297,9 @@ tpl_log_entry_text_set_tpl_channel_text (TplLogEntryText * self, g_return_if_fail (TPL_IS_CHANNEL_TEXT (data) || data == NULL); priv = GET_PRIV (self); - tpl_object_unref_if_not_null (priv->tpl_text); - priv->tpl_text = data; - tpl_object_ref_if_not_null (data); + if (priv->tpl_text != NULL) + g_object_unref (priv->tpl_text); + priv->tpl_text = g_object_ref (data); } diff --git a/telepathy-logger/log-entry.c b/telepathy-logger/log-entry.c index 0c8f3f6e9..5585bbebf 100644 --- a/telepathy-logger/log-entry.c +++ b/telepathy-logger/log-entry.c @@ -91,10 +91,16 @@ tpl_log_entry_dispose (GObject *obj) TplLogEntry *self = TPL_LOG_ENTRY (obj); TplLogEntryPriv *priv = GET_PRIV (self); - tpl_object_unref_if_not_null (priv->sender); - priv->sender = NULL; - tpl_object_unref_if_not_null (priv->receiver); - priv->receiver = NULL; + if (priv->sender != NULL) + { + g_object_unref (priv->sender); + priv->sender = NULL; + } + if (priv->receiver) + { + g_object_unref (priv->receiver); + priv->receiver = NULL; + } G_OBJECT_CLASS (tpl_log_entry_parent_class)->dispose (obj); } @@ -427,9 +433,9 @@ tpl_log_entry_set_sender (TplLogEntry *self, priv = GET_PRIV (self); - tpl_object_unref_if_not_null (priv->sender); - priv->sender = data; - tpl_object_ref_if_not_null (data); + if (priv->sender != NULL) + g_object_unref (priv->sender); + priv->sender = g_object_ref (data); g_object_notify (G_OBJECT(self), "sender"); } @@ -444,9 +450,9 @@ tpl_log_entry_set_receiver (TplLogEntry *self, g_return_if_fail (TPL_IS_CONTACT (data) || data == NULL); priv = GET_PRIV (self); - tpl_object_unref_if_not_null (priv->receiver); - priv->receiver = data; - tpl_object_ref_if_not_null (data); + if (priv->receiver != NULL) + g_object_unref (priv->receiver); + priv->receiver = g_object_ref (data); g_object_notify (G_OBJECT(self), "receiver"); } diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c index 7b1509d58..5437f8fe1 100644 --- a/telepathy-logger/log-manager.c +++ b/telepathy-logger/log-manager.c @@ -599,7 +599,8 @@ tpl_log_manager_async_data_new (void) static void tpl_log_manager_async_data_free (TplLogManagerAsyncData *data) { - tpl_object_unref_if_not_null (data->manager); + if (data->manager != NULL) + g_object_unref (data->manager); data->request_free ((gpointer) data->request); g_slice_free (TplLogManagerAsyncData, data); } @@ -615,7 +616,8 @@ tpl_log_manager_chat_info_new (void) static void tpl_log_manager_chat_info_free (TplLogManagerChatInfo *data) { - tpl_object_unref_if_not_null (data->account); + if (data->account != NULL) + g_object_unref (data->account); if (data->chat_id != NULL) g_free (data->chat_id); if (data->date != NULL) diff --git a/telepathy-logger/log-store-empathy.c b/telepathy-logger/log-store-empathy.c index c88befcb4..e364d0b93 100644 --- a/telepathy-logger/log-store-empathy.c +++ b/telepathy-logger/log-store-empathy.c @@ -40,10 +40,11 @@ #include <telepathy-glib/util.h> #include <telepathy-logger/contact.h> +#include <telepathy-logger/log-entry-text.h> #include <telepathy-logger/log-manager.h> #include <telepathy-logger/log-store.h> -#include <telepathy-logger/log-entry-text.h> #include <telepathy-logger/datetime.h> +#include <telepathy-logger/util.h> #define DEBUG_FLAG TPL_DEBUG_LOG_STORE #include <telepathy-logger/debug.h> diff --git a/telepathy-logger/log-store-factory.c b/telepathy-logger/log-store-factory.c index f919526b2..bbc506365 100644 --- a/telepathy-logger/log-store-factory.c +++ b/telepathy-logger/log-store-factory.c @@ -22,8 +22,8 @@ #include "config.h" #include "log-store-factory.h" -#include <telepathy-logger/util.h> #include <telepathy-logger/log-store-empathy.h> +#include <telepathy-logger/util.h> #define DEBUG_FLAG TPL_DEBUG_LOG_STORE #include <telepathy-logger/debug.h> @@ -36,7 +36,7 @@ tpl_log_store_factory_init (void) g_return_if_fail (logstores_table == NULL); logstores_table = g_hash_table_new_full (g_str_hash, - (GEqualFunc) tpl_strequal, g_free, NULL); + (GEqualFunc) g_str_equal, g_free, NULL); } diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c index 507c720e0..6eaee8748 100644 --- a/telepathy-logger/observer.c +++ b/telepathy-logger/observer.c @@ -240,9 +240,12 @@ tpl_observer_observe_channels (TpSvcClientObserver *self, return; error: - tpl_object_unref_if_not_null (tp_acc); - tpl_object_unref_if_not_null (tp_conn); - tpl_object_unref_if_not_null (tp_bus_daemon); + if (tp_acc != NULL) + g_object_unref (tp_acc); + if (tp_conn != NULL) + g_object_unref (tp_conn); + if (tp_bus_daemon != NULL) + g_object_unref (tp_bus_daemon); g_clear_error (&error); tp_svc_client_observer_return_from_observe_channels (dbus_context); @@ -488,8 +491,11 @@ tpl_observer_dispose (GObject *obj) g_hash_table_unref (priv->channel_map); priv->channel_map = NULL; } - tpl_object_unref_if_not_null (priv->logmanager); - priv->logmanager = NULL; + if (priv->logmanager != NULL) + { + g_object_unref (priv->logmanager); + priv->logmanager = NULL; + } G_OBJECT_CLASS (tpl_observer_parent_class)->dispose (obj); } diff --git a/telepathy-logger/util.c b/telepathy-logger/util.c deleted file mode 100644 index d263c46b7..000000000 --- a/telepathy-logger/util.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2009 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 - * - * Authors: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> - */ - -#include "config.h" -#include "util.h" - -#include <telepathy-glib/util.h> - -gboolean -tpl_strequal (const gchar *left, - const gchar *right) -{ - return !tp_strdiff (left, right); -} diff --git a/telepathy-logger/util.h b/telepathy-logger/util.h index 190207af1..0db8623a1 100644 --- a/telepathy-logger/util.h +++ b/telepathy-logger/util.h @@ -42,12 +42,4 @@ return; \ } -#define tpl_object_unref_if_not_null(obj) if (obj != NULL && G_IS_OBJECT (obj)) \ - g_object_unref (obj); -#define tpl_object_ref_if_not_null(obj) if (obj != NULL && G_IS_OBJECT (obj)) \ - g_object_ref (obj); - - -gboolean tpl_strequal (const gchar *left, const gchar *right); - #endif // __TPL_UTIL_H__ |