SMACC2
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1// Copyright 2024 RobosoftAI Inc.
2//
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#pragma once
16
17#include <chrono>
18#include <optional>
19#include <string>
20#include <vector>
21
22namespace cl_gcalcli
23{
24
29{
33 ERROR
34};
35
40{
41 std::string id;
42 std::string title;
43 std::string calendar_name;
44 std::string location;
45 std::string description;
46 std::chrono::system_clock::time_point start_time;
47 std::chrono::system_clock::time_point end_time;
48 bool is_all_day = false;
49
53 bool isActiveNow() const
54 {
55 auto now = std::chrono::system_clock::now();
56 return now >= start_time && now < end_time;
57 }
58
62 bool hasStartedWithinMinutes(int minutes) const
63 {
64 auto now = std::chrono::system_clock::now();
65 auto window_start = start_time - std::chrono::minutes(minutes);
66 return now >= window_start && now < end_time;
67 }
68
72 bool willStartWithinMinutes(int minutes) const
73 {
74 auto now = std::chrono::system_clock::now();
75 return now < start_time && now >= (start_time - std::chrono::minutes(minutes));
76 }
77
81 bool hasEnded() const
82 {
83 auto now = std::chrono::system_clock::now();
84 return now >= end_time;
85 }
86
91 {
92 auto now = std::chrono::system_clock::now();
93 auto diff = std::chrono::duration_cast<std::chrono::minutes>(start_time - now);
94 return static_cast<int>(diff.count());
95 }
96};
97
102{
104 std::string gcalcli_path = "gcalcli";
105
107 std::optional<std::string> config_folder;
108
110 std::vector<std::string> calendars;
111
113 std::chrono::seconds poll_interval{30};
114
116 std::chrono::seconds heartbeat_interval{60};
117
119 int agenda_days = 7;
120
123};
124
129{
131 std::string pattern;
132
134 bool use_regex = false;
135
138
140 bool trigger_on_start = true;
141
143 bool trigger_on_end = false;
144
146 bool continuous = false;
147};
148
149} // namespace cl_gcalcli
ConnectionState
Connection state for gcalcli.
Definition types.hpp:29
Represents a Google Calendar event.
Definition types.hpp:40
bool hasEnded() const
Check if the event has ended.
Definition types.hpp:81
std::chrono::system_clock::time_point end_time
Definition types.hpp:47
int minutesUntilStart() const
Get minutes until event starts (negative if already started)
Definition types.hpp:90
bool isActiveNow() const
Check if the event is currently active (ongoing)
Definition types.hpp:53
bool willStartWithinMinutes(int minutes) const
Check if the event will start within the next N minutes.
Definition types.hpp:72
std::string calendar_name
Definition types.hpp:43
std::chrono::system_clock::time_point start_time
Definition types.hpp:46
std::string description
Definition types.hpp:45
bool hasStartedWithinMinutes(int minutes) const
Check if the event has started within the last N minutes.
Definition types.hpp:62
Event watch configuration for CpCalendarEventListener.
Definition types.hpp:129
bool trigger_on_start
Post event when event starts.
Definition types.hpp:140
bool use_regex
True = regex matching, False = exact string matching.
Definition types.hpp:134
bool trigger_on_end
Post event when event ends.
Definition types.hpp:143
bool continuous
Keep watching (true) or one-shot (false)
Definition types.hpp:146
int minutes_before
Trigger N minutes before event starts (0 = at start time)
Definition types.hpp:137
std::string pattern
Pattern to match event titles (regex or exact)
Definition types.hpp:131
Configuration for gcalcli client.
Definition types.hpp:102
std::chrono::seconds poll_interval
How often to poll for agenda updates.
Definition types.hpp:113
std::chrono::seconds heartbeat_interval
How often to check connection health (heartbeat)
Definition types.hpp:116
std::string gcalcli_path
Path to gcalcli executable (default: "gcalcli" from PATH)
Definition types.hpp:104
std::vector< std::string > calendars
Calendars to monitor (empty = all calendars)
Definition types.hpp:110
int agenda_days
Number of days ahead to fetch in agenda.
Definition types.hpp:119
std::optional< std::string > config_folder
Optional config folder for gcalcli (if not using default)
Definition types.hpp:107
int max_consecutive_failures
Number of consecutive failures before connection is considered lost.
Definition types.hpp:122