|
|
|
@ -48,82 +48,6 @@ static void relog_now(int notused)
|
|
|
|
|
alog_reopen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finds text part, returns copy. */
|
|
|
|
|
static MIMEEntity *find_textpart(MIMEEntity *m)
|
|
|
|
|
{
|
|
|
|
|
Octstr *ctype = NULL, *params = NULL;
|
|
|
|
|
MIMEEntity *res = NULL;
|
|
|
|
|
List *headers;
|
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
|
|
if (!m) return NULL;
|
|
|
|
|
|
|
|
|
|
headers = mime_entity_headers(m);
|
|
|
|
|
get_content_type(headers, &ctype, ¶ms);
|
|
|
|
|
http_destroy_headers(headers);
|
|
|
|
|
|
|
|
|
|
if (ctype && octstr_str_compare(ctype, "text/plain") == 0) {
|
|
|
|
|
res = mime_entity_duplicate(m);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((n = mime_entity_num_parts(m)) > 0) {
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
|
MIMEEntity *x = mime_entity_get_part(m, i);
|
|
|
|
|
res = find_textpart(x);
|
|
|
|
|
mime_entity_destroy(x);
|
|
|
|
|
|
|
|
|
|
if (res != NULL)
|
|
|
|
|
goto done2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
done:
|
|
|
|
|
if (res) { /* We got it! Convert charset if needed. */
|
|
|
|
|
List *params_h = get_value_parameters(params);
|
|
|
|
|
Octstr *charset = http_header_value(params_h, octstr_imm("charset"));
|
|
|
|
|
Octstr *body = mime_entity_body(res);
|
|
|
|
|
if (charset == NULL ||
|
|
|
|
|
octstr_str_compare(charset, "unknown") == 0) {
|
|
|
|
|
octstr_destroy(charset);
|
|
|
|
|
charset = octstr_create(DEFAULT_CHARSET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (octstr_str_case_compare(charset, DEFAULT_CHARSET) != 0) {
|
|
|
|
|
charset_convert(body, DEFAULT_CHARSET, octstr_get_cstr(charset)); /* XXX error ignored? */
|
|
|
|
|
mime_entity_set_body(res, body);
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(body);
|
|
|
|
|
http_destroy_headers(params_h);
|
|
|
|
|
octstr_destroy(charset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done2:
|
|
|
|
|
|
|
|
|
|
octstr_destroy(ctype);
|
|
|
|
|
octstr_destroy(params);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Gets the keyword, if any, from the text part of the message.
|
|
|
|
|
* converts charset as needed.
|
|
|
|
|
*/
|
|
|
|
|
static Octstr *get_keyword(MIMEEntity *me)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
MIMEEntity *t = find_textpart(me);
|
|
|
|
|
Octstr *txt = t ? mime_entity_body(t) : NULL;
|
|
|
|
|
List *l = t ? octstr_split_words(txt) : NULL;
|
|
|
|
|
Octstr *keyword = l ? gwlist_extract_first(l) : NULL;
|
|
|
|
|
|
|
|
|
|
if (t)
|
|
|
|
|
mime_entity_destroy(t);
|
|
|
|
|
gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
|
|
|
|
|
octstr_destroy(txt);
|
|
|
|
|
|
|
|
|
|
return keyword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int _x_octstr_comp(Octstr *x, Octstr *y)
|
|
|
|
|
{
|
|
|
|
|
return (octstr_case_compare(x,y) == 0);
|
|
|
|
@ -665,7 +589,7 @@ static int mmsbox_service_dispatch(MmsEnvelope *e)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
me = mms_tomime(msg, 0);
|
|
|
|
|
keyword = get_keyword(me);
|
|
|
|
|
keyword = get_keyword_from_mime(me);
|
|
|
|
|
|
|
|
|
|
xto = gwlist_get(e->to, 0);
|
|
|
|
|
ms = get_service(keyword, e->fromproxy, xto ? xto->rcpt : NULL);
|
|
|
|
|