测试子系统Tscan告警修改+api整改 Signed-off-by:baozewei@huawei.com

Signed-off-by: 18903078203 <baozewei@huawei.com>
This commit is contained in:
18903078203 2023-11-21 17:23:02 +08:00
parent 8617e32266
commit 8976836c19
6 changed files with 37 additions and 25 deletions

View File

@ -378,6 +378,10 @@ int32_t PrintServiceProxy::QueryPrintJobById(std::string &printJobId, PrintJob &
int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_QUERYPRINTJOBBYID, data, reply, option); int32_t ret = Remote()->SendRequest(OHOS::Print::IPrintInterfaceCode::CMD_QUERYPRINTJOBBYID, data, reply, option);
ret = GetResult(ret, reply); ret = GetResult(ret, reply);
auto printJobPtr = PrintJob::Unmarshalling(reply); auto printJobPtr = PrintJob::Unmarshalling(reply);
if (printJobPtr == nullptr) {
PRINT_HILOGE("wrong printJob from data");
return E_PRINT_GENERIC_FAILURE;
}
printJob = *printJobPtr; printJob = *printJobPtr;
PRINT_HILOGD("[QueryPrintJobById] printerId : %{public}s", printJob.GetJobId().c_str()); PRINT_HILOGD("[QueryPrintJobById] printerId : %{public}s", printJob.GetJobId().c_str());
PRINT_HILOGD("PrintServiceProxy QueryPrintJobById succeeded."); PRINT_HILOGD("PrintServiceProxy QueryPrintJobById succeeded.");

View File

@ -186,6 +186,7 @@ declare namespace print {
jobId: string; // job id jobId: string; // job id
printerId: string; // printer id to take charge of printing printerId: string; // printer id to take charge of printing
jobState: PrintJobState; // current print job state jobState: PrintJobState; // current print job state
jobSubstate: PrintJobSubState; // current print job sub state.
copyNumber: number; // copies of document list copyNumber: number; // copies of document list
pageRange: PrinterRange; // range size to be printed pageRange: PrinterRange; // range size to be printed
isSequential: boolean; // sequential print isSequential: boolean; // sequential print
@ -237,10 +238,10 @@ declare namespace print {
PRINT_JOB_BLOCK_PRINT_PERMISSION_ERROR = 19, // The printing permission is abnormal. PRINT_JOB_BLOCK_PRINT_PERMISSION_ERROR = 19, // The printing permission is abnormal.
PRINT_JOB_BLOCK_PRINT_COLOR_PERMISSION_ERROR = 20, // Color printing permission exception PRINT_JOB_BLOCK_PRINT_COLOR_PERMISSION_ERROR = 20, // Color printing permission exception
PRINT_JOB_BLOCK_NETWORK_ERROR = 21, // The device is not connected to the network. PRINT_JOB_BLOCK_NETWORK_ERROR = 21, // The device is not connected to the network.
PRINT_JOB_BLOCK_CONNECT_SERVER_ERROR = 22, // Unable to connect to the server PRINT_JOB_BLOCK_SERVER_CONNECTION_ERROR = 22, // Unable to connect to the server
PRINT_JOB_BLOCK_LARGE_FILE_ERROR = 23, // Large file exception PRINT_JOB_BLOCK_LARGE_FILE_ERROR = 23, // Large file exception
PRINT_JOB_BLOCK_PARSE_FILE_ERROR = 24, // File parsing exception. PRINT_JOB_BLOCK_FILE_PARSING_ERROR = 24, // File parsing exception.
PRINT_JOB_BLOCK_FILE_CONVERT_SLOWLY = 25, // The file conversion is too slow. PRINT_JOB_BLOCK_SLOW_FILE_CONVERSION = 25, // The file conversion is too slow.
PRINT_JOB_RUNNING_UPLOADING_FILES = 26, // Uploading file... PRINT_JOB_RUNNING_UPLOADING_FILES = 26, // Uploading file...
PRINT_JOB_RUNNING_CONVERTING_FILES = 27, // Converting files... PRINT_JOB_RUNNING_CONVERTING_FILES = 27, // Converting files...

View File

@ -80,7 +80,7 @@ napi_value PrintAsyncCall::SyncCall(napi_env env, PrintAsyncCall::Context::ExecA
context_->ctx->exec_ = std::move(exec); context_->ctx->exec_ = std::move(exec);
} }
napi_value promise = nullptr; napi_value promise = nullptr;
if (context_->callback == nullptr) { if (context_ != nullptr && context_->callback == nullptr) {
napi_create_promise(env, &context_->defer, &promise); napi_create_promise(env, &context_->defer, &promise);
} else { } else {
napi_get_undefined(env, &promise); napi_get_undefined(env, &promise);
@ -131,7 +131,11 @@ void PrintAsyncCall::OnComplete(napi_env env, napi_status status, void *data)
if (context->paramStatus != napi_ok) { if (context->paramStatus != napi_ok) {
errorIndex = E_PRINT_INVALID_PARAMETER; errorIndex = E_PRINT_INVALID_PARAMETER;
} else { } else {
errorIndex = context->ctx->GetErrorIndex(); if (context->ctx == nullptr) {
errorIndex = E_PRINT_GENERIC_FAILURE;
} else {
errorIndex = context->ctx->GetErrorIndex();
}
} }
PRINT_HILOGE("ErrorMessage: [%{public}s], ErrorIndex:[%{public}d]", PRINT_HILOGE("ErrorMessage: [%{public}s], ErrorIndex:[%{public}d]",
GetErrorText(errorIndex).c_str(), errorIndex); GetErrorText(errorIndex).c_str(), errorIndex);

View File

@ -38,6 +38,7 @@ static constexpr const char *FUNCTION_CANCEL_PRINT = "cancelPrintJob";
static constexpr const char *FUNCTION_REQUEST_PREVIEW = "requestPrintPreview"; static constexpr const char *FUNCTION_REQUEST_PREVIEW = "requestPrintPreview";
static constexpr const char *FUNCTION_QUERY_CAPABILITY = "queryPrinterCapability"; static constexpr const char *FUNCTION_QUERY_CAPABILITY = "queryPrinterCapability";
static constexpr const char *FUNCTION_QUERY_ALL_PRINTJOB = "queryAllPrintJobs"; static constexpr const char *FUNCTION_QUERY_ALL_PRINTJOB = "queryAllPrintJobs";
static constexpr const char *FUNCTION_QUERY_PRINTJOB_LIST = "queryPrintJobList";
static constexpr const char *FUNCTION_QUERY_PRINTJOB_BYID = "queryPrintJobById"; static constexpr const char *FUNCTION_QUERY_PRINTJOB_BYID = "queryPrintJobById";
static constexpr const char *FUNCTION_REGISTER_EVENT = "on"; static constexpr const char *FUNCTION_REGISTER_EVENT = "on";
static constexpr const char *FUNCTION_UNREGISTER_EVENT = "off"; static constexpr const char *FUNCTION_UNREGISTER_EVENT = "off";
@ -86,10 +87,10 @@ static constexpr const char *PROPERTY_BLOCK_ACCOUNT_ERROR = "PRINT_BLOCK_ACCOUNT
static constexpr const char *PROPERTY_BLOCK_PRINT_PERMISSION_ERROR = "PRINT_JOB_BLOCK_PRINT_PERMISSION_ERROR"; static constexpr const char *PROPERTY_BLOCK_PRINT_PERMISSION_ERROR = "PRINT_JOB_BLOCK_PRINT_PERMISSION_ERROR";
static constexpr const char *PROPERTY_BLOCK_PRINT_COLOR_PERMISSION_ERROR = "PRINT_JOB_BLOCK_PRINT_COLOR_PERMISSION_ERROR"; static constexpr const char *PROPERTY_BLOCK_PRINT_COLOR_PERMISSION_ERROR = "PRINT_JOB_BLOCK_PRINT_COLOR_PERMISSION_ERROR";
static constexpr const char *PROPERTY_BLOCK_NETWORK_ERROR = "PRINT_JOB_BLOCK_NETWORK_ERROR"; static constexpr const char *PROPERTY_BLOCK_NETWORK_ERROR = "PRINT_JOB_BLOCK_NETWORK_ERROR";
static constexpr const char *PROPERTY_BLOCK_CONNECT_SERVER_ERROR = "PRINT_JOB_BLOCK_CONNECT_SERVER_ERROR"; static constexpr const char *PROPERTY_BLOCK_SERVER_CONNECTION_ERROR = "PRINT_JOB_BLOCK_CONNECT_SERVER_ERROR";
static constexpr const char *PROPERTY_BLOCK_LARGE_FILE_ERROR = "PRINT_JOB_BLOCK_LARGE_FILE_ERROR"; static constexpr const char *PROPERTY_BLOCK_LARGE_FILE_ERROR = "PRINT_JOB_BLOCK_LARGE_FILE_ERROR";
static constexpr const char *PROPERTY_BLOCK_PARSE_FILE_ERROR = "PRINT_JOB_BLOCK_PARSE_FILE_ERROR"; static constexpr const char *PROPERTY_BLOCK_FILE_PARSING_ERROR = "PRINT_JOB_BLOCK_PARSE_FILE_ERROR";
static constexpr const char *PROPERTY_BLOCK_FILE_CONVERT_SLOWLY = "PRINT_JOB_BLOCK_FILE_CONVERT_SLOWLY"; static constexpr const char *PROPERTY_BLOCK_SLOW_FILE_CONVERSION = "PRINT_JOB_BLOCK_FILE_CONVERT_SLOWLY";
static constexpr const char *PROPERTY_RUNNING_UPLOADING_FILES = "PRINT_JOB_RUNNING_UPLOADING_FILES"; static constexpr const char *PROPERTY_RUNNING_UPLOADING_FILES = "PRINT_JOB_RUNNING_UPLOADING_FILES";
static constexpr const char *PROPERTY_RUNNING_CONVERTING_FILES = "PRINT_JOB_RUNNING_CONVERTING_FILES"; static constexpr const char *PROPERTY_RUNNING_CONVERTING_FILES = "PRINT_JOB_RUNNING_CONVERTING_FILES";
static constexpr const char *PROPERTY_BLOCK_UNKNOWN = "PRINT_JOB_BLOCK_UNKNOWN"; static constexpr const char *PROPERTY_BLOCK_UNKNOWN = "PRINT_JOB_BLOCK_UNKNOWN";
@ -139,10 +140,10 @@ static napi_value block_account_error = nullptr;
static napi_value block_print_permission_error = nullptr; static napi_value block_print_permission_error = nullptr;
static napi_value block_print_color_permission_error = nullptr; static napi_value block_print_color_permission_error = nullptr;
static napi_value block_network_error = nullptr; static napi_value block_network_error = nullptr;
static napi_value block_connect_server_error = nullptr; static napi_value block_server_connection_error = nullptr;
static napi_value block_large_file_error = nullptr; static napi_value block_large_file_error = nullptr;
static napi_value block_parse_file_error = nullptr; static napi_value block_file_parsing_error = nullptr;
static napi_value block_file_convert_slowly = nullptr; static napi_value block_slow_file_conversion = nullptr;
static napi_value running_uploading_files = nullptr; static napi_value running_uploading_files = nullptr;
static napi_value running_converting_files = nullptr; static napi_value running_converting_files = nullptr;
static napi_value block_unknown = nullptr; static napi_value block_unknown = nullptr;
@ -207,10 +208,11 @@ static void NapiCreateEnum(napi_env env)
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_PRINT_PERMISSION_ERROR), &block_print_permission_error); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_PRINT_PERMISSION_ERROR), &block_print_permission_error);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_PRINT_COLOR_PERMISSION_ERROR), &block_print_color_permission_error); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_PRINT_COLOR_PERMISSION_ERROR), &block_print_color_permission_error);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_NETWORK_ERROR), &block_network_error); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_NETWORK_ERROR), &block_network_error);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_CONNECT_SERVER_ERROR), &block_connect_server_error); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_SERVER_CONNECTION_ERROR),
&block_server_connection_error);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_LARGE_FILE_ERROR), &block_large_file_error); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_LARGE_FILE_ERROR), &block_large_file_error);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_PARSE_FILE_ERROR), &block_parse_file_error); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_FILE_PARSING_ERROR), &block_file_parsing_error);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_FILE_CONVERT_SLOWLY), &block_file_convert_slowly); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_SLOW_FILE_CONVERSION), &block_slow_file_conversion);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_RUNNING_UPLOADING_FILES), &running_uploading_files); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_RUNNING_UPLOADING_FILES), &running_uploading_files);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_RUNNING_CONVERTING_FILES), &running_converting_files); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_RUNNING_CONVERTING_FILES), &running_converting_files);
napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_UNKNOWN), &block_unknown); napi_create_int32(env, static_cast<int32_t>(PRINT_JOB_BLOCKED_UNKNOWN), &block_unknown);
@ -266,10 +268,10 @@ static napi_value Init(napi_env env, napi_value exports)
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_PRINT_PERMISSION_ERROR, block_print_permission_error), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_PRINT_PERMISSION_ERROR, block_print_permission_error),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_PRINT_COLOR_PERMISSION_ERROR, block_print_color_permission_error), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_PRINT_COLOR_PERMISSION_ERROR, block_print_color_permission_error),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_NETWORK_ERROR, block_network_error), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_NETWORK_ERROR, block_network_error),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_CONNECT_SERVER_ERROR, block_connect_server_error), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_SERVER_CONNECTION_ERROR, block_server_connection_error),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_LARGE_FILE_ERROR, block_large_file_error), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_LARGE_FILE_ERROR, block_large_file_error),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_PARSE_FILE_ERROR, block_parse_file_error), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_FILE_PARSING_ERROR, block_file_parsing_error),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_FILE_CONVERT_SLOWLY, block_file_convert_slowly), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_SLOW_FILE_CONVERSION, block_slow_file_conversion),
PRINT_NAPI_PROPERTY(PROPERTY_RUNNING_UPLOADING_FILES, running_uploading_files), PRINT_NAPI_PROPERTY(PROPERTY_RUNNING_UPLOADING_FILES, running_uploading_files),
PRINT_NAPI_PROPERTY(PROPERTY_RUNNING_CONVERTING_FILES, running_converting_files), PRINT_NAPI_PROPERTY(PROPERTY_RUNNING_CONVERTING_FILES, running_converting_files),
PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_UNKNOWN, block_unknown), PRINT_NAPI_PROPERTY(PROPERTY_BLOCK_UNKNOWN, block_unknown),
@ -297,6 +299,7 @@ static napi_value Init(napi_env env, napi_value exports)
PRINT_NAPI_METHOD(FUNCTION_REQUEST_PREVIEW, NapiInnerPrint::RequestPreview), PRINT_NAPI_METHOD(FUNCTION_REQUEST_PREVIEW, NapiInnerPrint::RequestPreview),
PRINT_NAPI_METHOD(FUNCTION_QUERY_CAPABILITY, NapiInnerPrint::QueryCapability), PRINT_NAPI_METHOD(FUNCTION_QUERY_CAPABILITY, NapiInnerPrint::QueryCapability),
PRINT_NAPI_METHOD(FUNCTION_QUERY_ALL_PRINTJOB, NapiInnerPrint::QueryAllPrintJob), PRINT_NAPI_METHOD(FUNCTION_QUERY_ALL_PRINTJOB, NapiInnerPrint::QueryAllPrintJob),
PRINT_NAPI_METHOD(FUNCTION_QUERY_PRINTJOB_LIST, NapiInnerPrint::QueryAllPrintJob),
PRINT_NAPI_METHOD(FUNCTION_QUERY_PRINTJOB_BYID, NapiInnerPrint::QueryPrintJobById), PRINT_NAPI_METHOD(FUNCTION_QUERY_PRINTJOB_BYID, NapiInnerPrint::QueryPrintJobById),
PRINT_NAPI_METHOD(FUNCTION_REGISTER_EVENT, NapiInnerPrint::On), PRINT_NAPI_METHOD(FUNCTION_REGISTER_EVENT, NapiInnerPrint::On),
PRINT_NAPI_METHOD(FUNCTION_UNREGISTER_EVENT, NapiInnerPrint::Off), PRINT_NAPI_METHOD(FUNCTION_UNREGISTER_EVENT, NapiInnerPrint::Off),

View File

@ -391,8 +391,6 @@ void PrintCupsClient::AddCupsPrintJob(const PrintJob &jobInfo)
{ {
JobParameters *jobParams = BuildJobParameters(jobInfo); JobParameters *jobParams = BuildJobParameters(jobInfo);
if (jobParams == nullptr) { if (jobParams == nullptr) {
PrintServiceAbility::GetInstance()->UpdatePrintJobState(jobParams->serviceJobId, PRINT_JOB_BLOCKED,
PRINT_JOB_BLOCKED_UNKNOWN);
return; return;
} }
DumpJobParameters(jobParams); DumpJobParameters(jobParams);
@ -526,7 +524,7 @@ bool PrintCupsClient::VerifyPrintJob(JobParameters *jobParams, int &num_options,
num_options, options)) == 0) { num_options, options)) == 0) {
PRINT_HILOGE("Unable to cupsCreateJob: %s", cupsLastErrorString()); PRINT_HILOGE("Unable to cupsCreateJob: %s", cupsLastErrorString());
PrintServiceAbility::GetInstance()->UpdatePrintJobState(jobParams->serviceJobId, PRINT_JOB_BLOCKED, PrintServiceAbility::GetInstance()->UpdatePrintJobState(jobParams->serviceJobId, PRINT_JOB_BLOCKED,
PRINT_JOB_BLOCKED_CONNECT_SERVER_ERROR); PRINT_JOB_BLOCKED_SERVER_CONNECTION_ERROR);
return false; return false;
} }
return true; return true;
@ -620,9 +618,11 @@ void PrintCupsClient::MonitorJobState(JobMonitorParam *param, CallbackFunc callb
PRINT_HILOGD("the prevous jobState is the same as current, ignore"); PRINT_HILOGD("the prevous jobState is the same as current, ignore");
continue; continue;
} }
prevousJobStatus->job_state = jobStatus->job_state; if (prevousJobStatus != nullptr) {
strlcpy(prevousJobStatus->printer_state_reasons, jobStatus->printer_state_reasons, prevousJobStatus->job_state = jobStatus->job_state;
strlcpy(prevousJobStatus->printer_state_reasons, jobStatus->printer_state_reasons,
sizeof(jobStatus->printer_state_reasons)); sizeof(jobStatus->printer_state_reasons));
}
JobStatusCallback(param, jobStatus, false); JobStatusCallback(param, jobStatus, false);
} }
httpClose(http); httpClose(http);

View File

@ -123,10 +123,10 @@ enum PrintJobSubState {
PRINT_JOB_BLOCKED_PRINT_PERMISSION_ERROR = 19, // The printing permission is abnormal. PRINT_JOB_BLOCKED_PRINT_PERMISSION_ERROR = 19, // The printing permission is abnormal.
PRINT_JOB_BLOCKED_PRINT_COLOR_PERMISSION_ERROR = 20, // Color printing permission exception PRINT_JOB_BLOCKED_PRINT_COLOR_PERMISSION_ERROR = 20, // Color printing permission exception
PRINT_JOB_BLOCKED_NETWORK_ERROR = 21, // The device is not connected to the network. PRINT_JOB_BLOCKED_NETWORK_ERROR = 21, // The device is not connected to the network.
PRINT_JOB_BLOCKED_CONNECT_SERVER_ERROR = 22, // Unable to connect to the server PRINT_JOB_BLOCKED_SERVER_CONNECTION_ERROR = 22, // Unable to connect to the server
PRINT_JOB_BLOCKED_LARGE_FILE_ERROR = 23, // Large file exception PRINT_JOB_BLOCKED_LARGE_FILE_ERROR = 23, // Large file exception
PRINT_JOB_BLOCKED_PARSE_FILE_ERROR = 24, // File parsing exception. PRINT_JOB_BLOCKED_FILE_PARSING_ERROR = 24, // File parsing exception.
PRINT_JOB_BLOCKED_FILE_CONVERT_SLOWLY = 25, // The file conversion is too slow. PRINT_JOB_BLOCKED_SLOW_FILE_CONVERSION = 25, // The file conversion is too slow.
PRINT_JOB_RUNNING_UPLOADING_FILES = 26, // Uploading file... PRINT_JOB_RUNNING_UPLOADING_FILES = 26, // Uploading file...
PRINT_JOB_RUNNING_CONVERTING_FILES = 27, // Converting files... PRINT_JOB_RUNNING_CONVERTING_FILES = 27, // Converting files...
PRINT_JOB_CREATE_FILE_COMPLETED_SUCCESS = 28, // print job create file succeed PRINT_JOB_CREATE_FILE_COMPLETED_SUCCESS = 28, // print job create file succeed