aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/Makefile.am2
-rw-r--r--libempathy/empathy-dispatcher.c1028
-rw-r--r--libempathy/empathy-dispatcher.h28
-rw-r--r--libempathy/empathy-handler.c416
-rw-r--r--libempathy/empathy-handler.h91
5 files changed, 37 insertions, 1528 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index ca0df9206..eb8a874c4 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -42,7 +42,6 @@ libempathy_headers = \
empathy-ft-factory.h \
empathy-ft-handler.h \
empathy-gsettings.h \
- empathy-handler.h \
empathy-idle.h \
empathy-individual-manager.h \
empathy-irc-network-manager.h \
@@ -79,7 +78,6 @@ libempathy_la_SOURCES = \
empathy-dispatcher.c \
empathy-ft-factory.c \
empathy-ft-handler.c \
- empathy-handler.c \
empathy-idle.c \
empathy-individual-manager.c \
empathy-irc-network-manager.c \
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 02500efcb..55dfcf074 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -45,7 +45,6 @@
#include <extensions/extensions.h>
#include "empathy-dispatcher.h"
-#include "empathy-handler.h"
#include "empathy-utils.h"
#include "empathy-tp-contact-factory.h"
#include "empathy-chatroom-manager.h"
@@ -69,12 +68,6 @@ typedef struct
GList *channels;
GPtrArray *array;
- /* main handler */
- EmpathyHandler *handler;
-
- /* extra handlers */
- GList *handlers;
-
GHashTable *request_channel_class_async_ids;
/* reffed (TpAccount *) => gulong
* Signal handler ID of the "status-changed" signal */
@@ -84,37 +77,8 @@ typedef struct
TpDBusDaemon *dbus;
} EmpathyDispatcherPriv;
-static GList *
-empathy_dispatcher_get_channels (EmpathyHandler *handler,
- gpointer user_data);
-
-static gboolean
-empathy_dispatcher_handle_channels (EmpathyHandler *handler,
- const gchar *account_path,
- const gchar *connection_path,
- const GPtrArray *channels,
- const GPtrArray *requests_satisfied,
- guint64 timestamp,
- GHashTable *handler_info,
- gpointer user_data,
- GError **error);
-
G_DEFINE_TYPE (EmpathyDispatcher, empathy_dispatcher, G_TYPE_OBJECT);
-enum
-{
- PROP_INTERFACES = 1,
- PROP_HANDLER,
-};
-
-enum
-{
- OBSERVE,
- DISPATCH,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
static EmpathyDispatcher *dispatcher = NULL;
static void dispatcher_init_connection_if_needed (
@@ -125,29 +89,6 @@ static GList * empathy_dispatcher_find_channel_classes
(EmpathyDispatcher *dispatcher, TpConnection *connection,
const gchar *channel_type, guint handle_type, GArray *fixed_properties);
-
-typedef struct
-{
- EmpathyDispatcher *dispatcher;
- EmpathyDispatchOperation *operation;
- TpConnection *connection;
- gboolean should_ensure;
- gchar *channel_type;
- guint handle_type;
- guint handle;
- EmpathyContact *contact;
- TpProxyPendingCall *pending_call;
-
- /* Properties to pass to the channel when requesting it */
- GHashTable *request;
- gint64 timestamp;
- EmpathyDispatcherRequestCb *cb;
- gpointer user_data;
- gpointer *request_data;
-
- TpChannelRequest *channel_request;
-} DispatcherRequestData;
-
typedef struct
{
TpChannel *channel;
@@ -157,13 +98,9 @@ typedef struct
typedef struct
{
- /* ObjectPath => DispatchData.. */
- GHashTable *dispatched_channels;
/* ObjectPath -> EmpathyDispatchOperations */
GHashTable *dispatching_channels;
- /* List of DispatcherRequestData */
- GList *outstanding_requests;
/* List of requestable channel classes */
GPtrArray *requestable_channels;
} ConnectionData;
@@ -179,104 +116,11 @@ typedef struct
gpointer user_data;
} FindChannelRequest;
-static void
-empathy_dispatcher_call_create_or_ensure_channel (
- EmpathyDispatcher *dispatcher,
- DispatcherRequestData *request_data);
-
-static void
-dispatcher_request_failed (EmpathyDispatcher *dispatcher,
- DispatcherRequestData *request_data,
- const GError *error);
-
-static DispatchData *
-new_dispatch_data (TpChannel *channel,
- GObject *channel_wrapper)
-{
- DispatchData *d = g_slice_new0 (DispatchData);
- d->channel = g_object_ref (channel);
- if (channel_wrapper != NULL)
- d->channel_wrapper = g_object_ref (channel_wrapper);
-
- return d;
-}
-
-static void
-free_dispatch_data (DispatchData *data)
-{
- g_object_unref (data->channel);
- if (data->channel_wrapper != NULL)
- g_object_unref (data->channel_wrapper);
-
- g_slice_free (DispatchData, data);
-}
-
-static DispatcherRequestData *
-new_dispatcher_request_data (EmpathyDispatcher *self,
- TpConnection *connection,
- const gchar *channel_type,
- guint handle_type,
- guint handle,
- GHashTable *request,
- gint64 timestamp,
- EmpathyContact *contact,
- EmpathyDispatcherRequestCb *cb,
- gpointer user_data)
-{
- DispatcherRequestData *result = g_slice_new0 (DispatcherRequestData);
-
- result->dispatcher = g_object_ref (self);
- result->connection = connection;
-
- result->should_ensure = FALSE;
-
- result->channel_type = g_strdup (channel_type);
- result->handle_type = handle_type;
- result->handle = handle;
- result->request = request;
- result->timestamp = timestamp;
-
- if (contact != NULL)
- result->contact = g_object_ref (contact);
-
- result->cb = cb;
- result->user_data = user_data;
-
- return result;
-}
-
-static void
-free_dispatcher_request_data (DispatcherRequestData *r)
-{
- g_free (r->channel_type);
-
- if (r->dispatcher != NULL)
- g_object_unref (r->dispatcher);
-
- if (r->contact != NULL)
- g_object_unref (r->contact);
-
- if (r->request != NULL)
- g_hash_table_unref (r->request);
-
-
- if (r->pending_call != NULL)
- tp_proxy_pending_call_cancel (r->pending_call);
-
- if (r->channel_request != NULL)
- g_object_unref (r->channel_request);
-
- g_slice_free (DispatcherRequestData, r);
-}
-
static ConnectionData *
new_connection_data (void)
{
ConnectionData *cd = g_slice_new0 (ConnectionData);
- cd->dispatched_channels = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) free_dispatch_data);
-
cd->dispatching_channels = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
@@ -286,17 +130,10 @@ new_connection_data (void)
static void
free_connection_data (ConnectionData *cd)
{
- GList *l;
guint i;
- g_hash_table_destroy (cd->dispatched_channels);
g_hash_table_destroy (cd->dispatching_channels);
- for (l = cd->outstanding_requests ; l != NULL; l = g_list_delete_link (l,l))
- {
- free_dispatcher_request_data (l->data);
- }
-
if (cd->requestable_channels != NULL)
{
for (i = 0 ; i < cd->requestable_channels->len ; i++)
@@ -337,69 +174,13 @@ dispatcher_connection_invalidated_cb (TpConnection *connection,
EmpathyDispatcher *self)
{
EmpathyDispatcherPriv *priv = GET_PRIV (self);
- ConnectionData *connection_data;
DEBUG ("Error: %s", message);
- /* Terminate pending requests, if any */
- connection_data = g_hash_table_lookup (priv->connections, connection);
- if (connection_data != NULL)
- {
- GList *l;
- GError *error = NULL;
-
- error = g_error_new_literal (domain, code, message);
-
- for (l = connection_data->outstanding_requests; l != NULL;
- l = g_list_next (l))
- {
- DispatcherRequestData *request_data = l->data;
-
- if (request_data->cb != NULL)
- request_data->cb (NULL, error, request_data->user_data);
- }
-
- g_error_free (error);
- }
-
g_hash_table_remove (priv->connections, connection);
}
static void
-dispatch_operation_flush_requests (EmpathyDispatcher *self,
- EmpathyDispatchOperation *operation,
- GError *error,
- ConnectionData *cd)
-{
- GList *l;
-
- l = cd->outstanding_requests;
- while (l != NULL)
- {
- DispatcherRequestData *d = (DispatcherRequestData *) l->data;
- GList *lt = l;
-
- l = g_list_next (l);
-
- if (d->operation == operation)
- {
- if (d->cb != NULL)
- {
- if (error != NULL)
- d->cb (NULL, error, d->user_data);
- else
- d->cb (operation, NULL, d->user_data);
- }
-
- cd->outstanding_requests = g_list_delete_link
- (cd->outstanding_requests, lt);
-
- free_dispatcher_request_data (d);
- }
- }
-}
-
-static void
dispatcher_channel_invalidated_cb (TpProxy *proxy,
guint domain,
gint code,
@@ -425,361 +206,69 @@ dispatcher_channel_invalidated_cb (TpProxy *proxy,
DEBUG ("Channel %s invalidated", object_path);
- g_hash_table_remove (cd->dispatched_channels, object_path);
- g_hash_table_remove (cd->dispatching_channels, object_path);
-}
-
-static void
-dispatch_operation_claimed_cb (EmpathyDispatchOperation *operation,
- EmpathyDispatcher *self)
-{
- /* Our job is done, remove the dispatch operation and mark the channel as
- * dispatched */
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- TpConnection *connection;
- ConnectionData *cd;
- const gchar *object_path;
-
- connection = empathy_dispatch_operation_get_tp_connection (operation);
- cd = g_hash_table_lookup (priv->connections, connection);
- g_assert (cd != NULL);
-
- object_path = empathy_dispatch_operation_get_object_path (operation);
-
- if (g_hash_table_lookup (cd->dispatched_channels, object_path) == NULL)
- {
- DispatchData *d;
- d = new_dispatch_data (
- empathy_dispatch_operation_get_channel (operation),
- empathy_dispatch_operation_get_channel_wrapper (operation));
- g_hash_table_insert (cd->dispatched_channels,
- g_strdup (object_path), d);
- }
g_hash_table_remove (cd->dispatching_channels, object_path);
-
- DEBUG ("Channel claimed: %s", object_path);
}
static void
-dispatch_operation_ready_cb (EmpathyDispatchOperation *operation,
- EmpathyDispatcher *self)
+got_connection_rcc (EmpathyDispatcher *self,
+ TpConnection *connection)
{
EmpathyDispatcherPriv *priv = GET_PRIV (self);
- TpConnection *connection;
+ TpCapabilities *caps;
ConnectionData *cd;
- EmpathyDispatchOperationState status;
-
- g_signal_connect (operation, "claimed",
- G_CALLBACK (dispatch_operation_claimed_cb), self);
-
- /* Signal the observers */
- DEBUG ("Send to observers: %s",
- empathy_dispatch_operation_get_object_path (operation));
- g_signal_emit (self, signals[OBSERVE], 0, operation);
+ GList *requests, *l;
+ FindChannelRequest *request;
+ GList *retval;
- empathy_dispatch_operation_start (operation);
+ caps = tp_connection_get_capabilities (connection);
+ g_assert (caps != NULL);
- /* Signal potential requestors */
- connection = empathy_dispatch_operation_get_tp_connection (operation);
cd = g_hash_table_lookup (priv->connections, connection);
g_assert (cd != NULL);
- g_object_ref (operation);
- g_object_ref (self);
-
- dispatch_operation_flush_requests (self, operation, NULL, cd);
- status = empathy_dispatch_operation_get_status (operation);
- g_object_unref (operation);
-
- if (status == EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED)
- return;
-
- g_assert (status == EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING);
- DEBUG ("Send of for dispatching: %s",
- empathy_dispatch_operation_get_object_path (operation));
- g_signal_emit (self, signals[DISPATCH], 0, operation);
-
- g_object_unref (self);
-}
-
-static void
-dispatcher_start_dispatching (EmpathyDispatcher *self,
- EmpathyDispatchOperation *operation,
- ConnectionData *cd)
-{
- const gchar *object_path =
- empathy_dispatch_operation_get_object_path (operation);
-
- DEBUG ("Dispatching process started for %s", object_path);
-
- if (g_hash_table_lookup (cd->dispatching_channels, object_path) == NULL)
- {
- g_hash_table_insert (cd->dispatching_channels,
- g_strdup (object_path), operation);
-
- switch (empathy_dispatch_operation_get_status (operation))
- {
- case EMPATHY_DISPATCHER_OPERATION_STATE_PREPARING:
- g_signal_connect (operation, "ready",
- G_CALLBACK (dispatch_operation_ready_cb), self);
- break;
- case EMPATHY_DISPATCHER_OPERATION_STATE_PENDING:
- dispatch_operation_ready_cb (operation, self);
- break;
- case EMPATHY_DISPATCHER_OPERATION_STATE_DISPATCHING:
- case EMPATHY_DISPATCHER_OPERATION_STATE_CLAIMED:
- case EMPATHY_DISPATCHER_OPERATION_STATE_INVALIDATED:
- default:
- g_assert_not_reached ();
- }
-
- }
- else if (empathy_dispatch_operation_get_status (operation) >=
- EMPATHY_DISPATCHER_OPERATION_STATE_PENDING)
- {
- /* Already dispatching and the operation is pending, thus the observers
- * have seen it (if applicable), so we can flush the request right away.
- */
- dispatch_operation_flush_requests (self, operation, NULL, cd);
- }
-}
-
-static void
-dispatcher_connection_new_channel (EmpathyDispatcher *self,
- TpConnection *connection,
- const gchar *object_path,
- const gchar *channel_type,
- guint handle_type,
- guint handle,
- GHashTable *properties,
- gboolean incoming,
- const GPtrArray *requests_satisfied,
- gint64 timestamp)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- TpChannel *channel;
- ConnectionData *cd;
- EmpathyDispatchOperation *operation;
- int i;
- /* Channel types we never want to dispatch because they're either deprecated
- * or can't sensibly be dispatch (e.g. channels that should always be
- * requested) */
- const char *blacklist[] = {
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
- TP_IFACE_CHANNEL_TYPE_TUBES,
- TP_IFACE_CHANNEL_TYPE_ROOM_LIST,
- NULL
- };
-
- dispatcher_init_connection_if_needed (self, connection);
-
- cd = g_hash_table_lookup (priv->connections, connection);
-
- for (i = 0 ; blacklist[i] != NULL; i++)
- {
- if (!tp_strdiff (channel_type, blacklist[i]))
- {
- DEBUG ("Ignoring blacklisted channel type %s on %s",
- channel_type, object_path);
- return;
- }
- }
+ cd->requestable_channels = g_boxed_copy (
+ TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
+ tp_capabilities_get_channel_classes (caps));
- DEBUG ("%s channel of type %s on %s", incoming ? "incoming" : "outgoing",
- channel_type, object_path);
-
- if (properties == NULL)
- channel = tp_channel_new (connection, object_path, channel_type,
- handle_type, handle, NULL);
- else
- channel = tp_channel_new_from_properties (connection, object_path,
- properties, NULL);
-
- g_signal_connect (channel, "invalidated",
- G_CALLBACK (dispatcher_channel_invalidated_cb),
- self);
-
- priv->channels = g_list_prepend (priv->channels, channel);
-
- operation = empathy_dispatch_operation_new (connection, channel, NULL,
- incoming, timestamp);
-
- g_object_unref (channel);
-
- if (!incoming && requests_satisfied != NULL)
- {
- GList *l;
- gboolean found = FALSE;
-
- l = cd->outstanding_requests;
-
- while (l != NULL)
- {
- DispatcherRequestData *d = (DispatcherRequestData *) l->data;
- guint n;
- const gchar *path;
-
- l = g_list_next (l);
- if (d->request == NULL)
- continue;
-
- if (d->operation != NULL)
- continue;
-
- path = tp_proxy_get_object_path (d->channel_request);
- for (n = 0; n < requests_satisfied->len ; n++)
- {
- const gchar *p = g_ptr_array_index (requests_satisfied, n);
- if (!tp_strdiff (p, path))
- {
- DEBUG ("Channel satified request %s"
- "(already dispatched: %d)", p, found);
- if (!found)
- {
- d->operation = operation;
- found = TRUE;
- continue;
- }
- else
- {
- GError err = { TP_ERRORS, TP_ERROR_NOT_YOURS,
- "Not yours!" };
- dispatcher_request_failed (dispatcher, d, &err);
- }
- }
- }
- }
- }
-
- dispatcher_start_dispatching (dispatcher, operation, cd);
-}
-
-static void
-dispatcher_connection_new_channel_with_properties (
- EmpathyDispatcher *self,
- TpConnection *connection,
- const gchar *object_path,
- GHashTable *properties,
- const GPtrArray *requests_satisfied,
- gint64 timestamp)
-{
- const gchar *channel_type;
- guint handle_type;
- guint handle;
- gboolean requested;
- gboolean valid;
+ requests = g_hash_table_lookup (priv->outstanding_classes_requests,
+ connection);
- channel_type = tp_asv_get_string (properties,
- TP_IFACE_CHANNEL ".ChannelType");
- if (channel_type == NULL)
+ for (l = requests; l != NULL; l = l->next)
{
- g_message ("%s had an invalid ChannelType property", object_path);
- return;
- }
+ request = l->data;
- handle_type = tp_asv_get_uint32 (properties,
- TP_IFACE_CHANNEL ".TargetHandleType", &valid);
- if (!valid)
- {
- g_message ("%s had an invalid TargetHandleType property", object_path);
- return;
- }
+ retval = empathy_dispatcher_find_channel_classes (self,
+ connection, request->channel_type,
+ request->handle_type, request->properties);
+ request->callback (retval, request->user_data);
- handle = tp_asv_get_uint32 (properties,
- TP_IFACE_CHANNEL ".TargetHandle", &valid);
- if (!valid)
- {
- g_message ("%s had an invalid TargetHandle property", object_path);
- return;
+ free_find_channel_request (request);
+ g_list_free (retval);
}
- /* We assume there is no channel dispather, so we're the only one dispatching
- * it. Which means that a requested channel it is outgoing one */
- requested = tp_asv_get_boolean (properties,
- TP_IFACE_CHANNEL ".Requested", &valid);
- if (!valid)
- {
- g_message ("%s had an invalid Requested property", object_path);
- requested = FALSE;
- }
+ g_list_free (requests);
- dispatcher_connection_new_channel (self, connection,
- object_path, channel_type, handle_type, handle, properties, !requested,
- requests_satisfied, timestamp);
+ g_hash_table_remove (priv->outstanding_classes_requests, connection);
}
static void
-dispatcher_connection_got_all (TpProxy *proxy,
- GHashTable *properties,
- const GError *error,
- gpointer user_data,
- GObject *object)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (object);
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- GPtrArray *requestable_channels;
-
- if (error) {
- DEBUG ("Error: %s", error->message);
- return;
- }
-
- requestable_channels = tp_asv_get_boxed (properties,
- "RequestableChannelClasses", TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST);
-
- if (requestable_channels == NULL)
- DEBUG ("No RequestableChannelClasses property !?! on connection");
- else
- {
- ConnectionData *cd;
- GList *requests, *l;
- FindChannelRequest *request;
- GList *retval;
-
- cd = g_hash_table_lookup (priv->connections, proxy);
- g_assert (cd != NULL);
-
- cd->requestable_channels = g_boxed_copy (
- TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, requestable_channels);
-
- requests = g_hash_table_lookup (priv->outstanding_classes_requests,
- proxy);
-
- for (l = requests; l != NULL; l = l->next)
- {
- request = l->data;
-
- retval = empathy_dispatcher_find_channel_classes (self,
- TP_CONNECTION (proxy), request->channel_type,
- request->handle_type, request->properties);
- request->callback (retval, request->user_data);
-
- free_find_channel_request (request);
- g_list_free (retval);
- }
-
- g_list_free (requests);
-
- g_hash_table_remove (priv->outstanding_classes_requests, proxy);
- }
-}
-
-static void
-connection_ready_cb (TpConnection *connection,
- const GError *error,
+connection_prepare_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
EmpathyDispatcher *self = EMPATHY_DISPATCHER (user_data);
+ GError *error = NULL;
+ TpConnection *connection = (TpConnection *) source;
- if (error != NULL)
+ if (!tp_proxy_prepare_finish (source, result, &error))
{
DEBUG ("Error: %s", error->message);
+
+ g_error_free (error);
goto out;
}
- tp_cli_dbus_properties_call_get_all (connection, -1,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS, dispatcher_connection_got_all,
- NULL, NULL, G_OBJECT (self));
+ got_connection_rcc (self, connection);
out:
g_object_unref (self);
@@ -790,6 +279,9 @@ dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
TpConnection *connection)
{
EmpathyDispatcherPriv *priv = GET_PRIV (self);
+ GQuark features[] = { TP_CONNECTION_FEATURE_CORE,
+ TP_CONNECTION_FEATURE_CAPABILITIES,
+ 0 };
if (g_hash_table_lookup (priv->connections, connection) != NULL)
return;
@@ -800,10 +292,10 @@ dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
g_signal_connect (connection, "invalidated",
G_CALLBACK (dispatcher_connection_invalidated_cb), self);
- /* Ensure to keep the self object alive while the call_when_ready is
- * running */
+ /* Ensure to keep the self object alive while preparing the connection */
g_object_ref (self);
- tp_connection_call_when_ready (connection, connection_ready_cb, self);
+
+ tp_proxy_prepare_async (connection, features, connection_prepare_cb, self);
}
static void
@@ -851,17 +343,6 @@ dispatcher_constructor (GType type,
priv = GET_PRIV (dispatcher);
- if (priv->handler == NULL)
- priv->handler = empathy_handler_new (NULL, NULL, NULL);
-
- empathy_handler_set_handle_channels_func (priv->handler,
- empathy_dispatcher_handle_channels,
- dispatcher);
-
- empathy_handler_set_channels_func (priv->handler,
- empathy_dispatcher_get_channels,
- dispatcher);
-
return retval;
}
@@ -871,23 +352,12 @@ dispatcher_dispose (GObject *object)
EmpathyDispatcherPriv *priv = GET_PRIV (object);
GHashTableIter iter;
gpointer connection;
- GList *l;
if (priv->dispose_has_run)
return;
priv->dispose_has_run = TRUE;
- for (l = priv->handlers ; l != NULL; l = g_list_next (l))
- g_object_unref (G_OBJECT (l->data));
-
- g_list_free (priv->handlers);
- priv->handlers = NULL;
-
- if (priv->handler != NULL)
- g_object_unref (priv->handler);
- priv->handler = NULL;
-
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, &connection, NULL))
{
@@ -954,86 +424,14 @@ dispatcher_finalize (GObject *object)
}
static void
-dispatcher_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (object);
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_HANDLER:
- priv->handler = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-dispatcher_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (object);
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_HANDLER:
- g_value_set_object (value, priv->handler);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
empathy_dispatcher_class_init (EmpathyDispatcherClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
object_class->dispose = dispatcher_dispose;
object_class->finalize = dispatcher_finalize;
object_class->constructor = dispatcher_constructor;
- object_class->get_property = dispatcher_get_property;
- object_class->set_property = dispatcher_set_property;
-
- param_spec = g_param_spec_object ("handler", "handler",
- "The main Telepathy Client Hander object",
- EMPATHY_TYPE_HANDLER,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class,
- PROP_HANDLER, param_spec);
-
- signals[OBSERVE] =
- g_signal_new ("observe",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_DISPATCH_OPERATION);
-
- signals[DISPATCH] =
- g_signal_new ("dispatch",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1, EMPATHY_TYPE_DISPATCH_OPERATION);
-
-
g_type_class_add_private (object_class, sizeof (EmpathyDispatcherPriv));
}
@@ -1155,54 +553,11 @@ empathy_dispatcher_init (EmpathyDispatcher *self)
}
EmpathyDispatcher *
-empathy_dispatcher_new (const gchar *name,
- GPtrArray *filters,
- GStrv capabilities)
-{
- EmpathyHandler *handler;
- EmpathyDispatcher *ret;
-
- g_assert (dispatcher == NULL);
- handler = empathy_handler_new (name, filters, capabilities);
-
- ret = EMPATHY_DISPATCHER (
- g_object_new (EMPATHY_TYPE_DISPATCHER,
- "handler", handler,
- NULL));
- g_object_unref (handler);
-
- return ret;
-}
-
-EmpathyDispatcher *
empathy_dispatcher_dup_singleton (void)
{
return EMPATHY_DISPATCHER (g_object_new (EMPATHY_TYPE_DISPATCHER, NULL));
}
-static void
-dispatcher_request_failed (EmpathyDispatcher *self,
- DispatcherRequestData *request_data,
- const GError *error)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- ConnectionData *conn_data;
-
- conn_data = g_hash_table_lookup (priv->connections,
- request_data->connection);
- if (request_data->cb != NULL)
- request_data->cb (NULL, error, request_data->user_data);
-
- if (conn_data != NULL)
- {
- conn_data->outstanding_requests =
- g_list_remove (conn_data->outstanding_requests, request_data);
- }
- /* else Connection has been invalidated */
-
- free_dispatcher_request_data (request_data);
-}
-
void
empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
gint64 timestamp)
@@ -1275,221 +630,6 @@ empathy_dispatcher_join_muc (TpAccount *account,
g_object_unref (req);
}
-static void
-dispatcher_channel_request_failed_cb (TpChannelRequest *request,
- const gchar *error,
- const gchar *message,
- gpointer user_data,
- GObject *weak_object)
-{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
- EmpathyDispatcher *self =
- EMPATHY_DISPATCHER (request_data->dispatcher);
- GError *err = NULL;
-
- request_data->pending_call = NULL;
-
- DEBUG ("Request failed: %s - %s %s",
- tp_proxy_get_object_path (request),
- error, message);
-
- tp_proxy_dbus_error_to_gerror (TP_PROXY (request),
- error, message, &err);
-
- dispatcher_request_failed (self, request_data, err);
-
- g_error_free (err);
-}
-
-static void
-dispatcher_channel_request_succeeded_cb (TpChannelRequest *request,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (weak_object);
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
- ConnectionData *conn_data;
-
- conn_data = g_hash_table_lookup (priv->connections,
- request_data->connection);
-
- DEBUG ("Request succeeded: %s", tp_proxy_get_object_path (request));
-
- /* When success gets called the internal request should have been satisfied,
- * if it's still in outstanding_requests and doesn't have an operation
- * assigned to it, the channel got handled by someone else.. */
-
- if (g_list_find (conn_data->outstanding_requests, request_data) == NULL)
- return;
-
- if (request_data->operation == NULL)
- {
- GError err = { TP_ERRORS, TP_ERROR_NOT_YOURS, "Not yours!" };
- dispatcher_request_failed (self, request_data, &err);
- }
-}
-
-static void
-dispatcher_channel_request_proceed_cb (TpChannelRequest *request,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (weak_object);
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
-
- request_data->pending_call = NULL;
-
- if (error != NULL)
- dispatcher_request_failed (self, request_data, error);
-}
-
-static void
-dispatcher_create_channel_cb (TpChannelDispatcher *proxy,
- const gchar *request_path,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (request_data->dispatcher);
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpChannelRequest *request;
- GError *err = NULL;
- TpProxyPendingCall *call;
-
- request_data->pending_call = NULL;
-
- if (error != NULL)
- {
- dispatcher_request_failed (self, request_data, error);
- return;
- }
-
- request = tp_channel_request_new (priv->dbus, request_path, NULL, NULL);
- request_data->channel_request = request;
-
- if (tp_cli_channel_request_connect_to_failed (request,
- dispatcher_channel_request_failed_cb, request_data,
- NULL, G_OBJECT (self), &err) == NULL)
- {
- dispatcher_request_failed (self, request_data, err);
- g_error_free (err);
- return;
- }
-
- if (tp_cli_channel_request_connect_to_succeeded (request,
- dispatcher_channel_request_succeeded_cb, request_data,
- NULL, G_OBJECT (self), &err) == NULL)
- {
- dispatcher_request_failed (self, request_data, err);
- g_error_free (err);
- return;
- }
-
- call = tp_cli_channel_request_call_proceed (request,
- -1, dispatcher_channel_request_proceed_cb,
- request_data, NULL, G_OBJECT (self));
-
- if (call != NULL)
- request_data->pending_call = call;
-}
-
-static void
-empathy_dispatcher_call_create_or_ensure_channel (
- EmpathyDispatcher *self,
- DispatcherRequestData *request_data)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
- TpAccount *account;
- const gchar *handler = "";
- TpProxyPendingCall *call;
-
- account = empathy_get_account_for_connection (request_data->connection);
-
- g_assert (account != NULL);
-
- if (request_data->cb)
- handler = empathy_handler_get_busname (priv->handler);
-
- if (request_data->should_ensure)
- {
- call = tp_cli_channel_dispatcher_call_ensure_channel (
- priv->channel_dispatcher,
- -1, tp_proxy_get_object_path (TP_PROXY (account)),
- request_data->request, request_data->timestamp, handler,
- dispatcher_create_channel_cb, request_data, NULL, NULL);
- }
- else
- {
- call = tp_cli_channel_dispatcher_call_create_channel (
- priv->channel_dispatcher,
- -1, tp_proxy_get_object_path (TP_PROXY (account)),
- request_data->request, request_data->timestamp, handler,
- dispatcher_create_channel_cb, request_data, NULL,
- G_OBJECT (dispatcher));
- }
-
- if (call != NULL)
- request_data->pending_call = call;
-}
-
-/**
- * empathy_dispatcher_create_channel:
- * @self: the EmpathyDispatcher
- * @connection: the Connection to dispatch on
- * @request: an a{sv} map of properties for the request, i.e. using tp_asv_new()
- * @callback: a callback for when the channel arrives (or NULL)
- * @user_data: optional user data (or NULL)
- *
- * When calling this function, #EmpathyDispatcher takes ownership of your
- * reference to @request. DO NOT unref or destroy @request. When the request is
- * done, @request will be unreferenced. Take another reference if you want to
- * keep it around.
- */
-void
-empathy_dispatcher_create_channel (EmpathyDispatcher *self,
- TpConnection *connection,
- GHashTable *request,
- gint64 timestamp,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- ConnectionData *connection_data;
- DispatcherRequestData *request_data;
- const gchar *channel_type;
- guint handle_type;
- guint handle;
- gboolean valid;
-
- g_return_if_fail (EMPATHY_IS_DISPATCHER (self));
- g_return_if_fail (TP_IS_CONNECTION (connection));
- g_return_if_fail (request != NULL);
-
- connection_data = g_hash_table_lookup (priv->connections, connection);
- g_assert (connection_data != NULL);
-
- channel_type = tp_asv_get_string (request, TP_IFACE_CHANNEL ".ChannelType");
-
- handle_type = tp_asv_get_uint32 (request,
- TP_IFACE_CHANNEL ".TargetHandleType", &valid);
- if (!valid)
- handle_type = TP_UNKNOWN_HANDLE_TYPE;
-
- handle = tp_asv_get_uint32 (request, TP_IFACE_CHANNEL ".TargetHandle", NULL);
-
- request_data = new_dispatcher_request_data (self, connection,
- channel_type, handle_type, handle, request, timestamp,
- NULL, callback, user_data);
-
- connection_data->outstanding_requests = g_list_prepend
- (connection_data->outstanding_requests, request_data);
-
- empathy_dispatcher_call_create_or_ensure_channel (self, request_data);
-}
-
static gboolean
channel_class_matches (GValueArray *class,
const char *channel_type,
@@ -1816,97 +956,3 @@ empathy_dispatcher_find_requestable_channel_classes_async
g_hash_table_insert (priv->request_channel_class_async_ids,
request, GUINT_TO_POINTER (source_id));
}
-
-static GList *
-empathy_dispatcher_get_channels (EmpathyHandler *handler,
- gpointer user_data)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (user_data);
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
-
- return priv->channels;
-}
-
-static gboolean
-empathy_dispatcher_handle_channels (EmpathyHandler *handler,
- const gchar *account_path,
- const gchar *connection_path,
- const GPtrArray *channels,
- const GPtrArray *requests_satisfied,
- guint64 timestamp,
- GHashTable *handler_info,
- gpointer user_data,
- GError **error)
-{
- EmpathyDispatcher *self = EMPATHY_DISPATCHER (user_data);
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- guint i;
- TpAccount *account;
- TpConnection *connection;
-
- /* FIXME: should probably find out whether the account manager is prepared
- * before ensuring. See bug #600111. */
- account = tp_account_manager_ensure_account (priv->account_manager,
- account_path);
- g_assert (account != NULL);
-
- connection = tp_account_ensure_connection (account, connection_path);
- if (connection == NULL)
- {
- g_set_error_literal (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
- "Invalid connection argument");
- return FALSE;
- }
-
- for (i = 0; i < channels->len ; i++)
- {
- GValueArray *arr = g_ptr_array_index (channels, i);
- const gchar *object_path;
- GHashTable *properties;
-
- object_path = g_value_get_boxed (g_value_array_get_nth (arr, 0));
- properties = g_value_get_boxed (g_value_array_get_nth (arr, 1));
-
- dispatcher_connection_new_channel_with_properties (self,
- connection, object_path, properties, requests_satisfied, timestamp);
- }
-
- return TRUE;
-}
-
-
-EmpathyHandler *
-empathy_dispatcher_add_handler (EmpathyDispatcher *self,
- const gchar *name,
- GPtrArray *filters,
- GStrv capabilities)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- EmpathyHandler *handler;
-
- handler = empathy_handler_new (name, filters, capabilities);
- priv->handlers = g_list_prepend (priv->handlers, handler);
-
- /* Only set the handle_channels function, the Channel property on the main
- * handler will always report all dispatched channels even if they came from
- * a different Handler */
- empathy_handler_set_handle_channels_func (handler,
- empathy_dispatcher_handle_channels, self);
-
- return handler;
-}
-
-void
-empathy_dispatcher_remove_handler (EmpathyDispatcher *self,
- EmpathyHandler *handler)
-{
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
- GList *h;
-
- h = g_list_find (priv->handlers, handler);
- g_return_if_fail (h != NULL);
-
- priv->handlers = g_list_delete_link (priv->handlers, h);
-
- g_object_unref (handler);
-}
diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h
index 7991de085..c44ac9d01 100644
--- a/libempathy/empathy-dispatcher.h
+++ b/libempathy/empathy-dispatcher.h
@@ -28,7 +28,6 @@
#include <telepathy-glib/channel.h>
#include "empathy-contact.h"
-#include "empathy-handler.h"
#include "empathy-dispatch-operation.h"
G_BEGIN_DECLS
@@ -57,23 +56,11 @@ struct _EmpathyDispatcherClass
GObjectClass parent_class;
};
-/* Will be called when the channel is ready for dispatching. The requestor
- * handle the channel itself by calling empathy_dispatch_operation_handles */
-typedef void (EmpathyDispatcherRequestCb) (
- EmpathyDispatchOperation *dispatch, const GError *error,
- gpointer user_data);
typedef void (EmpathyDispatcherFindChannelClassCb) (
GList *channel_classes, gpointer user_data);
GType empathy_dispatcher_get_type (void) G_GNUC_CONST;
-void empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher,
- TpConnection *connection,
- GHashTable *request,
- gint64 timestamp,
- EmpathyDispatcherRequestCb *callback,
- gpointer user_data);
-
/* Requesting 1 to 1 text channels */
void empathy_dispatcher_chat_with_contact_id (TpAccount *account,
const gchar *contact_id,
@@ -98,21 +85,6 @@ GList * empathy_dispatcher_find_requestable_channel_classes
const gchar *channel_type, guint handle_type,
const char *first_property_name, ...);
-/* Create the dispatcher singleton */
-EmpathyDispatcher * empathy_dispatcher_new (const gchar *name,
- GPtrArray *filters,
- GStrv capabilities);
-
-EmpathyHandler *
-empathy_dispatcher_add_handler (EmpathyDispatcher *dispatcher,
- const gchar *name,
- GPtrArray *filters,
- GStrv capabilities);
-
-void
-empathy_dispatcher_remove_handler (EmpathyDispatcher *dispatcher,
- EmpathyHandler *handler);
-
/* Get the dispatcher singleton */
EmpathyDispatcher * empathy_dispatcher_dup_singleton (void);
diff --git a/libempathy/empathy-handler.c b/libempathy/empathy-handler.c
deleted file mode 100644
index 20850cd60..000000000
--- a/libempathy/empathy-handler.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * Copyright (C) 2007-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: Xavier Claessens <xclaesse@gmail.com>
- * Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/proxy-subclass.h>
-#include <telepathy-glib/gtypes.h>
-#include <telepathy-glib/defs.h>
-#include <telepathy-glib/svc-client.h>
-#include <telepathy-glib/svc-generic.h>
-#include <telepathy-glib/interfaces.h>
-
-#include "empathy-handler.h"
-#include "empathy-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
-#include <libempathy/empathy-debug.h>
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyHandler)
-typedef struct
-{
- EmpathyHandlerHandleChannelsFunc *handle_channels;
- gpointer handle_channels_user_data;
-
- EmpathyHandlerChannelsFunc *channels;
- gpointer channels_user_data;
-
- gchar *name;
- gchar *busname;
-
- GPtrArray *filters;
- GStrv *capabilities;
-
- gboolean dispose_run;
-} EmpathyHandlerPriv;
-
-static void empathy_handler_client_handler_iface_init (gpointer g_iface,
- gpointer g_iface_data);
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyHandler,
- empathy_handler,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
- tp_dbus_properties_mixin_iface_init);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CLIENT, NULL);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CLIENT_HANDLER,
- empathy_handler_client_handler_iface_init);
- );
-
-static const gchar *empathy_handler_interfaces[] = {
- TP_IFACE_CLIENT_HANDLER,
- NULL
-};
-
-enum
-{
- PROP_INTERFACES = 1,
- PROP_CHANNEL_FILTER,
- PROP_CHANNELS,
- PROP_CAPABILITIES,
- PROP_NAME,
-};
-
-static GObject *
-handler_constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *obj =
- G_OBJECT_CLASS (empathy_handler_parent_class)->constructor
- (type, n_construct_params, construct_params);
- EmpathyHandler *handler = EMPATHY_HANDLER (obj);
- EmpathyHandlerPriv *priv = GET_PRIV (handler);
- TpDBusDaemon *dbus;
- gchar *object_path;
-
- priv = GET_PRIV (handler);
-
- priv->busname = g_strdup_printf (TP_CLIENT_BUS_NAME_BASE"%s", priv->name);
- object_path = g_strdup_printf (TP_CLIENT_OBJECT_PATH_BASE"%s",
- priv->name);
-
- dbus = tp_dbus_daemon_dup (NULL);
-
- DEBUG ("Registering at %s, %s", priv->busname, object_path);
- g_assert (tp_dbus_daemon_request_name (dbus,
- priv->busname, TRUE, NULL));
- dbus_g_connection_register_g_object (tp_proxy_get_dbus_connection (dbus),
- object_path, obj);
-
-
- g_free (object_path);
- g_object_unref (dbus);
-
- return G_OBJECT (handler);
-}
-
-static void
-handler_dispose (GObject *object)
-{
- EmpathyHandlerPriv *priv = GET_PRIV (object);
- TpDBusDaemon *dbus;
-
- if (priv->dispose_run)
- return;
-
- priv->dispose_run = TRUE;
-
- dbus = tp_dbus_daemon_dup (NULL);
-
- tp_dbus_daemon_release_name (dbus, priv->busname, NULL);
-
- g_object_unref (dbus);
-
- if (G_OBJECT_CLASS (empathy_handler_parent_class)->dispose != NULL)
- G_OBJECT_CLASS (empathy_handler_parent_class)->dispose (object);
-}
-
-static void
-handler_finalize (GObject *object)
-{
- EmpathyHandlerPriv *priv = GET_PRIV (object);
-
- if (priv->filters != NULL)
- g_boxed_free (TP_ARRAY_TYPE_CHANNEL_CLASS_LIST, priv->filters);
-
- if (priv->capabilities != NULL)
- g_boxed_free (G_TYPE_STRV, priv->capabilities);
-
- g_free (priv->name);
- g_free (priv->busname);
-
- if (G_OBJECT_CLASS (empathy_handler_parent_class)->finalize != NULL)
- G_OBJECT_CLASS (empathy_handler_parent_class)->finalize (object);
-}
-
-static void
-handler_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyHandler *handler = EMPATHY_HANDLER (object);
- EmpathyHandlerPriv *priv = GET_PRIV (handler);
-
- switch (property_id)
- {
- case PROP_CHANNEL_FILTER:
- priv->filters = g_value_dup_boxed (value);
- if (priv->filters == NULL)
- priv->filters = g_ptr_array_new ();
- break;
- case PROP_CAPABILITIES:
- priv->capabilities = g_value_dup_boxed (value);
- break;
- case PROP_NAME:
- priv->name = g_value_dup_string (value);
- if (EMP_STR_EMPTY (priv->name))
- {
- TpDBusDaemon *bus;
-
- bus = tp_dbus_daemon_dup (NULL);
- priv->name = g_strdup_printf ("badger_%s_%p",
- tp_dbus_daemon_get_unique_name (bus), object);
- g_strdelimit (priv->name, ":.", '_');
- g_object_unref (bus);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-handler_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyHandler *self = EMPATHY_HANDLER (object);
- EmpathyHandlerPriv *priv = GET_PRIV (self);
-
- switch (property_id)
- {
- case PROP_INTERFACES:
- g_value_set_boxed (value, empathy_handler_interfaces);
- break;
- case PROP_CHANNEL_FILTER:
- g_value_set_boxed (value, priv->filters);
- break;
- case PROP_CAPABILITIES:
- g_value_set_boxed (value, priv->capabilities);
- break;
- case PROP_NAME:
- g_value_set_string (value, priv->name);
- break;
- case PROP_CHANNELS:
- {
- GList *l, *channels = NULL;
- GPtrArray *array = g_ptr_array_new ();
-
- if (priv->channels != NULL)
- channels = priv->channels (self, priv->channels_user_data);
-
- for (l = channels ; l != NULL; l = g_list_next (l))
- {
- TpProxy *channel = TP_PROXY (l->data);
- g_ptr_array_add (array,
- (gpointer) tp_proxy_get_object_path (channel));
- }
- g_value_set_boxed (value, array);
- g_ptr_array_free (array, TRUE);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-empathy_handler_class_init (EmpathyHandlerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- static TpDBusPropertiesMixinPropImpl client_props[] = {
- { "Interfaces", "interfaces", NULL },
- { NULL }
- };
- static TpDBusPropertiesMixinPropImpl client_handler_props[] = {
- { "HandlerChannelFilter", "channel-filter", NULL },
- { "HandledChannels", "channels", NULL },
- { "Capabilities", "capabilities", NULL },
- { NULL }
- };
- static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
- { TP_IFACE_CLIENT,
- tp_dbus_properties_mixin_getter_gobject_properties,
- NULL,
- client_props
- },
- { TP_IFACE_CLIENT_HANDLER,
- tp_dbus_properties_mixin_getter_gobject_properties,
- NULL,
- client_handler_props
- },
- { NULL }
- };
-
- object_class->finalize = handler_finalize;
- object_class->dispose = handler_dispose;
- object_class->constructor = handler_constructor;
-
- object_class->get_property = handler_get_property;
- object_class->set_property = handler_set_property;
-
- param_spec = g_param_spec_boxed ("interfaces", "interfaces",
- "Available D-Bus interfaces",
- G_TYPE_STRV,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INTERFACES, param_spec);
-
- param_spec = g_param_spec_boxed ("channel-filter", "channel-filter",
- "Filter for channels this handles",
- TP_ARRAY_TYPE_CHANNEL_CLASS_LIST,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class,
- PROP_CHANNEL_FILTER, param_spec);
-
- param_spec = g_param_spec_boxed ("capabilities", "capabilities",
- "Filter for channels this handles",
- G_TYPE_STRV,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class,
- PROP_CAPABILITIES, param_spec);
-
- param_spec = g_param_spec_boxed ("channels", "channels",
- "List of channels we're handling",
- EMPATHY_ARRAY_TYPE_OBJECT,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class,
- PROP_CHANNELS, param_spec);
-
- param_spec = g_param_spec_string ("name", "name",
- "The local name of the handler",
- NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class,
- PROP_NAME, param_spec);
-
- g_type_class_add_private (object_class, sizeof (EmpathyHandlerPriv));
-
- klass->dbus_props_class.interfaces = prop_interfaces;
- tp_dbus_properties_mixin_class_init (object_class,
- G_STRUCT_OFFSET (EmpathyHandlerClass, dbus_props_class));
-}
-
-static void
-empathy_handler_init (EmpathyHandler *handler)
-{
- EmpathyHandlerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (handler,
- EMPATHY_TYPE_HANDLER, EmpathyHandlerPriv);
-
- handler->priv = priv;
-}
-
-EmpathyHandler *
-empathy_handler_new (const gchar *name,
- GPtrArray *filters,
- GStrv capabilities)
-{
- return EMPATHY_HANDLER (
- g_object_new (EMPATHY_TYPE_HANDLER,
- "name", name,
- "channel-filter", filters,
- "capabilities", capabilities,
- NULL));
-}
-
-static void
-empathy_handler_handle_channels (TpSvcClientHandler *self,
- const gchar *account_path,
- const gchar *connection_path,
- const GPtrArray *channels,
- const GPtrArray *requests_satisfied,
- guint64 timestamp,
- GHashTable *handler_info,
- DBusGMethodInvocation *context)
-{
- EmpathyHandler *handler = EMPATHY_HANDLER (self);
- EmpathyHandlerPriv *priv = GET_PRIV (handler);
- GError *error = NULL;
-
- if (!priv->handle_channels)
- {
- error = g_error_new_literal (TP_ERRORS,
- TP_ERROR_NOT_AVAILABLE,
- "No handler function setup");
- goto error;
- }
-
- if (!priv->handle_channels (handler, account_path, connection_path,
- channels, requests_satisfied, timestamp, handler_info,
- priv->handle_channels_user_data, &error))
- goto error;
-
- tp_svc_client_handler_return_from_handle_channels (context);
- return;
-
-error:
- dbus_g_method_return_error (context, error);
- g_error_free (error);
-}
-
-const gchar *
-empathy_handler_get_busname (EmpathyHandler *handler)
-{
- EmpathyHandlerPriv *priv = GET_PRIV (handler);
-
- return priv->busname;
-}
-
-static void
-empathy_handler_client_handler_iface_init (gpointer g_iface,
- gpointer g_iface_data)
-{
- TpSvcClientHandlerClass *klass = (TpSvcClientHandlerClass *) g_iface;
-
- tp_svc_client_handler_implement_handle_channels (klass,
- empathy_handler_handle_channels);
-}
-
-void
-empathy_handler_set_handle_channels_func (EmpathyHandler *handler,
- EmpathyHandlerHandleChannelsFunc *func,
- gpointer user_data)
-{
- EmpathyHandlerPriv *priv = GET_PRIV (handler);
-
- priv->handle_channels = func;
- priv->handle_channels_user_data = user_data;
-}
-
-void
-empathy_handler_set_channels_func (EmpathyHandler *handler,
- EmpathyHandlerChannelsFunc *func,
- gpointer user_data)
-{
- EmpathyHandlerPriv *priv = GET_PRIV (handler);
-
- priv->channels = func;
- priv->channels_user_data = user_data;
-}
-
diff --git a/libempathy/empathy-handler.h b/libempathy/empathy-handler.h
deleted file mode 100644
index f6b894ba0..000000000
--- a/libempathy/empathy-handler.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2007-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: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
- */
-
-#ifndef __EMPATHY_HANDLER_H__
-#define __EMPATHY_HANDLER_H__
-
-#include <glib.h>
-
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/dbus-properties-mixin.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_HANDLER (empathy_handler_get_type ())
-#define EMPATHY_HANDLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
- EMPATHY_TYPE_HANDLER, EmpathyHandler))
-#define EMPATHY_HANDLER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
- EMPATHY_TYPE_HANDLER, EmpathyHandlerClass))
-#define EMPATHY_IS_HANDLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
- EMPATHY_TYPE_HANDLER))
-#define EMPATHY_IS_HANDLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
- EMPATHY_TYPE_HANDLER))
-#define EMPATHY_HANDLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
- EMPATHY_TYPE_HANDLER, EmpathyHandlerClass))
-
-GType empathy_handler_get_type (void) G_GNUC_CONST;
-
-typedef struct _EmpathyHandler EmpathyHandler;
-typedef struct _EmpathyHandlerClass EmpathyHandlerClass;
-
-struct _EmpathyHandler
-{
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyHandlerClass
-{
- GObjectClass parent_class;
- TpDBusPropertiesMixinClass dbus_props_class;
-};
-
-
-EmpathyHandler * empathy_handler_new (const gchar *name,
- GPtrArray *filters,
- GStrv capabilities);
-
-const gchar *empathy_handler_get_busname (EmpathyHandler *handler);
-
-typedef gboolean (EmpathyHandlerHandleChannelsFunc) (EmpathyHandler *handler,
- const gchar *account_path,
- const gchar *connection_path,
- const GPtrArray *channels,
- const GPtrArray *requests_satisfied,
- guint64 timestamp,
- GHashTable *handler_info,
- gpointer user_data,
- GError **error);
-
-void empathy_handler_set_handle_channels_func (EmpathyHandler *handler,
- EmpathyHandlerHandleChannelsFunc *func,
- gpointer user_data);
-
-typedef GList * (EmpathyHandlerChannelsFunc) (
- EmpathyHandler *handler,
- gpointer user_data);
-
-void empathy_handler_set_channels_func (EmpathyHandler *handler,
- EmpathyHandlerChannelsFunc func,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_HANDLER_H__ */