aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/Makefile.am2
-rw-r--r--libempathy/empathy-contact.c146
-rw-r--r--libempathy/empathy-tp-chat.c78
-rw-r--r--libempathy/empathy-tp-chat.h2
4 files changed, 31 insertions, 197 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 186f08aa9..48846311f 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -12,6 +12,7 @@ AM_CPPFLAGS = \
$(EMPATHY_CFLAGS) \
$(YELL_CFLAGS) \
$(GEOCLUE_CFLAGS) \
+ $(GEOCODE_CFLAGS) \
$(NETWORK_MANAGER_CFLAGS) \
$(CONNMAN_CFLAGS) \
$(WARN_CFLAGS) \
@@ -114,6 +115,7 @@ libempathy_la_LIBADD = \
$(GCR_LIBS) \
$(EMPATHY_LIBS) \
$(GEOCLUE_LIBS) \
+ $(GEOCODE_LIBS) \
$(NETWORK_MANAGER_LIBS) \
$(CONNMAN_LIBS)
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 6cdb3b6d9..55bc40bdd 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -35,8 +35,8 @@
#include <folks/folks.h>
#include <folks/folks-telepathy.h>
-#ifdef HAVE_GEOCLUE
-#include <geoclue/geoclue-geocode.h>
+#ifdef HAVE_GEOCODE
+#include <geocode-glib/geocode-glib.h>
#endif
#include "empathy-contact.h"
@@ -80,7 +80,7 @@ static void contact_get_property (GObject *object, guint param_id,
static void contact_set_property (GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec);
-#ifdef HAVE_GEOCLUE
+#ifdef HAVE_GEOCODE
static void update_geocode (EmpathyContact *contact);
#endif
@@ -1441,7 +1441,7 @@ empathy_contact_set_location (EmpathyContact *contact,
g_hash_table_unref (priv->location);
priv->location = g_hash_table_ref (location);
-#ifdef HAVE_GEOCLUE
+#ifdef HAVE_GEOCODE
update_geocode (contact);
#endif
g_object_notify (G_OBJECT (contact), "location");
@@ -1509,41 +1509,37 @@ empathy_contact_equal (gconstpointer contact1,
return FALSE;
}
-#ifdef HAVE_GEOCLUE
-#define GEOCODE_SERVICE "org.freedesktop.Geoclue.Providers.Yahoo"
-#define GEOCODE_PATH "/org/freedesktop/Geoclue/Providers/Yahoo"
-
-/* This callback is called by geoclue when it found a position
+#ifdef HAVE_GEOCODE
+/* This callback is called by geocode-glib when it found a position
* for the given address. A position is necessary for a contact
* to show up on the map
*/
static void
-geocode_cb (GeoclueGeocode *geocode,
- GeocluePositionFields fields,
- double latitude,
- double longitude,
- double altitude,
- GeoclueAccuracy *accuracy,
- GError *error,
- gpointer contact)
+geocode_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ EmpathyContact *contact = user_data;
EmpathyContactPriv *priv = GET_PRIV (contact);
+ GError *error = NULL;
GHashTable *new_location;
+ GHashTable *resolved;
+ gdouble latitude, longitude;
if (priv->location == NULL)
goto out;
- if (error != NULL)
+ resolved = geocode_object_resolve_finish (GEOCODE_OBJECT (source), result,
+ &error);
+
+ if (resolved == NULL)
{
- DEBUG ("Error geocoding location : %s", error->message);
+ DEBUG ("Failed to resolve geocode: %s", error->message);
+ g_error_free (error);
goto out;
}
- /* No need to change location if we didn't find the position */
- if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE))
- goto out;
-
- if (!(fields & GEOCLUE_POSITION_FIELDS_LONGITUDE))
+ if (!geocode_object_get_coords (resolved, &longitude, &latitude))
goto out;
new_location = tp_asv_new (
@@ -1559,43 +1555,20 @@ geocode_cb (GeoclueGeocode *geocode,
tp_g_hash_table_update (new_location, priv->location,
(GBoxedCopyFunc) g_strdup, (GBoxedCopyFunc) tp_g_value_slice_dup);
- /* Set the altitude only if it wasn't defined before */
- if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE &&
- g_hash_table_lookup (new_location, EMPATHY_LOCATION_ALT) == NULL)
- {
- tp_asv_set_double (new_location, g_strdup (EMPATHY_LOCATION_ALT),
- altitude);
- DEBUG ("\t - Altitude: %f", altitude);
- }
-
/* Don't change the accuracy as we used an address to get this position */
g_hash_table_unref (priv->location);
priv->location = new_location;
- g_object_notify (contact, "location");
+ g_object_notify ((GObject *) contact, "location");
+
out:
- g_object_unref (geocode);
+ tp_clear_pointer (&result, g_hash_table_unref);
g_object_unref (contact);
}
-static gchar *
-get_dup_string (GHashTable *location,
- gchar *key)
-{
- GValue *value;
-
- value = g_hash_table_lookup (location, key);
- if (value != NULL)
- return g_value_dup_string (value);
-
- return NULL;
-}
-
static void
update_geocode (EmpathyContact *contact)
{
- static GeoclueGeocode *geocode;
- gchar *str;
- GHashTable *address;
+ GeocodeObject *geocode;
GHashTable *location;
location = empathy_contact_get_location (contact);
@@ -1607,75 +1580,12 @@ update_geocode (EmpathyContact *contact)
g_hash_table_lookup (location, EMPATHY_LOCATION_LON) != NULL)
return;
- if (geocode == NULL)
- {
- geocode = geoclue_geocode_new (GEOCODE_SERVICE, GEOCODE_PATH);
- g_object_add_weak_pointer (G_OBJECT (geocode), (gpointer *) &geocode);
- }
- else
- {
- g_object_ref (geocode);
- }
+ geocode = geocode_object_new_for_params (location);
- address = geoclue_address_details_new ();
+ geocode_object_resolve_async (geocode, NULL, geocode_cb,
+ g_object_ref (contact));
- str = get_dup_string (location, EMPATHY_LOCATION_COUNTRY_CODE);
- if (str != NULL)
- {
- g_hash_table_insert (address,
- g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRYCODE), str);
- DEBUG ("\t - countrycode: %s", str);
- }
-
- str = get_dup_string (location, EMPATHY_LOCATION_COUNTRY);
- if (str != NULL)
- {
- g_hash_table_insert (address,
- g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRY), str);
- DEBUG ("\t - country: %s", str);
- }
-
- str = get_dup_string (location, EMPATHY_LOCATION_POSTAL_CODE);
- if (str != NULL)
- {
- g_hash_table_insert (address,
- g_strdup (GEOCLUE_ADDRESS_KEY_POSTALCODE), str);
- DEBUG ("\t - postalcode: %s", str);
- }
-
- str = get_dup_string (location, EMPATHY_LOCATION_REGION);
- if (str != NULL)
- {
- g_hash_table_insert (address,
- g_strdup (GEOCLUE_ADDRESS_KEY_REGION), str);
- DEBUG ("\t - region: %s", str);
- }
-
- str = get_dup_string (location, EMPATHY_LOCATION_LOCALITY);
- if (str != NULL)
- {
- g_hash_table_insert (address,
- g_strdup (GEOCLUE_ADDRESS_KEY_LOCALITY), str);
- DEBUG ("\t - locality: %s", str);
- }
-
- str = get_dup_string (location, EMPATHY_LOCATION_STREET);
- if (str != NULL)
- {
- g_hash_table_insert (address,
- g_strdup (GEOCLUE_ADDRESS_KEY_STREET), str);
- DEBUG ("\t - street: %s", str);
- }
-
- if (g_hash_table_size (address) > 0)
- {
- g_object_ref (contact);
-
- geoclue_geocode_address_to_position_async (geocode, address,
- geocode_cb, contact);
- }
-
- g_hash_table_unref (address);
+ g_object_unref (geocode);
}
#endif
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 02bdc80e3..63b1e87d6 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -54,8 +54,6 @@ struct _EmpathyTpChatPrivate {
* (channel doesn't implement the Password interface) */
gboolean got_password_flags;
gboolean can_upgrade_to_muc;
- gboolean got_sms_channel;
- gboolean sms_channel;
GHashTable *messages_being_sent;
@@ -70,7 +68,6 @@ enum {
PROP_ACCOUNT,
PROP_REMOTE_CONTACT,
PROP_PASSWORD_NEEDED,
- PROP_SMS_CHANNEL,
PROP_N_MESSAGES_SENDING,
};
@@ -379,7 +376,7 @@ handle_delivery_report (EmpathyTpChat *self,
* TpMessage. (fdo #35884) */
echo = tp_asv_get_boxed (header, "delivery-echo",
TP_ARRAY_TYPE_MESSAGE_PART_LIST);
- if (echo != NULL && echo->len >= 1) {
+ if (echo != NULL && echo->len >= 2) {
const GHashTable *echo_body;
echo_body = g_ptr_array_index (echo, 1);
@@ -872,9 +869,6 @@ check_almost_ready (EmpathyTpChat *self)
if (!self->priv->got_password_flags)
return;
- if (!self->priv->got_sms_channel)
- return;
-
/* We need either the members (room) or the remote contact (private chat).
* If the chat is protected by a password we can't get these information so
* consider the chat as ready so it can be presented to the user. */
@@ -1265,41 +1259,6 @@ got_password_flags_cb (TpChannel *proxy,
}
static void
-sms_channel_changed_cb (TpChannel *channel,
- gboolean sms_channel,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChat *self = (EmpathyTpChat *) chat;
-
- self->priv->sms_channel = sms_channel;
-
- g_object_notify (G_OBJECT (chat), "sms-channel");
-}
-
-static void
-get_sms_channel_cb (TpProxy *channel,
- const GValue *value,
- const GError *in_error,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChat *self = (EmpathyTpChat *) chat;
-
- if (in_error != NULL) {
- DEBUG ("Failed to get SMSChannel: %s", in_error->message);
- return;
- }
-
- g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
-
- self->priv->sms_channel = g_value_get_boolean (value);
- self->priv->got_sms_channel = TRUE;
-
- check_almost_ready (EMPATHY_TP_CHAT (chat));
-}
-
-static void
tp_chat_get_property (GObject *object,
guint param_id,
GValue *value,
@@ -1317,9 +1276,6 @@ tp_chat_get_property (GObject *object,
case PROP_PASSWORD_NEEDED:
g_value_set_boolean (value, empathy_tp_chat_password_needed (self));
break;
- case PROP_SMS_CHANNEL:
- g_value_set_boolean (value, self->priv->sms_channel);
- break;
case PROP_N_MESSAGES_SENDING:
g_value_set_uint (value,
g_hash_table_size (self->priv->messages_being_sent));
@@ -1414,14 +1370,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_SMS_CHANNEL,
- g_param_spec_boolean ("sms-channel",
- "SMS Channel",
- "TRUE if channel is for sending SMSes",
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
PROP_N_MESSAGES_SENDING,
g_param_spec_uint ("n-messages-sending",
"Num Messages Sending",
@@ -1805,15 +1753,6 @@ empathy_tp_chat_get_self_contact (EmpathyTpChat *self)
return self->priv->user;
}
-
-gboolean
-empathy_tp_chat_is_sms_channel (EmpathyTpChat *self)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_CHAT (self), FALSE);
-
- return self->priv->sms_channel;
-}
-
GQuark
empathy_tp_chat_get_feature_ready (void)
{
@@ -1926,21 +1865,6 @@ conn_prepared_cb (GObject *source,
/* No Password interface, so no need to fetch the password flags */
self->priv->got_password_flags = TRUE;
}
-
- /* Check if the chat is for SMS */
- if (tp_proxy_has_interface_by_id (channel,
- TP_IFACE_QUARK_CHANNEL_INTERFACE_SMS)) {
- tp_cli_channel_interface_sms_connect_to_sms_channel_changed (
- channel,
- sms_channel_changed_cb, self, NULL, G_OBJECT (self), NULL);
-
- tp_cli_dbus_properties_call_get (channel, -1,
- TP_IFACE_CHANNEL_INTERFACE_SMS, "SMSChannel",
- get_sms_channel_cb, self, NULL, G_OBJECT (self));
- } else {
- /* if there's no SMS support, then we're not waiting for it */
- self->priv->got_sms_channel = TRUE;
- }
}
static void
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index de55c1a8c..20ba02a68 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -121,8 +121,6 @@ TpChannelChatState
EmpathyContact * empathy_tp_chat_get_self_contact (EmpathyTpChat *self);
-gboolean empathy_tp_chat_is_sms_channel (EmpathyTpChat *chat);
-
G_END_DECLS
#endif /* __EMPATHY_TP_CHAT_H__ */