1 /*
2  * Copyright (c) 2023 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 #ifndef OHOS_CLOUD_SYNC_SERVICE_DATA_SYNC_CONST_H
16 #define OHOS_CLOUD_SYNC_SERVICE_DATA_SYNC_CONST_H
17 
18 #include <set>
19 #include <string>
20 namespace OHOS::FileManagement::CloudSync {
21 
22 enum CleanAction {
23     RETAIN_DATA = 0,
24     CLEAR_DATA
25 };
26 
27 enum AlbumSource {
28     ALBUM_FROM_LOCAL = 1,
29     ALBUM_FROM_CLOUD = 2
30 };
31 
32 enum class SyncTriggerType : int32_t {
33     APP_TRIGGER,
34     CLOUD_TRIGGER,
35     PENDING_TRIGGER,
36     BATTERY_OK_TRIGGER,
37     NETWORK_AVAIL_TRIGGER,
38     TASK_TRIGGER,
39     SYSTEM_LOAD_TRIGGER,
40 };
41 
42 enum class ThumbState : int32_t {
43     DOWNLOADED,
44     LCD_TO_DOWNLOAD,
45     THM_TO_DOWNLOAD,
46     TO_DOWNLOAD,
47 };
48 
49 struct LocalInfo {
50     std::string parentCloudId;
51     std::string fileName;
52     int64_t mdirtyTime;
53     int64_t fdirtyTime;
54     int64_t recycledTime;
55     int64_t rowId;
56 };
57 
58 struct BundleNameUserInfo {
59     std::string bundleName;
60     int32_t userId;
61     int32_t pid;
62 };
63 
64 const int32_t POSITION_LOCAL = 1;
65 const int32_t POSITION_CLOUD = 2;
66 const int32_t POSITION_BOTH = 3;
67 
68 const int32_t FILE = 0;
69 const int32_t DIRECTORY = 1;
70 
71 const int32_t MILLISECOND_TO_SECOND = 1000;
72 const int32_t SECOND_TO_MILLISECOND = 1000;
73 const int64_t MILLISECOND_TO_NANOSECOND = 1e6;
74 
75 const std::string GALLERY_BUNDLE_NAME = "com.ohos.photos";
76 const std::string MEDIALIBRARY_BUNDLE_NAME = "com.ohos.medialibrary.medialibrarydata";
77 
78 static const std::string CLOUDSYNC_STATUS_KEY = "persist.kernel.cloudsync.status";
79 static const std::string CLOUDSYNC_STATUS_LOGOUT = "0";
80 static const std::string CLOUDSYNC_STATUS_START = "1";
81 static const std::string CLOUDSYNC_STATUS_INC_SYNC = "2";
82 static const std::string CLOUDSYNC_STATUS_FULL_SYNC = "3";
83 static const std::string CLOUDSYNC_STATUS_FINISH = "4";
84 static const std::string CLOUDSYNC_STATUS_SWITCHOFF = "5";
85 
GetCurrentTimeStamp()86 static inline uint64_t GetCurrentTimeStamp()
87 {
88     struct timespec t;
89     clock_gettime(CLOCK_REALTIME, &t);
90     return t.tv_sec * MILLISECOND_TO_NANOSECOND + t.tv_nsec / SECOND_TO_MILLISECOND;
91 }
92 } // namespace OHOS::FileManagement::CloudSync
93 #endif // OHOS_CLOUD_SYNC_SERVICE_DATA_SYNC_CONST_H
94