aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2010-05-10 18:36:28 +0800
committerXavier Claessens <xclaesse@gmail.com>2010-05-26 17:17:47 +0800
commitb8ff75d21c1be60e6df472a35599a9e22046a92b (patch)
treefcaa7453e65ac310e4a3c0f854bcb8b588722863 /libempathy
parent696bd076bbd431aad122c66cadfb6ec3f5ff1762 (diff)
downloadgsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.tar
gsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.tar.gz
gsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.tar.bz2
gsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.tar.lz
gsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.tar.xz
gsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.tar.zst
gsoc2013-empathy-b8ff75d21c1be60e6df472a35599a9e22046a92b.zip
Port to new EmpathyTpContactFactory API
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-dispatch-operation.c8
-rw-r--r--libempathy/empathy-dispatcher.c8
-rw-r--r--libempathy/empathy-ft-handler.c10
-rw-r--r--libempathy/empathy-tp-call.c7
-rw-r--r--libempathy/empathy-tp-chat.c50
-rw-r--r--libempathy/empathy-tp-contact-list.c15
6 files changed, 36 insertions, 62 deletions
diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c
index 08013889e..f6cc0d6ef 100644
--- a/libempathy/empathy-dispatch-operation.c
+++ b/libempathy/empathy-dispatch-operation.c
@@ -185,7 +185,7 @@ empathy_dispatch_operation_invalidated (TpProxy *proxy, guint domain,
}
static void
-dispatcher_operation_got_contact_cb (EmpathyTpContactFactory *factory,
+dispatcher_operation_got_contact_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -219,7 +219,6 @@ dispatch_operation_connection_ready (TpConnection *connection,
{
EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data);
EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
- EmpathyTpContactFactory *factory;
TpHandle handle;
if (error != NULL)
@@ -231,12 +230,9 @@ dispatch_operation_connection_ready (TpConnection *connection,
handle = tp_channel_get_handle (priv->channel, NULL);
- factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
-
- empathy_tp_contact_factory_get_from_handle (factory, handle,
+ empathy_tp_contact_factory_get_from_handle (priv->connection, handle,
dispatcher_operation_got_contact_cb, NULL, NULL, G_OBJECT (self));
- g_object_unref (factory);
out:
g_object_unref (self);
}
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index e476fc671..c8943c9df 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -1357,7 +1357,7 @@ typedef struct
} ChatWithContactIdData;
static void
-dispatcher_chat_with_contact_id_cb (EmpathyTpContactFactory *factory,
+dispatcher_chat_with_contact_id_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -1392,23 +1392,19 @@ empathy_dispatcher_chat_with_contact_id (TpConnection *connection,
gpointer user_data)
{
EmpathyDispatcher *self;
- EmpathyTpContactFactory *factory;
ChatWithContactIdData *data;
g_return_if_fail (TP_IS_CONNECTION (connection));
g_return_if_fail (!EMP_STR_EMPTY (contact_id));
self = empathy_dispatcher_dup_singleton ();
- factory = empathy_tp_contact_factory_dup_singleton (connection);
data = g_slice_new0 (ChatWithContactIdData);
data->dispatcher = self;
data->callback = callback;
data->user_data = user_data;
data->timestamp = timestamp;
- empathy_tp_contact_factory_get_from_id (factory, contact_id,
+ empathy_tp_contact_factory_get_from_id (connection, contact_id,
dispatcher_chat_with_contact_id_cb, data, NULL, NULL);
-
- g_object_unref (factory);
}
static void
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index bbc99f61a..0140fc3cc 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -1203,7 +1203,7 @@ out:
}
static void
-contact_factory_contact_cb (EmpathyTpContactFactory *factory,
+contact_factory_contact_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -1238,7 +1238,6 @@ channel_get_all_properties_cb (TpProxy *proxy,
CallbacksData *cb_data = user_data;
EmpathyFTHandler *handler = EMPATHY_FT_HANDLER (weak_object);
EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
- EmpathyTpContactFactory *c_factory;
TpHandle c_handle;
if (error != NULL)
@@ -1273,14 +1272,11 @@ channel_get_all_properties_cb (TpProxy *proxy,
priv->description = g_value_dup_string (
g_hash_table_lookup (properties, "Description"));
- c_factory = empathy_tp_contact_factory_dup_singleton
- (tp_channel_borrow_connection (TP_CHANNEL (proxy)));
c_handle = tp_channel_get_handle (TP_CHANNEL (proxy), NULL);
- empathy_tp_contact_factory_get_from_handle (c_factory, c_handle,
+ empathy_tp_contact_factory_get_from_handle (
+ tp_channel_borrow_connection (TP_CHANNEL (proxy)), c_handle,
contact_factory_contact_cb, cb_data, callbacks_data_free,
G_OBJECT (handler));
-
- g_object_unref (c_factory);
}
/* public methods */
diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c
index 32a09255f..78ee6d005 100644
--- a/libempathy/empathy-tp-call.c
+++ b/libempathy/empathy-tp-call.c
@@ -264,7 +264,7 @@ tp_call_request_streams_for_capabilities (EmpathyTpCall *call,
}
static void
-tp_call_got_contact_cb (EmpathyTpContactFactory *factory,
+tp_call_got_contact_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -303,15 +303,12 @@ tp_call_update_status (EmpathyTpCall *call)
{
if (priv->contact == NULL && iter.element != self_handle)
{
- EmpathyTpContactFactory *factory;
TpConnection *connection;
/* We found the remote contact */
connection = tp_channel_borrow_connection (priv->channel);
- factory = empathy_tp_contact_factory_dup_singleton (connection);
- empathy_tp_contact_factory_get_from_handle (factory, iter.element,
+ empathy_tp_contact_factory_get_from_handle (connection, iter.element,
tp_call_got_contact_cb, NULL, NULL, G_OBJECT (call));
- g_object_unref (factory);
}
if (priv->status == EMPATHY_TP_CALL_STATUS_PENDING &&
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index cad014df3..485510214 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -42,7 +42,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpChat)
typedef struct {
gboolean dispose_has_run;
- EmpathyTpContactFactory *factory;
+ TpConnection *connection;
EmpathyContactMonitor *contact_monitor;
EmpathyContact *user;
EmpathyContact *remote_contact;
@@ -132,14 +132,12 @@ tp_chat_add (EmpathyContactList *list,
-1, &handles, NULL, NULL, NULL, NULL, NULL);
} else if (priv->can_upgrade_to_muc) {
EmpathyDispatcher *dispatcher;
- TpConnection *connection;
GHashTable *props;
const char *object_path;
GPtrArray channels = { (gpointer *) &object_path, 1 };
const char *invitees[2] = { NULL, };
dispatcher = empathy_dispatcher_dup_singleton ();
- connection = tp_channel_borrow_connection (priv->channel);
invitees[0] = empathy_contact_get_id (contact);
object_path = tp_proxy_get_object_path (priv->channel);
@@ -159,7 +157,7 @@ tp_chat_add (EmpathyContactList *list,
/* Although this is a MUC, it's anonymous, so CreateChannel is
* valid.
* props now belongs to EmpathyDispatcher, don't free it */
- empathy_dispatcher_create_channel (dispatcher, connection,
+ empathy_dispatcher_create_channel (dispatcher, priv->connection,
props, EMPATHY_DISPATCHER_NON_USER_ACTION, NULL, NULL);
g_object_unref (dispatcher);
@@ -243,7 +241,7 @@ tp_chat_emit_queued_messages (EmpathyTpChat *chat)
}
static void
-tp_chat_got_sender_cb (EmpathyTpContactFactory *factory,
+tp_chat_got_sender_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer message,
@@ -291,7 +289,7 @@ tp_chat_build_message (EmpathyTpChat *chat,
empathy_message_set_sender (message, priv->user);
tp_chat_emit_queued_messages (chat);
} else {
- empathy_tp_contact_factory_get_from_handle (priv->factory,
+ empathy_tp_contact_factory_get_from_handle (priv->connection,
from_handle,
tp_chat_got_sender_cb,
message, NULL, G_OBJECT (chat));
@@ -412,7 +410,7 @@ typedef struct {
} StateChangedData;
static void
-tp_chat_state_changed_got_contact_cb (EmpathyTpContactFactory *factory,
+tp_chat_state_changed_got_contact_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -442,7 +440,7 @@ tp_chat_state_changed_cb (TpChannel *channel,
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- empathy_tp_contact_factory_get_from_handle (priv->factory, handle,
+ empathy_tp_contact_factory_get_from_handle (priv->connection, handle,
tp_chat_state_changed_got_contact_cb, GUINT_TO_POINTER (state),
NULL, chat);
}
@@ -758,6 +756,10 @@ tp_chat_dispose (GObject *object)
priv->dispose_has_run = TRUE;
+ if (priv->connection != NULL)
+ g_object_unref (priv->connection);
+ priv->connection = NULL;
+
if (priv->channel != NULL) {
g_signal_handlers_disconnect_by_func (priv->channel,
tp_chat_invalidated_cb, self);
@@ -769,10 +771,6 @@ tp_chat_dispose (GObject *object)
g_object_unref (priv->remote_contact);
priv->remote_contact = NULL;
- if (priv->factory != NULL)
- g_object_unref (priv->factory);
- priv->factory = NULL;
-
if (priv->user != NULL)
g_object_unref (priv->user);
priv->user = NULL;
@@ -931,7 +929,7 @@ tp_chat_update_remote_contact (EmpathyTpChat *chat)
}
static void
-tp_chat_got_added_contacts_cb (EmpathyTpContactFactory *factory,
+tp_chat_got_added_contacts_cb (TpConnection *connection,
guint n_contacts,
EmpathyContact * const * contacts,
guint n_failed,
@@ -1025,7 +1023,7 @@ contact_rename_data_free (ContactRenameData* data)
}
static void
-tp_chat_got_renamed_contacts_cb (EmpathyTpContactFactory *factory,
+tp_chat_got_renamed_contacts_cb (TpConnection *connection,
guint n_contacts,
EmpathyContact * const * contacts,
guint n_failed,
@@ -1107,7 +1105,7 @@ tp_chat_group_members_changed_cb (TpChannel *self,
old_handle = g_array_index (removed, guint, 0);
rename_data = contact_rename_data_new (old_handle, reason, message);
- empathy_tp_contact_factory_get_from_handles (priv->factory,
+ empathy_tp_contact_factory_get_from_handles (priv->connection,
added->len, (TpHandle *) added->data,
tp_chat_got_renamed_contacts_cb,
rename_data, (GDestroyNotify) contact_rename_data_free,
@@ -1141,7 +1139,7 @@ tp_chat_group_members_changed_cb (TpChannel *self,
/* Request added contacts */
if (added->len > 0) {
- empathy_tp_contact_factory_get_from_handles (priv->factory,
+ empathy_tp_contact_factory_get_from_handles (priv->connection,
added->len, (TpHandle *) added->data,
tp_chat_got_added_contacts_cb, NULL, NULL,
G_OBJECT (chat));
@@ -1155,7 +1153,7 @@ tp_chat_group_members_changed_cb (TpChannel *self,
}
static void
-tp_chat_got_remote_contact_cb (EmpathyTpContactFactory *factory,
+tp_chat_got_remote_contact_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -1176,7 +1174,7 @@ tp_chat_got_remote_contact_cb (EmpathyTpContactFactory *factory,
}
static void
-tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
+tp_chat_got_self_contact_cb (TpConnection *connection,
EmpathyContact *contact,
const GError *error,
gpointer user_data,
@@ -1240,15 +1238,13 @@ tp_chat_constructor (GType type,
{
GObject *chat;
EmpathyTpChatPriv *priv;
- TpConnection *connection;
TpHandle handle;
chat = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props);
priv = GET_PRIV (chat);
- connection = tp_channel_borrow_connection (priv->channel);
- priv->factory = empathy_tp_contact_factory_dup_singleton (connection);
+ priv->connection = g_object_ref (tp_channel_borrow_connection (priv->channel));
g_signal_connect (priv->channel, "invalidated",
G_CALLBACK (tp_chat_invalidated_cb),
chat);
@@ -1260,14 +1256,14 @@ tp_chat_constructor (GType type,
/* Get self contact from the group's self handle */
handle = tp_channel_group_get_self_handle (priv->channel);
- empathy_tp_contact_factory_get_from_handle (priv->factory,
+ empathy_tp_contact_factory_get_from_handle (priv->connection,
handle, tp_chat_got_self_contact_cb,
NULL, NULL, chat);
/* Get initial member contacts */
members = tp_channel_group_get_members (priv->channel);
handles = tp_intset_to_array (members);
- empathy_tp_contact_factory_get_from_handles (priv->factory,
+ empathy_tp_contact_factory_get_from_handles (priv->connection,
handles->len, (TpHandle *) handles->data,
tp_chat_got_added_contacts_cb, NULL, NULL, chat);
@@ -1280,19 +1276,19 @@ tp_chat_constructor (GType type,
GList *list, *ptr;
/* Get the self contact from the connection's self handle */
- handle = tp_connection_get_self_handle (connection);
- empathy_tp_contact_factory_get_from_handle (priv->factory,
+ handle = tp_connection_get_self_handle (priv->connection);
+ empathy_tp_contact_factory_get_from_handle (priv->connection,
handle, tp_chat_got_self_contact_cb,
NULL, NULL, chat);
/* Get the remote contact */
handle = tp_channel_get_handle (priv->channel, NULL);
- empathy_tp_contact_factory_get_from_handle (priv->factory,
+ empathy_tp_contact_factory_get_from_handle (priv->connection,
handle, tp_chat_got_remote_contact_cb,
NULL, NULL, chat);
list = empathy_dispatcher_find_requestable_channel_classes (
- dispatcher, connection,
+ dispatcher, priv->connection,
tp_channel_get_channel_type (priv->channel),
TP_UNKNOWN_HANDLE_TYPE, NULL);
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index f8d897185..a77bb10b4 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -41,7 +41,6 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpContactList)
typedef struct {
- EmpathyTpContactFactory *factory;
TpConnection *connection;
TpChannel *publish;
@@ -372,7 +371,7 @@ tp_contact_list_group_add (EmpathyTpContactList *list,
}
static void
-got_added_members_cb (EmpathyTpContactFactory *factory,
+got_added_members_cb (TpConnection *connection,
guint n_contacts,
EmpathyContact * const * contacts,
guint n_failed,
@@ -427,7 +426,7 @@ add_to_members (EmpathyTpContactList *list,
}
if (request->len > 0) {
- empathy_tp_contact_factory_get_from_handles (priv->factory,
+ empathy_tp_contact_factory_get_from_handles (priv->connection,
request->len, (TpHandle *) request->data,
got_added_members_cb, NULL, NULL, G_OBJECT (list));
}
@@ -436,7 +435,7 @@ add_to_members (EmpathyTpContactList *list,
}
static void
-tp_contact_list_got_local_pending_cb (EmpathyTpContactFactory *factory,
+tp_contact_list_got_local_pending_cb (TpConnection *connection,
guint n_contacts,
EmpathyContact * const * contacts,
guint n_failed,
@@ -562,7 +561,7 @@ tp_contact_list_publish_group_members_changed_cb (TpChannel *channel,
/* Those contacts want our presence, auto accept those that are already
* member, otherwise add in pendings. */
if (local_pending->len > 0) {
- empathy_tp_contact_factory_get_from_handles (priv->factory,
+ empathy_tp_contact_factory_get_from_handles (priv->connection,
local_pending->len, (TpHandle *) local_pending->data,
tp_contact_list_got_local_pending_cb, NULL, NULL,
G_OBJECT (list));
@@ -726,10 +725,6 @@ tp_contact_list_finalize (GObject *object)
g_object_unref (priv->connection);
}
- if (priv->factory) {
- g_object_unref (priv->factory);
- }
-
g_hash_table_iter_init (&iter, priv->groups);
while (g_hash_table_iter_next (&iter, NULL, &channel)) {
g_signal_handlers_disconnect_by_func (channel,
@@ -920,8 +915,6 @@ tp_contact_list_constructed (GObject *list)
{
EmpathyTpContactListPriv *priv = GET_PRIV (list);
- priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
-
/* call GetAliasFlags */
if (tp_proxy_has_interface_by_id (priv->connection,
TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING)) {