1 /* 2 * Copyright (C) 2021 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 I_DISTRIBUTEDFILE_SERVICE_H 17 #define I_DISTRIBUTEDFILE_SERVICE_H 18 19 #include "iremote_broker.h" 20 #include "i_filetransfer_callback.h" 21 22 namespace OHOS { 23 namespace Storage { 24 namespace DistributedFile { 25 class IDistributedFileService : public IRemoteBroker { 26 public: 27 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedFile.IDistributedFileService"); 28 // define the message code 29 enum DistributedFileSurfaceCode { 30 INTERFACE1 = 0, 31 SEND_FILE_DISTRIBUTED, 32 OPEN_FILE_FD, 33 REGISTER_NOTIFY_CALLBACK, 34 UN_REGISTER_NOTIFY_CALLBACK, 35 IS_DEVICE_ONLINE 36 }; 37 // define the error code 38 enum { 39 DISTRIBUTEDFILE_SUCCESS = 0, 40 DFS_SUCCESS = 0, 41 DFS_NO_ERROR = 0, 42 DFS_SENDFILE_SUCCESS = 0, 43 DFS_REMOTE_ADDRESS_IS_NULL = -100, 44 DFS_DESCRIPTOR_IS_EMPTY, 45 DFS_SESSION_ID_IS_EMPTY, 46 DFS_WRITE_REPLY_FAIL, 47 DFS_WRITE_REMOTE_OBJECT_FAIL, 48 DFS_WRITE_DESCRIPTOR_TOKEN_FAIL, 49 DFS_CALLBACK_PARAM_ERROR, 50 DFS_NO_SUCH_FILE, 51 DFS_NO_DEVICE_ONLINE, 52 DFS_PARAM_FILE_COUNT_ERROR, 53 DFS_PARAM_DEVICE_ID_ERROR, 54 DFS_MEM_ERROR, 55 DFS_SOFTBUS_SEND_ERROR, 56 DFS_FILE_OP_ERROR, 57 DFS_NOTIFY_CALLBACK_EMPTY, 58 }; 59 enum { 60 DEVICE_NOT_ONLINE, 61 DEVICE_ONLINE, 62 }; 63 virtual int32_t SendFile(const std::string &cid, 64 const std::vector<std::string> &sourceFileList, 65 const std::vector<std::string> &destinationFileList, 66 const uint32_t fileCount) = 0; 67 virtual int32_t OpenFile(int32_t fd, const std::string &fileName, int32_t mode) = 0; 68 virtual int32_t RegisterNotifyCallback(sptr<IFileTransferCallback> &callback) = 0; 69 virtual int32_t UnRegisterNotifyCallback() = 0; 70 virtual int32_t IsDeviceOnline(const std::string &cid) = 0; 71 }; 72 } // namespace DistributedFile 73 } // namespace Storage 74 } // namespace OHOS 75 #endif // I_DISTRIBUTEDFILE_SERVICE_H