Le 13/11/2012 01:18, Jonas Sicking a écrit :
> On Fri, Nov 9, 2012 at 1:58 AM, David Bruant <
brua...@gmail.com> wrote:
>> Le 09/11/2012 09:03, Jonas Sicking a écrit :
>>> I'd love to have a standardized promise API which we could use. If
>>> someone gets something standardized then I'd love to switch to using
>>> it.
https://twitter.com/SickingJ/status/202152629743255552
>> :-D
> I'm quite serious.
I know and that's what makes me happy.
> The web needs a standardized promise.
100% agreed. It's being worked on.
Ok, so I guess send to an array of messages is expected to be removed as
I suggested in my original message?
> MMS however allows sending a single message to multiple people. But
> the API doesn't support MMS yet. And I don't think the API should get
> into the business of trying to guess when to send a message as an SMS
> and when to send it as an MMS.
The WebSMS wikimo page [1] suggests that the same API will be used for
MMS. Is it outdated, then?
>>>> # "Should use opaque objects as message-iden
>>>>> / Jonas
>>>> tifiers rather than longs?"
>>>> => Yes, and the SmsMessage instance itself is this object.
>>>> From the object capability perspective, it would be better to be able to
>>>> delete only messages you have access to.
>>>> Actually, I would rather prefer SmsMessage.prototype.delete than
>>>> SmsManager.delete, this way, it's clear you can only delete messages you
>>>> have access to.
>>> This would make it impossible to store a message identifier in
>>> IndexedDB, which can be quite useful when building more complex UIs.
>> I agree message ids should be kept in the SmsMessage API and as a retrieval
>> mechanism in SmsManager.get(id). But that's where it should stop in my
>> opinion. Every operation that affects only a given message (delete,
>> markAsRead) should be a method in the SmsMessage interface applied to the
>> message instance, not in the SmsManager interface.
> Being able to store identifiers in local databases is a requirement in
> my opinion. Otherwise it gets very hard to cache any data locally in
> the app and cross-reference to the SMS database.
I think we agree; I wrote "I agree message ids should be kept in the
SmsMessage API and as a retrieval mechanism in SmsManager.get(id)"
To be more concrete, the way I see the APIs, we would have (I'm making
all relevant changes):
interface SmsManager
{
DOMRequest send(DOMString number, DOMString message);
unsigned short getNumberOfMessagesForText(in DOMString text);
DOMRequest getMessage(in long id); //
request.result == SMSMessage
DOMRequest getMessages(in SMSFilter filter, bool reverse); //
request.result == SMSIterator
};
interface SmsMessage
{
readonly attribute long id;
readonly attribute DOMString delivery; // could be "sent" or "received"
readonly attribute DOMString sender;
readonly attribute DOMString receiver;
readonly attribute DOMString body;
readonly attribute Date timestamp;
attribute boolean read;
DOMRequest delete();
};
/** CHANGES
* I used DOMRequest instead of the SMS-specific SMSRequest
* I got rid of id-based method except .getMessage
* I got rid of send for an array since it's not relevant for SMS and
devs can do the same in one line of JS.
* SmsManager.markMessageRead is gone and SmsMessage.read is RW (the
ECMAScript representation is a getter/setter that does the right
coercion according to WebIDL)
* delete is on the SmsMessage interface (where it belongs in my opinion)
*/
I think I didn't say it clearly enough, but the way I see it, SmsFilter
still allows to do what the current API allows (including leveraging
indexes!). I just provide more flexibility if people want to create
custom filters. But it's really the same thing.
I've already done half of it, but after your reply to this message, I'll
propose a new IDL and upon agreement, I'll file a bug to modify the API.
David
[1]
https://wiki.mozilla.org/WebAPI/WebSMS