WebAPI/LogAPI: Difference between revisions
< WebAPI
Jump to navigation
Jump to search
(→WebIDL) |
|||
Line 39: | Line 39: | ||
interface LogEntryProperties { | interface LogEntryProperties { | ||
// possible values: ['incoming', 'outgoing''] | |||
attribute DOMString | attribute DOMString type; | ||
attribute DOMString | // [missed, new] | ||
attribute DOMString[] | attribute DOMString status; | ||
attribute DOMString | // ContactId | ||
attribute DOMString | attribute DOMString[] contactId; | ||
// Tel number if not in contacts | |||
attribute DOMString[] tel; | |||
// Object id (for example SMS message on the SMS database) | |||
attribute DOMString objectId; | |||
// oneOf ['SMS', 'Telephony', 'Facebook', 'Twitter'] | |||
attribute DOMString service; | |||
attribute DOMString title; | attribute DOMString title; | ||
attribute DOMString description; | attribute DOMString description; | ||
// Any extra data to be used by applications | |||
attribute any extra; | |||
}; | }; | ||
Revision as of 09:36, 26 April 2012
Use Cases
To record the history of user activity with the device, particularly with communication services (Phone Calls, Messages, Social Networks, etc.)
Consumers
- Comms Log Application (Global for the user and per-contact)
Producers
- Dialer, SMS, e-mail, Facebook, Twitter, ...
WebIDL
interface LogManager : EventTarget { DOMRequest put(LogEntry entry); DOMRequest delete(DOMString entryId); DOMRequest clear(LogClearOptions coptions); // Entries are always returned ordered by timestamp DOMRequest find(LogFindOptions options); attribute Function onentryadded; }; interface LogIterator { DOMRequest next(optional unsigned short n); attribute boolean hasMore; attribute unsigned long position; }; dictionary LogFindOptions { attribute unsigned long maxRecords; attribute DOMString contactId; attribute Date from; attribute Date to; attribute DOMString service; }; interface LogEntryProperties { // possible values: ['incoming', 'outgoing''] attribute DOMString type; // [missed, new] attribute DOMString status; // ContactId attribute DOMString[] contactId; // Tel number if not in contacts attribute DOMString[] tel; // Object id (for example SMS message on the SMS database) attribute DOMString objectId; // oneOf ['SMS', 'Telephony', 'Facebook', 'Twitter'] attribute DOMString service; attribute DOMString title; attribute DOMString description; // Any extra data to be used by applications attribute any extra; }; [Constructor(LogEntryProperties properties)] interface LogEntry : LogEntryProperties { readonly attribute DOMString id; readonly attribute DOMTimestamp timestamp; // When happened };
Examples
Get latest global 20 log entries (ordered by timestamp, newest to oldest)
var filter = {maxNumber: 20}; var req = navigator.mozLog.find(filter); req.onsuccess = function(e) { var iterator = e.target.result; var req2 = iterator.next(10); req2.onsuccess = function(e) { var entries = e.target.result; if(iterator.hasMore) { iterator.next(10); } } }
Get latest 10 log entries corresponding to a contactId