• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_ALBUM_ORDER_NAPI_H_
17 #define INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_ALBUM_ORDER_NAPI_H_
18 
19 #include "album_order.h"
20 
21 #include "datashare_values_bucket.h"
22 #include "fetch_result.h"
23 #include "file_asset.h"
24 #include "napi_error.h"
25 
26 namespace OHOS {
27 namespace Media {
28 #define EXPORT __attribute__ ((visibility ("default")))
29 class AlbumOrderNapi {
30 public:
31     EXPORT AlbumOrderNapi();
32     EXPORT ~AlbumOrderNapi();
33 
34     EXPORT static napi_value PhotoAccessInit(napi_env env, napi_value exports);
35     EXPORT static napi_value CreateAlbumOrderNapi(napi_env env, std::unique_ptr<AlbumOrder> &albumData);
36     EXPORT static napi_value CreateAlbumOrderNapi(napi_env env, std::shared_ptr<AlbumOrder> &albumData);
37 
38     int32_t GetAlbumId() const;
39     int32_t GetAlbumOrder() const;
40     int32_t GetOrderSection() const;
41     int32_t GetOrderType() const;
42     int32_t GetOrderStatus() const;
43 
44     std::shared_ptr<AlbumOrder> GetAlbumOrderInstance() const;
45 
46 private:
47     EXPORT void SetAlbumOrderNapiProperties();
48     EXPORT static napi_value AlbumOrderNapiConstructor(napi_env env, napi_callback_info info);
49     EXPORT static void AlbumOrderNapiDestructor(napi_env env, void *nativeObject, void *finalizeHint);
50 
51     EXPORT static napi_value JSGetAlbumId(napi_env env, napi_callback_info info);
52     EXPORT static napi_value JSSetAlbumId(napi_env env, napi_callback_info info);
53 
54     EXPORT static napi_value JSGetAlbumOrder(napi_env env, napi_callback_info info);
55     EXPORT static napi_value JSSetAlbumOrder(napi_env env, napi_callback_info info);
56 
57     EXPORT static napi_value JSGetOrderSection(napi_env env, napi_callback_info info);
58     EXPORT static napi_value JSSetOrderSection(napi_env env, napi_callback_info info);
59 
60     EXPORT static napi_value JSGetOrderType(napi_env env, napi_callback_info info);
61     EXPORT static napi_value JSSetOrderType(napi_env env, napi_callback_info info);
62 
63     EXPORT static napi_value JSGetOrderStatus(napi_env env, napi_callback_info info);
64     EXPORT static napi_value JSSetOrderStatus(napi_env env, napi_callback_info info);
65 
66     napi_env env_;
67     std::shared_ptr<AlbumOrder> albumOrderPtr;
68     static thread_local AlbumOrder *pOrderData_;
69     static thread_local napi_ref constructor_;
70     static thread_local napi_ref photoAccessConstructor_;
71     static std::mutex mutex_;
72 };
73 } // namespace Media
74 } // namespace OHOS
75 
76 #endif  // INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_PHOTO_ALBUM_NAPI_H_