mirror of
https://gitee.com/openharmony/print_print_fwk
synced 2024-11-27 02:50:40 +00:00
Add 0906 second code
Signed-off-by: @chuangda_1 <fangwanning@huawei.com>
This commit is contained in:
parent
7f6c4a62ce
commit
1e85cc482e
@ -1,4 +1,4 @@
|
||||
/*NotifyHandler
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef PRINT_MARGIN_H
|
||||
#define PRINT_MARGIN_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS::Print {
|
||||
class PrintMargin {
|
||||
public:
|
||||
|
@ -17,7 +17,6 @@
|
||||
#define PRINT_PAGESIZE_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS::Print {
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef PRINT_RESOLUTION_H
|
||||
#define PRINT_RESOLUTION_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS::Print {
|
||||
class PrintResolution {
|
||||
public:
|
||||
|
@ -37,242 +37,17 @@ PrintProgressNotify::~PrintProgressNotify()
|
||||
|
||||
void PrintProgressNotify::DataReadInfo(PrinterInfo &info, MessageParcel &data)
|
||||
{
|
||||
/*
|
||||
info.SetPrinterId(data.ReadUint32());
|
||||
info.SetPrinterName(data.ReadString());
|
||||
info.SetPrinterIcon(data.ReadUint32());
|
||||
info.SetPrinterState(data.ReadUint32());
|
||||
info.SetDescription(data.ReadString());
|
||||
uint32_t pageSizeLength = data.ReadUint32();
|
||||
uint32_t resolutionLength = data.ReadUint32();
|
||||
PRINT_HILOGI("OnStartDiscoverPrinter pageSizeLength = %{public}d", pageSizeLength);
|
||||
PRINT_HILOGI("OnStartDiscoverPrinter resolutionLength = %{public}d", resolutionLength);
|
||||
info.GetCapability().GetMinMargin().SetTop(data.ReadUint32());
|
||||
info.GetCapability().GetMinMargin().SetBottom(data.ReadUint32());
|
||||
info.GetCapability().GetMinMargin().SetLeft(data.ReadUint32());
|
||||
info.GetCapability().GetMinMargin().SetRight(data.ReadUint32());
|
||||
|
||||
for(uint32_t i = 0; i < pageSizeLength; i++)
|
||||
{
|
||||
PrintPageSize PrintPageSize;
|
||||
PrintPageSize.SetId(data.ReadUint32());
|
||||
PrintPageSize.SetName(data.ReadString());
|
||||
PrintPageSize.SetWidth(data.ReadUint32());
|
||||
PrintPageSize.SetHeight(data.ReadUint32());
|
||||
info.GetCapability().GetPageSize().push_back(PrintPageSize);
|
||||
PrintPageSize.Dump();
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < resolutionLength; i++)
|
||||
{
|
||||
PrintResolution PrintResolution;
|
||||
PrintResolution.SetId(data.ReadUint32());
|
||||
PrintResolution.SetHorizontalDpi(data.ReadUint32());
|
||||
PrintResolution.SetVerticalDpi(data.ReadUint32());
|
||||
info.GetCapability().GetResolution().push_back(PrintResolution);
|
||||
PrintResolution.Dump();
|
||||
}
|
||||
|
||||
info.GetCapability().SetColorMode(data.ReadUint32());
|
||||
info.GetCapability().SetDuplexMode(data.ReadUint32());
|
||||
*/
|
||||
PRINT_HILOGD("");
|
||||
}
|
||||
|
||||
void PrintProgressNotify::DataReadJob(PrintJob &job, MessageParcel &data)
|
||||
{
|
||||
/*
|
||||
uint32_t fileLength = data.ReadUint32();
|
||||
for(uint32_t i = 0; i < fileLength; i++)
|
||||
{
|
||||
job.GetFiles().push_back(data.ReadString());
|
||||
|
||||
}
|
||||
job.SetJobId(data.ReadUint32());
|
||||
job.SetPrintId(data.ReadUint32());
|
||||
job.SetJobState(data.ReadUint32());
|
||||
job.SetCopyNumber(data.ReadUint32());
|
||||
|
||||
job.GetPageRange().SetStartPage(data.ReadUint32());
|
||||
job.GetPageRange().SetEndPage(data.ReadUint32());
|
||||
uint32_t pageLength = data.ReadUint32();
|
||||
for(uint32_t i = 0; i < pageLength; i++)
|
||||
{
|
||||
job.GetPageRange().SetPages(data.ReadUint32());
|
||||
}
|
||||
|
||||
job.SetIsSequential(data.ReadUint32());
|
||||
|
||||
job.GetPageSize().SetId(data.ReadUint32());
|
||||
job.GetPageSize().SetName(data.ReadString());
|
||||
job.GetPageSize().SetWidth(data.ReadUint32());
|
||||
job.GetPageSize().SetHeight(data.ReadUint32());
|
||||
|
||||
job.SetIsLandscape(data.ReadUint32());
|
||||
job.SetColorMode(data.ReadUint32());
|
||||
job.SetDuplexMode(data.ReadUint32());
|
||||
|
||||
job.GetMargin().SetTop(data.ReadUint32());
|
||||
job.GetMargin().SetBottom(data.ReadUint32());
|
||||
job.GetMargin().SetLeft(data.ReadUint32());
|
||||
job.GetMargin().SetRight(data.ReadUint32());
|
||||
|
||||
job.GetPreview().SetResult(data.ReadString());
|
||||
job.GetPreview().GetPreviewRange().SetStartPage(data.ReadUint32());
|
||||
job.GetPreview().GetPreviewRange().SetEndPage(data.ReadUint32());
|
||||
uint32_t previewPageLength = data.ReadUint32();
|
||||
|
||||
for(uint32_t i = 0; i < previewPageLength; i++)
|
||||
{
|
||||
job.GetPreview().GetPreviewRange().SetPages(data.ReadUint32());
|
||||
}
|
||||
*/
|
||||
PRINT_HILOGD("");
|
||||
}
|
||||
|
||||
void PrintProgressNotify::WriteInfoJsObject(napi_env env, PrinterInfo info, napi_value *result)
|
||||
{
|
||||
/*
|
||||
napi_value resultPrintMargin;
|
||||
napi_create_object(env, result);
|
||||
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "printerId", info.GetPrintId());
|
||||
PrintNapiUtils::SetStringPropertyUtf8(env, *result, "printerName", info.GetPrinterName().c_str());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "printerIcon", info.GetPrinterIcon());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "printerState", info.GetPrinterState());
|
||||
PrintNapiUtils::SetStringPropertyUtf8(env, *result, "description", info.GetDescription().c_str());
|
||||
|
||||
napi_value capability;
|
||||
napi_create_object(env, &capability);
|
||||
napi_create_object(env, &resultPrintMargin);
|
||||
napi_value arrPageSize,arrResolution;
|
||||
napi_status status = napi_create_array(env, &arrPageSize);
|
||||
status = napi_create_array(env, &arrResolution);
|
||||
|
||||
PrintNapiUtils::SetUint32Property(env, capability, "colorMode", info.GetCapability().GetColorMode());
|
||||
PrintNapiUtils::SetUint32Property(env, capability, "duplexMode", info.GetCapability().GetDuplexMode());
|
||||
|
||||
PrintNapiUtils::SetUint32Property(env, resultPrintMargin, "top", info.GetCapability().GetMinMargin().GetTop());
|
||||
PrintNapiUtils::SetUint32Property(env, resultPrintMargin, "bottom",
|
||||
info.GetCapability().GetMinMargin().GetBottom()); PrintNapiUtils::SetUint32Property(env, resultPrintMargin,
|
||||
"left", info.GetCapability().GetMinMargin().GetLeft()); PrintNapiUtils::SetUint32Property(env, resultPrintMargin,
|
||||
"right", info.GetCapability().GetMinMargin().GetRight()); uint32_t printerCapabilityLength =
|
||||
info.GetCapability().GetPageSize().size();
|
||||
|
||||
for(uint32_t i = 0; i < printerCapabilityLength; i++)
|
||||
{
|
||||
napi_value resultPrinterPageSize;
|
||||
napi_create_object(env, &resultPrinterPageSize);
|
||||
PrintNapiUtils::SetUint32Property(env, resultPrinterPageSize, "id",
|
||||
info.GetCapability().GetPageSize()[i].GetId()); PrintNapiUtils::SetStringPropertyUtf8(env, resultPrinterPageSize,
|
||||
"name", info.GetCapability().GetPageSize()[i].GetName().c_str()); PrintNapiUtils::SetUint32Property(env,
|
||||
resultPrinterPageSize, "width", info.GetCapability().GetPageSize()[i].GetWidth());
|
||||
PrintNapiUtils::SetUint32Property(env, resultPrinterPageSize, "height",
|
||||
info.GetCapability().GetPageSize()[i].GetHeight()); status = napi_set_element(env, arrPageSize, i,
|
||||
resultPrinterPageSize);
|
||||
}
|
||||
|
||||
uint32_t printerCapabilityresolutionLength = info.GetCapability().GetResolution().size();
|
||||
|
||||
for(uint32_t i = 0; i < printerCapabilityresolutionLength; i++)
|
||||
{
|
||||
napi_value resultPrinterResolution;
|
||||
napi_create_object(env, &resultPrinterResolution);
|
||||
PrintNapiUtils::SetUint32Property(env, resultPrinterResolution, "id",
|
||||
info.GetCapability().GetResolution()[i].GetId()); PrintNapiUtils::SetUint32Property(env, resultPrinterResolution,
|
||||
"horizontalDpi", info.GetCapability().GetResolution()[i].GetHorizontalDpi());
|
||||
PrintNapiUtils::SetUint32Property(env, resultPrinterResolution, "verticalDpi",
|
||||
info.GetCapability().GetResolution()[i].GetVerticalDpi()); status = napi_set_element(env, arrResolution, i,
|
||||
resultPrinterResolution);
|
||||
}
|
||||
|
||||
status = napi_set_named_property(env, capability, "minMargin", resultPrintMargin);
|
||||
PRINT_HILOGD("output ---- status[%{public}d]", status);
|
||||
napi_set_named_property(env, capability, "pageSize", arrPageSize);
|
||||
napi_set_named_property(env, capability, "resolution", arrResolution);
|
||||
napi_set_named_property(env, *result, "capability", capability);
|
||||
*/
|
||||
}
|
||||
|
||||
void PrintProgressNotify::WriteJobJsObject(napi_env env, PrintJob job, napi_value *result)
|
||||
{
|
||||
/*
|
||||
napi_create_object(env, result);
|
||||
napi_value arrFiles;
|
||||
napi_status status = napi_create_array(env, &arrFiles);
|
||||
uint32_t arrFilesLength = job.GetFiles().size();
|
||||
|
||||
for(uint32_t i = 0; i < arrFilesLength; i++)
|
||||
{
|
||||
napi_value value;
|
||||
status = napi_create_string_utf8(env, job.GetFiles()[i].c_str(), NAPI_AUTO_LENGTH, &value);
|
||||
status = napi_set_element(env, arrFiles, i, value);
|
||||
}
|
||||
napi_set_named_property(env, *result, "files", arrFiles);
|
||||
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "jobId", job.GetJobId());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "printerId", job.GetPrinterId());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "jobState", job.GetJobState());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "copyNumber", job.GetCopyNumber());
|
||||
napi_value pageRange;
|
||||
napi_create_object(env, &pageRange);
|
||||
PrintNapiUtils::SetUint32Property(env, pageRange, "startPage", job.GetPageRange().GetStartPage());
|
||||
PrintNapiUtils::SetUint32Property(env, pageRange, "endPage", job.GetPageRange().GetEndPage());
|
||||
napi_value arrPages;
|
||||
status = napi_create_array(env, &arrPages);
|
||||
|
||||
uint32_t arrPagesLength = job.GetPageRange().GetPages().size();
|
||||
|
||||
for(uint32_t i = 0; i < arrPagesLength; i++)
|
||||
{
|
||||
napi_value value;
|
||||
napi_create_uint32(env, job.GetPageRange().GetPages()[i], &value);
|
||||
status = napi_set_element(env, arrPages, i, value);
|
||||
}
|
||||
napi_set_named_property(env, pageRange, "files", arrPages);
|
||||
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "isSequential", job.GetIsSequential());
|
||||
napi_value pageSize;
|
||||
napi_create_object(env, &pageSize);
|
||||
PrintNapiUtils::SetUint32Property(env, pageSize, "id", job.GetPageSize().GetId());
|
||||
PrintNapiUtils::SetStringPropertyUtf8(env, pageSize, "name", job.GetPageSize().GetName().c_str());
|
||||
PrintNapiUtils::SetUint32Property(env, pageSize, "width", job.GetPageSize().GetWidth());
|
||||
PrintNapiUtils::SetUint32Property(env, pageSize, "height", job.GetPageSize().GetHeight());
|
||||
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "isLandscape", job.GetIsLandscape());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "colorMode", job.GetColorMode());
|
||||
PrintNapiUtils::SetUint32Property(env, *result, "duplexMode", job.GetDuplexMode());
|
||||
|
||||
napi_value margin;
|
||||
napi_create_object(env, &margin);
|
||||
PrintNapiUtils::SetUint32Property(env, margin, "top", job.GetMargin().GetTop());
|
||||
PrintNapiUtils::SetUint32Property(env, margin, "bottom", job.GetMargin().GetBottom());
|
||||
PrintNapiUtils::SetUint32Property(env, margin, "left", job.GetMargin().GetLeft());
|
||||
PrintNapiUtils::SetUint32Property(env, margin, "right", job.GetMargin().GetRight());
|
||||
|
||||
napi_value preview;
|
||||
napi_create_object(env, &preview);
|
||||
PrintNapiUtils::SetStringPropertyUtf8(env, preview, "result", job.GetPreview().GetResult().c_str());
|
||||
napi_value subPageRange;
|
||||
napi_create_object(env, &subPageRange);
|
||||
PrintNapiUtils::SetUint32Property(env, subPageRange, "startPage", job.GetPageRange().GetStartPage());
|
||||
PrintNapiUtils::SetUint32Property(env, subPageRange, "endPage", job.GetPageRange().GetEndPage());
|
||||
napi_value arrPreviewPages;
|
||||
status = napi_create_array(env, &arrPreviewPages);
|
||||
uint32_t arrPreviewPagesLength = job.GetPageRange().GetPages().size();
|
||||
|
||||
for(uint32_t i = 0; i < arrPreviewPagesLength; i++)
|
||||
{
|
||||
napi_value value;
|
||||
napi_create_uint32(env, job.GetPageRange().GetPages()[i], &value);
|
||||
status = napi_set_element(env, arrPreviewPages, i, value);
|
||||
}
|
||||
napi_set_named_property(env, subPageRange, "files", arrPreviewPages);
|
||||
napi_set_named_property(env, preview, "pageRange", subPageRange);
|
||||
|
||||
napi_set_named_property(env, *result, "pageRange", pageRange);
|
||||
napi_set_named_property(env, *result, "pageSize", pageSize);
|
||||
napi_set_named_property(env, *result, "margin", margin);
|
||||
napi_set_named_property(env, *result, "preview", preview);
|
||||
*/
|
||||
PRINT_HILOGD("");
|
||||
}
|
||||
|
||||
void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
@ -305,7 +80,6 @@ void PrintProgressNotify::OnCallBack(MessageParcel &data)
|
||||
DataReadJob(job, data);
|
||||
notifyData->thirdArgv = job;
|
||||
}
|
||||
|
||||
work->data = notifyData;
|
||||
|
||||
uv_queue_work(
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "print_service_proxy.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//#include "napi/native_api.h"
|
||||
//#include "napi/native_node_api.h"
|
||||
#include "napi_inner_print.h"
|
||||
#include "napi_print_ext.h"
|
||||
#include "napi_print_task.h"
|
||||
|
@ -370,21 +370,6 @@ bool PrintServiceAbility::On(
|
||||
{
|
||||
std::string combineType = type + "-";
|
||||
PRINT_HILOGI("PrintServiceAbility::On started. type=%{public}s", combineType.c_str());
|
||||
/*auto iter = registeredListeners_.find(combineType);
|
||||
if (iter == registeredListeners_.end()) {
|
||||
std::lock_guard<std::mutex> lck(listenerMapMutex_);
|
||||
std::pair<std::string, sptr<IPrintCallback>> newObj(combineType, listener);
|
||||
const auto temp = registeredListeners_.insert(newObj);
|
||||
if (!temp.second) {
|
||||
PRINT_HILOGE("PrintServiceAbility::On insert type=%{public}s object fail.", combineType.c_str());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
std::lock_guard<std::mutex> lck(listenerMapMutex_);
|
||||
PRINT_HILOGI("PrintServiceAbility::On Replace listener.");
|
||||
registeredListeners_[combineType] = listener;
|
||||
}
|
||||
PRINT_HILOGI("PrintServiceAbility::On end.");*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -392,204 +377,28 @@ bool PrintServiceAbility::Off(const std::string &type)
|
||||
{
|
||||
std::string combineType = type + "-";
|
||||
PRINT_HILOGI("PrintServiceAbility::Off started.type=%{public}s", combineType.c_str());
|
||||
/*auto iter = registeredListeners_.find(combineType);
|
||||
if (iter != registeredListeners_.end()) {
|
||||
PRINT_HILOGE("PrintServiceAbility::Off delete type=%{public}s object message.", combineType.c_str());
|
||||
std::lock_guard<std::mutex> lck(listenerMapMutex_);
|
||||
registeredListeners_.erase(iter);
|
||||
return true;
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
void PrintServiceAbility::DataWriteInfo(PrinterInfo info, MessageParcel &data)
|
||||
{
|
||||
/*
|
||||
data.WriteString("PrinterInfo");
|
||||
data.WriteUint32(info.GetPrintId());
|
||||
data.WriteString(info.GetPrinterName());
|
||||
data.WriteUint32(info.GetPrinterIcon());
|
||||
data.WriteUint32(info.GetPrinterState());
|
||||
data.WriteString(info.GetDescription());
|
||||
info.Dump();
|
||||
uint32_t pageSizeLength = info.GetCapability().GetPageSize().size();
|
||||
uint32_t resolutionLength = info.GetCapability().GetResolution().size();
|
||||
data.WriteUint32(pageSizeLength);
|
||||
data.WriteUint32(resolutionLength);
|
||||
data.WriteUint32(info.GetCapability().GetMinMargin().GetTop());
|
||||
data.WriteUint32(info.GetCapability().GetMinMargin().GetBottom());
|
||||
data.WriteUint32(info.GetCapability().GetMinMargin().GetLeft());
|
||||
data.WriteUint32(info.GetCapability().GetMinMargin().GetRight());
|
||||
info.GetCapability().GetMinMargin().Dump();
|
||||
for(uint32_t i = 0; i < pageSizeLength; i++)
|
||||
{
|
||||
data.WriteUint32(info.GetCapability().GetPageSize()[i].GetId());
|
||||
data.WriteString(info.GetCapability().GetPageSize()[i].GetName());
|
||||
data.WriteUint32(info.GetCapability().GetPageSize()[i].GetWidth());
|
||||
data.WriteUint32(info.GetCapability().GetPageSize()[i].GetHeight());
|
||||
info.GetCapability().GetPageSize()[i].Dump();
|
||||
}
|
||||
for(uint32_t i = 0; i < resolutionLength; i++)
|
||||
{
|
||||
data.WriteUint32(info.GetCapability().GetResolution()[i].GetId());
|
||||
data.WriteUint32(info.GetCapability().GetResolution()[i].GetHorizontalDpi());
|
||||
data.WriteUint32(info.GetCapability().GetResolution()[i].GetVerticalDpi());
|
||||
info.GetCapability().GetResolution()[i].Dump();
|
||||
}
|
||||
data.WriteUint32(info.GetCapability().GetColorMode());
|
||||
data.WriteUint32(info.GetCapability().GetDuplexMode());
|
||||
info.GetCapability().Dump();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void PrintServiceAbility::NotifyPrintStateHandler(const std::string &type, uint32_t state, PrinterInfo info)
|
||||
{
|
||||
std::string combineType = type;
|
||||
PRINT_HILOGI("PrintServiceAbility::NotifyHandler combineType %{public}s [%{public}d.", combineType.c_str(), state);
|
||||
/*auto iter = registeredListeners_.find(combineType);
|
||||
if (iter != registeredListeners_.end()) {
|
||||
PRINT_HILOGE("PrintServiceAbility::NotifyHandler type=%{public}s object message.", combineType.c_str());
|
||||
MessageParcel data;
|
||||
DataWrite(info, data);
|
||||
iter->second->OnCallBack(data);
|
||||
}
|
||||
if (type == "blocked") {
|
||||
std::string notifyType = "notify-block";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWrite(info, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}
|
||||
if (type == "success") {
|
||||
std::string notifyType = "notify-success";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWrite(info, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}
|
||||
if (type == "failed") {
|
||||
std::string notifyType = "notify-success";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWrite(info, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}
|
||||
if (type == "cancelled") {
|
||||
std::string notifyType = "notify-success";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWrite(info, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void PrintServiceAbility::DataWriteJob(PrintJob job, MessageParcel &data)
|
||||
{
|
||||
/*
|
||||
data.WriteString("PrintJob");
|
||||
uint32_t fileLength = job.GetFiles().size();
|
||||
data.WriteUint32(fileLength);
|
||||
for(uint32_t i = 0; i < fileLength; i++)
|
||||
{
|
||||
data.WriteString(job.GetFiles()[i]);
|
||||
|
||||
}
|
||||
data.WriteUint32(job.GetJobId());
|
||||
data.WriteUint32(job.GetPrinterId());
|
||||
data.WriteUint32(job.GetJobState());
|
||||
data.WriteUint32(job.GetCopyNumber());
|
||||
|
||||
data.WriteUint32(job.GetPageRange().GetStartPage());
|
||||
data.WriteUint32(job.GetPageRange().GetEndPage());
|
||||
uint32_t pageLength = job.GetPageRange().GetPages().size();
|
||||
data.WriteUint32(pageLength);
|
||||
for(uint32_t i = 0; i < pageLength; i++)
|
||||
{
|
||||
data.WriteUint32(job.GetPageRange().GetPages()[i]);
|
||||
}
|
||||
|
||||
data.WriteUint32(job.GetIsSequential());
|
||||
|
||||
data.WriteUint32(job.GetPageSize().GetId());
|
||||
data.WriteString(job.GetPageSize().GetName());
|
||||
data.WriteUint32(job.GetPageSize().GetWidth());
|
||||
data.WriteUint32(job.GetPageSize().GetHeight());
|
||||
|
||||
data.WriteUint32(job.GetIsLandscape());
|
||||
data.WriteUint32(job.GetColorMode());
|
||||
data.WriteUint32(job.GetDuplexMode());
|
||||
|
||||
data.WriteUint32(job.GetMargin().GetTop());
|
||||
data.WriteUint32(job.GetMargin().GetBottom());
|
||||
data.WriteUint32(job.GetMargin().GetLeft());
|
||||
data.WriteUint32(job.GetMargin().GetRight());
|
||||
|
||||
data.WriteString(job.GetPreview().GetResult());
|
||||
data.WriteUint32(job.GetPreview().GetPreviewRange().GetStartPage());
|
||||
data.WriteUint32(job.GetPreview().GetPreviewRange().GetEndPage());
|
||||
uint32_t previewPageLength = job.GetPreview().GetPreviewRange().GetPages().size();
|
||||
data.WriteUint32(previewPageLength);
|
||||
for(uint32_t i = 0; i < previewPageLength; i++)
|
||||
{
|
||||
data.WriteUint32(job.GetPreview().GetPreviewRange().GetPages()[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void PrintServiceAbility::NotifyJobStateHandler(const std::string &type, uint32_t state, PrintJob job)
|
||||
{
|
||||
std::string combineType = type;
|
||||
PRINT_HILOGI("PrintServiceAbility::NotifyHandler combineType %{public}s [%{public}d.", combineType.c_str(), state);
|
||||
/*auto iter = registeredListeners_.find(combineType);
|
||||
if (iter != registeredListeners_.end()) {
|
||||
PRINT_HILOGE("PrintServiceAbility::NotifyHandler type=%{public}s object message.", combineType.c_str());
|
||||
MessageParcel data;
|
||||
DataWriteJob(job, data);
|
||||
iter->second->OnCallBack(data);
|
||||
}
|
||||
if (type == "blocked") {
|
||||
std::string notifyType = "notify-block";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWriteJob(job, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}
|
||||
if (type == "success") {
|
||||
std::string notifyType = "notify-success";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWriteJob(job, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}
|
||||
if (type == "failed") {
|
||||
std::string notifyType = "notify-success";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWriteJob(job, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}
|
||||
if (type == "cancelled") {
|
||||
std::string notifyType = "notify-success";
|
||||
auto iter2 = registeredListeners_.find(notifyType);
|
||||
if (iter2 != registeredListeners_.end()) {
|
||||
MessageParcel data;
|
||||
DataWriteJob(job, data);
|
||||
iter2->second->OnCallBack(data);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
} // namespace OHOS::Print
|
||||
|
@ -15,16 +15,11 @@
|
||||
|
||||
#include "print_service_manager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <errno.h>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <new>
|
||||
#include <queue>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -302,39 +302,6 @@ bool PrintServiceStub::OnQueryPrinterCapability(MessageParcel &data, MessageParc
|
||||
PrinterCapability printerCapability;
|
||||
bool result = QueryPrinterCapability(data.ReadUint32(), printerCapability);
|
||||
printerCapability.ConvertToParcel(reply);
|
||||
/*
|
||||
std::vector<PrintPageSize> pageSizeList;
|
||||
std::vector<PrintResolution> resolutionList;
|
||||
|
||||
printerCapability.GetPageSize(pageSizeList);
|
||||
printerCapability.GetResolution(resolutionList);
|
||||
uint32_t arraypageSizeLength = pageSizeList.size();
|
||||
reply.WriteUint32(arraypageSizeLength);
|
||||
uint32_t resolutionLength = resolutionList.size();
|
||||
reply.WriteUint32(resolutionLength);
|
||||
|
||||
PrintMargin minMargin;
|
||||
printerCapability.GetMinMargin(minMargin);
|
||||
reply.WriteUint32(minMargin.GetTop());
|
||||
reply.WriteUint32(minMargin.GetBottom());
|
||||
reply.WriteUint32(minMargin.GetLeft());
|
||||
reply.WriteUint32(minMargin.GetRight());
|
||||
|
||||
for(uint32_t i = 0; i < arraypageSizeLength; i++) {
|
||||
reply.WriteString(pageSizeList[i].GetId());
|
||||
reply.WriteString(pageSizeList[i].GetName());
|
||||
reply.WriteUint32(pageSizeList[i].GetWidth());
|
||||
reply.WriteUint32(pageSizeList[i].GetHeight());
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < resolutionLength; i++) {
|
||||
reply.WriteUint32(resolutionList[i].GetId());
|
||||
reply.WriteUint32(resolutionList[i].GetHorizontalDpi());
|
||||
reply.WriteUint32(resolutionList[i].GetVerticalDpi());
|
||||
}
|
||||
|
||||
reply.WriteUint32(printerCapability.GetColorMode());
|
||||
reply.WriteUint32(printerCapability.GetDuplexMode());*/
|
||||
if (!reply.WriteBool(result)) {
|
||||
PRINT_HILOGD("WriteBool failed");
|
||||
return false;
|
||||
@ -363,26 +330,6 @@ bool PrintServiceStub::OnEventOn(MessageParcel &data, MessageParcel &reply)
|
||||
PRINT_HILOGE("PrintServiceStub::OnEventOn type is null.");
|
||||
return false;
|
||||
}
|
||||
/*sptr<IRemoteObject> remote = data.ReadRemoteObject();
|
||||
if (remote == nullptr) {
|
||||
PRINT_HILOGD("PrintServiceStub::OnEventOn remote is nullptr");
|
||||
if (!reply.WriteInt32(ERR_NONE)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
sptr<IPrintCallback> listener = iface_cast<IPrintCallback>(remote);
|
||||
if (listener.GetRefPtr() == nullptr) {
|
||||
PRINT_HILOGD("PrintServiceStub::OnEventOn listener is null");
|
||||
return false;
|
||||
}
|
||||
PrinterInfo info;
|
||||
bool result = On(type, 2, info, listener);
|
||||
if (!reply.WriteBool(result)) {
|
||||
PRINT_HILOGD("PrintServiceStub::OnEventOn 4444");
|
||||
return false;
|
||||
}
|
||||
PRINT_HILOGD("PrintServiceStub::OnEventOn out");*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -466,54 +413,43 @@ void PrintServiceStub::MakePrintJob(MessageParcel &data, PrintJob &printJob)
|
||||
printJob.SetPrintId(data.ReadUint32());
|
||||
printJob.SetJobState(data.ReadUint32());
|
||||
printJob.SetCopyNumber(data.ReadUint32());
|
||||
|
||||
PrintRange range;
|
||||
range.SetStartPage(data.ReadUint32());
|
||||
range.SetEndPage(data.ReadUint32());
|
||||
uint32_t pageLength = data.ReadUint32();
|
||||
if (pageLength > 0) {
|
||||
std::vector<uint32_t> rangePages;
|
||||
for (index = 0; index < pageLength; index++) {
|
||||
rangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(rangePages);
|
||||
std::vector<uint32_t> rangePages;
|
||||
for (index = 0; index < pageLength; index++) {
|
||||
rangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(rangePages);
|
||||
printJob.SetPageRange(range);
|
||||
|
||||
printJob.SetIsSequential(data.ReadUint32());
|
||||
|
||||
PrintPageSize pageSize;
|
||||
pageSize.SetId(data.ReadString());
|
||||
pageSize.SetName(data.ReadString());
|
||||
pageSize.SetWidth(data.ReadUint32());
|
||||
pageSize.SetHeight(data.ReadUint32());
|
||||
printJob.SetPageSize(pageSize);
|
||||
|
||||
printJob.SetIsLandscape(data.ReadUint32());
|
||||
printJob.SetColorMode(data.ReadUint32());
|
||||
printJob.SetDuplexMode(data.ReadUint32());
|
||||
|
||||
PrintMargin minMargin;
|
||||
minMargin.SetTop(data.ReadUint32());
|
||||
minMargin.SetBottom(data.ReadUint32());
|
||||
minMargin.SetLeft(data.ReadUint32());
|
||||
minMargin.SetRight(data.ReadUint32());
|
||||
printJob.SetMargin(minMargin);
|
||||
|
||||
PreviewAttribute previewAttr;
|
||||
|
||||
previewAttr.SetResult(data.ReadString());
|
||||
range.Reset();
|
||||
range.SetStartPage(data.ReadUint32());
|
||||
range.SetEndPage(data.ReadUint32());
|
||||
uint32_t previewPageLength = data.ReadUint32();
|
||||
if (previewPageLength > 0) {
|
||||
std::vector<uint32_t> previewRangePages;
|
||||
for (index = 0; index < previewPageLength; index++) {
|
||||
previewRangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(previewRangePages);
|
||||
std::vector<uint32_t> previewRangePages;
|
||||
for (index = 0; index < previewPageLength; index++) {
|
||||
previewRangePages.push_back(data.ReadUint32());
|
||||
}
|
||||
range.SetPages(previewRangePages);
|
||||
previewAttr.SetPreviewRange(range);
|
||||
printJob.SetPreview(previewAttr);
|
||||
}
|
||||
@ -568,5 +504,4 @@ void PrintServiceStub::MakePrinterInfo(MessageParcel &data, PrinterInfo &printer
|
||||
printerInfo.SetCapability(cap);
|
||||
printerInfo.Dump();
|
||||
}
|
||||
|
||||
} // namespace OHOS::Print
|
||||
|
@ -17,27 +17,24 @@
|
||||
#define PRINT_CONSTANT_H
|
||||
|
||||
namespace OHOS::Print {
|
||||
|
||||
enum PrinterState {
|
||||
PRINTER_ADD = 1, // new printers arrival
|
||||
PRINTER_REMOVED = 2, // printers lost
|
||||
PRINTER_IDLE = 3, // printer idle
|
||||
PRINTER_ADD = 1, // new printers arrival
|
||||
PRINTER_REMOVED = 2, // printers lost
|
||||
PRINTER_IDLE = 3, // printer idle
|
||||
PRINTER_PRINTING = 4, // printer is working
|
||||
PRINTER_BLOCK = 5, // printer has been blocked
|
||||
PRINTER_BUSY = 6, // printer is busy
|
||||
PRINTER_FAULT = 7, // printer failure
|
||||
PRINTER_BLOCK = 5, // printer has been blocked
|
||||
PRINTER_BUSY = 6, // printer is busy
|
||||
PRINTER_FAULT = 7, // printer failure
|
||||
PRINTER_UNKNOWN,
|
||||
};
|
||||
|
||||
enum PrintJobState {
|
||||
PRINT_JOB_INIT = 1, // initial state of print job
|
||||
PRINT_JOB_START = 2, // start print job
|
||||
PRINT_JOB_PRINTING = 3, // printing
|
||||
PRINT_JOB_BLOCK = 4, // print job has been blocked
|
||||
PRINT_JOB_COMPLETE = 5, // print completed
|
||||
PRINT_JOB_CANCEL = 6, // print job has been cancelled
|
||||
PRINT_JOB_INIT = 1, // initial state of print job
|
||||
PRINT_JOB_START = 2, // start print job
|
||||
PRINT_JOB_PRINTING = 3, // printing
|
||||
PRINT_JOB_BLOCK = 4, // print job has been blocked
|
||||
PRINT_JOB_COMPLETE = 5, // print completed
|
||||
PRINT_JOB_CANCEL = 6, // print job has been cancelled
|
||||
};
|
||||
|
||||
} // namespace OHOS::Print
|
||||
|
||||
#endif // PRINT_CONSTANT_H
|
Loading…
Reference in New Issue
Block a user