/** * @module CallLog */ import { Subscription } from "rxjs"; import { CallLog, CallLogRB } from '../../models/callLog.model'; import { RBEvent } from '../../models/event.model'; import { User } from "../../models/user.model"; import { Service } from '../../services/service'; /** @internal */ export declare const CALL_LOG_SVC = "CallLogService"; /** * @eventProperty * CallLog service events send to other services * Can listen to it via `CallLogService.subscribe()` API */ export declare enum CallLogServiceEvents { /** * @eventProperty * This `RBEvent` is sent when the call log history has been updated in one of the following ways: * - Reception of a new call log from the server (in the form of a notification, and not in response to an explicit fetch request). * - User request to delete call logs.\ * This covers cases of deletion of a specific call log, all call logs associated with a user, or the user's entire call log history.\ * This event contains no data, the current call logs history have to be retrieved by using the getCallLogs() API. */ ON_CALLLOG_UPDATED = "ON_CALLLOG_UPDATED", /** * @eventProperty * This `RBEvent` is sent when the total number of call logs for the connected user has been updated. * * **Event Data** * - **counter**: The total number of call logs */ ON_CALLLOG_TOTAL_NUMBER_UPDATED = "ON_CALLLOG_TOTAL_NUMBER_UPDATED", /** * @eventProperty * This `RBEvent` is sent when the counter of missed calls has been updated. * * **Event Data** * - **counter**: The number of missed calls */ ON_CALLLOG_MISSEDCALLS_COUNTER_UPDATED = "ON_CALLLOG_MISSEDCALLS_COUNTER_UPDATED" } /** * @ignore * @eventProperty * CallLog service internal events send to other sevices via sendInnerEvent() * Should not be used by SDK user */ export declare enum CallLogServiceInnerEvents { /** * @eventProperty * This RB event is sent when at least one call log present in the internal cache has been updated after a change * in the Personal Directory of the user. * By change, we mean the creation, modification or removal of a personal contact leading to the update of the display information * associated to a call log item such as the display name or the associated contact details. * This event does not cover any update in the call logs list. */ RAINBOW_ON_CALLLOG_INFOS_UPDATED = "RAINBOW_ON_CALLLOG_INFOS_UPDATED" } export interface CallLogService { /** * Subscribe to the CallLog updates, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - (optional) array of event to listen * @returns Returns RxJS Subscription */ subscribe(callback: (event: RBEvent) => any, eventNames?: CallLogServiceEvents | CallLogServiceEvents[]): Subscription; /** * Indicates whether the CallLog Service has been initialized or not. * If this is not the case, no call log has yet been retrieved. * @returns True if the CallLog Service has been intitialized; False otherwise. */ isInitialized(): boolean; /** * Initializes the CallLog service for the user by returning the most recent call logs. * The number of call logs to be returned can optionnaly be specified in the request * Additional call logs have to be retrieved furthermore via the API 'getNextCallLogs'. * @param number - (optional) Number of call logs to retrieve at initialization step. * This parameter is optional and set by default to 100. * The allowed range of values is [1..250]. * If the value provided is greater, the maximum value will be used. * If the value is 0 or less, the request will be rejected and an error thrown. * @returns Returns a Promise with an array of the first retrieved call logs * @throws Error - In the event of the specified parameter is invalid. */ initCallLogs(number: number): Promise; /** * Get the current content of the call logs history. * The request can be made at any time to retrieve the call logs already known by the Call Log service. * It is also advisable to make this request when an 'ON_CALLLOG_UPDATED' event has been received notifying you * that the call logs history has been updated following an operation such as the reception of a brand new call log, * the modification (e.g., marking as read) or the deletion of existing call log(s). * @returns Returns a Promise with an array of the call logs already known by the Call Log service */ getCallLogs(): Promise; /** * Get additional call logs. * The number of additional call logs to be returned can be specified in the request * @param number - (optional) Number of additional call logs to get. * This parameter is optional and set by default to 100. * The allowed range of values is [1..250]. * If the value provided is greater, the maximum value will be used. * If the value is 0 or less, the request will be rejected and an error thrown. * @returns Returns a Promise with an array of the call logs already known by the Call Log service and the newly retrieved. * @throws Error - In the event of the specified parameter is invalid. */ getNextCallLogs(number: number): Promise; /** * Return the number total of call logs available for the connected user */ getCallLogsCounter(): number; /** * Returns the number total of missed calls. * Missed call is a call with the following properties: state is 'missed', direction is 'incoming' and read flag is 'false'. * This API can be called before the first call logs are retrieved, i.e. before the initialization step. */ getMissedCallsCounter(): number; /** * Mark a call log item specified by its object instance as read * @param callLog - The call log instance to mark as read */ markCallLogAsRead(callLog: CallLog): void; /** * Mark all call logs already known by the Call Log service as read * This concerns the call logs fetched from server during the initialization step and through additional fetch requests. */ markAllCallsLogsAsRead(): void; /** * Delete all call logs associated with a user * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. */ deleteCallLogsForUser(user: User): Promise; /** * Delete the call log specified by its object instance * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. * @param callLog - The call log instance to delete */ deleteCallLog(callLog: CallLog): Promise; /** * Delete all the call logs history of the connected user * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. */ deleteAllCallLogs(): Promise; } /** * @ignore */ export declare class CallLogServiceRB extends Service implements CallLogService { private static CALL_LOG_NAMESPACE; private static CALL_LOG_ACK_NAMESPACE; private static CALL_LOG_NOTIF_NAMESPACE; private static NB_DEF_UCAAS_CALL_LOG; private static NB_MAX_NEXT_CALL_LOGS; private static NB_DEF_CALL_LOGS; private errorHelperService; private xmppService; private profileService; private logger; private contactService; private mainService; private telephonyService?; private webrtcGatewayService?; private personalDirectoryService?; private office365AdService?; private companyDirectoryService; private centralizedService; private initialized; private fetchServerXMPPError; private rxSubject; private innerRxSubject; private xmppConnectionSubscription; private personalDirSubscriptions; private callLogHandlerRef; private callLogMessageAckRef; private callLogNotificationRef; private usePhonebookDirectory; private callLogPromises; private numberMissedCallLogs; private numberTotalCallLogs; private numberDuplicatedCallLogs; private callLogs; private aggregatedCallLogs; private firstTimeStamp; private lastTimestamp; private startPromise; private startPromiseResolve; private ackAllCallLogsInDBDone; private fetchingCallLogs; private userFetchRequest; /** * Returns the Call Log singleton */ static getInstance(): CallLogServiceRB; static build(): CallLogServiceRB; private constructor(); /** * This async method has to be call to start the CallLogs service */ start(): Promise; /** * This async method has to be call to stop the CallLogs service */ stop(): Promise; private attachHandlers; private removeXMPPListeners; private attachXMPPListeners; private resetCallLogsData; /** * Subscribe to the CallLog updates, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - (optional) array of event to listen * @returns Returns RxJS Subscription */ subscribe(callback: (event: RBEvent) => any, eventNames?: CallLogServiceEvents | CallLogServiceEvents[]): Subscription; /** * Call log service events send to other services via sendEvent() * Can listen to it via CallLogServiceRB.subscribe() API * @param name - The name of the event * @param data - The data to be send (an object) */ private sendEvent; /** * Subscribe to updates from the service (all events are of RBEvent type {name: string, data:any}); * Here's a list of events received : * - RAINBOW_ON_CALLLOG_INFOS_UPDATED * @param handler - The call-back function that will be subscribed to the RxJS subject */ subscribeToInnerEvents(handler: any): Subscription; /** * Call log service events send to other services via sendEvent() * Can listen to it via CallLogServiceRB.subscribe() API * @param name - The name of the event * @param data - The data to be send (an object) */ private sendInnerEvent; /** * Initialize the Call Logs service on the 1st request to fetch call logs from the server * Only the following methods are allowed to initialize the call logs, i.e. to retrieve them for the first time from the server * - getCalllogs * - getAggregatedCalllogs * The consistency of the number of missed calls logs is also check * @param initFetchOptions - [optional] Options to fect the initial call logs from server */ private initialize; /** * Get the number of missed calls logs (state === "missed" && direction === CallDirection.INCOMING) from the server * This method can be used before retrieving all the callLogs from the server (by using fetch) * An event 'ON_CALLLOG_MISSEDCALLS_COUNTER_UPDATED' is sent with the number of missed calls logs. */ private getMissedCallsCounterFromServer; /** * Retrieve from server N call logs (specified by NB_DEF_UCAAS_CALL_LOG) time-stamped after the specified date * This method is called at reconnection after a XMPP disconnection. * @param useAfter - [optional] A date after which the call logs must be retrieved */ private getCallLogHistoryPage; /** * Retrieve (via a XMPP request to server) N call log from the server * after a specified timestamp (priority date criteria) or before a specified timestamp * @param options - fetch options */ private fetchCallLogsFromServer; /** * Management of XMPP Message regarding namespace 'jabber:iq:telephony:call_log' such as * - Number of call logs for the current user * - Number of unread call logs * - Reception of a call log item following a fetch request * @param stanza - The received stanza. */ private onHistoryCallLogMessageReceived; /** * Management of XMPP Message regarding namespace 'urn:xmpp:telephony:call_log:receipts' * Message received as an acknowledge following a call log operation 'mark-as-read' previously sent to the server * In the internal call logs table, the concerned call logs (identified by received "call_id" attribute(s)) are marked as as read. * This operation is done once a XMPP message in the format * * is received from the server. * Then the number of missed calls logs is checked again on internal cache and associated counter may be updated * If the case, an event 'ON_CALLLOG_MISSEDCALLS_COUNTER_UPDATED' is sent with the new value of the missed calls logs. * @param stanza - The received stanza. */ private onCallLogAckReceived; /** * Management of XMPP Message regarding namespace 'jabber:iq:notification:telephony:call_log' such as * - Reception of a new call log item from server (as notification, not on request) * - Deletion of one or more call logs (single call log, call log, call logs associated to a contact) * This operation is done once a XMPP message with a "deleted_call_log" elem or a "updated_call_log" elem is received from the server. * @param stanza - The received stanza. */ private onCallLogNotificationReceived; /** * Management of personal directory service events concerning the addition, modification and deletion (single or complete) of personal contacts * The call logs will be scanned to see if a name resolution can be performed for entries that only have a displayed phone number. * A name resolution in the personal directory can also be updated (in the case of a change in names, for example) * or even deleted if the associated number is no longer linked to a personal contact. * The "association" of a call log item with a personal contact is done via the data 'directoryContactId' * @param event - The received stanza. */ private onPersonalContactEvent; /** * Indicates whether the CallLog Service has been initialized or not. * If this is not the case, no call log has yet been retrieved. * @returns True if the CallLog Service has been initialized; False otherwise. */ isInitialized(): boolean; /** * Return an array of available call logs, each item representing one call log. * By available, we means first the call logs already recovered after the first initialization following a request to the server * to get the N most recent one. And then the call logs that have been added following new notification(s) from server. * Also some call logs may have been deleted following a user action. * Note that if it has not yet been done, the initialization phase will be automatically performed by retrieving * a certain number of logs from server (Fetch options defined by default by CallLogService are used) */ getCalllogs(): Promise; /** * Return an array of aggregated call logs, each item representing one more call logs grouped by contact. * The aggregated call logs are deduced from the available call logs (obtained with the 'getCalllogs' method) but the items * are grouped by contact according to different information such as status ("missed" or not), direction ("incoming", "outgoing") * Note that if it has not yet been done, the initialization phase will be automatically performed by retrieving * a certain number of logs from server (Fetch options defined by default by CallLogService are used) */ getAggregatedCalllogs(): Promise; /** * Request to retrieve new call logs from the server. * The number of new call logs to retrieve can be specified. * This API returns the whole call logs, those already retrieved by previous requests and the new one. * Each call log will contain some selected and simplified information . * Note that the initialization phase must have been done previously. If this is not the case, an error is returned * @param numberOfElts - Number of new call logs to fetch */ fetchNextPage(numberOfElts?: number): Promise; /** * Return an customized array of call logs with selected and simplified item information. * The customized call logs are deduced from the available call logs */ private orderCallLogsHistory; /** * Returns the number total of missed calls. * Missed call is a call with the following properties: state is 'missed', direction is 'incoming' and read flag is 'false'. * This API can be called before the first call logs are retrieved, i.e. before the initialization step. */ getMissedCallsCounter(): number; /** * Return the number total of call logs available for the connected user */ getCallLogsCounter(): number; /** * Get the number of missed calls (state === "missed" && direction === CallDirection.INCOMING) for call logs * present in the internal cache ONLY. * This counter may be different to the counter known by the server which covers all call logs available on its side */ private getMissedCallLogsInCacheCounter; /** * Mark a call log item specified by its object instance as read * @param calllog - The call log instance to mark as read */ markCallLogAsRead(callLog: CallLog): void; /** * Mark all call logs already known by the Call Log service as read * This concerns the call logs fetched from server during the initialization step and through additional fetch requests. */ markAllCallsLogsAsRead(): void; /** * Ack all call logs on server side. */ private ackAllCallLogsInDB; /** * Process the deletion of all call logs associated with a directory contact. * The contactId (i.E. the userId) is not managed by the xmpp server in "delete" IQ. * It will be necessary to carry out a deletion via the phone numbers used by the directory contact. * @param contact - The directory contact instance to delete */ private deleteCallLogsForDirectoryContact; /** * Delete all call logs associated to a user * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. */ deleteCallLogsForUser(user: User): Promise; /** * Delete the call log specified by its object instance * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. * @param callLog - The call log instance to delete */ deleteCallLog(callLog: CallLog): Promise; /** * Delete the call log specified by its id * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. * @param id - The call log identifier */ deleteCallLogById(id: string): Promise; /** * Delete all the call logs history of the connected user * A ON_CALLLOG_UPDATED event is sent afterwards at the completion of the operation to notify about the call logs history update. */ deleteAllCallLogs(): Promise; /** * Remove in the internal call logs table one call log specified by its id * This operation is done once a XMPP message with a "peer" elem and "call_id" attribute is received from the server. * @param jid - The contact's jid */ private removeCallLogsForUser; /** * Remove in the internal call logs table the call log item specified by its callId * This operation is done once a XMPP message with a "deleted_call_log" elem and "call_id" attribute is received from the server. * @param callId - Call log id */ private removeOneCallLog; /** * If the remote user is not an RB user, we will analyse whether we have any identifying information (names), as follows: * - Checks whether a name resolution has been performed on the server side * This requires attributes "origin" and "id" to be provided in the element "identity" * - If such name resolution done and a valid directory contact has been retrieved, this contact is also returned as result * - A temporary contact associated with the current call log is created in all cases: No name resolution done on server side, * provided information did not allow a directory contact to be retrieved (Invalid Id) or directory contact found * - Check whether name information can be retrieved in the following way: * - Presence of stanza attributes linked to names: "firstName"/"lastName"/"displayName" * - Search in Outlook if allowed * @param callLogElem - The received call log element * @param otherPartyNumber - The phone number of the remote party * Either the external number called by the Rainbow user OR the phone number that called the user * @returns Promise that resolves with contact(s) that will be linked to the call log entry */ private getOrCreateContactWithNameResolution; /** * Create a Call log from received call log or stanza XMPP element and add it in internal cache. * @param stanzaElem - The received stanza. * @param callLogElem - The received call log element */ private createCallLogFromStanza; /** * Order the call logs stored in the internal table (array) by date * A ON_CALLLOG_UPDATED event is sent to notify about the call logs history cache update * This event is sent only if the classification does not follow a explicit fetch request. * Update the counter of missed calls (state === "missed" && CallDirection.INCOMING) * The number of missed calls logs is then checked again on internal cache and the associated counter may be updated * If the case, an event 'ON_CALLLOG_MISSEDCALLS_COUNTER_UPDATED' is sent with the new value. */ private orderCallLogs; /** * Build the table of aggregated call logs * The aggregated call logs are deduced from the available call logs (obtained with the 'getCalllogs' method) but the items * are grouped by user according to different information such as status ("missed" or not), direction ("incoming", "outgoing") */ private aggregateCalllogs; /** * Check if the specified contact is a directory contact i.e. coming from one of the following directories: * - Personal directory / Business directory / Microsoft O365 contacts/AD users * - PBX phonebook / Outlook (for Desktop only) * @param contact - The contact to check. */ private isDirectoryContact; /** * Get a callLog entry from calLogs array by its id * @param id - The call log Id */ getCallLogById(id: string): CallLogRB; /** * Initializes the CallLog service for the user by returning the most recent call logs. * The number of call logs to be returned can optionnaly be specified in the request * Additional call logs have to be retrieved furthermore via the API 'getNextCallLogs'. * @param number - (optional) Number of call logs to retrieve at initialization step. * This parameter is optional and set by default to 100. * The maximum value allowed is 250. If the value supplied is greater, the maximum value will be used. * @returns Returns a Promise with an array of the first retrieved call logs */ initCallLogs(number?: number): Promise; /** * Get the current content of the call logs history. * The request can be made at any time to retrieve the call logs already known by the Call Log service. * It is also advisable to make this request when an 'ON_CALLLOG_UPDATED' event has been received notifying you * that the call logs history has been updated following an operation such as the reception of a brand new call log, * the modification (e.g., marking as read) or the deletion of existing call log(s). * @returns Returns a Promise with an array of the call logs already known by the Call Log service */ getCallLogs(): Promise; /** * Get additional call logs. * The number of additional call logs to be returned can be specified in the request * @param number - (optional) Number of additional call logs to get. * This parameter is optional and set by default to 100. * The allowed range of values is [1..250]. * If the value provided is greater, the maximum value will be used. * If the value is 0 or less, the request will be rejected and an error thrown. * @returns Returns a Promise with an array of the call logs already known by the Call Log service and the newly retrieved. * @throws Error - In the event of the specified parameter is invalid. */ getNextCallLogs(number?: number): Promise; } //# sourceMappingURL=callLog.service.d.ts.map