Class CpGcalcliConnection
Defined in File cp_gcalcli_connection.hpp
Inheritance Relationships
Base Types
public smacc2::ISmaccComponentpublic smacc2::ISmaccUpdatable
Class Documentation
-
class CpGcalcliConnection : public smacc2::ISmaccComponent, public smacc2::ISmaccUpdatable
Component that manages gcalcli connection health.
This component monitors the connection to Google Calendar via gcalcli. It performs periodic heartbeat checks using “gcalcli list” and tracks consecutive failures. After max_consecutive_failures, it emits EvConnectionLost events.
The component uses CpSubprocessExecutor from smacc2 core for command execution.
Public Functions
-
CpGcalcliConnection()
-
virtual ~CpGcalcliConnection() = default
-
void onInitialize() override
-
void configure(const GcalcliConfig &config)
Configure the gcalcli connection parameters.
-
ConnectionState getConnectionState() const
Get current connection state.
-
bool isConnected() const
Check if connected to Google Calendar.
-
bool checkConnection()
Manually trigger a connection check.
- Returns:
true if connection succeeded
-
void restartConnection()
Restart connection after failure.
-
smacc2::client_core_components::SubprocessResult executeGcalcli(const std::string &args, int timeout_ms = 30000)
Execute a gcalcli command.
- Parameters:
args – Command arguments (e.g., “agenda –tsv”)
timeout_ms – Command timeout in milliseconds
- Returns:
SubprocessResult with output and exit code
-
inline const GcalcliConfig &getConfig() const
Get the gcalcli configuration.
-
template<typename T>
inline smacc2::SmaccSignalConnection onConnectionLost(void (T::* callback)(), T *object)
-
template<typename T>
inline smacc2::SmaccSignalConnection onConnectionRestored(void (T::* callback)(), T *object)
-
template<typename T>
inline smacc2::SmaccSignalConnection onAuthenticationRequired(void (T::* callback)(), T *object)
-
template<typename TOrthogonal, typename TSourceObject>
inline void onStateOrthogonalAllocation() Template method for type-safe event posting setup.
Public Members
-
smacc2::SmaccSignal<void()> onConnectionLost_
-
smacc2::SmaccSignal<void()> onConnectionRestored_
-
smacc2::SmaccSignal<void()> onAuthenticationRequired_
-
std::function<void()> postConnectionLostEvent_
-
std::function<void()> postConnectionRestoredEvent_
-
std::function<void()> postAuthenticationRequiredEvent_
Protected Functions
-
void update() override
Periodic update for heartbeat (called by SignalDetector)
-
CpGcalcliConnection()