• 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 };
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 };
56 
57 struct BundleNameUserInfo {
58     std::string bundleName;
59     int32_t userId;
60     int32_t pid;
61 };
62 
63 const int32_t POSITION_LOCAL = 1;
64 const int32_t POSITION_CLOUD = 2;
65 const int32_t POSITION_BOTH = 3;
66 
67 const int32_t FILE = 0;
68 const int32_t DIRECTORY = 1;
69 
70 const int32_t MILLISECOND_TO_SECOND = 1000;
71 const int32_t SECOND_TO_MILLISECOND = 1000;
72 const int64_t MILLISECOND_TO_NANOSECOND = 1e6;
73 
74 const std::string GALLERY_BUNDLE_NAME = "com.ohos.photos";
75 const std::string MEDIALIBRARY_BUNDLE_NAME = "com.ohos.medialibrary.medialibrarydata";
76 
77 static const std::string CLOUDSYNC_STATUS_KEY = "persist.kernel.cloudsync.status";
78 static const std::string CLOUDSYNC_STATUS_LOGOUT = "0";
79 static const std::string CLOUDSYNC_STATUS_START = "1";
80 static const std::string CLOUDSYNC_STATUS_INC_SYNC = "2";
81 static const std::string CLOUDSYNC_STATUS_FULL_SYNC = "3";
82 static const std::string CLOUDSYNC_STATUS_FINISH = "4";
83 static const std::string CLOUDSYNC_STATUS_SWITCHOFF = "5";
84 
GetCurrentTimeStamp()85 static inline uint64_t GetCurrentTimeStamp()
86 {
87     struct timespec t;
88     clock_gettime(CLOCK_REALTIME, &t);
89     return t.tv_sec * MILLISECOND_TO_NANOSECOND + t.tv_nsec / SECOND_TO_MILLISECOND;
90 }
91 } // namespace OHOS::FileManagement::CloudSync
92 #endif // OHOS_CLOUD_SYNC_SERVICE_DATA_SYNC_CONST_H
93