From 3b1371f55fb0e44626a11c64ad8a42d41a094df6 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Thu, 14 Aug 2008 11:44:58 +0000 Subject: [PATCH] Added mms2email functionality to mmsbox --- mbuni/ChangeLog | 2 ++ mbuni/doc/userguide.shtml | 4 +-- mbuni/mmsbox/bearerbox.c | 54 +++++++++++++++++++++++++++++---------- mbuni/mmsbox/mmsbox_cfg.c | 10 ++++++++ mbuni/mmsbox/mmsbox_cfg.h | 2 ++ 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index ac4b72d..10131dc 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2008-08-14 P. A. Bagyenda + * Mmsbox will now queue message to email (outgoing) if recipient looks like an email address 2008-08-08 P. A. Bagyenda * Fix to content adaptation: Better handling of supported image types thanks to George Barros diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index 8db15b7..eca7490 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -698,7 +698,7 @@ lists all the configuration directives. The column Mode     - MMSC + ALL     @@ -804,7 +804,7 @@ lists all the configuration directives. The column Mode     - MMSC + ALL     diff --git a/mbuni/mmsbox/bearerbox.c b/mbuni/mmsbox/bearerbox.c index 8655435..da9b16d 100644 --- a/mbuni/mmsbox/bearerbox.c +++ b/mbuni/mmsbox/bearerbox.c @@ -206,7 +206,7 @@ static void mm7soap_receive(MmsBoxHTTPClientInfo *h) http_header_add(qh, "X-Mbuni-Timestamp", octstr_get_cstr(sx)); octstr_destroy(sx); } - + MOD_SUBJECT(m, h->m, from); qf = qfs->mms_queue_add(from, to, subject, @@ -946,24 +946,50 @@ static int sendMsg(MmsEnvelope *e) goto done; } - res = mms_sendtommsc(mmc, e->from, to->rcpt, - e->msgId, - otransid, - e->token, /* token = linkedid */ - e->vasid ? octstr_get_cstr(e->vasid) : NULL, - e->vaspid, - msg, - e->url1, e->url2, - e->hdrs, - &new_msgid, - &err); + if (octstr_search_char(to->rcpt, '@', 0) > 0) { + int j = octstr_case_search(e->from, octstr_imm("/TYPE=PLMN"), 0); + int k = octstr_case_search(e->from, octstr_imm("/TYPE=IPv"), 0); + int len = octstr_len(e->from); + Octstr *pfrom; + + + if (j > 0 && j - 1 + sizeof "/TYPE=PLMN" == len) + pfrom = octstr_copy(e->from, 0, j); + else if (k > 0 && k + sizeof "/TYPE=IPv" == len) + pfrom = octstr_copy(e->from, 0, k); + else + pfrom = octstr_duplicate(e->from); + + if (octstr_search_char(e->from, '@', 0) < 0) + octstr_format_append(pfrom,"@%S", myhostname); + + res = mms_sendtoemail(pfrom, to->rcpt, + e->subject ? e->subject : octstr_imm(""), + e->msgId, msg, 0, &err, octstr_get_cstr(sendmail_cmd), + myhostname, 0, 0, + "", + "", 0, + e->xqfname, + e->hdrs); + octstr_destroy(pfrom); + } else + res = mms_sendtommsc(mmc, e->from, to->rcpt, + e->msgId, + otransid, + e->token, /* token = linkedid */ + e->vasid ? octstr_get_cstr(e->vasid) : NULL, + e->vaspid, + msg, + e->url1, e->url2, + e->hdrs, + &new_msgid, + &err); done: - if (res == MMS_SEND_OK) { + if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) { to->process = 0; mmsbox_send_report(to->rcpt, "delivery-report", e->url1, octstr_imm("Sent"), new_msgid, mmc->id, mmc->group_id, otransid, NULL, -1); - } else if (res == MMS_SEND_ERROR_FATAL && mmc) mmsbox_send_report(to->rcpt, "delivery-report", e->url1, diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index 81b9957..3b3559e 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -33,6 +33,8 @@ long maxthreads = 0; double queue_interval = -1; Octstr *unified_prefix = NULL; List *strip_prefixes = NULL; +Octstr *sendmail_cmd = NULL; +Octstr *myhostname = NULL; int mt_multipart = 0; MmsQueueHandlerFuncs *qfs; /* queue functions. */ @@ -79,12 +81,20 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) maxthreads = 10; s = mms_cfg_get(grp, octstr_imm("queue-run-interval")); + if (s) { queue_interval = atof(octstr_get_cstr(s)); octstr_destroy(s); } if (queue_interval <= 0) queue_interval = QUEUERUN_INTERVAL; + + if ((sendmail_cmd = mms_cfg_get(grp, octstr_imm("send-mail-prog"))) == NULL) + sendmail_cmd = octstr_imm("/usr/sbin/sendmail -f '%f' '%t'"); + + if ((myhostname = mms_cfg_get(grp, octstr_imm("hostname"))) == NULL) + myhostname = octstr_imm("localhost"); + gdir = mms_cfg_get(grp, octstr_imm("storage-directory")); diff --git a/mbuni/mmsbox/mmsbox_cfg.h b/mbuni/mmsbox/mmsbox_cfg.h index 4539c87..266c41f 100644 --- a/mbuni/mmsbox/mmsbox_cfg.h +++ b/mbuni/mmsbox/mmsbox_cfg.h @@ -94,6 +94,8 @@ extern List *mms_services; /* list of MMS Services */ extern List *mmscs; /* MMSC list. Perhaps turn into a Dict instead? */ extern Octstr *incoming_qdir, *outgoing_qdir, *dlr_dir; extern Octstr *unified_prefix; +extern Octstr *sendmail_cmd; +extern Octstr *myhostname; extern List *strip_prefixes; extern long mmsbox_maxsendattempts, mmsbox_send_back_off, default_msgexpiry; extern long maxthreads;