updated mmsbox callback interface usage
This commit is contained in:
parent
ea9506fde2
commit
6cb349ec90
|
@ -1,3 +1,5 @@
|
|||
2010-11-05 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Better event callback info (MM7 headers, etc)
|
||||
2010-11-04 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Minor compiler error fixes
|
||||
2010-11-03 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
|
|
|
@ -1306,3 +1306,8 @@ Octstr *mm7_soap_header_value(MSoapMsg_t *m, Octstr *header)
|
|||
{
|
||||
return http_header_value(m->envelope, header);
|
||||
}
|
||||
|
||||
List *mm7_soap_headers(MSoapMsg_t *m)
|
||||
{
|
||||
return m ? http_header_duplicate(m->envelope) : NULL;
|
||||
}
|
||||
|
|
|
@ -80,4 +80,7 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
|
|||
MSoapMsg_t *mm7_make_resp(MSoapMsg_t *mreq, int status, Octstr *msgid, int isclientside);
|
||||
/* Return the header value for some header. */
|
||||
Octstr *mm7_soap_header_value(MSoapMsg_t *m, Octstr *header);
|
||||
|
||||
/* Return (a copy of) all the headers */
|
||||
List *mm7_soap_headers(MSoapMsg_t *m);
|
||||
#endif
|
||||
|
|
|
@ -195,7 +195,7 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|||
|
||||
MSoapMsg_t *mreq = NULL, *mresp = NULL;
|
||||
int hstatus = HTTP_OK;
|
||||
List *rh = NULL;
|
||||
List *rh = NULL, *lh;
|
||||
Octstr *reply_body = NULL;
|
||||
|
||||
List *to = NULL;
|
||||
|
@ -396,12 +396,13 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|||
s = mm7_soap_header_value(mreq, octstr_imm("MM7Version"));
|
||||
r = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
|
||||
transid = mm7_soap_header_value(mreq, octstr_imm("TransactionID"));
|
||||
lh = mm7_soap_headers(mreq);
|
||||
mmsbox_event_cb(h->m->id, mm7_msgtype(mreq), 0, s, 200,
|
||||
octstr_len(h->body), 0, from,
|
||||
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL, r, transid, NULL, value);
|
||||
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL, r, transid, lh, value);
|
||||
octstr_destroy(s);
|
||||
octstr_destroy(r);
|
||||
|
||||
http_destroy_headers(lh);
|
||||
done:
|
||||
if (mresp && mm7_soapmsg_to_httpmsg(mresp, &h->m->ver, &rh, &reply_body) == 0)
|
||||
http_send_reply(h->client, hstatus, rh, reply_body);
|
||||
|
@ -411,11 +412,13 @@ done:
|
|||
if (mresp) {
|
||||
Octstr *s = octstr_format("%d.%d.%d", h->m->ver.major, h->m->ver.minor1, h->m->ver.minor2);
|
||||
Octstr *r = mm7_soap_header_value(mresp, octstr_imm("MessageID"));
|
||||
List *lh = mm7_soap_headers(mresp);
|
||||
mmsbox_event_cb(h->m->id, mm7_msgtype(mresp), 0, s, status,
|
||||
octstr_len(reply_body), 0, to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
||||
from, r, transid, NULL, NULL);
|
||||
from, r, transid, lh, NULL);
|
||||
octstr_destroy(s);
|
||||
octstr_destroy(r);
|
||||
http_destroy_headers(lh);
|
||||
} else
|
||||
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE, 2);
|
||||
|
||||
|
@ -508,18 +511,18 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|||
MmsMsg *m = NULL;
|
||||
List *mh = NULL;
|
||||
int hstatus = HTTP_NO_CONTENT;
|
||||
List *rh = http_create_empty_headers();
|
||||
List *rh = http_create_empty_headers(), *lh;
|
||||
List *rqh = http_create_empty_headers();
|
||||
Octstr *reply_body = NULL, *value = NULL, *value2 = NULL;
|
||||
|
||||
List *to = gwlist_create(), *hto = NULL;
|
||||
Octstr *subject = NULL, *otransid = NULL, *msgid = NULL, *s;
|
||||
Octstr *subject = NULL, *otransid = NULL, *msgid = NULL, *s = NULL;
|
||||
Octstr *hfrom = NULL, *rr_uri = NULL;
|
||||
time_t expiryt = -1, deliveryt = -1;
|
||||
Octstr *qf = NULL, *xver = NULL, *mmc_id = NULL, *qdir = NULL;
|
||||
int msize = h->body ? octstr_len(h->body) : 0;
|
||||
int dlr;
|
||||
int mtype = -1, mm7type = -1;
|
||||
int i, mtype = -1, mm7type = -1;
|
||||
|
||||
debug("mmsbox.mm7eaif.sendinterface", 0,
|
||||
" --> Enterred eaif send interface, blen=[%d] <--- ",
|
||||
|
@ -702,24 +705,35 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|||
break;
|
||||
}
|
||||
|
||||
lh = http_create_empty_headers(); /* Collect extension headers */
|
||||
for (i = 0; i<gwlist_len(h->headers); i++) {
|
||||
Octstr *n = NULL, *v = NULL;
|
||||
|
||||
s = http_header_value(h->headers, octstr_imm("X-NOKIA-MMSC-Version"));
|
||||
http_header_get(h->headers, i, &n, &v);
|
||||
if (n && octstr_case_search(n, octstr_imm("X-NOKIA-"), 0) == 0)
|
||||
http_header_add(lh, octstr_get_cstr(n), octstr_get_cstr(v));
|
||||
|
||||
if (octstr_case_compare(n, octstr_imm("X-NOKIA-MMSC-Version")) == 0)
|
||||
s = octstr_duplicate(v); /* Get mmsc version */
|
||||
octstr_destroy(n);
|
||||
octstr_destroy(v);
|
||||
}
|
||||
mmsbox_event_cb(h->m->id, mm7type, 0, s, hstatus,
|
||||
msize, 0, hfrom,
|
||||
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
||||
msgid, otransid, NULL, value);
|
||||
msgid, otransid, lh, value);
|
||||
octstr_destroy(s);
|
||||
http_destroy_headers(lh);
|
||||
done:
|
||||
|
||||
xver = octstr_format(EAIF_VERSION, h->m->ver.major, h->m->ver.minor1);
|
||||
http_header_add(rh, "X-NOKIA-MMSC-Version", octstr_get_cstr(xver));
|
||||
|
||||
|
||||
mmsbox_event_cb(h->m->id, mm7type >= 0 ? mm7type + 1 : MM7_TAG_VASPErrorRsp, 0,
|
||||
xver, hstatus,
|
||||
0, 0, to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
||||
hfrom,
|
||||
msgid, otransid, NULL, reply_body);
|
||||
msgid, otransid, rh, reply_body);
|
||||
|
||||
http_send_reply(h->client, hstatus, rh, reply_body ? reply_body : octstr_imm(""));
|
||||
|
||||
|
@ -1186,11 +1200,14 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
/* Invoke call back */
|
||||
s = mm7_soap_header_value(mreq, octstr_imm("MM7Version"));
|
||||
r = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
|
||||
|
||||
mmsbox_event_cb(mmc->id, mm7_msgtype(mreq), 0, s, hstatus,
|
||||
mms_msgsize(m), e->attempts, e->from,
|
||||
to,r, transid, hdrs, NULL);
|
||||
octstr_destroy(s);
|
||||
octstr_destroy(r);
|
||||
|
||||
|
||||
if ((mresp = mm7_parse_soap(ph, rbody)) == NULL) {
|
||||
*error = octstr_format("Failed to parse MMSC[url=%S, id=%S] response!",
|
||||
mmc->mmsc_url, mmc->id);
|
||||
|
@ -1254,11 +1271,13 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
}
|
||||
|
||||
s = mm7_soap_header_value(mresp, octstr_imm("MM7Version"));
|
||||
|
||||
mmsbox_event_cb(mmc->id, mm7_msgtype(mresp), 0, s, tstatus,
|
||||
0, e->attempts, e->from,
|
||||
to, ret, transid,hdrs, status_details);
|
||||
octstr_destroy(s);
|
||||
|
||||
|
||||
if (ret)
|
||||
mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
|
||||
done1:
|
||||
|
@ -1820,7 +1839,7 @@ static int send_mm4_res(int mtype, Octstr *to, Octstr *sender, Octstr *transid,
|
|||
static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
||||
{
|
||||
char *err = NULL;
|
||||
List *headers, *h2;
|
||||
List *headers = NULL, *h2;
|
||||
Octstr *mm4_type;
|
||||
Octstr *transid = NULL, *orig_sys = NULL, *ack = NULL, *res = NULL, *me = NULL, *rstatus = NULL;
|
||||
int i, mtype = -1, mm1_type = -1, mm7type;
|
||||
|
@ -1938,7 +1957,6 @@ static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
|||
}
|
||||
|
||||
mime_replace_headers(mm, headers);
|
||||
http_destroy_headers(headers);
|
||||
|
||||
/* Now convert from mime to MMS message, if we should */
|
||||
if (mm1_type >= 0) {
|
||||
|
@ -2095,7 +2113,7 @@ static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
|||
mmsbox_event_cb(mmc->id, mm7type, 1, octstr_imm("1.0"), 200,
|
||||
mms_msgsize(msg), 0, from,
|
||||
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
||||
msgid, transid, NULL, value);
|
||||
msgid, transid, headers, value);
|
||||
|
||||
/* respond to the sender as necessary. */
|
||||
if (mm4_type &&
|
||||
|
@ -2124,7 +2142,7 @@ static Octstr *handle_msg(MIMEEntity *mm, Octstr *from, List *to, MmscGrp *mmc)
|
|||
octstr_destroy(mmc_id);
|
||||
octstr_destroy(value);
|
||||
mms_destroy(msg);
|
||||
|
||||
http_destroy_headers(headers);
|
||||
done:
|
||||
|
||||
return res;
|
||||
|
@ -2407,5 +2425,4 @@ void mm4_receive_func(int *sock)
|
|||
gwthread_join_every((void *)smtp_thread);
|
||||
|
||||
gwlist_destroy(slist, NULL);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue