1/**
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file: Call status
18 */
19const callStateTxtList = ['calling', 'callHold', 'dialing', 'partyIsRinging', '', 'thirdPartyCalls', 'hangUpCompleted',
20  'hangingUp', 'callIdle'];
21
22export default class CallStateConst {
23  // calling
24  public static CALL_STATUS_ACTIVE: number = 0;
25
26  // State keeping
27  public static CALL_STATUS_HOLDING: number = 1;
28
29  // Dialing
30  public static CALL_STATUS_DIALING: number = 2;
31
32  // The other party is ringing
33  public static CALL_STATUS_ALERTING: number = 3;
34
35  // Call from the other party
36  public static CALL_STATUS_INCOMING: number = 4;
37
38  // Waiting for third-party calls
39  public static CALL_STATUS_WAITING: number = 5;
40
41  // Hung up
42  public static CALL_STATUS_DISCONNECTED: number = 6;
43
44  // Hanging up
45  public static CALL_STATUS_DISCONNECTING: number = 7;
46
47  // Idle state
48  public static CALL_STATUS_IDLE: number = 8;
49  public static callStateObj = {
50    CALL_STATUS_ACTIVE: CallStateConst.CALL_STATUS_ACTIVE,
51    CALL_STATUS_HOLDING: CallStateConst.CALL_STATUS_HOLDING,
52    CALL_STATUS_DIALING: CallStateConst.CALL_STATUS_DIALING,
53    CALL_STATUS_ALERTING: CallStateConst.CALL_STATUS_ALERTING,
54    CALL_STATUS_INCOMING: CallStateConst.CALL_STATUS_INCOMING,
55    CALL_STATUS_WAITING: CallStateConst.CALL_STATUS_WAITING,
56    CALL_STATUS_DISCONNECTED: CallStateConst.CALL_STATUS_DISCONNECTED,
57    CALL_STATUS_DISCONNECTING: CallStateConst.CALL_STATUS_DISCONNECTING,
58    CALL_STATUS_IDLE: CallStateConst.CALL_STATUS_IDLE
59  };
60
61  public static callStateTextMap = {
62    [CallStateConst.CALL_STATUS_ACTIVE]: '',
63    [CallStateConst.CALL_STATUS_HOLDING]: $r('app.string.callHold'),
64    [CallStateConst.CALL_STATUS_DIALING]: $r('app.string.dialing'),
65    [CallStateConst.CALL_STATUS_ALERTING]: $r('app.string.partyIsRinging'),
66    [CallStateConst.CALL_STATUS_INCOMING]: '',
67    [CallStateConst.CALL_STATUS_WAITING]: '',
68    [CallStateConst.CALL_STATUS_DISCONNECTED]: $r('app.string.hangUpCompleted'),
69    [CallStateConst.CALL_STATUS_DISCONNECTING]: $r('app.string.hangingUp'),
70    [CallStateConst.CALL_STATUS_IDLE]: ''
71  };
72
73  public static defaultCallData = {
74    callId: 0,
75    callState: CallStateConst.CALL_STATUS_IDLE,
76    accountNumber: '',
77    videoState: 0,
78    callType: 0,
79    conferenceState: 0
80  };
81
82  public getCallStateText = (state) => callStateTxtList[state] !== undefined ? callStateTxtList[state] : '';
83}