Version: Smart Feature Phone 3.0

ContactsManager service

Instanciating the service#

Load the following scripts:

<script src="http://127.0.0.1/api/v1/shared/core.js"></script>
<script src="http://127.0.0.1/api/v1/shared/session.js"></script>
<script src="http://127.0.0.1/api/v1/contacts/service.js"></script>

You can then get an instance of the service with code similar to:

const session = new lib_session.Session();
const sessionstate = {};
let _contactsManager = null;
sessionstate.onsessionconnected = function () {
console.log(`ContactsManager onsessionconnected`);
lib_contacts.ContactsManager.get(session).then((ContactsManagerService) => {
console.log(`Got ContactsManager : #ContactsManagerService.service_id}`);
_contactsManager = ContactsManagerService;
}).catch((e) => {
console.log(`Error calling ContactsManager service${JSON.stringify(e)}`);
_contactsManager = null;
});
};
sessionstate.onsessiondisconnected = function () {
console.log(`ContactsManager onsessiondisconnected Daemon Crashed`);
};
// On desktop version, set ENV WS_RUNTIME_TOKEN=secrettoken
session.open('websocket', 'localhost', 'secrettoken', sessionstate, true);

Then the developer can use _contactsManager as ContactsManager service instance.

This service implements the ContactsFactory interface.


ChangeReason enumeration#

{
CREATE,
UPDATE,
REMOVE
}

FilterByOption enumeration#

{
NAME,
GIVEN_NAME,
FAMILY_NAME,
TEL,
EMAIL,
CATEGORY
}

FilterOption enumeration#

{
EQUALS,
CONTAINS,
MATCH,
STARTS_WITH,
FUZZY_MATCH
}

Order enumeration#

{
ASCENDING,
DESCENDING
}

SortOption enumeration#

{
GIVEN_NAME,
FAMILY_NAME,
NAME
}

Address dictionnary#

{
atype: string,
streetAddress: string?,
locality: string?,
region: string?,
postalCode: string?,
countryName: string?,
pref: boolean?
}

BlockedNumberChangeEvent dictionnary#

{
reason: <a href="#enumeration_ChangeReason">ChangeReason</a>,
number: string
}

BlockedNumberFindOptions dictionnary#

{
filterValue: string,
filterOption: <a href="#enumeration_FilterOption">FilterOption</a>
}

ContactField dictionnary#

{
atype: string,
value: string,
pref: boolean
}

ContactFindSortOptions dictionnary#

{
sortBy: <a href="#enumeration_SortOption">SortOption</a>,
sortOrder: <a href="#enumeration_Order">Order</a>,
sortLanguage: string,
filterValue: string,
filterOption: <a href="#enumeration_FilterOption">FilterOption</a>,
filterBy: <a href="#enumeration_FilterByOption">[FilterByOption]</a>,
onlyMainData: boolean
}

ContactInfo dictionnary#

{
id: string,
published: Date,
updated: Date,
bday: Date,
anniversary: Date,
sex: string,
genderIdentity: string,
ringtone: string,
photoType: string,
photoBlob: arraybuffer,
addresses: <a href="#dictionary_Address">[Address]?</a>,
email: <a href="#dictionary_ContactField">[ContactField]?</a>,
url: <a href="#dictionary_ContactField">[ContactField]?</a>,
name: string,
tel: <a href="#dictionary_ContactTelField">[ContactTelField]?</a>,
honorificPrefix: [string]?,
givenName: string,
phoneticGivenName: string,
additionalName: [string]?,
familyName: string,
phoneticFamilyName: string,
honorificSuffix: [string]?,
nickname: [string]?,
category: [string]?,
org: [string]?,
jobTitle: [string]?,
note: [string]?,
groups: [string]?,
icePosition: integer
}

ContactSortOptions dictionnary#

{
sortBy: <a href="#enumeration_SortOption">SortOption</a>,
sortOrder: <a href="#enumeration_Order">Order</a>,
sortLanguage: string
}

ContactTelField dictionnary#

{
atype: string,
value: string,
pref: boolean,
carrier: string
}

ContactsChangeEvent dictionnary#

{
reason: <a href="#enumeration_ChangeReason">ChangeReason</a>,
contacts: <a href="#dictionary_ContactInfo">[ContactInfo]?</a>
}

GroupChangeEvent dictionnary#

{
reason: <a href="#enumeration_ChangeReason">ChangeReason</a>,
group: <a href="#dictionary_GroupInfo">GroupInfo</a>
}

GroupInfo dictionnary#

{
id: string,
name: string
}

IceInfo dictionnary#

{
position: integer,
contactId: string
}

SimContactInfo dictionnary#

{
id: string,
tel: string,
email: string,
name: string,
category: string
}

SimContactLoadedEvent dictionnary#

{
removeCount: integer,
updateCount: integer
}

SpeedDialChangeEvent dictionnary#

{
reason: <a href="#enumeration_ChangeReason">ChangeReason</a>,
speeddial: <a href="#dictionary_SpeedDialInfo">SpeedDialInfo</a>
}

SpeedDialInfo dictionnary#

{
dialKey: string,
tel: string,
contactId: string
}

ContactCursor Interface#

Methods#

  next

next()

Resolves with [ContactInfo]

Rejects with void


ContactsFactory Interface#

Methods#

  add addBlockedNumber addGroup addSpeedDial clearContacts find findBlockedNumbers get getAll getAllBlockedNumbers getAllGroups getAllIce getContactidsFromGroup getCount getSpeedDials importVcf matches remove removeBlockedNumber removeGroup removeIce removeSpeedDial setIce update updateGroup updateSpeedDial

// contacts: [ContactInfo]
add(contacts)

Resolves with void

Rejects with void


// number: string
addBlockedNumber(number)

Resolves with void

Rejects with void


// name: string
addGroup(name)

Resolves with void

Rejects with void


// dialKey: string
// tel: string
// contactId: string
addSpeedDial(dialKey, tel, contactId)

Resolves with void

Rejects with void


clearContacts()

Resolves with void

Rejects with void


// params: ContactFindSortOptions
// batchSize: integer
find(params, batchSize)

Resolves with ContactCursor

Rejects with void


// options: BlockedNumberFindOptions
findBlockedNumbers(options)

Resolves with [string]?

Rejects with void


// id: string
// onlyMainData: boolean
get(id, onlyMainData)

Resolves with ContactInfo

Rejects with void


// options: ContactSortOptions
// batchSize: integer
// onlyMainData: boolean
getAll(options, batchSize, onlyMainData)

Resolves with ContactCursor

Rejects with void


getAllBlockedNumbers()

Resolves with [string]?

Rejects with void


getAllGroups()

Resolves with [GroupInfo]?

Rejects with void


getAllIce()

Resolves with [IceInfo]?

Rejects with void


// groupId: string
getContactidsFromGroup(groupId)

Resolves with [string]?

Rejects with void


getCount()

Resolves with integer

Rejects with void


getSpeedDials()

Resolves with [SpeedDialInfo]?

Rejects with void


// vcf: string
importVcf(vcf)

Resolves with integer

Rejects with void


// filterByOption: FilterByOption
// filter: FilterOption
// value: string
matches(filterByOption, filter, value)

Resolves with boolean

Rejects with void


// contactIds: [string]
remove(contactIds)

Resolves with void

Rejects with void


// number: string
removeBlockedNumber(number)

Resolves with void

Rejects with void


// id: string
removeGroup(id)

Resolves with void

Rejects with void


// contactId: string
removeIce(contactId)

Resolves with void

Rejects with void


// dialKey: string
removeSpeedDial(dialKey)

Resolves with void

Rejects with void


// contactId: string
// position: integer
setIce(contactId, position)

Resolves with void

Rejects with void


// contacts: [ContactInfo]
update(contacts)

Resolves with void

Rejects with void


// id: string
// name: string
updateGroup(id, name)

Resolves with void

Rejects with void


// dialKey: string
// tel: string
// contactId: string
updateSpeedDial(dialKey, tel, contactId)

Resolves with void

Rejects with void


Events#

  BLOCKEDNUMBER_CHANGE CONTACTS_CHANGE GROUP_CHANGE SIM_CONTACT_LOADED SPEEDDIAL_CHANGE

The BLOCKEDNUMBER_CHANGE event emits a BlockedNumberChangeEvent

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_contactsManager.addEventListener(_contactsManager.BLOCKEDNUMBER_CHANGE_EVENT, handleEvent);
_contactsManager.removeEventListener(_contactsManager.BLOCKEDNUMBER_CHANGE_EVENT, handleEvent);

The CONTACTS_CHANGE event emits a ContactsChangeEvent

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_contactsManager.addEventListener(_contactsManager.CONTACTS_CHANGE_EVENT, handleEvent);
_contactsManager.removeEventListener(_contactsManager.CONTACTS_CHANGE_EVENT, handleEvent);

The GROUP_CHANGE event emits a GroupChangeEvent

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_contactsManager.addEventListener(_contactsManager.GROUP_CHANGE_EVENT, handleEvent);
_contactsManager.removeEventListener(_contactsManager.GROUP_CHANGE_EVENT, handleEvent);

The SIM_CONTACT_LOADED event emits a SimContactLoadedEvent

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_contactsManager.addEventListener(_contactsManager.SIM_CONTACT_LOADED_EVENT, handleEvent);
_contactsManager.removeEventListener(_contactsManager.SIM_CONTACT_LOADED_EVENT, handleEvent);

The SPEEDDIAL_CHANGE event emits a SpeedDialChangeEvent

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_contactsManager.addEventListener(_contactsManager.SPEEDDIAL_CHANGE_EVENT, handleEvent);
_contactsManager.removeEventListener(_contactsManager.SPEEDDIAL_CHANGE_EVENT, handleEvent);

Sample code#

New APIs sample code