mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
added ftxui dependency
This commit is contained in:
+1
-1
@@ -107,7 +107,7 @@ cc_library(
|
||||
"platform/platform_util.cc",
|
||||
"platform/platform_util.h",
|
||||
],
|
||||
hdrs = ["platform/linux_sharing_platform.h"],
|
||||
hdrs = ["platform/linux_sharing_platform.h", "nearby_noop_analytics_recorder.h"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":fast_init",
|
||||
|
||||
@@ -6,47 +6,64 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
constexpr std::string_view sock_path = "/tmp/nearby_sharing.sock";
|
||||
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
#include "sharing/linux/platform/linux_sharing_platform.h"
|
||||
#include "sharing/linux/nearby_noop_analytics_recorder.h"
|
||||
#include "sharing/flags/generated/nearby_sharing_feature_flags.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
#include "sharing/nearby_sharing_service_factory.h"
|
||||
#include "sharing/nearby_sharing_settings.h"
|
||||
#include "sharing/share_target.h"
|
||||
#include "sharing/share_target_discovered_callback.h"
|
||||
#include "sharing/transfer_metadata.h"
|
||||
#include "sharing/transfer_update_callback.h"
|
||||
#include "sharing/proto/enums.pb.h"
|
||||
|
||||
|
||||
int main() {
|
||||
// should always be waiting on the socket for new connections
|
||||
int retries = 3;
|
||||
while (retries >= 0) {
|
||||
int server_fd;
|
||||
struct sockaddr_un addr;
|
||||
namespace nearby::sharing::linux {
|
||||
|
||||
server_fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (server_fd == -1) {
|
||||
retries--;
|
||||
continue;
|
||||
}
|
||||
class DiscoveryCallback final : public ShareTargetDiscoveredCallback {
|
||||
public:
|
||||
explicit DiscoveryCallback() {}
|
||||
|
||||
// removes old socket
|
||||
unlink(sock_path.data());
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, sock_path.data(), sizeof(addr.sun_path) - 1);
|
||||
|
||||
if (bind(server_fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
close(server_fd);
|
||||
retries--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (listen(server_fd, 10) == -1) {
|
||||
close(server_fd);
|
||||
retries--;
|
||||
continue;
|
||||
}
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
|
||||
// blocks till connection is present
|
||||
if (accept(server_fd, (struct sockaddr*)&addr, &addr_len)) {
|
||||
close(server_fd);
|
||||
retries--;
|
||||
continue;
|
||||
void OnShareTargetDiscovered(const ShareTarget& share_target) override {
|
||||
std::cout << "discovered target=\"" << share_target.device_name
|
||||
<< "\" id=" << share_target.id << std::endl;
|
||||
if (share_target.receive_disabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void OnShareTargetLost(const ShareTarget& share_target) override {
|
||||
std::cout << "lost target=\"" << share_target.device_name
|
||||
<< "\" id=" << share_target.id << std::endl;
|
||||
}
|
||||
|
||||
void OnShareTargetUpdated(const ShareTarget& share_target) override {
|
||||
std::cout << "updated target=\"" << share_target.device_name
|
||||
<< "\" id=" << share_target.id << std::endl;
|
||||
OnShareTargetDiscovered(share_target);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto analytics_recorder = nearby::sharing::linux::NoOpAnalyticsRecorder();
|
||||
auto linux_platform = nearby::sharing::linux::LinuxSharingPlatform("LinuxShare");
|
||||
auto service_ = nearby::sharing::NearbySharingServiceFactory::GetInstance()->CreateSharingService(
|
||||
linux_platform, &analytics_recorder, /*event_logger=*/nullptr,
|
||||
/*supports_file_sync=*/false);
|
||||
if (service_ == nullptr) {
|
||||
std::cerr << "failed to create NearbySharingService" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DELEGATE_SCRIPT="${SCRIPT_DIR}/install_nearby_sharing_service.sh"
|
||||
|
||||
if [[ ! -x "${DELEGATE_SCRIPT}" ]]; then
|
||||
echo "Missing installer: ${DELEGATE_SCRIPT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<'MSG'
|
||||
install_nearby_connections_service.sh is deprecated.
|
||||
Installing Nearby Sharing API artifacts instead.
|
||||
MSG
|
||||
|
||||
exec "${DELEGATE_SCRIPT}" "$@"
|
||||
@@ -1,157 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
TARGET="//sharing/linux:nearby_sharing_api_shared"
|
||||
HEADER_SRC="sharing/linux/nearby_sharing_api.h"
|
||||
BAZEL_CMD="${BAZEL:-bazel}"
|
||||
PREFIX="/usr/local"
|
||||
LIBDIR=""
|
||||
INCLUDEDIR=""
|
||||
SKIP_BUILD=0
|
||||
NEEDS_ELEVATION=0
|
||||
INSTALL_PREFIX=()
|
||||
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: $0 [options]
|
||||
|
||||
Builds and installs the Nearby Sharing shared library and public header.
|
||||
|
||||
Options:
|
||||
--prefix DIR Install prefix (default: /usr/local)
|
||||
--libdir DIR Library directory (default: <prefix>/lib)
|
||||
--includedir DIR Include root directory (default: <prefix>/include)
|
||||
--bazel CMD Bazel command (default: bazel or env BAZEL)
|
||||
--skip-build Skip bazel build step and only install from bazel-bin
|
||||
-h, --help Show this help
|
||||
|
||||
Examples:
|
||||
$0
|
||||
sudo $0
|
||||
sudo $0 --prefix /usr
|
||||
sudo $0 --bazel /usr/bin/bazel
|
||||
USAGE
|
||||
}
|
||||
|
||||
run_bazel() {
|
||||
if [[ "$(id -u)" -eq 0 && -n "${SUDO_USER:-}" ]]; then
|
||||
local caller_home
|
||||
caller_home="$(getent passwd "$SUDO_USER" | cut -d: -f6)"
|
||||
if [[ -z "$caller_home" ]]; then
|
||||
echo "Failed to resolve home directory for SUDO_USER=$SUDO_USER" >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo -u "$SUDO_USER" -H env \
|
||||
HOME="$caller_home" \
|
||||
BAZELISK_HOME="${BAZELISK_HOME:-$caller_home/.cache/bazelisk}" \
|
||||
"$BAZEL_CMD" "$@"
|
||||
else
|
||||
"$BAZEL_CMD" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
nearest_existing_parent() {
|
||||
local p="$1"
|
||||
while [[ ! -e "$p" ]]; do
|
||||
p="$(dirname "$p")"
|
||||
done
|
||||
printf '%s\n' "$p"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--prefix)
|
||||
PREFIX="$2"
|
||||
shift 2
|
||||
;;
|
||||
--libdir)
|
||||
LIBDIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--includedir)
|
||||
INCLUDEDIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--bazel)
|
||||
BAZEL_CMD="$2"
|
||||
shift 2
|
||||
;;
|
||||
--skip-build)
|
||||
SKIP_BUILD=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$LIBDIR" ]]; then
|
||||
LIBDIR="${PREFIX}/lib"
|
||||
fi
|
||||
|
||||
if [[ -z "$INCLUDEDIR" ]]; then
|
||||
INCLUDEDIR="${PREFIX}/include"
|
||||
fi
|
||||
|
||||
LIB_PARENT="$(nearest_existing_parent "$LIBDIR")"
|
||||
INCLUDE_PARENT="$(nearest_existing_parent "${INCLUDEDIR}/sharing/linux")"
|
||||
|
||||
if [[ ! -w "$LIB_PARENT" || ! -w "$INCLUDE_PARENT" ]]; then
|
||||
NEEDS_ELEVATION=1
|
||||
fi
|
||||
|
||||
if [[ "$NEEDS_ELEVATION" -eq 1 && "$(id -u)" -ne 0 ]]; then
|
||||
if ! command -v sudo >/dev/null 2>&1; then
|
||||
echo "Install requires elevated privileges, but sudo is not available." >&2
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_PREFIX=(sudo)
|
||||
fi
|
||||
|
||||
if [[ ! -f "$HEADER_SRC" ]]; then
|
||||
echo "Header not found: $HEADER_SRC" >&2
|
||||
echo "Run this script from the workspace root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$SKIP_BUILD" -eq 0 ]]; then
|
||||
echo "[1/4] Building $TARGET"
|
||||
run_bazel build "$TARGET"
|
||||
else
|
||||
echo "[1/4] Skipping build (--skip-build)"
|
||||
fi
|
||||
|
||||
echo "[2/4] Resolving bazel-bin path"
|
||||
BAZEL_BIN="$(run_bazel info bazel-bin)"
|
||||
LIB_SRC="${BAZEL_BIN}/sharing/linux/libnearby_sharing_api_shared.so"
|
||||
|
||||
if [[ ! -f "$LIB_SRC" ]]; then
|
||||
echo "Shared library not found: $LIB_SRC" >&2
|
||||
echo "Expected Bazel output for $TARGET is missing." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[3/4] Installing library and header"
|
||||
"${INSTALL_PREFIX[@]}" install -d "$LIBDIR"
|
||||
"${INSTALL_PREFIX[@]}" install -d "${INCLUDEDIR}/sharing/linux"
|
||||
"${INSTALL_PREFIX[@]}" install -m 0755 "$LIB_SRC" "$LIBDIR/"
|
||||
"${INSTALL_PREFIX[@]}" install -m 0644 "$HEADER_SRC" "${INCLUDEDIR}/sharing/linux/"
|
||||
|
||||
if command -v ldconfig >/dev/null 2>&1; then
|
||||
echo "[4/4] Refreshing dynamic linker cache"
|
||||
"${INSTALL_PREFIX[@]}" ldconfig
|
||||
else
|
||||
echo "[4/4] ldconfig not found; skipping linker cache refresh"
|
||||
fi
|
||||
|
||||
echo "Installed:"
|
||||
echo " library: $LIBDIR/$(basename "$LIB_SRC")"
|
||||
echo " header : ${INCLUDEDIR}/sharing/linux/$(basename "$HEADER_SRC")"
|
||||
@@ -0,0 +1,142 @@
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/share_target.h"
|
||||
|
||||
namespace nearby::sharing::linux {
|
||||
class NoOpAnalyticsRecorder final : public analytics::AnalyticsRecorder {
|
||||
public:
|
||||
void NewEstablishConnection(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus
|
||||
connection_status,
|
||||
const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewAcceptAgreements() override {}
|
||||
void NewDeclineAgreements() override {}
|
||||
void NewAddContact() override {}
|
||||
void NewRemoveContact() override {}
|
||||
void NewTapFeedback() override {}
|
||||
void NewTapHelp() override {}
|
||||
void NewLaunchDeviceContactConsent(
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus status)
|
||||
override {}
|
||||
void NewAdvertiseDevicePresenceEnd(int64_t session_id) override {}
|
||||
void NewAdvertiseDevicePresenceStart(
|
||||
int64_t session_id, proto::DeviceVisibility visibility,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
proto::DataUsage data_usage,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewDescribeAttachments(const AttachmentContainer& attachments) override {}
|
||||
void NewDiscoverShareTarget(
|
||||
const ShareTarget& share_target, int64_t session_id,
|
||||
int64_t latency_since_scanning_start_millis, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package,
|
||||
int64_t latency_since_send_surface_registered_millis) override {}
|
||||
void NewEnableNearbySharing(
|
||||
location::nearby::proto::sharing::NearbySharingStatus status) override {}
|
||||
void NewOpenReceivedAttachments(const AttachmentContainer& attachments,
|
||||
int64_t session_id) override {}
|
||||
void NewProcessReceivedAttachmentsEnd(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus status)
|
||||
override {}
|
||||
void NewReceiveAttachmentsEnd(
|
||||
int64_t session_id, int64_t received_bytes,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewReceiveAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments) override {}
|
||||
void NewReceiveFastInitialization(
|
||||
int64_t timeElapseSinceScreenUnlockMillis) override {}
|
||||
void NewAcceptFastInitialization() override {}
|
||||
void NewDismissFastInitialization() override {}
|
||||
void NewReceiveIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewRespondToIntroduction(
|
||||
location::nearby::proto::sharing::ResponseToIntroduction action,
|
||||
int64_t session_id) override {}
|
||||
void NewTapPrivacyNotification() override {}
|
||||
void NewDismissPrivacyNotification() override {}
|
||||
void NewScanForShareTargetsEnd(int64_t session_id) override {}
|
||||
void NewScanForShareTargetsStart(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
analytics::AnalyticsInformation analytics_information, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewSendAttachmentsEnd(
|
||||
int64_t session_id, int64_t sent_bytes, const ShareTarget& share_target,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
int transfer_position, int concurrent_connections,
|
||||
int64_t duration_millis, std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::ConnectionLayerStatus
|
||||
connection_layer_status,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments,
|
||||
int transfer_position,
|
||||
int concurrent_connections,
|
||||
bool advanced_protection_enabled,
|
||||
bool advanced_protection_mismatch) override {}
|
||||
void NewSendFastInitialization() override {}
|
||||
void NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target) override {}
|
||||
void NewSendIntroduction(
|
||||
ShareTargetType target_type, int64_t session_id,
|
||||
location::nearby::proto::sharing::DeviceRelationship relationship,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
int transfer_position, int concurrent_connections,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSetVisibility(proto::DeviceVisibility src_visibility,
|
||||
proto::DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis) override {}
|
||||
void NewDeviceSettings(analytics::AnalyticsDeviceSettings settings) override {
|
||||
}
|
||||
void NewSetDataUsage(proto::DataUsage original_preference,
|
||||
proto::DataUsage preference) override {}
|
||||
void NewAddQuickSettingsTile() override {}
|
||||
void NewRemoveQuickSettingsTile() override {}
|
||||
void NewTapQuickSettingsTile() override {}
|
||||
void NewToggleShowNotification(
|
||||
location::nearby::proto::sharing::ShowNotificationStatus prev_status,
|
||||
location::nearby::proto::sharing::ShowNotificationStatus current_status)
|
||||
override {}
|
||||
void NewSetDeviceName(int device_name_size) override {}
|
||||
void NewRequestSettingPermissions(
|
||||
location::nearby::proto::sharing::PermissionRequestType type,
|
||||
location::nearby::proto::sharing::PermissionRequestResult result)
|
||||
override {}
|
||||
void NewInstallAPKStatus(
|
||||
location::nearby::proto::sharing::InstallAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewVerifyAPKStatus(
|
||||
location::nearby::proto::sharing::VerifyAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewRpcCallStatus(absl::string_view rpc_name, RpcDirection direction,
|
||||
int error_code, absl::Duration latency) override {}
|
||||
int64_t GenerateNextId() override { return next_id_++; }
|
||||
|
||||
private:
|
||||
std::atomic<int64_t> next_id_{1};
|
||||
};
|
||||
}
|
||||
@@ -29,23 +29,16 @@
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "internal/base/file_path.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "proto/sharing_enums.pb.h"
|
||||
#include "sharing/advertisement.h"
|
||||
#include "sharing/analytics/analytics_device_settings.h"
|
||||
#include "sharing/analytics/analytics_information.h"
|
||||
#include "sharing/analytics/analytics_recorder.h"
|
||||
#include "sharing/attachment_container.h"
|
||||
#include "sharing/common/nearby_share_enums.h"
|
||||
#include "sharing/file_attachment.h"
|
||||
#include "sharing/linux/platform/linux_sharing_platform.h"
|
||||
#include "sharing/linux/nearby_noop_analytics_recorder.h"
|
||||
#include "sharing/flags/generated/nearby_sharing_feature_flags.h"
|
||||
#include "sharing/nearby_sharing_service.h"
|
||||
#include "sharing/nearby_sharing_service_factory.h"
|
||||
@@ -163,127 +156,6 @@ NearbySharingService::StatusCodes WaitForStatus(Invoker invoker) {
|
||||
return *status;
|
||||
}
|
||||
|
||||
class NoOpAnalyticsRecorder final : public analytics::AnalyticsRecorder {
|
||||
public:
|
||||
void NewEstablishConnection(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::EstablishConnectionStatus
|
||||
connection_status,
|
||||
const ShareTarget& share_target, int transfer_position,
|
||||
int concurrent_connections, int64_t duration_millis,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewAcceptAgreements() override {}
|
||||
void NewDeclineAgreements() override {}
|
||||
void NewAddContact() override {}
|
||||
void NewRemoveContact() override {}
|
||||
void NewTapFeedback() override {}
|
||||
void NewTapHelp() override {}
|
||||
void NewLaunchDeviceContactConsent(
|
||||
location::nearby::proto::sharing::ConsentAcceptanceStatus status)
|
||||
override {}
|
||||
void NewAdvertiseDevicePresenceEnd(int64_t session_id) override {}
|
||||
void NewAdvertiseDevicePresenceStart(
|
||||
int64_t session_id, proto::DeviceVisibility visibility,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
proto::DataUsage data_usage,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewDescribeAttachments(const AttachmentContainer& attachments) override {}
|
||||
void NewDiscoverShareTarget(
|
||||
const ShareTarget& share_target, int64_t session_id,
|
||||
int64_t latency_since_scanning_start_millis, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package,
|
||||
int64_t latency_since_send_surface_registered_millis) override {}
|
||||
void NewEnableNearbySharing(
|
||||
location::nearby::proto::sharing::NearbySharingStatus status) override {}
|
||||
void NewOpenReceivedAttachments(const AttachmentContainer& attachments,
|
||||
int64_t session_id) override {}
|
||||
void NewProcessReceivedAttachmentsEnd(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::ProcessReceivedAttachmentsStatus status)
|
||||
override {}
|
||||
void NewReceiveAttachmentsEnd(
|
||||
int64_t session_id, int64_t received_bytes,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewReceiveAttachmentsStart(
|
||||
int64_t session_id, const AttachmentContainer& attachments) override {}
|
||||
void NewReceiveFastInitialization(
|
||||
int64_t timeElapseSinceScreenUnlockMillis) override {}
|
||||
void NewAcceptFastInitialization() override {}
|
||||
void NewDismissFastInitialization() override {}
|
||||
void NewReceiveIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewRespondToIntroduction(
|
||||
location::nearby::proto::sharing::ResponseToIntroduction action,
|
||||
int64_t session_id) override {}
|
||||
void NewTapPrivacyNotification() override {}
|
||||
void NewDismissPrivacyNotification() override {}
|
||||
void NewScanForShareTargetsEnd(int64_t session_id) override {}
|
||||
void NewScanForShareTargetsStart(
|
||||
int64_t session_id,
|
||||
location::nearby::proto::sharing::SessionStatus status,
|
||||
analytics::AnalyticsInformation analytics_information, int64_t flow_id,
|
||||
std::optional<std::string> referrer_package) override {}
|
||||
void NewSendAttachmentsEnd(
|
||||
int64_t session_id, int64_t sent_bytes, const ShareTarget& share_target,
|
||||
location::nearby::proto::sharing::AttachmentTransmissionStatus status,
|
||||
int transfer_position, int concurrent_connections,
|
||||
int64_t duration_millis, std::optional<std::string> referrer_package,
|
||||
location::nearby::proto::sharing::ConnectionLayerStatus
|
||||
connection_layer_status,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendAttachmentsStart(int64_t session_id,
|
||||
const AttachmentContainer& attachments,
|
||||
int transfer_position,
|
||||
int concurrent_connections,
|
||||
bool advanced_protection_enabled,
|
||||
bool advanced_protection_mismatch) override {}
|
||||
void NewSendFastInitialization() override {}
|
||||
void NewSendStart(int64_t session_id, int transfer_position,
|
||||
int concurrent_connections,
|
||||
const ShareTarget& share_target) override {}
|
||||
void NewSendIntroduction(
|
||||
ShareTargetType target_type, int64_t session_id,
|
||||
location::nearby::proto::sharing::DeviceRelationship relationship,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSendIntroduction(
|
||||
int64_t session_id, const ShareTarget& share_target,
|
||||
int transfer_position, int concurrent_connections,
|
||||
location::nearby::proto::sharing::OSType share_target_os_type) override {}
|
||||
void NewSetVisibility(proto::DeviceVisibility src_visibility,
|
||||
proto::DeviceVisibility dst_visibility,
|
||||
int64_t duration_millis) override {}
|
||||
void NewDeviceSettings(analytics::AnalyticsDeviceSettings settings) override {
|
||||
}
|
||||
void NewSetDataUsage(proto::DataUsage original_preference,
|
||||
proto::DataUsage preference) override {}
|
||||
void NewAddQuickSettingsTile() override {}
|
||||
void NewRemoveQuickSettingsTile() override {}
|
||||
void NewTapQuickSettingsTile() override {}
|
||||
void NewToggleShowNotification(
|
||||
location::nearby::proto::sharing::ShowNotificationStatus prev_status,
|
||||
location::nearby::proto::sharing::ShowNotificationStatus current_status)
|
||||
override {}
|
||||
void NewSetDeviceName(int device_name_size) override {}
|
||||
void NewRequestSettingPermissions(
|
||||
location::nearby::proto::sharing::PermissionRequestType type,
|
||||
location::nearby::proto::sharing::PermissionRequestResult result)
|
||||
override {}
|
||||
void NewInstallAPKStatus(
|
||||
location::nearby::proto::sharing::InstallAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewVerifyAPKStatus(
|
||||
location::nearby::proto::sharing::VerifyAPKStatus status,
|
||||
location::nearby::proto::sharing::ApkSource source) override {}
|
||||
void NewRpcCallStatus(absl::string_view rpc_name, RpcDirection direction,
|
||||
int error_code, absl::Duration latency) override {}
|
||||
int64_t GenerateNextId() override { return next_id_++; }
|
||||
|
||||
private:
|
||||
std::atomic<int64_t> next_id_{1};
|
||||
};
|
||||
|
||||
struct CliState {
|
||||
std::mutex mutex;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
||||
|
||||
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
|
||||
|
||||
refresh_compile_commands(
|
||||
name = "refresh_compile_commands",
|
||||
|
||||
# Specify the targets of interest.
|
||||
# For example, specify a dict of targets and any flags required to build.
|
||||
targets = {
|
||||
":tui" : "",
|
||||
},
|
||||
# No need to add flags already in .bazelrc. They're automatically picked up.
|
||||
# If you don't need flags, a list of targets is also okay, as is a single target string.
|
||||
# Wildcard patterns, like //... for everything, *are* allowed here, just like a build.
|
||||
# As are additional targets (+) and subtractions (-), like in bazel query https://docs.bazel.build/versions/main/query.html#expressions
|
||||
# And if you're working on a header-only library, specify a test or binary target that compiles it.
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "tui",
|
||||
srcs = [
|
||||
"main.cc",
|
||||
],
|
||||
deps = [
|
||||
"@ftxui//:ftxui",
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
#include "ftxui/screen/screen.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
using namespace ftxui;
|
||||
auto document = text(L"Hello, FTXUI 6.1.9!") | border;
|
||||
auto screen = Screen::Create(Dimension::Fit(document));
|
||||
|
||||
Render(screen, document);
|
||||
screen.Print();
|
||||
|
||||
// Wait for user input before exiting.
|
||||
std::cout << '\n' << "Press Enter to exit..." << std::flush;
|
||||
std::cin.ignore(9999, '\n');
|
||||
std::cin.clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user