From 1e21db8592c6ad0372c6714993ade482982f1e06 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Tue, 30 May 2006 06:42:05 +0000 Subject: [PATCH] further improvements to HTTP POST data sent by MMSBox to a service: Always add filename parameter to each variable. --- mbuni/doc/examples/mmsc.conf | 48 +++--------------------------------- mbuni/mmsbox/mmsbox.c | 31 ++++++++++++++--------- mbuni/mmsbox/mmsbox_cfg.c | 2 +- 3 files changed, 24 insertions(+), 57 deletions(-) diff --git a/mbuni/doc/examples/mmsc.conf b/mbuni/doc/examples/mmsc.conf index 577a8be..50b33a7 100644 --- a/mbuni/doc/examples/mmsc.conf +++ b/mbuni/doc/examples/mmsc.conf @@ -35,54 +35,14 @@ mms-to-email-txt = "This is a multimedia message (HTML suppressed)" mms-to-email-html = "This is a multimedia message powered by Digital Solutions" mms-to-email-default-subject = "This is a multimedia message" mms-message-too-large-txt = "You have received a multimedia message from %S that is too large for your phone. Go to xxx to view it" -sendmms-port = 10001 - -group = send-mms-user -username = tester -password = foobar -# faked-sender = 100 - -group = send-mms-user -username = binary -password = "user" -faked-sender = 111 - -group = mmsc -id = testone -mmsc-url = http://mbuni:test@192.168.129.52:8080/eaif -# mmsc-url = http://localhost:8080/vasp/servlet/messagerouter -incoming-username = user -incoming-password = pass -incoming-port = 10002 -type = eaif - -group = mms-service -name = me -file = /tmp/start.smil -catch-all = true -# http-post-parameters = fx=true&images.=%i&text.=%t -accept-x-mbuni-headers = true -pass-thro-headers = X-NOKIA-MMSC-Charging,X-NOKIA-MMSC-Charged-Party -keyword = test -omit-empty = no -suppress-reply = true - -group = mms-service -name = fullmessage -get-url = http://localhost/~bagyenda/images/apache_pb.gif -# http-post-parameters = fx=true&image=%i&text=%t -accept-x-mbuni-headers = true -keyword = thixs - group = mms-vasp vasp-id = newscorp -type = soap +type = eaif short-code = 111 -vasp-username = newscorp -vasp-password = news123 -vasp-url = http://mmsc:mms@localhost:23535/ -mms-to-local-copy-handler = true +vasp-username = mbuni +vasp-password = test +vasp-url = http://user:pass@localhost:12345/ group = mmsproxy name = "A test mms proxy" diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index 43ef4e3..45850cc 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -146,7 +146,7 @@ static MmsService *get_service(Octstr *keyword, Octstr *mmc_id) } static void add_all_matching_parts(MIMEEntity *plist, MmsServiceUrlParam *pm, - MIMEEntity *me, MmsMsg *msg, int lev) + MIMEEntity *me, MmsMsg *msg, int lev, int count) { int i, n; @@ -163,7 +163,7 @@ static void add_all_matching_parts(MIMEEntity *plist, MmsServiceUrlParam *pm, if (me->multiparts && list_len(me->multiparts) > 0) { /* Don't process multipart. */ for (i = 0, n = list_len(me->multiparts); i < n; i++) add_all_matching_parts(plist, pm, - list_get(me->multiparts, i), msg, lev+1); + list_get(me->multiparts, i), msg, lev+1,i); goto done; } @@ -194,24 +194,28 @@ done: if (data) { MIMEEntity *p = mime_entity_create(); Octstr *cd = octstr_format("form-data; name=\"%S\"", pm->name); - + if (ctype) { - /* If name parameter given, pass it as filename. */ + /* If Content-Location header or name (content-type) parameter given, pass it as filename. */ Octstr *c = NULL, *q = NULL; + Octstr *cloc = http_header_value(me->headers, + octstr_imm("Content-Location")); split_header_value(ctype, &c, &q); - if (q) { - List *ph = get_value_parameters(q); - Octstr *v = http_header_value(ph, octstr_imm("name")); + if (q || cloc) { + List *ph = q ? get_value_parameters(q) : http_create_empty_headers(); + Octstr *v = cloc ? cloc : http_header_value(ph, octstr_imm("name")); - if (!v) /* make up a fake name. */ - v = octstr_format("%S-file", pm->name); + if (!v) /* make up a fake name if none is given */ + v = octstr_format("part-%d-%d", lev, count); octstr_format_append(cd, "; filename=\"%S\"", v); http_header_remove_all(ph, "name"); - octstr_destroy(v); + if (v != cloc) + octstr_destroy(v); octstr_destroy(ctype); + v = make_value_parameters(ph); if (v && octstr_len(v) > 0) ctype = octstr_format("%S; %S", c, v); @@ -221,11 +225,14 @@ done: octstr_destroy(v); http_destroy_headers(ph); - octstr_destroy(q); + if (q) + octstr_destroy(q); } if (c) octstr_destroy(c); + if (cloc) + octstr_destroy(cloc); } http_header_add(p->headers, "Content-Disposition", octstr_get_cstr(cd)); if (ctype) /* This header must come after the above it seems. */ @@ -304,7 +311,7 @@ static int fetch_serviceurl(MmsEnvelope *e, x->headers = rh; for (i = 0, n = list_len(ms->params); i < n; i++) { MmsServiceUrlParam *p = list_get(ms->params, i); - add_all_matching_parts(x, p, msg, m, 0); + add_all_matching_parts(x, p, msg, m, 0, i); } mime_entity_body_and_headers(x, &body, &rh); diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index a427df1..7060a14 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -102,7 +102,7 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) - unified_prefix = _mms_cfg_getx(grp, octstr_imm("unified-prefix")); + // unified_prefix = _mms_cfg_getx(grp, octstr_imm("unified-prefix")); mms_cfg_get_int(grp, octstr_imm("sendmms-port"), &sendmms_port.port); #ifdef HAVE_LIBSSL