Bug 709568 - Part 2: RIL <-> DOM glue for incoming SMS. r=smaug

This commit is contained in:
Philipp von Weitershausen 2011-12-24 06:02:52 +01:00
Родитель cc4e633aef
Коммит affbc98602
1 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -39,6 +39,7 @@
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const DEBUG = true; // set to false to suppress debug messages const DEBUG = true; // set to false to suppress debug messages
@ -56,6 +57,12 @@ const DOM_CALL_READYSTATE_INCOMING = "incoming";
const DOM_CALL_READYSTATE_HOLDING = "holding"; const DOM_CALL_READYSTATE_HOLDING = "holding";
const DOM_CALL_READYSTATE_HELD = "held"; const DOM_CALL_READYSTATE_HELD = "held";
const kSmsReceivedObserverTopic = "sms-received";
const DOM_SMS_DELIVERY_RECEIVED = "received";
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
"@mozilla.org/sms/smsservice;1",
"nsISmsService");
/** /**
* Fake nsIAudioManager implementation so that we can run the telephony * Fake nsIAudioManager implementation so that we can run the telephony
@ -156,6 +163,9 @@ nsTelephonyWorker.prototype = {
case "callstatechange": case "callstatechange":
this.handleCallState(message); this.handleCallState(message);
break; break;
case "sms-received":
this.handleSmsReceived(message);
break;
default: default:
// Got some message from the RIL worker that we don't know about. // Got some message from the RIL worker that we don't know about.
return; return;
@ -216,6 +226,17 @@ nsTelephonyWorker.prototype = {
} }
}, },
handleSmsReceived: function handleSmsReceived(message) {
//TODO: put the sms into a database, assign it a proper id, yada yada
let sms = gSmsService.createSmsMessage(-1,
DOM_SMS_DELIVERY_RECEIVED,
message.sender || null,
message.receiver || null,
message.body || null,
message.timestamp);
Services.obs.notifyObservers(sms, kSmsReceivedObserverTopic, null);
},
// nsIRadioWorker // nsIRadioWorker
worker: null, worker: null,