mirror of
https://gitee.com/openharmony/print_print_fwk
synced 2024-11-23 08:59:47 +00:00
commit
95d872cfa8
@ -76,17 +76,31 @@ static constexpr const char *FUNCTION_UPDATE_PRINTER_IN_SYSTEM = "updatePrinterI
|
||||
|
||||
static void SetEnumProperty(napi_env env, napi_value object, const std::string &name, uint32_t value)
|
||||
{
|
||||
napi_value tempValue = nullptr;
|
||||
if (napi_create_int32(env, value, &tempValue) != napi_ok) {
|
||||
if (name.empty()) {
|
||||
PRINT_HILOGE("Property name cannot be an empty string");
|
||||
return;
|
||||
}
|
||||
napi_value tempValue = nullptr;
|
||||
napi_status status = napi_create_int32(env, value, &tempValue);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create int32 value for enum %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
status = napi_set_named_property(env, object, name.c_str(), tempValue);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to set property %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
napi_set_named_property(env, object, name.c_str(), tempValue);
|
||||
}
|
||||
|
||||
static napi_value NapiCreateDirectionModeEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "DIRECTION_MODE_AUTO", static_cast<int32_t>(DIRECTION_MODE_AUTO));
|
||||
SetEnumProperty(env, object, "DIRECTION_MODE_PORTRAIT", static_cast<int32_t>(DIRECTION_MODE_PORTRAIT));
|
||||
SetEnumProperty(env, object, "DIRECTION_MODE_LANDSCAPE", static_cast<int32_t>(DIRECTION_MODE_LANDSCAPE));
|
||||
@ -96,7 +110,11 @@ static napi_value NapiCreateDirectionModeEnum(napi_env env)
|
||||
static napi_value NapiCreateColorModeEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "COLOR_MODE_MONOCHROME", static_cast<int32_t>(PRINT_COLOR_MODE_MONOCHROME));
|
||||
SetEnumProperty(env, object, "COLOR_MODE_COLOR", static_cast<int32_t>(PRINT_COLOR_MODE_COLOR));
|
||||
return object;
|
||||
@ -105,7 +123,11 @@ static napi_value NapiCreateColorModeEnum(napi_env env)
|
||||
static napi_value NapiCreateDuplexModeEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "DUPLEX_MODE_NONE", static_cast<int32_t>(DUPLEX_MODE_NONE));
|
||||
SetEnumProperty(env, object, "DUPLEX_MODE_LONG_EDGE", static_cast<int32_t>(DUPLEX_MODE_LONG_EDGE));
|
||||
SetEnumProperty(env, object, "DUPLEX_MODE_SHORT_EDGE", static_cast<int32_t>(DUPLEX_MODE_SHORT_EDGE));
|
||||
@ -115,7 +137,11 @@ static napi_value NapiCreateDuplexModeEnum(napi_env env)
|
||||
static napi_value NapiCreateQualityEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "QUALITY_DRAFT", static_cast<int32_t>(PRINT_QUALITY_DRAFT));
|
||||
SetEnumProperty(env, object, "QUALITY_NORMAL", static_cast<int32_t>(PRINT_QUALITY_NORMAL));
|
||||
SetEnumProperty(env, object, "QUALITY_HIGH", static_cast<int32_t>(PRINT_QUALITY_HIGH));
|
||||
@ -125,7 +151,11 @@ static napi_value NapiCreateQualityEnum(napi_env env)
|
||||
static napi_value NapiCreatePageTypeEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PAGE_ISO_A3", static_cast<int32_t>(PAGE_ISO_A3));
|
||||
SetEnumProperty(env, object, "PAGE_ISO_A4", static_cast<int32_t>(PAGE_ISO_A4));
|
||||
SetEnumProperty(env, object, "PAGE_ISO_A5", static_cast<int32_t>(PAGE_ISO_A5));
|
||||
@ -144,7 +174,11 @@ static napi_value NapiCreatePageTypeEnum(napi_env env)
|
||||
static napi_value NapiCreateDocumentAdapterStateEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PREVIEW_DESTROY", static_cast<int32_t>(PREVIEW_ABILITY_DESTROY));
|
||||
SetEnumProperty(env, object, "PRINT_TASK_SUCCEED", static_cast<int32_t>(PRINT_TASK_SUCCEED));
|
||||
SetEnumProperty(env, object, "PRINT_TASK_FAIL", static_cast<int32_t>(PRINT_TASK_FAIL));
|
||||
@ -156,7 +190,11 @@ static napi_value NapiCreateDocumentAdapterStateEnum(napi_env env)
|
||||
static napi_value NapiCreateFileCreationStateEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PRINT_FILE_CREATED", static_cast<int32_t>(PRINT_FILE_CREATED_SUCCESS));
|
||||
SetEnumProperty(env, object, "PRINT_FILE_CREATION_FAILED", static_cast<int32_t>(PRINT_FILE_CREATED_FAIL));
|
||||
SetEnumProperty(env, object, "PRINT_FILE_CREATED_UNRENDERED",
|
||||
@ -167,7 +205,11 @@ static napi_value NapiCreateFileCreationStateEnum(napi_env env)
|
||||
static napi_value NapiCreatePrinterStateEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PRINTER_ADDED", static_cast<int32_t>(PRINTER_ADDED));
|
||||
SetEnumProperty(env, object, "PRINTER_REMOVED", static_cast<int32_t>(PRINTER_REMOVED));
|
||||
SetEnumProperty(env, object, "PRINTER_CAPABILITY_UPDATED", static_cast<int32_t>(PRINTER_UPDATE_CAP));
|
||||
@ -180,7 +222,11 @@ static napi_value NapiCreatePrinterStateEnum(napi_env env)
|
||||
static napi_value NapiCreatePrintJobStateEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PRINT_JOB_PREPARE", static_cast<int32_t>(PRINT_JOB_PREPARED));
|
||||
SetEnumProperty(env, object, "PRINT_JOB_QUEUED", static_cast<int32_t>(PRINT_JOB_QUEUED));
|
||||
SetEnumProperty(env, object, "PRINT_JOB_RUNNING", static_cast<int32_t>(PRINT_JOB_RUNNING));
|
||||
@ -192,7 +238,10 @@ static napi_value NapiCreatePrintJobStateEnum(napi_env env)
|
||||
static napi_value NapiCreatePrintJobSubStateEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (napi_create_object(env, &object) != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PRINT_JOB_COMPLETED_SUCCESS", static_cast<int32_t>(PRINT_JOB_COMPLETED_SUCCESS));
|
||||
SetEnumProperty(env, object, "PRINT_JOB_COMPLETED_FAILED", static_cast<int32_t>(PRINT_JOB_COMPLETED_FAILED));
|
||||
SetEnumProperty(env, object, "PRINT_JOB_COMPLETED_CANCELLED", static_cast<int32_t>(PRINT_JOB_COMPLETED_CANCELLED));
|
||||
@ -241,7 +290,11 @@ static napi_value NapiCreatePrintJobSubStateEnum(napi_env env)
|
||||
static napi_value NapiCreatePrintErrorCodeEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "E_PRINT_NONE", static_cast<int32_t>(E_PRINT_NONE));
|
||||
SetEnumProperty(env, object, "E_PRINT_NO_PERMISSION", static_cast<int32_t>(E_PRINT_NO_PERMISSION));
|
||||
SetEnumProperty(env, object, "E_PRINT_INVALID_PARAMETER", static_cast<int32_t>(E_PRINT_INVALID_PARAMETER));
|
||||
@ -258,7 +311,11 @@ static napi_value NapiCreatePrintErrorCodeEnum(napi_env env)
|
||||
static napi_value NapiCreatePrintStatusEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PRINTER_STATUS_IDLE", static_cast<int32_t>(PRINTER_STATUS_IDLE));
|
||||
SetEnumProperty(env, object, "PRINTER_STATUS_BUSY", static_cast<int32_t>(PRINTER_STATUS_BUSY));
|
||||
SetEnumProperty(env, object, "PRINTER_STATUS_UNAVAILABLE", static_cast<int32_t>(PRINTER_STATUS_UNAVAILABLE));
|
||||
@ -268,7 +325,11 @@ static napi_value NapiCreatePrintStatusEnum(napi_env env)
|
||||
static napi_value NapiCreatePrintEventEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "PRINTER_EVENT_ADDED", static_cast<int32_t>(PRINTER_EVENT_ADDED));
|
||||
SetEnumProperty(env, object, "PRINTER_EVENT_DELETED", static_cast<int32_t>(PRINTER_EVENT_DELETED));
|
||||
SetEnumProperty(env, object, "PRINTER_EVENT_STATE_CHANGED", static_cast<int32_t>(PRINTER_EVENT_STATE_CHANGED));
|
||||
@ -279,7 +340,11 @@ static napi_value NapiCreatePrintEventEnum(napi_env env)
|
||||
static napi_value NapiCreateApplicationEventEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(env, object, "APPLICATION_CREATED", static_cast<int32_t>(APPLICATION_CREATED));
|
||||
SetEnumProperty(
|
||||
env, object, "APPLICATION_CLOSED_FOR_STARTED", static_cast<int32_t>(APPLICATION_CLOSED_FOR_STARTED));
|
||||
@ -291,7 +356,11 @@ static napi_value NapiCreateApplicationEventEnum(napi_env env)
|
||||
static napi_value NapiCreateDefaultPrinterTypeEnum(napi_env env)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
napi_status status = napi_create_object(env, &object);
|
||||
if (status != napi_ok) {
|
||||
PRINT_HILOGE("Failed to create object");
|
||||
return nullptr;
|
||||
}
|
||||
SetEnumProperty(
|
||||
env, object, "DEFAULT_PRINTER_TYPE_SETTED_BY_USER", static_cast<int32_t>(DEFAULT_PRINTER_TYPE_SETTED_BY_USER));
|
||||
SetEnumProperty(env,
|
||||
|
@ -32,6 +32,10 @@ VendorDriverBase::~VendorDriverBase() {}
|
||||
|
||||
bool VendorDriverBase::Init(IPrinterVendorManager *manager)
|
||||
{
|
||||
if (manager == nullptr) {
|
||||
PRINT_HILOGE("manager is a nullptr.");
|
||||
return false;
|
||||
}
|
||||
vendorManager = manager;
|
||||
return true;
|
||||
}
|
||||
|
@ -1966,7 +1966,7 @@ std::string ScanServiceAbility::ObtainUserCacheDirectory(const int32_t& userId)
|
||||
return "";
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << "/data/service/el2" << userId << "/print_service";
|
||||
oss << "/data/service/el2/" << userId << "/print_service";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user