• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_
17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_
18 
19 #include <string>
20 #include <variant>
21 #include <unordered_map>
22 #include "medialibrary_type_const.h"
23 
24 namespace OHOS {
25 namespace Media {
26 
27 constexpr int MEMBER_TYPE_INT32 = 0;
28 constexpr int MEMBER_TYPE_INT64 = 1;
29 constexpr int MEMBER_TYPE_STRING = 2;
30 
31 /**
32  * @brief Class for filling all file asset parameters
33  *
34  * @since 1.0
35  * @version 1.0
36  */
37 class FileAsset {
38 public:
39     FileAsset();
40     virtual ~FileAsset() = default;
41 
42     int32_t GetId() const;
43     void SetId(int32_t id);
44 
45     int32_t GetCount() const;
46     void SetCount(int32_t count);
47 
48     const std::string &GetUri() const;
49     void SetUri(const std::string &uri);
50 
51     const std::string &GetPath() const;
52     void SetPath(const std::string &path);
53 
54     const std::string &GetRelativePath() const;
55     void SetRelativePath(const std::string &relativePath);
56 
57     const std::string &GetMimeType() const;
58     void SetMimeType(const std::string &mimeType);
59 
60     MediaType GetMediaType() const;
61     void SetMediaType(MediaType mediaType);
62 
63     const std::string &GetDisplayName() const;
64     void SetDisplayName(const std::string &displayName);
65 
66     int64_t GetSize() const;
67     void SetSize(int64_t size);
68 
69     int64_t GetDateAdded() const;
70     void SetDateAdded(int64_t dataAdded);
71 
72     int64_t GetDateModified() const;
73     void SetDateModified(int64_t dateModified);
74 
75     const std::string &GetTitle() const;
76     void SetTitle(const std::string &title);
77 
78     const std::string &GetArtist() const;
79     void SetArtist(const std::string &artist);
80 
81     const std::string &GetAlbum() const;
82     void SetAlbum(const std::string &album);
83 
84     int32_t GetWidth() const;
85     void SetWidth(int32_t width);
86 
87     int32_t GetHeight() const;
88     void SetHeight(int32_t height);
89 
90     int32_t GetDuration() const;
91     void SetDuration(int32_t duration);
92 
93     int32_t GetOrientation() const;
94     void SetOrientation(int32_t orientation);
95 
96     int32_t GetAlbumId() const;
97     void SetAlbumId(int32_t albumId);
98 
99     const std::string &GetAlbumName() const;
100     void SetAlbumName(const std::string &albumName);
101 
102     int32_t GetParent() const;
103     void SetParent(int32_t parent);
104     const std::string &GetAlbumUri() const;
105     const std::string &GetTypeMask() const;
106     void SetTypeMask(const std::string &typeMask);
107     void SetAlbumUri(const std::string &albumUri);
108     int64_t GetDateTaken() const;
109     void SetDateTaken(int64_t dataTaken);
110 
111     bool IsPending() const;
112     void SetPending(bool isPending);
113     int64_t GetTimePending() const;
114     void SetTimePending(int64_t timePending);
115 
116     bool IsFavorite() const;
117     void SetFavorite(bool isFavorite);
118     int64_t GetDateTrashed() const;
119     void SetDateTrashed(int64_t dateTrashed);
120 
121     const std::string &GetSelfId() const;
122     void SetSelfId(const std::string &selfId);
123     int32_t GetIsTrash() const;
124     void SetIsTrash(int32_t isTrash);
125 
126     const std::string &GetRecyclePath() const;
127     void SetRecyclePath(const std::string &recyclePath);
128 
129     ResultNapiType GetResultNapiType() const;
130     void SetResultNapiType(const ResultNapiType type);
131 
132     int32_t CreateAsset(const std::string &filePath);
133     int32_t ModifyAsset(const std::string &oldPath, const std::string &newPath);
134     int32_t DeleteAsset(const std::string &filePath);
135     static int32_t OpenAsset(const std::string &filePath, const std::string &mode);
136     bool IsFileExists(const std::string &filePath);
137     const std::string &GetStrMember(const std::string &name) const;
138     int32_t GetInt32Member(const std::string &name) const;
139     int64_t GetInt64Member(const std::string &name) const;
140     std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string>> &GetMemberMap();
141     std::variant<int32_t, int64_t, std::string> &GetMemberValue(const std::string &name);
142 private:
143     std::string albumUri_;
144     std::string typeMask_;
145     ResultNapiType resultNapiType_;
146     int32_t count_;
147     std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string>> member_;
148 };
149 } // namespace Media
150 } // namespace OHOS
151 
152 #endif  // INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_
153