1/* 2 * Copyright (c) 2023 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 16import rpc from '@ohos.rpc'; 17 18const TAG = 'dlpClass'; 19const ARRAY_LENGTH_MAX = 100; 20const ARRAY_LENGTH_MIN = 0; 21 22export class IAuthUser extends rpc.MessageSequence { 23 public authAccount: string; 24 public authAccountType: number; 25 public dlpFileAccess: number; 26 public permExpiryTime: number; 27 28 constructor( 29 authAccount: string, 30 authAccountType: number, 31 dlpFileAccess: number, 32 permExpiryTime: number 33 ) { 34 super(); 35 this.authAccount = authAccount; 36 this.authAccountType = authAccountType; 37 this.dlpFileAccess = dlpFileAccess; 38 this.permExpiryTime = permExpiryTime; 39 } 40 41 marshalling(dataOut: rpc.MessageSequence): boolean { 42 dataOut.writeString(this.authAccount); 43 dataOut.writeInt(this.authAccountType); 44 dataOut.writeInt(this.dlpFileAccess); 45 dataOut.writeLong(this.permExpiryTime); 46 return true; 47 } 48 49 unmarshalling(dataIn: rpc.MessageSequence): boolean { 50 this.authAccount = dataIn.readString(); 51 this.authAccountType = dataIn.readInt(); 52 this.dlpFileAccess = dataIn.readInt(); 53 this.permExpiryTime = dataIn.readLong(); 54 return true; 55 } 56} 57 58export default class IDLDLPProperty extends rpc.MessageSequence { 59 public ownerAccount: string; 60 public ownerAccountID: string; 61 public ownerAccountType: number; 62 public authUserList: IAuthUser[]; 63 public contactAccount: string; 64 public offlineAccess: boolean; 65 public everyoneAccessList: number[]; 66 public expireTime: number; 67 68 constructor( 69 ownerAccount: string, 70 ownerAccountID: string, 71 ownerAccountType: number, 72 authUserList: IAuthUser[], 73 contactAccount: string, 74 offlineAccess: boolean, 75 everyoneAccessList: number[], 76 expireTime: number 77 ) { 78 super(); 79 this.ownerAccount = ownerAccount; 80 this.ownerAccountID = ownerAccountID; 81 this.ownerAccountType = ownerAccountType; 82 this.authUserList = authUserList; 83 this.contactAccount = contactAccount; 84 this.offlineAccess = offlineAccess; 85 this.everyoneAccessList = everyoneAccessList; 86 this.expireTime = expireTime; 87 } 88 89 marshalling(dataOut: rpc.MessageSequence): boolean { 90 dataOut.writeString(this.ownerAccount); 91 dataOut.writeString(this.ownerAccountID); 92 dataOut.writeInt(this.ownerAccountType); 93 dataOut.writeInt(this.authUserList.length); 94 dataOut.writeParcelableArray(this.authUserList); 95 dataOut.writeString(this.contactAccount); 96 dataOut.writeBoolean(this.offlineAccess); 97 dataOut.writeIntArray(this.everyoneAccessList); 98 dataOut.writeLong(this.expireTime); 99 return true; 100 } 101 102 unmarshalling(dataIn: rpc.MessageSequence): boolean { 103 this.ownerAccount = dataIn.readString(); 104 this.ownerAccountID = dataIn.readString(); 105 this.ownerAccountType = dataIn.readInt(); 106 let arrayLength:number = dataIn.readInt(); 107 if (arrayLength < ARRAY_LENGTH_MIN || arrayLength > ARRAY_LENGTH_MAX) { 108 return false; 109 } 110 for (let i = 0; i < arrayLength; i++) { 111 this.authUserList.push(new IAuthUser('', 0, 0, 0)); 112 } 113 dataIn.readParcelableArray(this.authUserList); 114 this.contactAccount = dataIn.readString(); 115 this.offlineAccess = dataIn.readBoolean(); 116 this.everyoneAccessList = dataIn.readIntArray(); 117 this.expireTime = dataIn.readLong(); 118 return true; 119 } 120}