]> git.0d.be Git - empathy.git/commitdiff
Add Location to EmpathyContact
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 2 Dec 2008 16:14:20 +0000 (11:14 -0500)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Thu, 7 May 2009 17:37:01 +0000 (13:37 -0400)
libempathy/Makefile.am
libempathy/empathy-contact.c
libempathy/empathy-contact.h
libempathy/empathy-location.h [new file with mode: 0644]

index 67966695ea91c56da87587882d25d7f18646a16c..3122342cf8571a0d160128625fe61511b0729ea6 100644 (file)
@@ -83,6 +83,7 @@ libempathy_headers =                          \
        empathy-irc-network.h                   \
        empathy-irc-network-manager.h           \
        empathy-irc-server.h                    \
        empathy-irc-network.h                   \
        empathy-irc-network-manager.h           \
        empathy-irc-server.h                    \
+       empathy-location.h                      \
        empathy-log-manager.h                   \
        empathy-log-store.h                     \
        empathy-log-store-empathy.h             \
        empathy-log-manager.h                   \
        empathy-log-store.h                     \
        empathy-log-store-empathy.h             \
index fe8cf8234f5016d0c488f29cc63be694d2b3ab5f..3663a0a901a8e59ecff76885592766bd4833a191 100644 (file)
@@ -50,6 +50,7 @@ typedef struct {
   EmpathyCapabilities capabilities;
   gboolean is_user;
   guint hash;
   EmpathyCapabilities capabilities;
   gboolean is_user;
   guint hash;
+  GHashTable *location;
 } EmpathyContactPriv;
 
 static void contact_finalize (GObject *object);
 } EmpathyContactPriv;
 
 static void contact_finalize (GObject *object);
@@ -73,6 +74,7 @@ enum
   PROP_HANDLE,
   PROP_CAPABILITIES,
   PROP_IS_USER,
   PROP_HANDLE,
   PROP_CAPABILITIES,
   PROP_IS_USER,
+  PROP_LOCATION
 };
 
 enum {
 };
 
 enum {
@@ -225,6 +227,15 @@ empathy_contact_class_init (EmpathyContactClass *class)
         FALSE,
         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
         FALSE,
         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+
+  g_object_class_install_property (object_class,
+      PROP_LOCATION,
+      g_param_spec_boxed ("location",
+        "Contact location",
+        "Physical location of the contact",
+        G_TYPE_HASH_TABLE,
+        G_PARAM_READABLE));
+
   signals[PRESENCE_CHANGED] =
     g_signal_new ("presence-changed",
                   G_TYPE_FROM_CLASS (class),
   signals[PRESENCE_CHANGED] =
     g_signal_new ("presence-changed",
                   G_TYPE_FROM_CLASS (class),
@@ -246,6 +257,10 @@ empathy_contact_init (EmpathyContact *contact)
     EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
 
   contact->priv = priv;
     EMPATHY_TYPE_CONTACT, EmpathyContactPriv);
 
   contact->priv = priv;
+
+  priv->location = g_hash_table_new_full (g_str_hash, g_str_equal,
+                       (GDestroyNotify) g_free,
+                       (GDestroyNotify) tp_g_value_slice_free);
 }
 
 static void
 }
 
 static void
@@ -1001,3 +1016,48 @@ empathy_avatar_save_to_file (EmpathyAvatar *self,
   return g_file_set_contents (filename, self->data, self->len, error);
 }
 
   return g_file_set_contents (filename, self->data, self->len, error);
 }
 
+/**
+ * empathy_contact_get_location:
+ * @contact: the contact
+ *
+ * Returns the user's location if available.  The keys are defined in
+ * empathy-location.h. If the contact doesn't have location
+ * information, the GHashTable will be empthy.
+ *
+ * Returns: a #GHashTable of location values
+ */
+GHashTable *
+empathy_contact_get_location (EmpathyContact *contact)
+{
+  EmpathyContactPriv *priv;
+
+  g_return_val_if_fail (EMPATHY_CONTACT (contact), NULL);
+
+  priv = GET_PRIV (contact);
+
+  return priv->location;
+}
+
+/**
+ * empathy_contact_set_location:
+ * @contact: the contact
+ * @location: the location
+ *
+ * Sets the user's location based on the location #GHashTable passed.
+ */
+void 
+empathy_contact_set_location (EmpathyContact *contact,
+                              GHashTable *location)
+{
+  EmpathyContactPriv *priv;
+
+  g_return_if_fail (EMPATHY_CONTACT (contact));
+  g_return_if_fail (location != NULL);
+
+  priv = GET_PRIV (contact);
+
+  g_hash_table_unref (priv->location);
+
+  priv->location = g_hash_table_ref (location);
+  g_object_notify (G_OBJECT (contact), "location");
+}
index c10561d0f479e04ea5bf33c13c82e269c2d32f98..fecb966480757ebca2b0108f3fc5175b780b9ff2 100644 (file)
@@ -119,6 +119,10 @@ void empathy_avatar_unref (EmpathyAvatar *avatar);
 gboolean empathy_avatar_save_to_file (EmpathyAvatar *avatar,
     const gchar *filename, GError **error);
 
 gboolean empathy_avatar_save_to_file (EmpathyAvatar *avatar,
     const gchar *filename, GError **error);
 
+GHashTable * empathy_contact_get_location (EmpathyContact *contact);
+void empathy_contact_set_location (EmpathyContact *contact,
+  GHashTable *location);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_CONTACT_H__ */
 G_END_DECLS
 
 #endif /* __EMPATHY_CONTACT_H__ */
diff --git a/libempathy/empathy-location.h b/libempathy/empathy-location.h
new file mode 100644 (file)
index 0000000..a43e2d3
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 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: Pierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_LOCATION_H__
+#define __EMPATHY_LOCATION_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_LOCATION_COUNTRY_CODE "countrycode"
+#define EMPATHY_LOCATION_COUNTRY "country"
+#define EMPATHY_LOCATION_REGION "region"
+#define EMPATHY_LOCATION_LOCALITY "locality"
+#define EMPATHY_LOCATION_AREA "area"
+#define EMPATHY_LOCATION_POSTAL_CODE "postalcode"
+#define EMPATHY_LOCATION_STREET "street"
+#define EMPATHY_LOCATION_BUILDING "building"
+#define EMPATHY_LOCATION_FLOOR "floor"
+#define EMPATHY_LOCATION_ROOM "room"
+#define EMPATHY_LOCATION_TEXT "text"
+#define EMPATHY_LOCATION_DESCRIPTION "description"
+#define EMPATHY_LOCATION_URI "uri"
+#define EMPATHY_LOCATION_LAT "lat"
+#define EMPATHY_LOCATION_LON "lon"
+#define EMPATHY_LOCATION_ALT "alt"
+#define EMPATHY_LOCATION_ACCURACY_LEVEL "accuracy-level"
+#define EMPATHY_LOCATION_ERROR "error"
+#define EMPATHY_LOCATION_VERTICAL_ERROR_M "vertical-error-m"
+#define EMPATHY_LOCATION_HORIZONTAL_ERROR_M "horizontal-error-m"
+#define EMPATHY_LOCATION_SPEED "speed"
+#define EMPATHY_LOCATION_BEARING "bearing"
+#define EMPATHY_LOCATION_CLIMB "climb"
+#define EMPATHY_LOCATION_TIMESTAMP "timestamp"
+
+G_END_DECLS
+
+#endif /* __EMPATHY_LOCATION_H__ */