• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-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
16// @ts-nocheck
17import { Constants, AppStorageKeyName } from '@ohos/common'
18import { Log } from '@ohos/common';
19import AppStorageHelper from '../Common/Adapter/AppStorageHelper'
20import { PrinterExtensionInfo } from '@ohos/common';
21
22const TAG = '[PrintExtensionModel]:'
23
24export class PrintExtensionModel {
25  private mPrintExtensions: Array<PrinterExtensionInfo> = []
26
27  get getPrintExtensions() {
28    return this.mPrintExtensions;
29  }
30
31  set setPrintExtensions(array: Array<PrinterExtensionInfo>) {
32    this.mPrintExtensions = array;
33  }
34
35  /**
36   * get all PrintExtension
37   */
38  public dealGetAllPrintExtension(data: Array<PrinterExtensionInfo>) {
39    if (data === undefined) {
40      Log.error(TAG, 'dealGetAllPrintExtension return for null data');
41      return;
42    }
43    this.setPrintExtensions([]);
44    for (let index = 0; index < data.length; index++) {
45      var newInfo = new PrinterExtensionInfo(data[index].extensionId, data[index].vendorId,
46      data[index].vendorName, data[index].vendorIcon, data[index].version);
47      this.mPrintExtensions.push(newInfo);
48    }
49    AppStorageHelper.setValue<Array<PrinterExtensionInfo>>(this.getPrintExtensions, AppStorageKeyName.PRINT_EXTENSION_LIST_NAME);
50  }
51}