18779efd5Sopenharmony_ci/** 28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License. 58779efd5Sopenharmony_ci * You may obtain a copy of the License at 68779efd5Sopenharmony_ci * 78779efd5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88779efd5Sopenharmony_ci * 98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and 138779efd5Sopenharmony_ci * limitations under the License. 148779efd5Sopenharmony_ci */ 158779efd5Sopenharmony_ci 168779efd5Sopenharmony_ciimport CallLogBuilder from '../entity/CallLogBuilder'; 178779efd5Sopenharmony_ciimport {Direction, AnswerState} from '../contract/Calls'; 188779efd5Sopenharmony_ci 198779efd5Sopenharmony_ciexport enum CallType { 208779efd5Sopenharmony_ci IN = 1, 218779efd5Sopenharmony_ci OUT = 2, 228779efd5Sopenharmony_ci VOICEMAIL = 4, 238779efd5Sopenharmony_ci MISSED = 3, 248779efd5Sopenharmony_ci REJECTED = 5 258779efd5Sopenharmony_ci} 268779efd5Sopenharmony_ci 278779efd5Sopenharmony_ciexport class CallLog { 288779efd5Sopenharmony_ci readonly id: number = -1; 298779efd5Sopenharmony_ci readonly phoneNumber: string; 308779efd5Sopenharmony_ci readonly displayName: string; 318779efd5Sopenharmony_ci readonly callDirection: number; 328779efd5Sopenharmony_ci readonly voicemailUri: string; 338779efd5Sopenharmony_ci readonly simId: number; 348779efd5Sopenharmony_ci readonly simType: number; 358779efd5Sopenharmony_ci readonly isHD: boolean; 368779efd5Sopenharmony_ci readonly isRead: boolean; 378779efd5Sopenharmony_ci readonly ringDuration: number; 388779efd5Sopenharmony_ci readonly talkDuration: number; 398779efd5Sopenharmony_ci readonly formattedNumber: string; 408779efd5Sopenharmony_ci readonly quickSearchKey: string; 418779efd5Sopenharmony_ci readonly numberType: number; 428779efd5Sopenharmony_ci readonly numberTypeName: string; 438779efd5Sopenharmony_ci readonly beginTime: number; 448779efd5Sopenharmony_ci readonly endTime: number; 458779efd5Sopenharmony_ci readonly answerState: number; 468779efd5Sopenharmony_ci readonly createTime: number; 478779efd5Sopenharmony_ci readonly numberLocation: string; 488779efd5Sopenharmony_ci readonly photoId: number; 498779efd5Sopenharmony_ci readonly photoUri: string; 508779efd5Sopenharmony_ci readonly countryIsoCode: number; 518779efd5Sopenharmony_ci readonly callType: number; 528779efd5Sopenharmony_ci constructor(builder: CallLogBuilder) { 538779efd5Sopenharmony_ci this.id = builder.id; 548779efd5Sopenharmony_ci this.phoneNumber = builder.phoneNumber; 558779efd5Sopenharmony_ci this.displayName = builder.displayName; 568779efd5Sopenharmony_ci this.callDirection = builder.callDirection; 578779efd5Sopenharmony_ci this.simId = builder.simId; 588779efd5Sopenharmony_ci this.simType = builder.simType; 598779efd5Sopenharmony_ci this.isHD = builder.isHD; 608779efd5Sopenharmony_ci this.isRead = builder.isRead; 618779efd5Sopenharmony_ci this.ringDuration = builder.ringDuration; 628779efd5Sopenharmony_ci this.talkDuration = builder.talkDuration; 638779efd5Sopenharmony_ci this.formattedNumber = builder.formattedNumber; 648779efd5Sopenharmony_ci this.quickSearchKey = builder.quickSearchKey; 658779efd5Sopenharmony_ci this.numberType = builder.numberType; 668779efd5Sopenharmony_ci this.numberTypeName = builder.numberTypeName; 678779efd5Sopenharmony_ci this.beginTime = builder.beginTime; 688779efd5Sopenharmony_ci this.endTime = builder.endTime; 698779efd5Sopenharmony_ci this.answerState = builder.answerState; 708779efd5Sopenharmony_ci this.createTime = builder.createTime; 718779efd5Sopenharmony_ci this.numberLocation = builder.numberLocation; 728779efd5Sopenharmony_ci this.photoId = builder.photoId; 738779efd5Sopenharmony_ci this.photoUri = builder.photoUri; 748779efd5Sopenharmony_ci this.countryIsoCode = builder.countryIsoCode; 758779efd5Sopenharmony_ci this.callType = this.getCallLogType(); 768779efd5Sopenharmony_ci } 778779efd5Sopenharmony_ci 788779efd5Sopenharmony_ci private getCallLogType() { 798779efd5Sopenharmony_ci if (this.callDirection == Direction.IN) { 808779efd5Sopenharmony_ci if (this.answerState == AnswerState.RECEIVED) { 818779efd5Sopenharmony_ci return CallType.IN; 828779efd5Sopenharmony_ci } 838779efd5Sopenharmony_ci if (this.answerState == AnswerState.MISSED) { 848779efd5Sopenharmony_ci return CallType.MISSED; 858779efd5Sopenharmony_ci } 868779efd5Sopenharmony_ci if (this.answerState == AnswerState.REJECT) { 878779efd5Sopenharmony_ci return CallType.REJECTED; 888779efd5Sopenharmony_ci } 898779efd5Sopenharmony_ci } else { 908779efd5Sopenharmony_ci return CallType.OUT; 918779efd5Sopenharmony_ci } 928779efd5Sopenharmony_ci } 938779efd5Sopenharmony_ci 948779efd5Sopenharmony_ci linkContact() { 958779efd5Sopenharmony_ci } 968779efd5Sopenharmony_ci 978779efd5Sopenharmony_ci /** 988779efd5Sopenharmony_ci * Configure Call Logs as Read 998779efd5Sopenharmony_ci */ 1008779efd5Sopenharmony_ci read() { 1018779efd5Sopenharmony_ci } 1028779efd5Sopenharmony_ci}