WebAPI/LogAPI: Difference between revisions
< WebAPI
Jump to navigation
Jump to search
(→WebIDL) |
(→WebIDL) |
||
Line 24: | Line 24: | ||
}; | }; | ||
// The iterator will be initialized with a window indicated in the iteration parameters | |||
interface DOMIterator { | interface DOMIterator { | ||
DOMRequest next(optional unsigned short n); | DOMRequest next(optional unsigned short n); // returns the next window | ||
attribute boolean hasMore; | attribute boolean hasMore; | ||
readonly attribute unsigned long count; | attribute unsigned long position; // points always to the element that will be the first returned by the window | ||
readonly attribute any[] values; | readonly attribute unsigned long count; // total number of objects | ||
readonly attribute any[] values; // Contains the current window of objects | |||
}; | }; | ||
Revision as of 10:16, 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 (desc) DOMRequest find(optional LogFindOptions options,optional IteratorOptions iopts); attribute Function onentryadded; }; // The iterator will be initialized with a window indicated in the iteration parameters interface DOMIterator { DOMRequest next(optional unsigned short n); // returns the next window attribute boolean hasMore; attribute unsigned long position; // points always to the element that will be the first returned by the window readonly attribute unsigned long count; // total number of objects readonly attribute any[] values; // Contains the current window of objects }; dictionary LogFindOptions { attribute DOMString contactId; attribute Date from; attribute Date to; attribute DOMString service; }; dictionary IteratorOptions { attribute unsigned long maxRecords; // Max number of records to be returned attribute unsigned long chunkSize: // Chunk size for the iterator }; interface LogEntryProperties { attribute DOMString type; // possible values: ['incoming', 'outgoing''] attribute DOMString status; // [missed, new] attribute DOMString[] contactId; // ContactId attribute DOMString[] tel; // Tel number if not in contacts attribute DOMString objectId; // Object id (for example SMS message on the SMS database) attribute DOMString service; // oneOf ['SMS', 'Telephony', 'Facebook', 'Twitter'] attribute DOMString title; attribute DOMString description; attribute any extra; // Any extra data to be used by applications }; [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