summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-07-15 09:30:38 +0000
committerDan Williams <dcbw@redhat.com>2007-07-15 09:30:38 +0000
commit96f27d2e176ea225bdca01503541cbcfb6bbc299 (patch)
tree3c6090cabaaf9a92e4cf7c5b7b178de2252aaf34
parent708766251341e277ac5017340923118f76120441 (diff)
Put IPv4 and IPv6 addresses into buddy properties
-rw-r--r--src/salut-connection.c34
-rw-r--r--src/salut-contact.c38
-rw-r--r--src/salut-contact.h4
3 files changed, 64 insertions, 12 deletions
diff --git a/src/salut-connection.c b/src/salut-connection.c
index 6dfe021f..bdb2880b 100644
--- a/src/salut-connection.c
+++ b/src/salut-connection.c
@@ -1223,7 +1223,9 @@ new_gvalue (GType type)
static GHashTable *
get_properties_hash (const GArray *key,
const gchar *color,
- const gchar *jid)
+ const gchar *jid,
+ const gchar *ip4,
+ const gchar *ip6)
{
GHashTable *properties;
GValue *gvalue;
@@ -1251,6 +1253,20 @@ get_properties_hash (const GArray *key,
g_hash_table_insert (properties, "jid", gvalue);
}
+ if (ip4 != NULL)
+ {
+ gvalue = new_gvalue (G_TYPE_STRING);
+ g_value_set_string (gvalue, ip4);
+ g_hash_table_insert (properties, "ip4-address", gvalue);
+ }
+
+ if (ip6 != NULL)
+ {
+ gvalue = new_gvalue (G_TYPE_STRING);
+ g_value_set_string (gvalue, ip6);
+ g_hash_table_insert (properties, "ip6-address", gvalue);
+ }
+
return properties;
}
@@ -1259,10 +1275,12 @@ emit_properties_changed (SalutConnection *connection,
TpHandle handle,
const GArray *key,
const gchar *color,
- const gchar *jid)
+ const gchar *jid,
+ const gchar *ip4,
+ const gchar *ip6)
{
GHashTable *properties;
- properties = get_properties_hash (key, color, jid);
+ properties = get_properties_hash (key, color, jid, ip4, ip6);
salut_svc_olpc_buddy_info_emit_properties_changed (connection,
handle, properties);
@@ -1321,7 +1339,7 @@ _contact_manager_contact_olpc_properties_changed (SalutConnection *self,
TpHandle handle)
{
emit_properties_changed (self, handle, contact->olpc_key,
- contact->olpc_color, contact->jid);
+ contact->olpc_color, contact->jid, contact->olpc_ip4, contact->olpc_ip6);
}
static void
@@ -1339,7 +1357,7 @@ salut_connection_olpc_get_properties (SalutSvcOLPCBuddyInfo *iface,
if (handle == base->self_handle)
{
properties = get_properties_hash (priv->self->olpc_key,
- priv->self->olpc_color, priv->self->jid);
+ priv->self->olpc_color, priv->self->jid, NULL, NULL);
}
else
{
@@ -1354,7 +1372,7 @@ salut_connection_olpc_get_properties (SalutSvcOLPCBuddyInfo *iface,
return;
}
properties = get_properties_hash (contact->olpc_key, contact->olpc_color,
- contact->jid);
+ contact->jid, contact->olpc_ip4, contact->olpc_ip6);
g_object_unref (contact);
}
@@ -2244,7 +2262,9 @@ _contact_manager_contact_change_cb(SalutContactManager *mgr,
}
#ifdef ENABLE_OLPC
- if (changes & SALUT_CONTACT_OLPC_PROPERTIES)
+ if ((changes & SALUT_CONTACT_OLPC_PROPERTIES) ||
+ (changes & SALUT_CONTACT_OLPC_IP4) ||
+ (changes & SALUT_CONTACT_OLPC_IP6))
_contact_manager_contact_olpc_properties_changed (self, contact, handle);
if (changes & SALUT_CONTACT_OLPC_CURRENT_ACTIVITY)
diff --git a/src/salut-contact.c b/src/salut-contact.c
index a96683c4..9d301a00 100644
--- a/src/salut-contact.c
+++ b/src/salut-contact.c
@@ -160,10 +160,8 @@ salut_contact_init (SalutContact *obj)
obj->olpc_color = NULL;
obj->olpc_cur_act = NULL;
obj->olpc_cur_act_room = 0;
- priv->olpc_announced_activities = g_hash_table_new_full (g_str_hash,
- g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) activity_free);
- priv->olpc_private_activities = g_hash_table_new_full (g_str_hash,
- g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) activity_free);
+ priv->olpc_activities = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free, (GDestroyNotify) activity_free);
#endif
priv->client = NULL;
priv->resolvers = NULL;
@@ -280,6 +278,8 @@ salut_contact_finalize (GObject *object) {
}
g_free (self->olpc_color);
g_free (self->olpc_cur_act);
+ g_free (self->olpc_ip4);
+ g_free (self->olpc_ip6);
#endif
G_OBJECT_CLASS (salut_contact_parent_class)->finalize (object);
@@ -641,7 +641,7 @@ static void
contact_resolved_cb(SalutAvahiServiceResolver *resolver,
AvahiIfIndex interface, AvahiProtocol protocol,
gchar *name, gchar *type, gchar *domain, gchar *host_name,
- AvahiAddress *a, gint port,
+ AvahiAddress *address, gint port,
AvahiStringList *txt, AvahiLookupResultFlags flags,
gpointer userdata) {
SalutContact *self = SALUT_CONTACT (userdata);
@@ -924,6 +924,34 @@ contact_resolved_cb(SalutAvahiServiceResolver *resolver,
g_array_free (new_key, TRUE);
}
}
+
+ if (address != NULL)
+ {
+ gchar* saddr = g_malloc0 (AVAHI_ADDRESS_STR_MAX);
+
+ if (avahi_address_snprint (saddr, AVAHI_ADDRESS_STR_MAX, address))
+ {
+ switch (address->proto)
+ {
+ case AVAHI_PROTO_INET:
+ self->olpc_ip4 = saddr;
+ SET_CHANGE (SALUT_CONTACT_OLPC_IP4);
+ break;
+ case AVAHI_PROTO_INET6:
+ self->olpc_ip6 = saddr;
+ SET_CHANGE (SALUT_CONTACT_OLPC_IP6);
+ break;
+ default:
+ g_free (saddr);
+ break;
+ }
+ }
+ else
+ {
+ g_free (saddr);
+ }
+ }
+
#endif
if (changes != 0) {
diff --git a/src/salut-contact.h b/src/salut-contact.h
index ce050562..3f387437 100644
--- a/src/salut-contact.h
+++ b/src/salut-contact.h
@@ -42,6 +42,8 @@ G_BEGIN_DECLS
#define SALUT_CONTACT_OLPC_PROPERTIES 0x8
#define SALUT_CONTACT_OLPC_CURRENT_ACTIVITY 0x10
#define SALUT_CONTACT_OLPC_ACTIVITIES 0x20
+#define SALUT_CONTACT_OLPC_IP4 0x40
+#define SALUT_CONTACT_OLPC_IP6 0x80
#endif /* ENABLE_OLPC */
typedef struct _SalutContact SalutContact;
@@ -63,6 +65,8 @@ struct _SalutContact {
gchar *olpc_color;
gchar *olpc_cur_act;
TpHandle olpc_cur_act_room;
+ gchar *olpc_ip4;
+ gchar *olpc_ip6;
#endif /* ENABLE_OLPC */
};