WebAPI/WebSMS: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎Proposed API: add SmsFilter and SmsIterator)
Line 24: Line 24:
     void            delete(in long uuid);
     void            delete(in long uuid);
     void            delete(in SmsMessage uuid);
     void            delete(in SmsMessage uuid);
     SMSRequest (request.result == SMSIterator) get( { person: "", date: "", direction: "forward" or "backward" } );
     SMSRequest (request.result == SMSIterator) get(SMSFilter);
   };
   };


Line 54: Line 54:
* Add a status attribute that can be equals to SENT or RECEIVED?
* Add a status attribute that can be equals to SENT or RECEIVED?
* Merge sender/receiver and use the status attribute?
* Merge sender/receiver and use the status attribute?
  interface SmsFilter {
    attribute long[] uuids;
    attribute long[] excludeUuids;
    Date            startDate;
    Date            endDate;
    DOMString[]      numbers;
    DOMString        body;
  };
Comments:
* Maybe add a ''isRead'' field?
* Add a ''type'' field that could be SMS or MMS;
* Maybe add a ''status'' field that could be SENT or RECEIVED?
* Can we make the ''body'' field better to allow AND/OR operations?
  interface SmsIterator {
    SmsFilter  filter;
    SmsMessage? next();
    SmsMessage? previous();
    SmsMessage? first();
    SmsMessage? last();
  };


In addition of these interfaces, there is a new event:
In addition of these interfaces, there is a new event:

Revision as of 17:59, 31 August 2011

Steps

In a first time, we want an API that allows to do a SMS Messaging application with similar features that the stock one.

Some advanced functionality might be added after. For example, a "before-sms-send" event that would allow preventing sending a SMS with .preventDefault().

MMS support will be considered later.

Status

You can find some patches here: bug 674725. They are implementing some parts of the proposed API except delete, get and SmsRequest. Also, SmsMessage isn't fully implemented. Those patches are still work in progress.

Proposed API

This API is work in progress and mostly reflect what is implemented and is going to be really soon. Some changes are going to happen. See the comments below each interfaces.

navigator.sms returns an object with the following interface:

 interface SmsManager
 {
   SmsRequest       send(in DOMString number, in DOMString message);
   void             suggestSend(in DOMString number, in DOMString message);
   unsigned short   getNumberOfMessagesForText(in DOMString text);
   void             delete(in long uuid);
   void             delete(in SmsMessage uuid);
   SMSRequest (request.result == SMSIterator) get(SMSFilter);
 };

Comments:

  • send and suggestSend could take an array of numbers.
  • suggestSend could be removed in favor of Web Activities.
  • maybe delete shouldn't return a SMSRequest?
 interface SmsRequest
 {
   readonly attribute unsigned short readyState;
   readonly attribute unsigned short errorCode;
   attribute EventListener           onsuccess;
   attribute EventListener           onerror;
   attribute readonly SmsMessage?    message;
 };
 interface SmsMessage
 {
   readonly attribute long      uuid;
   readonly attribute DOMString sender;
   readonly attribute DOMString receiver;
   readonly attribute DOMString body;
   readonly attribute Date      timestamp;
 };

Comments:

  • Have an array of receiver?
  • Add a status attribute that can be equals to SENT or RECEIVED?
  • Merge sender/receiver and use the status attribute?
 interface SmsFilter {
   attribute long[] uuids;
   attribute long[] excludeUuids;
   Date             startDate;
   Date             endDate;
   DOMString[]      numbers;
   DOMString        body;
 };

Comments:

  • Maybe add a isRead field?
  • Add a type field that could be SMS or MMS;
  • Maybe add a status field that could be SENT or RECEIVED?
  • Can we make the body field better to allow AND/OR operations?
 interface SmsIterator {
   SmsFilter   filter;
   SmsMessage? next();
   SmsMessage? previous();
   SmsMessage? first();
   SmsMessage? last();
 };

In addition of these interfaces, there is a new event:

 interface SmsEvent : Event
 {
   void initSmsEvent(in DOMString eventTypeArg,
                     in boolean canBubbleArg,
                     in boolean cancelableArg,
                     in SmsMessage message);
    readonly attribute SmsMessage message;
  }

The SmsEvent is used for the following events:

 smssent: happens on all window when a SMS is sent;
 smsdelivered: happens on all window when a SMS is delivered to the recipient;
 smsreceived: happens on all window when a SMS is received.

These events carry the SMS in event.message. A security story has to be defined for these events.