1 /*
2 * Copyright (c) 2022-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 #include "paste_uri_handler.h"
16
17 #include "pasteboard_hilog.h"
18 #include "remote_uri.h"
19 namespace OHOS::MiscServices {
PasteUriHandler()20 PasteUriHandler::PasteUriHandler()
21 {
22 isPaste_ = true;
23 }
ToUri(int32_t fd)24 std::string PasteUriHandler::ToUri(int32_t fd)
25 {
26 PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "begin");
27 if (fd < 0) {
28 PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "fd not available");
29 return "";
30 }
31 std::string result;
32 int ret = DistributedFS::ModuleRemoteUri::RemoteUri::ConvertUri(fd, result); // transfer fd ownership
33 if (ret != 0) {
34 PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "convert uri from fd failed: %{public}d", ret);
35 return result;
36 }
37 PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "end, %{public}s", result.c_str());
38 return result;
39 }
40 } // namespace OHOS::MiscServices
41