From 90ddec83d97ebb0cb94acef737ba34b5edcd5e32 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 30 Nov 2006 15:27:37 +0000 Subject: [PATCH] tweak git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3493 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/libdingaling/.update | 2 +- libs/libdingaling/src/libdingaling.c | 47 +++++++++++++++++++--------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/libs/libdingaling/.update b/libs/libdingaling/.update index 04fce42f4e..49c0de4241 100644 --- a/libs/libdingaling/.update +++ b/libs/libdingaling/.update @@ -1 +1 @@ -Thu Nov 16 16:09:31 UTC 2006 +Thu Nov 30 15:25:59 UTC 2006 diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 6a2c3aee19..b373a38175 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -497,18 +497,21 @@ static int on_disco_info(void *user_data, ikspak *pak) struct ldl_buffer *buffer; size_t x; - if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) { - iks *msg; - apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker); - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling...."); - apr_queue_push(handle->queue, msg); - } apr_cpystrn(id, from, sizeof(id)); if ((resource = strchr(id, '/'))) { *resource++ = '\0'; } + if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) { + iks *msg; + apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker); + msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, "Ding A Ling...."); + apr_queue_push(handle->queue, msg); + } + + + if (resource) { for (x = 0; x < strlen(resource); x++) { resource[x] = (char)tolower((int)resource[x]); @@ -705,13 +708,7 @@ static int on_presence(void *user_data, ikspak *pak) if (!status) { status = type; } - - if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) { - iks *msg; - apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker); - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling...."); - apr_queue_push(handle->queue, msg); - } + apr_cpystrn(id, from, sizeof(id)); lowercase(id); @@ -720,6 +717,15 @@ static int on_presence(void *user_data, ikspak *pak) *resource++ = '\0'; } + if (!apr_hash_get(handle->sub_hash, from, APR_HASH_KEY_STRING)) { + iks *msg; + apr_hash_set(handle->sub_hash, apr_pstrdup(handle->pool, from), APR_HASH_KEY_STRING, &marker); + msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, "Ding A Ling...."); + apr_queue_push(handle->queue, msg); + } + + + if (resource && strstr(resource, "talk") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) { apr_cpystrn(buffer->buf, from, buffer->len); fflush(stderr); @@ -811,14 +817,25 @@ static int on_subscribe(void *user_data, ikspak *pak) ldl_handle_t *handle = user_data; char *from = iks_find_attrib(pak->x, "from"); char *to = iks_find_attrib(pak->x, "to"); - iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "Ding A Ling...."); + iks *msg = NULL; + char *id = strdup(from); + char *r; + if (!id) { + return -1; + } + if ((r = strchr(from, '/'))) { + *r++; + } + + msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, id, "Ding A Ling...."); + if (to && ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { iks_insert_attrib(msg, "from", to); } apr_queue_push(handle->queue, msg); - msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, from, "Ding A Ling...."); + msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, id, "Ding A Ling...."); if (to && ldl_test_flag(handle, LDL_FLAG_COMPONENT)) { iks_insert_attrib(msg, "from", to);