diff --git a/fastpair/BUILD b/fastpair/BUILD index 4f0e025e..fe16b91e 100644 --- a/fastpair/BUILD +++ b/fastpair/BUILD @@ -1,6 +1,36 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) + package_group( name = "nearby_fastpair", packages = [ "//fastpair/...", ], ) + +cc_library( + name = "fastpair_controller", + srcs = [], + hdrs = [ + "fast_pair_controller.h", + ], + copts = ["-Ithird_party"], + visibility = [ + "//fastpair:__subpackages__", + ], + deps = [ + ], +) diff --git a/fastpair/client/windows/BUILD b/fastpair/client/windows/BUILD new file mode 100644 index 00000000..c7f55462 --- /dev/null +++ b/fastpair/client/windows/BUILD @@ -0,0 +1,61 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +load("//third_party/lexan/build_defs:lexan.bzl", "lexan") + +licenses(["notice"]) + +lexan.cc_windows_dll( + name = "fastpair_adapter", + srcs = [ + "fast_pair_controller_adapter.cc", + ], + hdrs = [ + "fast_pair_controller_adapter.h", + ], + copts = [ + "-Ithird_party", + ], + defines = [ + "_WIN32_WINNT=_WIN32_WINNT_WIN10", + ], + tags = ["windows-dll"], + deps = [ + "//fastpair:fastpair_controller", + "@com_google_absl//absl/strings", + ], +) + +lexan.cc_windows_dll( + name = "fastpair_dart", + srcs = [ + "fast_pair_controller_adapter.cc", + "fast_pair_controller_adapter_dart.cc", + ], + hdrs = [ + "fast_pair_controller_adapter.h", + "fast_pair_controller_adapter_dart.h", + ], + copts = [ + "-Ithird_party", + ], + defines = [ + "_WIN32_WINNT=_WIN32_WINNT_WIN10", + ], + tags = ["windows-dll"], + deps = [ + "//fastpair:fastpair_controller", + "//third_party/dart_lang/v2:dart_api_dl", + "@com_google_absl//absl/strings", + ], +) diff --git a/fastpair/client/windows/fast_pair_controller_adapter.cc b/fastpair/client/windows/fast_pair_controller_adapter.cc new file mode 100644 index 00000000..cb03a3a7 --- /dev/null +++ b/fastpair/client/windows/fast_pair_controller_adapter.cc @@ -0,0 +1,37 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "fastpair/client/windows/fast_pair_controller_adapter.h" + +namespace location { +namespace nearby { +namespace fastpair { + +FastPairController *InitFastPairController() { + return new FastPairController(); +} + +void CloseFastPairController(FastPairController *pController) { + if (pController != nullptr) delete pController; +} + +void StartScanning(FastPairController *pController) { +} + +void ServerAccess(FastPairController *pController) { +} + +} // namespace fastpair +} // namespace nearby +} // namespace location diff --git a/fastpair/client/windows/fast_pair_controller_adapter.h b/fastpair/client/windows/fast_pair_controller_adapter.h new file mode 100644 index 00000000..947b4643 --- /dev/null +++ b/fastpair/client/windows/fast_pair_controller_adapter.h @@ -0,0 +1,41 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_ + +#define DLL_EXPORT extern "C" __declspec(dllexport) + +#include "fastpair/fast_pair_controller.h" + +namespace location { +namespace nearby { +namespace fastpair { + +// Initiate a default FastPairController instance. +// Return the instance handle to client +DLL_EXPORT FastPairController *__stdcall InitFastPairController(); + +DLL_EXPORT void __stdcall CloseFastPairController( + FastPairController *pController); + +DLL_EXPORT void __stdcall StartScanning(FastPairController *pController); + +DLL_EXPORT void __stdcall ServerAccess(FastPairController *pController); + +} // namespace fastpair +} // namespace nearby +} // namespace location + +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_ diff --git a/fastpair/client/windows/fast_pair_controller_adapter_dart.cc b/fastpair/client/windows/fast_pair_controller_adapter_dart.cc new file mode 100644 index 00000000..e26fd632 --- /dev/null +++ b/fastpair/client/windows/fast_pair_controller_adapter_dart.cc @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "fastpair/client/windows/fast_pair_controller_adapter_dart.h" + +#include "fastpair/client/windows/fast_pair_controller_adapter.h" + +namespace location { +namespace nearby { +namespace fastpair { + +void StartScanningDart(FastPairController *pController) { + StartScanning(pController); +} + +void ServerAccessDart(FastPairController *pController) { + ServerAccess(pController); +} + +} // namespace fastpair +} // namespace nearby +} // namespace location diff --git a/fastpair/client/windows/fast_pair_controller_adapter_dart.h b/fastpair/client/windows/fast_pair_controller_adapter_dart.h new file mode 100644 index 00000000..c96425f9 --- /dev/null +++ b/fastpair/client/windows/fast_pair_controller_adapter_dart.h @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_ + +#include "third_party/dart_lang/v2/runtime/include/dart_api_dl.h" +#include "fastpair/client/windows/fast_pair_controller_adapter.h" + +namespace location { +namespace nearby { +namespace fastpair { + +DLL_EXPORT void __stdcall StartScanningDart(FastPairController* pController); + +DLL_EXPORT void __stdcall ServerAccessDart(FastPairController* pController); + +} // namespace fastpair +} // namespace nearby +} // namespace location + +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_ diff --git a/fastpair/fast_pair_controller.h b/fastpair/fast_pair_controller.h new file mode 100644 index 00000000..ae162a02 --- /dev/null +++ b/fastpair/fast_pair_controller.h @@ -0,0 +1,37 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_FAST_PAIR_CONTROLLER_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_FAST_PAIR_CONTROLLER_H_ + +#include + +namespace location { +namespace nearby { +namespace fastpair { + +class FastPairController { + public: + ~FastPairController() = default; + + void StartScanning(); + + void ServerAccess(); +}; + +} // namespace fastpair +} // namespace nearby +} // namespace location + +#endif // THIRD_PARTY_NEARBY_FAST_PAIR_FASTPAIR_CONTROLLER_H_