minor fixes re filtering
This commit is contained in:
parent
e6a0b2d72c
commit
cc3a502516
|
@ -1587,9 +1587,10 @@ Boolean
|
|||
|
||||
<td valign=top >
|
||||
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
|
||||
<tt>mmsbox_mt_filter.h</tt> for details. Also see
|
||||
<tt>mm7-mt-filter-params</tt> config variable in the <a href="#mmsc_vasp">VAS specific
|
||||
|
@ -2568,6 +2569,24 @@ faked-sender = 100<br>
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>mclass</tt>
|
||||
</td>
|
||||
<td valign=top>
|
||||
Message Class. (e.g. Personal)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>priority</tt>
|
||||
</td>
|
||||
<td valign=top>
|
||||
Message Priority. (e.g. Normal)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</p>
|
||||
|
@ -3127,6 +3146,24 @@ A detailed list of configuration parameters for MMS Services is given below.
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>X-Mbuni-MessageClass</tt>
|
||||
</td>
|
||||
<td valign=top >
|
||||
<b>Message Class</b> parameter for message.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign=top >
|
||||
<tt>X-Mbuni-Priority</tt>
|
||||
</td>
|
||||
<td valign=top >
|
||||
MMS message priority
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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;
|
||||
|
@ -816,31 +818,82 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
|
||||
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); i<n; i++) {
|
||||
Octstr *h = NULL, *v = NULL;
|
||||
List *hv = NULL;
|
||||
int j;
|
||||
http_header_get(l, i, &h, &v);
|
||||
|
||||
hv = http_header_split_value(v);
|
||||
|
||||
for (j = 0; j < gwlist_len(hv); j++) {
|
||||
Octstr *v = gwlist_get(hv, j);
|
||||
/* Fix the address. */
|
||||
_mms_fixup_address(v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL);
|
||||
gwlist_append(xto, v);
|
||||
}
|
||||
octstr_destroy(v);
|
||||
octstr_destroy(h);
|
||||
gwlist_destroy(hv, NULL); /* Don't kill strings since we added them to xto above! */
|
||||
}
|
||||
http_destroy_headers(l);
|
||||
}
|
||||
|
||||
xfrom = http_header_value(reply_headers, octstr_imm("X-Mbuni-From"));
|
||||
dlr_url = http_header_value(reply_headers, octstr_imm("X-Mbuni-DLR-Url"));
|
||||
rr_url = http_header_value(reply_headers, octstr_imm("X-Mbuni-RR-Url"));
|
||||
allow_adaptations = http_header_value(reply_headers, octstr_imm("X-Mbuni-Allow-Adaptations"));
|
||||
|
||||
mmc = http_header_value(reply_headers, octstr_imm("X-Mbuni-MMSC"));
|
||||
mclass = http_header_value(reply_headers, octstr_imm("X-Mbuni-MessageClass"));
|
||||
prio = http_header_value(reply_headers, octstr_imm("X-Mbuni-Priority"));
|
||||
hsvc_code = http_header_value(reply_headers, octstr_imm("X-Mbuni-ServiceCode"));
|
||||
}
|
||||
|
||||
if (gwlist_len(xto) == 0 && e && e->from)
|
||||
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); i<n; i++) {
|
||||
Octstr *h = NULL, *v = NULL;
|
||||
List *hv = NULL;
|
||||
int j;
|
||||
http_header_get(l, i, &h, &v);
|
||||
|
||||
hv = http_header_split_value(v);
|
||||
|
||||
for (j = 0; j < gwlist_len(hv); j++) {
|
||||
Octstr *v = gwlist_get(hv, j);
|
||||
/* Fix the address. */
|
||||
_mms_fixup_address(v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL);
|
||||
gwlist_append(xto, v);
|
||||
}
|
||||
octstr_destroy(v);
|
||||
octstr_destroy(h);
|
||||
gwlist_destroy(hv, NULL); /* Don't kill strings since we added them to xto above! */
|
||||
}
|
||||
http_destroy_headers(l);
|
||||
}
|
||||
dlr_url = http_header_value(reply_headers, octstr_imm("X-Mbuni-DLR-Url"));
|
||||
rr_url = http_header_value(reply_headers, octstr_imm("X-Mbuni-RR-Url"));
|
||||
allow_adaptations = http_header_value(reply_headers, octstr_imm("X-Mbuni-Allow-Adaptations"));
|
||||
|
||||
mmc = http_header_value(reply_headers, octstr_imm("X-Mbuni-MMSC"));
|
||||
}
|
||||
|
||||
if (gwlist_len(xto) == 0 && e && e->from)
|
||||
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);
|
||||
|
@ -975,6 +985,12 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
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(mclass);
|
||||
octstr_destroy(prio);
|
||||
octstr_destroy(allow_adaptations);
|
||||
if (from)
|
||||
octstr_destroy(from);
|
||||
if (subject)
|
||||
octstr_destroy(xfrom);
|
||||
octstr_destroy(subject);
|
||||
if (me)
|
||||
mime_entity_destroy(me);
|
||||
|
@ -1060,8 +1072,8 @@ done:
|
|||
if (hdrs)
|
||||
http_destroy_headers(hdrs);
|
||||
|
||||
if (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");
|
||||
|
@ -1232,6 +1259,7 @@ static void sendmms_func(void *unused)
|
|||
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"));
|
||||
|
|
Loading…
Reference in New Issue