• 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
16import type { P2PDiscovery } from './discovery/P2pDiscovery';
17import type { P2PMonitor } from './discovery/P2pMonitor';
18import type { MdnsDiscovery } from './discovery/MdnsDiscovery';
19import { Log } from '@ohos/common';
20import type { Backend } from './ipp/Backend';
21import type { CapabilitiesCache } from './ipp/CapabilitiesCache';
22import type { WifiModel } from './model/WifiModel';
23import type { LocalDiscoverySession } from './LocalDiscoverySession';
24import CheckEmptyUtils from '@ohos/common';
25
26const TAG = 'PrintServiceAdapter';
27
28export class PrintServiceAdapter {
29  private static instance: PrintServiceAdapter;
30  private _p2pDiscovery: P2PDiscovery;
31  private _mdnsDiscovery: MdnsDiscovery;
32  private _p2pMonitor: P2PMonitor;
33  private _backend: Backend;
34  private _capabilitiesCache: CapabilitiesCache;
35  private _wifiModel: WifiModel;
36  private _localDiscoverySession: LocalDiscoverySession;
37
38
39  public static getInstance(): PrintServiceAdapter {
40    Log.info(TAG, 'getInstance enter');
41    if (CheckEmptyUtils.isEmpty(this.instance)) {
42      this.instance = new PrintServiceAdapter();
43    }
44    return this.instance;
45  }
46
47  private constructor() {
48
49  }
50
51  get localDiscoverySession(): LocalDiscoverySession {
52    return this._localDiscoverySession;
53  }
54
55  set localDiscoverySession(localDiscoverySession: LocalDiscoverySession) {
56    this._localDiscoverySession = localDiscoverySession;
57  }
58
59  /**
60   * get P2pMonitor
61   *
62   * @return P2pMonitor P2pMonitor
63   */
64  get wifiModel(): WifiModel {
65    return this._wifiModel;
66  }
67
68  /**
69   * set P2pMonitor
70   *
71   * @param p2pMonitor P2pMonitor
72   */
73  set wifiModel(wifiModel: WifiModel) {
74    this._wifiModel = wifiModel;
75  }
76
77
78  /**
79   * get CapabilitiesCache
80   *
81   * @return getCapabilitiesCache getCapabilitiesCache
82   */
83  get capabilitiesCache(): CapabilitiesCache {
84    return this._capabilitiesCache;
85  }
86
87  /**
88   * set CapabilitiesCache
89   *
90   * @param capabilitiesCache CapabilitiesCache
91   */
92  set capabilitiesCache(capabilitiesCache: CapabilitiesCache) {
93    this._capabilitiesCache = capabilitiesCache;
94  }
95
96  /**
97  * get P2pDiscovery
98  *
99  * @return P2pDiscovery P2pDiscovery
100  */
101  get p2pDiscovery(): P2PDiscovery {
102    return this._p2pDiscovery;
103  }
104
105  /**
106   * set P2pDiscovery
107   *
108   * @param p2pDiscovery P2pDiscovery
109   */
110  set p2pDiscovery(p2pDiscovery: P2PDiscovery) {
111    this._p2pDiscovery = p2pDiscovery;
112  }
113
114  /**
115   * get Backend
116   *
117   * @return Backend Backend
118   */
119  get backend(): Backend {
120    return this._backend;
121  }
122
123  /**
124   * set Backend
125   *
126   * @param backend Backend
127   */
128  set backend(backend: Backend) {
129    this._backend = backend;
130  }
131
132  /**
133   * get MdnsDiscovery
134   *
135   * @return MdnsDiscovery
136   */
137  get mdnsDiscovery(): MdnsDiscovery {
138    return this._mdnsDiscovery;
139  }
140
141  /**
142   * set MdnsDiscovery
143   *
144   * @param MdnsDiscovery
145   */
146  set mdnsDiscovery(mdnsDiscovery: MdnsDiscovery) {
147    this._mdnsDiscovery = mdnsDiscovery;
148  }
149
150
151  /**
152   * get MdnsDiscovery
153   *
154   * @return MdnsDiscovery
155   */
156  get p2pMonitor(): P2PMonitor {
157    return this._p2pMonitor;
158  }
159
160  /**
161   * set MdnsDiscovery
162   *
163   * @param MdnsDiscovery
164   */
165  set p2pMonitor(p2pMonitor: P2PMonitor) {
166    this._p2pMonitor = p2pMonitor;
167  }
168}