• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 
16 #ifndef FONT_MANAGER_FONT_NAPI_CALLBACK_H
17 #define FONT_MANAGER_FONT_NAPI_CALLBACK_H
18 
19 #include "napi/native_api.h"
20 #include "napi/native_node_api.h"
21 #include "font_define.h"
22 #include "font_hilog.h"
23 
24 namespace OHOS {
25 namespace Global {
26 namespace FontManager {
27 struct FontNapiCallback {
28     napi_async_work work_;
29     napi_deferred deferred_;
30     std::string value_;
31     std::string errMsg_;
32     bool success_;
33     int errCode_;
34 
FontNapiCallbackFontNapiCallback35     FontNapiCallback() : work_(nullptr), deferred_(nullptr), success_(true), errCode_(SUCCESS) {}
36 
SetErrorMsgFontNapiCallback37     void SetErrorMsg(const std::string &msg, int32_t errCode)
38     {
39         errMsg_ = msg;
40         success_ = false;
41         errCode_ = errCode;
42         FONT_LOGE("%{public}s, err = %{public}d", msg.c_str(), errCode_);
43     }
44 };
45 } // namespace FontManager
46 } // namespace Global
47 } // namespace OHOS
48 #endif // FONT_MANAGER_FONT_NAPI_CALLBACK_H
49