• 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 FRAMEWORKS_ANI_SRC_INCLUDE_PHOTO_ALBUM_ANI_H
17 #define FRAMEWORKS_ANI_SRC_INCLUDE_PHOTO_ALBUM_ANI_H
18 
19 #include <ani.h>
20 #include "photo_album.h"
21 #include "datashare_predicates.h"
22 #include "datashare_values_bucket.h"
23 #include "fetch_result.h"
24 #include "file_asset.h"
25 #include "ani_error.h"
26 
27 namespace OHOS {
28 namespace Media {
29 #define EXPORT __attribute__ ((visibility ("default")))
30 class PhotoAlbumAni {
31 public:
32     EXPORT PhotoAlbumAni();
33     EXPORT ~PhotoAlbumAni();
34 
35     EXPORT static ani_status PhotoAccessInit(ani_env *env);
36     EXPORT static ani_object CreatePhotoAlbumAni(ani_env *env, std::unique_ptr<PhotoAlbum> &albumData);
37     EXPORT static ani_object CreatePhotoAlbumAni(ani_env *env, std::shared_ptr<PhotoAlbum> &albumData);
38     EXPORT static PhotoAlbumAni* UnwrapPhotoAlbumObject(ani_env *env, ani_object object);
39 
40     std::shared_ptr<PhotoAlbum> GetPhotoAlbumInstance() const;
41 
42 private:
43     EXPORT void SetPhotoAlbumAniProperties();
44     EXPORT static ani_object PhotoAlbumAniConstructor(ani_env *env, [[maybe_unused]] ani_class clazz);
45     EXPORT static ani_object CreateEmptyPhotoAlbumAni(ani_env *env, ani_class clazz);
46     EXPORT static void PhotoAlbumAniDestructor(ani_env *env, ani_object object);
47 
48     EXPORT static ani_object PhotoAccessGetPhotoAssets(ani_env *env, ani_object object, ani_object fetchOptions);
49     EXPORT static ani_object PhotoAccessGetPhotoAssetsSync(ani_env *env, ani_object object, ani_object fetchOptions);
50     EXPORT static void PhotoAccessHelperCommitModify(ani_env *env, ani_object object);
51     EXPORT static void PhotoAccessHelperAddAssets(ani_env *env, ani_object object, ani_object photoAssets);
52     EXPORT static void PhotoAccessHelperRemoveAssets(ani_env *env, ani_object object, ani_object photoAssets);
53     EXPORT static void PhotoAccessHelperRecoverPhotos(ani_env *env, ani_object object, ani_object photoAssets);
54     EXPORT static void PhotoAccessHelperDeletePhotos(ani_env *env, ani_object object, ani_object photoAssets);
55     EXPORT static void PhotoAccessHelperSetCoverUri(ani_env *env, ani_object object, ani_string uri);
56     EXPORT static ani_string PhotoAccessHelperGetFaceId(ani_env *env, ani_object object);
57     EXPORT static ani_double GetImageCount(ani_env *env, ani_object object);
58     EXPORT static ani_double GetVideoCount(ani_env *env, ani_object object);
59 
60     ani_env *env_;
61     std::shared_ptr<PhotoAlbum> photoAlbumPtr;
62     static thread_local PhotoAlbum *pAlbumData_;
63 };
64 
65 struct PhotoAlbumAniContext : public AniError {
66     int32_t changedRows;
67     int32_t newCount;
68     int32_t newImageCount;
69     int32_t newVideoCount;
70     std::vector<std::string> fetchColumn;
71     DataShare::DataSharePredicates predicates;
72     DataShare::DataShareValuesBucket valuesBucket;
73     std::vector<DataShare::DataShareValuesBucket> valuesBuckets;
74     std::string networkId;
75     std::string uri;
76     std::string faceTag;
77     std::unique_ptr<FetchResult<FileAsset>> fetchResult;
78     ResultNapiType resultNapiType;
79 
80     PhotoAlbumAni *objectInfo;
81 };
82 
83 } // namespace Media
84 } // namespace OHOS
85 
86 #endif // FRAMEWORKS_ANI_SRC_INCLUDE_PHOTO_ALBUM_ANI_H