• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     POWER_CONNECT_TRIGGER,
41     SCREEN_OFF_TRIGGER,
42 };
43 
44 enum class ThumbState : int32_t {
45     DOWNLOADED,
46     LCD_TO_DOWNLOAD,
47     THM_TO_DOWNLOAD,
48     TO_DOWNLOAD,
49 };
50 
51 struct LocalInfo {
52     std::string parentCloudId;
53     std::string fileName;
54     int64_t mdirtyTime;
55     int64_t fdirtyTime;
56     int64_t recycledTime;
57     int64_t rowId;
58     int32_t thm_flag;
59     int32_t lcd_flag;
60     int32_t dirtyType;
61 };
62 
63 struct BundleNameUserInfo {
64     std::string bundleName;
65     int32_t userId;
66     int32_t pid;
67 };
68 
69 const int32_t POSITION_LOCAL = 1;
70 const int32_t POSITION_CLOUD = 2;
71 const int32_t POSITION_BOTH = 3;
72 
73 const int32_t DOWNLOADED_THM = 0;
74 const int32_t TO_DOWNLOAD_THM = 1;
75 const int32_t NO_THM_TO_DOWNLOAD = 2;
76 const int32_t THM_DENTRY_INSERTED = 3;
77 
78 const int32_t FILE = 0;
79 const int32_t DIRECTORY = 1;
80 
81 const int32_t MILLISECOND_TO_SECOND = 1000;
82 const int32_t SECOND_TO_MILLISECOND = 1000;
83 const int64_t MILLISECOND_TO_NANOSECOND = 1e6;
84 const uint64_t TWELVE_HOURS_MILLISECOND = 12 * 60 * 60 * SECOND_TO_MILLISECOND;
85 
86 const int32_t NOT_IN_TRASH = 0;
87 const int32_t NOT_IN_PENDING = 0;
88 const int32_t NOT_HIDDEN = 0;
89 const int32_t NOT_TEMP_FILE = 0;
90 const int32_t IS_BURST_COVER = 1;
91 
92 const std::string HDC_BUNDLE_NAME = "com.ohos.ailife";
93 const std::string GALLERY_BUNDLE_NAME = "com.ohos.photos";
94 const std::string MEDIALIBRARY_BUNDLE_NAME = "com.ohos.medialibrary.medialibrarydata";
95 
96 static const std::string CLOUDSYNC_STATUS_KEY = "persist.kernel.cloudsync.status";
97 static const std::string CLOUDSYNC_STATUS_LOGOUT = "0";
98 static const std::string CLOUDSYNC_STATUS_START = "1";
99 static const std::string CLOUDSYNC_STATUS_INC_SYNC = "2";
100 static const std::string CLOUDSYNC_STATUS_FULL_SYNC = "3";
101 static const std::string CLOUDSYNC_STATUS_FINISH = "4";
102 static const std::string CLOUDSYNC_STATUS_SWITCHOFF = "5";
103 static const std::string CLOUDSYNC_STATUS_CLEANING = "6";
104 
105 static const std::string CLOUDSYNC_SWITCH_STATUS = "persist.kernel.cloudsync.switch_status";
106 
GetCurrentTimeStamp()107 static inline uint64_t GetCurrentTimeStamp()
108 {
109     struct timespec t;
110     clock_gettime(CLOCK_REALTIME, &t);
111     return t.tv_sec * MILLISECOND_TO_NANOSECOND + t.tv_nsec / SECOND_TO_MILLISECOND;
112 }
113 
GetCurrentTimeStampMs()114 static inline uint64_t GetCurrentTimeStampMs()
115 {
116     struct timespec t;
117     clock_gettime(CLOCK_REALTIME, &t);
118     return t.tv_sec * SECOND_TO_MILLISECOND + t.tv_nsec / MILLISECOND_TO_NANOSECOND;
119 }
120 } // namespace OHOS::FileManagement::CloudSync
121 #endif // OHOS_CLOUD_SYNC_SERVICE_DATA_SYNC_CONST_H
122