ladybird/Userland/Libraries/LibCore/TimeZoneWatcher.h
Timothy Flynn 577efcdc32 LibCore: Create a system time zone watcher
This creates platform-dependent monitors to detect when the system time
zone changes. On Linux, we use a file watcher to monitor files such as
/etc/localtime for changes. On macOS, this uses CFNotificationCenter to
be notified by the OS when the time zone changes.

Note: the macOS implementation requires running in a process which is
running the CoreFoundation event loop. Both the AppKit and Qt chromes
are doing so in the UI process, but this means we cannot run this
monitor in the WebContent process.
2024-08-25 09:47:42 +02:00

30 lines
523 B
C++

/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/Function.h>
#include <AK/Noncopyable.h>
#include <AK/NonnullOwnPtr.h>
namespace Core {
class TimeZoneWatcher {
AK_MAKE_NONCOPYABLE(TimeZoneWatcher);
public:
static ErrorOr<NonnullOwnPtr<TimeZoneWatcher>> create();
virtual ~TimeZoneWatcher() = default;
Function<void()> on_time_zone_changed;
protected:
TimeZoneWatcher() = default;
};
}