From 9fba2ff5b90124c84f33c0aac7bd096cfbc275c4 Mon Sep 17 00:00:00 2001
From: Jonny Lamb
Date: Thu, 22 Jul 2010 11:58:49 +0100
Subject: extensions: add Conn.I.ClientType draft
Signed-off-by: Jonny Lamb
---
extensions/Connection_Interface_Client_Type.xml | 199 ++++++++++++++++++++++++
extensions/Makefile.am | 3 +-
extensions/all.xml | 1 +
3 files changed, 202 insertions(+), 1 deletion(-)
create mode 100644 extensions/Connection_Interface_Client_Type.xml
(limited to 'extensions')
diff --git a/extensions/Connection_Interface_Client_Type.xml b/extensions/Connection_Interface_Client_Type.xml
new file mode 100644
index 000000000..6be261c54
--- /dev/null
+++ b/extensions/Connection_Interface_Client_Type.xml
@@ -0,0 +1,199 @@
+
+
+ Copyright (C) 2010 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+ (as draft)
+
+
+
+ An interface on connections to support protocols which allows users to
+ subscribe to the client types of their contacts.
+
+ One can connect to instant messaging networks on a huge variety of
+ devices, from PCs, to phones to consoles. It can be useful for users
+ to know what kind of device a contact is using so that he or she
+ can decide not to send that big file or start a video chat. This
+ interface exposes exactly this information for clients to display.
+
+ The client types are represented in strings, using the values
+
+ documented by the XMPP registrar with some additional types
+ added for other protocols. A contact can set one or more client types
+ so this interface returns a list of strings to denote client types
+ for a contact. The well-known client types to be used are:
+
+
+ - bot
+ - console (minimal non-GUI client used on dumb terminals or
+ text-only screens, not a games console)
+ - handheld
+ - pc
+ - phone
+ - web
+ - sms (the client is not actually an instant messaging client
+ but all messages sent to this contact will be delivered as SMSs)
+
+
+ If the empty list is given as the client types, this means that
+ details about the contact's client type is unknown. If there are
+ multiple resources of a contact online at one point in time, the
+ client types of the most available resource will be returned. In
+ other words, the client types are the types of the client whose
+ SimplePresence we see. For example, if a contact has two
+ resources:
+
+
+ - one his phone, with presence "available", and
+ - one his pc, with presence "busy",
+
+
+ then the methods in this interface will return the "phone" client type
+ as that is the more available resource. If some time later his phone's
+ presence moves to "away", then the
+ ClientTypesUpdated signal will notify
+ that his client type has changed from "phone" to "pc", because "busy"
+ is a more available presence than "away".
+
+
+
+
+
+ A mapping from contact handle to client types.
+
+
+
+ A contact.
+
+
+
+
+ The contact's client types as documented earlier in this interface.
+
+
+
+
+
+
+ Return the client types of the given contacts, if they are
+ already known. If any of the given contacts' client types are not known,
+ request their current client types, but return immediately without waiting
+ for a reply; if a reply with a non-empty client type is later received
+ for those contacts, the ClientTypesUpdated
+ signal will be emitted for them.
+
+
+ This method is appropriate for "lazy" client type finding, for instance
+ displaying the client types (if available) of everyone in your contact
+ list.
+
+
+
+
+
+ The contacts whose client types should be returned or signalled.
+
+
+
+
+
+ The contacts' client types, if already known. Contacts whose client
+ typess are not already known are omitted from the mapping; contacts known
+ to have no client type information appear in the mapping with an empty
+ list.
+
+
+
+
+
+
+
+
+
+
+
+ Return the current client types of the given contact. If necessary, make
+ a request to the server for up-to-date information, and wait for a
+ reply.
+
+
+ This method is appropriate for use in a "Contact Information..."
+ dialog; it can be used to show progress information (while waiting
+ for the method to return), and can distinguish between various error
+ conditions.
+
+
+
+
+
+ The contact whose client types should be returned.
+
+
+
+
+
+ The contact's client types. It MAY be empty, indicating that no client
+ type information was found.
+
+
+
+
+
+
+
+
+
+ The requested contact does not allow the local user to see their
+ client type information.
+
+
+
+
+
+
+
+ Emitted when a contact's client types change or become known.
+
+
+
+
+ The contact.
+
+
+
+
+ The contact's client types, or an empty list to indicate that nothing
+ is known about the contact's client types.
+
+
+
+
+
+
+ The same mapping that would be returned by
+ GetClientTypes for this contact.
+ Omitted from the result if the contact's client type is not
+ known.
+
+
+
+
+
+
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index ba369af96..a54fa9bd1 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -26,7 +26,8 @@ EXTRA_DIST = \
OLPC_Channel_Type_BuddyView.xml \
OLPC_Channel_Type_ActivityView.xml \
Channel_Interface_Sasl_Authentication.xml \
- Channel_Type_Server_Authentication.xml
+ Channel_Type_Server_Authentication.xml \
+ Connection_Interface_Client_Type.xml
noinst_LTLIBRARIES = libgabble-extensions.la
diff --git a/extensions/all.xml b/extensions/all.xml
index 22827090f..9dd9c6cea 100644
--- a/extensions/all.xml
+++ b/extensions/all.xml
@@ -48,6 +48,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
--
cgit v1.2.3
From 0c3956a6c9401d306383da605899a7b2c2a1175e Mon Sep 17 00:00:00 2001
From: Jonny Lamb
Date: Thu, 22 Jul 2010 17:43:25 +0100
Subject: extensions: update current spec for client type
Signed-off-by: Jonny Lamb
---
extensions/Connection_Interface_Client_Type.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'extensions')
diff --git a/extensions/Connection_Interface_Client_Type.xml b/extensions/Connection_Interface_Client_Type.xml
index 6be261c54..f59c84e42 100644
--- a/extensions/Connection_Interface_Client_Type.xml
+++ b/extensions/Connection_Interface_Client_Type.xml
@@ -115,7 +115,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
tp:type="Contact_Client_Types">
The contacts' client types, if already known. Contacts whose client
- typess are not already known are omitted from the mapping; contacts known
+ types are not already known are omitted from the mapping; contacts known
to have no client type information appear in the mapping with an empty
list.
@@ -127,7 +127,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
+
Return the current client types of the given contact. If necessary, make
a request to the server for up-to-date information, and wait for a
--
cgit v1.2.3
From b11fdbd1b54dca4558c844f83f4713d0068f5470 Mon Sep 17 00:00:00 2001
From: Jonny Lamb
Date: Tue, 27 Jul 2010 15:31:21 +0100
Subject: client types: now it's called ClientTypes; update everything
Signed-off-by: Jonny Lamb
---
extensions/Connection_Interface_Client_Type.xml | 199 ----------------
extensions/Connection_Interface_Client_Types.xml | 203 ++++++++++++++++
extensions/all.xml | 2 +-
src/Makefile.am | 4 +-
src/conn-client-type.c | 280 -----------------------
src/conn-client-type.h | 34 ---
src/conn-client-types.c | 280 +++++++++++++++++++++++
src/conn-client-types.h | 34 +++
src/connection.c | 10 +-
src/debug.c | 2 +-
src/debug.h | 2 +-
11 files changed, 527 insertions(+), 523 deletions(-)
delete mode 100644 extensions/Connection_Interface_Client_Type.xml
create mode 100644 extensions/Connection_Interface_Client_Types.xml
delete mode 100644 src/conn-client-type.c
delete mode 100644 src/conn-client-type.h
create mode 100644 src/conn-client-types.c
create mode 100644 src/conn-client-types.h
(limited to 'extensions')
diff --git a/extensions/Connection_Interface_Client_Type.xml b/extensions/Connection_Interface_Client_Type.xml
deleted file mode 100644
index f59c84e42..000000000
--- a/extensions/Connection_Interface_Client_Type.xml
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
- Copyright (C) 2010 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-
- (as draft)
-
-
-
- An interface on connections to support protocols which allows users to
- subscribe to the client types of their contacts.
-
- One can connect to instant messaging networks on a huge variety of
- devices, from PCs, to phones to consoles. It can be useful for users
- to know what kind of device a contact is using so that he or she
- can decide not to send that big file or start a video chat. This
- interface exposes exactly this information for clients to display.
-
- The client types are represented in strings, using the values
-
- documented by the XMPP registrar with some additional types
- added for other protocols. A contact can set one or more client types
- so this interface returns a list of strings to denote client types
- for a contact. The well-known client types to be used are:
-
-
- - bot
- - console (minimal non-GUI client used on dumb terminals or
- text-only screens, not a games console)
- - handheld
- - pc
- - phone
- - web
- - sms (the client is not actually an instant messaging client
- but all messages sent to this contact will be delivered as SMSs)
-
-
- If the empty list is given as the client types, this means that
- details about the contact's client type is unknown. If there are
- multiple resources of a contact online at one point in time, the
- client types of the most available resource will be returned. In
- other words, the client types are the types of the client whose
- SimplePresence we see. For example, if a contact has two
- resources:
-
-
- - one his phone, with presence "available", and
- - one his pc, with presence "busy",
-
-
- then the methods in this interface will return the "phone" client type
- as that is the more available resource. If some time later his phone's
- presence moves to "away", then the
- ClientTypesUpdated signal will notify
- that his client type has changed from "phone" to "pc", because "busy"
- is a more available presence than "away".
-
-
-
-
-
- A mapping from contact handle to client types.
-
-
-
- A contact.
-
-
-
-
- The contact's client types as documented earlier in this interface.
-
-
-
-
-
-
- Return the client types of the given contacts, if they are
- already known. If any of the given contacts' client types are not known,
- request their current client types, but return immediately without waiting
- for a reply; if a reply with a non-empty client type is later received
- for those contacts, the ClientTypesUpdated
- signal will be emitted for them.
-
-
- This method is appropriate for "lazy" client type finding, for instance
- displaying the client types (if available) of everyone in your contact
- list.
-
-
-
-
-
- The contacts whose client types should be returned or signalled.
-
-
-
-
-
- The contacts' client types, if already known. Contacts whose client
- types are not already known are omitted from the mapping; contacts known
- to have no client type information appear in the mapping with an empty
- list.
-
-
-
-
-
-
-
-
-
-
-
- Return the current client types of the given contact. If necessary, make
- a request to the server for up-to-date information, and wait for a
- reply.
-
-
- This method is appropriate for use in a "Contact Information..."
- dialog; it can be used to show progress information (while waiting
- for the method to return), and can distinguish between various error
- conditions.
-
-
-
-
-
- The contact whose client types should be returned.
-
-
-
-
-
- The contact's client types. It MAY be empty, indicating that no client
- type information was found.
-
-
-
-
-
-
-
-
-
- The requested contact does not allow the local user to see their
- client type information.
-
-
-
-
-
-
-
- Emitted when a contact's client types change or become known.
-
-
-
-
- The contact.
-
-
-
-
- The contact's client types, or an empty list to indicate that nothing
- is known about the contact's client types.
-
-
-
-
-
-
- The same mapping that would be returned by
- GetClientTypes for this contact.
- Omitted from the result if the contact's client type is not
- known.
-
-
-
-
-
-
diff --git a/extensions/Connection_Interface_Client_Types.xml b/extensions/Connection_Interface_Client_Types.xml
new file mode 100644
index 000000000..0822122aa
--- /dev/null
+++ b/extensions/Connection_Interface_Client_Types.xml
@@ -0,0 +1,203 @@
+
+
+ Copyright (C) 2010 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+ (as draft)
+
+
+
+ An interface on connections to support protocols which allows users to
+ subscribe to the client types of their contacts.
+
+ One can connect to instant messaging networks on a huge variety of
+ devices, from PCs, to phones to consoles. It can be useful for users
+ to know what kind of device a contact is using so that he or she
+ can decide not to send that big file or start a video chat. This
+ interface exposes exactly this information for clients to display.
+
+ The client types are represented in strings, using the values
+
+ documented by the XMPP registrar with some additional types
+ added for other protocols. A contact can set one or more client types
+ so this interface returns a list of strings to denote client types
+ for a contact. The well-known client types to be used are:
+
+
+ - bot
+ - console (minimal non-GUI client used on dumb terminals or
+ text-only screens, not a games console)
+ - handheld
+ - pc
+ - phone
+ - web
+ - sms (the client is not actually an instant messaging client
+ but all messages sent to this contact will be delivered as SMSs)
+ - game (a gaming device)
+
+
+ If the empty list is given as the client types, this means that
+ details about the contact's client types are unknown. If there are
+ multiple resources of a contact online at one point in time, the
+ client types of the most available resource will be returned. In
+ other words, the client types are the types of the client whose
+ SimplePresence we see. For example, if a contact has two
+ resources:
+
+
+ - one his phone, with presence "available", and
+ - one his pc, with presence "busy",
+
+
+ then the methods in this interface will return an array (with
+ one element: "phone") as the client types as that is the more
+ available resource. If some time later his phone's presence
+ moves to "away", then the
+ ClientTypesUpdated signal will
+ notify that his client type have changed from "phone" to "pc",
+ because "busy" is a more available presence than "away".
+
+
+
+
+
+ A mapping from contact handle to client types.
+
+
+
+ A contact.
+
+
+
+
+ The contact's client types as documented earlier in this interface.
+
+
+
+
+
+
+ Return the client types of the given contacts, if they are
+ already known. If any of the given contacts' client types are
+ not known, request their current client types, but return
+ immediately without waiting for a reply; if a reply with a
+ non-empty client type array is later received for those
+ contacts, the
+ ClientTypesUpdated signal will
+ be emitted for them.
+
+
+ This method is appropriate for "lazy" client type finding, for instance
+ displaying the client types (if available) of everyone in your contact
+ list.
+
+
+
+
+
+ The contacts whose client types should be returned or signalled.
+
+
+
+
+
+ The contacts' client types, if already known. Contacts whose client
+ types are not already known are omitted from the mapping; contacts known
+ to have no client type information appear in the mapping with an empty
+ list.
+
+
+
+
+
+
+
+
+
+
+
+ Return the current client types of the given contact. If necessary, make
+ a request to the server for up-to-date information, and wait for a
+ reply.
+
+
+ This method is appropriate for use in a "Contact Information..."
+ dialog; it can be used to show progress information (while waiting
+ for the method to return), and can distinguish between various error
+ conditions.
+
+
+
+
+
+ The contact whose client types should be returned.
+
+
+
+
+
+ The contact's client types. It MAY be empty, indicating that no client
+ type information was found.
+
+
+
+
+
+
+
+
+
+ The requested contact does not allow the local user to see their
+ client type information.
+
+
+
+
+
+
+
+ Emitted when a contact's client types change or become known.
+
+
+
+
+ The contact.
+
+
+
+
+ The contact's client types, or an empty list to indicate that nothing
+ is known about the contact's client types.
+
+
+
+
+
+
+ The same mapping that would be returned by
+ GetClientTypes for this contact.
+ Omitted from the result if the contact's client types are not
+ known.
+
+
+
+
+
+
diff --git a/extensions/all.xml b/extensions/all.xml
index 9dd9c6cea..36f8ac47f 100644
--- a/extensions/all.xml
+++ b/extensions/all.xml
@@ -48,7 +48,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
+
diff --git a/src/Makefile.am b/src/Makefile.am
index c1ebe16fa..3404f43b9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,8 +61,8 @@ libgabble_convenience_la_SOURCES = \
conn-aliasing.c \
conn-avatars.h \
conn-avatars.c \
- conn-client-type.h \
- conn-client-type.c \
+ conn-client-types.h \
+ conn-client-types.c \
conn-contact-info.h \
conn-contact-info.c \
conn-location.h \
diff --git a/src/conn-client-type.c b/src/conn-client-type.c
deleted file mode 100644
index 95aa6388f..000000000
--- a/src/conn-client-type.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * conn-client-type - Gabble client type interface
- * Copyright (C) 2010 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
- */
-
-#include "config.h"
-
-#include
-#include
-
-#include
-
-#include
-
-#include "conn-client-type.h"
-#include "disco.h"
-#include "namespaces.h"
-#include "presence.h"
-#include "presence-cache.h"
-
-#define DEBUG_FLAG GABBLE_DEBUG_CLIENT_TYPE
-#include "debug.h"
-
-static gboolean
-dummy_caps_set_predicate (const GabbleCapabilitySet *set,
- gconstpointer user_data)
-{
- return TRUE;
-}
-
-static void
-client_type_get_client_types (GabbleSvcConnectionInterfaceClientType *iface,
- const GArray *contacts,
- DBusGMethodInvocation *context)
-{
- GabbleConnection *conn = GABBLE_CONNECTION (iface);
- TpBaseConnection *base = (TpBaseConnection *) conn;
- TpHandleRepoIface *contact_handles;
- guint i;
- GHashTable *client_types;
- GabblePresence *presence;
- GError *error = NULL;
- GPtrArray *types_list, *empty_array;;
-
- /* Validate contacts */
- contact_handles = tp_base_connection_get_handles (base,
- TP_HANDLE_TYPE_CONTACT);
-
- if (!tp_handles_are_valid (contact_handles, contacts, TRUE, &error))
- {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- if (DEBUGGING)
- {
- DEBUG ("GetClientTypes called on the following handles:");
-
- for (i = 0; i < contacts->len; i++)
- {
- DEBUG (" * %u", g_array_index (contacts, TpHandle, i));
- }
- }
-
- client_types = g_hash_table_new (g_direct_hash, g_direct_equal);
- types_list = g_ptr_array_new_with_free_func (
- (GDestroyNotify) g_ptr_array_unref);
-
- empty_array = g_ptr_array_new ();
- g_ptr_array_add (empty_array, NULL);
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- GPtrArray *types;
- const gchar *res;
-
- presence = gabble_presence_cache_get (conn->presence_cache, handle);
-
- /* We know that we know nothing about this chap, so empty array it is. */
- if (presence == NULL)
- {
- types = empty_array;
- goto add_array;
- }
-
- /* Find the best resource. */
- res = gabble_presence_pick_resource_by_caps (presence,
- DEVICE_AGNOSTIC, dummy_caps_set_predicate, NULL);
-
- if (res == NULL)
- {
- types = empty_array;
- goto add_array;
- }
-
- /* Get the cached client types. */
- types = gabble_presence_get_client_types_array (presence, res, TRUE);
-
- if (types == NULL)
- {
- /* There's a pending disco request happening, so don't give an
- * empty array for this fellow. */
- if (gabble_presence_cache_disco_in_progress (conn->presence_cache,
- handle, res))
- continue;
-
- /* This guy, on the other hand, can get the most empty of arrays. */
- types = empty_array;
- }
-
-add_array:
- g_hash_table_insert (client_types, GUINT_TO_POINTER (handle),
- types->pdata);
-
- if (types != empty_array)
- g_ptr_array_add (types_list, types);
- }
-
- gabble_svc_connection_interface_client_type_return_from_get_client_types (
- context, client_types);
-
- g_hash_table_unref (client_types);
- g_ptr_array_unref (types_list);
- g_ptr_array_unref (empty_array);
-}
-
-void
-conn_client_type_iface_init (gpointer g_iface,
- gpointer iface_data)
-{
- GabbleSvcConnectionInterfaceClientTypeClass *klass = g_iface;
-
-#define IMPLEMENT(x) gabble_svc_connection_interface_client_type_implement_##x \
- (klass, client_type_##x)
- IMPLEMENT (get_client_types);
-#undef IMPLEMENT
-}
-
-static void
-conn_client_type_fill_contact_attributes (GObject *obj,
- const GArray *contacts,
- GHashTable *attributes_hash)
-{
- GabbleConnection *conn = GABBLE_CONNECTION (obj);
- guint i;
- GPtrArray *empty_array;
-
- empty_array = g_ptr_array_new ();
- g_ptr_array_add (empty_array, NULL);
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- GabblePresence *presence;
- GValue *val;
- GPtrArray *types;
- const gchar *res;
-
- presence = gabble_presence_cache_get (conn->presence_cache, handle);
-
- if (presence == NULL)
- {
- types = empty_array;
- goto add_array;
- }
-
- /* Find the best resource. */
- res = gabble_presence_pick_resource_by_caps (presence,
- DEVICE_AGNOSTIC, dummy_caps_set_predicate, NULL);
-
- if (res == NULL)
- {
- types = empty_array;
- goto add_array;
- }
-
- /* Get the cached client types. */
- types = gabble_presence_get_client_types_array (presence, res, FALSE);
-
- if (types == NULL)
- {
- /* There's a pending disco request happening, so don't give an
- * empty array for his troubles. */
- if (gabble_presence_cache_disco_in_progress (conn->presence_cache,
- handle, res))
- continue;
-
- /* This guy, on the other hand, can get the most empty of arrays. */
- types = empty_array;
- }
-
-add_array:
- val = tp_g_value_slice_new_boxed (
- dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
- types);
-
- tp_contacts_mixin_set_contact_attribute (attributes_hash, handle,
- GABBLE_IFACE_CONNECTION_INTERFACE_CLIENT_TYPE "/client-type", val);
-
- if (types != empty_array)
- g_ptr_array_unref (types);
- }
-
- g_ptr_array_unref (empty_array);
-
-}
-
-static void
-presences_updated_cb (GabblePresenceCache *presence_cache,
- const GArray *contacts,
- GabbleConnection *conn)
-{
- guint i;
-
- for (i = 0; i < contacts->len; i++)
- {
- TpHandle handle = g_array_index (contacts, TpHandle, i);
- GabblePresence *presence;
- GPtrArray *array, *empty_array;
- const gchar *res;
-
- empty_array = g_ptr_array_new ();
- g_ptr_array_add (empty_array, NULL);
-
- presence = gabble_presence_cache_get (presence_cache, handle);
-
- if (presence == NULL)
- {
- array = empty_array;
- goto emit;
- }
-
- res = gabble_presence_pick_resource_by_caps (presence,
- DEVICE_AGNOSTIC, dummy_caps_set_predicate, NULL);
-
- if (res == NULL)
- {
- array = empty_array;
- goto emit;
- }
-
- array = gabble_presence_get_client_types_array (presence, res, TRUE);
-
-emit:
- gabble_svc_connection_interface_client_type_emit_client_types_updated (
- conn, handle, (const gchar **) array->pdata);
-
- if (array != empty_array)
- g_ptr_array_unref (array);
-
- g_ptr_array_unref (empty_array);
- }
-}
-
-void
-conn_client_type_init (GabbleConnection *conn)
-{
- tp_contacts_mixin_add_contact_attributes_iface (G_OBJECT (conn),
- GABBLE_IFACE_CONNECTION_INTERFACE_CLIENT_TYPE,
- conn_client_type_fill_contact_attributes);
-
- g_signal_connect (conn->presence_cache, "presences-updated",
- G_CALLBACK (presences_updated_cb), conn);
-}
diff --git a/src/conn-client-type.h b/src/conn-client-type.h
deleted file mode 100644
index 47e1eb62c..000000000
--- a/src/conn-client-type.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * conn-client-type - Gabble client type interface
- * Copyright (C) 2010 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 __CONN_CLIENT_TYPE_H__
-#define __CONN_CLIENT_TYPE_H__
-
-#include "connection.h"
-#include
-
-G_BEGIN_DECLS
-
-void conn_client_type_iface_init (gpointer g_iface, gpointer iface_data);
-
-void conn_client_type_init (GabbleConnection *conn);
-
-G_END_DECLS
-
-#endif /* __CONN_CLIENT_TYPE_H__ */
diff --git a/src/conn-client-types.c b/src/conn-client-types.c
new file mode 100644
index 000000000..28134751a
--- /dev/null
+++ b/src/conn-client-types.c
@@ -0,0 +1,280 @@
+/*
+ * conn-client-types - Gabble client types interface
+ * Copyright (C) 2010 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
+ */
+
+#include "config.h"
+
+#include
+#include
+
+#include
+
+#include
+
+#include "conn-client-types.h"
+#include "disco.h"
+#include "namespaces.h"
+#include "presence.h"
+#include "presence-cache.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_CLIENT_TYPES
+#include "debug.h"
+
+static gboolean
+dummy_caps_set_predicate (const GabbleCapabilitySet *set,
+ gconstpointer user_data)
+{
+ return TRUE;
+}
+
+static void
+client_types_get_client_types (GabbleSvcConnectionInterfaceClientTypes *iface,
+ const GArray *contacts,
+ DBusGMethodInvocation *context)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (iface);
+ TpBaseConnection *base = (TpBaseConnection *) conn;
+ TpHandleRepoIface *contact_handles;
+ guint i;
+ GHashTable *client_types;
+ GabblePresence *presence;
+ GError *error = NULL;
+ GPtrArray *types_list, *empty_array;;
+
+ /* Validate contacts */
+ contact_handles = tp_base_connection_get_handles (base,
+ TP_HANDLE_TYPE_CONTACT);
+
+ if (!tp_handles_are_valid (contact_handles, contacts, TRUE, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
+ if (DEBUGGING)
+ {
+ DEBUG ("GetClientTypes called on the following handles:");
+
+ for (i = 0; i < contacts->len; i++)
+ {
+ DEBUG (" * %u", g_array_index (contacts, TpHandle, i));
+ }
+ }
+
+ client_types = g_hash_table_new (g_direct_hash, g_direct_equal);
+ types_list = g_ptr_array_new_with_free_func (
+ (GDestroyNotify) g_ptr_array_unref);
+
+ empty_array = g_ptr_array_new ();
+ g_ptr_array_add (empty_array, NULL);
+
+ for (i = 0; i < contacts->len; i++)
+ {
+ TpHandle handle = g_array_index (contacts, TpHandle, i);
+ GPtrArray *types;
+ const gchar *res;
+
+ presence = gabble_presence_cache_get (conn->presence_cache, handle);
+
+ /* We know that we know nothing about this chap, so empty array it is. */
+ if (presence == NULL)
+ {
+ types = empty_array;
+ goto add_array;
+ }
+
+ /* Find the best resource. */
+ res = gabble_presence_pick_resource_by_caps (presence,
+ DEVICE_AGNOSTIC, dummy_caps_set_predicate, NULL);
+
+ if (res == NULL)
+ {
+ types = empty_array;
+ goto add_array;
+ }
+
+ /* Get the cached client types. */
+ types = gabble_presence_get_client_types_array (presence, res, TRUE);
+
+ if (types == NULL)
+ {
+ /* There's a pending disco request happening, so don't give an
+ * empty array for this fellow. */
+ if (gabble_presence_cache_disco_in_progress (conn->presence_cache,
+ handle, res))
+ continue;
+
+ /* This guy, on the other hand, can get the most empty of arrays. */
+ types = empty_array;
+ }
+
+add_array:
+ g_hash_table_insert (client_types, GUINT_TO_POINTER (handle),
+ types->pdata);
+
+ if (types != empty_array)
+ g_ptr_array_add (types_list, types);
+ }
+
+ gabble_svc_connection_interface_client_types_return_from_get_client_types (
+ context, client_types);
+
+ g_hash_table_unref (client_types);
+ g_ptr_array_unref (types_list);
+ g_ptr_array_unref (empty_array);
+}
+
+void
+conn_client_types_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ GabbleSvcConnectionInterfaceClientTypesClass *klass = g_iface;
+
+#define IMPLEMENT(x) gabble_svc_connection_interface_client_types_implement_##x \
+ (klass, client_types_##x)
+ IMPLEMENT (get_client_types);
+#undef IMPLEMENT
+}
+
+static void
+conn_client_types_fill_contact_attributes (GObject *obj,
+ const GArray *contacts,
+ GHashTable *attributes_hash)
+{
+ GabbleConnection *conn = GABBLE_CONNECTION (obj);
+ guint i;
+ GPtrArray *empty_array;
+
+ empty_array = g_ptr_array_new ();
+ g_ptr_array_add (empty_array, NULL);
+
+ for (i = 0; i < contacts->len; i++)
+ {
+ TpHandle handle = g_array_index (contacts, TpHandle, i);
+ GabblePresence *presence;
+ GValue *val;
+ GPtrArray *types;
+ const gchar *res;
+
+ presence = gabble_presence_cache_get (conn->presence_cache, handle);
+
+ if (presence == NULL)
+ {
+ types = empty_array;
+ goto add_array;
+ }
+
+ /* Find the best resource. */
+ res = gabble_presence_pick_resource_by_caps (presence,
+ DEVICE_AGNOSTIC, dummy_caps_set_predicate, NULL);
+
+ if (res == NULL)
+ {
+ types = empty_array;
+ goto add_array;
+ }
+
+ /* Get the cached client types. */
+ types = gabble_presence_get_client_types_array (presence, res, FALSE);
+
+ if (types == NULL)
+ {
+ /* There's a pending disco request happening, so don't give an
+ * empty array for his troubles. */
+ if (gabble_presence_cache_disco_in_progress (conn->presence_cache,
+ handle, res))
+ continue;
+
+ /* This guy, on the other hand, can get the most empty of arrays. */
+ types = empty_array;
+ }
+
+add_array:
+ val = tp_g_value_slice_new_boxed (
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ types);
+
+ tp_contacts_mixin_set_contact_attribute (attributes_hash, handle,
+ GABBLE_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES "/client-types", val);
+
+ if (types != empty_array)
+ g_ptr_array_unref (types);
+ }
+
+ g_ptr_array_unref (empty_array);
+
+}
+
+static void
+presences_updated_cb (GabblePresenceCache *presence_cache,
+ const GArray *contacts,
+ GabbleConnection *conn)
+{
+ guint i;
+
+ for (i = 0; i < contacts->len; i++)
+ {
+ TpHandle handle = g_array_index (contacts, TpHandle, i);
+ GabblePresence *presence;
+ GPtrArray *array, *empty_array;
+ const gchar *res;
+
+ empty_array = g_ptr_array_new ();
+ g_ptr_array_add (empty_array, NULL);
+
+ presence = gabble_presence_cache_get (presence_cache, handle);
+
+ if (presence == NULL)
+ {
+ array = empty_array;
+ goto emit;
+ }
+
+ res = gabble_presence_pick_resource_by_caps (presence,
+ DEVICE_AGNOSTIC, dummy_caps_set_predicate, NULL);
+
+ if (res == NULL)
+ {
+ array = empty_array;
+ goto emit;
+ }
+
+ array = gabble_presence_get_client_types_array (presence, res, TRUE);
+
+emit:
+ gabble_svc_connection_interface_client_types_emit_client_types_updated (
+ conn, handle, (const gchar **) array->pdata);
+
+ if (array != empty_array)
+ g_ptr_array_unref (array);
+
+ g_ptr_array_unref (empty_array);
+ }
+}
+
+void
+conn_client_types_init (GabbleConnection *conn)
+{
+ tp_contacts_mixin_add_contact_attributes_iface (G_OBJECT (conn),
+ GABBLE_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES,
+ conn_client_types_fill_contact_attributes);
+
+ g_signal_connect (conn->presence_cache, "presences-updated",
+ G_CALLBACK (presences_updated_cb), conn);
+}
diff --git a/src/conn-client-types.h b/src/conn-client-types.h
new file mode 100644
index 000000000..2e88dd7ee
--- /dev/null
+++ b/src/conn-client-types.h
@@ -0,0 +1,34 @@
+/*
+ * conn-client-types - Gabble client types interface
+ * Copyright (C) 2010 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 __CONN_CLIENT_TYPES_H__
+#define __CONN_CLIENT_TYPES_H__
+
+#include "connection.h"
+#include
+
+G_BEGIN_DECLS
+
+void conn_client_types_iface_init (gpointer g_iface, gpointer iface_data);
+
+void conn_client_types_init (GabbleConnection *conn);
+
+G_END_DECLS
+
+#endif /* __CONN_CLIENT_TYPES_H__ */
diff --git a/src/connection.c b/src/connection.c
index f0f7aa808..059eecf07 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -54,7 +54,7 @@
#include "auth-manager.h"
#include "conn-aliasing.h"
#include "conn-avatars.h"
-#include "conn-client-type.h"
+#include "conn-client-types.h"
#include "conn-contact-info.h"
#include "conn-location.h"
#include "conn-presence.h"
@@ -128,8 +128,8 @@ G_DEFINE_TYPE_WITH_CODE(GabbleConnection,
conn_future_iface_init);
G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_CONNECTION_INTERFACE_MAIL_NOTIFICATION,
conn_mail_notif_iface_init);
- G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPE,
- conn_client_type_iface_init);
+ G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPES,
+ conn_client_types_iface_init);
)
/* properties */
@@ -361,7 +361,7 @@ gabble_connection_constructor (GType type,
conn_location_init (self);
conn_sidecars_init (self);
conn_mail_notif_init (self);
- conn_client_type_init (self);
+ conn_client_types_init (self);
tp_contacts_mixin_add_contact_attributes_iface (G_OBJECT (self),
TP_IFACE_CONNECTION_INTERFACE_CAPABILITIES,
@@ -762,7 +762,7 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class)
TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES,
TP_IFACE_CONNECTION_INTERFACE_LOCATION,
GABBLE_IFACE_CONNECTION_INTERFACE_GABBLE_DECLOAK,
- GABBLE_IFACE_CONNECTION_INTERFACE_CLIENT_TYPE,
+ GABBLE_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES,
NULL };
static TpDBusPropertiesMixinPropImpl olpc_gadget_props[] = {
{ "GadgetAvailable", NULL, NULL },
diff --git a/src/debug.c b/src/debug.c
index 6e92b697e..4d2f5d41f 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -47,7 +47,7 @@ static GDebugKey keys[] = {
{ "mail", GABBLE_DEBUG_MAIL_NOTIF },
{ "authentication", GABBLE_DEBUG_AUTH },
{ "share", GABBLE_DEBUG_SHARE },
- { "client-type", GABBLE_DEBUG_CLIENT_TYPE },
+ { "client-types", GABBLE_DEBUG_CLIENT_TYPES },
{ 0, },
};
diff --git a/src/debug.h b/src/debug.h
index 182669340..e76796044 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -35,7 +35,7 @@ typedef enum
GABBLE_DEBUG_AUTH = 1 << 23,
GABBLE_DEBUG_SLACKER = 1 << 24,
GABBLE_DEBUG_SHARE = 1 << 25,
- GABBLE_DEBUG_CLIENT_TYPE = 1 << 26,
+ GABBLE_DEBUG_CLIENT_TYPES = 1 << 26,
} GabbleDebugFlags;
void gabble_debug_set_flags_from_env (void);
--
cgit v1.2.3
From e338845ca649e3ac125c28197eb436bb282ab6eb Mon Sep 17 00:00:00 2001
From: Jonny Lamb
Date: Wed, 28 Jul 2010 10:38:58 +0100
Subject: extensions: fix yet another old reference
Signed-off-by: Jonny Lamb
---
extensions/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'extensions')
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index a54fa9bd1..8a7b9faca 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -27,7 +27,7 @@ EXTRA_DIST = \
OLPC_Channel_Type_ActivityView.xml \
Channel_Interface_Sasl_Authentication.xml \
Channel_Type_Server_Authentication.xml \
- Connection_Interface_Client_Type.xml
+ Connection_Interface_Client_Types.xml
noinst_LTLIBRARIES = libgabble-extensions.la
--
cgit v1.2.3