• 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 #include "print_service_proxy.h"
16 #include "iremote_broker.h"
17 #include "print_constant.h"
18 #include "print_job.h"
19 #include "print_log.h"
20 #include "printer_info.h"
21 
22 namespace OHOS::Print {
23 using namespace OHOS::HiviewDFX;
24 
PrintServiceProxy(const sptr<IRemoteObject> & object)25 PrintServiceProxy::PrintServiceProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IPrintService>(object) {}
26 
GetResult(int retCode,MessageParcel & reply)27 int32_t PrintServiceProxy::GetResult(int retCode, MessageParcel &reply)
28 {
29     if (retCode != ERR_NONE) {
30         PRINT_HILOGE("rpc error code = %{public}d", retCode);
31         return E_PRINT_RPC_FAILURE;
32     }
33 
34     retCode = reply.ReadInt32();
35     PRINT_HILOGD("PrintServiceProxy out. ret = [%{public}d]", retCode);
36     return retCode;
37 }
38 
StartPrint(const std::vector<std::string> & fileList,const std::vector<uint32_t> & fdList,std::string & taskId)39 int32_t PrintServiceProxy::StartPrint(const std::vector<std::string> &fileList,
40     const std::vector<uint32_t> &fdList, std::string &taskId)
41 {
42     MessageParcel data, reply;
43     MessageOption option;
44     data.WriteInterfaceToken(GetDescriptor());
45     PRINT_HILOGD("Current file is %{public}zd", fileList.size());
46     for (auto file : fileList) {
47         PRINT_HILOGD("file is %{private}s", file.c_str());
48     }
49 
50     data.WriteBool(fileList.size() > 0);
51     if (!fileList.empty()) {
52         data.WriteStringVector(fileList);
53     }
54 
55     data.WriteBool(fdList.size() > 0);
56     if (!fdList.empty()) {
57         data.WriteInt32(fdList.size());
58         for (auto fd : fdList) {
59             data.WriteFileDescriptor(fd);
60         }
61     }
62 
63     PRINT_HILOGD("PrintServiceProxy StartPrint started.");
64     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_START_PRINT, data, reply, option);
65     ret = GetResult(ret, reply);
66     taskId = reply.ReadString();
67     PRINT_HILOGD("PrintServiceProxy StartPrint ret = [%{public}d] TaskId = %{public}s", ret, taskId.c_str());
68     return ret;
69 }
70 
StartPrint(const std::vector<std::string> & fileList,const std::vector<uint32_t> & fdList,std::string & taskId,const sptr<IRemoteObject> & token)71 int32_t PrintServiceProxy::StartPrint(const std::vector<std::string> &fileList, const std::vector<uint32_t> &fdList,
72     std::string &taskId, const sptr<IRemoteObject> &token)
73 {
74     MessageParcel data, reply;
75     MessageOption option;
76     data.WriteInterfaceToken(GetDescriptor());
77     PRINT_HILOGD("Current file is %{public}zd", fileList.size());
78     for (auto file : fileList) {
79         PRINT_HILOGD("file is %{private}s", file.c_str());
80     }
81 
82     data.WriteBool(fileList.size() > 0);
83     if (!fileList.empty()) {
84         data.WriteStringVector(fileList);
85     }
86 
87     data.WriteBool(fdList.size() > 0);
88     if (!fdList.empty()) {
89         data.WriteInt32(fdList.size());
90         for (auto fd : fdList) {
91             data.WriteFileDescriptor(fd);
92         }
93     }
94 
95     if (token == nullptr || !data.WriteRemoteObject(token)) {
96         PRINT_HILOGE("StartPrint, Failed to write remote object.");
97         return E_PRINT_INVALID_PARAMETER;
98     }
99     PRINT_HILOGD("PrintServiceProxy StartPrint started.");
100     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_START_PRINT, data, reply, option);
101     ret = GetResult(ret, reply);
102     taskId = reply.ReadString();
103     PRINT_HILOGD("PrintServiceProxy StartPrint ret = [%{public}d] TaskId = %{public}s", ret, taskId.c_str());
104     return ret;
105 }
106 
StopPrint(const std::string & taskId)107 int32_t PrintServiceProxy::StopPrint(const std::string &taskId)
108 {
109     MessageParcel data, reply;
110     MessageOption option;
111     data.WriteInterfaceToken(GetDescriptor());
112     data.WriteString(taskId);
113     PRINT_HILOGD("PrintServiceProxy StopPrint started.");
114     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_STOP_PRINT, data, reply, option);
115     ret = GetResult(ret, reply);
116     PRINT_HILOGD("PrintServiceProxy StopPrint out. ret = [%{public}d]", ret);
117     return ret;
118 }
119 
ConnectPrinter(const std::string & printerId)120 int32_t PrintServiceProxy::ConnectPrinter(const std::string &printerId)
121 {
122     MessageParcel data, reply;
123     MessageOption option;
124     data.WriteInterfaceToken(GetDescriptor());
125     data.WriteString(printerId);
126     PRINT_HILOGD("PrintServiceProxy ConnectPrinter started.");
127     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_CONNECTPRINTER, data, reply, option);
128     ret = GetResult(ret, reply);
129     PRINT_HILOGD("PrintServiceProxy ConnectPrinter out. ret = [%{public}d]", ret);
130     return ret;
131 }
132 
DisconnectPrinter(const std::string & printerId)133 int32_t PrintServiceProxy::DisconnectPrinter(const std::string &printerId)
134 {
135     MessageParcel data, reply;
136     MessageOption option;
137     data.WriteInterfaceToken(GetDescriptor());
138     data.WriteString(printerId);
139     PRINT_HILOGD("PrintServiceProxy DisconnectPrinter started.");
140     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_DISCONNECTPRINTER, data, reply, option);
141     ret = GetResult(ret, reply);
142     PRINT_HILOGD("PrintServiceProxy DisconnectPrinter out. ret = [%{public}d]", ret);
143     return ret;
144 }
145 
QueryAllExtension(std::vector<PrintExtensionInfo> & extensionInfos)146 int32_t PrintServiceProxy::QueryAllExtension(std::vector<PrintExtensionInfo> &extensionInfos)
147 {
148     MessageParcel data, reply;
149     MessageOption option;
150     data.WriteInterfaceToken(GetDescriptor());
151     PRINT_HILOGD("PrintServiceProxy QueryAllExtension started.");
152     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_QUERYALLEXTENSION, data, reply, option);
153     ret = GetResult(ret, reply);
154     if (ret != E_PRINT_NONE) {
155         PRINT_HILOGD("PrintServiceProxy QueryAllExtension Failed.");
156         return ret;
157     }
158 
159     uint32_t len = reply.ReadUint32();
160     for (uint32_t i = 0; i < len; i++) {
161         auto infoPtr = PrintExtensionInfo::Unmarshalling(reply);
162         if (infoPtr == nullptr) {
163             PRINT_HILOGE("wrong information from data");
164             return E_PRINT_GENERIC_FAILURE;
165         }
166         extensionInfos.emplace_back(*infoPtr);
167     }
168     PRINT_HILOGD("PrintServiceProxy QueryAllExtension succeeded.");
169     return E_PRINT_NONE;
170 }
171 
StartDiscoverPrinter(const std::vector<std::string> & extensionList)172 int32_t PrintServiceProxy::StartDiscoverPrinter(const std::vector<std::string> &extensionList)
173 {
174     MessageParcel data, reply;
175     MessageOption option;
176     data.WriteInterfaceToken(GetDescriptor());
177     data.WriteStringVector(extensionList);
178     PRINT_HILOGD("PrintServiceProxy StartDiscoverPrinter started.");
179     int32_t ret = Remote()->SendRequest(
180         OHOS::Print::IPrintInterfaceCode::CMD_STARTDISCOVERPRINTER, data, reply, option);
181     ret = GetResult(ret, reply);
182     PRINT_HILOGD("PrintServiceProxy StartDiscoverPrinter out. ret = [%{public}d]", ret);
183     return ret;
184 }
185 
StopDiscoverPrinter()186 int32_t PrintServiceProxy::StopDiscoverPrinter()
187 {
188     MessageParcel data, reply;
189     MessageOption option;
190     data.WriteInterfaceToken(GetDescriptor());
191     PRINT_HILOGD("PrintServiceProxy StopDiscoverPrinter started.");
192     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_STOPDISCOVERPRINTER, data, reply, option);
193     ret = GetResult(ret, reply);
194     PRINT_HILOGD("PrintServiceProxy StopDiscoverPrinter out. ret = [%{public}d]", ret);
195     return ret;
196 }
197 
StartPrintJob(const PrintJob & jobinfo)198 int32_t PrintServiceProxy::StartPrintJob(const PrintJob &jobinfo)
199 {
200     MessageParcel data, reply;
201     MessageOption option;
202 
203     data.WriteInterfaceToken(GetDescriptor());
204     jobinfo.Marshalling(data);
205     PRINT_HILOGD("PrintServiceProxy StartPrintJob started.");
206     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_STARTPRINTJOB, data, reply, option);
207     ret = GetResult(ret, reply);
208     PRINT_HILOGD("PrintServiceProxy StartPrintJob out. ret = [%{public}d]", ret);
209     return ret;
210 }
211 
CancelPrintJob(const std::string & jobId)212 int32_t PrintServiceProxy::CancelPrintJob(const std::string &jobId)
213 {
214     MessageParcel data, reply;
215     MessageOption option;
216 
217     data.WriteInterfaceToken(GetDescriptor());
218     data.WriteString(jobId);
219     PRINT_HILOGD("PrintServiceProxy CancelPrintJob started.");
220     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_CANCELPRINTJOB, data, reply, option);
221     ret = GetResult(ret, reply);
222     PRINT_HILOGD("PrintServiceProxy CancelPrintJob out. ret = [%{public}d]", ret);
223     return ret;
224 }
225 
AddPrinters(const std::vector<PrinterInfo> & printerInfos)226 int32_t PrintServiceProxy::AddPrinters(const std::vector<PrinterInfo> &printerInfos)
227 {
228     MessageParcel data, reply;
229     MessageOption option;
230     data.WriteInterfaceToken(GetDescriptor());
231     data.WriteUint32(printerInfos.size());
232     PRINT_HILOGD("AddPrinters printerInfos.size() = %{public}zu", printerInfos.size());
233     for (uint32_t i = 0; i < printerInfos.size(); i++) {
234         printerInfos[i].Marshalling(data);
235     }
236     PRINT_HILOGD("PrintServiceProxy AddPrinters started.");
237     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_ADDPRINTERS, data, reply, option);
238     ret = GetResult(ret, reply);
239     PRINT_HILOGD("PrintServiceProxy AddPrinters out. ret = [%{public}d]", ret);
240     return ret;
241 }
242 
RemovePrinters(const std::vector<std::string> & printerIds)243 int32_t PrintServiceProxy::RemovePrinters(const std::vector<std::string> &printerIds)
244 {
245     MessageParcel data, reply;
246     MessageOption option;
247     data.WriteInterfaceToken(GetDescriptor());
248     data.WriteStringVector(printerIds);
249 
250     PRINT_HILOGD("PrintServiceProxy RemovePrinters started.");
251     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_REMOVEPRINTERS, data, reply, option);
252     ret = GetResult(ret, reply);
253     PRINT_HILOGD("PrintServiceProxy RemovePrinters out. ret = [%{public}d]", ret);
254     return ret;
255 }
256 
UpdatePrinters(const std::vector<PrinterInfo> & printerInfos)257 int32_t PrintServiceProxy::UpdatePrinters(const std::vector<PrinterInfo> &printerInfos)
258 {
259     MessageParcel data, reply;
260     MessageOption option;
261     data.WriteInterfaceToken(GetDescriptor());
262     data.WriteUint32(printerInfos.size());
263     PRINT_HILOGD("UpdatePrinters printerInfos.size() = %{public}zu", printerInfos.size());
264     for (uint32_t i = 0; i < printerInfos.size(); i++) {
265         printerInfos[i].Marshalling(data);
266     }
267     PRINT_HILOGD("PrintServiceProxy UpdatePrinters started.");
268     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_UPDATEPRINTERS, data, reply, option);
269     ret = GetResult(ret, reply);
270     PRINT_HILOGD("PrintServiceProxy UpdatePrinters out. ret = [%{public}d]", ret);
271     return ret;
272 }
273 
UpdatePrinterState(const std::string & printerId,uint32_t state)274 int32_t PrintServiceProxy::UpdatePrinterState(const std::string &printerId, uint32_t state)
275 {
276     MessageParcel data, reply;
277     MessageOption option;
278     data.WriteInterfaceToken(GetDescriptor());
279     data.WriteString(printerId);
280     data.WriteUint32(state);
281     PRINT_HILOGD("PrintServiceProxy UpdatePrinterState started.");
282     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_UPDATEPRINTERSTATE, data, reply, option);
283     ret = GetResult(ret, reply);
284     PRINT_HILOGD("PrintServiceProxy UpdatePrinterState out. ret = [%{public}d]", ret);
285     return ret;
286 }
287 
UpdatePrintJobState(const std::string & jobId,uint32_t state,uint32_t subState)288 int32_t PrintServiceProxy::UpdatePrintJobState(const std::string &jobId, uint32_t state, uint32_t subState)
289 {
290     MessageParcel data, reply;
291     MessageOption option;
292     data.WriteInterfaceToken(GetDescriptor());
293     data.WriteString(jobId);
294     data.WriteUint32(state);
295     data.WriteUint32(subState);
296     PRINT_HILOGD("PrintServiceProxy UpdatePrintJobState started.");
297     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_UPDATEPRINTJOBSTATE, data, reply, option);
298     ret = GetResult(ret, reply);
299     PRINT_HILOGD("PrintServiceProxy UpdatePrintJobState out. ret = [%{public}d]", ret);
300     return ret;
301 }
302 
UpdateExtensionInfo(const std::string & extInfo)303 int32_t PrintServiceProxy::UpdateExtensionInfo(const std::string &extInfo)
304 {
305     MessageParcel data, reply;
306     MessageOption option;
307     data.WriteInterfaceToken(GetDescriptor());
308     data.WriteString(extInfo);
309     PRINT_HILOGD("PrintServiceProxy UpdateExtensionInfo started.");
310     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_UPDATEEXTENSIONINFO, data, reply, option);
311     ret = GetResult(ret, reply);
312     PRINT_HILOGD("PrintServiceProxy UpdateExtensionInfo out. ret = [%{public}d]", ret);
313     return ret;
314 }
315 
RequestPreview(const PrintJob & jobinfo,std::string & previewResult)316 int32_t PrintServiceProxy::RequestPreview(const PrintJob &jobinfo, std::string &previewResult)
317 {
318     MessageParcel data, reply;
319     MessageOption option;
320     data.WriteInterfaceToken(GetDescriptor());
321     jobinfo.Marshalling(data);
322     PRINT_HILOGD("PrintServiceProxy RequestPreview started.");
323     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_REQUESTPREVIEW, data, reply, option);
324     ret = GetResult(ret, reply);
325     previewResult = reply.ReadString();
326     PRINT_HILOGD("PrintServiceProxy RequestPreview ret = [%{public}d] previewResult = %{public}s",
327         ret, previewResult.c_str());
328     return ret;
329 }
330 
QueryPrinterCapability(const std::string & printerId)331 int32_t PrintServiceProxy::QueryPrinterCapability(const std::string &printerId)
332 {
333     MessageParcel data, reply;
334     MessageOption option;
335     data.WriteInterfaceToken(GetDescriptor());
336     data.WriteString(printerId);
337     PRINT_HILOGD("PrintServiceProxy QueryPrinterCapability started.");
338     int32_t ret = Remote()->SendRequest(
339         OHOS::Print::IPrintInterfaceCode::CMD_QUERYPRINTERCAPABILITY, data, reply, option);
340     ret = GetResult(ret, reply);
341     PRINT_HILOGD("PrintServiceProxy QueryPrinterCapability out. ret = [%{public}d]", ret);
342     return ret;
343 }
344 
QueryAllPrintJob(std::vector<PrintJob> & printJobs)345 int32_t PrintServiceProxy::QueryAllPrintJob(std::vector<PrintJob> &printJobs)
346 {
347     MessageParcel data, reply;
348     MessageOption option;
349     data.WriteInterfaceToken(GetDescriptor());
350     PRINT_HILOGD("PrintServiceProxy QueryAllPrintJob started.");
351     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_QUERYALLPRINTJOB, data, reply, option);
352     ret = GetResult(ret, reply);
353     if (ret != E_PRINT_NONE) {
354         PRINT_HILOGD("PrintServiceProxy QueryAllPrintJob Failed.");
355         return ret;
356     }
357 
358     uint32_t len = reply.ReadUint32();
359     for (uint32_t i = 0; i < len; i++) {
360         auto jobPtr = PrintJob::Unmarshalling(reply);
361         if (jobPtr == nullptr) {
362             PRINT_HILOGE("wrong printJob from data");
363             return E_PRINT_GENERIC_FAILURE;
364         }
365         printJobs.emplace_back(*jobPtr);
366     }
367     PRINT_HILOGD("PrintServiceProxy QueryAllPrintJob succeeded.");
368     return E_PRINT_NONE;
369 }
370 
QueryPrintJobById(std::string & printJobId,PrintJob & printJob)371 int32_t PrintServiceProxy::QueryPrintJobById(std::string &printJobId, PrintJob &printJob)
372 {
373     MessageParcel data, reply;
374     MessageOption option;
375     data.WriteInterfaceToken(GetDescriptor());
376     data.WriteString(printJobId);
377     PRINT_HILOGD("PrintServiceProxy QueryAllPrintJob started.");
378     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_QUERYPRINTJOBBYID, data, reply, option);
379     ret = GetResult(ret, reply);
380     auto printJobPtr = PrintJob::Unmarshalling(reply);
381     printJob = *printJobPtr;
382     PRINT_HILOGD("[QueryPrintJobById] printerId : %{public}s", printJob.GetJobId().c_str());
383     PRINT_HILOGD("PrintServiceProxy QueryPrintJobById succeeded.");
384     return ret;
385 }
386 
AddPrinterToCups(const std::string & printerUri,const std::string & printerName)387 int32_t PrintServiceProxy::AddPrinterToCups(const std::string &printerUri, const std::string &printerName)
388 {
389     MessageParcel data, reply;
390     MessageOption option;
391     data.WriteInterfaceToken(GetDescriptor());
392     data.WriteString(printerUri);
393     data.WriteString(printerName);
394     PRINT_HILOGD("PrintServiceProxy AddPrinterToCups started.");
395     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_ADDPRINTERTOCUPS, data, reply, option);
396     ret = GetResult(ret, reply);
397     PRINT_HILOGD("PrintServiceProxy AddPrinterToCups succeeded.");
398     return ret;
399 }
400 
QueryPrinterCapabilityByUri(const std::string & printerUri,PrinterCapability & printerCaps)401 int32_t PrintServiceProxy::QueryPrinterCapabilityByUri(const std::string &printerUri, PrinterCapability &printerCaps)
402 {
403     MessageParcel data, reply;
404     MessageOption option;
405     data.WriteInterfaceToken(GetDescriptor());
406     data.WriteString(printerUri);
407     PRINT_HILOGD("PrintServiceProxy QueryPrinterCapabilityByUri started.");
408     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_QUERYPRINTERCAPABILITYBYURI,
409         data, reply, option);
410     ret = GetResult(ret, reply);
411     auto printerCapsPtr = PrinterCapability::Unmarshalling(reply);
412     printerCaps = *printerCapsPtr;
413     PRINT_HILOGD("PrintServiceProxy QueryPrinterCapabilityByUri succeeded.");
414     return ret;
415 }
416 
On(const std::string taskId,const std::string & type,const sptr<IPrintCallback> & listener)417 int32_t PrintServiceProxy::On(const std::string taskId, const std::string &type, const sptr<IPrintCallback> &listener)
418 {
419     if (listener == nullptr) {
420         PRINT_HILOGE("listener is nullptr");
421         return E_PRINT_INVALID_PARAMETER;
422     }
423 
424     if (type.empty()) {
425         PRINT_HILOGE("PrintServiceProxy::On type is null.");
426         return E_PRINT_INVALID_PARAMETER;
427     }
428 
429     MessageParcel data, reply;
430     MessageOption option;
431 
432     data.WriteInterfaceToken(GetDescriptor());
433     data.WriteString(taskId);
434     data.WriteString(type);
435     data.WriteRemoteObject(listener->AsObject().GetRefPtr());
436     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_ON, data, reply, option);
437     ret = GetResult(ret, reply);
438     PRINT_HILOGD("PrintServiceProxy On out. ret = [%{public}d]", ret);
439     return ret;
440 }
441 
Off(const std::string taskId,const std::string & type)442 int32_t PrintServiceProxy::Off(const std::string taskId, const std::string &type)
443 {
444     PRINT_HILOGD("PrintServiceProxy::Off in");
445     if (type.empty()) {
446         PRINT_HILOGE("PrintServiceProxy::On type is null.");
447         return E_PRINT_INVALID_PARAMETER;
448     }
449 
450     MessageParcel data, reply;
451     MessageOption option;
452 
453     data.WriteInterfaceToken(GetDescriptor());
454     data.WriteString(taskId);
455     data.WriteString(type);
456     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_OFF, data, reply, option);
457     ret = GetResult(ret, reply);
458     PRINT_HILOGD("PrintServiceProxy Off out. ret = [%{public}d]", ret);
459     return ret;
460 }
461 
RegisterExtCallback(const std::string & extensionCID,const sptr<IPrintExtensionCallback> & listener)462 int32_t PrintServiceProxy::RegisterExtCallback(const std::string &extensionCID,
463     const sptr<IPrintExtensionCallback> &listener)
464 {
465     PRINT_HILOGD("PrintServiceProxy::RegisterExtCallback in: %{public}s", extensionCID.c_str());
466     MessageParcel data, reply;
467     MessageOption option;
468 
469     data.WriteInterfaceToken(GetDescriptor());
470     data.WriteString(extensionCID);
471     data.WriteRemoteObject(listener->AsObject().GetRefPtr());
472 
473     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_REG_EXT_CB, data, reply, option);
474     ret = GetResult(ret, reply);
475     PRINT_HILOGD("PrintServiceProxy RegisterExtCallback out. ret = [%{public}d]", ret);
476     return ret;
477 }
478 
UnregisterAllExtCallback(const std::string & extensionId)479 int32_t PrintServiceProxy::UnregisterAllExtCallback(const std::string &extensionId)
480 {
481     PRINT_HILOGD("PrintServiceProxy::UnregisterAllExtCallback in");
482     MessageParcel data, reply;
483     MessageOption option;
484     data.WriteInterfaceToken(GetDescriptor());
485     data.WriteString(extensionId);
486     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_UNREG_EXT_CB, data, reply, option);
487     ret = GetResult(ret, reply);
488     PRINT_HILOGD("PrintServiceProxy UnregisterAllExtCallback out. ret = [%{public}d]", ret);
489     return ret;
490 }
491 
LoadExtSuccess(const std::string & extensionId)492 int32_t PrintServiceProxy::LoadExtSuccess(const std::string &extensionId)
493 {
494     PRINT_HILOGD("PrintServiceProxy::LoadExtSuccess in");
495     MessageParcel data, reply;
496     MessageOption option;
497     data.WriteInterfaceToken(GetDescriptor());
498     data.WriteString(extensionId);
499     int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_LOAD_EXT, data, reply, option);
500     ret = GetResult(ret, reply);
501     PRINT_HILOGD("PrintServiceProxy LoadExtSuccess out. ret = [%{public}d]", ret);
502     return ret;
503 }
504 } // namespace OHOS::Print
505