git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5019 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-04-26 14:38:40 +00:00
parent 177513d13e
commit 55655a0480
1 changed files with 16 additions and 8 deletions

View File

@ -1716,18 +1716,19 @@ static void ldl_random_string(char *buf, uint16_t len, char *set)
} }
} }
#define TLEN 8192
void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard) void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard)
{ {
iks *vxml, *iq; iks *vxml = NULL, *iq = NULL;
int e = 0; int e = 0;
ldl_avatar_t *ap; ldl_avatar_t *ap = NULL;
char *text = NULL;
ap = ldl_get_avatar(handle, NULL, from); ap = ldl_get_avatar(handle, NULL, from);
if (!vcard) { if (!vcard) {
char text[8192];
char *ext; char *ext;
if (!ap) { if (!ap) {
return; return;
} }
@ -1737,8 +1738,8 @@ void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id,
} else { } else {
ext = "png"; ext = "png";
} }
text = malloc(TLEN);
snprintf(text, sizeof(text), snprintf(text, TLEN,
"<vCard xmlns='vcard-temp'><PHOTO><TYPE>image/%s</TYPE><BINVAL>%s</BINVAL></PHOTO></vCard>", "<vCard xmlns='vcard-temp'><PHOTO><TYPE>image/%s</TYPE><BINVAL>%s</BINVAL></PHOTO></vCard>",
ext, ext,
ap->base64 ap->base64
@ -1753,12 +1754,12 @@ void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id,
if (!(vxml = iks_tree(vcard, 0, &e))) { if (!(vxml = iks_tree(vcard, 0, &e))) {
globals.logger(DL_LOG_ERR, "Parse returned error [%d]\n", e); globals.logger(DL_LOG_ERR, "Parse returned error [%d]\n", e);
return; goto fail;
} }
if (!(iq = iks_new("iq"))) { if (!(iq = iks_new("iq"))) {
globals.logger(DL_LOG_ERR, "Memory Error\n"); globals.logger(DL_LOG_ERR, "Memory Error\n");
return; goto fail;
} }
if (!iks_insert_attrib(iq, "to", to)) goto fail; if (!iks_insert_attrib(iq, "to", to)) goto fail;
@ -1769,17 +1770,24 @@ void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id,
if (!iks_insert_node(iq, vxml)) goto fail; if (!iks_insert_node(iq, vxml)) goto fail;
apr_queue_push(handle->queue, iq); apr_queue_push(handle->queue, iq);
iq = NULL; iq = NULL;
vxml = NULL; vxml = NULL;
fail: fail:
if (iq) { if (iq) {
iks_delete(iq); iks_delete(iq);
} }
if (vxml) { if (vxml) {
iks_delete(vxml); iks_delete(vxml);
} }
if (text) {
free(text);
}
} }
void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subject, char *body) void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subject, char *body)