From cc3a502516e5f74970e394ff4d703bc3b5478e5f Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Thu, 19 Jul 2007 18:15:17 +0000 Subject: [PATCH] minor fixes re filtering --- mbuni/doc/userguide.shtml | 43 +++++++- mbuni/mmlib/mms_msg.c | 3 +- mbuni/mmsbox/mmsbox.c | 204 ++++++++++++++++++++++---------------- 3 files changed, 157 insertions(+), 93 deletions(-) diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index 8cf263e..fc91157 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -1587,9 +1587,10 @@ Boolean Optional library to be used for filtering/transforming all content (except - SMIL), while building the MT MMS from a SMIL file. This is useful if say you want - to implement custom filtering/transformation of content (e.g. DRM - wrappers around selected content). Note that only elements + SMIL), while building the MT MMS from a SMIL file (or from a + file). This is useful if say you want to implement custom + filtering/transformation of content (e.g. DRM wrappers around + selected content). Note that only elements referenced within the returned SMIL are filtered. See mmsbox_mt_filter.h for details. Also see mm7-mt-filter-params config variable in the VAS specific @@ -2568,6 +2569,24 @@ faked-sender = 100
+ + + mclass + + + Message Class. (e.g. Personal) + + + + + + priority + + + Message Priority. (e.g. Normal) + + +

@@ -3127,6 +3146,24 @@ A detailed list of configuration parameters for MMS Services is given below. + + + X-Mbuni-MessageClass + + + Message Class parameter for message. + + + + + + X-Mbuni-Priority + + + MMS message priority + + +

diff --git a/mbuni/mmlib/mms_msg.c b/mbuni/mmlib/mms_msg.c index 20025d3..7b57f2f 100644 --- a/mbuni/mmlib/mms_msg.c +++ b/mbuni/mmlib/mms_msg.c @@ -1385,7 +1385,6 @@ MmsMsg *mms_frommime(MIMEEntity *mime) m = gw_malloc(sizeof *m); memset(m, 0, sizeof *m); - n = mime_entity_num_parts(mime); mx = mime_entity_duplicate(mime); unconvert_mime_msg(mx); /* Fix-up content type issues. */ @@ -1393,7 +1392,7 @@ MmsMsg *mms_frommime(MIMEEntity *mime) unbase64_mimeparts(mx); m->headers = mime_entity_headers(mx); - if (n > 0) { + if ((n = mime_entity_num_parts(mx)) > 0) { m->ismultipart = 1; m->body.l = gwlist_create(); for (i = 0; i < n; i++) diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index 8a81f7e..e93fe7a 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -295,11 +295,11 @@ enum _xurltype {FILE_TYPE, URL_TYPE}; static Octstr *url_path_prefix(Octstr *url, int type); static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, + Octstr *msg_url, Octstr *base_url, int type, MmsEnvelope *e, Octstr *svc_name, Octstr *faked_sender, Octstr *service_code, int accept_x_headers, List *passthro_headers, - Octstr *mmc_id, Octstr **err); static int fetch_serviceurl(MmsEnvelope *e, MmsService *ms, MmsMsg *m, @@ -422,10 +422,12 @@ static int fetch_serviceurl(MmsEnvelope *e, goto done; } else { Octstr *base_url = url_path_prefix(ms->url, typ); - res = make_and_queue_msg(rb, ctype, rph, base_url, + res = make_and_queue_msg(rb, ctype, rph, + ms->url, + base_url, typ, e, ms->name, ms->faked_sender, ms->service_code, ms->accept_x_headers, ms->passthro_headers, - e->fromproxy, err); + err); if (base_url) octstr_destroy(base_url); @@ -795,15 +797,15 @@ static void add_msg_parts(MIMEEntity *res, xmlNodePtr node, Octstr *base_url, /* Given content, make a message. We'll also use this for send-mms-user! */ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, + Octstr *msg_url, Octstr *base_url, int type, MmsEnvelope *e, Octstr *svc_name, Octstr *faked_sender, Octstr *service_code, int accept_x_headers, List *passthro_headers, - Octstr *mmc_id, Octstr **err) { - Octstr *from = NULL, *subject = NULL, *turl = get_toplevel_url(base_url); - Octstr *dlr_url = NULL, *rr_url = NULL, *mmc = NULL, *xservice_code = NULL; - Octstr *allow_adaptations = NULL; + Octstr *from = NULL, *xfrom = NULL, *subject = NULL, *turl = get_toplevel_url(base_url); + Octstr *dlr_url = NULL, *rr_url = NULL, *mmc = NULL, *xservice_code = NULL, *hsvc_code = NULL; + Octstr *allow_adaptations = NULL, *mclass = NULL, *prio = NULL; MmsMsg *m = NULL; MIMEEntity *me = mime_entity_create(); List *hdrs = NULL, *xheaders = NULL; @@ -815,32 +817,83 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, int i, n, res = -1; gw_assert(svc_name); + + /* Get headers needed, if we are allowed to do so. */ + if (accept_x_headers && reply_headers) { + Octstr *x = NULL; + List *l = NULL; + subject = http_header_value(reply_headers, octstr_imm("X-Mbuni-Subject")); + + if ((x = http_header_value(reply_headers, octstr_imm("X-Mbuni-Expiry"))) != NULL) + expiryt = date_parse_http(x); + + if ((l = http_header_find_all(reply_headers, "X-Mbuni-To")) != NULL) { + int i, n; + for (i = 0, n = gwlist_len(l); ifrom) + gwlist_append(xto, octstr_duplicate(e->from)); + + if (!subject && e && e->subject) + subject = octstr_duplicate(e->subject); + + if (!mmc && e) + mmc = e->fromproxy; /* Get the from address. */ if (faked_sender) from = octstr_duplicate(faked_sender); - else if (accept_x_headers && reply_headers && - (from = http_header_value(reply_headers, octstr_imm("X-Mbuni-From"))) != NULL) - (void)0; /* all done above. */ + else if (xfrom != NULL) + from = octstr_duplicate(xfrom); /* all done above. */ else { /* get first recipient, set that as sender. */ MmsEnvelopeTo *r = (e) ? gwlist_get(e->to, 0) : NULL; if (r) from = octstr_duplicate(r->rcpt); else - from = octstr_imm("anon@anon"); + from = octstr_create("anon@anon"); } /* Get service code. */ if (service_code) xservice_code = octstr_duplicate(service_code); - else if (accept_x_headers && reply_headers) - xservice_code = http_header_value(reply_headers, octstr_imm("X-Mbuni-ServiceCode")); + else if (hsvc_code) + xservice_code = octstr_duplicate(hsvc_code); if (from) _mms_fixup_address(from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); - /* start with the easy one... */ + /* Now get the data. */ if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0) m = mms_frombinary(data, from); else if (octstr_case_compare(ctype, octstr_imm("application/smil")) == 0) { @@ -868,7 +921,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, add_msg_parts(me, smil->xmlChildrenNode, base_url, turl, type, svc_name, - mmc_id, url_map); + mmc, url_map); dict_destroy(url_map); /* SMIL has been modified, convert it to text, put it in. */ @@ -908,54 +961,11 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, http_destroy_headers(xh); mime_entity_set_body(me, data); + + if (mt_filter && mmc) /* filter it too. */ + mt_filter->filter(&me, msg_url, mmc); } - /* Get headers needed, if we are allowed to do so. */ - if (accept_x_headers && reply_headers) { - Octstr *x = NULL; - List *l = NULL; - subject = http_header_value(reply_headers, octstr_imm("X-Mbuni-Subject")); - - if ((x = http_header_value(reply_headers, octstr_imm("X-Mbuni-Expiry"))) != NULL) - expiryt = date_parse_http(x); - - if ((l = http_header_find_all(reply_headers, "X-Mbuni-To")) != NULL) { - int i, n; - for (i = 0, n = gwlist_len(l); ifrom) - gwlist_append(xto, octstr_duplicate(e->from)); - - if (!subject && e && e->subject) - subject = octstr_duplicate(e->subject); - - if (!mmc && e) - mmc = e->fromproxy; /* Add some nice headers. */ xheaders = mime_entity_headers(me); @@ -974,7 +984,13 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, if (allow_adaptations) http_header_add(xheaders, "X-Mms-Allow-Adaptations", (octstr_str_compare(allow_adaptations, "true") == 0) ? "true" : "false"); + + if (mclass) + http_header_add(xheaders, "X-Mms-Message-Class", octstr_get_cstr(mclass)); + if (prio) + http_header_add(xheaders, "X-Mms-Priority", octstr_get_cstr(prio)); + if (subject) http_header_add(xheaders, "Subject", octstr_get_cstr(subject)); if (expiryt > 0) { @@ -1039,17 +1055,13 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, res = 0; done: - if (dlr_url) - octstr_destroy(dlr_url); - - if (rr_url) - octstr_destroy(rr_url); - - if (allow_adaptations) - octstr_destroy(allow_adaptations); - if (from) - octstr_destroy(from); - if (subject) + octstr_destroy(dlr_url); + octstr_destroy(rr_url); + octstr_destroy(mclass); + octstr_destroy(prio); + octstr_destroy(allow_adaptations); + octstr_destroy(from); + octstr_destroy(xfrom); octstr_destroy(subject); if (me) mime_entity_destroy(me); @@ -1059,9 +1071,9 @@ done: gwlist_destroy(xto, (gwlist_item_destructor_t *)octstr_destroy); if (hdrs) http_destroy_headers(hdrs); - - if (xservice_code) - octstr_destroy(xservice_code); + + octstr_destroy(xservice_code); + octstr_destroy(hsvc_code); return res; } @@ -1112,12 +1124,23 @@ static void sendmms_func(void *unused) int i, n, res = 0; Octstr *vasid = http_cgi_variable(cgivars, "vasid"); Octstr *service_code = http_cgi_variable(cgivars, "servicecode"); + Octstr *mclass = http_cgi_variable(cgivars, "mclass"); + Octstr *prio = http_cgi_variable(cgivars, "priority"); + Octstr *distro = http_cgi_variable(cgivars, "distribution"); + Octstr *data_url = NULL; + + dlr_url = http_cgi_variable(cgivars, "dlr-url"); + rr_url = http_cgi_variable(cgivars, "rr-url"); + allow_adaptations = http_cgi_variable(cgivars, "allow-adaptations"); + mmc = http_cgi_variable(cgivars, "mmsc"); + subject = http_cgi_variable(cgivars, "subject"); if ((base_url = http_cgi_variable(cgivars, "base-url")) == NULL) base_url = octstr_imm("http://localhost"); else base_url = octstr_duplicate(base_url); /* because we need to delete it below. */ - + + /* Now get the data. */ if ((data = http_cgi_variable(cgivars, "text")) != NULL) { /* text. */ Octstr *charset = http_cgi_variable(cgivars, "charset"); @@ -1138,6 +1161,7 @@ static void sendmms_func(void *unused) rb = octstr_format("failed to fetch content from url [%S]!", data); base_url = url_path_prefix(data, URL_TYPE); + data_url = octstr_duplicate(data); /* the URL of the message. */ data = reply; http_destroy_headers(rh); @@ -1162,11 +1186,6 @@ static void sendmms_func(void *unused) } else rb = octstr_imm("Missing content"); - dlr_url = http_cgi_variable(cgivars, "dlr-url"); - rr_url = http_cgi_variable(cgivars, "rr-url"); - allow_adaptations = http_cgi_variable(cgivars, "allow-adaptations"); - mmc = http_cgi_variable(cgivars, "mmsc"); - subject = http_cgi_variable(cgivars, "subject"); if ((to = http_cgi_variable(cgivars, "to")) == NULL) rb = octstr_imm("Missing recipient!"); @@ -1200,21 +1219,29 @@ static void sendmms_func(void *unused) if (allow_adaptations) http_header_add(rh, "X-Mbuni-Allow-Adaptations", - (octstr_str_compare(allow_adaptations, "1") == 0) ? "true" : "false"); - + (octstr_str_compare(allow_adaptations, "1") == 0) ? + "true" : "false"); if (mmc) http_header_add(rh, "X-Mbuni-MMSC", octstr_get_cstr(mmc)); if (subject) http_header_add(rh, "X-Mbuni-Subject", octstr_get_cstr(subject)); - + + if (mclass) + http_header_add(rh, "X-Mbuni-MessageClass", octstr_get_cstr(mclass)); + if (prio) + http_header_add(rh, "X-Mbuni-Priority", octstr_get_cstr(prio)); + if (distro) + http_header_add(rh, "X-Mbuni-DistributionIndicator", octstr_get_cstr(distro)); + /* Requests to make_and_queue below can block, but for now we don't care. */ if (ctype && data && !rb) { /* only send if no error. */ - res = make_and_queue_msg(data, ctype, rh, base_url, URL_TYPE, NULL, + res = make_and_queue_msg(data, ctype, rh, + data_url ? data_url : base_url, + base_url, URL_TYPE, NULL, vasid ? vasid : octstr_imm("sendmms-user"), u->faked_sender, service_code, 1, NULL, - mmc, &err); if (res < 0) rb = octstr_imm("Error in message conversion"); @@ -1225,13 +1252,14 @@ static void sendmms_func(void *unused) info(0, "MMSBox.mmssend: u=%s, %s", u ? octstr_get_cstr(u->user) : "none", (res == 0) ? "Sent" : "Not Sent"); - + if (rh) http_destroy_headers(rh); - + octstr_destroy(ctype); octstr_destroy(rb); octstr_destroy(base_url); + octstr_destroy(data_url); } else { http_send_reply(client, HTTP_UNAUTHORIZED, hh, octstr_imm("Authentication failed"));