• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18 * @kit BasicServicesKit
19 */
20
21import type Want from './@ohos.application.Want';
22import type print from './@ohos.print';
23
24/**
25 * class of print extensionAbility.
26 *
27 * @syscap SystemCapability.Print.PrintFramework
28 * @stagemodelonly
29 * @since 14
30 */
31export default class PrintExtensionAbility {
32
33  /**
34   * Called once to initialize the extensionAbility.
35   * @param { Want } want - call print page want params.
36   * @syscap SystemCapability.Print.PrintFramework
37   * @stagemodelonly
38   * @since 14
39   */
40  onCreate(want: Want): void;
41
42  /**
43   * Called once to start to discover the printers connected with the device.
44   * @syscap SystemCapability.Print.PrintFramework
45   * @stagemodelonly
46   * @since 14
47   */
48  onStartDiscoverPrinter(): void;
49
50  /**
51   * Called once to stop discovering the printer.
52   * @syscap SystemCapability.Print.PrintFramework
53   * @stagemodelonly
54   * @since 14
55   */
56  onStopDiscoverPrinter(): void;
57
58  /**
59   * Called once to connect to the specific printer.
60   * @param { number } printerId - connect the printerId.
61   * @syscap SystemCapability.Print.PrintFramework
62   * @stagemodelonly
63   * @since 14
64   */
65  onConnectPrinter(printerId: number): void;
66
67  /**
68   * Called once to disconnect to the specific printer.
69   * @param { number } printerId - connect the printerId.
70   * @syscap SystemCapability.Print.PrintFramework
71   * @stagemodelonly
72   * @since 14
73   */
74  onDisconnectPrinter(printerId: number): void;
75
76  /**
77   * Called once to start print job.
78   * @param { print.PrintJob } jobInfo - Indicates the information of print job.
79   * @throws { BusinessError } 202 - not system application
80   * @syscap SystemCapability.Print.PrintFramework
81   * @systemapi Hide this for inner system use.
82   * @stagemodelonly
83   * @since 10
84   */
85  onStartPrintJob(jobInfo: print.PrintJob): void;
86
87  /**
88   * Called once to remove the print job has been started.
89   * @param { print.PrintJob } jobInfo - Indicates the information of print job.
90   * @throws { BusinessError } 202 - not system application
91   * @syscap SystemCapability.Print.PrintFramework
92   * @systemapi Hide this for inner system use.
93   * @stagemodelonly
94   * @since 10
95   */
96  onCancelPrintJob(jobInfo: print.PrintJob): void;
97
98  /**
99   * Called once to request the capability of the printer.
100   * @param { number } printerId - Indicates the information of printer.
101   * @returns { print.PrinterCapability } printer capability.
102   * @throws { BusinessError } 202 - not system application
103   * @syscap SystemCapability.Print.PrintFramework
104   * @systemapi Hide this for inner system use.
105   * @stagemodelonly
106   * @since 10
107   */
108  onRequestPrinterCapability(printerId: number): print.PrinterCapability;
109
110  /**
111   * Called once to request preview and send result to Print SA.
112   * @param {  print.PrintJob } jobInfo - Indicates the information of job.
113   * @returns { string} preview result.
114   * @throws { BusinessError } 202 - not system application
115   * @syscap SystemCapability.Print.PrintFramework
116   * @systemapi Hide this for inner system use.
117   * @stagemodelonly
118   * @since 10
119   */
120  onRequestPreview(jobInfo: print.PrintJob): string;
121
122  /**
123   * Called once to finalize the extensionAbility.
124   * @syscap SystemCapability.Print.PrintFramework
125   * @stagemodelonly
126   * @since 14
127   */
128  onDestroy(): void;
129}
130