mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 749856 - Part 4: handle M-Retrieve.conf PDU, r=philikon
This commit is contained in:
parent
21f69c7d42
commit
26fdf81806
@ -13,6 +13,19 @@ Cu.import("resource://gre/modules/mms_consts.js");
|
||||
|
||||
let DEBUG; // set to true to see debug messages
|
||||
|
||||
function translatePduErrorToStatus(error) {
|
||||
switch (error) {
|
||||
case MMS_PDU_ERROR_OK:
|
||||
return MMS_PDU_STATUS_RETRIEVED;
|
||||
case MMS_PDU_ERROR_TRANSIENT_FAILURE:
|
||||
case MMS_PDU_ERROR_TRANSIENT_MESSAGE_NOT_FOUND:
|
||||
case MMS_PDU_ERROR_TRANSIENT_NETWORK_PROBLEM:
|
||||
return MMS_PDU_STATUS_DEFERRED;
|
||||
default:
|
||||
return MMS_PDU_STATUS_UNRECOGNISED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal decoding function for boolean values.
|
||||
*
|
||||
@ -1109,6 +1122,9 @@ if (DEBUG) {
|
||||
}
|
||||
|
||||
const EXPORTED_SYMBOLS = ALL_CONST_SYMBOLS.concat([
|
||||
// Utility functions
|
||||
"translatePduErrorToStatus",
|
||||
|
||||
// Decoders
|
||||
"BooleanValue",
|
||||
"Address",
|
||||
|
@ -153,22 +153,32 @@ MmsService.prototype = {
|
||||
/**
|
||||
* @param data
|
||||
* A wrapped object containing raw PDU data.
|
||||
* @param options
|
||||
* Additional options to be passed to corresponding PDU handler.
|
||||
*
|
||||
* @return true if incoming data parsed successfully and passed to PDU
|
||||
* handler; false otherwise.
|
||||
*/
|
||||
parseStreamAndDispatch: function parseStreamAndDispatch(data) {
|
||||
parseStreamAndDispatch: function parseStreamAndDispatch(data, options) {
|
||||
let msg = MMS.PduHelper.parse(data, null);
|
||||
if (!msg) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
debug("parseStreamAndDispatch: msg = " + JSON.stringify(msg));
|
||||
|
||||
switch (msg.type) {
|
||||
case MMS.MMS_PDU_TYPE_NOTIFICATION_IND:
|
||||
this.handleNotificationIndication(msg);
|
||||
this.handleNotificationIndication(msg, options);
|
||||
break;
|
||||
case MMS.MMS_PDU_TYPE_RETRIEVE_CONF:
|
||||
this.handleRetrieveConfirmation(msg, options);
|
||||
break;
|
||||
default:
|
||||
debug("Unsupported X-MMS-Message-Type: " + msg.type);
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -178,14 +188,50 @@ MmsService.prototype = {
|
||||
* The MMS message object.
|
||||
*/
|
||||
handleNotificationIndication: function handleNotificationIndication(msg) {
|
||||
function callback(status, retr) {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
function retrCallback(error, retr) {
|
||||
callback(MMS.translatePduErrorToStatus(error), retr);
|
||||
}
|
||||
|
||||
let url = msg.headers["x-mms-content-location"].uri;
|
||||
this.sendMmsRequest("GET", url, (function (status, data) {
|
||||
if (data) {
|
||||
this.parseStreamAndDispatch(data);
|
||||
if (!data) {
|
||||
callback.call(null, MMS.MMS_PDU_STATUS_DEFERRED, null);
|
||||
} else if (!this.parseStreamAndDispatch(data, retrCallback)) {
|
||||
callback.call(null, MMS.MMS_PDU_STATUS_UNRECOGNISED, null);
|
||||
}
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle incoming M-Retrieve.conf PDU.
|
||||
*
|
||||
* @param msg
|
||||
* The MMS message object.
|
||||
* @param callback
|
||||
* A callback function that accepts one argument as retrieved message.
|
||||
*/
|
||||
handleRetrieveConfirmation: function handleRetrieveConfirmation(msg, callback) {
|
||||
function callbackIfValid(status, msg) {
|
||||
if (callback) {
|
||||
callback(status, msg)
|
||||
}
|
||||
}
|
||||
|
||||
let status = msg.headers["x-mms-retrieve-status"];
|
||||
if ((status != null) && (status != MMS.MMS_PDU_ERROR_OK)) {
|
||||
callbackIfValid(status, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: further processing
|
||||
|
||||
callbackIfValid(MMS.MMS_PDU_ERROR_OK, msg);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update proxyInfo & MMSC from preferences.
|
||||
*
|
||||
|
@ -40,6 +40,17 @@ const MMS_PDU_ERROR_PERMANENT_SERVICE_DENIED = 225;
|
||||
const MMS_PDU_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 226;
|
||||
const MMS_PDU_ERROR_PERMANENT_CONTENT_UNSUPPORTED = 227;
|
||||
|
||||
// X-Mms-Status values
|
||||
// @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.54
|
||||
const MMS_PDU_STATUS_EXPIRED = 128;
|
||||
const MMS_PDU_STATUS_RETRIEVED = 129;
|
||||
const MMS_PDU_STATUS_REJECTED = 130;
|
||||
const MMS_PDU_STATUS_DEFERRED = 131;
|
||||
const MMS_PDU_STATUS_UNRECOGNISED = 132;
|
||||
const MMS_PDU_STATUS_INDETERMINATE = 133;
|
||||
const MMS_PDU_STATUS_FORWARDED = 134;
|
||||
const MMS_PDU_STATUS_UNREACHABLE = 135;
|
||||
|
||||
const ALL_CONST_SYMBOLS = Object.keys(this);
|
||||
|
||||
// Allow this file to be imported via Components.utils.import().
|
||||
|
Loading…
Reference in New Issue
Block a user